20 */const jt=100,Gt=301,Wt=302,qt=306,Xt=1e3,Zt=1001,Yt=1002,Jt=1003,Kt=1006,Qt=1008,ei=1009,ti=1012,ii=1014,ni=1015,ri=1016,si=1020,ai=1022,oi=1023,hi=1026,ci=1027,li=2300,ui=2301,di=2302,pi=2400,mi=2401,fi=2402,gi=2500,_i=3e3,vi=3001,yi=3007,bi=3002,xi=7680,wi=35044,Mi=35048,Si="300 es";class Ti{addEventListener(e,t){void 0===this._listeners&&(this._listeners={});const i=this._listeners;void 0===i[e]&&(i[e]=[]),-1===i[e].indexOf(t)&&i[e].push(t)}hasEventListener(e,t){if(void 0===this._listeners)return!1;const i=this._listeners;return void 0!==i[e]&&-1!==i[e].indexOf(t)}removeEventListener(e,t){if(void 0===this._listeners)return;const i=this._listeners[e];if(void 0!==i){const e=i.indexOf(t);-1!==e&&i.splice(e,1)}}dispatchEvent(e){if(void 0===this._listeners)return;const t=this._listeners[e.type];if(void 0!==t){e.target=this;const i=t.slice(0);for(let t=0,n=i.length;t<n;t++)i[t].call(this,e);e.target=null}}}let Ci=1234567;const Ei=Math.PI/180,Ai=180/Math.PI,Ii=[];for(let e=0;e<256;e++)Ii[e]=(e<16?"0":"")+e.toString(16);const Ri="undefined"!=typeof crypto&&"randomUUID"in crypto;function Pi(){if(Ri)return crypto.randomUUID().toUpperCase();const e=4294967295*Math.random()|0,t=4294967295*Math.random()|0,i=4294967295*Math.random()|0,n=4294967295*Math.random()|0;return(Ii[255&e]+Ii[e>>8&255]+Ii[e>>16&255]+Ii[e>>24&255]+"-"+Ii[255&t]+Ii[t>>8&255]+"-"+Ii[t>>16&15|64]+Ii[t>>24&255]+"-"+Ii[63&i|128]+Ii[i>>8&255]+"-"+Ii[i>>16&255]+Ii[i>>24&255]+Ii[255&n]+Ii[n>>8&255]+Ii[n>>16&255]+Ii[n>>24&255]).toUpperCase()}function Li(e,t,i){return Math.max(t,Math.min(i,e))}function Di(e,t){return(e%t+t)%t}function Ni(e,t,i){return(1-i)*e+i*t}function $i(e){return 0==(e&e-1)&&0!==e}function ki(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))}var Oi=Object.freeze({__proto__:null,DEG2RAD:Ei,RAD2DEG:Ai,generateUUID:Pi,clamp:Li,euclideanModulo:Di,mapLinear:function(e,t,i,n,r){return n+(e-t)*(r-n)/(i-t)},inverseLerp:function(e,t,i){return e!==t?(i-e)/(t-e):0},lerp:Ni,damp:function(e,t,i,n){return Ni(e,t,1-Math.exp(-i*n))},pingpong:function(e,t=1){return t-Math.abs(Di(e,2*t)-t)},smoothstep:function(e,t,i){return e<=t?0:e>=i?1:(e=(e-t)/(i-t))*e*(3-2*e)},smootherstep:function(e,t,i){return e<=t?0:e>=i?1:(e=(e-t)/(i-t))*e*e*(e*(6*e-15)+10)},randInt:function(e,t){return e+Math.floor(Math.random()*(t-e+1))},randFloat:function(e,t){return e+Math.random()*(t-e)},randFloatSpread:function(e){return e*(.5-Math.random())},seededRandom:function(e){return void 0!==e&&(Ci=e%2147483647),Ci=16807*Ci%2147483647,(Ci-1)/2147483646},degToRad:function(e){return e*Ei},radToDeg:function(e){return e*Ai},isPowerOfTwo:$i,ceilPowerOfTwo:function(e){return Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))},floorPowerOfTwo:ki,setQuaternionFromProperEuler:function(e,t,i,n,r){const s=Math.cos,a=Math.sin,o=s(i/2),h=a(i/2),c=s((t+n)/2),l=a((t+n)/2),u=s((t-n)/2),d=a((t-n)/2),p=s((n-t)/2),m=a((n-t)/2);switch(r){case"XYX":e.set(o*l,h*u,h*d,o*c);break;case"YZY":e.set(h*d,o*l,h*u,o*c);break;case"ZXZ":e.set(h*u,h*d,o*l,o*c);break;case"XZX":e.set(o*l,h*m,h*p,o*c);break;case"YXY":e.set(h*p,o*l,h*m,o*c);break;case"ZYZ":e.set(h*m,h*p,o*l,o*c);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}});class zi{constructor(e=0,t=0){this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e,t){return void 0!==t?(console.warn("THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this)}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e,t){return void 0!==t?(console.warn("THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(this.x-=e.x,this.y-=e.y,this)}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,i=this.y,n=e.elements;return this.x=n[0]*t+n[3]*i+n[6],this.y=n[1]*t+n[4]*i+n[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,i=this.y-e.y;return t*t+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t,i){return void 0!==i&&console.warn("THREE.Vector2: offset has been removed from .fromBufferAttribute()."),this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const i=Math.cos(t),n=Math.sin(t),r=this.x-e.x,s=this.y-e.y;return this.x=r*i-s*n+e.x,this.y=r*n+s*i+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}zi.prototype.isVector2=!0;class Fi{constructor(){this.elements=[1,0,0,0,1,0,0,0,1],arguments.length>0&&console.error("THREE.Matrix3: the constructor no longer reads arguments. use .set() instead.")}set(e,t,i,n,r,s,a,o,h){const c=this.elements;return c[0]=e,c[1]=n,c[2]=a,c[3]=t,c[4]=r,c[5]=o,c[6]=i,c[7]=s,c[8]=h,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],this}extractBasis(e,t,i){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const i=e.elements,n=t.elements,r=this.elements,s=i[0],a=i[3],o=i[6],h=i[1],c=i[4],l=i[7],u=i[2],d=i[5],p=i[8],m=n[0],f=n[3],g=n[6],_=n[1],v=n[4],y=n[7],b=n[2],x=n[5],w=n[8];return r[0]=s*m+a*_+o*b,r[3]=s*f+a*v+o*x,r[6]=s*g+a*y+o*w,r[1]=h*m+c*_+l*b,r[4]=h*f+c*v+l*x,r[7]=h*g+c*y+l*w,r[2]=u*m+d*_+p*b,r[5]=u*f+d*v+p*x,r[8]=u*g+d*y+p*w,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],i=e[1],n=e[2],r=e[3],s=e[4],a=e[5],o=e[6],h=e[7],c=e[8];return t*s*c-t*a*h-i*r*c+i*a*o+n*r*h-n*s*o}invert(){const e=this.elements,t=e[0],i=e[1],n=e[2],r=e[3],s=e[4],a=e[5],o=e[6],h=e[7],c=e[8],l=c*s-a*h,u=a*o-c*r,d=h*r-s*o,p=t*l+i*u+n*d;if(0===p)return this.set(0,0,0,0,0,0,0,0,0);const m=1/p;return e[0]=l*m,e[1]=(n*h-c*i)*m,e[2]=(a*i-n*s)*m,e[3]=u*m,e[4]=(c*t-n*o)*m,e[5]=(n*r-a*t)*m,e[6]=d*m,e[7]=(i*o-h*t)*m,e[8]=(s*t-i*r)*m,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,i,n,r,s,a){const o=Math.cos(r),h=Math.sin(r);return this.set(i*o,i*h,-i*(o*s+h*a)+s+e,-n*h,n*o,-n*(-h*s+o*a)+a+t,0,0,1),this}scale(e,t){const i=this.elements;return i[0]*=e,i[3]*=e,i[6]*=e,i[1]*=t,i[4]*=t,i[7]*=t,this}rotate(e){const t=Math.cos(e),i=Math.sin(e),n=this.elements,r=n[0],s=n[3],a=n[6],o=n[1],h=n[4],c=n[7];return n[0]=t*r+i*o,n[3]=t*s+i*h,n[6]=t*a+i*c,n[1]=-i*r+t*o,n[4]=-i*s+t*h,n[7]=-i*a+t*c,this}translate(e,t){const i=this.elements;return i[0]+=e*i[2],i[3]+=e*i[5],i[6]+=e*i[8],i[1]+=t*i[2],i[4]+=t*i[5],i[7]+=t*i[8],this}equals(e){const t=this.elements,i=e.elements;for(let e=0;e<9;e++)if(t[e]!==i[e])return!1;return!0}fromArray(e,t=0){for(let i=0;i<9;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){const i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e}clone(){return(new this.constructor).fromArray(this.elements)}}function Bi(e){if(0===e.length)return-1/0;let t=e[0];for(let i=1,n=e.length;i<n;++i)e[i]>t&&(t=e[i]);return t}function Ui(e){return document.createElementNS("http://www.w3.org/1999/xhtml",e)}function Vi(e,t=0){let i=3735928559^t,n=1103547991^t;for(let t,r=0;r<e.length;r++)t=e.charCodeAt(r),i=Math.imul(i^t,2654435761),n=Math.imul(n^t,1597334677);return i=Math.imul(i^i>>>16,2246822507)^Math.imul(n^n>>>13,3266489909),n=Math.imul(n^n>>>16,2246822507)^Math.imul(i^i>>>13,3266489909),4294967296*(2097151&n)+(i>>>0)}let Hi;Fi.prototype.isMatrix3=!0;class ji{static getDataURL(e){if(/^data:/i.test(e.src))return e.src;if("undefined"==typeof HTMLCanvasElement)return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{void 0===Hi&&(Hi=Ui("canvas")),Hi.width=e.width,Hi.height=e.height;const i=Hi.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),t=Hi}return t.width>2048||t.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",e),t.toDataURL("image/jpeg",.6)):t.toDataURL("image/png")}}let Gi=0;class Wi extends Ti{constructor(e=Wi.DEFAULT_IMAGE,t=Wi.DEFAULT_MAPPING,i=1001,n=1001,r=1006,s=1008,a=1023,o=1009,h=1,c=3e3){super(),Object.defineProperty(this,"id",{value:Gi++}),this.uuid=Pi(),this.name="",this.image=e,this.mipmaps=[],this.mapping=t,this.wrapS=i,this.wrapT=n,this.magFilter=r,this.minFilter=s,this.anisotropy=h,this.format=a,this.internalFormat=null,this.type=o,this.offset=new zi(0,0),this.repeat=new zi(1,1),this.center=new zi(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Fi,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.encoding=c,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(e){return this.name=e.name,this.image=e.image,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.encoding=e.encoding,this.userData=JSON.parse(JSON.stringify(e.userData)),this}toJSON(e){const t=void 0===e||"string"==typeof e;if(!t&&void 0!==e.textures[this.uuid])return e.textures[this.uuid];const i={metadata:{version:4.5,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,mapping:this.mapping,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,type:this.type,encoding:this.encoding,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};if(void 0!==this.image){const n=this.image;if(void 0===n.uuid&&(n.uuid=Pi()),!t&&void 0===e.images[n.uuid]){let t;if(Array.isArray(n)){t=[];for(let e=0,i=n.length;e<i;e++)n[e].isDataTexture?t.push(qi(n[e].image)):t.push(qi(n[e]))}else t=qi(n);e.images[n.uuid]={uuid:n.uuid,url:t}}i.image=n.uuid}return"{}"!==JSON.stringify(this.userData)&&(i.userData=this.userData),t||(e.textures[this.uuid]=i),i}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(300!==this.mapping)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Xt:e.x=e.x-Math.floor(e.x);break;case Zt:e.x=e.x<0?0:1;break;case Yt:1===Math.abs(Math.floor(e.x)%2)?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x)}if(e.y<0||e.y>1)switch(this.wrapT){case Xt:e.y=e.y-Math.floor(e.y);break;case Zt:e.y=e.y<0?0:1;break;case Yt:1===Math.abs(Math.floor(e.y)%2)?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y)}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){!0===e&&this.version++}}function qi(e){return"undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap?ji.getDataURL(e):e.data?{data:Array.prototype.slice.call(e.data),width:e.width,height:e.height,type:e.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}Wi.DEFAULT_IMAGE=void 0,Wi.DEFAULT_MAPPING=300,Wi.prototype.isTexture=!0;class Xi{constructor(e=0,t=0,i=0,n=1){this.x=e,this.y=t,this.z=i,this.w=n}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,i,n){return this.x=e,this.y=t,this.z=i,this.w=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=void 0!==e.w?e.w:1,this}add(e,t){return void 0!==t?(console.warn("THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this)}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e,t){return void 0!==t?(console.warn("THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this)}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,i=this.y,n=this.z,r=this.w,s=e.elements;return this.x=s[0]*t+s[4]*i+s[8]*n+s[12]*r,this.y=s[1]*t+s[5]*i+s[9]*n+s[13]*r,this.z=s[2]*t+s[6]*i+s[10]*n+s[14]*r,this.w=s[3]*t+s[7]*i+s[11]*n+s[15]*r,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,i,n,r;const s=.01,a=.1,o=e.elements,h=o[0],c=o[4],l=o[8],u=o[1],d=o[5],p=o[9],m=o[2],f=o[6],g=o[10];if(Math.abs(c-u)<s&&Math.abs(l-m)<s&&Math.abs(p-f)<s){if(Math.abs(c+u)<a&&Math.abs(l+m)<a&&Math.abs(p+f)<a&&Math.abs(h+d+g-3)<a)return this.set(1,0,0,0),this;t=Math.PI;const e=(h+1)/2,o=(d+1)/2,_=(g+1)/2,v=(c+u)/4,y=(l+m)/4,b=(p+f)/4;return e>o&&e>_?e<s?(i=0,n=.707106781,r=.707106781):(i=Math.sqrt(e),n=v/i,r=y/i):o>_?o<s?(i=.707106781,n=0,r=.707106781):(n=Math.sqrt(o),i=v/n,r=b/n):_<s?(i=.707106781,n=.707106781,r=0):(r=Math.sqrt(_),i=y/r,n=b/r),this.set(i,n,r,t),this}let _=Math.sqrt((f-p)*(f-p)+(l-m)*(l-m)+(u-c)*(u-c));return Math.abs(_)<.001&&(_=1),this.x=(f-p)/_,this.y=(l-m)/_,this.z=(u-c)/_,this.w=Math.acos((h+d+g-1)/2),this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this.w=Math.max(e.w,Math.min(t.w,this.w)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this.w=Math.max(e,Math.min(t,this.w)),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this.w=this.w<0?Math.ceil(this.w):Math.floor(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this.w=e.w+(t.w-e.w)*i,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t,i){return void 0!==i&&console.warn("THREE.Vector4: offset has been removed from .fromBufferAttribute()."),this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}Xi.prototype.isVector4=!0;class Zi extends Ti{constructor(e,t,i={}){super(),this.width=e,this.height=t,this.depth=1,this.scissor=new Xi(0,0,e,t),this.scissorTest=!1,this.viewport=new Xi(0,0,e,t),this.texture=new Wi(void 0,i.mapping,i.wrapS,i.wrapT,i.magFilter,i.minFilter,i.format,i.type,i.anisotropy,i.encoding),this.texture.isRenderTargetTexture=!0,this.texture.image={width:e,height:t,depth:1},this.texture.generateMipmaps=void 0!==i.generateMipmaps&&i.generateMipmaps,this.texture.internalFormat=void 0!==i.internalFormat?i.internalFormat:null,this.texture.minFilter=void 0!==i.minFilter?i.minFilter:Kt,this.depthBuffer=void 0===i.depthBuffer||i.depthBuffer,this.stencilBuffer=void 0!==i.stencilBuffer&&i.stencilBuffer,this.depthTexture=void 0!==i.depthTexture?i.depthTexture:null}setTexture(e){e.image={width:this.width,height:this.height,depth:this.depth},this.texture=e}setSize(e,t,i=1){this.width===e&&this.height===t&&this.depth===i||(this.width=e,this.height=t,this.depth=i,this.texture.image.width=e,this.texture.image.height=t,this.texture.image.depth=i,this.dispose()),this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return(new this.constructor).copy(this)}copy(e){return this.width=e.width,this.height=e.height,this.depth=e.depth,this.viewport.copy(e.viewport),this.texture=e.texture.clone(),this.texture.image={...this.texture.image},this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.depthTexture=e.depthTexture,this}dispose(){this.dispatchEvent({type:"dispose"})}}Zi.prototype.isWebGLRenderTarget=!0;(class extends Zi{constructor(e,t,i){super(e,t);const n=this.texture;this.texture=[];for(let e=0;e<i;e++)this.texture[e]=n.clone()}setSize(e,t,i=1){if(this.width!==e||this.height!==t||this.depth!==i){this.width=e,this.height=t,this.depth=i;for(let n=0,r=this.texture.length;n<r;n++)this.texture[n].image.width=e,this.texture[n].image.height=t,this.texture[n].image.depth=i;this.dispose()}return this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t),this}copy(e){this.dispose(),this.width=e.width,this.height=e.height,this.depth=e.depth,this.viewport.set(0,0,this.width,this.height),this.scissor.set(0,0,this.width,this.height),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.depthTexture=e.depthTexture,this.texture.length=0;for(let t=0,i=e.texture.length;t<i;t++)this.texture[t]=e.texture[t].clone();return this}}).prototype.isWebGLMultipleRenderTargets=!0;class Yi extends Zi{constructor(e,t,i){super(e,t,i),this.samples=4}copy(e){return super.copy.call(this,e),this.samples=e.samples,this}}Yi.prototype.isWebGLMultisampleRenderTarget=!0;class Ji{constructor(e=0,t=0,i=0,n=1){this._x=e,this._y=t,this._z=i,this._w=n}static slerp(e,t,i,n){return console.warn("THREE.Quaternion: Static .slerp() has been deprecated. Use qm.slerpQuaternions( qa, qb, t ) instead."),i.slerpQuaternions(e,t,n)}static slerpFlat(e,t,i,n,r,s,a){let o=i[n+0],h=i[n+1],c=i[n+2],l=i[n+3];const u=r[s+0],d=r[s+1],p=r[s+2],m=r[s+3];if(0===a)return e[t+0]=o,e[t+1]=h,e[t+2]=c,void(e[t+3]=l);if(1===a)return e[t+0]=u,e[t+1]=d,e[t+2]=p,void(e[t+3]=m);if(l!==m||o!==u||h!==d||c!==p){let e=1-a;const t=o*u+h*d+c*p+l*m,i=t>=0?1:-1,n=1-t*t;if(n>Number.EPSILON){const r=Math.sqrt(n),s=Math.atan2(r,t*i);e=Math.sin(e*s)/r,a=Math.sin(a*s)/r}const r=a*i;if(o=o*e+u*r,h=h*e+d*r,c=c*e+p*r,l=l*e+m*r,e===1-a){const e=1/Math.sqrt(o*o+h*h+c*c+l*l);o*=e,h*=e,c*=e,l*=e}}e[t]=o,e[t+1]=h,e[t+2]=c,e[t+3]=l}static multiplyQuaternionsFlat(e,t,i,n,r,s){const a=i[n],o=i[n+1],h=i[n+2],c=i[n+3],l=r[s],u=r[s+1],d=r[s+2],p=r[s+3];return e[t]=a*p+c*l+o*d-h*u,e[t+1]=o*p+c*u+h*l-a*d,e[t+2]=h*p+c*d+a*u-o*l,e[t+3]=c*p-a*l-o*u-h*d,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,i,n){return this._x=e,this._y=t,this._z=i,this._w=n,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t){if(!e||!e.isEuler)throw new Error("THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.");const i=e._x,n=e._y,r=e._z,s=e._order,a=Math.cos,o=Math.sin,h=a(i/2),c=a(n/2),l=a(r/2),u=o(i/2),d=o(n/2),p=o(r/2);switch(s){case"XYZ":this._x=u*c*l+h*d*p,this._y=h*d*l-u*c*p,this._z=h*c*p+u*d*l,this._w=h*c*l-u*d*p;break;case"YXZ":this._x=u*c*l+h*d*p,this._y=h*d*l-u*c*p,this._z=h*c*p-u*d*l,this._w=h*c*l+u*d*p;break;case"ZXY":this._x=u*c*l-h*d*p,this._y=h*d*l+u*c*p,this._z=h*c*p+u*d*l,this._w=h*c*l-u*d*p;break;case"ZYX":this._x=u*c*l-h*d*p,this._y=h*d*l+u*c*p,this._z=h*c*p-u*d*l,this._w=h*c*l+u*d*p;break;case"YZX":this._x=u*c*l+h*d*p,this._y=h*d*l+u*c*p,this._z=h*c*p-u*d*l,this._w=h*c*l-u*d*p;break;case"XZY":this._x=u*c*l-h*d*p,this._y=h*d*l-u*c*p,this._z=h*c*p+u*d*l,this._w=h*c*l+u*d*p;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+s)}return!1!==t&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const i=t/2,n=Math.sin(i);return this._x=e.x*n,this._y=e.y*n,this._z=e.z*n,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,i=t[0],n=t[4],r=t[8],s=t[1],a=t[5],o=t[9],h=t[2],c=t[6],l=t[10],u=i+a+l;if(u>0){const e=.5/Math.sqrt(u+1);this._w=.25/e,this._x=(c-o)*e,this._y=(r-h)*e,this._z=(s-n)*e}else if(i>a&&i>l){const e=2*Math.sqrt(1+i-a-l);this._w=(c-o)/e,this._x=.25*e,this._y=(n+s)/e,this._z=(r+h)/e}else if(a>l){const e=2*Math.sqrt(1+a-i-l);this._w=(r-h)/e,this._x=(n+s)/e,this._y=.25*e,this._z=(o+c)/e}else{const e=2*Math.sqrt(1+l-i-a);this._w=(s-n)/e,this._x=(r+h)/e,this._y=(o+c)/e,this._z=.25*e}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let i=e.dot(t)+1;return i<Number.EPSILON?(i=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=i):(this._x=0,this._y=-e.z,this._z=e.y,this._w=i)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=i),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Li(this.dot(e),-1,1)))}rotateTowards(e,t){const i=this.angleTo(e);if(0===i)return this;const n=Math.min(1,t/i);return this.slerp(e,n),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return 0===e?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e,t){return void 0!==t?(console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."),this.multiplyQuaternions(e,t)):this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const i=e._x,n=e._y,r=e._z,s=e._w,a=t._x,o=t._y,h=t._z,c=t._w;return this._x=i*c+s*a+n*h-r*o,this._y=n*c+s*o+r*a-i*h,this._z=r*c+s*h+i*o-n*a,this._w=s*c-i*a-n*o-r*h,this._onChangeCallback(),this}slerp(e,t){if(0===t)return this;if(1===t)return this.copy(e);const i=this._x,n=this._y,r=this._z,s=this._w;let a=s*e._w+i*e._x+n*e._y+r*e._z;if(a<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,a=-a):this.copy(e),a>=1)return this._w=s,this._x=i,this._y=n,this._z=r,this;const o=1-a*a;if(o<=Number.EPSILON){const e=1-t;return this._w=e*s+t*this._w,this._x=e*i+t*this._x,this._y=e*n+t*this._y,this._z=e*r+t*this._z,this.normalize(),this._onChangeCallback(),this}const h=Math.sqrt(o),c=Math.atan2(h,a),l=Math.sin((1-t)*c)/h,u=Math.sin(t*c)/h;return this._w=s*l+this._w*u,this._x=i*l+this._x*u,this._y=n*l+this._y*u,this._z=r*l+this._z*u,this._onChangeCallback(),this}slerpQuaternions(e,t,i){this.copy(e).slerp(t,i)}random(){const e=Math.random(),t=Math.sqrt(1-e),i=Math.sqrt(e),n=2*Math.PI*Math.random(),r=2*Math.PI*Math.random();return this.set(t*Math.cos(n),i*Math.sin(r),i*Math.cos(r),t*Math.sin(n))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}}Ji.prototype.isQuaternion=!0;class Ki{constructor(e=0,t=0,i=0){this.x=e,this.y=t,this.z=i}set(e,t,i){return void 0===i&&(i=this.z),this.x=e,this.y=t,this.z=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e,t){return void 0!==t?(console.warn("THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this.z+=e.z,this)}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e,t){return void 0!==t?(console.warn("THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(this.x-=e.x,this.y-=e.y,this.z-=e.z,this)}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e,t){return void 0!==t?(console.warn("THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead."),this.multiplyVectors(e,t)):(this.x*=e.x,this.y*=e.y,this.z*=e.z,this)}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return e&&e.isEuler||console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order."),this.applyQuaternion(en.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(en.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,i=this.y,n=this.z,r=e.elements;return this.x=r[0]*t+r[3]*i+r[6]*n,this.y=r[1]*t+r[4]*i+r[7]*n,this.z=r[2]*t+r[5]*i+r[8]*n,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,i=this.y,n=this.z,r=e.elements,s=1/(r[3]*t+r[7]*i+r[11]*n+r[15]);return this.x=(r[0]*t+r[4]*i+r[8]*n+r[12])*s,this.y=(r[1]*t+r[5]*i+r[9]*n+r[13])*s,this.z=(r[2]*t+r[6]*i+r[10]*n+r[14])*s,this}applyQuaternion(e){const t=this.x,i=this.y,n=this.z,r=e.x,s=e.y,a=e.z,o=e.w,h=o*t+s*n-a*i,c=o*i+a*t-r*n,l=o*n+r*i-s*t,u=-r*t-s*i-a*n;return this.x=h*o+u*-r+c*-a-l*-s,this.y=c*o+u*-s+l*-r-h*-a,this.z=l*o+u*-a+h*-s-c*-r,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,i=this.y,n=this.z,r=e.elements;return this.x=r[0]*t+r[4]*i+r[8]*n,this.y=r[1]*t+r[5]*i+r[9]*n,this.z=r[2]*t+r[6]*i+r[10]*n,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this}cross(e,t){return void 0!==t?(console.warn("THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."),this.crossVectors(e,t)):this.crossVectors(this,e)}crossVectors(e,t){const i=e.x,n=e.y,r=e.z,s=t.x,a=t.y,o=t.z;return this.x=n*o-r*a,this.y=r*s-i*o,this.z=i*a-n*s,this}projectOnVector(e){const t=e.lengthSq();if(0===t)return this.set(0,0,0);const i=e.dot(this)/t;return this.copy(e).multiplyScalar(i)}projectOnPlane(e){return Qi.copy(this).projectOnVector(e),this.sub(Qi)}reflect(e){return this.sub(Qi.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(0===t)return Math.PI/2;const i=this.dot(e)/t;return Math.acos(Li(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,i=this.y-e.y,n=this.z-e.z;return t*t+i*i+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,i){const n=Math.sin(t)*e;return this.x=n*Math.sin(i),this.y=Math.cos(t)*e,this.z=n*Math.cos(i),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,i){return this.x=e*Math.sin(t),this.y=i,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),i=this.setFromMatrixColumn(e,1).length(),n=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=i,this.z=n,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,4*t)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,3*t)}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t,i){return void 0!==i&&console.warn("THREE.Vector3: offset has been removed from .fromBufferAttribute()."),this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=2*(Math.random()-.5),t=Math.random()*Math.PI*2,i=Math.sqrt(1-e**2);return this.x=i*Math.cos(t),this.y=i*Math.sin(t),this.z=e,this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}Ki.prototype.isVector3=!0;const Qi=new Ki,en=new Ji;class tn{constructor(e=new Ki(1/0,1/0,1/0),t=new Ki(-1/0,-1/0,-1/0)){this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){let t=1/0,i=1/0,n=1/0,r=-1/0,s=-1/0,a=-1/0;for(let o=0,h=e.length;o<h;o+=3){const h=e[o],c=e[o+1],l=e[o+2];h<t&&(t=h),c<i&&(i=c),l<n&&(n=l),h>r&&(r=h),c>s&&(s=c),l>a&&(a=l)}return this.min.set(t,i,n),this.max.set(r,s,a),this}setFromBufferAttribute(e){let t=1/0,i=1/0,n=1/0,r=-1/0,s=-1/0,a=-1/0;for(let o=0,h=e.count;o<h;o++){const h=e.getX(o),c=e.getY(o),l=e.getZ(o);h<t&&(t=h),c<i&&(i=c),l<n&&(n=l),h>r&&(r=h),c>s&&(s=c),l>a&&(a=l)}return this.min.set(t,i,n),this.max.set(r,s,a),this}setFromPoints(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const i=rn.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(i),this.max.copy(e).add(i),this}setFromObject(e){return this.makeEmpty(),this.expandByObject(e)}clone(){return(new this.constructor).copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e){e.updateWorldMatrix(!1,!1);const t=e.geometry;void 0!==t&&(null===t.boundingBox&&t.computeBoundingBox(),sn.copy(t.boundingBox),sn.applyMatrix4(e.matrixWorld),this.union(sn));const i=e.children;for(let e=0,t=i.length;e<t;e++)this.expandByObject(i[e]);return this}containsPoint(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y||e.z<this.min.z||e.z>this.max.z)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return!(e.max.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y||e.max.z<this.min.z||e.min.z>this.max.z)}intersectsSphere(e){return this.clampPoint(e.center,rn),rn.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,i;return e.normal.x>0?(t=e.normal.x*this.min.x,i=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,i=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,i+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,i+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,i+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,i+=e.normal.z*this.min.z),t<=-e.constant&&i>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(dn),pn.subVectors(this.max,dn),an.subVectors(e.a,dn),on.subVectors(e.b,dn),hn.subVectors(e.c,dn),cn.subVectors(on,an),ln.subVectors(hn,on),un.subVectors(an,hn);let t=[0,-cn.z,cn.y,0,-ln.z,ln.y,0,-un.z,un.y,cn.z,0,-cn.x,ln.z,0,-ln.x,un.z,0,-un.x,-cn.y,cn.x,0,-ln.y,ln.x,0,-un.y,un.x,0];return!!gn(t,an,on,hn,pn)&&(t=[1,0,0,0,1,0,0,0,1],!!gn(t,an,on,hn,pn)&&(mn.crossVectors(cn,ln),t=[mn.x,mn.y,mn.z],gn(t,an,on,hn,pn)))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return rn.copy(e).clamp(this.min,this.max).sub(e).length()}getBoundingSphere(e){return this.getCenter(e.center),e.radius=.5*this.getSize(rn).length(),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()||(nn[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),nn[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),nn[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),nn[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),nn[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),nn[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),nn[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),nn[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(nn)),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}tn.prototype.isBox3=!0;const nn=[new Ki,new Ki,new Ki,new Ki,new Ki,new Ki,new Ki,new Ki],rn=new Ki,sn=new tn,an=new Ki,on=new Ki,hn=new Ki,cn=new Ki,ln=new Ki,un=new Ki,dn=new Ki,pn=new Ki,mn=new Ki,fn=new Ki;function gn(e,t,i,n,r){for(let s=0,a=e.length-3;s<=a;s+=3){fn.fromArray(e,s);const a=r.x*Math.abs(fn.x)+r.y*Math.abs(fn.y)+r.z*Math.abs(fn.z),o=t.dot(fn),h=i.dot(fn),c=n.dot(fn);if(Math.max(-Math.max(o,h,c),Math.min(o,h,c))>a)return!1}return!0}const _n=new tn,vn=new Ki,yn=new Ki,bn=new Ki;class xn{constructor(e=new Ki,t=-1){this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const i=this.center;void 0!==t?i.copy(t):_n.setFromPoints(e).getCenter(i);let n=0;for(let t=0,r=e.length;t<r;t++)n=Math.max(n,i.distanceToSquared(e[t]));return this.radius=Math.sqrt(n),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){const t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){const i=this.center.distanceToSquared(e);return t.copy(e),i>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){bn.subVectors(e,this.center);const t=bn.lengthSq();if(t>this.radius*this.radius){const e=Math.sqrt(t),i=.5*(e-this.radius);this.center.add(bn.multiplyScalar(i/e)),this.radius+=i}return this}union(e){return yn.subVectors(e.center,this.center).normalize().multiplyScalar(e.radius),this.expandByPoint(vn.copy(e.center).add(yn)),this.expandByPoint(vn.copy(e.center).sub(yn)),this}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return(new this.constructor).copy(this)}}const wn=new Ki,Mn=new Ki,Sn=new Ki,Tn=new Ki,Cn=new Ki,En=new Ki,An=new Ki;class In{constructor(e=new Ki,t=new Ki(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.direction).multiplyScalar(e).add(this.origin)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,wn)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const i=t.dot(this.direction);return i<0?t.copy(this.origin):t.copy(this.direction).multiplyScalar(i).add(this.origin)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=wn.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(wn.copy(this.direction).multiplyScalar(t).add(this.origin),wn.distanceToSquared(e))}distanceSqToSegment(e,t,i,n){Mn.copy(e).add(t).multiplyScalar(.5),Sn.copy(t).sub(e).normalize(),Tn.copy(this.origin).sub(Mn);const r=.5*e.distanceTo(t),s=-this.direction.dot(Sn),a=Tn.dot(this.direction),o=-Tn.dot(Sn),h=Tn.lengthSq(),c=Math.abs(1-s*s);let l,u,d,p;if(c>0)if(l=s*o-a,u=s*a-o,p=r*c,l>=0)if(u>=-p)if(u<=p){const e=1/c;l*=e,u*=e,d=l*(l+s*u+2*a)+u*(s*l+u+2*o)+h}else u=r,l=Math.max(0,-(s*u+a)),d=-l*l+u*(u+2*o)+h;else u=-r,l=Math.max(0,-(s*u+a)),d=-l*l+u*(u+2*o)+h;else u<=-p?(l=Math.max(0,-(-s*r+a)),u=l>0?-r:Math.min(Math.max(-r,-o),r),d=-l*l+u*(u+2*o)+h):u<=p?(l=0,u=Math.min(Math.max(-r,-o),r),d=u*(u+2*o)+h):(l=Math.max(0,-(s*r+a)),u=l>0?r:Math.min(Math.max(-r,-o),r),d=-l*l+u*(u+2*o)+h);else u=s>0?-r:r,l=Math.max(0,-(s*u+a)),d=-l*l+u*(u+2*o)+h;return i&&i.copy(this.direction).multiplyScalar(l).add(this.origin),n&&n.copy(Sn).multiplyScalar(u).add(Mn),d}intersectSphere(e,t){wn.subVectors(e.center,this.origin);const i=wn.dot(this.direction),n=wn.dot(wn)-i*i,r=e.radius*e.radius;if(n>r)return null;const s=Math.sqrt(r-n),a=i-s,o=i+s;return a<0&&o<0?null:a<0?this.at(o,t):this.at(a,t)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(0===t)return 0===e.distanceToPoint(this.origin)?0:null;const i=-(this.origin.dot(e.normal)+e.constant)/t;return i>=0?i:null}intersectPlane(e,t){const i=this.distanceToPlane(e);return null===i?null:this.at(i,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);if(0===t)return!0;return e.normal.dot(this.direction)*t<0}intersectBox(e,t){let i,n,r,s,a,o;const h=1/this.direction.x,c=1/this.direction.y,l=1/this.direction.z,u=this.origin;return h>=0?(i=(e.min.x-u.x)*h,n=(e.max.x-u.x)*h):(i=(e.max.x-u.x)*h,n=(e.min.x-u.x)*h),c>=0?(r=(e.min.y-u.y)*c,s=(e.max.y-u.y)*c):(r=(e.max.y-u.y)*c,s=(e.min.y-u.y)*c),i>s||r>n?null:((r>i||i!=i)&&(i=r),(s<n||n!=n)&&(n=s),l>=0?(a=(e.min.z-u.z)*l,o=(e.max.z-u.z)*l):(a=(e.max.z-u.z)*l,o=(e.min.z-u.z)*l),i>o||a>n?null:((a>i||i!=i)&&(i=a),(o<n||n!=n)&&(n=o),n<0?null:this.at(i>=0?i:n,t)))}intersectsBox(e){return null!==this.intersectBox(e,wn)}intersectTriangle(e,t,i,n,r){Cn.subVectors(t,e),En.subVectors(i,e),An.crossVectors(Cn,En);let s,a=this.direction.dot(An);if(a>0){if(n)return null;s=1}else{if(!(a<0))return null;s=-1,a=-a}Tn.subVectors(this.origin,e);const o=s*this.direction.dot(En.crossVectors(Tn,En));if(o<0)return null;const h=s*this.direction.dot(Cn.cross(Tn));if(h<0)return null;if(o+h>a)return null;const c=-s*Tn.dot(An);return c<0?null:this.at(c/a,r)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return(new this.constructor).copy(this)}}class Rn{constructor(){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],arguments.length>0&&console.error("THREE.Matrix4: the constructor no longer reads arguments. use .set() instead.")}set(e,t,i,n,r,s,a,o,h,c,l,u,d,p,m,f){const g=this.elements;return g[0]=e,g[4]=t,g[8]=i,g[12]=n,g[1]=r,g[5]=s,g[9]=a,g[13]=o,g[2]=h,g[6]=c,g[10]=l,g[14]=u,g[3]=d,g[7]=p,g[11]=m,g[15]=f,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 Rn).fromArray(this.elements)}copy(e){const t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],t[9]=i[9],t[10]=i[10],t[11]=i[11],t[12]=i[12],t[13]=i[13],t[14]=i[14],t[15]=i[15],this}copyPosition(e){const t=this.elements,i=e.elements;return t[12]=i[12],t[13]=i[13],t[14]=i[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,i){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this}makeBasis(e,t,i){return this.set(e.x,t.x,i.x,0,e.y,t.y,i.y,0,e.z,t.z,i.z,0,0,0,0,1),this}extractRotation(e){const t=this.elements,i=e.elements,n=1/Pn.setFromMatrixColumn(e,0).length(),r=1/Pn.setFromMatrixColumn(e,1).length(),s=1/Pn.setFromMatrixColumn(e,2).length();return t[0]=i[0]*n,t[1]=i[1]*n,t[2]=i[2]*n,t[3]=0,t[4]=i[4]*r,t[5]=i[5]*r,t[6]=i[6]*r,t[7]=0,t[8]=i[8]*s,t[9]=i[9]*s,t[10]=i[10]*s,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){e&&e.isEuler||console.error("THREE.Matrix4: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.");const t=this.elements,i=e.x,n=e.y,r=e.z,s=Math.cos(i),a=Math.sin(i),o=Math.cos(n),h=Math.sin(n),c=Math.cos(r),l=Math.sin(r);if("XYZ"===e.order){const e=s*c,i=s*l,n=a*c,r=a*l;t[0]=o*c,t[4]=-o*l,t[8]=h,t[1]=i+n*h,t[5]=e-r*h,t[9]=-a*o,t[2]=r-e*h,t[6]=n+i*h,t[10]=s*o}else if("YXZ"===e.order){const e=o*c,i=o*l,n=h*c,r=h*l;t[0]=e+r*a,t[4]=n*a-i,t[8]=s*h,t[1]=s*l,t[5]=s*c,t[9]=-a,t[2]=i*a-n,t[6]=r+e*a,t[10]=s*o}else if("ZXY"===e.order){const e=o*c,i=o*l,n=h*c,r=h*l;t[0]=e-r*a,t[4]=-s*l,t[8]=n+i*a,t[1]=i+n*a,t[5]=s*c,t[9]=r-e*a,t[2]=-s*h,t[6]=a,t[10]=s*o}else if("ZYX"===e.order){const e=s*c,i=s*l,n=a*c,r=a*l;t[0]=o*c,t[4]=n*h-i,t[8]=e*h+r,t[1]=o*l,t[5]=r*h+e,t[9]=i*h-n,t[2]=-h,t[6]=a*o,t[10]=s*o}else if("YZX"===e.order){const e=s*o,i=s*h,n=a*o,r=a*h;t[0]=o*c,t[4]=r-e*l,t[8]=n*l+i,t[1]=l,t[5]=s*c,t[9]=-a*c,t[2]=-h*c,t[6]=i*l+n,t[10]=e-r*l}else if("XZY"===e.order){const e=s*o,i=s*h,n=a*o,r=a*h;t[0]=o*c,t[4]=-l,t[8]=h*c,t[1]=e*l+r,t[5]=s*c,t[9]=i*l-n,t[2]=n*l-i,t[6]=a*c,t[10]=r*l+e}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(Dn,e,Nn)}lookAt(e,t,i){const n=this.elements;return On.subVectors(e,t),0===On.lengthSq()&&(On.z=1),On.normalize(),$n.crossVectors(i,On),0===$n.lengthSq()&&(1===Math.abs(i.z)?On.x+=1e-4:On.z+=1e-4,On.normalize(),$n.crossVectors(i,On)),$n.normalize(),kn.crossVectors(On,$n),n[0]=$n.x,n[4]=kn.x,n[8]=On.x,n[1]=$n.y,n[5]=kn.y,n[9]=On.y,n[2]=$n.z,n[6]=kn.z,n[10]=On.z,this}multiply(e,t){return void 0!==t?(console.warn("THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead."),this.multiplyMatrices(e,t)):this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const i=e.elements,n=t.elements,r=this.elements,s=i[0],a=i[4],o=i[8],h=i[12],c=i[1],l=i[5],u=i[9],d=i[13],p=i[2],m=i[6],f=i[10],g=i[14],_=i[3],v=i[7],y=i[11],b=i[15],x=n[0],w=n[4],M=n[8],S=n[12],T=n[1],C=n[5],E=n[9],A=n[13],I=n[2],R=n[6],P=n[10],L=n[14],D=n[3],N=n[7],$=n[11],k=n[15];return r[0]=s*x+a*T+o*I+h*D,r[4]=s*w+a*C+o*R+h*N,r[8]=s*M+a*E+o*P+h*$,r[12]=s*S+a*A+o*L+h*k,r[1]=c*x+l*T+u*I+d*D,r[5]=c*w+l*C+u*R+d*N,r[9]=c*M+l*E+u*P+d*$,r[13]=c*S+l*A+u*L+d*k,r[2]=p*x+m*T+f*I+g*D,r[6]=p*w+m*C+f*R+g*N,r[10]=p*M+m*E+f*P+g*$,r[14]=p*S+m*A+f*L+g*k,r[3]=_*x+v*T+y*I+b*D,r[7]=_*w+v*C+y*R+b*N,r[11]=_*M+v*E+y*P+b*$,r[15]=_*S+v*A+y*L+b*k,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],i=e[4],n=e[8],r=e[12],s=e[1],a=e[5],o=e[9],h=e[13],c=e[2],l=e[6],u=e[10],d=e[14];return e[3]*(+r*o*l-n*h*l-r*a*u+i*h*u+n*a*d-i*o*d)+e[7]*(+t*o*d-t*h*u+r*s*u-n*s*d+n*h*c-r*o*c)+e[11]*(+t*h*l-t*a*d-r*s*l+i*s*d+r*a*c-i*h*c)+e[15]*(-n*a*c-t*o*l+t*a*u+n*s*l-i*s*u+i*o*c)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,i){const n=this.elements;return e.isVector3?(n[12]=e.x,n[13]=e.y,n[14]=e.z):(n[12]=e,n[13]=t,n[14]=i),this}invert(){const e=this.elements,t=e[0],i=e[1],n=e[2],r=e[3],s=e[4],a=e[5],o=e[6],h=e[7],c=e[8],l=e[9],u=e[10],d=e[11],p=e[12],m=e[13],f=e[14],g=e[15],_=l*f*h-m*u*h+m*o*d-a*f*d-l*o*g+a*u*g,v=p*u*h-c*f*h-p*o*d+s*f*d+c*o*g-s*u*g,y=c*m*h-p*l*h+p*a*d-s*m*d-c*a*g+s*l*g,b=p*l*o-c*m*o-p*a*u+s*m*u+c*a*f-s*l*f,x=t*_+i*v+n*y+r*b;if(0===x)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const w=1/x;return e[0]=_*w,e[1]=(m*u*r-l*f*r-m*n*d+i*f*d+l*n*g-i*u*g)*w,e[2]=(a*f*r-m*o*r+m*n*h-i*f*h-a*n*g+i*o*g)*w,e[3]=(l*o*r-a*u*r-l*n*h+i*u*h+a*n*d-i*o*d)*w,e[4]=v*w,e[5]=(c*f*r-p*u*r+p*n*d-t*f*d-c*n*g+t*u*g)*w,e[6]=(p*o*r-s*f*r-p*n*h+t*f*h+s*n*g-t*o*g)*w,e[7]=(s*u*r-c*o*r+c*n*h-t*u*h-s*n*d+t*o*d)*w,e[8]=y*w,e[9]=(p*l*r-c*m*r-p*i*d+t*m*d+c*i*g-t*l*g)*w,e[10]=(s*m*r-p*a*r+p*i*h-t*m*h-s*i*g+t*a*g)*w,e[11]=(c*a*r-s*l*r-c*i*h+t*l*h+s*i*d-t*a*d)*w,e[12]=b*w,e[13]=(c*m*n-p*l*n+p*i*u-t*m*u-c*i*f+t*l*f)*w,e[14]=(p*a*n-s*m*n-p*i*o+t*m*o+s*i*f-t*a*f)*w,e[15]=(s*l*n-c*a*n+c*i*o-t*l*o-s*i*u+t*a*u)*w,this}scale(e){const t=this.elements,i=e.x,n=e.y,r=e.z;return t[0]*=i,t[4]*=n,t[8]*=r,t[1]*=i,t[5]*=n,t[9]*=r,t[2]*=i,t[6]*=n,t[10]*=r,t[3]*=i,t[7]*=n,t[11]*=r,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],i=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],n=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,i,n))}makeTranslation(e,t,i){return this.set(1,0,0,e,0,1,0,t,0,0,1,i,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),i=Math.sin(e);return this.set(1,0,0,0,0,t,-i,0,0,i,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,0,i,0,0,1,0,0,-i,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,0,i,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const i=Math.cos(t),n=Math.sin(t),r=1-i,s=e.x,a=e.y,o=e.z,h=r*s,c=r*a;return this.set(h*s+i,h*a-n*o,h*o+n*a,0,h*a+n*o,c*a+i,c*o-n*s,0,h*o-n*a,c*o+n*s,r*o*o+i,0,0,0,0,1),this}makeScale(e,t,i){return this.set(e,0,0,0,0,t,0,0,0,0,i,0,0,0,0,1),this}makeShear(e,t,i,n,r,s){return this.set(1,i,r,0,e,1,s,0,t,n,1,0,0,0,0,1),this}compose(e,t,i){const n=this.elements,r=t._x,s=t._y,a=t._z,o=t._w,h=r+r,c=s+s,l=a+a,u=r*h,d=r*c,p=r*l,m=s*c,f=s*l,g=a*l,_=o*h,v=o*c,y=o*l,b=i.x,x=i.y,w=i.z;return n[0]=(1-(m+g))*b,n[1]=(d+y)*b,n[2]=(p-v)*b,n[3]=0,n[4]=(d-y)*x,n[5]=(1-(u+g))*x,n[6]=(f+_)*x,n[7]=0,n[8]=(p+v)*w,n[9]=(f-_)*w,n[10]=(1-(u+m))*w,n[11]=0,n[12]=e.x,n[13]=e.y,n[14]=e.z,n[15]=1,this}decompose(e,t,i){const n=this.elements;let r=Pn.set(n[0],n[1],n[2]).length();const s=Pn.set(n[4],n[5],n[6]).length(),a=Pn.set(n[8],n[9],n[10]).length();this.determinant()<0&&(r=-r),e.x=n[12],e.y=n[13],e.z=n[14],Ln.copy(this);const o=1/r,h=1/s,c=1/a;return Ln.elements[0]*=o,Ln.elements[1]*=o,Ln.elements[2]*=o,Ln.elements[4]*=h,Ln.elements[5]*=h,Ln.elements[6]*=h,Ln.elements[8]*=c,Ln.elements[9]*=c,Ln.elements[10]*=c,t.setFromRotationMatrix(Ln),i.x=r,i.y=s,i.z=a,this}makePerspective(e,t,i,n,r,s){void 0===s&&console.warn("THREE.Matrix4: .makePerspective() has been redefined and has a new signature. Please check the docs.");const a=this.elements,o=2*r/(t-e),h=2*r/(i-n),c=(t+e)/(t-e),l=(i+n)/(i-n),u=-(s+r)/(s-r),d=-2*s*r/(s-r);return a[0]=o,a[4]=0,a[8]=c,a[12]=0,a[1]=0,a[5]=h,a[9]=l,a[13]=0,a[2]=0,a[6]=0,a[10]=u,a[14]=d,a[3]=0,a[7]=0,a[11]=-1,a[15]=0,this}makeOrthographic(e,t,i,n,r,s){const a=this.elements,o=1/(t-e),h=1/(i-n),c=1/(s-r),l=(t+e)*o,u=(i+n)*h,d=(s+r)*c;return a[0]=2*o,a[4]=0,a[8]=0,a[12]=-l,a[1]=0,a[5]=2*h,a[9]=0,a[13]=-u,a[2]=0,a[6]=0,a[10]=-2*c,a[14]=-d,a[3]=0,a[7]=0,a[11]=0,a[15]=1,this}equals(e){const t=this.elements,i=e.elements;for(let e=0;e<16;e++)if(t[e]!==i[e])return!1;return!0}fromArray(e,t=0){for(let i=0;i<16;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){const i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e[t+9]=i[9],e[t+10]=i[10],e[t+11]=i[11],e[t+12]=i[12],e[t+13]=i[13],e[t+14]=i[14],e[t+15]=i[15],e}}Rn.prototype.isMatrix4=!0;const Pn=new Ki,Ln=new Rn,Dn=new Ki(0,0,0),Nn=new Ki(1,1,1),$n=new Ki,kn=new Ki,On=new Ki,zn=new Rn,Fn=new Ji;class Bn{constructor(e=0,t=0,i=0,n=Bn.DefaultOrder){this._x=e,this._y=t,this._z=i,this._order=n}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,i,n=this._order){return this._x=e,this._y=t,this._z=i,this._order=n,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,i=!0){const n=e.elements,r=n[0],s=n[4],a=n[8],o=n[1],h=n[5],c=n[9],l=n[2],u=n[6],d=n[10];switch(t){case"XYZ":this._y=Math.asin(Li(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-c,d),this._z=Math.atan2(-s,r)):(this._x=Math.atan2(u,h),this._z=0);break;case"YXZ":this._x=Math.asin(-Li(c,-1,1)),Math.abs(c)<.9999999?(this._y=Math.atan2(a,d),this._z=Math.atan2(o,h)):(this._y=Math.atan2(-l,r),this._z=0);break;case"ZXY":this._x=Math.asin(Li(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(-l,d),this._z=Math.atan2(-s,h)):(this._y=0,this._z=Math.atan2(o,r));break;case"ZYX":this._y=Math.asin(-Li(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(u,d),this._z=Math.atan2(o,r)):(this._x=0,this._z=Math.atan2(-s,h));break;case"YZX":this._z=Math.asin(Li(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-c,h),this._y=Math.atan2(-l,r)):(this._x=0,this._y=Math.atan2(a,d));break;case"XZY":this._z=Math.asin(-Li(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(u,h),this._y=Math.atan2(a,r)):(this._x=Math.atan2(-c,d),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,!0===i&&this._onChangeCallback(),this}setFromQuaternion(e,t,i){return zn.makeRotationFromQuaternion(e),this.setFromRotationMatrix(zn,t,i)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return Fn.setFromEuler(this),this.setFromQuaternion(Fn,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],void 0!==e[3]&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}toVector3(e){return e?e.set(this._x,this._y,this._z):new Ki(this._x,this._y,this._z)}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}}Bn.prototype.isEuler=!0,Bn.DefaultOrder="XYZ",Bn.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"];class Un{constructor(){this.mask=1}set(e){this.mask=1<<e|0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return 0!=(this.mask&e.mask)}}let Vn=0;const Hn=new Ki,jn=new Ji,Gn=new Rn,Wn=new Ki,qn=new Ki,Xn=new Ki,Zn=new Ji,Yn=new Ki(1,0,0),Jn=new Ki(0,1,0),Kn=new Ki(0,0,1),Qn={type:"added"},er={type:"removed"};class tr extends Ti{constructor(){super(),Object.defineProperty(this,"id",{value:Vn++}),this.uuid=Pi(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=tr.DefaultUp.clone();const e=new Ki,t=new Bn,i=new Ji,n=new Ki(1,1,1);t._onChange((function(){i.setFromEuler(t,!1)})),i._onChange((function(){t.setFromQuaternion(i,void 0,!1)})),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:i},scale:{configurable:!0,enumerable:!0,value:n},modelViewMatrix:{value:new Rn},normalMatrix:{value:new Fi}}),this.matrix=new Rn,this.matrixWorld=new Rn,this.matrixAutoUpdate=tr.DefaultMatrixAutoUpdate,this.matrixWorldNeedsUpdate=!1,this.layers=new Un,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={}}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return jn.setFromAxisAngle(e,t),this.quaternion.multiply(jn),this}rotateOnWorldAxis(e,t){return jn.setFromAxisAngle(e,t),this.quaternion.premultiply(jn),this}rotateX(e){return this.rotateOnAxis(Yn,e)}rotateY(e){return this.rotateOnAxis(Jn,e)}rotateZ(e){return this.rotateOnAxis(Kn,e)}translateOnAxis(e,t){return Hn.copy(e).applyQuaternion(this.quaternion),this.position.add(Hn.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(Yn,e)}translateY(e){return this.translateOnAxis(Jn,e)}translateZ(e){return this.translateOnAxis(Kn,e)}localToWorld(e){return e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return e.applyMatrix4(Gn.copy(this.matrixWorld).invert())}lookAt(e,t,i){e.isVector3?Wn.copy(e):Wn.set(e,t,i);const n=this.parent;this.updateWorldMatrix(!0,!1),qn.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Gn.lookAt(qn,Wn,this.up):Gn.lookAt(Wn,qn,this.up),this.quaternion.setFromRotationMatrix(Gn),n&&(Gn.extractRotation(n.matrixWorld),jn.setFromRotationMatrix(Gn),this.quaternion.premultiply(jn.invert()))}add(e){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return e===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(null!==e.parent&&e.parent.remove(e),e.parent=this,this.children.push(e),e.dispatchEvent(Qn)):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.remove(arguments[e]);return this}const t=this.children.indexOf(e);return-1!==t&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(er)),this}removeFromParent(){const e=this.parent;return null!==e&&e.remove(this),this}clear(){for(let e=0;e<this.children.length;e++){const t=this.children[e];t.parent=null,t.dispatchEvent(er)}return this.children.length=0,this}attach(e){return this.updateWorldMatrix(!0,!1),Gn.copy(this.matrixWorld).invert(),null!==e.parent&&(e.parent.updateWorldMatrix(!0,!1),Gn.multiply(e.parent.matrixWorld)),e.applyMatrix4(Gn),this.add(e),e.updateWorldMatrix(!1,!0),this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let i=0,n=this.children.length;i<n;i++){const n=this.children[i].getObjectByProperty(e,t);if(void 0!==n)return n}}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(qn,e,Xn),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(qn,Zn,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);const t=this.children;for(let i=0,n=t.length;i<n;i++)t[i].traverse(e)}traverseVisible(e){if(!1===this.visible)return;e(this);const t=this.children;for(let i=0,n=t.length;i<n;i++)t[i].traverseVisible(e)}traverseAncestors(e){const t=this.parent;null!==t&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1,e=!0);const t=this.children;for(let i=0,n=t.length;i<n;i++)t[i].updateMatrixWorld(e)}updateWorldMatrix(e,t){const i=this.parent;if(!0===e&&null!==i&&i.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),!0===t){const e=this.children;for(let t=0,i=e.length;t<i;t++)e[t].updateWorldMatrix(!1,!0)}}toJSON(e){const t=void 0===e||"string"==typeof e,i={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{}},i.metadata={version:4.5,type:"Object",generator:"Object3D.toJSON"});const n={};function r(t,i){return void 0===t[i.uuid]&&(t[i.uuid]=i.toJSON(e)),i.uuid}if(n.uuid=this.uuid,n.type=this.type,""!==this.name&&(n.name=this.name),!0===this.castShadow&&(n.castShadow=!0),!0===this.receiveShadow&&(n.receiveShadow=!0),!1===this.visible&&(n.visible=!1),!1===this.frustumCulled&&(n.frustumCulled=!1),0!==this.renderOrder&&(n.renderOrder=this.renderOrder),"{}"!==JSON.stringify(this.userData)&&(n.userData=this.userData),n.layers=this.layers.mask,n.matrix=this.matrix.toArray(),!1===this.matrixAutoUpdate&&(n.matrixAutoUpdate=!1),this.isInstancedMesh&&(n.type="InstancedMesh",n.count=this.count,n.instanceMatrix=this.instanceMatrix.toJSON(),null!==this.instanceColor&&(n.instanceColor=this.instanceColor.toJSON())),this.isScene)this.background&&(this.background.isColor?n.background=this.background.toJSON():this.background.isTexture&&(n.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&(n.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){n.geometry=r(e.geometries,this.geometry);const t=this.geometry.parameters;if(void 0!==t&&void 0!==t.shapes){const i=t.shapes;if(Array.isArray(i))for(let t=0,n=i.length;t<n;t++){const n=i[t];r(e.shapes,n)}else r(e.shapes,i)}}if(this.isSkinnedMesh&&(n.bindMode=this.bindMode,n.bindMatrix=this.bindMatrix.toArray(),void 0!==this.skeleton&&(r(e.skeletons,this.skeleton),n.skeleton=this.skeleton.uuid)),void 0!==this.material)if(Array.isArray(this.material)){const t=[];for(let i=0,n=this.material.length;i<n;i++)t.push(r(e.materials,this.material[i]));n.material=t}else n.material=r(e.materials,this.material);if(this.children.length>0){n.children=[];for(let t=0;t<this.children.length;t++)n.children.push(this.children[t].toJSON(e).object)}if(this.animations.length>0){n.animations=[];for(let t=0;t<this.animations.length;t++){const i=this.animations[t];n.animations.push(r(e.animations,i))}}if(t){const t=s(e.geometries),n=s(e.materials),r=s(e.textures),a=s(e.images),o=s(e.shapes),h=s(e.skeletons),c=s(e.animations);t.length>0&&(i.geometries=t),n.length>0&&(i.materials=n),r.length>0&&(i.textures=r),a.length>0&&(i.images=a),o.length>0&&(i.shapes=o),h.length>0&&(i.skeletons=h),c.length>0&&(i.animations=c)}return i.object=n,i;function s(e){const t=[];for(const i in e){const n=e[i];delete n.metadata,t.push(n)}return t}}clone(e){return(new this.constructor).copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.userData=JSON.parse(JSON.stringify(e.userData)),!0===t)for(let t=0;t<e.children.length;t++){const i=e.children[t];this.add(i.clone())}return this}}tr.DefaultUp=new Ki(0,1,0),tr.DefaultMatrixAutoUpdate=!0,tr.prototype.isObject3D=!0;const ir=new Ki,nr=new Ki,rr=new Ki,sr=new Ki,ar=new Ki,or=new Ki,hr=new Ki,cr=new Ki,lr=new Ki,ur=new Ki;class dr{constructor(e=new Ki,t=new Ki,i=new Ki){this.a=e,this.b=t,this.c=i}static getNormal(e,t,i,n){n.subVectors(i,t),ir.subVectors(e,t),n.cross(ir);const r=n.lengthSq();return r>0?n.multiplyScalar(1/Math.sqrt(r)):n.set(0,0,0)}static getBarycoord(e,t,i,n,r){ir.subVectors(n,t),nr.subVectors(i,t),rr.subVectors(e,t);const s=ir.dot(ir),a=ir.dot(nr),o=ir.dot(rr),h=nr.dot(nr),c=nr.dot(rr),l=s*h-a*a;if(0===l)return r.set(-2,-1,-1);const u=1/l,d=(h*o-a*c)*u,p=(s*c-a*o)*u;return r.set(1-d-p,p,d)}static containsPoint(e,t,i,n){return this.getBarycoord(e,t,i,n,sr),sr.x>=0&&sr.y>=0&&sr.x+sr.y<=1}static getUV(e,t,i,n,r,s,a,o){return this.getBarycoord(e,t,i,n,sr),o.set(0,0),o.addScaledVector(r,sr.x),o.addScaledVector(s,sr.y),o.addScaledVector(a,sr.z),o}static isFrontFacing(e,t,i,n){return ir.subVectors(i,t),nr.subVectors(e,t),ir.cross(nr).dot(n)<0}set(e,t,i){return this.a.copy(e),this.b.copy(t),this.c.copy(i),this}setFromPointsAndIndices(e,t,i,n){return this.a.copy(e[t]),this.b.copy(e[i]),this.c.copy(e[n]),this}setFromAttributeAndIndices(e,t,i,n){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,i),this.c.fromBufferAttribute(e,n),this}clone(){return(new this.constructor).copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return ir.subVectors(this.c,this.b),nr.subVectors(this.a,this.b),.5*ir.cross(nr).length()}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return dr.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return dr.getBarycoord(e,this.a,this.b,this.c,t)}getUV(e,t,i,n,r){return dr.getUV(e,this.a,this.b,this.c,t,i,n,r)}containsPoint(e){return dr.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return dr.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const i=this.a,n=this.b,r=this.c;let s,a;ar.subVectors(n,i),or.subVectors(r,i),cr.subVectors(e,i);const o=ar.dot(cr),h=or.dot(cr);if(o<=0&&h<=0)return t.copy(i);lr.subVectors(e,n);const c=ar.dot(lr),l=or.dot(lr);if(c>=0&&l<=c)return t.copy(n);const u=o*l-c*h;if(u<=0&&o>=0&&c<=0)return s=o/(o-c),t.copy(i).addScaledVector(ar,s);ur.subVectors(e,r);const d=ar.dot(ur),p=or.dot(ur);if(p>=0&&d<=p)return t.copy(r);const m=d*h-o*p;if(m<=0&&h>=0&&p<=0)return a=h/(h-p),t.copy(i).addScaledVector(or,a);const f=c*p-d*l;if(f<=0&&l-c>=0&&d-p>=0)return hr.subVectors(r,n),a=(l-c)/(l-c+(d-p)),t.copy(n).addScaledVector(hr,a);const g=1/(f+m+u);return s=m*g,a=u*g,t.copy(i).addScaledVector(ar,s).addScaledVector(or,a)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}let pr=0;class mr extends Ti{constructor(){super(),Object.defineProperty(this,"id",{value:pr++}),this.uuid=Pi(),this.name="",this.type="Material",this.fog=!0,this.blending=1,this.side=0,this.vertexColors=!1,this.opacity=1,this.format=oi,this.transparent=!1,this.blendSrc=204,this.blendDst=205,this.blendEquation=jt,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=3,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=519,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=xi,this.stencilZFail=xi,this.stencilZPass=xi,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(void 0!==e)for(const t in e){const i=e[t];if(void 0===i){console.warn("THREE.Material: '"+t+"' parameter is undefined.");continue}if("shading"===t){console.warn("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead."),this.flatShading=1===i;continue}const n=this[t];void 0!==n?n&&n.isColor?n.set(i):n&&n.isVector3&&i&&i.isVector3?n.copy(i):this[t]=i:console.warn("THREE."+this.type+": '"+t+"' is not a property of this material.")}}toJSON(e){const t=void 0===e||"string"==typeof e;t&&(e={textures:{},images:{}});const i={metadata:{version:4.5,type:"Material",generator:"Material.toJSON"}};function n(e){const t=[];for(const i in e){const n=e[i];delete n.metadata,t.push(n)}return t}if(i.uuid=this.uuid,i.type=this.type,""!==this.name&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),void 0!==this.roughness&&(i.roughness=this.roughness),void 0!==this.metalness&&(i.metalness=this.metalness),void 0!==this.sheen&&(i.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(i.sheenColor=this.sheenColor.getHex()),void 0!==this.sheenRoughness&&(i.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.emissiveIntensity&&1!==this.emissiveIntensity&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),void 0!==this.specularIntensity&&(i.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(i.specularColor=this.specularColor.getHex()),void 0!==this.shininess&&(i.shininess=this.shininess),void 0!==this.clearcoat&&(i.clearcoat=this.clearcoat),void 0!==this.clearcoatRoughness&&(i.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(i.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(i.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(e).uuid,i.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(e).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(e).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(e).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(e).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(i.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(i.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(e).uuid,void 0!==this.combine&&(i.combine=this.combine)),void 0!==this.envMapIntensity&&(i.envMapIntensity=this.envMapIntensity),void 0!==this.reflectivity&&(i.reflectivity=this.reflectivity),void 0!==this.refractionRatio&&(i.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(e).uuid),void 0!==this.transmission&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(e).uuid),void 0!==this.thickness&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(e).uuid),void 0!==this.attenuationDistance&&(i.attenuationDistance=this.attenuationDistance),void 0!==this.attenuationColor&&(i.attenuationColor=this.attenuationColor.getHex()),void 0!==this.size&&(i.size=this.size),null!==this.shadowSide&&(i.shadowSide=this.shadowSide),void 0!==this.sizeAttenuation&&(i.sizeAttenuation=this.sizeAttenuation),1!==this.blending&&(i.blending=this.blending),0!==this.side&&(i.side=this.side),this.vertexColors&&(i.vertexColors=!0),this.opacity<1&&(i.opacity=this.opacity),this.format!==oi&&(i.format=this.format),!0===this.transparent&&(i.transparent=this.transparent),i.depthFunc=this.depthFunc,i.depthTest=this.depthTest,i.depthWrite=this.depthWrite,i.colorWrite=this.colorWrite,i.stencilWrite=this.stencilWrite,i.stencilWriteMask=this.stencilWriteMask,i.stencilFunc=this.stencilFunc,i.stencilRef=this.stencilRef,i.stencilFuncMask=this.stencilFuncMask,i.stencilFail=this.stencilFail,i.stencilZFail=this.stencilZFail,i.stencilZPass=this.stencilZPass,this.rotation&&0!==this.rotation&&(i.rotation=this.rotation),!0===this.polygonOffset&&(i.polygonOffset=!0),0!==this.polygonOffsetFactor&&(i.polygonOffsetFactor=this.polygonOffsetFactor),0!==this.polygonOffsetUnits&&(i.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth&&1!==this.linewidth&&(i.linewidth=this.linewidth),void 0!==this.dashSize&&(i.dashSize=this.dashSize),void 0!==this.gapSize&&(i.gapSize=this.gapSize),void 0!==this.scale&&(i.scale=this.scale),!0===this.dithering&&(i.dithering=!0),this.alphaTest>0&&(i.alphaTest=this.alphaTest),!0===this.alphaToCoverage&&(i.alphaToCoverage=this.alphaToCoverage),!0===this.premultipliedAlpha&&(i.premultipliedAlpha=this.premultipliedAlpha),!0===this.wireframe&&(i.wireframe=this.wireframe),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(i.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(i.wireframeLinejoin=this.wireframeLinejoin),!0===this.flatShading&&(i.flatShading=this.flatShading),!1===this.visible&&(i.visible=!1),!1===this.toneMapped&&(i.toneMapped=!1),"{}"!==JSON.stringify(this.userData)&&(i.userData=this.userData),t){const t=n(e.textures),r=n(e.images);t.length>0&&(i.textures=t),r.length>0&&(i.images=r)}return i}clone(){return(new this.constructor).copy(this)}copy(e){this.name=e.name,this.fog=e.fog,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.format=e.format,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let i=null;if(null!==t){const e=t.length;i=new Array(e);for(let n=0;n!==e;++n)i[n]=t[n].clone()}return this.clippingPlanes=i,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){!0===e&&this.version++}}mr.prototype.isMaterial=!0;const fr={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},gr={h:0,s:0,l:0},_r={h:0,s:0,l:0};function vr(e,t,i){return i<0&&(i+=1),i>1&&(i-=1),i<1/6?e+6*(t-e)*i:i<.5?t:i<2/3?e+6*(t-e)*(2/3-i):e}function yr(e){return e<.04045?.0773993808*e:Math.pow(.9478672986*e+.0521327014,2.4)}function br(e){return e<.0031308?12.92*e:1.055*Math.pow(e,.41666)-.055}class xr{constructor(e,t,i){return void 0===t&&void 0===i?this.set(e):this.setRGB(e,t,i)}set(e){return e&&e.isColor?this.copy(e):"number"==typeof e?this.setHex(e):"string"==typeof e&&this.setStyle(e),this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(255&e)/255,this}setRGB(e,t,i){return this.r=e,this.g=t,this.b=i,this}setHSL(e,t,i){if(e=Di(e,1),t=Li(t,0,1),i=Li(i,0,1),0===t)this.r=this.g=this.b=i;else{const n=i<=.5?i*(1+t):i+t-i*t,r=2*i-n;this.r=vr(r,n,e+1/3),this.g=vr(r,n,e),this.b=vr(r,n,e-1/3)}return this}setStyle(e){function t(t){void 0!==t&&parseFloat(t)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^((?:rgb|hsl)a?)\(([^\)]*)\)/.exec(e)){let e;const n=i[1],r=i[2];switch(n){case"rgb":case"rgba":if(e=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(r))return this.r=Math.min(255,parseInt(e[1],10))/255,this.g=Math.min(255,parseInt(e[2],10))/255,this.b=Math.min(255,parseInt(e[3],10))/255,t(e[4]),this;if(e=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(r))return this.r=Math.min(100,parseInt(e[1],10))/100,this.g=Math.min(100,parseInt(e[2],10))/100,this.b=Math.min(100,parseInt(e[3],10))/100,t(e[4]),this;break;case"hsl":case"hsla":if(e=/^\s*(\d*\.?\d+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(r)){const i=parseFloat(e[1])/360,n=parseInt(e[2],10)/100,r=parseInt(e[3],10)/100;return t(e[4]),this.setHSL(i,n,r)}}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){const e=i[1],t=e.length;if(3===t)return this.r=parseInt(e.charAt(0)+e.charAt(0),16)/255,this.g=parseInt(e.charAt(1)+e.charAt(1),16)/255,this.b=parseInt(e.charAt(2)+e.charAt(2),16)/255,this;if(6===t)return this.r=parseInt(e.charAt(0)+e.charAt(1),16)/255,this.g=parseInt(e.charAt(2)+e.charAt(3),16)/255,this.b=parseInt(e.charAt(4)+e.charAt(5),16)/255,this}return e&&e.length>0?this.setColorName(e):this}setColorName(e){const t=fr[e.toLowerCase()];return void 0!==t?this.setHex(t):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copyGammaToLinear(e,t=2){return this.r=Math.pow(e.r,t),this.g=Math.pow(e.g,t),this.b=Math.pow(e.b,t),this}copyLinearToGamma(e,t=2){const i=t>0?1/t:1;return this.r=Math.pow(e.r,i),this.g=Math.pow(e.g,i),this.b=Math.pow(e.b,i),this}convertGammaToLinear(e){return this.copyGammaToLinear(this,e),this}convertLinearToGamma(e){return this.copyLinearToGamma(this,e),this}copySRGBToLinear(e){return this.r=yr(e.r),this.g=yr(e.g),this.b=yr(e.b),this}copyLinearToSRGB(e){return this.r=br(e.r),this.g=br(e.g),this.b=br(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(){return 255*this.r<<16^255*this.g<<8^255*this.b<<0}getHexString(){return("000000"+this.getHex().toString(16)).slice(-6)}getHSL(e){const t=this.r,i=this.g,n=this.b,r=Math.max(t,i,n),s=Math.min(t,i,n);let a,o;const h=(s+r)/2;if(s===r)a=0,o=0;else{const e=r-s;switch(o=h<=.5?e/(r+s):e/(2-r-s),r){case t:a=(i-n)/e+(i<n?6:0);break;case i:a=(n-t)/e+2;break;case n:a=(t-i)/e+4}a/=6}return e.h=a,e.s=o,e.l=h,e}getStyle(){return"rgb("+(255*this.r|0)+","+(255*this.g|0)+","+(255*this.b|0)+")"}offsetHSL(e,t,i){return this.getHSL(gr),gr.h+=e,gr.s+=t,gr.l+=i,this.setHSL(gr.h,gr.s,gr.l),this}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,i){return this.r=e.r+(t.r-e.r)*i,this.g=e.g+(t.g-e.g)*i,this.b=e.b+(t.b-e.b)*i,this}lerpHSL(e,t){this.getHSL(gr),e.getHSL(_r);const i=Ni(gr.h,_r.h,t),n=Ni(gr.s,_r.s,t),r=Ni(gr.l,_r.l,t);return this.setHSL(i,n,r),this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),!0===e.normalized&&(this.r/=255,this.g/=255,this.b/=255),this}toJSON(){return this.getHex()}}xr.NAMES=fr,xr.prototype.isColor=!0,xr.prototype.r=1,xr.prototype.g=1,xr.prototype.b=1;class wr extends mr{constructor(e){super(),this.type="MeshBasicMaterial",this.color=new xr(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this}}wr.prototype.isMeshBasicMaterial=!0;const Mr=new Ki,Sr=new zi;class Tr{constructor(e,t,i){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.name="",this.array=e,this.itemSize=t,this.count=void 0!==e?e.length/t:0,this.normalized=!0===i,this.usage=wi,this.updateRange={offset:0,count:-1},this.version=0}onUploadCallback(){}set needsUpdate(e){!0===e&&this.version++}setUsage(e){return this.usage=e,this}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this}copyAt(e,t,i){e*=this.itemSize,i*=t.itemSize;for(let n=0,r=this.itemSize;n<r;n++)this.array[e+n]=t.array[i+n];return this}copyArray(e){return this.array.set(e),this}copyColorsArray(e){const t=this.array;let i=0;for(let n=0,r=e.length;n<r;n++){let r=e[n];void 0===r&&(console.warn("THREE.BufferAttribute.copyColorsArray(): color is undefined",n),r=new xr),t[i++]=r.r,t[i++]=r.g,t[i++]=r.b}return this}copyVector2sArray(e){const t=this.array;let i=0;for(let n=0,r=e.length;n<r;n++){let r=e[n];void 0===r&&(console.warn("THREE.BufferAttribute.copyVector2sArray(): vector is undefined",n),r=new zi),t[i++]=r.x,t[i++]=r.y}return this}copyVector3sArray(e){const t=this.array;let i=0;for(let n=0,r=e.length;n<r;n++){let r=e[n];void 0===r&&(console.warn("THREE.BufferAttribute.copyVector3sArray(): vector is undefined",n),r=new Ki),t[i++]=r.x,t[i++]=r.y,t[i++]=r.z}return this}copyVector4sArray(e){const t=this.array;let i=0;for(let n=0,r=e.length;n<r;n++){let r=e[n];void 0===r&&(console.warn("THREE.BufferAttribute.copyVector4sArray(): vector is undefined",n),r=new Xi),t[i++]=r.x,t[i++]=r.y,t[i++]=r.z,t[i++]=r.w}return this}applyMatrix3(e){if(2===this.itemSize)for(let t=0,i=this.count;t<i;t++)Sr.fromBufferAttribute(this,t),Sr.applyMatrix3(e),this.setXY(t,Sr.x,Sr.y);else if(3===this.itemSize)for(let t=0,i=this.count;t<i;t++)Mr.fromBufferAttribute(this,t),Mr.applyMatrix3(e),this.setXYZ(t,Mr.x,Mr.y,Mr.z);return this}applyMatrix4(e){for(let t=0,i=this.count;t<i;t++)Mr.x=this.getX(t),Mr.y=this.getY(t),Mr.z=this.getZ(t),Mr.applyMatrix4(e),this.setXYZ(t,Mr.x,Mr.y,Mr.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)Mr.x=this.getX(t),Mr.y=this.getY(t),Mr.z=this.getZ(t),Mr.applyNormalMatrix(e),this.setXYZ(t,Mr.x,Mr.y,Mr.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)Mr.x=this.getX(t),Mr.y=this.getY(t),Mr.z=this.getZ(t),Mr.transformDirection(e),this.setXYZ(t,Mr.x,Mr.y,Mr.z);return this}set(e,t=0){return this.array.set(e,t),this}getX(e){return this.array[e*this.itemSize]}setX(e,t){return this.array[e*this.itemSize]=t,this}getY(e){return this.array[e*this.itemSize+1]}setY(e,t){return this.array[e*this.itemSize+1]=t,this}getZ(e){return this.array[e*this.itemSize+2]}setZ(e,t){return this.array[e*this.itemSize+2]=t,this}getW(e){return this.array[e*this.itemSize+3]}setW(e,t){return this.array[e*this.itemSize+3]=t,this}setXY(e,t,i){return e*=this.itemSize,this.array[e+0]=t,this.array[e+1]=i,this}setXYZ(e,t,i,n){return e*=this.itemSize,this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=n,this}setXYZW(e,t,i,n,r){return e*=this.itemSize,this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=n,this.array[e+3]=r,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.prototype.slice.call(this.array),normalized:this.normalized};return""!==this.name&&(e.name=this.name),this.usage!==wi&&(e.usage=this.usage),0===this.updateRange.offset&&-1===this.updateRange.count||(e.updateRange=this.updateRange),e}}Tr.prototype.isBufferAttribute=!0;class Cr extends Tr{constructor(e,t,i){super(new Uint16Array(e),t,i)}}class Er extends Tr{constructor(e,t,i){super(new Uint32Array(e),t,i)}}(class extends Tr{constructor(e,t,i){super(new Uint16Array(e),t,i)}}).prototype.isFloat16BufferAttribute=!0;class Ar extends Tr{constructor(e,t,i){super(new Float32Array(e),t,i)}}let Ir=0;const Rr=new Rn,Pr=new tr,Lr=new Ki,Dr=new tn,Nr=new tn,$r=new Ki;class kr extends Ti{constructor(){super(),Object.defineProperty(this,"id",{value:Ir++}),this.uuid=Pi(),this.name="",this.type="BufferGeometry",this.index=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(Bi(e)>65535?Er:Cr)(e,1):this.index=e,this}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return void 0!==this.attributes[e]}addGroup(e,t,i=0){this.groups.push({start:e,count:t,materialIndex:i})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){const t=this.attributes.position;void 0!==t&&(t.applyMatrix4(e),t.needsUpdate=!0);const i=this.attributes.normal;if(void 0!==i){const t=(new Fi).getNormalMatrix(e);i.applyNormalMatrix(t),i.needsUpdate=!0}const n=this.attributes.tangent;return void 0!==n&&(n.transformDirection(e),n.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this}applyQuaternion(e){return Rr.makeRotationFromQuaternion(e),this.applyMatrix4(Rr),this}rotateX(e){return Rr.makeRotationX(e),this.applyMatrix4(Rr),this}rotateY(e){return Rr.makeRotationY(e),this.applyMatrix4(Rr),this}rotateZ(e){return Rr.makeRotationZ(e),this.applyMatrix4(Rr),this}translate(e,t,i){return Rr.makeTranslation(e,t,i),this.applyMatrix4(Rr),this}scale(e,t,i){return Rr.makeScale(e,t,i),this.applyMatrix4(Rr),this}lookAt(e){return Pr.lookAt(e),Pr.updateMatrix(),this.applyMatrix4(Pr.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Lr).negate(),this.translate(Lr.x,Lr.y,Lr.z),this}setFromPoints(e){const t=[];for(let i=0,n=e.length;i<n;i++){const n=e[i];t.push(n.x,n.y,n.z||0)}return this.setAttribute("position",new Ar(t,3)),this}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new tn);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute)return console.error('THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box. Alternatively set "mesh.frustumCulled" to "false".',this),void this.boundingBox.set(new Ki(-1/0,-1/0,-1/0),new Ki(1/0,1/0,1/0));if(void 0!==e){if(this.boundingBox.setFromBufferAttribute(e),t)for(let e=0,i=t.length;e<i;e++){const i=t[e];Dr.setFromBufferAttribute(i),this.morphTargetsRelative?($r.addVectors(this.boundingBox.min,Dr.min),this.boundingBox.expandByPoint($r),$r.addVectors(this.boundingBox.max,Dr.max),this.boundingBox.expandByPoint($r)):(this.boundingBox.expandByPoint(Dr.min),this.boundingBox.expandByPoint(Dr.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){null===this.boundingSphere&&(this.boundingSphere=new xn);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute)return console.error('THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere. Alternatively set "mesh.frustumCulled" to "false".',this),void this.boundingSphere.set(new Ki,1/0);if(e){const i=this.boundingSphere.center;if(Dr.setFromBufferAttribute(e),t)for(let e=0,i=t.length;e<i;e++){const i=t[e];Nr.setFromBufferAttribute(i),this.morphTargetsRelative?($r.addVectors(Dr.min,Nr.min),Dr.expandByPoint($r),$r.addVectors(Dr.max,Nr.max),Dr.expandByPoint($r)):(Dr.expandByPoint(Nr.min),Dr.expandByPoint(Nr.max))}Dr.getCenter(i);let n=0;for(let t=0,r=e.count;t<r;t++)$r.fromBufferAttribute(e,t),n=Math.max(n,i.distanceToSquared($r));if(t)for(let r=0,s=t.length;r<s;r++){const s=t[r],a=this.morphTargetsRelative;for(let t=0,r=s.count;t<r;t++)$r.fromBufferAttribute(s,t),a&&(Lr.fromBufferAttribute(e,t),$r.add(Lr)),n=Math.max(n,i.distanceToSquared($r))}this.boundingSphere.radius=Math.sqrt(n),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,t=this.attributes;if(null===e||void 0===t.position||void 0===t.normal||void 0===t.uv)return void console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");const i=e.array,n=t.position.array,r=t.normal.array,s=t.uv.array,a=n.length/3;void 0===t.tangent&&this.setAttribute("tangent",new Tr(new Float32Array(4*a),4));const o=t.tangent.array,h=[],c=[];for(let e=0;e<a;e++)h[e]=new Ki,c[e]=new Ki;const l=new Ki,u=new Ki,d=new Ki,p=new zi,m=new zi,f=new zi,g=new Ki,_=new Ki;function v(e,t,i){l.fromArray(n,3*e),u.fromArray(n,3*t),d.fromArray(n,3*i),p.fromArray(s,2*e),m.fromArray(s,2*t),f.fromArray(s,2*i),u.sub(l),d.sub(l),m.sub(p),f.sub(p);const r=1/(m.x*f.y-f.x*m.y);isFinite(r)&&(g.copy(u).multiplyScalar(f.y).addScaledVector(d,-m.y).multiplyScalar(r),_.copy(d).multiplyScalar(m.x).addScaledVector(u,-f.x).multiplyScalar(r),h[e].add(g),h[t].add(g),h[i].add(g),c[e].add(_),c[t].add(_),c[i].add(_))}let y=this.groups;0===y.length&&(y=[{start:0,count:i.length}]);for(let e=0,t=y.length;e<t;++e){const t=y[e],n=t.start;for(let e=n,r=n+t.count;e<r;e+=3)v(i[e+0],i[e+1],i[e+2])}const b=new Ki,x=new Ki,w=new Ki,M=new Ki;function S(e){w.fromArray(r,3*e),M.copy(w);const t=h[e];b.copy(t),b.sub(w.multiplyScalar(w.dot(t))).normalize(),x.crossVectors(M,t);const i=x.dot(c[e])<0?-1:1;o[4*e]=b.x,o[4*e+1]=b.y,o[4*e+2]=b.z,o[4*e+3]=i}for(let e=0,t=y.length;e<t;++e){const t=y[e],n=t.start;for(let e=n,r=n+t.count;e<r;e+=3)S(i[e+0]),S(i[e+1]),S(i[e+2])}}computeVertexNormals(){const e=this.index,t=this.getAttribute("position");if(void 0!==t){let i=this.getAttribute("normal");if(void 0===i)i=new Tr(new Float32Array(3*t.count),3),this.setAttribute("normal",i);else for(let e=0,t=i.count;e<t;e++)i.setXYZ(e,0,0,0);const n=new Ki,r=new Ki,s=new Ki,a=new Ki,o=new Ki,h=new Ki,c=new Ki,l=new Ki;if(e)for(let u=0,d=e.count;u<d;u+=3){const d=e.getX(u+0),p=e.getX(u+1),m=e.getX(u+2);n.fromBufferAttribute(t,d),r.fromBufferAttribute(t,p),s.fromBufferAttribute(t,m),c.subVectors(s,r),l.subVectors(n,r),c.cross(l),a.fromBufferAttribute(i,d),o.fromBufferAttribute(i,p),h.fromBufferAttribute(i,m),a.add(c),o.add(c),h.add(c),i.setXYZ(d,a.x,a.y,a.z),i.setXYZ(p,o.x,o.y,o.z),i.setXYZ(m,h.x,h.y,h.z)}else for(let e=0,a=t.count;e<a;e+=3)n.fromBufferAttribute(t,e+0),r.fromBufferAttribute(t,e+1),s.fromBufferAttribute(t,e+2),c.subVectors(s,r),l.subVectors(n,r),c.cross(l),i.setXYZ(e+0,c.x,c.y,c.z),i.setXYZ(e+1,c.x,c.y,c.z),i.setXYZ(e+2,c.x,c.y,c.z);this.normalizeNormals(),i.needsUpdate=!0}}merge(e,t){if(!e||!e.isBufferGeometry)return void console.error("THREE.BufferGeometry.merge(): geometry not an instance of THREE.BufferGeometry.",e);void 0===t&&(t=0,console.warn("THREE.BufferGeometry.merge(): Overwriting original geometry, starting at offset=0. Use BufferGeometryUtils.mergeBufferGeometries() for lossless merge."));const i=this.attributes;for(const n in i){if(void 0===e.attributes[n])continue;const r=i[n].array,s=e.attributes[n],a=s.array,o=s.itemSize*t,h=Math.min(a.length,r.length-o);for(let e=0,t=o;e<h;e++,t++)r[t]=a[e]}return this}normalizeNormals(){const e=this.attributes.normal;for(let t=0,i=e.count;t<i;t++)$r.fromBufferAttribute(e,t),$r.normalize(),e.setXYZ(t,$r.x,$r.y,$r.z)}toNonIndexed(){function e(e,t){const i=e.array,n=e.itemSize,r=e.normalized,s=new i.constructor(t.length*n);let a=0,o=0;for(let r=0,h=t.length;r<h;r++){a=e.isInterleavedBufferAttribute?t[r]*e.data.stride+e.offset:t[r]*n;for(let e=0;e<n;e++)s[o++]=i[a++]}return new Tr(s,n,r)}if(null===this.index)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new kr,i=this.index.array,n=this.attributes;for(const r in n){const s=e(n[r],i);t.setAttribute(r,s)}const r=this.morphAttributes;for(const n in r){const s=[],a=r[n];for(let t=0,n=a.length;t<n;t++){const n=e(a[t],i);s.push(n)}t.morphAttributes[n]=s}t.morphTargetsRelative=this.morphTargetsRelative;const s=this.groups;for(let e=0,i=s.length;e<i;e++){const i=s[e];t.addGroup(i.start,i.count,i.materialIndex)}return t}toJSON(){const e={metadata:{version:4.5,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,""!==this.name&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),void 0!==this.parameters){const t=this.parameters;for(const i in t)void 0!==t[i]&&(e[i]=t[i]);return e}e.data={attributes:{}};const t=this.index;null!==t&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const i=this.attributes;for(const t in i){const n=i[t];e.data.attributes[t]=n.toJSON(e.data)}const n={};let r=!1;for(const t in this.morphAttributes){const i=this.morphAttributes[t],s=[];for(let t=0,n=i.length;t<n;t++){const n=i[t];s.push(n.toJSON(e.data))}s.length>0&&(n[t]=s,r=!0)}r&&(e.data.morphAttributes=n,e.data.morphTargetsRelative=this.morphTargetsRelative);const s=this.groups;s.length>0&&(e.data.groups=JSON.parse(JSON.stringify(s)));const a=this.boundingSphere;return null!==a&&(e.data.boundingSphere={center:a.center.toArray(),radius:a.radius}),e}clone(){return(new this.constructor).copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const i=e.index;null!==i&&this.setIndex(i.clone(t));const n=e.attributes;for(const e in n){const i=n[e];this.setAttribute(e,i.clone(t))}const r=e.morphAttributes;for(const e in r){const i=[],n=r[e];for(let e=0,r=n.length;e<r;e++)i.push(n[e].clone(t));this.morphAttributes[e]=i}this.morphTargetsRelative=e.morphTargetsRelative;const s=e.groups;for(let e=0,t=s.length;e<t;e++){const t=s[e];this.addGroup(t.start,t.count,t.materialIndex)}const a=e.boundingBox;null!==a&&(this.boundingBox=a.clone());const o=e.boundingSphere;return null!==o&&(this.boundingSphere=o.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,void 0!==e.parameters&&(this.parameters=Object.assign({},e.parameters)),this}dispose(){this.dispatchEvent({type:"dispose"})}}kr.prototype.isBufferGeometry=!0;const Or=new Rn,zr=new In,Fr=new xn,Br=new Ki,Ur=new Ki,Vr=new Ki,Hr=new Ki,jr=new Ki,Gr=new Ki,Wr=new Ki,qr=new Ki,Xr=new Ki,Zr=new zi,Yr=new zi,Jr=new zi,Kr=new Ki,Qr=new Ki;class es extends tr{constructor(e=new kr,t=new wr){super(),this.type="Mesh",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e){return super.copy(e),void 0!==e.morphTargetInfluences&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),void 0!==e.morphTargetDictionary&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=e.material,this.geometry=e.geometry,this}updateMorphTargets(){const e=this.geometry;if(e.isBufferGeometry){const t=e.morphAttributes,i=Object.keys(t);if(i.length>0){const e=t[i[0]];if(void 0!==e){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,i=e.length;t<i;t++){const i=e[t].name||String(t);this.morphTargetInfluences.push(0),this.morphTargetDictionary[i]=t}}}}else{const t=e.morphTargets;void 0!==t&&t.length>0&&console.error("THREE.Mesh.updateMorphTargets() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")}}raycast(e,t){const i=this.geometry,n=this.material,r=this.matrixWorld;if(void 0===n)return;if(null===i.boundingSphere&&i.computeBoundingSphere(),Fr.copy(i.boundingSphere),Fr.applyMatrix4(r),!1===e.ray.intersectsSphere(Fr))return;if(Or.copy(r).invert(),zr.copy(e.ray).applyMatrix4(Or),null!==i.boundingBox&&!1===zr.intersectsBox(i.boundingBox))return;let s;if(i.isBufferGeometry){const r=i.index,a=i.attributes.position,o=i.morphAttributes.position,h=i.morphTargetsRelative,c=i.attributes.uv,l=i.attributes.uv2,u=i.groups,d=i.drawRange;if(null!==r)if(Array.isArray(n))for(let i=0,p=u.length;i<p;i++){const p=u[i],m=n[p.materialIndex];for(let i=Math.max(p.start,d.start),n=Math.min(r.count,Math.min(p.start+p.count,d.start+d.count));i<n;i+=3){const n=r.getX(i),u=r.getX(i+1),d=r.getX(i+2);s=ts(this,m,e,zr,a,o,h,c,l,n,u,d),s&&(s.faceIndex=Math.floor(i/3),s.face.materialIndex=p.materialIndex,t.push(s))}}else{for(let i=Math.max(0,d.start),u=Math.min(r.count,d.start+d.count);i<u;i+=3){const u=r.getX(i),d=r.getX(i+1),p=r.getX(i+2);s=ts(this,n,e,zr,a,o,h,c,l,u,d,p),s&&(s.faceIndex=Math.floor(i/3),t.push(s))}}else if(void 0!==a)if(Array.isArray(n))for(let i=0,r=u.length;i<r;i++){const r=u[i],p=n[r.materialIndex];for(let i=Math.max(r.start,d.start),n=Math.min(a.count,Math.min(r.start+r.count,d.start+d.count));i<n;i+=3){s=ts(this,p,e,zr,a,o,h,c,l,i,i+1,i+2),s&&(s.faceIndex=Math.floor(i/3),s.face.materialIndex=r.materialIndex,t.push(s))}}else{for(let i=Math.max(0,d.start),r=Math.min(a.count,d.start+d.count);i<r;i+=3){s=ts(this,n,e,zr,a,o,h,c,l,i,i+1,i+2),s&&(s.faceIndex=Math.floor(i/3),t.push(s))}}}else i.isGeometry&&console.error("THREE.Mesh.raycast() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")}}function ts(e,t,i,n,r,s,a,o,h,c,l,u){Br.fromBufferAttribute(r,c),Ur.fromBufferAttribute(r,l),Vr.fromBufferAttribute(r,u);const d=e.morphTargetInfluences;if(s&&d){Wr.set(0,0,0),qr.set(0,0,0),Xr.set(0,0,0);for(let e=0,t=s.length;e<t;e++){const t=d[e],i=s[e];0!==t&&(Hr.fromBufferAttribute(i,c),jr.fromBufferAttribute(i,l),Gr.fromBufferAttribute(i,u),a?(Wr.addScaledVector(Hr,t),qr.addScaledVector(jr,t),Xr.addScaledVector(Gr,t)):(Wr.addScaledVector(Hr.sub(Br),t),qr.addScaledVector(jr.sub(Ur),t),Xr.addScaledVector(Gr.sub(Vr),t)))}Br.add(Wr),Ur.add(qr),Vr.add(Xr)}e.isSkinnedMesh&&(e.boneTransform(c,Br),e.boneTransform(l,Ur),e.boneTransform(u,Vr));const p=function(e,t,i,n,r,s,a,o){let h;if(h=1===t.side?n.intersectTriangle(a,s,r,!0,o):n.intersectTriangle(r,s,a,2!==t.side,o),null===h)return null;Qr.copy(o),Qr.applyMatrix4(e.matrixWorld);const c=i.ray.origin.distanceTo(Qr);return c<i.near||c>i.far?null:{distance:c,point:Qr.clone(),object:e}}(e,t,i,n,Br,Ur,Vr,Kr);if(p){o&&(Zr.fromBufferAttribute(o,c),Yr.fromBufferAttribute(o,l),Jr.fromBufferAttribute(o,u),p.uv=dr.getUV(Kr,Br,Ur,Vr,Zr,Yr,Jr,new zi)),h&&(Zr.fromBufferAttribute(h,c),Yr.fromBufferAttribute(h,l),Jr.fromBufferAttribute(h,u),p.uv2=dr.getUV(Kr,Br,Ur,Vr,Zr,Yr,Jr,new zi));const e={a:c,b:l,c:u,normal:new Ki,materialIndex:0};dr.getNormal(Br,Ur,Vr,e.normal),p.face=e}return p}es.prototype.isMesh=!0;class is extends kr{constructor(e=1,t=1,i=1,n=1,r=1,s=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:i,widthSegments:n,heightSegments:r,depthSegments:s};const a=this;n=Math.floor(n),r=Math.floor(r),s=Math.floor(s);const o=[],h=[],c=[],l=[];let u=0,d=0;function p(e,t,i,n,r,s,p,m,f,g,_){const v=s/f,y=p/g,b=s/2,x=p/2,w=m/2,M=f+1,S=g+1;let T=0,C=0;const E=new Ki;for(let s=0;s<S;s++){const a=s*y-x;for(let o=0;o<M;o++){const u=o*v-b;E[e]=u*n,E[t]=a*r,E[i]=w,h.push(E.x,E.y,E.z),E[e]=0,E[t]=0,E[i]=m>0?1:-1,c.push(E.x,E.y,E.z),l.push(o/f),l.push(1-s/g),T+=1}}for(let e=0;e<g;e++)for(let t=0;t<f;t++){const i=u+t+M*e,n=u+t+M*(e+1),r=u+(t+1)+M*(e+1),s=u+(t+1)+M*e;o.push(i,n,s),o.push(n,r,s),C+=6}a.addGroup(d,C,_),d+=C,u+=T}p("z","y","x",-1,-1,i,t,e,s,r,0),p("z","y","x",1,-1,i,t,-e,s,r,1),p("x","z","y",1,1,e,i,t,n,s,2),p("x","z","y",1,-1,e,i,-t,n,s,3),p("x","y","z",1,-1,e,t,i,n,r,4),p("x","y","z",-1,-1,e,t,-i,n,r,5),this.setIndex(o),this.setAttribute("position",new Ar(h,3)),this.setAttribute("normal",new Ar(c,3)),this.setAttribute("uv",new Ar(l,2))}static fromJSON(e){return new is(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function ns(e){const t={};for(const i in e){t[i]={};for(const n in e[i]){const r=e[i][n];r&&(r.isColor||r.isMatrix3||r.isMatrix4||r.isVector2||r.isVector3||r.isVector4||r.isTexture||r.isQuaternion)?t[i][n]=r.clone():Array.isArray(r)?t[i][n]=r.slice():t[i][n]=r}}return t}function rs(e){const t={};for(let i=0;i<e.length;i++){const n=ns(e[i]);for(const e in n)t[e]=n[e]}return t}const ss={clone:ns,merge:rs};class as extends mr{constructor(e){super(),this.type="ShaderMaterial",this.defines={},this.uniforms={},this.vertexShader="void main() {\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",this.fragmentShader="void main() {\n\tgl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );\n}",this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv2:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,void 0!==e&&(void 0!==e.attributes&&console.error("THREE.ShaderMaterial: attributes should now be defined in THREE.BufferGeometry instead."),this.setValues(e))}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=ns(e.uniforms),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this}toJSON(e){const t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(const i in this.uniforms){const n=this.uniforms[i].value;n&&n.isTexture?t.uniforms[i]={type:"t",value:n.toJSON(e).uuid}:n&&n.isColor?t.uniforms[i]={type:"c",value:n.getHex()}:n&&n.isVector2?t.uniforms[i]={type:"v2",value:n.toArray()}:n&&n.isVector3?t.uniforms[i]={type:"v3",value:n.toArray()}:n&&n.isVector4?t.uniforms[i]={type:"v4",value:n.toArray()}:n&&n.isMatrix3?t.uniforms[i]={type:"m3",value:n.toArray()}:n&&n.isMatrix4?t.uniforms[i]={type:"m4",value:n.toArray()}:t.uniforms[i]={value:n}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader;const i={};for(const e in this.extensions)!0===this.extensions[e]&&(i[e]=!0);return Object.keys(i).length>0&&(t.extensions=i),t}}as.prototype.isShaderMaterial=!0;class os extends tr{constructor(){super(),this.type="Camera",this.matrixWorldInverse=new Rn,this.projectionMatrix=new Rn,this.projectionMatrixInverse=new Rn}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(-t[8],-t[9],-t[10]).normalize()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return(new this.constructor).copy(this)}}os.prototype.isCamera=!0;class hs extends os{constructor(e=50,t=1,i=.1,n=2e3){super(),this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=i,this.far=n,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=null===e.view?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const t=.5*this.getFilmHeight()/e;this.fov=2*Ai*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(.5*Ei*this.fov);return.5*this.getFilmHeight()/e}getEffectiveFOV(){return 2*Ai*Math.atan(Math.tan(.5*Ei*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}setViewOffset(e,t,i,n,r,s){this.aspect=e/t,null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=n,this.view.width=r,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(.5*Ei*this.fov)/this.zoom,i=2*t,n=this.aspect*i,r=-.5*n;const s=this.view;if(null!==this.view&&this.view.enabled){const e=s.fullWidth,a=s.fullHeight;r+=s.offsetX*n/e,t-=s.offsetY*i/a,n*=s.width/e,i*=s.height/a}const a=this.filmOffset;0!==a&&(r+=e*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+n,t,t-i,e,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,null!==this.view&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}hs.prototype.isPerspectiveCamera=!0;const cs=90;class ls extends tr{constructor(e,t,i){if(super(),this.type="CubeCamera",!0!==i.isWebGLCubeRenderTarget)return void console.error("THREE.CubeCamera: The constructor now expects an instance of WebGLCubeRenderTarget as third parameter.");this.renderTarget=i;const n=new hs(cs,1,e,t);n.layers=this.layers,n.up.set(0,-1,0),n.lookAt(new Ki(1,0,0)),this.add(n);const r=new hs(cs,1,e,t);r.layers=this.layers,r.up.set(0,-1,0),r.lookAt(new Ki(-1,0,0)),this.add(r);const s=new hs(cs,1,e,t);s.layers=this.layers,s.up.set(0,0,1),s.lookAt(new Ki(0,1,0)),this.add(s);const a=new hs(cs,1,e,t);a.layers=this.layers,a.up.set(0,0,-1),a.lookAt(new Ki(0,-1,0)),this.add(a);const o=new hs(cs,1,e,t);o.layers=this.layers,o.up.set(0,-1,0),o.lookAt(new Ki(0,0,1)),this.add(o);const h=new hs(cs,1,e,t);h.layers=this.layers,h.up.set(0,-1,0),h.lookAt(new Ki(0,0,-1)),this.add(h)}update(e,t){null===this.parent&&this.updateMatrixWorld();const i=this.renderTarget,[n,r,s,a,o,h]=this.children,c=e.xr.enabled,l=e.getRenderTarget();e.xr.enabled=!1;const u=i.texture.generateMipmaps;i.texture.generateMipmaps=!1,e.setRenderTarget(i,0),e.render(t,n),e.setRenderTarget(i,1),e.render(t,r),e.setRenderTarget(i,2),e.render(t,s),e.setRenderTarget(i,3),e.render(t,a),e.setRenderTarget(i,4),e.render(t,o),i.texture.generateMipmaps=u,e.setRenderTarget(i,5),e.render(t,h),e.setRenderTarget(l),e.xr.enabled=c}}class us extends Wi{constructor(e,t,i,n,r,s,a,o,h,c){super(e=void 0!==e?e:[],t=void 0!==t?t:Gt,i,n,r,s,a,o,h,c),this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}us.prototype.isCubeTexture=!0;class ds extends Zi{constructor(e,t,i){Number.isInteger(t)&&(console.warn("THREE.WebGLCubeRenderTarget: constructor signature is now WebGLCubeRenderTarget( size, options )"),t=i),super(e,e,t),t=t||{},this.texture=new us(void 0,t.mapping,t.wrapS,t.wrapT,t.magFilter,t.minFilter,t.format,t.type,t.anisotropy,t.encoding),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=void 0!==t.generateMipmaps&&t.generateMipmaps,this.texture.minFilter=void 0!==t.minFilter?t.minFilter:Kt,this.texture._needsFlipEnvMap=!1}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.format=oi,this.texture.encoding=t.encoding,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const i={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 <begin_vertex>\n\t\t\t\t\t#include <project_vertex>\n\n\t\t\t\t}\n\t\t\t",fragmentShader:"\n\n\t\t\t\tuniform sampler2D tEquirect;\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\t#include <common>\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvec3 direction = normalize( vWorldDirection );\n\n\t\t\t\t\tvec2 sampleUV = equirectUv( direction );\n\n\t\t\t\t\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\n\t\t\t\t}\n\t\t\t"},n=new is(5,5,5),r=new as({name:"CubemapFromEquirect",uniforms:ns(i.uniforms),vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,side:1,blending:0});r.uniforms.tEquirect.value=t;const s=new es(n,r),a=t.minFilter;t.minFilter===Qt&&(t.minFilter=Kt);return new ls(1,10,this).update(e,s),t.minFilter=a,s.geometry.dispose(),s.material.dispose(),this}clear(e,t,i,n){const r=e.getRenderTarget();for(let r=0;r<6;r++)e.setRenderTarget(this,r),e.clear(t,i,n);e.setRenderTarget(r)}}ds.prototype.isWebGLCubeRenderTarget=!0;const ps=new Ki,ms=new Ki,fs=new Fi;class gs{constructor(e=new Ki(1,0,0),t=0){this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,i,n){return this.normal.set(e,t,i),this.constant=n,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,i){const n=ps.subVectors(i,t).cross(ms.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(n,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(this.normal).multiplyScalar(-this.distanceToPoint(e)).add(e)}intersectLine(e,t){const i=e.delta(ps),n=this.normal.dot(i);if(0===n)return 0===this.distanceToPoint(e.start)?t.copy(e.start):null;const r=-(e.start.dot(this.normal)+this.constant)/n;return r<0||r>1?null:t.copy(i).multiplyScalar(r).add(e.start)}intersectsLine(e){const t=this.distanceToPoint(e.start),i=this.distanceToPoint(e.end);return t<0&&i>0||i<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const i=t||fs.getNormalMatrix(e),n=this.coplanarPoint(ps).applyMatrix4(e),r=this.normal.applyMatrix3(i).normalize();return this.constant=-n.dot(r),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return(new this.constructor).copy(this)}}gs.prototype.isPlane=!0;const _s=new xn,vs=new Ki;class ys{constructor(e=new gs,t=new gs,i=new gs,n=new gs,r=new gs,s=new gs){this.planes=[e,t,i,n,r,s]}set(e,t,i,n,r,s){const a=this.planes;return a[0].copy(e),a[1].copy(t),a[2].copy(i),a[3].copy(n),a[4].copy(r),a[5].copy(s),this}copy(e){const t=this.planes;for(let i=0;i<6;i++)t[i].copy(e.planes[i]);return this}setFromProjectionMatrix(e){const t=this.planes,i=e.elements,n=i[0],r=i[1],s=i[2],a=i[3],o=i[4],h=i[5],c=i[6],l=i[7],u=i[8],d=i[9],p=i[10],m=i[11],f=i[12],g=i[13],_=i[14],v=i[15];return t[0].setComponents(a-n,l-o,m-u,v-f).normalize(),t[1].setComponents(a+n,l+o,m+u,v+f).normalize(),t[2].setComponents(a+r,l+h,m+d,v+g).normalize(),t[3].setComponents(a-r,l-h,m-d,v-g).normalize(),t[4].setComponents(a-s,l-c,m-p,v-_).normalize(),t[5].setComponents(a+s,l+c,m+p,v+_).normalize(),this}intersectsObject(e){const t=e.geometry;return null===t.boundingSphere&&t.computeBoundingSphere(),_s.copy(t.boundingSphere).applyMatrix4(e.matrixWorld),this.intersectsSphere(_s)}intersectsSprite(e){return _s.center.set(0,0,0),_s.radius=.7071067811865476,_s.applyMatrix4(e.matrixWorld),this.intersectsSphere(_s)}intersectsSphere(e){const t=this.planes,i=e.center,n=-e.radius;for(let e=0;e<6;e++){if(t[e].distanceToPoint(i)<n)return!1}return!0}intersectsBox(e){const t=this.planes;for(let i=0;i<6;i++){const n=t[i];if(vs.x=n.normal.x>0?e.max.x:e.min.x,vs.y=n.normal.y>0?e.max.y:e.min.y,vs.z=n.normal.z>0?e.max.z:e.min.z,n.distanceToPoint(vs)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let i=0;i<6;i++)if(t[i].distanceToPoint(e)<0)return!1;return!0}clone(){return(new this.constructor).copy(this)}}function bs(){let e=null,t=!1,i=null,n=null;function r(t,s){i(t,s),n=e.requestAnimationFrame(r)}return{start:function(){!0!==t&&null!==i&&(n=e.requestAnimationFrame(r),t=!0)},stop:function(){e.cancelAnimationFrame(n),t=!1},setAnimationLoop:function(e){i=e},setContext:function(t){e=t}}}function xs(e,t){const i=t.isWebGL2,n=new WeakMap;return{get:function(e){return e.isInterleavedBufferAttribute&&(e=e.data),n.get(e)},remove:function(t){t.isInterleavedBufferAttribute&&(t=t.data);const i=n.get(t);i&&(e.deleteBuffer(i.buffer),n.delete(t))},update:function(t,r){if(t.isGLBufferAttribute){const e=n.get(t);return void((!e||e.version<t.version)&&n.set(t,{buffer:t.buffer,type:t.type,bytesPerElement:t.elementSize,version:t.version}))}t.isInterleavedBufferAttribute&&(t=t.data);const s=n.get(t);void 0===s?n.set(t,function(t,n){const r=t.array,s=t.usage,a=e.createBuffer();e.bindBuffer(n,a),e.bufferData(n,r,s),t.onUploadCallback();let o=5126;return r instanceof Float32Array?o=5126:r instanceof Float64Array?console.warn("THREE.WebGLAttributes: Unsupported data buffer format: Float64Array."):r instanceof Uint16Array?t.isFloat16BufferAttribute?i?o=5131:console.warn("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2."):o=5123:r instanceof Int16Array?o=5122:r instanceof Uint32Array?o=5125:r instanceof Int32Array?o=5124:r instanceof Int8Array?o=5120:(r instanceof Uint8Array||r instanceof Uint8ClampedArray)&&(o=5121),{buffer:a,type:o,bytesPerElement:r.BYTES_PER_ELEMENT,version:t.version}}(t,r)):s.version<t.version&&(!function(t,n,r){const s=n.array,a=n.updateRange;e.bindBuffer(r,t),-1===a.count?e.bufferSubData(r,0,s):(i?e.bufferSubData(r,a.offset*s.BYTES_PER_ELEMENT,s,a.offset,a.count):e.bufferSubData(r,a.offset*s.BYTES_PER_ELEMENT,s.subarray(a.offset,a.offset+a.count)),a.count=-1)}(s.buffer,t,r),s.version=t.version)}}}class ws extends kr{constructor(e=1,t=1,i=1,n=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:i,heightSegments:n};const r=e/2,s=t/2,a=Math.floor(i),o=Math.floor(n),h=a+1,c=o+1,l=e/a,u=t/o,d=[],p=[],m=[],f=[];for(let e=0;e<c;e++){const t=e*u-s;for(let i=0;i<h;i++){const n=i*l-r;p.push(n,-t,0),m.push(0,0,1),f.push(i/a),f.push(1-e/o)}}for(let e=0;e<o;e++)for(let t=0;t<a;t++){const i=t+h*e,n=t+h*(e+1),r=t+1+h*(e+1),s=t+1+h*e;d.push(i,n,s),d.push(n,r,s)}this.setIndex(d),this.setAttribute("position",new Ar(p,3)),this.setAttribute("normal",new Ar(m,3)),this.setAttribute("uv",new Ar(f,2))}static fromJSON(e){return new ws(e.width,e.height,e.widthSegments,e.heightSegments)}}const Ms={alphamap_fragment:"#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, vUv ).g;\n#endif",alphamap_pars_fragment:"#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",alphatest_fragment:"#ifdef USE_ALPHATEST\n\tif ( diffuseColor.a < alphaTest ) discard;\n#endif",alphatest_pars_fragment:"#ifdef USE_ALPHATEST\n\tuniform float alphaTest;\n#endif",aomap_fragment:"#ifdef USE_AOMAP\n\tfloat ambientOcclusion = ( texture2D( aoMap, vUv2 ).r - 1.0 ) * aoMapIntensity + 1.0;\n\treflectedLight.indirectDiffuse *= ambientOcclusion;\n\t#if defined( USE_ENVMAP ) && defined( STANDARD )\n\t\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\t\treflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );\n\t#endif\n#endif",aomap_pars_fragment:"#ifdef USE_AOMAP\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n#endif",begin_vertex:"vec3 transformed = vec3( position );",beginnormal_vertex:"vec3 objectNormal = vec3( normal );\n#ifdef USE_TANGENT\n\tvec3 objectTangent = vec3( tangent.xyz );\n#endif",bsdfs:"vec3 BRDF_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n}\nfloat V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\nvec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 f0, const in float f90, const in float roughness ) {\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( 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 dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( f0, f90, dotVH );\n\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\tfloat D = D_GGX( alpha, dotNH );\n\treturn F * ( V * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\nfloat G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_BlinnPhong( const in 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}\nconst mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );\nvec4 LinearToLogLuv( in vec4 value ) {\n\tvec3 Xp_Y_XYZp = cLogLuvM * value.rgb;\n\tXp_Y_XYZp = max( Xp_Y_XYZp, vec3( 1e-6, 1e-6, 1e-6 ) );\n\tvec4 vResult;\n\tvResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;\n\tfloat Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;\n\tvResult.w = fract( Le );\n\tvResult.z = ( Le - ( floor( vResult.w * 255.0 ) ) / 255.0 ) / 255.0;\n\treturn vResult;\n}\nconst mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );\nvec4 LogLuvToLinear( in vec4 value ) {\n\tfloat Le = value.z * 255.0 + value.w;\n\tvec3 Xp_Y_XYZp;\n\tXp_Y_XYZp.y = exp2( ( Le - 127.0 ) / 2.0 );\n\tXp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;\n\tXp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;\n\tvec3 vRGB = cLogLuvInverseM * Xp_Y_XYZp.rgb;\n\treturn vec4( max( vRGB, 0.0 ), 1.0 );\n}",envmap_fragment:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvec3 cameraToFrag;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToFrag, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t\tenvColor = envMapTexelToLinear( envColor );\n\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\tvec4 envColor = textureCubeUV( envMap, reflectVec, 0.0 );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif",envmap_common_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float envMapIntensity;\n\tuniform float flipEnvMap;\n\tuniform int maxMipLevel;\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\t\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float reflectivity;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\tvarying vec3 vWorldPosition;\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) ||defined( PHONG )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\t\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif",envmap_physical_pars_fragment:"#if defined( USE_ENVMAP )\n\t#ifdef ENVMAP_MODE_REFRACTION\n\t\tuniform float refractionRatio;\n\t#endif\n\tvec3 getIBLIrradiance( const in 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 <tonemapping_fragment>\n\t#include <encodings_fragment>\n}",cube_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\tgl_Position.z = gl_Position.w;\n}",cube_frag:"#include <envmap_common_pars_fragment>\nuniform float opacity;\nvarying vec3 vWorldDirection;\n#include <cube_uv_reflection_fragment>\nvoid main() {\n\tvec3 vReflect = vWorldDirection;\n\t#include <envmap_fragment>\n\tgl_FragColor = envColor;\n\tgl_FragColor.a *= opacity;\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n}",depth_vert:"#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include <uv_vertex>\n\t#include <skinbase_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvHighPrecisionZW = gl_Position.zw;\n}",depth_frag:"#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <logdepthbuf_fragment>\n\tfloat fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;\n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( fragCoordZ );\n\t#endif\n}",distanceRGBA_vert:"#define DISTANCE\nvarying vec3 vWorldPosition;\n#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <skinbase_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <worldpos_vertex>\n\t#include <clipping_planes_vertex>\n\tvWorldPosition = worldPosition.xyz;\n}",distanceRGBA_frag:"#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main () {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = packDepthToRGBA( dist );\n}",equirect_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n}",equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvec3 direction = normalize( vWorldDirection );\n\tvec2 sampleUV = equirectUv( direction );\n\tvec4 texColor = texture2D( tEquirect, sampleUV );\n\tgl_FragColor = mapTexelToLinear( texColor );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n}",linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\tvLineDistance = scale * lineDistance;\n\t#include <color_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}",linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include <common>\n#include <color_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <color_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}",meshbasic_vert:"#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinbase_vertex>\n\t\t#include <skinnormal_vertex>\n\t\t#include <defaultnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <fog_vertex>\n}",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <cube_uv_reflection_fragment>\n#include <fog_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <specularmap_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel= texture2D( lightMap, vUv2 );\n\t\treflectedLight.indirectDiffuse += lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include <aomap_fragment>\n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include <envmap_fragment>\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshlambert_vert:"#define LAMBERT\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n\tvarying vec3 vIndirectBack;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <envmap_pars_vertex>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <lights_lambert_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshlambert_frag:"uniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n\tvarying vec3 vIndirectBack;\n#endif\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <cube_uv_reflection_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <fog_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <shadowmask_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <specularmap_fragment>\n\t#include <emissivemap_fragment>\n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.indirectDiffuse += ( gl_FrontFacing ) ? vIndirectFront : vIndirectBack;\n\t#else\n\t\treflectedLight.indirectDiffuse += vIndirectFront;\n\t#endif\n\t#include <lightmap_fragment>\n\treflectedLight.indirectDiffuse *= BRDF_Lambert( diffuseColor.rgb );\n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.directDiffuse = ( gl_FrontFacing ) ? vLightFront : vLightBack;\n\t#else\n\t\treflectedLight.directDiffuse = vLightFront;\n\t#endif\n\treflectedLight.directDiffuse *= BRDF_Lambert( diffuseColor.rgb ) * getShadowMask();\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshmatcap_vert:"#define MATCAP\nvarying vec3 vViewPosition;\n#include <common>\n#include <uv_pars_vertex>\n#include <color_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n\tvViewPosition = - mvPosition.xyz;\n}",meshmatcap_frag:"#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <fog_pars_fragment>\n#include <normal_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\tvec3 viewDir = normalize( vViewPosition );\n\tvec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n\tvec3 y = cross( viewDir, x );\n\tvec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;\n\t#ifdef USE_MATCAP\n\t\tvec4 matcapColor = texture2D( matcap, uv );\n\t\tmatcapColor = matcapTexelToLinear( matcapColor );\n\t#else\n\t\tvec4 matcapColor = vec4( 1.0 );\n\t#endif\n\tvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshnormal_vert:"#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}",meshnormal_frag:"#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#include <packing>\n#include <uv_pars_fragment>\n#include <normal_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\t#include <logdepthbuf_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\tgl_FragColor = vec4( packNormalToRGB( normal ), opacity );\n}",meshphong_vert:"#define PHONG\nvarying vec3 vViewPosition;\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <cube_uv_reflection_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_phong_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_phong_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshphysical_vert:"#define STANDARD\nvarying vec3 vViewPosition;\n#ifdef USE_TRANSMISSION\n\tvarying vec3 vWorldPosition;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n#ifdef USE_TRANSMISSION\n\tvWorldPosition = worldPosition.xyz;\n#endif\n}",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 <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <bsdfs>\n#include <cube_uv_reflection_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_physical_pars_fragment>\n#include <fog_pars_fragment>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_physical_pars_fragment>\n#include <transmission_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <clearcoat_pars_fragment>\n#include <roughnessmap_pars_fragment>\n#include <metalnessmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <roughnessmap_fragment>\n\t#include <metalnessmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <clearcoat_normal_fragment_begin>\n\t#include <clearcoat_normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_physical_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\n\tvec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n\t#include <transmission_fragment>\n\tvec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNVcc = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) );\n\t\tvec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );\n\t\toutgoingLight = outgoingLight * ( 1.0 - clearcoat * Fcc ) + clearcoatSpecular * clearcoat;\n\t#endif\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshtoon_vert:"#define TOON\nvarying vec3 vViewPosition;\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshtoon_frag:"#define TOON\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <gradientmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_toon_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_toon_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",points_vert:"uniform float size;\nuniform float scale;\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <color_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\tgl_PointSize = size;\n\t#ifdef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n\t#endif\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <fog_vertex>\n}",points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <color_pars_fragment>\n#include <map_particle_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_particle_fragment>\n\t#include <color_fragment>\n\t#include <alphatest_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}",shadow_vert:"#include <common>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\nvoid main() {\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",shadow_frag:"uniform vec3 color;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <shadowmap_pars_fragment>\n#include <shadowmask_pars_fragment>\nvoid main() {\n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n}",sprite_vert:"uniform float rotation;\nuniform vec2 center;\n#include <common>\n#include <uv_pars_vertex>\n#include <fog_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\tvec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\n\tvec2 scale;\n\tscale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );\n\tscale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );\n\t#ifndef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) scale *= - mvPosition.z;\n\t#endif\n\tvec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n\tvec2 rotatedPosition;\n\trotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n\trotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n\tmvPosition.xy += rotatedPosition;\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}",sprite_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n}"},Ss={common:{diffuse:{value:new xr(16777215)},opacity:{value:1},map:{value:null},uvTransform:{value:new Fi},uv2Transform:{value:new Fi},alphaMap:{value:null},alphaTest:{value:0}},specularmap:{specularMap:{value:null}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},maxMipLevel:{value:0}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1}},emissivemap:{emissiveMap:{value:null}},bumpmap:{bumpMap:{value:null},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalScale:{value:new zi(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 xr(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 xr(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaTest:{value:0},uvTransform:{value:new Fi}},sprite:{diffuse:{value:new xr(16777215)},opacity:{value:1},center:{value:new zi(.5,.5)},rotation:{value:0},map:{value:null},alphaMap:{value:null},alphaTest:{value:0},uvTransform:{value:new Fi}}},Ts={basic:{uniforms:rs([Ss.common,Ss.specularmap,Ss.envmap,Ss.aomap,Ss.lightmap,Ss.fog]),vertexShader:Ms.meshbasic_vert,fragmentShader:Ms.meshbasic_frag},lambert:{uniforms:rs([Ss.common,Ss.specularmap,Ss.envmap,Ss.aomap,Ss.lightmap,Ss.emissivemap,Ss.fog,Ss.lights,{emissive:{value:new xr(0)}}]),vertexShader:Ms.meshlambert_vert,fragmentShader:Ms.meshlambert_frag},phong:{uniforms:rs([Ss.common,Ss.specularmap,Ss.envmap,Ss.aomap,Ss.lightmap,Ss.emissivemap,Ss.bumpmap,Ss.normalmap,Ss.displacementmap,Ss.fog,Ss.lights,{emissive:{value:new xr(0)},specular:{value:new xr(1118481)},shininess:{value:30}}]),vertexShader:Ms.meshphong_vert,fragmentShader:Ms.meshphong_frag},standard:{uniforms:rs([Ss.common,Ss.envmap,Ss.aomap,Ss.lightmap,Ss.emissivemap,Ss.bumpmap,Ss.normalmap,Ss.displacementmap,Ss.roughnessmap,Ss.metalnessmap,Ss.fog,Ss.lights,{emissive:{value:new xr(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Ms.meshphysical_vert,fragmentShader:Ms.meshphysical_frag},toon:{uniforms:rs([Ss.common,Ss.aomap,Ss.lightmap,Ss.emissivemap,Ss.bumpmap,Ss.normalmap,Ss.displacementmap,Ss.gradientmap,Ss.fog,Ss.lights,{emissive:{value:new xr(0)}}]),vertexShader:Ms.meshtoon_vert,fragmentShader:Ms.meshtoon_frag},matcap:{uniforms:rs([Ss.common,Ss.bumpmap,Ss.normalmap,Ss.displacementmap,Ss.fog,{matcap:{value:null}}]),vertexShader:Ms.meshmatcap_vert,fragmentShader:Ms.meshmatcap_frag},points:{uniforms:rs([Ss.points,Ss.fog]),vertexShader:Ms.points_vert,fragmentShader:Ms.points_frag},dashed:{uniforms:rs([Ss.common,Ss.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Ms.linedashed_vert,fragmentShader:Ms.linedashed_frag},depth:{uniforms:rs([Ss.common,Ss.displacementmap]),vertexShader:Ms.depth_vert,fragmentShader:Ms.depth_frag},normal:{uniforms:rs([Ss.common,Ss.bumpmap,Ss.normalmap,Ss.displacementmap,{opacity:{value:1}}]),vertexShader:Ms.meshnormal_vert,fragmentShader:Ms.meshnormal_frag},sprite:{uniforms:rs([Ss.sprite,Ss.fog]),vertexShader:Ms.sprite_vert,fragmentShader:Ms.sprite_frag},background:{uniforms:{uvTransform:{value:new Fi},t2D:{value:null}},vertexShader:Ms.background_vert,fragmentShader:Ms.background_frag},cube:{uniforms:rs([Ss.envmap,{opacity:{value:1}}]),vertexShader:Ms.cube_vert,fragmentShader:Ms.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Ms.equirect_vert,fragmentShader:Ms.equirect_frag},distanceRGBA:{uniforms:rs([Ss.common,Ss.displacementmap,{referencePosition:{value:new Ki},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Ms.distanceRGBA_vert,fragmentShader:Ms.distanceRGBA_frag},shadow:{uniforms:rs([Ss.lights,Ss.fog,{color:{value:new xr(0)},opacity:{value:1}}]),vertexShader:Ms.shadow_vert,fragmentShader:Ms.shadow_frag}};function Cs(e,t,i,n,r){const s=new xr(0);let a,o,h=0,c=null,l=0,u=null;function d(e,t){i.buffers.color.setClear(e.r,e.g,e.b,t,r)}return{getClearColor:function(){return s},setClearColor:function(e,t=1){s.set(e),h=t,d(s,h)},getClearAlpha:function(){return h},setClearAlpha:function(e){h=e,d(s,h)},render:function(i,r){let p=!1,m=!0===r.isScene?r.background:null;m&&m.isTexture&&(m=t.get(m));const f=e.xr,g=f.getSession&&f.getSession();g&&"additive"===g.environmentBlendMode&&(m=null),null===m?d(s,h):m&&m.isColor&&(d(m,1),p=!0),(e.autoClear||p)&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),m&&(m.isCubeTexture||m.mapping===qt)?(void 0===o&&(o=new es(new is(1,1,1),new as({name:"BackgroundCubeMaterial",uniforms:ns(Ts.cube.uniforms),vertexShader:Ts.cube.vertexShader,fragmentShader:Ts.cube.fragmentShader,side:1,depthTest:!1,depthWrite:!1,fog:!1})),o.geometry.deleteAttribute("normal"),o.geometry.deleteAttribute("uv"),o.onBeforeRender=function(e,t,i){this.matrixWorld.copyPosition(i.matrixWorld)},Object.defineProperty(o.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),n.update(o)),o.material.uniforms.envMap.value=m,o.material.uniforms.flipEnvMap.value=m.isCubeTexture&&!1===m.isRenderTargetTexture?-1:1,c===m&&l===m.version&&u===e.toneMapping||(o.material.needsUpdate=!0,c=m,l=m.version,u=e.toneMapping),i.unshift(o,o.geometry,o.material,0,0,null)):m&&m.isTexture&&(void 0===a&&(a=new es(new ws(2,2),new as({name:"BackgroundMaterial",uniforms:ns(Ts.background.uniforms),vertexShader:Ts.background.vertexShader,fragmentShader:Ts.background.fragmentShader,side:0,depthTest:!1,depthWrite:!1,fog:!1})),a.geometry.deleteAttribute("normal"),Object.defineProperty(a.material,"map",{get:function(){return this.uniforms.t2D.value}}),n.update(a)),a.material.uniforms.t2D.value=m,!0===m.matrixAutoUpdate&&m.updateMatrix(),a.material.uniforms.uvTransform.value.copy(m.matrix),c===m&&l===m.version&&u===e.toneMapping||(a.material.needsUpdate=!0,c=m,l=m.version,u=e.toneMapping),i.unshift(a,a.geometry,a.material,0,0,null))}}}function Es(e,t,i,n){const r=e.getParameter(34921),s=n.isWebGL2?null:t.get("OES_vertex_array_object"),a=n.isWebGL2||null!==s,o={},h=d(null);let c=h;function l(t){return n.isWebGL2?e.bindVertexArray(t):s.bindVertexArrayOES(t)}function u(t){return n.isWebGL2?e.deleteVertexArray(t):s.deleteVertexArrayOES(t)}function d(e){const t=[],i=[],n=[];for(let e=0;e<r;e++)t[e]=0,i[e]=0,n[e]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:t,enabledAttributes:i,attributeDivisors:n,object:e,attributes:{},index:null}}function p(){const e=c.newAttributes;for(let t=0,i=e.length;t<i;t++)e[t]=0}function m(e){f(e,0)}function f(i,r){const s=c.newAttributes,a=c.enabledAttributes,o=c.attributeDivisors;if(s[i]=1,0===a[i]&&(e.enableVertexAttribArray(i),a[i]=1),o[i]!==r){(n.isWebGL2?e:t.get("ANGLE_instanced_arrays"))[n.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](i,r),o[i]=r}}function g(){const t=c.newAttributes,i=c.enabledAttributes;for(let n=0,r=i.length;n<r;n++)i[n]!==t[n]&&(e.disableVertexAttribArray(n),i[n]=0)}function _(t,i,r,s,a,o){!0!==n.isWebGL2||5124!==r&&5125!==r?e.vertexAttribPointer(t,i,r,s,a,o):e.vertexAttribIPointer(t,i,r,a,o)}function v(){y(),c!==h&&(c=h,l(c.object))}function y(){h.geometry=null,h.program=null,h.wireframe=!1}return{setup:function(r,h,u,v,y){let b=!1;if(a){const t=function(t,i,r){const a=!0===r.wireframe;let h=o[t.id];void 0===h&&(h={},o[t.id]=h);let c=h[i.id];void 0===c&&(c={},h[i.id]=c);let l=c[a];void 0===l&&(l=d(n.isWebGL2?e.createVertexArray():s.createVertexArrayOES()),c[a]=l);return l}(v,u,h);c!==t&&(c=t,l(c.object)),b=function(e,t){const i=c.attributes,n=e.attributes;let r=0;for(const e in n){const t=i[e],s=n[e];if(void 0===t)return!0;if(t.attribute!==s)return!0;if(t.data!==s.data)return!0;r++}return c.attributesNum!==r||c.index!==t}(v,y),b&&function(e,t){const i={},n=e.attributes;let r=0;for(const e in n){const t=n[e],s={};s.attribute=t,t.data&&(s.data=t.data),i[e]=s,r++}c.attributes=i,c.attributesNum=r,c.index=t}(v,y)}else{const e=!0===h.wireframe;c.geometry===v.id&&c.program===u.id&&c.wireframe===e||(c.geometry=v.id,c.program=u.id,c.wireframe=e,b=!0)}!0===r.isInstancedMesh&&(b=!0),null!==y&&i.update(y,34963),b&&(!function(r,s,a,o){if(!1===n.isWebGL2&&(r.isInstancedMesh||o.isInstancedBufferGeometry)&&null===t.get("ANGLE_instanced_arrays"))return;p();const h=o.attributes,c=a.getAttributes(),l=s.defaultAttributeValues;for(const t in c){const n=c[t];if(n.location>=0){let s=h[t];if(void 0===s&&("instanceMatrix"===t&&r.instanceMatrix&&(s=r.instanceMatrix),"instanceColor"===t&&r.instanceColor&&(s=r.instanceColor)),void 0!==s){const t=s.normalized,a=s.itemSize,h=i.get(s);if(void 0===h)continue;const c=h.buffer,l=h.type,u=h.bytesPerElement;if(s.isInterleavedBufferAttribute){const i=s.data,h=i.stride,d=s.offset;if(i&&i.isInstancedInterleavedBuffer){for(let e=0;e<n.locationSize;e++)f(n.location+e,i.meshPerAttribute);!0!==r.isInstancedMesh&&void 0===o._maxInstanceCount&&(o._maxInstanceCount=i.meshPerAttribute*i.count)}else for(let e=0;e<n.locationSize;e++)m(n.location+e);e.bindBuffer(34962,c);for(let e=0;e<n.locationSize;e++)_(n.location+e,a/n.locationSize,l,t,h*u,(d+a/n.locationSize*e)*u)}else{if(s.isInstancedBufferAttribute){for(let e=0;e<n.locationSize;e++)f(n.location+e,s.meshPerAttribute);!0!==r.isInstancedMesh&&void 0===o._maxInstanceCount&&(o._maxInstanceCount=s.meshPerAttribute*s.count)}else for(let e=0;e<n.locationSize;e++)m(n.location+e);e.bindBuffer(34962,c);for(let e=0;e<n.locationSize;e++)_(n.location+e,a/n.locationSize,l,t,a*u,a/n.locationSize*e*u)}}else if(void 0!==l){const i=l[t];if(void 0!==i)switch(i.length){case 2:e.vertexAttrib2fv(n.location,i);break;case 3:e.vertexAttrib3fv(n.location,i);break;case 4:e.vertexAttrib4fv(n.location,i);break;default:e.vertexAttrib1fv(n.location,i)}}}}g()}(r,h,u,v),null!==y&&e.bindBuffer(34963,i.get(y).buffer))},reset:v,resetDefaultState:y,dispose:function(){v();for(const e in o){const t=o[e];for(const e in t){const i=t[e];for(const e in i)u(i[e].object),delete i[e];delete t[e]}delete o[e]}},releaseStatesOfGeometry:function(e){if(void 0===o[e.id])return;const t=o[e.id];for(const e in t){const i=t[e];for(const e in i)u(i[e].object),delete i[e];delete t[e]}delete o[e.id]},releaseStatesOfProgram:function(e){for(const t in o){const i=o[t];if(void 0===i[e.id])continue;const n=i[e.id];for(const e in n)u(n[e].object),delete n[e];delete i[e.id]}},initAttributes:p,enableAttribute:m,disableUnusedAttributes:g}}function As(e,t,i,n){const r=n.isWebGL2;let s;this.setMode=function(e){s=e},this.render=function(t,n){e.drawArrays(s,t,n),i.update(n,s,1)},this.renderInstances=function(n,a,o){if(0===o)return;let h,c;if(r)h=e,c="drawArraysInstanced";else if(h=t.get("ANGLE_instanced_arrays"),c="drawArraysInstancedANGLE",null===h)return void console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");h[c](s,n,a,o),i.update(a,s,o)}}function Is(e,t,i){let n;function r(t){if("highp"===t){if(e.getShaderPrecisionFormat(35633,36338).precision>0&&e.getShaderPrecisionFormat(35632,36338).precision>0)return"highp";t="mediump"}return"mediump"===t&&e.getShaderPrecisionFormat(35633,36337).precision>0&&e.getShaderPrecisionFormat(35632,36337).precision>0?"mediump":"lowp"}const s="undefined"!=typeof WebGL2RenderingContext&&e instanceof WebGL2RenderingContext||"undefined"!=typeof WebGL2ComputeRenderingContext&&e instanceof WebGL2ComputeRenderingContext;let a=void 0!==i.precision?i.precision:"highp";const o=r(a);o!==a&&(console.warn("THREE.WebGLRenderer:",a,"not supported, using",o,"instead."),a=o);const h=s||t.has("WEBGL_draw_buffers"),c=!0===i.logarithmicDepthBuffer,l=e.getParameter(34930),u=e.getParameter(35660),d=e.getParameter(3379),p=e.getParameter(34076),m=e.getParameter(34921),f=e.getParameter(36347),g=e.getParameter(36348),_=e.getParameter(36349),v=u>0,y=s||t.has("OES_texture_float");return{isWebGL2:s,drawBuffers:h,getMaxAnisotropy:function(){if(void 0!==n)return n;if(!0===t.has("EXT_texture_filter_anisotropic")){const i=t.get("EXT_texture_filter_anisotropic");n=e.getParameter(i.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else n=0;return n},getMaxPrecision:r,precision:a,logarithmicDepthBuffer:c,maxTextures:l,maxVertexTextures:u,maxTextureSize:d,maxCubemapSize:p,maxAttributes:m,maxVertexUniforms:f,maxVaryings:g,maxFragmentUniforms:_,vertexTextures:v,floatFragmentTextures:y,floatVertexTextures:v&&y,maxSamples:s?e.getParameter(36183):0}}function Rs(e){const t=this;let i=null,n=0,r=!1,s=!1;const a=new gs,o=new Fi,h={value:null,needsUpdate:!1};function c(){h.value!==i&&(h.value=i,h.needsUpdate=n>0),t.numPlanes=n,t.numIntersection=0}function l(e,i,n,r){const s=null!==e?e.length:0;let c=null;if(0!==s){if(c=h.value,!0!==r||null===c){const t=n+4*s,r=i.matrixWorldInverse;o.getNormalMatrix(r),(null===c||c.length<t)&&(c=new Float32Array(t));for(let t=0,i=n;t!==s;++t,i+=4)a.copy(e[t]).applyMatrix4(r,o),a.normal.toArray(c,i),c[i+3]=a.constant}h.value=c,h.needsUpdate=!0}return t.numPlanes=s,t.numIntersection=0,c}this.uniform=h,this.numPlanes=0,this.numIntersection=0,this.init=function(e,t,s){const a=0!==e.length||t||0!==n||r;return r=t,i=l(e,s,0),n=e.length,a},this.beginShadows=function(){s=!0,l(null)},this.endShadows=function(){s=!1,c()},this.setState=function(t,a,o){const u=t.clippingPlanes,d=t.clipIntersection,p=t.clipShadows,m=e.get(t);if(!r||null===u||0===u.length||s&&!p)s?l(null):c();else{const e=s?0:n,t=4*e;let r=m.clippingState||null;h.value=r,r=l(u,a,t,o);for(let e=0;e!==t;++e)r[e]=i[e];m.clippingState=r,this.numIntersection=d?this.numPlanes:0,this.numPlanes+=e}}}function Ps(e){let t=new WeakMap;function i(e,t){return 303===t?e.mapping=Gt:304===t&&(e.mapping=Wt),e}function n(e){const i=e.target;i.removeEventListener("dispose",n);const r=t.get(i);void 0!==r&&(t.delete(i),r.dispose())}return{get:function(r){if(r&&r.isTexture&&!1===r.isRenderTargetTexture){const s=r.mapping;if(303===s||304===s){if(t.has(r)){return i(t.get(r).texture,r.mapping)}{const s=r.image;if(s&&s.height>0){const a=e.getRenderTarget(),o=new ds(s.height/2);return o.fromEquirectangularTexture(e,r),t.set(r,o),e.setRenderTarget(a),r.addEventListener("dispose",n),i(o.texture,r.mapping)}return null}}}return r},dispose:function(){t=new WeakMap}}}Ts.physical={uniforms:rs([Ts.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatNormalScale:{value:new zi(1,1)},clearcoatNormalMap:{value:null},sheen:{value:0},sheenColor:{value:new xr(0)},sheenColorMap:{value:null},sheenRoughness:{value:0},sheenRoughnessMap:{value:null},transmission:{value:0},transmissionMap:{value:null},transmissionSamplerSize:{value:new zi},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},attenuationDistance:{value:0},attenuationColor:{value:new xr(0)},specularIntensity:{value:0},specularIntensityMap:{value:null},specularColor:{value:new xr(1,1,1)},specularColorMap:{value:null}}]),vertexShader:Ms.meshphysical_vert,fragmentShader:Ms.meshphysical_frag};class Ls extends os{constructor(e=-1,t=1,i=1,n=-1,r=.1,s=2e3){super(),this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=i,this.bottom=n,this.near=r,this.far=s,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=null===e.view?null:Object.assign({},e.view),this}setViewOffset(e,t,i,n,r,s){null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=n,this.view.width=r,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),i=(this.right+this.left)/2,n=(this.top+this.bottom)/2;let r=i-e,s=i+e,a=n+t,o=n-t;if(null!==this.view&&this.view.enabled){const e=(this.right-this.left)/this.view.fullWidth/this.zoom,t=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=e*this.view.offsetX,s=r+e*this.view.width,a-=t*this.view.offsetY,o=a-t*this.view.height}this.projectionMatrix.makeOrthographic(r,s,a,o,this.near,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,null!==this.view&&(t.object.view=Object.assign({},this.view)),t}}Ls.prototype.isOrthographicCamera=!0;class Ds extends as{constructor(e){super(e),this.type="RawShaderMaterial"}}Ds.prototype.isRawShaderMaterial=!0;const Ns=Math.pow(2,8),$s=[.125,.215,.35,.446,.526,.582],ks=5+$s.length,Os=20,zs={[_i]:0,[vi]:1,[bi]:2,3004:3,3005:4,3006:5,[yi]:6},Fs=new Ls,{_lodPlanes:Bs,_sizeLods:Us,_sigmas:Vs}=Ys(),Hs=new xr;let js=null;const Gs=(1+Math.sqrt(5))/2,Ws=1/Gs,qs=[new Ki(1,1,1),new Ki(-1,1,1),new Ki(1,1,-1),new Ki(-1,1,-1),new Ki(0,Gs,Ws),new Ki(0,Gs,-Ws),new Ki(Ws,0,Gs),new Ki(-Ws,0,Gs),new Ki(Gs,Ws,0),new Ki(-Gs,Ws,0)];class Xs{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._blurMaterial=function(e){const t=new Float32Array(e),i=new Ki(0,1,0);return new Ds({name:"SphericalGaussianBlur",defines:{n:e},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:t},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:i},inputEncoding:{value:zs[3e3]},outputEncoding:{value:zs[3e3]}},vertexShader:ta(),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${ia()}\n\n\t\t\t#define ENVMAP_TYPE_CUBE_UV\n\t\t\t#include <cube_uv_reflection_fragment>\n\n\t\t\tvec3 getSample( float theta, vec3 axis ) {\n\n\t\t\t\tfloat cosTheta = cos( theta );\n\t\t\t\t// Rodrigues' axis-angle rotation\n\t\t\t\tvec3 sampleDirection = vOutputDirection * cosTheta\n\t\t\t\t\t+ cross( axis, vOutputDirection ) * sin( theta )\n\t\t\t\t\t+ axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );\n\n\t\t\t\treturn bilinearCubeUV( envMap, sampleDirection, mipInt );\n\n\t\t\t}\n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );\n\n\t\t\t\tif ( all( equal( axis, vec3( 0.0 ) ) ) ) {\n\n\t\t\t\t\taxis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );\n\n\t\t\t\t}\n\n\t\t\t\taxis = normalize( axis );\n\n\t\t\t\tgl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t\t\t\tgl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );\n\n\t\t\t\tfor ( int i = 1; i < n; i++ ) {\n\n\t\t\t\t\tif ( i >= samples ) {\n\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t}\n\n\t\t\t\t\tfloat theta = dTheta * float( i );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( theta, axis );\n\n\t\t\t\t}\n\n\t\t\t\tgl_FragColor = linearToOutputTexel( gl_FragColor );\n\n\t\t\t}\n\t\t`,blending:0,depthTest:!1,depthWrite:!1})}(Os),this._equirectShader=null,this._cubemapShader=null,this._compileMaterial(this._blurMaterial)}fromScene(e,t=0,i=.1,n=100){js=this._renderer.getRenderTarget();const r=this._allocateTargets();return this._sceneToCubeUV(e,i,n,r),t>0&&this._blur(r,0,0,t),this._applyPMREM(r),this._cleanup(r),r}fromEquirectangular(e){return this._fromTexture(e)}fromCubemap(e){return this._fromTexture(e)}compileCubemapShader(){null===this._cubemapShader&&(this._cubemapShader=ea(),this._compileMaterial(this._cubemapShader))}compileEquirectangularShader(){null===this._equirectShader&&(this._equirectShader=Qs(),this._compileMaterial(this._equirectShader))}dispose(){this._blurMaterial.dispose(),null!==this._cubemapShader&&this._cubemapShader.dispose(),null!==this._equirectShader&&this._equirectShader.dispose();for(let e=0;e<Bs.length;e++)Bs[e].dispose()}_cleanup(e){this._pingPongRenderTarget.dispose(),this._renderer.setRenderTarget(js),e.scissorTest=!1,Ks(e,0,0,e.width,e.height)}_fromTexture(e){js=this._renderer.getRenderTarget();const t=this._allocateTargets(e);return this._textureToCubeUV(e,t),this._applyPMREM(t),this._cleanup(t),t}_allocateTargets(e){const t={magFilter:Jt,minFilter:Jt,generateMipmaps:!1,type:ei,format:1023,encoding:Zs(e)?e.encoding:bi,depthBuffer:!1},i=Js(t);return i.depthBuffer=!e,this._pingPongRenderTarget=Js(t),i}_compileMaterial(e){const t=new es(Bs[0],e);this._renderer.compile(t,Fs)}_sceneToCubeUV(e,t,i,n){const r=new hs(90,1,t,i),s=[1,-1,1,1,1,1],a=[1,1,1,-1,-1,-1],o=this._renderer,h=o.autoClear,c=o.outputEncoding,l=o.toneMapping;o.getClearColor(Hs),o.toneMapping=0,o.outputEncoding=_i,o.autoClear=!1;const u=new wr({name:"PMREM.Background",side:1,depthWrite:!1,depthTest:!1}),d=new es(new is,u);let p=!1;const m=e.background;m?m.isColor&&(u.color.copy(m),e.background=null,p=!0):(u.color.copy(Hs),p=!0);for(let t=0;t<6;t++){const i=t%3;0==i?(r.up.set(0,s[t],0),r.lookAt(a[t],0,0)):1==i?(r.up.set(0,0,s[t]),r.lookAt(0,a[t],0)):(r.up.set(0,s[t],0),r.lookAt(0,0,a[t])),Ks(n,i*Ns,t>2?Ns:0,Ns,Ns),o.setRenderTarget(n),p&&o.render(d,r),o.render(e,r)}d.geometry.dispose(),d.material.dispose(),o.toneMapping=l,o.outputEncoding=c,o.autoClear=h,e.background=m}_setEncoding(e,t){!0===this._renderer.capabilities.isWebGL2&&t.format===oi&&t.type===ei&&t.encoding===vi?e.value=zs[3e3]:e.value=zs[t.encoding]}_textureToCubeUV(e,t){const i=this._renderer,n=e.mapping===Gt||e.mapping===Wt;n?null==this._cubemapShader&&(this._cubemapShader=ea()):null==this._equirectShader&&(this._equirectShader=Qs());const r=n?this._cubemapShader:this._equirectShader,s=new es(Bs[0],r),a=r.uniforms;a.envMap.value=e,n||a.texelSize.value.set(1/e.image.width,1/e.image.height),this._setEncoding(a.inputEncoding,e),this._setEncoding(a.outputEncoding,t.texture),Ks(t,0,0,3*Ns,2*Ns),i.setRenderTarget(t),i.render(s,Fs)}_applyPMREM(e){const t=this._renderer,i=t.autoClear;t.autoClear=!1;for(let t=1;t<ks;t++){const i=Math.sqrt(Vs[t]*Vs[t]-Vs[t-1]*Vs[t-1]),n=qs[(t-1)%qs.length];this._blur(e,t-1,t,i,n)}t.autoClear=i}_blur(e,t,i,n,r){const s=this._pingPongRenderTarget;this._halfBlur(e,s,t,i,n,"latitudinal",r),this._halfBlur(s,e,i,i,n,"longitudinal",r)}_halfBlur(e,t,i,n,r,s,a){const o=this._renderer,h=this._blurMaterial;"latitudinal"!==s&&"longitudinal"!==s&&console.error("blur direction must be either latitudinal or longitudinal!");const c=new es(Bs[n],h),l=h.uniforms,u=Us[i]-1,d=isFinite(r)?Math.PI/(2*u):2*Math.PI/39,p=r/d,m=isFinite(r)?1+Math.floor(3*p):Os;m>Os&&console.warn(`sigmaRadians, ${r}, is too large and will clip, as it requested ${m} samples when the maximum is set to 20`);const f=[];let g=0;for(let e=0;e<Os;++e){const t=e/p,i=Math.exp(-t*t/2);f.push(i),0==e?g+=i:e<m&&(g+=2*i)}for(let e=0;e<f.length;e++)f[e]=f[e]/g;l.envMap.value=e.texture,l.samples.value=m,l.weights.value=f,l.latitudinal.value="latitudinal"===s,a&&(l.poleAxis.value=a),l.dTheta.value=d,l.mipInt.value=8-i,this._setEncoding(l.inputEncoding,e.texture),this._setEncoding(l.outputEncoding,e.texture);const _=Us[n];Ks(t,3*Math.max(0,Ns-2*_),(0===n?0:2*Ns)+2*_*(n>4?n-8+4:0),3*_,2*_),o.setRenderTarget(t),o.render(c,Fs)}}function Zs(e){return void 0!==e&&e.type===ei&&(e.encoding===_i||e.encoding===vi||e.encoding===yi)}function Ys(){const e=[],t=[],i=[];let n=8;for(let r=0;r<ks;r++){const s=Math.pow(2,n);t.push(s);let a=1/s;r>4?a=$s[r-8+4-1]:0==r&&(a=0),i.push(a);const o=1/(s-1),h=-o/2,c=1+o/2,l=[h,h,c,h,c,c,h,h,c,c,h,c],u=6,d=6,p=3,m=2,f=1,g=new Float32Array(p*d*u),_=new Float32Array(m*d*u),v=new Float32Array(f*d*u);for(let e=0;e<u;e++){const t=e%3*2/3-1,i=e>2?0:-1,n=[t,i,0,t+2/3,i,0,t+2/3,i+1,0,t,i,0,t+2/3,i+1,0,t,i+1,0];g.set(n,p*d*e),_.set(l,m*d*e);const r=[e,e,e,e,e,e];v.set(r,f*d*e)}const y=new kr;y.setAttribute("position",new Tr(g,p)),y.setAttribute("uv",new Tr(_,m)),y.setAttribute("faceIndex",new Tr(v,f)),e.push(y),n>4&&n--}return{_lodPlanes:e,_sizeLods:t,_sigmas:i}}function Js(e){const t=new Zi(3*Ns,3*Ns,e);return t.texture.mapping=qt,t.texture.name="PMREM.cubeUv",t.scissorTest=!0,t}function Ks(e,t,i,n,r){e.viewport.set(t,i,n,r),e.scissor.set(t,i,n,r)}function Qs(){const e=new zi(1,1);return new Ds({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null},texelSize:{value:e},inputEncoding:{value:zs[3e3]},outputEncoding:{value:zs[3e3]}},vertexShader:ta(),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${ia()}\n\n\t\t\t#include <common>\n\n\t\t\tvoid main() {\n\n\t\t\t\tgl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\n\t\t\t\tvec3 outputDirection = normalize( vOutputDirection );\n\t\t\t\tvec2 uv = equirectUv( outputDirection );\n\n\t\t\t\tvec2 f = fract( uv / texelSize - 0.5 );\n\t\t\t\tuv -= f * texelSize;\n\t\t\t\tvec3 tl = envMapTexelToLinear( texture2D ( envMap, uv ) ).rgb;\n\t\t\t\tuv.x += texelSize.x;\n\t\t\t\tvec3 tr = envMapTexelToLinear( texture2D ( envMap, uv ) ).rgb;\n\t\t\t\tuv.y += texelSize.y;\n\t\t\t\tvec3 br = envMapTexelToLinear( texture2D ( envMap, uv ) ).rgb;\n\t\t\t\tuv.x -= texelSize.x;\n\t\t\t\tvec3 bl = envMapTexelToLinear( texture2D ( envMap, uv ) ).rgb;\n\n\t\t\t\tvec3 tm = mix( tl, tr, f.x );\n\t\t\t\tvec3 bm = mix( bl, br, f.x );\n\t\t\t\tgl_FragColor.rgb = mix( tm, bm, f.y );\n\n\t\t\t\tgl_FragColor = linearToOutputTexel( gl_FragColor );\n\n\t\t\t}\n\t\t`,blending:0,depthTest:!1,depthWrite:!1})}function ea(){return new Ds({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},inputEncoding:{value:zs[3e3]},outputEncoding:{value:zs[3e3]}},vertexShader:ta(),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${ia()}\n\n\t\t\tvoid main() {\n\n\t\t\t\tgl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t\t\t\tgl_FragColor.rgb = envMapTexelToLinear( textureCube( envMap, vec3( - vOutputDirection.x, vOutputDirection.yz ) ) ).rgb;\n\t\t\t\tgl_FragColor = linearToOutputTexel( gl_FragColor );\n\n\t\t\t}\n\t\t`,blending:0,depthTest:!1,depthWrite:!1})}function ta(){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 ia(){return"\n\n\t\tuniform int inputEncoding;\n\t\tuniform int outputEncoding;\n\n\t\t#include <encodings_pars_fragment>\n\n\t\tvec4 inputTexelToLinear( vec4 value ) {\n\n\t\t\tif ( inputEncoding == 0 ) {\n\n\t\t\t\treturn value;\n\n\t\t\t} else if ( inputEncoding == 1 ) {\n\n\t\t\t\treturn sRGBToLinear( value );\n\n\t\t\t} else if ( inputEncoding == 2 ) {\n\n\t\t\t\treturn RGBEToLinear( value );\n\n\t\t\t} else if ( inputEncoding == 3 ) {\n\n\t\t\t\treturn RGBMToLinear( value, 7.0 );\n\n\t\t\t} else if ( inputEncoding == 4 ) {\n\n\t\t\t\treturn RGBMToLinear( value, 16.0 );\n\n\t\t\t} else if ( inputEncoding == 5 ) {\n\n\t\t\t\treturn RGBDToLinear( value, 256.0 );\n\n\t\t\t} else {\n\n\t\t\t\treturn GammaToLinear( value, 2.2 );\n\n\t\t\t}\n\n\t\t}\n\n\t\tvec4 linearToOutputTexel( vec4 value ) {\n\n\t\t\tif ( outputEncoding == 0 ) {\n\n\t\t\t\treturn value;\n\n\t\t\t} else if ( outputEncoding == 1 ) {\n\n\t\t\t\treturn LinearTosRGB( value );\n\n\t\t\t} else if ( outputEncoding == 2 ) {\n\n\t\t\t\treturn LinearToRGBE( value );\n\n\t\t\t} else if ( outputEncoding == 3 ) {\n\n\t\t\t\treturn LinearToRGBM( value, 7.0 );\n\n\t\t\t} else if ( outputEncoding == 4 ) {\n\n\t\t\t\treturn LinearToRGBM( value, 16.0 );\n\n\t\t\t} else if ( outputEncoding == 5 ) {\n\n\t\t\t\treturn LinearToRGBD( value, 256.0 );\n\n\t\t\t} else {\n\n\t\t\t\treturn LinearToGamma( value, 2.2 );\n\n\t\t\t}\n\n\t\t}\n\n\t\tvec4 envMapTexelToLinear( vec4 color ) {\n\n\t\t\treturn inputTexelToLinear( color );\n\n\t\t}\n\t"}function na(e){let t=new WeakMap,i=null;function n(e){const i=e.target;i.removeEventListener("dispose",n);const r=t.get(i);void 0!==r&&(t.delete(i),r.dispose())}return{get:function(r){if(r&&r.isTexture&&!1===r.isRenderTargetTexture){const s=r.mapping,a=303===s||304===s,o=s===Gt||s===Wt;if(a||o){if(t.has(r))return t.get(r).texture;{const s=r.image;if(a&&s&&s.height>0||o&&s&&function(e){let t=0;const i=6;for(let n=0;n<i;n++)void 0!==e[n]&&t++;return t===i}(s)){const s=e.getRenderTarget();null===i&&(i=new Xs(e));const o=a?i.fromEquirectangular(r):i.fromCubemap(r);return t.set(r,o),e.setRenderTarget(s),r.addEventListener("dispose",n),o.texture}return null}}}return r},dispose:function(){t=new WeakMap,null!==i&&(i.dispose(),i=null)}}}function ra(e){const t={};function i(i){if(void 0!==t[i])return t[i];let n;switch(i){case"WEBGL_depth_texture":n=e.getExtension("WEBGL_depth_texture")||e.getExtension("MOZ_WEBGL_depth_texture")||e.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":n=e.getExtension("EXT_texture_filter_anisotropic")||e.getExtension("MOZ_EXT_texture_filter_anisotropic")||e.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":n=e.getExtension("WEBGL_compressed_texture_s3tc")||e.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":n=e.getExtension("WEBGL_compressed_texture_pvrtc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:n=e.getExtension(i)}return t[i]=n,n}return{has:function(e){return null!==i(e)},init:function(e){e.isWebGL2?i("EXT_color_buffer_float"):(i("WEBGL_depth_texture"),i("OES_texture_float"),i("OES_texture_half_float"),i("OES_texture_half_float_linear"),i("OES_standard_derivatives"),i("OES_element_index_uint"),i("OES_vertex_array_object"),i("ANGLE_instanced_arrays")),i("OES_texture_float_linear"),i("EXT_color_buffer_half_float")},get:function(e){const t=i(e);return null===t&&console.warn("THREE.WebGLRenderer: "+e+" extension not supported."),t}}}function sa(e,t,i,n){const r={},s=new WeakMap;function a(e){const o=e.target;null!==o.index&&t.remove(o.index);for(const e in o.attributes)t.remove(o.attributes[e]);o.removeEventListener("dispose",a),delete r[o.id];const h=s.get(o);h&&(t.remove(h),s.delete(o)),n.releaseStatesOfGeometry(o),!0===o.isInstancedBufferGeometry&&delete o._maxInstanceCount,i.memory.geometries--}function o(e){const i=[],n=e.index,r=e.attributes.position;let a=0;if(null!==n){const e=n.array;a=n.version;for(let t=0,n=e.length;t<n;t+=3){const n=e[t+0],r=e[t+1],s=e[t+2];i.push(n,r,r,s,s,n)}}else{const e=r.array;a=r.version;for(let t=0,n=e.length/3-1;t<n;t+=3){const e=t+0,n=t+1,r=t+2;i.push(e,n,n,r,r,e)}}const o=new(Bi(i)>65535?Er:Cr)(i,1);o.version=a;const h=s.get(e);h&&t.remove(h),s.set(e,o)}return{get:function(e,t){return!0===r[t.id]||(t.addEventListener("dispose",a),r[t.id]=!0,i.memory.geometries++),t},update:function(e){const i=e.attributes;for(const e in i)t.update(i[e],34962);const n=e.morphAttributes;for(const e in n){const i=n[e];for(let e=0,n=i.length;e<n;e++)t.update(i[e],34962)}},getWireframeAttribute:function(e){const t=s.get(e);if(t){const i=e.index;null!==i&&t.version<i.version&&o(e)}else o(e);return s.get(e)}}}function aa(e,t,i,n){const r=n.isWebGL2;let s,a,o;this.setMode=function(e){s=e},this.setIndex=function(e){a=e.type,o=e.bytesPerElement},this.render=function(t,n){e.drawElements(s,n,a,t*o),i.update(n,s,1)},this.renderInstances=function(n,h,c){if(0===c)return;let l,u;if(r)l=e,u="drawElementsInstanced";else if(l=t.get("ANGLE_instanced_arrays"),u="drawElementsInstancedANGLE",null===l)return void console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");l[u](s,h,a,n*o,c),i.update(h,s,c)}}function oa(e){const t={frame:0,calls:0,triangles:0,points:0,lines:0};return{memory:{geometries:0,textures:0},render:t,programs:null,autoReset:!0,reset:function(){t.frame++,t.calls=0,t.triangles=0,t.points=0,t.lines=0},update:function(e,i,n){switch(t.calls++,i){case 4:t.triangles+=n*(e/3);break;case 1:t.lines+=n*(e/2);break;case 3:t.lines+=n*(e-1);break;case 2:t.lines+=n*e;break;case 0:t.points+=n*e;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",i)}}}}class ha extends Wi{constructor(e=null,t=1,i=1,n=1){super(null),this.image={data:e,width:t,height:i,depth:n},this.magFilter=Jt,this.minFilter=Jt,this.wrapR=Zt,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.needsUpdate=!0}}function ca(e,t){return e[0]-t[0]}function la(e,t){return Math.abs(t[1])-Math.abs(e[1])}function ua(e,t){let i=1;const n=t.isInterleavedBufferAttribute?t.data.array:t.array;n instanceof Int8Array?i=127:n instanceof Int16Array?i=32767:n instanceof Int32Array?i=2147483647:console.error("THREE.WebGLMorphtargets: Unsupported morph attribute data type: ",n),e.divideScalar(i)}function da(e,t,i){const n={},r=new Float32Array(8),s=new WeakMap,a=new Ki,o=[];for(let e=0;e<8;e++)o[e]=[e,0];return{update:function(h,c,l,u){const d=h.morphTargetInfluences;if(!0===t.isWebGL2){const n=c.morphAttributes.position.length;let r=s.get(c);if(void 0===r||r.count!==n){void 0!==r&&r.texture.dispose();const e=void 0!==c.morphAttributes.normal,i=c.morphAttributes.position,o=c.morphAttributes.normal||[],h=!0===e?2:1;let l=c.attributes.position.count*h,u=1;l>t.maxTextureSize&&(u=Math.ceil(l/t.maxTextureSize),l=t.maxTextureSize);const d=new Float32Array(l*u*4*n),p=new ha(d,l,u,n);p.format=oi,p.type=ni;const m=4*h;for(let t=0;t<n;t++){const n=i[t],r=o[t],s=l*u*4*t;for(let t=0;t<n.count;t++){a.fromBufferAttribute(n,t),!0===n.normalized&&ua(a,n);const i=t*m;d[s+i+0]=a.x,d[s+i+1]=a.y,d[s+i+2]=a.z,d[s+i+3]=0,!0===e&&(a.fromBufferAttribute(r,t),!0===r.normalized&&ua(a,r),d[s+i+4]=a.x,d[s+i+5]=a.y,d[s+i+6]=a.z,d[s+i+7]=0)}}r={count:n,texture:p,size:new zi(l,u)},s.set(c,r)}let o=0;for(let e=0;e<d.length;e++)o+=d[e];const h=c.morphTargetsRelative?1:1-o;u.getUniforms().setValue(e,"morphTargetBaseInfluence",h),u.getUniforms().setValue(e,"morphTargetInfluences",d),u.getUniforms().setValue(e,"morphTargetsTexture",r.texture,i),u.getUniforms().setValue(e,"morphTargetsTextureSize",r.size)}else{const t=void 0===d?0:d.length;let i=n[c.id];if(void 0===i||i.length!==t){i=[];for(let e=0;e<t;e++)i[e]=[e,0];n[c.id]=i}for(let e=0;e<t;e++){const t=i[e];t[0]=e,t[1]=d[e]}i.sort(la);for(let e=0;e<8;e++)e<t&&i[e][1]?(o[e][0]=i[e][0],o[e][1]=i[e][1]):(o[e][0]=Number.MAX_SAFE_INTEGER,o[e][1]=0);o.sort(ca);const s=c.morphAttributes.position,a=c.morphAttributes.normal;let h=0;for(let e=0;e<8;e++){const t=o[e],i=t[0],n=t[1];i!==Number.MAX_SAFE_INTEGER&&n?(s&&c.getAttribute("morphTarget"+e)!==s[i]&&c.setAttribute("morphTarget"+e,s[i]),a&&c.getAttribute("morphNormal"+e)!==a[i]&&c.setAttribute("morphNormal"+e,a[i]),r[e]=n,h+=n):(s&&!0===c.hasAttribute("morphTarget"+e)&&c.deleteAttribute("morphTarget"+e),a&&!0===c.hasAttribute("morphNormal"+e)&&c.deleteAttribute("morphNormal"+e),r[e]=0)}const l=c.morphTargetsRelative?1:1-h;u.getUniforms().setValue(e,"morphTargetBaseInfluence",l),u.getUniforms().setValue(e,"morphTargetInfluences",r)}}}}function pa(e,t,i,n){let r=new WeakMap;function s(e){const t=e.target;t.removeEventListener("dispose",s),i.remove(t.instanceMatrix),null!==t.instanceColor&&i.remove(t.instanceColor)}return{update:function(e){const a=n.render.frame,o=e.geometry,h=t.get(e,o);return r.get(h)!==a&&(t.update(h),r.set(h,a)),e.isInstancedMesh&&(!1===e.hasEventListener("dispose",s)&&e.addEventListener("dispose",s),i.update(e.instanceMatrix,34962),null!==e.instanceColor&&i.update(e.instanceColor,34962)),h},dispose:function(){r=new WeakMap}}}ha.prototype.isDataTexture2DArray=!0;class ma extends Wi{constructor(e=null,t=1,i=1,n=1){super(null),this.image={data:e,width:t,height:i,depth:n},this.magFilter=Jt,this.minFilter=Jt,this.wrapR=Zt,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.needsUpdate=!0}}ma.prototype.isDataTexture3D=!0;const fa=new Wi,ga=new ha,_a=new ma,va=new us,ya=[],ba=[],xa=new Float32Array(16),wa=new Float32Array(9),Ma=new Float32Array(4);function Sa(e,t,i){const n=e[0];if(n<=0||n>0)return e;const r=t*i;let s=ya[r];if(void 0===s&&(s=new Float32Array(r),ya[r]=s),0!==t){n.toArray(s,0);for(let n=1,r=0;n!==t;++n)r+=i,e[n].toArray(s,r)}return s}function Ta(e,t){if(e.length!==t.length)return!1;for(let i=0,n=e.length;i<n;i++)if(e[i]!==t[i])return!1;return!0}function Ca(e,t){for(let i=0,n=t.length;i<n;i++)e[i]=t[i]}function Ea(e,t){let i=ba[t];void 0===i&&(i=new Int32Array(t),ba[t]=i);for(let n=0;n!==t;++n)i[n]=e.allocateTextureUnit();return i}function Aa(e,t){const i=this.cache;i[0]!==t&&(e.uniform1f(this.addr,t),i[0]=t)}function Ia(e,t){const i=this.cache;if(void 0!==t.x)i[0]===t.x&&i[1]===t.y||(e.uniform2f(this.addr,t.x,t.y),i[0]=t.x,i[1]=t.y);else{if(Ta(i,t))return;e.uniform2fv(this.addr,t),Ca(i,t)}}function Ra(e,t){const i=this.cache;if(void 0!==t.x)i[0]===t.x&&i[1]===t.y&&i[2]===t.z||(e.uniform3f(this.addr,t.x,t.y,t.z),i[0]=t.x,i[1]=t.y,i[2]=t.z);else if(void 0!==t.r)i[0]===t.r&&i[1]===t.g&&i[2]===t.b||(e.uniform3f(this.addr,t.r,t.g,t.b),i[0]=t.r,i[1]=t.g,i[2]=t.b);else{if(Ta(i,t))return;e.uniform3fv(this.addr,t),Ca(i,t)}}function Pa(e,t){const i=this.cache;if(void 0!==t.x)i[0]===t.x&&i[1]===t.y&&i[2]===t.z&&i[3]===t.w||(e.uniform4f(this.addr,t.x,t.y,t.z,t.w),i[0]=t.x,i[1]=t.y,i[2]=t.z,i[3]=t.w);else{if(Ta(i,t))return;e.uniform4fv(this.addr,t),Ca(i,t)}}function La(e,t){const i=this.cache,n=t.elements;if(void 0===n){if(Ta(i,t))return;e.uniformMatrix2fv(this.addr,!1,t),Ca(i,t)}else{if(Ta(i,n))return;Ma.set(n),e.uniformMatrix2fv(this.addr,!1,Ma),Ca(i,n)}}function Da(e,t){const i=this.cache,n=t.elements;if(void 0===n){if(Ta(i,t))return;e.uniformMatrix3fv(this.addr,!1,t),Ca(i,t)}else{if(Ta(i,n))return;wa.set(n),e.uniformMatrix3fv(this.addr,!1,wa),Ca(i,n)}}function Na(e,t){const i=this.cache,n=t.elements;if(void 0===n){if(Ta(i,t))return;e.uniformMatrix4fv(this.addr,!1,t),Ca(i,t)}else{if(Ta(i,n))return;xa.set(n),e.uniformMatrix4fv(this.addr,!1,xa),Ca(i,n)}}function $a(e,t){const i=this.cache;i[0]!==t&&(e.uniform1i(this.addr,t),i[0]=t)}function ka(e,t){const i=this.cache;Ta(i,t)||(e.uniform2iv(this.addr,t),Ca(i,t))}function Oa(e,t){const i=this.cache;Ta(i,t)||(e.uniform3iv(this.addr,t),Ca(i,t))}function za(e,t){const i=this.cache;Ta(i,t)||(e.uniform4iv(this.addr,t),Ca(i,t))}function Fa(e,t){const i=this.cache;i[0]!==t&&(e.uniform1ui(this.addr,t),i[0]=t)}function Ba(e,t){const i=this.cache;Ta(i,t)||(e.uniform2uiv(this.addr,t),Ca(i,t))}function Ua(e,t){const i=this.cache;Ta(i,t)||(e.uniform3uiv(this.addr,t),Ca(i,t))}function Va(e,t){const i=this.cache;Ta(i,t)||(e.uniform4uiv(this.addr,t),Ca(i,t))}function Ha(e,t,i){const n=this.cache,r=i.allocateTextureUnit();n[0]!==r&&(e.uniform1i(this.addr,r),n[0]=r),i.safeSetTexture2D(t||fa,r)}function ja(e,t,i){const n=this.cache,r=i.allocateTextureUnit();n[0]!==r&&(e.uniform1i(this.addr,r),n[0]=r),i.setTexture3D(t||_a,r)}function Ga(e,t,i){const n=this.cache,r=i.allocateTextureUnit();n[0]!==r&&(e.uniform1i(this.addr,r),n[0]=r),i.safeSetTextureCube(t||va,r)}function Wa(e,t,i){const n=this.cache,r=i.allocateTextureUnit();n[0]!==r&&(e.uniform1i(this.addr,r),n[0]=r),i.setTexture2DArray(t||ga,r)}function qa(e,t){e.uniform1fv(this.addr,t)}function Xa(e,t){const i=Sa(t,this.size,2);e.uniform2fv(this.addr,i)}function Za(e,t){const i=Sa(t,this.size,3);e.uniform3fv(this.addr,i)}function Ya(e,t){const i=Sa(t,this.size,4);e.uniform4fv(this.addr,i)}function Ja(e,t){const i=Sa(t,this.size,4);e.uniformMatrix2fv(this.addr,!1,i)}function Ka(e,t){const i=Sa(t,this.size,9);e.uniformMatrix3fv(this.addr,!1,i)}function Qa(e,t){const i=Sa(t,this.size,16);e.uniformMatrix4fv(this.addr,!1,i)}function eo(e,t){e.uniform1iv(this.addr,t)}function to(e,t){e.uniform2iv(this.addr,t)}function io(e,t){e.uniform3iv(this.addr,t)}function no(e,t){e.uniform4iv(this.addr,t)}function ro(e,t){e.uniform1uiv(this.addr,t)}function so(e,t){e.uniform2uiv(this.addr,t)}function ao(e,t){e.uniform3uiv(this.addr,t)}function oo(e,t){e.uniform4uiv(this.addr,t)}function ho(e,t,i){const n=t.length,r=Ea(i,n);e.uniform1iv(this.addr,r);for(let e=0;e!==n;++e)i.safeSetTexture2D(t[e]||fa,r[e])}function co(e,t,i){const n=t.length,r=Ea(i,n);e.uniform1iv(this.addr,r);for(let e=0;e!==n;++e)i.safeSetTextureCube(t[e]||va,r[e])}function lo(e,t,i){this.id=e,this.addr=i,this.cache=[],this.setValue=function(e){switch(e){case 5126:return Aa;case 35664:return Ia;case 35665:return Ra;case 35666:return Pa;case 35674:return La;case 35675:return Da;case 35676:return Na;case 5124:case 35670:return $a;case 35667:case 35671:return ka;case 35668:case 35672:return Oa;case 35669:case 35673:return za;case 5125:return Fa;case 36294:return Ba;case 36295:return Ua;case 36296:return Va;case 35678:case 36198:case 36298:case 36306:case 35682:return Ha;case 35679:case 36299:case 36307:return ja;case 35680:case 36300:case 36308:case 36293:return Ga;case 36289:case 36303:case 36311:case 36292:return Wa}}(t.type)}function uo(e,t,i){this.id=e,this.addr=i,this.cache=[],this.size=t.size,this.setValue=function(e){switch(e){case 5126:return qa;case 35664:return Xa;case 35665:return Za;case 35666:return Ya;case 35674:return Ja;case 35675:return Ka;case 35676:return Qa;case 5124:case 35670:return eo;case 35667:case 35671:return to;case 35668:case 35672:return io;case 35669:case 35673:return no;case 5125:return ro;case 36294:return so;case 36295:return ao;case 36296:return oo;case 35678:case 36198:case 36298:case 36306:case 35682:return ho;case 35680:case 36300:case 36308:case 36293:return co}}(t.type)}function po(e){this.id=e,this.seq=[],this.map={}}uo.prototype.updateCache=function(e){const t=this.cache;e instanceof Float32Array&&t.length!==e.length&&(this.cache=new Float32Array(e.length)),Ca(t,e)},po.prototype.setValue=function(e,t,i){const n=this.seq;for(let r=0,s=n.length;r!==s;++r){const s=n[r];s.setValue(e,t[s.id],i)}};const mo=/(\w+)(\])?(\[|\.)?/g;function fo(e,t){e.seq.push(t),e.map[t.id]=t}function go(e,t,i){const n=e.name,r=n.length;for(mo.lastIndex=0;;){const s=mo.exec(n),a=mo.lastIndex;let o=s[1];const h="]"===s[2],c=s[3];if(h&&(o|=0),void 0===c||"["===c&&a+2===r){fo(i,void 0===c?new lo(o,e,t):new uo(o,e,t));break}{let e=i.map[o];void 0===e&&(e=new po(o),fo(i,e)),i=e}}}function _o(e,t){this.seq=[],this.map={};const i=e.getProgramParameter(t,35718);for(let n=0;n<i;++n){const i=e.getActiveUniform(t,n);go(i,e.getUniformLocation(t,i.name),this)}}function vo(e,t,i){const n=e.createShader(t);return e.shaderSource(n,i),e.compileShader(n),n}_o.prototype.setValue=function(e,t,i,n){const r=this.map[t];void 0!==r&&r.setValue(e,i,n)},_o.prototype.setOptional=function(e,t,i){const n=t[i];void 0!==n&&this.setValue(e,i,n)},_o.upload=function(e,t,i,n){for(let r=0,s=t.length;r!==s;++r){const s=t[r],a=i[s.id];!1!==a.needsUpdate&&s.setValue(e,a.value,n)}},_o.seqWithValue=function(e,t){const i=[];for(let n=0,r=e.length;n!==r;++n){const r=e[n];r.id in t&&i.push(r)}return i};let yo=0;function bo(e){switch(e){case _i:return["Linear","( value )"];case vi:return["sRGB","( value )"];case bi:return["RGBE","( value )"];case 3004:return["RGBM","( value, 7.0 )"];case 3005:return["RGBM","( value, 16.0 )"];case 3006:return["RGBD","( value, 256.0 )"];case yi:return["Gamma","( value, float( GAMMA_FACTOR ) )"];case 3003:return["LogLuv","( value )"];default:return console.warn("THREE.WebGLProgram: Unsupported encoding:",e),["Linear","( value )"]}}function xo(e,t,i){const n=e.getShaderParameter(t,35713),r=e.getShaderInfoLog(t).trim();return n&&""===r?"":i.toUpperCase()+"\n\n"+r+"\n\n"+function(e){const t=e.split("\n");for(let e=0;e<t.length;e++)t[e]=e+1+": "+t[e];return t.join("\n")}(e.getShaderSource(t))}function wo(e,t){const i=bo(t);return"vec4 "+e+"( vec4 value ) { return "+i[0]+"ToLinear"+i[1]+"; }"}function Mo(e,t){const i=bo(t);return"vec4 "+e+"( vec4 value ) { return LinearTo"+i[0]+i[1]+"; }"}function So(e,t){let i;switch(t){case 1:i="Linear";break;case 2:i="Reinhard";break;case 3:i="OptimizedCineon";break;case 4:i="ACESFilmic";break;case 5:i="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",t),i="Linear"}return"vec3 "+e+"( vec3 color ) { return "+i+"ToneMapping( color ); }"}function To(e){return""!==e}function Co(e,t){return e.replace(/NUM_DIR_LIGHTS/g,t.numDirLights).replace(/NUM_SPOT_LIGHTS/g,t.numSpotLights).replace(/NUM_RECT_AREA_LIGHTS/g,t.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,t.numPointLights).replace(/NUM_HEMI_LIGHTS/g,t.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,t.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS/g,t.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,t.numPointLightShadows)}function Eo(e,t){return e.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}const Ao=/^[ \t]*#include +<([\w\d./]+)>/gm;function Io(e){return e.replace(Ao,Ro)}function Ro(e,t){const i=Ms[t];if(void 0===i)throw new Error("Can not resolve #include <"+t+">");return Io(i)}const Po=/#pragma unroll_loop[\s]+?for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}/g,Lo=/#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 Do(e){return e.replace(Lo,$o).replace(Po,No)}function No(e,t,i,n){return console.warn("WebGLProgram: #pragma unroll_loop shader syntax is deprecated. Please use #pragma unroll_loop_start syntax instead."),$o(e,t,i,n)}function $o(e,t,i,n){let r="";for(let e=parseInt(t);e<parseInt(i);e++)r+=n.replace(/\[\s*i\s*\]/g,"[ "+e+" ]").replace(/UNROLLED_LOOP_INDEX/g,e);return r}function ko(e){let t="precision "+e.precision+" float;\nprecision "+e.precision+" int;";return"highp"===e.precision?t+="\n#define HIGH_PRECISION":"mediump"===e.precision?t+="\n#define MEDIUM_PRECISION":"lowp"===e.precision&&(t+="\n#define LOW_PRECISION"),t}function Oo(e,t,i,n){const r=e.getContext(),s=i.defines;let a=i.vertexShader,o=i.fragmentShader;const h=function(e){let t="SHADOWMAP_TYPE_BASIC";return 1===e.shadowMapType?t="SHADOWMAP_TYPE_PCF":2===e.shadowMapType?t="SHADOWMAP_TYPE_PCF_SOFT":3===e.shadowMapType&&(t="SHADOWMAP_TYPE_VSM"),t}(i),c=function(e){let t="ENVMAP_TYPE_CUBE";if(e.envMap)switch(e.envMapMode){case Gt:case Wt:t="ENVMAP_TYPE_CUBE";break;case qt:case 307:t="ENVMAP_TYPE_CUBE_UV"}return t}(i),l=function(e){let t="ENVMAP_MODE_REFLECTION";if(e.envMap)switch(e.envMapMode){case Wt:case 307:t="ENVMAP_MODE_REFRACTION"}return t}(i),u=function(e){let t="ENVMAP_BLENDING_NONE";if(e.envMap)switch(e.combine){case 0:t="ENVMAP_BLENDING_MULTIPLY";break;case 1:t="ENVMAP_BLENDING_MIX";break;case 2:t="ENVMAP_BLENDING_ADD"}return t}(i),d=e.gammaFactor>0?e.gammaFactor:1,p=i.isWebGL2?"":function(e){return[e.extensionDerivatives||e.envMapCubeUV||e.bumpMap||e.tangentSpaceNormalMap||e.clearcoatNormalMap||e.flatShading||"physical"===e.shaderID?"#extension GL_OES_standard_derivatives : enable":"",(e.extensionFragDepth||e.logarithmicDepthBuffer)&&e.rendererExtensionFragDepth?"#extension GL_EXT_frag_depth : enable":"",e.extensionDrawBuffers&&e.rendererExtensionDrawBuffers?"#extension GL_EXT_draw_buffers : require":"",(e.extensionShaderTextureLOD||e.envMap||e.transmission)&&e.rendererExtensionShaderTextureLod?"#extension GL_EXT_shader_texture_lod : enable":""].filter(To).join("\n")}(i),m=function(e){const t=[];for(const i in e){const n=e[i];!1!==n&&t.push("#define "+i+" "+n)}return t.join("\n")}(s),f=r.createProgram();let g,_,v=i.glslVersion?"#version "+i.glslVersion+"\n":"";i.isRawShaderMaterial?(g=[m].filter(To).join("\n"),g.length>0&&(g+="\n"),_=[p,m].filter(To).join("\n"),_.length>0&&(_+="\n")):(g=[ko(i),"#define SHADER_NAME "+i.shaderName,m,i.instancing?"#define USE_INSTANCING":"",i.instancingColor?"#define USE_INSTANCING_COLOR":"",i.supportsVertexTextures?"#define VERTEX_TEXTURES":"","#define GAMMA_FACTOR "+d,"#define MAX_BONES "+i.maxBones,i.useFog&&i.fog?"#define USE_FOG":"",i.useFog&&i.fogExp2?"#define FOG_EXP2":"",i.map?"#define USE_MAP":"",i.envMap?"#define USE_ENVMAP":"",i.envMap?"#define "+l:"",i.lightMap?"#define USE_LIGHTMAP":"",i.aoMap?"#define USE_AOMAP":"",i.emissiveMap?"#define USE_EMISSIVEMAP":"",i.bumpMap?"#define USE_BUMPMAP":"",i.normalMap?"#define USE_NORMALMAP":"",i.normalMap&&i.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",i.normalMap&&i.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",i.clearcoatMap?"#define USE_CLEARCOATMAP":"",i.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",i.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",i.displacementMap&&i.supportsVertexTextures?"#define USE_DISPLACEMENTMAP":"",i.specularMap?"#define USE_SPECULARMAP":"",i.specularIntensityMap?"#define USE_SPECULARINTENSITYMAP":"",i.specularColorMap?"#define USE_SPECULARCOLORMAP":"",i.roughnessMap?"#define USE_ROUGHNESSMAP":"",i.metalnessMap?"#define USE_METALNESSMAP":"",i.alphaMap?"#define USE_ALPHAMAP":"",i.transmission?"#define USE_TRANSMISSION":"",i.transmissionMap?"#define USE_TRANSMISSIONMAP":"",i.thicknessMap?"#define USE_THICKNESSMAP":"",i.sheenColorMap?"#define USE_SHEENCOLORMAP":"",i.sheenRoughnessMap?"#define USE_SHEENROUGHNESSMAP":"",i.vertexTangents?"#define USE_TANGENT":"",i.vertexColors?"#define USE_COLOR":"",i.vertexAlphas?"#define USE_COLOR_ALPHA":"",i.vertexUvs?"#define USE_UV":"",i.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",i.flatShading?"#define FLAT_SHADED":"",i.skinning?"#define USE_SKINNING":"",i.useVertexTexture?"#define BONE_TEXTURE":"",i.morphTargets?"#define USE_MORPHTARGETS":"",i.morphNormals&&!1===i.flatShading?"#define USE_MORPHNORMALS":"",i.morphTargets&&i.isWebGL2?"#define MORPHTARGETS_TEXTURE":"",i.morphTargets&&i.isWebGL2?"#define MORPHTARGETS_COUNT "+i.morphTargetsCount:"",i.doubleSided?"#define DOUBLE_SIDED":"",i.flipSided?"#define FLIP_SIDED":"",i.shadowMapEnabled?"#define USE_SHADOWMAP":"",i.shadowMapEnabled?"#define "+h:"",i.sizeAttenuation?"#define USE_SIZEATTENUATION":"",i.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",i.logarithmicDepthBuffer&&i.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING","\tattribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR","\tattribute vec3 instanceColor;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_TANGENT","\tattribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )","\tattribute vec4 color;","#elif defined( USE_COLOR )","\tattribute vec3 color;","#endif","#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(To).join("\n"),_=[p,ko(i),"#define SHADER_NAME "+i.shaderName,m,"#define GAMMA_FACTOR "+d,i.useFog&&i.fog?"#define USE_FOG":"",i.useFog&&i.fogExp2?"#define FOG_EXP2":"",i.map?"#define USE_MAP":"",i.matcap?"#define USE_MATCAP":"",i.envMap?"#define USE_ENVMAP":"",i.envMap?"#define "+c:"",i.envMap?"#define "+l:"",i.envMap?"#define "+u:"",i.lightMap?"#define USE_LIGHTMAP":"",i.aoMap?"#define USE_AOMAP":"",i.emissiveMap?"#define USE_EMISSIVEMAP":"",i.bumpMap?"#define USE_BUMPMAP":"",i.normalMap?"#define USE_NORMALMAP":"",i.normalMap&&i.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",i.normalMap&&i.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",i.clearcoat?"#define USE_CLEARCOAT":"",i.clearcoatMap?"#define USE_CLEARCOATMAP":"",i.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",i.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",i.specularMap?"#define USE_SPECULARMAP":"",i.specularIntensityMap?"#define USE_SPECULARINTENSITYMAP":"",i.specularColorMap?"#define USE_SPECULARCOLORMAP":"",i.roughnessMap?"#define USE_ROUGHNESSMAP":"",i.metalnessMap?"#define USE_METALNESSMAP":"",i.alphaMap?"#define USE_ALPHAMAP":"",i.alphaTest?"#define USE_ALPHATEST":"",i.sheen?"#define USE_SHEEN":"",i.sheenColorMap?"#define USE_SHEENCOLORMAP":"",i.sheenRoughnessMap?"#define USE_SHEENROUGHNESSMAP":"",i.transmission?"#define USE_TRANSMISSION":"",i.transmissionMap?"#define USE_TRANSMISSIONMAP":"",i.thicknessMap?"#define USE_THICKNESSMAP":"",i.vertexTangents?"#define USE_TANGENT":"",i.vertexColors||i.instancingColor?"#define USE_COLOR":"",i.vertexAlphas?"#define USE_COLOR_ALPHA":"",i.vertexUvs?"#define USE_UV":"",i.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",i.gradientMap?"#define USE_GRADIENTMAP":"",i.flatShading?"#define FLAT_SHADED":"",i.doubleSided?"#define DOUBLE_SIDED":"",i.flipSided?"#define FLIP_SIDED":"",i.shadowMapEnabled?"#define USE_SHADOWMAP":"",i.shadowMapEnabled?"#define "+h:"",i.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",i.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",i.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",i.logarithmicDepthBuffer&&i.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"",(i.extensionShaderTextureLOD||i.envMap)&&i.rendererExtensionShaderTextureLod?"#define TEXTURE_LOD_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",0!==i.toneMapping?"#define TONE_MAPPING":"",0!==i.toneMapping?Ms.tonemapping_pars_fragment:"",0!==i.toneMapping?So("toneMapping",i.toneMapping):"",i.dithering?"#define DITHERING":"",i.format===ai?"#define OPAQUE":"",Ms.encodings_pars_fragment,i.map?wo("mapTexelToLinear",i.mapEncoding):"",i.matcap?wo("matcapTexelToLinear",i.matcapEncoding):"",i.envMap?wo("envMapTexelToLinear",i.envMapEncoding):"",i.emissiveMap?wo("emissiveMapTexelToLinear",i.emissiveMapEncoding):"",i.specularColorMap?wo("specularColorMapTexelToLinear",i.specularColorMapEncoding):"",i.sheenColorMap?wo("sheenColorMapTexelToLinear",i.sheenColorMapEncoding):"",i.lightMap?wo("lightMapTexelToLinear",i.lightMapEncoding):"",Mo("linearToOutputTexel",i.outputEncoding),i.depthPacking?"#define DEPTH_PACKING "+i.depthPacking:"","\n"].filter(To).join("\n")),a=Io(a),a=Co(a,i),a=Eo(a,i),o=Io(o),o=Co(o,i),o=Eo(o,i),a=Do(a),o=Do(o),i.isWebGL2&&!0!==i.isRawShaderMaterial&&(v="#version 300 es\n",g=["precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+g,_=["#define varying in",i.glslVersion===Si?"":"out highp vec4 pc_fragColor;",i.glslVersion===Si?"":"#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 y=v+_+o,b=vo(r,35633,v+g+a),x=vo(r,35632,y);if(r.attachShader(f,b),r.attachShader(f,x),void 0!==i.index0AttributeName?r.bindAttribLocation(f,0,i.index0AttributeName):!0===i.morphTargets&&r.bindAttribLocation(f,0,"position"),r.linkProgram(f),e.debug.checkShaderErrors){const e=r.getProgramInfoLog(f).trim(),t=r.getShaderInfoLog(b).trim(),i=r.getShaderInfoLog(x).trim();let n=!0,s=!0;if(!1===r.getProgramParameter(f,35714)){n=!1;const t=xo(r,b,"vertex"),i=xo(r,x,"fragment");console.error("THREE.WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(f,35715)+"\n\nProgram Info Log: "+e+"\n"+t+"\n"+i)}else""!==e?console.warn("THREE.WebGLProgram: Program Info Log:",e):""!==t&&""!==i||(s=!1);s&&(this.diagnostics={runnable:n,programLog:e,vertexShader:{log:t,prefix:g},fragmentShader:{log:i,prefix:_}})}let w,M;return r.deleteShader(b),r.deleteShader(x),this.getUniforms=function(){return void 0===w&&(w=new _o(r,f)),w},this.getAttributes=function(){return void 0===M&&(M=function(e,t){const i={},n=e.getProgramParameter(t,35721);for(let r=0;r<n;r++){const n=e.getActiveAttrib(t,r),s=n.name;let a=1;35674===n.type&&(a=2),35675===n.type&&(a=3),35676===n.type&&(a=4),i[s]={type:n.type,location:e.getAttribLocation(t,s),locationSize:a}}return i}(r,f)),M},this.destroy=function(){n.releaseStatesOfProgram(this),r.deleteProgram(f),this.program=void 0},this.name=i.shaderName,this.id=yo++,this.cacheKey=t,this.usedTimes=1,this.program=f,this.vertexShader=b,this.fragmentShader=x,this}function zo(e,t,i,n,r,s,a){const o=[],h=r.isWebGL2,c=r.logarithmicDepthBuffer,l=r.floatVertexTextures,u=r.maxVertexUniforms,d=r.vertexTextures;let p=r.precision;const m={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"},f=["precision","isWebGL2","supportsVertexTextures","outputEncoding","instancing","instancingColor","map","mapEncoding","matcap","matcapEncoding","envMap","envMapMode","envMapEncoding","envMapCubeUV","lightMap","lightMapEncoding","aoMap","emissiveMap","emissiveMapEncoding","bumpMap","normalMap","objectSpaceNormalMap","tangentSpaceNormalMap","clearcoat","clearcoatMap","clearcoatRoughnessMap","clearcoatNormalMap","displacementMap","specularMap",,"roughnessMap","metalnessMap","gradientMap","alphaMap","alphaTest","combine","vertexColors","vertexAlphas","vertexTangents","vertexUvs","uvsVertexOnly","fog","useFog","fogExp2","flatShading","sizeAttenuation","logarithmicDepthBuffer","skinning","maxBones","useVertexTexture","morphTargets","morphNormals","morphTargetsCount","premultipliedAlpha","numDirLights","numPointLights","numSpotLights","numHemiLights","numRectAreaLights","numDirLightShadows","numPointLightShadows","numSpotLightShadows","shadowMapEnabled","shadowMapType","toneMapping","physicallyCorrectLights","doubleSided","flipSided","numClippingPlanes","numClipIntersection","depthPacking","dithering","format","specularIntensityMap","specularColorMap","specularColorMapEncoding","transmission","transmissionMap","thicknessMap","sheen","sheenColorMap","sheenColorMapEncoding","sheenRoughnessMap"];function g(e){let t;return e&&e.isTexture?t=e.encoding:e&&e.isWebGLRenderTarget?(console.warn("THREE.WebGLPrograms.getTextureEncodingFromMap: don't use render targets as textures. Use their .texture property instead."),t=e.texture.encoding):t=_i,h&&e&&e.isTexture&&e.format===oi&&e.type===ei&&e.encoding===vi&&(t=_i),t}return{getParameters:function(s,o,f,_,v){const y=_.fog,b=s.isMeshStandardMaterial?_.environment:null,x=(s.isMeshStandardMaterial?i:t).get(s.envMap||b),w=m[s.type],M=v.isSkinnedMesh?function(e){const t=e.skeleton.bones;if(l)return 1024;{const e=u,i=Math.floor((e-20)/4),n=Math.min(i,t.length);return n<t.length?(console.warn("THREE.WebGLRenderer: Skeleton has "+t.length+" bones. This GPU supports "+n+"."),0):n}}(v):0;let S,T;if(null!==s.precision&&(p=r.getMaxPrecision(s.precision),p!==s.precision&&console.warn("THREE.WebGLProgram.getParameters:",s.precision,"not supported, using",p,"instead.")),w){const e=Ts[w];S=e.vertexShader,T=e.fragmentShader}else S=s.vertexShader,T=s.fragmentShader;const C=e.getRenderTarget(),E=s.alphaTest>0,A=s.clearcoat>0;return{isWebGL2:h,shaderID:w,shaderName:s.type,vertexShader:S,fragmentShader:T,defines:s.defines,isRawShaderMaterial:!0===s.isRawShaderMaterial,glslVersion:s.glslVersion,precision:p,instancing:!0===v.isInstancedMesh,instancingColor:!0===v.isInstancedMesh&&null!==v.instanceColor,supportsVertexTextures:d,outputEncoding:null!==C?g(C.texture):e.outputEncoding,map:!!s.map,mapEncoding:g(s.map),matcap:!!s.matcap,matcapEncoding:g(s.matcap),envMap:!!x,envMapMode:x&&x.mapping,envMapEncoding:g(x),envMapCubeUV:!!x&&(x.mapping===qt||307===x.mapping),lightMap:!!s.lightMap,lightMapEncoding:g(s.lightMap),aoMap:!!s.aoMap,emissiveMap:!!s.emissiveMap,emissiveMapEncoding:g(s.emissiveMap),bumpMap:!!s.bumpMap,normalMap:!!s.normalMap,objectSpaceNormalMap:1===s.normalMapType,tangentSpaceNormalMap:0===s.normalMapType,clearcoat:A,clearcoatMap:A&&!!s.clearcoatMap,clearcoatRoughnessMap:A&&!!s.clearcoatRoughnessMap,clearcoatNormalMap:A&&!!s.clearcoatNormalMap,displacementMap:!!s.displacementMap,roughnessMap:!!s.roughnessMap,metalnessMap:!!s.metalnessMap,specularMap:!!s.specularMap,specularIntensityMap:!!s.specularIntensityMap,specularColorMap:!!s.specularColorMap,specularColorMapEncoding:g(s.specularColorMap),alphaMap:!!s.alphaMap,alphaTest:E,gradientMap:!!s.gradientMap,sheen:s.sheen>0,sheenColorMap:!!s.sheenColorMap,sheenColorMapEncoding:g(s.sheenColorMap),sheenRoughnessMap:!!s.sheenRoughnessMap,transmission:s.transmission>0,transmissionMap:!!s.transmissionMap,thicknessMap:!!s.thicknessMap,combine:s.combine,vertexTangents:!!s.normalMap&&!!v.geometry&&!!v.geometry.attributes.tangent,vertexColors:s.vertexColors,vertexAlphas:!0===s.vertexColors&&!!v.geometry&&!!v.geometry.attributes.color&&4===v.geometry.attributes.color.itemSize,vertexUvs:!!s.map||!!s.bumpMap||!!s.normalMap||!!s.specularMap||!!s.alphaMap||!!s.emissiveMap||!!s.roughnessMap||!!s.metalnessMap||!!s.clearcoatMap||!!s.clearcoatRoughnessMap||!!s.clearcoatNormalMap||!!s.displacementMap||!!s.transmissionMap||!!s.thicknessMap||!!s.specularIntensityMap||!!s.specularColorMap||!!s.sheenColorMap||s.sheenRoughnessMap,uvsVertexOnly:!(s.map||s.bumpMap||s.normalMap||s.specularMap||s.alphaMap||s.emissiveMap||s.roughnessMap||s.metalnessMap||s.clearcoatNormalMap||s.transmission>0||s.transmissionMap||s.thicknessMap||s.specularIntensityMap||s.specularColorMap||!!s.sheen>0||s.sheenColorMap||s.sheenRoughnessMap||!s.displacementMap),fog:!!y,useFog:s.fog,fogExp2:y&&y.isFogExp2,flatShading:!!s.flatShading,sizeAttenuation:s.sizeAttenuation,logarithmicDepthBuffer:c,skinning:!0===v.isSkinnedMesh&&M>0,maxBones:M,useVertexTexture:l,morphTargets:!!v.geometry&&!!v.geometry.morphAttributes.position,morphNormals:!!v.geometry&&!!v.geometry.morphAttributes.normal,morphTargetsCount:v.geometry&&v.geometry.morphAttributes.position?v.geometry.morphAttributes.position.length:0,numDirLights:o.directional.length,numPointLights:o.point.length,numSpotLights:o.spot.length,numRectAreaLights:o.rectArea.length,numHemiLights:o.hemi.length,numDirLightShadows:o.directionalShadowMap.length,numPointLightShadows:o.pointShadowMap.length,numSpotLightShadows:o.spotShadowMap.length,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,format:s.format,dithering:s.dithering,shadowMapEnabled:e.shadowMap.enabled&&f.length>0,shadowMapType:e.shadowMap.type,toneMapping:s.toneMapped?e.toneMapping:0,physicallyCorrectLights:e.physicallyCorrectLights,premultipliedAlpha:s.premultipliedAlpha,doubleSided:2===s.side,flipSided:1===s.side,depthPacking:void 0!==s.depthPacking&&s.depthPacking,index0AttributeName:s.index0AttributeName,extensionDerivatives:s.extensions&&s.extensions.derivatives,extensionFragDepth:s.extensions&&s.extensions.fragDepth,extensionDrawBuffers:s.extensions&&s.extensions.drawBuffers,extensionShaderTextureLOD:s.extensions&&s.extensions.shaderTextureLOD,rendererExtensionFragDepth:h||n.has("EXT_frag_depth"),rendererExtensionDrawBuffers:h||n.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:h||n.has("EXT_shader_texture_lod"),customProgramCacheKey:s.customProgramCacheKey()}},getProgramCacheKey:function(t){const i=[];if(t.shaderID?i.push(t.shaderID):(i.push(Vi(t.fragmentShader)),i.push(Vi(t.vertexShader))),void 0!==t.defines)for(const e in t.defines)i.push(e),i.push(t.defines[e]);if(!1===t.isRawShaderMaterial){for(let e=0;e<f.length;e++)i.push(t[f[e]]);i.push(e.outputEncoding),i.push(e.gammaFactor)}return i.push(t.customProgramCacheKey),i.join()},getUniforms:function(e){const t=m[e.type];let i;if(t){const e=Ts[t];i=ss.clone(e.uniforms)}else i=e.uniforms;return i},acquireProgram:function(t,i){let n;for(let e=0,t=o.length;e<t;e++){const t=o[e];if(t.cacheKey===i){n=t,++n.usedTimes;break}}return void 0===n&&(n=new Oo(e,i,t,s),o.push(n)),n},releaseProgram:function(e){if(0==--e.usedTimes){const t=o.indexOf(e);o[t]=o[o.length-1],o.pop(),e.destroy()}},programs:o}}function Fo(){let e=new WeakMap;return{get:function(t){let i=e.get(t);return void 0===i&&(i={},e.set(t,i)),i},remove:function(t){e.delete(t)},update:function(t,i,n){e.get(t)[i]=n},dispose:function(){e=new WeakMap}}}function Bo(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.program!==t.program?e.program.id-t.program.id:e.material.id!==t.material.id?e.material.id-t.material.id:e.z!==t.z?e.z-t.z:e.id-t.id}function Uo(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.z!==t.z?t.z-e.z:e.id-t.id}function Vo(e){const t=[];let i=0;const n=[],r=[],s=[],a={id:-1};function o(n,r,s,o,h,c){let l=t[i];const u=e.get(s);return void 0===l?(l={id:n.id,object:n,geometry:r,material:s,program:u.program||a,groupOrder:o,renderOrder:n.renderOrder,z:h,group:c},t[i]=l):(l.id=n.id,l.object=n,l.geometry=r,l.material=s,l.program=u.program||a,l.groupOrder=o,l.renderOrder=n.renderOrder,l.z=h,l.group=c),i++,l}return{opaque:n,transmissive:r,transparent:s,init:function(){i=0,n.length=0,r.length=0,s.length=0},push:function(e,t,i,a,h,c){const l=o(e,t,i,a,h,c);i.transmission>0?r.push(l):!0===i.transparent?s.push(l):n.push(l)},unshift:function(e,t,i,a,h,c){const l=o(e,t,i,a,h,c);i.transmission>0?r.unshift(l):!0===i.transparent?s.unshift(l):n.unshift(l)},finish:function(){for(let e=i,n=t.length;e<n;e++){const i=t[e];if(null===i.id)break;i.id=null,i.object=null,i.geometry=null,i.material=null,i.program=null,i.group=null}},sort:function(e,t){n.length>1&&n.sort(e||Bo),r.length>1&&r.sort(t||Uo),s.length>1&&s.sort(t||Uo)}}}function Ho(e){let t=new WeakMap;return{get:function(i,n){let r;return!1===t.has(i)?(r=new Vo(e),t.set(i,[r])):n>=t.get(i).length?(r=new Vo(e),t.get(i).push(r)):r=t.get(i)[n],r},dispose:function(){t=new WeakMap}}}function jo(){const e={};return{get:function(t){if(void 0!==e[t.id])return e[t.id];let i;switch(t.type){case"DirectionalLight":i={direction:new Ki,color:new xr};break;case"SpotLight":i={position:new Ki,direction:new Ki,color:new xr,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":i={position:new Ki,color:new xr,distance:0,decay:0};break;case"HemisphereLight":i={direction:new Ki,skyColor:new xr,groundColor:new xr};break;case"RectAreaLight":i={color:new xr,position:new Ki,halfWidth:new Ki,halfHeight:new Ki}}return e[t.id]=i,i}}}let Go=0;function Wo(e,t){return(t.castShadow?1:0)-(e.castShadow?1:0)}function qo(e,t){const i=new jo,n=function(){const e={};return{get:function(t){if(void 0!==e[t.id])return e[t.id];let i;switch(t.type){case"DirectionalLight":case"SpotLight":i={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new zi};break;case"PointLight":i={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new zi,shadowCameraNear:1,shadowCameraFar:1e3}}return e[t.id]=i,i}}}(),r={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotShadow:[],spotShadowMap:[],spotShadowMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[]};for(let e=0;e<9;e++)r.probe.push(new Ki);const s=new Ki,a=new Rn,o=new Rn;return{setup:function(s,a){let o=0,h=0,c=0;for(let e=0;e<9;e++)r.probe[e].set(0,0,0);let l=0,u=0,d=0,p=0,m=0,f=0,g=0,_=0;s.sort(Wo);const v=!0!==a?Math.PI:1;for(let e=0,t=s.length;e<t;e++){const t=s[e],a=t.color,y=t.intensity,b=t.distance,x=t.shadow&&t.shadow.map?t.shadow.map.texture:null;if(t.isAmbientLight)o+=a.r*y*v,h+=a.g*y*v,c+=a.b*y*v;else if(t.isLightProbe)for(let e=0;e<9;e++)r.probe[e].addScaledVector(t.sh.coefficients[e],y);else if(t.isDirectionalLight){const e=i.get(t);if(e.color.copy(t.color).multiplyScalar(t.intensity*v),t.castShadow){const e=t.shadow,i=n.get(t);i.shadowBias=e.bias,i.shadowNormalBias=e.normalBias,i.shadowRadius=e.radius,i.shadowMapSize=e.mapSize,r.directionalShadow[l]=i,r.directionalShadowMap[l]=x,r.directionalShadowMatrix[l]=t.shadow.matrix,f++}r.directional[l]=e,l++}else if(t.isSpotLight){const e=i.get(t);if(e.position.setFromMatrixPosition(t.matrixWorld),e.color.copy(a).multiplyScalar(y*v),e.distance=b,e.coneCos=Math.cos(t.angle),e.penumbraCos=Math.cos(t.angle*(1-t.penumbra)),e.decay=t.decay,t.castShadow){const e=t.shadow,i=n.get(t);i.shadowBias=e.bias,i.shadowNormalBias=e.normalBias,i.shadowRadius=e.radius,i.shadowMapSize=e.mapSize,r.spotShadow[d]=i,r.spotShadowMap[d]=x,r.spotShadowMatrix[d]=t.shadow.matrix,_++}r.spot[d]=e,d++}else if(t.isRectAreaLight){const e=i.get(t);e.color.copy(a).multiplyScalar(y),e.halfWidth.set(.5*t.width,0,0),e.halfHeight.set(0,.5*t.height,0),r.rectArea[p]=e,p++}else if(t.isPointLight){const e=i.get(t);if(e.color.copy(t.color).multiplyScalar(t.intensity*v),e.distance=t.distance,e.decay=t.decay,t.castShadow){const e=t.shadow,i=n.get(t);i.shadowBias=e.bias,i.shadowNormalBias=e.normalBias,i.shadowRadius=e.radius,i.shadowMapSize=e.mapSize,i.shadowCameraNear=e.camera.near,i.shadowCameraFar=e.camera.far,r.pointShadow[u]=i,r.pointShadowMap[u]=x,r.pointShadowMatrix[u]=t.shadow.matrix,g++}r.point[u]=e,u++}else if(t.isHemisphereLight){const e=i.get(t);e.skyColor.copy(t.color).multiplyScalar(y*v),e.groundColor.copy(t.groundColor).multiplyScalar(y*v),r.hemi[m]=e,m++}}p>0&&(t.isWebGL2||!0===e.has("OES_texture_float_linear")?(r.rectAreaLTC1=Ss.LTC_FLOAT_1,r.rectAreaLTC2=Ss.LTC_FLOAT_2):!0===e.has("OES_texture_half_float_linear")?(r.rectAreaLTC1=Ss.LTC_HALF_1,r.rectAreaLTC2=Ss.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),r.ambient[0]=o,r.ambient[1]=h,r.ambient[2]=c;const y=r.hash;y.directionalLength===l&&y.pointLength===u&&y.spotLength===d&&y.rectAreaLength===p&&y.hemiLength===m&&y.numDirectionalShadows===f&&y.numPointShadows===g&&y.numSpotShadows===_||(r.directional.length=l,r.spot.length=d,r.rectArea.length=p,r.point.length=u,r.hemi.length=m,r.directionalShadow.length=f,r.directionalShadowMap.length=f,r.pointShadow.length=g,r.pointShadowMap.length=g,r.spotShadow.length=_,r.spotShadowMap.length=_,r.directionalShadowMatrix.length=f,r.pointShadowMatrix.length=g,r.spotShadowMatrix.length=_,y.directionalLength=l,y.pointLength=u,y.spotLength=d,y.rectAreaLength=p,y.hemiLength=m,y.numDirectionalShadows=f,y.numPointShadows=g,y.numSpotShadows=_,r.version=Go++)},setupView:function(e,t){let i=0,n=0,h=0,c=0,l=0;const u=t.matrixWorldInverse;for(let t=0,d=e.length;t<d;t++){const d=e[t];if(d.isDirectionalLight){const e=r.directional[i];e.direction.setFromMatrixPosition(d.matrixWorld),s.setFromMatrixPosition(d.target.matrixWorld),e.direction.sub(s),e.direction.transformDirection(u),i++}else if(d.isSpotLight){const e=r.spot[h];e.position.setFromMatrixPosition(d.matrixWorld),e.position.applyMatrix4(u),e.direction.setFromMatrixPosition(d.matrixWorld),s.setFromMatrixPosition(d.target.matrixWorld),e.direction.sub(s),e.direction.transformDirection(u),h++}else if(d.isRectAreaLight){const e=r.rectArea[c];e.position.setFromMatrixPosition(d.matrixWorld),e.position.applyMatrix4(u),o.identity(),a.copy(d.matrixWorld),a.premultiply(u),o.extractRotation(a),e.halfWidth.set(.5*d.width,0,0),e.halfHeight.set(0,.5*d.height,0),e.halfWidth.applyMatrix4(o),e.halfHeight.applyMatrix4(o),c++}else if(d.isPointLight){const e=r.point[n];e.position.setFromMatrixPosition(d.matrixWorld),e.position.applyMatrix4(u),n++}else if(d.isHemisphereLight){const e=r.hemi[l];e.direction.setFromMatrixPosition(d.matrixWorld),e.direction.transformDirection(u),e.direction.normalize(),l++}}},state:r}}function Xo(e,t){const i=new qo(e,t),n=[],r=[];return{init:function(){n.length=0,r.length=0},state:{lightsArray:n,shadowsArray:r,lights:i},setupLights:function(e){i.setup(n,e)},setupLightsView:function(e){i.setupView(n,e)},pushLight:function(e){n.push(e)},pushShadow:function(e){r.push(e)}}}function Zo(e,t){let i=new WeakMap;return{get:function(n,r=0){let s;return!1===i.has(n)?(s=new Xo(e,t),i.set(n,[s])):r>=i.get(n).length?(s=new Xo(e,t),i.get(n).push(s)):s=i.get(n)[r],s},dispose:function(){i=new WeakMap}}}class Yo extends mr{constructor(e){super(),this.type="MeshDepthMaterial",this.depthPacking=3200,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}Yo.prototype.isMeshDepthMaterial=!0;class Jo extends mr{constructor(e){super(),this.type="MeshDistanceMaterial",this.referencePosition=new Ki,this.nearDistance=1,this.farDistance=1e3,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.fog=!1,this.setValues(e)}copy(e){return super.copy(e),this.referencePosition.copy(e.referencePosition),this.nearDistance=e.nearDistance,this.farDistance=e.farDistance,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}Jo.prototype.isMeshDistanceMaterial=!0;function Ko(e,t,i){let n=new ys;const r=new zi,s=new zi,a=new Xi,o=new Yo({depthPacking:3201}),h=new Jo,c={},l=i.maxTextureSize,u={0:1,1:0,2:2},d=new as({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new zi},radius:{value:4}},vertexShader:"void main() {\n\tgl_Position = vec4( position, 1.0 );\n}",fragmentShader:"uniform sampler2D shadow_pass;\nuniform vec2 resolution;\nuniform float radius;\n#include <packing>\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}"}),p=d.clone();p.defines.HORIZONTAL_PASS=1;const m=new kr;m.setAttribute("position",new Tr(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const f=new es(m,d),g=this;function _(i,n){const r=t.update(f);d.defines.VSM_SAMPLES!==i.blurSamples&&(d.defines.VSM_SAMPLES=i.blurSamples,p.defines.VSM_SAMPLES=i.blurSamples,d.needsUpdate=!0,p.needsUpdate=!0),d.uniforms.shadow_pass.value=i.map.texture,d.uniforms.resolution.value=i.mapSize,d.uniforms.radius.value=i.radius,e.setRenderTarget(i.mapPass),e.clear(),e.renderBufferDirect(n,null,r,d,f,null),p.uniforms.shadow_pass.value=i.mapPass.texture,p.uniforms.resolution.value=i.mapSize,p.uniforms.radius.value=i.radius,e.setRenderTarget(i.map),e.clear(),e.renderBufferDirect(n,null,r,p,f,null)}function v(t,i,n,r,s,a,l){let d=null;const p=!0===r.isPointLight?t.customDistanceMaterial:t.customDepthMaterial;if(d=void 0!==p?p:!0===r.isPointLight?h:o,e.localClippingEnabled&&!0===n.clipShadows&&0!==n.clippingPlanes.length||n.displacementMap&&0!==n.displacementScale||n.alphaMap&&n.alphaTest>0){const e=d.uuid,t=n.uuid;let i=c[e];void 0===i&&(i={},c[e]=i);let r=i[t];void 0===r&&(r=d.clone(),i[t]=r),d=r}return d.visible=n.visible,d.wireframe=n.wireframe,d.side=3===l?null!==n.shadowSide?n.shadowSide:n.side:null!==n.shadowSide?n.shadowSide:u[n.side],d.alphaMap=n.alphaMap,d.alphaTest=n.alphaTest,d.clipShadows=n.clipShadows,d.clippingPlanes=n.clippingPlanes,d.clipIntersection=n.clipIntersection,d.displacementMap=n.displacementMap,d.displacementScale=n.displacementScale,d.displacementBias=n.displacementBias,d.wireframeLinewidth=n.wireframeLinewidth,d.linewidth=n.linewidth,!0===r.isPointLight&&!0===d.isMeshDistanceMaterial&&(d.referencePosition.setFromMatrixPosition(r.matrixWorld),d.nearDistance=s,d.farDistance=a),d}function y(i,r,s,a,o){if(!1===i.visible)return;if(i.layers.test(r.layers)&&(i.isMesh||i.isLine||i.isPoints)&&(i.castShadow||i.receiveShadow&&3===o)&&(!i.frustumCulled||n.intersectsObject(i))){i.modelViewMatrix.multiplyMatrices(s.matrixWorldInverse,i.matrixWorld);const n=t.update(i),r=i.material;if(Array.isArray(r)){const t=n.groups;for(let h=0,c=t.length;h<c;h++){const c=t[h],l=r[c.materialIndex];if(l&&l.visible){const t=v(i,0,l,a,s.near,s.far,o);e.renderBufferDirect(s,null,n,t,i,c)}}}else if(r.visible){const t=v(i,0,r,a,s.near,s.far,o);e.renderBufferDirect(s,null,n,t,i,null)}}const h=i.children;for(let e=0,t=h.length;e<t;e++)y(h[e],r,s,a,o)}this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=1,this.render=function(t,i,o){if(!1===g.enabled)return;if(!1===g.autoUpdate&&!1===g.needsUpdate)return;if(0===t.length)return;const h=e.getRenderTarget(),c=e.getActiveCubeFace(),u=e.getActiveMipmapLevel(),d=e.state;d.setBlending(0),d.buffers.color.setClear(1,1,1,1),d.buffers.depth.setTest(!0),d.setScissorTest(!1);for(let h=0,c=t.length;h<c;h++){const c=t[h],u=c.shadow;if(void 0===u){console.warn("THREE.WebGLShadowMap:",c,"has no shadow.");continue}if(!1===u.autoUpdate&&!1===u.needsUpdate)continue;r.copy(u.mapSize);const p=u.getFrameExtents();if(r.multiply(p),s.copy(u.mapSize),(r.x>l||r.y>l)&&(r.x>l&&(s.x=Math.floor(l/p.x),r.x=s.x*p.x,u.mapSize.x=s.x),r.y>l&&(s.y=Math.floor(l/p.y),r.y=s.y*p.y,u.mapSize.y=s.y)),null===u.map&&!u.isPointLightShadow&&3===this.type){const e={minFilter:Kt,magFilter:Kt,format:oi};u.map=new Zi(r.x,r.y,e),u.map.texture.name=c.name+".shadowMap",u.mapPass=new Zi(r.x,r.y,e),u.camera.updateProjectionMatrix()}if(null===u.map){const e={minFilter:Jt,magFilter:Jt,format:oi};u.map=new Zi(r.x,r.y,e),u.map.texture.name=c.name+".shadowMap",u.camera.updateProjectionMatrix()}e.setRenderTarget(u.map),e.clear();const m=u.getViewportCount();for(let e=0;e<m;e++){const t=u.getViewport(e);a.set(s.x*t.x,s.y*t.y,s.x*t.z,s.y*t.w),d.viewport(a),u.updateMatrices(c,e),n=u.getFrustum(),y(i,o,u.camera,c,this.type)}u.isPointLightShadow||3!==this.type||_(u,o),u.needsUpdate=!1}g.needsUpdate=!1,e.setRenderTarget(h,c,u)}}function Qo(e,t,i){const n=i.isWebGL2;const r=new function(){let t=!1;const i=new Xi;let n=null;const r=new Xi(0,0,0,0);return{setMask:function(i){n===i||t||(e.colorMask(i,i,i,i),n=i)},setLocked:function(e){t=e},setClear:function(t,n,s,a,o){!0===o&&(t*=a,n*=a,s*=a),i.set(t,n,s,a),!1===r.equals(i)&&(e.clearColor(t,n,s,a),r.copy(i))},reset:function(){t=!1,n=null,r.set(-1,0,0,0)}}},s=new function(){let t=!1,i=null,n=null,r=null;return{setTest:function(e){e?O(2929):z(2929)},setMask:function(n){i===n||t||(e.depthMask(n),i=n)},setFunc:function(t){if(n!==t){if(t)switch(t){case 0:e.depthFunc(512);break;case 1:e.depthFunc(519);break;case 2:e.depthFunc(513);break;case 3:e.depthFunc(515);break;case 4:e.depthFunc(514);break;case 5:e.depthFunc(518);break;case 6:e.depthFunc(516);break;case 7:e.depthFunc(517);break;default:e.depthFunc(515)}else e.depthFunc(515);n=t}},setLocked:function(e){t=e},setClear:function(t){r!==t&&(e.clearDepth(t),r=t)},reset:function(){t=!1,i=null,n=null,r=null}}},a=new function(){let t=!1,i=null,n=null,r=null,s=null,a=null,o=null,h=null,c=null;return{setTest:function(e){t||(e?O(2960):z(2960))},setMask:function(n){i===n||t||(e.stencilMask(n),i=n)},setFunc:function(t,i,a){n===t&&r===i&&s===a||(e.stencilFunc(t,i,a),n=t,r=i,s=a)},setOp:function(t,i,n){a===t&&o===i&&h===n||(e.stencilOp(t,i,n),a=t,o=i,h=n)},setLocked:function(e){t=e},setClear:function(t){c!==t&&(e.clearStencil(t),c=t)},reset:function(){t=!1,i=null,n=null,r=null,s=null,a=null,o=null,h=null,c=null}}};let o={},h=null,c={},l=null,u=!1,d=null,p=null,m=null,f=null,g=null,_=null,v=null,y=!1,b=null,x=null,w=null,M=null,S=null;const T=e.getParameter(35661);let C=!1,E=0;const A=e.getParameter(7938);-1!==A.indexOf("WebGL")?(E=parseFloat(/^WebGL (\d)/.exec(A)[1]),C=E>=1):-1!==A.indexOf("OpenGL ES")&&(E=parseFloat(/^OpenGL ES (\d)/.exec(A)[1]),C=E>=2);let I=null,R={};const P=e.getParameter(3088),L=e.getParameter(2978),D=(new Xi).fromArray(P),N=(new Xi).fromArray(L);function $(t,i,n){const r=new Uint8Array(4),s=e.createTexture();e.bindTexture(t,s),e.texParameteri(t,10241,9728),e.texParameteri(t,10240,9728);for(let t=0;t<n;t++)e.texImage2D(i+t,0,6408,1,1,0,6408,5121,r);return s}const k={};function O(t){!0!==o[t]&&(e.enable(t),o[t]=!0)}function z(t){!1!==o[t]&&(e.disable(t),o[t]=!1)}k[3553]=$(3553,3553,1),k[34067]=$(34067,34069,6),r.setClear(0,0,0,1),s.setClear(1),a.setClear(0),O(2929),s.setFunc(3),V(!1),H(1),O(2884),U(0);const F={[jt]:32774,101:32778,102:32779};if(n)F[103]=32775,F[104]=32776;else{const e=t.get("EXT_blend_minmax");null!==e&&(F[103]=e.MIN_EXT,F[104]=e.MAX_EXT)}const B={200:0,201:1,202:768,204:770,210:776,208:774,206:772,203:769,205:771,209:775,207:773};function U(t,i,n,r,s,a,o,h){if(0!==t){if(!1===u&&(O(3042),u=!0),5===t)s=s||i,a=a||n,o=o||r,i===p&&s===g||(e.blendEquationSeparate(F[i],F[s]),p=i,g=s),n===m&&r===f&&a===_&&o===v||(e.blendFuncSeparate(B[n],B[r],B[a],B[o]),m=n,f=r,_=a,v=o),d=t,y=null;else if(t!==d||h!==y){if(p===jt&&g===jt||(e.blendEquation(32774),p=jt,g=jt),h)switch(t){case 1:e.blendFuncSeparate(1,771,1,771);break;case 2:e.blendFunc(1,1);break;case 3:e.blendFuncSeparate(0,0,769,771);break;case 4:e.blendFuncSeparate(0,768,0,770);break;default:console.error("THREE.WebGLState: Invalid blending: ",t)}else switch(t){case 1:e.blendFuncSeparate(770,771,1,771);break;case 2:e.blendFunc(770,1);break;case 3:e.blendFunc(0,769);break;case 4:e.blendFunc(0,768);break;default:console.error("THREE.WebGLState: Invalid blending: ",t)}m=null,f=null,_=null,v=null,d=t,y=h}}else!0===u&&(z(3042),u=!1)}function V(t){b!==t&&(t?e.frontFace(2304):e.frontFace(2305),b=t)}function H(t){0!==t?(O(2884),t!==x&&(1===t?e.cullFace(1029):2===t?e.cullFace(1028):e.cullFace(1032))):z(2884),x=t}function j(t,i,n){t?(O(32823),M===i&&S===n||(e.polygonOffset(i,n),M=i,S=n)):z(32823)}function G(t){void 0===t&&(t=33984+T-1),I!==t&&(e.activeTexture(t),I=t)}return{buffers:{color:r,depth:s,stencil:a},enable:O,disable:z,bindFramebuffer:function(t,i){return null===i&&null!==h&&(i=h),c[t]!==i&&(e.bindFramebuffer(t,i),c[t]=i,n&&(36009===t&&(c[36160]=i),36160===t&&(c[36009]=i)),!0)},bindXRFramebuffer:function(t){t!==h&&(e.bindFramebuffer(36160,t),h=t)},useProgram:function(t){return l!==t&&(e.useProgram(t),l=t,!0)},setBlending:U,setMaterial:function(e,t){2===e.side?z(2884):O(2884);let i=1===e.side;t&&(i=!i),V(i),1===e.blending&&!1===e.transparent?U(0):U(e.blending,e.blendEquation,e.blendSrc,e.blendDst,e.blendEquationAlpha,e.blendSrcAlpha,e.blendDstAlpha,e.premultipliedAlpha),s.setFunc(e.depthFunc),s.setTest(e.depthTest),s.setMask(e.depthWrite),r.setMask(e.colorWrite);const n=e.stencilWrite;a.setTest(n),n&&(a.setMask(e.stencilWriteMask),a.setFunc(e.stencilFunc,e.stencilRef,e.stencilFuncMask),a.setOp(e.stencilFail,e.stencilZFail,e.stencilZPass)),j(e.polygonOffset,e.polygonOffsetFactor,e.polygonOffsetUnits),!0===e.alphaToCoverage?O(32926):z(32926)},setFlipSided:V,setCullFace:H,setLineWidth:function(t){t!==w&&(C&&e.lineWidth(t),w=t)},setPolygonOffset:j,setScissorTest:function(e){e?O(3089):z(3089)},activeTexture:G,bindTexture:function(t,i){null===I&&G();let n=R[I];void 0===n&&(n={type:void 0,texture:void 0},R[I]=n),n.type===t&&n.texture===i||(e.bindTexture(t,i||k[t]),n.type=t,n.texture=i)},unbindTexture:function(){const t=R[I];void 0!==t&&void 0!==t.type&&(e.bindTexture(t.type,null),t.type=void 0,t.texture=void 0)},compressedTexImage2D:function(){try{e.compressedTexImage2D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},texImage2D:function(){try{e.texImage2D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},texImage3D:function(){try{e.texImage3D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},scissor:function(t){!1===D.equals(t)&&(e.scissor(t.x,t.y,t.z,t.w),D.copy(t))},viewport:function(t){!1===N.equals(t)&&(e.viewport(t.x,t.y,t.z,t.w),N.copy(t))},reset:function(){e.disable(3042),e.disable(2884),e.disable(2929),e.disable(32823),e.disable(3089),e.disable(2960),e.disable(32926),e.blendEquation(32774),e.blendFunc(1,0),e.blendFuncSeparate(1,0,1,0),e.colorMask(!0,!0,!0,!0),e.clearColor(0,0,0,0),e.depthMask(!0),e.depthFunc(513),e.clearDepth(1),e.stencilMask(4294967295),e.stencilFunc(519,0,4294967295),e.stencilOp(7680,7680,7680),e.clearStencil(0),e.cullFace(1029),e.frontFace(2305),e.polygonOffset(0,0),e.activeTexture(33984),e.bindFramebuffer(36160,null),!0===n&&(e.bindFramebuffer(36009,null),e.bindFramebuffer(36008,null)),e.useProgram(null),e.lineWidth(1),e.scissor(0,0,e.canvas.width,e.canvas.height),e.viewport(0,0,e.canvas.width,e.canvas.height),o={},I=null,R={},h=null,c={},l=null,u=!1,d=null,p=null,m=null,f=null,g=null,_=null,v=null,y=!1,b=null,x=null,w=null,M=null,S=null,D.set(0,0,e.canvas.width,e.canvas.height),N.set(0,0,e.canvas.width,e.canvas.height),r.reset(),s.reset(),a.reset()}}}function eh(e,t,i,n,r,s,a){const o=r.isWebGL2,h=r.maxTextures,c=r.maxCubemapSize,l=r.maxTextureSize,u=r.maxSamples,d=new WeakMap;let p,m=!1;try{m="undefined"!=typeof OffscreenCanvas&&null!==new OffscreenCanvas(1,1).getContext("2d")}catch(e){}function f(e,t){return m?new OffscreenCanvas(e,t):Ui("canvas")}function g(e,t,i,n){let r=1;if((e.width>n||e.height>n)&&(r=n/Math.max(e.width,e.height)),r<1||!0===t){if("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap){const n=t?ki:Math.floor,s=n(r*e.width),a=n(r*e.height);void 0===p&&(p=f(s,a));const o=i?f(s,a):p;o.width=s,o.height=a;return o.getContext("2d").drawImage(e,0,0,s,a),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+e.width+"x"+e.height+") to ("+s+"x"+a+")."),o}return"data"in e&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+e.width+"x"+e.height+")."),e}return e}function _(e){return $i(e.width)&&$i(e.height)}function v(e,t){return e.generateMipmaps&&t&&e.minFilter!==Jt&&e.minFilter!==Kt}function y(t,i,r,s,a=1){e.generateMipmap(t);n.get(i).__maxMipLevel=Math.log2(Math.max(r,s,a))}function b(i,n,r,s){if(!1===o)return n;if(null!==i){if(void 0!==e[i])return e[i];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+i+"'")}let a=n;return 6403===n&&(5126===r&&(a=33326),5131===r&&(a=33325),5121===r&&(a=33321)),6407===n&&(5126===r&&(a=34837),5131===r&&(a=34843),5121===r&&(a=32849)),6408===n&&(5126===r&&(a=34836),5131===r&&(a=34842),5121===r&&(a=s===vi?35907:32856)),33325!==a&&33326!==a&&34842!==a&&34836!==a||t.get("EXT_color_buffer_float"),a}function x(e){return e===Jt||1004===e||1005===e?9728:9729}function w(t){const i=t.target;i.removeEventListener("dispose",w),function(t){const i=n.get(t);if(void 0===i.__webglInit)return;e.deleteTexture(i.__webglTexture),n.remove(t)}(i),i.isVideoTexture&&d.delete(i),a.memory.textures--}function M(t){const i=t.target;i.removeEventListener("dispose",M),function(t){const i=t.texture,r=n.get(t),s=n.get(i);if(!t)return;void 0!==s.__webglTexture&&(e.deleteTexture(s.__webglTexture),a.memory.textures--);t.depthTexture&&t.depthTexture.dispose();if(t.isWebGLCubeRenderTarget)for(let t=0;t<6;t++)e.deleteFramebuffer(r.__webglFramebuffer[t]),r.__webglDepthbuffer&&e.deleteRenderbuffer(r.__webglDepthbuffer[t]);else e.deleteFramebuffer(r.__webglFramebuffer),r.__webglDepthbuffer&&e.deleteRenderbuffer(r.__webglDepthbuffer),r.__webglMultisampledFramebuffer&&e.deleteFramebuffer(r.__webglMultisampledFramebuffer),r.__webglColorRenderbuffer&&e.deleteRenderbuffer(r.__webglColorRenderbuffer),r.__webglDepthRenderbuffer&&e.deleteRenderbuffer(r.__webglDepthRenderbuffer);if(t.isWebGLMultipleRenderTargets)for(let t=0,r=i.length;t<r;t++){const r=n.get(i[t]);r.__webglTexture&&(e.deleteTexture(r.__webglTexture),a.memory.textures--),n.remove(i[t])}n.remove(i),n.remove(t)}(i)}let S=0;function T(e,t){const r=n.get(e);if(e.isVideoTexture&&function(e){const t=a.render.frame;d.get(e)!==t&&(d.set(e,t),e.update())}(e),e.version>0&&r.__version!==e.version){const i=e.image;if(void 0===i)console.warn("THREE.WebGLRenderer: Texture marked for update but image is undefined");else{if(!1!==i.complete)return void P(r,e,t);console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete")}}i.activeTexture(33984+t),i.bindTexture(3553,r.__webglTexture)}function C(t,r){const a=n.get(t);t.version>0&&a.__version!==t.version?function(t,n,r){if(6!==n.image.length)return;R(t,n),i.activeTexture(33984+r),i.bindTexture(34067,t.__webglTexture),e.pixelStorei(37440,n.flipY),e.pixelStorei(37441,n.premultiplyAlpha),e.pixelStorei(3317,n.unpackAlignment),e.pixelStorei(37443,0);const a=n&&(n.isCompressedTexture||n.image[0].isCompressedTexture),h=n.image[0]&&n.image[0].isDataTexture,l=[];for(let e=0;e<6;e++)l[e]=a||h?h?n.image[e].image:n.image[e]:g(n.image[e],!1,!0,c);const u=l[0],d=_(u)||o,p=s.convert(n.format),m=s.convert(n.type),f=b(n.internalFormat,p,m,n.encoding);let x;if(I(34067,n,d),a){for(let e=0;e<6;e++){x=l[e].mipmaps;for(let t=0;t<x.length;t++){const r=x[t];n.format!==oi&&n.format!==ai?null!==p?i.compressedTexImage2D(34069+e,t,f,r.width,r.height,0,r.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):i.texImage2D(34069+e,t,f,r.width,r.height,0,p,m,r.data)}}t.__maxMipLevel=x.length-1}else{x=n.mipmaps;for(let e=0;e<6;e++)if(h){i.texImage2D(34069+e,0,f,l[e].width,l[e].height,0,p,m,l[e].data);for(let t=0;t<x.length;t++){const n=x[t].image[e].image;i.texImage2D(34069+e,t+1,f,n.width,n.height,0,p,m,n.data)}}else{i.texImage2D(34069+e,0,f,p,m,l[e]);for(let t=0;t<x.length;t++){const n=x[t];i.texImage2D(34069+e,t+1,f,p,m,n.image[e])}}t.__maxMipLevel=x.length}v(n,d)&&y(34067,n,u.width,u.height);t.__version=n.version,n.onUpdate&&n.onUpdate(n)}(a,t,r):(i.activeTexture(33984+r),i.bindTexture(34067,a.__webglTexture))}const E={[Xt]:10497,[Zt]:33071,[Yt]:33648},A={[Jt]:9728,1004:9984,1005:9986,[Kt]:9729,1007:9985,[Qt]:9987};function I(i,s,a){if(a?(e.texParameteri(i,10242,E[s.wrapS]),e.texParameteri(i,10243,E[s.wrapT]),32879!==i&&35866!==i||e.texParameteri(i,32882,E[s.wrapR]),e.texParameteri(i,10240,A[s.magFilter]),e.texParameteri(i,10241,A[s.minFilter])):(e.texParameteri(i,10242,33071),e.texParameteri(i,10243,33071),32879!==i&&35866!==i||e.texParameteri(i,32882,33071),s.wrapS===Zt&&s.wrapT===Zt||console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),e.texParameteri(i,10240,x(s.magFilter)),e.texParameteri(i,10241,x(s.minFilter)),s.minFilter!==Jt&&s.minFilter!==Kt&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),!0===t.has("EXT_texture_filter_anisotropic")){const a=t.get("EXT_texture_filter_anisotropic");if(s.type===ni&&!1===t.has("OES_texture_float_linear"))return;if(!1===o&&s.type===ri&&!1===t.has("OES_texture_half_float_linear"))return;(s.anisotropy>1||n.get(s).__currentAnisotropy)&&(e.texParameterf(i,a.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(s.anisotropy,r.getMaxAnisotropy())),n.get(s).__currentAnisotropy=s.anisotropy)}}function R(t,i){void 0===t.__webglInit&&(t.__webglInit=!0,i.addEventListener("dispose",w),t.__webglTexture=e.createTexture(),a.memory.textures++)}function P(t,n,r){let a=3553;n.isDataTexture2DArray&&(a=35866),n.isDataTexture3D&&(a=32879),R(t,n),i.activeTexture(33984+r),i.bindTexture(a,t.__webglTexture),e.pixelStorei(37440,n.flipY),e.pixelStorei(37441,n.premultiplyAlpha),e.pixelStorei(3317,n.unpackAlignment),e.pixelStorei(37443,0);const h=function(e){return!o&&(e.wrapS!==Zt||e.wrapT!==Zt||e.minFilter!==Jt&&e.minFilter!==Kt)}(n)&&!1===_(n.image),c=g(n.image,h,!1,l),u=_(c)||o,d=s.convert(n.format);let p,m=s.convert(n.type),f=b(n.internalFormat,d,m,n.encoding);I(a,n,u);const x=n.mipmaps;if(n.isDepthTexture)f=6402,o?f=n.type===ni?36012:n.type===ii?33190:n.type===si?35056:33189:n.type===ni&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),n.format===hi&&6402===f&&n.type!==ti&&n.type!==ii&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),n.type=ti,m=s.convert(n.type)),n.format===ci&&6402===f&&(f=34041,n.type!==si&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),n.type=si,m=s.convert(n.type))),i.texImage2D(3553,0,f,c.width,c.height,0,d,m,null);else if(n.isDataTexture)if(x.length>0&&u){for(let e=0,t=x.length;e<t;e++)p=x[e],i.texImage2D(3553,e,f,p.width,p.height,0,d,m,p.data);n.generateMipmaps=!1,t.__maxMipLevel=x.length-1}else i.texImage2D(3553,0,f,c.width,c.height,0,d,m,c.data),t.__maxMipLevel=0;else if(n.isCompressedTexture){for(let e=0,t=x.length;e<t;e++)p=x[e],n.format!==oi&&n.format!==ai?null!==d?i.compressedTexImage2D(3553,e,f,p.width,p.height,0,p.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):i.texImage2D(3553,e,f,p.width,p.height,0,d,m,p.data);t.__maxMipLevel=x.length-1}else if(n.isDataTexture2DArray)i.texImage3D(35866,0,f,c.width,c.height,c.depth,0,d,m,c.data),t.__maxMipLevel=0;else if(n.isDataTexture3D)i.texImage3D(32879,0,f,c.width,c.height,c.depth,0,d,m,c.data),t.__maxMipLevel=0;else if(x.length>0&&u){for(let e=0,t=x.length;e<t;e++)p=x[e],i.texImage2D(3553,e,f,d,m,p);n.generateMipmaps=!1,t.__maxMipLevel=x.length-1}else i.texImage2D(3553,0,f,d,m,c),t.__maxMipLevel=0;v(n,u)&&y(a,n,c.width,c.height),t.__version=n.version,n.onUpdate&&n.onUpdate(n)}function L(t,r,a,o,h){const c=s.convert(a.format),l=s.convert(a.type),u=b(a.internalFormat,c,l,a.encoding);32879===h||35866===h?i.texImage3D(h,0,u,r.width,r.height,r.depth,0,c,l,null):i.texImage2D(h,0,u,r.width,r.height,0,c,l,null),i.bindFramebuffer(36160,t),e.framebufferTexture2D(36160,o,h,n.get(a).__webglTexture,0),i.bindFramebuffer(36160,null)}function D(t,i,n){if(e.bindRenderbuffer(36161,t),i.depthBuffer&&!i.stencilBuffer){let r=33189;if(n){const t=i.depthTexture;t&&t.isDepthTexture&&(t.type===ni?r=36012:t.type===ii&&(r=33190));const n=$(i);e.renderbufferStorageMultisample(36161,n,r,i.width,i.height)}else e.renderbufferStorage(36161,r,i.width,i.height);e.framebufferRenderbuffer(36160,36096,36161,t)}else if(i.depthBuffer&&i.stencilBuffer){if(n){const t=$(i);e.renderbufferStorageMultisample(36161,t,35056,i.width,i.height)}else e.renderbufferStorage(36161,34041,i.width,i.height);e.framebufferRenderbuffer(36160,33306,36161,t)}else{const t=!0===i.isWebGLMultipleRenderTargets?i.texture[0]:i.texture,r=s.convert(t.format),a=s.convert(t.type),o=b(t.internalFormat,r,a,t.encoding);if(n){const t=$(i);e.renderbufferStorageMultisample(36161,t,o,i.width,i.height)}else e.renderbufferStorage(36161,o,i.width,i.height)}e.bindRenderbuffer(36161,null)}function N(t){const r=n.get(t),s=!0===t.isWebGLCubeRenderTarget;if(t.depthTexture){if(s)throw new Error("target.depthTexture not supported in Cube render targets");!function(t,r){if(r&&r.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(i.bindFramebuffer(36160,t),!r.depthTexture||!r.depthTexture.isDepthTexture)throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");n.get(r.depthTexture).__webglTexture&&r.depthTexture.image.width===r.width&&r.depthTexture.image.height===r.height||(r.depthTexture.image.width=r.width,r.depthTexture.image.height=r.height,r.depthTexture.needsUpdate=!0),T(r.depthTexture,0);const s=n.get(r.depthTexture).__webglTexture;if(r.depthTexture.format===hi)e.framebufferTexture2D(36160,36096,3553,s,0);else{if(r.depthTexture.format!==ci)throw new Error("Unknown depthTexture format");e.framebufferTexture2D(36160,33306,3553,s,0)}}(r.__webglFramebuffer,t)}else if(s){r.__webglDepthbuffer=[];for(let n=0;n<6;n++)i.bindFramebuffer(36160,r.__webglFramebuffer[n]),r.__webglDepthbuffer[n]=e.createRenderbuffer(),D(r.__webglDepthbuffer[n],t,!1)}else i.bindFramebuffer(36160,r.__webglFramebuffer),r.__webglDepthbuffer=e.createRenderbuffer(),D(r.__webglDepthbuffer,t,!1);i.bindFramebuffer(36160,null)}function $(e){return o&&e.isWebGLMultisampleRenderTarget?Math.min(u,e.samples):0}let k=!1,O=!1;this.allocateTextureUnit=function(){const e=S;return e>=h&&console.warn("THREE.WebGLTextures: Trying to use "+e+" texture units while this GPU supports only "+h),S+=1,e},this.resetTextureUnits=function(){S=0},this.setTexture2D=T,this.setTexture2DArray=function(e,t){const r=n.get(e);e.version>0&&r.__version!==e.version?P(r,e,t):(i.activeTexture(33984+t),i.bindTexture(35866,r.__webglTexture))},this.setTexture3D=function(e,t){const r=n.get(e);e.version>0&&r.__version!==e.version?P(r,e,t):(i.activeTexture(33984+t),i.bindTexture(32879,r.__webglTexture))},this.setTextureCube=C,this.setupRenderTarget=function(t){const h=t.texture,c=n.get(t),l=n.get(h);t.addEventListener("dispose",M),!0!==t.isWebGLMultipleRenderTargets&&(l.__webglTexture=e.createTexture(),l.__version=h.version,a.memory.textures++);const u=!0===t.isWebGLCubeRenderTarget,d=!0===t.isWebGLMultipleRenderTargets,p=!0===t.isWebGLMultisampleRenderTarget,m=h.isDataTexture3D||h.isDataTexture2DArray,f=_(t)||o;if(!o||h.format!==ai||h.type!==ni&&h.type!==ri||(h.format=oi,console.warn("THREE.WebGLRenderer: Rendering to textures with RGB format is not supported. Using RGBA format instead.")),u){c.__webglFramebuffer=[];for(let t=0;t<6;t++)c.__webglFramebuffer[t]=e.createFramebuffer()}else if(c.__webglFramebuffer=e.createFramebuffer(),d)if(r.drawBuffers){const i=t.texture;for(let t=0,r=i.length;t<r;t++){const r=n.get(i[t]);void 0===r.__webglTexture&&(r.__webglTexture=e.createTexture(),a.memory.textures++)}}else console.warn("THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.");else if(p)if(o){c.__webglMultisampledFramebuffer=e.createFramebuffer(),c.__webglColorRenderbuffer=e.createRenderbuffer(),e.bindRenderbuffer(36161,c.__webglColorRenderbuffer);const n=s.convert(h.format),r=s.convert(h.type),a=b(h.internalFormat,n,r,h.encoding),o=$(t);e.renderbufferStorageMultisample(36161,o,a,t.width,t.height),i.bindFramebuffer(36160,c.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(36160,36064,36161,c.__webglColorRenderbuffer),e.bindRenderbuffer(36161,null),t.depthBuffer&&(c.__webglDepthRenderbuffer=e.createRenderbuffer(),D(c.__webglDepthRenderbuffer,t,!0)),i.bindFramebuffer(36160,null)}else console.warn("THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2.");if(u){i.bindTexture(34067,l.__webglTexture),I(34067,h,f);for(let e=0;e<6;e++)L(c.__webglFramebuffer[e],t,h,36064,34069+e);v(h,f)&&y(34067,h,t.width,t.height),i.unbindTexture()}else if(d){const e=t.texture;for(let r=0,s=e.length;r<s;r++){const s=e[r],a=n.get(s);i.bindTexture(3553,a.__webglTexture),I(3553,s,f),L(c.__webglFramebuffer,t,s,36064+r,3553),v(s,f)&&y(3553,s,t.width,t.height)}i.unbindTexture()}else{let e=3553;if(m)if(o){e=h.isDataTexture3D?32879:35866}else console.warn("THREE.DataTexture3D and THREE.DataTexture2DArray only supported with WebGL2.");i.bindTexture(e,l.__webglTexture),I(e,h,f),L(c.__webglFramebuffer,t,h,36064,e),v(h,f)&&y(e,h,t.width,t.height,t.depth),i.unbindTexture()}t.depthBuffer&&N(t)},this.updateRenderTargetMipmap=function(e){const t=_(e)||o,r=!0===e.isWebGLMultipleRenderTargets?e.texture:[e.texture];for(let s=0,a=r.length;s<a;s++){const a=r[s];if(v(a,t)){const t=e.isWebGLCubeRenderTarget?34067:3553,r=n.get(a).__webglTexture;i.bindTexture(t,r),y(t,a,e.width,e.height),i.unbindTexture()}}},this.updateMultisampleRenderTarget=function(t){if(t.isWebGLMultisampleRenderTarget)if(o){const r=t.width,s=t.height;let a=16384;t.depthBuffer&&(a|=256),t.stencilBuffer&&(a|=1024);const o=n.get(t);i.bindFramebuffer(36008,o.__webglMultisampledFramebuffer),i.bindFramebuffer(36009,o.__webglFramebuffer),e.blitFramebuffer(0,0,r,s,0,0,r,s,a,9728),i.bindFramebuffer(36008,null),i.bindFramebuffer(36009,o.__webglMultisampledFramebuffer)}else console.warn("THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2.")},this.safeSetTexture2D=function(e,t){e&&e.isWebGLRenderTarget&&(!1===k&&(console.warn("THREE.WebGLTextures.safeSetTexture2D: don't use render targets as textures. Use their .texture property instead."),k=!0),e=e.texture),T(e,t)},this.safeSetTextureCube=function(e,t){e&&e.isWebGLCubeRenderTarget&&(!1===O&&(console.warn("THREE.WebGLTextures.safeSetTextureCube: don't use cube render targets as textures. Use their .texture property instead."),O=!0),e=e.texture),C(e,t)}}function th(e,t,i){const n=i.isWebGL2;return{convert:function(e){let i;if(e===ei)return 5121;if(1017===e)return 32819;if(1018===e)return 32820;if(1019===e)return 33635;if(1010===e)return 5120;if(1011===e)return 5122;if(e===ti)return 5123;if(1013===e)return 5124;if(e===ii)return 5125;if(e===ni)return 5126;if(e===ri)return n?5131:(i=t.get("OES_texture_half_float"),null!==i?i.HALF_FLOAT_OES:null);if(1021===e)return 6406;if(e===ai)return 6407;if(e===oi)return 6408;if(1024===e)return 6409;if(1025===e)return 6410;if(e===hi)return 6402;if(e===ci)return 34041;if(1028===e)return 6403;if(1029===e)return 36244;if(1030===e)return 33319;if(1031===e)return 33320;if(1032===e)return 36248;if(1033===e)return 36249;if(33776===e||33777===e||33778===e||33779===e){if(i=t.get("WEBGL_compressed_texture_s3tc"),null===i)return null;if(33776===e)return i.COMPRESSED_RGB_S3TC_DXT1_EXT;if(33777===e)return i.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(33778===e)return i.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(33779===e)return i.COMPRESSED_RGBA_S3TC_DXT5_EXT}if(35840===e||35841===e||35842===e||35843===e){if(i=t.get("WEBGL_compressed_texture_pvrtc"),null===i)return null;if(35840===e)return i.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(35841===e)return i.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(35842===e)return i.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(35843===e)return i.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(36196===e)return i=t.get("WEBGL_compressed_texture_etc1"),null!==i?i.COMPRESSED_RGB_ETC1_WEBGL:null;if((37492===e||37496===e)&&(i=t.get("WEBGL_compressed_texture_etc"),null!==i)){if(37492===e)return i.COMPRESSED_RGB8_ETC2;if(37496===e)return i.COMPRESSED_RGBA8_ETC2_EAC}return 37808===e||37809===e||37810===e||37811===e||37812===e||37813===e||37814===e||37815===e||37816===e||37817===e||37818===e||37819===e||37820===e||37821===e||37840===e||37841===e||37842===e||37843===e||37844===e||37845===e||37846===e||37847===e||37848===e||37849===e||37850===e||37851===e||37852===e||37853===e?(i=t.get("WEBGL_compressed_texture_astc"),null!==i?e:null):36492===e?(i=t.get("EXT_texture_compression_bptc"),null!==i?e:null):e===si?n?34042:(i=t.get("WEBGL_depth_texture"),null!==i?i.UNSIGNED_INT_24_8_WEBGL:null):void 0}}}class ih extends hs{constructor(e=[]){super(),this.cameras=e}}ih.prototype.isArrayCamera=!0;class nh extends tr{constructor(){super(),this.type="Group"}}nh.prototype.isGroup=!0;const rh={type:"move"};class sh{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return null===this._hand&&(this._hand=new nh,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return null===this._targetRay&&(this._targetRay=new nh,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new Ki,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new Ki),this._targetRay}getGripSpace(){return null===this._grip&&(this._grip=new nh,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new Ki,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new Ki),this._grip}dispatchEvent(e){return null!==this._targetRay&&this._targetRay.dispatchEvent(e),null!==this._grip&&this._grip.dispatchEvent(e),null!==this._hand&&this._hand.dispatchEvent(e),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),null!==this._targetRay&&(this._targetRay.visible=!1),null!==this._grip&&(this._grip.visible=!1),null!==this._hand&&(this._hand.visible=!1),this}update(e,t,i){let n=null,r=null,s=null;const a=this._targetRay,o=this._grip,h=this._hand;if(e&&"visible-blurred"!==t.session.visibilityState)if(null!==a&&(n=t.getPose(e.targetRaySpace,i),null!==n&&(a.matrix.fromArray(n.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),n.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(n.linearVelocity)):a.hasLinearVelocity=!1,n.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(n.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(rh))),h&&e.hand){s=!0;for(const n of e.hand.values()){const e=t.getJointPose(n,i);if(void 0===h.joints[n.jointName]){const e=new nh;e.matrixAutoUpdate=!1,e.visible=!1,h.joints[n.jointName]=e,h.add(e)}const r=h.joints[n.jointName];null!==e&&(r.matrix.fromArray(e.transform.matrix),r.matrix.decompose(r.position,r.rotation,r.scale),r.jointRadius=e.radius),r.visible=null!==e}const n=h.joints["index-finger-tip"],r=h.joints["thumb-tip"],a=n.position.distanceTo(r.position),o=.02,c=.005;h.inputState.pinching&&a>o+c?(h.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!h.inputState.pinching&&a<=o-c&&(h.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else null!==o&&e.gripSpace&&(r=t.getPose(e.gripSpace,i),null!==r&&(o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),r.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(r.linearVelocity)):o.hasLinearVelocity=!1,r.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(r.angularVelocity)):o.hasAngularVelocity=!1));return null!==a&&(a.visible=null!==n),null!==o&&(o.visible=null!==r),null!==h&&(h.visible=null!==s),this}}class ah extends Ti{constructor(e,t){super();const i=this,n=e.state;let r=null,s=1,a=null,o="local-floor",h=null,c=null,l=null,u=null,d=null,p=!1,m=null,f=null,g=null,_=null,v=null,y=null;const b=[],x=new Map,w=new hs;w.layers.enable(1),w.viewport=new Xi;const M=new hs;M.layers.enable(2),M.viewport=new Xi;const S=[w,M],T=new ih;T.layers.enable(1),T.layers.enable(2);let C=null,E=null;function A(e){const t=x.get(e.inputSource);t&&t.dispatchEvent({type:e.type,data:e.inputSource})}function I(){x.forEach((function(e,t){e.disconnect(t)})),x.clear(),C=null,E=null,n.bindXRFramebuffer(null),e.setRenderTarget(e.getRenderTarget()),l&&t.deleteFramebuffer(l),m&&t.deleteFramebuffer(m),f&&t.deleteRenderbuffer(f),g&&t.deleteRenderbuffer(g),l=null,m=null,f=null,g=null,d=null,u=null,c=null,r=null,$.stop(),i.isPresenting=!1,i.dispatchEvent({type:"sessionend"})}function R(e){const t=r.inputSources;for(let e=0;e<b.length;e++)x.set(t[e],b[e]);for(let t=0;t<e.removed.length;t++){const i=e.removed[t],n=x.get(i);n&&(n.dispatchEvent({type:"disconnected",data:i}),x.delete(i))}for(let t=0;t<e.added.length;t++){const i=e.added[t],n=x.get(i);n&&n.dispatchEvent({type:"connected",data:i})}}this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(e){let t=b[e];return void 0===t&&(t=new sh,b[e]=t),t.getTargetRaySpace()},this.getControllerGrip=function(e){let t=b[e];return void 0===t&&(t=new sh,b[e]=t),t.getGripSpace()},this.getHand=function(e){let t=b[e];return void 0===t&&(t=new sh,b[e]=t),t.getHandSpace()},this.setFramebufferScaleFactor=function(e){s=e,!0===i.isPresenting&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(e){o=e,!0===i.isPresenting&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return a},this.getBaseLayer=function(){return null!==u?u:d},this.getBinding=function(){return c},this.getFrame=function(){return _},this.getSession=function(){return r},this.setSession=async function(e){if(r=e,null!==r){r.addEventListener("select",A),r.addEventListener("selectstart",A),r.addEventListener("selectend",A),r.addEventListener("squeeze",A),r.addEventListener("squeezestart",A),r.addEventListener("squeezeend",A),r.addEventListener("end",I),r.addEventListener("inputsourceschange",R);const e=t.getContextAttributes();if(!0!==e.xrCompatible&&await t.makeXRCompatible(),void 0===r.renderState.layers){const i={antialias:e.antialias,alpha:e.alpha,depth:e.depth,stencil:e.stencil,framebufferScaleFactor:s};d=new XRWebGLLayer(r,t,i),r.updateRenderState({baseLayer:d})}else if(t instanceof WebGLRenderingContext){const i={antialias:!0,alpha:e.alpha,depth:e.depth,stencil:e.stencil,framebufferScaleFactor:s};d=new XRWebGLLayer(r,t,i),r.updateRenderState({layers:[d]})}else{p=e.antialias;let i=null;e.depth&&(y=256,e.stencil&&(y|=1024),v=e.stencil?33306:36096,i=e.stencil?35056:33190);const a={colorFormat:e.alpha?32856:32849,depthFormat:i,scaleFactor:s};c=new XRWebGLBinding(r,t),u=c.createProjectionLayer(a),l=t.createFramebuffer(),r.updateRenderState({layers:[u]}),p&&(m=t.createFramebuffer(),f=t.createRenderbuffer(),t.bindRenderbuffer(36161,f),t.renderbufferStorageMultisample(36161,4,32856,u.textureWidth,u.textureHeight),n.bindFramebuffer(36160,m),t.framebufferRenderbuffer(36160,36064,36161,f),t.bindRenderbuffer(36161,null),null!==i&&(g=t.createRenderbuffer(),t.bindRenderbuffer(36161,g),t.renderbufferStorageMultisample(36161,4,i,u.textureWidth,u.textureHeight),t.framebufferRenderbuffer(36160,v,36161,g),t.bindRenderbuffer(36161,null)),n.bindFramebuffer(36160,null))}a=await r.requestReferenceSpace(o),$.setContext(r),$.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}};const P=new Ki,L=new Ki;function D(e,t){null===t?e.matrixWorld.copy(e.matrix):e.matrixWorld.multiplyMatrices(t.matrixWorld,e.matrix),e.matrixWorldInverse.copy(e.matrixWorld).invert()}this.updateCamera=function(e){if(null===r)return;T.near=M.near=w.near=e.near,T.far=M.far=w.far=e.far,C===T.near&&E===T.far||(r.updateRenderState({depthNear:T.near,depthFar:T.far}),C=T.near,E=T.far);const t=e.parent,i=T.cameras;D(T,t);for(let e=0;e<i.length;e++)D(i[e],t);T.matrixWorld.decompose(T.position,T.quaternion,T.scale),e.position.copy(T.position),e.quaternion.copy(T.quaternion),e.scale.copy(T.scale),e.matrix.copy(T.matrix),e.matrixWorld.copy(T.matrixWorld);const n=e.children;for(let e=0,t=n.length;e<t;e++)n[e].updateMatrixWorld(!0);2===i.length?function(e,t,i){P.setFromMatrixPosition(t.matrixWorld),L.setFromMatrixPosition(i.matrixWorld);const n=P.distanceTo(L),r=t.projectionMatrix.elements,s=i.projectionMatrix.elements,a=r[14]/(r[10]-1),o=r[14]/(r[10]+1),h=(r[9]+1)/r[5],c=(r[9]-1)/r[5],l=(r[8]-1)/r[0],u=(s[8]+1)/s[0],d=a*l,p=a*u,m=n/(-l+u),f=m*-l;t.matrixWorld.decompose(e.position,e.quaternion,e.scale),e.translateX(f),e.translateZ(m),e.matrixWorld.compose(e.position,e.quaternion,e.scale),e.matrixWorldInverse.copy(e.matrixWorld).invert();const g=a+m,_=o+m,v=d-f,y=p+(n-f),b=h*o/_*g,x=c*o/_*g;e.projectionMatrix.makePerspective(v,y,b,x,g,_)}(T,w,M):T.projectionMatrix.copy(w.projectionMatrix)},this.getCamera=function(){return T},this.getFoveation=function(){return null!==u?u.fixedFoveation:null!==d?d.fixedFoveation:void 0},this.setFoveation=function(e){null!==u&&(u.fixedFoveation=e),null!==d&&void 0!==d.fixedFoveation&&(d.fixedFoveation=e)};let N=null;const $=new bs;$.setAnimationLoop((function(e,i){if(h=i.getViewerPose(a),_=i,null!==h){const e=h.views;null!==d&&n.bindXRFramebuffer(d.framebuffer);let i=!1;e.length!==T.cameras.length&&(T.cameras.length=0,i=!0);for(let r=0;r<e.length;r++){const s=e[r];let a=null;if(null!==d)a=d.getViewport(s);else{const e=c.getViewSubImage(u,s);n.bindXRFramebuffer(l),void 0!==e.depthStencilTexture&&t.framebufferTexture2D(36160,v,3553,e.depthStencilTexture,0),t.framebufferTexture2D(36160,36064,3553,e.colorTexture,0),a=e.viewport}const o=S[r];o.matrix.fromArray(s.transform.matrix),o.projectionMatrix.fromArray(s.projectionMatrix),o.viewport.set(a.x,a.y,a.width,a.height),0===r&&T.matrix.copy(o.matrix),!0===i&&T.cameras.push(o)}p&&(n.bindXRFramebuffer(m),null!==y&&t.clear(y))}const s=r.inputSources;for(let e=0;e<b.length;e++){const t=b[e],n=s[e];t.update(n,i,a)}if(N&&N(e,i),p){const e=u.textureWidth,i=u.textureHeight;n.bindFramebuffer(36008,m),n.bindFramebuffer(36009,l),t.invalidateFramebuffer(36008,[v]),t.invalidateFramebuffer(36009,[v]),t.blitFramebuffer(0,0,e,i,0,0,e,i,16384,9728),t.invalidateFramebuffer(36008,[36064]),n.bindFramebuffer(36008,null),n.bindFramebuffer(36009,null),n.bindFramebuffer(36160,m)}_=null})),this.setAnimationLoop=function(e){N=e},this.dispose=function(){}}}function oh(e){function t(t,i){t.opacity.value=i.opacity,i.color&&t.diffuse.value.copy(i.color),i.emissive&&t.emissive.value.copy(i.emissive).multiplyScalar(i.emissiveIntensity),i.map&&(t.map.value=i.map),i.alphaMap&&(t.alphaMap.value=i.alphaMap),i.specularMap&&(t.specularMap.value=i.specularMap),i.alphaTest>0&&(t.alphaTest.value=i.alphaTest);const n=e.get(i).envMap;if(n){t.envMap.value=n,t.flipEnvMap.value=n.isCubeTexture&&!1===n.isRenderTargetTexture?-1:1,t.reflectivity.value=i.reflectivity,t.ior.value=i.ior,t.refractionRatio.value=i.refractionRatio;const r=e.get(n).__maxMipLevel;void 0!==r&&(t.maxMipLevel.value=r)}let r,s;i.lightMap&&(t.lightMap.value=i.lightMap,t.lightMapIntensity.value=i.lightMapIntensity),i.aoMap&&(t.aoMap.value=i.aoMap,t.aoMapIntensity.value=i.aoMapIntensity),i.map?r=i.map:i.specularMap?r=i.specularMap:i.displacementMap?r=i.displacementMap:i.normalMap?r=i.normalMap:i.bumpMap?r=i.bumpMap:i.roughnessMap?r=i.roughnessMap:i.metalnessMap?r=i.metalnessMap:i.alphaMap?r=i.alphaMap:i.emissiveMap?r=i.emissiveMap:i.clearcoatMap?r=i.clearcoatMap:i.clearcoatNormalMap?r=i.clearcoatNormalMap:i.clearcoatRoughnessMap?r=i.clearcoatRoughnessMap:i.specularIntensityMap?r=i.specularIntensityMap:i.specularColorMap?r=i.specularColorMap:i.transmissionMap?r=i.transmissionMap:i.thicknessMap?r=i.thicknessMap:i.sheenColorMap?r=i.sheenColorMap:i.sheenRoughnessMap&&(r=i.sheenRoughnessMap),void 0!==r&&(r.isWebGLRenderTarget&&(r=r.texture),!0===r.matrixAutoUpdate&&r.updateMatrix(),t.uvTransform.value.copy(r.matrix)),i.aoMap?s=i.aoMap:i.lightMap&&(s=i.lightMap),void 0!==s&&(s.isWebGLRenderTarget&&(s=s.texture),!0===s.matrixAutoUpdate&&s.updateMatrix(),t.uv2Transform.value.copy(s.matrix))}function i(t,i){t.roughness.value=i.roughness,t.metalness.value=i.metalness,i.roughnessMap&&(t.roughnessMap.value=i.roughnessMap),i.metalnessMap&&(t.metalnessMap.value=i.metalnessMap),i.emissiveMap&&(t.emissiveMap.value=i.emissiveMap),i.bumpMap&&(t.bumpMap.value=i.bumpMap,t.bumpScale.value=i.bumpScale,1===i.side&&(t.bumpScale.value*=-1)),i.normalMap&&(t.normalMap.value=i.normalMap,t.normalScale.value.copy(i.normalScale),1===i.side&&t.normalScale.value.negate()),i.displacementMap&&(t.displacementMap.value=i.displacementMap,t.displacementScale.value=i.displacementScale,t.displacementBias.value=i.displacementBias);e.get(i).envMap&&(t.envMapIntensity.value=i.envMapIntensity)}return{refreshFogUniforms:function(e,t){e.fogColor.value.copy(t.color),t.isFog?(e.fogNear.value=t.near,e.fogFar.value=t.far):t.isFogExp2&&(e.fogDensity.value=t.density)},refreshMaterialUniforms:function(e,n,r,s,a){n.isMeshBasicMaterial?t(e,n):n.isMeshLambertMaterial?(t(e,n),function(e,t){t.emissiveMap&&(e.emissiveMap.value=t.emissiveMap)}(e,n)):n.isMeshToonMaterial?(t(e,n),function(e,t){t.gradientMap&&(e.gradientMap.value=t.gradientMap);t.emissiveMap&&(e.emissiveMap.value=t.emissiveMap);t.bumpMap&&(e.bumpMap.value=t.bumpMap,e.bumpScale.value=t.bumpScale,1===t.side&&(e.bumpScale.value*=-1));t.normalMap&&(e.normalMap.value=t.normalMap,e.normalScale.value.copy(t.normalScale),1===t.side&&e.normalScale.value.negate());t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias)}(e,n)):n.isMeshPhongMaterial?(t(e,n),function(e,t){e.specular.value.copy(t.specular),e.shininess.value=Math.max(t.shininess,1e-4),t.emissiveMap&&(e.emissiveMap.value=t.emissiveMap);t.bumpMap&&(e.bumpMap.value=t.bumpMap,e.bumpScale.value=t.bumpScale,1===t.side&&(e.bumpScale.value*=-1));t.normalMap&&(e.normalMap.value=t.normalMap,e.normalScale.value.copy(t.normalScale),1===t.side&&e.normalScale.value.negate());t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias)}(e,n)):n.isMeshStandardMaterial?(t(e,n),n.isMeshPhysicalMaterial?function(e,t,n){i(e,t),e.ior.value=t.ior,t.sheen>0&&(e.sheenColor.value.copy(t.sheenColor).multiplyScalar(t.sheen),e.sheenRoughness.value=t.sheenRoughness,t.sheenColorMap&&(e.sheenColorMap.value=t.sheenColorMap),t.sheenRoughnessMap&&(e.sheenRoughnessMap.value=t.sheenRoughnessMap));t.clearcoat>0&&(e.clearcoat.value=t.clearcoat,e.clearcoatRoughness.value=t.clearcoatRoughness,t.clearcoatMap&&(e.clearcoatMap.value=t.clearcoatMap),t.clearcoatRoughnessMap&&(e.clearcoatRoughnessMap.value=t.clearcoatRoughnessMap),t.clearcoatNormalMap&&(e.clearcoatNormalScale.value.copy(t.clearcoatNormalScale),e.clearcoatNormalMap.value=t.clearcoatNormalMap,1===t.side&&e.clearcoatNormalScale.value.negate()));t.transmission>0&&(e.transmission.value=t.transmission,e.transmissionSamplerMap.value=n.texture,e.transmissionSamplerSize.value.set(n.width,n.height),t.transmissionMap&&(e.transmissionMap.value=t.transmissionMap),e.thickness.value=t.thickness,t.thicknessMap&&(e.thicknessMap.value=t.thicknessMap),e.attenuationDistance.value=t.attenuationDistance,e.attenuationColor.value.copy(t.attenuationColor));e.specularIntensity.value=t.specularIntensity,e.specularColor.value.copy(t.specularColor),t.specularIntensityMap&&(e.specularIntensityMap.value=t.specularIntensityMap);t.specularColorMap&&(e.specularColorMap.value=t.specularColorMap)}(e,n,a):i(e,n)):n.isMeshMatcapMaterial?(t(e,n),function(e,t){t.matcap&&(e.matcap.value=t.matcap);t.bumpMap&&(e.bumpMap.value=t.bumpMap,e.bumpScale.value=t.bumpScale,1===t.side&&(e.bumpScale.value*=-1));t.normalMap&&(e.normalMap.value=t.normalMap,e.normalScale.value.copy(t.normalScale),1===t.side&&e.normalScale.value.negate());t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias)}(e,n)):n.isMeshDepthMaterial?(t(e,n),function(e,t){t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias)}(e,n)):n.isMeshDistanceMaterial?(t(e,n),function(e,t){t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias);e.referencePosition.value.copy(t.referencePosition),e.nearDistance.value=t.nearDistance,e.farDistance.value=t.farDistance}(e,n)):n.isMeshNormalMaterial?(t(e,n),function(e,t){t.bumpMap&&(e.bumpMap.value=t.bumpMap,e.bumpScale.value=t.bumpScale,1===t.side&&(e.bumpScale.value*=-1));t.normalMap&&(e.normalMap.value=t.normalMap,e.normalScale.value.copy(t.normalScale),1===t.side&&e.normalScale.value.negate());t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias)}(e,n)):n.isLineBasicMaterial?(function(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity}(e,n),n.isLineDashedMaterial&&function(e,t){e.dashSize.value=t.dashSize,e.totalSize.value=t.dashSize+t.gapSize,e.scale.value=t.scale}(e,n)):n.isPointsMaterial?function(e,t,i,n){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.size.value=t.size*i,e.scale.value=.5*n,t.map&&(e.map.value=t.map);t.alphaMap&&(e.alphaMap.value=t.alphaMap);t.alphaTest>0&&(e.alphaTest.value=t.alphaTest);let r;t.map?r=t.map:t.alphaMap&&(r=t.alphaMap);void 0!==r&&(!0===r.matrixAutoUpdate&&r.updateMatrix(),e.uvTransform.value.copy(r.matrix))}(e,n,r,s):n.isSpriteMaterial?function(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.rotation.value=t.rotation,t.map&&(e.map.value=t.map);t.alphaMap&&(e.alphaMap.value=t.alphaMap);t.alphaTest>0&&(e.alphaTest.value=t.alphaTest);let i;t.map?i=t.map:t.alphaMap&&(i=t.alphaMap);void 0!==i&&(!0===i.matrixAutoUpdate&&i.updateMatrix(),e.uvTransform.value.copy(i.matrix))}(e,n):n.isShadowMaterial?(e.color.value.copy(n.color),e.opacity.value=n.opacity):n.isShaderMaterial&&(n.uniformsNeedUpdate=!1)}}}function hh(e={}){const t=void 0!==e.canvas?e.canvas:function(){const e=Ui("canvas");return e.style.display="block",e}(),i=void 0!==e.context?e.context:null,n=void 0!==e.alpha&&e.alpha,r=void 0===e.depth||e.depth,s=void 0===e.stencil||e.stencil,a=void 0!==e.antialias&&e.antialias,o=void 0===e.premultipliedAlpha||e.premultipliedAlpha,h=void 0!==e.preserveDrawingBuffer&&e.preserveDrawingBuffer,c=void 0!==e.powerPreference?e.powerPreference:"default",l=void 0!==e.failIfMajorPerformanceCaveat&&e.failIfMajorPerformanceCaveat;let u=null,d=null;const p=[],m=[];this.domElement=t,this.debug={checkShaderErrors:!0},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.gammaFactor=2,this.outputEncoding=_i,this.physicallyCorrectLights=!1,this.toneMapping=0,this.toneMappingExposure=1;const f=this;let g=!1,_=0,v=0,y=null,b=-1,x=null;const w=new Xi,M=new Xi;let S=null,T=t.width,C=t.height,E=1,A=null,I=null;const R=new Xi(0,0,T,C),P=new Xi(0,0,T,C);let L=!1;const D=[],N=new ys;let $=!1,k=!1,O=null;const z=new Rn,F=new Ki,B={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function U(){return null===y?E:1}let V,H,j,G,W,q,X,Z,Y,J,K,Q,ee,te,ie,ne,re,se,ae,oe,he,ce,le,ue=i;function de(e,i){for(let n=0;n<e.length;n++){const r=e[n],s=t.getContext(r,i);if(null!==s)return s}return null}try{const e={alpha:n,depth:r,stencil:s,antialias:a,premultipliedAlpha:o,preserveDrawingBuffer:h,powerPreference:c,failIfMajorPerformanceCaveat:l};if(t.addEventListener("webglcontextlost",fe,!1),t.addEventListener("webglcontextrestored",ge,!1),null===ue){const t=["webgl2","webgl","experimental-webgl"];if(!0===f.isWebGL1Renderer&&t.shift(),ue=de(t,e),null===ue)throw de(t)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}void 0===ue.getShaderPrecisionFormat&&(ue.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(e){throw console.error("THREE.WebGLRenderer: "+e.message),e}function pe(){V=new ra(ue),H=new Is(ue,V,e),V.init(H),ce=new th(ue,V,H),j=new Qo(ue,V,H),D[0]=1029,G=new oa(ue),W=new Fo,q=new eh(ue,V,j,W,H,ce,G),X=new Ps(f),Z=new na(f),Y=new xs(ue,H),le=new Es(ue,V,Y,H),J=new sa(ue,Y,G,le),K=new pa(ue,J,Y,G),ae=new da(ue,H,q),ne=new Rs(W),Q=new zo(f,X,Z,V,H,le,ne),ee=new oh(W),te=new Ho(W),ie=new Zo(V,H),se=new Cs(f,X,j,K,o),re=new Ko(f,K,H),oe=new As(ue,V,G,H),he=new aa(ue,V,G,H),G.programs=Q.programs,f.capabilities=H,f.extensions=V,f.properties=W,f.renderLists=te,f.shadowMap=re,f.state=j,f.info=G}pe();const me=new ah(f,ue);function fe(e){e.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),g=!0}function ge(){console.log("THREE.WebGLRenderer: Context Restored."),g=!1;const e=G.autoReset,t=re.enabled,i=re.autoUpdate,n=re.needsUpdate,r=re.type;pe(),G.autoReset=e,re.enabled=t,re.autoUpdate=i,re.needsUpdate=n,re.type=r}function _e(e){const t=e.target;t.removeEventListener("dispose",_e),function(e){(function(e){const t=W.get(e).programs;void 0!==t&&t.forEach((function(e){Q.releaseProgram(e)}))})(e),W.remove(e)}(t)}this.xr=me,this.getContext=function(){return ue},this.getContextAttributes=function(){return ue.getContextAttributes()},this.forceContextLoss=function(){const e=V.get("WEBGL_lose_context");e&&e.loseContext()},this.forceContextRestore=function(){const e=V.get("WEBGL_lose_context");e&&e.restoreContext()},this.getPixelRatio=function(){return E},this.setPixelRatio=function(e){void 0!==e&&(E=e,this.setSize(T,C,!1))},this.getSize=function(e){return e.set(T,C)},this.setSize=function(e,i,n){me.isPresenting?console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting."):(T=e,C=i,t.width=Math.floor(e*E),t.height=Math.floor(i*E),!1!==n&&(t.style.width=e+"px",t.style.height=i+"px"),this.setViewport(0,0,e,i))},this.getDrawingBufferSize=function(e){return e.set(T*E,C*E).floor()},this.setDrawingBufferSize=function(e,i,n){T=e,C=i,E=n,t.width=Math.floor(e*n),t.height=Math.floor(i*n),this.setViewport(0,0,e,i)},this.getCurrentViewport=function(e){return e.copy(w)},this.getViewport=function(e){return e.copy(R)},this.setViewport=function(e,t,i,n){e.isVector4?R.set(e.x,e.y,e.z,e.w):R.set(e,t,i,n),j.viewport(w.copy(R).multiplyScalar(E).floor())},this.getScissor=function(e){return e.copy(P)},this.setScissor=function(e,t,i,n){e.isVector4?P.set(e.x,e.y,e.z,e.w):P.set(e,t,i,n),j.scissor(M.copy(P).multiplyScalar(E).floor())},this.getScissorTest=function(){return L},this.setScissorTest=function(e){j.setScissorTest(L=e)},this.setOpaqueSort=function(e){A=e},this.setTransparentSort=function(e){I=e},this.getClearColor=function(e){return e.copy(se.getClearColor())},this.setClearColor=function(){se.setClearColor.apply(se,arguments)},this.getClearAlpha=function(){return se.getClearAlpha()},this.setClearAlpha=function(){se.setClearAlpha.apply(se,arguments)},this.clear=function(e,t,i){let n=0;(void 0===e||e)&&(n|=16384),(void 0===t||t)&&(n|=256),(void 0===i||i)&&(n|=1024),ue.clear(n)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){t.removeEventListener("webglcontextlost",fe,!1),t.removeEventListener("webglcontextrestored",ge,!1),te.dispose(),ie.dispose(),W.dispose(),X.dispose(),Z.dispose(),K.dispose(),le.dispose(),me.dispose(),me.removeEventListener("sessionstart",ye),me.removeEventListener("sessionend",be),O&&(O.dispose(),O=null),xe.stop()},this.renderBufferDirect=function(e,t,i,n,r,s){null===t&&(t=B);const a=r.isMesh&&r.matrixWorld.determinant()<0,o=function(e,t,i,n,r){!0!==t.isScene&&(t=B);q.resetTextureUnits();const s=t.fog,a=n.isMeshStandardMaterial?t.environment:null,o=null===y?f.outputEncoding:y.texture.encoding,h=(n.isMeshStandardMaterial?Z:X).get(n.envMap||a),c=!0===n.vertexColors&&!!i.attributes.color&&4===i.attributes.color.itemSize,l=!!n.normalMap&&!!i.attributes.tangent,u=!!i.morphAttributes.position,p=!!i.morphAttributes.normal,m=i.morphAttributes.position?i.morphAttributes.position.length:0,g=W.get(n),_=d.state.lights;if(!0===$&&(!0===k||e!==x)){const t=e===x&&n.id===b;ne.setState(n,e,t)}let v=!1;n.version===g.__version?g.needsLights&&g.lightsStateVersion!==_.state.version||g.outputEncoding!==o||r.isInstancedMesh&&!1===g.instancing?v=!0:r.isInstancedMesh||!0!==g.instancing?r.isSkinnedMesh&&!1===g.skinning?v=!0:r.isSkinnedMesh||!0!==g.skinning?g.envMap!==h||n.fog&&g.fog!==s?v=!0:void 0===g.numClippingPlanes||g.numClippingPlanes===ne.numPlanes&&g.numIntersection===ne.numIntersection?(g.vertexAlphas!==c||g.vertexTangents!==l||g.morphTargets!==u||g.morphNormals!==p||!0===H.isWebGL2&&g.morphTargetsCount!==m)&&(v=!0):v=!0:v=!0:v=!0:(v=!0,g.__version=n.version);let w=g.currentProgram;!0===v&&(w=Ce(n,t,r));let M=!1,S=!1,T=!1;const A=w.getUniforms(),I=g.uniforms;j.useProgram(w.program)&&(M=!0,S=!0,T=!0);n.id!==b&&(b=n.id,S=!0);if(M||x!==e){if(A.setValue(ue,"projectionMatrix",e.projectionMatrix),H.logarithmicDepthBuffer&&A.setValue(ue,"logDepthBufFC",2/(Math.log(e.far+1)/Math.LN2)),x!==e&&(x=e,S=!0,T=!0),n.isShaderMaterial||n.isMeshPhongMaterial||n.isMeshToonMaterial||n.isMeshStandardMaterial||n.envMap){const t=A.map.cameraPosition;void 0!==t&&t.setValue(ue,F.setFromMatrixPosition(e.matrixWorld))}(n.isMeshPhongMaterial||n.isMeshToonMaterial||n.isMeshLambertMaterial||n.isMeshBasicMaterial||n.isMeshStandardMaterial||n.isShaderMaterial)&&A.setValue(ue,"isOrthographic",!0===e.isOrthographicCamera),(n.isMeshPhongMaterial||n.isMeshToonMaterial||n.isMeshLambertMaterial||n.isMeshBasicMaterial||n.isMeshStandardMaterial||n.isShaderMaterial||n.isShadowMaterial||r.isSkinnedMesh)&&A.setValue(ue,"viewMatrix",e.matrixWorldInverse)}if(r.isSkinnedMesh){A.setOptional(ue,r,"bindMatrix"),A.setOptional(ue,r,"bindMatrixInverse");const e=r.skeleton;e&&(H.floatVertexTextures?(null===e.boneTexture&&e.computeBoneTexture(),A.setValue(ue,"boneTexture",e.boneTexture,q),A.setValue(ue,"boneTextureSize",e.boneTextureSize)):A.setOptional(ue,e,"boneMatrices"))}!i||void 0===i.morphAttributes.position&&void 0===i.morphAttributes.normal||ae.update(r,i,n,w);(S||g.receiveShadow!==r.receiveShadow)&&(g.receiveShadow=r.receiveShadow,A.setValue(ue,"receiveShadow",r.receiveShadow));S&&(A.setValue(ue,"toneMappingExposure",f.toneMappingExposure),g.needsLights&&(P=T,(R=I).ambientLightColor.needsUpdate=P,R.lightProbe.needsUpdate=P,R.directionalLights.needsUpdate=P,R.directionalLightShadows.needsUpdate=P,R.pointLights.needsUpdate=P,R.pointLightShadows.needsUpdate=P,R.spotLights.needsUpdate=P,R.spotLightShadows.needsUpdate=P,R.rectAreaLights.needsUpdate=P,R.hemisphereLights.needsUpdate=P),s&&n.fog&&ee.refreshFogUniforms(I,s),ee.refreshMaterialUniforms(I,n,E,C,O),_o.upload(ue,g.uniformsList,I,q));var R,P;n.isShaderMaterial&&!0===n.uniformsNeedUpdate&&(_o.upload(ue,g.uniformsList,I,q),n.uniformsNeedUpdate=!1);n.isSpriteMaterial&&A.setValue(ue,"center",r.center);return A.setValue(ue,"modelViewMatrix",r.modelViewMatrix),A.setValue(ue,"normalMatrix",r.normalMatrix),A.setValue(ue,"modelMatrix",r.matrixWorld),w}(e,t,i,n,r);j.setMaterial(n,a);let h=i.index;const c=i.attributes.position;if(null===h){if(void 0===c||0===c.count)return}else if(0===h.count)return;let l,u=1;!0===n.wireframe&&(h=J.getWireframeAttribute(i),u=2),le.setup(r,n,o,i,h);let p=oe;null!==h&&(l=Y.get(h),p=he,p.setIndex(l));const m=null!==h?h.count:c.count,g=i.drawRange.start*u,_=i.drawRange.count*u,v=null!==s?s.start*u:0,w=null!==s?s.count*u:1/0,M=Math.max(g,v),S=Math.min(m,g+_,v+w)-1,T=Math.max(0,S-M+1);if(0!==T){if(r.isMesh)!0===n.wireframe?(j.setLineWidth(n.wireframeLinewidth*U()),p.setMode(1)):p.setMode(4);else if(r.isLine){let e=n.linewidth;void 0===e&&(e=1),j.setLineWidth(e*U()),r.isLineSegments?p.setMode(1):r.isLineLoop?p.setMode(2):p.setMode(3)}else r.isPoints?p.setMode(0):r.isSprite&&p.setMode(4);if(r.isInstancedMesh)p.renderInstances(M,T,r.count);else if(i.isInstancedBufferGeometry){const e=Math.min(i.instanceCount,i._maxInstanceCount);p.renderInstances(M,T,e)}else p.render(M,T)}},this.compile=function(e,t){d=ie.get(e),d.init(),m.push(d),e.traverseVisible((function(e){e.isLight&&e.layers.test(t.layers)&&(d.pushLight(e),e.castShadow&&d.pushShadow(e))})),d.setupLights(f.physicallyCorrectLights),e.traverse((function(t){const i=t.material;if(i)if(Array.isArray(i))for(let n=0;n<i.length;n++){Ce(i[n],e,t)}else Ce(i,e,t)})),m.pop(),d=null};let ve=null;function ye(){xe.stop()}function be(){xe.start()}const xe=new bs;function we(e,t,i,n){if(!1===e.visible)return;if(e.layers.test(t.layers))if(e.isGroup)i=e.renderOrder;else if(e.isLOD)!0===e.autoUpdate&&e.update(t);else if(e.isLight)d.pushLight(e),e.castShadow&&d.pushShadow(e);else if(e.isSprite){if(!e.frustumCulled||N.intersectsSprite(e)){n&&F.setFromMatrixPosition(e.matrixWorld).applyMatrix4(z);const t=K.update(e),r=e.material;r.visible&&u.push(e,t,r,i,F.z,null)}}else if((e.isMesh||e.isLine||e.isPoints)&&(e.isSkinnedMesh&&e.skeleton.frame!==G.render.frame&&(e.skeleton.update(),e.skeleton.frame=G.render.frame),!e.frustumCulled||N.intersectsObject(e))){n&&F.setFromMatrixPosition(e.matrixWorld).applyMatrix4(z);const t=K.update(e),r=e.material;if(Array.isArray(r)){const n=t.groups;for(let s=0,a=n.length;s<a;s++){const a=n[s],o=r[a.materialIndex];o&&o.visible&&u.push(e,t,o,i,F.z,a)}}else r.visible&&u.push(e,t,r,i,F.z,null)}const r=e.children;for(let e=0,s=r.length;e<s;e++)we(r[e],t,i,n)}function Me(e,t,i,n){const r=e.opaque,s=e.transmissive,o=e.transparent;d.setupLightsView(i),s.length>0&&function(e,t,i){if(null===O){const e=!0===a&&!0===H.isWebGL2;O=new(e?Yi:Zi)(1024,1024,{generateMipmaps:!0,type:null!==ce.convert(ri)?ri:ei,minFilter:Qt,magFilter:Jt,wrapS:Zt,wrapT:Zt})}const n=f.getRenderTarget();f.setRenderTarget(O),f.clear();const r=f.toneMapping;f.toneMapping=0,Se(e,t,i),f.toneMapping=r,q.updateMultisampleRenderTarget(O),q.updateRenderTargetMipmap(O),f.setRenderTarget(n)}(r,t,i),n&&j.viewport(w.copy(n)),r.length>0&&Se(r,t,i),s.length>0&&Se(s,t,i),o.length>0&&Se(o,t,i)}function Se(e,t,i){const n=!0===t.isScene?t.overrideMaterial:null;for(let r=0,s=e.length;r<s;r++){const s=e[r],a=s.object,o=s.geometry,h=null===n?s.material:n,c=s.group;a.layers.test(i.layers)&&Te(a,t,i,o,h,c)}}function Te(e,t,i,n,r,s){e.onBeforeRender(f,t,i,n,r,s),e.modelViewMatrix.multiplyMatrices(i.matrixWorldInverse,e.matrixWorld),e.normalMatrix.getNormalMatrix(e.modelViewMatrix),r.onBeforeRender(f,t,i,n,e,s),!0===r.transparent&&2===r.side?(r.side=1,r.needsUpdate=!0,f.renderBufferDirect(i,t,n,r,e,s),r.side=0,r.needsUpdate=!0,f.renderBufferDirect(i,t,n,r,e,s),r.side=2):f.renderBufferDirect(i,t,n,r,e,s),e.onAfterRender(f,t,i,n,r,s)}function Ce(e,t,i){!0!==t.isScene&&(t=B);const n=W.get(e),r=d.state.lights,s=d.state.shadowsArray,a=r.state.version,o=Q.getParameters(e,r.state,s,t,i),h=Q.getProgramCacheKey(o);let c=n.programs;n.environment=e.isMeshStandardMaterial?t.environment:null,n.fog=t.fog,n.envMap=(e.isMeshStandardMaterial?Z:X).get(e.envMap||n.environment),void 0===c&&(e.addEventListener("dispose",_e),c=new Map,n.programs=c);let l=c.get(h);if(void 0!==l){if(n.currentProgram===l&&n.lightsStateVersion===a)return Ee(e,o),l}else o.uniforms=Q.getUniforms(e),e.onBuild(i,o,f),e.onBeforeCompile(o,f),l=Q.acquireProgram(o,h),c.set(h,l),n.uniforms=o.uniforms;const u=n.uniforms;(e.isShaderMaterial||e.isRawShaderMaterial)&&!0!==e.clipping||(u.clippingPlanes=ne.uniform),Ee(e,o),n.needsLights=function(e){return e.isMeshLambertMaterial||e.isMeshToonMaterial||e.isMeshPhongMaterial||e.isMeshStandardMaterial||e.isShadowMaterial||e.isShaderMaterial&&!0===e.lights}(e),n.lightsStateVersion=a,n.needsLights&&(u.ambientLightColor.value=r.state.ambient,u.lightProbe.value=r.state.probe,u.directionalLights.value=r.state.directional,u.directionalLightShadows.value=r.state.directionalShadow,u.spotLights.value=r.state.spot,u.spotLightShadows.value=r.state.spotShadow,u.rectAreaLights.value=r.state.rectArea,u.ltc_1.value=r.state.rectAreaLTC1,u.ltc_2.value=r.state.rectAreaLTC2,u.pointLights.value=r.state.point,u.pointLightShadows.value=r.state.pointShadow,u.hemisphereLights.value=r.state.hemi,u.directionalShadowMap.value=r.state.directionalShadowMap,u.directionalShadowMatrix.value=r.state.directionalShadowMatrix,u.spotShadowMap.value=r.state.spotShadowMap,u.spotShadowMatrix.value=r.state.spotShadowMatrix,u.pointShadowMap.value=r.state.pointShadowMap,u.pointShadowMatrix.value=r.state.pointShadowMatrix);const p=l.getUniforms(),m=_o.seqWithValue(p.seq,u);return n.currentProgram=l,n.uniformsList=m,l}function Ee(e,t){const i=W.get(e);i.outputEncoding=t.outputEncoding,i.instancing=t.instancing,i.skinning=t.skinning,i.morphTargets=t.morphTargets,i.morphNormals=t.morphNormals,i.morphTargetsCount=t.morphTargetsCount,i.numClippingPlanes=t.numClippingPlanes,i.numIntersection=t.numClipIntersection,i.vertexAlphas=t.vertexAlphas,i.vertexTangents=t.vertexTangents}xe.setAnimationLoop((function(e){ve&&ve(e)})),"undefined"!=typeof window&&xe.setContext(window),this.setAnimationLoop=function(e){ve=e,me.setAnimationLoop(e),null===e?xe.stop():xe.start()},me.addEventListener("sessionstart",ye),me.addEventListener("sessionend",be),this.render=function(e,t){if(void 0!==t&&!0!==t.isCamera)return void console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");if(!0===g)return;!0===e.autoUpdate&&e.updateMatrixWorld(),null===t.parent&&t.updateMatrixWorld(),!0===me.enabled&&!0===me.isPresenting&&(!0===me.cameraAutoUpdate&&me.updateCamera(t),t=me.getCamera()),!0===e.isScene&&e.onBeforeRender(f,e,t,y),d=ie.get(e,m.length),d.init(),m.push(d),z.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),N.setFromProjectionMatrix(z),k=this.localClippingEnabled,$=ne.init(this.clippingPlanes,k,t),u=te.get(e,p.length),u.init(),p.push(u),we(e,t,0,f.sortObjects),u.finish(),!0===f.sortObjects&&u.sort(A,I),!0===$&&ne.beginShadows();const i=d.state.shadowsArray;if(re.render(i,e,t),!0===$&&ne.endShadows(),!0===this.info.autoReset&&this.info.reset(),se.render(u,e),d.setupLights(f.physicallyCorrectLights),t.isArrayCamera){const i=t.cameras;for(let t=0,n=i.length;t<n;t++){const n=i[t];Me(u,e,n,n.viewport)}}else Me(u,e,t);null!==y&&(q.updateMultisampleRenderTarget(y),q.updateRenderTargetMipmap(y)),!0===e.isScene&&e.onAfterRender(f,e,t),j.buffers.depth.setTest(!0),j.buffers.depth.setMask(!0),j.buffers.color.setMask(!0),j.setPolygonOffset(!1),le.resetDefaultState(),b=-1,x=null,m.pop(),d=m.length>0?m[m.length-1]:null,p.pop(),u=p.length>0?p[p.length-1]:null},this.getActiveCubeFace=function(){return _},this.getActiveMipmapLevel=function(){return v},this.getRenderTarget=function(){return y},this.setRenderTarget=function(e,t=0,i=0){y=e,_=t,v=i,e&&void 0===W.get(e).__webglFramebuffer&&q.setupRenderTarget(e);let n=null,r=!1,s=!1;if(e){const i=e.texture;(i.isDataTexture3D||i.isDataTexture2DArray)&&(s=!0);const a=W.get(e).__webglFramebuffer;e.isWebGLCubeRenderTarget?(n=a[t],r=!0):n=e.isWebGLMultisampleRenderTarget?W.get(e).__webglMultisampledFramebuffer:a,w.copy(e.viewport),M.copy(e.scissor),S=e.scissorTest}else w.copy(R).multiplyScalar(E).floor(),M.copy(P).multiplyScalar(E).floor(),S=L;if(j.bindFramebuffer(36160,n)&&H.drawBuffers){let t=!1;if(e)if(e.isWebGLMultipleRenderTargets){const i=e.texture;if(D.length!==i.length||36064!==D[0]){for(let e=0,t=i.length;e<t;e++)D[e]=36064+e;D.length=i.length,t=!0}}else 1===D.length&&36064===D[0]||(D[0]=36064,D.length=1,t=!0);else 1===D.length&&1029===D[0]||(D[0]=1029,D.length=1,t=!0);t&&(H.isWebGL2?ue.drawBuffers(D):V.get("WEBGL_draw_buffers").drawBuffersWEBGL(D))}if(j.viewport(w),j.scissor(M),j.setScissorTest(S),r){const n=W.get(e.texture);ue.framebufferTexture2D(36160,36064,34069+t,n.__webglTexture,i)}else if(s){const n=W.get(e.texture),r=t||0;ue.framebufferTextureLayer(36160,36064,n.__webglTexture,i||0,r)}b=-1},this.readRenderTargetPixels=function(e,t,i,n,r,s,a){if(!e||!e.isWebGLRenderTarget)return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let o=W.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&void 0!==a&&(o=o[a]),o){j.bindFramebuffer(36160,o);try{const a=e.texture,o=a.format,h=a.type;if(o!==oi&&ce.convert(o)!==ue.getParameter(35739))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");const c=h===ri&&(V.has("EXT_color_buffer_half_float")||H.isWebGL2&&V.has("EXT_color_buffer_float"));if(!(h===ei||ce.convert(h)===ue.getParameter(35738)||h===ni&&(H.isWebGL2||V.has("OES_texture_float")||V.has("WEBGL_color_buffer_float"))||c))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");36053===ue.checkFramebufferStatus(36160)?t>=0&&t<=e.width-n&&i>=0&&i<=e.height-r&&ue.readPixels(t,i,n,r,ce.convert(o),ce.convert(h),s):console.error("THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete.")}finally{const e=null!==y?W.get(y).__webglFramebuffer:null;j.bindFramebuffer(36160,e)}}},this.copyFramebufferToTexture=function(e,t,i=0){const n=Math.pow(2,-i),r=Math.floor(t.image.width*n),s=Math.floor(t.image.height*n);let a=ce.convert(t.format);H.isWebGL2&&(6407===a&&(a=32849),6408===a&&(a=32856)),q.setTexture2D(t,0),ue.copyTexImage2D(3553,i,a,e.x,e.y,r,s,0),j.unbindTexture()},this.copyTextureToTexture=function(e,t,i,n=0){const r=t.image.width,s=t.image.height,a=ce.convert(i.format),o=ce.convert(i.type);q.setTexture2D(i,0),ue.pixelStorei(37440,i.flipY),ue.pixelStorei(37441,i.premultiplyAlpha),ue.pixelStorei(3317,i.unpackAlignment),t.isDataTexture?ue.texSubImage2D(3553,n,e.x,e.y,r,s,a,o,t.image.data):t.isCompressedTexture?ue.compressedTexSubImage2D(3553,n,e.x,e.y,t.mipmaps[0].width,t.mipmaps[0].height,a,t.mipmaps[0].data):ue.texSubImage2D(3553,n,e.x,e.y,a,o,t.image),0===n&&i.generateMipmaps&&ue.generateMipmap(3553),j.unbindTexture()},this.copyTextureToTexture3D=function(e,t,i,n,r=0){if(f.isWebGL1Renderer)return void console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");const s=e.max.x-e.min.x+1,a=e.max.y-e.min.y+1,o=e.max.z-e.min.z+1,h=ce.convert(n.format),c=ce.convert(n.type);let l;if(n.isDataTexture3D)q.setTexture3D(n,0),l=32879;else{if(!n.isDataTexture2DArray)return void console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");q.setTexture2DArray(n,0),l=35866}ue.pixelStorei(37440,n.flipY),ue.pixelStorei(37441,n.premultiplyAlpha),ue.pixelStorei(3317,n.unpackAlignment);const u=ue.getParameter(3314),d=ue.getParameter(32878),p=ue.getParameter(3316),m=ue.getParameter(3315),g=ue.getParameter(32877),_=i.isCompressedTexture?i.mipmaps[0]:i.image;ue.pixelStorei(3314,_.width),ue.pixelStorei(32878,_.height),ue.pixelStorei(3316,e.min.x),ue.pixelStorei(3315,e.min.y),ue.pixelStorei(32877,e.min.z),i.isDataTexture||i.isDataTexture3D?ue.texSubImage3D(l,r,t.x,t.y,t.z,s,a,o,h,c,_.data):i.isCompressedTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),ue.compressedTexSubImage3D(l,r,t.x,t.y,t.z,s,a,o,h,_.data)):ue.texSubImage3D(l,r,t.x,t.y,t.z,s,a,o,h,c,_),ue.pixelStorei(3314,u),ue.pixelStorei(32878,d),ue.pixelStorei(3316,p),ue.pixelStorei(3315,m),ue.pixelStorei(32877,g),0===r&&n.generateMipmaps&&ue.generateMipmap(l),j.unbindTexture()},this.initTexture=function(e){q.setTexture2D(e,0),j.unbindTexture()},this.resetState=function(){_=0,v=0,y=null,j.reset(),le.reset()},"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}hh.prototype.isWebGLRenderer=!0;(class extends hh{}).prototype.isWebGL1Renderer=!0;class ch extends tr{constructor(){super(),this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.overrideMaterial=null,this.autoUpdate=!0,"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),null!==e.background&&(this.background=e.background.clone()),null!==e.environment&&(this.environment=e.environment.clone()),null!==e.fog&&(this.fog=e.fog.clone()),null!==e.overrideMaterial&&(this.overrideMaterial=e.overrideMaterial.clone()),this.autoUpdate=e.autoUpdate,this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return null!==this.fog&&(t.object.fog=this.fog.toJSON()),t}}ch.prototype.isScene=!0;class lh{constructor(e,t){this.array=e,this.stride=t,this.count=void 0!==e?e.length/t:0,this.usage=wi,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=Pi()}onUploadCallback(){}set needsUpdate(e){!0===e&&this.version++}setUsage(e){return this.usage=e,this}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,i){e*=this.stride,i*=t.stride;for(let n=0,r=this.stride;n<r;n++)this.array[e+n]=t.array[i+n];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){void 0===e.arrayBuffers&&(e.arrayBuffers={}),void 0===this.array.buffer._uuid&&(this.array.buffer._uuid=Pi()),void 0===e.arrayBuffers[this.array.buffer._uuid]&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),i=new this.constructor(t,this.stride);return i.setUsage(this.usage),i}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return void 0===e.arrayBuffers&&(e.arrayBuffers={}),void 0===this.array.buffer._uuid&&(this.array.buffer._uuid=Pi()),void 0===e.arrayBuffers[this.array.buffer._uuid]&&(e.arrayBuffers[this.array.buffer._uuid]=Array.prototype.slice.call(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}lh.prototype.isInterleavedBuffer=!0;const uh=new Ki;class dh{constructor(e,t,i,n=!1){this.name="",this.data=e,this.itemSize=t,this.offset=i,this.normalized=!0===n}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,i=this.data.count;t<i;t++)uh.x=this.getX(t),uh.y=this.getY(t),uh.z=this.getZ(t),uh.applyMatrix4(e),this.setXYZ(t,uh.x,uh.y,uh.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)uh.x=this.getX(t),uh.y=this.getY(t),uh.z=this.getZ(t),uh.applyNormalMatrix(e),this.setXYZ(t,uh.x,uh.y,uh.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)uh.x=this.getX(t),uh.y=this.getY(t),uh.z=this.getZ(t),uh.transformDirection(e),this.setXYZ(t,uh.x,uh.y,uh.z);return this}setX(e,t){return this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){return this.data.array[e*this.data.stride+this.offset]}getY(e){return this.data.array[e*this.data.stride+this.offset+1]}getZ(e){return this.data.array[e*this.data.stride+this.offset+2]}getW(e){return this.data.array[e*this.data.stride+this.offset+3]}setXY(e,t,i){return e=e*this.data.stride+this.offset,this.data.array[e+0]=t,this.data.array[e+1]=i,this}setXYZ(e,t,i,n){return e=e*this.data.stride+this.offset,this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=n,this}setXYZW(e,t,i,n,r){return e=e*this.data.stride+this.offset,this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=n,this.data.array[e+3]=r,this}clone(e){if(void 0===e){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interlaved buffer attribute will deinterleave buffer data.");const e=[];for(let t=0;t<this.count;t++){const i=t*this.data.stride+this.offset;for(let t=0;t<this.itemSize;t++)e.push(this.data.array[i+t])}return new Tr(new this.array.constructor(e),this.itemSize,this.normalized)}return void 0===e.interleavedBuffers&&(e.interleavedBuffers={}),void 0===e.interleavedBuffers[this.data.uuid]&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new dh(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(void 0===e){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interlaved buffer attribute will deinterleave buffer data.");const e=[];for(let t=0;t<this.count;t++){const i=t*this.data.stride+this.offset;for(let t=0;t<this.itemSize;t++)e.push(this.data.array[i+t])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:e,normalized:this.normalized}}return void 0===e.interleavedBuffers&&(e.interleavedBuffers={}),void 0===e.interleavedBuffers[this.data.uuid]&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}dh.prototype.isInterleavedBufferAttribute=!0;class ph extends mr{constructor(e){super(),this.type="SpriteMaterial",this.color=new xr(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this}}let mh;ph.prototype.isSpriteMaterial=!0;const fh=new Ki,gh=new Ki,_h=new Ki,vh=new zi,yh=new zi,bh=new Rn,xh=new Ki,wh=new Ki,Mh=new Ki,Sh=new zi,Th=new zi,Ch=new zi;class Eh extends tr{constructor(e){if(super(),this.type="Sprite",void 0===mh){mh=new kr;const e=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),t=new lh(e,5);mh.setIndex([0,1,2,0,2,3]),mh.setAttribute("position",new dh(t,3,0,!1)),mh.setAttribute("uv",new dh(t,2,3,!1))}this.geometry=mh,this.material=void 0!==e?e:new ph,this.center=new zi(.5,.5)}raycast(e,t){null===e.camera&&console.error('THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),gh.setFromMatrixScale(this.matrixWorld),bh.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),_h.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&!1===this.material.sizeAttenuation&&gh.multiplyScalar(-_h.z);const i=this.material.rotation;let n,r;0!==i&&(r=Math.cos(i),n=Math.sin(i));const s=this.center;Ah(xh.set(-.5,-.5,0),_h,s,gh,n,r),Ah(wh.set(.5,-.5,0),_h,s,gh,n,r),Ah(Mh.set(.5,.5,0),_h,s,gh,n,r),Sh.set(0,0),Th.set(1,0),Ch.set(1,1);let a=e.ray.intersectTriangle(xh,wh,Mh,!1,fh);if(null===a&&(Ah(wh.set(-.5,.5,0),_h,s,gh,n,r),Th.set(0,1),a=e.ray.intersectTriangle(xh,Mh,wh,!1,fh),null===a))return;const o=e.ray.origin.distanceTo(fh);o<e.near||o>e.far||t.push({distance:o,point:fh.clone(),uv:dr.getUV(fh,xh,wh,Mh,Sh,Th,Ch,new zi),face:null,object:this})}copy(e){return super.copy(e),void 0!==e.center&&this.center.copy(e.center),this.material=e.material,this}}function Ah(e,t,i,n,r,s){vh.subVectors(e,i).addScalar(.5).multiply(n),void 0!==r?(yh.x=s*vh.x-r*vh.y,yh.y=r*vh.x+s*vh.y):yh.copy(vh),e.copy(t),e.x+=yh.x,e.y+=yh.y,e.applyMatrix4(bh)}Eh.prototype.isSprite=!0;const Ih=new Ki,Rh=new Xi,Ph=new Xi,Lh=new Ki,Dh=new Rn;class Nh extends es{constructor(e,t){super(e,t),this.type="SkinnedMesh",this.bindMode="attached",this.bindMatrix=new Rn,this.bindMatrixInverse=new Rn}copy(e){return super.copy(e),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,this}bind(e,t){this.skeleton=e,void 0===t&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){const e=new Xi,t=this.geometry.attributes.skinWeight;for(let i=0,n=t.count;i<n;i++){e.x=t.getX(i),e.y=t.getY(i),e.z=t.getZ(i),e.w=t.getW(i);const n=1/e.manhattanLength();n!==1/0?e.multiplyScalar(n):e.set(1,0,0,0),t.setXYZW(i,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),"attached"===this.bindMode?this.bindMatrixInverse.copy(this.matrixWorld).invert():"detached"===this.bindMode?this.bindMatrixInverse.copy(this.bindMatrix).invert():console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}boneTransform(e,t){const i=this.skeleton,n=this.geometry;Rh.fromBufferAttribute(n.attributes.skinIndex,e),Ph.fromBufferAttribute(n.attributes.skinWeight,e),Ih.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let e=0;e<4;e++){const n=Ph.getComponent(e);if(0!==n){const r=Rh.getComponent(e);Dh.multiplyMatrices(i.bones[r].matrixWorld,i.boneInverses[r]),t.addScaledVector(Lh.copy(Ih).applyMatrix4(Dh),n)}}return t.applyMatrix4(this.bindMatrixInverse)}}Nh.prototype.isSkinnedMesh=!0;(class extends tr{constructor(){super(),this.type="Bone"}}).prototype.isBone=!0;(class extends Wi{constructor(e=null,t=1,i=1,n,r,s,a,o,h=1003,c=1003,l,u){super(null,s,a,o,h,c,n,r,l,u),this.image={data:e,width:t,height:i},this.magFilter=h,this.minFilter=c,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.needsUpdate=!0}}).prototype.isDataTexture=!0;class $h extends Tr{constructor(e,t,i,n=1){"number"==typeof i&&(n=i,i=!1,console.error("THREE.InstancedBufferAttribute: The constructor now expects normalized as the third argument.")),super(e,t,i),this.meshPerAttribute=n}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){const e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}}$h.prototype.isInstancedBufferAttribute=!0;const kh=new Rn,Oh=new Rn,zh=[],Fh=new es;(class extends es{constructor(e,t,i){super(e,t),this.instanceMatrix=new $h(new Float32Array(16*i),16),this.instanceColor=null,this.count=i,this.frustumCulled=!1}copy(e){return super.copy(e),this.instanceMatrix.copy(e.instanceMatrix),null!==e.instanceColor&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,this}getColorAt(e,t){t.fromArray(this.instanceColor.array,3*e)}getMatrixAt(e,t){t.fromArray(this.instanceMatrix.array,16*e)}raycast(e,t){const i=this.matrixWorld,n=this.count;if(Fh.geometry=this.geometry,Fh.material=this.material,void 0!==Fh.material)for(let r=0;r<n;r++){this.getMatrixAt(r,kh),Oh.multiplyMatrices(i,kh),Fh.matrixWorld=Oh,Fh.raycast(e,zh);for(let e=0,i=zh.length;e<i;e++){const i=zh[e];i.instanceId=r,i.object=this,t.push(i)}zh.length=0}}setColorAt(e,t){null===this.instanceColor&&(this.instanceColor=new $h(new Float32Array(3*this.instanceMatrix.count),3)),t.toArray(this.instanceColor.array,3*e)}setMatrixAt(e,t){t.toArray(this.instanceMatrix.array,16*e)}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"})}}).prototype.isInstancedMesh=!0;class Bh extends mr{constructor(e){super(),this.type="LineBasicMaterial",this.color=new xr(16777215),this.linewidth=1,this.linecap="round",this.linejoin="round",this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this}}Bh.prototype.isLineBasicMaterial=!0;const Uh=new Ki,Vh=new Ki,Hh=new Rn,jh=new In,Gh=new xn;class Wh extends tr{constructor(e=new kr,t=new Bh){super(),this.type="Line",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e){return super.copy(e),this.material=e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.isBufferGeometry)if(null===e.index){const t=e.attributes.position,i=[0];for(let e=1,n=t.count;e<n;e++)Uh.fromBufferAttribute(t,e-1),Vh.fromBufferAttribute(t,e),i[e]=i[e-1],i[e]+=Uh.distanceTo(Vh);e.setAttribute("lineDistance",new Ar(i,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");else e.isGeometry&&console.error("THREE.Line.computeLineDistances() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.");return this}raycast(e,t){const i=this.geometry,n=this.matrixWorld,r=e.params.Line.threshold,s=i.drawRange;if(null===i.boundingSphere&&i.computeBoundingSphere(),Gh.copy(i.boundingSphere),Gh.applyMatrix4(n),Gh.radius+=r,!1===e.ray.intersectsSphere(Gh))return;Hh.copy(n).invert(),jh.copy(e.ray).applyMatrix4(Hh);const a=r/((this.scale.x+this.scale.y+this.scale.z)/3),o=a*a,h=new Ki,c=new Ki,l=new Ki,u=new Ki,d=this.isLineSegments?2:1;if(i.isBufferGeometry){const n=i.index,r=i.attributes.position;if(null!==n){for(let i=Math.max(0,s.start),a=Math.min(n.count,s.start+s.count)-1;i<a;i+=d){const s=n.getX(i),a=n.getX(i+1);h.fromBufferAttribute(r,s),c.fromBufferAttribute(r,a);if(jh.distanceSqToSegment(h,c,u,l)>o)continue;u.applyMatrix4(this.matrixWorld);const d=e.ray.origin.distanceTo(u);d<e.near||d>e.far||t.push({distance:d,point:l.clone().applyMatrix4(this.matrixWorld),index:i,face:null,faceIndex:null,object:this})}}else{for(let i=Math.max(0,s.start),n=Math.min(r.count,s.start+s.count)-1;i<n;i+=d){h.fromBufferAttribute(r,i),c.fromBufferAttribute(r,i+1);if(jh.distanceSqToSegment(h,c,u,l)>o)continue;u.applyMatrix4(this.matrixWorld);const n=e.ray.origin.distanceTo(u);n<e.near||n>e.far||t.push({distance:n,point:l.clone().applyMatrix4(this.matrixWorld),index:i,face:null,faceIndex:null,object:this})}}}else i.isGeometry&&console.error("THREE.Line.raycast() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")}updateMorphTargets(){const e=this.geometry;if(e.isBufferGeometry){const t=e.morphAttributes,i=Object.keys(t);if(i.length>0){const e=t[i[0]];if(void 0!==e){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,i=e.length;t<i;t++){const i=e[t].name||String(t);this.morphTargetInfluences.push(0),this.morphTargetDictionary[i]=t}}}}else{const t=e.morphTargets;void 0!==t&&t.length>0&&console.error("THREE.Line.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.")}}}Wh.prototype.isLine=!0;const qh=new Ki,Xh=new Ki;class Zh extends Wh{constructor(e,t){super(e,t),this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.isBufferGeometry)if(null===e.index){const t=e.attributes.position,i=[];for(let e=0,n=t.count;e<n;e+=2)qh.fromBufferAttribute(t,e),Xh.fromBufferAttribute(t,e+1),i[e]=0===e?0:i[e-1],i[e+1]=i[e]+qh.distanceTo(Xh);e.setAttribute("lineDistance",new Ar(i,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");else e.isGeometry&&console.error("THREE.LineSegments.computeLineDistances() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.");return this}}Zh.prototype.isLineSegments=!0;(class extends Wh{constructor(e,t){super(e,t),this.type="LineLoop"}}).prototype.isLineLoop=!0;class Yh extends mr{constructor(e){super(),this.type="PointsMaterial",this.color=new xr(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this}}Yh.prototype.isPointsMaterial=!0;const Jh=new Rn,Kh=new In,Qh=new xn,ec=new Ki;class tc extends tr{constructor(e=new kr,t=new Yh){super(),this.type="Points",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e){return super.copy(e),this.material=e.material,this.geometry=e.geometry,this}raycast(e,t){const i=this.geometry,n=this.matrixWorld,r=e.params.Points.threshold,s=i.drawRange;if(null===i.boundingSphere&&i.computeBoundingSphere(),Qh.copy(i.boundingSphere),Qh.applyMatrix4(n),Qh.radius+=r,!1===e.ray.intersectsSphere(Qh))return;Jh.copy(n).invert(),Kh.copy(e.ray).applyMatrix4(Jh);const a=r/((this.scale.x+this.scale.y+this.scale.z)/3),o=a*a;if(i.isBufferGeometry){const r=i.index,a=i.attributes.position;if(null!==r){for(let i=Math.max(0,s.start),h=Math.min(r.count,s.start+s.count);i<h;i++){const s=r.getX(i);ec.fromBufferAttribute(a,s),ic(ec,s,o,n,e,t,this)}}else{for(let i=Math.max(0,s.start),r=Math.min(a.count,s.start+s.count);i<r;i++)ec.fromBufferAttribute(a,i),ic(ec,i,o,n,e,t,this)}}else console.error("THREE.Points.raycast() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")}updateMorphTargets(){const e=this.geometry;if(e.isBufferGeometry){const t=e.morphAttributes,i=Object.keys(t);if(i.length>0){const e=t[i[0]];if(void 0!==e){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,i=e.length;t<i;t++){const i=e[t].name||String(t);this.morphTargetInfluences.push(0),this.morphTargetDictionary[i]=t}}}}else{const t=e.morphTargets;void 0!==t&&t.length>0&&console.error("THREE.Points.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.")}}}function ic(e,t,i,n,r,s,a){const o=Kh.distanceSqToPoint(e);if(o<i){const i=new Ki;Kh.closestPointToPoint(e,i),i.applyMatrix4(n);const h=r.ray.origin.distanceTo(i);if(h<r.near||h>r.far)return;s.push({distance:h,distanceToRay:Math.sqrt(o),point:i,index:t,face:null,object:a})}}tc.prototype.isPoints=!0;(class extends Wi{constructor(e,t,i,n,r,s,a,o,h){super(e,t,i,n,r,s,a,o,h),this.format=void 0!==a?a:ai,this.minFilter=void 0!==s?s:Kt,this.magFilter=void 0!==r?r:Kt,this.generateMipmaps=!1;const c=this;"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback((function t(){c.needsUpdate=!0,e.requestVideoFrameCallback(t)}))}clone(){return new this.constructor(this.image).copy(this)}update(){const e=this.image;!1==="requestVideoFrameCallback"in e&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}).prototype.isVideoTexture=!0;(class extends Wi{constructor(e,t,i,n,r,s,a,o,h,c,l,u){super(null,s,a,o,h,c,n,r,l,u),this.image={width:t,height:i},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}}).prototype.isCompressedTexture=!0;(class extends Wi{constructor(e,t,i,n,r,s,a,o,h){super(e,t,i,n,r,s,a,o,h),this.needsUpdate=!0}}).prototype.isCanvasTexture=!0;(class extends Wi{constructor(e,t,i,n,r,s,a,o,h,c){if((c=void 0!==c?c:hi)!==hi&&c!==ci)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");void 0===i&&c===hi&&(i=ti),void 0===i&&c===ci&&(i=si),super(null,n,r,s,a,o,c,i,h),this.image={width:e,height:t},this.magFilter=void 0!==a?a:Jt,this.minFilter=void 0!==o?o:Jt,this.flipY=!1,this.generateMipmaps=!1}}).prototype.isDepthTexture=!0;class nc extends kr{constructor(e=1,t=8,i=0,n=2*Math.PI){super(),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:i,thetaLength:n},t=Math.max(3,t);const r=[],s=[],a=[],o=[],h=new Ki,c=new zi;s.push(0,0,0),a.push(0,0,1),o.push(.5,.5);for(let r=0,l=3;r<=t;r++,l+=3){const u=i+r/t*n;h.x=e*Math.cos(u),h.y=e*Math.sin(u),s.push(h.x,h.y,h.z),a.push(0,0,1),c.x=(s[l]/e+1)/2,c.y=(s[l+1]/e+1)/2,o.push(c.x,c.y)}for(let e=1;e<=t;e++)r.push(e,e+1,0);this.setIndex(r),this.setAttribute("position",new Ar(s,3)),this.setAttribute("normal",new Ar(a,3)),this.setAttribute("uv",new Ar(o,2))}static fromJSON(e){return new nc(e.radius,e.segments,e.thetaStart,e.thetaLength)}}new Ki,new Ki,new Ki,new dr;class rc{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){const i=this.getUtoTmapping(e);return this.getPoint(i,t)}getPoints(e=5){const t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return t}getSpacedPoints(e=5){const t=[];for(let i=0;i<=e;i++)t.push(this.getPointAt(i/e));return t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const t=[];let i,n=this.getPoint(0),r=0;t.push(0);for(let s=1;s<=e;s++)i=this.getPoint(s/e),r+=i.distanceTo(n),t.push(r),n=i;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){const i=this.getLengths();let n=0;const r=i.length;let s;s=t||e*i[r-1];let a,o=0,h=r-1;for(;o<=h;)if(n=Math.floor(o+(h-o)/2),a=i[n]-s,a<0)o=n+1;else{if(!(a>0)){h=n;break}h=n-1}if(n=h,i[n]===s)return n/(r-1);const c=i[n];return(n+(s-c)/(i[n+1]-c))/(r-1)}getTangent(e,t){const i=1e-4;let n=e-i,r=e+i;n<0&&(n=0),r>1&&(r=1);const s=this.getPoint(n),a=this.getPoint(r),o=t||(s.isVector2?new zi:new Ki);return o.copy(a).sub(s).normalize(),o}getTangentAt(e,t){const i=this.getUtoTmapping(e);return this.getTangent(i,t)}computeFrenetFrames(e,t){const i=new Ki,n=[],r=[],s=[],a=new Ki,o=new Rn;for(let t=0;t<=e;t++){const i=t/e;n[t]=this.getTangentAt(i,new Ki)}r[0]=new Ki,s[0]=new Ki;let h=Number.MAX_VALUE;const c=Math.abs(n[0].x),l=Math.abs(n[0].y),u=Math.abs(n[0].z);c<=h&&(h=c,i.set(1,0,0)),l<=h&&(h=l,i.set(0,1,0)),u<=h&&i.set(0,0,1),a.crossVectors(n[0],i).normalize(),r[0].crossVectors(n[0],a),s[0].crossVectors(n[0],r[0]);for(let t=1;t<=e;t++){if(r[t]=r[t-1].clone(),s[t]=s[t-1].clone(),a.crossVectors(n[t-1],n[t]),a.length()>Number.EPSILON){a.normalize();const e=Math.acos(Li(n[t-1].dot(n[t]),-1,1));r[t].applyMatrix4(o.makeRotationAxis(a,e))}s[t].crossVectors(n[t],r[t])}if(!0===t){let t=Math.acos(Li(r[0].dot(r[e]),-1,1));t/=e,n[0].dot(a.crossVectors(r[0],r[e]))>0&&(t=-t);for(let i=1;i<=e;i++)r[i].applyMatrix4(o.makeRotationAxis(n[i],t*i)),s[i].crossVectors(n[i],r[i])}return{tangents:n,normals:r,binormals:s}}clone(){return(new this.constructor).copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.5,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class sc extends rc{constructor(e=0,t=0,i=1,n=1,r=0,s=2*Math.PI,a=!1,o=0){super(),this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=i,this.yRadius=n,this.aStartAngle=r,this.aEndAngle=s,this.aClockwise=a,this.aRotation=o}getPoint(e,t){const i=t||new zi,n=2*Math.PI;let r=this.aEndAngle-this.aStartAngle;const s=Math.abs(r)<Number.EPSILON;for(;r<0;)r+=n;for(;r>n;)r-=n;r<Number.EPSILON&&(r=s?0:n),!0!==this.aClockwise||s||(r===n?r=-n:r-=n);const a=this.aStartAngle+e*r;let o=this.aX+this.xRadius*Math.cos(a),h=this.aY+this.yRadius*Math.sin(a);if(0!==this.aRotation){const e=Math.cos(this.aRotation),t=Math.sin(this.aRotation),i=o-this.aX,n=h-this.aY;o=i*e-n*t+this.aX,h=i*t+n*e+this.aY}return i.set(o,h)}copy(e){return super.copy(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}toJSON(){const e=super.toJSON();return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e}fromJSON(e){return super.fromJSON(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}}sc.prototype.isEllipseCurve=!0;class ac extends sc{constructor(e,t,i,n,r,s){super(e,t,i,i,n,r,s),this.type="ArcCurve"}}function oc(){let e=0,t=0,i=0,n=0;function r(r,s,a,o){e=r,t=a,i=-3*r+3*s-2*a-o,n=2*r-2*s+a+o}return{initCatmullRom:function(e,t,i,n,s){r(t,i,s*(i-e),s*(n-t))},initNonuniformCatmullRom:function(e,t,i,n,s,a,o){let h=(t-e)/s-(i-e)/(s+a)+(i-t)/a,c=(i-t)/a-(n-t)/(a+o)+(n-i)/o;h*=a,c*=a,r(t,i,h,c)},calc:function(r){const s=r*r;return e+t*r+i*s+n*(s*r)}}}ac.prototype.isArcCurve=!0;const hc=new Ki,cc=new oc,lc=new oc,uc=new oc;class dc extends rc{constructor(e=[],t=!1,i="centripetal",n=.5){super(),this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=i,this.tension=n}getPoint(e,t=new Ki){const i=t,n=this.points,r=n.length,s=(r-(this.closed?0:1))*e;let a,o,h=Math.floor(s),c=s-h;this.closed?h+=h>0?0:(Math.floor(Math.abs(h)/r)+1)*r:0===c&&h===r-1&&(h=r-2,c=1),this.closed||h>0?a=n[(h-1)%r]:(hc.subVectors(n[0],n[1]).add(n[0]),a=hc);const l=n[h%r],u=n[(h+1)%r];if(this.closed||h+2<r?o=n[(h+2)%r]:(hc.subVectors(n[r-1],n[r-2]).add(n[r-1]),o=hc),"centripetal"===this.curveType||"chordal"===this.curveType){const e="chordal"===this.curveType?.5:.25;let t=Math.pow(a.distanceToSquared(l),e),i=Math.pow(l.distanceToSquared(u),e),n=Math.pow(u.distanceToSquared(o),e);i<1e-4&&(i=1),t<1e-4&&(t=i),n<1e-4&&(n=i),cc.initNonuniformCatmullRom(a.x,l.x,u.x,o.x,t,i,n),lc.initNonuniformCatmullRom(a.y,l.y,u.y,o.y,t,i,n),uc.initNonuniformCatmullRom(a.z,l.z,u.z,o.z,t,i,n)}else"catmullrom"===this.curveType&&(cc.initCatmullRom(a.x,l.x,u.x,o.x,this.tension),lc.initCatmullRom(a.y,l.y,u.y,o.y,this.tension),uc.initCatmullRom(a.z,l.z,u.z,o.z,this.tension));return i.set(cc.calc(c),lc.calc(c),uc.calc(c)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){const i=e.points[t];this.points.push(i.clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,i=this.points.length;t<i;t++){const i=this.points[t];e.points.push(i.toArray())}return e.closed=this.closed,e.curveType=this.curveType,e.tension=this.tension,e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){const i=e.points[t];this.points.push((new Ki).fromArray(i))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}}function pc(e,t,i,n,r){const s=.5*(n-t),a=.5*(r-i),o=e*e;return(2*i-2*n+s+a)*(e*o)+(-3*i+3*n-2*s-a)*o+s*e+i}function mc(e,t,i,n){return function(e,t){const i=1-e;return i*i*t}(e,t)+function(e,t){return 2*(1-e)*e*t}(e,i)+function(e,t){return e*e*t}(e,n)}function fc(e,t,i,n,r){return function(e,t){const i=1-e;return i*i*i*t}(e,t)+function(e,t){const i=1-e;return 3*i*i*e*t}(e,i)+function(e,t){return 3*(1-e)*e*e*t}(e,n)+function(e,t){return e*e*e*t}(e,r)}dc.prototype.isCatmullRomCurve3=!0;class gc extends rc{constructor(e=new zi,t=new zi,i=new zi,n=new zi){super(),this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=i,this.v3=n}getPoint(e,t=new zi){const i=t,n=this.v0,r=this.v1,s=this.v2,a=this.v3;return i.set(fc(e,n.x,r.x,s.x,a.x),fc(e,n.y,r.y,s.y,a.y)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}}gc.prototype.isCubicBezierCurve=!0;class _c extends rc{constructor(e=new Ki,t=new Ki,i=new Ki,n=new Ki){super(),this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=i,this.v3=n}getPoint(e,t=new Ki){const i=t,n=this.v0,r=this.v1,s=this.v2,a=this.v3;return i.set(fc(e,n.x,r.x,s.x,a.x),fc(e,n.y,r.y,s.y,a.y),fc(e,n.z,r.z,s.z,a.z)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}}_c.prototype.isCubicBezierCurve3=!0;class vc extends rc{constructor(e=new zi,t=new zi){super(),this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new zi){const i=t;return 1===e?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t){const i=t||new zi;return i.copy(this.v2).sub(this.v1).normalize(),i}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}vc.prototype.isLineCurve=!0;class yc extends rc{constructor(e=new zi,t=new zi,i=new zi){super(),this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new zi){const i=t,n=this.v0,r=this.v1,s=this.v2;return i.set(mc(e,n.x,r.x,s.x),mc(e,n.y,r.y,s.y)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}yc.prototype.isQuadraticBezierCurve=!0;class bc extends rc{constructor(e=new Ki,t=new Ki,i=new Ki){super(),this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new Ki){const i=t,n=this.v0,r=this.v1,s=this.v2;return i.set(mc(e,n.x,r.x,s.x),mc(e,n.y,r.y,s.y),mc(e,n.z,r.z,s.z)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}bc.prototype.isQuadraticBezierCurve3=!0;class xc extends rc{constructor(e=[]){super(),this.type="SplineCurve",this.points=e}getPoint(e,t=new zi){const i=t,n=this.points,r=(n.length-1)*e,s=Math.floor(r),a=r-s,o=n[0===s?s:s-1],h=n[s],c=n[s>n.length-2?n.length-1:s+1],l=n[s>n.length-3?n.length-1:s+2];return i.set(pc(a,o.x,h.x,c.x,l.x),pc(a,o.y,h.y,c.y,l.y)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){const i=e.points[t];this.points.push(i.clone())}return this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,i=this.points.length;t<i;t++){const i=this.points[t];e.points.push(i.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){const i=e.points[t];this.points.push((new zi).fromArray(i))}return this}}xc.prototype.isSplineCurve=!0;var wc=Object.freeze({__proto__:null,ArcCurve:ac,CatmullRomCurve3:dc,CubicBezierCurve:gc,CubicBezierCurve3:_c,EllipseCurve:sc,LineCurve:vc,LineCurve3:class extends rc{constructor(e=new Ki,t=new Ki){super(),this.type="LineCurve3",this.isLineCurve3=!0,this.v1=e,this.v2=t}getPoint(e,t=new Ki){const i=t;return 1===e?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i}getPointAt(e,t){return this.getPoint(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},QuadraticBezierCurve:yc,QuadraticBezierCurve3:bc,SplineCurve:xc});class Mc extends rc{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(e){this.curves.push(e)}closePath(){const e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);e.equals(t)||this.curves.push(new vc(t,e))}getPoint(e,t){const i=e*this.getLength(),n=this.getCurveLengths();let r=0;for(;r<n.length;){if(n[r]>=i){const e=n[r]-i,s=this.curves[r],a=s.getLength(),o=0===a?0:1-e/a;return s.getPointAt(o,t)}r++}return null}getLength(){const e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const e=[];let t=0;for(let i=0,n=this.curves.length;i<n;i++)t+=this.curves[i].getLength(),e.push(t);return this.cacheLengths=e,e}getSpacedPoints(e=40){const t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return this.autoClose&&t.push(t[0]),t}getPoints(e=12){const t=[];let i;for(let n=0,r=this.curves;n<r.length;n++){const s=r[n],a=s&&s.isEllipseCurve?2*e:s&&(s.isLineCurve||s.isLineCurve3)?1:s&&s.isSplineCurve?e*s.points.length:e,o=s.getPoints(a);for(let e=0;e<o.length;e++){const n=o[e];i&&i.equals(n)||(t.push(n),i=n)}}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,i=e.curves.length;t<i;t++){const i=e.curves[t];this.curves.push(i.clone())}return this.autoClose=e.autoClose,this}toJSON(){const e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let t=0,i=this.curves.length;t<i;t++){const i=this.curves[t];e.curves.push(i.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,i=e.curves.length;t<i;t++){const i=e.curves[t];this.curves.push((new wc[i.type]).fromJSON(i))}return this}}class Sc extends Mc{constructor(e){super(),this.type="Path",this.currentPoint=new zi,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,i=e.length;t<i;t++)this.lineTo(e[t].x,e[t].y);return this}moveTo(e,t){return this.currentPoint.set(e,t),this}lineTo(e,t){const i=new vc(this.currentPoint.clone(),new zi(e,t));return this.curves.push(i),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,i,n){const r=new yc(this.currentPoint.clone(),new zi(e,t),new zi(i,n));return this.curves.push(r),this.currentPoint.set(i,n),this}bezierCurveTo(e,t,i,n,r,s){const a=new gc(this.currentPoint.clone(),new zi(e,t),new zi(i,n),new zi(r,s));return this.curves.push(a),this.currentPoint.set(r,s),this}splineThru(e){const t=[this.currentPoint.clone()].concat(e),i=new xc(t);return this.curves.push(i),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,i,n,r,s){const a=this.currentPoint.x,o=this.currentPoint.y;return this.absarc(e+a,t+o,i,n,r,s),this}absarc(e,t,i,n,r,s){return this.absellipse(e,t,i,i,n,r,s),this}ellipse(e,t,i,n,r,s,a,o){const h=this.currentPoint.x,c=this.currentPoint.y;return this.absellipse(e+h,t+c,i,n,r,s,a,o),this}absellipse(e,t,i,n,r,s,a,o){const h=new sc(e,t,i,n,r,s,a,o);if(this.curves.length>0){const e=h.getPoint(0);e.equals(this.currentPoint)||this.lineTo(e.x,e.y)}this.curves.push(h);const c=h.getPoint(1);return this.currentPoint.copy(c),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){const e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}}class Tc extends Sc{constructor(e){super(e),this.uuid=Pi(),this.type="Shape",this.holes=[]}getPointsHoles(e){const t=[];for(let i=0,n=this.holes.length;i<n;i++)t[i]=this.holes[i].getPoints(e);return t}extractPoints(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}}copy(e){super.copy(e),this.holes=[];for(let t=0,i=e.holes.length;t<i;t++){const i=e.holes[t];this.holes.push(i.clone())}return this}toJSON(){const e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let t=0,i=this.holes.length;t<i;t++){const i=this.holes[t];e.holes.push(i.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.uuid=e.uuid,this.holes=[];for(let t=0,i=e.holes.length;t<i;t++){const i=e.holes[t];this.holes.push((new Sc).fromJSON(i))}return this}}const Cc=function(e,t,i=2){const n=t&&t.length,r=n?t[0]*i:e.length;let s=Ec(e,0,r,i,!0);const a=[];if(!s||s.next===s.prev)return a;let o,h,c,l,u,d,p;if(n&&(s=function(e,t,i,n){const r=[];let s,a,o,h,c;for(s=0,a=t.length;s<a;s++)o=t[s]*n,h=s<a-1?t[s+1]*n:e.length,c=Ec(e,o,h,n,!1),c===c.next&&(c.steiner=!0),r.push(zc(c));for(r.sort(Nc),s=0;s<r.length;s++)$c(r[s],i),i=Ac(i,i.next);return i}(e,t,s,i)),e.length>80*i){o=c=e[0],h=l=e[1];for(let t=i;t<r;t+=i)u=e[t],d=e[t+1],u<o&&(o=u),d<h&&(h=d),u>c&&(c=u),d>l&&(l=d);p=Math.max(c-o,l-h),p=0!==p?1/p:0}return Ic(s,a,i,o,h,p),a};function Ec(e,t,i,n,r){let s,a;if(r===function(e,t,i,n){let r=0;for(let s=t,a=i-n;s<i;s+=n)r+=(e[a]-e[s])*(e[s+1]+e[a+1]),a=s;return r}(e,t,i,n)>0)for(s=t;s<i;s+=n)a=Xc(s,e[s],e[s+1],a);else for(s=i-n;s>=t;s-=n)a=Xc(s,e[s],e[s+1],a);return a&&Vc(a,a.next)&&(Zc(a),a=a.next),a}function Ac(e,t){if(!e)return e;t||(t=e);let i,n=e;do{if(i=!1,n.steiner||!Vc(n,n.next)&&0!==Uc(n.prev,n,n.next))n=n.next;else{if(Zc(n),n=t=n.prev,n===n.next)break;i=!0}}while(i||n!==t);return t}function Ic(e,t,i,n,r,s,a){if(!e)return;!a&&s&&function(e,t,i,n){let r=e;do{null===r.z&&(r.z=Oc(r.x,r.y,t,i,n)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==e);r.prevZ.nextZ=null,r.prevZ=null,function(e){let t,i,n,r,s,a,o,h,c=1;do{for(i=e,e=null,s=null,a=0;i;){for(a++,n=i,o=0,t=0;t<c&&(o++,n=n.nextZ,n);t++);for(h=c;o>0||h>0&&n;)0!==o&&(0===h||!n||i.z<=n.z)?(r=i,i=i.nextZ,o--):(r=n,n=n.nextZ,h--),s?s.nextZ=r:e=r,r.prevZ=s,s=r;i=n}s.nextZ=null,c*=2}while(a>1)}(r)}(e,n,r,s);let o,h,c=e;for(;e.prev!==e.next;)if(o=e.prev,h=e.next,s?Pc(e,n,r,s):Rc(e))t.push(o.i/i),t.push(e.i/i),t.push(h.i/i),Zc(e),e=h.next,c=h.next;else if((e=h)===c){a?1===a?Ic(e=Lc(Ac(e),t,i),t,i,n,r,s,2):2===a&&Dc(e,t,i,n,r,s):Ic(Ac(e),t,i,n,r,s,1);break}}function Rc(e){const t=e.prev,i=e,n=e.next;if(Uc(t,i,n)>=0)return!1;let r=e.next.next;for(;r!==e.prev;){if(Fc(t.x,t.y,i.x,i.y,n.x,n.y,r.x,r.y)&&Uc(r.prev,r,r.next)>=0)return!1;r=r.next}return!0}function Pc(e,t,i,n){const r=e.prev,s=e,a=e.next;if(Uc(r,s,a)>=0)return!1;const o=r.x<s.x?r.x<a.x?r.x:a.x:s.x<a.x?s.x:a.x,h=r.y<s.y?r.y<a.y?r.y:a.y:s.y<a.y?s.y:a.y,c=r.x>s.x?r.x>a.x?r.x:a.x:s.x>a.x?s.x:a.x,l=r.y>s.y?r.y>a.y?r.y:a.y:s.y>a.y?s.y:a.y,u=Oc(o,h,t,i,n),d=Oc(c,l,t,i,n);let p=e.prevZ,m=e.nextZ;for(;p&&p.z>=u&&m&&m.z<=d;){if(p!==e.prev&&p!==e.next&&Fc(r.x,r.y,s.x,s.y,a.x,a.y,p.x,p.y)&&Uc(p.prev,p,p.next)>=0)return!1;if(p=p.prevZ,m!==e.prev&&m!==e.next&&Fc(r.x,r.y,s.x,s.y,a.x,a.y,m.x,m.y)&&Uc(m.prev,m,m.next)>=0)return!1;m=m.nextZ}for(;p&&p.z>=u;){if(p!==e.prev&&p!==e.next&&Fc(r.x,r.y,s.x,s.y,a.x,a.y,p.x,p.y)&&Uc(p.prev,p,p.next)>=0)return!1;p=p.prevZ}for(;m&&m.z<=d;){if(m!==e.prev&&m!==e.next&&Fc(r.x,r.y,s.x,s.y,a.x,a.y,m.x,m.y)&&Uc(m.prev,m,m.next)>=0)return!1;m=m.nextZ}return!0}function Lc(e,t,i){let n=e;do{const r=n.prev,s=n.next.next;!Vc(r,s)&&Hc(r,n,n.next,s)&&Wc(r,s)&&Wc(s,r)&&(t.push(r.i/i),t.push(n.i/i),t.push(s.i/i),Zc(n),Zc(n.next),n=e=s),n=n.next}while(n!==e);return Ac(n)}function Dc(e,t,i,n,r,s){let a=e;do{let e=a.next.next;for(;e!==a.prev;){if(a.i!==e.i&&Bc(a,e)){let o=qc(a,e);return a=Ac(a,a.next),o=Ac(o,o.next),Ic(a,t,i,n,r,s),void Ic(o,t,i,n,r,s)}e=e.next}a=a.next}while(a!==e)}function Nc(e,t){return e.x-t.x}function $c(e,t){if(t=function(e,t){let i=t;const n=e.x,r=e.y;let s,a=-1/0;do{if(r<=i.y&&r>=i.next.y&&i.next.y!==i.y){const e=i.x+(r-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(e<=n&&e>a){if(a=e,e===n){if(r===i.y)return i;if(r===i.next.y)return i.next}s=i.x<i.next.x?i:i.next}}i=i.next}while(i!==t);if(!s)return null;if(n===a)return s;const o=s,h=s.x,c=s.y;let l,u=1/0;i=s;do{n>=i.x&&i.x>=h&&n!==i.x&&Fc(r<c?n:a,r,h,c,r<c?a:n,r,i.x,i.y)&&(l=Math.abs(r-i.y)/(n-i.x),Wc(i,e)&&(l<u||l===u&&(i.x>s.x||i.x===s.x&&kc(s,i)))&&(s=i,u=l)),i=i.next}while(i!==o);return s}(e,t)){const i=qc(t,e);Ac(t,t.next),Ac(i,i.next)}}function kc(e,t){return Uc(e.prev,e,t.prev)<0&&Uc(t.next,e,e.next)<0}function Oc(e,t,i,n,r){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-i)*r)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-n)*r)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function zc(e){let t=e,i=e;do{(t.x<i.x||t.x===i.x&&t.y<i.y)&&(i=t),t=t.next}while(t!==e);return i}function Fc(e,t,i,n,r,s,a,o){return(r-a)*(t-o)-(e-a)*(s-o)>=0&&(e-a)*(n-o)-(i-a)*(t-o)>=0&&(i-a)*(s-o)-(r-a)*(n-o)>=0}function Bc(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){let i=e;do{if(i.i!==e.i&&i.next.i!==e.i&&i.i!==t.i&&i.next.i!==t.i&&Hc(i,i.next,e,t))return!0;i=i.next}while(i!==e);return!1}(e,t)&&(Wc(e,t)&&Wc(t,e)&&function(e,t){let i=e,n=!1;const r=(e.x+t.x)/2,s=(e.y+t.y)/2;do{i.y>s!=i.next.y>s&&i.next.y!==i.y&&r<(i.next.x-i.x)*(s-i.y)/(i.next.y-i.y)+i.x&&(n=!n),i=i.next}while(i!==e);return n}(e,t)&&(Uc(e.prev,e,t.prev)||Uc(e,t.prev,t))||Vc(e,t)&&Uc(e.prev,e,e.next)>0&&Uc(t.prev,t,t.next)>0)}function Uc(e,t,i){return(t.y-e.y)*(i.x-t.x)-(t.x-e.x)*(i.y-t.y)}function Vc(e,t){return e.x===t.x&&e.y===t.y}function Hc(e,t,i,n){const r=Gc(Uc(e,t,i)),s=Gc(Uc(e,t,n)),a=Gc(Uc(i,n,e)),o=Gc(Uc(i,n,t));return r!==s&&a!==o||(!(0!==r||!jc(e,i,t))||(!(0!==s||!jc(e,n,t))||(!(0!==a||!jc(i,e,n))||!(0!==o||!jc(i,t,n)))))}function jc(e,t,i){return t.x<=Math.max(e.x,i.x)&&t.x>=Math.min(e.x,i.x)&&t.y<=Math.max(e.y,i.y)&&t.y>=Math.min(e.y,i.y)}function Gc(e){return e>0?1:e<0?-1:0}function Wc(e,t){return Uc(e.prev,e,e.next)<0?Uc(e,t,e.next)>=0&&Uc(e,e.prev,t)>=0:Uc(e,t,e.prev)<0||Uc(e,e.next,t)<0}function qc(e,t){const i=new Yc(e.i,e.x,e.y),n=new Yc(t.i,t.x,t.y),r=e.next,s=t.prev;return e.next=t,t.prev=e,i.next=r,r.prev=i,n.next=i,i.prev=n,s.next=n,n.prev=s,n}function Xc(e,t,i,n){const r=new Yc(e,t,i);return n?(r.next=n.next,r.prev=n,n.next.prev=r,n.next=r):(r.prev=r,r.next=r),r}function Zc(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function Yc(e,t,i){this.i=e,this.x=t,this.y=i,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}class Jc{static area(e){const t=e.length;let i=0;for(let n=t-1,r=0;r<t;n=r++)i+=e[n].x*e[r].y-e[r].x*e[n].y;return.5*i}static isClockWise(e){return Jc.area(e)<0}static triangulateShape(e,t){const i=[],n=[],r=[];Kc(e),Qc(i,e);let s=e.length;t.forEach(Kc);for(let e=0;e<t.length;e++)n.push(s),s+=t[e].length,Qc(i,t[e]);const a=Cc(i,n);for(let e=0;e<a.length;e+=3)r.push(a.slice(e,e+3));return r}}function Kc(e){const t=e.length;t>2&&e[t-1].equals(e[0])&&e.pop()}function Qc(e,t){for(let i=0;i<t.length;i++)e.push(t[i].x),e.push(t[i].y)}class el extends kr{constructor(e=new Tc([new zi(.5,.5),new zi(-.5,.5),new zi(-.5,-.5),new zi(.5,-.5)]),t={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:e,options:t},e=Array.isArray(e)?e:[e];const i=this,n=[],r=[];for(let t=0,i=e.length;t<i;t++){s(e[t])}function s(e){const s=[],a=void 0!==t.curveSegments?t.curveSegments:12,o=void 0!==t.steps?t.steps:1;let h=void 0!==t.depth?t.depth:1,c=void 0===t.bevelEnabled||t.bevelEnabled,l=void 0!==t.bevelThickness?t.bevelThickness:.2,u=void 0!==t.bevelSize?t.bevelSize:l-.1,d=void 0!==t.bevelOffset?t.bevelOffset:0,p=void 0!==t.bevelSegments?t.bevelSegments:3;const m=t.extrudePath,f=void 0!==t.UVGenerator?t.UVGenerator:tl;void 0!==t.amount&&(console.warn("THREE.ExtrudeBufferGeometry: amount has been renamed to depth."),h=t.amount);let g,_,v,y,b,x=!1;m&&(g=m.getSpacedPoints(o),x=!0,c=!1,_=m.computeFrenetFrames(o,!1),v=new Ki,y=new Ki,b=new Ki),c||(p=0,l=0,u=0,d=0);const w=e.extractPoints(a);let M=w.shape;const S=w.holes;if(!Jc.isClockWise(M)){M=M.reverse();for(let e=0,t=S.length;e<t;e++){const t=S[e];Jc.isClockWise(t)&&(S[e]=t.reverse())}}const T=Jc.triangulateShape(M,S),C=M;for(let e=0,t=S.length;e<t;e++){const t=S[e];M=M.concat(t)}function E(e,t,i){return t||console.error("THREE.ExtrudeGeometry: vec does not exist"),t.clone().multiplyScalar(i).add(e)}const A=M.length,I=T.length;function R(e,t,i){let n,r,s;const a=e.x-t.x,o=e.y-t.y,h=i.x-e.x,c=i.y-e.y,l=a*a+o*o,u=a*c-o*h;if(Math.abs(u)>Number.EPSILON){const u=Math.sqrt(l),d=Math.sqrt(h*h+c*c),p=t.x-o/u,m=t.y+a/u,f=((i.x-c/d-p)*c-(i.y+h/d-m)*h)/(a*c-o*h);n=p+a*f-e.x,r=m+o*f-e.y;const g=n*n+r*r;if(g<=2)return new zi(n,r);s=Math.sqrt(g/2)}else{let e=!1;a>Number.EPSILON?h>Number.EPSILON&&(e=!0):a<-Number.EPSILON?h<-Number.EPSILON&&(e=!0):Math.sign(o)===Math.sign(c)&&(e=!0),e?(n=-o,r=a,s=Math.sqrt(l)):(n=a,r=o,s=Math.sqrt(l/2))}return new zi(n/s,r/s)}const P=[];for(let e=0,t=C.length,i=t-1,n=e+1;e<t;e++,i++,n++)i===t&&(i=0),n===t&&(n=0),P[e]=R(C[e],C[i],C[n]);const L=[];let D,N=P.concat();for(let e=0,t=S.length;e<t;e++){const t=S[e];D=[];for(let e=0,i=t.length,n=i-1,r=e+1;e<i;e++,n++,r++)n===i&&(n=0),r===i&&(r=0),D[e]=R(t[e],t[n],t[r]);L.push(D),N=N.concat(D)}for(let e=0;e<p;e++){const t=e/p,i=l*Math.cos(t*Math.PI/2),n=u*Math.sin(t*Math.PI/2)+d;for(let e=0,t=C.length;e<t;e++){const t=E(C[e],P[e],n);O(t.x,t.y,-i)}for(let e=0,t=S.length;e<t;e++){const t=S[e];D=L[e];for(let e=0,r=t.length;e<r;e++){const r=E(t[e],D[e],n);O(r.x,r.y,-i)}}}const $=u+d;for(let e=0;e<A;e++){const t=c?E(M[e],N[e],$):M[e];x?(y.copy(_.normals[0]).multiplyScalar(t.x),v.copy(_.binormals[0]).multiplyScalar(t.y),b.copy(g[0]).add(y).add(v),O(b.x,b.y,b.z)):O(t.x,t.y,0)}for(let e=1;e<=o;e++)for(let t=0;t<A;t++){const i=c?E(M[t],N[t],$):M[t];x?(y.copy(_.normals[e]).multiplyScalar(i.x),v.copy(_.binormals[e]).multiplyScalar(i.y),b.copy(g[e]).add(y).add(v),O(b.x,b.y,b.z)):O(i.x,i.y,h/o*e)}for(let e=p-1;e>=0;e--){const t=e/p,i=l*Math.cos(t*Math.PI/2),n=u*Math.sin(t*Math.PI/2)+d;for(let e=0,t=C.length;e<t;e++){const t=E(C[e],P[e],n);O(t.x,t.y,h+i)}for(let e=0,t=S.length;e<t;e++){const t=S[e];D=L[e];for(let e=0,r=t.length;e<r;e++){const r=E(t[e],D[e],n);x?O(r.x,r.y+g[o-1].y,g[o-1].x+i):O(r.x,r.y,h+i)}}}function k(e,t){let i=e.length;for(;--i>=0;){const n=i;let r=i-1;r<0&&(r=e.length-1);for(let e=0,i=o+2*p;e<i;e++){const i=A*e,s=A*(e+1);F(t+n+i,t+r+i,t+r+s,t+n+s)}}}function O(e,t,i){s.push(e),s.push(t),s.push(i)}function z(e,t,r){B(e),B(t),B(r);const s=n.length/3,a=f.generateTopUV(i,n,s-3,s-2,s-1);U(a[0]),U(a[1]),U(a[2])}function F(e,t,r,s){B(e),B(t),B(s),B(t),B(r),B(s);const a=n.length/3,o=f.generateSideWallUV(i,n,a-6,a-3,a-2,a-1);U(o[0]),U(o[1]),U(o[3]),U(o[1]),U(o[2]),U(o[3])}function B(e){n.push(s[3*e+0]),n.push(s[3*e+1]),n.push(s[3*e+2])}function U(e){r.push(e.x),r.push(e.y)}!function(){const e=n.length/3;if(c){let e=0,t=A*e;for(let e=0;e<I;e++){const i=T[e];z(i[2]+t,i[1]+t,i[0]+t)}e=o+2*p,t=A*e;for(let e=0;e<I;e++){const i=T[e];z(i[0]+t,i[1]+t,i[2]+t)}}else{for(let e=0;e<I;e++){const t=T[e];z(t[2],t[1],t[0])}for(let e=0;e<I;e++){const t=T[e];z(t[0]+A*o,t[1]+A*o,t[2]+A*o)}}i.addGroup(e,n.length/3-e,0)}(),function(){const e=n.length/3;let t=0;k(C,t),t+=C.length;for(let e=0,i=S.length;e<i;e++){const i=S[e];k(i,t),t+=i.length}i.addGroup(e,n.length/3-e,1)}()}this.setAttribute("position",new Ar(n,3)),this.setAttribute("uv",new Ar(r,2)),this.computeVertexNormals()}toJSON(){const e=super.toJSON();return function(e,t,i){if(i.shapes=[],Array.isArray(e))for(let t=0,n=e.length;t<n;t++){const n=e[t];i.shapes.push(n.uuid)}else i.shapes.push(e.uuid);void 0!==t.extrudePath&&(i.options.extrudePath=t.extrudePath.toJSON());return i}(this.parameters.shapes,this.parameters.options,e)}static fromJSON(e,t){const i=[];for(let n=0,r=e.shapes.length;n<r;n++){const r=t[e.shapes[n]];i.push(r)}const n=e.options.extrudePath;return void 0!==n&&(e.options.extrudePath=(new wc[n.type]).fromJSON(n)),new el(i,e.options)}}const tl={generateTopUV:function(e,t,i,n,r){const s=t[3*i],a=t[3*i+1],o=t[3*n],h=t[3*n+1],c=t[3*r],l=t[3*r+1];return[new zi(s,a),new zi(o,h),new zi(c,l)]},generateSideWallUV:function(e,t,i,n,r,s){const a=t[3*i],o=t[3*i+1],h=t[3*i+2],c=t[3*n],l=t[3*n+1],u=t[3*n+2],d=t[3*r],p=t[3*r+1],m=t[3*r+2],f=t[3*s],g=t[3*s+1],_=t[3*s+2];return Math.abs(o-l)<Math.abs(a-c)?[new zi(a,1-h),new zi(c,1-u),new zi(d,1-m),new zi(f,1-_)]:[new zi(o,1-h),new zi(l,1-u),new zi(p,1-m),new zi(g,1-_)]}};class il extends kr{constructor(e=new Tc([new zi(0,.5),new zi(-.5,-.5),new zi(.5,-.5)]),t=12){super(),this.type="ShapeGeometry",this.parameters={shapes:e,curveSegments:t};const i=[],n=[],r=[],s=[];let a=0,o=0;if(!1===Array.isArray(e))h(e);else for(let t=0;t<e.length;t++)h(e[t]),this.addGroup(a,o,t),a+=o,o=0;function h(e){const a=n.length/3,h=e.extractPoints(t);let c=h.shape;const l=h.holes;!1===Jc.isClockWise(c)&&(c=c.reverse());for(let e=0,t=l.length;e<t;e++){const t=l[e];!0===Jc.isClockWise(t)&&(l[e]=t.reverse())}const u=Jc.triangulateShape(c,l);for(let e=0,t=l.length;e<t;e++){const t=l[e];c=c.concat(t)}for(let e=0,t=c.length;e<t;e++){const t=c[e];n.push(t.x,t.y,0),r.push(0,0,1),s.push(t.x,t.y)}for(let e=0,t=u.length;e<t;e++){const t=u[e],n=t[0]+a,r=t[1]+a,s=t[2]+a;i.push(n,r,s),o+=3}}this.setIndex(i),this.setAttribute("position",new Ar(n,3)),this.setAttribute("normal",new Ar(r,3)),this.setAttribute("uv",new Ar(s,2))}toJSON(){const e=super.toJSON();return function(e,t){if(t.shapes=[],Array.isArray(e))for(let i=0,n=e.length;i<n;i++){const n=e[i];t.shapes.push(n.uuid)}else t.shapes.push(e.uuid);return t}(this.parameters.shapes,e)}static fromJSON(e,t){const i=[];for(let n=0,r=e.shapes.length;n<r;n++){const r=t[e.shapes[n]];i.push(r)}return new il(i,e.curveSegments)}}class nl extends kr{constructor(e=1,t=32,i=16,n=0,r=2*Math.PI,s=0,a=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:i,phiStart:n,phiLength:r,thetaStart:s,thetaLength:a},t=Math.max(3,Math.floor(t)),i=Math.max(2,Math.floor(i));const o=Math.min(s+a,Math.PI);let h=0;const c=[],l=new Ki,u=new Ki,d=[],p=[],m=[],f=[];for(let d=0;d<=i;d++){const g=[],_=d/i;let v=0;0==d&&0==s?v=.5/t:d==i&&o==Math.PI&&(v=-.5/t);for(let i=0;i<=t;i++){const o=i/t;l.x=-e*Math.cos(n+o*r)*Math.sin(s+_*a),l.y=e*Math.cos(s+_*a),l.z=e*Math.sin(n+o*r)*Math.sin(s+_*a),p.push(l.x,l.y,l.z),u.copy(l).normalize(),m.push(u.x,u.y,u.z),f.push(o+v,1-_),g.push(h++)}c.push(g)}for(let e=0;e<i;e++)for(let n=0;n<t;n++){const t=c[e][n+1],r=c[e][n],a=c[e+1][n],h=c[e+1][n+1];(0!==e||s>0)&&d.push(t,r,h),(e!==i-1||o<Math.PI)&&d.push(r,a,h)}this.setIndex(d),this.setAttribute("position",new Ar(p,3)),this.setAttribute("normal",new Ar(m,3)),this.setAttribute("uv",new Ar(f,2))}static fromJSON(e){return new nl(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}(class extends mr{constructor(e){super(),this.type="ShadowMaterial",this.color=new xr(0),this.transparent=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this}}).prototype.isShadowMaterial=!0;class rl extends mr{constructor(e){super(),this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new xr(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new xr(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new zi(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapIntensity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapIntensity=e.envMapIntensity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this}}rl.prototype.isMeshStandardMaterial=!0;(class extends rl{constructor(e){super(),this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new zi(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return Li(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(e){this.ior=(1+.4*e)/(1-.4*e)}}),this.sheenColor=new xr(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=.01,this.thicknessMap=null,this.attenuationDistance=0,this.attenuationColor=new xr(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new xr(1,1,1),this.specularColorMap=null,this._sheen=0,this._clearcoat=0,this._transmission=0,this.setValues(e)}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.ior=e.ior,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}).prototype.isMeshPhysicalMaterial=!0;(class extends mr{constructor(e){super(),this.type="MeshPhongMaterial",this.color=new xr(16777215),this.specular=new xr(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new xr(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new zi(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this}}).prototype.isMeshPhongMaterial=!0;(class extends mr{constructor(e){super(),this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new xr(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new xr(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new zi(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.gradientMap=e.gradientMap,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this}}).prototype.isMeshToonMaterial=!0;(class extends mr{constructor(e){super(),this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new zi(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this}}).prototype.isMeshNormalMaterial=!0;(class extends mr{constructor(e){super(),this.type="MeshLambertMaterial",this.color=new xr(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new xr(0),this.emissiveIntensity=1,this.emissiveMap=null,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this}}).prototype.isMeshLambertMaterial=!0;(class extends mr{constructor(e){super(),this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new xr(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new zi(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.defines={MATCAP:""},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.flatShading=e.flatShading,this}}).prototype.isMeshMatcapMaterial=!0;(class extends Bh{constructor(e){super(),this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}}).prototype.isLineDashedMaterial=!0;const sl={arraySlice:function(e,t,i){return sl.isTypedArray(e)?new e.constructor(e.subarray(t,void 0!==i?i:e.length)):e.slice(t,i)},convertArray:function(e,t,i){return!e||!i&&e.constructor===t?e:"number"==typeof t.BYTES_PER_ELEMENT?new t(e):Array.prototype.slice.call(e)},isTypedArray:function(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)},getKeyframeOrder:function(e){const t=e.length,i=new Array(t);for(let e=0;e!==t;++e)i[e]=e;return i.sort((function(t,i){return e[t]-e[i]})),i},sortedArray:function(e,t,i){const n=e.length,r=new e.constructor(n);for(let s=0,a=0;a!==n;++s){const n=i[s]*t;for(let i=0;i!==t;++i)r[a++]=e[n+i]}return r},flattenJSON:function(e,t,i,n){let r=1,s=e[0];for(;void 0!==s&&void 0===s[n];)s=e[r++];if(void 0===s)return;let a=s[n];if(void 0!==a)if(Array.isArray(a))do{a=s[n],void 0!==a&&(t.push(s.time),i.push.apply(i,a)),s=e[r++]}while(void 0!==s);else if(void 0!==a.toArray)do{a=s[n],void 0!==a&&(t.push(s.time),a.toArray(i,i.length)),s=e[r++]}while(void 0!==s);else do{a=s[n],void 0!==a&&(t.push(s.time),i.push(a)),s=e[r++]}while(void 0!==s)},subclip:function(e,t,i,n,r=30){const s=e.clone();s.name=t;const a=[];for(let e=0;e<s.tracks.length;++e){const t=s.tracks[e],o=t.getValueSize(),h=[],c=[];for(let e=0;e<t.times.length;++e){const s=t.times[e]*r;if(!(s<i||s>=n)){h.push(t.times[e]);for(let i=0;i<o;++i)c.push(t.values[e*o+i])}}0!==h.length&&(t.times=sl.convertArray(h,t.times.constructor),t.values=sl.convertArray(c,t.values.constructor),a.push(t))}s.tracks=a;let o=1/0;for(let e=0;e<s.tracks.length;++e)o>s.tracks[e].times[0]&&(o=s.tracks[e].times[0]);for(let e=0;e<s.tracks.length;++e)s.tracks[e].shift(-1*o);return s.resetDuration(),s},makeClipAdditive:function(e,t=0,i=e,n=30){n<=0&&(n=30);const r=i.tracks.length,s=t/n;for(let t=0;t<r;++t){const n=i.tracks[t],r=n.ValueTypeName;if("bool"===r||"string"===r)continue;const a=e.tracks.find((function(e){return e.name===n.name&&e.ValueTypeName===r}));if(void 0===a)continue;let o=0;const h=n.getValueSize();n.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(o=h/3);let c=0;const l=a.getValueSize();a.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(c=l/3);const u=n.times.length-1;let d;if(s<=n.times[0]){const e=o,t=h-o;d=sl.arraySlice(n.values,e,t)}else if(s>=n.times[u]){const e=u*h+o,t=e+h-o;d=sl.arraySlice(n.values,e,t)}else{const e=n.createInterpolant(),t=o,i=h-o;e.evaluate(s),d=sl.arraySlice(e.resultBuffer,t,i)}if("quaternion"===r){(new Ji).fromArray(d).normalize().conjugate().toArray(d)}const p=a.times.length;for(let e=0;e<p;++e){const t=e*l+c;if("quaternion"===r)Ji.multiplyQuaternionsFlat(a.values,t,d,0,a.values,t);else{const e=l-2*c;for(let i=0;i<e;++i)a.values[t+i]-=d[i]}}}return e.blendMode=2501,e}};class al{constructor(e,t,i,n){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=void 0!==n?n:new t.constructor(i),this.sampleValues=t,this.valueSize=i,this.settings=null,this.DefaultSettings_={}}evaluate(e){const t=this.parameterPositions;let i=this._cachedIndex,n=t[i],r=t[i-1];e:{t:{let s;i:{n:if(!(e<n)){for(let s=i+2;;){if(void 0===n){if(e<r)break n;return i=t.length,this._cachedIndex=i,this.afterEnd_(i-1,e,r)}if(i===s)break;if(r=n,n=t[++i],e<n)break t}s=t.length;break i}if(e>=r)break e;{const a=t[1];e<a&&(i=2,r=a);for(let s=i-2;;){if(void 0===r)return this._cachedIndex=0,this.beforeStart_(0,e,n);if(i===s)break;if(n=r,r=t[--i-1],e>=r)break t}s=i,i=0}}for(;i<s;){const n=i+s>>>1;e<t[n]?s=n:i=n+1}if(n=t[i],r=t[i-1],void 0===r)return this._cachedIndex=0,this.beforeStart_(0,e,n);if(void 0===n)return i=t.length,this._cachedIndex=i,this.afterEnd_(i-1,r,e)}this._cachedIndex=i,this.intervalChanged_(i,r,n)}return this.interpolate_(i,r,e,n)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){const t=this.resultBuffer,i=this.sampleValues,n=this.valueSize,r=e*n;for(let e=0;e!==n;++e)t[e]=i[r+e];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}}al.prototype.beforeStart_=al.prototype.copySampleValue_,al.prototype.afterEnd_=al.prototype.copySampleValue_;class ol extends al{constructor(e,t,i,n){super(e,t,i,n),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:pi,endingEnd:pi}}intervalChanged_(e,t,i){const n=this.parameterPositions;let r=e-2,s=e+1,a=n[r],o=n[s];if(void 0===a)switch(this.getSettings_().endingStart){case mi:r=e,a=2*t-i;break;case fi:r=n.length-2,a=t+n[r]-n[r+1];break;default:r=e,a=i}if(void 0===o)switch(this.getSettings_().endingEnd){case mi:s=e,o=2*i-t;break;case fi:s=1,o=i+n[1]-n[0];break;default:s=e-1,o=t}const h=.5*(i-t),c=this.valueSize;this._weightPrev=h/(t-a),this._weightNext=h/(o-i),this._offsetPrev=r*c,this._offsetNext=s*c}interpolate_(e,t,i,n){const r=this.resultBuffer,s=this.sampleValues,a=this.valueSize,o=e*a,h=o-a,c=this._offsetPrev,l=this._offsetNext,u=this._weightPrev,d=this._weightNext,p=(i-t)/(n-t),m=p*p,f=m*p,g=-u*f+2*u*m-u*p,_=(1+u)*f+(-1.5-2*u)*m+(-.5+u)*p+1,v=(-1-d)*f+(1.5+d)*m+.5*p,y=d*f-d*m;for(let e=0;e!==a;++e)r[e]=g*s[c+e]+_*s[h+e]+v*s[o+e]+y*s[l+e];return r}}class hl extends al{constructor(e,t,i,n){super(e,t,i,n)}interpolate_(e,t,i,n){const r=this.resultBuffer,s=this.sampleValues,a=this.valueSize,o=e*a,h=o-a,c=(i-t)/(n-t),l=1-c;for(let e=0;e!==a;++e)r[e]=s[h+e]*l+s[o+e]*c;return r}}class cl extends al{constructor(e,t,i,n){super(e,t,i,n)}interpolate_(e){return this.copySampleValue_(e-1)}}class ll{constructor(e,t,i,n){if(void 0===e)throw new Error("THREE.KeyframeTrack: track name is undefined");if(void 0===t||0===t.length)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=sl.convertArray(t,this.TimeBufferType),this.values=sl.convertArray(i,this.ValueBufferType),this.setInterpolation(n||this.DefaultInterpolation)}static toJSON(e){const t=e.constructor;let i;if(t.toJSON!==this.toJSON)i=t.toJSON(e);else{i={name:e.name,times:sl.convertArray(e.times,Array),values:sl.convertArray(e.values,Array)};const t=e.getInterpolation();t!==e.DefaultInterpolation&&(i.interpolation=t)}return i.type=e.ValueTypeName,i}InterpolantFactoryMethodDiscrete(e){return new cl(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new hl(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new ol(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case li:t=this.InterpolantFactoryMethodDiscrete;break;case ui:t=this.InterpolantFactoryMethodLinear;break;case di:t=this.InterpolantFactoryMethodSmooth}if(void 0===t){const t="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(void 0===this.createInterpolant){if(e===this.DefaultInterpolation)throw new Error(t);this.setInterpolation(this.DefaultInterpolation)}return console.warn("THREE.KeyframeTrack:",t),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return li;case this.InterpolantFactoryMethodLinear:return ui;case this.InterpolantFactoryMethodSmooth:return di}}getValueSize(){return this.values.length/this.times.length}shift(e){if(0!==e){const t=this.times;for(let i=0,n=t.length;i!==n;++i)t[i]+=e}return this}scale(e){if(1!==e){const t=this.times;for(let i=0,n=t.length;i!==n;++i)t[i]*=e}return this}trim(e,t){const i=this.times,n=i.length;let r=0,s=n-1;for(;r!==n&&i[r]<e;)++r;for(;-1!==s&&i[s]>t;)--s;if(++s,0!==r||s!==n){r>=s&&(s=Math.max(s,1),r=s-1);const e=this.getValueSize();this.times=sl.arraySlice(i,r,s),this.values=sl.arraySlice(this.values,r*e,s*e)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!=0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);const i=this.times,n=this.values,r=i.length;0===r&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let s=null;for(let t=0;t!==r;t++){const n=i[t];if("number"==typeof n&&isNaN(n)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,t,n),e=!1;break}if(null!==s&&s>n){console.error("THREE.KeyframeTrack: Out of order keys.",this,t,n,s),e=!1;break}s=n}if(void 0!==n&&sl.isTypedArray(n))for(let t=0,i=n.length;t!==i;++t){const i=n[t];if(isNaN(i)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,t,i),e=!1;break}}return e}optimize(){const e=sl.arraySlice(this.times),t=sl.arraySlice(this.values),i=this.getValueSize(),n=this.getInterpolation()===di,r=e.length-1;let s=1;for(let a=1;a<r;++a){let r=!1;const o=e[a];if(o!==e[a+1]&&(1!==a||o!==e[0]))if(n)r=!0;else{const e=a*i,n=e-i,s=e+i;for(let a=0;a!==i;++a){const i=t[e+a];if(i!==t[n+a]||i!==t[s+a]){r=!0;break}}}if(r){if(a!==s){e[s]=e[a];const n=a*i,r=s*i;for(let e=0;e!==i;++e)t[r+e]=t[n+e]}++s}}if(r>0){e[s]=e[r];for(let e=r*i,n=s*i,a=0;a!==i;++a)t[n+a]=t[e+a];++s}return s!==e.length?(this.times=sl.arraySlice(e,0,s),this.values=sl.arraySlice(t,0,s*i)):(this.times=e,this.values=t),this}clone(){const e=sl.arraySlice(this.times,0),t=sl.arraySlice(this.values,0),i=new(0,this.constructor)(this.name,e,t);return i.createInterpolant=this.createInterpolant,i}}ll.prototype.TimeBufferType=Float32Array,ll.prototype.ValueBufferType=Float32Array,ll.prototype.DefaultInterpolation=ui;class ul extends ll{}ul.prototype.ValueTypeName="bool",ul.prototype.ValueBufferType=Array,ul.prototype.DefaultInterpolation=li,ul.prototype.InterpolantFactoryMethodLinear=void 0,ul.prototype.InterpolantFactoryMethodSmooth=void 0;class dl extends ll{}dl.prototype.ValueTypeName="color";class pl extends ll{}pl.prototype.ValueTypeName="number";class ml extends al{constructor(e,t,i,n){super(e,t,i,n)}interpolate_(e,t,i,n){const r=this.resultBuffer,s=this.sampleValues,a=this.valueSize,o=(i-t)/(n-t);let h=e*a;for(let e=h+a;h!==e;h+=4)Ji.slerpFlat(r,0,s,h-a,s,h,o);return r}}class fl extends ll{InterpolantFactoryMethodLinear(e){return new ml(this.times,this.values,this.getValueSize(),e)}}fl.prototype.ValueTypeName="quaternion",fl.prototype.DefaultInterpolation=ui,fl.prototype.InterpolantFactoryMethodSmooth=void 0;class gl extends ll{}gl.prototype.ValueTypeName="string",gl.prototype.ValueBufferType=Array,gl.prototype.DefaultInterpolation=li,gl.prototype.InterpolantFactoryMethodLinear=void 0,gl.prototype.InterpolantFactoryMethodSmooth=void 0;class _l extends ll{}_l.prototype.ValueTypeName="vector";class vl{constructor(e,t=-1,i,n=2500){this.name=e,this.tracks=i,this.duration=t,this.blendMode=n,this.uuid=Pi(),this.duration<0&&this.resetDuration()}static parse(e){const t=[],i=e.tracks,n=1/(e.fps||1);for(let e=0,r=i.length;e!==r;++e)t.push(yl(i[e]).scale(n));const r=new this(e.name,e.duration,t,e.blendMode);return r.uuid=e.uuid,r}static toJSON(e){const t=[],i=e.tracks,n={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let e=0,n=i.length;e!==n;++e)t.push(ll.toJSON(i[e]));return n}static CreateFromMorphTargetSequence(e,t,i,n){const r=t.length,s=[];for(let e=0;e<r;e++){let a=[],o=[];a.push((e+r-1)%r,e,(e+1)%r),o.push(0,1,0);const h=sl.getKeyframeOrder(a);a=sl.sortedArray(a,1,h),o=sl.sortedArray(o,1,h),n||0!==a[0]||(a.push(r),o.push(o[0])),s.push(new pl(".morphTargetInfluences["+t[e].name+"]",a,o).scale(1/i))}return new this(e,-1,s)}static findByName(e,t){let i=e;if(!Array.isArray(e)){const t=e;i=t.geometry&&t.geometry.animations||t.animations}for(let e=0;e<i.length;e++)if(i[e].name===t)return i[e];return null}static CreateClipsFromMorphTargetSequences(e,t,i){const n={},r=/^([\w-]*?)([\d]+)$/;for(let t=0,i=e.length;t<i;t++){const i=e[t],s=i.name.match(r);if(s&&s.length>1){const e=s[1];let t=n[e];t||(n[e]=t=[]),t.push(i)}}const s=[];for(const e in n)s.push(this.CreateFromMorphTargetSequence(e,n[e],t,i));return s}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const i=function(e,t,i,n,r){if(0!==i.length){const s=[],a=[];sl.flattenJSON(i,s,a,n),0!==s.length&&r.push(new e(t,s,a))}},n=[],r=e.name||"default",s=e.fps||30,a=e.blendMode;let o=e.length||-1;const h=e.hierarchy||[];for(let e=0;e<h.length;e++){const r=h[e].keys;if(r&&0!==r.length)if(r[0].morphTargets){const e={};let t;for(t=0;t<r.length;t++)if(r[t].morphTargets)for(let i=0;i<r[t].morphTargets.length;i++)e[r[t].morphTargets[i]]=-1;for(const i in e){const e=[],s=[];for(let n=0;n!==r[t].morphTargets.length;++n){const n=r[t];e.push(n.time),s.push(n.morphTarget===i?1:0)}n.push(new pl(".morphTargetInfluence["+i+"]",e,s))}o=e.length*(s||1)}else{const s=".bones["+t[e].name+"]";i(_l,s+".position",r,"pos",n),i(fl,s+".quaternion",r,"rot",n),i(_l,s+".scale",r,"scl",n)}}if(0===n.length)return null;return new this(r,o,n,a)}resetDuration(){let e=0;for(let t=0,i=this.tracks.length;t!==i;++t){const i=this.tracks[t];e=Math.max(e,i.times[i.times.length-1])}return this.duration=e,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){const e=[];for(let t=0;t<this.tracks.length;t++)e.push(this.tracks[t].clone());return new this.constructor(this.name,this.duration,e,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}}function yl(e){if(void 0===e.type)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const t=function(e){switch(e.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return pl;case"vector":case"vector2":case"vector3":case"vector4":return _l;case"color":return dl;case"quaternion":return fl;case"bool":case"boolean":return ul;case"string":return gl}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+e)}(e.type);if(void 0===e.times){const t=[],i=[];sl.flattenJSON(e.keys,t,i,"value"),e.times=t,e.values=i}return void 0!==t.parse?t.parse(e):new t(e.name,e.times,e.values,e.interpolation)}const bl={enabled:!1,files:{},add:function(e,t){!1!==this.enabled&&(this.files[e]=t)},get:function(e){if(!1!==this.enabled)return this.files[e]},remove:function(e){delete this.files[e]},clear:function(){this.files={}}};const xl=new class{constructor(e,t,i){const n=this;let r,s=!1,a=0,o=0;const h=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=i,this.itemStart=function(e){o++,!1===s&&void 0!==n.onStart&&n.onStart(e,a,o),s=!0},this.itemEnd=function(e){a++,void 0!==n.onProgress&&n.onProgress(e,a,o),a===o&&(s=!1,void 0!==n.onLoad&&n.onLoad())},this.itemError=function(e){void 0!==n.onError&&n.onError(e)},this.resolveURL=function(e){return r?r(e):e},this.setURLModifier=function(e){return r=e,this},this.addHandler=function(e,t){return h.push(e,t),this},this.removeHandler=function(e){const t=h.indexOf(e);return-1!==t&&h.splice(t,2),this},this.getHandler=function(e){for(let t=0,i=h.length;t<i;t+=2){const i=h[t],n=h[t+1];if(i.global&&(i.lastIndex=0),i.test(e))return n}return null}}};class wl{constructor(e){this.manager=void 0!==e?e:xl,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){const i=this;return new Promise((function(n,r){i.load(e,n,t,r)}))}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}}const Ml={};class Sl extends wl{constructor(e){super(e)}load(e,t,i,n){void 0===e&&(e=""),void 0!==this.path&&(e=this.path+e),e=this.manager.resolveURL(e);const r=bl.get(e);if(void 0!==r)return this.manager.itemStart(e),setTimeout((()=>{t&&t(r),this.manager.itemEnd(e)}),0),r;if(void 0!==Ml[e])return void Ml[e].push({onLoad:t,onProgress:i,onError:n});Ml[e]=[],Ml[e].push({onLoad:t,onProgress:i,onError:n});const s=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"});fetch(s).then((t=>{if(200===t.status||0===t.status){0===t.status&&console.warn("THREE.FileLoader: HTTP Status 0 received.");const i=Ml[e],n=t.body.getReader(),r=t.headers.get("Content-Length"),s=r?parseInt(r):0,a=0!==s;let o=0;return new ReadableStream({start(e){!function t(){n.read().then((({done:n,value:r})=>{if(n)e.close();else{o+=r.byteLength;const n=new ProgressEvent("progress",{lengthComputable:a,loaded:o,total:s});for(let e=0,t=i.length;e<t;e++){const t=i[e];t.onProgress&&t.onProgress(n)}e.enqueue(r),t()}}))}()}})}throw Error(`fetch for "${t.url}" responded with ${t.status}: ${t.statusText}`)})).then((e=>{const t=new Response(e);switch(this.responseType){case"arraybuffer":return t.arrayBuffer();case"blob":return t.blob();case"document":return t.text().then((e=>(new DOMParser).parseFromString(e,this.mimeType)));case"json":return t.json();default:return t.text()}})).then((t=>{bl.add(e,t);const i=Ml[e];delete Ml[e];for(let e=0,n=i.length;e<n;e++){const n=i[e];n.onLoad&&n.onLoad(t)}this.manager.itemEnd(e)})).catch((t=>{const i=Ml[e];delete Ml[e];for(let e=0,n=i.length;e<n;e++){const n=i[e];n.onError&&n.onError(t)}this.manager.itemError(e),this.manager.itemEnd(e)})),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}}class Tl extends wl{constructor(e){super(e)}load(e,t,i,n){void 0!==this.path&&(e=this.path+e),e=this.manager.resolveURL(e);const r=this,s=bl.get(e);if(void 0!==s)return r.manager.itemStart(e),setTimeout((function(){t&&t(s),r.manager.itemEnd(e)}),0),s;const a=Ui("img");function o(){c(),bl.add(e,this),t&&t(this),r.manager.itemEnd(e)}function h(t){c(),n&&n(t),r.manager.itemError(e),r.manager.itemEnd(e)}function c(){a.removeEventListener("load",o,!1),a.removeEventListener("error",h,!1)}return a.addEventListener("load",o,!1),a.addEventListener("error",h,!1),"data:"!==e.substr(0,5)&&void 0!==this.crossOrigin&&(a.crossOrigin=this.crossOrigin),r.manager.itemStart(e),a.src=e,a}}class Cl extends wl{constructor(e){super(e)}load(e,t,i,n){const r=new us,s=new Tl(this.manager);s.setCrossOrigin(this.crossOrigin),s.setPath(this.path);let a=0;function o(i){s.load(e[i],(function(e){r.images[i]=e,a++,6===a&&(r.needsUpdate=!0,t&&t(r))}),void 0,n)}for(let t=0;t<e.length;++t)o(t);return r}}class El extends wl{constructor(e){super(e)}load(e,t,i,n){const r=new Wi,s=new Tl(this.manager);return s.setCrossOrigin(this.crossOrigin),s.setPath(this.path),s.load(e,(function(e){r.image=e,r.needsUpdate=!0,void 0!==t&&t(r)}),i,n),r}}class Al extends tr{constructor(e,t=1){super(),this.type="Light",this.color=new xr(e),this.intensity=t}dispose(){}copy(e){return super.copy(e),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,void 0!==this.groundColor&&(t.object.groundColor=this.groundColor.getHex()),void 0!==this.distance&&(t.object.distance=this.distance),void 0!==this.angle&&(t.object.angle=this.angle),void 0!==this.decay&&(t.object.decay=this.decay),void 0!==this.penumbra&&(t.object.penumbra=this.penumbra),void 0!==this.shadow&&(t.object.shadow=this.shadow.toJSON()),t}}Al.prototype.isLight=!0;(class extends Al{constructor(e,t,i){super(e,i),this.type="HemisphereLight",this.position.copy(tr.DefaultUp),this.updateMatrix(),this.groundColor=new xr(t)}copy(e){return Al.prototype.copy.call(this,e),this.groundColor.copy(e.groundColor),this}}).prototype.isHemisphereLight=!0;const Il=new Rn,Rl=new Ki,Pl=new Ki;class Ll{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new zi(512,512),this.map=null,this.mapPass=null,this.matrix=new Rn,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new ys,this._frameExtents=new zi(1,1),this._viewportCount=1,this._viewports=[new Xi(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,i=this.matrix;Rl.setFromMatrixPosition(e.matrixWorld),t.position.copy(Rl),Pl.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(Pl),t.updateMatrixWorld(),Il.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Il),i.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),i.multiply(t.projectionMatrix),i.multiply(t.matrixWorldInverse)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this}clone(){return(new this.constructor).copy(this)}toJSON(){const e={};return 0!==this.bias&&(e.bias=this.bias),0!==this.normalBias&&(e.normalBias=this.normalBias),1!==this.radius&&(e.radius=this.radius),512===this.mapSize.x&&512===this.mapSize.y||(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}class Dl extends Ll{constructor(){super(new hs(50,1,.5,500)),this.focus=1}updateMatrices(e){const t=this.camera,i=2*Ai*e.angle*this.focus,n=this.mapSize.width/this.mapSize.height,r=e.distance||t.far;i===t.fov&&n===t.aspect&&r===t.far||(t.fov=i,t.aspect=n,t.far=r,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}Dl.prototype.isSpotLightShadow=!0;(class extends Al{constructor(e,t,i=0,n=Math.PI/3,r=0,s=1){super(e,t),this.type="SpotLight",this.position.copy(tr.DefaultUp),this.updateMatrix(),this.target=new tr,this.distance=i,this.angle=n,this.penumbra=r,this.decay=s,this.shadow=new Dl}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}).prototype.isSpotLight=!0;const Nl=new Rn,$l=new Ki,kl=new Ki;class Ol extends Ll{constructor(){super(new hs(90,1,.5,500)),this._frameExtents=new zi(4,2),this._viewportCount=6,this._viewports=[new Xi(2,1,1,1),new Xi(0,1,1,1),new Xi(3,1,1,1),new Xi(1,1,1,1),new Xi(3,0,1,1),new Xi(1,0,1,1)],this._cubeDirections=[new Ki(1,0,0),new Ki(-1,0,0),new Ki(0,0,1),new Ki(0,0,-1),new Ki(0,1,0),new Ki(0,-1,0)],this._cubeUps=[new Ki(0,1,0),new Ki(0,1,0),new Ki(0,1,0),new Ki(0,1,0),new Ki(0,0,1),new Ki(0,0,-1)]}updateMatrices(e,t=0){const i=this.camera,n=this.matrix,r=e.distance||i.far;r!==i.far&&(i.far=r,i.updateProjectionMatrix()),$l.setFromMatrixPosition(e.matrixWorld),i.position.copy($l),kl.copy(i.position),kl.add(this._cubeDirections[t]),i.up.copy(this._cubeUps[t]),i.lookAt(kl),i.updateMatrixWorld(),n.makeTranslation(-$l.x,-$l.y,-$l.z),Nl.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Nl)}}Ol.prototype.isPointLightShadow=!0;(class extends Al{constructor(e,t,i=0,n=1){super(e,t),this.type="PointLight",this.distance=i,this.decay=n,this.shadow=new Ol}get power(){return 4*this.intensity*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}}).prototype.isPointLight=!0;class zl extends Ll{constructor(){super(new Ls(-5,5,5,-5,.5,500))}}zl.prototype.isDirectionalLightShadow=!0;(class extends Al{constructor(e,t){super(e,t),this.type="DirectionalLight",this.position.copy(tr.DefaultUp),this.updateMatrix(),this.target=new tr,this.shadow=new zl}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}).prototype.isDirectionalLight=!0;(class extends Al{constructor(e,t){super(e,t),this.type="AmbientLight"}}).prototype.isAmbientLight=!0;(class extends Al{constructor(e,t,i=10,n=10){super(e,t),this.type="RectAreaLight",this.width=i,this.height=n}get power(){return this.intensity*this.width*this.height*Math.PI}set power(e){this.intensity=e/(this.width*this.height*Math.PI)}copy(e){return super.copy(e),this.width=e.width,this.height=e.height,this}toJSON(e){const t=super.toJSON(e);return t.object.width=this.width,t.object.height=this.height,t}}).prototype.isRectAreaLight=!0;class Fl{constructor(){this.coefficients=[];for(let e=0;e<9;e++)this.coefficients.push(new Ki)}set(e){for(let t=0;t<9;t++)this.coefficients[t].copy(e[t]);return this}zero(){for(let e=0;e<9;e++)this.coefficients[e].set(0,0,0);return this}getAt(e,t){const i=e.x,n=e.y,r=e.z,s=this.coefficients;return t.copy(s[0]).multiplyScalar(.282095),t.addScaledVector(s[1],.488603*n),t.addScaledVector(s[2],.488603*r),t.addScaledVector(s[3],.488603*i),t.addScaledVector(s[4],i*n*1.092548),t.addScaledVector(s[5],n*r*1.092548),t.addScaledVector(s[6],.315392*(3*r*r-1)),t.addScaledVector(s[7],i*r*1.092548),t.addScaledVector(s[8],.546274*(i*i-n*n)),t}getIrradianceAt(e,t){const i=e.x,n=e.y,r=e.z,s=this.coefficients;return t.copy(s[0]).multiplyScalar(.886227),t.addScaledVector(s[1],1.023328*n),t.addScaledVector(s[2],1.023328*r),t.addScaledVector(s[3],1.023328*i),t.addScaledVector(s[4],.858086*i*n),t.addScaledVector(s[5],.858086*n*r),t.addScaledVector(s[6],.743125*r*r-.247708),t.addScaledVector(s[7],.858086*i*r),t.addScaledVector(s[8],.429043*(i*i-n*n)),t}add(e){for(let t=0;t<9;t++)this.coefficients[t].add(e.coefficients[t]);return this}addScaledSH(e,t){for(let i=0;i<9;i++)this.coefficients[i].addScaledVector(e.coefficients[i],t);return this}scale(e){for(let t=0;t<9;t++)this.coefficients[t].multiplyScalar(e);return this}lerp(e,t){for(let i=0;i<9;i++)this.coefficients[i].lerp(e.coefficients[i],t);return this}equals(e){for(let t=0;t<9;t++)if(!this.coefficients[t].equals(e.coefficients[t]))return!1;return!0}copy(e){return this.set(e.coefficients)}clone(){return(new this.constructor).copy(this)}fromArray(e,t=0){const i=this.coefficients;for(let n=0;n<9;n++)i[n].fromArray(e,t+3*n);return this}toArray(e=[],t=0){const i=this.coefficients;for(let n=0;n<9;n++)i[n].toArray(e,t+3*n);return e}static getBasisAt(e,t){const i=e.x,n=e.y,r=e.z;t[0]=.282095,t[1]=.488603*n,t[2]=.488603*r,t[3]=.488603*i,t[4]=1.092548*i*n,t[5]=1.092548*n*r,t[6]=.315392*(3*r*r-1),t[7]=1.092548*i*r,t[8]=.546274*(i*i-n*n)}}Fl.prototype.isSphericalHarmonics3=!0;class Bl extends Al{constructor(e=new Fl,t=1){super(void 0,t),this.sh=e}copy(e){return super.copy(e),this.sh.copy(e.sh),this}fromJSON(e){return this.intensity=e.intensity,this.sh.fromArray(e.sh),this}toJSON(e){const t=super.toJSON(e);return t.object.sh=this.sh.toArray(),t}}Bl.prototype.isLightProbe=!0;(class extends kr{constructor(){super(),this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(e){return super.copy(e),this.instanceCount=e.instanceCount,this}clone(){return(new this.constructor).copy(this)}toJSON(){const e=super.toJSON(this);return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}}).prototype.isInstancedBufferGeometry=!0;let Ul;(class extends wl{constructor(e){super(e),"undefined"==typeof createImageBitmap&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),"undefined"==typeof fetch&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(e){return this.options=e,this}load(e,t,i,n){void 0===e&&(e=""),void 0!==this.path&&(e=this.path+e),e=this.manager.resolveURL(e);const r=this,s=bl.get(e);if(void 0!==s)return r.manager.itemStart(e),setTimeout((function(){t&&t(s),r.manager.itemEnd(e)}),0),s;const a={};a.credentials="anonymous"===this.crossOrigin?"same-origin":"include",a.headers=this.requestHeader,fetch(e,a).then((function(e){return e.blob()})).then((function(e){return createImageBitmap(e,Object.assign(r.options,{colorSpaceConversion:"none"}))})).then((function(i){bl.add(e,i),t&&t(i),r.manager.itemEnd(e)})).catch((function(t){n&&n(t),r.manager.itemError(e),r.manager.itemEnd(e)})),r.manager.itemStart(e)}}).prototype.isImageBitmapLoader=!0;const Vl=function(){return void 0===Ul&&(Ul=new(window.AudioContext||window.webkitAudioContext)),Ul};class Hl extends wl{constructor(e){super(e)}load(e,t,i,n){const r=this,s=new Sl(this.manager);s.setResponseType("arraybuffer"),s.setPath(this.path),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(e,(function(i){try{const e=i.slice(0);Vl().decodeAudioData(e,(function(e){t(e)}))}catch(t){n?n(t):console.error(t),r.manager.itemError(e)}}),i,n)}}(class extends Bl{constructor(e,t,i=1){super(void 0,i);const n=(new xr).set(e),r=(new xr).set(t),s=new Ki(n.r,n.g,n.b),a=new Ki(r.r,r.g,r.b),o=Math.sqrt(Math.PI),h=o*Math.sqrt(.75);this.sh.coefficients[0].copy(s).add(a).multiplyScalar(o),this.sh.coefficients[1].copy(s).sub(a).multiplyScalar(h)}}).prototype.isHemisphereLightProbe=!0;(class extends Bl{constructor(e,t=1){super(void 0,t);const i=(new xr).set(e);this.sh.coefficients[0].set(i.r,i.g,i.b).multiplyScalar(2*Math.sqrt(Math.PI))}}).prototype.isAmbientLightProbe=!0;class jl{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=Gl(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let e=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){const t=Gl();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}}function Gl(){return("undefined"==typeof performance?Date:performance).now()}class Wl{constructor(e,t,i){let n,r,s;switch(this.binding=e,this.valueSize=i,t){case"quaternion":n=this._slerp,r=this._slerpAdditive,s=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(6*i),this._workIndex=5;break;case"string":case"bool":n=this._select,r=this._select,s=this._setAdditiveIdentityOther,this.buffer=new Array(5*i);break;default:n=this._lerp,r=this._lerpAdditive,s=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(5*i)}this._mixBufferRegion=n,this._mixBufferRegionAdditive=r,this._setIdentity=s,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(e,t){const i=this.buffer,n=this.valueSize,r=e*n+n;let s=this.cumulativeWeight;if(0===s){for(let e=0;e!==n;++e)i[r+e]=i[e];s=t}else{s+=t;const e=t/s;this._mixBufferRegion(i,r,0,e,n)}this.cumulativeWeight=s}accumulateAdditive(e){const t=this.buffer,i=this.valueSize,n=i*this._addIndex;0===this.cumulativeWeightAdditive&&this._setIdentity(),this._mixBufferRegionAdditive(t,n,0,e,i),this.cumulativeWeightAdditive+=e}apply(e){const t=this.valueSize,i=this.buffer,n=e*t+t,r=this.cumulativeWeight,s=this.cumulativeWeightAdditive,a=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,r<1){const e=t*this._origIndex;this._mixBufferRegion(i,n,e,1-r,t)}s>0&&this._mixBufferRegionAdditive(i,n,this._addIndex*t,1,t);for(let e=t,r=t+t;e!==r;++e)if(i[e]!==i[e+t]){a.setValue(i,n);break}}saveOriginalState(){const e=this.binding,t=this.buffer,i=this.valueSize,n=i*this._origIndex;e.getValue(t,n);for(let e=i,r=n;e!==r;++e)t[e]=t[n+e%i];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const e=3*this.valueSize;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){const e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let i=e;i<t;i++)this.buffer[i]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){const e=this._origIndex*this.valueSize,t=this._addIndex*this.valueSize;for(let i=0;i<this.valueSize;i++)this.buffer[t+i]=this.buffer[e+i]}_select(e,t,i,n,r){if(n>=.5)for(let n=0;n!==r;++n)e[t+n]=e[i+n]}_slerp(e,t,i,n){Ji.slerpFlat(e,t,e,t,e,i,n)}_slerpAdditive(e,t,i,n,r){const s=this._workIndex*r;Ji.multiplyQuaternionsFlat(e,s,e,t,e,i),Ji.slerpFlat(e,t,e,t,e,s,n)}_lerp(e,t,i,n,r){const s=1-n;for(let a=0;a!==r;++a){const r=t+a;e[r]=e[r]*s+e[i+a]*n}}_lerpAdditive(e,t,i,n,r){for(let s=0;s!==r;++s){const r=t+s;e[r]=e[r]+e[i+s]*n}}}const ql="\\[\\]\\.:\\/",Xl=new RegExp("[\\[\\]\\.:\\/]","g"),Zl="[^\\[\\]\\.:\\/]",Yl="[^"+ql.replace("\\.","")+"]",Jl=/((?:WC+[\/:])*)/.source.replace("WC",Zl),Kl=/(WCOD+)?/.source.replace("WCOD",Yl),Ql=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Zl),eu=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Zl),tu=new RegExp("^"+Jl+Kl+Ql+eu+"$"),iu=["material","materials","bones"];class nu{constructor(e,t,i){this.path=t,this.parsedPath=i||nu.parseTrackName(t),this.node=nu.findNode(e,this.parsedPath.nodeName)||e,this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,i){return e&&e.isAnimationObjectGroup?new nu.Composite(e,t,i):new nu(e,t,i)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(Xl,"")}static parseTrackName(e){const t=tu.exec(e);if(!t)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const i={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},n=i.nodeName&&i.nodeName.lastIndexOf(".");if(void 0!==n&&-1!==n){const e=i.nodeName.substring(n+1);-1!==iu.indexOf(e)&&(i.nodeName=i.nodeName.substring(0,n),i.objectName=e)}if(null===i.propertyName||0===i.propertyName.length)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return i}static findNode(e,t){if(!t||""===t||"."===t||-1===t||t===e.name||t===e.uuid)return e;if(e.skeleton){const i=e.skeleton.getBoneByName(t);if(void 0!==i)return i}if(e.children){const i=function(e){for(let n=0;n<e.length;n++){const r=e[n];if(r.name===t||r.uuid===t)return r;const s=i(r.children);if(s)return s}return null},n=i(e.children);if(n)return n}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){const i=this.resolvedProperty;for(let n=0,r=i.length;n!==r;++n)e[t++]=i[n]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){const i=this.resolvedProperty;for(let n=0,r=i.length;n!==r;++n)i[n]=e[t++]}_setValue_array_setNeedsUpdate(e,t){const i=this.resolvedProperty;for(let n=0,r=i.length;n!==r;++n)i[n]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){const i=this.resolvedProperty;for(let n=0,r=i.length;n!==r;++n)i[n]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node;const t=this.parsedPath,i=t.objectName,n=t.propertyName;let r=t.propertyIndex;if(e||(e=nu.findNode(this.rootNode,t.nodeName)||this.rootNode,this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e)return void console.error("THREE.PropertyBinding: Trying to update node for track: "+this.path+" but it wasn't found.");if(i){let n=t.objectIndex;switch(i){case"materials":if(!e.material)return void console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);if(!e.material.materials)return void console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);e=e.material.materials;break;case"bones":if(!e.skeleton)return void console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);e=e.skeleton.bones;for(let t=0;t<e.length;t++)if(e[t].name===n){n=t;break}break;default:if(void 0===e[i])return void console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);e=e[i]}if(void 0!==n){if(void 0===e[n])return void console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);e=e[n]}}const s=e[n];if(void 0===s){const i=t.nodeName;return void console.error("THREE.PropertyBinding: Trying to update property for track: "+i+"."+n+" but it wasn't found.",e)}let a=this.Versioning.None;this.targetObject=e,void 0!==e.needsUpdate?a=this.Versioning.NeedsUpdate:void 0!==e.matrixWorldNeedsUpdate&&(a=this.Versioning.MatrixWorldNeedsUpdate);let o=this.BindingType.Direct;if(void 0!==r){if("morphTargetInfluences"===n){if(!e.geometry)return void console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);if(!e.geometry.isBufferGeometry)return void console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences on THREE.Geometry. Use THREE.BufferGeometry instead.",this);if(!e.geometry.morphAttributes)return void console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);void 0!==e.morphTargetDictionary[r]&&(r=e.morphTargetDictionary[r])}o=this.BindingType.ArrayElement,this.resolvedProperty=s,this.propertyIndex=r}else void 0!==s.fromArray&&void 0!==s.toArray?(o=this.BindingType.HasFromToArray,this.resolvedProperty=s):Array.isArray(s)?(o=this.BindingType.EntireArray,this.resolvedProperty=s):this.propertyName=n;this.getValue=this.GetterByBindingType[o],this.setValue=this.SetterByBindingTypeAndVersioning[o][a]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}nu.Composite=class{constructor(e,t,i){const n=i||nu.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,n)}getValue(e,t){this.bind();const i=this._targetGroup.nCachedObjects_,n=this._bindings[i];void 0!==n&&n.getValue(e,t)}setValue(e,t){const i=this._bindings;for(let n=this._targetGroup.nCachedObjects_,r=i.length;n!==r;++n)i[n].setValue(e,t)}bind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].bind()}unbind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].unbind()}},nu.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},nu.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},nu.prototype.GetterByBindingType=[nu.prototype._getValue_direct,nu.prototype._getValue_array,nu.prototype._getValue_arrayElement,nu.prototype._getValue_toArray],nu.prototype.SetterByBindingTypeAndVersioning=[[nu.prototype._setValue_direct,nu.prototype._setValue_direct_setNeedsUpdate,nu.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[nu.prototype._setValue_array,nu.prototype._setValue_array_setNeedsUpdate,nu.prototype._setValue_array_setMatrixWorldNeedsUpdate],[nu.prototype._setValue_arrayElement,nu.prototype._setValue_arrayElement_setNeedsUpdate,nu.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[nu.prototype._setValue_fromArray,nu.prototype._setValue_fromArray_setNeedsUpdate,nu.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class ru{constructor(e,t,i=null,n=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=i,this.blendMode=n;const r=t.tracks,s=r.length,a=new Array(s),o={endingStart:pi,endingEnd:pi};for(let e=0;e!==s;++e){const t=r[e].createInterpolant(null);a[e]=t,t.settings=o}this._interpolantSettings=o,this._interpolants=a,this._propertyBindings=new Array(s),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=2201,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&0!==this.timeScale&&null===this._startTime&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,i){if(e.fadeOut(t),this.fadeIn(t),i){const i=this._clip.duration,n=e._clip.duration,r=n/i,s=i/n;e.warp(1,r,t),this.warp(s,1,t)}return this}crossFadeTo(e,t,i){return e.crossFadeFrom(this,t,i)}stopFading(){const e=this._weightInterpolant;return null!==e&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,i){const n=this._mixer,r=n.time,s=this.timeScale;let a=this._timeScaleInterpolant;null===a&&(a=n._lendControlInterpolant(),this._timeScaleInterpolant=a);const o=a.parameterPositions,h=a.sampleValues;return o[0]=r,o[1]=r+i,h[0]=e/s,h[1]=t/s,this}stopWarping(){const e=this._timeScaleInterpolant;return null!==e&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,i,n){if(!this.enabled)return void this._updateWeight(e);const r=this._startTime;if(null!==r){const n=(e-r)*i;if(n<0||0===i)return;this._startTime=null,t=i*n}t*=this._updateTimeScale(e);const s=this._updateTime(t),a=this._updateWeight(e);if(a>0){const e=this._interpolants,t=this._propertyBindings;switch(this.blendMode){case 2501:for(let i=0,n=e.length;i!==n;++i)e[i].evaluate(s),t[i].accumulateAdditive(a);break;case gi:default:for(let i=0,r=e.length;i!==r;++i)e[i].evaluate(s),t[i].accumulate(n,a)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;const i=this._weightInterpolant;if(null!==i){const n=i.evaluate(e)[0];t*=n,e>i.parameterPositions[1]&&(this.stopFading(),0===n&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;const i=this._timeScaleInterpolant;if(null!==i){t*=i.evaluate(e)[0],e>i.parameterPositions[1]&&(this.stopWarping(),0===t?this.paused=!0:this.timeScale=t)}}return this._effectiveTimeScale=t,t}_updateTime(e){const t=this._clip.duration,i=this.loop;let n=this.time+e,r=this._loopCount;const s=2202===i;if(0===e)return-1===r?n:s&&1==(1&r)?t-n:n;if(2200===i){-1===r&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(n>=t)n=t;else{if(!(n<0)){this.time=n;break e}n=0}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=n,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(-1===r&&(e>=0?(r=0,this._setEndings(!0,0===this.repetitions,s)):this._setEndings(0===this.repetitions,!0,s)),n>=t||n<0){const i=Math.floor(n/t);n-=t*i,r+=Math.abs(i);const a=this.repetitions-r;if(a<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,n=e>0?t:0,this.time=n,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(1===a){const t=e<0;this._setEndings(t,!t,s)}else this._setEndings(!1,!1,s);this._loopCount=r,this.time=n,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:i})}}else this.time=n;if(s&&1==(1&r))return t-n}return n}_setEndings(e,t,i){const n=this._interpolantSettings;i?(n.endingStart=mi,n.endingEnd=mi):(n.endingStart=e?this.zeroSlopeAtStart?mi:pi:fi,n.endingEnd=t?this.zeroSlopeAtEnd?mi:pi:fi)}_scheduleFading(e,t,i){const n=this._mixer,r=n.time;let s=this._weightInterpolant;null===s&&(s=n._lendControlInterpolant(),this._weightInterpolant=s);const a=s.parameterPositions,o=s.sampleValues;return a[0]=r,o[0]=t,a[1]=r+e,o[1]=i,this}}(class extends Ti{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){const i=e._localRoot||this._root,n=e._clip.tracks,r=n.length,s=e._propertyBindings,a=e._interpolants,o=i.uuid,h=this._bindingsByRootAndName;let c=h[o];void 0===c&&(c={},h[o]=c);for(let e=0;e!==r;++e){const r=n[e],h=r.name;let l=c[h];if(void 0!==l)s[e]=l;else{if(l=s[e],void 0!==l){null===l._cacheIndex&&(++l.referenceCount,this._addInactiveBinding(l,o,h));continue}const n=t&&t._propertyBindings[e].binding.parsedPath;l=new Wl(nu.create(i,h,n),r.ValueTypeName,r.getValueSize()),++l.referenceCount,this._addInactiveBinding(l,o,h),s[e]=l}a[e].resultBuffer=l.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(null===e._cacheIndex){const t=(e._localRoot||this._root).uuid,i=e._clip.uuid,n=this._actionsByClip[i];this._bindAction(e,n&&n.knownActions[0]),this._addInactiveAction(e,i,t)}const t=e._propertyBindings;for(let e=0,i=t.length;e!==i;++e){const i=t[e];0==i.useCount++&&(this._lendBinding(i),i.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){const t=e._propertyBindings;for(let e=0,i=t.length;e!==i;++e){const i=t[e];0==--i.useCount&&(i.restoreOriginalState(),this._takeBackBinding(i))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){const t=e._cacheIndex;return null!==t&&t<this._nActiveActions}_addInactiveAction(e,t,i){const n=this._actions,r=this._actionsByClip;let s=r[t];if(void 0===s)s={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,r[t]=s;else{const t=s.knownActions;e._byClipCacheIndex=t.length,t.push(e)}e._cacheIndex=n.length,n.push(e),s.actionByRoot[i]=e}_removeInactiveAction(e){const t=this._actions,i=t[t.length-1],n=e._cacheIndex;i._cacheIndex=n,t[n]=i,t.pop(),e._cacheIndex=null;const r=e._clip.uuid,s=this._actionsByClip,a=s[r],o=a.knownActions,h=o[o.length-1],c=e._byClipCacheIndex;h._byClipCacheIndex=c,o[c]=h,o.pop(),e._byClipCacheIndex=null;delete a.actionByRoot[(e._localRoot||this._root).uuid],0===o.length&&delete s[r],this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){const t=e._propertyBindings;for(let e=0,i=t.length;e!==i;++e){const i=t[e];0==--i.referenceCount&&this._removeInactiveBinding(i)}}_lendAction(e){const t=this._actions,i=e._cacheIndex,n=this._nActiveActions++,r=t[n];e._cacheIndex=n,t[n]=e,r._cacheIndex=i,t[i]=r}_takeBackAction(e){const t=this._actions,i=e._cacheIndex,n=--this._nActiveActions,r=t[n];e._cacheIndex=n,t[n]=e,r._cacheIndex=i,t[i]=r}_addInactiveBinding(e,t,i){const n=this._bindingsByRootAndName,r=this._bindings;let s=n[t];void 0===s&&(s={},n[t]=s),s[i]=e,e._cacheIndex=r.length,r.push(e)}_removeInactiveBinding(e){const t=this._bindings,i=e.binding,n=i.rootNode.uuid,r=i.path,s=this._bindingsByRootAndName,a=s[n],o=t[t.length-1],h=e._cacheIndex;o._cacheIndex=h,t[h]=o,t.pop(),delete a[r],0===Object.keys(a).length&&delete s[n]}_lendBinding(e){const t=this._bindings,i=e._cacheIndex,n=this._nActiveBindings++,r=t[n];e._cacheIndex=n,t[n]=e,r._cacheIndex=i,t[i]=r}_takeBackBinding(e){const t=this._bindings,i=e._cacheIndex,n=--this._nActiveBindings,r=t[n];e._cacheIndex=n,t[n]=e,r._cacheIndex=i,t[i]=r}_lendControlInterpolant(){const e=this._controlInterpolants,t=this._nActiveControlInterpolants++;let i=e[t];return void 0===i&&(i=new hl(new Float32Array(2),new Float32Array(2),1,this._controlInterpolantsResultBuffer),i.__cacheIndex=t,e[t]=i),i}_takeBackControlInterpolant(e){const t=this._controlInterpolants,i=e.__cacheIndex,n=--this._nActiveControlInterpolants,r=t[n];e.__cacheIndex=n,t[n]=e,r.__cacheIndex=i,t[i]=r}clipAction(e,t,i){const n=t||this._root,r=n.uuid;let s="string"==typeof e?vl.findByName(n,e):e;const a=null!==s?s.uuid:e,o=this._actionsByClip[a];let h=null;if(void 0===i&&(i=null!==s?s.blendMode:gi),void 0!==o){const e=o.actionByRoot[r];if(void 0!==e&&e.blendMode===i)return e;h=o.knownActions[0],null===s&&(s=h._clip)}if(null===s)return null;const c=new ru(this,s,t,i);return this._bindAction(c,h),this._addInactiveAction(c,a,r),c}existingAction(e,t){const i=t||this._root,n=i.uuid,r="string"==typeof e?vl.findByName(i,e):e,s=r?r.uuid:e,a=this._actionsByClip[s];return void 0!==a&&a.actionByRoot[n]||null}stopAllAction(){const e=this._actions;for(let t=this._nActiveActions-1;t>=0;--t)e[t].stop();return this}update(e){e*=this.timeScale;const t=this._actions,i=this._nActiveActions,n=this.time+=e,r=Math.sign(e),s=this._accuIndex^=1;for(let a=0;a!==i;++a){t[a]._update(n,e,r,s)}const a=this._bindings,o=this._nActiveBindings;for(let e=0;e!==o;++e)a[e].apply(s);return this}setTime(e){this.time=0;for(let e=0;e<this._actions.length;e++)this._actions[e].time=0;return this.update(e)}getRoot(){return this._root}uncacheClip(e){const t=this._actions,i=e.uuid,n=this._actionsByClip,r=n[i];if(void 0!==r){const e=r.knownActions;for(let i=0,n=e.length;i!==n;++i){const n=e[i];this._deactivateAction(n);const r=n._cacheIndex,s=t[t.length-1];n._cacheIndex=null,n._byClipCacheIndex=null,s._cacheIndex=r,t[r]=s,t.pop(),this._removeInactiveBindingsForAction(n)}delete n[i]}}uncacheRoot(e){const t=e.uuid,i=this._actionsByClip;for(const e in i){const n=i[e].actionByRoot[t];void 0!==n&&(this._deactivateAction(n),this._removeInactiveAction(n))}const n=this._bindingsByRootAndName[t];if(void 0!==n)for(const e in n){const t=n[e];t.restoreOriginalState(),this._removeInactiveBinding(t)}}uncacheAction(e,t){const i=this.existingAction(e,t);null!==i&&(this._deactivateAction(i),this._removeInactiveAction(i))}}).prototype._controlInterpolantsResultBuffer=new Float32Array(1);(class extends lh{constructor(e,t,i=1){super(e,t),this.meshPerAttribute=i}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}clone(e){const t=super.clone(e);return t.meshPerAttribute=this.meshPerAttribute,t}toJSON(e){const t=super.toJSON(e);return t.isInstancedInterleavedBuffer=!0,t.meshPerAttribute=this.meshPerAttribute,t}}).prototype.isInstancedInterleavedBuffer=!0;class su{constructor(e,t,i=0,n=1/0){this.ray=new In(e,t),this.near=i,this.far=n,this.camera=null,this.layers=new Un,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){t&&t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t&&t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,(t.near+t.far)/(t.near-t.far)).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):console.error("THREE.Raycaster: Unsupported camera type: "+t.type)}intersectObject(e,t=!0,i=[]){return ou(e,this,i,t),i.sort(au),i}intersectObjects(e,t=!0,i=[]){for(let n=0,r=e.length;n<r;n++)ou(e[n],this,i,t);return i.sort(au),i}}function au(e,t){return e.distance-t.distance}function ou(e,t,i,n){if(e.layers.test(t.layers)&&e.raycast(t,i),!0===n){const n=e.children;for(let e=0,r=n.length;e<r;e++)ou(n[e],t,i,!0)}}const hu=new Ki,cu=new Rn,lu=new Rn;function uu(e){const t=[];e&&e.isBone&&t.push(e);for(let i=0;i<e.children.length;i++)t.push.apply(t,uu(e.children[i]));return t}const du=new Float32Array(1);new Int32Array(du.buffer),rc.create=function(e,t){return console.log("THREE.Curve.create() has been deprecated"),e.prototype=Object.create(rc.prototype),e.prototype.constructor=e,e.prototype.getPoint=t,e},Sc.prototype.fromPoints=function(e){return console.warn("THREE.Path: .fromPoints() has been renamed to .setFromPoints()."),this.setFromPoints(e)},class extends Zh{constructor(e=10,t=10,i=4473924,n=8947848){i=new xr(i),n=new xr(n);const r=t/2,s=e/t,a=e/2,o=[],h=[];for(let e=0,c=0,l=-a;e<=t;e++,l+=s){o.push(-a,0,l,a,0,l),o.push(l,0,-a,l,0,a);const t=e===r?i:n;t.toArray(h,c),c+=3,t.toArray(h,c),c+=3,t.toArray(h,c),c+=3,t.toArray(h,c),c+=3}const c=new kr;c.setAttribute("position",new Ar(o,3)),c.setAttribute("color",new Ar(h,3));super(c,new Bh({vertexColors:!0,toneMapped:!1})),this.type="GridHelper"}}.prototype.setColors=function(){console.error("THREE.GridHelper: setColors() has been deprecated, pass them in the constructor instead.")},class extends Zh{constructor(e){const t=uu(e),i=new kr,n=[],r=[],s=new xr(0,0,1),a=new xr(0,1,0);for(let e=0;e<t.length;e++){const i=t[e];i.parent&&i.parent.isBone&&(n.push(0,0,0),n.push(0,0,0),r.push(s.r,s.g,s.b),r.push(a.r,a.g,a.b))}i.setAttribute("position",new Ar(n,3)),i.setAttribute("color",new Ar(r,3));super(i,new Bh({vertexColors:!0,depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0})),this.type="SkeletonHelper",this.isSkeletonHelper=!0,this.root=e,this.bones=t,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1}updateMatrixWorld(e){const t=this.bones,i=this.geometry,n=i.getAttribute("position");lu.copy(this.root.matrixWorld).invert();for(let e=0,i=0;e<t.length;e++){const r=t[e];r.parent&&r.parent.isBone&&(cu.multiplyMatrices(lu,r.matrixWorld),hu.setFromMatrixPosition(cu),n.setXYZ(i,hu.x,hu.y,hu.z),cu.multiplyMatrices(lu,r.parent.matrixWorld),hu.setFromMatrixPosition(cu),n.setXYZ(i+1,hu.x,hu.y,hu.z),i+=2)}i.getAttribute("position").needsUpdate=!0,super.updateMatrixWorld(e)}}.prototype.update=function(){console.error("THREE.SkeletonHelper: update() no longer needs to be called.")},wl.prototype.extractUrlBase=function(e){return console.warn("THREE.Loader: .extractUrlBase() has been deprecated. Use THREE.LoaderUtils.extractUrlBase() instead."),class{static decodeText(e){if("undefined"!=typeof TextDecoder)return(new TextDecoder).decode(e);let t="";for(let i=0,n=e.length;i<n;i++)t+=String.fromCharCode(e[i]);try{return decodeURIComponent(escape(t))}catch(e){return t}}static extractUrlBase(e){const t=e.lastIndexOf("/");return-1===t?"./":e.substr(0,t+1)}static resolveURL(e,t){return"string"!=typeof e||""===e?"":(/^https?:\/\//i.test(t)&&/^\//.test(e)&&(t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e)?e:t+e)}}.extractUrlBase(e)},wl.Handlers={add:function(){console.error("THREE.Loader: Handlers.add() has been removed. Use LoadingManager.addHandler() instead.")},get:function(){console.error("THREE.Loader: Handlers.get() has been removed. Use LoadingManager.getHandler() instead.")}},tn.prototype.center=function(e){return console.warn("THREE.Box3: .center() has been renamed to .getCenter()."),this.getCenter(e)},tn.prototype.empty=function(){return console.warn("THREE.Box3: .empty() has been renamed to .isEmpty()."),this.isEmpty()},tn.prototype.isIntersectionBox=function(e){return console.warn("THREE.Box3: .isIntersectionBox() has been renamed to .intersectsBox()."),this.intersectsBox(e)},tn.prototype.isIntersectionSphere=function(e){return console.warn("THREE.Box3: .isIntersectionSphere() has been renamed to .intersectsSphere()."),this.intersectsSphere(e)},tn.prototype.size=function(e){return console.warn("THREE.Box3: .size() has been renamed to .getSize()."),this.getSize(e)},xn.prototype.empty=function(){return console.warn("THREE.Sphere: .empty() has been renamed to .isEmpty()."),this.isEmpty()},ys.prototype.setFromMatrix=function(e){return console.warn("THREE.Frustum: .setFromMatrix() has been renamed to .setFromProjectionMatrix()."),this.setFromProjectionMatrix(e)},Fi.prototype.flattenToArrayOffset=function(e,t){return console.warn("THREE.Matrix3: .flattenToArrayOffset() has been deprecated. Use .toArray() instead."),this.toArray(e,t)},Fi.prototype.multiplyVector3=function(e){return console.warn("THREE.Matrix3: .multiplyVector3() has been removed. Use vector.applyMatrix3( matrix ) instead."),e.applyMatrix3(this)},Fi.prototype.multiplyVector3Array=function(){console.error("THREE.Matrix3: .multiplyVector3Array() has been removed.")},Fi.prototype.applyToBufferAttribute=function(e){return console.warn("THREE.Matrix3: .applyToBufferAttribute() has been removed. Use attribute.applyMatrix3( matrix ) instead."),e.applyMatrix3(this)},Fi.prototype.applyToVector3Array=function(){console.error("THREE.Matrix3: .applyToVector3Array() has been removed.")},Fi.prototype.getInverse=function(e){return console.warn("THREE.Matrix3: .getInverse() has been removed. Use matrixInv.copy( matrix ).invert(); instead."),this.copy(e).invert()},Rn.prototype.extractPosition=function(e){return console.warn("THREE.Matrix4: .extractPosition() has been renamed to .copyPosition()."),this.copyPosition(e)},Rn.prototype.flattenToArrayOffset=function(e,t){return console.warn("THREE.Matrix4: .flattenToArrayOffset() has been deprecated. Use .toArray() instead."),this.toArray(e,t)},Rn.prototype.getPosition=function(){return console.warn("THREE.Matrix4: .getPosition() has been removed. Use Vector3.setFromMatrixPosition( matrix ) instead."),(new Ki).setFromMatrixColumn(this,3)},Rn.prototype.setRotationFromQuaternion=function(e){return console.warn("THREE.Matrix4: .setRotationFromQuaternion() has been renamed to .makeRotationFromQuaternion()."),this.makeRotationFromQuaternion(e)},Rn.prototype.multiplyToArray=function(){console.warn("THREE.Matrix4: .multiplyToArray() has been removed.")},Rn.prototype.multiplyVector3=function(e){return console.warn("THREE.Matrix4: .multiplyVector3() has been removed. Use vector.applyMatrix4( matrix ) instead."),e.applyMatrix4(this)},Rn.prototype.multiplyVector4=function(e){return console.warn("THREE.Matrix4: .multiplyVector4() has been removed. Use vector.applyMatrix4( matrix ) instead."),e.applyMatrix4(this)},Rn.prototype.multiplyVector3Array=function(){console.error("THREE.Matrix4: .multiplyVector3Array() has been removed.")},Rn.prototype.rotateAxis=function(e){console.warn("THREE.Matrix4: .rotateAxis() has been removed. Use Vector3.transformDirection( matrix ) instead."),e.transformDirection(this)},Rn.prototype.crossVector=function(e){return console.warn("THREE.Matrix4: .crossVector() has been removed. Use vector.applyMatrix4( matrix ) instead."),e.applyMatrix4(this)},Rn.prototype.translate=function(){console.error("THREE.Matrix4: .translate() has been removed.")},Rn.prototype.rotateX=function(){console.error("THREE.Matrix4: .rotateX() has been removed.")},Rn.prototype.rotateY=function(){console.error("THREE.Matrix4: .rotateY() has been removed.")},Rn.prototype.rotateZ=function(){console.error("THREE.Matrix4: .rotateZ() has been removed.")},Rn.prototype.rotateByAxis=function(){console.error("THREE.Matrix4: .rotateByAxis() has been removed.")},Rn.prototype.applyToBufferAttribute=function(e){return console.warn("THREE.Matrix4: .applyToBufferAttribute() has been removed. Use attribute.applyMatrix4( matrix ) instead."),e.applyMatrix4(this)},Rn.prototype.applyToVector3Array=function(){console.error("THREE.Matrix4: .applyToVector3Array() has been removed.")},Rn.prototype.makeFrustum=function(e,t,i,n,r,s){return console.warn("THREE.Matrix4: .makeFrustum() has been removed. Use .makePerspective( left, right, top, bottom, near, far ) instead."),this.makePerspective(e,t,n,i,r,s)},Rn.prototype.getInverse=function(e){return console.warn("THREE.Matrix4: .getInverse() has been removed. Use matrixInv.copy( matrix ).invert(); instead."),this.copy(e).invert()},gs.prototype.isIntersectionLine=function(e){return console.warn("THREE.Plane: .isIntersectionLine() has been renamed to .intersectsLine()."),this.intersectsLine(e)},Ji.prototype.multiplyVector3=function(e){return console.warn("THREE.Quaternion: .multiplyVector3() has been removed. Use is now vector.applyQuaternion( quaternion ) instead."),e.applyQuaternion(this)},Ji.prototype.inverse=function(){return console.warn("THREE.Quaternion: .inverse() has been renamed to invert()."),this.invert()},In.prototype.isIntersectionBox=function(e){return console.warn("THREE.Ray: .isIntersectionBox() has been renamed to .intersectsBox()."),this.intersectsBox(e)},In.prototype.isIntersectionPlane=function(e){return console.warn("THREE.Ray: .isIntersectionPlane() has been renamed to .intersectsPlane()."),this.intersectsPlane(e)},In.prototype.isIntersectionSphere=function(e){return console.warn("THREE.Ray: .isIntersectionSphere() has been renamed to .intersectsSphere()."),this.intersectsSphere(e)},dr.prototype.area=function(){return console.warn("THREE.Triangle: .area() has been renamed to .getArea()."),this.getArea()},dr.prototype.barycoordFromPoint=function(e,t){return console.warn("THREE.Triangle: .barycoordFromPoint() has been renamed to .getBarycoord()."),this.getBarycoord(e,t)},dr.prototype.midpoint=function(e){return console.warn("THREE.Triangle: .midpoint() has been renamed to .getMidpoint()."),this.getMidpoint(e)},dr.prototypenormal=function(e){return console.warn("THREE.Triangle: .normal() has been renamed to .getNormal()."),this.getNormal(e)},dr.prototype.plane=function(e){return console.warn("THREE.Triangle: .plane() has been renamed to .getPlane()."),this.getPlane(e)},dr.barycoordFromPoint=function(e,t,i,n,r){return console.warn("THREE.Triangle: .barycoordFromPoint() has been renamed to .getBarycoord()."),dr.getBarycoord(e,t,i,n,r)},dr.normal=function(e,t,i,n){return console.warn("THREE.Triangle: .normal() has been renamed to .getNormal()."),dr.getNormal(e,t,i,n)},Tc.prototype.extractAllPoints=function(e){return console.warn("THREE.Shape: .extractAllPoints() has been removed. Use .extractPoints() instead."),this.extractPoints(e)},Tc.prototype.extrude=function(e){return console.warn("THREE.Shape: .extrude() has been removed. Use ExtrudeGeometry() instead."),new el(this,e)},Tc.prototype.makeGeometry=function(e){return console.warn("THREE.Shape: .makeGeometry() has been removed. Use ShapeGeometry() instead."),new il(this,e)},zi.prototype.fromAttribute=function(e,t,i){return console.warn("THREE.Vector2: .fromAttribute() has been renamed to .fromBufferAttribute()."),this.fromBufferAttribute(e,t,i)},zi.prototype.distanceToManhattan=function(e){return console.warn("THREE.Vector2: .distanceToManhattan() has been renamed to .manhattanDistanceTo()."),this.manhattanDistanceTo(e)},zi.prototype.lengthManhattan=function(){return console.warn("THREE.Vector2: .lengthManhattan() has been renamed to .manhattanLength()."),this.manhattanLength()},Ki.prototype.setEulerFromRotationMatrix=function(){console.error("THREE.Vector3: .setEulerFromRotationMatrix() has been removed. Use Euler.setFromRotationMatrix() instead.")},Ki.prototype.setEulerFromQuaternion=function(){console.error("THREE.Vector3: .setEulerFromQuaternion() has been removed. Use Euler.setFromQuaternion() instead.")},Ki.prototype.getPositionFromMatrix=function(e){return console.warn("THREE.Vector3: .getPositionFromMatrix() has been renamed to .setFromMatrixPosition()."),this.setFromMatrixPosition(e)},Ki.prototype.getScaleFromMatrix=function(e){return console.warn("THREE.Vector3: .getScaleFromMatrix() has been renamed to .setFromMatrixScale()."),this.setFromMatrixScale(e)},Ki.prototype.getColumnFromMatrix=function(e,t){return console.warn("THREE.Vector3: .getColumnFromMatrix() has been renamed to .setFromMatrixColumn()."),this.setFromMatrixColumn(t,e)},Ki.prototype.applyProjection=function(e){return console.warn("THREE.Vector3: .applyProjection() has been removed. Use .applyMatrix4( m ) instead."),this.applyMatrix4(e)},Ki.prototype.fromAttribute=function(e,t,i){return console.warn("THREE.Vector3: .fromAttribute() has been renamed to .fromBufferAttribute()."),this.fromBufferAttribute(e,t,i)},Ki.prototype.distanceToManhattan=function(e){return console.warn("THREE.Vector3: .distanceToManhattan() has been renamed to .manhattanDistanceTo()."),this.manhattanDistanceTo(e)},Ki.prototype.lengthManhattan=function(){return console.warn("THREE.Vector3: .lengthManhattan() has been renamed to .manhattanLength()."),this.manhattanLength()},Xi.prototype.fromAttribute=function(e,t,i){return console.warn("THREE.Vector4: .fromAttribute() has been renamed to .fromBufferAttribute()."),this.fromBufferAttribute(e,t,i)},Xi.prototype.lengthManhattan=function(){return console.warn("THREE.Vector4: .lengthManhattan() has been renamed to .manhattanLength()."),this.manhattanLength()},tr.prototype.getChildByName=function(e){return console.warn("THREE.Object3D: .getChildByName() has been renamed to .getObjectByName()."),this.getObjectByName(e)},tr.prototype.renderDepth=function(){console.warn("THREE.Object3D: .renderDepth has been removed. Use .renderOrder, instead.")},tr.prototype.translate=function(e,t){return console.warn("THREE.Object3D: .translate() has been removed. Use .translateOnAxis( axis, distance ) instead."),this.translateOnAxis(t,e)},tr.prototype.getWorldRotation=function(){console.error("THREE.Object3D: .getWorldRotation() has been removed. Use THREE.Object3D.getWorldQuaternion( target ) instead.")},tr.prototype.applyMatrix=function(e){return console.warn("THREE.Object3D: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(e)},Object.defineProperties(tr.prototype,{eulerOrder:{get:function(){return console.warn("THREE.Object3D: .eulerOrder is now .rotation.order."),this.rotation.order},set:function(e){console.warn("THREE.Object3D: .eulerOrder is now .rotation.order."),this.rotation.order=e}},useQuaternion:{get:function(){console.warn("THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.")},set:function(){console.warn("THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.")}}}),es.prototype.setDrawMode=function(){console.error("THREE.Mesh: .setDrawMode() has been removed. The renderer now always assumes THREE.TrianglesDrawMode. Transform your geometry via BufferGeometryUtils.toTrianglesDrawMode() if necessary.")},Object.defineProperties(es.prototype,{drawMode:{get:function(){return console.error("THREE.Mesh: .drawMode has been removed. The renderer now always assumes THREE.TrianglesDrawMode."),0},set:function(){console.error("THREE.Mesh: .drawMode has been removed. The renderer now always assumes THREE.TrianglesDrawMode. Transform your geometry via BufferGeometryUtils.toTrianglesDrawMode() if necessary.")}}}),Nh.prototype.initBones=function(){console.error("THREE.SkinnedMesh: initBones() has been removed.")},hs.prototype.setLens=function(e,t){console.warn("THREE.PerspectiveCamera.setLens is deprecated. Use .setFocalLength and .filmGauge for a photographic setup."),void 0!==t&&(this.filmGauge=t),this.setFocalLength(e)},Object.defineProperties(Al.prototype,{onlyShadow:{set:function(){console.warn("THREE.Light: .onlyShadow has been removed.")}},shadowCameraFov:{set:function(e){console.warn("THREE.Light: .shadowCameraFov is now .shadow.camera.fov."),this.shadow.camera.fov=e}},shadowCameraLeft:{set:function(e){console.warn("THREE.Light: .shadowCameraLeft is now .shadow.camera.left."),this.shadow.camera.left=e}},shadowCameraRight:{set:function(e){console.warn("THREE.Light: .shadowCameraRight is now .shadow.camera.right."),this.shadow.camera.right=e}},shadowCameraTop:{set:function(e){console.warn("THREE.Light: .shadowCameraTop is now .shadow.camera.top."),this.shadow.camera.top=e}},shadowCameraBottom:{set:function(e){console.warn("THREE.Light: .shadowCameraBottom is now .shadow.camera.bottom."),this.shadow.camera.bottom=e}},shadowCameraNear:{set:function(e){console.warn("THREE.Light: .shadowCameraNear is now .shadow.camera.near."),this.shadow.camera.near=e}},shadowCameraFar:{set:function(e){console.warn("THREE.Light: .shadowCameraFar is now .shadow.camera.far."),this.shadow.camera.far=e}},shadowCameraVisible:{set:function(){console.warn("THREE.Light: .shadowCameraVisible has been removed. Use new THREE.CameraHelper( light.shadow.camera ) instead.")}},shadowBias:{set:function(e){console.warn("THREE.Light: .shadowBias is now .shadow.bias."),this.shadow.bias=e}},shadowDarkness:{set:function(){console.warn("THREE.Light: .shadowDarkness has been removed.")}},shadowMapWidth:{set:function(e){console.warn("THREE.Light: .shadowMapWidth is now .shadow.mapSize.width."),this.shadow.mapSize.width=e}},shadowMapHeight:{set:function(e){console.warn("THREE.Light: .shadowMapHeight is now .shadow.mapSize.height."),this.shadow.mapSize.height=e}}}),Object.defineProperties(Tr.prototype,{length:{get:function(){return console.warn("THREE.BufferAttribute: .length has been deprecated. Use .count instead."),this.array.length}},dynamic:{get:function(){return console.warn("THREE.BufferAttribute: .dynamic has been deprecated. Use .usage instead."),this.usage===Mi},set:function(){console.warn("THREE.BufferAttribute: .dynamic has been deprecated. Use .usage instead."),this.setUsage(Mi)}}}),Tr.prototype.setDynamic=function(e){return console.warn("THREE.BufferAttribute: .setDynamic() has been deprecated. Use .setUsage() instead."),this.setUsage(!0===e?Mi:wi),this},Tr.prototype.copyIndicesArray=function(){console.error("THREE.BufferAttribute: .copyIndicesArray() has been removed.")},Tr.prototype.setArray=function(){console.error("THREE.BufferAttribute: .setArray has been removed. Use BufferGeometry .setAttribute to replace/resize attribute buffers")},kr.prototype.addIndex=function(e){console.warn("THREE.BufferGeometry: .addIndex() has been renamed to .setIndex()."),this.setIndex(e)},kr.prototype.addAttribute=function(e,t){return console.warn("THREE.BufferGeometry: .addAttribute() has been renamed to .setAttribute()."),t&&t.isBufferAttribute||t&&t.isInterleavedBufferAttribute?"index"===e?(console.warn("THREE.BufferGeometry.addAttribute: Use .setIndex() for index attribute."),this.setIndex(t),this):this.setAttribute(e,t):(console.warn("THREE.BufferGeometry: .addAttribute() now expects ( name, attribute )."),this.setAttribute(e,new Tr(arguments[1],arguments[2])))},kr.prototype.addDrawCall=function(e,t,i){void 0!==i&&console.warn("THREE.BufferGeometry: .addDrawCall() no longer supports indexOffset."),console.warn("THREE.BufferGeometry: .addDrawCall() is now .addGroup()."),this.addGroup(e,t)},kr.prototype.clearDrawCalls=function(){console.warn("THREE.BufferGeometry: .clearDrawCalls() is now .clearGroups()."),this.clearGroups()},kr.prototype.computeOffsets=function(){console.warn("THREE.BufferGeometry: .computeOffsets() has been removed.")},kr.prototype.removeAttribute=function(e){return console.warn("THREE.BufferGeometry: .removeAttribute() has been renamed to .deleteAttribute()."),this.deleteAttribute(e)},kr.prototype.applyMatrix=function(e){return console.warn("THREE.BufferGeometry: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(e)},Object.defineProperties(kr.prototype,{drawcalls:{get:function(){return console.error("THREE.BufferGeometry: .drawcalls has been renamed to .groups."),this.groups}},offsets:{get:function(){return console.warn("THREE.BufferGeometry: .offsets has been renamed to .groups."),this.groups}}}),lh.prototype.setDynamic=function(e){return console.warn("THREE.InterleavedBuffer: .setDynamic() has been deprecated. Use .setUsage() instead."),this.setUsage(!0===e?Mi:wi),this},lh.prototype.setArray=function(){console.error("THREE.InterleavedBuffer: .setArray has been removed. Use BufferGeometry .setAttribute to replace/resize attribute buffers")},el.prototype.getArrays=function(){console.error("THREE.ExtrudeGeometry: .getArrays() has been removed.")},el.prototype.addShapeList=function(){console.error("THREE.ExtrudeGeometry: .addShapeList() has been removed.")},el.prototype.addShape=function(){console.error("THREE.ExtrudeGeometry: .addShape() has been removed.")},ch.prototype.dispose=function(){console.error("THREE.Scene: .dispose() has been removed.")},Object.defineProperties(mr.prototype,{wrapAround:{get:function(){console.warn("THREE.Material: .wrapAround has been removed.")},set:function(){console.warn("THREE.Material: .wrapAround has been removed.")}},overdraw:{get:function(){console.warn("THREE.Material: .overdraw has been removed.")},set:function(){console.warn("THREE.Material: .overdraw has been removed.")}},wrapRGB:{get:function(){return console.warn("THREE.Material: .wrapRGB has been removed."),new xr}},shading:{get:function(){console.error("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead.")},set:function(e){console.warn("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead."),this.flatShading=1===e}},stencilMask:{get:function(){return console.warn("THREE."+this.type+": .stencilMask has been removed. Use .stencilFuncMask instead."),this.stencilFuncMask},set:function(e){console.warn("THREE."+this.type+": .stencilMask has been removed. Use .stencilFuncMask instead."),this.stencilFuncMask=e}},vertexTangents:{get:function(){console.warn("THREE."+this.type+": .vertexTangents has been removed.")},set:function(){console.warn("THREE."+this.type+": .vertexTangents has been removed.")}}}),Object.defineProperties(as.prototype,{derivatives:{get:function(){return console.warn("THREE.ShaderMaterial: .derivatives has been moved to .extensions.derivatives."),this.extensions.derivatives},set:function(e){console.warn("THREE. ShaderMaterial: .derivatives has been moved to .extensions.derivatives."),this.extensions.derivatives=e}}}),hh.prototype.clearTarget=function(e,t,i,n){console.warn("THREE.WebGLRenderer: .clearTarget() has been deprecated. Use .setRenderTarget() and .clear() instead."),this.setRenderTarget(e),this.clear(t,i,n)},hh.prototype.animate=function(e){console.warn("THREE.WebGLRenderer: .animate() is now .setAnimationLoop()."),this.setAnimationLoop(e)},hh.prototype.getCurrentRenderTarget=function(){return console.warn("THREE.WebGLRenderer: .getCurrentRenderTarget() is now .getRenderTarget()."),this.getRenderTarget()},hh.prototype.getMaxAnisotropy=function(){return console.warn("THREE.WebGLRenderer: .getMaxAnisotropy() is now .capabilities.getMaxAnisotropy()."),this.capabilities.getMaxAnisotropy()},hh.prototype.getPrecision=function(){return console.warn("THREE.WebGLRenderer: .getPrecision() is now .capabilities.precision."),this.capabilities.precision},hh.prototype.resetGLState=function(){return console.warn("THREE.WebGLRenderer: .resetGLState() is now .state.reset()."),this.state.reset()},hh.prototype.supportsFloatTextures=function(){return console.warn("THREE.WebGLRenderer: .supportsFloatTextures() is now .extensions.get( 'OES_texture_float' )."),this.extensions.get("OES_texture_float")},hh.prototype.supportsHalfFloatTextures=function(){return console.warn("THREE.WebGLRenderer: .supportsHalfFloatTextures() is now .extensions.get( 'OES_texture_half_float' )."),this.extensions.get("OES_texture_half_float")},hh.prototype.supportsStandardDerivatives=function(){return console.warn("THREE.WebGLRenderer: .supportsStandardDerivatives() is now .extensions.get( 'OES_standard_derivatives' )."),this.extensions.get("OES_standard_derivatives")},hh.prototype.supportsCompressedTextureS3TC=function(){return console.warn("THREE.WebGLRenderer: .supportsCompressedTextureS3TC() is now .extensions.get( 'WEBGL_compressed_texture_s3tc' )."),this.extensions.get("WEBGL_compressed_texture_s3tc")},hh.prototype.supportsCompressedTexturePVRTC=function(){return console.warn("THREE.WebGLRenderer: .supportsCompressedTexturePVRTC() is now .extensions.get( 'WEBGL_compressed_texture_pvrtc' )."),this.extensions.get("WEBGL_compressed_texture_pvrtc")},hh.prototype.supportsBlendMinMax=function(){return console.warn("THREE.WebGLRenderer: .supportsBlendMinMax() is now .extensions.get( 'EXT_blend_minmax' )."),this.extensions.get("EXT_blend_minmax")},hh.prototype.supportsVertexTextures=function(){return console.warn("THREE.WebGLRenderer: .supportsVertexTextures() is now .capabilities.vertexTextures."),this.capabilities.vertexTextures},hh.prototype.supportsInstancedArrays=function(){return console.warn("THREE.WebGLRenderer: .supportsInstancedArrays() is now .extensions.get( 'ANGLE_instanced_arrays' )."),this.extensions.get("ANGLE_instanced_arrays")},hh.prototype.enableScissorTest=function(e){console.warn("THREE.WebGLRenderer: .enableScissorTest() is now .setScissorTest()."),this.setScissorTest(e)},hh.prototype.initMaterial=function(){console.warn("THREE.WebGLRenderer: .initMaterial() has been removed.")},hh.prototype.addPrePlugin=function(){console.warn("THREE.WebGLRenderer: .addPrePlugin() has been removed.")},hh.prototype.addPostPlugin=function(){console.warn("THREE.WebGLRenderer: .addPostPlugin() has been removed.")},hh.prototype.updateShadowMap=function(){console.warn("THREE.WebGLRenderer: .updateShadowMap() has been removed.")},hh.prototype.setFaceCulling=function(){console.warn("THREE.WebGLRenderer: .setFaceCulling() has been removed.")},hh.prototype.allocTextureUnit=function(){console.warn("THREE.WebGLRenderer: .allocTextureUnit() has been removed.")},hh.prototype.setTexture=function(){console.warn("THREE.WebGLRenderer: .setTexture() has been removed.")},hh.prototype.setTexture2D=function(){console.warn("THREE.WebGLRenderer: .setTexture2D() has been removed.")},hh.prototype.setTextureCube=function(){console.warn("THREE.WebGLRenderer: .setTextureCube() has been removed.")},hh.prototype.getActiveMipMapLevel=function(){return console.warn("THREE.WebGLRenderer: .getActiveMipMapLevel() is now .getActiveMipmapLevel()."),this.getActiveMipmapLevel()},Object.defineProperties(hh.prototype,{shadowMapEnabled:{get:function(){return this.shadowMap.enabled},set:function(e){console.warn("THREE.WebGLRenderer: .shadowMapEnabled is now .shadowMap.enabled."),this.shadowMap.enabled=e}},shadowMapType:{get:function(){return this.shadowMap.type},set:function(e){console.warn("THREE.WebGLRenderer: .shadowMapType is now .shadowMap.type."),this.shadowMap.type=e}},shadowMapCullFace:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMapCullFace has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMapCullFace has been removed. Set Material.shadowSide instead.")}},context:{get:function(){return console.warn("THREE.WebGLRenderer: .context has been removed. Use .getContext() instead."),this.getContext()}},vr:{get:function(){return console.warn("THREE.WebGLRenderer: .vr has been renamed to .xr"),this.xr}},gammaInput:{get:function(){return console.warn("THREE.WebGLRenderer: .gammaInput has been removed. Set the encoding for textures via Texture.encoding instead."),!1},set:function(){console.warn("THREE.WebGLRenderer: .gammaInput has been removed. Set the encoding for textures via Texture.encoding instead.")}},gammaOutput:{get:function(){return console.warn("THREE.WebGLRenderer: .gammaOutput has been removed. Set WebGLRenderer.outputEncoding instead."),!1},set:function(e){console.warn("THREE.WebGLRenderer: .gammaOutput has been removed. Set WebGLRenderer.outputEncoding instead."),this.outputEncoding=!0===e?vi:_i}},toneMappingWhitePoint:{get:function(){return console.warn("THREE.WebGLRenderer: .toneMappingWhitePoint has been removed."),1},set:function(){console.warn("THREE.WebGLRenderer: .toneMappingWhitePoint has been removed.")}}}),Object.defineProperties(Ko.prototype,{cullFace:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMap.cullFace has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMap.cullFace has been removed. Set Material.shadowSide instead.")}},renderReverseSided:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderReverseSided has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderReverseSided has been removed. Set Material.shadowSide instead.")}},renderSingleSided:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderSingleSided has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderSingleSided has been removed. Set Material.shadowSide instead.")}}}),Object.defineProperties(Zi.prototype,{wrapS:{get:function(){return console.warn("THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS."),this.texture.wrapS},set:function(e){console.warn("THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS."),this.texture.wrapS=e}},wrapT:{get:function(){return console.warn("THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT."),this.texture.wrapT},set:function(e){console.warn("THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT."),this.texture.wrapT=e}},magFilter:{get:function(){return console.warn("THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter."),this.texture.magFilter},set:function(e){console.warn("THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter."),this.texture.magFilter=e}},minFilter:{get:function(){return console.warn("THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter."),this.texture.minFilter},set:function(e){console.warn("THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter."),this.texture.minFilter=e}},anisotropy:{get:function(){return console.warn("THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy."),this.texture.anisotropy},set:function(e){console.warn("THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy."),this.texture.anisotropy=e}},offset:{get:function(){return console.warn("THREE.WebGLRenderTarget: .offset is now .texture.offset."),this.texture.offset},set:function(e){console.warn("THREE.WebGLRenderTarget: .offset is now .texture.offset."),this.texture.offset=e}},repeat:{get:function(){return console.warn("THREE.WebGLRenderTarget: .repeat is now .texture.repeat."),this.texture.repeat},set:function(e){console.warn("THREE.WebGLRenderTarget: .repeat is now .texture.repeat."),this.texture.repeat=e}},format:{get:function(){return console.warn("THREE.WebGLRenderTarget: .format is now .texture.format."),this.texture.format},set:function(e){console.warn("THREE.WebGLRenderTarget: .format is now .texture.format."),this.texture.format=e}},type:{get:function(){return console.warn("THREE.WebGLRenderTarget: .type is now .texture.type."),this.texture.type},set:function(e){console.warn("THREE.WebGLRenderTarget: .type is now .texture.type."),this.texture.type=e}},generateMipmaps:{get:function(){return console.warn("THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps."),this.texture.generateMipmaps},set:function(e){console.warn("THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps."),this.texture.generateMipmaps=e}}}),class extends tr{constructor(e){super(),this.type="Audio",this.listener=e,this.context=e.context,this.gain=this.context.createGain(),this.gain.connect(e.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.source=null,this.sourceType="empty",this._startedAt=0,this._progress=0,this._connected=!1,this.filters=[]}getOutput(){return this.gain}setNodeSource(e){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=e,this.connect(),this}setMediaElementSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(e),this.connect(),this}setMediaStreamSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(e),this.connect(),this}setBuffer(e){return this.buffer=e,this.sourceType="buffer",this.autoplay&&this.play(),this}play(e=0){if(!0===this.isPlaying)return void console.warn("THREE.Audio: Audio is already playing.");if(!1===this.hasPlaybackControl)return void console.warn("THREE.Audio: this Audio has no playback control.");this._startedAt=this.context.currentTime+e;const t=this.context.createBufferSource();return t.buffer=this.buffer,t.loop=this.loop,t.loopStart=this.loopStart,t.loopEnd=this.loopEnd,t.onended=this.onEnded.bind(this),t.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=t,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){if(!1!==this.hasPlaybackControl)return!0===this.isPlaying&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,!0===this.loop&&(this._progress=this._progress%(this.duration||this.buffer.duration)),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this;console.warn("THREE.Audio: this Audio has no playback control.")}stop(){if(!1!==this.hasPlaybackControl)return this._progress=0,this.source.stop(),this.source.onended=null,this.isPlaying=!1,this;console.warn("THREE.Audio: this Audio has no playback control.")}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let e=1,t=this.filters.length;e<t;e++)this.filters[e-1].connect(this.filters[e]);this.filters[this.filters.length-1].connect(this.getOutput())}else this.source.connect(this.getOutput());return this._connected=!0,this}disconnect(){if(this.filters.length>0){this.source.disconnect(this.filters[0]);for(let e=1,t=this.filters.length;e<t;e++)this.filters[e-1].disconnect(this.filters[e]);this.filters[this.filters.length-1].disconnect(this.getOutput())}else this.source.disconnect(this.getOutput());return this._connected=!1,this}getFilters(){return this.filters}setFilters(e){return e||(e=[]),!0===this._connected?(this.disconnect(),this.filters=e.slice(),this.connect()):this.filters=e.slice(),this}setDetune(e){if(this.detune=e,void 0!==this.source.detune)return!0===this.isPlaying&&this.source.detune.setTargetAtTime(this.detune,this.context.currentTime,.01),this}getDetune(){return this.detune}getFilter(){return this.getFilters()[0]}setFilter(e){return this.setFilters(e?[e]:[])}setPlaybackRate(e){if(!1!==this.hasPlaybackControl)return this.playbackRate=e,!0===this.isPlaying&&this.source.playbackRate.setTargetAtTime(this.playbackRate,this.context.currentTime,.01),this;console.warn("THREE.Audio: this Audio has no playback control.")}getPlaybackRate(){return this.playbackRate}onEnded(){this.isPlaying=!1}getLoop(){return!1===this.hasPlaybackControl?(console.warn("THREE.Audio: this Audio has no playback control."),!1):this.loop}setLoop(e){if(!1!==this.hasPlaybackControl)return this.loop=e,!0===this.isPlaying&&(this.source.loop=this.loop),this;console.warn("THREE.Audio: this Audio has no playback control.")}setLoopStart(e){return this.loopStart=e,this}setLoopEnd(e){return this.loopEnd=e,this}getVolume(){return this.gain.gain.value}setVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}}.prototype.load=function(e){console.warn("THREE.Audio: .load has been deprecated. Use THREE.AudioLoader instead.");const t=this;return(new Hl).load(e,(function(e){t.setBuffer(e)})),this},ls.prototype.updateCubeMap=function(e,t){return console.warn("THREE.CubeCamera: .updateCubeMap() is now .update()."),this.update(e,t)},ls.prototype.clear=function(e,t,i,n){return console.warn("THREE.CubeCamera: .clear() is now .renderTarget.clear()."),this.renderTarget.clear(e,t,i,n)},ji.crossOrigin=void 0,ji.loadTexture=function(e,t,i,n){console.warn("THREE.ImageUtils.loadTexture has been deprecated. Use THREE.TextureLoader() instead.");const r=new El;r.setCrossOrigin(this.crossOrigin);const s=r.load(e,i,void 0,n);return t&&(s.mapping=t),s},ji.loadTextureCube=function(e,t,i,n){console.warn("THREE.ImageUtils.loadTextureCube has been deprecated. Use THREE.CubeTextureLoader() instead.");const r=new Cl;r.setCrossOrigin(this.crossOrigin);const s=r.load(e,i,void 0,n);return t&&(s.mapping=t),s},ji.loadCompressedTexture=function(){console.error("THREE.ImageUtils.loadCompressedTexture has been removed. Use THREE.DDSLoader instead.")},ji.loadCompressedTextureCube=function(){console.error("THREE.ImageUtils.loadCompressedTextureCube has been removed. Use THREE.DDSLoader instead.")},"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:"134"}})),"undefined"!=typeof window&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__="134");const pu=Math.PI/180,mu=180/Math.PI,fu=6378137,gu=6356752.31424518;function _u(e,t,i,n,r,s){const a=xu(e,t,i);return yu(a[0],a[1],a[2],n,r,s)}function vu(e,t,i,n,r,s){const a=bu(e,t,i,n,r,s);return wu(a[0],a[1],a[2])}function yu(e,t,i,n,r,s){const a=xu(n,r,s),o=[e-a[0],t-a[1],i-a[2]];n*=pu,r*=pu;const h=Math.cos(n),c=Math.sin(n),l=Math.cos(r),u=Math.sin(r);return[-c*o[0]+h*o[1],-u*h*o[0]-u*c*o[1]+l*o[2],l*h*o[0]+l*c*o[1]+u*o[2]]}function bu(e,t,i,n,r,s){const a=xu(n,r,s);n*=pu,r*=pu;const o=Math.cos(n),h=Math.sin(n),c=Math.cos(r),l=Math.sin(r);return[-h*e-l*o*t+c*o*i+a[0],o*e-l*h*t+c*h*i+a[1],c*t+l*i+a[2]]}function xu(e,t,i){const n=fu,r=gu;e*=pu,t*=pu;const s=Math.cos(e),a=Math.sin(e),o=Math.cos(t),h=Math.sin(t),c=n*n,l=r*r,u=1/Math.sqrt(c*o*o+l*h*h),d=(c*u+i)*o;return[d*s,d*a,(l*u+i)*h]}function wu(e,t,i){const n=fu,r=gu,s=n*n,a=r*r,o=s-a,h=Math.sqrt(o/s),c=Math.sqrt(o/a),l=Math.sqrt(e*e+t*t),u=Math.atan2(i*n,l*r),d=Math.sin(u),p=Math.cos(u),m=Math.atan2(t,e),f=Math.atan2(i+c*c*r*d*d*d,l-h*h*n*p*p*p),g=Math.sin(f),_=Math.cos(f),v=n/Math.sqrt(1-h*h*g*g);return[m*mu,f*mu,l/_-v]}class Mu{boundingBoxCorners(e,t){const i=vu(-t,-t,0,e.lng,e.lat,0),n=vu(t,t,0,e.lng,e.lat,0);return[{lat:i[1],lng:i[0]},{lat:n[1],lng:n[0]}]}rotationFromCompass(e,t){let i=0,n=0,r=0;switch(t){case 1:i=Math.PI/2;break;case 3:i=-Math.PI/2,r=Math.PI;break;case 6:n=-Math.PI/2,r=-Math.PI/2;break;case 8:n=Math.PI/2,r=Math.PI/2}const s=(new Rn).makeRotationZ(r),a=new Bn(i,n,e*Math.PI/180,"XYZ"),o=(new Rn).makeRotationFromEuler(a),h=(new Xi).setAxisAngleFromRotationMatrix(o.multiply(s));return h.multiplyScalar(h.w).toArray().slice(0,3)}}class Su{constructor(e){if(!e)throw new Error(`Incorrect core image data ${e}`);this._cache=null,this._core=e,this._spatial=null}get assetsCached(){return null!=this._core&&null!=this._spatial&&null!=this._cache&&null!=this._cache.image&&null!=this._cache.mesh}get cameraParameters(){return this._spatial.camera_parameters}get cameraType(){return this._spatial.camera_type}get capturedAt(){return this._spatial.captured_at}get clusterId(){return this._spatial.cluster?this._spatial.cluster.id:null}get clusterUrl(){return this._spatial.cluster?this._spatial.cluster.url:null}get compassAngle(){return null!=this._spatial.computed_compass_angle?this._spatial.computed_compass_angle:this._spatial.compass_angle}get complete(){return null!=this._spatial}get computedAltitude(){return this._spatial.computed_altitude}get computedCompassAngle(){return this._spatial.computed_compass_angle}get computedLngLat(){return this._core.computed_geometry}get creatorId(){return this._spatial.creator.id}get creatorUsername(){return this._spatial.creator.username}get exifOrientation(){return this._spatial.exif_orientation}get height(){return this._spatial.height}get image(){return this._cache.image}get image$(){return this._cache.image$}get id(){return this._core.id}get lngLat(){return null!=this._core.computed_geometry?this._core.computed_geometry:this._core.geometry}get merged(){return null!=this._spatial&&null!=this._spatial.merge_id}get mergeId(){return this._spatial.merge_id}get mesh(){return this._cache.mesh}get originalAltitude(){return this._spatial.altitude}get originalCompassAngle(){return this._spatial.compass_angle}get originalLngLat(){return this._core.geometry}get ownerId(){return this._spatial.owner?this._spatial.owner.id:null}get private(){return this._spatial.private}get qualityScore(){return this._spatial.quality_score}get rotation(){return this._spatial.computed_rotation}get scale(){return this._spatial.atomic_scale}get sequenceId(){return this._core.sequence?this._core.sequence.id:null}get sequenceEdges(){return this._cache.sequenceEdges}get sequenceEdges$(){return this._cache.sequenceEdges$}get spatialEdges(){return this._cache.spatialEdges}get spatialEdges$(){return this._cache.spatialEdges$}get width(){return this._spatial.width}cacheAssets$(){return this._cache.cacheAssets$(this._spatial,this.merged).pipe(De((()=>this)))}cacheImage$(){return this._cache.cacheImage$(this._spatial).pipe(De((()=>this)))}cacheSequenceEdges(e){this._cache.cacheSequenceEdges(e)}cacheSpatialEdges(e){this._cache.cacheSpatialEdges(e)}dispose(){null!=this._cache&&(this._cache.dispose(),this._cache=null),this._core=null,this._spatial=null}initializeCache(e){if(null!=this._cache)throw new Error(`Image cache already initialized (${this.id}).`);this._cache=e}makeComplete(e){if(null==e)throw new Error("Fill can not be null.");this._spatial=e}resetSequenceEdges(){this._cache.resetSequenceEdges()}resetSpatialEdges(){this._cache.resetSpatialEdges()}uncache(){null!=this._cache&&(this._cache.dispose(),this._cache=null)}}class Tu{constructor(e){this._disposed=!1,this._provider=e,this._image=null,this._mesh=null,this._sequenceEdges={cached:!1,edges:[]},this._spatialEdges={cached:!1,edges:[]},this._imageChanged$=new j,this._image$=this._imageChanged$.pipe(Ot(null),Rt(1),U()),this._iamgeSubscription=this._image$.subscribe(),this._sequenceEdgesChanged$=new j,this._sequenceEdges$=this._sequenceEdgesChanged$.pipe(Ot(this._sequenceEdges),Rt(1),U()),this._sequenceEdgesSubscription=this._sequenceEdges$.subscribe((()=>{})),this._spatialEdgesChanged$=new j,this._spatialEdges$=this._spatialEdgesChanged$.pipe(Ot(this._spatialEdges),Rt(1),U()),this._spatialEdgesSubscription=this._spatialEdges$.subscribe((()=>{})),this._cachingAssets$=null}get image(){return this._image}get image$(){return this._image$}get mesh(){return this._mesh}get sequenceEdges(){return this._sequenceEdges}get sequenceEdges$(){return this._sequenceEdges$}get spatialEdges(){return this._spatialEdges}get spatialEdges$(){return this._spatialEdges$}cacheAssets$(e,t){return null!=this._cachingAssets$||(this._cachingAssets$=Ve(this._cacheImage$(e),this._cacheMesh$(e,t)).pipe(De((([e,t])=>(this._image=e,this._mesh=t,this))),Mt((()=>{this._cachingAssets$=null})),Rt(1),U()),this._cachingAssets$.pipe(St((e=>!!e._image))).subscribe((()=>{this._imageChanged$.next(this._image)}),(()=>{}))),this._cachingAssets$}cacheImage$(e){if(null!=this._image)return Ce(this);const t=this._cacheImage$(e).pipe(St((e=>!!e)),Ut((e=>{this._disposeImage(),this._image=e})),De((()=>this)),Rt(1),U());return t.subscribe((()=>{this._imageChanged$.next(this._image)}),(()=>{})),t}cacheSequenceEdges(e){this._sequenceEdges={cached:!0,edges:e},this._sequenceEdgesChanged$.next(this._sequenceEdges)}cacheSpatialEdges(e){this._spatialEdges={cached:!0,edges:e},this._spatialEdgesChanged$.next(this._spatialEdges)}dispose(){this._iamgeSubscription.unsubscribe(),this._sequenceEdgesSubscription.unsubscribe(),this._spatialEdgesSubscription.unsubscribe(),this._disposeImage(),this._mesh=null,this._sequenceEdges={cached:!1,edges:[]},this._spatialEdges={cached:!1,edges:[]},this._imageChanged$.next(null),this._sequenceEdgesChanged$.next(this._sequenceEdges),this._spatialEdgesChanged$.next(this._spatialEdges),this._disposed=!0,null!=this._imageAborter&&(this._imageAborter(),this._imageAborter=null),null!=this._meshAborter&&(this._meshAborter(),this._meshAborter=null)}resetSequenceEdges(){this._sequenceEdges={cached:!1,edges:[]},this._sequenceEdgesChanged$.next(this._sequenceEdges)}resetSpatialEdges(){this._spatialEdges={cached:!1,edges:[]},this._spatialEdgesChanged$.next(this._spatialEdges)}_cacheImage$(e){return k.create((t=>{const i=new Promise(((e,t)=>{this._imageAborter=t})),n=e.thumb.url;if(n)this._provider.getImageBuffer(n,i).then((e=>{this._imageAborter=null;const i=new Image;i.crossOrigin="Anonymous",i.onload=()=>{if(this._disposed){window.URL.revokeObjectURL(i.src);const e=`Image load was aborted (${n})`;t.error(new Error(e))}else t.next(i),t.complete()},i.onerror=()=>{this._imageAborter=null,t.error(new Error(`Failed to load image (${n})`))};const r=new Blob([e]);i.src=window.URL.createObjectURL(r)}),(e=>{this._imageAborter=null,t.error(e)}));else{const i=e.thumb.id,r=`Incorrect thumb URL for ${e.id} (${i}, ${n})`;t.error(new Error(r))}}))}_cacheMesh$(e,t){return k.create((i=>{if(!t)return i.next(this._createEmptyMesh()),void i.complete();const n=e.mesh.url;if(!n){const t=e.mesh.id,r=`Incorrect mesh URL for ${e.id} (${t}, ${n})`;return console.warn(r),i.next(this._createEmptyMesh()),void i.complete()}const r=new Promise(((e,t)=>{this._meshAborter=t}));this._provider.getMesh(n,r).then((e=>{this._meshAborter=null,this._disposed||(i.next(e),i.complete())}),(e=>{this._meshAborter=null,console.error(e),i.next(this._createEmptyMesh()),i.complete()}))}))}_createEmptyMesh(){return{faces:[],vertices:[]}}_disposeImage(){null!=this._image&&window.URL.revokeObjectURL(this._image.src),this._image=null}}class Cu{constructor(e){this._id=e.id,this._imageIds=e.image_ids}get id(){return this._id}get imageIds(){return this._imageIds}dispose(){this._id=null,this._imageIds=null}findNext(e){let t=this._imageIds.indexOf(e);return t+1>=this._imageIds.length||-1===t?null:this._imageIds[t+1]}findPrev(e){let t=this._imageIds.indexOf(e);return 0===t||-1===t?null:this._imageIds[t-1]}}class Eu{constructor(){this.sphericalPreferredDistance=2,this.sphericalMotion=2,this.sphericalSequencePenalty=1,this.sphericalMergeCCPenalty=4,this.stepPreferredDistance=4,this.stepMotion=3,this.stepRotation=4,this.stepSequencePenalty=2,this.stepMergeCCPenalty=6,this.similarDistance=2,this.similarRotation=3,this.turnDistance=4,this.turnMotion=2,this.turnSequencePenalty=1,this.turnMergeCCPenalty=4}}var Au;e.NavigationDirection=void 0,(Au=e.NavigationDirection||(e.NavigationDirection={}))[Au.Next=0]="Next",Au[Au.Prev=1]="Prev",Au[Au.StepLeft=2]="StepLeft",Au[Au.StepRight=3]="StepRight",Au[Au.StepForward=4]="StepForward",Au[Au.StepBackward=5]="StepBackward",Au[Au.TurnLeft=6]="TurnLeft",Au[Au.TurnRight=7]="TurnRight",Au[Au.TurnU=8]="TurnU",Au[Au.Spherical=9]="Spherical",Au[Au.Similar=10]="Similar";class Iu{constructor(){this.steps={},this.turns={},this.spherical={},this.steps[e.NavigationDirection.StepForward]={direction:e.NavigationDirection.StepForward,motionChange:0,useFallback:!0},this.steps[e.NavigationDirection.StepBackward]={direction:e.NavigationDirection.StepBackward,motionChange:Math.PI,useFallback:!0},this.steps[e.NavigationDirection.StepLeft]={direction:e.NavigationDirection.StepLeft,motionChange:Math.PI/2,useFallback:!1},this.steps[e.NavigationDirection.StepRight]={direction:e.NavigationDirection.StepRight,motionChange:-Math.PI/2,useFallback:!1},this.turns[e.NavigationDirection.TurnLeft]={direction:e.NavigationDirection.TurnLeft,directionChange:Math.PI/2,motionChange:Math.PI/4},this.turns[e.NavigationDirection.TurnRight]={direction:e.NavigationDirection.TurnRight,directionChange:-Math.PI/2,motionChange:-Math.PI/4},this.turns[e.NavigationDirection.TurnU]={direction:e.NavigationDirection.TurnU,directionChange:Math.PI,motionChange:null},this.spherical[e.NavigationDirection.StepForward]={direction:e.NavigationDirection.StepForward,directionChange:0,next:e.NavigationDirection.StepLeft,prev:e.NavigationDirection.StepRight},this.spherical[e.NavigationDirection.StepBackward]={direction:e.NavigationDirection.StepBackward,directionChange:Math.PI,next:e.NavigationDirection.StepRight,prev:e.NavigationDirection.StepLeft},this.spherical[e.NavigationDirection.StepLeft]={direction:e.NavigationDirection.StepLeft,directionChange:Math.PI/2,next:e.NavigationDirection.StepBackward,prev:e.NavigationDirection.StepForward},this.spherical[e.NavigationDirection.StepRight]={direction:e.NavigationDirection.StepRight,directionChange:-Math.PI/2,next:e.NavigationDirection.StepForward,prev:e.NavigationDirection.StepBackward}}}class Ru{constructor(){this.sphericalMinDistance=.1,this.sphericalMaxDistance=20,this.sphericalPreferredDistance=5,this.sphericalMaxItems=4,this.sphericalMaxStepTurnChange=Math.PI/8,this.rotationMaxDistance=this.turnMaxRigDistance,this.rotationMaxDirectionChange=Math.PI/6,this.rotationMaxVerticalDirectionChange=Math.PI/8,this.similarMaxDirectionChange=Math.PI/8,this.similarMaxDistance=12,this.similarMinTimeDifference=432e5,this.stepMaxDistance=20,this.stepMaxDirectionChange=Math.PI/6,this.stepMaxDrift=Math.PI/6,this.stepPreferredDistance=4,this.turnMaxDistance=15,this.turnMaxDirectionChange=2*Math.PI/9,this.turnMaxRigDistance=.65,this.turnMinRigDirectionChange=Math.PI/6}get maxDistance(){return Math.max(this.sphericalMaxDistance,this.similarMaxDistance,this.stepMaxDistance,this.turnMaxDistance)}}class Pu extends Error{constructor(e){super(e),Object.setPrototypeOf(this,Pu.prototype),this.name="MapillaryError"}}class Lu extends Pu{constructor(e){super(null!=e?e:"The argument is not valid."),Object.setPrototypeOf(this,Lu.prototype),this.name="ArgumentMapillaryError"}}class Du{constructor(){this._epsilon=1e-9}azimuthalToBearing(e){return-e+Math.PI/2}degToRad(e){return Math.PI*e/180}radToDeg(e){return 180*e/Math.PI}rotationMatrix(e){let t=new Ki(e[0],e[1],e[2]),i=t.length();return i>0&&t.normalize(),(new Rn).makeRotationAxis(t,i)}rotate(e,t){let i=new Ki(e[0],e[1],e[2]),n=this.rotationMatrix(t);return i.applyMatrix4(n),i}opticalCenter(e,t){let i=[-e[0],-e[1],-e[2]],n=[-t[0],-t[1],-t[2]];return this.rotate(n,i)}viewingDirection(e){let t=[-e[0],-e[1],-e[2]];return this.rotate([0,0,1],t)}wrap(e,t,i){if(i<t)throw new Error("Invalid arguments: max must be larger than min.");let n=i-t;for(;e>i||e<t;)e>i?e-=n:e<t&&(e+=n);return e}wrapAngle(e){return this.wrap(e,-Math.PI,Math.PI)}clamp(e,t,i){return e<t?t:e>i?i:e}angleBetweenVector2(e,t,i,n){let r=Math.atan2(n,i)-Math.atan2(t,e);return this.wrapAngle(r)}angleDifference(e,t){let i=t-e;return this.wrapAngle(i)}relativeRotationAngle(e,t){let i=this.rotationMatrix([-e[0],-e[1],-e[2]]),n=this.rotationMatrix(t),r=i.multiply(n).elements,s=r[0]+r[5]+r[10];return Math.acos(Math.max(Math.min((s-1)/2,1),-1))}angleToPlane(e,t){let i=(new Ki).fromArray(e),n=i.length();if(n<this._epsilon)return 0;let r=i.dot((new Ki).fromArray(t));return Math.asin(r/n)}azimuthal(e,t){const i=(new Ki).fromArray(e),n=(new Ki).fromArray(t),r=i.clone().dot(n),s=i.clone().sub(n.clone().multiplyScalar(r));return Math.atan2(s.y,s.x)}distanceFromLngLat(e,t,i,n){let r=this.degToRad(n-t),s=this.degToRad(i-e),a=Math.sin(r/2)*Math.sin(r/2)+Math.cos(this.degToRad(t))*Math.cos(this.degToRad(n))*Math.sin(s/2)*Math.sin(s/2);return 12742e3*Math.atan2(Math.sqrt(a),Math.sqrt(1-a))}}const Nu=new Du;function $u(e){return"spherical"===e}function ku(e){return"fisheye"===e}function Ou(e,t,i){const n=_u(e.lng,e.lat,e.alt,i.lng,i.lat,i.alt),r=Nu.rotate(n,t);return[-r.x,-r.y,-r.z]}function zu(e,t,i,n,r){const s=[];for(let e=0;e<t.length;++e){const r=t[e],a=i[e];for(let e=0;e<=n;++e)s.push([r[0]+a[0]*e/n,r[1]+a[1]*e/n])}const a=new os;a.up.copy(e.upVector()),a.position.copy((new Ki).fromArray(e.unprojectSfM([0,0],0))),a.lookAt((new Ki).fromArray(e.unprojectSfM([0,0],10))),a.updateMatrix(),a.updateMatrixWorld(!0);return s.map((t=>{const i=e.unprojectBasic(t,1e4),n=r.worldToCamera(i,a);return[Math.abs(n[0]/n[2]),Math.abs(n[1]/n[2])]}))}class Fu{constructor(e,t,i){this._spatial=new Du,this._settings=null!=e?e:new Ru,this._directions=null!=t?t:new Iu,this._coefficients=null!=i?i:new Eu}getPotentialEdges(e,t,i){if(!e.complete)throw new Lu("Image has to be full.");if(!e.merged)return[];let n=this._spatial.viewingDirection(e.rotation),r=this._spatial.angleToPlane(n.toArray(),[0,0,1]),s=[];for(let a of t){if(!a.merged||a.id===e.id)continue;let t=_u(a.lngLat.lng,a.lngLat.lat,a.computedAltitude,e.lngLat.lng,e.lngLat.lat,e.computedAltitude),o=new Ki(t[0],t[1],t[2]),h=o.length();if(h>this._settings.maxDistance&&i.indexOf(a.id)<0)continue;let c=this._spatial.angleBetweenVector2(n.x,n.y,o.x,o.y),l=this._spatial.angleToPlane(o.toArray(),[0,0,1]),u=this._spatial.viewingDirection(a.rotation),d=this._spatial.angleBetweenVector2(n.x,n.y,u.x,u.y),p=this._spatial.angleToPlane(u.toArray(),[0,0,1])-r,m=this._spatial.relativeRotationAngle(e.rotation,a.rotation),f=this._spatial.angleBetweenVector2(1,0,o.x,o.y),g=null!=a.sequenceId&&null!=e.sequenceId&&a.sequenceId===e.sequenceId,_=a.mergeId===e.mergeId,v=a.creatorId===e.creatorId,y={capturedAt:a.capturedAt,directionChange:d,distance:h,spherical:$u(a.cameraType),id:a.id,motionChange:c,rotation:m,sameMergeCC:_,sameSequence:g,sameUser:v,sequenceId:a.sequenceId,verticalDirectionChange:p,verticalMotion:l,worldMotionAzimuth:f};s.push(y)}return s}computeSequenceEdges(t,i){if(!t.complete)throw new Lu("Image has to be full.");if(t.sequenceId!==i.id)throw new Lu("Image and sequence does not correspond.");let n=[],r=i.findNext(t.id);null!=r&&n.push({data:{direction:e.NavigationDirection.Next,worldMotionAzimuth:Number.NaN},source:t.id,target:r});let s=i.findPrev(t.id);return null!=s&&n.push({data:{direction:e.NavigationDirection.Prev,worldMotionAzimuth:Number.NaN},source:t.id,target:s}),n}computeSimilarEdges(t,i){if(!t.complete)throw new Lu("Image has to be full.");let n=$u(t.cameraType),r={};for(let e of i)if(null!=e.sequenceId&&!e.sameSequence){if(n){if(!e.spherical)continue}else if(!e.spherical&&Math.abs(e.directionChange)>this._settings.similarMaxDirectionChange)continue;e.distance>this._settings.similarMaxDistance||e.sameUser&&Math.abs(e.capturedAt-t.capturedAt)<this._settings.similarMinTimeDifference||(null==r[e.sequenceId]&&(r[e.sequenceId]=[]),r[e.sequenceId].push(e))}let s=[],a=$u(t.cameraType)?e=>e.distance:e=>this._coefficients.similarDistance*e.distance+this._coefficients.similarRotation*e.rotation;for(let e in r){if(!r.hasOwnProperty(e))continue;let t=Number.MAX_VALUE,i=null;for(let n of r[e]){let e=a(n);e<t&&(t=e,i=n)}null!=i&&s.push(i)}return s.map((i=>({data:{direction:e.NavigationDirection.Similar,worldMotionAzimuth:i.worldMotionAzimuth},source:t.id,target:i.id})))}computeStepEdges(e,t,i,n){if(!e.complete)throw new Lu("Image has to be full.");let r=[];if($u(e.cameraType))return r;for(let s in this._directions.steps){if(!this._directions.steps.hasOwnProperty(s))continue;let a=this._directions.steps[s],o=Number.MAX_VALUE,h=null,c=null;for(let e of t){if(e.spherical)continue;if(Math.abs(e.directionChange)>this._settings.stepMaxDirectionChange)continue;let t=this._spatial.angleDifference(a.motionChange,e.motionChange),r=this._spatial.angleDifference(e.directionChange,t),s=Math.max(Math.abs(t),Math.abs(r));if(Math.abs(s)>this._settings.stepMaxDrift)continue;let l=e.id;if(!a.useFallback||l!==i&&l!==n||(c=e),e.distance>this._settings.stepMaxDistance)continue;t=Math.sqrt(t*t+e.verticalMotion*e.verticalMotion);let u=this._coefficients.stepPreferredDistance*Math.abs(e.distance-this._settings.stepPreferredDistance)/this._settings.stepMaxDistance+this._coefficients.stepMotion*t/this._settings.stepMaxDrift+this._coefficients.stepRotation*e.rotation/this._settings.stepMaxDirectionChange+this._coefficients.stepSequencePenalty*(e.sameSequence?0:1)+this._coefficients.stepMergeCCPenalty*(e.sameMergeCC?0:1);u<o&&(o=u,h=e)}h=null==h?c:h,null!=h&&r.push({data:{direction:a.direction,worldMotionAzimuth:h.worldMotionAzimuth},source:e.id,target:h.id})}return r}computeTurnEdges(t,i){if(!t.complete)throw new Lu("Image has to be full.");let n=[];if($u(t.cameraType))return n;for(let r in this._directions.turns){if(!this._directions.turns.hasOwnProperty(r))continue;let s=this._directions.turns[r],a=Number.MAX_VALUE,o=null;for(let t of i){if(t.spherical)continue;if(t.distance>this._settings.turnMaxDistance)continue;let i,n=s.direction!==e.NavigationDirection.TurnU&&t.distance<this._settings.turnMaxRigDistance&&Math.abs(t.directionChange)>this._settings.turnMinRigDirectionChange,r=this._spatial.angleDifference(s.directionChange,t.directionChange);if(n&&t.directionChange*s.directionChange>0&&Math.abs(t.directionChange)<Math.abs(s.directionChange))i=-Math.PI/2+Math.abs(t.directionChange);else{if(Math.abs(r)>this._settings.turnMaxDirectionChange)continue;let e=s.motionChange?this._spatial.angleDifference(s.motionChange,t.motionChange):0;e=Math.sqrt(e*e+t.verticalMotion*t.verticalMotion),i=this._coefficients.turnDistance*t.distance/this._settings.turnMaxDistance+this._coefficients.turnMotion*e/Math.PI+this._coefficients.turnSequencePenalty*(t.sameSequence?0:1)+this._coefficients.turnMergeCCPenalty*(t.sameMergeCC?0:1)}i<a&&(a=i,o=t)}null!=o&&n.push({data:{direction:s.direction,worldMotionAzimuth:o.worldMotionAzimuth},source:t.id,target:o.id})}return n}computePerspectiveToSphericalEdges(t,i){if(!t.complete)throw new Lu("Image has to be full.");if($u(t.cameraType))return[];let n=Number.MAX_VALUE,r=null;for(let e of i){if(!e.spherical)continue;let t=this._coefficients.sphericalPreferredDistance*Math.abs(e.distance-this._settings.sphericalPreferredDistance)/this._settings.sphericalMaxDistance+this._coefficients.sphericalMotion*Math.abs(e.motionChange)/Math.PI+this._coefficients.sphericalMergeCCPenalty*(e.sameMergeCC?0:1);t<n&&(n=t,r=e)}return null==r?[]:[{data:{direction:e.NavigationDirection.Spherical,worldMotionAzimuth:r.worldMotionAzimuth},source:t.id,target:r.id}]}computeSphericalEdges(t,i){if(!t.complete)throw new Lu("Image has to be full.");if(!$u(t.cameraType))return[];let n=[],r=[],s=[];for(let e of i)if(!(e.distance>this._settings.sphericalMaxDistance))if(e.spherical){if(e.distance<this._settings.sphericalMinDistance)continue;r.push(e)}else for(let t in this._directions.spherical){if(!this._directions.spherical.hasOwnProperty(t))continue;let i=this._directions.spherical[t],n=this._spatial.angleDifference(e.directionChange,e.motionChange),r=this._spatial.angleDifference(i.directionChange,n);if(!(Math.abs(r)>this._settings.sphericalMaxStepTurnChange)){s.push([i.direction,e]);break}}let a=Math.PI/this._settings.sphericalMaxItems,o=[],h=[];for(let i=0;i<this._settings.sphericalMaxItems;i++){let s=i/this._settings.sphericalMaxItems*2*Math.PI,c=Number.MAX_VALUE,l=null;for(let e of r){let t=this._spatial.angleDifference(s,e.motionChange);if(Math.abs(t)>a)continue;let i=Number.MAX_VALUE;for(let t of o){let n=Math.abs(this._spatial.angleDifference(t,e.motionChange));n<i&&(i=n)}if(i<=a)continue;let n=this._coefficients.sphericalPreferredDistance*Math.abs(e.distance-this._settings.sphericalPreferredDistance)/this._settings.sphericalMaxDistance+this._coefficients.sphericalMotion*Math.abs(t)/a+this._coefficients.sphericalSequencePenalty*(e.sameSequence?0:1)+this._coefficients.sphericalMergeCCPenalty*(e.sameMergeCC?0:1);n<c&&(c=n,l=e)}null!=l?(o.push(l.motionChange),n.push({data:{direction:e.NavigationDirection.Spherical,worldMotionAzimuth:l.worldMotionAzimuth},source:t.id,target:l.id})):h.push(s)}let c={};c[e.NavigationDirection.Spherical]=o,c[e.NavigationDirection.StepForward]=[],c[e.NavigationDirection.StepLeft]=[],c[e.NavigationDirection.StepBackward]=[],c[e.NavigationDirection.StepRight]=[];for(let i of h){let r=[];for(let o in this._directions.spherical){if(!this._directions.spherical.hasOwnProperty(o))continue;let h=this._directions.spherical[o],l=c[e.NavigationDirection.Spherical].concat(c[h.direction]).concat(c[h.prev]).concat(c[h.next]),u=Number.MAX_VALUE,d=null;for(let e of s){if(e[0]!==h.direction)continue;let t=this._spatial.angleDifference(i,e[1].motionChange);if(Math.abs(t)>a)continue;let n=Number.MAX_VALUE;for(let t of l){let i=Math.abs(this._spatial.angleDifference(t,e[1].motionChange));i<n&&(n=i)}if(n<=a)continue;let r=this._coefficients.sphericalPreferredDistance*Math.abs(e[1].distance-this._settings.sphericalPreferredDistance)/this._settings.sphericalMaxDistance+this._coefficients.sphericalMotion*Math.abs(t)/a+this._coefficients.sphericalMergeCCPenalty*(e[1].sameMergeCC?0:1);r<u&&(u=r,d=e)}null!=d&&(r.push(d),n.push({data:{direction:d[0],worldMotionAzimuth:d[1].worldMotionAzimuth},source:t.id,target:d[1].id}))}for(let e of r)c[e[0]].push(e[1].motionChange)}return n}}class Bu extends Pu{constructor(e){super(e),Object.setPrototypeOf(this,Bu.prototype),this.name="GraphMapillaryError"}}class Uu{constructor(e,t,i,n,r,s){this._api=e,this._cachedNodes={},this._cachedNodeTiles={},this._cachedSequenceNodes={},this._cachedSpatialEdges={},this._cachedTiles={},this._cachingFill$={},this._cachingFull$={},this._cachingSequenceNodes$={},this._cachingSequences$={},this._cachingSpatialArea$={},this._cachingTiles$={},this._changed$=new j,this._filterCreator=null!=r?r:new Ht,this._filter=this._filterCreator.createFilter(void 0),this._filterSubject$=new j,this._filter$=Ze(Ce(this._filter),this._filterSubject$).pipe(Rt(1),U()),this._filterSubscription=this._filter$.subscribe((()=>{})),this._defaultAlt=2,this._edgeCalculator=null!=n?n:new Fu,this._graphCalculator=null!=i?i:new Mu,this._configuration=null!=s?s:{maxSequences:50,maxUnusedImages:100,maxUnusedPreStoredImages:30,maxUnusedTiles:20},this._nodes={},this._nodeIndex=null!=t?t:new Uu._spatialIndex(16),this._nodeIndexTiles={},this._nodeToTile={},this._preStored={},this._requiredNodeTiles={},this._requiredSpatialArea={},this._sequences={},this._tileThreshold=20}static register(e){Uu._spatialIndex=e}get api(){return this._api}get changed$(){return this._changed$}get filter$(){return this._filter$}cacheBoundingBox$(e,t){const i=this._api.data.geometry.bboxToCellIds(e,t).filter((e=>!(e in this._cachedTiles))).map((e=>e in this._cachingTiles$?this._cachingTiles$[e]:this._cacheTile$(e)));return 0===i.length&&i.push(Ce(this)),ge(i).pipe(qe(),Ct(),We((()=>{const i=this._nodeIndex.search({maxX:t.lng,maxY:t.lat,minX:e.lng,minY:e.lat}).map((e=>e.node)),n=[],r=[];for(const e of i)e.complete?n.push(e):r.push(e.id);const s=[];for(;r.length>0;)s.push(r.splice(0,200));return it(Ce(n),ge(s.map((e=>this._api.getSpatialImages$(e).pipe(De((e=>{const t=[];for(const i of e){if(!this.hasNode(i.node_id))continue;const e=this.getNode(i.node_id);e.complete||this._makeFull(e,i.node),t.push(e)}return t})))))).pipe(qe()))})),ut(((e,t)=>e.concat(t))))}cacheCell$(e){return(e in this._cachedTiles?Ce(this):e in this._cachingTiles$?this._cachingTiles$[e]:this._cacheTile$(e)).pipe(We((()=>{const t=this._cachedTiles[e];t.accessed=(new Date).getTime();const i=t.nodes,n=[],r=[];for(const e of i)e.complete?n.push(e):r.push(e.id);const s=[];for(;r.length>0;)s.push(r.splice(0,200));return it(Ce(n),ge(s.map((e=>this._api.getSpatialImages$(e).pipe(De((e=>{const t=[];for(const i of e){if(!i.node){console.warn(`Image is empty (${i.node})`);continue}const e=i.node_id;if(!this.hasNode(e))continue;const n=this.getNode(e);n.complete||this._makeFull(n,i.node),t.push(n)}return t})))))).pipe(qe()))})),ut(((e,t)=>e.concat(t))))}cacheFill$(e){if(e in this._cachingFull$)throw new Bu(`Cannot fill node while caching full (${e}).`);if(!this.hasNode(e))throw new Bu(`Cannot fill node that does not exist in graph (${e}).`);if(e in this._cachingFill$)return this._cachingFill$[e];const t=this.getNode(e);if(t.complete)throw new Bu(`Cannot fill node that is already full (${e}).`);return this._cachingFill$[e]=this._api.getSpatialImages$([e]).pipe(Ut((e=>{for(const i of e)i.node||console.warn(`Image is empty ${i.node_id}`),t.complete||this._makeFull(t,i.node),delete this._cachingFill$[i.node_id]})),De((()=>this)),Mt((()=>{e in this._cachingFill$&&delete this._cachingFill$[e],this._changed$.next(this)})),It(),U()),this._cachingFill$[e]}cacheFull$(e){if(e in this._cachingFull$)return this._cachingFull$[e];if(this.hasNode(e))throw new Bu(`Cannot cache full node that already exist in graph (${e}).`);return this._cachingFull$[e]=this._api.getImages$([e]).pipe(Ut((t=>{for(const i of t){if(!i.node)throw new Bu(`Image does not exist (${e}, ${i.node}).`);const t=i.node_id;if(this.hasNode(t)){const t=this.getNode(e);t.complete||this._makeFull(t,i.node)}else{if(null==i.node.sequence.id)throw new Bu(`Image has no sequence key (${e}).`);const n=new Su(i.node);this._makeFull(n,i.node);const r=this._api.data.geometry.lngLatToCellId(n.originalLngLat);this._preStore(r,n),this._setNode(n),delete this._cachingFull$[t]}}})),De((()=>this)),Mt((()=>{e in this._cachingFull$&&delete this._cachingFull$[e],this._changed$.next(this)})),It(),U()),this._cachingFull$[e]}cacheNodeSequence$(e){if(!this.hasNode(e))throw new Bu(`Cannot cache sequence edges of node that does not exist in graph (${e}).`);let t=this.getNode(e);if(t.sequenceId in this._sequences)throw new Bu(`Sequence already cached (${e}), (${t.sequenceId}).`);return this._cacheSequence$(t.sequenceId)}cacheSequence$(e){if(e in this._sequences)throw new Bu(`Sequence already cached (${e})`);return this._cacheSequence$(e)}cacheSequenceEdges(e){let t=this.getNode(e);if(!(t.sequenceId in this._sequences))throw new Bu(`Sequence is not cached (${e}), (${t.sequenceId})`);let i=this._sequences[t.sequenceId].sequence,n=this._edgeCalculator.computeSequenceEdges(t,i);t.cacheSequenceEdges(n)}cacheSequenceNodes$(e,t){if(!this.hasSequence(e))throw new Bu(`Cannot cache sequence nodes of sequence that does not exist in graph (${e}).`);if(this.hasSequenceNodes(e))throw new Bu(`Sequence nodes already cached (${e}).`);const i=this.getSequence(e);if(i.id in this._cachingSequenceNodes$)return this._cachingSequenceNodes$[i.id];const n=[],r=i.imageIds.slice();if(t&&r.length>50){const e=r.indexOf(t),i=Math.max(0,Math.min(e-25,r.length-50));n.push(r.splice(i,50))}for(;r.length>0;)n.push(r.splice(0,200));let s=n.length;const a=ge(n).pipe(We((e=>this._api.getImages$(e).pipe(Ut((e=>{for(const t of e){if(!t.node){console.warn(`Image empty (${t.node_id})`);continue}const e=t.node_id;if(this.hasNode(e)){const i=this.getNode(e);i.complete||this._makeFull(i,t.node)}else{null==t.node.sequence.id&&console.warn(`Sequence missing, discarding node (${t.node_id})`);const e=new Su(t.node);this._makeFull(e,t.node);const i=this._api.data.geometry.lngLatToCellId(e.originalLngLat);this._preStore(i,e),this._setNode(e)}}s--})),De((()=>this)))),6),Ct(),Mt((()=>{delete this._cachingSequenceNodes$[i.id],0===s&&(this._cachedSequenceNodes[i.id]=!0)})),It(),U());return this._cachingSequenceNodes$[i.id]=a,a}cacheSpatialArea$(e){if(!this.hasNode(e))throw new Bu(`Cannot cache spatial area of node that does not exist in graph (${e}).`);if(e in this._cachedSpatialEdges)throw new Bu(`Image already spatially cached (${e}).`);if(!(e in this._requiredSpatialArea))throw new Bu(`Spatial area not determined (${e}).`);let t=this._requiredSpatialArea[e];if(0===Object.keys(t.cacheNodes).length)throw new Bu(`Spatial nodes already cached (${e}).`);if(e in this._cachingSpatialArea$)return this._cachingSpatialArea$[e];let i=[];for(;t.cacheKeys.length>0;)i.push(t.cacheKeys.splice(0,200));let n=i.length,r=[];for(let s of i){let i=this._api.getSpatialImages$(s).pipe(Ut((i=>{for(const e of i){if(!e.node){console.warn(`Image is empty (${e.node_id})`);continue}const i=e.node_id,n=t.cacheNodes[i];n.complete?delete t.cacheNodes[i]:(this._makeFull(n,e.node),delete t.cacheNodes[i])}0==--n&&delete this._cachingSpatialArea$[e]})),De((()=>this)),ct((i=>{for(let e of s)e in t.all&&delete t.all[e],e in t.cacheNodes&&delete t.cacheNodes[e];throw 0==--n&&delete this._cachingSpatialArea$[e],i})),Mt((()=>{0===Object.keys(t.cacheNodes).length&&this._changed$.next(this)})),It(),U());r.push(i)}return this._cachingSpatialArea$[e]=r,r}cacheSpatialEdges(e){if(e in this._cachedSpatialEdges)throw new Bu(`Spatial edges already cached (${e}).`);let t=this.getNode(e),i=this._sequences[t.sequenceId].sequence,n=[],r=i.findPrev(t.id);null!=r&&n.push(r);let s=i.findNext(t.id);null!=s&&n.push(s);let a=this._requiredSpatialArea[e].all,o=[],h=this._filter;for(let e in a){if(!a.hasOwnProperty(e))continue;let t=a[e];h(t)&&o.push(t)}let c=this._edgeCalculator.getPotentialEdges(t,o,n),l=this._edgeCalculator.computeStepEdges(t,c,r,s);l=l.concat(this._edgeCalculator.computeTurnEdges(t,c)),l=l.concat(this._edgeCalculator.computeSphericalEdges(t,c)),l=l.concat(this._edgeCalculator.computePerspectiveToSphericalEdges(t,c)),l=l.concat(this._edgeCalculator.computeSimilarEdges(t,c)),t.cacheSpatialEdges(l),this._cachedSpatialEdges[e]=t,delete this._requiredSpatialArea[e],delete this._cachedNodeTiles[e]}cacheTiles$(e){if(e in this._cachedNodeTiles)throw new Bu(`Tiles already cached (${e}).`);if(e in this._cachedSpatialEdges)throw new Bu(`Spatial edges already cached so tiles considered cached (${e}).`);if(!(e in this._requiredNodeTiles))throw new Bu(`Tiles have not been determined (${e}).`);let t=this._requiredNodeTiles[e];if(0===t.cache.length&&0===t.caching.length)throw new Bu(`Tiles already cached (${e}).`);if(!this.hasNode(e))throw new Bu(`Cannot cache tiles of node that does not exist in graph (${e}).`);let i=t.cache.slice();t.caching=this._requiredNodeTiles[e].caching.concat(i),t.cache=[];let n=[];for(let i of t.caching){const r=i in this._cachingTiles$?this._cachingTiles$[i]:this._cacheTile$(i);n.push(r.pipe(Ut((n=>{let r=t.caching.indexOf(i);r>-1&&t.caching.splice(r,1),0===t.caching.length&&0===t.cache.length&&(delete this._requiredNodeTiles[e],this._cachedNodeTiles[e]=!0)})),ct((n=>{let r=t.caching.indexOf(i);throw r>-1&&t.caching.splice(r,1),0===t.caching.length&&0===t.cache.length&&(delete this._requiredNodeTiles[e],this._cachedNodeTiles[e]=!0),n})),Mt((()=>{this._changed$.next(this)})),It(),U()))}return n}initializeCache(e){if(e in this._cachedNodes)throw new Bu(`Image already in cache (${e}).`);const t=this.getNode(e),i=this._api.data;t.initializeCache(new Tu(i));const n=(new Date).getTime();this._cachedNodes[e]={accessed:n,node:t},this._updateCachedTileAccess(e,n)}isCachingFill(e){return e in this._cachingFill$}isCachingFull(e){return e in this._cachingFull$}isCachingNodeSequence(e){return this.getNode(e).sequenceId in this._cachingSequences$}isCachingSequence(e){return e in this._cachingSequences$}isCachingSequenceNodes(e){return e in this._cachingSequenceNodes$}isCachingTiles(e){return e in this._requiredNodeTiles&&0===this._requiredNodeTiles[e].cache.length&&this._requiredNodeTiles[e].caching.length>0}hasInitializedCache(e){return e in this._cachedNodes}hasNode(e){let t=(new Date).getTime();return this._updateCachedNodeAccess(e,t),this._updateCachedTileAccess(e,t),e in this._nodes}hasNodeSequence(e){let t=this.getNode(e).sequenceId,i=t in this._sequences;return i&&(this._sequences[t].accessed=(new Date).getTime()),i}hasSequence(e){let t=e in this._sequences;return t&&(this._sequences[e].accessed=(new Date).getTime()),t}hasSequenceNodes(e){return e in this._cachedSequenceNodes}hasSpatialArea(e){if(!this.hasNode(e))throw new Bu(`Spatial area nodes cannot be determined if node not in graph (${e}).`);if(e in this._cachedSpatialEdges)return!0;if(e in this._requiredSpatialArea)return 0===Object.keys(this._requiredSpatialArea[e].cacheNodes).length;let t=this.getNode(e),i=this._graphCalculator.boundingBoxCorners(t.lngLat,this._tileThreshold),n=this._nodeIndex.search({maxX:i[1].lng,maxY:i[1].lat,minX:i[0].lng,minY:i[0].lat}),r={all:{},cacheKeys:[],cacheNodes:{}};for(let e of n)r.all[e.node.id]=e.node,e.node.complete||(r.cacheKeys.push(e.node.id),r.cacheNodes[e.node.id]=e.node);return this._requiredSpatialArea[e]=r,0===r.cacheKeys.length}hasTiles(e){if(e in this._cachedNodeTiles)return!0;if(e in this._cachedSpatialEdges)return!0;if(!this.hasNode(e))throw new Bu(`Image does not exist in graph (${e}).`);let t={cache:[],caching:[]};if(e in this._requiredNodeTiles)t=this._requiredNodeTiles[e];else{const i=this.getNode(e),[n,r]=this._graphCalculator.boundingBoxCorners(i.lngLat,this._tileThreshold);t.cache=this._api.data.geometry.bboxToCellIds(n,r).filter((e=>!(e in this._cachedTiles))),t.cache.length>0&&(this._requiredNodeTiles[e]=t)}return 0===t.cache.length&&0===t.caching.length}getNode(e){let t=(new Date).getTime();return this._updateCachedNodeAccess(e,t),this._updateCachedTileAccess(e,t),this._nodes[e]}getSequence(e){let t=this._sequences[e];return t.accessed=(new Date).getTime(),t.sequence}resetSpatialEdges(){let e=Object.keys(this._cachedSpatialEdges);for(let t of e){this._cachedSpatialEdges[t].resetSpatialEdges(),delete this._cachedSpatialEdges[t]}}reset(e){const t=[];for(const i of e){if(!this.hasNode(i))throw new Error(`Image does not exist ${i}`);const e=this.getNode(i);e.resetSequenceEdges(),e.resetSpatialEdges(),t.push(e)}for(let t of Object.keys(this._cachedNodes))-1===e.indexOf(t)&&(this._cachedNodes[t].node.dispose(),delete this._cachedNodes[t]);this._cachedNodeTiles={},this._cachedSpatialEdges={},this._cachedTiles={},this._cachingFill$={},this._cachingFull$={},this._cachingSequences$={},this._cachingSpatialArea$={},this._cachingTiles$={},this._nodes={},this._nodeToTile={},this._preStored={};for(const e of t){this._nodes[e.id]=e;const t=this._api.data.geometry.lngLatToCellId(e.originalLngLat);this._preStore(t,e)}this._requiredNodeTiles={},this._requiredSpatialArea={},this._sequences={},this._nodeIndexTiles={},this._nodeIndex.clear()}setFilter(e){this._filter=this._filterCreator.createFilter(e),this._filterSubject$.next(this._filter)}uncache(e,t,i){const n={};this._addNewKeys(n,this._cachingFull$),this._addNewKeys(n,this._cachingFill$),this._addNewKeys(n,this._cachingSpatialArea$),this._addNewKeys(n,this._requiredNodeTiles),this._addNewKeys(n,this._requiredSpatialArea);for(const t of e)t in n||(n[t]=!0);const r=this._tileThreshold,s=this._graphCalculator,a=this._api.data.geometry,o=new Set(t);for(let e in n){if(!n.hasOwnProperty(e))continue;const t=this._nodes[e],[i,h]=s.boundingBoxCorners(t.lngLat,r),c=a.bboxToCellIds(i,h);for(const e of c)o.has(e)||o.add(e)}const h=[];for(let e in this._cachedTiles)this._cachedTiles.hasOwnProperty(e)&&!o.has(e)&&h.push([e,this._cachedTiles[e]]);const c=h.sort(((e,t)=>t[1].accessed-e[1].accessed)).slice(this._configuration.maxUnusedTiles).map((e=>e[0]));for(let e of c)this._uncacheTile(e,i);const l=[],u=[];for(let e in this._preStored){if(!this._preStored.hasOwnProperty(e)||e in this._cachingTiles$)continue;const t=this._preStored[e];for(let r in t)t.hasOwnProperty(r)&&!(r in n)&&t[r].sequenceId!==i&&(r in this._cachedNodes?l.push([this._cachedNodes[r],e]):u.push([r,e]))}const d=l.sort((([e],[t])=>t.accessed-e.accessed)).slice(this._configuration.maxUnusedPreStoredImages).map((([e,t])=>[e.node.id,t]));this._uncachePreStored(u),this._uncachePreStored(d);const p=[];for(let e in this._cachedNodes)this._cachedNodes.hasOwnProperty(e)&&!(e in n)&&p.push(this._cachedNodes[e]);const m=p.sort(((e,t)=>t.accessed-e.accessed)).slice(this._configuration.maxUnusedImages);for(const e of m){e.node.uncache();const t=e.node.id;delete this._cachedNodes[t],t in this._cachedNodeTiles&&delete this._cachedNodeTiles[t],t in this._cachedSpatialEdges&&delete this._cachedSpatialEdges[t]}const f=[];for(let e in this._sequences)this._sequences.hasOwnProperty(e)&&!(e in this._cachingSequences$)&&e!==i&&f.push(this._sequences[e]);const g=f.sort(((e,t)=>t.accessed-e.accessed)).slice(this._configuration.maxSequences);for(const e of g){const t=e.sequence.id;delete this._sequences[t],t in this._cachedSequenceNodes&&delete this._cachedSequenceNodes[t],e.sequence.dispose()}}updateCells$(e){const t=this._cachedTiles,i=this._cachingTiles$;return ge(e).pipe(We((e=>e in t?this._updateCell$(e):e in i?i[e].pipe(ct((()=>Ce(this))),We((()=>this._updateCell$(e)))):ie())))}unsubscribe(){this._filterSubscription.unsubscribe()}_addNewKeys(e,t){for(let i in t)t.hasOwnProperty(i)&&this.hasNode(i)&&(i in e||(e[i]=!0))}_cacheSequence$(e){return e in this._cachingSequences$||(this._cachingSequences$[e]=this._api.getSequence$(e).pipe(Ut((t=>{t?(t.id in this._sequences||(this._sequences[t.id]={accessed:(new Date).getTime(),sequence:new Cu(t)}),delete this._cachingSequences$[e]):console.warn(`Sequence does not exist (${e})`)})),De((()=>this)),Mt((()=>{e in this._cachingSequences$&&delete this._cachingSequences$[e],this._changed$.next(this)})),It(),U())),this._cachingSequences$[e]}_cacheTile$(e){return this._cachingTiles$[e]=this._api.getCoreImages$(e).pipe(Ut((t=>{if(e in this._cachedTiles)return;const i=t.images;this._nodeIndexTiles[e]=[],this._cachedTiles[e]={accessed:(new Date).getTime(),nodes:[]};const n=this._cachedTiles[e].nodes,r=this._removeFromPreStore(e);for(const t of i){if(!t)break;if(null==t.sequence.id){console.warn(`Sequence missing, discarding node (${t.id})`);continue}if(null!=r&&t.id in r){const i=r[t.id];delete r[t.id],n.push(i);const s={lat:i.lngLat.lat,lng:i.lngLat.lng,node:i};this._nodeIndex.insert(s),this._nodeIndexTiles[e].push(s),this._nodeToTile[i.id]=e;continue}const i=new Su(t);n.push(i);const s={lat:i.lngLat.lat,lng:i.lngLat.lng,node:i};this._nodeIndex.insert(s),this._nodeIndexTiles[e].push(s),this._nodeToTile[i.id]=e,this._setNode(i)}delete this._cachingTiles$[e]})),De((()=>this)),ct((t=>{throw delete this._cachingTiles$[e],t})),It(),U()),this._cachingTiles$[e]}_makeFull(e,t){null==t.computed_altitude&&(t.computed_altitude=this._defaultAlt),null==t.computed_rotation&&(t.computed_rotation=this._graphCalculator.rotationFromCompass(t.compass_angle,t.exif_orientation)),e.makeComplete(t)}_preStore(e,t){e in this._preStored||(this._preStored[e]={}),this._preStored[e][t.id]=t}_removeFromPreStore(e){let t=null;return e in this._preStored&&(t=this._preStored[e],delete this._preStored[e]),t}_setNode(e){let t=e.id;if(this.hasNode(t))throw new Bu(`Image already exist (${t}).`);this._nodes[t]=e}_uncacheTile(e,t){for(let i of this._cachedTiles[e].nodes){let n=i.id;delete this._nodeToTile[n],n in this._cachedNodes&&delete this._cachedNodes[n],n in this._cachedNodeTiles&&delete this._cachedNodeTiles[n],n in this._cachedSpatialEdges&&delete this._cachedSpatialEdges[n],i.sequenceId===t?(this._preStore(e,i),i.uncache()):(delete this._nodes[n],i.sequenceId in this._cachedSequenceNodes&&delete this._cachedSequenceNodes[i.sequenceId],i.dispose())}for(let t of this._nodeIndexTiles[e])this._nodeIndex.remove(t);delete this._nodeIndexTiles[e],delete this._cachedTiles[e]}_uncachePreStored(e){let t={};for(let[i,n]of e){i in this._nodes&&delete this._nodes[i],i in this._cachedNodes&&delete this._cachedNodes[i];let e=this._preStored[n][i];e.sequenceId in this._cachedSequenceNodes&&delete this._cachedSequenceNodes[e.sequenceId],delete this._preStored[n][i],e.dispose(),t[n]=!0}for(let e in t)t.hasOwnProperty(e)&&0===Object.keys(this._preStored[e]).length&&delete this._preStored[e]}_updateCachedTileAccess(e,t){e in this._nodeToTile&&(this._cachedTiles[this._nodeToTile[e]].accessed=t)}_updateCachedNodeAccess(e,t){e in this._cachedNodes&&(this._cachedNodes[e].accessed=t)}_updateCell$(e){return this._api.getCoreImages$(e).pipe(We((t=>{if(!(e in this._cachedTiles))return ie();const i=this._nodeIndex,n=this._nodeIndexTiles[e],r=this._nodeToTile,s=this._cachedTiles[e];s.accessed=(new Date).getTime();const a=s.nodes,o=t.images;for(const t of o){if(null==t)break;if(this.hasNode(t.id))continue;if(null==t.sequence.id){console.warn(`Sequence missing, discarding node (${t.id})`);continue}const s=new Su(t);a.push(s);const o={lat:s.lngLat.lat,lng:s.lngLat.lng,node:s};i.insert(o),n.push(o),r[s.id]=e,this._setNode(s)}return Ce(e)})),ct((e=>(console.error(e),ie()))))}}class Vu{constructor(){this._hash={},this._index=new Vu._spatialIndex(16),this._indexChanged$=new j,this._updated$=new j}static register(e){Vu._spatialIndex=e}get changed$(){return this._indexChanged$}get updated$(){return this._updated$}add(e){const t=[],i=this._hash,n=this._index;for(const r of e){const e=r.id;e in i&&(n.remove(i[e]),t.push(r));const s={lat:r.lngLat.lat,lng:r.lngLat.lng,marker:r};i[e]=s,n.insert(s)}t.length>0&&this._updated$.next(t),e.length>t.length&&this._indexChanged$.next(this)}has(e){return e in this._hash}get(e){return this.has(e)?this._hash[e].marker:void 0}getAll(){return this._index.all().map((e=>e.marker))}remove(e){const t=this._hash,i=this._index;let n=!1;for(const r of e){if(!(r in t))continue;const e=t[r];i.remove(e),delete t[r],n=!0}n&&this._indexChanged$.next(this)}removeAll(){this._hash={},this._index.clear(),this._indexChanged$.next(this)}search([e,t]){return this._index.search({maxX:t.lng,maxY:t.lat,minX:e.lng,minY:e.lat}).map((e=>e.marker))}update(e){const t=this._hash,i=this._index,n=e.id;if(!(n in t))return;i.remove(t[n]);const r={lat:e.lngLat.lat,lng:e.lngLat.lng,marker:e};t[n]=r,i.insert(r)}}function Hu(e,t,i,n,r){ju(e,t,i||0,n||e.length-1,r||Wu)}function ju(e,t,i,n,r){for(;n>i;){if(n-i>600){var s=n-i+1,a=t-i+1,o=Math.log(s),h=.5*Math.exp(2*o/3),c=.5*Math.sqrt(o*h*(s-h)/s)*(a-s/2<0?-1:1);ju(e,t,Math.max(i,Math.floor(t-a*h/s+c)),Math.min(n,Math.floor(t+(s-a)*h/s+c)),r)}var l=e[t],u=i,d=n;for(Gu(e,i,t),r(e[n],l)>0&&Gu(e,i,n);u<d;){for(Gu(e,u,d),u++,d--;r(e[u],l)<0;)u++;for(;r(e[d],l)>0;)d--}0===r(e[i],l)?Gu(e,i,d):Gu(e,++d,n),d<=t&&(i=d+1),t<=d&&(n=d-1)}}function Gu(e,t,i){var n=e[t];e[t]=e[i],e[i]=n}function Wu(e,t){return e<t?-1:e>t?1:0}function qu(e,t,i){if(!i)return t.indexOf(e);for(let n=0;n<t.length;n++)if(i(e,t[n]))return n;return-1}function Xu(e,t){Zu(e,0,e.children.length,t,e)}function Zu(e,t,i,n,r){r||(r=rd(null)),r.minX=1/0,r.minY=1/0,r.maxX=-1/0,r.maxY=-1/0;for(let s=t;s<i;s++){const t=e.children[s];Yu(r,e.leaf?n(t):t)}return r}function Yu(e,t){return e.minX=Math.min(e.minX,t.minX),e.minY=Math.min(e.minY,t.minY),e.maxX=Math.max(e.maxX,t.maxX),e.maxY=Math.max(e.maxY,t.maxY),e}function Ju(e,t){return e.minX-t.minX}function Ku(e,t){return e.minY-t.minY}function Qu(e){return(e.maxX-e.minX)*(e.maxY-e.minY)}function ed(e){return e.maxX-e.minX+(e.maxY-e.minY)}function td(e,t){const i=Math.max(e.minX,t.minX),n=Math.max(e.minY,t.minY),r=Math.min(e.maxX,t.maxX),s=Math.min(e.maxY,t.maxY);return Math.max(0,r-i)*Math.max(0,s-n)}function id(e,t){return e.minX<=t.minX&&e.minY<=t.minY&&t.maxX<=e.maxX&&t.maxY<=e.maxY}function nd(e,t){return t.minX<=e.maxX&&t.minY<=e.maxY&&t.maxX>=e.minX&&t.maxY>=e.minY}function rd(e){return{children:e,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function sd(e,t,i,n,r){const s=[t,i];for(;s.length;){if((i=s.pop())-(t=s.pop())<=n)continue;const a=t+Math.ceil((i-t)/n/2)*n;Hu(e,a,t,i,r),s.push(t,a,a,i)}}class ad extends class{constructor(e=9){this._maxEntries=Math.max(4,e),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),this.clear()}all(){return this._all(this.data,[])}search(e){let t=this.data;const i=[];if(!nd(e,t))return i;const n=this.toBBox,r=[];for(;t;){for(let s=0;s<t.children.length;s++){const a=t.children[s],o=t.leaf?n(a):a;nd(e,o)&&(t.leaf?i.push(a):id(e,o)?this._all(a,i):r.push(a))}t=r.pop()}return i}collides(e){let t=this.data;if(!nd(e,t))return!1;const i=[];for(;t;){for(let n=0;n<t.children.length;n++){const r=t.children[n],s=t.leaf?this.toBBox(r):r;if(nd(e,s)){if(t.leaf||id(e,s))return!0;i.push(r)}}t=i.pop()}return!1}load(e){if(!e||!e.length)return this;if(e.length<this._minEntries){for(let t=0;t<e.length;t++)this.insert(e[t]);return this}let t=this._build(e.slice(),0,e.length-1,0);if(this.data.children.length)if(this.data.height===t.height)this._splitRoot(this.data,t);else{if(this.data.height<t.height){const e=this.data;this.data=t,t=e}this._insert(t,this.data.height-t.height-1,!0)}else this.data=t;return this}insert(e){return e&&this._insert(e,this.data.height-1),this}clear(){return this.data=rd([]),this}remove(e,t){if(!e)return this;let i=this.data;const n=this.toBBox(e),r=[],s=[];let a,o,h;for(;i||r.length;){if(i||(i=r.pop(),o=r[r.length-1],a=s.pop(),h=!0),i.leaf){const n=qu(e,i.children,t);if(-1!==n)return i.children.splice(n,1),r.push(i),this._condense(r),this}h||i.leaf||!id(i,n)?o?(a++,i=o.children[a],h=!1):i=null:(r.push(i),s.push(a),a=0,o=i,i=i.children[0])}return this}toBBox(e){return e}compareMinX(e,t){return e.minX-t.minX}compareMinY(e,t){return e.minY-t.minY}toJSON(){return this.data}fromJSON(e){return this.data=e,this}_all(e,t){const i=[];for(;e;)e.leaf?t.push(...e.children):i.push(...e.children),e=i.pop();return t}_build(e,t,i,n){const r=i-t+1;let s,a=this._maxEntries;if(r<=a)return s=rd(e.slice(t,i+1)),Xu(s,this.toBBox),s;n||(n=Math.ceil(Math.log(r)/Math.log(a)),a=Math.ceil(r/Math.pow(a,n-1))),s=rd([]),s.leaf=!1,s.height=n;const o=Math.ceil(r/a),h=o*Math.ceil(Math.sqrt(a));sd(e,t,i,h,this.compareMinX);for(let r=t;r<=i;r+=h){const t=Math.min(r+h-1,i);sd(e,r,t,o,this.compareMinY);for(let i=r;i<=t;i+=o){const r=Math.min(i+o-1,t);s.children.push(this._build(e,i,r,n-1))}}return Xu(s,this.toBBox),s}_chooseSubtree(e,t,i,n){for(;n.push(t),!t.leaf&&n.length-1!==i;){let i,n=1/0,a=1/0;for(let o=0;o<t.children.length;o++){const h=t.children[o],c=Qu(h),l=(r=e,s=h,(Math.max(s.maxX,r.maxX)-Math.min(s.minX,r.minX))*(Math.max(s.maxY,r.maxY)-Math.min(s.minY,r.minY))-c);l<a?(a=l,n=c<n?c:n,i=h):l===a&&c<n&&(n=c,i=h)}t=i||t.children[0]}var r,s;return t}_insert(e,t,i){const n=i?e:this.toBBox(e),r=[],s=this._chooseSubtree(n,this.data,t,r);for(s.children.push(e),Yu(s,n);t>=0&&r[t].children.length>this._maxEntries;)this._split(r,t),t--;this._adjustParentBBoxes(n,r,t)}_split(e,t){const i=e[t],n=i.children.length,r=this._minEntries;this._chooseSplitAxis(i,r,n);const s=this._chooseSplitIndex(i,r,n),a=rd(i.children.splice(s,i.children.length-s));a.height=i.height,a.leaf=i.leaf,Xu(i,this.toBBox),Xu(a,this.toBBox),t?e[t-1].children.push(a):this._splitRoot(i,a)}_splitRoot(e,t){this.data=rd([e,t]),this.data.height=e.height+1,this.data.leaf=!1,Xu(this.data,this.toBBox)}_chooseSplitIndex(e,t,i){let n,r=1/0,s=1/0;for(let a=t;a<=i-t;a++){const t=Zu(e,0,a,this.toBBox),o=Zu(e,a,i,this.toBBox),h=td(t,o),c=Qu(t)+Qu(o);h<r?(r=h,n=a,s=c<s?c:s):h===r&&c<s&&(s=c,n=a)}return n||i-t}_chooseSplitAxis(e,t,i){const n=e.leaf?this.compareMinX:Ju,r=e.leaf?this.compareMinY:Ku;this._allDistMargin(e,t,i,n)<this._allDistMargin(e,t,i,r)&&e.children.sort(n)}_allDistMargin(e,t,i,n){e.children.sort(n);const r=this.toBBox,s=Zu(e,0,t,r),a=Zu(e,i-t,i,r);let o=ed(s)+ed(a);for(let n=t;n<i-t;n++){const t=e.children[n];Yu(s,e.leaf?r(t):t),o+=ed(s)}for(let n=i-t-1;n>=t;n--){const t=e.children[n];Yu(a,e.leaf?r(t):t),o+=ed(a)}return o}_adjustParentBBoxes(e,t,i){for(let n=i;n>=0;n--)Yu(t[n],e)}_condense(e){for(let t,i=e.length-1;i>=0;i--)0===e[i].children.length?i>0?(t=e[i-1].children,t.splice(t.indexOf(e[i]),1)):this.clear():Xu(e[i],this.toBBox)}}{compareMinX(e,t){return e.lng-t.lng}compareMinY(e,t){return e.lat-t.lat}toBBox(e){return{minX:e.lng,minY:e.lat,maxX:e.lng,maxY:e.lat}}}class od{constructor(e,t){this._components={};for(const i in od.registeredComponents){if(!od.registeredComponents.hasOwnProperty(i))continue;const n=od.registeredComponents[i];this._components[i]={active:!1,component:new n(i,e,t)}}this._coverComponent=new od.registeredCoverComponent("cover",e,t),this._coverComponent.activate(),this._coverActivated=!0}static register(e){void 0===od.registeredComponents[e.componentName]&&(od.registeredComponents[e.componentName]=e)}static registerCover(e){od.registeredCoverComponent=e}get coverActivated(){return this._coverActivated}activateCover(){if(!this._coverActivated){this._coverActivated=!0;for(const e in this._components){if(!this._components.hasOwnProperty(e))continue;const t=this._components[e];t.active&&t.component.deactivate()}}}deactivateCover(){if(this._coverActivated){this._coverActivated=!1;for(const e in this._components){if(!this._components.hasOwnProperty(e))continue;const t=this._components[e];t.active&&t.component.activate()}}}activate(e){this._checkName(e),this._components[e].active=!0,this._coverActivated||this.get(e).activate()}configure(e,t){this._checkName(e),this.get(e).configure(t)}deactivate(e){this._checkName(e),this._components[e].active=!1,this._coverActivated||this.get(e).deactivate()}get(e){return this._components[e].component}getCover(){return this._coverComponent}remove(){this._coverComponent.deactivate();for(const e in this._components)this._components.hasOwnProperty(e)&&this._components[e].component.deactivate()}_checkName(e){if(!(e in this._components))throw new Lu(`Component does not exist: ${e}`)}}od.registeredComponents={};var hd="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function cd(e){if(e.__esModule)return e;var t=Object.defineProperty({},"__esModule",{value:!0});return Object.keys(e).forEach((function(i){var n=Object.getOwnPropertyDescriptor(e,i);Object.defineProperty(t,i,n.get?n:{enumerable:!0,get:function(){return e[i]}})})),t}var ld=Array.isArray,ud=Object.prototype.toString,dd=ld||function(e){return"[object Array]"===ud.call(e)};md.NONE=0,md.VTEXT=1,md.VNODE=2,md.WIDGET=3,md.PROPS=4,md.ORDER=5,md.INSERT=6,md.REMOVE=7,md.THUNK=8;var pd=md;function md(e,t,i){this.type=Number(e),this.vNode=t,this.patch=i}md.prototype.version="2",md.prototype.type="VirtualPatch";var fd=function(e){return e&&"VirtualNode"===e.type&&"2"===e.version};var gd=function(e){return e&&"VirtualText"===e.type&&"2"===e.version};var _d=function(e){return e&&"Widget"===e.type};var vd=function(e){return e&&"Thunk"===e.type};var yd=fd,bd=gd,xd=_d,wd=vd,Md=function(e,t){var i=e,n=t;wd(t)&&(n=Sd(t,e));wd(e)&&(i=Sd(e,null));return{a:i,b:n}};function Sd(e,t){var i=e.vnode;if(i||(i=e.vnode=e.render(t)),!(yd(i)||bd(i)||xd(i)))throw new Error("thunk did not return a valid node");return i}var Td=function(e){return"object"==typeof e&&null!==e},Cd=function(e){return e&&("function"==typeof e.hook&&!e.hasOwnProperty("hook")||"function"==typeof e.unhook&&!e.hasOwnProperty("unhook"))};var Ed=Td,Ad=Cd;function Id(e){return Object.getPrototypeOf?Object.getPrototypeOf(e):e.__proto__?e.__proto__:e.constructor?e.constructor.prototype:void 0}var Rd=dd,Pd=pd,Ld=fd,Dd=gd,Nd=_d,$d=vd,kd=Md,Od=function e(t,i){var n;for(var r in t){r in i||((n=n||{})[r]=void 0);var s=t[r],a=i[r];if(s!==a)if(Ed(s)&&Ed(a))if(Id(a)!==Id(s))(n=n||{})[r]=a;else if(Ad(a))(n=n||{})[r]=a;else{var o=e(s,a);o&&((n=n||{})[r]=o)}else(n=n||{})[r]=a}for(var h in i)h in t||((n=n||{})[h]=i[h]);return n};function zd(e,t){var i={a:e};return Fd(e,t,i,0),i}function Fd(e,t,i,n){if(e!==t){var r=i[n],s=!1;if($d(e)||$d(t))Vd(e,t,i,n);else if(null==t)Nd(e)||(Bd(e,i,n),r=i[n]),r=Wd(r,new Pd(Pd.REMOVE,e,t));else if(Ld(t))if(Ld(e))if(e.tagName===t.tagName&&e.namespace===t.namespace&&e.key===t.key){var a=Od(e.properties,t.properties);a&&(r=Wd(r,new Pd(Pd.PROPS,e,a))),r=function(e,t,i,n,r){for(var s=e.children,a=function(e,t){var i=Gd(t),n=i.keys,r=i.free;if(r.length===t.length)return{children:t,moves:null};var s=Gd(e),a=s.keys;if(s.free.length===e.length)return{children:t,moves:null};for(var o=[],h=0,c=r.length,l=0,u=0;u<e.length;u++){var d,p=e[u];p.key?n.hasOwnProperty(p.key)?(d=n[p.key],o.push(t[d])):(d=u-l++,o.push(null)):h<c?(d=r[h++],o.push(t[d])):(d=u-l++,o.push(null))}for(var m=h>=r.length?t.length:r[h],f=0;f<t.length;f++){var g=t[f];g.key?a.hasOwnProperty(g.key)||o.push(g):f>=m&&o.push(g)}for(var _,v=o.slice(),y=0,b=[],x=[],w=0;w<t.length;){var M=t[w];for(_=v[y];null===_&&v.length;)b.push(jd(v,y,null)),_=v[y];_&&_.key===M.key?(y++,w++):M.key?(_&&_.key&&n[_.key]!==w+1?(b.push(jd(v,y,_.key)),(_=v[y])&&_.key===M.key?y++:x.push({key:M.key,to:w})):x.push({key:M.key,to:w}),w++):_&&_.key&&b.push(jd(v,y,_.key))}for(;y<v.length;)_=v[y],b.push(jd(v,y,_&&_.key));if(b.length===l&&!x.length)return{children:o,moves:null};return{children:o,moves:{removes:b,inserts:x}}}(s,t.children),o=a.children,h=s.length,c=o.length,l=h>c?h:c,u=0;u<l;u++){var d=s[u],p=o[u];r+=1,d?Fd(d,p,i,r):p&&(n=Wd(n,new Pd(Pd.INSERT,null,p))),Ld(d)&&d.count&&(r+=d.count)}a.moves&&(n=Wd(n,new Pd(Pd.ORDER,e,a.moves)));return n}(e,t,i,r,n)}else r=Wd(r,new Pd(Pd.VNODE,e,t)),s=!0;else r=Wd(r,new Pd(Pd.VNODE,e,t)),s=!0;else Dd(t)?Dd(e)?e.text!==t.text&&(r=Wd(r,new Pd(Pd.VTEXT,e,t))):(r=Wd(r,new Pd(Pd.VTEXT,e,t)),s=!0):Nd(t)&&(Nd(e)||(s=!0),r=Wd(r,new Pd(Pd.WIDGET,e,t)));r&&(i[n]=r),s&&Bd(e,i,n)}}function Bd(e,t,i){Hd(e,t,i),Ud(e,t,i)}function Ud(e,t,i){if(Nd(e))"function"==typeof e.destroy&&(t[i]=Wd(t[i],new Pd(Pd.REMOVE,e,null)));else if(Ld(e)&&(e.hasWidgets||e.hasThunks))for(var n=e.children,r=n.length,s=0;s<r;s++){var a=n[s];Ud(a,t,i+=1),Ld(a)&&a.count&&(i+=a.count)}else $d(e)&&Vd(e,null,t,i)}function Vd(e,t,i,n){var r=kd(e,t),s=zd(r.a,r.b);(function(e){for(var t in e)if("a"!==t)return!0;return!1})(s)&&(i[n]=new Pd(Pd.THUNK,null,s))}function Hd(e,t,i){if(Ld(e)){if(e.hooks&&(t[i]=Wd(t[i],new Pd(Pd.PROPS,e,function(e){var t={};for(var i in e)t[i]=void 0;return t}(e.hooks)))),e.descendantHooks||e.hasThunks)for(var n=e.children,r=n.length,s=0;s<r;s++){var a=n[s];Hd(a,t,i+=1),Ld(a)&&a.count&&(i+=a.count)}}else $d(e)&&Vd(e,null,t,i)}function jd(e,t,i){return e.splice(t,1),{from:t,key:i}}function Gd(e){for(var t={},i=[],n=e.length,r=0;r<n;r++){var s=e[r];s.key?t[s.key]=r:i.push(r)}return{keys:t,free:i}}function Wd(e,t){return e?(Rd(e)?e.push(t):e=[e,t],e):t}var qd=zd,Xd=Array.prototype.slice,Zd=function(e,t){"length"in e||(e=[e]);e=Xd.call(e);for(;e.length;){var i=e.shift(),n=t(i);if(n)return n;i.childNodes&&i.childNodes.length&&(e=Xd.call(i.childNodes).concat(e))}};var Yd=Jd;function Jd(e,t){if(!(this instanceof Jd))return new Jd(e,t);this.data=e,this.nodeValue=e,this.length=e.length,this.ownerDocument=t||null}Jd.prototype.nodeType=8,Jd.prototype.nodeName="#comment",Jd.prototype.toString=function(){return"[object Comment]"};var Kd=Qd;function Qd(e,t){if(!(this instanceof Qd))return new Qd(e);this.data=e||"",this.length=this.data.length,this.ownerDocument=t||null}Qd.prototype.type="DOMTextNode",Qd.prototype.nodeType=3,Qd.prototype.nodeName="#text",Qd.prototype.toString=function(){return this.data},Qd.prototype.replaceData=function(e,t,i){var n=this.data,r=n.substring(0,e),s=n.substring(e+t,n.length);this.data=r+i+s,this.length=this.data.length};var ep=function(e){var t=this,i=e.type;e.target||(e.target=t);t.listeners||(t.listeners={});var n=t.listeners[i];if(n)return n.forEach((function(i){e.currentTarget=t,"function"==typeof i?i(e):i.handleEvent(e)}));t.parentNode&&t.parentNode.dispatchEvent(e)};var tp=function(e,t){var i=this;i.listeners||(i.listeners={});i.listeners[e]||(i.listeners[e]=[]);-1===i.listeners[e].indexOf(t)&&i.listeners[e].push(t)};var ip=function(e,t){var i=this;if(!i.listeners)return;if(!i.listeners[e])return;var n=i.listeners[e],r=n.indexOf(t);-1!==r&&n.splice(r,1)};var np=["area","base","br","col","embed","hr","img","input","keygen","link","menuitem","meta","param","source","track","wbr"];function rp(e){switch(e.nodeType){case 3:return op(e.data);case 8:return"\x3c!--"+e.data+"--\x3e";default:return function(e){var t=[],i=e.tagName;"http://www.w3.org/1999/xhtml"===e.namespaceURI&&(i=i.toLowerCase());t.push("<"+i+function(e){var t=[];for(var i in e)sp(e,i)&&t.push({name:i,value:e[i]});for(var n in e._attributes)for(var r in e._attributes[n]){var s=e._attributes[n][r],a=(s.prefix?s.prefix+":":"")+r;t.push({name:a,value:s.value})}e.className&&t.push({name:"class",value:e.className});return t.length?ap(t):""}(e)+function(e){var t=e.dataset,i=[];for(var n in t)i.push({name:"data-"+n,value:t[n]});return i.length?ap(i):""}(e)),np.indexOf(i)>-1?t.push(" />"):(t.push(">"),e.childNodes.length?t.push.apply(t,e.childNodes.map(rp)):e.textContent||e.innerText?t.push(op(e.textContent||e.innerText)):e.innerHTML&&t.push(e.innerHTML),t.push("</"+i+">"));return t.join("")}(e)}}function sp(e,t){var i=typeof e[t];return"style"===t&&Object.keys(e.style).length>0||e.hasOwnProperty(t)&&("string"===i||"boolean"===i||"number"===i)&&"nodeName"!==t&&"className"!==t&&"tagName"!==t&&"textContent"!==t&&"innerText"!==t&&"namespaceURI"!==t&&"innerHTML"!==t}function ap(e){var t=[];return e.forEach((function(e){var i=e.name,n=e.value;"style"===i&&(n=function(e){if("string"==typeof e)return e;var t="";return Object.keys(e).forEach((function(i){var n=e[i];i=i.replace(/[A-Z]/g,(function(e){return"-"+e.toLowerCase()})),t+=i+":"+n+";"})),t}(n)),t.push(i+'="'+(op(n).replace(/"/g,""")+'"'))})),t.length?" "+t.join(" "):""}function op(e){var t="";return"string"==typeof e?t=e:e&&(t=e.toString()),t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}var hp=Zd,cp=ep,lp=tp,up=ip,dp=rp,pp="http://www.w3.org/1999/xhtml",mp=fp;function fp(e,t,i){if(!(this instanceof fp))return new fp(e);var n=void 0===i?pp:i||null;this.tagName=n===pp?String(e).toUpperCase():e,this.nodeName=this.tagName,this.className="",this.dataset={},this.childNodes=[],this.parentNode=null,this.style={},this.ownerDocument=t||null,this.namespaceURI=n,this._attributes={},"INPUT"===this.tagName&&(this.type="text")}fp.prototype.type="DOMElement",fp.prototype.nodeType=1,fp.prototype.appendChild=function(e){return e.parentNode&&e.parentNode.removeChild(e),this.childNodes.push(e),e.parentNode=this,e},fp.prototype.replaceChild=function(e,t){e.parentNode&&e.parentNode.removeChild(e);var i=this.childNodes.indexOf(t);return t.parentNode=null,this.childNodes[i]=e,e.parentNode=this,t},fp.prototype.removeChild=function(e){var t=this.childNodes.indexOf(e);return this.childNodes.splice(t,1),e.parentNode=null,e},fp.prototype.insertBefore=function(e,t){e.parentNode&&e.parentNode.removeChild(e);var i=null==t?-1:this.childNodes.indexOf(t);return i>-1?this.childNodes.splice(i,0,e):this.childNodes.push(e),e.parentNode=this,e},fp.prototype.setAttributeNS=function(e,t,i){var n=null,r=t,s=t.indexOf(":");(s>-1&&(n=t.substr(0,s),r=t.substr(s+1)),"INPUT"===this.tagName&&"type"===t)?this.type=i:(this._attributes[e]||(this._attributes[e]={}))[r]={value:i,prefix:n}},fp.prototype.getAttributeNS=function(e,t){var i=this._attributes[e],n=i&&i[t]&&i[t].value;return"INPUT"===this.tagName&&"type"===t?this.type:"string"!=typeof n?null:n},fp.prototype.removeAttributeNS=function(e,t){var i=this._attributes[e];i&&delete i[t]},fp.prototype.hasAttributeNS=function(e,t){var i=this._attributes[e];return!!i&&t in i},fp.prototype.setAttribute=function(e,t){return this.setAttributeNS(null,e,t)},fp.prototype.getAttribute=function(e){return this.getAttributeNS(null,e)},fp.prototype.removeAttribute=function(e){return this.removeAttributeNS(null,e)},fp.prototype.hasAttribute=function(e){return this.hasAttributeNS(null,e)},fp.prototype.removeEventListener=up,fp.prototype.addEventListener=lp,fp.prototype.dispatchEvent=cp,fp.prototype.focus=function(){},fp.prototype.toString=function(){return dp(this)},fp.prototype.getElementsByClassName=function(e){var t=e.split(" "),i=[];return hp(this,(function(e){if(1===e.nodeType){var n=(e.className||"").split(" ");t.every((function(e){return-1!==n.indexOf(e)}))&&i.push(e)}})),i},fp.prototype.getElementsByTagName=function(e){e=e.toLowerCase();var t=[];return hp(this.childNodes,(function(i){1!==i.nodeType||"*"!==e&&i.tagName.toLowerCase()!==e||t.push(i)})),t},fp.prototype.contains=function(e){return hp(this,(function(t){return e===t}))||!1};var gp=mp,_p=vp;function vp(e){if(!(this instanceof vp))return new vp;this.childNodes=[],this.parentNode=null,this.ownerDocument=e||null}vp.prototype.type="DocumentFragment",vp.prototype.nodeType=11,vp.prototype.nodeName="#document-fragment",vp.prototype.appendChild=gp.prototype.appendChild,vp.prototype.replaceChild=gp.prototype.replaceChild,vp.prototype.removeChild=gp.prototype.removeChild,vp.prototype.toString=function(){return this.childNodes.map((function(e){return String(e)})).join("")};var yp=bp;function bp(e){}bp.prototype.initEvent=function(e,t,i){this.type=e,this.bubbles=t,this.cancelable=i},bp.prototype.preventDefault=function(){};var xp=Zd,wp=Yd,Mp=Kd,Sp=mp,Tp=_p,Cp=yp,Ep=ep,Ap=tp,Ip=ip,Rp=Pp;function Pp(){if(!(this instanceof Pp))return new Pp;this.head=this.createElement("head"),this.body=this.createElement("body"),this.documentElement=this.createElement("html"),this.documentElement.appendChild(this.head),this.documentElement.appendChild(this.body),this.childNodes=[this.documentElement],this.nodeType=9}var Lp=Pp.prototype;Lp.createTextNode=function(e){return new Mp(e,this)},Lp.createElementNS=function(e,t){var i=null===e?null:String(e);return new Sp(t,this,i)},Lp.createElement=function(e){return new Sp(e,this)},Lp.createDocumentFragment=function(){return new Tp(this)},Lp.createEvent=function(e){return new Cp(e)},Lp.createComment=function(e){return new wp(e,this)},Lp.getElementById=function(e){return e=String(e),xp(this.childNodes,(function(t){if(String(t.id)===e)return t}))||null},Lp.getElementsByClassName=Sp.prototype.getElementsByClassName,Lp.getElementsByTagName=Sp.prototype.getElementsByTagName,Lp.contains=Sp.prototype.contains,Lp.removeEventListener=Ip,Lp.addEventListener=Ap,Lp.dispatchEvent=Ep;var Dp,Np=new Rp,$p=void 0!==hd?hd:"undefined"!=typeof window?window:{},kp=Np;"undefined"!=typeof document?Dp=document:(Dp=$p["__GLOBAL_DOCUMENT_CACHE@4"])||(Dp=$p["__GLOBAL_DOCUMENT_CACHE@4"]=kp);var Op=Td,zp=Cd,Fp=function(e,t,i){for(var n in t){var r=t[n];void 0===r?Bp(e,n,r,i):zp(r)?(Bp(e,n,r,i),r.hook&&r.hook(e,n,i?i[n]:void 0)):Op(r)?Up(e,t,i,n,r):e[n]=r}};function Bp(e,t,i,n){if(n){var r=n[t];if(zp(r))r.unhook&&r.unhook(e,t,i);else if("attributes"===t)for(var s in r)e.removeAttribute(s);else if("style"===t)for(var a in r)e.style[a]="";else e[t]="string"==typeof r?"":null}}function Up(e,t,i,n,r){var s=i?i[n]:void 0;if("attributes"!==n)if(s&&Op(s)&&Vp(s)!==Vp(r))e[n]=r;else{Op(e[n])||(e[n]={});var a="style"===n?"":void 0;for(var o in r){var h=r[o];e[n][o]=void 0===h?a:h}}else for(var c in r){var l=r[c];void 0===l?e.removeAttribute(c):e.setAttribute(c,l)}}function Vp(e){return Object.getPrototypeOf?Object.getPrototypeOf(e):e.__proto__?e.__proto__:e.constructor?e.constructor.prototype:void 0}var Hp=Dp,jp=Fp,Gp=fd,Wp=gd,qp=_d,Xp=Md,Zp=function e(t,i){var n=i&&i.document||Hp,r=i?i.warn:null;if(t=Xp(t).a,qp(t))return t.init();if(Wp(t))return n.createTextNode(t.text);if(!Gp(t))return r&&r("Item is not a valid virtual dom node",t),null;var s=null===t.namespace?n.createElement(t.tagName):n.createElementNS(t.namespace,t.tagName),a=t.properties;jp(s,a);for(var o=t.children,h=0;h<o.length;h++){var c=e(o[h],i);c&&s.appendChild(c)}return s};var Yp={};function Jp(e,t,i,n,r){if(n=n||{},e){Kp(i,r,r)&&(n[r]=e);var s=t.children;if(s)for(var a=e.childNodes,o=0;o<t.children.length;o++){r+=1;var h=s[o]||Yp,c=r+(h.count||0);Kp(i,r,c)&&Jp(a[o],h,i,n,r),r=c}}return n}function Kp(e,t,i){if(0===e.length)return!1;for(var n,r,s=0,a=e.length-1;s<=a;){if(r=e[n=(a+s)/2>>0],s===a)return r>=t&&r<=i;if(r<t)s=n+1;else{if(!(r>i))return!0;a=n-1}}return!1}function Qp(e,t){return e>t?1:-1}var em=_d;var tm=Fp,im=_d,nm=pd,rm=function(e,t){if(em(e)&&em(t))return"name"in e&&"name"in t?e.id===t.id:e.init===t.init;return!1};function sm(e,t){"function"==typeof t.destroy&&im(t)&&t.destroy(e)}var am=Dp,om=dd,hm=Zp,cm=function(e,t,i,n){return i&&0!==i.length?(i.sort(Qp),Jp(e,t,i,n,0)):{}},lm=function(e,t,i){var n=e.type,r=e.vNode,s=e.patch;switch(n){case nm.REMOVE:return function(e,t){var i=e.parentNode;i&&i.removeChild(e);return sm(e,t),null}(t,r);case nm.INSERT:return function(e,t,i){var n=i.render(t,i);e&&e.appendChild(n);return e}(t,s,i);case nm.VTEXT:return function(e,t,i,n){var r;if(3===e.nodeType)e.replaceData(0,e.length,i.text),r=e;else{var s=e.parentNode;r=n.render(i,n),s&&r!==e&&s.replaceChild(r,e)}return r}(t,0,s,i);case nm.WIDGET:return function(e,t,i,n){var r,s=rm(t,i);r=s?i.update(t,e)||e:n.render(i,n);var a=e.parentNode;a&&r!==e&&a.replaceChild(r,e);s||sm(e,t);return r}(t,r,s,i);case nm.VNODE:return function(e,t,i,n){var r=e.parentNode,s=n.render(i,n);r&&s!==e&&r.replaceChild(s,e);return s}(t,0,s,i);case nm.ORDER:return function(e,t){for(var i,n,r,s=e.childNodes,a={},o=0;o<t.removes.length;o++)i=s[(n=t.removes[o]).from],n.key&&(a[n.key]=i),e.removeChild(i);for(var h=s.length,c=0;c<t.inserts.length;c++)i=a[(r=t.inserts[c]).key],e.insertBefore(i,r.to>=h++?null:s[r.to])}(t,s),t;case nm.PROPS:return tm(t,s,r.properties),t;case nm.THUNK:return function(e,t){e&&t&&e!==t&&e.parentNode&&e.parentNode.replaceChild(t,e);return t}(t,i.patch(t,s,i));default:return t}};function um(e,t,i){var n=function(e){var t=[];for(var i in e)"a"!==i&&t.push(Number(i));return t}(t);if(0===n.length)return e;var r=cm(e,t.a,n),s=e.ownerDocument;i.document||s===am||(i.document=s);for(var a=0;a<n.length;a++){var o=n[a];e=dm(e,r[o],t[o],i)}return e}function dm(e,t,i,n){if(!t)return e;var r;if(om(i))for(var s=0;s<i.length;s++)r=lm(i[s],t,n),t===e&&(e=r);else r=lm(i,t,n),t===e&&(e=r);return e}var pm=function e(t,i,n){return(n=n||{}).patch=n.patch&&n.patch!==e?n.patch:um,n.render=n.render||hm,n.patch(t,i,n)},mm=fd,fm=_d,gm=vd,_m=Cd,vm=xm,ym={},bm=[];function xm(e,t,i,n,r){this.tagName=e,this.properties=t||ym,this.children=i||bm,this.key=null!=n?String(n):void 0,this.namespace="string"==typeof r?r:null;var s,a=i&&i.length||0,o=0,h=!1,c=!1,l=!1;for(var u in t)if(t.hasOwnProperty(u)){var d=t[u];_m(d)&&d.unhook&&(s||(s={}),s[u]=d)}for(var p=0;p<a;p++){var m=i[p];mm(m)?(o+=m.count||0,!h&&m.hasWidgets&&(h=!0),!c&&m.hasThunks&&(c=!0),l||!m.hooks&&!m.descendantHooks||(l=!0)):!h&&fm(m)?"function"==typeof m.destroy&&(h=!0):!c&&gm(m)&&(c=!0)}this.count=a+o,this.hasWidgets=h,this.hasThunks=c,this.hooks=s,this.descendantHooks=l}xm.prototype.version="2",xm.prototype.type="VirtualNode";var wm=Mm;function Mm(e){this.text=String(e)}Mm.prototype.version="2",Mm.prototype.type="VirtualText";
27 var Sm,Tm,Cm,Em=(Tm=String.prototype.split,Cm=/()??/.exec("")[1]===Sm,function(e,t,i){if("[object RegExp]"!==Object.prototype.toString.call(t))return Tm.call(e,t,i);var n,r,s,a,o=[],h=(t.ignoreCase?"i":"")+(t.multiline?"m":"")+(t.extended?"x":"")+(t.sticky?"y":""),c=0;for(t=new RegExp(t.source,h+"g"),e+="",Cm||(n=new RegExp("^"+t.source+"$(?!\\s)",h)),i=i===Sm?-1>>>0:i>>>0;(r=t.exec(e))&&!((s=r.index+r[0].length)>c&&(o.push(e.slice(c,r.index)),!Cm&&r.length>1&&r[0].replace(n,(function(){for(var e=1;e<arguments.length-2;e++)arguments[e]===Sm&&(r[e]=Sm)})),r.length>1&&r.index<e.length&&Array.prototype.push.apply(o,r.slice(1)),a=r[0].length,c=s,o.length>=i));)t.lastIndex===r.index&&t.lastIndex++;return c===e.length?!a&&t.test("")||o.push(""):o.push(e.slice(c)),o.length>i?o.slice(0,i):o}),Am=/([\.#]?[a-zA-Z0-9\u007F-\uFFFF_:-]+)/,Im=/^\.|#/,Rm=function(e,t){if(!e)return"DIV";var i,n,r,s,a=!t.hasOwnProperty("id"),o=Em(e,Am),h=null;Im.test(o[1])&&(h="DIV");for(s=0;s<o.length;s++)(n=o[s])&&(r=n.charAt(0),h?"."===r?(i=i||[]).push(n.substring(1,n.length)):"#"===r&&a&&(t.id=n.substring(1,n.length)):h=n);i&&(t.className&&i.push(t.className),t.className=i.join(" "));return t.namespace?h:h.toUpperCase()};var Pm=Lm;function Lm(e){if(!(this instanceof Lm))return new Lm(e);this.value=e}Lm.prototype.hook=function(e,t){e[t]!==this.value&&(e[t]=this.value)};var Dm="undefined"!=typeof window?window:void 0!==hd?hd:{};var Nm=function(e,t){if(e in Dm)return Dm[e];return Dm[e]=t,t};(function(e,t,i){var n="__INDIVIDUAL_ONE_VERSION_"+e,r=Nm(n+"_ENFORCE_SINGLETON",t);if(r!==t)throw new Error("Can only have one copy of "+e+".\nYou already have version "+r+" installed.\nThis means you cannot install version "+t);Nm(n,i)})("ev-store","7");var $m="__EV_STORE_KEY@7";var km=function(e){var t=e[$m];t||(t=e[$m]={});return t},Om=zm;function zm(e){if(!(this instanceof zm))return new zm(e);this.value=e}zm.prototype.hook=function(e,t){km(e)[t.substr(3)]=this.value},zm.prototype.unhook=function(e,t){km(e)[t.substr(3)]=void 0};var Fm=dd,Bm=vm,Um=wm,Vm=fd,Hm=gd,jm=_d,Gm=Cd,Wm=vd,qm=Rm,Xm=Pm,Zm=Om;function Ym(e,t,i,n){if("string"==typeof e)t.push(new Um(e));else if("number"==typeof e)t.push(new Um(String(e)));else if(Jm(e))t.push(e);else{if(!Fm(e)){if(null==e)return;throw function(e){var t=new Error;return t.type="virtual-hyperscript.unexpected.virtual-element",t.message="Unexpected virtual child passed to h().\nExpected a VNode / Vthunk / VWidget / string but:\ngot:\n"+Km(e.foreignObject)+".\nThe parent vnode is:\n"+Km(e.parentVnode),t.foreignObject=e.foreignObject,t.parentVnode=e.parentVnode,t}({foreignObject:e,parentVnode:{tagName:i,properties:n}})}for(var r=0;r<e.length;r++)Ym(e[r],t,i,n)}}function Jm(e){return Vm(e)||Hm(e)||jm(e)||Wm(e)}function Km(e){try{return JSON.stringify(e,null," ")}catch(t){return String(e)}}var Qm,ef,tf={diff:qd,patch:pm,h:function(e,t,i){var n,r,s,a,o=[];!i&&(h=t,"string"==typeof h||Fm(h)||Jm(h))&&(i=t,r={});var h;n=qm(e,r=r||t||{}),r.hasOwnProperty("key")&&(s=r.key,r.key=void 0);r.hasOwnProperty("namespace")&&(a=r.namespace,r.namespace=void 0);"INPUT"!==n||a||!r.hasOwnProperty("value")||void 0===r.value||Gm(r.value)||(r.value=Xm(r.value));(function(e){for(var t in e)if(e.hasOwnProperty(t)){var i=e[t];if(Gm(i))continue;"ev-"===t.substr(0,3)&&(e[t]=Zm(i))}})(r),null!=i&&Ym(i,o,n,r);return new Bm(n,r,o,s,a)},create:Zp,VNode:vm,VText:wm};class nf{constructor(){this._events={}}fire(e,t){if(this._listens(e))for(const i of this._events[e])i(t)}off(e,t){if(e){if(this._listens(e)){const i=this._events[e].indexOf(t);i>=0&&this._events[e].splice(i,1),this._events[e].length||delete this._events[e]}}else this._events={}}on(e,t){this._events[e]=this._events[e]||[],this._events[e].push(t)}_listens(e){return e in this._events}}class rf{constructor(){this._subscriptions=[]}push(e){this._subscriptions.push(e)}unsubscribe(){for(const e of this._subscriptions)e.unsubscribe();this._subscriptions=[]}}class sf extends nf{constructor(e,t,i){super(),this._activated$=new W(!1),this._configurationSubject$=new j,this._activated=!1,this._container=t,this._name=e,this._navigator=i,this._subscriptions=new rf,this._configuration$=this._configurationSubject$.pipe(Ot(this.defaultConfiguration),Lt(((e,t)=>{for(let i in t)t.hasOwnProperty(i)&&(e[i]=t[i]);return e})),Rt(1),U()),this._configuration$.subscribe((()=>{}))}get activated(){return this._activated}get activated$(){return this._activated$}get defaultConfiguration(){return this._getDefaultConfiguration()}get configuration$(){return this._configuration$}get name(){return this._name}activate(e){this._activated||(void 0!==e&&this._configurationSubject$.next(e),this._activated=!0,this._activate(),this._activated$.next(!0))}configure(e){this._configurationSubject$.next(e)}deactivate(){this._activated&&(this._activated=!1,this._deactivate(),this._container.domRenderer.clear(this._name),this._container.glRenderer.clear(this._name),this._activated$.next(!1))}fire(e,t){super.fire(e,t)}off(e,t){super.off(e,t)}on(e,t){super.on(e,t)}resize(){}}!function(e){e[e.Hidden=0]="Hidden",e[e.Loading=1]="Loading",e[e.Visible=2]="Visible"}(Qm||(Qm={}));class af extends sf{constructor(e,t,i){super(e,t,i)}_activate(){const e=this.configuration$.pipe(St((e=>!!e.id)),st((e=>!e.src)),zt((e=>this._getImageSrc$(e.id).pipe(ct((e=>(console.error(e),ie())))))),Rt(1),U()),t=this._subscriptions;t.push(e.pipe(De((e=>({src:e})))).subscribe((e=>{this._configurationSubject$.next(e)}))),t.push(Ve(this.configuration$,e).pipe(st((([e,t])=>!!e.src&&e.src!==t)),St()).subscribe((([,e])=>{window.URL.revokeObjectURL(e)}))),t.push(this._configuration$.pipe(vt(void 0,(e=>e.state)),zt((e=>Ve(Ce(e.state),this._navigator.stateService.currentImage$))),zt((([e,t])=>{const i=Ve(Ce(t.id),t.image$.pipe(st((e=>!!e)),De((e=>e.src))));return e===Qm.Visible?i.pipe(St()):i})),vt((([e,t],[i,n])=>e===i&&t===n)),De((([e,t])=>({id:e,src:t})))).subscribe(this._configurationSubject$)),t.push(Ve(this._configuration$,this._container.configurationService.exploreUrl$,this._container.renderService.size$).pipe(De((([e,t,i])=>{if(!e.src)return{name:this._name,vNode:tf.h("div",[])};const n=i.width<=640||i.height<=480?".mapillary-cover-compact":"";if(e.state===Qm.Hidden){const t=tf.h("div.mapillary-cover-container.mapillary-cover-done"+n,[this._getCoverBackgroundVNode(e)]);return{name:this._name,vNode:t}}const r=tf.h("div.mapillary-cover-container"+n,[this._getCoverButtonVNode(e,t)]);return{name:this._name,vNode:r}}))).subscribe(this._container.domRenderer.render$))}_deactivate(){this._subscriptions.unsubscribe()}_getDefaultConfiguration(){return{state:Qm.Visible}}_getCoverButtonVNode(e,t){const i=e.state===Qm.Loading?"div.mapillary-cover.mapillary-cover-loading":"div.mapillary-cover",n=tf.h("div.mapillary-cover-button",[tf.h("div.mapillary-cover-button-icon",[])]),r=tf.h("a.mapillary-cover-logo",{href:t,target:"_blank"},[]),s=tf.h("div.mapillary-cover-indicator",{onclick:()=>{this.configure({state:Qm.Loading})}},[]);return tf.h(i,[this._getCoverBackgroundVNode(e),s,n,r])}_getCoverBackgroundVNode(e){const t={style:{backgroundImage:`url(${e.src})`}},i=[];return e.state===Qm.Loading&&i.push(tf.h("div.mapillary-cover-spinner",{},[])),tf.h("div.mapillary-cover-background",t,i)}_getImageSrc$(e){return k.create((t=>{this._navigator.api.getImages$([e]).subscribe((i=>{for(const n of i){const i="number"==typeof e?e.toString():e;if(n.node_id===i)return void this._navigator.api.data.getImageBuffer(n.node.thumb.url).then((i=>{const n=new Image;n.crossOrigin="Anonymous",n.onload=()=>{t.next(n.src),t.complete()},n.onerror=()=>{t.error(new Error(`Failed to load cover image (${e})`))};const r=new Blob([i]);n.src=window.URL.createObjectURL(r)}),(e=>{t.error(e)}))}t.error(new Pu(`Non existent cover key: ${e}`))}),(e=>{t.error(e)}))}))}}af.componentName="cover";class of extends sf{_activate(){this._subscriptions.push(Ve(this._container.configurationService.exploreUrl$,this._navigator.stateService.currentImage$,this._container.renderService.size$).pipe(De((([e,t,i])=>{const n=this._makeAttribution(t.creatorUsername,e,t.id,t.capturedAt,i.width);return{name:this._name,vNode:n}}))).subscribe(this._container.domRenderer.render$))}_deactivate(){this._subscriptions.unsubscribe()}_getDefaultConfiguration(){return{}}makeImageUrl(e,t){return`${e}/app/?pKey=${t}&focus=photo`}_makeAttribution(e,t,i,n,r){const s=r<=640,a=this._makeDate(n,s),o=this._makeBy(e,t,i,s),h=s?".mapillary-attribution-compact":"";return tf.h("div.mapillary-attribution-container"+h,{},[...o,a])}_makeBy(e,t,i,n){const r=tf.h("div.mapillary-attribution-logo",[]);return e?this._makeCreatorBy(r,e,t,i,n):this._makeGeneralBy(r,t,i,n)}_makeCreatorBy(e,t,i,n,r){const s=tf.h("a.mapillary-attribution-icon-container",{href:i,rel:"noreferrer",target:"_blank"},[e]),a=r?`${t}`:`image by ${t}`,o=tf.h("div.mapillary-attribution-username",{textContent:a},[]);return[s,tf.h("a.mapillary-attribution-image-container",{href:this.makeImageUrl(i,n),rel:"noreferrer",target:"_blank"},[o])]}_makeGeneralBy(e,t,i,n){const r=tf.h("div.mapillary-attribution-username",{textContent:"images by"},[]),s=[tf.h("div.mapillary-attribution-icon-container",{},[e]),tf.h("div.mapillary-attribution-username",{textContent:"contributors"},[])];n||s.unshift(r);return[tf.h("a.mapillary-attribution-image-container",{href:this.makeImageUrl(t,i),rel:"noreferrer",target:"_blank"},s)]}_makeDate(e,t){const i=new Date(e).toDateString().split(" "),n=(i.length>3?t?[i[3]]:[i[1],i[2]+",",i[3]]:i).join(" ");return tf.h("div.mapillary-attribution-date",{textContent:n},[])}}of.componentName="attribution";class hf{constructor(){this._unprojectDepth=200}basicToCanvas(e,t,i,n,r){const s=n.unprojectBasic([e,t],this._unprojectDepth);return this.projectToCanvas(s,i,r)}basicToCanvasSafe(e,t,i,n,r){const s=this.basicToViewportSafe(e,t,n,r);if(null===s)return null;return this.viewportToCanvas(s[0],s[1],i)}basicToViewport(e,t,i,n){const r=i.unprojectBasic([e,t],this._unprojectDepth);return this.projectToViewport(r,n)}basicToViewportSafe(e,t,i,n){const r=i.unprojectBasic([e,t],this._unprojectDepth);if(this.worldToCamera(r,n)[2]>0)return null;return this.projectToViewport(r,n)}cameraToViewport(e,t){const i=(new Ki).fromArray(e).applyMatrix4(t.projectionMatrix);return[i.x,i.y]}canvasPosition(e,t){const i=t.getBoundingClientRect();return[e.clientX-i.left-t.clientLeft,e.clientY-i.top-t.clientTop]}canvasToBasic(e,t,i,n,r){const s=this.unprojectFromCanvas(e,t,i,r).toArray();return n.projectBasic(s)}canvasToViewport(e,t,i){const[n,r]=this.containerToCanvas(i);return[2*e/n-1,1-2*t/r]}containerToCanvas(e){return[e.offsetWidth,e.offsetHeight]}getBasicDistances(e,t){const i=this.viewportToBasic(-1,1,e,t),n=this.viewportToBasic(1,1,e,t),r=this.viewportToBasic(1,-1,e,t),s=this.viewportToBasic(-1,-1,e,t);let a=0,o=0,h=0,c=0;return i[1]<0&&n[1]<0&&(a=i[1]>n[1]?-i[1]:-n[1]),n[0]>1&&r[0]>1&&(o=n[0]<r[0]?n[0]-1:r[0]-1),r[1]>1&&s[1]>1&&(h=r[1]<s[1]?r[1]-1:s[1]-1),s[0]<0&&i[0]<0&&(c=s[0]>i[0]?-s[0]:-i[0]),[a,o,h,c]}getPixelDistances(e,t,i){const n=this.viewportToBasic(-1,1,t,i),r=this.viewportToBasic(1,1,t,i),s=this.viewportToBasic(1,-1,t,i),a=this.viewportToBasic(-1,-1,t,i);let o=0,h=0,c=0,l=0;const[u,d]=this.containerToCanvas(e);if(n[1]<0&&r[1]<0){const s=n[1]>r[1]?n[0]:r[0],a=this.basicToCanvas(s,0,e,t,i);o=a[1]>0?a[1]:0}if(r[0]>1&&s[0]>1){const n=r[0]<s[0]?r[1]:s[1],a=this.basicToCanvas(1,n,e,t,i);h=a[0]<u?u-a[0]:0}if(s[1]>1&&a[1]>1){const n=s[1]<a[1]?s[0]:a[0],r=this.basicToCanvas(n,1,e,t,i);c=r[1]<d?d-r[1]:0}if(a[0]<0&&n[0]<0){const r=a[0]>n[0]?a[1]:n[1],s=this.basicToCanvas(0,r,e,t,i);l=s[0]>0?s[0]:0}return[o,h,c,l]}insideElement(e,t){const i=t.getBoundingClientRect(),n=i.left+t.clientLeft,r=n+t.clientWidth,s=i.top+t.clientTop,a=s+t.clientHeight;return e.clientX>n&&e.clientX<r&&e.clientY>s&&e.clientY<a}projectToCanvas(e,t,i){const n=this.projectToViewport(e,i);return this.viewportToCanvas(n[0],n[1],t)}projectToCanvasSafe(e,t,i){if(this.worldToCamera(e,i)[2]>0)return null;const n=this.projectToViewport(e,i);return this.viewportToCanvas(n[0],n[1],t)}projectToViewport(e,t){const i=new Ki(e[0],e[1],e[2]).project(t);return[i.x,i.y]}unprojectFromCanvas(e,t,i,n){const r=this.canvasToViewport(e,t,i);return this.unprojectFromViewport(r[0],r[1],n)}unprojectFromViewport(e,t,i){return new Ki(e,t,1).unproject(i)}viewportToBasic(e,t,i,n){const r=new Ki(e,t,1).unproject(n).toArray();return i.projectBasic(r)}viewportToCanvas(e,t,i){const[n,r]=this.containerToCanvas(i);return[n*(e+1)/2,-r*(t-1)/2]}worldToCamera(e,t){return new Ki(e[0],e[1],e[2]).applyMatrix4(t.matrixWorldInverse).toArray()}}e.ComponentSize=void 0,(ef=e.ComponentSize||(e.ComponentSize={}))[ef.Automatic=0]="Automatic",ef[ef.Large=1]="Large",ef[ef.Small=2]="Small";class cf extends sf{constructor(e,t,i){super(e,t,i),this._spatial=new Du,this._viewportCoords=new hf,this._svgNamespace="http://www.w3.org/2000/svg",this._distinctThreshold=Math.PI/360,this._animationSpeed=.075}_activate(){const t=this._subscriptions,i=this._container.renderService.renderCamera$.pipe(De((e=>{let t=this._spatial.degToRad(e.perspective.fov),i=e.perspective.aspect===Number.POSITIVE_INFINITY?Math.PI:2*Math.atan(e.perspective.aspect*Math.tan(.5*t));return[this._spatial.azimuthalToBearing(e.rotation.phi),i]})),vt(((e,t)=>Math.abs(t[0]-e[0])<this._distinctThreshold&&Math.abs(t[1]-e[1])<this._distinctThreshold))),n=Ve(this._navigator.stateService.currentState$.pipe(vt(void 0,(e=>e.state.currentImage.id))),this._navigator.panService.panImages$).pipe(De((([e,t])=>{const i=e.state.currentImage,n=e.state.currentTransform;if($u(i.cameraType))return[Math.PI,Math.PI];const r=this._computeProjectedPoints(n),s=this._spatial.degToRad(this._computeHorizontalFov(r));let a=s/2,o=s/2;for(const[e,,n]of t){const t=this._spatial.wrap(e.compassAngle-i.compassAngle,-180,180);t<0?a=this._spatial.degToRad(Math.abs(t))+n/2:o=this._spatial.degToRad(Math.abs(t))+n/2}return[a,o]})),vt((([e,t],[i,n])=>Math.abs(i-e)<this._distinctThreshold&&Math.abs(n-t)<this._distinctThreshold))),r=Ve(this._navigator.stateService.currentState$.pipe(vt(void 0,(e=>e.state.currentImage.id))),this._container.renderService.bearing$).pipe(De((([e,t])=>this._spatial.degToRad(e.state.currentImage.compassAngle-t)))),s=new j,a=s.pipe(Lt(((e,t)=>t(e)),{alpha:0,curr:[0,0,0],prev:[0,0,0]}),De((e=>{const t=Oi.smootherstep(e.alpha,0,1),i=e.curr,n=e.prev;return[this._interpolate(n[0],i[0],t),this._interpolate(n[1],i[1],t)]})));t.push(n.pipe(De((e=>t=>{const i=Oi.smootherstep(t.alpha,0,1),n=t.curr,r=t.prev,s=[this._interpolate(r[0],n[0],i),this._interpolate(r[1],n[1],i)];return{alpha:0,curr:e.slice(),prev:s}}))).subscribe(s)),t.push(n.pipe(zt((()=>this._container.renderService.renderCameraFrame$.pipe($t(1),Lt((e=>e+this._animationSpeed),0),Bt((e=>e<=1+this._animationSpeed)),De((e=>Math.min(e,1)))))),De((e=>t=>({alpha:e,curr:t.curr.slice(),prev:t.prev.slice()})))).subscribe(s));const o=Ve(r,a).pipe(De((([e,t])=>[e,t[0],t[1]])));t.push(Ve(i,o,this._configuration$,this._container.renderService.size$).pipe(De((([[t,i],[n,r,s],a,o])=>{const h=this._createBackground(t),c=this._createFovIndicator(r,s,n),l=this._createNorth(t),u=this._createCircleSectorCompass(this._createCircleSector(Math.max(Math.PI/20,i),"#FFF")),d=a.size===e.ComponentSize.Small||a.size===e.ComponentSize.Automatic&&o.width<640?".mapillary-bearing-compact":"";return{name:this._name,vNode:tf.h("div.mapillary-bearing-indicator-container"+d,{oncontextmenu:e=>{e.preventDefault()}},[h,c,l,u])}}))).subscribe(this._container.domRenderer.render$))}_deactivate(){this._subscriptions.unsubscribe()}_getDefaultConfiguration(){return{size:e.ComponentSize.Automatic}}_createFovIndicator(e,t,i){const n=this._createFovArc(e,t),r=tf.h("g",{attributes:{transform:"translate(18,18)"},namespace:this._svgNamespace},[n]);return tf.h("svg",{attributes:{viewBox:"0 0 36 36"},namespace:this._svgNamespace,style:{height:"36px",left:"2px",position:"absolute",top:"2px",transform:`rotateZ(${this._spatial.radToDeg(i)}deg)`,width:"36px"}},[r])}_createFovArc(e,t){const i=16.75,n=e+t;if(n>2*Math.PI-Math.PI/90)return tf.h("circle",{attributes:{cx:"0",cy:"0","fill-opacity":"0",r:"16.75",stroke:"#FFF","stroke-width":"2.5"},namespace:this._svgNamespace},[]);let r=-Math.PI/2-e,s=r+n,a=i*Math.cos(r),o=i*Math.sin(r),h=i*Math.cos(s),c=i*Math.sin(s),l=`M ${a} ${o} A 16.75 16.75 0 ${n>=Math.PI?1:0} 1 ${h} ${c}`;return tf.h("path",{attributes:{d:l,"fill-opacity":"0",stroke:"#FFF","stroke-width":"2.5"},namespace:this._svgNamespace},[])}_createCircleSectorCompass(e){let t=tf.h("g",{attributes:{transform:"translate(1,1)"},namespace:this._svgNamespace},[e]);return tf.h("svg",{attributes:{viewBox:"0 0 2 2"},namespace:this._svgNamespace,style:{height:"26px",left:"7px",position:"absolute",top:"7px",width:"26px"}},[t])}_createCircleSector(e,t){if(e>2*Math.PI-Math.PI/90)return tf.h("circle",{attributes:{cx:"0",cy:"0",fill:t,r:"1"},namespace:this._svgNamespace},[]);let i=-Math.PI/2-e/2,n=i+e,r=Math.cos(i),s=Math.sin(i),a=Math.cos(n),o=Math.sin(n),h=`M 0 0 ${r} ${s} A 1 1 0 ${e>=Math.PI?1:0} 1 ${a} ${o}`;return tf.h("path",{attributes:{d:h,fill:t},namespace:this._svgNamespace},[])}_createNorth(e){const t=tf.h("div.mapillary-bearing-north",[]);return tf.h("div.mapillary-bearing-north-container",{style:{transform:`rotateZ(${this._spatial.radToDeg(-e)}deg)`}},[t])}_createBackground(e){return tf.h("div.mapillary-bearing-indicator-background",{style:{transform:`rotateZ(${this._spatial.radToDeg(-e)}deg)`}},[tf.h("div.mapillary-bearing-indicator-background-circle",[]),tf.h("div.mapillary-bearing-indicator-background-arrow-container",[tf.h("div.mapillary-bearing-indicator-background-arrow",[])])])}_computeProjectedPoints(e){return zu(e,[[1,0]],[[0,.5]],12,this._viewportCoords)}_computeHorizontalFov(e){const t=e.map((e=>this._coordToFov(e[0])));return Math.min(...t)}_coordToFov(e){return this._spatial.radToDeg(2*Math.atan(e))}_interpolate(e,t,i){return(1-i)*e+i*t}}cf.componentName="bearing";class lf extends sf{constructor(e,t,i){super(e,t,i)}_activate(){const t=this._subscriptions;t.push(Ve(this._navigator.stateService.currentImage$.pipe(zt((e=>e.sequenceEdges$)),st((e=>e.cached))),this._configuration$).pipe(zt((t=>{let i=t[0],n=t[1],r=Math.max(0,Math.min(4,n.depth.sequence));return it(this._cache$(i.edges,e.NavigationDirection.Next,r),this._cache$(i.edges,e.NavigationDirection.Prev,r)).pipe(ct((e=>(console.error("Failed to cache sequence edges.",e),ie()))))}))).subscribe((()=>{}))),t.push(Ve(this._navigator.stateService.currentImage$.pipe(zt((e=>Ve(Ce(e),e.spatialEdges$.pipe(st((e=>e.cached))))))),this._configuration$).pipe(zt((([[t,i],n])=>{let r=i.edges,s=n.depth,a=Math.max(0,Math.min(2,s.spherical)),o=$u(t.cameraType)?0:Math.max(0,Math.min(3,s.step)),h=$u(t.cameraType)?0:Math.max(0,Math.min(1,s.turn)),c=this._cache$(r,e.NavigationDirection.Spherical,a);return it(this._cache$(r,e.NavigationDirection.StepForward,o),this._cache$(r,e.NavigationDirection.StepBackward,o),this._cache$(r,e.NavigationDirection.StepLeft,o),this._cache$(r,e.NavigationDirection.StepRight,o),c,this._cache$(r,e.NavigationDirection.TurnLeft,h),this._cache$(r,e.NavigationDirection.TurnRight,h),this._cache$(r,e.NavigationDirection.TurnU,h)).pipe(ct((e=>(console.error("Failed to cache spatial edges.",e),ie()))))}))).subscribe((()=>{})))}_deactivate(){this._subscriptions.unsubscribe()}_getDefaultConfiguration(){return{depth:{spherical:1,sequence:2,step:1,turn:0}}}_cache$(e,t,i){return at(Ce(e),Ce(i)).pipe(wt((e=>{let i=e[0],n=e[1],r=[];if(n>0)for(let e of i)e.data.direction===t&&r.push(at(this._navigator.graphService.cacheImage$(e.target).pipe(We((e=>this._imageToEdges$(e,t)))),Ce(n-1)));return ge(r).pipe(qe())})),$t(1))}_imageToEdges$(t,i){return([e.NavigationDirection.Next,e.NavigationDirection.Prev].indexOf(i)>-1?t.sequenceEdges$:t.spatialEdges$).pipe(St((e=>e.cached)),De((e=>e.edges)))}}lf.componentName="cache";class uf extends Pu{constructor(e){super(null!=e?e:"The request was cancelled."),Object.setPrototypeOf(this,uf.prototype),this.name="CancelMapillaryError"}}class df{constructor(e,t){this._spatial=new Du,this._minThresholdWidth=320,this._maxThresholdWidth=1480,this._minThresholdHeight=240,this._maxThresholdHeight=820,this._configure(e),this._resize(t),this._reset()}get minWidth(){return this._minWidth}get maxWidth(){return this._maxWidth}get containerWidth(){return this._containerWidth}get containerWidthCss(){return this._containerWidthCss}get containerMarginCss(){return this._containerMarginCss}get containerLeftCss(){return this._containerLeftCss}get containerHeight(){return this._containerHeight}get containerHeightCss(){return this._containerHeightCss}get containerBottomCss(){return this._containerBottomCss}get stepCircleSize(){return this._stepCircleSize}get stepCircleSizeCss(){return this._stepCircleSizeCss}get stepCircleMarginCss(){return this._stepCircleMarginCss}get turnCircleSize(){return this._turnCircleSize}get turnCircleSizeCss(){return this._turnCircleSizeCss}get outerRadius(){return this._outerRadius}get innerRadius(){return this._innerRadius}get shadowOffset(){return this._shadowOffset}configure(e){this._configure(e),this._reset()}resize(e){this._resize(e),this._reset()}angleToCoordinates(e){return[Math.cos(e),Math.sin(e)]}relativeAngleToCoordiantes(e,t){let i=this._spatial.wrapAngle(e-t);return this.angleToCoordinates(i)}_configure(e){this._minWidth=e.minWidth,this._maxWidth=this._getMaxWidth(e.minWidth,e.maxWidth)}_resize(e){this._elementWidth=e.width,this._elementHeight=e.height}_reset(){this._containerWidth=this._getContainerWidth(this._elementWidth,this._elementHeight),this._containerHeight=this._getContainerHeight(this.containerWidth),this._stepCircleSize=this._getStepCircleDiameter(this._containerHeight),this._turnCircleSize=this._getTurnCircleDiameter(this.containerHeight),this._outerRadius=this._getOuterRadius(this._containerHeight),this._innerRadius=this._getInnerRadius(this._containerHeight),this._shadowOffset=3,this._containerWidthCss=this._numberToCssPixels(this._containerWidth),this._containerMarginCss=this._numberToCssPixels(-.5*this._containerWidth),this._containerLeftCss=this._numberToCssPixels(Math.floor(.5*this._elementWidth)),this._containerHeightCss=this._numberToCssPixels(this._containerHeight),this._containerBottomCss=this._numberToCssPixels(Math.floor(-.08*this._containerHeight)),this._stepCircleSizeCss=this._numberToCssPixels(this._stepCircleSize),this._stepCircleMarginCss=this._numberToCssPixels(-.5*this._stepCircleSize),this._turnCircleSizeCss=this._numberToCssPixels(this._turnCircleSize)}_getContainerWidth(e,t){let i=(e-this._minThresholdWidth)/(this._maxThresholdWidth-this._minThresholdWidth),n=(t-this._minThresholdHeight)/(this._maxThresholdHeight-this._minThresholdHeight),r=Math.max(0,Math.min(1,Math.min(i,n)));return r=.04*Math.round(25*r),this._minWidth+r*(this._maxWidth-this._minWidth)}_getContainerHeight(e){return.77*e}_getStepCircleDiameter(e){return.34*e}_getTurnCircleDiameter(e){return.3*e}_getOuterRadius(e){return.31*e}_getInnerRadius(e){return.125*e}_numberToCssPixels(e){return e+"px"}_getMaxWidth(e,t){return e>t?e:t}}class pf{constructor(t,i){this._isEdge=!1,this._spatial=new Du,this._calculator=new df(t,i),this._image=null,this._rotation={phi:0,theta:0},this._epsilon=.5*Math.PI/180,this._highlightKey=null,this._distinguishSequence=!1,this._needsRender=!1,this._stepEdges=[],this._turnEdges=[],this._sphericalEdges=[],this._sequenceEdgeKeys=[],this._stepDirections=[e.NavigationDirection.StepForward,e.NavigationDirection.StepBackward,e.NavigationDirection.StepLeft,e.NavigationDirection.StepRight],this._turnDirections=[e.NavigationDirection.TurnLeft,e.NavigationDirection.TurnRight,e.NavigationDirection.TurnU],this._turnNames={},this._turnNames[e.NavigationDirection.TurnLeft]="mapillary-direction-turn-left",this._turnNames[e.NavigationDirection.TurnRight]="mapillary-direction-turn-right",this._turnNames[e.NavigationDirection.TurnU]="mapillary-direction-turn-around";let n=!!document.documentMode;this._isEdge=!n&&!!window.StyleMedia}get needsRender(){return this._needsRender}render(e){this._needsRender=!1;let t=this._rotation,i=[],n=[];return $u(this._image.cameraType)?i=i.concat(this._createSphericalArrows(e,t)):(i=i.concat(this._createPerspectiveToSphericalArrows(e,t)),i=i.concat(this._createStepArrows(e,t)),n=n.concat(this._createTurnArrows(e))),this._getContainer(i,n,t)}setEdges(e,t){this._setEdges(e,t),this._setNeedsRender()}setImage(e){this._image=e,this._clearEdges(),this._setNeedsRender()}setRenderCamera(e){let t=e.rotation;Math.abs(t.phi-this._rotation.phi)<this._epsilon||(this._rotation=t,this._setNeedsRender())}setConfiguration(e){let t=!1;this._highlightKey===e.highlightId&&this._distinguishSequence===e.distinguishSequence||(this._highlightKey=e.highlightId,this._distinguishSequence=e.distinguishSequence,t=!0),this._calculator.minWidth===e.minWidth&&this._calculator.maxWidth===e.maxWidth||(this._calculator.configure(e),t=!0),t&&this._setNeedsRender()}resize(e){this._calculator.resize(e),this._setNeedsRender()}_setNeedsRender(){null!=this._image&&(this._needsRender=!0)}_clearEdges(){this._stepEdges=[],this._turnEdges=[],this._sphericalEdges=[],this._sequenceEdgeKeys=[]}_setEdges(t,i){this._stepEdges=[],this._turnEdges=[],this._sphericalEdges=[],this._sequenceEdgeKeys=[];for(let i of t.edges){let t=i.data.direction;this._stepDirections.indexOf(t)>-1?this._stepEdges.push(i):this._turnDirections.indexOf(t)>-1?this._turnEdges.push(i):i.data.direction===e.NavigationDirection.Spherical&&this._sphericalEdges.push(i)}if(this._distinguishSequence&&null!=i){let e=this._sphericalEdges.concat(this._stepEdges).concat(this._turnEdges);for(let t of e){let e=t.target;for(let t of i.imageIds)if(t===e){this._sequenceEdgeKeys.push(e);break}}}}_createSphericalArrows(e,t){let i=[];for(let n of this._sphericalEdges)i.push(this._createVNodeByKey(e,n.target,n.data.worldMotionAzimuth,t,this._calculator.outerRadius,"mapillary-direction-arrow-spherical"));for(let n of this._stepEdges)i.push(this._createSphericalToPerspectiveArrow(e,n.target,n.data.worldMotionAzimuth,t,n.data.direction));return i}_createSphericalToPerspectiveArrow(t,i,n,r,s){let a=Math.PI/8,o=r.phi;switch(s){case e.NavigationDirection.StepBackward:o=r.phi-Math.PI;break;case e.NavigationDirection.StepLeft:o=r.phi+Math.PI/2;break;case e.NavigationDirection.StepRight:o=r.phi-Math.PI/2}return Math.abs(this._spatial.wrapAngle(n-o))<a?this._createVNodeByKey(t,i,n,r,this._calculator.outerRadius,"mapillary-direction-arrow-step"):this._createVNodeInactive(i,n,r)}_createPerspectiveToSphericalArrows(e,t){let i=[];for(let n of this._sphericalEdges)i.push(this._createVNodeByKey(e,n.target,n.data.worldMotionAzimuth,t,this._calculator.innerRadius,"mapillary-direction-arrow-spherical",!0));return i}_createStepArrows(e,t){let i=[];for(let n of this._stepEdges)i.push(this._createVNodeByDirection(e,n.target,n.data.worldMotionAzimuth,t,n.data.direction));return i}_createTurnArrows(e){let t=[];for(let i of this._turnEdges){let n=i.data.direction,r=this._turnNames[n];t.push(this._createVNodeByTurn(e,i.target,r,n))}return t}_createVNodeByKey(e,t,i,n,r,s,a){return this._createVNode(t,i,n,r,s,"mapillary-direction-circle",(i=>{e.moveTo$(t).subscribe(void 0,(e=>{e instanceof uf||console.error(e)}))}),a)}_createVNodeByDirection(e,t,i,n,r){return this._createVNode(t,i,n,this._calculator.outerRadius,"mapillary-direction-arrow-step","mapillary-direction-circle",(t=>{e.moveDir$(r).subscribe(void 0,(e=>{e instanceof uf||console.error(e)}))}))}_createVNodeByTurn(t,i,n,r){let s={height:this._calculator.turnCircleSizeCss,transform:"rotate(0)",width:this._calculator.turnCircleSizeCss};switch(r){case e.NavigationDirection.TurnLeft:s.left="5px",s.top="5px";break;case e.NavigationDirection.TurnRight:s.right="5px",s.top="5px";break;case e.NavigationDirection.TurnU:s.left="5px",s.bottom="5px"}let a={attributes:{"data-id":i},onclick:e=>{t.moveDir$(r).subscribe(void 0,(e=>{e instanceof uf||console.error(e)}))},style:s},o="mapillary-direction-turn-circle";this._sequenceEdgeKeys.indexOf(i)>-1&&(o+="-sequence"),this._highlightKey===i&&(o+="-highlight");let h=tf.h(`div.${n}`,{},[]);return tf.h("div."+o,a,[h])}_createVNodeInactive(e,t,i){return this._createVNode(e,t,i,this._calculator.outerRadius,"mapillary-direction-arrow-inactive","mapillary-direction-circle-inactive")}_createVNode(e,t,i,n,r,s,a,o){let h=this._calculator.angleToCoordinates(t-i.phi),c=Math.round(-n*h[1]+.5*this._calculator.containerWidth),l=Math.round(-n*h[0]+.5*this._calculator.containerHeight),u=this._calculator.relativeAngleToCoordiantes(t,i.phi),d=this._calculator.shadowOffset,p=`drop-shadow(${-d*u[1]}px ${d*u[0]}px 1px rgba(0,0,0,0.8))`,m={style:{"-webkit-filter":p,filter:p}},f=tf.h("div."+r,m,[]),g=-this._spatial.radToDeg(t-i.phi),_=o?`translate(${c}px, ${l}px) rotate(${g}deg) translateZ(-0.01px)`:`translate(${c}px, ${l}px) rotate(${g}deg)`,v={attributes:{"data-id":e},onclick:a,style:{height:this._calculator.stepCircleSizeCss,marginLeft:this._calculator.stepCircleMarginCss,marginTop:this._calculator.stepCircleMarginCss,transform:_,width:this._calculator.stepCircleSizeCss}};return this._sequenceEdgeKeys.indexOf(e)>-1&&(s+="-sequence"),this._highlightKey===e&&(s+="-highlight"),tf.h("div."+s,v,[f])}_getContainer(e,t,i){let n=this._isEdge?"rotateX(60deg)":`perspective(${this._calculator.containerWidthCss}) rotateX(60deg)`,r={oncontextmenu:e=>{e.preventDefault()},style:{bottom:this._calculator.containerBottomCss,height:this._calculator.containerHeightCss,left:this._calculator.containerLeftCss,marginLeft:this._calculator.containerMarginCss,transform:n,width:this._calculator.containerWidthCss}};return tf.h("div.mapillary-direction-perspective",r,t.concat(e))}}class mf extends sf{constructor(e,t,i,n){super(e,t,i),this._renderer=n||new pf(this.defaultConfiguration,{height:t.container.offsetHeight,width:t.container.offsetWidth}),this._hoveredIdSubject$=new j,this._hoveredId$=this._hoveredIdSubject$.pipe(Dt())}fire(e,t){super.fire(e,t)}off(e,t){super.off(e,t)}on(e,t){super.on(e,t)}_activate(){const e=this._subscriptions;e.push(this._configuration$.subscribe((e=>{this._renderer.setConfiguration(e)}))),e.push(this._container.renderService.size$.subscribe((e=>{this._renderer.resize(e)}))),e.push(this._navigator.stateService.currentImage$.pipe(Ut((e=>{this._container.domRenderer.render$.next({name:this._name,vNode:tf.h("div",{},[])}),this._renderer.setImage(e)})),Vt(this._configuration$),zt((([e,t])=>Ve(e.spatialEdges$,t.distinguishSequence?this._navigator.graphService.cacheSequence$(e.sequenceId).pipe(ct((t=>(console.error(`Failed to cache sequence (${e.sequenceId})`,t),Ce(null))))):Ce(null))))).subscribe((([e,t])=>{this._renderer.setEdges(e,t)}))),e.push(this._container.renderService.renderCameraFrame$.pipe(Ut((e=>{this._renderer.setRenderCamera(e)})),De((()=>this._renderer)),st((e=>e.needsRender)),De((e=>({name:this._name,vNode:e.render(this._navigator)})))).subscribe(this._container.domRenderer.render$)),e.push(Ve(this._container.domRenderer.element$,this._container.renderService.renderCamera$,this._container.mouseService.mouseMove$.pipe(Ot(null)),this._container.mouseService.mouseUp$.pipe(Ot(null))).pipe(De((([e])=>{let t=e.getElementsByClassName("mapillary-direction-perspective");for(let e=0;e<t.length;e++){let i=t.item(e).querySelector(":hover");if(null!=i&&i.hasAttribute("data-id"))return i.getAttribute("data-id")}return null})),vt()).subscribe(this._hoveredIdSubject$)),e.push(this._hoveredId$.subscribe((e=>{const t="hover",i={id:e,target:this,type:t};this.fire(t,i)})))}_deactivate(){this._subscriptions.unsubscribe()}_getDefaultConfiguration(){return{distinguishSequence:!1,maxWidth:460,minWidth:260}}}mf.componentName="direction";class ff{}ff.fisheye={fragment:"\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n\nuniform sampler2D projectorTex;\nuniform float opacity;\nuniform float focal;\nuniform float k1;\nuniform float k2;\nuniform float scale_x;\nuniform float scale_y;\nuniform float radial_peak;\n\nvarying vec4 vRstq;\n\nvoid main()\n{\n float x = vRstq.x;\n float y = vRstq.y;\n float z = vRstq.z;\n\n float r = sqrt(x * x + y * y);\n float theta = atan(r, z);\n\n if (radial_peak > 0. && theta > radial_peak) {\n theta = radial_peak;\n }\n\n float theta2 = theta * theta;\n float theta_d = theta * (1.0 + theta2 * (k1 + theta2 * k2));\n float s = focal * theta_d / r;\n\n float u = scale_x * s * x + 0.5;\n float v = -scale_y * s * y + 0.5;\n\n vec4 baseColor;\n if (u >= 0. && u <= 1. && v >= 0. && v <= 1.) {\n baseColor = texture2D(projectorTex, vec2(u, v));\n baseColor.a = opacity;\n } else {\n baseColor = vec4(0.0, 0.0, 0.0, 0.0);\n }\n\n gl_FragColor = baseColor;\n}\n",vertex:"\n#ifdef GL_ES\nprecision highp float;\n#endif\n\nuniform mat4 projectorMat;\n\nvarying vec4 vRstq;\n\nvoid main()\n{\n vRstq = projectorMat * vec4(position, 1.0);\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n}\n"},ff.fisheyeCurtain={fragment:"\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n\nuniform sampler2D projectorTex;\nuniform float opacity;\nuniform float focal;\nuniform float k1;\nuniform float k2;\nuniform float scale_x;\nuniform float scale_y;\nuniform float radial_peak;\nuniform float curtain;\n\nvarying vec4 vRstq;\n\nvoid main()\n{\n float x = vRstq.x;\n float y = vRstq.y;\n float z = vRstq.z;\n\n float r2 = sqrt(x * x + y * y);\n float theta = atan(r2, z);\n\n if (radial_peak > 0. && theta > radial_peak) {\n theta = radial_peak;\n }\n\n float theta2 = theta * theta;\n float theta_d = theta * (1.0 + theta2 * (k1 + theta2 * k2));\n float s = focal * theta_d / r2;\n\n float u = scale_x * s * x + 0.5;\n float v = -scale_y * s * y + 0.5;\n\n vec4 baseColor;\n if ((u < curtain || curtain >= 1.0) && u >= 0. && u <= 1. && v >= 0. && v <= 1.) {\n baseColor = texture2D(projectorTex, vec2(u, v));\n baseColor.a = opacity;\n } else {\n baseColor = vec4(0.0, 0.0, 0.0, 0.0);\n }\n\n gl_FragColor = baseColor;\n}\n",vertex:"\n#ifdef GL_ES\nprecision highp float;\n#endif\n\nuniform mat4 projectorMat;\n\nvarying vec4 vRstq;\n\nvoid main()\n{\n vRstq = projectorMat * vec4(position, 1.0);\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n}\n"},ff.perspective={fragment:"\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n\nuniform sampler2D projectorTex;\nuniform float opacity;\nuniform float focal;\nuniform float k1;\nuniform float k2;\nuniform float scale_x;\nuniform float scale_y;\nuniform float radial_peak;\n\nvarying vec4 vRstq;\n\nvoid main()\n{\n float x = vRstq.x / vRstq.z;\n float y = vRstq.y / vRstq.z;\n float r2 = x * x + y * y;\n\n if (radial_peak > 0. && r2 > radial_peak * sqrt(r2)) {\n r2 = radial_peak * radial_peak;\n }\n\n float d = 1.0 + k1 * r2 + k2 * r2 * r2;\n float u = scale_x * focal * d * x + 0.5;\n float v = - scale_y * focal * d * y + 0.5;\n\n vec4 baseColor;\n if (u >= 0. && u <= 1. && v >= 0. && v <= 1.) {\n baseColor = texture2D(projectorTex, vec2(u, v));\n baseColor.a = opacity;\n } else {\n baseColor = vec4(0.0, 0.0, 0.0, 0.0);\n }\n\n gl_FragColor = baseColor;\n}\n",vertex:"\n#ifdef GL_ES\nprecision highp float;\n#endif\n\nuniform mat4 projectorMat;\n\nvarying vec4 vRstq;\n\nvoid main()\n{\n vRstq = projectorMat * vec4(position, 1.0);\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n}\n"},ff.perspectiveCurtain={fragment:"\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n\nuniform sampler2D projectorTex;\nuniform float opacity;\nuniform float focal;\nuniform float k1;\nuniform float k2;\nuniform float scale_x;\nuniform float scale_y;\nuniform float radial_peak;\nuniform float curtain;\n\nvarying vec4 vRstq;\n\nvoid main()\n{\n float x = vRstq.x / vRstq.z;\n float y = vRstq.y / vRstq.z;\n float r2 = x * x + y * y;\n\n if (radial_peak > 0. && r2 > radial_peak * sqrt(r2)) {\n r2 = radial_peak * radial_peak;\n }\n\n float d = 1.0 + k1 * r2 + k2 * r2 * r2;\n float u = scale_x * focal * d * x + 0.5;\n float v = - scale_y * focal * d * y + 0.5;\n\n vec4 baseColor;\n if ((u < curtain || curtain >= 1.0) && u >= 0. && u <= 1. && v >= 0. && v <= 1.) {\n baseColor = texture2D(projectorTex, vec2(u, v));\n baseColor.a = opacity;\n } else {\n baseColor = vec4(0.0, 0.0, 0.0, 0.0);\n }\n\n gl_FragColor = baseColor;\n}\n",vertex:"\n#ifdef GL_ES\nprecision highp float;\n#endif\n\nuniform mat4 projectorMat;\n\nvarying vec4 vRstq;\n\nvoid main()\n{\n vRstq = projectorMat * vec4(position, 1.0);\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n}\n"},ff.perspectiveDistorted={fragment:"\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n\nuniform sampler2D projectorTex;\nuniform float opacity;\n\nvarying vec4 vRstq;\n\nvoid main()\n{\n float u = vRstq.x / vRstq.w;\n float v = vRstq.y / vRstq.w;\n\n vec4 baseColor;\n if (u >= 0. && u <= 1. && v >= 0. && v <= 1.) {\n baseColor = texture2D(projectorTex, vec2(u, v));\n baseColor.a = opacity;\n } else {\n baseColor = vec4(0.0, 0.0, 0.0, 0.0);\n }\n\n gl_FragColor = baseColor;\n}\n",vertex:"\n#ifdef GL_ES\nprecision highp float;\n#endif\n\nuniform mat4 projectorMat;\n\nvarying vec4 vRstq;\n\nvoid main()\n{\n vRstq = projectorMat * vec4(position, 1.0);\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n}\n"},ff.perspectiveDistortedCurtain={fragment:"\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n\nuniform sampler2D projectorTex;\nuniform float opacity;\nuniform float curtain;\n\nvarying vec4 vRstq;\n\nvoid main()\n{\n float u = vRstq.x / vRstq.w;\n float v = vRstq.y / vRstq.w;\n\n vec4 baseColor;\n if ((u < curtain || curtain >= 1.0) && u >= 0. && u <= 1. && v >= 0. && v <= 1.) {\n baseColor = texture2D(projectorTex, vec2(u, v));\n baseColor.a = opacity;\n } else {\n baseColor = vec4(0.0, 0.0, 0.0, 0.0);\n }\n\n gl_FragColor = baseColor;\n}\n",vertex:"\n#ifdef GL_ES\nprecision highp float;\n#endif\n\nuniform mat4 projectorMat;\n\nvarying vec4 vRstq;\n\nvoid main()\n{\n vRstq = projectorMat * vec4(position, 1.0);\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n}\n"},ff.spherical={fragment:"\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n\n#define tau 6.28318530718\n\nuniform sampler2D projectorTex;\nuniform float opacity;\n\nvarying vec4 vRstq;\n\nvoid main()\n{\n vec3 b = normalize(vRstq.xyz);\n float lat = -asin(b.y);\n float lng = atan(b.x, b.z);\n float x = lng / tau + 0.5;\n float y = lat / tau * 2.0 + 0.5;\n vec4 baseColor = texture2D(projectorTex, vec2(x, y));\n baseColor.a = opacity;\n gl_FragColor = baseColor;\n}\n",vertex:"\n#ifdef GL_ES\nprecision highp float;\n#endif\n\nuniform mat4 projectorMat;\n\nvarying vec4 vRstq;\n\nvoid main()\n{\n vRstq = projectorMat * vec4(position, 1.0);\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n}\n"},ff.sphericalCurtain={fragment:"\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n\n#define tau 6.28318530718\n\nuniform sampler2D projectorTex;\nuniform float curtain;\nuniform float opacity;\n\nvarying vec4 vRstq;\n\nvoid main()\n{\n vec3 b = normalize(vRstq.xyz);\n float lat = -asin(b.y);\n float lng = atan(b.x, b.z);\n float x = lng / tau + 0.5;\n float y = lat / tau * 2.0 + 0.5;\n\n bool inverted = curtain < 0.5;\n\n float curtainMin = inverted ? curtain + 0.5 : curtain - 0.5;\n float curtainMax = curtain;\n\n bool insideCurtain = inverted ?\n x > curtainMin || x < curtainMax :\n x > curtainMin && x < curtainMax;\n\n vec4 baseColor;\n if (insideCurtain) {\n baseColor = texture2D(projectorTex, vec2(x, y));\n baseColor.a = opacity;\n } else {\n baseColor = vec4(0.0, 0.0, 0.0, 0.0);\n }\n\n gl_FragColor = baseColor;\n}\n",vertex:"\n#ifdef GL_ES\nprecision highp float;\n#endif\n\nuniform mat4 projectorMat;\n\nvarying vec4 vRstq;\n\nvoid main()\n{\n vRstq = projectorMat * vec4(position, 1.0);\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n}\n"};class gf{constructor(e,t){this._imagePlaneDepth=null!=e?e:200,this._imageSphereRadius=null!=t?t:200}createMesh(e,t){return $u(t.cameraType)?this._createImageSphere(e,t):ku(t.cameraType)?this._createImagePlaneFisheye(e,t):this._createImagePlane(e,t)}createFlatMesh(e,t,i,n,r,s){let a=this._createTexture(e.image),o=this._createDistortedPlaneMaterialParameters(t,a),h=new as(o),c=this._getFlatImagePlaneGeoFromBasic(t,i,n,r,s);return new es(c,h)}createCurtainMesh(e,t){return $u(t.cameraType)?this._createSphereCurtainMesh(e,t):ku(t.cameraType)?this._createCurtainMeshFisheye(e,t):this._createCurtainMesh(e,t)}createDistortedCurtainMesh(e,t){return this._createDistortedCurtainMesh(e,t)}_createCurtainMesh(e,t){let i=this._createTexture(e.image),n=this._createCurtainPlaneMaterialParameters(t,i),r=new as(n),s=this._useMesh(t,e)?this._getImagePlaneGeo(t,e):this._getRegularFlatImagePlaneGeo(t);return new es(s,r)}_createCurtainMeshFisheye(e,t){let i=this._createTexture(e.image),n=this._createCurtainPlaneMaterialParametersFisheye(t,i),r=new as(n),s=this._useMesh(t,e)?this._getImagePlaneGeoFisheye(t,e):this._getRegularFlatImagePlaneGeo(t);return new es(s,r)}_createDistortedCurtainMesh(e,t){let i=this._createTexture(e.image),n=this._createDistortedCurtainPlaneMaterialParameters(t,i),r=new as(n),s=this._getRegularFlatImagePlaneGeo(t);return new es(s,r)}_createSphereCurtainMesh(e,t){let i=this._createTexture(e.image),n=this._createCurtainSphereMaterialParameters(t,i),r=new as(n);return this._useMesh(t,e)?new es(this._getImageSphereGeo(t,e),r):new es(this._getFlatImageSphereGeo(t),r)}_createImageSphere(e,t){let i=this._createTexture(e.image),n=this._createSphereMaterialParameters(t,i),r=new as(n);return this._useMesh(t,e)?new es(this._getImageSphereGeo(t,e),r):new es(this._getFlatImageSphereGeo(t),r)}_createImagePlane(e,t){let i=this._createTexture(e.image),n=this._createPlaneMaterialParameters(t,i),r=new as(n),s=this._useMesh(t,e)?this._getImagePlaneGeo(t,e):this._getRegularFlatImagePlaneGeo(t);return new es(s,r)}_createImagePlaneFisheye(e,t){let i=this._createTexture(e.image),n=this._createPlaneMaterialParametersFisheye(t,i),r=new as(n),s=this._useMesh(t,e)?this._getImagePlaneGeoFisheye(t,e):this._getRegularFlatImagePlaneGeoFisheye(t);return new es(s,r)}_createSphereMaterialParameters(e,t){return{depthWrite:!1,fragmentShader:ff.spherical.fragment,side:2,transparent:!0,uniforms:{opacity:{value:1},projectorMat:{value:e.rt},projectorTex:{value:t}},vertexShader:ff.spherical.vertex}}_createCurtainSphereMaterialParameters(e,t){return{depthWrite:!1,fragmentShader:ff.sphericalCurtain.fragment,side:2,transparent:!0,uniforms:{curtain:{value:1},opacity:{value:1},projectorMat:{value:e.rt},projectorTex:{value:t}},vertexShader:ff.sphericalCurtain.vertex}}_createPlaneMaterialParameters(e,t){return{depthWrite:!1,fragmentShader:ff.perspective.fragment,side:2,transparent:!0,uniforms:{focal:{value:e.focal},k1:{value:e.ck1},k2:{value:e.ck2},opacity:{value:1},projectorMat:{value:e.basicRt},projectorTex:{value:t},radial_peak:{value:e.radialPeak?e.radialPeak:0},scale_x:{value:Math.max(e.basicHeight,e.basicWidth)/e.basicWidth},scale_y:{value:Math.max(e.basicWidth,e.basicHeight)/e.basicHeight}},vertexShader:ff.perspective.vertex}}_createPlaneMaterialParametersFisheye(e,t){return{depthWrite:!1,fragmentShader:ff.fisheye.fragment,side:2,transparent:!0,uniforms:{focal:{value:e.focal},k1:{value:e.ck1},k2:{value:e.ck2},opacity:{value:1},projectorMat:{value:e.basicRt},projectorTex:{value:t},radial_peak:{value:e.radialPeak?e.radialPeak:0},scale_x:{value:Math.max(e.basicHeight,e.basicWidth)/e.basicWidth},scale_y:{value:Math.max(e.basicWidth,e.basicHeight)/e.basicHeight}},vertexShader:ff.fisheye.vertex}}_createCurtainPlaneMaterialParametersFisheye(e,t){return{depthWrite:!1,fragmentShader:ff.fisheyeCurtain.fragment,side:2,transparent:!0,uniforms:{curtain:{value:1},focal:{value:e.focal},k1:{value:e.ck1},k2:{value:e.ck2},opacity:{value:1},projectorMat:{value:e.basicRt},projectorTex:{value:t},radial_peak:{value:e.radialPeak?e.radialPeak:0},scale_x:{value:Math.max(e.basicHeight,e.basicWidth)/e.basicWidth},scale_y:{value:Math.max(e.basicWidth,e.basicHeight)/e.basicHeight}},vertexShader:ff.fisheyeCurtain.vertex}}_createCurtainPlaneMaterialParameters(e,t){return{depthWrite:!1,fragmentShader:ff.perspectiveCurtain.fragment,side:2,transparent:!0,uniforms:{curtain:{value:1},focal:{value:e.focal},k1:{value:e.ck1},k2:{value:e.ck2},opacity:{value:1},projectorMat:{value:e.basicRt},projectorTex:{value:t},radial_peak:{value:e.radialPeak?e.radialPeak:0},scale_x:{value:Math.max(e.basicHeight,e.basicWidth)/e.basicWidth},scale_y:{value:Math.max(e.basicWidth,e.basicHeight)/e.basicHeight}},vertexShader:ff.perspectiveCurtain.vertex}}_createDistortedCurtainPlaneMaterialParameters(e,t){return{depthWrite:!1,fragmentShader:ff.perspectiveDistortedCurtain.fragment,side:2,transparent:!0,uniforms:{curtain:{value:1},opacity:{value:1},projectorMat:{value:e.projectorMatrix()},projectorTex:{value:t}},vertexShader:ff.perspectiveDistortedCurtain.vertex}}_createDistortedPlaneMaterialParameters(e,t){return{depthWrite:!1,fragmentShader:ff.perspectiveDistorted.fragment,side:2,transparent:!0,uniforms:{opacity:{value:1},projectorMat:{value:e.projectorMatrix()},projectorTex:{value:t}},vertexShader:ff.perspectiveDistorted.vertex}}_createTexture(e){let t=new Wi(e);return t.minFilter=Kt,t.needsUpdate=!0,t}_useMesh(e,t){return t.mesh.vertices.length&&e.hasValidScale}_getImageSphereGeo(e,t){const i=e.srtInverse;let n=5*e.scale,r=this._imageSphereRadius*e.scale,s=t.mesh.vertices,a=s.length/3,o=new Float32Array(s.length);for(let e=0;e<a;++e){let t=3*e,a=s[t+0],h=s[t+1],c=s[t+2],l=Math.sqrt(a*a+h*h+c*c),u=Math.max(n,Math.min(l,r))/l,d=new Ki(a*u,h*u,c*u);d.applyMatrix4(i),o[t+0]=d.x,o[t+1]=d.y,o[t+2]=d.z}let h=t.mesh.faces,c=new Uint16Array(h.length);for(let e=0;e<h.length;++e)c[e]=h[e];let l=new kr;return l.setAttribute("position",new Tr(o,3)),l.setIndex(new Tr(c,1)),l}_getImagePlaneGeo(e,t){const i=e.srtInverse;let n=5*e.scale,r=this._imagePlaneDepth*e.scale,s=t.mesh.vertices,a=s.length/3,o=new Float32Array(s.length);for(let e=0;e<a;++e){let t=3*e,a=s[t+0],h=s[t+1],c=s[t+2];e<4&&(a*=3,h*=3);let l=Math.max(n,Math.min(c,r)),u=l/c,d=new Ki(a*u,h*u,l);d.applyMatrix4(i),o[t+0]=d.x,o[t+1]=d.y,o[t+2]=d.z}let h=t.mesh.faces,c=new Uint16Array(h.length);for(let e=0;e<h.length;++e)c[e]=h[e];let l=new kr;return l.setAttribute("position",new Tr(o,3)),l.setIndex(new Tr(c,1)),l}_getImagePlaneGeoFisheye(e,t){const i=e.srtInverse;let n=5*e.scale,r=this._imagePlaneDepth*e.scale,s=t.mesh.vertices,a=s.length/3,o=new Float32Array(s.length);for(let e=0;e<a;++e){let t=3*e,a=s[t+0],h=s[t+1],c=s[t+2],l=Math.sqrt(a*a+h*h+c*c),u=Math.max(n,Math.min(l,r))/l,d=new Ki(a*u,h*u,c*u);d.applyMatrix4(i),o[t+0]=d.x,o[t+1]=d.y,o[t+2]=d.z}let h=t.mesh.faces,c=new Uint16Array(h.length);for(let e=0;e<h.length;++e)c[e]=h[e];let l=new kr;return l.setAttribute("position",new Tr(o,3)),l.setIndex(new Tr(c,1)),l}_getFlatImageSphereGeo(e){const t=new nl(this._imageSphereRadius,20,40),i=e.rt.clone().invert();return t.applyMatrix4(i),t}_getRegularFlatImagePlaneGeo(e){let t=e.width,i=e.height,n=Math.max(t,i),r=t/2/n,s=i/2/n;return this._getFlatImagePlaneGeo(e,r,s)}_getFlatImagePlaneGeo(e,t,i){let n=[];return n.push(e.unprojectSfM([-t,-i],this._imagePlaneDepth)),n.push(e.unprojectSfM([t,-i],this._imagePlaneDepth)),n.push(e.unprojectSfM([t,i],this._imagePlaneDepth)),n.push(e.unprojectSfM([-t,i],this._imagePlaneDepth)),this._createFlatGeometry(n)}_getRegularFlatImagePlaneGeoFisheye(e){let t=e.width,i=e.height,n=Math.max(t,i),r=t/2/n,s=i/2/n;return this._getFlatImagePlaneGeoFisheye(e,r,s)}_getFlatImagePlaneGeoFisheye(e,t,i){let n=[];return n.push(e.unprojectSfM([-t,-i],this._imagePlaneDepth)),n.push(e.unprojectSfM([t,-i],this._imagePlaneDepth)),n.push(e.unprojectSfM([t,i],this._imagePlaneDepth)),n.push(e.unprojectSfM([-t,i],this._imagePlaneDepth)),this._createFlatGeometry(n)}_getFlatImagePlaneGeoFromBasic(e,t,i,n,r){let s=[];return s.push(e.unprojectBasic([t,n],this._imagePlaneDepth)),s.push(e.unprojectBasic([i,n],this._imagePlaneDepth)),s.push(e.unprojectBasic([i,r],this._imagePlaneDepth)),s.push(e.unprojectBasic([t,r],this._imagePlaneDepth)),this._createFlatGeometry(s)}_createFlatGeometry(e){let t=new Float32Array(12);for(let i=0;i<e.length;i++){let n=3*i;t[n+0]=e[i][0],t[n+1]=e[i][1],t[n+2]=e[i][2]}let i=new Uint16Array(6);i[0]=0,i[1]=1,i[2]=3,i[3]=1,i[4]=2,i[5]=3;let n=new kr;return n.setAttribute("position",new Tr(t,3)),n.setIndex(new Tr(i,1)),n}}class _f{constructor(){this._planes={},this._planesOld={},this._planesPeriphery={},this._scene=new ch,this._sceneOld=new ch,this._scenePeriphery=new ch}get planes(){return this._planes}get planesOld(){return this._planesOld}get planesPeriphery(){return this._planesPeriphery}get scene(){return this._scene}get sceneOld(){return this._sceneOld}get scenePeriphery(){return this._scenePeriphery}updateImagePlanes(e){this._dispose(this._planesOld,this.sceneOld);for(const e in this._planes){if(!this._planes.hasOwnProperty(e))continue;const t=this._planes[e];this._scene.remove(t),this._sceneOld.add(t)}for(const t in e)e.hasOwnProperty(t)&&this._scene.add(e[t]);this._planesOld=this._planes,this._planes=e}addImagePlanes(e){for(const t in e){if(!e.hasOwnProperty(t))continue;const i=e[t];this._scene.add(i),this._planes[t]=i}}addImagePlanesOld(e){for(const t in e){if(!e.hasOwnProperty(t))continue;const i=e[t];this._sceneOld.add(i),this._planesOld[t]=i}}setImagePlanes(e){this._clear(),this.addImagePlanes(e)}addPeripheryPlanes(e){for(const t in e){if(!e.hasOwnProperty(t))continue;const i=e[t];this._scenePeriphery.add(i),this._planesPeriphery[t]=i}}setPeripheryPlanes(e){this._clearPeriphery(),this.addPeripheryPlanes(e)}setImagePlanesOld(e){this._clearOld(),this.addImagePlanesOld(e)}clear(){this._clear(),this._clearOld()}_clear(){this._dispose(this._planes,this._scene),this._planes={}}_clearOld(){this._dispose(this._planesOld,this._sceneOld),this._planesOld={}}_clearPeriphery(){this._dispose(this._planesPeriphery,this._scenePeriphery),this._planesPeriphery={}}_dispose(e,t){for(const i in e){if(!e.hasOwnProperty(i))continue;const n=e[i];t.remove(n),n.geometry.dispose(),n.material.dispose();let r=n.material.uniforms.projectorTex.value;null!=r&&r.dispose()}}}class vf{constructor(){this._factory=new gf,this._scene=new _f,this._alpha=0,this._alphaOld=0,this._fadeOutSpeed=.05,this._currentKey=null,this._previousKey=null,this._providerDisposers={},this._frameId=0,this._needsRender=!1}get frameId(){return this._frameId}get needsRender(){return this._needsRender}indicateNeedsRender(){this._needsRender=!0}addPeripheryPlane(e,t){const i=this._factory.createMesh(e,t),n={};n[e.id]=i,this._scene.addPeripheryPlanes(n),this._needsRender=!0}clearPeripheryPlanes(){this._scene.setPeripheryPlanes({}),this._needsRender=!0}updateFrame(e){this._updateFrameId(e.id),this._needsRender=this._updateAlpha(e.state.alpha)||this._needsRender,this._needsRender=this._updateAlphaOld(e.state.alpha)||this._needsRender,this._needsRender=this._updateImagePlanes(e.state)||this._needsRender}setTextureProvider(e,t){if(e!==this._currentKey)return;let i=t.textureCreated$.subscribe((e=>{this._updateTexture(e)})),n=t.textureUpdated$.subscribe((e=>{this._needsRender=!0}));if(e in this._providerDisposers){(0,this._providerDisposers[e])(),delete this._providerDisposers[e]}this._providerDisposers[e]=()=>{i.unsubscribe(),n.unsubscribe(),t.dispose()}}updateTextureImage(e,t){this._needsRender=!0;const i=this._extend({},this._scene.planes,this._scene.planesOld,this._scene.planesPeriphery);for(const n in i){if(!i.hasOwnProperty(n))continue;if(n!==t.id)continue;let r=i[n].material.uniforms.projectorTex.value;r.image=e,r.needsUpdate=!0}}render(e,t){const i=this._scene.planes,n=this._scene.planesOld,r=this._scene.planesPeriphery,s=Object.keys(n).length?1:this._alpha,a=Object.keys(n).length?1:Math.floor(this._alpha);for(const e in i){if(!i.hasOwnProperty(e))continue;i[e].material.uniforms.opacity.value=s}for(const e in n){if(!n.hasOwnProperty(e))continue;n[e].material.uniforms.opacity.value=this._alphaOld}for(const e in r){if(!r.hasOwnProperty(e))continue;r[e].material.uniforms.opacity.value=a}t.render(this._scene.scenePeriphery,e),t.render(this._scene.scene,e),t.render(this._scene.sceneOld,e);for(const e in i){if(!i.hasOwnProperty(e))continue;i[e].material.uniforms.opacity.value=this._alpha}t.render(this._scene.scene,e)}clearNeedsRender(){this._needsRender=!1}dispose(){this._scene.clear()}_updateFrameId(e){this._frameId=e}_updateAlpha(e){return e!==this._alpha&&(this._alpha=e,!0)}_updateAlphaOld(e){return!(e<1||0===this._alphaOld)&&(this._alphaOld=Math.max(0,this._alphaOld-this._fadeOutSpeed),!0)}_updateImagePlanes(e){if(null==e.currentImage||e.currentImage.id===this._currentKey)return!1;let t=null!=e.previousImage?e.previousImage.id:null,i=e.currentImage.id;if(this._previousKey!==t&&this._previousKey!==i&&this._previousKey in this._providerDisposers){(0,this._providerDisposers[this._previousKey])(),delete this._providerDisposers[this._previousKey]}if(null!=t){if(t!==this._currentKey&&t!==this._previousKey){let i=this._factory.createMesh(e.previousImage,e.previousTransform);const n={};n[t]=i,this._scene.updateImagePlanes(n)}this._previousKey=t}this._currentKey=i;let n=this._factory.createMesh(e.currentImage,e.currentTransform);const r={};return r[i]=n,this._scene.updateImagePlanes(r),this._alphaOld=1,!0}_updateTexture(e){this._needsRender=!0;const t=this._scene.planes;for(const i in t){if(!t.hasOwnProperty(i))continue;let n=t[i].material,r=n.uniforms.projectorTex.value;n.uniforms.projectorTex.value=null,r.dispose(),n.uniforms.projectorTex.value=e}}_extend(e,...t){for(const i of t)for(const t in i)i.hasOwnProperty(t)&&(e[t]=i[t]);return e}}var yf;!function(e){e[e.Background=0]="Background",e[e.Opaque=1]="Opaque"}(yf||(yf={}));class bf{constructor(e){this._api=e,this._urls$=new Map}getImage$(e){let t;const i=new Promise(((e,i)=>{t=i}));return[k.create((n=>{this._api.data.getImageBuffer(e,i).then((e=>{t=null;const i=new Image;i.crossOrigin="Anonymous",i.onload=()=>{window.URL.revokeObjectURL(i.src),n.next(i),n.complete()},i.onerror=()=>{t=null,window.URL.revokeObjectURL(i.src),n.error(new Error("Failed to load image tile"))};const r=new Blob([e]);i.src=window.URL.createObjectURL(r)}),(e=>{t=null,n.error(e)}))})),()=>{t&&t()}]}getURLs$(e,t){const i=this._inventId(e,t);if(this._urls$.has(i))return this._urls$.get(i);const n={imageId:e,z:t},r=this._api.getImageTiles$(n).pipe(De((e=>e.node)),Mt((()=>{this._urls$.delete(i)})),It(),U());return this._urls$.set(i,r),r}_inventId(e,t){return`${e}-${t}`}}class xf{constructor(){this._tiles=new Map,this._urlLevels=new Set,this._urls=new Map}add(e,t){if(this._tiles.has(e))throw new Error(`Image tile already stored (${e})`);this._tiles.set(e,t)}addURLs(e,t){const i=this._urls;for(const e of t){const t=this.inventId(e);if(this._urls.has(t))throw new Error(`URL already stored (${t})`);i.set(t,e.url)}this._urlLevels.add(e)}dispose(){this._tiles.forEach((e=>window.URL.revokeObjectURL(e.src))),this._tiles.clear(),this._urls.clear(),this._urlLevels.clear()}get(e){return this._tiles.get(e)}getURL(e){return this._urls.get(e)}has(e){return this._tiles.has(e)}hasURL(e){return this._urls.has(e)}hasURLLevel(e){return this._urlLevels.has(e)}inventId(e){return`${e.z}-${e.x}-${e.y}`}}class wf{constructor(){this._viewportCoords=new hf}computeRegionOfInterest(e,t,i){const n=this._viewportBoundaryPoints(4),r=this._viewportPointsBoundingBox(n,e,i);this._clipBoundingBox(r);const s=2/t.width,a=2/t.height,o=[[-.5*s,.5*a],[.5*s,.5*a],[.5*s,-.5*a],[-.5*s,-.5*a]],h=this._viewportPointsBoundingBox(o,e,i),c=h.minX<h.maxX;return{bbox:r,pixelHeight:h.maxY-h.minY,pixelWidth:h.maxX-h.minX+(c?0:1)}}_viewportBoundaryPoints(e){const t=[],i=[[-1,1],[1,1],[1,-1],[-1,-1]],n=[[2,0],[0,-2],[-2,0],[0,2]];for(let r=0;r<4;++r){const s=i[r],a=n[r];for(let i=0;i<e;++i)t.push([s[0]+a[0]*i/e,s[1]+a[1]*i/e])}return t}_viewportPointsBoundingBox(e,t,i){const n=e.map((e=>this._viewportCoords.viewportToBasic(e[0],e[1],i,t.perspective)));return $u(i.cameraType)?this._boundingBoxSpherical(n):this._boundingBox(n)}_boundingBox(e){const t={maxX:Number.NEGATIVE_INFINITY,maxY:Number.NEGATIVE_INFINITY,minX:Number.POSITIVE_INFINITY,minY:Number.POSITIVE_INFINITY};for(let i=0;i<e.length;++i)t.minX=Math.min(t.minX,e[i][0]),t.maxX=Math.max(t.maxX,e[i][0]),t.minY=Math.min(t.minY,e[i][1]),t.maxY=Math.max(t.maxY,e[i][1]);return t}_boundingBoxSpherical(e){const t=[],i=[];for(let n=0;n<e.length;++n)t.push(e[n][0]),i.push(e[n][1]);t.sort(((e,t)=>this._sign(e-t))),i.sort(((e,t)=>this._sign(e-t)));const n=this._intervalSpherical(t);return{maxX:n[1],maxY:i[i.length-1],minX:n[0],minY:i[0]}}_intervalSpherical(e){let t=0,i=-1;for(let n=0;n<e.length-1;++n){const r=e[n+1]-e[n];r>t&&(t=r,i=n)}return e[0]+1-e[e.length-1]>t?[e[0],e[e.length-1]]:[e[i+1],e[i]]}_clipBoundingBox(e){e.minX=Math.max(0,Math.min(1,e.minX)),e.maxX=Math.max(0,Math.min(1,e.maxX)),e.minY=Math.max(0,Math.min(1,e.minY)),e.maxY=Math.max(0,Math.min(1,e.maxY))}_sign(e){return e>0?1:e<0?-1:0}}function Mf(e,t,i){return Math.max(t,Math.min(i,e))}function Sf(e){return 1024/Tf(e)}function Tf(e){return Math.pow(2,e.z-e.max)}function Cf(e){return Math.ceil(function(e){const t=Math.max(e.w,e.h);return Math.log(t)/Math.log(2)}(e))}function Ef(e,t,i){const n=Sf(i),r=t.w,s=t.h,a=Math.ceil(r/n)-1,o=Math.ceil(s/n)-1;return{x:Mf(Math.floor(r*e[0]/n),0,a),y:Mf(Math.floor(s*e[1]/n),0,o)}}function Af(e,t,i){const n=1024*(1/Tf(i)),r=n*e.x,s=n*e.y,a=Math.min(n,t.w-r);return{h:Math.min(n,t.h-s),x:r,y:s,w:a}}function If(e,t,i){return i*e<=t&&t<i*(e+1)}function Rf(e,t){if(e.z===t.z)return e.x===t.x&&e.y===t.y;const i=e.z<t.z?e:t,n=e.z<t.z?t:e,r=1/Tf({max:n.z,z:i.z}),s=If(i.x,n.x,r),a=If(i.y,n.y,r);return s&&a}function Pf(e){return e.w>0&&e.h>0}class Lf{constructor(e,t,i,n,r,s,a){const o={h:i,w:t};Pf(o)||console.warn(`Original image size (${t}, ${i}) is invalid (${e}). Tiles will not be loaded.`),this._imageId=e,this._size=o,this._level={max:Cf(this._size),z:-1},this._holder=new rf,this._updated$=new j,this._createdSubject$=new j,this._created$=this._createdSubject$.pipe(Rt(1),U()),this._holder.push(this._created$.subscribe((()=>{}))),this._hasSubject$=new j,this._has$=this._hasSubject$.pipe(Ot(!1),Rt(1),U()),this._holder.push(this._has$.subscribe((()=>{}))),this._renderedLevel=new Set,this._rendered=new Map,this._subscriptions=new Map,this._urlSubscriptions=new Map,this._loader=r,this._store=s,this._background=n,this._renderer=a,this._aborts=[],this._render=null,this._disposed=!1}get disposed(){return this._disposed}get hasTexture$(){return this._has$}get id(){return this._imageId}get textureUpdated$(){return this._updated$}get textureCreated$(){return this._created$}abort(){this._subscriptions.forEach((e=>e.unsubscribe())),this._subscriptions.clear();for(const e of this._aborts)e();this._aborts=[]}dispose(){this._disposed?console.warn(`Texture already disposed (${this._imageId})`):(this._urlSubscriptions.forEach((e=>e.unsubscribe())),this._urlSubscriptions.clear(),this.abort(),null!=this._render&&(this._render.target.dispose(),this._render.target=null,this._render.camera=null,this._render=null),this._store.dispose(),this._holder.unsubscribe(),this._renderedLevel.clear(),this._background=null,this._renderer=null,this._disposed=!0)}setRegionOfInterest(e){if(!Pf(this._size))return;const t=1/e.pixelWidth,i=function(e,t,i){return Math.max(t,Math.min(i,Cf(e)))}({h:1/e.pixelHeight,w:t},11,this._level.max);i!==this._level.z&&(this.abort(),this._level.z=i,this._renderedLevel.clear(),this._rendered.forEach(((e,t)=>{e.z===i&&this._renderedLevel.add(t)}))),null==this._render&&this._initRender();const n=function(e,t,i,n){const r=[];if(e.x>t.x){const s=Sf(n),a=Math.ceil(i.w/s)-1;for(let t=e.x;t<=a;t++)r.push(t);for(let e=0;e<=t.x;e++)r.push(e)}else for(let i=e.x;i<=t.x;i++)r.push(i);const s=[];for(const i of r)for(let n=e.y;n<=t.y;n++)s.push({x:i,y:n});return s}(Ef([e.bbox.minX,e.bbox.minY],this._size,this._level),Ef([e.bbox.maxX,e.bbox.maxY],this._size,this._level),this._size,this._level);this._fetchTiles(i,n)}_fetchTile(e){const t=this._loader.getImage$(e.url),i=t[0],n=t[1];this._aborts.push(n);const r=this._store.inventId(e),s=i.subscribe((t=>{const i=Af(e,this._size,this._level);this._renderToTarget(i,t),this._subscriptions.delete(r),this._removeFromArray(n,this._aborts),this._markRendered(e),this._store.add(r,t),this._updated$.next(!0)}),(e=>{this._subscriptions.delete(r),this._removeFromArray(n,this._aborts),console.error(e)}));s.closed||this._subscriptions.set(r,s)}_fetchTiles(e,t){const i=(this._store.hasURLLevel(e)?Ce(void 0):this._loader.getURLs$(this._imageId,e).pipe(Ut((t=>{this._store.hasURLLevel(e)||this._store.addURLs(e,t)})))).subscribe((()=>{if(e===this._level.z){for(const i of t){const t={x:i.x,y:i.y,z:e,url:null},n=this._store.inventId(t);if(!this._renderedLevel.has(n)&&!this._subscriptions.has(n))if(this._store.has(n)){const e=Af(i,this._size,this._level);this._renderToTarget(e,this._store.get(n)),this._markRendered(t),this._updated$.next(!0)}else t.url=this._store.getURL(n),this._fetchTile(t)}this._urlSubscriptions.delete(e)}}),(t=>{this._urlSubscriptions.delete(e),console.error(t)}));i.closed||this._urlSubscriptions.set(e,i)}_initRender(){const e=this._size.w/2,t=this._size.h/2,i=new Ls(-e,e,t,-t,-1,1);i.position.z=1;const n=this._renderer.getContext(),r=n.getParameter(n.MAX_TEXTURE_SIZE),s=Math.max(this._size.w,this._size.h),a=r>s?1:r/s,o=Math.floor(a*this._size.w),h=Math.floor(a*this._size.h),c=new Zi(o,h,{depthBuffer:!1,format:ai,magFilter:Kt,minFilter:Kt,stencilBuffer:!1});this._render={camera:i,target:c};const l=Af({x:0,y:0},this._size,{max:this._level.max,z:0});this._renderToTarget(l,this._background),this._createdSubject$.next(c.texture),this._hasSubject$.next(!0)}_markRendered(e){const t=Array.from(this._rendered.entries()).filter((([t,i])=>i.z!==e.z));for(const[i,n]of t)Rf(e,n)&&this._rendered.delete(i);const i=this._store.inventId(e);this._rendered.set(i,e),this._renderedLevel.add(i)}_removeFromArray(e,t){const i=t.indexOf(e);-1!==i&&t.splice(i,1)}_renderToTarget(e,t){const i=new Wi(t);i.minFilter=Kt,i.needsUpdate=!0;const n=new ws(e.w,e.h),r=new wr({map:i,side:0}),s=new es(n,r);s.position.x=-this._size.w/2+e.x+e.w/2,s.position.y=this._size.h/2-e.y-e.h/2;const a=new ch;a.add(s);const o=this._renderer.getRenderTarget();this._renderer.resetState(),this._renderer.setRenderTarget(this._render.target),this._renderer.render(a,this._render.camera),this._renderer.setRenderTarget(o),a.remove(s),n.dispose(),r.dispose(),i.dispose()}}var Df,Nf,$f,kf;!function(e){e[e.Custom=0]="Custom",e[e.Earth=1]="Earth",e[e.Traversing=2]="Traversing",e[e.Waiting=3]="Waiting",e[e.WaitingInteractively=4]="WaitingInteractively"}(Df||(Df={}));class Of extends sf{constructor(e,t,i){super(e,t,i),this._imageTileLoader=new bf(i.api),this._roiCalculator=new wf,this._rendererOperation$=new j,this._rendererCreator$=new j,this._rendererDisposer$=new j,this._renderer$=this._rendererOperation$.pipe(Lt(((e,t)=>t(e)),null),st((e=>null!=e)),vt(void 0,(e=>e.frameId))),this._rendererCreator$.pipe(De((()=>e=>{if(null!=e)throw new Error("Multiple image plane states can not be created at the same time");return new vf}))).subscribe(this._rendererOperation$),this._rendererDisposer$.pipe(De((()=>e=>(e.dispose(),null)))).subscribe(this._rendererOperation$)}_activate(){const e=this._subscriptions;e.push(this._renderer$.pipe(De((e=>{const t={name:this._name,renderer:{frameId:e.frameId,needsRender:e.needsRender,render:e.render.bind(e),pass:yf.Background}};return e.clearNeedsRender(),t}))).subscribe(this._container.glRenderer.render$)),this._rendererCreator$.next(null),e.push(this._navigator.stateService.currentState$.pipe(De((e=>t=>(t.updateFrame(e),t)))).subscribe(this._rendererOperation$));const t=this._container.configurationService.imageTiling$.pipe(zt((e=>e?this._navigator.stateService.currentState$:new j)),vt(void 0,(e=>e.state.currentImage.id)),Vt(this._container.glRenderer.webGLRenderer$),De((([e,t])=>{const i=e.state,n=i.currentImage,r=i.currentTransform;return new Lf(n.id,r.basicWidth,r.basicHeight,n.image,this._imageTileLoader,new xf,t)})),Rt(1),U());e.push(t.subscribe((()=>{}))),e.push(t.pipe(De((e=>t=>(t.setTextureProvider(e.id,e),t)))).subscribe(this._rendererOperation$)),e.push(t.pipe(At()).subscribe((e=>{e[0].abort()})));const i=this._container.configurationService.imageTiling$.pipe(zt((e=>e?Ve(this._navigator.stateService.state$,this._navigator.stateService.inTranslation$):new j)),zt((([e,t])=>(e===Df.Traversing||e===Df.Waiting||e===Df.WaitingInteractively)&&!t?this._container.renderService.renderCameraFrame$:ie())),De((e=>({camera:e,height:e.size.height.valueOf(),lookat:e.camera.lookat.clone(),width:e.size.width.valueOf(),zoom:e.zoom.valueOf()}))),At(),De((([e,t])=>{const i=e.width===t.width&&e.height===t.height&&e.zoom===t.zoom&&e.lookat.equals(t.lookat);return{camera:t.camera,stalled:i}})),vt(((e,t)=>e.stalled===t.stalled)),st((e=>e.stalled)),Vt(this._container.renderService.size$,this._navigator.stateService.currentTransform$));e.push(t.pipe(zt((e=>i.pipe(De((([t,i,n])=>{const r=t.camera,s=(new hf).viewportToBasic(0,0,n,r.perspective);if(!(s[0]<0||s[1]<0||s[0]>1||s[1]>1))return[this._roiCalculator.computeRegionOfInterest(r,i,n),e]})),st((e=>!!e))))),st((e=>!e[1].disposed))).subscribe((([e,t])=>{t.setRegionOfInterest(e)})));const n=t.pipe(zt((e=>e.hasTexture$)),Ot(!1),Rt(1),U());e.push(n.subscribe((()=>{}))),e.push(this._navigator.panService.panImages$.pipe(st((e=>0===e.length)),De((()=>e=>(e.clearPeripheryPlanes(),e)))).subscribe(this._rendererOperation$));const r=this._navigator.panService.panImages$.pipe(zt((e=>ge(e).pipe(We((([e,t])=>Ve(this._navigator.graphService.cacheImage$(e.id).pipe(ct((t=>(console.error(`Failed to cache periphery image (${e.id})`,t),ie())))),Ce(t))))))),Dt());e.push(r.pipe(De((([e,t])=>i=>(i.addPeripheryPlane(e,t),i)))).subscribe(this._rendererOperation$)),e.push(r.pipe(We((([e])=>e.cacheImage$().pipe(ct((()=>ie()))))),De((e=>t=>(t.updateTextureImage(e.image,e),t)))).subscribe(this._rendererOperation$));const s=this._navigator.stateService.currentState$.pipe(De((e=>e.state.alpha<1)),vt()),a=Ve(this._container.mouseService.active$,this._container.touchService.active$,this._navigator.stateService.inMotion$,s).pipe(De((([e,t,i,n])=>!(e||t||i||n))),st((e=>e)));e.push(this._navigator.stateService.state$.pipe(zt((e=>e===Df.Traversing?this._navigator.panService.panImages$:ie())),zt((e=>a.pipe(Vt(this._container.renderService.renderCamera$,this._navigator.stateService.currentImage$,this._navigator.stateService.currentTransform$),We((([,t,i,n])=>Ce([t,i,n,e])))))),zt((([e,t,i,n])=>{const r=e.camera.lookat.clone().sub(e.camera.position),s=[(new Du).viewingDirection(t.rotation).angleTo(r),void 0],a=(new hf).viewportToBasic(0,0,i,e.perspective);a[0]>=0&&a[0]<=1&&a[1]>=0&&a[1]<=1&&(s[0]=Number.NEGATIVE_INFINITY);for(const[e]of n){const t=(new Du).viewingDirection(e.rotation).angleTo(r);t<s[0]&&(s[0]=t,s[1]=e.id)}return s[1]?this._navigator.moveTo$(s[1]).pipe(ct((()=>ie()))):ie()}))).subscribe())}_deactivate(){this._rendererDisposer$.next(null),this._subscriptions.unsubscribe()}_getDefaultConfiguration(){return{}}}Of.componentName="image";class zf{constructor(e,t,i){this._component=e,this._container=t,this._navigator=i,this._enabled=!1}get isEnabled(){return this._enabled}enable(){!this._enabled&&this._component.activated&&(this._enable(),this._enabled=!0,this._component.configure(this._getConfiguration(!0)))}disable(){this._enabled&&(this._disable(),this._enabled=!1,this._component.activated&&this._component.configure(this._getConfiguration(!1)))}}class Ff extends zf{_enable(){const t=this._navigator.stateService.currentImage$.pipe(zt((e=>e.sequenceEdges$)));this._keyDownSubscription=this._container.keyboardService.keyDown$.pipe(Vt(t)).subscribe((([t,i])=>{let n=null;switch(t.keyCode){case 38:n=e.NavigationDirection.Next;break;case 40:n=e.NavigationDirection.Prev;break;default:return}if(t.preventDefault(),t.altKey&&!t.shiftKey&&i.cached)for(const e of i.edges)if(e.data.direction===n)return void this._navigator.moveTo$(e.target).subscribe(void 0,(e=>{e instanceof uf||console.error(e)}))}))}_disable(){this._keyDownSubscription.unsubscribe()}_getConfiguration(e){return{keySequenceNavigation:e}}}class Bf extends zf{constructor(e,t,i,n){super(e,t,i),this._spatial=n}_enable(){const t=this._navigator.stateService.currentImage$.pipe(zt((e=>e.spatialEdges$)));this._keyDownSubscription=this._container.keyboardService.keyDown$.pipe(Vt(t,this._navigator.stateService.currentState$)).subscribe((([t,i,n])=>{let r=$u(n.state.currentImage.cameraType),s=null;switch(t.keyCode){case 37:s=t.shiftKey&&!r?e.NavigationDirection.TurnLeft:e.NavigationDirection.StepLeft;break;case 38:s=t.shiftKey&&!r?e.NavigationDirection.Spherical:e.NavigationDirection.StepForward;break;case 39:s=t.shiftKey&&!r?e.NavigationDirection.TurnRight:e.NavigationDirection.StepRight;break;case 40:s=t.shiftKey&&!r?e.NavigationDirection.TurnU:e.NavigationDirection.StepBackward;break;default:return}if(t.preventDefault(),!(t.altKey||!i.cached||t.shiftKey&&r))if(r){const t={};t[e.NavigationDirection.StepBackward]=Math.PI,t[e.NavigationDirection.StepForward]=0,t[e.NavigationDirection.StepLeft]=Math.PI/2,t[e.NavigationDirection.StepRight]=-Math.PI/2;const r=this._rotationFromCamera(n.state.camera).phi,a=this._spatial.wrapAngle(r+t[s]),o=Math.PI/4,h=i.edges.filter((t=>t.data.direction===e.NavigationDirection.Spherical||t.data.direction===s));let c=Number.MAX_VALUE,l=null;for(const e of h){const t=Math.abs(this._spatial.wrapAngle(e.data.worldMotionAzimuth-a));t<Math.min(c,o)&&(c=t,l=e.target)}if(null==l)return;this._moveTo(l)}else this._moveDir(s,i)}))}_disable(){this._keyDownSubscription.unsubscribe()}_getConfiguration(e){return{keySpatialNavigation:e}}_moveDir(e,t){for(const i of t.edges)if(i.data.direction===e)return void this._moveTo(i.target)}_moveTo(e){this._navigator.moveTo$(e).subscribe(void 0,(e=>{e instanceof uf||console.error(e)}))}_rotationFromCamera(e){let t=e.lookat.clone().sub(e.position),i=t.clone().dot(e.up),n=t.clone().sub(e.up.clone().multiplyScalar(i));return{phi:Math.atan2(n.y,n.x),theta:Math.PI/2-this._spatial.angleToPlane(t.toArray(),[0,0,1])}}}class Uf extends zf{constructor(e,t,i,n){super(e,t,i),this._viewportCoords=n}_enable(){this._keyDownSubscription=this._container.keyboardService.keyDown$.pipe(Vt(this._container.renderService.renderCamera$,this._navigator.stateService.currentTransform$)).subscribe((([e,t,i])=>{if(e.altKey||e.ctrlKey||e.metaKey)return;let n=0;switch(e.key){case"+":n=1;break;case"-":n=-1;break;default:return}e.preventDefault();const r=this._viewportCoords.unprojectFromViewport(0,0,t.perspective),s=i.projectBasic(r.toArray());this._navigator.stateService.zoomIn(n,s)}))}_disable(){this._keyDownSubscription.unsubscribe()}_getConfiguration(e){return{keyZoom:e}}}class Vf extends zf{_enable(){this._keyDownSubscription=this._container.keyboardService.keyDown$.pipe(Vt(this._navigator.playService.playing$,this._navigator.playService.direction$,this._navigator.playService.speed$,this._navigator.stateService.currentImage$.pipe(zt((e=>e.sequenceEdges$))),this._navigator.stateService.state$.pipe(De((e=>e===Df.Earth)),vt()))).subscribe((([t,i,n,r,s,a])=>{if(!(t.altKey||t.ctrlKey||t.metaKey)){switch(t.key){case"D":if(!t.shiftKey)return;const o=i?null:n===e.NavigationDirection.Next?e.NavigationDirection.Prev:n===e.NavigationDirection.Prev?e.NavigationDirection.Next:null;null!=o&&this._navigator.playService.setDirection(o);break;case" ":if(t.shiftKey)return;if(!a)if(i)this._navigator.playService.stop();else for(let e of s.edges)e.data.direction===n&&this._navigator.playService.play();break;case"<":this._navigator.playService.setSpeed(r-.05);break;case">":this._navigator.playService.setSpeed(r+.05);break;default:return}t.preventDefault()}}))}_disable(){this._keyDownSubscription.unsubscribe()}_getConfiguration(e){return{keyPlay:e}}}class Hf extends sf{constructor(e,t,i){super(e,t,i),this._keyPlayHandler=new Vf(this,t,i),this._keySequenceNavigationHandler=new Ff(this,t,i),this._keySpatialNavigationHandler=new Bf(this,t,i,new Du),this._keyZoomHandler=new Uf(this,t,i,new hf)}get keyPlay(){return this._keyPlayHandler}get keySequenceNavigation(){return this._keySequenceNavigationHandler}get keySpatialNavigation(){return this._keySpatialNavigationHandler}get keyZoom(){return this._keyZoomHandler}_activate(){this._subscriptions.push(this._configuration$.subscribe((e=>{e.keyPlay?this._keyPlayHandler.enable():this._keyPlayHandler.disable(),e.keySequenceNavigation?this._keySequenceNavigationHandler.enable():this._keySequenceNavigationHandler.disable(),e.keySpatialNavigation?this._keySpatialNavigationHandler.enable():this._keySpatialNavigationHandler.disable(),e.keyZoom?this._keyZoomHandler.enable():this._keyZoomHandler.disable()})))}_deactivate(){this._subscriptions.unsubscribe(),this._keyPlayHandler.disable(),this._keySequenceNavigationHandler.disable(),this._keySpatialNavigationHandler.disable(),this._keyZoomHandler.disable()}_getDefaultConfiguration(){return{keyPlay:!0,keySequenceNavigation:!0,keySpatialNavigation:!0,keyZoom:!0}}}Hf.componentName="keyboard";class jf{constructor(e,t){this._needsRender=!1,this._interactiveObjects=[],this._markers={},this._objectMarkers={},this._raycaster=t||new su,this._scene=e||new ch}get markers(){return this._markers}get needsRender(){return this._needsRender}add(e,t){e.id in this._markers&&this._dispose(e.id),e.createGeometry(t),this._scene.add(e.geometry),this._markers[e.id]=e;for(let t of e.getInteractiveObjects())this._interactiveObjects.push(t),this._objectMarkers[t.uuid]=e.id;this._needsRender=!0}clear(){for(const e in this._markers)this._markers.hasOwnProperty&&this._dispose(e);this._needsRender=!0}get(e){return this._markers[e]}getAll(){return Object.keys(this._markers).map((e=>this._markers[e]))}has(e){return e in this._markers}intersectObjects([e,t],i){this._raycaster.setFromCamera(new zi(e,t),i);const n=this._raycaster.intersectObjects(this._interactiveObjects);for(const e of n)if(e.object.uuid in this._objectMarkers)return this._objectMarkers[e.object.uuid];return null}lerpAltitude(e,t,i){e in this._markers&&(this._markers[e].lerpAltitude(t,i),this._needsRender=!0)}remove(e){e in this._markers&&(this._dispose(e),this._needsRender=!0)}render(e,t){t.render(this._scene,e),this._needsRender=!1}update(e,t,i){if(!(e in this._markers))return;this._markers[e].updatePosition(t,i),this._needsRender=!0}_dispose(e){const t=this._markers[e];this._scene.remove(t.geometry);for(let i of t.getInteractiveObjects()){const t=this._interactiveObjects.indexOf(i);-1!==t?this._interactiveObjects.splice(t,1):console.warn(`Object does not exist (${i.id}) for ${e}`),delete this._objectMarkers[i.uuid]}t.disposeGeometry(),delete this._markers[e]}}class Gf extends sf{constructor(e,t,i){super(e,t,i),this._graphCalculator=new Mu,this._markerScene=new jf,this._markerSet=new Vu,this._viewportCoords=new hf,this._relativeGroundAltitude=-2}add(e){this._markerSet.add(e)}fire(e,t){super.fire(e,t)}get(e){return this._markerSet.get(e)}getAll(){return this._markerSet.getAll()}getMarkerIdAt(e){return new Promise(((t,i)=>{this._container.renderService.renderCamera$.pipe(St(),De((t=>{const i=this._viewportCoords.canvasToViewport(e[0],e[1],this._container.container);return this._markerScene.intersectObjects(i,t.perspective)}))).subscribe((e=>{t(e)}),(e=>{i(e)}))}))}has(e){return this._markerSet.has(e)}off(e,t){super.off(e,t)}on(e,t){super.on(e,t)}remove(e){this._markerSet.remove(e)}removeAll(){this._markerSet.removeAll()}_activate(){const e=this._navigator.stateService.currentState$.pipe(De((e=>e.state.camera.position.z+this._relativeGroundAltitude)),vt(((e,t)=>Math.abs(e-t)<.01)),Rt(1),U()),t=Ve(e,this._navigator.stateService.reference$).pipe(St(),De((()=>{})),Rt(1),U()),i=this._configuration$.pipe(De((e=>({visibleBBoxSize:Math.max(1,Math.min(200,e.visibleBBoxSize))})))),n=this._navigator.stateService.currentImage$.pipe(De((e=>e.lngLat)),Rt(1),U()),r=Ve(i,n).pipe(De((([e,t])=>this._graphCalculator.boundingBoxCorners(t,e.visibleBBoxSize/2))),Rt(1),U()),s=Ve(Ze(Ce(this._markerSet),this._markerSet.changed$),r).pipe(De((([e,t])=>e.search(t)))),a=this._subscriptions;a.push(t.pipe(zt((()=>s.pipe(Vt(this._navigator.stateService.reference$,e))))).subscribe((([e,t,i])=>{const n=this._markerScene,r=n.markers,s=Object.assign({},r);for(const a of e)if(a.id in r)delete s[a.id];else{const e=_u(a.lngLat.lng,a.lngLat.lat,t.alt+i,t.lng,t.lat,t.alt);n.add(a,e)}for(const e in s)s.hasOwnProperty(e)&&n.remove(e)}))),a.push(t.pipe(zt((()=>this._markerSet.updated$.pipe(Vt(r,this._navigator.stateService.reference$,e))))).subscribe((([e,[t,i],n,r])=>{const s=this._markerScene;for(const a of e){const e=s.has(a.id),o=a.lngLat.lat>t.lat&&a.lngLat.lat<i.lat&&a.lngLat.lng>t.lng&&a.lngLat.lng<i.lng;if(o){const e=_u(a.lngLat.lng,a.lngLat.lat,n.alt+r,n.lng,n.lat,n.alt);s.add(a,e)}else!o&&e&&s.remove(a.id)}}))),a.push(this._navigator.stateService.reference$.pipe($t(1),Vt(e)).subscribe((([e,t])=>{const i=this._markerScene;for(const n of i.getAll()){const r=_u(n.lngLat.lng,n.lngLat.lat,e.alt+t,e.lng,e.lat,e.alt);i.update(n.id,r)}}))),a.push(e.pipe($t(1),Vt(this._navigator.stateService.reference$,n)).subscribe((([e,t,i])=>{const n=this._markerScene,r=_u(i.lng,i.lat,t.alt+e,t.lng,t.lat,t.alt);for(const i of n.getAll()){const s=_u(i.lngLat.lng,i.lngLat.lat,t.alt+e,t.lng,t.lat,t.alt),a=s[0]-r[0],o=s[1]-r[1],h=Math.sqrt(a*a+o*o);h>50||n.lerpAltitude(i.id,e,Math.min(1,Math.max(0,1.2-1.2*h/50)))}}))),a.push(this._navigator.stateService.currentState$.pipe(De((e=>{const t=this._markerScene;return{name:this._name,renderer:{frameId:e.id,needsRender:t.needsRender,render:t.render.bind(t),pass:yf.Opaque}}}))).subscribe(this._container.glRenderer.render$));const o=Ve(this._container.renderService.renderCamera$,this._container.mouseService.mouseMove$).pipe(De((([e,t])=>{const i=this._container.container,[n,r]=this._viewportCoords.canvasPosition(t,i),s=this._viewportCoords.canvasToViewport(n,r,i);return this._markerScene.intersectObjects(s,e.perspective)})),Rt(1),U()),h=this._container.mouseService.filtered$(this._name,this._container.mouseService.mouseDragStart$).pipe(De((()=>!0))),c=this._container.mouseService.filtered$(this._name,this._container.mouseService.mouseDragEnd$).pipe(De((()=>!1))),l=it(h,c).pipe(Ot(!1));a.push(it(h.pipe(Vt(o)),Ve(c,Ce(null))).pipe(Ot([!1,null]),At()).subscribe((([e,t])=>{const i=t[0],n=i?"markerdragstart":"markerdragend",r=i?t[1]:e[1],s={marker:this._markerScene.get(r),target:this,type:n};this.fire(n,s)})));const u=it(this._container.mouseService.mouseDown$.pipe(De((()=>!0))),this._container.mouseService.documentMouseUp$.pipe(De((()=>!1)))).pipe(Ot(!1));a.push(Ve(this._container.mouseService.active$,o.pipe(vt()),u,l).pipe(De((([e,t,i,n])=>!e&&null!=t&&i||n)),vt()).subscribe((e=>{e?(this._container.mouseService.claimMouse(this._name,1),this._container.mouseService.claimWheel(this._name,1)):(this._container.mouseService.unclaimMouse(this._name),this._container.mouseService.unclaimWheel(this._name))})));const d=this._container.mouseService.filtered$(this._name,this._container.mouseService.mouseDragStart$).pipe(Vt(o,this._container.renderService.renderCamera$),De((([e,t,i])=>{const n=this._markerScene.get(t),r=this._container.container,[s,a]=this._viewportCoords.projectToCanvas(n.geometry.position.toArray(),r,i.perspective),[o,h]=this._viewportCoords.canvasPosition(e,r);return[n,[o-s,h-a],i]})),Rt(1),U());a.push(this._container.mouseService.filtered$(this._name,this._container.mouseService.mouseDrag$).pipe(Vt(d,this._navigator.stateService.reference$,i)).subscribe((([e,[t,i,n],r,s])=>{if(!this._markerScene.has(t.id))return;const a=this._container.container,[o,h]=this._viewportCoords.canvasPosition(e,a),c=o-i[0],l=h-i[1],[u,d]=this._viewportCoords.canvasToViewport(c,l,a),p=new Ki(u,d,1).unproject(n.perspective).sub(n.perspective.position).normalize(),m=Math.min(this._relativeGroundAltitude/p.z,s.visibleBBoxSize/2-.1);if(m<0)return;const f=p.clone().multiplyScalar(m).add(n.perspective.position);f.z=n.perspective.position.z+this._relativeGroundAltitude;const[g,_]=vu(f.x,f.y,f.z,r.lng,r.lat,r.alt);this._markerScene.update(t.id,f.toArray(),{lat:_,lng:g}),this._markerSet.update(t);const v="markerposition",y={marker:t,target:this,type:v};this.fire(v,y)})))}_deactivate(){this._subscriptions.unsubscribe(),this._markerScene.clear()}_getDefaultConfiguration(){return{visibleBBoxSize:100}}}function Wf(e,t){return e.x<=Math.max(t.p1.x,t.p2.x)&&e.x>=Math.min(t.p1.x,t.p2.x)&&e.y>=Math.max(t.p1.y,t.p2.y)&&e.y>=Math.min(t.p1.y,t.p2.y)}function qf(e,t){const i=e.p2.x-e.p1.x,n=e.p2.y-e.p1.y,r=t.p2.x-t.p1.x,s=t.p2.y-t.p1.y,a=i*s-n*r;return a*a<1e-10*(i*i+n*n)*(r*r+s*s)}function Xf(e,t,i){const n=(t.y-e.y)*(i.x-t.x)-(i.y-t.y)*(t.x-e.x);return(r=n)>0?1:r<0?-1:0;var r}function Zf(e,t){if(qf(e,t))return!1;const i=Xf(e.p1,e.p2,t.p1),n=Xf(e.p1,e.p2,t.p2),r=Xf(t.p1,t.p2,e.p1),s=Xf(t.p1,t.p2,e.p2);return i!==n&&r!==s||(!(0!==i||!Wf(t.p1,e))||(!(0!==n||!Wf(t.p2,e))||(!(0!==r||!Wf(e.p1,t))||!(0!==s||!Wf(e.p2,t)))))}function Yf(e,t){if(qf(e,t))return;const i=e.p1.x,n=e.p2.x,r=e.p1.y,s=e.p2.y,a=t.p1.x,o=t.p2.x,h=t.p1.y,c=t.p2.y,l=(i-n)*(h-c)-(r-s)*(a-o);return{x:((i*s-r*n)*(a-o)-(i-n)*(a*c-h*o))/l,y:((i*s-r*n)*(h-c)-(r-s)*(a*c-h*o))/l}}function Jf(e,t){return e>=-1&&e<=1&&t>=-1&&t<=1}function Kf(e,t){return e>=0&&e<=1&&t>=0&&t<=1}function Qf(e,t,i){const n=function(e){let t=[],i=[[0,0],[1,0],[1,1],[0,1]],n=[[1,0],[0,1],[-1,0],[0,-1]];for(let r=0;r<4;++r){let s=i[r],a=n[r];for(let i=0;i<e;++i)t.push([s[0]+a[0]*i/e,s[1]+a[1]*i/e])}return t}(100).map((n=>i.basicToViewportSafe(n[0],n[1],e,t))),r=[],s=[{x:-1,y:1},{x:1,y:1},{x:1,y:-1},{x:-1,y:-1}],a=[!1,!1,!1,!1];for(let e=0;e<n.length;e++){const t=n[e],i=n[(e+1)%n.length];if(null===t)continue;if(null===i){Jf(t[0],t[1])&&r.push(t);continue}const[o,h]=t,[c,l]=i;if(Jf(o,h))if(Jf(c,l))r.push(t);else for(let e=0;e<4;e++){const i={p1:{x:o,y:h},p2:{x:c,y:l}},n={p1:s[e],p2:s[(e+1)%4]};if(Zf(i,n)){const s=Yf(i,n);r.push(t,[s.x,s.y]),a[e]=!0}}}const[o,h]=i.viewportToBasic(-1,1,e,t),[c,l]=i.viewportToBasic(1,1,e,t),[u,d]=i.viewportToBasic(1,-1,e,t),[p,m]=i.viewportToBasic(-1,-1,e,t);Kf(o,h)&&(a[3]=a[0]=!0),Kf(c,l)&&(a[0]=a[1]=!0),Kf(u,d)&&(a[1]=a[2]=!0),Kf(p,m)&&(a[2]=a[3]=!0);const f=[-1,-1,1,1];for(let e of r){const t=e[0],i=e[1];t>f[1]&&(f[1]=t),t<f[3]&&(f[3]=t),i>f[0]&&(f[0]=i),i<f[2]&&(f[2]=i)}const g=[1,1,-1,-1],_=[];for(let e=0;e<4;e++)a[e]?_.push(0):_.push(Math.abs(g[e]-f[e]));return _}Gf.componentName="marker";class eg extends zf{constructor(e,t,i,n,r){super(e,t,i),this._spatial=r,this._viewportCoords=n}_enable(){const e=this._navigator.stateService.currentState$.pipe(De((e=>e.state.alpha<1)),vt());this._bounceSubscription=Ve(e,this._navigator.stateService.inTranslation$,this._container.mouseService.active$,this._container.touchService.active$).pipe(De((e=>e[0]||e[1]||e[2]||e[3])),vt(),zt((e=>e?ie():Ve(this._container.renderService.renderCamera$,this._navigator.stateService.currentTransform$.pipe(St())))),Vt(this._navigator.panService.panImages$)).subscribe((([[e,t],i])=>{if(!t.hasValidScale&&e.camera.focal<.1)return;if(0===e.perspective.aspect||e.perspective.aspect===Number.POSITIVE_INFINITY)return;const n=Qf(t,e.perspective,this._viewportCoords),r=this._viewportCoords.viewportToBasic(0,0,t,e.perspective);(r[0]<0||r[0]>1)&&i.length>0&&(n[0]=n[2]=0);for(const[,t]of i){const i=Qf(t,e.perspective,this._viewportCoords);for(let e=1;e<n.length;e+=2)i[e]<n[e]&&(n[e]=i[e])}if(Math.max(...n)<.01)return;const s=n[1]-n[3],a=n[0]-n[2],o=this._viewportCoords.unprojectFromViewport(0,0,e.perspective).sub(e.perspective.position),h=this._viewportCoords.unprojectFromViewport(s,0,e.perspective).sub(e.perspective.position),c=this._viewportCoords.unprojectFromViewport(0,a,e.perspective).sub(e.perspective.position);let l=(s>0?1:-1)*h.angleTo(o),u=(a>0?1:-1)*c.angleTo(o);const d=Math.PI/60;l=this._spatial.clamp(.1*l,-d,d),u=this._spatial.clamp(.1*u,-d,d),this._navigator.stateService.rotateUnbounded({phi:l,theta:u})}))}_disable(){this._bounceSubscription.unsubscribe()}_getConfiguration(){return{}}}class tg{static filteredPairwiseMouseDrag$(e,t){return this._filteredPairwiseMouseDrag$(e,t,t.mouseDragStart$,t.mouseDrag$,t.mouseDragEnd$)}static filteredPairwiseMouseRightDrag$(e,t){return this._filteredPairwiseMouseDrag$(e,t,t.mouseRightDragStart$,t.mouseRightDrag$,t.mouseRightDragEnd$)}static _filteredPairwiseMouseDrag$(e,t,i,n,r){return t.filtered$(e,i).pipe(zt((i=>it(Ze(Ce(i),t.filtered$(e,n)),t.filtered$(e,r).pipe(De((()=>null)))).pipe(Bt((e=>!!e)),Ot(null)))),At(),st((e=>null!=e[0]&&null!=e[1])))}}class ig extends zf{constructor(e,t,i,n,r){super(e,t,i),this._spatial=r,this._viewportCoords=n}_enable(){let e=this._container.mouseService.filtered$(this._component.name,this._container.mouseService.mouseDragStart$).pipe(De((()=>!0)),Dt()),t=this._container.mouseService.filtered$(this._component.name,this._container.mouseService.mouseDragEnd$).pipe(De((()=>!1)),Dt());this._activeMouseSubscription=it(e,t).subscribe(this._container.mouseService.activate$);const i=it(e,t).pipe(zt((e=>e?this._container.mouseService.documentMouseMove$:ie())));this._preventDefaultSubscription=it(i,this._container.touchService.touchMove$).subscribe((e=>{e.preventDefault()}));let n=this._container.touchService.singleTouchDragStart$.pipe(De((()=>!0))),r=this._container.touchService.singleTouchDragEnd$.pipe(De((()=>!1)));this._activeTouchSubscription=it(n,r).subscribe(this._container.touchService.activate$);const s=this._navigator.stateService.currentState$.pipe(De((e=>$u(e.state.currentImage.cameraType)||e.state.imagesAhead<1)),vt(),zt((e=>{if(!e)return ie();const t=tg.filteredPairwiseMouseDrag$(this._component.name,this._container.mouseService),i=it(this._container.touchService.singleTouchDragStart$,this._container.touchService.singleTouchDrag$,this._container.touchService.singleTouchDragEnd$.pipe(De((()=>null)))).pipe(De((e=>null!=e&&e.touches.length>0?e.touches[0]:null)),At(),st((e=>null!=e[0]&&null!=e[1])));return it(t,i)})),Vt(this._container.renderService.renderCamera$,this._navigator.stateService.currentTransform$,this._navigator.panService.panImages$),De((([e,t,i,n])=>{let r=e[0],s=e[1],a=s.clientX-r.clientX,o=s.clientY-r.clientY,h=this._container.container,[c,l]=this._viewportCoords.canvasPosition(s,h),u=this._viewportCoords.unprojectFromCanvas(c,l,h,t.perspective).sub(t.perspective.position),d=this._viewportCoords.unprojectFromCanvas(c-a,l,h,t.perspective).sub(t.perspective.position),p=this._viewportCoords.unprojectFromCanvas(c,l-o,h,t.perspective).sub(t.perspective.position),m=(a>0?1:-1)*d.angleTo(u),f=(o>0?-1:1)*p.angleTo(u);const g=Qf(i,t.perspective,this._viewportCoords);for(const[,e]of n){const i=Qf(e,t.perspective,this._viewportCoords);for(let e=0;e<g.length;e++)i[e]<g[e]&&(g[e]=i[e])}return g[0]>0&&f<0&&(f/=Math.max(1,200*g[0])),g[2]>0&&f>0&&(f/=Math.max(1,200*g[2])),g[1]>0&&m<0&&(m/=Math.max(1,200*g[1])),g[3]>0&&m>0&&(m/=Math.max(1,200*g[3])),{phi:m,theta:f}})),Dt());var a;this._rotateWithoutInertiaSubscription=s.subscribe((e=>{this._navigator.stateService.rotateWithoutInertia(e)})),this._rotateSubscription=s.pipe(Lt(((e,t)=>(this._drainBuffer(e),e.push([Date.now(),t]),e)),[]),(a=it(this._container.mouseService.filtered$(this._component.name,this._container.mouseService.mouseDragEnd$),this._container.touchService.singleTouchDragEnd$),F((function(e,t){var i=!1,n=null;e.subscribe(new B(t,(function(e){i=!0,n=e}))),a.subscribe(new B(t,(function(){if(i){i=!1;var e=n;n=null,t.next(e)}}),w))}))),De((e=>{const t=this._drainBuffer(e.slice()),i={phi:0,theta:0};for(const e of t)i.phi+=e[1].phi,i.theta+=e[1].theta;const n=t.length;n>0&&(i.phi/=n,i.theta/=n);const r=Math.PI/18;return i.phi=this._spatial.clamp(i.phi,-r,r),i.theta=this._spatial.clamp(i.theta,-r,r),i}))).subscribe((e=>{this._navigator.stateService.rotate(e)}))}_disable(){this._activeMouseSubscription.unsubscribe(),this._activeTouchSubscription.unsubscribe(),this._preventDefaultSubscription.unsubscribe(),this._rotateSubscription.unsubscribe(),this._rotateWithoutInertiaSubscription.unsubscribe(),this._activeMouseSubscription=null,this._activeTouchSubscription=null,this._preventDefaultSubscription=null,this._rotateSubscription=null}_getConfiguration(e){return{dragPan:e}}_drainBuffer(e){const t=Date.now();for(;e.length>0&&t-e[0][0]>50;)e.shift();return e}}class ng extends zf{constructor(e,t,i,n,r){super(e,t,i),this._spatial=r,this._viewportCoords=n,this._subscriptions=new rf}_enable(){const e=this._navigator.stateService.state$.pipe(De((e=>e===Df.Earth)),Rt(1),U()),t=this._subscriptions;t.push(e.pipe(zt((e=>e?this._container.mouseService.mouseWheel$:ie()))).subscribe((e=>{e.preventDefault()}))),t.push(e.pipe(zt((e=>e?tg.filteredPairwiseMouseDrag$(this._component.name,this._container.mouseService).pipe(st((([e,t])=>!(e.ctrlKey&&t.ctrlKey)))):ie())),Vt(this._container.renderService.renderCamera$,this._navigator.stateService.currentTransform$),De((([[e,t],i,n])=>{const r=[0,0,1],s=[0,0,-2],a=this._planeIntersection(t,r,s,i.perspective,this._container.container),o=this._planeIntersection(e,r,s,i.perspective,this._container.container);if(!a||!o)return null;return(new Ki).subVectors(a,o).multiplyScalar(-1).toArray()})),st((e=>!!e))).subscribe((e=>{this._navigator.stateService.truck(e)}))),t.push(e.pipe(zt((e=>e?tg.filteredPairwiseMouseDrag$(this._component.name,this._container.mouseService).pipe(st((([e,t])=>e.ctrlKey&&t.ctrlKey))):ie())),De((([e,t])=>this._mousePairToRotation(e,t)))).subscribe((e=>{this._navigator.stateService.orbit(e)}))),t.push(e.pipe(zt((e=>e?tg.filteredPairwiseMouseRightDrag$(this._component.name,this._container.mouseService).pipe(st((([e,t])=>!e.ctrlKey&&!t.ctrlKey))):ie())),De((([e,t])=>this._mousePairToRotation(e,t)))).subscribe((e=>{this._navigator.stateService.orbit(e)}))),t.push(e.pipe(zt((e=>e?this._container.mouseService.filteredWheel$(this._component.name,this._container.mouseService.mouseWheel$):ie())),De((e=>{let t=e.deltaY;1===e.deltaMode?t*=40:2===e.deltaMode&&(t*=800);return-t/this._viewportCoords.containerToCanvas(this._container.container)[1]}))).subscribe((e=>{this._navigator.stateService.dolly(e)})))}_disable(){this._subscriptions.unsubscribe()}_getConfiguration(){return{}}_eventToViewport(e,t){const i=this._viewportCoords.canvasPosition(e,t);return this._viewportCoords.canvasToViewport(i[0],i[1],t)}_mousePairToRotation(e,t){const[i,n]=this._eventToViewport(t,this._container.container),[r,s]=this._eventToViewport(e,this._container.container);return{phi:(r-i)*Math.PI,theta:(n-s)*Math.PI/2}}_planeIntersection(e,t,i,n,r){const[s,a]=this._viewportCoords.canvasPosition(e,r),o=this._viewportCoords.unprojectFromCanvas(s,a,r,n).sub(n.position).normalize();if(Math.abs(this._spatial.angleToPlane(o.toArray(),t))<Math.PI/90)return null;const h=n.position.clone(),c=(new Ki).fromArray(t),l=(new Ki).fromArray(i),u=(new Ki).subVectors(l,h).dot(c)/o.clone().dot(c),d=(new Ki).addVectors(h,o.multiplyScalar(u));return this._viewportCoords.worldToCamera(d.toArray(),n)[2]>0?null:d}}class rg extends zf{constructor(e,t,i,n){super(e,t,i),this._viewportCoords=n}_enable(){this._container.mouseService.claimWheel(this._component.name,0),this._preventDefaultSubscription=this._container.mouseService.mouseWheel$.subscribe((e=>{e.preventDefault()})),this._zoomSubscription=this._container.mouseService.filteredWheel$(this._component.name,this._container.mouseService.mouseWheel$).pipe(Vt(this._navigator.stateService.currentState$,((e,t)=>[e,t])),st((e=>{let t=e[1].state;return $u(t.currentImage.cameraType)||t.imagesAhead<1})),De((e=>e[0])),Vt(this._container.renderService.renderCamera$,this._navigator.stateService.currentTransform$,((e,t,i)=>[e,t,i]))).subscribe((e=>{let t=e[0],i=e[1],n=e[2],r=this._container.container,[s,a]=this._viewportCoords.canvasPosition(t,r),o=this._viewportCoords.unprojectFromCanvas(s,a,r,i.perspective),h=n.projectBasic(o.toArray()),c=t.deltaY;1===t.deltaMode?c*=40:2===t.deltaMode&&(c*=800);let l=-3*c/this._viewportCoords.containerToCanvas(r)[1];this._navigator.stateService.zoomIn(l,h)}))}_disable(){this._container.mouseService.unclaimWheel(this._component.name),this._preventDefaultSubscription.unsubscribe(),this._zoomSubscription.unsubscribe(),this._preventDefaultSubscription=null,this._zoomSubscription=null}_getConfiguration(e){return{scrollZoom:e}}}class sg extends zf{constructor(e,t,i,n){super(e,t,i),this._viewportCoords=n}_enable(){this._preventDefaultSubscription=this._container.touchService.pinch$.subscribe((e=>{e.originalEvent.preventDefault()}));let e=this._container.touchService.pinchStart$.pipe(De((e=>!0))),t=this._container.touchService.pinchEnd$.pipe(De((e=>!1)));this._activeSubscription=it(e,t).subscribe(this._container.touchService.activate$),this._zoomSubscription=this._container.touchService.pinch$.pipe(Vt(this._navigator.stateService.currentState$),st((e=>{let t=e[1].state;return $u(t.currentImage.cameraType)||t.imagesAhead<1})),De((e=>e[0])),Vt(this._container.renderService.renderCamera$,this._navigator.stateService.currentTransform$)).subscribe((([e,t,i])=>{let n=this._container.container,[r,s]=this._viewportCoords.canvasPosition(e,n),a=this._viewportCoords.unprojectFromCanvas(r,s,n,t.perspective),o=i.projectBasic(a.toArray());const[h,c]=this._viewportCoords.containerToCanvas(n);let l=3*e.distanceChange/Math.min(h,c);this._navigator.stateService.zoomIn(l,o)}))}_disable(){this._activeSubscription.unsubscribe(),this._preventDefaultSubscription.unsubscribe(),this._zoomSubscription.unsubscribe(),this._preventDefaultSubscription=null,this._zoomSubscription=null}_getConfiguration(e){return{touchZoom:e}}}class ag extends sf{constructor(e,t,i){super(e,t,i);const n=new Du,r=new hf;this._bounceHandler=new eg(this,t,i,r,n),this._dragPanHandler=new ig(this,t,i,r,n),this._earthControlHandler=new ng(this,t,i,r,n),this._scrollZoomHandler=new rg(this,t,i,r),this._touchZoomHandler=new sg(this,t,i,r)}get dragPan(){return this._dragPanHandler}get earthControl(){return this._earthControlHandler}get scrollZoom(){return this._scrollZoomHandler}get touchZoom(){return this._touchZoomHandler}_activate(){this._bounceHandler.enable(),this._subscriptions.push(this._configuration$.subscribe((e=>{e.dragPan?this._dragPanHandler.enable():this._dragPanHandler.disable(),e.earthControl?this._earthControlHandler.enable():this._earthControlHandler.disable(),e.scrollZoom?this._scrollZoomHandler.enable():this._scrollZoomHandler.disable(),e.touchZoom?this._touchZoomHandler.enable():this._touchZoomHandler.disable()}))),this._container.mouseService.claimMouse(this._name,0)}_deactivate(){this._container.mouseService.unclaimMouse(this._name),this._subscriptions.unsubscribe(),this._bounceHandler.disable(),this._dragPanHandler.disable(),this._earthControlHandler.disable(),this._scrollZoomHandler.disable(),this._touchZoomHandler.disable()}_getDefaultConfiguration(){return{dragPan:!0,earthControl:!0,scrollZoom:!0,touchZoom:!0}}}ag.componentName="pointer";class og{constructor(e){this._document=e||document}get document(){return this._document}createElement(e,t,i){const n=this._document.createElement(e);return t&&(n.className=t),i&&i.appendChild(n),n}}class hg extends sf{constructor(e,t,i,n){super(e,t,i),this._dom=n||new og,this._popups=[],this._added$=new j,this._popups$=new j}add(e){for(const t of e)-1===this._popups.indexOf(t)&&(this._popups.push(t),this._activated&&t.setParentContainer(this._popupContainer));this._added$.next(e),this._popups$.next(this._popups)}getAll(){return this._popups.slice()}remove(e){for(const t of e)this._remove(t);this._popups$.next(this._popups)}removeAll(){for(const e of this._popups.slice())this._remove(e);this._popups$.next(this._popups)}_activate(){this._popupContainer=this._dom.createElement("div","mapillary-popup-container",this._container.container);for(const e of this._popups)e.setParentContainer(this._popupContainer);const e=this._subscriptions;e.push(Ve(this._container.renderService.renderCamera$,this._container.renderService.size$,this._navigator.stateService.currentTransform$).subscribe((([e,t,i])=>{for(const n of this._popups)n.update(e,t,i)})));const t=this._popups$.pipe(Ot(this._popups),zt((e=>ge(e).pipe(We((e=>e.changed$))))),De((e=>[e])));e.push(it(this._added$,t).pipe(Vt(this._container.renderService.renderCamera$,this._container.renderService.size$,this._navigator.stateService.currentTransform$)).subscribe((([e,t,i,n])=>{for(const r of e)r.update(t,i,n)})))}_deactivate(){this._subscriptions.unsubscribe();for(const e of this._popups)e.remove();this._container.container.removeChild(this._popupContainer),delete this._popupContainer}_getDefaultConfiguration(){return{}}_remove(e){const t=this._popups.indexOf(e);if(-1===t)return;const i=this._popups.splice(t,1)[0];this._activated&&i.remove()}}hg.componentName="popup",function(e){e[e.Sequence=0]="Sequence",e[e.Spatial=1]="Spatial"}(Nf||(Nf={})),function(e){e[e.Default=0]="Default",e[e.Playback=1]="Playback",e[e.Timeline=2]="Timeline"}($f||($f={}));class cg{constructor(e){this._container=e,this._minThresholdWidth=320,this._maxThresholdWidth=1480,this._minThresholdHeight=240,this._maxThresholdHeight=820,this._stepperDefaultWidth=108,this._controlsDefaultWidth=88,this._defaultHeight=30,this._expandControls=!1,this._mode=$f.Default,this._speed=.5,this._changingSpeed=!1,this._index=null,this._changingPosition=!1,this._mouseEnterDirection$=new j,this._mouseLeaveDirection$=new j,this._notifyChanged$=new j,this._notifyChangingPositionChanged$=new j,this._notifySpeedChanged$=new j,this._notifyIndexChanged$=new j}get changed$(){return this._notifyChanged$}get changingPositionChanged$(){return this._notifyChangingPositionChanged$}get speed$(){return this._notifySpeedChanged$}get index$(){return this._notifyIndexChanged$}get mouseEnterDirection$(){return this._mouseEnterDirection$}get mouseLeaveDirection$(){return this._mouseLeaveDirection$}activate(){this._changingSubscription||(this._changingSubscription=it(this._container.mouseService.documentMouseUp$,this._container.touchService.touchEnd$.pipe(st((e=>0===e.touches.length)))).subscribe((()=>{this._changingSpeed&&(this._changingSpeed=!1),this._changingPosition&&this._setChangingPosition(!1)})))}deactivate(){this._changingSubscription&&(this._changingSpeed=!1,this._changingPosition=!1,this._expandControls=!1,this._mode=$f.Default,this._changingSubscription.unsubscribe(),this._changingSubscription=null)}render(e,t,i,n,r,s,a,o,h){if(!1===t.visible)return tf.h("div.mapillary-sequence-container",{},[]);const c=this._createStepper(e,t,a,i,o,h),l=this._createSequenceControls(i),u=this._createPlaybackControls(i,n,o,t),d=this._createTimelineControls(i,r,s);return tf.h("div.mapillary-sequence-container",[c,l,u,d])}getContainerWidth(e,t){let i=t.minWidth,n=t.maxWidth;n<i&&(n=i);let r=(e.width-this._minThresholdWidth)/(this._maxThresholdWidth-this._minThresholdWidth),s=(e.height-this._minThresholdHeight)/(this._maxThresholdHeight-this._minThresholdHeight);return i+Math.max(0,Math.min(1,Math.min(r,s)))*(n-i)}_createPositionInput(e,t){this._index=e;const i=e=>{this._index=Number(e.target.value),this._notifyIndexChanged$.next(this._index)},n=this._container.domContainer.getBoundingClientRect(),r=e=>{e.stopPropagation(),this._setChangingPosition(!0)},s=e=>{!0===this._changingPosition&&e.stopPropagation()},a={max:null!=t?t:1,min:0,onchange:i,oninput:i,onkeydown:e=>{"ArrowDown"!==e.key&&"ArrowLeft"!==e.key&&"ArrowRight"!==e.key&&"ArrowUp"!==e.key||e.preventDefault()},onpointerdown:r,onpointermove:s,ontouchmove:s,ontouchstart:r,style:{width:`${Math.max(276,Math.min(410,5+.8*n.width))-65}px`},type:"range",value:null!=e?e:0},o=null==e||null==t||t<=1;o&&(a.disabled="true");const h=tf.h("input.mapillary-sequence-position",a,[]),c=o?".mapillary-sequence-position-container-inactive":".mapillary-sequence-position-container";return tf.h("div"+c,[h])}_createSpeedInput(e){this._speed=e;const t=e=>{this._speed=Number(e.target.value)/1e3,this._notifySpeedChanged$.next(this._speed)},i=this._container.domContainer.getBoundingClientRect(),n=Math.max(276,Math.min(410,5+.8*i.width))-160,r=e=>{this._changingSpeed=!0,e.stopPropagation()},s=e=>{!0===this._changingSpeed&&e.stopPropagation()},a=tf.h("input.mapillary-sequence-speed",{max:1e3,min:0,onchange:t,oninput:t,onkeydown:e=>{"ArrowDown"!==e.key&&"ArrowLeft"!==e.key&&"ArrowRight"!==e.key&&"ArrowUp"!==e.key||e.preventDefault()},onpointerdown:r,onpointermove:s,ontouchmove:s,ontouchstart:r,style:{width:`${n}px`},type:"range",value:1e3*e},[]);return tf.h("div.mapillary-sequence-speed-container",[a])}_createPlaybackControls(t,i,n,r){if(this._mode!==$f.Playback)return tf.h("div.mapillary-sequence-playback",[]);const s=tf.h("div.mapillary-sequence-switch-icon.mapillary-sequence-icon-visible",[]),a=r.direction===e.NavigationDirection.Next?e.NavigationDirection.Prev:e.NavigationDirection.Next,o=r.playing,h={onclick:()=>{o||n.configure({direction:a})}},c=r.playing?".mapillary-sequence-switch-button-inactive":".mapillary-sequence-switch-button",l=tf.h("div"+c,h,[s]),u=tf.h("div.mapillary-sequence-slow-icon.mapillary-sequence-icon-visible",[]),d=tf.h("div.mapillary-sequence-slow-container",[u]),p=tf.h("div.mapillary-sequence-fast-icon.mapillary-sequence-icon-visible",[]),m=tf.h("div.mapillary-sequence-fast-container",[p]),f=tf.h("div.mapillary-sequence-close-icon.mapillary-sequence-icon-visible",[]),g={onclick:()=>{this._mode=$f.Default,this._notifyChanged$.next(this)}},_=tf.h("div.mapillary-sequence-close-button",g,[f]),v=[l,d,this._createSpeedInput(i),m,_],y={style:{top:`${Math.round(t/this._stepperDefaultWidth*this._defaultHeight+10)}px`}};return tf.h("div.mapillary-sequence-playback",y,v)}_createPlayingButton(t,i,n,r,s){let a=r.direction===e.NavigationDirection.Next&&null!=t||r.direction===e.NavigationDirection.Prev&&null!=i;a=a&&n;let o={onclick:r.playing?()=>{s.stop()}:a?()=>{s.play()}:null},h={};r.direction===e.NavigationDirection.Prev&&(h.style={transform:"rotate(180deg) translate(50%, 50%)"});let c=tf.h("div.mapillary-sequence-icon",h,[]),l=r.playing?"mapillary-sequence-stop":a?"mapillary-sequence-play":"mapillary-sequence-play-inactive";return tf.h("div."+l,o,[c])}_createSequenceControls(e){const t=Math.round(8/this._stepperDefaultWidth*e),i={onclick:()=>{this._expandControls=!this._expandControls,this._mode=$f.Default,this._notifyChanged$.next(this)},style:{"border-bottom-right-radius":`${t}px`,"border-top-right-radius":`${t}px`}},n=tf.h("div.mapillary-sequence-expander-bar",[]),r=tf.h("div.mapillary-sequence-expander-button",i,[n]),s=this._mode===$f.Playback?".mapillary-sequence-fast-icon-gray.mapillary-sequence-icon-visible":".mapillary-sequence-fast-icon",a=tf.h("div"+s,[]),o={onclick:()=>{this._mode=this._mode===$f.Playback?$f.Default:$f.Playback,this._notifyChanged$.next(this)}},h=tf.h("div.mapillary-sequence-playback-button",o,[a]),c=this._mode===$f.Timeline?".mapillary-sequence-timeline-icon-gray.mapillary-sequence-icon-visible":".mapillary-sequence-timeline-icon",l=tf.h("div"+c,[]),u={onclick:()=>{this._mode=this._mode===$f.Timeline?$f.Default:$f.Timeline,this._notifyChanged$.next(this)}},d=tf.h("div.mapillary-sequence-timeline-button",u,[l]),p={style:{height:this._defaultHeight/this._stepperDefaultWidth*e+"px",transform:`translate(${e/2+2}px, 0)`,width:this._controlsDefaultWidth/this._stepperDefaultWidth*e+"px"}},m=".mapillary-sequence-controls"+(this._expandControls?".mapillary-sequence-controls-expanded":"");return tf.h("div"+m,p,[h,d,r])}_createSequenceArrows(t,i,n,r,s){let a={onclick:null!=t?()=>{s.moveDir$(e.NavigationDirection.Next).subscribe(void 0,(e=>{e instanceof uf||console.error(e)}))}:null,onpointerenter:()=>{this._mouseEnterDirection$.next(e.NavigationDirection.Next)},onpointerleave:()=>{this._mouseLeaveDirection$.next(e.NavigationDirection.Next)}};const o=Math.round(8/this._stepperDefaultWidth*n);let h={onclick:null!=i?()=>{s.moveDir$(e.NavigationDirection.Prev).subscribe(void 0,(e=>{e instanceof uf||console.error(e)}))}:null,onpointerenter:()=>{this._mouseEnterDirection$.next(e.NavigationDirection.Prev)},onpointerleave:()=>{this._mouseLeaveDirection$.next(e.NavigationDirection.Prev)},style:{"border-bottom-left-radius":`${o}px`,"border-top-left-radius":`${o}px`}},c=this._getStepClassName(e.NavigationDirection.Next,t,r.highlightId),l=this._getStepClassName(e.NavigationDirection.Prev,i,r.highlightId),u=tf.h("div.mapillary-sequence-icon",[]),d=tf.h("div.mapillary-sequence-icon",[]);return[tf.h("div."+l,h,[d]),tf.h("div."+c,a,[u])]}_createStepper(t,i,n,r,s,a){let o=null,h=null;for(let i of t.edges)i.data.direction===e.NavigationDirection.Next&&(o=i.target),i.data.direction===e.NavigationDirection.Prev&&(h=i.target);const c=this._createPlayingButton(o,h,n,i,s),l=this._createSequenceArrows(o,h,r,i,a);l.splice(1,0,c);const u={oncontextmenu:e=>{e.preventDefault()},style:{height:this._defaultHeight/this._stepperDefaultWidth*r+"px",width:r+"px"}};return tf.h("div.mapillary-sequence-stepper",u,l)}_createTimelineControls(e,t,i){if(this._mode!==$f.Timeline)return tf.h("div.mapillary-sequence-timeline",[]);const n=this._createPositionInput(t,i),r=tf.h("div.mapillary-sequence-close-icon.mapillary-sequence-icon-visible",[]),s={onclick:()=>{this._mode=$f.Default,this._notifyChanged$.next(this)}},a=tf.h("div.mapillary-sequence-close-button",s,[r]),o={style:{top:`${Math.round(e/this._stepperDefaultWidth*this._defaultHeight+10)}px`}};return tf.h("div.mapillary-sequence-timeline",o,[n,a])}_getStepClassName(t,i,n){let r=t===e.NavigationDirection.Next?"mapillary-sequence-step-next":"mapillary-sequence-step-prev";return null==i?r+="-inactive":n===i&&(r+="-highlight"),r}_setChangingPosition(e){this._changingPosition=e,this._notifyChangingPositionChanged$.next(e)}}class lg extends sf{constructor(e,t,i,n,r){super(e,t,i),this._sequenceDOMRenderer=n||new cg(t),this._scheduler=r,this._containerWidth$=new j,this._hoveredIdSubject$=new j,this._hoveredId$=this._hoveredIdSubject$.pipe(Dt()),this._navigator.playService.playing$.pipe($t(1),Vt(this._configuration$)).subscribe((([e,t])=>{const i="playing",n={playing:e,target:this,type:i};this.fire(i,n),e!==t.playing&&(e?this.play():this.stop())})),this._navigator.playService.direction$.pipe($t(1),Vt(this._configuration$)).subscribe((([e,t])=>{e!==t.direction&&this.configure({direction:e})}))}fire(e,t){super.fire(e,t)}off(e,t){super.off(e,t)}on(e,t){super.on(e,t)}play(){this.configure({playing:!0})}stop(){this.configure({playing:!1})}_activate(){this._sequenceDOMRenderer.activate();const e=this._navigator.stateService.currentImage$.pipe(zt((e=>e.sequenceEdges$)),Rt(1),U()),t=this._navigator.stateService.currentImage$.pipe(vt(void 0,(e=>e.sequenceId)),zt((e=>Ze(Ce(null),this._navigator.graphService.cacheSequence$(e.sequenceId).pipe(Pt(3),ct((e=>(console.error("Failed to cache sequence",e),Ce(null)))))))),Ot(null),Rt(1),U()),i=this._subscriptions;i.push(t.subscribe());const n=this._sequenceDOMRenderer.index$.pipe(Vt(t),De((([e,t])=>null!=t?t.imageIds[e]:null)),st((e=>!!e)),vt(),It(),U());i.push(it(n.pipe(ft(100,this._scheduler)),n.pipe(ot(400,this._scheduler))).pipe(vt(),zt((e=>this._navigator.moveTo$(e).pipe(ct((()=>ie())))))).subscribe()),i.push(this._sequenceDOMRenderer.changingPositionChanged$.pipe(st((e=>e))).subscribe((()=>{this._navigator.graphService.setGraphMode(Nf.Sequence)}))),i.push(this._sequenceDOMRenderer.changingPositionChanged$.pipe(st((e=>!e))).subscribe((()=>{this._navigator.graphService.setGraphMode(Nf.Spatial)}))),this._navigator.graphService.graphMode$.pipe(zt((e=>e===Nf.Spatial?this._navigator.stateService.currentImage$.pipe(_t(2)):ie())),st((e=>!e.spatialEdges.cached)),zt((e=>this._navigator.graphService.cacheImage$(e.id).pipe(ct((()=>ie())))))).subscribe(),i.push(this._sequenceDOMRenderer.changingPositionChanged$.pipe(st((e=>e))).subscribe((()=>{this._navigator.playService.stop()}))),i.push(Ve(this._navigator.graphService.graphMode$,this._sequenceDOMRenderer.changingPositionChanged$.pipe(Ot(!1),vt())).pipe(Vt(this._navigator.stateService.currentImage$),zt((([[e,t],i])=>t&&e===Nf.Sequence?this._navigator.graphService.cacheSequenceImages$(i.sequenceId,i.id).pipe(Pt(3),ct((e=>(console.error("Failed to cache sequence images.",e),ie())))):ie()))).subscribe());const r=t.pipe(zt((e=>{if(!e)return Ce({index:null,max:null});let t=!0;return this._sequenceDOMRenderer.changingPositionChanged$.pipe(Ot(!1),vt(),zt((e=>{const i=!e&&t?0:1;return t=!1,e?n:this._navigator.stateService.currentImage$.pipe(De((e=>e.id)),vt(),$t(i))})),De((t=>{const i=e.imageIds.indexOf(t);return-1===i?{index:null,max:null}:{index:i,max:e.imageIds.length-1}})))}))),s=this._navigator.stateService.state$.pipe(De((e=>e===Df.Earth)),vt());i.push(Ve(e,this._configuration$,this._containerWidth$,this._sequenceDOMRenderer.changed$.pipe(Ot(this._sequenceDOMRenderer)),this._navigator.playService.speed$,r,s).pipe(De((([e,t,i,,n,r,s])=>{const a=this._sequenceDOMRenderer.render(e,t,i,n,r.index,r.max,!s,this,this._navigator);return{name:this._name,vNode:a}}))).subscribe(this._container.domRenderer.render$)),i.push(this._sequenceDOMRenderer.speed$.subscribe((e=>{this._navigator.playService.setSpeed(e)}))),i.push(this._configuration$.pipe(De((e=>e.direction)),vt()).subscribe((e=>{this._navigator.playService.setDirection(e)}))),i.push(Ve(this._container.renderService.size$,this._configuration$.pipe(vt(((e,t)=>e[0]===t[0]&&e[1]===t[1]),(e=>[e.minWidth,e.maxWidth])))).pipe(De((([e,t])=>this._sequenceDOMRenderer.getContainerWidth(e,t)))).subscribe(this._containerWidth$)),i.push(this._configuration$.pipe(De((e=>e.playing)),vt()).subscribe((e=>{e?this._navigator.playService.play():this._navigator.playService.stop()}))),i.push(this._sequenceDOMRenderer.mouseEnterDirection$.pipe(zt((t=>Ze(e.pipe(De((e=>{for(let i of e.edges)if(i.data.direction===t)return i.target;return null})),Ft(this._sequenceDOMRenderer.mouseLeaveDirection$)),Ce(null)))),vt()).subscribe(this._hoveredIdSubject$)),i.push(this._hoveredId$.subscribe((e=>{const t="hover",i={id:e,target:this,type:t};this.fire(t,i)})))}_deactivate(){this._subscriptions.unsubscribe(),this._sequenceDOMRenderer.deactivate()}_getDefaultConfiguration(){return{direction:e.NavigationDirection.Next,maxWidth:108,minWidth:70,playing:!1,visible:!0}}}lg.componentName="sequence",e.SliderConfigurationMode=void 0,(kf=e.SliderConfigurationMode||(e.SliderConfigurationMode={}))[kf.Motion=0]="Motion",kf[kf.Stationary=1]="Stationary";class ug{constructor(e,t,i,n,r,s,a,o,h,c){this._orientation=this._getValue(e,1);let l=null!=a?a.width:4,u=null!=a?a.height:3,d=this._orientation<5;this._width=this._getValue(t,d?l:u),this._height=this._getValue(i,d?u:l),this._basicAspect=d?this._width/this._height:this._height/this._width,this._basicWidth=d?t:i,this._basicHeight=d?i:t;const p=this._getCameraParameters(h,c),m=p[0],f=p[1],g=p[2];this._focal=this._getValue(m,1),this._scale=this._getValue(n,0),this._worldToCamera=this.createWorldToCamera(r,s),this._worldToCameraInverse=(new Rn).copy(this._worldToCamera).invert(),this._scaledWorldToCamera=this._createScaledWorldToCamera(this._worldToCamera,this._scale),this._scaledWorldToCameraInverse=(new Rn).copy(this._scaledWorldToCamera).invert(),this._basicWorldToCamera=this._createBasicWorldToCamera(this._worldToCamera,e),this._textureScale=o||[1,1],this._ck1=f||0,this._ck2=g||0,this._cameraType=c||"perspective",this._radialPeak=this._getRadialPeak(this._ck1,this._ck2)}get ck1(){return this._ck1}get ck2(){return this._ck2}get cameraType(){return this._cameraType}get basicAspect(){return this._basicAspect}get basicHeight(){return this._basicHeight}get basicRt(){return this._basicWorldToCamera}get basicWidth(){return this._basicWidth}get focal(){return this._focal}get height(){return this._height}get orientation(){return this._orientation}get rt(){return this._worldToCamera}get srt(){return this._scaledWorldToCamera}get srtInverse(){return this._scaledWorldToCameraInverse}get scale(){return this._scale}get hasValidScale(){return this._scale>.01&&this._scale<50}get radialPeak(){return this._radialPeak}get width(){return this._width}upVector(){let e=this._worldToCamera.elements;switch(this._orientation){case 1:return new Ki(-e[1],-e[5],-e[9]);case 3:return new Ki(e[1],e[5],e[9]);case 6:return new Ki(-e[0],-e[4],-e[8]);case 8:return new Ki(e[0],e[4],e[8]);default:return new Ki(-e[1],-e[5],-e[9])}}projectorMatrix(){let e=this._normalizedToTextureMatrix(),t=this._focal,i=(new Rn).set(t,0,0,0,0,t,0,0,0,0,0,0,0,0,1,0);return e.multiply(i),e.multiply(this._worldToCamera),e}projectBasic(e){let t=this.projectSfM(e);return this._sfmToBasic(t)}unprojectBasic(e,t,i){let n=this._basicToSfm(e);return this.unprojectSfM(n,t,i)}projectSfM(e){let t=new Xi(e[0],e[1],e[2],1);return t.applyMatrix4(this._worldToCamera),this._bearingToSfm([t.x,t.y,t.z])}unprojectSfM(e,t,i){const n=this._sfmToBearing(e),r=(i&&!$u(this._cameraType)?new Xi(t*n[0]/n[2],t*n[1]/n[2],t,1):new Xi(t*n[0],t*n[1],t*n[2],1)).applyMatrix4(this._worldToCameraInverse);return[r.x/r.w,r.y/r.w,r.z/r.w]}_sfmToBearing(e){if($u(this._cameraType)){let t=2*e[0]*Math.PI,i=2*-e[1]*Math.PI;return[Math.cos(i)*Math.sin(t),-Math.sin(i),Math.cos(i)*Math.cos(t)]}if(ku(this._cameraType)){let[t,i]=[e[0]/this._focal,e[1]/this._focal];const n=Math.sqrt(t*t+i*i);let r=n/this._distortionFromDistortedRadius(n,this._ck1,this._ck2,this._radialPeak),s=Math.cos(r),a=Math.sin(r);const o=n>1e-8?1/n:1;return[a*t*o,a*i*o,s]}{let[t,i]=[e[0]/this._focal,e[1]/this._focal];const n=Math.sqrt(t*t+i*i);let r=this._distortionFromDistortedRadius(n,this._ck1,this._ck2,this._radialPeak);let s=new Ki(t/r,i/r,1);return s.normalize(),[s.x,s.y,s.z]}}_distortionFromDistortedRadius(e,t,i,n){let r=1;for(let s=0;s<10;s++){let s=e/r;s>n&&(s=n),r=1+t*Math.pow(s,2)+i*Math.pow(s,4)}return r}_bearingToSfm(e){if($u(this._cameraType)){let t=e[0],i=e[1],n=e[2],r=Math.atan2(t,n),s=Math.atan2(-i,Math.sqrt(t*t+n*n));return[r/(2*Math.PI),-s/(2*Math.PI)]}if(ku(this._cameraType)){if(e[2]>0){const[t,i,n]=e,r=Math.sqrt(t*t+i*i);let s=Math.atan2(r,n);s>this._radialPeak&&(s=this._radialPeak);const a=1+Math.pow(s,2)*(this._ck1+Math.pow(s,2)*this._ck2),o=this._focal*a*s/r;return[o*t,o*i]}return[e[0]<0?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,e[1]<0?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY]}if(e[2]>0){let[t,i]=[e[0]/e[2],e[1]/e[2]],n=t*t+i*i;const r=Math.pow(this._radialPeak,2);n>r&&(n=r);const s=1+this._ck1*n+this._ck2*Math.pow(n,2);return[this._focal*s*t,this._focal*s*i]}return[e[0]<0?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,e[1]<0?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY]}_basicToSfm(e){let t,i;switch(this._orientation){case 1:t=e[0],i=e[1];break;case 3:t=1-e[0],i=1-e[1];break;case 6:t=e[1],i=1-e[0];break;case 8:t=1-e[1],i=e[0];break;default:t=e[0],i=e[1]}let n=this._width,r=this._height,s=Math.max(n,r);return[t*n/s-n/s/2,i*r/s-r/s/2]}_sfmToBasic(e){let t,i,n=this._width,r=this._height,s=Math.max(n,r),a=(e[0]+n/s/2)/n*s,o=(e[1]+r/s/2)/r*s;switch(this._orientation){case 1:t=a,i=o;break;case 3:t=1-a,i=1-o;break;case 6:t=1-o,i=a;break;case 8:t=o,i=1-a;break;default:t=a,i=o}return[t,i]}_getValue(e,t){return null!=e&&e>0?e:t}_getCameraParameters(e,t){if($u(t))return[];if(!e||0===e.length)return[1,0,0];const i=3-e.length;return i<=0?e:e.concat(new Array(i).fill(0))}createWorldToCamera(e,t){const i=new Ki(e[0],e[1],e[2]),n=i.length();n>0&&i.normalize();const r=new Rn;return r.makeRotationAxis(i,n),r.setPosition(new Ki(t[0],t[1],t[2])),r}_createScaledWorldToCamera(e,t){const i=e.clone(),n=i.elements;return n[12]=t*n[12],n[13]=t*n[13],n[14]=t*n[14],i.scale(new Ki(t,t,t)),i}_createBasicWorldToCamera(e,t){const i=new Ki(0,0,1);let n=0;switch(t){case 3:n=Math.PI;break;case 6:n=Math.PI/2;break;case 8:n=3*Math.PI/2}return(new Rn).makeRotationAxis(i,n).multiply(e)}_getRadialPeak(e,t){const i=5*t,n=3*e,r=Math.pow(n,2)-4*i*1;if(r<0)return;const s=(-n-Math.sqrt(r))/2/i,a=(-n+Math.sqrt(r))/2/i,o=Math.min(s,a),h=Math.max(s,a);return o>0?Math.sqrt(o):h>0?Math.sqrt(h):void 0}_normalizedToTextureMatrix(){const e=Math.max(this._width,this._height),t=this._orientation<5?this._textureScale[0]:this._textureScale[1],i=this._orientation<5?this._textureScale[1]:this._textureScale[0],n=e/this._width*t,r=e/this._height*i;switch(this._orientation){case 1:return(new Rn).set(n,0,0,.5,0,-r,0,.5,0,0,1,0,0,0,0,1);case 3:return(new Rn).set(-n,0,0,.5,0,r,0,.5,0,0,1,0,0,0,0,1);case 6:return(new Rn).set(0,-r,0,.5,-n,0,0,.5,0,0,1,0,0,0,0,1);case 8:return(new Rn).set(0,r,0,.5,n,0,0,.5,0,0,1,0,0,0,0,1);default:return(new Rn).set(n,0,0,.5,0,-r,0,.5,0,0,1,0,0,0,0,1)}}}class dg{constructor(){this._factory=new gf,this._scene=new _f,this._spatial=new Du,this._currentKey=null,this._previousKey=null,this._disabled=!1,this._curtain=1,this._frameId=0,this._needsRender=!1,this._mode=null,this._currentProviderDisposers={},this._previousProviderDisposers={}}get disabled(){return this._disabled}get frameId(){return this._frameId}get needsRender(){return this._needsRender}setTextureProvider(e,t){this._setTextureProvider(e,this._currentKey,t,this._currentProviderDisposers,this._updateTexture.bind(this))}setTextureProviderPrev(e,t){this._setTextureProvider(e,this._previousKey,t,this._previousProviderDisposers,this._updateTexturePrev.bind(this))}update(e,t){this._updateFrameId(e.id),this._updateImagePlanes(e.state,t)}updateCurtain(e){this._curtain!==e&&(this._curtain=e,this._updateCurtain(),this._needsRender=!0)}updateTexture(e,t){const i=t.id===this._currentKey?this._scene.planes:t.id===this._previousKey?this._scene.planesOld:{};if(0!==Object.keys(i).length){this._needsRender=!0;for(const t in i){if(!i.hasOwnProperty(t))continue;let n=i[t].material.uniforms.projectorTex.value;n.image=e,n.needsUpdate=!0}}}updateTextureImage(e,t){if(this._currentKey!==t.id)return;this._needsRender=!0;const i=this._scene.planes;for(const t in i){if(!i.hasOwnProperty(t))continue;let n=i[t].material.uniforms.projectorTex.value;n.image=e,n.needsUpdate=!0}}render(e,t){this.disabled||t.render(this._scene.sceneOld,e),t.render(this._scene.scene,e),this._needsRender=!1}dispose(){this._scene.clear();for(const e in this._currentProviderDisposers)this._currentProviderDisposers.hasOwnProperty(e)&&this._currentProviderDisposers[e]();for(const e in this._previousProviderDisposers)this._previousProviderDisposers.hasOwnProperty(e)&&this._previousProviderDisposers[e]();this._currentProviderDisposers={},this._previousProviderDisposers={}}_getBasicCorners(e,t){let i,n;return e>t?(i=.5,n=.5*e/t):(i=.5*t/e,n=.5),[[.5-i,.5-n],[.5+i,.5+n]]}_setDisabled(e){this._disabled=null==e.currentImage||null==e.previousImage||$u(e.currentImage.cameraType)&&!$u(e.previousImage.cameraType)}_setTextureProvider(e,t,i,n,r){if(e!==t)return;let s=i.textureCreated$.subscribe(r),a=i.textureUpdated$.subscribe((e=>{this._needsRender=!0}));if(e in n){(0,n[e])(),delete n[e]}n[e]=()=>{s.unsubscribe(),a.unsubscribe(),i.dispose()}}_updateCurtain(){const e=this._scene.planes;for(const t in e){if(!e.hasOwnProperty(t))continue;let i=e[t].material;i.uniforms.curtain&&(i.uniforms.curtain.value=this._curtain)}}_updateFrameId(e){this._frameId=e}_updateImagePlanes(t,i){const n=null!=t.currentImage&&this._currentKey!==t.currentImage.id,r=null!=t.previousImage&&this._previousKey!==t.previousImage.id,s=this._mode!==i;if(!(n||r||s))return;this._setDisabled(t),this._needsRender=!0,this._mode=i;const a=t.motionless||i===e.SliderConfigurationMode.Stationary||$u(t.currentImage.cameraType);if((this.disabled||r)&&this._previousKey in this._previousProviderDisposers&&(this._previousProviderDisposers[this._previousKey](),delete this._previousProviderDisposers[this._previousKey]),this.disabled)this._scene.setImagePlanesOld({});else if(r||s){const e=t.previousImage;this._previousKey=e.id;const i=t.currentTransform.rt.elements;let n=[i[12],i[13],i[14]];const r=t.currentTransform.basicAspect,s=t.previousTransform.basicAspect,o=r>s?[1,s/r]:[r/s,1];let h=t.currentImage.rotation,c=t.currentImage.width,l=t.currentImage.height;$u(e.cameraType)&&(h=t.previousImage.rotation,n=this._spatial.rotate(this._spatial.opticalCenter(t.currentImage.rotation,n).toArray(),h).multiplyScalar(-1).toArray(),c=t.previousImage.width,l=t.previousImage.height);const u=new ug(t.currentImage.exifOrientation,c,l,t.currentImage.scale,h,n,e.image,o,t.currentImage.cameraParameters,t.currentImage.cameraType);let d;if($u(e.cameraType))d=this._factory.createMesh(e,a||$u(t.currentImage.cameraType)?u:t.previousTransform);else if(a){const[[e,i],[n,a]]=this._getBasicCorners(r,s);d=this._factory.createFlatMesh(t.previousImage,u,e,n,i,a)}else d=this._factory.createMesh(t.previousImage,t.previousTransform);const p={};p[e.id]=d,this._scene.setImagePlanesOld(p)}if(n||s){this._currentKey in this._currentProviderDisposers&&(this._currentProviderDisposers[this._currentKey](),delete this._currentProviderDisposers[this._currentKey]),this._currentKey=t.currentImage.id;const e={};$u(t.currentImage.cameraType)?e[t.currentImage.id]=this._factory.createCurtainMesh(t.currentImage,t.currentTransform):e[t.currentImage.id]=a?this._factory.createDistortedCurtainMesh(t.currentImage,t.currentTransform):this._factory.createCurtainMesh(t.currentImage,t.currentTransform),this._scene.setImagePlanes(e),this._updateCurtain()}}_updateTexture(e){this._needsRender=!0;const t=this._scene.planes;for(const i in t){if(!t.hasOwnProperty(i))continue;let n=t[i].material,r=n.uniforms.projectorTex.value;n.uniforms.projectorTex.value=null,r.dispose(),n.uniforms.projectorTex.value=e}}_updateTexturePrev(e){this._needsRender=!0;const t=this._scene.planesOld;for(const i in t){if(!t.hasOwnProperty(i))continue;let n=t[i].material,r=n.uniforms.projectorTex.value;n.uniforms.projectorTex.value=null,r.dispose(),n.uniforms.projectorTex.value=e}}}class pg{constructor(e){this._container=e,this._interacting=!1,this._notifyModeChanged$=new j,this._notifyPositionChanged$=new j,this._stopInteractionSubscription=null}get mode$(){return this._notifyModeChanged$}get position$(){return this._notifyPositionChanged$}activate(){this._stopInteractionSubscription||(this._stopInteractionSubscription=it(this._container.mouseService.documentMouseUp$,this._container.touchService.touchEnd$.pipe(st((e=>0===e.touches.length)))).subscribe((e=>{this._interacting&&(this._interacting=!1)})))}deactivate(){this._stopInteractionSubscription&&(this._interacting=!1,this._stopInteractionSubscription.unsubscribe(),this._stopInteractionSubscription=null)}render(e,t,i,n,r){const s=[];if(r){s.push(tf.h("div.mapillary-slider-border",[]));const r=!(i||n);r&&(s.push(this._createModeButton(t)),s.push(this._createModeButton2d(t))),s.push(this._createPositionInput(e,r))}const a=this._container.domContainer.getBoundingClientRect(),o=Math.max(215,Math.min(400,a.width-100));return tf.h("div.mapillary-slider-container",{style:{width:`${o}px`}},s)}_createModeButton(t){const i={onclick:()=>{t!==e.SliderConfigurationMode.Motion&&this._notifyModeChanged$.next(e.SliderConfigurationMode.Motion)}},n=t===e.SliderConfigurationMode.Stationary?"mapillary-slider-mode-button-inactive":"mapillary-slider-mode-button";return tf.h("div."+n,i,[tf.h("div.mapillary-slider-mode-icon",[])])}_createModeButton2d(t){const i={onclick:()=>{t!==e.SliderConfigurationMode.Stationary&&this._notifyModeChanged$.next(e.SliderConfigurationMode.Stationary)}},n=t===e.SliderConfigurationMode.Motion?"mapillary-slider-mode-button-2d-inactive":"mapillary-slider-mode-button-2d";return tf.h("div."+n,i,[tf.h("div.mapillary-slider-mode-icon-2d",[])])}_createPositionInput(e,t){const i=e=>{this._notifyPositionChanged$.next(Number(e.target.value)/1e3)},n=e=>{this._interacting=!0,e.stopPropagation()},r=e=>{this._interacting&&e.stopPropagation()},s=this._container.domContainer.getBoundingClientRect(),a=Math.max(215,Math.min(400,s.width-105))-84+(t?0:52),o=tf.h("input.mapillary-slider-position",{max:1e3,min:0,onchange:i,oninput:i,onkeydown:e=>{"ArrowDown"!==e.key&&"ArrowLeft"!==e.key&&"ArrowRight"!==e.key&&"ArrowUp"!==e.key||e.preventDefault()},onpointerdown:n,onpointermove:r,ontouchmove:r,ontouchstart:n,style:{width:`${a}px`},type:"range",value:1e3*e},[]);return tf.h("div.mapillary-slider-position-container",[o])}}class mg extends sf{constructor(e,t,i,n){super(e,t,i),this._viewportCoords=n||new hf,this._domRenderer=new pg(t),this._imageTileLoader=new bf(i.api),this._roiCalculator=new wf,this._spatial=new Du,this._glRendererOperation$=new j,this._glRendererCreator$=new j,this._glRendererDisposer$=new j,this._glRenderer$=this._glRendererOperation$.pipe(Lt(((e,t)=>t(e)),null),st((e=>null!=e)),vt(void 0,(e=>e.frameId))),this._glRendererCreator$.pipe(De((()=>e=>{if(null!=e)throw new Error("Multiple slider states can not be created at the same time");return new dg}))).subscribe(this._glRendererOperation$),this._glRendererDisposer$.pipe(De((()=>e=>(e.dispose(),null)))).subscribe(this._glRendererOperation$)}_activate(){const t=this._subscriptions;t.push(this._domRenderer.mode$.subscribe((e=>{this.configure({mode:e})}))),t.push(this._glRenderer$.pipe(De((e=>({name:this._name,renderer:{frameId:e.frameId,needsRender:e.needsRender,render:e.render.bind(e),pass:yf.Background}})))).subscribe(this._container.glRenderer.render$));const i=Ze(this.configuration$.pipe(De((e=>null!=e.initialPosition?e.initialPosition:1)),St()),this._domRenderer.position$),n=this.configuration$.pipe(De((e=>e.mode)),vt()),r=this._navigator.stateService.currentState$.pipe(De((e=>e.state.motionless)),vt()),s=this._navigator.stateService.currentState$.pipe(De((e=>$u(e.state.currentImage.cameraType))),vt()),a=Ve(this._configuration$.pipe(De((e=>e.sliderVisible))),this._navigator.stateService.currentState$.pipe(De((e=>!(null==e.state.currentImage||null==e.state.previousImage||$u(e.state.currentImage.cameraType)&&!$u(e.state.previousImage.cameraType)))),vt())).pipe(De((([e,t])=>e&&t)),vt());this._waitSubscription=Ve(n,r,s,a).pipe(Vt(this._navigator.stateService.state$)).subscribe((([[t,i,n,r],s])=>{const a=r&&(i||t===e.SliderConfigurationMode.Stationary||n);a&&s!==Df.WaitingInteractively?this._navigator.stateService.waitInteractively():a||s===Df.Waiting||this._navigator.stateService.wait()})),t.push(Ve(i,n,r,s,a).subscribe((([t,i,n,r])=>{n||i===e.SliderConfigurationMode.Stationary||r?this._navigator.stateService.moveTo(1):this._navigator.stateService.moveTo(t)}))),t.push(Ve(i,n,r,s,a,this._container.renderService.size$).pipe(De((([e,t,i,n,r])=>({name:this._name,vNode:this._domRenderer.render(e,t,i,n,r)})))).subscribe(this._container.domRenderer.render$)),this._glRendererCreator$.next(null),t.push(Ve(i,s,a,this._container.renderService.renderCamera$,this._navigator.stateService.currentTransform$).pipe(De((([e,t,i,n,r])=>{if(!t)return i?e:1;const s=this._viewportCoords.viewportToBasic(-1.15,0,r,n.perspective),a=this._viewportCoords.viewportToBasic(1.15,0,r,n.perspective),o=a[0]<s[0]?a[0]+1:a[0],h=s[0]+e*(o-s[0]);return h>1?h-1:h})),De((e=>t=>(t.updateCurtain(e),t)))).subscribe(this._glRendererOperation$)),t.push(Ve(this._navigator.stateService.currentState$,n).pipe(De((([e,t])=>i=>(i.update(e,t),i)))).subscribe(this._glRendererOperation$)),t.push(this._configuration$.pipe(st((e=>null!=e.ids)),zt((e=>at(at(this._catchCacheImage$(e.ids.background),this._catchCacheImage$(e.ids.foreground)).pipe(De((e=>({background:e[0],foreground:e[1]})))),this._navigator.stateService.currentState$.pipe(St())).pipe(De((e=>({images:e[0],state:e[1].state}))))))).subscribe((e=>{null!=e.state.currentImage&&null!=e.state.previousImage&&e.state.currentImage.id===e.images.foreground.id&&e.state.previousImage.id===e.images.background.id||(e.state.currentImage.id!==e.images.background.id?e.state.currentImage.id!==e.images.foreground.id||1!==e.state.trajectory.length?(this._navigator.stateService.setImages([e.images.background]),this._navigator.stateService.setImages([e.images.foreground])):this._navigator.stateService.prependImages([e.images.background]):this._navigator.stateService.setImages([e.images.foreground]))}),(e=>{console.error(e)})));const o=this._container.configurationService.imageTiling$.pipe(zt((e=>e?this._navigator.stateService.currentState$:new j)),vt(void 0,(e=>e.state.currentImage.id)),Vt(this._container.glRenderer.webGLRenderer$,this._container.renderService.size$),De((([e,t,i])=>{const n=e.state;Math.max(i.width,i.height);const r=n.currentImage,s=n.currentTransform;return new Lf(r.id,s.basicWidth,s.basicHeight,r.image,this._imageTileLoader,new xf,t)})),Rt(1),U());t.push(o.subscribe((()=>{}))),t.push(o.pipe(De((e=>t=>(t.setTextureProvider(e.id,e),t)))).subscribe(this._glRendererOperation$)),t.push(o.pipe(At()).subscribe((e=>{e[0].abort()})));const h=this._container.configurationService.imageTiling$.pipe(zt((e=>e?Ve(this._container.renderService.renderCameraFrame$,this._container.renderService.size$.pipe(ft(250))):new j)),De((([e,t])=>[e.camera.position.clone(),e.camera.lookat.clone(),e.zoom.valueOf(),t.height.valueOf(),t.width.valueOf()])),At(),kt((e=>e[1][2]-e[0][2]<0||0===e[1][2])),De((e=>{let t=e[0][0].equals(e[1][0]),i=e[0][1].equals(e[1][1]),n=e[0][2]===e[1][2],r=e[0][3]===e[1][3],s=e[0][4]===e[1][4];return t&&i&&n&&r&&s})),vt(),st((e=>e)),zt((()=>this._container.renderService.renderCameraFrame$.pipe(St()))),Vt(this._container.renderService.size$,this._navigator.stateService.currentTransform$));t.push(o.pipe(zt((e=>h.pipe(De((([t,i,n])=>[this._roiCalculator.computeRegionOfInterest(t,i,n),e]))))),st((e=>!e[1].disposed))).subscribe((e=>{let t=e[0];e[1].setRegionOfInterest(t)})));const c=o.pipe(zt((e=>e.hasTexture$)),Ot(!1),Rt(1),U());t.push(c.subscribe((()=>{})));const l=this._container.configurationService.imageTiling$.pipe(zt((e=>e?this._navigator.stateService.currentState$:new j)),st((e=>!!e.state.previousImage)),vt(void 0,(e=>e.state.previousImage.id)),Vt(this._container.glRenderer.webGLRenderer$,this._container.renderService.size$),De((([e,t,i])=>{const n=e.state,r=n.previousImage,s=n.previousTransform;return new Lf(r.id,s.basicWidth,s.basicHeight,r.image,this._imageTileLoader,new xf,t)})),Rt(1),U());t.push(l.subscribe((()=>{}))),t.push(l.pipe(De((e=>t=>(t.setTextureProviderPrev(e.id,e),t)))).subscribe(this._glRendererOperation$)),t.push(l.pipe(At()).subscribe((e=>{e[0].abort()})));const u=this._container.configurationService.imageTiling$.pipe(zt((e=>e?Ve(this._container.renderService.renderCameraFrame$,this._container.renderService.size$.pipe(ft(250))):new j)),De((([e,t])=>[e.camera.position.clone(),e.camera.lookat.clone(),e.zoom.valueOf(),t.height.valueOf(),t.width.valueOf()])),At(),kt((e=>e[1][2]-e[0][2]<0||0===e[1][2])),De((e=>{let t=e[0][0].equals(e[1][0]),i=e[0][1].equals(e[1][1]),n=e[0][2]===e[1][2],r=e[0][3]===e[1][3],s=e[0][4]===e[1][4];return t&&i&&n&&r&&s})),vt(),st((e=>e)),zt((()=>this._container.renderService.renderCameraFrame$.pipe(St()))),Vt(this._container.renderService.size$,this._navigator.stateService.currentTransform$));t.push(l.pipe(zt((e=>u.pipe(De((([t,i,n])=>[this._roiCalculator.computeRegionOfInterest(t,i,n),e]))))),st((e=>!e[1].disposed)),Vt(this._navigator.stateService.currentState$)).subscribe((([[e,t],i])=>{let n=null;if($u(i.state.previousImage.cameraType))if($u(i.state.currentImage.cameraType)){const t=this._spatial.viewingDirection(i.state.currentImage.rotation),r=this._spatial.viewingDirection(i.state.previousImage.rotation),s=this._spatial.angleBetweenVector2(t.x,t.y,r.x,r.y)/(2*Math.PI);n={bbox:{maxX:this._spatial.wrap(e.bbox.maxX+s,0,1),maxY:e.bbox.maxY,minX:this._spatial.wrap(e.bbox.minX+s,0,1),minY:e.bbox.minY},pixelHeight:e.pixelHeight,pixelWidth:e.pixelWidth}}else{const t=this._spatial.viewingDirection(i.state.currentImage.rotation),r=this._spatial.viewingDirection(i.state.previousImage.rotation),s=this._spatial.angleBetweenVector2(t.x,t.y,r.x,r.y)/(2*Math.PI),a=this._spatial.angleToPlane(t.toArray(),[0,0,1]),o=(this._spatial.angleToPlane(r.toArray(),[0,0,1])-a)/(2*Math.PI),h=i.state.currentTransform,c=Math.max(h.basicWidth,h.basicHeight),l=c>0?2*Math.atan(.5*h.basicWidth/(c*h.focal)):Math.PI/3,u=c>0?2*Math.atan(.5*h.basicHeight/(c*h.focal)):Math.PI/3,d=l/(2*Math.PI),p=u/Math.PI,m=(e.bbox.maxX-e.bbox.minX)*d,f=(e.bbox.maxY-e.bbox.minY)*p,g=e.pixelWidth*d,_=e.pixelHeight*p,v=(e.bbox.minX+e.bbox.maxX)/2-.5,y=(e.bbox.minY+e.bbox.maxY)/2-.5,b=.5+s+d*v-m/2,x=.5+s+d*v+m/2,w=.5+o+p*y-f/2,M=.5+o+p*y+f/2;n={bbox:{maxX:this._spatial.wrap(x,0,1),maxY:M,minX:this._spatial.wrap(b,0,1),minY:w},pixelHeight:_,pixelWidth:g}}else{const t=i.state.currentTransform.basicAspect,r=i.state.previousTransform.basicAspect,[[s,a],[o,h]]=this._getBasicCorners(t,r),c=o-s,l=h-a,u=e.pixelWidth/c,d=e.pixelHeight/l,p=(c-1)/(2*c)+e.bbox.minX/c,m=(c-1)/(2*c)+e.bbox.maxX/c,f=(l-1)/(2*l)+e.bbox.minY/l,g={maxX:m,maxY:(l-1)/(2*l)+e.bbox.maxY/l,minX:p,minY:f};this._clipBoundingBox(g),n={bbox:g,pixelHeight:d,pixelWidth:u}}t.setRegionOfInterest(n)})));const d=l.pipe(zt((e=>e.hasTexture$)),Ot(!1),Rt(1),U());t.push(d.subscribe((()=>{})))}_deactivate(){this._waitSubscription.unsubscribe(),this._navigator.stateService.state$.pipe(St()).subscribe((e=>{e!==Df.Traversing&&this._navigator.stateService.traverse()})),this._glRendererDisposer$.next(null),this._domRenderer.deactivate(),this._subscriptions.unsubscribe(),this.configure({ids:null})}_getDefaultConfiguration(){return{initialPosition:1,mode:e.SliderConfigurationMode.Motion,sliderVisible:!0}}_catchCacheImage$(e){return this._navigator.graphService.cacheImage$(e).pipe(ct((t=>(console.error(`Failed to cache slider image (${e})`,t),ie()))))}_getBasicCorners(e,t){let i,n;return e>t?(i=.5,n=.5*e/t):(i=.5*t/e,n=.5),[[.5-i,.5-n],[.5+i,.5+n]]}_clipBoundingBox(e){e.minX=Math.max(0,Math.min(1,e.minX)),e.maxX=Math.max(0,Math.min(1,e.maxX)),e.minY=Math.max(0,Math.min(1,e.minY)),e.maxY=Math.max(0,Math.min(1,e.maxY))}}mg.componentName="slider";class fg{constructor(t,i){this._subscriptions=new rf,this._graphService=t,this._stateService=i;const n=this._subscriptions;this._directionSubject$=new j,this._direction$=this._directionSubject$.pipe(Ot(e.NavigationDirection.Next),Rt(1),U()),n.push(this._direction$.subscribe()),this._playing=!1,this._playingSubject$=new j,this._playing$=this._playingSubject$.pipe(Ot(this._playing),Rt(1),U()),n.push(this._playing$.subscribe()),this._speed=.5,this._speedSubject$=new j,this._speed$=this._speedSubject$.pipe(Ot(this._speed),Rt(1),U()),n.push(this._speed$.subscribe()),this._imagesAhead=this._mapImagesAhead(this._mapSpeed(this._speed)),this._bridging$=null}get playing(){return this._playing}get direction$(){return this._direction$}get playing$(){return this._playing$}get speed$(){return this._speed$}play(){if(this._playing)return;this._stateService.cutImages();const t=this._setSpeed(this._speed);this._stateService.setSpeed(t),this._graphModeSubscription=this._speed$.pipe(De((e=>e>fg.sequenceSpeed?Nf.Sequence:Nf.Spatial)),vt()).subscribe((e=>{this._graphService.setGraphMode(e)})),this._cacheSubscription=Ve(this._stateService.currentImage$.pipe(De((e=>[e.sequenceId,e.id])),vt(void 0,(([e])=>e))),this._graphService.graphMode$,this._direction$).pipe(zt((([[t,i],n,r])=>{if(r!==e.NavigationDirection.Next&&r!==e.NavigationDirection.Prev)return Ce([void 0,r]);return Ve((n===Nf.Sequence?this._graphService.cacheSequenceImages$(t,i):this._graphService.cacheSequence$(t)).pipe(Pt(3),ct((e=>(console.error(e),Ce(void 0))))),Ce(r))})),zt((([t,i])=>{if(void 0===t)return ie();const n=t.imageIds.slice();return i===e.NavigationDirection.Prev&&n.reverse(),this._stateService.currentState$.pipe(De((e=>[e.state.trajectory[e.state.trajectory.length-1].id,e.state.imagesAhead])),Lt((([e,t],[i,r])=>{void 0===e&&(e=i);const s=n.length-1;if(r>=this._imagesAhead||n[s]===e)return[e,[]];const a=n.indexOf(i),o=n.indexOf(e)+1,h=Math.min(s,a+this._imagesAhead-r)+1;return h<=o?[e,[]]:[n[h-1],n.slice(o,h)]}),[void 0,[]]),We((([e,t])=>ge(t))))})),We((e=>this._graphService.cacheImage$(e).pipe(ct((()=>ie())))),6)).subscribe(),this._playingSubscription=this._stateService.currentState$.pipe(st((e=>e.state.imagesAhead<this._imagesAhead)),vt(void 0,(e=>e.state.lastImage.id)),De((e=>{const t=e.state.lastImage,i=e.state.trajectory;let n;for(let e=i.length-2;e>=0;e--){const r=i[e];if(r.sequenceId!==t.sequenceId)break;if(r.capturedAt!==t.capturedAt){n=r.capturedAt<t.capturedAt;break}}return[e.state.lastImage,n]})),Vt(this._direction$),zt((([[t,i],n])=>at(([e.NavigationDirection.Next,e.NavigationDirection.Prev].indexOf(n)>-1?t.sequenceEdges$:t.spatialEdges$).pipe(St((e=>e.cached)),Pe(15e3)),Ce(n)).pipe(De((([e,t])=>{for(let i of e.edges)if(i.data.direction===t)return i.target;return null})),zt((e=>null!=e?this._graphService.cacheImage$(e):ie())))))).subscribe((e=>{this._stateService.appendImagess([e])}),(e=>{console.error(e),this.stop()})),this._clearSubscription=this._stateService.currentImage$.pipe(ht(1,10)).subscribe((e=>{this._stateService.clearPriorImages()})),this._setPlaying(!0);const i=this._stateService.currentState$.pipe(De((e=>e.state)),vt((([e,t],[i,n])=>e===i&&t===n),(e=>[e.currentImage.id,e.lastImage.id])),st((e=>e.currentImage.id===e.lastImage.id&&e.currentIndex===e.trajectory.length-1)),De((e=>e.currentImage)));this._stopSubscription=Ve(i,this._direction$).pipe(zt((([t,i])=>{const n=([e.NavigationDirection.Next,e.NavigationDirection.Prev].indexOf(i)>-1?t.sequenceEdges$:t.spatialEdges$).pipe(St((e=>e.cached)),Pe(15e3),ct((e=>(console.error(e),Ce({cached:!1,edges:[]})))));return Ve(Ce(i),n).pipe(De((([e,t])=>{for(const i of t.edges)if(i.data.direction===e)return!0;return!1})))})),We((e=>e||!this._bridging$?Ce(e):this._bridging$.pipe(De((e=>null!=e)),ct((e=>(console.error(e),Ce(!1))))))),St((e=>!e))).subscribe(void 0,void 0,(()=>{this.stop()})),this._stopSubscription.closed&&(this._stopSubscription=null),this._earthSubscription=this._stateService.state$.pipe(De((e=>e===Df.Earth)),vt(),St((e=>e))).subscribe(void 0,void 0,(()=>{this.stop()})),this._earthSubscription.closed&&(this._earthSubscription=null)}dispose(){this.stop(),this._subscriptions.unsubscribe()}setDirection(e){this._directionSubject$.next(e)}setSpeed(e){if((e=Math.max(0,Math.min(1,e)))===this._speed)return;const t=this._setSpeed(e);this._playing&&this._stateService.setSpeed(t),this._speedSubject$.next(this._speed)}stop(){this._playing&&(this._stopSubscription&&(this._stopSubscription.closed||this._stopSubscription.unsubscribe(),this._stopSubscription=null),this._earthSubscription&&(this._earthSubscription.closed||this._earthSubscription.unsubscribe(),this._earthSubscription=null),this._graphModeSubscription.unsubscribe(),this._graphModeSubscription=null,this._cacheSubscription.unsubscribe(),this._cacheSubscription=null,this._playingSubscription.unsubscribe(),this._playingSubscription=null,this._clearSubscription.unsubscribe(),this._clearSubscription=null,this._stateService.setSpeed(1),this._stateService.cutImages(),this._graphService.setGraphMode(Nf.Spatial),this._setPlaying(!1))}_mapSpeed(e){const t=2*e-1;return Math.pow(10,t)-.2*t}_mapImagesAhead(e){return Math.round(Math.max(10,Math.min(50,8+6*e)))}_setPlaying(e){this._playing=e,this._playingSubject$.next(e)}_setSpeed(e){this._speed=e;const t=this._mapSpeed(this._speed);return this._imagesAhead=this._mapImagesAhead(t),t}}var gg,_g;fg.sequenceSpeed=.54,e.CameraVisualizationMode=void 0,(gg=e.CameraVisualizationMode||(e.CameraVisualizationMode={}))[gg.Hidden=0]="Hidden",gg[gg.Homogeneous=1]="Homogeneous",gg[gg.Cluster=2]="Cluster",gg[gg.ConnectedComponent=3]="ConnectedComponent",gg[gg.Sequence=4]="Sequence",e.OriginalPositionMode=void 0,(_g=e.OriginalPositionMode||(e.OriginalPositionMode={}))[_g.Hidden=0]="Hidden",_g[_g.Altitude=1]="Altitude",_g[_g.Flat=2]="Flat";class vg extends tc{constructor(e){super(),this._originalSize=e.originalSize;const{cluster:t,color:i,scale:n,translation:r}=e;this._makeAttributes(t),this.material.size=n*this._originalSize,this.setColor(i),this.matrixAutoUpdate=!1,this.position.fromArray(r),this.updateMatrix(),this.updateMatrixWorld(!1)}dispose(){this.geometry.dispose(),this.material.dispose()}setColor(e){this.material.vertexColors=null==e,this.material.color=new xr(e),this.material.needsUpdate=!0}resize(e){this.material.size=e*this._originalSize,this.material.needsUpdate=!0}_makeAttributes(e){const t=[],i=[],n=e.points;for(const e in n){if(!n.hasOwnProperty(e))continue;const r=n[e];t.push(...r.coordinates);const s=r.color;i.push(s[0]),i.push(s[1]),i.push(s[2])}const r=this.geometry;r.setAttribute("position",new Tr(new Float32Array(t),3)),r.setAttribute("color",new Tr(new Float32Array(i),3))}}class yg extends Wh{constructor(e){super(),this._makeAttributes(e),this.matrixAutoUpdate=!1,this.updateMatrix(),this.updateMatrixWorld(!1)}dispose(){this.geometry.dispose(),this.material.dispose()}_makeAttributes(e){const t=e.slice();t.push(e[0]);let i=0;const n=new Float32Array(3*(e.length+1));for(const e of t)n[i++]=e[0],n[i++]=e[1],n[i++]=e[2];this.geometry.setAttribute("position",new Tr(n,3))}}function bg(e,t){return e===t}function xg(e){const t=function(e){return Math.pow(2,e)}(e)/2;return{min:[-t,-t,-t],max:[t,t,t]}}class wg{constructor(e,t,i,n){this.level=e,this.leafLevel=t,this.boundingBox=i,this.parent=n,this.children=[],this.items=[],n&&n.children.push(this)}get isEmpty(){return!(this.children.length||this.items.length)}add(e){const t=this;if(!t.boundingBox.containsPoint(e.position))throw new Error("Item not contained in node");if(bg(t.level,t.leafLevel))return t.items.push(e),this;for(const i of t.children)if(i.boundingBox.containsPoint(e.position))return i.add(e);for(const i of t._generateBoundingBoxes())if(i.containsPoint(e.position)){return new wg(t.level-1,t.leafLevel,i,t).add(e)}throw new Error("Item not contained in children")}intersect(e,t,i){if(e.intersectBox(this.boundingBox,t))if(bg(this.level,this.leafLevel))i.push(this);else for(const n of this.children)n.intersect(e,t,i)}remove(e){const t=this.items.indexOf(e);if(t<0)throw new Error(`Item does not exist ${e.uuid}`);this.items.splice(t,1)}traverse(){const e=this;if(!e.isEmpty)return;const t=e.parent;if(!t)return;const i=t.children.indexOf(e);if(i<0)throw new Error("Corrupt octree");t.children.splice(i,1),this.parent=null,t.traverse()}_generateBoundingBoxes(){const e=this.boundingBox.min,t=(this.boundingBox.max.x-e.x)/2,i=[[e.x,e.y+t,e.z+t],[e.x+t,e.y+t,e.z+t],[e.x,e.y,e.z+t],[e.x+t,e.y,e.z+t],[e.x,e.y+t,e.z],[e.x+t,e.y+t,e.z],[e.x,e.y,e.z],[e.x+t,e.y,e.z]],n=[];for(const[e,r,s]of i)n.push(new tn(new Ki(e,r,s),new Ki(e+t,r+t,s+t)));return n}}class Mg{constructor(e,t){if(this.rootLevel=e,this.leafLevel=t,t>e)throw new Error;this._index=new Map,this._root=this._makeRoot()}get root(){return this._root}add(e){if(!this.root.boundingBox.containsPoint(e.position))return void console.warn(`Object outside bounding box ${e.uuid}`);const t=this._root.add(e);this._index.set(e.uuid,t)}has(e){return this._index.has(e.uuid)}intersect(e){const t=[],i=new Ki;return this._root.intersect(e,i,t),t.map((e=>e.items)).reduce(((e,t)=>(e.push(...t),e)),[])}reset(){this._root=this._makeRoot(),this._index.clear()}remove(e){if(!this.has(e))throw new Error(`Frame does not exist ${e.uuid}`);const t=this._index.get(e.uuid);t.remove(e),t.traverse(),this._index.delete(e.uuid)}_makeRoot(){const e=this.rootLevel,t=xg(e),i=new tn((new Ki).fromArray(t.min),(new Ki).fromArray(t.max));return new wg(e,this.leafLevel,i)}}class Sg{constructor(e,t){this._objects=[],this._objectImageMap=new Map,this._octree=null!=e?e:new Mg(14,6),this._raycaster=null!=t?t:new su,this._interactiveLayer=1,this._raycaster=t||new su(void 0,void 0,1,1e4),this._lineThreshold=.2,this._largeLineThreshold=.4,this._raycaster.params.Line.threshold=this._lineThreshold,this._raycaster.layers.set(this._interactiveLayer)}get interactiveLayer(){return this._interactiveLayer}get octree(){return this._octree}get raycaster(){return this._raycaster}add(e,t){const i=e.uuid;this._objectImageMap.set(i,t),this._objects.push(e),this._octree.add(e)}intersectObjects(e,t){this._raycaster.setFromCamera((new zi).fromArray(e),t);const i=this._octree.intersect(this.raycaster.ray),n=this._raycaster.intersectObjects(i),r=this._objectImageMap;for(const e of n){const t=e.object.uuid;if(r.has(t))return r.get(t)}return null}remove(e){const t=this._objects,i=t.indexOf(e);if(-1!==i){const n=t.splice(i,1);for(const e of n)this._objectImageMap.delete(e.uuid);this._octree.remove(e)}else console.warn("Object does not exist")}resetIntersectionThreshold(e){this._raycaster.params.Line.threshold=e?this._largeLineThreshold:this._lineThreshold}}class Tg extends Wh{constructor(e){super(e.geometry,e.material);const t=e.mode,i=e.originalOrigin,n=e.transform.unprojectBasic([0,0],0);this._relativeAltitude=i[2]-n[2],this._makeAttributes(n,i,t),this.matrixAutoUpdate=!1,this.position.fromArray(n),this.updateMatrix(),this.updateMatrixWorld(!1)}dispose(){this.geometry.dispose(),this.material.dispose()}setMode(e){const t=this.geometry.attributes.position;t.array[5]=this._modeToAltitude(e),t.needsUpdate=!0,this.geometry.computeBoundingSphere()}_makeAttributes(e,t,i){const n=new Float32Array(6);n[0]=0,n[1]=0,n[2]=0,n[3]=t[0]-e[0],n[4]=t[1]-e[1],n[5]=this._modeToAltitude(i);const r=new Tr(n,3);this.geometry.setAttribute("position",r),r.needsUpdate=!0,this.geometry.computeBoundingSphere()}_modeToAltitude(t){return t===e.OriginalPositionMode.Altitude?this._relativeAltitude:0}}class Cg extends Zh{constructor(e){super(e.geometry,e.material);const t=e.color,i=e.size,n=e.scale,r=e.transform,s=r.unprojectBasic([0,0],0),a=this._makePositions(i,r,s);this._makeAttributes(a,t),this.geometry.computeBoundingSphere(),this.geometry.computeBoundingBox(),this.matrixAutoUpdate=!1,this.position.fromArray(s),this.scale.set(n,n,n),this.updateMatrix(),this.updateMatrixWorld(!1)}dispose(){this.geometry.dispose(),this.material.dispose()}setColor(e){return this._updateColorAttribute(e),this}resize(e){return this.scale.set(e,e,e),this.updateMatrix(),this.updateMatrixWorld(!1),this}_makeAttributes(e,t){const i=this.geometry,n=new Tr(new Float32Array(e),3);i.setAttribute("position",n),n.needsUpdate=!0;const r=new Tr(new Float32Array(e.length),3);i.setAttribute("color",r),this._updateColorAttribute(t)}_updateColorAttribute(e){const[t,i,n]=new xr(e).toArray(),r=this.geometry.attributes.color,s=r.array,a=s.length;let o=0;for(let e=0;e<a;e++)s[o++]=t,s[o++]=i,s[o++]=n;r.needsUpdate=!0}}class Eg extends Cg{_makePositions(e,t,i){const n=[];n.push(...this._makeAxis(e,t,i)),n.push(...this._makeLat(.5,10,e,t,i));for(const r of[0,.25,.5,.75])n.push(...this._makeLng(r,10,e,t,i));return n}_makeAxis(e,t,i){const n=t.unprojectBasic([.5,1],.8*e),r=t.unprojectBasic([.5,0],1.2*e);return[n[0]-i[0],n[1]-i[1],n[2]-i[2],r[0]-i[0],r[1]-i[1],r[2]-i[2]]}_makeLat(e,t,i,n,r){const s=.8*i,[a,o,h]=r,c=[],l=n.unprojectBasic([0,e],s);l[0]-=a,l[1]-=o,l[2]-=h,c.push(...l);for(let i=1;i<=t;i++){const r=n.unprojectBasic([i/t,e],s);r[0]-=a,r[1]-=o,r[2]-=h,c.push(...r,...r)}return c.push(...l),c}_makeLng(e,t,i,n,r){const s=.8*i,[a,o,h]=r,c=[],l=n.unprojectBasic([e,0],s);l[0]-=a,l[1]-=o,l[2]-=h,c.push(...l);for(let i=0;i<=t;i++){const r=n.unprojectBasic([e,i/t],s);r[0]-=a,r[1]-=o,r[2]-=h,c.push(...r,...r)}return c.push(...l),c}}class Ag extends Cg{_makePositions(e,t,i){const n=[];return n.push(...this._makeDiags(e,t,i)),n.push(...this._makeFrame(e,8,t,i)),n}_makeDiags(e,t,i){const[n,r,s]=i,a=[0,0,0],o=[];for(const i of[[0,0],[1,0],[1,1],[0,1]]){const h=t.unprojectBasic(i,e);h[0]-=n,h[1]-=r,h[2]-=s,o.push(...a,...h)}return o}_makeFrame(e,t,i,n){const r=[];r.push(...this._subsample([0,1],[0,0],t)),r.push(...this._subsample([0,0],[1,0],t)),r.push(...this._subsample([1,0],[1,1],t));const[s,a,o]=n,h=[];for(const t of r){const n=i.unprojectBasic(t,e);n[0]-=s,n[1]-=a,n[2]-=o,h.push(...n)}return h}_interpolate(e,t,i){return e+i*(t-e)}_subsample(e,t,i){if(i<1)return[e,t];const n=[];n.push(e);for(let r=0;r<=i;r++){const s=[];for(let n=0;n<3;n++)s.push(this._interpolate(e[n],t[n],r/(i+1)));n.push(s),n.push(s)}return n.push(t),n}}function Ig(e,t,i){const[n,r,s]=t,[a,o,h]=vu(n,r,s,i.lng,i.lat,i.alt);return _u(a,o,h,e.lng,e.lat,e.alt)}class Rg{constructor(e,t,i){this.id=e,this._scene=t,this._intersection=i,this.cameras=new tr,this.keys=[],this._positionLines={},this._positions=new tr,this._cameraFrames={},this._clusters=new Map,this._connectedComponents=new Map,this._sequences=new Map,this._props={},this.clusterVisibles={},this._frameMaterial=new Bh({fog:!1,vertexColors:!0}),this._positionMaterial=new Bh({fog:!1,color:16711680}),this._scene.add(this.cameras,this._positions)}addImage(e){const t=e.image,i=t.id;if(this.hasImage(i))throw new Error(`Image exists ${i}`);const n=e.idMap.ccId;this._connectedComponents.has(n)||this._connectedComponents.set(n,[]);const r=e.idMap.clusterId;this._clusters.has(r)||this._clusters.set(r,[]);const s=e.idMap.sequenceId;this._sequences.has(s)||this._sequences.set(s,[]),this._props[i]={image:t,ids:{ccId:n,clusterId:r,sequenceId:s}},this.keys.push(i)}applyCameraColor(e,t){this._cameraFrames[e].setColor(t)}applyCameraSize(e){for(const t of this.cameras.children)t.resize(e)}applyFilter(e){var t;const i=this.clusterVisibles;for(const e in i)i.hasOwnProperty(e)&&(i[e]=!1);const n=this._cameraFrames,r=this._positionLines,s=this._intersection.interactiveLayer;for(const a of Object.values(this._props)){const o=a.image,h=e(o),c=o.id;r[c].visible=h;const l=n[c];this._setCameraVisibility(l,h,s),i[t=a.ids.clusterId]||(i[t]=h)}}applyPositionMode(t){this._positions.visible=t!==e.OriginalPositionMode.Hidden;for(const e of this._positions.children)e.setMode(t)}dispose(){this._disposeCameras(),this._disposePositions(),this._scene=null,this._intersection=null}getCamerasByMode(t){if(t===e.CameraVisualizationMode.Cluster)return this._clusters;if(t===e.CameraVisualizationMode.ConnectedComponent)return this._connectedComponents;if(t===e.CameraVisualizationMode.Sequence)return this._sequences;const i=e.CameraVisualizationMode,n=i[i.Homogeneous],r=new Map;return r.set(n,this.cameras.children),r}getColorId(t,i){const n=this._props[t],r=e.CameraVisualizationMode;switch(i){case r.Cluster:return n.ids.clusterId;case r.ConnectedComponent:return n.ids.ccId;case r.Sequence:return n.ids.sequenceId;default:return r[r.Homogeneous]}}hasImage(e){return-1!==this.keys.indexOf(e)}resetReference(e,t){const i=this._cameraFrames;for(const n in i){if(!i.hasOwnProperty(n))continue;const r=i[n];r.position.fromArray(Ig(e,r.position.toArray(),t))}const n=this._positionLines;for(const i in n){if(!n.hasOwnProperty(i))continue;const r=n[i];r.position.fromArray(Ig(e,r.position.toArray(),t))}}visualize(e){var t,i;const n=e.id,r=e.visible,s=e.transform,a={color:e.color,material:this._frameMaterial,scale:e.scale,size:e.maxSize,transform:s},o=$u(s.cameraType)?new Eg(a):new Ag(a),h=this._intersection.interactiveLayer;this._setCameraVisibility(o,r,h),this.cameras.add(o),this._cameraFrames[n]=o;this._intersection.add(o,n);const c=this._props[n].ids;(t=this.clusterVisibles)[i=c.clusterId]||(t[i]=r),this._connectedComponents.get(c.ccId).push(o),this._clusters.get(c.clusterId).push(o),this._sequences.get(c.sequenceId).push(o);const l={material:this._positionMaterial,mode:e.positionMode,originalOrigin:e.originalPosition,transform:s},u=new Tg(l);u.visible=r,this._positions.add(u),this._positionLines[n]=u}_disposeCameras(){const e=this._intersection,t=this.cameras;for(const i of t.children.slice())i.dispose(),e.remove(i),t.remove(i);this._scene.remove(this.cameras)}_disposePositions(){const e=this._positions;for(const t of e.children.slice())t.dispose(),e.remove(t);this._scene.remove(this._positions)}_setCameraVisibility(e,t,i){e.visible=t,t?e.layers.enable(i):e.layers.disable(i)}}class Pg{constructor(){this._colors=new Map;const t=e.CameraVisualizationMode;this._colors.set(t[t.Homogeneous],"#FFFFFF")}getColor(e){const t=this._colors;return t.has(e)||t.set(e,this._randomColor()),t.get(e)}_randomColor(){return`hsl(${Math.floor(360*Math.random())}, 100%, 50%)`}}function Lg(t){return t!==e.CameraVisualizationMode.Hidden}var Dg;e.PointVisualizationMode=void 0,(Dg=e.PointVisualizationMode||(e.PointVisualizationMode={}))[Dg.Hidden=0]="Hidden",Dg[Dg.Original=1]="Original",Dg[Dg.Cluster=2]="Cluster";class Ng{constructor(t,i){this._rayNearScale=1.1,this._originalPointSize=2,this._originalCameraSize=2,this._imageCellMap=new Map,this._scene=i||new ch,this._scene.autoUpdate=!1,this._intersection=new Sg,this._assets=new Pg,this._needsRender=!1,this._images={},this._cells={},this._cellClusters={},this._clusters={},this._cameraVisualizationMode=t.cameraVisualizationMode?t.cameraVisualizationMode:e.CameraVisualizationMode.Homogeneous,this._cameraSize=t.cameraSize,this._pointSize=t.pointSize,this._pointVisualizationMode=t.pointVisualizationMode?t.pointVisualizationMode:e.PointVisualizationMode.Original,this._positionMode=t.originalPositionMode,this._cellsVisible=t.cellsVisible,this._hoveredId=null,this._selectedId=null,this._colors={hover:"#FF0000",select:"#FF8000"},this._filter=()=>!0}get needsRender(){return this._needsRender}get intersection(){return this._intersection}addCluster(t,i,n){if(this.hasCluster(t.id,n))return;const r=t.id;if(!(r in this._clusters)){this._clusters[r]={points:new tr,cellIds:[]};const n=this._getClusterVisible(r),s=this._clusters[r],a=this._pointVisualizationMode===e.PointVisualizationMode.Cluster?this._assets.getColor(r):null,o=new vg({cluster:t,color:a,originalSize:this._originalPointSize,scale:this._pointSize,translation:i});s.points.visible=n,s.points.add(o),this._scene.add(s.points)}-1===this._clusters[r].cellIds.indexOf(n)&&this._clusters[r].cellIds.push(n),n in this._cellClusters||(this._cellClusters[n]={keys:[]}),-1===this._cellClusters[n].keys.indexOf(r)&&this._cellClusters[n].keys.push(r),this._needsRender=!0}addImage(e,t,i,n){var r,s,a;const o=e.id,h={clusterId:null!==(r=e.clusterId)&&void 0!==r?r:"NO_CLUSTER_ID",sequenceId:null!==(s=e.sequenceId)&&void 0!==s?s:"NO_SEQUENCE_ID",ccId:null!==(a=e.mergeId)&&void 0!==a?a:"NO_MERGE_ID"};if(!(n in this._images)){const e=new Rg(n,this._scene,this._intersection);e.cameras.visible=Lg(this._cameraVisualizationMode),e.applyPositionMode(this._positionMode),this._images[n]=e}const c=this._images[n];if(c.hasImage(o))return;c.addImage({idMap:h,image:e});const l=c.getColorId(o,this._cameraVisualizationMode),u=this._assets.getColor(l),d=this._filter(e);if(c.visualize({id:o,color:u,positionMode:this._positionMode,scale:this._cameraSize,transform:t,visible:d,maxSize:this._originalCameraSize,originalPosition:i}),this._imageCellMap.set(o,n),o===this._selectedId&&this._highlight(o,this._colors.select,this._cameraVisualizationMode),h.clusterId in this._clusters){const e=this._getClusterVisible(h.clusterId);this._clusters[h.clusterId].points.visible=e}this._needsRender=!0}addCell(e,t){if(this.hasCell(t))return;const i=new yg(e);this._cells[t]=new tr,this._cells[t].visible=this._cellsVisible,this._cells[t].add(i),this._scene.add(this._cells[t]),this._needsRender=!0}deactivate(){this._filter=()=>!0,this._selectedId=null,this._hoveredId=null,this.uncache()}hasCluster(e,t){return e in this._clusters&&-1!==this._clusters[e].cellIds.indexOf(t)}hasCell(e){return e in this._cells}hasImage(e,t){return t in this._images&&this._images[t].hasImage(e)}render(e,t){t.render(this._scene,e),this._needsRender=!1}resetReference(e,t){const i=this._clusters;for(const n in i){if(!i.hasOwnProperty(n))continue;const r=i[n];r.points.position.fromArray(Ig(e,r.points.position.toArray(),t))}const n=this._cells;for(const i in n){if(!n.hasOwnProperty(i))continue;const r=n[i];r.position.fromArray(Ig(e,r.position.toArray(),t))}const r=this._images;for(const i in r){if(!r.hasOwnProperty(i))continue;r[i].resetReference(e,t)}}setCameraSize(e){if(Math.abs(e-this._cameraSize)<.001)return;const t=this._images;for(const i of Object.keys(t))t[i].applyCameraSize(e);this._intersection.raycaster.near=this._getNear(e),this._cameraSize=e,this._needsRender=!0}setFilter(t){this._filter=t;const i={};for(const e of Object.values(this._images)){e.applyFilter(t);const n=e.clusterVisibles;for(const e in n)n.hasOwnProperty(e)&&(e in i||(i[e]=!1),i[e]||(i[e]=n[e]))}const n=this._pointVisualizationMode!==e.PointVisualizationMode.Hidden;for(const e in i){if(!i.hasOwnProperty(e))continue;i[e]&&(i[e]=n);const t=i[e];e in this._clusters&&(this._clusters[e].points.visible=t)}this._needsRender=!0}setHoveredImage(e){if(null!=e&&!this._imageCellMap.has(e))throw new Pu(`Image does not exist: ${e}`);this._hoveredId!==e&&(this._needsRender=!0,null!=this._hoveredId&&(this._hoveredId===this._selectedId?this._highlight(this._hoveredId,this._colors.select,this._cameraVisualizationMode):this._resetCameraColor(this._hoveredId)),this._highlight(e,this._colors.hover,this._cameraVisualizationMode),this._hoveredId=e)}setNavigationState(e){this._intersection.resetIntersectionThreshold(e)}setPointSize(e){if(Math.abs(e-this._pointSize)<.001)return;const t=this._clusters;for(const i in t)if(t.hasOwnProperty(i))for(const n of t[i].points.children)n.resize(e);this._pointSize=e,this._needsRender=!0}setPointVisualizationMode(t){if(t!==this._pointVisualizationMode){this._pointVisualizationMode=t;for(const i in this._clusters){if(!this._clusters.hasOwnProperty(i))continue;const n=this._clusters[i];n.points.visible=this._getClusterVisible(i);for(const r of n.points.children){const n=t===e.PointVisualizationMode.Cluster?this._assets.getColor(i):null;r.setColor(n)}}this._needsRender=!0}}setPositionMode(e){if(e!==this._positionMode){for(const t of Object.values(this._images))t.applyPositionMode(e);this._positionMode=e,this._needsRender=!0}}setSelectedImage(e){this._selectedId!==e&&(this._needsRender=!0,null!=this._selectedId&&this._resetCameraColor(this._selectedId),this._highlight(e,this._colors.select,this._cameraVisualizationMode),this._selectedId=e)}setCellVisibility(e){if(e!==this._cellsVisible){for(const t in this._cells)this._cells.hasOwnProperty(t)&&(this._cells[t].visible=e);this._cellsVisible=e,this._needsRender=!0}}setCameraVisualizationMode(e){if(e===this._cameraVisualizationMode)return;const t=Lg(e),i=this._assets;for(const n of Object.values(this._images)){n.cameras.visible=t;n.getCamerasByMode(e).forEach(((e,t)=>{const n=i.getColor(t);for(const t of e)t.setColor(n)}))}this._highlight(this._hoveredId,this._colors.hover,e),this._highlight(this._selectedId,this._colors.select,e),this._cameraVisualizationMode=e,this._needsRender=!0}uncache(e){for(const t of Object.keys(this._cellClusters))e&&-1!==e.indexOf(t)||this._disposeReconstruction(t);for(const t of Object.keys(this._images)){if(e&&-1!==e.indexOf(t))continue;const i=this._imageCellMap,n=this._images[t].keys;for(const e of n)i.delete(e);this._images[t].dispose(),delete this._images[t]}for(const t of Object.keys(this._cells))e&&-1!==e.indexOf(t)||this._disposeCell(t);this._needsRender=!0}_getClusterVisible(t){if(this._pointVisualizationMode===e.PointVisualizationMode.Hidden)return!1;let i=!1;for(const e of Object.values(this._images)){const n=e.clusterVisibles;t in n&&(i||(i=n[t]))}return i}_disposePoints(e){for(const t of this._cellClusters[e].keys){if(!(t in this._clusters))continue;const i=this._clusters[t].cellIds.indexOf(e);if(-1!==i&&(this._clusters[t].cellIds.splice(i,1),!(this._clusters[t].cellIds.length>0))){for(const e of this._clusters[t].points.children.slice())e.dispose();this._scene.remove(this._clusters[t].points),delete this._clusters[t]}}}_disposeReconstruction(e){this._disposePoints(e),delete this._cellClusters[e]}_disposeCell(e){const t=this._cells[e];for(const e of t.children.slice())e.dispose(),t.remove(e);this._scene.remove(t),delete this._cells[e]}_getNear(e){const t=this._rayNearScale*this._originalCameraSize*e;return Math.max(1,t)}_resetCameraColor(e){const t=this._imageCellMap;if(null==e||!t.has(e))return;const i=t.get(e),n=this._images[i],r=n.getColorId(e,this._cameraVisualizationMode),s=this._assets.getColor(r);n.applyCameraColor(e,s)}_highlight(t,i,n){const r=this._imageCellMap;if(null==t||!r.has(t))return;const s=r.get(t);i=n===e.CameraVisualizationMode.Homogeneous?i:"#FFFFFF",this._images[s].applyCameraColor(t,i)}}class $g{constructor(e,t){this._graphService=e,this._data=t,this._cells={},this._cacheRequests={},this._clusters={},this._clusterCells={},this._cellClusters={},this._cachingCells$={},this._cachingClusters$={}}cacheClusters$(e){if(!this.hasCell(e))throw new Error("Cannot cache reconstructions of a non-existing cell.");if(this.hasClusters(e))throw new Error("Cannot cache reconstructions that already exists.");if(this.isCachingClusters(e))return this._cachingClusters$[e];const t=this.getCell(e).filter((e=>!!e.clusterId&&!!e.clusterUrl)).map((e=>({key:e.clusterId,url:e.clusterUrl}))),i=Array.from(new Map(t.map((e=>[e.key,e]))).values());let n;this._cellClusters[e]=i,this._cacheRequests[e]=[];const r=new Promise(((e,t)=>{n=t}));return this._cacheRequests[e].push(n),this._cachingClusters$[e]=this._cacheClusters$(i,e,r).pipe(Mt((()=>{e in this._cachingClusters$&&delete this._cachingClusters$[e],e in this._cacheRequests&&delete this._cacheRequests[e]})),It(),U()),this._cachingClusters$[e]}cacheCell$(e){if(this.hasCell(e))throw new Error("Cannot cache cell that already exists.");return this.isCachingCell(e)||(this._cachingCells$[e]=this._graphService.cacheCell$(e).pipe(ct((e=>(console.error(e),ie()))),st((()=>!(e in this._cells))),Ut((t=>{this._cells[e]=[],this._cells[e].push(...t),delete this._cachingCells$[e]})),Mt((()=>{e in this._cachingCells$&&delete this._cachingCells$[e]})),It(),U())),this._cachingCells$[e]}isCachingClusters(e){return e in this._cachingClusters$}isCachingCell(e){return e in this._cachingCells$}hasClusters(e){if(e in this._cachingClusters$||!(e in this._cellClusters))return!1;for(const t of this._cellClusters[e])if(!(t.key in this._clusters))return!1;return!0}hasCell(e){return!(e in this._cachingCells$)&&e in this._cells}getClusters(e){return e in this._cellClusters?this._cellClusters[e].map((e=>this._clusters[e.key])).filter((e=>!!e)):[]}getCell(e){return e in this._cells?this._cells[e]:[]}uncache(e){for(let t of Object.keys(this._cacheRequests))if(!e||-1===e.indexOf(t)){for(const e of this._cacheRequests[t])e();delete this._cacheRequests[t]}for(let t of Object.keys(this._cellClusters))if(!e||-1===e.indexOf(t)){for(const e of this._cellClusters[t]){if(!(e.key in this._clusterCells))continue;const i=this._clusterCells[e.key].indexOf(t);-1!==i&&(this._clusterCells[e.key].splice(i,1),this._clusterCells[e.key].length>0||(delete this._clusterCells[e.key],delete this._clusters[e.key]))}delete this._cellClusters[t]}for(let t of Object.keys(this._cells))e&&-1!==e.indexOf(t)||delete this._cells[t]}updateCell$(e){if(!this.hasCell(e))throw new Error("Cannot update cell that does not exists.");return this._graphService.cacheCell$(e).pipe(ct((e=>(console.error(e),ie()))),st((()=>e in this._cells)),Ut((t=>{this._cells[e]=[],this._cells[e].push(...t)})),It(),U())}updateClusters$(e){if(!this.hasCell(e))throw new Error("Cannot update reconstructions of a non-existing cell.");if(!this.hasClusters(e))throw new Error("Cannot update reconstructions for cell that is not cached.");const t=this.getCell(e).filter((e=>!!e.clusterId&&!!e.clusterUrl)).map((e=>({key:e.clusterId,url:e.clusterUrl}))),i=Array.from(new Map(t.map((e=>[e.key,e]))).values()).filter((e=>!(e.key in this._clusters)));return this._cellClusters[e].push(...i),this._cacheClusters$(i,e,null)}_cacheClusters$(e,t,i){return ge(e).pipe(We((e=>this._hasCluster(e.key)?Ce(this._getCluster(e.key)):this._getCluster$(e.url,e.key,i).pipe(ct((e=>(e instanceof uf||console.error(e),ie()))))),6),st((()=>t in this._cellClusters)),Ut((e=>{this._hasCluster(e.id)||(this._clusters[e.id]=e),e.id in this._clusterCells||(this._clusterCells[e.id]=[]),-1===this._clusterCells[e.id].indexOf(t)&&this._clusterCells[e.id].push(t)})))}_getCluster(e){return this._clusters[e]}_getCluster$(e,t,i){return k.create((n=>{this._data.getCluster(e,i).then((e=>{e.id=t,n.next(e),n.complete()}),(e=>{n.error(e)}))}))}_hasCluster(e){return e in this._clusters}}function kg(e,t,i){const n=new Set;return n.add(e),Og(n,[e],0,t,i),Array.from(n)}function Og(e,t,i,n,r){if(i>=n)return;const s=[];for(const e of t){const t=r.getAdjacent(e);s.push(...t)}const a=[];for(const t of s)e.has(t)||(e.add(t),a.push(t));Og(e,a,i+1,n,r)}class zg extends sf{constructor(e,t,i){super(e,t,i),this._cache=new $g(i.graphService,i.api.data),this._scene=new Ng(this._getDefaultConfiguration()),this._viewportCoords=new hf,this._spatial=new Du}getFrameIdAt(e){return new Promise(((t,i)=>{this._container.renderService.renderCamera$.pipe(St(),De((t=>{const i=this._viewportCoords.canvasToViewport(e[0],e[1],this._container.container);return this._scene.intersection.intersectObjects(i,t.perspective)}))).subscribe((e=>{t(e)}),(e=>{i(e)}))}))}_activate(){this._navigator.cacheService.configure({cellDepth:3});const t=this._subscriptions;t.push(this._navigator.stateService.reference$.pipe(At()).subscribe((([e,t])=>{this._scene.resetReference(t,e)}))),t.push(this._navigator.graphService.filter$.subscribe((e=>{this._scene.setFilter(e)})));const i=this._container.renderService.bearing$.pipe(De((e=>6*Math.floor(e/6))),vt(),Rt(1),U()),n=this._navigator.stateService.currentImage$.pipe(De((e=>this._navigator.api.data.geometry.lngLatToCellId(e.originalLngLat))),vt(),Rt(1),U()),r=this._configuration$.pipe(De((e=>this._spatial.clamp(e.cellGridDepth,1,3))),vt(),Rt(1),U()),s=Ve(this._navigator.playService.playing$,this._navigator.playService.speed$).pipe(De((([e,t])=>e&&t>fg.sequenceSpeed)),vt(),Rt(1),U()),a=this._navigator.stateService.state$.pipe(De((e=>function(e){return e===Df.Custom||e===Df.Earth}(e))),vt(),Rt(1),U());t.push(a.subscribe((e=>{this._scene.setNavigationState(e)})));const o=Ve(a,s,i,r,this._navigator.stateService.currentImage$).pipe(vt((([e,t,i,n,r],[s,a,o,h,c])=>{if(e!==s)return!1;const l=r.id===c.id&&t===a&&n===h;return e?l:l&&i===o})),dt((([e,t,i,n,r])=>{if(e){const e=this._navigator.api.data.geometry,i=e.lngLatToCellId(r.originalLngLat);return Ce(t?[i]:kg(i,n,e))}const s=t?30:90;return Ce(this._cellsInFov(r,i,s))})),zt((e=>ge(e).pipe(We((e=>(this._cache.hasCell(e)?Ce(this._cache.getCell(e)):this._cache.cacheCell$(e)).pipe(De((t=>({id:e,images:t}))))),6)))));t.push(o.pipe(Vt(this._navigator.stateService.reference$)).subscribe((([e,t])=>{this._scene.hasCell(e.id)||this._scene.addCell(this._cellToTopocentric(e.id,t),e.id)}))),t.push(o.pipe(Vt(this._navigator.stateService.reference$)).subscribe((([e,t])=>{this._addSceneImages(e,t)}))),t.push(o.pipe(dt((e=>{const t=e.id;let i;return i=this._cache.hasClusters(t)?ge(this._cache.getClusters(t)):this._cache.isCachingClusters(t)?this._cache.cacheClusters$(t).pipe(Ct(null,{}),zt((()=>ge(this._cache.getClusters(t))))):this._cache.hasCell(t)?this._cache.cacheClusters$(t):ie(),Ve(Ce(t),i)})),Vt(this._navigator.stateService.reference$)).subscribe((([[e,t],i])=>{this._scene.hasCluster(t.id,e)||this._scene.addCluster(t,this._computeTranslation(t,i),e)}))),t.push(this._configuration$.pipe(De((t=>{var i;t.cameraSize=this._spatial.clamp(t.cameraSize,.01,1),t.pointSize=this._spatial.clamp(t.pointSize,.01,1);const n=t.pointsVisible?null!==(i=t.pointVisualizationMode)&&void 0!==i?i:e.PointVisualizationMode.Original:e.PointVisualizationMode.Hidden;return{cameraSize:t.cameraSize,cameraVisualizationMode:t.cameraVisualizationMode,cellsVisible:t.cellsVisible,originalPositionMode:t.originalPositionMode,pointSize:t.pointSize,pointVisualizationMode:n}})),vt(((e,t)=>e.cameraSize===t.cameraSize&&e.cameraVisualizationMode===t.cameraVisualizationMode&&e.cellsVisible===t.cellsVisible&&e.originalPositionMode===t.originalPositionMode&&e.pointSize===t.pointSize&&e.pointVisualizationMode===t.pointVisualizationMode))).subscribe((e=>{this._scene.setCameraSize(e.cameraSize);const t=e.cameraVisualizationMode;this._scene.setCameraVisualizationMode(t),this._scene.setCellVisibility(e.cellsVisible),this._scene.setPointSize(e.pointSize);const i=e.pointVisualizationMode;this._scene.setPointVisualizationMode(i);const n=e.originalPositionMode;this._scene.setPositionMode(n)}))),t.push(Ve(n,r).subscribe((([e,t])=>{const i=kg(e,t,this._navigator.api.data.geometry);this._scene.uncache(i),this._cache.uncache(i)}))),t.push(this._navigator.playService.playing$.pipe(zt((e=>e?ie():this._container.mouseService.dblClick$)),Vt(this._container.renderService.renderCamera$),zt((([e,t])=>{const i=this._container.container,[n,r]=this._viewportCoords.canvasPosition(e,i),s=this._viewportCoords.canvasToViewport(n,r,i),a=this._scene.intersection.intersectObjects(s,t.perspective);return a?this._navigator.moveTo$(a).pipe(ct((()=>ie()))):ie()}))).subscribe());const h=Ve(this._configuration$,this._navigator.stateService.state$).pipe(De((([e,t])=>(e.cameraSize=this._spatial.clamp(e.cameraSize,.01,1),{size:e.cameraSize,visible:Lg(e.cameraVisualizationMode),state:t}))),vt(((e,t)=>e.size===t.size&&e.visible===t.visible&&e.state===t.state))),c=this._container.mouseService.mouseMove$.pipe(Rt(1),U());t.push(c.subscribe());const l=it(this._container.mouseService.mouseEnter$,this._container.mouseService.mouseLeave$,this._container.mouseService.windowBlur$);t.push(Ve(this._navigator.playService.playing$,l,a,this._navigator.graphService.filter$).pipe(zt((([e,t])=>e||"pointerenter"!==t.type?Ve(Ce(t),Ce(null),Ce(null)):Ve(Ze(c.pipe(_t(1)),this._container.mouseService.mouseMove$),this._container.renderService.renderCamera$,h)))).subscribe((([e,t])=>{if("pointermove"!==e.type)return void this._scene.setHoveredImage(null);const i=this._container.container,[n,r]=this._viewportCoords.canvasPosition(e,i),s=this._viewportCoords.canvasToViewport(n,r,i),a=this._scene.intersection.intersectObjects(s,t.perspective);this._scene.setHoveredImage(a)}))),t.push(this._navigator.stateService.currentId$.subscribe((e=>{this._scene.setSelectedImage(e)}))),t.push(this._navigator.stateService.currentState$.pipe(De((e=>{const t=this._scene;return{name:this._name,renderer:{frameId:e.id,needsRender:t.needsRender,render:t.render.bind(t),pass:yf.Opaque}}}))).subscribe(this._container.glRenderer.render$));const u=this._navigator.graphService.dataAdded$.pipe(st((e=>this._cache.hasCell(e))),We((e=>this._cache.updateCell$(e).pipe(De((t=>({id:e,images:t}))),Vt(this._navigator.stateService.reference$)))),It(),U());t.push(u.subscribe((([e,t])=>{this._addSceneImages(e,t)}))),t.push(u.pipe(dt((([e])=>{const t=e.id,i=this._cache;let n;return n=i.hasClusters(t)?i.updateClusters$(t):i.isCachingClusters(t)?this._cache.cacheClusters$(t).pipe(Ct(null,{}),zt((()=>ge(i.updateClusters$(t))))):ie(),Ve(Ce(t),n)})),Vt(this._navigator.stateService.reference$)).subscribe((([[e,t],i])=>{this._scene.hasCluster(t.id,e)||this._scene.addCluster(t,this._computeTranslation(t,i),e)})))}_deactivate(){this._subscriptions.unsubscribe(),this._cache.uncache(),this._scene.deactivate(),this._navigator.cacheService.configure()}_getDefaultConfiguration(){return{cameraSize:.1,cameraVisualizationMode:e.CameraVisualizationMode.Homogeneous,cellGridDepth:1,originalPositionMode:e.OriginalPositionMode.Hidden,pointSize:.1,pointsVisible:!0,pointVisualizationMode:e.PointVisualizationMode.Original,cellsVisible:!1}}_addSceneImages(e,t){const i=e.id,n=e.images;for(const e of n)this._scene.hasImage(e.id,i)||this._scene.addImage(e,this._createTransform(e,t),this._computeOriginalPosition(e,t),i)}_cellsInFov(e,t,i){const n=this._spatial,r=this._navigator.api.data.geometry,s=r.lngLatToCellId(e.originalLngLat),a=[s],o=i/2,h=r.getAdjacent(s);for(const i of h){const s=r.getVertices(i);for(const r of s){const[s,h]=_u(r.lng,r.lat,0,e.lngLat.lng,e.lngLat.lat,0),c=Math.atan2(h,s),l=n.radToDeg(n.azimuthalToBearing(c));Math.abs(l-t)<o&&a.push(i)}}return a}_computeOriginalPosition(e,t){return _u(e.originalLngLat.lng,e.originalLngLat.lat,null!=e.originalAltitude?e.originalAltitude:e.computedAltitude,t.lng,t.lat,t.alt)}_cellToTopocentric(e,t){return this._navigator.api.data.geometry.getVertices(e).map((e=>_u(e.lng,e.lat,-2,t.lng,t.lat,t.alt)))}_computeTranslation(e,t){return _u(e.reference.lng,e.reference.lat,e.reference.alt,t.lng,t.lat,t.alt)}_createTransform(e,t){const i=Ou({alt:e.computedAltitude,lat:e.lngLat.lat,lng:e.lngLat.lng},e.rotation,t);return new ug(e.exifOrientation,e.width,e.height,e.scale,e.rotation,i,void 0,void 0,e.cameraParameters,e.cameraType)}}zg.componentName="spatial";class Fg{constructor(){this._notifyChanged$=new j}get changed$(){return this._notifyChanged$}}class Bg extends Pu{constructor(e){super(null!=e?e:"The provided geometry value is incorrect"),Object.setPrototypeOf(this,Bg.prototype),this.name="GeometryTagError"}}class Ug extends Fg{constructor(e){super();if(e.length<2)throw new Bg("A points geometry must have two or more positions.");this._points=[];for(const t of e){if(t[0]<0||t[0]>1||t[1]<0||t[1]>1)throw new Bg("Basic coordinates of points must be on the interval [0, 1].");this._points.push(t.slice())}}get points(){return this._points}addPoint2d(e){const t=[Math.max(0,Math.min(1,e[0])),Math.max(0,Math.min(1,e[1]))];this._points.push(t),this._notifyChanged$.next(this)}getPoint2d(e){return this._points[e].slice()}removePoint2d(e){if(e<0||e>=this._points.length||this._points.length<3)throw new Bg("Index for removed point must be valid.");this._points.splice(e,1),this._notifyChanged$.next(this)}setVertex2d(e,t,i){this.setPoint2d(e,t,i)}setPoint2d(e,t,i){const n=[Math.max(0,Math.min(1,t[0])),Math.max(0,Math.min(1,t[1]))];this._points[e]=n,this._notifyChanged$.next(this)}getPoints3d(e){return this._getPoints3d(this._points,e)}getPoint3d(e,t){return t.unprojectBasic(this._points[e],200)}getPoints2d(){return this._points.slice()}getCentroid2d(e){if(!e)throw new Bg("Get centroid must be called with a transform for points geometries.");const[t,i,n,r]=this.getRect2d(e);return[t<n?(t+n)/2:(t+n+1)/2%1,(i+r)/2]}getCentroid3d(e){let t=this.getCentroid2d();return e.unprojectBasic(t,200)}getRect2d(e){let t=1,i=0,n=1,r=0;const s=this._points;for(const e of s)e[0]<t&&(t=e[0]),e[0]>i&&(i=e[0]),e[1]<n&&(n=e[1]),e[1]>r&&(r=e[1]);if($u(e.cameraType)){const e=[];for(let t=0;t<s.length;t++)e[t]=t;e.sort(((e,t)=>s[e][0]<s[t][0]?-1:s[e][0]>s[t][0]?1:e<t?-1:1));let n=s[e[0]][0]+1-s[e[e.length-1]][0],r=0;for(let t=0;t<e.length-1;t++){const i=e[t],a=e[t+1],o=s[a][0]-s[i][0];o>n&&(n=o,r=t+1)}r>0&&(t=s[e[r]][0],i=s[e[r-1]][0])}return[t,n,i,r]}setCentroid2d(e,t){throw new Error("Not implemented")}_getPoints3d(e,t){return e.map((e=>t.unprojectBasic(e,200)))}}class Vg{constructor(e,t,i){this._geometry=e,this._transform=t,this._viewportCoords=i||new hf,this._aborted$=new j,this._created$=new j,this._glObjectsChanged$=new j,this._geometryChangedSubscription=this._geometry.changed$.subscribe((()=>{this._onGeometryChanged(),this._glObjectsChanged$.next(this)}))}get geometry(){return this._geometry}get glObjects(){return this._glObjects}get aborted$(){return this._aborted$}get created$(){return this._created$}get glObjectsChanged$(){return this._glObjectsChanged$}get geometryChanged$(){return this._geometry.changed$.pipe(De((()=>this)))}dispose(){this._geometryChangedSubscription.unsubscribe()}_canvasToTransform(e){return`translate(-50%,-50%) translate(${Math.round(e[0])}px,${Math.round(e[1])}px)`}_colorToBackground(e){return"#"+("000000"+e.toString(16)).substr(-6)}_createOutine(e,t){const i=this._getLinePositions(e),n=new kr;n.setAttribute("position",new Tr(i,3));const r=new Bh({color:t,linewidth:1});return new Wh(n,r)}_disposeLine(e){null!=e&&(e.geometry.dispose(),e.material.dispose())}_getLinePositions(e){const t=e.length,i=new Float32Array(3*t);for(let n=0;n<t;++n){const t=3*n,r=e[n];i[t]=r[0],i[t+1]=r[1],i[t+2]=r[2]}return i}}var Hg={exports:{}};function jg(e,t,i){i=i||2;var n,r,s,a,o,h,c,l=t&&t.length,u=l?t[0]*i:e.length,d=Gg(e,0,u,i,!0),p=[];if(!d||d.next===d.prev)return p;if(l&&(d=function(e,t,i,n){var r,s,a,o=[];for(r=0,s=t.length;r<s;r++)(a=Gg(e,t[r]*n,r<s-1?t[r+1]*n:e.length,n,!1))===a.next&&(a.steiner=!0),o.push(i_(a));for(o.sort(Kg),r=0;r<o.length;r++)i=Wg(i=Qg(o[r],i),i.next);return i}(e,t,d,i)),e.length>80*i){n=s=e[0],r=a=e[1];for(var m=i;m<u;m+=i)(o=e[m])<n&&(n=o),(h=e[m+1])<r&&(r=h),o>s&&(s=o),h>a&&(a=h);c=0!==(c=Math.max(s-n,a-r))?1/c:0}return qg(d,p,i,n,r,c),p}function Gg(e,t,i,n,r){var s,a;if(r===f_(e,t,i,n)>0)for(s=t;s<i;s+=n)a=d_(s,e[s],e[s+1],a);else for(s=i-n;s>=t;s-=n)a=d_(s,e[s],e[s+1],a);return a&&a_(a,a.next)&&(p_(a),a=a.next),a}function Wg(e,t){if(!e)return e;t||(t=e);var i,n=e;do{if(i=!1,n.steiner||!a_(n,n.next)&&0!==s_(n.prev,n,n.next))n=n.next;else{if(p_(n),(n=t=n.prev)===n.next)break;i=!0}}while(i||n!==t);return t}function qg(e,t,i,n,r,s,a){if(e){!a&&s&&function(e,t,i,n){var r=e;do{null===r.z&&(r.z=t_(r.x,r.y,t,i,n)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==e);r.prevZ.nextZ=null,r.prevZ=null,function(e){var t,i,n,r,s,a,o,h,c=1;do{for(i=e,e=null,s=null,a=0;i;){for(a++,n=i,o=0,t=0;t<c&&(o++,n=n.nextZ);t++);for(h=c;o>0||h>0&&n;)0!==o&&(0===h||!n||i.z<=n.z)?(r=i,i=i.nextZ,o--):(r=n,n=n.nextZ,h--),s?s.nextZ=r:e=r,r.prevZ=s,s=r;i=n}s.nextZ=null,c*=2}while(a>1)}(r)}(e,n,r,s);for(var o,h,c=e;e.prev!==e.next;)if(o=e.prev,h=e.next,s?Zg(e,n,r,s):Xg(e))t.push(o.i/i),t.push(e.i/i),t.push(h.i/i),p_(e),e=h.next,c=h.next;else if((e=h)===c){a?1===a?qg(e=Yg(Wg(e),t,i),t,i,n,r,s,2):2===a&&Jg(e,t,i,n,r,s):qg(Wg(e),t,i,n,r,s,1);break}}}function Xg(e){var t=e.prev,i=e,n=e.next;if(s_(t,i,n)>=0)return!1;for(var r=e.next.next;r!==e.prev;){if(n_(t.x,t.y,i.x,i.y,n.x,n.y,r.x,r.y)&&s_(r.prev,r,r.next)>=0)return!1;r=r.next}return!0}function Zg(e,t,i,n){var r=e.prev,s=e,a=e.next;if(s_(r,s,a)>=0)return!1;for(var o=r.x<s.x?r.x<a.x?r.x:a.x:s.x<a.x?s.x:a.x,h=r.y<s.y?r.y<a.y?r.y:a.y:s.y<a.y?s.y:a.y,c=r.x>s.x?r.x>a.x?r.x:a.x:s.x>a.x?s.x:a.x,l=r.y>s.y?r.y>a.y?r.y:a.y:s.y>a.y?s.y:a.y,u=t_(o,h,t,i,n),d=t_(c,l,t,i,n),p=e.prevZ,m=e.nextZ;p&&p.z>=u&&m&&m.z<=d;){if(p!==e.prev&&p!==e.next&&n_(r.x,r.y,s.x,s.y,a.x,a.y,p.x,p.y)&&s_(p.prev,p,p.next)>=0)return!1;if(p=p.prevZ,m!==e.prev&&m!==e.next&&n_(r.x,r.y,s.x,s.y,a.x,a.y,m.x,m.y)&&s_(m.prev,m,m.next)>=0)return!1;m=m.nextZ}for(;p&&p.z>=u;){if(p!==e.prev&&p!==e.next&&n_(r.x,r.y,s.x,s.y,a.x,a.y,p.x,p.y)&&s_(p.prev,p,p.next)>=0)return!1;p=p.prevZ}for(;m&&m.z<=d;){if(m!==e.prev&&m!==e.next&&n_(r.x,r.y,s.x,s.y,a.x,a.y,m.x,m.y)&&s_(m.prev,m,m.next)>=0)return!1;m=m.nextZ}return!0}function Yg(e,t,i){var n=e;do{var r=n.prev,s=n.next.next;!a_(r,s)&&o_(r,n,n.next,s)&&l_(r,s)&&l_(s,r)&&(t.push(r.i/i),t.push(n.i/i),t.push(s.i/i),p_(n),p_(n.next),n=e=s),n=n.next}while(n!==e);return Wg(n)}function Jg(e,t,i,n,r,s){var a=e;do{for(var o=a.next.next;o!==a.prev;){if(a.i!==o.i&&r_(a,o)){var h=u_(a,o);return a=Wg(a,a.next),h=Wg(h,h.next),qg(a,t,i,n,r,s),void qg(h,t,i,n,r,s)}o=o.next}a=a.next}while(a!==e)}function Kg(e,t){return e.x-t.x}function Qg(e,t){var i=function(e,t){var i,n=t,r=e.x,s=e.y,a=-1/0;do{if(s<=n.y&&s>=n.next.y&&n.next.y!==n.y){var o=n.x+(s-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(o<=r&&o>a){if(a=o,o===r){if(s===n.y)return n;if(s===n.next.y)return n.next}i=n.x<n.next.x?n:n.next}}n=n.next}while(n!==t);if(!i)return null;if(r===a)return i;var h,c=i,l=i.x,u=i.y,d=1/0;n=i;do{r>=n.x&&n.x>=l&&r!==n.x&&n_(s<u?r:a,s,l,u,s<u?a:r,s,n.x,n.y)&&(h=Math.abs(s-n.y)/(r-n.x),l_(n,e)&&(h<d||h===d&&(n.x>i.x||n.x===i.x&&e_(i,n)))&&(i=n,d=h)),n=n.next}while(n!==c);return i}(e,t);if(!i)return t;var n=u_(i,e),r=Wg(i,i.next);return Wg(n,n.next),t===i?r:t}function e_(e,t){return s_(e.prev,e,t.prev)<0&&s_(t.next,e,e.next)<0}function t_(e,t,i,n,r){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-i)*r)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-n)*r)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function i_(e){var t=e,i=e;do{(t.x<i.x||t.x===i.x&&t.y<i.y)&&(i=t),t=t.next}while(t!==e);return i}function n_(e,t,i,n,r,s,a,o){return(r-a)*(t-o)-(e-a)*(s-o)>=0&&(e-a)*(n-o)-(i-a)*(t-o)>=0&&(i-a)*(s-o)-(r-a)*(n-o)>=0}function r_(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){var i=e;do{if(i.i!==e.i&&i.next.i!==e.i&&i.i!==t.i&&i.next.i!==t.i&&o_(i,i.next,e,t))return!0;i=i.next}while(i!==e);return!1}(e,t)&&(l_(e,t)&&l_(t,e)&&function(e,t){var i=e,n=!1,r=(e.x+t.x)/2,s=(e.y+t.y)/2;do{i.y>s!=i.next.y>s&&i.next.y!==i.y&&r<(i.next.x-i.x)*(s-i.y)/(i.next.y-i.y)+i.x&&(n=!n),i=i.next}while(i!==e);return n}(e,t)&&(s_(e.prev,e,t.prev)||s_(e,t.prev,t))||a_(e,t)&&s_(e.prev,e,e.next)>0&&s_(t.prev,t,t.next)>0)}function s_(e,t,i){return(t.y-e.y)*(i.x-t.x)-(t.x-e.x)*(i.y-t.y)}function a_(e,t){return e.x===t.x&&e.y===t.y}function o_(e,t,i,n){var r=c_(s_(e,t,i)),s=c_(s_(e,t,n)),a=c_(s_(i,n,e)),o=c_(s_(i,n,t));return r!==s&&a!==o||(!(0!==r||!h_(e,i,t))||(!(0!==s||!h_(e,n,t))||(!(0!==a||!h_(i,e,n))||!(0!==o||!h_(i,t,n)))))}function h_(e,t,i){return t.x<=Math.max(e.x,i.x)&&t.x>=Math.min(e.x,i.x)&&t.y<=Math.max(e.y,i.y)&&t.y>=Math.min(e.y,i.y)}function c_(e){return e>0?1:e<0?-1:0}function l_(e,t){return s_(e.prev,e,e.next)<0?s_(e,t,e.next)>=0&&s_(e,e.prev,t)>=0:s_(e,t,e.prev)<0||s_(e,e.next,t)<0}function u_(e,t){var i=new m_(e.i,e.x,e.y),n=new m_(t.i,t.x,t.y),r=e.next,s=t.prev;return e.next=t,t.prev=e,i.next=r,r.prev=i,n.next=i,i.prev=n,s.next=n,n.prev=s,n}function d_(e,t,i,n){var r=new m_(e,t,i);return n?(r.next=n.next,r.prev=n,n.next.prev=r,n.next=r):(r.prev=r,r.next=r),r}function p_(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function m_(e,t,i){this.i=e,this.x=t,this.y=i,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function f_(e,t,i,n){for(var r=0,s=t,a=i-n;s<i;s+=n)r+=(e[a]-e[s])*(e[s+1]+e[a+1]),a=s;return r}Hg.exports=jg,Hg.exports.default=jg,jg.deviation=function(e,t,i,n){var r=t&&t.length,s=r?t[0]*i:e.length,a=Math.abs(f_(e,0,s,i));if(r)for(var o=0,h=t.length;o<h;o++){var c=t[o]*i,l=o<h-1?t[o+1]*i:e.length;a-=Math.abs(f_(e,c,l,i))}var u=0;for(o=0;o<n.length;o+=3){var d=n[o]*i,p=n[o+1]*i,m=n[o+2]*i;u+=Math.abs((e[d]-e[m])*(e[p+1]-e[d+1])-(e[d]-e[p])*(e[m+1]-e[d+1]))}return 0===a&&0===u?0:Math.abs((u-a)/a)},jg.flatten=function(e){for(var t=e[0][0].length,i={vertices:[],holes:[],dimensions:t},n=0,r=0;r<e.length;r++){for(var s=0;s<e[r].length;s++)for(var a=0;a<t;a++)i.vertices.push(e[r][s][a]);r>0&&(n+=e[r-1].length,i.holes.push(n))}return i};var g_=Hg.exports,__={exports:{}};function v_(e,t){return e<t?-1:e>t?1:0}var y_=cd(Object.freeze({__proto__:null,default:class{constructor(e=[],t=v_){if(this.data=e,this.length=this.data.length,this.compare=t,this.length>0)for(let e=(this.length>>1)-1;e>=0;e--)this._down(e)}push(e){this.data.push(e),this.length++,this._up(this.length-1)}pop(){if(0===this.length)return;const e=this.data[0],t=this.data.pop();return this.length--,this.length>0&&(this.data[0]=t,this._down(0)),e}peek(){return this.data[0]}_up(e){const{data:t,compare:i}=this,n=t[e];for(;e>0;){const r=e-1>>1,s=t[r];if(i(n,s)>=0)break;t[e]=s,e=r}t[e]=n}_down(e){const{data:t,compare:i}=this,n=this.length>>1,r=t[e];for(;e<n;){let n=1+(e<<1),s=t[n];const a=n+1;if(a<this.length&&i(t[a],s)<0&&(n=a,s=t[a]),i(s,r)>=0)break;t[e]=s,e=n}t[e]=r}}}));function b_(e,t,i){var n,r,s,a;t=t||1;for(var o=0;o<e[0].length;o++){var h=e[0][o];(!o||h[0]<n)&&(n=h[0]),(!o||h[1]<r)&&(r=h[1]),(!o||h[0]>s)&&(s=h[0]),(!o||h[1]>a)&&(a=h[1])}var c=s-n,l=a-r,u=Math.min(c,l),d=u/2;if(0===u){var p=[n,r];return p.distance=0,p}for(var m=new y_(void 0,x_),f=n;f<s;f+=u)for(var g=r;g<a;g+=u)m.push(new w_(f+d,g+d,d,e));var _=function(e){for(var t=0,i=0,n=0,r=e[0],s=0,a=r.length,o=a-1;s<a;o=s++){var h=r[s],c=r[o],l=h[0]*c[1]-c[0]*h[1];i+=(h[0]+c[0])*l,n+=(h[1]+c[1])*l,t+=3*l}return 0===t?new w_(r[0][0],r[0][1],0,e):new w_(i/t,n/t,0,e)}(e),v=new w_(n+c/2,r+l/2,0,e);v.d>_.d&&(_=v);for(var y=m.length;m.length;){var b=m.pop();b.d>_.d&&(_=b,i&&console.log("found best %d after %d probes",Math.round(1e4*b.d)/1e4,y)),b.max-_.d<=t||(d=b.h/2,m.push(new w_(b.x-d,b.y-d,d,e)),m.push(new w_(b.x+d,b.y-d,d,e)),m.push(new w_(b.x-d,b.y+d,d,e)),m.push(new w_(b.x+d,b.y+d,d,e)),y+=4)}i&&(console.log("num probes: "+y),console.log("best distance: "+_.d));var x=[_.x,_.y];return x.distance=_.d,x}function x_(e,t){return t.max-e.max}function w_(e,t,i,n){this.x=e,this.y=t,this.h=i,this.d=function(e,t,i){for(var n=!1,r=1/0,s=0;s<i.length;s++)for(var a=i[s],o=0,h=a.length,c=h-1;o<h;c=o++){var l=a[o],u=a[c];l[1]>t!=u[1]>t&&e<(u[0]-l[0])*(t-l[1])/(u[1]-l[1])+l[0]&&(n=!n),r=Math.min(r,M_(e,t,l,u))}return 0===r?0:(n?1:-1)*Math.sqrt(r)}(e,t,n),this.max=this.d+this.h*Math.SQRT2}function M_(e,t,i,n){var r=i[0],s=i[1],a=n[0]-r,o=n[1]-s;if(0!==a||0!==o){var h=((e-r)*a+(t-s)*o)/(a*a+o*o);h>1?(r=n[0],s=n[1]):h>0&&(r+=a*h,s+=o*h)}return(a=e-r)*a+(o=t-s)*o}y_.default&&(y_=y_.default),__.exports=b_,__.exports.default=b_;var S_=__.exports;function T_(e,t){return e>t?1:e<t?-1:0}class C_{constructor(e=T_,t=!1){this._compare=e,this._root=null,this._size=0,this._noDuplicates=!!t}rotateLeft(e){var t=e.right;t&&(e.right=t.left,t.left&&(t.left.parent=e),t.parent=e.parent),e.parent?e===e.parent.left?e.parent.left=t:e.parent.right=t:this._root=t,t&&(t.left=e),e.parent=t}rotateRight(e){var t=e.left;t&&(e.left=t.right,t.right&&(t.right.parent=e),t.parent=e.parent),e.parent?e===e.parent.left?e.parent.left=t:e.parent.right=t:this._root=t,t&&(t.right=e),e.parent=t}_splay(e){for(;e.parent;){var t=e.parent;t.parent?t.left===e&&t.parent.left===t?(this.rotateRight(t.parent),this.rotateRight(t)):t.right===e&&t.parent.right===t?(this.rotateLeft(t.parent),this.rotateLeft(t)):t.left===e&&t.parent.right===t?(this.rotateRight(t),this.rotateLeft(t)):(this.rotateLeft(t),this.rotateRight(t)):t.left===e?this.rotateRight(t):this.rotateLeft(t)}}splay(e){for(var t,i,n,r,s;e.parent;)(i=(t=e.parent).parent)&&i.parent?((n=i.parent).left===i?n.left=e:n.right=e,e.parent=n):(e.parent=null,this._root=e),r=e.left,s=e.right,e===t.left?(i&&(i.left===t?(t.right?(i.left=t.right,i.left.parent=i):i.left=null,t.right=i,i.parent=t):(r?(i.right=r,r.parent=i):i.right=null,e.left=i,i.parent=e)),s?(t.left=s,s.parent=t):t.left=null,e.right=t,t.parent=e):(i&&(i.right===t?(t.left?(i.right=t.left,i.right.parent=i):i.right=null,t.left=i,i.parent=t):(s?(i.left=s,s.parent=i):i.left=null,e.right=i,i.parent=e)),r?(t.right=r,r.parent=t):t.right=null,e.left=t,t.parent=e)}replace(e,t){e.parent?e===e.parent.left?e.parent.left=t:e.parent.right=t:this._root=t,t&&(t.parent=e.parent)}minNode(e=this._root){if(e)for(;e.left;)e=e.left;return e}maxNode(e=this._root){if(e)for(;e.right;)e=e.right;return e}insert(e,t){var i=this._root,n=null,r=this._compare;if(this._noDuplicates)for(;i;){if(n=i,0===r(i.key,e))return;i=r(i.key,e)<0?i.right:i.left}else for(;i;)n=i,i=r(i.key,e)<0?i.right:i.left;return i={key:e,data:t,left:null,right:null,parent:n},n?r(n.key,i.key)<0?n.right=i:n.left=i:this._root=i,this.splay(i),this._size++,i}find(e){for(var t=this._root,i=this._compare;t;){var n=i(t.key,e);if(n<0)t=t.right;else{if(!(n>0))return t;t=t.left}}return null}contains(e){for(var t=this._root,i=this._compare;t;){var n=i(e,t.key);if(0===n)return!0;t=n<0?t.left:t.right}return!1}remove(e){var t=this.find(e);if(!t)return!1;if(this.splay(t),t.left)if(t.right){var i=this.minNode(t.right);i.parent!==t&&(this.replace(i,i.right),i.right=t.right,i.right.parent=i),this.replace(t,i),i.left=t.left,i.left.parent=i}else this.replace(t,t.left);else this.replace(t,t.right);return this._size--,!0}removeNode(e){if(!e)return!1;if(this.splay(e),e.left)if(e.right){var t=this.minNode(e.right);t.parent!==e&&(this.replace(t,t.right),t.right=e.right,t.right.parent=t),this.replace(e,t),t.left=e.left,t.left.parent=t}else this.replace(e,e.left);else this.replace(e,e.right);return this._size--,!0}erase(e){var t=this.find(e);if(t){this.splay(t);var i=t.left,n=t.right,r=null;i&&(i.parent=null,r=this.maxNode(i),this.splay(r),this._root=r),n&&(i?r.right=n:this._root=n,n.parent=r),this._size--}}pop(){var e=this._root,t=null;if(e){for(;e.left;)e=e.left;t={key:e.key,data:e.data},this.remove(e.key)}return t}next(e){var t=e;if(t)if(t.right)for(t=t.right;t&&t.left;)t=t.left;else for(t=e.parent;t&&t.right===e;)e=t,t=t.parent;return t}prev(e){var t=e;if(t)if(t.left)for(t=t.left;t&&t.right;)t=t.right;else for(t=e.parent;t&&t.left===e;)e=t,t=t.parent;return t}forEach(e){for(var t=this._root,i=[],n=!1,r=0;!n;)t?(i.push(t),t=t.left):i.length>0?(e(t=i.pop(),r++),t=t.right):n=!0;return this}range(e,t,i,n){const r=[],s=this._compare;let a,o=this._root;for(;0!==r.length||o;)if(o)r.push(o),o=o.left;else{if(o=r.pop(),a=s(o.key,t),a>0)break;if(s(o.key,e)>=0&&i.call(n,o))return this;o=o.right}return this}keys(){for(var e=this._root,t=[],i=[],n=!1;!n;)e?(t.push(e),e=e.left):t.length>0?(e=t.pop(),i.push(e.key),e=e.right):n=!0;return i}values(){for(var e=this._root,t=[],i=[],n=!1;!n;)e?(t.push(e),e=e.left):t.length>0?(e=t.pop(),i.push(e.data),e=e.right):n=!0;return i}at(e){for(var t=this._root,i=[],n=!1,r=0;!n;)if(t)i.push(t),t=t.left;else if(i.length>0){if(t=i.pop(),r===e)return t;r++,t=t.right}else n=!0;return null}load(e=[],t=[],i=!1){if(0!==this._size)throw new Error("bulk-load: tree is not empty");const n=e.length;return i&&A_(e,t,0,n-1,this._compare),this._root=E_(null,e,t,0,n),this._size=n,this}min(){var e=this.minNode(this._root);return e?e.key:null}max(){var e=this.maxNode(this._root);return e?e.key:null}isEmpty(){return null===this._root}get size(){return this._size}static createTree(e,t,i,n,r){return new C_(i,r).load(e,t,n)}}function E_(e,t,i,n,r){const s=r-n;if(s>0){const a=n+Math.floor(s/2),o={key:t[a],data:i[a],parent:e};return o.left=E_(o,t,i,n,a),o.right=E_(o,t,i,a+1,r),o}return null}function A_(e,t,i,n,r){if(i>=n)return;const s=e[i+n>>1];let a=i-1,o=n+1;for(;;){do{a++}while(r(e[a],s)<0);do{o--}while(r(e[o],s)>0);if(a>=o)break;let i=e[a];e[a]=e[o],e[o]=i,i=t[a],t[a]=t[o],t[o]=i}A_(e,t,i,o,r),A_(e,t,o+1,n,r)}function I_(e,t,i){null===t?(e.inOut=!1,e.otherInOut=!0):(e.isSubject===t.isSubject?(e.inOut=!t.inOut,e.otherInOut=t.otherInOut):(e.inOut=!t.otherInOut,e.otherInOut=t.isVertical()?!t.inOut:t.inOut),t&&(e.prevInResult=!R_(t,i)||t.isVertical()?t.prevInResult:t));let n=R_(e,i);e.resultTransition=n?function(e,t){let i,n=!e.inOut,r=!e.otherInOut;switch(t){case 0:i=n&&r;break;case 1:i=n||r;break;case 3:i=n^r;break;case 2:i=e.isSubject?n&&!r:r&&!n}return i?1:-1}(e,i):0}function R_(e,t){switch(e.type){case 0:switch(t){case 0:return!e.otherInOut;case 1:return e.otherInOut;case 2:return e.isSubject&&e.otherInOut||!e.isSubject&&!e.otherInOut;case 3:return!0}break;case 2:return 0===t||1===t;case 3:return 2===t;case 1:return!1}return!1}class P_{constructor(e,t,i,n,r){this.left=t,this.point=e,this.otherEvent=i,this.isSubject=n,this.type=r||0,this.inOut=!1,this.otherInOut=!1,this.prevInResult=null,this.resultTransition=0,this.otherPos=-1,this.outputContourId=-1,this.isExteriorRing=!0}isBelow(e){const t=this.point,i=this.otherEvent.point;return this.left?(t[0]-e[0])*(i[1]-e[1])-(i[0]-e[0])*(t[1]-e[1])>0:(i[0]-e[0])*(t[1]-e[1])-(t[0]-e[0])*(i[1]-e[1])>0}isAbove(e){return!this.isBelow(e)}isVertical(){return this.point[0]===this.otherEvent.point[0]}get inResult(){return 0!==this.resultTransition}clone(){const e=new P_(this.point,this.left,this.otherEvent,this.isSubject,this.type);return e.contourId=this.contourId,e.resultTransition=this.resultTransition,e.prevInResult=this.prevInResult,e.isExteriorRing=this.isExteriorRing,e.inOut=this.inOut,e.otherInOut=this.otherInOut,e}}function L_(e,t){return e[0]===t[0]&&e[1]===t[1]}const D_=134217729;function N_(e,t,i,n,r){let s,a,o,h,c=t[0],l=n[0],u=0,d=0;l>c==l>-c?(s=c,c=t[++u]):(s=l,l=n[++d]);let p=0;if(u<e&&d<i)for(l>c==l>-c?(a=c+s,o=s-(a-c),c=t[++u]):(a=l+s,o=s-(a-l),l=n[++d]),s=a,0!==o&&(r[p++]=o);u<e&&d<i;)l>c==l>-c?(a=s+c,h=a-s,o=s-(a-h)+(c-h),c=t[++u]):(a=s+l,h=a-s,o=s-(a-h)+(l-h),l=n[++d]),s=a,0!==o&&(r[p++]=o);for(;u<e;)a=s+c,h=a-s,o=s-(a-h)+(c-h),c=t[++u],s=a,0!==o&&(r[p++]=o);for(;d<i;)a=s+l,h=a-s,o=s-(a-h)+(l-h),l=n[++d],s=a,0!==o&&(r[p++]=o);return 0===s&&0!==p||(r[p++]=s),p}function $_(e){return new Float64Array(e)}const k_=$_(4),O_=$_(8),z_=$_(12),F_=$_(16),B_=$_(4);function U_(e,t,i,n,r,s){const a=(t-s)*(i-r),o=(e-r)*(n-s),h=a-o;if(0===a||0===o||a>0!=o>0)return h;const c=Math.abs(a+o);return Math.abs(h)>=33306690738754716e-32*c?h:-function(e,t,i,n,r,s,a){let o,h,c,l,u,d,p,m,f,g,_,v,y,b,x,w,M,S;const T=e-r,C=i-r,E=t-s,A=n-s;b=T*A,d=D_*T,p=d-(d-T),m=T-p,d=D_*A,f=d-(d-A),g=A-f,x=m*g-(b-p*f-m*f-p*g),w=E*C,d=D_*E,p=d-(d-E),m=E-p,d=D_*C,f=d-(d-C),g=C-f,M=m*g-(w-p*f-m*f-p*g),_=x-M,u=x-_,k_[0]=x-(_+u)+(u-M),v=b+_,u=v-b,y=b-(v-u)+(_-u),_=y-w,u=y-_,k_[1]=y-(_+u)+(u-w),S=v+_,u=S-v,k_[2]=v-(S-u)+(_-u),k_[3]=S;let I=function(e,t){let i=t[0];for(let n=1;n<e;n++)i+=t[n];return i}(4,k_),R=22204460492503146e-32*a;if(I>=R||-I>=R)return I;if(u=e-T,o=e-(T+u)+(u-r),u=i-C,c=i-(C+u)+(u-r),u=t-E,h=t-(E+u)+(u-s),u=n-A,l=n-(A+u)+(u-s),0===o&&0===h&&0===c&&0===l)return I;if(R=11093356479670487e-47*a+33306690738754706e-32*Math.abs(I),I+=T*l+A*o-(E*c+C*h),I>=R||-I>=R)return I;b=o*A,d=D_*o,p=d-(d-o),m=o-p,d=D_*A,f=d-(d-A),g=A-f,x=m*g-(b-p*f-m*f-p*g),w=h*C,d=D_*h,p=d-(d-h),m=h-p,d=D_*C,f=d-(d-C),g=C-f,M=m*g-(w-p*f-m*f-p*g),_=x-M,u=x-_,B_[0]=x-(_+u)+(u-M),v=b+_,u=v-b,y=b-(v-u)+(_-u),_=y-w,u=y-_,B_[1]=y-(_+u)+(u-w),S=v+_,u=S-v,B_[2]=v-(S-u)+(_-u),B_[3]=S;const P=N_(4,k_,4,B_,O_);b=T*l,d=D_*T,p=d-(d-T),m=T-p,d=D_*l,f=d-(d-l),g=l-f,x=m*g-(b-p*f-m*f-p*g),w=E*c,d=D_*E,p=d-(d-E),m=E-p,d=D_*c,f=d-(d-c),g=c-f,M=m*g-(w-p*f-m*f-p*g),_=x-M,u=x-_,B_[0]=x-(_+u)+(u-M),v=b+_,u=v-b,y=b-(v-u)+(_-u),_=y-w,u=y-_,B_[1]=y-(_+u)+(u-w),S=v+_,u=S-v,B_[2]=v-(S-u)+(_-u),B_[3]=S;const L=N_(P,O_,4,B_,z_);b=o*l,d=D_*o,p=d-(d-o),m=o-p,d=D_*l,f=d-(d-l),g=l-f,x=m*g-(b-p*f-m*f-p*g),w=h*c,d=D_*h,p=d-(d-h),m=h-p,d=D_*c,f=d-(d-c),g=c-f,M=m*g-(w-p*f-m*f-p*g),_=x-M,u=x-_,B_[0]=x-(_+u)+(u-M),v=b+_,u=v-b,y=b-(v-u)+(_-u),_=y-w,u=y-_,B_[1]=y-(_+u)+(u-w),S=v+_,u=S-v,B_[2]=v-(S-u)+(_-u),B_[3]=S;const D=N_(L,z_,4,B_,F_);return F_[D-1]}(e,t,i,n,r,s,c)}function V_(e,t,i){const n=U_(e[0],e[1],t[0],t[1],i[0],i[1]);return n>0?-1:n<0?1:0}function H_(e,t){const i=e.point,n=t.point;return i[0]>n[0]?1:i[0]<n[0]?-1:i[1]!==n[1]?i[1]>n[1]?1:-1:function(e,t,i,n){if(e.left!==t.left)return e.left?1:-1;if(0!==V_(i,e.otherEvent.point,t.otherEvent.point))return e.isBelow(t.otherEvent.point)?-1:1;return!e.isSubject&&t.isSubject?1:-1}(e,t,i)}function j_(e,t,i){const n=new P_(t,!1,e,e.isSubject),r=new P_(t,!0,e.otherEvent,e.isSubject);return L_(e.point,e.otherEvent.point)&&console.warn("what is that, a collapsed segment?",e),n.contourId=r.contourId=e.contourId,H_(r,e.otherEvent)>0&&(e.otherEvent.left=!0,r.left=!1),e.otherEvent.otherEvent=r,e.otherEvent=n,i.push(r),i.push(n),i}function G_(e,t){return e[0]*t[1]-e[1]*t[0]}function W_(e,t){return e[0]*t[0]+e[1]*t[1]}function q_(e,t,i){const n=function(e,t,i,n,r){const s=[t[0]-e[0],t[1]-e[1]],a=[n[0]-i[0],n[1]-i[1]];function o(e,t,i){return[e[0]+t*i[0],e[1]+t*i[1]]}const h=[i[0]-e[0],i[1]-e[1]];let c=G_(s,a),l=c*c;const u=W_(s,s);if(l>0){const t=G_(h,a)/c;if(t<0||t>1)return null;const n=G_(h,s)/c;return n<0||n>1?null:0===t||1===t?r?null:[o(e,t,s)]:0===n||1===n?r?null:[o(i,n,a)]:[o(e,t,s)]}if(c=G_(h,s),l=c*c,l>0)return null;const d=W_(s,h)/u,p=d+W_(s,a)/u,m=Math.min(d,p),f=Math.max(d,p);return m<=1&&f>=0?1===m?r?null:[o(e,m>0?m:0,s)]:0===f?r?null:[o(e,f<1?f:1,s)]:r&&0===m&&1===f?null:[o(e,m>0?m:0,s),o(e,f<1?f:1,s)]:null}(e.point,e.otherEvent.point,t.point,t.otherEvent.point),r=n?n.length:0;if(0===r)return 0;if(1===r&&(L_(e.point,t.point)||L_(e.otherEvent.point,t.otherEvent.point)))return 0;if(2===r&&e.isSubject===t.isSubject)return 0;if(1===r)return L_(e.point,n[0])||L_(e.otherEvent.point,n[0])||j_(e,n[0],i),L_(t.point,n[0])||L_(t.otherEvent.point,n[0])||j_(t,n[0],i),1;const s=[];let a=!1,o=!1;return L_(e.point,t.point)?a=!0:1===H_(e,t)?s.push(t,e):s.push(e,t),L_(e.otherEvent.point,t.otherEvent.point)?o=!0:1===H_(e.otherEvent,t.otherEvent)?s.push(t.otherEvent,e.otherEvent):s.push(e.otherEvent,t.otherEvent),a&&o||a?(t.type=1,e.type=t.inOut===e.inOut?2:3,a&&!o&&j_(s[1].otherEvent,s[0].point,i),2):o?(j_(s[0],s[1].point,i),3):s[0]!==s[3].otherEvent?(j_(s[0],s[1].point,i),j_(s[1],s[2].point,i),3):(j_(s[0],s[1].point,i),j_(s[3].otherEvent,s[2].point,i),3)}function X_(e,t){if(e===t)return 0;if(0!==V_(e.point,e.otherEvent.point,t.point)||0!==V_(e.point,e.otherEvent.point,t.otherEvent.point))return L_(e.point,t.point)?e.isBelow(t.otherEvent.point)?-1:1:e.point[0]===t.point[0]?e.point[1]<t.point[1]?-1:1:1===H_(e,t)?t.isAbove(e.point)?-1:1:e.isBelow(t.point)?-1:1;if(e.isSubject!==t.isSubject)return e.isSubject?-1:1;{let i=e.point,n=t.point;if(i[0]===n[0]&&i[1]===n[1])return i=e.otherEvent.point,n=t.otherEvent.point,i[0]===n[0]&&i[1]===n[1]?0:e.contourId>t.contourId?1:-1}return 1===H_(e,t)?1:-1}class Z_{constructor(){this.points=[],this.holeIds=[],this.holeOf=null,this.depth=null}isExterior(){return null==this.holeOf}}function Y_(e,t,i,n){let r,s=e+1,a=t[e].point;const o=t.length;for(s<o&&(r=t[s].point);s<o&&r[0]===a[0]&&r[1]===a[1];){if(!i[s])return s;s++,r=t[s].point}for(s=e-1;i[s]&&s>n;)s--;return s}function J_(e,t,i){const n=new Z_;if(null!=e.prevInResult){const r=e.prevInResult,s=r.outputContourId;if(r.resultTransition>0){const e=t[s];if(null!=e.holeOf){const r=e.holeOf;t[r].holeIds.push(i),n.holeOf=r,n.depth=t[s].depth}else t[s].holeIds.push(i),n.holeOf=s,n.depth=t[s].depth+1}else n.holeOf=null,n.depth=t[s].depth}else n.holeOf=null,n.depth=0;return n}function K_(e){let t,i;const n=function(e){let t,i,n,r;const s=[];for(i=0,n=e.length;i<n;i++)t=e[i],(t.left&&t.inResult||!t.left&&t.otherEvent.inResult)&&s.push(t);let a=!1;for(;!a;)for(a=!0,i=0,n=s.length;i<n;i++)i+1<n&&1===H_(s[i],s[i+1])&&(r=s[i],s[i]=s[i+1],s[i+1]=r,a=!1);for(i=0,n=s.length;i<n;i++)t=s[i],t.otherPos=i;for(i=0,n=s.length;i<n;i++)t=s[i],t.left||(r=t.otherPos,t.otherPos=t.otherEvent.otherPos,t.otherEvent.otherPos=r);return s}(e),r={},s=[];for(t=0,i=n.length;t<i;t++){if(r[t])continue;const e=s.length,i=J_(n[t],s,e),a=t=>{r[t]=!0,n[t].outputContourId=e};let o=t,h=t;const c=n[t].point;for(i.points.push(c);a(o),o=n[o].otherPos,a(o),i.points.push(n[o].point),o=Y_(o,n,r,h),o!=h;);s.push(i)}return s}var Q_={exports:{}};function ev(e,t){if(!(this instanceof ev))return new ev(e,t);if(this.data=e||[],this.length=this.data.length,this.compare=t||tv,this.length>0)for(var i=(this.length>>1)-1;i>=0;i--)this._down(i)}function tv(e,t){return e<t?-1:e>t?1:0}Q_.exports=ev,Q_.exports.default=ev,ev.prototype={push:function(e){this.data.push(e),this.length++,this._up(this.length-1)},pop:function(){if(0!==this.length){var e=this.data[0];return this.length--,this.length>0&&(this.data[0]=this.data[this.length],this._down(0)),this.data.pop(),e}},peek:function(){return this.data[0]},_up:function(e){for(var t=this.data,i=this.compare,n=t[e];e>0;){var r=e-1>>1,s=t[r];if(i(n,s)>=0)break;t[e]=s,e=r}t[e]=n},_down:function(e){for(var t=this.data,i=this.compare,n=this.length>>1,r=t[e];e<n;){var s=1+(e<<1),a=s+1,o=t[s];if(a<this.length&&i(t[a],o)<0&&(s=a,o=t[a]),i(o,r)>=0)break;t[e]=o,e=s}t[e]=r}};var iv=Q_.exports;const nv=Math.max,rv=Math.min;let sv=0;function av(e,t,i,n,r,s){let a,o,h,c,l,u;for(a=0,o=e.length-1;a<o;a++){if(h=e[a],c=e[a+1],l=new P_(h,!1,void 0,t),u=new P_(c,!1,l,t),l.otherEvent=u,h[0]===c[0]&&h[1]===c[1])continue;l.contourId=u.contourId=i,s||(l.isExteriorRing=!1,u.isExteriorRing=!1),H_(l,u)>0?u.left=!0:l.left=!0;const o=h[0],d=h[1];r[0]=rv(r[0],o),r[1]=rv(r[1],d),r[2]=nv(r[2],o),r[3]=nv(r[3],d),n.push(l),n.push(u)}}const ov=[];function hv(e,t,i){"number"==typeof e[0][0][0]&&(e=[e]),"number"==typeof t[0][0][0]&&(t=[t]);let n=function(e,t,i){let n=null;return e.length*t.length==0&&(0===i?n=ov:2===i?n=e:1!==i&&3!==i||(n=0===e.length?t:e)),n}(e,t,i);if(n)return n===ov?null:n;const r=[1/0,1/0,-1/0,-1/0],s=[1/0,1/0,-1/0,-1/0],a=function(e,t,i,n,r){const s=new iv(null,H_);let a,o,h,c,l,u;for(h=0,c=e.length;h<c;h++)for(a=e[h],l=0,u=a.length;l<u;l++)o=0===l,o&&sv++,av(a[l],!0,sv,s,i,o);for(h=0,c=t.length;h<c;h++)for(a=t[h],l=0,u=a.length;l<u;l++)o=0===l,2===r&&(o=!1),o&&sv++,av(a[l],!1,sv,s,n,o);return s}(e,t,r,s,i);if(n=function(e,t,i,n,r){let s=null;return(i[0]>n[2]||n[0]>i[2]||i[1]>n[3]||n[1]>i[3])&&(0===r?s=ov:2===r?s=e:1!==r&&3!==r||(s=e.concat(t))),s}(e,t,r,s,i),n)return n===ov?null:n;const o=K_(function(e,t,i,n,r,s){const a=new C_(X_),o=[],h=Math.min(n[2],r[2]);let c,l,u;for(;0!==e.length;){let t=e.pop();if(o.push(t),0===s&&t.point[0]>h||2===s&&t.point[0]>n[2])break;if(t.left){l=c=a.insert(t),u=a.minNode(),c=c!==u?a.prev(c):null,l=a.next(l);const i=c?c.key:null;let n;if(I_(t,i,s),l&&2===q_(t,l.key,e)&&(I_(t,i,s),I_(t,l.key,s)),c&&2===q_(c.key,t,e)){let e=c;e=e!==u?a.prev(e):null,n=e?e.key:null,I_(i,n,s),I_(t,i,s)}}else t=t.otherEvent,l=c=a.find(t),c&&l&&(c=c!==u?a.prev(c):null,l=a.next(l),a.remove(t),l&&c&&q_(c.key,l.key,e))}return o}(a,0,0,r,s,i)),h=[];for(let e=0;e<o.length;e++){let t=o[e];if(t.isExterior()){let e=[t.points];for(let i=0;i<t.holeIds.length;i++){let n=t.holeIds[i];e.push(o[n].points)}h.push(e)}}return h}class cv extends Fg{constructor(){super(),this._subsampleThreshold=.005}_getPoleOfInaccessibility2d(e){return S_([e],.03)}_project(e,t){const i=this._createCamera(t.upVector().toArray(),t.unprojectSfM([0,0],0),t.unprojectSfM([0,0],10));return this._deunproject(e,t,i)}_subsample(e,t=this._subsampleThreshold){const i=[],n=e.length;for(let r=0;r<n;r++){const s=e[r],a=e[(r+1)%n];i.push(s);const o=Math.sqrt(Math.pow(a[0]-s[0],2)+Math.pow(a[1]-s[1],2)),h=Math.floor(o/t),c=1/(h+1);for(let e=1;e<=h;e++){const t=e*c,n=[(1-t)*s[0]+t*a[0],(1-t)*s[1]+t*a[1]];i.push(n)}}return i}_triangulate(e,t,i,n){let r=[e.slice(0,-1)];for(let e of null!=i?i:[])r.push(e.slice(0,-1));let s=t.slice(0,-1);for(let e of null!=n?n:[])s=s.concat(e.slice(0,-1));let a=g_.flatten(r),o=g_(a.vertices,a.holes,a.dimensions),h=[];for(let e=0;e<o.length;++e){let t=s[o[e]];h.push(t[0]),h.push(t[1]),h.push(t[2])}return h}_triangulateSpherical(e,t,i){const n=[],r=1e-9;for(let s=0;s<3;s++)for(let a=0;a<3;a++){const o=s/3+(0===s?-1e-9:r),h=a/3+(0===a?-1e-9:r),c=(s+1)/3+r,l=(a+1)/3+r,u=[[o,h],[o,l],[c,l],[c,h],[o,h]],d=[(2*s+1)/6,(2*a+1)/6];n.push(...this._triangulateSubarea(e,t,u,d,i))}return n}_unproject(e,t,i=200){return e.map((e=>t.unprojectBasic(e,i)))}_createCamera(e,t,i){const n=new os;return n.up.copy((new Ki).fromArray(e)),n.position.copy((new Ki).fromArray(t)),n.lookAt((new Ki).fromArray(i)),n.updateMatrix(),n.updateMatrixWorld(!0),n}_deunproject(e,t,i){return e.map((e=>{const n=t.unprojectBasic(e,1e4),r=new Ki(n[0],n[1],n[2]).applyMatrix4(i.matrixWorldInverse);return[r.x/r.z,r.y/r.z]}))}_triangulateSubarea(e,t,i,n,r){const s=hv([e,...t],[i],0);if(!s)return[];const a=[],o=this._subsampleThreshold,h=this._createCamera(r.upVector().toArray(),r.unprojectSfM([0,0],0),r.unprojectBasic(n,10));for(const e of s){const t=this._subsample(e[0],o),i=this._deunproject(t,r,h),n=this._unproject(t,r),s=[],c=[];for(let t=1;t<e.length;t++){let i=this._subsample(e[t],o);const n=this._deunproject(i,r,h),a=this._unproject(i,r);s.push(n),c.push(a)}a.push(...this._triangulate(i,n,s,c))}return a}}class lv extends cv{constructor(e){if(super(),4!==e.length)throw new Bg("Rectangle needs to have four values.");if(e[1]>e[3])throw new Bg("Basic Y coordinates values can not be inverted.");for(let t of e)if(t<0||t>1)throw new Bg("Basic coordinates must be on the interval [0, 1].");this._anchorIndex=void 0,this._rect=e.slice(0,4),this._inverted=this._rect[0]>this._rect[2]}get anchorIndex(){return this._anchorIndex}get inverted(){return this._inverted}get rect(){return this._rect}initializeAnchorIndexing(e){if(void 0!==this._anchorIndex)throw new Bg("Anchor indexing is already initialized.");if(e<0||e>3)throw new Bg(`Invalid anchor index: ${e}.`);this._anchorIndex=void 0===e?0:e}terminateAnchorIndexing(){this._anchorIndex=void 0}setOppositeVertex2d(e,t){if(void 0===this._anchorIndex)throw new Bg("Anchor indexing needs to be initialized.");const i=[Math.max(0,Math.min(1,e[0])),Math.max(0,Math.min(1,e[1]))],n=this._rect.slice(),r=0===this._anchorIndex?[n[0],n[3]]:1===this._anchorIndex?[n[0],n[1]]:2===this._anchorIndex?[n[2],n[1]]:[n[2],n[3]];if($u(t.cameraType)){const e=this._anchorIndex<2?i[0]-n[2]:i[0]-n[0];!this._inverted&&this._anchorIndex<2&&i[0]<.25&&n[2]>.75&&e<-.5||!this._inverted&&this._anchorIndex>=2&&i[0]<.25&&n[2]>.75&&e<-.5?(this._inverted=!0,this._anchorIndex=r[1]>i[1]?0:1):this._inverted&&this._anchorIndex>=2&&i[0]<.25&&n[0]>.75&&e<-.5?(this._inverted=!1,this._anchorIndex=r[0]>i[0]?r[1]>i[1]?3:2:r[1]>i[1]?0:1):!this._inverted&&this._anchorIndex>=2&&i[0]>.75&&n[0]<.25&&e>.5||!this._inverted&&this._anchorIndex<2&&i[0]>.75&&n[0]<.25&&e>.5?(this._inverted=!0,this._anchorIndex=r[1]>i[1]?3:2):this._inverted&&this._anchorIndex<2&&i[0]>.75&&n[2]<.25&&e>.5?(this._inverted=!1,this._anchorIndex=r[0]>i[0]?r[1]>i[1]?3:2:r[1]>i[1]?0:1):this._inverted&&this._anchorIndex<2&&i[0]>n[0]?(this._inverted=!1,this._anchorIndex=r[1]>i[1]?0:1):this._inverted&&this._anchorIndex>=2&&i[0]<n[2]?(this._inverted=!1,this._anchorIndex=r[1]>i[1]?3:2):this._inverted?this._anchorIndex<2?this._anchorIndex=r[1]>i[1]?0:1:this._anchorIndex=r[1]>i[1]?3:2:this._anchorIndex=r[0]<=i[0]&&r[1]>i[1]?0:r[0]<=i[0]&&r[1]<=i[1]?1:r[0]>i[0]&&r[1]<=i[1]?2:3;const t=[];0===this._anchorIndex?(t[0]=r[0],t[1]=i[1],t[2]=i[0],t[3]=r[1]):1===this._anchorIndex?(t[0]=r[0],t[1]=r[1],t[2]=i[0],t[3]=i[1]):2===this._anchorIndex?(t[0]=i[0],t[1]=r[1],t[2]=r[0],t[3]=i[1]):(t[0]=i[0],t[1]=i[1],t[2]=r[0],t[3]=r[1]),(!this._inverted&&t[0]>t[2]||this._inverted&&t[0]<t[2])&&(t[0]=n[0],t[2]=n[2]),t[1]>t[3]&&(t[1]=n[1],t[3]=n[3]),this._rect[0]=t[0],this._rect[1]=t[1],this._rect[2]=t[2],this._rect[3]=t[3]}else{this._anchorIndex=r[0]<=i[0]&&r[1]>i[1]?0:r[0]<=i[0]&&r[1]<=i[1]?1:r[0]>i[0]&&r[1]<=i[1]?2:3;const e=[];0===this._anchorIndex?(e[0]=r[0],e[1]=i[1],e[2]=i[0],e[3]=r[1]):1===this._anchorIndex?(e[0]=r[0],e[1]=r[1],e[2]=i[0],e[3]=i[1]):2===this._anchorIndex?(e[0]=i[0],e[1]=r[1],e[2]=r[0],e[3]=i[1]):(e[0]=i[0],e[1]=i[1],e[2]=r[0],e[3]=r[1]),e[0]>e[2]&&(e[0]=n[0],e[2]=n[2]),e[1]>e[3]&&(e[1]=n[1],e[3]=n[3]),this._rect[0]=e[0],this._rect[1]=e[1],this._rect[2]=e[2],this._rect[3]=e[3]}this._notifyChanged$.next(this)}setVertex2d(e,t,i){let n=this._rect.slice(),r=[Math.max(0,Math.min(1,t[0])),Math.max(0,Math.min(1,t[1]))],s=[];if(0===e?(s[0]=r[0],s[1]=n[1],s[2]=n[2],s[3]=r[1]):1===e?(s[0]=r[0],s[1]=r[1],s[2]=n[2],s[3]=n[3]):2===e?(s[0]=n[0],s[1]=r[1],s[2]=r[0],s[3]=n[3]):3===e&&(s[0]=n[0],s[1]=n[1],s[2]=r[0],s[3]=r[1]),$u(i.cameraType)){let t=e<2&&r[0]>.75&&n[0]<.25||e>=2&&this._inverted&&r[0]>.75&&n[2]<.25,i=e<2&&this._inverted&&r[0]<.25&&n[0]>.75||e>=2&&r[0]<.25&&n[2]>.75;t||i?this._inverted=!this._inverted:(s[0]-n[0]<-.25&&(s[0]=n[0]),s[2]-n[2]>.25&&(s[2]=n[2])),(!this._inverted&&s[0]>s[2]||this._inverted&&s[0]<s[2])&&(s[0]=n[0],s[2]=n[2])}else s[0]>s[2]&&(s[0]=n[0],s[2]=n[2]);s[1]>s[3]&&(s[1]=n[1],s[3]=n[3]),this._rect[0]=s[0],this._rect[1]=s[1],this._rect[2]=s[2],this._rect[3]=s[3],this._notifyChanged$.next(this)}setCentroid2d(e,t){let i=this._rect.slice(),n=i[0],r=this._inverted?i[2]+1:i[2],s=i[1],a=i[3],o=n+(r-n)/2,h=s+(a-s)/2,c=0;if($u(t.cameraType))c=this._inverted?e[0]+1-o:e[0]-o;else{let t=-n,i=1-r;c=Math.max(t,Math.min(i,e[0]-o))}let l=-s,u=1-a,d=Math.max(l,Math.min(u,e[1]-h));this._rect[0]=i[0]+c,this._rect[1]=i[1]+d,this._rect[2]=i[2]+c,this._rect[3]=i[3]+d,this._rect[0]<0?(this._rect[0]+=1,this._inverted=!this._inverted):this._rect[0]>1&&(this._rect[0]-=1,this._inverted=!this._inverted),this._rect[2]<0?(this._rect[2]+=1,this._inverted=!this._inverted):this._rect[2]>1&&(this._rect[2]-=1,this._inverted=!this._inverted),this._notifyChanged$.next(this)}getPoints3d(e){return this._getPoints2d().map((t=>e.unprojectBasic(t,200)))}getVertex2d(e){return this._rectToVertices2d(this._rect)[e]}getNonAdjustedVertex2d(e){return this._rectToNonAdjustedVertices2d(this._rect)[e]}getVertex3d(e,t){return t.unprojectBasic(this._rectToVertices2d(this._rect)[e],200)}getVertices2d(){return this._rectToVertices2d(this._rect)}getVertices3d(e){return this._rectToVertices2d(this._rect).map((t=>e.unprojectBasic(t,200)))}getCentroid2d(){const e=this._rect;return[(e[0]+(this._inverted?e[2]+1:e[2]))/2,(e[1]+e[3])/2]}getCentroid3d(e){const t=this.getCentroid2d();return e.unprojectBasic(t,200)}getPoleOfInaccessibility2d(){return this._getPoleOfInaccessibility2d(this._rectToVertices2d(this._rect))}getPoleOfInaccessibility3d(e){let t=this._getPoleOfInaccessibility2d(this._rectToVertices2d(this._rect));return e.unprojectBasic(t,200)}getTriangles3d(e){return $u(e.cameraType)?[]:this._triangulate(this._project(this._getPoints2d(),e),this.getPoints3d(e))}validate(e){let t=this._rect;return!(!this._inverted&&e[0]<t[0]||e[0]-t[2]>.25||e[1]<t[1])}_getPoints2d(){let e=this._rectToVertices2d(this._rect),t=e.length-1,i=[];for(let n=0;n<t;++n){let t=e[n][0],r=e[n][1],s=(e[n+1][0]-t)/9,a=(e[n+1][1]-r)/9;for(let e=0;e<10;++e){let n=[t+e*s,r+e*a];i.push(n)}}return i}_rectToVertices2d(e){return[[e[0],e[3]],[e[0],e[1]],[this._inverted?e[2]+1:e[2],e[1]],[this._inverted?e[2]+1:e[2],e[3]],[e[0],e[3]]]}_rectToNonAdjustedVertices2d(e){return[[e[0],e[3]],[e[0],e[1]],[e[2],e[1]],[e[2],e[3]],[e[0],e[3]]]}}class uv extends Vg{constructor(e,t,i,n){super(e,i,n),this._options={color:null==t.color?16777215:t.color,indicateCompleter:null==t.indicateCompleter||t.indicateCompleter},this._rectGeometry=new lv(this._geometry.getRect2d(i)),this._createGlObjects()}create(){this._geometry.points.length<3||(this._geometry.removePoint2d(this._geometry.points.length-1),this._created$.next(this))}dispose(){super.dispose(),this._disposeObjects()}getDOMObjects(e,t){const i={offsetHeight:t.height,offsetWidth:t.width},n=[],r=this._geometry.getPoints2d(),s=r.length;for(let t=0;t<s-1;t++){const a=t,[o,h]=r[t],c=this._viewportCoords.basicToCanvasSafe(o,h,i,this._transform,e);if(!c)continue;const l=e=>{e.stopPropagation(),this._aborted$.next(this)},u=e=>{e.stopPropagation(),this._geometry.removePoint2d(a)},d=this._canvasToTransform(c),p={onclick:0===t&&s<3?l:u,style:{transform:d}};n.push(tf.h("div.mapillary-tag-interactor",p,[]));const m={style:{background:this._colorToBackground(this._options.color),transform:d}};n.push(tf.h("div.mapillary-tag-vertex",m,[]))}if(s>2&&!0===this._options.indicateCompleter){const[t,r]=this._geometry.getCentroid2d(this._transform),s=this._viewportCoords.basicToCanvasSafe(t,r,i,this._transform,e);if(s){const e=e=>{e.stopPropagation(),this._geometry.removePoint2d(this._geometry.points.length-1),this._created$.next(this)},t=this._canvasToTransform(s),i={onclick:e,style:{transform:t}};n.push(tf.h("div.mapillary-tag-completer.mapillary-tag-larger",i,[]));const r={style:{background:this._colorToBackground(this._options.color),transform:t}};n.push(tf.h("div.mapillary-tag-vertex.mapillary-tag-larger",r,[]));const a={style:{transform:t}};n.push(tf.h("div.mapillary-tag-dot",a,[]))}}return n}_onGeometryChanged(){this._disposeObjects(),this._rectGeometry=new lv(this._geometry.getRect2d(this._transform)),this._createGlObjects()}_createGlObjects(){this._glObjects=[];const e=this._rectGeometry.getPoints3d(this._transform);this._outline=this._createOutine(e,this._options.color),this._glObjects.push(this._outline)}_disposeObjects(){this._disposeLine(this._outline),this._outline=null,this._glObjects=null}}class dv extends cv{constructor(e,t){super();let i=e.length;if(i<3)throw new Bg("A polygon must have three or more positions.");if(e[0][0]!==e[i-1][0]||e[0][1]!==e[i-1][1])throw new Bg("First and last positions must be equivalent.");this._polygon=[];for(let t of e){if(t[0]<0||t[0]>1||t[1]<0||t[1]>1)throw new Bg("Basic coordinates of polygon must be on the interval [0, 1].");this._polygon.push(t.slice())}if(this._holes=[],null!=t)for(let e=0;e<t.length;e++){let i=t[e],n=i.length;if(n<3)throw new Bg("A polygon hole must have three or more positions.");if(i[0][0]!==i[n-1][0]||i[0][1]!==i[n-1][1])throw new Bg("First and last positions of hole must be equivalent.");this._holes.push([]);for(let t of i){if(t[0]<0||t[0]>1||t[1]<0||t[1]>1)throw new Bg("Basic coordinates of hole must be on the interval [0, 1].");this._holes[e].push(t.slice())}}}get polygon(){return this._polygon}get holes(){return this._holes}addVertex2d(e){let t=[Math.max(0,Math.min(1,e[0])),Math.max(0,Math.min(1,e[1]))];this._polygon.splice(this._polygon.length-1,0,t),this._notifyChanged$.next(this)}getVertex2d(e){return this._polygon[e].slice()}removeVertex2d(e){if(e<0||e>=this._polygon.length||this._polygon.length<4)throw new Bg("Index for removed vertex must be valid.");if(e>0&&e<this._polygon.length-1)this._polygon.splice(e,1);else{this._polygon.splice(0,1),this._polygon.pop();let e=this._polygon[0].slice();this._polygon.push(e)}this._notifyChanged$.next(this)}setVertex2d(e,t,i){let n=[Math.max(0,Math.min(1,t[0])),Math.max(0,Math.min(1,t[1]))];0===e||e===this._polygon.length-1?(this._polygon[0]=n.slice(),this._polygon[this._polygon.length-1]=n.slice()):this._polygon[e]=n.slice(),this._notifyChanged$.next(this)}setCentroid2d(e,t){let i=this._polygon.map((e=>e[0])),n=this._polygon.map((e=>e[1])),r=Math.min.apply(Math,i),s=Math.max.apply(Math,i),a=Math.min.apply(Math,n),o=Math.max.apply(Math,n),h=this.getCentroid2d(),c=-r,l=1-s,u=-a,d=1-o,p=Math.max(c,Math.min(l,e[0]-h[0])),m=Math.max(u,Math.min(d,e[1]-h[1]));for(let e of this._polygon)e[0]+=p,e[1]+=m;this._notifyChanged$.next(this)}getPoints3d(e){return this._getPoints3d(this._subsample(this._polygon),e)}getVertex3d(e,t){return t.unprojectBasic(this._polygon[e],200)}getVertices2d(){return this._polygon.slice()}getVertices3d(e){return this._getPoints3d(this._polygon,e)}getHolePoints3d(e){return this._holes.map((t=>this._getPoints3d(this._subsample(t),e)))}getHoleVertices3d(e){return this._holes.map((t=>this._getPoints3d(t,e)))}getCentroid2d(){let e=this._polygon,t=0,i=0,n=0;for(let r=0;r<e.length-1;r++){let s=e[r][0],a=e[r][1],o=e[r+1][0],h=e[r+1][1],c=s*h-o*a;t+=c,i+=(s+o)*c,n+=(a+h)*c}return t/=2,i/=6*t,n/=6*t,[i,n]}getCentroid3d(e){let t=this.getCentroid2d();return e.unprojectBasic(t,200)}get3dDomainTriangles3d(e){return this._triangulate(this._project(this._polygon,e),this.getVertices3d(e),this._holes.map((t=>this._project(t,e))),this.getHoleVertices3d(e))}getTriangles3d(e){if($u(e.cameraType))return this._triangulateSpherical(this._polygon.slice(),this.holes.slice(),e);const t=this._project(this._subsample(this._polygon),e),i=this.getPoints3d(e),n=this._holes.map((t=>this._project(this._subsample(t),e))),r=this.getHolePoints3d(e);return this._triangulate(t,i,n,r)}getPoleOfInaccessibility2d(){return this._getPoleOfInaccessibility2d(this._polygon.slice())}getPoleOfInaccessibility3d(e){let t=this._getPoleOfInaccessibility2d(this._polygon.slice());return e.unprojectBasic(t,200)}_getPoints3d(e,t){return e.map((e=>t.unprojectBasic(e,200)))}}class pv extends Vg{constructor(e,t,i,n){super(e,i,n),this._options={color:null==t.color?16777215:t.color},this._createGlObjects()}create(){if(this._geometry instanceof lv)this._created$.next(this);else if(this._geometry instanceof dv){const e=this._geometry;e.removeVertex2d(e.polygon.length-2),this._created$.next(this)}}dispose(){super.dispose(),this._disposeLine(this._outline),this._disposeObjects()}getDOMObjects(e,t){const i=[],n={offsetHeight:t.height,offsetWidth:t.width},r=e=>{e.stopPropagation(),this._aborted$.next(this)};if(this._geometry instanceof lv){const t=this._geometry.anchorIndex,s=void 0===t?1:t,[a,o]=this._geometry.getVertex2d(s),h=this._viewportCoords.basicToCanvasSafe(a,o,n,this._transform,e);if(null!=h){const e=this._colorToBackground(this._options.color),t=this._canvasToTransform(h),n={style:{background:e,transform:t}},s={onclick:r,style:{transform:t}};i.push(tf.h("div.mapillary-tag-interactor",s,[])),i.push(tf.h("div.mapillary-tag-vertex",n,[]))}}else if(this._geometry instanceof dv){const t=this._geometry,[s,a]=t.getVertex2d(0),o=this._viewportCoords.basicToCanvasSafe(s,a,n,this._transform,e);if(null!=o){const e={onclick:t.polygon.length>4?e=>{e.stopPropagation(),t.removeVertex2d(t.polygon.length-2),this._created$.next(this)}:r,style:{transform:this._canvasToTransform(o)}},n=t.polygon.length>4?"mapillary-tag-completer":"mapillary-tag-interactor";i.push(tf.h("div."+n,e,[]))}if(t.polygon.length>3){const[r,s]=t.getVertex2d(t.polygon.length-3),a=this._viewportCoords.basicToCanvasSafe(r,s,n,this._transform,e);if(null!=a){const e={onclick:e=>{e.stopPropagation(),t.removeVertex2d(t.polygon.length-3)},style:{transform:this._canvasToTransform(a)}};i.push(tf.h("div.mapillary-tag-interactor",e,[]))}}const h=t.polygon.slice();h.splice(-2,2);for(const t of h){const r=this._viewportCoords.basicToCanvasSafe(t[0],t[1],n,this._transform,e);if(null!=r){const e={style:{background:this._colorToBackground(this._options.color),transform:this._canvasToTransform(r)}};i.push(tf.h("div.mapillary-tag-vertex",e,[]))}}}return i}addPoint(e){if(this._geometry instanceof lv){if(!this._geometry.validate(e))return;this._created$.next(this)}else if(this._geometry instanceof dv){this._geometry.addVertex2d(e)}}_onGeometryChanged(){this._disposeLine(this._outline),this._disposeObjects(),this._createGlObjects()}_disposeObjects(){this._outline=null,this._glObjects=[]}_createGlObjects(){const e=this._geometry instanceof lv?this._geometry.getPoints3d(this._transform):this._geometry.getVertices3d(this._transform);this._outline=this._createOutine(e,this._options.color),this._glObjects=[this._outline]}}class mv{constructor(e,t){this._component=e,this._navigator=t,this._tagOperation$=new j,this._createPoints$=new j,this._createPolygon$=new j,this._createRect$=new j,this._delete$=new j,this._tag$=this._tagOperation$.pipe(Lt(((e,t)=>t(e)),null),Dt()),this._replayedTag$=this._tag$.pipe(Rt(1),U()),this._replayedTag$.subscribe(),this._createPoints$.pipe(Vt(this._component.configuration$,this._navigator.stateService.currentTransform$),De((([e,t,i])=>()=>{const n=new Ug([[e[0],e[1]],[e[0],e[1]]]);return new uv(n,{color:t.createColor,indicateCompleter:t.indicatePointsCompleter},i)}))).subscribe(this._tagOperation$),this._createRect$.pipe(Vt(this._component.configuration$,this._navigator.stateService.currentTransform$),De((([e,t,i])=>()=>{const n=new lv([e[0],e[1],e[0],e[1]]);return new pv(n,{color:t.createColor},i)}))).subscribe(this._tagOperation$),this._createPolygon$.pipe(Vt(this._component.configuration$,this._navigator.stateService.currentTransform$),De((([e,t,i])=>()=>{const n=new dv([[e[0],e[1]],[e[0],e[1]],[e[0],e[1]]]);return new pv(n,{color:t.createColor},i)}))).subscribe(this._tagOperation$),this._delete$.pipe(De((()=>()=>null))).subscribe(this._tagOperation$)}get createRect$(){return this._createRect$}get createPolygon$(){return this._createPolygon$}get createPoints$(){return this._createPoints$}get delete$(){return this._delete$}get tag$(){return this._tag$}get replayedTag$(){return this._replayedTag$}}class fv{render(e,t,i,n,r){let s=[];for(const t of e)s=s.concat(t.getDOMObjects(i,n,r));return null!=t&&(s=s.concat(t.getDOMObjects(n,r))),tf.h("div.mapillary-tag-container",{},s)}clear(){return tf.h("div",{},[])}}class gv{constructor(e,t){this._createTag=null,this._needsRender=!1,this._raycaster=t||new su,this._scene=e||new ch,this._objectTags={},this._retrievableObjects=[],this._tags={}}get needsRender(){return this._needsRender}add(e){for(let t of e)t.tag.id in this._tags&&this._remove(t.tag.id),this._add(t);this._needsRender=!0}addCreateTag(e){for(const t of e.glObjects)this._scene.add(t);this._createTag={tag:e,objects:e.glObjects},this._needsRender=!0}clear(){for(const e of Object.keys(this._tags))this._remove(e);this._needsRender=!1}get(e){return this.has(e)?this._tags[e].tag:void 0}has(e){return e in this._tags}hasCreateTag(){return null!=this._createTag}intersectObjects([e,t],i){this._raycaster.setFromCamera(new zi(e,t),i);const n=this._raycaster.intersectObjects(this._retrievableObjects),r=[];for(const e of n)e.object.uuid in this._objectTags&&r.push(this._objectTags[e.object.uuid]);return r}remove(e){for(const t of e)this._remove(t);this._needsRender=!0}removeAll(){for(const e of Object.keys(this._tags))this._remove(e);this._needsRender=!0}removeCreateTag(){if(null!=this._createTag){for(const e of this._createTag.objects)this._scene.remove(e);this._createTag.tag.dispose(),this._createTag=null,this._needsRender=!0}}render(e,t){t.render(this._scene,e),this._needsRender=!1}update(){this._needsRender=!0}updateCreateTagObjects(e){if(this._createTag.tag!==e)throw new Error("Create tags do not have the same reference.");for(let e of this._createTag.objects)this._scene.remove(e);for(const t of e.glObjects)this._scene.add(t);this._createTag.objects=e.glObjects,this._needsRender=!0}updateObjects(e){const t=e.tag.id;if(this._tags[t].tag!==e)throw new Error("Tags do not have the same reference.");const i=this._tags[t];this._removeObjects(i),delete this._tags[t],this._add(e),this._needsRender=!0}_add(e){const t=e.tag.id,i={tag:e,objects:[],retrievableObjects:[]};this._tags[t]=i;for(const t of e.getGLObjects())i.objects.push(t),this._scene.add(t);for(const t of e.getRetrievableObjects())i.retrievableObjects.push(t),this._retrievableObjects.push(t),this._objectTags[t.uuid]=e.tag.id}_remove(e){const t=this._tags[e];this._removeObjects(t),t.tag.dispose(),delete this._tags[e]}_removeObjects(e){for(const t of e.objects)this._scene.remove(t);for(const t of e.retrievableObjects){const e=this._retrievableObjects.indexOf(t);-1!==e&&this._retrievableObjects.splice(e,1)}}}var _v,vv,yv,bv;e.TagMode=void 0,(_v=e.TagMode||(e.TagMode={}))[_v.Default=0]="Default",_v[_v.CreatePoint=1]="CreatePoint",_v[_v.CreatePoints=2]="CreatePoints",_v[_v.CreatePolygon=3]="CreatePolygon",_v[_v.CreateRect=4]="CreateRect",_v[_v.CreateRectDrag=5]="CreateRectDrag",function(e){e[e.None=0]="None",e[e.Centroid=1]="Centroid",e[e.Vertex=2]="Vertex"}(vv||(vv={}));class xv{constructor(e,t,i){this._tag=e,this._transform=t,this._viewportCoords=i||new hf,this._glObjectsChanged$=new j,this._interact$=new j}get glObjectsChanged$(){return this._glObjectsChanged$}get interact$(){return this._interact$}get tag(){return this._tag}}class wv extends xv{constructor(e,t){super(e,t),this._geometryChangedSubscription=this._tag.geometry.changed$.subscribe((()=>{this._onGeometryChanged()})),this._changedSubscription=this._tag.changed$.subscribe((()=>{this._onTagChanged()&&this._glObjectsChanged$.next(this)}))}dispose(){this._changedSubscription.unsubscribe(),this._geometryChangedSubscription.unsubscribe()}_colorToCss(e){return"#"+("000000"+e.toString(16)).substr(-6)}_createFill(){let e=this._getTriangles(),t=new Float32Array(e),i=new kr;i.setAttribute("position",new Tr(t,3)),i.computeBoundingSphere();let n=new wr({side:2,transparent:!0});return this._updateFillMaterial(n),new es(i,n)}_createLine(e){let t=this._getLinePositions(e),i=new kr;i.setAttribute("position",new Tr(t,3)),i.computeBoundingSphere();let n=new Bh;this._updateLineBasicMaterial(n);const r=new Wh(i,n);return r.renderOrder=1,r}_createOutline(){return this._createLine(this._getPoints3d())}_disposeFill(){null!=this._fill&&(this._fill.geometry.dispose(),this._fill.material.dispose(),this._fill=null)}_disposeOutline(){null!=this._outline&&(this._outline.geometry.dispose(),this._outline.material.dispose(),this._outline=null)}_getLinePositions(e){let t=e.length,i=new Float32Array(3*t);for(let n=0;n<t;++n){let t=3*n,r=e[n];i[t+0]=r[0],i[t+1]=r[1],i[t+2]=r[2]}return i}_interact(e,t,i){return n=>{let r=n.offsetX-n.target.offsetWidth/2,s=n.offsetY-n.target.offsetHeight/2;this._interact$.next({cursor:t,offsetX:r,offsetY:s,operation:e,tag:this._tag,vertexIndex:i})}}_updateFillGeometry(){let e=this._getTriangles(),t=new Float32Array(e),i=this._fill.geometry,n=i.getAttribute("position");n.array.length===t.length?(n.set(t),n.needsUpdate=!0):(i.deleteAttribute("position"),i.setAttribute("position",new Tr(t,3))),i.computeBoundingSphere()}_updateLine(e,t){let i=this._getLinePositions(t),n=e.geometry,r=n.getAttribute("position");r.set(i),r.needsUpdate=!0,n.computeBoundingSphere()}_updateOulineGeometry(){this._updateLine(this._outline,this._getPoints3d())}}class Mv extends wv{constructor(e,t){super(e,t),this._rectGeometry=new lv(this._tag.geometry.getRect2d(t)),this._fill=$u(t.cameraType)?null:this._createFill(),this._outline=this._tag.lineWidth>=1?this._createOutline():null}dispose(){super.dispose(),this._disposeFill(),this._disposeOutline()}getDOMObjects(e,t,i){const n=[],r={offsetHeight:i.height,offsetWidth:i.width};if(!this._tag.editable)return n;const s=this._colorToCss(this._tag.lineColor),a=this._tag.geometry.getPoints2d();for(let e=0;e<a.length;e++){const[i,o]=a[e],h=this._viewportCoords.basicToCanvasSafe(i,o,r,this._transform,t);if(null==h)continue;const c="crosshair",l=this._interact(vv.Vertex,c,e),u=`translate(-50%, -50%) translate(${Math.round(h[0])}px,${Math.round(h[1])}px)`,d={onpointerdown:l,style:{background:s,transform:u,cursor:c}};if(n.push(tf.h("div.mapillary-tag-resizer",d,[])),!this._tag.indicateVertices)continue;const p={style:{background:s,transform:u}};n.push(tf.h("div.mapillary-tag-vertex",p,[]))}return n}getGLObjects(){const e=[];return null!=this._fill&&e.push(this._fill),null!=this._outline&&e.push(this._outline),e}getRetrievableObjects(){return null!=this._fill?[this._fill]:[]}_onGeometryChanged(){this._rectGeometry=new lv(this._tag.geometry.getRect2d(this._transform)),null!=this._fill&&this._updateFillGeometry(),null!=this._outline&&this._updateOulineGeometry()}_onTagChanged(){let e=!1;return null!=this._fill&&this._updateFillMaterial(this._fill.material),null==this._outline?this._tag.lineWidth>=1&&(this._outline=this._createOutline(),e=!0):this._updateOutlineMaterial(),e}_getPoints3d(){return this._rectGeometry.getPoints3d(this._transform)}_getTriangles(){return this._rectGeometry.getTriangles3d(this._transform)}_updateFillMaterial(e){e.color=new xr(this._tag.fillColor),e.opacity=this._tag.fillOpacity,e.needsUpdate=!0}_updateLineBasicMaterial(e){e.color=new xr(this._tag.lineColor),e.linewidth=Math.max(this._tag.lineWidth,1),e.visible=this._tag.lineWidth>=1&&this._tag.lineOpacity>0,e.opacity=this._tag.lineOpacity,e.transparent=this._tag.lineOpacity<1,e.needsUpdate=!0}_updateOutlineMaterial(){let e=this._outline.material;this._updateLineBasicMaterial(e)}}class Sv extends nf{constructor(e,t){super(),this._id=e,this._geometry=t,this._notifyChanged$=new j,this._notifyChanged$.subscribe((e=>{const t={target:this,type:"tag"};this.fire("tag",t)})),this._geometry.changed$.subscribe((e=>{const t="geometry",i={target:this,type:t};this.fire(t,i)}))}get id(){return this._id}get geometry(){return this._geometry}get changed$(){return this._notifyChanged$}get geometryChanged$(){return this._geometry.changed$.pipe(De((()=>this)),Dt())}fire(e,t){super.fire(e,t)}off(e,t){super.off(e,t)}on(e,t){super.on(e,t)}}class Tv extends Sv{constructor(e,t,i){super(e,t),i=i||{},this._editable=null!=i.editable&&i.editable,this._fillColor=null==i.fillColor?16777215:i.fillColor,this._fillOpacity=null==i.fillOpacity?0:i.fillOpacity,this._indicateVertices=null==i.indicateVertices||i.indicateVertices,this._lineColor=null==i.lineColor?16777215:i.lineColor,this._lineOpacity=null==i.lineOpacity?1:i.lineOpacity,this._lineWidth=null==i.lineWidth?1:i.lineWidth}get editable(){return this._editable}set editable(e){this._editable=e,this._notifyChanged$.next(this)}get fillColor(){return this._fillColor}set fillColor(e){this._fillColor=e,this._notifyChanged$.next(this)}get fillOpacity(){return this._fillOpacity}set fillOpacity(e){this._fillOpacity=e,this._notifyChanged$.next(this)}get geometry(){return this._geometry}get indicateVertices(){return this._indicateVertices}set indicateVertices(e){this._indicateVertices=e,this._notifyChanged$.next(this)}get lineColor(){return this._lineColor}set lineColor(e){this._lineColor=e,this._notifyChanged$.next(this)}get lineOpacity(){return this._lineOpacity}set lineOpacity(e){this._lineOpacity=e,this._notifyChanged$.next(this)}get lineWidth(){return this._lineWidth}set lineWidth(e){this._lineWidth=e,this._notifyChanged$.next(this)}setOptions(e){this._editable=null==e.editable?this._editable:e.editable,this._indicateVertices=null==e.indicateVertices?this._indicateVertices:e.indicateVertices,this._lineColor=null==e.lineColor?this._lineColor:e.lineColor,this._lineWidth=null==e.lineWidth?this._lineWidth:e.lineWidth,this._fillColor=null==e.fillColor?this._fillColor:e.fillColor,this._fillOpacity=null==e.fillOpacity?this._fillOpacity:e.fillOpacity,this._notifyChanged$.next(this)}}e.TagDomain=void 0,(yv=e.TagDomain||(e.TagDomain={}))[yv.TwoDimensional=0]="TwoDimensional",yv[yv.ThreeDimensional=1]="ThreeDimensional";class Cv extends wv{constructor(t,i){super(t,i),this._fill=$u(i.cameraType)?t.domain===e.TagDomain.TwoDimensional&&t.geometry instanceof dv?this._createFill():null:this._createFill(),this._holes=this._tag.lineWidth>=1?this._createHoles():[],this._outline=this._tag.lineWidth>=1?this._createOutline():null}dispose(){super.dispose(),this._disposeFill(),this._disposeHoles(),this._disposeOutline()}getDOMObjects(e,t,i){const n=[],r=this._tag.geometry instanceof lv,s=!$u(this._transform.cameraType),a={offsetHeight:i.height,offsetWidth:i.width};if(null!=this._tag.icon&&(r||s)){const[i,r]=this._tag.geometry instanceof lv?this._tag.geometry.getVertex2d(this._tag.iconIndex):this._tag.geometry.getPoleOfInaccessibility2d(),s=this._viewportCoords.basicToCanvasSafe(i,r,a,this._transform,t);if(null!=s){const t=()=>{this._interact$.next({offsetX:0,offsetY:0,operation:vv.None,tag:this._tag})};if(e.loaded){const i=e.getDOMSprite(this._tag.icon,this._tag.iconFloat),r={onclick:e=>{e.stopPropagation(),this._tag.click$.next(this._tag)},onpointerdown:t,style:{transform:`translate(${Math.round(s[0])}px,${Math.round(s[1])}px)`}};n.push(tf.h("div.mapillary-tag-symbol",r,[i]))}}}else if(null!=this._tag.text&&(r||s)){const[e,i]=this._tag.geometry instanceof lv?this._tag.geometry.getVertex2d(3):this._tag.geometry.getPoleOfInaccessibility2d(),r=this._viewportCoords.basicToCanvasSafe(e,i,a,this._transform,t);if(null!=r){const e=Math.round(r[0]),t=Math.round(r[1]),i=this._tag.geometry instanceof lv?`translate(${e}px,${t}px)`:`translate(-50%, -50%) translate(${e}px,${t}px)`,s={onpointerdown:()=>{this._interact$.next({offsetX:0,offsetY:0,operation:vv.None,tag:this._tag})},style:{color:this._colorToCss(this._tag.textColor),transform:i},textContent:this._tag.text};n.push(tf.h("span.mapillary-tag-symbol",s,[]))}}if(!this._tag.editable)return n;const o=this._colorToCss(this._tag.lineColor);if(this._tag.geometry instanceof lv){const[e,i]=this._tag.geometry.getCentroid2d(),r=this._viewportCoords.basicToCanvasSafe(e,i,a,this._transform,t);if(null!=r){const e={onpointerdown:this._interact(vv.Centroid,"move"),style:{background:o,transform:`translate(-50%, -50%) translate(${Math.round(r[0])}px,${Math.round(r[1])}px)`}};n.push(tf.h("div.mapillary-tag-mover",e,[]))}}const h=this._tag.geometry.getVertices2d();for(let e=0;e<h.length-1;e++){if(r&&(null!=this._tag.icon&&e===this._tag.iconIndex||null==this._tag.icon&&null!=this._tag.text&&3===e))continue;const[i,s]=h[e],c=this._viewportCoords.basicToCanvasSafe(i,s,a,this._transform,t);if(null==c)continue;const l=r?e%2==0?"nesw-resize":"nwse-resize":"crosshair",u=this._interact(vv.Vertex,l,e),d=`translate(-50%, -50%) translate(${Math.round(c[0])}px,${Math.round(c[1])}px)`,p={onpointerdown:u,style:{background:o,transform:d,cursor:l}};if(n.push(tf.h("div.mapillary-tag-resizer",p,[])),!this._tag.indicateVertices)continue;const m={style:{background:o,transform:d}};n.push(tf.h("div.mapillary-tag-vertex",m,[]))}return n}getGLObjects(){const e=[];null!=this._fill&&e.push(this._fill);for(const t of this._holes)e.push(t);return null!=this._outline&&e.push(this._outline),e}getRetrievableObjects(){return null!=this._fill?[this._fill]:[]}_onGeometryChanged(){null!=this._fill&&this._updateFillGeometry(),this._holes.length>0&&this._updateHoleGeometries(),null!=this._outline&&this._updateOulineGeometry()}_onTagChanged(){let e=!1;return null!=this._fill&&this._updateFillMaterial(this._fill.material),null==this._outline?this._tag.lineWidth>=1&&(this._holes=this._createHoles(),this._outline=this._createOutline(),e=!0):(this._updateHoleMaterials(),this._updateOutlineMaterial()),e}_getPoints3d(){return this._in3dDomain()?this._tag.geometry.getVertices3d(this._transform):this._tag.geometry.getPoints3d(this._transform)}_getTriangles(){return this._in3dDomain()?this._tag.geometry.get3dDomainTriangles3d(this._transform):this._tag.geometry.getTriangles3d(this._transform)}_updateFillMaterial(e){e.color=new xr(this._tag.fillColor),e.opacity=this._tag.fillOpacity,e.needsUpdate=!0}_updateLineBasicMaterial(e){e.color=new xr(this._tag.lineColor),e.linewidth=Math.max(this._tag.lineWidth,1),e.visible=this._tag.lineWidth>=1&&this._tag.lineOpacity>0,e.opacity=this._tag.lineOpacity,e.transparent=this._tag.lineOpacity<1,e.needsUpdate=!0}_createHoles(){let e=[];if(this._tag.geometry instanceof dv){let t=this._getHoles3d();for(let i of t){let t=this._createLine(i);e.push(t)}}return e}_disposeHoles(){for(let e of this._holes)e.geometry.dispose(),e.material.dispose();this._holes=[]}_getHoles3d(){const e=this._tag.geometry;return this._in3dDomain()?e.getHoleVertices3d(this._transform):e.getHolePoints3d(this._transform)}_in3dDomain(){return this._tag.geometry instanceof dv&&this._tag.domain===e.TagDomain.ThreeDimensional}_updateHoleGeometries(){let e=this._getHoles3d();if(e.length!==this._holes.length)throw new Error("Changing the number of holes is not supported.");for(let t=0;t<this._holes.length;t++){let i=e[t],n=this._holes[t];this._updateLine(n,i)}}_updateHoleMaterials(){for(const e of this._holes)this._updateLineBasicMaterial(e.material)}_updateOutlineMaterial(){this._updateLineBasicMaterial(this._outline.material)}}e.Alignment=void 0,(bv=e.Alignment||(e.Alignment={}))[bv.Bottom=0]="Bottom",bv[bv.BottomLeft=1]="BottomLeft",bv[bv.BottomRight=2]="BottomRight",bv[bv.Center=3]="Center",bv[bv.Left=4]="Left",bv[bv.Right=5]="Right",bv[bv.Top=6]="Top",bv[bv.TopLeft=7]="TopLeft",bv[bv.TopRight=8]="TopRight";class Ev extends Sv{constructor(t,i,n){super(t,i);const r=null!=(n=n||{}).domain&&i instanceof dv?n.domain:e.TagDomain.TwoDimensional,s=this._twoDimensionalPolygon(r,i);this._domain=r,this._editable=null!=n.editable&&!s&&n.editable,this._fillColor=null==n.fillColor?16777215:n.fillColor,this._fillOpacity=null==n.fillOpacity?0:n.fillOpacity,this._icon=void 0===n.icon?null:n.icon,this._iconFloat=null==n.iconFloat?e.Alignment.Center:n.iconFloat,this._iconIndex=null==n.iconIndex?3:n.iconIndex,this._indicateVertices=null==n.indicateVertices||n.indicateVertices,this._lineColor=null==n.lineColor?16777215:n.lineColor,this._lineOpacity=null==n.lineOpacity?1:n.lineOpacity,this._lineWidth=null==n.lineWidth?1:n.lineWidth,this._text=void 0===n.text?null:n.text,this._textColor=null==n.textColor?16777215:n.textColor,this._click$=new j,this._click$.subscribe((()=>{const e="click",t={target:this,type:e};this.fire(e,t)}))}get click$(){return this._click$}get domain(){return this._domain}get editable(){return this._editable}set editable(e){this._twoDimensionalPolygon(this._domain,this._geometry)||(this._editable=e,this._notifyChanged$.next(this))}get fillColor(){return this._fillColor}set fillColor(e){this._fillColor=e,this._notifyChanged$.next(this)}get fillOpacity(){return this._fillOpacity}set fillOpacity(e){this._fillOpacity=e,this._notifyChanged$.next(this)}get geometry(){return this._geometry}get icon(){return this._icon}set icon(e){this._icon=e,this._notifyChanged$.next(this)}get iconFloat(){return this._iconFloat}set iconFloat(e){this._iconFloat=e,this._notifyChanged$.next(this)}get iconIndex(){return this._iconIndex}set iconIndex(e){this._iconIndex=e,this._notifyChanged$.next(this)}get indicateVertices(){return this._indicateVertices}set indicateVertices(e){this._indicateVertices=e,this._notifyChanged$.next(this)}get lineColor(){return this._lineColor}set lineColor(e){this._lineColor=e,this._notifyChanged$.next(this)}get lineOpacity(){return this._lineOpacity}set lineOpacity(e){this._lineOpacity=e,this._notifyChanged$.next(this)}get lineWidth(){return this._lineWidth}set lineWidth(e){this._lineWidth=e,this._notifyChanged$.next(this)}get text(){return this._text}set text(e){this._text=e,this._notifyChanged$.next(this)}get textColor(){return this._textColor}set textColor(e){this._textColor=e,this._notifyChanged$.next(this)}fire(e,t){super.fire(e,t)}off(e,t){super.off(e,t)}on(e,t){super.on(e,t)}setOptions(e){const t=this._twoDimensionalPolygon(this._domain,this._geometry);this._editable=t||null==e.editable?this._editable:e.editable,this._icon=void 0===e.icon?this._icon:e.icon,this._iconFloat=null==e.iconFloat?this._iconFloat:e.iconFloat,this._iconIndex=null==e.iconIndex?this._iconIndex:e.iconIndex,this._indicateVertices=null==e.indicateVertices?this._indicateVertices:e.indicateVertices,this._lineColor=null==e.lineColor?this._lineColor:e.lineColor,this._lineWidth=null==e.lineWidth?this._lineWidth:e.lineWidth,this._fillColor=null==e.fillColor?this._fillColor:e.fillColor,this._fillOpacity=null==e.fillOpacity?this._fillOpacity:e.fillOpacity,this._text=void 0===e.text?this._text:e.text,this._textColor=null==e.textColor?this._textColor:e.textColor,this._notifyChanged$.next(this)}_twoDimensionalPolygon(t,i){return t!==e.TagDomain.ThreeDimensional&&i instanceof dv}}class Av extends xv{dispose(){}getDOMObjects(t,i,n){const r=this._tag,s={offsetHeight:n.height,offsetWidth:n.width},a=[],[o,h]=r.geometry.getCentroid2d(),c=this._viewportCoords.basicToCanvasSafe(o,h,s,this._transform,i);if(null!=c){const i=e=>{this._interact$.next({offsetX:0,offsetY:0,operation:vv.None,tag:r})},n=Math.round(c[0]),s=Math.round(c[1]);if(null!=r.icon){if(t.loaded){const o=t.getDOMSprite(r.icon,e.Alignment.Bottom),h={onpointerdown:i,style:{pointerEvents:"all",transform:`translate(${n}px,${s+8}px)`}};a.push(tf.h("div",h,[o]))}}else if(null!=r.text){const e=`translate(-50%,0%) translate(${n}px,${s+8}px)`,t={onpointerdown:i,style:{color:this._colorToCss(r.textColor),transform:e},textContent:r.text};a.push(tf.h("span.mapillary-tag-symbol",t,[]))}const o=this._interact(vv.Centroid,r,"move"),h=this._colorToCss(r.color),l=`translate(-50%,-50%) translate(${n}px,${s}px)`;if(r.editable){let e={onpointerdown:o,style:{background:h,transform:l}};a.push(tf.h("div.mapillary-tag-spot-interactor",e,[]))}const u={style:{background:h,transform:l}};a.push(tf.h("div.mapillary-tag-vertex",u,[]))}return a}getGLObjects(){return[]}getRetrievableObjects(){return[]}_colorToCss(e){return"#"+("000000"+e.toString(16)).substr(-6)}_interact(e,t,i,n){return r=>{const s=r.offsetX-r.target.offsetWidth/2,a=r.offsetY-r.target.offsetHeight/2;this._interact$.next({cursor:i,offsetX:s,offsetY:a,operation:e,tag:t,vertexIndex:n})}}}class Iv extends Sv{constructor(e,t,i){super(e,t),i=i||{},this._color=null==i.color?16777215:i.color,this._editable=null!=i.editable&&i.editable,this._icon=void 0===i.icon?null:i.icon,this._text=void 0===i.text?null:i.text,this._textColor=null==i.textColor?16777215:i.textColor}get color(){return this._color}set color(e){this._color=e,this._notifyChanged$.next(this)}get editable(){return this._editable}set editable(e){this._editable=e,this._notifyChanged$.next(this)}get icon(){return this._icon}set icon(e){this._icon=e,this._notifyChanged$.next(this)}get text(){return this._text}set text(e){this._text=e,this._notifyChanged$.next(this)}get textColor(){return this._textColor}set textColor(e){this._textColor=e,this._notifyChanged$.next(this)}setOptions(e){this._color=null==e.color?this._color:e.color,this._editable=null==e.editable?this._editable:e.editable,this._icon=void 0===e.icon?this._icon:e.icon,this._text=void 0===e.text?this._text:e.text,this._textColor=null==e.textColor?this._textColor:e.textColor,this._notifyChanged$.next(this)}}class Rv{constructor(){this._active=!1,this._hash={},this._hashDeactivated={},this._notifyChanged$=new j}get active(){return this._active}get changed$(){return this._notifyChanged$}activate(e){if(!this._active){for(const t in this._hashDeactivated){if(!this._hashDeactivated.hasOwnProperty(t))continue;const i=this._hashDeactivated[t];this._add(i,e)}this._hashDeactivated={},this._active=!0,this._notifyChanged$.next(this)}}deactivate(){if(this._active){for(const e in this._hash)this._hash.hasOwnProperty(e)&&(this._hashDeactivated[e]=this._hash[e].tag);this._hash={},this._active=!1}}add(e,t){this._assertActivationState(!0);for(const i of e)this._add(i,t);this._notifyChanged$.next(this)}addDeactivated(e){this._assertActivationState(!1);for(const t of e){if(!(t instanceof Ev||t instanceof Iv||t instanceof Tv))throw new Error("Tag type not supported");this._hashDeactivated[t.id]=t}}get(e){return this.has(e)?this._hash[e]:void 0}getAll(){const e=this._hash;return Object.keys(e).map((t=>e[t]))}getAllDeactivated(){const e=this._hashDeactivated;return Object.keys(e).map((t=>e[t]))}getDeactivated(e){return this.hasDeactivated(e)?this._hashDeactivated[e]:void 0}has(e){return e in this._hash}hasDeactivated(e){return e in this._hashDeactivated}remove(e){this._assertActivationState(!0);const t=this._hash;for(const i of e)i in t&&delete t[i];this._notifyChanged$.next(this)}removeAll(){this._assertActivationState(!0),this._hash={},this._notifyChanged$.next(this)}removeAllDeactivated(){this._assertActivationState(!1),this._hashDeactivated={}}removeDeactivated(e){this._assertActivationState(!1);const t=this._hashDeactivated;for(const i of e)i in t&&delete t[i]}_add(e,t){if(e instanceof Ev)this._hash[e.id]=new Cv(e,t);else if(e instanceof Iv)this._hash[e.id]=new Av(e,t);else{if(!(e instanceof Tv))throw new Error("Tag type not supported");this._hash[e.id]=new Mv(e,t)}}_assertActivationState(e){if(e!==this._active)throw new Error("Tag set not in correct state for operation.")}}class Pv extends Fg{constructor(e){super();let t=e[0],i=e[1];if(t<0||t>1||i<0||i>1)throw new Bg("Basic coordinates must be on the interval [0, 1].");this._point=e.slice()}get point(){return this._point}getCentroid2d(){return this._point.slice()}getCentroid3d(e){return e.unprojectBasic(this._point,200)}setCentroid2d(e,t){let i=[Math.max(0,Math.min(1,e[0])),Math.max(0,Math.min(1,e[1]))];this._point[0]=i[0],this._point[1]=i[1],this._notifyChanged$.next(this)}}class Lv extends zf{constructor(e,t,i,n){super(e,t,i),this._name=`${this._component.name}-${this._getNameExtension()}`,this._viewportCoords=n}_getConfiguration(e){return{}}_mouseEventToBasic(e,t,i,n,r,s){r=null!=r?r:0,s=null!=s?s:0;const[a,o]=this._viewportCoords.canvasPosition(e,t);return this._viewportCoords.canvasToBasic(a-r,o-s,t,n,i.perspective)}}class Dv extends Lv{constructor(e,t,i,n,r){super(e,t,i,n),this._tagCreator=r,this._geometryCreated$=new j}get geometryCreated$(){return this._geometryCreated$}_enable(){this._enableCreate(),this._container.container.classList.add("component-tag-create")}_disable(){this._container.container.classList.remove("component-tag-create"),this._disableCreate()}_validateBasic(e){const t=e[0],i=e[1];return 0<=t&&t<=1&&0<=i&&i<=1}_mouseEventToBasic$(e){return e.pipe(Vt(this._container.renderService.renderCamera$,this._navigator.stateService.currentTransform$),De((([e,t,i])=>this._mouseEventToBasic(e,this._container.container,t,i))))}}class Nv extends Dv{_enableCreate(){this._container.mouseService.deferPixels(this._name,4),this._geometryCreatedSubscription=this._mouseEventToBasic$(this._container.mouseService.proximateClick$).pipe(st(this._validateBasic),De((e=>new Pv(e)))).subscribe(this._geometryCreated$)}_disableCreate(){this._container.mouseService.undeferPixels(this._name),this._geometryCreatedSubscription.unsubscribe()}_getNameExtension(){return"create-point"}}class $v extends Dv{_enableCreate(){this._container.mouseService.deferPixels(this._name,4);const e=this._navigator.stateService.currentTransform$.pipe(De((()=>{})),Rt(1),U());this._deleteSubscription=e.pipe($t(1)).subscribe(this._tagCreator.delete$);const t=this._mouseEventToBasic$(this._container.mouseService.proximateClick$).pipe(Dt());this._createSubscription=e.pipe(zt((()=>t.pipe(st(this._validateBasic),_t(1))))).subscribe(this._create$),this._setVertexSubscription=this._tagCreator.tag$.pipe(zt((e=>e?Ve(Ce(e),it(this._container.mouseService.mouseMove$,this._container.mouseService.domMouseMove$),this._container.renderService.renderCamera$,this._navigator.stateService.currentTransform$):ie()))).subscribe((([e,t,i,n])=>{const r=this._mouseEventToBasic(t,this._container.container,i,n);this._setVertex2d(e,r,n)})),this._addPointSubscription=this._tagCreator.tag$.pipe(zt((e=>e?Ve(Ce(e),t):ie()))).subscribe((([e,t])=>{this._addPoint(e,t)})),this._geometryCreateSubscription=this._tagCreator.tag$.pipe(zt((e=>e?e.created$.pipe(De((e=>e.geometry))):ie()))).subscribe(this._geometryCreated$)}_disableCreate(){this._container.mouseService.undeferPixels(this._name),this._tagCreator.delete$.next(null),this._addPointSubscription.unsubscribe(),this._createSubscription.unsubscribe(),this._deleteSubscription.unsubscribe(),this._geometryCreateSubscription.unsubscribe(),this._setVertexSubscription.unsubscribe()}}class kv extends $v{get _create$(){return this._tagCreator.createPoints$}_addPoint(e,t){e.geometry.addPoint2d(t)}_getNameExtension(){return"create-points"}_setVertex2d(e,t,i){e.geometry.setPoint2d(e.geometry.points.length-1,t,i)}}class Ov extends $v{get _create$(){return this._tagCreator.createPolygon$}_addPoint(e,t){e.addPoint(t)}_getNameExtension(){return"create-polygon"}_setVertex2d(e,t,i){e.geometry.setVertex2d(e.geometry.polygon.length-2,t,i)}}class zv extends $v{get _create$(){return this._tagCreator.createRect$}_addPoint(e,t){const i=e.geometry;i.validate(t)||(t=i.getNonAdjustedVertex2d(3)),e.addPoint(t)}_enable(){super._enable(),this._initializeAnchorIndexingSubscription=this._tagCreator.tag$.pipe(st((e=>!!e))).subscribe((e=>{e.geometry.initializeAnchorIndexing()}))}_disable(){super._disable(),this._initializeAnchorIndexingSubscription.unsubscribe()}_getNameExtension(){return"create-rect"}_setVertex2d(e,t,i){e.geometry.setOppositeVertex2d(t,i)}}class Fv extends Dv{_enableCreate(){this._container.mouseService.claimMouse(this._name,2),this._deleteSubscription=this._navigator.stateService.currentTransform$.pipe(De((e=>null)),$t(1)).subscribe(this._tagCreator.delete$),this._createSubscription=this._mouseEventToBasic$(this._container.mouseService.filtered$(this._name,this._container.mouseService.mouseDragStart$)).pipe(st(this._validateBasic)).subscribe(this._tagCreator.createRect$),this._initializeAnchorIndexingSubscription=this._tagCreator.tag$.pipe(st((e=>!!e))).subscribe((e=>{e.geometry.initializeAnchorIndexing()}));const e=Ve(it(this._container.mouseService.filtered$(this._name,this._container.mouseService.mouseMove$),this._container.mouseService.filtered$(this._name,this._container.mouseService.domMouseMove$)),this._container.renderService.renderCamera$).pipe(Vt(this._navigator.stateService.currentTransform$),De((([[e,t],i])=>this._mouseEventToBasic(e,this._container.container,t,i))));this._setVertexSubscription=this._tagCreator.tag$.pipe(zt((t=>t?Ve(Ce(t),e,this._navigator.stateService.currentTransform$):ie()))).subscribe((([e,t,i])=>{e.geometry.setOppositeVertex2d(t,i)}));const t=this._container.mouseService.mouseDragEnd$.pipe(Vt(this._mouseEventToBasic$(this._container.mouseService.filtered$(this._name,this._container.mouseService.mouseDrag$)).pipe(st(this._validateBasic)),((e,t)=>t)),Dt());this._addPointSubscription=this._tagCreator.tag$.pipe(zt((e=>e?Ve(Ce(e),t):ie()))).subscribe((([e,t])=>{const i=e.geometry;i.validate(t)||(t=i.getNonAdjustedVertex2d(3)),e.addPoint(t)})),this._geometryCreatedSubscription=this._tagCreator.tag$.pipe(zt((e=>e?e.created$.pipe(De((e=>e.geometry))):ie()))).subscribe(this._geometryCreated$)}_disableCreate(){this._container.mouseService.unclaimMouse(this._name),this._tagCreator.delete$.next(null),this._addPointSubscription.unsubscribe(),this._createSubscription.unsubscribe(),this._deleteSubscription.unsubscribe(),this._geometryCreatedSubscription.unsubscribe(),this._initializeAnchorIndexingSubscription.unsubscribe(),this._setVertexSubscription.unsubscribe()}_getNameExtension(){return"create-rect-drag"}}class Bv extends Lv{constructor(e,t,i,n,r){super(e,t,i,n),this._tagSet=r}_enable(){const e=this._tagSet.changed$.pipe(De((e=>e.getAll())),zt((e=>ge(e).pipe(We((e=>e.interact$))))),zt((e=>Ze(Ce(e),this._container.mouseService.documentMouseUp$.pipe(De((()=>({offsetX:0,offsetY:0,operation:vv.None,tag:null}))),St())))),Dt());it(this._container.mouseService.mouseMove$,this._container.mouseService.domMouseMove$).pipe(Dt()),this._claimMouseSubscription=e.pipe(zt((e=>e.tag?this._container.mouseService.domMouseDragStart$:ie()))).subscribe((()=>{this._container.mouseService.claimMouse(this._name,3)})),this._cursorSubscription=e.pipe(De((e=>e.cursor)),vt()).subscribe((e=>{const t=["crosshair","move","nesw-resize","nwse-resize"];for(const e of t)this._container.container.classList.remove(`component-tag-edit-${e}`);e&&this._container.container.classList.add(`component-tag-edit-${e}`)})),this._unclaimMouseSubscription=this._container.mouseService.filtered$(this._name,this._container.mouseService.domMouseDragEnd$).subscribe((e=>{this._container.mouseService.unclaimMouse(this._name)})),this._preventDefaultSubscription=e.pipe(zt((e=>e.tag?this._container.mouseService.documentMouseMove$:ie()))).subscribe((e=>{e.preventDefault()})),this._updateGeometrySubscription=e.pipe(zt((e=>{if(e.operation===vv.None||!e.tag)return ie();return Ve(this._container.mouseService.filtered$(this._name,this._container.mouseService.domMouseDrag$).pipe(st((e=>this._viewportCoords.insideElement(e,this._container.container)))),this._container.renderService.renderCamera$).pipe(Vt(Ce(e),this._navigator.stateService.currentTransform$,(([e,t],i,n)=>[e,t,i,n])))}))).subscribe((([e,t,i,n])=>{const r=this._mouseEventToBasic(e,this._container.container,t,n,i.offsetX,i.offsetY),s=i.tag.geometry;i.operation===vv.Centroid?s.setCentroid2d(r,n):i.operation===vv.Vertex&&s.setVertex2d(i.vertexIndex,r,n)}))}_disable(){this._claimMouseSubscription.unsubscribe(),this._cursorSubscription.unsubscribe(),this._preventDefaultSubscription.unsubscribe(),this._unclaimMouseSubscription.unsubscribe(),this._updateGeometrySubscription.unsubscribe()}_getNameExtension(){return"edit-vertex"}}class Uv extends sf{constructor(e,t,i){super(e,t,i),this._tagDomRenderer=new fv,this._tagScene=new gv,this._tagSet=new Rv,this._tagCreator=new mv(this,i),this._viewportCoords=new hf,this._createHandlers={CreatePoint:new Nv(this,t,i,this._viewportCoords,this._tagCreator),CreatePoints:new kv(this,t,i,this._viewportCoords,this._tagCreator),CreatePolygon:new Ov(this,t,i,this._viewportCoords,this._tagCreator),CreateRect:new zv(this,t,i,this._viewportCoords,this._tagCreator),CreateRectDrag:new Fv(this,t,i,this._viewportCoords,this._tagCreator),Default:void 0},this._editVertexHandler=new Bv(this,t,i,this._viewportCoords,this._tagSet),this._renderTags$=this._tagSet.changed$.pipe(De((e=>{const t=e.getAll();return t.sort(((e,t)=>{const i=e.tag.id,n=t.tag.id;return i<n?-1:i>n?1:0})),t})),Dt()),this._tagChanged$=this._renderTags$.pipe(zt((e=>ge(e).pipe(We((e=>it(e.tag.changed$,e.tag.geometryChanged$)))))),Dt()),this._renderTagGLChanged$=this._renderTags$.pipe(zt((e=>ge(e).pipe(We((e=>e.glObjectsChanged$))))),Dt()),this._createGeometryChanged$=this._tagCreator.tag$.pipe(zt((e=>null!=e?e.geometryChanged$:ie())),Dt()),this._createGLObjectsChanged$=this._tagCreator.tag$.pipe(zt((e=>null!=e?e.glObjectsChanged$:ie())),Dt()),this._creatingConfiguration$=this._configuration$.pipe(vt(((e,t)=>e.mode===t.mode),(e=>({createColor:e.createColor,mode:e.mode}))),Rt(1),U()),this._creatingConfiguration$.subscribe((e=>{const t="tagmode",i={mode:e.mode,target:this,type:t};this.fire(t,i)}))}add(e){this._activated?this._navigator.stateService.currentTransform$.pipe(St()).subscribe((t=>{this._tagSet.add(e,t);const i=e.map((e=>this._tagSet.get(e.id)));this._tagScene.add(i)})):this._tagSet.addDeactivated(e)}calculateRect(e){return new Promise(((t,i)=>{this._navigator.stateService.currentTransform$.pipe(St(),De((t=>e.getRect2d(t)))).subscribe((e=>{t(e)}),(e=>{i(e)}))}))}create(){this._tagCreator.replayedTag$.pipe(St(),st((e=>!!e))).subscribe((e=>{e.create()}))}changeMode(e){this.configure({mode:e})}fire(e,t){super.fire(e,t)}get(e){if(this._activated){const t=this._tagSet.get(e);return void 0!==t?t.tag:void 0}return this._tagSet.getDeactivated(e)}getAll(){return this.activated?this._tagSet.getAll().map((e=>e.tag)):this._tagSet.getAllDeactivated()}getTagIdsAt(e){return new Promise(((t,i)=>{this._container.renderService.renderCamera$.pipe(St(),De((t=>{const i=this._viewportCoords.canvasToViewport(e[0],e[1],this._container.container);return this._tagScene.intersectObjects(i,t.perspective)}))).subscribe((e=>{t(e)}),(e=>{i(e)}))}))}has(e){return this._activated?this._tagSet.has(e):this._tagSet.hasDeactivated(e)}off(e,t){super.off(e,t)}on(e,t){super.on(e,t)}remove(e){this._activated?(this._tagSet.remove(e),this._tagScene.remove(e)):this._tagSet.removeDeactivated(e)}removeAll(){this._activated?(this._tagSet.removeAll(),this._tagScene.removeAll()):this._tagSet.removeAllDeactivated()}_activate(){this._editVertexHandler.enable();const t=ge(Object.keys(this._createHandlers)).pipe(De((e=>this._createHandlers[e])),st((e=>!!e)),We((e=>e.geometryCreated$)),Dt()),i=this._subscriptions;i.push(t.subscribe((e=>{const t="geometrycreate",i={geometry:e,target:this,type:t};this.fire(t,i)}))),i.push(this._tagCreator.tag$.pipe(kt((e=>null==e)),vt()).subscribe((e=>{const t=null!=e?"tagcreatestart":"tagcreateend",i={target:this,type:t};this.fire(t,i)}))),i.push(t.subscribe((()=>{this.changeMode(e.TagMode.Default)}))),i.push(this._creatingConfiguration$.subscribe((t=>{this._disableCreateHandlers();const i=e.TagMode[t.mode],n=this._createHandlers[i];n&&n.enable()}))),i.push(this._renderTags$.subscribe((()=>{const e="tags",t={target:this,type:e};this.fire(e,t)}))),i.push(this._tagCreator.tag$.pipe(zt((e=>null!=e?e.aborted$.pipe(De((()=>null))):ie()))).subscribe((()=>{this.changeMode(e.TagMode.Default)}))),i.push(this._tagCreator.tag$.subscribe((e=>{this._tagScene.hasCreateTag()&&this._tagScene.removeCreateTag(),null!=e&&this._tagScene.addCreateTag(e)}))),i.push(this._createGLObjectsChanged$.subscribe((e=>{this._tagScene.updateCreateTagObjects(e)}))),i.push(this._renderTagGLChanged$.subscribe((e=>{this._tagScene.updateObjects(e)}))),i.push(this._tagChanged$.subscribe((()=>{this._tagScene.update()}))),i.push(Ve(this._renderTags$.pipe(Ot([]),Ut((()=>{this._container.domRenderer.render$.next({name:this._name,vNode:this._tagDomRenderer.clear()})}))),this._container.renderService.renderCamera$,this._container.spriteService.spriteAtlas$,this._container.renderService.size$,this._tagChanged$.pipe(Ot(null)),it(this._tagCreator.tag$,this._createGeometryChanged$).pipe(Ot(null))).pipe(De((([e,t,i,n,,r])=>({name:this._name,vNode:this._tagDomRenderer.render(e,r,i,t.perspective,n)})))).subscribe(this._container.domRenderer.render$)),i.push(this._navigator.stateService.currentState$.pipe(De((e=>{const t=this._tagScene;return{name:this._name,renderer:{frameId:e.id,needsRender:t.needsRender,render:t.render.bind(t),pass:yf.Opaque}}}))).subscribe(this._container.glRenderer.render$)),this._navigator.stateService.currentTransform$.pipe(St()).subscribe((e=>{this._tagSet.activate(e),this._tagScene.add(this._tagSet.getAll())}))}_deactivate(){this._editVertexHandler.disable(),this._disableCreateHandlers(),this._tagScene.clear(),this._tagSet.deactivate(),this._tagCreator.delete$.next(null),this._subscriptions.unsubscribe(),this._container.container.classList.remove("component-tag-create")}_getDefaultConfiguration(){return{createColor:16777215,indicatePointsCompleter:!0,mode:e.TagMode.Default}}_disableCreateHandlers(){const e=this._createHandlers;for(const t in e){if(!e.hasOwnProperty(t))continue;const i=e[t];i&&i.disable()}}}Uv.componentName="tag";class Vv extends sf{constructor(e,t,i){super(e,t,i),this._viewportCoords=new hf,this._zoomDelta$=new j}_activate(){const t=this._subscriptions;t.push(Ve(this._navigator.stateService.currentState$,this._navigator.stateService.state$,this._configuration$,this._container.renderService.size$).pipe(De((([t,i,n,r])=>{const s=t.state.zoom,a=tf.h("div.mapillary-zoom-in-icon",[]),o=s>=3||i===Df.Waiting?tf.h("div.mapillary-zoom-in-button-inactive",[a]):tf.h("div.mapillary-zoom-in-button",{onclick:()=>{this._zoomDelta$.next(1)}},[a]),h=tf.h("div.mapillary-zoom-out-icon",[]),c=s<=0||i===Df.Waiting?tf.h("div.mapillary-zoom-out-button-inactive",[h]):tf.h("div.mapillary-zoom-out-button",{onclick:()=>{this._zoomDelta$.next(-1)}},[h]),l=n.size===e.ComponentSize.Small||n.size===e.ComponentSize.Automatic&&r.width<640?".mapillary-zoom-compact":"";return{name:this._name,vNode:tf.h("div.mapillary-zoom-container"+l,{oncontextmenu:e=>{e.preventDefault()}},[o,c])}}))).subscribe(this._container.domRenderer.render$)),t.push(this._zoomDelta$.pipe(Vt(this._container.renderService.renderCamera$,this._navigator.stateService.currentTransform$)).subscribe((([e,t,i])=>{const n=this._viewportCoords.unprojectFromViewport(0,0,t.perspective),r=i.projectBasic(n.toArray());this._navigator.stateService.zoomIn(e,r)})))}_deactivate(){this._subscriptions.unsubscribe()}_getDefaultConfiguration(){return{size:e.ComponentSize.Automatic}}}Vv.componentName="zoom";class Hv extends sf{constructor(e,t,i,n){super(e,t,i),this._canvasId=`${t.id}-${this._name}`,this._dom=n||new og}_activate(){const e=this._container.domRenderer.element$.pipe(De((()=>this._dom.document.getElementById(this._canvasId))),st((e=>!!e)),De((e=>{const t=e.parentElement,i=t.offsetWidth;return[e,{height:t.offsetHeight,width:i}]})),vt(((e,t)=>e.height===t.height&&e.width===t.width),(([,e])=>e)));this._subscriptions.push(Ve(e,this._navigator.stateService.currentImage$).subscribe((([[e,t],i])=>{e.width=t.width,e.height=t.height,e.getContext("2d").drawImage(i.image,0,0,t.width,t.height)}))),this._container.domRenderer.renderAdaptive$.next({name:this._name,vNode:tf.h(`canvas#${this._canvasId}`,[])})}_deactivate(){this._subscriptions.unsubscribe()}_getDefaultConfiguration(){return{}}}Hv.componentName="imagefallback";class jv extends sf{constructor(t,i,n){super(t,i,n),this._seqNames={},this._seqNames[e.NavigationDirection[e.NavigationDirection.Prev]]="-prev",this._seqNames[e.NavigationDirection[e.NavigationDirection.Next]]="-next",this._spaTopNames={},this._spaTopNames[e.NavigationDirection[e.NavigationDirection.TurnLeft]]="-turn-left",this._spaTopNames[e.NavigationDirection[e.NavigationDirection.StepLeft]]="-left",this._spaTopNames[e.NavigationDirection[e.NavigationDirection.StepForward]]="-forward",this._spaTopNames[e.NavigationDirection[e.NavigationDirection.StepRight]]="-right",this._spaTopNames[e.NavigationDirection[e.NavigationDirection.TurnRight]]="-turn-right",this._spaBottomNames={},this._spaBottomNames[e.NavigationDirection[e.NavigationDirection.TurnU]]="-turn-around",this._spaBottomNames[e.NavigationDirection[e.NavigationDirection.StepBackward]]="-backward"}_activate(){this._subscriptions.push(Ve(this._navigator.stateService.currentImage$,this._configuration$).pipe(zt((([e,t])=>Ve(t.sequence?e.sequenceEdges$.pipe(De((e=>e.edges.map((e=>e.data.direction))))):Ce([]),!$u(e.cameraType)&&t.spatial?e.spatialEdges$.pipe(De((e=>e.edges.map((e=>e.data.direction))))):Ce([])).pipe(De((([e,t])=>e.concat(t)))))),De((e=>{const t=this._createArrowRow(this._seqNames,e),i=this._createArrowRow(this._spaTopNames,e),n=this._createArrowRow(this._spaBottomNames,e),r=tf.h("div.mapillary-navigation-sequence",t),s=tf.h("div.NavigationSpatialTop",i),a=tf.h("div.mapillary-navigation-spatial-bottom",n),o=tf.h("div.mapillary-navigation-spatial",[s,a]);return{name:this._name,vNode:tf.h("div.NavigationContainer",[r,o])}}))).subscribe(this._container.domRenderer.render$))}_deactivate(){this._subscriptions.unsubscribe()}_getDefaultConfiguration(){return{sequence:!0,spatial:!0}}_createArrowRow(t,i){const n=[];for(const r in t){if(!t.hasOwnProperty(r))continue;const s=e.NavigationDirection[r];-1!==i.indexOf(s)?n.push(this._createVNode(s,t[r],"visible")):n.push(this._createVNode(s,t[r],"hidden"))}return n}_createVNode(e,t,i){return tf.h(`span.mapillary-navigation-button.mapillary-navigation${t}`,{onclick:()=>{this._navigator.moveDir$(e).subscribe(void 0,(e=>{e instanceof uf||console.error(e)}))},style:{visibility:i}},[])}}jv.componentName="navigationfallback";function Gv(e){let t=e.length;for(;--t>=0;)e[t]=0}const Wv=256,qv=286,Xv=30,Zv=15,Yv=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]),Jv=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]),Kv=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),Qv=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),ey=new Array(576);Gv(ey);const ty=new Array(60);Gv(ty);const iy=new Array(512);Gv(iy);const ny=new Array(256);Gv(ny);const ry=new Array(29);Gv(ry);const sy=new Array(Xv);function ay(e,t,i,n,r){this.static_tree=e,this.extra_bits=t,this.extra_base=i,this.elems=n,this.max_length=r,this.has_stree=e&&e.length}let oy,hy,cy;function ly(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}Gv(sy);const uy=e=>e<256?iy[e]:iy[256+(e>>>7)],dy=(e,t)=>{e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255},py=(e,t,i)=>{e.bi_valid>16-i?(e.bi_buf|=t<<e.bi_valid&65535,dy(e,e.bi_buf),e.bi_buf=t>>16-e.bi_valid,e.bi_valid+=i-16):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=i)},my=(e,t,i)=>{py(e,i[2*t],i[2*t+1])},fy=(e,t)=>{let i=0;do{i|=1&e,e>>>=1,i<<=1}while(--t>0);return i>>>1},gy=(e,t,i)=>{const n=new Array(16);let r,s,a=0;for(r=1;r<=Zv;r++)n[r]=a=a+i[r-1]<<1;for(s=0;s<=t;s++){let t=e[2*s+1];0!==t&&(e[2*s]=fy(n[t]++,t))}},_y=e=>{let t;for(t=0;t<qv;t++)e.dyn_ltree[2*t]=0;for(t=0;t<Xv;t++)e.dyn_dtree[2*t]=0;for(t=0;t<19;t++)e.bl_tree[2*t]=0;e.dyn_ltree[512]=1,e.opt_len=e.static_len=0,e.last_lit=e.matches=0},vy=e=>{e.bi_valid>8?dy(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},yy=(e,t,i,n)=>{const r=2*t,s=2*i;return e[r]<e[s]||e[r]===e[s]&&n[t]<=n[i]},by=(e,t,i)=>{const n=e.heap[i];let r=i<<1;for(;r<=e.heap_len&&(r<e.heap_len&&yy(t,e.heap[r+1],e.heap[r],e.depth)&&r++,!yy(t,n,e.heap[r],e.depth));)e.heap[i]=e.heap[r],i=r,r<<=1;e.heap[i]=n},xy=(e,t,i)=>{let n,r,s,a,o=0;if(0!==e.last_lit)do{n=e.pending_buf[e.d_buf+2*o]<<8|e.pending_buf[e.d_buf+2*o+1],r=e.pending_buf[e.l_buf+o],o++,0===n?my(e,r,t):(s=ny[r],my(e,s+Wv+1,t),a=Yv[s],0!==a&&(r-=ry[s],py(e,r,a)),n--,s=uy(n),my(e,s,i),a=Jv[s],0!==a&&(n-=sy[s],py(e,n,a)))}while(o<e.last_lit);my(e,256,t)},wy=(e,t)=>{const i=t.dyn_tree,n=t.stat_desc.static_tree,r=t.stat_desc.has_stree,s=t.stat_desc.elems;let a,o,h,c=-1;for(e.heap_len=0,e.heap_max=573,a=0;a<s;a++)0!==i[2*a]?(e.heap[++e.heap_len]=c=a,e.depth[a]=0):i[2*a+1]=0;for(;e.heap_len<2;)h=e.heap[++e.heap_len]=c<2?++c:0,i[2*h]=1,e.depth[h]=0,e.opt_len--,r&&(e.static_len-=n[2*h+1]);for(t.max_code=c,a=e.heap_len>>1;a>=1;a--)by(e,i,a);h=s;do{a=e.heap[1],e.heap[1]=e.heap[e.heap_len--],by(e,i,1),o=e.heap[1],e.heap[--e.heap_max]=a,e.heap[--e.heap_max]=o,i[2*h]=i[2*a]+i[2*o],e.depth[h]=(e.depth[a]>=e.depth[o]?e.depth[a]:e.depth[o])+1,i[2*a+1]=i[2*o+1]=h,e.heap[1]=h++,by(e,i,1)}while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],((e,t)=>{const i=t.dyn_tree,n=t.max_code,r=t.stat_desc.static_tree,s=t.stat_desc.has_stree,a=t.stat_desc.extra_bits,o=t.stat_desc.extra_base,h=t.stat_desc.max_length;let c,l,u,d,p,m,f=0;for(d=0;d<=Zv;d++)e.bl_count[d]=0;for(i[2*e.heap[e.heap_max]+1]=0,c=e.heap_max+1;c<573;c++)l=e.heap[c],d=i[2*i[2*l+1]+1]+1,d>h&&(d=h,f++),i[2*l+1]=d,l>n||(e.bl_count[d]++,p=0,l>=o&&(p=a[l-o]),m=i[2*l],e.opt_len+=m*(d+p),s&&(e.static_len+=m*(r[2*l+1]+p)));if(0!==f){do{for(d=h-1;0===e.bl_count[d];)d--;e.bl_count[d]--,e.bl_count[d+1]+=2,e.bl_count[h]--,f-=2}while(f>0);for(d=h;0!==d;d--)for(l=e.bl_count[d];0!==l;)u=e.heap[--c],u>n||(i[2*u+1]!==d&&(e.opt_len+=(d-i[2*u+1])*i[2*u],i[2*u+1]=d),l--)}})(e,t),gy(i,c,e.bl_count)},My=(e,t,i)=>{let n,r,s=-1,a=t[1],o=0,h=7,c=4;for(0===a&&(h=138,c=3),t[2*(i+1)+1]=65535,n=0;n<=i;n++)r=a,a=t[2*(n+1)+1],++o<h&&r===a||(o<c?e.bl_tree[2*r]+=o:0!==r?(r!==s&&e.bl_tree[2*r]++,e.bl_tree[32]++):o<=10?e.bl_tree[34]++:e.bl_tree[36]++,o=0,s=r,0===a?(h=138,c=3):r===a?(h=6,c=3):(h=7,c=4))},Sy=(e,t,i)=>{let n,r,s=-1,a=t[1],o=0,h=7,c=4;for(0===a&&(h=138,c=3),n=0;n<=i;n++)if(r=a,a=t[2*(n+1)+1],!(++o<h&&r===a)){if(o<c)do{my(e,r,e.bl_tree)}while(0!=--o);else 0!==r?(r!==s&&(my(e,r,e.bl_tree),o--),my(e,16,e.bl_tree),py(e,o-3,2)):o<=10?(my(e,17,e.bl_tree),py(e,o-3,3)):(my(e,18,e.bl_tree),py(e,o-11,7));o=0,s=r,0===a?(h=138,c=3):r===a?(h=6,c=3):(h=7,c=4)}};let Ty=!1;const Cy=(e,t,i,n)=>{py(e,0+(n?1:0),3),((e,t,i,n)=>{vy(e),n&&(dy(e,i),dy(e,~i)),e.pending_buf.set(e.window.subarray(t,t+i),e.pending),e.pending+=i})(e,t,i,!0)};var Ey={_tr_init:e=>{Ty||((()=>{let e,t,i,n,r;const s=new Array(16);for(i=0,n=0;n<28;n++)for(ry[n]=i,e=0;e<1<<Yv[n];e++)ny[i++]=n;for(ny[i-1]=n,r=0,n=0;n<16;n++)for(sy[n]=r,e=0;e<1<<Jv[n];e++)iy[r++]=n;for(r>>=7;n<Xv;n++)for(sy[n]=r<<7,e=0;e<1<<Jv[n]-7;e++)iy[256+r++]=n;for(t=0;t<=Zv;t++)s[t]=0;for(e=0;e<=143;)ey[2*e+1]=8,e++,s[8]++;for(;e<=255;)ey[2*e+1]=9,e++,s[9]++;for(;e<=279;)ey[2*e+1]=7,e++,s[7]++;for(;e<=287;)ey[2*e+1]=8,e++,s[8]++;for(gy(ey,287,s),e=0;e<Xv;e++)ty[2*e+1]=5,ty[2*e]=fy(e,5);oy=new ay(ey,Yv,257,qv,Zv),hy=new ay(ty,Jv,0,Xv,Zv),cy=new ay(new Array(0),Kv,0,19,7)})(),Ty=!0),e.l_desc=new ly(e.dyn_ltree,oy),e.d_desc=new ly(e.dyn_dtree,hy),e.bl_desc=new ly(e.bl_tree,cy),e.bi_buf=0,e.bi_valid=0,_y(e)},_tr_stored_block:Cy,_tr_flush_block:(e,t,i,n)=>{let r,s,a=0;e.level>0?(2===e.strm.data_type&&(e.strm.data_type=(e=>{let t,i=4093624447;for(t=0;t<=31;t++,i>>>=1)if(1&i&&0!==e.dyn_ltree[2*t])return 0;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return 1;for(t=32;t<Wv;t++)if(0!==e.dyn_ltree[2*t])return 1;return 0})(e)),wy(e,e.l_desc),wy(e,e.d_desc),a=(e=>{let t;for(My(e,e.dyn_ltree,e.l_desc.max_code),My(e,e.dyn_dtree,e.d_desc.max_code),wy(e,e.bl_desc),t=18;t>=3&&0===e.bl_tree[2*Qv[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t})(e),r=e.opt_len+3+7>>>3,s=e.static_len+3+7>>>3,s<=r&&(r=s)):r=s=i+5,i+4<=r&&-1!==t?Cy(e,t,i,n):4===e.strategy||s===r?(py(e,2+(n?1:0),3),xy(e,ey,ty)):(py(e,4+(n?1:0),3),((e,t,i,n)=>{let r;for(py(e,t-257,5),py(e,i-1,5),py(e,n-4,4),r=0;r<n;r++)py(e,e.bl_tree[2*Qv[r]+1],3);Sy(e,e.dyn_ltree,t-1),Sy(e,e.dyn_dtree,i-1)})(e,e.l_desc.max_code+1,e.d_desc.max_code+1,a+1),xy(e,e.dyn_ltree,e.dyn_dtree)),_y(e),n&&vy(e)},_tr_tally:(e,t,i)=>(e.pending_buf[e.d_buf+2*e.last_lit]=t>>>8&255,e.pending_buf[e.d_buf+2*e.last_lit+1]=255&t,e.pending_buf[e.l_buf+e.last_lit]=255&i,e.last_lit++,0===t?e.dyn_ltree[2*i]++:(e.matches++,t--,e.dyn_ltree[2*(ny[i]+Wv+1)]++,e.dyn_dtree[2*uy(t)]++),e.last_lit===e.lit_bufsize-1),_tr_align:e=>{py(e,2,3),my(e,256,ey),(e=>{16===e.bi_valid?(dy(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)})(e)}};var Ay=(e,t,i,n)=>{let r=65535&e|0,s=e>>>16&65535|0,a=0;for(;0!==i;){a=i>2e3?2e3:i,i-=a;do{r=r+t[n++]|0,s=s+r|0}while(--a);r%=65521,s%=65521}return r|s<<16|0};const Iy=new Uint32Array((()=>{let e,t=[];for(var i=0;i<256;i++){e=i;for(var n=0;n<8;n++)e=1&e?3988292384^e>>>1:e>>>1;t[i]=e}return t})());var Ry=(e,t,i,n)=>{const r=Iy,s=n+i;e^=-1;for(let i=n;i<s;i++)e=e>>>8^r[255&(e^t[i])];return-1^e},Py={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"},Ly={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};const{_tr_init:Dy,_tr_stored_block:Ny,_tr_flush_block:$y,_tr_tally:ky,_tr_align:Oy}=Ey,{Z_NO_FLUSH:zy,Z_PARTIAL_FLUSH:Fy,Z_FULL_FLUSH:By,Z_FINISH:Uy,Z_BLOCK:Vy,Z_OK:Hy,Z_STREAM_END:jy,Z_STREAM_ERROR:Gy,Z_DATA_ERROR:Wy,Z_BUF_ERROR:qy,Z_DEFAULT_COMPRESSION:Xy,Z_FILTERED:Zy,Z_HUFFMAN_ONLY:Yy,Z_RLE:Jy,Z_FIXED:Ky,Z_DEFAULT_STRATEGY:Qy,Z_UNKNOWN:eb,Z_DEFLATED:tb}=Ly,ib=258,nb=262,rb=103,sb=113,ab=666,ob=(e,t)=>(e.msg=Py[t],t),hb=e=>(e<<1)-(e>4?9:0),cb=e=>{let t=e.length;for(;--t>=0;)e[t]=0};let lb=(e,t,i)=>(t<<e.hash_shift^i)&e.hash_mask;const ub=e=>{const t=e.state;let i=t.pending;i>e.avail_out&&(i=e.avail_out),0!==i&&(e.output.set(t.pending_buf.subarray(t.pending_out,t.pending_out+i),e.next_out),e.next_out+=i,t.pending_out+=i,e.total_out+=i,e.avail_out-=i,t.pending-=i,0===t.pending&&(t.pending_out=0))},db=(e,t)=>{$y(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,ub(e.strm)},pb=(e,t)=>{e.pending_buf[e.pending++]=t},mb=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t},fb=(e,t,i,n)=>{let r=e.avail_in;return r>n&&(r=n),0===r?0:(e.avail_in-=r,t.set(e.input.subarray(e.next_in,e.next_in+r),i),1===e.state.wrap?e.adler=Ay(e.adler,t,r,i):2===e.state.wrap&&(e.adler=Ry(e.adler,t,r,i)),e.next_in+=r,e.total_in+=r,r)},gb=(e,t)=>{let i,n,r=e.max_chain_length,s=e.strstart,a=e.prev_length,o=e.nice_match;const h=e.strstart>e.w_size-nb?e.strstart-(e.w_size-nb):0,c=e.window,l=e.w_mask,u=e.prev,d=e.strstart+ib;let p=c[s+a-1],m=c[s+a];e.prev_length>=e.good_match&&(r>>=2),o>e.lookahead&&(o=e.lookahead);do{if(i=t,c[i+a]===m&&c[i+a-1]===p&&c[i]===c[s]&&c[++i]===c[s+1]){s+=2,i++;do{}while(c[++s]===c[++i]&&c[++s]===c[++i]&&c[++s]===c[++i]&&c[++s]===c[++i]&&c[++s]===c[++i]&&c[++s]===c[++i]&&c[++s]===c[++i]&&c[++s]===c[++i]&&s<d);if(n=ib-(d-s),s=d-ib,n>a){if(e.match_start=t,a=n,n>=o)break;p=c[s+a-1],m=c[s+a]}}}while((t=u[t&l])>h&&0!=--r);return a<=e.lookahead?a:e.lookahead},_b=e=>{const t=e.w_size;let i,n,r,s,a;do{if(s=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-nb)){e.window.set(e.window.subarray(t,t+t),0),e.match_start-=t,e.strstart-=t,e.block_start-=t,n=e.hash_size,i=n;do{r=e.head[--i],e.head[i]=r>=t?r-t:0}while(--n);n=t,i=n;do{r=e.prev[--i],e.prev[i]=r>=t?r-t:0}while(--n);s+=t}if(0===e.strm.avail_in)break;if(n=fb(e.strm,e.window,e.strstart+e.lookahead,s),e.lookahead+=n,e.lookahead+e.insert>=3)for(a=e.strstart-e.insert,e.ins_h=e.window[a],e.ins_h=lb(e,e.ins_h,e.window[a+1]);e.insert&&(e.ins_h=lb(e,e.ins_h,e.window[a+3-1]),e.prev[a&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=a,a++,e.insert--,!(e.lookahead+e.insert<3)););}while(e.lookahead<nb&&0!==e.strm.avail_in)},vb=(e,t)=>{let i,n;for(;;){if(e.lookahead<nb){if(_b(e),e.lookahead<nb&&t===zy)return 1;if(0===e.lookahead)break}if(i=0,e.lookahead>=3&&(e.ins_h=lb(e,e.ins_h,e.window[e.strstart+3-1]),i=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!==i&&e.strstart-i<=e.w_size-nb&&(e.match_length=gb(e,i)),e.match_length>=3)if(n=ky(e,e.strstart-e.match_start,e.match_length-3),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=3){e.match_length--;do{e.strstart++,e.ins_h=lb(e,e.ins_h,e.window[e.strstart+3-1]),i=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart}while(0!=--e.match_length);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=lb(e,e.ins_h,e.window[e.strstart+1]);else n=ky(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(n&&(db(e,!1),0===e.strm.avail_out))return 1}return e.insert=e.strstart<2?e.strstart:2,t===Uy?(db(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(db(e,!1),0===e.strm.avail_out)?1:2},yb=(e,t)=>{let i,n,r;for(;;){if(e.lookahead<nb){if(_b(e),e.lookahead<nb&&t===zy)return 1;if(0===e.lookahead)break}if(i=0,e.lookahead>=3&&(e.ins_h=lb(e,e.ins_h,e.window[e.strstart+3-1]),i=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=2,0!==i&&e.prev_length<e.max_lazy_match&&e.strstart-i<=e.w_size-nb&&(e.match_length=gb(e,i),e.match_length<=5&&(e.strategy===Zy||3===e.match_length&&e.strstart-e.match_start>4096)&&(e.match_length=2)),e.prev_length>=3&&e.match_length<=e.prev_length){r=e.strstart+e.lookahead-3,n=ky(e,e.strstart-1-e.prev_match,e.prev_length-3),e.lookahead-=e.prev_length-1,e.prev_length-=2;do{++e.strstart<=r&&(e.ins_h=lb(e,e.ins_h,e.window[e.strstart+3-1]),i=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart)}while(0!=--e.prev_length);if(e.match_available=0,e.match_length=2,e.strstart++,n&&(db(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if(n=ky(e,0,e.window[e.strstart-1]),n&&db(e,!1),e.strstart++,e.lookahead--,0===e.strm.avail_out)return 1}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(n=ky(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,t===Uy?(db(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(db(e,!1),0===e.strm.avail_out)?1:2};function bb(e,t,i,n,r){this.good_length=e,this.max_lazy=t,this.nice_length=i,this.max_chain=n,this.func=r}const xb=[new bb(0,0,0,0,((e,t)=>{let i=65535;for(i>e.pending_buf_size-5&&(i=e.pending_buf_size-5);;){if(e.lookahead<=1){if(_b(e),0===e.lookahead&&t===zy)return 1;if(0===e.lookahead)break}e.strstart+=e.lookahead,e.lookahead=0;const n=e.block_start+i;if((0===e.strstart||e.strstart>=n)&&(e.lookahead=e.strstart-n,e.strstart=n,db(e,!1),0===e.strm.avail_out))return 1;if(e.strstart-e.block_start>=e.w_size-nb&&(db(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===Uy?(db(e,!0),0===e.strm.avail_out?3:4):(e.strstart>e.block_start&&(db(e,!1),e.strm.avail_out),1)})),new bb(4,4,8,4,vb),new bb(4,5,16,8,vb),new bb(4,6,32,32,vb),new bb(4,4,16,16,yb),new bb(8,16,32,32,yb),new bb(8,16,128,128,yb),new bb(8,32,128,256,yb),new bb(32,128,258,1024,yb),new bb(32,258,258,4096,yb)];function wb(){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=tb,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),cb(this.dyn_ltree),cb(this.dyn_dtree),cb(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),cb(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),cb(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 Mb=e=>{if(!e||!e.state)return ob(e,Gy);e.total_in=e.total_out=0,e.data_type=eb;const t=e.state;return t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap?42:sb,e.adler=2===t.wrap?0:1,t.last_flush=zy,Dy(t),Hy},Sb=e=>{const t=Mb(e);var i;return t===Hy&&((i=e.state).window_size=2*i.w_size,cb(i.head),i.max_lazy_match=xb[i.level].max_lazy,i.good_match=xb[i.level].good_length,i.nice_match=xb[i.level].nice_length,i.max_chain_length=xb[i.level].max_chain,i.strstart=0,i.block_start=0,i.lookahead=0,i.insert=0,i.match_length=i.prev_length=2,i.match_available=0,i.ins_h=0),t},Tb=(e,t,i,n,r,s)=>{if(!e)return Gy;let a=1;if(t===Xy&&(t=6),n<0?(a=0,n=-n):n>15&&(a=2,n-=16),r<1||r>9||i!==tb||n<8||n>15||t<0||t>9||s<0||s>Ky)return ob(e,Gy);8===n&&(n=9);const o=new wb;return e.state=o,o.strm=e,o.wrap=a,o.gzhead=null,o.w_bits=n,o.w_size=1<<o.w_bits,o.w_mask=o.w_size-1,o.hash_bits=r+7,o.hash_size=1<<o.hash_bits,o.hash_mask=o.hash_size-1,o.hash_shift=~~((o.hash_bits+3-1)/3),o.window=new Uint8Array(2*o.w_size),o.head=new Uint16Array(o.hash_size),o.prev=new Uint16Array(o.w_size),o.lit_bufsize=1<<r+6,o.pending_buf_size=4*o.lit_bufsize,o.pending_buf=new Uint8Array(o.pending_buf_size),o.d_buf=1*o.lit_bufsize,o.l_buf=3*o.lit_bufsize,o.level=t,o.strategy=s,o.method=i,Sb(e)};var Cb={deflateInit:(e,t)=>Tb(e,t,tb,15,8,Qy),deflateInit2:Tb,deflateReset:Sb,deflateResetKeep:Mb,deflateSetHeader:(e,t)=>e&&e.state?2!==e.state.wrap?Gy:(e.state.gzhead=t,Hy):Gy,deflate:(e,t)=>{let i,n;if(!e||!e.state||t>Vy||t<0)return e?ob(e,Gy):Gy;const r=e.state;if(!e.output||!e.input&&0!==e.avail_in||r.status===ab&&t!==Uy)return ob(e,0===e.avail_out?qy:Gy);r.strm=e;const s=r.last_flush;if(r.last_flush=t,42===r.status)if(2===r.wrap)e.adler=0,pb(r,31),pb(r,139),pb(r,8),r.gzhead?(pb(r,(r.gzhead.text?1:0)+(r.gzhead.hcrc?2:0)+(r.gzhead.extra?4:0)+(r.gzhead.name?8:0)+(r.gzhead.comment?16:0)),pb(r,255&r.gzhead.time),pb(r,r.gzhead.time>>8&255),pb(r,r.gzhead.time>>16&255),pb(r,r.gzhead.time>>24&255),pb(r,9===r.level?2:r.strategy>=Yy||r.level<2?4:0),pb(r,255&r.gzhead.os),r.gzhead.extra&&r.gzhead.extra.length&&(pb(r,255&r.gzhead.extra.length),pb(r,r.gzhead.extra.length>>8&255)),r.gzhead.hcrc&&(e.adler=Ry(e.adler,r.pending_buf,r.pending,0)),r.gzindex=0,r.status=69):(pb(r,0),pb(r,0),pb(r,0),pb(r,0),pb(r,0),pb(r,9===r.level?2:r.strategy>=Yy||r.level<2?4:0),pb(r,3),r.status=sb);else{let t=tb+(r.w_bits-8<<4)<<8,i=-1;i=r.strategy>=Yy||r.level<2?0:r.level<6?1:6===r.level?2:3,t|=i<<6,0!==r.strstart&&(t|=32),t+=31-t%31,r.status=sb,mb(r,t),0!==r.strstart&&(mb(r,e.adler>>>16),mb(r,65535&e.adler)),e.adler=1}if(69===r.status)if(r.gzhead.extra){for(i=r.pending;r.gzindex<(65535&r.gzhead.extra.length)&&(r.pending!==r.pending_buf_size||(r.gzhead.hcrc&&r.pending>i&&(e.adler=Ry(e.adler,r.pending_buf,r.pending-i,i)),ub(e),i=r.pending,r.pending!==r.pending_buf_size));)pb(r,255&r.gzhead.extra[r.gzindex]),r.gzindex++;r.gzhead.hcrc&&r.pending>i&&(e.adler=Ry(e.adler,r.pending_buf,r.pending-i,i)),r.gzindex===r.gzhead.extra.length&&(r.gzindex=0,r.status=73)}else r.status=73;if(73===r.status)if(r.gzhead.name){i=r.pending;do{if(r.pending===r.pending_buf_size&&(r.gzhead.hcrc&&r.pending>i&&(e.adler=Ry(e.adler,r.pending_buf,r.pending-i,i)),ub(e),i=r.pending,r.pending===r.pending_buf_size)){n=1;break}n=r.gzindex<r.gzhead.name.length?255&r.gzhead.name.charCodeAt(r.gzindex++):0,pb(r,n)}while(0!==n);r.gzhead.hcrc&&r.pending>i&&(e.adler=Ry(e.adler,r.pending_buf,r.pending-i,i)),0===n&&(r.gzindex=0,r.status=91)}else r.status=91;if(91===r.status)if(r.gzhead.comment){i=r.pending;do{if(r.pending===r.pending_buf_size&&(r.gzhead.hcrc&&r.pending>i&&(e.adler=Ry(e.adler,r.pending_buf,r.pending-i,i)),ub(e),i=r.pending,r.pending===r.pending_buf_size)){n=1;break}n=r.gzindex<r.gzhead.comment.length?255&r.gzhead.comment.charCodeAt(r.gzindex++):0,pb(r,n)}while(0!==n);r.gzhead.hcrc&&r.pending>i&&(e.adler=Ry(e.adler,r.pending_buf,r.pending-i,i)),0===n&&(r.status=rb)}else r.status=rb;if(r.status===rb&&(r.gzhead.hcrc?(r.pending+2>r.pending_buf_size&&ub(e),r.pending+2<=r.pending_buf_size&&(pb(r,255&e.adler),pb(r,e.adler>>8&255),e.adler=0,r.status=sb)):r.status=sb),0!==r.pending){if(ub(e),0===e.avail_out)return r.last_flush=-1,Hy}else if(0===e.avail_in&&hb(t)<=hb(s)&&t!==Uy)return ob(e,qy);if(r.status===ab&&0!==e.avail_in)return ob(e,qy);if(0!==e.avail_in||0!==r.lookahead||t!==zy&&r.status!==ab){let i=r.strategy===Yy?((e,t)=>{let i;for(;;){if(0===e.lookahead&&(_b(e),0===e.lookahead)){if(t===zy)return 1;break}if(e.match_length=0,i=ky(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,i&&(db(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===Uy?(db(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(db(e,!1),0===e.strm.avail_out)?1:2})(r,t):r.strategy===Jy?((e,t)=>{let i,n,r,s;const a=e.window;for(;;){if(e.lookahead<=ib){if(_b(e),e.lookahead<=ib&&t===zy)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=3&&e.strstart>0&&(r=e.strstart-1,n=a[r],n===a[++r]&&n===a[++r]&&n===a[++r])){s=e.strstart+ib;do{}while(n===a[++r]&&n===a[++r]&&n===a[++r]&&n===a[++r]&&n===a[++r]&&n===a[++r]&&n===a[++r]&&n===a[++r]&&r<s);e.match_length=ib-(s-r),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=3?(i=ky(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(i=ky(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),i&&(db(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===Uy?(db(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(db(e,!1),0===e.strm.avail_out)?1:2})(r,t):xb[r.level].func(r,t);if(3!==i&&4!==i||(r.status=ab),1===i||3===i)return 0===e.avail_out&&(r.last_flush=-1),Hy;if(2===i&&(t===Fy?Oy(r):t!==Vy&&(Ny(r,0,0,!1),t===By&&(cb(r.head),0===r.lookahead&&(r.strstart=0,r.block_start=0,r.insert=0))),ub(e),0===e.avail_out))return r.last_flush=-1,Hy}return t!==Uy?Hy:r.wrap<=0?jy:(2===r.wrap?(pb(r,255&e.adler),pb(r,e.adler>>8&255),pb(r,e.adler>>16&255),pb(r,e.adler>>24&255),pb(r,255&e.total_in),pb(r,e.total_in>>8&255),pb(r,e.total_in>>16&255),pb(r,e.total_in>>24&255)):(mb(r,e.adler>>>16),mb(r,65535&e.adler)),ub(e),r.wrap>0&&(r.wrap=-r.wrap),0!==r.pending?Hy:jy)},deflateEnd:e=>{if(!e||!e.state)return Gy;const t=e.state.status;return 42!==t&&69!==t&&73!==t&&91!==t&&t!==rb&&t!==sb&&t!==ab?ob(e,Gy):(e.state=null,t===sb?ob(e,Wy):Hy)},deflateSetDictionary:(e,t)=>{let i=t.length;if(!e||!e.state)return Gy;const n=e.state,r=n.wrap;if(2===r||1===r&&42!==n.status||n.lookahead)return Gy;if(1===r&&(e.adler=Ay(e.adler,t,i,0)),n.wrap=0,i>=n.w_size){0===r&&(cb(n.head),n.strstart=0,n.block_start=0,n.insert=0);let e=new Uint8Array(n.w_size);e.set(t.subarray(i-n.w_size,i),0),t=e,i=n.w_size}const s=e.avail_in,a=e.next_in,o=e.input;for(e.avail_in=i,e.next_in=0,e.input=t,_b(n);n.lookahead>=3;){let e=n.strstart,t=n.lookahead-2;do{n.ins_h=lb(n,n.ins_h,n.window[e+3-1]),n.prev[e&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=e,e++}while(--t);n.strstart=e,n.lookahead=2,_b(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,e.next_in=a,e.input=o,e.avail_in=s,n.wrap=r,Hy},deflateInfo:"pako deflate (from Nodeca project)"};const Eb=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var Ab=function(e){const t=Array.prototype.slice.call(arguments,1);for(;t.length;){const i=t.shift();if(i){if("object"!=typeof i)throw new TypeError(i+"must be non-object");for(const t in i)Eb(i,t)&&(e[t]=i[t])}}return e},Ib=e=>{let t=0;for(let i=0,n=e.length;i<n;i++)t+=e[i].length;const i=new Uint8Array(t);for(let t=0,n=0,r=e.length;t<r;t++){let r=e[t];i.set(r,n),n+=r.length}return i};let Rb=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(e){Rb=!1}const Pb=new Uint8Array(256);for(let e=0;e<256;e++)Pb[e]=e>=252?6:e>=248?5:e>=240?4:e>=224?3:e>=192?2:1;Pb[254]=Pb[254]=1;var Lb=e=>{if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(e);let t,i,n,r,s,a=e.length,o=0;for(r=0;r<a;r++)i=e.charCodeAt(r),55296==(64512&i)&&r+1<a&&(n=e.charCodeAt(r+1),56320==(64512&n)&&(i=65536+(i-55296<<10)+(n-56320),r++)),o+=i<128?1:i<2048?2:i<65536?3:4;for(t=new Uint8Array(o),s=0,r=0;s<o;r++)i=e.charCodeAt(r),55296==(64512&i)&&r+1<a&&(n=e.charCodeAt(r+1),56320==(64512&n)&&(i=65536+(i-55296<<10)+(n-56320),r++)),i<128?t[s++]=i:i<2048?(t[s++]=192|i>>>6,t[s++]=128|63&i):i<65536?(t[s++]=224|i>>>12,t[s++]=128|i>>>6&63,t[s++]=128|63&i):(t[s++]=240|i>>>18,t[s++]=128|i>>>12&63,t[s++]=128|i>>>6&63,t[s++]=128|63&i);return t},Db=(e,t)=>{const i=t||e.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(e.subarray(0,t));let n,r;const s=new Array(2*i);for(r=0,n=0;n<i;){let t=e[n++];if(t<128){s[r++]=t;continue}let a=Pb[t];if(a>4)s[r++]=65533,n+=a-1;else{for(t&=2===a?31:3===a?15:7;a>1&&n<i;)t=t<<6|63&e[n++],a--;a>1?s[r++]=65533:t<65536?s[r++]=t:(t-=65536,s[r++]=55296|t>>10&1023,s[r++]=56320|1023&t)}}return((e,t)=>{if(t<65534&&e.subarray&&Rb)return String.fromCharCode.apply(null,e.length===t?e:e.subarray(0,t));let i="";for(let n=0;n<t;n++)i+=String.fromCharCode(e[n]);return i})(s,r)},Nb=(e,t)=>{(t=t||e.length)>e.length&&(t=e.length);let i=t-1;for(;i>=0&&128==(192&e[i]);)i--;return i<0||0===i?t:i+Pb[e[i]]>t?i:t};var $b=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};const kb=Object.prototype.toString,{Z_NO_FLUSH:Ob,Z_SYNC_FLUSH:zb,Z_FULL_FLUSH:Fb,Z_FINISH:Bb,Z_OK:Ub,Z_STREAM_END:Vb,Z_DEFAULT_COMPRESSION:Hb,Z_DEFAULT_STRATEGY:jb,Z_DEFLATED:Gb}=Ly;function Wb(e){this.options=Ab({level:Hb,method:Gb,chunkSize:16384,windowBits:15,memLevel:8,strategy:jb},e||{});let t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new $b,this.strm.avail_out=0;let i=Cb.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(i!==Ub)throw new Error(Py[i]);if(t.header&&Cb.deflateSetHeader(this.strm,t.header),t.dictionary){let e;if(e="string"==typeof t.dictionary?Lb(t.dictionary):"[object ArrayBuffer]"===kb.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,i=Cb.deflateSetDictionary(this.strm,e),i!==Ub)throw new Error(Py[i]);this._dict_set=!0}}Wb.prototype.push=function(e,t){const i=this.strm,n=this.options.chunkSize;let r,s;if(this.ended)return!1;for(s=t===~~t?t:!0===t?Bb:Ob,"string"==typeof e?i.input=Lb(e):"[object ArrayBuffer]"===kb.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(n),i.next_out=0,i.avail_out=n),(s===zb||s===Fb)&&i.avail_out<=6)this.onData(i.output.subarray(0,i.next_out)),i.avail_out=0;else{if(r=Cb.deflate(i,s),r===Vb)return i.next_out>0&&this.onData(i.output.subarray(0,i.next_out)),r=Cb.deflateEnd(this.strm),this.onEnd(r),this.ended=!0,r===Ub;if(0!==i.avail_out){if(s>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},Wb.prototype.onData=function(e){this.chunks.push(e)},Wb.prototype.onEnd=function(e){e===Ub&&(this.result=Ib(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var qb=function(e,t){let i,n,r,s,a,o,h,c,l,u,d,p,m,f,g,_,v,y,b,x,w,M,S,T;const C=e.state;i=e.next_in,S=e.input,n=i+(e.avail_in-5),r=e.next_out,T=e.output,s=r-(t-e.avail_out),a=r+(e.avail_out-257),o=C.dmax,h=C.wsize,c=C.whave,l=C.wnext,u=C.window,d=C.hold,p=C.bits,m=C.lencode,f=C.distcode,g=(1<<C.lenbits)-1,_=(1<<C.distbits)-1;e:do{p<15&&(d+=S[i++]<<p,p+=8,d+=S[i++]<<p,p+=8),v=m[d&g];t:for(;;){if(y=v>>>24,d>>>=y,p-=y,y=v>>>16&255,0===y)T[r++]=65535&v;else{if(!(16&y)){if(0==(64&y)){v=m[(65535&v)+(d&(1<<y)-1)];continue t}if(32&y){C.mode=12;break e}e.msg="invalid literal/length code",C.mode=30;break e}b=65535&v,y&=15,y&&(p<y&&(d+=S[i++]<<p,p+=8),b+=d&(1<<y)-1,d>>>=y,p-=y),p<15&&(d+=S[i++]<<p,p+=8,d+=S[i++]<<p,p+=8),v=f[d&_];i:for(;;){if(y=v>>>24,d>>>=y,p-=y,y=v>>>16&255,!(16&y)){if(0==(64&y)){v=f[(65535&v)+(d&(1<<y)-1)];continue i}e.msg="invalid distance code",C.mode=30;break e}if(x=65535&v,y&=15,p<y&&(d+=S[i++]<<p,p+=8,p<y&&(d+=S[i++]<<p,p+=8)),x+=d&(1<<y)-1,x>o){e.msg="invalid distance too far back",C.mode=30;break e}if(d>>>=y,p-=y,y=r-s,x>y){if(y=x-y,y>c&&C.sane){e.msg="invalid distance too far back",C.mode=30;break e}if(w=0,M=u,0===l){if(w+=h-y,y<b){b-=y;do{T[r++]=u[w++]}while(--y);w=r-x,M=T}}else if(l<y){if(w+=h+l-y,y-=l,y<b){b-=y;do{T[r++]=u[w++]}while(--y);if(w=0,l<b){y=l,b-=y;do{T[r++]=u[w++]}while(--y);w=r-x,M=T}}}else if(w+=l-y,y<b){b-=y;do{T[r++]=u[w++]}while(--y);w=r-x,M=T}for(;b>2;)T[r++]=M[w++],T[r++]=M[w++],T[r++]=M[w++],b-=3;b&&(T[r++]=M[w++],b>1&&(T[r++]=M[w++]))}else{w=r-x;do{T[r++]=T[w++],T[r++]=T[w++],T[r++]=T[w++],b-=3}while(b>2);b&&(T[r++]=T[w++],b>1&&(T[r++]=T[w++]))}break}}break}}while(i<n&&r<a);b=p>>3,i-=b,p-=b<<3,d&=(1<<p)-1,e.next_in=i,e.next_out=r,e.avail_in=i<n?n-i+5:5-(i-n),e.avail_out=r<a?a-r+257:257-(r-a),C.hold=d,C.bits=p};const Xb=15,Zb=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0]),Yb=new Uint8Array([16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78]),Jb=new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0]),Kb=new Uint8Array([16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64]);var Qb=(e,t,i,n,r,s,a,o)=>{const h=o.bits;let c,l,u,d,p,m,f=0,g=0,_=0,v=0,y=0,b=0,x=0,w=0,M=0,S=0,T=null,C=0;const E=new Uint16Array(16),A=new Uint16Array(16);let I,R,P,L=null,D=0;for(f=0;f<=Xb;f++)E[f]=0;for(g=0;g<n;g++)E[t[i+g]]++;for(y=h,v=Xb;v>=1&&0===E[v];v--);if(y>v&&(y=v),0===v)return r[s++]=20971520,r[s++]=20971520,o.bits=1,0;for(_=1;_<v&&0===E[_];_++);for(y<_&&(y=_),w=1,f=1;f<=Xb;f++)if(w<<=1,w-=E[f],w<0)return-1;if(w>0&&(0===e||1!==v))return-1;for(A[1]=0,f=1;f<Xb;f++)A[f+1]=A[f]+E[f];for(g=0;g<n;g++)0!==t[i+g]&&(a[A[t[i+g]]++]=g);if(0===e?(T=L=a,m=19):1===e?(T=Zb,C-=257,L=Yb,D-=257,m=256):(T=Jb,L=Kb,m=-1),S=0,g=0,f=_,p=s,b=y,x=0,u=-1,M=1<<y,d=M-1,1===e&&M>852||2===e&&M>592)return 1;for(;;){I=f-x,a[g]<m?(R=0,P=a[g]):a[g]>m?(R=L[D+a[g]],P=T[C+a[g]]):(R=96,P=0),c=1<<f-x,l=1<<b,_=l;do{l-=c,r[p+(S>>x)+l]=I<<24|R<<16|P|0}while(0!==l);for(c=1<<f-1;S&c;)c>>=1;if(0!==c?(S&=c-1,S+=c):S=0,g++,0==--E[f]){if(f===v)break;f=t[i+a[g]]}if(f>y&&(S&d)!==u){for(0===x&&(x=y),p+=_,b=f-x,w=1<<b;b+x<v&&(w-=E[b+x],!(w<=0));)b++,w<<=1;if(M+=1<<b,1===e&&M>852||2===e&&M>592)return 1;u=S&d,r[u]=y<<24|b<<16|p-s|0}}return 0!==S&&(r[p+S]=f-x<<24|64<<16|0),o.bits=y,0};const{Z_FINISH:ex,Z_BLOCK:tx,Z_TREES:ix,Z_OK:nx,Z_STREAM_END:rx,Z_NEED_DICT:sx,Z_STREAM_ERROR:ax,Z_DATA_ERROR:ox,Z_MEM_ERROR:hx,Z_BUF_ERROR:cx,Z_DEFLATED:lx}=Ly,ux=12,dx=30,px=e=>(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24);function mx(){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 fx=e=>{if(!e||!e.state)return ax;const 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,nx},gx=e=>{if(!e||!e.state)return ax;const t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,fx(e)},_x=(e,t)=>{let i;if(!e||!e.state)return ax;const n=e.state;return t<0?(i=0,t=-t):(i=1+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?ax:(null!==n.window&&n.wbits!==t&&(n.window=null),n.wrap=i,n.wbits=t,gx(e))},vx=(e,t)=>{if(!e)return ax;const i=new mx;e.state=i,i.window=null;const n=_x(e,t);return n!==nx&&(e.state=null),n};let yx,bx,xx=!0;const wx=e=>{if(xx){yx=new Int32Array(512),bx=new Int32Array(32);let t=0;for(;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(Qb(1,e.lens,0,288,yx,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;Qb(2,e.lens,0,32,bx,0,e.work,{bits:5}),xx=!1}e.lencode=yx,e.lenbits=9,e.distcode=bx,e.distbits=5},Mx=(e,t,i,n)=>{let r;const s=e.state;return null===s.window&&(s.wsize=1<<s.wbits,s.wnext=0,s.whave=0,s.window=new Uint8Array(s.wsize)),n>=s.wsize?(s.window.set(t.subarray(i-s.wsize,i),0),s.wnext=0,s.whave=s.wsize):(r=s.wsize-s.wnext,r>n&&(r=n),s.window.set(t.subarray(i-n,i-n+r),s.wnext),(n-=r)?(s.window.set(t.subarray(i-n,i),0),s.wnext=n,s.whave=s.wsize):(s.wnext+=r,s.wnext===s.wsize&&(s.wnext=0),s.whave<s.wsize&&(s.whave+=r))),0};var Sx={inflateReset:gx,inflateReset2:_x,inflateResetKeep:fx,inflateInit:e=>vx(e,15),inflateInit2:vx,inflate:(e,t)=>{let i,n,r,s,a,o,h,c,l,u,d,p,m,f,g,_,v,y,b,x,w,M,S=0;const T=new Uint8Array(4);let C,E;const A=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(!e||!e.state||!e.output||!e.input&&0!==e.avail_in)return ax;i=e.state,i.mode===ux&&(i.mode=13),a=e.next_out,r=e.output,h=e.avail_out,s=e.next_in,n=e.input,o=e.avail_in,c=i.hold,l=i.bits,u=o,d=h,M=nx;e:for(;;)switch(i.mode){case 1:if(0===i.wrap){i.mode=13;break}for(;l<16;){if(0===o)break e;o--,c+=n[s++]<<l,l+=8}if(2&i.wrap&&35615===c){i.check=0,T[0]=255&c,T[1]=c>>>8&255,i.check=Ry(i.check,T,2,0),c=0,l=0,i.mode=2;break}if(i.flags=0,i.head&&(i.head.done=!1),!(1&i.wrap)||(((255&c)<<8)+(c>>8))%31){e.msg="incorrect header check",i.mode=dx;break}if((15&c)!==lx){e.msg="unknown compression method",i.mode=dx;break}if(c>>>=4,l-=4,w=8+(15&c),0===i.wbits)i.wbits=w;else if(w>i.wbits){e.msg="invalid window size",i.mode=dx;break}i.dmax=1<<i.wbits,e.adler=i.check=1,i.mode=512&c?10:ux,c=0,l=0;break;case 2:for(;l<16;){if(0===o)break e;o--,c+=n[s++]<<l,l+=8}if(i.flags=c,(255&i.flags)!==lx){e.msg="unknown compression method",i.mode=dx;break}if(57344&i.flags){e.msg="unknown header flags set",i.mode=dx;break}i.head&&(i.head.text=c>>8&1),512&i.flags&&(T[0]=255&c,T[1]=c>>>8&255,i.check=Ry(i.check,T,2,0)),c=0,l=0,i.mode=3;case 3:for(;l<32;){if(0===o)break e;o--,c+=n[s++]<<l,l+=8}i.head&&(i.head.time=c),512&i.flags&&(T[0]=255&c,T[1]=c>>>8&255,T[2]=c>>>16&255,T[3]=c>>>24&255,i.check=Ry(i.check,T,4,0)),c=0,l=0,i.mode=4;case 4:for(;l<16;){if(0===o)break e;o--,c+=n[s++]<<l,l+=8}i.head&&(i.head.xflags=255&c,i.head.os=c>>8),512&i.flags&&(T[0]=255&c,T[1]=c>>>8&255,i.check=Ry(i.check,T,2,0)),c=0,l=0,i.mode=5;case 5:if(1024&i.flags){for(;l<16;){if(0===o)break e;o--,c+=n[s++]<<l,l+=8}i.length=c,i.head&&(i.head.extra_len=c),512&i.flags&&(T[0]=255&c,T[1]=c>>>8&255,i.check=Ry(i.check,T,2,0)),c=0,l=0}else i.head&&(i.head.extra=null);i.mode=6;case 6:if(1024&i.flags&&(p=i.length,p>o&&(p=o),p&&(i.head&&(w=i.head.extra_len-i.length,i.head.extra||(i.head.extra=new Uint8Array(i.head.extra_len)),i.head.extra.set(n.subarray(s,s+p),w)),512&i.flags&&(i.check=Ry(i.check,n,p,s)),o-=p,s+=p,i.length-=p),i.length))break e;i.length=0,i.mode=7;case 7:if(2048&i.flags){if(0===o)break e;p=0;do{w=n[s+p++],i.head&&w&&i.length<65536&&(i.head.name+=String.fromCharCode(w))}while(w&&p<o);if(512&i.flags&&(i.check=Ry(i.check,n,p,s)),o-=p,s+=p,w)break e}else i.head&&(i.head.name=null);i.length=0,i.mode=8;case 8:if(4096&i.flags){if(0===o)break e;p=0;do{w=n[s+p++],i.head&&w&&i.length<65536&&(i.head.comment+=String.fromCharCode(w))}while(w&&p<o);if(512&i.flags&&(i.check=Ry(i.check,n,p,s)),o-=p,s+=p,w)break e}else i.head&&(i.head.comment=null);i.mode=9;case 9:if(512&i.flags){for(;l<16;){if(0===o)break e;o--,c+=n[s++]<<l,l+=8}if(c!==(65535&i.check)){e.msg="header crc mismatch",i.mode=dx;break}c=0,l=0}i.head&&(i.head.hcrc=i.flags>>9&1,i.head.done=!0),e.adler=i.check=0,i.mode=ux;break;case 10:for(;l<32;){if(0===o)break e;o--,c+=n[s++]<<l,l+=8}e.adler=i.check=px(c),c=0,l=0,i.mode=11;case 11:if(0===i.havedict)return e.next_out=a,e.avail_out=h,e.next_in=s,e.avail_in=o,i.hold=c,i.bits=l,sx;e.adler=i.check=1,i.mode=ux;case ux:if(t===tx||t===ix)break e;case 13:if(i.last){c>>>=7&l,l-=7&l,i.mode=27;break}for(;l<3;){if(0===o)break e;o--,c+=n[s++]<<l,l+=8}switch(i.last=1&c,c>>>=1,l-=1,3&c){case 0:i.mode=14;break;case 1:if(wx(i),i.mode=20,t===ix){c>>>=2,l-=2;break e}break;case 2:i.mode=17;break;case 3:e.msg="invalid block type",i.mode=dx}c>>>=2,l-=2;break;case 14:for(c>>>=7&l,l-=7&l;l<32;){if(0===o)break e;o--,c+=n[s++]<<l,l+=8}if((65535&c)!=(c>>>16^65535)){e.msg="invalid stored block lengths",i.mode=dx;break}if(i.length=65535&c,c=0,l=0,i.mode=15,t===ix)break e;case 15:i.mode=16;case 16:if(p=i.length,p){if(p>o&&(p=o),p>h&&(p=h),0===p)break e;r.set(n.subarray(s,s+p),a),o-=p,s+=p,h-=p,a+=p,i.length-=p;break}i.mode=ux;break;case 17:for(;l<14;){if(0===o)break e;o--,c+=n[s++]<<l,l+=8}if(i.nlen=257+(31&c),c>>>=5,l-=5,i.ndist=1+(31&c),c>>>=5,l-=5,i.ncode=4+(15&c),c>>>=4,l-=4,i.nlen>286||i.ndist>30){e.msg="too many length or distance symbols",i.mode=dx;break}i.have=0,i.mode=18;case 18:for(;i.have<i.ncode;){for(;l<3;){if(0===o)break e;o--,c+=n[s++]<<l,l+=8}i.lens[A[i.have++]]=7&c,c>>>=3,l-=3}for(;i.have<19;)i.lens[A[i.have++]]=0;if(i.lencode=i.lendyn,i.lenbits=7,C={bits:i.lenbits},M=Qb(0,i.lens,0,19,i.lencode,0,i.work,C),i.lenbits=C.bits,M){e.msg="invalid code lengths set",i.mode=dx;break}i.have=0,i.mode=19;case 19:for(;i.have<i.nlen+i.ndist;){for(;S=i.lencode[c&(1<<i.lenbits)-1],g=S>>>24,_=S>>>16&255,v=65535&S,!(g<=l);){if(0===o)break e;o--,c+=n[s++]<<l,l+=8}if(v<16)c>>>=g,l-=g,i.lens[i.have++]=v;else{if(16===v){for(E=g+2;l<E;){if(0===o)break e;o--,c+=n[s++]<<l,l+=8}if(c>>>=g,l-=g,0===i.have){e.msg="invalid bit length repeat",i.mode=dx;break}w=i.lens[i.have-1],p=3+(3&c),c>>>=2,l-=2}else if(17===v){for(E=g+3;l<E;){if(0===o)break e;o--,c+=n[s++]<<l,l+=8}c>>>=g,l-=g,w=0,p=3+(7&c),c>>>=3,l-=3}else{for(E=g+7;l<E;){if(0===o)break e;o--,c+=n[s++]<<l,l+=8}c>>>=g,l-=g,w=0,p=11+(127&c),c>>>=7,l-=7}if(i.have+p>i.nlen+i.ndist){e.msg="invalid bit length repeat",i.mode=dx;break}for(;p--;)i.lens[i.have++]=w}}if(i.mode===dx)break;if(0===i.lens[256]){e.msg="invalid code -- missing end-of-block",i.mode=dx;break}if(i.lenbits=9,C={bits:i.lenbits},M=Qb(1,i.lens,0,i.nlen,i.lencode,0,i.work,C),i.lenbits=C.bits,M){e.msg="invalid literal/lengths set",i.mode=dx;break}if(i.distbits=6,i.distcode=i.distdyn,C={bits:i.distbits},M=Qb(2,i.lens,i.nlen,i.ndist,i.distcode,0,i.work,C),i.distbits=C.bits,M){e.msg="invalid distances set",i.mode=dx;break}if(i.mode=20,t===ix)break e;case 20:i.mode=21;case 21:if(o>=6&&h>=258){e.next_out=a,e.avail_out=h,e.next_in=s,e.avail_in=o,i.hold=c,i.bits=l,qb(e,d),a=e.next_out,r=e.output,h=e.avail_out,s=e.next_in,n=e.input,o=e.avail_in,c=i.hold,l=i.bits,i.mode===ux&&(i.back=-1);break}for(i.back=0;S=i.lencode[c&(1<<i.lenbits)-1],g=S>>>24,_=S>>>16&255,v=65535&S,!(g<=l);){if(0===o)break e;o--,c+=n[s++]<<l,l+=8}if(_&&0==(240&_)){for(y=g,b=_,x=v;S=i.lencode[x+((c&(1<<y+b)-1)>>y)],g=S>>>24,_=S>>>16&255,v=65535&S,!(y+g<=l);){if(0===o)break e;o--,c+=n[s++]<<l,l+=8}c>>>=y,l-=y,i.back+=y}if(c>>>=g,l-=g,i.back+=g,i.length=v,0===_){i.mode=26;break}if(32&_){i.back=-1,i.mode=ux;break}if(64&_){e.msg="invalid literal/length code",i.mode=dx;break}i.extra=15&_,i.mode=22;case 22:if(i.extra){for(E=i.extra;l<E;){if(0===o)break e;o--,c+=n[s++]<<l,l+=8}i.length+=c&(1<<i.extra)-1,c>>>=i.extra,l-=i.extra,i.back+=i.extra}i.was=i.length,i.mode=23;case 23:for(;S=i.distcode[c&(1<<i.distbits)-1],g=S>>>24,_=S>>>16&255,v=65535&S,!(g<=l);){if(0===o)break e;o--,c+=n[s++]<<l,l+=8}if(0==(240&_)){for(y=g,b=_,x=v;S=i.distcode[x+((c&(1<<y+b)-1)>>y)],g=S>>>24,_=S>>>16&255,v=65535&S,!(y+g<=l);){if(0===o)break e;o--,c+=n[s++]<<l,l+=8}c>>>=y,l-=y,i.back+=y}if(c>>>=g,l-=g,i.back+=g,64&_){e.msg="invalid distance code",i.mode=dx;break}i.offset=v,i.extra=15&_,i.mode=24;case 24:if(i.extra){for(E=i.extra;l<E;){if(0===o)break e;o--,c+=n[s++]<<l,l+=8}i.offset+=c&(1<<i.extra)-1,c>>>=i.extra,l-=i.extra,i.back+=i.extra}if(i.offset>i.dmax){e.msg="invalid distance too far back",i.mode=dx;break}i.mode=25;case 25:if(0===h)break e;if(p=d-h,i.offset>p){if(p=i.offset-p,p>i.whave&&i.sane){e.msg="invalid distance too far back",i.mode=dx;break}p>i.wnext?(p-=i.wnext,m=i.wsize-p):m=i.wnext-p,p>i.length&&(p=i.length),f=i.window}else f=r,m=a-i.offset,p=i.length;p>h&&(p=h),h-=p,i.length-=p;do{r[a++]=f[m++]}while(--p);0===i.length&&(i.mode=21);break;case 26:if(0===h)break e;r[a++]=i.length,h--,i.mode=21;break;case 27:if(i.wrap){for(;l<32;){if(0===o)break e;o--,c|=n[s++]<<l,l+=8}if(d-=h,e.total_out+=d,i.total+=d,d&&(e.adler=i.check=i.flags?Ry(i.check,r,d,a-d):Ay(i.check,r,d,a-d)),d=h,(i.flags?c:px(c))!==i.check){e.msg="incorrect data check",i.mode=dx;break}c=0,l=0}i.mode=28;case 28:if(i.wrap&&i.flags){for(;l<32;){if(0===o)break e;o--,c+=n[s++]<<l,l+=8}if(c!==(4294967295&i.total)){e.msg="incorrect length check",i.mode=dx;break}c=0,l=0}i.mode=29;case 29:M=rx;break e;case dx:M=ox;break e;case 31:return hx;case 32:default:return ax}return e.next_out=a,e.avail_out=h,e.next_in=s,e.avail_in=o,i.hold=c,i.bits=l,(i.wsize||d!==e.avail_out&&i.mode<dx&&(i.mode<27||t!==ex))&&Mx(e,e.output,e.next_out,d-e.avail_out),u-=e.avail_in,d-=e.avail_out,e.total_in+=u,e.total_out+=d,i.total+=d,i.wrap&&d&&(e.adler=i.check=i.flags?Ry(i.check,r,d,e.next_out-d):Ay(i.check,r,d,e.next_out-d)),e.data_type=i.bits+(i.last?64:0)+(i.mode===ux?128:0)+(20===i.mode||15===i.mode?256:0),(0===u&&0===d||t===ex)&&M===nx&&(M=cx),M},inflateEnd:e=>{if(!e||!e.state)return ax;let t=e.state;return t.window&&(t.window=null),e.state=null,nx},inflateGetHeader:(e,t)=>{if(!e||!e.state)return ax;const i=e.state;return 0==(2&i.wrap)?ax:(i.head=t,t.done=!1,nx)},inflateSetDictionary:(e,t)=>{const i=t.length;let n,r,s;return e&&e.state?(n=e.state,0!==n.wrap&&11!==n.mode?ax:11===n.mode&&(r=1,r=Ay(r,t,i,0),r!==n.check)?ox:(s=Mx(e,t,i,i),s?(n.mode=31,hx):(n.havedict=1,nx))):ax},inflateInfo:"pako inflate (from Nodeca project)"};var Tx=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};const Cx=Object.prototype.toString,{Z_NO_FLUSH:Ex,Z_FINISH:Ax,Z_OK:Ix,Z_STREAM_END:Rx,Z_NEED_DICT:Px,Z_STREAM_ERROR:Lx,Z_DATA_ERROR:Dx,Z_MEM_ERROR:Nx}=Ly;function $x(e){this.options=Ab({chunkSize:65536,windowBits:15,to:""},e||{});const t=this.options;t.raw&&t.windowBits>=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 $b,this.strm.avail_out=0;let i=Sx.inflateInit2(this.strm,t.windowBits);if(i!==Ix)throw new Error(Py[i]);if(this.header=new Tx,Sx.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=Lb(t.dictionary):"[object ArrayBuffer]"===Cx.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(i=Sx.inflateSetDictionary(this.strm,t.dictionary),i!==Ix)))throw new Error(Py[i])}function kx(e,t){const i=new $x(t);if(i.push(e),i.err)throw i.msg||Py[i.err];return i.result}$x.prototype.push=function(e,t){const i=this.strm,n=this.options.chunkSize,r=this.options.dictionary;let s,a,o;if(this.ended)return!1;for(a=t===~~t?t:!0===t?Ax:Ex,"[object ArrayBuffer]"===Cx.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(n),i.next_out=0,i.avail_out=n),s=Sx.inflate(i,a),s===Px&&r&&(s=Sx.inflateSetDictionary(i,r),s===Ix?s=Sx.inflate(i,a):s===Dx&&(s=Px));i.avail_in>0&&s===Rx&&i.state.wrap>0&&0!==e[i.next_in];)Sx.inflateReset(i),s=Sx.inflate(i,a);switch(s){case Lx:case Dx:case Px:case Nx:return this.onEnd(s),this.ended=!0,!1}if(o=i.avail_out,i.next_out&&(0===i.avail_out||s===Rx))if("string"===this.options.to){let e=Nb(i.output,i.next_out),t=i.next_out-e,r=Db(i.output,e);i.next_out=t,i.avail_out=n-t,t&&i.output.set(i.output.subarray(e,e+t),0),this.onData(r)}else this.onData(i.output.length===i.next_out?i.output:i.output.subarray(0,i.next_out));if(s!==Ix||0!==o){if(s===Rx)return s=Sx.inflateEnd(this.strm),this.onEnd(s),this.ended=!0,!0;if(0===i.avail_in)break}}return!0},$x.prototype.onData=function(e){this.chunks.push(e)},$x.prototype.onEnd=function(e){e===Ix&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=Ib(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var Ox={Inflate:$x,inflate:kx,inflateRaw:function(e,t){return(t=t||{}).raw=!0,kx(e,t)},ungzip:kx,constants:Ly};const{Inflate:zx,inflate:Fx,inflateRaw:Bx,ungzip:Ux}=Ox;var Vx=Fx,Hx={