@shopware-ag/dive 1.19.1-beta.1 → 1.19.1-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/dive.cjs CHANGED
@@ -2,7 +2,7 @@
2
2
  * @license
3
3
  * Copyright 2010-2023 Three.js Authors
4
4
  * SPDX-License-Identifier: MIT
5
- */const Df="163",js={ROTATE:0,DOLLY:1,PAN:2},qs={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},rb=0,ym=1,sb=2,j_=1,q_=2,Tr=3,tr=0,Kn=1,si=2,Jr=0,Eo=1,Mm=2,Sm=3,Em=4,ob=5,Ts=100,ab=101,cb=102,lb=103,ub=104,hb=200,fb=201,db=202,pb=203,rf=204,sf=205,mb=206,gb=207,_b=208,vb=209,xb=210,yb=211,Mb=212,Sb=213,Eb=214,Tb=0,bb=1,wb=2,Tl=3,Ab=4,Rb=5,Cb=6,Pb=7,$_=0,Lb=1,Ib=2,Ar=0,Db=1,Ub=2,Nb=3,Ob=4,Fb=5,Bb=6,zb=7,Tm="attached",kb="detached",K_=300,Ao=301,Ro=302,of=303,af=304,Fl=306,es=1e3,$i=1001,Co=1002,Nn=1003,Uf=1004,yo=1005,Xn=1006,Da=1007,Ki=1008,Qr=1009,Hb=1010,Gb=1011,Z_=1012,J_=1013,Po=1014,Zi=1015,bl=1016,Q_=1017,e0=1018,Ga=1020,Vb=35902,Wb=1021,Xb=1022,Ei=1023,Yb=1024,jb=1025,To=1026,Ba=1027,t0=1028,n0=1029,qb=1030,i0=1031,r0=1033,ih=33776,rh=33777,sh=33778,oh=33779,bm=35840,wm=35841,Am=35842,Rm=35843,s0=36196,Cm=37492,Pm=37496,Lm=37808,Im=37809,Dm=37810,Um=37811,Nm=37812,Om=37813,Fm=37814,Bm=37815,zm=37816,km=37817,Hm=37818,Gm=37819,Vm=37820,Wm=37821,ah=36492,Xm=36494,Ym=36495,$b=36283,jm=36284,qm=36285,$m=36286,Lo=2300,As=2301,ch=2302,Km=2400,Zm=2401,Jm=2402,Kb=2500,Zb=0,o0=1,cf=2,Jb=3200,Qb=3201,a0=0,ew=1,Sn="",on="srgb",Tn="srgb-linear",Nf="display-p3",Bl="display-p3-linear",wl="linear",Wt="srgb",Al="rec709",Rl="p3",$s=7680,Qm=519,tw=512,nw=513,iw=514,c0=515,rw=516,sw=517,ow=518,aw=519,lf=35044,eg="300 es",br=2e3,Cl=2001;class Ps{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){if(this._listeners===void 0)return!1;const n=this._listeners;return n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){if(this._listeners===void 0)return;const r=this._listeners[e];if(r!==void 0){const o=r.indexOf(t);o!==-1&&r.splice(o,1)}}dispatchEvent(e){if(this._listeners===void 0)return;const n=this._listeners[e.type];if(n!==void 0){e.target=this;const r=n.slice(0);for(let o=0,a=r.length;o<a;o++)r[o].call(this,e);e.target=null}}}const Cn=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let tg=1234567;const Ua=Math.PI/180,Io=180/Math.PI;function Fi(){const i=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(Cn[i&255]+Cn[i>>8&255]+Cn[i>>16&255]+Cn[i>>24&255]+"-"+Cn[e&255]+Cn[e>>8&255]+"-"+Cn[e>>16&15|64]+Cn[e>>24&255]+"-"+Cn[t&63|128]+Cn[t>>8&255]+"-"+Cn[t>>16&255]+Cn[t>>24&255]+Cn[n&255]+Cn[n>>8&255]+Cn[n>>16&255]+Cn[n>>24&255]).toLowerCase()}function En(i,e,t){return Math.max(e,Math.min(t,i))}function Of(i,e){return(i%e+e)%e}function cw(i,e,t,n,r){return n+(i-e)*(r-n)/(t-e)}function lw(i,e,t){return i!==e?(t-i)/(e-i):0}function Na(i,e,t){return(1-t)*i+t*e}function uw(i,e,t,n){return Na(i,e,1-Math.exp(-t*n))}function hw(i,e=1){return e-Math.abs(Of(i,e*2)-e)}function fw(i,e,t){return i<=e?0:i>=t?1:(i=(i-e)/(t-e),i*i*(3-2*i))}function dw(i,e,t){return i<=e?0:i>=t?1:(i=(i-e)/(t-e),i*i*i*(i*(i*6-15)+10))}function pw(i,e){return i+Math.floor(Math.random()*(e-i+1))}function mw(i,e){return i+Math.random()*(e-i)}function gw(i){return i*(.5-Math.random())}function _w(i){i!==void 0&&(tg=i);let e=tg+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function vw(i){return i*Ua}function xw(i){return i*Io}function yw(i){return(i&i-1)===0&&i!==0}function Mw(i){return Math.pow(2,Math.ceil(Math.log(i)/Math.LN2))}function Sw(i){return Math.pow(2,Math.floor(Math.log(i)/Math.LN2))}function Ew(i,e,t,n,r){const o=Math.cos,a=Math.sin,l=o(t/2),u=a(t/2),h=o((e+n)/2),d=a((e+n)/2),p=o((e-n)/2),m=a((e-n)/2),g=o((n-e)/2),y=a((n-e)/2);switch(r){case"XYX":i.set(l*d,u*p,u*m,l*h);break;case"YZY":i.set(u*m,l*d,u*p,l*h);break;case"ZXZ":i.set(u*p,u*m,l*d,l*h);break;case"XZX":i.set(l*d,u*y,u*g,l*h);break;case"YXY":i.set(u*g,l*d,u*y,l*h);break;case"ZYZ":i.set(u*y,u*g,l*d,l*h);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}function Ni(i,e){switch(e.constructor){case Float32Array:return i;case Uint32Array:return i/4294967295;case Uint16Array:return i/65535;case Uint8Array:return i/255;case Int32Array:return Math.max(i/2147483647,-1);case Int16Array:return Math.max(i/32767,-1);case Int8Array:return Math.max(i/127,-1);default:throw new Error("Invalid component type.")}}function Dt(i,e){switch(e.constructor){case Float32Array:return i;case Uint32Array:return Math.round(i*4294967295);case Uint16Array:return Math.round(i*65535);case Uint8Array:return Math.round(i*255);case Int32Array:return Math.round(i*2147483647);case Int16Array:return Math.round(i*32767);case Int8Array:return Math.round(i*127);default:throw new Error("Invalid component type.")}}const ci={DEG2RAD:Ua,RAD2DEG:Io,generateUUID:Fi,clamp:En,euclideanModulo:Of,mapLinear:cw,inverseLerp:lw,lerp:Na,damp:uw,pingpong:hw,smoothstep:fw,smootherstep:dw,randInt:pw,randFloat:mw,randFloatSpread:gw,seededRandom:_w,degToRad:vw,radToDeg:xw,isPowerOfTwo:yw,ceilPowerOfTwo:Mw,floorPowerOfTwo:Sw,setQuaternionFromProperEuler:Ew,normalize:Dt,denormalize:Ni};class Pe{constructor(e=0,t=0){Pe.prototype.isVector2=!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){return 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){return 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,n=this.y,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6],this.y=r[1]*t+r[4]*n+r[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(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}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(En(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const n=Math.cos(t),r=Math.sin(t),o=this.x-e.x,a=this.y-e.y;return this.x=o*n-a*r+e.x,this.y=o*r+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class ht{constructor(e,t,n,r,o,a,l,u,h){ht.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,r,o,a,l,u,h)}set(e,t,n,r,o,a,l,u,h){const d=this.elements;return d[0]=e,d[1]=r,d[2]=l,d[3]=t,d[4]=o,d[5]=u,d[6]=n,d[7]=a,d[8]=h,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){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 n=e.elements,r=t.elements,o=this.elements,a=n[0],l=n[3],u=n[6],h=n[1],d=n[4],p=n[7],m=n[2],g=n[5],y=n[8],S=r[0],_=r[3],v=r[6],R=r[1],b=r[4],A=r[7],B=r[2],N=r[5],D=r[8];return o[0]=a*S+l*R+u*B,o[3]=a*_+l*b+u*N,o[6]=a*v+l*A+u*D,o[1]=h*S+d*R+p*B,o[4]=h*_+d*b+p*N,o[7]=h*v+d*A+p*D,o[2]=m*S+g*R+y*B,o[5]=m*_+g*b+y*N,o[8]=m*v+g*A+y*D,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],n=e[1],r=e[2],o=e[3],a=e[4],l=e[5],u=e[6],h=e[7],d=e[8];return t*a*d-t*l*h-n*o*d+n*l*u+r*o*h-r*a*u}invert(){const e=this.elements,t=e[0],n=e[1],r=e[2],o=e[3],a=e[4],l=e[5],u=e[6],h=e[7],d=e[8],p=d*a-l*h,m=l*u-d*o,g=h*o-a*u,y=t*p+n*m+r*g;if(y===0)return this.set(0,0,0,0,0,0,0,0,0);const S=1/y;return e[0]=p*S,e[1]=(r*h-d*n)*S,e[2]=(l*n-r*a)*S,e[3]=m*S,e[4]=(d*t-r*u)*S,e[5]=(r*o-l*t)*S,e[6]=g*S,e[7]=(n*u-h*t)*S,e[8]=(a*t-n*o)*S,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,n,r,o,a,l){const u=Math.cos(o),h=Math.sin(o);return this.set(n*u,n*h,-n*(u*a+h*l)+a+e,-r*h,r*u,-r*(-h*a+u*l)+l+t,0,0,1),this}scale(e,t){return this.premultiply(lh.makeScale(e,t)),this}rotate(e){return this.premultiply(lh.makeRotation(-e)),this}translate(e,t){return this.premultiply(lh.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,n=e.elements;for(let r=0;r<9;r++)if(t[r]!==n[r])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}}const lh=new ht;function l0(i){for(let e=i.length-1;e>=0;--e)if(i[e]>=65535)return!0;return!1}function za(i){return document.createElementNS("http://www.w3.org/1999/xhtml",i)}function Tw(){const i=za("canvas");return i.style.display="block",i}const ng={};function u0(i){i in ng||(ng[i]=!0,console.warn(i))}const ig=new ht().set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),rg=new ht().set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),Nc={[Tn]:{transfer:wl,primaries:Al,toReference:i=>i,fromReference:i=>i},[on]:{transfer:Wt,primaries:Al,toReference:i=>i.convertSRGBToLinear(),fromReference:i=>i.convertLinearToSRGB()},[Bl]:{transfer:wl,primaries:Rl,toReference:i=>i.applyMatrix3(rg),fromReference:i=>i.applyMatrix3(ig)},[Nf]:{transfer:Wt,primaries:Rl,toReference:i=>i.convertSRGBToLinear().applyMatrix3(rg),fromReference:i=>i.applyMatrix3(ig).convertLinearToSRGB()}},bw=new Set([Tn,Bl]),Lt={enabled:!0,_workingColorSpace:Tn,get workingColorSpace(){return this._workingColorSpace},set workingColorSpace(i){if(!bw.has(i))throw new Error(`Unsupported working color space, "${i}".`);this._workingColorSpace=i},convert:function(i,e,t){if(this.enabled===!1||e===t||!e||!t)return i;const n=Nc[e].toReference,r=Nc[t].fromReference;return r(n(i))},fromWorkingColorSpace:function(i,e){return this.convert(i,this._workingColorSpace,e)},toWorkingColorSpace:function(i,e){return this.convert(i,e,this._workingColorSpace)},getPrimaries:function(i){return Nc[i].primaries},getTransfer:function(i){return i===Sn?wl:Nc[i].transfer}};function bo(i){return i<.04045?i*.0773993808:Math.pow(i*.9478672986+.0521327014,2.4)}function uh(i){return i<.0031308?i*12.92:1.055*Math.pow(i,.41666)-.055}let Ks;class ww{static getDataURL(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{Ks===void 0&&(Ks=za("canvas")),Ks.width=e.width,Ks.height=e.height;const n=Ks.getContext("2d");e instanceof ImageData?n.putImageData(e,0,0):n.drawImage(e,0,0,e.width,e.height),t=Ks}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")}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const t=za("canvas");t.width=e.width,t.height=e.height;const n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);const r=n.getImageData(0,0,e.width,e.height),o=r.data;for(let a=0;a<o.length;a++)o[a]=bo(o[a]/255)*255;return n.putImageData(r,0,0),t}else if(e.data){const t=e.data.slice(0);for(let n=0;n<t.length;n++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[n]=Math.floor(bo(t[n]/255)*255):t[n]=bo(t[n]);return{data:t,width:e.width,height:e.height}}else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let Aw=0;class Ff{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:Aw++}),this.uuid=Fi(),this.data=e,this.dataReady=!0,this.version=0}set needsUpdate(e){e===!0&&this.version++}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];const n={uuid:this.uuid,url:""},r=this.data;if(r!==null){let o;if(Array.isArray(r)){o=[];for(let a=0,l=r.length;a<l;a++)r[a].isDataTexture?o.push(hh(r[a].image)):o.push(hh(r[a]))}else o=hh(r);n.url=o}return t||(e.images[this.uuid]=n),n}}function hh(i){return typeof HTMLImageElement<"u"&&i instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&i instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&i instanceof ImageBitmap?ww.getDataURL(i):i.data?{data:Array.from(i.data),width:i.width,height:i.height,type:i.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}let Rw=0;class cn extends Ps{constructor(e=cn.DEFAULT_IMAGE,t=cn.DEFAULT_MAPPING,n=$i,r=$i,o=Xn,a=Ki,l=Ei,u=Qr,h=cn.DEFAULT_ANISOTROPY,d=Sn){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Rw++}),this.uuid=Fi(),this.name="",this.source=new Ff(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=n,this.wrapT=r,this.magFilter=o,this.minFilter=a,this.anisotropy=h,this.format=l,this.internalFormat=null,this.type=u,this.offset=new Pe(0,0),this.repeat=new Pe(1,1),this.center=new Pe(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new ht,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=d,this.userData={},this.version=0,this.onUpdate=null,this.isRenderTargetTexture=!1,this.pmremVersion=0}get image(){return this.source.data}set image(e=null){this.source.data=e}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.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,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.colorSpace=e.colorSpace,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const n={metadata:{version:4.6,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,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,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==K_)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case es:e.x=e.x-Math.floor(e.x);break;case $i:e.x=e.x<0?0:1;break;case Co:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case es:e.y=e.y-Math.floor(e.y);break;case $i:e.y=e.y<0?0:1;break;case Co:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}}cn.DEFAULT_IMAGE=null;cn.DEFAULT_MAPPING=K_;cn.DEFAULT_ANISOTROPY=1;class Ut{constructor(e=0,t=0,n=0,r=1){Ut.prototype.isVector4=!0,this.x=e,this.y=t,this.z=n,this.w=r}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,r){return this.x=e,this.y=t,this.z=n,this.w=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw 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=e.w!==void 0?e.w:1,this}add(e){return 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){return 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,n=this.y,r=this.z,o=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*r+a[12]*o,this.y=a[1]*t+a[5]*n+a[9]*r+a[13]*o,this.z=a[2]*t+a[6]*n+a[10]*r+a[14]*o,this.w=a[3]*t+a[7]*n+a[11]*r+a[15]*o,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,n,r,o;const u=e.elements,h=u[0],d=u[4],p=u[8],m=u[1],g=u[5],y=u[9],S=u[2],_=u[6],v=u[10];if(Math.abs(d-m)<.01&&Math.abs(p-S)<.01&&Math.abs(y-_)<.01){if(Math.abs(d+m)<.1&&Math.abs(p+S)<.1&&Math.abs(y+_)<.1&&Math.abs(h+g+v-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const b=(h+1)/2,A=(g+1)/2,B=(v+1)/2,N=(d+m)/4,D=(p+S)/4,C=(y+_)/4;return b>A&&b>B?b<.01?(n=0,r=.707106781,o=.707106781):(n=Math.sqrt(b),r=N/n,o=D/n):A>B?A<.01?(n=.707106781,r=0,o=.707106781):(r=Math.sqrt(A),n=N/r,o=C/r):B<.01?(n=.707106781,r=.707106781,o=0):(o=Math.sqrt(B),n=D/o,r=C/o),this.set(n,r,o,t),this}let R=Math.sqrt((_-y)*(_-y)+(p-S)*(p-S)+(m-d)*(m-d));return Math.abs(R)<.001&&(R=1),this.x=(_-y)/R,this.y=(p-S)/R,this.z=(m-d)/R,this.w=Math.acos((h+g+v-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 n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return 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}}class Cw extends Ps{constructor(e=1,t=1,n={}){super(),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=1,this.scissor=new Ut(0,0,e,t),this.scissorTest=!1,this.viewport=new Ut(0,0,e,t);const r={width:e,height:t,depth:1};n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Xn,depthBuffer:!0,stencilBuffer:!1,depthTexture:null,samples:0,count:1},n);const o=new cn(r,n.mapping,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.colorSpace);o.flipY=!1,o.generateMipmaps=n.generateMipmaps,o.internalFormat=n.internalFormat,this.textures=[];const a=n.count;for(let l=0;l<a;l++)this.textures[l]=o.clone(),this.textures[l].isRenderTargetTexture=!0;this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.depthTexture=n.depthTexture,this.samples=n.samples}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}setSize(e,t,n=1){if(this.width!==e||this.height!==t||this.depth!==n){this.width=e,this.height=t,this.depth=n;for(let r=0,o=this.textures.length;r<o;r++)this.textures[r].image.width=e,this.textures[r].image.height=t,this.textures[r].image.depth=n;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){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let n=0,r=e.textures.length;n<r;n++)this.textures[n]=e.textures[n].clone(),this.textures[n].isRenderTargetTexture=!0;const t=Object.assign({},e.texture.image);return this.texture.source=new Ff(t),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class Rs extends Cw{constructor(e=1,t=1,n={}){super(e,t,n),this.isWebGLRenderTarget=!0}}class h0 extends cn{constructor(e=null,t=1,n=1,r=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:r},this.magFilter=Nn,this.minFilter=Nn,this.wrapR=$i,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Pw extends cn{constructor(e=null,t=1,n=1,r=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:r},this.magFilter=Nn,this.minFilter=Nn,this.wrapR=$i,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class an{constructor(e=0,t=0,n=0,r=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=r}static slerpFlat(e,t,n,r,o,a,l){let u=n[r+0],h=n[r+1],d=n[r+2],p=n[r+3];const m=o[a+0],g=o[a+1],y=o[a+2],S=o[a+3];if(l===0){e[t+0]=u,e[t+1]=h,e[t+2]=d,e[t+3]=p;return}if(l===1){e[t+0]=m,e[t+1]=g,e[t+2]=y,e[t+3]=S;return}if(p!==S||u!==m||h!==g||d!==y){let _=1-l;const v=u*m+h*g+d*y+p*S,R=v>=0?1:-1,b=1-v*v;if(b>Number.EPSILON){const B=Math.sqrt(b),N=Math.atan2(B,v*R);_=Math.sin(_*N)/B,l=Math.sin(l*N)/B}const A=l*R;if(u=u*_+m*A,h=h*_+g*A,d=d*_+y*A,p=p*_+S*A,_===1-l){const B=1/Math.sqrt(u*u+h*h+d*d+p*p);u*=B,h*=B,d*=B,p*=B}}e[t]=u,e[t+1]=h,e[t+2]=d,e[t+3]=p}static multiplyQuaternionsFlat(e,t,n,r,o,a){const l=n[r],u=n[r+1],h=n[r+2],d=n[r+3],p=o[a],m=o[a+1],g=o[a+2],y=o[a+3];return e[t]=l*y+d*p+u*g-h*m,e[t+1]=u*y+d*m+h*p-l*g,e[t+2]=h*y+d*g+l*m-u*p,e[t+3]=d*y-l*p-u*m-h*g,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,r){return this._x=e,this._y=t,this._z=n,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){const n=e._x,r=e._y,o=e._z,a=e._order,l=Math.cos,u=Math.sin,h=l(n/2),d=l(r/2),p=l(o/2),m=u(n/2),g=u(r/2),y=u(o/2);switch(a){case"XYZ":this._x=m*d*p+h*g*y,this._y=h*g*p-m*d*y,this._z=h*d*y+m*g*p,this._w=h*d*p-m*g*y;break;case"YXZ":this._x=m*d*p+h*g*y,this._y=h*g*p-m*d*y,this._z=h*d*y-m*g*p,this._w=h*d*p+m*g*y;break;case"ZXY":this._x=m*d*p-h*g*y,this._y=h*g*p+m*d*y,this._z=h*d*y+m*g*p,this._w=h*d*p-m*g*y;break;case"ZYX":this._x=m*d*p-h*g*y,this._y=h*g*p+m*d*y,this._z=h*d*y-m*g*p,this._w=h*d*p+m*g*y;break;case"YZX":this._x=m*d*p+h*g*y,this._y=h*g*p+m*d*y,this._z=h*d*y-m*g*p,this._w=h*d*p-m*g*y;break;case"XZY":this._x=m*d*p-h*g*y,this._y=h*g*p-m*d*y,this._z=h*d*y+m*g*p,this._w=h*d*p+m*g*y;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const n=t/2,r=Math.sin(n);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,n=t[0],r=t[4],o=t[8],a=t[1],l=t[5],u=t[9],h=t[2],d=t[6],p=t[10],m=n+l+p;if(m>0){const g=.5/Math.sqrt(m+1);this._w=.25/g,this._x=(d-u)*g,this._y=(o-h)*g,this._z=(a-r)*g}else if(n>l&&n>p){const g=2*Math.sqrt(1+n-l-p);this._w=(d-u)/g,this._x=.25*g,this._y=(r+a)/g,this._z=(o+h)/g}else if(l>p){const g=2*Math.sqrt(1+l-n-p);this._w=(o-h)/g,this._x=(r+a)/g,this._y=.25*g,this._z=(u+d)/g}else{const g=2*Math.sqrt(1+p-n-l);this._w=(a-r)/g,this._x=(o+h)/g,this._y=(u+d)/g,this._z=.25*g}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<Number.EPSILON?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(En(this.dot(e),-1,1)))}rotateTowards(e,t){const n=this.angleTo(e);if(n===0)return this;const r=Math.min(1,t/n);return this.slerp(e,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const n=e._x,r=e._y,o=e._z,a=e._w,l=t._x,u=t._y,h=t._z,d=t._w;return this._x=n*d+a*l+r*h-o*u,this._y=r*d+a*u+o*l-n*h,this._z=o*d+a*h+n*u-r*l,this._w=a*d-n*l-r*u-o*h,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);const n=this._x,r=this._y,o=this._z,a=this._w;let l=a*e._w+n*e._x+r*e._y+o*e._z;if(l<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,l=-l):this.copy(e),l>=1)return this._w=a,this._x=n,this._y=r,this._z=o,this;const u=1-l*l;if(u<=Number.EPSILON){const g=1-t;return this._w=g*a+t*this._w,this._x=g*n+t*this._x,this._y=g*r+t*this._y,this._z=g*o+t*this._z,this.normalize(),this}const h=Math.sqrt(u),d=Math.atan2(h,l),p=Math.sin((1-t)*d)/h,m=Math.sin(t*d)/h;return this._w=a*p+this._w*m,this._x=n*p+this._x*m,this._y=r*p+this._y*m,this._z=o*p+this._z*m,this._onChangeCallback(),this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),r=Math.sqrt(1-n),o=Math.sqrt(n);return this.set(r*Math.sin(e),r*Math.cos(e),o*Math.sin(t),o*Math.cos(t))}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._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class F{constructor(e=0,t=0,n=0){F.prototype.isVector3=!0,this.x=e,this.y=t,this.z=n}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw 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){return 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){return 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){return 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 this.applyQuaternion(sg.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(sg.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,n=this.y,r=this.z,o=e.elements;return this.x=o[0]*t+o[3]*n+o[6]*r,this.y=o[1]*t+o[4]*n+o[7]*r,this.z=o[2]*t+o[5]*n+o[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,n=this.y,r=this.z,o=e.elements,a=1/(o[3]*t+o[7]*n+o[11]*r+o[15]);return this.x=(o[0]*t+o[4]*n+o[8]*r+o[12])*a,this.y=(o[1]*t+o[5]*n+o[9]*r+o[13])*a,this.z=(o[2]*t+o[6]*n+o[10]*r+o[14])*a,this}applyQuaternion(e){const t=this.x,n=this.y,r=this.z,o=e.x,a=e.y,l=e.z,u=e.w,h=2*(a*r-l*n),d=2*(l*t-o*r),p=2*(o*n-a*t);return this.x=t+u*h+a*p-l*d,this.y=n+u*d+l*h-o*p,this.z=r+u*p+o*d-a*h,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,n=this.y,r=this.z,o=e.elements;return this.x=o[0]*t+o[4]*n+o[8]*r,this.y=o[1]*t+o[5]*n+o[9]*r,this.z=o[2]*t+o[6]*n+o[10]*r,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const n=e.x,r=e.y,o=e.z,a=t.x,l=t.y,u=t.z;return this.x=r*u-o*l,this.y=o*a-n*u,this.z=n*l-r*a,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return fh.copy(this).projectOnVector(e),this.sub(fh)}reflect(e){return this.sub(fh.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(En(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y,r=this.z-e.z;return t*t+n*n+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){const r=Math.sin(t)*e;return this.x=r*Math.sin(n),this.y=Math.cos(t)*e,this.z=r*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){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(),n=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=r,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}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){return 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=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const fh=new F,sg=new an;class zi{constructor(e=new F(1/0,1/0,1/0),t=new F(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t+=3)this.expandByPoint(Pi.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(Pi.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const n=Pi.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}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,t=!1){e.updateWorldMatrix(!1,!1);const n=e.geometry;if(n!==void 0){const o=n.getAttribute("position");if(t===!0&&o!==void 0&&e.isInstancedMesh!==!0)for(let a=0,l=o.count;a<l;a++)e.isMesh===!0?e.getVertexPosition(a,Pi):Pi.fromBufferAttribute(o,a),Pi.applyMatrix4(e.matrixWorld),this.expandByPoint(Pi);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),Oc.copy(e.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),Oc.copy(n.boundingBox)),Oc.applyMatrix4(e.matrixWorld),this.union(Oc)}const r=e.children;for(let o=0,a=r.length;o<a;o++)this.expandByObject(r[o],t);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,Pi),Pi.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(ca),Fc.subVectors(this.max,ca),Zs.subVectors(e.a,ca),Js.subVectors(e.b,ca),Qs.subVectors(e.c,ca),kr.subVectors(Js,Zs),Hr.subVectors(Qs,Js),ds.subVectors(Zs,Qs);let t=[0,-kr.z,kr.y,0,-Hr.z,Hr.y,0,-ds.z,ds.y,kr.z,0,-kr.x,Hr.z,0,-Hr.x,ds.z,0,-ds.x,-kr.y,kr.x,0,-Hr.y,Hr.x,0,-ds.y,ds.x,0];return!dh(t,Zs,Js,Qs,Fc)||(t=[1,0,0,0,1,0,0,0,1],!dh(t,Zs,Js,Qs,Fc))?!1:(Bc.crossVectors(kr,Hr),t=[Bc.x,Bc.y,Bc.z],dh(t,Zs,Js,Qs,Fc))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Pi).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Pi).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(_r[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),_r[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),_r[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),_r[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),_r[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),_r[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),_r[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),_r[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(_r),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)}}const _r=[new F,new F,new F,new F,new F,new F,new F,new F],Pi=new F,Oc=new zi,Zs=new F,Js=new F,Qs=new F,kr=new F,Hr=new F,ds=new F,ca=new F,Fc=new F,Bc=new F,ps=new F;function dh(i,e,t,n,r){for(let o=0,a=i.length-3;o<=a;o+=3){ps.fromArray(i,o);const l=r.x*Math.abs(ps.x)+r.y*Math.abs(ps.y)+r.z*Math.abs(ps.z),u=e.dot(ps),h=t.dot(ps),d=n.dot(ps);if(Math.max(-Math.max(u,h,d),Math.min(u,h,d))>l)return!1}return!0}const Lw=new zi,la=new F,ph=new F;class rr{constructor(e=new F,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const n=this.center;t!==void 0?n.copy(t):Lw.setFromPoints(e).getCenter(n);let r=0;for(let o=0,a=e.length;o<a;o++)r=Math.max(r,n.distanceToSquared(e[o]));return this.radius=Math.sqrt(r),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 n=this.center.distanceToSquared(e);return t.copy(e),n>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){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;la.subVectors(e,this.center);const t=la.lengthSq();if(t>this.radius*this.radius){const n=Math.sqrt(t),r=(n-this.radius)*.5;this.center.addScaledVector(la,r/n),this.radius+=r}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(ph.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(la.copy(e.center).add(ph)),this.expandByPoint(la.copy(e.center).sub(ph))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}}const vr=new F,mh=new F,zc=new F,Gr=new F,gh=new F,kc=new F,_h=new F;class Oo{constructor(e=new F,t=new F(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.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,vr)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=vr.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(vr.copy(this.origin).addScaledVector(this.direction,t),vr.distanceToSquared(e))}distanceSqToSegment(e,t,n,r){mh.copy(e).add(t).multiplyScalar(.5),zc.copy(t).sub(e).normalize(),Gr.copy(this.origin).sub(mh);const o=e.distanceTo(t)*.5,a=-this.direction.dot(zc),l=Gr.dot(this.direction),u=-Gr.dot(zc),h=Gr.lengthSq(),d=Math.abs(1-a*a);let p,m,g,y;if(d>0)if(p=a*u-l,m=a*l-u,y=o*d,p>=0)if(m>=-y)if(m<=y){const S=1/d;p*=S,m*=S,g=p*(p+a*m+2*l)+m*(a*p+m+2*u)+h}else m=o,p=Math.max(0,-(a*m+l)),g=-p*p+m*(m+2*u)+h;else m=-o,p=Math.max(0,-(a*m+l)),g=-p*p+m*(m+2*u)+h;else m<=-y?(p=Math.max(0,-(-a*o+l)),m=p>0?-o:Math.min(Math.max(-o,-u),o),g=-p*p+m*(m+2*u)+h):m<=y?(p=0,m=Math.min(Math.max(-o,-u),o),g=m*(m+2*u)+h):(p=Math.max(0,-(a*o+l)),m=p>0?o:Math.min(Math.max(-o,-u),o),g=-p*p+m*(m+2*u)+h);else m=a>0?-o:o,p=Math.max(0,-(a*m+l)),g=-p*p+m*(m+2*u)+h;return n&&n.copy(this.origin).addScaledVector(this.direction,p),r&&r.copy(mh).addScaledVector(zc,m),g}intersectSphere(e,t){vr.subVectors(e.center,this.origin);const n=vr.dot(this.direction),r=vr.dot(vr)-n*n,o=e.radius*e.radius;if(r>o)return null;const a=Math.sqrt(o-r),l=n-a,u=n+a;return u<0?null:l<0?this.at(u,t):this.at(l,t)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;const n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){const n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,r,o,a,l,u;const h=1/this.direction.x,d=1/this.direction.y,p=1/this.direction.z,m=this.origin;return h>=0?(n=(e.min.x-m.x)*h,r=(e.max.x-m.x)*h):(n=(e.max.x-m.x)*h,r=(e.min.x-m.x)*h),d>=0?(o=(e.min.y-m.y)*d,a=(e.max.y-m.y)*d):(o=(e.max.y-m.y)*d,a=(e.min.y-m.y)*d),n>a||o>r||((o>n||isNaN(n))&&(n=o),(a<r||isNaN(r))&&(r=a),p>=0?(l=(e.min.z-m.z)*p,u=(e.max.z-m.z)*p):(l=(e.max.z-m.z)*p,u=(e.min.z-m.z)*p),n>u||l>r)||((l>n||n!==n)&&(n=l),(u<r||r!==r)&&(r=u),r<0)?null:this.at(n>=0?n:r,t)}intersectsBox(e){return this.intersectBox(e,vr)!==null}intersectTriangle(e,t,n,r,o){gh.subVectors(t,e),kc.subVectors(n,e),_h.crossVectors(gh,kc);let a=this.direction.dot(_h),l;if(a>0){if(r)return null;l=1}else if(a<0)l=-1,a=-a;else return null;Gr.subVectors(this.origin,e);const u=l*this.direction.dot(kc.crossVectors(Gr,kc));if(u<0)return null;const h=l*this.direction.dot(gh.cross(Gr));if(h<0||u+h>a)return null;const d=-l*Gr.dot(_h);return d<0?null:this.at(d/a,o)}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 Qe{constructor(e,t,n,r,o,a,l,u,h,d,p,m,g,y,S,_){Qe.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,n,r,o,a,l,u,h,d,p,m,g,y,S,_)}set(e,t,n,r,o,a,l,u,h,d,p,m,g,y,S,_){const v=this.elements;return v[0]=e,v[4]=t,v[8]=n,v[12]=r,v[1]=o,v[5]=a,v[9]=l,v[13]=u,v[2]=h,v[6]=d,v[10]=p,v[14]=m,v[3]=g,v[7]=y,v[11]=S,v[15]=_,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 Qe().fromArray(this.elements)}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){const t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[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,n){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){const t=this.elements,n=e.elements,r=1/eo.setFromMatrixColumn(e,0).length(),o=1/eo.setFromMatrixColumn(e,1).length(),a=1/eo.setFromMatrixColumn(e,2).length();return t[0]=n[0]*r,t[1]=n[1]*r,t[2]=n[2]*r,t[3]=0,t[4]=n[4]*o,t[5]=n[5]*o,t[6]=n[6]*o,t[7]=0,t[8]=n[8]*a,t[9]=n[9]*a,t[10]=n[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,n=e.x,r=e.y,o=e.z,a=Math.cos(n),l=Math.sin(n),u=Math.cos(r),h=Math.sin(r),d=Math.cos(o),p=Math.sin(o);if(e.order==="XYZ"){const m=a*d,g=a*p,y=l*d,S=l*p;t[0]=u*d,t[4]=-u*p,t[8]=h,t[1]=g+y*h,t[5]=m-S*h,t[9]=-l*u,t[2]=S-m*h,t[6]=y+g*h,t[10]=a*u}else if(e.order==="YXZ"){const m=u*d,g=u*p,y=h*d,S=h*p;t[0]=m+S*l,t[4]=y*l-g,t[8]=a*h,t[1]=a*p,t[5]=a*d,t[9]=-l,t[2]=g*l-y,t[6]=S+m*l,t[10]=a*u}else if(e.order==="ZXY"){const m=u*d,g=u*p,y=h*d,S=h*p;t[0]=m-S*l,t[4]=-a*p,t[8]=y+g*l,t[1]=g+y*l,t[5]=a*d,t[9]=S-m*l,t[2]=-a*h,t[6]=l,t[10]=a*u}else if(e.order==="ZYX"){const m=a*d,g=a*p,y=l*d,S=l*p;t[0]=u*d,t[4]=y*h-g,t[8]=m*h+S,t[1]=u*p,t[5]=S*h+m,t[9]=g*h-y,t[2]=-h,t[6]=l*u,t[10]=a*u}else if(e.order==="YZX"){const m=a*u,g=a*h,y=l*u,S=l*h;t[0]=u*d,t[4]=S-m*p,t[8]=y*p+g,t[1]=p,t[5]=a*d,t[9]=-l*d,t[2]=-h*d,t[6]=g*p+y,t[10]=m-S*p}else if(e.order==="XZY"){const m=a*u,g=a*h,y=l*u,S=l*h;t[0]=u*d,t[4]=-p,t[8]=h*d,t[1]=m*p+S,t[5]=a*d,t[9]=g*p-y,t[2]=y*p-g,t[6]=l*d,t[10]=S*p+m}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(Iw,e,Dw)}lookAt(e,t,n){const r=this.elements;return ii.subVectors(e,t),ii.lengthSq()===0&&(ii.z=1),ii.normalize(),Vr.crossVectors(n,ii),Vr.lengthSq()===0&&(Math.abs(n.z)===1?ii.x+=1e-4:ii.z+=1e-4,ii.normalize(),Vr.crossVectors(n,ii)),Vr.normalize(),Hc.crossVectors(ii,Vr),r[0]=Vr.x,r[4]=Hc.x,r[8]=ii.x,r[1]=Vr.y,r[5]=Hc.y,r[9]=ii.y,r[2]=Vr.z,r[6]=Hc.z,r[10]=ii.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,r=t.elements,o=this.elements,a=n[0],l=n[4],u=n[8],h=n[12],d=n[1],p=n[5],m=n[9],g=n[13],y=n[2],S=n[6],_=n[10],v=n[14],R=n[3],b=n[7],A=n[11],B=n[15],N=r[0],D=r[4],C=r[8],E=r[12],M=r[1],O=r[5],H=r[9],G=r[13],Y=r[2],$=r[6],re=r[10],se=r[14],K=r[3],ae=r[7],pe=r[11],ve=r[15];return o[0]=a*N+l*M+u*Y+h*K,o[4]=a*D+l*O+u*$+h*ae,o[8]=a*C+l*H+u*re+h*pe,o[12]=a*E+l*G+u*se+h*ve,o[1]=d*N+p*M+m*Y+g*K,o[5]=d*D+p*O+m*$+g*ae,o[9]=d*C+p*H+m*re+g*pe,o[13]=d*E+p*G+m*se+g*ve,o[2]=y*N+S*M+_*Y+v*K,o[6]=y*D+S*O+_*$+v*ae,o[10]=y*C+S*H+_*re+v*pe,o[14]=y*E+S*G+_*se+v*ve,o[3]=R*N+b*M+A*Y+B*K,o[7]=R*D+b*O+A*$+B*ae,o[11]=R*C+b*H+A*re+B*pe,o[15]=R*E+b*G+A*se+B*ve,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],n=e[4],r=e[8],o=e[12],a=e[1],l=e[5],u=e[9],h=e[13],d=e[2],p=e[6],m=e[10],g=e[14],y=e[3],S=e[7],_=e[11],v=e[15];return y*(+o*u*p-r*h*p-o*l*m+n*h*m+r*l*g-n*u*g)+S*(+t*u*g-t*h*m+o*a*m-r*a*g+r*h*d-o*u*d)+_*(+t*h*p-t*l*g-o*a*p+n*a*g+o*l*d-n*h*d)+v*(-r*l*d-t*u*p+t*l*m+r*a*p-n*a*m+n*u*d)}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,n){const r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=t,r[14]=n),this}invert(){const e=this.elements,t=e[0],n=e[1],r=e[2],o=e[3],a=e[4],l=e[5],u=e[6],h=e[7],d=e[8],p=e[9],m=e[10],g=e[11],y=e[12],S=e[13],_=e[14],v=e[15],R=p*_*h-S*m*h+S*u*g-l*_*g-p*u*v+l*m*v,b=y*m*h-d*_*h-y*u*g+a*_*g+d*u*v-a*m*v,A=d*S*h-y*p*h+y*l*g-a*S*g-d*l*v+a*p*v,B=y*p*u-d*S*u-y*l*m+a*S*m+d*l*_-a*p*_,N=t*R+n*b+r*A+o*B;if(N===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const D=1/N;return e[0]=R*D,e[1]=(S*m*o-p*_*o-S*r*g+n*_*g+p*r*v-n*m*v)*D,e[2]=(l*_*o-S*u*o+S*r*h-n*_*h-l*r*v+n*u*v)*D,e[3]=(p*u*o-l*m*o-p*r*h+n*m*h+l*r*g-n*u*g)*D,e[4]=b*D,e[5]=(d*_*o-y*m*o+y*r*g-t*_*g-d*r*v+t*m*v)*D,e[6]=(y*u*o-a*_*o-y*r*h+t*_*h+a*r*v-t*u*v)*D,e[7]=(a*m*o-d*u*o+d*r*h-t*m*h-a*r*g+t*u*g)*D,e[8]=A*D,e[9]=(y*p*o-d*S*o-y*n*g+t*S*g+d*n*v-t*p*v)*D,e[10]=(a*S*o-y*l*o+y*n*h-t*S*h-a*n*v+t*l*v)*D,e[11]=(d*l*o-a*p*o-d*n*h+t*p*h+a*n*g-t*l*g)*D,e[12]=B*D,e[13]=(d*S*r-y*p*r+y*n*m-t*S*m-d*n*_+t*p*_)*D,e[14]=(y*l*r-a*S*r-y*n*u+t*S*u+a*n*_-t*l*_)*D,e[15]=(a*p*r-d*l*r+d*n*u-t*p*u-a*n*m+t*l*m)*D,this}scale(e){const t=this.elements,n=e.x,r=e.y,o=e.z;return t[0]*=n,t[4]*=r,t[8]*=o,t[1]*=n,t[5]*=r,t[9]*=o,t[2]*=n,t[6]*=r,t[10]*=o,t[3]*=n,t[7]*=r,t[11]*=o,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,r))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const n=Math.cos(t),r=Math.sin(t),o=1-n,a=e.x,l=e.y,u=e.z,h=o*a,d=o*l;return this.set(h*a+n,h*l-r*u,h*u+r*l,0,h*l+r*u,d*l+n,d*u-r*a,0,h*u-r*l,d*u+r*a,o*u*u+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,r,o,a){return this.set(1,n,o,0,e,1,a,0,t,r,1,0,0,0,0,1),this}compose(e,t,n){const r=this.elements,o=t._x,a=t._y,l=t._z,u=t._w,h=o+o,d=a+a,p=l+l,m=o*h,g=o*d,y=o*p,S=a*d,_=a*p,v=l*p,R=u*h,b=u*d,A=u*p,B=n.x,N=n.y,D=n.z;return r[0]=(1-(S+v))*B,r[1]=(g+A)*B,r[2]=(y-b)*B,r[3]=0,r[4]=(g-A)*N,r[5]=(1-(m+v))*N,r[6]=(_+R)*N,r[7]=0,r[8]=(y+b)*D,r[9]=(_-R)*D,r[10]=(1-(m+S))*D,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,n){const r=this.elements;let o=eo.set(r[0],r[1],r[2]).length();const a=eo.set(r[4],r[5],r[6]).length(),l=eo.set(r[8],r[9],r[10]).length();this.determinant()<0&&(o=-o),e.x=r[12],e.y=r[13],e.z=r[14],Li.copy(this);const h=1/o,d=1/a,p=1/l;return Li.elements[0]*=h,Li.elements[1]*=h,Li.elements[2]*=h,Li.elements[4]*=d,Li.elements[5]*=d,Li.elements[6]*=d,Li.elements[8]*=p,Li.elements[9]*=p,Li.elements[10]*=p,t.setFromRotationMatrix(Li),n.x=o,n.y=a,n.z=l,this}makePerspective(e,t,n,r,o,a,l=br){const u=this.elements,h=2*o/(t-e),d=2*o/(n-r),p=(t+e)/(t-e),m=(n+r)/(n-r);let g,y;if(l===br)g=-(a+o)/(a-o),y=-2*a*o/(a-o);else if(l===Cl)g=-a/(a-o),y=-a*o/(a-o);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+l);return u[0]=h,u[4]=0,u[8]=p,u[12]=0,u[1]=0,u[5]=d,u[9]=m,u[13]=0,u[2]=0,u[6]=0,u[10]=g,u[14]=y,u[3]=0,u[7]=0,u[11]=-1,u[15]=0,this}makeOrthographic(e,t,n,r,o,a,l=br){const u=this.elements,h=1/(t-e),d=1/(n-r),p=1/(a-o),m=(t+e)*h,g=(n+r)*d;let y,S;if(l===br)y=(a+o)*p,S=-2*p;else if(l===Cl)y=o*p,S=-1*p;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+l);return u[0]=2*h,u[4]=0,u[8]=0,u[12]=-m,u[1]=0,u[5]=2*d,u[9]=0,u[13]=-g,u[2]=0,u[6]=0,u[10]=S,u[14]=-y,u[3]=0,u[7]=0,u[11]=0,u[15]=1,this}equals(e){const t=this.elements,n=e.elements;for(let r=0;r<16;r++)if(t[r]!==n[r])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}}const eo=new F,Li=new Qe,Iw=new F(0,0,0),Dw=new F(1,1,1),Vr=new F,Hc=new F,ii=new F,og=new Qe,ag=new an;class Bi{constructor(e=0,t=0,n=0,r=Bi.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=r}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,r=this._order){return this._x=e,this._y=t,this._z=n,this._order=r,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,n=!0){const r=e.elements,o=r[0],a=r[4],l=r[8],u=r[1],h=r[5],d=r[9],p=r[2],m=r[6],g=r[10];switch(t){case"XYZ":this._y=Math.asin(En(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-d,g),this._z=Math.atan2(-a,o)):(this._x=Math.atan2(m,h),this._z=0);break;case"YXZ":this._x=Math.asin(-En(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(l,g),this._z=Math.atan2(u,h)):(this._y=Math.atan2(-p,o),this._z=0);break;case"ZXY":this._x=Math.asin(En(m,-1,1)),Math.abs(m)<.9999999?(this._y=Math.atan2(-p,g),this._z=Math.atan2(-a,h)):(this._y=0,this._z=Math.atan2(u,o));break;case"ZYX":this._y=Math.asin(-En(p,-1,1)),Math.abs(p)<.9999999?(this._x=Math.atan2(m,g),this._z=Math.atan2(u,o)):(this._x=0,this._z=Math.atan2(-a,h));break;case"YZX":this._z=Math.asin(En(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(-d,h),this._y=Math.atan2(-p,o)):(this._x=0,this._y=Math.atan2(l,g));break;case"XZY":this._z=Math.asin(-En(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(m,h),this._y=Math.atan2(l,o)):(this._x=Math.atan2(-d,g),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return og.makeRotationFromQuaternion(e),this.setFromRotationMatrix(og,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return ag.setFromEuler(this),this.setFromQuaternion(ag,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}Bi.DEFAULT_ORDER="XYZ";class Bf{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}}let Uw=0;const cg=new F,to=new an,xr=new Qe,Gc=new F,ua=new F,Nw=new F,Ow=new an,lg=new F(1,0,0),ug=new F(0,1,0),hg=new F(0,0,1),fg={type:"added"},Fw={type:"removed"},no={type:"childadded",child:null},vh={type:"childremoved",child:null};class gt extends Ps{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Uw++}),this.uuid=Fi(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=gt.DEFAULT_UP.clone();const e=new F,t=new Bi,n=new an,r=new F(1,1,1);function o(){n.setFromEuler(t,!1)}function a(){t.setFromQuaternion(n,void 0,!1)}t._onChange(o),n._onChange(a),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:r},modelViewMatrix:{value:new Qe},normalMatrix:{value:new ht}}),this.matrix=new Qe,this.matrixWorld=new Qe,this.matrixAutoUpdate=gt.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=gt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new Bf,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={}}onBeforeShadow(){}onAfterShadow(){}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 to.setFromAxisAngle(e,t),this.quaternion.multiply(to),this}rotateOnWorldAxis(e,t){return to.setFromAxisAngle(e,t),this.quaternion.premultiply(to),this}rotateX(e){return this.rotateOnAxis(lg,e)}rotateY(e){return this.rotateOnAxis(ug,e)}rotateZ(e){return this.rotateOnAxis(hg,e)}translateOnAxis(e,t){return cg.copy(e).applyQuaternion(this.quaternion),this.position.add(cg.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(lg,e)}translateY(e){return this.translateOnAxis(ug,e)}translateZ(e){return this.translateOnAxis(hg,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(xr.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?Gc.copy(e):Gc.set(e,t,n);const r=this.parent;this.updateWorldMatrix(!0,!1),ua.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?xr.lookAt(ua,Gc,this.up):xr.lookAt(Gc,ua,this.up),this.quaternion.setFromRotationMatrix(xr),r&&(xr.extractRotation(r.matrixWorld),to.setFromRotationMatrix(xr),this.quaternion.premultiply(to.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(fg),no.child=e,this.dispatchEvent(no),no.child=null):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}const t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(Fw),vh.child=e,this.dispatchEvent(vh),vh.child=null),this}removeFromParent(){const e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),xr.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),xr.multiply(e.parent.matrixWorld)),e.applyMatrix4(xr),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(fg),no.child=e,this.dispatchEvent(no),no.child=null,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 n=0,r=this.children.length;n<r;n++){const a=this.children[n].getObjectByProperty(e,t);if(a!==void 0)return a}}getObjectsByProperty(e,t,n=[]){this[e]===t&&n.push(this);const r=this.children;for(let o=0,a=r.length;o<a;o++)r[o].getObjectsByProperty(e,t,n);return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(ua,e,Nw),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(ua,Ow,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 n=0,r=t.length;n<r;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].traverseVisible(e)}traverseAncestors(e){const t=this.parent;t!==null&&(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)&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1,e=!0);const t=this.children;for(let n=0,r=t.length;n<r;n++){const o=t[n];(o.matrixWorldAutoUpdate===!0||e===!0)&&o.updateMatrixWorld(e)}}updateWorldMatrix(e,t){const n=this.parent;if(e===!0&&n!==null&&n.matrixWorldAutoUpdate===!0&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),t===!0){const r=this.children;for(let o=0,a=r.length;o<a;o++){const l=r[o];l.matrixWorldAutoUpdate===!0&&l.updateWorldMatrix(!1,!0)}}}toJSON(e){const t=e===void 0||typeof e=="string",n={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.6,type:"Object",generator:"Object3D.toJSON"});const r={};r.uuid=this.uuid,r.type=this.type,this.name!==""&&(r.name=this.name),this.castShadow===!0&&(r.castShadow=!0),this.receiveShadow===!0&&(r.receiveShadow=!0),this.visible===!1&&(r.visible=!1),this.frustumCulled===!1&&(r.frustumCulled=!1),this.renderOrder!==0&&(r.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),r.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(r.matrixAutoUpdate=!1),this.isInstancedMesh&&(r.type="InstancedMesh",r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(r.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(r.type="BatchedMesh",r.perObjectFrustumCulled=this.perObjectFrustumCulled,r.sortObjects=this.sortObjects,r.drawRanges=this._drawRanges,r.reservedRanges=this._reservedRanges,r.visibility=this._visibility,r.active=this._active,r.bounds=this._bounds.map(l=>({boxInitialized:l.boxInitialized,boxMin:l.box.min.toArray(),boxMax:l.box.max.toArray(),sphereInitialized:l.sphereInitialized,sphereRadius:l.sphere.radius,sphereCenter:l.sphere.center.toArray()})),r.maxGeometryCount=this._maxGeometryCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.geometryCount=this._geometryCount,r.matricesTexture=this._matricesTexture.toJSON(e),this.boundingSphere!==null&&(r.boundingSphere={center:r.boundingSphere.center.toArray(),radius:r.boundingSphere.radius}),this.boundingBox!==null&&(r.boundingBox={min:r.boundingBox.min.toArray(),max:r.boundingBox.max.toArray()}));function o(l,u){return l[u.uuid]===void 0&&(l[u.uuid]=u.toJSON(e)),u.uuid}if(this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=o(e.geometries,this.geometry);const l=this.geometry.parameters;if(l!==void 0&&l.shapes!==void 0){const u=l.shapes;if(Array.isArray(u))for(let h=0,d=u.length;h<d;h++){const p=u[h];o(e.shapes,p)}else o(e.shapes,u)}}if(this.isSkinnedMesh&&(r.bindMode=this.bindMode,r.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(o(e.skeletons,this.skeleton),r.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const l=[];for(let u=0,h=this.material.length;u<h;u++)l.push(o(e.materials,this.material[u]));r.material=l}else r.material=o(e.materials,this.material);if(this.children.length>0){r.children=[];for(let l=0;l<this.children.length;l++)r.children.push(this.children[l].toJSON(e).object)}if(this.animations.length>0){r.animations=[];for(let l=0;l<this.animations.length;l++){const u=this.animations[l];r.animations.push(o(e.animations,u))}}if(t){const l=a(e.geometries),u=a(e.materials),h=a(e.textures),d=a(e.images),p=a(e.shapes),m=a(e.skeletons),g=a(e.animations),y=a(e.nodes);l.length>0&&(n.geometries=l),u.length>0&&(n.materials=u),h.length>0&&(n.textures=h),d.length>0&&(n.images=d),p.length>0&&(n.shapes=p),m.length>0&&(n.skeletons=m),g.length>0&&(n.animations=g),y.length>0&&(n.nodes=y)}return n.object=r,n;function a(l){const u=[];for(const h in l){const d=l[h];delete d.metadata,u.push(d)}return u}}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.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,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.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;n<e.children.length;n++){const r=e.children[n];this.add(r.clone())}return this}}gt.DEFAULT_UP=new F(0,1,0);gt.DEFAULT_MATRIX_AUTO_UPDATE=!0;gt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const Ii=new F,yr=new F,xh=new F,Mr=new F,io=new F,ro=new F,dg=new F,yh=new F,Mh=new F,Sh=new F;class Oi{constructor(e=new F,t=new F,n=new F){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,r){r.subVectors(n,t),Ii.subVectors(e,t),r.cross(Ii);const o=r.lengthSq();return o>0?r.multiplyScalar(1/Math.sqrt(o)):r.set(0,0,0)}static getBarycoord(e,t,n,r,o){Ii.subVectors(r,t),yr.subVectors(n,t),xh.subVectors(e,t);const a=Ii.dot(Ii),l=Ii.dot(yr),u=Ii.dot(xh),h=yr.dot(yr),d=yr.dot(xh),p=a*h-l*l;if(p===0)return o.set(0,0,0),null;const m=1/p,g=(h*u-l*d)*m,y=(a*d-l*u)*m;return o.set(1-g-y,y,g)}static containsPoint(e,t,n,r){return this.getBarycoord(e,t,n,r,Mr)===null?!1:Mr.x>=0&&Mr.y>=0&&Mr.x+Mr.y<=1}static getInterpolation(e,t,n,r,o,a,l,u){return this.getBarycoord(e,t,n,r,Mr)===null?(u.x=0,u.y=0,"z"in u&&(u.z=0),"w"in u&&(u.w=0),null):(u.setScalar(0),u.addScaledVector(o,Mr.x),u.addScaledVector(a,Mr.y),u.addScaledVector(l,Mr.z),u)}static isFrontFacing(e,t,n,r){return Ii.subVectors(n,t),yr.subVectors(e,t),Ii.cross(yr).dot(r)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,r){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,t,n,r){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,r),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return Ii.subVectors(this.c,this.b),yr.subVectors(this.a,this.b),Ii.cross(yr).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Oi.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return Oi.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,r,o){return Oi.getInterpolation(e,this.a,this.b,this.c,t,n,r,o)}containsPoint(e){return Oi.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Oi.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const n=this.a,r=this.b,o=this.c;let a,l;io.subVectors(r,n),ro.subVectors(o,n),yh.subVectors(e,n);const u=io.dot(yh),h=ro.dot(yh);if(u<=0&&h<=0)return t.copy(n);Mh.subVectors(e,r);const d=io.dot(Mh),p=ro.dot(Mh);if(d>=0&&p<=d)return t.copy(r);const m=u*p-d*h;if(m<=0&&u>=0&&d<=0)return a=u/(u-d),t.copy(n).addScaledVector(io,a);Sh.subVectors(e,o);const g=io.dot(Sh),y=ro.dot(Sh);if(y>=0&&g<=y)return t.copy(o);const S=g*h-u*y;if(S<=0&&h>=0&&y<=0)return l=h/(h-y),t.copy(n).addScaledVector(ro,l);const _=d*y-g*p;if(_<=0&&p-d>=0&&g-y>=0)return dg.subVectors(o,r),l=(p-d)/(p-d+(g-y)),t.copy(r).addScaledVector(dg,l);const v=1/(_+S+m);return a=S*v,l=m*v,t.copy(n).addScaledVector(io,a).addScaledVector(ro,l)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const f0={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},Wr={h:0,s:0,l:0},Vc={h:0,s:0,l:0};function Eh(i,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?i+(e-i)*6*t:t<1/2?e:t<2/3?i+(e-i)*6*(2/3-t):i}class Oe{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){const r=e;r&&r.isColor?this.copy(r):typeof r=="number"?this.setHex(r):typeof r=="string"&&this.setStyle(r)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=on){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Lt.toWorkingColorSpace(this,t),this}setRGB(e,t,n,r=Lt.workingColorSpace){return this.r=e,this.g=t,this.b=n,Lt.toWorkingColorSpace(this,r),this}setHSL(e,t,n,r=Lt.workingColorSpace){if(e=Of(e,1),t=En(t,0,1),n=En(n,0,1),t===0)this.r=this.g=this.b=n;else{const o=n<=.5?n*(1+t):n+t-n*t,a=2*n-o;this.r=Eh(a,o,e+1/3),this.g=Eh(a,o,e),this.b=Eh(a,o,e-1/3)}return Lt.toWorkingColorSpace(this,r),this}setStyle(e,t=on){function n(o){o!==void 0&&parseFloat(o)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let o;const a=r[1],l=r[2];switch(a){case"rgb":case"rgba":if(o=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(l))return n(o[4]),this.setRGB(Math.min(255,parseInt(o[1],10))/255,Math.min(255,parseInt(o[2],10))/255,Math.min(255,parseInt(o[3],10))/255,t);if(o=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(l))return n(o[4]),this.setRGB(Math.min(100,parseInt(o[1],10))/100,Math.min(100,parseInt(o[2],10))/100,Math.min(100,parseInt(o[3],10))/100,t);break;case"hsl":case"hsla":if(o=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(l))return n(o[4]),this.setHSL(parseFloat(o[1])/360,parseFloat(o[2])/100,parseFloat(o[3])/100,t);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){const o=r[1],a=o.length;if(a===3)return this.setRGB(parseInt(o.charAt(0),16)/15,parseInt(o.charAt(1),16)/15,parseInt(o.charAt(2),16)/15,t);if(a===6)return this.setHex(parseInt(o,16),t);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=on){const n=f0[e.toLowerCase()];return n!==void 0?this.setHex(n,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}copySRGBToLinear(e){return this.r=bo(e.r),this.g=bo(e.g),this.b=bo(e.b),this}copyLinearToSRGB(e){return this.r=uh(e.r),this.g=uh(e.g),this.b=uh(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=on){return Lt.fromWorkingColorSpace(Pn.copy(this),e),Math.round(En(Pn.r*255,0,255))*65536+Math.round(En(Pn.g*255,0,255))*256+Math.round(En(Pn.b*255,0,255))}getHexString(e=on){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Lt.workingColorSpace){Lt.fromWorkingColorSpace(Pn.copy(this),t);const n=Pn.r,r=Pn.g,o=Pn.b,a=Math.max(n,r,o),l=Math.min(n,r,o);let u,h;const d=(l+a)/2;if(l===a)u=0,h=0;else{const p=a-l;switch(h=d<=.5?p/(a+l):p/(2-a-l),a){case n:u=(r-o)/p+(r<o?6:0);break;case r:u=(o-n)/p+2;break;case o:u=(n-r)/p+4;break}u/=6}return e.h=u,e.s=h,e.l=d,e}getRGB(e,t=Lt.workingColorSpace){return Lt.fromWorkingColorSpace(Pn.copy(this),t),e.r=Pn.r,e.g=Pn.g,e.b=Pn.b,e}getStyle(e=on){Lt.fromWorkingColorSpace(Pn.copy(this),e);const t=Pn.r,n=Pn.g,r=Pn.b;return e!==on?`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${r.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(r*255)})`}offsetHSL(e,t,n){return this.getHSL(Wr),this.setHSL(Wr.h+e,Wr.s+t,Wr.l+n)}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,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(Wr),e.getHSL(Vc);const n=Na(Wr.h,Vc.h,t),r=Na(Wr.s,Vc.s,t),o=Na(Wr.l,Vc.l,t);return this.setHSL(n,r,o),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const t=this.r,n=this.g,r=this.b,o=e.elements;return this.r=o[0]*t+o[3]*n+o[6]*r,this.g=o[1]*t+o[4]*n+o[7]*r,this.b=o[2]*t+o[5]*n+o[8]*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),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const Pn=new Oe;Oe.NAMES=f0;let Bw=0;class Ti extends Ps{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Bw++}),this.uuid=Fi(),this.name="",this.type="Material",this.blending=Eo,this.side=tr,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=rf,this.blendDst=sf,this.blendEquation=Ts,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Oe(0,0,0),this.blendAlpha=0,this.depthFunc=Tl,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=Qm,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=$s,this.stencilZFail=$s,this.stencilZPass=$s,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.forceSinglePass=!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(e!==void 0)for(const t in e){const n=e[t];if(n===void 0){console.warn(`THREE.Material: parameter '${t}' has value of undefined.`);continue}const r=this[t];if(r===void 0){console.warn(`THREE.Material: '${t}' is not a property of THREE.${this.type}.`);continue}r&&r.isColor?r.set(n):r&&r.isVector3&&n&&n.isVector3?r.copy(n):this[t]=n}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const n={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==Eo&&(n.blending=this.blending),this.side!==tr&&(n.side=this.side),this.vertexColors===!0&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=!0),this.blendSrc!==rf&&(n.blendSrc=this.blendSrc),this.blendDst!==sf&&(n.blendDst=this.blendDst),this.blendEquation!==Ts&&(n.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(n.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(n.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==Tl&&(n.depthFunc=this.depthFunc),this.depthTest===!1&&(n.depthTest=this.depthTest),this.depthWrite===!1&&(n.depthWrite=this.depthWrite),this.colorWrite===!1&&(n.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==Qm&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==$s&&(n.stencilFail=this.stencilFail),this.stencilZFail!==$s&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==$s&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function r(o){const a=[];for(const l in o){const u=o[l];delete u.metadata,a.push(u)}return a}if(t){const o=r(e.textures),a=r(e.images);o.length>0&&(n.textures=o),a.length>0&&(n.images=a)}return n}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,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 n=null;if(t!==null){const r=t.length;n=new Array(r);for(let o=0;o!==r;++o)n[o]=t[o].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,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){e===!0&&this.version++}}class Ji extends Ti{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Oe(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.envMapRotation=new Bi,this.combine=$_,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,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.envMapRotation.copy(e.envMapRotation),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.fog=e.fog,this}}const un=new F,Wc=new Pe;class Nt{constructor(e,t,n=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=lf,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.gpuType=Zi,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}get updateRange(){return u0("THREE.BufferAttribute: updateRange() is deprecated and will be removed in r169. Use addUpdateRange() instead."),this._updateRange}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}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.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let r=0,o=this.itemSize;r<o;r++)this.array[e+r]=t.array[n+r];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,n=this.count;t<n;t++)Wc.fromBufferAttribute(this,t),Wc.applyMatrix3(e),this.setXY(t,Wc.x,Wc.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)un.fromBufferAttribute(this,t),un.applyMatrix3(e),this.setXYZ(t,un.x,un.y,un.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)un.fromBufferAttribute(this,t),un.applyMatrix4(e),this.setXYZ(t,un.x,un.y,un.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)un.fromBufferAttribute(this,t),un.applyNormalMatrix(e),this.setXYZ(t,un.x,un.y,un.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)un.fromBufferAttribute(this,t),un.transformDirection(e),this.setXYZ(t,un.x,un.y,un.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let n=this.array[e*this.itemSize+t];return this.normalized&&(n=Ni(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=Dt(n,this.array)),this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=Ni(t,this.array)),t}setX(e,t){return this.normalized&&(t=Dt(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=Ni(t,this.array)),t}setY(e,t){return this.normalized&&(t=Dt(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=Ni(t,this.array)),t}setZ(e,t){return this.normalized&&(t=Dt(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=Ni(t,this.array)),t}setW(e,t){return this.normalized&&(t=Dt(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=Dt(t,this.array),n=Dt(n,this.array)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,r){return e*=this.itemSize,this.normalized&&(t=Dt(t,this.array),n=Dt(n,this.array),r=Dt(r,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this}setXYZW(e,t,n,r,o){return e*=this.itemSize,this.normalized&&(t=Dt(t,this.array),n=Dt(n,this.array),r=Dt(r,this.array),o=Dt(o,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this.array[e+3]=o,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.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==lf&&(e.usage=this.usage),e}}class d0 extends Nt{constructor(e,t,n){super(new Uint16Array(e),t,n)}}class p0 extends Nt{constructor(e,t,n){super(new Uint32Array(e),t,n)}}class Bt extends Nt{constructor(e,t,n){super(new Float32Array(e),t,n)}}let zw=0;const xi=new Qe,Th=new gt,so=new F,ri=new zi,ha=new zi,_n=new F;class tn extends Ps{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:zw++}),this.uuid=Fi(),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(l0(e)?p0:d0)(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 this.attributes[e]!==void 0}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){const t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);const n=this.attributes.normal;if(n!==void 0){const o=new ht().getNormalMatrix(e);n.applyNormalMatrix(o),n.needsUpdate=!0}const r=this.attributes.tangent;return r!==void 0&&(r.transformDirection(e),r.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return xi.makeRotationFromQuaternion(e),this.applyMatrix4(xi),this}rotateX(e){return xi.makeRotationX(e),this.applyMatrix4(xi),this}rotateY(e){return xi.makeRotationY(e),this.applyMatrix4(xi),this}rotateZ(e){return xi.makeRotationZ(e),this.applyMatrix4(xi),this}translate(e,t,n){return xi.makeTranslation(e,t,n),this.applyMatrix4(xi),this}scale(e,t,n){return xi.makeScale(e,t,n),this.applyMatrix4(xi),this}lookAt(e){return Th.lookAt(e),Th.updateMatrix(),this.applyMatrix4(Th.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(so).negate(),this.translate(so.x,so.y,so.z),this}setFromPoints(e){const t=[];for(let n=0,r=e.length;n<r;n++){const o=e[n];t.push(o.x,o.y,o.z||0)}return this.setAttribute("position",new Bt(t,3)),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new zi);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new F(-1/0,-1/0,-1/0),new F(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,r=t.length;n<r;n++){const o=t[n];ri.setFromBufferAttribute(o),this.morphTargetsRelative?(_n.addVectors(this.boundingBox.min,ri.min),this.boundingBox.expandByPoint(_n),_n.addVectors(this.boundingBox.max,ri.max),this.boundingBox.expandByPoint(_n)):(this.boundingBox.expandByPoint(ri.min),this.boundingBox.expandByPoint(ri.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(){this.boundingSphere===null&&(this.boundingSphere=new rr);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new F,1/0);return}if(e){const n=this.boundingSphere.center;if(ri.setFromBufferAttribute(e),t)for(let o=0,a=t.length;o<a;o++){const l=t[o];ha.setFromBufferAttribute(l),this.morphTargetsRelative?(_n.addVectors(ri.min,ha.min),ri.expandByPoint(_n),_n.addVectors(ri.max,ha.max),ri.expandByPoint(_n)):(ri.expandByPoint(ha.min),ri.expandByPoint(ha.max))}ri.getCenter(n);let r=0;for(let o=0,a=e.count;o<a;o++)_n.fromBufferAttribute(e,o),r=Math.max(r,n.distanceToSquared(_n));if(t)for(let o=0,a=t.length;o<a;o++){const l=t[o],u=this.morphTargetsRelative;for(let h=0,d=l.count;h<d;h++)_n.fromBufferAttribute(l,h),u&&(so.fromBufferAttribute(e,h),_n.add(so)),r=Math.max(r,n.distanceToSquared(_n))}this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const n=t.position,r=t.normal,o=t.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new Nt(new Float32Array(4*n.count),4));const a=this.getAttribute("tangent"),l=[],u=[];for(let C=0;C<n.count;C++)l[C]=new F,u[C]=new F;const h=new F,d=new F,p=new F,m=new Pe,g=new Pe,y=new Pe,S=new F,_=new F;function v(C,E,M){h.fromBufferAttribute(n,C),d.fromBufferAttribute(n,E),p.fromBufferAttribute(n,M),m.fromBufferAttribute(o,C),g.fromBufferAttribute(o,E),y.fromBufferAttribute(o,M),d.sub(h),p.sub(h),g.sub(m),y.sub(m);const O=1/(g.x*y.y-y.x*g.y);isFinite(O)&&(S.copy(d).multiplyScalar(y.y).addScaledVector(p,-g.y).multiplyScalar(O),_.copy(p).multiplyScalar(g.x).addScaledVector(d,-y.x).multiplyScalar(O),l[C].add(S),l[E].add(S),l[M].add(S),u[C].add(_),u[E].add(_),u[M].add(_))}let R=this.groups;R.length===0&&(R=[{start:0,count:e.count}]);for(let C=0,E=R.length;C<E;++C){const M=R[C],O=M.start,H=M.count;for(let G=O,Y=O+H;G<Y;G+=3)v(e.getX(G+0),e.getX(G+1),e.getX(G+2))}const b=new F,A=new F,B=new F,N=new F;function D(C){B.fromBufferAttribute(r,C),N.copy(B);const E=l[C];b.copy(E),b.sub(B.multiplyScalar(B.dot(E))).normalize(),A.crossVectors(N,E);const O=A.dot(u[C])<0?-1:1;a.setXYZW(C,b.x,b.y,b.z,O)}for(let C=0,E=R.length;C<E;++C){const M=R[C],O=M.start,H=M.count;for(let G=O,Y=O+H;G<Y;G+=3)D(e.getX(G+0)),D(e.getX(G+1)),D(e.getX(G+2))}}computeVertexNormals(){const e=this.index,t=this.getAttribute("position");if(t!==void 0){let n=this.getAttribute("normal");if(n===void 0)n=new Nt(new Float32Array(t.count*3),3),this.setAttribute("normal",n);else for(let m=0,g=n.count;m<g;m++)n.setXYZ(m,0,0,0);const r=new F,o=new F,a=new F,l=new F,u=new F,h=new F,d=new F,p=new F;if(e)for(let m=0,g=e.count;m<g;m+=3){const y=e.getX(m+0),S=e.getX(m+1),_=e.getX(m+2);r.fromBufferAttribute(t,y),o.fromBufferAttribute(t,S),a.fromBufferAttribute(t,_),d.subVectors(a,o),p.subVectors(r,o),d.cross(p),l.fromBufferAttribute(n,y),u.fromBufferAttribute(n,S),h.fromBufferAttribute(n,_),l.add(d),u.add(d),h.add(d),n.setXYZ(y,l.x,l.y,l.z),n.setXYZ(S,u.x,u.y,u.z),n.setXYZ(_,h.x,h.y,h.z)}else for(let m=0,g=t.count;m<g;m+=3)r.fromBufferAttribute(t,m+0),o.fromBufferAttribute(t,m+1),a.fromBufferAttribute(t,m+2),d.subVectors(a,o),p.subVectors(r,o),d.cross(p),n.setXYZ(m+0,d.x,d.y,d.z),n.setXYZ(m+1,d.x,d.y,d.z),n.setXYZ(m+2,d.x,d.y,d.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)_n.fromBufferAttribute(e,t),_n.normalize(),e.setXYZ(t,_n.x,_n.y,_n.z)}toNonIndexed(){function e(l,u){const h=l.array,d=l.itemSize,p=l.normalized,m=new h.constructor(u.length*d);let g=0,y=0;for(let S=0,_=u.length;S<_;S++){l.isInterleavedBufferAttribute?g=u[S]*l.data.stride+l.offset:g=u[S]*d;for(let v=0;v<d;v++)m[y++]=h[g++]}return new Nt(m,d,p)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new tn,n=this.index.array,r=this.attributes;for(const l in r){const u=r[l],h=e(u,n);t.setAttribute(l,h)}const o=this.morphAttributes;for(const l in o){const u=[],h=o[l];for(let d=0,p=h.length;d<p;d++){const m=h[d],g=e(m,n);u.push(g)}t.morphAttributes[l]=u}t.morphTargetsRelative=this.morphTargetsRelative;const a=this.groups;for(let l=0,u=a.length;l<u;l++){const h=a[l];t.addGroup(h.start,h.count,h.materialIndex)}return t}toJSON(){const e={metadata:{version:4.6,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){const u=this.parameters;for(const h in u)u[h]!==void 0&&(e[h]=u[h]);return e}e.data={attributes:{}};const t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const n=this.attributes;for(const u in n){const h=n[u];e.data.attributes[u]=h.toJSON(e.data)}const r={};let o=!1;for(const u in this.morphAttributes){const h=this.morphAttributes[u],d=[];for(let p=0,m=h.length;p<m;p++){const g=h[p];d.push(g.toJSON(e.data))}d.length>0&&(r[u]=d,o=!0)}o&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));const l=this.boundingSphere;return l!==null&&(e.data.boundingSphere={center:l.center.toArray(),radius:l.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 n=e.index;n!==null&&this.setIndex(n.clone(t));const r=e.attributes;for(const h in r){const d=r[h];this.setAttribute(h,d.clone(t))}const o=e.morphAttributes;for(const h in o){const d=[],p=o[h];for(let m=0,g=p.length;m<g;m++)d.push(p[m].clone(t));this.morphAttributes[h]=d}this.morphTargetsRelative=e.morphTargetsRelative;const a=e.groups;for(let h=0,d=a.length;h<d;h++){const p=a[h];this.addGroup(p.start,p.count,p.materialIndex)}const l=e.boundingBox;l!==null&&(this.boundingBox=l.clone());const u=e.boundingSphere;return u!==null&&(this.boundingSphere=u.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const pg=new Qe,ms=new Oo,Xc=new rr,mg=new F,oo=new F,ao=new F,co=new F,bh=new F,Yc=new F,jc=new Pe,qc=new Pe,$c=new Pe,gg=new F,_g=new F,vg=new F,Kc=new F,Zc=new F;class Se extends gt{constructor(e=new tn,t=new Ji){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const r=t[n[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let o=0,a=r.length;o<a;o++){const l=r[o].name||String(o);this.morphTargetInfluences.push(0),this.morphTargetDictionary[l]=o}}}}getVertexPosition(e,t){const n=this.geometry,r=n.attributes.position,o=n.morphAttributes.position,a=n.morphTargetsRelative;t.fromBufferAttribute(r,e);const l=this.morphTargetInfluences;if(o&&l){Yc.set(0,0,0);for(let u=0,h=o.length;u<h;u++){const d=l[u],p=o[u];d!==0&&(bh.fromBufferAttribute(p,e),a?Yc.addScaledVector(bh,d):Yc.addScaledVector(bh.sub(t),d))}t.add(Yc)}return t}raycast(e,t){const n=this.geometry,r=this.material,o=this.matrixWorld;r!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),Xc.copy(n.boundingSphere),Xc.applyMatrix4(o),ms.copy(e.ray).recast(e.near),!(Xc.containsPoint(ms.origin)===!1&&(ms.intersectSphere(Xc,mg)===null||ms.origin.distanceToSquared(mg)>(e.far-e.near)**2))&&(pg.copy(o).invert(),ms.copy(e.ray).applyMatrix4(pg),!(n.boundingBox!==null&&ms.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,ms)))}_computeIntersections(e,t,n){let r;const o=this.geometry,a=this.material,l=o.index,u=o.attributes.position,h=o.attributes.uv,d=o.attributes.uv1,p=o.attributes.normal,m=o.groups,g=o.drawRange;if(l!==null)if(Array.isArray(a))for(let y=0,S=m.length;y<S;y++){const _=m[y],v=a[_.materialIndex],R=Math.max(_.start,g.start),b=Math.min(l.count,Math.min(_.start+_.count,g.start+g.count));for(let A=R,B=b;A<B;A+=3){const N=l.getX(A),D=l.getX(A+1),C=l.getX(A+2);r=Jc(this,v,e,n,h,d,p,N,D,C),r&&(r.faceIndex=Math.floor(A/3),r.face.materialIndex=_.materialIndex,t.push(r))}}else{const y=Math.max(0,g.start),S=Math.min(l.count,g.start+g.count);for(let _=y,v=S;_<v;_+=3){const R=l.getX(_),b=l.getX(_+1),A=l.getX(_+2);r=Jc(this,a,e,n,h,d,p,R,b,A),r&&(r.faceIndex=Math.floor(_/3),t.push(r))}}else if(u!==void 0)if(Array.isArray(a))for(let y=0,S=m.length;y<S;y++){const _=m[y],v=a[_.materialIndex],R=Math.max(_.start,g.start),b=Math.min(u.count,Math.min(_.start+_.count,g.start+g.count));for(let A=R,B=b;A<B;A+=3){const N=A,D=A+1,C=A+2;r=Jc(this,v,e,n,h,d,p,N,D,C),r&&(r.faceIndex=Math.floor(A/3),r.face.materialIndex=_.materialIndex,t.push(r))}}else{const y=Math.max(0,g.start),S=Math.min(u.count,g.start+g.count);for(let _=y,v=S;_<v;_+=3){const R=_,b=_+1,A=_+2;r=Jc(this,a,e,n,h,d,p,R,b,A),r&&(r.faceIndex=Math.floor(_/3),t.push(r))}}}}function kw(i,e,t,n,r,o,a,l){let u;if(e.side===Kn?u=n.intersectTriangle(a,o,r,!0,l):u=n.intersectTriangle(r,o,a,e.side===tr,l),u===null)return null;Zc.copy(l),Zc.applyMatrix4(i.matrixWorld);const h=t.ray.origin.distanceTo(Zc);return h<t.near||h>t.far?null:{distance:h,point:Zc.clone(),object:i}}function Jc(i,e,t,n,r,o,a,l,u,h){i.getVertexPosition(l,oo),i.getVertexPosition(u,ao),i.getVertexPosition(h,co);const d=kw(i,e,t,n,oo,ao,co,Kc);if(d){r&&(jc.fromBufferAttribute(r,l),qc.fromBufferAttribute(r,u),$c.fromBufferAttribute(r,h),d.uv=Oi.getInterpolation(Kc,oo,ao,co,jc,qc,$c,new Pe)),o&&(jc.fromBufferAttribute(o,l),qc.fromBufferAttribute(o,u),$c.fromBufferAttribute(o,h),d.uv1=Oi.getInterpolation(Kc,oo,ao,co,jc,qc,$c,new Pe)),a&&(gg.fromBufferAttribute(a,l),_g.fromBufferAttribute(a,u),vg.fromBufferAttribute(a,h),d.normal=Oi.getInterpolation(Kc,oo,ao,co,gg,_g,vg,new F),d.normal.dot(n.direction)>0&&d.normal.multiplyScalar(-1));const p={a:l,b:u,c:h,normal:new F,materialIndex:0};Oi.getNormal(oo,ao,co,p.normal),d.face=p}return d}class Kt extends tn{constructor(e=1,t=1,n=1,r=1,o=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:r,heightSegments:o,depthSegments:a};const l=this;r=Math.floor(r),o=Math.floor(o),a=Math.floor(a);const u=[],h=[],d=[],p=[];let m=0,g=0;y("z","y","x",-1,-1,n,t,e,a,o,0),y("z","y","x",1,-1,n,t,-e,a,o,1),y("x","z","y",1,1,e,n,t,r,a,2),y("x","z","y",1,-1,e,n,-t,r,a,3),y("x","y","z",1,-1,e,t,n,r,o,4),y("x","y","z",-1,-1,e,t,-n,r,o,5),this.setIndex(u),this.setAttribute("position",new Bt(h,3)),this.setAttribute("normal",new Bt(d,3)),this.setAttribute("uv",new Bt(p,2));function y(S,_,v,R,b,A,B,N,D,C,E){const M=A/D,O=B/C,H=A/2,G=B/2,Y=N/2,$=D+1,re=C+1;let se=0,K=0;const ae=new F;for(let pe=0;pe<re;pe++){const ve=pe*O-G;for(let ke=0;ke<$;ke++){const Ze=ke*M-H;ae[S]=Ze*R,ae[_]=ve*b,ae[v]=Y,h.push(ae.x,ae.y,ae.z),ae[S]=0,ae[_]=0,ae[v]=N>0?1:-1,d.push(ae.x,ae.y,ae.z),p.push(ke/D),p.push(1-pe/C),se+=1}}for(let pe=0;pe<C;pe++)for(let ve=0;ve<D;ve++){const ke=m+ve+$*pe,Ze=m+ve+$*(pe+1),te=m+(ve+1)+$*(pe+1),fe=m+(ve+1)+$*pe;u.push(ke,Ze,fe),u.push(Ze,te,fe),K+=6}l.addGroup(g,K,E),g+=K,m+=se}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Kt(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function Do(i){const e={};for(const t in i){e[t]={};for(const n in i[t]){const r=i[t][n];r&&(r.isColor||r.isMatrix3||r.isMatrix4||r.isVector2||r.isVector3||r.isVector4||r.isTexture||r.isQuaternion)?r.isRenderTargetTexture?(console.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[t][n]=null):e[t][n]=r.clone():Array.isArray(r)?e[t][n]=r.slice():e[t][n]=r}}return e}function Vn(i){const e={};for(let t=0;t<i.length;t++){const n=Do(i[t]);for(const r in n)e[r]=n[r]}return e}function Hw(i){const e=[];for(let t=0;t<i.length;t++)e.push(i[t].clone());return e}function m0(i){const e=i.getRenderTarget();return e===null?i.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:Lt.workingColorSpace}const Gw={clone:Do,merge:Vn};var Vw=`void main() {
5
+ */const Uf="163",js={ROTATE:0,DOLLY:1,PAN:2},qs={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},rb=0,ym=1,sb=2,j_=1,q_=2,Tr=3,tr=0,Kn=1,si=2,Jr=0,Eo=1,Mm=2,Sm=3,Em=4,ob=5,Ts=100,ab=101,cb=102,lb=103,ub=104,hb=200,fb=201,db=202,pb=203,sf=204,of=205,mb=206,gb=207,_b=208,vb=209,xb=210,yb=211,Mb=212,Sb=213,Eb=214,Tb=0,bb=1,wb=2,Tl=3,Ab=4,Rb=5,Cb=6,Pb=7,$_=0,Lb=1,Ib=2,Ar=0,Db=1,Ub=2,Nb=3,Ob=4,Fb=5,Bb=6,zb=7,Tm="attached",kb="detached",K_=300,Ao=301,Ro=302,af=303,cf=304,Bl=306,es=1e3,$i=1001,Co=1002,Nn=1003,Nf=1004,yo=1005,Xn=1006,Da=1007,Ki=1008,Qr=1009,Hb=1010,Gb=1011,Z_=1012,J_=1013,Po=1014,Zi=1015,bl=1016,Q_=1017,e0=1018,Ga=1020,Vb=35902,Wb=1021,Xb=1022,Ei=1023,Yb=1024,jb=1025,To=1026,Ba=1027,t0=1028,n0=1029,qb=1030,i0=1031,r0=1033,rh=33776,sh=33777,oh=33778,ah=33779,bm=35840,wm=35841,Am=35842,Rm=35843,s0=36196,Cm=37492,Pm=37496,Lm=37808,Im=37809,Dm=37810,Um=37811,Nm=37812,Om=37813,Fm=37814,Bm=37815,zm=37816,km=37817,Hm=37818,Gm=37819,Vm=37820,Wm=37821,ch=36492,Xm=36494,Ym=36495,$b=36283,jm=36284,qm=36285,$m=36286,Lo=2300,As=2301,lh=2302,Km=2400,Zm=2401,Jm=2402,Kb=2500,Zb=0,o0=1,lf=2,Jb=3200,Qb=3201,a0=0,ew=1,Sn="",on="srgb",Tn="srgb-linear",Of="display-p3",zl="display-p3-linear",wl="linear",Wt="srgb",Al="rec709",Rl="p3",$s=7680,Qm=519,tw=512,nw=513,iw=514,c0=515,rw=516,sw=517,ow=518,aw=519,uf=35044,eg="300 es",br=2e3,Cl=2001;class Ps{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){if(this._listeners===void 0)return!1;const n=this._listeners;return n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){if(this._listeners===void 0)return;const r=this._listeners[e];if(r!==void 0){const o=r.indexOf(t);o!==-1&&r.splice(o,1)}}dispatchEvent(e){if(this._listeners===void 0)return;const n=this._listeners[e.type];if(n!==void 0){e.target=this;const r=n.slice(0);for(let o=0,a=r.length;o<a;o++)r[o].call(this,e);e.target=null}}}const Cn=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let tg=1234567;const Ua=Math.PI/180,Io=180/Math.PI;function Fi(){const i=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(Cn[i&255]+Cn[i>>8&255]+Cn[i>>16&255]+Cn[i>>24&255]+"-"+Cn[e&255]+Cn[e>>8&255]+"-"+Cn[e>>16&15|64]+Cn[e>>24&255]+"-"+Cn[t&63|128]+Cn[t>>8&255]+"-"+Cn[t>>16&255]+Cn[t>>24&255]+Cn[n&255]+Cn[n>>8&255]+Cn[n>>16&255]+Cn[n>>24&255]).toLowerCase()}function En(i,e,t){return Math.max(e,Math.min(t,i))}function Ff(i,e){return(i%e+e)%e}function cw(i,e,t,n,r){return n+(i-e)*(r-n)/(t-e)}function lw(i,e,t){return i!==e?(t-i)/(e-i):0}function Na(i,e,t){return(1-t)*i+t*e}function uw(i,e,t,n){return Na(i,e,1-Math.exp(-t*n))}function hw(i,e=1){return e-Math.abs(Ff(i,e*2)-e)}function fw(i,e,t){return i<=e?0:i>=t?1:(i=(i-e)/(t-e),i*i*(3-2*i))}function dw(i,e,t){return i<=e?0:i>=t?1:(i=(i-e)/(t-e),i*i*i*(i*(i*6-15)+10))}function pw(i,e){return i+Math.floor(Math.random()*(e-i+1))}function mw(i,e){return i+Math.random()*(e-i)}function gw(i){return i*(.5-Math.random())}function _w(i){i!==void 0&&(tg=i);let e=tg+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function vw(i){return i*Ua}function xw(i){return i*Io}function yw(i){return(i&i-1)===0&&i!==0}function Mw(i){return Math.pow(2,Math.ceil(Math.log(i)/Math.LN2))}function Sw(i){return Math.pow(2,Math.floor(Math.log(i)/Math.LN2))}function Ew(i,e,t,n,r){const o=Math.cos,a=Math.sin,l=o(t/2),u=a(t/2),h=o((e+n)/2),d=a((e+n)/2),p=o((e-n)/2),m=a((e-n)/2),g=o((n-e)/2),y=a((n-e)/2);switch(r){case"XYX":i.set(l*d,u*p,u*m,l*h);break;case"YZY":i.set(u*m,l*d,u*p,l*h);break;case"ZXZ":i.set(u*p,u*m,l*d,l*h);break;case"XZX":i.set(l*d,u*y,u*g,l*h);break;case"YXY":i.set(u*g,l*d,u*y,l*h);break;case"ZYZ":i.set(u*y,u*g,l*d,l*h);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}function Ni(i,e){switch(e.constructor){case Float32Array:return i;case Uint32Array:return i/4294967295;case Uint16Array:return i/65535;case Uint8Array:return i/255;case Int32Array:return Math.max(i/2147483647,-1);case Int16Array:return Math.max(i/32767,-1);case Int8Array:return Math.max(i/127,-1);default:throw new Error("Invalid component type.")}}function Dt(i,e){switch(e.constructor){case Float32Array:return i;case Uint32Array:return Math.round(i*4294967295);case Uint16Array:return Math.round(i*65535);case Uint8Array:return Math.round(i*255);case Int32Array:return Math.round(i*2147483647);case Int16Array:return Math.round(i*32767);case Int8Array:return Math.round(i*127);default:throw new Error("Invalid component type.")}}const ci={DEG2RAD:Ua,RAD2DEG:Io,generateUUID:Fi,clamp:En,euclideanModulo:Ff,mapLinear:cw,inverseLerp:lw,lerp:Na,damp:uw,pingpong:hw,smoothstep:fw,smootherstep:dw,randInt:pw,randFloat:mw,randFloatSpread:gw,seededRandom:_w,degToRad:vw,radToDeg:xw,isPowerOfTwo:yw,ceilPowerOfTwo:Mw,floorPowerOfTwo:Sw,setQuaternionFromProperEuler:Ew,normalize:Dt,denormalize:Ni};class Pe{constructor(e=0,t=0){Pe.prototype.isVector2=!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){return 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){return 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,n=this.y,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6],this.y=r[1]*t+r[4]*n+r[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(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}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(En(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const n=Math.cos(t),r=Math.sin(t),o=this.x-e.x,a=this.y-e.y;return this.x=o*n-a*r+e.x,this.y=o*r+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class ht{constructor(e,t,n,r,o,a,l,u,h){ht.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,r,o,a,l,u,h)}set(e,t,n,r,o,a,l,u,h){const d=this.elements;return d[0]=e,d[1]=r,d[2]=l,d[3]=t,d[4]=o,d[5]=u,d[6]=n,d[7]=a,d[8]=h,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){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 n=e.elements,r=t.elements,o=this.elements,a=n[0],l=n[3],u=n[6],h=n[1],d=n[4],p=n[7],m=n[2],g=n[5],y=n[8],S=r[0],_=r[3],v=r[6],R=r[1],b=r[4],A=r[7],B=r[2],N=r[5],D=r[8];return o[0]=a*S+l*R+u*B,o[3]=a*_+l*b+u*N,o[6]=a*v+l*A+u*D,o[1]=h*S+d*R+p*B,o[4]=h*_+d*b+p*N,o[7]=h*v+d*A+p*D,o[2]=m*S+g*R+y*B,o[5]=m*_+g*b+y*N,o[8]=m*v+g*A+y*D,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],n=e[1],r=e[2],o=e[3],a=e[4],l=e[5],u=e[6],h=e[7],d=e[8];return t*a*d-t*l*h-n*o*d+n*l*u+r*o*h-r*a*u}invert(){const e=this.elements,t=e[0],n=e[1],r=e[2],o=e[3],a=e[4],l=e[5],u=e[6],h=e[7],d=e[8],p=d*a-l*h,m=l*u-d*o,g=h*o-a*u,y=t*p+n*m+r*g;if(y===0)return this.set(0,0,0,0,0,0,0,0,0);const S=1/y;return e[0]=p*S,e[1]=(r*h-d*n)*S,e[2]=(l*n-r*a)*S,e[3]=m*S,e[4]=(d*t-r*u)*S,e[5]=(r*o-l*t)*S,e[6]=g*S,e[7]=(n*u-h*t)*S,e[8]=(a*t-n*o)*S,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,n,r,o,a,l){const u=Math.cos(o),h=Math.sin(o);return this.set(n*u,n*h,-n*(u*a+h*l)+a+e,-r*h,r*u,-r*(-h*a+u*l)+l+t,0,0,1),this}scale(e,t){return this.premultiply(uh.makeScale(e,t)),this}rotate(e){return this.premultiply(uh.makeRotation(-e)),this}translate(e,t){return this.premultiply(uh.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,n=e.elements;for(let r=0;r<9;r++)if(t[r]!==n[r])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}}const uh=new ht;function l0(i){for(let e=i.length-1;e>=0;--e)if(i[e]>=65535)return!0;return!1}function za(i){return document.createElementNS("http://www.w3.org/1999/xhtml",i)}function Tw(){const i=za("canvas");return i.style.display="block",i}const ng={};function u0(i){i in ng||(ng[i]=!0,console.warn(i))}const ig=new ht().set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),rg=new ht().set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),Nc={[Tn]:{transfer:wl,primaries:Al,toReference:i=>i,fromReference:i=>i},[on]:{transfer:Wt,primaries:Al,toReference:i=>i.convertSRGBToLinear(),fromReference:i=>i.convertLinearToSRGB()},[zl]:{transfer:wl,primaries:Rl,toReference:i=>i.applyMatrix3(rg),fromReference:i=>i.applyMatrix3(ig)},[Of]:{transfer:Wt,primaries:Rl,toReference:i=>i.convertSRGBToLinear().applyMatrix3(rg),fromReference:i=>i.applyMatrix3(ig).convertLinearToSRGB()}},bw=new Set([Tn,zl]),Lt={enabled:!0,_workingColorSpace:Tn,get workingColorSpace(){return this._workingColorSpace},set workingColorSpace(i){if(!bw.has(i))throw new Error(`Unsupported working color space, "${i}".`);this._workingColorSpace=i},convert:function(i,e,t){if(this.enabled===!1||e===t||!e||!t)return i;const n=Nc[e].toReference,r=Nc[t].fromReference;return r(n(i))},fromWorkingColorSpace:function(i,e){return this.convert(i,this._workingColorSpace,e)},toWorkingColorSpace:function(i,e){return this.convert(i,e,this._workingColorSpace)},getPrimaries:function(i){return Nc[i].primaries},getTransfer:function(i){return i===Sn?wl:Nc[i].transfer}};function bo(i){return i<.04045?i*.0773993808:Math.pow(i*.9478672986+.0521327014,2.4)}function hh(i){return i<.0031308?i*12.92:1.055*Math.pow(i,.41666)-.055}let Ks;class ww{static getDataURL(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{Ks===void 0&&(Ks=za("canvas")),Ks.width=e.width,Ks.height=e.height;const n=Ks.getContext("2d");e instanceof ImageData?n.putImageData(e,0,0):n.drawImage(e,0,0,e.width,e.height),t=Ks}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")}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const t=za("canvas");t.width=e.width,t.height=e.height;const n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);const r=n.getImageData(0,0,e.width,e.height),o=r.data;for(let a=0;a<o.length;a++)o[a]=bo(o[a]/255)*255;return n.putImageData(r,0,0),t}else if(e.data){const t=e.data.slice(0);for(let n=0;n<t.length;n++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[n]=Math.floor(bo(t[n]/255)*255):t[n]=bo(t[n]);return{data:t,width:e.width,height:e.height}}else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let Aw=0;class Bf{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:Aw++}),this.uuid=Fi(),this.data=e,this.dataReady=!0,this.version=0}set needsUpdate(e){e===!0&&this.version++}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];const n={uuid:this.uuid,url:""},r=this.data;if(r!==null){let o;if(Array.isArray(r)){o=[];for(let a=0,l=r.length;a<l;a++)r[a].isDataTexture?o.push(fh(r[a].image)):o.push(fh(r[a]))}else o=fh(r);n.url=o}return t||(e.images[this.uuid]=n),n}}function fh(i){return typeof HTMLImageElement<"u"&&i instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&i instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&i instanceof ImageBitmap?ww.getDataURL(i):i.data?{data:Array.from(i.data),width:i.width,height:i.height,type:i.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}let Rw=0;class cn extends Ps{constructor(e=cn.DEFAULT_IMAGE,t=cn.DEFAULT_MAPPING,n=$i,r=$i,o=Xn,a=Ki,l=Ei,u=Qr,h=cn.DEFAULT_ANISOTROPY,d=Sn){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Rw++}),this.uuid=Fi(),this.name="",this.source=new Bf(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=n,this.wrapT=r,this.magFilter=o,this.minFilter=a,this.anisotropy=h,this.format=l,this.internalFormat=null,this.type=u,this.offset=new Pe(0,0),this.repeat=new Pe(1,1),this.center=new Pe(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new ht,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=d,this.userData={},this.version=0,this.onUpdate=null,this.isRenderTargetTexture=!1,this.pmremVersion=0}get image(){return this.source.data}set image(e=null){this.source.data=e}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.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,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.colorSpace=e.colorSpace,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const n={metadata:{version:4.6,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,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,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==K_)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case es:e.x=e.x-Math.floor(e.x);break;case $i:e.x=e.x<0?0:1;break;case Co:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case es:e.y=e.y-Math.floor(e.y);break;case $i:e.y=e.y<0?0:1;break;case Co:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}}cn.DEFAULT_IMAGE=null;cn.DEFAULT_MAPPING=K_;cn.DEFAULT_ANISOTROPY=1;class Ut{constructor(e=0,t=0,n=0,r=1){Ut.prototype.isVector4=!0,this.x=e,this.y=t,this.z=n,this.w=r}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,r){return this.x=e,this.y=t,this.z=n,this.w=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw 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=e.w!==void 0?e.w:1,this}add(e){return 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){return 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,n=this.y,r=this.z,o=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*r+a[12]*o,this.y=a[1]*t+a[5]*n+a[9]*r+a[13]*o,this.z=a[2]*t+a[6]*n+a[10]*r+a[14]*o,this.w=a[3]*t+a[7]*n+a[11]*r+a[15]*o,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,n,r,o;const u=e.elements,h=u[0],d=u[4],p=u[8],m=u[1],g=u[5],y=u[9],S=u[2],_=u[6],v=u[10];if(Math.abs(d-m)<.01&&Math.abs(p-S)<.01&&Math.abs(y-_)<.01){if(Math.abs(d+m)<.1&&Math.abs(p+S)<.1&&Math.abs(y+_)<.1&&Math.abs(h+g+v-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const b=(h+1)/2,A=(g+1)/2,B=(v+1)/2,N=(d+m)/4,D=(p+S)/4,C=(y+_)/4;return b>A&&b>B?b<.01?(n=0,r=.707106781,o=.707106781):(n=Math.sqrt(b),r=N/n,o=D/n):A>B?A<.01?(n=.707106781,r=0,o=.707106781):(r=Math.sqrt(A),n=N/r,o=C/r):B<.01?(n=.707106781,r=.707106781,o=0):(o=Math.sqrt(B),n=D/o,r=C/o),this.set(n,r,o,t),this}let R=Math.sqrt((_-y)*(_-y)+(p-S)*(p-S)+(m-d)*(m-d));return Math.abs(R)<.001&&(R=1),this.x=(_-y)/R,this.y=(p-S)/R,this.z=(m-d)/R,this.w=Math.acos((h+g+v-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 n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return 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}}class Cw extends Ps{constructor(e=1,t=1,n={}){super(),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=1,this.scissor=new Ut(0,0,e,t),this.scissorTest=!1,this.viewport=new Ut(0,0,e,t);const r={width:e,height:t,depth:1};n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Xn,depthBuffer:!0,stencilBuffer:!1,depthTexture:null,samples:0,count:1},n);const o=new cn(r,n.mapping,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.colorSpace);o.flipY=!1,o.generateMipmaps=n.generateMipmaps,o.internalFormat=n.internalFormat,this.textures=[];const a=n.count;for(let l=0;l<a;l++)this.textures[l]=o.clone(),this.textures[l].isRenderTargetTexture=!0;this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.depthTexture=n.depthTexture,this.samples=n.samples}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}setSize(e,t,n=1){if(this.width!==e||this.height!==t||this.depth!==n){this.width=e,this.height=t,this.depth=n;for(let r=0,o=this.textures.length;r<o;r++)this.textures[r].image.width=e,this.textures[r].image.height=t,this.textures[r].image.depth=n;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){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let n=0,r=e.textures.length;n<r;n++)this.textures[n]=e.textures[n].clone(),this.textures[n].isRenderTargetTexture=!0;const t=Object.assign({},e.texture.image);return this.texture.source=new Bf(t),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class Rs extends Cw{constructor(e=1,t=1,n={}){super(e,t,n),this.isWebGLRenderTarget=!0}}class h0 extends cn{constructor(e=null,t=1,n=1,r=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:r},this.magFilter=Nn,this.minFilter=Nn,this.wrapR=$i,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Pw extends cn{constructor(e=null,t=1,n=1,r=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:r},this.magFilter=Nn,this.minFilter=Nn,this.wrapR=$i,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class an{constructor(e=0,t=0,n=0,r=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=r}static slerpFlat(e,t,n,r,o,a,l){let u=n[r+0],h=n[r+1],d=n[r+2],p=n[r+3];const m=o[a+0],g=o[a+1],y=o[a+2],S=o[a+3];if(l===0){e[t+0]=u,e[t+1]=h,e[t+2]=d,e[t+3]=p;return}if(l===1){e[t+0]=m,e[t+1]=g,e[t+2]=y,e[t+3]=S;return}if(p!==S||u!==m||h!==g||d!==y){let _=1-l;const v=u*m+h*g+d*y+p*S,R=v>=0?1:-1,b=1-v*v;if(b>Number.EPSILON){const B=Math.sqrt(b),N=Math.atan2(B,v*R);_=Math.sin(_*N)/B,l=Math.sin(l*N)/B}const A=l*R;if(u=u*_+m*A,h=h*_+g*A,d=d*_+y*A,p=p*_+S*A,_===1-l){const B=1/Math.sqrt(u*u+h*h+d*d+p*p);u*=B,h*=B,d*=B,p*=B}}e[t]=u,e[t+1]=h,e[t+2]=d,e[t+3]=p}static multiplyQuaternionsFlat(e,t,n,r,o,a){const l=n[r],u=n[r+1],h=n[r+2],d=n[r+3],p=o[a],m=o[a+1],g=o[a+2],y=o[a+3];return e[t]=l*y+d*p+u*g-h*m,e[t+1]=u*y+d*m+h*p-l*g,e[t+2]=h*y+d*g+l*m-u*p,e[t+3]=d*y-l*p-u*m-h*g,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,r){return this._x=e,this._y=t,this._z=n,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){const n=e._x,r=e._y,o=e._z,a=e._order,l=Math.cos,u=Math.sin,h=l(n/2),d=l(r/2),p=l(o/2),m=u(n/2),g=u(r/2),y=u(o/2);switch(a){case"XYZ":this._x=m*d*p+h*g*y,this._y=h*g*p-m*d*y,this._z=h*d*y+m*g*p,this._w=h*d*p-m*g*y;break;case"YXZ":this._x=m*d*p+h*g*y,this._y=h*g*p-m*d*y,this._z=h*d*y-m*g*p,this._w=h*d*p+m*g*y;break;case"ZXY":this._x=m*d*p-h*g*y,this._y=h*g*p+m*d*y,this._z=h*d*y+m*g*p,this._w=h*d*p-m*g*y;break;case"ZYX":this._x=m*d*p-h*g*y,this._y=h*g*p+m*d*y,this._z=h*d*y-m*g*p,this._w=h*d*p+m*g*y;break;case"YZX":this._x=m*d*p+h*g*y,this._y=h*g*p+m*d*y,this._z=h*d*y-m*g*p,this._w=h*d*p-m*g*y;break;case"XZY":this._x=m*d*p-h*g*y,this._y=h*g*p-m*d*y,this._z=h*d*y+m*g*p,this._w=h*d*p+m*g*y;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const n=t/2,r=Math.sin(n);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,n=t[0],r=t[4],o=t[8],a=t[1],l=t[5],u=t[9],h=t[2],d=t[6],p=t[10],m=n+l+p;if(m>0){const g=.5/Math.sqrt(m+1);this._w=.25/g,this._x=(d-u)*g,this._y=(o-h)*g,this._z=(a-r)*g}else if(n>l&&n>p){const g=2*Math.sqrt(1+n-l-p);this._w=(d-u)/g,this._x=.25*g,this._y=(r+a)/g,this._z=(o+h)/g}else if(l>p){const g=2*Math.sqrt(1+l-n-p);this._w=(o-h)/g,this._x=(r+a)/g,this._y=.25*g,this._z=(u+d)/g}else{const g=2*Math.sqrt(1+p-n-l);this._w=(a-r)/g,this._x=(o+h)/g,this._y=(u+d)/g,this._z=.25*g}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<Number.EPSILON?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(En(this.dot(e),-1,1)))}rotateTowards(e,t){const n=this.angleTo(e);if(n===0)return this;const r=Math.min(1,t/n);return this.slerp(e,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const n=e._x,r=e._y,o=e._z,a=e._w,l=t._x,u=t._y,h=t._z,d=t._w;return this._x=n*d+a*l+r*h-o*u,this._y=r*d+a*u+o*l-n*h,this._z=o*d+a*h+n*u-r*l,this._w=a*d-n*l-r*u-o*h,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);const n=this._x,r=this._y,o=this._z,a=this._w;let l=a*e._w+n*e._x+r*e._y+o*e._z;if(l<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,l=-l):this.copy(e),l>=1)return this._w=a,this._x=n,this._y=r,this._z=o,this;const u=1-l*l;if(u<=Number.EPSILON){const g=1-t;return this._w=g*a+t*this._w,this._x=g*n+t*this._x,this._y=g*r+t*this._y,this._z=g*o+t*this._z,this.normalize(),this}const h=Math.sqrt(u),d=Math.atan2(h,l),p=Math.sin((1-t)*d)/h,m=Math.sin(t*d)/h;return this._w=a*p+this._w*m,this._x=n*p+this._x*m,this._y=r*p+this._y*m,this._z=o*p+this._z*m,this._onChangeCallback(),this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),r=Math.sqrt(1-n),o=Math.sqrt(n);return this.set(r*Math.sin(e),r*Math.cos(e),o*Math.sin(t),o*Math.cos(t))}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._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class F{constructor(e=0,t=0,n=0){F.prototype.isVector3=!0,this.x=e,this.y=t,this.z=n}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw 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){return 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){return 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){return 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 this.applyQuaternion(sg.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(sg.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,n=this.y,r=this.z,o=e.elements;return this.x=o[0]*t+o[3]*n+o[6]*r,this.y=o[1]*t+o[4]*n+o[7]*r,this.z=o[2]*t+o[5]*n+o[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,n=this.y,r=this.z,o=e.elements,a=1/(o[3]*t+o[7]*n+o[11]*r+o[15]);return this.x=(o[0]*t+o[4]*n+o[8]*r+o[12])*a,this.y=(o[1]*t+o[5]*n+o[9]*r+o[13])*a,this.z=(o[2]*t+o[6]*n+o[10]*r+o[14])*a,this}applyQuaternion(e){const t=this.x,n=this.y,r=this.z,o=e.x,a=e.y,l=e.z,u=e.w,h=2*(a*r-l*n),d=2*(l*t-o*r),p=2*(o*n-a*t);return this.x=t+u*h+a*p-l*d,this.y=n+u*d+l*h-o*p,this.z=r+u*p+o*d-a*h,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,n=this.y,r=this.z,o=e.elements;return this.x=o[0]*t+o[4]*n+o[8]*r,this.y=o[1]*t+o[5]*n+o[9]*r,this.z=o[2]*t+o[6]*n+o[10]*r,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const n=e.x,r=e.y,o=e.z,a=t.x,l=t.y,u=t.z;return this.x=r*u-o*l,this.y=o*a-n*u,this.z=n*l-r*a,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return dh.copy(this).projectOnVector(e),this.sub(dh)}reflect(e){return this.sub(dh.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(En(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y,r=this.z-e.z;return t*t+n*n+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){const r=Math.sin(t)*e;return this.x=r*Math.sin(n),this.y=Math.cos(t)*e,this.z=r*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){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(),n=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=r,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}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){return 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=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const dh=new F,sg=new an;class zi{constructor(e=new F(1/0,1/0,1/0),t=new F(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t+=3)this.expandByPoint(Pi.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(Pi.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const n=Pi.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}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,t=!1){e.updateWorldMatrix(!1,!1);const n=e.geometry;if(n!==void 0){const o=n.getAttribute("position");if(t===!0&&o!==void 0&&e.isInstancedMesh!==!0)for(let a=0,l=o.count;a<l;a++)e.isMesh===!0?e.getVertexPosition(a,Pi):Pi.fromBufferAttribute(o,a),Pi.applyMatrix4(e.matrixWorld),this.expandByPoint(Pi);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),Oc.copy(e.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),Oc.copy(n.boundingBox)),Oc.applyMatrix4(e.matrixWorld),this.union(Oc)}const r=e.children;for(let o=0,a=r.length;o<a;o++)this.expandByObject(r[o],t);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,Pi),Pi.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(ca),Fc.subVectors(this.max,ca),Zs.subVectors(e.a,ca),Js.subVectors(e.b,ca),Qs.subVectors(e.c,ca),kr.subVectors(Js,Zs),Hr.subVectors(Qs,Js),ds.subVectors(Zs,Qs);let t=[0,-kr.z,kr.y,0,-Hr.z,Hr.y,0,-ds.z,ds.y,kr.z,0,-kr.x,Hr.z,0,-Hr.x,ds.z,0,-ds.x,-kr.y,kr.x,0,-Hr.y,Hr.x,0,-ds.y,ds.x,0];return!ph(t,Zs,Js,Qs,Fc)||(t=[1,0,0,0,1,0,0,0,1],!ph(t,Zs,Js,Qs,Fc))?!1:(Bc.crossVectors(kr,Hr),t=[Bc.x,Bc.y,Bc.z],ph(t,Zs,Js,Qs,Fc))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Pi).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Pi).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(_r[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),_r[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),_r[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),_r[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),_r[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),_r[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),_r[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),_r[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(_r),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)}}const _r=[new F,new F,new F,new F,new F,new F,new F,new F],Pi=new F,Oc=new zi,Zs=new F,Js=new F,Qs=new F,kr=new F,Hr=new F,ds=new F,ca=new F,Fc=new F,Bc=new F,ps=new F;function ph(i,e,t,n,r){for(let o=0,a=i.length-3;o<=a;o+=3){ps.fromArray(i,o);const l=r.x*Math.abs(ps.x)+r.y*Math.abs(ps.y)+r.z*Math.abs(ps.z),u=e.dot(ps),h=t.dot(ps),d=n.dot(ps);if(Math.max(-Math.max(u,h,d),Math.min(u,h,d))>l)return!1}return!0}const Lw=new zi,la=new F,mh=new F;class rr{constructor(e=new F,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const n=this.center;t!==void 0?n.copy(t):Lw.setFromPoints(e).getCenter(n);let r=0;for(let o=0,a=e.length;o<a;o++)r=Math.max(r,n.distanceToSquared(e[o]));return this.radius=Math.sqrt(r),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 n=this.center.distanceToSquared(e);return t.copy(e),n>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){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;la.subVectors(e,this.center);const t=la.lengthSq();if(t>this.radius*this.radius){const n=Math.sqrt(t),r=(n-this.radius)*.5;this.center.addScaledVector(la,r/n),this.radius+=r}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(mh.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(la.copy(e.center).add(mh)),this.expandByPoint(la.copy(e.center).sub(mh))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}}const vr=new F,gh=new F,zc=new F,Gr=new F,_h=new F,kc=new F,vh=new F;class Oo{constructor(e=new F,t=new F(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.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,vr)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=vr.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(vr.copy(this.origin).addScaledVector(this.direction,t),vr.distanceToSquared(e))}distanceSqToSegment(e,t,n,r){gh.copy(e).add(t).multiplyScalar(.5),zc.copy(t).sub(e).normalize(),Gr.copy(this.origin).sub(gh);const o=e.distanceTo(t)*.5,a=-this.direction.dot(zc),l=Gr.dot(this.direction),u=-Gr.dot(zc),h=Gr.lengthSq(),d=Math.abs(1-a*a);let p,m,g,y;if(d>0)if(p=a*u-l,m=a*l-u,y=o*d,p>=0)if(m>=-y)if(m<=y){const S=1/d;p*=S,m*=S,g=p*(p+a*m+2*l)+m*(a*p+m+2*u)+h}else m=o,p=Math.max(0,-(a*m+l)),g=-p*p+m*(m+2*u)+h;else m=-o,p=Math.max(0,-(a*m+l)),g=-p*p+m*(m+2*u)+h;else m<=-y?(p=Math.max(0,-(-a*o+l)),m=p>0?-o:Math.min(Math.max(-o,-u),o),g=-p*p+m*(m+2*u)+h):m<=y?(p=0,m=Math.min(Math.max(-o,-u),o),g=m*(m+2*u)+h):(p=Math.max(0,-(a*o+l)),m=p>0?o:Math.min(Math.max(-o,-u),o),g=-p*p+m*(m+2*u)+h);else m=a>0?-o:o,p=Math.max(0,-(a*m+l)),g=-p*p+m*(m+2*u)+h;return n&&n.copy(this.origin).addScaledVector(this.direction,p),r&&r.copy(gh).addScaledVector(zc,m),g}intersectSphere(e,t){vr.subVectors(e.center,this.origin);const n=vr.dot(this.direction),r=vr.dot(vr)-n*n,o=e.radius*e.radius;if(r>o)return null;const a=Math.sqrt(o-r),l=n-a,u=n+a;return u<0?null:l<0?this.at(u,t):this.at(l,t)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;const n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){const n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,r,o,a,l,u;const h=1/this.direction.x,d=1/this.direction.y,p=1/this.direction.z,m=this.origin;return h>=0?(n=(e.min.x-m.x)*h,r=(e.max.x-m.x)*h):(n=(e.max.x-m.x)*h,r=(e.min.x-m.x)*h),d>=0?(o=(e.min.y-m.y)*d,a=(e.max.y-m.y)*d):(o=(e.max.y-m.y)*d,a=(e.min.y-m.y)*d),n>a||o>r||((o>n||isNaN(n))&&(n=o),(a<r||isNaN(r))&&(r=a),p>=0?(l=(e.min.z-m.z)*p,u=(e.max.z-m.z)*p):(l=(e.max.z-m.z)*p,u=(e.min.z-m.z)*p),n>u||l>r)||((l>n||n!==n)&&(n=l),(u<r||r!==r)&&(r=u),r<0)?null:this.at(n>=0?n:r,t)}intersectsBox(e){return this.intersectBox(e,vr)!==null}intersectTriangle(e,t,n,r,o){_h.subVectors(t,e),kc.subVectors(n,e),vh.crossVectors(_h,kc);let a=this.direction.dot(vh),l;if(a>0){if(r)return null;l=1}else if(a<0)l=-1,a=-a;else return null;Gr.subVectors(this.origin,e);const u=l*this.direction.dot(kc.crossVectors(Gr,kc));if(u<0)return null;const h=l*this.direction.dot(_h.cross(Gr));if(h<0||u+h>a)return null;const d=-l*Gr.dot(vh);return d<0?null:this.at(d/a,o)}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 Qe{constructor(e,t,n,r,o,a,l,u,h,d,p,m,g,y,S,_){Qe.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,n,r,o,a,l,u,h,d,p,m,g,y,S,_)}set(e,t,n,r,o,a,l,u,h,d,p,m,g,y,S,_){const v=this.elements;return v[0]=e,v[4]=t,v[8]=n,v[12]=r,v[1]=o,v[5]=a,v[9]=l,v[13]=u,v[2]=h,v[6]=d,v[10]=p,v[14]=m,v[3]=g,v[7]=y,v[11]=S,v[15]=_,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 Qe().fromArray(this.elements)}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){const t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[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,n){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){const t=this.elements,n=e.elements,r=1/eo.setFromMatrixColumn(e,0).length(),o=1/eo.setFromMatrixColumn(e,1).length(),a=1/eo.setFromMatrixColumn(e,2).length();return t[0]=n[0]*r,t[1]=n[1]*r,t[2]=n[2]*r,t[3]=0,t[4]=n[4]*o,t[5]=n[5]*o,t[6]=n[6]*o,t[7]=0,t[8]=n[8]*a,t[9]=n[9]*a,t[10]=n[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,n=e.x,r=e.y,o=e.z,a=Math.cos(n),l=Math.sin(n),u=Math.cos(r),h=Math.sin(r),d=Math.cos(o),p=Math.sin(o);if(e.order==="XYZ"){const m=a*d,g=a*p,y=l*d,S=l*p;t[0]=u*d,t[4]=-u*p,t[8]=h,t[1]=g+y*h,t[5]=m-S*h,t[9]=-l*u,t[2]=S-m*h,t[6]=y+g*h,t[10]=a*u}else if(e.order==="YXZ"){const m=u*d,g=u*p,y=h*d,S=h*p;t[0]=m+S*l,t[4]=y*l-g,t[8]=a*h,t[1]=a*p,t[5]=a*d,t[9]=-l,t[2]=g*l-y,t[6]=S+m*l,t[10]=a*u}else if(e.order==="ZXY"){const m=u*d,g=u*p,y=h*d,S=h*p;t[0]=m-S*l,t[4]=-a*p,t[8]=y+g*l,t[1]=g+y*l,t[5]=a*d,t[9]=S-m*l,t[2]=-a*h,t[6]=l,t[10]=a*u}else if(e.order==="ZYX"){const m=a*d,g=a*p,y=l*d,S=l*p;t[0]=u*d,t[4]=y*h-g,t[8]=m*h+S,t[1]=u*p,t[5]=S*h+m,t[9]=g*h-y,t[2]=-h,t[6]=l*u,t[10]=a*u}else if(e.order==="YZX"){const m=a*u,g=a*h,y=l*u,S=l*h;t[0]=u*d,t[4]=S-m*p,t[8]=y*p+g,t[1]=p,t[5]=a*d,t[9]=-l*d,t[2]=-h*d,t[6]=g*p+y,t[10]=m-S*p}else if(e.order==="XZY"){const m=a*u,g=a*h,y=l*u,S=l*h;t[0]=u*d,t[4]=-p,t[8]=h*d,t[1]=m*p+S,t[5]=a*d,t[9]=g*p-y,t[2]=y*p-g,t[6]=l*d,t[10]=S*p+m}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(Iw,e,Dw)}lookAt(e,t,n){const r=this.elements;return ii.subVectors(e,t),ii.lengthSq()===0&&(ii.z=1),ii.normalize(),Vr.crossVectors(n,ii),Vr.lengthSq()===0&&(Math.abs(n.z)===1?ii.x+=1e-4:ii.z+=1e-4,ii.normalize(),Vr.crossVectors(n,ii)),Vr.normalize(),Hc.crossVectors(ii,Vr),r[0]=Vr.x,r[4]=Hc.x,r[8]=ii.x,r[1]=Vr.y,r[5]=Hc.y,r[9]=ii.y,r[2]=Vr.z,r[6]=Hc.z,r[10]=ii.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,r=t.elements,o=this.elements,a=n[0],l=n[4],u=n[8],h=n[12],d=n[1],p=n[5],m=n[9],g=n[13],y=n[2],S=n[6],_=n[10],v=n[14],R=n[3],b=n[7],A=n[11],B=n[15],N=r[0],D=r[4],C=r[8],E=r[12],M=r[1],O=r[5],H=r[9],G=r[13],Y=r[2],$=r[6],re=r[10],se=r[14],K=r[3],ae=r[7],pe=r[11],ve=r[15];return o[0]=a*N+l*M+u*Y+h*K,o[4]=a*D+l*O+u*$+h*ae,o[8]=a*C+l*H+u*re+h*pe,o[12]=a*E+l*G+u*se+h*ve,o[1]=d*N+p*M+m*Y+g*K,o[5]=d*D+p*O+m*$+g*ae,o[9]=d*C+p*H+m*re+g*pe,o[13]=d*E+p*G+m*se+g*ve,o[2]=y*N+S*M+_*Y+v*K,o[6]=y*D+S*O+_*$+v*ae,o[10]=y*C+S*H+_*re+v*pe,o[14]=y*E+S*G+_*se+v*ve,o[3]=R*N+b*M+A*Y+B*K,o[7]=R*D+b*O+A*$+B*ae,o[11]=R*C+b*H+A*re+B*pe,o[15]=R*E+b*G+A*se+B*ve,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],n=e[4],r=e[8],o=e[12],a=e[1],l=e[5],u=e[9],h=e[13],d=e[2],p=e[6],m=e[10],g=e[14],y=e[3],S=e[7],_=e[11],v=e[15];return y*(+o*u*p-r*h*p-o*l*m+n*h*m+r*l*g-n*u*g)+S*(+t*u*g-t*h*m+o*a*m-r*a*g+r*h*d-o*u*d)+_*(+t*h*p-t*l*g-o*a*p+n*a*g+o*l*d-n*h*d)+v*(-r*l*d-t*u*p+t*l*m+r*a*p-n*a*m+n*u*d)}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,n){const r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=t,r[14]=n),this}invert(){const e=this.elements,t=e[0],n=e[1],r=e[2],o=e[3],a=e[4],l=e[5],u=e[6],h=e[7],d=e[8],p=e[9],m=e[10],g=e[11],y=e[12],S=e[13],_=e[14],v=e[15],R=p*_*h-S*m*h+S*u*g-l*_*g-p*u*v+l*m*v,b=y*m*h-d*_*h-y*u*g+a*_*g+d*u*v-a*m*v,A=d*S*h-y*p*h+y*l*g-a*S*g-d*l*v+a*p*v,B=y*p*u-d*S*u-y*l*m+a*S*m+d*l*_-a*p*_,N=t*R+n*b+r*A+o*B;if(N===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const D=1/N;return e[0]=R*D,e[1]=(S*m*o-p*_*o-S*r*g+n*_*g+p*r*v-n*m*v)*D,e[2]=(l*_*o-S*u*o+S*r*h-n*_*h-l*r*v+n*u*v)*D,e[3]=(p*u*o-l*m*o-p*r*h+n*m*h+l*r*g-n*u*g)*D,e[4]=b*D,e[5]=(d*_*o-y*m*o+y*r*g-t*_*g-d*r*v+t*m*v)*D,e[6]=(y*u*o-a*_*o-y*r*h+t*_*h+a*r*v-t*u*v)*D,e[7]=(a*m*o-d*u*o+d*r*h-t*m*h-a*r*g+t*u*g)*D,e[8]=A*D,e[9]=(y*p*o-d*S*o-y*n*g+t*S*g+d*n*v-t*p*v)*D,e[10]=(a*S*o-y*l*o+y*n*h-t*S*h-a*n*v+t*l*v)*D,e[11]=(d*l*o-a*p*o-d*n*h+t*p*h+a*n*g-t*l*g)*D,e[12]=B*D,e[13]=(d*S*r-y*p*r+y*n*m-t*S*m-d*n*_+t*p*_)*D,e[14]=(y*l*r-a*S*r-y*n*u+t*S*u+a*n*_-t*l*_)*D,e[15]=(a*p*r-d*l*r+d*n*u-t*p*u-a*n*m+t*l*m)*D,this}scale(e){const t=this.elements,n=e.x,r=e.y,o=e.z;return t[0]*=n,t[4]*=r,t[8]*=o,t[1]*=n,t[5]*=r,t[9]*=o,t[2]*=n,t[6]*=r,t[10]*=o,t[3]*=n,t[7]*=r,t[11]*=o,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,r))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const n=Math.cos(t),r=Math.sin(t),o=1-n,a=e.x,l=e.y,u=e.z,h=o*a,d=o*l;return this.set(h*a+n,h*l-r*u,h*u+r*l,0,h*l+r*u,d*l+n,d*u-r*a,0,h*u-r*l,d*u+r*a,o*u*u+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,r,o,a){return this.set(1,n,o,0,e,1,a,0,t,r,1,0,0,0,0,1),this}compose(e,t,n){const r=this.elements,o=t._x,a=t._y,l=t._z,u=t._w,h=o+o,d=a+a,p=l+l,m=o*h,g=o*d,y=o*p,S=a*d,_=a*p,v=l*p,R=u*h,b=u*d,A=u*p,B=n.x,N=n.y,D=n.z;return r[0]=(1-(S+v))*B,r[1]=(g+A)*B,r[2]=(y-b)*B,r[3]=0,r[4]=(g-A)*N,r[5]=(1-(m+v))*N,r[6]=(_+R)*N,r[7]=0,r[8]=(y+b)*D,r[9]=(_-R)*D,r[10]=(1-(m+S))*D,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,n){const r=this.elements;let o=eo.set(r[0],r[1],r[2]).length();const a=eo.set(r[4],r[5],r[6]).length(),l=eo.set(r[8],r[9],r[10]).length();this.determinant()<0&&(o=-o),e.x=r[12],e.y=r[13],e.z=r[14],Li.copy(this);const h=1/o,d=1/a,p=1/l;return Li.elements[0]*=h,Li.elements[1]*=h,Li.elements[2]*=h,Li.elements[4]*=d,Li.elements[5]*=d,Li.elements[6]*=d,Li.elements[8]*=p,Li.elements[9]*=p,Li.elements[10]*=p,t.setFromRotationMatrix(Li),n.x=o,n.y=a,n.z=l,this}makePerspective(e,t,n,r,o,a,l=br){const u=this.elements,h=2*o/(t-e),d=2*o/(n-r),p=(t+e)/(t-e),m=(n+r)/(n-r);let g,y;if(l===br)g=-(a+o)/(a-o),y=-2*a*o/(a-o);else if(l===Cl)g=-a/(a-o),y=-a*o/(a-o);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+l);return u[0]=h,u[4]=0,u[8]=p,u[12]=0,u[1]=0,u[5]=d,u[9]=m,u[13]=0,u[2]=0,u[6]=0,u[10]=g,u[14]=y,u[3]=0,u[7]=0,u[11]=-1,u[15]=0,this}makeOrthographic(e,t,n,r,o,a,l=br){const u=this.elements,h=1/(t-e),d=1/(n-r),p=1/(a-o),m=(t+e)*h,g=(n+r)*d;let y,S;if(l===br)y=(a+o)*p,S=-2*p;else if(l===Cl)y=o*p,S=-1*p;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+l);return u[0]=2*h,u[4]=0,u[8]=0,u[12]=-m,u[1]=0,u[5]=2*d,u[9]=0,u[13]=-g,u[2]=0,u[6]=0,u[10]=S,u[14]=-y,u[3]=0,u[7]=0,u[11]=0,u[15]=1,this}equals(e){const t=this.elements,n=e.elements;for(let r=0;r<16;r++)if(t[r]!==n[r])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}}const eo=new F,Li=new Qe,Iw=new F(0,0,0),Dw=new F(1,1,1),Vr=new F,Hc=new F,ii=new F,og=new Qe,ag=new an;class Bi{constructor(e=0,t=0,n=0,r=Bi.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=r}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,r=this._order){return this._x=e,this._y=t,this._z=n,this._order=r,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,n=!0){const r=e.elements,o=r[0],a=r[4],l=r[8],u=r[1],h=r[5],d=r[9],p=r[2],m=r[6],g=r[10];switch(t){case"XYZ":this._y=Math.asin(En(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-d,g),this._z=Math.atan2(-a,o)):(this._x=Math.atan2(m,h),this._z=0);break;case"YXZ":this._x=Math.asin(-En(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(l,g),this._z=Math.atan2(u,h)):(this._y=Math.atan2(-p,o),this._z=0);break;case"ZXY":this._x=Math.asin(En(m,-1,1)),Math.abs(m)<.9999999?(this._y=Math.atan2(-p,g),this._z=Math.atan2(-a,h)):(this._y=0,this._z=Math.atan2(u,o));break;case"ZYX":this._y=Math.asin(-En(p,-1,1)),Math.abs(p)<.9999999?(this._x=Math.atan2(m,g),this._z=Math.atan2(u,o)):(this._x=0,this._z=Math.atan2(-a,h));break;case"YZX":this._z=Math.asin(En(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(-d,h),this._y=Math.atan2(-p,o)):(this._x=0,this._y=Math.atan2(l,g));break;case"XZY":this._z=Math.asin(-En(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(m,h),this._y=Math.atan2(l,o)):(this._x=Math.atan2(-d,g),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return og.makeRotationFromQuaternion(e),this.setFromRotationMatrix(og,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return ag.setFromEuler(this),this.setFromQuaternion(ag,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}Bi.DEFAULT_ORDER="XYZ";class zf{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}}let Uw=0;const cg=new F,to=new an,xr=new Qe,Gc=new F,ua=new F,Nw=new F,Ow=new an,lg=new F(1,0,0),ug=new F(0,1,0),hg=new F(0,0,1),fg={type:"added"},Fw={type:"removed"},no={type:"childadded",child:null},xh={type:"childremoved",child:null};class gt extends Ps{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Uw++}),this.uuid=Fi(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=gt.DEFAULT_UP.clone();const e=new F,t=new Bi,n=new an,r=new F(1,1,1);function o(){n.setFromEuler(t,!1)}function a(){t.setFromQuaternion(n,void 0,!1)}t._onChange(o),n._onChange(a),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:r},modelViewMatrix:{value:new Qe},normalMatrix:{value:new ht}}),this.matrix=new Qe,this.matrixWorld=new Qe,this.matrixAutoUpdate=gt.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=gt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new zf,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={}}onBeforeShadow(){}onAfterShadow(){}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 to.setFromAxisAngle(e,t),this.quaternion.multiply(to),this}rotateOnWorldAxis(e,t){return to.setFromAxisAngle(e,t),this.quaternion.premultiply(to),this}rotateX(e){return this.rotateOnAxis(lg,e)}rotateY(e){return this.rotateOnAxis(ug,e)}rotateZ(e){return this.rotateOnAxis(hg,e)}translateOnAxis(e,t){return cg.copy(e).applyQuaternion(this.quaternion),this.position.add(cg.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(lg,e)}translateY(e){return this.translateOnAxis(ug,e)}translateZ(e){return this.translateOnAxis(hg,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(xr.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?Gc.copy(e):Gc.set(e,t,n);const r=this.parent;this.updateWorldMatrix(!0,!1),ua.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?xr.lookAt(ua,Gc,this.up):xr.lookAt(Gc,ua,this.up),this.quaternion.setFromRotationMatrix(xr),r&&(xr.extractRotation(r.matrixWorld),to.setFromRotationMatrix(xr),this.quaternion.premultiply(to.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(fg),no.child=e,this.dispatchEvent(no),no.child=null):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}const t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(Fw),xh.child=e,this.dispatchEvent(xh),xh.child=null),this}removeFromParent(){const e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),xr.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),xr.multiply(e.parent.matrixWorld)),e.applyMatrix4(xr),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(fg),no.child=e,this.dispatchEvent(no),no.child=null,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 n=0,r=this.children.length;n<r;n++){const a=this.children[n].getObjectByProperty(e,t);if(a!==void 0)return a}}getObjectsByProperty(e,t,n=[]){this[e]===t&&n.push(this);const r=this.children;for(let o=0,a=r.length;o<a;o++)r[o].getObjectsByProperty(e,t,n);return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(ua,e,Nw),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(ua,Ow,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 n=0,r=t.length;n<r;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].traverseVisible(e)}traverseAncestors(e){const t=this.parent;t!==null&&(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)&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1,e=!0);const t=this.children;for(let n=0,r=t.length;n<r;n++){const o=t[n];(o.matrixWorldAutoUpdate===!0||e===!0)&&o.updateMatrixWorld(e)}}updateWorldMatrix(e,t){const n=this.parent;if(e===!0&&n!==null&&n.matrixWorldAutoUpdate===!0&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),t===!0){const r=this.children;for(let o=0,a=r.length;o<a;o++){const l=r[o];l.matrixWorldAutoUpdate===!0&&l.updateWorldMatrix(!1,!0)}}}toJSON(e){const t=e===void 0||typeof e=="string",n={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.6,type:"Object",generator:"Object3D.toJSON"});const r={};r.uuid=this.uuid,r.type=this.type,this.name!==""&&(r.name=this.name),this.castShadow===!0&&(r.castShadow=!0),this.receiveShadow===!0&&(r.receiveShadow=!0),this.visible===!1&&(r.visible=!1),this.frustumCulled===!1&&(r.frustumCulled=!1),this.renderOrder!==0&&(r.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),r.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(r.matrixAutoUpdate=!1),this.isInstancedMesh&&(r.type="InstancedMesh",r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(r.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(r.type="BatchedMesh",r.perObjectFrustumCulled=this.perObjectFrustumCulled,r.sortObjects=this.sortObjects,r.drawRanges=this._drawRanges,r.reservedRanges=this._reservedRanges,r.visibility=this._visibility,r.active=this._active,r.bounds=this._bounds.map(l=>({boxInitialized:l.boxInitialized,boxMin:l.box.min.toArray(),boxMax:l.box.max.toArray(),sphereInitialized:l.sphereInitialized,sphereRadius:l.sphere.radius,sphereCenter:l.sphere.center.toArray()})),r.maxGeometryCount=this._maxGeometryCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.geometryCount=this._geometryCount,r.matricesTexture=this._matricesTexture.toJSON(e),this.boundingSphere!==null&&(r.boundingSphere={center:r.boundingSphere.center.toArray(),radius:r.boundingSphere.radius}),this.boundingBox!==null&&(r.boundingBox={min:r.boundingBox.min.toArray(),max:r.boundingBox.max.toArray()}));function o(l,u){return l[u.uuid]===void 0&&(l[u.uuid]=u.toJSON(e)),u.uuid}if(this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=o(e.geometries,this.geometry);const l=this.geometry.parameters;if(l!==void 0&&l.shapes!==void 0){const u=l.shapes;if(Array.isArray(u))for(let h=0,d=u.length;h<d;h++){const p=u[h];o(e.shapes,p)}else o(e.shapes,u)}}if(this.isSkinnedMesh&&(r.bindMode=this.bindMode,r.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(o(e.skeletons,this.skeleton),r.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const l=[];for(let u=0,h=this.material.length;u<h;u++)l.push(o(e.materials,this.material[u]));r.material=l}else r.material=o(e.materials,this.material);if(this.children.length>0){r.children=[];for(let l=0;l<this.children.length;l++)r.children.push(this.children[l].toJSON(e).object)}if(this.animations.length>0){r.animations=[];for(let l=0;l<this.animations.length;l++){const u=this.animations[l];r.animations.push(o(e.animations,u))}}if(t){const l=a(e.geometries),u=a(e.materials),h=a(e.textures),d=a(e.images),p=a(e.shapes),m=a(e.skeletons),g=a(e.animations),y=a(e.nodes);l.length>0&&(n.geometries=l),u.length>0&&(n.materials=u),h.length>0&&(n.textures=h),d.length>0&&(n.images=d),p.length>0&&(n.shapes=p),m.length>0&&(n.skeletons=m),g.length>0&&(n.animations=g),y.length>0&&(n.nodes=y)}return n.object=r,n;function a(l){const u=[];for(const h in l){const d=l[h];delete d.metadata,u.push(d)}return u}}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.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,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.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;n<e.children.length;n++){const r=e.children[n];this.add(r.clone())}return this}}gt.DEFAULT_UP=new F(0,1,0);gt.DEFAULT_MATRIX_AUTO_UPDATE=!0;gt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const Ii=new F,yr=new F,yh=new F,Mr=new F,io=new F,ro=new F,dg=new F,Mh=new F,Sh=new F,Eh=new F;class Oi{constructor(e=new F,t=new F,n=new F){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,r){r.subVectors(n,t),Ii.subVectors(e,t),r.cross(Ii);const o=r.lengthSq();return o>0?r.multiplyScalar(1/Math.sqrt(o)):r.set(0,0,0)}static getBarycoord(e,t,n,r,o){Ii.subVectors(r,t),yr.subVectors(n,t),yh.subVectors(e,t);const a=Ii.dot(Ii),l=Ii.dot(yr),u=Ii.dot(yh),h=yr.dot(yr),d=yr.dot(yh),p=a*h-l*l;if(p===0)return o.set(0,0,0),null;const m=1/p,g=(h*u-l*d)*m,y=(a*d-l*u)*m;return o.set(1-g-y,y,g)}static containsPoint(e,t,n,r){return this.getBarycoord(e,t,n,r,Mr)===null?!1:Mr.x>=0&&Mr.y>=0&&Mr.x+Mr.y<=1}static getInterpolation(e,t,n,r,o,a,l,u){return this.getBarycoord(e,t,n,r,Mr)===null?(u.x=0,u.y=0,"z"in u&&(u.z=0),"w"in u&&(u.w=0),null):(u.setScalar(0),u.addScaledVector(o,Mr.x),u.addScaledVector(a,Mr.y),u.addScaledVector(l,Mr.z),u)}static isFrontFacing(e,t,n,r){return Ii.subVectors(n,t),yr.subVectors(e,t),Ii.cross(yr).dot(r)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,r){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,t,n,r){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,r),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return Ii.subVectors(this.c,this.b),yr.subVectors(this.a,this.b),Ii.cross(yr).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Oi.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return Oi.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,r,o){return Oi.getInterpolation(e,this.a,this.b,this.c,t,n,r,o)}containsPoint(e){return Oi.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Oi.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const n=this.a,r=this.b,o=this.c;let a,l;io.subVectors(r,n),ro.subVectors(o,n),Mh.subVectors(e,n);const u=io.dot(Mh),h=ro.dot(Mh);if(u<=0&&h<=0)return t.copy(n);Sh.subVectors(e,r);const d=io.dot(Sh),p=ro.dot(Sh);if(d>=0&&p<=d)return t.copy(r);const m=u*p-d*h;if(m<=0&&u>=0&&d<=0)return a=u/(u-d),t.copy(n).addScaledVector(io,a);Eh.subVectors(e,o);const g=io.dot(Eh),y=ro.dot(Eh);if(y>=0&&g<=y)return t.copy(o);const S=g*h-u*y;if(S<=0&&h>=0&&y<=0)return l=h/(h-y),t.copy(n).addScaledVector(ro,l);const _=d*y-g*p;if(_<=0&&p-d>=0&&g-y>=0)return dg.subVectors(o,r),l=(p-d)/(p-d+(g-y)),t.copy(r).addScaledVector(dg,l);const v=1/(_+S+m);return a=S*v,l=m*v,t.copy(n).addScaledVector(io,a).addScaledVector(ro,l)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const f0={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},Wr={h:0,s:0,l:0},Vc={h:0,s:0,l:0};function Th(i,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?i+(e-i)*6*t:t<1/2?e:t<2/3?i+(e-i)*6*(2/3-t):i}class Oe{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){const r=e;r&&r.isColor?this.copy(r):typeof r=="number"?this.setHex(r):typeof r=="string"&&this.setStyle(r)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=on){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Lt.toWorkingColorSpace(this,t),this}setRGB(e,t,n,r=Lt.workingColorSpace){return this.r=e,this.g=t,this.b=n,Lt.toWorkingColorSpace(this,r),this}setHSL(e,t,n,r=Lt.workingColorSpace){if(e=Ff(e,1),t=En(t,0,1),n=En(n,0,1),t===0)this.r=this.g=this.b=n;else{const o=n<=.5?n*(1+t):n+t-n*t,a=2*n-o;this.r=Th(a,o,e+1/3),this.g=Th(a,o,e),this.b=Th(a,o,e-1/3)}return Lt.toWorkingColorSpace(this,r),this}setStyle(e,t=on){function n(o){o!==void 0&&parseFloat(o)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let o;const a=r[1],l=r[2];switch(a){case"rgb":case"rgba":if(o=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(l))return n(o[4]),this.setRGB(Math.min(255,parseInt(o[1],10))/255,Math.min(255,parseInt(o[2],10))/255,Math.min(255,parseInt(o[3],10))/255,t);if(o=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(l))return n(o[4]),this.setRGB(Math.min(100,parseInt(o[1],10))/100,Math.min(100,parseInt(o[2],10))/100,Math.min(100,parseInt(o[3],10))/100,t);break;case"hsl":case"hsla":if(o=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(l))return n(o[4]),this.setHSL(parseFloat(o[1])/360,parseFloat(o[2])/100,parseFloat(o[3])/100,t);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){const o=r[1],a=o.length;if(a===3)return this.setRGB(parseInt(o.charAt(0),16)/15,parseInt(o.charAt(1),16)/15,parseInt(o.charAt(2),16)/15,t);if(a===6)return this.setHex(parseInt(o,16),t);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=on){const n=f0[e.toLowerCase()];return n!==void 0?this.setHex(n,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}copySRGBToLinear(e){return this.r=bo(e.r),this.g=bo(e.g),this.b=bo(e.b),this}copyLinearToSRGB(e){return this.r=hh(e.r),this.g=hh(e.g),this.b=hh(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=on){return Lt.fromWorkingColorSpace(Pn.copy(this),e),Math.round(En(Pn.r*255,0,255))*65536+Math.round(En(Pn.g*255,0,255))*256+Math.round(En(Pn.b*255,0,255))}getHexString(e=on){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Lt.workingColorSpace){Lt.fromWorkingColorSpace(Pn.copy(this),t);const n=Pn.r,r=Pn.g,o=Pn.b,a=Math.max(n,r,o),l=Math.min(n,r,o);let u,h;const d=(l+a)/2;if(l===a)u=0,h=0;else{const p=a-l;switch(h=d<=.5?p/(a+l):p/(2-a-l),a){case n:u=(r-o)/p+(r<o?6:0);break;case r:u=(o-n)/p+2;break;case o:u=(n-r)/p+4;break}u/=6}return e.h=u,e.s=h,e.l=d,e}getRGB(e,t=Lt.workingColorSpace){return Lt.fromWorkingColorSpace(Pn.copy(this),t),e.r=Pn.r,e.g=Pn.g,e.b=Pn.b,e}getStyle(e=on){Lt.fromWorkingColorSpace(Pn.copy(this),e);const t=Pn.r,n=Pn.g,r=Pn.b;return e!==on?`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${r.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(r*255)})`}offsetHSL(e,t,n){return this.getHSL(Wr),this.setHSL(Wr.h+e,Wr.s+t,Wr.l+n)}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,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(Wr),e.getHSL(Vc);const n=Na(Wr.h,Vc.h,t),r=Na(Wr.s,Vc.s,t),o=Na(Wr.l,Vc.l,t);return this.setHSL(n,r,o),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const t=this.r,n=this.g,r=this.b,o=e.elements;return this.r=o[0]*t+o[3]*n+o[6]*r,this.g=o[1]*t+o[4]*n+o[7]*r,this.b=o[2]*t+o[5]*n+o[8]*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),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const Pn=new Oe;Oe.NAMES=f0;let Bw=0;class Ti extends Ps{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Bw++}),this.uuid=Fi(),this.name="",this.type="Material",this.blending=Eo,this.side=tr,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=sf,this.blendDst=of,this.blendEquation=Ts,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Oe(0,0,0),this.blendAlpha=0,this.depthFunc=Tl,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=Qm,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=$s,this.stencilZFail=$s,this.stencilZPass=$s,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.forceSinglePass=!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(e!==void 0)for(const t in e){const n=e[t];if(n===void 0){console.warn(`THREE.Material: parameter '${t}' has value of undefined.`);continue}const r=this[t];if(r===void 0){console.warn(`THREE.Material: '${t}' is not a property of THREE.${this.type}.`);continue}r&&r.isColor?r.set(n):r&&r.isVector3&&n&&n.isVector3?r.copy(n):this[t]=n}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const n={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==Eo&&(n.blending=this.blending),this.side!==tr&&(n.side=this.side),this.vertexColors===!0&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=!0),this.blendSrc!==sf&&(n.blendSrc=this.blendSrc),this.blendDst!==of&&(n.blendDst=this.blendDst),this.blendEquation!==Ts&&(n.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(n.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(n.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==Tl&&(n.depthFunc=this.depthFunc),this.depthTest===!1&&(n.depthTest=this.depthTest),this.depthWrite===!1&&(n.depthWrite=this.depthWrite),this.colorWrite===!1&&(n.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==Qm&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==$s&&(n.stencilFail=this.stencilFail),this.stencilZFail!==$s&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==$s&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function r(o){const a=[];for(const l in o){const u=o[l];delete u.metadata,a.push(u)}return a}if(t){const o=r(e.textures),a=r(e.images);o.length>0&&(n.textures=o),a.length>0&&(n.images=a)}return n}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,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 n=null;if(t!==null){const r=t.length;n=new Array(r);for(let o=0;o!==r;++o)n[o]=t[o].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,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){e===!0&&this.version++}}class Ji extends Ti{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Oe(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.envMapRotation=new Bi,this.combine=$_,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,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.envMapRotation.copy(e.envMapRotation),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.fog=e.fog,this}}const un=new F,Wc=new Pe;class Nt{constructor(e,t,n=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=uf,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.gpuType=Zi,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}get updateRange(){return u0("THREE.BufferAttribute: updateRange() is deprecated and will be removed in r169. Use addUpdateRange() instead."),this._updateRange}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}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.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let r=0,o=this.itemSize;r<o;r++)this.array[e+r]=t.array[n+r];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,n=this.count;t<n;t++)Wc.fromBufferAttribute(this,t),Wc.applyMatrix3(e),this.setXY(t,Wc.x,Wc.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)un.fromBufferAttribute(this,t),un.applyMatrix3(e),this.setXYZ(t,un.x,un.y,un.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)un.fromBufferAttribute(this,t),un.applyMatrix4(e),this.setXYZ(t,un.x,un.y,un.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)un.fromBufferAttribute(this,t),un.applyNormalMatrix(e),this.setXYZ(t,un.x,un.y,un.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)un.fromBufferAttribute(this,t),un.transformDirection(e),this.setXYZ(t,un.x,un.y,un.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let n=this.array[e*this.itemSize+t];return this.normalized&&(n=Ni(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=Dt(n,this.array)),this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=Ni(t,this.array)),t}setX(e,t){return this.normalized&&(t=Dt(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=Ni(t,this.array)),t}setY(e,t){return this.normalized&&(t=Dt(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=Ni(t,this.array)),t}setZ(e,t){return this.normalized&&(t=Dt(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=Ni(t,this.array)),t}setW(e,t){return this.normalized&&(t=Dt(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=Dt(t,this.array),n=Dt(n,this.array)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,r){return e*=this.itemSize,this.normalized&&(t=Dt(t,this.array),n=Dt(n,this.array),r=Dt(r,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this}setXYZW(e,t,n,r,o){return e*=this.itemSize,this.normalized&&(t=Dt(t,this.array),n=Dt(n,this.array),r=Dt(r,this.array),o=Dt(o,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this.array[e+3]=o,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.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==uf&&(e.usage=this.usage),e}}class d0 extends Nt{constructor(e,t,n){super(new Uint16Array(e),t,n)}}class p0 extends Nt{constructor(e,t,n){super(new Uint32Array(e),t,n)}}class Bt extends Nt{constructor(e,t,n){super(new Float32Array(e),t,n)}}let zw=0;const xi=new Qe,bh=new gt,so=new F,ri=new zi,ha=new zi,_n=new F;class tn extends Ps{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:zw++}),this.uuid=Fi(),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(l0(e)?p0:d0)(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 this.attributes[e]!==void 0}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){const t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);const n=this.attributes.normal;if(n!==void 0){const o=new ht().getNormalMatrix(e);n.applyNormalMatrix(o),n.needsUpdate=!0}const r=this.attributes.tangent;return r!==void 0&&(r.transformDirection(e),r.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return xi.makeRotationFromQuaternion(e),this.applyMatrix4(xi),this}rotateX(e){return xi.makeRotationX(e),this.applyMatrix4(xi),this}rotateY(e){return xi.makeRotationY(e),this.applyMatrix4(xi),this}rotateZ(e){return xi.makeRotationZ(e),this.applyMatrix4(xi),this}translate(e,t,n){return xi.makeTranslation(e,t,n),this.applyMatrix4(xi),this}scale(e,t,n){return xi.makeScale(e,t,n),this.applyMatrix4(xi),this}lookAt(e){return bh.lookAt(e),bh.updateMatrix(),this.applyMatrix4(bh.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(so).negate(),this.translate(so.x,so.y,so.z),this}setFromPoints(e){const t=[];for(let n=0,r=e.length;n<r;n++){const o=e[n];t.push(o.x,o.y,o.z||0)}return this.setAttribute("position",new Bt(t,3)),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new zi);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new F(-1/0,-1/0,-1/0),new F(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,r=t.length;n<r;n++){const o=t[n];ri.setFromBufferAttribute(o),this.morphTargetsRelative?(_n.addVectors(this.boundingBox.min,ri.min),this.boundingBox.expandByPoint(_n),_n.addVectors(this.boundingBox.max,ri.max),this.boundingBox.expandByPoint(_n)):(this.boundingBox.expandByPoint(ri.min),this.boundingBox.expandByPoint(ri.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(){this.boundingSphere===null&&(this.boundingSphere=new rr);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new F,1/0);return}if(e){const n=this.boundingSphere.center;if(ri.setFromBufferAttribute(e),t)for(let o=0,a=t.length;o<a;o++){const l=t[o];ha.setFromBufferAttribute(l),this.morphTargetsRelative?(_n.addVectors(ri.min,ha.min),ri.expandByPoint(_n),_n.addVectors(ri.max,ha.max),ri.expandByPoint(_n)):(ri.expandByPoint(ha.min),ri.expandByPoint(ha.max))}ri.getCenter(n);let r=0;for(let o=0,a=e.count;o<a;o++)_n.fromBufferAttribute(e,o),r=Math.max(r,n.distanceToSquared(_n));if(t)for(let o=0,a=t.length;o<a;o++){const l=t[o],u=this.morphTargetsRelative;for(let h=0,d=l.count;h<d;h++)_n.fromBufferAttribute(l,h),u&&(so.fromBufferAttribute(e,h),_n.add(so)),r=Math.max(r,n.distanceToSquared(_n))}this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const n=t.position,r=t.normal,o=t.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new Nt(new Float32Array(4*n.count),4));const a=this.getAttribute("tangent"),l=[],u=[];for(let C=0;C<n.count;C++)l[C]=new F,u[C]=new F;const h=new F,d=new F,p=new F,m=new Pe,g=new Pe,y=new Pe,S=new F,_=new F;function v(C,E,M){h.fromBufferAttribute(n,C),d.fromBufferAttribute(n,E),p.fromBufferAttribute(n,M),m.fromBufferAttribute(o,C),g.fromBufferAttribute(o,E),y.fromBufferAttribute(o,M),d.sub(h),p.sub(h),g.sub(m),y.sub(m);const O=1/(g.x*y.y-y.x*g.y);isFinite(O)&&(S.copy(d).multiplyScalar(y.y).addScaledVector(p,-g.y).multiplyScalar(O),_.copy(p).multiplyScalar(g.x).addScaledVector(d,-y.x).multiplyScalar(O),l[C].add(S),l[E].add(S),l[M].add(S),u[C].add(_),u[E].add(_),u[M].add(_))}let R=this.groups;R.length===0&&(R=[{start:0,count:e.count}]);for(let C=0,E=R.length;C<E;++C){const M=R[C],O=M.start,H=M.count;for(let G=O,Y=O+H;G<Y;G+=3)v(e.getX(G+0),e.getX(G+1),e.getX(G+2))}const b=new F,A=new F,B=new F,N=new F;function D(C){B.fromBufferAttribute(r,C),N.copy(B);const E=l[C];b.copy(E),b.sub(B.multiplyScalar(B.dot(E))).normalize(),A.crossVectors(N,E);const O=A.dot(u[C])<0?-1:1;a.setXYZW(C,b.x,b.y,b.z,O)}for(let C=0,E=R.length;C<E;++C){const M=R[C],O=M.start,H=M.count;for(let G=O,Y=O+H;G<Y;G+=3)D(e.getX(G+0)),D(e.getX(G+1)),D(e.getX(G+2))}}computeVertexNormals(){const e=this.index,t=this.getAttribute("position");if(t!==void 0){let n=this.getAttribute("normal");if(n===void 0)n=new Nt(new Float32Array(t.count*3),3),this.setAttribute("normal",n);else for(let m=0,g=n.count;m<g;m++)n.setXYZ(m,0,0,0);const r=new F,o=new F,a=new F,l=new F,u=new F,h=new F,d=new F,p=new F;if(e)for(let m=0,g=e.count;m<g;m+=3){const y=e.getX(m+0),S=e.getX(m+1),_=e.getX(m+2);r.fromBufferAttribute(t,y),o.fromBufferAttribute(t,S),a.fromBufferAttribute(t,_),d.subVectors(a,o),p.subVectors(r,o),d.cross(p),l.fromBufferAttribute(n,y),u.fromBufferAttribute(n,S),h.fromBufferAttribute(n,_),l.add(d),u.add(d),h.add(d),n.setXYZ(y,l.x,l.y,l.z),n.setXYZ(S,u.x,u.y,u.z),n.setXYZ(_,h.x,h.y,h.z)}else for(let m=0,g=t.count;m<g;m+=3)r.fromBufferAttribute(t,m+0),o.fromBufferAttribute(t,m+1),a.fromBufferAttribute(t,m+2),d.subVectors(a,o),p.subVectors(r,o),d.cross(p),n.setXYZ(m+0,d.x,d.y,d.z),n.setXYZ(m+1,d.x,d.y,d.z),n.setXYZ(m+2,d.x,d.y,d.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)_n.fromBufferAttribute(e,t),_n.normalize(),e.setXYZ(t,_n.x,_n.y,_n.z)}toNonIndexed(){function e(l,u){const h=l.array,d=l.itemSize,p=l.normalized,m=new h.constructor(u.length*d);let g=0,y=0;for(let S=0,_=u.length;S<_;S++){l.isInterleavedBufferAttribute?g=u[S]*l.data.stride+l.offset:g=u[S]*d;for(let v=0;v<d;v++)m[y++]=h[g++]}return new Nt(m,d,p)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new tn,n=this.index.array,r=this.attributes;for(const l in r){const u=r[l],h=e(u,n);t.setAttribute(l,h)}const o=this.morphAttributes;for(const l in o){const u=[],h=o[l];for(let d=0,p=h.length;d<p;d++){const m=h[d],g=e(m,n);u.push(g)}t.morphAttributes[l]=u}t.morphTargetsRelative=this.morphTargetsRelative;const a=this.groups;for(let l=0,u=a.length;l<u;l++){const h=a[l];t.addGroup(h.start,h.count,h.materialIndex)}return t}toJSON(){const e={metadata:{version:4.6,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){const u=this.parameters;for(const h in u)u[h]!==void 0&&(e[h]=u[h]);return e}e.data={attributes:{}};const t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const n=this.attributes;for(const u in n){const h=n[u];e.data.attributes[u]=h.toJSON(e.data)}const r={};let o=!1;for(const u in this.morphAttributes){const h=this.morphAttributes[u],d=[];for(let p=0,m=h.length;p<m;p++){const g=h[p];d.push(g.toJSON(e.data))}d.length>0&&(r[u]=d,o=!0)}o&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));const l=this.boundingSphere;return l!==null&&(e.data.boundingSphere={center:l.center.toArray(),radius:l.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 n=e.index;n!==null&&this.setIndex(n.clone(t));const r=e.attributes;for(const h in r){const d=r[h];this.setAttribute(h,d.clone(t))}const o=e.morphAttributes;for(const h in o){const d=[],p=o[h];for(let m=0,g=p.length;m<g;m++)d.push(p[m].clone(t));this.morphAttributes[h]=d}this.morphTargetsRelative=e.morphTargetsRelative;const a=e.groups;for(let h=0,d=a.length;h<d;h++){const p=a[h];this.addGroup(p.start,p.count,p.materialIndex)}const l=e.boundingBox;l!==null&&(this.boundingBox=l.clone());const u=e.boundingSphere;return u!==null&&(this.boundingSphere=u.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const pg=new Qe,ms=new Oo,Xc=new rr,mg=new F,oo=new F,ao=new F,co=new F,wh=new F,Yc=new F,jc=new Pe,qc=new Pe,$c=new Pe,gg=new F,_g=new F,vg=new F,Kc=new F,Zc=new F;class Se extends gt{constructor(e=new tn,t=new Ji){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const r=t[n[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let o=0,a=r.length;o<a;o++){const l=r[o].name||String(o);this.morphTargetInfluences.push(0),this.morphTargetDictionary[l]=o}}}}getVertexPosition(e,t){const n=this.geometry,r=n.attributes.position,o=n.morphAttributes.position,a=n.morphTargetsRelative;t.fromBufferAttribute(r,e);const l=this.morphTargetInfluences;if(o&&l){Yc.set(0,0,0);for(let u=0,h=o.length;u<h;u++){const d=l[u],p=o[u];d!==0&&(wh.fromBufferAttribute(p,e),a?Yc.addScaledVector(wh,d):Yc.addScaledVector(wh.sub(t),d))}t.add(Yc)}return t}raycast(e,t){const n=this.geometry,r=this.material,o=this.matrixWorld;r!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),Xc.copy(n.boundingSphere),Xc.applyMatrix4(o),ms.copy(e.ray).recast(e.near),!(Xc.containsPoint(ms.origin)===!1&&(ms.intersectSphere(Xc,mg)===null||ms.origin.distanceToSquared(mg)>(e.far-e.near)**2))&&(pg.copy(o).invert(),ms.copy(e.ray).applyMatrix4(pg),!(n.boundingBox!==null&&ms.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,ms)))}_computeIntersections(e,t,n){let r;const o=this.geometry,a=this.material,l=o.index,u=o.attributes.position,h=o.attributes.uv,d=o.attributes.uv1,p=o.attributes.normal,m=o.groups,g=o.drawRange;if(l!==null)if(Array.isArray(a))for(let y=0,S=m.length;y<S;y++){const _=m[y],v=a[_.materialIndex],R=Math.max(_.start,g.start),b=Math.min(l.count,Math.min(_.start+_.count,g.start+g.count));for(let A=R,B=b;A<B;A+=3){const N=l.getX(A),D=l.getX(A+1),C=l.getX(A+2);r=Jc(this,v,e,n,h,d,p,N,D,C),r&&(r.faceIndex=Math.floor(A/3),r.face.materialIndex=_.materialIndex,t.push(r))}}else{const y=Math.max(0,g.start),S=Math.min(l.count,g.start+g.count);for(let _=y,v=S;_<v;_+=3){const R=l.getX(_),b=l.getX(_+1),A=l.getX(_+2);r=Jc(this,a,e,n,h,d,p,R,b,A),r&&(r.faceIndex=Math.floor(_/3),t.push(r))}}else if(u!==void 0)if(Array.isArray(a))for(let y=0,S=m.length;y<S;y++){const _=m[y],v=a[_.materialIndex],R=Math.max(_.start,g.start),b=Math.min(u.count,Math.min(_.start+_.count,g.start+g.count));for(let A=R,B=b;A<B;A+=3){const N=A,D=A+1,C=A+2;r=Jc(this,v,e,n,h,d,p,N,D,C),r&&(r.faceIndex=Math.floor(A/3),r.face.materialIndex=_.materialIndex,t.push(r))}}else{const y=Math.max(0,g.start),S=Math.min(u.count,g.start+g.count);for(let _=y,v=S;_<v;_+=3){const R=_,b=_+1,A=_+2;r=Jc(this,a,e,n,h,d,p,R,b,A),r&&(r.faceIndex=Math.floor(_/3),t.push(r))}}}}function kw(i,e,t,n,r,o,a,l){let u;if(e.side===Kn?u=n.intersectTriangle(a,o,r,!0,l):u=n.intersectTriangle(r,o,a,e.side===tr,l),u===null)return null;Zc.copy(l),Zc.applyMatrix4(i.matrixWorld);const h=t.ray.origin.distanceTo(Zc);return h<t.near||h>t.far?null:{distance:h,point:Zc.clone(),object:i}}function Jc(i,e,t,n,r,o,a,l,u,h){i.getVertexPosition(l,oo),i.getVertexPosition(u,ao),i.getVertexPosition(h,co);const d=kw(i,e,t,n,oo,ao,co,Kc);if(d){r&&(jc.fromBufferAttribute(r,l),qc.fromBufferAttribute(r,u),$c.fromBufferAttribute(r,h),d.uv=Oi.getInterpolation(Kc,oo,ao,co,jc,qc,$c,new Pe)),o&&(jc.fromBufferAttribute(o,l),qc.fromBufferAttribute(o,u),$c.fromBufferAttribute(o,h),d.uv1=Oi.getInterpolation(Kc,oo,ao,co,jc,qc,$c,new Pe)),a&&(gg.fromBufferAttribute(a,l),_g.fromBufferAttribute(a,u),vg.fromBufferAttribute(a,h),d.normal=Oi.getInterpolation(Kc,oo,ao,co,gg,_g,vg,new F),d.normal.dot(n.direction)>0&&d.normal.multiplyScalar(-1));const p={a:l,b:u,c:h,normal:new F,materialIndex:0};Oi.getNormal(oo,ao,co,p.normal),d.face=p}return d}class Kt extends tn{constructor(e=1,t=1,n=1,r=1,o=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:r,heightSegments:o,depthSegments:a};const l=this;r=Math.floor(r),o=Math.floor(o),a=Math.floor(a);const u=[],h=[],d=[],p=[];let m=0,g=0;y("z","y","x",-1,-1,n,t,e,a,o,0),y("z","y","x",1,-1,n,t,-e,a,o,1),y("x","z","y",1,1,e,n,t,r,a,2),y("x","z","y",1,-1,e,n,-t,r,a,3),y("x","y","z",1,-1,e,t,n,r,o,4),y("x","y","z",-1,-1,e,t,-n,r,o,5),this.setIndex(u),this.setAttribute("position",new Bt(h,3)),this.setAttribute("normal",new Bt(d,3)),this.setAttribute("uv",new Bt(p,2));function y(S,_,v,R,b,A,B,N,D,C,E){const M=A/D,O=B/C,H=A/2,G=B/2,Y=N/2,$=D+1,re=C+1;let se=0,K=0;const ae=new F;for(let pe=0;pe<re;pe++){const ve=pe*O-G;for(let ke=0;ke<$;ke++){const Ze=ke*M-H;ae[S]=Ze*R,ae[_]=ve*b,ae[v]=Y,h.push(ae.x,ae.y,ae.z),ae[S]=0,ae[_]=0,ae[v]=N>0?1:-1,d.push(ae.x,ae.y,ae.z),p.push(ke/D),p.push(1-pe/C),se+=1}}for(let pe=0;pe<C;pe++)for(let ve=0;ve<D;ve++){const ke=m+ve+$*pe,Ze=m+ve+$*(pe+1),te=m+(ve+1)+$*(pe+1),fe=m+(ve+1)+$*pe;u.push(ke,Ze,fe),u.push(Ze,te,fe),K+=6}l.addGroup(g,K,E),g+=K,m+=se}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Kt(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function Do(i){const e={};for(const t in i){e[t]={};for(const n in i[t]){const r=i[t][n];r&&(r.isColor||r.isMatrix3||r.isMatrix4||r.isVector2||r.isVector3||r.isVector4||r.isTexture||r.isQuaternion)?r.isRenderTargetTexture?(console.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[t][n]=null):e[t][n]=r.clone():Array.isArray(r)?e[t][n]=r.slice():e[t][n]=r}}return e}function Vn(i){const e={};for(let t=0;t<i.length;t++){const n=Do(i[t]);for(const r in n)e[r]=n[r]}return e}function Hw(i){const e=[];for(let t=0;t<i.length;t++)e.push(i[t].clone());return e}function m0(i){const e=i.getRenderTarget();return e===null?i.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:Lt.workingColorSpace}const Gw={clone:Do,merge:Vn};var Vw=`void main() {
6
6
  gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
7
7
  }`,Ww=`void main() {
8
8
  gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
@@ -41,7 +41,7 @@
41
41
  gl_FragColor = texture2D( tEquirect, sampleUV );
42
42
 
43
43
  }
44
- `},r=new Kt(5,5,5),o=new Rr({name:"CubemapFromEquirect",uniforms:Do(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:Kn,blending:Jr});o.uniforms.tEquirect.value=t;const a=new Se(r,o),l=t.minFilter;return t.minFilter===Ki&&(t.minFilter=Xn),new Xw(1,10,this).update(e,a),t.minFilter=l,a.geometry.dispose(),a.material.dispose(),this}clear(e,t,n,r){const o=e.getRenderTarget();for(let a=0;a<6;a++)e.setRenderTarget(this,a),e.clear(t,n,r);e.setRenderTarget(o)}}const wh=new F,Yw=new F,jw=new ht;class $r{constructor(e=new F(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,r){return this.normal.set(e,t,n),this.constant=r,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){const r=wh.subVectors(n,t).cross(Yw.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(r,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(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t){const n=e.delta(wh),r=this.normal.dot(n);if(r===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const o=-(e.start.dot(this.normal)+this.constant)/r;return o<0||o>1?null:t.copy(e.start).addScaledVector(n,o)}intersectsLine(e){const t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const n=t||jw.getNormalMatrix(e),r=this.coplanarPoint(wh).applyMatrix4(e),o=this.normal.applyMatrix3(n).normalize();return this.constant=-r.dot(o),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)}}const gs=new rr,Qc=new F;class zf{constructor(e=new $r,t=new $r,n=new $r,r=new $r,o=new $r,a=new $r){this.planes=[e,t,n,r,o,a]}set(e,t,n,r,o,a){const l=this.planes;return l[0].copy(e),l[1].copy(t),l[2].copy(n),l[3].copy(r),l[4].copy(o),l[5].copy(a),this}copy(e){const t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=br){const n=this.planes,r=e.elements,o=r[0],a=r[1],l=r[2],u=r[3],h=r[4],d=r[5],p=r[6],m=r[7],g=r[8],y=r[9],S=r[10],_=r[11],v=r[12],R=r[13],b=r[14],A=r[15];if(n[0].setComponents(u-o,m-h,_-g,A-v).normalize(),n[1].setComponents(u+o,m+h,_+g,A+v).normalize(),n[2].setComponents(u+a,m+d,_+y,A+R).normalize(),n[3].setComponents(u-a,m-d,_-y,A-R).normalize(),n[4].setComponents(u-l,m-p,_-S,A-b).normalize(),t===br)n[5].setComponents(u+l,m+p,_+S,A+b).normalize();else if(t===Cl)n[5].setComponents(l,p,S,b).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),gs.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),gs.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(gs)}intersectsSprite(e){return gs.center.set(0,0,0),gs.radius=.7071067811865476,gs.applyMatrix4(e.matrixWorld),this.intersectsSphere(gs)}intersectsSphere(e){const t=this.planes,n=e.center,r=-e.radius;for(let o=0;o<6;o++)if(t[o].distanceToPoint(n)<r)return!1;return!0}intersectsBox(e){const t=this.planes;for(let n=0;n<6;n++){const r=t[n];if(Qc.x=r.normal.x>0?e.max.x:e.min.x,Qc.y=r.normal.y>0?e.max.y:e.min.y,Qc.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(Qc)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}function x0(){let i=null,e=!1,t=null,n=null;function r(o,a){t(o,a),n=i.requestAnimationFrame(r)}return{start:function(){e!==!0&&t!==null&&(n=i.requestAnimationFrame(r),e=!0)},stop:function(){i.cancelAnimationFrame(n),e=!1},setAnimationLoop:function(o){t=o},setContext:function(o){i=o}}}function qw(i){const e=new WeakMap;function t(l,u){const h=l.array,d=l.usage,p=h.byteLength,m=i.createBuffer();i.bindBuffer(u,m),i.bufferData(u,h,d),l.onUploadCallback();let g;if(h instanceof Float32Array)g=i.FLOAT;else if(h instanceof Uint16Array)l.isFloat16BufferAttribute?g=i.HALF_FLOAT:g=i.UNSIGNED_SHORT;else if(h instanceof Int16Array)g=i.SHORT;else if(h instanceof Uint32Array)g=i.UNSIGNED_INT;else if(h instanceof Int32Array)g=i.INT;else if(h instanceof Int8Array)g=i.BYTE;else if(h instanceof Uint8Array)g=i.UNSIGNED_BYTE;else if(h instanceof Uint8ClampedArray)g=i.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+h);return{buffer:m,type:g,bytesPerElement:h.BYTES_PER_ELEMENT,version:l.version,size:p}}function n(l,u,h){const d=u.array,p=u._updateRange,m=u.updateRanges;if(i.bindBuffer(h,l),p.count===-1&&m.length===0&&i.bufferSubData(h,0,d),m.length!==0){for(let g=0,y=m.length;g<y;g++){const S=m[g];i.bufferSubData(h,S.start*d.BYTES_PER_ELEMENT,d,S.start,S.count)}u.clearUpdateRanges()}p.count!==-1&&(i.bufferSubData(h,p.offset*d.BYTES_PER_ELEMENT,d,p.offset,p.count),p.count=-1),u.onUploadCallback()}function r(l){return l.isInterleavedBufferAttribute&&(l=l.data),e.get(l)}function o(l){l.isInterleavedBufferAttribute&&(l=l.data);const u=e.get(l);u&&(i.deleteBuffer(u.buffer),e.delete(l))}function a(l,u){if(l.isGLBufferAttribute){const d=e.get(l);(!d||d.version<l.version)&&e.set(l,{buffer:l.buffer,type:l.type,bytesPerElement:l.elementSize,version:l.version});return}l.isInterleavedBufferAttribute&&(l=l.data);const h=e.get(l);if(h===void 0)e.set(l,t(l,u));else if(h.version<l.version){if(h.size!==l.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");n(h.buffer,l,u),h.version=l.version}}return{get:r,remove:o,update:a}}class ns extends tn{constructor(e=1,t=1,n=1,r=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:r};const o=e/2,a=t/2,l=Math.floor(n),u=Math.floor(r),h=l+1,d=u+1,p=e/l,m=t/u,g=[],y=[],S=[],_=[];for(let v=0;v<d;v++){const R=v*m-a;for(let b=0;b<h;b++){const A=b*p-o;y.push(A,-R,0),S.push(0,0,1),_.push(b/l),_.push(1-v/u)}}for(let v=0;v<u;v++)for(let R=0;R<l;R++){const b=R+h*v,A=R+h*(v+1),B=R+1+h*(v+1),N=R+1+h*v;g.push(b,A,N),g.push(A,B,N)}this.setIndex(g),this.setAttribute("position",new Bt(y,3)),this.setAttribute("normal",new Bt(S,3)),this.setAttribute("uv",new Bt(_,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new ns(e.width,e.height,e.widthSegments,e.heightSegments)}}var $w=`#ifdef USE_ALPHAHASH
44
+ `},r=new Kt(5,5,5),o=new Rr({name:"CubemapFromEquirect",uniforms:Do(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:Kn,blending:Jr});o.uniforms.tEquirect.value=t;const a=new Se(r,o),l=t.minFilter;return t.minFilter===Ki&&(t.minFilter=Xn),new Xw(1,10,this).update(e,a),t.minFilter=l,a.geometry.dispose(),a.material.dispose(),this}clear(e,t,n,r){const o=e.getRenderTarget();for(let a=0;a<6;a++)e.setRenderTarget(this,a),e.clear(t,n,r);e.setRenderTarget(o)}}const Ah=new F,Yw=new F,jw=new ht;class $r{constructor(e=new F(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,r){return this.normal.set(e,t,n),this.constant=r,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){const r=Ah.subVectors(n,t).cross(Yw.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(r,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(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t){const n=e.delta(Ah),r=this.normal.dot(n);if(r===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const o=-(e.start.dot(this.normal)+this.constant)/r;return o<0||o>1?null:t.copy(e.start).addScaledVector(n,o)}intersectsLine(e){const t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const n=t||jw.getNormalMatrix(e),r=this.coplanarPoint(Ah).applyMatrix4(e),o=this.normal.applyMatrix3(n).normalize();return this.constant=-r.dot(o),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)}}const gs=new rr,Qc=new F;class kf{constructor(e=new $r,t=new $r,n=new $r,r=new $r,o=new $r,a=new $r){this.planes=[e,t,n,r,o,a]}set(e,t,n,r,o,a){const l=this.planes;return l[0].copy(e),l[1].copy(t),l[2].copy(n),l[3].copy(r),l[4].copy(o),l[5].copy(a),this}copy(e){const t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=br){const n=this.planes,r=e.elements,o=r[0],a=r[1],l=r[2],u=r[3],h=r[4],d=r[5],p=r[6],m=r[7],g=r[8],y=r[9],S=r[10],_=r[11],v=r[12],R=r[13],b=r[14],A=r[15];if(n[0].setComponents(u-o,m-h,_-g,A-v).normalize(),n[1].setComponents(u+o,m+h,_+g,A+v).normalize(),n[2].setComponents(u+a,m+d,_+y,A+R).normalize(),n[3].setComponents(u-a,m-d,_-y,A-R).normalize(),n[4].setComponents(u-l,m-p,_-S,A-b).normalize(),t===br)n[5].setComponents(u+l,m+p,_+S,A+b).normalize();else if(t===Cl)n[5].setComponents(l,p,S,b).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),gs.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),gs.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(gs)}intersectsSprite(e){return gs.center.set(0,0,0),gs.radius=.7071067811865476,gs.applyMatrix4(e.matrixWorld),this.intersectsSphere(gs)}intersectsSphere(e){const t=this.planes,n=e.center,r=-e.radius;for(let o=0;o<6;o++)if(t[o].distanceToPoint(n)<r)return!1;return!0}intersectsBox(e){const t=this.planes;for(let n=0;n<6;n++){const r=t[n];if(Qc.x=r.normal.x>0?e.max.x:e.min.x,Qc.y=r.normal.y>0?e.max.y:e.min.y,Qc.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(Qc)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}function x0(){let i=null,e=!1,t=null,n=null;function r(o,a){t(o,a),n=i.requestAnimationFrame(r)}return{start:function(){e!==!0&&t!==null&&(n=i.requestAnimationFrame(r),e=!0)},stop:function(){i.cancelAnimationFrame(n),e=!1},setAnimationLoop:function(o){t=o},setContext:function(o){i=o}}}function qw(i){const e=new WeakMap;function t(l,u){const h=l.array,d=l.usage,p=h.byteLength,m=i.createBuffer();i.bindBuffer(u,m),i.bufferData(u,h,d),l.onUploadCallback();let g;if(h instanceof Float32Array)g=i.FLOAT;else if(h instanceof Uint16Array)l.isFloat16BufferAttribute?g=i.HALF_FLOAT:g=i.UNSIGNED_SHORT;else if(h instanceof Int16Array)g=i.SHORT;else if(h instanceof Uint32Array)g=i.UNSIGNED_INT;else if(h instanceof Int32Array)g=i.INT;else if(h instanceof Int8Array)g=i.BYTE;else if(h instanceof Uint8Array)g=i.UNSIGNED_BYTE;else if(h instanceof Uint8ClampedArray)g=i.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+h);return{buffer:m,type:g,bytesPerElement:h.BYTES_PER_ELEMENT,version:l.version,size:p}}function n(l,u,h){const d=u.array,p=u._updateRange,m=u.updateRanges;if(i.bindBuffer(h,l),p.count===-1&&m.length===0&&i.bufferSubData(h,0,d),m.length!==0){for(let g=0,y=m.length;g<y;g++){const S=m[g];i.bufferSubData(h,S.start*d.BYTES_PER_ELEMENT,d,S.start,S.count)}u.clearUpdateRanges()}p.count!==-1&&(i.bufferSubData(h,p.offset*d.BYTES_PER_ELEMENT,d,p.offset,p.count),p.count=-1),u.onUploadCallback()}function r(l){return l.isInterleavedBufferAttribute&&(l=l.data),e.get(l)}function o(l){l.isInterleavedBufferAttribute&&(l=l.data);const u=e.get(l);u&&(i.deleteBuffer(u.buffer),e.delete(l))}function a(l,u){if(l.isGLBufferAttribute){const d=e.get(l);(!d||d.version<l.version)&&e.set(l,{buffer:l.buffer,type:l.type,bytesPerElement:l.elementSize,version:l.version});return}l.isInterleavedBufferAttribute&&(l=l.data);const h=e.get(l);if(h===void 0)e.set(l,t(l,u));else if(h.version<l.version){if(h.size!==l.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");n(h.buffer,l,u),h.version=l.version}}return{get:r,remove:o,update:a}}class ns extends tn{constructor(e=1,t=1,n=1,r=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:r};const o=e/2,a=t/2,l=Math.floor(n),u=Math.floor(r),h=l+1,d=u+1,p=e/l,m=t/u,g=[],y=[],S=[],_=[];for(let v=0;v<d;v++){const R=v*m-a;for(let b=0;b<h;b++){const A=b*p-o;y.push(A,-R,0),S.push(0,0,1),_.push(b/l),_.push(1-v/u)}}for(let v=0;v<u;v++)for(let R=0;R<l;R++){const b=R+h*v,A=R+h*(v+1),B=R+1+h*(v+1),N=R+1+h*v;g.push(b,A,N),g.push(A,B,N)}this.setIndex(g),this.setAttribute("position",new Bt(y,3)),this.setAttribute("normal",new Bt(S,3)),this.setAttribute("uv",new Bt(_,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new ns(e.width,e.height,e.widthSegments,e.heightSegments)}}var $w=`#ifdef USE_ALPHAHASH
45
45
  if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
46
46
  #endif`,Kw=`#ifdef USE_ALPHAHASH
47
47
  const float ALPHA_HASH_SCALE = 0.05;
@@ -3543,7 +3543,7 @@ void main() {
3543
3543
  #include <tonemapping_fragment>
3544
3544
  #include <colorspace_fragment>
3545
3545
  #include <fog_fragment>
3546
- }`,ut={alphahash_fragment:$w,alphahash_pars_fragment:Kw,alphamap_fragment:Zw,alphamap_pars_fragment:Jw,alphatest_fragment:Qw,alphatest_pars_fragment:eA,aomap_fragment:tA,aomap_pars_fragment:nA,batching_pars_vertex:iA,batching_vertex:rA,begin_vertex:sA,beginnormal_vertex:oA,bsdfs:aA,iridescence_fragment:cA,bumpmap_pars_fragment:lA,clipping_planes_fragment:uA,clipping_planes_pars_fragment:hA,clipping_planes_pars_vertex:fA,clipping_planes_vertex:dA,color_fragment:pA,color_pars_fragment:mA,color_pars_vertex:gA,color_vertex:_A,common:vA,cube_uv_reflection_fragment:xA,defaultnormal_vertex:yA,displacementmap_pars_vertex:MA,displacementmap_vertex:SA,emissivemap_fragment:EA,emissivemap_pars_fragment:TA,colorspace_fragment:bA,colorspace_pars_fragment:wA,envmap_fragment:AA,envmap_common_pars_fragment:RA,envmap_pars_fragment:CA,envmap_pars_vertex:PA,envmap_physical_pars_fragment:GA,envmap_vertex:LA,fog_vertex:IA,fog_pars_vertex:DA,fog_fragment:UA,fog_pars_fragment:NA,gradientmap_pars_fragment:OA,lightmap_fragment:FA,lightmap_pars_fragment:BA,lights_lambert_fragment:zA,lights_lambert_pars_fragment:kA,lights_pars_begin:HA,lights_toon_fragment:VA,lights_toon_pars_fragment:WA,lights_phong_fragment:XA,lights_phong_pars_fragment:YA,lights_physical_fragment:jA,lights_physical_pars_fragment:qA,lights_fragment_begin:$A,lights_fragment_maps:KA,lights_fragment_end:ZA,logdepthbuf_fragment:JA,logdepthbuf_pars_fragment:QA,logdepthbuf_pars_vertex:e1,logdepthbuf_vertex:t1,map_fragment:n1,map_pars_fragment:i1,map_particle_fragment:r1,map_particle_pars_fragment:s1,metalnessmap_fragment:o1,metalnessmap_pars_fragment:a1,morphinstance_vertex:c1,morphcolor_vertex:l1,morphnormal_vertex:u1,morphtarget_pars_vertex:h1,morphtarget_vertex:f1,normal_fragment_begin:d1,normal_fragment_maps:p1,normal_pars_fragment:m1,normal_pars_vertex:g1,normal_vertex:_1,normalmap_pars_fragment:v1,clearcoat_normal_fragment_begin:x1,clearcoat_normal_fragment_maps:y1,clearcoat_pars_fragment:M1,iridescence_pars_fragment:S1,opaque_fragment:E1,packing:T1,premultiplied_alpha_fragment:b1,project_vertex:w1,dithering_fragment:A1,dithering_pars_fragment:R1,roughnessmap_fragment:C1,roughnessmap_pars_fragment:P1,shadowmap_pars_fragment:L1,shadowmap_pars_vertex:I1,shadowmap_vertex:D1,shadowmask_pars_fragment:U1,skinbase_vertex:N1,skinning_pars_vertex:O1,skinning_vertex:F1,skinnormal_vertex:B1,specularmap_fragment:z1,specularmap_pars_fragment:k1,tonemapping_fragment:H1,tonemapping_pars_fragment:G1,transmission_fragment:V1,transmission_pars_fragment:W1,uv_pars_fragment:X1,uv_pars_vertex:Y1,uv_vertex:j1,worldpos_vertex:q1,background_vert:$1,background_frag:K1,backgroundCube_vert:Z1,backgroundCube_frag:J1,cube_vert:Q1,cube_frag:eR,depth_vert:tR,depth_frag:nR,distanceRGBA_vert:iR,distanceRGBA_frag:rR,equirect_vert:sR,equirect_frag:oR,linedashed_vert:aR,linedashed_frag:cR,meshbasic_vert:lR,meshbasic_frag:uR,meshlambert_vert:hR,meshlambert_frag:fR,meshmatcap_vert:dR,meshmatcap_frag:pR,meshnormal_vert:mR,meshnormal_frag:gR,meshphong_vert:_R,meshphong_frag:vR,meshphysical_vert:xR,meshphysical_frag:yR,meshtoon_vert:MR,meshtoon_frag:SR,points_vert:ER,points_frag:TR,shadow_vert:bR,shadow_frag:wR,sprite_vert:AR,sprite_frag:RR},be={common:{diffuse:{value:new Oe(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new ht},alphaMap:{value:null},alphaMapTransform:{value:new ht},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new ht}},envmap:{envMap:{value:null},envMapRotation:{value:new ht},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new ht}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new ht}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new ht},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new ht},normalScale:{value:new Pe(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new ht},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new ht}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new ht}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new ht}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Oe(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:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{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 Oe(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new ht},alphaTest:{value:0},uvTransform:{value:new ht}},sprite:{diffuse:{value:new Oe(16777215)},opacity:{value:1},center:{value:new Pe(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new ht},alphaMap:{value:null},alphaMapTransform:{value:new ht},alphaTest:{value:0}}},ji={basic:{uniforms:Vn([be.common,be.specularmap,be.envmap,be.aomap,be.lightmap,be.fog]),vertexShader:ut.meshbasic_vert,fragmentShader:ut.meshbasic_frag},lambert:{uniforms:Vn([be.common,be.specularmap,be.envmap,be.aomap,be.lightmap,be.emissivemap,be.bumpmap,be.normalmap,be.displacementmap,be.fog,be.lights,{emissive:{value:new Oe(0)}}]),vertexShader:ut.meshlambert_vert,fragmentShader:ut.meshlambert_frag},phong:{uniforms:Vn([be.common,be.specularmap,be.envmap,be.aomap,be.lightmap,be.emissivemap,be.bumpmap,be.normalmap,be.displacementmap,be.fog,be.lights,{emissive:{value:new Oe(0)},specular:{value:new Oe(1118481)},shininess:{value:30}}]),vertexShader:ut.meshphong_vert,fragmentShader:ut.meshphong_frag},standard:{uniforms:Vn([be.common,be.envmap,be.aomap,be.lightmap,be.emissivemap,be.bumpmap,be.normalmap,be.displacementmap,be.roughnessmap,be.metalnessmap,be.fog,be.lights,{emissive:{value:new Oe(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:ut.meshphysical_vert,fragmentShader:ut.meshphysical_frag},toon:{uniforms:Vn([be.common,be.aomap,be.lightmap,be.emissivemap,be.bumpmap,be.normalmap,be.displacementmap,be.gradientmap,be.fog,be.lights,{emissive:{value:new Oe(0)}}]),vertexShader:ut.meshtoon_vert,fragmentShader:ut.meshtoon_frag},matcap:{uniforms:Vn([be.common,be.bumpmap,be.normalmap,be.displacementmap,be.fog,{matcap:{value:null}}]),vertexShader:ut.meshmatcap_vert,fragmentShader:ut.meshmatcap_frag},points:{uniforms:Vn([be.points,be.fog]),vertexShader:ut.points_vert,fragmentShader:ut.points_frag},dashed:{uniforms:Vn([be.common,be.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:ut.linedashed_vert,fragmentShader:ut.linedashed_frag},depth:{uniforms:Vn([be.common,be.displacementmap]),vertexShader:ut.depth_vert,fragmentShader:ut.depth_frag},normal:{uniforms:Vn([be.common,be.bumpmap,be.normalmap,be.displacementmap,{opacity:{value:1}}]),vertexShader:ut.meshnormal_vert,fragmentShader:ut.meshnormal_frag},sprite:{uniforms:Vn([be.sprite,be.fog]),vertexShader:ut.sprite_vert,fragmentShader:ut.sprite_frag},background:{uniforms:{uvTransform:{value:new ht},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:ut.background_vert,fragmentShader:ut.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new ht}},vertexShader:ut.backgroundCube_vert,fragmentShader:ut.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:ut.cube_vert,fragmentShader:ut.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:ut.equirect_vert,fragmentShader:ut.equirect_frag},distanceRGBA:{uniforms:Vn([be.common,be.displacementmap,{referencePosition:{value:new F},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:ut.distanceRGBA_vert,fragmentShader:ut.distanceRGBA_frag},shadow:{uniforms:Vn([be.lights,be.fog,{color:{value:new Oe(0)},opacity:{value:1}}]),vertexShader:ut.shadow_vert,fragmentShader:ut.shadow_frag}};ji.physical={uniforms:Vn([ji.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new ht},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new ht},clearcoatNormalScale:{value:new Pe(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new ht},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new ht},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new ht},sheen:{value:0},sheenColor:{value:new Oe(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new ht},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new ht},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new ht},transmissionSamplerSize:{value:new Pe},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new ht},attenuationDistance:{value:0},attenuationColor:{value:new Oe(0)},specularColor:{value:new Oe(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new ht},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new ht},anisotropyVector:{value:new Pe},anisotropyMap:{value:null},anisotropyMapTransform:{value:new ht}}]),vertexShader:ut.meshphysical_vert,fragmentShader:ut.meshphysical_frag};const el={r:0,b:0,g:0},_s=new Bi,CR=new Qe;function PR(i,e,t,n,r,o,a){const l=new Oe(0);let u=o===!0?0:1,h,d,p=null,m=0,g=null;function y(_,v){let R=!1,b=v.isScene===!0?v.background:null;b&&b.isTexture&&(b=(v.backgroundBlurriness>0?t:e).get(b)),b===null?S(l,u):b&&b.isColor&&(S(b,1),R=!0);const A=i.xr.getEnvironmentBlendMode();A==="additive"?n.buffers.color.setClear(0,0,0,1,a):A==="alpha-blend"&&n.buffers.color.setClear(0,0,0,0,a),(i.autoClear||R)&&i.clear(i.autoClearColor,i.autoClearDepth,i.autoClearStencil),b&&(b.isCubeTexture||b.mapping===Fl)?(d===void 0&&(d=new Se(new Kt(1,1,1),new Rr({name:"BackgroundCubeMaterial",uniforms:Do(ji.backgroundCube.uniforms),vertexShader:ji.backgroundCube.vertexShader,fragmentShader:ji.backgroundCube.fragmentShader,side:Kn,depthTest:!1,depthWrite:!1,fog:!1})),d.geometry.deleteAttribute("normal"),d.geometry.deleteAttribute("uv"),d.onBeforeRender=function(B,N,D){this.matrixWorld.copyPosition(D.matrixWorld)},Object.defineProperty(d.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(d)),_s.copy(v.backgroundRotation),_s.x*=-1,_s.y*=-1,_s.z*=-1,b.isCubeTexture&&b.isRenderTargetTexture===!1&&(_s.y*=-1,_s.z*=-1),d.material.uniforms.envMap.value=b,d.material.uniforms.flipEnvMap.value=b.isCubeTexture&&b.isRenderTargetTexture===!1?-1:1,d.material.uniforms.backgroundBlurriness.value=v.backgroundBlurriness,d.material.uniforms.backgroundIntensity.value=v.backgroundIntensity,d.material.uniforms.backgroundRotation.value.setFromMatrix4(CR.makeRotationFromEuler(_s)),d.material.toneMapped=Lt.getTransfer(b.colorSpace)!==Wt,(p!==b||m!==b.version||g!==i.toneMapping)&&(d.material.needsUpdate=!0,p=b,m=b.version,g=i.toneMapping),d.layers.enableAll(),_.unshift(d,d.geometry,d.material,0,0,null)):b&&b.isTexture&&(h===void 0&&(h=new Se(new ns(2,2),new Rr({name:"BackgroundMaterial",uniforms:Do(ji.background.uniforms),vertexShader:ji.background.vertexShader,fragmentShader:ji.background.fragmentShader,side:tr,depthTest:!1,depthWrite:!1,fog:!1})),h.geometry.deleteAttribute("normal"),Object.defineProperty(h.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(h)),h.material.uniforms.t2D.value=b,h.material.uniforms.backgroundIntensity.value=v.backgroundIntensity,h.material.toneMapped=Lt.getTransfer(b.colorSpace)!==Wt,b.matrixAutoUpdate===!0&&b.updateMatrix(),h.material.uniforms.uvTransform.value.copy(b.matrix),(p!==b||m!==b.version||g!==i.toneMapping)&&(h.material.needsUpdate=!0,p=b,m=b.version,g=i.toneMapping),h.layers.enableAll(),_.unshift(h,h.geometry,h.material,0,0,null))}function S(_,v){_.getRGB(el,m0(i)),n.buffers.color.setClear(el.r,el.g,el.b,v,a)}return{getClearColor:function(){return l},setClearColor:function(_,v=1){l.set(_),u=v,S(l,u)},getClearAlpha:function(){return u},setClearAlpha:function(_){u=_,S(l,u)},render:y}}function LR(i,e){const t=i.getParameter(i.MAX_VERTEX_ATTRIBS),n={},r=m(null);let o=r,a=!1;function l(M,O,H,G,Y){let $=!1;const re=p(G,H,O);o!==re&&(o=re,h(o.object)),$=g(M,G,H,Y),$&&y(M,G,H,Y),Y!==null&&e.update(Y,i.ELEMENT_ARRAY_BUFFER),($||a)&&(a=!1,A(M,O,H,G),Y!==null&&i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,e.get(Y).buffer))}function u(){return i.createVertexArray()}function h(M){return i.bindVertexArray(M)}function d(M){return i.deleteVertexArray(M)}function p(M,O,H){const G=H.wireframe===!0;let Y=n[M.id];Y===void 0&&(Y={},n[M.id]=Y);let $=Y[O.id];$===void 0&&($={},Y[O.id]=$);let re=$[G];return re===void 0&&(re=m(u()),$[G]=re),re}function m(M){const O=[],H=[],G=[];for(let Y=0;Y<t;Y++)O[Y]=0,H[Y]=0,G[Y]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:O,enabledAttributes:H,attributeDivisors:G,object:M,attributes:{},index:null}}function g(M,O,H,G){const Y=o.attributes,$=O.attributes;let re=0;const se=H.getAttributes();for(const K in se)if(se[K].location>=0){const pe=Y[K];let ve=$[K];if(ve===void 0&&(K==="instanceMatrix"&&M.instanceMatrix&&(ve=M.instanceMatrix),K==="instanceColor"&&M.instanceColor&&(ve=M.instanceColor)),pe===void 0||pe.attribute!==ve||ve&&pe.data!==ve.data)return!0;re++}return o.attributesNum!==re||o.index!==G}function y(M,O,H,G){const Y={},$=O.attributes;let re=0;const se=H.getAttributes();for(const K in se)if(se[K].location>=0){let pe=$[K];pe===void 0&&(K==="instanceMatrix"&&M.instanceMatrix&&(pe=M.instanceMatrix),K==="instanceColor"&&M.instanceColor&&(pe=M.instanceColor));const ve={};ve.attribute=pe,pe&&pe.data&&(ve.data=pe.data),Y[K]=ve,re++}o.attributes=Y,o.attributesNum=re,o.index=G}function S(){const M=o.newAttributes;for(let O=0,H=M.length;O<H;O++)M[O]=0}function _(M){v(M,0)}function v(M,O){const H=o.newAttributes,G=o.enabledAttributes,Y=o.attributeDivisors;H[M]=1,G[M]===0&&(i.enableVertexAttribArray(M),G[M]=1),Y[M]!==O&&(i.vertexAttribDivisor(M,O),Y[M]=O)}function R(){const M=o.newAttributes,O=o.enabledAttributes;for(let H=0,G=O.length;H<G;H++)O[H]!==M[H]&&(i.disableVertexAttribArray(H),O[H]=0)}function b(M,O,H,G,Y,$,re){re===!0?i.vertexAttribIPointer(M,O,H,Y,$):i.vertexAttribPointer(M,O,H,G,Y,$)}function A(M,O,H,G){S();const Y=G.attributes,$=H.getAttributes(),re=O.defaultAttributeValues;for(const se in $){const K=$[se];if(K.location>=0){let ae=Y[se];if(ae===void 0&&(se==="instanceMatrix"&&M.instanceMatrix&&(ae=M.instanceMatrix),se==="instanceColor"&&M.instanceColor&&(ae=M.instanceColor)),ae!==void 0){const pe=ae.normalized,ve=ae.itemSize,ke=e.get(ae);if(ke===void 0)continue;const Ze=ke.buffer,te=ke.type,fe=ke.bytesPerElement,Ee=te===i.INT||te===i.UNSIGNED_INT||ae.gpuType===J_;if(ae.isInterleavedBufferAttribute){const Me=ae.data,ze=Me.stride,Ve=ae.offset;if(Me.isInstancedInterleavedBuffer){for(let it=0;it<K.locationSize;it++)v(K.location+it,Me.meshPerAttribute);M.isInstancedMesh!==!0&&G._maxInstanceCount===void 0&&(G._maxInstanceCount=Me.meshPerAttribute*Me.count)}else for(let it=0;it<K.locationSize;it++)_(K.location+it);i.bindBuffer(i.ARRAY_BUFFER,Ze);for(let it=0;it<K.locationSize;it++)b(K.location+it,ve/K.locationSize,te,pe,ze*fe,(Ve+ve/K.locationSize*it)*fe,Ee)}else{if(ae.isInstancedBufferAttribute){for(let Me=0;Me<K.locationSize;Me++)v(K.location+Me,ae.meshPerAttribute);M.isInstancedMesh!==!0&&G._maxInstanceCount===void 0&&(G._maxInstanceCount=ae.meshPerAttribute*ae.count)}else for(let Me=0;Me<K.locationSize;Me++)_(K.location+Me);i.bindBuffer(i.ARRAY_BUFFER,Ze);for(let Me=0;Me<K.locationSize;Me++)b(K.location+Me,ve/K.locationSize,te,pe,ve*fe,ve/K.locationSize*Me*fe,Ee)}}else if(re!==void 0){const pe=re[se];if(pe!==void 0)switch(pe.length){case 2:i.vertexAttrib2fv(K.location,pe);break;case 3:i.vertexAttrib3fv(K.location,pe);break;case 4:i.vertexAttrib4fv(K.location,pe);break;default:i.vertexAttrib1fv(K.location,pe)}}}}R()}function B(){C();for(const M in n){const O=n[M];for(const H in O){const G=O[H];for(const Y in G)d(G[Y].object),delete G[Y];delete O[H]}delete n[M]}}function N(M){if(n[M.id]===void 0)return;const O=n[M.id];for(const H in O){const G=O[H];for(const Y in G)d(G[Y].object),delete G[Y];delete O[H]}delete n[M.id]}function D(M){for(const O in n){const H=n[O];if(H[M.id]===void 0)continue;const G=H[M.id];for(const Y in G)d(G[Y].object),delete G[Y];delete H[M.id]}}function C(){E(),a=!0,o!==r&&(o=r,h(o.object))}function E(){r.geometry=null,r.program=null,r.wireframe=!1}return{setup:l,reset:C,resetDefaultState:E,dispose:B,releaseStatesOfGeometry:N,releaseStatesOfProgram:D,initAttributes:S,enableAttribute:_,disableUnusedAttributes:R}}function IR(i,e,t){let n;function r(u){n=u}function o(u,h){i.drawArrays(n,u,h),t.update(h,n,1)}function a(u,h,d){d!==0&&(i.drawArraysInstanced(n,u,h,d),t.update(h,n,d))}function l(u,h,d){if(d===0)return;const p=e.get("WEBGL_multi_draw");if(p===null)for(let m=0;m<d;m++)this.render(u[m],h[m]);else{p.multiDrawArraysWEBGL(n,u,0,h,0,d);let m=0;for(let g=0;g<d;g++)m+=h[g];t.update(m,n,1)}}this.setMode=r,this.render=o,this.renderInstances=a,this.renderMultiDraw=l}function DR(i,e,t){let n;function r(){if(n!==void 0)return n;if(e.has("EXT_texture_filter_anisotropic")===!0){const b=e.get("EXT_texture_filter_anisotropic");n=i.getParameter(b.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else n=0;return n}function o(b){if(b==="highp"){if(i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.HIGH_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.HIGH_FLOAT).precision>0)return"highp";b="mediump"}return b==="mediump"&&i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.MEDIUM_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let a=t.precision!==void 0?t.precision:"highp";const l=o(a);l!==a&&(console.warn("THREE.WebGLRenderer:",a,"not supported, using",l,"instead."),a=l);const u=t.logarithmicDepthBuffer===!0,h=i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS),d=i.getParameter(i.MAX_VERTEX_TEXTURE_IMAGE_UNITS),p=i.getParameter(i.MAX_TEXTURE_SIZE),m=i.getParameter(i.MAX_CUBE_MAP_TEXTURE_SIZE),g=i.getParameter(i.MAX_VERTEX_ATTRIBS),y=i.getParameter(i.MAX_VERTEX_UNIFORM_VECTORS),S=i.getParameter(i.MAX_VARYING_VECTORS),_=i.getParameter(i.MAX_FRAGMENT_UNIFORM_VECTORS),v=d>0,R=i.getParameter(i.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:r,getMaxPrecision:o,precision:a,logarithmicDepthBuffer:u,maxTextures:h,maxVertexTextures:d,maxTextureSize:p,maxCubemapSize:m,maxAttributes:g,maxVertexUniforms:y,maxVaryings:S,maxFragmentUniforms:_,vertexTextures:v,maxSamples:R}}function UR(i){const e=this;let t=null,n=0,r=!1,o=!1;const a=new $r,l=new ht,u={value:null,needsUpdate:!1};this.uniform=u,this.numPlanes=0,this.numIntersection=0,this.init=function(p,m){const g=p.length!==0||m||n!==0||r;return r=m,n=p.length,g},this.beginShadows=function(){o=!0,d(null)},this.endShadows=function(){o=!1},this.setGlobalState=function(p,m){t=d(p,m,0)},this.setState=function(p,m,g){const y=p.clippingPlanes,S=p.clipIntersection,_=p.clipShadows,v=i.get(p);if(!r||y===null||y.length===0||o&&!_)o?d(null):h();else{const R=o?0:n,b=R*4;let A=v.clippingState||null;u.value=A,A=d(y,m,b,g);for(let B=0;B!==b;++B)A[B]=t[B];v.clippingState=A,this.numIntersection=S?this.numPlanes:0,this.numPlanes+=R}};function h(){u.value!==t&&(u.value=t,u.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function d(p,m,g,y){const S=p!==null?p.length:0;let _=null;if(S!==0){if(_=u.value,y!==!0||_===null){const v=g+S*4,R=m.matrixWorldInverse;l.getNormalMatrix(R),(_===null||_.length<v)&&(_=new Float32Array(v));for(let b=0,A=g;b!==S;++b,A+=4)a.copy(p[b]).applyMatrix4(R,l),a.normal.toArray(_,A),_[A+3]=a.constant}u.value=_,u.needsUpdate=!0}return e.numPlanes=S,e.numIntersection=0,_}}function NR(i){let e=new WeakMap;function t(a,l){return l===of?a.mapping=Ao:l===af&&(a.mapping=Ro),a}function n(a){if(a&&a.isTexture){const l=a.mapping;if(l===of||l===af)if(e.has(a)){const u=e.get(a).texture;return t(u,a.mapping)}else{const u=a.image;if(u&&u.height>0){const h=new v0(u.height);return h.fromEquirectangularTexture(i,a),e.set(a,h),a.addEventListener("dispose",r),t(h.texture,a.mapping)}else return null}}return a}function r(a){const l=a.target;l.removeEventListener("dispose",r);const u=e.get(l);u!==void 0&&(e.delete(l),u.dispose())}function o(){e=new WeakMap}return{get:n,dispose:o}}class zl extends g0{constructor(e=-1,t=1,n=1,r=-1,o=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=r,this.near=o,this.far=a,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=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,n,r,o,a){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=r,this.view.width=o,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,r=(this.top+this.bottom)/2;let o=n-e,a=n+e,l=r+t,u=r-t;if(this.view!==null&&this.view.enabled){const h=(this.right-this.left)/this.view.fullWidth/this.zoom,d=(this.top-this.bottom)/this.view.fullHeight/this.zoom;o+=h*this.view.offsetX,a=o+h*this.view.width,l-=d*this.view.offsetY,u=l-d*this.view.height}this.projectionMatrix.makeOrthographic(o,a,l,u,this.near,this.far,this.coordinateSystem),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,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}}const Mo=4,Mg=[.125,.215,.35,.446,.526,.582],bs=20,Ah=new zl,Sg=new Oe;let Rh=null,Ch=0,Ph=0,Lh=!1;const Ms=(1+Math.sqrt(5))/2,ho=1/Ms,Eg=[new F(1,1,1),new F(-1,1,1),new F(1,1,-1),new F(-1,1,-1),new F(0,Ms,ho),new F(0,Ms,-ho),new F(ho,0,Ms),new F(-ho,0,Ms),new F(Ms,ho,0),new F(-Ms,ho,0)];class Tg{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(e,t=0,n=.1,r=100){Rh=this._renderer.getRenderTarget(),Ch=this._renderer.getActiveCubeFace(),Ph=this._renderer.getActiveMipmapLevel(),Lh=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(256);const o=this._allocateTargets();return o.depthBuffer=!0,this._sceneToCubeUV(e,n,r,o),t>0&&this._blur(o,0,0,t),this._applyPMREM(o),this._cleanup(o),o}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=Ag(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=wg(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodPlanes.length;e++)this._lodPlanes[e].dispose()}_cleanup(e){this._renderer.setRenderTarget(Rh,Ch,Ph),this._renderer.xr.enabled=Lh,e.scissorTest=!1,tl(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===Ao||e.mapping===Ro?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),Rh=this._renderer.getRenderTarget(),Ch=this._renderer.getActiveCubeFace(),Ph=this._renderer.getActiveMipmapLevel(),Lh=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const n=t||this._allocateTargets();return this._textureToCubeUV(e,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){const e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,n={magFilter:Xn,minFilter:Xn,generateMipmaps:!1,type:bl,format:Ei,colorSpace:Tn,depthBuffer:!1},r=bg(e,t,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=bg(e,t,n);const{_lodMax:o}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=OR(o)),this._blurMaterial=FR(o,e,t)}return r}_compileMaterial(e){const t=new Se(this._lodPlanes[0],e);this._renderer.compile(t,Ah)}_sceneToCubeUV(e,t,n,r){const l=new Un(90,1,t,n),u=[1,-1,1,1,1,1],h=[1,1,1,-1,-1,-1],d=this._renderer,p=d.autoClear,m=d.toneMapping;d.getClearColor(Sg),d.toneMapping=Ar,d.autoClear=!1;const g=new Ji({name:"PMREM.Background",side:Kn,depthWrite:!1,depthTest:!1}),y=new Se(new Kt,g);let S=!1;const _=e.background;_?_.isColor&&(g.color.copy(_),e.background=null,S=!0):(g.color.copy(Sg),S=!0);for(let v=0;v<6;v++){const R=v%3;R===0?(l.up.set(0,u[v],0),l.lookAt(h[v],0,0)):R===1?(l.up.set(0,0,u[v]),l.lookAt(0,h[v],0)):(l.up.set(0,u[v],0),l.lookAt(0,0,h[v]));const b=this._cubeSize;tl(r,R*b,v>2?b:0,b,b),d.setRenderTarget(r),S&&d.render(y,l),d.render(e,l)}y.geometry.dispose(),y.material.dispose(),d.toneMapping=m,d.autoClear=p,e.background=_}_textureToCubeUV(e,t){const n=this._renderer,r=e.mapping===Ao||e.mapping===Ro;r?(this._cubemapMaterial===null&&(this._cubemapMaterial=Ag()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=wg());const o=r?this._cubemapMaterial:this._equirectMaterial,a=new Se(this._lodPlanes[0],o),l=o.uniforms;l.envMap.value=e;const u=this._cubeSize;tl(t,0,0,3*u,2*u),n.setRenderTarget(t),n.render(a,Ah)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;for(let r=1;r<this._lodPlanes.length;r++){const o=Math.sqrt(this._sigmas[r]*this._sigmas[r]-this._sigmas[r-1]*this._sigmas[r-1]),a=Eg[(r-1)%Eg.length];this._blur(e,r-1,r,o,a)}t.autoClear=n}_blur(e,t,n,r,o){const a=this._pingPongRenderTarget;this._halfBlur(e,a,t,n,r,"latitudinal",o),this._halfBlur(a,e,n,n,r,"longitudinal",o)}_halfBlur(e,t,n,r,o,a,l){const u=this._renderer,h=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");const d=3,p=new Se(this._lodPlanes[r],h),m=h.uniforms,g=this._sizeLods[n]-1,y=isFinite(o)?Math.PI/(2*g):2*Math.PI/(2*bs-1),S=o/y,_=isFinite(o)?1+Math.floor(d*S):bs;_>bs&&console.warn(`sigmaRadians, ${o}, is too large and will clip, as it requested ${_} samples when the maximum is set to ${bs}`);const v=[];let R=0;for(let D=0;D<bs;++D){const C=D/S,E=Math.exp(-C*C/2);v.push(E),D===0?R+=E:D<_&&(R+=2*E)}for(let D=0;D<v.length;D++)v[D]=v[D]/R;m.envMap.value=e.texture,m.samples.value=_,m.weights.value=v,m.latitudinal.value=a==="latitudinal",l&&(m.poleAxis.value=l);const{_lodMax:b}=this;m.dTheta.value=y,m.mipInt.value=b-n;const A=this._sizeLods[r],B=3*A*(r>b-Mo?r-b+Mo:0),N=4*(this._cubeSize-A);tl(t,B,N,3*A,2*A),u.setRenderTarget(t),u.render(p,Ah)}}function OR(i){const e=[],t=[],n=[];let r=i;const o=i-Mo+1+Mg.length;for(let a=0;a<o;a++){const l=Math.pow(2,r);t.push(l);let u=1/l;a>i-Mo?u=Mg[a-i+Mo-1]:a===0&&(u=0),n.push(u);const h=1/(l-2),d=-h,p=1+h,m=[d,d,p,d,p,p,d,d,p,p,d,p],g=6,y=6,S=3,_=2,v=1,R=new Float32Array(S*y*g),b=new Float32Array(_*y*g),A=new Float32Array(v*y*g);for(let N=0;N<g;N++){const D=N%3*2/3-1,C=N>2?0:-1,E=[D,C,0,D+2/3,C,0,D+2/3,C+1,0,D,C,0,D+2/3,C+1,0,D,C+1,0];R.set(E,S*y*N),b.set(m,_*y*N);const M=[N,N,N,N,N,N];A.set(M,v*y*N)}const B=new tn;B.setAttribute("position",new Nt(R,S)),B.setAttribute("uv",new Nt(b,_)),B.setAttribute("faceIndex",new Nt(A,v)),e.push(B),r>Mo&&r--}return{lodPlanes:e,sizeLods:t,sigmas:n}}function bg(i,e,t){const n=new Rs(i,e,t);return n.texture.mapping=Fl,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function tl(i,e,t,n,r){i.viewport.set(e,t,n,r),i.scissor.set(e,t,n,r)}function FR(i,e,t){const n=new Float32Array(bs),r=new F(0,1,0);return new Rr({name:"SphericalGaussianBlur",defines:{n:bs,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${i}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:r}},vertexShader:kf(),fragmentShader:`
3546
+ }`,ut={alphahash_fragment:$w,alphahash_pars_fragment:Kw,alphamap_fragment:Zw,alphamap_pars_fragment:Jw,alphatest_fragment:Qw,alphatest_pars_fragment:eA,aomap_fragment:tA,aomap_pars_fragment:nA,batching_pars_vertex:iA,batching_vertex:rA,begin_vertex:sA,beginnormal_vertex:oA,bsdfs:aA,iridescence_fragment:cA,bumpmap_pars_fragment:lA,clipping_planes_fragment:uA,clipping_planes_pars_fragment:hA,clipping_planes_pars_vertex:fA,clipping_planes_vertex:dA,color_fragment:pA,color_pars_fragment:mA,color_pars_vertex:gA,color_vertex:_A,common:vA,cube_uv_reflection_fragment:xA,defaultnormal_vertex:yA,displacementmap_pars_vertex:MA,displacementmap_vertex:SA,emissivemap_fragment:EA,emissivemap_pars_fragment:TA,colorspace_fragment:bA,colorspace_pars_fragment:wA,envmap_fragment:AA,envmap_common_pars_fragment:RA,envmap_pars_fragment:CA,envmap_pars_vertex:PA,envmap_physical_pars_fragment:GA,envmap_vertex:LA,fog_vertex:IA,fog_pars_vertex:DA,fog_fragment:UA,fog_pars_fragment:NA,gradientmap_pars_fragment:OA,lightmap_fragment:FA,lightmap_pars_fragment:BA,lights_lambert_fragment:zA,lights_lambert_pars_fragment:kA,lights_pars_begin:HA,lights_toon_fragment:VA,lights_toon_pars_fragment:WA,lights_phong_fragment:XA,lights_phong_pars_fragment:YA,lights_physical_fragment:jA,lights_physical_pars_fragment:qA,lights_fragment_begin:$A,lights_fragment_maps:KA,lights_fragment_end:ZA,logdepthbuf_fragment:JA,logdepthbuf_pars_fragment:QA,logdepthbuf_pars_vertex:e1,logdepthbuf_vertex:t1,map_fragment:n1,map_pars_fragment:i1,map_particle_fragment:r1,map_particle_pars_fragment:s1,metalnessmap_fragment:o1,metalnessmap_pars_fragment:a1,morphinstance_vertex:c1,morphcolor_vertex:l1,morphnormal_vertex:u1,morphtarget_pars_vertex:h1,morphtarget_vertex:f1,normal_fragment_begin:d1,normal_fragment_maps:p1,normal_pars_fragment:m1,normal_pars_vertex:g1,normal_vertex:_1,normalmap_pars_fragment:v1,clearcoat_normal_fragment_begin:x1,clearcoat_normal_fragment_maps:y1,clearcoat_pars_fragment:M1,iridescence_pars_fragment:S1,opaque_fragment:E1,packing:T1,premultiplied_alpha_fragment:b1,project_vertex:w1,dithering_fragment:A1,dithering_pars_fragment:R1,roughnessmap_fragment:C1,roughnessmap_pars_fragment:P1,shadowmap_pars_fragment:L1,shadowmap_pars_vertex:I1,shadowmap_vertex:D1,shadowmask_pars_fragment:U1,skinbase_vertex:N1,skinning_pars_vertex:O1,skinning_vertex:F1,skinnormal_vertex:B1,specularmap_fragment:z1,specularmap_pars_fragment:k1,tonemapping_fragment:H1,tonemapping_pars_fragment:G1,transmission_fragment:V1,transmission_pars_fragment:W1,uv_pars_fragment:X1,uv_pars_vertex:Y1,uv_vertex:j1,worldpos_vertex:q1,background_vert:$1,background_frag:K1,backgroundCube_vert:Z1,backgroundCube_frag:J1,cube_vert:Q1,cube_frag:eR,depth_vert:tR,depth_frag:nR,distanceRGBA_vert:iR,distanceRGBA_frag:rR,equirect_vert:sR,equirect_frag:oR,linedashed_vert:aR,linedashed_frag:cR,meshbasic_vert:lR,meshbasic_frag:uR,meshlambert_vert:hR,meshlambert_frag:fR,meshmatcap_vert:dR,meshmatcap_frag:pR,meshnormal_vert:mR,meshnormal_frag:gR,meshphong_vert:_R,meshphong_frag:vR,meshphysical_vert:xR,meshphysical_frag:yR,meshtoon_vert:MR,meshtoon_frag:SR,points_vert:ER,points_frag:TR,shadow_vert:bR,shadow_frag:wR,sprite_vert:AR,sprite_frag:RR},be={common:{diffuse:{value:new Oe(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new ht},alphaMap:{value:null},alphaMapTransform:{value:new ht},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new ht}},envmap:{envMap:{value:null},envMapRotation:{value:new ht},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new ht}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new ht}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new ht},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new ht},normalScale:{value:new Pe(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new ht},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new ht}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new ht}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new ht}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Oe(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:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{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 Oe(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new ht},alphaTest:{value:0},uvTransform:{value:new ht}},sprite:{diffuse:{value:new Oe(16777215)},opacity:{value:1},center:{value:new Pe(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new ht},alphaMap:{value:null},alphaMapTransform:{value:new ht},alphaTest:{value:0}}},ji={basic:{uniforms:Vn([be.common,be.specularmap,be.envmap,be.aomap,be.lightmap,be.fog]),vertexShader:ut.meshbasic_vert,fragmentShader:ut.meshbasic_frag},lambert:{uniforms:Vn([be.common,be.specularmap,be.envmap,be.aomap,be.lightmap,be.emissivemap,be.bumpmap,be.normalmap,be.displacementmap,be.fog,be.lights,{emissive:{value:new Oe(0)}}]),vertexShader:ut.meshlambert_vert,fragmentShader:ut.meshlambert_frag},phong:{uniforms:Vn([be.common,be.specularmap,be.envmap,be.aomap,be.lightmap,be.emissivemap,be.bumpmap,be.normalmap,be.displacementmap,be.fog,be.lights,{emissive:{value:new Oe(0)},specular:{value:new Oe(1118481)},shininess:{value:30}}]),vertexShader:ut.meshphong_vert,fragmentShader:ut.meshphong_frag},standard:{uniforms:Vn([be.common,be.envmap,be.aomap,be.lightmap,be.emissivemap,be.bumpmap,be.normalmap,be.displacementmap,be.roughnessmap,be.metalnessmap,be.fog,be.lights,{emissive:{value:new Oe(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:ut.meshphysical_vert,fragmentShader:ut.meshphysical_frag},toon:{uniforms:Vn([be.common,be.aomap,be.lightmap,be.emissivemap,be.bumpmap,be.normalmap,be.displacementmap,be.gradientmap,be.fog,be.lights,{emissive:{value:new Oe(0)}}]),vertexShader:ut.meshtoon_vert,fragmentShader:ut.meshtoon_frag},matcap:{uniforms:Vn([be.common,be.bumpmap,be.normalmap,be.displacementmap,be.fog,{matcap:{value:null}}]),vertexShader:ut.meshmatcap_vert,fragmentShader:ut.meshmatcap_frag},points:{uniforms:Vn([be.points,be.fog]),vertexShader:ut.points_vert,fragmentShader:ut.points_frag},dashed:{uniforms:Vn([be.common,be.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:ut.linedashed_vert,fragmentShader:ut.linedashed_frag},depth:{uniforms:Vn([be.common,be.displacementmap]),vertexShader:ut.depth_vert,fragmentShader:ut.depth_frag},normal:{uniforms:Vn([be.common,be.bumpmap,be.normalmap,be.displacementmap,{opacity:{value:1}}]),vertexShader:ut.meshnormal_vert,fragmentShader:ut.meshnormal_frag},sprite:{uniforms:Vn([be.sprite,be.fog]),vertexShader:ut.sprite_vert,fragmentShader:ut.sprite_frag},background:{uniforms:{uvTransform:{value:new ht},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:ut.background_vert,fragmentShader:ut.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new ht}},vertexShader:ut.backgroundCube_vert,fragmentShader:ut.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:ut.cube_vert,fragmentShader:ut.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:ut.equirect_vert,fragmentShader:ut.equirect_frag},distanceRGBA:{uniforms:Vn([be.common,be.displacementmap,{referencePosition:{value:new F},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:ut.distanceRGBA_vert,fragmentShader:ut.distanceRGBA_frag},shadow:{uniforms:Vn([be.lights,be.fog,{color:{value:new Oe(0)},opacity:{value:1}}]),vertexShader:ut.shadow_vert,fragmentShader:ut.shadow_frag}};ji.physical={uniforms:Vn([ji.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new ht},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new ht},clearcoatNormalScale:{value:new Pe(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new ht},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new ht},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new ht},sheen:{value:0},sheenColor:{value:new Oe(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new ht},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new ht},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new ht},transmissionSamplerSize:{value:new Pe},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new ht},attenuationDistance:{value:0},attenuationColor:{value:new Oe(0)},specularColor:{value:new Oe(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new ht},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new ht},anisotropyVector:{value:new Pe},anisotropyMap:{value:null},anisotropyMapTransform:{value:new ht}}]),vertexShader:ut.meshphysical_vert,fragmentShader:ut.meshphysical_frag};const el={r:0,b:0,g:0},_s=new Bi,CR=new Qe;function PR(i,e,t,n,r,o,a){const l=new Oe(0);let u=o===!0?0:1,h,d,p=null,m=0,g=null;function y(_,v){let R=!1,b=v.isScene===!0?v.background:null;b&&b.isTexture&&(b=(v.backgroundBlurriness>0?t:e).get(b)),b===null?S(l,u):b&&b.isColor&&(S(b,1),R=!0);const A=i.xr.getEnvironmentBlendMode();A==="additive"?n.buffers.color.setClear(0,0,0,1,a):A==="alpha-blend"&&n.buffers.color.setClear(0,0,0,0,a),(i.autoClear||R)&&i.clear(i.autoClearColor,i.autoClearDepth,i.autoClearStencil),b&&(b.isCubeTexture||b.mapping===Bl)?(d===void 0&&(d=new Se(new Kt(1,1,1),new Rr({name:"BackgroundCubeMaterial",uniforms:Do(ji.backgroundCube.uniforms),vertexShader:ji.backgroundCube.vertexShader,fragmentShader:ji.backgroundCube.fragmentShader,side:Kn,depthTest:!1,depthWrite:!1,fog:!1})),d.geometry.deleteAttribute("normal"),d.geometry.deleteAttribute("uv"),d.onBeforeRender=function(B,N,D){this.matrixWorld.copyPosition(D.matrixWorld)},Object.defineProperty(d.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(d)),_s.copy(v.backgroundRotation),_s.x*=-1,_s.y*=-1,_s.z*=-1,b.isCubeTexture&&b.isRenderTargetTexture===!1&&(_s.y*=-1,_s.z*=-1),d.material.uniforms.envMap.value=b,d.material.uniforms.flipEnvMap.value=b.isCubeTexture&&b.isRenderTargetTexture===!1?-1:1,d.material.uniforms.backgroundBlurriness.value=v.backgroundBlurriness,d.material.uniforms.backgroundIntensity.value=v.backgroundIntensity,d.material.uniforms.backgroundRotation.value.setFromMatrix4(CR.makeRotationFromEuler(_s)),d.material.toneMapped=Lt.getTransfer(b.colorSpace)!==Wt,(p!==b||m!==b.version||g!==i.toneMapping)&&(d.material.needsUpdate=!0,p=b,m=b.version,g=i.toneMapping),d.layers.enableAll(),_.unshift(d,d.geometry,d.material,0,0,null)):b&&b.isTexture&&(h===void 0&&(h=new Se(new ns(2,2),new Rr({name:"BackgroundMaterial",uniforms:Do(ji.background.uniforms),vertexShader:ji.background.vertexShader,fragmentShader:ji.background.fragmentShader,side:tr,depthTest:!1,depthWrite:!1,fog:!1})),h.geometry.deleteAttribute("normal"),Object.defineProperty(h.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(h)),h.material.uniforms.t2D.value=b,h.material.uniforms.backgroundIntensity.value=v.backgroundIntensity,h.material.toneMapped=Lt.getTransfer(b.colorSpace)!==Wt,b.matrixAutoUpdate===!0&&b.updateMatrix(),h.material.uniforms.uvTransform.value.copy(b.matrix),(p!==b||m!==b.version||g!==i.toneMapping)&&(h.material.needsUpdate=!0,p=b,m=b.version,g=i.toneMapping),h.layers.enableAll(),_.unshift(h,h.geometry,h.material,0,0,null))}function S(_,v){_.getRGB(el,m0(i)),n.buffers.color.setClear(el.r,el.g,el.b,v,a)}return{getClearColor:function(){return l},setClearColor:function(_,v=1){l.set(_),u=v,S(l,u)},getClearAlpha:function(){return u},setClearAlpha:function(_){u=_,S(l,u)},render:y}}function LR(i,e){const t=i.getParameter(i.MAX_VERTEX_ATTRIBS),n={},r=m(null);let o=r,a=!1;function l(M,O,H,G,Y){let $=!1;const re=p(G,H,O);o!==re&&(o=re,h(o.object)),$=g(M,G,H,Y),$&&y(M,G,H,Y),Y!==null&&e.update(Y,i.ELEMENT_ARRAY_BUFFER),($||a)&&(a=!1,A(M,O,H,G),Y!==null&&i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,e.get(Y).buffer))}function u(){return i.createVertexArray()}function h(M){return i.bindVertexArray(M)}function d(M){return i.deleteVertexArray(M)}function p(M,O,H){const G=H.wireframe===!0;let Y=n[M.id];Y===void 0&&(Y={},n[M.id]=Y);let $=Y[O.id];$===void 0&&($={},Y[O.id]=$);let re=$[G];return re===void 0&&(re=m(u()),$[G]=re),re}function m(M){const O=[],H=[],G=[];for(let Y=0;Y<t;Y++)O[Y]=0,H[Y]=0,G[Y]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:O,enabledAttributes:H,attributeDivisors:G,object:M,attributes:{},index:null}}function g(M,O,H,G){const Y=o.attributes,$=O.attributes;let re=0;const se=H.getAttributes();for(const K in se)if(se[K].location>=0){const pe=Y[K];let ve=$[K];if(ve===void 0&&(K==="instanceMatrix"&&M.instanceMatrix&&(ve=M.instanceMatrix),K==="instanceColor"&&M.instanceColor&&(ve=M.instanceColor)),pe===void 0||pe.attribute!==ve||ve&&pe.data!==ve.data)return!0;re++}return o.attributesNum!==re||o.index!==G}function y(M,O,H,G){const Y={},$=O.attributes;let re=0;const se=H.getAttributes();for(const K in se)if(se[K].location>=0){let pe=$[K];pe===void 0&&(K==="instanceMatrix"&&M.instanceMatrix&&(pe=M.instanceMatrix),K==="instanceColor"&&M.instanceColor&&(pe=M.instanceColor));const ve={};ve.attribute=pe,pe&&pe.data&&(ve.data=pe.data),Y[K]=ve,re++}o.attributes=Y,o.attributesNum=re,o.index=G}function S(){const M=o.newAttributes;for(let O=0,H=M.length;O<H;O++)M[O]=0}function _(M){v(M,0)}function v(M,O){const H=o.newAttributes,G=o.enabledAttributes,Y=o.attributeDivisors;H[M]=1,G[M]===0&&(i.enableVertexAttribArray(M),G[M]=1),Y[M]!==O&&(i.vertexAttribDivisor(M,O),Y[M]=O)}function R(){const M=o.newAttributes,O=o.enabledAttributes;for(let H=0,G=O.length;H<G;H++)O[H]!==M[H]&&(i.disableVertexAttribArray(H),O[H]=0)}function b(M,O,H,G,Y,$,re){re===!0?i.vertexAttribIPointer(M,O,H,Y,$):i.vertexAttribPointer(M,O,H,G,Y,$)}function A(M,O,H,G){S();const Y=G.attributes,$=H.getAttributes(),re=O.defaultAttributeValues;for(const se in $){const K=$[se];if(K.location>=0){let ae=Y[se];if(ae===void 0&&(se==="instanceMatrix"&&M.instanceMatrix&&(ae=M.instanceMatrix),se==="instanceColor"&&M.instanceColor&&(ae=M.instanceColor)),ae!==void 0){const pe=ae.normalized,ve=ae.itemSize,ke=e.get(ae);if(ke===void 0)continue;const Ze=ke.buffer,te=ke.type,fe=ke.bytesPerElement,Ee=te===i.INT||te===i.UNSIGNED_INT||ae.gpuType===J_;if(ae.isInterleavedBufferAttribute){const Me=ae.data,ze=Me.stride,Ve=ae.offset;if(Me.isInstancedInterleavedBuffer){for(let it=0;it<K.locationSize;it++)v(K.location+it,Me.meshPerAttribute);M.isInstancedMesh!==!0&&G._maxInstanceCount===void 0&&(G._maxInstanceCount=Me.meshPerAttribute*Me.count)}else for(let it=0;it<K.locationSize;it++)_(K.location+it);i.bindBuffer(i.ARRAY_BUFFER,Ze);for(let it=0;it<K.locationSize;it++)b(K.location+it,ve/K.locationSize,te,pe,ze*fe,(Ve+ve/K.locationSize*it)*fe,Ee)}else{if(ae.isInstancedBufferAttribute){for(let Me=0;Me<K.locationSize;Me++)v(K.location+Me,ae.meshPerAttribute);M.isInstancedMesh!==!0&&G._maxInstanceCount===void 0&&(G._maxInstanceCount=ae.meshPerAttribute*ae.count)}else for(let Me=0;Me<K.locationSize;Me++)_(K.location+Me);i.bindBuffer(i.ARRAY_BUFFER,Ze);for(let Me=0;Me<K.locationSize;Me++)b(K.location+Me,ve/K.locationSize,te,pe,ve*fe,ve/K.locationSize*Me*fe,Ee)}}else if(re!==void 0){const pe=re[se];if(pe!==void 0)switch(pe.length){case 2:i.vertexAttrib2fv(K.location,pe);break;case 3:i.vertexAttrib3fv(K.location,pe);break;case 4:i.vertexAttrib4fv(K.location,pe);break;default:i.vertexAttrib1fv(K.location,pe)}}}}R()}function B(){C();for(const M in n){const O=n[M];for(const H in O){const G=O[H];for(const Y in G)d(G[Y].object),delete G[Y];delete O[H]}delete n[M]}}function N(M){if(n[M.id]===void 0)return;const O=n[M.id];for(const H in O){const G=O[H];for(const Y in G)d(G[Y].object),delete G[Y];delete O[H]}delete n[M.id]}function D(M){for(const O in n){const H=n[O];if(H[M.id]===void 0)continue;const G=H[M.id];for(const Y in G)d(G[Y].object),delete G[Y];delete H[M.id]}}function C(){E(),a=!0,o!==r&&(o=r,h(o.object))}function E(){r.geometry=null,r.program=null,r.wireframe=!1}return{setup:l,reset:C,resetDefaultState:E,dispose:B,releaseStatesOfGeometry:N,releaseStatesOfProgram:D,initAttributes:S,enableAttribute:_,disableUnusedAttributes:R}}function IR(i,e,t){let n;function r(u){n=u}function o(u,h){i.drawArrays(n,u,h),t.update(h,n,1)}function a(u,h,d){d!==0&&(i.drawArraysInstanced(n,u,h,d),t.update(h,n,d))}function l(u,h,d){if(d===0)return;const p=e.get("WEBGL_multi_draw");if(p===null)for(let m=0;m<d;m++)this.render(u[m],h[m]);else{p.multiDrawArraysWEBGL(n,u,0,h,0,d);let m=0;for(let g=0;g<d;g++)m+=h[g];t.update(m,n,1)}}this.setMode=r,this.render=o,this.renderInstances=a,this.renderMultiDraw=l}function DR(i,e,t){let n;function r(){if(n!==void 0)return n;if(e.has("EXT_texture_filter_anisotropic")===!0){const b=e.get("EXT_texture_filter_anisotropic");n=i.getParameter(b.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else n=0;return n}function o(b){if(b==="highp"){if(i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.HIGH_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.HIGH_FLOAT).precision>0)return"highp";b="mediump"}return b==="mediump"&&i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.MEDIUM_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let a=t.precision!==void 0?t.precision:"highp";const l=o(a);l!==a&&(console.warn("THREE.WebGLRenderer:",a,"not supported, using",l,"instead."),a=l);const u=t.logarithmicDepthBuffer===!0,h=i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS),d=i.getParameter(i.MAX_VERTEX_TEXTURE_IMAGE_UNITS),p=i.getParameter(i.MAX_TEXTURE_SIZE),m=i.getParameter(i.MAX_CUBE_MAP_TEXTURE_SIZE),g=i.getParameter(i.MAX_VERTEX_ATTRIBS),y=i.getParameter(i.MAX_VERTEX_UNIFORM_VECTORS),S=i.getParameter(i.MAX_VARYING_VECTORS),_=i.getParameter(i.MAX_FRAGMENT_UNIFORM_VECTORS),v=d>0,R=i.getParameter(i.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:r,getMaxPrecision:o,precision:a,logarithmicDepthBuffer:u,maxTextures:h,maxVertexTextures:d,maxTextureSize:p,maxCubemapSize:m,maxAttributes:g,maxVertexUniforms:y,maxVaryings:S,maxFragmentUniforms:_,vertexTextures:v,maxSamples:R}}function UR(i){const e=this;let t=null,n=0,r=!1,o=!1;const a=new $r,l=new ht,u={value:null,needsUpdate:!1};this.uniform=u,this.numPlanes=0,this.numIntersection=0,this.init=function(p,m){const g=p.length!==0||m||n!==0||r;return r=m,n=p.length,g},this.beginShadows=function(){o=!0,d(null)},this.endShadows=function(){o=!1},this.setGlobalState=function(p,m){t=d(p,m,0)},this.setState=function(p,m,g){const y=p.clippingPlanes,S=p.clipIntersection,_=p.clipShadows,v=i.get(p);if(!r||y===null||y.length===0||o&&!_)o?d(null):h();else{const R=o?0:n,b=R*4;let A=v.clippingState||null;u.value=A,A=d(y,m,b,g);for(let B=0;B!==b;++B)A[B]=t[B];v.clippingState=A,this.numIntersection=S?this.numPlanes:0,this.numPlanes+=R}};function h(){u.value!==t&&(u.value=t,u.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function d(p,m,g,y){const S=p!==null?p.length:0;let _=null;if(S!==0){if(_=u.value,y!==!0||_===null){const v=g+S*4,R=m.matrixWorldInverse;l.getNormalMatrix(R),(_===null||_.length<v)&&(_=new Float32Array(v));for(let b=0,A=g;b!==S;++b,A+=4)a.copy(p[b]).applyMatrix4(R,l),a.normal.toArray(_,A),_[A+3]=a.constant}u.value=_,u.needsUpdate=!0}return e.numPlanes=S,e.numIntersection=0,_}}function NR(i){let e=new WeakMap;function t(a,l){return l===af?a.mapping=Ao:l===cf&&(a.mapping=Ro),a}function n(a){if(a&&a.isTexture){const l=a.mapping;if(l===af||l===cf)if(e.has(a)){const u=e.get(a).texture;return t(u,a.mapping)}else{const u=a.image;if(u&&u.height>0){const h=new v0(u.height);return h.fromEquirectangularTexture(i,a),e.set(a,h),a.addEventListener("dispose",r),t(h.texture,a.mapping)}else return null}}return a}function r(a){const l=a.target;l.removeEventListener("dispose",r);const u=e.get(l);u!==void 0&&(e.delete(l),u.dispose())}function o(){e=new WeakMap}return{get:n,dispose:o}}class kl extends g0{constructor(e=-1,t=1,n=1,r=-1,o=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=r,this.near=o,this.far=a,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=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,n,r,o,a){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=r,this.view.width=o,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,r=(this.top+this.bottom)/2;let o=n-e,a=n+e,l=r+t,u=r-t;if(this.view!==null&&this.view.enabled){const h=(this.right-this.left)/this.view.fullWidth/this.zoom,d=(this.top-this.bottom)/this.view.fullHeight/this.zoom;o+=h*this.view.offsetX,a=o+h*this.view.width,l-=d*this.view.offsetY,u=l-d*this.view.height}this.projectionMatrix.makeOrthographic(o,a,l,u,this.near,this.far,this.coordinateSystem),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,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}}const Mo=4,Mg=[.125,.215,.35,.446,.526,.582],bs=20,Rh=new kl,Sg=new Oe;let Ch=null,Ph=0,Lh=0,Ih=!1;const Ms=(1+Math.sqrt(5))/2,ho=1/Ms,Eg=[new F(1,1,1),new F(-1,1,1),new F(1,1,-1),new F(-1,1,-1),new F(0,Ms,ho),new F(0,Ms,-ho),new F(ho,0,Ms),new F(-ho,0,Ms),new F(Ms,ho,0),new F(-Ms,ho,0)];class Tg{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(e,t=0,n=.1,r=100){Ch=this._renderer.getRenderTarget(),Ph=this._renderer.getActiveCubeFace(),Lh=this._renderer.getActiveMipmapLevel(),Ih=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(256);const o=this._allocateTargets();return o.depthBuffer=!0,this._sceneToCubeUV(e,n,r,o),t>0&&this._blur(o,0,0,t),this._applyPMREM(o),this._cleanup(o),o}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=Ag(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=wg(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodPlanes.length;e++)this._lodPlanes[e].dispose()}_cleanup(e){this._renderer.setRenderTarget(Ch,Ph,Lh),this._renderer.xr.enabled=Ih,e.scissorTest=!1,tl(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===Ao||e.mapping===Ro?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),Ch=this._renderer.getRenderTarget(),Ph=this._renderer.getActiveCubeFace(),Lh=this._renderer.getActiveMipmapLevel(),Ih=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const n=t||this._allocateTargets();return this._textureToCubeUV(e,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){const e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,n={magFilter:Xn,minFilter:Xn,generateMipmaps:!1,type:bl,format:Ei,colorSpace:Tn,depthBuffer:!1},r=bg(e,t,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=bg(e,t,n);const{_lodMax:o}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=OR(o)),this._blurMaterial=FR(o,e,t)}return r}_compileMaterial(e){const t=new Se(this._lodPlanes[0],e);this._renderer.compile(t,Rh)}_sceneToCubeUV(e,t,n,r){const l=new Un(90,1,t,n),u=[1,-1,1,1,1,1],h=[1,1,1,-1,-1,-1],d=this._renderer,p=d.autoClear,m=d.toneMapping;d.getClearColor(Sg),d.toneMapping=Ar,d.autoClear=!1;const g=new Ji({name:"PMREM.Background",side:Kn,depthWrite:!1,depthTest:!1}),y=new Se(new Kt,g);let S=!1;const _=e.background;_?_.isColor&&(g.color.copy(_),e.background=null,S=!0):(g.color.copy(Sg),S=!0);for(let v=0;v<6;v++){const R=v%3;R===0?(l.up.set(0,u[v],0),l.lookAt(h[v],0,0)):R===1?(l.up.set(0,0,u[v]),l.lookAt(0,h[v],0)):(l.up.set(0,u[v],0),l.lookAt(0,0,h[v]));const b=this._cubeSize;tl(r,R*b,v>2?b:0,b,b),d.setRenderTarget(r),S&&d.render(y,l),d.render(e,l)}y.geometry.dispose(),y.material.dispose(),d.toneMapping=m,d.autoClear=p,e.background=_}_textureToCubeUV(e,t){const n=this._renderer,r=e.mapping===Ao||e.mapping===Ro;r?(this._cubemapMaterial===null&&(this._cubemapMaterial=Ag()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=wg());const o=r?this._cubemapMaterial:this._equirectMaterial,a=new Se(this._lodPlanes[0],o),l=o.uniforms;l.envMap.value=e;const u=this._cubeSize;tl(t,0,0,3*u,2*u),n.setRenderTarget(t),n.render(a,Rh)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;for(let r=1;r<this._lodPlanes.length;r++){const o=Math.sqrt(this._sigmas[r]*this._sigmas[r]-this._sigmas[r-1]*this._sigmas[r-1]),a=Eg[(r-1)%Eg.length];this._blur(e,r-1,r,o,a)}t.autoClear=n}_blur(e,t,n,r,o){const a=this._pingPongRenderTarget;this._halfBlur(e,a,t,n,r,"latitudinal",o),this._halfBlur(a,e,n,n,r,"longitudinal",o)}_halfBlur(e,t,n,r,o,a,l){const u=this._renderer,h=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");const d=3,p=new Se(this._lodPlanes[r],h),m=h.uniforms,g=this._sizeLods[n]-1,y=isFinite(o)?Math.PI/(2*g):2*Math.PI/(2*bs-1),S=o/y,_=isFinite(o)?1+Math.floor(d*S):bs;_>bs&&console.warn(`sigmaRadians, ${o}, is too large and will clip, as it requested ${_} samples when the maximum is set to ${bs}`);const v=[];let R=0;for(let D=0;D<bs;++D){const C=D/S,E=Math.exp(-C*C/2);v.push(E),D===0?R+=E:D<_&&(R+=2*E)}for(let D=0;D<v.length;D++)v[D]=v[D]/R;m.envMap.value=e.texture,m.samples.value=_,m.weights.value=v,m.latitudinal.value=a==="latitudinal",l&&(m.poleAxis.value=l);const{_lodMax:b}=this;m.dTheta.value=y,m.mipInt.value=b-n;const A=this._sizeLods[r],B=3*A*(r>b-Mo?r-b+Mo:0),N=4*(this._cubeSize-A);tl(t,B,N,3*A,2*A),u.setRenderTarget(t),u.render(p,Rh)}}function OR(i){const e=[],t=[],n=[];let r=i;const o=i-Mo+1+Mg.length;for(let a=0;a<o;a++){const l=Math.pow(2,r);t.push(l);let u=1/l;a>i-Mo?u=Mg[a-i+Mo-1]:a===0&&(u=0),n.push(u);const h=1/(l-2),d=-h,p=1+h,m=[d,d,p,d,p,p,d,d,p,p,d,p],g=6,y=6,S=3,_=2,v=1,R=new Float32Array(S*y*g),b=new Float32Array(_*y*g),A=new Float32Array(v*y*g);for(let N=0;N<g;N++){const D=N%3*2/3-1,C=N>2?0:-1,E=[D,C,0,D+2/3,C,0,D+2/3,C+1,0,D,C,0,D+2/3,C+1,0,D,C+1,0];R.set(E,S*y*N),b.set(m,_*y*N);const M=[N,N,N,N,N,N];A.set(M,v*y*N)}const B=new tn;B.setAttribute("position",new Nt(R,S)),B.setAttribute("uv",new Nt(b,_)),B.setAttribute("faceIndex",new Nt(A,v)),e.push(B),r>Mo&&r--}return{lodPlanes:e,sizeLods:t,sigmas:n}}function bg(i,e,t){const n=new Rs(i,e,t);return n.texture.mapping=Bl,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function tl(i,e,t,n,r){i.viewport.set(e,t,n,r),i.scissor.set(e,t,n,r)}function FR(i,e,t){const n=new Float32Array(bs),r=new F(0,1,0);return new Rr({name:"SphericalGaussianBlur",defines:{n:bs,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${i}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:r}},vertexShader:Hf(),fragmentShader:`
3547
3547
 
3548
3548
  precision mediump float;
3549
3549
  precision mediump int;
@@ -3603,7 +3603,7 @@ void main() {
3603
3603
  }
3604
3604
 
3605
3605
  }
3606
- `,blending:Jr,depthTest:!1,depthWrite:!1})}function wg(){return new Rr({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:kf(),fragmentShader:`
3606
+ `,blending:Jr,depthTest:!1,depthWrite:!1})}function wg(){return new Rr({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Hf(),fragmentShader:`
3607
3607
 
3608
3608
  precision mediump float;
3609
3609
  precision mediump int;
@@ -3622,7 +3622,7 @@ void main() {
3622
3622
  gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
3623
3623
 
3624
3624
  }
3625
- `,blending:Jr,depthTest:!1,depthWrite:!1})}function Ag(){return new Rr({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:kf(),fragmentShader:`
3625
+ `,blending:Jr,depthTest:!1,depthWrite:!1})}function Ag(){return new Rr({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Hf(),fragmentShader:`
3626
3626
 
3627
3627
  precision mediump float;
3628
3628
  precision mediump int;
@@ -3638,7 +3638,7 @@ void main() {
3638
3638
  gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
3639
3639
 
3640
3640
  }
3641
- `,blending:Jr,depthTest:!1,depthWrite:!1})}function kf(){return`
3641
+ `,blending:Jr,depthTest:!1,depthWrite:!1})}function Hf(){return`
3642
3642
 
3643
3643
  precision mediump float;
3644
3644
  precision mediump int;
@@ -3693,15 +3693,15 @@ void main() {
3693
3693
  gl_Position = vec4( position, 1.0 );
3694
3694
 
3695
3695
  }
3696
- `}function BR(i){let e=new WeakMap,t=null;function n(l){if(l&&l.isTexture){const u=l.mapping,h=u===of||u===af,d=u===Ao||u===Ro;if(h||d){let p=e.get(l);const m=p!==void 0?p.texture.pmremVersion:0;if(l.isRenderTargetTexture&&l.pmremVersion!==m)return t===null&&(t=new Tg(i)),p=h?t.fromEquirectangular(l,p):t.fromCubemap(l,p),p.texture.pmremVersion=l.pmremVersion,e.set(l,p),p.texture;if(p!==void 0)return p.texture;{const g=l.image;return h&&g&&g.height>0||d&&g&&r(g)?(t===null&&(t=new Tg(i)),p=h?t.fromEquirectangular(l):t.fromCubemap(l),p.texture.pmremVersion=l.pmremVersion,e.set(l,p),l.addEventListener("dispose",o),p.texture):null}}}return l}function r(l){let u=0;const h=6;for(let d=0;d<h;d++)l[d]!==void 0&&u++;return u===h}function o(l){const u=l.target;u.removeEventListener("dispose",o);const h=e.get(u);h!==void 0&&(e.delete(u),h.dispose())}function a(){e=new WeakMap,t!==null&&(t.dispose(),t=null)}return{get:n,dispose:a}}function zR(i){const e={};function t(n){if(e[n]!==void 0)return e[n];let r;switch(n){case"WEBGL_depth_texture":r=i.getExtension("WEBGL_depth_texture")||i.getExtension("MOZ_WEBGL_depth_texture")||i.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":r=i.getExtension("EXT_texture_filter_anisotropic")||i.getExtension("MOZ_EXT_texture_filter_anisotropic")||i.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":r=i.getExtension("WEBGL_compressed_texture_s3tc")||i.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||i.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":r=i.getExtension("WEBGL_compressed_texture_pvrtc")||i.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:r=i.getExtension(n)}return e[n]=r,r}return{has:function(n){return t(n)!==null},init:function(){t("EXT_color_buffer_float"),t("WEBGL_clip_cull_distance"),t("OES_texture_float_linear"),t("EXT_color_buffer_half_float"),t("WEBGL_multisampled_render_to_texture"),t("WEBGL_render_shared_exponent")},get:function(n){const r=t(n);return r===null&&console.warn("THREE.WebGLRenderer: "+n+" extension not supported."),r}}}function kR(i,e,t,n){const r={},o=new WeakMap;function a(p){const m=p.target;m.index!==null&&e.remove(m.index);for(const y in m.attributes)e.remove(m.attributes[y]);for(const y in m.morphAttributes){const S=m.morphAttributes[y];for(let _=0,v=S.length;_<v;_++)e.remove(S[_])}m.removeEventListener("dispose",a),delete r[m.id];const g=o.get(m);g&&(e.remove(g),o.delete(m)),n.releaseStatesOfGeometry(m),m.isInstancedBufferGeometry===!0&&delete m._maxInstanceCount,t.memory.geometries--}function l(p,m){return r[m.id]===!0||(m.addEventListener("dispose",a),r[m.id]=!0,t.memory.geometries++),m}function u(p){const m=p.attributes;for(const y in m)e.update(m[y],i.ARRAY_BUFFER);const g=p.morphAttributes;for(const y in g){const S=g[y];for(let _=0,v=S.length;_<v;_++)e.update(S[_],i.ARRAY_BUFFER)}}function h(p){const m=[],g=p.index,y=p.attributes.position;let S=0;if(g!==null){const R=g.array;S=g.version;for(let b=0,A=R.length;b<A;b+=3){const B=R[b+0],N=R[b+1],D=R[b+2];m.push(B,N,N,D,D,B)}}else if(y!==void 0){const R=y.array;S=y.version;for(let b=0,A=R.length/3-1;b<A;b+=3){const B=b+0,N=b+1,D=b+2;m.push(B,N,N,D,D,B)}}else return;const _=new(l0(m)?p0:d0)(m,1);_.version=S;const v=o.get(p);v&&e.remove(v),o.set(p,_)}function d(p){const m=o.get(p);if(m){const g=p.index;g!==null&&m.version<g.version&&h(p)}else h(p);return o.get(p)}return{get:l,update:u,getWireframeAttribute:d}}function HR(i,e,t){let n;function r(p){n=p}let o,a;function l(p){o=p.type,a=p.bytesPerElement}function u(p,m){i.drawElements(n,m,o,p*a),t.update(m,n,1)}function h(p,m,g){g!==0&&(i.drawElementsInstanced(n,m,o,p*a,g),t.update(m,n,g))}function d(p,m,g){if(g===0)return;const y=e.get("WEBGL_multi_draw");if(y===null)for(let S=0;S<g;S++)this.render(p[S]/a,m[S]);else{y.multiDrawElementsWEBGL(n,m,0,o,p,0,g);let S=0;for(let _=0;_<g;_++)S+=m[_];t.update(S,n,1)}}this.setMode=r,this.setIndex=l,this.render=u,this.renderInstances=h,this.renderMultiDraw=d}function GR(i){const e={geometries:0,textures:0},t={frame:0,calls:0,triangles:0,points:0,lines:0};function n(o,a,l){switch(t.calls++,a){case i.TRIANGLES:t.triangles+=l*(o/3);break;case i.LINES:t.lines+=l*(o/2);break;case i.LINE_STRIP:t.lines+=l*(o-1);break;case i.LINE_LOOP:t.lines+=l*o;break;case i.POINTS:t.points+=l*o;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",a);break}}function r(){t.calls=0,t.triangles=0,t.points=0,t.lines=0}return{memory:e,render:t,programs:null,autoReset:!0,reset:r,update:n}}function VR(i,e,t){const n=new WeakMap,r=new Ut;function o(a,l,u){const h=a.morphTargetInfluences,d=l.morphAttributes.position||l.morphAttributes.normal||l.morphAttributes.color,p=d!==void 0?d.length:0;let m=n.get(l);if(m===void 0||m.count!==p){let E=function(){D.dispose(),n.delete(l),l.removeEventListener("dispose",E)};m!==void 0&&m.texture.dispose();const g=l.morphAttributes.position!==void 0,y=l.morphAttributes.normal!==void 0,S=l.morphAttributes.color!==void 0,_=l.morphAttributes.position||[],v=l.morphAttributes.normal||[],R=l.morphAttributes.color||[];let b=0;g===!0&&(b=1),y===!0&&(b=2),S===!0&&(b=3);let A=l.attributes.position.count*b,B=1;A>e.maxTextureSize&&(B=Math.ceil(A/e.maxTextureSize),A=e.maxTextureSize);const N=new Float32Array(A*B*4*p),D=new h0(N,A,B,p);D.type=Zi,D.needsUpdate=!0;const C=b*4;for(let M=0;M<p;M++){const O=_[M],H=v[M],G=R[M],Y=A*B*4*M;for(let $=0;$<O.count;$++){const re=$*C;g===!0&&(r.fromBufferAttribute(O,$),N[Y+re+0]=r.x,N[Y+re+1]=r.y,N[Y+re+2]=r.z,N[Y+re+3]=0),y===!0&&(r.fromBufferAttribute(H,$),N[Y+re+4]=r.x,N[Y+re+5]=r.y,N[Y+re+6]=r.z,N[Y+re+7]=0),S===!0&&(r.fromBufferAttribute(G,$),N[Y+re+8]=r.x,N[Y+re+9]=r.y,N[Y+re+10]=r.z,N[Y+re+11]=G.itemSize===4?r.w:1)}}m={count:p,texture:D,size:new Pe(A,B)},n.set(l,m),l.addEventListener("dispose",E)}if(a.isInstancedMesh===!0&&a.morphTexture!==null)u.getUniforms().setValue(i,"morphTexture",a.morphTexture,t);else{let g=0;for(let S=0;S<h.length;S++)g+=h[S];const y=l.morphTargetsRelative?1:1-g;u.getUniforms().setValue(i,"morphTargetBaseInfluence",y),u.getUniforms().setValue(i,"morphTargetInfluences",h)}u.getUniforms().setValue(i,"morphTargetsTexture",m.texture,t),u.getUniforms().setValue(i,"morphTargetsTextureSize",m.size)}return{update:o}}function WR(i,e,t,n){let r=new WeakMap;function o(u){const h=n.render.frame,d=u.geometry,p=e.get(u,d);if(r.get(p)!==h&&(e.update(p),r.set(p,h)),u.isInstancedMesh&&(u.hasEventListener("dispose",l)===!1&&u.addEventListener("dispose",l),r.get(u)!==h&&(t.update(u.instanceMatrix,i.ARRAY_BUFFER),u.instanceColor!==null&&t.update(u.instanceColor,i.ARRAY_BUFFER),r.set(u,h))),u.isSkinnedMesh){const m=u.skeleton;r.get(m)!==h&&(m.update(),r.set(m,h))}return p}function a(){r=new WeakMap}function l(u){const h=u.target;h.removeEventListener("dispose",l),t.remove(h.instanceMatrix),h.instanceColor!==null&&t.remove(h.instanceColor)}return{update:o,dispose:a}}class y0 extends cn{constructor(e,t,n,r,o,a,l,u,h,d){if(d=d!==void 0?d:To,d!==To&&d!==Ba)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");n===void 0&&d===To&&(n=Po),n===void 0&&d===Ba&&(n=Ga),super(null,r,o,a,l,u,d,n,h),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=l!==void 0?l:Nn,this.minFilter=u!==void 0?u:Nn,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.compareFunction=e.compareFunction,this}toJSON(e){const t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}}const M0=new cn,S0=new y0(1,1);S0.compareFunction=c0;const E0=new h0,T0=new Pw,b0=new _0,Rg=[],Cg=[],Pg=new Float32Array(16),Lg=new Float32Array(9),Ig=new Float32Array(4);function Fo(i,e,t){const n=i[0];if(n<=0||n>0)return i;const r=e*t;let o=Rg[r];if(o===void 0&&(o=new Float32Array(r),Rg[r]=o),e!==0){n.toArray(o,0);for(let a=1,l=0;a!==e;++a)l+=t,i[a].toArray(o,l)}return o}function dn(i,e){if(i.length!==e.length)return!1;for(let t=0,n=i.length;t<n;t++)if(i[t]!==e[t])return!1;return!0}function pn(i,e){for(let t=0,n=e.length;t<n;t++)i[t]=e[t]}function kl(i,e){let t=Cg[e];t===void 0&&(t=new Int32Array(e),Cg[e]=t);for(let n=0;n!==e;++n)t[n]=i.allocateTextureUnit();return t}function XR(i,e){const t=this.cache;t[0]!==e&&(i.uniform1f(this.addr,e),t[0]=e)}function YR(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(i.uniform2f(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(dn(t,e))return;i.uniform2fv(this.addr,e),pn(t,e)}}function jR(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(i.uniform3f(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else if(e.r!==void 0)(t[0]!==e.r||t[1]!==e.g||t[2]!==e.b)&&(i.uniform3f(this.addr,e.r,e.g,e.b),t[0]=e.r,t[1]=e.g,t[2]=e.b);else{if(dn(t,e))return;i.uniform3fv(this.addr,e),pn(t,e)}}function qR(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(i.uniform4f(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(dn(t,e))return;i.uniform4fv(this.addr,e),pn(t,e)}}function $R(i,e){const t=this.cache,n=e.elements;if(n===void 0){if(dn(t,e))return;i.uniformMatrix2fv(this.addr,!1,e),pn(t,e)}else{if(dn(t,n))return;Ig.set(n),i.uniformMatrix2fv(this.addr,!1,Ig),pn(t,n)}}function KR(i,e){const t=this.cache,n=e.elements;if(n===void 0){if(dn(t,e))return;i.uniformMatrix3fv(this.addr,!1,e),pn(t,e)}else{if(dn(t,n))return;Lg.set(n),i.uniformMatrix3fv(this.addr,!1,Lg),pn(t,n)}}function ZR(i,e){const t=this.cache,n=e.elements;if(n===void 0){if(dn(t,e))return;i.uniformMatrix4fv(this.addr,!1,e),pn(t,e)}else{if(dn(t,n))return;Pg.set(n),i.uniformMatrix4fv(this.addr,!1,Pg),pn(t,n)}}function JR(i,e){const t=this.cache;t[0]!==e&&(i.uniform1i(this.addr,e),t[0]=e)}function QR(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(i.uniform2i(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(dn(t,e))return;i.uniform2iv(this.addr,e),pn(t,e)}}function eC(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(i.uniform3i(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(dn(t,e))return;i.uniform3iv(this.addr,e),pn(t,e)}}function tC(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(i.uniform4i(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(dn(t,e))return;i.uniform4iv(this.addr,e),pn(t,e)}}function nC(i,e){const t=this.cache;t[0]!==e&&(i.uniform1ui(this.addr,e),t[0]=e)}function iC(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(i.uniform2ui(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(dn(t,e))return;i.uniform2uiv(this.addr,e),pn(t,e)}}function rC(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(i.uniform3ui(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(dn(t,e))return;i.uniform3uiv(this.addr,e),pn(t,e)}}function sC(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(i.uniform4ui(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(dn(t,e))return;i.uniform4uiv(this.addr,e),pn(t,e)}}function oC(i,e,t){const n=this.cache,r=t.allocateTextureUnit();n[0]!==r&&(i.uniform1i(this.addr,r),n[0]=r);const o=this.type===i.SAMPLER_2D_SHADOW?S0:M0;t.setTexture2D(e||o,r)}function aC(i,e,t){const n=this.cache,r=t.allocateTextureUnit();n[0]!==r&&(i.uniform1i(this.addr,r),n[0]=r),t.setTexture3D(e||T0,r)}function cC(i,e,t){const n=this.cache,r=t.allocateTextureUnit();n[0]!==r&&(i.uniform1i(this.addr,r),n[0]=r),t.setTextureCube(e||b0,r)}function lC(i,e,t){const n=this.cache,r=t.allocateTextureUnit();n[0]!==r&&(i.uniform1i(this.addr,r),n[0]=r),t.setTexture2DArray(e||E0,r)}function uC(i){switch(i){case 5126:return XR;case 35664:return YR;case 35665:return jR;case 35666:return qR;case 35674:return $R;case 35675:return KR;case 35676:return ZR;case 5124:case 35670:return JR;case 35667:case 35671:return QR;case 35668:case 35672:return eC;case 35669:case 35673:return tC;case 5125:return nC;case 36294:return iC;case 36295:return rC;case 36296:return sC;case 35678:case 36198:case 36298:case 36306:case 35682:return oC;case 35679:case 36299:case 36307:return aC;case 35680:case 36300:case 36308:case 36293:return cC;case 36289:case 36303:case 36311:case 36292:return lC}}function hC(i,e){i.uniform1fv(this.addr,e)}function fC(i,e){const t=Fo(e,this.size,2);i.uniform2fv(this.addr,t)}function dC(i,e){const t=Fo(e,this.size,3);i.uniform3fv(this.addr,t)}function pC(i,e){const t=Fo(e,this.size,4);i.uniform4fv(this.addr,t)}function mC(i,e){const t=Fo(e,this.size,4);i.uniformMatrix2fv(this.addr,!1,t)}function gC(i,e){const t=Fo(e,this.size,9);i.uniformMatrix3fv(this.addr,!1,t)}function _C(i,e){const t=Fo(e,this.size,16);i.uniformMatrix4fv(this.addr,!1,t)}function vC(i,e){i.uniform1iv(this.addr,e)}function xC(i,e){i.uniform2iv(this.addr,e)}function yC(i,e){i.uniform3iv(this.addr,e)}function MC(i,e){i.uniform4iv(this.addr,e)}function SC(i,e){i.uniform1uiv(this.addr,e)}function EC(i,e){i.uniform2uiv(this.addr,e)}function TC(i,e){i.uniform3uiv(this.addr,e)}function bC(i,e){i.uniform4uiv(this.addr,e)}function wC(i,e,t){const n=this.cache,r=e.length,o=kl(t,r);dn(n,o)||(i.uniform1iv(this.addr,o),pn(n,o));for(let a=0;a!==r;++a)t.setTexture2D(e[a]||M0,o[a])}function AC(i,e,t){const n=this.cache,r=e.length,o=kl(t,r);dn(n,o)||(i.uniform1iv(this.addr,o),pn(n,o));for(let a=0;a!==r;++a)t.setTexture3D(e[a]||T0,o[a])}function RC(i,e,t){const n=this.cache,r=e.length,o=kl(t,r);dn(n,o)||(i.uniform1iv(this.addr,o),pn(n,o));for(let a=0;a!==r;++a)t.setTextureCube(e[a]||b0,o[a])}function CC(i,e,t){const n=this.cache,r=e.length,o=kl(t,r);dn(n,o)||(i.uniform1iv(this.addr,o),pn(n,o));for(let a=0;a!==r;++a)t.setTexture2DArray(e[a]||E0,o[a])}function PC(i){switch(i){case 5126:return hC;case 35664:return fC;case 35665:return dC;case 35666:return pC;case 35674:return mC;case 35675:return gC;case 35676:return _C;case 5124:case 35670:return vC;case 35667:case 35671:return xC;case 35668:case 35672:return yC;case 35669:case 35673:return MC;case 5125:return SC;case 36294:return EC;case 36295:return TC;case 36296:return bC;case 35678:case 36198:case 36298:case 36306:case 35682:return wC;case 35679:case 36299:case 36307:return AC;case 35680:case 36300:case 36308:case 36293:return RC;case 36289:case 36303:case 36311:case 36292:return CC}}class LC{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.setValue=uC(t.type)}}class IC{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=PC(t.type)}}class DC{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,n){const r=this.seq;for(let o=0,a=r.length;o!==a;++o){const l=r[o];l.setValue(e,t[l.id],n)}}}const Ih=/(\w+)(\])?(\[|\.)?/g;function Dg(i,e){i.seq.push(e),i.map[e.id]=e}function UC(i,e,t){const n=i.name,r=n.length;for(Ih.lastIndex=0;;){const o=Ih.exec(n),a=Ih.lastIndex;let l=o[1];const u=o[2]==="]",h=o[3];if(u&&(l=l|0),h===void 0||h==="["&&a+2===r){Dg(t,h===void 0?new LC(l,i,e):new IC(l,i,e));break}else{let p=t.map[l];p===void 0&&(p=new DC(l),Dg(t,p)),t=p}}}class xl{constructor(e,t){this.seq=[],this.map={};const n=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let r=0;r<n;++r){const o=e.getActiveUniform(t,r),a=e.getUniformLocation(t,o.name);UC(o,a,this)}}setValue(e,t,n,r){const o=this.map[t];o!==void 0&&o.setValue(e,n,r)}setOptional(e,t,n){const r=t[n];r!==void 0&&this.setValue(e,n,r)}static upload(e,t,n,r){for(let o=0,a=t.length;o!==a;++o){const l=t[o],u=n[l.id];u.needsUpdate!==!1&&l.setValue(e,u.value,r)}}static seqWithValue(e,t){const n=[];for(let r=0,o=e.length;r!==o;++r){const a=e[r];a.id in t&&n.push(a)}return n}}function Ug(i,e,t){const n=i.createShader(e);return i.shaderSource(n,t),i.compileShader(n),n}const NC=37297;let OC=0;function FC(i,e){const t=i.split(`
3696
+ `}function BR(i){let e=new WeakMap,t=null;function n(l){if(l&&l.isTexture){const u=l.mapping,h=u===af||u===cf,d=u===Ao||u===Ro;if(h||d){let p=e.get(l);const m=p!==void 0?p.texture.pmremVersion:0;if(l.isRenderTargetTexture&&l.pmremVersion!==m)return t===null&&(t=new Tg(i)),p=h?t.fromEquirectangular(l,p):t.fromCubemap(l,p),p.texture.pmremVersion=l.pmremVersion,e.set(l,p),p.texture;if(p!==void 0)return p.texture;{const g=l.image;return h&&g&&g.height>0||d&&g&&r(g)?(t===null&&(t=new Tg(i)),p=h?t.fromEquirectangular(l):t.fromCubemap(l),p.texture.pmremVersion=l.pmremVersion,e.set(l,p),l.addEventListener("dispose",o),p.texture):null}}}return l}function r(l){let u=0;const h=6;for(let d=0;d<h;d++)l[d]!==void 0&&u++;return u===h}function o(l){const u=l.target;u.removeEventListener("dispose",o);const h=e.get(u);h!==void 0&&(e.delete(u),h.dispose())}function a(){e=new WeakMap,t!==null&&(t.dispose(),t=null)}return{get:n,dispose:a}}function zR(i){const e={};function t(n){if(e[n]!==void 0)return e[n];let r;switch(n){case"WEBGL_depth_texture":r=i.getExtension("WEBGL_depth_texture")||i.getExtension("MOZ_WEBGL_depth_texture")||i.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":r=i.getExtension("EXT_texture_filter_anisotropic")||i.getExtension("MOZ_EXT_texture_filter_anisotropic")||i.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":r=i.getExtension("WEBGL_compressed_texture_s3tc")||i.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||i.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":r=i.getExtension("WEBGL_compressed_texture_pvrtc")||i.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:r=i.getExtension(n)}return e[n]=r,r}return{has:function(n){return t(n)!==null},init:function(){t("EXT_color_buffer_float"),t("WEBGL_clip_cull_distance"),t("OES_texture_float_linear"),t("EXT_color_buffer_half_float"),t("WEBGL_multisampled_render_to_texture"),t("WEBGL_render_shared_exponent")},get:function(n){const r=t(n);return r===null&&console.warn("THREE.WebGLRenderer: "+n+" extension not supported."),r}}}function kR(i,e,t,n){const r={},o=new WeakMap;function a(p){const m=p.target;m.index!==null&&e.remove(m.index);for(const y in m.attributes)e.remove(m.attributes[y]);for(const y in m.morphAttributes){const S=m.morphAttributes[y];for(let _=0,v=S.length;_<v;_++)e.remove(S[_])}m.removeEventListener("dispose",a),delete r[m.id];const g=o.get(m);g&&(e.remove(g),o.delete(m)),n.releaseStatesOfGeometry(m),m.isInstancedBufferGeometry===!0&&delete m._maxInstanceCount,t.memory.geometries--}function l(p,m){return r[m.id]===!0||(m.addEventListener("dispose",a),r[m.id]=!0,t.memory.geometries++),m}function u(p){const m=p.attributes;for(const y in m)e.update(m[y],i.ARRAY_BUFFER);const g=p.morphAttributes;for(const y in g){const S=g[y];for(let _=0,v=S.length;_<v;_++)e.update(S[_],i.ARRAY_BUFFER)}}function h(p){const m=[],g=p.index,y=p.attributes.position;let S=0;if(g!==null){const R=g.array;S=g.version;for(let b=0,A=R.length;b<A;b+=3){const B=R[b+0],N=R[b+1],D=R[b+2];m.push(B,N,N,D,D,B)}}else if(y!==void 0){const R=y.array;S=y.version;for(let b=0,A=R.length/3-1;b<A;b+=3){const B=b+0,N=b+1,D=b+2;m.push(B,N,N,D,D,B)}}else return;const _=new(l0(m)?p0:d0)(m,1);_.version=S;const v=o.get(p);v&&e.remove(v),o.set(p,_)}function d(p){const m=o.get(p);if(m){const g=p.index;g!==null&&m.version<g.version&&h(p)}else h(p);return o.get(p)}return{get:l,update:u,getWireframeAttribute:d}}function HR(i,e,t){let n;function r(p){n=p}let o,a;function l(p){o=p.type,a=p.bytesPerElement}function u(p,m){i.drawElements(n,m,o,p*a),t.update(m,n,1)}function h(p,m,g){g!==0&&(i.drawElementsInstanced(n,m,o,p*a,g),t.update(m,n,g))}function d(p,m,g){if(g===0)return;const y=e.get("WEBGL_multi_draw");if(y===null)for(let S=0;S<g;S++)this.render(p[S]/a,m[S]);else{y.multiDrawElementsWEBGL(n,m,0,o,p,0,g);let S=0;for(let _=0;_<g;_++)S+=m[_];t.update(S,n,1)}}this.setMode=r,this.setIndex=l,this.render=u,this.renderInstances=h,this.renderMultiDraw=d}function GR(i){const e={geometries:0,textures:0},t={frame:0,calls:0,triangles:0,points:0,lines:0};function n(o,a,l){switch(t.calls++,a){case i.TRIANGLES:t.triangles+=l*(o/3);break;case i.LINES:t.lines+=l*(o/2);break;case i.LINE_STRIP:t.lines+=l*(o-1);break;case i.LINE_LOOP:t.lines+=l*o;break;case i.POINTS:t.points+=l*o;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",a);break}}function r(){t.calls=0,t.triangles=0,t.points=0,t.lines=0}return{memory:e,render:t,programs:null,autoReset:!0,reset:r,update:n}}function VR(i,e,t){const n=new WeakMap,r=new Ut;function o(a,l,u){const h=a.morphTargetInfluences,d=l.morphAttributes.position||l.morphAttributes.normal||l.morphAttributes.color,p=d!==void 0?d.length:0;let m=n.get(l);if(m===void 0||m.count!==p){let E=function(){D.dispose(),n.delete(l),l.removeEventListener("dispose",E)};m!==void 0&&m.texture.dispose();const g=l.morphAttributes.position!==void 0,y=l.morphAttributes.normal!==void 0,S=l.morphAttributes.color!==void 0,_=l.morphAttributes.position||[],v=l.morphAttributes.normal||[],R=l.morphAttributes.color||[];let b=0;g===!0&&(b=1),y===!0&&(b=2),S===!0&&(b=3);let A=l.attributes.position.count*b,B=1;A>e.maxTextureSize&&(B=Math.ceil(A/e.maxTextureSize),A=e.maxTextureSize);const N=new Float32Array(A*B*4*p),D=new h0(N,A,B,p);D.type=Zi,D.needsUpdate=!0;const C=b*4;for(let M=0;M<p;M++){const O=_[M],H=v[M],G=R[M],Y=A*B*4*M;for(let $=0;$<O.count;$++){const re=$*C;g===!0&&(r.fromBufferAttribute(O,$),N[Y+re+0]=r.x,N[Y+re+1]=r.y,N[Y+re+2]=r.z,N[Y+re+3]=0),y===!0&&(r.fromBufferAttribute(H,$),N[Y+re+4]=r.x,N[Y+re+5]=r.y,N[Y+re+6]=r.z,N[Y+re+7]=0),S===!0&&(r.fromBufferAttribute(G,$),N[Y+re+8]=r.x,N[Y+re+9]=r.y,N[Y+re+10]=r.z,N[Y+re+11]=G.itemSize===4?r.w:1)}}m={count:p,texture:D,size:new Pe(A,B)},n.set(l,m),l.addEventListener("dispose",E)}if(a.isInstancedMesh===!0&&a.morphTexture!==null)u.getUniforms().setValue(i,"morphTexture",a.morphTexture,t);else{let g=0;for(let S=0;S<h.length;S++)g+=h[S];const y=l.morphTargetsRelative?1:1-g;u.getUniforms().setValue(i,"morphTargetBaseInfluence",y),u.getUniforms().setValue(i,"morphTargetInfluences",h)}u.getUniforms().setValue(i,"morphTargetsTexture",m.texture,t),u.getUniforms().setValue(i,"morphTargetsTextureSize",m.size)}return{update:o}}function WR(i,e,t,n){let r=new WeakMap;function o(u){const h=n.render.frame,d=u.geometry,p=e.get(u,d);if(r.get(p)!==h&&(e.update(p),r.set(p,h)),u.isInstancedMesh&&(u.hasEventListener("dispose",l)===!1&&u.addEventListener("dispose",l),r.get(u)!==h&&(t.update(u.instanceMatrix,i.ARRAY_BUFFER),u.instanceColor!==null&&t.update(u.instanceColor,i.ARRAY_BUFFER),r.set(u,h))),u.isSkinnedMesh){const m=u.skeleton;r.get(m)!==h&&(m.update(),r.set(m,h))}return p}function a(){r=new WeakMap}function l(u){const h=u.target;h.removeEventListener("dispose",l),t.remove(h.instanceMatrix),h.instanceColor!==null&&t.remove(h.instanceColor)}return{update:o,dispose:a}}class y0 extends cn{constructor(e,t,n,r,o,a,l,u,h,d){if(d=d!==void 0?d:To,d!==To&&d!==Ba)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");n===void 0&&d===To&&(n=Po),n===void 0&&d===Ba&&(n=Ga),super(null,r,o,a,l,u,d,n,h),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=l!==void 0?l:Nn,this.minFilter=u!==void 0?u:Nn,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.compareFunction=e.compareFunction,this}toJSON(e){const t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}}const M0=new cn,S0=new y0(1,1);S0.compareFunction=c0;const E0=new h0,T0=new Pw,b0=new _0,Rg=[],Cg=[],Pg=new Float32Array(16),Lg=new Float32Array(9),Ig=new Float32Array(4);function Fo(i,e,t){const n=i[0];if(n<=0||n>0)return i;const r=e*t;let o=Rg[r];if(o===void 0&&(o=new Float32Array(r),Rg[r]=o),e!==0){n.toArray(o,0);for(let a=1,l=0;a!==e;++a)l+=t,i[a].toArray(o,l)}return o}function dn(i,e){if(i.length!==e.length)return!1;for(let t=0,n=i.length;t<n;t++)if(i[t]!==e[t])return!1;return!0}function pn(i,e){for(let t=0,n=e.length;t<n;t++)i[t]=e[t]}function Hl(i,e){let t=Cg[e];t===void 0&&(t=new Int32Array(e),Cg[e]=t);for(let n=0;n!==e;++n)t[n]=i.allocateTextureUnit();return t}function XR(i,e){const t=this.cache;t[0]!==e&&(i.uniform1f(this.addr,e),t[0]=e)}function YR(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(i.uniform2f(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(dn(t,e))return;i.uniform2fv(this.addr,e),pn(t,e)}}function jR(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(i.uniform3f(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else if(e.r!==void 0)(t[0]!==e.r||t[1]!==e.g||t[2]!==e.b)&&(i.uniform3f(this.addr,e.r,e.g,e.b),t[0]=e.r,t[1]=e.g,t[2]=e.b);else{if(dn(t,e))return;i.uniform3fv(this.addr,e),pn(t,e)}}function qR(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(i.uniform4f(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(dn(t,e))return;i.uniform4fv(this.addr,e),pn(t,e)}}function $R(i,e){const t=this.cache,n=e.elements;if(n===void 0){if(dn(t,e))return;i.uniformMatrix2fv(this.addr,!1,e),pn(t,e)}else{if(dn(t,n))return;Ig.set(n),i.uniformMatrix2fv(this.addr,!1,Ig),pn(t,n)}}function KR(i,e){const t=this.cache,n=e.elements;if(n===void 0){if(dn(t,e))return;i.uniformMatrix3fv(this.addr,!1,e),pn(t,e)}else{if(dn(t,n))return;Lg.set(n),i.uniformMatrix3fv(this.addr,!1,Lg),pn(t,n)}}function ZR(i,e){const t=this.cache,n=e.elements;if(n===void 0){if(dn(t,e))return;i.uniformMatrix4fv(this.addr,!1,e),pn(t,e)}else{if(dn(t,n))return;Pg.set(n),i.uniformMatrix4fv(this.addr,!1,Pg),pn(t,n)}}function JR(i,e){const t=this.cache;t[0]!==e&&(i.uniform1i(this.addr,e),t[0]=e)}function QR(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(i.uniform2i(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(dn(t,e))return;i.uniform2iv(this.addr,e),pn(t,e)}}function eC(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(i.uniform3i(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(dn(t,e))return;i.uniform3iv(this.addr,e),pn(t,e)}}function tC(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(i.uniform4i(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(dn(t,e))return;i.uniform4iv(this.addr,e),pn(t,e)}}function nC(i,e){const t=this.cache;t[0]!==e&&(i.uniform1ui(this.addr,e),t[0]=e)}function iC(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(i.uniform2ui(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(dn(t,e))return;i.uniform2uiv(this.addr,e),pn(t,e)}}function rC(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(i.uniform3ui(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(dn(t,e))return;i.uniform3uiv(this.addr,e),pn(t,e)}}function sC(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(i.uniform4ui(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(dn(t,e))return;i.uniform4uiv(this.addr,e),pn(t,e)}}function oC(i,e,t){const n=this.cache,r=t.allocateTextureUnit();n[0]!==r&&(i.uniform1i(this.addr,r),n[0]=r);const o=this.type===i.SAMPLER_2D_SHADOW?S0:M0;t.setTexture2D(e||o,r)}function aC(i,e,t){const n=this.cache,r=t.allocateTextureUnit();n[0]!==r&&(i.uniform1i(this.addr,r),n[0]=r),t.setTexture3D(e||T0,r)}function cC(i,e,t){const n=this.cache,r=t.allocateTextureUnit();n[0]!==r&&(i.uniform1i(this.addr,r),n[0]=r),t.setTextureCube(e||b0,r)}function lC(i,e,t){const n=this.cache,r=t.allocateTextureUnit();n[0]!==r&&(i.uniform1i(this.addr,r),n[0]=r),t.setTexture2DArray(e||E0,r)}function uC(i){switch(i){case 5126:return XR;case 35664:return YR;case 35665:return jR;case 35666:return qR;case 35674:return $R;case 35675:return KR;case 35676:return ZR;case 5124:case 35670:return JR;case 35667:case 35671:return QR;case 35668:case 35672:return eC;case 35669:case 35673:return tC;case 5125:return nC;case 36294:return iC;case 36295:return rC;case 36296:return sC;case 35678:case 36198:case 36298:case 36306:case 35682:return oC;case 35679:case 36299:case 36307:return aC;case 35680:case 36300:case 36308:case 36293:return cC;case 36289:case 36303:case 36311:case 36292:return lC}}function hC(i,e){i.uniform1fv(this.addr,e)}function fC(i,e){const t=Fo(e,this.size,2);i.uniform2fv(this.addr,t)}function dC(i,e){const t=Fo(e,this.size,3);i.uniform3fv(this.addr,t)}function pC(i,e){const t=Fo(e,this.size,4);i.uniform4fv(this.addr,t)}function mC(i,e){const t=Fo(e,this.size,4);i.uniformMatrix2fv(this.addr,!1,t)}function gC(i,e){const t=Fo(e,this.size,9);i.uniformMatrix3fv(this.addr,!1,t)}function _C(i,e){const t=Fo(e,this.size,16);i.uniformMatrix4fv(this.addr,!1,t)}function vC(i,e){i.uniform1iv(this.addr,e)}function xC(i,e){i.uniform2iv(this.addr,e)}function yC(i,e){i.uniform3iv(this.addr,e)}function MC(i,e){i.uniform4iv(this.addr,e)}function SC(i,e){i.uniform1uiv(this.addr,e)}function EC(i,e){i.uniform2uiv(this.addr,e)}function TC(i,e){i.uniform3uiv(this.addr,e)}function bC(i,e){i.uniform4uiv(this.addr,e)}function wC(i,e,t){const n=this.cache,r=e.length,o=Hl(t,r);dn(n,o)||(i.uniform1iv(this.addr,o),pn(n,o));for(let a=0;a!==r;++a)t.setTexture2D(e[a]||M0,o[a])}function AC(i,e,t){const n=this.cache,r=e.length,o=Hl(t,r);dn(n,o)||(i.uniform1iv(this.addr,o),pn(n,o));for(let a=0;a!==r;++a)t.setTexture3D(e[a]||T0,o[a])}function RC(i,e,t){const n=this.cache,r=e.length,o=Hl(t,r);dn(n,o)||(i.uniform1iv(this.addr,o),pn(n,o));for(let a=0;a!==r;++a)t.setTextureCube(e[a]||b0,o[a])}function CC(i,e,t){const n=this.cache,r=e.length,o=Hl(t,r);dn(n,o)||(i.uniform1iv(this.addr,o),pn(n,o));for(let a=0;a!==r;++a)t.setTexture2DArray(e[a]||E0,o[a])}function PC(i){switch(i){case 5126:return hC;case 35664:return fC;case 35665:return dC;case 35666:return pC;case 35674:return mC;case 35675:return gC;case 35676:return _C;case 5124:case 35670:return vC;case 35667:case 35671:return xC;case 35668:case 35672:return yC;case 35669:case 35673:return MC;case 5125:return SC;case 36294:return EC;case 36295:return TC;case 36296:return bC;case 35678:case 36198:case 36298:case 36306:case 35682:return wC;case 35679:case 36299:case 36307:return AC;case 35680:case 36300:case 36308:case 36293:return RC;case 36289:case 36303:case 36311:case 36292:return CC}}class LC{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.setValue=uC(t.type)}}class IC{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=PC(t.type)}}class DC{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,n){const r=this.seq;for(let o=0,a=r.length;o!==a;++o){const l=r[o];l.setValue(e,t[l.id],n)}}}const Dh=/(\w+)(\])?(\[|\.)?/g;function Dg(i,e){i.seq.push(e),i.map[e.id]=e}function UC(i,e,t){const n=i.name,r=n.length;for(Dh.lastIndex=0;;){const o=Dh.exec(n),a=Dh.lastIndex;let l=o[1];const u=o[2]==="]",h=o[3];if(u&&(l=l|0),h===void 0||h==="["&&a+2===r){Dg(t,h===void 0?new LC(l,i,e):new IC(l,i,e));break}else{let p=t.map[l];p===void 0&&(p=new DC(l),Dg(t,p)),t=p}}}class xl{constructor(e,t){this.seq=[],this.map={};const n=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let r=0;r<n;++r){const o=e.getActiveUniform(t,r),a=e.getUniformLocation(t,o.name);UC(o,a,this)}}setValue(e,t,n,r){const o=this.map[t];o!==void 0&&o.setValue(e,n,r)}setOptional(e,t,n){const r=t[n];r!==void 0&&this.setValue(e,n,r)}static upload(e,t,n,r){for(let o=0,a=t.length;o!==a;++o){const l=t[o],u=n[l.id];u.needsUpdate!==!1&&l.setValue(e,u.value,r)}}static seqWithValue(e,t){const n=[];for(let r=0,o=e.length;r!==o;++r){const a=e[r];a.id in t&&n.push(a)}return n}}function Ug(i,e,t){const n=i.createShader(e);return i.shaderSource(n,t),i.compileShader(n),n}const NC=37297;let OC=0;function FC(i,e){const t=i.split(`
3697
3697
  `),n=[],r=Math.max(e-6,0),o=Math.min(e+6,t.length);for(let a=r;a<o;a++){const l=a+1;n.push(`${l===e?">":" "} ${l}: ${t[a]}`)}return n.join(`
3698
- `)}function BC(i){const e=Lt.getPrimaries(Lt.workingColorSpace),t=Lt.getPrimaries(i);let n;switch(e===t?n="":e===Rl&&t===Al?n="LinearDisplayP3ToLinearSRGB":e===Al&&t===Rl&&(n="LinearSRGBToLinearDisplayP3"),i){case Tn:case Bl:return[n,"LinearTransferOETF"];case on:case Nf:return[n,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",i),[n,"LinearTransferOETF"]}}function Ng(i,e,t){const n=i.getShaderParameter(e,i.COMPILE_STATUS),r=i.getShaderInfoLog(e).trim();if(n&&r==="")return"";const o=/ERROR: 0:(\d+)/.exec(r);if(o){const a=parseInt(o[1]);return t.toUpperCase()+`
3698
+ `)}function BC(i){const e=Lt.getPrimaries(Lt.workingColorSpace),t=Lt.getPrimaries(i);let n;switch(e===t?n="":e===Rl&&t===Al?n="LinearDisplayP3ToLinearSRGB":e===Al&&t===Rl&&(n="LinearSRGBToLinearDisplayP3"),i){case Tn:case zl:return[n,"LinearTransferOETF"];case on:case Of:return[n,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",i),[n,"LinearTransferOETF"]}}function Ng(i,e,t){const n=i.getShaderParameter(e,i.COMPILE_STATUS),r=i.getShaderInfoLog(e).trim();if(n&&r==="")return"";const o=/ERROR: 0:(\d+)/.exec(r);if(o){const a=parseInt(o[1]);return t.toUpperCase()+`
3699
3699
 
3700
3700
  `+r+`
3701
3701
 
3702
3702
  `+FC(i.getShaderSource(e),a)}else return r}function zC(i,e){const t=BC(e);return`vec4 ${i}( vec4 value ) { return ${t[0]}( ${t[1]}( value ) ); }`}function kC(i,e){let t;switch(e){case Db:t="Linear";break;case Ub:t="Reinhard";break;case Nb:t="OptimizedCineon";break;case Ob:t="ACESFilmic";break;case Bb:t="AgX";break;case zb:t="Neutral";break;case Fb:t="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),t="Linear"}return"vec3 "+i+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}function HC(i){return[i.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",i.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(ba).join(`
3703
3703
  `)}function GC(i){const e=[];for(const t in i){const n=i[t];n!==!1&&e.push("#define "+t+" "+n)}return e.join(`
3704
- `)}function VC(i,e){const t={},n=i.getProgramParameter(e,i.ACTIVE_ATTRIBUTES);for(let r=0;r<n;r++){const o=i.getActiveAttrib(e,r),a=o.name;let l=1;o.type===i.FLOAT_MAT2&&(l=2),o.type===i.FLOAT_MAT3&&(l=3),o.type===i.FLOAT_MAT4&&(l=4),t[a]={type:o.type,location:i.getAttribLocation(e,a),locationSize:l}}return t}function ba(i){return i!==""}function Og(i,e){const t=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return i.replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,e.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,t).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,e.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,e.numPointLightShadows)}function Fg(i,e){return i.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const WC=/^[ \t]*#include +<([\w\d./]+)>/gm;function uf(i){return i.replace(WC,YC)}const XC=new Map([["encodings_fragment","colorspace_fragment"],["encodings_pars_fragment","colorspace_pars_fragment"],["output_fragment","opaque_fragment"]]);function YC(i,e){let t=ut[e];if(t===void 0){const n=XC.get(e);if(n!==void 0)t=ut[n],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,n);else throw new Error("Can not resolve #include <"+e+">")}return uf(t)}const jC=/#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 Bg(i){return i.replace(jC,qC)}function qC(i,e,t,n){let r="";for(let o=parseInt(e);o<parseInt(t);o++)r+=n.replace(/\[\s*i\s*\]/g,"[ "+o+" ]").replace(/UNROLLED_LOOP_INDEX/g,o);return r}function zg(i){let e=`precision ${i.precision} float;
3704
+ `)}function VC(i,e){const t={},n=i.getProgramParameter(e,i.ACTIVE_ATTRIBUTES);for(let r=0;r<n;r++){const o=i.getActiveAttrib(e,r),a=o.name;let l=1;o.type===i.FLOAT_MAT2&&(l=2),o.type===i.FLOAT_MAT3&&(l=3),o.type===i.FLOAT_MAT4&&(l=4),t[a]={type:o.type,location:i.getAttribLocation(e,a),locationSize:l}}return t}function ba(i){return i!==""}function Og(i,e){const t=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return i.replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,e.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,t).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,e.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,e.numPointLightShadows)}function Fg(i,e){return i.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const WC=/^[ \t]*#include +<([\w\d./]+)>/gm;function hf(i){return i.replace(WC,YC)}const XC=new Map([["encodings_fragment","colorspace_fragment"],["encodings_pars_fragment","colorspace_pars_fragment"],["output_fragment","opaque_fragment"]]);function YC(i,e){let t=ut[e];if(t===void 0){const n=XC.get(e);if(n!==void 0)t=ut[n],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,n);else throw new Error("Can not resolve #include <"+e+">")}return hf(t)}const jC=/#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 Bg(i){return i.replace(jC,qC)}function qC(i,e,t,n){let r="";for(let o=parseInt(e);o<parseInt(t);o++)r+=n.replace(/\[\s*i\s*\]/g,"[ "+o+" ]").replace(/UNROLLED_LOOP_INDEX/g,o);return r}function zg(i){let e=`precision ${i.precision} float;
3705
3705
  precision ${i.precision} int;
3706
3706
  precision ${i.precision} sampler2D;
3707
3707
  precision ${i.precision} samplerCube;
@@ -3721,7 +3721,7 @@ void main() {
3721
3721
  `;return i.precision==="highp"?e+=`
3722
3722
  #define HIGH_PRECISION`:i.precision==="mediump"?e+=`
3723
3723
  #define MEDIUM_PRECISION`:i.precision==="lowp"&&(e+=`
3724
- #define LOW_PRECISION`),e}function $C(i){let e="SHADOWMAP_TYPE_BASIC";return i.shadowMapType===j_?e="SHADOWMAP_TYPE_PCF":i.shadowMapType===q_?e="SHADOWMAP_TYPE_PCF_SOFT":i.shadowMapType===Tr&&(e="SHADOWMAP_TYPE_VSM"),e}function KC(i){let e="ENVMAP_TYPE_CUBE";if(i.envMap)switch(i.envMapMode){case Ao:case Ro:e="ENVMAP_TYPE_CUBE";break;case Fl:e="ENVMAP_TYPE_CUBE_UV";break}return e}function ZC(i){let e="ENVMAP_MODE_REFLECTION";if(i.envMap)switch(i.envMapMode){case Ro:e="ENVMAP_MODE_REFRACTION";break}return e}function JC(i){let e="ENVMAP_BLENDING_NONE";if(i.envMap)switch(i.combine){case $_:e="ENVMAP_BLENDING_MULTIPLY";break;case Lb:e="ENVMAP_BLENDING_MIX";break;case Ib:e="ENVMAP_BLENDING_ADD";break}return e}function QC(i){const e=i.envMapCubeUVHeight;if(e===null)return null;const t=Math.log2(e)-2,n=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,t),7*16)),texelHeight:n,maxMip:t}}function eP(i,e,t,n){const r=i.getContext(),o=t.defines;let a=t.vertexShader,l=t.fragmentShader;const u=$C(t),h=KC(t),d=ZC(t),p=JC(t),m=QC(t),g=HC(t),y=GC(o),S=r.createProgram();let _,v,R=t.glslVersion?"#version "+t.glslVersion+`
3724
+ #define LOW_PRECISION`),e}function $C(i){let e="SHADOWMAP_TYPE_BASIC";return i.shadowMapType===j_?e="SHADOWMAP_TYPE_PCF":i.shadowMapType===q_?e="SHADOWMAP_TYPE_PCF_SOFT":i.shadowMapType===Tr&&(e="SHADOWMAP_TYPE_VSM"),e}function KC(i){let e="ENVMAP_TYPE_CUBE";if(i.envMap)switch(i.envMapMode){case Ao:case Ro:e="ENVMAP_TYPE_CUBE";break;case Bl:e="ENVMAP_TYPE_CUBE_UV";break}return e}function ZC(i){let e="ENVMAP_MODE_REFLECTION";if(i.envMap)switch(i.envMapMode){case Ro:e="ENVMAP_MODE_REFRACTION";break}return e}function JC(i){let e="ENVMAP_BLENDING_NONE";if(i.envMap)switch(i.combine){case $_:e="ENVMAP_BLENDING_MULTIPLY";break;case Lb:e="ENVMAP_BLENDING_MIX";break;case Ib:e="ENVMAP_BLENDING_ADD";break}return e}function QC(i){const e=i.envMapCubeUVHeight;if(e===null)return null;const t=Math.log2(e)-2,n=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,t),7*16)),texelHeight:n,maxMip:t}}function eP(i,e,t,n){const r=i.getContext(),o=t.defines;let a=t.vertexShader,l=t.fragmentShader;const u=$C(t),h=KC(t),d=ZC(t),p=JC(t),m=QC(t),g=HC(t),y=GC(o),S=r.createProgram();let _,v,R=t.glslVersion?"#version "+t.glslVersion+`
3725
3725
  `:"";t.isRawShaderMaterial?(_=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,y].filter(ba).join(`
3726
3726
  `),_.length>0&&(_+=`
3727
3727
  `),v=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,y].filter(ba).join(`
@@ -3730,7 +3730,7 @@ void main() {
3730
3730
  `].filter(ba).join(`
3731
3731
  `),v=[zg(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,y,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+h:"",t.envMap?"#define "+d:"",t.envMap?"#define "+p:"",m?"#define CUBEUV_TEXEL_WIDTH "+m.texelWidth:"",m?"#define CUBEUV_TEXEL_HEIGHT "+m.texelHeight:"",m?"#define CUBEUV_MAX_MIP "+m.maxMip+".0":"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoat?"#define USE_CLEARCOAT":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.iridescence?"#define USE_IRIDESCENCE":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaTest?"#define USE_ALPHATEST":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.sheen?"#define USE_SHEEN":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors||t.instancingColor?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.gradientMap?"#define USE_GRADIENTMAP":"",t.flatShading?"#define FLAT_SHADED":"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+u:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.useLegacyLights?"#define LEGACY_LIGHTS":"",t.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",t.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==Ar?"#define TONE_MAPPING":"",t.toneMapping!==Ar?ut.tonemapping_pars_fragment:"",t.toneMapping!==Ar?kC("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",ut.colorspace_pars_fragment,zC("linearToOutputTexel",t.outputColorSpace),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",`
3732
3732
  `].filter(ba).join(`
3733
- `)),a=uf(a),a=Og(a,t),a=Fg(a,t),l=uf(l),l=Og(l,t),l=Fg(l,t),a=Bg(a),l=Bg(l),t.isRawShaderMaterial!==!0&&(R=`#version 300 es
3733
+ `)),a=hf(a),a=Og(a,t),a=Fg(a,t),l=hf(l),l=Og(l,t),l=Fg(l,t),a=Bg(a),l=Bg(l),t.isRawShaderMaterial!==!0&&(R=`#version 300 es
3734
3734
  `,_=[g,"#define attribute in","#define varying out","#define texture2D texture"].join(`
3735
3735
  `)+`
3736
3736
  `+_,v=["#define varying in",t.glslVersion===eg?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===eg?"":"#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(`
@@ -3742,7 +3742,7 @@ Material Type: `+O.type+`
3742
3742
 
3743
3743
  Program Info Log: `+H+`
3744
3744
  `+se+`
3745
- `+K)}else H!==""?console.warn("THREE.WebGLProgram: Program Info Log:",H):(G===""||Y==="")&&(re=!1);re&&(O.diagnostics={runnable:$,programLog:H,vertexShader:{log:G,prefix:_},fragmentShader:{log:Y,prefix:v}})}r.deleteShader(B),r.deleteShader(N),C=new xl(r,S),E=VC(r,S)}let C;this.getUniforms=function(){return C===void 0&&D(this),C};let E;this.getAttributes=function(){return E===void 0&&D(this),E};let M=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return M===!1&&(M=r.getProgramParameter(S,NC)),M},this.destroy=function(){n.releaseStatesOfProgram(this),r.deleteProgram(S),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=OC++,this.cacheKey=e,this.usedTimes=1,this.program=S,this.vertexShader=B,this.fragmentShader=N,this}let tP=0;class nP{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const t=e.vertexShader,n=e.fragmentShader,r=this._getShaderStage(t),o=this._getShaderStage(n),a=this._getShaderCacheForMaterial(e);return a.has(r)===!1&&(a.add(r),r.usedTimes++),a.has(o)===!1&&(a.add(o),o.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const n of t)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const t=this.materialCache;let n=t.get(e);return n===void 0&&(n=new Set,t.set(e,n)),n}_getShaderStage(e){const t=this.shaderCache;let n=t.get(e);return n===void 0&&(n=new iP(e),t.set(e,n)),n}}class iP{constructor(e){this.id=tP++,this.code=e,this.usedTimes=0}}function rP(i,e,t,n,r,o,a){const l=new Bf,u=new nP,h=new Set,d=[],p=r.logarithmicDepthBuffer,m=r.vertexTextures;let g=r.precision;const y={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"};function S(E){return h.add(E),E===0?"uv":`uv${E}`}function _(E,M,O,H,G){const Y=H.fog,$=G.geometry,re=E.isMeshStandardMaterial?H.environment:null,se=(E.isMeshStandardMaterial?t:e).get(E.envMap||re),K=se&&se.mapping===Fl?se.image.height:null,ae=y[E.type];E.precision!==null&&(g=r.getMaxPrecision(E.precision),g!==E.precision&&console.warn("THREE.WebGLProgram.getParameters:",E.precision,"not supported, using",g,"instead."));const pe=$.morphAttributes.position||$.morphAttributes.normal||$.morphAttributes.color,ve=pe!==void 0?pe.length:0;let ke=0;$.morphAttributes.position!==void 0&&(ke=1),$.morphAttributes.normal!==void 0&&(ke=2),$.morphAttributes.color!==void 0&&(ke=3);let Ze,te,fe,Ee;if(ae){const ln=ji[ae];Ze=ln.vertexShader,te=ln.fragmentShader}else Ze=E.vertexShader,te=E.fragmentShader,u.update(E),fe=u.getVertexShaderID(E),Ee=u.getFragmentShaderID(E);const Me=i.getRenderTarget(),ze=G.isInstancedMesh===!0,Ve=G.isBatchedMesh===!0,it=!!E.map,q=!!E.matcap,$e=!!se,Fe=!!E.aoMap,mt=!!E.lightMap,We=!!E.bumpMap,At=!!E.normalMap,z=!!E.displacementMap,P=!!E.emissiveMap,ie=!!E.metalnessMap,le=!!E.roughnessMap,de=E.anisotropy>0,ge=E.clearcoat>0,He=E.iridescence>0,_e=E.sheen>0,De=E.transmission>0,Xe=de&&!!E.anisotropyMap,xe=ge&&!!E.clearcoatMap,we=ge&&!!E.clearcoatNormalMap,Ke=ge&&!!E.clearcoatRoughnessMap,Le=He&&!!E.iridescenceMap,Ie=He&&!!E.iridescenceThicknessMap,ct=_e&&!!E.sheenColorMap,ft=_e&&!!E.sheenRoughnessMap,Et=!!E.specularMap,_t=!!E.specularColorMap,Tt=!!E.specularIntensityMap,Ne=De&&!!E.transmissionMap,T=De&&!!E.thicknessMap,Z=!!E.gradientMap,ce=!!E.alphaMap,ye=E.alphaTest>0,Re=!!E.alphaHash,vt=!!E.extensions;let dt=Ar;E.toneMapped&&(Me===null||Me.isXRRenderTarget===!0)&&(dt=i.toneMapping);const zt={shaderID:ae,shaderType:E.type,shaderName:E.name,vertexShader:Ze,fragmentShader:te,defines:E.defines,customVertexShaderID:fe,customFragmentShaderID:Ee,isRawShaderMaterial:E.isRawShaderMaterial===!0,glslVersion:E.glslVersion,precision:g,batching:Ve,instancing:ze,instancingColor:ze&&G.instanceColor!==null,instancingMorph:ze&&G.morphTexture!==null,supportsVertexTextures:m,outputColorSpace:Me===null?i.outputColorSpace:Me.isXRRenderTarget===!0?Me.texture.colorSpace:Tn,alphaToCoverage:!!E.alphaToCoverage,map:it,matcap:q,envMap:$e,envMapMode:$e&&se.mapping,envMapCubeUVHeight:K,aoMap:Fe,lightMap:mt,bumpMap:We,normalMap:At,displacementMap:m&&z,emissiveMap:P,normalMapObjectSpace:At&&E.normalMapType===ew,normalMapTangentSpace:At&&E.normalMapType===a0,metalnessMap:ie,roughnessMap:le,anisotropy:de,anisotropyMap:Xe,clearcoat:ge,clearcoatMap:xe,clearcoatNormalMap:we,clearcoatRoughnessMap:Ke,iridescence:He,iridescenceMap:Le,iridescenceThicknessMap:Ie,sheen:_e,sheenColorMap:ct,sheenRoughnessMap:ft,specularMap:Et,specularColorMap:_t,specularIntensityMap:Tt,transmission:De,transmissionMap:Ne,thicknessMap:T,gradientMap:Z,opaque:E.transparent===!1&&E.blending===Eo&&E.alphaToCoverage===!1,alphaMap:ce,alphaTest:ye,alphaHash:Re,combine:E.combine,mapUv:it&&S(E.map.channel),aoMapUv:Fe&&S(E.aoMap.channel),lightMapUv:mt&&S(E.lightMap.channel),bumpMapUv:We&&S(E.bumpMap.channel),normalMapUv:At&&S(E.normalMap.channel),displacementMapUv:z&&S(E.displacementMap.channel),emissiveMapUv:P&&S(E.emissiveMap.channel),metalnessMapUv:ie&&S(E.metalnessMap.channel),roughnessMapUv:le&&S(E.roughnessMap.channel),anisotropyMapUv:Xe&&S(E.anisotropyMap.channel),clearcoatMapUv:xe&&S(E.clearcoatMap.channel),clearcoatNormalMapUv:we&&S(E.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Ke&&S(E.clearcoatRoughnessMap.channel),iridescenceMapUv:Le&&S(E.iridescenceMap.channel),iridescenceThicknessMapUv:Ie&&S(E.iridescenceThicknessMap.channel),sheenColorMapUv:ct&&S(E.sheenColorMap.channel),sheenRoughnessMapUv:ft&&S(E.sheenRoughnessMap.channel),specularMapUv:Et&&S(E.specularMap.channel),specularColorMapUv:_t&&S(E.specularColorMap.channel),specularIntensityMapUv:Tt&&S(E.specularIntensityMap.channel),transmissionMapUv:Ne&&S(E.transmissionMap.channel),thicknessMapUv:T&&S(E.thicknessMap.channel),alphaMapUv:ce&&S(E.alphaMap.channel),vertexTangents:!!$.attributes.tangent&&(At||de),vertexColors:E.vertexColors,vertexAlphas:E.vertexColors===!0&&!!$.attributes.color&&$.attributes.color.itemSize===4,pointsUvs:G.isPoints===!0&&!!$.attributes.uv&&(it||ce),fog:!!Y,useFog:E.fog===!0,fogExp2:!!Y&&Y.isFogExp2,flatShading:E.flatShading===!0,sizeAttenuation:E.sizeAttenuation===!0,logarithmicDepthBuffer:p,skinning:G.isSkinnedMesh===!0,morphTargets:$.morphAttributes.position!==void 0,morphNormals:$.morphAttributes.normal!==void 0,morphColors:$.morphAttributes.color!==void 0,morphTargetsCount:ve,morphTextureStride:ke,numDirLights:M.directional.length,numPointLights:M.point.length,numSpotLights:M.spot.length,numSpotLightMaps:M.spotLightMap.length,numRectAreaLights:M.rectArea.length,numHemiLights:M.hemi.length,numDirLightShadows:M.directionalShadowMap.length,numPointLightShadows:M.pointShadowMap.length,numSpotLightShadows:M.spotShadowMap.length,numSpotLightShadowsWithMaps:M.numSpotLightShadowsWithMaps,numLightProbes:M.numLightProbes,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:E.dithering,shadowMapEnabled:i.shadowMap.enabled&&O.length>0,shadowMapType:i.shadowMap.type,toneMapping:dt,useLegacyLights:i._useLegacyLights,decodeVideoTexture:it&&E.map.isVideoTexture===!0&&Lt.getTransfer(E.map.colorSpace)===Wt,premultipliedAlpha:E.premultipliedAlpha,doubleSided:E.side===si,flipSided:E.side===Kn,useDepthPacking:E.depthPacking>=0,depthPacking:E.depthPacking||0,index0AttributeName:E.index0AttributeName,extensionClipCullDistance:vt&&E.extensions.clipCullDistance===!0&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:vt&&E.extensions.multiDraw===!0&&n.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:E.customProgramCacheKey()};return zt.vertexUv1s=h.has(1),zt.vertexUv2s=h.has(2),zt.vertexUv3s=h.has(3),h.clear(),zt}function v(E){const M=[];if(E.shaderID?M.push(E.shaderID):(M.push(E.customVertexShaderID),M.push(E.customFragmentShaderID)),E.defines!==void 0)for(const O in E.defines)M.push(O),M.push(E.defines[O]);return E.isRawShaderMaterial===!1&&(R(M,E),b(M,E),M.push(i.outputColorSpace)),M.push(E.customProgramCacheKey),M.join()}function R(E,M){E.push(M.precision),E.push(M.outputColorSpace),E.push(M.envMapMode),E.push(M.envMapCubeUVHeight),E.push(M.mapUv),E.push(M.alphaMapUv),E.push(M.lightMapUv),E.push(M.aoMapUv),E.push(M.bumpMapUv),E.push(M.normalMapUv),E.push(M.displacementMapUv),E.push(M.emissiveMapUv),E.push(M.metalnessMapUv),E.push(M.roughnessMapUv),E.push(M.anisotropyMapUv),E.push(M.clearcoatMapUv),E.push(M.clearcoatNormalMapUv),E.push(M.clearcoatRoughnessMapUv),E.push(M.iridescenceMapUv),E.push(M.iridescenceThicknessMapUv),E.push(M.sheenColorMapUv),E.push(M.sheenRoughnessMapUv),E.push(M.specularMapUv),E.push(M.specularColorMapUv),E.push(M.specularIntensityMapUv),E.push(M.transmissionMapUv),E.push(M.thicknessMapUv),E.push(M.combine),E.push(M.fogExp2),E.push(M.sizeAttenuation),E.push(M.morphTargetsCount),E.push(M.morphAttributeCount),E.push(M.numDirLights),E.push(M.numPointLights),E.push(M.numSpotLights),E.push(M.numSpotLightMaps),E.push(M.numHemiLights),E.push(M.numRectAreaLights),E.push(M.numDirLightShadows),E.push(M.numPointLightShadows),E.push(M.numSpotLightShadows),E.push(M.numSpotLightShadowsWithMaps),E.push(M.numLightProbes),E.push(M.shadowMapType),E.push(M.toneMapping),E.push(M.numClippingPlanes),E.push(M.numClipIntersection),E.push(M.depthPacking)}function b(E,M){l.disableAll(),M.supportsVertexTextures&&l.enable(0),M.instancing&&l.enable(1),M.instancingColor&&l.enable(2),M.instancingMorph&&l.enable(3),M.matcap&&l.enable(4),M.envMap&&l.enable(5),M.normalMapObjectSpace&&l.enable(6),M.normalMapTangentSpace&&l.enable(7),M.clearcoat&&l.enable(8),M.iridescence&&l.enable(9),M.alphaTest&&l.enable(10),M.vertexColors&&l.enable(11),M.vertexAlphas&&l.enable(12),M.vertexUv1s&&l.enable(13),M.vertexUv2s&&l.enable(14),M.vertexUv3s&&l.enable(15),M.vertexTangents&&l.enable(16),M.anisotropy&&l.enable(17),M.alphaHash&&l.enable(18),M.batching&&l.enable(19),E.push(l.mask),l.disableAll(),M.fog&&l.enable(0),M.useFog&&l.enable(1),M.flatShading&&l.enable(2),M.logarithmicDepthBuffer&&l.enable(3),M.skinning&&l.enable(4),M.morphTargets&&l.enable(5),M.morphNormals&&l.enable(6),M.morphColors&&l.enable(7),M.premultipliedAlpha&&l.enable(8),M.shadowMapEnabled&&l.enable(9),M.useLegacyLights&&l.enable(10),M.doubleSided&&l.enable(11),M.flipSided&&l.enable(12),M.useDepthPacking&&l.enable(13),M.dithering&&l.enable(14),M.transmission&&l.enable(15),M.sheen&&l.enable(16),M.opaque&&l.enable(17),M.pointsUvs&&l.enable(18),M.decodeVideoTexture&&l.enable(19),M.alphaToCoverage&&l.enable(20),E.push(l.mask)}function A(E){const M=y[E.type];let O;if(M){const H=ji[M];O=Gw.clone(H.uniforms)}else O=E.uniforms;return O}function B(E,M){let O;for(let H=0,G=d.length;H<G;H++){const Y=d[H];if(Y.cacheKey===M){O=Y,++O.usedTimes;break}}return O===void 0&&(O=new eP(i,M,E,o),d.push(O)),O}function N(E){if(--E.usedTimes===0){const M=d.indexOf(E);d[M]=d[d.length-1],d.pop(),E.destroy()}}function D(E){u.remove(E)}function C(){u.dispose()}return{getParameters:_,getProgramCacheKey:v,getUniforms:A,acquireProgram:B,releaseProgram:N,releaseShaderCache:D,programs:d,dispose:C}}function sP(){let i=new WeakMap;function e(o){let a=i.get(o);return a===void 0&&(a={},i.set(o,a)),a}function t(o){i.delete(o)}function n(o,a,l){i.get(o)[a]=l}function r(){i=new WeakMap}return{get:e,remove:t,update:n,dispose:r}}function oP(i,e){return i.groupOrder!==e.groupOrder?i.groupOrder-e.groupOrder:i.renderOrder!==e.renderOrder?i.renderOrder-e.renderOrder:i.material.id!==e.material.id?i.material.id-e.material.id:i.z!==e.z?i.z-e.z:i.id-e.id}function kg(i,e){return i.groupOrder!==e.groupOrder?i.groupOrder-e.groupOrder:i.renderOrder!==e.renderOrder?i.renderOrder-e.renderOrder:i.z!==e.z?e.z-i.z:i.id-e.id}function Hg(){const i=[];let e=0;const t=[],n=[],r=[];function o(){e=0,t.length=0,n.length=0,r.length=0}function a(p,m,g,y,S,_){let v=i[e];return v===void 0?(v={id:p.id,object:p,geometry:m,material:g,groupOrder:y,renderOrder:p.renderOrder,z:S,group:_},i[e]=v):(v.id=p.id,v.object=p,v.geometry=m,v.material=g,v.groupOrder=y,v.renderOrder=p.renderOrder,v.z=S,v.group=_),e++,v}function l(p,m,g,y,S,_){const v=a(p,m,g,y,S,_);g.transmission>0?n.push(v):g.transparent===!0?r.push(v):t.push(v)}function u(p,m,g,y,S,_){const v=a(p,m,g,y,S,_);g.transmission>0?n.unshift(v):g.transparent===!0?r.unshift(v):t.unshift(v)}function h(p,m){t.length>1&&t.sort(p||oP),n.length>1&&n.sort(m||kg),r.length>1&&r.sort(m||kg)}function d(){for(let p=e,m=i.length;p<m;p++){const g=i[p];if(g.id===null)break;g.id=null,g.object=null,g.geometry=null,g.material=null,g.group=null}}return{opaque:t,transmissive:n,transparent:r,init:o,push:l,unshift:u,finish:d,sort:h}}function aP(){let i=new WeakMap;function e(n,r){const o=i.get(n);let a;return o===void 0?(a=new Hg,i.set(n,[a])):r>=o.length?(a=new Hg,o.push(a)):a=o[r],a}function t(){i=new WeakMap}return{get:e,dispose:t}}function cP(){const i={};return{get:function(e){if(i[e.id]!==void 0)return i[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new F,color:new Oe};break;case"SpotLight":t={position:new F,direction:new F,color:new Oe,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new F,color:new Oe,distance:0,decay:0};break;case"HemisphereLight":t={direction:new F,skyColor:new Oe,groundColor:new Oe};break;case"RectAreaLight":t={color:new Oe,position:new F,halfWidth:new F,halfHeight:new F};break}return i[e.id]=t,t}}}function lP(){const i={};return{get:function(e){if(i[e.id]!==void 0)return i[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Pe};break;case"SpotLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Pe};break;case"PointLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Pe,shadowCameraNear:1,shadowCameraFar:1e3};break}return i[e.id]=t,t}}}let uP=0;function hP(i,e){return(e.castShadow?2:0)-(i.castShadow?2:0)+(e.map?1:0)-(i.map?1:0)}function fP(i){const e=new cP,t=lP(),n={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let h=0;h<9;h++)n.probe.push(new F);const r=new F,o=new Qe,a=new Qe;function l(h,d){let p=0,m=0,g=0;for(let O=0;O<9;O++)n.probe[O].set(0,0,0);let y=0,S=0,_=0,v=0,R=0,b=0,A=0,B=0,N=0,D=0,C=0;h.sort(hP);const E=d===!0?Math.PI:1;for(let O=0,H=h.length;O<H;O++){const G=h[O],Y=G.color,$=G.intensity,re=G.distance,se=G.shadow&&G.shadow.map?G.shadow.map.texture:null;if(G.isAmbientLight)p+=Y.r*$*E,m+=Y.g*$*E,g+=Y.b*$*E;else if(G.isLightProbe){for(let K=0;K<9;K++)n.probe[K].addScaledVector(G.sh.coefficients[K],$);C++}else if(G.isDirectionalLight){const K=e.get(G);if(K.color.copy(G.color).multiplyScalar(G.intensity*E),G.castShadow){const ae=G.shadow,pe=t.get(G);pe.shadowBias=ae.bias,pe.shadowNormalBias=ae.normalBias,pe.shadowRadius=ae.radius,pe.shadowMapSize=ae.mapSize,n.directionalShadow[y]=pe,n.directionalShadowMap[y]=se,n.directionalShadowMatrix[y]=G.shadow.matrix,b++}n.directional[y]=K,y++}else if(G.isSpotLight){const K=e.get(G);K.position.setFromMatrixPosition(G.matrixWorld),K.color.copy(Y).multiplyScalar($*E),K.distance=re,K.coneCos=Math.cos(G.angle),K.penumbraCos=Math.cos(G.angle*(1-G.penumbra)),K.decay=G.decay,n.spot[_]=K;const ae=G.shadow;if(G.map&&(n.spotLightMap[N]=G.map,N++,ae.updateMatrices(G),G.castShadow&&D++),n.spotLightMatrix[_]=ae.matrix,G.castShadow){const pe=t.get(G);pe.shadowBias=ae.bias,pe.shadowNormalBias=ae.normalBias,pe.shadowRadius=ae.radius,pe.shadowMapSize=ae.mapSize,n.spotShadow[_]=pe,n.spotShadowMap[_]=se,B++}_++}else if(G.isRectAreaLight){const K=e.get(G);K.color.copy(Y).multiplyScalar($),K.halfWidth.set(G.width*.5,0,0),K.halfHeight.set(0,G.height*.5,0),n.rectArea[v]=K,v++}else if(G.isPointLight){const K=e.get(G);if(K.color.copy(G.color).multiplyScalar(G.intensity*E),K.distance=G.distance,K.decay=G.decay,G.castShadow){const ae=G.shadow,pe=t.get(G);pe.shadowBias=ae.bias,pe.shadowNormalBias=ae.normalBias,pe.shadowRadius=ae.radius,pe.shadowMapSize=ae.mapSize,pe.shadowCameraNear=ae.camera.near,pe.shadowCameraFar=ae.camera.far,n.pointShadow[S]=pe,n.pointShadowMap[S]=se,n.pointShadowMatrix[S]=G.shadow.matrix,A++}n.point[S]=K,S++}else if(G.isHemisphereLight){const K=e.get(G);K.skyColor.copy(G.color).multiplyScalar($*E),K.groundColor.copy(G.groundColor).multiplyScalar($*E),n.hemi[R]=K,R++}}v>0&&(i.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=be.LTC_FLOAT_1,n.rectAreaLTC2=be.LTC_FLOAT_2):(n.rectAreaLTC1=be.LTC_HALF_1,n.rectAreaLTC2=be.LTC_HALF_2)),n.ambient[0]=p,n.ambient[1]=m,n.ambient[2]=g;const M=n.hash;(M.directionalLength!==y||M.pointLength!==S||M.spotLength!==_||M.rectAreaLength!==v||M.hemiLength!==R||M.numDirectionalShadows!==b||M.numPointShadows!==A||M.numSpotShadows!==B||M.numSpotMaps!==N||M.numLightProbes!==C)&&(n.directional.length=y,n.spot.length=_,n.rectArea.length=v,n.point.length=S,n.hemi.length=R,n.directionalShadow.length=b,n.directionalShadowMap.length=b,n.pointShadow.length=A,n.pointShadowMap.length=A,n.spotShadow.length=B,n.spotShadowMap.length=B,n.directionalShadowMatrix.length=b,n.pointShadowMatrix.length=A,n.spotLightMatrix.length=B+N-D,n.spotLightMap.length=N,n.numSpotLightShadowsWithMaps=D,n.numLightProbes=C,M.directionalLength=y,M.pointLength=S,M.spotLength=_,M.rectAreaLength=v,M.hemiLength=R,M.numDirectionalShadows=b,M.numPointShadows=A,M.numSpotShadows=B,M.numSpotMaps=N,M.numLightProbes=C,n.version=uP++)}function u(h,d){let p=0,m=0,g=0,y=0,S=0;const _=d.matrixWorldInverse;for(let v=0,R=h.length;v<R;v++){const b=h[v];if(b.isDirectionalLight){const A=n.directional[p];A.direction.setFromMatrixPosition(b.matrixWorld),r.setFromMatrixPosition(b.target.matrixWorld),A.direction.sub(r),A.direction.transformDirection(_),p++}else if(b.isSpotLight){const A=n.spot[g];A.position.setFromMatrixPosition(b.matrixWorld),A.position.applyMatrix4(_),A.direction.setFromMatrixPosition(b.matrixWorld),r.setFromMatrixPosition(b.target.matrixWorld),A.direction.sub(r),A.direction.transformDirection(_),g++}else if(b.isRectAreaLight){const A=n.rectArea[y];A.position.setFromMatrixPosition(b.matrixWorld),A.position.applyMatrix4(_),a.identity(),o.copy(b.matrixWorld),o.premultiply(_),a.extractRotation(o),A.halfWidth.set(b.width*.5,0,0),A.halfHeight.set(0,b.height*.5,0),A.halfWidth.applyMatrix4(a),A.halfHeight.applyMatrix4(a),y++}else if(b.isPointLight){const A=n.point[m];A.position.setFromMatrixPosition(b.matrixWorld),A.position.applyMatrix4(_),m++}else if(b.isHemisphereLight){const A=n.hemi[S];A.direction.setFromMatrixPosition(b.matrixWorld),A.direction.transformDirection(_),S++}}}return{setup:l,setupView:u,state:n}}function Gg(i){const e=new fP(i),t=[],n=[];function r(){t.length=0,n.length=0}function o(d){t.push(d)}function a(d){n.push(d)}function l(d){e.setup(t,d)}function u(d){e.setupView(t,d)}return{init:r,state:{lightsArray:t,shadowsArray:n,lights:e,transmissionRenderTarget:null},setupLights:l,setupLightsView:u,pushLight:o,pushShadow:a}}function dP(i){let e=new WeakMap;function t(r,o=0){const a=e.get(r);let l;return a===void 0?(l=new Gg(i),e.set(r,[l])):o>=a.length?(l=new Gg(i),a.push(l)):l=a[o],l}function n(){e=new WeakMap}return{get:t,dispose:n}}class pP extends Ti{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=Jb,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=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}}class mP extends Ti{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}const gP=`void main() {
3745
+ `+K)}else H!==""?console.warn("THREE.WebGLProgram: Program Info Log:",H):(G===""||Y==="")&&(re=!1);re&&(O.diagnostics={runnable:$,programLog:H,vertexShader:{log:G,prefix:_},fragmentShader:{log:Y,prefix:v}})}r.deleteShader(B),r.deleteShader(N),C=new xl(r,S),E=VC(r,S)}let C;this.getUniforms=function(){return C===void 0&&D(this),C};let E;this.getAttributes=function(){return E===void 0&&D(this),E};let M=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return M===!1&&(M=r.getProgramParameter(S,NC)),M},this.destroy=function(){n.releaseStatesOfProgram(this),r.deleteProgram(S),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=OC++,this.cacheKey=e,this.usedTimes=1,this.program=S,this.vertexShader=B,this.fragmentShader=N,this}let tP=0;class nP{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const t=e.vertexShader,n=e.fragmentShader,r=this._getShaderStage(t),o=this._getShaderStage(n),a=this._getShaderCacheForMaterial(e);return a.has(r)===!1&&(a.add(r),r.usedTimes++),a.has(o)===!1&&(a.add(o),o.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const n of t)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const t=this.materialCache;let n=t.get(e);return n===void 0&&(n=new Set,t.set(e,n)),n}_getShaderStage(e){const t=this.shaderCache;let n=t.get(e);return n===void 0&&(n=new iP(e),t.set(e,n)),n}}class iP{constructor(e){this.id=tP++,this.code=e,this.usedTimes=0}}function rP(i,e,t,n,r,o,a){const l=new zf,u=new nP,h=new Set,d=[],p=r.logarithmicDepthBuffer,m=r.vertexTextures;let g=r.precision;const y={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"};function S(E){return h.add(E),E===0?"uv":`uv${E}`}function _(E,M,O,H,G){const Y=H.fog,$=G.geometry,re=E.isMeshStandardMaterial?H.environment:null,se=(E.isMeshStandardMaterial?t:e).get(E.envMap||re),K=se&&se.mapping===Bl?se.image.height:null,ae=y[E.type];E.precision!==null&&(g=r.getMaxPrecision(E.precision),g!==E.precision&&console.warn("THREE.WebGLProgram.getParameters:",E.precision,"not supported, using",g,"instead."));const pe=$.morphAttributes.position||$.morphAttributes.normal||$.morphAttributes.color,ve=pe!==void 0?pe.length:0;let ke=0;$.morphAttributes.position!==void 0&&(ke=1),$.morphAttributes.normal!==void 0&&(ke=2),$.morphAttributes.color!==void 0&&(ke=3);let Ze,te,fe,Ee;if(ae){const ln=ji[ae];Ze=ln.vertexShader,te=ln.fragmentShader}else Ze=E.vertexShader,te=E.fragmentShader,u.update(E),fe=u.getVertexShaderID(E),Ee=u.getFragmentShaderID(E);const Me=i.getRenderTarget(),ze=G.isInstancedMesh===!0,Ve=G.isBatchedMesh===!0,it=!!E.map,q=!!E.matcap,$e=!!se,Fe=!!E.aoMap,mt=!!E.lightMap,We=!!E.bumpMap,At=!!E.normalMap,z=!!E.displacementMap,P=!!E.emissiveMap,ie=!!E.metalnessMap,le=!!E.roughnessMap,de=E.anisotropy>0,ge=E.clearcoat>0,He=E.iridescence>0,_e=E.sheen>0,De=E.transmission>0,Xe=de&&!!E.anisotropyMap,xe=ge&&!!E.clearcoatMap,we=ge&&!!E.clearcoatNormalMap,Ke=ge&&!!E.clearcoatRoughnessMap,Le=He&&!!E.iridescenceMap,Ie=He&&!!E.iridescenceThicknessMap,ct=_e&&!!E.sheenColorMap,ft=_e&&!!E.sheenRoughnessMap,Et=!!E.specularMap,_t=!!E.specularColorMap,Tt=!!E.specularIntensityMap,Ne=De&&!!E.transmissionMap,T=De&&!!E.thicknessMap,Z=!!E.gradientMap,ce=!!E.alphaMap,ye=E.alphaTest>0,Re=!!E.alphaHash,vt=!!E.extensions;let dt=Ar;E.toneMapped&&(Me===null||Me.isXRRenderTarget===!0)&&(dt=i.toneMapping);const zt={shaderID:ae,shaderType:E.type,shaderName:E.name,vertexShader:Ze,fragmentShader:te,defines:E.defines,customVertexShaderID:fe,customFragmentShaderID:Ee,isRawShaderMaterial:E.isRawShaderMaterial===!0,glslVersion:E.glslVersion,precision:g,batching:Ve,instancing:ze,instancingColor:ze&&G.instanceColor!==null,instancingMorph:ze&&G.morphTexture!==null,supportsVertexTextures:m,outputColorSpace:Me===null?i.outputColorSpace:Me.isXRRenderTarget===!0?Me.texture.colorSpace:Tn,alphaToCoverage:!!E.alphaToCoverage,map:it,matcap:q,envMap:$e,envMapMode:$e&&se.mapping,envMapCubeUVHeight:K,aoMap:Fe,lightMap:mt,bumpMap:We,normalMap:At,displacementMap:m&&z,emissiveMap:P,normalMapObjectSpace:At&&E.normalMapType===ew,normalMapTangentSpace:At&&E.normalMapType===a0,metalnessMap:ie,roughnessMap:le,anisotropy:de,anisotropyMap:Xe,clearcoat:ge,clearcoatMap:xe,clearcoatNormalMap:we,clearcoatRoughnessMap:Ke,iridescence:He,iridescenceMap:Le,iridescenceThicknessMap:Ie,sheen:_e,sheenColorMap:ct,sheenRoughnessMap:ft,specularMap:Et,specularColorMap:_t,specularIntensityMap:Tt,transmission:De,transmissionMap:Ne,thicknessMap:T,gradientMap:Z,opaque:E.transparent===!1&&E.blending===Eo&&E.alphaToCoverage===!1,alphaMap:ce,alphaTest:ye,alphaHash:Re,combine:E.combine,mapUv:it&&S(E.map.channel),aoMapUv:Fe&&S(E.aoMap.channel),lightMapUv:mt&&S(E.lightMap.channel),bumpMapUv:We&&S(E.bumpMap.channel),normalMapUv:At&&S(E.normalMap.channel),displacementMapUv:z&&S(E.displacementMap.channel),emissiveMapUv:P&&S(E.emissiveMap.channel),metalnessMapUv:ie&&S(E.metalnessMap.channel),roughnessMapUv:le&&S(E.roughnessMap.channel),anisotropyMapUv:Xe&&S(E.anisotropyMap.channel),clearcoatMapUv:xe&&S(E.clearcoatMap.channel),clearcoatNormalMapUv:we&&S(E.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Ke&&S(E.clearcoatRoughnessMap.channel),iridescenceMapUv:Le&&S(E.iridescenceMap.channel),iridescenceThicknessMapUv:Ie&&S(E.iridescenceThicknessMap.channel),sheenColorMapUv:ct&&S(E.sheenColorMap.channel),sheenRoughnessMapUv:ft&&S(E.sheenRoughnessMap.channel),specularMapUv:Et&&S(E.specularMap.channel),specularColorMapUv:_t&&S(E.specularColorMap.channel),specularIntensityMapUv:Tt&&S(E.specularIntensityMap.channel),transmissionMapUv:Ne&&S(E.transmissionMap.channel),thicknessMapUv:T&&S(E.thicknessMap.channel),alphaMapUv:ce&&S(E.alphaMap.channel),vertexTangents:!!$.attributes.tangent&&(At||de),vertexColors:E.vertexColors,vertexAlphas:E.vertexColors===!0&&!!$.attributes.color&&$.attributes.color.itemSize===4,pointsUvs:G.isPoints===!0&&!!$.attributes.uv&&(it||ce),fog:!!Y,useFog:E.fog===!0,fogExp2:!!Y&&Y.isFogExp2,flatShading:E.flatShading===!0,sizeAttenuation:E.sizeAttenuation===!0,logarithmicDepthBuffer:p,skinning:G.isSkinnedMesh===!0,morphTargets:$.morphAttributes.position!==void 0,morphNormals:$.morphAttributes.normal!==void 0,morphColors:$.morphAttributes.color!==void 0,morphTargetsCount:ve,morphTextureStride:ke,numDirLights:M.directional.length,numPointLights:M.point.length,numSpotLights:M.spot.length,numSpotLightMaps:M.spotLightMap.length,numRectAreaLights:M.rectArea.length,numHemiLights:M.hemi.length,numDirLightShadows:M.directionalShadowMap.length,numPointLightShadows:M.pointShadowMap.length,numSpotLightShadows:M.spotShadowMap.length,numSpotLightShadowsWithMaps:M.numSpotLightShadowsWithMaps,numLightProbes:M.numLightProbes,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:E.dithering,shadowMapEnabled:i.shadowMap.enabled&&O.length>0,shadowMapType:i.shadowMap.type,toneMapping:dt,useLegacyLights:i._useLegacyLights,decodeVideoTexture:it&&E.map.isVideoTexture===!0&&Lt.getTransfer(E.map.colorSpace)===Wt,premultipliedAlpha:E.premultipliedAlpha,doubleSided:E.side===si,flipSided:E.side===Kn,useDepthPacking:E.depthPacking>=0,depthPacking:E.depthPacking||0,index0AttributeName:E.index0AttributeName,extensionClipCullDistance:vt&&E.extensions.clipCullDistance===!0&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:vt&&E.extensions.multiDraw===!0&&n.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:E.customProgramCacheKey()};return zt.vertexUv1s=h.has(1),zt.vertexUv2s=h.has(2),zt.vertexUv3s=h.has(3),h.clear(),zt}function v(E){const M=[];if(E.shaderID?M.push(E.shaderID):(M.push(E.customVertexShaderID),M.push(E.customFragmentShaderID)),E.defines!==void 0)for(const O in E.defines)M.push(O),M.push(E.defines[O]);return E.isRawShaderMaterial===!1&&(R(M,E),b(M,E),M.push(i.outputColorSpace)),M.push(E.customProgramCacheKey),M.join()}function R(E,M){E.push(M.precision),E.push(M.outputColorSpace),E.push(M.envMapMode),E.push(M.envMapCubeUVHeight),E.push(M.mapUv),E.push(M.alphaMapUv),E.push(M.lightMapUv),E.push(M.aoMapUv),E.push(M.bumpMapUv),E.push(M.normalMapUv),E.push(M.displacementMapUv),E.push(M.emissiveMapUv),E.push(M.metalnessMapUv),E.push(M.roughnessMapUv),E.push(M.anisotropyMapUv),E.push(M.clearcoatMapUv),E.push(M.clearcoatNormalMapUv),E.push(M.clearcoatRoughnessMapUv),E.push(M.iridescenceMapUv),E.push(M.iridescenceThicknessMapUv),E.push(M.sheenColorMapUv),E.push(M.sheenRoughnessMapUv),E.push(M.specularMapUv),E.push(M.specularColorMapUv),E.push(M.specularIntensityMapUv),E.push(M.transmissionMapUv),E.push(M.thicknessMapUv),E.push(M.combine),E.push(M.fogExp2),E.push(M.sizeAttenuation),E.push(M.morphTargetsCount),E.push(M.morphAttributeCount),E.push(M.numDirLights),E.push(M.numPointLights),E.push(M.numSpotLights),E.push(M.numSpotLightMaps),E.push(M.numHemiLights),E.push(M.numRectAreaLights),E.push(M.numDirLightShadows),E.push(M.numPointLightShadows),E.push(M.numSpotLightShadows),E.push(M.numSpotLightShadowsWithMaps),E.push(M.numLightProbes),E.push(M.shadowMapType),E.push(M.toneMapping),E.push(M.numClippingPlanes),E.push(M.numClipIntersection),E.push(M.depthPacking)}function b(E,M){l.disableAll(),M.supportsVertexTextures&&l.enable(0),M.instancing&&l.enable(1),M.instancingColor&&l.enable(2),M.instancingMorph&&l.enable(3),M.matcap&&l.enable(4),M.envMap&&l.enable(5),M.normalMapObjectSpace&&l.enable(6),M.normalMapTangentSpace&&l.enable(7),M.clearcoat&&l.enable(8),M.iridescence&&l.enable(9),M.alphaTest&&l.enable(10),M.vertexColors&&l.enable(11),M.vertexAlphas&&l.enable(12),M.vertexUv1s&&l.enable(13),M.vertexUv2s&&l.enable(14),M.vertexUv3s&&l.enable(15),M.vertexTangents&&l.enable(16),M.anisotropy&&l.enable(17),M.alphaHash&&l.enable(18),M.batching&&l.enable(19),E.push(l.mask),l.disableAll(),M.fog&&l.enable(0),M.useFog&&l.enable(1),M.flatShading&&l.enable(2),M.logarithmicDepthBuffer&&l.enable(3),M.skinning&&l.enable(4),M.morphTargets&&l.enable(5),M.morphNormals&&l.enable(6),M.morphColors&&l.enable(7),M.premultipliedAlpha&&l.enable(8),M.shadowMapEnabled&&l.enable(9),M.useLegacyLights&&l.enable(10),M.doubleSided&&l.enable(11),M.flipSided&&l.enable(12),M.useDepthPacking&&l.enable(13),M.dithering&&l.enable(14),M.transmission&&l.enable(15),M.sheen&&l.enable(16),M.opaque&&l.enable(17),M.pointsUvs&&l.enable(18),M.decodeVideoTexture&&l.enable(19),M.alphaToCoverage&&l.enable(20),E.push(l.mask)}function A(E){const M=y[E.type];let O;if(M){const H=ji[M];O=Gw.clone(H.uniforms)}else O=E.uniforms;return O}function B(E,M){let O;for(let H=0,G=d.length;H<G;H++){const Y=d[H];if(Y.cacheKey===M){O=Y,++O.usedTimes;break}}return O===void 0&&(O=new eP(i,M,E,o),d.push(O)),O}function N(E){if(--E.usedTimes===0){const M=d.indexOf(E);d[M]=d[d.length-1],d.pop(),E.destroy()}}function D(E){u.remove(E)}function C(){u.dispose()}return{getParameters:_,getProgramCacheKey:v,getUniforms:A,acquireProgram:B,releaseProgram:N,releaseShaderCache:D,programs:d,dispose:C}}function sP(){let i=new WeakMap;function e(o){let a=i.get(o);return a===void 0&&(a={},i.set(o,a)),a}function t(o){i.delete(o)}function n(o,a,l){i.get(o)[a]=l}function r(){i=new WeakMap}return{get:e,remove:t,update:n,dispose:r}}function oP(i,e){return i.groupOrder!==e.groupOrder?i.groupOrder-e.groupOrder:i.renderOrder!==e.renderOrder?i.renderOrder-e.renderOrder:i.material.id!==e.material.id?i.material.id-e.material.id:i.z!==e.z?i.z-e.z:i.id-e.id}function kg(i,e){return i.groupOrder!==e.groupOrder?i.groupOrder-e.groupOrder:i.renderOrder!==e.renderOrder?i.renderOrder-e.renderOrder:i.z!==e.z?e.z-i.z:i.id-e.id}function Hg(){const i=[];let e=0;const t=[],n=[],r=[];function o(){e=0,t.length=0,n.length=0,r.length=0}function a(p,m,g,y,S,_){let v=i[e];return v===void 0?(v={id:p.id,object:p,geometry:m,material:g,groupOrder:y,renderOrder:p.renderOrder,z:S,group:_},i[e]=v):(v.id=p.id,v.object=p,v.geometry=m,v.material=g,v.groupOrder=y,v.renderOrder=p.renderOrder,v.z=S,v.group=_),e++,v}function l(p,m,g,y,S,_){const v=a(p,m,g,y,S,_);g.transmission>0?n.push(v):g.transparent===!0?r.push(v):t.push(v)}function u(p,m,g,y,S,_){const v=a(p,m,g,y,S,_);g.transmission>0?n.unshift(v):g.transparent===!0?r.unshift(v):t.unshift(v)}function h(p,m){t.length>1&&t.sort(p||oP),n.length>1&&n.sort(m||kg),r.length>1&&r.sort(m||kg)}function d(){for(let p=e,m=i.length;p<m;p++){const g=i[p];if(g.id===null)break;g.id=null,g.object=null,g.geometry=null,g.material=null,g.group=null}}return{opaque:t,transmissive:n,transparent:r,init:o,push:l,unshift:u,finish:d,sort:h}}function aP(){let i=new WeakMap;function e(n,r){const o=i.get(n);let a;return o===void 0?(a=new Hg,i.set(n,[a])):r>=o.length?(a=new Hg,o.push(a)):a=o[r],a}function t(){i=new WeakMap}return{get:e,dispose:t}}function cP(){const i={};return{get:function(e){if(i[e.id]!==void 0)return i[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new F,color:new Oe};break;case"SpotLight":t={position:new F,direction:new F,color:new Oe,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new F,color:new Oe,distance:0,decay:0};break;case"HemisphereLight":t={direction:new F,skyColor:new Oe,groundColor:new Oe};break;case"RectAreaLight":t={color:new Oe,position:new F,halfWidth:new F,halfHeight:new F};break}return i[e.id]=t,t}}}function lP(){const i={};return{get:function(e){if(i[e.id]!==void 0)return i[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Pe};break;case"SpotLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Pe};break;case"PointLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Pe,shadowCameraNear:1,shadowCameraFar:1e3};break}return i[e.id]=t,t}}}let uP=0;function hP(i,e){return(e.castShadow?2:0)-(i.castShadow?2:0)+(e.map?1:0)-(i.map?1:0)}function fP(i){const e=new cP,t=lP(),n={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let h=0;h<9;h++)n.probe.push(new F);const r=new F,o=new Qe,a=new Qe;function l(h,d){let p=0,m=0,g=0;for(let O=0;O<9;O++)n.probe[O].set(0,0,0);let y=0,S=0,_=0,v=0,R=0,b=0,A=0,B=0,N=0,D=0,C=0;h.sort(hP);const E=d===!0?Math.PI:1;for(let O=0,H=h.length;O<H;O++){const G=h[O],Y=G.color,$=G.intensity,re=G.distance,se=G.shadow&&G.shadow.map?G.shadow.map.texture:null;if(G.isAmbientLight)p+=Y.r*$*E,m+=Y.g*$*E,g+=Y.b*$*E;else if(G.isLightProbe){for(let K=0;K<9;K++)n.probe[K].addScaledVector(G.sh.coefficients[K],$);C++}else if(G.isDirectionalLight){const K=e.get(G);if(K.color.copy(G.color).multiplyScalar(G.intensity*E),G.castShadow){const ae=G.shadow,pe=t.get(G);pe.shadowBias=ae.bias,pe.shadowNormalBias=ae.normalBias,pe.shadowRadius=ae.radius,pe.shadowMapSize=ae.mapSize,n.directionalShadow[y]=pe,n.directionalShadowMap[y]=se,n.directionalShadowMatrix[y]=G.shadow.matrix,b++}n.directional[y]=K,y++}else if(G.isSpotLight){const K=e.get(G);K.position.setFromMatrixPosition(G.matrixWorld),K.color.copy(Y).multiplyScalar($*E),K.distance=re,K.coneCos=Math.cos(G.angle),K.penumbraCos=Math.cos(G.angle*(1-G.penumbra)),K.decay=G.decay,n.spot[_]=K;const ae=G.shadow;if(G.map&&(n.spotLightMap[N]=G.map,N++,ae.updateMatrices(G),G.castShadow&&D++),n.spotLightMatrix[_]=ae.matrix,G.castShadow){const pe=t.get(G);pe.shadowBias=ae.bias,pe.shadowNormalBias=ae.normalBias,pe.shadowRadius=ae.radius,pe.shadowMapSize=ae.mapSize,n.spotShadow[_]=pe,n.spotShadowMap[_]=se,B++}_++}else if(G.isRectAreaLight){const K=e.get(G);K.color.copy(Y).multiplyScalar($),K.halfWidth.set(G.width*.5,0,0),K.halfHeight.set(0,G.height*.5,0),n.rectArea[v]=K,v++}else if(G.isPointLight){const K=e.get(G);if(K.color.copy(G.color).multiplyScalar(G.intensity*E),K.distance=G.distance,K.decay=G.decay,G.castShadow){const ae=G.shadow,pe=t.get(G);pe.shadowBias=ae.bias,pe.shadowNormalBias=ae.normalBias,pe.shadowRadius=ae.radius,pe.shadowMapSize=ae.mapSize,pe.shadowCameraNear=ae.camera.near,pe.shadowCameraFar=ae.camera.far,n.pointShadow[S]=pe,n.pointShadowMap[S]=se,n.pointShadowMatrix[S]=G.shadow.matrix,A++}n.point[S]=K,S++}else if(G.isHemisphereLight){const K=e.get(G);K.skyColor.copy(G.color).multiplyScalar($*E),K.groundColor.copy(G.groundColor).multiplyScalar($*E),n.hemi[R]=K,R++}}v>0&&(i.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=be.LTC_FLOAT_1,n.rectAreaLTC2=be.LTC_FLOAT_2):(n.rectAreaLTC1=be.LTC_HALF_1,n.rectAreaLTC2=be.LTC_HALF_2)),n.ambient[0]=p,n.ambient[1]=m,n.ambient[2]=g;const M=n.hash;(M.directionalLength!==y||M.pointLength!==S||M.spotLength!==_||M.rectAreaLength!==v||M.hemiLength!==R||M.numDirectionalShadows!==b||M.numPointShadows!==A||M.numSpotShadows!==B||M.numSpotMaps!==N||M.numLightProbes!==C)&&(n.directional.length=y,n.spot.length=_,n.rectArea.length=v,n.point.length=S,n.hemi.length=R,n.directionalShadow.length=b,n.directionalShadowMap.length=b,n.pointShadow.length=A,n.pointShadowMap.length=A,n.spotShadow.length=B,n.spotShadowMap.length=B,n.directionalShadowMatrix.length=b,n.pointShadowMatrix.length=A,n.spotLightMatrix.length=B+N-D,n.spotLightMap.length=N,n.numSpotLightShadowsWithMaps=D,n.numLightProbes=C,M.directionalLength=y,M.pointLength=S,M.spotLength=_,M.rectAreaLength=v,M.hemiLength=R,M.numDirectionalShadows=b,M.numPointShadows=A,M.numSpotShadows=B,M.numSpotMaps=N,M.numLightProbes=C,n.version=uP++)}function u(h,d){let p=0,m=0,g=0,y=0,S=0;const _=d.matrixWorldInverse;for(let v=0,R=h.length;v<R;v++){const b=h[v];if(b.isDirectionalLight){const A=n.directional[p];A.direction.setFromMatrixPosition(b.matrixWorld),r.setFromMatrixPosition(b.target.matrixWorld),A.direction.sub(r),A.direction.transformDirection(_),p++}else if(b.isSpotLight){const A=n.spot[g];A.position.setFromMatrixPosition(b.matrixWorld),A.position.applyMatrix4(_),A.direction.setFromMatrixPosition(b.matrixWorld),r.setFromMatrixPosition(b.target.matrixWorld),A.direction.sub(r),A.direction.transformDirection(_),g++}else if(b.isRectAreaLight){const A=n.rectArea[y];A.position.setFromMatrixPosition(b.matrixWorld),A.position.applyMatrix4(_),a.identity(),o.copy(b.matrixWorld),o.premultiply(_),a.extractRotation(o),A.halfWidth.set(b.width*.5,0,0),A.halfHeight.set(0,b.height*.5,0),A.halfWidth.applyMatrix4(a),A.halfHeight.applyMatrix4(a),y++}else if(b.isPointLight){const A=n.point[m];A.position.setFromMatrixPosition(b.matrixWorld),A.position.applyMatrix4(_),m++}else if(b.isHemisphereLight){const A=n.hemi[S];A.direction.setFromMatrixPosition(b.matrixWorld),A.direction.transformDirection(_),S++}}}return{setup:l,setupView:u,state:n}}function Gg(i){const e=new fP(i),t=[],n=[];function r(){t.length=0,n.length=0}function o(d){t.push(d)}function a(d){n.push(d)}function l(d){e.setup(t,d)}function u(d){e.setupView(t,d)}return{init:r,state:{lightsArray:t,shadowsArray:n,lights:e,transmissionRenderTarget:null},setupLights:l,setupLightsView:u,pushLight:o,pushShadow:a}}function dP(i){let e=new WeakMap;function t(r,o=0){const a=e.get(r);let l;return a===void 0?(l=new Gg(i),e.set(r,[l])):o>=a.length?(l=new Gg(i),a.push(l)):l=a[o],l}function n(){e=new WeakMap}return{get:t,dispose:n}}class pP extends Ti{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=Jb,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=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}}class mP extends Ti{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}const gP=`void main() {
3746
3746
  gl_Position = vec4( position, 1.0 );
3747
3747
  }`,_P=`uniform sampler2D shadow_pass;
3748
3748
  uniform vec2 resolution;
@@ -3770,7 +3770,7 @@ void main() {
3770
3770
  squared_mean = squared_mean / samples;
3771
3771
  float std_dev = sqrt( squared_mean - mean * mean );
3772
3772
  gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
3773
- }`;function vP(i,e,t){let n=new zf;const r=new Pe,o=new Pe,a=new Ut,l=new pP({depthPacking:Qb}),u=new mP,h={},d=t.maxTextureSize,p={[tr]:Kn,[Kn]:tr,[si]:si},m=new Rr({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Pe},radius:{value:4}},vertexShader:gP,fragmentShader:_P}),g=m.clone();g.defines.HORIZONTAL_PASS=1;const y=new tn;y.setAttribute("position",new Nt(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const S=new Se(y,m),_=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=j_;let v=this.type;this.render=function(N,D,C){if(_.enabled===!1||_.autoUpdate===!1&&_.needsUpdate===!1||N.length===0)return;const E=i.getRenderTarget(),M=i.getActiveCubeFace(),O=i.getActiveMipmapLevel(),H=i.state;H.setBlending(Jr),H.buffers.color.setClear(1,1,1,1),H.buffers.depth.setTest(!0),H.setScissorTest(!1);const G=v!==Tr&&this.type===Tr,Y=v===Tr&&this.type!==Tr;for(let $=0,re=N.length;$<re;$++){const se=N[$],K=se.shadow;if(K===void 0){console.warn("THREE.WebGLShadowMap:",se,"has no shadow.");continue}if(K.autoUpdate===!1&&K.needsUpdate===!1)continue;r.copy(K.mapSize);const ae=K.getFrameExtents();if(r.multiply(ae),o.copy(K.mapSize),(r.x>d||r.y>d)&&(r.x>d&&(o.x=Math.floor(d/ae.x),r.x=o.x*ae.x,K.mapSize.x=o.x),r.y>d&&(o.y=Math.floor(d/ae.y),r.y=o.y*ae.y,K.mapSize.y=o.y)),K.map===null||G===!0||Y===!0){const ve=this.type!==Tr?{minFilter:Nn,magFilter:Nn}:{};K.map!==null&&K.map.dispose(),K.map=new Rs(r.x,r.y,ve),K.map.texture.name=se.name+".shadowMap",K.camera.updateProjectionMatrix()}i.setRenderTarget(K.map),i.clear();const pe=K.getViewportCount();for(let ve=0;ve<pe;ve++){const ke=K.getViewport(ve);a.set(o.x*ke.x,o.y*ke.y,o.x*ke.z,o.y*ke.w),H.viewport(a),K.updateMatrices(se,ve),n=K.getFrustum(),A(D,C,K.camera,se,this.type)}K.isPointLightShadow!==!0&&this.type===Tr&&R(K,C),K.needsUpdate=!1}v=this.type,_.needsUpdate=!1,i.setRenderTarget(E,M,O)};function R(N,D){const C=e.update(S);m.defines.VSM_SAMPLES!==N.blurSamples&&(m.defines.VSM_SAMPLES=N.blurSamples,g.defines.VSM_SAMPLES=N.blurSamples,m.needsUpdate=!0,g.needsUpdate=!0),N.mapPass===null&&(N.mapPass=new Rs(r.x,r.y)),m.uniforms.shadow_pass.value=N.map.texture,m.uniforms.resolution.value=N.mapSize,m.uniforms.radius.value=N.radius,i.setRenderTarget(N.mapPass),i.clear(),i.renderBufferDirect(D,null,C,m,S,null),g.uniforms.shadow_pass.value=N.mapPass.texture,g.uniforms.resolution.value=N.mapSize,g.uniforms.radius.value=N.radius,i.setRenderTarget(N.map),i.clear(),i.renderBufferDirect(D,null,C,g,S,null)}function b(N,D,C,E){let M=null;const O=C.isPointLight===!0?N.customDistanceMaterial:N.customDepthMaterial;if(O!==void 0)M=O;else if(M=C.isPointLight===!0?u:l,i.localClippingEnabled&&D.clipShadows===!0&&Array.isArray(D.clippingPlanes)&&D.clippingPlanes.length!==0||D.displacementMap&&D.displacementScale!==0||D.alphaMap&&D.alphaTest>0||D.map&&D.alphaTest>0){const H=M.uuid,G=D.uuid;let Y=h[H];Y===void 0&&(Y={},h[H]=Y);let $=Y[G];$===void 0&&($=M.clone(),Y[G]=$,D.addEventListener("dispose",B)),M=$}if(M.visible=D.visible,M.wireframe=D.wireframe,E===Tr?M.side=D.shadowSide!==null?D.shadowSide:D.side:M.side=D.shadowSide!==null?D.shadowSide:p[D.side],M.alphaMap=D.alphaMap,M.alphaTest=D.alphaTest,M.map=D.map,M.clipShadows=D.clipShadows,M.clippingPlanes=D.clippingPlanes,M.clipIntersection=D.clipIntersection,M.displacementMap=D.displacementMap,M.displacementScale=D.displacementScale,M.displacementBias=D.displacementBias,M.wireframeLinewidth=D.wireframeLinewidth,M.linewidth=D.linewidth,C.isPointLight===!0&&M.isMeshDistanceMaterial===!0){const H=i.properties.get(M);H.light=C}return M}function A(N,D,C,E,M){if(N.visible===!1)return;if(N.layers.test(D.layers)&&(N.isMesh||N.isLine||N.isPoints)&&(N.castShadow||N.receiveShadow&&M===Tr)&&(!N.frustumCulled||n.intersectsObject(N))){N.modelViewMatrix.multiplyMatrices(C.matrixWorldInverse,N.matrixWorld);const G=e.update(N),Y=N.material;if(Array.isArray(Y)){const $=G.groups;for(let re=0,se=$.length;re<se;re++){const K=$[re],ae=Y[K.materialIndex];if(ae&&ae.visible){const pe=b(N,ae,E,M);N.onBeforeShadow(i,N,D,C,G,pe,K),i.renderBufferDirect(C,null,G,pe,N,K),N.onAfterShadow(i,N,D,C,G,pe,K)}}}else if(Y.visible){const $=b(N,Y,E,M);N.onBeforeShadow(i,N,D,C,G,$,null),i.renderBufferDirect(C,null,G,$,N,null),N.onAfterShadow(i,N,D,C,G,$,null)}}const H=N.children;for(let G=0,Y=H.length;G<Y;G++)A(H[G],D,C,E,M)}function B(N){N.target.removeEventListener("dispose",B);for(const C in h){const E=h[C],M=N.target.uuid;M in E&&(E[M].dispose(),delete E[M])}}}function xP(i){function e(){let T=!1;const Z=new Ut;let ce=null;const ye=new Ut(0,0,0,0);return{setMask:function(Re){ce!==Re&&!T&&(i.colorMask(Re,Re,Re,Re),ce=Re)},setLocked:function(Re){T=Re},setClear:function(Re,vt,dt,zt,ln){ln===!0&&(Re*=zt,vt*=zt,dt*=zt),Z.set(Re,vt,dt,zt),ye.equals(Z)===!1&&(i.clearColor(Re,vt,dt,zt),ye.copy(Z))},reset:function(){T=!1,ce=null,ye.set(-1,0,0,0)}}}function t(){let T=!1,Z=null,ce=null,ye=null;return{setTest:function(Re){Re?Ee(i.DEPTH_TEST):Me(i.DEPTH_TEST)},setMask:function(Re){Z!==Re&&!T&&(i.depthMask(Re),Z=Re)},setFunc:function(Re){if(ce!==Re){switch(Re){case Tb:i.depthFunc(i.NEVER);break;case bb:i.depthFunc(i.ALWAYS);break;case wb:i.depthFunc(i.LESS);break;case Tl:i.depthFunc(i.LEQUAL);break;case Ab:i.depthFunc(i.EQUAL);break;case Rb:i.depthFunc(i.GEQUAL);break;case Cb:i.depthFunc(i.GREATER);break;case Pb:i.depthFunc(i.NOTEQUAL);break;default:i.depthFunc(i.LEQUAL)}ce=Re}},setLocked:function(Re){T=Re},setClear:function(Re){ye!==Re&&(i.clearDepth(Re),ye=Re)},reset:function(){T=!1,Z=null,ce=null,ye=null}}}function n(){let T=!1,Z=null,ce=null,ye=null,Re=null,vt=null,dt=null,zt=null,ln=null;return{setTest:function(Rt){T||(Rt?Ee(i.STENCIL_TEST):Me(i.STENCIL_TEST))},setMask:function(Rt){Z!==Rt&&!T&&(i.stencilMask(Rt),Z=Rt)},setFunc:function(Rt,Zt,Jt){(ce!==Rt||ye!==Zt||Re!==Jt)&&(i.stencilFunc(Rt,Zt,Jt),ce=Rt,ye=Zt,Re=Jt)},setOp:function(Rt,Zt,Jt){(vt!==Rt||dt!==Zt||zt!==Jt)&&(i.stencilOp(Rt,Zt,Jt),vt=Rt,dt=Zt,zt=Jt)},setLocked:function(Rt){T=Rt},setClear:function(Rt){ln!==Rt&&(i.clearStencil(Rt),ln=Rt)},reset:function(){T=!1,Z=null,ce=null,ye=null,Re=null,vt=null,dt=null,zt=null,ln=null}}}const r=new e,o=new t,a=new n,l=new WeakMap,u=new WeakMap;let h={},d={},p=new WeakMap,m=[],g=null,y=!1,S=null,_=null,v=null,R=null,b=null,A=null,B=null,N=new Oe(0,0,0),D=0,C=!1,E=null,M=null,O=null,H=null,G=null;const Y=i.getParameter(i.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let $=!1,re=0;const se=i.getParameter(i.VERSION);se.indexOf("WebGL")!==-1?(re=parseFloat(/^WebGL (\d)/.exec(se)[1]),$=re>=1):se.indexOf("OpenGL ES")!==-1&&(re=parseFloat(/^OpenGL ES (\d)/.exec(se)[1]),$=re>=2);let K=null,ae={};const pe=i.getParameter(i.SCISSOR_BOX),ve=i.getParameter(i.VIEWPORT),ke=new Ut().fromArray(pe),Ze=new Ut().fromArray(ve);function te(T,Z,ce,ye){const Re=new Uint8Array(4),vt=i.createTexture();i.bindTexture(T,vt),i.texParameteri(T,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(T,i.TEXTURE_MAG_FILTER,i.NEAREST);for(let dt=0;dt<ce;dt++)T===i.TEXTURE_3D||T===i.TEXTURE_2D_ARRAY?i.texImage3D(Z,0,i.RGBA,1,1,ye,0,i.RGBA,i.UNSIGNED_BYTE,Re):i.texImage2D(Z+dt,0,i.RGBA,1,1,0,i.RGBA,i.UNSIGNED_BYTE,Re);return vt}const fe={};fe[i.TEXTURE_2D]=te(i.TEXTURE_2D,i.TEXTURE_2D,1),fe[i.TEXTURE_CUBE_MAP]=te(i.TEXTURE_CUBE_MAP,i.TEXTURE_CUBE_MAP_POSITIVE_X,6),fe[i.TEXTURE_2D_ARRAY]=te(i.TEXTURE_2D_ARRAY,i.TEXTURE_2D_ARRAY,1,1),fe[i.TEXTURE_3D]=te(i.TEXTURE_3D,i.TEXTURE_3D,1,1),r.setClear(0,0,0,1),o.setClear(1),a.setClear(0),Ee(i.DEPTH_TEST),o.setFunc(Tl),We(!1),At(ym),Ee(i.CULL_FACE),Fe(Jr);function Ee(T){h[T]!==!0&&(i.enable(T),h[T]=!0)}function Me(T){h[T]!==!1&&(i.disable(T),h[T]=!1)}function ze(T,Z){return d[T]!==Z?(i.bindFramebuffer(T,Z),d[T]=Z,T===i.DRAW_FRAMEBUFFER&&(d[i.FRAMEBUFFER]=Z),T===i.FRAMEBUFFER&&(d[i.DRAW_FRAMEBUFFER]=Z),!0):!1}function Ve(T,Z){let ce=m,ye=!1;if(T){ce=p.get(Z),ce===void 0&&(ce=[],p.set(Z,ce));const Re=T.textures;if(ce.length!==Re.length||ce[0]!==i.COLOR_ATTACHMENT0){for(let vt=0,dt=Re.length;vt<dt;vt++)ce[vt]=i.COLOR_ATTACHMENT0+vt;ce.length=Re.length,ye=!0}}else ce[0]!==i.BACK&&(ce[0]=i.BACK,ye=!0);ye&&i.drawBuffers(ce)}function it(T){return g!==T?(i.useProgram(T),g=T,!0):!1}const q={[Ts]:i.FUNC_ADD,[ab]:i.FUNC_SUBTRACT,[cb]:i.FUNC_REVERSE_SUBTRACT};q[lb]=i.MIN,q[ub]=i.MAX;const $e={[hb]:i.ZERO,[fb]:i.ONE,[db]:i.SRC_COLOR,[rf]:i.SRC_ALPHA,[xb]:i.SRC_ALPHA_SATURATE,[_b]:i.DST_COLOR,[mb]:i.DST_ALPHA,[pb]:i.ONE_MINUS_SRC_COLOR,[sf]:i.ONE_MINUS_SRC_ALPHA,[vb]:i.ONE_MINUS_DST_COLOR,[gb]:i.ONE_MINUS_DST_ALPHA,[yb]:i.CONSTANT_COLOR,[Mb]:i.ONE_MINUS_CONSTANT_COLOR,[Sb]:i.CONSTANT_ALPHA,[Eb]:i.ONE_MINUS_CONSTANT_ALPHA};function Fe(T,Z,ce,ye,Re,vt,dt,zt,ln,Rt){if(T===Jr){y===!0&&(Me(i.BLEND),y=!1);return}if(y===!1&&(Ee(i.BLEND),y=!0),T!==ob){if(T!==S||Rt!==C){if((_!==Ts||b!==Ts)&&(i.blendEquation(i.FUNC_ADD),_=Ts,b=Ts),Rt)switch(T){case Eo:i.blendFuncSeparate(i.ONE,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case Mm:i.blendFunc(i.ONE,i.ONE);break;case Sm:i.blendFuncSeparate(i.ZERO,i.ONE_MINUS_SRC_COLOR,i.ZERO,i.ONE);break;case Em:i.blendFuncSeparate(i.ZERO,i.SRC_COLOR,i.ZERO,i.SRC_ALPHA);break;default:console.error("THREE.WebGLState: Invalid blending: ",T);break}else switch(T){case Eo:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case Mm:i.blendFunc(i.SRC_ALPHA,i.ONE);break;case Sm:i.blendFuncSeparate(i.ZERO,i.ONE_MINUS_SRC_COLOR,i.ZERO,i.ONE);break;case Em:i.blendFunc(i.ZERO,i.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",T);break}v=null,R=null,A=null,B=null,N.set(0,0,0),D=0,S=T,C=Rt}return}Re=Re||Z,vt=vt||ce,dt=dt||ye,(Z!==_||Re!==b)&&(i.blendEquationSeparate(q[Z],q[Re]),_=Z,b=Re),(ce!==v||ye!==R||vt!==A||dt!==B)&&(i.blendFuncSeparate($e[ce],$e[ye],$e[vt],$e[dt]),v=ce,R=ye,A=vt,B=dt),(zt.equals(N)===!1||ln!==D)&&(i.blendColor(zt.r,zt.g,zt.b,ln),N.copy(zt),D=ln),S=T,C=!1}function mt(T,Z){T.side===si?Me(i.CULL_FACE):Ee(i.CULL_FACE);let ce=T.side===Kn;Z&&(ce=!ce),We(ce),T.blending===Eo&&T.transparent===!1?Fe(Jr):Fe(T.blending,T.blendEquation,T.blendSrc,T.blendDst,T.blendEquationAlpha,T.blendSrcAlpha,T.blendDstAlpha,T.blendColor,T.blendAlpha,T.premultipliedAlpha),o.setFunc(T.depthFunc),o.setTest(T.depthTest),o.setMask(T.depthWrite),r.setMask(T.colorWrite);const ye=T.stencilWrite;a.setTest(ye),ye&&(a.setMask(T.stencilWriteMask),a.setFunc(T.stencilFunc,T.stencilRef,T.stencilFuncMask),a.setOp(T.stencilFail,T.stencilZFail,T.stencilZPass)),P(T.polygonOffset,T.polygonOffsetFactor,T.polygonOffsetUnits),T.alphaToCoverage===!0?Ee(i.SAMPLE_ALPHA_TO_COVERAGE):Me(i.SAMPLE_ALPHA_TO_COVERAGE)}function We(T){E!==T&&(T?i.frontFace(i.CW):i.frontFace(i.CCW),E=T)}function At(T){T!==rb?(Ee(i.CULL_FACE),T!==M&&(T===ym?i.cullFace(i.BACK):T===sb?i.cullFace(i.FRONT):i.cullFace(i.FRONT_AND_BACK))):Me(i.CULL_FACE),M=T}function z(T){T!==O&&($&&i.lineWidth(T),O=T)}function P(T,Z,ce){T?(Ee(i.POLYGON_OFFSET_FILL),(H!==Z||G!==ce)&&(i.polygonOffset(Z,ce),H=Z,G=ce)):Me(i.POLYGON_OFFSET_FILL)}function ie(T){T?Ee(i.SCISSOR_TEST):Me(i.SCISSOR_TEST)}function le(T){T===void 0&&(T=i.TEXTURE0+Y-1),K!==T&&(i.activeTexture(T),K=T)}function de(T,Z,ce){ce===void 0&&(K===null?ce=i.TEXTURE0+Y-1:ce=K);let ye=ae[ce];ye===void 0&&(ye={type:void 0,texture:void 0},ae[ce]=ye),(ye.type!==T||ye.texture!==Z)&&(K!==ce&&(i.activeTexture(ce),K=ce),i.bindTexture(T,Z||fe[T]),ye.type=T,ye.texture=Z)}function ge(){const T=ae[K];T!==void 0&&T.type!==void 0&&(i.bindTexture(T.type,null),T.type=void 0,T.texture=void 0)}function He(){try{i.compressedTexImage2D.apply(i,arguments)}catch(T){console.error("THREE.WebGLState:",T)}}function _e(){try{i.compressedTexImage3D.apply(i,arguments)}catch(T){console.error("THREE.WebGLState:",T)}}function De(){try{i.texSubImage2D.apply(i,arguments)}catch(T){console.error("THREE.WebGLState:",T)}}function Xe(){try{i.texSubImage3D.apply(i,arguments)}catch(T){console.error("THREE.WebGLState:",T)}}function xe(){try{i.compressedTexSubImage2D.apply(i,arguments)}catch(T){console.error("THREE.WebGLState:",T)}}function we(){try{i.compressedTexSubImage3D.apply(i,arguments)}catch(T){console.error("THREE.WebGLState:",T)}}function Ke(){try{i.texStorage2D.apply(i,arguments)}catch(T){console.error("THREE.WebGLState:",T)}}function Le(){try{i.texStorage3D.apply(i,arguments)}catch(T){console.error("THREE.WebGLState:",T)}}function Ie(){try{i.texImage2D.apply(i,arguments)}catch(T){console.error("THREE.WebGLState:",T)}}function ct(){try{i.texImage3D.apply(i,arguments)}catch(T){console.error("THREE.WebGLState:",T)}}function ft(T){ke.equals(T)===!1&&(i.scissor(T.x,T.y,T.z,T.w),ke.copy(T))}function Et(T){Ze.equals(T)===!1&&(i.viewport(T.x,T.y,T.z,T.w),Ze.copy(T))}function _t(T,Z){let ce=u.get(Z);ce===void 0&&(ce=new WeakMap,u.set(Z,ce));let ye=ce.get(T);ye===void 0&&(ye=i.getUniformBlockIndex(Z,T.name),ce.set(T,ye))}function Tt(T,Z){const ye=u.get(Z).get(T);l.get(Z)!==ye&&(i.uniformBlockBinding(Z,ye,T.__bindingPointIndex),l.set(Z,ye))}function Ne(){i.disable(i.BLEND),i.disable(i.CULL_FACE),i.disable(i.DEPTH_TEST),i.disable(i.POLYGON_OFFSET_FILL),i.disable(i.SCISSOR_TEST),i.disable(i.STENCIL_TEST),i.disable(i.SAMPLE_ALPHA_TO_COVERAGE),i.blendEquation(i.FUNC_ADD),i.blendFunc(i.ONE,i.ZERO),i.blendFuncSeparate(i.ONE,i.ZERO,i.ONE,i.ZERO),i.blendColor(0,0,0,0),i.colorMask(!0,!0,!0,!0),i.clearColor(0,0,0,0),i.depthMask(!0),i.depthFunc(i.LESS),i.clearDepth(1),i.stencilMask(4294967295),i.stencilFunc(i.ALWAYS,0,4294967295),i.stencilOp(i.KEEP,i.KEEP,i.KEEP),i.clearStencil(0),i.cullFace(i.BACK),i.frontFace(i.CCW),i.polygonOffset(0,0),i.activeTexture(i.TEXTURE0),i.bindFramebuffer(i.FRAMEBUFFER,null),i.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),i.bindFramebuffer(i.READ_FRAMEBUFFER,null),i.useProgram(null),i.lineWidth(1),i.scissor(0,0,i.canvas.width,i.canvas.height),i.viewport(0,0,i.canvas.width,i.canvas.height),h={},K=null,ae={},d={},p=new WeakMap,m=[],g=null,y=!1,S=null,_=null,v=null,R=null,b=null,A=null,B=null,N=new Oe(0,0,0),D=0,C=!1,E=null,M=null,O=null,H=null,G=null,ke.set(0,0,i.canvas.width,i.canvas.height),Ze.set(0,0,i.canvas.width,i.canvas.height),r.reset(),o.reset(),a.reset()}return{buffers:{color:r,depth:o,stencil:a},enable:Ee,disable:Me,bindFramebuffer:ze,drawBuffers:Ve,useProgram:it,setBlending:Fe,setMaterial:mt,setFlipSided:We,setCullFace:At,setLineWidth:z,setPolygonOffset:P,setScissorTest:ie,activeTexture:le,bindTexture:de,unbindTexture:ge,compressedTexImage2D:He,compressedTexImage3D:_e,texImage2D:Ie,texImage3D:ct,updateUBOMapping:_t,uniformBlockBinding:Tt,texStorage2D:Ke,texStorage3D:Le,texSubImage2D:De,texSubImage3D:Xe,compressedTexSubImage2D:xe,compressedTexSubImage3D:we,scissor:ft,viewport:Et,reset:Ne}}function yP(i,e,t,n,r,o,a){const l=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,u=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),h=new Pe,d=new WeakMap;let p;const m=new WeakMap;let g=!1;try{g=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function y(z,P){return g?new OffscreenCanvas(z,P):za("canvas")}function S(z,P,ie){let le=1;const de=At(z);if((de.width>ie||de.height>ie)&&(le=ie/Math.max(de.width,de.height)),le<1)if(typeof HTMLImageElement<"u"&&z instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&z instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&z instanceof ImageBitmap||typeof VideoFrame<"u"&&z instanceof VideoFrame){const ge=Math.floor(le*de.width),He=Math.floor(le*de.height);p===void 0&&(p=y(ge,He));const _e=P?y(ge,He):p;return _e.width=ge,_e.height=He,_e.getContext("2d").drawImage(z,0,0,ge,He),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+de.width+"x"+de.height+") to ("+ge+"x"+He+")."),_e}else return"data"in z&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+de.width+"x"+de.height+")."),z;return z}function _(z){return z.generateMipmaps&&z.minFilter!==Nn&&z.minFilter!==Xn}function v(z){i.generateMipmap(z)}function R(z,P,ie,le,de=!1){if(z!==null){if(i[z]!==void 0)return i[z];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+z+"'")}let ge=P;if(P===i.RED&&(ie===i.FLOAT&&(ge=i.R32F),ie===i.HALF_FLOAT&&(ge=i.R16F),ie===i.UNSIGNED_BYTE&&(ge=i.R8)),P===i.RED_INTEGER&&(ie===i.UNSIGNED_BYTE&&(ge=i.R8UI),ie===i.UNSIGNED_SHORT&&(ge=i.R16UI),ie===i.UNSIGNED_INT&&(ge=i.R32UI),ie===i.BYTE&&(ge=i.R8I),ie===i.SHORT&&(ge=i.R16I),ie===i.INT&&(ge=i.R32I)),P===i.RG&&(ie===i.FLOAT&&(ge=i.RG32F),ie===i.HALF_FLOAT&&(ge=i.RG16F),ie===i.UNSIGNED_BYTE&&(ge=i.RG8)),P===i.RG_INTEGER&&(ie===i.UNSIGNED_BYTE&&(ge=i.RG8UI),ie===i.UNSIGNED_SHORT&&(ge=i.RG16UI),ie===i.UNSIGNED_INT&&(ge=i.RG32UI),ie===i.BYTE&&(ge=i.RG8I),ie===i.SHORT&&(ge=i.RG16I),ie===i.INT&&(ge=i.RG32I)),P===i.RGB&&ie===i.UNSIGNED_INT_5_9_9_9_REV&&(ge=i.RGB9_E5),P===i.RGBA){const He=de?wl:Lt.getTransfer(le);ie===i.FLOAT&&(ge=i.RGBA32F),ie===i.HALF_FLOAT&&(ge=i.RGBA16F),ie===i.UNSIGNED_BYTE&&(ge=He===Wt?i.SRGB8_ALPHA8:i.RGBA8),ie===i.UNSIGNED_SHORT_4_4_4_4&&(ge=i.RGBA4),ie===i.UNSIGNED_SHORT_5_5_5_1&&(ge=i.RGB5_A1)}return(ge===i.R16F||ge===i.R32F||ge===i.RG16F||ge===i.RG32F||ge===i.RGBA16F||ge===i.RGBA32F)&&e.get("EXT_color_buffer_float"),ge}function b(z,P){return _(z)===!0||z.isFramebufferTexture&&z.minFilter!==Nn&&z.minFilter!==Xn?Math.log2(Math.max(P.width,P.height))+1:z.mipmaps!==void 0&&z.mipmaps.length>0?z.mipmaps.length:z.isCompressedTexture&&Array.isArray(z.image)?P.mipmaps.length:1}function A(z){const P=z.target;P.removeEventListener("dispose",A),N(P),P.isVideoTexture&&d.delete(P)}function B(z){const P=z.target;P.removeEventListener("dispose",B),C(P)}function N(z){const P=n.get(z);if(P.__webglInit===void 0)return;const ie=z.source,le=m.get(ie);if(le){const de=le[P.__cacheKey];de.usedTimes--,de.usedTimes===0&&D(z),Object.keys(le).length===0&&m.delete(ie)}n.remove(z)}function D(z){const P=n.get(z);i.deleteTexture(P.__webglTexture);const ie=z.source,le=m.get(ie);delete le[P.__cacheKey],a.memory.textures--}function C(z){const P=n.get(z);if(z.depthTexture&&z.depthTexture.dispose(),z.isWebGLCubeRenderTarget)for(let le=0;le<6;le++){if(Array.isArray(P.__webglFramebuffer[le]))for(let de=0;de<P.__webglFramebuffer[le].length;de++)i.deleteFramebuffer(P.__webglFramebuffer[le][de]);else i.deleteFramebuffer(P.__webglFramebuffer[le]);P.__webglDepthbuffer&&i.deleteRenderbuffer(P.__webglDepthbuffer[le])}else{if(Array.isArray(P.__webglFramebuffer))for(let le=0;le<P.__webglFramebuffer.length;le++)i.deleteFramebuffer(P.__webglFramebuffer[le]);else i.deleteFramebuffer(P.__webglFramebuffer);if(P.__webglDepthbuffer&&i.deleteRenderbuffer(P.__webglDepthbuffer),P.__webglMultisampledFramebuffer&&i.deleteFramebuffer(P.__webglMultisampledFramebuffer),P.__webglColorRenderbuffer)for(let le=0;le<P.__webglColorRenderbuffer.length;le++)P.__webglColorRenderbuffer[le]&&i.deleteRenderbuffer(P.__webglColorRenderbuffer[le]);P.__webglDepthRenderbuffer&&i.deleteRenderbuffer(P.__webglDepthRenderbuffer)}const ie=z.textures;for(let le=0,de=ie.length;le<de;le++){const ge=n.get(ie[le]);ge.__webglTexture&&(i.deleteTexture(ge.__webglTexture),a.memory.textures--),n.remove(ie[le])}n.remove(z)}let E=0;function M(){E=0}function O(){const z=E;return z>=r.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+z+" texture units while this GPU supports only "+r.maxTextures),E+=1,z}function H(z){const P=[];return P.push(z.wrapS),P.push(z.wrapT),P.push(z.wrapR||0),P.push(z.magFilter),P.push(z.minFilter),P.push(z.anisotropy),P.push(z.internalFormat),P.push(z.format),P.push(z.type),P.push(z.generateMipmaps),P.push(z.premultiplyAlpha),P.push(z.flipY),P.push(z.unpackAlignment),P.push(z.colorSpace),P.join()}function G(z,P){const ie=n.get(z);if(z.isVideoTexture&&mt(z),z.isRenderTargetTexture===!1&&z.version>0&&ie.__version!==z.version){const le=z.image;if(le===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(le.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{ke(ie,z,P);return}}t.bindTexture(i.TEXTURE_2D,ie.__webglTexture,i.TEXTURE0+P)}function Y(z,P){const ie=n.get(z);if(z.version>0&&ie.__version!==z.version){ke(ie,z,P);return}t.bindTexture(i.TEXTURE_2D_ARRAY,ie.__webglTexture,i.TEXTURE0+P)}function $(z,P){const ie=n.get(z);if(z.version>0&&ie.__version!==z.version){ke(ie,z,P);return}t.bindTexture(i.TEXTURE_3D,ie.__webglTexture,i.TEXTURE0+P)}function re(z,P){const ie=n.get(z);if(z.version>0&&ie.__version!==z.version){Ze(ie,z,P);return}t.bindTexture(i.TEXTURE_CUBE_MAP,ie.__webglTexture,i.TEXTURE0+P)}const se={[es]:i.REPEAT,[$i]:i.CLAMP_TO_EDGE,[Co]:i.MIRRORED_REPEAT},K={[Nn]:i.NEAREST,[Uf]:i.NEAREST_MIPMAP_NEAREST,[yo]:i.NEAREST_MIPMAP_LINEAR,[Xn]:i.LINEAR,[Da]:i.LINEAR_MIPMAP_NEAREST,[Ki]:i.LINEAR_MIPMAP_LINEAR},ae={[tw]:i.NEVER,[aw]:i.ALWAYS,[nw]:i.LESS,[c0]:i.LEQUAL,[iw]:i.EQUAL,[ow]:i.GEQUAL,[rw]:i.GREATER,[sw]:i.NOTEQUAL};function pe(z,P){if(P.type===Zi&&e.has("OES_texture_float_linear")===!1&&(P.magFilter===Xn||P.magFilter===Da||P.magFilter===yo||P.magFilter===Ki||P.minFilter===Xn||P.minFilter===Da||P.minFilter===yo||P.minFilter===Ki)&&console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),i.texParameteri(z,i.TEXTURE_WRAP_S,se[P.wrapS]),i.texParameteri(z,i.TEXTURE_WRAP_T,se[P.wrapT]),(z===i.TEXTURE_3D||z===i.TEXTURE_2D_ARRAY)&&i.texParameteri(z,i.TEXTURE_WRAP_R,se[P.wrapR]),i.texParameteri(z,i.TEXTURE_MAG_FILTER,K[P.magFilter]),i.texParameteri(z,i.TEXTURE_MIN_FILTER,K[P.minFilter]),P.compareFunction&&(i.texParameteri(z,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE),i.texParameteri(z,i.TEXTURE_COMPARE_FUNC,ae[P.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(P.magFilter===Nn||P.minFilter!==yo&&P.minFilter!==Ki||P.type===Zi&&e.has("OES_texture_float_linear")===!1)return;if(P.anisotropy>1||n.get(P).__currentAnisotropy){const ie=e.get("EXT_texture_filter_anisotropic");i.texParameterf(z,ie.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(P.anisotropy,r.getMaxAnisotropy())),n.get(P).__currentAnisotropy=P.anisotropy}}}function ve(z,P){let ie=!1;z.__webglInit===void 0&&(z.__webglInit=!0,P.addEventListener("dispose",A));const le=P.source;let de=m.get(le);de===void 0&&(de={},m.set(le,de));const ge=H(P);if(ge!==z.__cacheKey){de[ge]===void 0&&(de[ge]={texture:i.createTexture(),usedTimes:0},a.memory.textures++,ie=!0),de[ge].usedTimes++;const He=de[z.__cacheKey];He!==void 0&&(de[z.__cacheKey].usedTimes--,He.usedTimes===0&&D(P)),z.__cacheKey=ge,z.__webglTexture=de[ge].texture}return ie}function ke(z,P,ie){let le=i.TEXTURE_2D;(P.isDataArrayTexture||P.isCompressedArrayTexture)&&(le=i.TEXTURE_2D_ARRAY),P.isData3DTexture&&(le=i.TEXTURE_3D);const de=ve(z,P),ge=P.source;t.bindTexture(le,z.__webglTexture,i.TEXTURE0+ie);const He=n.get(ge);if(ge.version!==He.__version||de===!0){t.activeTexture(i.TEXTURE0+ie);const _e=Lt.getPrimaries(Lt.workingColorSpace),De=P.colorSpace===Sn?null:Lt.getPrimaries(P.colorSpace),Xe=P.colorSpace===Sn||_e===De?i.NONE:i.BROWSER_DEFAULT_WEBGL;i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,P.flipY),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,P.premultiplyAlpha),i.pixelStorei(i.UNPACK_ALIGNMENT,P.unpackAlignment),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,Xe);let xe=S(P.image,!1,r.maxTextureSize);xe=We(P,xe);const we=o.convert(P.format,P.colorSpace),Ke=o.convert(P.type);let Le=R(P.internalFormat,we,Ke,P.colorSpace,P.isVideoTexture);pe(le,P);let Ie;const ct=P.mipmaps,ft=P.isVideoTexture!==!0&&Le!==s0,Et=He.__version===void 0||de===!0,_t=ge.dataReady,Tt=b(P,xe);if(P.isDepthTexture)Le=i.DEPTH_COMPONENT16,P.type===Zi?Le=i.DEPTH_COMPONENT32F:P.type===Po?Le=i.DEPTH_COMPONENT24:P.type===Ga&&(Le=i.DEPTH24_STENCIL8),Et&&(ft?t.texStorage2D(i.TEXTURE_2D,1,Le,xe.width,xe.height):t.texImage2D(i.TEXTURE_2D,0,Le,xe.width,xe.height,0,we,Ke,null));else if(P.isDataTexture)if(ct.length>0){ft&&Et&&t.texStorage2D(i.TEXTURE_2D,Tt,Le,ct[0].width,ct[0].height);for(let Ne=0,T=ct.length;Ne<T;Ne++)Ie=ct[Ne],ft?_t&&t.texSubImage2D(i.TEXTURE_2D,Ne,0,0,Ie.width,Ie.height,we,Ke,Ie.data):t.texImage2D(i.TEXTURE_2D,Ne,Le,Ie.width,Ie.height,0,we,Ke,Ie.data);P.generateMipmaps=!1}else ft?(Et&&t.texStorage2D(i.TEXTURE_2D,Tt,Le,xe.width,xe.height),_t&&t.texSubImage2D(i.TEXTURE_2D,0,0,0,xe.width,xe.height,we,Ke,xe.data)):t.texImage2D(i.TEXTURE_2D,0,Le,xe.width,xe.height,0,we,Ke,xe.data);else if(P.isCompressedTexture)if(P.isCompressedArrayTexture){ft&&Et&&t.texStorage3D(i.TEXTURE_2D_ARRAY,Tt,Le,ct[0].width,ct[0].height,xe.depth);for(let Ne=0,T=ct.length;Ne<T;Ne++)Ie=ct[Ne],P.format!==Ei?we!==null?ft?_t&&t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,Ne,0,0,0,Ie.width,Ie.height,xe.depth,we,Ie.data,0,0):t.compressedTexImage3D(i.TEXTURE_2D_ARRAY,Ne,Le,Ie.width,Ie.height,xe.depth,0,Ie.data,0,0):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):ft?_t&&t.texSubImage3D(i.TEXTURE_2D_ARRAY,Ne,0,0,0,Ie.width,Ie.height,xe.depth,we,Ke,Ie.data):t.texImage3D(i.TEXTURE_2D_ARRAY,Ne,Le,Ie.width,Ie.height,xe.depth,0,we,Ke,Ie.data)}else{ft&&Et&&t.texStorage2D(i.TEXTURE_2D,Tt,Le,ct[0].width,ct[0].height);for(let Ne=0,T=ct.length;Ne<T;Ne++)Ie=ct[Ne],P.format!==Ei?we!==null?ft?_t&&t.compressedTexSubImage2D(i.TEXTURE_2D,Ne,0,0,Ie.width,Ie.height,we,Ie.data):t.compressedTexImage2D(i.TEXTURE_2D,Ne,Le,Ie.width,Ie.height,0,Ie.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):ft?_t&&t.texSubImage2D(i.TEXTURE_2D,Ne,0,0,Ie.width,Ie.height,we,Ke,Ie.data):t.texImage2D(i.TEXTURE_2D,Ne,Le,Ie.width,Ie.height,0,we,Ke,Ie.data)}else if(P.isDataArrayTexture)ft?(Et&&t.texStorage3D(i.TEXTURE_2D_ARRAY,Tt,Le,xe.width,xe.height,xe.depth),_t&&t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,0,xe.width,xe.height,xe.depth,we,Ke,xe.data)):t.texImage3D(i.TEXTURE_2D_ARRAY,0,Le,xe.width,xe.height,xe.depth,0,we,Ke,xe.data);else if(P.isData3DTexture)ft?(Et&&t.texStorage3D(i.TEXTURE_3D,Tt,Le,xe.width,xe.height,xe.depth),_t&&t.texSubImage3D(i.TEXTURE_3D,0,0,0,0,xe.width,xe.height,xe.depth,we,Ke,xe.data)):t.texImage3D(i.TEXTURE_3D,0,Le,xe.width,xe.height,xe.depth,0,we,Ke,xe.data);else if(P.isFramebufferTexture){if(Et)if(ft)t.texStorage2D(i.TEXTURE_2D,Tt,Le,xe.width,xe.height);else{let Ne=xe.width,T=xe.height;for(let Z=0;Z<Tt;Z++)t.texImage2D(i.TEXTURE_2D,Z,Le,Ne,T,0,we,Ke,null),Ne>>=1,T>>=1}}else if(ct.length>0){if(ft&&Et){const Ne=At(ct[0]);t.texStorage2D(i.TEXTURE_2D,Tt,Le,Ne.width,Ne.height)}for(let Ne=0,T=ct.length;Ne<T;Ne++)Ie=ct[Ne],ft?_t&&t.texSubImage2D(i.TEXTURE_2D,Ne,0,0,we,Ke,Ie):t.texImage2D(i.TEXTURE_2D,Ne,Le,we,Ke,Ie);P.generateMipmaps=!1}else if(ft){if(Et){const Ne=At(xe);t.texStorage2D(i.TEXTURE_2D,Tt,Le,Ne.width,Ne.height)}_t&&t.texSubImage2D(i.TEXTURE_2D,0,0,0,we,Ke,xe)}else t.texImage2D(i.TEXTURE_2D,0,Le,we,Ke,xe);_(P)&&v(le),He.__version=ge.version,P.onUpdate&&P.onUpdate(P)}z.__version=P.version}function Ze(z,P,ie){if(P.image.length!==6)return;const le=ve(z,P),de=P.source;t.bindTexture(i.TEXTURE_CUBE_MAP,z.__webglTexture,i.TEXTURE0+ie);const ge=n.get(de);if(de.version!==ge.__version||le===!0){t.activeTexture(i.TEXTURE0+ie);const He=Lt.getPrimaries(Lt.workingColorSpace),_e=P.colorSpace===Sn?null:Lt.getPrimaries(P.colorSpace),De=P.colorSpace===Sn||He===_e?i.NONE:i.BROWSER_DEFAULT_WEBGL;i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,P.flipY),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,P.premultiplyAlpha),i.pixelStorei(i.UNPACK_ALIGNMENT,P.unpackAlignment),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,De);const Xe=P.isCompressedTexture||P.image[0].isCompressedTexture,xe=P.image[0]&&P.image[0].isDataTexture,we=[];for(let T=0;T<6;T++)!Xe&&!xe?we[T]=S(P.image[T],!0,r.maxCubemapSize):we[T]=xe?P.image[T].image:P.image[T],we[T]=We(P,we[T]);const Ke=we[0],Le=o.convert(P.format,P.colorSpace),Ie=o.convert(P.type),ct=R(P.internalFormat,Le,Ie,P.colorSpace),ft=P.isVideoTexture!==!0,Et=ge.__version===void 0||le===!0,_t=de.dataReady;let Tt=b(P,Ke);pe(i.TEXTURE_CUBE_MAP,P);let Ne;if(Xe){ft&&Et&&t.texStorage2D(i.TEXTURE_CUBE_MAP,Tt,ct,Ke.width,Ke.height);for(let T=0;T<6;T++){Ne=we[T].mipmaps;for(let Z=0;Z<Ne.length;Z++){const ce=Ne[Z];P.format!==Ei?Le!==null?ft?_t&&t.compressedTexSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+T,Z,0,0,ce.width,ce.height,Le,ce.data):t.compressedTexImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+T,Z,ct,ce.width,ce.height,0,ce.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):ft?_t&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+T,Z,0,0,ce.width,ce.height,Le,Ie,ce.data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+T,Z,ct,ce.width,ce.height,0,Le,Ie,ce.data)}}}else{if(Ne=P.mipmaps,ft&&Et){Ne.length>0&&Tt++;const T=At(we[0]);t.texStorage2D(i.TEXTURE_CUBE_MAP,Tt,ct,T.width,T.height)}for(let T=0;T<6;T++)if(xe){ft?_t&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+T,0,0,0,we[T].width,we[T].height,Le,Ie,we[T].data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+T,0,ct,we[T].width,we[T].height,0,Le,Ie,we[T].data);for(let Z=0;Z<Ne.length;Z++){const ye=Ne[Z].image[T].image;ft?_t&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+T,Z+1,0,0,ye.width,ye.height,Le,Ie,ye.data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+T,Z+1,ct,ye.width,ye.height,0,Le,Ie,ye.data)}}else{ft?_t&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+T,0,0,0,Le,Ie,we[T]):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+T,0,ct,Le,Ie,we[T]);for(let Z=0;Z<Ne.length;Z++){const ce=Ne[Z];ft?_t&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+T,Z+1,0,0,Le,Ie,ce.image[T]):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+T,Z+1,ct,Le,Ie,ce.image[T])}}}_(P)&&v(i.TEXTURE_CUBE_MAP),ge.__version=de.version,P.onUpdate&&P.onUpdate(P)}z.__version=P.version}function te(z,P,ie,le,de,ge){const He=o.convert(ie.format,ie.colorSpace),_e=o.convert(ie.type),De=R(ie.internalFormat,He,_e,ie.colorSpace);if(!n.get(P).__hasExternalTextures){const xe=Math.max(1,P.width>>ge),we=Math.max(1,P.height>>ge);de===i.TEXTURE_3D||de===i.TEXTURE_2D_ARRAY?t.texImage3D(de,ge,De,xe,we,P.depth,0,He,_e,null):t.texImage2D(de,ge,De,xe,we,0,He,_e,null)}t.bindFramebuffer(i.FRAMEBUFFER,z),Fe(P)?l.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,le,de,n.get(ie).__webglTexture,0,$e(P)):(de===i.TEXTURE_2D||de>=i.TEXTURE_CUBE_MAP_POSITIVE_X&&de<=i.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&i.framebufferTexture2D(i.FRAMEBUFFER,le,de,n.get(ie).__webglTexture,ge),t.bindFramebuffer(i.FRAMEBUFFER,null)}function fe(z,P,ie){if(i.bindRenderbuffer(i.RENDERBUFFER,z),P.depthBuffer&&!P.stencilBuffer){let le=i.DEPTH_COMPONENT24;if(ie||Fe(P)){const de=P.depthTexture;de&&de.isDepthTexture&&(de.type===Zi?le=i.DEPTH_COMPONENT32F:de.type===Po&&(le=i.DEPTH_COMPONENT24));const ge=$e(P);Fe(P)?l.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,ge,le,P.width,P.height):i.renderbufferStorageMultisample(i.RENDERBUFFER,ge,le,P.width,P.height)}else i.renderbufferStorage(i.RENDERBUFFER,le,P.width,P.height);i.framebufferRenderbuffer(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.RENDERBUFFER,z)}else if(P.depthBuffer&&P.stencilBuffer){const le=$e(P);ie&&Fe(P)===!1?i.renderbufferStorageMultisample(i.RENDERBUFFER,le,i.DEPTH24_STENCIL8,P.width,P.height):Fe(P)?l.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,le,i.DEPTH24_STENCIL8,P.width,P.height):i.renderbufferStorage(i.RENDERBUFFER,i.DEPTH_STENCIL,P.width,P.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.RENDERBUFFER,z)}else{const le=P.textures;for(let de=0;de<le.length;de++){const ge=le[de],He=o.convert(ge.format,ge.colorSpace),_e=o.convert(ge.type),De=R(ge.internalFormat,He,_e,ge.colorSpace),Xe=$e(P);ie&&Fe(P)===!1?i.renderbufferStorageMultisample(i.RENDERBUFFER,Xe,De,P.width,P.height):Fe(P)?l.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,Xe,De,P.width,P.height):i.renderbufferStorage(i.RENDERBUFFER,De,P.width,P.height)}}i.bindRenderbuffer(i.RENDERBUFFER,null)}function Ee(z,P){if(P&&P.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(t.bindFramebuffer(i.FRAMEBUFFER,z),!(P.depthTexture&&P.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!n.get(P.depthTexture).__webglTexture||P.depthTexture.image.width!==P.width||P.depthTexture.image.height!==P.height)&&(P.depthTexture.image.width=P.width,P.depthTexture.image.height=P.height,P.depthTexture.needsUpdate=!0),G(P.depthTexture,0);const le=n.get(P.depthTexture).__webglTexture,de=$e(P);if(P.depthTexture.format===To)Fe(P)?l.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.TEXTURE_2D,le,0,de):i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.TEXTURE_2D,le,0);else if(P.depthTexture.format===Ba)Fe(P)?l.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.TEXTURE_2D,le,0,de):i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.TEXTURE_2D,le,0);else throw new Error("Unknown depthTexture format")}function Me(z){const P=n.get(z),ie=z.isWebGLCubeRenderTarget===!0;if(z.depthTexture&&!P.__autoAllocateDepthBuffer){if(ie)throw new Error("target.depthTexture not supported in Cube render targets");Ee(P.__webglFramebuffer,z)}else if(ie){P.__webglDepthbuffer=[];for(let le=0;le<6;le++)t.bindFramebuffer(i.FRAMEBUFFER,P.__webglFramebuffer[le]),P.__webglDepthbuffer[le]=i.createRenderbuffer(),fe(P.__webglDepthbuffer[le],z,!1)}else t.bindFramebuffer(i.FRAMEBUFFER,P.__webglFramebuffer),P.__webglDepthbuffer=i.createRenderbuffer(),fe(P.__webglDepthbuffer,z,!1);t.bindFramebuffer(i.FRAMEBUFFER,null)}function ze(z,P,ie){const le=n.get(z);P!==void 0&&te(le.__webglFramebuffer,z,z.texture,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,0),ie!==void 0&&Me(z)}function Ve(z){const P=z.texture,ie=n.get(z),le=n.get(P);z.addEventListener("dispose",B);const de=z.textures,ge=z.isWebGLCubeRenderTarget===!0,He=de.length>1;if(He||(le.__webglTexture===void 0&&(le.__webglTexture=i.createTexture()),le.__version=P.version,a.memory.textures++),ge){ie.__webglFramebuffer=[];for(let _e=0;_e<6;_e++)if(P.mipmaps&&P.mipmaps.length>0){ie.__webglFramebuffer[_e]=[];for(let De=0;De<P.mipmaps.length;De++)ie.__webglFramebuffer[_e][De]=i.createFramebuffer()}else ie.__webglFramebuffer[_e]=i.createFramebuffer()}else{if(P.mipmaps&&P.mipmaps.length>0){ie.__webglFramebuffer=[];for(let _e=0;_e<P.mipmaps.length;_e++)ie.__webglFramebuffer[_e]=i.createFramebuffer()}else ie.__webglFramebuffer=i.createFramebuffer();if(He)for(let _e=0,De=de.length;_e<De;_e++){const Xe=n.get(de[_e]);Xe.__webglTexture===void 0&&(Xe.__webglTexture=i.createTexture(),a.memory.textures++)}if(z.samples>0&&Fe(z)===!1){ie.__webglMultisampledFramebuffer=i.createFramebuffer(),ie.__webglColorRenderbuffer=[],t.bindFramebuffer(i.FRAMEBUFFER,ie.__webglMultisampledFramebuffer);for(let _e=0;_e<de.length;_e++){const De=de[_e];ie.__webglColorRenderbuffer[_e]=i.createRenderbuffer(),i.bindRenderbuffer(i.RENDERBUFFER,ie.__webglColorRenderbuffer[_e]);const Xe=o.convert(De.format,De.colorSpace),xe=o.convert(De.type),we=R(De.internalFormat,Xe,xe,De.colorSpace,z.isXRRenderTarget===!0),Ke=$e(z);i.renderbufferStorageMultisample(i.RENDERBUFFER,Ke,we,z.width,z.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+_e,i.RENDERBUFFER,ie.__webglColorRenderbuffer[_e])}i.bindRenderbuffer(i.RENDERBUFFER,null),z.depthBuffer&&(ie.__webglDepthRenderbuffer=i.createRenderbuffer(),fe(ie.__webglDepthRenderbuffer,z,!0)),t.bindFramebuffer(i.FRAMEBUFFER,null)}}if(ge){t.bindTexture(i.TEXTURE_CUBE_MAP,le.__webglTexture),pe(i.TEXTURE_CUBE_MAP,P);for(let _e=0;_e<6;_e++)if(P.mipmaps&&P.mipmaps.length>0)for(let De=0;De<P.mipmaps.length;De++)te(ie.__webglFramebuffer[_e][De],z,P,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+_e,De);else te(ie.__webglFramebuffer[_e],z,P,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+_e,0);_(P)&&v(i.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(He){for(let _e=0,De=de.length;_e<De;_e++){const Xe=de[_e],xe=n.get(Xe);t.bindTexture(i.TEXTURE_2D,xe.__webglTexture),pe(i.TEXTURE_2D,Xe),te(ie.__webglFramebuffer,z,Xe,i.COLOR_ATTACHMENT0+_e,i.TEXTURE_2D,0),_(Xe)&&v(i.TEXTURE_2D)}t.unbindTexture()}else{let _e=i.TEXTURE_2D;if((z.isWebGL3DRenderTarget||z.isWebGLArrayRenderTarget)&&(_e=z.isWebGL3DRenderTarget?i.TEXTURE_3D:i.TEXTURE_2D_ARRAY),t.bindTexture(_e,le.__webglTexture),pe(_e,P),P.mipmaps&&P.mipmaps.length>0)for(let De=0;De<P.mipmaps.length;De++)te(ie.__webglFramebuffer[De],z,P,i.COLOR_ATTACHMENT0,_e,De);else te(ie.__webglFramebuffer,z,P,i.COLOR_ATTACHMENT0,_e,0);_(P)&&v(_e),t.unbindTexture()}z.depthBuffer&&Me(z)}function it(z){const P=z.textures;for(let ie=0,le=P.length;ie<le;ie++){const de=P[ie];if(_(de)){const ge=z.isWebGLCubeRenderTarget?i.TEXTURE_CUBE_MAP:i.TEXTURE_2D,He=n.get(de).__webglTexture;t.bindTexture(ge,He),v(ge),t.unbindTexture()}}}function q(z){if(z.samples>0&&Fe(z)===!1){const P=z.textures,ie=z.width,le=z.height;let de=i.COLOR_BUFFER_BIT;const ge=[],He=z.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,_e=n.get(z),De=P.length>1;if(De)for(let Xe=0;Xe<P.length;Xe++)t.bindFramebuffer(i.FRAMEBUFFER,_e.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+Xe,i.RENDERBUFFER,null),t.bindFramebuffer(i.FRAMEBUFFER,_e.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+Xe,i.TEXTURE_2D,null,0);t.bindFramebuffer(i.READ_FRAMEBUFFER,_e.__webglMultisampledFramebuffer),t.bindFramebuffer(i.DRAW_FRAMEBUFFER,_e.__webglFramebuffer);for(let Xe=0;Xe<P.length;Xe++){ge.push(i.COLOR_ATTACHMENT0+Xe),z.depthBuffer&&ge.push(He);const xe=_e.__ignoreDepthValues!==void 0?_e.__ignoreDepthValues:!1;if(xe===!1&&(z.depthBuffer&&(de|=i.DEPTH_BUFFER_BIT),z.stencilBuffer&&_e.__isTransmissionRenderTarget!==!0&&(de|=i.STENCIL_BUFFER_BIT)),De&&i.framebufferRenderbuffer(i.READ_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.RENDERBUFFER,_e.__webglColorRenderbuffer[Xe]),xe===!0&&(i.invalidateFramebuffer(i.READ_FRAMEBUFFER,[He]),i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,[He])),De){const we=n.get(P[Xe]).__webglTexture;i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,we,0)}i.blitFramebuffer(0,0,ie,le,0,0,ie,le,de,i.NEAREST),u&&i.invalidateFramebuffer(i.READ_FRAMEBUFFER,ge)}if(t.bindFramebuffer(i.READ_FRAMEBUFFER,null),t.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),De)for(let Xe=0;Xe<P.length;Xe++){t.bindFramebuffer(i.FRAMEBUFFER,_e.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+Xe,i.RENDERBUFFER,_e.__webglColorRenderbuffer[Xe]);const xe=n.get(P[Xe]).__webglTexture;t.bindFramebuffer(i.FRAMEBUFFER,_e.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+Xe,i.TEXTURE_2D,xe,0)}t.bindFramebuffer(i.DRAW_FRAMEBUFFER,_e.__webglMultisampledFramebuffer)}}function $e(z){return Math.min(r.maxSamples,z.samples)}function Fe(z){const P=n.get(z);return z.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&P.__useRenderToTexture!==!1}function mt(z){const P=a.render.frame;d.get(z)!==P&&(d.set(z,P),z.update())}function We(z,P){const ie=z.colorSpace,le=z.format,de=z.type;return z.isCompressedTexture===!0||z.isVideoTexture===!0||ie!==Tn&&ie!==Sn&&(Lt.getTransfer(ie)===Wt?(le!==Ei||de!==Qr)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",ie)),P}function At(z){return typeof HTMLImageElement<"u"&&z instanceof HTMLImageElement?(h.width=z.naturalWidth||z.width,h.height=z.naturalHeight||z.height):typeof VideoFrame<"u"&&z instanceof VideoFrame?(h.width=z.displayWidth,h.height=z.displayHeight):(h.width=z.width,h.height=z.height),h}this.allocateTextureUnit=O,this.resetTextureUnits=M,this.setTexture2D=G,this.setTexture2DArray=Y,this.setTexture3D=$,this.setTextureCube=re,this.rebindTextures=ze,this.setupRenderTarget=Ve,this.updateRenderTargetMipmap=it,this.updateMultisampleRenderTarget=q,this.setupDepthRenderbuffer=Me,this.setupFrameBufferTexture=te,this.useMultisampledRTT=Fe}function MP(i,e){function t(n,r=Sn){let o;const a=Lt.getTransfer(r);if(n===Qr)return i.UNSIGNED_BYTE;if(n===Q_)return i.UNSIGNED_SHORT_4_4_4_4;if(n===e0)return i.UNSIGNED_SHORT_5_5_5_1;if(n===Vb)return i.UNSIGNED_INT_5_9_9_9_REV;if(n===Hb)return i.BYTE;if(n===Gb)return i.SHORT;if(n===Z_)return i.UNSIGNED_SHORT;if(n===J_)return i.INT;if(n===Po)return i.UNSIGNED_INT;if(n===Zi)return i.FLOAT;if(n===bl)return i.HALF_FLOAT;if(n===Wb)return i.ALPHA;if(n===Xb)return i.RGB;if(n===Ei)return i.RGBA;if(n===Yb)return i.LUMINANCE;if(n===jb)return i.LUMINANCE_ALPHA;if(n===To)return i.DEPTH_COMPONENT;if(n===Ba)return i.DEPTH_STENCIL;if(n===t0)return i.RED;if(n===n0)return i.RED_INTEGER;if(n===qb)return i.RG;if(n===i0)return i.RG_INTEGER;if(n===r0)return i.RGBA_INTEGER;if(n===ih||n===rh||n===sh||n===oh)if(a===Wt)if(o=e.get("WEBGL_compressed_texture_s3tc_srgb"),o!==null){if(n===ih)return o.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===rh)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===sh)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===oh)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(o=e.get("WEBGL_compressed_texture_s3tc"),o!==null){if(n===ih)return o.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===rh)return o.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===sh)return o.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===oh)return o.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===bm||n===wm||n===Am||n===Rm)if(o=e.get("WEBGL_compressed_texture_pvrtc"),o!==null){if(n===bm)return o.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===wm)return o.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===Am)return o.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===Rm)return o.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===s0)return o=e.get("WEBGL_compressed_texture_etc1"),o!==null?o.COMPRESSED_RGB_ETC1_WEBGL:null;if(n===Cm||n===Pm)if(o=e.get("WEBGL_compressed_texture_etc"),o!==null){if(n===Cm)return a===Wt?o.COMPRESSED_SRGB8_ETC2:o.COMPRESSED_RGB8_ETC2;if(n===Pm)return a===Wt?o.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:o.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(n===Lm||n===Im||n===Dm||n===Um||n===Nm||n===Om||n===Fm||n===Bm||n===zm||n===km||n===Hm||n===Gm||n===Vm||n===Wm)if(o=e.get("WEBGL_compressed_texture_astc"),o!==null){if(n===Lm)return a===Wt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:o.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===Im)return a===Wt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:o.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===Dm)return a===Wt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:o.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===Um)return a===Wt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:o.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===Nm)return a===Wt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:o.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===Om)return a===Wt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:o.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===Fm)return a===Wt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:o.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===Bm)return a===Wt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:o.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===zm)return a===Wt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:o.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===km)return a===Wt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:o.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===Hm)return a===Wt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:o.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===Gm)return a===Wt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:o.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===Vm)return a===Wt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:o.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===Wm)return a===Wt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:o.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===ah||n===Xm||n===Ym)if(o=e.get("EXT_texture_compression_bptc"),o!==null){if(n===ah)return a===Wt?o.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:o.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===Xm)return o.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===Ym)return o.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===$b||n===jm||n===qm||n===$m)if(o=e.get("EXT_texture_compression_rgtc"),o!==null){if(n===ah)return o.COMPRESSED_RED_RGTC1_EXT;if(n===jm)return o.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===qm)return o.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===$m)return o.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===Ga?i.UNSIGNED_INT_24_8:i[n]!==void 0?i[n]:null}return{convert:t}}class SP extends Un{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}}let Qi=class extends gt{constructor(){super(),this.isGroup=!0,this.type="Group"}};const EP={type:"move"};class Dh{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Qi,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new Qi,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new F,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new F),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Qi,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new F,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new F),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const t=this._hand;if(t)for(const n of e.hand.values())this._getHandJoint(t,n)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,n){let r=null,o=null,a=null;const l=this._targetRay,u=this._grip,h=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(h&&e.hand){a=!0;for(const S of e.hand.values()){const _=t.getJointPose(S,n),v=this._getHandJoint(h,S);_!==null&&(v.matrix.fromArray(_.transform.matrix),v.matrix.decompose(v.position,v.rotation,v.scale),v.matrixWorldNeedsUpdate=!0,v.jointRadius=_.radius),v.visible=_!==null}const d=h.joints["index-finger-tip"],p=h.joints["thumb-tip"],m=d.position.distanceTo(p.position),g=.02,y=.005;h.inputState.pinching&&m>g+y?(h.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!h.inputState.pinching&&m<=g-y&&(h.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else u!==null&&e.gripSpace&&(o=t.getPose(e.gripSpace,n),o!==null&&(u.matrix.fromArray(o.transform.matrix),u.matrix.decompose(u.position,u.rotation,u.scale),u.matrixWorldNeedsUpdate=!0,o.linearVelocity?(u.hasLinearVelocity=!0,u.linearVelocity.copy(o.linearVelocity)):u.hasLinearVelocity=!1,o.angularVelocity?(u.hasAngularVelocity=!0,u.angularVelocity.copy(o.angularVelocity)):u.hasAngularVelocity=!1));l!==null&&(r=t.getPose(e.targetRaySpace,n),r===null&&o!==null&&(r=o),r!==null&&(l.matrix.fromArray(r.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,r.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(r.linearVelocity)):l.hasLinearVelocity=!1,r.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(r.angularVelocity)):l.hasAngularVelocity=!1,this.dispatchEvent(EP)))}return l!==null&&(l.visible=r!==null),u!==null&&(u.visible=o!==null),h!==null&&(h.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const n=new Qi;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}const TP=`
3773
+ }`;function vP(i,e,t){let n=new kf;const r=new Pe,o=new Pe,a=new Ut,l=new pP({depthPacking:Qb}),u=new mP,h={},d=t.maxTextureSize,p={[tr]:Kn,[Kn]:tr,[si]:si},m=new Rr({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Pe},radius:{value:4}},vertexShader:gP,fragmentShader:_P}),g=m.clone();g.defines.HORIZONTAL_PASS=1;const y=new tn;y.setAttribute("position",new Nt(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const S=new Se(y,m),_=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=j_;let v=this.type;this.render=function(N,D,C){if(_.enabled===!1||_.autoUpdate===!1&&_.needsUpdate===!1||N.length===0)return;const E=i.getRenderTarget(),M=i.getActiveCubeFace(),O=i.getActiveMipmapLevel(),H=i.state;H.setBlending(Jr),H.buffers.color.setClear(1,1,1,1),H.buffers.depth.setTest(!0),H.setScissorTest(!1);const G=v!==Tr&&this.type===Tr,Y=v===Tr&&this.type!==Tr;for(let $=0,re=N.length;$<re;$++){const se=N[$],K=se.shadow;if(K===void 0){console.warn("THREE.WebGLShadowMap:",se,"has no shadow.");continue}if(K.autoUpdate===!1&&K.needsUpdate===!1)continue;r.copy(K.mapSize);const ae=K.getFrameExtents();if(r.multiply(ae),o.copy(K.mapSize),(r.x>d||r.y>d)&&(r.x>d&&(o.x=Math.floor(d/ae.x),r.x=o.x*ae.x,K.mapSize.x=o.x),r.y>d&&(o.y=Math.floor(d/ae.y),r.y=o.y*ae.y,K.mapSize.y=o.y)),K.map===null||G===!0||Y===!0){const ve=this.type!==Tr?{minFilter:Nn,magFilter:Nn}:{};K.map!==null&&K.map.dispose(),K.map=new Rs(r.x,r.y,ve),K.map.texture.name=se.name+".shadowMap",K.camera.updateProjectionMatrix()}i.setRenderTarget(K.map),i.clear();const pe=K.getViewportCount();for(let ve=0;ve<pe;ve++){const ke=K.getViewport(ve);a.set(o.x*ke.x,o.y*ke.y,o.x*ke.z,o.y*ke.w),H.viewport(a),K.updateMatrices(se,ve),n=K.getFrustum(),A(D,C,K.camera,se,this.type)}K.isPointLightShadow!==!0&&this.type===Tr&&R(K,C),K.needsUpdate=!1}v=this.type,_.needsUpdate=!1,i.setRenderTarget(E,M,O)};function R(N,D){const C=e.update(S);m.defines.VSM_SAMPLES!==N.blurSamples&&(m.defines.VSM_SAMPLES=N.blurSamples,g.defines.VSM_SAMPLES=N.blurSamples,m.needsUpdate=!0,g.needsUpdate=!0),N.mapPass===null&&(N.mapPass=new Rs(r.x,r.y)),m.uniforms.shadow_pass.value=N.map.texture,m.uniforms.resolution.value=N.mapSize,m.uniforms.radius.value=N.radius,i.setRenderTarget(N.mapPass),i.clear(),i.renderBufferDirect(D,null,C,m,S,null),g.uniforms.shadow_pass.value=N.mapPass.texture,g.uniforms.resolution.value=N.mapSize,g.uniforms.radius.value=N.radius,i.setRenderTarget(N.map),i.clear(),i.renderBufferDirect(D,null,C,g,S,null)}function b(N,D,C,E){let M=null;const O=C.isPointLight===!0?N.customDistanceMaterial:N.customDepthMaterial;if(O!==void 0)M=O;else if(M=C.isPointLight===!0?u:l,i.localClippingEnabled&&D.clipShadows===!0&&Array.isArray(D.clippingPlanes)&&D.clippingPlanes.length!==0||D.displacementMap&&D.displacementScale!==0||D.alphaMap&&D.alphaTest>0||D.map&&D.alphaTest>0){const H=M.uuid,G=D.uuid;let Y=h[H];Y===void 0&&(Y={},h[H]=Y);let $=Y[G];$===void 0&&($=M.clone(),Y[G]=$,D.addEventListener("dispose",B)),M=$}if(M.visible=D.visible,M.wireframe=D.wireframe,E===Tr?M.side=D.shadowSide!==null?D.shadowSide:D.side:M.side=D.shadowSide!==null?D.shadowSide:p[D.side],M.alphaMap=D.alphaMap,M.alphaTest=D.alphaTest,M.map=D.map,M.clipShadows=D.clipShadows,M.clippingPlanes=D.clippingPlanes,M.clipIntersection=D.clipIntersection,M.displacementMap=D.displacementMap,M.displacementScale=D.displacementScale,M.displacementBias=D.displacementBias,M.wireframeLinewidth=D.wireframeLinewidth,M.linewidth=D.linewidth,C.isPointLight===!0&&M.isMeshDistanceMaterial===!0){const H=i.properties.get(M);H.light=C}return M}function A(N,D,C,E,M){if(N.visible===!1)return;if(N.layers.test(D.layers)&&(N.isMesh||N.isLine||N.isPoints)&&(N.castShadow||N.receiveShadow&&M===Tr)&&(!N.frustumCulled||n.intersectsObject(N))){N.modelViewMatrix.multiplyMatrices(C.matrixWorldInverse,N.matrixWorld);const G=e.update(N),Y=N.material;if(Array.isArray(Y)){const $=G.groups;for(let re=0,se=$.length;re<se;re++){const K=$[re],ae=Y[K.materialIndex];if(ae&&ae.visible){const pe=b(N,ae,E,M);N.onBeforeShadow(i,N,D,C,G,pe,K),i.renderBufferDirect(C,null,G,pe,N,K),N.onAfterShadow(i,N,D,C,G,pe,K)}}}else if(Y.visible){const $=b(N,Y,E,M);N.onBeforeShadow(i,N,D,C,G,$,null),i.renderBufferDirect(C,null,G,$,N,null),N.onAfterShadow(i,N,D,C,G,$,null)}}const H=N.children;for(let G=0,Y=H.length;G<Y;G++)A(H[G],D,C,E,M)}function B(N){N.target.removeEventListener("dispose",B);for(const C in h){const E=h[C],M=N.target.uuid;M in E&&(E[M].dispose(),delete E[M])}}}function xP(i){function e(){let T=!1;const Z=new Ut;let ce=null;const ye=new Ut(0,0,0,0);return{setMask:function(Re){ce!==Re&&!T&&(i.colorMask(Re,Re,Re,Re),ce=Re)},setLocked:function(Re){T=Re},setClear:function(Re,vt,dt,zt,ln){ln===!0&&(Re*=zt,vt*=zt,dt*=zt),Z.set(Re,vt,dt,zt),ye.equals(Z)===!1&&(i.clearColor(Re,vt,dt,zt),ye.copy(Z))},reset:function(){T=!1,ce=null,ye.set(-1,0,0,0)}}}function t(){let T=!1,Z=null,ce=null,ye=null;return{setTest:function(Re){Re?Ee(i.DEPTH_TEST):Me(i.DEPTH_TEST)},setMask:function(Re){Z!==Re&&!T&&(i.depthMask(Re),Z=Re)},setFunc:function(Re){if(ce!==Re){switch(Re){case Tb:i.depthFunc(i.NEVER);break;case bb:i.depthFunc(i.ALWAYS);break;case wb:i.depthFunc(i.LESS);break;case Tl:i.depthFunc(i.LEQUAL);break;case Ab:i.depthFunc(i.EQUAL);break;case Rb:i.depthFunc(i.GEQUAL);break;case Cb:i.depthFunc(i.GREATER);break;case Pb:i.depthFunc(i.NOTEQUAL);break;default:i.depthFunc(i.LEQUAL)}ce=Re}},setLocked:function(Re){T=Re},setClear:function(Re){ye!==Re&&(i.clearDepth(Re),ye=Re)},reset:function(){T=!1,Z=null,ce=null,ye=null}}}function n(){let T=!1,Z=null,ce=null,ye=null,Re=null,vt=null,dt=null,zt=null,ln=null;return{setTest:function(Rt){T||(Rt?Ee(i.STENCIL_TEST):Me(i.STENCIL_TEST))},setMask:function(Rt){Z!==Rt&&!T&&(i.stencilMask(Rt),Z=Rt)},setFunc:function(Rt,Zt,Jt){(ce!==Rt||ye!==Zt||Re!==Jt)&&(i.stencilFunc(Rt,Zt,Jt),ce=Rt,ye=Zt,Re=Jt)},setOp:function(Rt,Zt,Jt){(vt!==Rt||dt!==Zt||zt!==Jt)&&(i.stencilOp(Rt,Zt,Jt),vt=Rt,dt=Zt,zt=Jt)},setLocked:function(Rt){T=Rt},setClear:function(Rt){ln!==Rt&&(i.clearStencil(Rt),ln=Rt)},reset:function(){T=!1,Z=null,ce=null,ye=null,Re=null,vt=null,dt=null,zt=null,ln=null}}}const r=new e,o=new t,a=new n,l=new WeakMap,u=new WeakMap;let h={},d={},p=new WeakMap,m=[],g=null,y=!1,S=null,_=null,v=null,R=null,b=null,A=null,B=null,N=new Oe(0,0,0),D=0,C=!1,E=null,M=null,O=null,H=null,G=null;const Y=i.getParameter(i.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let $=!1,re=0;const se=i.getParameter(i.VERSION);se.indexOf("WebGL")!==-1?(re=parseFloat(/^WebGL (\d)/.exec(se)[1]),$=re>=1):se.indexOf("OpenGL ES")!==-1&&(re=parseFloat(/^OpenGL ES (\d)/.exec(se)[1]),$=re>=2);let K=null,ae={};const pe=i.getParameter(i.SCISSOR_BOX),ve=i.getParameter(i.VIEWPORT),ke=new Ut().fromArray(pe),Ze=new Ut().fromArray(ve);function te(T,Z,ce,ye){const Re=new Uint8Array(4),vt=i.createTexture();i.bindTexture(T,vt),i.texParameteri(T,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(T,i.TEXTURE_MAG_FILTER,i.NEAREST);for(let dt=0;dt<ce;dt++)T===i.TEXTURE_3D||T===i.TEXTURE_2D_ARRAY?i.texImage3D(Z,0,i.RGBA,1,1,ye,0,i.RGBA,i.UNSIGNED_BYTE,Re):i.texImage2D(Z+dt,0,i.RGBA,1,1,0,i.RGBA,i.UNSIGNED_BYTE,Re);return vt}const fe={};fe[i.TEXTURE_2D]=te(i.TEXTURE_2D,i.TEXTURE_2D,1),fe[i.TEXTURE_CUBE_MAP]=te(i.TEXTURE_CUBE_MAP,i.TEXTURE_CUBE_MAP_POSITIVE_X,6),fe[i.TEXTURE_2D_ARRAY]=te(i.TEXTURE_2D_ARRAY,i.TEXTURE_2D_ARRAY,1,1),fe[i.TEXTURE_3D]=te(i.TEXTURE_3D,i.TEXTURE_3D,1,1),r.setClear(0,0,0,1),o.setClear(1),a.setClear(0),Ee(i.DEPTH_TEST),o.setFunc(Tl),We(!1),At(ym),Ee(i.CULL_FACE),Fe(Jr);function Ee(T){h[T]!==!0&&(i.enable(T),h[T]=!0)}function Me(T){h[T]!==!1&&(i.disable(T),h[T]=!1)}function ze(T,Z){return d[T]!==Z?(i.bindFramebuffer(T,Z),d[T]=Z,T===i.DRAW_FRAMEBUFFER&&(d[i.FRAMEBUFFER]=Z),T===i.FRAMEBUFFER&&(d[i.DRAW_FRAMEBUFFER]=Z),!0):!1}function Ve(T,Z){let ce=m,ye=!1;if(T){ce=p.get(Z),ce===void 0&&(ce=[],p.set(Z,ce));const Re=T.textures;if(ce.length!==Re.length||ce[0]!==i.COLOR_ATTACHMENT0){for(let vt=0,dt=Re.length;vt<dt;vt++)ce[vt]=i.COLOR_ATTACHMENT0+vt;ce.length=Re.length,ye=!0}}else ce[0]!==i.BACK&&(ce[0]=i.BACK,ye=!0);ye&&i.drawBuffers(ce)}function it(T){return g!==T?(i.useProgram(T),g=T,!0):!1}const q={[Ts]:i.FUNC_ADD,[ab]:i.FUNC_SUBTRACT,[cb]:i.FUNC_REVERSE_SUBTRACT};q[lb]=i.MIN,q[ub]=i.MAX;const $e={[hb]:i.ZERO,[fb]:i.ONE,[db]:i.SRC_COLOR,[sf]:i.SRC_ALPHA,[xb]:i.SRC_ALPHA_SATURATE,[_b]:i.DST_COLOR,[mb]:i.DST_ALPHA,[pb]:i.ONE_MINUS_SRC_COLOR,[of]:i.ONE_MINUS_SRC_ALPHA,[vb]:i.ONE_MINUS_DST_COLOR,[gb]:i.ONE_MINUS_DST_ALPHA,[yb]:i.CONSTANT_COLOR,[Mb]:i.ONE_MINUS_CONSTANT_COLOR,[Sb]:i.CONSTANT_ALPHA,[Eb]:i.ONE_MINUS_CONSTANT_ALPHA};function Fe(T,Z,ce,ye,Re,vt,dt,zt,ln,Rt){if(T===Jr){y===!0&&(Me(i.BLEND),y=!1);return}if(y===!1&&(Ee(i.BLEND),y=!0),T!==ob){if(T!==S||Rt!==C){if((_!==Ts||b!==Ts)&&(i.blendEquation(i.FUNC_ADD),_=Ts,b=Ts),Rt)switch(T){case Eo:i.blendFuncSeparate(i.ONE,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case Mm:i.blendFunc(i.ONE,i.ONE);break;case Sm:i.blendFuncSeparate(i.ZERO,i.ONE_MINUS_SRC_COLOR,i.ZERO,i.ONE);break;case Em:i.blendFuncSeparate(i.ZERO,i.SRC_COLOR,i.ZERO,i.SRC_ALPHA);break;default:console.error("THREE.WebGLState: Invalid blending: ",T);break}else switch(T){case Eo:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case Mm:i.blendFunc(i.SRC_ALPHA,i.ONE);break;case Sm:i.blendFuncSeparate(i.ZERO,i.ONE_MINUS_SRC_COLOR,i.ZERO,i.ONE);break;case Em:i.blendFunc(i.ZERO,i.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",T);break}v=null,R=null,A=null,B=null,N.set(0,0,0),D=0,S=T,C=Rt}return}Re=Re||Z,vt=vt||ce,dt=dt||ye,(Z!==_||Re!==b)&&(i.blendEquationSeparate(q[Z],q[Re]),_=Z,b=Re),(ce!==v||ye!==R||vt!==A||dt!==B)&&(i.blendFuncSeparate($e[ce],$e[ye],$e[vt],$e[dt]),v=ce,R=ye,A=vt,B=dt),(zt.equals(N)===!1||ln!==D)&&(i.blendColor(zt.r,zt.g,zt.b,ln),N.copy(zt),D=ln),S=T,C=!1}function mt(T,Z){T.side===si?Me(i.CULL_FACE):Ee(i.CULL_FACE);let ce=T.side===Kn;Z&&(ce=!ce),We(ce),T.blending===Eo&&T.transparent===!1?Fe(Jr):Fe(T.blending,T.blendEquation,T.blendSrc,T.blendDst,T.blendEquationAlpha,T.blendSrcAlpha,T.blendDstAlpha,T.blendColor,T.blendAlpha,T.premultipliedAlpha),o.setFunc(T.depthFunc),o.setTest(T.depthTest),o.setMask(T.depthWrite),r.setMask(T.colorWrite);const ye=T.stencilWrite;a.setTest(ye),ye&&(a.setMask(T.stencilWriteMask),a.setFunc(T.stencilFunc,T.stencilRef,T.stencilFuncMask),a.setOp(T.stencilFail,T.stencilZFail,T.stencilZPass)),P(T.polygonOffset,T.polygonOffsetFactor,T.polygonOffsetUnits),T.alphaToCoverage===!0?Ee(i.SAMPLE_ALPHA_TO_COVERAGE):Me(i.SAMPLE_ALPHA_TO_COVERAGE)}function We(T){E!==T&&(T?i.frontFace(i.CW):i.frontFace(i.CCW),E=T)}function At(T){T!==rb?(Ee(i.CULL_FACE),T!==M&&(T===ym?i.cullFace(i.BACK):T===sb?i.cullFace(i.FRONT):i.cullFace(i.FRONT_AND_BACK))):Me(i.CULL_FACE),M=T}function z(T){T!==O&&($&&i.lineWidth(T),O=T)}function P(T,Z,ce){T?(Ee(i.POLYGON_OFFSET_FILL),(H!==Z||G!==ce)&&(i.polygonOffset(Z,ce),H=Z,G=ce)):Me(i.POLYGON_OFFSET_FILL)}function ie(T){T?Ee(i.SCISSOR_TEST):Me(i.SCISSOR_TEST)}function le(T){T===void 0&&(T=i.TEXTURE0+Y-1),K!==T&&(i.activeTexture(T),K=T)}function de(T,Z,ce){ce===void 0&&(K===null?ce=i.TEXTURE0+Y-1:ce=K);let ye=ae[ce];ye===void 0&&(ye={type:void 0,texture:void 0},ae[ce]=ye),(ye.type!==T||ye.texture!==Z)&&(K!==ce&&(i.activeTexture(ce),K=ce),i.bindTexture(T,Z||fe[T]),ye.type=T,ye.texture=Z)}function ge(){const T=ae[K];T!==void 0&&T.type!==void 0&&(i.bindTexture(T.type,null),T.type=void 0,T.texture=void 0)}function He(){try{i.compressedTexImage2D.apply(i,arguments)}catch(T){console.error("THREE.WebGLState:",T)}}function _e(){try{i.compressedTexImage3D.apply(i,arguments)}catch(T){console.error("THREE.WebGLState:",T)}}function De(){try{i.texSubImage2D.apply(i,arguments)}catch(T){console.error("THREE.WebGLState:",T)}}function Xe(){try{i.texSubImage3D.apply(i,arguments)}catch(T){console.error("THREE.WebGLState:",T)}}function xe(){try{i.compressedTexSubImage2D.apply(i,arguments)}catch(T){console.error("THREE.WebGLState:",T)}}function we(){try{i.compressedTexSubImage3D.apply(i,arguments)}catch(T){console.error("THREE.WebGLState:",T)}}function Ke(){try{i.texStorage2D.apply(i,arguments)}catch(T){console.error("THREE.WebGLState:",T)}}function Le(){try{i.texStorage3D.apply(i,arguments)}catch(T){console.error("THREE.WebGLState:",T)}}function Ie(){try{i.texImage2D.apply(i,arguments)}catch(T){console.error("THREE.WebGLState:",T)}}function ct(){try{i.texImage3D.apply(i,arguments)}catch(T){console.error("THREE.WebGLState:",T)}}function ft(T){ke.equals(T)===!1&&(i.scissor(T.x,T.y,T.z,T.w),ke.copy(T))}function Et(T){Ze.equals(T)===!1&&(i.viewport(T.x,T.y,T.z,T.w),Ze.copy(T))}function _t(T,Z){let ce=u.get(Z);ce===void 0&&(ce=new WeakMap,u.set(Z,ce));let ye=ce.get(T);ye===void 0&&(ye=i.getUniformBlockIndex(Z,T.name),ce.set(T,ye))}function Tt(T,Z){const ye=u.get(Z).get(T);l.get(Z)!==ye&&(i.uniformBlockBinding(Z,ye,T.__bindingPointIndex),l.set(Z,ye))}function Ne(){i.disable(i.BLEND),i.disable(i.CULL_FACE),i.disable(i.DEPTH_TEST),i.disable(i.POLYGON_OFFSET_FILL),i.disable(i.SCISSOR_TEST),i.disable(i.STENCIL_TEST),i.disable(i.SAMPLE_ALPHA_TO_COVERAGE),i.blendEquation(i.FUNC_ADD),i.blendFunc(i.ONE,i.ZERO),i.blendFuncSeparate(i.ONE,i.ZERO,i.ONE,i.ZERO),i.blendColor(0,0,0,0),i.colorMask(!0,!0,!0,!0),i.clearColor(0,0,0,0),i.depthMask(!0),i.depthFunc(i.LESS),i.clearDepth(1),i.stencilMask(4294967295),i.stencilFunc(i.ALWAYS,0,4294967295),i.stencilOp(i.KEEP,i.KEEP,i.KEEP),i.clearStencil(0),i.cullFace(i.BACK),i.frontFace(i.CCW),i.polygonOffset(0,0),i.activeTexture(i.TEXTURE0),i.bindFramebuffer(i.FRAMEBUFFER,null),i.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),i.bindFramebuffer(i.READ_FRAMEBUFFER,null),i.useProgram(null),i.lineWidth(1),i.scissor(0,0,i.canvas.width,i.canvas.height),i.viewport(0,0,i.canvas.width,i.canvas.height),h={},K=null,ae={},d={},p=new WeakMap,m=[],g=null,y=!1,S=null,_=null,v=null,R=null,b=null,A=null,B=null,N=new Oe(0,0,0),D=0,C=!1,E=null,M=null,O=null,H=null,G=null,ke.set(0,0,i.canvas.width,i.canvas.height),Ze.set(0,0,i.canvas.width,i.canvas.height),r.reset(),o.reset(),a.reset()}return{buffers:{color:r,depth:o,stencil:a},enable:Ee,disable:Me,bindFramebuffer:ze,drawBuffers:Ve,useProgram:it,setBlending:Fe,setMaterial:mt,setFlipSided:We,setCullFace:At,setLineWidth:z,setPolygonOffset:P,setScissorTest:ie,activeTexture:le,bindTexture:de,unbindTexture:ge,compressedTexImage2D:He,compressedTexImage3D:_e,texImage2D:Ie,texImage3D:ct,updateUBOMapping:_t,uniformBlockBinding:Tt,texStorage2D:Ke,texStorage3D:Le,texSubImage2D:De,texSubImage3D:Xe,compressedTexSubImage2D:xe,compressedTexSubImage3D:we,scissor:ft,viewport:Et,reset:Ne}}function yP(i,e,t,n,r,o,a){const l=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,u=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),h=new Pe,d=new WeakMap;let p;const m=new WeakMap;let g=!1;try{g=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function y(z,P){return g?new OffscreenCanvas(z,P):za("canvas")}function S(z,P,ie){let le=1;const de=At(z);if((de.width>ie||de.height>ie)&&(le=ie/Math.max(de.width,de.height)),le<1)if(typeof HTMLImageElement<"u"&&z instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&z instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&z instanceof ImageBitmap||typeof VideoFrame<"u"&&z instanceof VideoFrame){const ge=Math.floor(le*de.width),He=Math.floor(le*de.height);p===void 0&&(p=y(ge,He));const _e=P?y(ge,He):p;return _e.width=ge,_e.height=He,_e.getContext("2d").drawImage(z,0,0,ge,He),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+de.width+"x"+de.height+") to ("+ge+"x"+He+")."),_e}else return"data"in z&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+de.width+"x"+de.height+")."),z;return z}function _(z){return z.generateMipmaps&&z.minFilter!==Nn&&z.minFilter!==Xn}function v(z){i.generateMipmap(z)}function R(z,P,ie,le,de=!1){if(z!==null){if(i[z]!==void 0)return i[z];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+z+"'")}let ge=P;if(P===i.RED&&(ie===i.FLOAT&&(ge=i.R32F),ie===i.HALF_FLOAT&&(ge=i.R16F),ie===i.UNSIGNED_BYTE&&(ge=i.R8)),P===i.RED_INTEGER&&(ie===i.UNSIGNED_BYTE&&(ge=i.R8UI),ie===i.UNSIGNED_SHORT&&(ge=i.R16UI),ie===i.UNSIGNED_INT&&(ge=i.R32UI),ie===i.BYTE&&(ge=i.R8I),ie===i.SHORT&&(ge=i.R16I),ie===i.INT&&(ge=i.R32I)),P===i.RG&&(ie===i.FLOAT&&(ge=i.RG32F),ie===i.HALF_FLOAT&&(ge=i.RG16F),ie===i.UNSIGNED_BYTE&&(ge=i.RG8)),P===i.RG_INTEGER&&(ie===i.UNSIGNED_BYTE&&(ge=i.RG8UI),ie===i.UNSIGNED_SHORT&&(ge=i.RG16UI),ie===i.UNSIGNED_INT&&(ge=i.RG32UI),ie===i.BYTE&&(ge=i.RG8I),ie===i.SHORT&&(ge=i.RG16I),ie===i.INT&&(ge=i.RG32I)),P===i.RGB&&ie===i.UNSIGNED_INT_5_9_9_9_REV&&(ge=i.RGB9_E5),P===i.RGBA){const He=de?wl:Lt.getTransfer(le);ie===i.FLOAT&&(ge=i.RGBA32F),ie===i.HALF_FLOAT&&(ge=i.RGBA16F),ie===i.UNSIGNED_BYTE&&(ge=He===Wt?i.SRGB8_ALPHA8:i.RGBA8),ie===i.UNSIGNED_SHORT_4_4_4_4&&(ge=i.RGBA4),ie===i.UNSIGNED_SHORT_5_5_5_1&&(ge=i.RGB5_A1)}return(ge===i.R16F||ge===i.R32F||ge===i.RG16F||ge===i.RG32F||ge===i.RGBA16F||ge===i.RGBA32F)&&e.get("EXT_color_buffer_float"),ge}function b(z,P){return _(z)===!0||z.isFramebufferTexture&&z.minFilter!==Nn&&z.minFilter!==Xn?Math.log2(Math.max(P.width,P.height))+1:z.mipmaps!==void 0&&z.mipmaps.length>0?z.mipmaps.length:z.isCompressedTexture&&Array.isArray(z.image)?P.mipmaps.length:1}function A(z){const P=z.target;P.removeEventListener("dispose",A),N(P),P.isVideoTexture&&d.delete(P)}function B(z){const P=z.target;P.removeEventListener("dispose",B),C(P)}function N(z){const P=n.get(z);if(P.__webglInit===void 0)return;const ie=z.source,le=m.get(ie);if(le){const de=le[P.__cacheKey];de.usedTimes--,de.usedTimes===0&&D(z),Object.keys(le).length===0&&m.delete(ie)}n.remove(z)}function D(z){const P=n.get(z);i.deleteTexture(P.__webglTexture);const ie=z.source,le=m.get(ie);delete le[P.__cacheKey],a.memory.textures--}function C(z){const P=n.get(z);if(z.depthTexture&&z.depthTexture.dispose(),z.isWebGLCubeRenderTarget)for(let le=0;le<6;le++){if(Array.isArray(P.__webglFramebuffer[le]))for(let de=0;de<P.__webglFramebuffer[le].length;de++)i.deleteFramebuffer(P.__webglFramebuffer[le][de]);else i.deleteFramebuffer(P.__webglFramebuffer[le]);P.__webglDepthbuffer&&i.deleteRenderbuffer(P.__webglDepthbuffer[le])}else{if(Array.isArray(P.__webglFramebuffer))for(let le=0;le<P.__webglFramebuffer.length;le++)i.deleteFramebuffer(P.__webglFramebuffer[le]);else i.deleteFramebuffer(P.__webglFramebuffer);if(P.__webglDepthbuffer&&i.deleteRenderbuffer(P.__webglDepthbuffer),P.__webglMultisampledFramebuffer&&i.deleteFramebuffer(P.__webglMultisampledFramebuffer),P.__webglColorRenderbuffer)for(let le=0;le<P.__webglColorRenderbuffer.length;le++)P.__webglColorRenderbuffer[le]&&i.deleteRenderbuffer(P.__webglColorRenderbuffer[le]);P.__webglDepthRenderbuffer&&i.deleteRenderbuffer(P.__webglDepthRenderbuffer)}const ie=z.textures;for(let le=0,de=ie.length;le<de;le++){const ge=n.get(ie[le]);ge.__webglTexture&&(i.deleteTexture(ge.__webglTexture),a.memory.textures--),n.remove(ie[le])}n.remove(z)}let E=0;function M(){E=0}function O(){const z=E;return z>=r.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+z+" texture units while this GPU supports only "+r.maxTextures),E+=1,z}function H(z){const P=[];return P.push(z.wrapS),P.push(z.wrapT),P.push(z.wrapR||0),P.push(z.magFilter),P.push(z.minFilter),P.push(z.anisotropy),P.push(z.internalFormat),P.push(z.format),P.push(z.type),P.push(z.generateMipmaps),P.push(z.premultiplyAlpha),P.push(z.flipY),P.push(z.unpackAlignment),P.push(z.colorSpace),P.join()}function G(z,P){const ie=n.get(z);if(z.isVideoTexture&&mt(z),z.isRenderTargetTexture===!1&&z.version>0&&ie.__version!==z.version){const le=z.image;if(le===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(le.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{ke(ie,z,P);return}}t.bindTexture(i.TEXTURE_2D,ie.__webglTexture,i.TEXTURE0+P)}function Y(z,P){const ie=n.get(z);if(z.version>0&&ie.__version!==z.version){ke(ie,z,P);return}t.bindTexture(i.TEXTURE_2D_ARRAY,ie.__webglTexture,i.TEXTURE0+P)}function $(z,P){const ie=n.get(z);if(z.version>0&&ie.__version!==z.version){ke(ie,z,P);return}t.bindTexture(i.TEXTURE_3D,ie.__webglTexture,i.TEXTURE0+P)}function re(z,P){const ie=n.get(z);if(z.version>0&&ie.__version!==z.version){Ze(ie,z,P);return}t.bindTexture(i.TEXTURE_CUBE_MAP,ie.__webglTexture,i.TEXTURE0+P)}const se={[es]:i.REPEAT,[$i]:i.CLAMP_TO_EDGE,[Co]:i.MIRRORED_REPEAT},K={[Nn]:i.NEAREST,[Nf]:i.NEAREST_MIPMAP_NEAREST,[yo]:i.NEAREST_MIPMAP_LINEAR,[Xn]:i.LINEAR,[Da]:i.LINEAR_MIPMAP_NEAREST,[Ki]:i.LINEAR_MIPMAP_LINEAR},ae={[tw]:i.NEVER,[aw]:i.ALWAYS,[nw]:i.LESS,[c0]:i.LEQUAL,[iw]:i.EQUAL,[ow]:i.GEQUAL,[rw]:i.GREATER,[sw]:i.NOTEQUAL};function pe(z,P){if(P.type===Zi&&e.has("OES_texture_float_linear")===!1&&(P.magFilter===Xn||P.magFilter===Da||P.magFilter===yo||P.magFilter===Ki||P.minFilter===Xn||P.minFilter===Da||P.minFilter===yo||P.minFilter===Ki)&&console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),i.texParameteri(z,i.TEXTURE_WRAP_S,se[P.wrapS]),i.texParameteri(z,i.TEXTURE_WRAP_T,se[P.wrapT]),(z===i.TEXTURE_3D||z===i.TEXTURE_2D_ARRAY)&&i.texParameteri(z,i.TEXTURE_WRAP_R,se[P.wrapR]),i.texParameteri(z,i.TEXTURE_MAG_FILTER,K[P.magFilter]),i.texParameteri(z,i.TEXTURE_MIN_FILTER,K[P.minFilter]),P.compareFunction&&(i.texParameteri(z,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE),i.texParameteri(z,i.TEXTURE_COMPARE_FUNC,ae[P.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(P.magFilter===Nn||P.minFilter!==yo&&P.minFilter!==Ki||P.type===Zi&&e.has("OES_texture_float_linear")===!1)return;if(P.anisotropy>1||n.get(P).__currentAnisotropy){const ie=e.get("EXT_texture_filter_anisotropic");i.texParameterf(z,ie.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(P.anisotropy,r.getMaxAnisotropy())),n.get(P).__currentAnisotropy=P.anisotropy}}}function ve(z,P){let ie=!1;z.__webglInit===void 0&&(z.__webglInit=!0,P.addEventListener("dispose",A));const le=P.source;let de=m.get(le);de===void 0&&(de={},m.set(le,de));const ge=H(P);if(ge!==z.__cacheKey){de[ge]===void 0&&(de[ge]={texture:i.createTexture(),usedTimes:0},a.memory.textures++,ie=!0),de[ge].usedTimes++;const He=de[z.__cacheKey];He!==void 0&&(de[z.__cacheKey].usedTimes--,He.usedTimes===0&&D(P)),z.__cacheKey=ge,z.__webglTexture=de[ge].texture}return ie}function ke(z,P,ie){let le=i.TEXTURE_2D;(P.isDataArrayTexture||P.isCompressedArrayTexture)&&(le=i.TEXTURE_2D_ARRAY),P.isData3DTexture&&(le=i.TEXTURE_3D);const de=ve(z,P),ge=P.source;t.bindTexture(le,z.__webglTexture,i.TEXTURE0+ie);const He=n.get(ge);if(ge.version!==He.__version||de===!0){t.activeTexture(i.TEXTURE0+ie);const _e=Lt.getPrimaries(Lt.workingColorSpace),De=P.colorSpace===Sn?null:Lt.getPrimaries(P.colorSpace),Xe=P.colorSpace===Sn||_e===De?i.NONE:i.BROWSER_DEFAULT_WEBGL;i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,P.flipY),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,P.premultiplyAlpha),i.pixelStorei(i.UNPACK_ALIGNMENT,P.unpackAlignment),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,Xe);let xe=S(P.image,!1,r.maxTextureSize);xe=We(P,xe);const we=o.convert(P.format,P.colorSpace),Ke=o.convert(P.type);let Le=R(P.internalFormat,we,Ke,P.colorSpace,P.isVideoTexture);pe(le,P);let Ie;const ct=P.mipmaps,ft=P.isVideoTexture!==!0&&Le!==s0,Et=He.__version===void 0||de===!0,_t=ge.dataReady,Tt=b(P,xe);if(P.isDepthTexture)Le=i.DEPTH_COMPONENT16,P.type===Zi?Le=i.DEPTH_COMPONENT32F:P.type===Po?Le=i.DEPTH_COMPONENT24:P.type===Ga&&(Le=i.DEPTH24_STENCIL8),Et&&(ft?t.texStorage2D(i.TEXTURE_2D,1,Le,xe.width,xe.height):t.texImage2D(i.TEXTURE_2D,0,Le,xe.width,xe.height,0,we,Ke,null));else if(P.isDataTexture)if(ct.length>0){ft&&Et&&t.texStorage2D(i.TEXTURE_2D,Tt,Le,ct[0].width,ct[0].height);for(let Ne=0,T=ct.length;Ne<T;Ne++)Ie=ct[Ne],ft?_t&&t.texSubImage2D(i.TEXTURE_2D,Ne,0,0,Ie.width,Ie.height,we,Ke,Ie.data):t.texImage2D(i.TEXTURE_2D,Ne,Le,Ie.width,Ie.height,0,we,Ke,Ie.data);P.generateMipmaps=!1}else ft?(Et&&t.texStorage2D(i.TEXTURE_2D,Tt,Le,xe.width,xe.height),_t&&t.texSubImage2D(i.TEXTURE_2D,0,0,0,xe.width,xe.height,we,Ke,xe.data)):t.texImage2D(i.TEXTURE_2D,0,Le,xe.width,xe.height,0,we,Ke,xe.data);else if(P.isCompressedTexture)if(P.isCompressedArrayTexture){ft&&Et&&t.texStorage3D(i.TEXTURE_2D_ARRAY,Tt,Le,ct[0].width,ct[0].height,xe.depth);for(let Ne=0,T=ct.length;Ne<T;Ne++)Ie=ct[Ne],P.format!==Ei?we!==null?ft?_t&&t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,Ne,0,0,0,Ie.width,Ie.height,xe.depth,we,Ie.data,0,0):t.compressedTexImage3D(i.TEXTURE_2D_ARRAY,Ne,Le,Ie.width,Ie.height,xe.depth,0,Ie.data,0,0):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):ft?_t&&t.texSubImage3D(i.TEXTURE_2D_ARRAY,Ne,0,0,0,Ie.width,Ie.height,xe.depth,we,Ke,Ie.data):t.texImage3D(i.TEXTURE_2D_ARRAY,Ne,Le,Ie.width,Ie.height,xe.depth,0,we,Ke,Ie.data)}else{ft&&Et&&t.texStorage2D(i.TEXTURE_2D,Tt,Le,ct[0].width,ct[0].height);for(let Ne=0,T=ct.length;Ne<T;Ne++)Ie=ct[Ne],P.format!==Ei?we!==null?ft?_t&&t.compressedTexSubImage2D(i.TEXTURE_2D,Ne,0,0,Ie.width,Ie.height,we,Ie.data):t.compressedTexImage2D(i.TEXTURE_2D,Ne,Le,Ie.width,Ie.height,0,Ie.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):ft?_t&&t.texSubImage2D(i.TEXTURE_2D,Ne,0,0,Ie.width,Ie.height,we,Ke,Ie.data):t.texImage2D(i.TEXTURE_2D,Ne,Le,Ie.width,Ie.height,0,we,Ke,Ie.data)}else if(P.isDataArrayTexture)ft?(Et&&t.texStorage3D(i.TEXTURE_2D_ARRAY,Tt,Le,xe.width,xe.height,xe.depth),_t&&t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,0,xe.width,xe.height,xe.depth,we,Ke,xe.data)):t.texImage3D(i.TEXTURE_2D_ARRAY,0,Le,xe.width,xe.height,xe.depth,0,we,Ke,xe.data);else if(P.isData3DTexture)ft?(Et&&t.texStorage3D(i.TEXTURE_3D,Tt,Le,xe.width,xe.height,xe.depth),_t&&t.texSubImage3D(i.TEXTURE_3D,0,0,0,0,xe.width,xe.height,xe.depth,we,Ke,xe.data)):t.texImage3D(i.TEXTURE_3D,0,Le,xe.width,xe.height,xe.depth,0,we,Ke,xe.data);else if(P.isFramebufferTexture){if(Et)if(ft)t.texStorage2D(i.TEXTURE_2D,Tt,Le,xe.width,xe.height);else{let Ne=xe.width,T=xe.height;for(let Z=0;Z<Tt;Z++)t.texImage2D(i.TEXTURE_2D,Z,Le,Ne,T,0,we,Ke,null),Ne>>=1,T>>=1}}else if(ct.length>0){if(ft&&Et){const Ne=At(ct[0]);t.texStorage2D(i.TEXTURE_2D,Tt,Le,Ne.width,Ne.height)}for(let Ne=0,T=ct.length;Ne<T;Ne++)Ie=ct[Ne],ft?_t&&t.texSubImage2D(i.TEXTURE_2D,Ne,0,0,we,Ke,Ie):t.texImage2D(i.TEXTURE_2D,Ne,Le,we,Ke,Ie);P.generateMipmaps=!1}else if(ft){if(Et){const Ne=At(xe);t.texStorage2D(i.TEXTURE_2D,Tt,Le,Ne.width,Ne.height)}_t&&t.texSubImage2D(i.TEXTURE_2D,0,0,0,we,Ke,xe)}else t.texImage2D(i.TEXTURE_2D,0,Le,we,Ke,xe);_(P)&&v(le),He.__version=ge.version,P.onUpdate&&P.onUpdate(P)}z.__version=P.version}function Ze(z,P,ie){if(P.image.length!==6)return;const le=ve(z,P),de=P.source;t.bindTexture(i.TEXTURE_CUBE_MAP,z.__webglTexture,i.TEXTURE0+ie);const ge=n.get(de);if(de.version!==ge.__version||le===!0){t.activeTexture(i.TEXTURE0+ie);const He=Lt.getPrimaries(Lt.workingColorSpace),_e=P.colorSpace===Sn?null:Lt.getPrimaries(P.colorSpace),De=P.colorSpace===Sn||He===_e?i.NONE:i.BROWSER_DEFAULT_WEBGL;i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,P.flipY),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,P.premultiplyAlpha),i.pixelStorei(i.UNPACK_ALIGNMENT,P.unpackAlignment),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,De);const Xe=P.isCompressedTexture||P.image[0].isCompressedTexture,xe=P.image[0]&&P.image[0].isDataTexture,we=[];for(let T=0;T<6;T++)!Xe&&!xe?we[T]=S(P.image[T],!0,r.maxCubemapSize):we[T]=xe?P.image[T].image:P.image[T],we[T]=We(P,we[T]);const Ke=we[0],Le=o.convert(P.format,P.colorSpace),Ie=o.convert(P.type),ct=R(P.internalFormat,Le,Ie,P.colorSpace),ft=P.isVideoTexture!==!0,Et=ge.__version===void 0||le===!0,_t=de.dataReady;let Tt=b(P,Ke);pe(i.TEXTURE_CUBE_MAP,P);let Ne;if(Xe){ft&&Et&&t.texStorage2D(i.TEXTURE_CUBE_MAP,Tt,ct,Ke.width,Ke.height);for(let T=0;T<6;T++){Ne=we[T].mipmaps;for(let Z=0;Z<Ne.length;Z++){const ce=Ne[Z];P.format!==Ei?Le!==null?ft?_t&&t.compressedTexSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+T,Z,0,0,ce.width,ce.height,Le,ce.data):t.compressedTexImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+T,Z,ct,ce.width,ce.height,0,ce.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):ft?_t&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+T,Z,0,0,ce.width,ce.height,Le,Ie,ce.data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+T,Z,ct,ce.width,ce.height,0,Le,Ie,ce.data)}}}else{if(Ne=P.mipmaps,ft&&Et){Ne.length>0&&Tt++;const T=At(we[0]);t.texStorage2D(i.TEXTURE_CUBE_MAP,Tt,ct,T.width,T.height)}for(let T=0;T<6;T++)if(xe){ft?_t&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+T,0,0,0,we[T].width,we[T].height,Le,Ie,we[T].data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+T,0,ct,we[T].width,we[T].height,0,Le,Ie,we[T].data);for(let Z=0;Z<Ne.length;Z++){const ye=Ne[Z].image[T].image;ft?_t&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+T,Z+1,0,0,ye.width,ye.height,Le,Ie,ye.data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+T,Z+1,ct,ye.width,ye.height,0,Le,Ie,ye.data)}}else{ft?_t&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+T,0,0,0,Le,Ie,we[T]):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+T,0,ct,Le,Ie,we[T]);for(let Z=0;Z<Ne.length;Z++){const ce=Ne[Z];ft?_t&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+T,Z+1,0,0,Le,Ie,ce.image[T]):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+T,Z+1,ct,Le,Ie,ce.image[T])}}}_(P)&&v(i.TEXTURE_CUBE_MAP),ge.__version=de.version,P.onUpdate&&P.onUpdate(P)}z.__version=P.version}function te(z,P,ie,le,de,ge){const He=o.convert(ie.format,ie.colorSpace),_e=o.convert(ie.type),De=R(ie.internalFormat,He,_e,ie.colorSpace);if(!n.get(P).__hasExternalTextures){const xe=Math.max(1,P.width>>ge),we=Math.max(1,P.height>>ge);de===i.TEXTURE_3D||de===i.TEXTURE_2D_ARRAY?t.texImage3D(de,ge,De,xe,we,P.depth,0,He,_e,null):t.texImage2D(de,ge,De,xe,we,0,He,_e,null)}t.bindFramebuffer(i.FRAMEBUFFER,z),Fe(P)?l.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,le,de,n.get(ie).__webglTexture,0,$e(P)):(de===i.TEXTURE_2D||de>=i.TEXTURE_CUBE_MAP_POSITIVE_X&&de<=i.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&i.framebufferTexture2D(i.FRAMEBUFFER,le,de,n.get(ie).__webglTexture,ge),t.bindFramebuffer(i.FRAMEBUFFER,null)}function fe(z,P,ie){if(i.bindRenderbuffer(i.RENDERBUFFER,z),P.depthBuffer&&!P.stencilBuffer){let le=i.DEPTH_COMPONENT24;if(ie||Fe(P)){const de=P.depthTexture;de&&de.isDepthTexture&&(de.type===Zi?le=i.DEPTH_COMPONENT32F:de.type===Po&&(le=i.DEPTH_COMPONENT24));const ge=$e(P);Fe(P)?l.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,ge,le,P.width,P.height):i.renderbufferStorageMultisample(i.RENDERBUFFER,ge,le,P.width,P.height)}else i.renderbufferStorage(i.RENDERBUFFER,le,P.width,P.height);i.framebufferRenderbuffer(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.RENDERBUFFER,z)}else if(P.depthBuffer&&P.stencilBuffer){const le=$e(P);ie&&Fe(P)===!1?i.renderbufferStorageMultisample(i.RENDERBUFFER,le,i.DEPTH24_STENCIL8,P.width,P.height):Fe(P)?l.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,le,i.DEPTH24_STENCIL8,P.width,P.height):i.renderbufferStorage(i.RENDERBUFFER,i.DEPTH_STENCIL,P.width,P.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.RENDERBUFFER,z)}else{const le=P.textures;for(let de=0;de<le.length;de++){const ge=le[de],He=o.convert(ge.format,ge.colorSpace),_e=o.convert(ge.type),De=R(ge.internalFormat,He,_e,ge.colorSpace),Xe=$e(P);ie&&Fe(P)===!1?i.renderbufferStorageMultisample(i.RENDERBUFFER,Xe,De,P.width,P.height):Fe(P)?l.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,Xe,De,P.width,P.height):i.renderbufferStorage(i.RENDERBUFFER,De,P.width,P.height)}}i.bindRenderbuffer(i.RENDERBUFFER,null)}function Ee(z,P){if(P&&P.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(t.bindFramebuffer(i.FRAMEBUFFER,z),!(P.depthTexture&&P.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!n.get(P.depthTexture).__webglTexture||P.depthTexture.image.width!==P.width||P.depthTexture.image.height!==P.height)&&(P.depthTexture.image.width=P.width,P.depthTexture.image.height=P.height,P.depthTexture.needsUpdate=!0),G(P.depthTexture,0);const le=n.get(P.depthTexture).__webglTexture,de=$e(P);if(P.depthTexture.format===To)Fe(P)?l.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.TEXTURE_2D,le,0,de):i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.TEXTURE_2D,le,0);else if(P.depthTexture.format===Ba)Fe(P)?l.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.TEXTURE_2D,le,0,de):i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.TEXTURE_2D,le,0);else throw new Error("Unknown depthTexture format")}function Me(z){const P=n.get(z),ie=z.isWebGLCubeRenderTarget===!0;if(z.depthTexture&&!P.__autoAllocateDepthBuffer){if(ie)throw new Error("target.depthTexture not supported in Cube render targets");Ee(P.__webglFramebuffer,z)}else if(ie){P.__webglDepthbuffer=[];for(let le=0;le<6;le++)t.bindFramebuffer(i.FRAMEBUFFER,P.__webglFramebuffer[le]),P.__webglDepthbuffer[le]=i.createRenderbuffer(),fe(P.__webglDepthbuffer[le],z,!1)}else t.bindFramebuffer(i.FRAMEBUFFER,P.__webglFramebuffer),P.__webglDepthbuffer=i.createRenderbuffer(),fe(P.__webglDepthbuffer,z,!1);t.bindFramebuffer(i.FRAMEBUFFER,null)}function ze(z,P,ie){const le=n.get(z);P!==void 0&&te(le.__webglFramebuffer,z,z.texture,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,0),ie!==void 0&&Me(z)}function Ve(z){const P=z.texture,ie=n.get(z),le=n.get(P);z.addEventListener("dispose",B);const de=z.textures,ge=z.isWebGLCubeRenderTarget===!0,He=de.length>1;if(He||(le.__webglTexture===void 0&&(le.__webglTexture=i.createTexture()),le.__version=P.version,a.memory.textures++),ge){ie.__webglFramebuffer=[];for(let _e=0;_e<6;_e++)if(P.mipmaps&&P.mipmaps.length>0){ie.__webglFramebuffer[_e]=[];for(let De=0;De<P.mipmaps.length;De++)ie.__webglFramebuffer[_e][De]=i.createFramebuffer()}else ie.__webglFramebuffer[_e]=i.createFramebuffer()}else{if(P.mipmaps&&P.mipmaps.length>0){ie.__webglFramebuffer=[];for(let _e=0;_e<P.mipmaps.length;_e++)ie.__webglFramebuffer[_e]=i.createFramebuffer()}else ie.__webglFramebuffer=i.createFramebuffer();if(He)for(let _e=0,De=de.length;_e<De;_e++){const Xe=n.get(de[_e]);Xe.__webglTexture===void 0&&(Xe.__webglTexture=i.createTexture(),a.memory.textures++)}if(z.samples>0&&Fe(z)===!1){ie.__webglMultisampledFramebuffer=i.createFramebuffer(),ie.__webglColorRenderbuffer=[],t.bindFramebuffer(i.FRAMEBUFFER,ie.__webglMultisampledFramebuffer);for(let _e=0;_e<de.length;_e++){const De=de[_e];ie.__webglColorRenderbuffer[_e]=i.createRenderbuffer(),i.bindRenderbuffer(i.RENDERBUFFER,ie.__webglColorRenderbuffer[_e]);const Xe=o.convert(De.format,De.colorSpace),xe=o.convert(De.type),we=R(De.internalFormat,Xe,xe,De.colorSpace,z.isXRRenderTarget===!0),Ke=$e(z);i.renderbufferStorageMultisample(i.RENDERBUFFER,Ke,we,z.width,z.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+_e,i.RENDERBUFFER,ie.__webglColorRenderbuffer[_e])}i.bindRenderbuffer(i.RENDERBUFFER,null),z.depthBuffer&&(ie.__webglDepthRenderbuffer=i.createRenderbuffer(),fe(ie.__webglDepthRenderbuffer,z,!0)),t.bindFramebuffer(i.FRAMEBUFFER,null)}}if(ge){t.bindTexture(i.TEXTURE_CUBE_MAP,le.__webglTexture),pe(i.TEXTURE_CUBE_MAP,P);for(let _e=0;_e<6;_e++)if(P.mipmaps&&P.mipmaps.length>0)for(let De=0;De<P.mipmaps.length;De++)te(ie.__webglFramebuffer[_e][De],z,P,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+_e,De);else te(ie.__webglFramebuffer[_e],z,P,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+_e,0);_(P)&&v(i.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(He){for(let _e=0,De=de.length;_e<De;_e++){const Xe=de[_e],xe=n.get(Xe);t.bindTexture(i.TEXTURE_2D,xe.__webglTexture),pe(i.TEXTURE_2D,Xe),te(ie.__webglFramebuffer,z,Xe,i.COLOR_ATTACHMENT0+_e,i.TEXTURE_2D,0),_(Xe)&&v(i.TEXTURE_2D)}t.unbindTexture()}else{let _e=i.TEXTURE_2D;if((z.isWebGL3DRenderTarget||z.isWebGLArrayRenderTarget)&&(_e=z.isWebGL3DRenderTarget?i.TEXTURE_3D:i.TEXTURE_2D_ARRAY),t.bindTexture(_e,le.__webglTexture),pe(_e,P),P.mipmaps&&P.mipmaps.length>0)for(let De=0;De<P.mipmaps.length;De++)te(ie.__webglFramebuffer[De],z,P,i.COLOR_ATTACHMENT0,_e,De);else te(ie.__webglFramebuffer,z,P,i.COLOR_ATTACHMENT0,_e,0);_(P)&&v(_e),t.unbindTexture()}z.depthBuffer&&Me(z)}function it(z){const P=z.textures;for(let ie=0,le=P.length;ie<le;ie++){const de=P[ie];if(_(de)){const ge=z.isWebGLCubeRenderTarget?i.TEXTURE_CUBE_MAP:i.TEXTURE_2D,He=n.get(de).__webglTexture;t.bindTexture(ge,He),v(ge),t.unbindTexture()}}}function q(z){if(z.samples>0&&Fe(z)===!1){const P=z.textures,ie=z.width,le=z.height;let de=i.COLOR_BUFFER_BIT;const ge=[],He=z.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,_e=n.get(z),De=P.length>1;if(De)for(let Xe=0;Xe<P.length;Xe++)t.bindFramebuffer(i.FRAMEBUFFER,_e.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+Xe,i.RENDERBUFFER,null),t.bindFramebuffer(i.FRAMEBUFFER,_e.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+Xe,i.TEXTURE_2D,null,0);t.bindFramebuffer(i.READ_FRAMEBUFFER,_e.__webglMultisampledFramebuffer),t.bindFramebuffer(i.DRAW_FRAMEBUFFER,_e.__webglFramebuffer);for(let Xe=0;Xe<P.length;Xe++){ge.push(i.COLOR_ATTACHMENT0+Xe),z.depthBuffer&&ge.push(He);const xe=_e.__ignoreDepthValues!==void 0?_e.__ignoreDepthValues:!1;if(xe===!1&&(z.depthBuffer&&(de|=i.DEPTH_BUFFER_BIT),z.stencilBuffer&&_e.__isTransmissionRenderTarget!==!0&&(de|=i.STENCIL_BUFFER_BIT)),De&&i.framebufferRenderbuffer(i.READ_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.RENDERBUFFER,_e.__webglColorRenderbuffer[Xe]),xe===!0&&(i.invalidateFramebuffer(i.READ_FRAMEBUFFER,[He]),i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,[He])),De){const we=n.get(P[Xe]).__webglTexture;i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,we,0)}i.blitFramebuffer(0,0,ie,le,0,0,ie,le,de,i.NEAREST),u&&i.invalidateFramebuffer(i.READ_FRAMEBUFFER,ge)}if(t.bindFramebuffer(i.READ_FRAMEBUFFER,null),t.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),De)for(let Xe=0;Xe<P.length;Xe++){t.bindFramebuffer(i.FRAMEBUFFER,_e.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+Xe,i.RENDERBUFFER,_e.__webglColorRenderbuffer[Xe]);const xe=n.get(P[Xe]).__webglTexture;t.bindFramebuffer(i.FRAMEBUFFER,_e.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+Xe,i.TEXTURE_2D,xe,0)}t.bindFramebuffer(i.DRAW_FRAMEBUFFER,_e.__webglMultisampledFramebuffer)}}function $e(z){return Math.min(r.maxSamples,z.samples)}function Fe(z){const P=n.get(z);return z.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&P.__useRenderToTexture!==!1}function mt(z){const P=a.render.frame;d.get(z)!==P&&(d.set(z,P),z.update())}function We(z,P){const ie=z.colorSpace,le=z.format,de=z.type;return z.isCompressedTexture===!0||z.isVideoTexture===!0||ie!==Tn&&ie!==Sn&&(Lt.getTransfer(ie)===Wt?(le!==Ei||de!==Qr)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",ie)),P}function At(z){return typeof HTMLImageElement<"u"&&z instanceof HTMLImageElement?(h.width=z.naturalWidth||z.width,h.height=z.naturalHeight||z.height):typeof VideoFrame<"u"&&z instanceof VideoFrame?(h.width=z.displayWidth,h.height=z.displayHeight):(h.width=z.width,h.height=z.height),h}this.allocateTextureUnit=O,this.resetTextureUnits=M,this.setTexture2D=G,this.setTexture2DArray=Y,this.setTexture3D=$,this.setTextureCube=re,this.rebindTextures=ze,this.setupRenderTarget=Ve,this.updateRenderTargetMipmap=it,this.updateMultisampleRenderTarget=q,this.setupDepthRenderbuffer=Me,this.setupFrameBufferTexture=te,this.useMultisampledRTT=Fe}function MP(i,e){function t(n,r=Sn){let o;const a=Lt.getTransfer(r);if(n===Qr)return i.UNSIGNED_BYTE;if(n===Q_)return i.UNSIGNED_SHORT_4_4_4_4;if(n===e0)return i.UNSIGNED_SHORT_5_5_5_1;if(n===Vb)return i.UNSIGNED_INT_5_9_9_9_REV;if(n===Hb)return i.BYTE;if(n===Gb)return i.SHORT;if(n===Z_)return i.UNSIGNED_SHORT;if(n===J_)return i.INT;if(n===Po)return i.UNSIGNED_INT;if(n===Zi)return i.FLOAT;if(n===bl)return i.HALF_FLOAT;if(n===Wb)return i.ALPHA;if(n===Xb)return i.RGB;if(n===Ei)return i.RGBA;if(n===Yb)return i.LUMINANCE;if(n===jb)return i.LUMINANCE_ALPHA;if(n===To)return i.DEPTH_COMPONENT;if(n===Ba)return i.DEPTH_STENCIL;if(n===t0)return i.RED;if(n===n0)return i.RED_INTEGER;if(n===qb)return i.RG;if(n===i0)return i.RG_INTEGER;if(n===r0)return i.RGBA_INTEGER;if(n===rh||n===sh||n===oh||n===ah)if(a===Wt)if(o=e.get("WEBGL_compressed_texture_s3tc_srgb"),o!==null){if(n===rh)return o.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===sh)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===oh)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===ah)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(o=e.get("WEBGL_compressed_texture_s3tc"),o!==null){if(n===rh)return o.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===sh)return o.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===oh)return o.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===ah)return o.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===bm||n===wm||n===Am||n===Rm)if(o=e.get("WEBGL_compressed_texture_pvrtc"),o!==null){if(n===bm)return o.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===wm)return o.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===Am)return o.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===Rm)return o.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===s0)return o=e.get("WEBGL_compressed_texture_etc1"),o!==null?o.COMPRESSED_RGB_ETC1_WEBGL:null;if(n===Cm||n===Pm)if(o=e.get("WEBGL_compressed_texture_etc"),o!==null){if(n===Cm)return a===Wt?o.COMPRESSED_SRGB8_ETC2:o.COMPRESSED_RGB8_ETC2;if(n===Pm)return a===Wt?o.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:o.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(n===Lm||n===Im||n===Dm||n===Um||n===Nm||n===Om||n===Fm||n===Bm||n===zm||n===km||n===Hm||n===Gm||n===Vm||n===Wm)if(o=e.get("WEBGL_compressed_texture_astc"),o!==null){if(n===Lm)return a===Wt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:o.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===Im)return a===Wt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:o.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===Dm)return a===Wt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:o.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===Um)return a===Wt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:o.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===Nm)return a===Wt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:o.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===Om)return a===Wt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:o.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===Fm)return a===Wt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:o.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===Bm)return a===Wt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:o.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===zm)return a===Wt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:o.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===km)return a===Wt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:o.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===Hm)return a===Wt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:o.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===Gm)return a===Wt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:o.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===Vm)return a===Wt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:o.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===Wm)return a===Wt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:o.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===ch||n===Xm||n===Ym)if(o=e.get("EXT_texture_compression_bptc"),o!==null){if(n===ch)return a===Wt?o.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:o.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===Xm)return o.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===Ym)return o.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===$b||n===jm||n===qm||n===$m)if(o=e.get("EXT_texture_compression_rgtc"),o!==null){if(n===ch)return o.COMPRESSED_RED_RGTC1_EXT;if(n===jm)return o.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===qm)return o.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===$m)return o.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===Ga?i.UNSIGNED_INT_24_8:i[n]!==void 0?i[n]:null}return{convert:t}}class SP extends Un{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}}let Qi=class extends gt{constructor(){super(),this.isGroup=!0,this.type="Group"}};const EP={type:"move"};class Uh{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Qi,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new Qi,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new F,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new F),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Qi,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new F,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new F),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const t=this._hand;if(t)for(const n of e.hand.values())this._getHandJoint(t,n)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,n){let r=null,o=null,a=null;const l=this._targetRay,u=this._grip,h=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(h&&e.hand){a=!0;for(const S of e.hand.values()){const _=t.getJointPose(S,n),v=this._getHandJoint(h,S);_!==null&&(v.matrix.fromArray(_.transform.matrix),v.matrix.decompose(v.position,v.rotation,v.scale),v.matrixWorldNeedsUpdate=!0,v.jointRadius=_.radius),v.visible=_!==null}const d=h.joints["index-finger-tip"],p=h.joints["thumb-tip"],m=d.position.distanceTo(p.position),g=.02,y=.005;h.inputState.pinching&&m>g+y?(h.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!h.inputState.pinching&&m<=g-y&&(h.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else u!==null&&e.gripSpace&&(o=t.getPose(e.gripSpace,n),o!==null&&(u.matrix.fromArray(o.transform.matrix),u.matrix.decompose(u.position,u.rotation,u.scale),u.matrixWorldNeedsUpdate=!0,o.linearVelocity?(u.hasLinearVelocity=!0,u.linearVelocity.copy(o.linearVelocity)):u.hasLinearVelocity=!1,o.angularVelocity?(u.hasAngularVelocity=!0,u.angularVelocity.copy(o.angularVelocity)):u.hasAngularVelocity=!1));l!==null&&(r=t.getPose(e.targetRaySpace,n),r===null&&o!==null&&(r=o),r!==null&&(l.matrix.fromArray(r.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,r.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(r.linearVelocity)):l.hasLinearVelocity=!1,r.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(r.angularVelocity)):l.hasAngularVelocity=!1,this.dispatchEvent(EP)))}return l!==null&&(l.visible=r!==null),u!==null&&(u.visible=o!==null),h!==null&&(h.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const n=new Qi;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}const TP=`
3774
3774
  void main() {
3775
3775
 
3776
3776
  gl_Position = vec4( position, 1.0 );
@@ -3794,16 +3794,16 @@ void main() {
3794
3794
 
3795
3795
  }
3796
3796
 
3797
- }`;class wP{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t,n){if(this.texture===null){const r=new cn,o=e.properties.get(r);o.__webglTexture=t.texture,(t.depthNear!=n.depthNear||t.depthFar!=n.depthFar)&&(this.depthNear=t.depthNear,this.depthFar=t.depthFar),this.texture=r}}render(e,t){if(this.texture!==null){if(this.mesh===null){const n=t.cameras[0].viewport,r=new Rr({vertexShader:TP,fragmentShader:bP,uniforms:{depthColor:{value:this.texture},depthWidth:{value:n.z},depthHeight:{value:n.w}}});this.mesh=new Se(new ns(20,20),r)}e.render(this.mesh,t)}}reset(){this.texture=null,this.mesh=null}}class AP extends Ps{constructor(e,t){super();const n=this;let r=null,o=1,a=null,l="local-floor",u=1,h=null,d=null,p=null,m=null,g=null,y=null;const S=new wP,_=t.getContextAttributes();let v=null,R=null;const b=[],A=[],B=new Pe;let N=null;const D=new Un;D.layers.enable(1),D.viewport=new Ut;const C=new Un;C.layers.enable(2),C.viewport=new Ut;const E=[D,C],M=new SP;M.layers.enable(1),M.layers.enable(2);let O=null,H=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(te){let fe=b[te];return fe===void 0&&(fe=new Dh,b[te]=fe),fe.getTargetRaySpace()},this.getControllerGrip=function(te){let fe=b[te];return fe===void 0&&(fe=new Dh,b[te]=fe),fe.getGripSpace()},this.getHand=function(te){let fe=b[te];return fe===void 0&&(fe=new Dh,b[te]=fe),fe.getHandSpace()};function G(te){const fe=A.indexOf(te.inputSource);if(fe===-1)return;const Ee=b[fe];Ee!==void 0&&(Ee.update(te.inputSource,te.frame,h||a),Ee.dispatchEvent({type:te.type,data:te.inputSource}))}function Y(){r.removeEventListener("select",G),r.removeEventListener("selectstart",G),r.removeEventListener("selectend",G),r.removeEventListener("squeeze",G),r.removeEventListener("squeezestart",G),r.removeEventListener("squeezeend",G),r.removeEventListener("end",Y),r.removeEventListener("inputsourceschange",$);for(let te=0;te<b.length;te++){const fe=A[te];fe!==null&&(A[te]=null,b[te].disconnect(fe))}O=null,H=null,S.reset(),e.setRenderTarget(v),g=null,m=null,p=null,r=null,R=null,Ze.stop(),n.isPresenting=!1,e.setPixelRatio(N),e.setSize(B.width,B.height,!1),n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(te){o=te,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(te){l=te,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return h||a},this.setReferenceSpace=function(te){h=te},this.getBaseLayer=function(){return m!==null?m:g},this.getBinding=function(){return p},this.getFrame=function(){return y},this.getSession=function(){return r},this.setSession=async function(te){if(r=te,r!==null){if(v=e.getRenderTarget(),r.addEventListener("select",G),r.addEventListener("selectstart",G),r.addEventListener("selectend",G),r.addEventListener("squeeze",G),r.addEventListener("squeezestart",G),r.addEventListener("squeezeend",G),r.addEventListener("end",Y),r.addEventListener("inputsourceschange",$),_.xrCompatible!==!0&&await t.makeXRCompatible(),N=e.getPixelRatio(),e.getSize(B),r.renderState.layers===void 0){const fe={antialias:_.antialias,alpha:!0,depth:_.depth,stencil:_.stencil,framebufferScaleFactor:o};g=new XRWebGLLayer(r,t,fe),r.updateRenderState({baseLayer:g}),e.setPixelRatio(1),e.setSize(g.framebufferWidth,g.framebufferHeight,!1),R=new Rs(g.framebufferWidth,g.framebufferHeight,{format:Ei,type:Qr,colorSpace:e.outputColorSpace,stencilBuffer:_.stencil})}else{let fe=null,Ee=null,Me=null;_.depth&&(Me=_.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,fe=_.stencil?Ba:To,Ee=_.stencil?Ga:Po);const ze={colorFormat:t.RGBA8,depthFormat:Me,scaleFactor:o};p=new XRWebGLBinding(r,t),m=p.createProjectionLayer(ze),r.updateRenderState({layers:[m]}),e.setPixelRatio(1),e.setSize(m.textureWidth,m.textureHeight,!1),R=new Rs(m.textureWidth,m.textureHeight,{format:Ei,type:Qr,depthTexture:new y0(m.textureWidth,m.textureHeight,Ee,void 0,void 0,void 0,void 0,void 0,void 0,fe),stencilBuffer:_.stencil,colorSpace:e.outputColorSpace,samples:_.antialias?4:0});const Ve=e.properties.get(R);Ve.__ignoreDepthValues=m.ignoreDepthValues}R.isXRRenderTarget=!0,this.setFoveation(u),h=null,a=await r.requestReferenceSpace(l),Ze.setContext(r),Ze.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(r!==null)return r.environmentBlendMode};function $(te){for(let fe=0;fe<te.removed.length;fe++){const Ee=te.removed[fe],Me=A.indexOf(Ee);Me>=0&&(A[Me]=null,b[Me].disconnect(Ee))}for(let fe=0;fe<te.added.length;fe++){const Ee=te.added[fe];let Me=A.indexOf(Ee);if(Me===-1){for(let Ve=0;Ve<b.length;Ve++)if(Ve>=A.length){A.push(Ee),Me=Ve;break}else if(A[Ve]===null){A[Ve]=Ee,Me=Ve;break}if(Me===-1)break}const ze=b[Me];ze&&ze.connect(Ee)}}const re=new F,se=new F;function K(te,fe,Ee){re.setFromMatrixPosition(fe.matrixWorld),se.setFromMatrixPosition(Ee.matrixWorld);const Me=re.distanceTo(se),ze=fe.projectionMatrix.elements,Ve=Ee.projectionMatrix.elements,it=ze[14]/(ze[10]-1),q=ze[14]/(ze[10]+1),$e=(ze[9]+1)/ze[5],Fe=(ze[9]-1)/ze[5],mt=(ze[8]-1)/ze[0],We=(Ve[8]+1)/Ve[0],At=it*mt,z=it*We,P=Me/(-mt+We),ie=P*-mt;fe.matrixWorld.decompose(te.position,te.quaternion,te.scale),te.translateX(ie),te.translateZ(P),te.matrixWorld.compose(te.position,te.quaternion,te.scale),te.matrixWorldInverse.copy(te.matrixWorld).invert();const le=it+P,de=q+P,ge=At-ie,He=z+(Me-ie),_e=$e*q/de*le,De=Fe*q/de*le;te.projectionMatrix.makePerspective(ge,He,_e,De,le,de),te.projectionMatrixInverse.copy(te.projectionMatrix).invert()}function ae(te,fe){fe===null?te.matrixWorld.copy(te.matrix):te.matrixWorld.multiplyMatrices(fe.matrixWorld,te.matrix),te.matrixWorldInverse.copy(te.matrixWorld).invert()}this.updateCamera=function(te){if(r===null)return;S.texture!==null&&(te.near=S.depthNear,te.far=S.depthFar),M.near=C.near=D.near=te.near,M.far=C.far=D.far=te.far,(O!==M.near||H!==M.far)&&(r.updateRenderState({depthNear:M.near,depthFar:M.far}),O=M.near,H=M.far,D.near=O,D.far=H,C.near=O,C.far=H,D.updateProjectionMatrix(),C.updateProjectionMatrix(),te.updateProjectionMatrix());const fe=te.parent,Ee=M.cameras;ae(M,fe);for(let Me=0;Me<Ee.length;Me++)ae(Ee[Me],fe);Ee.length===2?K(M,D,C):M.projectionMatrix.copy(D.projectionMatrix),pe(te,M,fe)};function pe(te,fe,Ee){Ee===null?te.matrix.copy(fe.matrixWorld):(te.matrix.copy(Ee.matrixWorld),te.matrix.invert(),te.matrix.multiply(fe.matrixWorld)),te.matrix.decompose(te.position,te.quaternion,te.scale),te.updateMatrixWorld(!0),te.projectionMatrix.copy(fe.projectionMatrix),te.projectionMatrixInverse.copy(fe.projectionMatrixInverse),te.isPerspectiveCamera&&(te.fov=Io*2*Math.atan(1/te.projectionMatrix.elements[5]),te.zoom=1)}this.getCamera=function(){return M},this.getFoveation=function(){if(!(m===null&&g===null))return u},this.setFoveation=function(te){u=te,m!==null&&(m.fixedFoveation=te),g!==null&&g.fixedFoveation!==void 0&&(g.fixedFoveation=te)},this.hasDepthSensing=function(){return S.texture!==null};let ve=null;function ke(te,fe){if(d=fe.getViewerPose(h||a),y=fe,d!==null){const Ee=d.views;g!==null&&(e.setRenderTargetFramebuffer(R,g.framebuffer),e.setRenderTarget(R));let Me=!1;Ee.length!==M.cameras.length&&(M.cameras.length=0,Me=!0);for(let Ve=0;Ve<Ee.length;Ve++){const it=Ee[Ve];let q=null;if(g!==null)q=g.getViewport(it);else{const Fe=p.getViewSubImage(m,it);q=Fe.viewport,Ve===0&&(e.setRenderTargetTextures(R,Fe.colorTexture,m.ignoreDepthValues?void 0:Fe.depthStencilTexture),e.setRenderTarget(R))}let $e=E[Ve];$e===void 0&&($e=new Un,$e.layers.enable(Ve),$e.viewport=new Ut,E[Ve]=$e),$e.matrix.fromArray(it.transform.matrix),$e.matrix.decompose($e.position,$e.quaternion,$e.scale),$e.projectionMatrix.fromArray(it.projectionMatrix),$e.projectionMatrixInverse.copy($e.projectionMatrix).invert(),$e.viewport.set(q.x,q.y,q.width,q.height),Ve===0&&(M.matrix.copy($e.matrix),M.matrix.decompose(M.position,M.quaternion,M.scale)),Me===!0&&M.cameras.push($e)}const ze=r.enabledFeatures;if(ze&&ze.includes("depth-sensing")){const Ve=p.getDepthInformation(Ee[0]);Ve&&Ve.isValid&&Ve.texture&&S.init(e,Ve,r.renderState)}}for(let Ee=0;Ee<b.length;Ee++){const Me=A[Ee],ze=b[Ee];Me!==null&&ze!==void 0&&ze.update(Me,fe,h||a)}S.render(e,M),ve&&ve(te,fe),fe.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:fe}),y=null}const Ze=new x0;Ze.setAnimationLoop(ke),this.setAnimationLoop=function(te){ve=te},this.dispose=function(){}}}const vs=new Bi,RP=new Qe;function CP(i,e){function t(_,v){_.matrixAutoUpdate===!0&&_.updateMatrix(),v.value.copy(_.matrix)}function n(_,v){v.color.getRGB(_.fogColor.value,m0(i)),v.isFog?(_.fogNear.value=v.near,_.fogFar.value=v.far):v.isFogExp2&&(_.fogDensity.value=v.density)}function r(_,v,R,b,A){v.isMeshBasicMaterial||v.isMeshLambertMaterial?o(_,v):v.isMeshToonMaterial?(o(_,v),p(_,v)):v.isMeshPhongMaterial?(o(_,v),d(_,v)):v.isMeshStandardMaterial?(o(_,v),m(_,v),v.isMeshPhysicalMaterial&&g(_,v,A)):v.isMeshMatcapMaterial?(o(_,v),y(_,v)):v.isMeshDepthMaterial?o(_,v):v.isMeshDistanceMaterial?(o(_,v),S(_,v)):v.isMeshNormalMaterial?o(_,v):v.isLineBasicMaterial?(a(_,v),v.isLineDashedMaterial&&l(_,v)):v.isPointsMaterial?u(_,v,R,b):v.isSpriteMaterial?h(_,v):v.isShadowMaterial?(_.color.value.copy(v.color),_.opacity.value=v.opacity):v.isShaderMaterial&&(v.uniformsNeedUpdate=!1)}function o(_,v){_.opacity.value=v.opacity,v.color&&_.diffuse.value.copy(v.color),v.emissive&&_.emissive.value.copy(v.emissive).multiplyScalar(v.emissiveIntensity),v.map&&(_.map.value=v.map,t(v.map,_.mapTransform)),v.alphaMap&&(_.alphaMap.value=v.alphaMap,t(v.alphaMap,_.alphaMapTransform)),v.bumpMap&&(_.bumpMap.value=v.bumpMap,t(v.bumpMap,_.bumpMapTransform),_.bumpScale.value=v.bumpScale,v.side===Kn&&(_.bumpScale.value*=-1)),v.normalMap&&(_.normalMap.value=v.normalMap,t(v.normalMap,_.normalMapTransform),_.normalScale.value.copy(v.normalScale),v.side===Kn&&_.normalScale.value.negate()),v.displacementMap&&(_.displacementMap.value=v.displacementMap,t(v.displacementMap,_.displacementMapTransform),_.displacementScale.value=v.displacementScale,_.displacementBias.value=v.displacementBias),v.emissiveMap&&(_.emissiveMap.value=v.emissiveMap,t(v.emissiveMap,_.emissiveMapTransform)),v.specularMap&&(_.specularMap.value=v.specularMap,t(v.specularMap,_.specularMapTransform)),v.alphaTest>0&&(_.alphaTest.value=v.alphaTest);const R=e.get(v),b=R.envMap,A=R.envMapRotation;if(b&&(_.envMap.value=b,vs.copy(A),vs.x*=-1,vs.y*=-1,vs.z*=-1,b.isCubeTexture&&b.isRenderTargetTexture===!1&&(vs.y*=-1,vs.z*=-1),_.envMapRotation.value.setFromMatrix4(RP.makeRotationFromEuler(vs)),_.flipEnvMap.value=b.isCubeTexture&&b.isRenderTargetTexture===!1?-1:1,_.reflectivity.value=v.reflectivity,_.ior.value=v.ior,_.refractionRatio.value=v.refractionRatio),v.lightMap){_.lightMap.value=v.lightMap;const B=i._useLegacyLights===!0?Math.PI:1;_.lightMapIntensity.value=v.lightMapIntensity*B,t(v.lightMap,_.lightMapTransform)}v.aoMap&&(_.aoMap.value=v.aoMap,_.aoMapIntensity.value=v.aoMapIntensity,t(v.aoMap,_.aoMapTransform))}function a(_,v){_.diffuse.value.copy(v.color),_.opacity.value=v.opacity,v.map&&(_.map.value=v.map,t(v.map,_.mapTransform))}function l(_,v){_.dashSize.value=v.dashSize,_.totalSize.value=v.dashSize+v.gapSize,_.scale.value=v.scale}function u(_,v,R,b){_.diffuse.value.copy(v.color),_.opacity.value=v.opacity,_.size.value=v.size*R,_.scale.value=b*.5,v.map&&(_.map.value=v.map,t(v.map,_.uvTransform)),v.alphaMap&&(_.alphaMap.value=v.alphaMap,t(v.alphaMap,_.alphaMapTransform)),v.alphaTest>0&&(_.alphaTest.value=v.alphaTest)}function h(_,v){_.diffuse.value.copy(v.color),_.opacity.value=v.opacity,_.rotation.value=v.rotation,v.map&&(_.map.value=v.map,t(v.map,_.mapTransform)),v.alphaMap&&(_.alphaMap.value=v.alphaMap,t(v.alphaMap,_.alphaMapTransform)),v.alphaTest>0&&(_.alphaTest.value=v.alphaTest)}function d(_,v){_.specular.value.copy(v.specular),_.shininess.value=Math.max(v.shininess,1e-4)}function p(_,v){v.gradientMap&&(_.gradientMap.value=v.gradientMap)}function m(_,v){_.metalness.value=v.metalness,v.metalnessMap&&(_.metalnessMap.value=v.metalnessMap,t(v.metalnessMap,_.metalnessMapTransform)),_.roughness.value=v.roughness,v.roughnessMap&&(_.roughnessMap.value=v.roughnessMap,t(v.roughnessMap,_.roughnessMapTransform)),v.envMap&&(_.envMapIntensity.value=v.envMapIntensity)}function g(_,v,R){_.ior.value=v.ior,v.sheen>0&&(_.sheenColor.value.copy(v.sheenColor).multiplyScalar(v.sheen),_.sheenRoughness.value=v.sheenRoughness,v.sheenColorMap&&(_.sheenColorMap.value=v.sheenColorMap,t(v.sheenColorMap,_.sheenColorMapTransform)),v.sheenRoughnessMap&&(_.sheenRoughnessMap.value=v.sheenRoughnessMap,t(v.sheenRoughnessMap,_.sheenRoughnessMapTransform))),v.clearcoat>0&&(_.clearcoat.value=v.clearcoat,_.clearcoatRoughness.value=v.clearcoatRoughness,v.clearcoatMap&&(_.clearcoatMap.value=v.clearcoatMap,t(v.clearcoatMap,_.clearcoatMapTransform)),v.clearcoatRoughnessMap&&(_.clearcoatRoughnessMap.value=v.clearcoatRoughnessMap,t(v.clearcoatRoughnessMap,_.clearcoatRoughnessMapTransform)),v.clearcoatNormalMap&&(_.clearcoatNormalMap.value=v.clearcoatNormalMap,t(v.clearcoatNormalMap,_.clearcoatNormalMapTransform),_.clearcoatNormalScale.value.copy(v.clearcoatNormalScale),v.side===Kn&&_.clearcoatNormalScale.value.negate())),v.iridescence>0&&(_.iridescence.value=v.iridescence,_.iridescenceIOR.value=v.iridescenceIOR,_.iridescenceThicknessMinimum.value=v.iridescenceThicknessRange[0],_.iridescenceThicknessMaximum.value=v.iridescenceThicknessRange[1],v.iridescenceMap&&(_.iridescenceMap.value=v.iridescenceMap,t(v.iridescenceMap,_.iridescenceMapTransform)),v.iridescenceThicknessMap&&(_.iridescenceThicknessMap.value=v.iridescenceThicknessMap,t(v.iridescenceThicknessMap,_.iridescenceThicknessMapTransform))),v.transmission>0&&(_.transmission.value=v.transmission,_.transmissionSamplerMap.value=R.texture,_.transmissionSamplerSize.value.set(R.width,R.height),v.transmissionMap&&(_.transmissionMap.value=v.transmissionMap,t(v.transmissionMap,_.transmissionMapTransform)),_.thickness.value=v.thickness,v.thicknessMap&&(_.thicknessMap.value=v.thicknessMap,t(v.thicknessMap,_.thicknessMapTransform)),_.attenuationDistance.value=v.attenuationDistance,_.attenuationColor.value.copy(v.attenuationColor)),v.anisotropy>0&&(_.anisotropyVector.value.set(v.anisotropy*Math.cos(v.anisotropyRotation),v.anisotropy*Math.sin(v.anisotropyRotation)),v.anisotropyMap&&(_.anisotropyMap.value=v.anisotropyMap,t(v.anisotropyMap,_.anisotropyMapTransform))),_.specularIntensity.value=v.specularIntensity,_.specularColor.value.copy(v.specularColor),v.specularColorMap&&(_.specularColorMap.value=v.specularColorMap,t(v.specularColorMap,_.specularColorMapTransform)),v.specularIntensityMap&&(_.specularIntensityMap.value=v.specularIntensityMap,t(v.specularIntensityMap,_.specularIntensityMapTransform))}function y(_,v){v.matcap&&(_.matcap.value=v.matcap)}function S(_,v){const R=e.get(v).light;_.referencePosition.value.setFromMatrixPosition(R.matrixWorld),_.nearDistance.value=R.shadow.camera.near,_.farDistance.value=R.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:r}}function PP(i,e,t,n){let r={},o={},a=[];const l=i.getParameter(i.MAX_UNIFORM_BUFFER_BINDINGS);function u(R,b){const A=b.program;n.uniformBlockBinding(R,A)}function h(R,b){let A=r[R.id];A===void 0&&(y(R),A=d(R),r[R.id]=A,R.addEventListener("dispose",_));const B=b.program;n.updateUBOMapping(R,B);const N=e.render.frame;o[R.id]!==N&&(m(R),o[R.id]=N)}function d(R){const b=p();R.__bindingPointIndex=b;const A=i.createBuffer(),B=R.__size,N=R.usage;return i.bindBuffer(i.UNIFORM_BUFFER,A),i.bufferData(i.UNIFORM_BUFFER,B,N),i.bindBuffer(i.UNIFORM_BUFFER,null),i.bindBufferBase(i.UNIFORM_BUFFER,b,A),A}function p(){for(let R=0;R<l;R++)if(a.indexOf(R)===-1)return a.push(R),R;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function m(R){const b=r[R.id],A=R.uniforms,B=R.__cache;i.bindBuffer(i.UNIFORM_BUFFER,b);for(let N=0,D=A.length;N<D;N++){const C=Array.isArray(A[N])?A[N]:[A[N]];for(let E=0,M=C.length;E<M;E++){const O=C[E];if(g(O,N,E,B)===!0){const H=O.__offset,G=Array.isArray(O.value)?O.value:[O.value];let Y=0;for(let $=0;$<G.length;$++){const re=G[$],se=S(re);typeof re=="number"||typeof re=="boolean"?(O.__data[0]=re,i.bufferSubData(i.UNIFORM_BUFFER,H+Y,O.__data)):re.isMatrix3?(O.__data[0]=re.elements[0],O.__data[1]=re.elements[1],O.__data[2]=re.elements[2],O.__data[3]=0,O.__data[4]=re.elements[3],O.__data[5]=re.elements[4],O.__data[6]=re.elements[5],O.__data[7]=0,O.__data[8]=re.elements[6],O.__data[9]=re.elements[7],O.__data[10]=re.elements[8],O.__data[11]=0):(re.toArray(O.__data,Y),Y+=se.storage/Float32Array.BYTES_PER_ELEMENT)}i.bufferSubData(i.UNIFORM_BUFFER,H,O.__data)}}}i.bindBuffer(i.UNIFORM_BUFFER,null)}function g(R,b,A,B){const N=R.value,D=b+"_"+A;if(B[D]===void 0)return typeof N=="number"||typeof N=="boolean"?B[D]=N:B[D]=N.clone(),!0;{const C=B[D];if(typeof N=="number"||typeof N=="boolean"){if(C!==N)return B[D]=N,!0}else if(C.equals(N)===!1)return C.copy(N),!0}return!1}function y(R){const b=R.uniforms;let A=0;const B=16;for(let D=0,C=b.length;D<C;D++){const E=Array.isArray(b[D])?b[D]:[b[D]];for(let M=0,O=E.length;M<O;M++){const H=E[M],G=Array.isArray(H.value)?H.value:[H.value];for(let Y=0,$=G.length;Y<$;Y++){const re=G[Y],se=S(re),K=A%B;K!==0&&B-K<se.boundary&&(A+=B-K),H.__data=new Float32Array(se.storage/Float32Array.BYTES_PER_ELEMENT),H.__offset=A,A+=se.storage}}}const N=A%B;return N>0&&(A+=B-N),R.__size=A,R.__cache={},this}function S(R){const b={boundary:0,storage:0};return typeof R=="number"||typeof R=="boolean"?(b.boundary=4,b.storage=4):R.isVector2?(b.boundary=8,b.storage=8):R.isVector3||R.isColor?(b.boundary=16,b.storage=12):R.isVector4?(b.boundary=16,b.storage=16):R.isMatrix3?(b.boundary=48,b.storage=48):R.isMatrix4?(b.boundary=64,b.storage=64):R.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",R),b}function _(R){const b=R.target;b.removeEventListener("dispose",_);const A=a.indexOf(b.__bindingPointIndex);a.splice(A,1),i.deleteBuffer(r[b.id]),delete r[b.id],delete o[b.id]}function v(){for(const R in r)i.deleteBuffer(r[R]);a=[],r={},o={}}return{bind:u,update:h,dispose:v}}class w0{constructor(e={}){const{canvas:t=Tw(),context:n=null,depth:r=!0,stencil:o=!1,alpha:a=!1,antialias:l=!1,premultipliedAlpha:u=!0,preserveDrawingBuffer:h=!1,powerPreference:d="default",failIfMajorPerformanceCaveat:p=!1}=e;this.isWebGLRenderer=!0;let m;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");m=n.getContextAttributes().alpha}else m=a;const g=new Uint32Array(4),y=new Int32Array(4);let S=null,_=null;const v=[],R=[];this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this._outputColorSpace=on,this._useLegacyLights=!1,this.toneMapping=Ar,this.toneMappingExposure=1;const b=this;let A=!1,B=0,N=0,D=null,C=-1,E=null;const M=new Ut,O=new Ut;let H=null;const G=new Oe(0);let Y=0,$=t.width,re=t.height,se=1,K=null,ae=null;const pe=new Ut(0,0,$,re),ve=new Ut(0,0,$,re);let ke=!1;const Ze=new zf;let te=!1,fe=!1;const Ee=new Qe,Me=new Pe,ze=new F,Ve={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function it(){return D===null?se:1}let q=n;function $e(U,j){const ee=t.getContext(U,j);return ee!==null?ee:null}try{const U={alpha:!0,depth:r,stencil:o,antialias:l,premultipliedAlpha:u,preserveDrawingBuffer:h,powerPreference:d,failIfMajorPerformanceCaveat:p};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${Df}`),t.addEventListener("webglcontextlost",Z,!1),t.addEventListener("webglcontextrestored",ce,!1),t.addEventListener("webglcontextcreationerror",ye,!1),q===null){const j="webgl2";if(q=$e(j,U),q===null)throw $e(j)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(U){throw console.error("THREE.WebGLRenderer: "+U.message),U}let Fe,mt,We,At,z,P,ie,le,de,ge,He,_e,De,Xe,xe,we,Ke,Le,Ie,ct,ft,Et,_t,Tt;function Ne(){Fe=new zR(q),Fe.init(),mt=new DR(q,Fe,e),Et=new MP(q,Fe),We=new xP(q),At=new GR(q),z=new sP,P=new yP(q,Fe,We,z,mt,Et,At),ie=new NR(b),le=new BR(b),de=new qw(q),_t=new LR(q,de),ge=new kR(q,de,At,_t),He=new WR(q,ge,de,At),Ie=new VR(q,mt,P),we=new UR(z),_e=new rP(b,ie,le,Fe,mt,_t,we),De=new CP(b,z),Xe=new aP,xe=new dP(Fe),Le=new PR(b,ie,le,We,He,m,u),Ke=new vP(b,He,mt),Tt=new PP(q,At,mt,We),ct=new IR(q,Fe,At),ft=new HR(q,Fe,At),At.programs=_e.programs,b.capabilities=mt,b.extensions=Fe,b.properties=z,b.renderLists=Xe,b.shadowMap=Ke,b.state=We,b.info=At}Ne();const T=new AP(b,q);this.xr=T,this.getContext=function(){return q},this.getContextAttributes=function(){return q.getContextAttributes()},this.forceContextLoss=function(){const U=Fe.get("WEBGL_lose_context");U&&U.loseContext()},this.forceContextRestore=function(){const U=Fe.get("WEBGL_lose_context");U&&U.restoreContext()},this.getPixelRatio=function(){return se},this.setPixelRatio=function(U){U!==void 0&&(se=U,this.setSize($,re,!1))},this.getSize=function(U){return U.set($,re)},this.setSize=function(U,j,ee=!0){if(T.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}$=U,re=j,t.width=Math.floor(U*se),t.height=Math.floor(j*se),ee===!0&&(t.style.width=U+"px",t.style.height=j+"px"),this.setViewport(0,0,U,j)},this.getDrawingBufferSize=function(U){return U.set($*se,re*se).floor()},this.setDrawingBufferSize=function(U,j,ee){$=U,re=j,se=ee,t.width=Math.floor(U*ee),t.height=Math.floor(j*ee),this.setViewport(0,0,U,j)},this.getCurrentViewport=function(U){return U.copy(M)},this.getViewport=function(U){return U.copy(pe)},this.setViewport=function(U,j,ee,ne){U.isVector4?pe.set(U.x,U.y,U.z,U.w):pe.set(U,j,ee,ne),We.viewport(M.copy(pe).multiplyScalar(se).round())},this.getScissor=function(U){return U.copy(ve)},this.setScissor=function(U,j,ee,ne){U.isVector4?ve.set(U.x,U.y,U.z,U.w):ve.set(U,j,ee,ne),We.scissor(O.copy(ve).multiplyScalar(se).round())},this.getScissorTest=function(){return ke},this.setScissorTest=function(U){We.setScissorTest(ke=U)},this.setOpaqueSort=function(U){K=U},this.setTransparentSort=function(U){ae=U},this.getClearColor=function(U){return U.copy(Le.getClearColor())},this.setClearColor=function(){Le.setClearColor.apply(Le,arguments)},this.getClearAlpha=function(){return Le.getClearAlpha()},this.setClearAlpha=function(){Le.setClearAlpha.apply(Le,arguments)},this.clear=function(U=!0,j=!0,ee=!0){let ne=0;if(U){let J=!1;if(D!==null){const Ae=D.texture.format;J=Ae===r0||Ae===i0||Ae===n0}if(J){const Ae=D.texture.type,Be=Ae===Qr||Ae===Po||Ae===Z_||Ae===Ga||Ae===Q_||Ae===e0,Ge=Le.getClearColor(),Je=Le.getClearAlpha(),et=Ge.r,tt=Ge.g,rt=Ge.b;Be?(g[0]=et,g[1]=tt,g[2]=rt,g[3]=Je,q.clearBufferuiv(q.COLOR,0,g)):(y[0]=et,y[1]=tt,y[2]=rt,y[3]=Je,q.clearBufferiv(q.COLOR,0,y))}else ne|=q.COLOR_BUFFER_BIT}j&&(ne|=q.DEPTH_BUFFER_BIT),ee&&(ne|=q.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),q.clear(ne)},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",Z,!1),t.removeEventListener("webglcontextrestored",ce,!1),t.removeEventListener("webglcontextcreationerror",ye,!1),Xe.dispose(),xe.dispose(),z.dispose(),ie.dispose(),le.dispose(),He.dispose(),_t.dispose(),Tt.dispose(),_e.dispose(),T.dispose(),T.removeEventListener("sessionstart",Zt),T.removeEventListener("sessionend",Jt),Fn.stop()};function Z(U){U.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),A=!0}function ce(){console.log("THREE.WebGLRenderer: Context Restored."),A=!1;const U=At.autoReset,j=Ke.enabled,ee=Ke.autoUpdate,ne=Ke.needsUpdate,J=Ke.type;Ne(),At.autoReset=U,Ke.enabled=j,Ke.autoUpdate=ee,Ke.needsUpdate=ne,Ke.type=J}function ye(U){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",U.statusMessage)}function Re(U){const j=U.target;j.removeEventListener("dispose",Re),vt(j)}function vt(U){dt(U),z.remove(U)}function dt(U){const j=z.get(U).programs;j!==void 0&&(j.forEach(function(ee){_e.releaseProgram(ee)}),U.isShaderMaterial&&_e.releaseShaderCache(U))}this.renderBufferDirect=function(U,j,ee,ne,J,Ae){j===null&&(j=Ve);const Be=J.isMesh&&J.matrixWorld.determinant()<0,Ge=Xl(U,j,ee,ne,J);We.setMaterial(ne,Be);let Je=ee.index,et=1;if(ne.wireframe===!0){if(Je=ge.getWireframeAttribute(ee),Je===void 0)return;et=2}const tt=ee.drawRange,rt=ee.attributes.position;let qt=tt.start*et,wn=(tt.start+tt.count)*et;Ae!==null&&(qt=Math.max(qt,Ae.start*et),wn=Math.min(wn,(Ae.start+Ae.count)*et)),Je!==null?(qt=Math.max(qt,0),wn=Math.min(wn,Je.count)):rt!=null&&(qt=Math.max(qt,0),wn=Math.min(wn,rt.count));const nn=wn-qt;if(nn<0||nn===1/0)return;_t.setup(J,ne,Ge,ee,Je);let ui,Gt=ct;if(Je!==null&&(ui=de.get(Je),Gt=ft,Gt.setIndex(ui)),J.isMesh)ne.wireframe===!0?(We.setLineWidth(ne.wireframeLinewidth*it()),Gt.setMode(q.LINES)):Gt.setMode(q.TRIANGLES);else if(J.isLine){let ot=ne.linewidth;ot===void 0&&(ot=1),We.setLineWidth(ot*it()),J.isLineSegments?Gt.setMode(q.LINES):J.isLineLoop?Gt.setMode(q.LINE_LOOP):Gt.setMode(q.LINE_STRIP)}else J.isPoints?Gt.setMode(q.POINTS):J.isSprite&&Gt.setMode(q.TRIANGLES);if(J.isBatchedMesh)Gt.renderMultiDraw(J._multiDrawStarts,J._multiDrawCounts,J._multiDrawCount);else if(J.isInstancedMesh)Gt.renderInstances(qt,nn,J.count);else if(ee.isInstancedBufferGeometry){const ot=ee._maxInstanceCount!==void 0?ee._maxInstanceCount:1/0,Vo=Math.min(ee.instanceCount,ot);Gt.renderInstances(qt,nn,Vo)}else Gt.render(qt,nn)};function zt(U,j,ee){U.transparent===!0&&U.side===si&&U.forceSinglePass===!1?(U.side=Kn,U.needsUpdate=!0,Is(U,j,ee),U.side=tr,U.needsUpdate=!0,Is(U,j,ee),U.side=si):Is(U,j,ee)}this.compile=function(U,j,ee=null){ee===null&&(ee=U),_=xe.get(ee),_.init(),R.push(_),ee.traverseVisible(function(J){J.isLight&&J.layers.test(j.layers)&&(_.pushLight(J),J.castShadow&&_.pushShadow(J))}),U!==ee&&U.traverseVisible(function(J){J.isLight&&J.layers.test(j.layers)&&(_.pushLight(J),J.castShadow&&_.pushShadow(J))}),_.setupLights(b._useLegacyLights);const ne=new Set;return U.traverse(function(J){const Ae=J.material;if(Ae)if(Array.isArray(Ae))for(let Be=0;Be<Ae.length;Be++){const Ge=Ae[Be];zt(Ge,ee,J),ne.add(Ge)}else zt(Ae,ee,J),ne.add(Ae)}),R.pop(),_=null,ne},this.compileAsync=function(U,j,ee=null){const ne=this.compile(U,j,ee);return new Promise(J=>{function Ae(){if(ne.forEach(function(Be){z.get(Be).currentProgram.isReady()&&ne.delete(Be)}),ne.size===0){J(U);return}setTimeout(Ae,10)}Fe.get("KHR_parallel_shader_compile")!==null?Ae():setTimeout(Ae,10)})};let ln=null;function Rt(U){ln&&ln(U)}function Zt(){Fn.stop()}function Jt(){Fn.start()}const Fn=new x0;Fn.setAnimationLoop(Rt),typeof self<"u"&&Fn.setContext(self),this.setAnimationLoop=function(U){ln=U,T.setAnimationLoop(U),U===null?Fn.stop():Fn.start()},T.addEventListener("sessionstart",Zt),T.addEventListener("sessionend",Jt),this.render=function(U,j){if(j!==void 0&&j.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(A===!0)return;U.matrixWorldAutoUpdate===!0&&U.updateMatrixWorld(),j.parent===null&&j.matrixWorldAutoUpdate===!0&&j.updateMatrixWorld(),T.enabled===!0&&T.isPresenting===!0&&(T.cameraAutoUpdate===!0&&T.updateCamera(j),j=T.getCamera()),U.isScene===!0&&U.onBeforeRender(b,U,j,D),_=xe.get(U,R.length),_.init(),R.push(_),Ee.multiplyMatrices(j.projectionMatrix,j.matrixWorldInverse),Ze.setFromProjectionMatrix(Ee),fe=this.localClippingEnabled,te=we.init(this.clippingPlanes,fe),S=Xe.get(U,v.length),S.init(),v.push(S),bn(U,j,0,b.sortObjects),S.finish(),b.sortObjects===!0&&S.sort(K,ae),this.info.render.frame++,te===!0&&we.beginShadows();const ee=_.state.shadowsArray;if(Ke.render(ee,U,j),te===!0&&we.endShadows(),this.info.autoReset===!0&&this.info.reset(),(T.enabled===!1||T.isPresenting===!1||T.hasDepthSensing()===!1)&&Le.render(S,U),_.setupLights(b._useLegacyLights),j.isArrayCamera){const ne=j.cameras;for(let J=0,Ae=ne.length;J<Ae;J++){const Be=ne[J];ki(S,U,Be,Be.viewport)}}else ki(S,U,j);D!==null&&(P.updateMultisampleRenderTarget(D),P.updateRenderTargetMipmap(D)),U.isScene===!0&&U.onAfterRender(b,U,j),_t.resetDefaultState(),C=-1,E=null,R.pop(),R.length>0?_=R[R.length-1]:_=null,v.pop(),v.length>0?S=v[v.length-1]:S=null};function bn(U,j,ee,ne){if(U.visible===!1)return;if(U.layers.test(j.layers)){if(U.isGroup)ee=U.renderOrder;else if(U.isLOD)U.autoUpdate===!0&&U.update(j);else if(U.isLight)_.pushLight(U),U.castShadow&&_.pushShadow(U);else if(U.isSprite){if(!U.frustumCulled||Ze.intersectsSprite(U)){ne&&ze.setFromMatrixPosition(U.matrixWorld).applyMatrix4(Ee);const Be=He.update(U),Ge=U.material;Ge.visible&&S.push(U,Be,Ge,ee,ze.z,null)}}else if((U.isMesh||U.isLine||U.isPoints)&&(!U.frustumCulled||Ze.intersectsObject(U))){const Be=He.update(U),Ge=U.material;if(ne&&(U.boundingSphere!==void 0?(U.boundingSphere===null&&U.computeBoundingSphere(),ze.copy(U.boundingSphere.center)):(Be.boundingSphere===null&&Be.computeBoundingSphere(),ze.copy(Be.boundingSphere.center)),ze.applyMatrix4(U.matrixWorld).applyMatrix4(Ee)),Array.isArray(Ge)){const Je=Be.groups;for(let et=0,tt=Je.length;et<tt;et++){const rt=Je[et],qt=Ge[rt.materialIndex];qt&&qt.visible&&S.push(U,Be,qt,ee,ze.z,rt)}}else Ge.visible&&S.push(U,Be,Ge,ee,ze.z,null)}}const Ae=U.children;for(let Be=0,Ge=Ae.length;Be<Ge;Be++)bn(Ae[Be],j,ee,ne)}function ki(U,j,ee,ne){const J=U.opaque,Ae=U.transmissive,Be=U.transparent;_.setupLightsView(ee),te===!0&&we.setGlobalState(b.clippingPlanes,ee),Ae.length>0&&Hi(J,Ae,j,ee),ne&&We.viewport(M.copy(ne)),J.length>0&&ar(J,j,ee),Ae.length>0&&ar(Ae,j,ee),Be.length>0&&ar(Be,j,ee),We.buffers.depth.setTest(!0),We.buffers.depth.setMask(!0),We.buffers.color.setMask(!0),We.setPolygonOffset(!1)}function Hi(U,j,ee,ne){if((ee.isScene===!0?ee.overrideMaterial:null)!==null)return;if(_.state.transmissionRenderTarget===null){_.state.transmissionRenderTarget=new Rs(1,1,{generateMipmaps:!0,type:Fe.has("EXT_color_buffer_half_float")||Fe.has("EXT_color_buffer_float")?bl:Qr,minFilter:Ki,samples:4,stencilBuffer:o});const et=z.get(_.state.transmissionRenderTarget);et.__isTransmissionRenderTarget=!0}const Ae=_.state.transmissionRenderTarget;b.getDrawingBufferSize(Me),Ae.setSize(Me.x,Me.y);const Be=b.getRenderTarget();b.setRenderTarget(Ae),b.getClearColor(G),Y=b.getClearAlpha(),Y<1&&b.setClearColor(16777215,.5),b.clear();const Ge=b.toneMapping;b.toneMapping=Ar,ar(U,ee,ne),P.updateMultisampleRenderTarget(Ae),P.updateRenderTargetMipmap(Ae);let Je=!1;for(let et=0,tt=j.length;et<tt;et++){const rt=j[et],qt=rt.object,wn=rt.geometry,nn=rt.material,ui=rt.group;if(nn.side===si&&qt.layers.test(ne.layers)){const Gt=nn.side;nn.side=Kn,nn.needsUpdate=!0,Ya(qt,ee,ne,wn,nn,ui),nn.side=Gt,nn.needsUpdate=!0,Je=!0}}Je===!0&&(P.updateMultisampleRenderTarget(Ae),P.updateRenderTargetMipmap(Ae)),b.setRenderTarget(Be),b.setClearColor(G,Y),b.toneMapping=Ge}function ar(U,j,ee){const ne=j.isScene===!0?j.overrideMaterial:null;for(let J=0,Ae=U.length;J<Ae;J++){const Be=U[J],Ge=Be.object,Je=Be.geometry,et=ne===null?Be.material:ne,tt=Be.group;Ge.layers.test(ee.layers)&&Ya(Ge,j,ee,Je,et,tt)}}function Ya(U,j,ee,ne,J,Ae){U.onBeforeRender(b,j,ee,ne,J,Ae),U.modelViewMatrix.multiplyMatrices(ee.matrixWorldInverse,U.matrixWorld),U.normalMatrix.getNormalMatrix(U.modelViewMatrix),J.onBeforeRender(b,j,ee,ne,U,Ae),J.transparent===!0&&J.side===si&&J.forceSinglePass===!1?(J.side=Kn,J.needsUpdate=!0,b.renderBufferDirect(ee,j,ne,J,U,Ae),J.side=tr,J.needsUpdate=!0,b.renderBufferDirect(ee,j,ne,J,U,Ae),J.side=si):b.renderBufferDirect(ee,j,ne,J,U,Ae),U.onAfterRender(b,j,ee,ne,J,Ae)}function Is(U,j,ee){j.isScene!==!0&&(j=Ve);const ne=z.get(U),J=_.state.lights,Ae=_.state.shadowsArray,Be=J.state.version,Ge=_e.getParameters(U,J.state,Ae,j,ee),Je=_e.getProgramCacheKey(Ge);let et=ne.programs;ne.environment=U.isMeshStandardMaterial?j.environment:null,ne.fog=j.fog,ne.envMap=(U.isMeshStandardMaterial?le:ie).get(U.envMap||ne.environment),ne.envMapRotation=ne.environment!==null&&U.envMap===null?j.environmentRotation:U.envMapRotation,et===void 0&&(U.addEventListener("dispose",Re),et=new Map,ne.programs=et);let tt=et.get(Je);if(tt!==void 0){if(ne.currentProgram===tt&&ne.lightsStateVersion===Be)return qa(U,Ge),tt}else Ge.uniforms=_e.getUniforms(U),U.onBuild(ee,Ge,b),U.onBeforeCompile(Ge,b),tt=_e.acquireProgram(Ge,Je),et.set(Je,tt),ne.uniforms=Ge.uniforms;const rt=ne.uniforms;return(!U.isShaderMaterial&&!U.isRawShaderMaterial||U.clipping===!0)&&(rt.clippingPlanes=we.uniform),qa(U,Ge),ne.needsLights=jl(U),ne.lightsStateVersion=Be,ne.needsLights&&(rt.ambientLightColor.value=J.state.ambient,rt.lightProbe.value=J.state.probe,rt.directionalLights.value=J.state.directional,rt.directionalLightShadows.value=J.state.directionalShadow,rt.spotLights.value=J.state.spot,rt.spotLightShadows.value=J.state.spotShadow,rt.rectAreaLights.value=J.state.rectArea,rt.ltc_1.value=J.state.rectAreaLTC1,rt.ltc_2.value=J.state.rectAreaLTC2,rt.pointLights.value=J.state.point,rt.pointLightShadows.value=J.state.pointShadow,rt.hemisphereLights.value=J.state.hemi,rt.directionalShadowMap.value=J.state.directionalShadowMap,rt.directionalShadowMatrix.value=J.state.directionalShadowMatrix,rt.spotShadowMap.value=J.state.spotShadowMap,rt.spotLightMatrix.value=J.state.spotLightMatrix,rt.spotLightMap.value=J.state.spotLightMap,rt.pointShadowMap.value=J.state.pointShadowMap,rt.pointShadowMatrix.value=J.state.pointShadowMatrix),ne.currentProgram=tt,ne.uniformsList=null,tt}function ja(U){if(U.uniformsList===null){const j=U.currentProgram.getUniforms();U.uniformsList=xl.seqWithValue(j.seq,U.uniforms)}return U.uniformsList}function qa(U,j){const ee=z.get(U);ee.outputColorSpace=j.outputColorSpace,ee.batching=j.batching,ee.instancing=j.instancing,ee.instancingColor=j.instancingColor,ee.instancingMorph=j.instancingMorph,ee.skinning=j.skinning,ee.morphTargets=j.morphTargets,ee.morphNormals=j.morphNormals,ee.morphColors=j.morphColors,ee.morphTargetsCount=j.morphTargetsCount,ee.numClippingPlanes=j.numClippingPlanes,ee.numIntersection=j.numClipIntersection,ee.vertexAlphas=j.vertexAlphas,ee.vertexTangents=j.vertexTangents,ee.toneMapping=j.toneMapping}function Xl(U,j,ee,ne,J){j.isScene!==!0&&(j=Ve),P.resetTextureUnits();const Ae=j.fog,Be=ne.isMeshStandardMaterial?j.environment:null,Ge=D===null?b.outputColorSpace:D.isXRRenderTarget===!0?D.texture.colorSpace:Tn,Je=(ne.isMeshStandardMaterial?le:ie).get(ne.envMap||Be),et=ne.vertexColors===!0&&!!ee.attributes.color&&ee.attributes.color.itemSize===4,tt=!!ee.attributes.tangent&&(!!ne.normalMap||ne.anisotropy>0),rt=!!ee.morphAttributes.position,qt=!!ee.morphAttributes.normal,wn=!!ee.morphAttributes.color;let nn=Ar;ne.toneMapped&&(D===null||D.isXRRenderTarget===!0)&&(nn=b.toneMapping);const ui=ee.morphAttributes.position||ee.morphAttributes.normal||ee.morphAttributes.color,Gt=ui!==void 0?ui.length:0,ot=z.get(ne),Vo=_.state.lights;if(te===!0&&(fe===!0||U!==E)){const Bn=U===E&&ne.id===C;we.setState(ne,U,Bn)}let kt=!1;ne.version===ot.__version?(ot.needsLights&&ot.lightsStateVersion!==Vo.state.version||ot.outputColorSpace!==Ge||J.isBatchedMesh&&ot.batching===!1||!J.isBatchedMesh&&ot.batching===!0||J.isInstancedMesh&&ot.instancing===!1||!J.isInstancedMesh&&ot.instancing===!0||J.isSkinnedMesh&&ot.skinning===!1||!J.isSkinnedMesh&&ot.skinning===!0||J.isInstancedMesh&&ot.instancingColor===!0&&J.instanceColor===null||J.isInstancedMesh&&ot.instancingColor===!1&&J.instanceColor!==null||J.isInstancedMesh&&ot.instancingMorph===!0&&J.morphTexture===null||J.isInstancedMesh&&ot.instancingMorph===!1&&J.morphTexture!==null||ot.envMap!==Je||ne.fog===!0&&ot.fog!==Ae||ot.numClippingPlanes!==void 0&&(ot.numClippingPlanes!==we.numPlanes||ot.numIntersection!==we.numIntersection)||ot.vertexAlphas!==et||ot.vertexTangents!==tt||ot.morphTargets!==rt||ot.morphNormals!==qt||ot.morphColors!==wn||ot.toneMapping!==nn||ot.morphTargetsCount!==Gt)&&(kt=!0):(kt=!0,ot.__version=ne.version);let Gi=ot.currentProgram;kt===!0&&(Gi=Is(ne,j,J));let Wo=!1,Cr=!1,is=!1;const mn=Gi.getUniforms(),bi=ot.uniforms;if(We.useProgram(Gi.program)&&(Wo=!0,Cr=!0,is=!0),ne.id!==C&&(C=ne.id,Cr=!0),Wo||E!==U){mn.setValue(q,"projectionMatrix",U.projectionMatrix),mn.setValue(q,"viewMatrix",U.matrixWorldInverse);const Bn=mn.map.cameraPosition;Bn!==void 0&&Bn.setValue(q,ze.setFromMatrixPosition(U.matrixWorld)),mt.logarithmicDepthBuffer&&mn.setValue(q,"logDepthBufFC",2/(Math.log(U.far+1)/Math.LN2)),(ne.isMeshPhongMaterial||ne.isMeshToonMaterial||ne.isMeshLambertMaterial||ne.isMeshBasicMaterial||ne.isMeshStandardMaterial||ne.isShaderMaterial)&&mn.setValue(q,"isOrthographic",U.isOrthographicCamera===!0),E!==U&&(E=U,Cr=!0,is=!0)}if(J.isSkinnedMesh){mn.setOptional(q,J,"bindMatrix"),mn.setOptional(q,J,"bindMatrixInverse");const Bn=J.skeleton;Bn&&(Bn.boneTexture===null&&Bn.computeBoneTexture(),mn.setValue(q,"boneTexture",Bn.boneTexture,P))}J.isBatchedMesh&&(mn.setOptional(q,J,"batchingTexture"),mn.setValue(q,"batchingTexture",J._matricesTexture,P));const Pr=ee.morphAttributes;if((Pr.position!==void 0||Pr.normal!==void 0||Pr.color!==void 0)&&Ie.update(J,ee,Gi),(Cr||ot.receiveShadow!==J.receiveShadow)&&(ot.receiveShadow=J.receiveShadow,mn.setValue(q,"receiveShadow",J.receiveShadow)),ne.isMeshGouraudMaterial&&ne.envMap!==null&&(bi.envMap.value=Je,bi.flipEnvMap.value=Je.isCubeTexture&&Je.isRenderTargetTexture===!1?-1:1),ne.isMeshStandardMaterial&&ne.envMap===null&&j.environment!==null&&(bi.envMapIntensity.value=j.environmentIntensity),Cr&&(mn.setValue(q,"toneMappingExposure",b.toneMappingExposure),ot.needsLights&&Yl(bi,is),Ae&&ne.fog===!0&&De.refreshFogUniforms(bi,Ae),De.refreshMaterialUniforms(bi,ne,se,re,_.state.transmissionRenderTarget),xl.upload(q,ja(ot),bi,P)),ne.isShaderMaterial&&ne.uniformsNeedUpdate===!0&&(xl.upload(q,ja(ot),bi,P),ne.uniformsNeedUpdate=!1),ne.isSpriteMaterial&&mn.setValue(q,"center",J.center),mn.setValue(q,"modelViewMatrix",J.modelViewMatrix),mn.setValue(q,"normalMatrix",J.normalMatrix),mn.setValue(q,"modelMatrix",J.matrixWorld),ne.isShaderMaterial||ne.isRawShaderMaterial){const Bn=ne.uniformsGroups;for(let Xo=0,$a=Bn.length;Xo<$a;Xo++){const Yo=Bn[Xo];Tt.update(Yo,Gi),Tt.bind(Yo,Gi)}}return Gi}function Yl(U,j){U.ambientLightColor.needsUpdate=j,U.lightProbe.needsUpdate=j,U.directionalLights.needsUpdate=j,U.directionalLightShadows.needsUpdate=j,U.pointLights.needsUpdate=j,U.pointLightShadows.needsUpdate=j,U.spotLights.needsUpdate=j,U.spotLightShadows.needsUpdate=j,U.rectAreaLights.needsUpdate=j,U.hemisphereLights.needsUpdate=j}function jl(U){return U.isMeshLambertMaterial||U.isMeshToonMaterial||U.isMeshPhongMaterial||U.isMeshStandardMaterial||U.isShadowMaterial||U.isShaderMaterial&&U.lights===!0}this.getActiveCubeFace=function(){return B},this.getActiveMipmapLevel=function(){return N},this.getRenderTarget=function(){return D},this.setRenderTargetTextures=function(U,j,ee){z.get(U.texture).__webglTexture=j,z.get(U.depthTexture).__webglTexture=ee;const ne=z.get(U);ne.__hasExternalTextures=!0,ne.__autoAllocateDepthBuffer=ee===void 0,ne.__autoAllocateDepthBuffer||Fe.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),ne.__useRenderToTexture=!1)},this.setRenderTargetFramebuffer=function(U,j){const ee=z.get(U);ee.__webglFramebuffer=j,ee.__useDefaultFramebuffer=j===void 0},this.setRenderTarget=function(U,j=0,ee=0){D=U,B=j,N=ee;let ne=!0,J=null,Ae=!1,Be=!1;if(U){const Je=z.get(U);Je.__useDefaultFramebuffer!==void 0?(We.bindFramebuffer(q.FRAMEBUFFER,null),ne=!1):Je.__webglFramebuffer===void 0?P.setupRenderTarget(U):Je.__hasExternalTextures&&P.rebindTextures(U,z.get(U.texture).__webglTexture,z.get(U.depthTexture).__webglTexture);const et=U.texture;(et.isData3DTexture||et.isDataArrayTexture||et.isCompressedArrayTexture)&&(Be=!0);const tt=z.get(U).__webglFramebuffer;U.isWebGLCubeRenderTarget?(Array.isArray(tt[j])?J=tt[j][ee]:J=tt[j],Ae=!0):U.samples>0&&P.useMultisampledRTT(U)===!1?J=z.get(U).__webglMultisampledFramebuffer:Array.isArray(tt)?J=tt[ee]:J=tt,M.copy(U.viewport),O.copy(U.scissor),H=U.scissorTest}else M.copy(pe).multiplyScalar(se).floor(),O.copy(ve).multiplyScalar(se).floor(),H=ke;if(We.bindFramebuffer(q.FRAMEBUFFER,J)&&ne&&We.drawBuffers(U,J),We.viewport(M),We.scissor(O),We.setScissorTest(H),Ae){const Je=z.get(U.texture);q.framebufferTexture2D(q.FRAMEBUFFER,q.COLOR_ATTACHMENT0,q.TEXTURE_CUBE_MAP_POSITIVE_X+j,Je.__webglTexture,ee)}else if(Be){const Je=z.get(U.texture),et=j||0;q.framebufferTextureLayer(q.FRAMEBUFFER,q.COLOR_ATTACHMENT0,Je.__webglTexture,ee||0,et)}C=-1},this.readRenderTargetPixels=function(U,j,ee,ne,J,Ae,Be){if(!(U&&U.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Ge=z.get(U).__webglFramebuffer;if(U.isWebGLCubeRenderTarget&&Be!==void 0&&(Ge=Ge[Be]),Ge){We.bindFramebuffer(q.FRAMEBUFFER,Ge);try{const Je=U.texture,et=Je.format,tt=Je.type;if(et!==Ei&&Et.convert(et)!==q.getParameter(q.IMPLEMENTATION_COLOR_READ_FORMAT)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}const rt=tt===bl&&(Fe.has("EXT_color_buffer_half_float")||Fe.has("EXT_color_buffer_float"));if(tt!==Qr&&Et.convert(tt)!==q.getParameter(q.IMPLEMENTATION_COLOR_READ_TYPE)&&tt!==Zi&&!rt){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}j>=0&&j<=U.width-ne&&ee>=0&&ee<=U.height-J&&q.readPixels(j,ee,ne,J,Et.convert(et),Et.convert(tt),Ae)}finally{const Je=D!==null?z.get(D).__webglFramebuffer:null;We.bindFramebuffer(q.FRAMEBUFFER,Je)}}},this.copyFramebufferToTexture=function(U,j,ee=0){const ne=Math.pow(2,-ee),J=Math.floor(j.image.width*ne),Ae=Math.floor(j.image.height*ne);P.setTexture2D(j,0),q.copyTexSubImage2D(q.TEXTURE_2D,ee,0,0,U.x,U.y,J,Ae),We.unbindTexture()},this.copyTextureToTexture=function(U,j,ee,ne=0){const J=j.image.width,Ae=j.image.height,Be=Et.convert(ee.format),Ge=Et.convert(ee.type);P.setTexture2D(ee,0),q.pixelStorei(q.UNPACK_FLIP_Y_WEBGL,ee.flipY),q.pixelStorei(q.UNPACK_PREMULTIPLY_ALPHA_WEBGL,ee.premultiplyAlpha),q.pixelStorei(q.UNPACK_ALIGNMENT,ee.unpackAlignment),j.isDataTexture?q.texSubImage2D(q.TEXTURE_2D,ne,U.x,U.y,J,Ae,Be,Ge,j.image.data):j.isCompressedTexture?q.compressedTexSubImage2D(q.TEXTURE_2D,ne,U.x,U.y,j.mipmaps[0].width,j.mipmaps[0].height,Be,j.mipmaps[0].data):q.texSubImage2D(q.TEXTURE_2D,ne,U.x,U.y,Be,Ge,j.image),ne===0&&ee.generateMipmaps&&q.generateMipmap(q.TEXTURE_2D),We.unbindTexture()},this.copyTextureToTexture3D=function(U,j,ee,ne,J=0){const Ae=Math.round(U.max.x-U.min.x),Be=Math.round(U.max.y-U.min.y),Ge=U.max.z-U.min.z+1,Je=Et.convert(ne.format),et=Et.convert(ne.type);let tt;if(ne.isData3DTexture)P.setTexture3D(ne,0),tt=q.TEXTURE_3D;else if(ne.isDataArrayTexture||ne.isCompressedArrayTexture)P.setTexture2DArray(ne,0),tt=q.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}q.pixelStorei(q.UNPACK_FLIP_Y_WEBGL,ne.flipY),q.pixelStorei(q.UNPACK_PREMULTIPLY_ALPHA_WEBGL,ne.premultiplyAlpha),q.pixelStorei(q.UNPACK_ALIGNMENT,ne.unpackAlignment);const rt=q.getParameter(q.UNPACK_ROW_LENGTH),qt=q.getParameter(q.UNPACK_IMAGE_HEIGHT),wn=q.getParameter(q.UNPACK_SKIP_PIXELS),nn=q.getParameter(q.UNPACK_SKIP_ROWS),ui=q.getParameter(q.UNPACK_SKIP_IMAGES),Gt=ee.isCompressedTexture?ee.mipmaps[J]:ee.image;q.pixelStorei(q.UNPACK_ROW_LENGTH,Gt.width),q.pixelStorei(q.UNPACK_IMAGE_HEIGHT,Gt.height),q.pixelStorei(q.UNPACK_SKIP_PIXELS,U.min.x),q.pixelStorei(q.UNPACK_SKIP_ROWS,U.min.y),q.pixelStorei(q.UNPACK_SKIP_IMAGES,U.min.z),ee.isDataTexture||ee.isData3DTexture?q.texSubImage3D(tt,J,j.x,j.y,j.z,Ae,Be,Ge,Je,et,Gt.data):ne.isCompressedArrayTexture?q.compressedTexSubImage3D(tt,J,j.x,j.y,j.z,Ae,Be,Ge,Je,Gt.data):q.texSubImage3D(tt,J,j.x,j.y,j.z,Ae,Be,Ge,Je,et,Gt),q.pixelStorei(q.UNPACK_ROW_LENGTH,rt),q.pixelStorei(q.UNPACK_IMAGE_HEIGHT,qt),q.pixelStorei(q.UNPACK_SKIP_PIXELS,wn),q.pixelStorei(q.UNPACK_SKIP_ROWS,nn),q.pixelStorei(q.UNPACK_SKIP_IMAGES,ui),J===0&&ne.generateMipmaps&&q.generateMipmap(tt),We.unbindTexture()},this.initTexture=function(U){U.isCubeTexture?P.setTextureCube(U,0):U.isData3DTexture?P.setTexture3D(U,0):U.isDataArrayTexture||U.isCompressedArrayTexture?P.setTexture2DArray(U,0):P.setTexture2D(U,0),We.unbindTexture()},this.resetState=function(){B=0,N=0,D=null,We.reset(),_t.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return br}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=e===Nf?"display-p3":"srgb",t.unpackColorSpace=Lt.workingColorSpace===Bl?"display-p3":"srgb"}get useLegacyLights(){return console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights}set useLegacyLights(e){console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights=e}}class Pl extends gt{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new Bi,this.environmentIntensity=1,this.environmentRotation=new Bi,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}}class A0{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=lf,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.version=0,this.uuid=Fi()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}get updateRange(){return u0("THREE.InterleavedBuffer: updateRange() is deprecated and will be removed in r169. Use addUpdateRange() instead."),this._updateRange}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}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,n){e*=this.stride,n*=t.stride;for(let r=0,o=this.stride;r<o;r++)this.array[e+r]=t.array[n+r];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Fi()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(t,this.stride);return n.setUsage(this.usage),n}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Fi()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}const Gn=new F;class ka{constructor(e,t,n,r=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=n,this.normalized=r}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,n=this.data.count;t<n;t++)Gn.fromBufferAttribute(this,t),Gn.applyMatrix4(e),this.setXYZ(t,Gn.x,Gn.y,Gn.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)Gn.fromBufferAttribute(this,t),Gn.applyNormalMatrix(e),this.setXYZ(t,Gn.x,Gn.y,Gn.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)Gn.fromBufferAttribute(this,t),Gn.transformDirection(e),this.setXYZ(t,Gn.x,Gn.y,Gn.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(n=Ni(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=Dt(n,this.array)),this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){return this.normalized&&(t=Dt(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=Dt(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=Dt(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=Dt(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=Ni(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=Ni(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=Ni(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=Ni(t,this.array)),t}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=Dt(t,this.array),n=Dt(n,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=Dt(t,this.array),n=Dt(n,this.array),r=Dt(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=r,this}setXYZW(e,t,n,r,o){return e=e*this.data.stride+this.offset,this.normalized&&(t=Dt(t,this.array),n=Dt(n,this.array),r=Dt(r,this.array),o=Dt(o,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=r,this.data.array[e+3]=o,this}clone(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let n=0;n<this.count;n++){const r=n*this.data.stride+this.offset;for(let o=0;o<this.itemSize;o++)t.push(this.data.array[r+o])}return new Nt(new this.array.constructor(t),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new ka(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let n=0;n<this.count;n++){const r=n*this.data.stride+this.offset;for(let o=0;o<this.itemSize;o++)t.push(this.data.array[r+o])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}class R0 extends Ti{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new Oe(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!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.fog=e.fog,this}}let fo;const fa=new F,po=new F,mo=new F,go=new Pe,da=new Pe,C0=new Qe,nl=new F,pa=new F,il=new F,Vg=new Pe,Uh=new Pe,Wg=new Pe;class LP extends gt{constructor(e=new R0){if(super(),this.isSprite=!0,this.type="Sprite",fo===void 0){fo=new tn;const t=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),n=new A0(t,5);fo.setIndex([0,1,2,0,2,3]),fo.setAttribute("position",new ka(n,3,0,!1)),fo.setAttribute("uv",new ka(n,2,3,!1))}this.geometry=fo,this.material=e,this.center=new Pe(.5,.5)}raycast(e,t){e.camera===null&&console.error('THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),po.setFromMatrixScale(this.matrixWorld),C0.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),mo.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&po.multiplyScalar(-mo.z);const n=this.material.rotation;let r,o;n!==0&&(o=Math.cos(n),r=Math.sin(n));const a=this.center;rl(nl.set(-.5,-.5,0),mo,a,po,r,o),rl(pa.set(.5,-.5,0),mo,a,po,r,o),rl(il.set(.5,.5,0),mo,a,po,r,o),Vg.set(0,0),Uh.set(1,0),Wg.set(1,1);let l=e.ray.intersectTriangle(nl,pa,il,!1,fa);if(l===null&&(rl(pa.set(-.5,.5,0),mo,a,po,r,o),Uh.set(0,1),l=e.ray.intersectTriangle(nl,il,pa,!1,fa),l===null))return;const u=e.ray.origin.distanceTo(fa);u<e.near||u>e.far||t.push({distance:u,point:fa.clone(),uv:Oi.getInterpolation(fa,nl,pa,il,Vg,Uh,Wg,new Pe),face:null,object:this})}copy(e,t){return super.copy(e,t),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}}function rl(i,e,t,n,r,o){go.subVectors(i,t).addScalar(.5).multiply(n),r!==void 0?(da.x=o*go.x-r*go.y,da.y=r*go.x+o*go.y):da.copy(go),i.copy(e),i.x+=da.x,i.y+=da.y,i.applyMatrix4(C0)}const Xg=new F,Yg=new Ut,jg=new Ut,IP=new F,qg=new Qe,sl=new F,Nh=new rr,$g=new Qe,Oh=new Oo;class DP extends Se{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=Tm,this.bindMatrix=new Qe,this.bindMatrixInverse=new Qe,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const e=this.geometry;this.boundingBox===null&&(this.boundingBox=new zi),this.boundingBox.makeEmpty();const t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,sl),this.boundingBox.expandByPoint(sl)}computeBoundingSphere(){const e=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new rr),this.boundingSphere.makeEmpty();const t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,sl),this.boundingSphere.expandByPoint(sl)}copy(e,t){return super.copy(e,t),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}raycast(e,t){const n=this.material,r=this.matrixWorld;n!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),Nh.copy(this.boundingSphere),Nh.applyMatrix4(r),e.ray.intersectsSphere(Nh)!==!1&&($g.copy(r).invert(),Oh.copy(e.ray).applyMatrix4($g),!(this.boundingBox!==null&&Oh.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(e,t,Oh)))}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){this.skeleton=e,t===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){const e=new Ut,t=this.geometry.attributes.skinWeight;for(let n=0,r=t.count;n<r;n++){e.fromBufferAttribute(t,n);const o=1/e.manhattanLength();o!==1/0?e.multiplyScalar(o):e.set(1,0,0,0),t.setXYZW(n,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode===Tm?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===kb?this.bindMatrixInverse.copy(this.bindMatrix).invert():console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){const n=this.skeleton,r=this.geometry;Yg.fromBufferAttribute(r.attributes.skinIndex,e),jg.fromBufferAttribute(r.attributes.skinWeight,e),Xg.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let o=0;o<4;o++){const a=jg.getComponent(o);if(a!==0){const l=Yg.getComponent(o);qg.multiplyMatrices(n.bones[l].matrixWorld,n.boneInverses[l]),t.addScaledVector(IP.copy(Xg).applyMatrix4(qg),a)}}return t.applyMatrix4(this.bindMatrixInverse)}}class P0 extends gt{constructor(){super(),this.isBone=!0,this.type="Bone"}}class L0 extends cn{constructor(e=null,t=1,n=1,r,o,a,l,u,h=Nn,d=Nn,p,m){super(null,a,l,u,h,d,r,o,p,m),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const Kg=new Qe,UP=new Qe;class Hf{constructor(e=[],t=[]){this.uuid=Fi(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){const e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let n=0,r=this.bones.length;n<r;n++)this.boneInverses.push(new Qe)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){const n=new Qe;this.bones[e]&&n.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(n)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){const n=this.bones[e];n&&n.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){const n=this.bones[e];n&&(n.parent&&n.parent.isBone?(n.matrix.copy(n.parent.matrixWorld).invert(),n.matrix.multiply(n.matrixWorld)):n.matrix.copy(n.matrixWorld),n.matrix.decompose(n.position,n.quaternion,n.scale))}}update(){const e=this.bones,t=this.boneInverses,n=this.boneMatrices,r=this.boneTexture;for(let o=0,a=e.length;o<a;o++){const l=e[o]?e[o].matrixWorld:UP;Kg.multiplyMatrices(l,t[o]),Kg.toArray(n,o*16)}r!==null&&(r.needsUpdate=!0)}clone(){return new Hf(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);const t=new Float32Array(e*e*4);t.set(this.boneMatrices);const n=new L0(t,e,e,Ei,Zi);return n.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=n,this}getBoneByName(e){for(let t=0,n=this.bones.length;t<n;t++){const r=this.bones[t];if(r.name===e)return r}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let n=0,r=e.bones.length;n<r;n++){const o=e.bones[n];let a=t[o];a===void 0&&(console.warn("THREE.Skeleton: No bone found with UUID:",o),a=new P0),this.bones.push(a),this.boneInverses.push(new Qe().fromArray(e.boneInverses[n]))}return this.init(),this}toJSON(){const e={metadata:{version:4.6,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;const t=this.bones,n=this.boneInverses;for(let r=0,o=t.length;r<o;r++){const a=t[r];e.bones.push(a.uuid);const l=n[r];e.boneInverses.push(l.toArray())}return e}}class hf extends Nt{constructor(e,t,n,r=1){super(e,t,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=r}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}}const _o=new Qe,Zg=new Qe,ol=[],Jg=new zi,NP=new Qe,ma=new Se,ga=new rr;class OP extends Se{constructor(e,t,n){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new hf(new Float32Array(n*16),16),this.instanceColor=null,this.morphTexture=null,this.count=n,this.boundingBox=null,this.boundingSphere=null;for(let r=0;r<n;r++)this.setMatrixAt(r,NP)}computeBoundingBox(){const e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new zi),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,_o),Jg.copy(e.boundingBox).applyMatrix4(_o),this.boundingBox.union(Jg)}computeBoundingSphere(){const e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new rr),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,_o),ga.copy(e.boundingSphere).applyMatrix4(_o),this.boundingSphere.union(ga)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.morphTexture!==null&&(this.morphTexture=e.morphTexture.clone()),e.instanceColor!==null&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}getColorAt(e,t){t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){t.fromArray(this.instanceMatrix.array,e*16)}getMorphAt(e,t){const n=t.morphTargetInfluences,r=this.morphTexture.source.data.data,o=n.length+1,a=e*o+1;for(let l=0;l<n.length;l++)n[l]=r[a+l]}raycast(e,t){const n=this.matrixWorld,r=this.count;if(ma.geometry=this.geometry,ma.material=this.material,ma.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),ga.copy(this.boundingSphere),ga.applyMatrix4(n),e.ray.intersectsSphere(ga)!==!1))for(let o=0;o<r;o++){this.getMatrixAt(o,_o),Zg.multiplyMatrices(n,_o),ma.matrixWorld=Zg,ma.raycast(e,ol);for(let a=0,l=ol.length;a<l;a++){const u=ol[a];u.instanceId=o,u.object=this,t.push(u)}ol.length=0}}setColorAt(e,t){this.instanceColor===null&&(this.instanceColor=new hf(new Float32Array(this.instanceMatrix.count*3),3)),t.toArray(this.instanceColor.array,e*3)}setMatrixAt(e,t){t.toArray(this.instanceMatrix.array,e*16)}setMorphAt(e,t){const n=t.morphTargetInfluences,r=n.length+1;this.morphTexture===null&&(this.morphTexture=new L0(new Float32Array(r*this.count),r,this.count,t0,Zi));const o=this.morphTexture.source.data.data;let a=0;for(let h=0;h<n.length;h++)a+=n[h];const l=this.geometry.morphTargetsRelative?1:1-a,u=r*e;o[u]=l,o.set(n,u+1)}updateMorphTargets(){}dispose(){return this.dispatchEvent({type:"dispose"}),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null),this}}class Bo extends Ti{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Oe(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}const Qg=new F,e_=new F,t_=new Qe,Fh=new Oo,al=new rr;class Si extends gt{constructor(e=new tn,t=new Bo){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,n=[0];for(let r=1,o=t.count;r<o;r++)Qg.fromBufferAttribute(t,r-1),e_.fromBufferAttribute(t,r),n[r]=n[r-1],n[r]+=Qg.distanceTo(e_);e.setAttribute("lineDistance",new Bt(n,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){const n=this.geometry,r=this.matrixWorld,o=e.params.Line.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),al.copy(n.boundingSphere),al.applyMatrix4(r),al.radius+=o,e.ray.intersectsSphere(al)===!1)return;t_.copy(r).invert(),Fh.copy(e.ray).applyMatrix4(t_);const l=o/((this.scale.x+this.scale.y+this.scale.z)/3),u=l*l,h=new F,d=new F,p=new F,m=new F,g=this.isLineSegments?2:1,y=n.index,_=n.attributes.position;if(y!==null){const v=Math.max(0,a.start),R=Math.min(y.count,a.start+a.count);for(let b=v,A=R-1;b<A;b+=g){const B=y.getX(b),N=y.getX(b+1);if(h.fromBufferAttribute(_,B),d.fromBufferAttribute(_,N),Fh.distanceSqToSegment(h,d,m,p)>u)continue;m.applyMatrix4(this.matrixWorld);const C=e.ray.origin.distanceTo(m);C<e.near||C>e.far||t.push({distance:C,point:p.clone().applyMatrix4(this.matrixWorld),index:b,face:null,faceIndex:null,object:this})}}else{const v=Math.max(0,a.start),R=Math.min(_.count,a.start+a.count);for(let b=v,A=R-1;b<A;b+=g){if(h.fromBufferAttribute(_,b),d.fromBufferAttribute(_,b+1),Fh.distanceSqToSegment(h,d,m,p)>u)continue;m.applyMatrix4(this.matrixWorld);const N=e.ray.origin.distanceTo(m);N<e.near||N>e.far||t.push({distance:N,point:p.clone().applyMatrix4(this.matrixWorld),index:b,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const r=t[n[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let o=0,a=r.length;o<a;o++){const l=r[o].name||String(o);this.morphTargetInfluences.push(0),this.morphTargetDictionary[l]=o}}}}}const n_=new F,i_=new F;class Gf extends Si{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,n=[];for(let r=0,o=t.count;r<o;r+=2)n_.fromBufferAttribute(t,r),i_.fromBufferAttribute(t,r+1),n[r]=r===0?0:n[r-1],n[r+1]=n[r]+n_.distanceTo(i_);e.setAttribute("lineDistance",new Bt(n,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class FP extends Si{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}}class I0 extends Ti{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new Oe(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!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.fog=e.fog,this}}const r_=new Qe,ff=new Oo,cl=new rr,ll=new F;class BP extends gt{constructor(e=new tn,t=new I0){super(),this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}raycast(e,t){const n=this.geometry,r=this.matrixWorld,o=e.params.Points.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),cl.copy(n.boundingSphere),cl.applyMatrix4(r),cl.radius+=o,e.ray.intersectsSphere(cl)===!1)return;r_.copy(r).invert(),ff.copy(e.ray).applyMatrix4(r_);const l=o/((this.scale.x+this.scale.y+this.scale.z)/3),u=l*l,h=n.index,p=n.attributes.position;if(h!==null){const m=Math.max(0,a.start),g=Math.min(h.count,a.start+a.count);for(let y=m,S=g;y<S;y++){const _=h.getX(y);ll.fromBufferAttribute(p,_),s_(ll,_,u,r,e,t,this)}}else{const m=Math.max(0,a.start),g=Math.min(p.count,a.start+a.count);for(let y=m,S=g;y<S;y++)ll.fromBufferAttribute(p,y),s_(ll,y,u,r,e,t,this)}}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const r=t[n[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let o=0,a=r.length;o<a;o++){const l=r[o].name||String(o);this.morphTargetInfluences.push(0),this.morphTargetDictionary[l]=o}}}}}function s_(i,e,t,n,r,o,a){const l=ff.distanceSqToPoint(i);if(l<t){const u=new F;ff.closestPointToPoint(i,u),u.applyMatrix4(n);const h=r.ray.origin.distanceTo(u);if(h<r.near||h>r.far)return;o.push({distance:h,distanceToRay:Math.sqrt(l),point:u,index:e,face:null,object:a})}}class Bh extends cn{constructor(e,t,n,r,o,a,l,u,h,d,p,m){super(null,a,l,u,h,d,r,o,p,m),this.isCompressedTexture=!0,this.image={width:t,height:n},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}}class zP extends cn{constructor(e,t,n,r,o,a,l,u,h){super(e,t,n,r,o,a,l,u,h),this.isCanvasTexture=!0,this.needsUpdate=!0}}class vn extends tn{constructor(e=1,t=1,n=1,r=32,o=1,a=!1,l=0,u=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:n,radialSegments:r,heightSegments:o,openEnded:a,thetaStart:l,thetaLength:u};const h=this;r=Math.floor(r),o=Math.floor(o);const d=[],p=[],m=[],g=[];let y=0;const S=[],_=n/2;let v=0;R(),a===!1&&(e>0&&b(!0),t>0&&b(!1)),this.setIndex(d),this.setAttribute("position",new Bt(p,3)),this.setAttribute("normal",new Bt(m,3)),this.setAttribute("uv",new Bt(g,2));function R(){const A=new F,B=new F;let N=0;const D=(t-e)/n;for(let C=0;C<=o;C++){const E=[],M=C/o,O=M*(t-e)+e;for(let H=0;H<=r;H++){const G=H/r,Y=G*u+l,$=Math.sin(Y),re=Math.cos(Y);B.x=O*$,B.y=-M*n+_,B.z=O*re,p.push(B.x,B.y,B.z),A.set($,D,re).normalize(),m.push(A.x,A.y,A.z),g.push(G,1-M),E.push(y++)}S.push(E)}for(let C=0;C<r;C++)for(let E=0;E<o;E++){const M=S[E][C],O=S[E+1][C],H=S[E+1][C+1],G=S[E][C+1];d.push(M,O,G),d.push(O,H,G),N+=6}h.addGroup(v,N,0),v+=N}function b(A){const B=y,N=new Pe,D=new F;let C=0;const E=A===!0?e:t,M=A===!0?1:-1;for(let H=1;H<=r;H++)p.push(0,_*M,0),m.push(0,M,0),g.push(.5,.5),y++;const O=y;for(let H=0;H<=r;H++){const Y=H/r*u+l,$=Math.cos(Y),re=Math.sin(Y);D.x=E*re,D.y=_*M,D.z=E*$,p.push(D.x,D.y,D.z),m.push(0,M,0),N.x=$*.5+.5,N.y=re*.5*M+.5,g.push(N.x,N.y),y++}for(let H=0;H<r;H++){const G=B+H,Y=O+H;A===!0?d.push(Y,Y+1,G):d.push(Y+1,Y,G),C+=3}h.addGroup(v,C,A===!0?1:2),v+=C}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new vn(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class Vf extends vn{constructor(e=1,t=1,n=32,r=1,o=!1,a=0,l=Math.PI*2){super(0,e,t,n,r,o,a,l),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:n,heightSegments:r,openEnded:o,thetaStart:a,thetaLength:l}}static fromJSON(e){return new Vf(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class Wf extends tn{constructor(e=[],t=[],n=1,r=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:n,detail:r};const o=[],a=[];l(r),h(n),d(),this.setAttribute("position",new Bt(o,3)),this.setAttribute("normal",new Bt(o.slice(),3)),this.setAttribute("uv",new Bt(a,2)),r===0?this.computeVertexNormals():this.normalizeNormals();function l(R){const b=new F,A=new F,B=new F;for(let N=0;N<t.length;N+=3)g(t[N+0],b),g(t[N+1],A),g(t[N+2],B),u(b,A,B,R)}function u(R,b,A,B){const N=B+1,D=[];for(let C=0;C<=N;C++){D[C]=[];const E=R.clone().lerp(A,C/N),M=b.clone().lerp(A,C/N),O=N-C;for(let H=0;H<=O;H++)H===0&&C===N?D[C][H]=E:D[C][H]=E.clone().lerp(M,H/O)}for(let C=0;C<N;C++)for(let E=0;E<2*(N-C)-1;E++){const M=Math.floor(E/2);E%2===0?(m(D[C][M+1]),m(D[C+1][M]),m(D[C][M])):(m(D[C][M+1]),m(D[C+1][M+1]),m(D[C+1][M]))}}function h(R){const b=new F;for(let A=0;A<o.length;A+=3)b.x=o[A+0],b.y=o[A+1],b.z=o[A+2],b.normalize().multiplyScalar(R),o[A+0]=b.x,o[A+1]=b.y,o[A+2]=b.z}function d(){const R=new F;for(let b=0;b<o.length;b+=3){R.x=o[b+0],R.y=o[b+1],R.z=o[b+2];const A=_(R)/2/Math.PI+.5,B=v(R)/Math.PI+.5;a.push(A,1-B)}y(),p()}function p(){for(let R=0;R<a.length;R+=6){const b=a[R+0],A=a[R+2],B=a[R+4],N=Math.max(b,A,B),D=Math.min(b,A,B);N>.9&&D<.1&&(b<.2&&(a[R+0]+=1),A<.2&&(a[R+2]+=1),B<.2&&(a[R+4]+=1))}}function m(R){o.push(R.x,R.y,R.z)}function g(R,b){const A=R*3;b.x=e[A+0],b.y=e[A+1],b.z=e[A+2]}function y(){const R=new F,b=new F,A=new F,B=new F,N=new Pe,D=new Pe,C=new Pe;for(let E=0,M=0;E<o.length;E+=9,M+=6){R.set(o[E+0],o[E+1],o[E+2]),b.set(o[E+3],o[E+4],o[E+5]),A.set(o[E+6],o[E+7],o[E+8]),N.set(a[M+0],a[M+1]),D.set(a[M+2],a[M+3]),C.set(a[M+4],a[M+5]),B.copy(R).add(b).add(A).divideScalar(3);const O=_(B);S(N,M+0,R,O),S(D,M+2,b,O),S(C,M+4,A,O)}}function S(R,b,A,B){B<0&&R.x===1&&(a[b]=R.x-1),A.x===0&&A.z===0&&(a[b]=B/2/Math.PI+.5)}function _(R){return Math.atan2(R.z,-R.x)}function v(R){return Math.atan2(-R.y,Math.sqrt(R.x*R.x+R.z*R.z))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Wf(e.vertices,e.indices,e.radius,e.details)}}class So extends Wf{constructor(e=1,t=0){const n=[1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],r=[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2];super(n,r,e,t),this.type="OctahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new So(e.radius,e.detail)}}class Va extends tn{constructor(e=1,t=32,n=16,r=0,o=Math.PI*2,a=0,l=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:n,phiStart:r,phiLength:o,thetaStart:a,thetaLength:l},t=Math.max(3,Math.floor(t)),n=Math.max(2,Math.floor(n));const u=Math.min(a+l,Math.PI);let h=0;const d=[],p=new F,m=new F,g=[],y=[],S=[],_=[];for(let v=0;v<=n;v++){const R=[],b=v/n;let A=0;v===0&&a===0?A=.5/t:v===n&&u===Math.PI&&(A=-.5/t);for(let B=0;B<=t;B++){const N=B/t;p.x=-e*Math.cos(r+N*o)*Math.sin(a+b*l),p.y=e*Math.cos(a+b*l),p.z=e*Math.sin(r+N*o)*Math.sin(a+b*l),y.push(p.x,p.y,p.z),m.copy(p).normalize(),S.push(m.x,m.y,m.z),_.push(N+A,1-b),R.push(h++)}d.push(R)}for(let v=0;v<n;v++)for(let R=0;R<t;R++){const b=d[v][R+1],A=d[v][R],B=d[v+1][R],N=d[v+1][R+1];(v!==0||a>0)&&g.push(b,A,N),(v!==n-1||u<Math.PI)&&g.push(A,B,N)}this.setIndex(g),this.setAttribute("position",new Bt(y,3)),this.setAttribute("normal",new Bt(S,3)),this.setAttribute("uv",new Bt(_,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Va(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}class ws extends tn{constructor(e=1,t=.4,n=12,r=48,o=Math.PI*2){super(),this.type="TorusGeometry",this.parameters={radius:e,tube:t,radialSegments:n,tubularSegments:r,arc:o},n=Math.floor(n),r=Math.floor(r);const a=[],l=[],u=[],h=[],d=new F,p=new F,m=new F;for(let g=0;g<=n;g++)for(let y=0;y<=r;y++){const S=y/r*o,_=g/n*Math.PI*2;p.x=(e+t*Math.cos(_))*Math.cos(S),p.y=(e+t*Math.cos(_))*Math.sin(S),p.z=t*Math.sin(_),l.push(p.x,p.y,p.z),d.x=e*Math.cos(S),d.y=e*Math.sin(S),m.subVectors(p,d).normalize(),u.push(m.x,m.y,m.z),h.push(y/r),h.push(g/n)}for(let g=1;g<=n;g++)for(let y=1;y<=r;y++){const S=(r+1)*g+y-1,_=(r+1)*(g-1)+y-1,v=(r+1)*(g-1)+y,R=(r+1)*g+y;a.push(S,_,R),a.push(_,v,R)}this.setIndex(a),this.setAttribute("position",new Bt(l,3)),this.setAttribute("normal",new Bt(u,3)),this.setAttribute("uv",new Bt(h,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new ws(e.radius,e.tube,e.radialSegments,e.tubularSegments,e.arc)}}class kP extends Ti{constructor(e){super(),this.isShadowMaterial=!0,this.type="ShadowMaterial",this.color=new Oe(0),this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.fog=e.fog,this}}class zo extends Ti{constructor(e){super(),this.isMeshStandardMaterial=!0,this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new Oe(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 Oe(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=a0,this.normalScale=new Pe(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Bi,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,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.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class sr extends zo{constructor(e){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new Pe(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return En(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+.4*t)/(1-.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new Oe(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new Oe(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new Oe(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){this._anisotropy>0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=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.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,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.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,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}}class HP extends Bo{constructor(e){super(),this.isLineDashedMaterial=!0,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}}function ul(i,e,t){return!i||!t&&i.constructor===e?i:typeof e.BYTES_PER_ELEMENT=="number"?new e(i):Array.prototype.slice.call(i)}function GP(i){return ArrayBuffer.isView(i)&&!(i instanceof DataView)}function VP(i){function e(r,o){return i[r]-i[o]}const t=i.length,n=new Array(t);for(let r=0;r!==t;++r)n[r]=r;return n.sort(e),n}function o_(i,e,t){const n=i.length,r=new i.constructor(n);for(let o=0,a=0;a!==n;++o){const l=t[o]*e;for(let u=0;u!==e;++u)r[a++]=i[l+u]}return r}function D0(i,e,t,n){let r=1,o=i[0];for(;o!==void 0&&o[n]===void 0;)o=i[r++];if(o===void 0)return;let a=o[n];if(a!==void 0)if(Array.isArray(a))do a=o[n],a!==void 0&&(e.push(o.time),t.push.apply(t,a)),o=i[r++];while(o!==void 0);else if(a.toArray!==void 0)do a=o[n],a!==void 0&&(e.push(o.time),a.toArray(t,t.length)),o=i[r++];while(o!==void 0);else do a=o[n],a!==void 0&&(e.push(o.time),t.push(a)),o=i[r++];while(o!==void 0)}class Wa{constructor(e,t,n,r){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=r!==void 0?r:new t.constructor(n),this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){const t=this.parameterPositions;let n=this._cachedIndex,r=t[n],o=t[n-1];e:{t:{let a;n:{i:if(!(e<r)){for(let l=n+2;;){if(r===void 0){if(e<o)break i;return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===l)break;if(o=r,r=t[++n],e<r)break t}a=t.length;break n}if(!(e>=o)){const l=t[1];e<l&&(n=2,o=l);for(let u=n-2;;){if(o===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===u)break;if(r=o,o=t[--n-1],e>=o)break t}a=n,n=0;break n}break e}for(;n<a;){const l=n+a>>>1;e<t[l]?a=l:n=l+1}if(r=t[n],o=t[n-1],o===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(r===void 0)return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,o,r)}return this.interpolate_(n,o,e,r)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,r=this.valueSize,o=e*r;for(let a=0;a!==r;++a)t[a]=n[o+a];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}}class WP extends Wa{constructor(e,t,n,r){super(e,t,n,r),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:Km,endingEnd:Km}}intervalChanged_(e,t,n){const r=this.parameterPositions;let o=e-2,a=e+1,l=r[o],u=r[a];if(l===void 0)switch(this.getSettings_().endingStart){case Zm:o=e,l=2*t-n;break;case Jm:o=r.length-2,l=t+r[o]-r[o+1];break;default:o=e,l=n}if(u===void 0)switch(this.getSettings_().endingEnd){case Zm:a=e,u=2*n-t;break;case Jm:a=1,u=n+r[1]-r[0];break;default:a=e-1,u=t}const h=(n-t)*.5,d=this.valueSize;this._weightPrev=h/(t-l),this._weightNext=h/(u-n),this._offsetPrev=o*d,this._offsetNext=a*d}interpolate_(e,t,n,r){const o=this.resultBuffer,a=this.sampleValues,l=this.valueSize,u=e*l,h=u-l,d=this._offsetPrev,p=this._offsetNext,m=this._weightPrev,g=this._weightNext,y=(n-t)/(r-t),S=y*y,_=S*y,v=-m*_+2*m*S-m*y,R=(1+m)*_+(-1.5-2*m)*S+(-.5+m)*y+1,b=(-1-g)*_+(1.5+g)*S+.5*y,A=g*_-g*S;for(let B=0;B!==l;++B)o[B]=v*a[d+B]+R*a[h+B]+b*a[u+B]+A*a[p+B];return o}}class XP extends Wa{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e,t,n,r){const o=this.resultBuffer,a=this.sampleValues,l=this.valueSize,u=e*l,h=u-l,d=(n-t)/(r-t),p=1-d;for(let m=0;m!==l;++m)o[m]=a[h+m]*p+a[u+m]*d;return o}}class YP extends Wa{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e){return this.copySampleValue_(e-1)}}class or{constructor(e,t,n,r){if(e===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=ul(t,this.TimeBufferType),this.values=ul(n,this.ValueBufferType),this.setInterpolation(r||this.DefaultInterpolation)}static toJSON(e){const t=e.constructor;let n;if(t.toJSON!==this.toJSON)n=t.toJSON(e);else{n={name:e.name,times:ul(e.times,Array),values:ul(e.values,Array)};const r=e.getInterpolation();r!==e.DefaultInterpolation&&(n.interpolation=r)}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new YP(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new XP(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new WP(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case Lo:t=this.InterpolantFactoryMethodDiscrete;break;case As:t=this.InterpolantFactoryMethodLinear;break;case ch:t=this.InterpolantFactoryMethodSmooth;break}if(t===void 0){const n="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(n);return console.warn("THREE.KeyframeTrack:",n),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return Lo;case this.InterpolantFactoryMethodLinear:return As;case this.InterpolantFactoryMethodSmooth:return ch}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){const t=this.times;for(let n=0,r=t.length;n!==r;++n)t[n]+=e}return this}scale(e){if(e!==1){const t=this.times;for(let n=0,r=t.length;n!==r;++n)t[n]*=e}return this}trim(e,t){const n=this.times,r=n.length;let o=0,a=r-1;for(;o!==r&&n[o]<e;)++o;for(;a!==-1&&n[a]>t;)--a;if(++a,o!==0||a!==r){o>=a&&(a=Math.max(a,1),o=a-1);const l=this.getValueSize();this.times=n.slice(o,a),this.values=this.values.slice(o*l,a*l)}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 n=this.times,r=this.values,o=n.length;o===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let a=null;for(let l=0;l!==o;l++){const u=n[l];if(typeof u=="number"&&isNaN(u)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,l,u),e=!1;break}if(a!==null&&a>u){console.error("THREE.KeyframeTrack: Out of order keys.",this,l,u,a),e=!1;break}a=u}if(r!==void 0&&GP(r))for(let l=0,u=r.length;l!==u;++l){const h=r[l];if(isNaN(h)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,l,h),e=!1;break}}return e}optimize(){const e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),r=this.getInterpolation()===ch,o=e.length-1;let a=1;for(let l=1;l<o;++l){let u=!1;const h=e[l],d=e[l+1];if(h!==d&&(l!==1||h!==e[0]))if(r)u=!0;else{const p=l*n,m=p-n,g=p+n;for(let y=0;y!==n;++y){const S=t[p+y];if(S!==t[m+y]||S!==t[g+y]){u=!0;break}}}if(u){if(l!==a){e[a]=e[l];const p=l*n,m=a*n;for(let g=0;g!==n;++g)t[m+g]=t[p+g]}++a}}if(o>0){e[a]=e[o];for(let l=o*n,u=a*n,h=0;h!==n;++h)t[u+h]=t[l+h];++a}return a!==e.length?(this.times=e.slice(0,a),this.values=t.slice(0,a*n)):(this.times=e,this.values=t),this}clone(){const e=this.times.slice(),t=this.values.slice(),n=this.constructor,r=new n(this.name,e,t);return r.createInterpolant=this.createInterpolant,r}}or.prototype.TimeBufferType=Float32Array;or.prototype.ValueBufferType=Float32Array;or.prototype.DefaultInterpolation=As;class ko extends or{}ko.prototype.ValueTypeName="bool";ko.prototype.ValueBufferType=Array;ko.prototype.DefaultInterpolation=Lo;ko.prototype.InterpolantFactoryMethodLinear=void 0;ko.prototype.InterpolantFactoryMethodSmooth=void 0;class U0 extends or{}U0.prototype.ValueTypeName="color";class Uo extends or{}Uo.prototype.ValueTypeName="number";class jP extends Wa{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e,t,n,r){const o=this.resultBuffer,a=this.sampleValues,l=this.valueSize,u=(n-t)/(r-t);let h=e*l;for(let d=h+l;h!==d;h+=4)an.slerpFlat(o,0,a,h-l,a,h,u);return o}}class Cs extends or{InterpolantFactoryMethodLinear(e){return new jP(this.times,this.values,this.getValueSize(),e)}}Cs.prototype.ValueTypeName="quaternion";Cs.prototype.DefaultInterpolation=As;Cs.prototype.InterpolantFactoryMethodSmooth=void 0;class Ho extends or{}Ho.prototype.ValueTypeName="string";Ho.prototype.ValueBufferType=Array;Ho.prototype.DefaultInterpolation=Lo;Ho.prototype.InterpolantFactoryMethodLinear=void 0;Ho.prototype.InterpolantFactoryMethodSmooth=void 0;class No extends or{}No.prototype.ValueTypeName="vector";class qP{constructor(e="",t=-1,n=[],r=Kb){this.name=e,this.tracks=n,this.duration=t,this.blendMode=r,this.uuid=Fi(),this.duration<0&&this.resetDuration()}static parse(e){const t=[],n=e.tracks,r=1/(e.fps||1);for(let a=0,l=n.length;a!==l;++a)t.push(KP(n[a]).scale(r));const o=new this(e.name,e.duration,t,e.blendMode);return o.uuid=e.uuid,o}static toJSON(e){const t=[],n=e.tracks,r={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let o=0,a=n.length;o!==a;++o)t.push(or.toJSON(n[o]));return r}static CreateFromMorphTargetSequence(e,t,n,r){const o=t.length,a=[];for(let l=0;l<o;l++){let u=[],h=[];u.push((l+o-1)%o,l,(l+1)%o),h.push(0,1,0);const d=VP(u);u=o_(u,1,d),h=o_(h,1,d),!r&&u[0]===0&&(u.push(o),h.push(h[0])),a.push(new Uo(".morphTargetInfluences["+t[l].name+"]",u,h).scale(1/n))}return new this(e,-1,a)}static findByName(e,t){let n=e;if(!Array.isArray(e)){const r=e;n=r.geometry&&r.geometry.animations||r.animations}for(let r=0;r<n.length;r++)if(n[r].name===t)return n[r];return null}static CreateClipsFromMorphTargetSequences(e,t,n){const r={},o=/^([\w-]*?)([\d]+)$/;for(let l=0,u=e.length;l<u;l++){const h=e[l],d=h.name.match(o);if(d&&d.length>1){const p=d[1];let m=r[p];m||(r[p]=m=[]),m.push(h)}}const a=[];for(const l in r)a.push(this.CreateFromMorphTargetSequence(l,r[l],t,n));return a}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const n=function(p,m,g,y,S){if(g.length!==0){const _=[],v=[];D0(g,_,v,y),_.length!==0&&S.push(new p(m,_,v))}},r=[],o=e.name||"default",a=e.fps||30,l=e.blendMode;let u=e.length||-1;const h=e.hierarchy||[];for(let p=0;p<h.length;p++){const m=h[p].keys;if(!(!m||m.length===0))if(m[0].morphTargets){const g={};let y;for(y=0;y<m.length;y++)if(m[y].morphTargets)for(let S=0;S<m[y].morphTargets.length;S++)g[m[y].morphTargets[S]]=-1;for(const S in g){const _=[],v=[];for(let R=0;R!==m[y].morphTargets.length;++R){const b=m[y];_.push(b.time),v.push(b.morphTarget===S?1:0)}r.push(new Uo(".morphTargetInfluence["+S+"]",_,v))}u=g.length*a}else{const g=".bones["+t[p].name+"]";n(No,g+".position",m,"pos",r),n(Cs,g+".quaternion",m,"rot",r),n(No,g+".scale",m,"scl",r)}}return r.length===0?null:new this(o,u,r,l)}resetDuration(){const e=this.tracks;let t=0;for(let n=0,r=e.length;n!==r;++n){const o=this.tracks[n];t=Math.max(t,o.times[o.times.length-1])}return this.duration=t,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 $P(i){switch(i.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return Uo;case"vector":case"vector2":case"vector3":case"vector4":return No;case"color":return U0;case"quaternion":return Cs;case"bool":case"boolean":return ko;case"string":return Ho}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+i)}function KP(i){if(i.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const e=$P(i.type);if(i.times===void 0){const t=[],n=[];D0(i.keys,t,n,"value"),i.times=t,i.values=n}return e.parse!==void 0?e.parse(i):new e(i.name,i.times,i.values,i.interpolation)}const Zr={enabled:!1,files:{},add:function(i,e){this.enabled!==!1&&(this.files[i]=e)},get:function(i){if(this.enabled!==!1)return this.files[i]},remove:function(i){delete this.files[i]},clear:function(){this.files={}}};class ZP{constructor(e,t,n){const r=this;let o=!1,a=0,l=0,u;const h=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this.itemStart=function(d){l++,o===!1&&r.onStart!==void 0&&r.onStart(d,a,l),o=!0},this.itemEnd=function(d){a++,r.onProgress!==void 0&&r.onProgress(d,a,l),a===l&&(o=!1,r.onLoad!==void 0&&r.onLoad())},this.itemError=function(d){r.onError!==void 0&&r.onError(d)},this.resolveURL=function(d){return u?u(d):d},this.setURLModifier=function(d){return u=d,this},this.addHandler=function(d,p){return h.push(d,p),this},this.removeHandler=function(d){const p=h.indexOf(d);return p!==-1&&h.splice(p,2),this},this.getHandler=function(d){for(let p=0,m=h.length;p<m;p+=2){const g=h[p],y=h[p+1];if(g.global&&(g.lastIndex=0),g.test(d))return y}return null}}}const JP=new ZP;let Ls=class{constructor(e){this.manager=e!==void 0?e:JP,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){const n=this;return new Promise(function(r,o){n.load(e,r,t,o)})}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}};Ls.DEFAULT_MATERIAL_NAME="__DEFAULT";const Sr={};class QP extends Error{constructor(e,t){super(e),this.response=t}}class Ll extends Ls{constructor(e){super(e)}load(e,t,n,r){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const o=Zr.get(e);if(o!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(o),this.manager.itemEnd(e)},0),o;if(Sr[e]!==void 0){Sr[e].push({onLoad:t,onProgress:n,onError:r});return}Sr[e]=[],Sr[e].push({onLoad:t,onProgress:n,onError:r});const a=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),l=this.mimeType,u=this.responseType;fetch(a).then(h=>{if(h.status===200||h.status===0){if(h.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||h.body===void 0||h.body.getReader===void 0)return h;const d=Sr[e],p=h.body.getReader(),m=h.headers.get("Content-Length")||h.headers.get("X-File-Size"),g=m?parseInt(m):0,y=g!==0;let S=0;const _=new ReadableStream({start(v){R();function R(){p.read().then(({done:b,value:A})=>{if(b)v.close();else{S+=A.byteLength;const B=new ProgressEvent("progress",{lengthComputable:y,loaded:S,total:g});for(let N=0,D=d.length;N<D;N++){const C=d[N];C.onProgress&&C.onProgress(B)}v.enqueue(A),R()}})}}});return new Response(_)}else throw new QP(`fetch for "${h.url}" responded with ${h.status}: ${h.statusText}`,h)}).then(h=>{switch(u){case"arraybuffer":return h.arrayBuffer();case"blob":return h.blob();case"document":return h.text().then(d=>new DOMParser().parseFromString(d,l));case"json":return h.json();default:if(l===void 0)return h.text();{const p=/charset="?([^;"\s]*)"?/i.exec(l),m=p&&p[1]?p[1].toLowerCase():void 0,g=new TextDecoder(m);return h.arrayBuffer().then(y=>g.decode(y))}}}).then(h=>{Zr.add(e,h);const d=Sr[e];delete Sr[e];for(let p=0,m=d.length;p<m;p++){const g=d[p];g.onLoad&&g.onLoad(h)}}).catch(h=>{const d=Sr[e];if(d===void 0)throw this.manager.itemError(e),h;delete Sr[e];for(let p=0,m=d.length;p<m;p++){const g=d[p];g.onError&&g.onError(h)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}}class eL extends Ls{constructor(e){super(e)}load(e,t,n,r){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const o=this,a=Zr.get(e);if(a!==void 0)return o.manager.itemStart(e),setTimeout(function(){t&&t(a),o.manager.itemEnd(e)},0),a;const l=za("img");function u(){d(),Zr.add(e,this),t&&t(this),o.manager.itemEnd(e)}function h(p){d(),r&&r(p),o.manager.itemError(e),o.manager.itemEnd(e)}function d(){l.removeEventListener("load",u,!1),l.removeEventListener("error",h,!1)}return l.addEventListener("load",u,!1),l.addEventListener("error",h,!1),e.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(l.crossOrigin=this.crossOrigin),o.manager.itemStart(e),l.src=e,l}}class N0 extends Ls{constructor(e){super(e)}load(e,t,n,r){const o=new cn,a=new eL(this.manager);return a.setCrossOrigin(this.crossOrigin),a.setPath(this.path),a.load(e,function(l){o.image=l,o.needsUpdate=!0,t!==void 0&&t(o)},n,r),o}}class Go extends gt{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new Oe(e),this.intensity=t}dispose(){}copy(e,t){return super.copy(e,t),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,this.groundColor!==void 0&&(t.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(t.object.distance=this.distance),this.angle!==void 0&&(t.object.angle=this.angle),this.decay!==void 0&&(t.object.decay=this.decay),this.penumbra!==void 0&&(t.object.penumbra=this.penumbra),this.shadow!==void 0&&(t.object.shadow=this.shadow.toJSON()),t}}class tL extends Go{constructor(e,t,n){super(e,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(gt.DEFAULT_UP),this.updateMatrix(),this.groundColor=new Oe(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}}const zh=new Qe,a_=new F,c_=new F;class Xf{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Pe(512,512),this.map=null,this.mapPass=null,this.matrix=new Qe,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new zf,this._frameExtents=new Pe(1,1),this._viewportCount=1,this._viewports=[new Ut(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,n=this.matrix;a_.setFromMatrixPosition(e.matrixWorld),t.position.copy(a_),c_.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(c_),t.updateMatrixWorld(),zh.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(zh),n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(zh)}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 this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}class nL extends Xf{constructor(){super(new Un(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){const t=this.camera,n=Io*2*e.angle*this.focus,r=this.mapSize.width/this.mapSize.height,o=e.distance||t.far;(n!==t.fov||r!==t.aspect||o!==t.far)&&(t.fov=n,t.aspect=r,t.far=o,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}class iL extends Go{constructor(e,t,n=0,r=Math.PI/3,o=0,a=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(gt.DEFAULT_UP),this.updateMatrix(),this.target=new gt,this.distance=n,this.angle=r,this.penumbra=o,this.decay=a,this.map=null,this.shadow=new nL}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),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}}const l_=new Qe,_a=new F,kh=new F;class rL extends Xf{constructor(){super(new Un(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new Pe(4,2),this._viewportCount=6,this._viewports=[new Ut(2,1,1,1),new Ut(0,1,1,1),new Ut(3,1,1,1),new Ut(1,1,1,1),new Ut(3,0,1,1),new Ut(1,0,1,1)],this._cubeDirections=[new F(1,0,0),new F(-1,0,0),new F(0,0,1),new F(0,0,-1),new F(0,1,0),new F(0,-1,0)],this._cubeUps=[new F(0,1,0),new F(0,1,0),new F(0,1,0),new F(0,1,0),new F(0,0,1),new F(0,0,-1)]}updateMatrices(e,t=0){const n=this.camera,r=this.matrix,o=e.distance||n.far;o!==n.far&&(n.far=o,n.updateProjectionMatrix()),_a.setFromMatrixPosition(e.matrixWorld),n.position.copy(_a),kh.copy(n.position),kh.add(this._cubeDirections[t]),n.up.copy(this._cubeUps[t]),n.lookAt(kh),n.updateMatrixWorld(),r.makeTranslation(-_a.x,-_a.y,-_a.z),l_.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(l_)}}class O0 extends Go{constructor(e,t,n=0,r=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=r,this.shadow=new rL}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}}class sL extends Xf{constructor(){super(new zl(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class Yf extends Go{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(gt.DEFAULT_UP),this.updateMatrix(),this.target=new gt,this.shadow=new sL}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}class oL extends Go{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}}class aL{constructor(){this.isSphericalHarmonics3=!0,this.coefficients=[];for(let e=0;e<9;e++)this.coefficients.push(new F)}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 n=e.x,r=e.y,o=e.z,a=this.coefficients;return t.copy(a[0]).multiplyScalar(.282095),t.addScaledVector(a[1],.488603*r),t.addScaledVector(a[2],.488603*o),t.addScaledVector(a[3],.488603*n),t.addScaledVector(a[4],1.092548*(n*r)),t.addScaledVector(a[5],1.092548*(r*o)),t.addScaledVector(a[6],.315392*(3*o*o-1)),t.addScaledVector(a[7],1.092548*(n*o)),t.addScaledVector(a[8],.546274*(n*n-r*r)),t}getIrradianceAt(e,t){const n=e.x,r=e.y,o=e.z,a=this.coefficients;return t.copy(a[0]).multiplyScalar(.886227),t.addScaledVector(a[1],2*.511664*r),t.addScaledVector(a[2],2*.511664*o),t.addScaledVector(a[3],2*.511664*n),t.addScaledVector(a[4],2*.429043*n*r),t.addScaledVector(a[5],2*.429043*r*o),t.addScaledVector(a[6],.743125*o*o-.247708),t.addScaledVector(a[7],2*.429043*n*o),t.addScaledVector(a[8],.429043*(n*n-r*r)),t}add(e){for(let t=0;t<9;t++)this.coefficients[t].add(e.coefficients[t]);return this}addScaledSH(e,t){for(let n=0;n<9;n++)this.coefficients[n].addScaledVector(e.coefficients[n],t);return this}scale(e){for(let t=0;t<9;t++)this.coefficients[t].multiplyScalar(e);return this}lerp(e,t){for(let n=0;n<9;n++)this.coefficients[n].lerp(e.coefficients[n],t);return this}equals(e){for(let t=0;t<9;t++)if(!this.coefficients[t].equals(e.coefficients[t]))return!1;return!0}copy(e){return this.set(e.coefficients)}clone(){return new this.constructor().copy(this)}fromArray(e,t=0){const n=this.coefficients;for(let r=0;r<9;r++)n[r].fromArray(e,t+r*3);return this}toArray(e=[],t=0){const n=this.coefficients;for(let r=0;r<9;r++)n[r].toArray(e,t+r*3);return e}static getBasisAt(e,t){const n=e.x,r=e.y,o=e.z;t[0]=.282095,t[1]=.488603*r,t[2]=.488603*o,t[3]=.488603*n,t[4]=1.092548*n*r,t[5]=1.092548*r*o,t[6]=.315392*(3*o*o-1),t[7]=1.092548*n*o,t[8]=.546274*(n*n-r*r)}}class cL extends Go{constructor(e=new aL,t=1){super(void 0,t),this.isLightProbe=!0,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}}class Oa{static decodeText(e){if(typeof TextDecoder<"u")return new TextDecoder().decode(e);let t="";for(let n=0,r=e.length;n<r;n++)t+=String.fromCharCode(e[n]);try{return decodeURIComponent(escape(t))}catch{return t}}static extractUrlBase(e){const t=e.lastIndexOf("/");return t===-1?"./":e.slice(0,t+1)}static resolveURL(e,t){return typeof e!="string"||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)}}class lL extends Ls{constructor(e){super(e),this.isImageBitmapLoader=!0,typeof createImageBitmap>"u"&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(e){return this.options=e,this}load(e,t,n,r){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const o=this,a=Zr.get(e);if(a!==void 0){if(o.manager.itemStart(e),a.then){a.then(h=>{t&&t(h),o.manager.itemEnd(e)}).catch(h=>{r&&r(h)});return}return setTimeout(function(){t&&t(a),o.manager.itemEnd(e)},0),a}const l={};l.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",l.headers=this.requestHeader;const u=fetch(e,l).then(function(h){return h.blob()}).then(function(h){return createImageBitmap(h,Object.assign(o.options,{colorSpaceConversion:"none"}))}).then(function(h){return Zr.add(e,h),t&&t(h),o.manager.itemEnd(e),h}).catch(function(h){r&&r(h),Zr.remove(e),o.manager.itemError(e),o.manager.itemEnd(e)});Zr.add(e,u),o.manager.itemStart(e)}}const jf="\\[\\]\\.:\\/",uL=new RegExp("["+jf+"]","g"),qf="[^"+jf+"]",hL="[^"+jf.replace("\\.","")+"]",fL=/((?:WC+[\/:])*)/.source.replace("WC",qf),dL=/(WCOD+)?/.source.replace("WCOD",hL),pL=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",qf),mL=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",qf),gL=new RegExp("^"+fL+dL+pL+mL+"$"),_L=["material","materials","bones","map"];class vL{constructor(e,t,n){const r=n||wt.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,r)}getValue(e,t){this.bind();const n=this._targetGroup.nCachedObjects_,r=this._bindings[n];r!==void 0&&r.getValue(e,t)}setValue(e,t){const n=this._bindings;for(let r=this._targetGroup.nCachedObjects_,o=n.length;r!==o;++r)n[r].setValue(e,t)}bind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}}class wt{constructor(e,t,n){this.path=t,this.parsedPath=n||wt.parseTrackName(t),this.node=wt.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){return e&&e.isAnimationObjectGroup?new wt.Composite(e,t,n):new wt(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(uL,"")}static parseTrackName(e){const t=gL.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},r=n.nodeName&&n.nodeName.lastIndexOf(".");if(r!==void 0&&r!==-1){const o=n.nodeName.substring(r+1);_L.indexOf(o)!==-1&&(n.nodeName=n.nodeName.substring(0,r),n.objectName=o)}if(n.propertyName===null||n.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return n}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){const n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){const n=function(o){for(let a=0;a<o.length;a++){const l=o[a];if(l.name===t||l.uuid===t)return l;const u=n(l.children);if(u)return u}return null},r=n(e.children);if(r)return r}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){const n=this.resolvedProperty;for(let r=0,o=n.length;r!==o;++r)e[t++]=n[r]}_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 n=this.resolvedProperty;for(let r=0,o=n.length;r!==o;++r)n[r]=e[t++]}_setValue_array_setNeedsUpdate(e,t){const n=this.resolvedProperty;for(let r=0,o=n.length;r!==o;++r)n[r]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){const n=this.resolvedProperty;for(let r=0,o=n.length;r!==o;++r)n[r]=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,n=t.objectName,r=t.propertyName;let o=t.propertyIndex;if(e||(e=wt.findNode(this.rootNode,t.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){console.warn("THREE.PropertyBinding: No target node found for track: "+this.path+".");return}if(n){let h=t.objectIndex;switch(n){case"materials":if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let d=0;d<e.length;d++)if(e[d].name===h){h=d;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}e=e.material.map;break;default:if(e[n]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[n]}if(h!==void 0){if(e[h]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[h]}}const a=e[r];if(a===void 0){const h=t.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+h+"."+r+" but it wasn't found.",e);return}let l=this.Versioning.None;this.targetObject=e,e.needsUpdate!==void 0?l=this.Versioning.NeedsUpdate:e.matrixWorldNeedsUpdate!==void 0&&(l=this.Versioning.MatrixWorldNeedsUpdate);let u=this.BindingType.Direct;if(o!==void 0){if(r==="morphTargetInfluences"){if(!e.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[o]!==void 0&&(o=e.morphTargetDictionary[o])}u=this.BindingType.ArrayElement,this.resolvedProperty=a,this.propertyIndex=o}else a.fromArray!==void 0&&a.toArray!==void 0?(u=this.BindingType.HasFromToArray,this.resolvedProperty=a):Array.isArray(a)?(u=this.BindingType.EntireArray,this.resolvedProperty=a):this.propertyName=r;this.getValue=this.GetterByBindingType[u],this.setValue=this.SetterByBindingTypeAndVersioning[u][l]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}wt.Composite=vL;wt.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};wt.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};wt.prototype.GetterByBindingType=[wt.prototype._getValue_direct,wt.prototype._getValue_array,wt.prototype._getValue_arrayElement,wt.prototype._getValue_toArray];wt.prototype.SetterByBindingTypeAndVersioning=[[wt.prototype._setValue_direct,wt.prototype._setValue_direct_setNeedsUpdate,wt.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[wt.prototype._setValue_array,wt.prototype._setValue_array_setNeedsUpdate,wt.prototype._setValue_array_setMatrixWorldNeedsUpdate],[wt.prototype._setValue_arrayElement,wt.prototype._setValue_arrayElement_setNeedsUpdate,wt.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[wt.prototype._setValue_fromArray,wt.prototype._setValue_fromArray_setNeedsUpdate,wt.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class $f{constructor(e){this.value=e}clone(){return new $f(this.value.clone===void 0?this.value:this.value.clone())}}const u_=new Qe;class Hl{constructor(e,t,n=0,r=1/0){this.ray=new Oo(e,t),this.near=n,this.far=r,this.camera=null,this.layers=new Bf,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,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.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)}setFromXRController(e){return u_.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(u_),this}intersectObject(e,t=!0,n=[]){return df(e,this,n,t),n.sort(h_),n}intersectObjects(e,t=!0,n=[]){for(let r=0,o=e.length;r<o;r++)df(e[r],this,n,t);return n.sort(h_),n}}function h_(i,e){return i.distance-e.distance}function df(i,e,t,n){if(i.layers.test(e.layers)&&i.raycast(e,t),n===!0){const r=i.children;for(let o=0,a=r.length;o<a;o++)df(r[o],e,t,!0)}}class f_{constructor(e=1,t=0,n=0){return this.radius=e,this.phi=t,this.theta=n,this}set(e,t,n){return this.radius=e,this.phi=t,this.theta=n,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=Math.max(1e-6,Math.min(Math.PI-1e-6,this.phi)),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,n){return this.radius=Math.sqrt(e*e+t*t+n*n),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,n),this.phi=Math.acos(En(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}class xL extends Gf{constructor(e=10,t=10,n=4473924,r=8947848){n=new Oe(n),r=new Oe(r);const o=t/2,a=e/t,l=e/2,u=[],h=[];for(let m=0,g=0,y=-l;m<=t;m++,y+=a){u.push(-l,0,y,l,0,y),u.push(y,0,-l,y,0,l);const S=m===o?n:r;S.toArray(h,g),g+=3,S.toArray(h,g),g+=3,S.toArray(h,g),g+=3,S.toArray(h,g),g+=3}const d=new tn;d.setAttribute("position",new Bt(u,3)),d.setAttribute("color",new Bt(h,3));const p=new Bo({vertexColors:!0,toneMapped:!1});super(d,p),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}class yL extends Gf{constructor(e=1){const t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],n=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],r=new tn;r.setAttribute("position",new Bt(t,3)),r.setAttribute("color",new Bt(n,3));const o=new Bo({vertexColors:!0,toneMapped:!1});super(r,o),this.type="AxesHelper"}setColors(e,t,n){const r=new Oe,o=this.geometry.attributes.color.array;return r.set(e),r.toArray(o,0),r.toArray(o,3),r.set(t),r.toArray(o,6),r.toArray(o,9),r.set(n),r.toArray(o,12),r.toArray(o,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:Df}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Df);const Ss={antialias:!0,alpha:!0,stencil:!1,shadowMapEnabled:!0,shadowMapType:q_,toneMapping:Ar,canvas:void 0};class d_ extends w0{paused=!1;running=!1;force=!1;preRenderCallbacks=new Map;postRenderCallbacks=new Map;constructor(e=Ss){super({antialias:e.antialias||Ss.antialias,alpha:e.alpha||Ss.alpha,preserveDrawingBuffer:!0,canvas:e.canvas}),this.setPixelRatio(window.devicePixelRatio),this.shadowMap.enabled=e.shadowMapEnabled||Ss.shadowMapEnabled,this.shadowMap.type=e.shadowMapType||Ss.shadowMapType,this.toneMapping=e.toneMapping||Ss.toneMapping,this.debug.checkShaderErrors=!1}Dispose(){this.StopRenderer(),this.dispose()}StartRenderer(e,t){this.setAnimationLoop((n,r)=>{this.internal_render(e,t,n,r)}),this.running=!0}PauseRenderer(){this.paused=!0}ResumeRenderer(){this.paused=!1}StopRenderer(){this.setAnimationLoop(null),this.running=!1}OnResize(e,t){this.setSize(e,t)}AddPreRenderCallback(e){const t=ci.generateUUID();return this.preRenderCallbacks.set(t,e),t}RemovePreRenderCallback(e){return this.preRenderCallbacks.has(e)?(this.preRenderCallbacks.delete(e),!0):!1}AddPostRenderCallback(e){const t=ci.generateUUID();return this.postRenderCallbacks.set(t,e),t}RemovePostRenderCallback(e){return this.postRenderCallbacks.has(e)?(this.postRenderCallbacks.delete(e),!0):!1}ForceRendering(){this.force=!0}internal_render(e,t,n,r){(this.paused||!this.running)&&!this.force||(this.preRenderCallbacks.forEach(o=>{o(n,r)}),this.render(e,t),this.postRenderCallbacks.forEach(o=>{o(n,r)}),this.force=!1)}}const ML=1,va=2,Kf=4,F0=8,li=16;class SL extends gt{isDIVELight=!0;isDIVEAmbientLight=!0;_light;constructor(){super(),this.name="DIVEAmbientLight",this._light=new oL(16777215,1),this._light.layers.mask=li,this.add(this._light)}SetColor(e){this._light.color=e}SetIntensity(e){this._light.intensity=e}SetEnabled(e){this._light.visible=e}}const Ln=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];function EL(){const i=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(Ln[i&255]+Ln[i>>8&255]+Ln[i>>16&255]+Ln[i>>24&255]+"-"+Ln[e&255]+Ln[e>>8&255]+"-"+Ln[e>>16&15|64]+Ln[e>>24&255]+"-"+Ln[t&63|128]+Ln[t>>8&255]+"-"+Ln[t>>16&255]+Ln[t>>24&255]+Ln[n&255]+Ln[n>>8&255]+Ln[n>>16&255]+Ln[n>>24&255]).toLowerCase()}function yl(i,e){return i?e in i:!1}function Il(i,e){if(i)return yl(i,e)?i:Il(i.parent,e)}class TL{POINTER_DRAG_THRESHOLD=.001;name;_canvas;_scene;_controller;_pointer;get _pointerAnyDown(){return this._pointerPrimaryDown||this._pointerMiddleDown||this._pointerSecondaryDown}_pointerPrimaryDown;_pointerMiddleDown;_pointerSecondaryDown;_lastPointerDown;_lastPointerUp;_raycaster;_intersects;_hovered;_dragging;_dragStart;_dragCurrent;_dragEnd;_dragDelta;_draggable;_dragRaycastOnObjects;constructor(e,t){this.name="BaseTool",this._canvas=t.domElement,this._scene=e,this._controller=t,this._pointer=new Pe,this._pointerPrimaryDown=!1,this._pointerMiddleDown=!1,this._pointerSecondaryDown=!1,this._lastPointerDown=new Pe,this._lastPointerUp=new Pe,this._raycaster=new Hl,this._raycaster.layers.mask=li|Kf,this._intersects=[],this._hovered=null,this._dragging=!1,this._dragStart=new F,this._dragCurrent=new F,this._dragEnd=new F,this._dragDelta=new F,this._draggable=null,this._dragRaycastOnObjects=null}Activate(){}Deactivate(){}onPointerDown(e){switch(e.button){case 0:{this._pointerPrimaryDown=!0;break}case 1:{this._pointerMiddleDown=!0;break}case 2:{this._pointerSecondaryDown=!0;break}default:console.warn("DIVEBaseTool.onPointerDown: Unknown button: "+e.button)}this._lastPointerDown.copy(this._pointer),this._draggable=Il(this._intersects[0]?.object,"isDraggable")||null}onDragStart(e){this._draggable&&(this._dragRaycastOnObjects!==null&&(this._intersects=this._raycaster.intersectObjects(this._dragRaycastOnObjects,!0)),this._intersects.length!==0&&(this._dragStart.copy(this._intersects[0].point.clone()),this._dragCurrent.copy(this._intersects[0].point.clone()),this._dragEnd.copy(this._dragStart.clone()),this._dragDelta.set(0,0,0),this._draggable&&this._draggable.onDragStart&&(this._draggable.onDragStart({dragStart:this._dragStart,dragCurrent:this._dragCurrent,dragEnd:this._dragEnd,dragDelta:this._dragDelta}),this._dragging=!0,this._controller.enabled=!1)))}onPointerMove(e){this._pointer.x=e.offsetX/this._canvas.clientWidth*2-1,this._pointer.y=-(e.offsetY/this._canvas.clientHeight)*2+1,this._raycaster.setFromCamera(this._pointer,this._controller.object),this._intersects=this.raycast(this._scene.children);const t=Il(this._intersects[0]?.object,"isHoverable");if(this._intersects[0]&&t){if(!this._hovered){t.onPointerEnter&&t.onPointerEnter(this._intersects[0]),this._hovered=t;return}if(this._hovered.uuid!==t.uuid){this._hovered.onPointerLeave&&this._hovered.onPointerLeave(),t.onPointerEnter&&t.onPointerEnter(this._intersects[0]),this._hovered=t;return}t.onPointerOver&&t.onPointerOver(this._intersects[0]),this._hovered=t}else this._hovered&&this._hovered.onPointerLeave&&this._hovered.onPointerLeave(),this._hovered=null;this._pointerAnyDown&&(this._dragging||this.onDragStart(e),this.onDrag(e))}onDrag(e){this._dragRaycastOnObjects!==null&&(this._intersects=this._raycaster.intersectObjects(this._dragRaycastOnObjects,!0));const t=this._intersects[0];t&&(this._dragCurrent.copy(t.point.clone()),this._dragEnd.copy(t.point.clone()),this._dragDelta.subVectors(this._dragCurrent.clone(),this._dragStart.clone()),this._draggable&&this._draggable.onDrag&&this._draggable.onDrag({dragStart:this._dragStart,dragCurrent:this._dragCurrent,dragEnd:this._dragEnd,dragDelta:this._dragDelta}))}onPointerUp(e){switch(this.pointerWasDragged()||this._dragging?this._draggable&&this.onDragEnd(e):this.onClick(e),e.button){case 0:this._pointerPrimaryDown=!1;break;case 1:this._pointerMiddleDown=!1;break;case 2:this._pointerSecondaryDown=!1;break}this._lastPointerUp.copy(this._pointer)}onClick(e){}onDragEnd(e){const t=this._intersects[0];t&&(this._dragEnd.copy(t.point.clone()),this._dragCurrent.copy(t.point.clone()),this._dragDelta.subVectors(this._dragCurrent.clone(),this._dragStart.clone())),this._draggable&&this._draggable.onDragEnd&&this._draggable.onDragEnd({dragStart:this._dragStart,dragCurrent:this._dragCurrent,dragEnd:this._dragEnd,dragDelta:this._dragDelta}),this._draggable=null,this._dragging=!1,this._dragStart.set(0,0,0),this._dragCurrent.set(0,0,0),this._dragEnd.set(0,0,0),this._dragDelta.set(0,0,0),this._controller.enabled=!0}onWheel(e){}raycast(e){return e!==void 0?this._raycaster.intersectObjects(e,!0).filter(t=>t.object.visible):this._raycaster.intersectObjects(this._scene.children,!0).filter(t=>t.object.visible)}pointerWasDragged(){return this._lastPointerDown.distanceTo(this._pointer)>this.POINTER_DRAG_THRESHOLD}}const xs=new Hl,In=new F,Yr=new F,jt=new an,p_={X:new F(1,0,0),Y:new F(0,1,0),Z:new F(0,0,1)},Hh={type:"change"},m_={type:"mouseDown"},g_={type:"mouseUp",mode:null},__={type:"objectChange"};class bL extends gt{constructor(e,t){super(),t===void 0&&(console.warn('THREE.TransformControls: The second parameter "domElement" is now mandatory.'),t=document),this.isTransformControls=!0,this.visible=!1,this.domElement=t,this.domElement.style.touchAction="none";const n=new LL;this._gizmo=n,this.add(n);const r=new IL;this._plane=r,this.add(r);const o=this;function a(R,b){let A=b;Object.defineProperty(o,R,{get:function(){return A!==void 0?A:b},set:function(B){A!==B&&(A=B,r[R]=B,n[R]=B,o.dispatchEvent({type:R+"-changed",value:B}),o.dispatchEvent(Hh))}}),o[R]=b,r[R]=b,n[R]=b}a("camera",e),a("object",void 0),a("enabled",!0),a("axis",null),a("mode","translate"),a("translationSnap",null),a("rotationSnap",null),a("scaleSnap",null),a("space","world"),a("size",1),a("dragging",!1),a("showX",!0),a("showY",!0),a("showZ",!0);const l=new F,u=new F,h=new an,d=new an,p=new F,m=new an,g=new F,y=new F,S=new F,_=0,v=new F;a("worldPosition",l),a("worldPositionStart",u),a("worldQuaternion",h),a("worldQuaternionStart",d),a("cameraPosition",p),a("cameraQuaternion",m),a("pointStart",g),a("pointEnd",y),a("rotationAxis",S),a("rotationAngle",_),a("eye",v),this._offset=new F,this._startNorm=new F,this._endNorm=new F,this._cameraScale=new F,this._parentPosition=new F,this._parentQuaternion=new an,this._parentQuaternionInv=new an,this._parentScale=new F,this._worldScaleStart=new F,this._worldQuaternionInv=new an,this._worldScale=new F,this._positionStart=new F,this._quaternionStart=new an,this._scaleStart=new F,this._getPointer=wL.bind(this),this._onPointerDown=RL.bind(this),this._onPointerHover=AL.bind(this),this._onPointerMove=CL.bind(this),this._onPointerUp=PL.bind(this),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointermove",this._onPointerHover),this.domElement.addEventListener("pointerup",this._onPointerUp)}updateMatrixWorld(e){this.object!==void 0&&(this.object.updateMatrixWorld(),this.object.parent===null?console.error("TransformControls: The attached 3D object must be a part of the scene graph."):this.object.parent.matrixWorld.decompose(this._parentPosition,this._parentQuaternion,this._parentScale),this.object.matrixWorld.decompose(this.worldPosition,this.worldQuaternion,this._worldScale),this._parentQuaternionInv.copy(this._parentQuaternion).invert(),this._worldQuaternionInv.copy(this.worldQuaternion).invert()),this.camera.updateMatrixWorld(),this.camera.matrixWorld.decompose(this.cameraPosition,this.cameraQuaternion,this._cameraScale),this.camera.isOrthographicCamera?this.camera.getWorldDirection(this.eye).negate():this.eye.copy(this.cameraPosition).sub(this.worldPosition).normalize(),super.updateMatrixWorld(e)}pointerHover(e){if(this.object===void 0||this.dragging===!0)return;e!==null&&xs.setFromCamera(e,this.camera);const t=Gh(this._gizmo.picker[this.mode],xs);t?this.axis=t.object.name:this.axis=null}pointerDown(e){if(!(this.object===void 0||this.dragging===!0||e!=null&&e.button!==0)&&this.axis!==null){e!==null&&xs.setFromCamera(e,this.camera);const t=Gh(this._plane,xs,!0);t&&(this.object.updateMatrixWorld(),this.object.parent.updateMatrixWorld(),this._positionStart.copy(this.object.position),this._quaternionStart.copy(this.object.quaternion),this._scaleStart.copy(this.object.scale),this.object.matrixWorld.decompose(this.worldPositionStart,this.worldQuaternionStart,this._worldScaleStart),this.pointStart.copy(t.point).sub(this.worldPositionStart)),this.dragging=!0,m_.mode=this.mode,this.dispatchEvent(m_)}}pointerMove(e){const t=this.axis,n=this.mode,r=this.object;let o=this.space;if(n==="scale"?o="local":(t==="E"||t==="XYZE"||t==="XYZ")&&(o="world"),r===void 0||t===null||this.dragging===!1||e!==null&&e.button!==-1)return;e!==null&&xs.setFromCamera(e,this.camera);const a=Gh(this._plane,xs,!0);if(a){if(this.pointEnd.copy(a.point).sub(this.worldPositionStart),n==="translate")this._offset.copy(this.pointEnd).sub(this.pointStart),o==="local"&&t!=="XYZ"&&this._offset.applyQuaternion(this._worldQuaternionInv),t.indexOf("X")===-1&&(this._offset.x=0),t.indexOf("Y")===-1&&(this._offset.y=0),t.indexOf("Z")===-1&&(this._offset.z=0),o==="local"&&t!=="XYZ"?this._offset.applyQuaternion(this._quaternionStart).divide(this._parentScale):this._offset.applyQuaternion(this._parentQuaternionInv).divide(this._parentScale),r.position.copy(this._offset).add(this._positionStart),this.translationSnap&&(o==="local"&&(r.position.applyQuaternion(jt.copy(this._quaternionStart).invert()),t.search("X")!==-1&&(r.position.x=Math.round(r.position.x/this.translationSnap)*this.translationSnap),t.search("Y")!==-1&&(r.position.y=Math.round(r.position.y/this.translationSnap)*this.translationSnap),t.search("Z")!==-1&&(r.position.z=Math.round(r.position.z/this.translationSnap)*this.translationSnap),r.position.applyQuaternion(this._quaternionStart)),o==="world"&&(r.parent&&r.position.add(In.setFromMatrixPosition(r.parent.matrixWorld)),t.search("X")!==-1&&(r.position.x=Math.round(r.position.x/this.translationSnap)*this.translationSnap),t.search("Y")!==-1&&(r.position.y=Math.round(r.position.y/this.translationSnap)*this.translationSnap),t.search("Z")!==-1&&(r.position.z=Math.round(r.position.z/this.translationSnap)*this.translationSnap),r.parent&&r.position.sub(In.setFromMatrixPosition(r.parent.matrixWorld))));else if(n==="scale"){if(t.search("XYZ")!==-1){let l=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(l*=-1),Yr.set(l,l,l)}else In.copy(this.pointStart),Yr.copy(this.pointEnd),In.applyQuaternion(this._worldQuaternionInv),Yr.applyQuaternion(this._worldQuaternionInv),Yr.divide(In),t.search("X")===-1&&(Yr.x=1),t.search("Y")===-1&&(Yr.y=1),t.search("Z")===-1&&(Yr.z=1);r.scale.copy(this._scaleStart).multiply(Yr),this.scaleSnap&&(t.search("X")!==-1&&(r.scale.x=Math.round(r.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap),t.search("Y")!==-1&&(r.scale.y=Math.round(r.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap),t.search("Z")!==-1&&(r.scale.z=Math.round(r.scale.z/this.scaleSnap)*this.scaleSnap||this.scaleSnap))}else if(n==="rotate"){this._offset.copy(this.pointEnd).sub(this.pointStart);const l=20/this.worldPosition.distanceTo(In.setFromMatrixPosition(this.camera.matrixWorld));let u=!1;t==="XYZE"?(this.rotationAxis.copy(this._offset).cross(this.eye).normalize(),this.rotationAngle=this._offset.dot(In.copy(this.rotationAxis).cross(this.eye))*l):(t==="X"||t==="Y"||t==="Z")&&(this.rotationAxis.copy(p_[t]),In.copy(p_[t]),o==="local"&&In.applyQuaternion(this.worldQuaternion),In.cross(this.eye),In.length()===0?u=!0:this.rotationAngle=this._offset.dot(In.normalize())*l),(t==="E"||u)&&(this.rotationAxis.copy(this.eye),this.rotationAngle=this.pointEnd.angleTo(this.pointStart),this._startNorm.copy(this.pointStart).normalize(),this._endNorm.copy(this.pointEnd).normalize(),this.rotationAngle*=this._endNorm.cross(this._startNorm).dot(this.eye)<0?1:-1),this.rotationSnap&&(this.rotationAngle=Math.round(this.rotationAngle/this.rotationSnap)*this.rotationSnap),o==="local"&&t!=="E"&&t!=="XYZE"?(r.quaternion.copy(this._quaternionStart),r.quaternion.multiply(jt.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this._parentQuaternionInv),r.quaternion.copy(jt.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),r.quaternion.multiply(this._quaternionStart).normalize())}this.dispatchEvent(Hh),this.dispatchEvent(__)}}pointerUp(e){e!==null&&e.button!==0||(this.dragging&&this.axis!==null&&(g_.mode=this.mode,this.dispatchEvent(g_)),this.dragging=!1,this.axis=null)}dispose(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerHover),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.traverse(function(e){e.geometry&&e.geometry.dispose(),e.material&&e.material.dispose()})}attach(e){return this.object=e,this.visible=!0,this}detach(){return this.object=void 0,this.visible=!1,this.axis=null,this}reset(){this.enabled&&this.dragging&&(this.object.position.copy(this._positionStart),this.object.quaternion.copy(this._quaternionStart),this.object.scale.copy(this._scaleStart),this.dispatchEvent(Hh),this.dispatchEvent(__),this.pointStart.copy(this.pointEnd))}getRaycaster(){return xs}getMode(){return this.mode}setMode(e){this.mode=e}setTranslationSnap(e){this.translationSnap=e}setRotationSnap(e){this.rotationSnap=e}setScaleSnap(e){this.scaleSnap=e}setSize(e){this.size=e}setSpace(e){this.space=e}}function wL(i){if(this.domElement.ownerDocument.pointerLockElement)return{x:0,y:0,button:i.button};{const e=this.domElement.getBoundingClientRect();return{x:(i.clientX-e.left)/e.width*2-1,y:-(i.clientY-e.top)/e.height*2+1,button:i.button}}}function AL(i){if(this.enabled)switch(i.pointerType){case"mouse":case"pen":this.pointerHover(this._getPointer(i));break}}function RL(i){this.enabled&&(document.pointerLockElement||this.domElement.setPointerCapture(i.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.pointerHover(this._getPointer(i)),this.pointerDown(this._getPointer(i)))}function CL(i){this.enabled&&this.pointerMove(this._getPointer(i))}function PL(i){this.enabled&&(this.domElement.releasePointerCapture(i.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.pointerUp(this._getPointer(i)))}function Gh(i,e,t){const n=e.intersectObject(i,!0);for(let r=0;r<n.length;r++)if(n[r].object.visible||t)return n[r];return!1}const hl=new Bi,Ft=new F(0,1,0),v_=new F(0,0,0),x_=new Qe,fl=new an,Ml=new an,Yi=new F,y_=new Qe,wa=new F(1,0,0),Es=new F(0,1,0),Aa=new F(0,0,1),dl=new F,xa=new F,ya=new F;class LL extends gt{constructor(){super(),this.isTransformControlsGizmo=!0,this.type="TransformControlsGizmo";const e=new Ji({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),t=new Bo({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),n=e.clone();n.opacity=.15;const r=t.clone();r.opacity=.5;const o=e.clone();o.color.setHex(16711680);const a=e.clone();a.color.setHex(65280);const l=e.clone();l.color.setHex(255);const u=e.clone();u.color.setHex(16711680),u.opacity=.5;const h=e.clone();h.color.setHex(65280),h.opacity=.5;const d=e.clone();d.color.setHex(255),d.opacity=.5;const p=e.clone();p.opacity=.25;const m=e.clone();m.color.setHex(16776960),m.opacity=.25,e.clone().color.setHex(16776960);const y=e.clone();y.color.setHex(7895160);const S=new vn(0,.04,.1,12);S.translate(0,.05,0);const _=new Kt(.08,.08,.08);_.translate(0,.04,0);const v=new tn;v.setAttribute("position",new Bt([0,0,0,1,0,0],3));const R=new vn(.0075,.0075,.5,3);R.translate(0,.25,0);function b($,re){const se=new ws($,.0075,3,64,re*Math.PI*2);return se.rotateY(Math.PI/2),se.rotateX(Math.PI/2),se}function A(){const $=new tn;return $.setAttribute("position",new Bt([0,0,0,1,1,1],3)),$}const B={X:[[new Se(S,o),[.5,0,0],[0,0,-Math.PI/2]],[new Se(S,o),[-.5,0,0],[0,0,Math.PI/2]],[new Se(R,o),[0,0,0],[0,0,-Math.PI/2]]],Y:[[new Se(S,a),[0,.5,0]],[new Se(S,a),[0,-.5,0],[Math.PI,0,0]],[new Se(R,a)]],Z:[[new Se(S,l),[0,0,.5],[Math.PI/2,0,0]],[new Se(S,l),[0,0,-.5],[-Math.PI/2,0,0]],[new Se(R,l),null,[Math.PI/2,0,0]]],XYZ:[[new Se(new So(.1,0),p.clone()),[0,0,0]]],XY:[[new Se(new Kt(.15,.15,.01),d.clone()),[.15,.15,0]]],YZ:[[new Se(new Kt(.15,.15,.01),u.clone()),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new Se(new Kt(.15,.15,.01),h.clone()),[.15,0,.15],[-Math.PI/2,0,0]]]},N={X:[[new Se(new vn(.2,0,.6,4),n),[.3,0,0],[0,0,-Math.PI/2]],[new Se(new vn(.2,0,.6,4),n),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new Se(new vn(.2,0,.6,4),n),[0,.3,0]],[new Se(new vn(.2,0,.6,4),n),[0,-.3,0],[0,0,Math.PI]]],Z:[[new Se(new vn(.2,0,.6,4),n),[0,0,.3],[Math.PI/2,0,0]],[new Se(new vn(.2,0,.6,4),n),[0,0,-.3],[-Math.PI/2,0,0]]],XYZ:[[new Se(new So(.2,0),n)]],XY:[[new Se(new Kt(.2,.2,.01),n),[.15,.15,0]]],YZ:[[new Se(new Kt(.2,.2,.01),n),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new Se(new Kt(.2,.2,.01),n),[.15,0,.15],[-Math.PI/2,0,0]]]},D={START:[[new Se(new So(.01,2),r),null,null,null,"helper"]],END:[[new Se(new So(.01,2),r),null,null,null,"helper"]],DELTA:[[new Si(A(),r),null,null,null,"helper"]],X:[[new Si(v,r.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new Si(v,r.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new Si(v,r.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},C={XYZE:[[new Se(b(.5,1),y),null,[0,Math.PI/2,0]]],X:[[new Se(b(.5,.5),o)]],Y:[[new Se(b(.5,.5),a),null,[0,0,-Math.PI/2]]],Z:[[new Se(b(.5,.5),l),null,[0,Math.PI/2,0]]],E:[[new Se(b(.75,1),m),null,[0,Math.PI/2,0]]]},E={AXIS:[[new Si(v,r.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]]},M={XYZE:[[new Se(new Va(.25,10,8),n)]],X:[[new Se(new ws(.5,.1,4,24),n),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new Se(new ws(.5,.1,4,24),n),[0,0,0],[Math.PI/2,0,0]]],Z:[[new Se(new ws(.5,.1,4,24),n),[0,0,0],[0,0,-Math.PI/2]]],E:[[new Se(new ws(.75,.1,2,24),n)]]},O={X:[[new Se(_,o),[.5,0,0],[0,0,-Math.PI/2]],[new Se(R,o),[0,0,0],[0,0,-Math.PI/2]],[new Se(_,o),[-.5,0,0],[0,0,Math.PI/2]]],Y:[[new Se(_,a),[0,.5,0]],[new Se(R,a)],[new Se(_,a),[0,-.5,0],[0,0,Math.PI]]],Z:[[new Se(_,l),[0,0,.5],[Math.PI/2,0,0]],[new Se(R,l),[0,0,0],[Math.PI/2,0,0]],[new Se(_,l),[0,0,-.5],[-Math.PI/2,0,0]]],XY:[[new Se(new Kt(.15,.15,.01),d),[.15,.15,0]]],YZ:[[new Se(new Kt(.15,.15,.01),u),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new Se(new Kt(.15,.15,.01),h),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new Se(new Kt(.1,.1,.1),p.clone())]]},H={X:[[new Se(new vn(.2,0,.6,4),n),[.3,0,0],[0,0,-Math.PI/2]],[new Se(new vn(.2,0,.6,4),n),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new Se(new vn(.2,0,.6,4),n),[0,.3,0]],[new Se(new vn(.2,0,.6,4),n),[0,-.3,0],[0,0,Math.PI]]],Z:[[new Se(new vn(.2,0,.6,4),n),[0,0,.3],[Math.PI/2,0,0]],[new Se(new vn(.2,0,.6,4),n),[0,0,-.3],[-Math.PI/2,0,0]]],XY:[[new Se(new Kt(.2,.2,.01),n),[.15,.15,0]]],YZ:[[new Se(new Kt(.2,.2,.01),n),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new Se(new Kt(.2,.2,.01),n),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new Se(new Kt(.2,.2,.2),n),[0,0,0]]]},G={X:[[new Si(v,r.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new Si(v,r.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new Si(v,r.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]};function Y($){const re=new gt;for(const se in $)for(let K=$[se].length;K--;){const ae=$[se][K][0].clone(),pe=$[se][K][1],ve=$[se][K][2],ke=$[se][K][3],Ze=$[se][K][4];ae.name=se,ae.tag=Ze,pe&&ae.position.set(pe[0],pe[1],pe[2]),ve&&ae.rotation.set(ve[0],ve[1],ve[2]),ke&&ae.scale.set(ke[0],ke[1],ke[2]),ae.updateMatrix();const te=ae.geometry.clone();te.applyMatrix4(ae.matrix),ae.geometry=te,ae.renderOrder=1/0,ae.position.set(0,0,0),ae.rotation.set(0,0,0),ae.scale.set(1,1,1),re.add(ae)}return re}this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=Y(B)),this.add(this.gizmo.rotate=Y(C)),this.add(this.gizmo.scale=Y(O)),this.add(this.picker.translate=Y(N)),this.add(this.picker.rotate=Y(M)),this.add(this.picker.scale=Y(H)),this.add(this.helper.translate=Y(D)),this.add(this.helper.rotate=Y(E)),this.add(this.helper.scale=Y(G)),this.picker.translate.visible=!1,this.picker.rotate.visible=!1,this.picker.scale.visible=!1}updateMatrixWorld(e){const n=(this.mode==="scale"?"local":this.space)==="local"?this.worldQuaternion:Ml;this.gizmo.translate.visible=this.mode==="translate",this.gizmo.rotate.visible=this.mode==="rotate",this.gizmo.scale.visible=this.mode==="scale",this.helper.translate.visible=this.mode==="translate",this.helper.rotate.visible=this.mode==="rotate",this.helper.scale.visible=this.mode==="scale";let r=[];r=r.concat(this.picker[this.mode].children),r=r.concat(this.gizmo[this.mode].children),r=r.concat(this.helper[this.mode].children);for(let o=0;o<r.length;o++){const a=r[o];a.visible=!0,a.rotation.set(0,0,0),a.position.copy(this.worldPosition);let l;if(this.camera.isOrthographicCamera?l=(this.camera.top-this.camera.bottom)/this.camera.zoom:l=this.worldPosition.distanceTo(this.cameraPosition)*Math.min(1.9*Math.tan(Math.PI*this.camera.fov/360)/this.camera.zoom,7),a.scale.set(1,1,1).multiplyScalar(l*this.size/4),a.tag==="helper"){a.visible=!1,a.name==="AXIS"?(a.visible=!!this.axis,this.axis==="X"&&(jt.setFromEuler(hl.set(0,0,0)),a.quaternion.copy(n).multiply(jt),Math.abs(Ft.copy(wa).applyQuaternion(n).dot(this.eye))>.9&&(a.visible=!1)),this.axis==="Y"&&(jt.setFromEuler(hl.set(0,0,Math.PI/2)),a.quaternion.copy(n).multiply(jt),Math.abs(Ft.copy(Es).applyQuaternion(n).dot(this.eye))>.9&&(a.visible=!1)),this.axis==="Z"&&(jt.setFromEuler(hl.set(0,Math.PI/2,0)),a.quaternion.copy(n).multiply(jt),Math.abs(Ft.copy(Aa).applyQuaternion(n).dot(this.eye))>.9&&(a.visible=!1)),this.axis==="XYZE"&&(jt.setFromEuler(hl.set(0,Math.PI/2,0)),Ft.copy(this.rotationAxis),a.quaternion.setFromRotationMatrix(x_.lookAt(v_,Ft,Es)),a.quaternion.multiply(jt),a.visible=this.dragging),this.axis==="E"&&(a.visible=!1)):a.name==="START"?(a.position.copy(this.worldPositionStart),a.visible=this.dragging):a.name==="END"?(a.position.copy(this.worldPosition),a.visible=this.dragging):a.name==="DELTA"?(a.position.copy(this.worldPositionStart),a.quaternion.copy(this.worldQuaternionStart),In.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),In.applyQuaternion(this.worldQuaternionStart.clone().invert()),a.scale.copy(In),a.visible=this.dragging):(a.quaternion.copy(n),this.dragging?a.position.copy(this.worldPositionStart):a.position.copy(this.worldPosition),this.axis&&(a.visible=this.axis.search(a.name)!==-1));continue}a.quaternion.copy(n),this.mode==="translate"||this.mode==="scale"?(a.name==="X"&&Math.abs(Ft.copy(wa).applyQuaternion(n).dot(this.eye))>.99&&(a.scale.set(1e-10,1e-10,1e-10),a.visible=!1),a.name==="Y"&&Math.abs(Ft.copy(Es).applyQuaternion(n).dot(this.eye))>.99&&(a.scale.set(1e-10,1e-10,1e-10),a.visible=!1),a.name==="Z"&&Math.abs(Ft.copy(Aa).applyQuaternion(n).dot(this.eye))>.99&&(a.scale.set(1e-10,1e-10,1e-10),a.visible=!1),a.name==="XY"&&Math.abs(Ft.copy(Aa).applyQuaternion(n).dot(this.eye))<.2&&(a.scale.set(1e-10,1e-10,1e-10),a.visible=!1),a.name==="YZ"&&Math.abs(Ft.copy(wa).applyQuaternion(n).dot(this.eye))<.2&&(a.scale.set(1e-10,1e-10,1e-10),a.visible=!1),a.name==="XZ"&&Math.abs(Ft.copy(Es).applyQuaternion(n).dot(this.eye))<.2&&(a.scale.set(1e-10,1e-10,1e-10),a.visible=!1)):this.mode==="rotate"&&(fl.copy(n),Ft.copy(this.eye).applyQuaternion(jt.copy(n).invert()),a.name.search("E")!==-1&&a.quaternion.setFromRotationMatrix(x_.lookAt(this.eye,v_,Es)),a.name==="X"&&(jt.setFromAxisAngle(wa,Math.atan2(-Ft.y,Ft.z)),jt.multiplyQuaternions(fl,jt),a.quaternion.copy(jt)),a.name==="Y"&&(jt.setFromAxisAngle(Es,Math.atan2(Ft.x,Ft.z)),jt.multiplyQuaternions(fl,jt),a.quaternion.copy(jt)),a.name==="Z"&&(jt.setFromAxisAngle(Aa,Math.atan2(Ft.y,Ft.x)),jt.multiplyQuaternions(fl,jt),a.quaternion.copy(jt))),a.visible=a.visible&&(a.name.indexOf("X")===-1||this.showX),a.visible=a.visible&&(a.name.indexOf("Y")===-1||this.showY),a.visible=a.visible&&(a.name.indexOf("Z")===-1||this.showZ),a.visible=a.visible&&(a.name.indexOf("E")===-1||this.showX&&this.showY&&this.showZ),a.material._color=a.material._color||a.material.color.clone(),a.material._opacity=a.material._opacity||a.material.opacity,a.material.color.copy(a.material._color),a.material.opacity=a.material._opacity,this.enabled&&this.axis&&(a.name===this.axis||this.axis.split("").some(function(u){return a.name===u}))&&(a.material.color.setHex(16776960),a.material.opacity=1)}super.updateMatrixWorld(e)}}class IL extends Se{constructor(){super(new ns(1e5,1e5,2,2),new Ji({visible:!1,wireframe:!0,side:si,transparent:!0,opacity:.1,toneMapped:!1})),this.isTransformControlsPlane=!0,this.type="TransformControlsPlane"}updateMatrixWorld(e){let t=this.space;switch(this.position.copy(this.worldPosition),this.mode==="scale"&&(t="local"),dl.copy(wa).applyQuaternion(t==="local"?this.worldQuaternion:Ml),xa.copy(Es).applyQuaternion(t==="local"?this.worldQuaternion:Ml),ya.copy(Aa).applyQuaternion(t==="local"?this.worldQuaternion:Ml),Ft.copy(xa),this.mode){case"translate":case"scale":switch(this.axis){case"X":Ft.copy(this.eye).cross(dl),Yi.copy(dl).cross(Ft);break;case"Y":Ft.copy(this.eye).cross(xa),Yi.copy(xa).cross(Ft);break;case"Z":Ft.copy(this.eye).cross(ya),Yi.copy(ya).cross(Ft);break;case"XY":Yi.copy(ya);break;case"YZ":Yi.copy(dl);break;case"XZ":Ft.copy(ya),Yi.copy(xa);break;case"XYZ":case"E":Yi.set(0,0,0);break}break;case"rotate":default:Yi.set(0,0,0)}Yi.length()===0?this.quaternion.copy(this.cameraQuaternion):(y_.lookAt(In.set(0,0,0),Yi,Ft),this.quaternion.setFromRotationMatrix(y_)),super.updateMatrixWorld(e)}}const B0="#c20017",z0="#00ab26",k0="#0081d4",pf=B0,mf=z0,gf=k0;class DL extends TL{isTransformTool=!0;_scaleLinked;_gizmo;constructor(e,t){super(e,t),this.name="DIVETransformTool",this._scaleLinked=!1,this._gizmo=this.initGizmo(),this._scene.add(this._gizmo)}Activate(){}SetGizmoMode(e){this._gizmo.mode=e}SetGizmoVisibility(e){const t=this._scene.children.includes(this._gizmo);e&&!t?(this._scene.add(this._gizmo),"isTransformControls"in this._gizmo&&this._gizmo.getRaycaster().layers.enableAll()):!e&&t&&(this._scene.remove(this._gizmo),"isTransformControls"in this._gizmo&&this._gizmo.getRaycaster().layers.disableAll())}SetGizmoScaleLinked(e){this._scaleLinked=e}initGizmo(){const e=new bL(this._controller.object,this._controller.domElement);return e.mode="translate",e.traverse(t=>{if(!("isMesh"in t))return;const n=t.material;t.name==="X"&&n.color.set(pf),t.name==="Y"&&n.color.set(mf),t.name==="Z"&&n.color.set(gf),t.name==="XY"&&n.color.set(gf),t.name==="YZ"&&n.color.set(pf),t.name==="XZ"&&n.color.set(mf)}),e.addEventListener("mouseDown",()=>{this._controller.enabled=!1,yl(e.object,"isMovable")&&e.object.onMoveStart&&e.object.onMoveStart()}),e.addEventListener("objectChange",()=>{if(yl(e.object,"isMovable")&&e.object.onMove&&(e.object.onMove(),this._scaleLinked)){const t=e.object.scale,n=(t.x+t.y+t.z)/3;e.object.scale.set(n,n,n)}}),e.addEventListener("mouseUp",()=>{this._controller.enabled=!0,yl(e.object,"isMovable")&&e.object.onMoveEnd&&e.object.onMoveEnd()}),e}}const M_=i=>i.isSelectTool!==void 0;class UL extends DL{isSelectTool=!0;constructor(e,t){super(e,t),this.name="SelectTool"}Activate(){}Select(e){this.AttachGizmo(e),e.onSelect&&e.onSelect()}Deselect(e){this.DetachGizmo(),e.onDeselect&&e.onDeselect()}AttachGizmo(e){if("isMovable"in e){const t=e;this._gizmo.attach(t),this.SetGizmoVisibility(t.visible)}}DetachGizmo(){this._gizmo.detach()}onClick(e){super.onClick(e);const t=this._raycaster.intersectObjects(this._scene.Root.children,!0).filter(r=>r.object.visible)[0],n=Il(t?.object,"isSelectable");if(!t||!n){this._gizmo.object&&this.Deselect(this._gizmo.object);return}if(this._gizmo.object){if(this._gizmo.object.uuid===n.uuid)return;this.Deselect(this._gizmo.object)}this.Select(n)}}var pl=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},Ra={exports:{}};/**
3797
+ }`;class wP{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t,n){if(this.texture===null){const r=new cn,o=e.properties.get(r);o.__webglTexture=t.texture,(t.depthNear!=n.depthNear||t.depthFar!=n.depthFar)&&(this.depthNear=t.depthNear,this.depthFar=t.depthFar),this.texture=r}}render(e,t){if(this.texture!==null){if(this.mesh===null){const n=t.cameras[0].viewport,r=new Rr({vertexShader:TP,fragmentShader:bP,uniforms:{depthColor:{value:this.texture},depthWidth:{value:n.z},depthHeight:{value:n.w}}});this.mesh=new Se(new ns(20,20),r)}e.render(this.mesh,t)}}reset(){this.texture=null,this.mesh=null}}class AP extends Ps{constructor(e,t){super();const n=this;let r=null,o=1,a=null,l="local-floor",u=1,h=null,d=null,p=null,m=null,g=null,y=null;const S=new wP,_=t.getContextAttributes();let v=null,R=null;const b=[],A=[],B=new Pe;let N=null;const D=new Un;D.layers.enable(1),D.viewport=new Ut;const C=new Un;C.layers.enable(2),C.viewport=new Ut;const E=[D,C],M=new SP;M.layers.enable(1),M.layers.enable(2);let O=null,H=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(te){let fe=b[te];return fe===void 0&&(fe=new Uh,b[te]=fe),fe.getTargetRaySpace()},this.getControllerGrip=function(te){let fe=b[te];return fe===void 0&&(fe=new Uh,b[te]=fe),fe.getGripSpace()},this.getHand=function(te){let fe=b[te];return fe===void 0&&(fe=new Uh,b[te]=fe),fe.getHandSpace()};function G(te){const fe=A.indexOf(te.inputSource);if(fe===-1)return;const Ee=b[fe];Ee!==void 0&&(Ee.update(te.inputSource,te.frame,h||a),Ee.dispatchEvent({type:te.type,data:te.inputSource}))}function Y(){r.removeEventListener("select",G),r.removeEventListener("selectstart",G),r.removeEventListener("selectend",G),r.removeEventListener("squeeze",G),r.removeEventListener("squeezestart",G),r.removeEventListener("squeezeend",G),r.removeEventListener("end",Y),r.removeEventListener("inputsourceschange",$);for(let te=0;te<b.length;te++){const fe=A[te];fe!==null&&(A[te]=null,b[te].disconnect(fe))}O=null,H=null,S.reset(),e.setRenderTarget(v),g=null,m=null,p=null,r=null,R=null,Ze.stop(),n.isPresenting=!1,e.setPixelRatio(N),e.setSize(B.width,B.height,!1),n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(te){o=te,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(te){l=te,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return h||a},this.setReferenceSpace=function(te){h=te},this.getBaseLayer=function(){return m!==null?m:g},this.getBinding=function(){return p},this.getFrame=function(){return y},this.getSession=function(){return r},this.setSession=async function(te){if(r=te,r!==null){if(v=e.getRenderTarget(),r.addEventListener("select",G),r.addEventListener("selectstart",G),r.addEventListener("selectend",G),r.addEventListener("squeeze",G),r.addEventListener("squeezestart",G),r.addEventListener("squeezeend",G),r.addEventListener("end",Y),r.addEventListener("inputsourceschange",$),_.xrCompatible!==!0&&await t.makeXRCompatible(),N=e.getPixelRatio(),e.getSize(B),r.renderState.layers===void 0){const fe={antialias:_.antialias,alpha:!0,depth:_.depth,stencil:_.stencil,framebufferScaleFactor:o};g=new XRWebGLLayer(r,t,fe),r.updateRenderState({baseLayer:g}),e.setPixelRatio(1),e.setSize(g.framebufferWidth,g.framebufferHeight,!1),R=new Rs(g.framebufferWidth,g.framebufferHeight,{format:Ei,type:Qr,colorSpace:e.outputColorSpace,stencilBuffer:_.stencil})}else{let fe=null,Ee=null,Me=null;_.depth&&(Me=_.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,fe=_.stencil?Ba:To,Ee=_.stencil?Ga:Po);const ze={colorFormat:t.RGBA8,depthFormat:Me,scaleFactor:o};p=new XRWebGLBinding(r,t),m=p.createProjectionLayer(ze),r.updateRenderState({layers:[m]}),e.setPixelRatio(1),e.setSize(m.textureWidth,m.textureHeight,!1),R=new Rs(m.textureWidth,m.textureHeight,{format:Ei,type:Qr,depthTexture:new y0(m.textureWidth,m.textureHeight,Ee,void 0,void 0,void 0,void 0,void 0,void 0,fe),stencilBuffer:_.stencil,colorSpace:e.outputColorSpace,samples:_.antialias?4:0});const Ve=e.properties.get(R);Ve.__ignoreDepthValues=m.ignoreDepthValues}R.isXRRenderTarget=!0,this.setFoveation(u),h=null,a=await r.requestReferenceSpace(l),Ze.setContext(r),Ze.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(r!==null)return r.environmentBlendMode};function $(te){for(let fe=0;fe<te.removed.length;fe++){const Ee=te.removed[fe],Me=A.indexOf(Ee);Me>=0&&(A[Me]=null,b[Me].disconnect(Ee))}for(let fe=0;fe<te.added.length;fe++){const Ee=te.added[fe];let Me=A.indexOf(Ee);if(Me===-1){for(let Ve=0;Ve<b.length;Ve++)if(Ve>=A.length){A.push(Ee),Me=Ve;break}else if(A[Ve]===null){A[Ve]=Ee,Me=Ve;break}if(Me===-1)break}const ze=b[Me];ze&&ze.connect(Ee)}}const re=new F,se=new F;function K(te,fe,Ee){re.setFromMatrixPosition(fe.matrixWorld),se.setFromMatrixPosition(Ee.matrixWorld);const Me=re.distanceTo(se),ze=fe.projectionMatrix.elements,Ve=Ee.projectionMatrix.elements,it=ze[14]/(ze[10]-1),q=ze[14]/(ze[10]+1),$e=(ze[9]+1)/ze[5],Fe=(ze[9]-1)/ze[5],mt=(ze[8]-1)/ze[0],We=(Ve[8]+1)/Ve[0],At=it*mt,z=it*We,P=Me/(-mt+We),ie=P*-mt;fe.matrixWorld.decompose(te.position,te.quaternion,te.scale),te.translateX(ie),te.translateZ(P),te.matrixWorld.compose(te.position,te.quaternion,te.scale),te.matrixWorldInverse.copy(te.matrixWorld).invert();const le=it+P,de=q+P,ge=At-ie,He=z+(Me-ie),_e=$e*q/de*le,De=Fe*q/de*le;te.projectionMatrix.makePerspective(ge,He,_e,De,le,de),te.projectionMatrixInverse.copy(te.projectionMatrix).invert()}function ae(te,fe){fe===null?te.matrixWorld.copy(te.matrix):te.matrixWorld.multiplyMatrices(fe.matrixWorld,te.matrix),te.matrixWorldInverse.copy(te.matrixWorld).invert()}this.updateCamera=function(te){if(r===null)return;S.texture!==null&&(te.near=S.depthNear,te.far=S.depthFar),M.near=C.near=D.near=te.near,M.far=C.far=D.far=te.far,(O!==M.near||H!==M.far)&&(r.updateRenderState({depthNear:M.near,depthFar:M.far}),O=M.near,H=M.far,D.near=O,D.far=H,C.near=O,C.far=H,D.updateProjectionMatrix(),C.updateProjectionMatrix(),te.updateProjectionMatrix());const fe=te.parent,Ee=M.cameras;ae(M,fe);for(let Me=0;Me<Ee.length;Me++)ae(Ee[Me],fe);Ee.length===2?K(M,D,C):M.projectionMatrix.copy(D.projectionMatrix),pe(te,M,fe)};function pe(te,fe,Ee){Ee===null?te.matrix.copy(fe.matrixWorld):(te.matrix.copy(Ee.matrixWorld),te.matrix.invert(),te.matrix.multiply(fe.matrixWorld)),te.matrix.decompose(te.position,te.quaternion,te.scale),te.updateMatrixWorld(!0),te.projectionMatrix.copy(fe.projectionMatrix),te.projectionMatrixInverse.copy(fe.projectionMatrixInverse),te.isPerspectiveCamera&&(te.fov=Io*2*Math.atan(1/te.projectionMatrix.elements[5]),te.zoom=1)}this.getCamera=function(){return M},this.getFoveation=function(){if(!(m===null&&g===null))return u},this.setFoveation=function(te){u=te,m!==null&&(m.fixedFoveation=te),g!==null&&g.fixedFoveation!==void 0&&(g.fixedFoveation=te)},this.hasDepthSensing=function(){return S.texture!==null};let ve=null;function ke(te,fe){if(d=fe.getViewerPose(h||a),y=fe,d!==null){const Ee=d.views;g!==null&&(e.setRenderTargetFramebuffer(R,g.framebuffer),e.setRenderTarget(R));let Me=!1;Ee.length!==M.cameras.length&&(M.cameras.length=0,Me=!0);for(let Ve=0;Ve<Ee.length;Ve++){const it=Ee[Ve];let q=null;if(g!==null)q=g.getViewport(it);else{const Fe=p.getViewSubImage(m,it);q=Fe.viewport,Ve===0&&(e.setRenderTargetTextures(R,Fe.colorTexture,m.ignoreDepthValues?void 0:Fe.depthStencilTexture),e.setRenderTarget(R))}let $e=E[Ve];$e===void 0&&($e=new Un,$e.layers.enable(Ve),$e.viewport=new Ut,E[Ve]=$e),$e.matrix.fromArray(it.transform.matrix),$e.matrix.decompose($e.position,$e.quaternion,$e.scale),$e.projectionMatrix.fromArray(it.projectionMatrix),$e.projectionMatrixInverse.copy($e.projectionMatrix).invert(),$e.viewport.set(q.x,q.y,q.width,q.height),Ve===0&&(M.matrix.copy($e.matrix),M.matrix.decompose(M.position,M.quaternion,M.scale)),Me===!0&&M.cameras.push($e)}const ze=r.enabledFeatures;if(ze&&ze.includes("depth-sensing")){const Ve=p.getDepthInformation(Ee[0]);Ve&&Ve.isValid&&Ve.texture&&S.init(e,Ve,r.renderState)}}for(let Ee=0;Ee<b.length;Ee++){const Me=A[Ee],ze=b[Ee];Me!==null&&ze!==void 0&&ze.update(Me,fe,h||a)}S.render(e,M),ve&&ve(te,fe),fe.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:fe}),y=null}const Ze=new x0;Ze.setAnimationLoop(ke),this.setAnimationLoop=function(te){ve=te},this.dispose=function(){}}}const vs=new Bi,RP=new Qe;function CP(i,e){function t(_,v){_.matrixAutoUpdate===!0&&_.updateMatrix(),v.value.copy(_.matrix)}function n(_,v){v.color.getRGB(_.fogColor.value,m0(i)),v.isFog?(_.fogNear.value=v.near,_.fogFar.value=v.far):v.isFogExp2&&(_.fogDensity.value=v.density)}function r(_,v,R,b,A){v.isMeshBasicMaterial||v.isMeshLambertMaterial?o(_,v):v.isMeshToonMaterial?(o(_,v),p(_,v)):v.isMeshPhongMaterial?(o(_,v),d(_,v)):v.isMeshStandardMaterial?(o(_,v),m(_,v),v.isMeshPhysicalMaterial&&g(_,v,A)):v.isMeshMatcapMaterial?(o(_,v),y(_,v)):v.isMeshDepthMaterial?o(_,v):v.isMeshDistanceMaterial?(o(_,v),S(_,v)):v.isMeshNormalMaterial?o(_,v):v.isLineBasicMaterial?(a(_,v),v.isLineDashedMaterial&&l(_,v)):v.isPointsMaterial?u(_,v,R,b):v.isSpriteMaterial?h(_,v):v.isShadowMaterial?(_.color.value.copy(v.color),_.opacity.value=v.opacity):v.isShaderMaterial&&(v.uniformsNeedUpdate=!1)}function o(_,v){_.opacity.value=v.opacity,v.color&&_.diffuse.value.copy(v.color),v.emissive&&_.emissive.value.copy(v.emissive).multiplyScalar(v.emissiveIntensity),v.map&&(_.map.value=v.map,t(v.map,_.mapTransform)),v.alphaMap&&(_.alphaMap.value=v.alphaMap,t(v.alphaMap,_.alphaMapTransform)),v.bumpMap&&(_.bumpMap.value=v.bumpMap,t(v.bumpMap,_.bumpMapTransform),_.bumpScale.value=v.bumpScale,v.side===Kn&&(_.bumpScale.value*=-1)),v.normalMap&&(_.normalMap.value=v.normalMap,t(v.normalMap,_.normalMapTransform),_.normalScale.value.copy(v.normalScale),v.side===Kn&&_.normalScale.value.negate()),v.displacementMap&&(_.displacementMap.value=v.displacementMap,t(v.displacementMap,_.displacementMapTransform),_.displacementScale.value=v.displacementScale,_.displacementBias.value=v.displacementBias),v.emissiveMap&&(_.emissiveMap.value=v.emissiveMap,t(v.emissiveMap,_.emissiveMapTransform)),v.specularMap&&(_.specularMap.value=v.specularMap,t(v.specularMap,_.specularMapTransform)),v.alphaTest>0&&(_.alphaTest.value=v.alphaTest);const R=e.get(v),b=R.envMap,A=R.envMapRotation;if(b&&(_.envMap.value=b,vs.copy(A),vs.x*=-1,vs.y*=-1,vs.z*=-1,b.isCubeTexture&&b.isRenderTargetTexture===!1&&(vs.y*=-1,vs.z*=-1),_.envMapRotation.value.setFromMatrix4(RP.makeRotationFromEuler(vs)),_.flipEnvMap.value=b.isCubeTexture&&b.isRenderTargetTexture===!1?-1:1,_.reflectivity.value=v.reflectivity,_.ior.value=v.ior,_.refractionRatio.value=v.refractionRatio),v.lightMap){_.lightMap.value=v.lightMap;const B=i._useLegacyLights===!0?Math.PI:1;_.lightMapIntensity.value=v.lightMapIntensity*B,t(v.lightMap,_.lightMapTransform)}v.aoMap&&(_.aoMap.value=v.aoMap,_.aoMapIntensity.value=v.aoMapIntensity,t(v.aoMap,_.aoMapTransform))}function a(_,v){_.diffuse.value.copy(v.color),_.opacity.value=v.opacity,v.map&&(_.map.value=v.map,t(v.map,_.mapTransform))}function l(_,v){_.dashSize.value=v.dashSize,_.totalSize.value=v.dashSize+v.gapSize,_.scale.value=v.scale}function u(_,v,R,b){_.diffuse.value.copy(v.color),_.opacity.value=v.opacity,_.size.value=v.size*R,_.scale.value=b*.5,v.map&&(_.map.value=v.map,t(v.map,_.uvTransform)),v.alphaMap&&(_.alphaMap.value=v.alphaMap,t(v.alphaMap,_.alphaMapTransform)),v.alphaTest>0&&(_.alphaTest.value=v.alphaTest)}function h(_,v){_.diffuse.value.copy(v.color),_.opacity.value=v.opacity,_.rotation.value=v.rotation,v.map&&(_.map.value=v.map,t(v.map,_.mapTransform)),v.alphaMap&&(_.alphaMap.value=v.alphaMap,t(v.alphaMap,_.alphaMapTransform)),v.alphaTest>0&&(_.alphaTest.value=v.alphaTest)}function d(_,v){_.specular.value.copy(v.specular),_.shininess.value=Math.max(v.shininess,1e-4)}function p(_,v){v.gradientMap&&(_.gradientMap.value=v.gradientMap)}function m(_,v){_.metalness.value=v.metalness,v.metalnessMap&&(_.metalnessMap.value=v.metalnessMap,t(v.metalnessMap,_.metalnessMapTransform)),_.roughness.value=v.roughness,v.roughnessMap&&(_.roughnessMap.value=v.roughnessMap,t(v.roughnessMap,_.roughnessMapTransform)),v.envMap&&(_.envMapIntensity.value=v.envMapIntensity)}function g(_,v,R){_.ior.value=v.ior,v.sheen>0&&(_.sheenColor.value.copy(v.sheenColor).multiplyScalar(v.sheen),_.sheenRoughness.value=v.sheenRoughness,v.sheenColorMap&&(_.sheenColorMap.value=v.sheenColorMap,t(v.sheenColorMap,_.sheenColorMapTransform)),v.sheenRoughnessMap&&(_.sheenRoughnessMap.value=v.sheenRoughnessMap,t(v.sheenRoughnessMap,_.sheenRoughnessMapTransform))),v.clearcoat>0&&(_.clearcoat.value=v.clearcoat,_.clearcoatRoughness.value=v.clearcoatRoughness,v.clearcoatMap&&(_.clearcoatMap.value=v.clearcoatMap,t(v.clearcoatMap,_.clearcoatMapTransform)),v.clearcoatRoughnessMap&&(_.clearcoatRoughnessMap.value=v.clearcoatRoughnessMap,t(v.clearcoatRoughnessMap,_.clearcoatRoughnessMapTransform)),v.clearcoatNormalMap&&(_.clearcoatNormalMap.value=v.clearcoatNormalMap,t(v.clearcoatNormalMap,_.clearcoatNormalMapTransform),_.clearcoatNormalScale.value.copy(v.clearcoatNormalScale),v.side===Kn&&_.clearcoatNormalScale.value.negate())),v.iridescence>0&&(_.iridescence.value=v.iridescence,_.iridescenceIOR.value=v.iridescenceIOR,_.iridescenceThicknessMinimum.value=v.iridescenceThicknessRange[0],_.iridescenceThicknessMaximum.value=v.iridescenceThicknessRange[1],v.iridescenceMap&&(_.iridescenceMap.value=v.iridescenceMap,t(v.iridescenceMap,_.iridescenceMapTransform)),v.iridescenceThicknessMap&&(_.iridescenceThicknessMap.value=v.iridescenceThicknessMap,t(v.iridescenceThicknessMap,_.iridescenceThicknessMapTransform))),v.transmission>0&&(_.transmission.value=v.transmission,_.transmissionSamplerMap.value=R.texture,_.transmissionSamplerSize.value.set(R.width,R.height),v.transmissionMap&&(_.transmissionMap.value=v.transmissionMap,t(v.transmissionMap,_.transmissionMapTransform)),_.thickness.value=v.thickness,v.thicknessMap&&(_.thicknessMap.value=v.thicknessMap,t(v.thicknessMap,_.thicknessMapTransform)),_.attenuationDistance.value=v.attenuationDistance,_.attenuationColor.value.copy(v.attenuationColor)),v.anisotropy>0&&(_.anisotropyVector.value.set(v.anisotropy*Math.cos(v.anisotropyRotation),v.anisotropy*Math.sin(v.anisotropyRotation)),v.anisotropyMap&&(_.anisotropyMap.value=v.anisotropyMap,t(v.anisotropyMap,_.anisotropyMapTransform))),_.specularIntensity.value=v.specularIntensity,_.specularColor.value.copy(v.specularColor),v.specularColorMap&&(_.specularColorMap.value=v.specularColorMap,t(v.specularColorMap,_.specularColorMapTransform)),v.specularIntensityMap&&(_.specularIntensityMap.value=v.specularIntensityMap,t(v.specularIntensityMap,_.specularIntensityMapTransform))}function y(_,v){v.matcap&&(_.matcap.value=v.matcap)}function S(_,v){const R=e.get(v).light;_.referencePosition.value.setFromMatrixPosition(R.matrixWorld),_.nearDistance.value=R.shadow.camera.near,_.farDistance.value=R.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:r}}function PP(i,e,t,n){let r={},o={},a=[];const l=i.getParameter(i.MAX_UNIFORM_BUFFER_BINDINGS);function u(R,b){const A=b.program;n.uniformBlockBinding(R,A)}function h(R,b){let A=r[R.id];A===void 0&&(y(R),A=d(R),r[R.id]=A,R.addEventListener("dispose",_));const B=b.program;n.updateUBOMapping(R,B);const N=e.render.frame;o[R.id]!==N&&(m(R),o[R.id]=N)}function d(R){const b=p();R.__bindingPointIndex=b;const A=i.createBuffer(),B=R.__size,N=R.usage;return i.bindBuffer(i.UNIFORM_BUFFER,A),i.bufferData(i.UNIFORM_BUFFER,B,N),i.bindBuffer(i.UNIFORM_BUFFER,null),i.bindBufferBase(i.UNIFORM_BUFFER,b,A),A}function p(){for(let R=0;R<l;R++)if(a.indexOf(R)===-1)return a.push(R),R;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function m(R){const b=r[R.id],A=R.uniforms,B=R.__cache;i.bindBuffer(i.UNIFORM_BUFFER,b);for(let N=0,D=A.length;N<D;N++){const C=Array.isArray(A[N])?A[N]:[A[N]];for(let E=0,M=C.length;E<M;E++){const O=C[E];if(g(O,N,E,B)===!0){const H=O.__offset,G=Array.isArray(O.value)?O.value:[O.value];let Y=0;for(let $=0;$<G.length;$++){const re=G[$],se=S(re);typeof re=="number"||typeof re=="boolean"?(O.__data[0]=re,i.bufferSubData(i.UNIFORM_BUFFER,H+Y,O.__data)):re.isMatrix3?(O.__data[0]=re.elements[0],O.__data[1]=re.elements[1],O.__data[2]=re.elements[2],O.__data[3]=0,O.__data[4]=re.elements[3],O.__data[5]=re.elements[4],O.__data[6]=re.elements[5],O.__data[7]=0,O.__data[8]=re.elements[6],O.__data[9]=re.elements[7],O.__data[10]=re.elements[8],O.__data[11]=0):(re.toArray(O.__data,Y),Y+=se.storage/Float32Array.BYTES_PER_ELEMENT)}i.bufferSubData(i.UNIFORM_BUFFER,H,O.__data)}}}i.bindBuffer(i.UNIFORM_BUFFER,null)}function g(R,b,A,B){const N=R.value,D=b+"_"+A;if(B[D]===void 0)return typeof N=="number"||typeof N=="boolean"?B[D]=N:B[D]=N.clone(),!0;{const C=B[D];if(typeof N=="number"||typeof N=="boolean"){if(C!==N)return B[D]=N,!0}else if(C.equals(N)===!1)return C.copy(N),!0}return!1}function y(R){const b=R.uniforms;let A=0;const B=16;for(let D=0,C=b.length;D<C;D++){const E=Array.isArray(b[D])?b[D]:[b[D]];for(let M=0,O=E.length;M<O;M++){const H=E[M],G=Array.isArray(H.value)?H.value:[H.value];for(let Y=0,$=G.length;Y<$;Y++){const re=G[Y],se=S(re),K=A%B;K!==0&&B-K<se.boundary&&(A+=B-K),H.__data=new Float32Array(se.storage/Float32Array.BYTES_PER_ELEMENT),H.__offset=A,A+=se.storage}}}const N=A%B;return N>0&&(A+=B-N),R.__size=A,R.__cache={},this}function S(R){const b={boundary:0,storage:0};return typeof R=="number"||typeof R=="boolean"?(b.boundary=4,b.storage=4):R.isVector2?(b.boundary=8,b.storage=8):R.isVector3||R.isColor?(b.boundary=16,b.storage=12):R.isVector4?(b.boundary=16,b.storage=16):R.isMatrix3?(b.boundary=48,b.storage=48):R.isMatrix4?(b.boundary=64,b.storage=64):R.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",R),b}function _(R){const b=R.target;b.removeEventListener("dispose",_);const A=a.indexOf(b.__bindingPointIndex);a.splice(A,1),i.deleteBuffer(r[b.id]),delete r[b.id],delete o[b.id]}function v(){for(const R in r)i.deleteBuffer(r[R]);a=[],r={},o={}}return{bind:u,update:h,dispose:v}}class w0{constructor(e={}){const{canvas:t=Tw(),context:n=null,depth:r=!0,stencil:o=!1,alpha:a=!1,antialias:l=!1,premultipliedAlpha:u=!0,preserveDrawingBuffer:h=!1,powerPreference:d="default",failIfMajorPerformanceCaveat:p=!1}=e;this.isWebGLRenderer=!0;let m;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");m=n.getContextAttributes().alpha}else m=a;const g=new Uint32Array(4),y=new Int32Array(4);let S=null,_=null;const v=[],R=[];this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this._outputColorSpace=on,this._useLegacyLights=!1,this.toneMapping=Ar,this.toneMappingExposure=1;const b=this;let A=!1,B=0,N=0,D=null,C=-1,E=null;const M=new Ut,O=new Ut;let H=null;const G=new Oe(0);let Y=0,$=t.width,re=t.height,se=1,K=null,ae=null;const pe=new Ut(0,0,$,re),ve=new Ut(0,0,$,re);let ke=!1;const Ze=new kf;let te=!1,fe=!1;const Ee=new Qe,Me=new Pe,ze=new F,Ve={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function it(){return D===null?se:1}let q=n;function $e(U,j){const ee=t.getContext(U,j);return ee!==null?ee:null}try{const U={alpha:!0,depth:r,stencil:o,antialias:l,premultipliedAlpha:u,preserveDrawingBuffer:h,powerPreference:d,failIfMajorPerformanceCaveat:p};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${Uf}`),t.addEventListener("webglcontextlost",Z,!1),t.addEventListener("webglcontextrestored",ce,!1),t.addEventListener("webglcontextcreationerror",ye,!1),q===null){const j="webgl2";if(q=$e(j,U),q===null)throw $e(j)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(U){throw console.error("THREE.WebGLRenderer: "+U.message),U}let Fe,mt,We,At,z,P,ie,le,de,ge,He,_e,De,Xe,xe,we,Ke,Le,Ie,ct,ft,Et,_t,Tt;function Ne(){Fe=new zR(q),Fe.init(),mt=new DR(q,Fe,e),Et=new MP(q,Fe),We=new xP(q),At=new GR(q),z=new sP,P=new yP(q,Fe,We,z,mt,Et,At),ie=new NR(b),le=new BR(b),de=new qw(q),_t=new LR(q,de),ge=new kR(q,de,At,_t),He=new WR(q,ge,de,At),Ie=new VR(q,mt,P),we=new UR(z),_e=new rP(b,ie,le,Fe,mt,_t,we),De=new CP(b,z),Xe=new aP,xe=new dP(Fe),Le=new PR(b,ie,le,We,He,m,u),Ke=new vP(b,He,mt),Tt=new PP(q,At,mt,We),ct=new IR(q,Fe,At),ft=new HR(q,Fe,At),At.programs=_e.programs,b.capabilities=mt,b.extensions=Fe,b.properties=z,b.renderLists=Xe,b.shadowMap=Ke,b.state=We,b.info=At}Ne();const T=new AP(b,q);this.xr=T,this.getContext=function(){return q},this.getContextAttributes=function(){return q.getContextAttributes()},this.forceContextLoss=function(){const U=Fe.get("WEBGL_lose_context");U&&U.loseContext()},this.forceContextRestore=function(){const U=Fe.get("WEBGL_lose_context");U&&U.restoreContext()},this.getPixelRatio=function(){return se},this.setPixelRatio=function(U){U!==void 0&&(se=U,this.setSize($,re,!1))},this.getSize=function(U){return U.set($,re)},this.setSize=function(U,j,ee=!0){if(T.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}$=U,re=j,t.width=Math.floor(U*se),t.height=Math.floor(j*se),ee===!0&&(t.style.width=U+"px",t.style.height=j+"px"),this.setViewport(0,0,U,j)},this.getDrawingBufferSize=function(U){return U.set($*se,re*se).floor()},this.setDrawingBufferSize=function(U,j,ee){$=U,re=j,se=ee,t.width=Math.floor(U*ee),t.height=Math.floor(j*ee),this.setViewport(0,0,U,j)},this.getCurrentViewport=function(U){return U.copy(M)},this.getViewport=function(U){return U.copy(pe)},this.setViewport=function(U,j,ee,ne){U.isVector4?pe.set(U.x,U.y,U.z,U.w):pe.set(U,j,ee,ne),We.viewport(M.copy(pe).multiplyScalar(se).round())},this.getScissor=function(U){return U.copy(ve)},this.setScissor=function(U,j,ee,ne){U.isVector4?ve.set(U.x,U.y,U.z,U.w):ve.set(U,j,ee,ne),We.scissor(O.copy(ve).multiplyScalar(se).round())},this.getScissorTest=function(){return ke},this.setScissorTest=function(U){We.setScissorTest(ke=U)},this.setOpaqueSort=function(U){K=U},this.setTransparentSort=function(U){ae=U},this.getClearColor=function(U){return U.copy(Le.getClearColor())},this.setClearColor=function(){Le.setClearColor.apply(Le,arguments)},this.getClearAlpha=function(){return Le.getClearAlpha()},this.setClearAlpha=function(){Le.setClearAlpha.apply(Le,arguments)},this.clear=function(U=!0,j=!0,ee=!0){let ne=0;if(U){let J=!1;if(D!==null){const Ae=D.texture.format;J=Ae===r0||Ae===i0||Ae===n0}if(J){const Ae=D.texture.type,Be=Ae===Qr||Ae===Po||Ae===Z_||Ae===Ga||Ae===Q_||Ae===e0,Ge=Le.getClearColor(),Je=Le.getClearAlpha(),et=Ge.r,tt=Ge.g,rt=Ge.b;Be?(g[0]=et,g[1]=tt,g[2]=rt,g[3]=Je,q.clearBufferuiv(q.COLOR,0,g)):(y[0]=et,y[1]=tt,y[2]=rt,y[3]=Je,q.clearBufferiv(q.COLOR,0,y))}else ne|=q.COLOR_BUFFER_BIT}j&&(ne|=q.DEPTH_BUFFER_BIT),ee&&(ne|=q.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),q.clear(ne)},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",Z,!1),t.removeEventListener("webglcontextrestored",ce,!1),t.removeEventListener("webglcontextcreationerror",ye,!1),Xe.dispose(),xe.dispose(),z.dispose(),ie.dispose(),le.dispose(),He.dispose(),_t.dispose(),Tt.dispose(),_e.dispose(),T.dispose(),T.removeEventListener("sessionstart",Zt),T.removeEventListener("sessionend",Jt),Fn.stop()};function Z(U){U.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),A=!0}function ce(){console.log("THREE.WebGLRenderer: Context Restored."),A=!1;const U=At.autoReset,j=Ke.enabled,ee=Ke.autoUpdate,ne=Ke.needsUpdate,J=Ke.type;Ne(),At.autoReset=U,Ke.enabled=j,Ke.autoUpdate=ee,Ke.needsUpdate=ne,Ke.type=J}function ye(U){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",U.statusMessage)}function Re(U){const j=U.target;j.removeEventListener("dispose",Re),vt(j)}function vt(U){dt(U),z.remove(U)}function dt(U){const j=z.get(U).programs;j!==void 0&&(j.forEach(function(ee){_e.releaseProgram(ee)}),U.isShaderMaterial&&_e.releaseShaderCache(U))}this.renderBufferDirect=function(U,j,ee,ne,J,Ae){j===null&&(j=Ve);const Be=J.isMesh&&J.matrixWorld.determinant()<0,Ge=Yl(U,j,ee,ne,J);We.setMaterial(ne,Be);let Je=ee.index,et=1;if(ne.wireframe===!0){if(Je=ge.getWireframeAttribute(ee),Je===void 0)return;et=2}const tt=ee.drawRange,rt=ee.attributes.position;let qt=tt.start*et,wn=(tt.start+tt.count)*et;Ae!==null&&(qt=Math.max(qt,Ae.start*et),wn=Math.min(wn,(Ae.start+Ae.count)*et)),Je!==null?(qt=Math.max(qt,0),wn=Math.min(wn,Je.count)):rt!=null&&(qt=Math.max(qt,0),wn=Math.min(wn,rt.count));const nn=wn-qt;if(nn<0||nn===1/0)return;_t.setup(J,ne,Ge,ee,Je);let ui,Gt=ct;if(Je!==null&&(ui=de.get(Je),Gt=ft,Gt.setIndex(ui)),J.isMesh)ne.wireframe===!0?(We.setLineWidth(ne.wireframeLinewidth*it()),Gt.setMode(q.LINES)):Gt.setMode(q.TRIANGLES);else if(J.isLine){let ot=ne.linewidth;ot===void 0&&(ot=1),We.setLineWidth(ot*it()),J.isLineSegments?Gt.setMode(q.LINES):J.isLineLoop?Gt.setMode(q.LINE_LOOP):Gt.setMode(q.LINE_STRIP)}else J.isPoints?Gt.setMode(q.POINTS):J.isSprite&&Gt.setMode(q.TRIANGLES);if(J.isBatchedMesh)Gt.renderMultiDraw(J._multiDrawStarts,J._multiDrawCounts,J._multiDrawCount);else if(J.isInstancedMesh)Gt.renderInstances(qt,nn,J.count);else if(ee.isInstancedBufferGeometry){const ot=ee._maxInstanceCount!==void 0?ee._maxInstanceCount:1/0,Vo=Math.min(ee.instanceCount,ot);Gt.renderInstances(qt,nn,Vo)}else Gt.render(qt,nn)};function zt(U,j,ee){U.transparent===!0&&U.side===si&&U.forceSinglePass===!1?(U.side=Kn,U.needsUpdate=!0,Is(U,j,ee),U.side=tr,U.needsUpdate=!0,Is(U,j,ee),U.side=si):Is(U,j,ee)}this.compile=function(U,j,ee=null){ee===null&&(ee=U),_=xe.get(ee),_.init(),R.push(_),ee.traverseVisible(function(J){J.isLight&&J.layers.test(j.layers)&&(_.pushLight(J),J.castShadow&&_.pushShadow(J))}),U!==ee&&U.traverseVisible(function(J){J.isLight&&J.layers.test(j.layers)&&(_.pushLight(J),J.castShadow&&_.pushShadow(J))}),_.setupLights(b._useLegacyLights);const ne=new Set;return U.traverse(function(J){const Ae=J.material;if(Ae)if(Array.isArray(Ae))for(let Be=0;Be<Ae.length;Be++){const Ge=Ae[Be];zt(Ge,ee,J),ne.add(Ge)}else zt(Ae,ee,J),ne.add(Ae)}),R.pop(),_=null,ne},this.compileAsync=function(U,j,ee=null){const ne=this.compile(U,j,ee);return new Promise(J=>{function Ae(){if(ne.forEach(function(Be){z.get(Be).currentProgram.isReady()&&ne.delete(Be)}),ne.size===0){J(U);return}setTimeout(Ae,10)}Fe.get("KHR_parallel_shader_compile")!==null?Ae():setTimeout(Ae,10)})};let ln=null;function Rt(U){ln&&ln(U)}function Zt(){Fn.stop()}function Jt(){Fn.start()}const Fn=new x0;Fn.setAnimationLoop(Rt),typeof self<"u"&&Fn.setContext(self),this.setAnimationLoop=function(U){ln=U,T.setAnimationLoop(U),U===null?Fn.stop():Fn.start()},T.addEventListener("sessionstart",Zt),T.addEventListener("sessionend",Jt),this.render=function(U,j){if(j!==void 0&&j.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(A===!0)return;U.matrixWorldAutoUpdate===!0&&U.updateMatrixWorld(),j.parent===null&&j.matrixWorldAutoUpdate===!0&&j.updateMatrixWorld(),T.enabled===!0&&T.isPresenting===!0&&(T.cameraAutoUpdate===!0&&T.updateCamera(j),j=T.getCamera()),U.isScene===!0&&U.onBeforeRender(b,U,j,D),_=xe.get(U,R.length),_.init(),R.push(_),Ee.multiplyMatrices(j.projectionMatrix,j.matrixWorldInverse),Ze.setFromProjectionMatrix(Ee),fe=this.localClippingEnabled,te=we.init(this.clippingPlanes,fe),S=Xe.get(U,v.length),S.init(),v.push(S),bn(U,j,0,b.sortObjects),S.finish(),b.sortObjects===!0&&S.sort(K,ae),this.info.render.frame++,te===!0&&we.beginShadows();const ee=_.state.shadowsArray;if(Ke.render(ee,U,j),te===!0&&we.endShadows(),this.info.autoReset===!0&&this.info.reset(),(T.enabled===!1||T.isPresenting===!1||T.hasDepthSensing()===!1)&&Le.render(S,U),_.setupLights(b._useLegacyLights),j.isArrayCamera){const ne=j.cameras;for(let J=0,Ae=ne.length;J<Ae;J++){const Be=ne[J];ki(S,U,Be,Be.viewport)}}else ki(S,U,j);D!==null&&(P.updateMultisampleRenderTarget(D),P.updateRenderTargetMipmap(D)),U.isScene===!0&&U.onAfterRender(b,U,j),_t.resetDefaultState(),C=-1,E=null,R.pop(),R.length>0?_=R[R.length-1]:_=null,v.pop(),v.length>0?S=v[v.length-1]:S=null};function bn(U,j,ee,ne){if(U.visible===!1)return;if(U.layers.test(j.layers)){if(U.isGroup)ee=U.renderOrder;else if(U.isLOD)U.autoUpdate===!0&&U.update(j);else if(U.isLight)_.pushLight(U),U.castShadow&&_.pushShadow(U);else if(U.isSprite){if(!U.frustumCulled||Ze.intersectsSprite(U)){ne&&ze.setFromMatrixPosition(U.matrixWorld).applyMatrix4(Ee);const Be=He.update(U),Ge=U.material;Ge.visible&&S.push(U,Be,Ge,ee,ze.z,null)}}else if((U.isMesh||U.isLine||U.isPoints)&&(!U.frustumCulled||Ze.intersectsObject(U))){const Be=He.update(U),Ge=U.material;if(ne&&(U.boundingSphere!==void 0?(U.boundingSphere===null&&U.computeBoundingSphere(),ze.copy(U.boundingSphere.center)):(Be.boundingSphere===null&&Be.computeBoundingSphere(),ze.copy(Be.boundingSphere.center)),ze.applyMatrix4(U.matrixWorld).applyMatrix4(Ee)),Array.isArray(Ge)){const Je=Be.groups;for(let et=0,tt=Je.length;et<tt;et++){const rt=Je[et],qt=Ge[rt.materialIndex];qt&&qt.visible&&S.push(U,Be,qt,ee,ze.z,rt)}}else Ge.visible&&S.push(U,Be,Ge,ee,ze.z,null)}}const Ae=U.children;for(let Be=0,Ge=Ae.length;Be<Ge;Be++)bn(Ae[Be],j,ee,ne)}function ki(U,j,ee,ne){const J=U.opaque,Ae=U.transmissive,Be=U.transparent;_.setupLightsView(ee),te===!0&&we.setGlobalState(b.clippingPlanes,ee),Ae.length>0&&Hi(J,Ae,j,ee),ne&&We.viewport(M.copy(ne)),J.length>0&&ar(J,j,ee),Ae.length>0&&ar(Ae,j,ee),Be.length>0&&ar(Be,j,ee),We.buffers.depth.setTest(!0),We.buffers.depth.setMask(!0),We.buffers.color.setMask(!0),We.setPolygonOffset(!1)}function Hi(U,j,ee,ne){if((ee.isScene===!0?ee.overrideMaterial:null)!==null)return;if(_.state.transmissionRenderTarget===null){_.state.transmissionRenderTarget=new Rs(1,1,{generateMipmaps:!0,type:Fe.has("EXT_color_buffer_half_float")||Fe.has("EXT_color_buffer_float")?bl:Qr,minFilter:Ki,samples:4,stencilBuffer:o});const et=z.get(_.state.transmissionRenderTarget);et.__isTransmissionRenderTarget=!0}const Ae=_.state.transmissionRenderTarget;b.getDrawingBufferSize(Me),Ae.setSize(Me.x,Me.y);const Be=b.getRenderTarget();b.setRenderTarget(Ae),b.getClearColor(G),Y=b.getClearAlpha(),Y<1&&b.setClearColor(16777215,.5),b.clear();const Ge=b.toneMapping;b.toneMapping=Ar,ar(U,ee,ne),P.updateMultisampleRenderTarget(Ae),P.updateRenderTargetMipmap(Ae);let Je=!1;for(let et=0,tt=j.length;et<tt;et++){const rt=j[et],qt=rt.object,wn=rt.geometry,nn=rt.material,ui=rt.group;if(nn.side===si&&qt.layers.test(ne.layers)){const Gt=nn.side;nn.side=Kn,nn.needsUpdate=!0,Ya(qt,ee,ne,wn,nn,ui),nn.side=Gt,nn.needsUpdate=!0,Je=!0}}Je===!0&&(P.updateMultisampleRenderTarget(Ae),P.updateRenderTargetMipmap(Ae)),b.setRenderTarget(Be),b.setClearColor(G,Y),b.toneMapping=Ge}function ar(U,j,ee){const ne=j.isScene===!0?j.overrideMaterial:null;for(let J=0,Ae=U.length;J<Ae;J++){const Be=U[J],Ge=Be.object,Je=Be.geometry,et=ne===null?Be.material:ne,tt=Be.group;Ge.layers.test(ee.layers)&&Ya(Ge,j,ee,Je,et,tt)}}function Ya(U,j,ee,ne,J,Ae){U.onBeforeRender(b,j,ee,ne,J,Ae),U.modelViewMatrix.multiplyMatrices(ee.matrixWorldInverse,U.matrixWorld),U.normalMatrix.getNormalMatrix(U.modelViewMatrix),J.onBeforeRender(b,j,ee,ne,U,Ae),J.transparent===!0&&J.side===si&&J.forceSinglePass===!1?(J.side=Kn,J.needsUpdate=!0,b.renderBufferDirect(ee,j,ne,J,U,Ae),J.side=tr,J.needsUpdate=!0,b.renderBufferDirect(ee,j,ne,J,U,Ae),J.side=si):b.renderBufferDirect(ee,j,ne,J,U,Ae),U.onAfterRender(b,j,ee,ne,J,Ae)}function Is(U,j,ee){j.isScene!==!0&&(j=Ve);const ne=z.get(U),J=_.state.lights,Ae=_.state.shadowsArray,Be=J.state.version,Ge=_e.getParameters(U,J.state,Ae,j,ee),Je=_e.getProgramCacheKey(Ge);let et=ne.programs;ne.environment=U.isMeshStandardMaterial?j.environment:null,ne.fog=j.fog,ne.envMap=(U.isMeshStandardMaterial?le:ie).get(U.envMap||ne.environment),ne.envMapRotation=ne.environment!==null&&U.envMap===null?j.environmentRotation:U.envMapRotation,et===void 0&&(U.addEventListener("dispose",Re),et=new Map,ne.programs=et);let tt=et.get(Je);if(tt!==void 0){if(ne.currentProgram===tt&&ne.lightsStateVersion===Be)return qa(U,Ge),tt}else Ge.uniforms=_e.getUniforms(U),U.onBuild(ee,Ge,b),U.onBeforeCompile(Ge,b),tt=_e.acquireProgram(Ge,Je),et.set(Je,tt),ne.uniforms=Ge.uniforms;const rt=ne.uniforms;return(!U.isShaderMaterial&&!U.isRawShaderMaterial||U.clipping===!0)&&(rt.clippingPlanes=we.uniform),qa(U,Ge),ne.needsLights=ql(U),ne.lightsStateVersion=Be,ne.needsLights&&(rt.ambientLightColor.value=J.state.ambient,rt.lightProbe.value=J.state.probe,rt.directionalLights.value=J.state.directional,rt.directionalLightShadows.value=J.state.directionalShadow,rt.spotLights.value=J.state.spot,rt.spotLightShadows.value=J.state.spotShadow,rt.rectAreaLights.value=J.state.rectArea,rt.ltc_1.value=J.state.rectAreaLTC1,rt.ltc_2.value=J.state.rectAreaLTC2,rt.pointLights.value=J.state.point,rt.pointLightShadows.value=J.state.pointShadow,rt.hemisphereLights.value=J.state.hemi,rt.directionalShadowMap.value=J.state.directionalShadowMap,rt.directionalShadowMatrix.value=J.state.directionalShadowMatrix,rt.spotShadowMap.value=J.state.spotShadowMap,rt.spotLightMatrix.value=J.state.spotLightMatrix,rt.spotLightMap.value=J.state.spotLightMap,rt.pointShadowMap.value=J.state.pointShadowMap,rt.pointShadowMatrix.value=J.state.pointShadowMatrix),ne.currentProgram=tt,ne.uniformsList=null,tt}function ja(U){if(U.uniformsList===null){const j=U.currentProgram.getUniforms();U.uniformsList=xl.seqWithValue(j.seq,U.uniforms)}return U.uniformsList}function qa(U,j){const ee=z.get(U);ee.outputColorSpace=j.outputColorSpace,ee.batching=j.batching,ee.instancing=j.instancing,ee.instancingColor=j.instancingColor,ee.instancingMorph=j.instancingMorph,ee.skinning=j.skinning,ee.morphTargets=j.morphTargets,ee.morphNormals=j.morphNormals,ee.morphColors=j.morphColors,ee.morphTargetsCount=j.morphTargetsCount,ee.numClippingPlanes=j.numClippingPlanes,ee.numIntersection=j.numClipIntersection,ee.vertexAlphas=j.vertexAlphas,ee.vertexTangents=j.vertexTangents,ee.toneMapping=j.toneMapping}function Yl(U,j,ee,ne,J){j.isScene!==!0&&(j=Ve),P.resetTextureUnits();const Ae=j.fog,Be=ne.isMeshStandardMaterial?j.environment:null,Ge=D===null?b.outputColorSpace:D.isXRRenderTarget===!0?D.texture.colorSpace:Tn,Je=(ne.isMeshStandardMaterial?le:ie).get(ne.envMap||Be),et=ne.vertexColors===!0&&!!ee.attributes.color&&ee.attributes.color.itemSize===4,tt=!!ee.attributes.tangent&&(!!ne.normalMap||ne.anisotropy>0),rt=!!ee.morphAttributes.position,qt=!!ee.morphAttributes.normal,wn=!!ee.morphAttributes.color;let nn=Ar;ne.toneMapped&&(D===null||D.isXRRenderTarget===!0)&&(nn=b.toneMapping);const ui=ee.morphAttributes.position||ee.morphAttributes.normal||ee.morphAttributes.color,Gt=ui!==void 0?ui.length:0,ot=z.get(ne),Vo=_.state.lights;if(te===!0&&(fe===!0||U!==E)){const Bn=U===E&&ne.id===C;we.setState(ne,U,Bn)}let kt=!1;ne.version===ot.__version?(ot.needsLights&&ot.lightsStateVersion!==Vo.state.version||ot.outputColorSpace!==Ge||J.isBatchedMesh&&ot.batching===!1||!J.isBatchedMesh&&ot.batching===!0||J.isInstancedMesh&&ot.instancing===!1||!J.isInstancedMesh&&ot.instancing===!0||J.isSkinnedMesh&&ot.skinning===!1||!J.isSkinnedMesh&&ot.skinning===!0||J.isInstancedMesh&&ot.instancingColor===!0&&J.instanceColor===null||J.isInstancedMesh&&ot.instancingColor===!1&&J.instanceColor!==null||J.isInstancedMesh&&ot.instancingMorph===!0&&J.morphTexture===null||J.isInstancedMesh&&ot.instancingMorph===!1&&J.morphTexture!==null||ot.envMap!==Je||ne.fog===!0&&ot.fog!==Ae||ot.numClippingPlanes!==void 0&&(ot.numClippingPlanes!==we.numPlanes||ot.numIntersection!==we.numIntersection)||ot.vertexAlphas!==et||ot.vertexTangents!==tt||ot.morphTargets!==rt||ot.morphNormals!==qt||ot.morphColors!==wn||ot.toneMapping!==nn||ot.morphTargetsCount!==Gt)&&(kt=!0):(kt=!0,ot.__version=ne.version);let Gi=ot.currentProgram;kt===!0&&(Gi=Is(ne,j,J));let Wo=!1,Cr=!1,is=!1;const mn=Gi.getUniforms(),bi=ot.uniforms;if(We.useProgram(Gi.program)&&(Wo=!0,Cr=!0,is=!0),ne.id!==C&&(C=ne.id,Cr=!0),Wo||E!==U){mn.setValue(q,"projectionMatrix",U.projectionMatrix),mn.setValue(q,"viewMatrix",U.matrixWorldInverse);const Bn=mn.map.cameraPosition;Bn!==void 0&&Bn.setValue(q,ze.setFromMatrixPosition(U.matrixWorld)),mt.logarithmicDepthBuffer&&mn.setValue(q,"logDepthBufFC",2/(Math.log(U.far+1)/Math.LN2)),(ne.isMeshPhongMaterial||ne.isMeshToonMaterial||ne.isMeshLambertMaterial||ne.isMeshBasicMaterial||ne.isMeshStandardMaterial||ne.isShaderMaterial)&&mn.setValue(q,"isOrthographic",U.isOrthographicCamera===!0),E!==U&&(E=U,Cr=!0,is=!0)}if(J.isSkinnedMesh){mn.setOptional(q,J,"bindMatrix"),mn.setOptional(q,J,"bindMatrixInverse");const Bn=J.skeleton;Bn&&(Bn.boneTexture===null&&Bn.computeBoneTexture(),mn.setValue(q,"boneTexture",Bn.boneTexture,P))}J.isBatchedMesh&&(mn.setOptional(q,J,"batchingTexture"),mn.setValue(q,"batchingTexture",J._matricesTexture,P));const Pr=ee.morphAttributes;if((Pr.position!==void 0||Pr.normal!==void 0||Pr.color!==void 0)&&Ie.update(J,ee,Gi),(Cr||ot.receiveShadow!==J.receiveShadow)&&(ot.receiveShadow=J.receiveShadow,mn.setValue(q,"receiveShadow",J.receiveShadow)),ne.isMeshGouraudMaterial&&ne.envMap!==null&&(bi.envMap.value=Je,bi.flipEnvMap.value=Je.isCubeTexture&&Je.isRenderTargetTexture===!1?-1:1),ne.isMeshStandardMaterial&&ne.envMap===null&&j.environment!==null&&(bi.envMapIntensity.value=j.environmentIntensity),Cr&&(mn.setValue(q,"toneMappingExposure",b.toneMappingExposure),ot.needsLights&&jl(bi,is),Ae&&ne.fog===!0&&De.refreshFogUniforms(bi,Ae),De.refreshMaterialUniforms(bi,ne,se,re,_.state.transmissionRenderTarget),xl.upload(q,ja(ot),bi,P)),ne.isShaderMaterial&&ne.uniformsNeedUpdate===!0&&(xl.upload(q,ja(ot),bi,P),ne.uniformsNeedUpdate=!1),ne.isSpriteMaterial&&mn.setValue(q,"center",J.center),mn.setValue(q,"modelViewMatrix",J.modelViewMatrix),mn.setValue(q,"normalMatrix",J.normalMatrix),mn.setValue(q,"modelMatrix",J.matrixWorld),ne.isShaderMaterial||ne.isRawShaderMaterial){const Bn=ne.uniformsGroups;for(let Xo=0,$a=Bn.length;Xo<$a;Xo++){const Yo=Bn[Xo];Tt.update(Yo,Gi),Tt.bind(Yo,Gi)}}return Gi}function jl(U,j){U.ambientLightColor.needsUpdate=j,U.lightProbe.needsUpdate=j,U.directionalLights.needsUpdate=j,U.directionalLightShadows.needsUpdate=j,U.pointLights.needsUpdate=j,U.pointLightShadows.needsUpdate=j,U.spotLights.needsUpdate=j,U.spotLightShadows.needsUpdate=j,U.rectAreaLights.needsUpdate=j,U.hemisphereLights.needsUpdate=j}function ql(U){return U.isMeshLambertMaterial||U.isMeshToonMaterial||U.isMeshPhongMaterial||U.isMeshStandardMaterial||U.isShadowMaterial||U.isShaderMaterial&&U.lights===!0}this.getActiveCubeFace=function(){return B},this.getActiveMipmapLevel=function(){return N},this.getRenderTarget=function(){return D},this.setRenderTargetTextures=function(U,j,ee){z.get(U.texture).__webglTexture=j,z.get(U.depthTexture).__webglTexture=ee;const ne=z.get(U);ne.__hasExternalTextures=!0,ne.__autoAllocateDepthBuffer=ee===void 0,ne.__autoAllocateDepthBuffer||Fe.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),ne.__useRenderToTexture=!1)},this.setRenderTargetFramebuffer=function(U,j){const ee=z.get(U);ee.__webglFramebuffer=j,ee.__useDefaultFramebuffer=j===void 0},this.setRenderTarget=function(U,j=0,ee=0){D=U,B=j,N=ee;let ne=!0,J=null,Ae=!1,Be=!1;if(U){const Je=z.get(U);Je.__useDefaultFramebuffer!==void 0?(We.bindFramebuffer(q.FRAMEBUFFER,null),ne=!1):Je.__webglFramebuffer===void 0?P.setupRenderTarget(U):Je.__hasExternalTextures&&P.rebindTextures(U,z.get(U.texture).__webglTexture,z.get(U.depthTexture).__webglTexture);const et=U.texture;(et.isData3DTexture||et.isDataArrayTexture||et.isCompressedArrayTexture)&&(Be=!0);const tt=z.get(U).__webglFramebuffer;U.isWebGLCubeRenderTarget?(Array.isArray(tt[j])?J=tt[j][ee]:J=tt[j],Ae=!0):U.samples>0&&P.useMultisampledRTT(U)===!1?J=z.get(U).__webglMultisampledFramebuffer:Array.isArray(tt)?J=tt[ee]:J=tt,M.copy(U.viewport),O.copy(U.scissor),H=U.scissorTest}else M.copy(pe).multiplyScalar(se).floor(),O.copy(ve).multiplyScalar(se).floor(),H=ke;if(We.bindFramebuffer(q.FRAMEBUFFER,J)&&ne&&We.drawBuffers(U,J),We.viewport(M),We.scissor(O),We.setScissorTest(H),Ae){const Je=z.get(U.texture);q.framebufferTexture2D(q.FRAMEBUFFER,q.COLOR_ATTACHMENT0,q.TEXTURE_CUBE_MAP_POSITIVE_X+j,Je.__webglTexture,ee)}else if(Be){const Je=z.get(U.texture),et=j||0;q.framebufferTextureLayer(q.FRAMEBUFFER,q.COLOR_ATTACHMENT0,Je.__webglTexture,ee||0,et)}C=-1},this.readRenderTargetPixels=function(U,j,ee,ne,J,Ae,Be){if(!(U&&U.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Ge=z.get(U).__webglFramebuffer;if(U.isWebGLCubeRenderTarget&&Be!==void 0&&(Ge=Ge[Be]),Ge){We.bindFramebuffer(q.FRAMEBUFFER,Ge);try{const Je=U.texture,et=Je.format,tt=Je.type;if(et!==Ei&&Et.convert(et)!==q.getParameter(q.IMPLEMENTATION_COLOR_READ_FORMAT)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}const rt=tt===bl&&(Fe.has("EXT_color_buffer_half_float")||Fe.has("EXT_color_buffer_float"));if(tt!==Qr&&Et.convert(tt)!==q.getParameter(q.IMPLEMENTATION_COLOR_READ_TYPE)&&tt!==Zi&&!rt){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}j>=0&&j<=U.width-ne&&ee>=0&&ee<=U.height-J&&q.readPixels(j,ee,ne,J,Et.convert(et),Et.convert(tt),Ae)}finally{const Je=D!==null?z.get(D).__webglFramebuffer:null;We.bindFramebuffer(q.FRAMEBUFFER,Je)}}},this.copyFramebufferToTexture=function(U,j,ee=0){const ne=Math.pow(2,-ee),J=Math.floor(j.image.width*ne),Ae=Math.floor(j.image.height*ne);P.setTexture2D(j,0),q.copyTexSubImage2D(q.TEXTURE_2D,ee,0,0,U.x,U.y,J,Ae),We.unbindTexture()},this.copyTextureToTexture=function(U,j,ee,ne=0){const J=j.image.width,Ae=j.image.height,Be=Et.convert(ee.format),Ge=Et.convert(ee.type);P.setTexture2D(ee,0),q.pixelStorei(q.UNPACK_FLIP_Y_WEBGL,ee.flipY),q.pixelStorei(q.UNPACK_PREMULTIPLY_ALPHA_WEBGL,ee.premultiplyAlpha),q.pixelStorei(q.UNPACK_ALIGNMENT,ee.unpackAlignment),j.isDataTexture?q.texSubImage2D(q.TEXTURE_2D,ne,U.x,U.y,J,Ae,Be,Ge,j.image.data):j.isCompressedTexture?q.compressedTexSubImage2D(q.TEXTURE_2D,ne,U.x,U.y,j.mipmaps[0].width,j.mipmaps[0].height,Be,j.mipmaps[0].data):q.texSubImage2D(q.TEXTURE_2D,ne,U.x,U.y,Be,Ge,j.image),ne===0&&ee.generateMipmaps&&q.generateMipmap(q.TEXTURE_2D),We.unbindTexture()},this.copyTextureToTexture3D=function(U,j,ee,ne,J=0){const Ae=Math.round(U.max.x-U.min.x),Be=Math.round(U.max.y-U.min.y),Ge=U.max.z-U.min.z+1,Je=Et.convert(ne.format),et=Et.convert(ne.type);let tt;if(ne.isData3DTexture)P.setTexture3D(ne,0),tt=q.TEXTURE_3D;else if(ne.isDataArrayTexture||ne.isCompressedArrayTexture)P.setTexture2DArray(ne,0),tt=q.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}q.pixelStorei(q.UNPACK_FLIP_Y_WEBGL,ne.flipY),q.pixelStorei(q.UNPACK_PREMULTIPLY_ALPHA_WEBGL,ne.premultiplyAlpha),q.pixelStorei(q.UNPACK_ALIGNMENT,ne.unpackAlignment);const rt=q.getParameter(q.UNPACK_ROW_LENGTH),qt=q.getParameter(q.UNPACK_IMAGE_HEIGHT),wn=q.getParameter(q.UNPACK_SKIP_PIXELS),nn=q.getParameter(q.UNPACK_SKIP_ROWS),ui=q.getParameter(q.UNPACK_SKIP_IMAGES),Gt=ee.isCompressedTexture?ee.mipmaps[J]:ee.image;q.pixelStorei(q.UNPACK_ROW_LENGTH,Gt.width),q.pixelStorei(q.UNPACK_IMAGE_HEIGHT,Gt.height),q.pixelStorei(q.UNPACK_SKIP_PIXELS,U.min.x),q.pixelStorei(q.UNPACK_SKIP_ROWS,U.min.y),q.pixelStorei(q.UNPACK_SKIP_IMAGES,U.min.z),ee.isDataTexture||ee.isData3DTexture?q.texSubImage3D(tt,J,j.x,j.y,j.z,Ae,Be,Ge,Je,et,Gt.data):ne.isCompressedArrayTexture?q.compressedTexSubImage3D(tt,J,j.x,j.y,j.z,Ae,Be,Ge,Je,Gt.data):q.texSubImage3D(tt,J,j.x,j.y,j.z,Ae,Be,Ge,Je,et,Gt),q.pixelStorei(q.UNPACK_ROW_LENGTH,rt),q.pixelStorei(q.UNPACK_IMAGE_HEIGHT,qt),q.pixelStorei(q.UNPACK_SKIP_PIXELS,wn),q.pixelStorei(q.UNPACK_SKIP_ROWS,nn),q.pixelStorei(q.UNPACK_SKIP_IMAGES,ui),J===0&&ne.generateMipmaps&&q.generateMipmap(tt),We.unbindTexture()},this.initTexture=function(U){U.isCubeTexture?P.setTextureCube(U,0):U.isData3DTexture?P.setTexture3D(U,0):U.isDataArrayTexture||U.isCompressedArrayTexture?P.setTexture2DArray(U,0):P.setTexture2D(U,0),We.unbindTexture()},this.resetState=function(){B=0,N=0,D=null,We.reset(),_t.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return br}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=e===Of?"display-p3":"srgb",t.unpackColorSpace=Lt.workingColorSpace===zl?"display-p3":"srgb"}get useLegacyLights(){return console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights}set useLegacyLights(e){console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights=e}}class Pl extends gt{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new Bi,this.environmentIntensity=1,this.environmentRotation=new Bi,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}}class A0{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=uf,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.version=0,this.uuid=Fi()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}get updateRange(){return u0("THREE.InterleavedBuffer: updateRange() is deprecated and will be removed in r169. Use addUpdateRange() instead."),this._updateRange}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}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,n){e*=this.stride,n*=t.stride;for(let r=0,o=this.stride;r<o;r++)this.array[e+r]=t.array[n+r];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Fi()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(t,this.stride);return n.setUsage(this.usage),n}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Fi()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}const Gn=new F;class ka{constructor(e,t,n,r=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=n,this.normalized=r}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,n=this.data.count;t<n;t++)Gn.fromBufferAttribute(this,t),Gn.applyMatrix4(e),this.setXYZ(t,Gn.x,Gn.y,Gn.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)Gn.fromBufferAttribute(this,t),Gn.applyNormalMatrix(e),this.setXYZ(t,Gn.x,Gn.y,Gn.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)Gn.fromBufferAttribute(this,t),Gn.transformDirection(e),this.setXYZ(t,Gn.x,Gn.y,Gn.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(n=Ni(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=Dt(n,this.array)),this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){return this.normalized&&(t=Dt(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=Dt(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=Dt(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=Dt(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=Ni(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=Ni(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=Ni(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=Ni(t,this.array)),t}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=Dt(t,this.array),n=Dt(n,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=Dt(t,this.array),n=Dt(n,this.array),r=Dt(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=r,this}setXYZW(e,t,n,r,o){return e=e*this.data.stride+this.offset,this.normalized&&(t=Dt(t,this.array),n=Dt(n,this.array),r=Dt(r,this.array),o=Dt(o,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=r,this.data.array[e+3]=o,this}clone(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let n=0;n<this.count;n++){const r=n*this.data.stride+this.offset;for(let o=0;o<this.itemSize;o++)t.push(this.data.array[r+o])}return new Nt(new this.array.constructor(t),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new ka(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let n=0;n<this.count;n++){const r=n*this.data.stride+this.offset;for(let o=0;o<this.itemSize;o++)t.push(this.data.array[r+o])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}class R0 extends Ti{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new Oe(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!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.fog=e.fog,this}}let fo;const fa=new F,po=new F,mo=new F,go=new Pe,da=new Pe,C0=new Qe,nl=new F,pa=new F,il=new F,Vg=new Pe,Nh=new Pe,Wg=new Pe;class LP extends gt{constructor(e=new R0){if(super(),this.isSprite=!0,this.type="Sprite",fo===void 0){fo=new tn;const t=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),n=new A0(t,5);fo.setIndex([0,1,2,0,2,3]),fo.setAttribute("position",new ka(n,3,0,!1)),fo.setAttribute("uv",new ka(n,2,3,!1))}this.geometry=fo,this.material=e,this.center=new Pe(.5,.5)}raycast(e,t){e.camera===null&&console.error('THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),po.setFromMatrixScale(this.matrixWorld),C0.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),mo.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&po.multiplyScalar(-mo.z);const n=this.material.rotation;let r,o;n!==0&&(o=Math.cos(n),r=Math.sin(n));const a=this.center;rl(nl.set(-.5,-.5,0),mo,a,po,r,o),rl(pa.set(.5,-.5,0),mo,a,po,r,o),rl(il.set(.5,.5,0),mo,a,po,r,o),Vg.set(0,0),Nh.set(1,0),Wg.set(1,1);let l=e.ray.intersectTriangle(nl,pa,il,!1,fa);if(l===null&&(rl(pa.set(-.5,.5,0),mo,a,po,r,o),Nh.set(0,1),l=e.ray.intersectTriangle(nl,il,pa,!1,fa),l===null))return;const u=e.ray.origin.distanceTo(fa);u<e.near||u>e.far||t.push({distance:u,point:fa.clone(),uv:Oi.getInterpolation(fa,nl,pa,il,Vg,Nh,Wg,new Pe),face:null,object:this})}copy(e,t){return super.copy(e,t),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}}function rl(i,e,t,n,r,o){go.subVectors(i,t).addScalar(.5).multiply(n),r!==void 0?(da.x=o*go.x-r*go.y,da.y=r*go.x+o*go.y):da.copy(go),i.copy(e),i.x+=da.x,i.y+=da.y,i.applyMatrix4(C0)}const Xg=new F,Yg=new Ut,jg=new Ut,IP=new F,qg=new Qe,sl=new F,Oh=new rr,$g=new Qe,Fh=new Oo;class DP extends Se{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=Tm,this.bindMatrix=new Qe,this.bindMatrixInverse=new Qe,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const e=this.geometry;this.boundingBox===null&&(this.boundingBox=new zi),this.boundingBox.makeEmpty();const t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,sl),this.boundingBox.expandByPoint(sl)}computeBoundingSphere(){const e=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new rr),this.boundingSphere.makeEmpty();const t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,sl),this.boundingSphere.expandByPoint(sl)}copy(e,t){return super.copy(e,t),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}raycast(e,t){const n=this.material,r=this.matrixWorld;n!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),Oh.copy(this.boundingSphere),Oh.applyMatrix4(r),e.ray.intersectsSphere(Oh)!==!1&&($g.copy(r).invert(),Fh.copy(e.ray).applyMatrix4($g),!(this.boundingBox!==null&&Fh.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(e,t,Fh)))}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){this.skeleton=e,t===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){const e=new Ut,t=this.geometry.attributes.skinWeight;for(let n=0,r=t.count;n<r;n++){e.fromBufferAttribute(t,n);const o=1/e.manhattanLength();o!==1/0?e.multiplyScalar(o):e.set(1,0,0,0),t.setXYZW(n,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode===Tm?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===kb?this.bindMatrixInverse.copy(this.bindMatrix).invert():console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){const n=this.skeleton,r=this.geometry;Yg.fromBufferAttribute(r.attributes.skinIndex,e),jg.fromBufferAttribute(r.attributes.skinWeight,e),Xg.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let o=0;o<4;o++){const a=jg.getComponent(o);if(a!==0){const l=Yg.getComponent(o);qg.multiplyMatrices(n.bones[l].matrixWorld,n.boneInverses[l]),t.addScaledVector(IP.copy(Xg).applyMatrix4(qg),a)}}return t.applyMatrix4(this.bindMatrixInverse)}}class P0 extends gt{constructor(){super(),this.isBone=!0,this.type="Bone"}}class L0 extends cn{constructor(e=null,t=1,n=1,r,o,a,l,u,h=Nn,d=Nn,p,m){super(null,a,l,u,h,d,r,o,p,m),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const Kg=new Qe,UP=new Qe;class Gf{constructor(e=[],t=[]){this.uuid=Fi(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){const e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let n=0,r=this.bones.length;n<r;n++)this.boneInverses.push(new Qe)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){const n=new Qe;this.bones[e]&&n.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(n)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){const n=this.bones[e];n&&n.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){const n=this.bones[e];n&&(n.parent&&n.parent.isBone?(n.matrix.copy(n.parent.matrixWorld).invert(),n.matrix.multiply(n.matrixWorld)):n.matrix.copy(n.matrixWorld),n.matrix.decompose(n.position,n.quaternion,n.scale))}}update(){const e=this.bones,t=this.boneInverses,n=this.boneMatrices,r=this.boneTexture;for(let o=0,a=e.length;o<a;o++){const l=e[o]?e[o].matrixWorld:UP;Kg.multiplyMatrices(l,t[o]),Kg.toArray(n,o*16)}r!==null&&(r.needsUpdate=!0)}clone(){return new Gf(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);const t=new Float32Array(e*e*4);t.set(this.boneMatrices);const n=new L0(t,e,e,Ei,Zi);return n.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=n,this}getBoneByName(e){for(let t=0,n=this.bones.length;t<n;t++){const r=this.bones[t];if(r.name===e)return r}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let n=0,r=e.bones.length;n<r;n++){const o=e.bones[n];let a=t[o];a===void 0&&(console.warn("THREE.Skeleton: No bone found with UUID:",o),a=new P0),this.bones.push(a),this.boneInverses.push(new Qe().fromArray(e.boneInverses[n]))}return this.init(),this}toJSON(){const e={metadata:{version:4.6,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;const t=this.bones,n=this.boneInverses;for(let r=0,o=t.length;r<o;r++){const a=t[r];e.bones.push(a.uuid);const l=n[r];e.boneInverses.push(l.toArray())}return e}}class ff extends Nt{constructor(e,t,n,r=1){super(e,t,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=r}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}}const _o=new Qe,Zg=new Qe,ol=[],Jg=new zi,NP=new Qe,ma=new Se,ga=new rr;class OP extends Se{constructor(e,t,n){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new ff(new Float32Array(n*16),16),this.instanceColor=null,this.morphTexture=null,this.count=n,this.boundingBox=null,this.boundingSphere=null;for(let r=0;r<n;r++)this.setMatrixAt(r,NP)}computeBoundingBox(){const e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new zi),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,_o),Jg.copy(e.boundingBox).applyMatrix4(_o),this.boundingBox.union(Jg)}computeBoundingSphere(){const e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new rr),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,_o),ga.copy(e.boundingSphere).applyMatrix4(_o),this.boundingSphere.union(ga)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.morphTexture!==null&&(this.morphTexture=e.morphTexture.clone()),e.instanceColor!==null&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}getColorAt(e,t){t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){t.fromArray(this.instanceMatrix.array,e*16)}getMorphAt(e,t){const n=t.morphTargetInfluences,r=this.morphTexture.source.data.data,o=n.length+1,a=e*o+1;for(let l=0;l<n.length;l++)n[l]=r[a+l]}raycast(e,t){const n=this.matrixWorld,r=this.count;if(ma.geometry=this.geometry,ma.material=this.material,ma.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),ga.copy(this.boundingSphere),ga.applyMatrix4(n),e.ray.intersectsSphere(ga)!==!1))for(let o=0;o<r;o++){this.getMatrixAt(o,_o),Zg.multiplyMatrices(n,_o),ma.matrixWorld=Zg,ma.raycast(e,ol);for(let a=0,l=ol.length;a<l;a++){const u=ol[a];u.instanceId=o,u.object=this,t.push(u)}ol.length=0}}setColorAt(e,t){this.instanceColor===null&&(this.instanceColor=new ff(new Float32Array(this.instanceMatrix.count*3),3)),t.toArray(this.instanceColor.array,e*3)}setMatrixAt(e,t){t.toArray(this.instanceMatrix.array,e*16)}setMorphAt(e,t){const n=t.morphTargetInfluences,r=n.length+1;this.morphTexture===null&&(this.morphTexture=new L0(new Float32Array(r*this.count),r,this.count,t0,Zi));const o=this.morphTexture.source.data.data;let a=0;for(let h=0;h<n.length;h++)a+=n[h];const l=this.geometry.morphTargetsRelative?1:1-a,u=r*e;o[u]=l,o.set(n,u+1)}updateMorphTargets(){}dispose(){return this.dispatchEvent({type:"dispose"}),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null),this}}class Bo extends Ti{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Oe(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}const Qg=new F,e_=new F,t_=new Qe,Bh=new Oo,al=new rr;class Si extends gt{constructor(e=new tn,t=new Bo){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,n=[0];for(let r=1,o=t.count;r<o;r++)Qg.fromBufferAttribute(t,r-1),e_.fromBufferAttribute(t,r),n[r]=n[r-1],n[r]+=Qg.distanceTo(e_);e.setAttribute("lineDistance",new Bt(n,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){const n=this.geometry,r=this.matrixWorld,o=e.params.Line.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),al.copy(n.boundingSphere),al.applyMatrix4(r),al.radius+=o,e.ray.intersectsSphere(al)===!1)return;t_.copy(r).invert(),Bh.copy(e.ray).applyMatrix4(t_);const l=o/((this.scale.x+this.scale.y+this.scale.z)/3),u=l*l,h=new F,d=new F,p=new F,m=new F,g=this.isLineSegments?2:1,y=n.index,_=n.attributes.position;if(y!==null){const v=Math.max(0,a.start),R=Math.min(y.count,a.start+a.count);for(let b=v,A=R-1;b<A;b+=g){const B=y.getX(b),N=y.getX(b+1);if(h.fromBufferAttribute(_,B),d.fromBufferAttribute(_,N),Bh.distanceSqToSegment(h,d,m,p)>u)continue;m.applyMatrix4(this.matrixWorld);const C=e.ray.origin.distanceTo(m);C<e.near||C>e.far||t.push({distance:C,point:p.clone().applyMatrix4(this.matrixWorld),index:b,face:null,faceIndex:null,object:this})}}else{const v=Math.max(0,a.start),R=Math.min(_.count,a.start+a.count);for(let b=v,A=R-1;b<A;b+=g){if(h.fromBufferAttribute(_,b),d.fromBufferAttribute(_,b+1),Bh.distanceSqToSegment(h,d,m,p)>u)continue;m.applyMatrix4(this.matrixWorld);const N=e.ray.origin.distanceTo(m);N<e.near||N>e.far||t.push({distance:N,point:p.clone().applyMatrix4(this.matrixWorld),index:b,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const r=t[n[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let o=0,a=r.length;o<a;o++){const l=r[o].name||String(o);this.morphTargetInfluences.push(0),this.morphTargetDictionary[l]=o}}}}}const n_=new F,i_=new F;class Vf extends Si{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,n=[];for(let r=0,o=t.count;r<o;r+=2)n_.fromBufferAttribute(t,r),i_.fromBufferAttribute(t,r+1),n[r]=r===0?0:n[r-1],n[r+1]=n[r]+n_.distanceTo(i_);e.setAttribute("lineDistance",new Bt(n,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class FP extends Si{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}}class I0 extends Ti{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new Oe(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!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.fog=e.fog,this}}const r_=new Qe,df=new Oo,cl=new rr,ll=new F;class BP extends gt{constructor(e=new tn,t=new I0){super(),this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}raycast(e,t){const n=this.geometry,r=this.matrixWorld,o=e.params.Points.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),cl.copy(n.boundingSphere),cl.applyMatrix4(r),cl.radius+=o,e.ray.intersectsSphere(cl)===!1)return;r_.copy(r).invert(),df.copy(e.ray).applyMatrix4(r_);const l=o/((this.scale.x+this.scale.y+this.scale.z)/3),u=l*l,h=n.index,p=n.attributes.position;if(h!==null){const m=Math.max(0,a.start),g=Math.min(h.count,a.start+a.count);for(let y=m,S=g;y<S;y++){const _=h.getX(y);ll.fromBufferAttribute(p,_),s_(ll,_,u,r,e,t,this)}}else{const m=Math.max(0,a.start),g=Math.min(p.count,a.start+a.count);for(let y=m,S=g;y<S;y++)ll.fromBufferAttribute(p,y),s_(ll,y,u,r,e,t,this)}}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const r=t[n[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let o=0,a=r.length;o<a;o++){const l=r[o].name||String(o);this.morphTargetInfluences.push(0),this.morphTargetDictionary[l]=o}}}}}function s_(i,e,t,n,r,o,a){const l=df.distanceSqToPoint(i);if(l<t){const u=new F;df.closestPointToPoint(i,u),u.applyMatrix4(n);const h=r.ray.origin.distanceTo(u);if(h<r.near||h>r.far)return;o.push({distance:h,distanceToRay:Math.sqrt(l),point:u,index:e,face:null,object:a})}}class zh extends cn{constructor(e,t,n,r,o,a,l,u,h,d,p,m){super(null,a,l,u,h,d,r,o,p,m),this.isCompressedTexture=!0,this.image={width:t,height:n},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}}class zP extends cn{constructor(e,t,n,r,o,a,l,u,h){super(e,t,n,r,o,a,l,u,h),this.isCanvasTexture=!0,this.needsUpdate=!0}}class vn extends tn{constructor(e=1,t=1,n=1,r=32,o=1,a=!1,l=0,u=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:n,radialSegments:r,heightSegments:o,openEnded:a,thetaStart:l,thetaLength:u};const h=this;r=Math.floor(r),o=Math.floor(o);const d=[],p=[],m=[],g=[];let y=0;const S=[],_=n/2;let v=0;R(),a===!1&&(e>0&&b(!0),t>0&&b(!1)),this.setIndex(d),this.setAttribute("position",new Bt(p,3)),this.setAttribute("normal",new Bt(m,3)),this.setAttribute("uv",new Bt(g,2));function R(){const A=new F,B=new F;let N=0;const D=(t-e)/n;for(let C=0;C<=o;C++){const E=[],M=C/o,O=M*(t-e)+e;for(let H=0;H<=r;H++){const G=H/r,Y=G*u+l,$=Math.sin(Y),re=Math.cos(Y);B.x=O*$,B.y=-M*n+_,B.z=O*re,p.push(B.x,B.y,B.z),A.set($,D,re).normalize(),m.push(A.x,A.y,A.z),g.push(G,1-M),E.push(y++)}S.push(E)}for(let C=0;C<r;C++)for(let E=0;E<o;E++){const M=S[E][C],O=S[E+1][C],H=S[E+1][C+1],G=S[E][C+1];d.push(M,O,G),d.push(O,H,G),N+=6}h.addGroup(v,N,0),v+=N}function b(A){const B=y,N=new Pe,D=new F;let C=0;const E=A===!0?e:t,M=A===!0?1:-1;for(let H=1;H<=r;H++)p.push(0,_*M,0),m.push(0,M,0),g.push(.5,.5),y++;const O=y;for(let H=0;H<=r;H++){const Y=H/r*u+l,$=Math.cos(Y),re=Math.sin(Y);D.x=E*re,D.y=_*M,D.z=E*$,p.push(D.x,D.y,D.z),m.push(0,M,0),N.x=$*.5+.5,N.y=re*.5*M+.5,g.push(N.x,N.y),y++}for(let H=0;H<r;H++){const G=B+H,Y=O+H;A===!0?d.push(Y,Y+1,G):d.push(Y+1,Y,G),C+=3}h.addGroup(v,C,A===!0?1:2),v+=C}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new vn(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class Wf extends vn{constructor(e=1,t=1,n=32,r=1,o=!1,a=0,l=Math.PI*2){super(0,e,t,n,r,o,a,l),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:n,heightSegments:r,openEnded:o,thetaStart:a,thetaLength:l}}static fromJSON(e){return new Wf(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class Xf extends tn{constructor(e=[],t=[],n=1,r=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:n,detail:r};const o=[],a=[];l(r),h(n),d(),this.setAttribute("position",new Bt(o,3)),this.setAttribute("normal",new Bt(o.slice(),3)),this.setAttribute("uv",new Bt(a,2)),r===0?this.computeVertexNormals():this.normalizeNormals();function l(R){const b=new F,A=new F,B=new F;for(let N=0;N<t.length;N+=3)g(t[N+0],b),g(t[N+1],A),g(t[N+2],B),u(b,A,B,R)}function u(R,b,A,B){const N=B+1,D=[];for(let C=0;C<=N;C++){D[C]=[];const E=R.clone().lerp(A,C/N),M=b.clone().lerp(A,C/N),O=N-C;for(let H=0;H<=O;H++)H===0&&C===N?D[C][H]=E:D[C][H]=E.clone().lerp(M,H/O)}for(let C=0;C<N;C++)for(let E=0;E<2*(N-C)-1;E++){const M=Math.floor(E/2);E%2===0?(m(D[C][M+1]),m(D[C+1][M]),m(D[C][M])):(m(D[C][M+1]),m(D[C+1][M+1]),m(D[C+1][M]))}}function h(R){const b=new F;for(let A=0;A<o.length;A+=3)b.x=o[A+0],b.y=o[A+1],b.z=o[A+2],b.normalize().multiplyScalar(R),o[A+0]=b.x,o[A+1]=b.y,o[A+2]=b.z}function d(){const R=new F;for(let b=0;b<o.length;b+=3){R.x=o[b+0],R.y=o[b+1],R.z=o[b+2];const A=_(R)/2/Math.PI+.5,B=v(R)/Math.PI+.5;a.push(A,1-B)}y(),p()}function p(){for(let R=0;R<a.length;R+=6){const b=a[R+0],A=a[R+2],B=a[R+4],N=Math.max(b,A,B),D=Math.min(b,A,B);N>.9&&D<.1&&(b<.2&&(a[R+0]+=1),A<.2&&(a[R+2]+=1),B<.2&&(a[R+4]+=1))}}function m(R){o.push(R.x,R.y,R.z)}function g(R,b){const A=R*3;b.x=e[A+0],b.y=e[A+1],b.z=e[A+2]}function y(){const R=new F,b=new F,A=new F,B=new F,N=new Pe,D=new Pe,C=new Pe;for(let E=0,M=0;E<o.length;E+=9,M+=6){R.set(o[E+0],o[E+1],o[E+2]),b.set(o[E+3],o[E+4],o[E+5]),A.set(o[E+6],o[E+7],o[E+8]),N.set(a[M+0],a[M+1]),D.set(a[M+2],a[M+3]),C.set(a[M+4],a[M+5]),B.copy(R).add(b).add(A).divideScalar(3);const O=_(B);S(N,M+0,R,O),S(D,M+2,b,O),S(C,M+4,A,O)}}function S(R,b,A,B){B<0&&R.x===1&&(a[b]=R.x-1),A.x===0&&A.z===0&&(a[b]=B/2/Math.PI+.5)}function _(R){return Math.atan2(R.z,-R.x)}function v(R){return Math.atan2(-R.y,Math.sqrt(R.x*R.x+R.z*R.z))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Xf(e.vertices,e.indices,e.radius,e.details)}}class So extends Xf{constructor(e=1,t=0){const n=[1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],r=[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2];super(n,r,e,t),this.type="OctahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new So(e.radius,e.detail)}}class Va extends tn{constructor(e=1,t=32,n=16,r=0,o=Math.PI*2,a=0,l=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:n,phiStart:r,phiLength:o,thetaStart:a,thetaLength:l},t=Math.max(3,Math.floor(t)),n=Math.max(2,Math.floor(n));const u=Math.min(a+l,Math.PI);let h=0;const d=[],p=new F,m=new F,g=[],y=[],S=[],_=[];for(let v=0;v<=n;v++){const R=[],b=v/n;let A=0;v===0&&a===0?A=.5/t:v===n&&u===Math.PI&&(A=-.5/t);for(let B=0;B<=t;B++){const N=B/t;p.x=-e*Math.cos(r+N*o)*Math.sin(a+b*l),p.y=e*Math.cos(a+b*l),p.z=e*Math.sin(r+N*o)*Math.sin(a+b*l),y.push(p.x,p.y,p.z),m.copy(p).normalize(),S.push(m.x,m.y,m.z),_.push(N+A,1-b),R.push(h++)}d.push(R)}for(let v=0;v<n;v++)for(let R=0;R<t;R++){const b=d[v][R+1],A=d[v][R],B=d[v+1][R],N=d[v+1][R+1];(v!==0||a>0)&&g.push(b,A,N),(v!==n-1||u<Math.PI)&&g.push(A,B,N)}this.setIndex(g),this.setAttribute("position",new Bt(y,3)),this.setAttribute("normal",new Bt(S,3)),this.setAttribute("uv",new Bt(_,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Va(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}class ws extends tn{constructor(e=1,t=.4,n=12,r=48,o=Math.PI*2){super(),this.type="TorusGeometry",this.parameters={radius:e,tube:t,radialSegments:n,tubularSegments:r,arc:o},n=Math.floor(n),r=Math.floor(r);const a=[],l=[],u=[],h=[],d=new F,p=new F,m=new F;for(let g=0;g<=n;g++)for(let y=0;y<=r;y++){const S=y/r*o,_=g/n*Math.PI*2;p.x=(e+t*Math.cos(_))*Math.cos(S),p.y=(e+t*Math.cos(_))*Math.sin(S),p.z=t*Math.sin(_),l.push(p.x,p.y,p.z),d.x=e*Math.cos(S),d.y=e*Math.sin(S),m.subVectors(p,d).normalize(),u.push(m.x,m.y,m.z),h.push(y/r),h.push(g/n)}for(let g=1;g<=n;g++)for(let y=1;y<=r;y++){const S=(r+1)*g+y-1,_=(r+1)*(g-1)+y-1,v=(r+1)*(g-1)+y,R=(r+1)*g+y;a.push(S,_,R),a.push(_,v,R)}this.setIndex(a),this.setAttribute("position",new Bt(l,3)),this.setAttribute("normal",new Bt(u,3)),this.setAttribute("uv",new Bt(h,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new ws(e.radius,e.tube,e.radialSegments,e.tubularSegments,e.arc)}}class kP extends Ti{constructor(e){super(),this.isShadowMaterial=!0,this.type="ShadowMaterial",this.color=new Oe(0),this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.fog=e.fog,this}}class zo extends Ti{constructor(e){super(),this.isMeshStandardMaterial=!0,this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new Oe(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 Oe(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=a0,this.normalScale=new Pe(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Bi,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,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.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class sr extends zo{constructor(e){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new Pe(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return En(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+.4*t)/(1-.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new Oe(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new Oe(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new Oe(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){this._anisotropy>0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=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.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,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.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,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}}class HP extends Bo{constructor(e){super(),this.isLineDashedMaterial=!0,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}}function ul(i,e,t){return!i||!t&&i.constructor===e?i:typeof e.BYTES_PER_ELEMENT=="number"?new e(i):Array.prototype.slice.call(i)}function GP(i){return ArrayBuffer.isView(i)&&!(i instanceof DataView)}function VP(i){function e(r,o){return i[r]-i[o]}const t=i.length,n=new Array(t);for(let r=0;r!==t;++r)n[r]=r;return n.sort(e),n}function o_(i,e,t){const n=i.length,r=new i.constructor(n);for(let o=0,a=0;a!==n;++o){const l=t[o]*e;for(let u=0;u!==e;++u)r[a++]=i[l+u]}return r}function D0(i,e,t,n){let r=1,o=i[0];for(;o!==void 0&&o[n]===void 0;)o=i[r++];if(o===void 0)return;let a=o[n];if(a!==void 0)if(Array.isArray(a))do a=o[n],a!==void 0&&(e.push(o.time),t.push.apply(t,a)),o=i[r++];while(o!==void 0);else if(a.toArray!==void 0)do a=o[n],a!==void 0&&(e.push(o.time),a.toArray(t,t.length)),o=i[r++];while(o!==void 0);else do a=o[n],a!==void 0&&(e.push(o.time),t.push(a)),o=i[r++];while(o!==void 0)}class Wa{constructor(e,t,n,r){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=r!==void 0?r:new t.constructor(n),this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){const t=this.parameterPositions;let n=this._cachedIndex,r=t[n],o=t[n-1];e:{t:{let a;n:{i:if(!(e<r)){for(let l=n+2;;){if(r===void 0){if(e<o)break i;return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===l)break;if(o=r,r=t[++n],e<r)break t}a=t.length;break n}if(!(e>=o)){const l=t[1];e<l&&(n=2,o=l);for(let u=n-2;;){if(o===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===u)break;if(r=o,o=t[--n-1],e>=o)break t}a=n,n=0;break n}break e}for(;n<a;){const l=n+a>>>1;e<t[l]?a=l:n=l+1}if(r=t[n],o=t[n-1],o===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(r===void 0)return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,o,r)}return this.interpolate_(n,o,e,r)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,r=this.valueSize,o=e*r;for(let a=0;a!==r;++a)t[a]=n[o+a];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}}class WP extends Wa{constructor(e,t,n,r){super(e,t,n,r),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:Km,endingEnd:Km}}intervalChanged_(e,t,n){const r=this.parameterPositions;let o=e-2,a=e+1,l=r[o],u=r[a];if(l===void 0)switch(this.getSettings_().endingStart){case Zm:o=e,l=2*t-n;break;case Jm:o=r.length-2,l=t+r[o]-r[o+1];break;default:o=e,l=n}if(u===void 0)switch(this.getSettings_().endingEnd){case Zm:a=e,u=2*n-t;break;case Jm:a=1,u=n+r[1]-r[0];break;default:a=e-1,u=t}const h=(n-t)*.5,d=this.valueSize;this._weightPrev=h/(t-l),this._weightNext=h/(u-n),this._offsetPrev=o*d,this._offsetNext=a*d}interpolate_(e,t,n,r){const o=this.resultBuffer,a=this.sampleValues,l=this.valueSize,u=e*l,h=u-l,d=this._offsetPrev,p=this._offsetNext,m=this._weightPrev,g=this._weightNext,y=(n-t)/(r-t),S=y*y,_=S*y,v=-m*_+2*m*S-m*y,R=(1+m)*_+(-1.5-2*m)*S+(-.5+m)*y+1,b=(-1-g)*_+(1.5+g)*S+.5*y,A=g*_-g*S;for(let B=0;B!==l;++B)o[B]=v*a[d+B]+R*a[h+B]+b*a[u+B]+A*a[p+B];return o}}class XP extends Wa{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e,t,n,r){const o=this.resultBuffer,a=this.sampleValues,l=this.valueSize,u=e*l,h=u-l,d=(n-t)/(r-t),p=1-d;for(let m=0;m!==l;++m)o[m]=a[h+m]*p+a[u+m]*d;return o}}class YP extends Wa{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e){return this.copySampleValue_(e-1)}}class or{constructor(e,t,n,r){if(e===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=ul(t,this.TimeBufferType),this.values=ul(n,this.ValueBufferType),this.setInterpolation(r||this.DefaultInterpolation)}static toJSON(e){const t=e.constructor;let n;if(t.toJSON!==this.toJSON)n=t.toJSON(e);else{n={name:e.name,times:ul(e.times,Array),values:ul(e.values,Array)};const r=e.getInterpolation();r!==e.DefaultInterpolation&&(n.interpolation=r)}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new YP(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new XP(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new WP(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case Lo:t=this.InterpolantFactoryMethodDiscrete;break;case As:t=this.InterpolantFactoryMethodLinear;break;case lh:t=this.InterpolantFactoryMethodSmooth;break}if(t===void 0){const n="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(n);return console.warn("THREE.KeyframeTrack:",n),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return Lo;case this.InterpolantFactoryMethodLinear:return As;case this.InterpolantFactoryMethodSmooth:return lh}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){const t=this.times;for(let n=0,r=t.length;n!==r;++n)t[n]+=e}return this}scale(e){if(e!==1){const t=this.times;for(let n=0,r=t.length;n!==r;++n)t[n]*=e}return this}trim(e,t){const n=this.times,r=n.length;let o=0,a=r-1;for(;o!==r&&n[o]<e;)++o;for(;a!==-1&&n[a]>t;)--a;if(++a,o!==0||a!==r){o>=a&&(a=Math.max(a,1),o=a-1);const l=this.getValueSize();this.times=n.slice(o,a),this.values=this.values.slice(o*l,a*l)}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 n=this.times,r=this.values,o=n.length;o===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let a=null;for(let l=0;l!==o;l++){const u=n[l];if(typeof u=="number"&&isNaN(u)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,l,u),e=!1;break}if(a!==null&&a>u){console.error("THREE.KeyframeTrack: Out of order keys.",this,l,u,a),e=!1;break}a=u}if(r!==void 0&&GP(r))for(let l=0,u=r.length;l!==u;++l){const h=r[l];if(isNaN(h)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,l,h),e=!1;break}}return e}optimize(){const e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),r=this.getInterpolation()===lh,o=e.length-1;let a=1;for(let l=1;l<o;++l){let u=!1;const h=e[l],d=e[l+1];if(h!==d&&(l!==1||h!==e[0]))if(r)u=!0;else{const p=l*n,m=p-n,g=p+n;for(let y=0;y!==n;++y){const S=t[p+y];if(S!==t[m+y]||S!==t[g+y]){u=!0;break}}}if(u){if(l!==a){e[a]=e[l];const p=l*n,m=a*n;for(let g=0;g!==n;++g)t[m+g]=t[p+g]}++a}}if(o>0){e[a]=e[o];for(let l=o*n,u=a*n,h=0;h!==n;++h)t[u+h]=t[l+h];++a}return a!==e.length?(this.times=e.slice(0,a),this.values=t.slice(0,a*n)):(this.times=e,this.values=t),this}clone(){const e=this.times.slice(),t=this.values.slice(),n=this.constructor,r=new n(this.name,e,t);return r.createInterpolant=this.createInterpolant,r}}or.prototype.TimeBufferType=Float32Array;or.prototype.ValueBufferType=Float32Array;or.prototype.DefaultInterpolation=As;class ko extends or{}ko.prototype.ValueTypeName="bool";ko.prototype.ValueBufferType=Array;ko.prototype.DefaultInterpolation=Lo;ko.prototype.InterpolantFactoryMethodLinear=void 0;ko.prototype.InterpolantFactoryMethodSmooth=void 0;class U0 extends or{}U0.prototype.ValueTypeName="color";class Uo extends or{}Uo.prototype.ValueTypeName="number";class jP extends Wa{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e,t,n,r){const o=this.resultBuffer,a=this.sampleValues,l=this.valueSize,u=(n-t)/(r-t);let h=e*l;for(let d=h+l;h!==d;h+=4)an.slerpFlat(o,0,a,h-l,a,h,u);return o}}class Cs extends or{InterpolantFactoryMethodLinear(e){return new jP(this.times,this.values,this.getValueSize(),e)}}Cs.prototype.ValueTypeName="quaternion";Cs.prototype.DefaultInterpolation=As;Cs.prototype.InterpolantFactoryMethodSmooth=void 0;class Ho extends or{}Ho.prototype.ValueTypeName="string";Ho.prototype.ValueBufferType=Array;Ho.prototype.DefaultInterpolation=Lo;Ho.prototype.InterpolantFactoryMethodLinear=void 0;Ho.prototype.InterpolantFactoryMethodSmooth=void 0;class No extends or{}No.prototype.ValueTypeName="vector";class qP{constructor(e="",t=-1,n=[],r=Kb){this.name=e,this.tracks=n,this.duration=t,this.blendMode=r,this.uuid=Fi(),this.duration<0&&this.resetDuration()}static parse(e){const t=[],n=e.tracks,r=1/(e.fps||1);for(let a=0,l=n.length;a!==l;++a)t.push(KP(n[a]).scale(r));const o=new this(e.name,e.duration,t,e.blendMode);return o.uuid=e.uuid,o}static toJSON(e){const t=[],n=e.tracks,r={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let o=0,a=n.length;o!==a;++o)t.push(or.toJSON(n[o]));return r}static CreateFromMorphTargetSequence(e,t,n,r){const o=t.length,a=[];for(let l=0;l<o;l++){let u=[],h=[];u.push((l+o-1)%o,l,(l+1)%o),h.push(0,1,0);const d=VP(u);u=o_(u,1,d),h=o_(h,1,d),!r&&u[0]===0&&(u.push(o),h.push(h[0])),a.push(new Uo(".morphTargetInfluences["+t[l].name+"]",u,h).scale(1/n))}return new this(e,-1,a)}static findByName(e,t){let n=e;if(!Array.isArray(e)){const r=e;n=r.geometry&&r.geometry.animations||r.animations}for(let r=0;r<n.length;r++)if(n[r].name===t)return n[r];return null}static CreateClipsFromMorphTargetSequences(e,t,n){const r={},o=/^([\w-]*?)([\d]+)$/;for(let l=0,u=e.length;l<u;l++){const h=e[l],d=h.name.match(o);if(d&&d.length>1){const p=d[1];let m=r[p];m||(r[p]=m=[]),m.push(h)}}const a=[];for(const l in r)a.push(this.CreateFromMorphTargetSequence(l,r[l],t,n));return a}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const n=function(p,m,g,y,S){if(g.length!==0){const _=[],v=[];D0(g,_,v,y),_.length!==0&&S.push(new p(m,_,v))}},r=[],o=e.name||"default",a=e.fps||30,l=e.blendMode;let u=e.length||-1;const h=e.hierarchy||[];for(let p=0;p<h.length;p++){const m=h[p].keys;if(!(!m||m.length===0))if(m[0].morphTargets){const g={};let y;for(y=0;y<m.length;y++)if(m[y].morphTargets)for(let S=0;S<m[y].morphTargets.length;S++)g[m[y].morphTargets[S]]=-1;for(const S in g){const _=[],v=[];for(let R=0;R!==m[y].morphTargets.length;++R){const b=m[y];_.push(b.time),v.push(b.morphTarget===S?1:0)}r.push(new Uo(".morphTargetInfluence["+S+"]",_,v))}u=g.length*a}else{const g=".bones["+t[p].name+"]";n(No,g+".position",m,"pos",r),n(Cs,g+".quaternion",m,"rot",r),n(No,g+".scale",m,"scl",r)}}return r.length===0?null:new this(o,u,r,l)}resetDuration(){const e=this.tracks;let t=0;for(let n=0,r=e.length;n!==r;++n){const o=this.tracks[n];t=Math.max(t,o.times[o.times.length-1])}return this.duration=t,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 $P(i){switch(i.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return Uo;case"vector":case"vector2":case"vector3":case"vector4":return No;case"color":return U0;case"quaternion":return Cs;case"bool":case"boolean":return ko;case"string":return Ho}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+i)}function KP(i){if(i.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const e=$P(i.type);if(i.times===void 0){const t=[],n=[];D0(i.keys,t,n,"value"),i.times=t,i.values=n}return e.parse!==void 0?e.parse(i):new e(i.name,i.times,i.values,i.interpolation)}const Zr={enabled:!1,files:{},add:function(i,e){this.enabled!==!1&&(this.files[i]=e)},get:function(i){if(this.enabled!==!1)return this.files[i]},remove:function(i){delete this.files[i]},clear:function(){this.files={}}};class ZP{constructor(e,t,n){const r=this;let o=!1,a=0,l=0,u;const h=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this.itemStart=function(d){l++,o===!1&&r.onStart!==void 0&&r.onStart(d,a,l),o=!0},this.itemEnd=function(d){a++,r.onProgress!==void 0&&r.onProgress(d,a,l),a===l&&(o=!1,r.onLoad!==void 0&&r.onLoad())},this.itemError=function(d){r.onError!==void 0&&r.onError(d)},this.resolveURL=function(d){return u?u(d):d},this.setURLModifier=function(d){return u=d,this},this.addHandler=function(d,p){return h.push(d,p),this},this.removeHandler=function(d){const p=h.indexOf(d);return p!==-1&&h.splice(p,2),this},this.getHandler=function(d){for(let p=0,m=h.length;p<m;p+=2){const g=h[p],y=h[p+1];if(g.global&&(g.lastIndex=0),g.test(d))return y}return null}}}const JP=new ZP;let Ls=class{constructor(e){this.manager=e!==void 0?e:JP,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){const n=this;return new Promise(function(r,o){n.load(e,r,t,o)})}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}};Ls.DEFAULT_MATERIAL_NAME="__DEFAULT";const Sr={};class QP extends Error{constructor(e,t){super(e),this.response=t}}class Ll extends Ls{constructor(e){super(e)}load(e,t,n,r){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const o=Zr.get(e);if(o!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(o),this.manager.itemEnd(e)},0),o;if(Sr[e]!==void 0){Sr[e].push({onLoad:t,onProgress:n,onError:r});return}Sr[e]=[],Sr[e].push({onLoad:t,onProgress:n,onError:r});const a=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),l=this.mimeType,u=this.responseType;fetch(a).then(h=>{if(h.status===200||h.status===0){if(h.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||h.body===void 0||h.body.getReader===void 0)return h;const d=Sr[e],p=h.body.getReader(),m=h.headers.get("Content-Length")||h.headers.get("X-File-Size"),g=m?parseInt(m):0,y=g!==0;let S=0;const _=new ReadableStream({start(v){R();function R(){p.read().then(({done:b,value:A})=>{if(b)v.close();else{S+=A.byteLength;const B=new ProgressEvent("progress",{lengthComputable:y,loaded:S,total:g});for(let N=0,D=d.length;N<D;N++){const C=d[N];C.onProgress&&C.onProgress(B)}v.enqueue(A),R()}})}}});return new Response(_)}else throw new QP(`fetch for "${h.url}" responded with ${h.status}: ${h.statusText}`,h)}).then(h=>{switch(u){case"arraybuffer":return h.arrayBuffer();case"blob":return h.blob();case"document":return h.text().then(d=>new DOMParser().parseFromString(d,l));case"json":return h.json();default:if(l===void 0)return h.text();{const p=/charset="?([^;"\s]*)"?/i.exec(l),m=p&&p[1]?p[1].toLowerCase():void 0,g=new TextDecoder(m);return h.arrayBuffer().then(y=>g.decode(y))}}}).then(h=>{Zr.add(e,h);const d=Sr[e];delete Sr[e];for(let p=0,m=d.length;p<m;p++){const g=d[p];g.onLoad&&g.onLoad(h)}}).catch(h=>{const d=Sr[e];if(d===void 0)throw this.manager.itemError(e),h;delete Sr[e];for(let p=0,m=d.length;p<m;p++){const g=d[p];g.onError&&g.onError(h)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}}class eL extends Ls{constructor(e){super(e)}load(e,t,n,r){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const o=this,a=Zr.get(e);if(a!==void 0)return o.manager.itemStart(e),setTimeout(function(){t&&t(a),o.manager.itemEnd(e)},0),a;const l=za("img");function u(){d(),Zr.add(e,this),t&&t(this),o.manager.itemEnd(e)}function h(p){d(),r&&r(p),o.manager.itemError(e),o.manager.itemEnd(e)}function d(){l.removeEventListener("load",u,!1),l.removeEventListener("error",h,!1)}return l.addEventListener("load",u,!1),l.addEventListener("error",h,!1),e.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(l.crossOrigin=this.crossOrigin),o.manager.itemStart(e),l.src=e,l}}class N0 extends Ls{constructor(e){super(e)}load(e,t,n,r){const o=new cn,a=new eL(this.manager);return a.setCrossOrigin(this.crossOrigin),a.setPath(this.path),a.load(e,function(l){o.image=l,o.needsUpdate=!0,t!==void 0&&t(o)},n,r),o}}class Go extends gt{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new Oe(e),this.intensity=t}dispose(){}copy(e,t){return super.copy(e,t),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,this.groundColor!==void 0&&(t.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(t.object.distance=this.distance),this.angle!==void 0&&(t.object.angle=this.angle),this.decay!==void 0&&(t.object.decay=this.decay),this.penumbra!==void 0&&(t.object.penumbra=this.penumbra),this.shadow!==void 0&&(t.object.shadow=this.shadow.toJSON()),t}}class tL extends Go{constructor(e,t,n){super(e,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(gt.DEFAULT_UP),this.updateMatrix(),this.groundColor=new Oe(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}}const kh=new Qe,a_=new F,c_=new F;class Yf{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Pe(512,512),this.map=null,this.mapPass=null,this.matrix=new Qe,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new kf,this._frameExtents=new Pe(1,1),this._viewportCount=1,this._viewports=[new Ut(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,n=this.matrix;a_.setFromMatrixPosition(e.matrixWorld),t.position.copy(a_),c_.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(c_),t.updateMatrixWorld(),kh.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(kh),n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(kh)}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 this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}class nL extends Yf{constructor(){super(new Un(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){const t=this.camera,n=Io*2*e.angle*this.focus,r=this.mapSize.width/this.mapSize.height,o=e.distance||t.far;(n!==t.fov||r!==t.aspect||o!==t.far)&&(t.fov=n,t.aspect=r,t.far=o,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}class iL extends Go{constructor(e,t,n=0,r=Math.PI/3,o=0,a=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(gt.DEFAULT_UP),this.updateMatrix(),this.target=new gt,this.distance=n,this.angle=r,this.penumbra=o,this.decay=a,this.map=null,this.shadow=new nL}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),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}}const l_=new Qe,_a=new F,Hh=new F;class rL extends Yf{constructor(){super(new Un(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new Pe(4,2),this._viewportCount=6,this._viewports=[new Ut(2,1,1,1),new Ut(0,1,1,1),new Ut(3,1,1,1),new Ut(1,1,1,1),new Ut(3,0,1,1),new Ut(1,0,1,1)],this._cubeDirections=[new F(1,0,0),new F(-1,0,0),new F(0,0,1),new F(0,0,-1),new F(0,1,0),new F(0,-1,0)],this._cubeUps=[new F(0,1,0),new F(0,1,0),new F(0,1,0),new F(0,1,0),new F(0,0,1),new F(0,0,-1)]}updateMatrices(e,t=0){const n=this.camera,r=this.matrix,o=e.distance||n.far;o!==n.far&&(n.far=o,n.updateProjectionMatrix()),_a.setFromMatrixPosition(e.matrixWorld),n.position.copy(_a),Hh.copy(n.position),Hh.add(this._cubeDirections[t]),n.up.copy(this._cubeUps[t]),n.lookAt(Hh),n.updateMatrixWorld(),r.makeTranslation(-_a.x,-_a.y,-_a.z),l_.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(l_)}}class O0 extends Go{constructor(e,t,n=0,r=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=r,this.shadow=new rL}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}}class sL extends Yf{constructor(){super(new kl(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class jf extends Go{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(gt.DEFAULT_UP),this.updateMatrix(),this.target=new gt,this.shadow=new sL}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}class oL extends Go{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}}class aL{constructor(){this.isSphericalHarmonics3=!0,this.coefficients=[];for(let e=0;e<9;e++)this.coefficients.push(new F)}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 n=e.x,r=e.y,o=e.z,a=this.coefficients;return t.copy(a[0]).multiplyScalar(.282095),t.addScaledVector(a[1],.488603*r),t.addScaledVector(a[2],.488603*o),t.addScaledVector(a[3],.488603*n),t.addScaledVector(a[4],1.092548*(n*r)),t.addScaledVector(a[5],1.092548*(r*o)),t.addScaledVector(a[6],.315392*(3*o*o-1)),t.addScaledVector(a[7],1.092548*(n*o)),t.addScaledVector(a[8],.546274*(n*n-r*r)),t}getIrradianceAt(e,t){const n=e.x,r=e.y,o=e.z,a=this.coefficients;return t.copy(a[0]).multiplyScalar(.886227),t.addScaledVector(a[1],2*.511664*r),t.addScaledVector(a[2],2*.511664*o),t.addScaledVector(a[3],2*.511664*n),t.addScaledVector(a[4],2*.429043*n*r),t.addScaledVector(a[5],2*.429043*r*o),t.addScaledVector(a[6],.743125*o*o-.247708),t.addScaledVector(a[7],2*.429043*n*o),t.addScaledVector(a[8],.429043*(n*n-r*r)),t}add(e){for(let t=0;t<9;t++)this.coefficients[t].add(e.coefficients[t]);return this}addScaledSH(e,t){for(let n=0;n<9;n++)this.coefficients[n].addScaledVector(e.coefficients[n],t);return this}scale(e){for(let t=0;t<9;t++)this.coefficients[t].multiplyScalar(e);return this}lerp(e,t){for(let n=0;n<9;n++)this.coefficients[n].lerp(e.coefficients[n],t);return this}equals(e){for(let t=0;t<9;t++)if(!this.coefficients[t].equals(e.coefficients[t]))return!1;return!0}copy(e){return this.set(e.coefficients)}clone(){return new this.constructor().copy(this)}fromArray(e,t=0){const n=this.coefficients;for(let r=0;r<9;r++)n[r].fromArray(e,t+r*3);return this}toArray(e=[],t=0){const n=this.coefficients;for(let r=0;r<9;r++)n[r].toArray(e,t+r*3);return e}static getBasisAt(e,t){const n=e.x,r=e.y,o=e.z;t[0]=.282095,t[1]=.488603*r,t[2]=.488603*o,t[3]=.488603*n,t[4]=1.092548*n*r,t[5]=1.092548*r*o,t[6]=.315392*(3*o*o-1),t[7]=1.092548*n*o,t[8]=.546274*(n*n-r*r)}}class cL extends Go{constructor(e=new aL,t=1){super(void 0,t),this.isLightProbe=!0,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}}class Oa{static decodeText(e){if(typeof TextDecoder<"u")return new TextDecoder().decode(e);let t="";for(let n=0,r=e.length;n<r;n++)t+=String.fromCharCode(e[n]);try{return decodeURIComponent(escape(t))}catch{return t}}static extractUrlBase(e){const t=e.lastIndexOf("/");return t===-1?"./":e.slice(0,t+1)}static resolveURL(e,t){return typeof e!="string"||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)}}class lL extends Ls{constructor(e){super(e),this.isImageBitmapLoader=!0,typeof createImageBitmap>"u"&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(e){return this.options=e,this}load(e,t,n,r){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const o=this,a=Zr.get(e);if(a!==void 0){if(o.manager.itemStart(e),a.then){a.then(h=>{t&&t(h),o.manager.itemEnd(e)}).catch(h=>{r&&r(h)});return}return setTimeout(function(){t&&t(a),o.manager.itemEnd(e)},0),a}const l={};l.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",l.headers=this.requestHeader;const u=fetch(e,l).then(function(h){return h.blob()}).then(function(h){return createImageBitmap(h,Object.assign(o.options,{colorSpaceConversion:"none"}))}).then(function(h){return Zr.add(e,h),t&&t(h),o.manager.itemEnd(e),h}).catch(function(h){r&&r(h),Zr.remove(e),o.manager.itemError(e),o.manager.itemEnd(e)});Zr.add(e,u),o.manager.itemStart(e)}}const qf="\\[\\]\\.:\\/",uL=new RegExp("["+qf+"]","g"),$f="[^"+qf+"]",hL="[^"+qf.replace("\\.","")+"]",fL=/((?:WC+[\/:])*)/.source.replace("WC",$f),dL=/(WCOD+)?/.source.replace("WCOD",hL),pL=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",$f),mL=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",$f),gL=new RegExp("^"+fL+dL+pL+mL+"$"),_L=["material","materials","bones","map"];class vL{constructor(e,t,n){const r=n||wt.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,r)}getValue(e,t){this.bind();const n=this._targetGroup.nCachedObjects_,r=this._bindings[n];r!==void 0&&r.getValue(e,t)}setValue(e,t){const n=this._bindings;for(let r=this._targetGroup.nCachedObjects_,o=n.length;r!==o;++r)n[r].setValue(e,t)}bind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}}class wt{constructor(e,t,n){this.path=t,this.parsedPath=n||wt.parseTrackName(t),this.node=wt.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){return e&&e.isAnimationObjectGroup?new wt.Composite(e,t,n):new wt(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(uL,"")}static parseTrackName(e){const t=gL.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},r=n.nodeName&&n.nodeName.lastIndexOf(".");if(r!==void 0&&r!==-1){const o=n.nodeName.substring(r+1);_L.indexOf(o)!==-1&&(n.nodeName=n.nodeName.substring(0,r),n.objectName=o)}if(n.propertyName===null||n.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return n}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){const n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){const n=function(o){for(let a=0;a<o.length;a++){const l=o[a];if(l.name===t||l.uuid===t)return l;const u=n(l.children);if(u)return u}return null},r=n(e.children);if(r)return r}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){const n=this.resolvedProperty;for(let r=0,o=n.length;r!==o;++r)e[t++]=n[r]}_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 n=this.resolvedProperty;for(let r=0,o=n.length;r!==o;++r)n[r]=e[t++]}_setValue_array_setNeedsUpdate(e,t){const n=this.resolvedProperty;for(let r=0,o=n.length;r!==o;++r)n[r]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){const n=this.resolvedProperty;for(let r=0,o=n.length;r!==o;++r)n[r]=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,n=t.objectName,r=t.propertyName;let o=t.propertyIndex;if(e||(e=wt.findNode(this.rootNode,t.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){console.warn("THREE.PropertyBinding: No target node found for track: "+this.path+".");return}if(n){let h=t.objectIndex;switch(n){case"materials":if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let d=0;d<e.length;d++)if(e[d].name===h){h=d;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}e=e.material.map;break;default:if(e[n]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[n]}if(h!==void 0){if(e[h]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[h]}}const a=e[r];if(a===void 0){const h=t.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+h+"."+r+" but it wasn't found.",e);return}let l=this.Versioning.None;this.targetObject=e,e.needsUpdate!==void 0?l=this.Versioning.NeedsUpdate:e.matrixWorldNeedsUpdate!==void 0&&(l=this.Versioning.MatrixWorldNeedsUpdate);let u=this.BindingType.Direct;if(o!==void 0){if(r==="morphTargetInfluences"){if(!e.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[o]!==void 0&&(o=e.morphTargetDictionary[o])}u=this.BindingType.ArrayElement,this.resolvedProperty=a,this.propertyIndex=o}else a.fromArray!==void 0&&a.toArray!==void 0?(u=this.BindingType.HasFromToArray,this.resolvedProperty=a):Array.isArray(a)?(u=this.BindingType.EntireArray,this.resolvedProperty=a):this.propertyName=r;this.getValue=this.GetterByBindingType[u],this.setValue=this.SetterByBindingTypeAndVersioning[u][l]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}wt.Composite=vL;wt.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};wt.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};wt.prototype.GetterByBindingType=[wt.prototype._getValue_direct,wt.prototype._getValue_array,wt.prototype._getValue_arrayElement,wt.prototype._getValue_toArray];wt.prototype.SetterByBindingTypeAndVersioning=[[wt.prototype._setValue_direct,wt.prototype._setValue_direct_setNeedsUpdate,wt.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[wt.prototype._setValue_array,wt.prototype._setValue_array_setNeedsUpdate,wt.prototype._setValue_array_setMatrixWorldNeedsUpdate],[wt.prototype._setValue_arrayElement,wt.prototype._setValue_arrayElement_setNeedsUpdate,wt.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[wt.prototype._setValue_fromArray,wt.prototype._setValue_fromArray_setNeedsUpdate,wt.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class Kf{constructor(e){this.value=e}clone(){return new Kf(this.value.clone===void 0?this.value:this.value.clone())}}const u_=new Qe;class Gl{constructor(e,t,n=0,r=1/0){this.ray=new Oo(e,t),this.near=n,this.far=r,this.camera=null,this.layers=new zf,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,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.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)}setFromXRController(e){return u_.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(u_),this}intersectObject(e,t=!0,n=[]){return pf(e,this,n,t),n.sort(h_),n}intersectObjects(e,t=!0,n=[]){for(let r=0,o=e.length;r<o;r++)pf(e[r],this,n,t);return n.sort(h_),n}}function h_(i,e){return i.distance-e.distance}function pf(i,e,t,n){if(i.layers.test(e.layers)&&i.raycast(e,t),n===!0){const r=i.children;for(let o=0,a=r.length;o<a;o++)pf(r[o],e,t,!0)}}class f_{constructor(e=1,t=0,n=0){return this.radius=e,this.phi=t,this.theta=n,this}set(e,t,n){return this.radius=e,this.phi=t,this.theta=n,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=Math.max(1e-6,Math.min(Math.PI-1e-6,this.phi)),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,n){return this.radius=Math.sqrt(e*e+t*t+n*n),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,n),this.phi=Math.acos(En(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}class xL extends Vf{constructor(e=10,t=10,n=4473924,r=8947848){n=new Oe(n),r=new Oe(r);const o=t/2,a=e/t,l=e/2,u=[],h=[];for(let m=0,g=0,y=-l;m<=t;m++,y+=a){u.push(-l,0,y,l,0,y),u.push(y,0,-l,y,0,l);const S=m===o?n:r;S.toArray(h,g),g+=3,S.toArray(h,g),g+=3,S.toArray(h,g),g+=3,S.toArray(h,g),g+=3}const d=new tn;d.setAttribute("position",new Bt(u,3)),d.setAttribute("color",new Bt(h,3));const p=new Bo({vertexColors:!0,toneMapped:!1});super(d,p),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}class yL extends Vf{constructor(e=1){const t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],n=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],r=new tn;r.setAttribute("position",new Bt(t,3)),r.setAttribute("color",new Bt(n,3));const o=new Bo({vertexColors:!0,toneMapped:!1});super(r,o),this.type="AxesHelper"}setColors(e,t,n){const r=new Oe,o=this.geometry.attributes.color.array;return r.set(e),r.toArray(o,0),r.toArray(o,3),r.set(t),r.toArray(o,6),r.toArray(o,9),r.set(n),r.toArray(o,12),r.toArray(o,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:Uf}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Uf);const Ss={antialias:!0,alpha:!0,stencil:!1,shadowMapEnabled:!0,shadowMapType:q_,toneMapping:Ar,canvas:void 0};class d_ extends w0{paused=!1;running=!1;force=!1;preRenderCallbacks=new Map;postRenderCallbacks=new Map;constructor(e=Ss){super({antialias:e.antialias||Ss.antialias,alpha:e.alpha||Ss.alpha,preserveDrawingBuffer:!0,canvas:e.canvas}),this.setPixelRatio(window.devicePixelRatio),this.shadowMap.enabled=e.shadowMapEnabled||Ss.shadowMapEnabled,this.shadowMap.type=e.shadowMapType||Ss.shadowMapType,this.toneMapping=e.toneMapping||Ss.toneMapping,this.debug.checkShaderErrors=!1}Dispose(){this.StopRenderer(),this.dispose()}StartRenderer(e,t){this.setAnimationLoop((n,r)=>{this.internal_render(e,t,n,r)}),this.running=!0}PauseRenderer(){this.paused=!0}ResumeRenderer(){this.paused=!1}StopRenderer(){this.setAnimationLoop(null),this.running=!1}OnResize(e,t){this.setSize(e,t)}AddPreRenderCallback(e){const t=ci.generateUUID();return this.preRenderCallbacks.set(t,e),t}RemovePreRenderCallback(e){return this.preRenderCallbacks.has(e)?(this.preRenderCallbacks.delete(e),!0):!1}AddPostRenderCallback(e){const t=ci.generateUUID();return this.postRenderCallbacks.set(t,e),t}RemovePostRenderCallback(e){return this.postRenderCallbacks.has(e)?(this.postRenderCallbacks.delete(e),!0):!1}ForceRendering(){this.force=!0}internal_render(e,t,n,r){(this.paused||!this.running)&&!this.force||(this.preRenderCallbacks.forEach(o=>{o(n,r)}),this.render(e,t),this.postRenderCallbacks.forEach(o=>{o(n,r)}),this.force=!1)}}const ML=1,va=2,Zf=4,F0=8,li=16;class SL extends gt{isDIVELight=!0;isDIVEAmbientLight=!0;_light;constructor(){super(),this.name="DIVEAmbientLight",this._light=new oL(16777215,1),this._light.layers.mask=li,this.add(this._light)}SetColor(e){this._light.color=e}SetIntensity(e){this._light.intensity=e}SetEnabled(e){this._light.visible=e}}const Ln=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];function EL(){const i=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(Ln[i&255]+Ln[i>>8&255]+Ln[i>>16&255]+Ln[i>>24&255]+"-"+Ln[e&255]+Ln[e>>8&255]+"-"+Ln[e>>16&15|64]+Ln[e>>24&255]+"-"+Ln[t&63|128]+Ln[t>>8&255]+"-"+Ln[t>>16&255]+Ln[t>>24&255]+Ln[n&255]+Ln[n>>8&255]+Ln[n>>16&255]+Ln[n>>24&255]).toLowerCase()}function yl(i,e){return i?e in i:!1}function Il(i,e){if(i)return yl(i,e)?i:Il(i.parent,e)}class TL{POINTER_DRAG_THRESHOLD=.001;name;_canvas;_scene;_controller;_pointer;get _pointerAnyDown(){return this._pointerPrimaryDown||this._pointerMiddleDown||this._pointerSecondaryDown}_pointerPrimaryDown;_pointerMiddleDown;_pointerSecondaryDown;_lastPointerDown;_lastPointerUp;_raycaster;_intersects;_hovered;_dragging;_dragStart;_dragCurrent;_dragEnd;_dragDelta;_draggable;_dragRaycastOnObjects;constructor(e,t){this.name="BaseTool",this._canvas=t.domElement,this._scene=e,this._controller=t,this._pointer=new Pe,this._pointerPrimaryDown=!1,this._pointerMiddleDown=!1,this._pointerSecondaryDown=!1,this._lastPointerDown=new Pe,this._lastPointerUp=new Pe,this._raycaster=new Gl,this._raycaster.layers.mask=li|Zf,this._intersects=[],this._hovered=null,this._dragging=!1,this._dragStart=new F,this._dragCurrent=new F,this._dragEnd=new F,this._dragDelta=new F,this._draggable=null,this._dragRaycastOnObjects=null}Activate(){}Deactivate(){}onPointerDown(e){switch(e.button){case 0:{this._pointerPrimaryDown=!0;break}case 1:{this._pointerMiddleDown=!0;break}case 2:{this._pointerSecondaryDown=!0;break}default:console.warn("DIVEBaseTool.onPointerDown: Unknown button: "+e.button)}this._lastPointerDown.copy(this._pointer),this._draggable=Il(this._intersects[0]?.object,"isDraggable")||null}onDragStart(e){this._draggable&&(this._dragRaycastOnObjects!==null&&(this._intersects=this._raycaster.intersectObjects(this._dragRaycastOnObjects,!0)),this._intersects.length!==0&&(this._dragStart.copy(this._intersects[0].point.clone()),this._dragCurrent.copy(this._intersects[0].point.clone()),this._dragEnd.copy(this._dragStart.clone()),this._dragDelta.set(0,0,0),this._draggable&&this._draggable.onDragStart&&(this._draggable.onDragStart({dragStart:this._dragStart,dragCurrent:this._dragCurrent,dragEnd:this._dragEnd,dragDelta:this._dragDelta}),this._dragging=!0,this._controller.enabled=!1)))}onPointerMove(e){this._pointer.x=e.offsetX/this._canvas.clientWidth*2-1,this._pointer.y=-(e.offsetY/this._canvas.clientHeight)*2+1,this._raycaster.setFromCamera(this._pointer,this._controller.object),this._intersects=this.raycast(this._scene.children);const t=Il(this._intersects[0]?.object,"isHoverable");if(this._intersects[0]&&t){if(!this._hovered){t.onPointerEnter&&t.onPointerEnter(this._intersects[0]),this._hovered=t;return}if(this._hovered.uuid!==t.uuid){this._hovered.onPointerLeave&&this._hovered.onPointerLeave(),t.onPointerEnter&&t.onPointerEnter(this._intersects[0]),this._hovered=t;return}t.onPointerOver&&t.onPointerOver(this._intersects[0]),this._hovered=t}else this._hovered&&this._hovered.onPointerLeave&&this._hovered.onPointerLeave(),this._hovered=null;this._pointerAnyDown&&(this._dragging||this.onDragStart(e),this.onDrag(e))}onDrag(e){this._dragRaycastOnObjects!==null&&(this._intersects=this._raycaster.intersectObjects(this._dragRaycastOnObjects,!0));const t=this._intersects[0];t&&(this._dragCurrent.copy(t.point.clone()),this._dragEnd.copy(t.point.clone()),this._dragDelta.subVectors(this._dragCurrent.clone(),this._dragStart.clone()),this._draggable&&this._draggable.onDrag&&this._draggable.onDrag({dragStart:this._dragStart,dragCurrent:this._dragCurrent,dragEnd:this._dragEnd,dragDelta:this._dragDelta}))}onPointerUp(e){switch(this.pointerWasDragged()||this._dragging?this._draggable&&this.onDragEnd(e):this.onClick(e),e.button){case 0:this._pointerPrimaryDown=!1;break;case 1:this._pointerMiddleDown=!1;break;case 2:this._pointerSecondaryDown=!1;break}this._lastPointerUp.copy(this._pointer)}onClick(e){}onDragEnd(e){const t=this._intersects[0];t&&(this._dragEnd.copy(t.point.clone()),this._dragCurrent.copy(t.point.clone()),this._dragDelta.subVectors(this._dragCurrent.clone(),this._dragStart.clone())),this._draggable&&this._draggable.onDragEnd&&this._draggable.onDragEnd({dragStart:this._dragStart,dragCurrent:this._dragCurrent,dragEnd:this._dragEnd,dragDelta:this._dragDelta}),this._draggable=null,this._dragging=!1,this._dragStart.set(0,0,0),this._dragCurrent.set(0,0,0),this._dragEnd.set(0,0,0),this._dragDelta.set(0,0,0),this._controller.enabled=!0}onWheel(e){}raycast(e){return e!==void 0?this._raycaster.intersectObjects(e,!0).filter(t=>t.object.visible):this._raycaster.intersectObjects(this._scene.children,!0).filter(t=>t.object.visible)}pointerWasDragged(){return this._lastPointerDown.distanceTo(this._pointer)>this.POINTER_DRAG_THRESHOLD}}const xs=new Gl,In=new F,Yr=new F,jt=new an,p_={X:new F(1,0,0),Y:new F(0,1,0),Z:new F(0,0,1)},Gh={type:"change"},m_={type:"mouseDown"},g_={type:"mouseUp",mode:null},__={type:"objectChange"};class bL extends gt{constructor(e,t){super(),t===void 0&&(console.warn('THREE.TransformControls: The second parameter "domElement" is now mandatory.'),t=document),this.isTransformControls=!0,this.visible=!1,this.domElement=t,this.domElement.style.touchAction="none";const n=new LL;this._gizmo=n,this.add(n);const r=new IL;this._plane=r,this.add(r);const o=this;function a(R,b){let A=b;Object.defineProperty(o,R,{get:function(){return A!==void 0?A:b},set:function(B){A!==B&&(A=B,r[R]=B,n[R]=B,o.dispatchEvent({type:R+"-changed",value:B}),o.dispatchEvent(Gh))}}),o[R]=b,r[R]=b,n[R]=b}a("camera",e),a("object",void 0),a("enabled",!0),a("axis",null),a("mode","translate"),a("translationSnap",null),a("rotationSnap",null),a("scaleSnap",null),a("space","world"),a("size",1),a("dragging",!1),a("showX",!0),a("showY",!0),a("showZ",!0);const l=new F,u=new F,h=new an,d=new an,p=new F,m=new an,g=new F,y=new F,S=new F,_=0,v=new F;a("worldPosition",l),a("worldPositionStart",u),a("worldQuaternion",h),a("worldQuaternionStart",d),a("cameraPosition",p),a("cameraQuaternion",m),a("pointStart",g),a("pointEnd",y),a("rotationAxis",S),a("rotationAngle",_),a("eye",v),this._offset=new F,this._startNorm=new F,this._endNorm=new F,this._cameraScale=new F,this._parentPosition=new F,this._parentQuaternion=new an,this._parentQuaternionInv=new an,this._parentScale=new F,this._worldScaleStart=new F,this._worldQuaternionInv=new an,this._worldScale=new F,this._positionStart=new F,this._quaternionStart=new an,this._scaleStart=new F,this._getPointer=wL.bind(this),this._onPointerDown=RL.bind(this),this._onPointerHover=AL.bind(this),this._onPointerMove=CL.bind(this),this._onPointerUp=PL.bind(this),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointermove",this._onPointerHover),this.domElement.addEventListener("pointerup",this._onPointerUp)}updateMatrixWorld(e){this.object!==void 0&&(this.object.updateMatrixWorld(),this.object.parent===null?console.error("TransformControls: The attached 3D object must be a part of the scene graph."):this.object.parent.matrixWorld.decompose(this._parentPosition,this._parentQuaternion,this._parentScale),this.object.matrixWorld.decompose(this.worldPosition,this.worldQuaternion,this._worldScale),this._parentQuaternionInv.copy(this._parentQuaternion).invert(),this._worldQuaternionInv.copy(this.worldQuaternion).invert()),this.camera.updateMatrixWorld(),this.camera.matrixWorld.decompose(this.cameraPosition,this.cameraQuaternion,this._cameraScale),this.camera.isOrthographicCamera?this.camera.getWorldDirection(this.eye).negate():this.eye.copy(this.cameraPosition).sub(this.worldPosition).normalize(),super.updateMatrixWorld(e)}pointerHover(e){if(this.object===void 0||this.dragging===!0)return;e!==null&&xs.setFromCamera(e,this.camera);const t=Vh(this._gizmo.picker[this.mode],xs);t?this.axis=t.object.name:this.axis=null}pointerDown(e){if(!(this.object===void 0||this.dragging===!0||e!=null&&e.button!==0)&&this.axis!==null){e!==null&&xs.setFromCamera(e,this.camera);const t=Vh(this._plane,xs,!0);t&&(this.object.updateMatrixWorld(),this.object.parent.updateMatrixWorld(),this._positionStart.copy(this.object.position),this._quaternionStart.copy(this.object.quaternion),this._scaleStart.copy(this.object.scale),this.object.matrixWorld.decompose(this.worldPositionStart,this.worldQuaternionStart,this._worldScaleStart),this.pointStart.copy(t.point).sub(this.worldPositionStart)),this.dragging=!0,m_.mode=this.mode,this.dispatchEvent(m_)}}pointerMove(e){const t=this.axis,n=this.mode,r=this.object;let o=this.space;if(n==="scale"?o="local":(t==="E"||t==="XYZE"||t==="XYZ")&&(o="world"),r===void 0||t===null||this.dragging===!1||e!==null&&e.button!==-1)return;e!==null&&xs.setFromCamera(e,this.camera);const a=Vh(this._plane,xs,!0);if(a){if(this.pointEnd.copy(a.point).sub(this.worldPositionStart),n==="translate")this._offset.copy(this.pointEnd).sub(this.pointStart),o==="local"&&t!=="XYZ"&&this._offset.applyQuaternion(this._worldQuaternionInv),t.indexOf("X")===-1&&(this._offset.x=0),t.indexOf("Y")===-1&&(this._offset.y=0),t.indexOf("Z")===-1&&(this._offset.z=0),o==="local"&&t!=="XYZ"?this._offset.applyQuaternion(this._quaternionStart).divide(this._parentScale):this._offset.applyQuaternion(this._parentQuaternionInv).divide(this._parentScale),r.position.copy(this._offset).add(this._positionStart),this.translationSnap&&(o==="local"&&(r.position.applyQuaternion(jt.copy(this._quaternionStart).invert()),t.search("X")!==-1&&(r.position.x=Math.round(r.position.x/this.translationSnap)*this.translationSnap),t.search("Y")!==-1&&(r.position.y=Math.round(r.position.y/this.translationSnap)*this.translationSnap),t.search("Z")!==-1&&(r.position.z=Math.round(r.position.z/this.translationSnap)*this.translationSnap),r.position.applyQuaternion(this._quaternionStart)),o==="world"&&(r.parent&&r.position.add(In.setFromMatrixPosition(r.parent.matrixWorld)),t.search("X")!==-1&&(r.position.x=Math.round(r.position.x/this.translationSnap)*this.translationSnap),t.search("Y")!==-1&&(r.position.y=Math.round(r.position.y/this.translationSnap)*this.translationSnap),t.search("Z")!==-1&&(r.position.z=Math.round(r.position.z/this.translationSnap)*this.translationSnap),r.parent&&r.position.sub(In.setFromMatrixPosition(r.parent.matrixWorld))));else if(n==="scale"){if(t.search("XYZ")!==-1){let l=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(l*=-1),Yr.set(l,l,l)}else In.copy(this.pointStart),Yr.copy(this.pointEnd),In.applyQuaternion(this._worldQuaternionInv),Yr.applyQuaternion(this._worldQuaternionInv),Yr.divide(In),t.search("X")===-1&&(Yr.x=1),t.search("Y")===-1&&(Yr.y=1),t.search("Z")===-1&&(Yr.z=1);r.scale.copy(this._scaleStart).multiply(Yr),this.scaleSnap&&(t.search("X")!==-1&&(r.scale.x=Math.round(r.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap),t.search("Y")!==-1&&(r.scale.y=Math.round(r.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap),t.search("Z")!==-1&&(r.scale.z=Math.round(r.scale.z/this.scaleSnap)*this.scaleSnap||this.scaleSnap))}else if(n==="rotate"){this._offset.copy(this.pointEnd).sub(this.pointStart);const l=20/this.worldPosition.distanceTo(In.setFromMatrixPosition(this.camera.matrixWorld));let u=!1;t==="XYZE"?(this.rotationAxis.copy(this._offset).cross(this.eye).normalize(),this.rotationAngle=this._offset.dot(In.copy(this.rotationAxis).cross(this.eye))*l):(t==="X"||t==="Y"||t==="Z")&&(this.rotationAxis.copy(p_[t]),In.copy(p_[t]),o==="local"&&In.applyQuaternion(this.worldQuaternion),In.cross(this.eye),In.length()===0?u=!0:this.rotationAngle=this._offset.dot(In.normalize())*l),(t==="E"||u)&&(this.rotationAxis.copy(this.eye),this.rotationAngle=this.pointEnd.angleTo(this.pointStart),this._startNorm.copy(this.pointStart).normalize(),this._endNorm.copy(this.pointEnd).normalize(),this.rotationAngle*=this._endNorm.cross(this._startNorm).dot(this.eye)<0?1:-1),this.rotationSnap&&(this.rotationAngle=Math.round(this.rotationAngle/this.rotationSnap)*this.rotationSnap),o==="local"&&t!=="E"&&t!=="XYZE"?(r.quaternion.copy(this._quaternionStart),r.quaternion.multiply(jt.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this._parentQuaternionInv),r.quaternion.copy(jt.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),r.quaternion.multiply(this._quaternionStart).normalize())}this.dispatchEvent(Gh),this.dispatchEvent(__)}}pointerUp(e){e!==null&&e.button!==0||(this.dragging&&this.axis!==null&&(g_.mode=this.mode,this.dispatchEvent(g_)),this.dragging=!1,this.axis=null)}dispose(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerHover),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.traverse(function(e){e.geometry&&e.geometry.dispose(),e.material&&e.material.dispose()})}attach(e){return this.object=e,this.visible=!0,this}detach(){return this.object=void 0,this.visible=!1,this.axis=null,this}reset(){this.enabled&&this.dragging&&(this.object.position.copy(this._positionStart),this.object.quaternion.copy(this._quaternionStart),this.object.scale.copy(this._scaleStart),this.dispatchEvent(Gh),this.dispatchEvent(__),this.pointStart.copy(this.pointEnd))}getRaycaster(){return xs}getMode(){return this.mode}setMode(e){this.mode=e}setTranslationSnap(e){this.translationSnap=e}setRotationSnap(e){this.rotationSnap=e}setScaleSnap(e){this.scaleSnap=e}setSize(e){this.size=e}setSpace(e){this.space=e}}function wL(i){if(this.domElement.ownerDocument.pointerLockElement)return{x:0,y:0,button:i.button};{const e=this.domElement.getBoundingClientRect();return{x:(i.clientX-e.left)/e.width*2-1,y:-(i.clientY-e.top)/e.height*2+1,button:i.button}}}function AL(i){if(this.enabled)switch(i.pointerType){case"mouse":case"pen":this.pointerHover(this._getPointer(i));break}}function RL(i){this.enabled&&(document.pointerLockElement||this.domElement.setPointerCapture(i.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.pointerHover(this._getPointer(i)),this.pointerDown(this._getPointer(i)))}function CL(i){this.enabled&&this.pointerMove(this._getPointer(i))}function PL(i){this.enabled&&(this.domElement.releasePointerCapture(i.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.pointerUp(this._getPointer(i)))}function Vh(i,e,t){const n=e.intersectObject(i,!0);for(let r=0;r<n.length;r++)if(n[r].object.visible||t)return n[r];return!1}const hl=new Bi,Ft=new F(0,1,0),v_=new F(0,0,0),x_=new Qe,fl=new an,Ml=new an,Yi=new F,y_=new Qe,wa=new F(1,0,0),Es=new F(0,1,0),Aa=new F(0,0,1),dl=new F,xa=new F,ya=new F;class LL extends gt{constructor(){super(),this.isTransformControlsGizmo=!0,this.type="TransformControlsGizmo";const e=new Ji({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),t=new Bo({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),n=e.clone();n.opacity=.15;const r=t.clone();r.opacity=.5;const o=e.clone();o.color.setHex(16711680);const a=e.clone();a.color.setHex(65280);const l=e.clone();l.color.setHex(255);const u=e.clone();u.color.setHex(16711680),u.opacity=.5;const h=e.clone();h.color.setHex(65280),h.opacity=.5;const d=e.clone();d.color.setHex(255),d.opacity=.5;const p=e.clone();p.opacity=.25;const m=e.clone();m.color.setHex(16776960),m.opacity=.25,e.clone().color.setHex(16776960);const y=e.clone();y.color.setHex(7895160);const S=new vn(0,.04,.1,12);S.translate(0,.05,0);const _=new Kt(.08,.08,.08);_.translate(0,.04,0);const v=new tn;v.setAttribute("position",new Bt([0,0,0,1,0,0],3));const R=new vn(.0075,.0075,.5,3);R.translate(0,.25,0);function b($,re){const se=new ws($,.0075,3,64,re*Math.PI*2);return se.rotateY(Math.PI/2),se.rotateX(Math.PI/2),se}function A(){const $=new tn;return $.setAttribute("position",new Bt([0,0,0,1,1,1],3)),$}const B={X:[[new Se(S,o),[.5,0,0],[0,0,-Math.PI/2]],[new Se(S,o),[-.5,0,0],[0,0,Math.PI/2]],[new Se(R,o),[0,0,0],[0,0,-Math.PI/2]]],Y:[[new Se(S,a),[0,.5,0]],[new Se(S,a),[0,-.5,0],[Math.PI,0,0]],[new Se(R,a)]],Z:[[new Se(S,l),[0,0,.5],[Math.PI/2,0,0]],[new Se(S,l),[0,0,-.5],[-Math.PI/2,0,0]],[new Se(R,l),null,[Math.PI/2,0,0]]],XYZ:[[new Se(new So(.1,0),p.clone()),[0,0,0]]],XY:[[new Se(new Kt(.15,.15,.01),d.clone()),[.15,.15,0]]],YZ:[[new Se(new Kt(.15,.15,.01),u.clone()),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new Se(new Kt(.15,.15,.01),h.clone()),[.15,0,.15],[-Math.PI/2,0,0]]]},N={X:[[new Se(new vn(.2,0,.6,4),n),[.3,0,0],[0,0,-Math.PI/2]],[new Se(new vn(.2,0,.6,4),n),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new Se(new vn(.2,0,.6,4),n),[0,.3,0]],[new Se(new vn(.2,0,.6,4),n),[0,-.3,0],[0,0,Math.PI]]],Z:[[new Se(new vn(.2,0,.6,4),n),[0,0,.3],[Math.PI/2,0,0]],[new Se(new vn(.2,0,.6,4),n),[0,0,-.3],[-Math.PI/2,0,0]]],XYZ:[[new Se(new So(.2,0),n)]],XY:[[new Se(new Kt(.2,.2,.01),n),[.15,.15,0]]],YZ:[[new Se(new Kt(.2,.2,.01),n),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new Se(new Kt(.2,.2,.01),n),[.15,0,.15],[-Math.PI/2,0,0]]]},D={START:[[new Se(new So(.01,2),r),null,null,null,"helper"]],END:[[new Se(new So(.01,2),r),null,null,null,"helper"]],DELTA:[[new Si(A(),r),null,null,null,"helper"]],X:[[new Si(v,r.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new Si(v,r.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new Si(v,r.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},C={XYZE:[[new Se(b(.5,1),y),null,[0,Math.PI/2,0]]],X:[[new Se(b(.5,.5),o)]],Y:[[new Se(b(.5,.5),a),null,[0,0,-Math.PI/2]]],Z:[[new Se(b(.5,.5),l),null,[0,Math.PI/2,0]]],E:[[new Se(b(.75,1),m),null,[0,Math.PI/2,0]]]},E={AXIS:[[new Si(v,r.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]]},M={XYZE:[[new Se(new Va(.25,10,8),n)]],X:[[new Se(new ws(.5,.1,4,24),n),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new Se(new ws(.5,.1,4,24),n),[0,0,0],[Math.PI/2,0,0]]],Z:[[new Se(new ws(.5,.1,4,24),n),[0,0,0],[0,0,-Math.PI/2]]],E:[[new Se(new ws(.75,.1,2,24),n)]]},O={X:[[new Se(_,o),[.5,0,0],[0,0,-Math.PI/2]],[new Se(R,o),[0,0,0],[0,0,-Math.PI/2]],[new Se(_,o),[-.5,0,0],[0,0,Math.PI/2]]],Y:[[new Se(_,a),[0,.5,0]],[new Se(R,a)],[new Se(_,a),[0,-.5,0],[0,0,Math.PI]]],Z:[[new Se(_,l),[0,0,.5],[Math.PI/2,0,0]],[new Se(R,l),[0,0,0],[Math.PI/2,0,0]],[new Se(_,l),[0,0,-.5],[-Math.PI/2,0,0]]],XY:[[new Se(new Kt(.15,.15,.01),d),[.15,.15,0]]],YZ:[[new Se(new Kt(.15,.15,.01),u),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new Se(new Kt(.15,.15,.01),h),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new Se(new Kt(.1,.1,.1),p.clone())]]},H={X:[[new Se(new vn(.2,0,.6,4),n),[.3,0,0],[0,0,-Math.PI/2]],[new Se(new vn(.2,0,.6,4),n),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new Se(new vn(.2,0,.6,4),n),[0,.3,0]],[new Se(new vn(.2,0,.6,4),n),[0,-.3,0],[0,0,Math.PI]]],Z:[[new Se(new vn(.2,0,.6,4),n),[0,0,.3],[Math.PI/2,0,0]],[new Se(new vn(.2,0,.6,4),n),[0,0,-.3],[-Math.PI/2,0,0]]],XY:[[new Se(new Kt(.2,.2,.01),n),[.15,.15,0]]],YZ:[[new Se(new Kt(.2,.2,.01),n),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new Se(new Kt(.2,.2,.01),n),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new Se(new Kt(.2,.2,.2),n),[0,0,0]]]},G={X:[[new Si(v,r.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new Si(v,r.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new Si(v,r.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]};function Y($){const re=new gt;for(const se in $)for(let K=$[se].length;K--;){const ae=$[se][K][0].clone(),pe=$[se][K][1],ve=$[se][K][2],ke=$[se][K][3],Ze=$[se][K][4];ae.name=se,ae.tag=Ze,pe&&ae.position.set(pe[0],pe[1],pe[2]),ve&&ae.rotation.set(ve[0],ve[1],ve[2]),ke&&ae.scale.set(ke[0],ke[1],ke[2]),ae.updateMatrix();const te=ae.geometry.clone();te.applyMatrix4(ae.matrix),ae.geometry=te,ae.renderOrder=1/0,ae.position.set(0,0,0),ae.rotation.set(0,0,0),ae.scale.set(1,1,1),re.add(ae)}return re}this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=Y(B)),this.add(this.gizmo.rotate=Y(C)),this.add(this.gizmo.scale=Y(O)),this.add(this.picker.translate=Y(N)),this.add(this.picker.rotate=Y(M)),this.add(this.picker.scale=Y(H)),this.add(this.helper.translate=Y(D)),this.add(this.helper.rotate=Y(E)),this.add(this.helper.scale=Y(G)),this.picker.translate.visible=!1,this.picker.rotate.visible=!1,this.picker.scale.visible=!1}updateMatrixWorld(e){const n=(this.mode==="scale"?"local":this.space)==="local"?this.worldQuaternion:Ml;this.gizmo.translate.visible=this.mode==="translate",this.gizmo.rotate.visible=this.mode==="rotate",this.gizmo.scale.visible=this.mode==="scale",this.helper.translate.visible=this.mode==="translate",this.helper.rotate.visible=this.mode==="rotate",this.helper.scale.visible=this.mode==="scale";let r=[];r=r.concat(this.picker[this.mode].children),r=r.concat(this.gizmo[this.mode].children),r=r.concat(this.helper[this.mode].children);for(let o=0;o<r.length;o++){const a=r[o];a.visible=!0,a.rotation.set(0,0,0),a.position.copy(this.worldPosition);let l;if(this.camera.isOrthographicCamera?l=(this.camera.top-this.camera.bottom)/this.camera.zoom:l=this.worldPosition.distanceTo(this.cameraPosition)*Math.min(1.9*Math.tan(Math.PI*this.camera.fov/360)/this.camera.zoom,7),a.scale.set(1,1,1).multiplyScalar(l*this.size/4),a.tag==="helper"){a.visible=!1,a.name==="AXIS"?(a.visible=!!this.axis,this.axis==="X"&&(jt.setFromEuler(hl.set(0,0,0)),a.quaternion.copy(n).multiply(jt),Math.abs(Ft.copy(wa).applyQuaternion(n).dot(this.eye))>.9&&(a.visible=!1)),this.axis==="Y"&&(jt.setFromEuler(hl.set(0,0,Math.PI/2)),a.quaternion.copy(n).multiply(jt),Math.abs(Ft.copy(Es).applyQuaternion(n).dot(this.eye))>.9&&(a.visible=!1)),this.axis==="Z"&&(jt.setFromEuler(hl.set(0,Math.PI/2,0)),a.quaternion.copy(n).multiply(jt),Math.abs(Ft.copy(Aa).applyQuaternion(n).dot(this.eye))>.9&&(a.visible=!1)),this.axis==="XYZE"&&(jt.setFromEuler(hl.set(0,Math.PI/2,0)),Ft.copy(this.rotationAxis),a.quaternion.setFromRotationMatrix(x_.lookAt(v_,Ft,Es)),a.quaternion.multiply(jt),a.visible=this.dragging),this.axis==="E"&&(a.visible=!1)):a.name==="START"?(a.position.copy(this.worldPositionStart),a.visible=this.dragging):a.name==="END"?(a.position.copy(this.worldPosition),a.visible=this.dragging):a.name==="DELTA"?(a.position.copy(this.worldPositionStart),a.quaternion.copy(this.worldQuaternionStart),In.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),In.applyQuaternion(this.worldQuaternionStart.clone().invert()),a.scale.copy(In),a.visible=this.dragging):(a.quaternion.copy(n),this.dragging?a.position.copy(this.worldPositionStart):a.position.copy(this.worldPosition),this.axis&&(a.visible=this.axis.search(a.name)!==-1));continue}a.quaternion.copy(n),this.mode==="translate"||this.mode==="scale"?(a.name==="X"&&Math.abs(Ft.copy(wa).applyQuaternion(n).dot(this.eye))>.99&&(a.scale.set(1e-10,1e-10,1e-10),a.visible=!1),a.name==="Y"&&Math.abs(Ft.copy(Es).applyQuaternion(n).dot(this.eye))>.99&&(a.scale.set(1e-10,1e-10,1e-10),a.visible=!1),a.name==="Z"&&Math.abs(Ft.copy(Aa).applyQuaternion(n).dot(this.eye))>.99&&(a.scale.set(1e-10,1e-10,1e-10),a.visible=!1),a.name==="XY"&&Math.abs(Ft.copy(Aa).applyQuaternion(n).dot(this.eye))<.2&&(a.scale.set(1e-10,1e-10,1e-10),a.visible=!1),a.name==="YZ"&&Math.abs(Ft.copy(wa).applyQuaternion(n).dot(this.eye))<.2&&(a.scale.set(1e-10,1e-10,1e-10),a.visible=!1),a.name==="XZ"&&Math.abs(Ft.copy(Es).applyQuaternion(n).dot(this.eye))<.2&&(a.scale.set(1e-10,1e-10,1e-10),a.visible=!1)):this.mode==="rotate"&&(fl.copy(n),Ft.copy(this.eye).applyQuaternion(jt.copy(n).invert()),a.name.search("E")!==-1&&a.quaternion.setFromRotationMatrix(x_.lookAt(this.eye,v_,Es)),a.name==="X"&&(jt.setFromAxisAngle(wa,Math.atan2(-Ft.y,Ft.z)),jt.multiplyQuaternions(fl,jt),a.quaternion.copy(jt)),a.name==="Y"&&(jt.setFromAxisAngle(Es,Math.atan2(Ft.x,Ft.z)),jt.multiplyQuaternions(fl,jt),a.quaternion.copy(jt)),a.name==="Z"&&(jt.setFromAxisAngle(Aa,Math.atan2(Ft.y,Ft.x)),jt.multiplyQuaternions(fl,jt),a.quaternion.copy(jt))),a.visible=a.visible&&(a.name.indexOf("X")===-1||this.showX),a.visible=a.visible&&(a.name.indexOf("Y")===-1||this.showY),a.visible=a.visible&&(a.name.indexOf("Z")===-1||this.showZ),a.visible=a.visible&&(a.name.indexOf("E")===-1||this.showX&&this.showY&&this.showZ),a.material._color=a.material._color||a.material.color.clone(),a.material._opacity=a.material._opacity||a.material.opacity,a.material.color.copy(a.material._color),a.material.opacity=a.material._opacity,this.enabled&&this.axis&&(a.name===this.axis||this.axis.split("").some(function(u){return a.name===u}))&&(a.material.color.setHex(16776960),a.material.opacity=1)}super.updateMatrixWorld(e)}}class IL extends Se{constructor(){super(new ns(1e5,1e5,2,2),new Ji({visible:!1,wireframe:!0,side:si,transparent:!0,opacity:.1,toneMapped:!1})),this.isTransformControlsPlane=!0,this.type="TransformControlsPlane"}updateMatrixWorld(e){let t=this.space;switch(this.position.copy(this.worldPosition),this.mode==="scale"&&(t="local"),dl.copy(wa).applyQuaternion(t==="local"?this.worldQuaternion:Ml),xa.copy(Es).applyQuaternion(t==="local"?this.worldQuaternion:Ml),ya.copy(Aa).applyQuaternion(t==="local"?this.worldQuaternion:Ml),Ft.copy(xa),this.mode){case"translate":case"scale":switch(this.axis){case"X":Ft.copy(this.eye).cross(dl),Yi.copy(dl).cross(Ft);break;case"Y":Ft.copy(this.eye).cross(xa),Yi.copy(xa).cross(Ft);break;case"Z":Ft.copy(this.eye).cross(ya),Yi.copy(ya).cross(Ft);break;case"XY":Yi.copy(ya);break;case"YZ":Yi.copy(dl);break;case"XZ":Ft.copy(ya),Yi.copy(xa);break;case"XYZ":case"E":Yi.set(0,0,0);break}break;case"rotate":default:Yi.set(0,0,0)}Yi.length()===0?this.quaternion.copy(this.cameraQuaternion):(y_.lookAt(In.set(0,0,0),Yi,Ft),this.quaternion.setFromRotationMatrix(y_)),super.updateMatrixWorld(e)}}const B0="#c20017",z0="#00ab26",k0="#0081d4",mf=B0,gf=z0,_f=k0;class DL extends TL{isTransformTool=!0;_scaleLinked;_gizmo;constructor(e,t){super(e,t),this.name="DIVETransformTool",this._scaleLinked=!1,this._gizmo=this.initGizmo(),this._scene.add(this._gizmo)}Activate(){}SetGizmoMode(e){this._gizmo.mode=e}SetGizmoVisibility(e){const t=this._scene.children.includes(this._gizmo);e&&!t?(this._scene.add(this._gizmo),"isTransformControls"in this._gizmo&&this._gizmo.getRaycaster().layers.enableAll()):!e&&t&&(this._scene.remove(this._gizmo),"isTransformControls"in this._gizmo&&this._gizmo.getRaycaster().layers.disableAll())}SetGizmoScaleLinked(e){this._scaleLinked=e}initGizmo(){const e=new bL(this._controller.object,this._controller.domElement);return e.mode="translate",e.traverse(t=>{if(!("isMesh"in t))return;const n=t.material;t.name==="X"&&n.color.set(mf),t.name==="Y"&&n.color.set(gf),t.name==="Z"&&n.color.set(_f),t.name==="XY"&&n.color.set(_f),t.name==="YZ"&&n.color.set(mf),t.name==="XZ"&&n.color.set(gf)}),e.addEventListener("mouseDown",()=>{this._controller.enabled=!1,yl(e.object,"isMovable")&&e.object.onMoveStart&&e.object.onMoveStart()}),e.addEventListener("objectChange",()=>{if(yl(e.object,"isMovable")&&e.object.onMove&&(e.object.onMove(),this._scaleLinked)){const t=e.object.scale,n=(t.x+t.y+t.z)/3;e.object.scale.set(n,n,n)}}),e.addEventListener("mouseUp",()=>{this._controller.enabled=!0,yl(e.object,"isMovable")&&e.object.onMoveEnd&&e.object.onMoveEnd()}),e}}const M_=i=>i.isSelectTool!==void 0;class UL extends DL{isSelectTool=!0;constructor(e,t){super(e,t),this.name="SelectTool"}Activate(){}Select(e){this.AttachGizmo(e),e.onSelect&&e.onSelect()}Deselect(e){this.DetachGizmo(),e.onDeselect&&e.onDeselect()}AttachGizmo(e){if("isMovable"in e){const t=e;this._gizmo.attach(t),this.SetGizmoVisibility(t.visible)}}DetachGizmo(){this._gizmo.detach()}onClick(e){super.onClick(e);const t=this._raycaster.intersectObjects(this._scene.Root.children,!0).filter(r=>r.object.visible)[0],n=Il(t?.object,"isSelectable");if(!t||!n){this._gizmo.object&&this.Deselect(this._gizmo.object);return}if(this._gizmo.object){if(this._gizmo.object.uuid===n.uuid)return;this.Deselect(this._gizmo.object)}this.Select(n)}}var pl=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},Ra={exports:{}};/**
3798
3798
  * @license
3799
3799
  * Lodash <https://lodash.com/>
3800
3800
  * Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
3801
3801
  * Released under MIT license <https://lodash.com/license>
3802
3802
  * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
3803
3803
  * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
3804
- */var NL=Ra.exports,S_;function OL(){return S_||(S_=1,function(i,e){(function(){var t,n="4.17.21",r=200,o="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",a="Expected a function",l="Invalid `variable` option passed into `_.template`",u="__lodash_hash_undefined__",h=500,d="__lodash_placeholder__",p=1,m=2,g=4,y=1,S=2,_=1,v=2,R=4,b=8,A=16,B=32,N=64,D=128,C=256,E=512,M=30,O="...",H=800,G=16,Y=1,$=2,re=3,se=1/0,K=9007199254740991,ae=17976931348623157e292,pe=NaN,ve=4294967295,ke=ve-1,Ze=ve>>>1,te=[["ary",D],["bind",_],["bindKey",v],["curry",b],["curryRight",A],["flip",E],["partial",B],["partialRight",N],["rearg",C]],fe="[object Arguments]",Ee="[object Array]",Me="[object AsyncFunction]",ze="[object Boolean]",Ve="[object Date]",it="[object DOMException]",q="[object Error]",$e="[object Function]",Fe="[object GeneratorFunction]",mt="[object Map]",We="[object Number]",At="[object Null]",z="[object Object]",P="[object Promise]",ie="[object Proxy]",le="[object RegExp]",de="[object Set]",ge="[object String]",He="[object Symbol]",_e="[object Undefined]",De="[object WeakMap]",Xe="[object WeakSet]",xe="[object ArrayBuffer]",we="[object DataView]",Ke="[object Float32Array]",Le="[object Float64Array]",Ie="[object Int8Array]",ct="[object Int16Array]",ft="[object Int32Array]",Et="[object Uint8Array]",_t="[object Uint8ClampedArray]",Tt="[object Uint16Array]",Ne="[object Uint32Array]",T=/\b__p \+= '';/g,Z=/\b(__p \+=) '' \+/g,ce=/(__e\(.*?\)|\b__t\)) \+\n'';/g,ye=/&(?:amp|lt|gt|quot|#39);/g,Re=/[&<>"']/g,vt=RegExp(ye.source),dt=RegExp(Re.source),zt=/<%-([\s\S]+?)%>/g,ln=/<%([\s\S]+?)%>/g,Rt=/<%=([\s\S]+?)%>/g,Zt=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Jt=/^\w*$/,Fn=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,bn=/[\\^$.*+?()[\]{}|]/g,ki=RegExp(bn.source),Hi=/^\s+/,ar=/\s/,Ya=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,Is=/\{\n\/\* \[wrapped with (.+)\] \*/,ja=/,? & /,qa=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,Xl=/[()=,{}\[\]\/\s]/,Yl=/\\(\\)?/g,jl=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,U=/\w*$/,j=/^[-+]0x[0-9a-f]+$/i,ee=/^0b[01]+$/i,ne=/^\[object .+?Constructor\]$/,J=/^0o[0-7]+$/i,Ae=/^(?:0|[1-9]\d*)$/,Be=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Ge=/($^)/,Je=/['\n\r\u2028\u2029\\]/g,et="\\ud800-\\udfff",tt="\\u0300-\\u036f",rt="\\ufe20-\\ufe2f",qt="\\u20d0-\\u20ff",wn=tt+rt+qt,nn="\\u2700-\\u27bf",ui="a-z\\xdf-\\xf6\\xf8-\\xff",Gt="\\xac\\xb1\\xd7\\xf7",ot="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",Vo="\\u2000-\\u206f",kt=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",Gi="A-Z\\xc0-\\xd6\\xd8-\\xde",Wo="\\ufe0e\\ufe0f",Cr=Gt+ot+Vo+kt,is="['’]",mn="["+et+"]",bi="["+Cr+"]",Pr="["+wn+"]",Bn="\\d+",Xo="["+nn+"]",$a="["+ui+"]",Yo="[^"+et+Cr+Bn+nn+ui+Gi+"]",ql="\\ud83c[\\udffb-\\udfff]",ov="(?:"+Pr+"|"+ql+")",sd="[^"+et+"]",$l="(?:\\ud83c[\\udde6-\\uddff]){2}",Kl="[\\ud800-\\udbff][\\udc00-\\udfff]",Ds="["+Gi+"]",od="\\u200d",ad="(?:"+$a+"|"+Yo+")",av="(?:"+Ds+"|"+Yo+")",cd="(?:"+is+"(?:d|ll|m|re|s|t|ve))?",ld="(?:"+is+"(?:D|LL|M|RE|S|T|VE))?",ud=ov+"?",hd="["+Wo+"]?",cv="(?:"+od+"(?:"+[sd,$l,Kl].join("|")+")"+hd+ud+")*",lv="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",uv="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",fd=hd+ud+cv,hv="(?:"+[Xo,$l,Kl].join("|")+")"+fd,fv="(?:"+[sd+Pr+"?",Pr,$l,Kl,mn].join("|")+")",dv=RegExp(is,"g"),pv=RegExp(Pr,"g"),Zl=RegExp(ql+"(?="+ql+")|"+fv+fd,"g"),mv=RegExp([Ds+"?"+$a+"+"+cd+"(?="+[bi,Ds,"$"].join("|")+")",av+"+"+ld+"(?="+[bi,Ds+ad,"$"].join("|")+")",Ds+"?"+ad+"+"+cd,Ds+"+"+ld,uv,lv,Bn,hv].join("|"),"g"),gv=RegExp("["+od+et+wn+Wo+"]"),_v=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,vv=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],xv=-1,Vt={};Vt[Ke]=Vt[Le]=Vt[Ie]=Vt[ct]=Vt[ft]=Vt[Et]=Vt[_t]=Vt[Tt]=Vt[Ne]=!0,Vt[fe]=Vt[Ee]=Vt[xe]=Vt[ze]=Vt[we]=Vt[Ve]=Vt[q]=Vt[$e]=Vt[mt]=Vt[We]=Vt[z]=Vt[le]=Vt[de]=Vt[ge]=Vt[De]=!1;var Ht={};Ht[fe]=Ht[Ee]=Ht[xe]=Ht[we]=Ht[ze]=Ht[Ve]=Ht[Ke]=Ht[Le]=Ht[Ie]=Ht[ct]=Ht[ft]=Ht[mt]=Ht[We]=Ht[z]=Ht[le]=Ht[de]=Ht[ge]=Ht[He]=Ht[Et]=Ht[_t]=Ht[Tt]=Ht[Ne]=!0,Ht[q]=Ht[$e]=Ht[De]=!1;var yv={À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",Ç:"C",ç:"c",Ð:"D",ð:"d",È:"E",É:"E",Ê:"E",Ë:"E",è:"e",é:"e",ê:"e",ë:"e",Ì:"I",Í:"I",Î:"I",Ï:"I",ì:"i",í:"i",î:"i",ï:"i",Ñ:"N",ñ:"n",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ø:"O",ò:"o",ó:"o",ô:"o",õ:"o",ö:"o",ø:"o",Ù:"U",Ú:"U",Û:"U",Ü:"U",ù:"u",ú:"u",û:"u",ü:"u",Ý:"Y",ý:"y",ÿ:"y",Æ:"Ae",æ:"ae",Þ:"Th",þ:"th",ß:"ss",Ā:"A",Ă:"A",Ą:"A",ā:"a",ă:"a",ą:"a",Ć:"C",Ĉ:"C",Ċ:"C",Č:"C",ć:"c",ĉ:"c",ċ:"c",č:"c",Ď:"D",Đ:"D",ď:"d",đ:"d",Ē:"E",Ĕ:"E",Ė:"E",Ę:"E",Ě:"E",ē:"e",ĕ:"e",ė:"e",ę:"e",ě:"e",Ĝ:"G",Ğ:"G",Ġ:"G",Ģ:"G",ĝ:"g",ğ:"g",ġ:"g",ģ:"g",Ĥ:"H",Ħ:"H",ĥ:"h",ħ:"h",Ĩ:"I",Ī:"I",Ĭ:"I",Į:"I",İ:"I",ĩ:"i",ī:"i",ĭ:"i",į:"i",ı:"i",Ĵ:"J",ĵ:"j",Ķ:"K",ķ:"k",ĸ:"k",Ĺ:"L",Ļ:"L",Ľ:"L",Ŀ:"L",Ł:"L",ĺ:"l",ļ:"l",ľ:"l",ŀ:"l",ł:"l",Ń:"N",Ņ:"N",Ň:"N",Ŋ:"N",ń:"n",ņ:"n",ň:"n",ŋ:"n",Ō:"O",Ŏ:"O",Ő:"O",ō:"o",ŏ:"o",ő:"o",Ŕ:"R",Ŗ:"R",Ř:"R",ŕ:"r",ŗ:"r",ř:"r",Ś:"S",Ŝ:"S",Ş:"S",Š:"S",ś:"s",ŝ:"s",ş:"s",š:"s",Ţ:"T",Ť:"T",Ŧ:"T",ţ:"t",ť:"t",ŧ:"t",Ũ:"U",Ū:"U",Ŭ:"U",Ů:"U",Ű:"U",Ų:"U",ũ:"u",ū:"u",ŭ:"u",ů:"u",ű:"u",ų:"u",Ŵ:"W",ŵ:"w",Ŷ:"Y",ŷ:"y",Ÿ:"Y",Ź:"Z",Ż:"Z",Ž:"Z",ź:"z",ż:"z",ž:"z",IJ:"IJ",ij:"ij",Œ:"Oe",œ:"oe",ʼn:"'n",ſ:"s"},Mv={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},Sv={"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#39;":"'"},Ev={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Tv=parseFloat,bv=parseInt,dd=typeof pl=="object"&&pl&&pl.Object===Object&&pl,wv=typeof self=="object"&&self&&self.Object===Object&&self,xn=dd||wv||Function("return this")(),Jl=e&&!e.nodeType&&e,rs=Jl&&!0&&i&&!i.nodeType&&i,pd=rs&&rs.exports===Jl,Ql=pd&&dd.process,hi=function(){try{var W=rs&&rs.require&&rs.require("util").types;return W||Ql&&Ql.binding&&Ql.binding("util")}catch{}}(),md=hi&&hi.isArrayBuffer,gd=hi&&hi.isDate,_d=hi&&hi.isMap,vd=hi&&hi.isRegExp,xd=hi&&hi.isSet,yd=hi&&hi.isTypedArray;function Zn(W,oe,Q){switch(Q.length){case 0:return W.call(oe);case 1:return W.call(oe,Q[0]);case 2:return W.call(oe,Q[0],Q[1]);case 3:return W.call(oe,Q[0],Q[1],Q[2])}return W.apply(oe,Q)}function Av(W,oe,Q,Ce){for(var nt=-1,Ct=W==null?0:W.length;++nt<Ct;){var hn=W[nt];oe(Ce,hn,Q(hn),W)}return Ce}function fi(W,oe){for(var Q=-1,Ce=W==null?0:W.length;++Q<Ce&&oe(W[Q],Q,W)!==!1;);return W}function Rv(W,oe){for(var Q=W==null?0:W.length;Q--&&oe(W[Q],Q,W)!==!1;);return W}function Md(W,oe){for(var Q=-1,Ce=W==null?0:W.length;++Q<Ce;)if(!oe(W[Q],Q,W))return!1;return!0}function Lr(W,oe){for(var Q=-1,Ce=W==null?0:W.length,nt=0,Ct=[];++Q<Ce;){var hn=W[Q];oe(hn,Q,W)&&(Ct[nt++]=hn)}return Ct}function Ka(W,oe){var Q=W==null?0:W.length;return!!Q&&Us(W,oe,0)>-1}function eu(W,oe,Q){for(var Ce=-1,nt=W==null?0:W.length;++Ce<nt;)if(Q(oe,W[Ce]))return!0;return!1}function Yt(W,oe){for(var Q=-1,Ce=W==null?0:W.length,nt=Array(Ce);++Q<Ce;)nt[Q]=oe(W[Q],Q,W);return nt}function Ir(W,oe){for(var Q=-1,Ce=oe.length,nt=W.length;++Q<Ce;)W[nt+Q]=oe[Q];return W}function tu(W,oe,Q,Ce){var nt=-1,Ct=W==null?0:W.length;for(Ce&&Ct&&(Q=W[++nt]);++nt<Ct;)Q=oe(Q,W[nt],nt,W);return Q}function Cv(W,oe,Q,Ce){var nt=W==null?0:W.length;for(Ce&&nt&&(Q=W[--nt]);nt--;)Q=oe(Q,W[nt],nt,W);return Q}function nu(W,oe){for(var Q=-1,Ce=W==null?0:W.length;++Q<Ce;)if(oe(W[Q],Q,W))return!0;return!1}var Pv=iu("length");function Lv(W){return W.split("")}function Iv(W){return W.match(qa)||[]}function Sd(W,oe,Q){var Ce;return Q(W,function(nt,Ct,hn){if(oe(nt,Ct,hn))return Ce=Ct,!1}),Ce}function Za(W,oe,Q,Ce){for(var nt=W.length,Ct=Q+(Ce?1:-1);Ce?Ct--:++Ct<nt;)if(oe(W[Ct],Ct,W))return Ct;return-1}function Us(W,oe,Q){return oe===oe?Wv(W,oe,Q):Za(W,Ed,Q)}function Dv(W,oe,Q,Ce){for(var nt=Q-1,Ct=W.length;++nt<Ct;)if(Ce(W[nt],oe))return nt;return-1}function Ed(W){return W!==W}function Td(W,oe){var Q=W==null?0:W.length;return Q?su(W,oe)/Q:pe}function iu(W){return function(oe){return oe==null?t:oe[W]}}function ru(W){return function(oe){return W==null?t:W[oe]}}function bd(W,oe,Q,Ce,nt){return nt(W,function(Ct,hn,Ot){Q=Ce?(Ce=!1,Ct):oe(Q,Ct,hn,Ot)}),Q}function Uv(W,oe){var Q=W.length;for(W.sort(oe);Q--;)W[Q]=W[Q].value;return W}function su(W,oe){for(var Q,Ce=-1,nt=W.length;++Ce<nt;){var Ct=oe(W[Ce]);Ct!==t&&(Q=Q===t?Ct:Q+Ct)}return Q}function ou(W,oe){for(var Q=-1,Ce=Array(W);++Q<W;)Ce[Q]=oe(Q);return Ce}function Nv(W,oe){return Yt(oe,function(Q){return[Q,W[Q]]})}function wd(W){return W&&W.slice(0,Pd(W)+1).replace(Hi,"")}function Jn(W){return function(oe){return W(oe)}}function au(W,oe){return Yt(oe,function(Q){return W[Q]})}function jo(W,oe){return W.has(oe)}function Ad(W,oe){for(var Q=-1,Ce=W.length;++Q<Ce&&Us(oe,W[Q],0)>-1;);return Q}function Rd(W,oe){for(var Q=W.length;Q--&&Us(oe,W[Q],0)>-1;);return Q}function Ov(W,oe){for(var Q=W.length,Ce=0;Q--;)W[Q]===oe&&++Ce;return Ce}var Fv=ru(yv),Bv=ru(Mv);function zv(W){return"\\"+Ev[W]}function kv(W,oe){return W==null?t:W[oe]}function Ns(W){return gv.test(W)}function Hv(W){return _v.test(W)}function Gv(W){for(var oe,Q=[];!(oe=W.next()).done;)Q.push(oe.value);return Q}function cu(W){var oe=-1,Q=Array(W.size);return W.forEach(function(Ce,nt){Q[++oe]=[nt,Ce]}),Q}function Cd(W,oe){return function(Q){return W(oe(Q))}}function Dr(W,oe){for(var Q=-1,Ce=W.length,nt=0,Ct=[];++Q<Ce;){var hn=W[Q];(hn===oe||hn===d)&&(W[Q]=d,Ct[nt++]=Q)}return Ct}function Ja(W){var oe=-1,Q=Array(W.size);return W.forEach(function(Ce){Q[++oe]=Ce}),Q}function Vv(W){var oe=-1,Q=Array(W.size);return W.forEach(function(Ce){Q[++oe]=[Ce,Ce]}),Q}function Wv(W,oe,Q){for(var Ce=Q-1,nt=W.length;++Ce<nt;)if(W[Ce]===oe)return Ce;return-1}function Xv(W,oe,Q){for(var Ce=Q+1;Ce--;)if(W[Ce]===oe)return Ce;return Ce}function Os(W){return Ns(W)?jv(W):Pv(W)}function wi(W){return Ns(W)?qv(W):Lv(W)}function Pd(W){for(var oe=W.length;oe--&&ar.test(W.charAt(oe)););return oe}var Yv=ru(Sv);function jv(W){for(var oe=Zl.lastIndex=0;Zl.test(W);)++oe;return oe}function qv(W){return W.match(Zl)||[]}function $v(W){return W.match(mv)||[]}var Kv=function W(oe){oe=oe==null?xn:Fs.defaults(xn.Object(),oe,Fs.pick(xn,vv));var Q=oe.Array,Ce=oe.Date,nt=oe.Error,Ct=oe.Function,hn=oe.Math,Ot=oe.Object,lu=oe.RegExp,Zv=oe.String,di=oe.TypeError,Qa=Q.prototype,Jv=Ct.prototype,Bs=Ot.prototype,ec=oe["__core-js_shared__"],tc=Jv.toString,It=Bs.hasOwnProperty,Qv=0,Ld=function(){var s=/[^.]+$/.exec(ec&&ec.keys&&ec.keys.IE_PROTO||"");return s?"Symbol(src)_1."+s:""}(),nc=Bs.toString,ex=tc.call(Ot),tx=xn._,nx=lu("^"+tc.call(It).replace(bn,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),ic=pd?oe.Buffer:t,Ur=oe.Symbol,rc=oe.Uint8Array,Id=ic?ic.allocUnsafe:t,sc=Cd(Ot.getPrototypeOf,Ot),Dd=Ot.create,Ud=Bs.propertyIsEnumerable,oc=Qa.splice,Nd=Ur?Ur.isConcatSpreadable:t,qo=Ur?Ur.iterator:t,ss=Ur?Ur.toStringTag:t,ac=function(){try{var s=us(Ot,"defineProperty");return s({},"",{}),s}catch{}}(),ix=oe.clearTimeout!==xn.clearTimeout&&oe.clearTimeout,rx=Ce&&Ce.now!==xn.Date.now&&Ce.now,sx=oe.setTimeout!==xn.setTimeout&&oe.setTimeout,cc=hn.ceil,lc=hn.floor,uu=Ot.getOwnPropertySymbols,ox=ic?ic.isBuffer:t,Od=oe.isFinite,ax=Qa.join,cx=Cd(Ot.keys,Ot),fn=hn.max,An=hn.min,lx=Ce.now,ux=oe.parseInt,Fd=hn.random,hx=Qa.reverse,hu=us(oe,"DataView"),$o=us(oe,"Map"),fu=us(oe,"Promise"),zs=us(oe,"Set"),Ko=us(oe,"WeakMap"),Zo=us(Ot,"create"),uc=Ko&&new Ko,ks={},fx=hs(hu),dx=hs($o),px=hs(fu),mx=hs(zs),gx=hs(Ko),hc=Ur?Ur.prototype:t,Jo=hc?hc.valueOf:t,Bd=hc?hc.toString:t;function L(s){if(Qt(s)&&!st(s)&&!(s instanceof Mt)){if(s instanceof pi)return s;if(It.call(s,"__wrapped__"))return zp(s)}return new pi(s)}var Hs=function(){function s(){}return function(c){if(!$t(c))return{};if(Dd)return Dd(c);s.prototype=c;var f=new s;return s.prototype=t,f}}();function fc(){}function pi(s,c){this.__wrapped__=s,this.__actions__=[],this.__chain__=!!c,this.__index__=0,this.__values__=t}L.templateSettings={escape:zt,evaluate:ln,interpolate:Rt,variable:"",imports:{_:L}},L.prototype=fc.prototype,L.prototype.constructor=L,pi.prototype=Hs(fc.prototype),pi.prototype.constructor=pi;function Mt(s){this.__wrapped__=s,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=ve,this.__views__=[]}function _x(){var s=new Mt(this.__wrapped__);return s.__actions__=Yn(this.__actions__),s.__dir__=this.__dir__,s.__filtered__=this.__filtered__,s.__iteratees__=Yn(this.__iteratees__),s.__takeCount__=this.__takeCount__,s.__views__=Yn(this.__views__),s}function vx(){if(this.__filtered__){var s=new Mt(this);s.__dir__=-1,s.__filtered__=!0}else s=this.clone(),s.__dir__*=-1;return s}function xx(){var s=this.__wrapped__.value(),c=this.__dir__,f=st(s),x=c<0,w=f?s.length:0,I=Ly(0,w,this.__views__),k=I.start,V=I.end,X=V-k,ue=x?V:k-1,he=this.__iteratees__,me=he.length,Te=0,Ue=An(X,this.__takeCount__);if(!f||!x&&w==X&&Ue==X)return cp(s,this.__actions__);var je=[];e:for(;X--&&Te<Ue;){ue+=c;for(var lt=-1,qe=s[ue];++lt<me;){var xt=he[lt],bt=xt.iteratee,ti=xt.type,Hn=bt(qe);if(ti==$)qe=Hn;else if(!Hn){if(ti==Y)continue e;break e}}je[Te++]=qe}return je}Mt.prototype=Hs(fc.prototype),Mt.prototype.constructor=Mt;function os(s){var c=-1,f=s==null?0:s.length;for(this.clear();++c<f;){var x=s[c];this.set(x[0],x[1])}}function yx(){this.__data__=Zo?Zo(null):{},this.size=0}function Mx(s){var c=this.has(s)&&delete this.__data__[s];return this.size-=c?1:0,c}function Sx(s){var c=this.__data__;if(Zo){var f=c[s];return f===u?t:f}return It.call(c,s)?c[s]:t}function Ex(s){var c=this.__data__;return Zo?c[s]!==t:It.call(c,s)}function Tx(s,c){var f=this.__data__;return this.size+=this.has(s)?0:1,f[s]=Zo&&c===t?u:c,this}os.prototype.clear=yx,os.prototype.delete=Mx,os.prototype.get=Sx,os.prototype.has=Ex,os.prototype.set=Tx;function cr(s){var c=-1,f=s==null?0:s.length;for(this.clear();++c<f;){var x=s[c];this.set(x[0],x[1])}}function bx(){this.__data__=[],this.size=0}function wx(s){var c=this.__data__,f=dc(c,s);if(f<0)return!1;var x=c.length-1;return f==x?c.pop():oc.call(c,f,1),--this.size,!0}function Ax(s){var c=this.__data__,f=dc(c,s);return f<0?t:c[f][1]}function Rx(s){return dc(this.__data__,s)>-1}function Cx(s,c){var f=this.__data__,x=dc(f,s);return x<0?(++this.size,f.push([s,c])):f[x][1]=c,this}cr.prototype.clear=bx,cr.prototype.delete=wx,cr.prototype.get=Ax,cr.prototype.has=Rx,cr.prototype.set=Cx;function lr(s){var c=-1,f=s==null?0:s.length;for(this.clear();++c<f;){var x=s[c];this.set(x[0],x[1])}}function Px(){this.size=0,this.__data__={hash:new os,map:new($o||cr),string:new os}}function Lx(s){var c=bc(this,s).delete(s);return this.size-=c?1:0,c}function Ix(s){return bc(this,s).get(s)}function Dx(s){return bc(this,s).has(s)}function Ux(s,c){var f=bc(this,s),x=f.size;return f.set(s,c),this.size+=f.size==x?0:1,this}lr.prototype.clear=Px,lr.prototype.delete=Lx,lr.prototype.get=Ix,lr.prototype.has=Dx,lr.prototype.set=Ux;function as(s){var c=-1,f=s==null?0:s.length;for(this.__data__=new lr;++c<f;)this.add(s[c])}function Nx(s){return this.__data__.set(s,u),this}function Ox(s){return this.__data__.has(s)}as.prototype.add=as.prototype.push=Nx,as.prototype.has=Ox;function Ai(s){var c=this.__data__=new cr(s);this.size=c.size}function Fx(){this.__data__=new cr,this.size=0}function Bx(s){var c=this.__data__,f=c.delete(s);return this.size=c.size,f}function zx(s){return this.__data__.get(s)}function kx(s){return this.__data__.has(s)}function Hx(s,c){var f=this.__data__;if(f instanceof cr){var x=f.__data__;if(!$o||x.length<r-1)return x.push([s,c]),this.size=++f.size,this;f=this.__data__=new lr(x)}return f.set(s,c),this.size=f.size,this}Ai.prototype.clear=Fx,Ai.prototype.delete=Bx,Ai.prototype.get=zx,Ai.prototype.has=kx,Ai.prototype.set=Hx;function zd(s,c){var f=st(s),x=!f&&fs(s),w=!f&&!x&&zr(s),I=!f&&!x&&!w&&Xs(s),k=f||x||w||I,V=k?ou(s.length,Zv):[],X=V.length;for(var ue in s)(c||It.call(s,ue))&&!(k&&(ue=="length"||w&&(ue=="offset"||ue=="parent")||I&&(ue=="buffer"||ue=="byteLength"||ue=="byteOffset")||dr(ue,X)))&&V.push(ue);return V}function kd(s){var c=s.length;return c?s[Eu(0,c-1)]:t}function Gx(s,c){return wc(Yn(s),cs(c,0,s.length))}function Vx(s){return wc(Yn(s))}function du(s,c,f){(f!==t&&!Ri(s[c],f)||f===t&&!(c in s))&&ur(s,c,f)}function Qo(s,c,f){var x=s[c];(!(It.call(s,c)&&Ri(x,f))||f===t&&!(c in s))&&ur(s,c,f)}function dc(s,c){for(var f=s.length;f--;)if(Ri(s[f][0],c))return f;return-1}function Wx(s,c,f,x){return Nr(s,function(w,I,k){c(x,w,f(w),k)}),x}function Hd(s,c){return s&&Wi(c,gn(c),s)}function Xx(s,c){return s&&Wi(c,qn(c),s)}function ur(s,c,f){c=="__proto__"&&ac?ac(s,c,{configurable:!0,enumerable:!0,value:f,writable:!0}):s[c]=f}function pu(s,c){for(var f=-1,x=c.length,w=Q(x),I=s==null;++f<x;)w[f]=I?t:qu(s,c[f]);return w}function cs(s,c,f){return s===s&&(f!==t&&(s=s<=f?s:f),c!==t&&(s=s>=c?s:c)),s}function mi(s,c,f,x,w,I){var k,V=c&p,X=c&m,ue=c&g;if(f&&(k=w?f(s,x,w,I):f(s)),k!==t)return k;if(!$t(s))return s;var he=st(s);if(he){if(k=Dy(s),!V)return Yn(s,k)}else{var me=Rn(s),Te=me==$e||me==Fe;if(zr(s))return hp(s,V);if(me==z||me==fe||Te&&!w){if(k=X||Te?{}:Pp(s),!V)return X?Sy(s,Xx(k,s)):My(s,Hd(k,s))}else{if(!Ht[me])return w?s:{};k=Uy(s,me,V)}}I||(I=new Ai);var Ue=I.get(s);if(Ue)return Ue;I.set(s,k),sm(s)?s.forEach(function(qe){k.add(mi(qe,c,f,qe,s,I))}):im(s)&&s.forEach(function(qe,xt){k.set(xt,mi(qe,c,f,xt,s,I))});var je=ue?X?Uu:Du:X?qn:gn,lt=he?t:je(s);return fi(lt||s,function(qe,xt){lt&&(xt=qe,qe=s[xt]),Qo(k,xt,mi(qe,c,f,xt,s,I))}),k}function Yx(s){var c=gn(s);return function(f){return Gd(f,s,c)}}function Gd(s,c,f){var x=f.length;if(s==null)return!x;for(s=Ot(s);x--;){var w=f[x],I=c[w],k=s[w];if(k===t&&!(w in s)||!I(k))return!1}return!0}function Vd(s,c,f){if(typeof s!="function")throw new di(a);return oa(function(){s.apply(t,f)},c)}function ea(s,c,f,x){var w=-1,I=Ka,k=!0,V=s.length,X=[],ue=c.length;if(!V)return X;f&&(c=Yt(c,Jn(f))),x?(I=eu,k=!1):c.length>=r&&(I=jo,k=!1,c=new as(c));e:for(;++w<V;){var he=s[w],me=f==null?he:f(he);if(he=x||he!==0?he:0,k&&me===me){for(var Te=ue;Te--;)if(c[Te]===me)continue e;X.push(he)}else I(c,me,x)||X.push(he)}return X}var Nr=gp(Vi),Wd=gp(gu,!0);function jx(s,c){var f=!0;return Nr(s,function(x,w,I){return f=!!c(x,w,I),f}),f}function pc(s,c,f){for(var x=-1,w=s.length;++x<w;){var I=s[x],k=c(I);if(k!=null&&(V===t?k===k&&!ei(k):f(k,V)))var V=k,X=I}return X}function qx(s,c,f,x){var w=s.length;for(f=at(f),f<0&&(f=-f>w?0:w+f),x=x===t||x>w?w:at(x),x<0&&(x+=w),x=f>x?0:am(x);f<x;)s[f++]=c;return s}function Xd(s,c){var f=[];return Nr(s,function(x,w,I){c(x,w,I)&&f.push(x)}),f}function yn(s,c,f,x,w){var I=-1,k=s.length;for(f||(f=Oy),w||(w=[]);++I<k;){var V=s[I];c>0&&f(V)?c>1?yn(V,c-1,f,x,w):Ir(w,V):x||(w[w.length]=V)}return w}var mu=_p(),Yd=_p(!0);function Vi(s,c){return s&&mu(s,c,gn)}function gu(s,c){return s&&Yd(s,c,gn)}function mc(s,c){return Lr(c,function(f){return pr(s[f])})}function ls(s,c){c=Fr(c,s);for(var f=0,x=c.length;s!=null&&f<x;)s=s[Xi(c[f++])];return f&&f==x?s:t}function jd(s,c,f){var x=c(s);return st(s)?x:Ir(x,f(s))}function zn(s){return s==null?s===t?_e:At:ss&&ss in Ot(s)?Py(s):Vy(s)}function _u(s,c){return s>c}function $x(s,c){return s!=null&&It.call(s,c)}function Kx(s,c){return s!=null&&c in Ot(s)}function Zx(s,c,f){return s>=An(c,f)&&s<fn(c,f)}function vu(s,c,f){for(var x=f?eu:Ka,w=s[0].length,I=s.length,k=I,V=Q(I),X=1/0,ue=[];k--;){var he=s[k];k&&c&&(he=Yt(he,Jn(c))),X=An(he.length,X),V[k]=!f&&(c||w>=120&&he.length>=120)?new as(k&&he):t}he=s[0];var me=-1,Te=V[0];e:for(;++me<w&&ue.length<X;){var Ue=he[me],je=c?c(Ue):Ue;if(Ue=f||Ue!==0?Ue:0,!(Te?jo(Te,je):x(ue,je,f))){for(k=I;--k;){var lt=V[k];if(!(lt?jo(lt,je):x(s[k],je,f)))continue e}Te&&Te.push(je),ue.push(Ue)}}return ue}function Jx(s,c,f,x){return Vi(s,function(w,I,k){c(x,f(w),I,k)}),x}function ta(s,c,f){c=Fr(c,s),s=Up(s,c);var x=s==null?s:s[Xi(_i(c))];return x==null?t:Zn(x,s,f)}function qd(s){return Qt(s)&&zn(s)==fe}function Qx(s){return Qt(s)&&zn(s)==xe}function ey(s){return Qt(s)&&zn(s)==Ve}function na(s,c,f,x,w){return s===c?!0:s==null||c==null||!Qt(s)&&!Qt(c)?s!==s&&c!==c:ty(s,c,f,x,na,w)}function ty(s,c,f,x,w,I){var k=st(s),V=st(c),X=k?Ee:Rn(s),ue=V?Ee:Rn(c);X=X==fe?z:X,ue=ue==fe?z:ue;var he=X==z,me=ue==z,Te=X==ue;if(Te&&zr(s)){if(!zr(c))return!1;k=!0,he=!1}if(Te&&!he)return I||(I=new Ai),k||Xs(s)?Ap(s,c,f,x,w,I):Ry(s,c,X,f,x,w,I);if(!(f&y)){var Ue=he&&It.call(s,"__wrapped__"),je=me&&It.call(c,"__wrapped__");if(Ue||je){var lt=Ue?s.value():s,qe=je?c.value():c;return I||(I=new Ai),w(lt,qe,f,x,I)}}return Te?(I||(I=new Ai),Cy(s,c,f,x,w,I)):!1}function ny(s){return Qt(s)&&Rn(s)==mt}function xu(s,c,f,x){var w=f.length,I=w,k=!x;if(s==null)return!I;for(s=Ot(s);w--;){var V=f[w];if(k&&V[2]?V[1]!==s[V[0]]:!(V[0]in s))return!1}for(;++w<I;){V=f[w];var X=V[0],ue=s[X],he=V[1];if(k&&V[2]){if(ue===t&&!(X in s))return!1}else{var me=new Ai;if(x)var Te=x(ue,he,X,s,c,me);if(!(Te===t?na(he,ue,y|S,x,me):Te))return!1}}return!0}function $d(s){if(!$t(s)||By(s))return!1;var c=pr(s)?nx:ne;return c.test(hs(s))}function iy(s){return Qt(s)&&zn(s)==le}function ry(s){return Qt(s)&&Rn(s)==de}function sy(s){return Qt(s)&&Ic(s.length)&&!!Vt[zn(s)]}function Kd(s){return typeof s=="function"?s:s==null?$n:typeof s=="object"?st(s)?Qd(s[0],s[1]):Jd(s):vm(s)}function yu(s){if(!sa(s))return cx(s);var c=[];for(var f in Ot(s))It.call(s,f)&&f!="constructor"&&c.push(f);return c}function oy(s){if(!$t(s))return Gy(s);var c=sa(s),f=[];for(var x in s)x=="constructor"&&(c||!It.call(s,x))||f.push(x);return f}function Mu(s,c){return s<c}function Zd(s,c){var f=-1,x=jn(s)?Q(s.length):[];return Nr(s,function(w,I,k){x[++f]=c(w,I,k)}),x}function Jd(s){var c=Ou(s);return c.length==1&&c[0][2]?Ip(c[0][0],c[0][1]):function(f){return f===s||xu(f,s,c)}}function Qd(s,c){return Bu(s)&&Lp(c)?Ip(Xi(s),c):function(f){var x=qu(f,s);return x===t&&x===c?$u(f,s):na(c,x,y|S)}}function gc(s,c,f,x,w){s!==c&&mu(c,function(I,k){if(w||(w=new Ai),$t(I))ay(s,c,k,f,gc,x,w);else{var V=x?x(ku(s,k),I,k+"",s,c,w):t;V===t&&(V=I),du(s,k,V)}},qn)}function ay(s,c,f,x,w,I,k){var V=ku(s,f),X=ku(c,f),ue=k.get(X);if(ue){du(s,f,ue);return}var he=I?I(V,X,f+"",s,c,k):t,me=he===t;if(me){var Te=st(X),Ue=!Te&&zr(X),je=!Te&&!Ue&&Xs(X);he=X,Te||Ue||je?st(V)?he=V:rn(V)?he=Yn(V):Ue?(me=!1,he=hp(X,!0)):je?(me=!1,he=fp(X,!0)):he=[]:aa(X)||fs(X)?(he=V,fs(V)?he=cm(V):(!$t(V)||pr(V))&&(he=Pp(X))):me=!1}me&&(k.set(X,he),w(he,X,x,I,k),k.delete(X)),du(s,f,he)}function ep(s,c){var f=s.length;if(f)return c+=c<0?f:0,dr(c,f)?s[c]:t}function tp(s,c,f){c.length?c=Yt(c,function(I){return st(I)?function(k){return ls(k,I.length===1?I[0]:I)}:I}):c=[$n];var x=-1;c=Yt(c,Jn(Ye()));var w=Zd(s,function(I,k,V){var X=Yt(c,function(ue){return ue(I)});return{criteria:X,index:++x,value:I}});return Uv(w,function(I,k){return yy(I,k,f)})}function cy(s,c){return np(s,c,function(f,x){return $u(s,x)})}function np(s,c,f){for(var x=-1,w=c.length,I={};++x<w;){var k=c[x],V=ls(s,k);f(V,k)&&ia(I,Fr(k,s),V)}return I}function ly(s){return function(c){return ls(c,s)}}function Su(s,c,f,x){var w=x?Dv:Us,I=-1,k=c.length,V=s;for(s===c&&(c=Yn(c)),f&&(V=Yt(s,Jn(f)));++I<k;)for(var X=0,ue=c[I],he=f?f(ue):ue;(X=w(V,he,X,x))>-1;)V!==s&&oc.call(V,X,1),oc.call(s,X,1);return s}function ip(s,c){for(var f=s?c.length:0,x=f-1;f--;){var w=c[f];if(f==x||w!==I){var I=w;dr(w)?oc.call(s,w,1):wu(s,w)}}return s}function Eu(s,c){return s+lc(Fd()*(c-s+1))}function uy(s,c,f,x){for(var w=-1,I=fn(cc((c-s)/(f||1)),0),k=Q(I);I--;)k[x?I:++w]=s,s+=f;return k}function Tu(s,c){var f="";if(!s||c<1||c>K)return f;do c%2&&(f+=s),c=lc(c/2),c&&(s+=s);while(c);return f}function pt(s,c){return Hu(Dp(s,c,$n),s+"")}function hy(s){return kd(Ys(s))}function fy(s,c){var f=Ys(s);return wc(f,cs(c,0,f.length))}function ia(s,c,f,x){if(!$t(s))return s;c=Fr(c,s);for(var w=-1,I=c.length,k=I-1,V=s;V!=null&&++w<I;){var X=Xi(c[w]),ue=f;if(X==="__proto__"||X==="constructor"||X==="prototype")return s;if(w!=k){var he=V[X];ue=x?x(he,X,V):t,ue===t&&(ue=$t(he)?he:dr(c[w+1])?[]:{})}Qo(V,X,ue),V=V[X]}return s}var rp=uc?function(s,c){return uc.set(s,c),s}:$n,dy=ac?function(s,c){return ac(s,"toString",{configurable:!0,enumerable:!1,value:Zu(c),writable:!0})}:$n;function py(s){return wc(Ys(s))}function gi(s,c,f){var x=-1,w=s.length;c<0&&(c=-c>w?0:w+c),f=f>w?w:f,f<0&&(f+=w),w=c>f?0:f-c>>>0,c>>>=0;for(var I=Q(w);++x<w;)I[x]=s[x+c];return I}function my(s,c){var f;return Nr(s,function(x,w,I){return f=c(x,w,I),!f}),!!f}function _c(s,c,f){var x=0,w=s==null?x:s.length;if(typeof c=="number"&&c===c&&w<=Ze){for(;x<w;){var I=x+w>>>1,k=s[I];k!==null&&!ei(k)&&(f?k<=c:k<c)?x=I+1:w=I}return w}return bu(s,c,$n,f)}function bu(s,c,f,x){var w=0,I=s==null?0:s.length;if(I===0)return 0;c=f(c);for(var k=c!==c,V=c===null,X=ei(c),ue=c===t;w<I;){var he=lc((w+I)/2),me=f(s[he]),Te=me!==t,Ue=me===null,je=me===me,lt=ei(me);if(k)var qe=x||je;else ue?qe=je&&(x||Te):V?qe=je&&Te&&(x||!Ue):X?qe=je&&Te&&!Ue&&(x||!lt):Ue||lt?qe=!1:qe=x?me<=c:me<c;qe?w=he+1:I=he}return An(I,ke)}function sp(s,c){for(var f=-1,x=s.length,w=0,I=[];++f<x;){var k=s[f],V=c?c(k):k;if(!f||!Ri(V,X)){var X=V;I[w++]=k===0?0:k}}return I}function op(s){return typeof s=="number"?s:ei(s)?pe:+s}function Qn(s){if(typeof s=="string")return s;if(st(s))return Yt(s,Qn)+"";if(ei(s))return Bd?Bd.call(s):"";var c=s+"";return c=="0"&&1/s==-1/0?"-0":c}function Or(s,c,f){var x=-1,w=Ka,I=s.length,k=!0,V=[],X=V;if(f)k=!1,w=eu;else if(I>=r){var ue=c?null:wy(s);if(ue)return Ja(ue);k=!1,w=jo,X=new as}else X=c?[]:V;e:for(;++x<I;){var he=s[x],me=c?c(he):he;if(he=f||he!==0?he:0,k&&me===me){for(var Te=X.length;Te--;)if(X[Te]===me)continue e;c&&X.push(me),V.push(he)}else w(X,me,f)||(X!==V&&X.push(me),V.push(he))}return V}function wu(s,c){return c=Fr(c,s),s=Up(s,c),s==null||delete s[Xi(_i(c))]}function ap(s,c,f,x){return ia(s,c,f(ls(s,c)),x)}function vc(s,c,f,x){for(var w=s.length,I=x?w:-1;(x?I--:++I<w)&&c(s[I],I,s););return f?gi(s,x?0:I,x?I+1:w):gi(s,x?I+1:0,x?w:I)}function cp(s,c){var f=s;return f instanceof Mt&&(f=f.value()),tu(c,function(x,w){return w.func.apply(w.thisArg,Ir([x],w.args))},f)}function Au(s,c,f){var x=s.length;if(x<2)return x?Or(s[0]):[];for(var w=-1,I=Q(x);++w<x;)for(var k=s[w],V=-1;++V<x;)V!=w&&(I[w]=ea(I[w]||k,s[V],c,f));return Or(yn(I,1),c,f)}function lp(s,c,f){for(var x=-1,w=s.length,I=c.length,k={};++x<w;){var V=x<I?c[x]:t;f(k,s[x],V)}return k}function Ru(s){return rn(s)?s:[]}function Cu(s){return typeof s=="function"?s:$n}function Fr(s,c){return st(s)?s:Bu(s,c)?[s]:Bp(Pt(s))}var gy=pt;function Br(s,c,f){var x=s.length;return f=f===t?x:f,!c&&f>=x?s:gi(s,c,f)}var up=ix||function(s){return xn.clearTimeout(s)};function hp(s,c){if(c)return s.slice();var f=s.length,x=Id?Id(f):new s.constructor(f);return s.copy(x),x}function Pu(s){var c=new s.constructor(s.byteLength);return new rc(c).set(new rc(s)),c}function _y(s,c){var f=c?Pu(s.buffer):s.buffer;return new s.constructor(f,s.byteOffset,s.byteLength)}function vy(s){var c=new s.constructor(s.source,U.exec(s));return c.lastIndex=s.lastIndex,c}function xy(s){return Jo?Ot(Jo.call(s)):{}}function fp(s,c){var f=c?Pu(s.buffer):s.buffer;return new s.constructor(f,s.byteOffset,s.length)}function dp(s,c){if(s!==c){var f=s!==t,x=s===null,w=s===s,I=ei(s),k=c!==t,V=c===null,X=c===c,ue=ei(c);if(!V&&!ue&&!I&&s>c||I&&k&&X&&!V&&!ue||x&&k&&X||!f&&X||!w)return 1;if(!x&&!I&&!ue&&s<c||ue&&f&&w&&!x&&!I||V&&f&&w||!k&&w||!X)return-1}return 0}function yy(s,c,f){for(var x=-1,w=s.criteria,I=c.criteria,k=w.length,V=f.length;++x<k;){var X=dp(w[x],I[x]);if(X){if(x>=V)return X;var ue=f[x];return X*(ue=="desc"?-1:1)}}return s.index-c.index}function pp(s,c,f,x){for(var w=-1,I=s.length,k=f.length,V=-1,X=c.length,ue=fn(I-k,0),he=Q(X+ue),me=!x;++V<X;)he[V]=c[V];for(;++w<k;)(me||w<I)&&(he[f[w]]=s[w]);for(;ue--;)he[V++]=s[w++];return he}function mp(s,c,f,x){for(var w=-1,I=s.length,k=-1,V=f.length,X=-1,ue=c.length,he=fn(I-V,0),me=Q(he+ue),Te=!x;++w<he;)me[w]=s[w];for(var Ue=w;++X<ue;)me[Ue+X]=c[X];for(;++k<V;)(Te||w<I)&&(me[Ue+f[k]]=s[w++]);return me}function Yn(s,c){var f=-1,x=s.length;for(c||(c=Q(x));++f<x;)c[f]=s[f];return c}function Wi(s,c,f,x){var w=!f;f||(f={});for(var I=-1,k=c.length;++I<k;){var V=c[I],X=x?x(f[V],s[V],V,f,s):t;X===t&&(X=s[V]),w?ur(f,V,X):Qo(f,V,X)}return f}function My(s,c){return Wi(s,Fu(s),c)}function Sy(s,c){return Wi(s,Rp(s),c)}function xc(s,c){return function(f,x){var w=st(f)?Av:Wx,I=c?c():{};return w(f,s,Ye(x,2),I)}}function Gs(s){return pt(function(c,f){var x=-1,w=f.length,I=w>1?f[w-1]:t,k=w>2?f[2]:t;for(I=s.length>3&&typeof I=="function"?(w--,I):t,k&&kn(f[0],f[1],k)&&(I=w<3?t:I,w=1),c=Ot(c);++x<w;){var V=f[x];V&&s(c,V,x,I)}return c})}function gp(s,c){return function(f,x){if(f==null)return f;if(!jn(f))return s(f,x);for(var w=f.length,I=c?w:-1,k=Ot(f);(c?I--:++I<w)&&x(k[I],I,k)!==!1;);return f}}function _p(s){return function(c,f,x){for(var w=-1,I=Ot(c),k=x(c),V=k.length;V--;){var X=k[s?V:++w];if(f(I[X],X,I)===!1)break}return c}}function Ey(s,c,f){var x=c&_,w=ra(s);function I(){var k=this&&this!==xn&&this instanceof I?w:s;return k.apply(x?f:this,arguments)}return I}function vp(s){return function(c){c=Pt(c);var f=Ns(c)?wi(c):t,x=f?f[0]:c.charAt(0),w=f?Br(f,1).join(""):c.slice(1);return x[s]()+w}}function Vs(s){return function(c){return tu(gm(mm(c).replace(dv,"")),s,"")}}function ra(s){return function(){var c=arguments;switch(c.length){case 0:return new s;case 1:return new s(c[0]);case 2:return new s(c[0],c[1]);case 3:return new s(c[0],c[1],c[2]);case 4:return new s(c[0],c[1],c[2],c[3]);case 5:return new s(c[0],c[1],c[2],c[3],c[4]);case 6:return new s(c[0],c[1],c[2],c[3],c[4],c[5]);case 7:return new s(c[0],c[1],c[2],c[3],c[4],c[5],c[6])}var f=Hs(s.prototype),x=s.apply(f,c);return $t(x)?x:f}}function Ty(s,c,f){var x=ra(s);function w(){for(var I=arguments.length,k=Q(I),V=I,X=Ws(w);V--;)k[V]=arguments[V];var ue=I<3&&k[0]!==X&&k[I-1]!==X?[]:Dr(k,X);if(I-=ue.length,I<f)return Ep(s,c,yc,w.placeholder,t,k,ue,t,t,f-I);var he=this&&this!==xn&&this instanceof w?x:s;return Zn(he,this,k)}return w}function xp(s){return function(c,f,x){var w=Ot(c);if(!jn(c)){var I=Ye(f,3);c=gn(c),f=function(V){return I(w[V],V,w)}}var k=s(c,f,x);return k>-1?w[I?c[k]:k]:t}}function yp(s){return fr(function(c){var f=c.length,x=f,w=pi.prototype.thru;for(s&&c.reverse();x--;){var I=c[x];if(typeof I!="function")throw new di(a);if(w&&!k&&Tc(I)=="wrapper")var k=new pi([],!0)}for(x=k?x:f;++x<f;){I=c[x];var V=Tc(I),X=V=="wrapper"?Nu(I):t;X&&zu(X[0])&&X[1]==(D|b|B|C)&&!X[4].length&&X[9]==1?k=k[Tc(X[0])].apply(k,X[3]):k=I.length==1&&zu(I)?k[V]():k.thru(I)}return function(){var ue=arguments,he=ue[0];if(k&&ue.length==1&&st(he))return k.plant(he).value();for(var me=0,Te=f?c[me].apply(this,ue):he;++me<f;)Te=c[me].call(this,Te);return Te}})}function yc(s,c,f,x,w,I,k,V,X,ue){var he=c&D,me=c&_,Te=c&v,Ue=c&(b|A),je=c&E,lt=Te?t:ra(s);function qe(){for(var xt=arguments.length,bt=Q(xt),ti=xt;ti--;)bt[ti]=arguments[ti];if(Ue)var Hn=Ws(qe),ni=Ov(bt,Hn);if(x&&(bt=pp(bt,x,w,Ue)),I&&(bt=mp(bt,I,k,Ue)),xt-=ni,Ue&&xt<ue){var sn=Dr(bt,Hn);return Ep(s,c,yc,qe.placeholder,f,bt,sn,V,X,ue-xt)}var Ci=me?f:this,gr=Te?Ci[s]:s;return xt=bt.length,V?bt=Wy(bt,V):je&&xt>1&&bt.reverse(),he&&X<xt&&(bt.length=X),this&&this!==xn&&this instanceof qe&&(gr=lt||ra(gr)),gr.apply(Ci,bt)}return qe}function Mp(s,c){return function(f,x){return Jx(f,s,c(x),{})}}function Mc(s,c){return function(f,x){var w;if(f===t&&x===t)return c;if(f!==t&&(w=f),x!==t){if(w===t)return x;typeof f=="string"||typeof x=="string"?(f=Qn(f),x=Qn(x)):(f=op(f),x=op(x)),w=s(f,x)}return w}}function Lu(s){return fr(function(c){return c=Yt(c,Jn(Ye())),pt(function(f){var x=this;return s(c,function(w){return Zn(w,x,f)})})})}function Sc(s,c){c=c===t?" ":Qn(c);var f=c.length;if(f<2)return f?Tu(c,s):c;var x=Tu(c,cc(s/Os(c)));return Ns(c)?Br(wi(x),0,s).join(""):x.slice(0,s)}function by(s,c,f,x){var w=c&_,I=ra(s);function k(){for(var V=-1,X=arguments.length,ue=-1,he=x.length,me=Q(he+X),Te=this&&this!==xn&&this instanceof k?I:s;++ue<he;)me[ue]=x[ue];for(;X--;)me[ue++]=arguments[++V];return Zn(Te,w?f:this,me)}return k}function Sp(s){return function(c,f,x){return x&&typeof x!="number"&&kn(c,f,x)&&(f=x=t),c=mr(c),f===t?(f=c,c=0):f=mr(f),x=x===t?c<f?1:-1:mr(x),uy(c,f,x,s)}}function Ec(s){return function(c,f){return typeof c=="string"&&typeof f=="string"||(c=vi(c),f=vi(f)),s(c,f)}}function Ep(s,c,f,x,w,I,k,V,X,ue){var he=c&b,me=he?k:t,Te=he?t:k,Ue=he?I:t,je=he?t:I;c|=he?B:N,c&=~(he?N:B),c&R||(c&=-4);var lt=[s,c,w,Ue,me,je,Te,V,X,ue],qe=f.apply(t,lt);return zu(s)&&Np(qe,lt),qe.placeholder=x,Op(qe,s,c)}function Iu(s){var c=hn[s];return function(f,x){if(f=vi(f),x=x==null?0:An(at(x),292),x&&Od(f)){var w=(Pt(f)+"e").split("e"),I=c(w[0]+"e"+(+w[1]+x));return w=(Pt(I)+"e").split("e"),+(w[0]+"e"+(+w[1]-x))}return c(f)}}var wy=zs&&1/Ja(new zs([,-0]))[1]==se?function(s){return new zs(s)}:eh;function Tp(s){return function(c){var f=Rn(c);return f==mt?cu(c):f==de?Vv(c):Nv(c,s(c))}}function hr(s,c,f,x,w,I,k,V){var X=c&v;if(!X&&typeof s!="function")throw new di(a);var ue=x?x.length:0;if(ue||(c&=-97,x=w=t),k=k===t?k:fn(at(k),0),V=V===t?V:at(V),ue-=w?w.length:0,c&N){var he=x,me=w;x=w=t}var Te=X?t:Nu(s),Ue=[s,c,f,x,w,he,me,I,k,V];if(Te&&Hy(Ue,Te),s=Ue[0],c=Ue[1],f=Ue[2],x=Ue[3],w=Ue[4],V=Ue[9]=Ue[9]===t?X?0:s.length:fn(Ue[9]-ue,0),!V&&c&(b|A)&&(c&=-25),!c||c==_)var je=Ey(s,c,f);else c==b||c==A?je=Ty(s,c,V):(c==B||c==(_|B))&&!w.length?je=by(s,c,f,x):je=yc.apply(t,Ue);var lt=Te?rp:Np;return Op(lt(je,Ue),s,c)}function bp(s,c,f,x){return s===t||Ri(s,Bs[f])&&!It.call(x,f)?c:s}function wp(s,c,f,x,w,I){return $t(s)&&$t(c)&&(I.set(c,s),gc(s,c,t,wp,I),I.delete(c)),s}function Ay(s){return aa(s)?t:s}function Ap(s,c,f,x,w,I){var k=f&y,V=s.length,X=c.length;if(V!=X&&!(k&&X>V))return!1;var ue=I.get(s),he=I.get(c);if(ue&&he)return ue==c&&he==s;var me=-1,Te=!0,Ue=f&S?new as:t;for(I.set(s,c),I.set(c,s);++me<V;){var je=s[me],lt=c[me];if(x)var qe=k?x(lt,je,me,c,s,I):x(je,lt,me,s,c,I);if(qe!==t){if(qe)continue;Te=!1;break}if(Ue){if(!nu(c,function(xt,bt){if(!jo(Ue,bt)&&(je===xt||w(je,xt,f,x,I)))return Ue.push(bt)})){Te=!1;break}}else if(!(je===lt||w(je,lt,f,x,I))){Te=!1;break}}return I.delete(s),I.delete(c),Te}function Ry(s,c,f,x,w,I,k){switch(f){case we:if(s.byteLength!=c.byteLength||s.byteOffset!=c.byteOffset)return!1;s=s.buffer,c=c.buffer;case xe:return!(s.byteLength!=c.byteLength||!I(new rc(s),new rc(c)));case ze:case Ve:case We:return Ri(+s,+c);case q:return s.name==c.name&&s.message==c.message;case le:case ge:return s==c+"";case mt:var V=cu;case de:var X=x&y;if(V||(V=Ja),s.size!=c.size&&!X)return!1;var ue=k.get(s);if(ue)return ue==c;x|=S,k.set(s,c);var he=Ap(V(s),V(c),x,w,I,k);return k.delete(s),he;case He:if(Jo)return Jo.call(s)==Jo.call(c)}return!1}function Cy(s,c,f,x,w,I){var k=f&y,V=Du(s),X=V.length,ue=Du(c),he=ue.length;if(X!=he&&!k)return!1;for(var me=X;me--;){var Te=V[me];if(!(k?Te in c:It.call(c,Te)))return!1}var Ue=I.get(s),je=I.get(c);if(Ue&&je)return Ue==c&&je==s;var lt=!0;I.set(s,c),I.set(c,s);for(var qe=k;++me<X;){Te=V[me];var xt=s[Te],bt=c[Te];if(x)var ti=k?x(bt,xt,Te,c,s,I):x(xt,bt,Te,s,c,I);if(!(ti===t?xt===bt||w(xt,bt,f,x,I):ti)){lt=!1;break}qe||(qe=Te=="constructor")}if(lt&&!qe){var Hn=s.constructor,ni=c.constructor;Hn!=ni&&"constructor"in s&&"constructor"in c&&!(typeof Hn=="function"&&Hn instanceof Hn&&typeof ni=="function"&&ni instanceof ni)&&(lt=!1)}return I.delete(s),I.delete(c),lt}function fr(s){return Hu(Dp(s,t,Gp),s+"")}function Du(s){return jd(s,gn,Fu)}function Uu(s){return jd(s,qn,Rp)}var Nu=uc?function(s){return uc.get(s)}:eh;function Tc(s){for(var c=s.name+"",f=ks[c],x=It.call(ks,c)?f.length:0;x--;){var w=f[x],I=w.func;if(I==null||I==s)return w.name}return c}function Ws(s){var c=It.call(L,"placeholder")?L:s;return c.placeholder}function Ye(){var s=L.iteratee||Ju;return s=s===Ju?Kd:s,arguments.length?s(arguments[0],arguments[1]):s}function bc(s,c){var f=s.__data__;return Fy(c)?f[typeof c=="string"?"string":"hash"]:f.map}function Ou(s){for(var c=gn(s),f=c.length;f--;){var x=c[f],w=s[x];c[f]=[x,w,Lp(w)]}return c}function us(s,c){var f=kv(s,c);return $d(f)?f:t}function Py(s){var c=It.call(s,ss),f=s[ss];try{s[ss]=t;var x=!0}catch{}var w=nc.call(s);return x&&(c?s[ss]=f:delete s[ss]),w}var Fu=uu?function(s){return s==null?[]:(s=Ot(s),Lr(uu(s),function(c){return Ud.call(s,c)}))}:th,Rp=uu?function(s){for(var c=[];s;)Ir(c,Fu(s)),s=sc(s);return c}:th,Rn=zn;(hu&&Rn(new hu(new ArrayBuffer(1)))!=we||$o&&Rn(new $o)!=mt||fu&&Rn(fu.resolve())!=P||zs&&Rn(new zs)!=de||Ko&&Rn(new Ko)!=De)&&(Rn=function(s){var c=zn(s),f=c==z?s.constructor:t,x=f?hs(f):"";if(x)switch(x){case fx:return we;case dx:return mt;case px:return P;case mx:return de;case gx:return De}return c});function Ly(s,c,f){for(var x=-1,w=f.length;++x<w;){var I=f[x],k=I.size;switch(I.type){case"drop":s+=k;break;case"dropRight":c-=k;break;case"take":c=An(c,s+k);break;case"takeRight":s=fn(s,c-k);break}}return{start:s,end:c}}function Iy(s){var c=s.match(Is);return c?c[1].split(ja):[]}function Cp(s,c,f){c=Fr(c,s);for(var x=-1,w=c.length,I=!1;++x<w;){var k=Xi(c[x]);if(!(I=s!=null&&f(s,k)))break;s=s[k]}return I||++x!=w?I:(w=s==null?0:s.length,!!w&&Ic(w)&&dr(k,w)&&(st(s)||fs(s)))}function Dy(s){var c=s.length,f=new s.constructor(c);return c&&typeof s[0]=="string"&&It.call(s,"index")&&(f.index=s.index,f.input=s.input),f}function Pp(s){return typeof s.constructor=="function"&&!sa(s)?Hs(sc(s)):{}}function Uy(s,c,f){var x=s.constructor;switch(c){case xe:return Pu(s);case ze:case Ve:return new x(+s);case we:return _y(s,f);case Ke:case Le:case Ie:case ct:case ft:case Et:case _t:case Tt:case Ne:return fp(s,f);case mt:return new x;case We:case ge:return new x(s);case le:return vy(s);case de:return new x;case He:return xy(s)}}function Ny(s,c){var f=c.length;if(!f)return s;var x=f-1;return c[x]=(f>1?"& ":"")+c[x],c=c.join(f>2?", ":" "),s.replace(Ya,`{
3804
+ */var NL=Ra.exports,S_;function OL(){return S_||(S_=1,function(i,e){(function(){var t,n="4.17.21",r=200,o="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",a="Expected a function",l="Invalid `variable` option passed into `_.template`",u="__lodash_hash_undefined__",h=500,d="__lodash_placeholder__",p=1,m=2,g=4,y=1,S=2,_=1,v=2,R=4,b=8,A=16,B=32,N=64,D=128,C=256,E=512,M=30,O="...",H=800,G=16,Y=1,$=2,re=3,se=1/0,K=9007199254740991,ae=17976931348623157e292,pe=NaN,ve=4294967295,ke=ve-1,Ze=ve>>>1,te=[["ary",D],["bind",_],["bindKey",v],["curry",b],["curryRight",A],["flip",E],["partial",B],["partialRight",N],["rearg",C]],fe="[object Arguments]",Ee="[object Array]",Me="[object AsyncFunction]",ze="[object Boolean]",Ve="[object Date]",it="[object DOMException]",q="[object Error]",$e="[object Function]",Fe="[object GeneratorFunction]",mt="[object Map]",We="[object Number]",At="[object Null]",z="[object Object]",P="[object Promise]",ie="[object Proxy]",le="[object RegExp]",de="[object Set]",ge="[object String]",He="[object Symbol]",_e="[object Undefined]",De="[object WeakMap]",Xe="[object WeakSet]",xe="[object ArrayBuffer]",we="[object DataView]",Ke="[object Float32Array]",Le="[object Float64Array]",Ie="[object Int8Array]",ct="[object Int16Array]",ft="[object Int32Array]",Et="[object Uint8Array]",_t="[object Uint8ClampedArray]",Tt="[object Uint16Array]",Ne="[object Uint32Array]",T=/\b__p \+= '';/g,Z=/\b(__p \+=) '' \+/g,ce=/(__e\(.*?\)|\b__t\)) \+\n'';/g,ye=/&(?:amp|lt|gt|quot|#39);/g,Re=/[&<>"']/g,vt=RegExp(ye.source),dt=RegExp(Re.source),zt=/<%-([\s\S]+?)%>/g,ln=/<%([\s\S]+?)%>/g,Rt=/<%=([\s\S]+?)%>/g,Zt=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Jt=/^\w*$/,Fn=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,bn=/[\\^$.*+?()[\]{}|]/g,ki=RegExp(bn.source),Hi=/^\s+/,ar=/\s/,Ya=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,Is=/\{\n\/\* \[wrapped with (.+)\] \*/,ja=/,? & /,qa=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,Yl=/[()=,{}\[\]\/\s]/,jl=/\\(\\)?/g,ql=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,U=/\w*$/,j=/^[-+]0x[0-9a-f]+$/i,ee=/^0b[01]+$/i,ne=/^\[object .+?Constructor\]$/,J=/^0o[0-7]+$/i,Ae=/^(?:0|[1-9]\d*)$/,Be=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Ge=/($^)/,Je=/['\n\r\u2028\u2029\\]/g,et="\\ud800-\\udfff",tt="\\u0300-\\u036f",rt="\\ufe20-\\ufe2f",qt="\\u20d0-\\u20ff",wn=tt+rt+qt,nn="\\u2700-\\u27bf",ui="a-z\\xdf-\\xf6\\xf8-\\xff",Gt="\\xac\\xb1\\xd7\\xf7",ot="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",Vo="\\u2000-\\u206f",kt=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",Gi="A-Z\\xc0-\\xd6\\xd8-\\xde",Wo="\\ufe0e\\ufe0f",Cr=Gt+ot+Vo+kt,is="['’]",mn="["+et+"]",bi="["+Cr+"]",Pr="["+wn+"]",Bn="\\d+",Xo="["+nn+"]",$a="["+ui+"]",Yo="[^"+et+Cr+Bn+nn+ui+Gi+"]",$l="\\ud83c[\\udffb-\\udfff]",ov="(?:"+Pr+"|"+$l+")",sd="[^"+et+"]",Kl="(?:\\ud83c[\\udde6-\\uddff]){2}",Zl="[\\ud800-\\udbff][\\udc00-\\udfff]",Ds="["+Gi+"]",od="\\u200d",ad="(?:"+$a+"|"+Yo+")",av="(?:"+Ds+"|"+Yo+")",cd="(?:"+is+"(?:d|ll|m|re|s|t|ve))?",ld="(?:"+is+"(?:D|LL|M|RE|S|T|VE))?",ud=ov+"?",hd="["+Wo+"]?",cv="(?:"+od+"(?:"+[sd,Kl,Zl].join("|")+")"+hd+ud+")*",lv="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",uv="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",fd=hd+ud+cv,hv="(?:"+[Xo,Kl,Zl].join("|")+")"+fd,fv="(?:"+[sd+Pr+"?",Pr,Kl,Zl,mn].join("|")+")",dv=RegExp(is,"g"),pv=RegExp(Pr,"g"),Jl=RegExp($l+"(?="+$l+")|"+fv+fd,"g"),mv=RegExp([Ds+"?"+$a+"+"+cd+"(?="+[bi,Ds,"$"].join("|")+")",av+"+"+ld+"(?="+[bi,Ds+ad,"$"].join("|")+")",Ds+"?"+ad+"+"+cd,Ds+"+"+ld,uv,lv,Bn,hv].join("|"),"g"),gv=RegExp("["+od+et+wn+Wo+"]"),_v=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,vv=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],xv=-1,Vt={};Vt[Ke]=Vt[Le]=Vt[Ie]=Vt[ct]=Vt[ft]=Vt[Et]=Vt[_t]=Vt[Tt]=Vt[Ne]=!0,Vt[fe]=Vt[Ee]=Vt[xe]=Vt[ze]=Vt[we]=Vt[Ve]=Vt[q]=Vt[$e]=Vt[mt]=Vt[We]=Vt[z]=Vt[le]=Vt[de]=Vt[ge]=Vt[De]=!1;var Ht={};Ht[fe]=Ht[Ee]=Ht[xe]=Ht[we]=Ht[ze]=Ht[Ve]=Ht[Ke]=Ht[Le]=Ht[Ie]=Ht[ct]=Ht[ft]=Ht[mt]=Ht[We]=Ht[z]=Ht[le]=Ht[de]=Ht[ge]=Ht[He]=Ht[Et]=Ht[_t]=Ht[Tt]=Ht[Ne]=!0,Ht[q]=Ht[$e]=Ht[De]=!1;var yv={À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",Ç:"C",ç:"c",Ð:"D",ð:"d",È:"E",É:"E",Ê:"E",Ë:"E",è:"e",é:"e",ê:"e",ë:"e",Ì:"I",Í:"I",Î:"I",Ï:"I",ì:"i",í:"i",î:"i",ï:"i",Ñ:"N",ñ:"n",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ø:"O",ò:"o",ó:"o",ô:"o",õ:"o",ö:"o",ø:"o",Ù:"U",Ú:"U",Û:"U",Ü:"U",ù:"u",ú:"u",û:"u",ü:"u",Ý:"Y",ý:"y",ÿ:"y",Æ:"Ae",æ:"ae",Þ:"Th",þ:"th",ß:"ss",Ā:"A",Ă:"A",Ą:"A",ā:"a",ă:"a",ą:"a",Ć:"C",Ĉ:"C",Ċ:"C",Č:"C",ć:"c",ĉ:"c",ċ:"c",č:"c",Ď:"D",Đ:"D",ď:"d",đ:"d",Ē:"E",Ĕ:"E",Ė:"E",Ę:"E",Ě:"E",ē:"e",ĕ:"e",ė:"e",ę:"e",ě:"e",Ĝ:"G",Ğ:"G",Ġ:"G",Ģ:"G",ĝ:"g",ğ:"g",ġ:"g",ģ:"g",Ĥ:"H",Ħ:"H",ĥ:"h",ħ:"h",Ĩ:"I",Ī:"I",Ĭ:"I",Į:"I",İ:"I",ĩ:"i",ī:"i",ĭ:"i",į:"i",ı:"i",Ĵ:"J",ĵ:"j",Ķ:"K",ķ:"k",ĸ:"k",Ĺ:"L",Ļ:"L",Ľ:"L",Ŀ:"L",Ł:"L",ĺ:"l",ļ:"l",ľ:"l",ŀ:"l",ł:"l",Ń:"N",Ņ:"N",Ň:"N",Ŋ:"N",ń:"n",ņ:"n",ň:"n",ŋ:"n",Ō:"O",Ŏ:"O",Ő:"O",ō:"o",ŏ:"o",ő:"o",Ŕ:"R",Ŗ:"R",Ř:"R",ŕ:"r",ŗ:"r",ř:"r",Ś:"S",Ŝ:"S",Ş:"S",Š:"S",ś:"s",ŝ:"s",ş:"s",š:"s",Ţ:"T",Ť:"T",Ŧ:"T",ţ:"t",ť:"t",ŧ:"t",Ũ:"U",Ū:"U",Ŭ:"U",Ů:"U",Ű:"U",Ų:"U",ũ:"u",ū:"u",ŭ:"u",ů:"u",ű:"u",ų:"u",Ŵ:"W",ŵ:"w",Ŷ:"Y",ŷ:"y",Ÿ:"Y",Ź:"Z",Ż:"Z",Ž:"Z",ź:"z",ż:"z",ž:"z",IJ:"IJ",ij:"ij",Œ:"Oe",œ:"oe",ʼn:"'n",ſ:"s"},Mv={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},Sv={"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#39;":"'"},Ev={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Tv=parseFloat,bv=parseInt,dd=typeof pl=="object"&&pl&&pl.Object===Object&&pl,wv=typeof self=="object"&&self&&self.Object===Object&&self,xn=dd||wv||Function("return this")(),Ql=e&&!e.nodeType&&e,rs=Ql&&!0&&i&&!i.nodeType&&i,pd=rs&&rs.exports===Ql,eu=pd&&dd.process,hi=function(){try{var W=rs&&rs.require&&rs.require("util").types;return W||eu&&eu.binding&&eu.binding("util")}catch{}}(),md=hi&&hi.isArrayBuffer,gd=hi&&hi.isDate,_d=hi&&hi.isMap,vd=hi&&hi.isRegExp,xd=hi&&hi.isSet,yd=hi&&hi.isTypedArray;function Zn(W,oe,Q){switch(Q.length){case 0:return W.call(oe);case 1:return W.call(oe,Q[0]);case 2:return W.call(oe,Q[0],Q[1]);case 3:return W.call(oe,Q[0],Q[1],Q[2])}return W.apply(oe,Q)}function Av(W,oe,Q,Ce){for(var nt=-1,Ct=W==null?0:W.length;++nt<Ct;){var hn=W[nt];oe(Ce,hn,Q(hn),W)}return Ce}function fi(W,oe){for(var Q=-1,Ce=W==null?0:W.length;++Q<Ce&&oe(W[Q],Q,W)!==!1;);return W}function Rv(W,oe){for(var Q=W==null?0:W.length;Q--&&oe(W[Q],Q,W)!==!1;);return W}function Md(W,oe){for(var Q=-1,Ce=W==null?0:W.length;++Q<Ce;)if(!oe(W[Q],Q,W))return!1;return!0}function Lr(W,oe){for(var Q=-1,Ce=W==null?0:W.length,nt=0,Ct=[];++Q<Ce;){var hn=W[Q];oe(hn,Q,W)&&(Ct[nt++]=hn)}return Ct}function Ka(W,oe){var Q=W==null?0:W.length;return!!Q&&Us(W,oe,0)>-1}function tu(W,oe,Q){for(var Ce=-1,nt=W==null?0:W.length;++Ce<nt;)if(Q(oe,W[Ce]))return!0;return!1}function Yt(W,oe){for(var Q=-1,Ce=W==null?0:W.length,nt=Array(Ce);++Q<Ce;)nt[Q]=oe(W[Q],Q,W);return nt}function Ir(W,oe){for(var Q=-1,Ce=oe.length,nt=W.length;++Q<Ce;)W[nt+Q]=oe[Q];return W}function nu(W,oe,Q,Ce){var nt=-1,Ct=W==null?0:W.length;for(Ce&&Ct&&(Q=W[++nt]);++nt<Ct;)Q=oe(Q,W[nt],nt,W);return Q}function Cv(W,oe,Q,Ce){var nt=W==null?0:W.length;for(Ce&&nt&&(Q=W[--nt]);nt--;)Q=oe(Q,W[nt],nt,W);return Q}function iu(W,oe){for(var Q=-1,Ce=W==null?0:W.length;++Q<Ce;)if(oe(W[Q],Q,W))return!0;return!1}var Pv=ru("length");function Lv(W){return W.split("")}function Iv(W){return W.match(qa)||[]}function Sd(W,oe,Q){var Ce;return Q(W,function(nt,Ct,hn){if(oe(nt,Ct,hn))return Ce=Ct,!1}),Ce}function Za(W,oe,Q,Ce){for(var nt=W.length,Ct=Q+(Ce?1:-1);Ce?Ct--:++Ct<nt;)if(oe(W[Ct],Ct,W))return Ct;return-1}function Us(W,oe,Q){return oe===oe?Wv(W,oe,Q):Za(W,Ed,Q)}function Dv(W,oe,Q,Ce){for(var nt=Q-1,Ct=W.length;++nt<Ct;)if(Ce(W[nt],oe))return nt;return-1}function Ed(W){return W!==W}function Td(W,oe){var Q=W==null?0:W.length;return Q?ou(W,oe)/Q:pe}function ru(W){return function(oe){return oe==null?t:oe[W]}}function su(W){return function(oe){return W==null?t:W[oe]}}function bd(W,oe,Q,Ce,nt){return nt(W,function(Ct,hn,Ot){Q=Ce?(Ce=!1,Ct):oe(Q,Ct,hn,Ot)}),Q}function Uv(W,oe){var Q=W.length;for(W.sort(oe);Q--;)W[Q]=W[Q].value;return W}function ou(W,oe){for(var Q,Ce=-1,nt=W.length;++Ce<nt;){var Ct=oe(W[Ce]);Ct!==t&&(Q=Q===t?Ct:Q+Ct)}return Q}function au(W,oe){for(var Q=-1,Ce=Array(W);++Q<W;)Ce[Q]=oe(Q);return Ce}function Nv(W,oe){return Yt(oe,function(Q){return[Q,W[Q]]})}function wd(W){return W&&W.slice(0,Pd(W)+1).replace(Hi,"")}function Jn(W){return function(oe){return W(oe)}}function cu(W,oe){return Yt(oe,function(Q){return W[Q]})}function jo(W,oe){return W.has(oe)}function Ad(W,oe){for(var Q=-1,Ce=W.length;++Q<Ce&&Us(oe,W[Q],0)>-1;);return Q}function Rd(W,oe){for(var Q=W.length;Q--&&Us(oe,W[Q],0)>-1;);return Q}function Ov(W,oe){for(var Q=W.length,Ce=0;Q--;)W[Q]===oe&&++Ce;return Ce}var Fv=su(yv),Bv=su(Mv);function zv(W){return"\\"+Ev[W]}function kv(W,oe){return W==null?t:W[oe]}function Ns(W){return gv.test(W)}function Hv(W){return _v.test(W)}function Gv(W){for(var oe,Q=[];!(oe=W.next()).done;)Q.push(oe.value);return Q}function lu(W){var oe=-1,Q=Array(W.size);return W.forEach(function(Ce,nt){Q[++oe]=[nt,Ce]}),Q}function Cd(W,oe){return function(Q){return W(oe(Q))}}function Dr(W,oe){for(var Q=-1,Ce=W.length,nt=0,Ct=[];++Q<Ce;){var hn=W[Q];(hn===oe||hn===d)&&(W[Q]=d,Ct[nt++]=Q)}return Ct}function Ja(W){var oe=-1,Q=Array(W.size);return W.forEach(function(Ce){Q[++oe]=Ce}),Q}function Vv(W){var oe=-1,Q=Array(W.size);return W.forEach(function(Ce){Q[++oe]=[Ce,Ce]}),Q}function Wv(W,oe,Q){for(var Ce=Q-1,nt=W.length;++Ce<nt;)if(W[Ce]===oe)return Ce;return-1}function Xv(W,oe,Q){for(var Ce=Q+1;Ce--;)if(W[Ce]===oe)return Ce;return Ce}function Os(W){return Ns(W)?jv(W):Pv(W)}function wi(W){return Ns(W)?qv(W):Lv(W)}function Pd(W){for(var oe=W.length;oe--&&ar.test(W.charAt(oe)););return oe}var Yv=su(Sv);function jv(W){for(var oe=Jl.lastIndex=0;Jl.test(W);)++oe;return oe}function qv(W){return W.match(Jl)||[]}function $v(W){return W.match(mv)||[]}var Kv=function W(oe){oe=oe==null?xn:Fs.defaults(xn.Object(),oe,Fs.pick(xn,vv));var Q=oe.Array,Ce=oe.Date,nt=oe.Error,Ct=oe.Function,hn=oe.Math,Ot=oe.Object,uu=oe.RegExp,Zv=oe.String,di=oe.TypeError,Qa=Q.prototype,Jv=Ct.prototype,Bs=Ot.prototype,ec=oe["__core-js_shared__"],tc=Jv.toString,It=Bs.hasOwnProperty,Qv=0,Ld=function(){var s=/[^.]+$/.exec(ec&&ec.keys&&ec.keys.IE_PROTO||"");return s?"Symbol(src)_1."+s:""}(),nc=Bs.toString,ex=tc.call(Ot),tx=xn._,nx=uu("^"+tc.call(It).replace(bn,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),ic=pd?oe.Buffer:t,Ur=oe.Symbol,rc=oe.Uint8Array,Id=ic?ic.allocUnsafe:t,sc=Cd(Ot.getPrototypeOf,Ot),Dd=Ot.create,Ud=Bs.propertyIsEnumerable,oc=Qa.splice,Nd=Ur?Ur.isConcatSpreadable:t,qo=Ur?Ur.iterator:t,ss=Ur?Ur.toStringTag:t,ac=function(){try{var s=us(Ot,"defineProperty");return s({},"",{}),s}catch{}}(),ix=oe.clearTimeout!==xn.clearTimeout&&oe.clearTimeout,rx=Ce&&Ce.now!==xn.Date.now&&Ce.now,sx=oe.setTimeout!==xn.setTimeout&&oe.setTimeout,cc=hn.ceil,lc=hn.floor,hu=Ot.getOwnPropertySymbols,ox=ic?ic.isBuffer:t,Od=oe.isFinite,ax=Qa.join,cx=Cd(Ot.keys,Ot),fn=hn.max,An=hn.min,lx=Ce.now,ux=oe.parseInt,Fd=hn.random,hx=Qa.reverse,fu=us(oe,"DataView"),$o=us(oe,"Map"),du=us(oe,"Promise"),zs=us(oe,"Set"),Ko=us(oe,"WeakMap"),Zo=us(Ot,"create"),uc=Ko&&new Ko,ks={},fx=hs(fu),dx=hs($o),px=hs(du),mx=hs(zs),gx=hs(Ko),hc=Ur?Ur.prototype:t,Jo=hc?hc.valueOf:t,Bd=hc?hc.toString:t;function L(s){if(Qt(s)&&!st(s)&&!(s instanceof Mt)){if(s instanceof pi)return s;if(It.call(s,"__wrapped__"))return zp(s)}return new pi(s)}var Hs=function(){function s(){}return function(c){if(!$t(c))return{};if(Dd)return Dd(c);s.prototype=c;var f=new s;return s.prototype=t,f}}();function fc(){}function pi(s,c){this.__wrapped__=s,this.__actions__=[],this.__chain__=!!c,this.__index__=0,this.__values__=t}L.templateSettings={escape:zt,evaluate:ln,interpolate:Rt,variable:"",imports:{_:L}},L.prototype=fc.prototype,L.prototype.constructor=L,pi.prototype=Hs(fc.prototype),pi.prototype.constructor=pi;function Mt(s){this.__wrapped__=s,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=ve,this.__views__=[]}function _x(){var s=new Mt(this.__wrapped__);return s.__actions__=Yn(this.__actions__),s.__dir__=this.__dir__,s.__filtered__=this.__filtered__,s.__iteratees__=Yn(this.__iteratees__),s.__takeCount__=this.__takeCount__,s.__views__=Yn(this.__views__),s}function vx(){if(this.__filtered__){var s=new Mt(this);s.__dir__=-1,s.__filtered__=!0}else s=this.clone(),s.__dir__*=-1;return s}function xx(){var s=this.__wrapped__.value(),c=this.__dir__,f=st(s),x=c<0,w=f?s.length:0,I=Ly(0,w,this.__views__),k=I.start,V=I.end,X=V-k,ue=x?V:k-1,he=this.__iteratees__,me=he.length,Te=0,Ue=An(X,this.__takeCount__);if(!f||!x&&w==X&&Ue==X)return cp(s,this.__actions__);var je=[];e:for(;X--&&Te<Ue;){ue+=c;for(var lt=-1,qe=s[ue];++lt<me;){var xt=he[lt],bt=xt.iteratee,ti=xt.type,Hn=bt(qe);if(ti==$)qe=Hn;else if(!Hn){if(ti==Y)continue e;break e}}je[Te++]=qe}return je}Mt.prototype=Hs(fc.prototype),Mt.prototype.constructor=Mt;function os(s){var c=-1,f=s==null?0:s.length;for(this.clear();++c<f;){var x=s[c];this.set(x[0],x[1])}}function yx(){this.__data__=Zo?Zo(null):{},this.size=0}function Mx(s){var c=this.has(s)&&delete this.__data__[s];return this.size-=c?1:0,c}function Sx(s){var c=this.__data__;if(Zo){var f=c[s];return f===u?t:f}return It.call(c,s)?c[s]:t}function Ex(s){var c=this.__data__;return Zo?c[s]!==t:It.call(c,s)}function Tx(s,c){var f=this.__data__;return this.size+=this.has(s)?0:1,f[s]=Zo&&c===t?u:c,this}os.prototype.clear=yx,os.prototype.delete=Mx,os.prototype.get=Sx,os.prototype.has=Ex,os.prototype.set=Tx;function cr(s){var c=-1,f=s==null?0:s.length;for(this.clear();++c<f;){var x=s[c];this.set(x[0],x[1])}}function bx(){this.__data__=[],this.size=0}function wx(s){var c=this.__data__,f=dc(c,s);if(f<0)return!1;var x=c.length-1;return f==x?c.pop():oc.call(c,f,1),--this.size,!0}function Ax(s){var c=this.__data__,f=dc(c,s);return f<0?t:c[f][1]}function Rx(s){return dc(this.__data__,s)>-1}function Cx(s,c){var f=this.__data__,x=dc(f,s);return x<0?(++this.size,f.push([s,c])):f[x][1]=c,this}cr.prototype.clear=bx,cr.prototype.delete=wx,cr.prototype.get=Ax,cr.prototype.has=Rx,cr.prototype.set=Cx;function lr(s){var c=-1,f=s==null?0:s.length;for(this.clear();++c<f;){var x=s[c];this.set(x[0],x[1])}}function Px(){this.size=0,this.__data__={hash:new os,map:new($o||cr),string:new os}}function Lx(s){var c=bc(this,s).delete(s);return this.size-=c?1:0,c}function Ix(s){return bc(this,s).get(s)}function Dx(s){return bc(this,s).has(s)}function Ux(s,c){var f=bc(this,s),x=f.size;return f.set(s,c),this.size+=f.size==x?0:1,this}lr.prototype.clear=Px,lr.prototype.delete=Lx,lr.prototype.get=Ix,lr.prototype.has=Dx,lr.prototype.set=Ux;function as(s){var c=-1,f=s==null?0:s.length;for(this.__data__=new lr;++c<f;)this.add(s[c])}function Nx(s){return this.__data__.set(s,u),this}function Ox(s){return this.__data__.has(s)}as.prototype.add=as.prototype.push=Nx,as.prototype.has=Ox;function Ai(s){var c=this.__data__=new cr(s);this.size=c.size}function Fx(){this.__data__=new cr,this.size=0}function Bx(s){var c=this.__data__,f=c.delete(s);return this.size=c.size,f}function zx(s){return this.__data__.get(s)}function kx(s){return this.__data__.has(s)}function Hx(s,c){var f=this.__data__;if(f instanceof cr){var x=f.__data__;if(!$o||x.length<r-1)return x.push([s,c]),this.size=++f.size,this;f=this.__data__=new lr(x)}return f.set(s,c),this.size=f.size,this}Ai.prototype.clear=Fx,Ai.prototype.delete=Bx,Ai.prototype.get=zx,Ai.prototype.has=kx,Ai.prototype.set=Hx;function zd(s,c){var f=st(s),x=!f&&fs(s),w=!f&&!x&&zr(s),I=!f&&!x&&!w&&Xs(s),k=f||x||w||I,V=k?au(s.length,Zv):[],X=V.length;for(var ue in s)(c||It.call(s,ue))&&!(k&&(ue=="length"||w&&(ue=="offset"||ue=="parent")||I&&(ue=="buffer"||ue=="byteLength"||ue=="byteOffset")||dr(ue,X)))&&V.push(ue);return V}function kd(s){var c=s.length;return c?s[Tu(0,c-1)]:t}function Gx(s,c){return wc(Yn(s),cs(c,0,s.length))}function Vx(s){return wc(Yn(s))}function pu(s,c,f){(f!==t&&!Ri(s[c],f)||f===t&&!(c in s))&&ur(s,c,f)}function Qo(s,c,f){var x=s[c];(!(It.call(s,c)&&Ri(x,f))||f===t&&!(c in s))&&ur(s,c,f)}function dc(s,c){for(var f=s.length;f--;)if(Ri(s[f][0],c))return f;return-1}function Wx(s,c,f,x){return Nr(s,function(w,I,k){c(x,w,f(w),k)}),x}function Hd(s,c){return s&&Wi(c,gn(c),s)}function Xx(s,c){return s&&Wi(c,qn(c),s)}function ur(s,c,f){c=="__proto__"&&ac?ac(s,c,{configurable:!0,enumerable:!0,value:f,writable:!0}):s[c]=f}function mu(s,c){for(var f=-1,x=c.length,w=Q(x),I=s==null;++f<x;)w[f]=I?t:$u(s,c[f]);return w}function cs(s,c,f){return s===s&&(f!==t&&(s=s<=f?s:f),c!==t&&(s=s>=c?s:c)),s}function mi(s,c,f,x,w,I){var k,V=c&p,X=c&m,ue=c&g;if(f&&(k=w?f(s,x,w,I):f(s)),k!==t)return k;if(!$t(s))return s;var he=st(s);if(he){if(k=Dy(s),!V)return Yn(s,k)}else{var me=Rn(s),Te=me==$e||me==Fe;if(zr(s))return hp(s,V);if(me==z||me==fe||Te&&!w){if(k=X||Te?{}:Pp(s),!V)return X?Sy(s,Xx(k,s)):My(s,Hd(k,s))}else{if(!Ht[me])return w?s:{};k=Uy(s,me,V)}}I||(I=new Ai);var Ue=I.get(s);if(Ue)return Ue;I.set(s,k),sm(s)?s.forEach(function(qe){k.add(mi(qe,c,f,qe,s,I))}):im(s)&&s.forEach(function(qe,xt){k.set(xt,mi(qe,c,f,xt,s,I))});var je=ue?X?Nu:Uu:X?qn:gn,lt=he?t:je(s);return fi(lt||s,function(qe,xt){lt&&(xt=qe,qe=s[xt]),Qo(k,xt,mi(qe,c,f,xt,s,I))}),k}function Yx(s){var c=gn(s);return function(f){return Gd(f,s,c)}}function Gd(s,c,f){var x=f.length;if(s==null)return!x;for(s=Ot(s);x--;){var w=f[x],I=c[w],k=s[w];if(k===t&&!(w in s)||!I(k))return!1}return!0}function Vd(s,c,f){if(typeof s!="function")throw new di(a);return oa(function(){s.apply(t,f)},c)}function ea(s,c,f,x){var w=-1,I=Ka,k=!0,V=s.length,X=[],ue=c.length;if(!V)return X;f&&(c=Yt(c,Jn(f))),x?(I=tu,k=!1):c.length>=r&&(I=jo,k=!1,c=new as(c));e:for(;++w<V;){var he=s[w],me=f==null?he:f(he);if(he=x||he!==0?he:0,k&&me===me){for(var Te=ue;Te--;)if(c[Te]===me)continue e;X.push(he)}else I(c,me,x)||X.push(he)}return X}var Nr=gp(Vi),Wd=gp(_u,!0);function jx(s,c){var f=!0;return Nr(s,function(x,w,I){return f=!!c(x,w,I),f}),f}function pc(s,c,f){for(var x=-1,w=s.length;++x<w;){var I=s[x],k=c(I);if(k!=null&&(V===t?k===k&&!ei(k):f(k,V)))var V=k,X=I}return X}function qx(s,c,f,x){var w=s.length;for(f=at(f),f<0&&(f=-f>w?0:w+f),x=x===t||x>w?w:at(x),x<0&&(x+=w),x=f>x?0:am(x);f<x;)s[f++]=c;return s}function Xd(s,c){var f=[];return Nr(s,function(x,w,I){c(x,w,I)&&f.push(x)}),f}function yn(s,c,f,x,w){var I=-1,k=s.length;for(f||(f=Oy),w||(w=[]);++I<k;){var V=s[I];c>0&&f(V)?c>1?yn(V,c-1,f,x,w):Ir(w,V):x||(w[w.length]=V)}return w}var gu=_p(),Yd=_p(!0);function Vi(s,c){return s&&gu(s,c,gn)}function _u(s,c){return s&&Yd(s,c,gn)}function mc(s,c){return Lr(c,function(f){return pr(s[f])})}function ls(s,c){c=Fr(c,s);for(var f=0,x=c.length;s!=null&&f<x;)s=s[Xi(c[f++])];return f&&f==x?s:t}function jd(s,c,f){var x=c(s);return st(s)?x:Ir(x,f(s))}function zn(s){return s==null?s===t?_e:At:ss&&ss in Ot(s)?Py(s):Vy(s)}function vu(s,c){return s>c}function $x(s,c){return s!=null&&It.call(s,c)}function Kx(s,c){return s!=null&&c in Ot(s)}function Zx(s,c,f){return s>=An(c,f)&&s<fn(c,f)}function xu(s,c,f){for(var x=f?tu:Ka,w=s[0].length,I=s.length,k=I,V=Q(I),X=1/0,ue=[];k--;){var he=s[k];k&&c&&(he=Yt(he,Jn(c))),X=An(he.length,X),V[k]=!f&&(c||w>=120&&he.length>=120)?new as(k&&he):t}he=s[0];var me=-1,Te=V[0];e:for(;++me<w&&ue.length<X;){var Ue=he[me],je=c?c(Ue):Ue;if(Ue=f||Ue!==0?Ue:0,!(Te?jo(Te,je):x(ue,je,f))){for(k=I;--k;){var lt=V[k];if(!(lt?jo(lt,je):x(s[k],je,f)))continue e}Te&&Te.push(je),ue.push(Ue)}}return ue}function Jx(s,c,f,x){return Vi(s,function(w,I,k){c(x,f(w),I,k)}),x}function ta(s,c,f){c=Fr(c,s),s=Up(s,c);var x=s==null?s:s[Xi(_i(c))];return x==null?t:Zn(x,s,f)}function qd(s){return Qt(s)&&zn(s)==fe}function Qx(s){return Qt(s)&&zn(s)==xe}function ey(s){return Qt(s)&&zn(s)==Ve}function na(s,c,f,x,w){return s===c?!0:s==null||c==null||!Qt(s)&&!Qt(c)?s!==s&&c!==c:ty(s,c,f,x,na,w)}function ty(s,c,f,x,w,I){var k=st(s),V=st(c),X=k?Ee:Rn(s),ue=V?Ee:Rn(c);X=X==fe?z:X,ue=ue==fe?z:ue;var he=X==z,me=ue==z,Te=X==ue;if(Te&&zr(s)){if(!zr(c))return!1;k=!0,he=!1}if(Te&&!he)return I||(I=new Ai),k||Xs(s)?Ap(s,c,f,x,w,I):Ry(s,c,X,f,x,w,I);if(!(f&y)){var Ue=he&&It.call(s,"__wrapped__"),je=me&&It.call(c,"__wrapped__");if(Ue||je){var lt=Ue?s.value():s,qe=je?c.value():c;return I||(I=new Ai),w(lt,qe,f,x,I)}}return Te?(I||(I=new Ai),Cy(s,c,f,x,w,I)):!1}function ny(s){return Qt(s)&&Rn(s)==mt}function yu(s,c,f,x){var w=f.length,I=w,k=!x;if(s==null)return!I;for(s=Ot(s);w--;){var V=f[w];if(k&&V[2]?V[1]!==s[V[0]]:!(V[0]in s))return!1}for(;++w<I;){V=f[w];var X=V[0],ue=s[X],he=V[1];if(k&&V[2]){if(ue===t&&!(X in s))return!1}else{var me=new Ai;if(x)var Te=x(ue,he,X,s,c,me);if(!(Te===t?na(he,ue,y|S,x,me):Te))return!1}}return!0}function $d(s){if(!$t(s)||By(s))return!1;var c=pr(s)?nx:ne;return c.test(hs(s))}function iy(s){return Qt(s)&&zn(s)==le}function ry(s){return Qt(s)&&Rn(s)==de}function sy(s){return Qt(s)&&Ic(s.length)&&!!Vt[zn(s)]}function Kd(s){return typeof s=="function"?s:s==null?$n:typeof s=="object"?st(s)?Qd(s[0],s[1]):Jd(s):vm(s)}function Mu(s){if(!sa(s))return cx(s);var c=[];for(var f in Ot(s))It.call(s,f)&&f!="constructor"&&c.push(f);return c}function oy(s){if(!$t(s))return Gy(s);var c=sa(s),f=[];for(var x in s)x=="constructor"&&(c||!It.call(s,x))||f.push(x);return f}function Su(s,c){return s<c}function Zd(s,c){var f=-1,x=jn(s)?Q(s.length):[];return Nr(s,function(w,I,k){x[++f]=c(w,I,k)}),x}function Jd(s){var c=Fu(s);return c.length==1&&c[0][2]?Ip(c[0][0],c[0][1]):function(f){return f===s||yu(f,s,c)}}function Qd(s,c){return zu(s)&&Lp(c)?Ip(Xi(s),c):function(f){var x=$u(f,s);return x===t&&x===c?Ku(f,s):na(c,x,y|S)}}function gc(s,c,f,x,w){s!==c&&gu(c,function(I,k){if(w||(w=new Ai),$t(I))ay(s,c,k,f,gc,x,w);else{var V=x?x(Hu(s,k),I,k+"",s,c,w):t;V===t&&(V=I),pu(s,k,V)}},qn)}function ay(s,c,f,x,w,I,k){var V=Hu(s,f),X=Hu(c,f),ue=k.get(X);if(ue){pu(s,f,ue);return}var he=I?I(V,X,f+"",s,c,k):t,me=he===t;if(me){var Te=st(X),Ue=!Te&&zr(X),je=!Te&&!Ue&&Xs(X);he=X,Te||Ue||je?st(V)?he=V:rn(V)?he=Yn(V):Ue?(me=!1,he=hp(X,!0)):je?(me=!1,he=fp(X,!0)):he=[]:aa(X)||fs(X)?(he=V,fs(V)?he=cm(V):(!$t(V)||pr(V))&&(he=Pp(X))):me=!1}me&&(k.set(X,he),w(he,X,x,I,k),k.delete(X)),pu(s,f,he)}function ep(s,c){var f=s.length;if(f)return c+=c<0?f:0,dr(c,f)?s[c]:t}function tp(s,c,f){c.length?c=Yt(c,function(I){return st(I)?function(k){return ls(k,I.length===1?I[0]:I)}:I}):c=[$n];var x=-1;c=Yt(c,Jn(Ye()));var w=Zd(s,function(I,k,V){var X=Yt(c,function(ue){return ue(I)});return{criteria:X,index:++x,value:I}});return Uv(w,function(I,k){return yy(I,k,f)})}function cy(s,c){return np(s,c,function(f,x){return Ku(s,x)})}function np(s,c,f){for(var x=-1,w=c.length,I={};++x<w;){var k=c[x],V=ls(s,k);f(V,k)&&ia(I,Fr(k,s),V)}return I}function ly(s){return function(c){return ls(c,s)}}function Eu(s,c,f,x){var w=x?Dv:Us,I=-1,k=c.length,V=s;for(s===c&&(c=Yn(c)),f&&(V=Yt(s,Jn(f)));++I<k;)for(var X=0,ue=c[I],he=f?f(ue):ue;(X=w(V,he,X,x))>-1;)V!==s&&oc.call(V,X,1),oc.call(s,X,1);return s}function ip(s,c){for(var f=s?c.length:0,x=f-1;f--;){var w=c[f];if(f==x||w!==I){var I=w;dr(w)?oc.call(s,w,1):Au(s,w)}}return s}function Tu(s,c){return s+lc(Fd()*(c-s+1))}function uy(s,c,f,x){for(var w=-1,I=fn(cc((c-s)/(f||1)),0),k=Q(I);I--;)k[x?I:++w]=s,s+=f;return k}function bu(s,c){var f="";if(!s||c<1||c>K)return f;do c%2&&(f+=s),c=lc(c/2),c&&(s+=s);while(c);return f}function pt(s,c){return Gu(Dp(s,c,$n),s+"")}function hy(s){return kd(Ys(s))}function fy(s,c){var f=Ys(s);return wc(f,cs(c,0,f.length))}function ia(s,c,f,x){if(!$t(s))return s;c=Fr(c,s);for(var w=-1,I=c.length,k=I-1,V=s;V!=null&&++w<I;){var X=Xi(c[w]),ue=f;if(X==="__proto__"||X==="constructor"||X==="prototype")return s;if(w!=k){var he=V[X];ue=x?x(he,X,V):t,ue===t&&(ue=$t(he)?he:dr(c[w+1])?[]:{})}Qo(V,X,ue),V=V[X]}return s}var rp=uc?function(s,c){return uc.set(s,c),s}:$n,dy=ac?function(s,c){return ac(s,"toString",{configurable:!0,enumerable:!1,value:Ju(c),writable:!0})}:$n;function py(s){return wc(Ys(s))}function gi(s,c,f){var x=-1,w=s.length;c<0&&(c=-c>w?0:w+c),f=f>w?w:f,f<0&&(f+=w),w=c>f?0:f-c>>>0,c>>>=0;for(var I=Q(w);++x<w;)I[x]=s[x+c];return I}function my(s,c){var f;return Nr(s,function(x,w,I){return f=c(x,w,I),!f}),!!f}function _c(s,c,f){var x=0,w=s==null?x:s.length;if(typeof c=="number"&&c===c&&w<=Ze){for(;x<w;){var I=x+w>>>1,k=s[I];k!==null&&!ei(k)&&(f?k<=c:k<c)?x=I+1:w=I}return w}return wu(s,c,$n,f)}function wu(s,c,f,x){var w=0,I=s==null?0:s.length;if(I===0)return 0;c=f(c);for(var k=c!==c,V=c===null,X=ei(c),ue=c===t;w<I;){var he=lc((w+I)/2),me=f(s[he]),Te=me!==t,Ue=me===null,je=me===me,lt=ei(me);if(k)var qe=x||je;else ue?qe=je&&(x||Te):V?qe=je&&Te&&(x||!Ue):X?qe=je&&Te&&!Ue&&(x||!lt):Ue||lt?qe=!1:qe=x?me<=c:me<c;qe?w=he+1:I=he}return An(I,ke)}function sp(s,c){for(var f=-1,x=s.length,w=0,I=[];++f<x;){var k=s[f],V=c?c(k):k;if(!f||!Ri(V,X)){var X=V;I[w++]=k===0?0:k}}return I}function op(s){return typeof s=="number"?s:ei(s)?pe:+s}function Qn(s){if(typeof s=="string")return s;if(st(s))return Yt(s,Qn)+"";if(ei(s))return Bd?Bd.call(s):"";var c=s+"";return c=="0"&&1/s==-1/0?"-0":c}function Or(s,c,f){var x=-1,w=Ka,I=s.length,k=!0,V=[],X=V;if(f)k=!1,w=tu;else if(I>=r){var ue=c?null:wy(s);if(ue)return Ja(ue);k=!1,w=jo,X=new as}else X=c?[]:V;e:for(;++x<I;){var he=s[x],me=c?c(he):he;if(he=f||he!==0?he:0,k&&me===me){for(var Te=X.length;Te--;)if(X[Te]===me)continue e;c&&X.push(me),V.push(he)}else w(X,me,f)||(X!==V&&X.push(me),V.push(he))}return V}function Au(s,c){return c=Fr(c,s),s=Up(s,c),s==null||delete s[Xi(_i(c))]}function ap(s,c,f,x){return ia(s,c,f(ls(s,c)),x)}function vc(s,c,f,x){for(var w=s.length,I=x?w:-1;(x?I--:++I<w)&&c(s[I],I,s););return f?gi(s,x?0:I,x?I+1:w):gi(s,x?I+1:0,x?w:I)}function cp(s,c){var f=s;return f instanceof Mt&&(f=f.value()),nu(c,function(x,w){return w.func.apply(w.thisArg,Ir([x],w.args))},f)}function Ru(s,c,f){var x=s.length;if(x<2)return x?Or(s[0]):[];for(var w=-1,I=Q(x);++w<x;)for(var k=s[w],V=-1;++V<x;)V!=w&&(I[w]=ea(I[w]||k,s[V],c,f));return Or(yn(I,1),c,f)}function lp(s,c,f){for(var x=-1,w=s.length,I=c.length,k={};++x<w;){var V=x<I?c[x]:t;f(k,s[x],V)}return k}function Cu(s){return rn(s)?s:[]}function Pu(s){return typeof s=="function"?s:$n}function Fr(s,c){return st(s)?s:zu(s,c)?[s]:Bp(Pt(s))}var gy=pt;function Br(s,c,f){var x=s.length;return f=f===t?x:f,!c&&f>=x?s:gi(s,c,f)}var up=ix||function(s){return xn.clearTimeout(s)};function hp(s,c){if(c)return s.slice();var f=s.length,x=Id?Id(f):new s.constructor(f);return s.copy(x),x}function Lu(s){var c=new s.constructor(s.byteLength);return new rc(c).set(new rc(s)),c}function _y(s,c){var f=c?Lu(s.buffer):s.buffer;return new s.constructor(f,s.byteOffset,s.byteLength)}function vy(s){var c=new s.constructor(s.source,U.exec(s));return c.lastIndex=s.lastIndex,c}function xy(s){return Jo?Ot(Jo.call(s)):{}}function fp(s,c){var f=c?Lu(s.buffer):s.buffer;return new s.constructor(f,s.byteOffset,s.length)}function dp(s,c){if(s!==c){var f=s!==t,x=s===null,w=s===s,I=ei(s),k=c!==t,V=c===null,X=c===c,ue=ei(c);if(!V&&!ue&&!I&&s>c||I&&k&&X&&!V&&!ue||x&&k&&X||!f&&X||!w)return 1;if(!x&&!I&&!ue&&s<c||ue&&f&&w&&!x&&!I||V&&f&&w||!k&&w||!X)return-1}return 0}function yy(s,c,f){for(var x=-1,w=s.criteria,I=c.criteria,k=w.length,V=f.length;++x<k;){var X=dp(w[x],I[x]);if(X){if(x>=V)return X;var ue=f[x];return X*(ue=="desc"?-1:1)}}return s.index-c.index}function pp(s,c,f,x){for(var w=-1,I=s.length,k=f.length,V=-1,X=c.length,ue=fn(I-k,0),he=Q(X+ue),me=!x;++V<X;)he[V]=c[V];for(;++w<k;)(me||w<I)&&(he[f[w]]=s[w]);for(;ue--;)he[V++]=s[w++];return he}function mp(s,c,f,x){for(var w=-1,I=s.length,k=-1,V=f.length,X=-1,ue=c.length,he=fn(I-V,0),me=Q(he+ue),Te=!x;++w<he;)me[w]=s[w];for(var Ue=w;++X<ue;)me[Ue+X]=c[X];for(;++k<V;)(Te||w<I)&&(me[Ue+f[k]]=s[w++]);return me}function Yn(s,c){var f=-1,x=s.length;for(c||(c=Q(x));++f<x;)c[f]=s[f];return c}function Wi(s,c,f,x){var w=!f;f||(f={});for(var I=-1,k=c.length;++I<k;){var V=c[I],X=x?x(f[V],s[V],V,f,s):t;X===t&&(X=s[V]),w?ur(f,V,X):Qo(f,V,X)}return f}function My(s,c){return Wi(s,Bu(s),c)}function Sy(s,c){return Wi(s,Rp(s),c)}function xc(s,c){return function(f,x){var w=st(f)?Av:Wx,I=c?c():{};return w(f,s,Ye(x,2),I)}}function Gs(s){return pt(function(c,f){var x=-1,w=f.length,I=w>1?f[w-1]:t,k=w>2?f[2]:t;for(I=s.length>3&&typeof I=="function"?(w--,I):t,k&&kn(f[0],f[1],k)&&(I=w<3?t:I,w=1),c=Ot(c);++x<w;){var V=f[x];V&&s(c,V,x,I)}return c})}function gp(s,c){return function(f,x){if(f==null)return f;if(!jn(f))return s(f,x);for(var w=f.length,I=c?w:-1,k=Ot(f);(c?I--:++I<w)&&x(k[I],I,k)!==!1;);return f}}function _p(s){return function(c,f,x){for(var w=-1,I=Ot(c),k=x(c),V=k.length;V--;){var X=k[s?V:++w];if(f(I[X],X,I)===!1)break}return c}}function Ey(s,c,f){var x=c&_,w=ra(s);function I(){var k=this&&this!==xn&&this instanceof I?w:s;return k.apply(x?f:this,arguments)}return I}function vp(s){return function(c){c=Pt(c);var f=Ns(c)?wi(c):t,x=f?f[0]:c.charAt(0),w=f?Br(f,1).join(""):c.slice(1);return x[s]()+w}}function Vs(s){return function(c){return nu(gm(mm(c).replace(dv,"")),s,"")}}function ra(s){return function(){var c=arguments;switch(c.length){case 0:return new s;case 1:return new s(c[0]);case 2:return new s(c[0],c[1]);case 3:return new s(c[0],c[1],c[2]);case 4:return new s(c[0],c[1],c[2],c[3]);case 5:return new s(c[0],c[1],c[2],c[3],c[4]);case 6:return new s(c[0],c[1],c[2],c[3],c[4],c[5]);case 7:return new s(c[0],c[1],c[2],c[3],c[4],c[5],c[6])}var f=Hs(s.prototype),x=s.apply(f,c);return $t(x)?x:f}}function Ty(s,c,f){var x=ra(s);function w(){for(var I=arguments.length,k=Q(I),V=I,X=Ws(w);V--;)k[V]=arguments[V];var ue=I<3&&k[0]!==X&&k[I-1]!==X?[]:Dr(k,X);if(I-=ue.length,I<f)return Ep(s,c,yc,w.placeholder,t,k,ue,t,t,f-I);var he=this&&this!==xn&&this instanceof w?x:s;return Zn(he,this,k)}return w}function xp(s){return function(c,f,x){var w=Ot(c);if(!jn(c)){var I=Ye(f,3);c=gn(c),f=function(V){return I(w[V],V,w)}}var k=s(c,f,x);return k>-1?w[I?c[k]:k]:t}}function yp(s){return fr(function(c){var f=c.length,x=f,w=pi.prototype.thru;for(s&&c.reverse();x--;){var I=c[x];if(typeof I!="function")throw new di(a);if(w&&!k&&Tc(I)=="wrapper")var k=new pi([],!0)}for(x=k?x:f;++x<f;){I=c[x];var V=Tc(I),X=V=="wrapper"?Ou(I):t;X&&ku(X[0])&&X[1]==(D|b|B|C)&&!X[4].length&&X[9]==1?k=k[Tc(X[0])].apply(k,X[3]):k=I.length==1&&ku(I)?k[V]():k.thru(I)}return function(){var ue=arguments,he=ue[0];if(k&&ue.length==1&&st(he))return k.plant(he).value();for(var me=0,Te=f?c[me].apply(this,ue):he;++me<f;)Te=c[me].call(this,Te);return Te}})}function yc(s,c,f,x,w,I,k,V,X,ue){var he=c&D,me=c&_,Te=c&v,Ue=c&(b|A),je=c&E,lt=Te?t:ra(s);function qe(){for(var xt=arguments.length,bt=Q(xt),ti=xt;ti--;)bt[ti]=arguments[ti];if(Ue)var Hn=Ws(qe),ni=Ov(bt,Hn);if(x&&(bt=pp(bt,x,w,Ue)),I&&(bt=mp(bt,I,k,Ue)),xt-=ni,Ue&&xt<ue){var sn=Dr(bt,Hn);return Ep(s,c,yc,qe.placeholder,f,bt,sn,V,X,ue-xt)}var Ci=me?f:this,gr=Te?Ci[s]:s;return xt=bt.length,V?bt=Wy(bt,V):je&&xt>1&&bt.reverse(),he&&X<xt&&(bt.length=X),this&&this!==xn&&this instanceof qe&&(gr=lt||ra(gr)),gr.apply(Ci,bt)}return qe}function Mp(s,c){return function(f,x){return Jx(f,s,c(x),{})}}function Mc(s,c){return function(f,x){var w;if(f===t&&x===t)return c;if(f!==t&&(w=f),x!==t){if(w===t)return x;typeof f=="string"||typeof x=="string"?(f=Qn(f),x=Qn(x)):(f=op(f),x=op(x)),w=s(f,x)}return w}}function Iu(s){return fr(function(c){return c=Yt(c,Jn(Ye())),pt(function(f){var x=this;return s(c,function(w){return Zn(w,x,f)})})})}function Sc(s,c){c=c===t?" ":Qn(c);var f=c.length;if(f<2)return f?bu(c,s):c;var x=bu(c,cc(s/Os(c)));return Ns(c)?Br(wi(x),0,s).join(""):x.slice(0,s)}function by(s,c,f,x){var w=c&_,I=ra(s);function k(){for(var V=-1,X=arguments.length,ue=-1,he=x.length,me=Q(he+X),Te=this&&this!==xn&&this instanceof k?I:s;++ue<he;)me[ue]=x[ue];for(;X--;)me[ue++]=arguments[++V];return Zn(Te,w?f:this,me)}return k}function Sp(s){return function(c,f,x){return x&&typeof x!="number"&&kn(c,f,x)&&(f=x=t),c=mr(c),f===t?(f=c,c=0):f=mr(f),x=x===t?c<f?1:-1:mr(x),uy(c,f,x,s)}}function Ec(s){return function(c,f){return typeof c=="string"&&typeof f=="string"||(c=vi(c),f=vi(f)),s(c,f)}}function Ep(s,c,f,x,w,I,k,V,X,ue){var he=c&b,me=he?k:t,Te=he?t:k,Ue=he?I:t,je=he?t:I;c|=he?B:N,c&=~(he?N:B),c&R||(c&=-4);var lt=[s,c,w,Ue,me,je,Te,V,X,ue],qe=f.apply(t,lt);return ku(s)&&Np(qe,lt),qe.placeholder=x,Op(qe,s,c)}function Du(s){var c=hn[s];return function(f,x){if(f=vi(f),x=x==null?0:An(at(x),292),x&&Od(f)){var w=(Pt(f)+"e").split("e"),I=c(w[0]+"e"+(+w[1]+x));return w=(Pt(I)+"e").split("e"),+(w[0]+"e"+(+w[1]-x))}return c(f)}}var wy=zs&&1/Ja(new zs([,-0]))[1]==se?function(s){return new zs(s)}:th;function Tp(s){return function(c){var f=Rn(c);return f==mt?lu(c):f==de?Vv(c):Nv(c,s(c))}}function hr(s,c,f,x,w,I,k,V){var X=c&v;if(!X&&typeof s!="function")throw new di(a);var ue=x?x.length:0;if(ue||(c&=-97,x=w=t),k=k===t?k:fn(at(k),0),V=V===t?V:at(V),ue-=w?w.length:0,c&N){var he=x,me=w;x=w=t}var Te=X?t:Ou(s),Ue=[s,c,f,x,w,he,me,I,k,V];if(Te&&Hy(Ue,Te),s=Ue[0],c=Ue[1],f=Ue[2],x=Ue[3],w=Ue[4],V=Ue[9]=Ue[9]===t?X?0:s.length:fn(Ue[9]-ue,0),!V&&c&(b|A)&&(c&=-25),!c||c==_)var je=Ey(s,c,f);else c==b||c==A?je=Ty(s,c,V):(c==B||c==(_|B))&&!w.length?je=by(s,c,f,x):je=yc.apply(t,Ue);var lt=Te?rp:Np;return Op(lt(je,Ue),s,c)}function bp(s,c,f,x){return s===t||Ri(s,Bs[f])&&!It.call(x,f)?c:s}function wp(s,c,f,x,w,I){return $t(s)&&$t(c)&&(I.set(c,s),gc(s,c,t,wp,I),I.delete(c)),s}function Ay(s){return aa(s)?t:s}function Ap(s,c,f,x,w,I){var k=f&y,V=s.length,X=c.length;if(V!=X&&!(k&&X>V))return!1;var ue=I.get(s),he=I.get(c);if(ue&&he)return ue==c&&he==s;var me=-1,Te=!0,Ue=f&S?new as:t;for(I.set(s,c),I.set(c,s);++me<V;){var je=s[me],lt=c[me];if(x)var qe=k?x(lt,je,me,c,s,I):x(je,lt,me,s,c,I);if(qe!==t){if(qe)continue;Te=!1;break}if(Ue){if(!iu(c,function(xt,bt){if(!jo(Ue,bt)&&(je===xt||w(je,xt,f,x,I)))return Ue.push(bt)})){Te=!1;break}}else if(!(je===lt||w(je,lt,f,x,I))){Te=!1;break}}return I.delete(s),I.delete(c),Te}function Ry(s,c,f,x,w,I,k){switch(f){case we:if(s.byteLength!=c.byteLength||s.byteOffset!=c.byteOffset)return!1;s=s.buffer,c=c.buffer;case xe:return!(s.byteLength!=c.byteLength||!I(new rc(s),new rc(c)));case ze:case Ve:case We:return Ri(+s,+c);case q:return s.name==c.name&&s.message==c.message;case le:case ge:return s==c+"";case mt:var V=lu;case de:var X=x&y;if(V||(V=Ja),s.size!=c.size&&!X)return!1;var ue=k.get(s);if(ue)return ue==c;x|=S,k.set(s,c);var he=Ap(V(s),V(c),x,w,I,k);return k.delete(s),he;case He:if(Jo)return Jo.call(s)==Jo.call(c)}return!1}function Cy(s,c,f,x,w,I){var k=f&y,V=Uu(s),X=V.length,ue=Uu(c),he=ue.length;if(X!=he&&!k)return!1;for(var me=X;me--;){var Te=V[me];if(!(k?Te in c:It.call(c,Te)))return!1}var Ue=I.get(s),je=I.get(c);if(Ue&&je)return Ue==c&&je==s;var lt=!0;I.set(s,c),I.set(c,s);for(var qe=k;++me<X;){Te=V[me];var xt=s[Te],bt=c[Te];if(x)var ti=k?x(bt,xt,Te,c,s,I):x(xt,bt,Te,s,c,I);if(!(ti===t?xt===bt||w(xt,bt,f,x,I):ti)){lt=!1;break}qe||(qe=Te=="constructor")}if(lt&&!qe){var Hn=s.constructor,ni=c.constructor;Hn!=ni&&"constructor"in s&&"constructor"in c&&!(typeof Hn=="function"&&Hn instanceof Hn&&typeof ni=="function"&&ni instanceof ni)&&(lt=!1)}return I.delete(s),I.delete(c),lt}function fr(s){return Gu(Dp(s,t,Gp),s+"")}function Uu(s){return jd(s,gn,Bu)}function Nu(s){return jd(s,qn,Rp)}var Ou=uc?function(s){return uc.get(s)}:th;function Tc(s){for(var c=s.name+"",f=ks[c],x=It.call(ks,c)?f.length:0;x--;){var w=f[x],I=w.func;if(I==null||I==s)return w.name}return c}function Ws(s){var c=It.call(L,"placeholder")?L:s;return c.placeholder}function Ye(){var s=L.iteratee||Qu;return s=s===Qu?Kd:s,arguments.length?s(arguments[0],arguments[1]):s}function bc(s,c){var f=s.__data__;return Fy(c)?f[typeof c=="string"?"string":"hash"]:f.map}function Fu(s){for(var c=gn(s),f=c.length;f--;){var x=c[f],w=s[x];c[f]=[x,w,Lp(w)]}return c}function us(s,c){var f=kv(s,c);return $d(f)?f:t}function Py(s){var c=It.call(s,ss),f=s[ss];try{s[ss]=t;var x=!0}catch{}var w=nc.call(s);return x&&(c?s[ss]=f:delete s[ss]),w}var Bu=hu?function(s){return s==null?[]:(s=Ot(s),Lr(hu(s),function(c){return Ud.call(s,c)}))}:nh,Rp=hu?function(s){for(var c=[];s;)Ir(c,Bu(s)),s=sc(s);return c}:nh,Rn=zn;(fu&&Rn(new fu(new ArrayBuffer(1)))!=we||$o&&Rn(new $o)!=mt||du&&Rn(du.resolve())!=P||zs&&Rn(new zs)!=de||Ko&&Rn(new Ko)!=De)&&(Rn=function(s){var c=zn(s),f=c==z?s.constructor:t,x=f?hs(f):"";if(x)switch(x){case fx:return we;case dx:return mt;case px:return P;case mx:return de;case gx:return De}return c});function Ly(s,c,f){for(var x=-1,w=f.length;++x<w;){var I=f[x],k=I.size;switch(I.type){case"drop":s+=k;break;case"dropRight":c-=k;break;case"take":c=An(c,s+k);break;case"takeRight":s=fn(s,c-k);break}}return{start:s,end:c}}function Iy(s){var c=s.match(Is);return c?c[1].split(ja):[]}function Cp(s,c,f){c=Fr(c,s);for(var x=-1,w=c.length,I=!1;++x<w;){var k=Xi(c[x]);if(!(I=s!=null&&f(s,k)))break;s=s[k]}return I||++x!=w?I:(w=s==null?0:s.length,!!w&&Ic(w)&&dr(k,w)&&(st(s)||fs(s)))}function Dy(s){var c=s.length,f=new s.constructor(c);return c&&typeof s[0]=="string"&&It.call(s,"index")&&(f.index=s.index,f.input=s.input),f}function Pp(s){return typeof s.constructor=="function"&&!sa(s)?Hs(sc(s)):{}}function Uy(s,c,f){var x=s.constructor;switch(c){case xe:return Lu(s);case ze:case Ve:return new x(+s);case we:return _y(s,f);case Ke:case Le:case Ie:case ct:case ft:case Et:case _t:case Tt:case Ne:return fp(s,f);case mt:return new x;case We:case ge:return new x(s);case le:return vy(s);case de:return new x;case He:return xy(s)}}function Ny(s,c){var f=c.length;if(!f)return s;var x=f-1;return c[x]=(f>1?"& ":"")+c[x],c=c.join(f>2?", ":" "),s.replace(Ya,`{
3805
3805
  /* [wrapped with `+c+`] */
3806
- `)}function Oy(s){return st(s)||fs(s)||!!(Nd&&s&&s[Nd])}function dr(s,c){var f=typeof s;return c=c??K,!!c&&(f=="number"||f!="symbol"&&Ae.test(s))&&s>-1&&s%1==0&&s<c}function kn(s,c,f){if(!$t(f))return!1;var x=typeof c;return(x=="number"?jn(f)&&dr(c,f.length):x=="string"&&c in f)?Ri(f[c],s):!1}function Bu(s,c){if(st(s))return!1;var f=typeof s;return f=="number"||f=="symbol"||f=="boolean"||s==null||ei(s)?!0:Jt.test(s)||!Zt.test(s)||c!=null&&s in Ot(c)}function Fy(s){var c=typeof s;return c=="string"||c=="number"||c=="symbol"||c=="boolean"?s!=="__proto__":s===null}function zu(s){var c=Tc(s),f=L[c];if(typeof f!="function"||!(c in Mt.prototype))return!1;if(s===f)return!0;var x=Nu(f);return!!x&&s===x[0]}function By(s){return!!Ld&&Ld in s}var zy=ec?pr:nh;function sa(s){var c=s&&s.constructor,f=typeof c=="function"&&c.prototype||Bs;return s===f}function Lp(s){return s===s&&!$t(s)}function Ip(s,c){return function(f){return f==null?!1:f[s]===c&&(c!==t||s in Ot(f))}}function ky(s){var c=Pc(s,function(x){return f.size===h&&f.clear(),x}),f=c.cache;return c}function Hy(s,c){var f=s[1],x=c[1],w=f|x,I=w<(_|v|D),k=x==D&&f==b||x==D&&f==C&&s[7].length<=c[8]||x==(D|C)&&c[7].length<=c[8]&&f==b;if(!(I||k))return s;x&_&&(s[2]=c[2],w|=f&_?0:R);var V=c[3];if(V){var X=s[3];s[3]=X?pp(X,V,c[4]):V,s[4]=X?Dr(s[3],d):c[4]}return V=c[5],V&&(X=s[5],s[5]=X?mp(X,V,c[6]):V,s[6]=X?Dr(s[5],d):c[6]),V=c[7],V&&(s[7]=V),x&D&&(s[8]=s[8]==null?c[8]:An(s[8],c[8])),s[9]==null&&(s[9]=c[9]),s[0]=c[0],s[1]=w,s}function Gy(s){var c=[];if(s!=null)for(var f in Ot(s))c.push(f);return c}function Vy(s){return nc.call(s)}function Dp(s,c,f){return c=fn(c===t?s.length-1:c,0),function(){for(var x=arguments,w=-1,I=fn(x.length-c,0),k=Q(I);++w<I;)k[w]=x[c+w];w=-1;for(var V=Q(c+1);++w<c;)V[w]=x[w];return V[c]=f(k),Zn(s,this,V)}}function Up(s,c){return c.length<2?s:ls(s,gi(c,0,-1))}function Wy(s,c){for(var f=s.length,x=An(c.length,f),w=Yn(s);x--;){var I=c[x];s[x]=dr(I,f)?w[I]:t}return s}function ku(s,c){if(!(c==="constructor"&&typeof s[c]=="function")&&c!="__proto__")return s[c]}var Np=Fp(rp),oa=sx||function(s,c){return xn.setTimeout(s,c)},Hu=Fp(dy);function Op(s,c,f){var x=c+"";return Hu(s,Ny(x,Xy(Iy(x),f)))}function Fp(s){var c=0,f=0;return function(){var x=lx(),w=G-(x-f);if(f=x,w>0){if(++c>=H)return arguments[0]}else c=0;return s.apply(t,arguments)}}function wc(s,c){var f=-1,x=s.length,w=x-1;for(c=c===t?x:c;++f<c;){var I=Eu(f,w),k=s[I];s[I]=s[f],s[f]=k}return s.length=c,s}var Bp=ky(function(s){var c=[];return s.charCodeAt(0)===46&&c.push(""),s.replace(Fn,function(f,x,w,I){c.push(w?I.replace(Yl,"$1"):x||f)}),c});function Xi(s){if(typeof s=="string"||ei(s))return s;var c=s+"";return c=="0"&&1/s==-1/0?"-0":c}function hs(s){if(s!=null){try{return tc.call(s)}catch{}try{return s+""}catch{}}return""}function Xy(s,c){return fi(te,function(f){var x="_."+f[0];c&f[1]&&!Ka(s,x)&&s.push(x)}),s.sort()}function zp(s){if(s instanceof Mt)return s.clone();var c=new pi(s.__wrapped__,s.__chain__);return c.__actions__=Yn(s.__actions__),c.__index__=s.__index__,c.__values__=s.__values__,c}function Yy(s,c,f){(f?kn(s,c,f):c===t)?c=1:c=fn(at(c),0);var x=s==null?0:s.length;if(!x||c<1)return[];for(var w=0,I=0,k=Q(cc(x/c));w<x;)k[I++]=gi(s,w,w+=c);return k}function jy(s){for(var c=-1,f=s==null?0:s.length,x=0,w=[];++c<f;){var I=s[c];I&&(w[x++]=I)}return w}function qy(){var s=arguments.length;if(!s)return[];for(var c=Q(s-1),f=arguments[0],x=s;x--;)c[x-1]=arguments[x];return Ir(st(f)?Yn(f):[f],yn(c,1))}var $y=pt(function(s,c){return rn(s)?ea(s,yn(c,1,rn,!0)):[]}),Ky=pt(function(s,c){var f=_i(c);return rn(f)&&(f=t),rn(s)?ea(s,yn(c,1,rn,!0),Ye(f,2)):[]}),Zy=pt(function(s,c){var f=_i(c);return rn(f)&&(f=t),rn(s)?ea(s,yn(c,1,rn,!0),t,f):[]});function Jy(s,c,f){var x=s==null?0:s.length;return x?(c=f||c===t?1:at(c),gi(s,c<0?0:c,x)):[]}function Qy(s,c,f){var x=s==null?0:s.length;return x?(c=f||c===t?1:at(c),c=x-c,gi(s,0,c<0?0:c)):[]}function eM(s,c){return s&&s.length?vc(s,Ye(c,3),!0,!0):[]}function tM(s,c){return s&&s.length?vc(s,Ye(c,3),!0):[]}function nM(s,c,f,x){var w=s==null?0:s.length;return w?(f&&typeof f!="number"&&kn(s,c,f)&&(f=0,x=w),qx(s,c,f,x)):[]}function kp(s,c,f){var x=s==null?0:s.length;if(!x)return-1;var w=f==null?0:at(f);return w<0&&(w=fn(x+w,0)),Za(s,Ye(c,3),w)}function Hp(s,c,f){var x=s==null?0:s.length;if(!x)return-1;var w=x-1;return f!==t&&(w=at(f),w=f<0?fn(x+w,0):An(w,x-1)),Za(s,Ye(c,3),w,!0)}function Gp(s){var c=s==null?0:s.length;return c?yn(s,1):[]}function iM(s){var c=s==null?0:s.length;return c?yn(s,se):[]}function rM(s,c){var f=s==null?0:s.length;return f?(c=c===t?1:at(c),yn(s,c)):[]}function sM(s){for(var c=-1,f=s==null?0:s.length,x={};++c<f;){var w=s[c];x[w[0]]=w[1]}return x}function Vp(s){return s&&s.length?s[0]:t}function oM(s,c,f){var x=s==null?0:s.length;if(!x)return-1;var w=f==null?0:at(f);return w<0&&(w=fn(x+w,0)),Us(s,c,w)}function aM(s){var c=s==null?0:s.length;return c?gi(s,0,-1):[]}var cM=pt(function(s){var c=Yt(s,Ru);return c.length&&c[0]===s[0]?vu(c):[]}),lM=pt(function(s){var c=_i(s),f=Yt(s,Ru);return c===_i(f)?c=t:f.pop(),f.length&&f[0]===s[0]?vu(f,Ye(c,2)):[]}),uM=pt(function(s){var c=_i(s),f=Yt(s,Ru);return c=typeof c=="function"?c:t,c&&f.pop(),f.length&&f[0]===s[0]?vu(f,t,c):[]});function hM(s,c){return s==null?"":ax.call(s,c)}function _i(s){var c=s==null?0:s.length;return c?s[c-1]:t}function fM(s,c,f){var x=s==null?0:s.length;if(!x)return-1;var w=x;return f!==t&&(w=at(f),w=w<0?fn(x+w,0):An(w,x-1)),c===c?Xv(s,c,w):Za(s,Ed,w,!0)}function dM(s,c){return s&&s.length?ep(s,at(c)):t}var pM=pt(Wp);function Wp(s,c){return s&&s.length&&c&&c.length?Su(s,c):s}function mM(s,c,f){return s&&s.length&&c&&c.length?Su(s,c,Ye(f,2)):s}function gM(s,c,f){return s&&s.length&&c&&c.length?Su(s,c,t,f):s}var _M=fr(function(s,c){var f=s==null?0:s.length,x=pu(s,c);return ip(s,Yt(c,function(w){return dr(w,f)?+w:w}).sort(dp)),x});function vM(s,c){var f=[];if(!(s&&s.length))return f;var x=-1,w=[],I=s.length;for(c=Ye(c,3);++x<I;){var k=s[x];c(k,x,s)&&(f.push(k),w.push(x))}return ip(s,w),f}function Gu(s){return s==null?s:hx.call(s)}function xM(s,c,f){var x=s==null?0:s.length;return x?(f&&typeof f!="number"&&kn(s,c,f)?(c=0,f=x):(c=c==null?0:at(c),f=f===t?x:at(f)),gi(s,c,f)):[]}function yM(s,c){return _c(s,c)}function MM(s,c,f){return bu(s,c,Ye(f,2))}function SM(s,c){var f=s==null?0:s.length;if(f){var x=_c(s,c);if(x<f&&Ri(s[x],c))return x}return-1}function EM(s,c){return _c(s,c,!0)}function TM(s,c,f){return bu(s,c,Ye(f,2),!0)}function bM(s,c){var f=s==null?0:s.length;if(f){var x=_c(s,c,!0)-1;if(Ri(s[x],c))return x}return-1}function wM(s){return s&&s.length?sp(s):[]}function AM(s,c){return s&&s.length?sp(s,Ye(c,2)):[]}function RM(s){var c=s==null?0:s.length;return c?gi(s,1,c):[]}function CM(s,c,f){return s&&s.length?(c=f||c===t?1:at(c),gi(s,0,c<0?0:c)):[]}function PM(s,c,f){var x=s==null?0:s.length;return x?(c=f||c===t?1:at(c),c=x-c,gi(s,c<0?0:c,x)):[]}function LM(s,c){return s&&s.length?vc(s,Ye(c,3),!1,!0):[]}function IM(s,c){return s&&s.length?vc(s,Ye(c,3)):[]}var DM=pt(function(s){return Or(yn(s,1,rn,!0))}),UM=pt(function(s){var c=_i(s);return rn(c)&&(c=t),Or(yn(s,1,rn,!0),Ye(c,2))}),NM=pt(function(s){var c=_i(s);return c=typeof c=="function"?c:t,Or(yn(s,1,rn,!0),t,c)});function OM(s){return s&&s.length?Or(s):[]}function FM(s,c){return s&&s.length?Or(s,Ye(c,2)):[]}function BM(s,c){return c=typeof c=="function"?c:t,s&&s.length?Or(s,t,c):[]}function Vu(s){if(!(s&&s.length))return[];var c=0;return s=Lr(s,function(f){if(rn(f))return c=fn(f.length,c),!0}),ou(c,function(f){return Yt(s,iu(f))})}function Xp(s,c){if(!(s&&s.length))return[];var f=Vu(s);return c==null?f:Yt(f,function(x){return Zn(c,t,x)})}var zM=pt(function(s,c){return rn(s)?ea(s,c):[]}),kM=pt(function(s){return Au(Lr(s,rn))}),HM=pt(function(s){var c=_i(s);return rn(c)&&(c=t),Au(Lr(s,rn),Ye(c,2))}),GM=pt(function(s){var c=_i(s);return c=typeof c=="function"?c:t,Au(Lr(s,rn),t,c)}),VM=pt(Vu);function WM(s,c){return lp(s||[],c||[],Qo)}function XM(s,c){return lp(s||[],c||[],ia)}var YM=pt(function(s){var c=s.length,f=c>1?s[c-1]:t;return f=typeof f=="function"?(s.pop(),f):t,Xp(s,f)});function Yp(s){var c=L(s);return c.__chain__=!0,c}function jM(s,c){return c(s),s}function Ac(s,c){return c(s)}var qM=fr(function(s){var c=s.length,f=c?s[0]:0,x=this.__wrapped__,w=function(I){return pu(I,s)};return c>1||this.__actions__.length||!(x instanceof Mt)||!dr(f)?this.thru(w):(x=x.slice(f,+f+(c?1:0)),x.__actions__.push({func:Ac,args:[w],thisArg:t}),new pi(x,this.__chain__).thru(function(I){return c&&!I.length&&I.push(t),I}))});function $M(){return Yp(this)}function KM(){return new pi(this.value(),this.__chain__)}function ZM(){this.__values__===t&&(this.__values__=om(this.value()));var s=this.__index__>=this.__values__.length,c=s?t:this.__values__[this.__index__++];return{done:s,value:c}}function JM(){return this}function QM(s){for(var c,f=this;f instanceof fc;){var x=zp(f);x.__index__=0,x.__values__=t,c?w.__wrapped__=x:c=x;var w=x;f=f.__wrapped__}return w.__wrapped__=s,c}function eS(){var s=this.__wrapped__;if(s instanceof Mt){var c=s;return this.__actions__.length&&(c=new Mt(this)),c=c.reverse(),c.__actions__.push({func:Ac,args:[Gu],thisArg:t}),new pi(c,this.__chain__)}return this.thru(Gu)}function tS(){return cp(this.__wrapped__,this.__actions__)}var nS=xc(function(s,c,f){It.call(s,f)?++s[f]:ur(s,f,1)});function iS(s,c,f){var x=st(s)?Md:jx;return f&&kn(s,c,f)&&(c=t),x(s,Ye(c,3))}function rS(s,c){var f=st(s)?Lr:Xd;return f(s,Ye(c,3))}var sS=xp(kp),oS=xp(Hp);function aS(s,c){return yn(Rc(s,c),1)}function cS(s,c){return yn(Rc(s,c),se)}function lS(s,c,f){return f=f===t?1:at(f),yn(Rc(s,c),f)}function jp(s,c){var f=st(s)?fi:Nr;return f(s,Ye(c,3))}function qp(s,c){var f=st(s)?Rv:Wd;return f(s,Ye(c,3))}var uS=xc(function(s,c,f){It.call(s,f)?s[f].push(c):ur(s,f,[c])});function hS(s,c,f,x){s=jn(s)?s:Ys(s),f=f&&!x?at(f):0;var w=s.length;return f<0&&(f=fn(w+f,0)),Dc(s)?f<=w&&s.indexOf(c,f)>-1:!!w&&Us(s,c,f)>-1}var fS=pt(function(s,c,f){var x=-1,w=typeof c=="function",I=jn(s)?Q(s.length):[];return Nr(s,function(k){I[++x]=w?Zn(c,k,f):ta(k,c,f)}),I}),dS=xc(function(s,c,f){ur(s,f,c)});function Rc(s,c){var f=st(s)?Yt:Zd;return f(s,Ye(c,3))}function pS(s,c,f,x){return s==null?[]:(st(c)||(c=c==null?[]:[c]),f=x?t:f,st(f)||(f=f==null?[]:[f]),tp(s,c,f))}var mS=xc(function(s,c,f){s[f?0:1].push(c)},function(){return[[],[]]});function gS(s,c,f){var x=st(s)?tu:bd,w=arguments.length<3;return x(s,Ye(c,4),f,w,Nr)}function _S(s,c,f){var x=st(s)?Cv:bd,w=arguments.length<3;return x(s,Ye(c,4),f,w,Wd)}function vS(s,c){var f=st(s)?Lr:Xd;return f(s,Lc(Ye(c,3)))}function xS(s){var c=st(s)?kd:hy;return c(s)}function yS(s,c,f){(f?kn(s,c,f):c===t)?c=1:c=at(c);var x=st(s)?Gx:fy;return x(s,c)}function MS(s){var c=st(s)?Vx:py;return c(s)}function SS(s){if(s==null)return 0;if(jn(s))return Dc(s)?Os(s):s.length;var c=Rn(s);return c==mt||c==de?s.size:yu(s).length}function ES(s,c,f){var x=st(s)?nu:my;return f&&kn(s,c,f)&&(c=t),x(s,Ye(c,3))}var TS=pt(function(s,c){if(s==null)return[];var f=c.length;return f>1&&kn(s,c[0],c[1])?c=[]:f>2&&kn(c[0],c[1],c[2])&&(c=[c[0]]),tp(s,yn(c,1),[])}),Cc=rx||function(){return xn.Date.now()};function bS(s,c){if(typeof c!="function")throw new di(a);return s=at(s),function(){if(--s<1)return c.apply(this,arguments)}}function $p(s,c,f){return c=f?t:c,c=s&&c==null?s.length:c,hr(s,D,t,t,t,t,c)}function Kp(s,c){var f;if(typeof c!="function")throw new di(a);return s=at(s),function(){return--s>0&&(f=c.apply(this,arguments)),s<=1&&(c=t),f}}var Wu=pt(function(s,c,f){var x=_;if(f.length){var w=Dr(f,Ws(Wu));x|=B}return hr(s,x,c,f,w)}),Zp=pt(function(s,c,f){var x=_|v;if(f.length){var w=Dr(f,Ws(Zp));x|=B}return hr(c,x,s,f,w)});function Jp(s,c,f){c=f?t:c;var x=hr(s,b,t,t,t,t,t,c);return x.placeholder=Jp.placeholder,x}function Qp(s,c,f){c=f?t:c;var x=hr(s,A,t,t,t,t,t,c);return x.placeholder=Qp.placeholder,x}function em(s,c,f){var x,w,I,k,V,X,ue=0,he=!1,me=!1,Te=!0;if(typeof s!="function")throw new di(a);c=vi(c)||0,$t(f)&&(he=!!f.leading,me="maxWait"in f,I=me?fn(vi(f.maxWait)||0,c):I,Te="trailing"in f?!!f.trailing:Te);function Ue(sn){var Ci=x,gr=w;return x=w=t,ue=sn,k=s.apply(gr,Ci),k}function je(sn){return ue=sn,V=oa(xt,c),he?Ue(sn):k}function lt(sn){var Ci=sn-X,gr=sn-ue,xm=c-Ci;return me?An(xm,I-gr):xm}function qe(sn){var Ci=sn-X,gr=sn-ue;return X===t||Ci>=c||Ci<0||me&&gr>=I}function xt(){var sn=Cc();if(qe(sn))return bt(sn);V=oa(xt,lt(sn))}function bt(sn){return V=t,Te&&x?Ue(sn):(x=w=t,k)}function ti(){V!==t&&up(V),ue=0,x=X=w=V=t}function Hn(){return V===t?k:bt(Cc())}function ni(){var sn=Cc(),Ci=qe(sn);if(x=arguments,w=this,X=sn,Ci){if(V===t)return je(X);if(me)return up(V),V=oa(xt,c),Ue(X)}return V===t&&(V=oa(xt,c)),k}return ni.cancel=ti,ni.flush=Hn,ni}var wS=pt(function(s,c){return Vd(s,1,c)}),AS=pt(function(s,c,f){return Vd(s,vi(c)||0,f)});function RS(s){return hr(s,E)}function Pc(s,c){if(typeof s!="function"||c!=null&&typeof c!="function")throw new di(a);var f=function(){var x=arguments,w=c?c.apply(this,x):x[0],I=f.cache;if(I.has(w))return I.get(w);var k=s.apply(this,x);return f.cache=I.set(w,k)||I,k};return f.cache=new(Pc.Cache||lr),f}Pc.Cache=lr;function Lc(s){if(typeof s!="function")throw new di(a);return function(){var c=arguments;switch(c.length){case 0:return!s.call(this);case 1:return!s.call(this,c[0]);case 2:return!s.call(this,c[0],c[1]);case 3:return!s.call(this,c[0],c[1],c[2])}return!s.apply(this,c)}}function CS(s){return Kp(2,s)}var PS=gy(function(s,c){c=c.length==1&&st(c[0])?Yt(c[0],Jn(Ye())):Yt(yn(c,1),Jn(Ye()));var f=c.length;return pt(function(x){for(var w=-1,I=An(x.length,f);++w<I;)x[w]=c[w].call(this,x[w]);return Zn(s,this,x)})}),Xu=pt(function(s,c){var f=Dr(c,Ws(Xu));return hr(s,B,t,c,f)}),tm=pt(function(s,c){var f=Dr(c,Ws(tm));return hr(s,N,t,c,f)}),LS=fr(function(s,c){return hr(s,C,t,t,t,c)});function IS(s,c){if(typeof s!="function")throw new di(a);return c=c===t?c:at(c),pt(s,c)}function DS(s,c){if(typeof s!="function")throw new di(a);return c=c==null?0:fn(at(c),0),pt(function(f){var x=f[c],w=Br(f,0,c);return x&&Ir(w,x),Zn(s,this,w)})}function US(s,c,f){var x=!0,w=!0;if(typeof s!="function")throw new di(a);return $t(f)&&(x="leading"in f?!!f.leading:x,w="trailing"in f?!!f.trailing:w),em(s,c,{leading:x,maxWait:c,trailing:w})}function NS(s){return $p(s,1)}function OS(s,c){return Xu(Cu(c),s)}function FS(){if(!arguments.length)return[];var s=arguments[0];return st(s)?s:[s]}function BS(s){return mi(s,g)}function zS(s,c){return c=typeof c=="function"?c:t,mi(s,g,c)}function kS(s){return mi(s,p|g)}function HS(s,c){return c=typeof c=="function"?c:t,mi(s,p|g,c)}function GS(s,c){return c==null||Gd(s,c,gn(c))}function Ri(s,c){return s===c||s!==s&&c!==c}var VS=Ec(_u),WS=Ec(function(s,c){return s>=c}),fs=qd(function(){return arguments}())?qd:function(s){return Qt(s)&&It.call(s,"callee")&&!Ud.call(s,"callee")},st=Q.isArray,XS=md?Jn(md):Qx;function jn(s){return s!=null&&Ic(s.length)&&!pr(s)}function rn(s){return Qt(s)&&jn(s)}function YS(s){return s===!0||s===!1||Qt(s)&&zn(s)==ze}var zr=ox||nh,jS=gd?Jn(gd):ey;function qS(s){return Qt(s)&&s.nodeType===1&&!aa(s)}function $S(s){if(s==null)return!0;if(jn(s)&&(st(s)||typeof s=="string"||typeof s.splice=="function"||zr(s)||Xs(s)||fs(s)))return!s.length;var c=Rn(s);if(c==mt||c==de)return!s.size;if(sa(s))return!yu(s).length;for(var f in s)if(It.call(s,f))return!1;return!0}function KS(s,c){return na(s,c)}function ZS(s,c,f){f=typeof f=="function"?f:t;var x=f?f(s,c):t;return x===t?na(s,c,t,f):!!x}function Yu(s){if(!Qt(s))return!1;var c=zn(s);return c==q||c==it||typeof s.message=="string"&&typeof s.name=="string"&&!aa(s)}function JS(s){return typeof s=="number"&&Od(s)}function pr(s){if(!$t(s))return!1;var c=zn(s);return c==$e||c==Fe||c==Me||c==ie}function nm(s){return typeof s=="number"&&s==at(s)}function Ic(s){return typeof s=="number"&&s>-1&&s%1==0&&s<=K}function $t(s){var c=typeof s;return s!=null&&(c=="object"||c=="function")}function Qt(s){return s!=null&&typeof s=="object"}var im=_d?Jn(_d):ny;function QS(s,c){return s===c||xu(s,c,Ou(c))}function eE(s,c,f){return f=typeof f=="function"?f:t,xu(s,c,Ou(c),f)}function tE(s){return rm(s)&&s!=+s}function nE(s){if(zy(s))throw new nt(o);return $d(s)}function iE(s){return s===null}function rE(s){return s==null}function rm(s){return typeof s=="number"||Qt(s)&&zn(s)==We}function aa(s){if(!Qt(s)||zn(s)!=z)return!1;var c=sc(s);if(c===null)return!0;var f=It.call(c,"constructor")&&c.constructor;return typeof f=="function"&&f instanceof f&&tc.call(f)==ex}var ju=vd?Jn(vd):iy;function sE(s){return nm(s)&&s>=-9007199254740991&&s<=K}var sm=xd?Jn(xd):ry;function Dc(s){return typeof s=="string"||!st(s)&&Qt(s)&&zn(s)==ge}function ei(s){return typeof s=="symbol"||Qt(s)&&zn(s)==He}var Xs=yd?Jn(yd):sy;function oE(s){return s===t}function aE(s){return Qt(s)&&Rn(s)==De}function cE(s){return Qt(s)&&zn(s)==Xe}var lE=Ec(Mu),uE=Ec(function(s,c){return s<=c});function om(s){if(!s)return[];if(jn(s))return Dc(s)?wi(s):Yn(s);if(qo&&s[qo])return Gv(s[qo]());var c=Rn(s),f=c==mt?cu:c==de?Ja:Ys;return f(s)}function mr(s){if(!s)return s===0?s:0;if(s=vi(s),s===se||s===-1/0){var c=s<0?-1:1;return c*ae}return s===s?s:0}function at(s){var c=mr(s),f=c%1;return c===c?f?c-f:c:0}function am(s){return s?cs(at(s),0,ve):0}function vi(s){if(typeof s=="number")return s;if(ei(s))return pe;if($t(s)){var c=typeof s.valueOf=="function"?s.valueOf():s;s=$t(c)?c+"":c}if(typeof s!="string")return s===0?s:+s;s=wd(s);var f=ee.test(s);return f||J.test(s)?bv(s.slice(2),f?2:8):j.test(s)?pe:+s}function cm(s){return Wi(s,qn(s))}function hE(s){return s?cs(at(s),-9007199254740991,K):s===0?s:0}function Pt(s){return s==null?"":Qn(s)}var fE=Gs(function(s,c){if(sa(c)||jn(c)){Wi(c,gn(c),s);return}for(var f in c)It.call(c,f)&&Qo(s,f,c[f])}),lm=Gs(function(s,c){Wi(c,qn(c),s)}),Uc=Gs(function(s,c,f,x){Wi(c,qn(c),s,x)}),dE=Gs(function(s,c,f,x){Wi(c,gn(c),s,x)}),pE=fr(pu);function mE(s,c){var f=Hs(s);return c==null?f:Hd(f,c)}var gE=pt(function(s,c){s=Ot(s);var f=-1,x=c.length,w=x>2?c[2]:t;for(w&&kn(c[0],c[1],w)&&(x=1);++f<x;)for(var I=c[f],k=qn(I),V=-1,X=k.length;++V<X;){var ue=k[V],he=s[ue];(he===t||Ri(he,Bs[ue])&&!It.call(s,ue))&&(s[ue]=I[ue])}return s}),_E=pt(function(s){return s.push(t,wp),Zn(um,t,s)});function vE(s,c){return Sd(s,Ye(c,3),Vi)}function xE(s,c){return Sd(s,Ye(c,3),gu)}function yE(s,c){return s==null?s:mu(s,Ye(c,3),qn)}function ME(s,c){return s==null?s:Yd(s,Ye(c,3),qn)}function SE(s,c){return s&&Vi(s,Ye(c,3))}function EE(s,c){return s&&gu(s,Ye(c,3))}function TE(s){return s==null?[]:mc(s,gn(s))}function bE(s){return s==null?[]:mc(s,qn(s))}function qu(s,c,f){var x=s==null?t:ls(s,c);return x===t?f:x}function wE(s,c){return s!=null&&Cp(s,c,$x)}function $u(s,c){return s!=null&&Cp(s,c,Kx)}var AE=Mp(function(s,c,f){c!=null&&typeof c.toString!="function"&&(c=nc.call(c)),s[c]=f},Zu($n)),RE=Mp(function(s,c,f){c!=null&&typeof c.toString!="function"&&(c=nc.call(c)),It.call(s,c)?s[c].push(f):s[c]=[f]},Ye),CE=pt(ta);function gn(s){return jn(s)?zd(s):yu(s)}function qn(s){return jn(s)?zd(s,!0):oy(s)}function PE(s,c){var f={};return c=Ye(c,3),Vi(s,function(x,w,I){ur(f,c(x,w,I),x)}),f}function LE(s,c){var f={};return c=Ye(c,3),Vi(s,function(x,w,I){ur(f,w,c(x,w,I))}),f}var IE=Gs(function(s,c,f){gc(s,c,f)}),um=Gs(function(s,c,f,x){gc(s,c,f,x)}),DE=fr(function(s,c){var f={};if(s==null)return f;var x=!1;c=Yt(c,function(I){return I=Fr(I,s),x||(x=I.length>1),I}),Wi(s,Uu(s),f),x&&(f=mi(f,p|m|g,Ay));for(var w=c.length;w--;)wu(f,c[w]);return f});function UE(s,c){return hm(s,Lc(Ye(c)))}var NE=fr(function(s,c){return s==null?{}:cy(s,c)});function hm(s,c){if(s==null)return{};var f=Yt(Uu(s),function(x){return[x]});return c=Ye(c),np(s,f,function(x,w){return c(x,w[0])})}function OE(s,c,f){c=Fr(c,s);var x=-1,w=c.length;for(w||(w=1,s=t);++x<w;){var I=s==null?t:s[Xi(c[x])];I===t&&(x=w,I=f),s=pr(I)?I.call(s):I}return s}function FE(s,c,f){return s==null?s:ia(s,c,f)}function BE(s,c,f,x){return x=typeof x=="function"?x:t,s==null?s:ia(s,c,f,x)}var fm=Tp(gn),dm=Tp(qn);function zE(s,c,f){var x=st(s),w=x||zr(s)||Xs(s);if(c=Ye(c,4),f==null){var I=s&&s.constructor;w?f=x?new I:[]:$t(s)?f=pr(I)?Hs(sc(s)):{}:f={}}return(w?fi:Vi)(s,function(k,V,X){return c(f,k,V,X)}),f}function kE(s,c){return s==null?!0:wu(s,c)}function HE(s,c,f){return s==null?s:ap(s,c,Cu(f))}function GE(s,c,f,x){return x=typeof x=="function"?x:t,s==null?s:ap(s,c,Cu(f),x)}function Ys(s){return s==null?[]:au(s,gn(s))}function VE(s){return s==null?[]:au(s,qn(s))}function WE(s,c,f){return f===t&&(f=c,c=t),f!==t&&(f=vi(f),f=f===f?f:0),c!==t&&(c=vi(c),c=c===c?c:0),cs(vi(s),c,f)}function XE(s,c,f){return c=mr(c),f===t?(f=c,c=0):f=mr(f),s=vi(s),Zx(s,c,f)}function YE(s,c,f){if(f&&typeof f!="boolean"&&kn(s,c,f)&&(c=f=t),f===t&&(typeof c=="boolean"?(f=c,c=t):typeof s=="boolean"&&(f=s,s=t)),s===t&&c===t?(s=0,c=1):(s=mr(s),c===t?(c=s,s=0):c=mr(c)),s>c){var x=s;s=c,c=x}if(f||s%1||c%1){var w=Fd();return An(s+w*(c-s+Tv("1e-"+((w+"").length-1))),c)}return Eu(s,c)}var jE=Vs(function(s,c,f){return c=c.toLowerCase(),s+(f?pm(c):c)});function pm(s){return Ku(Pt(s).toLowerCase())}function mm(s){return s=Pt(s),s&&s.replace(Be,Fv).replace(pv,"")}function qE(s,c,f){s=Pt(s),c=Qn(c);var x=s.length;f=f===t?x:cs(at(f),0,x);var w=f;return f-=c.length,f>=0&&s.slice(f,w)==c}function $E(s){return s=Pt(s),s&&dt.test(s)?s.replace(Re,Bv):s}function KE(s){return s=Pt(s),s&&ki.test(s)?s.replace(bn,"\\$&"):s}var ZE=Vs(function(s,c,f){return s+(f?"-":"")+c.toLowerCase()}),JE=Vs(function(s,c,f){return s+(f?" ":"")+c.toLowerCase()}),QE=vp("toLowerCase");function eT(s,c,f){s=Pt(s),c=at(c);var x=c?Os(s):0;if(!c||x>=c)return s;var w=(c-x)/2;return Sc(lc(w),f)+s+Sc(cc(w),f)}function tT(s,c,f){s=Pt(s),c=at(c);var x=c?Os(s):0;return c&&x<c?s+Sc(c-x,f):s}function nT(s,c,f){s=Pt(s),c=at(c);var x=c?Os(s):0;return c&&x<c?Sc(c-x,f)+s:s}function iT(s,c,f){return f||c==null?c=0:c&&(c=+c),ux(Pt(s).replace(Hi,""),c||0)}function rT(s,c,f){return(f?kn(s,c,f):c===t)?c=1:c=at(c),Tu(Pt(s),c)}function sT(){var s=arguments,c=Pt(s[0]);return s.length<3?c:c.replace(s[1],s[2])}var oT=Vs(function(s,c,f){return s+(f?"_":"")+c.toLowerCase()});function aT(s,c,f){return f&&typeof f!="number"&&kn(s,c,f)&&(c=f=t),f=f===t?ve:f>>>0,f?(s=Pt(s),s&&(typeof c=="string"||c!=null&&!ju(c))&&(c=Qn(c),!c&&Ns(s))?Br(wi(s),0,f):s.split(c,f)):[]}var cT=Vs(function(s,c,f){return s+(f?" ":"")+Ku(c)});function lT(s,c,f){return s=Pt(s),f=f==null?0:cs(at(f),0,s.length),c=Qn(c),s.slice(f,f+c.length)==c}function uT(s,c,f){var x=L.templateSettings;f&&kn(s,c,f)&&(c=t),s=Pt(s),c=Uc({},c,x,bp);var w=Uc({},c.imports,x.imports,bp),I=gn(w),k=au(w,I),V,X,ue=0,he=c.interpolate||Ge,me="__p += '",Te=lu((c.escape||Ge).source+"|"+he.source+"|"+(he===Rt?jl:Ge).source+"|"+(c.evaluate||Ge).source+"|$","g"),Ue="//# sourceURL="+(It.call(c,"sourceURL")?(c.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++xv+"]")+`
3806
+ `)}function Oy(s){return st(s)||fs(s)||!!(Nd&&s&&s[Nd])}function dr(s,c){var f=typeof s;return c=c??K,!!c&&(f=="number"||f!="symbol"&&Ae.test(s))&&s>-1&&s%1==0&&s<c}function kn(s,c,f){if(!$t(f))return!1;var x=typeof c;return(x=="number"?jn(f)&&dr(c,f.length):x=="string"&&c in f)?Ri(f[c],s):!1}function zu(s,c){if(st(s))return!1;var f=typeof s;return f=="number"||f=="symbol"||f=="boolean"||s==null||ei(s)?!0:Jt.test(s)||!Zt.test(s)||c!=null&&s in Ot(c)}function Fy(s){var c=typeof s;return c=="string"||c=="number"||c=="symbol"||c=="boolean"?s!=="__proto__":s===null}function ku(s){var c=Tc(s),f=L[c];if(typeof f!="function"||!(c in Mt.prototype))return!1;if(s===f)return!0;var x=Ou(f);return!!x&&s===x[0]}function By(s){return!!Ld&&Ld in s}var zy=ec?pr:ih;function sa(s){var c=s&&s.constructor,f=typeof c=="function"&&c.prototype||Bs;return s===f}function Lp(s){return s===s&&!$t(s)}function Ip(s,c){return function(f){return f==null?!1:f[s]===c&&(c!==t||s in Ot(f))}}function ky(s){var c=Pc(s,function(x){return f.size===h&&f.clear(),x}),f=c.cache;return c}function Hy(s,c){var f=s[1],x=c[1],w=f|x,I=w<(_|v|D),k=x==D&&f==b||x==D&&f==C&&s[7].length<=c[8]||x==(D|C)&&c[7].length<=c[8]&&f==b;if(!(I||k))return s;x&_&&(s[2]=c[2],w|=f&_?0:R);var V=c[3];if(V){var X=s[3];s[3]=X?pp(X,V,c[4]):V,s[4]=X?Dr(s[3],d):c[4]}return V=c[5],V&&(X=s[5],s[5]=X?mp(X,V,c[6]):V,s[6]=X?Dr(s[5],d):c[6]),V=c[7],V&&(s[7]=V),x&D&&(s[8]=s[8]==null?c[8]:An(s[8],c[8])),s[9]==null&&(s[9]=c[9]),s[0]=c[0],s[1]=w,s}function Gy(s){var c=[];if(s!=null)for(var f in Ot(s))c.push(f);return c}function Vy(s){return nc.call(s)}function Dp(s,c,f){return c=fn(c===t?s.length-1:c,0),function(){for(var x=arguments,w=-1,I=fn(x.length-c,0),k=Q(I);++w<I;)k[w]=x[c+w];w=-1;for(var V=Q(c+1);++w<c;)V[w]=x[w];return V[c]=f(k),Zn(s,this,V)}}function Up(s,c){return c.length<2?s:ls(s,gi(c,0,-1))}function Wy(s,c){for(var f=s.length,x=An(c.length,f),w=Yn(s);x--;){var I=c[x];s[x]=dr(I,f)?w[I]:t}return s}function Hu(s,c){if(!(c==="constructor"&&typeof s[c]=="function")&&c!="__proto__")return s[c]}var Np=Fp(rp),oa=sx||function(s,c){return xn.setTimeout(s,c)},Gu=Fp(dy);function Op(s,c,f){var x=c+"";return Gu(s,Ny(x,Xy(Iy(x),f)))}function Fp(s){var c=0,f=0;return function(){var x=lx(),w=G-(x-f);if(f=x,w>0){if(++c>=H)return arguments[0]}else c=0;return s.apply(t,arguments)}}function wc(s,c){var f=-1,x=s.length,w=x-1;for(c=c===t?x:c;++f<c;){var I=Tu(f,w),k=s[I];s[I]=s[f],s[f]=k}return s.length=c,s}var Bp=ky(function(s){var c=[];return s.charCodeAt(0)===46&&c.push(""),s.replace(Fn,function(f,x,w,I){c.push(w?I.replace(jl,"$1"):x||f)}),c});function Xi(s){if(typeof s=="string"||ei(s))return s;var c=s+"";return c=="0"&&1/s==-1/0?"-0":c}function hs(s){if(s!=null){try{return tc.call(s)}catch{}try{return s+""}catch{}}return""}function Xy(s,c){return fi(te,function(f){var x="_."+f[0];c&f[1]&&!Ka(s,x)&&s.push(x)}),s.sort()}function zp(s){if(s instanceof Mt)return s.clone();var c=new pi(s.__wrapped__,s.__chain__);return c.__actions__=Yn(s.__actions__),c.__index__=s.__index__,c.__values__=s.__values__,c}function Yy(s,c,f){(f?kn(s,c,f):c===t)?c=1:c=fn(at(c),0);var x=s==null?0:s.length;if(!x||c<1)return[];for(var w=0,I=0,k=Q(cc(x/c));w<x;)k[I++]=gi(s,w,w+=c);return k}function jy(s){for(var c=-1,f=s==null?0:s.length,x=0,w=[];++c<f;){var I=s[c];I&&(w[x++]=I)}return w}function qy(){var s=arguments.length;if(!s)return[];for(var c=Q(s-1),f=arguments[0],x=s;x--;)c[x-1]=arguments[x];return Ir(st(f)?Yn(f):[f],yn(c,1))}var $y=pt(function(s,c){return rn(s)?ea(s,yn(c,1,rn,!0)):[]}),Ky=pt(function(s,c){var f=_i(c);return rn(f)&&(f=t),rn(s)?ea(s,yn(c,1,rn,!0),Ye(f,2)):[]}),Zy=pt(function(s,c){var f=_i(c);return rn(f)&&(f=t),rn(s)?ea(s,yn(c,1,rn,!0),t,f):[]});function Jy(s,c,f){var x=s==null?0:s.length;return x?(c=f||c===t?1:at(c),gi(s,c<0?0:c,x)):[]}function Qy(s,c,f){var x=s==null?0:s.length;return x?(c=f||c===t?1:at(c),c=x-c,gi(s,0,c<0?0:c)):[]}function eM(s,c){return s&&s.length?vc(s,Ye(c,3),!0,!0):[]}function tM(s,c){return s&&s.length?vc(s,Ye(c,3),!0):[]}function nM(s,c,f,x){var w=s==null?0:s.length;return w?(f&&typeof f!="number"&&kn(s,c,f)&&(f=0,x=w),qx(s,c,f,x)):[]}function kp(s,c,f){var x=s==null?0:s.length;if(!x)return-1;var w=f==null?0:at(f);return w<0&&(w=fn(x+w,0)),Za(s,Ye(c,3),w)}function Hp(s,c,f){var x=s==null?0:s.length;if(!x)return-1;var w=x-1;return f!==t&&(w=at(f),w=f<0?fn(x+w,0):An(w,x-1)),Za(s,Ye(c,3),w,!0)}function Gp(s){var c=s==null?0:s.length;return c?yn(s,1):[]}function iM(s){var c=s==null?0:s.length;return c?yn(s,se):[]}function rM(s,c){var f=s==null?0:s.length;return f?(c=c===t?1:at(c),yn(s,c)):[]}function sM(s){for(var c=-1,f=s==null?0:s.length,x={};++c<f;){var w=s[c];x[w[0]]=w[1]}return x}function Vp(s){return s&&s.length?s[0]:t}function oM(s,c,f){var x=s==null?0:s.length;if(!x)return-1;var w=f==null?0:at(f);return w<0&&(w=fn(x+w,0)),Us(s,c,w)}function aM(s){var c=s==null?0:s.length;return c?gi(s,0,-1):[]}var cM=pt(function(s){var c=Yt(s,Cu);return c.length&&c[0]===s[0]?xu(c):[]}),lM=pt(function(s){var c=_i(s),f=Yt(s,Cu);return c===_i(f)?c=t:f.pop(),f.length&&f[0]===s[0]?xu(f,Ye(c,2)):[]}),uM=pt(function(s){var c=_i(s),f=Yt(s,Cu);return c=typeof c=="function"?c:t,c&&f.pop(),f.length&&f[0]===s[0]?xu(f,t,c):[]});function hM(s,c){return s==null?"":ax.call(s,c)}function _i(s){var c=s==null?0:s.length;return c?s[c-1]:t}function fM(s,c,f){var x=s==null?0:s.length;if(!x)return-1;var w=x;return f!==t&&(w=at(f),w=w<0?fn(x+w,0):An(w,x-1)),c===c?Xv(s,c,w):Za(s,Ed,w,!0)}function dM(s,c){return s&&s.length?ep(s,at(c)):t}var pM=pt(Wp);function Wp(s,c){return s&&s.length&&c&&c.length?Eu(s,c):s}function mM(s,c,f){return s&&s.length&&c&&c.length?Eu(s,c,Ye(f,2)):s}function gM(s,c,f){return s&&s.length&&c&&c.length?Eu(s,c,t,f):s}var _M=fr(function(s,c){var f=s==null?0:s.length,x=mu(s,c);return ip(s,Yt(c,function(w){return dr(w,f)?+w:w}).sort(dp)),x});function vM(s,c){var f=[];if(!(s&&s.length))return f;var x=-1,w=[],I=s.length;for(c=Ye(c,3);++x<I;){var k=s[x];c(k,x,s)&&(f.push(k),w.push(x))}return ip(s,w),f}function Vu(s){return s==null?s:hx.call(s)}function xM(s,c,f){var x=s==null?0:s.length;return x?(f&&typeof f!="number"&&kn(s,c,f)?(c=0,f=x):(c=c==null?0:at(c),f=f===t?x:at(f)),gi(s,c,f)):[]}function yM(s,c){return _c(s,c)}function MM(s,c,f){return wu(s,c,Ye(f,2))}function SM(s,c){var f=s==null?0:s.length;if(f){var x=_c(s,c);if(x<f&&Ri(s[x],c))return x}return-1}function EM(s,c){return _c(s,c,!0)}function TM(s,c,f){return wu(s,c,Ye(f,2),!0)}function bM(s,c){var f=s==null?0:s.length;if(f){var x=_c(s,c,!0)-1;if(Ri(s[x],c))return x}return-1}function wM(s){return s&&s.length?sp(s):[]}function AM(s,c){return s&&s.length?sp(s,Ye(c,2)):[]}function RM(s){var c=s==null?0:s.length;return c?gi(s,1,c):[]}function CM(s,c,f){return s&&s.length?(c=f||c===t?1:at(c),gi(s,0,c<0?0:c)):[]}function PM(s,c,f){var x=s==null?0:s.length;return x?(c=f||c===t?1:at(c),c=x-c,gi(s,c<0?0:c,x)):[]}function LM(s,c){return s&&s.length?vc(s,Ye(c,3),!1,!0):[]}function IM(s,c){return s&&s.length?vc(s,Ye(c,3)):[]}var DM=pt(function(s){return Or(yn(s,1,rn,!0))}),UM=pt(function(s){var c=_i(s);return rn(c)&&(c=t),Or(yn(s,1,rn,!0),Ye(c,2))}),NM=pt(function(s){var c=_i(s);return c=typeof c=="function"?c:t,Or(yn(s,1,rn,!0),t,c)});function OM(s){return s&&s.length?Or(s):[]}function FM(s,c){return s&&s.length?Or(s,Ye(c,2)):[]}function BM(s,c){return c=typeof c=="function"?c:t,s&&s.length?Or(s,t,c):[]}function Wu(s){if(!(s&&s.length))return[];var c=0;return s=Lr(s,function(f){if(rn(f))return c=fn(f.length,c),!0}),au(c,function(f){return Yt(s,ru(f))})}function Xp(s,c){if(!(s&&s.length))return[];var f=Wu(s);return c==null?f:Yt(f,function(x){return Zn(c,t,x)})}var zM=pt(function(s,c){return rn(s)?ea(s,c):[]}),kM=pt(function(s){return Ru(Lr(s,rn))}),HM=pt(function(s){var c=_i(s);return rn(c)&&(c=t),Ru(Lr(s,rn),Ye(c,2))}),GM=pt(function(s){var c=_i(s);return c=typeof c=="function"?c:t,Ru(Lr(s,rn),t,c)}),VM=pt(Wu);function WM(s,c){return lp(s||[],c||[],Qo)}function XM(s,c){return lp(s||[],c||[],ia)}var YM=pt(function(s){var c=s.length,f=c>1?s[c-1]:t;return f=typeof f=="function"?(s.pop(),f):t,Xp(s,f)});function Yp(s){var c=L(s);return c.__chain__=!0,c}function jM(s,c){return c(s),s}function Ac(s,c){return c(s)}var qM=fr(function(s){var c=s.length,f=c?s[0]:0,x=this.__wrapped__,w=function(I){return mu(I,s)};return c>1||this.__actions__.length||!(x instanceof Mt)||!dr(f)?this.thru(w):(x=x.slice(f,+f+(c?1:0)),x.__actions__.push({func:Ac,args:[w],thisArg:t}),new pi(x,this.__chain__).thru(function(I){return c&&!I.length&&I.push(t),I}))});function $M(){return Yp(this)}function KM(){return new pi(this.value(),this.__chain__)}function ZM(){this.__values__===t&&(this.__values__=om(this.value()));var s=this.__index__>=this.__values__.length,c=s?t:this.__values__[this.__index__++];return{done:s,value:c}}function JM(){return this}function QM(s){for(var c,f=this;f instanceof fc;){var x=zp(f);x.__index__=0,x.__values__=t,c?w.__wrapped__=x:c=x;var w=x;f=f.__wrapped__}return w.__wrapped__=s,c}function eS(){var s=this.__wrapped__;if(s instanceof Mt){var c=s;return this.__actions__.length&&(c=new Mt(this)),c=c.reverse(),c.__actions__.push({func:Ac,args:[Vu],thisArg:t}),new pi(c,this.__chain__)}return this.thru(Vu)}function tS(){return cp(this.__wrapped__,this.__actions__)}var nS=xc(function(s,c,f){It.call(s,f)?++s[f]:ur(s,f,1)});function iS(s,c,f){var x=st(s)?Md:jx;return f&&kn(s,c,f)&&(c=t),x(s,Ye(c,3))}function rS(s,c){var f=st(s)?Lr:Xd;return f(s,Ye(c,3))}var sS=xp(kp),oS=xp(Hp);function aS(s,c){return yn(Rc(s,c),1)}function cS(s,c){return yn(Rc(s,c),se)}function lS(s,c,f){return f=f===t?1:at(f),yn(Rc(s,c),f)}function jp(s,c){var f=st(s)?fi:Nr;return f(s,Ye(c,3))}function qp(s,c){var f=st(s)?Rv:Wd;return f(s,Ye(c,3))}var uS=xc(function(s,c,f){It.call(s,f)?s[f].push(c):ur(s,f,[c])});function hS(s,c,f,x){s=jn(s)?s:Ys(s),f=f&&!x?at(f):0;var w=s.length;return f<0&&(f=fn(w+f,0)),Dc(s)?f<=w&&s.indexOf(c,f)>-1:!!w&&Us(s,c,f)>-1}var fS=pt(function(s,c,f){var x=-1,w=typeof c=="function",I=jn(s)?Q(s.length):[];return Nr(s,function(k){I[++x]=w?Zn(c,k,f):ta(k,c,f)}),I}),dS=xc(function(s,c,f){ur(s,f,c)});function Rc(s,c){var f=st(s)?Yt:Zd;return f(s,Ye(c,3))}function pS(s,c,f,x){return s==null?[]:(st(c)||(c=c==null?[]:[c]),f=x?t:f,st(f)||(f=f==null?[]:[f]),tp(s,c,f))}var mS=xc(function(s,c,f){s[f?0:1].push(c)},function(){return[[],[]]});function gS(s,c,f){var x=st(s)?nu:bd,w=arguments.length<3;return x(s,Ye(c,4),f,w,Nr)}function _S(s,c,f){var x=st(s)?Cv:bd,w=arguments.length<3;return x(s,Ye(c,4),f,w,Wd)}function vS(s,c){var f=st(s)?Lr:Xd;return f(s,Lc(Ye(c,3)))}function xS(s){var c=st(s)?kd:hy;return c(s)}function yS(s,c,f){(f?kn(s,c,f):c===t)?c=1:c=at(c);var x=st(s)?Gx:fy;return x(s,c)}function MS(s){var c=st(s)?Vx:py;return c(s)}function SS(s){if(s==null)return 0;if(jn(s))return Dc(s)?Os(s):s.length;var c=Rn(s);return c==mt||c==de?s.size:Mu(s).length}function ES(s,c,f){var x=st(s)?iu:my;return f&&kn(s,c,f)&&(c=t),x(s,Ye(c,3))}var TS=pt(function(s,c){if(s==null)return[];var f=c.length;return f>1&&kn(s,c[0],c[1])?c=[]:f>2&&kn(c[0],c[1],c[2])&&(c=[c[0]]),tp(s,yn(c,1),[])}),Cc=rx||function(){return xn.Date.now()};function bS(s,c){if(typeof c!="function")throw new di(a);return s=at(s),function(){if(--s<1)return c.apply(this,arguments)}}function $p(s,c,f){return c=f?t:c,c=s&&c==null?s.length:c,hr(s,D,t,t,t,t,c)}function Kp(s,c){var f;if(typeof c!="function")throw new di(a);return s=at(s),function(){return--s>0&&(f=c.apply(this,arguments)),s<=1&&(c=t),f}}var Xu=pt(function(s,c,f){var x=_;if(f.length){var w=Dr(f,Ws(Xu));x|=B}return hr(s,x,c,f,w)}),Zp=pt(function(s,c,f){var x=_|v;if(f.length){var w=Dr(f,Ws(Zp));x|=B}return hr(c,x,s,f,w)});function Jp(s,c,f){c=f?t:c;var x=hr(s,b,t,t,t,t,t,c);return x.placeholder=Jp.placeholder,x}function Qp(s,c,f){c=f?t:c;var x=hr(s,A,t,t,t,t,t,c);return x.placeholder=Qp.placeholder,x}function em(s,c,f){var x,w,I,k,V,X,ue=0,he=!1,me=!1,Te=!0;if(typeof s!="function")throw new di(a);c=vi(c)||0,$t(f)&&(he=!!f.leading,me="maxWait"in f,I=me?fn(vi(f.maxWait)||0,c):I,Te="trailing"in f?!!f.trailing:Te);function Ue(sn){var Ci=x,gr=w;return x=w=t,ue=sn,k=s.apply(gr,Ci),k}function je(sn){return ue=sn,V=oa(xt,c),he?Ue(sn):k}function lt(sn){var Ci=sn-X,gr=sn-ue,xm=c-Ci;return me?An(xm,I-gr):xm}function qe(sn){var Ci=sn-X,gr=sn-ue;return X===t||Ci>=c||Ci<0||me&&gr>=I}function xt(){var sn=Cc();if(qe(sn))return bt(sn);V=oa(xt,lt(sn))}function bt(sn){return V=t,Te&&x?Ue(sn):(x=w=t,k)}function ti(){V!==t&&up(V),ue=0,x=X=w=V=t}function Hn(){return V===t?k:bt(Cc())}function ni(){var sn=Cc(),Ci=qe(sn);if(x=arguments,w=this,X=sn,Ci){if(V===t)return je(X);if(me)return up(V),V=oa(xt,c),Ue(X)}return V===t&&(V=oa(xt,c)),k}return ni.cancel=ti,ni.flush=Hn,ni}var wS=pt(function(s,c){return Vd(s,1,c)}),AS=pt(function(s,c,f){return Vd(s,vi(c)||0,f)});function RS(s){return hr(s,E)}function Pc(s,c){if(typeof s!="function"||c!=null&&typeof c!="function")throw new di(a);var f=function(){var x=arguments,w=c?c.apply(this,x):x[0],I=f.cache;if(I.has(w))return I.get(w);var k=s.apply(this,x);return f.cache=I.set(w,k)||I,k};return f.cache=new(Pc.Cache||lr),f}Pc.Cache=lr;function Lc(s){if(typeof s!="function")throw new di(a);return function(){var c=arguments;switch(c.length){case 0:return!s.call(this);case 1:return!s.call(this,c[0]);case 2:return!s.call(this,c[0],c[1]);case 3:return!s.call(this,c[0],c[1],c[2])}return!s.apply(this,c)}}function CS(s){return Kp(2,s)}var PS=gy(function(s,c){c=c.length==1&&st(c[0])?Yt(c[0],Jn(Ye())):Yt(yn(c,1),Jn(Ye()));var f=c.length;return pt(function(x){for(var w=-1,I=An(x.length,f);++w<I;)x[w]=c[w].call(this,x[w]);return Zn(s,this,x)})}),Yu=pt(function(s,c){var f=Dr(c,Ws(Yu));return hr(s,B,t,c,f)}),tm=pt(function(s,c){var f=Dr(c,Ws(tm));return hr(s,N,t,c,f)}),LS=fr(function(s,c){return hr(s,C,t,t,t,c)});function IS(s,c){if(typeof s!="function")throw new di(a);return c=c===t?c:at(c),pt(s,c)}function DS(s,c){if(typeof s!="function")throw new di(a);return c=c==null?0:fn(at(c),0),pt(function(f){var x=f[c],w=Br(f,0,c);return x&&Ir(w,x),Zn(s,this,w)})}function US(s,c,f){var x=!0,w=!0;if(typeof s!="function")throw new di(a);return $t(f)&&(x="leading"in f?!!f.leading:x,w="trailing"in f?!!f.trailing:w),em(s,c,{leading:x,maxWait:c,trailing:w})}function NS(s){return $p(s,1)}function OS(s,c){return Yu(Pu(c),s)}function FS(){if(!arguments.length)return[];var s=arguments[0];return st(s)?s:[s]}function BS(s){return mi(s,g)}function zS(s,c){return c=typeof c=="function"?c:t,mi(s,g,c)}function kS(s){return mi(s,p|g)}function HS(s,c){return c=typeof c=="function"?c:t,mi(s,p|g,c)}function GS(s,c){return c==null||Gd(s,c,gn(c))}function Ri(s,c){return s===c||s!==s&&c!==c}var VS=Ec(vu),WS=Ec(function(s,c){return s>=c}),fs=qd(function(){return arguments}())?qd:function(s){return Qt(s)&&It.call(s,"callee")&&!Ud.call(s,"callee")},st=Q.isArray,XS=md?Jn(md):Qx;function jn(s){return s!=null&&Ic(s.length)&&!pr(s)}function rn(s){return Qt(s)&&jn(s)}function YS(s){return s===!0||s===!1||Qt(s)&&zn(s)==ze}var zr=ox||ih,jS=gd?Jn(gd):ey;function qS(s){return Qt(s)&&s.nodeType===1&&!aa(s)}function $S(s){if(s==null)return!0;if(jn(s)&&(st(s)||typeof s=="string"||typeof s.splice=="function"||zr(s)||Xs(s)||fs(s)))return!s.length;var c=Rn(s);if(c==mt||c==de)return!s.size;if(sa(s))return!Mu(s).length;for(var f in s)if(It.call(s,f))return!1;return!0}function KS(s,c){return na(s,c)}function ZS(s,c,f){f=typeof f=="function"?f:t;var x=f?f(s,c):t;return x===t?na(s,c,t,f):!!x}function ju(s){if(!Qt(s))return!1;var c=zn(s);return c==q||c==it||typeof s.message=="string"&&typeof s.name=="string"&&!aa(s)}function JS(s){return typeof s=="number"&&Od(s)}function pr(s){if(!$t(s))return!1;var c=zn(s);return c==$e||c==Fe||c==Me||c==ie}function nm(s){return typeof s=="number"&&s==at(s)}function Ic(s){return typeof s=="number"&&s>-1&&s%1==0&&s<=K}function $t(s){var c=typeof s;return s!=null&&(c=="object"||c=="function")}function Qt(s){return s!=null&&typeof s=="object"}var im=_d?Jn(_d):ny;function QS(s,c){return s===c||yu(s,c,Fu(c))}function eE(s,c,f){return f=typeof f=="function"?f:t,yu(s,c,Fu(c),f)}function tE(s){return rm(s)&&s!=+s}function nE(s){if(zy(s))throw new nt(o);return $d(s)}function iE(s){return s===null}function rE(s){return s==null}function rm(s){return typeof s=="number"||Qt(s)&&zn(s)==We}function aa(s){if(!Qt(s)||zn(s)!=z)return!1;var c=sc(s);if(c===null)return!0;var f=It.call(c,"constructor")&&c.constructor;return typeof f=="function"&&f instanceof f&&tc.call(f)==ex}var qu=vd?Jn(vd):iy;function sE(s){return nm(s)&&s>=-9007199254740991&&s<=K}var sm=xd?Jn(xd):ry;function Dc(s){return typeof s=="string"||!st(s)&&Qt(s)&&zn(s)==ge}function ei(s){return typeof s=="symbol"||Qt(s)&&zn(s)==He}var Xs=yd?Jn(yd):sy;function oE(s){return s===t}function aE(s){return Qt(s)&&Rn(s)==De}function cE(s){return Qt(s)&&zn(s)==Xe}var lE=Ec(Su),uE=Ec(function(s,c){return s<=c});function om(s){if(!s)return[];if(jn(s))return Dc(s)?wi(s):Yn(s);if(qo&&s[qo])return Gv(s[qo]());var c=Rn(s),f=c==mt?lu:c==de?Ja:Ys;return f(s)}function mr(s){if(!s)return s===0?s:0;if(s=vi(s),s===se||s===-1/0){var c=s<0?-1:1;return c*ae}return s===s?s:0}function at(s){var c=mr(s),f=c%1;return c===c?f?c-f:c:0}function am(s){return s?cs(at(s),0,ve):0}function vi(s){if(typeof s=="number")return s;if(ei(s))return pe;if($t(s)){var c=typeof s.valueOf=="function"?s.valueOf():s;s=$t(c)?c+"":c}if(typeof s!="string")return s===0?s:+s;s=wd(s);var f=ee.test(s);return f||J.test(s)?bv(s.slice(2),f?2:8):j.test(s)?pe:+s}function cm(s){return Wi(s,qn(s))}function hE(s){return s?cs(at(s),-9007199254740991,K):s===0?s:0}function Pt(s){return s==null?"":Qn(s)}var fE=Gs(function(s,c){if(sa(c)||jn(c)){Wi(c,gn(c),s);return}for(var f in c)It.call(c,f)&&Qo(s,f,c[f])}),lm=Gs(function(s,c){Wi(c,qn(c),s)}),Uc=Gs(function(s,c,f,x){Wi(c,qn(c),s,x)}),dE=Gs(function(s,c,f,x){Wi(c,gn(c),s,x)}),pE=fr(mu);function mE(s,c){var f=Hs(s);return c==null?f:Hd(f,c)}var gE=pt(function(s,c){s=Ot(s);var f=-1,x=c.length,w=x>2?c[2]:t;for(w&&kn(c[0],c[1],w)&&(x=1);++f<x;)for(var I=c[f],k=qn(I),V=-1,X=k.length;++V<X;){var ue=k[V],he=s[ue];(he===t||Ri(he,Bs[ue])&&!It.call(s,ue))&&(s[ue]=I[ue])}return s}),_E=pt(function(s){return s.push(t,wp),Zn(um,t,s)});function vE(s,c){return Sd(s,Ye(c,3),Vi)}function xE(s,c){return Sd(s,Ye(c,3),_u)}function yE(s,c){return s==null?s:gu(s,Ye(c,3),qn)}function ME(s,c){return s==null?s:Yd(s,Ye(c,3),qn)}function SE(s,c){return s&&Vi(s,Ye(c,3))}function EE(s,c){return s&&_u(s,Ye(c,3))}function TE(s){return s==null?[]:mc(s,gn(s))}function bE(s){return s==null?[]:mc(s,qn(s))}function $u(s,c,f){var x=s==null?t:ls(s,c);return x===t?f:x}function wE(s,c){return s!=null&&Cp(s,c,$x)}function Ku(s,c){return s!=null&&Cp(s,c,Kx)}var AE=Mp(function(s,c,f){c!=null&&typeof c.toString!="function"&&(c=nc.call(c)),s[c]=f},Ju($n)),RE=Mp(function(s,c,f){c!=null&&typeof c.toString!="function"&&(c=nc.call(c)),It.call(s,c)?s[c].push(f):s[c]=[f]},Ye),CE=pt(ta);function gn(s){return jn(s)?zd(s):Mu(s)}function qn(s){return jn(s)?zd(s,!0):oy(s)}function PE(s,c){var f={};return c=Ye(c,3),Vi(s,function(x,w,I){ur(f,c(x,w,I),x)}),f}function LE(s,c){var f={};return c=Ye(c,3),Vi(s,function(x,w,I){ur(f,w,c(x,w,I))}),f}var IE=Gs(function(s,c,f){gc(s,c,f)}),um=Gs(function(s,c,f,x){gc(s,c,f,x)}),DE=fr(function(s,c){var f={};if(s==null)return f;var x=!1;c=Yt(c,function(I){return I=Fr(I,s),x||(x=I.length>1),I}),Wi(s,Nu(s),f),x&&(f=mi(f,p|m|g,Ay));for(var w=c.length;w--;)Au(f,c[w]);return f});function UE(s,c){return hm(s,Lc(Ye(c)))}var NE=fr(function(s,c){return s==null?{}:cy(s,c)});function hm(s,c){if(s==null)return{};var f=Yt(Nu(s),function(x){return[x]});return c=Ye(c),np(s,f,function(x,w){return c(x,w[0])})}function OE(s,c,f){c=Fr(c,s);var x=-1,w=c.length;for(w||(w=1,s=t);++x<w;){var I=s==null?t:s[Xi(c[x])];I===t&&(x=w,I=f),s=pr(I)?I.call(s):I}return s}function FE(s,c,f){return s==null?s:ia(s,c,f)}function BE(s,c,f,x){return x=typeof x=="function"?x:t,s==null?s:ia(s,c,f,x)}var fm=Tp(gn),dm=Tp(qn);function zE(s,c,f){var x=st(s),w=x||zr(s)||Xs(s);if(c=Ye(c,4),f==null){var I=s&&s.constructor;w?f=x?new I:[]:$t(s)?f=pr(I)?Hs(sc(s)):{}:f={}}return(w?fi:Vi)(s,function(k,V,X){return c(f,k,V,X)}),f}function kE(s,c){return s==null?!0:Au(s,c)}function HE(s,c,f){return s==null?s:ap(s,c,Pu(f))}function GE(s,c,f,x){return x=typeof x=="function"?x:t,s==null?s:ap(s,c,Pu(f),x)}function Ys(s){return s==null?[]:cu(s,gn(s))}function VE(s){return s==null?[]:cu(s,qn(s))}function WE(s,c,f){return f===t&&(f=c,c=t),f!==t&&(f=vi(f),f=f===f?f:0),c!==t&&(c=vi(c),c=c===c?c:0),cs(vi(s),c,f)}function XE(s,c,f){return c=mr(c),f===t?(f=c,c=0):f=mr(f),s=vi(s),Zx(s,c,f)}function YE(s,c,f){if(f&&typeof f!="boolean"&&kn(s,c,f)&&(c=f=t),f===t&&(typeof c=="boolean"?(f=c,c=t):typeof s=="boolean"&&(f=s,s=t)),s===t&&c===t?(s=0,c=1):(s=mr(s),c===t?(c=s,s=0):c=mr(c)),s>c){var x=s;s=c,c=x}if(f||s%1||c%1){var w=Fd();return An(s+w*(c-s+Tv("1e-"+((w+"").length-1))),c)}return Tu(s,c)}var jE=Vs(function(s,c,f){return c=c.toLowerCase(),s+(f?pm(c):c)});function pm(s){return Zu(Pt(s).toLowerCase())}function mm(s){return s=Pt(s),s&&s.replace(Be,Fv).replace(pv,"")}function qE(s,c,f){s=Pt(s),c=Qn(c);var x=s.length;f=f===t?x:cs(at(f),0,x);var w=f;return f-=c.length,f>=0&&s.slice(f,w)==c}function $E(s){return s=Pt(s),s&&dt.test(s)?s.replace(Re,Bv):s}function KE(s){return s=Pt(s),s&&ki.test(s)?s.replace(bn,"\\$&"):s}var ZE=Vs(function(s,c,f){return s+(f?"-":"")+c.toLowerCase()}),JE=Vs(function(s,c,f){return s+(f?" ":"")+c.toLowerCase()}),QE=vp("toLowerCase");function eT(s,c,f){s=Pt(s),c=at(c);var x=c?Os(s):0;if(!c||x>=c)return s;var w=(c-x)/2;return Sc(lc(w),f)+s+Sc(cc(w),f)}function tT(s,c,f){s=Pt(s),c=at(c);var x=c?Os(s):0;return c&&x<c?s+Sc(c-x,f):s}function nT(s,c,f){s=Pt(s),c=at(c);var x=c?Os(s):0;return c&&x<c?Sc(c-x,f)+s:s}function iT(s,c,f){return f||c==null?c=0:c&&(c=+c),ux(Pt(s).replace(Hi,""),c||0)}function rT(s,c,f){return(f?kn(s,c,f):c===t)?c=1:c=at(c),bu(Pt(s),c)}function sT(){var s=arguments,c=Pt(s[0]);return s.length<3?c:c.replace(s[1],s[2])}var oT=Vs(function(s,c,f){return s+(f?"_":"")+c.toLowerCase()});function aT(s,c,f){return f&&typeof f!="number"&&kn(s,c,f)&&(c=f=t),f=f===t?ve:f>>>0,f?(s=Pt(s),s&&(typeof c=="string"||c!=null&&!qu(c))&&(c=Qn(c),!c&&Ns(s))?Br(wi(s),0,f):s.split(c,f)):[]}var cT=Vs(function(s,c,f){return s+(f?" ":"")+Zu(c)});function lT(s,c,f){return s=Pt(s),f=f==null?0:cs(at(f),0,s.length),c=Qn(c),s.slice(f,f+c.length)==c}function uT(s,c,f){var x=L.templateSettings;f&&kn(s,c,f)&&(c=t),s=Pt(s),c=Uc({},c,x,bp);var w=Uc({},c.imports,x.imports,bp),I=gn(w),k=cu(w,I),V,X,ue=0,he=c.interpolate||Ge,me="__p += '",Te=uu((c.escape||Ge).source+"|"+he.source+"|"+(he===Rt?ql:Ge).source+"|"+(c.evaluate||Ge).source+"|$","g"),Ue="//# sourceURL="+(It.call(c,"sourceURL")?(c.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++xv+"]")+`
3807
3807
  `;s.replace(Te,function(qe,xt,bt,ti,Hn,ni){return bt||(bt=ti),me+=s.slice(ue,ni).replace(Je,zv),xt&&(V=!0,me+=`' +
3808
3808
  __e(`+xt+`) +
3809
3809
  '`),Hn&&(X=!0,me+=`';
@@ -3814,22 +3814,22 @@ __p += '`),bt&&(me+=`' +
3814
3814
  `;var je=It.call(c,"variable")&&c.variable;if(!je)me=`with (obj) {
3815
3815
  `+me+`
3816
3816
  }
3817
- `;else if(Xl.test(je))throw new nt(l);me=(X?me.replace(T,""):me).replace(Z,"$1").replace(ce,"$1;"),me="function("+(je||"obj")+`) {
3817
+ `;else if(Yl.test(je))throw new nt(l);me=(X?me.replace(T,""):me).replace(Z,"$1").replace(ce,"$1;"),me="function("+(je||"obj")+`) {
3818
3818
  `+(je?"":`obj || (obj = {});
3819
3819
  `)+"var __t, __p = ''"+(V?", __e = _.escape":"")+(X?`, __j = Array.prototype.join;
3820
3820
  function print() { __p += __j.call(arguments, '') }
3821
3821
  `:`;
3822
3822
  `)+me+`return __p
3823
- }`;var lt=_m(function(){return Ct(I,Ue+"return "+me).apply(t,k)});if(lt.source=me,Yu(lt))throw lt;return lt}function hT(s){return Pt(s).toLowerCase()}function fT(s){return Pt(s).toUpperCase()}function dT(s,c,f){if(s=Pt(s),s&&(f||c===t))return wd(s);if(!s||!(c=Qn(c)))return s;var x=wi(s),w=wi(c),I=Ad(x,w),k=Rd(x,w)+1;return Br(x,I,k).join("")}function pT(s,c,f){if(s=Pt(s),s&&(f||c===t))return s.slice(0,Pd(s)+1);if(!s||!(c=Qn(c)))return s;var x=wi(s),w=Rd(x,wi(c))+1;return Br(x,0,w).join("")}function mT(s,c,f){if(s=Pt(s),s&&(f||c===t))return s.replace(Hi,"");if(!s||!(c=Qn(c)))return s;var x=wi(s),w=Ad(x,wi(c));return Br(x,w).join("")}function gT(s,c){var f=M,x=O;if($t(c)){var w="separator"in c?c.separator:w;f="length"in c?at(c.length):f,x="omission"in c?Qn(c.omission):x}s=Pt(s);var I=s.length;if(Ns(s)){var k=wi(s);I=k.length}if(f>=I)return s;var V=f-Os(x);if(V<1)return x;var X=k?Br(k,0,V).join(""):s.slice(0,V);if(w===t)return X+x;if(k&&(V+=X.length-V),ju(w)){if(s.slice(V).search(w)){var ue,he=X;for(w.global||(w=lu(w.source,Pt(U.exec(w))+"g")),w.lastIndex=0;ue=w.exec(he);)var me=ue.index;X=X.slice(0,me===t?V:me)}}else if(s.indexOf(Qn(w),V)!=V){var Te=X.lastIndexOf(w);Te>-1&&(X=X.slice(0,Te))}return X+x}function _T(s){return s=Pt(s),s&&vt.test(s)?s.replace(ye,Yv):s}var vT=Vs(function(s,c,f){return s+(f?" ":"")+c.toUpperCase()}),Ku=vp("toUpperCase");function gm(s,c,f){return s=Pt(s),c=f?t:c,c===t?Hv(s)?$v(s):Iv(s):s.match(c)||[]}var _m=pt(function(s,c){try{return Zn(s,t,c)}catch(f){return Yu(f)?f:new nt(f)}}),xT=fr(function(s,c){return fi(c,function(f){f=Xi(f),ur(s,f,Wu(s[f],s))}),s});function yT(s){var c=s==null?0:s.length,f=Ye();return s=c?Yt(s,function(x){if(typeof x[1]!="function")throw new di(a);return[f(x[0]),x[1]]}):[],pt(function(x){for(var w=-1;++w<c;){var I=s[w];if(Zn(I[0],this,x))return Zn(I[1],this,x)}})}function MT(s){return Yx(mi(s,p))}function Zu(s){return function(){return s}}function ST(s,c){return s==null||s!==s?c:s}var ET=yp(),TT=yp(!0);function $n(s){return s}function Ju(s){return Kd(typeof s=="function"?s:mi(s,p))}function bT(s){return Jd(mi(s,p))}function wT(s,c){return Qd(s,mi(c,p))}var AT=pt(function(s,c){return function(f){return ta(f,s,c)}}),RT=pt(function(s,c){return function(f){return ta(s,f,c)}});function Qu(s,c,f){var x=gn(c),w=mc(c,x);f==null&&!($t(c)&&(w.length||!x.length))&&(f=c,c=s,s=this,w=mc(c,gn(c)));var I=!($t(f)&&"chain"in f)||!!f.chain,k=pr(s);return fi(w,function(V){var X=c[V];s[V]=X,k&&(s.prototype[V]=function(){var ue=this.__chain__;if(I||ue){var he=s(this.__wrapped__),me=he.__actions__=Yn(this.__actions__);return me.push({func:X,args:arguments,thisArg:s}),he.__chain__=ue,he}return X.apply(s,Ir([this.value()],arguments))})}),s}function CT(){return xn._===this&&(xn._=tx),this}function eh(){}function PT(s){return s=at(s),pt(function(c){return ep(c,s)})}var LT=Lu(Yt),IT=Lu(Md),DT=Lu(nu);function vm(s){return Bu(s)?iu(Xi(s)):ly(s)}function UT(s){return function(c){return s==null?t:ls(s,c)}}var NT=Sp(),OT=Sp(!0);function th(){return[]}function nh(){return!1}function FT(){return{}}function BT(){return""}function zT(){return!0}function kT(s,c){if(s=at(s),s<1||s>K)return[];var f=ve,x=An(s,ve);c=Ye(c),s-=ve;for(var w=ou(x,c);++f<s;)c(f);return w}function HT(s){return st(s)?Yt(s,Xi):ei(s)?[s]:Yn(Bp(Pt(s)))}function GT(s){var c=++Qv;return Pt(s)+c}var VT=Mc(function(s,c){return s+c},0),WT=Iu("ceil"),XT=Mc(function(s,c){return s/c},1),YT=Iu("floor");function jT(s){return s&&s.length?pc(s,$n,_u):t}function qT(s,c){return s&&s.length?pc(s,Ye(c,2),_u):t}function $T(s){return Td(s,$n)}function KT(s,c){return Td(s,Ye(c,2))}function ZT(s){return s&&s.length?pc(s,$n,Mu):t}function JT(s,c){return s&&s.length?pc(s,Ye(c,2),Mu):t}var QT=Mc(function(s,c){return s*c},1),eb=Iu("round"),tb=Mc(function(s,c){return s-c},0);function nb(s){return s&&s.length?su(s,$n):0}function ib(s,c){return s&&s.length?su(s,Ye(c,2)):0}return L.after=bS,L.ary=$p,L.assign=fE,L.assignIn=lm,L.assignInWith=Uc,L.assignWith=dE,L.at=pE,L.before=Kp,L.bind=Wu,L.bindAll=xT,L.bindKey=Zp,L.castArray=FS,L.chain=Yp,L.chunk=Yy,L.compact=jy,L.concat=qy,L.cond=yT,L.conforms=MT,L.constant=Zu,L.countBy=nS,L.create=mE,L.curry=Jp,L.curryRight=Qp,L.debounce=em,L.defaults=gE,L.defaultsDeep=_E,L.defer=wS,L.delay=AS,L.difference=$y,L.differenceBy=Ky,L.differenceWith=Zy,L.drop=Jy,L.dropRight=Qy,L.dropRightWhile=eM,L.dropWhile=tM,L.fill=nM,L.filter=rS,L.flatMap=aS,L.flatMapDeep=cS,L.flatMapDepth=lS,L.flatten=Gp,L.flattenDeep=iM,L.flattenDepth=rM,L.flip=RS,L.flow=ET,L.flowRight=TT,L.fromPairs=sM,L.functions=TE,L.functionsIn=bE,L.groupBy=uS,L.initial=aM,L.intersection=cM,L.intersectionBy=lM,L.intersectionWith=uM,L.invert=AE,L.invertBy=RE,L.invokeMap=fS,L.iteratee=Ju,L.keyBy=dS,L.keys=gn,L.keysIn=qn,L.map=Rc,L.mapKeys=PE,L.mapValues=LE,L.matches=bT,L.matchesProperty=wT,L.memoize=Pc,L.merge=IE,L.mergeWith=um,L.method=AT,L.methodOf=RT,L.mixin=Qu,L.negate=Lc,L.nthArg=PT,L.omit=DE,L.omitBy=UE,L.once=CS,L.orderBy=pS,L.over=LT,L.overArgs=PS,L.overEvery=IT,L.overSome=DT,L.partial=Xu,L.partialRight=tm,L.partition=mS,L.pick=NE,L.pickBy=hm,L.property=vm,L.propertyOf=UT,L.pull=pM,L.pullAll=Wp,L.pullAllBy=mM,L.pullAllWith=gM,L.pullAt=_M,L.range=NT,L.rangeRight=OT,L.rearg=LS,L.reject=vS,L.remove=vM,L.rest=IS,L.reverse=Gu,L.sampleSize=yS,L.set=FE,L.setWith=BE,L.shuffle=MS,L.slice=xM,L.sortBy=TS,L.sortedUniq=wM,L.sortedUniqBy=AM,L.split=aT,L.spread=DS,L.tail=RM,L.take=CM,L.takeRight=PM,L.takeRightWhile=LM,L.takeWhile=IM,L.tap=jM,L.throttle=US,L.thru=Ac,L.toArray=om,L.toPairs=fm,L.toPairsIn=dm,L.toPath=HT,L.toPlainObject=cm,L.transform=zE,L.unary=NS,L.union=DM,L.unionBy=UM,L.unionWith=NM,L.uniq=OM,L.uniqBy=FM,L.uniqWith=BM,L.unset=kE,L.unzip=Vu,L.unzipWith=Xp,L.update=HE,L.updateWith=GE,L.values=Ys,L.valuesIn=VE,L.without=zM,L.words=gm,L.wrap=OS,L.xor=kM,L.xorBy=HM,L.xorWith=GM,L.zip=VM,L.zipObject=WM,L.zipObjectDeep=XM,L.zipWith=YM,L.entries=fm,L.entriesIn=dm,L.extend=lm,L.extendWith=Uc,Qu(L,L),L.add=VT,L.attempt=_m,L.camelCase=jE,L.capitalize=pm,L.ceil=WT,L.clamp=WE,L.clone=BS,L.cloneDeep=kS,L.cloneDeepWith=HS,L.cloneWith=zS,L.conformsTo=GS,L.deburr=mm,L.defaultTo=ST,L.divide=XT,L.endsWith=qE,L.eq=Ri,L.escape=$E,L.escapeRegExp=KE,L.every=iS,L.find=sS,L.findIndex=kp,L.findKey=vE,L.findLast=oS,L.findLastIndex=Hp,L.findLastKey=xE,L.floor=YT,L.forEach=jp,L.forEachRight=qp,L.forIn=yE,L.forInRight=ME,L.forOwn=SE,L.forOwnRight=EE,L.get=qu,L.gt=VS,L.gte=WS,L.has=wE,L.hasIn=$u,L.head=Vp,L.identity=$n,L.includes=hS,L.indexOf=oM,L.inRange=XE,L.invoke=CE,L.isArguments=fs,L.isArray=st,L.isArrayBuffer=XS,L.isArrayLike=jn,L.isArrayLikeObject=rn,L.isBoolean=YS,L.isBuffer=zr,L.isDate=jS,L.isElement=qS,L.isEmpty=$S,L.isEqual=KS,L.isEqualWith=ZS,L.isError=Yu,L.isFinite=JS,L.isFunction=pr,L.isInteger=nm,L.isLength=Ic,L.isMap=im,L.isMatch=QS,L.isMatchWith=eE,L.isNaN=tE,L.isNative=nE,L.isNil=rE,L.isNull=iE,L.isNumber=rm,L.isObject=$t,L.isObjectLike=Qt,L.isPlainObject=aa,L.isRegExp=ju,L.isSafeInteger=sE,L.isSet=sm,L.isString=Dc,L.isSymbol=ei,L.isTypedArray=Xs,L.isUndefined=oE,L.isWeakMap=aE,L.isWeakSet=cE,L.join=hM,L.kebabCase=ZE,L.last=_i,L.lastIndexOf=fM,L.lowerCase=JE,L.lowerFirst=QE,L.lt=lE,L.lte=uE,L.max=jT,L.maxBy=qT,L.mean=$T,L.meanBy=KT,L.min=ZT,L.minBy=JT,L.stubArray=th,L.stubFalse=nh,L.stubObject=FT,L.stubString=BT,L.stubTrue=zT,L.multiply=QT,L.nth=dM,L.noConflict=CT,L.noop=eh,L.now=Cc,L.pad=eT,L.padEnd=tT,L.padStart=nT,L.parseInt=iT,L.random=YE,L.reduce=gS,L.reduceRight=_S,L.repeat=rT,L.replace=sT,L.result=OE,L.round=eb,L.runInContext=W,L.sample=xS,L.size=SS,L.snakeCase=oT,L.some=ES,L.sortedIndex=yM,L.sortedIndexBy=MM,L.sortedIndexOf=SM,L.sortedLastIndex=EM,L.sortedLastIndexBy=TM,L.sortedLastIndexOf=bM,L.startCase=cT,L.startsWith=lT,L.subtract=tb,L.sum=nb,L.sumBy=ib,L.template=uT,L.times=kT,L.toFinite=mr,L.toInteger=at,L.toLength=am,L.toLower=hT,L.toNumber=vi,L.toSafeInteger=hE,L.toString=Pt,L.toUpper=fT,L.trim=dT,L.trimEnd=pT,L.trimStart=mT,L.truncate=gT,L.unescape=_T,L.uniqueId=GT,L.upperCase=vT,L.upperFirst=Ku,L.each=jp,L.eachRight=qp,L.first=Vp,Qu(L,function(){var s={};return Vi(L,function(c,f){It.call(L.prototype,f)||(s[f]=c)}),s}(),{chain:!1}),L.VERSION=n,fi(["bind","bindKey","curry","curryRight","partial","partialRight"],function(s){L[s].placeholder=L}),fi(["drop","take"],function(s,c){Mt.prototype[s]=function(f){f=f===t?1:fn(at(f),0);var x=this.__filtered__&&!c?new Mt(this):this.clone();return x.__filtered__?x.__takeCount__=An(f,x.__takeCount__):x.__views__.push({size:An(f,ve),type:s+(x.__dir__<0?"Right":"")}),x},Mt.prototype[s+"Right"]=function(f){return this.reverse()[s](f).reverse()}}),fi(["filter","map","takeWhile"],function(s,c){var f=c+1,x=f==Y||f==re;Mt.prototype[s]=function(w){var I=this.clone();return I.__iteratees__.push({iteratee:Ye(w,3),type:f}),I.__filtered__=I.__filtered__||x,I}}),fi(["head","last"],function(s,c){var f="take"+(c?"Right":"");Mt.prototype[s]=function(){return this[f](1).value()[0]}}),fi(["initial","tail"],function(s,c){var f="drop"+(c?"":"Right");Mt.prototype[s]=function(){return this.__filtered__?new Mt(this):this[f](1)}}),Mt.prototype.compact=function(){return this.filter($n)},Mt.prototype.find=function(s){return this.filter(s).head()},Mt.prototype.findLast=function(s){return this.reverse().find(s)},Mt.prototype.invokeMap=pt(function(s,c){return typeof s=="function"?new Mt(this):this.map(function(f){return ta(f,s,c)})}),Mt.prototype.reject=function(s){return this.filter(Lc(Ye(s)))},Mt.prototype.slice=function(s,c){s=at(s);var f=this;return f.__filtered__&&(s>0||c<0)?new Mt(f):(s<0?f=f.takeRight(-s):s&&(f=f.drop(s)),c!==t&&(c=at(c),f=c<0?f.dropRight(-c):f.take(c-s)),f)},Mt.prototype.takeRightWhile=function(s){return this.reverse().takeWhile(s).reverse()},Mt.prototype.toArray=function(){return this.take(ve)},Vi(Mt.prototype,function(s,c){var f=/^(?:filter|find|map|reject)|While$/.test(c),x=/^(?:head|last)$/.test(c),w=L[x?"take"+(c=="last"?"Right":""):c],I=x||/^find/.test(c);w&&(L.prototype[c]=function(){var k=this.__wrapped__,V=x?[1]:arguments,X=k instanceof Mt,ue=V[0],he=X||st(k),me=function(xt){var bt=w.apply(L,Ir([xt],V));return x&&Te?bt[0]:bt};he&&f&&typeof ue=="function"&&ue.length!=1&&(X=he=!1);var Te=this.__chain__,Ue=!!this.__actions__.length,je=I&&!Te,lt=X&&!Ue;if(!I&&he){k=lt?k:new Mt(this);var qe=s.apply(k,V);return qe.__actions__.push({func:Ac,args:[me],thisArg:t}),new pi(qe,Te)}return je&&lt?s.apply(this,V):(qe=this.thru(me),je?x?qe.value()[0]:qe.value():qe)})}),fi(["pop","push","shift","sort","splice","unshift"],function(s){var c=Qa[s],f=/^(?:push|sort|unshift)$/.test(s)?"tap":"thru",x=/^(?:pop|shift)$/.test(s);L.prototype[s]=function(){var w=arguments;if(x&&!this.__chain__){var I=this.value();return c.apply(st(I)?I:[],w)}return this[f](function(k){return c.apply(st(k)?k:[],w)})}}),Vi(Mt.prototype,function(s,c){var f=L[c];if(f){var x=f.name+"";It.call(ks,x)||(ks[x]=[]),ks[x].push({name:c,func:f})}}),ks[yc(t,v).name]=[{name:"wrapper",func:t}],Mt.prototype.clone=_x,Mt.prototype.reverse=vx,Mt.prototype.value=xx,L.prototype.at=qM,L.prototype.chain=$M,L.prototype.commit=KM,L.prototype.next=ZM,L.prototype.plant=QM,L.prototype.reverse=eS,L.prototype.toJSON=L.prototype.valueOf=L.prototype.value=tS,L.prototype.first=L.prototype.head,qo&&(L.prototype[qo]=JM),L},Fs=Kv();rs?((rs.exports=Fs)._=Fs,Jl._=Fs):xn._=Fs}).call(NL)}(Ra,Ra.exports)),Ra.exports}var FL=OL();class Vh{constructor(e,t){this._path=e,this._ctor=t}_promise=null;_instance=null;async get(){return this._instance?Promise.resolve(this._instance):this._promise?this._promise:(this._promise=(async()=>{const t=(await import(this._path))[this._ctor];if(!t)throw new Error(`DIVE: Module class ${this._ctor} not found in ${this._path}`);if(typeof t!="function")throw new Error(`DIVE: Module at ${this._path} does not export a valid constructor (${this._ctor} wanted)`);return this._instance=new t,this._instance})(),this._promise)}}class On{static __instances=[];static get(e){const t=this.__instances.find(n=>n.id===e);return t||this.__instances.find(n=>Array.from(n.registered.values()).find(r=>r.id===e))}_id;get id(){return this._id}renderer;scene;controller;toolbox;_mediaGenerator=new Vh("../mediacreator/MediaCreator.ts","DIVEMediaCreator");_io=new Vh("../io/IO.ts","DIVEIO");_ar=new Vh("../ar/AR.ts","DIVEAR");registered=new Map;listeners=new Map;constructor(e,t,n,r){this._id=EL(),this.renderer=e,this.scene=t,this.controller=n,this.toolbox=r,On.__instances.push(this)}DestroyInstance(){const e=On.__instances.findIndex(t=>t.id===this.id);return e===-1?!1:(On.__instances.splice(e,1),!0)}PerformAction(e,t){let n=!1;switch(e){case"START_RENDER":{this.renderer.StartRenderer(this.scene,this.controller.object),n=!0;break}case"GET_ALL_SCENE_DATA":{n=this.getAllSceneData(t);break}case"GET_ALL_OBJECTS":{n=this.getAllObjects(t);break}case"GET_OBJECTS":{n=this.getObjects(t);break}case"ADD_OBJECT":{n=this.addObject(t);break}case"UPDATE_OBJECT":{n=this.updateObject(t);break}case"DELETE_OBJECT":{n=this.deleteObject(t);break}case"SELECT_OBJECT":{n=this.selectObject(t);break}case"DESELECT_OBJECT":{n=this.deselectObject(t);break}case"SET_BACKGROUND":{n=this.setBackground(t);break}case"DROP_IT":{n=this.dropIt(t);break}case"PLACE_ON_FLOOR":{n=this.placeOnFloor(t);break}case"SET_CAMERA_TRANSFORM":{n=this.setCameraTransform(t);break}case"GET_CAMERA_TRANSFORM":{n=this.getCameraTransform(t);break}case"MOVE_CAMERA":{n=this.moveCamera(t);break}case"RESET_CAMERA":{n=this.resetCamera(t);break}case"COMPUTE_ENCOMPASSING_VIEW":{n=this.computeEncompassingView(t);break}case"SET_CAMERA_LAYER":{n=this.setCameraLayer(t);break}case"ZOOM_CAMERA":{n=this.zoomCamera(t);break}case"SET_GIZMO_MODE":{n=this.setGizmoMode(t);break}case"SET_GIZMO_VISIBILITY":{n=this.setGizmoVisibility(t);break}case"SET_GIZMO_SCALE_LINKED":{n=this.setGizmoScaleLinked(t);break}case"USE_TOOL":{n=this.useTool(t);break}case"MODEL_LOADED":{n=this.modelLoaded(t);break}case"UPDATE_SCENE":{n=this.updateScene(t);break}case"GENERATE_MEDIA":{n=this.generateMedia(t);break}case"SET_PARENT":{n=this.setParent(t);break}case"EXPORT_SCENE":{n=this.exportScene(t);break}case"LAUNCH_AR":{const{uri:r,options:o}=t;n=new Promise((a,l)=>{this._ar.get().then(u=>{a(u.launch(r,o))}).catch(l)});break}default:console.warn(`DIVECommunication.PerformAction: has been executed with unknown Action type ${e}`)}return this.dispatch(e,t),n}Subscribe(e,t){return this.listeners.get(e)||this.listeners.set(e,[]),this.listeners.get(e).push(t),()=>{const n=this.listeners.get(e);if(!n)return!1;const r=n.findIndex(o=>o===t);return r===-1?!1:(n.splice(r,1),!0)}}dispatch(e,t){const n=this.listeners.get(e);n&&n.forEach(r=>r(t))}getAllSceneData(e){const t={name:this.scene.name,mediaItem:null,backgroundColor:"#"+this.scene.background.getHexString(),floorEnabled:this.scene.Floor.visible,floorColor:"#"+this.scene.Floor.material.color.getHexString(),userCamera:{position:this.controller.object.position.clone(),target:this.controller.target.clone()},spotmarks:[],lights:Array.from(this.registered.values()).filter(n=>n.entityType==="light"),objects:Array.from(this.registered.values()).filter(n=>n.entityType==="model"),cameras:Array.from(this.registered.values()).filter(n=>n.entityType==="pov"),primitives:Array.from(this.registered.values()).filter(n=>n.entityType==="primitive"),groups:Array.from(this.registered.values()).filter(n=>n.entityType==="group")};return Object.assign(e,t),t}getAllObjects(e){return Object.assign(e,this.registered),this.registered}getObjects(e){if(e.ids.length===0)return[];const t=[];return this.registered.forEach(n=>{e.ids.includes(n.id)&&t.push(n)}),t}addObject(e){return this.registered.get(e.id)?!1:(e.parentId===void 0&&(e.parentId=null),this.registered.set(e.id,e),this.scene.AddSceneObject(e),!0)}updateObject(e){const t=this.registered.get(e.id);if(!t)return!1;this.registered.set(e.id,FL.merge(t,e));const n=this.registered.get(e.id);return this.scene.UpdateSceneObject({...e,id:n.id,entityType:n.entityType}),Object.assign(e,n),!0}deleteObject(e){const t=this.registered.get(e.id);return t?(t.parentId&&this.setParent({object:{id:t.id},parent:null}),t.entityType==="group"&&this.registered.forEach(n=>{n.parentId===t.id&&this.updateObject({id:n.id,parentId:null})}),Object.assign(e,t),this.registered.delete(e.id),Array.from(this.registered.values()).forEach(n=>{n.parentId&&n.parentId===e.id&&(n.parentId=null)}),this.scene.DeleteSceneObject(t),!0):!1}selectObject(e){const t=this.registered.get(e.id);if(!t)return!1;const n=this.scene.GetSceneObject(t);if(!n||!("isSelectable"in n))return!1;const r=this.toolbox.GetActiveTool();return r&&M_(r)&&r.AttachGizmo(n),Object.assign(e,t),!0}deselectObject(e){const t=this.registered.get(e.id);if(!t)return!1;const n=this.scene.GetSceneObject(t);if(!n||!("isSelectable"in n))return!1;const r=this.toolbox.GetActiveTool();return r&&M_(r)&&r.DetachGizmo(),Object.assign(e,t),!0}setBackground(e){return this.scene.SetBackground(e.color),!0}dropIt(e){const t=this.registered.get(e.id);return t?(this.scene.GetSceneObject(t).DropIt(),!0):!1}placeOnFloor(e){const t=this.registered.get(e.id);return t?(this.scene.PlaceOnFloor(t),!0):!1}setCameraTransform(e){return this.controller.object.position.copy(e.position),this.controller.target.copy(e.target),this.controller.update(),!0}getCameraTransform(e){const t={position:this.controller.object.position.clone(),target:this.controller.target.clone()};return Object.assign(e,t),t}moveCamera(e){let t={x:0,y:0,z:0},n={x:0,y:0,z:0};return"id"in e?(t=this.registered.get(e.id).position,n=this.registered.get(e.id).target):(t=e.position,n=e.target),this.controller.MoveTo(t,n,e.duration,e.locked),!0}setCameraLayer(e){return this.controller.object.SetCameraLayer(e.layer),!0}resetCamera(e){return this.controller.RevertLast(e.duration),!0}computeEncompassingView(e){const t=this.scene.ComputeSceneBB(),n=this.controller.ComputeEncompassingView(t);return Object.assign(e,n),n}zoomCamera(e){return e.direction==="IN"&&this.controller.ZoomIn(e.by),e.direction==="OUT"&&this.controller.ZoomOut(e.by),!0}setGizmoMode(e){return this.toolbox.SetGizmoMode(e.mode),!0}setGizmoVisibility(e){return this.toolbox.SetGizmoVisibility(e),e}setGizmoScaleLinked(e){return this.toolbox.SetGizmoScaleLinked(e),e}useTool(e){return this.toolbox.UseTool(e.tool),!0}modelLoaded(e){return this.registered.get(e.id).loaded=!0,!0}updateScene(e){return e.name!==void 0&&(this.scene.name=e.name),e.backgroundColor!==void 0&&this.scene.SetBackground(e.backgroundColor),e.gridEnabled!==void 0&&this.scene.Grid.SetVisibility(e.gridEnabled),e.floorEnabled!==void 0&&this.scene.Floor.SetVisibility(e.floorEnabled),e.floorColor!==void 0&&this.scene.Floor.SetColor(e.floorColor),e.name=this.scene.name,e.backgroundColor="#"+this.scene.background.getHexString(),e.gridEnabled=this.scene.Grid.visible,e.floorEnabled=this.scene.Floor.visible,e.floorColor="#"+this.scene.Floor.material.color.getHexString(),!0}generateMedia(e){let t={x:0,y:0,z:0},n={x:0,y:0,z:0};return"id"in e?(t=this.registered.get(e.id).position,n=this.registered.get(e.id).target):(t=e.position,n=e.target),this._mediaGenerator.get().then(r=>r.GenerateMedia(t,n,e.width,e.height))}setParent(e){const t=this.registered.get(e.object.id);if(!t)return!1;const n=this.scene.GetSceneObject(t);if(!n)return!1;if(e.parent===null)return this.scene.Root.attach(n),this.updateObject({id:t.id,parentId:null}),!0;if(e.object.id===e.parent.id)return!1;const r=this.registered.get(e.parent.id);if(!r)return this.scene.Root.attach(n),this.updateObject({id:t.id,parentId:null}),!0;const o=this.scene.GetSceneObject(r);return o?(o.attach(n),this.updateObject({id:t.id,parentId:r.id}),!0):(this.scene.Root.attach(n),this.updateObject({id:t.id,parentId:null}),!0)}exportScene(e){return new Promise((t,n)=>{this._io.get().then(r=>{t(r.Export(e.type))}).catch(n)})}}class BL extends gt{isDIVELight=!0;isDIVEPointLight=!0;isMovable=!0;isSelectable=!0;gizmo=null;light;mesh;constructor(){super(),this.name="DIVEPointLight",this.light=new O0(16777215,1),this.light.layers.mask=li,this.light.castShadow=!0,this.light.shadow.mapSize.width=512,this.light.shadow.mapSize.height=512,this.add(this.light);const e=.1,t=new Va(e,e*320,e*320),n=new Ji({color:this.light.color,transparent:!0,opacity:.8,side:tr});this.mesh=new Se(t,n),this.mesh.layers.mask=Kf,this.add(this.mesh)}SetColor(e){this.light.color=e,this.mesh.material.color=e}SetIntensity(e){this.light.intensity=e,this.mesh.material.opacity=e>.8?.8:e*.8}SetEnabled(e){this.light.visible=e}onMove(){On.get(this.userData.id)?.PerformAction("UPDATE_OBJECT",{id:this.userData.id,position:this.position})}onSelect(){On.get(this.userData.id)?.PerformAction("SELECT_OBJECT",{id:this.userData.id})}onDeselect(){On.get(this.userData.id)?.PerformAction("DESELECT_OBJECT",{id:this.userData.id})}}class zL extends gt{isDIVELight=!0;isDIVESceneLight=!0;_hemiLight;_dirLight;constructor(){super(),this.name="DIVESceneLight",this._hemiLight=new tL(16777215,16777215,2),this._hemiLight.layers.mask=li,this._hemiLight.position.set(0,50,0),this.add(this._hemiLight),this._dirLight=new Yf(16777215,3),this._dirLight.layers.mask=li,this._dirLight.position.set(1,1.75,1),this._dirLight.position.multiplyScalar(30),this._dirLight.castShadow=!0,this._dirLight.shadow.mapSize.width=2048,this._dirLight.shadow.mapSize.height=2048;const e=5;this._dirLight.shadow.camera.left=-5,this._dirLight.shadow.camera.right=e,this._dirLight.shadow.camera.top=e,this._dirLight.shadow.camera.bottom=-5,this._dirLight.shadow.camera.far=3500,this.add(this._dirLight)}SetColor(e){this._hemiLight.color=e,this._dirLight.color=e}SetIntensity(e){this._hemiLight.intensity=e*2,this._dirLight.intensity=e*3}SetEnabled(e){this._hemiLight.visible=e,this._dirLight.visible=e}}const Zf=i=>i.parent?Zf(i.parent):i;class kL{isMovable=!0}class HL{isSelectable=!0}function GL(i,e){return e.forEach(t=>{Object.getOwnPropertyNames(t.prototype).forEach(n=>{Object.defineProperty(i.prototype,n,Object.getOwnPropertyDescriptor(t.prototype,n))})}),i}class Jf extends GL(gt,[HL,kL]){isDIVENode=!0;gizmo=null;_positionWorldBuffer;_boundingBox;constructor(){super(),this.layers.mask=li,this._positionWorldBuffer=new F,this._boundingBox=new zi}SetPosition(e){if(!this.parent){this.position.set(e.x,e.y,e.z);return}const t=new F(e.x,e.y,e.z);this.position.copy(this.parent.worldToLocal(t)),"isDIVEGroup"in this.parent&&this.parent.UpdateLineTo(this)}SetRotation(e){this.rotation.set(e.x,e.y,e.z)}SetScale(e){this.scale.set(e.x,e.y,e.z)}SetVisibility(e){this.visible=e}SetToWorldOrigin(){this.position.set(0,0,0),On.get(this.userData.id)?.PerformAction("UPDATE_OBJECT",{id:this.userData.id,position:this.getWorldPosition(this._positionWorldBuffer),rotation:this.rotation,scale:this.scale})}onMove(){On.get(this.userData.id)?.PerformAction("UPDATE_OBJECT",{id:this.userData.id,position:this.getWorldPosition(this._positionWorldBuffer),rotation:this.rotation,scale:this.scale})}onSelect(){On.get(this.userData.id)?.PerformAction("SELECT_OBJECT",{id:this.userData.id})}onDeselect(){On.get(this.userData.id)?.PerformAction("DESELECT_OBJECT",{id:this.userData.id})}}class VL extends Jf{isDIVEModel=!0;_mesh=null;_material=null;SetModel(e){this.clear(),this._boundingBox.makeEmpty(),e.traverse(t=>{t.castShadow=!0,t.receiveShadow=!0,t.layers.mask=this.layers.mask,this._boundingBox.expandByObject(t),!this._mesh&&"isMesh"in t&&(this._mesh=t,this._material?this._mesh.material=this._material:this._material=t.material)}),this.add(e)}SetMaterial(e){this._material||(this._material=new zo),e.vertexColors!==void 0&&(this._material.vertexColors=e.vertexColors),e.color!==void 0&&this._material.color.set(e.color),e.map!==void 0&&(this._material.map=e.map),e.normalMap!==void 0&&(this._material.normalMap=e.normalMap),e.roughness!==void 0&&(this._material.roughness=e.roughness),e.roughnessMap!==void 0&&(this._material.roughnessMap=e.roughnessMap,this._material.roughnessMap&&(this._material.roughness=1)),e.metalness!==void 0&&(this._material.metalness=e.metalness),e.metalnessMap!==void 0&&(this._material.metalnessMap=e.metalnessMap,this._material.metalnessMap&&(this._material.metalness=1)),this._mesh&&(this._mesh.material=this._material)}PlaceOnFloor(){const e=this.getWorldPosition(this._positionWorldBuffer),t=e.clone();this._mesh?.geometry?.computeBoundingBox();const n=this._mesh?.geometry?.boundingBox;!n||!this._mesh||(e.y=e.y-this._mesh.localToWorld(n.min.clone()).y,e.y!==t.y&&On.get(this.userData.id)?.PerformAction("UPDATE_OBJECT",{id:this.userData.id,position:e,rotation:this.rotation,scale:this.scale}))}DropIt(){if(!this.parent){console.warn("DIVEModel: DropIt() called on a model that is not in the scene.",this);return}const e=this._boundingBox.min.y*this.scale.y,t=this.localToWorld(this._boundingBox.getCenter(new F).multiply(this.scale));t.y=e+this.position.y;const n=new Hl(t,new F(0,-1,0));n.layers.mask=li;const r=n.intersectObjects(Zf(this).Root.children,!0);if(r.length>0){const o=r[0].object;o.geometry.computeBoundingBox();const a=o.geometry.boundingBox,l=o.localToWorld(a.max.clone()),u=this.position.clone(),h=this.position.clone().setY(l.y).sub(new F(0,e,0));if(this.position.copy(h),this.position.y===u.y)return;this.onMove()}}}class WL extends Jf{isDIVEPrimitive=!0;_mesh;constructor(){super(),this._mesh=new Se,this._mesh.layers.mask=li,this._mesh.castShadow=!0,this._mesh.receiveShadow=!0,this._mesh.material=new zo,this.add(this._mesh)}SetGeometry(e){const t=this.assembleGeometry(e);t&&(this._mesh.geometry=t,this._boundingBox.setFromObject(this._mesh))}SetMaterial(e){const t=this._mesh.material;e.vertexColors!==void 0&&(t.vertexColors=e.vertexColors),e.color!==void 0&&(t.color=new Oe(e.color)),e.map!==void 0&&(t.map=e.map),e.normalMap!==void 0&&(t.normalMap=e.normalMap),e.roughness!==void 0&&(t.roughness=e.roughness),e.roughnessMap!==void 0&&(t.roughnessMap=e.roughnessMap,t.roughnessMap&&(t.roughness=1)),e.metalness!==void 0&&(t.metalness=e.metalness),e.metalnessMap!==void 0&&(t.metalnessMap=e.metalnessMap,t.metalnessMap&&(t.metalness=0)),this._mesh&&(this._mesh.material=t)}PlaceOnFloor(){const e=this.getWorldPosition(this._positionWorldBuffer),t=e.clone();this._mesh?.geometry?.computeBoundingBox();const n=this._mesh?.geometry?.boundingBox;!n||!this._mesh||(e.y=e.y-this._mesh.localToWorld(n.min.clone()).y,e.y!==t.y&&On.get(this.userData.id)?.PerformAction("UPDATE_OBJECT",{id:this.userData.id,position:e,rotation:this.rotation,scale:this.scale}))}DropIt(){if(!this.parent){console.warn("DIVEPrimitive: DropIt() called on a model that is not in the scene.",this);return}const e=this._boundingBox.min.y*this.scale.y,t=this.localToWorld(this._boundingBox.getCenter(new F).multiply(this.scale));t.y=e+this.position.y;const n=new Hl(t,new F(0,-1,0));n.layers.mask=li;const r=n.intersectObjects(Zf(this).Root.children,!0);if(r.length>0){const o=r[0].object;o.geometry.computeBoundingBox();const a=o.geometry.boundingBox,l=o.localToWorld(a.max.clone()),u=this.position.clone(),h=this.position.clone().setY(l.y).sub(new F(0,e,0));if(this.position.copy(h),this.position.y===u.y)return;this.onMove()}}assembleGeometry(e){switch(this._mesh.material.flatShading=!1,e.name.toLowerCase()){case"cylinder":return this.createCylinderGeometry(e);case"sphere":return this.createSphereGeometry(e);case"pyramid":return this._mesh.material.flatShading=!0,this.createPyramidGeometry(e);case"cube":case"box":return this.createBoxGeometry(e);case"cone":return this.createConeGeometry(e);case"wall":return this.createWallGeometry(e);case"plane":return this.createPlaneGeometry(e);default:return console.warn("DIVEPrimitive.assembleGeometry: Invalid geometry type:",e.name.toLowerCase()),null}}createCylinderGeometry(e){const t=new vn(e.width/2,e.width/2,e.height,64);return t.translate(0,e.height/2,0),t}createSphereGeometry(e){return new Va(e.width/2,256,256)}createPyramidGeometry(e){const t=new Float32Array([-e.width/2,0,-e.depth/2,e.width/2,0,-e.depth/2,e.width/2,0,e.depth/2,-e.width/2,0,e.depth/2,0,e.height,0]),n=new Uint16Array([0,1,2,0,2,3,0,4,1,1,4,2,2,4,3,3,4,0]),r=new tn;return r.setAttribute("position",new Nt(t,3)),r.setIndex(new Nt(n,1)),r.computeVertexNormals(),r.computeBoundingBox(),r.computeBoundingSphere(),r}createBoxGeometry(e){const t=new Kt(e.width,e.height,e.depth);return t.translate(0,e.height/2,0),t}createConeGeometry(e){const t=new Vf(e.width/2,e.height,256);return t.translate(0,e.height/2,0),t}createWallGeometry(e){const t=new Kt(e.width,e.height,e.depth||.05,16);return t.translate(0,e.height/2,0),t}createPlaneGeometry(e){const t=new Kt(e.width,e.height,e.depth);return t.translate(0,e.height/2,0),t}}class XL extends Jf{isDIVEGroup=!0;_members;get members(){return this._members}_lines;constructor(){super(),this.name="DIVEGroup",this._members=[],this._lines=[]}SetPosition(e){super.SetPosition(e),this._members.forEach(t=>{"isDIVENode"in t&&t.onMove()})}SetLinesVisibility(e,t){if(!t){this._lines.forEach(r=>{r.visible=e});return}const n=this._members.indexOf(t);n!==-1&&(this._lines[n].visible=e)}attach(e){if(this._members.includes(e))return this;const t=this.createLine();return this.add(t),this._lines.push(t),super.attach(e),this._members.push(e),this.updateLineTo(t,e),this.SetLinesVisibility(!0,e),this}remove(e){const t=this._members.indexOf(e);if(t===-1)return this;const n=this._lines[t];return super.remove(n),this._lines.splice(t,1),super.remove(e),this._members.splice(t,1),this}UpdateLineTo(e){const t=this._members.indexOf(e);t!==-1&&this.updateLineTo(this._lines[t],e)}createLine(){const e=new tn,t=new HP({color:6710886,dashSize:.05,gapSize:.025}),n=new Si(e,t);return n.visible=!1,n}updateLineTo(e,t){e.geometry.setFromPoints([new F(0,0,0),t.position.clone()]),e.computeLineDistances()}}function E_(i,e){if(e===Zb)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),i;if(e===cf||e===o0){let t=i.getIndex();if(t===null){const a=[],l=i.getAttribute("position");if(l!==void 0){for(let u=0;u<l.count;u++)a.push(u);i.setIndex(a),t=i.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),i}const n=t.count-2,r=[];if(e===cf)for(let a=1;a<=n;a++)r.push(t.getX(0)),r.push(t.getX(a)),r.push(t.getX(a+1));else for(let a=0;a<n;a++)a%2===0?(r.push(t.getX(a)),r.push(t.getX(a+1)),r.push(t.getX(a+2))):(r.push(t.getX(a+2)),r.push(t.getX(a+1)),r.push(t.getX(a)));r.length/3!==n&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const o=i.clone();return o.setIndex(r),o.clearGroups(),o}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),i}class YL extends Ls{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new ZL(t)}),this.register(function(t){return new oI(t)}),this.register(function(t){return new aI(t)}),this.register(function(t){return new cI(t)}),this.register(function(t){return new QL(t)}),this.register(function(t){return new eI(t)}),this.register(function(t){return new tI(t)}),this.register(function(t){return new nI(t)}),this.register(function(t){return new KL(t)}),this.register(function(t){return new iI(t)}),this.register(function(t){return new JL(t)}),this.register(function(t){return new sI(t)}),this.register(function(t){return new rI(t)}),this.register(function(t){return new qL(t)}),this.register(function(t){return new lI(t)}),this.register(function(t){return new uI(t)})}load(e,t,n,r){const o=this;let a;if(this.resourcePath!=="")a=this.resourcePath;else if(this.path!==""){const h=Oa.extractUrlBase(e);a=Oa.resolveURL(h,this.path)}else a=Oa.extractUrlBase(e);this.manager.itemStart(e);const l=function(h){r?r(h):console.error(h),o.manager.itemError(e),o.manager.itemEnd(e)},u=new Ll(this.manager);u.setPath(this.path),u.setResponseType("arraybuffer"),u.setRequestHeader(this.requestHeader),u.setWithCredentials(this.withCredentials),u.load(e,function(h){try{o.parse(h,a,function(d){t(d),o.manager.itemEnd(e)},l)}catch(d){l(d)}},n,l)}setDRACOLoader(e){return this.dracoLoader=e,this}setDDSLoader(){throw new Error('THREE.GLTFLoader: "MSFT_texture_dds" no longer supported. Please update to "KHR_texture_basisu".')}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,n,r){let o;const a={},l={},u=new TextDecoder;if(typeof e=="string")o=JSON.parse(e);else if(e instanceof ArrayBuffer)if(u.decode(new Uint8Array(e,0,4))===H0){try{a[St.KHR_BINARY_GLTF]=new hI(e)}catch(p){r&&r(p);return}o=JSON.parse(a[St.KHR_BINARY_GLTF].content)}else o=JSON.parse(u.decode(e));else o=e;if(o.asset===void 0||o.asset.version[0]<2){r&&r(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const h=new TI(o,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});h.fileLoader.setRequestHeader(this.requestHeader);for(let d=0;d<this.pluginCallbacks.length;d++){const p=this.pluginCallbacks[d](h);p.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),l[p.name]=p,a[p.name]=!0}if(o.extensionsUsed)for(let d=0;d<o.extensionsUsed.length;++d){const p=o.extensionsUsed[d],m=o.extensionsRequired||[];switch(p){case St.KHR_MATERIALS_UNLIT:a[p]=new $L;break;case St.KHR_DRACO_MESH_COMPRESSION:a[p]=new fI(o,this.dracoLoader);break;case St.KHR_TEXTURE_TRANSFORM:a[p]=new dI;break;case St.KHR_MESH_QUANTIZATION:a[p]=new pI;break;default:m.indexOf(p)>=0&&l[p]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+p+'".')}}h.setExtensions(a),h.setPlugins(l),h.parse(n,r)}parseAsync(e,t){const n=this;return new Promise(function(r,o){n.parse(e,t,r,o)})}}function jL(){let i={};return{get:function(e){return i[e]},add:function(e,t){i[e]=t},remove:function(e){delete i[e]},removeAll:function(){i={}}}}const St={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class qL{constructor(e){this.parser=e,this.name=St.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let n=0,r=t.length;n<r;n++){const o=t[n];o.extensions&&o.extensions[this.name]&&o.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,o.extensions[this.name].light)}}_loadLight(e){const t=this.parser,n="light:"+e;let r=t.cache.get(n);if(r)return r;const o=t.json,u=((o.extensions&&o.extensions[this.name]||{}).lights||[])[e];let h;const d=new Oe(16777215);u.color!==void 0&&d.setRGB(u.color[0],u.color[1],u.color[2],Tn);const p=u.range!==void 0?u.range:0;switch(u.type){case"directional":h=new Yf(d),h.target.position.set(0,0,-1),h.add(h.target);break;case"point":h=new O0(d),h.distance=p;break;case"spot":h=new iL(d),h.distance=p,u.spot=u.spot||{},u.spot.innerConeAngle=u.spot.innerConeAngle!==void 0?u.spot.innerConeAngle:0,u.spot.outerConeAngle=u.spot.outerConeAngle!==void 0?u.spot.outerConeAngle:Math.PI/4,h.angle=u.spot.outerConeAngle,h.penumbra=1-u.spot.innerConeAngle/u.spot.outerConeAngle,h.target.position.set(0,0,-1),h.add(h.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+u.type)}return h.position.set(0,0,0),h.decay=2,Kr(h,u),u.intensity!==void 0&&(h.intensity=u.intensity),h.name=t.createUniqueName(u.name||"light_"+e),r=Promise.resolve(h),t.cache.add(n,r),r}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){const t=this,n=this.parser,o=n.json.nodes[e],l=(o.extensions&&o.extensions[this.name]||{}).light;return l===void 0?null:this._loadLight(l).then(function(u){return n._getNodeRef(t.cache,l,u)})}}let $L=class{constructor(){this.name=St.KHR_MATERIALS_UNLIT}getMaterialType(){return Ji}extendParams(e,t,n){const r=[];e.color=new Oe(1,1,1),e.opacity=1;const o=t.pbrMetallicRoughness;if(o){if(Array.isArray(o.baseColorFactor)){const a=o.baseColorFactor;e.color.setRGB(a[0],a[1],a[2],Tn),e.opacity=a[3]}o.baseColorTexture!==void 0&&r.push(n.assignTexture(e,"map",o.baseColorTexture,on))}return Promise.all(r)}},KL=class{constructor(e){this.parser=e,this.name=St.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const r=this.parser.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const o=r.extensions[this.name].emissiveStrength;return o!==void 0&&(t.emissiveIntensity=o),Promise.resolve()}},ZL=class{constructor(e){this.parser=e,this.name=St.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:sr}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const o=[],a=r.extensions[this.name];if(a.clearcoatFactor!==void 0&&(t.clearcoat=a.clearcoatFactor),a.clearcoatTexture!==void 0&&o.push(n.assignTexture(t,"clearcoatMap",a.clearcoatTexture)),a.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=a.clearcoatRoughnessFactor),a.clearcoatRoughnessTexture!==void 0&&o.push(n.assignTexture(t,"clearcoatRoughnessMap",a.clearcoatRoughnessTexture)),a.clearcoatNormalTexture!==void 0&&(o.push(n.assignTexture(t,"clearcoatNormalMap",a.clearcoatNormalTexture)),a.clearcoatNormalTexture.scale!==void 0)){const l=a.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new Pe(l,l)}return Promise.all(o)}},JL=class{constructor(e){this.parser=e,this.name=St.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:sr}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const o=[],a=r.extensions[this.name];return a.iridescenceFactor!==void 0&&(t.iridescence=a.iridescenceFactor),a.iridescenceTexture!==void 0&&o.push(n.assignTexture(t,"iridescenceMap",a.iridescenceTexture)),a.iridescenceIor!==void 0&&(t.iridescenceIOR=a.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),a.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=a.iridescenceThicknessMinimum),a.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=a.iridescenceThicknessMaximum),a.iridescenceThicknessTexture!==void 0&&o.push(n.assignTexture(t,"iridescenceThicknessMap",a.iridescenceThicknessTexture)),Promise.all(o)}},QL=class{constructor(e){this.parser=e,this.name=St.KHR_MATERIALS_SHEEN}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:sr}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const o=[];t.sheenColor=new Oe(0,0,0),t.sheenRoughness=0,t.sheen=1;const a=r.extensions[this.name];if(a.sheenColorFactor!==void 0){const l=a.sheenColorFactor;t.sheenColor.setRGB(l[0],l[1],l[2],Tn)}return a.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=a.sheenRoughnessFactor),a.sheenColorTexture!==void 0&&o.push(n.assignTexture(t,"sheenColorMap",a.sheenColorTexture,on)),a.sheenRoughnessTexture!==void 0&&o.push(n.assignTexture(t,"sheenRoughnessMap",a.sheenRoughnessTexture)),Promise.all(o)}},eI=class{constructor(e){this.parser=e,this.name=St.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:sr}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const o=[],a=r.extensions[this.name];return a.transmissionFactor!==void 0&&(t.transmission=a.transmissionFactor),a.transmissionTexture!==void 0&&o.push(n.assignTexture(t,"transmissionMap",a.transmissionTexture)),Promise.all(o)}},tI=class{constructor(e){this.parser=e,this.name=St.KHR_MATERIALS_VOLUME}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:sr}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const o=[],a=r.extensions[this.name];t.thickness=a.thicknessFactor!==void 0?a.thicknessFactor:0,a.thicknessTexture!==void 0&&o.push(n.assignTexture(t,"thicknessMap",a.thicknessTexture)),t.attenuationDistance=a.attenuationDistance||1/0;const l=a.attenuationColor||[1,1,1];return t.attenuationColor=new Oe().setRGB(l[0],l[1],l[2],Tn),Promise.all(o)}},nI=class{constructor(e){this.parser=e,this.name=St.KHR_MATERIALS_IOR}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:sr}extendMaterialParams(e,t){const r=this.parser.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const o=r.extensions[this.name];return t.ior=o.ior!==void 0?o.ior:1.5,Promise.resolve()}},iI=class{constructor(e){this.parser=e,this.name=St.KHR_MATERIALS_SPECULAR}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:sr}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const o=[],a=r.extensions[this.name];t.specularIntensity=a.specularFactor!==void 0?a.specularFactor:1,a.specularTexture!==void 0&&o.push(n.assignTexture(t,"specularIntensityMap",a.specularTexture));const l=a.specularColorFactor||[1,1,1];return t.specularColor=new Oe().setRGB(l[0],l[1],l[2],Tn),a.specularColorTexture!==void 0&&o.push(n.assignTexture(t,"specularColorMap",a.specularColorTexture,on)),Promise.all(o)}},rI=class{constructor(e){this.parser=e,this.name=St.EXT_MATERIALS_BUMP}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:sr}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const o=[],a=r.extensions[this.name];return t.bumpScale=a.bumpFactor!==void 0?a.bumpFactor:1,a.bumpTexture!==void 0&&o.push(n.assignTexture(t,"bumpMap",a.bumpTexture)),Promise.all(o)}},sI=class{constructor(e){this.parser=e,this.name=St.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:sr}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const o=[],a=r.extensions[this.name];return a.anisotropyStrength!==void 0&&(t.anisotropy=a.anisotropyStrength),a.anisotropyRotation!==void 0&&(t.anisotropyRotation=a.anisotropyRotation),a.anisotropyTexture!==void 0&&o.push(n.assignTexture(t,"anisotropyMap",a.anisotropyTexture)),Promise.all(o)}};class oI{constructor(e){this.parser=e,this.name=St.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,n=t.json,r=n.textures[e];if(!r.extensions||!r.extensions[this.name])return null;const o=r.extensions[this.name],a=t.options.ktx2Loader;if(!a){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,o.source,a)}}class aI{constructor(e){this.parser=e,this.name=St.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,n=this.parser,r=n.json,o=r.textures[e];if(!o.extensions||!o.extensions[t])return null;const a=o.extensions[t],l=r.images[a.source];let u=n.textureLoader;if(l.uri){const h=n.options.manager.getHandler(l.uri);h!==null&&(u=h)}return this.detectSupport().then(function(h){if(h)return n.loadTextureImage(e,a.source,u);if(r.extensionsRequired&&r.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return n.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(t.height===1)}})),this.isSupported}}class cI{constructor(e){this.parser=e,this.name=St.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){const t=this.name,n=this.parser,r=n.json,o=r.textures[e];if(!o.extensions||!o.extensions[t])return null;const a=o.extensions[t],l=r.images[a.source];let u=n.textureLoader;if(l.uri){const h=n.options.manager.getHandler(l.uri);h!==null&&(u=h)}return this.detectSupport().then(function(h){if(h)return n.loadTextureImage(e,a.source,u);if(r.extensionsRequired&&r.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return n.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const t=new Image;t.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",t.onload=t.onerror=function(){e(t.height===1)}})),this.isSupported}}class lI{constructor(e){this.name=St.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){const r=n.extensions[this.name],o=this.parser.getDependency("buffer",r.buffer),a=this.parser.options.meshoptDecoder;if(!a||!a.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return o.then(function(l){const u=r.byteOffset||0,h=r.byteLength||0,d=r.count,p=r.byteStride,m=new Uint8Array(l,u,h);return a.decodeGltfBufferAsync?a.decodeGltfBufferAsync(d,p,m,r.mode,r.filter).then(function(g){return g.buffer}):a.ready.then(function(){const g=new ArrayBuffer(d*p);return a.decodeGltfBuffer(new Uint8Array(g),d,p,m,r.mode,r.filter),g})})}else return null}}let uI=class{constructor(e){this.name=St.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||n.mesh===void 0)return null;const r=t.meshes[n.mesh];for(const h of r.primitives)if(h.mode!==yi.TRIANGLES&&h.mode!==yi.TRIANGLE_STRIP&&h.mode!==yi.TRIANGLE_FAN&&h.mode!==void 0)return null;const a=n.extensions[this.name].attributes,l=[],u={};for(const h in a)l.push(this.parser.getDependency("accessor",a[h]).then(d=>(u[h]=d,u[h])));return l.length<1?null:(l.push(this.parser.createNodeMesh(e)),Promise.all(l).then(h=>{const d=h.pop(),p=d.isGroup?d.children:[d],m=h[0].count,g=[];for(const y of p){const S=new Qe,_=new F,v=new an,R=new F(1,1,1),b=new OP(y.geometry,y.material,m);for(let A=0;A<m;A++)u.TRANSLATION&&_.fromBufferAttribute(u.TRANSLATION,A),u.ROTATION&&v.fromBufferAttribute(u.ROTATION,A),u.SCALE&&R.fromBufferAttribute(u.SCALE,A),b.setMatrixAt(A,S.compose(_,v,R));for(const A in u)if(A==="_COLOR_0"){const B=u[A];b.instanceColor=new hf(B.array,B.itemSize,B.normalized)}else A!=="TRANSLATION"&&A!=="ROTATION"&&A!=="SCALE"&&y.geometry.setAttribute(A,u[A]);gt.prototype.copy.call(b,y),this.parser.assignFinalMaterial(b),g.push(b)}return d.isGroup?(d.clear(),d.add(...g),d):g[0]}))}};const H0="glTF",Ma=12,T_={JSON:1313821514,BIN:5130562};class hI{constructor(e){this.name=St.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,Ma),n=new TextDecoder;if(this.header={magic:n.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==H0)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const r=this.header.length-Ma,o=new DataView(e,Ma);let a=0;for(;a<r;){const l=o.getUint32(a,!0);a+=4;const u=o.getUint32(a,!0);if(a+=4,u===T_.JSON){const h=new Uint8Array(e,Ma+a,l);this.content=n.decode(h)}else if(u===T_.BIN){const h=Ma+a;this.body=e.slice(h,h+l)}a+=l}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class fI{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=St.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const n=this.json,r=this.dracoLoader,o=e.extensions[this.name].bufferView,a=e.extensions[this.name].attributes,l={},u={},h={};for(const d in a){const p=_f[d]||d.toLowerCase();l[p]=a[d]}for(const d in e.attributes){const p=_f[d]||d.toLowerCase();if(a[d]!==void 0){const m=n.accessors[e.attributes[d]],g=wo[m.componentType];h[p]=g.name,u[p]=m.normalized===!0}}return t.getDependency("bufferView",o).then(function(d){return new Promise(function(p,m){r.decodeDracoFile(d,function(g){for(const y in g.attributes){const S=g.attributes[y],_=u[y];_!==void 0&&(S.normalized=_)}p(g)},l,h,Tn,m)})})}}class dI{constructor(){this.name=St.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return(t.texCoord===void 0||t.texCoord===e.channel)&&t.offset===void 0&&t.rotation===void 0&&t.scale===void 0||(e=e.clone(),t.texCoord!==void 0&&(e.channel=t.texCoord),t.offset!==void 0&&e.offset.fromArray(t.offset),t.rotation!==void 0&&(e.rotation=t.rotation),t.scale!==void 0&&e.repeat.fromArray(t.scale),e.needsUpdate=!0),e}}class pI{constructor(){this.name=St.KHR_MESH_QUANTIZATION}}class G0 extends Wa{constructor(e,t,n,r){super(e,t,n,r)}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,r=this.valueSize,o=e*r*3+r;for(let a=0;a!==r;a++)t[a]=n[o+a];return t}interpolate_(e,t,n,r){const o=this.resultBuffer,a=this.sampleValues,l=this.valueSize,u=l*2,h=l*3,d=r-t,p=(n-t)/d,m=p*p,g=m*p,y=e*h,S=y-h,_=-2*g+3*m,v=g-m,R=1-_,b=v-m+p;for(let A=0;A!==l;A++){const B=a[S+A+l],N=a[S+A+u]*d,D=a[y+A+l],C=a[y+A]*d;o[A]=R*B+b*N+_*D+v*C}return o}}const mI=new an;class gI extends G0{interpolate_(e,t,n,r){const o=super.interpolate_(e,t,n,r);return mI.fromArray(o).normalize().toArray(o),o}}const yi={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},wo={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},b_={9728:Nn,9729:Xn,9984:Uf,9985:Da,9986:yo,9987:Ki},w_={33071:$i,33648:Co,10497:es},Wh={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},_f={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},jr={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},_I={CUBICSPLINE:void 0,LINEAR:As,STEP:Lo},Xh={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function vI(i){return i.DefaultMaterial===void 0&&(i.DefaultMaterial=new zo({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:tr})),i.DefaultMaterial}function ys(i,e,t){for(const n in t.extensions)i[n]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[n]=t.extensions[n])}function Kr(i,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(i.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function xI(i,e,t){let n=!1,r=!1,o=!1;for(let h=0,d=e.length;h<d;h++){const p=e[h];if(p.POSITION!==void 0&&(n=!0),p.NORMAL!==void 0&&(r=!0),p.COLOR_0!==void 0&&(o=!0),n&&r&&o)break}if(!n&&!r&&!o)return Promise.resolve(i);const a=[],l=[],u=[];for(let h=0,d=e.length;h<d;h++){const p=e[h];if(n){const m=p.POSITION!==void 0?t.getDependency("accessor",p.POSITION):i.attributes.position;a.push(m)}if(r){const m=p.NORMAL!==void 0?t.getDependency("accessor",p.NORMAL):i.attributes.normal;l.push(m)}if(o){const m=p.COLOR_0!==void 0?t.getDependency("accessor",p.COLOR_0):i.attributes.color;u.push(m)}}return Promise.all([Promise.all(a),Promise.all(l),Promise.all(u)]).then(function(h){const d=h[0],p=h[1],m=h[2];return n&&(i.morphAttributes.position=d),r&&(i.morphAttributes.normal=p),o&&(i.morphAttributes.color=m),i.morphTargetsRelative=!0,i})}function yI(i,e){if(i.updateMorphTargets(),e.weights!==void 0)for(let t=0,n=e.weights.length;t<n;t++)i.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){const t=e.extras.targetNames;if(i.morphTargetInfluences.length===t.length){i.morphTargetDictionary={};for(let n=0,r=t.length;n<r;n++)i.morphTargetDictionary[t[n]]=n}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function MI(i){let e;const t=i.extensions&&i.extensions[St.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+Yh(t.attributes):e=i.indices+":"+Yh(i.attributes)+":"+i.mode,i.targets!==void 0)for(let n=0,r=i.targets.length;n<r;n++)e+=":"+Yh(i.targets[n]);return e}function Yh(i){let e="";const t=Object.keys(i).sort();for(let n=0,r=t.length;n<r;n++)e+=t[n]+":"+i[t[n]]+";";return e}function vf(i){switch(i){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function SI(i){return i.search(/\.jpe?g($|\?)/i)>0||i.search(/^data\:image\/jpeg/)===0?"image/jpeg":i.search(/\.webp($|\?)/i)>0||i.search(/^data\:image\/webp/)===0?"image/webp":"image/png"}const EI=new Qe;class TI{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new jL,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let n=!1,r=!1,o=-1;typeof navigator<"u"&&(n=/^((?!chrome|android).)*safari/i.test(navigator.userAgent)===!0,r=navigator.userAgent.indexOf("Firefox")>-1,o=r?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1),typeof createImageBitmap>"u"||n||r&&o<98?this.textureLoader=new N0(this.options.manager):this.textureLoader=new lL(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new Ll(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const n=this,r=this.json,o=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(a){return a._markDefs&&a._markDefs()}),Promise.all(this._invokeAll(function(a){return a.beforeRoot&&a.beforeRoot()})).then(function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(a){const l={scene:a[0][r.scene||0],scenes:a[0],animations:a[1],cameras:a[2],asset:r.asset,parser:n,userData:{}};return ys(o,l,r),Kr(l,r),Promise.all(n._invokeAll(function(u){return u.afterRoot&&u.afterRoot(l)})).then(function(){for(const u of l.scenes)u.updateMatrixWorld();e(l)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let r=0,o=t.length;r<o;r++){const a=t[r].joints;for(let l=0,u=a.length;l<u;l++)e[a[l]].isBone=!0}for(let r=0,o=e.length;r<o;r++){const a=e[r];a.mesh!==void 0&&(this._addNodeRef(this.meshCache,a.mesh),a.skin!==void 0&&(n[a.mesh].isSkinnedMesh=!0)),a.camera!==void 0&&this._addNodeRef(this.cameraCache,a.camera)}}_addNodeRef(e,t){t!==void 0&&(e.refs[t]===void 0&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,n){if(e.refs[t]<=1)return n;const r=n.clone(),o=(a,l)=>{const u=this.associations.get(a);u!=null&&this.associations.set(l,u);for(const[h,d]of a.children.entries())o(d,l.children[h])};return o(n,r),r.name+="_instance_"+e.uses[t]++,r}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){const r=e(t[n]);if(r)return r}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const n=[];for(let r=0;r<t.length;r++){const o=e(t[r]);o&&n.push(o)}return n}getDependency(e,t){const n=e+":"+t;let r=this.cache.get(n);if(!r){switch(e){case"scene":r=this.loadScene(t);break;case"node":r=this._invokeOne(function(o){return o.loadNode&&o.loadNode(t)});break;case"mesh":r=this._invokeOne(function(o){return o.loadMesh&&o.loadMesh(t)});break;case"accessor":r=this.loadAccessor(t);break;case"bufferView":r=this._invokeOne(function(o){return o.loadBufferView&&o.loadBufferView(t)});break;case"buffer":r=this.loadBuffer(t);break;case"material":r=this._invokeOne(function(o){return o.loadMaterial&&o.loadMaterial(t)});break;case"texture":r=this._invokeOne(function(o){return o.loadTexture&&o.loadTexture(t)});break;case"skin":r=this.loadSkin(t);break;case"animation":r=this._invokeOne(function(o){return o.loadAnimation&&o.loadAnimation(t)});break;case"camera":r=this.loadCamera(t);break;default:if(r=this._invokeOne(function(o){return o!=this&&o.getDependency&&o.getDependency(e,t)}),!r)throw new Error("Unknown type: "+e);break}this.cache.add(n,r)}return r}getDependencies(e){let t=this.cache.get(e);if(!t){const n=this,r=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(r.map(function(o,a){return n.getDependency(e,a)})),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],n=this.fileLoader;if(t.type&&t.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[St.KHR_BINARY_GLTF].body);const r=this.options;return new Promise(function(o,a){n.load(Oa.resolveURL(t.uri,r.path),o,void 0,function(){a(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(n){const r=t.byteLength||0,o=t.byteOffset||0;return n.slice(o,o+r)})}loadAccessor(e){const t=this,n=this.json,r=this.json.accessors[e];if(r.bufferView===void 0&&r.sparse===void 0){const a=Wh[r.type],l=wo[r.componentType],u=r.normalized===!0,h=new l(r.count*a);return Promise.resolve(new Nt(h,a,u))}const o=[];return r.bufferView!==void 0?o.push(this.getDependency("bufferView",r.bufferView)):o.push(null),r.sparse!==void 0&&(o.push(this.getDependency("bufferView",r.sparse.indices.bufferView)),o.push(this.getDependency("bufferView",r.sparse.values.bufferView))),Promise.all(o).then(function(a){const l=a[0],u=Wh[r.type],h=wo[r.componentType],d=h.BYTES_PER_ELEMENT,p=d*u,m=r.byteOffset||0,g=r.bufferView!==void 0?n.bufferViews[r.bufferView].byteStride:void 0,y=r.normalized===!0;let S,_;if(g&&g!==p){const v=Math.floor(m/g),R="InterleavedBuffer:"+r.bufferView+":"+r.componentType+":"+v+":"+r.count;let b=t.cache.get(R);b||(S=new h(l,v*g,r.count*g/d),b=new A0(S,g/d),t.cache.add(R,b)),_=new ka(b,u,m%g/d,y)}else l===null?S=new h(r.count*u):S=new h(l,m,r.count*u),_=new Nt(S,u,y);if(r.sparse!==void 0){const v=Wh.SCALAR,R=wo[r.sparse.indices.componentType],b=r.sparse.indices.byteOffset||0,A=r.sparse.values.byteOffset||0,B=new R(a[1],b,r.sparse.count*v),N=new h(a[2],A,r.sparse.count*u);l!==null&&(_=new Nt(_.array.slice(),_.itemSize,_.normalized));for(let D=0,C=B.length;D<C;D++){const E=B[D];if(_.setX(E,N[D*u]),u>=2&&_.setY(E,N[D*u+1]),u>=3&&_.setZ(E,N[D*u+2]),u>=4&&_.setW(E,N[D*u+3]),u>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return _})}loadTexture(e){const t=this.json,n=this.options,o=t.textures[e].source,a=t.images[o];let l=this.textureLoader;if(a.uri){const u=n.manager.getHandler(a.uri);u!==null&&(l=u)}return this.loadTextureImage(e,o,l)}loadTextureImage(e,t,n){const r=this,o=this.json,a=o.textures[e],l=o.images[t],u=(l.uri||l.bufferView)+":"+a.sampler;if(this.textureCache[u])return this.textureCache[u];const h=this.loadImageSource(t,n).then(function(d){d.flipY=!1,d.name=a.name||l.name||"",d.name===""&&typeof l.uri=="string"&&l.uri.startsWith("data:image/")===!1&&(d.name=l.uri);const m=(o.samplers||{})[a.sampler]||{};return d.magFilter=b_[m.magFilter]||Xn,d.minFilter=b_[m.minFilter]||Ki,d.wrapS=w_[m.wrapS]||es,d.wrapT=w_[m.wrapT]||es,r.associations.set(d,{textures:e}),d}).catch(function(){return null});return this.textureCache[u]=h,h}loadImageSource(e,t){const n=this,r=this.json,o=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(p=>p.clone());const a=r.images[e],l=self.URL||self.webkitURL;let u=a.uri||"",h=!1;if(a.bufferView!==void 0)u=n.getDependency("bufferView",a.bufferView).then(function(p){h=!0;const m=new Blob([p],{type:a.mimeType});return u=l.createObjectURL(m),u});else if(a.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const d=Promise.resolve(u).then(function(p){return new Promise(function(m,g){let y=m;t.isImageBitmapLoader===!0&&(y=function(S){const _=new cn(S);_.needsUpdate=!0,m(_)}),t.load(Oa.resolveURL(p,o.path),y,void 0,g)})}).then(function(p){return h===!0&&l.revokeObjectURL(u),p.userData.mimeType=a.mimeType||SI(a.uri),p}).catch(function(p){throw console.error("THREE.GLTFLoader: Couldn't load texture",u),p});return this.sourceCache[e]=d,d}assignTexture(e,t,n,r){const o=this;return this.getDependency("texture",n.index).then(function(a){if(!a)return null;if(n.texCoord!==void 0&&n.texCoord>0&&(a=a.clone(),a.channel=n.texCoord),o.extensions[St.KHR_TEXTURE_TRANSFORM]){const l=n.extensions!==void 0?n.extensions[St.KHR_TEXTURE_TRANSFORM]:void 0;if(l){const u=o.associations.get(a);a=o.extensions[St.KHR_TEXTURE_TRANSFORM].extendTexture(a,l),o.associations.set(a,u)}}return r!==void 0&&(a.colorSpace=r),e[t]=a,a})}assignFinalMaterial(e){const t=e.geometry;let n=e.material;const r=t.attributes.tangent===void 0,o=t.attributes.color!==void 0,a=t.attributes.normal===void 0;if(e.isPoints){const l="PointsMaterial:"+n.uuid;let u=this.cache.get(l);u||(u=new I0,Ti.prototype.copy.call(u,n),u.color.copy(n.color),u.map=n.map,u.sizeAttenuation=!1,this.cache.add(l,u)),n=u}else if(e.isLine){const l="LineBasicMaterial:"+n.uuid;let u=this.cache.get(l);u||(u=new Bo,Ti.prototype.copy.call(u,n),u.color.copy(n.color),u.map=n.map,this.cache.add(l,u)),n=u}if(r||o||a){let l="ClonedMaterial:"+n.uuid+":";r&&(l+="derivative-tangents:"),o&&(l+="vertex-colors:"),a&&(l+="flat-shading:");let u=this.cache.get(l);u||(u=n.clone(),o&&(u.vertexColors=!0),a&&(u.flatShading=!0),r&&(u.normalScale&&(u.normalScale.y*=-1),u.clearcoatNormalScale&&(u.clearcoatNormalScale.y*=-1)),this.cache.add(l,u),this.associations.set(u,this.associations.get(n))),n=u}e.material=n}getMaterialType(){return zo}loadMaterial(e){const t=this,n=this.json,r=this.extensions,o=n.materials[e];let a;const l={},u=o.extensions||{},h=[];if(u[St.KHR_MATERIALS_UNLIT]){const p=r[St.KHR_MATERIALS_UNLIT];a=p.getMaterialType(),h.push(p.extendParams(l,o,t))}else{const p=o.pbrMetallicRoughness||{};if(l.color=new Oe(1,1,1),l.opacity=1,Array.isArray(p.baseColorFactor)){const m=p.baseColorFactor;l.color.setRGB(m[0],m[1],m[2],Tn),l.opacity=m[3]}p.baseColorTexture!==void 0&&h.push(t.assignTexture(l,"map",p.baseColorTexture,on)),l.metalness=p.metallicFactor!==void 0?p.metallicFactor:1,l.roughness=p.roughnessFactor!==void 0?p.roughnessFactor:1,p.metallicRoughnessTexture!==void 0&&(h.push(t.assignTexture(l,"metalnessMap",p.metallicRoughnessTexture)),h.push(t.assignTexture(l,"roughnessMap",p.metallicRoughnessTexture))),a=this._invokeOne(function(m){return m.getMaterialType&&m.getMaterialType(e)}),h.push(Promise.all(this._invokeAll(function(m){return m.extendMaterialParams&&m.extendMaterialParams(e,l)})))}o.doubleSided===!0&&(l.side=si);const d=o.alphaMode||Xh.OPAQUE;if(d===Xh.BLEND?(l.transparent=!0,l.depthWrite=!1):(l.transparent=!1,d===Xh.MASK&&(l.alphaTest=o.alphaCutoff!==void 0?o.alphaCutoff:.5)),o.normalTexture!==void 0&&a!==Ji&&(h.push(t.assignTexture(l,"normalMap",o.normalTexture)),l.normalScale=new Pe(1,1),o.normalTexture.scale!==void 0)){const p=o.normalTexture.scale;l.normalScale.set(p,p)}if(o.occlusionTexture!==void 0&&a!==Ji&&(h.push(t.assignTexture(l,"aoMap",o.occlusionTexture)),o.occlusionTexture.strength!==void 0&&(l.aoMapIntensity=o.occlusionTexture.strength)),o.emissiveFactor!==void 0&&a!==Ji){const p=o.emissiveFactor;l.emissive=new Oe().setRGB(p[0],p[1],p[2],Tn)}return o.emissiveTexture!==void 0&&a!==Ji&&h.push(t.assignTexture(l,"emissiveMap",o.emissiveTexture,on)),Promise.all(h).then(function(){const p=new a(l);return o.name&&(p.name=o.name),Kr(p,o),t.associations.set(p,{materials:e}),o.extensions&&ys(r,p,o),p})}createUniqueName(e){const t=wt.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,n=this.extensions,r=this.primitiveCache;function o(l){return n[St.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(l,t).then(function(u){return A_(u,l,t)})}const a=[];for(let l=0,u=e.length;l<u;l++){const h=e[l],d=MI(h),p=r[d];if(p)a.push(p.promise);else{let m;h.extensions&&h.extensions[St.KHR_DRACO_MESH_COMPRESSION]?m=o(h):m=A_(new tn,h,t),r[d]={primitive:h,promise:m},a.push(m)}}return Promise.all(a)}loadMesh(e){const t=this,n=this.json,r=this.extensions,o=n.meshes[e],a=o.primitives,l=[];for(let u=0,h=a.length;u<h;u++){const d=a[u].material===void 0?vI(this.cache):this.getDependency("material",a[u].material);l.push(d)}return l.push(t.loadGeometries(a)),Promise.all(l).then(function(u){const h=u.slice(0,u.length-1),d=u[u.length-1],p=[];for(let g=0,y=d.length;g<y;g++){const S=d[g],_=a[g];let v;const R=h[g];if(_.mode===yi.TRIANGLES||_.mode===yi.TRIANGLE_STRIP||_.mode===yi.TRIANGLE_FAN||_.mode===void 0)v=o.isSkinnedMesh===!0?new DP(S,R):new Se(S,R),v.isSkinnedMesh===!0&&v.normalizeSkinWeights(),_.mode===yi.TRIANGLE_STRIP?v.geometry=E_(v.geometry,o0):_.mode===yi.TRIANGLE_FAN&&(v.geometry=E_(v.geometry,cf));else if(_.mode===yi.LINES)v=new Gf(S,R);else if(_.mode===yi.LINE_STRIP)v=new Si(S,R);else if(_.mode===yi.LINE_LOOP)v=new FP(S,R);else if(_.mode===yi.POINTS)v=new BP(S,R);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+_.mode);Object.keys(v.geometry.morphAttributes).length>0&&yI(v,o),v.name=t.createUniqueName(o.name||"mesh_"+e),Kr(v,o),_.extensions&&ys(r,v,_),t.assignFinalMaterial(v),p.push(v)}for(let g=0,y=p.length;g<y;g++)t.associations.set(p[g],{meshes:e,primitives:g});if(p.length===1)return o.extensions&&ys(r,p[0],o),p[0];const m=new Qi;o.extensions&&ys(r,m,o),t.associations.set(m,{meshes:e});for(let g=0,y=p.length;g<y;g++)m.add(p[g]);return m})}loadCamera(e){let t;const n=this.json.cameras[e],r=n[n.type];if(!r){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return n.type==="perspective"?t=new Un(ci.radToDeg(r.yfov),r.aspectRatio||1,r.znear||1,r.zfar||2e6):n.type==="orthographic"&&(t=new zl(-r.xmag,r.xmag,r.ymag,-r.ymag,r.znear,r.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),Kr(t,n),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],n=[];for(let r=0,o=t.joints.length;r<o;r++)n.push(this._loadNodeShallow(t.joints[r]));return t.inverseBindMatrices!==void 0?n.push(this.getDependency("accessor",t.inverseBindMatrices)):n.push(null),Promise.all(n).then(function(r){const o=r.pop(),a=r,l=[],u=[];for(let h=0,d=a.length;h<d;h++){const p=a[h];if(p){l.push(p);const m=new Qe;o!==null&&m.fromArray(o.array,h*16),u.push(m)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[h])}return new Hf(l,u)})}loadAnimation(e){const t=this.json,n=this,r=t.animations[e],o=r.name?r.name:"animation_"+e,a=[],l=[],u=[],h=[],d=[];for(let p=0,m=r.channels.length;p<m;p++){const g=r.channels[p],y=r.samplers[g.sampler],S=g.target,_=S.node,v=r.parameters!==void 0?r.parameters[y.input]:y.input,R=r.parameters!==void 0?r.parameters[y.output]:y.output;S.node!==void 0&&(a.push(this.getDependency("node",_)),l.push(this.getDependency("accessor",v)),u.push(this.getDependency("accessor",R)),h.push(y),d.push(S))}return Promise.all([Promise.all(a),Promise.all(l),Promise.all(u),Promise.all(h),Promise.all(d)]).then(function(p){const m=p[0],g=p[1],y=p[2],S=p[3],_=p[4],v=[];for(let R=0,b=m.length;R<b;R++){const A=m[R],B=g[R],N=y[R],D=S[R],C=_[R];if(A===void 0)continue;A.updateMatrix&&A.updateMatrix();const E=n._createAnimationTracks(A,B,N,D,C);if(E)for(let M=0;M<E.length;M++)v.push(E[M])}return new qP(o,void 0,v)})}createNodeMesh(e){const t=this.json,n=this,r=t.nodes[e];return r.mesh===void 0?null:n.getDependency("mesh",r.mesh).then(function(o){const a=n._getNodeRef(n.meshCache,r.mesh,o);return r.weights!==void 0&&a.traverse(function(l){if(l.isMesh)for(let u=0,h=r.weights.length;u<h;u++)l.morphTargetInfluences[u]=r.weights[u]}),a})}loadNode(e){const t=this.json,n=this,r=t.nodes[e],o=n._loadNodeShallow(e),a=[],l=r.children||[];for(let h=0,d=l.length;h<d;h++)a.push(n.getDependency("node",l[h]));const u=r.skin===void 0?Promise.resolve(null):n.getDependency("skin",r.skin);return Promise.all([o,Promise.all(a),u]).then(function(h){const d=h[0],p=h[1],m=h[2];m!==null&&d.traverse(function(g){g.isSkinnedMesh&&g.bind(m,EI)});for(let g=0,y=p.length;g<y;g++)d.add(p[g]);return d})}_loadNodeShallow(e){const t=this.json,n=this.extensions,r=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const o=t.nodes[e],a=o.name?r.createUniqueName(o.name):"",l=[],u=r._invokeOne(function(h){return h.createNodeMesh&&h.createNodeMesh(e)});return u&&l.push(u),o.camera!==void 0&&l.push(r.getDependency("camera",o.camera).then(function(h){return r._getNodeRef(r.cameraCache,o.camera,h)})),r._invokeAll(function(h){return h.createNodeAttachment&&h.createNodeAttachment(e)}).forEach(function(h){l.push(h)}),this.nodeCache[e]=Promise.all(l).then(function(h){let d;if(o.isBone===!0?d=new P0:h.length>1?d=new Qi:h.length===1?d=h[0]:d=new gt,d!==h[0])for(let p=0,m=h.length;p<m;p++)d.add(h[p]);if(o.name&&(d.userData.name=o.name,d.name=a),Kr(d,o),o.extensions&&ys(n,d,o),o.matrix!==void 0){const p=new Qe;p.fromArray(o.matrix),d.applyMatrix4(p)}else o.translation!==void 0&&d.position.fromArray(o.translation),o.rotation!==void 0&&d.quaternion.fromArray(o.rotation),o.scale!==void 0&&d.scale.fromArray(o.scale);return r.associations.has(d)||r.associations.set(d,{}),r.associations.get(d).nodes=e,d}),this.nodeCache[e]}loadScene(e){const t=this.extensions,n=this.json.scenes[e],r=this,o=new Qi;n.name&&(o.name=r.createUniqueName(n.name)),Kr(o,n),n.extensions&&ys(t,o,n);const a=n.nodes||[],l=[];for(let u=0,h=a.length;u<h;u++)l.push(r.getDependency("node",a[u]));return Promise.all(l).then(function(u){for(let d=0,p=u.length;d<p;d++)o.add(u[d]);const h=d=>{const p=new Map;for(const[m,g]of r.associations)(m instanceof Ti||m instanceof cn)&&p.set(m,g);return d.traverse(m=>{const g=r.associations.get(m);g!=null&&p.set(m,g)}),p};return r.associations=h(o),o})}_createAnimationTracks(e,t,n,r,o){const a=[],l=e.name?e.name:e.uuid,u=[];jr[o.path]===jr.weights?e.traverse(function(m){m.morphTargetInfluences&&u.push(m.name?m.name:m.uuid)}):u.push(l);let h;switch(jr[o.path]){case jr.weights:h=Uo;break;case jr.rotation:h=Cs;break;case jr.position:case jr.scale:h=No;break;default:switch(n.itemSize){case 1:h=Uo;break;case 2:case 3:default:h=No;break}break}const d=r.interpolation!==void 0?_I[r.interpolation]:As,p=this._getArrayFromAccessor(n);for(let m=0,g=u.length;m<g;m++){const y=new h(u[m]+"."+jr[o.path],t.array,p,d);r.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(y),a.push(y)}return a}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const n=vf(t.constructor),r=new Float32Array(t.length);for(let o=0,a=t.length;o<a;o++)r[o]=t[o]*n;t=r}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(n){const r=this instanceof Cs?gI:G0;return new r(this.times,this.values,this.getValueSize()/3,n)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function bI(i,e,t){const n=e.attributes,r=new zi;if(n.POSITION!==void 0){const l=t.json.accessors[n.POSITION],u=l.min,h=l.max;if(u!==void 0&&h!==void 0){if(r.set(new F(u[0],u[1],u[2]),new F(h[0],h[1],h[2])),l.normalized){const d=vf(wo[l.componentType]);r.min.multiplyScalar(d),r.max.multiplyScalar(d)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const o=e.targets;if(o!==void 0){const l=new F,u=new F;for(let h=0,d=o.length;h<d;h++){const p=o[h];if(p.POSITION!==void 0){const m=t.json.accessors[p.POSITION],g=m.min,y=m.max;if(g!==void 0&&y!==void 0){if(u.setX(Math.max(Math.abs(g[0]),Math.abs(y[0]))),u.setY(Math.max(Math.abs(g[1]),Math.abs(y[1]))),u.setZ(Math.max(Math.abs(g[2]),Math.abs(y[2]))),m.normalized){const S=vf(wo[m.componentType]);u.multiplyScalar(S)}l.max(u)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}r.expandByVector(l)}i.boundingBox=r;const a=new rr;r.getCenter(a.center),a.radius=r.min.distanceTo(r.max)/2,i.boundingSphere=a}function A_(i,e,t){const n=e.attributes,r=[];function o(a,l){return t.getDependency("accessor",a).then(function(u){i.setAttribute(l,u)})}for(const a in n){const l=_f[a]||a.toLowerCase();l in i.attributes||r.push(o(n[a],l))}if(e.indices!==void 0&&!i.index){const a=t.getDependency("accessor",e.indices).then(function(l){i.setIndex(l)});r.push(a)}return Lt.workingColorSpace!==Tn&&"COLOR_0"in n&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${Lt.workingColorSpace}" not supported.`),Kr(i,e),bI(i,e,t),Promise.all(r).then(function(){return e.targets!==void 0?xI(i,e.targets,t):i})}/*!
3823
+ }`;var lt=_m(function(){return Ct(I,Ue+"return "+me).apply(t,k)});if(lt.source=me,ju(lt))throw lt;return lt}function hT(s){return Pt(s).toLowerCase()}function fT(s){return Pt(s).toUpperCase()}function dT(s,c,f){if(s=Pt(s),s&&(f||c===t))return wd(s);if(!s||!(c=Qn(c)))return s;var x=wi(s),w=wi(c),I=Ad(x,w),k=Rd(x,w)+1;return Br(x,I,k).join("")}function pT(s,c,f){if(s=Pt(s),s&&(f||c===t))return s.slice(0,Pd(s)+1);if(!s||!(c=Qn(c)))return s;var x=wi(s),w=Rd(x,wi(c))+1;return Br(x,0,w).join("")}function mT(s,c,f){if(s=Pt(s),s&&(f||c===t))return s.replace(Hi,"");if(!s||!(c=Qn(c)))return s;var x=wi(s),w=Ad(x,wi(c));return Br(x,w).join("")}function gT(s,c){var f=M,x=O;if($t(c)){var w="separator"in c?c.separator:w;f="length"in c?at(c.length):f,x="omission"in c?Qn(c.omission):x}s=Pt(s);var I=s.length;if(Ns(s)){var k=wi(s);I=k.length}if(f>=I)return s;var V=f-Os(x);if(V<1)return x;var X=k?Br(k,0,V).join(""):s.slice(0,V);if(w===t)return X+x;if(k&&(V+=X.length-V),qu(w)){if(s.slice(V).search(w)){var ue,he=X;for(w.global||(w=uu(w.source,Pt(U.exec(w))+"g")),w.lastIndex=0;ue=w.exec(he);)var me=ue.index;X=X.slice(0,me===t?V:me)}}else if(s.indexOf(Qn(w),V)!=V){var Te=X.lastIndexOf(w);Te>-1&&(X=X.slice(0,Te))}return X+x}function _T(s){return s=Pt(s),s&&vt.test(s)?s.replace(ye,Yv):s}var vT=Vs(function(s,c,f){return s+(f?" ":"")+c.toUpperCase()}),Zu=vp("toUpperCase");function gm(s,c,f){return s=Pt(s),c=f?t:c,c===t?Hv(s)?$v(s):Iv(s):s.match(c)||[]}var _m=pt(function(s,c){try{return Zn(s,t,c)}catch(f){return ju(f)?f:new nt(f)}}),xT=fr(function(s,c){return fi(c,function(f){f=Xi(f),ur(s,f,Xu(s[f],s))}),s});function yT(s){var c=s==null?0:s.length,f=Ye();return s=c?Yt(s,function(x){if(typeof x[1]!="function")throw new di(a);return[f(x[0]),x[1]]}):[],pt(function(x){for(var w=-1;++w<c;){var I=s[w];if(Zn(I[0],this,x))return Zn(I[1],this,x)}})}function MT(s){return Yx(mi(s,p))}function Ju(s){return function(){return s}}function ST(s,c){return s==null||s!==s?c:s}var ET=yp(),TT=yp(!0);function $n(s){return s}function Qu(s){return Kd(typeof s=="function"?s:mi(s,p))}function bT(s){return Jd(mi(s,p))}function wT(s,c){return Qd(s,mi(c,p))}var AT=pt(function(s,c){return function(f){return ta(f,s,c)}}),RT=pt(function(s,c){return function(f){return ta(s,f,c)}});function eh(s,c,f){var x=gn(c),w=mc(c,x);f==null&&!($t(c)&&(w.length||!x.length))&&(f=c,c=s,s=this,w=mc(c,gn(c)));var I=!($t(f)&&"chain"in f)||!!f.chain,k=pr(s);return fi(w,function(V){var X=c[V];s[V]=X,k&&(s.prototype[V]=function(){var ue=this.__chain__;if(I||ue){var he=s(this.__wrapped__),me=he.__actions__=Yn(this.__actions__);return me.push({func:X,args:arguments,thisArg:s}),he.__chain__=ue,he}return X.apply(s,Ir([this.value()],arguments))})}),s}function CT(){return xn._===this&&(xn._=tx),this}function th(){}function PT(s){return s=at(s),pt(function(c){return ep(c,s)})}var LT=Iu(Yt),IT=Iu(Md),DT=Iu(iu);function vm(s){return zu(s)?ru(Xi(s)):ly(s)}function UT(s){return function(c){return s==null?t:ls(s,c)}}var NT=Sp(),OT=Sp(!0);function nh(){return[]}function ih(){return!1}function FT(){return{}}function BT(){return""}function zT(){return!0}function kT(s,c){if(s=at(s),s<1||s>K)return[];var f=ve,x=An(s,ve);c=Ye(c),s-=ve;for(var w=au(x,c);++f<s;)c(f);return w}function HT(s){return st(s)?Yt(s,Xi):ei(s)?[s]:Yn(Bp(Pt(s)))}function GT(s){var c=++Qv;return Pt(s)+c}var VT=Mc(function(s,c){return s+c},0),WT=Du("ceil"),XT=Mc(function(s,c){return s/c},1),YT=Du("floor");function jT(s){return s&&s.length?pc(s,$n,vu):t}function qT(s,c){return s&&s.length?pc(s,Ye(c,2),vu):t}function $T(s){return Td(s,$n)}function KT(s,c){return Td(s,Ye(c,2))}function ZT(s){return s&&s.length?pc(s,$n,Su):t}function JT(s,c){return s&&s.length?pc(s,Ye(c,2),Su):t}var QT=Mc(function(s,c){return s*c},1),eb=Du("round"),tb=Mc(function(s,c){return s-c},0);function nb(s){return s&&s.length?ou(s,$n):0}function ib(s,c){return s&&s.length?ou(s,Ye(c,2)):0}return L.after=bS,L.ary=$p,L.assign=fE,L.assignIn=lm,L.assignInWith=Uc,L.assignWith=dE,L.at=pE,L.before=Kp,L.bind=Xu,L.bindAll=xT,L.bindKey=Zp,L.castArray=FS,L.chain=Yp,L.chunk=Yy,L.compact=jy,L.concat=qy,L.cond=yT,L.conforms=MT,L.constant=Ju,L.countBy=nS,L.create=mE,L.curry=Jp,L.curryRight=Qp,L.debounce=em,L.defaults=gE,L.defaultsDeep=_E,L.defer=wS,L.delay=AS,L.difference=$y,L.differenceBy=Ky,L.differenceWith=Zy,L.drop=Jy,L.dropRight=Qy,L.dropRightWhile=eM,L.dropWhile=tM,L.fill=nM,L.filter=rS,L.flatMap=aS,L.flatMapDeep=cS,L.flatMapDepth=lS,L.flatten=Gp,L.flattenDeep=iM,L.flattenDepth=rM,L.flip=RS,L.flow=ET,L.flowRight=TT,L.fromPairs=sM,L.functions=TE,L.functionsIn=bE,L.groupBy=uS,L.initial=aM,L.intersection=cM,L.intersectionBy=lM,L.intersectionWith=uM,L.invert=AE,L.invertBy=RE,L.invokeMap=fS,L.iteratee=Qu,L.keyBy=dS,L.keys=gn,L.keysIn=qn,L.map=Rc,L.mapKeys=PE,L.mapValues=LE,L.matches=bT,L.matchesProperty=wT,L.memoize=Pc,L.merge=IE,L.mergeWith=um,L.method=AT,L.methodOf=RT,L.mixin=eh,L.negate=Lc,L.nthArg=PT,L.omit=DE,L.omitBy=UE,L.once=CS,L.orderBy=pS,L.over=LT,L.overArgs=PS,L.overEvery=IT,L.overSome=DT,L.partial=Yu,L.partialRight=tm,L.partition=mS,L.pick=NE,L.pickBy=hm,L.property=vm,L.propertyOf=UT,L.pull=pM,L.pullAll=Wp,L.pullAllBy=mM,L.pullAllWith=gM,L.pullAt=_M,L.range=NT,L.rangeRight=OT,L.rearg=LS,L.reject=vS,L.remove=vM,L.rest=IS,L.reverse=Vu,L.sampleSize=yS,L.set=FE,L.setWith=BE,L.shuffle=MS,L.slice=xM,L.sortBy=TS,L.sortedUniq=wM,L.sortedUniqBy=AM,L.split=aT,L.spread=DS,L.tail=RM,L.take=CM,L.takeRight=PM,L.takeRightWhile=LM,L.takeWhile=IM,L.tap=jM,L.throttle=US,L.thru=Ac,L.toArray=om,L.toPairs=fm,L.toPairsIn=dm,L.toPath=HT,L.toPlainObject=cm,L.transform=zE,L.unary=NS,L.union=DM,L.unionBy=UM,L.unionWith=NM,L.uniq=OM,L.uniqBy=FM,L.uniqWith=BM,L.unset=kE,L.unzip=Wu,L.unzipWith=Xp,L.update=HE,L.updateWith=GE,L.values=Ys,L.valuesIn=VE,L.without=zM,L.words=gm,L.wrap=OS,L.xor=kM,L.xorBy=HM,L.xorWith=GM,L.zip=VM,L.zipObject=WM,L.zipObjectDeep=XM,L.zipWith=YM,L.entries=fm,L.entriesIn=dm,L.extend=lm,L.extendWith=Uc,eh(L,L),L.add=VT,L.attempt=_m,L.camelCase=jE,L.capitalize=pm,L.ceil=WT,L.clamp=WE,L.clone=BS,L.cloneDeep=kS,L.cloneDeepWith=HS,L.cloneWith=zS,L.conformsTo=GS,L.deburr=mm,L.defaultTo=ST,L.divide=XT,L.endsWith=qE,L.eq=Ri,L.escape=$E,L.escapeRegExp=KE,L.every=iS,L.find=sS,L.findIndex=kp,L.findKey=vE,L.findLast=oS,L.findLastIndex=Hp,L.findLastKey=xE,L.floor=YT,L.forEach=jp,L.forEachRight=qp,L.forIn=yE,L.forInRight=ME,L.forOwn=SE,L.forOwnRight=EE,L.get=$u,L.gt=VS,L.gte=WS,L.has=wE,L.hasIn=Ku,L.head=Vp,L.identity=$n,L.includes=hS,L.indexOf=oM,L.inRange=XE,L.invoke=CE,L.isArguments=fs,L.isArray=st,L.isArrayBuffer=XS,L.isArrayLike=jn,L.isArrayLikeObject=rn,L.isBoolean=YS,L.isBuffer=zr,L.isDate=jS,L.isElement=qS,L.isEmpty=$S,L.isEqual=KS,L.isEqualWith=ZS,L.isError=ju,L.isFinite=JS,L.isFunction=pr,L.isInteger=nm,L.isLength=Ic,L.isMap=im,L.isMatch=QS,L.isMatchWith=eE,L.isNaN=tE,L.isNative=nE,L.isNil=rE,L.isNull=iE,L.isNumber=rm,L.isObject=$t,L.isObjectLike=Qt,L.isPlainObject=aa,L.isRegExp=qu,L.isSafeInteger=sE,L.isSet=sm,L.isString=Dc,L.isSymbol=ei,L.isTypedArray=Xs,L.isUndefined=oE,L.isWeakMap=aE,L.isWeakSet=cE,L.join=hM,L.kebabCase=ZE,L.last=_i,L.lastIndexOf=fM,L.lowerCase=JE,L.lowerFirst=QE,L.lt=lE,L.lte=uE,L.max=jT,L.maxBy=qT,L.mean=$T,L.meanBy=KT,L.min=ZT,L.minBy=JT,L.stubArray=nh,L.stubFalse=ih,L.stubObject=FT,L.stubString=BT,L.stubTrue=zT,L.multiply=QT,L.nth=dM,L.noConflict=CT,L.noop=th,L.now=Cc,L.pad=eT,L.padEnd=tT,L.padStart=nT,L.parseInt=iT,L.random=YE,L.reduce=gS,L.reduceRight=_S,L.repeat=rT,L.replace=sT,L.result=OE,L.round=eb,L.runInContext=W,L.sample=xS,L.size=SS,L.snakeCase=oT,L.some=ES,L.sortedIndex=yM,L.sortedIndexBy=MM,L.sortedIndexOf=SM,L.sortedLastIndex=EM,L.sortedLastIndexBy=TM,L.sortedLastIndexOf=bM,L.startCase=cT,L.startsWith=lT,L.subtract=tb,L.sum=nb,L.sumBy=ib,L.template=uT,L.times=kT,L.toFinite=mr,L.toInteger=at,L.toLength=am,L.toLower=hT,L.toNumber=vi,L.toSafeInteger=hE,L.toString=Pt,L.toUpper=fT,L.trim=dT,L.trimEnd=pT,L.trimStart=mT,L.truncate=gT,L.unescape=_T,L.uniqueId=GT,L.upperCase=vT,L.upperFirst=Zu,L.each=jp,L.eachRight=qp,L.first=Vp,eh(L,function(){var s={};return Vi(L,function(c,f){It.call(L.prototype,f)||(s[f]=c)}),s}(),{chain:!1}),L.VERSION=n,fi(["bind","bindKey","curry","curryRight","partial","partialRight"],function(s){L[s].placeholder=L}),fi(["drop","take"],function(s,c){Mt.prototype[s]=function(f){f=f===t?1:fn(at(f),0);var x=this.__filtered__&&!c?new Mt(this):this.clone();return x.__filtered__?x.__takeCount__=An(f,x.__takeCount__):x.__views__.push({size:An(f,ve),type:s+(x.__dir__<0?"Right":"")}),x},Mt.prototype[s+"Right"]=function(f){return this.reverse()[s](f).reverse()}}),fi(["filter","map","takeWhile"],function(s,c){var f=c+1,x=f==Y||f==re;Mt.prototype[s]=function(w){var I=this.clone();return I.__iteratees__.push({iteratee:Ye(w,3),type:f}),I.__filtered__=I.__filtered__||x,I}}),fi(["head","last"],function(s,c){var f="take"+(c?"Right":"");Mt.prototype[s]=function(){return this[f](1).value()[0]}}),fi(["initial","tail"],function(s,c){var f="drop"+(c?"":"Right");Mt.prototype[s]=function(){return this.__filtered__?new Mt(this):this[f](1)}}),Mt.prototype.compact=function(){return this.filter($n)},Mt.prototype.find=function(s){return this.filter(s).head()},Mt.prototype.findLast=function(s){return this.reverse().find(s)},Mt.prototype.invokeMap=pt(function(s,c){return typeof s=="function"?new Mt(this):this.map(function(f){return ta(f,s,c)})}),Mt.prototype.reject=function(s){return this.filter(Lc(Ye(s)))},Mt.prototype.slice=function(s,c){s=at(s);var f=this;return f.__filtered__&&(s>0||c<0)?new Mt(f):(s<0?f=f.takeRight(-s):s&&(f=f.drop(s)),c!==t&&(c=at(c),f=c<0?f.dropRight(-c):f.take(c-s)),f)},Mt.prototype.takeRightWhile=function(s){return this.reverse().takeWhile(s).reverse()},Mt.prototype.toArray=function(){return this.take(ve)},Vi(Mt.prototype,function(s,c){var f=/^(?:filter|find|map|reject)|While$/.test(c),x=/^(?:head|last)$/.test(c),w=L[x?"take"+(c=="last"?"Right":""):c],I=x||/^find/.test(c);w&&(L.prototype[c]=function(){var k=this.__wrapped__,V=x?[1]:arguments,X=k instanceof Mt,ue=V[0],he=X||st(k),me=function(xt){var bt=w.apply(L,Ir([xt],V));return x&&Te?bt[0]:bt};he&&f&&typeof ue=="function"&&ue.length!=1&&(X=he=!1);var Te=this.__chain__,Ue=!!this.__actions__.length,je=I&&!Te,lt=X&&!Ue;if(!I&&he){k=lt?k:new Mt(this);var qe=s.apply(k,V);return qe.__actions__.push({func:Ac,args:[me],thisArg:t}),new pi(qe,Te)}return je&&lt?s.apply(this,V):(qe=this.thru(me),je?x?qe.value()[0]:qe.value():qe)})}),fi(["pop","push","shift","sort","splice","unshift"],function(s){var c=Qa[s],f=/^(?:push|sort|unshift)$/.test(s)?"tap":"thru",x=/^(?:pop|shift)$/.test(s);L.prototype[s]=function(){var w=arguments;if(x&&!this.__chain__){var I=this.value();return c.apply(st(I)?I:[],w)}return this[f](function(k){return c.apply(st(k)?k:[],w)})}}),Vi(Mt.prototype,function(s,c){var f=L[c];if(f){var x=f.name+"";It.call(ks,x)||(ks[x]=[]),ks[x].push({name:c,func:f})}}),ks[yc(t,v).name]=[{name:"wrapper",func:t}],Mt.prototype.clone=_x,Mt.prototype.reverse=vx,Mt.prototype.value=xx,L.prototype.at=qM,L.prototype.chain=$M,L.prototype.commit=KM,L.prototype.next=ZM,L.prototype.plant=QM,L.prototype.reverse=eS,L.prototype.toJSON=L.prototype.valueOf=L.prototype.value=tS,L.prototype.first=L.prototype.head,qo&&(L.prototype[qo]=JM),L},Fs=Kv();rs?((rs.exports=Fs)._=Fs,Ql._=Fs):xn._=Fs}).call(NL)}(Ra,Ra.exports)),Ra.exports}var FL=OL();class Wh{constructor(e,t){this._path=e,this._ctor=t}_promise=null;_instance=null;async get(){return this._instance?Promise.resolve(this._instance):this._promise?this._promise:(this._promise=(async()=>{const t=(await import(this._path))[this._ctor];if(!t)throw new Error(`DIVE: Module class ${this._ctor} not found in ${this._path}`);if(typeof t!="function")throw new Error(`DIVE: Module at ${this._path} does not export a valid constructor (${this._ctor} wanted)`);return this._instance=new t,this._instance})(),this._promise)}}class On{static __instances=[];static get(e){const t=this.__instances.find(n=>n.id===e);return t||this.__instances.find(n=>Array.from(n.registered.values()).find(r=>r.id===e))}_id;get id(){return this._id}renderer;scene;controller;toolbox;_mediaGenerator=new Wh("../mediacreator/MediaCreator.ts","DIVEMediaCreator");_io=new Wh("../io/IO.ts","DIVEIO");_ar=new Wh("../ar/AR.ts","DIVEAR");registered=new Map;listeners=new Map;constructor(e,t,n,r){this._id=EL(),this.renderer=e,this.scene=t,this.controller=n,this.toolbox=r,On.__instances.push(this)}DestroyInstance(){const e=On.__instances.findIndex(t=>t.id===this.id);return e===-1?!1:(On.__instances.splice(e,1),!0)}PerformAction(e,t){let n=!1;switch(e){case"START_RENDER":{this.renderer.StartRenderer(this.scene,this.controller.object),n=!0;break}case"GET_ALL_SCENE_DATA":{n=this.getAllSceneData(t);break}case"GET_ALL_OBJECTS":{n=this.getAllObjects(t);break}case"GET_OBJECTS":{n=this.getObjects(t);break}case"ADD_OBJECT":{n=this.addObject(t);break}case"UPDATE_OBJECT":{n=this.updateObject(t);break}case"DELETE_OBJECT":{n=this.deleteObject(t);break}case"SELECT_OBJECT":{n=this.selectObject(t);break}case"DESELECT_OBJECT":{n=this.deselectObject(t);break}case"SET_BACKGROUND":{n=this.setBackground(t);break}case"DROP_IT":{n=this.dropIt(t);break}case"PLACE_ON_FLOOR":{n=this.placeOnFloor(t);break}case"SET_CAMERA_TRANSFORM":{n=this.setCameraTransform(t);break}case"GET_CAMERA_TRANSFORM":{n=this.getCameraTransform(t);break}case"MOVE_CAMERA":{n=this.moveCamera(t);break}case"RESET_CAMERA":{n=this.resetCamera(t);break}case"COMPUTE_ENCOMPASSING_VIEW":{n=this.computeEncompassingView(t);break}case"SET_CAMERA_LAYER":{n=this.setCameraLayer(t);break}case"ZOOM_CAMERA":{n=this.zoomCamera(t);break}case"SET_GIZMO_MODE":{n=this.setGizmoMode(t);break}case"SET_GIZMO_VISIBILITY":{n=this.setGizmoVisibility(t);break}case"SET_GIZMO_SCALE_LINKED":{n=this.setGizmoScaleLinked(t);break}case"USE_TOOL":{n=this.useTool(t);break}case"MODEL_LOADED":{n=this.modelLoaded(t);break}case"UPDATE_SCENE":{n=this.updateScene(t);break}case"GENERATE_MEDIA":{n=this.generateMedia(t);break}case"SET_PARENT":{n=this.setParent(t);break}case"EXPORT_SCENE":{n=this.exportScene(t);break}case"LAUNCH_AR":{const{uri:r,options:o}=t;n=new Promise((a,l)=>{this._ar.get().then(u=>{a(u.launch(r,o))}).catch(l)});break}default:console.warn(`DIVECommunication.PerformAction: has been executed with unknown Action type ${e}`)}return this.dispatch(e,t),n}Subscribe(e,t){return this.listeners.get(e)||this.listeners.set(e,[]),this.listeners.get(e).push(t),()=>{const n=this.listeners.get(e);if(!n)return!1;const r=n.findIndex(o=>o===t);return r===-1?!1:(n.splice(r,1),!0)}}dispatch(e,t){const n=this.listeners.get(e);n&&n.forEach(r=>r(t))}getAllSceneData(e){const t={name:this.scene.name,mediaItem:null,backgroundColor:"#"+this.scene.background.getHexString(),floorEnabled:this.scene.Floor.visible,floorColor:"#"+this.scene.Floor.material.color.getHexString(),userCamera:{position:this.controller.object.position.clone(),target:this.controller.target.clone()},spotmarks:[],lights:Array.from(this.registered.values()).filter(n=>n.entityType==="light"),objects:Array.from(this.registered.values()).filter(n=>n.entityType==="model"),cameras:Array.from(this.registered.values()).filter(n=>n.entityType==="pov"),primitives:Array.from(this.registered.values()).filter(n=>n.entityType==="primitive"),groups:Array.from(this.registered.values()).filter(n=>n.entityType==="group")};return Object.assign(e,t),t}getAllObjects(e){return Object.assign(e,this.registered),this.registered}getObjects(e){if(e.ids.length===0)return[];const t=[];return this.registered.forEach(n=>{e.ids.includes(n.id)&&t.push(n)}),t}addObject(e){return this.registered.get(e.id)?!1:(e.parentId===void 0&&(e.parentId=null),this.registered.set(e.id,e),this.scene.AddSceneObject(e),!0)}updateObject(e){const t=this.registered.get(e.id);if(!t)return!1;this.registered.set(e.id,FL.merge(t,e));const n=this.registered.get(e.id);return this.scene.UpdateSceneObject({...e,id:n.id,entityType:n.entityType}),Object.assign(e,n),!0}deleteObject(e){const t=this.registered.get(e.id);return t?(t.parentId&&this.setParent({object:{id:t.id},parent:null}),t.entityType==="group"&&this.registered.forEach(n=>{n.parentId===t.id&&this.updateObject({id:n.id,parentId:null})}),Object.assign(e,t),this.registered.delete(e.id),Array.from(this.registered.values()).forEach(n=>{n.parentId&&n.parentId===e.id&&(n.parentId=null)}),this.scene.DeleteSceneObject(t),!0):!1}selectObject(e){const t=this.registered.get(e.id);if(!t)return!1;const n=this.scene.GetSceneObject(t);if(!n||!("isSelectable"in n))return!1;const r=this.toolbox.GetActiveTool();return r&&M_(r)&&r.AttachGizmo(n),Object.assign(e,t),!0}deselectObject(e){const t=this.registered.get(e.id);if(!t)return!1;const n=this.scene.GetSceneObject(t);if(!n||!("isSelectable"in n))return!1;const r=this.toolbox.GetActiveTool();return r&&M_(r)&&r.DetachGizmo(),Object.assign(e,t),!0}setBackground(e){return this.scene.SetBackground(e.color),!0}dropIt(e){const t=this.registered.get(e.id);return t?(this.scene.GetSceneObject(t).DropIt(),!0):!1}placeOnFloor(e){const t=this.registered.get(e.id);return t?(this.scene.PlaceOnFloor(t),!0):!1}setCameraTransform(e){return this.controller.object.position.copy(e.position),this.controller.target.copy(e.target),this.controller.update(),!0}getCameraTransform(e){const t={position:this.controller.object.position.clone(),target:this.controller.target.clone()};return Object.assign(e,t),t}moveCamera(e){let t={x:0,y:0,z:0},n={x:0,y:0,z:0};return"id"in e?(t=this.registered.get(e.id).position,n=this.registered.get(e.id).target):(t=e.position,n=e.target),this.controller.MoveTo(t,n,e.duration,e.locked),!0}setCameraLayer(e){return this.controller.object.SetCameraLayer(e.layer),!0}resetCamera(e){return this.controller.RevertLast(e.duration),!0}computeEncompassingView(e){const t=this.scene.ComputeSceneBB(),n=this.controller.ComputeEncompassingView(t);return Object.assign(e,n),n}zoomCamera(e){return e.direction==="IN"&&this.controller.ZoomIn(e.by),e.direction==="OUT"&&this.controller.ZoomOut(e.by),!0}setGizmoMode(e){return this.toolbox.SetGizmoMode(e.mode),!0}setGizmoVisibility(e){return this.toolbox.SetGizmoVisibility(e),e}setGizmoScaleLinked(e){return this.toolbox.SetGizmoScaleLinked(e),e}useTool(e){return this.toolbox.UseTool(e.tool),!0}modelLoaded(e){return this.registered.get(e.id).loaded=!0,!0}updateScene(e){return e.name!==void 0&&(this.scene.name=e.name),e.backgroundColor!==void 0&&this.scene.SetBackground(e.backgroundColor),e.gridEnabled!==void 0&&this.scene.Grid.SetVisibility(e.gridEnabled),e.floorEnabled!==void 0&&this.scene.Floor.SetVisibility(e.floorEnabled),e.floorColor!==void 0&&this.scene.Floor.SetColor(e.floorColor),e.name=this.scene.name,e.backgroundColor="#"+this.scene.background.getHexString(),e.gridEnabled=this.scene.Grid.visible,e.floorEnabled=this.scene.Floor.visible,e.floorColor="#"+this.scene.Floor.material.color.getHexString(),!0}generateMedia(e){let t={x:0,y:0,z:0},n={x:0,y:0,z:0};return"id"in e?(t=this.registered.get(e.id).position,n=this.registered.get(e.id).target):(t=e.position,n=e.target),this._mediaGenerator.get().then(r=>r.GenerateMedia(t,n,e.width,e.height))}setParent(e){const t=this.registered.get(e.object.id);if(!t)return!1;const n=this.scene.GetSceneObject(t);if(!n)return!1;if(e.parent===null)return this.scene.Root.attach(n),this.updateObject({id:t.id,parentId:null}),!0;if(e.object.id===e.parent.id)return!1;const r=this.registered.get(e.parent.id);if(!r)return this.scene.Root.attach(n),this.updateObject({id:t.id,parentId:null}),!0;const o=this.scene.GetSceneObject(r);return o?(o.attach(n),this.updateObject({id:t.id,parentId:r.id}),!0):(this.scene.Root.attach(n),this.updateObject({id:t.id,parentId:null}),!0)}exportScene(e){return new Promise((t,n)=>{this._io.get().then(r=>{t(r.Export(e.type))}).catch(n)})}}class BL extends gt{isDIVELight=!0;isDIVEPointLight=!0;isMovable=!0;isSelectable=!0;gizmo=null;light;mesh;constructor(){super(),this.name="DIVEPointLight",this.light=new O0(16777215,1),this.light.layers.mask=li,this.light.castShadow=!0,this.light.shadow.mapSize.width=512,this.light.shadow.mapSize.height=512,this.add(this.light);const e=.1,t=new Va(e,e*320,e*320),n=new Ji({color:this.light.color,transparent:!0,opacity:.8,side:tr});this.mesh=new Se(t,n),this.mesh.layers.mask=Zf,this.add(this.mesh)}SetColor(e){this.light.color=e,this.mesh.material.color=e}SetIntensity(e){this.light.intensity=e,this.mesh.material.opacity=e>.8?.8:e*.8}SetEnabled(e){this.light.visible=e}onMove(){On.get(this.userData.id)?.PerformAction("UPDATE_OBJECT",{id:this.userData.id,position:this.position})}onSelect(){On.get(this.userData.id)?.PerformAction("SELECT_OBJECT",{id:this.userData.id})}onDeselect(){On.get(this.userData.id)?.PerformAction("DESELECT_OBJECT",{id:this.userData.id})}}class zL extends gt{isDIVELight=!0;isDIVESceneLight=!0;_hemiLight;_dirLight;constructor(){super(),this.name="DIVESceneLight",this._hemiLight=new tL(16777215,16777215,2),this._hemiLight.layers.mask=li,this._hemiLight.position.set(0,50,0),this.add(this._hemiLight),this._dirLight=new jf(16777215,3),this._dirLight.layers.mask=li,this._dirLight.position.set(1,1.75,1),this._dirLight.position.multiplyScalar(30),this._dirLight.castShadow=!0,this._dirLight.shadow.mapSize.width=2048,this._dirLight.shadow.mapSize.height=2048;const e=5;this._dirLight.shadow.camera.left=-5,this._dirLight.shadow.camera.right=e,this._dirLight.shadow.camera.top=e,this._dirLight.shadow.camera.bottom=-5,this._dirLight.shadow.camera.far=3500,this.add(this._dirLight)}SetColor(e){this._hemiLight.color=e,this._dirLight.color=e}SetIntensity(e){this._hemiLight.intensity=e*2,this._dirLight.intensity=e*3}SetEnabled(e){this._hemiLight.visible=e,this._dirLight.visible=e}}const Jf=i=>i.parent?Jf(i.parent):i;class kL{isMovable=!0}class HL{isSelectable=!0}function GL(i,e){return e.forEach(t=>{Object.getOwnPropertyNames(t.prototype).forEach(n=>{Object.defineProperty(i.prototype,n,Object.getOwnPropertyDescriptor(t.prototype,n))})}),i}class Qf extends GL(gt,[HL,kL]){isDIVENode=!0;gizmo=null;_positionWorldBuffer;_boundingBox;constructor(){super(),this.layers.mask=li,this._positionWorldBuffer=new F,this._boundingBox=new zi}SetPosition(e){if(!this.parent){this.position.set(e.x,e.y,e.z);return}const t=new F(e.x,e.y,e.z);this.position.copy(this.parent.worldToLocal(t)),"isDIVEGroup"in this.parent&&this.parent.UpdateLineTo(this)}SetRotation(e){this.rotation.set(e.x,e.y,e.z)}SetScale(e){this.scale.set(e.x,e.y,e.z)}SetVisibility(e){this.visible=e}SetToWorldOrigin(){this.position.set(0,0,0),On.get(this.userData.id)?.PerformAction("UPDATE_OBJECT",{id:this.userData.id,position:this.getWorldPosition(this._positionWorldBuffer),rotation:this.rotation,scale:this.scale})}onMove(){On.get(this.userData.id)?.PerformAction("UPDATE_OBJECT",{id:this.userData.id,position:this.getWorldPosition(this._positionWorldBuffer),rotation:this.rotation,scale:this.scale})}onSelect(){On.get(this.userData.id)?.PerformAction("SELECT_OBJECT",{id:this.userData.id})}onDeselect(){On.get(this.userData.id)?.PerformAction("DESELECT_OBJECT",{id:this.userData.id})}}class VL extends Qf{isDIVEModel=!0;_mesh=null;_material=null;SetModel(e){this.clear(),this._boundingBox.makeEmpty(),e.traverse(t=>{t.castShadow=!0,t.receiveShadow=!0,t.layers.mask=this.layers.mask,this._boundingBox.expandByObject(t),!this._mesh&&"isMesh"in t&&(this._mesh=t,this._material?this._mesh.material=this._material:this._material=t.material)}),this.add(e)}SetMaterial(e){this._material||(this._material=new zo),e.vertexColors!==void 0&&(this._material.vertexColors=e.vertexColors),e.color!==void 0&&this._material.color.set(e.color),e.map!==void 0&&(this._material.map=e.map),e.normalMap!==void 0&&(this._material.normalMap=e.normalMap),e.roughness!==void 0&&(this._material.roughness=e.roughness),e.roughnessMap!==void 0&&(this._material.roughnessMap=e.roughnessMap,this._material.roughnessMap&&(this._material.roughness=1)),e.metalness!==void 0&&(this._material.metalness=e.metalness),e.metalnessMap!==void 0&&(this._material.metalnessMap=e.metalnessMap,this._material.metalnessMap&&(this._material.metalness=1)),this._mesh&&(this._mesh.material=this._material)}PlaceOnFloor(){const e=this.getWorldPosition(this._positionWorldBuffer),t=e.clone();this._mesh?.geometry?.computeBoundingBox();const n=this._mesh?.geometry?.boundingBox;!n||!this._mesh||(e.y=e.y-this._mesh.localToWorld(n.min.clone()).y,e.y!==t.y&&On.get(this.userData.id)?.PerformAction("UPDATE_OBJECT",{id:this.userData.id,position:e,rotation:this.rotation,scale:this.scale}))}DropIt(){if(!this.parent){console.warn("DIVEModel: DropIt() called on a model that is not in the scene.",this);return}const e=this._boundingBox.min.y*this.scale.y,t=this.localToWorld(this._boundingBox.getCenter(new F).multiply(this.scale));t.y=e+this.position.y;const n=new Gl(t,new F(0,-1,0));n.layers.mask=li;const r=n.intersectObjects(Jf(this).Root.children,!0);if(r.length>0){const o=r[0].object;o.geometry.computeBoundingBox();const a=o.geometry.boundingBox,l=o.localToWorld(a.max.clone()),u=this.position.clone(),h=this.position.clone().setY(l.y).sub(new F(0,e,0));if(this.position.copy(h),this.position.y===u.y)return;this.onMove()}}}class WL extends Qf{isDIVEPrimitive=!0;_mesh;constructor(){super(),this._mesh=new Se,this._mesh.layers.mask=li,this._mesh.castShadow=!0,this._mesh.receiveShadow=!0,this._mesh.material=new zo,this.add(this._mesh)}SetGeometry(e){const t=this.assembleGeometry(e);t&&(this._mesh.geometry=t,this._boundingBox.setFromObject(this._mesh))}SetMaterial(e){const t=this._mesh.material;e.vertexColors!==void 0&&(t.vertexColors=e.vertexColors),e.color!==void 0&&(t.color=new Oe(e.color)),e.map!==void 0&&(t.map=e.map),e.normalMap!==void 0&&(t.normalMap=e.normalMap),e.roughness!==void 0&&(t.roughness=e.roughness),e.roughnessMap!==void 0&&(t.roughnessMap=e.roughnessMap,t.roughnessMap&&(t.roughness=1)),e.metalness!==void 0&&(t.metalness=e.metalness),e.metalnessMap!==void 0&&(t.metalnessMap=e.metalnessMap,t.metalnessMap&&(t.metalness=0)),this._mesh&&(this._mesh.material=t)}PlaceOnFloor(){const e=this.getWorldPosition(this._positionWorldBuffer),t=e.clone();this._mesh?.geometry?.computeBoundingBox();const n=this._mesh?.geometry?.boundingBox;!n||!this._mesh||(e.y=e.y-this._mesh.localToWorld(n.min.clone()).y,e.y!==t.y&&On.get(this.userData.id)?.PerformAction("UPDATE_OBJECT",{id:this.userData.id,position:e,rotation:this.rotation,scale:this.scale}))}DropIt(){if(!this.parent){console.warn("DIVEPrimitive: DropIt() called on a model that is not in the scene.",this);return}const e=this._boundingBox.min.y*this.scale.y,t=this.localToWorld(this._boundingBox.getCenter(new F).multiply(this.scale));t.y=e+this.position.y;const n=new Gl(t,new F(0,-1,0));n.layers.mask=li;const r=n.intersectObjects(Jf(this).Root.children,!0);if(r.length>0){const o=r[0].object;o.geometry.computeBoundingBox();const a=o.geometry.boundingBox,l=o.localToWorld(a.max.clone()),u=this.position.clone(),h=this.position.clone().setY(l.y).sub(new F(0,e,0));if(this.position.copy(h),this.position.y===u.y)return;this.onMove()}}assembleGeometry(e){switch(this._mesh.material.flatShading=!1,e.name.toLowerCase()){case"cylinder":return this.createCylinderGeometry(e);case"sphere":return this.createSphereGeometry(e);case"pyramid":return this._mesh.material.flatShading=!0,this.createPyramidGeometry(e);case"cube":case"box":return this.createBoxGeometry(e);case"cone":return this.createConeGeometry(e);case"wall":return this.createWallGeometry(e);case"plane":return this.createPlaneGeometry(e);default:return console.warn("DIVEPrimitive.assembleGeometry: Invalid geometry type:",e.name.toLowerCase()),null}}createCylinderGeometry(e){const t=new vn(e.width/2,e.width/2,e.height,64);return t.translate(0,e.height/2,0),t}createSphereGeometry(e){return new Va(e.width/2,256,256)}createPyramidGeometry(e){const t=new Float32Array([-e.width/2,0,-e.depth/2,e.width/2,0,-e.depth/2,e.width/2,0,e.depth/2,-e.width/2,0,e.depth/2,0,e.height,0]),n=new Uint16Array([0,1,2,0,2,3,0,4,1,1,4,2,2,4,3,3,4,0]),r=new tn;return r.setAttribute("position",new Nt(t,3)),r.setIndex(new Nt(n,1)),r.computeVertexNormals(),r.computeBoundingBox(),r.computeBoundingSphere(),r}createBoxGeometry(e){const t=new Kt(e.width,e.height,e.depth);return t.translate(0,e.height/2,0),t}createConeGeometry(e){const t=new Wf(e.width/2,e.height,256);return t.translate(0,e.height/2,0),t}createWallGeometry(e){const t=new Kt(e.width,e.height,e.depth||.05,16);return t.translate(0,e.height/2,0),t}createPlaneGeometry(e){const t=new Kt(e.width,e.height,e.depth);return t.translate(0,e.height/2,0),t}}class XL extends Qf{isDIVEGroup=!0;_members;get members(){return this._members}_lines;constructor(){super(),this.name="DIVEGroup",this._members=[],this._lines=[]}SetPosition(e){super.SetPosition(e),this._members.forEach(t=>{"isDIVENode"in t&&t.onMove()})}SetLinesVisibility(e,t){if(!t){this._lines.forEach(r=>{r.visible=e});return}const n=this._members.indexOf(t);n!==-1&&(this._lines[n].visible=e)}attach(e){if(this._members.includes(e))return this;const t=this.createLine();return this.add(t),this._lines.push(t),super.attach(e),this._members.push(e),this.updateLineTo(t,e),this.SetLinesVisibility(!0,e),this}remove(e){const t=this._members.indexOf(e);if(t===-1)return this;const n=this._lines[t];return super.remove(n),this._lines.splice(t,1),super.remove(e),this._members.splice(t,1),this}UpdateLineTo(e){const t=this._members.indexOf(e);t!==-1&&this.updateLineTo(this._lines[t],e)}createLine(){const e=new tn,t=new HP({color:6710886,dashSize:.05,gapSize:.025}),n=new Si(e,t);return n.visible=!1,n}updateLineTo(e,t){e.geometry.setFromPoints([new F(0,0,0),t.position.clone()]),e.computeLineDistances()}}function E_(i,e){if(e===Zb)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),i;if(e===lf||e===o0){let t=i.getIndex();if(t===null){const a=[],l=i.getAttribute("position");if(l!==void 0){for(let u=0;u<l.count;u++)a.push(u);i.setIndex(a),t=i.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),i}const n=t.count-2,r=[];if(e===lf)for(let a=1;a<=n;a++)r.push(t.getX(0)),r.push(t.getX(a)),r.push(t.getX(a+1));else for(let a=0;a<n;a++)a%2===0?(r.push(t.getX(a)),r.push(t.getX(a+1)),r.push(t.getX(a+2))):(r.push(t.getX(a+2)),r.push(t.getX(a+1)),r.push(t.getX(a)));r.length/3!==n&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const o=i.clone();return o.setIndex(r),o.clearGroups(),o}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),i}class YL extends Ls{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new ZL(t)}),this.register(function(t){return new oI(t)}),this.register(function(t){return new aI(t)}),this.register(function(t){return new cI(t)}),this.register(function(t){return new QL(t)}),this.register(function(t){return new eI(t)}),this.register(function(t){return new tI(t)}),this.register(function(t){return new nI(t)}),this.register(function(t){return new KL(t)}),this.register(function(t){return new iI(t)}),this.register(function(t){return new JL(t)}),this.register(function(t){return new sI(t)}),this.register(function(t){return new rI(t)}),this.register(function(t){return new qL(t)}),this.register(function(t){return new lI(t)}),this.register(function(t){return new uI(t)})}load(e,t,n,r){const o=this;let a;if(this.resourcePath!=="")a=this.resourcePath;else if(this.path!==""){const h=Oa.extractUrlBase(e);a=Oa.resolveURL(h,this.path)}else a=Oa.extractUrlBase(e);this.manager.itemStart(e);const l=function(h){r?r(h):console.error(h),o.manager.itemError(e),o.manager.itemEnd(e)},u=new Ll(this.manager);u.setPath(this.path),u.setResponseType("arraybuffer"),u.setRequestHeader(this.requestHeader),u.setWithCredentials(this.withCredentials),u.load(e,function(h){try{o.parse(h,a,function(d){t(d),o.manager.itemEnd(e)},l)}catch(d){l(d)}},n,l)}setDRACOLoader(e){return this.dracoLoader=e,this}setDDSLoader(){throw new Error('THREE.GLTFLoader: "MSFT_texture_dds" no longer supported. Please update to "KHR_texture_basisu".')}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,n,r){let o;const a={},l={},u=new TextDecoder;if(typeof e=="string")o=JSON.parse(e);else if(e instanceof ArrayBuffer)if(u.decode(new Uint8Array(e,0,4))===H0){try{a[St.KHR_BINARY_GLTF]=new hI(e)}catch(p){r&&r(p);return}o=JSON.parse(a[St.KHR_BINARY_GLTF].content)}else o=JSON.parse(u.decode(e));else o=e;if(o.asset===void 0||o.asset.version[0]<2){r&&r(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const h=new TI(o,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});h.fileLoader.setRequestHeader(this.requestHeader);for(let d=0;d<this.pluginCallbacks.length;d++){const p=this.pluginCallbacks[d](h);p.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),l[p.name]=p,a[p.name]=!0}if(o.extensionsUsed)for(let d=0;d<o.extensionsUsed.length;++d){const p=o.extensionsUsed[d],m=o.extensionsRequired||[];switch(p){case St.KHR_MATERIALS_UNLIT:a[p]=new $L;break;case St.KHR_DRACO_MESH_COMPRESSION:a[p]=new fI(o,this.dracoLoader);break;case St.KHR_TEXTURE_TRANSFORM:a[p]=new dI;break;case St.KHR_MESH_QUANTIZATION:a[p]=new pI;break;default:m.indexOf(p)>=0&&l[p]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+p+'".')}}h.setExtensions(a),h.setPlugins(l),h.parse(n,r)}parseAsync(e,t){const n=this;return new Promise(function(r,o){n.parse(e,t,r,o)})}}function jL(){let i={};return{get:function(e){return i[e]},add:function(e,t){i[e]=t},remove:function(e){delete i[e]},removeAll:function(){i={}}}}const St={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class qL{constructor(e){this.parser=e,this.name=St.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let n=0,r=t.length;n<r;n++){const o=t[n];o.extensions&&o.extensions[this.name]&&o.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,o.extensions[this.name].light)}}_loadLight(e){const t=this.parser,n="light:"+e;let r=t.cache.get(n);if(r)return r;const o=t.json,u=((o.extensions&&o.extensions[this.name]||{}).lights||[])[e];let h;const d=new Oe(16777215);u.color!==void 0&&d.setRGB(u.color[0],u.color[1],u.color[2],Tn);const p=u.range!==void 0?u.range:0;switch(u.type){case"directional":h=new jf(d),h.target.position.set(0,0,-1),h.add(h.target);break;case"point":h=new O0(d),h.distance=p;break;case"spot":h=new iL(d),h.distance=p,u.spot=u.spot||{},u.spot.innerConeAngle=u.spot.innerConeAngle!==void 0?u.spot.innerConeAngle:0,u.spot.outerConeAngle=u.spot.outerConeAngle!==void 0?u.spot.outerConeAngle:Math.PI/4,h.angle=u.spot.outerConeAngle,h.penumbra=1-u.spot.innerConeAngle/u.spot.outerConeAngle,h.target.position.set(0,0,-1),h.add(h.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+u.type)}return h.position.set(0,0,0),h.decay=2,Kr(h,u),u.intensity!==void 0&&(h.intensity=u.intensity),h.name=t.createUniqueName(u.name||"light_"+e),r=Promise.resolve(h),t.cache.add(n,r),r}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){const t=this,n=this.parser,o=n.json.nodes[e],l=(o.extensions&&o.extensions[this.name]||{}).light;return l===void 0?null:this._loadLight(l).then(function(u){return n._getNodeRef(t.cache,l,u)})}}let $L=class{constructor(){this.name=St.KHR_MATERIALS_UNLIT}getMaterialType(){return Ji}extendParams(e,t,n){const r=[];e.color=new Oe(1,1,1),e.opacity=1;const o=t.pbrMetallicRoughness;if(o){if(Array.isArray(o.baseColorFactor)){const a=o.baseColorFactor;e.color.setRGB(a[0],a[1],a[2],Tn),e.opacity=a[3]}o.baseColorTexture!==void 0&&r.push(n.assignTexture(e,"map",o.baseColorTexture,on))}return Promise.all(r)}},KL=class{constructor(e){this.parser=e,this.name=St.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const r=this.parser.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const o=r.extensions[this.name].emissiveStrength;return o!==void 0&&(t.emissiveIntensity=o),Promise.resolve()}},ZL=class{constructor(e){this.parser=e,this.name=St.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:sr}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const o=[],a=r.extensions[this.name];if(a.clearcoatFactor!==void 0&&(t.clearcoat=a.clearcoatFactor),a.clearcoatTexture!==void 0&&o.push(n.assignTexture(t,"clearcoatMap",a.clearcoatTexture)),a.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=a.clearcoatRoughnessFactor),a.clearcoatRoughnessTexture!==void 0&&o.push(n.assignTexture(t,"clearcoatRoughnessMap",a.clearcoatRoughnessTexture)),a.clearcoatNormalTexture!==void 0&&(o.push(n.assignTexture(t,"clearcoatNormalMap",a.clearcoatNormalTexture)),a.clearcoatNormalTexture.scale!==void 0)){const l=a.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new Pe(l,l)}return Promise.all(o)}},JL=class{constructor(e){this.parser=e,this.name=St.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:sr}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const o=[],a=r.extensions[this.name];return a.iridescenceFactor!==void 0&&(t.iridescence=a.iridescenceFactor),a.iridescenceTexture!==void 0&&o.push(n.assignTexture(t,"iridescenceMap",a.iridescenceTexture)),a.iridescenceIor!==void 0&&(t.iridescenceIOR=a.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),a.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=a.iridescenceThicknessMinimum),a.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=a.iridescenceThicknessMaximum),a.iridescenceThicknessTexture!==void 0&&o.push(n.assignTexture(t,"iridescenceThicknessMap",a.iridescenceThicknessTexture)),Promise.all(o)}},QL=class{constructor(e){this.parser=e,this.name=St.KHR_MATERIALS_SHEEN}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:sr}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const o=[];t.sheenColor=new Oe(0,0,0),t.sheenRoughness=0,t.sheen=1;const a=r.extensions[this.name];if(a.sheenColorFactor!==void 0){const l=a.sheenColorFactor;t.sheenColor.setRGB(l[0],l[1],l[2],Tn)}return a.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=a.sheenRoughnessFactor),a.sheenColorTexture!==void 0&&o.push(n.assignTexture(t,"sheenColorMap",a.sheenColorTexture,on)),a.sheenRoughnessTexture!==void 0&&o.push(n.assignTexture(t,"sheenRoughnessMap",a.sheenRoughnessTexture)),Promise.all(o)}},eI=class{constructor(e){this.parser=e,this.name=St.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:sr}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const o=[],a=r.extensions[this.name];return a.transmissionFactor!==void 0&&(t.transmission=a.transmissionFactor),a.transmissionTexture!==void 0&&o.push(n.assignTexture(t,"transmissionMap",a.transmissionTexture)),Promise.all(o)}},tI=class{constructor(e){this.parser=e,this.name=St.KHR_MATERIALS_VOLUME}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:sr}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const o=[],a=r.extensions[this.name];t.thickness=a.thicknessFactor!==void 0?a.thicknessFactor:0,a.thicknessTexture!==void 0&&o.push(n.assignTexture(t,"thicknessMap",a.thicknessTexture)),t.attenuationDistance=a.attenuationDistance||1/0;const l=a.attenuationColor||[1,1,1];return t.attenuationColor=new Oe().setRGB(l[0],l[1],l[2],Tn),Promise.all(o)}},nI=class{constructor(e){this.parser=e,this.name=St.KHR_MATERIALS_IOR}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:sr}extendMaterialParams(e,t){const r=this.parser.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const o=r.extensions[this.name];return t.ior=o.ior!==void 0?o.ior:1.5,Promise.resolve()}},iI=class{constructor(e){this.parser=e,this.name=St.KHR_MATERIALS_SPECULAR}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:sr}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const o=[],a=r.extensions[this.name];t.specularIntensity=a.specularFactor!==void 0?a.specularFactor:1,a.specularTexture!==void 0&&o.push(n.assignTexture(t,"specularIntensityMap",a.specularTexture));const l=a.specularColorFactor||[1,1,1];return t.specularColor=new Oe().setRGB(l[0],l[1],l[2],Tn),a.specularColorTexture!==void 0&&o.push(n.assignTexture(t,"specularColorMap",a.specularColorTexture,on)),Promise.all(o)}},rI=class{constructor(e){this.parser=e,this.name=St.EXT_MATERIALS_BUMP}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:sr}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const o=[],a=r.extensions[this.name];return t.bumpScale=a.bumpFactor!==void 0?a.bumpFactor:1,a.bumpTexture!==void 0&&o.push(n.assignTexture(t,"bumpMap",a.bumpTexture)),Promise.all(o)}},sI=class{constructor(e){this.parser=e,this.name=St.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:sr}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const o=[],a=r.extensions[this.name];return a.anisotropyStrength!==void 0&&(t.anisotropy=a.anisotropyStrength),a.anisotropyRotation!==void 0&&(t.anisotropyRotation=a.anisotropyRotation),a.anisotropyTexture!==void 0&&o.push(n.assignTexture(t,"anisotropyMap",a.anisotropyTexture)),Promise.all(o)}};class oI{constructor(e){this.parser=e,this.name=St.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,n=t.json,r=n.textures[e];if(!r.extensions||!r.extensions[this.name])return null;const o=r.extensions[this.name],a=t.options.ktx2Loader;if(!a){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,o.source,a)}}class aI{constructor(e){this.parser=e,this.name=St.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,n=this.parser,r=n.json,o=r.textures[e];if(!o.extensions||!o.extensions[t])return null;const a=o.extensions[t],l=r.images[a.source];let u=n.textureLoader;if(l.uri){const h=n.options.manager.getHandler(l.uri);h!==null&&(u=h)}return this.detectSupport().then(function(h){if(h)return n.loadTextureImage(e,a.source,u);if(r.extensionsRequired&&r.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return n.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(t.height===1)}})),this.isSupported}}class cI{constructor(e){this.parser=e,this.name=St.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){const t=this.name,n=this.parser,r=n.json,o=r.textures[e];if(!o.extensions||!o.extensions[t])return null;const a=o.extensions[t],l=r.images[a.source];let u=n.textureLoader;if(l.uri){const h=n.options.manager.getHandler(l.uri);h!==null&&(u=h)}return this.detectSupport().then(function(h){if(h)return n.loadTextureImage(e,a.source,u);if(r.extensionsRequired&&r.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return n.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const t=new Image;t.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",t.onload=t.onerror=function(){e(t.height===1)}})),this.isSupported}}class lI{constructor(e){this.name=St.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){const r=n.extensions[this.name],o=this.parser.getDependency("buffer",r.buffer),a=this.parser.options.meshoptDecoder;if(!a||!a.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return o.then(function(l){const u=r.byteOffset||0,h=r.byteLength||0,d=r.count,p=r.byteStride,m=new Uint8Array(l,u,h);return a.decodeGltfBufferAsync?a.decodeGltfBufferAsync(d,p,m,r.mode,r.filter).then(function(g){return g.buffer}):a.ready.then(function(){const g=new ArrayBuffer(d*p);return a.decodeGltfBuffer(new Uint8Array(g),d,p,m,r.mode,r.filter),g})})}else return null}}let uI=class{constructor(e){this.name=St.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||n.mesh===void 0)return null;const r=t.meshes[n.mesh];for(const h of r.primitives)if(h.mode!==yi.TRIANGLES&&h.mode!==yi.TRIANGLE_STRIP&&h.mode!==yi.TRIANGLE_FAN&&h.mode!==void 0)return null;const a=n.extensions[this.name].attributes,l=[],u={};for(const h in a)l.push(this.parser.getDependency("accessor",a[h]).then(d=>(u[h]=d,u[h])));return l.length<1?null:(l.push(this.parser.createNodeMesh(e)),Promise.all(l).then(h=>{const d=h.pop(),p=d.isGroup?d.children:[d],m=h[0].count,g=[];for(const y of p){const S=new Qe,_=new F,v=new an,R=new F(1,1,1),b=new OP(y.geometry,y.material,m);for(let A=0;A<m;A++)u.TRANSLATION&&_.fromBufferAttribute(u.TRANSLATION,A),u.ROTATION&&v.fromBufferAttribute(u.ROTATION,A),u.SCALE&&R.fromBufferAttribute(u.SCALE,A),b.setMatrixAt(A,S.compose(_,v,R));for(const A in u)if(A==="_COLOR_0"){const B=u[A];b.instanceColor=new ff(B.array,B.itemSize,B.normalized)}else A!=="TRANSLATION"&&A!=="ROTATION"&&A!=="SCALE"&&y.geometry.setAttribute(A,u[A]);gt.prototype.copy.call(b,y),this.parser.assignFinalMaterial(b),g.push(b)}return d.isGroup?(d.clear(),d.add(...g),d):g[0]}))}};const H0="glTF",Ma=12,T_={JSON:1313821514,BIN:5130562};class hI{constructor(e){this.name=St.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,Ma),n=new TextDecoder;if(this.header={magic:n.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==H0)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const r=this.header.length-Ma,o=new DataView(e,Ma);let a=0;for(;a<r;){const l=o.getUint32(a,!0);a+=4;const u=o.getUint32(a,!0);if(a+=4,u===T_.JSON){const h=new Uint8Array(e,Ma+a,l);this.content=n.decode(h)}else if(u===T_.BIN){const h=Ma+a;this.body=e.slice(h,h+l)}a+=l}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class fI{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=St.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const n=this.json,r=this.dracoLoader,o=e.extensions[this.name].bufferView,a=e.extensions[this.name].attributes,l={},u={},h={};for(const d in a){const p=vf[d]||d.toLowerCase();l[p]=a[d]}for(const d in e.attributes){const p=vf[d]||d.toLowerCase();if(a[d]!==void 0){const m=n.accessors[e.attributes[d]],g=wo[m.componentType];h[p]=g.name,u[p]=m.normalized===!0}}return t.getDependency("bufferView",o).then(function(d){return new Promise(function(p,m){r.decodeDracoFile(d,function(g){for(const y in g.attributes){const S=g.attributes[y],_=u[y];_!==void 0&&(S.normalized=_)}p(g)},l,h,Tn,m)})})}}class dI{constructor(){this.name=St.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return(t.texCoord===void 0||t.texCoord===e.channel)&&t.offset===void 0&&t.rotation===void 0&&t.scale===void 0||(e=e.clone(),t.texCoord!==void 0&&(e.channel=t.texCoord),t.offset!==void 0&&e.offset.fromArray(t.offset),t.rotation!==void 0&&(e.rotation=t.rotation),t.scale!==void 0&&e.repeat.fromArray(t.scale),e.needsUpdate=!0),e}}class pI{constructor(){this.name=St.KHR_MESH_QUANTIZATION}}class G0 extends Wa{constructor(e,t,n,r){super(e,t,n,r)}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,r=this.valueSize,o=e*r*3+r;for(let a=0;a!==r;a++)t[a]=n[o+a];return t}interpolate_(e,t,n,r){const o=this.resultBuffer,a=this.sampleValues,l=this.valueSize,u=l*2,h=l*3,d=r-t,p=(n-t)/d,m=p*p,g=m*p,y=e*h,S=y-h,_=-2*g+3*m,v=g-m,R=1-_,b=v-m+p;for(let A=0;A!==l;A++){const B=a[S+A+l],N=a[S+A+u]*d,D=a[y+A+l],C=a[y+A]*d;o[A]=R*B+b*N+_*D+v*C}return o}}const mI=new an;class gI extends G0{interpolate_(e,t,n,r){const o=super.interpolate_(e,t,n,r);return mI.fromArray(o).normalize().toArray(o),o}}const yi={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},wo={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},b_={9728:Nn,9729:Xn,9984:Nf,9985:Da,9986:yo,9987:Ki},w_={33071:$i,33648:Co,10497:es},Xh={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},vf={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},jr={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},_I={CUBICSPLINE:void 0,LINEAR:As,STEP:Lo},Yh={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function vI(i){return i.DefaultMaterial===void 0&&(i.DefaultMaterial=new zo({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:tr})),i.DefaultMaterial}function ys(i,e,t){for(const n in t.extensions)i[n]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[n]=t.extensions[n])}function Kr(i,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(i.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function xI(i,e,t){let n=!1,r=!1,o=!1;for(let h=0,d=e.length;h<d;h++){const p=e[h];if(p.POSITION!==void 0&&(n=!0),p.NORMAL!==void 0&&(r=!0),p.COLOR_0!==void 0&&(o=!0),n&&r&&o)break}if(!n&&!r&&!o)return Promise.resolve(i);const a=[],l=[],u=[];for(let h=0,d=e.length;h<d;h++){const p=e[h];if(n){const m=p.POSITION!==void 0?t.getDependency("accessor",p.POSITION):i.attributes.position;a.push(m)}if(r){const m=p.NORMAL!==void 0?t.getDependency("accessor",p.NORMAL):i.attributes.normal;l.push(m)}if(o){const m=p.COLOR_0!==void 0?t.getDependency("accessor",p.COLOR_0):i.attributes.color;u.push(m)}}return Promise.all([Promise.all(a),Promise.all(l),Promise.all(u)]).then(function(h){const d=h[0],p=h[1],m=h[2];return n&&(i.morphAttributes.position=d),r&&(i.morphAttributes.normal=p),o&&(i.morphAttributes.color=m),i.morphTargetsRelative=!0,i})}function yI(i,e){if(i.updateMorphTargets(),e.weights!==void 0)for(let t=0,n=e.weights.length;t<n;t++)i.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){const t=e.extras.targetNames;if(i.morphTargetInfluences.length===t.length){i.morphTargetDictionary={};for(let n=0,r=t.length;n<r;n++)i.morphTargetDictionary[t[n]]=n}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function MI(i){let e;const t=i.extensions&&i.extensions[St.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+jh(t.attributes):e=i.indices+":"+jh(i.attributes)+":"+i.mode,i.targets!==void 0)for(let n=0,r=i.targets.length;n<r;n++)e+=":"+jh(i.targets[n]);return e}function jh(i){let e="";const t=Object.keys(i).sort();for(let n=0,r=t.length;n<r;n++)e+=t[n]+":"+i[t[n]]+";";return e}function xf(i){switch(i){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function SI(i){return i.search(/\.jpe?g($|\?)/i)>0||i.search(/^data\:image\/jpeg/)===0?"image/jpeg":i.search(/\.webp($|\?)/i)>0||i.search(/^data\:image\/webp/)===0?"image/webp":"image/png"}const EI=new Qe;class TI{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new jL,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let n=!1,r=!1,o=-1;typeof navigator<"u"&&(n=/^((?!chrome|android).)*safari/i.test(navigator.userAgent)===!0,r=navigator.userAgent.indexOf("Firefox")>-1,o=r?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1),typeof createImageBitmap>"u"||n||r&&o<98?this.textureLoader=new N0(this.options.manager):this.textureLoader=new lL(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new Ll(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const n=this,r=this.json,o=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(a){return a._markDefs&&a._markDefs()}),Promise.all(this._invokeAll(function(a){return a.beforeRoot&&a.beforeRoot()})).then(function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(a){const l={scene:a[0][r.scene||0],scenes:a[0],animations:a[1],cameras:a[2],asset:r.asset,parser:n,userData:{}};return ys(o,l,r),Kr(l,r),Promise.all(n._invokeAll(function(u){return u.afterRoot&&u.afterRoot(l)})).then(function(){for(const u of l.scenes)u.updateMatrixWorld();e(l)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let r=0,o=t.length;r<o;r++){const a=t[r].joints;for(let l=0,u=a.length;l<u;l++)e[a[l]].isBone=!0}for(let r=0,o=e.length;r<o;r++){const a=e[r];a.mesh!==void 0&&(this._addNodeRef(this.meshCache,a.mesh),a.skin!==void 0&&(n[a.mesh].isSkinnedMesh=!0)),a.camera!==void 0&&this._addNodeRef(this.cameraCache,a.camera)}}_addNodeRef(e,t){t!==void 0&&(e.refs[t]===void 0&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,n){if(e.refs[t]<=1)return n;const r=n.clone(),o=(a,l)=>{const u=this.associations.get(a);u!=null&&this.associations.set(l,u);for(const[h,d]of a.children.entries())o(d,l.children[h])};return o(n,r),r.name+="_instance_"+e.uses[t]++,r}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){const r=e(t[n]);if(r)return r}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const n=[];for(let r=0;r<t.length;r++){const o=e(t[r]);o&&n.push(o)}return n}getDependency(e,t){const n=e+":"+t;let r=this.cache.get(n);if(!r){switch(e){case"scene":r=this.loadScene(t);break;case"node":r=this._invokeOne(function(o){return o.loadNode&&o.loadNode(t)});break;case"mesh":r=this._invokeOne(function(o){return o.loadMesh&&o.loadMesh(t)});break;case"accessor":r=this.loadAccessor(t);break;case"bufferView":r=this._invokeOne(function(o){return o.loadBufferView&&o.loadBufferView(t)});break;case"buffer":r=this.loadBuffer(t);break;case"material":r=this._invokeOne(function(o){return o.loadMaterial&&o.loadMaterial(t)});break;case"texture":r=this._invokeOne(function(o){return o.loadTexture&&o.loadTexture(t)});break;case"skin":r=this.loadSkin(t);break;case"animation":r=this._invokeOne(function(o){return o.loadAnimation&&o.loadAnimation(t)});break;case"camera":r=this.loadCamera(t);break;default:if(r=this._invokeOne(function(o){return o!=this&&o.getDependency&&o.getDependency(e,t)}),!r)throw new Error("Unknown type: "+e);break}this.cache.add(n,r)}return r}getDependencies(e){let t=this.cache.get(e);if(!t){const n=this,r=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(r.map(function(o,a){return n.getDependency(e,a)})),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],n=this.fileLoader;if(t.type&&t.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[St.KHR_BINARY_GLTF].body);const r=this.options;return new Promise(function(o,a){n.load(Oa.resolveURL(t.uri,r.path),o,void 0,function(){a(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(n){const r=t.byteLength||0,o=t.byteOffset||0;return n.slice(o,o+r)})}loadAccessor(e){const t=this,n=this.json,r=this.json.accessors[e];if(r.bufferView===void 0&&r.sparse===void 0){const a=Xh[r.type],l=wo[r.componentType],u=r.normalized===!0,h=new l(r.count*a);return Promise.resolve(new Nt(h,a,u))}const o=[];return r.bufferView!==void 0?o.push(this.getDependency("bufferView",r.bufferView)):o.push(null),r.sparse!==void 0&&(o.push(this.getDependency("bufferView",r.sparse.indices.bufferView)),o.push(this.getDependency("bufferView",r.sparse.values.bufferView))),Promise.all(o).then(function(a){const l=a[0],u=Xh[r.type],h=wo[r.componentType],d=h.BYTES_PER_ELEMENT,p=d*u,m=r.byteOffset||0,g=r.bufferView!==void 0?n.bufferViews[r.bufferView].byteStride:void 0,y=r.normalized===!0;let S,_;if(g&&g!==p){const v=Math.floor(m/g),R="InterleavedBuffer:"+r.bufferView+":"+r.componentType+":"+v+":"+r.count;let b=t.cache.get(R);b||(S=new h(l,v*g,r.count*g/d),b=new A0(S,g/d),t.cache.add(R,b)),_=new ka(b,u,m%g/d,y)}else l===null?S=new h(r.count*u):S=new h(l,m,r.count*u),_=new Nt(S,u,y);if(r.sparse!==void 0){const v=Xh.SCALAR,R=wo[r.sparse.indices.componentType],b=r.sparse.indices.byteOffset||0,A=r.sparse.values.byteOffset||0,B=new R(a[1],b,r.sparse.count*v),N=new h(a[2],A,r.sparse.count*u);l!==null&&(_=new Nt(_.array.slice(),_.itemSize,_.normalized));for(let D=0,C=B.length;D<C;D++){const E=B[D];if(_.setX(E,N[D*u]),u>=2&&_.setY(E,N[D*u+1]),u>=3&&_.setZ(E,N[D*u+2]),u>=4&&_.setW(E,N[D*u+3]),u>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return _})}loadTexture(e){const t=this.json,n=this.options,o=t.textures[e].source,a=t.images[o];let l=this.textureLoader;if(a.uri){const u=n.manager.getHandler(a.uri);u!==null&&(l=u)}return this.loadTextureImage(e,o,l)}loadTextureImage(e,t,n){const r=this,o=this.json,a=o.textures[e],l=o.images[t],u=(l.uri||l.bufferView)+":"+a.sampler;if(this.textureCache[u])return this.textureCache[u];const h=this.loadImageSource(t,n).then(function(d){d.flipY=!1,d.name=a.name||l.name||"",d.name===""&&typeof l.uri=="string"&&l.uri.startsWith("data:image/")===!1&&(d.name=l.uri);const m=(o.samplers||{})[a.sampler]||{};return d.magFilter=b_[m.magFilter]||Xn,d.minFilter=b_[m.minFilter]||Ki,d.wrapS=w_[m.wrapS]||es,d.wrapT=w_[m.wrapT]||es,r.associations.set(d,{textures:e}),d}).catch(function(){return null});return this.textureCache[u]=h,h}loadImageSource(e,t){const n=this,r=this.json,o=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(p=>p.clone());const a=r.images[e],l=self.URL||self.webkitURL;let u=a.uri||"",h=!1;if(a.bufferView!==void 0)u=n.getDependency("bufferView",a.bufferView).then(function(p){h=!0;const m=new Blob([p],{type:a.mimeType});return u=l.createObjectURL(m),u});else if(a.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const d=Promise.resolve(u).then(function(p){return new Promise(function(m,g){let y=m;t.isImageBitmapLoader===!0&&(y=function(S){const _=new cn(S);_.needsUpdate=!0,m(_)}),t.load(Oa.resolveURL(p,o.path),y,void 0,g)})}).then(function(p){return h===!0&&l.revokeObjectURL(u),p.userData.mimeType=a.mimeType||SI(a.uri),p}).catch(function(p){throw console.error("THREE.GLTFLoader: Couldn't load texture",u),p});return this.sourceCache[e]=d,d}assignTexture(e,t,n,r){const o=this;return this.getDependency("texture",n.index).then(function(a){if(!a)return null;if(n.texCoord!==void 0&&n.texCoord>0&&(a=a.clone(),a.channel=n.texCoord),o.extensions[St.KHR_TEXTURE_TRANSFORM]){const l=n.extensions!==void 0?n.extensions[St.KHR_TEXTURE_TRANSFORM]:void 0;if(l){const u=o.associations.get(a);a=o.extensions[St.KHR_TEXTURE_TRANSFORM].extendTexture(a,l),o.associations.set(a,u)}}return r!==void 0&&(a.colorSpace=r),e[t]=a,a})}assignFinalMaterial(e){const t=e.geometry;let n=e.material;const r=t.attributes.tangent===void 0,o=t.attributes.color!==void 0,a=t.attributes.normal===void 0;if(e.isPoints){const l="PointsMaterial:"+n.uuid;let u=this.cache.get(l);u||(u=new I0,Ti.prototype.copy.call(u,n),u.color.copy(n.color),u.map=n.map,u.sizeAttenuation=!1,this.cache.add(l,u)),n=u}else if(e.isLine){const l="LineBasicMaterial:"+n.uuid;let u=this.cache.get(l);u||(u=new Bo,Ti.prototype.copy.call(u,n),u.color.copy(n.color),u.map=n.map,this.cache.add(l,u)),n=u}if(r||o||a){let l="ClonedMaterial:"+n.uuid+":";r&&(l+="derivative-tangents:"),o&&(l+="vertex-colors:"),a&&(l+="flat-shading:");let u=this.cache.get(l);u||(u=n.clone(),o&&(u.vertexColors=!0),a&&(u.flatShading=!0),r&&(u.normalScale&&(u.normalScale.y*=-1),u.clearcoatNormalScale&&(u.clearcoatNormalScale.y*=-1)),this.cache.add(l,u),this.associations.set(u,this.associations.get(n))),n=u}e.material=n}getMaterialType(){return zo}loadMaterial(e){const t=this,n=this.json,r=this.extensions,o=n.materials[e];let a;const l={},u=o.extensions||{},h=[];if(u[St.KHR_MATERIALS_UNLIT]){const p=r[St.KHR_MATERIALS_UNLIT];a=p.getMaterialType(),h.push(p.extendParams(l,o,t))}else{const p=o.pbrMetallicRoughness||{};if(l.color=new Oe(1,1,1),l.opacity=1,Array.isArray(p.baseColorFactor)){const m=p.baseColorFactor;l.color.setRGB(m[0],m[1],m[2],Tn),l.opacity=m[3]}p.baseColorTexture!==void 0&&h.push(t.assignTexture(l,"map",p.baseColorTexture,on)),l.metalness=p.metallicFactor!==void 0?p.metallicFactor:1,l.roughness=p.roughnessFactor!==void 0?p.roughnessFactor:1,p.metallicRoughnessTexture!==void 0&&(h.push(t.assignTexture(l,"metalnessMap",p.metallicRoughnessTexture)),h.push(t.assignTexture(l,"roughnessMap",p.metallicRoughnessTexture))),a=this._invokeOne(function(m){return m.getMaterialType&&m.getMaterialType(e)}),h.push(Promise.all(this._invokeAll(function(m){return m.extendMaterialParams&&m.extendMaterialParams(e,l)})))}o.doubleSided===!0&&(l.side=si);const d=o.alphaMode||Yh.OPAQUE;if(d===Yh.BLEND?(l.transparent=!0,l.depthWrite=!1):(l.transparent=!1,d===Yh.MASK&&(l.alphaTest=o.alphaCutoff!==void 0?o.alphaCutoff:.5)),o.normalTexture!==void 0&&a!==Ji&&(h.push(t.assignTexture(l,"normalMap",o.normalTexture)),l.normalScale=new Pe(1,1),o.normalTexture.scale!==void 0)){const p=o.normalTexture.scale;l.normalScale.set(p,p)}if(o.occlusionTexture!==void 0&&a!==Ji&&(h.push(t.assignTexture(l,"aoMap",o.occlusionTexture)),o.occlusionTexture.strength!==void 0&&(l.aoMapIntensity=o.occlusionTexture.strength)),o.emissiveFactor!==void 0&&a!==Ji){const p=o.emissiveFactor;l.emissive=new Oe().setRGB(p[0],p[1],p[2],Tn)}return o.emissiveTexture!==void 0&&a!==Ji&&h.push(t.assignTexture(l,"emissiveMap",o.emissiveTexture,on)),Promise.all(h).then(function(){const p=new a(l);return o.name&&(p.name=o.name),Kr(p,o),t.associations.set(p,{materials:e}),o.extensions&&ys(r,p,o),p})}createUniqueName(e){const t=wt.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,n=this.extensions,r=this.primitiveCache;function o(l){return n[St.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(l,t).then(function(u){return A_(u,l,t)})}const a=[];for(let l=0,u=e.length;l<u;l++){const h=e[l],d=MI(h),p=r[d];if(p)a.push(p.promise);else{let m;h.extensions&&h.extensions[St.KHR_DRACO_MESH_COMPRESSION]?m=o(h):m=A_(new tn,h,t),r[d]={primitive:h,promise:m},a.push(m)}}return Promise.all(a)}loadMesh(e){const t=this,n=this.json,r=this.extensions,o=n.meshes[e],a=o.primitives,l=[];for(let u=0,h=a.length;u<h;u++){const d=a[u].material===void 0?vI(this.cache):this.getDependency("material",a[u].material);l.push(d)}return l.push(t.loadGeometries(a)),Promise.all(l).then(function(u){const h=u.slice(0,u.length-1),d=u[u.length-1],p=[];for(let g=0,y=d.length;g<y;g++){const S=d[g],_=a[g];let v;const R=h[g];if(_.mode===yi.TRIANGLES||_.mode===yi.TRIANGLE_STRIP||_.mode===yi.TRIANGLE_FAN||_.mode===void 0)v=o.isSkinnedMesh===!0?new DP(S,R):new Se(S,R),v.isSkinnedMesh===!0&&v.normalizeSkinWeights(),_.mode===yi.TRIANGLE_STRIP?v.geometry=E_(v.geometry,o0):_.mode===yi.TRIANGLE_FAN&&(v.geometry=E_(v.geometry,lf));else if(_.mode===yi.LINES)v=new Vf(S,R);else if(_.mode===yi.LINE_STRIP)v=new Si(S,R);else if(_.mode===yi.LINE_LOOP)v=new FP(S,R);else if(_.mode===yi.POINTS)v=new BP(S,R);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+_.mode);Object.keys(v.geometry.morphAttributes).length>0&&yI(v,o),v.name=t.createUniqueName(o.name||"mesh_"+e),Kr(v,o),_.extensions&&ys(r,v,_),t.assignFinalMaterial(v),p.push(v)}for(let g=0,y=p.length;g<y;g++)t.associations.set(p[g],{meshes:e,primitives:g});if(p.length===1)return o.extensions&&ys(r,p[0],o),p[0];const m=new Qi;o.extensions&&ys(r,m,o),t.associations.set(m,{meshes:e});for(let g=0,y=p.length;g<y;g++)m.add(p[g]);return m})}loadCamera(e){let t;const n=this.json.cameras[e],r=n[n.type];if(!r){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return n.type==="perspective"?t=new Un(ci.radToDeg(r.yfov),r.aspectRatio||1,r.znear||1,r.zfar||2e6):n.type==="orthographic"&&(t=new kl(-r.xmag,r.xmag,r.ymag,-r.ymag,r.znear,r.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),Kr(t,n),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],n=[];for(let r=0,o=t.joints.length;r<o;r++)n.push(this._loadNodeShallow(t.joints[r]));return t.inverseBindMatrices!==void 0?n.push(this.getDependency("accessor",t.inverseBindMatrices)):n.push(null),Promise.all(n).then(function(r){const o=r.pop(),a=r,l=[],u=[];for(let h=0,d=a.length;h<d;h++){const p=a[h];if(p){l.push(p);const m=new Qe;o!==null&&m.fromArray(o.array,h*16),u.push(m)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[h])}return new Gf(l,u)})}loadAnimation(e){const t=this.json,n=this,r=t.animations[e],o=r.name?r.name:"animation_"+e,a=[],l=[],u=[],h=[],d=[];for(let p=0,m=r.channels.length;p<m;p++){const g=r.channels[p],y=r.samplers[g.sampler],S=g.target,_=S.node,v=r.parameters!==void 0?r.parameters[y.input]:y.input,R=r.parameters!==void 0?r.parameters[y.output]:y.output;S.node!==void 0&&(a.push(this.getDependency("node",_)),l.push(this.getDependency("accessor",v)),u.push(this.getDependency("accessor",R)),h.push(y),d.push(S))}return Promise.all([Promise.all(a),Promise.all(l),Promise.all(u),Promise.all(h),Promise.all(d)]).then(function(p){const m=p[0],g=p[1],y=p[2],S=p[3],_=p[4],v=[];for(let R=0,b=m.length;R<b;R++){const A=m[R],B=g[R],N=y[R],D=S[R],C=_[R];if(A===void 0)continue;A.updateMatrix&&A.updateMatrix();const E=n._createAnimationTracks(A,B,N,D,C);if(E)for(let M=0;M<E.length;M++)v.push(E[M])}return new qP(o,void 0,v)})}createNodeMesh(e){const t=this.json,n=this,r=t.nodes[e];return r.mesh===void 0?null:n.getDependency("mesh",r.mesh).then(function(o){const a=n._getNodeRef(n.meshCache,r.mesh,o);return r.weights!==void 0&&a.traverse(function(l){if(l.isMesh)for(let u=0,h=r.weights.length;u<h;u++)l.morphTargetInfluences[u]=r.weights[u]}),a})}loadNode(e){const t=this.json,n=this,r=t.nodes[e],o=n._loadNodeShallow(e),a=[],l=r.children||[];for(let h=0,d=l.length;h<d;h++)a.push(n.getDependency("node",l[h]));const u=r.skin===void 0?Promise.resolve(null):n.getDependency("skin",r.skin);return Promise.all([o,Promise.all(a),u]).then(function(h){const d=h[0],p=h[1],m=h[2];m!==null&&d.traverse(function(g){g.isSkinnedMesh&&g.bind(m,EI)});for(let g=0,y=p.length;g<y;g++)d.add(p[g]);return d})}_loadNodeShallow(e){const t=this.json,n=this.extensions,r=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const o=t.nodes[e],a=o.name?r.createUniqueName(o.name):"",l=[],u=r._invokeOne(function(h){return h.createNodeMesh&&h.createNodeMesh(e)});return u&&l.push(u),o.camera!==void 0&&l.push(r.getDependency("camera",o.camera).then(function(h){return r._getNodeRef(r.cameraCache,o.camera,h)})),r._invokeAll(function(h){return h.createNodeAttachment&&h.createNodeAttachment(e)}).forEach(function(h){l.push(h)}),this.nodeCache[e]=Promise.all(l).then(function(h){let d;if(o.isBone===!0?d=new P0:h.length>1?d=new Qi:h.length===1?d=h[0]:d=new gt,d!==h[0])for(let p=0,m=h.length;p<m;p++)d.add(h[p]);if(o.name&&(d.userData.name=o.name,d.name=a),Kr(d,o),o.extensions&&ys(n,d,o),o.matrix!==void 0){const p=new Qe;p.fromArray(o.matrix),d.applyMatrix4(p)}else o.translation!==void 0&&d.position.fromArray(o.translation),o.rotation!==void 0&&d.quaternion.fromArray(o.rotation),o.scale!==void 0&&d.scale.fromArray(o.scale);return r.associations.has(d)||r.associations.set(d,{}),r.associations.get(d).nodes=e,d}),this.nodeCache[e]}loadScene(e){const t=this.extensions,n=this.json.scenes[e],r=this,o=new Qi;n.name&&(o.name=r.createUniqueName(n.name)),Kr(o,n),n.extensions&&ys(t,o,n);const a=n.nodes||[],l=[];for(let u=0,h=a.length;u<h;u++)l.push(r.getDependency("node",a[u]));return Promise.all(l).then(function(u){for(let d=0,p=u.length;d<p;d++)o.add(u[d]);const h=d=>{const p=new Map;for(const[m,g]of r.associations)(m instanceof Ti||m instanceof cn)&&p.set(m,g);return d.traverse(m=>{const g=r.associations.get(m);g!=null&&p.set(m,g)}),p};return r.associations=h(o),o})}_createAnimationTracks(e,t,n,r,o){const a=[],l=e.name?e.name:e.uuid,u=[];jr[o.path]===jr.weights?e.traverse(function(m){m.morphTargetInfluences&&u.push(m.name?m.name:m.uuid)}):u.push(l);let h;switch(jr[o.path]){case jr.weights:h=Uo;break;case jr.rotation:h=Cs;break;case jr.position:case jr.scale:h=No;break;default:switch(n.itemSize){case 1:h=Uo;break;case 2:case 3:default:h=No;break}break}const d=r.interpolation!==void 0?_I[r.interpolation]:As,p=this._getArrayFromAccessor(n);for(let m=0,g=u.length;m<g;m++){const y=new h(u[m]+"."+jr[o.path],t.array,p,d);r.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(y),a.push(y)}return a}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const n=xf(t.constructor),r=new Float32Array(t.length);for(let o=0,a=t.length;o<a;o++)r[o]=t[o]*n;t=r}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(n){const r=this instanceof Cs?gI:G0;return new r(this.times,this.values,this.getValueSize()/3,n)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function bI(i,e,t){const n=e.attributes,r=new zi;if(n.POSITION!==void 0){const l=t.json.accessors[n.POSITION],u=l.min,h=l.max;if(u!==void 0&&h!==void 0){if(r.set(new F(u[0],u[1],u[2]),new F(h[0],h[1],h[2])),l.normalized){const d=xf(wo[l.componentType]);r.min.multiplyScalar(d),r.max.multiplyScalar(d)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const o=e.targets;if(o!==void 0){const l=new F,u=new F;for(let h=0,d=o.length;h<d;h++){const p=o[h];if(p.POSITION!==void 0){const m=t.json.accessors[p.POSITION],g=m.min,y=m.max;if(g!==void 0&&y!==void 0){if(u.setX(Math.max(Math.abs(g[0]),Math.abs(y[0]))),u.setY(Math.max(Math.abs(g[1]),Math.abs(y[1]))),u.setZ(Math.max(Math.abs(g[2]),Math.abs(y[2]))),m.normalized){const S=xf(wo[m.componentType]);u.multiplyScalar(S)}l.max(u)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}r.expandByVector(l)}i.boundingBox=r;const a=new rr;r.getCenter(a.center),a.radius=r.min.distanceTo(r.max)/2,i.boundingSphere=a}function A_(i,e,t){const n=e.attributes,r=[];function o(a,l){return t.getDependency("accessor",a).then(function(u){i.setAttribute(l,u)})}for(const a in n){const l=vf[a]||a.toLowerCase();l in i.attributes||r.push(o(n[a],l))}if(e.indices!==void 0&&!i.index){const a=t.getDependency("accessor",e.indices).then(function(l){i.setIndex(l)});r.push(a)}return Lt.workingColorSpace!==Tn&&"COLOR_0"in n&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${Lt.workingColorSpace}" not supported.`),Kr(i,e),bI(i,e,t),Promise.all(r).then(function(){return e.targets!==void 0?xI(i,e.targets,t):i})}/*!
3824
3824
  fflate - fast JavaScript compression/decompression
3825
3825
  <https://101arrowz.github.io/fflate>
3826
3826
  Licensed under MIT. https://github.com/101arrowz/fflate/blob/master/LICENSE
3827
3827
  version 0.8.2
3828
- */var en=Uint8Array,oi=Uint16Array,Qf=Int32Array,Gl=new en([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Vl=new en([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),xf=new en([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),V0=function(i,e){for(var t=new oi(31),n=0;n<31;++n)t[n]=e+=1<<i[n-1];for(var r=new Qf(t[30]),n=1;n<30;++n)for(var o=t[n];o<t[n+1];++o)r[o]=o-t[n]<<5|n;return{b:t,r}},W0=V0(Gl,2),X0=W0.b,yf=W0.r;X0[28]=258,yf[258]=28;var Y0=V0(Vl,0),wI=Y0.b,R_=Y0.r,Mf=new oi(32768);for(var Xt=0;Xt<32768;++Xt){var qr=(Xt&43690)>>1|(Xt&21845)<<1;qr=(qr&52428)>>2|(qr&13107)<<2,qr=(qr&61680)>>4|(qr&3855)<<4,Mf[Xt]=((qr&65280)>>8|(qr&255)<<8)>>1}var er=function(i,e,t){for(var n=i.length,r=0,o=new oi(e);r<n;++r)i[r]&&++o[i[r]-1];var a=new oi(e);for(r=1;r<e;++r)a[r]=a[r-1]+o[r-1]<<1;var l;if(t){l=new oi(1<<e);var u=15-e;for(r=0;r<n;++r)if(i[r])for(var h=r<<4|i[r],d=e-i[r],p=a[i[r]-1]++<<d,m=p|(1<<d)-1;p<=m;++p)l[Mf[p]>>u]=h}else for(l=new oi(n),r=0;r<n;++r)i[r]&&(l[r]=Mf[a[i[r]-1]++]>>15-i[r]);return l},ts=new en(288);for(var Xt=0;Xt<144;++Xt)ts[Xt]=8;for(var Xt=144;Xt<256;++Xt)ts[Xt]=9;for(var Xt=256;Xt<280;++Xt)ts[Xt]=7;for(var Xt=280;Xt<288;++Xt)ts[Xt]=8;var Ha=new en(32);for(var Xt=0;Xt<32;++Xt)Ha[Xt]=5;var AI=er(ts,9,0),RI=er(ts,9,1),CI=er(Ha,5,0),PI=er(Ha,5,1),jh=function(i){for(var e=i[0],t=1;t<i.length;++t)i[t]>e&&(e=i[t]);return e},Di=function(i,e,t){var n=e/8|0;return(i[n]|i[n+1]<<8)>>(e&7)&t},qh=function(i,e){var t=e/8|0;return(i[t]|i[t+1]<<8|i[t+2]<<16)>>(e&7)},ed=function(i){return(i+7)/8|0},Xa=function(i,e,t){return(e==null||e<0)&&(e=0),(t==null||t>i.length)&&(t=i.length),new en(i.subarray(e,t))},LI=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],Wn=function(i,e,t){var n=new Error(e||LI[i]);if(n.code=i,Error.captureStackTrace&&Error.captureStackTrace(n,Wn),!t)throw n;return n},II=function(i,e,t,n){var r=i.length,o=n?n.length:0;if(!r||e.f&&!e.l)return t||new en(0);var a=!t,l=a||e.i!=2,u=e.i;a&&(t=new en(r*3));var h=function(q){var $e=t.length;if(q>$e){var Fe=new en(Math.max($e*2,q));Fe.set(t),t=Fe}},d=e.f||0,p=e.p||0,m=e.b||0,g=e.l,y=e.d,S=e.m,_=e.n,v=r*8;do{if(!g){d=Di(i,p,1);var R=Di(i,p+1,3);if(p+=3,R)if(R==1)g=RI,y=PI,S=9,_=5;else if(R==2){var N=Di(i,p,31)+257,D=Di(i,p+10,15)+4,C=N+Di(i,p+5,31)+1;p+=14;for(var E=new en(C),M=new en(19),O=0;O<D;++O)M[xf[O]]=Di(i,p+O*3,7);p+=D*3;for(var H=jh(M),G=(1<<H)-1,Y=er(M,H,1),O=0;O<C;){var $=Y[Di(i,p,G)];p+=$&15;var b=$>>4;if(b<16)E[O++]=b;else{var re=0,se=0;for(b==16?(se=3+Di(i,p,3),p+=2,re=E[O-1]):b==17?(se=3+Di(i,p,7),p+=3):b==18&&(se=11+Di(i,p,127),p+=7);se--;)E[O++]=re}}var K=E.subarray(0,N),ae=E.subarray(N);S=jh(K),_=jh(ae),g=er(K,S,1),y=er(ae,_,1)}else Wn(1);else{var b=ed(p)+4,A=i[b-4]|i[b-3]<<8,B=b+A;if(B>r){u&&Wn(0);break}l&&h(m+A),t.set(i.subarray(b,B),m),e.b=m+=A,e.p=p=B*8,e.f=d;continue}if(p>v){u&&Wn(0);break}}l&&h(m+131072);for(var pe=(1<<S)-1,ve=(1<<_)-1,ke=p;;ke=p){var re=g[qh(i,p)&pe],Ze=re>>4;if(p+=re&15,p>v){u&&Wn(0);break}if(re||Wn(2),Ze<256)t[m++]=Ze;else if(Ze==256){ke=p,g=null;break}else{var te=Ze-254;if(Ze>264){var O=Ze-257,fe=Gl[O];te=Di(i,p,(1<<fe)-1)+X0[O],p+=fe}var Ee=y[qh(i,p)&ve],Me=Ee>>4;Ee||Wn(3),p+=Ee&15;var ae=wI[Me];if(Me>3){var fe=Vl[Me];ae+=qh(i,p)&(1<<fe)-1,p+=fe}if(p>v){u&&Wn(0);break}l&&h(m+131072);var ze=m+te;if(m<ae){var Ve=o-ae,it=Math.min(ae,ze);for(Ve+m<0&&Wn(3);m<it;++m)t[m]=n[Ve+m]}for(;m<ze;++m)t[m]=t[m-ae]}}e.l=g,e.p=ke,e.b=m,e.f=d,g&&(d=1,e.m=S,e.d=y,e.n=_)}while(!d);return m!=t.length&&a?Xa(t,0,m):t.subarray(0,m)},Er=function(i,e,t){t<<=e&7;var n=e/8|0;i[n]|=t,i[n+1]|=t>>8},Sa=function(i,e,t){t<<=e&7;var n=e/8|0;i[n]|=t,i[n+1]|=t>>8,i[n+2]|=t>>16},$h=function(i,e){for(var t=[],n=0;n<i.length;++n)i[n]&&t.push({s:n,f:i[n]});var r=t.length,o=t.slice();if(!r)return{t:q0,l:0};if(r==1){var a=new en(t[0].s+1);return a[t[0].s]=1,{t:a,l:1}}t.sort(function(B,N){return B.f-N.f}),t.push({s:-1,f:25001});var l=t[0],u=t[1],h=0,d=1,p=2;for(t[0]={s:-1,f:l.f+u.f,l,r:u};d!=r-1;)l=t[t[h].f<t[p].f?h++:p++],u=t[h!=d&&t[h].f<t[p].f?h++:p++],t[d++]={s:-1,f:l.f+u.f,l,r:u};for(var m=o[0].s,n=1;n<r;++n)o[n].s>m&&(m=o[n].s);var g=new oi(m+1),y=Sf(t[d-1],g,0);if(y>e){var n=0,S=0,_=y-e,v=1<<_;for(o.sort(function(N,D){return g[D.s]-g[N.s]||N.f-D.f});n<r;++n){var R=o[n].s;if(g[R]>e)S+=v-(1<<y-g[R]),g[R]=e;else break}for(S>>=_;S>0;){var b=o[n].s;g[b]<e?S-=1<<e-g[b]++-1:++n}for(;n>=0&&S;--n){var A=o[n].s;g[A]==e&&(--g[A],++S)}y=e}return{t:new en(g),l:y}},Sf=function(i,e,t){return i.s==-1?Math.max(Sf(i.l,e,t+1),Sf(i.r,e,t+1)):e[i.s]=t},C_=function(i){for(var e=i.length;e&&!i[--e];);for(var t=new oi(++e),n=0,r=i[0],o=1,a=function(u){t[n++]=u},l=1;l<=e;++l)if(i[l]==r&&l!=e)++o;else{if(!r&&o>2){for(;o>138;o-=138)a(32754);o>2&&(a(o>10?o-11<<5|28690:o-3<<5|12305),o=0)}else if(o>3){for(a(r),--o;o>6;o-=6)a(8304);o>2&&(a(o-3<<5|8208),o=0)}for(;o--;)a(r);o=1,r=i[l]}return{c:t.subarray(0,n),n:e}},Ea=function(i,e){for(var t=0,n=0;n<e.length;++n)t+=i[n]*e[n];return t},j0=function(i,e,t){var n=t.length,r=ed(e+2);i[r]=n&255,i[r+1]=n>>8,i[r+2]=i[r]^255,i[r+3]=i[r+1]^255;for(var o=0;o<n;++o)i[r+o+4]=t[o];return(r+4+n)*8},P_=function(i,e,t,n,r,o,a,l,u,h,d){Er(e,d++,t),++r[256];for(var p=$h(r,15),m=p.t,g=p.l,y=$h(o,15),S=y.t,_=y.l,v=C_(m),R=v.c,b=v.n,A=C_(S),B=A.c,N=A.n,D=new oi(19),C=0;C<R.length;++C)++D[R[C]&31];for(var C=0;C<B.length;++C)++D[B[C]&31];for(var E=$h(D,7),M=E.t,O=E.l,H=19;H>4&&!M[xf[H-1]];--H);var G=h+5<<3,Y=Ea(r,ts)+Ea(o,Ha)+a,$=Ea(r,m)+Ea(o,S)+a+14+3*H+Ea(D,M)+2*D[16]+3*D[17]+7*D[18];if(u>=0&&G<=Y&&G<=$)return j0(e,d,i.subarray(u,u+h));var re,se,K,ae;if(Er(e,d,1+($<Y)),d+=2,$<Y){re=er(m,g,0),se=m,K=er(S,_,0),ae=S;var pe=er(M,O,0);Er(e,d,b-257),Er(e,d+5,N-1),Er(e,d+10,H-4),d+=14;for(var C=0;C<H;++C)Er(e,d+3*C,M[xf[C]]);d+=3*H;for(var ve=[R,B],ke=0;ke<2;++ke)for(var Ze=ve[ke],C=0;C<Ze.length;++C){var te=Ze[C]&31;Er(e,d,pe[te]),d+=M[te],te>15&&(Er(e,d,Ze[C]>>5&127),d+=Ze[C]>>12)}}else re=AI,se=ts,K=CI,ae=Ha;for(var C=0;C<l;++C){var fe=n[C];if(fe>255){var te=fe>>18&31;Sa(e,d,re[te+257]),d+=se[te+257],te>7&&(Er(e,d,fe>>23&31),d+=Gl[te]);var Ee=fe&31;Sa(e,d,K[Ee]),d+=ae[Ee],Ee>3&&(Sa(e,d,fe>>5&8191),d+=Vl[Ee])}else Sa(e,d,re[fe]),d+=se[fe]}return Sa(e,d,re[256]),d+se[256]},DI=new Qf([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),q0=new en(0),UI=function(i,e,t,n,r,o){var a=o.z||i.length,l=new en(n+a+5*(1+Math.ceil(a/7e3))+r),u=l.subarray(n,l.length-r),h=o.l,d=(o.r||0)&7;if(e){d&&(u[0]=o.r>>3);for(var p=DI[e-1],m=p>>13,g=p&8191,y=(1<<t)-1,S=o.p||new oi(32768),_=o.h||new oi(y+1),v=Math.ceil(t/3),R=2*v,b=function(mt){return(i[mt]^i[mt+1]<<v^i[mt+2]<<R)&y},A=new Qf(25e3),B=new oi(288),N=new oi(32),D=0,C=0,E=o.i||0,M=0,O=o.w||0,H=0;E+2<a;++E){var G=b(E),Y=E&32767,$=_[G];if(S[Y]=$,_[G]=Y,O<=E){var re=a-E;if((D>7e3||M>24576)&&(re>423||!h)){d=P_(i,u,0,A,B,N,C,M,H,E-H,d),M=D=C=0,H=E;for(var se=0;se<286;++se)B[se]=0;for(var se=0;se<30;++se)N[se]=0}var K=2,ae=0,pe=g,ve=Y-$&32767;if(re>2&&G==b(E-ve))for(var ke=Math.min(m,re)-1,Ze=Math.min(32767,E),te=Math.min(258,re);ve<=Ze&&--pe&&Y!=$;){if(i[E+K]==i[E+K-ve]){for(var fe=0;fe<te&&i[E+fe]==i[E+fe-ve];++fe);if(fe>K){if(K=fe,ae=ve,fe>ke)break;for(var Ee=Math.min(ve,fe-2),Me=0,se=0;se<Ee;++se){var ze=E-ve+se&32767,Ve=S[ze],it=ze-Ve&32767;it>Me&&(Me=it,$=ze)}}}Y=$,$=S[Y],ve+=Y-$&32767}if(ae){A[M++]=268435456|yf[K]<<18|R_[ae];var q=yf[K]&31,$e=R_[ae]&31;C+=Gl[q]+Vl[$e],++B[257+q],++N[$e],O=E+K,++D}else A[M++]=i[E],++B[i[E]]}}for(E=Math.max(E,O);E<a;++E)A[M++]=i[E],++B[i[E]];d=P_(i,u,h,A,B,N,C,M,H,E-H,d),h||(o.r=d&7|u[d/8|0]<<3,d-=7,o.h=_,o.p=S,o.i=E,o.w=O)}else{for(var E=o.w||0;E<a+h;E+=65535){var Fe=E+65535;Fe>=a&&(u[d/8|0]=h,Fe=a),d=j0(u,d+1,i.subarray(E,Fe))}o.i=a}return Xa(l,0,n+ed(d)+r)},NI=function(){for(var i=new Int32Array(256),e=0;e<256;++e){for(var t=e,n=9;--n;)t=(t&1&&-306674912)^t>>>1;i[e]=t}return i}(),OI=function(){var i=-1;return{p:function(e){for(var t=i,n=0;n<e.length;++n)t=NI[t&255^e[n]]^t>>>8;i=t},d:function(){return~i}}},FI=function(i,e,t,n,r){if(!r&&(r={l:1},e.dictionary)){var o=e.dictionary.subarray(-32768),a=new en(o.length+i.length);a.set(o),a.set(i,o.length),i=a,r.w=o.length}return UI(i,e.level==null?6:e.level,e.mem==null?r.l?Math.ceil(Math.max(8,Math.min(13,Math.log(i.length)))*1.5):20:12+e.mem,t,n,r)},$0=function(i,e){var t={};for(var n in i)t[n]=i[n];for(var n in e)t[n]=e[n];return t},qi=function(i,e){return i[e]|i[e+1]<<8},Ui=function(i,e){return(i[e]|i[e+1]<<8|i[e+2]<<16|i[e+3]<<24)>>>0},Kh=function(i,e){return Ui(i,e)+Ui(i,e+4)*4294967296},Mn=function(i,e,t){for(;t;++e)i[e]=t,t>>>=8};function BI(i,e){return FI(i,e||{},0,0)}function zI(i,e){return II(i,{i:2},e&&e.out,e&&e.dictionary)}var K0=function(i,e,t,n){for(var r in i){var o=i[r],a=e+r,l=n;Array.isArray(o)&&(l=$0(n,o[1]),o=o[0]),o instanceof en?t[a]=[o,l]:(t[a+="/"]=[new en(0),l],K0(o,a,t,n))}},L_=typeof TextEncoder<"u"&&new TextEncoder,Ef=typeof TextDecoder<"u"&&new TextDecoder,kI=0;try{Ef.decode(q0,{stream:!0}),kI=1}catch{}var HI=function(i){for(var e="",t=0;;){var n=i[t++],r=(n>127)+(n>223)+(n>239);if(t+r>i.length)return{s:e,r:Xa(i,t-1)};r?r==3?(n=((n&15)<<18|(i[t++]&63)<<12|(i[t++]&63)<<6|i[t++]&63)-65536,e+=String.fromCharCode(55296|n>>10,56320|n&1023)):r&1?e+=String.fromCharCode((n&31)<<6|i[t++]&63):e+=String.fromCharCode((n&15)<<12|(i[t++]&63)<<6|i[t++]&63):e+=String.fromCharCode(n)}};function Dl(i,e){var t;if(L_)return L_.encode(i);for(var n=i.length,r=new en(i.length+(i.length>>1)),o=0,a=function(h){r[o++]=h},t=0;t<n;++t){if(o+5>r.length){var l=new en(o+8+(n-t<<1));l.set(r),r=l}var u=i.charCodeAt(t);u<128||e?a(u):u<2048?(a(192|u>>6),a(128|u&63)):u>55295&&u<57344?(u=65536+(u&1047552)|i.charCodeAt(++t)&1023,a(240|u>>18),a(128|u>>12&63),a(128|u>>6&63),a(128|u&63)):(a(224|u>>12),a(128|u>>6&63),a(128|u&63))}return Xa(r,0,o)}function Tf(i,e){if(e){for(var t="",n=0;n<i.length;n+=16384)t+=String.fromCharCode.apply(null,i.subarray(n,n+16384));return t}else{if(Ef)return Ef.decode(i);var r=HI(i),o=r.s,t=r.r;return t.length&&Wn(8),o}}var GI=function(i,e){return e+30+qi(i,e+26)+qi(i,e+28)},VI=function(i,e,t){var n=qi(i,e+28),r=Tf(i.subarray(e+46,e+46+n),!(qi(i,e+8)&2048)),o=e+46+n,a=Ui(i,e+20),l=t&&a==4294967295?WI(i,o):[a,Ui(i,e+24),Ui(i,e+42)],u=l[0],h=l[1],d=l[2];return[qi(i,e+10),u,h,r,o+qi(i,e+30)+qi(i,e+32),d]},WI=function(i,e){for(;qi(i,e)!=1;e+=4+qi(i,e+2));return[Kh(i,e+12),Kh(i,e+4),Kh(i,e+20)]},bf=function(i){var e=0;if(i)for(var t in i){var n=i[t].length;n>65535&&Wn(9),e+=n+4}return e},I_=function(i,e,t,n,r,o,a,l){var u=n.length,h=t.extra,d=l&&l.length,p=bf(h);Mn(i,e,a!=null?33639248:67324752),e+=4,a!=null&&(i[e++]=20,i[e++]=t.os),i[e]=20,e+=2,i[e++]=t.flag<<1|(o<0&&8),i[e++]=r&&8,i[e++]=t.compression&255,i[e++]=t.compression>>8;var m=new Date(t.mtime==null?Date.now():t.mtime),g=m.getFullYear()-1980;if((g<0||g>119)&&Wn(10),Mn(i,e,g<<25|m.getMonth()+1<<21|m.getDate()<<16|m.getHours()<<11|m.getMinutes()<<5|m.getSeconds()>>1),e+=4,o!=-1&&(Mn(i,e,t.crc),Mn(i,e+4,o<0?-o-2:o),Mn(i,e+8,t.size)),Mn(i,e+12,u),Mn(i,e+14,p),e+=16,a!=null&&(Mn(i,e,d),Mn(i,e+6,t.attrs),Mn(i,e+10,a),e+=14),i.set(n,e),e+=u,p)for(var y in h){var S=h[y],_=S.length;Mn(i,e,+y),Mn(i,e+2,_),i.set(S,e+4),e+=4+_}return d&&(i.set(l,e),e+=d),e},XI=function(i,e,t,n,r){Mn(i,e,101010256),Mn(i,e+8,t),Mn(i,e+10,t),Mn(i,e+12,n),Mn(i,e+16,r)};function YI(i,e){e||(e={});var t={},n=[];K0(i,"",t,e);var r=0,o=0;for(var a in t){var l=t[a],u=l[0],h=l[1],d=h.level==0?0:8,p=Dl(a),m=p.length,g=h.comment,y=g&&Dl(g),S=y&&y.length,_=bf(h.extra);m>65535&&Wn(11);var v=d?BI(u,h):u,R=v.length,b=OI();b.p(u),n.push($0(h,{size:u.length,crc:b.d(),c:v,f:p,m:y,u:m!=a.length||y&&g.length!=S,o:r,compression:d})),r+=30+m+_+R,o+=76+2*(m+_)+(S||0)+R}for(var A=new en(o+22),B=r,N=o-r,D=0;D<n.length;++D){var p=n[D];I_(A,p.o,p,p.f,p.u,p.c.length);var C=30+p.f.length+bf(p.extra);A.set(p.c,p.o+C),I_(A,r,p,p.f,p.u,p.c.length,p.o,p.m),r+=16+C+(p.m?p.m.length:0)}return XI(A,r,n.length,N,B),A}function jI(i,e){for(var t={},n=i.length-22;Ui(i,n)!=101010256;--n)(!n||i.length-n>65558)&&Wn(13);var r=qi(i,n+8);if(!r)return{};var o=Ui(i,n+16),a=o==4294967295||r==65535;if(a){var l=Ui(i,n-12);a=Ui(i,l)==101075792,a&&(r=Ui(i,l+32),o=Ui(i,l+48))}for(var u=0;u<r;++u){var h=VI(i,o,a),d=h[0],p=h[1],m=h[2],g=h[3],y=h[4],S=h[5],_=GI(i,S);o=y,d?d==8?t[g]=zI(i.subarray(_,_+p),{out:new en(m)}):Wn(14,"unknown compression type "+d):t[g]=Xa(i,_,_+p)}return t}class qI{parse(e){const t={},n=e.split(`
3829
- `);let r=null,o=t;const a=[t];for(const l of n)if(l.includes("=")){const u=l.split("="),h=u[0].trim(),d=u[1].trim();if(d.endsWith("{")){const p={};a.push(p),o[h]=p,o=p}else o[h]=d}else if(l.endsWith("{")){const u=o[r]||{};a.push(u),o[r]=u,o=u}else if(l.endsWith("}")){if(a.pop(),a.length===0)continue;o=a[a.length-1]}else if(l.endsWith("(")){const u={};a.push(u),r=l.split("(")[0].trim()||r,o[r]=u,o=u}else l.endsWith(")")?(a.pop(),o=a[a.length-1]):r=l.trim();return t}}class $I extends Ls{constructor(e){super(e)}load(e,t,n,r){const o=this,a=new Ll(o.manager);a.setPath(o.path),a.setResponseType("arraybuffer"),a.setRequestHeader(o.requestHeader),a.setWithCredentials(o.withCredentials),a.load(e,function(l){try{t(o.parse(l))}catch(u){r?r(u):console.error(u),o.manager.itemError(e)}},n,r)}parse(e){const t=new qI;function n(C){const E={};new Ll().setResponseType("arraybuffer");for(const O in C){if(O.endsWith("png")){const H=new Blob([C[O]],{type:{type:"image/png"}});E[O]=URL.createObjectURL(H)}if(O.endsWith("usd")||O.endsWith("usda")){if(r(C[O])){console.warn("THREE.USDZLoader: Crate files (.usdc or binary .usd) are not supported.");continue}const H=Tf(C[O]);E[O]=t.parse(H)}}return E}function r(C){const E=C.slice(0,7),M=new Uint8Array([80,88,82,45,85,83,68,67]);return E.every((O,H)=>O===M[H])}function o(C){if(C.length<1)return;const E=Object.keys(C)[0];let M=!1;if(E.endsWith("usda"))return C[E];if(E.endsWith("usdc"))M=!0;else if(E.endsWith("usd"))if(r(C[E]))M=!0;else return C[E];M&&console.warn("THREE.USDZLoader: Crate files (.usdc or binary .usd) are not supported.")}const a=jI(new Uint8Array(e)),l=n(a),u=o(a);if(u===void 0)return console.warn("THREE.USDZLoader: No usda file found."),new Qi;const h=Tf(u),d=t.parse(h);function p(C){if(C){if("prepend references"in C){const M=C["prepend references"].split("@"),O=M[1].replace(/^.\//,""),H=M[2].replace(/^<\//,"").replace(/>$/,"");return m(l[O],H)}return m(C)}}function m(C,E){if(C){if(E!==void 0){const M=`def Mesh "${E}"`;if(M in C)return C[M]}for(const M in C){const O=C[M];if(M.startsWith("def Mesh"))return"point3f[] points"in C&&(O["point3f[] points"]=C["point3f[] points"]),"texCoord2f[] primvars:st"in C&&(O["texCoord2f[] primvars:st"]=C["texCoord2f[] primvars:st"]),"int[] primvars:st:indices"in C&&(O["int[] primvars:st:indices"]=C["int[] primvars:st:indices"]),O;if(typeof O=="object"){const H=m(O);if(H)return H}}}}function g(C){if(!C)return;let E=new tn;if("int[] faceVertexIndices"in C){const M=JSON.parse(C["int[] faceVertexIndices"]);E.setIndex(M)}if("point3f[] points"in C){const M=JSON.parse(C["point3f[] points"].replace(/[()]*/g,"")),O=new Nt(new Float32Array(M),3);E.setAttribute("position",O)}if("normal3f[] normals"in C){const M=JSON.parse(C["normal3f[] normals"].replace(/[()]*/g,"")),O=new Nt(new Float32Array(M),3);E.setAttribute("normal",O)}else E.computeVertexNormals();if("float2[] primvars:st"in C&&(C["texCoord2f[] primvars:st"]=C["float2[] primvars:st"]),"texCoord2f[] primvars:st"in C){const M=JSON.parse(C["texCoord2f[] primvars:st"].replace(/[()]*/g,"")),O=new Nt(new Float32Array(M),2);if("int[] primvars:st:indices"in C){E=E.toNonIndexed();const H=JSON.parse(C["int[] primvars:st:indices"]);E.setAttribute("uv",y(O,H))}else E.setAttribute("uv",O)}return E}function y(C,E){const M=C.array,O=C.itemSize,H=new M.constructor(E.length*O);let G=0,Y=0;for(let $=0,re=E.length;$<re;$++){G=E[$]*O;for(let se=0;se<O;se++)H[Y++]=M[G++]}return new Nt(H,O)}function S(C){if(C){if("rel material:binding"in C){const O=C["rel material:binding"].replace(/^<\//,"").replace(/>$/,"").split("/");return _(d,` "${O[1]}"`)}return _(C)}}function _(C,E=""){for(const M in C){const O=C[M];if(M.startsWith("def Material"+E))return O;if(typeof O=="object"){const H=_(O,E);if(H)return H}}}function v(C,E){E["float inputs:rotation"]&&(C.rotation=parseFloat(E["float inputs:rotation"])),E["float2 inputs:scale"]&&(C.repeat=new Pe().fromArray(JSON.parse("["+E["float2 inputs:scale"].replace(/[()]*/g,"")+"]"))),E["float2 inputs:translation"]&&(C.offset=new Pe().fromArray(JSON.parse("["+E["float2 inputs:translation"].replace(/[()]*/g,"")+"]")))}function R(C){const E=new sr;if(C!==void 0){if('def Shader "PreviewSurface"'in C){const M=C['def Shader "PreviewSurface"'];if("color3f inputs:diffuseColor.connect"in M){const O=M["color3f inputs:diffuseColor.connect"],H=b(d,/(\w+).output/.exec(O)[1]);E.map=A(H),E.map.colorSpace=on,'def Shader "Transform2d_diffuse"'in C&&v(E.map,C['def Shader "Transform2d_diffuse"'])}else if("color3f inputs:diffuseColor"in M){const O=M["color3f inputs:diffuseColor"].replace(/[()]*/g,"");E.color.fromArray(JSON.parse("["+O+"]"))}if("color3f inputs:emissiveColor.connect"in M){const O=M["color3f inputs:emissiveColor.connect"],H=b(d,/(\w+).output/.exec(O)[1]);E.emissiveMap=A(H),E.emissiveMap.colorSpace=on,E.emissive.set(16777215),'def Shader "Transform2d_emissive"'in C&&v(E.emissiveMap,C['def Shader "Transform2d_emissive"'])}else if("color3f inputs:emissiveColor"in M){const O=M["color3f inputs:emissiveColor"].replace(/[()]*/g,"");E.emissive.fromArray(JSON.parse("["+O+"]"))}if("normal3f inputs:normal.connect"in M){const O=M["normal3f inputs:normal.connect"],H=b(d,/(\w+).output/.exec(O)[1]);E.normalMap=A(H),E.normalMap.colorSpace=Sn,'def Shader "Transform2d_normal"'in C&&v(E.normalMap,C['def Shader "Transform2d_normal"'])}if("float inputs:roughness.connect"in M){const O=M["float inputs:roughness.connect"],H=b(d,/(\w+).output/.exec(O)[1]);E.roughness=1,E.roughnessMap=A(H),E.roughnessMap.colorSpace=Sn,'def Shader "Transform2d_roughness"'in C&&v(E.roughnessMap,C['def Shader "Transform2d_roughness"'])}else"float inputs:roughness"in M&&(E.roughness=parseFloat(M["float inputs:roughness"]));if("float inputs:metallic.connect"in M){const O=M["float inputs:metallic.connect"],H=b(d,/(\w+).output/.exec(O)[1]);E.metalness=1,E.metalnessMap=A(H),E.metalnessMap.colorSpace=Sn,'def Shader "Transform2d_metallic"'in C&&v(E.metalnessMap,C['def Shader "Transform2d_metallic"'])}else"float inputs:metallic"in M&&(E.metalness=parseFloat(M["float inputs:metallic"]));if("float inputs:clearcoat.connect"in M){const O=M["float inputs:clearcoat.connect"],H=b(d,/(\w+).output/.exec(O)[1]);E.clearcoat=1,E.clearcoatMap=A(H),E.clearcoatMap.colorSpace=Sn,'def Shader "Transform2d_clearcoat"'in C&&v(E.clearcoatMap,C['def Shader "Transform2d_clearcoat"'])}else"float inputs:clearcoat"in M&&(E.clearcoat=parseFloat(M["float inputs:clearcoat"]));if("float inputs:clearcoatRoughness.connect"in M){const O=M["float inputs:clearcoatRoughness.connect"],H=b(d,/(\w+).output/.exec(O)[1]);E.clearcoatRoughness=1,E.clearcoatRoughnessMap=A(H),E.clearcoatRoughnessMap.colorSpace=Sn,'def Shader "Transform2d_clearcoatRoughness"'in C&&v(E.clearcoatRoughnessMap,C['def Shader "Transform2d_clearcoatRoughness"'])}else"float inputs:clearcoatRoughness"in M&&(E.clearcoatRoughness=parseFloat(M["float inputs:clearcoatRoughness"]));if("float inputs:ior"in M&&(E.ior=parseFloat(M["float inputs:ior"])),"float inputs:occlusion.connect"in M){const O=M["float inputs:occlusion.connect"],H=b(d,/(\w+).output/.exec(O)[1]);E.aoMap=A(H),E.aoMap.colorSpace=Sn,'def Shader "Transform2d_occlusion"'in C&&v(E.aoMap,C['def Shader "Transform2d_occlusion"'])}}if('def Shader "diffuseColor_texture"'in C){const M=C['def Shader "diffuseColor_texture"'];E.map=A(M),E.map.colorSpace=on}if('def Shader "normal_texture"'in C){const M=C['def Shader "normal_texture"'];E.normalMap=A(M),E.normalMap.colorSpace=Sn}}return E}function b(C,E){for(const M in C){const O=C[M];if(M.startsWith(`def Shader "${E}"`))return O;if(typeof O=="object"){const H=b(O,E);if(H)return H}}}function A(C){if("asset inputs:file"in C){const E=C["asset inputs:file"].replace(/@*/g,""),O=new N0().load(l[E]),H={'"clamp"':$i,'"mirror"':Co,'"repeat"':es};return"token inputs:wrapS"in C&&(O.wrapS=H[C["token inputs:wrapS"]]),"token inputs:wrapT"in C&&(O.wrapT=H[C["token inputs:wrapT"]]),O}return null}function B(C){const E=g(p(C)),M=R(S(C)),O=E?new Se(E,M):new gt;if("matrix4d xformOp:transform"in C){const H=JSON.parse("["+C["matrix4d xformOp:transform"].replace(/[()]*/g,"")+"]");O.matrix.fromArray(H),O.matrix.decompose(O.position,O.quaternion,O.scale)}return O}function N(C,E){for(const M in C)if(M.startsWith("def Scope"))N(C[M],E);else if(M.startsWith("def Xform")){const O=B(C[M]);/def Xform "(\w+)"/.test(M)&&(O.name=/def Xform "(\w+)"/.exec(M)[1]),E.add(O),N(C[M],O)}}const D=new Qi;return N(d,D),D}}const KI={glb:{key:"glb",extension:".glb",options:{}},gltf:{key:"gltf",extension:".gltf",options:{}},usdz:{key:"usdz",extension:".usdz",options:{}}},td=Object.values(KI).map(i=>i.extension);class Z0{_gltfLoader;_usdzLoader;constructor(){this._gltfLoader=new YL,this._usdzLoader=new $I}async load(e){const t=this._getFileTypeFromUri(e);return this._load(e,t)}_getFileTypeFromUri(e){const t=e.split(".").pop()?.toLowerCase();if(!t||!td.includes(t))throw new Error(`Unsupported file type: ${t}`);return t}async _load(e,t){switch(t){case"glb":case"gltf":return this._loadGltf(e);case"usdz":return this._loadUsdz(e)}}async _loadGltf(e){return(await this._gltfLoader.loadAsync(e)).scene}async _loadUsdz(e){return this._usdzLoader.loadAsync(e)}}class nd extends gt{isDIVERoot=!0;loader;constructor(){super(),this.name="Root",this.loader=new Z0}ComputeSceneBB(){const e=new zi;return this.traverse(t=>{"isObject3D"in t&&e.expandByObject(t)}),e}GetSceneObject(e){let t;return this.traverse(n=>{t||n.userData.id===e.id&&(t=n)}),t}AddSceneObject(e){switch(e.entityType){case"pov":break;case"light":{this.updateLight(e);break}case"model":{this.updateModel(e);break}case"primitive":{this.updatePrimitive(e);break}case"group":{this.updateGroup(e);break}default:console.warn(`DIVERoot.AddSceneObject: Unknown entity type: ${e.entityType}`)}}UpdateSceneObject(e){switch(e.entityType){case"pov":break;case"light":{this.updateLight(e);break}case"model":{this.updateModel(e);break}case"primitive":{this.updatePrimitive(e);break}case"group":{this.updateGroup(e);break}default:console.warn(`DIVERoot.UpdateSceneObject: Unknown entity type: ${e.entityType}`)}}DeleteSceneObject(e){switch(e.entityType){case"pov":break;case"light":{this.deleteLight(e);break}case"model":{this.deleteModel(e);break}case"primitive":{this.deletePrimitive(e);break}case"group":{this.deleteGroup(e);break}default:console.warn(`DIVERoot.DeleteSceneObject: Unknown entity type: ${e.entityType}`)}}PlaceOnFloor(e){switch(e.entityType){case"pov":case"light":break;case"model":case"primitive":{this.placeOnFloor(e);break}default:console.warn(`DIVERoot.PlaceOnFloor: Unknown entity type: ${e.entityType}`)}}updateLight(e){let t=this.GetSceneObject(e);if(!t){switch(e.type){case"scene":{t=new zL;break}case"ambient":{t=new SL;break}case"point":{t=new BL;break}default:{console.warn(`DIVERoot.updateLight: Unknown light type: ${e.type}`);return}}t.userData.id=e.id,this.add(t)}e.name!==void 0&&e.name!==null&&(t.name=e.name),e.position!==void 0&&e.position!==null&&t.position.set(e.position.x,e.position.y,e.position.z),e.intensity!==void 0&&e.intensity!==null&&t.SetIntensity(e.intensity),e.enabled!==void 0&&e.enabled!==null&&t.SetEnabled(e.enabled),e.color!==void 0&&e.color!==null&&t.SetColor(new Oe(e.color)),e.visible!==void 0&&e.visible!==null&&(t.visible=e.visible),e.parentId!==void 0&&this.setParent({...e,parentId:e.parentId})}updateModel(e){let t=this.GetSceneObject(e);t||(t=new VL,t.userData.id=e.id,t.userData.uri=e.uri,this.add(t)),e.uri!==void 0&&this.loader.load(e.uri).then(n=>{t.SetModel(n),On.get(e.id)?.PerformAction("MODEL_LOADED",{id:e.id})}),e.name!==void 0&&(t.name=e.name),e.position!==void 0&&t.SetPosition(e.position),e.rotation!==void 0&&t.SetRotation(e.rotation),e.scale!==void 0&&t.SetScale(e.scale),e.visible!==void 0&&t.SetVisibility(e.visible),e.material!==void 0&&t.SetMaterial(e.material),e.parentId!==void 0&&this.setParent({...e,parentId:e.parentId})}updatePrimitive(e){let t=this.GetSceneObject(e);t||(t=new WL,t.userData.id=e.id,this.add(t)),e.name!==void 0&&(t.name=e.name),e.geometry!==void 0&&t.SetGeometry(e.geometry),e.position!==void 0&&t.SetPosition(e.position),e.rotation!==void 0&&t.SetRotation(e.rotation),e.scale!==void 0&&t.SetScale(e.scale),e.visible!==void 0&&t.SetVisibility(e.visible),e.material!==void 0&&t.SetMaterial(e.material),e.parentId!==void 0&&this.setParent({...e,parentId:e.parentId})}updateGroup(e){let t=this.GetSceneObject(e);t||(t=new XL,t.userData.id=e.id,this.add(t)),e.name!==void 0&&(t.name=e.name),e.position!==void 0&&t.SetPosition(e.position),e.rotation!==void 0&&t.SetRotation(e.rotation),e.scale!==void 0&&t.SetScale(e.scale),e.visible!==void 0&&t.SetVisibility(e.visible),e.bbVisible!==void 0&&t.SetLinesVisibility(e.bbVisible),e.parentId!==void 0&&this.setParent({...e,parentId:e.parentId})}deleteLight(e){const t=this.GetSceneObject(e);if(!t){console.warn(`DIVERoot.deleteLight: Light with id ${e.id} not found`);return}this.detachTransformControls(t),t.parent.remove(t)}deleteModel(e){const t=this.GetSceneObject(e);if(!t){console.warn(`DIVERoot.deleteModel: Model with id ${e.id} not found`);return}this.detachTransformControls(t),t.parent.remove(t)}deletePrimitive(e){const t=this.GetSceneObject(e);if(!t){console.warn(`DIVERoot.deletePrimitive: Primitive with id ${e.id} not found`);return}this.detachTransformControls(t),t.parent.remove(t)}deleteGroup(e){const t=this.GetSceneObject(e);if(!t){console.warn(`DIVERoot.deleteGroup: Group with id ${e.id} not found`);return}this.detachTransformControls(t);for(let n=t.members.length-1;n>=0;n--)this.attach(t.members[n]);t.parent.remove(t)}placeOnFloor(e){const t=this.GetSceneObject(e);t&&t.PlaceOnFloor()}setParent(e){const t=this.GetSceneObject(e);if(t)if(e.parentId!==null){const n=this.GetSceneObject({id:e.parentId});if(!n)return;n.attach(t)}else this.attach(t)}detachTransformControls(e){this.findScene(e).children.find(t=>{"isTransformControls"in t&&t.detach()})}findScene(e){return e.parent!==null?this.findScene(e.parent):e}}const ZI="#888888",JI="#dddddd";class QI extends gt{constructor(){super(),this.name="Grid";const e=new xL(100,100,ZI,JI);e.material.depthTest=!1,e.layers.mask=F0,this.add(e)}SetVisibility(e){this.visible=e}}class e2 extends Se{isFloor=!0;constructor(){super(new ns(1e4,1e4),new zo({color:new Oe(150/255,150/255,150/255)})),this.name="Floor",this.layers.mask=li,this.receiveShadow=!0,this.rotateX(-Math.PI/2)}SetVisibility(e){this.visible=e}SetColor(e){this.material.color=new Oe(e)}}class t2{constructor(e,t,n,r,o){this.xrLight=e,this.renderer=t,this.lightProbe=n,this.xrWebGLBinding=null,this.estimationStartCallback=o,this.frameCallback=this.onXRFrame.bind(this);const a=t.xr.getSession();if(r&&"XRWebGLBinding"in window){const l=new v0(16);e.environment=l.texture;const u=t.getContext();switch(a.preferredReflectionFormat){case"srgba8":u.getExtension("EXT_sRGB");break;case"rgba16f":u.getExtension("OES_texture_half_float");break}this.xrWebGLBinding=new XRWebGLBinding(a,u),this.lightProbe.addEventListener("reflectionchange",()=>{this.updateReflection()})}a.requestAnimationFrame(this.frameCallback)}updateReflection(){const e=this.renderer.properties.get(this.xrLight.environment);if(e){const t=this.xrWebGLBinding.getReflectionCubeMap(this.lightProbe);t&&(e.__webglTexture=t,this.xrLight.environment.needsPMREMUpdate=!0)}}onXRFrame(e,t){if(!this.xrLight)return;t.session.requestAnimationFrame(this.frameCallback);const r=t.getLightEstimate(this.lightProbe);if(r){this.xrLight.lightProbe.sh.fromArray(r.sphericalHarmonicsCoefficients),this.xrLight.lightProbe.intensity=1;const o=Math.max(1,Math.max(r.primaryLightIntensity.x,Math.max(r.primaryLightIntensity.y,r.primaryLightIntensity.z)));this.xrLight.directionalLight.color.setRGB(r.primaryLightIntensity.x/o,r.primaryLightIntensity.y/o,r.primaryLightIntensity.z/o),this.xrLight.directionalLight.intensity=o,this.xrLight.directionalLight.position.copy(r.primaryLightDirection),this.estimationStartCallback&&(this.estimationStartCallback(),this.estimationStartCallback=null)}}dispose(){this.xrLight=null,this.renderer=null,this.lightProbe=null,this.xrWebGLBinding=null}}class n2 extends Qi{constructor(e,t=!0){super(),this.lightProbe=new cL,this.lightProbe.intensity=0,this.add(this.lightProbe),this.directionalLight=new Yf,this.directionalLight.intensity=0,this.add(this.directionalLight),this.environment=null;let n=null,r=!1;e.xr.addEventListener("sessionstart",()=>{const o=e.xr.getSession();"requestLightProbe"in o&&o.requestLightProbe({reflectionFormat:o.preferredReflectionFormat}).then(a=>{n=new t2(this,e,a,t,()=>{r=!0,this.dispatchEvent({type:"estimationstart"})})})}),e.xr.addEventListener("sessionend",()=>{n&&(n.dispose(),n=null),r&&this.dispatchEvent({type:"estimationend"})}),this.dispose=()=>{n&&(n.dispose(),n=null),this.remove(this.lightProbe),this.lightProbe=null,this.remove(this.directionalLight),this.directionalLight=null,this.environment=null}}}class i2 extends gt{_scene;_xrLight;_lightRoot;constructor(e){super(),this.name="XRLightRoot",this._scene=e,this._xrLight=null,this._lightRoot=new nd,this._lightRoot.UpdateSceneObject({id:"XRSceneLight",entityType:"light",name:"XRSceneLight",type:"scene",color:16777215,intensity:1,enabled:!0,visible:!0}),this.add(this._lightRoot)}InitLightEstimation(e){this._xrLight||(this._xrLight=new n2(e,!0),this._xrLight.layers.mask=li,this.add(this._xrLight)),this._xrLight.addEventListener("estimationstart",()=>{this.onEstimationStart()}),this._xrLight.addEventListener("estimationend",()=>{this.onEstimationEnd()})}DisposeLightEstimation(){this._xrLight&&(this._xrLight.removeEventListener("estimationstart",()=>{this.onEstimationStart()}),this._xrLight.removeEventListener("estimationend",()=>{this.onEstimationEnd()}))}onEstimationStart(){this._lightRoot.visible=!1,this._xrLight&&this._xrLight.environment&&(this._scene.environment=this._xrLight.environment)}onEstimationEnd(){this._lightRoot.visible=!0,this._scene.environment=null,this._xrLight}}class r2 extends gt{_xrLightRoot;_xrModelRoot;_xrHandNode;get XRModelRoot(){return this._xrModelRoot}get XRLightRoot(){return this._xrLightRoot}get XRHandNode(){return this._xrHandNode}_xrShadowPlane;constructor(e){super(),this.name="XRRoot",this._xrModelRoot=new nd,this._xrModelRoot.name="XRModelRoot",this.add(this._xrModelRoot),this._xrShadowPlane=new Se(new ns(100,100),new kP({opacity:1,transparent:!0})),this._xrModelRoot.add(this._xrShadowPlane),this._xrLightRoot=new i2(e),this._xrLightRoot.name="XRLightRoot",this.add(this._xrLightRoot),this._xrHandNode=new gt,this._xrHandNode.name="XRHandNode",this.add(this._xrHandNode)}InitLightEstimation(e){this._xrLightRoot.InitLightEstimation(e)}DisposeLightEstimation(){this._xrLightRoot.DisposeLightEstimation()}}class s2 extends Pl{_root;_floor;_grid;get Root(){return this._root}_xrRoot;get XRRoot(){return this._xrRoot}get Floor(){return this._floor}get Grid(){return this._grid}constructor(){super(),this.background=new Oe(16777215),this._root=new nd,this.add(this._root),this._floor=new e2,this.add(this._floor),this._grid=new QI,this.add(this._grid),this._xrRoot=new r2(this),this._xrRoot.visible=!1,this.add(this._xrRoot)}InitXR(e){this._root.visible=!1,this._xrRoot.visible=!0,this._xrRoot.InitLightEstimation(e)}DisposeXR(){this._root.visible=!0,this._xrRoot.visible=!1,this._xrRoot.DisposeLightEstimation()}SetBackground(e){this.background=new Oe(e)}ComputeSceneBB(){return this.Root.ComputeSceneBB()}GetSceneObject(e){return this.Root.GetSceneObject(e)}AddSceneObject(e){this.Root.AddSceneObject(e)}UpdateSceneObject(e){this.Root.UpdateSceneObject(e)}DeleteSceneObject(e){this.Root.DeleteSceneObject(e)}PlaceOnFloor(e){this.Root.PlaceOnFloor(e)}}const Ca={fov:70,near:.1,far:1e3};class Fa extends Un{static EDITOR_VIEW_LAYER_MASK=ML|Kf|F0|li;static LIVE_VIEW_LAYER_MASK=li;onSetCameraLayer=()=>{};constructor(e=Ca){super(e.fov||Ca.fov,1,e.near||Ca.near,e.far||Ca.far),this.layers.mask=Fa.EDITOR_VIEW_LAYER_MASK}OnResize(e,t){this.aspect=e/t,this.updateProjectionMatrix()}SetCameraLayer(e){this.layers.mask=e==="LIVE"?Fa.LIVE_VIEW_LAYER_MASK:Fa.EDITOR_VIEW_LAYER_MASK,this.onSetCameraLayer(this.layers.mask)}}const D_={type:"change"},Zh={type:"start"},U_={type:"end"},ml=new Oo,N_=new $r,o2=Math.cos(70*ci.DEG2RAD);class a2 extends Ps{constructor(e,t){super(),this.object=e,this.domElement=t,this.domElement.style.touchAction="none",this.enabled=!0,this.target=new F,this.cursor=new F,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:js.ROTATE,MIDDLE:js.DOLLY,RIGHT:js.PAN},this.touches={ONE:qs.ROTATE,TWO:qs.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this.getPolarAngle=function(){return l.phi},this.getAzimuthalAngle=function(){return l.theta},this.getDistance=function(){return this.object.position.distanceTo(this.target)},this.listenToKeyEvents=function(T){T.addEventListener("keydown",we),this._domElementKeyEvents=T},this.stopListenToKeyEvents=function(){this._domElementKeyEvents.removeEventListener("keydown",we),this._domElementKeyEvents=null},this.saveState=function(){n.target0.copy(n.target),n.position0.copy(n.object.position),n.zoom0=n.object.zoom},this.reset=function(){n.target.copy(n.target0),n.object.position.copy(n.position0),n.object.zoom=n.zoom0,n.object.updateProjectionMatrix(),n.dispatchEvent(D_),n.update(),o=r.NONE},this.update=function(){const T=new F,Z=new an().setFromUnitVectors(e.up,new F(0,1,0)),ce=Z.clone().invert(),ye=new F,Re=new an,vt=new F,dt=2*Math.PI;return function(ln=null){const Rt=n.object.position;T.copy(Rt).sub(n.target),T.applyQuaternion(Z),l.setFromVector3(T),n.autoRotate&&o===r.NONE&&H(M(ln)),n.enableDamping?(l.theta+=u.theta*n.dampingFactor,l.phi+=u.phi*n.dampingFactor):(l.theta+=u.theta,l.phi+=u.phi);let Zt=n.minAzimuthAngle,Jt=n.maxAzimuthAngle;isFinite(Zt)&&isFinite(Jt)&&(Zt<-Math.PI?Zt+=dt:Zt>Math.PI&&(Zt-=dt),Jt<-Math.PI?Jt+=dt:Jt>Math.PI&&(Jt-=dt),Zt<=Jt?l.theta=Math.max(Zt,Math.min(Jt,l.theta)):l.theta=l.theta>(Zt+Jt)/2?Math.max(Zt,l.theta):Math.min(Jt,l.theta)),l.phi=Math.max(n.minPolarAngle,Math.min(n.maxPolarAngle,l.phi)),l.makeSafe(),n.enableDamping===!0?n.target.addScaledVector(d,n.dampingFactor):n.target.add(d),n.target.sub(n.cursor),n.target.clampLength(n.minTargetRadius,n.maxTargetRadius),n.target.add(n.cursor);let Fn=!1;if(n.zoomToCursor&&N||n.object.isOrthographicCamera)l.radius=pe(l.radius);else{const bn=l.radius;l.radius=pe(l.radius*h),Fn=bn!=l.radius}if(T.setFromSpherical(l),T.applyQuaternion(ce),Rt.copy(n.target).add(T),n.object.lookAt(n.target),n.enableDamping===!0?(u.theta*=1-n.dampingFactor,u.phi*=1-n.dampingFactor,d.multiplyScalar(1-n.dampingFactor)):(u.set(0,0,0),d.set(0,0,0)),n.zoomToCursor&&N){let bn=null;if(n.object.isPerspectiveCamera){const ki=T.length();bn=pe(ki*h);const Hi=ki-bn;n.object.position.addScaledVector(A,Hi),n.object.updateMatrixWorld(),Fn=!!Hi}else if(n.object.isOrthographicCamera){const ki=new F(B.x,B.y,0);ki.unproject(n.object);const Hi=n.object.zoom;n.object.zoom=Math.max(n.minZoom,Math.min(n.maxZoom,n.object.zoom/h)),n.object.updateProjectionMatrix(),Fn=Hi!==n.object.zoom;const ar=new F(B.x,B.y,0);ar.unproject(n.object),n.object.position.sub(ar).add(ki),n.object.updateMatrixWorld(),bn=T.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),n.zoomToCursor=!1;bn!==null&&(this.screenSpacePanning?n.target.set(0,0,-1).transformDirection(n.object.matrix).multiplyScalar(bn).add(n.object.position):(ml.origin.copy(n.object.position),ml.direction.set(0,0,-1).transformDirection(n.object.matrix),Math.abs(n.object.up.dot(ml.direction))<o2?e.lookAt(n.target):(N_.setFromNormalAndCoplanarPoint(n.object.up,n.target),ml.intersectPlane(N_,n.target))))}else if(n.object.isOrthographicCamera){const bn=n.object.zoom;n.object.zoom=Math.max(n.minZoom,Math.min(n.maxZoom,n.object.zoom/h)),bn!==n.object.zoom&&(n.object.updateProjectionMatrix(),Fn=!0)}return h=1,N=!1,Fn||ye.distanceToSquared(n.object.position)>a||8*(1-Re.dot(n.object.quaternion))>a||vt.distanceToSquared(n.target)>a?(n.dispatchEvent(D_),ye.copy(n.object.position),Re.copy(n.object.quaternion),vt.copy(n.target),!0):!1}}(),this.dispose=function(){n.domElement.removeEventListener("contextmenu",Ie),n.domElement.removeEventListener("pointerdown",ie),n.domElement.removeEventListener("pointercancel",de),n.domElement.removeEventListener("wheel",_e),n.domElement.removeEventListener("pointermove",le),n.domElement.removeEventListener("pointerup",de),n.domElement.getRootNode().removeEventListener("keydown",Xe,{capture:!0}),n._domElementKeyEvents!==null&&(n._domElementKeyEvents.removeEventListener("keydown",we),n._domElementKeyEvents=null)};const n=this,r={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6};let o=r.NONE;const a=1e-6,l=new f_,u=new f_;let h=1;const d=new F,p=new Pe,m=new Pe,g=new Pe,y=new Pe,S=new Pe,_=new Pe,v=new Pe,R=new Pe,b=new Pe,A=new F,B=new Pe;let N=!1;const D=[],C={};let E=!1;function M(T){return T!==null?2*Math.PI/60*n.autoRotateSpeed*T:2*Math.PI/60/60*n.autoRotateSpeed}function O(T){const Z=Math.abs(T*.01);return Math.pow(.95,n.zoomSpeed*Z)}function H(T){u.theta-=T}function G(T){u.phi-=T}const Y=function(){const T=new F;return function(ce,ye){T.setFromMatrixColumn(ye,0),T.multiplyScalar(-ce),d.add(T)}}(),$=function(){const T=new F;return function(ce,ye){n.screenSpacePanning===!0?T.setFromMatrixColumn(ye,1):(T.setFromMatrixColumn(ye,0),T.crossVectors(n.object.up,T)),T.multiplyScalar(ce),d.add(T)}}(),re=function(){const T=new F;return function(ce,ye){const Re=n.domElement;if(n.object.isPerspectiveCamera){const vt=n.object.position;T.copy(vt).sub(n.target);let dt=T.length();dt*=Math.tan(n.object.fov/2*Math.PI/180),Y(2*ce*dt/Re.clientHeight,n.object.matrix),$(2*ye*dt/Re.clientHeight,n.object.matrix)}else n.object.isOrthographicCamera?(Y(ce*(n.object.right-n.object.left)/n.object.zoom/Re.clientWidth,n.object.matrix),$(ye*(n.object.top-n.object.bottom)/n.object.zoom/Re.clientHeight,n.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),n.enablePan=!1)}}();function se(T){n.object.isPerspectiveCamera||n.object.isOrthographicCamera?h/=T:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),n.enableZoom=!1)}function K(T){n.object.isPerspectiveCamera||n.object.isOrthographicCamera?h*=T:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),n.enableZoom=!1)}function ae(T,Z){if(!n.zoomToCursor)return;N=!0;const ce=n.domElement.getBoundingClientRect(),ye=T-ce.left,Re=Z-ce.top,vt=ce.width,dt=ce.height;B.x=ye/vt*2-1,B.y=-(Re/dt)*2+1,A.set(B.x,B.y,1).unproject(n.object).sub(n.object.position).normalize()}function pe(T){return Math.max(n.minDistance,Math.min(n.maxDistance,T))}function ve(T){p.set(T.clientX,T.clientY)}function ke(T){ae(T.clientX,T.clientX),v.set(T.clientX,T.clientY)}function Ze(T){y.set(T.clientX,T.clientY)}function te(T){m.set(T.clientX,T.clientY),g.subVectors(m,p).multiplyScalar(n.rotateSpeed);const Z=n.domElement;H(2*Math.PI*g.x/Z.clientHeight),G(2*Math.PI*g.y/Z.clientHeight),p.copy(m),n.update()}function fe(T){R.set(T.clientX,T.clientY),b.subVectors(R,v),b.y>0?se(O(b.y)):b.y<0&&K(O(b.y)),v.copy(R),n.update()}function Ee(T){S.set(T.clientX,T.clientY),_.subVectors(S,y).multiplyScalar(n.panSpeed),re(_.x,_.y),y.copy(S),n.update()}function Me(T){ae(T.clientX,T.clientY),T.deltaY<0?K(O(T.deltaY)):T.deltaY>0&&se(O(T.deltaY)),n.update()}function ze(T){let Z=!1;switch(T.code){case n.keys.UP:T.ctrlKey||T.metaKey||T.shiftKey?G(2*Math.PI*n.rotateSpeed/n.domElement.clientHeight):re(0,n.keyPanSpeed),Z=!0;break;case n.keys.BOTTOM:T.ctrlKey||T.metaKey||T.shiftKey?G(-2*Math.PI*n.rotateSpeed/n.domElement.clientHeight):re(0,-n.keyPanSpeed),Z=!0;break;case n.keys.LEFT:T.ctrlKey||T.metaKey||T.shiftKey?H(2*Math.PI*n.rotateSpeed/n.domElement.clientHeight):re(n.keyPanSpeed,0),Z=!0;break;case n.keys.RIGHT:T.ctrlKey||T.metaKey||T.shiftKey?H(-2*Math.PI*n.rotateSpeed/n.domElement.clientHeight):re(-n.keyPanSpeed,0),Z=!0;break}Z&&(T.preventDefault(),n.update())}function Ve(T){if(D.length===1)p.set(T.pageX,T.pageY);else{const Z=Tt(T),ce=.5*(T.pageX+Z.x),ye=.5*(T.pageY+Z.y);p.set(ce,ye)}}function it(T){if(D.length===1)y.set(T.pageX,T.pageY);else{const Z=Tt(T),ce=.5*(T.pageX+Z.x),ye=.5*(T.pageY+Z.y);y.set(ce,ye)}}function q(T){const Z=Tt(T),ce=T.pageX-Z.x,ye=T.pageY-Z.y,Re=Math.sqrt(ce*ce+ye*ye);v.set(0,Re)}function $e(T){n.enableZoom&&q(T),n.enablePan&&it(T)}function Fe(T){n.enableZoom&&q(T),n.enableRotate&&Ve(T)}function mt(T){if(D.length==1)m.set(T.pageX,T.pageY);else{const ce=Tt(T),ye=.5*(T.pageX+ce.x),Re=.5*(T.pageY+ce.y);m.set(ye,Re)}g.subVectors(m,p).multiplyScalar(n.rotateSpeed);const Z=n.domElement;H(2*Math.PI*g.x/Z.clientHeight),G(2*Math.PI*g.y/Z.clientHeight),p.copy(m)}function We(T){if(D.length===1)S.set(T.pageX,T.pageY);else{const Z=Tt(T),ce=.5*(T.pageX+Z.x),ye=.5*(T.pageY+Z.y);S.set(ce,ye)}_.subVectors(S,y).multiplyScalar(n.panSpeed),re(_.x,_.y),y.copy(S)}function At(T){const Z=Tt(T),ce=T.pageX-Z.x,ye=T.pageY-Z.y,Re=Math.sqrt(ce*ce+ye*ye);R.set(0,Re),b.set(0,Math.pow(R.y/v.y,n.zoomSpeed)),se(b.y),v.copy(R);const vt=(T.pageX+Z.x)*.5,dt=(T.pageY+Z.y)*.5;ae(vt,dt)}function z(T){n.enableZoom&&At(T),n.enablePan&&We(T)}function P(T){n.enableZoom&&At(T),n.enableRotate&&mt(T)}function ie(T){n.enabled!==!1&&(D.length===0&&(n.domElement.setPointerCapture(T.pointerId),n.domElement.addEventListener("pointermove",le),n.domElement.addEventListener("pointerup",de)),!Et(T)&&(ct(T),T.pointerType==="touch"?Ke(T):ge(T)))}function le(T){n.enabled!==!1&&(T.pointerType==="touch"?Le(T):He(T))}function de(T){switch(ft(T),D.length){case 0:n.domElement.releasePointerCapture(T.pointerId),n.domElement.removeEventListener("pointermove",le),n.domElement.removeEventListener("pointerup",de),n.dispatchEvent(U_),o=r.NONE;break;case 1:const Z=D[0],ce=C[Z];Ke({pointerId:Z,pageX:ce.x,pageY:ce.y});break}}function ge(T){let Z;switch(T.button){case 0:Z=n.mouseButtons.LEFT;break;case 1:Z=n.mouseButtons.MIDDLE;break;case 2:Z=n.mouseButtons.RIGHT;break;default:Z=-1}switch(Z){case js.DOLLY:if(n.enableZoom===!1)return;ke(T),o=r.DOLLY;break;case js.ROTATE:if(T.ctrlKey||T.metaKey||T.shiftKey){if(n.enablePan===!1)return;Ze(T),o=r.PAN}else{if(n.enableRotate===!1)return;ve(T),o=r.ROTATE}break;case js.PAN:if(T.ctrlKey||T.metaKey||T.shiftKey){if(n.enableRotate===!1)return;ve(T),o=r.ROTATE}else{if(n.enablePan===!1)return;Ze(T),o=r.PAN}break;default:o=r.NONE}o!==r.NONE&&n.dispatchEvent(Zh)}function He(T){switch(o){case r.ROTATE:if(n.enableRotate===!1)return;te(T);break;case r.DOLLY:if(n.enableZoom===!1)return;fe(T);break;case r.PAN:if(n.enablePan===!1)return;Ee(T);break}}function _e(T){n.enabled===!1||n.enableZoom===!1||o!==r.NONE||(T.preventDefault(),n.dispatchEvent(Zh),Me(De(T)),n.dispatchEvent(U_))}function De(T){const Z=T.deltaMode,ce={clientX:T.clientX,clientY:T.clientY,deltaY:T.deltaY};switch(Z){case 1:ce.deltaY*=16;break;case 2:ce.deltaY*=100;break}return T.ctrlKey&&!E&&(ce.deltaY*=10),ce}function Xe(T){T.key==="Control"&&(E=!0,n.domElement.getRootNode().addEventListener("keyup",xe,{passive:!0,capture:!0}))}function xe(T){T.key==="Control"&&(E=!1,n.domElement.getRootNode().removeEventListener("keyup",xe,{passive:!0,capture:!0}))}function we(T){n.enabled===!1||n.enablePan===!1||ze(T)}function Ke(T){switch(_t(T),D.length){case 1:switch(n.touches.ONE){case qs.ROTATE:if(n.enableRotate===!1)return;Ve(T),o=r.TOUCH_ROTATE;break;case qs.PAN:if(n.enablePan===!1)return;it(T),o=r.TOUCH_PAN;break;default:o=r.NONE}break;case 2:switch(n.touches.TWO){case qs.DOLLY_PAN:if(n.enableZoom===!1&&n.enablePan===!1)return;$e(T),o=r.TOUCH_DOLLY_PAN;break;case qs.DOLLY_ROTATE:if(n.enableZoom===!1&&n.enableRotate===!1)return;Fe(T),o=r.TOUCH_DOLLY_ROTATE;break;default:o=r.NONE}break;default:o=r.NONE}o!==r.NONE&&n.dispatchEvent(Zh)}function Le(T){switch(_t(T),o){case r.TOUCH_ROTATE:if(n.enableRotate===!1)return;mt(T),n.update();break;case r.TOUCH_PAN:if(n.enablePan===!1)return;We(T),n.update();break;case r.TOUCH_DOLLY_PAN:if(n.enableZoom===!1&&n.enablePan===!1)return;z(T),n.update();break;case r.TOUCH_DOLLY_ROTATE:if(n.enableZoom===!1&&n.enableRotate===!1)return;P(T),n.update();break;default:o=r.NONE}}function Ie(T){n.enabled!==!1&&T.preventDefault()}function ct(T){D.push(T.pointerId)}function ft(T){delete C[T.pointerId];for(let Z=0;Z<D.length;Z++)if(D[Z]==T.pointerId){D.splice(Z,1);return}}function Et(T){for(let Z=0;Z<D.length;Z++)if(D[Z]==T.pointerId)return!0;return!1}function _t(T){let Z=C[T.pointerId];Z===void 0&&(Z=new Pe,C[T.pointerId]=Z),Z.set(T.pageX,T.pageY)}function Tt(T){const Z=T.pointerId===D[0]?D[1]:D[0];return C[Z]}n.domElement.addEventListener("contextmenu",Ie),n.domElement.addEventListener("pointerdown",ie),n.domElement.addEventListener("pointercancel",de),n.domElement.addEventListener("wheel",_e,{passive:!1}),n.domElement.getRootNode().addEventListener("keydown",Xe,{passive:!0,capture:!0}),this.update()}}var wr=Object.freeze({Linear:Object.freeze({None:function(i){return i},In:function(i){return i},Out:function(i){return i},InOut:function(i){return i}}),Quadratic:Object.freeze({In:function(i){return i*i},Out:function(i){return i*(2-i)},InOut:function(i){return(i*=2)<1?.5*i*i:-.5*(--i*(i-2)-1)}}),Cubic:Object.freeze({In:function(i){return i*i*i},Out:function(i){return--i*i*i+1},InOut:function(i){return(i*=2)<1?.5*i*i*i:.5*((i-=2)*i*i+2)}}),Quartic:Object.freeze({In:function(i){return i*i*i*i},Out:function(i){return 1- --i*i*i*i},InOut:function(i){return(i*=2)<1?.5*i*i*i*i:-.5*((i-=2)*i*i*i-2)}}),Quintic:Object.freeze({In:function(i){return i*i*i*i*i},Out:function(i){return--i*i*i*i*i+1},InOut:function(i){return(i*=2)<1?.5*i*i*i*i*i:.5*((i-=2)*i*i*i*i+2)}}),Sinusoidal:Object.freeze({In:function(i){return 1-Math.sin((1-i)*Math.PI/2)},Out:function(i){return Math.sin(i*Math.PI/2)},InOut:function(i){return .5*(1-Math.sin(Math.PI*(.5-i)))}}),Exponential:Object.freeze({In:function(i){return i===0?0:Math.pow(1024,i-1)},Out:function(i){return i===1?1:1-Math.pow(2,-10*i)},InOut:function(i){return i===0?0:i===1?1:(i*=2)<1?.5*Math.pow(1024,i-1):.5*(-Math.pow(2,-10*(i-1))+2)}}),Circular:Object.freeze({In:function(i){return 1-Math.sqrt(1-i*i)},Out:function(i){return Math.sqrt(1- --i*i)},InOut:function(i){return(i*=2)<1?-.5*(Math.sqrt(1-i*i)-1):.5*(Math.sqrt(1-(i-=2)*i)+1)}}),Elastic:Object.freeze({In:function(i){return i===0?0:i===1?1:-Math.pow(2,10*(i-1))*Math.sin((i-1.1)*5*Math.PI)},Out:function(i){return i===0?0:i===1?1:Math.pow(2,-10*i)*Math.sin((i-.1)*5*Math.PI)+1},InOut:function(i){return i===0?0:i===1?1:(i*=2,i<1?-.5*Math.pow(2,10*(i-1))*Math.sin((i-1.1)*5*Math.PI):.5*Math.pow(2,-10*(i-1))*Math.sin((i-1.1)*5*Math.PI)+1)}}),Back:Object.freeze({In:function(i){var e=1.70158;return i===1?1:i*i*((e+1)*i-e)},Out:function(i){var e=1.70158;return i===0?0:--i*i*((e+1)*i+e)+1},InOut:function(i){var e=2.5949095;return(i*=2)<1?.5*(i*i*((e+1)*i-e)):.5*((i-=2)*i*((e+1)*i+e)+2)}}),Bounce:Object.freeze({In:function(i){return 1-wr.Bounce.Out(1-i)},Out:function(i){return i<1/2.75?7.5625*i*i:i<2/2.75?7.5625*(i-=1.5/2.75)*i+.75:i<2.5/2.75?7.5625*(i-=2.25/2.75)*i+.9375:7.5625*(i-=2.625/2.75)*i+.984375},InOut:function(i){return i<.5?wr.Bounce.In(i*2)*.5:wr.Bounce.Out(i*2-1)*.5+.5}}),generatePow:function(i){return i===void 0&&(i=4),i=i<Number.EPSILON?Number.EPSILON:i,i=i>1e4?1e4:i,{In:function(e){return Math.pow(e,i)},Out:function(e){return 1-Math.pow(1-e,i)},InOut:function(e){return e<.5?Math.pow(e*2,i)/2:(1-Math.pow(2-e*2,i))/2+.5}}}}),Pa=function(){return performance.now()},c2=function(){function i(){this._tweens={},this._tweensAddedDuringUpdate={}}return i.prototype.getAll=function(){var e=this;return Object.keys(this._tweens).map(function(t){return e._tweens[t]})},i.prototype.removeAll=function(){this._tweens={}},i.prototype.add=function(e){this._tweens[e.getId()]=e,this._tweensAddedDuringUpdate[e.getId()]=e},i.prototype.remove=function(e){delete this._tweens[e.getId()],delete this._tweensAddedDuringUpdate[e.getId()]},i.prototype.update=function(e,t){e===void 0&&(e=Pa()),t===void 0&&(t=!1);var n=Object.keys(this._tweens);if(n.length===0)return!1;for(;n.length>0;){this._tweensAddedDuringUpdate={};for(var r=0;r<n.length;r++){var o=this._tweens[n[r]],a=!t;o&&o.update(e,a)===!1&&!t&&delete this._tweens[n[r]]}n=Object.keys(this._tweensAddedDuringUpdate)}return!0},i}(),wf={Linear:function(i,e){var t=i.length-1,n=t*e,r=Math.floor(n),o=wf.Utils.Linear;return e<0?o(i[0],i[1],n):e>1?o(i[t],i[t-1],t-n):o(i[r],i[r+1>t?t:r+1],n-r)},Utils:{Linear:function(i,e,t){return(e-i)*t+i}}},J0=function(){function i(){}return i.nextId=function(){return i._nextId++},i._nextId=0,i}(),Af=new c2,l2=function(){function i(e,t){t===void 0&&(t=Af),this._object=e,this._group=t,this._isPaused=!1,this._pauseStart=0,this._valuesStart={},this._valuesEnd={},this._valuesStartRepeat={},this._duration=1e3,this._isDynamic=!1,this._initialRepeat=0,this._repeat=0,this._yoyo=!1,this._isPlaying=!1,this._reversed=!1,this._delayTime=0,this._startTime=0,this._easingFunction=wr.Linear.None,this._interpolationFunction=wf.Linear,this._chainedTweens=[],this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._id=J0.nextId(),this._isChainStopped=!1,this._propertiesAreSetUp=!1,this._goToEnd=!1}return i.prototype.getId=function(){return this._id},i.prototype.isPlaying=function(){return this._isPlaying},i.prototype.isPaused=function(){return this._isPaused},i.prototype.getDuration=function(){return this._duration},i.prototype.to=function(e,t){if(t===void 0&&(t=1e3),this._isPlaying)throw new Error("Can not call Tween.to() while Tween is already started or paused. Stop the Tween first.");return this._valuesEnd=e,this._propertiesAreSetUp=!1,this._duration=t<0?0:t,this},i.prototype.duration=function(e){return e===void 0&&(e=1e3),this._duration=e<0?0:e,this},i.prototype.dynamic=function(e){return e===void 0&&(e=!1),this._isDynamic=e,this},i.prototype.start=function(e,t){if(e===void 0&&(e=Pa()),t===void 0&&(t=!1),this._isPlaying)return this;if(this._group&&this._group.add(this),this._repeat=this._initialRepeat,this._reversed){this._reversed=!1;for(var n in this._valuesStartRepeat)this._swapEndStartRepeatValues(n),this._valuesStart[n]=this._valuesStartRepeat[n]}if(this._isPlaying=!0,this._isPaused=!1,this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._isChainStopped=!1,this._startTime=e,this._startTime+=this._delayTime,!this._propertiesAreSetUp||t){if(this._propertiesAreSetUp=!0,!this._isDynamic){var r={};for(var o in this._valuesEnd)r[o]=this._valuesEnd[o];this._valuesEnd=r}this._setupProperties(this._object,this._valuesStart,this._valuesEnd,this._valuesStartRepeat,t)}return this},i.prototype.startFromCurrentValues=function(e){return this.start(e,!0)},i.prototype._setupProperties=function(e,t,n,r,o){for(var a in n){var l=e[a],u=Array.isArray(l),h=u?"array":typeof l,d=!u&&Array.isArray(n[a]);if(!(h==="undefined"||h==="function")){if(d){var p=n[a];if(p.length===0)continue;for(var m=[l],g=0,y=p.length;g<y;g+=1){var S=this._handleRelativeValue(l,p[g]);if(isNaN(S)){d=!1,console.warn("Found invalid interpolation list. Skipping.");break}m.push(S)}d&&(n[a]=m)}if((h==="object"||u)&&l&&!d){t[a]=u?[]:{};var _=l;for(var v in _)t[a][v]=_[v];r[a]=u?[]:{};var p=n[a];if(!this._isDynamic){var R={};for(var v in p)R[v]=p[v];n[a]=p=R}this._setupProperties(_,t[a],p,r[a],o)}else(typeof t[a]>"u"||o)&&(t[a]=l),u||(t[a]*=1),d?r[a]=n[a].slice().reverse():r[a]=t[a]||0}}},i.prototype.stop=function(){return this._isChainStopped||(this._isChainStopped=!0,this.stopChainedTweens()),this._isPlaying?(this._group&&this._group.remove(this),this._isPlaying=!1,this._isPaused=!1,this._onStopCallback&&this._onStopCallback(this._object),this):this},i.prototype.end=function(){return this._goToEnd=!0,this.update(1/0),this},i.prototype.pause=function(e){return e===void 0&&(e=Pa()),this._isPaused||!this._isPlaying?this:(this._isPaused=!0,this._pauseStart=e,this._group&&this._group.remove(this),this)},i.prototype.resume=function(e){return e===void 0&&(e=Pa()),!this._isPaused||!this._isPlaying?this:(this._isPaused=!1,this._startTime+=e-this._pauseStart,this._pauseStart=0,this._group&&this._group.add(this),this)},i.prototype.stopChainedTweens=function(){for(var e=0,t=this._chainedTweens.length;e<t;e++)this._chainedTweens[e].stop();return this},i.prototype.group=function(e){return e===void 0&&(e=Af),this._group=e,this},i.prototype.delay=function(e){return e===void 0&&(e=0),this._delayTime=e,this},i.prototype.repeat=function(e){return e===void 0&&(e=0),this._initialRepeat=e,this._repeat=e,this},i.prototype.repeatDelay=function(e){return this._repeatDelayTime=e,this},i.prototype.yoyo=function(e){return e===void 0&&(e=!1),this._yoyo=e,this},i.prototype.easing=function(e){return e===void 0&&(e=wr.Linear.None),this._easingFunction=e,this},i.prototype.interpolation=function(e){return e===void 0&&(e=wf.Linear),this._interpolationFunction=e,this},i.prototype.chain=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return this._chainedTweens=e,this},i.prototype.onStart=function(e){return this._onStartCallback=e,this},i.prototype.onEveryStart=function(e){return this._onEveryStartCallback=e,this},i.prototype.onUpdate=function(e){return this._onUpdateCallback=e,this},i.prototype.onRepeat=function(e){return this._onRepeatCallback=e,this},i.prototype.onComplete=function(e){return this._onCompleteCallback=e,this},i.prototype.onStop=function(e){return this._onStopCallback=e,this},i.prototype.update=function(e,t){var n;if(e===void 0&&(e=Pa()),t===void 0&&(t=!0),this._isPaused)return!0;var r=this._startTime+this._duration;if(!this._goToEnd&&!this._isPlaying){if(e>r)return!1;t&&this.start(e,!0)}if(this._goToEnd=!1,e<this._startTime)return!0;this._onStartCallbackFired===!1&&(this._onStartCallback&&this._onStartCallback(this._object),this._onStartCallbackFired=!0),this._onEveryStartCallbackFired===!1&&(this._onEveryStartCallback&&this._onEveryStartCallback(this._object),this._onEveryStartCallbackFired=!0);var o=e-this._startTime,a=this._duration+((n=this._repeatDelayTime)!==null&&n!==void 0?n:this._delayTime),l=this._duration+this._repeat*a,u=this._calculateElapsedPortion(o,a,l),h=this._easingFunction(u),d=this._calculateCompletionStatus(o,a);if(d==="repeat"&&this._processRepetition(o,a),this._updateProperties(this._object,this._valuesStart,this._valuesEnd,h),d==="about-to-repeat"&&this._processRepetition(o,a),this._onUpdateCallback&&this._onUpdateCallback(this._object,u),d==="repeat"||d==="about-to-repeat")this._onRepeatCallback&&this._onRepeatCallback(this._object),this._onEveryStartCallbackFired=!1;else if(d==="completed"){this._isPlaying=!1,this._onCompleteCallback&&this._onCompleteCallback(this._object);for(var p=0,m=this._chainedTweens.length;p<m;p++)this._chainedTweens[p].start(this._startTime+this._duration,!1)}return d!=="completed"},i.prototype._calculateElapsedPortion=function(e,t,n){if(this._duration===0||e>n)return 1;var r=e%t,o=Math.min(r/this._duration,1);return o===0&&e!==0&&e%this._duration===0?1:o},i.prototype._calculateCompletionStatus=function(e,t){return this._duration!==0&&e<this._duration?"playing":this._repeat<=0?"completed":e===this._duration?"about-to-repeat":"repeat"},i.prototype._processRepetition=function(e,t){var n=Math.min(Math.trunc((e-this._duration)/t)+1,this._repeat);isFinite(this._repeat)&&(this._repeat-=n);for(var r in this._valuesStartRepeat){var o=this._valuesEnd[r];!this._yoyo&&typeof o=="string"&&(this._valuesStartRepeat[r]=this._valuesStartRepeat[r]+parseFloat(o)),this._yoyo&&this._swapEndStartRepeatValues(r),this._valuesStart[r]=this._valuesStartRepeat[r]}this._yoyo&&(this._reversed=!this._reversed),this._startTime+=t*n},i.prototype._updateProperties=function(e,t,n,r){for(var o in n)if(t[o]!==void 0){var a=t[o]||0,l=n[o],u=Array.isArray(e[o]),h=Array.isArray(l),d=!u&&h;d?e[o]=this._interpolationFunction(l,r):typeof l=="object"&&l?this._updateProperties(e[o],a,l,r):(l=this._handleRelativeValue(a,l),typeof l=="number"&&(e[o]=a+(l-a)*r))}},i.prototype._handleRelativeValue=function(e,t){return typeof t!="string"?t:t.charAt(0)==="+"||t.charAt(0)==="-"?e+parseFloat(t):parseFloat(t)},i.prototype._swapEndStartRepeatValues=function(e){var t=this._valuesStartRepeat[e],n=this._valuesEnd[e];typeof n=="string"?this._valuesStartRepeat[e]=this._valuesStartRepeat[e]+parseFloat(n):this._valuesStartRepeat[e]=this._valuesEnd[e],this._valuesEnd[e]=t},i}();J0.nextId;var nr=Af;nr.getAll.bind(nr);nr.removeAll.bind(nr);nr.add.bind(nr);nr.remove.bind(nr);var u2=nr.update.bind(nr);const Sl={enableDamping:!0,dampingFactor:.04};class Ul extends a2{static DEFAULT_ZOOM_FACTOR=1;_animationSystem;last=null;animating=!1;locked=!1;stopMoveTo=()=>{};stopRevertLast=()=>{};object;domElement;_removePreRenderCallback=()=>{};constructor(e,t,n,r=Sl){super(e,t.domElement),this._animationSystem=n,this.domElement=t.domElement,this.object=e;const o=t.AddPreRenderCallback(()=>{this.preRenderCallback()});this._removePreRenderCallback=()=>{t.RemovePreRenderCallback(o)},this.enableDamping=r.enableDamping||Sl.enableDamping,this.dampingFactor=r.dampingFactor||Sl.dampingFactor,this.object.position.set(0,2,2),this.target.copy({x:0,y:.5,z:0}),this.update()}Dispose(){this._removePreRenderCallback(),this.dispose()}ComputeEncompassingView(e){const t=e.getCenter(new F),n=e.getSize(new F),r=Math.max(n.x,n.y,n.z)*1.25;return{position:this.object.position.clone().normalize().multiplyScalar(r),target:t}}ZoomIn(e){const t=e||Ul.DEFAULT_ZOOM_FACTOR,{minDistance:n,maxDistance:r}=this;this.minDistance=this.maxDistance=ci.clamp(this.getDistance()-t,n+t,r-t),this.update(),this.minDistance=n,this.maxDistance=r}ZoomOut(e){const t=e||Ul.DEFAULT_ZOOM_FACTOR,{minDistance:n,maxDistance:r}=this;this.minDistance=this.maxDistance=ci.clamp(this.getDistance()+t,n+t,r-t),this.update(),this.minDistance=n,this.maxDistance=r}MoveTo(e,t,n,r){if(this.animating)return;const o=e||this.object.position.clone(),a=t||this.target.clone();this.stopRevertLast(),this.locked||(this.last={pos:this.object.position.clone(),target:this.target.clone()}),this.animating=n>0,this.locked=r,this.enabled=!1;const l=this._animationSystem.Animate(this.object.position).to(o,n).easing(wr.Quadratic.Out).start(),u=this._animationSystem.Animate(this.target).to(a,n).easing(wr.Quadratic.Out).onUpdate(()=>{this.object.lookAt(this.target)}).onComplete(()=>{this.animating=!1,this.enabled=!r}).start();this.stopMoveTo=()=>{l.stop(),u.stop()}}RevertLast(e){if(this.animating||!this.locked)return;this.stopMoveTo(),this.animating=e>0,this.enabled=!1;const{pos:t,target:n}=this.last,r=this._animationSystem.Animate(this.object.position).to(t,e).easing(wr.Quadratic.Out).start(),o=this._animationSystem.Animate(this.target).to(n,e).easing(wr.Quadratic.Out).onUpdate(()=>{this.object.lookAt(this.target)}).onComplete(()=>{this.animating=!1,this.locked=!1,this.enabled=!0}).start();this.stopRevertLast=()=>{r.stop(),o.stop()}}preRenderCallback=()=>{this.locked||this.update()}}class h2{static DefaultTool="select";_scene;_controller;_activeTool;_selectTool;get selectTool(){return this._selectTool||(this._selectTool=new UL(this._scene,this._controller)),this._selectTool}constructor(e,t){this._scene=e,this._controller=t,this._selectTool=null,this._activeTool=null}Dispose(){this.removeEventListeners()}GetActiveTool(){return this._activeTool}UseTool(e){switch(this._activeTool?.Deactivate(),e){case"select":{this.addEventListeners(),this.selectTool.Activate(),this._activeTool=this.selectTool;break}case"none":{this.removeEventListeners(),this._activeTool=null;break}default:console.warn(`DIVEToolBox.UseTool: Unknown tool: ${e}`)}}SetGizmoMode(e){this.selectTool.SetGizmoMode(e)}SetGizmoVisibility(e){this.selectTool.SetGizmoVisibility(e)}SetGizmoScaleLinked(e){this.selectTool.SetGizmoScaleLinked(e)}onPointerMove(e){this._activeTool?.onPointerMove(e)}onPointerDown(e){this._activeTool?.onPointerDown(e)}onPointerUp(e){this._activeTool?.onPointerUp(e)}onWheel(e){this._activeTool?.onWheel(e)}addEventListeners(){this._controller.domElement.addEventListener("pointermove",e=>this.onPointerMove(e)),this._controller.domElement.addEventListener("pointerdown",e=>this.onPointerDown(e)),this._controller.domElement.addEventListener("pointerup",e=>this.onPointerUp(e)),this._controller.domElement.addEventListener("wheel",e=>this.onWheel(e))}removeEventListeners(){this._controller.domElement.removeEventListener("pointermove",e=>this.onPointerMove(e)),this._controller.domElement.removeEventListener("pointerdown",e=>this.onPointerDown(e)),this._controller.domElement.removeEventListener("pointerup",e=>this.onPointerUp(e)),this._controller.domElement.removeEventListener("wheel",e=>this.onWheel(e))}}class f2{_renderer;_rendererCallbackId;constructor(e){this._renderer=e,this._rendererCallbackId=this._renderer.AddPreRenderCallback(()=>{this.Update()})}Dispose(){this._renderer.RemovePreRenderCallback(this._rendererCallbackId)}Update(){u2()}Animate(e){return new l2(e)}}function d2(i,e,t){return e=Nl(e),S2(i,Q0()?Reflect.construct(e,t||[],Nl(i).constructor):e.apply(i,t))}function Q0(){try{var i=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Q0=function(){return!!i})()}function p2(i,e){var t=i==null?null:typeof Symbol<"u"&&i[Symbol.iterator]||i["@@iterator"];if(t!=null){var n,r,o,a,l=[],u=!0,h=!1;try{if(o=(t=t.call(i)).next,e===0){if(Object(t)!==t)return;u=!1}else for(;!(u=(n=o.call(t)).done)&&(l.push(n.value),l.length!==e);u=!0);}catch(d){h=!0,r=d}finally{try{if(!u&&t.return!=null&&(a=t.return(),Object(a)!==a))return}finally{if(h)throw r}}return l}}function m2(i,e){if(typeof i!="object"||!i)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(i)}function g2(i){var e=m2(i,"string");return typeof e=="symbol"?e:String(e)}function _2(i,e){if(!(i instanceof e))throw new TypeError("Cannot call a class as a function")}function v2(i,e){for(var t=0;t<e.length;t++){var n=e[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(i,g2(n.key),n)}}function x2(i,e,t){return e&&v2(i.prototype,e),Object.defineProperty(i,"prototype",{writable:!1}),i}function y2(i,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");i.prototype=Object.create(e&&e.prototype,{constructor:{value:i,writable:!0,configurable:!0}}),Object.defineProperty(i,"prototype",{writable:!1}),e&&Rf(i,e)}function Nl(i){return Nl=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Nl(i)}function Rf(i,e){return Rf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,r){return n.__proto__=r,n},Rf(i,e)}function M2(i){if(i===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return i}function S2(i,e){if(e&&(typeof e=="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return M2(i)}function O_(i,e){return T2(i)||p2(i,e)||ev(i,e)||A2()}function gl(i){return E2(i)||b2(i)||ev(i)||w2()}function E2(i){if(Array.isArray(i))return Cf(i)}function T2(i){if(Array.isArray(i))return i}function b2(i){if(typeof Symbol<"u"&&i[Symbol.iterator]!=null||i["@@iterator"]!=null)return Array.from(i)}function ev(i,e){if(i){if(typeof i=="string")return Cf(i,e);var t=Object.prototype.toString.call(i).slice(8,-1);if(t==="Object"&&i.constructor&&(t=i.constructor.name),t==="Map"||t==="Set")return Array.from(i);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return Cf(i,e)}}function Cf(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,n=new Array(e);t<e;t++)n[t]=i[t];return n}function w2(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
3828
+ */var en=Uint8Array,oi=Uint16Array,ed=Int32Array,Vl=new en([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Wl=new en([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),yf=new en([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),V0=function(i,e){for(var t=new oi(31),n=0;n<31;++n)t[n]=e+=1<<i[n-1];for(var r=new ed(t[30]),n=1;n<30;++n)for(var o=t[n];o<t[n+1];++o)r[o]=o-t[n]<<5|n;return{b:t,r}},W0=V0(Vl,2),X0=W0.b,Mf=W0.r;X0[28]=258,Mf[258]=28;var Y0=V0(Wl,0),wI=Y0.b,R_=Y0.r,Sf=new oi(32768);for(var Xt=0;Xt<32768;++Xt){var qr=(Xt&43690)>>1|(Xt&21845)<<1;qr=(qr&52428)>>2|(qr&13107)<<2,qr=(qr&61680)>>4|(qr&3855)<<4,Sf[Xt]=((qr&65280)>>8|(qr&255)<<8)>>1}var er=function(i,e,t){for(var n=i.length,r=0,o=new oi(e);r<n;++r)i[r]&&++o[i[r]-1];var a=new oi(e);for(r=1;r<e;++r)a[r]=a[r-1]+o[r-1]<<1;var l;if(t){l=new oi(1<<e);var u=15-e;for(r=0;r<n;++r)if(i[r])for(var h=r<<4|i[r],d=e-i[r],p=a[i[r]-1]++<<d,m=p|(1<<d)-1;p<=m;++p)l[Sf[p]>>u]=h}else for(l=new oi(n),r=0;r<n;++r)i[r]&&(l[r]=Sf[a[i[r]-1]++]>>15-i[r]);return l},ts=new en(288);for(var Xt=0;Xt<144;++Xt)ts[Xt]=8;for(var Xt=144;Xt<256;++Xt)ts[Xt]=9;for(var Xt=256;Xt<280;++Xt)ts[Xt]=7;for(var Xt=280;Xt<288;++Xt)ts[Xt]=8;var Ha=new en(32);for(var Xt=0;Xt<32;++Xt)Ha[Xt]=5;var AI=er(ts,9,0),RI=er(ts,9,1),CI=er(Ha,5,0),PI=er(Ha,5,1),qh=function(i){for(var e=i[0],t=1;t<i.length;++t)i[t]>e&&(e=i[t]);return e},Di=function(i,e,t){var n=e/8|0;return(i[n]|i[n+1]<<8)>>(e&7)&t},$h=function(i,e){var t=e/8|0;return(i[t]|i[t+1]<<8|i[t+2]<<16)>>(e&7)},td=function(i){return(i+7)/8|0},Xa=function(i,e,t){return(e==null||e<0)&&(e=0),(t==null||t>i.length)&&(t=i.length),new en(i.subarray(e,t))},LI=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],Wn=function(i,e,t){var n=new Error(e||LI[i]);if(n.code=i,Error.captureStackTrace&&Error.captureStackTrace(n,Wn),!t)throw n;return n},II=function(i,e,t,n){var r=i.length,o=n?n.length:0;if(!r||e.f&&!e.l)return t||new en(0);var a=!t,l=a||e.i!=2,u=e.i;a&&(t=new en(r*3));var h=function(q){var $e=t.length;if(q>$e){var Fe=new en(Math.max($e*2,q));Fe.set(t),t=Fe}},d=e.f||0,p=e.p||0,m=e.b||0,g=e.l,y=e.d,S=e.m,_=e.n,v=r*8;do{if(!g){d=Di(i,p,1);var R=Di(i,p+1,3);if(p+=3,R)if(R==1)g=RI,y=PI,S=9,_=5;else if(R==2){var N=Di(i,p,31)+257,D=Di(i,p+10,15)+4,C=N+Di(i,p+5,31)+1;p+=14;for(var E=new en(C),M=new en(19),O=0;O<D;++O)M[yf[O]]=Di(i,p+O*3,7);p+=D*3;for(var H=qh(M),G=(1<<H)-1,Y=er(M,H,1),O=0;O<C;){var $=Y[Di(i,p,G)];p+=$&15;var b=$>>4;if(b<16)E[O++]=b;else{var re=0,se=0;for(b==16?(se=3+Di(i,p,3),p+=2,re=E[O-1]):b==17?(se=3+Di(i,p,7),p+=3):b==18&&(se=11+Di(i,p,127),p+=7);se--;)E[O++]=re}}var K=E.subarray(0,N),ae=E.subarray(N);S=qh(K),_=qh(ae),g=er(K,S,1),y=er(ae,_,1)}else Wn(1);else{var b=td(p)+4,A=i[b-4]|i[b-3]<<8,B=b+A;if(B>r){u&&Wn(0);break}l&&h(m+A),t.set(i.subarray(b,B),m),e.b=m+=A,e.p=p=B*8,e.f=d;continue}if(p>v){u&&Wn(0);break}}l&&h(m+131072);for(var pe=(1<<S)-1,ve=(1<<_)-1,ke=p;;ke=p){var re=g[$h(i,p)&pe],Ze=re>>4;if(p+=re&15,p>v){u&&Wn(0);break}if(re||Wn(2),Ze<256)t[m++]=Ze;else if(Ze==256){ke=p,g=null;break}else{var te=Ze-254;if(Ze>264){var O=Ze-257,fe=Vl[O];te=Di(i,p,(1<<fe)-1)+X0[O],p+=fe}var Ee=y[$h(i,p)&ve],Me=Ee>>4;Ee||Wn(3),p+=Ee&15;var ae=wI[Me];if(Me>3){var fe=Wl[Me];ae+=$h(i,p)&(1<<fe)-1,p+=fe}if(p>v){u&&Wn(0);break}l&&h(m+131072);var ze=m+te;if(m<ae){var Ve=o-ae,it=Math.min(ae,ze);for(Ve+m<0&&Wn(3);m<it;++m)t[m]=n[Ve+m]}for(;m<ze;++m)t[m]=t[m-ae]}}e.l=g,e.p=ke,e.b=m,e.f=d,g&&(d=1,e.m=S,e.d=y,e.n=_)}while(!d);return m!=t.length&&a?Xa(t,0,m):t.subarray(0,m)},Er=function(i,e,t){t<<=e&7;var n=e/8|0;i[n]|=t,i[n+1]|=t>>8},Sa=function(i,e,t){t<<=e&7;var n=e/8|0;i[n]|=t,i[n+1]|=t>>8,i[n+2]|=t>>16},Kh=function(i,e){for(var t=[],n=0;n<i.length;++n)i[n]&&t.push({s:n,f:i[n]});var r=t.length,o=t.slice();if(!r)return{t:q0,l:0};if(r==1){var a=new en(t[0].s+1);return a[t[0].s]=1,{t:a,l:1}}t.sort(function(B,N){return B.f-N.f}),t.push({s:-1,f:25001});var l=t[0],u=t[1],h=0,d=1,p=2;for(t[0]={s:-1,f:l.f+u.f,l,r:u};d!=r-1;)l=t[t[h].f<t[p].f?h++:p++],u=t[h!=d&&t[h].f<t[p].f?h++:p++],t[d++]={s:-1,f:l.f+u.f,l,r:u};for(var m=o[0].s,n=1;n<r;++n)o[n].s>m&&(m=o[n].s);var g=new oi(m+1),y=Ef(t[d-1],g,0);if(y>e){var n=0,S=0,_=y-e,v=1<<_;for(o.sort(function(N,D){return g[D.s]-g[N.s]||N.f-D.f});n<r;++n){var R=o[n].s;if(g[R]>e)S+=v-(1<<y-g[R]),g[R]=e;else break}for(S>>=_;S>0;){var b=o[n].s;g[b]<e?S-=1<<e-g[b]++-1:++n}for(;n>=0&&S;--n){var A=o[n].s;g[A]==e&&(--g[A],++S)}y=e}return{t:new en(g),l:y}},Ef=function(i,e,t){return i.s==-1?Math.max(Ef(i.l,e,t+1),Ef(i.r,e,t+1)):e[i.s]=t},C_=function(i){for(var e=i.length;e&&!i[--e];);for(var t=new oi(++e),n=0,r=i[0],o=1,a=function(u){t[n++]=u},l=1;l<=e;++l)if(i[l]==r&&l!=e)++o;else{if(!r&&o>2){for(;o>138;o-=138)a(32754);o>2&&(a(o>10?o-11<<5|28690:o-3<<5|12305),o=0)}else if(o>3){for(a(r),--o;o>6;o-=6)a(8304);o>2&&(a(o-3<<5|8208),o=0)}for(;o--;)a(r);o=1,r=i[l]}return{c:t.subarray(0,n),n:e}},Ea=function(i,e){for(var t=0,n=0;n<e.length;++n)t+=i[n]*e[n];return t},j0=function(i,e,t){var n=t.length,r=td(e+2);i[r]=n&255,i[r+1]=n>>8,i[r+2]=i[r]^255,i[r+3]=i[r+1]^255;for(var o=0;o<n;++o)i[r+o+4]=t[o];return(r+4+n)*8},P_=function(i,e,t,n,r,o,a,l,u,h,d){Er(e,d++,t),++r[256];for(var p=Kh(r,15),m=p.t,g=p.l,y=Kh(o,15),S=y.t,_=y.l,v=C_(m),R=v.c,b=v.n,A=C_(S),B=A.c,N=A.n,D=new oi(19),C=0;C<R.length;++C)++D[R[C]&31];for(var C=0;C<B.length;++C)++D[B[C]&31];for(var E=Kh(D,7),M=E.t,O=E.l,H=19;H>4&&!M[yf[H-1]];--H);var G=h+5<<3,Y=Ea(r,ts)+Ea(o,Ha)+a,$=Ea(r,m)+Ea(o,S)+a+14+3*H+Ea(D,M)+2*D[16]+3*D[17]+7*D[18];if(u>=0&&G<=Y&&G<=$)return j0(e,d,i.subarray(u,u+h));var re,se,K,ae;if(Er(e,d,1+($<Y)),d+=2,$<Y){re=er(m,g,0),se=m,K=er(S,_,0),ae=S;var pe=er(M,O,0);Er(e,d,b-257),Er(e,d+5,N-1),Er(e,d+10,H-4),d+=14;for(var C=0;C<H;++C)Er(e,d+3*C,M[yf[C]]);d+=3*H;for(var ve=[R,B],ke=0;ke<2;++ke)for(var Ze=ve[ke],C=0;C<Ze.length;++C){var te=Ze[C]&31;Er(e,d,pe[te]),d+=M[te],te>15&&(Er(e,d,Ze[C]>>5&127),d+=Ze[C]>>12)}}else re=AI,se=ts,K=CI,ae=Ha;for(var C=0;C<l;++C){var fe=n[C];if(fe>255){var te=fe>>18&31;Sa(e,d,re[te+257]),d+=se[te+257],te>7&&(Er(e,d,fe>>23&31),d+=Vl[te]);var Ee=fe&31;Sa(e,d,K[Ee]),d+=ae[Ee],Ee>3&&(Sa(e,d,fe>>5&8191),d+=Wl[Ee])}else Sa(e,d,re[fe]),d+=se[fe]}return Sa(e,d,re[256]),d+se[256]},DI=new ed([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),q0=new en(0),UI=function(i,e,t,n,r,o){var a=o.z||i.length,l=new en(n+a+5*(1+Math.ceil(a/7e3))+r),u=l.subarray(n,l.length-r),h=o.l,d=(o.r||0)&7;if(e){d&&(u[0]=o.r>>3);for(var p=DI[e-1],m=p>>13,g=p&8191,y=(1<<t)-1,S=o.p||new oi(32768),_=o.h||new oi(y+1),v=Math.ceil(t/3),R=2*v,b=function(mt){return(i[mt]^i[mt+1]<<v^i[mt+2]<<R)&y},A=new ed(25e3),B=new oi(288),N=new oi(32),D=0,C=0,E=o.i||0,M=0,O=o.w||0,H=0;E+2<a;++E){var G=b(E),Y=E&32767,$=_[G];if(S[Y]=$,_[G]=Y,O<=E){var re=a-E;if((D>7e3||M>24576)&&(re>423||!h)){d=P_(i,u,0,A,B,N,C,M,H,E-H,d),M=D=C=0,H=E;for(var se=0;se<286;++se)B[se]=0;for(var se=0;se<30;++se)N[se]=0}var K=2,ae=0,pe=g,ve=Y-$&32767;if(re>2&&G==b(E-ve))for(var ke=Math.min(m,re)-1,Ze=Math.min(32767,E),te=Math.min(258,re);ve<=Ze&&--pe&&Y!=$;){if(i[E+K]==i[E+K-ve]){for(var fe=0;fe<te&&i[E+fe]==i[E+fe-ve];++fe);if(fe>K){if(K=fe,ae=ve,fe>ke)break;for(var Ee=Math.min(ve,fe-2),Me=0,se=0;se<Ee;++se){var ze=E-ve+se&32767,Ve=S[ze],it=ze-Ve&32767;it>Me&&(Me=it,$=ze)}}}Y=$,$=S[Y],ve+=Y-$&32767}if(ae){A[M++]=268435456|Mf[K]<<18|R_[ae];var q=Mf[K]&31,$e=R_[ae]&31;C+=Vl[q]+Wl[$e],++B[257+q],++N[$e],O=E+K,++D}else A[M++]=i[E],++B[i[E]]}}for(E=Math.max(E,O);E<a;++E)A[M++]=i[E],++B[i[E]];d=P_(i,u,h,A,B,N,C,M,H,E-H,d),h||(o.r=d&7|u[d/8|0]<<3,d-=7,o.h=_,o.p=S,o.i=E,o.w=O)}else{for(var E=o.w||0;E<a+h;E+=65535){var Fe=E+65535;Fe>=a&&(u[d/8|0]=h,Fe=a),d=j0(u,d+1,i.subarray(E,Fe))}o.i=a}return Xa(l,0,n+td(d)+r)},NI=function(){for(var i=new Int32Array(256),e=0;e<256;++e){for(var t=e,n=9;--n;)t=(t&1&&-306674912)^t>>>1;i[e]=t}return i}(),OI=function(){var i=-1;return{p:function(e){for(var t=i,n=0;n<e.length;++n)t=NI[t&255^e[n]]^t>>>8;i=t},d:function(){return~i}}},FI=function(i,e,t,n,r){if(!r&&(r={l:1},e.dictionary)){var o=e.dictionary.subarray(-32768),a=new en(o.length+i.length);a.set(o),a.set(i,o.length),i=a,r.w=o.length}return UI(i,e.level==null?6:e.level,e.mem==null?r.l?Math.ceil(Math.max(8,Math.min(13,Math.log(i.length)))*1.5):20:12+e.mem,t,n,r)},$0=function(i,e){var t={};for(var n in i)t[n]=i[n];for(var n in e)t[n]=e[n];return t},qi=function(i,e){return i[e]|i[e+1]<<8},Ui=function(i,e){return(i[e]|i[e+1]<<8|i[e+2]<<16|i[e+3]<<24)>>>0},Zh=function(i,e){return Ui(i,e)+Ui(i,e+4)*4294967296},Mn=function(i,e,t){for(;t;++e)i[e]=t,t>>>=8};function BI(i,e){return FI(i,e||{},0,0)}function zI(i,e){return II(i,{i:2},e&&e.out,e&&e.dictionary)}var K0=function(i,e,t,n){for(var r in i){var o=i[r],a=e+r,l=n;Array.isArray(o)&&(l=$0(n,o[1]),o=o[0]),o instanceof en?t[a]=[o,l]:(t[a+="/"]=[new en(0),l],K0(o,a,t,n))}},L_=typeof TextEncoder<"u"&&new TextEncoder,Tf=typeof TextDecoder<"u"&&new TextDecoder,kI=0;try{Tf.decode(q0,{stream:!0}),kI=1}catch{}var HI=function(i){for(var e="",t=0;;){var n=i[t++],r=(n>127)+(n>223)+(n>239);if(t+r>i.length)return{s:e,r:Xa(i,t-1)};r?r==3?(n=((n&15)<<18|(i[t++]&63)<<12|(i[t++]&63)<<6|i[t++]&63)-65536,e+=String.fromCharCode(55296|n>>10,56320|n&1023)):r&1?e+=String.fromCharCode((n&31)<<6|i[t++]&63):e+=String.fromCharCode((n&15)<<12|(i[t++]&63)<<6|i[t++]&63):e+=String.fromCharCode(n)}};function Dl(i,e){var t;if(L_)return L_.encode(i);for(var n=i.length,r=new en(i.length+(i.length>>1)),o=0,a=function(h){r[o++]=h},t=0;t<n;++t){if(o+5>r.length){var l=new en(o+8+(n-t<<1));l.set(r),r=l}var u=i.charCodeAt(t);u<128||e?a(u):u<2048?(a(192|u>>6),a(128|u&63)):u>55295&&u<57344?(u=65536+(u&1047552)|i.charCodeAt(++t)&1023,a(240|u>>18),a(128|u>>12&63),a(128|u>>6&63),a(128|u&63)):(a(224|u>>12),a(128|u>>6&63),a(128|u&63))}return Xa(r,0,o)}function bf(i,e){if(e){for(var t="",n=0;n<i.length;n+=16384)t+=String.fromCharCode.apply(null,i.subarray(n,n+16384));return t}else{if(Tf)return Tf.decode(i);var r=HI(i),o=r.s,t=r.r;return t.length&&Wn(8),o}}var GI=function(i,e){return e+30+qi(i,e+26)+qi(i,e+28)},VI=function(i,e,t){var n=qi(i,e+28),r=bf(i.subarray(e+46,e+46+n),!(qi(i,e+8)&2048)),o=e+46+n,a=Ui(i,e+20),l=t&&a==4294967295?WI(i,o):[a,Ui(i,e+24),Ui(i,e+42)],u=l[0],h=l[1],d=l[2];return[qi(i,e+10),u,h,r,o+qi(i,e+30)+qi(i,e+32),d]},WI=function(i,e){for(;qi(i,e)!=1;e+=4+qi(i,e+2));return[Zh(i,e+12),Zh(i,e+4),Zh(i,e+20)]},wf=function(i){var e=0;if(i)for(var t in i){var n=i[t].length;n>65535&&Wn(9),e+=n+4}return e},I_=function(i,e,t,n,r,o,a,l){var u=n.length,h=t.extra,d=l&&l.length,p=wf(h);Mn(i,e,a!=null?33639248:67324752),e+=4,a!=null&&(i[e++]=20,i[e++]=t.os),i[e]=20,e+=2,i[e++]=t.flag<<1|(o<0&&8),i[e++]=r&&8,i[e++]=t.compression&255,i[e++]=t.compression>>8;var m=new Date(t.mtime==null?Date.now():t.mtime),g=m.getFullYear()-1980;if((g<0||g>119)&&Wn(10),Mn(i,e,g<<25|m.getMonth()+1<<21|m.getDate()<<16|m.getHours()<<11|m.getMinutes()<<5|m.getSeconds()>>1),e+=4,o!=-1&&(Mn(i,e,t.crc),Mn(i,e+4,o<0?-o-2:o),Mn(i,e+8,t.size)),Mn(i,e+12,u),Mn(i,e+14,p),e+=16,a!=null&&(Mn(i,e,d),Mn(i,e+6,t.attrs),Mn(i,e+10,a),e+=14),i.set(n,e),e+=u,p)for(var y in h){var S=h[y],_=S.length;Mn(i,e,+y),Mn(i,e+2,_),i.set(S,e+4),e+=4+_}return d&&(i.set(l,e),e+=d),e},XI=function(i,e,t,n,r){Mn(i,e,101010256),Mn(i,e+8,t),Mn(i,e+10,t),Mn(i,e+12,n),Mn(i,e+16,r)};function YI(i,e){e||(e={});var t={},n=[];K0(i,"",t,e);var r=0,o=0;for(var a in t){var l=t[a],u=l[0],h=l[1],d=h.level==0?0:8,p=Dl(a),m=p.length,g=h.comment,y=g&&Dl(g),S=y&&y.length,_=wf(h.extra);m>65535&&Wn(11);var v=d?BI(u,h):u,R=v.length,b=OI();b.p(u),n.push($0(h,{size:u.length,crc:b.d(),c:v,f:p,m:y,u:m!=a.length||y&&g.length!=S,o:r,compression:d})),r+=30+m+_+R,o+=76+2*(m+_)+(S||0)+R}for(var A=new en(o+22),B=r,N=o-r,D=0;D<n.length;++D){var p=n[D];I_(A,p.o,p,p.f,p.u,p.c.length);var C=30+p.f.length+wf(p.extra);A.set(p.c,p.o+C),I_(A,r,p,p.f,p.u,p.c.length,p.o,p.m),r+=16+C+(p.m?p.m.length:0)}return XI(A,r,n.length,N,B),A}function jI(i,e){for(var t={},n=i.length-22;Ui(i,n)!=101010256;--n)(!n||i.length-n>65558)&&Wn(13);var r=qi(i,n+8);if(!r)return{};var o=Ui(i,n+16),a=o==4294967295||r==65535;if(a){var l=Ui(i,n-12);a=Ui(i,l)==101075792,a&&(r=Ui(i,l+32),o=Ui(i,l+48))}for(var u=0;u<r;++u){var h=VI(i,o,a),d=h[0],p=h[1],m=h[2],g=h[3],y=h[4],S=h[5],_=GI(i,S);o=y,d?d==8?t[g]=zI(i.subarray(_,_+p),{out:new en(m)}):Wn(14,"unknown compression type "+d):t[g]=Xa(i,_,_+p)}return t}class qI{parse(e){const t={},n=e.split(`
3829
+ `);let r=null,o=t;const a=[t];for(const l of n)if(l.includes("=")){const u=l.split("="),h=u[0].trim(),d=u[1].trim();if(d.endsWith("{")){const p={};a.push(p),o[h]=p,o=p}else o[h]=d}else if(l.endsWith("{")){const u=o[r]||{};a.push(u),o[r]=u,o=u}else if(l.endsWith("}")){if(a.pop(),a.length===0)continue;o=a[a.length-1]}else if(l.endsWith("(")){const u={};a.push(u),r=l.split("(")[0].trim()||r,o[r]=u,o=u}else l.endsWith(")")?(a.pop(),o=a[a.length-1]):r=l.trim();return t}}class $I extends Ls{constructor(e){super(e)}load(e,t,n,r){const o=this,a=new Ll(o.manager);a.setPath(o.path),a.setResponseType("arraybuffer"),a.setRequestHeader(o.requestHeader),a.setWithCredentials(o.withCredentials),a.load(e,function(l){try{t(o.parse(l))}catch(u){r?r(u):console.error(u),o.manager.itemError(e)}},n,r)}parse(e){const t=new qI;function n(C){const E={};new Ll().setResponseType("arraybuffer");for(const O in C){if(O.endsWith("png")){const H=new Blob([C[O]],{type:{type:"image/png"}});E[O]=URL.createObjectURL(H)}if(O.endsWith("usd")||O.endsWith("usda")){if(r(C[O])){console.warn("THREE.USDZLoader: Crate files (.usdc or binary .usd) are not supported.");continue}const H=bf(C[O]);E[O]=t.parse(H)}}return E}function r(C){const E=C.slice(0,7),M=new Uint8Array([80,88,82,45,85,83,68,67]);return E.every((O,H)=>O===M[H])}function o(C){if(C.length<1)return;const E=Object.keys(C)[0];let M=!1;if(E.endsWith("usda"))return C[E];if(E.endsWith("usdc"))M=!0;else if(E.endsWith("usd"))if(r(C[E]))M=!0;else return C[E];M&&console.warn("THREE.USDZLoader: Crate files (.usdc or binary .usd) are not supported.")}const a=jI(new Uint8Array(e)),l=n(a),u=o(a);if(u===void 0)return console.warn("THREE.USDZLoader: No usda file found."),new Qi;const h=bf(u),d=t.parse(h);function p(C){if(C){if("prepend references"in C){const M=C["prepend references"].split("@"),O=M[1].replace(/^.\//,""),H=M[2].replace(/^<\//,"").replace(/>$/,"");return m(l[O],H)}return m(C)}}function m(C,E){if(C){if(E!==void 0){const M=`def Mesh "${E}"`;if(M in C)return C[M]}for(const M in C){const O=C[M];if(M.startsWith("def Mesh"))return"point3f[] points"in C&&(O["point3f[] points"]=C["point3f[] points"]),"texCoord2f[] primvars:st"in C&&(O["texCoord2f[] primvars:st"]=C["texCoord2f[] primvars:st"]),"int[] primvars:st:indices"in C&&(O["int[] primvars:st:indices"]=C["int[] primvars:st:indices"]),O;if(typeof O=="object"){const H=m(O);if(H)return H}}}}function g(C){if(!C)return;let E=new tn;if("int[] faceVertexIndices"in C){const M=JSON.parse(C["int[] faceVertexIndices"]);E.setIndex(M)}if("point3f[] points"in C){const M=JSON.parse(C["point3f[] points"].replace(/[()]*/g,"")),O=new Nt(new Float32Array(M),3);E.setAttribute("position",O)}if("normal3f[] normals"in C){const M=JSON.parse(C["normal3f[] normals"].replace(/[()]*/g,"")),O=new Nt(new Float32Array(M),3);E.setAttribute("normal",O)}else E.computeVertexNormals();if("float2[] primvars:st"in C&&(C["texCoord2f[] primvars:st"]=C["float2[] primvars:st"]),"texCoord2f[] primvars:st"in C){const M=JSON.parse(C["texCoord2f[] primvars:st"].replace(/[()]*/g,"")),O=new Nt(new Float32Array(M),2);if("int[] primvars:st:indices"in C){E=E.toNonIndexed();const H=JSON.parse(C["int[] primvars:st:indices"]);E.setAttribute("uv",y(O,H))}else E.setAttribute("uv",O)}return E}function y(C,E){const M=C.array,O=C.itemSize,H=new M.constructor(E.length*O);let G=0,Y=0;for(let $=0,re=E.length;$<re;$++){G=E[$]*O;for(let se=0;se<O;se++)H[Y++]=M[G++]}return new Nt(H,O)}function S(C){if(C){if("rel material:binding"in C){const O=C["rel material:binding"].replace(/^<\//,"").replace(/>$/,"").split("/");return _(d,` "${O[1]}"`)}return _(C)}}function _(C,E=""){for(const M in C){const O=C[M];if(M.startsWith("def Material"+E))return O;if(typeof O=="object"){const H=_(O,E);if(H)return H}}}function v(C,E){E["float inputs:rotation"]&&(C.rotation=parseFloat(E["float inputs:rotation"])),E["float2 inputs:scale"]&&(C.repeat=new Pe().fromArray(JSON.parse("["+E["float2 inputs:scale"].replace(/[()]*/g,"")+"]"))),E["float2 inputs:translation"]&&(C.offset=new Pe().fromArray(JSON.parse("["+E["float2 inputs:translation"].replace(/[()]*/g,"")+"]")))}function R(C){const E=new sr;if(C!==void 0){if('def Shader "PreviewSurface"'in C){const M=C['def Shader "PreviewSurface"'];if("color3f inputs:diffuseColor.connect"in M){const O=M["color3f inputs:diffuseColor.connect"],H=b(d,/(\w+).output/.exec(O)[1]);E.map=A(H),E.map.colorSpace=on,'def Shader "Transform2d_diffuse"'in C&&v(E.map,C['def Shader "Transform2d_diffuse"'])}else if("color3f inputs:diffuseColor"in M){const O=M["color3f inputs:diffuseColor"].replace(/[()]*/g,"");E.color.fromArray(JSON.parse("["+O+"]"))}if("color3f inputs:emissiveColor.connect"in M){const O=M["color3f inputs:emissiveColor.connect"],H=b(d,/(\w+).output/.exec(O)[1]);E.emissiveMap=A(H),E.emissiveMap.colorSpace=on,E.emissive.set(16777215),'def Shader "Transform2d_emissive"'in C&&v(E.emissiveMap,C['def Shader "Transform2d_emissive"'])}else if("color3f inputs:emissiveColor"in M){const O=M["color3f inputs:emissiveColor"].replace(/[()]*/g,"");E.emissive.fromArray(JSON.parse("["+O+"]"))}if("normal3f inputs:normal.connect"in M){const O=M["normal3f inputs:normal.connect"],H=b(d,/(\w+).output/.exec(O)[1]);E.normalMap=A(H),E.normalMap.colorSpace=Sn,'def Shader "Transform2d_normal"'in C&&v(E.normalMap,C['def Shader "Transform2d_normal"'])}if("float inputs:roughness.connect"in M){const O=M["float inputs:roughness.connect"],H=b(d,/(\w+).output/.exec(O)[1]);E.roughness=1,E.roughnessMap=A(H),E.roughnessMap.colorSpace=Sn,'def Shader "Transform2d_roughness"'in C&&v(E.roughnessMap,C['def Shader "Transform2d_roughness"'])}else"float inputs:roughness"in M&&(E.roughness=parseFloat(M["float inputs:roughness"]));if("float inputs:metallic.connect"in M){const O=M["float inputs:metallic.connect"],H=b(d,/(\w+).output/.exec(O)[1]);E.metalness=1,E.metalnessMap=A(H),E.metalnessMap.colorSpace=Sn,'def Shader "Transform2d_metallic"'in C&&v(E.metalnessMap,C['def Shader "Transform2d_metallic"'])}else"float inputs:metallic"in M&&(E.metalness=parseFloat(M["float inputs:metallic"]));if("float inputs:clearcoat.connect"in M){const O=M["float inputs:clearcoat.connect"],H=b(d,/(\w+).output/.exec(O)[1]);E.clearcoat=1,E.clearcoatMap=A(H),E.clearcoatMap.colorSpace=Sn,'def Shader "Transform2d_clearcoat"'in C&&v(E.clearcoatMap,C['def Shader "Transform2d_clearcoat"'])}else"float inputs:clearcoat"in M&&(E.clearcoat=parseFloat(M["float inputs:clearcoat"]));if("float inputs:clearcoatRoughness.connect"in M){const O=M["float inputs:clearcoatRoughness.connect"],H=b(d,/(\w+).output/.exec(O)[1]);E.clearcoatRoughness=1,E.clearcoatRoughnessMap=A(H),E.clearcoatRoughnessMap.colorSpace=Sn,'def Shader "Transform2d_clearcoatRoughness"'in C&&v(E.clearcoatRoughnessMap,C['def Shader "Transform2d_clearcoatRoughness"'])}else"float inputs:clearcoatRoughness"in M&&(E.clearcoatRoughness=parseFloat(M["float inputs:clearcoatRoughness"]));if("float inputs:ior"in M&&(E.ior=parseFloat(M["float inputs:ior"])),"float inputs:occlusion.connect"in M){const O=M["float inputs:occlusion.connect"],H=b(d,/(\w+).output/.exec(O)[1]);E.aoMap=A(H),E.aoMap.colorSpace=Sn,'def Shader "Transform2d_occlusion"'in C&&v(E.aoMap,C['def Shader "Transform2d_occlusion"'])}}if('def Shader "diffuseColor_texture"'in C){const M=C['def Shader "diffuseColor_texture"'];E.map=A(M),E.map.colorSpace=on}if('def Shader "normal_texture"'in C){const M=C['def Shader "normal_texture"'];E.normalMap=A(M),E.normalMap.colorSpace=Sn}}return E}function b(C,E){for(const M in C){const O=C[M];if(M.startsWith(`def Shader "${E}"`))return O;if(typeof O=="object"){const H=b(O,E);if(H)return H}}}function A(C){if("asset inputs:file"in C){const E=C["asset inputs:file"].replace(/@*/g,""),O=new N0().load(l[E]),H={'"clamp"':$i,'"mirror"':Co,'"repeat"':es};return"token inputs:wrapS"in C&&(O.wrapS=H[C["token inputs:wrapS"]]),"token inputs:wrapT"in C&&(O.wrapT=H[C["token inputs:wrapT"]]),O}return null}function B(C){const E=g(p(C)),M=R(S(C)),O=E?new Se(E,M):new gt;if("matrix4d xformOp:transform"in C){const H=JSON.parse("["+C["matrix4d xformOp:transform"].replace(/[()]*/g,"")+"]");O.matrix.fromArray(H),O.matrix.decompose(O.position,O.quaternion,O.scale)}return O}function N(C,E){for(const M in C)if(M.startsWith("def Scope"))N(C[M],E);else if(M.startsWith("def Xform")){const O=B(C[M]);/def Xform "(\w+)"/.test(M)&&(O.name=/def Xform "(\w+)"/.exec(M)[1]),E.add(O),N(C[M],O)}}const D=new Qi;return N(d,D),D}}const KI={glb:{key:"glb",extension:"glb"},gltf:{key:"gltf",extension:"gltf"},usdz:{key:"usdz",extension:"usdz"}},Ul=Object.values(KI).map(i=>i.extension);class D_ extends Error{constructor(e,t){super(e),this.cause=t,this.name="ConversionError"}}class Nl extends Error{constructor(e){super(e),this.name="FileTypeError"}}class Jh extends Error{constructor(e,t,n){super(t),this.url=e,this.cause=n,this.name="NetworkError"}}class Z0{_gltfLoader;_usdzLoader;constructor(){this._gltfLoader=new YL,this._usdzLoader=new $I}async load(e){const t=e.split(".").pop()?.toLowerCase();if(!t)throw new Nl("No file extension found in URI");if(!Ul.includes(t))throw new Nl(`Unsupported file type: ${t}. Supported types: ${Ul.join(", ")}`);switch(t){case"glb":case"gltf":return(await this._gltfLoader.loadAsync(e)).scene;case"usdz":return await this._usdzLoader.loadAsync(e)}}}class nd extends gt{isDIVERoot=!0;loader;constructor(){super(),this.name="Root",this.loader=new Z0}ComputeSceneBB(){const e=new zi;return this.traverse(t=>{"isObject3D"in t&&e.expandByObject(t)}),e}GetSceneObject(e){let t;return this.traverse(n=>{t||n.userData.id===e.id&&(t=n)}),t}AddSceneObject(e){switch(e.entityType){case"pov":break;case"light":{this.updateLight(e);break}case"model":{this.updateModel(e);break}case"primitive":{this.updatePrimitive(e);break}case"group":{this.updateGroup(e);break}default:console.warn(`DIVERoot.AddSceneObject: Unknown entity type: ${e.entityType}`)}}UpdateSceneObject(e){switch(e.entityType){case"pov":break;case"light":{this.updateLight(e);break}case"model":{this.updateModel(e);break}case"primitive":{this.updatePrimitive(e);break}case"group":{this.updateGroup(e);break}default:console.warn(`DIVERoot.UpdateSceneObject: Unknown entity type: ${e.entityType}`)}}DeleteSceneObject(e){switch(e.entityType){case"pov":break;case"light":{this.deleteLight(e);break}case"model":{this.deleteModel(e);break}case"primitive":{this.deletePrimitive(e);break}case"group":{this.deleteGroup(e);break}default:console.warn(`DIVERoot.DeleteSceneObject: Unknown entity type: ${e.entityType}`)}}PlaceOnFloor(e){switch(e.entityType){case"pov":case"light":break;case"model":case"primitive":{this.placeOnFloor(e);break}default:console.warn(`DIVERoot.PlaceOnFloor: Unknown entity type: ${e.entityType}`)}}updateLight(e){let t=this.GetSceneObject(e);if(!t){switch(e.type){case"scene":{t=new zL;break}case"ambient":{t=new SL;break}case"point":{t=new BL;break}default:{console.warn(`DIVERoot.updateLight: Unknown light type: ${e.type}`);return}}t.userData.id=e.id,this.add(t)}e.name!==void 0&&e.name!==null&&(t.name=e.name),e.position!==void 0&&e.position!==null&&t.position.set(e.position.x,e.position.y,e.position.z),e.intensity!==void 0&&e.intensity!==null&&t.SetIntensity(e.intensity),e.enabled!==void 0&&e.enabled!==null&&t.SetEnabled(e.enabled),e.color!==void 0&&e.color!==null&&t.SetColor(new Oe(e.color)),e.visible!==void 0&&e.visible!==null&&(t.visible=e.visible),e.parentId!==void 0&&this.setParent({...e,parentId:e.parentId})}updateModel(e){let t=this.GetSceneObject(e);t||(t=new VL,t.userData.id=e.id,t.userData.uri=e.uri,this.add(t)),e.uri!==void 0&&this.loader.load(e.uri).then(n=>{t.SetModel(n),On.get(e.id)?.PerformAction("MODEL_LOADED",{id:e.id})}),e.name!==void 0&&(t.name=e.name),e.position!==void 0&&t.SetPosition(e.position),e.rotation!==void 0&&t.SetRotation(e.rotation),e.scale!==void 0&&t.SetScale(e.scale),e.visible!==void 0&&t.SetVisibility(e.visible),e.material!==void 0&&t.SetMaterial(e.material),e.parentId!==void 0&&this.setParent({...e,parentId:e.parentId})}updatePrimitive(e){let t=this.GetSceneObject(e);t||(t=new WL,t.userData.id=e.id,this.add(t)),e.name!==void 0&&(t.name=e.name),e.geometry!==void 0&&t.SetGeometry(e.geometry),e.position!==void 0&&t.SetPosition(e.position),e.rotation!==void 0&&t.SetRotation(e.rotation),e.scale!==void 0&&t.SetScale(e.scale),e.visible!==void 0&&t.SetVisibility(e.visible),e.material!==void 0&&t.SetMaterial(e.material),e.parentId!==void 0&&this.setParent({...e,parentId:e.parentId})}updateGroup(e){let t=this.GetSceneObject(e);t||(t=new XL,t.userData.id=e.id,this.add(t)),e.name!==void 0&&(t.name=e.name),e.position!==void 0&&t.SetPosition(e.position),e.rotation!==void 0&&t.SetRotation(e.rotation),e.scale!==void 0&&t.SetScale(e.scale),e.visible!==void 0&&t.SetVisibility(e.visible),e.bbVisible!==void 0&&t.SetLinesVisibility(e.bbVisible),e.parentId!==void 0&&this.setParent({...e,parentId:e.parentId})}deleteLight(e){const t=this.GetSceneObject(e);if(!t){console.warn(`DIVERoot.deleteLight: Light with id ${e.id} not found`);return}this.detachTransformControls(t),t.parent.remove(t)}deleteModel(e){const t=this.GetSceneObject(e);if(!t){console.warn(`DIVERoot.deleteModel: Model with id ${e.id} not found`);return}this.detachTransformControls(t),t.parent.remove(t)}deletePrimitive(e){const t=this.GetSceneObject(e);if(!t){console.warn(`DIVERoot.deletePrimitive: Primitive with id ${e.id} not found`);return}this.detachTransformControls(t),t.parent.remove(t)}deleteGroup(e){const t=this.GetSceneObject(e);if(!t){console.warn(`DIVERoot.deleteGroup: Group with id ${e.id} not found`);return}this.detachTransformControls(t);for(let n=t.members.length-1;n>=0;n--)this.attach(t.members[n]);t.parent.remove(t)}placeOnFloor(e){const t=this.GetSceneObject(e);t&&t.PlaceOnFloor()}setParent(e){const t=this.GetSceneObject(e);if(t)if(e.parentId!==null){const n=this.GetSceneObject({id:e.parentId});if(!n)return;n.attach(t)}else this.attach(t)}detachTransformControls(e){this.findScene(e).children.find(t=>{"isTransformControls"in t&&t.detach()})}findScene(e){return e.parent!==null?this.findScene(e.parent):e}}const ZI="#888888",JI="#dddddd";class QI extends gt{constructor(){super(),this.name="Grid";const e=new xL(100,100,ZI,JI);e.material.depthTest=!1,e.layers.mask=F0,this.add(e)}SetVisibility(e){this.visible=e}}class e2 extends Se{isFloor=!0;constructor(){super(new ns(1e4,1e4),new zo({color:new Oe(150/255,150/255,150/255)})),this.name="Floor",this.layers.mask=li,this.receiveShadow=!0,this.rotateX(-Math.PI/2)}SetVisibility(e){this.visible=e}SetColor(e){this.material.color=new Oe(e)}}class t2{constructor(e,t,n,r,o){this.xrLight=e,this.renderer=t,this.lightProbe=n,this.xrWebGLBinding=null,this.estimationStartCallback=o,this.frameCallback=this.onXRFrame.bind(this);const a=t.xr.getSession();if(r&&"XRWebGLBinding"in window){const l=new v0(16);e.environment=l.texture;const u=t.getContext();switch(a.preferredReflectionFormat){case"srgba8":u.getExtension("EXT_sRGB");break;case"rgba16f":u.getExtension("OES_texture_half_float");break}this.xrWebGLBinding=new XRWebGLBinding(a,u),this.lightProbe.addEventListener("reflectionchange",()=>{this.updateReflection()})}a.requestAnimationFrame(this.frameCallback)}updateReflection(){const e=this.renderer.properties.get(this.xrLight.environment);if(e){const t=this.xrWebGLBinding.getReflectionCubeMap(this.lightProbe);t&&(e.__webglTexture=t,this.xrLight.environment.needsPMREMUpdate=!0)}}onXRFrame(e,t){if(!this.xrLight)return;t.session.requestAnimationFrame(this.frameCallback);const r=t.getLightEstimate(this.lightProbe);if(r){this.xrLight.lightProbe.sh.fromArray(r.sphericalHarmonicsCoefficients),this.xrLight.lightProbe.intensity=1;const o=Math.max(1,Math.max(r.primaryLightIntensity.x,Math.max(r.primaryLightIntensity.y,r.primaryLightIntensity.z)));this.xrLight.directionalLight.color.setRGB(r.primaryLightIntensity.x/o,r.primaryLightIntensity.y/o,r.primaryLightIntensity.z/o),this.xrLight.directionalLight.intensity=o,this.xrLight.directionalLight.position.copy(r.primaryLightDirection),this.estimationStartCallback&&(this.estimationStartCallback(),this.estimationStartCallback=null)}}dispose(){this.xrLight=null,this.renderer=null,this.lightProbe=null,this.xrWebGLBinding=null}}class n2 extends Qi{constructor(e,t=!0){super(),this.lightProbe=new cL,this.lightProbe.intensity=0,this.add(this.lightProbe),this.directionalLight=new jf,this.directionalLight.intensity=0,this.add(this.directionalLight),this.environment=null;let n=null,r=!1;e.xr.addEventListener("sessionstart",()=>{const o=e.xr.getSession();"requestLightProbe"in o&&o.requestLightProbe({reflectionFormat:o.preferredReflectionFormat}).then(a=>{n=new t2(this,e,a,t,()=>{r=!0,this.dispatchEvent({type:"estimationstart"})})})}),e.xr.addEventListener("sessionend",()=>{n&&(n.dispose(),n=null),r&&this.dispatchEvent({type:"estimationend"})}),this.dispose=()=>{n&&(n.dispose(),n=null),this.remove(this.lightProbe),this.lightProbe=null,this.remove(this.directionalLight),this.directionalLight=null,this.environment=null}}}class i2 extends gt{_scene;_xrLight;_lightRoot;constructor(e){super(),this.name="XRLightRoot",this._scene=e,this._xrLight=null,this._lightRoot=new nd,this._lightRoot.UpdateSceneObject({id:"XRSceneLight",entityType:"light",name:"XRSceneLight",type:"scene",color:16777215,intensity:1,enabled:!0,visible:!0}),this.add(this._lightRoot)}InitLightEstimation(e){this._xrLight||(this._xrLight=new n2(e,!0),this._xrLight.layers.mask=li,this.add(this._xrLight)),this._xrLight.addEventListener("estimationstart",()=>{this.onEstimationStart()}),this._xrLight.addEventListener("estimationend",()=>{this.onEstimationEnd()})}DisposeLightEstimation(){this._xrLight&&(this._xrLight.removeEventListener("estimationstart",()=>{this.onEstimationStart()}),this._xrLight.removeEventListener("estimationend",()=>{this.onEstimationEnd()}))}onEstimationStart(){this._lightRoot.visible=!1,this._xrLight&&this._xrLight.environment&&(this._scene.environment=this._xrLight.environment)}onEstimationEnd(){this._lightRoot.visible=!0,this._scene.environment=null,this._xrLight}}class r2 extends gt{_xrLightRoot;_xrModelRoot;_xrHandNode;get XRModelRoot(){return this._xrModelRoot}get XRLightRoot(){return this._xrLightRoot}get XRHandNode(){return this._xrHandNode}_xrShadowPlane;constructor(e){super(),this.name="XRRoot",this._xrModelRoot=new nd,this._xrModelRoot.name="XRModelRoot",this.add(this._xrModelRoot),this._xrShadowPlane=new Se(new ns(100,100),new kP({opacity:1,transparent:!0})),this._xrModelRoot.add(this._xrShadowPlane),this._xrLightRoot=new i2(e),this._xrLightRoot.name="XRLightRoot",this.add(this._xrLightRoot),this._xrHandNode=new gt,this._xrHandNode.name="XRHandNode",this.add(this._xrHandNode)}InitLightEstimation(e){this._xrLightRoot.InitLightEstimation(e)}DisposeLightEstimation(){this._xrLightRoot.DisposeLightEstimation()}}class s2 extends Pl{_root;_floor;_grid;get Root(){return this._root}_xrRoot;get XRRoot(){return this._xrRoot}get Floor(){return this._floor}get Grid(){return this._grid}constructor(){super(),this.background=new Oe(16777215),this._root=new nd,this.add(this._root),this._floor=new e2,this.add(this._floor),this._grid=new QI,this.add(this._grid),this._xrRoot=new r2(this),this._xrRoot.visible=!1,this.add(this._xrRoot)}InitXR(e){this._root.visible=!1,this._xrRoot.visible=!0,this._xrRoot.InitLightEstimation(e)}DisposeXR(){this._root.visible=!0,this._xrRoot.visible=!1,this._xrRoot.DisposeLightEstimation()}SetBackground(e){this.background=new Oe(e)}ComputeSceneBB(){return this.Root.ComputeSceneBB()}GetSceneObject(e){return this.Root.GetSceneObject(e)}AddSceneObject(e){this.Root.AddSceneObject(e)}UpdateSceneObject(e){this.Root.UpdateSceneObject(e)}DeleteSceneObject(e){this.Root.DeleteSceneObject(e)}PlaceOnFloor(e){this.Root.PlaceOnFloor(e)}}const Ca={fov:70,near:.1,far:1e3};class Fa extends Un{static EDITOR_VIEW_LAYER_MASK=ML|Zf|F0|li;static LIVE_VIEW_LAYER_MASK=li;onSetCameraLayer=()=>{};constructor(e=Ca){super(e.fov||Ca.fov,1,e.near||Ca.near,e.far||Ca.far),this.layers.mask=Fa.EDITOR_VIEW_LAYER_MASK}OnResize(e,t){this.aspect=e/t,this.updateProjectionMatrix()}SetCameraLayer(e){this.layers.mask=e==="LIVE"?Fa.LIVE_VIEW_LAYER_MASK:Fa.EDITOR_VIEW_LAYER_MASK,this.onSetCameraLayer(this.layers.mask)}}const U_={type:"change"},Qh={type:"start"},N_={type:"end"},ml=new Oo,O_=new $r,o2=Math.cos(70*ci.DEG2RAD);class a2 extends Ps{constructor(e,t){super(),this.object=e,this.domElement=t,this.domElement.style.touchAction="none",this.enabled=!0,this.target=new F,this.cursor=new F,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:js.ROTATE,MIDDLE:js.DOLLY,RIGHT:js.PAN},this.touches={ONE:qs.ROTATE,TWO:qs.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this.getPolarAngle=function(){return l.phi},this.getAzimuthalAngle=function(){return l.theta},this.getDistance=function(){return this.object.position.distanceTo(this.target)},this.listenToKeyEvents=function(T){T.addEventListener("keydown",we),this._domElementKeyEvents=T},this.stopListenToKeyEvents=function(){this._domElementKeyEvents.removeEventListener("keydown",we),this._domElementKeyEvents=null},this.saveState=function(){n.target0.copy(n.target),n.position0.copy(n.object.position),n.zoom0=n.object.zoom},this.reset=function(){n.target.copy(n.target0),n.object.position.copy(n.position0),n.object.zoom=n.zoom0,n.object.updateProjectionMatrix(),n.dispatchEvent(U_),n.update(),o=r.NONE},this.update=function(){const T=new F,Z=new an().setFromUnitVectors(e.up,new F(0,1,0)),ce=Z.clone().invert(),ye=new F,Re=new an,vt=new F,dt=2*Math.PI;return function(ln=null){const Rt=n.object.position;T.copy(Rt).sub(n.target),T.applyQuaternion(Z),l.setFromVector3(T),n.autoRotate&&o===r.NONE&&H(M(ln)),n.enableDamping?(l.theta+=u.theta*n.dampingFactor,l.phi+=u.phi*n.dampingFactor):(l.theta+=u.theta,l.phi+=u.phi);let Zt=n.minAzimuthAngle,Jt=n.maxAzimuthAngle;isFinite(Zt)&&isFinite(Jt)&&(Zt<-Math.PI?Zt+=dt:Zt>Math.PI&&(Zt-=dt),Jt<-Math.PI?Jt+=dt:Jt>Math.PI&&(Jt-=dt),Zt<=Jt?l.theta=Math.max(Zt,Math.min(Jt,l.theta)):l.theta=l.theta>(Zt+Jt)/2?Math.max(Zt,l.theta):Math.min(Jt,l.theta)),l.phi=Math.max(n.minPolarAngle,Math.min(n.maxPolarAngle,l.phi)),l.makeSafe(),n.enableDamping===!0?n.target.addScaledVector(d,n.dampingFactor):n.target.add(d),n.target.sub(n.cursor),n.target.clampLength(n.minTargetRadius,n.maxTargetRadius),n.target.add(n.cursor);let Fn=!1;if(n.zoomToCursor&&N||n.object.isOrthographicCamera)l.radius=pe(l.radius);else{const bn=l.radius;l.radius=pe(l.radius*h),Fn=bn!=l.radius}if(T.setFromSpherical(l),T.applyQuaternion(ce),Rt.copy(n.target).add(T),n.object.lookAt(n.target),n.enableDamping===!0?(u.theta*=1-n.dampingFactor,u.phi*=1-n.dampingFactor,d.multiplyScalar(1-n.dampingFactor)):(u.set(0,0,0),d.set(0,0,0)),n.zoomToCursor&&N){let bn=null;if(n.object.isPerspectiveCamera){const ki=T.length();bn=pe(ki*h);const Hi=ki-bn;n.object.position.addScaledVector(A,Hi),n.object.updateMatrixWorld(),Fn=!!Hi}else if(n.object.isOrthographicCamera){const ki=new F(B.x,B.y,0);ki.unproject(n.object);const Hi=n.object.zoom;n.object.zoom=Math.max(n.minZoom,Math.min(n.maxZoom,n.object.zoom/h)),n.object.updateProjectionMatrix(),Fn=Hi!==n.object.zoom;const ar=new F(B.x,B.y,0);ar.unproject(n.object),n.object.position.sub(ar).add(ki),n.object.updateMatrixWorld(),bn=T.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),n.zoomToCursor=!1;bn!==null&&(this.screenSpacePanning?n.target.set(0,0,-1).transformDirection(n.object.matrix).multiplyScalar(bn).add(n.object.position):(ml.origin.copy(n.object.position),ml.direction.set(0,0,-1).transformDirection(n.object.matrix),Math.abs(n.object.up.dot(ml.direction))<o2?e.lookAt(n.target):(O_.setFromNormalAndCoplanarPoint(n.object.up,n.target),ml.intersectPlane(O_,n.target))))}else if(n.object.isOrthographicCamera){const bn=n.object.zoom;n.object.zoom=Math.max(n.minZoom,Math.min(n.maxZoom,n.object.zoom/h)),bn!==n.object.zoom&&(n.object.updateProjectionMatrix(),Fn=!0)}return h=1,N=!1,Fn||ye.distanceToSquared(n.object.position)>a||8*(1-Re.dot(n.object.quaternion))>a||vt.distanceToSquared(n.target)>a?(n.dispatchEvent(U_),ye.copy(n.object.position),Re.copy(n.object.quaternion),vt.copy(n.target),!0):!1}}(),this.dispose=function(){n.domElement.removeEventListener("contextmenu",Ie),n.domElement.removeEventListener("pointerdown",ie),n.domElement.removeEventListener("pointercancel",de),n.domElement.removeEventListener("wheel",_e),n.domElement.removeEventListener("pointermove",le),n.domElement.removeEventListener("pointerup",de),n.domElement.getRootNode().removeEventListener("keydown",Xe,{capture:!0}),n._domElementKeyEvents!==null&&(n._domElementKeyEvents.removeEventListener("keydown",we),n._domElementKeyEvents=null)};const n=this,r={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6};let o=r.NONE;const a=1e-6,l=new f_,u=new f_;let h=1;const d=new F,p=new Pe,m=new Pe,g=new Pe,y=new Pe,S=new Pe,_=new Pe,v=new Pe,R=new Pe,b=new Pe,A=new F,B=new Pe;let N=!1;const D=[],C={};let E=!1;function M(T){return T!==null?2*Math.PI/60*n.autoRotateSpeed*T:2*Math.PI/60/60*n.autoRotateSpeed}function O(T){const Z=Math.abs(T*.01);return Math.pow(.95,n.zoomSpeed*Z)}function H(T){u.theta-=T}function G(T){u.phi-=T}const Y=function(){const T=new F;return function(ce,ye){T.setFromMatrixColumn(ye,0),T.multiplyScalar(-ce),d.add(T)}}(),$=function(){const T=new F;return function(ce,ye){n.screenSpacePanning===!0?T.setFromMatrixColumn(ye,1):(T.setFromMatrixColumn(ye,0),T.crossVectors(n.object.up,T)),T.multiplyScalar(ce),d.add(T)}}(),re=function(){const T=new F;return function(ce,ye){const Re=n.domElement;if(n.object.isPerspectiveCamera){const vt=n.object.position;T.copy(vt).sub(n.target);let dt=T.length();dt*=Math.tan(n.object.fov/2*Math.PI/180),Y(2*ce*dt/Re.clientHeight,n.object.matrix),$(2*ye*dt/Re.clientHeight,n.object.matrix)}else n.object.isOrthographicCamera?(Y(ce*(n.object.right-n.object.left)/n.object.zoom/Re.clientWidth,n.object.matrix),$(ye*(n.object.top-n.object.bottom)/n.object.zoom/Re.clientHeight,n.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),n.enablePan=!1)}}();function se(T){n.object.isPerspectiveCamera||n.object.isOrthographicCamera?h/=T:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),n.enableZoom=!1)}function K(T){n.object.isPerspectiveCamera||n.object.isOrthographicCamera?h*=T:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),n.enableZoom=!1)}function ae(T,Z){if(!n.zoomToCursor)return;N=!0;const ce=n.domElement.getBoundingClientRect(),ye=T-ce.left,Re=Z-ce.top,vt=ce.width,dt=ce.height;B.x=ye/vt*2-1,B.y=-(Re/dt)*2+1,A.set(B.x,B.y,1).unproject(n.object).sub(n.object.position).normalize()}function pe(T){return Math.max(n.minDistance,Math.min(n.maxDistance,T))}function ve(T){p.set(T.clientX,T.clientY)}function ke(T){ae(T.clientX,T.clientX),v.set(T.clientX,T.clientY)}function Ze(T){y.set(T.clientX,T.clientY)}function te(T){m.set(T.clientX,T.clientY),g.subVectors(m,p).multiplyScalar(n.rotateSpeed);const Z=n.domElement;H(2*Math.PI*g.x/Z.clientHeight),G(2*Math.PI*g.y/Z.clientHeight),p.copy(m),n.update()}function fe(T){R.set(T.clientX,T.clientY),b.subVectors(R,v),b.y>0?se(O(b.y)):b.y<0&&K(O(b.y)),v.copy(R),n.update()}function Ee(T){S.set(T.clientX,T.clientY),_.subVectors(S,y).multiplyScalar(n.panSpeed),re(_.x,_.y),y.copy(S),n.update()}function Me(T){ae(T.clientX,T.clientY),T.deltaY<0?K(O(T.deltaY)):T.deltaY>0&&se(O(T.deltaY)),n.update()}function ze(T){let Z=!1;switch(T.code){case n.keys.UP:T.ctrlKey||T.metaKey||T.shiftKey?G(2*Math.PI*n.rotateSpeed/n.domElement.clientHeight):re(0,n.keyPanSpeed),Z=!0;break;case n.keys.BOTTOM:T.ctrlKey||T.metaKey||T.shiftKey?G(-2*Math.PI*n.rotateSpeed/n.domElement.clientHeight):re(0,-n.keyPanSpeed),Z=!0;break;case n.keys.LEFT:T.ctrlKey||T.metaKey||T.shiftKey?H(2*Math.PI*n.rotateSpeed/n.domElement.clientHeight):re(n.keyPanSpeed,0),Z=!0;break;case n.keys.RIGHT:T.ctrlKey||T.metaKey||T.shiftKey?H(-2*Math.PI*n.rotateSpeed/n.domElement.clientHeight):re(-n.keyPanSpeed,0),Z=!0;break}Z&&(T.preventDefault(),n.update())}function Ve(T){if(D.length===1)p.set(T.pageX,T.pageY);else{const Z=Tt(T),ce=.5*(T.pageX+Z.x),ye=.5*(T.pageY+Z.y);p.set(ce,ye)}}function it(T){if(D.length===1)y.set(T.pageX,T.pageY);else{const Z=Tt(T),ce=.5*(T.pageX+Z.x),ye=.5*(T.pageY+Z.y);y.set(ce,ye)}}function q(T){const Z=Tt(T),ce=T.pageX-Z.x,ye=T.pageY-Z.y,Re=Math.sqrt(ce*ce+ye*ye);v.set(0,Re)}function $e(T){n.enableZoom&&q(T),n.enablePan&&it(T)}function Fe(T){n.enableZoom&&q(T),n.enableRotate&&Ve(T)}function mt(T){if(D.length==1)m.set(T.pageX,T.pageY);else{const ce=Tt(T),ye=.5*(T.pageX+ce.x),Re=.5*(T.pageY+ce.y);m.set(ye,Re)}g.subVectors(m,p).multiplyScalar(n.rotateSpeed);const Z=n.domElement;H(2*Math.PI*g.x/Z.clientHeight),G(2*Math.PI*g.y/Z.clientHeight),p.copy(m)}function We(T){if(D.length===1)S.set(T.pageX,T.pageY);else{const Z=Tt(T),ce=.5*(T.pageX+Z.x),ye=.5*(T.pageY+Z.y);S.set(ce,ye)}_.subVectors(S,y).multiplyScalar(n.panSpeed),re(_.x,_.y),y.copy(S)}function At(T){const Z=Tt(T),ce=T.pageX-Z.x,ye=T.pageY-Z.y,Re=Math.sqrt(ce*ce+ye*ye);R.set(0,Re),b.set(0,Math.pow(R.y/v.y,n.zoomSpeed)),se(b.y),v.copy(R);const vt=(T.pageX+Z.x)*.5,dt=(T.pageY+Z.y)*.5;ae(vt,dt)}function z(T){n.enableZoom&&At(T),n.enablePan&&We(T)}function P(T){n.enableZoom&&At(T),n.enableRotate&&mt(T)}function ie(T){n.enabled!==!1&&(D.length===0&&(n.domElement.setPointerCapture(T.pointerId),n.domElement.addEventListener("pointermove",le),n.domElement.addEventListener("pointerup",de)),!Et(T)&&(ct(T),T.pointerType==="touch"?Ke(T):ge(T)))}function le(T){n.enabled!==!1&&(T.pointerType==="touch"?Le(T):He(T))}function de(T){switch(ft(T),D.length){case 0:n.domElement.releasePointerCapture(T.pointerId),n.domElement.removeEventListener("pointermove",le),n.domElement.removeEventListener("pointerup",de),n.dispatchEvent(N_),o=r.NONE;break;case 1:const Z=D[0],ce=C[Z];Ke({pointerId:Z,pageX:ce.x,pageY:ce.y});break}}function ge(T){let Z;switch(T.button){case 0:Z=n.mouseButtons.LEFT;break;case 1:Z=n.mouseButtons.MIDDLE;break;case 2:Z=n.mouseButtons.RIGHT;break;default:Z=-1}switch(Z){case js.DOLLY:if(n.enableZoom===!1)return;ke(T),o=r.DOLLY;break;case js.ROTATE:if(T.ctrlKey||T.metaKey||T.shiftKey){if(n.enablePan===!1)return;Ze(T),o=r.PAN}else{if(n.enableRotate===!1)return;ve(T),o=r.ROTATE}break;case js.PAN:if(T.ctrlKey||T.metaKey||T.shiftKey){if(n.enableRotate===!1)return;ve(T),o=r.ROTATE}else{if(n.enablePan===!1)return;Ze(T),o=r.PAN}break;default:o=r.NONE}o!==r.NONE&&n.dispatchEvent(Qh)}function He(T){switch(o){case r.ROTATE:if(n.enableRotate===!1)return;te(T);break;case r.DOLLY:if(n.enableZoom===!1)return;fe(T);break;case r.PAN:if(n.enablePan===!1)return;Ee(T);break}}function _e(T){n.enabled===!1||n.enableZoom===!1||o!==r.NONE||(T.preventDefault(),n.dispatchEvent(Qh),Me(De(T)),n.dispatchEvent(N_))}function De(T){const Z=T.deltaMode,ce={clientX:T.clientX,clientY:T.clientY,deltaY:T.deltaY};switch(Z){case 1:ce.deltaY*=16;break;case 2:ce.deltaY*=100;break}return T.ctrlKey&&!E&&(ce.deltaY*=10),ce}function Xe(T){T.key==="Control"&&(E=!0,n.domElement.getRootNode().addEventListener("keyup",xe,{passive:!0,capture:!0}))}function xe(T){T.key==="Control"&&(E=!1,n.domElement.getRootNode().removeEventListener("keyup",xe,{passive:!0,capture:!0}))}function we(T){n.enabled===!1||n.enablePan===!1||ze(T)}function Ke(T){switch(_t(T),D.length){case 1:switch(n.touches.ONE){case qs.ROTATE:if(n.enableRotate===!1)return;Ve(T),o=r.TOUCH_ROTATE;break;case qs.PAN:if(n.enablePan===!1)return;it(T),o=r.TOUCH_PAN;break;default:o=r.NONE}break;case 2:switch(n.touches.TWO){case qs.DOLLY_PAN:if(n.enableZoom===!1&&n.enablePan===!1)return;$e(T),o=r.TOUCH_DOLLY_PAN;break;case qs.DOLLY_ROTATE:if(n.enableZoom===!1&&n.enableRotate===!1)return;Fe(T),o=r.TOUCH_DOLLY_ROTATE;break;default:o=r.NONE}break;default:o=r.NONE}o!==r.NONE&&n.dispatchEvent(Qh)}function Le(T){switch(_t(T),o){case r.TOUCH_ROTATE:if(n.enableRotate===!1)return;mt(T),n.update();break;case r.TOUCH_PAN:if(n.enablePan===!1)return;We(T),n.update();break;case r.TOUCH_DOLLY_PAN:if(n.enableZoom===!1&&n.enablePan===!1)return;z(T),n.update();break;case r.TOUCH_DOLLY_ROTATE:if(n.enableZoom===!1&&n.enableRotate===!1)return;P(T),n.update();break;default:o=r.NONE}}function Ie(T){n.enabled!==!1&&T.preventDefault()}function ct(T){D.push(T.pointerId)}function ft(T){delete C[T.pointerId];for(let Z=0;Z<D.length;Z++)if(D[Z]==T.pointerId){D.splice(Z,1);return}}function Et(T){for(let Z=0;Z<D.length;Z++)if(D[Z]==T.pointerId)return!0;return!1}function _t(T){let Z=C[T.pointerId];Z===void 0&&(Z=new Pe,C[T.pointerId]=Z),Z.set(T.pageX,T.pageY)}function Tt(T){const Z=T.pointerId===D[0]?D[1]:D[0];return C[Z]}n.domElement.addEventListener("contextmenu",Ie),n.domElement.addEventListener("pointerdown",ie),n.domElement.addEventListener("pointercancel",de),n.domElement.addEventListener("wheel",_e,{passive:!1}),n.domElement.getRootNode().addEventListener("keydown",Xe,{passive:!0,capture:!0}),this.update()}}var wr=Object.freeze({Linear:Object.freeze({None:function(i){return i},In:function(i){return i},Out:function(i){return i},InOut:function(i){return i}}),Quadratic:Object.freeze({In:function(i){return i*i},Out:function(i){return i*(2-i)},InOut:function(i){return(i*=2)<1?.5*i*i:-.5*(--i*(i-2)-1)}}),Cubic:Object.freeze({In:function(i){return i*i*i},Out:function(i){return--i*i*i+1},InOut:function(i){return(i*=2)<1?.5*i*i*i:.5*((i-=2)*i*i+2)}}),Quartic:Object.freeze({In:function(i){return i*i*i*i},Out:function(i){return 1- --i*i*i*i},InOut:function(i){return(i*=2)<1?.5*i*i*i*i:-.5*((i-=2)*i*i*i-2)}}),Quintic:Object.freeze({In:function(i){return i*i*i*i*i},Out:function(i){return--i*i*i*i*i+1},InOut:function(i){return(i*=2)<1?.5*i*i*i*i*i:.5*((i-=2)*i*i*i*i+2)}}),Sinusoidal:Object.freeze({In:function(i){return 1-Math.sin((1-i)*Math.PI/2)},Out:function(i){return Math.sin(i*Math.PI/2)},InOut:function(i){return .5*(1-Math.sin(Math.PI*(.5-i)))}}),Exponential:Object.freeze({In:function(i){return i===0?0:Math.pow(1024,i-1)},Out:function(i){return i===1?1:1-Math.pow(2,-10*i)},InOut:function(i){return i===0?0:i===1?1:(i*=2)<1?.5*Math.pow(1024,i-1):.5*(-Math.pow(2,-10*(i-1))+2)}}),Circular:Object.freeze({In:function(i){return 1-Math.sqrt(1-i*i)},Out:function(i){return Math.sqrt(1- --i*i)},InOut:function(i){return(i*=2)<1?-.5*(Math.sqrt(1-i*i)-1):.5*(Math.sqrt(1-(i-=2)*i)+1)}}),Elastic:Object.freeze({In:function(i){return i===0?0:i===1?1:-Math.pow(2,10*(i-1))*Math.sin((i-1.1)*5*Math.PI)},Out:function(i){return i===0?0:i===1?1:Math.pow(2,-10*i)*Math.sin((i-.1)*5*Math.PI)+1},InOut:function(i){return i===0?0:i===1?1:(i*=2,i<1?-.5*Math.pow(2,10*(i-1))*Math.sin((i-1.1)*5*Math.PI):.5*Math.pow(2,-10*(i-1))*Math.sin((i-1.1)*5*Math.PI)+1)}}),Back:Object.freeze({In:function(i){var e=1.70158;return i===1?1:i*i*((e+1)*i-e)},Out:function(i){var e=1.70158;return i===0?0:--i*i*((e+1)*i+e)+1},InOut:function(i){var e=2.5949095;return(i*=2)<1?.5*(i*i*((e+1)*i-e)):.5*((i-=2)*i*((e+1)*i+e)+2)}}),Bounce:Object.freeze({In:function(i){return 1-wr.Bounce.Out(1-i)},Out:function(i){return i<1/2.75?7.5625*i*i:i<2/2.75?7.5625*(i-=1.5/2.75)*i+.75:i<2.5/2.75?7.5625*(i-=2.25/2.75)*i+.9375:7.5625*(i-=2.625/2.75)*i+.984375},InOut:function(i){return i<.5?wr.Bounce.In(i*2)*.5:wr.Bounce.Out(i*2-1)*.5+.5}}),generatePow:function(i){return i===void 0&&(i=4),i=i<Number.EPSILON?Number.EPSILON:i,i=i>1e4?1e4:i,{In:function(e){return Math.pow(e,i)},Out:function(e){return 1-Math.pow(1-e,i)},InOut:function(e){return e<.5?Math.pow(e*2,i)/2:(1-Math.pow(2-e*2,i))/2+.5}}}}),Pa=function(){return performance.now()},c2=function(){function i(){this._tweens={},this._tweensAddedDuringUpdate={}}return i.prototype.getAll=function(){var e=this;return Object.keys(this._tweens).map(function(t){return e._tweens[t]})},i.prototype.removeAll=function(){this._tweens={}},i.prototype.add=function(e){this._tweens[e.getId()]=e,this._tweensAddedDuringUpdate[e.getId()]=e},i.prototype.remove=function(e){delete this._tweens[e.getId()],delete this._tweensAddedDuringUpdate[e.getId()]},i.prototype.update=function(e,t){e===void 0&&(e=Pa()),t===void 0&&(t=!1);var n=Object.keys(this._tweens);if(n.length===0)return!1;for(;n.length>0;){this._tweensAddedDuringUpdate={};for(var r=0;r<n.length;r++){var o=this._tweens[n[r]],a=!t;o&&o.update(e,a)===!1&&!t&&delete this._tweens[n[r]]}n=Object.keys(this._tweensAddedDuringUpdate)}return!0},i}(),Af={Linear:function(i,e){var t=i.length-1,n=t*e,r=Math.floor(n),o=Af.Utils.Linear;return e<0?o(i[0],i[1],n):e>1?o(i[t],i[t-1],t-n):o(i[r],i[r+1>t?t:r+1],n-r)},Utils:{Linear:function(i,e,t){return(e-i)*t+i}}},J0=function(){function i(){}return i.nextId=function(){return i._nextId++},i._nextId=0,i}(),Rf=new c2,l2=function(){function i(e,t){t===void 0&&(t=Rf),this._object=e,this._group=t,this._isPaused=!1,this._pauseStart=0,this._valuesStart={},this._valuesEnd={},this._valuesStartRepeat={},this._duration=1e3,this._isDynamic=!1,this._initialRepeat=0,this._repeat=0,this._yoyo=!1,this._isPlaying=!1,this._reversed=!1,this._delayTime=0,this._startTime=0,this._easingFunction=wr.Linear.None,this._interpolationFunction=Af.Linear,this._chainedTweens=[],this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._id=J0.nextId(),this._isChainStopped=!1,this._propertiesAreSetUp=!1,this._goToEnd=!1}return i.prototype.getId=function(){return this._id},i.prototype.isPlaying=function(){return this._isPlaying},i.prototype.isPaused=function(){return this._isPaused},i.prototype.getDuration=function(){return this._duration},i.prototype.to=function(e,t){if(t===void 0&&(t=1e3),this._isPlaying)throw new Error("Can not call Tween.to() while Tween is already started or paused. Stop the Tween first.");return this._valuesEnd=e,this._propertiesAreSetUp=!1,this._duration=t<0?0:t,this},i.prototype.duration=function(e){return e===void 0&&(e=1e3),this._duration=e<0?0:e,this},i.prototype.dynamic=function(e){return e===void 0&&(e=!1),this._isDynamic=e,this},i.prototype.start=function(e,t){if(e===void 0&&(e=Pa()),t===void 0&&(t=!1),this._isPlaying)return this;if(this._group&&this._group.add(this),this._repeat=this._initialRepeat,this._reversed){this._reversed=!1;for(var n in this._valuesStartRepeat)this._swapEndStartRepeatValues(n),this._valuesStart[n]=this._valuesStartRepeat[n]}if(this._isPlaying=!0,this._isPaused=!1,this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._isChainStopped=!1,this._startTime=e,this._startTime+=this._delayTime,!this._propertiesAreSetUp||t){if(this._propertiesAreSetUp=!0,!this._isDynamic){var r={};for(var o in this._valuesEnd)r[o]=this._valuesEnd[o];this._valuesEnd=r}this._setupProperties(this._object,this._valuesStart,this._valuesEnd,this._valuesStartRepeat,t)}return this},i.prototype.startFromCurrentValues=function(e){return this.start(e,!0)},i.prototype._setupProperties=function(e,t,n,r,o){for(var a in n){var l=e[a],u=Array.isArray(l),h=u?"array":typeof l,d=!u&&Array.isArray(n[a]);if(!(h==="undefined"||h==="function")){if(d){var p=n[a];if(p.length===0)continue;for(var m=[l],g=0,y=p.length;g<y;g+=1){var S=this._handleRelativeValue(l,p[g]);if(isNaN(S)){d=!1,console.warn("Found invalid interpolation list. Skipping.");break}m.push(S)}d&&(n[a]=m)}if((h==="object"||u)&&l&&!d){t[a]=u?[]:{};var _=l;for(var v in _)t[a][v]=_[v];r[a]=u?[]:{};var p=n[a];if(!this._isDynamic){var R={};for(var v in p)R[v]=p[v];n[a]=p=R}this._setupProperties(_,t[a],p,r[a],o)}else(typeof t[a]>"u"||o)&&(t[a]=l),u||(t[a]*=1),d?r[a]=n[a].slice().reverse():r[a]=t[a]||0}}},i.prototype.stop=function(){return this._isChainStopped||(this._isChainStopped=!0,this.stopChainedTweens()),this._isPlaying?(this._group&&this._group.remove(this),this._isPlaying=!1,this._isPaused=!1,this._onStopCallback&&this._onStopCallback(this._object),this):this},i.prototype.end=function(){return this._goToEnd=!0,this.update(1/0),this},i.prototype.pause=function(e){return e===void 0&&(e=Pa()),this._isPaused||!this._isPlaying?this:(this._isPaused=!0,this._pauseStart=e,this._group&&this._group.remove(this),this)},i.prototype.resume=function(e){return e===void 0&&(e=Pa()),!this._isPaused||!this._isPlaying?this:(this._isPaused=!1,this._startTime+=e-this._pauseStart,this._pauseStart=0,this._group&&this._group.add(this),this)},i.prototype.stopChainedTweens=function(){for(var e=0,t=this._chainedTweens.length;e<t;e++)this._chainedTweens[e].stop();return this},i.prototype.group=function(e){return e===void 0&&(e=Rf),this._group=e,this},i.prototype.delay=function(e){return e===void 0&&(e=0),this._delayTime=e,this},i.prototype.repeat=function(e){return e===void 0&&(e=0),this._initialRepeat=e,this._repeat=e,this},i.prototype.repeatDelay=function(e){return this._repeatDelayTime=e,this},i.prototype.yoyo=function(e){return e===void 0&&(e=!1),this._yoyo=e,this},i.prototype.easing=function(e){return e===void 0&&(e=wr.Linear.None),this._easingFunction=e,this},i.prototype.interpolation=function(e){return e===void 0&&(e=Af.Linear),this._interpolationFunction=e,this},i.prototype.chain=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return this._chainedTweens=e,this},i.prototype.onStart=function(e){return this._onStartCallback=e,this},i.prototype.onEveryStart=function(e){return this._onEveryStartCallback=e,this},i.prototype.onUpdate=function(e){return this._onUpdateCallback=e,this},i.prototype.onRepeat=function(e){return this._onRepeatCallback=e,this},i.prototype.onComplete=function(e){return this._onCompleteCallback=e,this},i.prototype.onStop=function(e){return this._onStopCallback=e,this},i.prototype.update=function(e,t){var n;if(e===void 0&&(e=Pa()),t===void 0&&(t=!0),this._isPaused)return!0;var r=this._startTime+this._duration;if(!this._goToEnd&&!this._isPlaying){if(e>r)return!1;t&&this.start(e,!0)}if(this._goToEnd=!1,e<this._startTime)return!0;this._onStartCallbackFired===!1&&(this._onStartCallback&&this._onStartCallback(this._object),this._onStartCallbackFired=!0),this._onEveryStartCallbackFired===!1&&(this._onEveryStartCallback&&this._onEveryStartCallback(this._object),this._onEveryStartCallbackFired=!0);var o=e-this._startTime,a=this._duration+((n=this._repeatDelayTime)!==null&&n!==void 0?n:this._delayTime),l=this._duration+this._repeat*a,u=this._calculateElapsedPortion(o,a,l),h=this._easingFunction(u),d=this._calculateCompletionStatus(o,a);if(d==="repeat"&&this._processRepetition(o,a),this._updateProperties(this._object,this._valuesStart,this._valuesEnd,h),d==="about-to-repeat"&&this._processRepetition(o,a),this._onUpdateCallback&&this._onUpdateCallback(this._object,u),d==="repeat"||d==="about-to-repeat")this._onRepeatCallback&&this._onRepeatCallback(this._object),this._onEveryStartCallbackFired=!1;else if(d==="completed"){this._isPlaying=!1,this._onCompleteCallback&&this._onCompleteCallback(this._object);for(var p=0,m=this._chainedTweens.length;p<m;p++)this._chainedTweens[p].start(this._startTime+this._duration,!1)}return d!=="completed"},i.prototype._calculateElapsedPortion=function(e,t,n){if(this._duration===0||e>n)return 1;var r=e%t,o=Math.min(r/this._duration,1);return o===0&&e!==0&&e%this._duration===0?1:o},i.prototype._calculateCompletionStatus=function(e,t){return this._duration!==0&&e<this._duration?"playing":this._repeat<=0?"completed":e===this._duration?"about-to-repeat":"repeat"},i.prototype._processRepetition=function(e,t){var n=Math.min(Math.trunc((e-this._duration)/t)+1,this._repeat);isFinite(this._repeat)&&(this._repeat-=n);for(var r in this._valuesStartRepeat){var o=this._valuesEnd[r];!this._yoyo&&typeof o=="string"&&(this._valuesStartRepeat[r]=this._valuesStartRepeat[r]+parseFloat(o)),this._yoyo&&this._swapEndStartRepeatValues(r),this._valuesStart[r]=this._valuesStartRepeat[r]}this._yoyo&&(this._reversed=!this._reversed),this._startTime+=t*n},i.prototype._updateProperties=function(e,t,n,r){for(var o in n)if(t[o]!==void 0){var a=t[o]||0,l=n[o],u=Array.isArray(e[o]),h=Array.isArray(l),d=!u&&h;d?e[o]=this._interpolationFunction(l,r):typeof l=="object"&&l?this._updateProperties(e[o],a,l,r):(l=this._handleRelativeValue(a,l),typeof l=="number"&&(e[o]=a+(l-a)*r))}},i.prototype._handleRelativeValue=function(e,t){return typeof t!="string"?t:t.charAt(0)==="+"||t.charAt(0)==="-"?e+parseFloat(t):parseFloat(t)},i.prototype._swapEndStartRepeatValues=function(e){var t=this._valuesStartRepeat[e],n=this._valuesEnd[e];typeof n=="string"?this._valuesStartRepeat[e]=this._valuesStartRepeat[e]+parseFloat(n):this._valuesStartRepeat[e]=this._valuesEnd[e],this._valuesEnd[e]=t},i}();J0.nextId;var nr=Rf;nr.getAll.bind(nr);nr.removeAll.bind(nr);nr.add.bind(nr);nr.remove.bind(nr);var u2=nr.update.bind(nr);const Sl={enableDamping:!0,dampingFactor:.04};class Ol extends a2{static DEFAULT_ZOOM_FACTOR=1;_animationSystem;last=null;animating=!1;locked=!1;stopMoveTo=()=>{};stopRevertLast=()=>{};object;domElement;_removePreRenderCallback=()=>{};constructor(e,t,n,r=Sl){super(e,t.domElement),this._animationSystem=n,this.domElement=t.domElement,this.object=e;const o=t.AddPreRenderCallback(()=>{this.preRenderCallback()});this._removePreRenderCallback=()=>{t.RemovePreRenderCallback(o)},this.enableDamping=r.enableDamping||Sl.enableDamping,this.dampingFactor=r.dampingFactor||Sl.dampingFactor,this.object.position.set(0,2,2),this.target.copy({x:0,y:.5,z:0}),this.update()}Dispose(){this._removePreRenderCallback(),this.dispose()}ComputeEncompassingView(e){const t=e.getCenter(new F),n=e.getSize(new F),r=Math.max(n.x,n.y,n.z)*1.25;return{position:this.object.position.clone().normalize().multiplyScalar(r),target:t}}ZoomIn(e){const t=e||Ol.DEFAULT_ZOOM_FACTOR,{minDistance:n,maxDistance:r}=this;this.minDistance=this.maxDistance=ci.clamp(this.getDistance()-t,n+t,r-t),this.update(),this.minDistance=n,this.maxDistance=r}ZoomOut(e){const t=e||Ol.DEFAULT_ZOOM_FACTOR,{minDistance:n,maxDistance:r}=this;this.minDistance=this.maxDistance=ci.clamp(this.getDistance()+t,n+t,r-t),this.update(),this.minDistance=n,this.maxDistance=r}MoveTo(e,t,n,r){if(this.animating)return;const o=e||this.object.position.clone(),a=t||this.target.clone();this.stopRevertLast(),this.locked||(this.last={pos:this.object.position.clone(),target:this.target.clone()}),this.animating=n>0,this.locked=r,this.enabled=!1;const l=this._animationSystem.Animate(this.object.position).to(o,n).easing(wr.Quadratic.Out).start(),u=this._animationSystem.Animate(this.target).to(a,n).easing(wr.Quadratic.Out).onUpdate(()=>{this.object.lookAt(this.target)}).onComplete(()=>{this.animating=!1,this.enabled=!r}).start();this.stopMoveTo=()=>{l.stop(),u.stop()}}RevertLast(e){if(this.animating||!this.locked)return;this.stopMoveTo(),this.animating=e>0,this.enabled=!1;const{pos:t,target:n}=this.last,r=this._animationSystem.Animate(this.object.position).to(t,e).easing(wr.Quadratic.Out).start(),o=this._animationSystem.Animate(this.target).to(n,e).easing(wr.Quadratic.Out).onUpdate(()=>{this.object.lookAt(this.target)}).onComplete(()=>{this.animating=!1,this.locked=!1,this.enabled=!0}).start();this.stopRevertLast=()=>{r.stop(),o.stop()}}preRenderCallback=()=>{this.locked||this.update()}}class h2{static DefaultTool="select";_scene;_controller;_activeTool;_selectTool;get selectTool(){return this._selectTool||(this._selectTool=new UL(this._scene,this._controller)),this._selectTool}constructor(e,t){this._scene=e,this._controller=t,this._selectTool=null,this._activeTool=null}Dispose(){this.removeEventListeners()}GetActiveTool(){return this._activeTool}UseTool(e){switch(this._activeTool?.Deactivate(),e){case"select":{this.addEventListeners(),this.selectTool.Activate(),this._activeTool=this.selectTool;break}case"none":{this.removeEventListeners(),this._activeTool=null;break}default:console.warn(`DIVEToolBox.UseTool: Unknown tool: ${e}`)}}SetGizmoMode(e){this.selectTool.SetGizmoMode(e)}SetGizmoVisibility(e){this.selectTool.SetGizmoVisibility(e)}SetGizmoScaleLinked(e){this.selectTool.SetGizmoScaleLinked(e)}onPointerMove(e){this._activeTool?.onPointerMove(e)}onPointerDown(e){this._activeTool?.onPointerDown(e)}onPointerUp(e){this._activeTool?.onPointerUp(e)}onWheel(e){this._activeTool?.onWheel(e)}addEventListeners(){this._controller.domElement.addEventListener("pointermove",e=>this.onPointerMove(e)),this._controller.domElement.addEventListener("pointerdown",e=>this.onPointerDown(e)),this._controller.domElement.addEventListener("pointerup",e=>this.onPointerUp(e)),this._controller.domElement.addEventListener("wheel",e=>this.onWheel(e))}removeEventListeners(){this._controller.domElement.removeEventListener("pointermove",e=>this.onPointerMove(e)),this._controller.domElement.removeEventListener("pointerdown",e=>this.onPointerDown(e)),this._controller.domElement.removeEventListener("pointerup",e=>this.onPointerUp(e)),this._controller.domElement.removeEventListener("wheel",e=>this.onWheel(e))}}class f2{_renderer;_rendererCallbackId;constructor(e){this._renderer=e,this._rendererCallbackId=this._renderer.AddPreRenderCallback(()=>{this.Update()})}Dispose(){this._renderer.RemovePreRenderCallback(this._rendererCallbackId)}Update(){u2()}Animate(e){return new l2(e)}}function d2(i,e,t){return e=Fl(e),S2(i,Q0()?Reflect.construct(e,t||[],Fl(i).constructor):e.apply(i,t))}function Q0(){try{var i=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Q0=function(){return!!i})()}function p2(i,e){var t=i==null?null:typeof Symbol<"u"&&i[Symbol.iterator]||i["@@iterator"];if(t!=null){var n,r,o,a,l=[],u=!0,h=!1;try{if(o=(t=t.call(i)).next,e===0){if(Object(t)!==t)return;u=!1}else for(;!(u=(n=o.call(t)).done)&&(l.push(n.value),l.length!==e);u=!0);}catch(d){h=!0,r=d}finally{try{if(!u&&t.return!=null&&(a=t.return(),Object(a)!==a))return}finally{if(h)throw r}}return l}}function m2(i,e){if(typeof i!="object"||!i)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(i)}function g2(i){var e=m2(i,"string");return typeof e=="symbol"?e:String(e)}function _2(i,e){if(!(i instanceof e))throw new TypeError("Cannot call a class as a function")}function v2(i,e){for(var t=0;t<e.length;t++){var n=e[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(i,g2(n.key),n)}}function x2(i,e,t){return e&&v2(i.prototype,e),Object.defineProperty(i,"prototype",{writable:!1}),i}function y2(i,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");i.prototype=Object.create(e&&e.prototype,{constructor:{value:i,writable:!0,configurable:!0}}),Object.defineProperty(i,"prototype",{writable:!1}),e&&Cf(i,e)}function Fl(i){return Fl=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Fl(i)}function Cf(i,e){return Cf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,r){return n.__proto__=r,n},Cf(i,e)}function M2(i){if(i===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return i}function S2(i,e){if(e&&(typeof e=="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return M2(i)}function F_(i,e){return T2(i)||p2(i,e)||ev(i,e)||A2()}function gl(i){return E2(i)||b2(i)||ev(i)||w2()}function E2(i){if(Array.isArray(i))return Pf(i)}function T2(i){if(Array.isArray(i))return i}function b2(i){if(typeof Symbol<"u"&&i[Symbol.iterator]!=null||i["@@iterator"]!=null)return Array.from(i)}function ev(i,e){if(i){if(typeof i=="string")return Pf(i,e);var t=Object.prototype.toString.call(i).slice(8,-1);if(t==="Object"&&i.constructor&&(t=i.constructor.name),t==="Map"||t==="Set")return Array.from(i);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return Pf(i,e)}}function Pf(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,n=new Array(e);t<e;t++)n[t]=i[t];return n}function w2(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
3830
3830
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function A2(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
3831
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var vo=typeof window<"u"&&window.THREE?window.THREE:{LinearFilter:Xn,Sprite:LP,SpriteMaterial:R0,SRGBColorSpace:on,Texture:cn},Jh=function(i){y2(e,i);function e(){var t,n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"",r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:10,o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"rgba(255, 255, 255, 1)";return _2(this,e),t=d2(this,e,[new vo.SpriteMaterial]),t._text="".concat(n),t._textHeight=r,t._color=o,t._backgroundColor=!1,t._padding=0,t._borderWidth=0,t._borderRadius=0,t._borderColor="white",t._strokeWidth=0,t._strokeColor="white",t._fontFace="system-ui",t._fontSize=90,t._fontWeight="normal",t._canvas=document.createElement("canvas"),t._genCanvas(),t}return x2(e,[{key:"text",get:function(){return this._text},set:function(n){this._text=n,this._genCanvas()}},{key:"textHeight",get:function(){return this._textHeight},set:function(n){this._textHeight=n,this._genCanvas()}},{key:"color",get:function(){return this._color},set:function(n){this._color=n,this._genCanvas()}},{key:"backgroundColor",get:function(){return this._backgroundColor},set:function(n){this._backgroundColor=n,this._genCanvas()}},{key:"padding",get:function(){return this._padding},set:function(n){this._padding=n,this._genCanvas()}},{key:"borderWidth",get:function(){return this._borderWidth},set:function(n){this._borderWidth=n,this._genCanvas()}},{key:"borderRadius",get:function(){return this._borderRadius},set:function(n){this._borderRadius=n,this._genCanvas()}},{key:"borderColor",get:function(){return this._borderColor},set:function(n){this._borderColor=n,this._genCanvas()}},{key:"fontFace",get:function(){return this._fontFace},set:function(n){this._fontFace=n,this._genCanvas()}},{key:"fontSize",get:function(){return this._fontSize},set:function(n){this._fontSize=n,this._genCanvas()}},{key:"fontWeight",get:function(){return this._fontWeight},set:function(n){this._fontWeight=n,this._genCanvas()}},{key:"strokeWidth",get:function(){return this._strokeWidth},set:function(n){this._strokeWidth=n,this._genCanvas()}},{key:"strokeColor",get:function(){return this._strokeColor},set:function(n){this._strokeColor=n,this._genCanvas()}},{key:"_genCanvas",value:function(){var n=this,r=this._canvas,o=r.getContext("2d"),a=Array.isArray(this.borderWidth)?this.borderWidth:[this.borderWidth,this.borderWidth],l=a.map(function(D){return D*n.fontSize*.1}),u=Array.isArray(this.borderRadius)?this.borderRadius:[this.borderRadius,this.borderRadius,this.borderRadius,this.borderRadius],h=u.map(function(D){return D*n.fontSize*.1}),d=Array.isArray(this.padding)?this.padding:[this.padding,this.padding],p=d.map(function(D){return D*n.fontSize*.1}),m=this.text.split(`
3832
- `),g="".concat(this.fontWeight," ").concat(this.fontSize,"px ").concat(this.fontFace);o.font=g;var y=Math.max.apply(Math,gl(m.map(function(D){return o.measureText(D).width}))),S=this.fontSize*m.length;if(r.width=y+l[0]*2+p[0]*2,r.height=S+l[1]*2+p[1]*2,this.borderWidth){if(o.strokeStyle=this.borderColor,l[0]){var _=l[0]/2;o.lineWidth=l[0],o.beginPath(),o.moveTo(_,h[0]),o.lineTo(_,r.height-h[3]),o.moveTo(r.width-_,h[1]),o.lineTo(r.width-_,r.height-h[2]),o.stroke()}if(l[1]){var v=l[1]/2;o.lineWidth=l[1],o.beginPath(),o.moveTo(Math.max(l[0],h[0]),v),o.lineTo(r.width-Math.max(l[0],h[1]),v),o.moveTo(Math.max(l[0],h[3]),r.height-v),o.lineTo(r.width-Math.max(l[0],h[2]),r.height-v),o.stroke()}if(this.borderRadius){var R=Math.max.apply(Math,gl(l)),b=R/2;o.lineWidth=R,o.beginPath(),[!!h[0]&&[h[0],b,b,h[0]],!!h[1]&&[r.width-h[1],r.width-b,b,h[1]],!!h[2]&&[r.width-h[2],r.width-b,r.height-b,r.height-h[2]],!!h[3]&&[h[3],b,r.height-b,r.height-h[3]]].filter(function(D){return D}).forEach(function(D){var C=O_(D,4),E=C[0],M=C[1],O=C[2],H=C[3];o.moveTo(E,O),o.quadraticCurveTo(M,O,M,H)}),o.stroke()}}this.backgroundColor&&(o.fillStyle=this.backgroundColor,this.borderRadius?(o.beginPath(),o.moveTo(l[0],h[0]),[[l[0],h[0],r.width-h[1],l[1],l[1],l[1]],[r.width-l[0],r.width-l[0],r.width-l[0],l[1],h[1],r.height-h[2]],[r.width-l[0],r.width-h[2],h[3],r.height-l[1],r.height-l[1],r.height-l[1]],[l[0],l[0],l[0],r.height-l[1],r.height-h[3],h[0]]].forEach(function(D){var C=O_(D,6),E=C[0],M=C[1],O=C[2],H=C[3],G=C[4],Y=C[5];o.quadraticCurveTo(E,H,M,G),o.lineTo(O,Y)}),o.closePath(),o.fill()):o.fillRect(l[0],l[1],r.width-l[0]*2,r.height-l[1]*2)),o.translate.apply(o,gl(l)),o.translate.apply(o,gl(p)),o.font=g,o.fillStyle=this.color,o.textBaseline="bottom";var A=this.strokeWidth>0;A&&(o.lineWidth=this.strokeWidth*this.fontSize/10,o.strokeStyle=this.strokeColor),m.forEach(function(D,C){var E=(y-o.measureText(D).width)/2,M=(C+1)*n.fontSize;A&&o.strokeText(D,E,M),o.fillText(D,E,M)}),this.material.map&&this.material.map.dispose();var B=this.material.map=new vo.Texture(r);B.minFilter=vo.LinearFilter,B.colorSpace=vo.SRGBColorSpace,B.needsUpdate=!0;var N=this.textHeight*m.length+a[1]*2+d[1]*2;this.scale.set(N*r.width/r.height,N,0)}},{key:"clone",value:function(){return new this.constructor(this.text,this.textHeight,this.color).copy(this)}},{key:"copy",value:function(n){return vo.Sprite.prototype.copy.call(this,n),this.color=n.color,this.backgroundColor=n.backgroundColor,this.padding=n.padding,this.borderWidth=n.borderWidth,this.borderColor=n.borderColor,this.fontFace=n.fontFace,this.fontSize=n.fontSize,this.fontWeight=n.fontWeight,this.strokeWidth=n.strokeWidth,this.strokeColor=n.strokeColor,this}}]),e}(vo.Sprite);class F_ extends zl{axesHelper;_renderer;_scene;_renderCallbackId;constructor(e,t,n){super(-1,1,1,-1,.1,100),this.layers.mask=va,this.axesHelper=new yL(.5),this.axesHelper.layers.mask=va,this.axesHelper.material.depthTest=!1,this.axesHelper.position.set(0,0,-1),this.axesHelper.setColors(new Oe(pf),new Oe(mf),new Oe(gf));const r=new Jh("X",.2,B0),o=new Jh("Y",.2,z0),a=new Jh("Z",.2,k0);r.layers.mask=va,o.layers.mask=va,a.layers.mask=va,r.position.set(.7,0,0),o.position.set(0,.7,0),a.position.set(0,0,.7),this.axesHelper.add(r),this.axesHelper.add(o),this.axesHelper.add(a),this.add(this.axesHelper),this._renderer=e,this._scene=t,this._scene.add(this);const l=new Ut;this._renderCallbackId=e.AddPostRenderCallback(()=>{const u=t.background;t.background=null,e.getViewport(l),e.setViewport(0,0,150,150),e.autoClear=!1,this.SetFromCameraMatrix(n.object.matrix),e.render(t,this),e.setViewport(l),e.autoClear=!0,t.background=u})}Dispose(){this._renderer.RemovePostRenderCallback(this._renderCallbackId),this._scene.remove(this)}SetFromCameraMatrix(e){this.axesHelper.rotation.setFromRotationMatrix(new Qe().extractRotation(e).invert())}}const Pf=(i,e)=>{if(Object.keys(i).length===0&&Object.keys(e).length===0)return{};if(typeof i!="object"||typeof e!="object")return e;let t={};return Object.keys(e).forEach(n=>{if(!Object.keys(i).includes(n)){t={...t,[n]:e[n]};return}if(Array.isArray(e[n])){if(!Array.isArray(i[n])){t={...t,[n]:e[n]};return}const r=i[n],o=e[n];if(r.length===0&&o.length===0){t={...t};return}if(r.length!==o.length){t={...t,[n]:e[n]};return}const a=[];if(o.forEach((l,u)=>{const h=Pf(r[u],o[u]);Object.keys(h).length&&a.push(o[u])}),Object.keys(a).length){t={...t,[n]:a};return}return}if(typeof e[n]=="object"){if(typeof i[n]!="object"){t={...t,[n]:e[n]};return}const r=Pf(i[n],e[n]);if(Object.keys(r).length){t={...t,[n]:r};return}}i[n]!==e[n]&&(t={...t,[n]:e[n]})}),t};var Mi=(i=>(i.IOS="iOS",i.ANDROID="Android",i.WINDOWS="Windows",i.MACOS="MacOS",i.LINUX="Linux",i.UNKNOWN="Unknown",i))(Mi||{}),La=(i=>(i.NO_WEBXR_API="NO_WEBXR_API",i.NO_HTTPS="NO_HTTPS",i.IMMERSIVE_AR_NOT_SUPPORTED_BY_DEVICE="IMMERSIVE_AR_NOT_SUPPORTED_BY_DEVICE",i.AR_PERMISSION_DENIED="AR_PERMISSION_DENIED",i.UNKNOWN_ERROR="UNKNOWN_ERROR",i))(La||{});class Lf{static _supportsWebXR=!1;static _webXRUnsupportedReason=null;static GetSystem(){if(typeof window>"u"||!window.navigator)return Mi.UNKNOWN;const e=window.navigator.userAgent.toLowerCase();return e.includes("iphone")||e.includes("ipad")?Mi.IOS:e.includes("android")?Mi.ANDROID:e.includes("windows")?Mi.WINDOWS:e.includes("macintosh")?Mi.MACOS:e.includes("linux")?Mi.LINUX:Mi.UNKNOWN}static async GetSupportsWebXR(){if(this._supportsWebXR!==!1)return this._supportsWebXR;if(!window.isSecureContext)return this._supportsWebXR=!1,this._webXRUnsupportedReason=La.NO_HTTPS,this._supportsWebXR;if(!navigator.xr)return this._supportsWebXR=!1,this._webXRUnsupportedReason=La.NO_WEBXR_API,this._supportsWebXR;try{const e=await navigator.xr.isSessionSupported("immersive-ar");this._supportsWebXR=e,this._supportsWebXR||(this._webXRUnsupportedReason=La.IMMERSIVE_AR_NOT_SUPPORTED_BY_DEVICE)}catch{this._supportsWebXR=!1,this._webXRUnsupportedReason=La.AR_PERMISSION_DENIED}return this._supportsWebXR}static GetWebXRUnsupportedReason(){return this._supportsWebXR?(console.log("WebXR is supported."),null):this._webXRUnsupportedReason}static GetSupportsARQuickLook(){return document.createElement("a").relList.supports("ar")}static GetSupportsSceneViewer(){if(typeof window>"u"||!window.navigator)return!1;const e=window.navigator.userAgent.toLowerCase();if(!e.includes("android")||!e.includes("chrome"))return!1;const t=e.match(/chrome\/(\d+)/);return!(!t||parseInt(t[1])<89)}static get isMobile(){return this.GetSystem()===Mi.ANDROID||this.GetSystem()===Mi.IOS}static get isDesktop(){return!this.isMobile}static async GetIsARCapable(){return this.GetSupportsARQuickLook()?!0:await this.GetSupportsWebXR()}}const R2="1.19.1-beta.1",C2={version:R2};function ir(i,e){const t=(i+"e").split("e");return+(t[0]+"e"+(+t[1]+(e||0)))}function P2(i,e=0){const t=ir(i,+e);return ir(Math.ceil(t),-e)}function L2(i,e=0){const t=ir(i,+e);return ir(Math.floor(t),-e)}function tv(i,e=0){if(i<0)return-tv(-i,e);const t=ir(i,+e);return ir(Math.round(t),-e)}function I2(i,e,t){return Math.atan2(i.clone().cross(e).dot(t),e.clone().dot(i))}function D2(i,e=0){const t=ir(i,+e);return ir(Math.round(t),-e).toFixed(e)}function U2(i,e=0){const t=ir(i,+e);return ir(Math.trunc(t),-e)}function N2(i){return(ci.radToDeg(i)+360)%360}function O2(i){return ci.degToRad(i)}const F2={ceilExp:P2,floorExp:L2,roundExp:tv,toFixedExp:D2,truncateExp:U2,signedAngleTo:I2,radToDeg:N2,degToRad:O2};let Ta,Qh,xo,_l;function El(i,e=1/0,t=null){Qh||(Qh=new ns(2,2,1,1)),xo||(xo=new Rr({uniforms:{blitTexture:new $f(i)},vertexShader:`
3831
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var vo=typeof window<"u"&&window.THREE?window.THREE:{LinearFilter:Xn,Sprite:LP,SpriteMaterial:R0,SRGBColorSpace:on,Texture:cn},ef=function(i){y2(e,i);function e(){var t,n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"",r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:10,o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"rgba(255, 255, 255, 1)";return _2(this,e),t=d2(this,e,[new vo.SpriteMaterial]),t._text="".concat(n),t._textHeight=r,t._color=o,t._backgroundColor=!1,t._padding=0,t._borderWidth=0,t._borderRadius=0,t._borderColor="white",t._strokeWidth=0,t._strokeColor="white",t._fontFace="system-ui",t._fontSize=90,t._fontWeight="normal",t._canvas=document.createElement("canvas"),t._genCanvas(),t}return x2(e,[{key:"text",get:function(){return this._text},set:function(n){this._text=n,this._genCanvas()}},{key:"textHeight",get:function(){return this._textHeight},set:function(n){this._textHeight=n,this._genCanvas()}},{key:"color",get:function(){return this._color},set:function(n){this._color=n,this._genCanvas()}},{key:"backgroundColor",get:function(){return this._backgroundColor},set:function(n){this._backgroundColor=n,this._genCanvas()}},{key:"padding",get:function(){return this._padding},set:function(n){this._padding=n,this._genCanvas()}},{key:"borderWidth",get:function(){return this._borderWidth},set:function(n){this._borderWidth=n,this._genCanvas()}},{key:"borderRadius",get:function(){return this._borderRadius},set:function(n){this._borderRadius=n,this._genCanvas()}},{key:"borderColor",get:function(){return this._borderColor},set:function(n){this._borderColor=n,this._genCanvas()}},{key:"fontFace",get:function(){return this._fontFace},set:function(n){this._fontFace=n,this._genCanvas()}},{key:"fontSize",get:function(){return this._fontSize},set:function(n){this._fontSize=n,this._genCanvas()}},{key:"fontWeight",get:function(){return this._fontWeight},set:function(n){this._fontWeight=n,this._genCanvas()}},{key:"strokeWidth",get:function(){return this._strokeWidth},set:function(n){this._strokeWidth=n,this._genCanvas()}},{key:"strokeColor",get:function(){return this._strokeColor},set:function(n){this._strokeColor=n,this._genCanvas()}},{key:"_genCanvas",value:function(){var n=this,r=this._canvas,o=r.getContext("2d"),a=Array.isArray(this.borderWidth)?this.borderWidth:[this.borderWidth,this.borderWidth],l=a.map(function(D){return D*n.fontSize*.1}),u=Array.isArray(this.borderRadius)?this.borderRadius:[this.borderRadius,this.borderRadius,this.borderRadius,this.borderRadius],h=u.map(function(D){return D*n.fontSize*.1}),d=Array.isArray(this.padding)?this.padding:[this.padding,this.padding],p=d.map(function(D){return D*n.fontSize*.1}),m=this.text.split(`
3832
+ `),g="".concat(this.fontWeight," ").concat(this.fontSize,"px ").concat(this.fontFace);o.font=g;var y=Math.max.apply(Math,gl(m.map(function(D){return o.measureText(D).width}))),S=this.fontSize*m.length;if(r.width=y+l[0]*2+p[0]*2,r.height=S+l[1]*2+p[1]*2,this.borderWidth){if(o.strokeStyle=this.borderColor,l[0]){var _=l[0]/2;o.lineWidth=l[0],o.beginPath(),o.moveTo(_,h[0]),o.lineTo(_,r.height-h[3]),o.moveTo(r.width-_,h[1]),o.lineTo(r.width-_,r.height-h[2]),o.stroke()}if(l[1]){var v=l[1]/2;o.lineWidth=l[1],o.beginPath(),o.moveTo(Math.max(l[0],h[0]),v),o.lineTo(r.width-Math.max(l[0],h[1]),v),o.moveTo(Math.max(l[0],h[3]),r.height-v),o.lineTo(r.width-Math.max(l[0],h[2]),r.height-v),o.stroke()}if(this.borderRadius){var R=Math.max.apply(Math,gl(l)),b=R/2;o.lineWidth=R,o.beginPath(),[!!h[0]&&[h[0],b,b,h[0]],!!h[1]&&[r.width-h[1],r.width-b,b,h[1]],!!h[2]&&[r.width-h[2],r.width-b,r.height-b,r.height-h[2]],!!h[3]&&[h[3],b,r.height-b,r.height-h[3]]].filter(function(D){return D}).forEach(function(D){var C=F_(D,4),E=C[0],M=C[1],O=C[2],H=C[3];o.moveTo(E,O),o.quadraticCurveTo(M,O,M,H)}),o.stroke()}}this.backgroundColor&&(o.fillStyle=this.backgroundColor,this.borderRadius?(o.beginPath(),o.moveTo(l[0],h[0]),[[l[0],h[0],r.width-h[1],l[1],l[1],l[1]],[r.width-l[0],r.width-l[0],r.width-l[0],l[1],h[1],r.height-h[2]],[r.width-l[0],r.width-h[2],h[3],r.height-l[1],r.height-l[1],r.height-l[1]],[l[0],l[0],l[0],r.height-l[1],r.height-h[3],h[0]]].forEach(function(D){var C=F_(D,6),E=C[0],M=C[1],O=C[2],H=C[3],G=C[4],Y=C[5];o.quadraticCurveTo(E,H,M,G),o.lineTo(O,Y)}),o.closePath(),o.fill()):o.fillRect(l[0],l[1],r.width-l[0]*2,r.height-l[1]*2)),o.translate.apply(o,gl(l)),o.translate.apply(o,gl(p)),o.font=g,o.fillStyle=this.color,o.textBaseline="bottom";var A=this.strokeWidth>0;A&&(o.lineWidth=this.strokeWidth*this.fontSize/10,o.strokeStyle=this.strokeColor),m.forEach(function(D,C){var E=(y-o.measureText(D).width)/2,M=(C+1)*n.fontSize;A&&o.strokeText(D,E,M),o.fillText(D,E,M)}),this.material.map&&this.material.map.dispose();var B=this.material.map=new vo.Texture(r);B.minFilter=vo.LinearFilter,B.colorSpace=vo.SRGBColorSpace,B.needsUpdate=!0;var N=this.textHeight*m.length+a[1]*2+d[1]*2;this.scale.set(N*r.width/r.height,N,0)}},{key:"clone",value:function(){return new this.constructor(this.text,this.textHeight,this.color).copy(this)}},{key:"copy",value:function(n){return vo.Sprite.prototype.copy.call(this,n),this.color=n.color,this.backgroundColor=n.backgroundColor,this.padding=n.padding,this.borderWidth=n.borderWidth,this.borderColor=n.borderColor,this.fontFace=n.fontFace,this.fontSize=n.fontSize,this.fontWeight=n.fontWeight,this.strokeWidth=n.strokeWidth,this.strokeColor=n.strokeColor,this}}]),e}(vo.Sprite);class B_ extends kl{axesHelper;_renderer;_scene;_renderCallbackId;constructor(e,t,n){super(-1,1,1,-1,.1,100),this.layers.mask=va,this.axesHelper=new yL(.5),this.axesHelper.layers.mask=va,this.axesHelper.material.depthTest=!1,this.axesHelper.position.set(0,0,-1),this.axesHelper.setColors(new Oe(mf),new Oe(gf),new Oe(_f));const r=new ef("X",.2,B0),o=new ef("Y",.2,z0),a=new ef("Z",.2,k0);r.layers.mask=va,o.layers.mask=va,a.layers.mask=va,r.position.set(.7,0,0),o.position.set(0,.7,0),a.position.set(0,0,.7),this.axesHelper.add(r),this.axesHelper.add(o),this.axesHelper.add(a),this.add(this.axesHelper),this._renderer=e,this._scene=t,this._scene.add(this);const l=new Ut;this._renderCallbackId=e.AddPostRenderCallback(()=>{const u=t.background;t.background=null,e.getViewport(l),e.setViewport(0,0,150,150),e.autoClear=!1,this.SetFromCameraMatrix(n.object.matrix),e.render(t,this),e.setViewport(l),e.autoClear=!0,t.background=u})}Dispose(){this._renderer.RemovePostRenderCallback(this._renderCallbackId),this._scene.remove(this)}SetFromCameraMatrix(e){this.axesHelper.rotation.setFromRotationMatrix(new Qe().extractRotation(e).invert())}}const Lf=(i,e)=>{if(Object.keys(i).length===0&&Object.keys(e).length===0)return{};if(typeof i!="object"||typeof e!="object")return e;let t={};return Object.keys(e).forEach(n=>{if(!Object.keys(i).includes(n)){t={...t,[n]:e[n]};return}if(Array.isArray(e[n])){if(!Array.isArray(i[n])){t={...t,[n]:e[n]};return}const r=i[n],o=e[n];if(r.length===0&&o.length===0){t={...t};return}if(r.length!==o.length){t={...t,[n]:e[n]};return}const a=[];if(o.forEach((l,u)=>{const h=Lf(r[u],o[u]);Object.keys(h).length&&a.push(o[u])}),Object.keys(a).length){t={...t,[n]:a};return}return}if(typeof e[n]=="object"){if(typeof i[n]!="object"){t={...t,[n]:e[n]};return}const r=Lf(i[n],e[n]);if(Object.keys(r).length){t={...t,[n]:r};return}}i[n]!==e[n]&&(t={...t,[n]:e[n]})}),t};var Mi=(i=>(i.IOS="iOS",i.ANDROID="Android",i.WINDOWS="Windows",i.MACOS="MacOS",i.LINUX="Linux",i.UNKNOWN="Unknown",i))(Mi||{}),La=(i=>(i.NO_WEBXR_API="NO_WEBXR_API",i.NO_HTTPS="NO_HTTPS",i.IMMERSIVE_AR_NOT_SUPPORTED_BY_DEVICE="IMMERSIVE_AR_NOT_SUPPORTED_BY_DEVICE",i.AR_PERMISSION_DENIED="AR_PERMISSION_DENIED",i.UNKNOWN_ERROR="UNKNOWN_ERROR",i))(La||{});class If{static _supportsWebXR=!1;static _webXRUnsupportedReason=null;static GetSystem(){if(typeof window>"u"||!window.navigator)return Mi.UNKNOWN;const e=window.navigator.userAgent.toLowerCase();return e.includes("iphone")||e.includes("ipad")?Mi.IOS:e.includes("android")?Mi.ANDROID:e.includes("windows")?Mi.WINDOWS:e.includes("macintosh")?Mi.MACOS:e.includes("linux")?Mi.LINUX:Mi.UNKNOWN}static async GetSupportsWebXR(){if(this._supportsWebXR!==!1)return this._supportsWebXR;if(!window.isSecureContext)return this._supportsWebXR=!1,this._webXRUnsupportedReason=La.NO_HTTPS,this._supportsWebXR;if(!navigator.xr)return this._supportsWebXR=!1,this._webXRUnsupportedReason=La.NO_WEBXR_API,this._supportsWebXR;try{const e=await navigator.xr.isSessionSupported("immersive-ar");this._supportsWebXR=e,this._supportsWebXR||(this._webXRUnsupportedReason=La.IMMERSIVE_AR_NOT_SUPPORTED_BY_DEVICE)}catch{this._supportsWebXR=!1,this._webXRUnsupportedReason=La.AR_PERMISSION_DENIED}return this._supportsWebXR}static GetWebXRUnsupportedReason(){return this._supportsWebXR?(console.log("WebXR is supported."),null):this._webXRUnsupportedReason}static GetSupportsARQuickLook(){return document.createElement("a").relList.supports("ar")}static GetSupportsSceneViewer(){if(typeof window>"u"||!window.navigator)return!1;const e=window.navigator.userAgent.toLowerCase();if(!e.includes("android")||!e.includes("chrome"))return!1;const t=e.match(/chrome\/(\d+)/);return!(!t||parseInt(t[1])<89)}static get isMobile(){return this.GetSystem()===Mi.ANDROID||this.GetSystem()===Mi.IOS}static get isDesktop(){return!this.isMobile}static async GetIsARCapable(){return this.GetSupportsARQuickLook()?!0:await this.GetSupportsWebXR()}}const R2="1.19.1-beta.2",C2={version:R2};function ir(i,e){const t=(i+"e").split("e");return+(t[0]+"e"+(+t[1]+(e||0)))}function P2(i,e=0){const t=ir(i,+e);return ir(Math.ceil(t),-e)}function L2(i,e=0){const t=ir(i,+e);return ir(Math.floor(t),-e)}function tv(i,e=0){if(i<0)return-tv(-i,e);const t=ir(i,+e);return ir(Math.round(t),-e)}function I2(i,e,t){return Math.atan2(i.clone().cross(e).dot(t),e.clone().dot(i))}function D2(i,e=0){const t=ir(i,+e);return ir(Math.round(t),-e).toFixed(e)}function U2(i,e=0){const t=ir(i,+e);return ir(Math.trunc(t),-e)}function N2(i){return(ci.radToDeg(i)+360)%360}function O2(i){return ci.degToRad(i)}const F2={ceilExp:P2,floorExp:L2,roundExp:tv,toFixedExp:D2,truncateExp:U2,signedAngleTo:I2,radToDeg:N2,degToRad:O2};let Ta,tf,xo,_l;function El(i,e=1/0,t=null){tf||(tf=new ns(2,2,1,1)),xo||(xo=new Rr({uniforms:{blitTexture:new Kf(i)},vertexShader:`
3833
3833
  varying vec2 vUv;
3834
3834
  void main(){
3835
3835
  vUv = uv;
@@ -3846,7 +3846,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
3846
3846
  #else
3847
3847
  gl_FragColor = texture2D( blitTexture, vUv);
3848
3848
  #endif
3849
- }`})),xo.uniforms.blitTexture.value=i,xo.defines.IS_SRGB=i.colorSpace==on,xo.needsUpdate=!0,_l||(_l=new Se(Qh,xo),_l.frustumCulled=!1);const n=new Un,r=new Pl;r.add(_l),t===null&&(t=Ta=new w0({antialias:!1}));const o=Math.min(i.image.width,e),a=Math.min(i.image.height,e);t.setSize(o,a),t.clear(),t.render(r,n);const l=document.createElement("canvas"),u=l.getContext("2d");l.width=o,l.height=a,u.drawImage(t.domElement,0,0,o,a);const h=new zP(l);return h.minFilter=i.minFilter,h.magFilter=i.magFilter,h.wrapS=i.wrapS,h.wrapT=i.wrapT,h.name=i.name,Ta&&(Ta.forceContextLoss(),Ta.dispose(),Ta=null),h}const B_={POSITION:["byte","byte normalized","unsigned byte","unsigned byte normalized","short","short normalized","unsigned short","unsigned short normalized"],NORMAL:["byte normalized","short normalized"],TANGENT:["byte normalized","short normalized"],TEXCOORD:["byte","byte normalized","unsigned byte","short","short normalized","unsigned short"]};class id{constructor(){this.pluginCallbacks=[],this.register(function(e){return new j2(e)}),this.register(function(e){return new q2(e)}),this.register(function(e){return new Z2(e)}),this.register(function(e){return new J2(e)}),this.register(function(e){return new Q2(e)}),this.register(function(e){return new eD(e)}),this.register(function(e){return new $2(e)}),this.register(function(e){return new K2(e)}),this.register(function(e){return new tD(e)}),this.register(function(e){return new nD(e)}),this.register(function(e){return new iD(e)}),this.register(function(e){return new rD(e)}),this.register(function(e){return new sD(e)})}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,n,r){const o=new Y2,a=[];for(let l=0,u=this.pluginCallbacks.length;l<u;l++)a.push(this.pluginCallbacks[l](o));o.setPlugins(a),o.write(e,t,r).catch(n)}parseAsync(e,t){const n=this;return new Promise(function(r,o){n.parse(e,r,o,t)})}}const yt={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,INT:5124,UNSIGNED_INT:5125,FLOAT:5126,ARRAY_BUFFER:34962,ELEMENT_ARRAY_BUFFER:34963,NEAREST:9728,LINEAR:9729,NEAREST_MIPMAP_NEAREST:9984,LINEAR_MIPMAP_NEAREST:9985,NEAREST_MIPMAP_LINEAR:9986,LINEAR_MIPMAP_LINEAR:9987,CLAMP_TO_EDGE:33071,MIRRORED_REPEAT:33648,REPEAT:10497},ef="KHR_mesh_quantization",ai={};ai[Nn]=yt.NEAREST;ai[Uf]=yt.NEAREST_MIPMAP_NEAREST;ai[yo]=yt.NEAREST_MIPMAP_LINEAR;ai[Xn]=yt.LINEAR;ai[Da]=yt.LINEAR_MIPMAP_NEAREST;ai[Ki]=yt.LINEAR_MIPMAP_LINEAR;ai[$i]=yt.CLAMP_TO_EDGE;ai[es]=yt.REPEAT;ai[Co]=yt.MIRRORED_REPEAT;const z_={scale:"scale",position:"translation",quaternion:"rotation",morphTargetInfluences:"weights"},B2=new Oe,k_=12,z2=1179937895,k2=2,H_=8,H2=1313821514,G2=5130562;function Ia(i,e){return i.length===e.length&&i.every(function(t,n){return t===e[n]})}function V2(i){return new TextEncoder().encode(i).buffer}function W2(i){return Ia(i.elements,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}function X2(i,e,t){const n={min:new Array(i.itemSize).fill(Number.POSITIVE_INFINITY),max:new Array(i.itemSize).fill(Number.NEGATIVE_INFINITY)};for(let r=e;r<e+t;r++)for(let o=0;o<i.itemSize;o++){let a;i.itemSize>4?a=i.array[r*i.itemSize+o]:(o===0?a=i.getX(r):o===1?a=i.getY(r):o===2?a=i.getZ(r):o===3&&(a=i.getW(r)),i.normalized===!0&&(a=ci.normalize(a,i.array))),n.min[o]=Math.min(n.min[o],a),n.max[o]=Math.max(n.max[o],a)}return n}function nv(i){return Math.ceil(i/4)*4}function tf(i,e=0){const t=nv(i.byteLength);if(t!==i.byteLength){const n=new Uint8Array(t);if(n.set(new Uint8Array(i)),e!==0)for(let r=i.byteLength;r<t;r++)n[r]=e;return n.buffer}return i}function G_(){return typeof document>"u"&&typeof OffscreenCanvas<"u"?new OffscreenCanvas(1,1):document.createElement("canvas")}function V_(i,e){if(i.toBlob!==void 0)return new Promise(n=>i.toBlob(n,e));let t;return e==="image/jpeg"?t=.92:e==="image/webp"&&(t=.8),i.convertToBlob({type:e,quality:t})}class Y2{constructor(){this.plugins=[],this.options={},this.pending=[],this.buffers=[],this.byteOffset=0,this.buffers=[],this.nodeMap=new Map,this.skins=[],this.extensionsUsed={},this.extensionsRequired={},this.uids=new Map,this.uid=0,this.json={asset:{version:"2.0",generator:"THREE.GLTFExporter"}},this.cache={meshes:new Map,attributes:new Map,attributesNormalized:new Map,materials:new Map,textures:new Map,images:new Map}}setPlugins(e){this.plugins=e}async write(e,t,n={}){this.options=Object.assign({binary:!1,trs:!1,onlyVisible:!0,maxTextureSize:1/0,animations:[],includeCustomExtensions:!1},n),this.options.animations.length>0&&(this.options.trs=!0),this.processInput(e),await Promise.all(this.pending);const r=this,o=r.buffers,a=r.json;n=r.options;const l=r.extensionsUsed,u=r.extensionsRequired,h=new Blob(o,{type:"application/octet-stream"}),d=Object.keys(l),p=Object.keys(u);if(d.length>0&&(a.extensionsUsed=d),p.length>0&&(a.extensionsRequired=p),a.buffers&&a.buffers.length>0&&(a.buffers[0].byteLength=h.size),n.binary===!0){const m=new FileReader;m.readAsArrayBuffer(h),m.onloadend=function(){const g=tf(m.result),y=new DataView(new ArrayBuffer(H_));y.setUint32(0,g.byteLength,!0),y.setUint32(4,G2,!0);const S=tf(V2(JSON.stringify(a)),32),_=new DataView(new ArrayBuffer(H_));_.setUint32(0,S.byteLength,!0),_.setUint32(4,H2,!0);const v=new ArrayBuffer(k_),R=new DataView(v);R.setUint32(0,z2,!0),R.setUint32(4,k2,!0);const b=k_+_.byteLength+S.byteLength+y.byteLength+g.byteLength;R.setUint32(8,b,!0);const A=new Blob([v,_,S,y,g],{type:"application/octet-stream"}),B=new FileReader;B.readAsArrayBuffer(A),B.onloadend=function(){t(B.result)}}}else if(a.buffers&&a.buffers.length>0){const m=new FileReader;m.readAsDataURL(h),m.onloadend=function(){const g=m.result;a.buffers[0].uri=g,t(a)}}else t(a)}serializeUserData(e,t){if(Object.keys(e.userData).length===0)return;const n=this.options,r=this.extensionsUsed;try{const o=JSON.parse(JSON.stringify(e.userData));if(n.includeCustomExtensions&&o.gltfExtensions){t.extensions===void 0&&(t.extensions={});for(const a in o.gltfExtensions)t.extensions[a]=o.gltfExtensions[a],r[a]=!0;delete o.gltfExtensions}Object.keys(o).length>0&&(t.extras=o)}catch(o){console.warn("THREE.GLTFExporter: userData of '"+e.name+"' won't be serialized because of JSON.stringify error - "+o.message)}}getUID(e,t=!1){if(this.uids.has(e)===!1){const r=new Map;r.set(!0,this.uid++),r.set(!1,this.uid++),this.uids.set(e,r)}return this.uids.get(e).get(t)}isNormalizedNormalAttribute(e){if(this.cache.attributesNormalized.has(e))return!1;const n=new F;for(let r=0,o=e.count;r<o;r++)if(Math.abs(n.fromBufferAttribute(e,r).length()-1)>5e-4)return!1;return!0}createNormalizedNormalAttribute(e){const t=this.cache;if(t.attributesNormalized.has(e))return t.attributesNormalized.get(e);const n=e.clone(),r=new F;for(let o=0,a=n.count;o<a;o++)r.fromBufferAttribute(n,o),r.x===0&&r.y===0&&r.z===0?r.setX(1):r.normalize(),n.setXYZ(o,r.x,r.y,r.z);return t.attributesNormalized.set(e,n),n}applyTextureTransform(e,t){let n=!1;const r={};(t.offset.x!==0||t.offset.y!==0)&&(r.offset=t.offset.toArray(),n=!0),t.rotation!==0&&(r.rotation=t.rotation,n=!0),(t.repeat.x!==1||t.repeat.y!==1)&&(r.scale=t.repeat.toArray(),n=!0),n&&(e.extensions=e.extensions||{},e.extensions.KHR_texture_transform=r,this.extensionsUsed.KHR_texture_transform=!0)}buildMetalRoughTexture(e,t){if(e===t)return e;function n(g){return g.colorSpace===on?function(S){return S<.04045?S*.0773993808:Math.pow(S*.9478672986+.0521327014,2.4)}:function(S){return S}}console.warn("THREE.GLTFExporter: Merged metalnessMap and roughnessMap textures."),e instanceof Bh&&(e=El(e)),t instanceof Bh&&(t=El(t));const r=e?e.image:null,o=t?t.image:null,a=Math.max(r?r.width:0,o?o.width:0),l=Math.max(r?r.height:0,o?o.height:0),u=G_();u.width=a,u.height=l;const h=u.getContext("2d");h.fillStyle="#00ffff",h.fillRect(0,0,a,l);const d=h.getImageData(0,0,a,l);if(r){h.drawImage(r,0,0,a,l);const g=n(e),y=h.getImageData(0,0,a,l).data;for(let S=2;S<y.length;S+=4)d.data[S]=g(y[S]/256)*256}if(o){h.drawImage(o,0,0,a,l);const g=n(t),y=h.getImageData(0,0,a,l).data;for(let S=1;S<y.length;S+=4)d.data[S]=g(y[S]/256)*256}h.putImageData(d,0,0);const m=(e||t).clone();return m.source=new Ff(u),m.colorSpace=Sn,m.channel=(e||t).channel,e&&t&&e.channel!==t.channel&&console.warn("THREE.GLTFExporter: UV channels for metalnessMap and roughnessMap textures must match."),m}processBuffer(e){const t=this.json,n=this.buffers;return t.buffers||(t.buffers=[{byteLength:0}]),n.push(e),0}processBufferView(e,t,n,r,o){const a=this.json;a.bufferViews||(a.bufferViews=[]);let l;switch(t){case yt.BYTE:case yt.UNSIGNED_BYTE:l=1;break;case yt.SHORT:case yt.UNSIGNED_SHORT:l=2;break;default:l=4}let u=e.itemSize*l;o===yt.ARRAY_BUFFER&&(u=Math.ceil(u/4)*4);const h=nv(r*u),d=new DataView(new ArrayBuffer(h));let p=0;for(let y=n;y<n+r;y++){for(let S=0;S<e.itemSize;S++){let _;e.itemSize>4?_=e.array[y*e.itemSize+S]:(S===0?_=e.getX(y):S===1?_=e.getY(y):S===2?_=e.getZ(y):S===3&&(_=e.getW(y)),e.normalized===!0&&(_=ci.normalize(_,e.array))),t===yt.FLOAT?d.setFloat32(p,_,!0):t===yt.INT?d.setInt32(p,_,!0):t===yt.UNSIGNED_INT?d.setUint32(p,_,!0):t===yt.SHORT?d.setInt16(p,_,!0):t===yt.UNSIGNED_SHORT?d.setUint16(p,_,!0):t===yt.BYTE?d.setInt8(p,_):t===yt.UNSIGNED_BYTE&&d.setUint8(p,_),p+=l}p%u!==0&&(p+=u-p%u)}const m={buffer:this.processBuffer(d.buffer),byteOffset:this.byteOffset,byteLength:h};return o!==void 0&&(m.target=o),o===yt.ARRAY_BUFFER&&(m.byteStride=u),this.byteOffset+=h,a.bufferViews.push(m),{id:a.bufferViews.length-1,byteLength:0}}processBufferViewImage(e){const t=this,n=t.json;return n.bufferViews||(n.bufferViews=[]),new Promise(function(r){const o=new FileReader;o.readAsArrayBuffer(e),o.onloadend=function(){const a=tf(o.result),l={buffer:t.processBuffer(a),byteOffset:t.byteOffset,byteLength:a.byteLength};t.byteOffset+=a.byteLength,r(n.bufferViews.push(l)-1)}})}processAccessor(e,t,n,r){const o=this.json,a={1:"SCALAR",2:"VEC2",3:"VEC3",4:"VEC4",9:"MAT3",16:"MAT4"};let l;if(e.array.constructor===Float32Array)l=yt.FLOAT;else if(e.array.constructor===Int32Array)l=yt.INT;else if(e.array.constructor===Uint32Array)l=yt.UNSIGNED_INT;else if(e.array.constructor===Int16Array)l=yt.SHORT;else if(e.array.constructor===Uint16Array)l=yt.UNSIGNED_SHORT;else if(e.array.constructor===Int8Array)l=yt.BYTE;else if(e.array.constructor===Uint8Array)l=yt.UNSIGNED_BYTE;else throw new Error("THREE.GLTFExporter: Unsupported bufferAttribute component type: "+e.array.constructor.name);if(n===void 0&&(n=0),(r===void 0||r===1/0)&&(r=e.count),r===0)return null;const u=X2(e,n,r);let h;t!==void 0&&(h=e===t.index?yt.ELEMENT_ARRAY_BUFFER:yt.ARRAY_BUFFER);const d=this.processBufferView(e,l,n,r,h),p={bufferView:d.id,byteOffset:d.byteOffset,componentType:l,count:r,max:u.max,min:u.min,type:a[e.itemSize]};return e.normalized===!0&&(p.normalized=!0),o.accessors||(o.accessors=[]),o.accessors.push(p)-1}processImage(e,t,n,r="image/png"){if(e!==null){const o=this,a=o.cache,l=o.json,u=o.options,h=o.pending;a.images.has(e)||a.images.set(e,{});const d=a.images.get(e),p=r+":flipY/"+n.toString();if(d[p]!==void 0)return d[p];l.images||(l.images=[]);const m={mimeType:r},g=G_();g.width=Math.min(e.width,u.maxTextureSize),g.height=Math.min(e.height,u.maxTextureSize);const y=g.getContext("2d");if(n===!0&&(y.translate(0,g.height),y.scale(1,-1)),e.data!==void 0){t!==Ei&&console.error("GLTFExporter: Only RGBAFormat is supported.",t),(e.width>u.maxTextureSize||e.height>u.maxTextureSize)&&console.warn("GLTFExporter: Image size is bigger than maxTextureSize",e);const _=new Uint8ClampedArray(e.height*e.width*4);for(let v=0;v<_.length;v+=4)_[v+0]=e.data[v+0],_[v+1]=e.data[v+1],_[v+2]=e.data[v+2],_[v+3]=e.data[v+3];y.putImageData(new ImageData(_,e.width,e.height),0,0)}else if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap||typeof OffscreenCanvas<"u"&&e instanceof OffscreenCanvas)y.drawImage(e,0,0,g.width,g.height);else throw new Error("THREE.GLTFExporter: Invalid image type. Use HTMLImageElement, HTMLCanvasElement, ImageBitmap or OffscreenCanvas.");u.binary===!0?h.push(V_(g,r).then(_=>o.processBufferViewImage(_)).then(_=>{m.bufferView=_})):g.toDataURL!==void 0?m.uri=g.toDataURL(r):h.push(V_(g,r).then(_=>new FileReader().readAsDataURL(_)).then(_=>{m.uri=_}));const S=l.images.push(m)-1;return d[p]=S,S}else throw new Error("THREE.GLTFExporter: No valid image data found. Unable to process texture.")}processSampler(e){const t=this.json;t.samplers||(t.samplers=[]);const n={magFilter:ai[e.magFilter],minFilter:ai[e.minFilter],wrapS:ai[e.wrapS],wrapT:ai[e.wrapT]};return t.samplers.push(n)-1}processTexture(e){const n=this.options,r=this.cache,o=this.json;if(r.textures.has(e))return r.textures.get(e);o.textures||(o.textures=[]),e instanceof Bh&&(e=El(e,n.maxTextureSize));let a=e.userData.mimeType;a==="image/webp"&&(a="image/png");const l={sampler:this.processSampler(e),source:this.processImage(e.image,e.format,e.flipY,a)};e.name&&(l.name=e.name),this._invokeAll(function(h){h.writeTexture&&h.writeTexture(e,l)});const u=o.textures.push(l)-1;return r.textures.set(e,u),u}processMaterial(e){const t=this.cache,n=this.json;if(t.materials.has(e))return t.materials.get(e);if(e.isShaderMaterial)return console.warn("GLTFExporter: THREE.ShaderMaterial not supported."),null;n.materials||(n.materials=[]);const r={pbrMetallicRoughness:{}};e.isMeshStandardMaterial!==!0&&e.isMeshBasicMaterial!==!0&&console.warn("GLTFExporter: Use MeshStandardMaterial or MeshBasicMaterial for best results.");const o=e.color.toArray().concat([e.opacity]);if(Ia(o,[1,1,1,1])||(r.pbrMetallicRoughness.baseColorFactor=o),e.isMeshStandardMaterial?(r.pbrMetallicRoughness.metallicFactor=e.metalness,r.pbrMetallicRoughness.roughnessFactor=e.roughness):(r.pbrMetallicRoughness.metallicFactor=.5,r.pbrMetallicRoughness.roughnessFactor=.5),e.metalnessMap||e.roughnessMap){const l=this.buildMetalRoughTexture(e.metalnessMap,e.roughnessMap),u={index:this.processTexture(l),channel:l.channel};this.applyTextureTransform(u,l),r.pbrMetallicRoughness.metallicRoughnessTexture=u}if(e.map){const l={index:this.processTexture(e.map),texCoord:e.map.channel};this.applyTextureTransform(l,e.map),r.pbrMetallicRoughness.baseColorTexture=l}if(e.emissive){const l=e.emissive;if(Math.max(l.r,l.g,l.b)>0&&(r.emissiveFactor=e.emissive.toArray()),e.emissiveMap){const h={index:this.processTexture(e.emissiveMap),texCoord:e.emissiveMap.channel};this.applyTextureTransform(h,e.emissiveMap),r.emissiveTexture=h}}if(e.normalMap){const l={index:this.processTexture(e.normalMap),texCoord:e.normalMap.channel};e.normalScale&&e.normalScale.x!==1&&(l.scale=e.normalScale.x),this.applyTextureTransform(l,e.normalMap),r.normalTexture=l}if(e.aoMap){const l={index:this.processTexture(e.aoMap),texCoord:e.aoMap.channel};e.aoMapIntensity!==1&&(l.strength=e.aoMapIntensity),this.applyTextureTransform(l,e.aoMap),r.occlusionTexture=l}e.transparent?r.alphaMode="BLEND":e.alphaTest>0&&(r.alphaMode="MASK",r.alphaCutoff=e.alphaTest),e.side===si&&(r.doubleSided=!0),e.name!==""&&(r.name=e.name),this.serializeUserData(e,r),this._invokeAll(function(l){l.writeMaterial&&l.writeMaterial(e,r)});const a=n.materials.push(r)-1;return t.materials.set(e,a),a}processMesh(e){const t=this.cache,n=this.json,r=[e.geometry.uuid];if(Array.isArray(e.material))for(let A=0,B=e.material.length;A<B;A++)r.push(e.material[A].uuid);else r.push(e.material.uuid);const o=r.join(":");if(t.meshes.has(o))return t.meshes.get(o);const a=e.geometry;let l;e.isLineSegments?l=yt.LINES:e.isLineLoop?l=yt.LINE_LOOP:e.isLine?l=yt.LINE_STRIP:e.isPoints?l=yt.POINTS:l=e.material.wireframe?yt.LINES:yt.TRIANGLES;const u={},h={},d=[],p=[],m={uv:"TEXCOORD_0",uv1:"TEXCOORD_1",uv2:"TEXCOORD_2",uv3:"TEXCOORD_3",color:"COLOR_0",skinWeight:"WEIGHTS_0",skinIndex:"JOINTS_0"},g=a.getAttribute("normal");g!==void 0&&!this.isNormalizedNormalAttribute(g)&&(console.warn("THREE.GLTFExporter: Creating normalized normal attribute from the non-normalized one."),a.setAttribute("normal",this.createNormalizedNormalAttribute(g)));let y=null;for(let A in a.attributes){if(A.slice(0,5)==="morph")continue;const B=a.attributes[A];if(A=m[A]||A.toUpperCase(),/^(POSITION|NORMAL|TANGENT|TEXCOORD_\d+|COLOR_\d+|JOINTS_\d+|WEIGHTS_\d+)$/.test(A)||(A="_"+A),t.attributes.has(this.getUID(B))){h[A]=t.attributes.get(this.getUID(B));continue}y=null;const D=B.array;A==="JOINTS_0"&&!(D instanceof Uint16Array)&&!(D instanceof Uint8Array)&&(console.warn('GLTFExporter: Attribute "skinIndex" converted to type UNSIGNED_SHORT.'),y=new Nt(new Uint16Array(D),B.itemSize,B.normalized));const C=this.processAccessor(y||B,a);C!==null&&(A.startsWith("_")||this.detectMeshQuantization(A,B),h[A]=C,t.attributes.set(this.getUID(B),C))}if(g!==void 0&&a.setAttribute("normal",g),Object.keys(h).length===0)return null;if(e.morphTargetInfluences!==void 0&&e.morphTargetInfluences.length>0){const A=[],B=[],N={};if(e.morphTargetDictionary!==void 0)for(const D in e.morphTargetDictionary)N[e.morphTargetDictionary[D]]=D;for(let D=0;D<e.morphTargetInfluences.length;++D){const C={};let E=!1;for(const M in a.morphAttributes){if(M!=="position"&&M!=="normal"){E||(console.warn("GLTFExporter: Only POSITION and NORMAL morph are supported."),E=!0);continue}const O=a.morphAttributes[M][D],H=M.toUpperCase(),G=a.attributes[M];if(t.attributes.has(this.getUID(O,!0))){C[H]=t.attributes.get(this.getUID(O,!0));continue}const Y=O.clone();if(!a.morphTargetsRelative)for(let $=0,re=O.count;$<re;$++)for(let se=0;se<O.itemSize;se++)se===0&&Y.setX($,O.getX($)-G.getX($)),se===1&&Y.setY($,O.getY($)-G.getY($)),se===2&&Y.setZ($,O.getZ($)-G.getZ($)),se===3&&Y.setW($,O.getW($)-G.getW($));C[H]=this.processAccessor(Y,a),t.attributes.set(this.getUID(G,!0),C[H])}p.push(C),A.push(e.morphTargetInfluences[D]),e.morphTargetDictionary!==void 0&&B.push(N[D])}u.weights=A,B.length>0&&(u.extras={},u.extras.targetNames=B)}const S=Array.isArray(e.material);if(S&&a.groups.length===0)return null;let _=!1;if(S&&a.index===null){const A=[];for(let B=0,N=a.attributes.position.count;B<N;B++)A[B]=B;a.setIndex(A),_=!0}const v=S?e.material:[e.material],R=S?a.groups:[{materialIndex:0,start:void 0,count:void 0}];for(let A=0,B=R.length;A<B;A++){const N={mode:l,attributes:h};if(this.serializeUserData(a,N),p.length>0&&(N.targets=p),a.index!==null){let C=this.getUID(a.index);(R[A].start!==void 0||R[A].count!==void 0)&&(C+=":"+R[A].start+":"+R[A].count),t.attributes.has(C)?N.indices=t.attributes.get(C):(N.indices=this.processAccessor(a.index,a,R[A].start,R[A].count),t.attributes.set(C,N.indices)),N.indices===null&&delete N.indices}const D=this.processMaterial(v[R[A].materialIndex]);D!==null&&(N.material=D),d.push(N)}_===!0&&a.setIndex(null),u.primitives=d,n.meshes||(n.meshes=[]),this._invokeAll(function(A){A.writeMesh&&A.writeMesh(e,u)});const b=n.meshes.push(u)-1;return t.meshes.set(o,b),b}detectMeshQuantization(e,t){if(this.extensionsUsed[ef])return;let n;switch(t.array.constructor){case Int8Array:n="byte";break;case Uint8Array:n="unsigned byte";break;case Int16Array:n="short";break;case Uint16Array:n="unsigned short";break;default:return}t.normalized&&(n+=" normalized");const r=e.split("_",1)[0];B_[r]&&B_[r].includes(n)&&(this.extensionsUsed[ef]=!0,this.extensionsRequired[ef]=!0)}processCamera(e){const t=this.json;t.cameras||(t.cameras=[]);const n=e.isOrthographicCamera,r={type:n?"orthographic":"perspective"};return n?r.orthographic={xmag:e.right*2,ymag:e.top*2,zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near}:r.perspective={aspectRatio:e.aspect,yfov:ci.degToRad(e.fov),zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near},e.name!==""&&(r.name=e.type),t.cameras.push(r)-1}processAnimation(e,t){const n=this.json,r=this.nodeMap;n.animations||(n.animations=[]),e=id.Utils.mergeMorphTargetTracks(e.clone(),t);const o=e.tracks,a=[],l=[];for(let u=0;u<o.length;++u){const h=o[u],d=wt.parseTrackName(h.name);let p=wt.findNode(t,d.nodeName);const m=z_[d.propertyName];if(d.objectName==="bones"&&(p.isSkinnedMesh===!0?p=p.skeleton.getBoneByName(d.objectIndex):p=void 0),!p||!m)return console.warn('THREE.GLTFExporter: Could not export animation track "%s".',h.name),null;const g=1;let y=h.values.length/h.times.length;m===z_.morphTargetInfluences&&(y/=p.morphTargetInfluences.length);let S;h.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline===!0?(S="CUBICSPLINE",y/=3):h.getInterpolation()===Lo?S="STEP":S="LINEAR",l.push({input:this.processAccessor(new Nt(h.times,g)),output:this.processAccessor(new Nt(h.values,y)),interpolation:S}),a.push({sampler:l.length-1,target:{node:r.get(p),path:m}})}return n.animations.push({name:e.name||"clip_"+n.animations.length,samplers:l,channels:a}),n.animations.length-1}processSkin(e){const t=this.json,n=this.nodeMap,r=t.nodes[n.get(e)],o=e.skeleton;if(o===void 0)return null;const a=e.skeleton.bones[0];if(a===void 0)return null;const l=[],u=new Float32Array(o.bones.length*16),h=new Qe;for(let p=0;p<o.bones.length;++p)l.push(n.get(o.bones[p])),h.copy(o.boneInverses[p]),h.multiply(e.bindMatrix).toArray(u,p*16);return t.skins===void 0&&(t.skins=[]),t.skins.push({inverseBindMatrices:this.processAccessor(new Nt(u,16)),joints:l,skeleton:n.get(a)}),r.skin=t.skins.length-1}processNode(e){const t=this.json,n=this.options,r=this.nodeMap;t.nodes||(t.nodes=[]);const o={};if(n.trs){const l=e.quaternion.toArray(),u=e.position.toArray(),h=e.scale.toArray();Ia(l,[0,0,0,1])||(o.rotation=l),Ia(u,[0,0,0])||(o.translation=u),Ia(h,[1,1,1])||(o.scale=h)}else e.matrixAutoUpdate&&e.updateMatrix(),W2(e.matrix)===!1&&(o.matrix=e.matrix.elements);if(e.name!==""&&(o.name=String(e.name)),this.serializeUserData(e,o),e.isMesh||e.isLine||e.isPoints){const l=this.processMesh(e);l!==null&&(o.mesh=l)}else e.isCamera&&(o.camera=this.processCamera(e));if(e.isSkinnedMesh&&this.skins.push(e),e.children.length>0){const l=[];for(let u=0,h=e.children.length;u<h;u++){const d=e.children[u];if(d.visible||n.onlyVisible===!1){const p=this.processNode(d);p!==null&&l.push(p)}}l.length>0&&(o.children=l)}this._invokeAll(function(l){l.writeNode&&l.writeNode(e,o)});const a=t.nodes.push(o)-1;return r.set(e,a),a}processScene(e){const t=this.json,n=this.options;t.scenes||(t.scenes=[],t.scene=0);const r={};e.name!==""&&(r.name=e.name),t.scenes.push(r);const o=[];for(let a=0,l=e.children.length;a<l;a++){const u=e.children[a];if(u.visible||n.onlyVisible===!1){const h=this.processNode(u);h!==null&&o.push(h)}}o.length>0&&(r.nodes=o),this.serializeUserData(e,r)}processObjects(e){const t=new Pl;t.name="AuxScene";for(let n=0;n<e.length;n++)t.children.push(e[n]);this.processScene(t)}processInput(e){const t=this.options;e=e instanceof Array?e:[e],this._invokeAll(function(r){r.beforeParse&&r.beforeParse(e)});const n=[];for(let r=0;r<e.length;r++)e[r]instanceof Pl?this.processScene(e[r]):n.push(e[r]);n.length>0&&this.processObjects(n);for(let r=0;r<this.skins.length;++r)this.processSkin(this.skins[r]);for(let r=0;r<t.animations.length;++r)this.processAnimation(t.animations[r],e[0]);this._invokeAll(function(r){r.afterParse&&r.afterParse(e)})}_invokeAll(e){for(let t=0,n=this.plugins.length;t<n;t++)e(this.plugins[t])}}class j2{constructor(e){this.writer=e,this.name="KHR_lights_punctual"}writeNode(e,t){if(!e.isLight)return;if(!e.isDirectionalLight&&!e.isPointLight&&!e.isSpotLight){console.warn("THREE.GLTFExporter: Only directional, point, and spot lights are supported.",e);return}const n=this.writer,r=n.json,o=n.extensionsUsed,a={};e.name&&(a.name=e.name),a.color=e.color.toArray(),a.intensity=e.intensity,e.isDirectionalLight?a.type="directional":e.isPointLight?(a.type="point",e.distance>0&&(a.range=e.distance)):e.isSpotLight&&(a.type="spot",e.distance>0&&(a.range=e.distance),a.spot={},a.spot.innerConeAngle=(1-e.penumbra)*e.angle,a.spot.outerConeAngle=e.angle),e.decay!==void 0&&e.decay!==2&&console.warn("THREE.GLTFExporter: Light decay may be lost. glTF is physically-based, and expects light.decay=2."),e.target&&(e.target.parent!==e||e.target.position.x!==0||e.target.position.y!==0||e.target.position.z!==-1)&&console.warn("THREE.GLTFExporter: Light direction may be lost. For best results, make light.target a child of the light with position 0,0,-1."),o[this.name]||(r.extensions=r.extensions||{},r.extensions[this.name]={lights:[]},o[this.name]=!0);const l=r.extensions[this.name].lights;l.push(a),t.extensions=t.extensions||{},t.extensions[this.name]={light:l.length-1}}}class q2{constructor(e){this.writer=e,this.name="KHR_materials_unlit"}writeMaterial(e,t){if(!e.isMeshBasicMaterial)return;const r=this.writer.extensionsUsed;t.extensions=t.extensions||{},t.extensions[this.name]={},r[this.name]=!0,t.pbrMetallicRoughness.metallicFactor=0,t.pbrMetallicRoughness.roughnessFactor=.9}}class $2{constructor(e){this.writer=e,this.name="KHR_materials_clearcoat"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.clearcoat===0)return;const n=this.writer,r=n.extensionsUsed,o={};if(o.clearcoatFactor=e.clearcoat,e.clearcoatMap){const a={index:n.processTexture(e.clearcoatMap),texCoord:e.clearcoatMap.channel};n.applyTextureTransform(a,e.clearcoatMap),o.clearcoatTexture=a}if(o.clearcoatRoughnessFactor=e.clearcoatRoughness,e.clearcoatRoughnessMap){const a={index:n.processTexture(e.clearcoatRoughnessMap),texCoord:e.clearcoatRoughnessMap.channel};n.applyTextureTransform(a,e.clearcoatRoughnessMap),o.clearcoatRoughnessTexture=a}if(e.clearcoatNormalMap){const a={index:n.processTexture(e.clearcoatNormalMap),texCoord:e.clearcoatNormalMap.channel};n.applyTextureTransform(a,e.clearcoatNormalMap),o.clearcoatNormalTexture=a}t.extensions=t.extensions||{},t.extensions[this.name]=o,r[this.name]=!0}}class K2{constructor(e){this.writer=e,this.name="KHR_materials_iridescence"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.iridescence===0)return;const n=this.writer,r=n.extensionsUsed,o={};if(o.iridescenceFactor=e.iridescence,e.iridescenceMap){const a={index:n.processTexture(e.iridescenceMap),texCoord:e.iridescenceMap.channel};n.applyTextureTransform(a,e.iridescenceMap),o.iridescenceTexture=a}if(o.iridescenceIor=e.iridescenceIOR,o.iridescenceThicknessMinimum=e.iridescenceThicknessRange[0],o.iridescenceThicknessMaximum=e.iridescenceThicknessRange[1],e.iridescenceThicknessMap){const a={index:n.processTexture(e.iridescenceThicknessMap),texCoord:e.iridescenceThicknessMap.channel};n.applyTextureTransform(a,e.iridescenceThicknessMap),o.iridescenceThicknessTexture=a}t.extensions=t.extensions||{},t.extensions[this.name]=o,r[this.name]=!0}}class Z2{constructor(e){this.writer=e,this.name="KHR_materials_transmission"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.transmission===0)return;const n=this.writer,r=n.extensionsUsed,o={};if(o.transmissionFactor=e.transmission,e.transmissionMap){const a={index:n.processTexture(e.transmissionMap),texCoord:e.transmissionMap.channel};n.applyTextureTransform(a,e.transmissionMap),o.transmissionTexture=a}t.extensions=t.extensions||{},t.extensions[this.name]=o,r[this.name]=!0}}class J2{constructor(e){this.writer=e,this.name="KHR_materials_volume"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.transmission===0)return;const n=this.writer,r=n.extensionsUsed,o={};if(o.thicknessFactor=e.thickness,e.thicknessMap){const a={index:n.processTexture(e.thicknessMap),texCoord:e.thicknessMap.channel};n.applyTextureTransform(a,e.thicknessMap),o.thicknessTexture=a}o.attenuationDistance=e.attenuationDistance,o.attenuationColor=e.attenuationColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=o,r[this.name]=!0}}class Q2{constructor(e){this.writer=e,this.name="KHR_materials_ior"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.ior===1.5)return;const r=this.writer.extensionsUsed,o={};o.ior=e.ior,t.extensions=t.extensions||{},t.extensions[this.name]=o,r[this.name]=!0}}class eD{constructor(e){this.writer=e,this.name="KHR_materials_specular"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.specularIntensity===1&&e.specularColor.equals(B2)&&!e.specularIntensityMap&&!e.specularColorMap)return;const n=this.writer,r=n.extensionsUsed,o={};if(e.specularIntensityMap){const a={index:n.processTexture(e.specularIntensityMap),texCoord:e.specularIntensityMap.channel};n.applyTextureTransform(a,e.specularIntensityMap),o.specularTexture=a}if(e.specularColorMap){const a={index:n.processTexture(e.specularColorMap),texCoord:e.specularColorMap.channel};n.applyTextureTransform(a,e.specularColorMap),o.specularColorTexture=a}o.specularFactor=e.specularIntensity,o.specularColorFactor=e.specularColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=o,r[this.name]=!0}}class tD{constructor(e){this.writer=e,this.name="KHR_materials_sheen"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.sheen==0)return;const n=this.writer,r=n.extensionsUsed,o={};if(e.sheenRoughnessMap){const a={index:n.processTexture(e.sheenRoughnessMap),texCoord:e.sheenRoughnessMap.channel};n.applyTextureTransform(a,e.sheenRoughnessMap),o.sheenRoughnessTexture=a}if(e.sheenColorMap){const a={index:n.processTexture(e.sheenColorMap),texCoord:e.sheenColorMap.channel};n.applyTextureTransform(a,e.sheenColorMap),o.sheenColorTexture=a}o.sheenRoughnessFactor=e.sheenRoughness,o.sheenColorFactor=e.sheenColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=o,r[this.name]=!0}}class nD{constructor(e){this.writer=e,this.name="KHR_materials_anisotropy"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.anisotropy==0)return;const n=this.writer,r=n.extensionsUsed,o={};if(e.anisotropyMap){const a={index:n.processTexture(e.anisotropyMap)};n.applyTextureTransform(a,e.anisotropyMap),o.anisotropyTexture=a}o.anisotropyStrength=e.anisotropy,o.anisotropyRotation=e.anisotropyRotation,t.extensions=t.extensions||{},t.extensions[this.name]=o,r[this.name]=!0}}class iD{constructor(e){this.writer=e,this.name="KHR_materials_emissive_strength"}writeMaterial(e,t){if(!e.isMeshStandardMaterial||e.emissiveIntensity===1)return;const r=this.writer.extensionsUsed,o={};o.emissiveStrength=e.emissiveIntensity,t.extensions=t.extensions||{},t.extensions[this.name]=o,r[this.name]=!0}}class rD{constructor(e){this.writer=e,this.name="EXT_materials_bump"}writeMaterial(e,t){if(!e.isMeshStandardMaterial||e.bumpScale===1&&!e.bumpMap)return;const n=this.writer,r=n.extensionsUsed,o={};if(e.bumpMap){const a={index:n.processTexture(e.bumpMap),texCoord:e.bumpMap.channel};n.applyTextureTransform(a,e.bumpMap),o.bumpTexture=a}o.bumpFactor=e.bumpScale,t.extensions=t.extensions||{},t.extensions[this.name]=o,r[this.name]=!0}}class sD{constructor(e){this.writer=e,this.name="EXT_mesh_gpu_instancing"}writeNode(e,t){if(!e.isInstancedMesh)return;const n=this.writer,r=e,o=new Float32Array(r.count*3),a=new Float32Array(r.count*4),l=new Float32Array(r.count*3),u=new Qe,h=new F,d=new an,p=new F;for(let g=0;g<r.count;g++)r.getMatrixAt(g,u),u.decompose(h,d,p),h.toArray(o,g*3),d.toArray(a,g*4),p.toArray(l,g*3);const m={TRANSLATION:n.processAccessor(new Nt(o,3)),ROTATION:n.processAccessor(new Nt(a,4)),SCALE:n.processAccessor(new Nt(l,3))};r.instanceColor&&(m._COLOR_0=n.processAccessor(r.instanceColor)),t.extensions=t.extensions||{},t.extensions[this.name]={attributes:m},n.extensionsUsed[this.name]=!0,n.extensionsRequired[this.name]=!0}}id.Utils={insertKeyframe:function(i,e){const n=i.getValueSize(),r=new i.TimeBufferType(i.times.length+1),o=new i.ValueBufferType(i.values.length+n),a=i.createInterpolant(new i.ValueBufferType(n));let l;if(i.times.length===0){r[0]=e;for(let u=0;u<n;u++)o[u]=0;l=0}else if(e<i.times[0]){if(Math.abs(i.times[0]-e)<.001)return 0;r[0]=e,r.set(i.times,1),o.set(a.evaluate(e),0),o.set(i.values,n),l=0}else if(e>i.times[i.times.length-1]){if(Math.abs(i.times[i.times.length-1]-e)<.001)return i.times.length-1;r[r.length-1]=e,r.set(i.times,0),o.set(i.values,0),o.set(a.evaluate(e),i.values.length),l=r.length-1}else for(let u=0;u<i.times.length;u++){if(Math.abs(i.times[u]-e)<.001)return u;if(i.times[u]<e&&i.times[u+1]>e){r.set(i.times.slice(0,u+1),0),r[u+1]=e,r.set(i.times.slice(u+1),u+2),o.set(i.values.slice(0,(u+1)*n),0),o.set(a.evaluate(e),(u+1)*n),o.set(i.values.slice((u+1)*n),(u+2)*n),l=u+1;break}}return i.times=r,i.values=o,l},mergeMorphTargetTracks:function(i,e){const t=[],n={},r=i.tracks;for(let o=0;o<r.length;++o){let a=r[o];const l=wt.parseTrackName(a.name),u=wt.findNode(e,l.nodeName);if(l.propertyName!=="morphTargetInfluences"||l.propertyIndex===void 0){t.push(a);continue}if(a.createInterpolant!==a.InterpolantFactoryMethodDiscrete&&a.createInterpolant!==a.InterpolantFactoryMethodLinear){if(a.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline)throw new Error("THREE.GLTFExporter: Cannot merge tracks with glTF CUBICSPLINE interpolation.");console.warn("THREE.GLTFExporter: Morph target interpolation mode not yet supported. Using LINEAR instead."),a=a.clone(),a.setInterpolation(As)}const h=u.morphTargetInfluences.length,d=u.morphTargetDictionary[l.propertyIndex];if(d===void 0)throw new Error("THREE.GLTFExporter: Morph target name not found: "+l.propertyIndex);let p;if(n[u.uuid]===void 0){p=a.clone();const g=new p.ValueBufferType(h*p.times.length);for(let y=0;y<p.times.length;y++)g[y*h+d]=p.values[y];p.name=(l.nodeName||"")+".morphTargetInfluences",p.values=g,n[u.uuid]=p,t.push(p);continue}const m=a.createInterpolant(new a.ValueBufferType(1));p=n[u.uuid];for(let g=0;g<p.times.length;g++)p.values[g*h+d]=m.evaluate(p.times[g]);for(let g=0;g<a.times.length;g++){const y=this.insertKeyframe(p,a.times[g]);p.values[y*h+d]=a.values[g]}}return i.tracks=t,i}};class oD{async parse(e,t={}){t=Object.assign({ar:{anchoring:{type:"plane"},planeAnchoring:{alignment:"horizontal"}},quickLookCompatible:!1,maxTextureSize:1024},t);const n={},r="model.usda";n[r]=null;let o=iv();o+=cD(t);const a={},l={};e.traverseVisible(h=>{if(h.isMesh){const d=h.geometry,p=h.material;if(p.isMeshStandardMaterial){const m="geometries/Geometry_"+d.id+".usda";if(!(m in n)){const g=fD(d);n[m]=uD(g)}p.uuid in a||(a[p.uuid]=p),o+=hD(h,d,p)}else console.warn("THREE.USDZExporter: Unsupported material type (USDZ only supports MeshStandardMaterial)",h)}else h.isCamera&&(o+=MD(h))}),o+=lD(),o+=vD(a,l,t.quickLookCompatible),n[r]=Dl(o),o=null;for(const h in l){let d=l[h];d.isCompressedTexture===!0&&(d=El(d));const p=aD(d.image,d.flipY,t.maxTextureSize),m=await new Promise(g=>p.toBlob(g,"image/png",1));n[`textures/Texture_${h}.png`]=new Uint8Array(await m.arrayBuffer())}let u=0;for(const h in n){const d=n[h],p=34+h.length;u+=p;const m=u&63;if(m!==4){const g=64-m,y=new Uint8Array(g);n[h]=[d,{extra:{12345:y}}]}u=d.length}return YI(n,{level:0})}}function aD(i,e,t){if(typeof HTMLImageElement<"u"&&i instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&i instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&i instanceof OffscreenCanvas||typeof ImageBitmap<"u"&&i instanceof ImageBitmap){const n=t/Math.max(i.width,i.height),r=document.createElement("canvas");r.width=i.width*Math.min(1,n),r.height=i.height*Math.min(1,n);const o=r.getContext("2d");return e===!0&&(o.translate(0,r.height),o.scale(1,-1)),o.drawImage(i,0,0,r.width,r.height),r}else throw new Error("THREE.USDZExporter: No valid image data found. Unable to process texture.")}const Dn=7;function iv(){return`#usda 1.0
3849
+ }`})),xo.uniforms.blitTexture.value=i,xo.defines.IS_SRGB=i.colorSpace==on,xo.needsUpdate=!0,_l||(_l=new Se(tf,xo),_l.frustumCulled=!1);const n=new Un,r=new Pl;r.add(_l),t===null&&(t=Ta=new w0({antialias:!1}));const o=Math.min(i.image.width,e),a=Math.min(i.image.height,e);t.setSize(o,a),t.clear(),t.render(r,n);const l=document.createElement("canvas"),u=l.getContext("2d");l.width=o,l.height=a,u.drawImage(t.domElement,0,0,o,a);const h=new zP(l);return h.minFilter=i.minFilter,h.magFilter=i.magFilter,h.wrapS=i.wrapS,h.wrapT=i.wrapT,h.name=i.name,Ta&&(Ta.forceContextLoss(),Ta.dispose(),Ta=null),h}const z_={POSITION:["byte","byte normalized","unsigned byte","unsigned byte normalized","short","short normalized","unsigned short","unsigned short normalized"],NORMAL:["byte normalized","short normalized"],TANGENT:["byte normalized","short normalized"],TEXCOORD:["byte","byte normalized","unsigned byte","short","short normalized","unsigned short"]};class id{constructor(){this.pluginCallbacks=[],this.register(function(e){return new j2(e)}),this.register(function(e){return new q2(e)}),this.register(function(e){return new Z2(e)}),this.register(function(e){return new J2(e)}),this.register(function(e){return new Q2(e)}),this.register(function(e){return new eD(e)}),this.register(function(e){return new $2(e)}),this.register(function(e){return new K2(e)}),this.register(function(e){return new tD(e)}),this.register(function(e){return new nD(e)}),this.register(function(e){return new iD(e)}),this.register(function(e){return new rD(e)}),this.register(function(e){return new sD(e)})}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,n,r){const o=new Y2,a=[];for(let l=0,u=this.pluginCallbacks.length;l<u;l++)a.push(this.pluginCallbacks[l](o));o.setPlugins(a),o.write(e,t,r).catch(n)}parseAsync(e,t){const n=this;return new Promise(function(r,o){n.parse(e,r,o,t)})}}const yt={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,INT:5124,UNSIGNED_INT:5125,FLOAT:5126,ARRAY_BUFFER:34962,ELEMENT_ARRAY_BUFFER:34963,NEAREST:9728,LINEAR:9729,NEAREST_MIPMAP_NEAREST:9984,LINEAR_MIPMAP_NEAREST:9985,NEAREST_MIPMAP_LINEAR:9986,LINEAR_MIPMAP_LINEAR:9987,CLAMP_TO_EDGE:33071,MIRRORED_REPEAT:33648,REPEAT:10497},nf="KHR_mesh_quantization",ai={};ai[Nn]=yt.NEAREST;ai[Nf]=yt.NEAREST_MIPMAP_NEAREST;ai[yo]=yt.NEAREST_MIPMAP_LINEAR;ai[Xn]=yt.LINEAR;ai[Da]=yt.LINEAR_MIPMAP_NEAREST;ai[Ki]=yt.LINEAR_MIPMAP_LINEAR;ai[$i]=yt.CLAMP_TO_EDGE;ai[es]=yt.REPEAT;ai[Co]=yt.MIRRORED_REPEAT;const k_={scale:"scale",position:"translation",quaternion:"rotation",morphTargetInfluences:"weights"},B2=new Oe,H_=12,z2=1179937895,k2=2,G_=8,H2=1313821514,G2=5130562;function Ia(i,e){return i.length===e.length&&i.every(function(t,n){return t===e[n]})}function V2(i){return new TextEncoder().encode(i).buffer}function W2(i){return Ia(i.elements,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}function X2(i,e,t){const n={min:new Array(i.itemSize).fill(Number.POSITIVE_INFINITY),max:new Array(i.itemSize).fill(Number.NEGATIVE_INFINITY)};for(let r=e;r<e+t;r++)for(let o=0;o<i.itemSize;o++){let a;i.itemSize>4?a=i.array[r*i.itemSize+o]:(o===0?a=i.getX(r):o===1?a=i.getY(r):o===2?a=i.getZ(r):o===3&&(a=i.getW(r)),i.normalized===!0&&(a=ci.normalize(a,i.array))),n.min[o]=Math.min(n.min[o],a),n.max[o]=Math.max(n.max[o],a)}return n}function nv(i){return Math.ceil(i/4)*4}function rf(i,e=0){const t=nv(i.byteLength);if(t!==i.byteLength){const n=new Uint8Array(t);if(n.set(new Uint8Array(i)),e!==0)for(let r=i.byteLength;r<t;r++)n[r]=e;return n.buffer}return i}function V_(){return typeof document>"u"&&typeof OffscreenCanvas<"u"?new OffscreenCanvas(1,1):document.createElement("canvas")}function W_(i,e){if(i.toBlob!==void 0)return new Promise(n=>i.toBlob(n,e));let t;return e==="image/jpeg"?t=.92:e==="image/webp"&&(t=.8),i.convertToBlob({type:e,quality:t})}class Y2{constructor(){this.plugins=[],this.options={},this.pending=[],this.buffers=[],this.byteOffset=0,this.buffers=[],this.nodeMap=new Map,this.skins=[],this.extensionsUsed={},this.extensionsRequired={},this.uids=new Map,this.uid=0,this.json={asset:{version:"2.0",generator:"THREE.GLTFExporter"}},this.cache={meshes:new Map,attributes:new Map,attributesNormalized:new Map,materials:new Map,textures:new Map,images:new Map}}setPlugins(e){this.plugins=e}async write(e,t,n={}){this.options=Object.assign({binary:!1,trs:!1,onlyVisible:!0,maxTextureSize:1/0,animations:[],includeCustomExtensions:!1},n),this.options.animations.length>0&&(this.options.trs=!0),this.processInput(e),await Promise.all(this.pending);const r=this,o=r.buffers,a=r.json;n=r.options;const l=r.extensionsUsed,u=r.extensionsRequired,h=new Blob(o,{type:"application/octet-stream"}),d=Object.keys(l),p=Object.keys(u);if(d.length>0&&(a.extensionsUsed=d),p.length>0&&(a.extensionsRequired=p),a.buffers&&a.buffers.length>0&&(a.buffers[0].byteLength=h.size),n.binary===!0){const m=new FileReader;m.readAsArrayBuffer(h),m.onloadend=function(){const g=rf(m.result),y=new DataView(new ArrayBuffer(G_));y.setUint32(0,g.byteLength,!0),y.setUint32(4,G2,!0);const S=rf(V2(JSON.stringify(a)),32),_=new DataView(new ArrayBuffer(G_));_.setUint32(0,S.byteLength,!0),_.setUint32(4,H2,!0);const v=new ArrayBuffer(H_),R=new DataView(v);R.setUint32(0,z2,!0),R.setUint32(4,k2,!0);const b=H_+_.byteLength+S.byteLength+y.byteLength+g.byteLength;R.setUint32(8,b,!0);const A=new Blob([v,_,S,y,g],{type:"application/octet-stream"}),B=new FileReader;B.readAsArrayBuffer(A),B.onloadend=function(){t(B.result)}}}else if(a.buffers&&a.buffers.length>0){const m=new FileReader;m.readAsDataURL(h),m.onloadend=function(){const g=m.result;a.buffers[0].uri=g,t(a)}}else t(a)}serializeUserData(e,t){if(Object.keys(e.userData).length===0)return;const n=this.options,r=this.extensionsUsed;try{const o=JSON.parse(JSON.stringify(e.userData));if(n.includeCustomExtensions&&o.gltfExtensions){t.extensions===void 0&&(t.extensions={});for(const a in o.gltfExtensions)t.extensions[a]=o.gltfExtensions[a],r[a]=!0;delete o.gltfExtensions}Object.keys(o).length>0&&(t.extras=o)}catch(o){console.warn("THREE.GLTFExporter: userData of '"+e.name+"' won't be serialized because of JSON.stringify error - "+o.message)}}getUID(e,t=!1){if(this.uids.has(e)===!1){const r=new Map;r.set(!0,this.uid++),r.set(!1,this.uid++),this.uids.set(e,r)}return this.uids.get(e).get(t)}isNormalizedNormalAttribute(e){if(this.cache.attributesNormalized.has(e))return!1;const n=new F;for(let r=0,o=e.count;r<o;r++)if(Math.abs(n.fromBufferAttribute(e,r).length()-1)>5e-4)return!1;return!0}createNormalizedNormalAttribute(e){const t=this.cache;if(t.attributesNormalized.has(e))return t.attributesNormalized.get(e);const n=e.clone(),r=new F;for(let o=0,a=n.count;o<a;o++)r.fromBufferAttribute(n,o),r.x===0&&r.y===0&&r.z===0?r.setX(1):r.normalize(),n.setXYZ(o,r.x,r.y,r.z);return t.attributesNormalized.set(e,n),n}applyTextureTransform(e,t){let n=!1;const r={};(t.offset.x!==0||t.offset.y!==0)&&(r.offset=t.offset.toArray(),n=!0),t.rotation!==0&&(r.rotation=t.rotation,n=!0),(t.repeat.x!==1||t.repeat.y!==1)&&(r.scale=t.repeat.toArray(),n=!0),n&&(e.extensions=e.extensions||{},e.extensions.KHR_texture_transform=r,this.extensionsUsed.KHR_texture_transform=!0)}buildMetalRoughTexture(e,t){if(e===t)return e;function n(g){return g.colorSpace===on?function(S){return S<.04045?S*.0773993808:Math.pow(S*.9478672986+.0521327014,2.4)}:function(S){return S}}console.warn("THREE.GLTFExporter: Merged metalnessMap and roughnessMap textures."),e instanceof zh&&(e=El(e)),t instanceof zh&&(t=El(t));const r=e?e.image:null,o=t?t.image:null,a=Math.max(r?r.width:0,o?o.width:0),l=Math.max(r?r.height:0,o?o.height:0),u=V_();u.width=a,u.height=l;const h=u.getContext("2d");h.fillStyle="#00ffff",h.fillRect(0,0,a,l);const d=h.getImageData(0,0,a,l);if(r){h.drawImage(r,0,0,a,l);const g=n(e),y=h.getImageData(0,0,a,l).data;for(let S=2;S<y.length;S+=4)d.data[S]=g(y[S]/256)*256}if(o){h.drawImage(o,0,0,a,l);const g=n(t),y=h.getImageData(0,0,a,l).data;for(let S=1;S<y.length;S+=4)d.data[S]=g(y[S]/256)*256}h.putImageData(d,0,0);const m=(e||t).clone();return m.source=new Bf(u),m.colorSpace=Sn,m.channel=(e||t).channel,e&&t&&e.channel!==t.channel&&console.warn("THREE.GLTFExporter: UV channels for metalnessMap and roughnessMap textures must match."),m}processBuffer(e){const t=this.json,n=this.buffers;return t.buffers||(t.buffers=[{byteLength:0}]),n.push(e),0}processBufferView(e,t,n,r,o){const a=this.json;a.bufferViews||(a.bufferViews=[]);let l;switch(t){case yt.BYTE:case yt.UNSIGNED_BYTE:l=1;break;case yt.SHORT:case yt.UNSIGNED_SHORT:l=2;break;default:l=4}let u=e.itemSize*l;o===yt.ARRAY_BUFFER&&(u=Math.ceil(u/4)*4);const h=nv(r*u),d=new DataView(new ArrayBuffer(h));let p=0;for(let y=n;y<n+r;y++){for(let S=0;S<e.itemSize;S++){let _;e.itemSize>4?_=e.array[y*e.itemSize+S]:(S===0?_=e.getX(y):S===1?_=e.getY(y):S===2?_=e.getZ(y):S===3&&(_=e.getW(y)),e.normalized===!0&&(_=ci.normalize(_,e.array))),t===yt.FLOAT?d.setFloat32(p,_,!0):t===yt.INT?d.setInt32(p,_,!0):t===yt.UNSIGNED_INT?d.setUint32(p,_,!0):t===yt.SHORT?d.setInt16(p,_,!0):t===yt.UNSIGNED_SHORT?d.setUint16(p,_,!0):t===yt.BYTE?d.setInt8(p,_):t===yt.UNSIGNED_BYTE&&d.setUint8(p,_),p+=l}p%u!==0&&(p+=u-p%u)}const m={buffer:this.processBuffer(d.buffer),byteOffset:this.byteOffset,byteLength:h};return o!==void 0&&(m.target=o),o===yt.ARRAY_BUFFER&&(m.byteStride=u),this.byteOffset+=h,a.bufferViews.push(m),{id:a.bufferViews.length-1,byteLength:0}}processBufferViewImage(e){const t=this,n=t.json;return n.bufferViews||(n.bufferViews=[]),new Promise(function(r){const o=new FileReader;o.readAsArrayBuffer(e),o.onloadend=function(){const a=rf(o.result),l={buffer:t.processBuffer(a),byteOffset:t.byteOffset,byteLength:a.byteLength};t.byteOffset+=a.byteLength,r(n.bufferViews.push(l)-1)}})}processAccessor(e,t,n,r){const o=this.json,a={1:"SCALAR",2:"VEC2",3:"VEC3",4:"VEC4",9:"MAT3",16:"MAT4"};let l;if(e.array.constructor===Float32Array)l=yt.FLOAT;else if(e.array.constructor===Int32Array)l=yt.INT;else if(e.array.constructor===Uint32Array)l=yt.UNSIGNED_INT;else if(e.array.constructor===Int16Array)l=yt.SHORT;else if(e.array.constructor===Uint16Array)l=yt.UNSIGNED_SHORT;else if(e.array.constructor===Int8Array)l=yt.BYTE;else if(e.array.constructor===Uint8Array)l=yt.UNSIGNED_BYTE;else throw new Error("THREE.GLTFExporter: Unsupported bufferAttribute component type: "+e.array.constructor.name);if(n===void 0&&(n=0),(r===void 0||r===1/0)&&(r=e.count),r===0)return null;const u=X2(e,n,r);let h;t!==void 0&&(h=e===t.index?yt.ELEMENT_ARRAY_BUFFER:yt.ARRAY_BUFFER);const d=this.processBufferView(e,l,n,r,h),p={bufferView:d.id,byteOffset:d.byteOffset,componentType:l,count:r,max:u.max,min:u.min,type:a[e.itemSize]};return e.normalized===!0&&(p.normalized=!0),o.accessors||(o.accessors=[]),o.accessors.push(p)-1}processImage(e,t,n,r="image/png"){if(e!==null){const o=this,a=o.cache,l=o.json,u=o.options,h=o.pending;a.images.has(e)||a.images.set(e,{});const d=a.images.get(e),p=r+":flipY/"+n.toString();if(d[p]!==void 0)return d[p];l.images||(l.images=[]);const m={mimeType:r},g=V_();g.width=Math.min(e.width,u.maxTextureSize),g.height=Math.min(e.height,u.maxTextureSize);const y=g.getContext("2d");if(n===!0&&(y.translate(0,g.height),y.scale(1,-1)),e.data!==void 0){t!==Ei&&console.error("GLTFExporter: Only RGBAFormat is supported.",t),(e.width>u.maxTextureSize||e.height>u.maxTextureSize)&&console.warn("GLTFExporter: Image size is bigger than maxTextureSize",e);const _=new Uint8ClampedArray(e.height*e.width*4);for(let v=0;v<_.length;v+=4)_[v+0]=e.data[v+0],_[v+1]=e.data[v+1],_[v+2]=e.data[v+2],_[v+3]=e.data[v+3];y.putImageData(new ImageData(_,e.width,e.height),0,0)}else if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap||typeof OffscreenCanvas<"u"&&e instanceof OffscreenCanvas)y.drawImage(e,0,0,g.width,g.height);else throw new Error("THREE.GLTFExporter: Invalid image type. Use HTMLImageElement, HTMLCanvasElement, ImageBitmap or OffscreenCanvas.");u.binary===!0?h.push(W_(g,r).then(_=>o.processBufferViewImage(_)).then(_=>{m.bufferView=_})):g.toDataURL!==void 0?m.uri=g.toDataURL(r):h.push(W_(g,r).then(_=>new FileReader().readAsDataURL(_)).then(_=>{m.uri=_}));const S=l.images.push(m)-1;return d[p]=S,S}else throw new Error("THREE.GLTFExporter: No valid image data found. Unable to process texture.")}processSampler(e){const t=this.json;t.samplers||(t.samplers=[]);const n={magFilter:ai[e.magFilter],minFilter:ai[e.minFilter],wrapS:ai[e.wrapS],wrapT:ai[e.wrapT]};return t.samplers.push(n)-1}processTexture(e){const n=this.options,r=this.cache,o=this.json;if(r.textures.has(e))return r.textures.get(e);o.textures||(o.textures=[]),e instanceof zh&&(e=El(e,n.maxTextureSize));let a=e.userData.mimeType;a==="image/webp"&&(a="image/png");const l={sampler:this.processSampler(e),source:this.processImage(e.image,e.format,e.flipY,a)};e.name&&(l.name=e.name),this._invokeAll(function(h){h.writeTexture&&h.writeTexture(e,l)});const u=o.textures.push(l)-1;return r.textures.set(e,u),u}processMaterial(e){const t=this.cache,n=this.json;if(t.materials.has(e))return t.materials.get(e);if(e.isShaderMaterial)return console.warn("GLTFExporter: THREE.ShaderMaterial not supported."),null;n.materials||(n.materials=[]);const r={pbrMetallicRoughness:{}};e.isMeshStandardMaterial!==!0&&e.isMeshBasicMaterial!==!0&&console.warn("GLTFExporter: Use MeshStandardMaterial or MeshBasicMaterial for best results.");const o=e.color.toArray().concat([e.opacity]);if(Ia(o,[1,1,1,1])||(r.pbrMetallicRoughness.baseColorFactor=o),e.isMeshStandardMaterial?(r.pbrMetallicRoughness.metallicFactor=e.metalness,r.pbrMetallicRoughness.roughnessFactor=e.roughness):(r.pbrMetallicRoughness.metallicFactor=.5,r.pbrMetallicRoughness.roughnessFactor=.5),e.metalnessMap||e.roughnessMap){const l=this.buildMetalRoughTexture(e.metalnessMap,e.roughnessMap),u={index:this.processTexture(l),channel:l.channel};this.applyTextureTransform(u,l),r.pbrMetallicRoughness.metallicRoughnessTexture=u}if(e.map){const l={index:this.processTexture(e.map),texCoord:e.map.channel};this.applyTextureTransform(l,e.map),r.pbrMetallicRoughness.baseColorTexture=l}if(e.emissive){const l=e.emissive;if(Math.max(l.r,l.g,l.b)>0&&(r.emissiveFactor=e.emissive.toArray()),e.emissiveMap){const h={index:this.processTexture(e.emissiveMap),texCoord:e.emissiveMap.channel};this.applyTextureTransform(h,e.emissiveMap),r.emissiveTexture=h}}if(e.normalMap){const l={index:this.processTexture(e.normalMap),texCoord:e.normalMap.channel};e.normalScale&&e.normalScale.x!==1&&(l.scale=e.normalScale.x),this.applyTextureTransform(l,e.normalMap),r.normalTexture=l}if(e.aoMap){const l={index:this.processTexture(e.aoMap),texCoord:e.aoMap.channel};e.aoMapIntensity!==1&&(l.strength=e.aoMapIntensity),this.applyTextureTransform(l,e.aoMap),r.occlusionTexture=l}e.transparent?r.alphaMode="BLEND":e.alphaTest>0&&(r.alphaMode="MASK",r.alphaCutoff=e.alphaTest),e.side===si&&(r.doubleSided=!0),e.name!==""&&(r.name=e.name),this.serializeUserData(e,r),this._invokeAll(function(l){l.writeMaterial&&l.writeMaterial(e,r)});const a=n.materials.push(r)-1;return t.materials.set(e,a),a}processMesh(e){const t=this.cache,n=this.json,r=[e.geometry.uuid];if(Array.isArray(e.material))for(let A=0,B=e.material.length;A<B;A++)r.push(e.material[A].uuid);else r.push(e.material.uuid);const o=r.join(":");if(t.meshes.has(o))return t.meshes.get(o);const a=e.geometry;let l;e.isLineSegments?l=yt.LINES:e.isLineLoop?l=yt.LINE_LOOP:e.isLine?l=yt.LINE_STRIP:e.isPoints?l=yt.POINTS:l=e.material.wireframe?yt.LINES:yt.TRIANGLES;const u={},h={},d=[],p=[],m={uv:"TEXCOORD_0",uv1:"TEXCOORD_1",uv2:"TEXCOORD_2",uv3:"TEXCOORD_3",color:"COLOR_0",skinWeight:"WEIGHTS_0",skinIndex:"JOINTS_0"},g=a.getAttribute("normal");g!==void 0&&!this.isNormalizedNormalAttribute(g)&&(console.warn("THREE.GLTFExporter: Creating normalized normal attribute from the non-normalized one."),a.setAttribute("normal",this.createNormalizedNormalAttribute(g)));let y=null;for(let A in a.attributes){if(A.slice(0,5)==="morph")continue;const B=a.attributes[A];if(A=m[A]||A.toUpperCase(),/^(POSITION|NORMAL|TANGENT|TEXCOORD_\d+|COLOR_\d+|JOINTS_\d+|WEIGHTS_\d+)$/.test(A)||(A="_"+A),t.attributes.has(this.getUID(B))){h[A]=t.attributes.get(this.getUID(B));continue}y=null;const D=B.array;A==="JOINTS_0"&&!(D instanceof Uint16Array)&&!(D instanceof Uint8Array)&&(console.warn('GLTFExporter: Attribute "skinIndex" converted to type UNSIGNED_SHORT.'),y=new Nt(new Uint16Array(D),B.itemSize,B.normalized));const C=this.processAccessor(y||B,a);C!==null&&(A.startsWith("_")||this.detectMeshQuantization(A,B),h[A]=C,t.attributes.set(this.getUID(B),C))}if(g!==void 0&&a.setAttribute("normal",g),Object.keys(h).length===0)return null;if(e.morphTargetInfluences!==void 0&&e.morphTargetInfluences.length>0){const A=[],B=[],N={};if(e.morphTargetDictionary!==void 0)for(const D in e.morphTargetDictionary)N[e.morphTargetDictionary[D]]=D;for(let D=0;D<e.morphTargetInfluences.length;++D){const C={};let E=!1;for(const M in a.morphAttributes){if(M!=="position"&&M!=="normal"){E||(console.warn("GLTFExporter: Only POSITION and NORMAL morph are supported."),E=!0);continue}const O=a.morphAttributes[M][D],H=M.toUpperCase(),G=a.attributes[M];if(t.attributes.has(this.getUID(O,!0))){C[H]=t.attributes.get(this.getUID(O,!0));continue}const Y=O.clone();if(!a.morphTargetsRelative)for(let $=0,re=O.count;$<re;$++)for(let se=0;se<O.itemSize;se++)se===0&&Y.setX($,O.getX($)-G.getX($)),se===1&&Y.setY($,O.getY($)-G.getY($)),se===2&&Y.setZ($,O.getZ($)-G.getZ($)),se===3&&Y.setW($,O.getW($)-G.getW($));C[H]=this.processAccessor(Y,a),t.attributes.set(this.getUID(G,!0),C[H])}p.push(C),A.push(e.morphTargetInfluences[D]),e.morphTargetDictionary!==void 0&&B.push(N[D])}u.weights=A,B.length>0&&(u.extras={},u.extras.targetNames=B)}const S=Array.isArray(e.material);if(S&&a.groups.length===0)return null;let _=!1;if(S&&a.index===null){const A=[];for(let B=0,N=a.attributes.position.count;B<N;B++)A[B]=B;a.setIndex(A),_=!0}const v=S?e.material:[e.material],R=S?a.groups:[{materialIndex:0,start:void 0,count:void 0}];for(let A=0,B=R.length;A<B;A++){const N={mode:l,attributes:h};if(this.serializeUserData(a,N),p.length>0&&(N.targets=p),a.index!==null){let C=this.getUID(a.index);(R[A].start!==void 0||R[A].count!==void 0)&&(C+=":"+R[A].start+":"+R[A].count),t.attributes.has(C)?N.indices=t.attributes.get(C):(N.indices=this.processAccessor(a.index,a,R[A].start,R[A].count),t.attributes.set(C,N.indices)),N.indices===null&&delete N.indices}const D=this.processMaterial(v[R[A].materialIndex]);D!==null&&(N.material=D),d.push(N)}_===!0&&a.setIndex(null),u.primitives=d,n.meshes||(n.meshes=[]),this._invokeAll(function(A){A.writeMesh&&A.writeMesh(e,u)});const b=n.meshes.push(u)-1;return t.meshes.set(o,b),b}detectMeshQuantization(e,t){if(this.extensionsUsed[nf])return;let n;switch(t.array.constructor){case Int8Array:n="byte";break;case Uint8Array:n="unsigned byte";break;case Int16Array:n="short";break;case Uint16Array:n="unsigned short";break;default:return}t.normalized&&(n+=" normalized");const r=e.split("_",1)[0];z_[r]&&z_[r].includes(n)&&(this.extensionsUsed[nf]=!0,this.extensionsRequired[nf]=!0)}processCamera(e){const t=this.json;t.cameras||(t.cameras=[]);const n=e.isOrthographicCamera,r={type:n?"orthographic":"perspective"};return n?r.orthographic={xmag:e.right*2,ymag:e.top*2,zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near}:r.perspective={aspectRatio:e.aspect,yfov:ci.degToRad(e.fov),zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near},e.name!==""&&(r.name=e.type),t.cameras.push(r)-1}processAnimation(e,t){const n=this.json,r=this.nodeMap;n.animations||(n.animations=[]),e=id.Utils.mergeMorphTargetTracks(e.clone(),t);const o=e.tracks,a=[],l=[];for(let u=0;u<o.length;++u){const h=o[u],d=wt.parseTrackName(h.name);let p=wt.findNode(t,d.nodeName);const m=k_[d.propertyName];if(d.objectName==="bones"&&(p.isSkinnedMesh===!0?p=p.skeleton.getBoneByName(d.objectIndex):p=void 0),!p||!m)return console.warn('THREE.GLTFExporter: Could not export animation track "%s".',h.name),null;const g=1;let y=h.values.length/h.times.length;m===k_.morphTargetInfluences&&(y/=p.morphTargetInfluences.length);let S;h.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline===!0?(S="CUBICSPLINE",y/=3):h.getInterpolation()===Lo?S="STEP":S="LINEAR",l.push({input:this.processAccessor(new Nt(h.times,g)),output:this.processAccessor(new Nt(h.values,y)),interpolation:S}),a.push({sampler:l.length-1,target:{node:r.get(p),path:m}})}return n.animations.push({name:e.name||"clip_"+n.animations.length,samplers:l,channels:a}),n.animations.length-1}processSkin(e){const t=this.json,n=this.nodeMap,r=t.nodes[n.get(e)],o=e.skeleton;if(o===void 0)return null;const a=e.skeleton.bones[0];if(a===void 0)return null;const l=[],u=new Float32Array(o.bones.length*16),h=new Qe;for(let p=0;p<o.bones.length;++p)l.push(n.get(o.bones[p])),h.copy(o.boneInverses[p]),h.multiply(e.bindMatrix).toArray(u,p*16);return t.skins===void 0&&(t.skins=[]),t.skins.push({inverseBindMatrices:this.processAccessor(new Nt(u,16)),joints:l,skeleton:n.get(a)}),r.skin=t.skins.length-1}processNode(e){const t=this.json,n=this.options,r=this.nodeMap;t.nodes||(t.nodes=[]);const o={};if(n.trs){const l=e.quaternion.toArray(),u=e.position.toArray(),h=e.scale.toArray();Ia(l,[0,0,0,1])||(o.rotation=l),Ia(u,[0,0,0])||(o.translation=u),Ia(h,[1,1,1])||(o.scale=h)}else e.matrixAutoUpdate&&e.updateMatrix(),W2(e.matrix)===!1&&(o.matrix=e.matrix.elements);if(e.name!==""&&(o.name=String(e.name)),this.serializeUserData(e,o),e.isMesh||e.isLine||e.isPoints){const l=this.processMesh(e);l!==null&&(o.mesh=l)}else e.isCamera&&(o.camera=this.processCamera(e));if(e.isSkinnedMesh&&this.skins.push(e),e.children.length>0){const l=[];for(let u=0,h=e.children.length;u<h;u++){const d=e.children[u];if(d.visible||n.onlyVisible===!1){const p=this.processNode(d);p!==null&&l.push(p)}}l.length>0&&(o.children=l)}this._invokeAll(function(l){l.writeNode&&l.writeNode(e,o)});const a=t.nodes.push(o)-1;return r.set(e,a),a}processScene(e){const t=this.json,n=this.options;t.scenes||(t.scenes=[],t.scene=0);const r={};e.name!==""&&(r.name=e.name),t.scenes.push(r);const o=[];for(let a=0,l=e.children.length;a<l;a++){const u=e.children[a];if(u.visible||n.onlyVisible===!1){const h=this.processNode(u);h!==null&&o.push(h)}}o.length>0&&(r.nodes=o),this.serializeUserData(e,r)}processObjects(e){const t=new Pl;t.name="AuxScene";for(let n=0;n<e.length;n++)t.children.push(e[n]);this.processScene(t)}processInput(e){const t=this.options;e=e instanceof Array?e:[e],this._invokeAll(function(r){r.beforeParse&&r.beforeParse(e)});const n=[];for(let r=0;r<e.length;r++)e[r]instanceof Pl?this.processScene(e[r]):n.push(e[r]);n.length>0&&this.processObjects(n);for(let r=0;r<this.skins.length;++r)this.processSkin(this.skins[r]);for(let r=0;r<t.animations.length;++r)this.processAnimation(t.animations[r],e[0]);this._invokeAll(function(r){r.afterParse&&r.afterParse(e)})}_invokeAll(e){for(let t=0,n=this.plugins.length;t<n;t++)e(this.plugins[t])}}class j2{constructor(e){this.writer=e,this.name="KHR_lights_punctual"}writeNode(e,t){if(!e.isLight)return;if(!e.isDirectionalLight&&!e.isPointLight&&!e.isSpotLight){console.warn("THREE.GLTFExporter: Only directional, point, and spot lights are supported.",e);return}const n=this.writer,r=n.json,o=n.extensionsUsed,a={};e.name&&(a.name=e.name),a.color=e.color.toArray(),a.intensity=e.intensity,e.isDirectionalLight?a.type="directional":e.isPointLight?(a.type="point",e.distance>0&&(a.range=e.distance)):e.isSpotLight&&(a.type="spot",e.distance>0&&(a.range=e.distance),a.spot={},a.spot.innerConeAngle=(1-e.penumbra)*e.angle,a.spot.outerConeAngle=e.angle),e.decay!==void 0&&e.decay!==2&&console.warn("THREE.GLTFExporter: Light decay may be lost. glTF is physically-based, and expects light.decay=2."),e.target&&(e.target.parent!==e||e.target.position.x!==0||e.target.position.y!==0||e.target.position.z!==-1)&&console.warn("THREE.GLTFExporter: Light direction may be lost. For best results, make light.target a child of the light with position 0,0,-1."),o[this.name]||(r.extensions=r.extensions||{},r.extensions[this.name]={lights:[]},o[this.name]=!0);const l=r.extensions[this.name].lights;l.push(a),t.extensions=t.extensions||{},t.extensions[this.name]={light:l.length-1}}}class q2{constructor(e){this.writer=e,this.name="KHR_materials_unlit"}writeMaterial(e,t){if(!e.isMeshBasicMaterial)return;const r=this.writer.extensionsUsed;t.extensions=t.extensions||{},t.extensions[this.name]={},r[this.name]=!0,t.pbrMetallicRoughness.metallicFactor=0,t.pbrMetallicRoughness.roughnessFactor=.9}}class $2{constructor(e){this.writer=e,this.name="KHR_materials_clearcoat"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.clearcoat===0)return;const n=this.writer,r=n.extensionsUsed,o={};if(o.clearcoatFactor=e.clearcoat,e.clearcoatMap){const a={index:n.processTexture(e.clearcoatMap),texCoord:e.clearcoatMap.channel};n.applyTextureTransform(a,e.clearcoatMap),o.clearcoatTexture=a}if(o.clearcoatRoughnessFactor=e.clearcoatRoughness,e.clearcoatRoughnessMap){const a={index:n.processTexture(e.clearcoatRoughnessMap),texCoord:e.clearcoatRoughnessMap.channel};n.applyTextureTransform(a,e.clearcoatRoughnessMap),o.clearcoatRoughnessTexture=a}if(e.clearcoatNormalMap){const a={index:n.processTexture(e.clearcoatNormalMap),texCoord:e.clearcoatNormalMap.channel};n.applyTextureTransform(a,e.clearcoatNormalMap),o.clearcoatNormalTexture=a}t.extensions=t.extensions||{},t.extensions[this.name]=o,r[this.name]=!0}}class K2{constructor(e){this.writer=e,this.name="KHR_materials_iridescence"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.iridescence===0)return;const n=this.writer,r=n.extensionsUsed,o={};if(o.iridescenceFactor=e.iridescence,e.iridescenceMap){const a={index:n.processTexture(e.iridescenceMap),texCoord:e.iridescenceMap.channel};n.applyTextureTransform(a,e.iridescenceMap),o.iridescenceTexture=a}if(o.iridescenceIor=e.iridescenceIOR,o.iridescenceThicknessMinimum=e.iridescenceThicknessRange[0],o.iridescenceThicknessMaximum=e.iridescenceThicknessRange[1],e.iridescenceThicknessMap){const a={index:n.processTexture(e.iridescenceThicknessMap),texCoord:e.iridescenceThicknessMap.channel};n.applyTextureTransform(a,e.iridescenceThicknessMap),o.iridescenceThicknessTexture=a}t.extensions=t.extensions||{},t.extensions[this.name]=o,r[this.name]=!0}}class Z2{constructor(e){this.writer=e,this.name="KHR_materials_transmission"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.transmission===0)return;const n=this.writer,r=n.extensionsUsed,o={};if(o.transmissionFactor=e.transmission,e.transmissionMap){const a={index:n.processTexture(e.transmissionMap),texCoord:e.transmissionMap.channel};n.applyTextureTransform(a,e.transmissionMap),o.transmissionTexture=a}t.extensions=t.extensions||{},t.extensions[this.name]=o,r[this.name]=!0}}class J2{constructor(e){this.writer=e,this.name="KHR_materials_volume"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.transmission===0)return;const n=this.writer,r=n.extensionsUsed,o={};if(o.thicknessFactor=e.thickness,e.thicknessMap){const a={index:n.processTexture(e.thicknessMap),texCoord:e.thicknessMap.channel};n.applyTextureTransform(a,e.thicknessMap),o.thicknessTexture=a}o.attenuationDistance=e.attenuationDistance,o.attenuationColor=e.attenuationColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=o,r[this.name]=!0}}class Q2{constructor(e){this.writer=e,this.name="KHR_materials_ior"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.ior===1.5)return;const r=this.writer.extensionsUsed,o={};o.ior=e.ior,t.extensions=t.extensions||{},t.extensions[this.name]=o,r[this.name]=!0}}class eD{constructor(e){this.writer=e,this.name="KHR_materials_specular"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.specularIntensity===1&&e.specularColor.equals(B2)&&!e.specularIntensityMap&&!e.specularColorMap)return;const n=this.writer,r=n.extensionsUsed,o={};if(e.specularIntensityMap){const a={index:n.processTexture(e.specularIntensityMap),texCoord:e.specularIntensityMap.channel};n.applyTextureTransform(a,e.specularIntensityMap),o.specularTexture=a}if(e.specularColorMap){const a={index:n.processTexture(e.specularColorMap),texCoord:e.specularColorMap.channel};n.applyTextureTransform(a,e.specularColorMap),o.specularColorTexture=a}o.specularFactor=e.specularIntensity,o.specularColorFactor=e.specularColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=o,r[this.name]=!0}}class tD{constructor(e){this.writer=e,this.name="KHR_materials_sheen"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.sheen==0)return;const n=this.writer,r=n.extensionsUsed,o={};if(e.sheenRoughnessMap){const a={index:n.processTexture(e.sheenRoughnessMap),texCoord:e.sheenRoughnessMap.channel};n.applyTextureTransform(a,e.sheenRoughnessMap),o.sheenRoughnessTexture=a}if(e.sheenColorMap){const a={index:n.processTexture(e.sheenColorMap),texCoord:e.sheenColorMap.channel};n.applyTextureTransform(a,e.sheenColorMap),o.sheenColorTexture=a}o.sheenRoughnessFactor=e.sheenRoughness,o.sheenColorFactor=e.sheenColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=o,r[this.name]=!0}}class nD{constructor(e){this.writer=e,this.name="KHR_materials_anisotropy"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.anisotropy==0)return;const n=this.writer,r=n.extensionsUsed,o={};if(e.anisotropyMap){const a={index:n.processTexture(e.anisotropyMap)};n.applyTextureTransform(a,e.anisotropyMap),o.anisotropyTexture=a}o.anisotropyStrength=e.anisotropy,o.anisotropyRotation=e.anisotropyRotation,t.extensions=t.extensions||{},t.extensions[this.name]=o,r[this.name]=!0}}class iD{constructor(e){this.writer=e,this.name="KHR_materials_emissive_strength"}writeMaterial(e,t){if(!e.isMeshStandardMaterial||e.emissiveIntensity===1)return;const r=this.writer.extensionsUsed,o={};o.emissiveStrength=e.emissiveIntensity,t.extensions=t.extensions||{},t.extensions[this.name]=o,r[this.name]=!0}}class rD{constructor(e){this.writer=e,this.name="EXT_materials_bump"}writeMaterial(e,t){if(!e.isMeshStandardMaterial||e.bumpScale===1&&!e.bumpMap)return;const n=this.writer,r=n.extensionsUsed,o={};if(e.bumpMap){const a={index:n.processTexture(e.bumpMap),texCoord:e.bumpMap.channel};n.applyTextureTransform(a,e.bumpMap),o.bumpTexture=a}o.bumpFactor=e.bumpScale,t.extensions=t.extensions||{},t.extensions[this.name]=o,r[this.name]=!0}}class sD{constructor(e){this.writer=e,this.name="EXT_mesh_gpu_instancing"}writeNode(e,t){if(!e.isInstancedMesh)return;const n=this.writer,r=e,o=new Float32Array(r.count*3),a=new Float32Array(r.count*4),l=new Float32Array(r.count*3),u=new Qe,h=new F,d=new an,p=new F;for(let g=0;g<r.count;g++)r.getMatrixAt(g,u),u.decompose(h,d,p),h.toArray(o,g*3),d.toArray(a,g*4),p.toArray(l,g*3);const m={TRANSLATION:n.processAccessor(new Nt(o,3)),ROTATION:n.processAccessor(new Nt(a,4)),SCALE:n.processAccessor(new Nt(l,3))};r.instanceColor&&(m._COLOR_0=n.processAccessor(r.instanceColor)),t.extensions=t.extensions||{},t.extensions[this.name]={attributes:m},n.extensionsUsed[this.name]=!0,n.extensionsRequired[this.name]=!0}}id.Utils={insertKeyframe:function(i,e){const n=i.getValueSize(),r=new i.TimeBufferType(i.times.length+1),o=new i.ValueBufferType(i.values.length+n),a=i.createInterpolant(new i.ValueBufferType(n));let l;if(i.times.length===0){r[0]=e;for(let u=0;u<n;u++)o[u]=0;l=0}else if(e<i.times[0]){if(Math.abs(i.times[0]-e)<.001)return 0;r[0]=e,r.set(i.times,1),o.set(a.evaluate(e),0),o.set(i.values,n),l=0}else if(e>i.times[i.times.length-1]){if(Math.abs(i.times[i.times.length-1]-e)<.001)return i.times.length-1;r[r.length-1]=e,r.set(i.times,0),o.set(i.values,0),o.set(a.evaluate(e),i.values.length),l=r.length-1}else for(let u=0;u<i.times.length;u++){if(Math.abs(i.times[u]-e)<.001)return u;if(i.times[u]<e&&i.times[u+1]>e){r.set(i.times.slice(0,u+1),0),r[u+1]=e,r.set(i.times.slice(u+1),u+2),o.set(i.values.slice(0,(u+1)*n),0),o.set(a.evaluate(e),(u+1)*n),o.set(i.values.slice((u+1)*n),(u+2)*n),l=u+1;break}}return i.times=r,i.values=o,l},mergeMorphTargetTracks:function(i,e){const t=[],n={},r=i.tracks;for(let o=0;o<r.length;++o){let a=r[o];const l=wt.parseTrackName(a.name),u=wt.findNode(e,l.nodeName);if(l.propertyName!=="morphTargetInfluences"||l.propertyIndex===void 0){t.push(a);continue}if(a.createInterpolant!==a.InterpolantFactoryMethodDiscrete&&a.createInterpolant!==a.InterpolantFactoryMethodLinear){if(a.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline)throw new Error("THREE.GLTFExporter: Cannot merge tracks with glTF CUBICSPLINE interpolation.");console.warn("THREE.GLTFExporter: Morph target interpolation mode not yet supported. Using LINEAR instead."),a=a.clone(),a.setInterpolation(As)}const h=u.morphTargetInfluences.length,d=u.morphTargetDictionary[l.propertyIndex];if(d===void 0)throw new Error("THREE.GLTFExporter: Morph target name not found: "+l.propertyIndex);let p;if(n[u.uuid]===void 0){p=a.clone();const g=new p.ValueBufferType(h*p.times.length);for(let y=0;y<p.times.length;y++)g[y*h+d]=p.values[y];p.name=(l.nodeName||"")+".morphTargetInfluences",p.values=g,n[u.uuid]=p,t.push(p);continue}const m=a.createInterpolant(new a.ValueBufferType(1));p=n[u.uuid];for(let g=0;g<p.times.length;g++)p.values[g*h+d]=m.evaluate(p.times[g]);for(let g=0;g<a.times.length;g++){const y=this.insertKeyframe(p,a.times[g]);p.values[y*h+d]=a.values[g]}}return i.tracks=t,i}};class oD{async parse(e,t={}){t=Object.assign({ar:{anchoring:{type:"plane"},planeAnchoring:{alignment:"horizontal"}},quickLookCompatible:!1,maxTextureSize:1024},t);const n={},r="model.usda";n[r]=null;let o=iv();o+=cD(t);const a={},l={};e.traverseVisible(h=>{if(h.isMesh){const d=h.geometry,p=h.material;if(p.isMeshStandardMaterial){const m="geometries/Geometry_"+d.id+".usda";if(!(m in n)){const g=fD(d);n[m]=uD(g)}p.uuid in a||(a[p.uuid]=p),o+=hD(h,d,p)}else console.warn("THREE.USDZExporter: Unsupported material type (USDZ only supports MeshStandardMaterial)",h)}else h.isCamera&&(o+=MD(h))}),o+=lD(),o+=vD(a,l,t.quickLookCompatible),n[r]=Dl(o),o=null;for(const h in l){let d=l[h];d.isCompressedTexture===!0&&(d=El(d));const p=aD(d.image,d.flipY,t.maxTextureSize),m=await new Promise(g=>p.toBlob(g,"image/png",1));n[`textures/Texture_${h}.png`]=new Uint8Array(await m.arrayBuffer())}let u=0;for(const h in n){const d=n[h],p=34+h.length;u+=p;const m=u&63;if(m!==4){const g=64-m,y=new Uint8Array(g);n[h]=[d,{extra:{12345:y}}]}u=d.length}return YI(n,{level:0})}}function aD(i,e,t){if(typeof HTMLImageElement<"u"&&i instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&i instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&i instanceof OffscreenCanvas||typeof ImageBitmap<"u"&&i instanceof ImageBitmap){const n=t/Math.max(i.width,i.height),r=document.createElement("canvas");r.width=i.width*Math.min(1,n),r.height=i.height*Math.min(1,n);const o=r.getContext("2d");return e===!0&&(o.translate(0,r.height),o.scale(1,-1)),o.drawImage(i,0,0,r.width,r.height),r}else throw new Error("THREE.USDZExporter: No valid image data found. Unable to process texture.")}const Dn=7;function iv(){return`#usda 1.0
3850
3850
  (
3851
3851
  customLayerData = {
3852
3852
  string creator = "Three.js USDZExporter"
@@ -3899,18 +3899,18 @@ ${dD(i)}
3899
3899
  {
3900
3900
  int[] faceVertexCounts = [${pD(i)}]
3901
3901
  int[] faceVertexIndices = [${mD(i)}]
3902
- normal3f[] normals = [${If(t.normal,n)}] (
3902
+ normal3f[] normals = [${Df(t.normal,n)}] (
3903
3903
  interpolation = "vertex"
3904
3904
  )
3905
- point3f[] points = [${If(t.position,n)}]
3905
+ point3f[] points = [${Df(t.position,n)}]
3906
3906
  ${_D(t)}
3907
3907
  uniform token subdivisionScheme = "none"
3908
3908
  }
3909
- `}function pD(i){const e=i.index!==null?i.index.count:i.attributes.position.count;return Array(e/3).fill(3).join(", ")}function mD(i){const e=i.index,t=[];if(e!==null)for(let n=0;n<e.count;n++)t.push(e.getX(n));else{const n=i.attributes.position.count;for(let r=0;r<n;r++)t.push(r)}return t.join(", ")}function If(i,e){if(i===void 0)return console.warn("USDZExporter: Normals missing."),Array(e).fill("(0, 0, 0)").join(", ");const t=[];for(let n=0;n<i.count;n++){const r=i.getX(n),o=i.getY(n),a=i.getZ(n);t.push(`(${r.toPrecision(Dn)}, ${o.toPrecision(Dn)}, ${a.toPrecision(Dn)})`)}return t.join(", ")}function gD(i){const e=[];for(let t=0;t<i.count;t++){const n=i.getX(t),r=i.getY(t);e.push(`(${n.toPrecision(Dn)}, ${1-r.toPrecision(Dn)})`)}return e.join(", ")}function _D(i){let e="";for(let n=0;n<4;n++){const r=n>0?n:"",o=i["uv"+r];o!==void 0&&(e+=`
3909
+ `}function pD(i){const e=i.index!==null?i.index.count:i.attributes.position.count;return Array(e/3).fill(3).join(", ")}function mD(i){const e=i.index,t=[];if(e!==null)for(let n=0;n<e.count;n++)t.push(e.getX(n));else{const n=i.attributes.position.count;for(let r=0;r<n;r++)t.push(r)}return t.join(", ")}function Df(i,e){if(i===void 0)return console.warn("USDZExporter: Normals missing."),Array(e).fill("(0, 0, 0)").join(", ");const t=[];for(let n=0;n<i.count;n++){const r=i.getX(n),o=i.getY(n),a=i.getZ(n);t.push(`(${r.toPrecision(Dn)}, ${o.toPrecision(Dn)}, ${a.toPrecision(Dn)})`)}return t.join(", ")}function gD(i){const e=[];for(let t=0;t<i.count;t++){const n=i.getX(t),r=i.getY(t);e.push(`(${n.toPrecision(Dn)}, ${1-r.toPrecision(Dn)})`)}return e.join(", ")}function _D(i){let e="";for(let n=0;n<4;n++){const r=n>0?n:"",o=i["uv"+r];o!==void 0&&(e+=`
3910
3910
  texCoord2f[] primvars:st${r} = [${gD(o)}] (
3911
3911
  interpolation = "vertex"
3912
3912
  )`)}const t=i.color;if(t!==void 0){const n=t.count;e+=`
3913
- color3f[] primvars:displayColor = [${If(t,n)}] (
3913
+ color3f[] primvars:displayColor = [${Df(t,n)}] (
3914
3914
  interpolation = "vertex"
3915
3915
  )`}return e}function vD(i,e,t=!1){const n=[];for(const r in i){const o=i[r];n.push(xD(o,e,t))}return`def "Materials"
3916
3916
  {
@@ -3931,8 +3931,8 @@ ${n.join("")}
3931
3931
  uniform token info:id = "UsdTransform2d"
3932
3932
  token inputs:in.connect = </Materials/Material_${i.id}/PrimvarReader_${u}.outputs:result>
3933
3933
  float inputs:rotation = ${(S*(180/Math.PI)).toFixed(Dn)}
3934
- float2 inputs:scale = ${X_(g)}
3935
- float2 inputs:translation = ${X_(y)}
3934
+ float2 inputs:scale = ${Y_(g)}
3935
+ float2 inputs:translation = ${Y_(y)}
3936
3936
  float2 outputs:result
3937
3937
  }
3938
3938
 
@@ -3950,7 +3950,7 @@ ${n.join("")}
3950
3950
  float outputs:b
3951
3951
  float3 outputs:rgb
3952
3952
  ${i.transparent||i.alphaTest>0?"float outputs:a":""}
3953
- }`}return i.side===si&&console.warn("THREE.USDZExporter: USDZ does not support double sided materials",i),i.map!==null?(r.push(`${n}color3f inputs:diffuseColor.connect = </Materials/Material_${i.id}/Texture_${i.map.id}_diffuse.outputs:rgb>`),i.transparent?r.push(`${n}float inputs:opacity.connect = </Materials/Material_${i.id}/Texture_${i.map.id}_diffuse.outputs:a>`):i.alphaTest>0&&(r.push(`${n}float inputs:opacity.connect = </Materials/Material_${i.id}/Texture_${i.map.id}_diffuse.outputs:a>`),r.push(`${n}float inputs:opacityThreshold = ${i.alphaTest}`)),o.push(a(i.map,"diffuse",i.color))):r.push(`${n}color3f inputs:diffuseColor = ${W_(i.color)}`),i.emissiveMap!==null?(r.push(`${n}color3f inputs:emissiveColor.connect = </Materials/Material_${i.id}/Texture_${i.emissiveMap.id}_emissive.outputs:rgb>`),o.push(a(i.emissiveMap,"emissive"))):i.emissive.getHex()>0&&r.push(`${n}color3f inputs:emissiveColor = ${W_(i.emissive)}`),i.normalMap!==null&&(r.push(`${n}normal3f inputs:normal.connect = </Materials/Material_${i.id}/Texture_${i.normalMap.id}_normal.outputs:rgb>`),o.push(a(i.normalMap,"normal"))),i.aoMap!==null&&(r.push(`${n}float inputs:occlusion.connect = </Materials/Material_${i.id}/Texture_${i.aoMap.id}_occlusion.outputs:r>`),o.push(a(i.aoMap,"occlusion"))),i.roughnessMap!==null&&i.roughness===1?(r.push(`${n}float inputs:roughness.connect = </Materials/Material_${i.id}/Texture_${i.roughnessMap.id}_roughness.outputs:g>`),o.push(a(i.roughnessMap,"roughness"))):r.push(`${n}float inputs:roughness = ${i.roughness}`),i.metalnessMap!==null&&i.metalness===1?(r.push(`${n}float inputs:metallic.connect = </Materials/Material_${i.id}/Texture_${i.metalnessMap.id}_metallic.outputs:b>`),o.push(a(i.metalnessMap,"metallic"))):r.push(`${n}float inputs:metallic = ${i.metalness}`),i.alphaMap!==null?(r.push(`${n}float inputs:opacity.connect = </Materials/Material_${i.id}/Texture_${i.alphaMap.id}_opacity.outputs:r>`),r.push(`${n}float inputs:opacityThreshold = 0.0001`),o.push(a(i.alphaMap,"opacity"))):r.push(`${n}float inputs:opacity = ${i.opacity}`),i.isMeshPhysicalMaterial&&(r.push(`${n}float inputs:clearcoat = ${i.clearcoat}`),r.push(`${n}float inputs:clearcoatRoughness = ${i.clearcoatRoughness}`),r.push(`${n}float inputs:ior = ${i.ior}`)),`
3953
+ }`}return i.side===si&&console.warn("THREE.USDZExporter: USDZ does not support double sided materials",i),i.map!==null?(r.push(`${n}color3f inputs:diffuseColor.connect = </Materials/Material_${i.id}/Texture_${i.map.id}_diffuse.outputs:rgb>`),i.transparent?r.push(`${n}float inputs:opacity.connect = </Materials/Material_${i.id}/Texture_${i.map.id}_diffuse.outputs:a>`):i.alphaTest>0&&(r.push(`${n}float inputs:opacity.connect = </Materials/Material_${i.id}/Texture_${i.map.id}_diffuse.outputs:a>`),r.push(`${n}float inputs:opacityThreshold = ${i.alphaTest}`)),o.push(a(i.map,"diffuse",i.color))):r.push(`${n}color3f inputs:diffuseColor = ${X_(i.color)}`),i.emissiveMap!==null?(r.push(`${n}color3f inputs:emissiveColor.connect = </Materials/Material_${i.id}/Texture_${i.emissiveMap.id}_emissive.outputs:rgb>`),o.push(a(i.emissiveMap,"emissive"))):i.emissive.getHex()>0&&r.push(`${n}color3f inputs:emissiveColor = ${X_(i.emissive)}`),i.normalMap!==null&&(r.push(`${n}normal3f inputs:normal.connect = </Materials/Material_${i.id}/Texture_${i.normalMap.id}_normal.outputs:rgb>`),o.push(a(i.normalMap,"normal"))),i.aoMap!==null&&(r.push(`${n}float inputs:occlusion.connect = </Materials/Material_${i.id}/Texture_${i.aoMap.id}_occlusion.outputs:r>`),o.push(a(i.aoMap,"occlusion"))),i.roughnessMap!==null&&i.roughness===1?(r.push(`${n}float inputs:roughness.connect = </Materials/Material_${i.id}/Texture_${i.roughnessMap.id}_roughness.outputs:g>`),o.push(a(i.roughnessMap,"roughness"))):r.push(`${n}float inputs:roughness = ${i.roughness}`),i.metalnessMap!==null&&i.metalness===1?(r.push(`${n}float inputs:metallic.connect = </Materials/Material_${i.id}/Texture_${i.metalnessMap.id}_metallic.outputs:b>`),o.push(a(i.metalnessMap,"metallic"))):r.push(`${n}float inputs:metallic = ${i.metalness}`),i.alphaMap!==null?(r.push(`${n}float inputs:opacity.connect = </Materials/Material_${i.id}/Texture_${i.alphaMap.id}_opacity.outputs:r>`),r.push(`${n}float inputs:opacityThreshold = 0.0001`),o.push(a(i.alphaMap,"opacity"))):r.push(`${n}float inputs:opacity = ${i.opacity}`),i.isMeshPhysicalMaterial&&(r.push(`${n}float inputs:clearcoat = ${i.clearcoat}`),r.push(`${n}float inputs:clearcoatRoughness = ${i.clearcoatRoughness}`),r.push(`${n}float inputs:ior = ${i.ior}`)),`
3954
3954
  def Material "Material_${i.id}"
3955
3955
  {
3956
3956
  def Shader "PreviewSurface"
@@ -3968,7 +3968,7 @@ ${o.join(`
3968
3968
  `)}
3969
3969
 
3970
3970
  }
3971
- `}function W_(i){return`(${i.r}, ${i.g}, ${i.b})`}function yD(i){return`(${i.r}, ${i.g}, ${i.b}, 1.0)`}function X_(i){return`(${i.x}, ${i.y})`}function MD(i){const e=i.name?i.name:"Camera_"+i.id,t=rv(i.matrixWorld);return i.matrixWorld.determinant()<0&&console.warn("THREE.USDZExporter: USDZ does not support negative scales",i),i.isOrthographicCamera?`def Camera "${e}"
3971
+ `}function X_(i){return`(${i.r}, ${i.g}, ${i.b})`}function yD(i){return`(${i.r}, ${i.g}, ${i.b}, 1.0)`}function Y_(i){return`(${i.x}, ${i.y})`}function MD(i){const e=i.name?i.name:"Camera_"+i.id,t=rv(i.matrixWorld);return i.matrixWorld.determinant()<0&&console.warn("THREE.USDZExporter: USDZ does not support negative scales",i),i.isOrthographicCamera?`def Camera "${e}"
3972
3972
  {
3973
3973
  matrix4d xformOp:transform = ${t}
3974
3974
  uniform token[] xformOpOrder = ["xformOp:transform"]
@@ -3992,7 +3992,7 @@ ${o.join(`
3992
3992
  float verticalAperture = ${i.getFilmHeight().toPrecision(Dn)}
3993
3993
  }
3994
3994
 
3995
- `}class SD{_gltfExporter;_usdzExporter;constructor(){this._gltfExporter=new id,this._usdzExporter=new oD}async export(e,t,n){switch(t){case"glb":return this._exportGlb(e,n);case"gltf":return this._exportGltf(e,n);case"usdz":return this._exportUsdz(e,n);default:throw new Error(`Unsupported file type: ${t}`)}}async _exportGlb(e,t){const n=await this._gltfExporter.parseAsync(e,{...t,binary:!0});if(n instanceof ArrayBuffer)return n;throw new Error("Failed to export GLB: expected ArrayBuffer")}async _exportGltf(e,t){const n=await this._gltfExporter.parseAsync(e,{...t,binary:!1}),r=JSON.stringify(n);return new TextEncoder().encode(r).buffer}async _exportUsdz(e,t){return(await this._usdzExporter.parse(e,t)).buffer}}class Ol extends Error{constructor(e,t){super(e),this.cause=t,this.name="ConversionError"}}class Y_ extends Ol{constructor(e){super(`Unsupported file type: ${e}. Supported types are: ${td.join(", ")}`),this.name="FileTypeError"}}class nf extends Ol{constructor(e,t){super(`Failed to fetch file from ${e}`,t),this.name="NetworkError"}}class rd{constructor(e){this._uri=e,this._loader=new Z0,this._exporter=new SD}_loader;_exporter;static convert(e){return new rd(e)}async to(e,t){try{if(this._getFileTypeFromUri()===e)return await this._loadFile();const r=await this._loader.load(this._uri);return await this._exporter.export(r,e,t)}catch(n){throw n instanceof Ol?n:new Ol("Failed to convert file",n)}}_getFileTypeFromUri(){const e=this._uri.split(".").pop()?.toLowerCase();if(!e)throw new Y_("no extension");if(!td.includes(e))throw new Y_(e);return e}async _loadFile(){try{const e=await fetch(this._uri);if(!e.ok)throw new nf(this._uri,`HTTP error! status: ${e.status}`);return e.arrayBuffer()}catch(e){throw e instanceof nf?e:new nf(this._uri,e)}}}class ED{async launch(e,t){const n=await this.convertToUSDZ(e,t);return this.launchARQuickLook(n,t)}async convertToUSDZ(e,t){const n=await rd.convert(e).to("usdz",{quickLookCompatible:!0,ar:{anchoring:{type:"plane"},planeAnchoring:{alignment:t?.arPlacement==="vertical"?"vertical":"horizontal"}}}),r=new Blob([n],{type:"model/vnd.usdz+zip"});return URL.createObjectURL(r)}launchARQuickLook(e,t){return new Promise(n=>{t?.arScale==="fixed"&&(e=e.concat("#allowsContentScaling=0"));const r=document.createElement("a");r.innerHTML="<picture></picture>",r.rel="ar",r.href=e,r.download="scene.usdz",n(),r.click()})}}class TD{launch(e,t){const n=self.location.toString(),r=document.createElement("a"),o=this._createParams(n,e,t),a=this._createIntent(n,e,o);r.setAttribute("href",a),r.click()}_createParams(e,t,n){const r=new URL(t,e),o=new URLSearchParams(r.search);return o.set("mode","ar_preferred"),this._applyScaleOption(o,n),this._applyPlacementOption(o,n),this._applySoundOption(o,e),this._applyLinkOption(o,e),o}_applyScaleOption(e,t){t?.arScale==="fixed"&&e.set("resizable","false")}_applyPlacementOption(e,t){t?.arPlacement==="vertical"&&e.set("enable_vertical_placement","true")}_applySoundOption(e,t){if(e.has("sound")){const n=new URL(e.get("sound"),t);e.set("sound",n.toString())}}_applyLinkOption(e,t){if(e.has("link")){const n=new URL(e.get("link"),t);e.set("link",n.toString())}}_createIntent(e,t,n){const r=new URL(e),o=new URL(t,e),a="#model-viewer-no-ar-fallback";return r.hash=a,`intent://arvr.google.com/scene-viewer/1.2?${n.toString()+"&file="+o.toString()}#Intent;scheme=https;package=com.google.android.googlequicksearchbox;action=android.intent.action.VIEW;S.browser_fallback_url=${encodeURIComponent(r.toString())};end;`}}class bD{async launch(e,t){const n=Lf.GetSystem();return n===Mi.IOS?this.tryARQuickLook(e,t):n===Mi.ANDROID?this.trySceneViewer(e,t):(console.log("DIVE: AR not supported. Not a mobile system. (System is "+n+")"),Promise.reject(new Error("AR not supported on non-mobile systems")))}async tryARQuickLook(e,t){if(!Lf.GetSupportsARQuickLook())return console.log("ARQuickLook not supported"),Promise.reject(new Error("ARQuickLook not supported"));console.log("DIVE: Launching AR with ARQuickLook ...");try{return new ED().launch(e,t)}catch(r){return console.error("Error launching ARQuickLook:",r),Promise.reject(r)}}async trySceneViewer(e,t){console.log("DIVE: Launching AR with SceneViewer ...");try{return new TD().launch(e,t)}catch(n){return console.error("Error launching SceneViewer:",n),Promise.reject(n)}}}const sv={autoResize:!0,autoStart:!0,displayAxes:!1,renderer:Ss,perspectiveCamera:Ca,orbitControls:Sl};class Wl{static QuickView(e,t){const n=new Wl(t);n.Communication.PerformAction("SET_CAMERA_TRANSFORM",{position:{x:0,y:2,z:2},target:{x:0,y:.5,z:0}});const r=ci.generateUUID();n.Communication.PerformAction("ADD_OBJECT",{entityType:"light",type:"scene",name:"light",id:r,enabled:!0,visible:!0,intensity:1,color:16777215});const o=ci.generateUUID();return n.Communication.Subscribe("MODEL_LOADED",a=>{if(a.id!==o)return;const l=n.Communication.PerformAction("COMPUTE_ENCOMPASSING_VIEW",{});n.Communication.PerformAction("SET_CAMERA_TRANSFORM",{position:l.position,target:l.target})}),n.Communication.PerformAction("ADD_OBJECT",{entityType:"model",name:"object",id:o,position:{x:0,y:0,z:0},rotation:{x:0,y:0,z:0},scale:{x:1,y:1,z:1},uri:e,visible:!0,loaded:!1}),n.Communication.PerformAction("UPDATE_SCENE",{backgroundColor:16777215,gridEnabled:!1,floorColor:16777215}),n}_settings;_resizeObserverId;_width;_height;renderer;scene;perspectiveCamera;orbitControls;toolbox;communication;animationSystem;axisCamera;get Communication(){return this.communication}get Canvas(){return this.renderer.domElement}get Info(){return Lf}set Settings(e){const t=Pf(this._settings,e);t.renderer&&(this.renderer=new d_(this._settings.renderer)),t.perspectiveCamera&&(t.perspectiveCamera.fov!==void 0&&(this.perspectiveCamera.fov=t.perspectiveCamera.fov),t.perspectiveCamera.near!==void 0&&(this.perspectiveCamera.near=t.perspectiveCamera.near),t.perspectiveCamera.far!==void 0&&(this.perspectiveCamera.far=t.perspectiveCamera.far),this.perspectiveCamera.OnResize(this.renderer.domElement.width,this.renderer.domElement.height)),t.orbitControls&&(t.orbitControls.enableDamping!==void 0&&(this.orbitControls.enableDamping=t.orbitControls.enableDamping),t.orbitControls.dampingFactor!==void 0&&(this.orbitControls.dampingFactor=t.orbitControls.dampingFactor)),t.autoResize!==this._settings.autoResize&&(t.autoResize?this.addResizeObserver():this.removeResizeObserver()),t.displayAxes?this.axisCamera=new F_(this.renderer,this.scene,this.orbitControls):(this.axisCamera?.Dispose(),this.axisCamera=null),Object.assign(this._settings,e)}constructor(e){this._settings={...sv,...e!==void 0?e:{}},this._resizeObserverId="",this._width=0,this._height=0,this.renderer=new d_(this._settings.renderer),this.scene=new s2,this.perspectiveCamera=new Fa(this._settings.perspectiveCamera),this.animationSystem=new f2(this.renderer),this.orbitControls=new Ul(this.perspectiveCamera,this.renderer,this.animationSystem,this._settings.orbitControls),this.toolbox=new h2(this.scene,this.orbitControls),this.communication=new On(this.renderer,this.scene,this.orbitControls,this.toolbox),this._settings.displayAxes?this.axisCamera=new F_(this.renderer,this.scene,this.orbitControls):this.axisCamera=null,this._settings.autoResize&&this.addResizeObserver(),window.DIVE={PrintScene:()=>{console.log(this.scene)}},console.log(`DIVE ${C2.version} initialized successfully!`),console.log(`
3995
+ `}class SD{_gltfExporter;_usdzExporter;constructor(){this._gltfExporter=new id,this._usdzExporter=new oD}async export(e,t,n){switch(t){case"glb":return this._exportGlb(e,n);case"gltf":return this._exportGltf(e,n);case"usdz":return this._exportUsdz(e,n);default:throw new Error(`Unsupported file type: ${t}`)}}async _exportGlb(e,t){const n=await this._gltfExporter.parseAsync(e,{...t,binary:!0});if(n instanceof ArrayBuffer)return n;throw new Error("Failed to export GLB: expected ArrayBuffer")}async _exportGltf(e,t){const n=await this._gltfExporter.parseAsync(e,{...t,binary:!1}),r=JSON.stringify(n);return new TextEncoder().encode(r).buffer}async _exportUsdz(e,t){return(await this._usdzExporter.parse(e,t)).buffer}}class rd{constructor(e){this._uri=e,this._loader=new Z0,this._exporter=new SD}_loader;_exporter;static convert(e){return new rd(e)}_getFileTypeFromUri(){const e=this._uri.split(".").pop()?.toLowerCase();if(!e)throw new Nl("No file extension found in URI");if(!Ul.includes(e))throw new Nl(`Unsupported file type: ${e}. Supported types: ${Ul.join(", ")}`);return e}async _loadFile(){const e=await fetch(this._uri);if(!e.ok)throw new Jh(this._uri,`Failed to fetch file from ${this._uri}`);try{return await e.arrayBuffer()}catch(t){throw t instanceof Jh?t:new Jh(this._uri,`Failed to fetch file from ${this._uri}`,t)}}async to(e,t){if(this._getFileTypeFromUri()===e)return await this._loadFile();try{const r=await this._loader.load(this._uri);return await this._exporter.export(r,e,t)}catch(r){throw r instanceof D_?r:new D_("Failed to convert file",r)}}}class ED{async launch(e,t){const n=await this.convertToUSDZ(e,t);return this.launchARQuickLook(n,t)}async convertToUSDZ(e,t){const n=await rd.convert(e).to("usdz",{quickLookCompatible:!0,ar:{anchoring:{type:"plane"},planeAnchoring:{alignment:t?.arPlacement==="vertical"?"vertical":"horizontal"}}}),r=new Blob([n],{type:"model/vnd.usdz+zip"});return URL.createObjectURL(r)}launchARQuickLook(e,t){return new Promise(n=>{t?.arScale==="fixed"&&(e=e.concat("#allowsContentScaling=0"));const r=document.createElement("a");r.innerHTML="<picture></picture>",r.rel="ar",r.href=e,r.download="scene.usdz",n(),r.click()})}}class TD{launch(e,t){const n=self.location.toString(),r=document.createElement("a"),o=this._createParams(n,e,t),a=this._createIntent(n,e,o);r.setAttribute("href",a),r.click()}_createParams(e,t,n){const r=new URL(t,e),o=new URLSearchParams(r.search);return o.set("mode","ar_preferred"),this._applyScaleOption(o,n),this._applyPlacementOption(o,n),this._applySoundOption(o,e),this._applyLinkOption(o,e),o}_applyScaleOption(e,t){t?.arScale==="fixed"&&e.set("resizable","false")}_applyPlacementOption(e,t){t?.arPlacement==="vertical"&&e.set("enable_vertical_placement","true")}_applySoundOption(e,t){if(e.has("sound")){const n=new URL(e.get("sound"),t);e.set("sound",n.toString())}}_applyLinkOption(e,t){if(e.has("link")){const n=new URL(e.get("link"),t);e.set("link",n.toString())}}_createIntent(e,t,n){const r=new URL(e),o=new URL(t,e),a="#model-viewer-no-ar-fallback";return r.hash=a,`intent://arvr.google.com/scene-viewer/1.2?${n.toString()+"&file="+o.toString()}#Intent;scheme=https;package=com.google.android.googlequicksearchbox;action=android.intent.action.VIEW;S.browser_fallback_url=${encodeURIComponent(r.toString())};end;`}}class bD{async launch(e,t){const n=If.GetSystem();return n===Mi.IOS?this.tryARQuickLook(e,t):n===Mi.ANDROID?this.trySceneViewer(e,t):(console.log("DIVE: AR not supported. Not a mobile system. (System is "+n+")"),Promise.reject(new Error("AR not supported on non-mobile systems")))}async tryARQuickLook(e,t){if(!If.GetSupportsARQuickLook())return console.log("ARQuickLook not supported"),Promise.reject(new Error("ARQuickLook not supported"));console.log("DIVE: Launching AR with ARQuickLook ...");try{return new ED().launch(e,t)}catch(r){return console.error("Error launching ARQuickLook:",r),Promise.reject(r)}}async trySceneViewer(e,t){console.log("DIVE: Launching AR with SceneViewer ...");try{return new TD().launch(e,t)}catch(n){return console.error("Error launching SceneViewer:",n),Promise.reject(n)}}}const sv={autoResize:!0,autoStart:!0,displayAxes:!1,renderer:Ss,perspectiveCamera:Ca,orbitControls:Sl};class Xl{static QuickView(e,t){const n=new Xl(t);n.Communication.PerformAction("SET_CAMERA_TRANSFORM",{position:{x:0,y:2,z:2},target:{x:0,y:.5,z:0}});const r=ci.generateUUID();n.Communication.PerformAction("ADD_OBJECT",{entityType:"light",type:"scene",name:"light",id:r,enabled:!0,visible:!0,intensity:1,color:16777215});const o=ci.generateUUID();return n.Communication.Subscribe("MODEL_LOADED",a=>{if(a.id!==o)return;const l=n.Communication.PerformAction("COMPUTE_ENCOMPASSING_VIEW",{});n.Communication.PerformAction("SET_CAMERA_TRANSFORM",{position:l.position,target:l.target})}),n.Communication.PerformAction("ADD_OBJECT",{entityType:"model",name:"object",id:o,position:{x:0,y:0,z:0},rotation:{x:0,y:0,z:0},scale:{x:1,y:1,z:1},uri:e,visible:!0,loaded:!1}),n.Communication.PerformAction("UPDATE_SCENE",{backgroundColor:16777215,gridEnabled:!1,floorColor:16777215}),n}_settings;_resizeObserverId;_width;_height;renderer;scene;perspectiveCamera;orbitControls;toolbox;communication;animationSystem;axisCamera;get Communication(){return this.communication}get Canvas(){return this.renderer.domElement}get Info(){return If}set Settings(e){const t=Lf(this._settings,e);t.renderer&&(this.renderer=new d_(this._settings.renderer)),t.perspectiveCamera&&(t.perspectiveCamera.fov!==void 0&&(this.perspectiveCamera.fov=t.perspectiveCamera.fov),t.perspectiveCamera.near!==void 0&&(this.perspectiveCamera.near=t.perspectiveCamera.near),t.perspectiveCamera.far!==void 0&&(this.perspectiveCamera.far=t.perspectiveCamera.far),this.perspectiveCamera.OnResize(this.renderer.domElement.width,this.renderer.domElement.height)),t.orbitControls&&(t.orbitControls.enableDamping!==void 0&&(this.orbitControls.enableDamping=t.orbitControls.enableDamping),t.orbitControls.dampingFactor!==void 0&&(this.orbitControls.dampingFactor=t.orbitControls.dampingFactor)),t.autoResize!==this._settings.autoResize&&(t.autoResize?this.addResizeObserver():this.removeResizeObserver()),t.displayAxes?this.axisCamera=new B_(this.renderer,this.scene,this.orbitControls):(this.axisCamera?.Dispose(),this.axisCamera=null),Object.assign(this._settings,e)}constructor(e){this._settings={...sv,...e!==void 0?e:{}},this._resizeObserverId="",this._width=0,this._height=0,this.renderer=new d_(this._settings.renderer),this.scene=new s2,this.perspectiveCamera=new Fa(this._settings.perspectiveCamera),this.animationSystem=new f2(this.renderer),this.orbitControls=new Ol(this.perspectiveCamera,this.renderer,this.animationSystem,this._settings.orbitControls),this.toolbox=new h2(this.scene,this.orbitControls),this.communication=new On(this.renderer,this.scene,this.orbitControls,this.toolbox),this._settings.displayAxes?this.axisCamera=new B_(this.renderer,this.scene,this.orbitControls):this.axisCamera=null,this._settings.autoResize&&this.addResizeObserver(),window.DIVE={PrintScene:()=>{console.log(this.scene)}},console.log(`DIVE ${C2.version} initialized successfully!`),console.log(`
3996
3996
  @@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@
3997
3997
  @@@@+-:::::::---------------------==------------------------------=#@@@@
3998
3998
  @@%=::::.......::---------------------------------------------------------+@@
@@ -4021,5 +4021,5 @@ ${o.join(`
4021
4021
  @@@@+:::::::#@@ @@*-------*@@@@
4022
4022
  @@@@@@@ @@@@@@
4023
4023
 
4024
- `),this._settings.autoStart&&this.renderer.StartRenderer(this.scene,this.perspectiveCamera)}Dispose(){this.removeResizeObserver(),this.renderer.Dispose(),this.orbitControls.Dispose(),this.axisCamera?.Dispose(),this.animationSystem.Dispose(),this.toolbox.Dispose(),this.communication.DestroyInstance()}OnResize(e,t){this.renderer.OnResize(e,t),this.perspectiveCamera.OnResize(e,t)}addResizeObserver(){this._resizeObserverId=this.renderer.AddPreRenderCallback(()=>{const e=this.renderer.domElement.parentElement;if(!e)return;const{clientWidth:t,clientHeight:n}=e;t===this._width&&n===this._height||(this.OnResize(t,n),this._width=t,this._height=n)})}removeResizeObserver(){this.renderer.RemovePreRenderCallback(this._resizeObserverId)}}exports.ARSystem=bD;exports.DIVE=Wl;exports.DIVECommunication=On;exports.DIVEDefaultSettings=sv;exports.DIVEMath=F2;exports.default=Wl;
4024
+ `),this._settings.autoStart&&this.renderer.StartRenderer(this.scene,this.perspectiveCamera)}Dispose(){this.removeResizeObserver(),this.renderer.Dispose(),this.orbitControls.Dispose(),this.axisCamera?.Dispose(),this.animationSystem.Dispose(),this.toolbox.Dispose(),this.communication.DestroyInstance()}OnResize(e,t){this.renderer.OnResize(e,t),this.perspectiveCamera.OnResize(e,t)}addResizeObserver(){this._resizeObserverId=this.renderer.AddPreRenderCallback(()=>{const e=this.renderer.domElement.parentElement;if(!e)return;const{clientWidth:t,clientHeight:n}=e;t===this._width&&n===this._height||(this.OnResize(t,n),this._width=t,this._height=n)})}removeResizeObserver(){this.renderer.RemovePreRenderCallback(this._resizeObserverId)}}exports.ARSystem=bD;exports.DIVE=Xl;exports.DIVECommunication=On;exports.DIVEDefaultSettings=sv;exports.DIVEMath=F2;exports.default=Xl;
4025
4025
  //# sourceMappingURL=dive.cjs.map