import{r as K,a as Hv,g as Hr,R as Um,c as q2,j as Ne,l as Z2,S as K2,b as Vx,T as $2}from"./index-BNlNRfcu.js";/** * @license * Copyright 2010-2023 Three.js Authors * SPDX-License-Identifier: MIT */const Yd="154",ab={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},J2={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},lb=0,L0=1,cb=2,Q2=3,ub=0,qd=1,gu=2,Or=3,ls=0,yi=1,vn=2,eC=2,Fs=0,pa=1,I0=2,D0=3,U0=4,hb=5,aa=100,fb=101,db=102,O0=103,N0=104,pb=200,mb=201,gb=202,vb=203,Vv=204,Wv=205,yb=206,_b=207,xb=208,wb=209,Sb=210,Eb=0,bb=1,Mb=2,Ld=3,Tb=4,Ab=5,Cb=6,Rb=7,ih=0,Pb=1,Lb=2,zr=0,Ib=1,Db=2,Ub=3,Xv=4,Ob=5,Zd=300,xo=301,wo=302,Cu=303,Ru=304,Jl=306,Pu=1e3,vi=1001,Lu=1002,Dn=1003,Id=1004,tC=1004,vu=1005,nC=1005,fn=1006,jv=1007,iC=1007,So=1008,rC=1008,os=1009,Nb=1010,Fb=1011,Kd=1012,Yv=1013,Ns=1014,rs=1015,Vl=1016,qv=1017,Zv=1018,mo=1020,kb=1021,Bi=1023,zb=1024,Bb=1025,go=1026,xa=1027,Gb=1028,Kv=1029,Hb=1030,$v=1031,Jv=1033,vd=33776,yd=33777,_d=33778,xd=33779,F0=35840,k0=35841,z0=35842,B0=35843,Vb=36196,G0=37492,H0=37496,V0=37808,W0=37809,X0=37810,j0=37811,Y0=37812,q0=37813,Z0=37814,K0=37815,$0=37816,J0=37817,Q0=37818,ev=37819,tv=37820,nv=37821,wd=36492,Wb=36283,iv=36284,rv=36285,sv=36286,Xb=2200,jb=2201,Yb=2202,Iu=2300,Du=2301,Sd=2302,ua=2400,ha=2401,Uu=2402,$d=2500,Qv=2501,sC=0,oC=1,aC=2,ey=3e3,vo=3001,qb=3200,ty=3201,Mo=0,Zb=1,yo="",Mt="srgb",Br="srgb-linear",ny="display-p3",lC=0,Ed=7680,cC=7681,uC=7682,hC=7683,fC=34055,dC=34056,pC=5386,mC=512,gC=513,vC=514,yC=515,_C=516,xC=517,wC=518,Kb=519,$b=512,Jb=513,Qb=514,eM=515,tM=516,nM=517,iM=518,rM=519,Ou=35044,SC=35048,EC=35040,bC=35045,MC=35049,TC=35041,AC=35046,CC=35050,RC=35042,PC="100",ov="300 es",Dd=1035,ss=2e3,Nu=2001;let Hs=class{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 i=this._listeners[e];if(i!==void 0){const s=i.indexOf(t);s!==-1&&i.splice(s,1)}}dispatchEvent(e){if(this._listeners===void 0)return;const n=this._listeners[e.type];if(n!==void 0){e.target=this;const i=n.slice(0);for(let s=0,o=i.length;s>8&255]+mi[r>>16&255]+mi[r>>24&255]+"-"+mi[e&255]+mi[e>>8&255]+"-"+mi[e>>16&15|64]+mi[e>>24&255]+"-"+mi[t&63|128]+mi[t>>8&255]+"-"+mi[t>>16&255]+mi[t>>24&255]+mi[n&255]+mi[n>>8&255]+mi[n>>16&255]+mi[n>>24&255]).toLowerCase()}function Tn(r,e,t){return Math.max(e,Math.min(t,r))}function iy(r,e){return(r%e+e)%e}function LC(r,e,t,n,i){return n+(r-e)*(i-n)/(t-e)}function IC(r,e,t){return r!==e?(t-r)/(e-r):0}function yu(r,e,t){return(1-t)*r+t*e}function DC(r,e,t,n){return yu(r,e,1-Math.exp(-t*n))}function UC(r,e=1){return e-Math.abs(iy(r,e*2)-e)}function OC(r,e,t){return r<=e?0:r>=t?1:(r=(r-e)/(t-e),r*r*(3-2*r))}function NC(r,e,t){return r<=e?0:r>=t?1:(r=(r-e)/(t-e),r*r*r*(r*(r*6-15)+10))}function FC(r,e){return r+Math.floor(Math.random()*(e-r+1))}function kC(r,e){return r+Math.random()*(e-r)}function zC(r){return r*(.5-Math.random())}function BC(r){r!==void 0&&(Wx=r);let e=Wx+=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 GC(r){return r*ma}function HC(r){return r*Wl}function av(r){return(r&r-1)===0&&r!==0}function sM(r){return Math.pow(2,Math.ceil(Math.log(r)/Math.LN2))}function Ud(r){return Math.pow(2,Math.floor(Math.log(r)/Math.LN2))}function VC(r,e,t,n,i){const s=Math.cos,o=Math.sin,a=s(t/2),l=o(t/2),c=s((e+n)/2),u=o((e+n)/2),h=s((e-n)/2),p=o((e-n)/2),m=s((n-e)/2),v=o((n-e)/2);switch(i){case"XYX":r.set(a*u,l*h,l*p,a*c);break;case"YZY":r.set(l*p,a*u,l*h,a*c);break;case"ZXZ":r.set(l*h,l*p,a*u,a*c);break;case"XZX":r.set(a*u,l*v,l*m,a*c);break;case"YXY":r.set(l*m,a*u,l*v,a*c);break;case"ZYZ":r.set(l*v,l*m,a*u,a*c);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function Qi(r,e){switch(e.constructor){case Float32Array:return r;case Uint32Array:return r/4294967295;case Uint16Array:return r/65535;case Uint8Array:return r/255;case Int32Array:return Math.max(r/2147483647,-1);case Int16Array:return Math.max(r/32767,-1);case Int8Array:return Math.max(r/127,-1);default:throw new Error("Invalid component type.")}}function Lt(r,e){switch(e.constructor){case Float32Array:return r;case Uint32Array:return Math.round(r*4294967295);case Uint16Array:return Math.round(r*65535);case Uint8Array:return Math.round(r*255);case Int32Array:return Math.round(r*2147483647);case Int16Array:return Math.round(r*32767);case Int8Array:return Math.round(r*127);default:throw new Error("Invalid component type.")}}const Od={DEG2RAD:ma,RAD2DEG:Wl,generateUUID:er,clamp:Tn,euclideanModulo:iy,mapLinear:LC,inverseLerp:IC,lerp:yu,damp:DC,pingpong:UC,smoothstep:OC,smootherstep:NC,randInt:FC,randFloat:kC,randFloatSpread:zC,seededRandom:BC,degToRad:GC,radToDeg:HC,isPowerOfTwo:av,ceilPowerOfTwo:sM,floorPowerOfTwo:Ud,setQuaternionFromProperEuler:VC,normalize:Lt,denormalize:Qi};class De{constructor(e=0,t=0){De.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,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6],this.y=i[1]*t+i[4]*n+i[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=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}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(Tn(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),i=Math.sin(t),s=this.x-e.x,o=this.y-e.y;return this.x=s*n-o*i+e.x,this.y=s*i+o*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Ct{constructor(e,t,n,i,s,o,a,l,c){Ct.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,i,s,o,a,l,c)}set(e,t,n,i,s,o,a,l,c){const u=this.elements;return u[0]=e,u[1]=i,u[2]=a,u[3]=t,u[4]=s,u[5]=l,u[6]=n,u[7]=o,u[8]=c,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,i=t.elements,s=this.elements,o=n[0],a=n[3],l=n[6],c=n[1],u=n[4],h=n[7],p=n[2],m=n[5],v=n[8],_=i[0],y=i[3],g=i[6],x=i[1],w=i[4],E=i[7],b=i[2],M=i[5],A=i[8];return s[0]=o*_+a*x+l*b,s[3]=o*y+a*w+l*M,s[6]=o*g+a*E+l*A,s[1]=c*_+u*x+h*b,s[4]=c*y+u*w+h*M,s[7]=c*g+u*E+h*A,s[2]=p*_+m*x+v*b,s[5]=p*y+m*w+v*M,s[8]=p*g+m*E+v*A,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],i=e[2],s=e[3],o=e[4],a=e[5],l=e[6],c=e[7],u=e[8];return t*o*u-t*a*c-n*s*u+n*a*l+i*s*c-i*o*l}invert(){const e=this.elements,t=e[0],n=e[1],i=e[2],s=e[3],o=e[4],a=e[5],l=e[6],c=e[7],u=e[8],h=u*o-a*c,p=a*l-u*s,m=c*s-o*l,v=t*h+n*p+i*m;if(v===0)return this.set(0,0,0,0,0,0,0,0,0);const _=1/v;return e[0]=h*_,e[1]=(i*c-u*n)*_,e[2]=(a*n-i*o)*_,e[3]=p*_,e[4]=(u*t-i*l)*_,e[5]=(i*s-a*t)*_,e[6]=m*_,e[7]=(n*l-c*t)*_,e[8]=(o*t-n*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,i,s,o,a){const l=Math.cos(s),c=Math.sin(s);return this.set(n*l,n*c,-n*(l*o+c*a)+o+e,-i*c,i*l,-i*(-c*o+l*a)+a+t,0,0,1),this}scale(e,t){return this.premultiply(Om.makeScale(e,t)),this}rotate(e){return this.premultiply(Om.makeRotation(-e)),this}translate(e,t){return this.premultiply(Om.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 i=0;i<9;i++)if(t[i]!==n[i])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 Om=new Ct;function oM(r){for(let e=r.length-1;e>=0;--e)if(r[e]>=65535)return!0;return!1}const WC={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function Dl(r,e){return new WC[r](e)}function Fu(r){return document.createElementNS("http://www.w3.org/1999/xhtml",r)}const Xx={};function _u(r){r in Xx||(Xx[r]=!0,console.warn(r))}function zl(r){return r<.04045?r*.0773993808:Math.pow(r*.9478672986+.0521327014,2.4)}function Nm(r){return r<.0031308?r*12.92:1.055*Math.pow(r,.41666)-.055}const XC=new Ct().fromArray([.8224621,.0331941,.0170827,.177538,.9668058,.0723974,-1e-7,1e-7,.9105199]),jC=new Ct().fromArray([1.2249401,-.0420569,-.0196376,-.2249404,1.0420571,-.0786361,1e-7,0,1.0982735]);function YC(r){return r.convertSRGBToLinear().applyMatrix3(jC)}function qC(r){return r.applyMatrix3(XC).convertLinearToSRGB()}const ZC={[Br]:r=>r,[Mt]:r=>r.convertSRGBToLinear(),[ny]:YC},KC={[Br]:r=>r,[Mt]:r=>r.convertLinearToSRGB(),[ny]:qC},vr={enabled:!0,get legacyMode(){return console.warn("THREE.ColorManagement: .legacyMode=false renamed to .enabled=true in r150."),!this.enabled},set legacyMode(r){console.warn("THREE.ColorManagement: .legacyMode=false renamed to .enabled=true in r150."),this.enabled=!r},get workingColorSpace(){return Br},set workingColorSpace(r){console.warn("THREE.ColorManagement: .workingColorSpace is readonly.")},convert:function(r,e,t){if(this.enabled===!1||e===t||!e||!t)return r;const n=ZC[e],i=KC[t];if(n===void 0||i===void 0)throw new Error(`Unsupported color space conversion, "${e}" to "${t}".`);return i(n(r))},fromWorkingColorSpace:function(r,e){return this.convert(r,this.workingColorSpace,e)},toWorkingColorSpace:function(r,e){return this.convert(r,e,this.workingColorSpace)}};let Ka;class ry{static getDataURL(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{Ka===void 0&&(Ka=Fu("canvas")),Ka.width=e.width,Ka.height=e.height;const n=Ka.getContext("2d");e instanceof ImageData?n.putImageData(e,0,0):n.drawImage(e,0,0,e.width,e.height),t=Ka}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=Fu("canvas");t.width=e.width,t.height=e.height;const n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);const i=n.getImageData(0,0,e.width,e.height),s=i.data;for(let o=0;o0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==Zd)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Pu:e.x=e.x-Math.floor(e.x);break;case vi:e.x=e.x<0?0:1;break;case Lu: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 Pu:e.y=e.y-Math.floor(e.y);break;case vi:e.y=e.y<0?0:1;break;case Lu: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)}get encoding(){return _u("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace===Mt?vo:ey}set encoding(e){_u("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=e===vo?Mt:yo}}Sn.DEFAULT_IMAGE=null;Sn.DEFAULT_MAPPING=Zd;Sn.DEFAULT_ANISOTROPY=1;class Xt{constructor(e=0,t=0,n=0,i=1){Xt.prototype.isVector4=!0,this.x=e,this.y=t,this.z=n,this.w=i}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,i){return this.x=e,this.y=t,this.z=n,this.w=i,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,i=this.z,s=this.w,o=e.elements;return this.x=o[0]*t+o[4]*n+o[8]*i+o[12]*s,this.y=o[1]*t+o[5]*n+o[9]*i+o[13]*s,this.z=o[2]*t+o[6]*n+o[10]*i+o[14]*s,this.w=o[3]*t+o[7]*n+o[11]*i+o[15]*s,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,i,s;const l=e.elements,c=l[0],u=l[4],h=l[8],p=l[1],m=l[5],v=l[9],_=l[2],y=l[6],g=l[10];if(Math.abs(u-p)<.01&&Math.abs(h-_)<.01&&Math.abs(v-y)<.01){if(Math.abs(u+p)<.1&&Math.abs(h+_)<.1&&Math.abs(v+y)<.1&&Math.abs(c+m+g-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const w=(c+1)/2,E=(m+1)/2,b=(g+1)/2,M=(u+p)/4,A=(h+_)/4,P=(v+y)/4;return w>E&&w>b?w<.01?(n=0,i=.707106781,s=.707106781):(n=Math.sqrt(w),i=M/n,s=A/n):E>b?E<.01?(n=.707106781,i=0,s=.707106781):(i=Math.sqrt(E),n=M/i,s=P/i):b<.01?(n=.707106781,i=.707106781,s=0):(s=Math.sqrt(b),n=A/s,i=P/s),this.set(n,i,s,t),this}let x=Math.sqrt((y-v)*(y-v)+(h-_)*(h-_)+(p-u)*(p-u));return Math.abs(x)<.001&&(x=1),this.x=(y-v)/x,this.y=(h-_)/x,this.z=(p-u)/x,this.w=Math.acos((c+m+g-1)/2),this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this.w=Math.max(e.w,Math.min(t.w,this.w)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this.w=Math.max(e,Math.min(t,this.w)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this.w=this.w<0?Math.ceil(this.w):Math.floor(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){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 Gr extends Hs{constructor(e=1,t=1,n={}){super(),this.isWebGLRenderTarget=!0,this.width=e,this.height=t,this.depth=1,this.scissor=new Xt(0,0,e,t),this.scissorTest=!1,this.viewport=new Xt(0,0,e,t);const i={width:e,height:t,depth:1};n.encoding!==void 0&&(_u("THREE.WebGLRenderTarget: option.encoding has been replaced by option.colorSpace."),n.colorSpace=n.encoding===vo?Mt:yo),this.texture=new Sn(i,n.mapping,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.flipY=!1,this.texture.generateMipmaps=n.generateMipmaps!==void 0?n.generateMipmaps:!1,this.texture.internalFormat=n.internalFormat!==void 0?n.internalFormat:null,this.texture.minFilter=n.minFilter!==void 0?n.minFilter:fn,this.depthBuffer=n.depthBuffer!==void 0?n.depthBuffer:!0,this.stencilBuffer=n.stencilBuffer!==void 0?n.stencilBuffer:!1,this.depthTexture=n.depthTexture!==void 0?n.depthTexture:null,this.samples=n.samples!==void 0?n.samples:0}setSize(e,t,n=1){(this.width!==e||this.height!==t||this.depth!==n)&&(this.width=e,this.height=t,this.depth=n,this.texture.image.width=e,this.texture.image.height=t,this.texture.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.texture=e.texture.clone(),this.texture.isRenderTargetTexture=!0;const t=Object.assign({},e.texture.image);return this.texture.source=new fa(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 Jd extends Sn{constructor(e=null,t=1,n=1,i=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=Dn,this.minFilter=Dn,this.wrapR=vi,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class QC extends Gr{constructor(e=1,t=1,n=1){super(e,t),this.isWebGLArrayRenderTarget=!0,this.depth=n,this.texture=new Jd(null,e,t,n),this.texture.isRenderTargetTexture=!0}}class sy extends Sn{constructor(e=null,t=1,n=1,i=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=Dn,this.minFilter=Dn,this.wrapR=vi,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class eR extends Gr{constructor(e=1,t=1,n=1){super(e,t),this.isWebGL3DRenderTarget=!0,this.depth=n,this.texture=new sy(null,e,t,n),this.texture.isRenderTargetTexture=!0}}class tR extends Gr{constructor(e=1,t=1,n=1,i={}){super(e,t,i),this.isWebGLMultipleRenderTargets=!0;const s=this.texture;this.texture=[];for(let o=0;o=0?1:-1,w=1-g*g;if(w>Number.EPSILON){const b=Math.sqrt(w),M=Math.atan2(b,g*x);y=Math.sin(y*M)/b,a=Math.sin(a*M)/b}const E=a*x;if(l=l*y+p*E,c=c*y+m*E,u=u*y+v*E,h=h*y+_*E,y===1-a){const b=1/Math.sqrt(l*l+c*c+u*u+h*h);l*=b,c*=b,u*=b,h*=b}}e[t]=l,e[t+1]=c,e[t+2]=u,e[t+3]=h}static multiplyQuaternionsFlat(e,t,n,i,s,o){const a=n[i],l=n[i+1],c=n[i+2],u=n[i+3],h=s[o],p=s[o+1],m=s[o+2],v=s[o+3];return e[t]=a*v+u*h+l*m-c*p,e[t+1]=l*v+u*p+c*h-a*m,e[t+2]=c*v+u*m+a*p-l*h,e[t+3]=u*v-a*h-l*p-c*m,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,i){return this._x=e,this._y=t,this._z=n,this._w=i,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){const n=e._x,i=e._y,s=e._z,o=e._order,a=Math.cos,l=Math.sin,c=a(n/2),u=a(i/2),h=a(s/2),p=l(n/2),m=l(i/2),v=l(s/2);switch(o){case"XYZ":this._x=p*u*h+c*m*v,this._y=c*m*h-p*u*v,this._z=c*u*v+p*m*h,this._w=c*u*h-p*m*v;break;case"YXZ":this._x=p*u*h+c*m*v,this._y=c*m*h-p*u*v,this._z=c*u*v-p*m*h,this._w=c*u*h+p*m*v;break;case"ZXY":this._x=p*u*h-c*m*v,this._y=c*m*h+p*u*v,this._z=c*u*v+p*m*h,this._w=c*u*h-p*m*v;break;case"ZYX":this._x=p*u*h-c*m*v,this._y=c*m*h+p*u*v,this._z=c*u*v-p*m*h,this._w=c*u*h+p*m*v;break;case"YZX":this._x=p*u*h+c*m*v,this._y=c*m*h+p*u*v,this._z=c*u*v-p*m*h,this._w=c*u*h-p*m*v;break;case"XZY":this._x=p*u*h-c*m*v,this._y=c*m*h-p*u*v,this._z=c*u*v+p*m*h,this._w=c*u*h+p*m*v;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+o)}return t!==!1&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const n=t/2,i=Math.sin(n);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,n=t[0],i=t[4],s=t[8],o=t[1],a=t[5],l=t[9],c=t[2],u=t[6],h=t[10],p=n+a+h;if(p>0){const m=.5/Math.sqrt(p+1);this._w=.25/m,this._x=(u-l)*m,this._y=(s-c)*m,this._z=(o-i)*m}else if(n>a&&n>h){const m=2*Math.sqrt(1+n-a-h);this._w=(u-l)/m,this._x=.25*m,this._y=(i+o)/m,this._z=(s+c)/m}else if(a>h){const m=2*Math.sqrt(1+a-n-h);this._w=(s-c)/m,this._x=(i+o)/m,this._y=.25*m,this._z=(l+u)/m}else{const m=2*Math.sqrt(1+h-n-a);this._w=(o-i)/m,this._x=(s+c)/m,this._y=(l+u)/m,this._z=.25*m}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return nMath.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(Tn(this.dot(e),-1,1)))}rotateTowards(e,t){const n=this.angleTo(e);if(n===0)return this;const i=Math.min(1,t/n);return this.slerp(e,i),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,i=e._y,s=e._z,o=e._w,a=t._x,l=t._y,c=t._z,u=t._w;return this._x=n*u+o*a+i*c-s*l,this._y=i*u+o*l+s*a-n*c,this._z=s*u+o*c+n*l-i*a,this._w=o*u-n*a-i*l-s*c,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);const n=this._x,i=this._y,s=this._z,o=this._w;let a=o*e._w+n*e._x+i*e._y+s*e._z;if(a<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,a=-a):this.copy(e),a>=1)return this._w=o,this._x=n,this._y=i,this._z=s,this;const l=1-a*a;if(l<=Number.EPSILON){const m=1-t;return this._w=m*o+t*this._w,this._x=m*n+t*this._x,this._y=m*i+t*this._y,this._z=m*s+t*this._z,this.normalize(),this._onChangeCallback(),this}const c=Math.sqrt(l),u=Math.atan2(c,a),h=Math.sin((1-t)*u)/c,p=Math.sin(t*u)/c;return this._w=o*h+this._w*p,this._x=n*h+this._x*p,this._y=i*h+this._y*p,this._z=s*h+this._z*p,this._onChangeCallback(),this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){const e=Math.random(),t=Math.sqrt(1-e),n=Math.sqrt(e),i=2*Math.PI*Math.random(),s=2*Math.PI*Math.random();return this.set(t*Math.cos(i),n*Math.sin(s),n*Math.cos(s),t*Math.sin(i))}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}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 Y{constructor(e=0,t=0,n=0){Y.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(jx.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(jx.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,n=this.y,i=this.z,s=e.elements;return this.x=s[0]*t+s[3]*n+s[6]*i,this.y=s[1]*t+s[4]*n+s[7]*i,this.z=s[2]*t+s[5]*n+s[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,n=this.y,i=this.z,s=e.elements,o=1/(s[3]*t+s[7]*n+s[11]*i+s[15]);return this.x=(s[0]*t+s[4]*n+s[8]*i+s[12])*o,this.y=(s[1]*t+s[5]*n+s[9]*i+s[13])*o,this.z=(s[2]*t+s[6]*n+s[10]*i+s[14])*o,this}applyQuaternion(e){const t=this.x,n=this.y,i=this.z,s=e.x,o=e.y,a=e.z,l=e.w,c=l*t+o*i-a*n,u=l*n+a*t-s*i,h=l*i+s*n-o*t,p=-s*t-o*n-a*i;return this.x=c*l+p*-s+u*-a-h*-o,this.y=u*l+p*-o+h*-s-c*-a,this.z=h*l+p*-a+c*-o-u*-s,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,i=this.z,s=e.elements;return this.x=s[0]*t+s[4]*n+s[8]*i,this.y=s[1]*t+s[5]*n+s[9]*i,this.z=s[2]*t+s[6]*n+s[10]*i,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=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const n=e.x,i=e.y,s=e.z,o=t.x,a=t.y,l=t.z;return this.x=i*l-s*a,this.y=s*o-n*l,this.z=n*a-i*o,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 km.copy(this).projectOnVector(e),this.sub(km)}reflect(e){return this.sub(km.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(Tn(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y,i=this.z-e.z;return t*t+n*n+i*i}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 i=Math.sin(t)*e;return this.x=i*Math.sin(n),this.y=Math.cos(t)*e,this.z=i*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(),i=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=i,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()-.5)*2,t=Math.random()*Math.PI*2,n=Math.sqrt(1-e**2);return this.x=n*Math.cos(t),this.y=n*Math.sin(t),this.z=e,this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const km=new Y,jx=new si;class ir{constructor(e=new Y(1/0,1/0,1/0),t=new Y(-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;tthis.max.x||e.ythis.max.y||e.zthis.max.z)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return!(e.max.xthis.max.x||e.max.ythis.max.y||e.max.zthis.max.z)}intersectsSphere(e){return this.clampPoint(e.center,Es),Es.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(Rc),hf.subVectors(this.max,Rc),Ja.subVectors(e.a,Rc),Qa.subVectors(e.b,Rc),el.subVectors(e.c,Rc),io.subVectors(Qa,Ja),ro.subVectors(el,Qa),Xo.subVectors(Ja,el);let t=[0,-io.z,io.y,0,-ro.z,ro.y,0,-Xo.z,Xo.y,io.z,0,-io.x,ro.z,0,-ro.x,Xo.z,0,-Xo.x,-io.y,io.x,0,-ro.y,ro.x,0,-Xo.y,Xo.x,0];return!zm(t,Ja,Qa,el,hf)||(t=[1,0,0,0,1,0,0,0,1],!zm(t,Ja,Qa,el,hf))?!1:(ff.crossVectors(io,ro),t=[ff.x,ff.y,ff.z],zm(t,Ja,Qa,el,hf))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Es).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Es).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:(Ss[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Ss[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Ss[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Ss[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Ss[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Ss[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Ss[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Ss[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Ss),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 Ss=[new Y,new Y,new Y,new Y,new Y,new Y,new Y,new Y],Es=new Y,$a=new ir,Ja=new Y,Qa=new Y,el=new Y,io=new Y,ro=new Y,Xo=new Y,Rc=new Y,hf=new Y,ff=new Y,jo=new Y;function zm(r,e,t,n,i){for(let s=0,o=r.length-3;s<=o;s+=3){jo.fromArray(r,s);const a=i.x*Math.abs(jo.x)+i.y*Math.abs(jo.y)+i.z*Math.abs(jo.z),l=e.dot(jo),c=t.dot(jo),u=n.dot(jo);if(Math.max(-Math.max(l,c,u),Math.min(l,c,u))>a)return!1}return!0}const nR=new ir,Pc=new Y,Bm=new Y;let rr=class{constructor(e=new Y,t=-1){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):nR.setFromPoints(e).getCenter(n);let i=0;for(let s=0,o=e.length;sthis.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;Pc.subVectors(e,this.center);const t=Pc.lengthSq();if(t>this.radius*this.radius){const n=Math.sqrt(t),i=(n-this.radius)*.5;this.center.addScaledVector(Pc,i/n),this.radius+=i}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):(Bm.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Pc.copy(e.center).add(Bm)),this.expandByPoint(Pc.copy(e.center).sub(Bm))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}};const bs=new Y,Gm=new Y,df=new Y,so=new Y,Hm=new Y,pf=new Y,Vm=new Y;class Ql{constructor(e=new Y,t=new Y(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,bs)),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=bs.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(bs.copy(this.origin).addScaledVector(this.direction,t),bs.distanceToSquared(e))}distanceSqToSegment(e,t,n,i){Gm.copy(e).add(t).multiplyScalar(.5),df.copy(t).sub(e).normalize(),so.copy(this.origin).sub(Gm);const s=e.distanceTo(t)*.5,o=-this.direction.dot(df),a=so.dot(this.direction),l=-so.dot(df),c=so.lengthSq(),u=Math.abs(1-o*o);let h,p,m,v;if(u>0)if(h=o*l-a,p=o*a-l,v=s*u,h>=0)if(p>=-v)if(p<=v){const _=1/u;h*=_,p*=_,m=h*(h+o*p+2*a)+p*(o*h+p+2*l)+c}else p=s,h=Math.max(0,-(o*p+a)),m=-h*h+p*(p+2*l)+c;else p=-s,h=Math.max(0,-(o*p+a)),m=-h*h+p*(p+2*l)+c;else p<=-v?(h=Math.max(0,-(-o*s+a)),p=h>0?-s:Math.min(Math.max(-s,-l),s),m=-h*h+p*(p+2*l)+c):p<=v?(h=0,p=Math.min(Math.max(-s,-l),s),m=p*(p+2*l)+c):(h=Math.max(0,-(o*s+a)),p=h>0?s:Math.min(Math.max(-s,-l),s),m=-h*h+p*(p+2*l)+c);else p=o>0?-s:s,h=Math.max(0,-(o*p+a)),m=-h*h+p*(p+2*l)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,h),i&&i.copy(Gm).addScaledVector(df,p),m}intersectSphere(e,t){bs.subVectors(e.center,this.origin);const n=bs.dot(this.direction),i=bs.dot(bs)-n*n,s=e.radius*e.radius;if(i>s)return null;const o=Math.sqrt(s-i),a=n-o,l=n+o;return l<0?null:a<0?this.at(l,t):this.at(a,t)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(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,i,s,o,a,l;const c=1/this.direction.x,u=1/this.direction.y,h=1/this.direction.z,p=this.origin;return c>=0?(n=(e.min.x-p.x)*c,i=(e.max.x-p.x)*c):(n=(e.max.x-p.x)*c,i=(e.min.x-p.x)*c),u>=0?(s=(e.min.y-p.y)*u,o=(e.max.y-p.y)*u):(s=(e.max.y-p.y)*u,o=(e.min.y-p.y)*u),n>o||s>i||((s>n||isNaN(n))&&(n=s),(o=0?(a=(e.min.z-p.z)*h,l=(e.max.z-p.z)*h):(a=(e.max.z-p.z)*h,l=(e.min.z-p.z)*h),n>l||a>i)||((a>n||n!==n)&&(n=a),(l=0?n:i,t)}intersectsBox(e){return this.intersectBox(e,bs)!==null}intersectTriangle(e,t,n,i,s){Hm.subVectors(t,e),pf.subVectors(n,e),Vm.crossVectors(Hm,pf);let o=this.direction.dot(Vm),a;if(o>0){if(i)return null;a=1}else if(o<0)a=-1,o=-o;else return null;so.subVectors(this.origin,e);const l=a*this.direction.dot(pf.crossVectors(so,pf));if(l<0)return null;const c=a*this.direction.dot(Hm.cross(so));if(c<0||l+c>o)return null;const u=-a*so.dot(Vm);return u<0?null:this.at(u/o,s)}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 yt{constructor(e,t,n,i,s,o,a,l,c,u,h,p,m,v,_,y){yt.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,i,s,o,a,l,c,u,h,p,m,v,_,y)}set(e,t,n,i,s,o,a,l,c,u,h,p,m,v,_,y){const g=this.elements;return g[0]=e,g[4]=t,g[8]=n,g[12]=i,g[1]=s,g[5]=o,g[9]=a,g[13]=l,g[2]=c,g[6]=u,g[10]=h,g[14]=p,g[3]=m,g[7]=v,g[11]=_,g[15]=y,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 yt().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,i=1/tl.setFromMatrixColumn(e,0).length(),s=1/tl.setFromMatrixColumn(e,1).length(),o=1/tl.setFromMatrixColumn(e,2).length();return t[0]=n[0]*i,t[1]=n[1]*i,t[2]=n[2]*i,t[3]=0,t[4]=n[4]*s,t[5]=n[5]*s,t[6]=n[6]*s,t[7]=0,t[8]=n[8]*o,t[9]=n[9]*o,t[10]=n[10]*o,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,i=e.y,s=e.z,o=Math.cos(n),a=Math.sin(n),l=Math.cos(i),c=Math.sin(i),u=Math.cos(s),h=Math.sin(s);if(e.order==="XYZ"){const p=o*u,m=o*h,v=a*u,_=a*h;t[0]=l*u,t[4]=-l*h,t[8]=c,t[1]=m+v*c,t[5]=p-_*c,t[9]=-a*l,t[2]=_-p*c,t[6]=v+m*c,t[10]=o*l}else if(e.order==="YXZ"){const p=l*u,m=l*h,v=c*u,_=c*h;t[0]=p+_*a,t[4]=v*a-m,t[8]=o*c,t[1]=o*h,t[5]=o*u,t[9]=-a,t[2]=m*a-v,t[6]=_+p*a,t[10]=o*l}else if(e.order==="ZXY"){const p=l*u,m=l*h,v=c*u,_=c*h;t[0]=p-_*a,t[4]=-o*h,t[8]=v+m*a,t[1]=m+v*a,t[5]=o*u,t[9]=_-p*a,t[2]=-o*c,t[6]=a,t[10]=o*l}else if(e.order==="ZYX"){const p=o*u,m=o*h,v=a*u,_=a*h;t[0]=l*u,t[4]=v*c-m,t[8]=p*c+_,t[1]=l*h,t[5]=_*c+p,t[9]=m*c-v,t[2]=-c,t[6]=a*l,t[10]=o*l}else if(e.order==="YZX"){const p=o*l,m=o*c,v=a*l,_=a*c;t[0]=l*u,t[4]=_-p*h,t[8]=v*h+m,t[1]=h,t[5]=o*u,t[9]=-a*u,t[2]=-c*u,t[6]=m*h+v,t[10]=p-_*h}else if(e.order==="XZY"){const p=o*l,m=o*c,v=a*l,_=a*c;t[0]=l*u,t[4]=-h,t[8]=c*u,t[1]=p*h+_,t[5]=o*u,t[9]=m*h-v,t[2]=v*h-m,t[6]=a*u,t[10]=_*h+p}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(iR,e,rR)}lookAt(e,t,n){const i=this.elements;return $i.subVectors(e,t),$i.lengthSq()===0&&($i.z=1),$i.normalize(),oo.crossVectors(n,$i),oo.lengthSq()===0&&(Math.abs(n.z)===1?$i.x+=1e-4:$i.z+=1e-4,$i.normalize(),oo.crossVectors(n,$i)),oo.normalize(),mf.crossVectors($i,oo),i[0]=oo.x,i[4]=mf.x,i[8]=$i.x,i[1]=oo.y,i[5]=mf.y,i[9]=$i.y,i[2]=oo.z,i[6]=mf.z,i[10]=$i.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,i=t.elements,s=this.elements,o=n[0],a=n[4],l=n[8],c=n[12],u=n[1],h=n[5],p=n[9],m=n[13],v=n[2],_=n[6],y=n[10],g=n[14],x=n[3],w=n[7],E=n[11],b=n[15],M=i[0],A=i[4],P=i[8],C=i[12],L=i[1],F=i[5],N=i[9],I=i[13],X=i[2],q=i[6],W=i[10],O=i[14],k=i[3],G=i[7],B=i[11],D=i[15];return s[0]=o*M+a*L+l*X+c*k,s[4]=o*A+a*F+l*q+c*G,s[8]=o*P+a*N+l*W+c*B,s[12]=o*C+a*I+l*O+c*D,s[1]=u*M+h*L+p*X+m*k,s[5]=u*A+h*F+p*q+m*G,s[9]=u*P+h*N+p*W+m*B,s[13]=u*C+h*I+p*O+m*D,s[2]=v*M+_*L+y*X+g*k,s[6]=v*A+_*F+y*q+g*G,s[10]=v*P+_*N+y*W+g*B,s[14]=v*C+_*I+y*O+g*D,s[3]=x*M+w*L+E*X+b*k,s[7]=x*A+w*F+E*q+b*G,s[11]=x*P+w*N+E*W+b*B,s[15]=x*C+w*I+E*O+b*D,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],i=e[8],s=e[12],o=e[1],a=e[5],l=e[9],c=e[13],u=e[2],h=e[6],p=e[10],m=e[14],v=e[3],_=e[7],y=e[11],g=e[15];return v*(+s*l*h-i*c*h-s*a*p+n*c*p+i*a*m-n*l*m)+_*(+t*l*m-t*c*p+s*o*p-i*o*m+i*c*u-s*l*u)+y*(+t*c*h-t*a*m-s*o*h+n*o*m+s*a*u-n*c*u)+g*(-i*a*u-t*l*h+t*a*p+i*o*h-n*o*p+n*l*u)}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 i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=t,i[14]=n),this}invert(){const e=this.elements,t=e[0],n=e[1],i=e[2],s=e[3],o=e[4],a=e[5],l=e[6],c=e[7],u=e[8],h=e[9],p=e[10],m=e[11],v=e[12],_=e[13],y=e[14],g=e[15],x=h*y*c-_*p*c+_*l*m-a*y*m-h*l*g+a*p*g,w=v*p*c-u*y*c-v*l*m+o*y*m+u*l*g-o*p*g,E=u*_*c-v*h*c+v*a*m-o*_*m-u*a*g+o*h*g,b=v*h*l-u*_*l-v*a*p+o*_*p+u*a*y-o*h*y,M=t*x+n*w+i*E+s*b;if(M===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const A=1/M;return e[0]=x*A,e[1]=(_*p*s-h*y*s-_*i*m+n*y*m+h*i*g-n*p*g)*A,e[2]=(a*y*s-_*l*s+_*i*c-n*y*c-a*i*g+n*l*g)*A,e[3]=(h*l*s-a*p*s-h*i*c+n*p*c+a*i*m-n*l*m)*A,e[4]=w*A,e[5]=(u*y*s-v*p*s+v*i*m-t*y*m-u*i*g+t*p*g)*A,e[6]=(v*l*s-o*y*s-v*i*c+t*y*c+o*i*g-t*l*g)*A,e[7]=(o*p*s-u*l*s+u*i*c-t*p*c-o*i*m+t*l*m)*A,e[8]=E*A,e[9]=(v*h*s-u*_*s-v*n*m+t*_*m+u*n*g-t*h*g)*A,e[10]=(o*_*s-v*a*s+v*n*c-t*_*c-o*n*g+t*a*g)*A,e[11]=(u*a*s-o*h*s-u*n*c+t*h*c+o*n*m-t*a*m)*A,e[12]=b*A,e[13]=(u*_*i-v*h*i+v*n*p-t*_*p-u*n*y+t*h*y)*A,e[14]=(v*a*i-o*_*i-v*n*l+t*_*l+o*n*y-t*a*y)*A,e[15]=(o*h*i-u*a*i+u*n*l-t*h*l-o*n*p+t*a*p)*A,this}scale(e){const t=this.elements,n=e.x,i=e.y,s=e.z;return t[0]*=n,t[4]*=i,t[8]*=s,t[1]*=n,t[5]*=i,t[9]*=s,t[2]*=n,t[6]*=i,t[10]*=s,t[3]*=n,t[7]*=i,t[11]*=s,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],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,i))}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),i=Math.sin(t),s=1-n,o=e.x,a=e.y,l=e.z,c=s*o,u=s*a;return this.set(c*o+n,c*a-i*l,c*l+i*a,0,c*a+i*l,u*a+n,u*l-i*o,0,c*l-i*a,u*l+i*o,s*l*l+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,i,s,o){return this.set(1,n,s,0,e,1,o,0,t,i,1,0,0,0,0,1),this}compose(e,t,n){const i=this.elements,s=t._x,o=t._y,a=t._z,l=t._w,c=s+s,u=o+o,h=a+a,p=s*c,m=s*u,v=s*h,_=o*u,y=o*h,g=a*h,x=l*c,w=l*u,E=l*h,b=n.x,M=n.y,A=n.z;return i[0]=(1-(_+g))*b,i[1]=(m+E)*b,i[2]=(v-w)*b,i[3]=0,i[4]=(m-E)*M,i[5]=(1-(p+g))*M,i[6]=(y+x)*M,i[7]=0,i[8]=(v+w)*A,i[9]=(y-x)*A,i[10]=(1-(p+_))*A,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,t,n){const i=this.elements;let s=tl.set(i[0],i[1],i[2]).length();const o=tl.set(i[4],i[5],i[6]).length(),a=tl.set(i[8],i[9],i[10]).length();this.determinant()<0&&(s=-s),e.x=i[12],e.y=i[13],e.z=i[14],Cr.copy(this);const c=1/s,u=1/o,h=1/a;return Cr.elements[0]*=c,Cr.elements[1]*=c,Cr.elements[2]*=c,Cr.elements[4]*=u,Cr.elements[5]*=u,Cr.elements[6]*=u,Cr.elements[8]*=h,Cr.elements[9]*=h,Cr.elements[10]*=h,t.setFromRotationMatrix(Cr),n.x=s,n.y=o,n.z=a,this}makePerspective(e,t,n,i,s,o,a=ss){const l=this.elements,c=2*s/(t-e),u=2*s/(n-i),h=(t+e)/(t-e),p=(n+i)/(n-i);let m,v;if(a===ss)m=-(o+s)/(o-s),v=-2*o*s/(o-s);else if(a===Nu)m=-o/(o-s),v=-o*s/(o-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);return l[0]=c,l[4]=0,l[8]=h,l[12]=0,l[1]=0,l[5]=u,l[9]=p,l[13]=0,l[2]=0,l[6]=0,l[10]=m,l[14]=v,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(e,t,n,i,s,o,a=ss){const l=this.elements,c=1/(t-e),u=1/(n-i),h=1/(o-s),p=(t+e)*c,m=(n+i)*u;let v,_;if(a===ss)v=(o+s)*h,_=-2*h;else if(a===Nu)v=s*h,_=-1*h;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);return l[0]=2*c,l[4]=0,l[8]=0,l[12]=-p,l[1]=0,l[5]=2*u,l[9]=0,l[13]=-m,l[2]=0,l[6]=0,l[10]=_,l[14]=-v,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(e){const t=this.elements,n=e.elements;for(let i=0;i<16;i++)if(t[i]!==n[i])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 tl=new Y,Cr=new yt,iR=new Y(0,0,0),rR=new Y(1,1,1),oo=new Y,mf=new Y,$i=new Y,Yx=new yt,qx=new si;class Eo{constructor(e=0,t=0,n=0,i=Eo.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,i=this._order){return this._x=e,this._y=t,this._z=n,this._order=i,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 i=e.elements,s=i[0],o=i[4],a=i[8],l=i[1],c=i[5],u=i[9],h=i[2],p=i[6],m=i[10];switch(t){case"XYZ":this._y=Math.asin(Tn(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-u,m),this._z=Math.atan2(-o,s)):(this._x=Math.atan2(p,c),this._z=0);break;case"YXZ":this._x=Math.asin(-Tn(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(a,m),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-h,s),this._z=0);break;case"ZXY":this._x=Math.asin(Tn(p,-1,1)),Math.abs(p)<.9999999?(this._y=Math.atan2(-h,m),this._z=Math.atan2(-o,c)):(this._y=0,this._z=Math.atan2(l,s));break;case"ZYX":this._y=Math.asin(-Tn(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(p,m),this._z=Math.atan2(l,s)):(this._x=0,this._z=Math.atan2(-o,c));break;case"YZX":this._z=Math.asin(Tn(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-u,c),this._y=Math.atan2(-h,s)):(this._x=0,this._y=Math.atan2(a,m));break;case"XZY":this._z=Math.asin(-Tn(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(p,c),this._y=Math.atan2(a,s)):(this._x=Math.atan2(-u,m),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 Yx.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Yx,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return qx.setFromEuler(this),this.setFromQuaternion(qx,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}}Eo.DEFAULT_ORDER="XYZ";class ga{constructor(){this.mask=1}set(e){this.mask=(1<>>0}enable(e){this.mask|=1<1){for(let t=0;t1){for(let n=0;n0&&(n=n.concat(o))}return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Lc,e,oR),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Lc,aR,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,i=t.length;n0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON()));function s(a,l){return a[l.uuid]===void 0&&(a[l.uuid]=l.toJSON(e)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=s(e.geometries,this.geometry);const a=this.geometry.parameters;if(a!==void 0&&a.shapes!==void 0){const l=a.shapes;if(Array.isArray(l))for(let c=0,u=l.length;c0){i.children=[];for(let a=0;a0){i.animations=[];for(let a=0;a0&&(n.geometries=a),l.length>0&&(n.materials=l),c.length>0&&(n.textures=c),u.length>0&&(n.images=u),h.length>0&&(n.shapes=h),p.length>0&&(n.skeletons=p),m.length>0&&(n.animations=m),v.length>0&&(n.nodes=v)}return n.object=i,n;function o(a){const l=[];for(const c in a){const u=a[c];delete u.metadata,l.push(u)}return l}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,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,this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;n0?i.multiplyScalar(1/Math.sqrt(s)):i.set(0,0,0)}static getBarycoord(e,t,n,i,s){Rr.subVectors(i,t),Ts.subVectors(n,t),Wm.subVectors(e,t);const o=Rr.dot(Rr),a=Rr.dot(Ts),l=Rr.dot(Wm),c=Ts.dot(Ts),u=Ts.dot(Wm),h=o*c-a*a;if(h===0)return s.set(-2,-1,-1);const p=1/h,m=(c*l-a*u)*p,v=(o*u-a*l)*p;return s.set(1-m-v,v,m)}static containsPoint(e,t,n,i){return this.getBarycoord(e,t,n,i,As),As.x>=0&&As.y>=0&&As.x+As.y<=1}static getUV(e,t,n,i,s,o,a,l){return vf===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),vf=!0),this.getInterpolation(e,t,n,i,s,o,a,l)}static getInterpolation(e,t,n,i,s,o,a,l){return this.getBarycoord(e,t,n,i,As),l.setScalar(0),l.addScaledVector(s,As.x),l.addScaledVector(o,As.y),l.addScaledVector(a,As.z),l}static isFrontFacing(e,t,n,i){return Rr.subVectors(n,t),Ts.subVectors(e,t),Rr.cross(Ts).dot(i)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,i){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,t,n,i){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,i),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 Rr.subVectors(this.c,this.b),Ts.subVectors(this.a,this.b),Rr.cross(Ts).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return zi.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return zi.getBarycoord(e,this.a,this.b,this.c,t)}getUV(e,t,n,i,s){return vf===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),vf=!0),zi.getInterpolation(e,this.a,this.b,this.c,t,n,i,s)}getInterpolation(e,t,n,i,s){return zi.getInterpolation(e,this.a,this.b,this.c,t,n,i,s)}containsPoint(e){return zi.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return zi.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const n=this.a,i=this.b,s=this.c;let o,a;il.subVectors(i,n),rl.subVectors(s,n),Xm.subVectors(e,n);const l=il.dot(Xm),c=rl.dot(Xm);if(l<=0&&c<=0)return t.copy(n);jm.subVectors(e,i);const u=il.dot(jm),h=rl.dot(jm);if(u>=0&&h<=u)return t.copy(i);const p=l*h-u*c;if(p<=0&&l>=0&&u<=0)return o=l/(l-u),t.copy(n).addScaledVector(il,o);Ym.subVectors(e,s);const m=il.dot(Ym),v=rl.dot(Ym);if(v>=0&&m<=v)return t.copy(s);const _=m*c-l*v;if(_<=0&&c>=0&&v<=0)return a=c/(c-v),t.copy(n).addScaledVector(rl,a);const y=u*v-m*h;if(y<=0&&h-u>=0&&m-v>=0)return e1.subVectors(s,i),a=(h-u)/(h-u+(m-v)),t.copy(i).addScaledVector(e1,a);const g=1/(y+_+p);return o=_*g,a=p*g,t.copy(n).addScaledVector(il,o).addScaledVector(rl,a)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}let cR=0;class oi extends Hs{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:cR++}),this.uuid=er(),this.name="",this.type="Material",this.blending=pa,this.side=ls,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=Vv,this.blendDst=Wv,this.blendEquation=aa,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=Ld,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=Kb,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Ed,this.stencilZFail=Ed,this.stencilZPass=Ed,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 i=this[t];if(i===void 0){console.warn(`THREE.Material: '${t}' is not a property of THREE.${this.type}.`);continue}i&&i.isColor?i.set(n):i&&i.isVector3&&n&&n.isVector3?i.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&&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.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!==pa&&(n.blending=this.blending),this.side!==ls&&(n.side=this.side),this.vertexColors&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=this.transparent),n.depthFunc=this.depthFunc,n.depthTest=this.depthTest,n.depthWrite=this.depthWrite,n.colorWrite=this.colorWrite,n.stencilWrite=this.stencilWrite,n.stencilWriteMask=this.stencilWriteMask,n.stencilFunc=this.stencilFunc,n.stencilRef=this.stencilRef,n.stencilFuncMask=this.stencilFuncMask,n.stencilFail=this.stencilFail,n.stencilZFail=this.stencilZFail,n.stencilZPass=this.stencilZPass,this.rotation!==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=this.alphaHash),this.alphaToCoverage===!0&&(n.alphaToCoverage=this.alphaToCoverage),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=this.premultipliedAlpha),this.forceSinglePass===!0&&(n.forceSinglePass=this.forceSinglePass),this.wireframe===!0&&(n.wireframe=this.wireframe),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=this.flatShading),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 i(s){const o=[];for(const a in s){const l=s[a];delete l.metadata,o.push(l)}return o}if(t){const s=i(e.textures),o=i(e.images);s.length>0&&(n.textures=s),o.length>0&&(n.images=o)}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.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 i=t.length;n=new Array(i);for(let s=0;s!==i;++s)n[s]=t[s].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++}}const aM={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},Pr={h:0,s:0,l:0},yf={h:0,s:0,l:0};function qm(r,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?r+(e-r)*6*t:t<1/2?e:t<2/3?r+(e-r)*6*(2/3-t):r}class Ke{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 i=e;i&&i.isColor?this.copy(i):typeof i=="number"?this.setHex(i):typeof i=="string"&&this.setStyle(i)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Mt){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,vr.toWorkingColorSpace(this,t),this}setRGB(e,t,n,i=vr.workingColorSpace){return this.r=e,this.g=t,this.b=n,vr.toWorkingColorSpace(this,i),this}setHSL(e,t,n,i=vr.workingColorSpace){if(e=iy(e,1),t=Tn(t,0,1),n=Tn(n,0,1),t===0)this.r=this.g=this.b=n;else{const s=n<=.5?n*(1+t):n+t-n*t,o=2*n-s;this.r=qm(o,s,e+1/3),this.g=qm(o,s,e),this.b=qm(o,s,e-1/3)}return vr.toWorkingColorSpace(this,i),this}setStyle(e,t=Mt){function n(s){s!==void 0&&parseFloat(s)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let s;const o=i[1],a=i[2];switch(o){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,t);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,t);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,t);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){const s=i[1],o=s.length;if(o===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,t);if(o===6)return this.setHex(parseInt(s,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=Mt){const n=aM[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=zl(e.r),this.g=zl(e.g),this.b=zl(e.b),this}copyLinearToSRGB(e){return this.r=Nm(e.r),this.g=Nm(e.g),this.b=Nm(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Mt){return vr.fromWorkingColorSpace(gi.copy(this),e),Math.round(Tn(gi.r*255,0,255))*65536+Math.round(Tn(gi.g*255,0,255))*256+Math.round(Tn(gi.b*255,0,255))}getHexString(e=Mt){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=vr.workingColorSpace){vr.fromWorkingColorSpace(gi.copy(this),t);const n=gi.r,i=gi.g,s=gi.b,o=Math.max(n,i,s),a=Math.min(n,i,s);let l,c;const u=(a+o)/2;if(a===o)l=0,c=0;else{const h=o-a;switch(c=u<=.5?h/(o+a):h/(2-o-a),o){case n:l=(i-s)/h+(i>-c-14,n[l|256]=1024>>-c-14|32768,i[l]=-c-1,i[l|256]=-c-1):c<=15?(n[l]=c+15<<10,n[l|256]=c+15<<10|32768,i[l]=13,i[l|256]=13):c<128?(n[l]=31744,n[l|256]=64512,i[l]=24,i[l|256]=24):(n[l]=31744,n[l|256]=64512,i[l]=13,i[l|256]=13)}const s=new Uint32Array(2048),o=new Uint32Array(64),a=new Uint32Array(64);for(let l=1;l<1024;++l){let c=l<<13,u=0;for(;(c&8388608)===0;)c<<=1,u-=8388608;c&=-8388609,u+=947912704,s[l]=c|u}for(let l=1024;l<2048;++l)s[l]=939524096+(l-1024<<13);for(let l=1;l<31;++l)o[l]=l<<23;o[31]=1199570944,o[32]=2147483648;for(let l=33;l<63;++l)o[l]=2147483648+(l-32<<23);o[63]=3347054592;for(let l=1;l<64;++l)l!==32&&(a[l]=1024);return{floatView:e,uint32View:t,baseTable:n,shiftTable:i,mantissaTable:s,exponentTable:o,offsetTable:a}}function ki(r){Math.abs(r)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),r=Tn(r,-65504,65504),Os.floatView[0]=r;const e=Os.uint32View[0],t=e>>23&511;return Os.baseTable[t]+((e&8388607)>>Os.shiftTable[t])}function hu(r){const e=r>>10;return Os.uint32View[0]=Os.mantissaTable[Os.offsetTable[e]+(r&1023)]+Os.exponentTable[e],Os.floatView[0]}const hR={toHalfFloat:ki,fromHalfFloat:hu},Fn=new Y,_f=new De;class $t{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=Ou,this.updateRange={offset:0,count:-1},this.gpuType=rs,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let i=0,s=this.itemSize;i0&&(e.userData=this.userData),this.parameters!==void 0){const l=this.parameters;for(const c in l)l[c]!==void 0&&(e[c]=l[c]);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 l in n){const c=n[l];e.data.attributes[l]=c.toJSON(e.data)}const i={};let s=!1;for(const l in this.morphAttributes){const c=this.morphAttributes[l],u=[];for(let h=0,p=c.length;h0&&(i[l]=u,s=!0)}s&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);const o=this.groups;o.length>0&&(e.data.groups=JSON.parse(JSON.stringify(o)));const a=this.boundingSphere;return a!==null&&(e.data.boundingSphere={center:a.center.toArray(),radius:a.radius}),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const n=e.index;n!==null&&this.setIndex(n.clone(t));const i=e.attributes;for(const c in i){const u=i[c];this.setAttribute(c,u.clone(t))}const s=e.morphAttributes;for(const c in s){const u=[],h=s[c];for(let p=0,m=h.length;p0){const i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=i.length;s(e.far-e.near)**2))&&(t1.copy(s).invert(),Yo.copy(e.ray).applyMatrix4(t1),!(n.boundingBox!==null&&Yo.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,Yo)))}_computeIntersections(e,t,n){let i;const s=this.geometry,o=this.material,a=s.index,l=s.attributes.position,c=s.attributes.uv,u=s.attributes.uv1,h=s.attributes.normal,p=s.groups,m=s.drawRange;if(a!==null)if(Array.isArray(o))for(let v=0,_=p.length;v<_;v++){const y=p[v],g=o[y.materialIndex],x=Math.max(y.start,m.start),w=Math.min(a.count,Math.min(y.start+y.count,m.start+m.count));for(let E=x,b=w;Et.far?null:{distance:c,point:Tf.clone(),object:r}}function Af(r,e,t,n,i,s,o,a,l,c){r.getVertexPosition(a,ol),r.getVertexPosition(l,al),r.getVertexPosition(c,ll);const u=xR(r,e,t,n,ol,al,ll,Mf);if(u){i&&(Sf.fromBufferAttribute(i,a),Ef.fromBufferAttribute(i,l),bf.fromBufferAttribute(i,c),u.uv=zi.getInterpolation(Mf,ol,al,ll,Sf,Ef,bf,new De)),s&&(Sf.fromBufferAttribute(s,a),Ef.fromBufferAttribute(s,l),bf.fromBufferAttribute(s,c),u.uv1=zi.getInterpolation(Mf,ol,al,ll,Sf,Ef,bf,new De),u.uv2=u.uv1),o&&(i1.fromBufferAttribute(o,a),r1.fromBufferAttribute(o,l),s1.fromBufferAttribute(o,c),u.normal=zi.getInterpolation(Mf,ol,al,ll,i1,r1,s1,new Y),u.normal.dot(n.direction)>0&&u.normal.multiplyScalar(-1));const h={a,b:l,c,normal:new Y,materialIndex:0};zi.getNormal(ol,al,ll,h.normal),u.face=h}return u}class Ws extends Tt{constructor(e=1,t=1,n=1,i=1,s=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:i,heightSegments:s,depthSegments:o};const a=this;i=Math.floor(i),s=Math.floor(s),o=Math.floor(o);const l=[],c=[],u=[],h=[];let p=0,m=0;v("z","y","x",-1,-1,n,t,e,o,s,0),v("z","y","x",1,-1,n,t,-e,o,s,1),v("x","z","y",1,1,e,n,t,i,o,2),v("x","z","y",1,-1,e,n,-t,i,o,3),v("x","y","z",1,-1,e,t,n,i,s,4),v("x","y","z",-1,-1,e,t,-n,i,s,5),this.setIndex(l),this.setAttribute("position",new st(c,3)),this.setAttribute("normal",new st(u,3)),this.setAttribute("uv",new st(h,2));function v(_,y,g,x,w,E,b,M,A,P,C){const L=E/A,F=b/P,N=E/2,I=b/2,X=M/2,q=A+1,W=P+1;let O=0,k=0;const G=new Y;for(let B=0;B0?1:-1,u.push(G.x,G.y,G.z),h.push(V/A),h.push(1-B/P),O+=1}}for(let B=0;B0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;const n={};for(const i in this.extensions)this.extensions[i]===!0&&(n[i]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}}class rh extends jt{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new yt,this.projectionMatrix=new yt,this.projectionMatrixInverse=new yt,this.coordinateSystem=ss}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(-t[8],-t[9],-t[10]).normalize()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}}class zn extends rh{constructor(e=50,t=1,n=.1,i=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=i,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const t=.5*this.getFilmHeight()/e;this.fov=Wl*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(ma*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return Wl*2*Math.atan(Math.tan(ma*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}setViewOffset(e,t,n,i,s,o){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=i,this.view.width=s,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(ma*.5*this.fov)/this.zoom,n=2*t,i=this.aspect*n,s=-.5*i;const o=this.view;if(this.view!==null&&this.view.enabled){const l=o.fullWidth,c=o.fullHeight;s+=o.offsetX*i/l,t-=o.offsetY*n/c,i*=o.width/l,n*=o.height/c}const a=this.filmOffset;a!==0&&(s+=e*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+i,t,t-n,e,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}const cl=-90,ul=1;class cM extends jt{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null;const i=new zn(cl,ul,e,t);i.layers=this.layers,this.add(i);const s=new zn(cl,ul,e,t);s.layers=this.layers,this.add(s);const o=new zn(cl,ul,e,t);o.layers=this.layers,this.add(o);const a=new zn(cl,ul,e,t);a.layers=this.layers,this.add(a);const l=new zn(cl,ul,e,t);l.layers=this.layers,this.add(l);const c=new zn(cl,ul,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[n,i,s,o,a,l]=t;for(const c of t)this.remove(c);if(e===ss)n.up.set(0,1,0),n.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),s.up.set(0,0,-1),s.lookAt(0,1,0),o.up.set(0,0,1),o.lookAt(0,-1,0),a.up.set(0,1,0),a.lookAt(0,0,1),l.up.set(0,1,0),l.lookAt(0,0,-1);else if(e===Nu)n.up.set(0,-1,0),n.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),s.up.set(0,0,1),s.lookAt(0,1,0),o.up.set(0,0,-1),o.lookAt(0,-1,0),a.up.set(0,-1,0),a.lookAt(0,0,1),l.up.set(0,-1,0),l.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const c of t)this.add(c),c.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();const n=this.renderTarget;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[i,s,o,a,l,c]=this.children,u=e.getRenderTarget(),h=e.toneMapping,p=e.xr.enabled;e.toneMapping=zr,e.xr.enabled=!1;const m=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,e.setRenderTarget(n,0),e.render(t,i),e.setRenderTarget(n,1),e.render(t,s),e.setRenderTarget(n,2),e.render(t,o),e.setRenderTarget(n,3),e.render(t,a),e.setRenderTarget(n,4),e.render(t,l),n.texture.generateMipmaps=m,e.setRenderTarget(n,5),e.render(t,c),e.setRenderTarget(u),e.toneMapping=h,e.xr.enabled=p,n.texture.needsPMREMUpdate=!0}}class sh extends Sn{constructor(e,t,n,i,s,o,a,l,c,u){e=e!==void 0?e:[],t=t!==void 0?t:xo,super(e,t,n,i,s,o,a,l,c,u),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class uM extends Gr{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const n={width:e,height:e,depth:1},i=[n,n,n,n,n,n];t.encoding!==void 0&&(_u("THREE.WebGLCubeRenderTarget: option.encoding has been replaced by option.colorSpace."),t.colorSpace=t.encoding===vo?Mt:yo),this.texture=new sh(i,t.mapping,t.wrapS,t.wrapT,t.magFilter,t.minFilter,t.format,t.type,t.anisotropy,t.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=t.generateMipmaps!==void 0?t.generateMipmaps:!1,this.texture.minFilter=t.minFilter!==void 0?t.minFilter:fn}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const n={uniforms:{tEquirect:{value:null}},vertexShader:` varying vec3 vWorldDirection; vec3 transformDirection( in vec3 dir, in mat4 matrix ) { return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); } void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include } `,fragmentShader:` uniform sampler2D tEquirect; varying vec3 vWorldDirection; #include void main() { vec3 direction = normalize( vWorldDirection ); vec2 sampleUV = equirectUv( direction ); gl_FragColor = texture2D( tEquirect, sampleUV ); } `},i=new Ws(5,5,5),s=new cs({name:"CubemapFromEquirect",uniforms:Xl(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:yi,blending:Fs});s.uniforms.tEquirect.value=t;const o=new _n(i,s),a=t.minFilter;return t.minFilter===So&&(t.minFilter=fn),new cM(1,10,this).update(e,o),t.minFilter=a,o.geometry.dispose(),o.material.dispose(),this}clear(e,t,n,i){const s=e.getRenderTarget();for(let o=0;o<6;o++)e.setRenderTarget(this,o),e.clear(t,n,i);e.setRenderTarget(s)}}const $m=new Y,bR=new Y,MR=new Ct;class Us{constructor(e=new Y(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,i){return this.normal.set(e,t,n),this.constant=i,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){const i=$m.subVectors(n,t).cross(bR.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(i,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($m),i=this.normal.dot(n);if(i===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const s=-(e.start.dot(this.normal)+this.constant)/i;return s<0||s>1?null:t.copy(e.start).addScaledVector(n,s)}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||MR.getNormalMatrix(e),i=this.coplanarPoint($m).applyMatrix4(e),s=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(s),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 qo=new rr,Cf=new Y;class oh{constructor(e=new Us,t=new Us,n=new Us,i=new Us,s=new Us,o=new Us){this.planes=[e,t,n,i,s,o]}set(e,t,n,i,s,o){const a=this.planes;return a[0].copy(e),a[1].copy(t),a[2].copy(n),a[3].copy(i),a[4].copy(s),a[5].copy(o),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=ss){const n=this.planes,i=e.elements,s=i[0],o=i[1],a=i[2],l=i[3],c=i[4],u=i[5],h=i[6],p=i[7],m=i[8],v=i[9],_=i[10],y=i[11],g=i[12],x=i[13],w=i[14],E=i[15];if(n[0].setComponents(l-s,p-c,y-m,E-g).normalize(),n[1].setComponents(l+s,p+c,y+m,E+g).normalize(),n[2].setComponents(l+o,p+u,y+v,E+x).normalize(),n[3].setComponents(l-o,p-u,y-v,E-x).normalize(),n[4].setComponents(l-a,p-h,y-_,E-w).normalize(),t===ss)n[5].setComponents(l+a,p+h,y+_,E+w).normalize();else if(t===Nu)n[5].setComponents(a,h,_,w).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(),qo.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),qo.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(qo)}intersectsSprite(e){return qo.center.set(0,0,0),qo.radius=.7071067811865476,qo.applyMatrix4(e.matrixWorld),this.intersectsSphere(qo)}intersectsSphere(e){const t=this.planes,n=e.center,i=-e.radius;for(let s=0;s<6;s++)if(t[s].distanceToPoint(n)0?e.max.x:e.min.x,Cf.y=i.normal.y>0?e.max.y:e.min.y,Cf.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(Cf)<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 hM(){let r=null,e=!1,t=null,n=null;function i(s,o){t(s,o),n=r.requestAnimationFrame(i)}return{start:function(){e!==!0&&t!==null&&(n=r.requestAnimationFrame(i),e=!0)},stop:function(){r.cancelAnimationFrame(n),e=!1},setAnimationLoop:function(s){t=s},setContext:function(s){r=s}}}function TR(r,e){const t=e.isWebGL2,n=new WeakMap;function i(c,u){const h=c.array,p=c.usage,m=r.createBuffer();r.bindBuffer(u,m),r.bufferData(u,h,p),c.onUploadCallback();let v;if(h instanceof Float32Array)v=r.FLOAT;else if(h instanceof Uint16Array)if(c.isFloat16BufferAttribute)if(t)v=r.HALF_FLOAT;else throw new Error("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.");else v=r.UNSIGNED_SHORT;else if(h instanceof Int16Array)v=r.SHORT;else if(h instanceof Uint32Array)v=r.UNSIGNED_INT;else if(h instanceof Int32Array)v=r.INT;else if(h instanceof Int8Array)v=r.BYTE;else if(h instanceof Uint8Array)v=r.UNSIGNED_BYTE;else if(h instanceof Uint8ClampedArray)v=r.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+h);return{buffer:m,type:v,bytesPerElement:h.BYTES_PER_ELEMENT,version:c.version}}function s(c,u,h){const p=u.array,m=u.updateRange;r.bindBuffer(h,c),m.count===-1?r.bufferSubData(h,0,p):(t?r.bufferSubData(h,m.offset*p.BYTES_PER_ELEMENT,p,m.offset,m.count):r.bufferSubData(h,m.offset*p.BYTES_PER_ELEMENT,p.subarray(m.offset,m.offset+m.count)),m.count=-1),u.onUploadCallback()}function o(c){return c.isInterleavedBufferAttribute&&(c=c.data),n.get(c)}function a(c){c.isInterleavedBufferAttribute&&(c=c.data);const u=n.get(c);u&&(r.deleteBuffer(u.buffer),n.delete(c))}function l(c,u){if(c.isGLBufferAttribute){const p=n.get(c);(!p||p.version 0 vec4 plane; #pragma unroll_loop_start for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) { plane = clippingPlanes[ i ]; if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard; } #pragma unroll_loop_end #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES bool clipped = true; #pragma unroll_loop_start for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) { plane = clippingPlanes[ i ]; clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped; } #pragma unroll_loop_end if ( clipped ) discard; #endif #endif`,GR=`#if NUM_CLIPPING_PLANES > 0 varying vec3 vClipPosition; uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ]; #endif`,HR=`#if NUM_CLIPPING_PLANES > 0 varying vec3 vClipPosition; #endif`,VR=`#if NUM_CLIPPING_PLANES > 0 vClipPosition = - mvPosition.xyz; #endif`,WR=`#if defined( USE_COLOR_ALPHA ) diffuseColor *= vColor; #elif defined( USE_COLOR ) diffuseColor.rgb *= vColor; #endif`,XR=`#if defined( USE_COLOR_ALPHA ) varying vec4 vColor; #elif defined( USE_COLOR ) varying vec3 vColor; #endif`,jR=`#if defined( USE_COLOR_ALPHA ) varying vec4 vColor; #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) varying vec3 vColor; #endif`,YR=`#if defined( USE_COLOR_ALPHA ) vColor = vec4( 1.0 ); #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) vColor = vec3( 1.0 ); #endif #ifdef USE_COLOR vColor *= color; #endif #ifdef USE_INSTANCING_COLOR vColor.xyz *= instanceColor.xyz; #endif`,qR=`#define PI 3.141592653589793 #define PI2 6.283185307179586 #define PI_HALF 1.5707963267948966 #define RECIPROCAL_PI 0.3183098861837907 #define RECIPROCAL_PI2 0.15915494309189535 #define EPSILON 1e-6 #ifndef saturate #define saturate( a ) clamp( a, 0.0, 1.0 ) #endif #define whiteComplement( a ) ( 1.0 - saturate( a ) ) float pow2( const in float x ) { return x*x; } vec3 pow2( const in vec3 x ) { return x*x; } float pow3( const in float x ) { return x*x*x; } float pow4( const in float x ) { float x2 = x*x; return x2*x2; } float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); } float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); } highp float rand( const in vec2 uv ) { const highp float a = 12.9898, b = 78.233, c = 43758.5453; highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI ); return fract( sin( sn ) * c ); } #ifdef HIGH_PRECISION float precisionSafeLength( vec3 v ) { return length( v ); } #else float precisionSafeLength( vec3 v ) { float maxComponent = max3( abs( v ) ); return length( v / maxComponent ) * maxComponent; } #endif struct IncidentLight { vec3 color; vec3 direction; bool visible; }; struct ReflectedLight { vec3 directDiffuse; vec3 directSpecular; vec3 indirectDiffuse; vec3 indirectSpecular; }; struct GeometricContext { vec3 position; vec3 normal; vec3 viewDir; #ifdef USE_CLEARCOAT vec3 clearcoatNormal; #endif }; #ifdef USE_ALPHAHASH varying vec3 vPosition; #endif vec3 transformDirection( in vec3 dir, in mat4 matrix ) { return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); } vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) { return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz ); } mat3 transposeMat3( const in mat3 m ) { mat3 tmp; tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x ); tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y ); tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z ); return tmp; } float luminance( const in vec3 rgb ) { const vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 ); return dot( weights, rgb ); } bool isPerspectiveMatrix( mat4 m ) { return m[ 2 ][ 3 ] == - 1.0; } vec2 equirectUv( in vec3 dir ) { float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5; float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5; return vec2( u, v ); } vec3 BRDF_Lambert( const in vec3 diffuseColor ) { return RECIPROCAL_PI * diffuseColor; } vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) { float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH ); return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel ); } float F_Schlick( const in float f0, const in float f90, const in float dotVH ) { float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH ); return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel ); } // validated`,ZR=`#ifdef ENVMAP_TYPE_CUBE_UV #define cubeUV_minMipLevel 4.0 #define cubeUV_minTileSize 16.0 float getFace( vec3 direction ) { vec3 absDirection = abs( direction ); float face = - 1.0; if ( absDirection.x > absDirection.z ) { if ( absDirection.x > absDirection.y ) face = direction.x > 0.0 ? 0.0 : 3.0; else face = direction.y > 0.0 ? 1.0 : 4.0; } else { if ( absDirection.z > absDirection.y ) face = direction.z > 0.0 ? 2.0 : 5.0; else face = direction.y > 0.0 ? 1.0 : 4.0; } return face; } vec2 getUV( vec3 direction, float face ) { vec2 uv; if ( face == 0.0 ) { uv = vec2( direction.z, direction.y ) / abs( direction.x ); } else if ( face == 1.0 ) { uv = vec2( - direction.x, - direction.z ) / abs( direction.y ); } else if ( face == 2.0 ) { uv = vec2( - direction.x, direction.y ) / abs( direction.z ); } else if ( face == 3.0 ) { uv = vec2( - direction.z, direction.y ) / abs( direction.x ); } else if ( face == 4.0 ) { uv = vec2( - direction.x, direction.z ) / abs( direction.y ); } else { uv = vec2( direction.x, direction.y ) / abs( direction.z ); } return 0.5 * ( uv + 1.0 ); } vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) { float face = getFace( direction ); float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 ); mipInt = max( mipInt, cubeUV_minMipLevel ); float faceSize = exp2( mipInt ); highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0; if ( face > 2.0 ) { uv.y += faceSize; face -= 3.0; } uv.x += face * faceSize; uv.x += filterInt * 3.0 * cubeUV_minTileSize; uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize ); uv.x *= CUBEUV_TEXEL_WIDTH; uv.y *= CUBEUV_TEXEL_HEIGHT; #ifdef texture2DGradEXT return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb; #else return texture2D( envMap, uv ).rgb; #endif } #define cubeUV_r0 1.0 #define cubeUV_v0 0.339 #define cubeUV_m0 - 2.0 #define cubeUV_r1 0.8 #define cubeUV_v1 0.276 #define cubeUV_m1 - 1.0 #define cubeUV_r4 0.4 #define cubeUV_v4 0.046 #define cubeUV_m4 2.0 #define cubeUV_r5 0.305 #define cubeUV_v5 0.016 #define cubeUV_m5 3.0 #define cubeUV_r6 0.21 #define cubeUV_v6 0.0038 #define cubeUV_m6 4.0 float roughnessToMip( float roughness ) { float mip = 0.0; if ( roughness >= cubeUV_r1 ) { mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0; } else if ( roughness >= cubeUV_r4 ) { mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1; } else if ( roughness >= cubeUV_r5 ) { mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4; } else if ( roughness >= cubeUV_r6 ) { mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5; } else { mip = - 2.0 * log2( 1.16 * roughness ); } return mip; } vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) { float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP ); float mipF = fract( mip ); float mipInt = floor( mip ); vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt ); if ( mipF == 0.0 ) { return vec4( color0, 1.0 ); } else { vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 ); return vec4( mix( color0, color1, mipF ), 1.0 ); } } #endif`,KR=`vec3 transformedNormal = objectNormal; #ifdef USE_INSTANCING mat3 m = mat3( instanceMatrix ); transformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) ); transformedNormal = m * transformedNormal; #endif transformedNormal = normalMatrix * transformedNormal; #ifdef FLIP_SIDED transformedNormal = - transformedNormal; #endif #ifdef USE_TANGENT vec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz; #ifdef FLIP_SIDED transformedTangent = - transformedTangent; #endif #endif`,$R=`#ifdef USE_DISPLACEMENTMAP uniform sampler2D displacementMap; uniform float displacementScale; uniform float displacementBias; #endif`,JR=`#ifdef USE_DISPLACEMENTMAP transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias ); #endif`,QR=`#ifdef USE_EMISSIVEMAP vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv ); totalEmissiveRadiance *= emissiveColor.rgb; #endif`,eP=`#ifdef USE_EMISSIVEMAP uniform sampler2D emissiveMap; #endif`,tP="gl_FragColor = linearToOutputTexel( gl_FragColor );",nP=`vec4 LinearToLinear( in vec4 value ) { return value; } vec4 LinearTosRGB( in vec4 value ) { return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a ); }`,iP=`#ifdef USE_ENVMAP #ifdef ENV_WORLDPOS vec3 cameraToFrag; if ( isOrthographic ) { cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); } else { cameraToFrag = normalize( vWorldPosition - cameraPosition ); } vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); #ifdef ENVMAP_MODE_REFLECTION vec3 reflectVec = reflect( cameraToFrag, worldNormal ); #else vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio ); #endif #else vec3 reflectVec = vReflect; #endif #ifdef ENVMAP_TYPE_CUBE vec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) ); #else vec4 envColor = vec4( 0.0 ); #endif #ifdef ENVMAP_BLENDING_MULTIPLY outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity ); #elif defined( ENVMAP_BLENDING_MIX ) outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity ); #elif defined( ENVMAP_BLENDING_ADD ) outgoingLight += envColor.xyz * specularStrength * reflectivity; #endif #endif`,rP=`#ifdef USE_ENVMAP uniform float envMapIntensity; uniform float flipEnvMap; #ifdef ENVMAP_TYPE_CUBE uniform samplerCube envMap; #else uniform sampler2D envMap; #endif #endif`,sP=`#ifdef USE_ENVMAP uniform float reflectivity; #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) #define ENV_WORLDPOS #endif #ifdef ENV_WORLDPOS varying vec3 vWorldPosition; uniform float refractionRatio; #else varying vec3 vReflect; #endif #endif`,oP=`#ifdef USE_ENVMAP #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) #define ENV_WORLDPOS #endif #ifdef ENV_WORLDPOS varying vec3 vWorldPosition; #else varying vec3 vReflect; uniform float refractionRatio; #endif #endif`,aP=`#ifdef USE_ENVMAP #ifdef ENV_WORLDPOS vWorldPosition = worldPosition.xyz; #else vec3 cameraToVertex; if ( isOrthographic ) { cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); } else { cameraToVertex = normalize( worldPosition.xyz - cameraPosition ); } vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix ); #ifdef ENVMAP_MODE_REFLECTION vReflect = reflect( cameraToVertex, worldNormal ); #else vReflect = refract( cameraToVertex, worldNormal, refractionRatio ); #endif #endif #endif`,lP=`#ifdef USE_FOG vFogDepth = - mvPosition.z; #endif`,cP=`#ifdef USE_FOG varying float vFogDepth; #endif`,uP=`#ifdef USE_FOG #ifdef FOG_EXP2 float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth ); #else float fogFactor = smoothstep( fogNear, fogFar, vFogDepth ); #endif gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor ); #endif`,hP=`#ifdef USE_FOG uniform vec3 fogColor; varying float vFogDepth; #ifdef FOG_EXP2 uniform float fogDensity; #else uniform float fogNear; uniform float fogFar; #endif #endif`,fP=`#ifdef USE_GRADIENTMAP uniform sampler2D gradientMap; #endif vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) { float dotNL = dot( normal, lightDirection ); vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 ); #ifdef USE_GRADIENTMAP return vec3( texture2D( gradientMap, coord ).r ); #else vec2 fw = fwidth( coord ) * 0.5; return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) ); #endif }`,dP=`#ifdef USE_LIGHTMAP vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity; reflectedLight.indirectDiffuse += lightMapIrradiance; #endif`,pP=`#ifdef USE_LIGHTMAP uniform sampler2D lightMap; uniform float lightMapIntensity; #endif`,mP=`LambertMaterial material; material.diffuseColor = diffuseColor.rgb; material.specularStrength = specularStrength;`,gP=`varying vec3 vViewPosition; struct LambertMaterial { vec3 diffuseColor; float specularStrength; }; void RE_Direct_Lambert( const in IncidentLight directLight, const in GeometricContext geometry, const in LambertMaterial material, inout ReflectedLight reflectedLight ) { float dotNL = saturate( dot( geometry.normal, directLight.direction ) ); vec3 irradiance = dotNL * directLight.color; reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in GeometricContext geometry, const in LambertMaterial material, inout ReflectedLight reflectedLight ) { reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } #define RE_Direct RE_Direct_Lambert #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,vP=`uniform bool receiveShadow; uniform vec3 ambientLightColor; uniform vec3 lightProbe[ 9 ]; vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) { float x = normal.x, y = normal.y, z = normal.z; vec3 result = shCoefficients[ 0 ] * 0.886227; result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y; result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z; result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x; result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y; result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z; result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 ); result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z; result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y ); return result; } vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) { vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe ); return irradiance; } vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) { vec3 irradiance = ambientLightColor; return irradiance; } float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) { #if defined ( LEGACY_LIGHTS ) if ( cutoffDistance > 0.0 && decayExponent > 0.0 ) { return pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent ); } return 1.0; #else float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 ); if ( cutoffDistance > 0.0 ) { distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) ); } return distanceFalloff; #endif } float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) { return smoothstep( coneCosine, penumbraCosine, angleCosine ); } #if NUM_DIR_LIGHTS > 0 struct DirectionalLight { vec3 direction; vec3 color; }; uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ]; void getDirectionalLightInfo( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight light ) { light.color = directionalLight.color; light.direction = directionalLight.direction; light.visible = true; } #endif #if NUM_POINT_LIGHTS > 0 struct PointLight { vec3 position; vec3 color; float distance; float decay; }; uniform PointLight pointLights[ NUM_POINT_LIGHTS ]; void getPointLightInfo( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight light ) { vec3 lVector = pointLight.position - geometry.position; light.direction = normalize( lVector ); float lightDistance = length( lVector ); light.color = pointLight.color; light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay ); light.visible = ( light.color != vec3( 0.0 ) ); } #endif #if NUM_SPOT_LIGHTS > 0 struct SpotLight { vec3 position; vec3 direction; vec3 color; float distance; float decay; float coneCos; float penumbraCos; }; uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ]; void getSpotLightInfo( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight light ) { vec3 lVector = spotLight.position - geometry.position; light.direction = normalize( lVector ); float angleCos = dot( light.direction, spotLight.direction ); float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos ); if ( spotAttenuation > 0.0 ) { float lightDistance = length( lVector ); light.color = spotLight.color * spotAttenuation; light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay ); light.visible = ( light.color != vec3( 0.0 ) ); } else { light.color = vec3( 0.0 ); light.visible = false; } } #endif #if NUM_RECT_AREA_LIGHTS > 0 struct RectAreaLight { vec3 color; vec3 position; vec3 halfWidth; vec3 halfHeight; }; uniform sampler2D ltc_1; uniform sampler2D ltc_2; uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ]; #endif #if NUM_HEMI_LIGHTS > 0 struct HemisphereLight { vec3 direction; vec3 skyColor; vec3 groundColor; }; uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ]; vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) { float dotNL = dot( normal, hemiLight.direction ); float hemiDiffuseWeight = 0.5 * dotNL + 0.5; vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight ); return irradiance; } #endif`,yP=`#ifdef USE_ENVMAP vec3 getIBLIrradiance( const in vec3 normal ) { #ifdef ENVMAP_TYPE_CUBE_UV vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); vec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 ); return PI * envMapColor.rgb * envMapIntensity; #else return vec3( 0.0 ); #endif } vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) { #ifdef ENVMAP_TYPE_CUBE_UV vec3 reflectVec = reflect( - viewDir, normal ); reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) ); reflectVec = inverseTransformDirection( reflectVec, viewMatrix ); vec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness ); return envMapColor.rgb * envMapIntensity; #else return vec3( 0.0 ); #endif } #ifdef USE_ANISOTROPY vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) { #ifdef ENVMAP_TYPE_CUBE_UV vec3 bentNormal = cross( bitangent, viewDir ); bentNormal = normalize( cross( bentNormal, bitangent ) ); bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) ); return getIBLRadiance( viewDir, bentNormal, roughness ); #else return vec3( 0.0 ); #endif } #endif #endif`,_P=`ToonMaterial material; material.diffuseColor = diffuseColor.rgb;`,xP=`varying vec3 vViewPosition; struct ToonMaterial { vec3 diffuseColor; }; void RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { vec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color; reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } #define RE_Direct RE_Direct_Toon #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,wP=`BlinnPhongMaterial material; material.diffuseColor = diffuseColor.rgb; material.specularColor = specular; material.specularShininess = shininess; material.specularStrength = specularStrength;`,SP=`varying vec3 vViewPosition; struct BlinnPhongMaterial { vec3 diffuseColor; vec3 specularColor; float specularShininess; float specularStrength; }; void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { float dotNL = saturate( dot( geometry.normal, directLight.direction ) ); vec3 irradiance = dotNL * directLight.color; reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularShininess ) * material.specularStrength; } void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } #define RE_Direct RE_Direct_BlinnPhong #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,EP=`PhysicalMaterial material; material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor ); vec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) ); float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z ); material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness; material.roughness = min( material.roughness, 1.0 ); #ifdef IOR material.ior = ior; #ifdef USE_SPECULAR float specularIntensityFactor = specularIntensity; vec3 specularColorFactor = specularColor; #ifdef USE_SPECULAR_COLORMAP specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb; #endif #ifdef USE_SPECULAR_INTENSITYMAP specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a; #endif material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor ); #else float specularIntensityFactor = 1.0; vec3 specularColorFactor = vec3( 1.0 ); material.specularF90 = 1.0; #endif material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor ); #else material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor ); material.specularF90 = 1.0; #endif #ifdef USE_CLEARCOAT material.clearcoat = clearcoat; material.clearcoatRoughness = clearcoatRoughness; material.clearcoatF0 = vec3( 0.04 ); material.clearcoatF90 = 1.0; #ifdef USE_CLEARCOATMAP material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x; #endif #ifdef USE_CLEARCOAT_ROUGHNESSMAP material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y; #endif material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 ); material.clearcoatRoughness += geometryRoughness; material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 ); #endif #ifdef USE_IRIDESCENCE material.iridescence = iridescence; material.iridescenceIOR = iridescenceIOR; #ifdef USE_IRIDESCENCEMAP material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r; #endif #ifdef USE_IRIDESCENCE_THICKNESSMAP material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum; #else material.iridescenceThickness = iridescenceThicknessMaximum; #endif #endif #ifdef USE_SHEEN material.sheenColor = sheenColor; #ifdef USE_SHEEN_COLORMAP material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb; #endif material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 ); #ifdef USE_SHEEN_ROUGHNESSMAP material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a; #endif #endif #ifdef USE_ANISOTROPY #ifdef USE_ANISOTROPYMAP mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x ); vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb; vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b; #else vec2 anisotropyV = anisotropyVector; #endif material.anisotropy = length( anisotropyV ); anisotropyV /= material.anisotropy; material.anisotropy = saturate( material.anisotropy ); material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) ); material.anisotropyT = tbn[ 0 ] * anisotropyV.x - tbn[ 1 ] * anisotropyV.y; material.anisotropyB = tbn[ 1 ] * anisotropyV.x + tbn[ 0 ] * anisotropyV.y; #endif`,bP=`struct PhysicalMaterial { vec3 diffuseColor; float roughness; vec3 specularColor; float specularF90; #ifdef USE_CLEARCOAT float clearcoat; float clearcoatRoughness; vec3 clearcoatF0; float clearcoatF90; #endif #ifdef USE_IRIDESCENCE float iridescence; float iridescenceIOR; float iridescenceThickness; vec3 iridescenceFresnel; vec3 iridescenceF0; #endif #ifdef USE_SHEEN vec3 sheenColor; float sheenRoughness; #endif #ifdef IOR float ior; #endif #ifdef USE_TRANSMISSION float transmission; float transmissionAlpha; float thickness; float attenuationDistance; vec3 attenuationColor; #endif #ifdef USE_ANISOTROPY float anisotropy; float alphaT; vec3 anisotropyT; vec3 anisotropyB; #endif }; vec3 clearcoatSpecular = vec3( 0.0 ); vec3 sheenSpecular = vec3( 0.0 ); vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) { float x = clamp( 1.0 - dotVH, 0.0, 1.0 ); float x2 = x * x; float x5 = clamp( x * x2 * x2, 0.0, 0.9999 ); return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 ); } float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) { float a2 = pow2( alpha ); float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) ); float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) ); return 0.5 / max( gv + gl, EPSILON ); } float D_GGX( const in float alpha, const in float dotNH ) { float a2 = pow2( alpha ); float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0; return RECIPROCAL_PI * a2 / pow2( denom ); } #ifdef USE_ANISOTROPY float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) { float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) ); float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) ); float v = 0.5 / ( gv + gl ); return saturate(v); } float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) { float a2 = alphaT * alphaB; highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH ); highp float v2 = dot( v, v ); float w2 = a2 / v2; return RECIPROCAL_PI * a2 * pow2 ( w2 ); } #endif #ifdef USE_CLEARCOAT vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) { vec3 f0 = material.clearcoatF0; float f90 = material.clearcoatF90; float roughness = material.clearcoatRoughness; float alpha = pow2( roughness ); vec3 halfDir = normalize( lightDir + viewDir ); float dotNL = saturate( dot( normal, lightDir ) ); float dotNV = saturate( dot( normal, viewDir ) ); float dotNH = saturate( dot( normal, halfDir ) ); float dotVH = saturate( dot( viewDir, halfDir ) ); vec3 F = F_Schlick( f0, f90, dotVH ); float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); float D = D_GGX( alpha, dotNH ); return F * ( V * D ); } #endif vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) { vec3 f0 = material.specularColor; float f90 = material.specularF90; float roughness = material.roughness; float alpha = pow2( roughness ); vec3 halfDir = normalize( lightDir + viewDir ); float dotNL = saturate( dot( normal, lightDir ) ); float dotNV = saturate( dot( normal, viewDir ) ); float dotNH = saturate( dot( normal, halfDir ) ); float dotVH = saturate( dot( viewDir, halfDir ) ); vec3 F = F_Schlick( f0, f90, dotVH ); #ifdef USE_IRIDESCENCE F = mix( F, material.iridescenceFresnel, material.iridescence ); #endif #ifdef USE_ANISOTROPY float dotTL = dot( material.anisotropyT, lightDir ); float dotTV = dot( material.anisotropyT, viewDir ); float dotTH = dot( material.anisotropyT, halfDir ); float dotBL = dot( material.anisotropyB, lightDir ); float dotBV = dot( material.anisotropyB, viewDir ); float dotBH = dot( material.anisotropyB, halfDir ); float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL ); float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH ); #else float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); float D = D_GGX( alpha, dotNH ); #endif return F * ( V * D ); } vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) { const float LUT_SIZE = 64.0; const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE; const float LUT_BIAS = 0.5 / LUT_SIZE; float dotNV = saturate( dot( N, V ) ); vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) ); uv = uv * LUT_SCALE + LUT_BIAS; return uv; } float LTC_ClippedSphereFormFactor( const in vec3 f ) { float l = length( f ); return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 ); } vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) { float x = dot( v1, v2 ); float y = abs( x ); float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y; float b = 3.4175940 + ( 4.1616724 + y ) * y; float v = a / b; float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v; return cross( v1, v2 ) * theta_sintheta; } vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) { vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ]; vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ]; vec3 lightNormal = cross( v1, v2 ); if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 ); vec3 T1, T2; T1 = normalize( V - N * dot( V, N ) ); T2 = - cross( N, T1 ); mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) ); vec3 coords[ 4 ]; coords[ 0 ] = mat * ( rectCoords[ 0 ] - P ); coords[ 1 ] = mat * ( rectCoords[ 1 ] - P ); coords[ 2 ] = mat * ( rectCoords[ 2 ] - P ); coords[ 3 ] = mat * ( rectCoords[ 3 ] - P ); coords[ 0 ] = normalize( coords[ 0 ] ); coords[ 1 ] = normalize( coords[ 1 ] ); coords[ 2 ] = normalize( coords[ 2 ] ); coords[ 3 ] = normalize( coords[ 3 ] ); vec3 vectorFormFactor = vec3( 0.0 ); vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] ); vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] ); vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] ); vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] ); float result = LTC_ClippedSphereFormFactor( vectorFormFactor ); return vec3( result ); } #if defined( USE_SHEEN ) float D_Charlie( float roughness, float dotNH ) { float alpha = pow2( roughness ); float invAlpha = 1.0 / alpha; float cos2h = dotNH * dotNH; float sin2h = max( 1.0 - cos2h, 0.0078125 ); return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI ); } float V_Neubelt( float dotNV, float dotNL ) { return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) ); } vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) { vec3 halfDir = normalize( lightDir + viewDir ); float dotNL = saturate( dot( normal, lightDir ) ); float dotNV = saturate( dot( normal, viewDir ) ); float dotNH = saturate( dot( normal, halfDir ) ); float D = D_Charlie( sheenRoughness, dotNH ); float V = V_Neubelt( dotNV, dotNL ); return sheenColor * ( D * V ); } #endif float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) { float dotNV = saturate( dot( normal, viewDir ) ); float r2 = roughness * roughness; float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95; float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72; float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) ); return saturate( DG * RECIPROCAL_PI ); } vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) { float dotNV = saturate( dot( normal, viewDir ) ); const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 ); const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 ); vec4 r = roughness * c0 + c1; float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y; vec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw; return fab; } vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) { vec2 fab = DFGApprox( normal, viewDir, roughness ); return specularColor * fab.x + specularF90 * fab.y; } #ifdef USE_IRIDESCENCE void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { #else void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { #endif vec2 fab = DFGApprox( normal, viewDir, roughness ); #ifdef USE_IRIDESCENCE vec3 Fr = mix( specularColor, iridescenceF0, iridescence ); #else vec3 Fr = specularColor; #endif vec3 FssEss = Fr * fab.x + specularF90 * fab.y; float Ess = fab.x + fab.y; float Ems = 1.0 - Ess; vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg ); singleScatter += FssEss; multiScatter += Fms * Ems; } #if NUM_RECT_AREA_LIGHTS > 0 void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { vec3 normal = geometry.normal; vec3 viewDir = geometry.viewDir; vec3 position = geometry.position; vec3 lightPos = rectAreaLight.position; vec3 halfWidth = rectAreaLight.halfWidth; vec3 halfHeight = rectAreaLight.halfHeight; vec3 lightColor = rectAreaLight.color; float roughness = material.roughness; vec3 rectCoords[ 4 ]; rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight; rectCoords[ 2 ] = lightPos - halfWidth + halfHeight; rectCoords[ 3 ] = lightPos + halfWidth + halfHeight; vec2 uv = LTC_Uv( normal, viewDir, roughness ); vec4 t1 = texture2D( ltc_1, uv ); vec4 t2 = texture2D( ltc_2, uv ); mat3 mInv = mat3( vec3( t1.x, 0, t1.y ), vec3( 0, 1, 0 ), vec3( t1.z, 0, t1.w ) ); vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y ); reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords ); reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords ); } #endif void RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { float dotNL = saturate( dot( geometry.normal, directLight.direction ) ); vec3 irradiance = dotNL * directLight.color; #ifdef USE_CLEARCOAT float dotNLcc = saturate( dot( geometry.clearcoatNormal, directLight.direction ) ); vec3 ccIrradiance = dotNLcc * directLight.color; clearcoatSpecular += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometry.viewDir, geometry.clearcoatNormal, material ); #endif #ifdef USE_SHEEN sheenSpecular += irradiance * BRDF_Sheen( directLight.direction, geometry.viewDir, geometry.normal, material.sheenColor, material.sheenRoughness ); #endif reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.normal, material ); reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) { #ifdef USE_CLEARCOAT clearcoatSpecular += clearcoatRadiance * EnvironmentBRDF( geometry.clearcoatNormal, geometry.viewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness ); #endif #ifdef USE_SHEEN sheenSpecular += irradiance * material.sheenColor * IBLSheenBRDF( geometry.normal, geometry.viewDir, material.sheenRoughness ); #endif vec3 singleScattering = vec3( 0.0 ); vec3 multiScattering = vec3( 0.0 ); vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI; #ifdef USE_IRIDESCENCE computeMultiscatteringIridescence( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering ); #else computeMultiscattering( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering ); #endif vec3 totalScattering = singleScattering + multiScattering; vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) ); reflectedLight.indirectSpecular += radiance * singleScattering; reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance; reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance; } #define RE_Direct RE_Direct_Physical #define RE_Direct_RectArea RE_Direct_RectArea_Physical #define RE_IndirectDiffuse RE_IndirectDiffuse_Physical #define RE_IndirectSpecular RE_IndirectSpecular_Physical float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) { return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion ); }`,MP=` GeometricContext geometry; geometry.position = - vViewPosition; geometry.normal = normal; geometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition ); #ifdef USE_CLEARCOAT geometry.clearcoatNormal = clearcoatNormal; #endif #ifdef USE_IRIDESCENCE float dotNVi = saturate( dot( normal, geometry.viewDir ) ); if ( material.iridescenceThickness == 0.0 ) { material.iridescence = 0.0; } else { material.iridescence = saturate( material.iridescence ); } if ( material.iridescence > 0.0 ) { material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor ); material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi ); } #endif IncidentLight directLight; #if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct ) PointLight pointLight; #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0 PointLightShadow pointLightShadow; #endif #pragma unroll_loop_start for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) { pointLight = pointLights[ i ]; getPointLightInfo( pointLight, geometry, directLight ); #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) pointLightShadow = pointLightShadows[ i ]; directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0; #endif RE_Direct( directLight, geometry, material, reflectedLight ); } #pragma unroll_loop_end #endif #if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct ) SpotLight spotLight; vec4 spotColor; vec3 spotLightCoord; bool inSpotLightMap; #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0 SpotLightShadow spotLightShadow; #endif #pragma unroll_loop_start for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) { spotLight = spotLights[ i ]; getSpotLightInfo( spotLight, geometry, directLight ); #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS #else #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) #endif #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS ) spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w; inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) ); spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy ); directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color; #endif #undef SPOT_LIGHT_MAP_INDEX #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) spotLightShadow = spotLightShadows[ i ]; directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; #endif RE_Direct( directLight, geometry, material, reflectedLight ); } #pragma unroll_loop_end #endif #if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct ) DirectionalLight directionalLight; #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0 DirectionalLightShadow directionalLightShadow; #endif #pragma unroll_loop_start for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) { directionalLight = directionalLights[ i ]; getDirectionalLightInfo( directionalLight, geometry, directLight ); #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS ) directionalLightShadow = directionalLightShadows[ i ]; directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; #endif RE_Direct( directLight, geometry, material, reflectedLight ); } #pragma unroll_loop_end #endif #if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea ) RectAreaLight rectAreaLight; #pragma unroll_loop_start for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) { rectAreaLight = rectAreaLights[ i ]; RE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight ); } #pragma unroll_loop_end #endif #if defined( RE_IndirectDiffuse ) vec3 iblIrradiance = vec3( 0.0 ); vec3 irradiance = getAmbientLightIrradiance( ambientLightColor ); irradiance += getLightProbeIrradiance( lightProbe, geometry.normal ); #if ( NUM_HEMI_LIGHTS > 0 ) #pragma unroll_loop_start for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) { irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry.normal ); } #pragma unroll_loop_end #endif #endif #if defined( RE_IndirectSpecular ) vec3 radiance = vec3( 0.0 ); vec3 clearcoatRadiance = vec3( 0.0 ); #endif`,TP=`#if defined( RE_IndirectDiffuse ) #ifdef USE_LIGHTMAP vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity; irradiance += lightMapIrradiance; #endif #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV ) iblIrradiance += getIBLIrradiance( geometry.normal ); #endif #endif #if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular ) #ifdef USE_ANISOTROPY radiance += getIBLAnisotropyRadiance( geometry.viewDir, geometry.normal, material.roughness, material.anisotropyB, material.anisotropy ); #else radiance += getIBLRadiance( geometry.viewDir, geometry.normal, material.roughness ); #endif #ifdef USE_CLEARCOAT clearcoatRadiance += getIBLRadiance( geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness ); #endif #endif`,AP=`#if defined( RE_IndirectDiffuse ) RE_IndirectDiffuse( irradiance, geometry, material, reflectedLight ); #endif #if defined( RE_IndirectSpecular ) RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight ); #endif`,CP=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT ) gl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5; #endif`,RP=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT ) uniform float logDepthBufFC; varying float vFragDepth; varying float vIsPerspective; #endif`,PP=`#ifdef USE_LOGDEPTHBUF #ifdef USE_LOGDEPTHBUF_EXT varying float vFragDepth; varying float vIsPerspective; #else uniform float logDepthBufFC; #endif #endif`,LP=`#ifdef USE_LOGDEPTHBUF #ifdef USE_LOGDEPTHBUF_EXT vFragDepth = 1.0 + gl_Position.w; vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) ); #else if ( isPerspectiveMatrix( projectionMatrix ) ) { gl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0; gl_Position.z *= gl_Position.w; } #endif #endif`,IP=`#ifdef USE_MAP diffuseColor *= texture2D( map, vMapUv ); #endif`,DP=`#ifdef USE_MAP uniform sampler2D map; #endif`,UP=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP ) #if defined( USE_POINTS_UV ) vec2 uv = vUv; #else vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy; #endif #endif #ifdef USE_MAP diffuseColor *= texture2D( map, uv ); #endif #ifdef USE_ALPHAMAP diffuseColor.a *= texture2D( alphaMap, uv ).g; #endif`,OP=`#if defined( USE_POINTS_UV ) varying vec2 vUv; #else #if defined( USE_MAP ) || defined( USE_ALPHAMAP ) uniform mat3 uvTransform; #endif #endif #ifdef USE_MAP uniform sampler2D map; #endif #ifdef USE_ALPHAMAP uniform sampler2D alphaMap; #endif`,NP=`float metalnessFactor = metalness; #ifdef USE_METALNESSMAP vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv ); metalnessFactor *= texelMetalness.b; #endif`,FP=`#ifdef USE_METALNESSMAP uniform sampler2D metalnessMap; #endif`,kP=`#if defined( USE_MORPHCOLORS ) && defined( MORPHTARGETS_TEXTURE ) vColor *= morphTargetBaseInfluence; for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { #if defined( USE_COLOR_ALPHA ) if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ]; #elif defined( USE_COLOR ) if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ]; #endif } #endif`,zP=`#ifdef USE_MORPHNORMALS objectNormal *= morphTargetBaseInfluence; #ifdef MORPHTARGETS_TEXTURE for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ]; } #else objectNormal += morphNormal0 * morphTargetInfluences[ 0 ]; objectNormal += morphNormal1 * morphTargetInfluences[ 1 ]; objectNormal += morphNormal2 * morphTargetInfluences[ 2 ]; objectNormal += morphNormal3 * morphTargetInfluences[ 3 ]; #endif #endif`,BP=`#ifdef USE_MORPHTARGETS uniform float morphTargetBaseInfluence; #ifdef MORPHTARGETS_TEXTURE uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ]; uniform sampler2DArray morphTargetsTexture; uniform ivec2 morphTargetsTextureSize; vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) { int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset; int y = texelIndex / morphTargetsTextureSize.x; int x = texelIndex - y * morphTargetsTextureSize.x; ivec3 morphUV = ivec3( x, y, morphTargetIndex ); return texelFetch( morphTargetsTexture, morphUV, 0 ); } #else #ifndef USE_MORPHNORMALS uniform float morphTargetInfluences[ 8 ]; #else uniform float morphTargetInfluences[ 4 ]; #endif #endif #endif`,GP=`#ifdef USE_MORPHTARGETS transformed *= morphTargetBaseInfluence; #ifdef MORPHTARGETS_TEXTURE for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ]; } #else transformed += morphTarget0 * morphTargetInfluences[ 0 ]; transformed += morphTarget1 * morphTargetInfluences[ 1 ]; transformed += morphTarget2 * morphTargetInfluences[ 2 ]; transformed += morphTarget3 * morphTargetInfluences[ 3 ]; #ifndef USE_MORPHNORMALS transformed += morphTarget4 * morphTargetInfluences[ 4 ]; transformed += morphTarget5 * morphTargetInfluences[ 5 ]; transformed += morphTarget6 * morphTargetInfluences[ 6 ]; transformed += morphTarget7 * morphTargetInfluences[ 7 ]; #endif #endif #endif`,HP=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0; #ifdef FLAT_SHADED vec3 fdx = dFdx( vViewPosition ); vec3 fdy = dFdy( vViewPosition ); vec3 normal = normalize( cross( fdx, fdy ) ); #else vec3 normal = normalize( vNormal ); #ifdef DOUBLE_SIDED normal *= faceDirection; #endif #endif #if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) #ifdef USE_TANGENT mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal ); #else mat3 tbn = getTangentFrame( - vViewPosition, normal, #if defined( USE_NORMALMAP ) vNormalMapUv #elif defined( USE_CLEARCOAT_NORMALMAP ) vClearcoatNormalMapUv #else vUv #endif ); #endif #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED ) tbn[0] *= faceDirection; tbn[1] *= faceDirection; #endif #endif #ifdef USE_CLEARCOAT_NORMALMAP #ifdef USE_TANGENT mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal ); #else mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv ); #endif #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED ) tbn2[0] *= faceDirection; tbn2[1] *= faceDirection; #endif #endif vec3 geometryNormal = normal;`,VP=`#ifdef USE_NORMALMAP_OBJECTSPACE normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0; #ifdef FLIP_SIDED normal = - normal; #endif #ifdef DOUBLE_SIDED normal = normal * faceDirection; #endif normal = normalize( normalMatrix * normal ); #elif defined( USE_NORMALMAP_TANGENTSPACE ) vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0; mapN.xy *= normalScale; normal = normalize( tbn * mapN ); #elif defined( USE_BUMPMAP ) normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection ); #endif`,WP=`#ifndef FLAT_SHADED varying vec3 vNormal; #ifdef USE_TANGENT varying vec3 vTangent; varying vec3 vBitangent; #endif #endif`,XP=`#ifndef FLAT_SHADED varying vec3 vNormal; #ifdef USE_TANGENT varying vec3 vTangent; varying vec3 vBitangent; #endif #endif`,jP=`#ifndef FLAT_SHADED vNormal = normalize( transformedNormal ); #ifdef USE_TANGENT vTangent = normalize( transformedTangent ); vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w ); #endif #endif`,YP=`#ifdef USE_NORMALMAP uniform sampler2D normalMap; uniform vec2 normalScale; #endif #ifdef USE_NORMALMAP_OBJECTSPACE uniform mat3 normalMatrix; #endif #if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) ) mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) { vec3 q0 = dFdx( eye_pos.xyz ); vec3 q1 = dFdy( eye_pos.xyz ); vec2 st0 = dFdx( uv.st ); vec2 st1 = dFdy( uv.st ); vec3 N = surf_norm; vec3 q1perp = cross( q1, N ); vec3 q0perp = cross( N, q0 ); vec3 T = q1perp * st0.x + q0perp * st1.x; vec3 B = q1perp * st0.y + q0perp * st1.y; float det = max( dot( T, T ), dot( B, B ) ); float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det ); return mat3( T * scale, B * scale, N ); } #endif`,qP=`#ifdef USE_CLEARCOAT vec3 clearcoatNormal = geometryNormal; #endif`,ZP=`#ifdef USE_CLEARCOAT_NORMALMAP vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0; clearcoatMapN.xy *= clearcoatNormalScale; clearcoatNormal = normalize( tbn2 * clearcoatMapN ); #endif`,KP=`#ifdef USE_CLEARCOATMAP uniform sampler2D clearcoatMap; #endif #ifdef USE_CLEARCOAT_NORMALMAP uniform sampler2D clearcoatNormalMap; uniform vec2 clearcoatNormalScale; #endif #ifdef USE_CLEARCOAT_ROUGHNESSMAP uniform sampler2D clearcoatRoughnessMap; #endif`,$P=`#ifdef USE_IRIDESCENCEMAP uniform sampler2D iridescenceMap; #endif #ifdef USE_IRIDESCENCE_THICKNESSMAP uniform sampler2D iridescenceThicknessMap; #endif`,JP=`#ifdef OPAQUE diffuseColor.a = 1.0; #endif #ifdef USE_TRANSMISSION diffuseColor.a *= material.transmissionAlpha; #endif gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,QP=`vec3 packNormalToRGB( const in vec3 normal ) { return normalize( normal ) * 0.5 + 0.5; } vec3 unpackRGBToNormal( const in vec3 rgb ) { return 2.0 * rgb.xyz - 1.0; } const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.; const vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. ); const vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. ); const float ShiftRight8 = 1. / 256.; vec4 packDepthToRGBA( const in float v ) { vec4 r = vec4( fract( v * PackFactors ), v ); r.yzw -= r.xyz * ShiftRight8; return r * PackUpscale; } float unpackRGBAToDepth( const in vec4 v ) { return dot( v, UnpackFactors ); } vec2 packDepthToRG( in highp float v ) { return packDepthToRGBA( v ).yx; } float unpackRGToDepth( const in highp vec2 v ) { return unpackRGBAToDepth( vec4( v.xy, 0.0, 0.0 ) ); } vec4 pack2HalfToRGBA( vec2 v ) { vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) ); return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w ); } vec2 unpackRGBATo2Half( vec4 v ) { return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) ); } float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) { return ( viewZ + near ) / ( near - far ); } float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) { return depth * ( near - far ) - near; } float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) { return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ ); } float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) { return ( near * far ) / ( ( far - near ) * depth - far ); }`,eL=`#ifdef PREMULTIPLIED_ALPHA gl_FragColor.rgb *= gl_FragColor.a; #endif`,tL=`vec4 mvPosition = vec4( transformed, 1.0 ); #ifdef USE_INSTANCING mvPosition = instanceMatrix * mvPosition; #endif mvPosition = modelViewMatrix * mvPosition; gl_Position = projectionMatrix * mvPosition;`,nL=`#ifdef DITHERING gl_FragColor.rgb = dithering( gl_FragColor.rgb ); #endif`,iL=`#ifdef DITHERING vec3 dithering( vec3 color ) { float grid_position = rand( gl_FragCoord.xy ); vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 ); dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position ); return color + dither_shift_RGB; } #endif`,rL=`float roughnessFactor = roughness; #ifdef USE_ROUGHNESSMAP vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv ); roughnessFactor *= texelRoughness.g; #endif`,sL=`#ifdef USE_ROUGHNESSMAP uniform sampler2D roughnessMap; #endif`,oL=`#if NUM_SPOT_LIGHT_COORDS > 0 varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; #endif #if NUM_SPOT_LIGHT_MAPS > 0 uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ]; #endif #ifdef USE_SHADOWMAP #if NUM_DIR_LIGHT_SHADOWS > 0 uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ]; varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; struct DirectionalLightShadow { float shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; }; uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; #endif #if NUM_SPOT_LIGHT_SHADOWS > 0 uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ]; struct SpotLightShadow { float shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; }; uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; #endif #if NUM_POINT_LIGHT_SHADOWS > 0 uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ]; varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; struct PointLightShadow { float shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; float shadowCameraNear; float shadowCameraFar; }; uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; #endif float texture2DCompare( sampler2D depths, vec2 uv, float compare ) { return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) ); } vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) { return unpackRGBATo2Half( texture2D( shadow, uv ) ); } float VSMShadow (sampler2D shadow, vec2 uv, float compare ){ float occlusion = 1.0; vec2 distribution = texture2DDistribution( shadow, uv ); float hard_shadow = step( compare , distribution.x ); if (hard_shadow != 1.0 ) { float distance = compare - distribution.x ; float variance = max( 0.00000, distribution.y * distribution.y ); float softness_probability = variance / (variance + distance * distance ); softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 ); } return occlusion; } float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) { float shadow = 1.0; shadowCoord.xyz /= shadowCoord.w; shadowCoord.z += shadowBias; bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; bool frustumTest = inFrustum && shadowCoord.z <= 1.0; if ( frustumTest ) { #if defined( SHADOWMAP_TYPE_PCF ) vec2 texelSize = vec2( 1.0 ) / shadowMapSize; float dx0 = - texelSize.x * shadowRadius; float dy0 = - texelSize.y * shadowRadius; float dx1 = + texelSize.x * shadowRadius; float dy1 = + texelSize.y * shadowRadius; float dx2 = dx0 / 2.0; float dy2 = dy0 / 2.0; float dx3 = dx1 / 2.0; float dy3 = dy1 / 2.0; shadow = ( texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z ) ) * ( 1.0 / 17.0 ); #elif defined( SHADOWMAP_TYPE_PCF_SOFT ) vec2 texelSize = vec2( 1.0 ) / shadowMapSize; float dx = texelSize.x; float dy = texelSize.y; vec2 uv = shadowCoord.xy; vec2 f = fract( uv * shadowMapSize + 0.5 ); uv -= f * texelSize; shadow = ( texture2DCompare( shadowMap, uv, shadowCoord.z ) + texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) + texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) + texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) + mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ), f.x ) + mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ), f.x ) + mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ), f.y ) + mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ), f.y ) + mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ), f.x ), mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ), f.x ), f.y ) ) * ( 1.0 / 9.0 ); #elif defined( SHADOWMAP_TYPE_VSM ) shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z ); #else shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ); #endif } return shadow; } vec2 cubeToUV( vec3 v, float texelSizeY ) { vec3 absV = abs( v ); float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) ); absV *= scaleToCube; v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY ); vec2 planar = v.xy; float almostATexel = 1.5 * texelSizeY; float almostOne = 1.0 - almostATexel; if ( absV.z >= almostOne ) { if ( v.z > 0.0 ) planar.x = 4.0 - v.x; } else if ( absV.x >= almostOne ) { float signX = sign( v.x ); planar.x = v.z * signX + 2.0 * signX; } else if ( absV.y >= almostOne ) { float signY = sign( v.y ); planar.x = v.x + 2.0 * signY + 2.0; planar.y = v.z * signY - 2.0; } return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 ); } float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) { vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) ); vec3 lightToPosition = shadowCoord.xyz; float dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias; vec3 bd3D = normalize( lightToPosition ); #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM ) vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y; return ( texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp ) ) * ( 1.0 / 9.0 ); #else return texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ); #endif } #endif`,aL=`#if NUM_SPOT_LIGHT_COORDS > 0 uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ]; varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; #endif #ifdef USE_SHADOWMAP #if NUM_DIR_LIGHT_SHADOWS > 0 uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ]; varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; struct DirectionalLightShadow { float shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; }; uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; #endif #if NUM_SPOT_LIGHT_SHADOWS > 0 struct SpotLightShadow { float shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; }; uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; #endif #if NUM_POINT_LIGHT_SHADOWS > 0 uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ]; varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; struct PointLightShadow { float shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; float shadowCameraNear; float shadowCameraFar; }; uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; #endif #endif`,lL=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 ) vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix ); vec4 shadowWorldPosition; #endif #if defined( USE_SHADOWMAP ) #if NUM_DIR_LIGHT_SHADOWS > 0 #pragma unroll_loop_start for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 ); vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition; } #pragma unroll_loop_end #endif #if NUM_POINT_LIGHT_SHADOWS > 0 #pragma unroll_loop_start for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 ); vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition; } #pragma unroll_loop_end #endif #endif #if NUM_SPOT_LIGHT_COORDS > 0 #pragma unroll_loop_start for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) { shadowWorldPosition = worldPosition; #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias; #endif vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition; } #pragma unroll_loop_end #endif`,cL=`float getShadowMask() { float shadow = 1.0; #ifdef USE_SHADOWMAP #if NUM_DIR_LIGHT_SHADOWS > 0 DirectionalLightShadow directionalLight; #pragma unroll_loop_start for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { directionalLight = directionalLightShadows[ i ]; shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; } #pragma unroll_loop_end #endif #if NUM_SPOT_LIGHT_SHADOWS > 0 SpotLightShadow spotLight; #pragma unroll_loop_start for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) { spotLight = spotLightShadows[ i ]; shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; } #pragma unroll_loop_end #endif #if NUM_POINT_LIGHT_SHADOWS > 0 PointLightShadow pointLight; #pragma unroll_loop_start for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { pointLight = pointLightShadows[ i ]; shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0; } #pragma unroll_loop_end #endif #endif return shadow; }`,uL=`#ifdef USE_SKINNING mat4 boneMatX = getBoneMatrix( skinIndex.x ); mat4 boneMatY = getBoneMatrix( skinIndex.y ); mat4 boneMatZ = getBoneMatrix( skinIndex.z ); mat4 boneMatW = getBoneMatrix( skinIndex.w ); #endif`,hL=`#ifdef USE_SKINNING uniform mat4 bindMatrix; uniform mat4 bindMatrixInverse; uniform highp sampler2D boneTexture; uniform int boneTextureSize; mat4 getBoneMatrix( const in float i ) { float j = i * 4.0; float x = mod( j, float( boneTextureSize ) ); float y = floor( j / float( boneTextureSize ) ); float dx = 1.0 / float( boneTextureSize ); float dy = 1.0 / float( boneTextureSize ); y = dy * ( y + 0.5 ); vec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) ); vec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) ); vec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) ); vec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) ); mat4 bone = mat4( v1, v2, v3, v4 ); return bone; } #endif`,fL=`#ifdef USE_SKINNING vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 ); vec4 skinned = vec4( 0.0 ); skinned += boneMatX * skinVertex * skinWeight.x; skinned += boneMatY * skinVertex * skinWeight.y; skinned += boneMatZ * skinVertex * skinWeight.z; skinned += boneMatW * skinVertex * skinWeight.w; transformed = ( bindMatrixInverse * skinned ).xyz; #endif`,dL=`#ifdef USE_SKINNING mat4 skinMatrix = mat4( 0.0 ); skinMatrix += skinWeight.x * boneMatX; skinMatrix += skinWeight.y * boneMatY; skinMatrix += skinWeight.z * boneMatZ; skinMatrix += skinWeight.w * boneMatW; skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix; objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz; #ifdef USE_TANGENT objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz; #endif #endif`,pL=`float specularStrength; #ifdef USE_SPECULARMAP vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv ); specularStrength = texelSpecular.r; #else specularStrength = 1.0; #endif`,mL=`#ifdef USE_SPECULARMAP uniform sampler2D specularMap; #endif`,gL=`#if defined( TONE_MAPPING ) gl_FragColor.rgb = toneMapping( gl_FragColor.rgb ); #endif`,vL=`#ifndef saturate #define saturate( a ) clamp( a, 0.0, 1.0 ) #endif uniform float toneMappingExposure; vec3 LinearToneMapping( vec3 color ) { return saturate( toneMappingExposure * color ); } vec3 ReinhardToneMapping( vec3 color ) { color *= toneMappingExposure; return saturate( color / ( vec3( 1.0 ) + color ) ); } vec3 OptimizedCineonToneMapping( vec3 color ) { color *= toneMappingExposure; color = max( vec3( 0.0 ), color - 0.004 ); return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) ); } vec3 RRTAndODTFit( vec3 v ) { vec3 a = v * ( v + 0.0245786 ) - 0.000090537; vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081; return a / b; } vec3 ACESFilmicToneMapping( vec3 color ) { const mat3 ACESInputMat = mat3( vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ), vec3( 0.04823, 0.01566, 0.83777 ) ); const mat3 ACESOutputMat = mat3( vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ), vec3( -0.07367, -0.00605, 1.07602 ) ); color *= toneMappingExposure / 0.6; color = ACESInputMat * color; color = RRTAndODTFit( color ); color = ACESOutputMat * color; return saturate( color ); } vec3 CustomToneMapping( vec3 color ) { return color; }`,yL=`#ifdef USE_TRANSMISSION material.transmission = transmission; material.transmissionAlpha = 1.0; material.thickness = thickness; material.attenuationDistance = attenuationDistance; material.attenuationColor = attenuationColor; #ifdef USE_TRANSMISSIONMAP material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r; #endif #ifdef USE_THICKNESSMAP material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g; #endif vec3 pos = vWorldPosition; vec3 v = normalize( cameraPosition - pos ); vec3 n = inverseTransformDirection( normal, viewMatrix ); vec4 transmitted = getIBLVolumeRefraction( n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90, pos, modelMatrix, viewMatrix, projectionMatrix, material.ior, material.thickness, material.attenuationColor, material.attenuationDistance ); material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission ); totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission ); #endif`,_L=`#ifdef USE_TRANSMISSION uniform float transmission; uniform float thickness; uniform float attenuationDistance; uniform vec3 attenuationColor; #ifdef USE_TRANSMISSIONMAP uniform sampler2D transmissionMap; #endif #ifdef USE_THICKNESSMAP uniform sampler2D thicknessMap; #endif uniform vec2 transmissionSamplerSize; uniform sampler2D transmissionSamplerMap; uniform mat4 modelMatrix; uniform mat4 projectionMatrix; varying vec3 vWorldPosition; float w0( float a ) { return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 ); } float w1( float a ) { return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 ); } float w2( float a ){ return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 ); } float w3( float a ) { return ( 1.0 / 6.0 ) * ( a * a * a ); } float g0( float a ) { return w0( a ) + w1( a ); } float g1( float a ) { return w2( a ) + w3( a ); } float h0( float a ) { return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) ); } float h1( float a ) { return 1.0 + w3( a ) / ( w2( a ) + w3( a ) ); } vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) { uv = uv * texelSize.zw + 0.5; vec2 iuv = floor( uv ); vec2 fuv = fract( uv ); float g0x = g0( fuv.x ); float g1x = g1( fuv.x ); float h0x = h0( fuv.x ); float h1x = h1( fuv.x ); float h0y = h0( fuv.y ); float h1y = h1( fuv.y ); vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy; vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy; vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy; vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy; return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) + g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) ); } vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) { vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) ); vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) ); vec2 fLodSizeInv = 1.0 / fLodSize; vec2 cLodSizeInv = 1.0 / cLodSize; vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) ); vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) ); return mix( fSample, cSample, fract( lod ) ); } vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) { vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior ); vec3 modelScale; modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) ); modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) ); modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) ); return normalize( refractionVector ) * thickness * modelScale; } float applyIorToRoughness( const in float roughness, const in float ior ) { return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 ); } vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) { float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior ); return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod ); } vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) { if ( isinf( attenuationDistance ) ) { return vec3( 1.0 ); } else { vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance; vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance; } } vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor, const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix, const in mat4 viewMatrix, const in mat4 projMatrix, const in float ior, const in float thickness, const in vec3 attenuationColor, const in float attenuationDistance ) { vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix ); vec3 refractedRayExit = position + transmissionRay; vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 ); vec2 refractionCoords = ndcPos.xy / ndcPos.w; refractionCoords += 1.0; refractionCoords /= 2.0; vec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior ); vec3 transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance ); vec3 attenuatedColor = transmittance * transmittedLight.rgb; vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness ); float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0; return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor ); } #endif`,xL=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) varying vec2 vUv; #endif #ifdef USE_MAP varying vec2 vMapUv; #endif #ifdef USE_ALPHAMAP varying vec2 vAlphaMapUv; #endif #ifdef USE_LIGHTMAP varying vec2 vLightMapUv; #endif #ifdef USE_AOMAP varying vec2 vAoMapUv; #endif #ifdef USE_BUMPMAP varying vec2 vBumpMapUv; #endif #ifdef USE_NORMALMAP varying vec2 vNormalMapUv; #endif #ifdef USE_EMISSIVEMAP varying vec2 vEmissiveMapUv; #endif #ifdef USE_METALNESSMAP varying vec2 vMetalnessMapUv; #endif #ifdef USE_ROUGHNESSMAP varying vec2 vRoughnessMapUv; #endif #ifdef USE_ANISOTROPYMAP varying vec2 vAnisotropyMapUv; #endif #ifdef USE_CLEARCOATMAP varying vec2 vClearcoatMapUv; #endif #ifdef USE_CLEARCOAT_NORMALMAP varying vec2 vClearcoatNormalMapUv; #endif #ifdef USE_CLEARCOAT_ROUGHNESSMAP varying vec2 vClearcoatRoughnessMapUv; #endif #ifdef USE_IRIDESCENCEMAP varying vec2 vIridescenceMapUv; #endif #ifdef USE_IRIDESCENCE_THICKNESSMAP varying vec2 vIridescenceThicknessMapUv; #endif #ifdef USE_SHEEN_COLORMAP varying vec2 vSheenColorMapUv; #endif #ifdef USE_SHEEN_ROUGHNESSMAP varying vec2 vSheenRoughnessMapUv; #endif #ifdef USE_SPECULARMAP varying vec2 vSpecularMapUv; #endif #ifdef USE_SPECULAR_COLORMAP varying vec2 vSpecularColorMapUv; #endif #ifdef USE_SPECULAR_INTENSITYMAP varying vec2 vSpecularIntensityMapUv; #endif #ifdef USE_TRANSMISSIONMAP uniform mat3 transmissionMapTransform; varying vec2 vTransmissionMapUv; #endif #ifdef USE_THICKNESSMAP uniform mat3 thicknessMapTransform; varying vec2 vThicknessMapUv; #endif`,wL=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) varying vec2 vUv; #endif #ifdef USE_MAP uniform mat3 mapTransform; varying vec2 vMapUv; #endif #ifdef USE_ALPHAMAP uniform mat3 alphaMapTransform; varying vec2 vAlphaMapUv; #endif #ifdef USE_LIGHTMAP uniform mat3 lightMapTransform; varying vec2 vLightMapUv; #endif #ifdef USE_AOMAP uniform mat3 aoMapTransform; varying vec2 vAoMapUv; #endif #ifdef USE_BUMPMAP uniform mat3 bumpMapTransform; varying vec2 vBumpMapUv; #endif #ifdef USE_NORMALMAP uniform mat3 normalMapTransform; varying vec2 vNormalMapUv; #endif #ifdef USE_DISPLACEMENTMAP uniform mat3 displacementMapTransform; varying vec2 vDisplacementMapUv; #endif #ifdef USE_EMISSIVEMAP uniform mat3 emissiveMapTransform; varying vec2 vEmissiveMapUv; #endif #ifdef USE_METALNESSMAP uniform mat3 metalnessMapTransform; varying vec2 vMetalnessMapUv; #endif #ifdef USE_ROUGHNESSMAP uniform mat3 roughnessMapTransform; varying vec2 vRoughnessMapUv; #endif #ifdef USE_ANISOTROPYMAP uniform mat3 anisotropyMapTransform; varying vec2 vAnisotropyMapUv; #endif #ifdef USE_CLEARCOATMAP uniform mat3 clearcoatMapTransform; varying vec2 vClearcoatMapUv; #endif #ifdef USE_CLEARCOAT_NORMALMAP uniform mat3 clearcoatNormalMapTransform; varying vec2 vClearcoatNormalMapUv; #endif #ifdef USE_CLEARCOAT_ROUGHNESSMAP uniform mat3 clearcoatRoughnessMapTransform; varying vec2 vClearcoatRoughnessMapUv; #endif #ifdef USE_SHEEN_COLORMAP uniform mat3 sheenColorMapTransform; varying vec2 vSheenColorMapUv; #endif #ifdef USE_SHEEN_ROUGHNESSMAP uniform mat3 sheenRoughnessMapTransform; varying vec2 vSheenRoughnessMapUv; #endif #ifdef USE_IRIDESCENCEMAP uniform mat3 iridescenceMapTransform; varying vec2 vIridescenceMapUv; #endif #ifdef USE_IRIDESCENCE_THICKNESSMAP uniform mat3 iridescenceThicknessMapTransform; varying vec2 vIridescenceThicknessMapUv; #endif #ifdef USE_SPECULARMAP uniform mat3 specularMapTransform; varying vec2 vSpecularMapUv; #endif #ifdef USE_SPECULAR_COLORMAP uniform mat3 specularColorMapTransform; varying vec2 vSpecularColorMapUv; #endif #ifdef USE_SPECULAR_INTENSITYMAP uniform mat3 specularIntensityMapTransform; varying vec2 vSpecularIntensityMapUv; #endif #ifdef USE_TRANSMISSIONMAP uniform mat3 transmissionMapTransform; varying vec2 vTransmissionMapUv; #endif #ifdef USE_THICKNESSMAP uniform mat3 thicknessMapTransform; varying vec2 vThicknessMapUv; #endif`,SL=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) vUv = vec3( uv, 1 ).xy; #endif #ifdef USE_MAP vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy; #endif #ifdef USE_ALPHAMAP vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy; #endif #ifdef USE_LIGHTMAP vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy; #endif #ifdef USE_AOMAP vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy; #endif #ifdef USE_BUMPMAP vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy; #endif #ifdef USE_NORMALMAP vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy; #endif #ifdef USE_DISPLACEMENTMAP vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy; #endif #ifdef USE_EMISSIVEMAP vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy; #endif #ifdef USE_METALNESSMAP vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy; #endif #ifdef USE_ROUGHNESSMAP vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy; #endif #ifdef USE_ANISOTROPYMAP vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy; #endif #ifdef USE_CLEARCOATMAP vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy; #endif #ifdef USE_CLEARCOAT_NORMALMAP vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy; #endif #ifdef USE_CLEARCOAT_ROUGHNESSMAP vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy; #endif #ifdef USE_IRIDESCENCEMAP vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy; #endif #ifdef USE_IRIDESCENCE_THICKNESSMAP vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy; #endif #ifdef USE_SHEEN_COLORMAP vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy; #endif #ifdef USE_SHEEN_ROUGHNESSMAP vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy; #endif #ifdef USE_SPECULARMAP vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy; #endif #ifdef USE_SPECULAR_COLORMAP vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy; #endif #ifdef USE_SPECULAR_INTENSITYMAP vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy; #endif #ifdef USE_TRANSMISSIONMAP vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy; #endif #ifdef USE_THICKNESSMAP vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy; #endif`,EL=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0 vec4 worldPosition = vec4( transformed, 1.0 ); #ifdef USE_INSTANCING worldPosition = instanceMatrix * worldPosition; #endif worldPosition = modelMatrix * worldPosition; #endif`;const bL=`varying vec2 vUv; uniform mat3 uvTransform; void main() { vUv = ( uvTransform * vec3( uv, 1 ) ).xy; gl_Position = vec4( position.xy, 1.0, 1.0 ); }`,ML=`uniform sampler2D t2D; uniform float backgroundIntensity; varying vec2 vUv; void main() { vec4 texColor = texture2D( t2D, vUv ); texColor.rgb *= backgroundIntensity; gl_FragColor = texColor; #include #include }`,TL=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include gl_Position.z = gl_Position.w; }`,AL=`#ifdef ENVMAP_TYPE_CUBE uniform samplerCube envMap; #elif defined( ENVMAP_TYPE_CUBE_UV ) uniform sampler2D envMap; #endif uniform float flipEnvMap; uniform float backgroundBlurriness; uniform float backgroundIntensity; varying vec3 vWorldDirection; #include void main() { #ifdef ENVMAP_TYPE_CUBE vec4 texColor = textureCube( envMap, vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) ); #elif defined( ENVMAP_TYPE_CUBE_UV ) vec4 texColor = textureCubeUV( envMap, vWorldDirection, backgroundBlurriness ); #else vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 ); #endif texColor.rgb *= backgroundIntensity; gl_FragColor = texColor; #include #include }`,CL=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include gl_Position.z = gl_Position.w; }`,RL=`uniform samplerCube tCube; uniform float tFlip; uniform float opacity; varying vec3 vWorldDirection; void main() { vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) ); gl_FragColor = texColor; gl_FragColor.a *= opacity; #include #include }`,PL=`#include #include #include #include #include #include #include varying vec2 vHighPrecisionZW; void main() { #include #include #ifdef USE_DISPLACEMENTMAP #include #include #include #endif #include #include #include #include #include #include #include vHighPrecisionZW = gl_Position.zw; }`,LL=`#if DEPTH_PACKING == 3200 uniform float opacity; #endif #include #include #include #include #include #include #include #include #include varying vec2 vHighPrecisionZW; void main() { #include vec4 diffuseColor = vec4( 1.0 ); #if DEPTH_PACKING == 3200 diffuseColor.a = opacity; #endif #include #include #include #include #include float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5; #if DEPTH_PACKING == 3200 gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity ); #elif DEPTH_PACKING == 3201 gl_FragColor = packDepthToRGBA( fragCoordZ ); #endif }`,IL=`#define DISTANCE varying vec3 vWorldPosition; #include #include #include #include #include #include void main() { #include #include #ifdef USE_DISPLACEMENTMAP #include #include #include #endif #include #include #include #include #include #include #include vWorldPosition = worldPosition.xyz; }`,DL=`#define DISTANCE uniform vec3 referencePosition; uniform float nearDistance; uniform float farDistance; varying vec3 vWorldPosition; #include #include #include #include #include #include #include #include void main () { #include vec4 diffuseColor = vec4( 1.0 ); #include #include #include #include float dist = length( vWorldPosition - referencePosition ); dist = ( dist - nearDistance ) / ( farDistance - nearDistance ); dist = saturate( dist ); gl_FragColor = packDepthToRGBA( dist ); }`,UL=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include }`,OL=`uniform sampler2D tEquirect; varying vec3 vWorldDirection; #include void main() { vec3 direction = normalize( vWorldDirection ); vec2 sampleUV = equirectUv( direction ); gl_FragColor = texture2D( tEquirect, sampleUV ); #include #include }`,NL=`uniform float scale; attribute float lineDistance; varying float vLineDistance; #include #include #include #include #include #include #include void main() { vLineDistance = scale * lineDistance; #include #include #include #include #include #include #include #include #include }`,FL=`uniform vec3 diffuse; uniform float opacity; uniform float dashSize; uniform float totalSize; varying float vLineDistance; #include #include #include #include #include #include #include void main() { #include if ( mod( vLineDistance, totalSize ) > dashSize ) { discard; } vec3 outgoingLight = vec3( 0.0 ); vec4 diffuseColor = vec4( diffuse, opacity ); #include #include #include outgoingLight = diffuseColor.rgb; #include #include #include #include #include }`,kL=`#include #include #include #include #include #include #include #include #include void main() { #include #include #include #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING ) #include #include #include #include #include #endif #include #include #include #include #include #include #include #include #include }`,zL=`uniform vec3 diffuse; uniform float opacity; #ifndef FLAT_SHADED varying vec3 vNormal; #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include vec4 diffuseColor = vec4( diffuse, opacity ); #include #include #include #include #include #include #include ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); #ifdef USE_LIGHTMAP vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI; #else reflectedLight.indirectDiffuse += vec3( 1.0 ); #endif #include reflectedLight.indirectDiffuse *= diffuseColor.rgb; vec3 outgoingLight = reflectedLight.indirectDiffuse; #include #include #include #include #include #include #include }`,BL=`#define LAMBERT varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; #include #include #include #include }`,GL=`#define LAMBERT uniform vec3 diffuse; uniform vec3 emissive; uniform float opacity; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include vec4 diffuseColor = vec4( diffuse, opacity ); ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); vec3 totalEmissiveRadiance = emissive; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; #include #include #include #include #include #include #include }`,HL=`#define MATCAP varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; }`,VL=`#define MATCAP uniform vec3 diffuse; uniform float opacity; uniform sampler2D matcap; varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include vec4 diffuseColor = vec4( diffuse, opacity ); #include #include #include #include #include #include #include #include vec3 viewDir = normalize( vViewPosition ); vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) ); vec3 y = cross( viewDir, x ); vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5; #ifdef USE_MATCAP vec4 matcapColor = texture2D( matcap, uv ); #else vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 ); #endif vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb; #include #include #include #include #include #include }`,WL=`#define NORMAL #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) varying vec3 vViewPosition; #endif #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) vViewPosition = - mvPosition.xyz; #endif }`,XL=`#define NORMAL uniform float opacity; #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) varying vec3 vViewPosition; #endif #include #include #include #include #include #include #include void main() { #include #include #include #include gl_FragColor = vec4( packNormalToRGB( normal ), opacity ); #ifdef OPAQUE gl_FragColor.a = 1.0; #endif }`,jL=`#define PHONG varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; #include #include #include #include }`,YL=`#define PHONG uniform vec3 diffuse; uniform vec3 emissive; uniform vec3 specular; uniform float shininess; uniform float opacity; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include vec4 diffuseColor = vec4( diffuse, opacity ); ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); vec3 totalEmissiveRadiance = emissive; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance; #include #include #include #include #include #include #include }`,qL=`#define STANDARD varying vec3 vViewPosition; #ifdef USE_TRANSMISSION varying vec3 vWorldPosition; #endif #include #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; #include #include #include #ifdef USE_TRANSMISSION vWorldPosition = worldPosition.xyz; #endif }`,ZL=`#define STANDARD #ifdef PHYSICAL #define IOR #define USE_SPECULAR #endif uniform vec3 diffuse; uniform vec3 emissive; uniform float roughness; uniform float metalness; uniform float opacity; #ifdef IOR uniform float ior; #endif #ifdef USE_SPECULAR uniform float specularIntensity; uniform vec3 specularColor; #ifdef USE_SPECULAR_COLORMAP uniform sampler2D specularColorMap; #endif #ifdef USE_SPECULAR_INTENSITYMAP uniform sampler2D specularIntensityMap; #endif #endif #ifdef USE_CLEARCOAT uniform float clearcoat; uniform float clearcoatRoughness; #endif #ifdef USE_IRIDESCENCE uniform float iridescence; uniform float iridescenceIOR; uniform float iridescenceThicknessMinimum; uniform float iridescenceThicknessMaximum; #endif #ifdef USE_SHEEN uniform vec3 sheenColor; uniform float sheenRoughness; #ifdef USE_SHEEN_COLORMAP uniform sampler2D sheenColorMap; #endif #ifdef USE_SHEEN_ROUGHNESSMAP uniform sampler2D sheenRoughnessMap; #endif #endif #ifdef USE_ANISOTROPY uniform vec2 anisotropyVector; #ifdef USE_ANISOTROPYMAP uniform sampler2D anisotropyMap; #endif #endif varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include vec4 diffuseColor = vec4( diffuse, opacity ); ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); vec3 totalEmissiveRadiance = emissive; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse; vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular; #include vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance; #ifdef USE_SHEEN float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor ); outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecular; #endif #ifdef USE_CLEARCOAT float dotNVcc = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) ); vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc ); outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + clearcoatSpecular * material.clearcoat; #endif #include #include #include #include #include #include }`,KL=`#define TOON varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; #include #include #include }`,$L=`#define TOON uniform vec3 diffuse; uniform vec3 emissive; uniform float opacity; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include vec4 diffuseColor = vec4( diffuse, opacity ); ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); vec3 totalEmissiveRadiance = emissive; #include #include #include #include #include #include #include #include #include #include #include #include #include #include vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; #include #include #include #include #include #include }`,JL=`uniform float size; uniform float scale; #include #include #include #include #include #include #ifdef USE_POINTS_UV varying vec2 vUv; uniform mat3 uvTransform; #endif void main() { #ifdef USE_POINTS_UV vUv = ( uvTransform * vec3( uv, 1 ) ).xy; #endif #include #include #include #include #include gl_PointSize = size; #ifdef USE_SIZEATTENUATION bool isPerspective = isPerspectiveMatrix( projectionMatrix ); if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z ); #endif #include #include #include #include }`,QL=`uniform vec3 diffuse; uniform float opacity; #include #include #include #include #include #include #include #include void main() { #include vec3 outgoingLight = vec3( 0.0 ); vec4 diffuseColor = vec4( diffuse, opacity ); #include #include #include #include #include outgoingLight = diffuseColor.rgb; #include #include #include #include #include }`,eI=`#include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include }`,tI=`uniform vec3 color; uniform float opacity; #include #include #include #include #include #include #include #include void main() { #include gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) ); #include #include #include }`,nI=`uniform float rotation; uniform vec2 center; #include #include #include #include #include void main() { #include vec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 ); vec2 scale; scale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) ); scale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) ); #ifndef USE_SIZEATTENUATION bool isPerspective = isPerspectiveMatrix( projectionMatrix ); if ( isPerspective ) scale *= - mvPosition.z; #endif vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale; vec2 rotatedPosition; rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y; rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y; mvPosition.xy += rotatedPosition; gl_Position = projectionMatrix * mvPosition; #include #include #include }`,iI=`uniform vec3 diffuse; uniform float opacity; #include #include #include #include #include #include #include #include #include void main() { #include vec3 outgoingLight = vec3( 0.0 ); vec4 diffuseColor = vec4( diffuse, opacity ); #include #include #include #include #include outgoingLight = diffuseColor.rgb; #include #include #include #include }`,bt={alphahash_fragment:AR,alphahash_pars_fragment:CR,alphamap_fragment:RR,alphamap_pars_fragment:PR,alphatest_fragment:LR,alphatest_pars_fragment:IR,aomap_fragment:DR,aomap_pars_fragment:UR,begin_vertex:OR,beginnormal_vertex:NR,bsdfs:FR,iridescence_fragment:kR,bumpmap_pars_fragment:zR,clipping_planes_fragment:BR,clipping_planes_pars_fragment:GR,clipping_planes_pars_vertex:HR,clipping_planes_vertex:VR,color_fragment:WR,color_pars_fragment:XR,color_pars_vertex:jR,color_vertex:YR,common:qR,cube_uv_reflection_fragment:ZR,defaultnormal_vertex:KR,displacementmap_pars_vertex:$R,displacementmap_vertex:JR,emissivemap_fragment:QR,emissivemap_pars_fragment:eP,colorspace_fragment:tP,colorspace_pars_fragment:nP,envmap_fragment:iP,envmap_common_pars_fragment:rP,envmap_pars_fragment:sP,envmap_pars_vertex:oP,envmap_physical_pars_fragment:yP,envmap_vertex:aP,fog_vertex:lP,fog_pars_vertex:cP,fog_fragment:uP,fog_pars_fragment:hP,gradientmap_pars_fragment:fP,lightmap_fragment:dP,lightmap_pars_fragment:pP,lights_lambert_fragment:mP,lights_lambert_pars_fragment:gP,lights_pars_begin:vP,lights_toon_fragment:_P,lights_toon_pars_fragment:xP,lights_phong_fragment:wP,lights_phong_pars_fragment:SP,lights_physical_fragment:EP,lights_physical_pars_fragment:bP,lights_fragment_begin:MP,lights_fragment_maps:TP,lights_fragment_end:AP,logdepthbuf_fragment:CP,logdepthbuf_pars_fragment:RP,logdepthbuf_pars_vertex:PP,logdepthbuf_vertex:LP,map_fragment:IP,map_pars_fragment:DP,map_particle_fragment:UP,map_particle_pars_fragment:OP,metalnessmap_fragment:NP,metalnessmap_pars_fragment:FP,morphcolor_vertex:kP,morphnormal_vertex:zP,morphtarget_pars_vertex:BP,morphtarget_vertex:GP,normal_fragment_begin:HP,normal_fragment_maps:VP,normal_pars_fragment:WP,normal_pars_vertex:XP,normal_vertex:jP,normalmap_pars_fragment:YP,clearcoat_normal_fragment_begin:qP,clearcoat_normal_fragment_maps:ZP,clearcoat_pars_fragment:KP,iridescence_pars_fragment:$P,opaque_fragment:JP,packing:QP,premultiplied_alpha_fragment:eL,project_vertex:tL,dithering_fragment:nL,dithering_pars_fragment:iL,roughnessmap_fragment:rL,roughnessmap_pars_fragment:sL,shadowmap_pars_fragment:oL,shadowmap_pars_vertex:aL,shadowmap_vertex:lL,shadowmask_pars_fragment:cL,skinbase_vertex:uL,skinning_pars_vertex:hL,skinning_vertex:fL,skinnormal_vertex:dL,specularmap_fragment:pL,specularmap_pars_fragment:mL,tonemapping_fragment:gL,tonemapping_pars_fragment:vL,transmission_fragment:yL,transmission_pars_fragment:_L,uv_pars_fragment:xL,uv_pars_vertex:wL,uv_vertex:SL,worldpos_vertex:EL,background_vert:bL,background_frag:ML,backgroundCube_vert:TL,backgroundCube_frag:AL,cube_vert:CL,cube_frag:RL,depth_vert:PL,depth_frag:LL,distanceRGBA_vert:IL,distanceRGBA_frag:DL,equirect_vert:UL,equirect_frag:OL,linedashed_vert:NL,linedashed_frag:FL,meshbasic_vert:kL,meshbasic_frag:zL,meshlambert_vert:BL,meshlambert_frag:GL,meshmatcap_vert:HL,meshmatcap_frag:VL,meshnormal_vert:WL,meshnormal_frag:XL,meshphong_vert:jL,meshphong_frag:YL,meshphysical_vert:qL,meshphysical_frag:ZL,meshtoon_vert:KL,meshtoon_frag:$L,points_vert:JL,points_frag:QL,shadow_vert:eI,shadow_frag:tI,sprite_vert:nI,sprite_frag:iI},Je={common:{diffuse:{value:new Ke(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Ct},alphaMap:{value:null},alphaMapTransform:{value:new Ct},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Ct}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Ct}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Ct}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Ct},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Ct},normalScale:{value:new De(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Ct},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Ct}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Ct}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Ct}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Ke(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 Ke(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Ct},alphaTest:{value:0},uvTransform:{value:new Ct}},sprite:{diffuse:{value:new Ke(16777215)},opacity:{value:1},center:{value:new De(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Ct},alphaMap:{value:null},alphaMapTransform:{value:new Ct},alphaTest:{value:0}}},Nr={basic:{uniforms:Ci([Je.common,Je.specularmap,Je.envmap,Je.aomap,Je.lightmap,Je.fog]),vertexShader:bt.meshbasic_vert,fragmentShader:bt.meshbasic_frag},lambert:{uniforms:Ci([Je.common,Je.specularmap,Je.envmap,Je.aomap,Je.lightmap,Je.emissivemap,Je.bumpmap,Je.normalmap,Je.displacementmap,Je.fog,Je.lights,{emissive:{value:new Ke(0)}}]),vertexShader:bt.meshlambert_vert,fragmentShader:bt.meshlambert_frag},phong:{uniforms:Ci([Je.common,Je.specularmap,Je.envmap,Je.aomap,Je.lightmap,Je.emissivemap,Je.bumpmap,Je.normalmap,Je.displacementmap,Je.fog,Je.lights,{emissive:{value:new Ke(0)},specular:{value:new Ke(1118481)},shininess:{value:30}}]),vertexShader:bt.meshphong_vert,fragmentShader:bt.meshphong_frag},standard:{uniforms:Ci([Je.common,Je.envmap,Je.aomap,Je.lightmap,Je.emissivemap,Je.bumpmap,Je.normalmap,Je.displacementmap,Je.roughnessmap,Je.metalnessmap,Je.fog,Je.lights,{emissive:{value:new Ke(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:bt.meshphysical_vert,fragmentShader:bt.meshphysical_frag},toon:{uniforms:Ci([Je.common,Je.aomap,Je.lightmap,Je.emissivemap,Je.bumpmap,Je.normalmap,Je.displacementmap,Je.gradientmap,Je.fog,Je.lights,{emissive:{value:new Ke(0)}}]),vertexShader:bt.meshtoon_vert,fragmentShader:bt.meshtoon_frag},matcap:{uniforms:Ci([Je.common,Je.bumpmap,Je.normalmap,Je.displacementmap,Je.fog,{matcap:{value:null}}]),vertexShader:bt.meshmatcap_vert,fragmentShader:bt.meshmatcap_frag},points:{uniforms:Ci([Je.points,Je.fog]),vertexShader:bt.points_vert,fragmentShader:bt.points_frag},dashed:{uniforms:Ci([Je.common,Je.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:bt.linedashed_vert,fragmentShader:bt.linedashed_frag},depth:{uniforms:Ci([Je.common,Je.displacementmap]),vertexShader:bt.depth_vert,fragmentShader:bt.depth_frag},normal:{uniforms:Ci([Je.common,Je.bumpmap,Je.normalmap,Je.displacementmap,{opacity:{value:1}}]),vertexShader:bt.meshnormal_vert,fragmentShader:bt.meshnormal_frag},sprite:{uniforms:Ci([Je.sprite,Je.fog]),vertexShader:bt.sprite_vert,fragmentShader:bt.sprite_frag},background:{uniforms:{uvTransform:{value:new Ct},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:bt.background_vert,fragmentShader:bt.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1}},vertexShader:bt.backgroundCube_vert,fragmentShader:bt.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:bt.cube_vert,fragmentShader:bt.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:bt.equirect_vert,fragmentShader:bt.equirect_frag},distanceRGBA:{uniforms:Ci([Je.common,Je.displacementmap,{referencePosition:{value:new Y},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:bt.distanceRGBA_vert,fragmentShader:bt.distanceRGBA_frag},shadow:{uniforms:Ci([Je.lights,Je.fog,{color:{value:new Ke(0)},opacity:{value:1}}]),vertexShader:bt.shadow_vert,fragmentShader:bt.shadow_frag}};Nr.physical={uniforms:Ci([Nr.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Ct},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Ct},clearcoatNormalScale:{value:new De(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Ct},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Ct},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Ct},sheen:{value:0},sheenColor:{value:new Ke(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Ct},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Ct},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Ct},transmissionSamplerSize:{value:new De},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Ct},attenuationDistance:{value:0},attenuationColor:{value:new Ke(0)},specularColor:{value:new Ke(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Ct},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Ct},anisotropyVector:{value:new De},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Ct}}]),vertexShader:bt.meshphysical_vert,fragmentShader:bt.meshphysical_frag};const Rf={r:0,b:0,g:0};function rI(r,e,t,n,i,s,o){const a=new Ke(0);let l=s===!0?0:1,c,u,h=null,p=0,m=null;function v(y,g){let x=!1,w=g.isScene===!0?g.background:null;switch(w&&w.isTexture&&(w=(g.backgroundBlurriness>0?t:e).get(w)),w===null?_(a,l):w&&w.isColor&&(_(w,1),x=!0),r.xr.getEnvironmentBlendMode()){case"opaque":x=!0;break;case"additive":n.buffers.color.setClear(0,0,0,1,o),x=!0;break;case"alpha-blend":n.buffers.color.setClear(0,0,0,0,o),x=!0;break}(r.autoClear||x)&&r.clear(r.autoClearColor,r.autoClearDepth,r.autoClearStencil),w&&(w.isCubeTexture||w.mapping===Jl)?(u===void 0&&(u=new _n(new Ws(1,1,1),new cs({name:"BackgroundCubeMaterial",uniforms:Xl(Nr.backgroundCube.uniforms),vertexShader:Nr.backgroundCube.vertexShader,fragmentShader:Nr.backgroundCube.fragmentShader,side:yi,depthTest:!1,depthWrite:!1,fog:!1})),u.geometry.deleteAttribute("normal"),u.geometry.deleteAttribute("uv"),u.onBeforeRender=function(M,A,P){this.matrixWorld.copyPosition(P.matrixWorld)},Object.defineProperty(u.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(u)),u.material.uniforms.envMap.value=w,u.material.uniforms.flipEnvMap.value=w.isCubeTexture&&w.isRenderTargetTexture===!1?-1:1,u.material.uniforms.backgroundBlurriness.value=g.backgroundBlurriness,u.material.uniforms.backgroundIntensity.value=g.backgroundIntensity,u.material.toneMapped=w.colorSpace!==Mt,(h!==w||p!==w.version||m!==r.toneMapping)&&(u.material.needsUpdate=!0,h=w,p=w.version,m=r.toneMapping),u.layers.enableAll(),y.unshift(u,u.geometry,u.material,0,0,null)):w&&w.isTexture&&(c===void 0&&(c=new _n(new To(2,2),new cs({name:"BackgroundMaterial",uniforms:Xl(Nr.background.uniforms),vertexShader:Nr.background.vertexShader,fragmentShader:Nr.background.fragmentShader,side:ls,depthTest:!1,depthWrite:!1,fog:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(c)),c.material.uniforms.t2D.value=w,c.material.uniforms.backgroundIntensity.value=g.backgroundIntensity,c.material.toneMapped=w.colorSpace!==Mt,w.matrixAutoUpdate===!0&&w.updateMatrix(),c.material.uniforms.uvTransform.value.copy(w.matrix),(h!==w||p!==w.version||m!==r.toneMapping)&&(c.material.needsUpdate=!0,h=w,p=w.version,m=r.toneMapping),c.layers.enableAll(),y.unshift(c,c.geometry,c.material,0,0,null))}function _(y,g){y.getRGB(Rf,lM(r)),n.buffers.color.setClear(Rf.r,Rf.g,Rf.b,g,o)}return{getClearColor:function(){return a},setClearColor:function(y,g=1){a.set(y),l=g,_(a,l)},getClearAlpha:function(){return l},setClearAlpha:function(y){l=y,_(a,l)},render:v}}function sI(r,e,t,n){const i=r.getParameter(r.MAX_VERTEX_ATTRIBS),s=n.isWebGL2?null:e.get("OES_vertex_array_object"),o=n.isWebGL2||s!==null,a={},l=y(null);let c=l,u=!1;function h(X,q,W,O,k){let G=!1;if(o){const B=_(O,W,q);c!==B&&(c=B,m(c.object)),G=g(X,O,W,k),G&&x(X,O,W,k)}else{const B=q.wireframe===!0;(c.geometry!==O.id||c.program!==W.id||c.wireframe!==B)&&(c.geometry=O.id,c.program=W.id,c.wireframe=B,G=!0)}k!==null&&t.update(k,r.ELEMENT_ARRAY_BUFFER),(G||u)&&(u=!1,P(X,q,W,O),k!==null&&r.bindBuffer(r.ELEMENT_ARRAY_BUFFER,t.get(k).buffer))}function p(){return n.isWebGL2?r.createVertexArray():s.createVertexArrayOES()}function m(X){return n.isWebGL2?r.bindVertexArray(X):s.bindVertexArrayOES(X)}function v(X){return n.isWebGL2?r.deleteVertexArray(X):s.deleteVertexArrayOES(X)}function _(X,q,W){const O=W.wireframe===!0;let k=a[X.id];k===void 0&&(k={},a[X.id]=k);let G=k[q.id];G===void 0&&(G={},k[q.id]=G);let B=G[O];return B===void 0&&(B=y(p()),G[O]=B),B}function y(X){const q=[],W=[],O=[];for(let k=0;k=0){const ee=k[V];let ie=G[V];if(ie===void 0&&(V==="instanceMatrix"&&X.instanceMatrix&&(ie=X.instanceMatrix),V==="instanceColor"&&X.instanceColor&&(ie=X.instanceColor)),ee===void 0||ee.attribute!==ie||ie&&ee.data!==ie.data)return!0;B++}return c.attributesNum!==B||c.index!==O}function x(X,q,W,O){const k={},G=q.attributes;let B=0;const D=W.getAttributes();for(const V in D)if(D[V].location>=0){let ee=G[V];ee===void 0&&(V==="instanceMatrix"&&X.instanceMatrix&&(ee=X.instanceMatrix),V==="instanceColor"&&X.instanceColor&&(ee=X.instanceColor));const ie={};ie.attribute=ee,ee&&ee.data&&(ie.data=ee.data),k[V]=ie,B++}c.attributes=k,c.attributesNum=B,c.index=O}function w(){const X=c.newAttributes;for(let q=0,W=X.length;q=0){let Z=k[D];if(Z===void 0&&(D==="instanceMatrix"&&X.instanceMatrix&&(Z=X.instanceMatrix),D==="instanceColor"&&X.instanceColor&&(Z=X.instanceColor)),Z!==void 0){const ee=Z.normalized,ie=Z.itemSize,ue=t.get(Z);if(ue===void 0)continue;const ce=ue.buffer,le=ue.type,Ae=ue.bytesPerElement,Ee=n.isWebGL2===!0&&(le===r.INT||le===r.UNSIGNED_INT||Z.gpuType===Yv);if(Z.isInterleavedBufferAttribute){const ae=Z.data,z=ae.stride,oe=Z.offset;if(ae.isInstancedInterleavedBuffer){for(let te=0;te0&&r.getShaderPrecisionFormat(r.FRAGMENT_SHADER,r.HIGH_FLOAT).precision>0)return"highp";A="mediump"}return A==="mediump"&&r.getShaderPrecisionFormat(r.VERTEX_SHADER,r.MEDIUM_FLOAT).precision>0&&r.getShaderPrecisionFormat(r.FRAGMENT_SHADER,r.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}const o=typeof WebGL2RenderingContext<"u"&&r.constructor.name==="WebGL2RenderingContext";let a=t.precision!==void 0?t.precision:"highp";const l=s(a);l!==a&&(console.warn("THREE.WebGLRenderer:",a,"not supported, using",l,"instead."),a=l);const c=o||e.has("WEBGL_draw_buffers"),u=t.logarithmicDepthBuffer===!0,h=r.getParameter(r.MAX_TEXTURE_IMAGE_UNITS),p=r.getParameter(r.MAX_VERTEX_TEXTURE_IMAGE_UNITS),m=r.getParameter(r.MAX_TEXTURE_SIZE),v=r.getParameter(r.MAX_CUBE_MAP_TEXTURE_SIZE),_=r.getParameter(r.MAX_VERTEX_ATTRIBS),y=r.getParameter(r.MAX_VERTEX_UNIFORM_VECTORS),g=r.getParameter(r.MAX_VARYING_VECTORS),x=r.getParameter(r.MAX_FRAGMENT_UNIFORM_VECTORS),w=p>0,E=o||e.has("OES_texture_float"),b=w&&E,M=o?r.getParameter(r.MAX_SAMPLES):0;return{isWebGL2:o,drawBuffers:c,getMaxAnisotropy:i,getMaxPrecision:s,precision:a,logarithmicDepthBuffer:u,maxTextures:h,maxVertexTextures:p,maxTextureSize:m,maxCubemapSize:v,maxAttributes:_,maxVertexUniforms:y,maxVaryings:g,maxFragmentUniforms:x,vertexTextures:w,floatFragmentTextures:E,floatVertexTextures:b,maxSamples:M}}function lI(r){const e=this;let t=null,n=0,i=!1,s=!1;const o=new Us,a=new Ct,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(h,p){const m=h.length!==0||p||n!==0||i;return i=p,n=h.length,m},this.beginShadows=function(){s=!0,u(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(h,p){t=u(h,p,0)},this.setState=function(h,p,m){const v=h.clippingPlanes,_=h.clipIntersection,y=h.clipShadows,g=r.get(h);if(!i||v===null||v.length===0||s&&!y)s?u(null):c();else{const x=s?0:n,w=x*4;let E=g.clippingState||null;l.value=E,E=u(v,p,w,m);for(let b=0;b!==w;++b)E[b]=t[b];g.clippingState=E,this.numIntersection=_?this.numPlanes:0,this.numPlanes+=x}};function c(){l.value!==t&&(l.value=t,l.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function u(h,p,m,v){const _=h!==null?h.length:0;let y=null;if(_!==0){if(y=l.value,v!==!0||y===null){const g=m+_*4,x=p.matrixWorldInverse;a.getNormalMatrix(x),(y===null||y.length0){const c=new uM(l.height/2);return c.fromEquirectangularTexture(r,o),e.set(o,c),o.addEventListener("dispose",i),t(c.texture,o.mapping)}else return null}}return o}function i(o){const a=o.target;a.removeEventListener("dispose",i);const l=e.get(a);l!==void 0&&(e.delete(a),l.dispose())}function s(){e=new WeakMap}return{get:n,dispose:s}}class Pa extends rh{constructor(e=-1,t=1,n=1,i=-1,s=.1,o=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=i,this.near=s,this.far=o,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,i,s,o){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=i,this.view.width=s,this.view.height=o,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,i=(this.top+this.bottom)/2;let s=n-e,o=n+e,a=i+t,l=i-t;if(this.view!==null&&this.view.enabled){const c=(this.right-this.left)/this.view.fullWidth/this.zoom,u=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=c*this.view.offsetX,o=s+c*this.view.width,a-=u*this.view.offsetY,l=a-u*this.view.height}this.projectionMatrix.makeOrthographic(s,o,a,l,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 Ul=4,o1=[.125,.215,.35,.446,.526,.582],la=20,Jm=new Pa,a1=new Ke;let Qm=null;const sa=(1+Math.sqrt(5))/2,hl=1/sa,l1=[new Y(1,1,1),new Y(-1,1,1),new Y(1,1,-1),new Y(-1,1,-1),new Y(0,sa,hl),new Y(0,sa,-hl),new Y(hl,0,sa),new Y(-hl,0,sa),new Y(sa,hl,0),new Y(-sa,hl,0)];class lv{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,i=100){Qm=this._renderer.getRenderTarget(),this._setSize(256);const s=this._allocateTargets();return s.depthBuffer=!0,this._sceneToCubeUV(e,n,i,s),t>0&&this._blur(s,0,0,t),this._applyPMREM(s),this._cleanup(s),s}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=h1(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=u1(),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;e2?w:0,w,w),u.setRenderTarget(i),_&&u.render(v,a),u.render(e,a)}v.geometry.dispose(),v.material.dispose(),u.toneMapping=p,u.autoClear=h,e.background=y}_textureToCubeUV(e,t){const n=this._renderer,i=e.mapping===xo||e.mapping===wo;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=h1()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=u1());const s=i?this._cubemapMaterial:this._equirectMaterial,o=new _n(this._lodPlanes[0],s),a=s.uniforms;a.envMap.value=e;const l=this._cubeSize;Pf(t,0,0,3*l,2*l),n.setRenderTarget(t),n.render(o,Jm)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;for(let i=1;ila&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${y} samples when the maximum is set to ${la}`);const g=[];let x=0;for(let A=0;Aw-Ul?i-w+Ul:0),M=4*(this._cubeSize-E);Pf(t,b,M,3*E,2*E),l.setRenderTarget(t),l.render(h,Jm)}}function uI(r){const e=[],t=[],n=[];let i=r;const s=r-Ul+1+o1.length;for(let o=0;or-Ul?l=o1[o-r+Ul-1]:o===0&&(l=0),n.push(l);const c=1/(a-2),u=-c,h=1+c,p=[u,u,h,u,h,h,u,u,h,h,u,h],m=6,v=6,_=3,y=2,g=1,x=new Float32Array(_*v*m),w=new Float32Array(y*v*m),E=new Float32Array(g*v*m);for(let M=0;M2?0:-1,C=[A,P,0,A+2/3,P,0,A+2/3,P+1,0,A,P,0,A+2/3,P+1,0,A,P+1,0];x.set(C,_*v*M),w.set(p,y*v*M);const L=[M,M,M,M,M,M];E.set(L,g*v*M)}const b=new Tt;b.setAttribute("position",new $t(x,_)),b.setAttribute("uv",new $t(w,y)),b.setAttribute("faceIndex",new $t(E,g)),e.push(b),i>Ul&&i--}return{lodPlanes:e,sizeLods:t,sigmas:n}}function c1(r,e,t){const n=new Gr(r,e,t);return n.texture.mapping=Jl,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function Pf(r,e,t,n,i){r.viewport.set(e,t,n,i),r.scissor.set(e,t,n,i)}function hI(r,e,t){const n=new Float32Array(la),i=new Y(0,1,0);return new cs({name:"SphericalGaussianBlur",defines:{n:la,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${r}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:i}},vertexShader:cy(),fragmentShader:` precision mediump float; precision mediump int; varying vec3 vOutputDirection; uniform sampler2D envMap; uniform int samples; uniform float weights[ n ]; uniform bool latitudinal; uniform float dTheta; uniform float mipInt; uniform vec3 poleAxis; #define ENVMAP_TYPE_CUBE_UV #include vec3 getSample( float theta, vec3 axis ) { float cosTheta = cos( theta ); // Rodrigues' axis-angle rotation vec3 sampleDirection = vOutputDirection * cosTheta + cross( axis, vOutputDirection ) * sin( theta ) + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta ); return bilinearCubeUV( envMap, sampleDirection, mipInt ); } void main() { vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection ); if ( all( equal( axis, vec3( 0.0 ) ) ) ) { axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x ); } axis = normalize( axis ); gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 ); gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis ); for ( int i = 1; i < n; i++ ) { if ( i >= samples ) { break; } float theta = dTheta * float( i ); gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis ); gl_FragColor.rgb += weights[ i ] * getSample( theta, axis ); } } `,blending:Fs,depthTest:!1,depthWrite:!1})}function u1(){return new cs({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:cy(),fragmentShader:` precision mediump float; precision mediump int; varying vec3 vOutputDirection; uniform sampler2D envMap; #include void main() { vec3 outputDirection = normalize( vOutputDirection ); vec2 uv = equirectUv( outputDirection ); gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 ); } `,blending:Fs,depthTest:!1,depthWrite:!1})}function h1(){return new cs({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:cy(),fragmentShader:` precision mediump float; precision mediump int; uniform float flipEnvMap; varying vec3 vOutputDirection; uniform samplerCube envMap; void main() { gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) ); } `,blending:Fs,depthTest:!1,depthWrite:!1})}function cy(){return` precision mediump float; precision mediump int; attribute float faceIndex; varying vec3 vOutputDirection; // RH coordinate system; PMREM face-indexing convention vec3 getDirection( vec2 uv, float face ) { uv = 2.0 * uv - 1.0; vec3 direction = vec3( uv, 1.0 ); if ( face == 0.0 ) { direction = direction.zyx; // ( 1, v, u ) pos x } else if ( face == 1.0 ) { direction = direction.xzy; direction.xz *= -1.0; // ( -u, 1, -v ) pos y } else if ( face == 2.0 ) { direction.x *= -1.0; // ( -u, v, 1 ) pos z } else if ( face == 3.0 ) { direction = direction.zyx; direction.xz *= -1.0; // ( -1, v, -u ) neg x } else if ( face == 4.0 ) { direction = direction.xzy; direction.xy *= -1.0; // ( -u, -1, v ) neg y } else if ( face == 5.0 ) { direction.z *= -1.0; // ( u, v, -1 ) neg z } return direction; } void main() { vOutputDirection = getDirection( uv, faceIndex ); gl_Position = vec4( position, 1.0 ); } `}function fI(r){let e=new WeakMap,t=null;function n(a){if(a&&a.isTexture){const l=a.mapping,c=l===Cu||l===Ru,u=l===xo||l===wo;if(c||u)if(a.isRenderTargetTexture&&a.needsPMREMUpdate===!0){a.needsPMREMUpdate=!1;let h=e.get(a);return t===null&&(t=new lv(r)),h=c?t.fromEquirectangular(a,h):t.fromCubemap(a,h),e.set(a,h),h.texture}else{if(e.has(a))return e.get(a).texture;{const h=a.image;if(c&&h&&h.height>0||u&&h&&i(h)){t===null&&(t=new lv(r));const p=c?t.fromEquirectangular(a):t.fromCubemap(a);return e.set(a,p),a.addEventListener("dispose",s),p.texture}else return null}}}return a}function i(a){let l=0;const c=6;for(let u=0;ue.maxTextureSize&&(L=Math.ceil(C/e.maxTextureSize),C=e.maxTextureSize);const F=new Float32Array(C*L*4*v),N=new Jd(F,C,L,v);N.type=rs,N.needsUpdate=!0;const I=P*4;for(let q=0;q0)return r;const i=e*t;let s=f1[i];if(s===void 0&&(s=new Float32Array(i),f1[i]=s),e!==0){n.toArray(s,0);for(let o=1,a=0;o!==e;++o)a+=t,r[o].toArray(s,a)}return s}function Wn(r,e){if(r.length!==e.length)return!1;for(let t=0,n=r.length;t":" "} ${a}: ${t[o]}`)}return n.join(` `)}function dD(r){switch(r){case Br:return["Linear","( value )"];case Mt:return["sRGB","( value )"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",r),["Linear","( value )"]}}function _1(r,e,t){const n=r.getShaderParameter(e,r.COMPILE_STATUS),i=r.getShaderInfoLog(e).trim();if(n&&i==="")return"";const s=/ERROR: 0:(\d+)/.exec(i);if(s){const o=parseInt(s[1]);return t.toUpperCase()+` `+i+` `+fD(r.getShaderSource(e),o)}else return i}function pD(r,e){const t=dD(e);return"vec4 "+r+"( vec4 value ) { return LinearTo"+t[0]+t[1]+"; }"}function mD(r,e){let t;switch(e){case Ib:t="Linear";break;case Db:t="Reinhard";break;case Ub:t="OptimizedCineon";break;case Xv:t="ACESFilmic";break;case Ob:t="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),t="Linear"}return"vec3 "+r+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}function gD(r){return[r.extensionDerivatives||r.envMapCubeUVHeight||r.bumpMap||r.normalMapTangentSpace||r.clearcoatNormalMap||r.flatShading||r.shaderID==="physical"?"#extension GL_OES_standard_derivatives : enable":"",(r.extensionFragDepth||r.logarithmicDepthBuffer)&&r.rendererExtensionFragDepth?"#extension GL_EXT_frag_depth : enable":"",r.extensionDrawBuffers&&r.rendererExtensionDrawBuffers?"#extension GL_EXT_draw_buffers : require":"",(r.extensionShaderTextureLOD||r.envMap||r.transmission)&&r.rendererExtensionShaderTextureLod?"#extension GL_EXT_shader_texture_lod : enable":""].filter(fu).join(` `)}function vD(r){const e=[];for(const t in r){const n=r[t];n!==!1&&e.push("#define "+t+" "+n)}return e.join(` `)}function yD(r,e){const t={},n=r.getProgramParameter(e,r.ACTIVE_ATTRIBUTES);for(let i=0;i/gm;function cv(r){return r.replace(_D,wD)}const xD=new Map([["encodings_fragment","colorspace_fragment"],["encodings_pars_fragment","colorspace_pars_fragment"],["output_fragment","opaque_fragment"]]);function wD(r,e){let t=bt[e];if(t===void 0){const n=xD.get(e);if(n!==void 0)t=bt[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 cv(t)}const SD=/#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 S1(r){return r.replace(SD,ED)}function ED(r,e,t,n){let i="";for(let s=parseInt(e);s0&&(y+=` `),g=[m,"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,v].filter(fu).join(` `),g.length>0&&(g+=` `)):(y=[E1(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,v,t.instancing?"#define USE_INSTANCING":"",t.instancingColor?"#define USE_INSTANCING_COLOR":"",t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+u:"",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.displacementMap?"#define USE_DISPLACEMENTMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",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.alphaHash?"#define USE_ALPHAHASH":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.mapUv?"#define MAP_UV "+t.mapUv:"",t.alphaMapUv?"#define ALPHAMAP_UV "+t.alphaMapUv:"",t.lightMapUv?"#define LIGHTMAP_UV "+t.lightMapUv:"",t.aoMapUv?"#define AOMAP_UV "+t.aoMapUv:"",t.emissiveMapUv?"#define EMISSIVEMAP_UV "+t.emissiveMapUv:"",t.bumpMapUv?"#define BUMPMAP_UV "+t.bumpMapUv:"",t.normalMapUv?"#define NORMALMAP_UV "+t.normalMapUv:"",t.displacementMapUv?"#define DISPLACEMENTMAP_UV "+t.displacementMapUv:"",t.metalnessMapUv?"#define METALNESSMAP_UV "+t.metalnessMapUv:"",t.roughnessMapUv?"#define ROUGHNESSMAP_UV "+t.roughnessMapUv:"",t.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+t.anisotropyMapUv:"",t.clearcoatMapUv?"#define CLEARCOATMAP_UV "+t.clearcoatMapUv:"",t.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+t.clearcoatNormalMapUv:"",t.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+t.clearcoatRoughnessMapUv:"",t.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+t.iridescenceMapUv:"",t.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+t.iridescenceThicknessMapUv:"",t.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+t.sheenColorMapUv:"",t.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+t.sheenRoughnessMapUv:"",t.specularMapUv?"#define SPECULARMAP_UV "+t.specularMapUv:"",t.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+t.specularColorMapUv:"",t.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+t.specularIntensityMapUv:"",t.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+t.transmissionMapUv:"",t.thicknessMapUv?"#define THICKNESSMAP_UV "+t.thicknessMapUv:"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors?"#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.flatShading?"#define FLAT_SHADED":"",t.skinning?"#define USE_SKINNING":"",t.morphTargets?"#define USE_MORPHTARGETS":"",t.morphNormals&&t.flatShading===!1?"#define USE_MORPHNORMALS":"",t.morphColors&&t.isWebGL2?"#define USE_MORPHCOLORS":"",t.morphTargetsCount>0&&t.isWebGL2?"#define MORPHTARGETS_TEXTURE":"",t.morphTargetsCount>0&&t.isWebGL2?"#define MORPHTARGETS_TEXTURE_STRIDE "+t.morphTextureStride:"",t.morphTargetsCount>0&&t.isWebGL2?"#define MORPHTARGETS_COUNT "+t.morphTargetsCount:"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+l:"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.useLegacyLights?"#define LEGACY_LIGHTS":"",t.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",t.logarithmicDepthBuffer&&t.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )"," attribute vec3 morphTarget0;"," attribute vec3 morphTarget1;"," attribute vec3 morphTarget2;"," attribute vec3 morphTarget3;"," #ifdef USE_MORPHNORMALS"," attribute vec3 morphNormal0;"," attribute vec3 morphNormal1;"," attribute vec3 morphNormal2;"," attribute vec3 morphNormal3;"," #else"," attribute vec3 morphTarget4;"," attribute vec3 morphTarget5;"," attribute vec3 morphTarget6;"," attribute vec3 morphTarget7;"," #endif","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",` `].filter(fu).join(` `),g=[m,E1(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,v,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+c:"",t.envMap?"#define "+u:"",t.envMap?"#define "+h:"",p?"#define CUBEUV_TEXEL_WIDTH "+p.texelWidth:"",p?"#define CUBEUV_TEXEL_HEIGHT "+p.texelHeight:"",p?"#define CUBEUV_MAX_MIP "+p.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 "+l:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.useLegacyLights?"#define LEGACY_LIGHTS":"",t.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",t.logarithmicDepthBuffer&&t.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==zr?"#define TONE_MAPPING":"",t.toneMapping!==zr?bt.tonemapping_pars_fragment:"",t.toneMapping!==zr?mD("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",bt.colorspace_pars_fragment,pD("linearToOutputTexel",t.outputColorSpace),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",` `].filter(fu).join(` `)),o=cv(o),o=x1(o,t),o=w1(o,t),a=cv(a),a=x1(a,t),a=w1(a,t),o=S1(o),a=S1(a),t.isWebGL2&&t.isRawShaderMaterial!==!0&&(x=`#version 300 es `,y=["precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join(` `)+` `+y,g=["#define varying in",t.glslVersion===ov?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===ov?"":"#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(` `)+` `+g);const w=x+y+o,E=x+g+a,b=y1(i,i.VERTEX_SHADER,w),M=y1(i,i.FRAGMENT_SHADER,E);if(i.attachShader(_,b),i.attachShader(_,M),t.index0AttributeName!==void 0?i.bindAttribLocation(_,0,t.index0AttributeName):t.morphTargets===!0&&i.bindAttribLocation(_,0,"position"),i.linkProgram(_),r.debug.checkShaderErrors){const C=i.getProgramInfoLog(_).trim(),L=i.getShaderInfoLog(b).trim(),F=i.getShaderInfoLog(M).trim();let N=!0,I=!0;if(i.getProgramParameter(_,i.LINK_STATUS)===!1)if(N=!1,typeof r.debug.onShaderError=="function")r.debug.onShaderError(i,_,b,M);else{const X=_1(i,b,"vertex"),q=_1(i,M,"fragment");console.error("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(_,i.VALIDATE_STATUS)+` Program Info Log: `+C+` `+X+` `+q)}else C!==""?console.warn("THREE.WebGLProgram: Program Info Log:",C):(L===""||F==="")&&(I=!1);I&&(this.diagnostics={runnable:N,programLog:C,vertexShader:{log:L,prefix:y},fragmentShader:{log:F,prefix:g}})}i.deleteShader(b),i.deleteShader(M);let A;this.getUniforms=function(){return A===void 0&&(A=new bd(i,_)),A};let P;return this.getAttributes=function(){return P===void 0&&(P=yD(i,_)),P},this.destroy=function(){n.releaseStatesOfProgram(this),i.deleteProgram(_),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=hD++,this.cacheKey=e,this.usedTimes=1,this.program=_,this.vertexShader=b,this.fragmentShader=M,this}let PD=0;class LD{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const t=e.vertexShader,n=e.fragmentShader,i=this._getShaderStage(t),s=this._getShaderStage(n),o=this._getShaderCacheForMaterial(e);return o.has(i)===!1&&(o.add(i),i.usedTimes++),o.has(s)===!1&&(o.add(s),s.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 ID(e),t.set(e,n)),n}}class ID{constructor(e){this.id=PD++,this.code=e,this.usedTimes=0}}function DD(r,e,t,n,i,s,o){const a=new ga,l=new LD,c=[],u=i.isWebGL2,h=i.logarithmicDepthBuffer,p=i.vertexTextures;let m=i.precision;const v={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 _(C){return C===0?"uv":`uv${C}`}function y(C,L,F,N,I){const X=N.fog,q=I.geometry,W=C.isMeshStandardMaterial?N.environment:null,O=(C.isMeshStandardMaterial?t:e).get(C.envMap||W),k=O&&O.mapping===Jl?O.image.height:null,G=v[C.type];C.precision!==null&&(m=i.getMaxPrecision(C.precision),m!==C.precision&&console.warn("THREE.WebGLProgram.getParameters:",C.precision,"not supported, using",m,"instead."));const B=q.morphAttributes.position||q.morphAttributes.normal||q.morphAttributes.color,D=B!==void 0?B.length:0;let V=0;q.morphAttributes.position!==void 0&&(V=1),q.morphAttributes.normal!==void 0&&(V=2),q.morphAttributes.color!==void 0&&(V=3);let Z,ee,ie,ue;if(G){const Ot=Nr[G];Z=Ot.vertexShader,ee=Ot.fragmentShader}else Z=C.vertexShader,ee=C.fragmentShader,l.update(C),ie=l.getVertexShaderID(C),ue=l.getFragmentShaderID(C);const ce=r.getRenderTarget(),le=I.isInstancedMesh===!0,Ae=!!C.map,Ee=!!C.matcap,ae=!!O,z=!!C.aoMap,oe=!!C.lightMap,te=!!C.bumpMap,se=!!C.normalMap,$=!!C.displacementMap,Ie=!!C.emissiveMap,de=!!C.metalnessMap,Se=!!C.roughnessMap,Le=C.anisotropy>0,ge=C.clearcoat>0,He=C.iridescence>0,j=C.sheen>0,H=C.transmission>0,ne=Le&&!!C.anisotropyMap,we=ge&&!!C.clearcoatMap,be=ge&&!!C.clearcoatNormalMap,Me=ge&&!!C.clearcoatRoughnessMap,Fe=He&&!!C.iridescenceMap,Ue=He&&!!C.iridescenceThicknessMap,xe=j&&!!C.sheenColorMap,Be=j&&!!C.sheenRoughnessMap,$e=!!C.specularMap,Ve=!!C.specularColorMap,Oe=!!C.specularIntensityMap,We=H&&!!C.transmissionMap,nt=H&&!!C.thicknessMap,pt=!!C.gradientMap,re=!!C.alphaMap,ze=C.alphaTest>0,ve=!!C.alphaHash,Ge=!!C.extensions,Ye=!!q.attributes.uv1,_t=!!q.attributes.uv2,It=!!q.attributes.uv3;return{isWebGL2:u,shaderID:G,shaderType:C.type,shaderName:C.name,vertexShader:Z,fragmentShader:ee,defines:C.defines,customVertexShaderID:ie,customFragmentShaderID:ue,isRawShaderMaterial:C.isRawShaderMaterial===!0,glslVersion:C.glslVersion,precision:m,instancing:le,instancingColor:le&&I.instanceColor!==null,supportsVertexTextures:p,outputColorSpace:ce===null?r.outputColorSpace:ce.isXRRenderTarget===!0?ce.texture.colorSpace:Br,map:Ae,matcap:Ee,envMap:ae,envMapMode:ae&&O.mapping,envMapCubeUVHeight:k,aoMap:z,lightMap:oe,bumpMap:te,normalMap:se,displacementMap:p&&$,emissiveMap:Ie,normalMapObjectSpace:se&&C.normalMapType===Zb,normalMapTangentSpace:se&&C.normalMapType===Mo,metalnessMap:de,roughnessMap:Se,anisotropy:Le,anisotropyMap:ne,clearcoat:ge,clearcoatMap:we,clearcoatNormalMap:be,clearcoatRoughnessMap:Me,iridescence:He,iridescenceMap:Fe,iridescenceThicknessMap:Ue,sheen:j,sheenColorMap:xe,sheenRoughnessMap:Be,specularMap:$e,specularColorMap:Ve,specularIntensityMap:Oe,transmission:H,transmissionMap:We,thicknessMap:nt,gradientMap:pt,opaque:C.transparent===!1&&C.blending===pa,alphaMap:re,alphaTest:ze,alphaHash:ve,combine:C.combine,mapUv:Ae&&_(C.map.channel),aoMapUv:z&&_(C.aoMap.channel),lightMapUv:oe&&_(C.lightMap.channel),bumpMapUv:te&&_(C.bumpMap.channel),normalMapUv:se&&_(C.normalMap.channel),displacementMapUv:$&&_(C.displacementMap.channel),emissiveMapUv:Ie&&_(C.emissiveMap.channel),metalnessMapUv:de&&_(C.metalnessMap.channel),roughnessMapUv:Se&&_(C.roughnessMap.channel),anisotropyMapUv:ne&&_(C.anisotropyMap.channel),clearcoatMapUv:we&&_(C.clearcoatMap.channel),clearcoatNormalMapUv:be&&_(C.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Me&&_(C.clearcoatRoughnessMap.channel),iridescenceMapUv:Fe&&_(C.iridescenceMap.channel),iridescenceThicknessMapUv:Ue&&_(C.iridescenceThicknessMap.channel),sheenColorMapUv:xe&&_(C.sheenColorMap.channel),sheenRoughnessMapUv:Be&&_(C.sheenRoughnessMap.channel),specularMapUv:$e&&_(C.specularMap.channel),specularColorMapUv:Ve&&_(C.specularColorMap.channel),specularIntensityMapUv:Oe&&_(C.specularIntensityMap.channel),transmissionMapUv:We&&_(C.transmissionMap.channel),thicknessMapUv:nt&&_(C.thicknessMap.channel),alphaMapUv:re&&_(C.alphaMap.channel),vertexTangents:!!q.attributes.tangent&&(se||Le),vertexColors:C.vertexColors,vertexAlphas:C.vertexColors===!0&&!!q.attributes.color&&q.attributes.color.itemSize===4,vertexUv1s:Ye,vertexUv2s:_t,vertexUv3s:It,pointsUvs:I.isPoints===!0&&!!q.attributes.uv&&(Ae||re),fog:!!X,useFog:C.fog===!0,fogExp2:X&&X.isFogExp2,flatShading:C.flatShading===!0,sizeAttenuation:C.sizeAttenuation===!0,logarithmicDepthBuffer:h,skinning:I.isSkinnedMesh===!0,morphTargets:q.morphAttributes.position!==void 0,morphNormals:q.morphAttributes.normal!==void 0,morphColors:q.morphAttributes.color!==void 0,morphTargetsCount:D,morphTextureStride:V,numDirLights:L.directional.length,numPointLights:L.point.length,numSpotLights:L.spot.length,numSpotLightMaps:L.spotLightMap.length,numRectAreaLights:L.rectArea.length,numHemiLights:L.hemi.length,numDirLightShadows:L.directionalShadowMap.length,numPointLightShadows:L.pointShadowMap.length,numSpotLightShadows:L.spotShadowMap.length,numSpotLightShadowsWithMaps:L.numSpotLightShadowsWithMaps,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:C.dithering,shadowMapEnabled:r.shadowMap.enabled&&F.length>0,shadowMapType:r.shadowMap.type,toneMapping:C.toneMapped?r.toneMapping:zr,useLegacyLights:r.useLegacyLights,premultipliedAlpha:C.premultipliedAlpha,doubleSided:C.side===vn,flipSided:C.side===yi,useDepthPacking:C.depthPacking>=0,depthPacking:C.depthPacking||0,index0AttributeName:C.index0AttributeName,extensionDerivatives:Ge&&C.extensions.derivatives===!0,extensionFragDepth:Ge&&C.extensions.fragDepth===!0,extensionDrawBuffers:Ge&&C.extensions.drawBuffers===!0,extensionShaderTextureLOD:Ge&&C.extensions.shaderTextureLOD===!0,rendererExtensionFragDepth:u||n.has("EXT_frag_depth"),rendererExtensionDrawBuffers:u||n.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:u||n.has("EXT_shader_texture_lod"),customProgramCacheKey:C.customProgramCacheKey()}}function g(C){const L=[];if(C.shaderID?L.push(C.shaderID):(L.push(C.customVertexShaderID),L.push(C.customFragmentShaderID)),C.defines!==void 0)for(const F in C.defines)L.push(F),L.push(C.defines[F]);return C.isRawShaderMaterial===!1&&(x(L,C),w(L,C),L.push(r.outputColorSpace)),L.push(C.customProgramCacheKey),L.join()}function x(C,L){C.push(L.precision),C.push(L.outputColorSpace),C.push(L.envMapMode),C.push(L.envMapCubeUVHeight),C.push(L.mapUv),C.push(L.alphaMapUv),C.push(L.lightMapUv),C.push(L.aoMapUv),C.push(L.bumpMapUv),C.push(L.normalMapUv),C.push(L.displacementMapUv),C.push(L.emissiveMapUv),C.push(L.metalnessMapUv),C.push(L.roughnessMapUv),C.push(L.anisotropyMapUv),C.push(L.clearcoatMapUv),C.push(L.clearcoatNormalMapUv),C.push(L.clearcoatRoughnessMapUv),C.push(L.iridescenceMapUv),C.push(L.iridescenceThicknessMapUv),C.push(L.sheenColorMapUv),C.push(L.sheenRoughnessMapUv),C.push(L.specularMapUv),C.push(L.specularColorMapUv),C.push(L.specularIntensityMapUv),C.push(L.transmissionMapUv),C.push(L.thicknessMapUv),C.push(L.combine),C.push(L.fogExp2),C.push(L.sizeAttenuation),C.push(L.morphTargetsCount),C.push(L.morphAttributeCount),C.push(L.numDirLights),C.push(L.numPointLights),C.push(L.numSpotLights),C.push(L.numSpotLightMaps),C.push(L.numHemiLights),C.push(L.numRectAreaLights),C.push(L.numDirLightShadows),C.push(L.numPointLightShadows),C.push(L.numSpotLightShadows),C.push(L.numSpotLightShadowsWithMaps),C.push(L.shadowMapType),C.push(L.toneMapping),C.push(L.numClippingPlanes),C.push(L.numClipIntersection),C.push(L.depthPacking)}function w(C,L){a.disableAll(),L.isWebGL2&&a.enable(0),L.supportsVertexTextures&&a.enable(1),L.instancing&&a.enable(2),L.instancingColor&&a.enable(3),L.matcap&&a.enable(4),L.envMap&&a.enable(5),L.normalMapObjectSpace&&a.enable(6),L.normalMapTangentSpace&&a.enable(7),L.clearcoat&&a.enable(8),L.iridescence&&a.enable(9),L.alphaTest&&a.enable(10),L.vertexColors&&a.enable(11),L.vertexAlphas&&a.enable(12),L.vertexUv1s&&a.enable(13),L.vertexUv2s&&a.enable(14),L.vertexUv3s&&a.enable(15),L.vertexTangents&&a.enable(16),L.anisotropy&&a.enable(17),C.push(a.mask),a.disableAll(),L.fog&&a.enable(0),L.useFog&&a.enable(1),L.flatShading&&a.enable(2),L.logarithmicDepthBuffer&&a.enable(3),L.skinning&&a.enable(4),L.morphTargets&&a.enable(5),L.morphNormals&&a.enable(6),L.morphColors&&a.enable(7),L.premultipliedAlpha&&a.enable(8),L.shadowMapEnabled&&a.enable(9),L.useLegacyLights&&a.enable(10),L.doubleSided&&a.enable(11),L.flipSided&&a.enable(12),L.useDepthPacking&&a.enable(13),L.dithering&&a.enable(14),L.transmission&&a.enable(15),L.sheen&&a.enable(16),L.opaque&&a.enable(17),L.pointsUvs&&a.enable(18),C.push(a.mask)}function E(C){const L=v[C.type];let F;if(L){const N=Nr[L];F=ly.clone(N.uniforms)}else F=C.uniforms;return F}function b(C,L){let F;for(let N=0,I=c.length;N0?n.push(g):m.transparent===!0?i.push(g):t.push(g)}function l(h,p,m,v,_,y){const g=o(h,p,m,v,_,y);m.transmission>0?n.unshift(g):m.transparent===!0?i.unshift(g):t.unshift(g)}function c(h,p){t.length>1&&t.sort(h||OD),n.length>1&&n.sort(p||b1),i.length>1&&i.sort(p||b1)}function u(){for(let h=e,p=r.length;h=s.length?(o=new M1,s.push(o)):o=s[i],o}function t(){r=new WeakMap}return{get:e,dispose:t}}function FD(){const r={};return{get:function(e){if(r[e.id]!==void 0)return r[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new Y,color:new Ke};break;case"SpotLight":t={position:new Y,direction:new Y,color:new Ke,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new Y,color:new Ke,distance:0,decay:0};break;case"HemisphereLight":t={direction:new Y,skyColor:new Ke,groundColor:new Ke};break;case"RectAreaLight":t={color:new Ke,position:new Y,halfWidth:new Y,halfHeight:new Y};break}return r[e.id]=t,t}}}function kD(){const r={};return{get:function(e){if(r[e.id]!==void 0)return r[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new De};break;case"SpotLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new De};break;case"PointLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new De,shadowCameraNear:1,shadowCameraFar:1e3};break}return r[e.id]=t,t}}}let zD=0;function BD(r,e){return(e.castShadow?2:0)-(r.castShadow?2:0)+(e.map?1:0)-(r.map?1:0)}function GD(r,e){const t=new FD,n=kD(),i={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-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};for(let u=0;u<9;u++)i.probe.push(new Y);const s=new Y,o=new yt,a=new yt;function l(u,h){let p=0,m=0,v=0;for(let F=0;F<9;F++)i.probe[F].set(0,0,0);let _=0,y=0,g=0,x=0,w=0,E=0,b=0,M=0,A=0,P=0;u.sort(BD);const C=h===!0?Math.PI:1;for(let F=0,N=u.length;F0&&(e.isWebGL2||r.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=Je.LTC_FLOAT_1,i.rectAreaLTC2=Je.LTC_FLOAT_2):r.has("OES_texture_half_float_linear")===!0?(i.rectAreaLTC1=Je.LTC_HALF_1,i.rectAreaLTC2=Je.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),i.ambient[0]=p,i.ambient[1]=m,i.ambient[2]=v;const L=i.hash;(L.directionalLength!==_||L.pointLength!==y||L.spotLength!==g||L.rectAreaLength!==x||L.hemiLength!==w||L.numDirectionalShadows!==E||L.numPointShadows!==b||L.numSpotShadows!==M||L.numSpotMaps!==A)&&(i.directional.length=_,i.spot.length=g,i.rectArea.length=x,i.point.length=y,i.hemi.length=w,i.directionalShadow.length=E,i.directionalShadowMap.length=E,i.pointShadow.length=b,i.pointShadowMap.length=b,i.spotShadow.length=M,i.spotShadowMap.length=M,i.directionalShadowMatrix.length=E,i.pointShadowMatrix.length=b,i.spotLightMatrix.length=M+A-P,i.spotLightMap.length=A,i.numSpotLightShadowsWithMaps=P,L.directionalLength=_,L.pointLength=y,L.spotLength=g,L.rectAreaLength=x,L.hemiLength=w,L.numDirectionalShadows=E,L.numPointShadows=b,L.numSpotShadows=M,L.numSpotMaps=A,i.version=zD++)}function c(u,h){let p=0,m=0,v=0,_=0,y=0;const g=h.matrixWorldInverse;for(let x=0,w=u.length;x=a.length?(l=new T1(r,e),a.push(l)):l=a[o],l}function i(){t=new WeakMap}return{get:n,dispose:i}}class ep extends oi{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=qb,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 tp extends oi{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 VD=`void main() { gl_Position = vec4( position, 1.0 ); }`,WD=`uniform sampler2D shadow_pass; uniform vec2 resolution; uniform float radius; #include void main() { const float samples = float( VSM_SAMPLES ); float mean = 0.0; float squared_mean = 0.0; float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 ); float uvStart = samples <= 1.0 ? 0.0 : - 1.0; for ( float i = 0.0; i < samples; i ++ ) { float uvOffset = uvStart + i * uvStride; #ifdef HORIZONTAL_PASS vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) ); mean += distribution.x; squared_mean += distribution.y * distribution.y + distribution.x * distribution.x; #else float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) ); mean += depth; squared_mean += depth * depth; #endif } mean = mean / samples; squared_mean = squared_mean / samples; float std_dev = sqrt( squared_mean - mean * mean ); gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) ); }`;function XD(r,e,t){let n=new oh;const i=new De,s=new De,o=new Xt,a=new ep({depthPacking:ty}),l=new tp,c={},u=t.maxTextureSize,h={[ls]:yi,[yi]:ls,[vn]:vn},p=new cs({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new De},radius:{value:4}},vertexShader:VD,fragmentShader:WD}),m=p.clone();m.defines.HORIZONTAL_PASS=1;const v=new Tt;v.setAttribute("position",new $t(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const _=new _n(v,p),y=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=qd;let g=this.type;this.render=function(b,M,A){if(y.enabled===!1||y.autoUpdate===!1&&y.needsUpdate===!1||b.length===0)return;const P=r.getRenderTarget(),C=r.getActiveCubeFace(),L=r.getActiveMipmapLevel(),F=r.state;F.setBlending(Fs),F.buffers.color.setClear(1,1,1,1),F.buffers.depth.setTest(!0),F.setScissorTest(!1);const N=g!==Or&&this.type===Or,I=g===Or&&this.type!==Or;for(let X=0,q=b.length;Xu||i.y>u)&&(i.x>u&&(s.x=Math.floor(u/k.x),i.x=s.x*k.x,O.mapSize.x=s.x),i.y>u&&(s.y=Math.floor(u/k.y),i.y=s.y*k.y,O.mapSize.y=s.y)),O.map===null||N===!0||I===!0){const B=this.type!==Or?{minFilter:Dn,magFilter:Dn}:{};O.map!==null&&O.map.dispose(),O.map=new Gr(i.x,i.y,B),O.map.texture.name=W.name+".shadowMap",O.camera.updateProjectionMatrix()}r.setRenderTarget(O.map),r.clear();const G=O.getViewportCount();for(let B=0;B0||M.map&&M.alphaTest>0){const F=C.uuid,N=M.uuid;let I=c[F];I===void 0&&(I={},c[F]=I);let X=I[N];X===void 0&&(X=C.clone(),I[N]=X),C=X}if(C.visible=M.visible,C.wireframe=M.wireframe,P===Or?C.side=M.shadowSide!==null?M.shadowSide:M.side:C.side=M.shadowSide!==null?M.shadowSide:h[M.side],C.alphaMap=M.alphaMap,C.alphaTest=M.alphaTest,C.map=M.map,C.clipShadows=M.clipShadows,C.clippingPlanes=M.clippingPlanes,C.clipIntersection=M.clipIntersection,C.displacementMap=M.displacementMap,C.displacementScale=M.displacementScale,C.displacementBias=M.displacementBias,C.wireframeLinewidth=M.wireframeLinewidth,C.linewidth=M.linewidth,A.isPointLight===!0&&C.isMeshDistanceMaterial===!0){const F=r.properties.get(C);F.light=A}return C}function E(b,M,A,P,C){if(b.visible===!1)return;if(b.layers.test(M.layers)&&(b.isMesh||b.isLine||b.isPoints)&&(b.castShadow||b.receiveShadow&&C===Or)&&(!b.frustumCulled||n.intersectsObject(b))){b.modelViewMatrix.multiplyMatrices(A.matrixWorldInverse,b.matrixWorld);const N=e.update(b),I=b.material;if(Array.isArray(I)){const X=N.groups;for(let q=0,W=X.length;q=1):k.indexOf("OpenGL ES")!==-1&&(O=parseFloat(/^OpenGL ES (\d)/.exec(k)[1]),W=O>=2);let G=null,B={};const D=r.getParameter(r.SCISSOR_BOX),V=r.getParameter(r.VIEWPORT),Z=new Xt().fromArray(D),ee=new Xt().fromArray(V);function ie(re,ze,ve,Ge){const Ye=new Uint8Array(4),_t=r.createTexture();r.bindTexture(re,_t),r.texParameteri(re,r.TEXTURE_MIN_FILTER,r.NEAREST),r.texParameteri(re,r.TEXTURE_MAG_FILTER,r.NEAREST);for(let It=0;It"u"?!1:/OculusBrowser/g.test(navigator.userAgent),v=new WeakMap;let _;const y=new WeakMap;let g=!1;try{g=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function x(j,H){return g?new OffscreenCanvas(j,H):Fu("canvas")}function w(j,H,ne,we){let be=1;if((j.width>we||j.height>we)&&(be=we/Math.max(j.width,j.height)),be<1||H===!0)if(typeof HTMLImageElement<"u"&&j instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&j instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&j instanceof ImageBitmap){const Me=H?Ud:Math.floor,Fe=Me(be*j.width),Ue=Me(be*j.height);_===void 0&&(_=x(Fe,Ue));const xe=ne?x(Fe,Ue):_;return xe.width=Fe,xe.height=Ue,xe.getContext("2d").drawImage(j,0,0,Fe,Ue),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+j.width+"x"+j.height+") to ("+Fe+"x"+Ue+")."),xe}else return"data"in j&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+j.width+"x"+j.height+")."),j;return j}function E(j){return av(j.width)&&av(j.height)}function b(j){return a?!1:j.wrapS!==vi||j.wrapT!==vi||j.minFilter!==Dn&&j.minFilter!==fn}function M(j,H){return j.generateMipmaps&&H&&j.minFilter!==Dn&&j.minFilter!==fn}function A(j){r.generateMipmap(j)}function P(j,H,ne,we,be=!1){if(a===!1)return H;if(j!==null){if(r[j]!==void 0)return r[j];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+j+"'")}let Me=H;return H===r.RED&&(ne===r.FLOAT&&(Me=r.R32F),ne===r.HALF_FLOAT&&(Me=r.R16F),ne===r.UNSIGNED_BYTE&&(Me=r.R8)),H===r.RG&&(ne===r.FLOAT&&(Me=r.RG32F),ne===r.HALF_FLOAT&&(Me=r.RG16F),ne===r.UNSIGNED_BYTE&&(Me=r.RG8)),H===r.RGBA&&(ne===r.FLOAT&&(Me=r.RGBA32F),ne===r.HALF_FLOAT&&(Me=r.RGBA16F),ne===r.UNSIGNED_BYTE&&(Me=we===Mt&&be===!1?r.SRGB8_ALPHA8:r.RGBA8),ne===r.UNSIGNED_SHORT_4_4_4_4&&(Me=r.RGBA4),ne===r.UNSIGNED_SHORT_5_5_5_1&&(Me=r.RGB5_A1)),(Me===r.R16F||Me===r.R32F||Me===r.RG16F||Me===r.RG32F||Me===r.RGBA16F||Me===r.RGBA32F)&&e.get("EXT_color_buffer_float"),Me}function C(j,H,ne){return M(j,ne)===!0||j.isFramebufferTexture&&j.minFilter!==Dn&&j.minFilter!==fn?Math.log2(Math.max(H.width,H.height))+1:j.mipmaps!==void 0&&j.mipmaps.length>0?j.mipmaps.length:j.isCompressedTexture&&Array.isArray(j.image)?H.mipmaps.length:1}function L(j){return j===Dn||j===Id||j===vu?r.NEAREST:r.LINEAR}function F(j){const H=j.target;H.removeEventListener("dispose",F),I(H),H.isVideoTexture&&v.delete(H)}function N(j){const H=j.target;H.removeEventListener("dispose",N),q(H)}function I(j){const H=n.get(j);if(H.__webglInit===void 0)return;const ne=j.source,we=y.get(ne);if(we){const be=we[H.__cacheKey];be.usedTimes--,be.usedTimes===0&&X(j),Object.keys(we).length===0&&y.delete(ne)}n.remove(j)}function X(j){const H=n.get(j);r.deleteTexture(H.__webglTexture);const ne=j.source,we=y.get(ne);delete we[H.__cacheKey],o.memory.textures--}function q(j){const H=j.texture,ne=n.get(j),we=n.get(H);if(we.__webglTexture!==void 0&&(r.deleteTexture(we.__webglTexture),o.memory.textures--),j.depthTexture&&j.depthTexture.dispose(),j.isWebGLCubeRenderTarget)for(let be=0;be<6;be++)r.deleteFramebuffer(ne.__webglFramebuffer[be]),ne.__webglDepthbuffer&&r.deleteRenderbuffer(ne.__webglDepthbuffer[be]);else{if(r.deleteFramebuffer(ne.__webglFramebuffer),ne.__webglDepthbuffer&&r.deleteRenderbuffer(ne.__webglDepthbuffer),ne.__webglMultisampledFramebuffer&&r.deleteFramebuffer(ne.__webglMultisampledFramebuffer),ne.__webglColorRenderbuffer)for(let be=0;be=l&&console.warn("THREE.WebGLTextures: Trying to use "+j+" texture units while this GPU supports only "+l),W+=1,j}function G(j){const H=[];return H.push(j.wrapS),H.push(j.wrapT),H.push(j.wrapR||0),H.push(j.magFilter),H.push(j.minFilter),H.push(j.anisotropy),H.push(j.internalFormat),H.push(j.format),H.push(j.type),H.push(j.generateMipmaps),H.push(j.premultiplyAlpha),H.push(j.flipY),H.push(j.unpackAlignment),H.push(j.colorSpace),H.join()}function B(j,H){const ne=n.get(j);if(j.isVideoTexture&&ge(j),j.isRenderTargetTexture===!1&&j.version>0&&ne.__version!==j.version){const we=j.image;if(we===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(we.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{Ae(ne,j,H);return}}t.bindTexture(r.TEXTURE_2D,ne.__webglTexture,r.TEXTURE0+H)}function D(j,H){const ne=n.get(j);if(j.version>0&&ne.__version!==j.version){Ae(ne,j,H);return}t.bindTexture(r.TEXTURE_2D_ARRAY,ne.__webglTexture,r.TEXTURE0+H)}function V(j,H){const ne=n.get(j);if(j.version>0&&ne.__version!==j.version){Ae(ne,j,H);return}t.bindTexture(r.TEXTURE_3D,ne.__webglTexture,r.TEXTURE0+H)}function Z(j,H){const ne=n.get(j);if(j.version>0&&ne.__version!==j.version){Ee(ne,j,H);return}t.bindTexture(r.TEXTURE_CUBE_MAP,ne.__webglTexture,r.TEXTURE0+H)}const ee={[Pu]:r.REPEAT,[vi]:r.CLAMP_TO_EDGE,[Lu]:r.MIRRORED_REPEAT},ie={[Dn]:r.NEAREST,[Id]:r.NEAREST_MIPMAP_NEAREST,[vu]:r.NEAREST_MIPMAP_LINEAR,[fn]:r.LINEAR,[jv]:r.LINEAR_MIPMAP_NEAREST,[So]:r.LINEAR_MIPMAP_LINEAR},ue={[$b]:r.NEVER,[rM]:r.ALWAYS,[Jb]:r.LESS,[eM]:r.LEQUAL,[Qb]:r.EQUAL,[iM]:r.GEQUAL,[tM]:r.GREATER,[nM]:r.NOTEQUAL};function ce(j,H,ne){if(ne?(r.texParameteri(j,r.TEXTURE_WRAP_S,ee[H.wrapS]),r.texParameteri(j,r.TEXTURE_WRAP_T,ee[H.wrapT]),(j===r.TEXTURE_3D||j===r.TEXTURE_2D_ARRAY)&&r.texParameteri(j,r.TEXTURE_WRAP_R,ee[H.wrapR]),r.texParameteri(j,r.TEXTURE_MAG_FILTER,ie[H.magFilter]),r.texParameteri(j,r.TEXTURE_MIN_FILTER,ie[H.minFilter])):(r.texParameteri(j,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(j,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE),(j===r.TEXTURE_3D||j===r.TEXTURE_2D_ARRAY)&&r.texParameteri(j,r.TEXTURE_WRAP_R,r.CLAMP_TO_EDGE),(H.wrapS!==vi||H.wrapT!==vi)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),r.texParameteri(j,r.TEXTURE_MAG_FILTER,L(H.magFilter)),r.texParameteri(j,r.TEXTURE_MIN_FILTER,L(H.minFilter)),H.minFilter!==Dn&&H.minFilter!==fn&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),H.compareFunction&&(r.texParameteri(j,r.TEXTURE_COMPARE_MODE,r.COMPARE_REF_TO_TEXTURE),r.texParameteri(j,r.TEXTURE_COMPARE_FUNC,ue[H.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){const we=e.get("EXT_texture_filter_anisotropic");if(H.magFilter===Dn||H.minFilter!==vu&&H.minFilter!==So||H.type===rs&&e.has("OES_texture_float_linear")===!1||a===!1&&H.type===Vl&&e.has("OES_texture_half_float_linear")===!1)return;(H.anisotropy>1||n.get(H).__currentAnisotropy)&&(r.texParameterf(j,we.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(H.anisotropy,i.getMaxAnisotropy())),n.get(H).__currentAnisotropy=H.anisotropy)}}function le(j,H){let ne=!1;j.__webglInit===void 0&&(j.__webglInit=!0,H.addEventListener("dispose",F));const we=H.source;let be=y.get(we);be===void 0&&(be={},y.set(we,be));const Me=G(H);if(Me!==j.__cacheKey){be[Me]===void 0&&(be[Me]={texture:r.createTexture(),usedTimes:0},o.memory.textures++,ne=!0),be[Me].usedTimes++;const Fe=be[j.__cacheKey];Fe!==void 0&&(be[j.__cacheKey].usedTimes--,Fe.usedTimes===0&&X(H)),j.__cacheKey=Me,j.__webglTexture=be[Me].texture}return ne}function Ae(j,H,ne){let we=r.TEXTURE_2D;(H.isDataArrayTexture||H.isCompressedArrayTexture)&&(we=r.TEXTURE_2D_ARRAY),H.isData3DTexture&&(we=r.TEXTURE_3D);const be=le(j,H),Me=H.source;t.bindTexture(we,j.__webglTexture,r.TEXTURE0+ne);const Fe=n.get(Me);if(Me.version!==Fe.__version||be===!0){t.activeTexture(r.TEXTURE0+ne),r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,H.flipY),r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,H.premultiplyAlpha),r.pixelStorei(r.UNPACK_ALIGNMENT,H.unpackAlignment),r.pixelStorei(r.UNPACK_COLORSPACE_CONVERSION_WEBGL,r.NONE);const Ue=b(H)&&E(H.image)===!1;let xe=w(H.image,Ue,!1,u);xe=He(H,xe);const Be=E(xe)||a,$e=s.convert(H.format,H.colorSpace);let Ve=s.convert(H.type),Oe=P(H.internalFormat,$e,Ve,H.colorSpace);ce(we,H,Be);let We;const nt=H.mipmaps,pt=a&&H.isVideoTexture!==!0,re=Fe.__version===void 0||be===!0,ze=C(H,xe,Be);if(H.isDepthTexture)Oe=r.DEPTH_COMPONENT,a?H.type===rs?Oe=r.DEPTH_COMPONENT32F:H.type===Ns?Oe=r.DEPTH_COMPONENT24:H.type===mo?Oe=r.DEPTH24_STENCIL8:Oe=r.DEPTH_COMPONENT16:H.type===rs&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),H.format===go&&Oe===r.DEPTH_COMPONENT&&H.type!==Kd&&H.type!==Ns&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),H.type=Ns,Ve=s.convert(H.type)),H.format===xa&&Oe===r.DEPTH_COMPONENT&&(Oe=r.DEPTH_STENCIL,H.type!==mo&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),H.type=mo,Ve=s.convert(H.type))),re&&(pt?t.texStorage2D(r.TEXTURE_2D,1,Oe,xe.width,xe.height):t.texImage2D(r.TEXTURE_2D,0,Oe,xe.width,xe.height,0,$e,Ve,null));else if(H.isDataTexture)if(nt.length>0&&Be){pt&&re&&t.texStorage2D(r.TEXTURE_2D,ze,Oe,nt[0].width,nt[0].height);for(let ve=0,Ge=nt.length;ve>=1,Ge>>=1}}else if(nt.length>0&&Be){pt&&re&&t.texStorage2D(r.TEXTURE_2D,ze,Oe,nt[0].width,nt[0].height);for(let ve=0,Ge=nt.length;ve0&&re++,t.texStorage2D(r.TEXTURE_CUBE_MAP,re,We,xe[0].width,xe[0].height));for(let ve=0;ve<6;ve++)if(Ue){nt?t.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+ve,0,0,0,xe[ve].width,xe[ve].height,Ve,Oe,xe[ve].data):t.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+ve,0,We,xe[ve].width,xe[ve].height,0,Ve,Oe,xe[ve].data);for(let Ge=0;Ge=r.TEXTURE_CUBE_MAP_POSITIVE_X&&be<=r.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&r.framebufferTexture2D(r.FRAMEBUFFER,we,be,n.get(ne).__webglTexture,0),t.bindFramebuffer(r.FRAMEBUFFER,null)}function z(j,H,ne){if(r.bindRenderbuffer(r.RENDERBUFFER,j),H.depthBuffer&&!H.stencilBuffer){let we=r.DEPTH_COMPONENT16;if(ne||Le(H)){const be=H.depthTexture;be&&be.isDepthTexture&&(be.type===rs?we=r.DEPTH_COMPONENT32F:be.type===Ns&&(we=r.DEPTH_COMPONENT24));const Me=Se(H);Le(H)?p.renderbufferStorageMultisampleEXT(r.RENDERBUFFER,Me,we,H.width,H.height):r.renderbufferStorageMultisample(r.RENDERBUFFER,Me,we,H.width,H.height)}else r.renderbufferStorage(r.RENDERBUFFER,we,H.width,H.height);r.framebufferRenderbuffer(r.FRAMEBUFFER,r.DEPTH_ATTACHMENT,r.RENDERBUFFER,j)}else if(H.depthBuffer&&H.stencilBuffer){const we=Se(H);ne&&Le(H)===!1?r.renderbufferStorageMultisample(r.RENDERBUFFER,we,r.DEPTH24_STENCIL8,H.width,H.height):Le(H)?p.renderbufferStorageMultisampleEXT(r.RENDERBUFFER,we,r.DEPTH24_STENCIL8,H.width,H.height):r.renderbufferStorage(r.RENDERBUFFER,r.DEPTH_STENCIL,H.width,H.height),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.DEPTH_STENCIL_ATTACHMENT,r.RENDERBUFFER,j)}else{const we=H.isWebGLMultipleRenderTargets===!0?H.texture:[H.texture];for(let be=0;be0&&Le(j)===!1){const Ue=Me?H:[H];ne.__webglMultisampledFramebuffer=r.createFramebuffer(),ne.__webglColorRenderbuffer=[],t.bindFramebuffer(r.FRAMEBUFFER,ne.__webglMultisampledFramebuffer);for(let xe=0;xe0&&Le(j)===!1){const H=j.isWebGLMultipleRenderTargets?j.texture:[j.texture],ne=j.width,we=j.height;let be=r.COLOR_BUFFER_BIT;const Me=[],Fe=j.stencilBuffer?r.DEPTH_STENCIL_ATTACHMENT:r.DEPTH_ATTACHMENT,Ue=n.get(j),xe=j.isWebGLMultipleRenderTargets===!0;if(xe)for(let Be=0;Be0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&H.__useRenderToTexture!==!1}function ge(j){const H=o.render.frame;v.get(j)!==H&&(v.set(j,H),j.update())}function He(j,H){const ne=j.colorSpace,we=j.format,be=j.type;return j.isCompressedTexture===!0||j.format===Dd||ne!==Br&&ne!==yo&&(ne===Mt?a===!1?e.has("EXT_sRGB")===!0&&we===Bi?(j.format=Dd,j.minFilter=fn,j.generateMipmaps=!1):H=ry.sRGBToLinear(H):(we!==Bi||be!==os)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",ne)),H}this.allocateTextureUnit=k,this.resetTextureUnits=O,this.setTexture2D=B,this.setTexture2DArray=D,this.setTexture3D=V,this.setTextureCube=Z,this.rebindTextures=se,this.setupRenderTarget=$,this.updateRenderTargetMipmap=Ie,this.updateMultisampleRenderTarget=de,this.setupDepthRenderbuffer=te,this.setupFrameBufferTexture=ae,this.useMultisampledRTT=Le}function gM(r,e,t){const n=t.isWebGL2;function i(s,o=yo){let a;if(s===os)return r.UNSIGNED_BYTE;if(s===qv)return r.UNSIGNED_SHORT_4_4_4_4;if(s===Zv)return r.UNSIGNED_SHORT_5_5_5_1;if(s===Nb)return r.BYTE;if(s===Fb)return r.SHORT;if(s===Kd)return r.UNSIGNED_SHORT;if(s===Yv)return r.INT;if(s===Ns)return r.UNSIGNED_INT;if(s===rs)return r.FLOAT;if(s===Vl)return n?r.HALF_FLOAT:(a=e.get("OES_texture_half_float"),a!==null?a.HALF_FLOAT_OES:null);if(s===kb)return r.ALPHA;if(s===Bi)return r.RGBA;if(s===zb)return r.LUMINANCE;if(s===Bb)return r.LUMINANCE_ALPHA;if(s===go)return r.DEPTH_COMPONENT;if(s===xa)return r.DEPTH_STENCIL;if(s===Dd)return a=e.get("EXT_sRGB"),a!==null?a.SRGB_ALPHA_EXT:null;if(s===Gb)return r.RED;if(s===Kv)return r.RED_INTEGER;if(s===Hb)return r.RG;if(s===$v)return r.RG_INTEGER;if(s===Jv)return r.RGBA_INTEGER;if(s===vd||s===yd||s===_d||s===xd)if(o===Mt)if(a=e.get("WEBGL_compressed_texture_s3tc_srgb"),a!==null){if(s===vd)return a.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(s===yd)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(s===_d)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(s===xd)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(a=e.get("WEBGL_compressed_texture_s3tc"),a!==null){if(s===vd)return a.COMPRESSED_RGB_S3TC_DXT1_EXT;if(s===yd)return a.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(s===_d)return a.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(s===xd)return a.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(s===F0||s===k0||s===z0||s===B0)if(a=e.get("WEBGL_compressed_texture_pvrtc"),a!==null){if(s===F0)return a.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(s===k0)return a.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(s===z0)return a.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(s===B0)return a.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(s===Vb)return a=e.get("WEBGL_compressed_texture_etc1"),a!==null?a.COMPRESSED_RGB_ETC1_WEBGL:null;if(s===G0||s===H0)if(a=e.get("WEBGL_compressed_texture_etc"),a!==null){if(s===G0)return o===Mt?a.COMPRESSED_SRGB8_ETC2:a.COMPRESSED_RGB8_ETC2;if(s===H0)return o===Mt?a.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:a.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(s===V0||s===W0||s===X0||s===j0||s===Y0||s===q0||s===Z0||s===K0||s===$0||s===J0||s===Q0||s===ev||s===tv||s===nv)if(a=e.get("WEBGL_compressed_texture_astc"),a!==null){if(s===V0)return o===Mt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:a.COMPRESSED_RGBA_ASTC_4x4_KHR;if(s===W0)return o===Mt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:a.COMPRESSED_RGBA_ASTC_5x4_KHR;if(s===X0)return o===Mt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:a.COMPRESSED_RGBA_ASTC_5x5_KHR;if(s===j0)return o===Mt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:a.COMPRESSED_RGBA_ASTC_6x5_KHR;if(s===Y0)return o===Mt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:a.COMPRESSED_RGBA_ASTC_6x6_KHR;if(s===q0)return o===Mt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:a.COMPRESSED_RGBA_ASTC_8x5_KHR;if(s===Z0)return o===Mt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:a.COMPRESSED_RGBA_ASTC_8x6_KHR;if(s===K0)return o===Mt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:a.COMPRESSED_RGBA_ASTC_8x8_KHR;if(s===$0)return o===Mt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:a.COMPRESSED_RGBA_ASTC_10x5_KHR;if(s===J0)return o===Mt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:a.COMPRESSED_RGBA_ASTC_10x6_KHR;if(s===Q0)return o===Mt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:a.COMPRESSED_RGBA_ASTC_10x8_KHR;if(s===ev)return o===Mt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:a.COMPRESSED_RGBA_ASTC_10x10_KHR;if(s===tv)return o===Mt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:a.COMPRESSED_RGBA_ASTC_12x10_KHR;if(s===nv)return o===Mt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:a.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(s===wd)if(a=e.get("EXT_texture_compression_bptc"),a!==null){if(s===wd)return o===Mt?a.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:a.COMPRESSED_RGBA_BPTC_UNORM_EXT}else return null;if(s===Wb||s===iv||s===rv||s===sv)if(a=e.get("EXT_texture_compression_rgtc"),a!==null){if(s===wd)return a.COMPRESSED_RED_RGTC1_EXT;if(s===iv)return a.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(s===rv)return a.COMPRESSED_RED_GREEN_RGTC2_EXT;if(s===sv)return a.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return s===mo?n?r.UNSIGNED_INT_24_8:(a=e.get("WEBGL_depth_texture"),a!==null?a.UNSIGNED_INT_24_8_WEBGL:null):r[s]!==void 0?r[s]:null}return{convert:i}}class vM extends zn{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}}class Ol extends jt{constructor(){super(),this.isGroup=!0,this.type="Group"}}const qD={type:"move"};class tg{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Ol,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 Ol,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new Y,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new Y),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Ol,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new Y,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new Y),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 i=null,s=null,o=null;const a=this._targetRay,l=this._grip,c=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(c&&e.hand){o=!0;for(const _ of e.hand.values()){const y=t.getJointPose(_,n),g=this._getHandJoint(c,_);y!==null&&(g.matrix.fromArray(y.transform.matrix),g.matrix.decompose(g.position,g.rotation,g.scale),g.matrixWorldNeedsUpdate=!0,g.jointRadius=y.radius),g.visible=y!==null}const u=c.joints["index-finger-tip"],h=c.joints["thumb-tip"],p=u.position.distanceTo(h.position),m=.02,v=.005;c.inputState.pinching&&p>m+v?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&p<=m-v&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,n),s!==null&&(l.matrix.fromArray(s.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,s.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(s.linearVelocity)):l.hasLinearVelocity=!1,s.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(s.angularVelocity)):l.hasAngularVelocity=!1));a!==null&&(i=t.getPose(e.targetRaySpace,n),i===null&&s!==null&&(i=s),i!==null&&(a.matrix.fromArray(i.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,i.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(i.linearVelocity)):a.hasLinearVelocity=!1,i.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(i.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(qD)))}return a!==null&&(a.visible=i!==null),l!==null&&(l.visible=s!==null),c!==null&&(c.visible=o!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const n=new Ol;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}class yM extends Sn{constructor(e,t,n,i,s,o,a,l,c,u){if(u=u!==void 0?u:go,u!==go&&u!==xa)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");n===void 0&&u===go&&(n=Ns),n===void 0&&u===xa&&(n=mo),super(null,i,s,o,a,l,u,n,c),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=a!==void 0?a:Dn,this.minFilter=l!==void 0?l:Dn,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}}class ZD extends Hs{constructor(e,t){super();const n=this;let i=null,s=1,o=null,a="local-floor",l=1,c=null,u=null,h=null,p=null,m=null,v=null;const _=t.getContextAttributes();let y=null,g=null;const x=[],w=[],E=new zn;E.layers.enable(1),E.viewport=new Xt;const b=new zn;b.layers.enable(2),b.viewport=new Xt;const M=[E,b],A=new vM;A.layers.enable(1),A.layers.enable(2);let P=null,C=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(D){let V=x[D];return V===void 0&&(V=new tg,x[D]=V),V.getTargetRaySpace()},this.getControllerGrip=function(D){let V=x[D];return V===void 0&&(V=new tg,x[D]=V),V.getGripSpace()},this.getHand=function(D){let V=x[D];return V===void 0&&(V=new tg,x[D]=V),V.getHandSpace()};function L(D){const V=w.indexOf(D.inputSource);if(V===-1)return;const Z=x[V];Z!==void 0&&(Z.update(D.inputSource,D.frame,c||o),Z.dispatchEvent({type:D.type,data:D.inputSource}))}function F(){i.removeEventListener("select",L),i.removeEventListener("selectstart",L),i.removeEventListener("selectend",L),i.removeEventListener("squeeze",L),i.removeEventListener("squeezestart",L),i.removeEventListener("squeezeend",L),i.removeEventListener("end",F),i.removeEventListener("inputsourceschange",N);for(let D=0;D=0&&(w[ee]=null,x[ee].disconnect(Z))}for(let V=0;V=w.length){w.push(Z),ee=ue;break}else if(w[ue]===null){w[ue]=Z,ee=ue;break}if(ee===-1)break}const ie=x[ee];ie&&ie.connect(Z)}}const I=new Y,X=new Y;function q(D,V,Z){I.setFromMatrixPosition(V.matrixWorld),X.setFromMatrixPosition(Z.matrixWorld);const ee=I.distanceTo(X),ie=V.projectionMatrix.elements,ue=Z.projectionMatrix.elements,ce=ie[14]/(ie[10]-1),le=ie[14]/(ie[10]+1),Ae=(ie[9]+1)/ie[5],Ee=(ie[9]-1)/ie[5],ae=(ie[8]-1)/ie[0],z=(ue[8]+1)/ue[0],oe=ce*ae,te=ce*z,se=ee/(-ae+z),$=se*-ae;V.matrixWorld.decompose(D.position,D.quaternion,D.scale),D.translateX($),D.translateZ(se),D.matrixWorld.compose(D.position,D.quaternion,D.scale),D.matrixWorldInverse.copy(D.matrixWorld).invert();const Ie=ce+se,de=le+se,Se=oe-$,Le=te+(ee-$),ge=Ae*le/de*Ie,He=Ee*le/de*Ie;D.projectionMatrix.makePerspective(Se,Le,ge,He,Ie,de),D.projectionMatrixInverse.copy(D.projectionMatrix).invert()}function W(D,V){V===null?D.matrixWorld.copy(D.matrix):D.matrixWorld.multiplyMatrices(V.matrixWorld,D.matrix),D.matrixWorldInverse.copy(D.matrixWorld).invert()}this.updateCamera=function(D){if(i===null)return;A.near=b.near=E.near=D.near,A.far=b.far=E.far=D.far,(P!==A.near||C!==A.far)&&(i.updateRenderState({depthNear:A.near,depthFar:A.far}),P=A.near,C=A.far);const V=D.parent,Z=A.cameras;W(A,V);for(let ee=0;ee0&&(y.alphaTest.value=g.alphaTest);const x=e.get(g).envMap;if(x&&(y.envMap.value=x,y.flipEnvMap.value=x.isCubeTexture&&x.isRenderTargetTexture===!1?-1:1,y.reflectivity.value=g.reflectivity,y.ior.value=g.ior,y.refractionRatio.value=g.refractionRatio),g.lightMap){y.lightMap.value=g.lightMap;const w=r.useLegacyLights===!0?Math.PI:1;y.lightMapIntensity.value=g.lightMapIntensity*w,t(g.lightMap,y.lightMapTransform)}g.aoMap&&(y.aoMap.value=g.aoMap,y.aoMapIntensity.value=g.aoMapIntensity,t(g.aoMap,y.aoMapTransform))}function o(y,g){y.diffuse.value.copy(g.color),y.opacity.value=g.opacity,g.map&&(y.map.value=g.map,t(g.map,y.mapTransform))}function a(y,g){y.dashSize.value=g.dashSize,y.totalSize.value=g.dashSize+g.gapSize,y.scale.value=g.scale}function l(y,g,x,w){y.diffuse.value.copy(g.color),y.opacity.value=g.opacity,y.size.value=g.size*x,y.scale.value=w*.5,g.map&&(y.map.value=g.map,t(g.map,y.uvTransform)),g.alphaMap&&(y.alphaMap.value=g.alphaMap,t(g.alphaMap,y.alphaMapTransform)),g.alphaTest>0&&(y.alphaTest.value=g.alphaTest)}function c(y,g){y.diffuse.value.copy(g.color),y.opacity.value=g.opacity,y.rotation.value=g.rotation,g.map&&(y.map.value=g.map,t(g.map,y.mapTransform)),g.alphaMap&&(y.alphaMap.value=g.alphaMap,t(g.alphaMap,y.alphaMapTransform)),g.alphaTest>0&&(y.alphaTest.value=g.alphaTest)}function u(y,g){y.specular.value.copy(g.specular),y.shininess.value=Math.max(g.shininess,1e-4)}function h(y,g){g.gradientMap&&(y.gradientMap.value=g.gradientMap)}function p(y,g){y.metalness.value=g.metalness,g.metalnessMap&&(y.metalnessMap.value=g.metalnessMap,t(g.metalnessMap,y.metalnessMapTransform)),y.roughness.value=g.roughness,g.roughnessMap&&(y.roughnessMap.value=g.roughnessMap,t(g.roughnessMap,y.roughnessMapTransform)),e.get(g).envMap&&(y.envMapIntensity.value=g.envMapIntensity)}function m(y,g,x){y.ior.value=g.ior,g.sheen>0&&(y.sheenColor.value.copy(g.sheenColor).multiplyScalar(g.sheen),y.sheenRoughness.value=g.sheenRoughness,g.sheenColorMap&&(y.sheenColorMap.value=g.sheenColorMap,t(g.sheenColorMap,y.sheenColorMapTransform)),g.sheenRoughnessMap&&(y.sheenRoughnessMap.value=g.sheenRoughnessMap,t(g.sheenRoughnessMap,y.sheenRoughnessMapTransform))),g.clearcoat>0&&(y.clearcoat.value=g.clearcoat,y.clearcoatRoughness.value=g.clearcoatRoughness,g.clearcoatMap&&(y.clearcoatMap.value=g.clearcoatMap,t(g.clearcoatMap,y.clearcoatMapTransform)),g.clearcoatRoughnessMap&&(y.clearcoatRoughnessMap.value=g.clearcoatRoughnessMap,t(g.clearcoatRoughnessMap,y.clearcoatRoughnessMapTransform)),g.clearcoatNormalMap&&(y.clearcoatNormalMap.value=g.clearcoatNormalMap,t(g.clearcoatNormalMap,y.clearcoatNormalMapTransform),y.clearcoatNormalScale.value.copy(g.clearcoatNormalScale),g.side===yi&&y.clearcoatNormalScale.value.negate())),g.iridescence>0&&(y.iridescence.value=g.iridescence,y.iridescenceIOR.value=g.iridescenceIOR,y.iridescenceThicknessMinimum.value=g.iridescenceThicknessRange[0],y.iridescenceThicknessMaximum.value=g.iridescenceThicknessRange[1],g.iridescenceMap&&(y.iridescenceMap.value=g.iridescenceMap,t(g.iridescenceMap,y.iridescenceMapTransform)),g.iridescenceThicknessMap&&(y.iridescenceThicknessMap.value=g.iridescenceThicknessMap,t(g.iridescenceThicknessMap,y.iridescenceThicknessMapTransform))),g.transmission>0&&(y.transmission.value=g.transmission,y.transmissionSamplerMap.value=x.texture,y.transmissionSamplerSize.value.set(x.width,x.height),g.transmissionMap&&(y.transmissionMap.value=g.transmissionMap,t(g.transmissionMap,y.transmissionMapTransform)),y.thickness.value=g.thickness,g.thicknessMap&&(y.thicknessMap.value=g.thicknessMap,t(g.thicknessMap,y.thicknessMapTransform)),y.attenuationDistance.value=g.attenuationDistance,y.attenuationColor.value.copy(g.attenuationColor)),g.anisotropy>0&&(y.anisotropyVector.value.set(g.anisotropy*Math.cos(g.anisotropyRotation),g.anisotropy*Math.sin(g.anisotropyRotation)),g.anisotropyMap&&(y.anisotropyMap.value=g.anisotropyMap,t(g.anisotropyMap,y.anisotropyMapTransform))),y.specularIntensity.value=g.specularIntensity,y.specularColor.value.copy(g.specularColor),g.specularColorMap&&(y.specularColorMap.value=g.specularColorMap,t(g.specularColorMap,y.specularColorMapTransform)),g.specularIntensityMap&&(y.specularIntensityMap.value=g.specularIntensityMap,t(g.specularIntensityMap,y.specularIntensityMapTransform))}function v(y,g){g.matcap&&(y.matcap.value=g.matcap)}function _(y,g){const x=e.get(g).light;y.referencePosition.value.setFromMatrixPosition(x.matrixWorld),y.nearDistance.value=x.shadow.camera.near,y.farDistance.value=x.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:i}}function $D(r,e,t,n){let i={},s={},o=[];const a=t.isWebGL2?r.getParameter(r.MAX_UNIFORM_BUFFER_BINDINGS):0;function l(x,w){const E=w.program;n.uniformBlockBinding(x,E)}function c(x,w){let E=i[x.id];E===void 0&&(v(x),E=u(x),i[x.id]=E,x.addEventListener("dispose",y));const b=w.program;n.updateUBOMapping(x,b);const M=e.render.frame;s[x.id]!==M&&(p(x),s[x.id]=M)}function u(x){const w=h();x.__bindingPointIndex=w;const E=r.createBuffer(),b=x.__size,M=x.usage;return r.bindBuffer(r.UNIFORM_BUFFER,E),r.bufferData(r.UNIFORM_BUFFER,b,M),r.bindBuffer(r.UNIFORM_BUFFER,null),r.bindBufferBase(r.UNIFORM_BUFFER,w,E),E}function h(){for(let x=0;x0){M=E%b;const N=b-M;M!==0&&N-L.boundary<0&&(E+=b-M,C.__offset=E)}E+=L.storage}return M=E%b,M>0&&(E+=b-M),x.__size=E,x.__cache={},this}function _(x){const w={boundary:0,storage:0};return typeof x=="number"?(w.boundary=4,w.storage=4):x.isVector2?(w.boundary=8,w.storage=8):x.isVector3||x.isColor?(w.boundary=16,w.storage=12):x.isVector4?(w.boundary=16,w.storage=16):x.isMatrix3?(w.boundary=48,w.storage=48):x.isMatrix4?(w.boundary=64,w.storage=64):x.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",x),w}function y(x){const w=x.target;w.removeEventListener("dispose",y);const E=o.indexOf(w.__bindingPointIndex);o.splice(E,1),r.deleteBuffer(i[w.id]),delete i[w.id],delete s[w.id]}function g(){for(const x in i)r.deleteBuffer(i[x]);o=[],i={},s={}}return{bind:l,update:c,dispose:g}}function JD(){const r=Fu("canvas");return r.style.display="block",r}class uy{constructor(e={}){const{canvas:t=JD(),context:n=null,depth:i=!0,stencil:s=!0,alpha:o=!1,antialias:a=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:u="default",failIfMajorPerformanceCaveat:h=!1}=e;this.isWebGLRenderer=!0;let p;n!==null?p=n.getContextAttributes().alpha:p=o;const m=new Uint32Array(4),v=new Int32Array(4);let _=null,y=null;const g=[],x=[];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=Mt,this.useLegacyLights=!0,this.toneMapping=zr,this.toneMappingExposure=1;const w=this;let E=!1,b=0,M=0,A=null,P=-1,C=null;const L=new Xt,F=new Xt;let N=null;const I=new Ke(0);let X=0,q=t.width,W=t.height,O=1,k=null,G=null;const B=new Xt(0,0,q,W),D=new Xt(0,0,q,W);let V=!1;const Z=new oh;let ee=!1,ie=!1,ue=null;const ce=new yt,le=new De,Ae=new Y,Ee={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function ae(){return A===null?O:1}let z=n;function oe(J,me){for(let Re=0;Re0?y=x[x.length-1]:y=null,g.pop(),g.length>0?_=g[g.length-1]:_=null};function li(J,me,Re,pe){if(J.visible===!1)return;if(J.layers.test(me.layers)){if(J.isGroup)Re=J.renderOrder;else if(J.isLOD)J.autoUpdate===!0&&J.update(me);else if(J.isLight)y.pushLight(J),J.castShadow&&y.pushShadow(J);else if(J.isSprite){if(!J.frustumCulled||Z.intersectsSprite(J)){pe&&Ae.setFromMatrixPosition(J.matrixWorld).applyMatrix4(ce);const lt=H.update(J),ct=J.material;ct.visible&&_.push(J,lt,ct,Re,Ae.z,null)}}else if((J.isMesh||J.isLine||J.isPoints)&&(!J.frustumCulled||Z.intersectsObject(J))){const lt=H.update(J),ct=J.material;if(pe&&(J.boundingSphere!==void 0?(J.boundingSphere===null&&J.computeBoundingSphere(),Ae.copy(J.boundingSphere.center)):(lt.boundingSphere===null&<.computeBoundingSphere(),Ae.copy(lt.boundingSphere.center)),Ae.applyMatrix4(J.matrixWorld).applyMatrix4(ce)),Array.isArray(ct)){const dt=lt.groups;for(let wt=0,ke=dt.length;wt0&&Bt(Pe,it,me,Re),pe&&$.viewport(L.copy(pe)),Pe.length>0&&sn(Pe,me,Re),it.length>0&&sn(it,me,Re),lt.length>0&&sn(lt,me,Re),$.buffers.depth.setTest(!0),$.buffers.depth.setMask(!0),$.buffers.color.setMask(!0),$.setPolygonOffset(!1)}function Bt(J,me,Re,pe){const Pe=se.isWebGL2;ue===null&&(ue=new Gr(1,1,{generateMipmaps:!0,type:te.has("EXT_color_buffer_half_float")?Vl:os,minFilter:So,samples:Pe?4:0})),w.getDrawingBufferSize(le),Pe?ue.setSize(le.x,le.y):ue.setSize(Ud(le.x),Ud(le.y));const it=w.getRenderTarget();w.setRenderTarget(ue),w.getClearColor(I),X=w.getClearAlpha(),X<1&&w.setClearColor(16777215,.5),w.clear();const lt=w.toneMapping;w.toneMapping=zr,sn(J,Re,pe),Se.updateMultisampleRenderTarget(ue),Se.updateRenderTargetMipmap(ue);let ct=!1;for(let dt=0,wt=me.length;dt0),ut=!!Re.morphAttributes.position,Jt=!!Re.morphAttributes.normal,Gt=!!Re.morphAttributes.color,Yn=pe.toneMapped?w.toneMapping:zr,ci=Re.morphAttributes.position||Re.morphAttributes.normal||Re.morphAttributes.color,qt=ci!==void 0?ci.length:0,mt=de.get(pe),kt=y.state.lights;if(ee===!0&&(ie===!0||J!==C)){const Un=J===C&&pe.id===P;Fe.setState(pe,J,Un)}let gt=!1;pe.version===mt.__version?(mt.needsLights&&mt.lightsStateVersion!==kt.state.version||mt.outputColorSpace!==ct||Pe.isInstancedMesh&&mt.instancing===!1||!Pe.isInstancedMesh&&mt.instancing===!0||Pe.isSkinnedMesh&&mt.skinning===!1||!Pe.isSkinnedMesh&&mt.skinning===!0||mt.envMap!==dt||pe.fog===!0&&mt.fog!==it||mt.numClippingPlanes!==void 0&&(mt.numClippingPlanes!==Fe.numPlanes||mt.numIntersection!==Fe.numIntersection)||mt.vertexAlphas!==wt||mt.vertexTangents!==ke||mt.morphTargets!==ut||mt.morphNormals!==Jt||mt.morphColors!==Gt||mt.toneMapping!==Yn||se.isWebGL2===!0&&mt.morphTargetsCount!==qt)&&(gt=!0):(gt=!0,mt.__version=pe.version);let Cn=mt.currentProgram;gt===!0&&(Cn=tn(pe,me,Pe));let En=!1,cn=!1,Ii=!1;const Qt=Cn.getUniforms(),on=mt.uniforms;if($.useProgram(Cn.program)&&(En=!0,cn=!0,Ii=!0),pe.id!==P&&(P=pe.id,cn=!0),En||C!==J){if(Qt.setValue(z,"projectionMatrix",J.projectionMatrix),se.logarithmicDepthBuffer&&Qt.setValue(z,"logDepthBufFC",2/(Math.log(J.far+1)/Math.LN2)),C!==J&&(C=J,cn=!0,Ii=!0),pe.isShaderMaterial||pe.isMeshPhongMaterial||pe.isMeshToonMaterial||pe.isMeshStandardMaterial||pe.envMap){const Un=Qt.map.cameraPosition;Un!==void 0&&Un.setValue(z,Ae.setFromMatrixPosition(J.matrixWorld))}(pe.isMeshPhongMaterial||pe.isMeshToonMaterial||pe.isMeshLambertMaterial||pe.isMeshBasicMaterial||pe.isMeshStandardMaterial||pe.isShaderMaterial)&&Qt.setValue(z,"isOrthographic",J.isOrthographicCamera===!0),(pe.isMeshPhongMaterial||pe.isMeshToonMaterial||pe.isMeshLambertMaterial||pe.isMeshBasicMaterial||pe.isMeshStandardMaterial||pe.isShaderMaterial||pe.isShadowMaterial||Pe.isSkinnedMesh)&&Qt.setValue(z,"viewMatrix",J.matrixWorldInverse)}if(Pe.isSkinnedMesh){Qt.setOptional(z,Pe,"bindMatrix"),Qt.setOptional(z,Pe,"bindMatrixInverse");const Un=Pe.skeleton;Un&&(se.floatVertexTextures?(Un.boneTexture===null&&Un.computeBoneTexture(),Qt.setValue(z,"boneTexture",Un.boneTexture,Se),Qt.setValue(z,"boneTextureSize",Un.boneTextureSize)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}const xi=Re.morphAttributes;if((xi.position!==void 0||xi.normal!==void 0||xi.color!==void 0&&se.isWebGL2===!0)&&Be.update(Pe,Re,Cn),(cn||mt.receiveShadow!==Pe.receiveShadow)&&(mt.receiveShadow=Pe.receiveShadow,Qt.setValue(z,"receiveShadow",Pe.receiveShadow)),pe.isMeshGouraudMaterial&&pe.envMap!==null&&(on.envMap.value=dt,on.flipEnvMap.value=dt.isCubeTexture&&dt.isRenderTargetTexture===!1?-1:1),cn&&(Qt.setValue(z,"toneMappingExposure",w.toneMappingExposure),mt.needsLights&&sr(on,Ii),it&&pe.fog===!0&&we.refreshFogUniforms(on,it),we.refreshMaterialUniforms(on,pe,O,W,ue),bd.upload(z,mt.uniformsList,on,Se)),pe.isShaderMaterial&&pe.uniformsNeedUpdate===!0&&(bd.upload(z,mt.uniformsList,on,Se),pe.uniformsNeedUpdate=!1),pe.isSpriteMaterial&&Qt.setValue(z,"center",Pe.center),Qt.setValue(z,"modelViewMatrix",Pe.modelViewMatrix),Qt.setValue(z,"normalMatrix",Pe.normalMatrix),Qt.setValue(z,"modelMatrix",Pe.matrixWorld),pe.isShaderMaterial||pe.isRawShaderMaterial){const Un=pe.uniformsGroups;for(let Xr=0,jr=Un.length;Xr0&&Se.useMultisampledRTT(J)===!1?Pe=de.get(J).__webglMultisampledFramebuffer:Pe=ke,L.copy(J.viewport),F.copy(J.scissor),N=J.scissorTest}else L.copy(B).multiplyScalar(O).floor(),F.copy(D).multiplyScalar(O).floor(),N=V;if($.bindFramebuffer(z.FRAMEBUFFER,Pe)&&se.drawBuffers&&pe&&$.drawBuffers(J,Pe),$.viewport(L),$.scissor(F),$.setScissorTest(N),it){const dt=de.get(J.texture);z.framebufferTexture2D(z.FRAMEBUFFER,z.COLOR_ATTACHMENT0,z.TEXTURE_CUBE_MAP_POSITIVE_X+me,dt.__webglTexture,Re)}else if(lt){const dt=de.get(J.texture),wt=me||0;z.framebufferTextureLayer(z.FRAMEBUFFER,z.COLOR_ATTACHMENT0,dt.__webglTexture,Re||0,wt)}P=-1},this.readRenderTargetPixels=function(J,me,Re,pe,Pe,it,lt){if(!(J&&J.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let ct=de.get(J).__webglFramebuffer;if(J.isWebGLCubeRenderTarget&<!==void 0&&(ct=ct[lt]),ct){$.bindFramebuffer(z.FRAMEBUFFER,ct);try{const dt=J.texture,wt=dt.format,ke=dt.type;if(wt!==Bi&&Oe.convert(wt)!==z.getParameter(z.IMPLEMENTATION_COLOR_READ_FORMAT)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}const ut=ke===Vl&&(te.has("EXT_color_buffer_half_float")||se.isWebGL2&&te.has("EXT_color_buffer_float"));if(ke!==os&&Oe.convert(ke)!==z.getParameter(z.IMPLEMENTATION_COLOR_READ_TYPE)&&!(ke===rs&&(se.isWebGL2||te.has("OES_texture_float")||te.has("WEBGL_color_buffer_float")))&&!ut){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}me>=0&&me<=J.width-pe&&Re>=0&&Re<=J.height-Pe&&z.readPixels(me,Re,pe,Pe,Oe.convert(wt),Oe.convert(ke),it)}finally{const dt=A!==null?de.get(A).__webglFramebuffer:null;$.bindFramebuffer(z.FRAMEBUFFER,dt)}}},this.copyFramebufferToTexture=function(J,me,Re=0){const pe=Math.pow(2,-Re),Pe=Math.floor(me.image.width*pe),it=Math.floor(me.image.height*pe);Se.setTexture2D(me,0),z.copyTexSubImage2D(z.TEXTURE_2D,Re,0,0,J.x,J.y,Pe,it),$.unbindTexture()},this.copyTextureToTexture=function(J,me,Re,pe=0){const Pe=me.image.width,it=me.image.height,lt=Oe.convert(Re.format),ct=Oe.convert(Re.type);Se.setTexture2D(Re,0),z.pixelStorei(z.UNPACK_FLIP_Y_WEBGL,Re.flipY),z.pixelStorei(z.UNPACK_PREMULTIPLY_ALPHA_WEBGL,Re.premultiplyAlpha),z.pixelStorei(z.UNPACK_ALIGNMENT,Re.unpackAlignment),me.isDataTexture?z.texSubImage2D(z.TEXTURE_2D,pe,J.x,J.y,Pe,it,lt,ct,me.image.data):me.isCompressedTexture?z.compressedTexSubImage2D(z.TEXTURE_2D,pe,J.x,J.y,me.mipmaps[0].width,me.mipmaps[0].height,lt,me.mipmaps[0].data):z.texSubImage2D(z.TEXTURE_2D,pe,J.x,J.y,lt,ct,me.image),pe===0&&Re.generateMipmaps&&z.generateMipmap(z.TEXTURE_2D),$.unbindTexture()},this.copyTextureToTexture3D=function(J,me,Re,pe,Pe=0){if(w.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}const it=J.max.x-J.min.x+1,lt=J.max.y-J.min.y+1,ct=J.max.z-J.min.z+1,dt=Oe.convert(pe.format),wt=Oe.convert(pe.type);let ke;if(pe.isData3DTexture)Se.setTexture3D(pe,0),ke=z.TEXTURE_3D;else if(pe.isDataArrayTexture)Se.setTexture2DArray(pe,0),ke=z.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}z.pixelStorei(z.UNPACK_FLIP_Y_WEBGL,pe.flipY),z.pixelStorei(z.UNPACK_PREMULTIPLY_ALPHA_WEBGL,pe.premultiplyAlpha),z.pixelStorei(z.UNPACK_ALIGNMENT,pe.unpackAlignment);const ut=z.getParameter(z.UNPACK_ROW_LENGTH),Jt=z.getParameter(z.UNPACK_IMAGE_HEIGHT),Gt=z.getParameter(z.UNPACK_SKIP_PIXELS),Yn=z.getParameter(z.UNPACK_SKIP_ROWS),ci=z.getParameter(z.UNPACK_SKIP_IMAGES),qt=Re.isCompressedTexture?Re.mipmaps[0]:Re.image;z.pixelStorei(z.UNPACK_ROW_LENGTH,qt.width),z.pixelStorei(z.UNPACK_IMAGE_HEIGHT,qt.height),z.pixelStorei(z.UNPACK_SKIP_PIXELS,J.min.x),z.pixelStorei(z.UNPACK_SKIP_ROWS,J.min.y),z.pixelStorei(z.UNPACK_SKIP_IMAGES,J.min.z),Re.isDataTexture||Re.isData3DTexture?z.texSubImage3D(ke,Pe,me.x,me.y,me.z,it,lt,ct,dt,wt,qt.data):Re.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),z.compressedTexSubImage3D(ke,Pe,me.x,me.y,me.z,it,lt,ct,dt,qt.data)):z.texSubImage3D(ke,Pe,me.x,me.y,me.z,it,lt,ct,dt,wt,qt),z.pixelStorei(z.UNPACK_ROW_LENGTH,ut),z.pixelStorei(z.UNPACK_IMAGE_HEIGHT,Jt),z.pixelStorei(z.UNPACK_SKIP_PIXELS,Gt),z.pixelStorei(z.UNPACK_SKIP_ROWS,Yn),z.pixelStorei(z.UNPACK_SKIP_IMAGES,ci),Pe===0&&pe.generateMipmaps&&z.generateMipmap(ke),$.unbindTexture()},this.initTexture=function(J){J.isCubeTexture?Se.setTextureCube(J,0):J.isData3DTexture?Se.setTexture3D(J,0):J.isDataArrayTexture||J.isCompressedArrayTexture?Se.setTexture2DArray(J,0):Se.setTexture2D(J,0),$.unbindTexture()},this.resetState=function(){b=0,M=0,A=null,$.reset(),We.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return ss}get physicallyCorrectLights(){return console.warn("THREE.WebGLRenderer: the property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead."),!this.useLegacyLights}set physicallyCorrectLights(e){console.warn("THREE.WebGLRenderer: the property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead."),this.useLegacyLights=!e}get outputEncoding(){return console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace===Mt?vo:ey}set outputEncoding(e){console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace=e===vo?Mt:Br}}class _M extends uy{}_M.prototype.isWebGL1Renderer=!0;class np{constructor(e,t=25e-5){this.isFogExp2=!0,this.name="",this.color=new Ke(e),this.density=t}clone(){return new np(this.color,this.density)}toJSON(){return{type:"FogExp2",color:this.color.getHex(),density:this.density}}}class ip{constructor(e,t=1,n=1e3){this.isFog=!0,this.name="",this.color=new Ke(e),this.near=t,this.far=n}clone(){return new ip(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}}class ku extends jt{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,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,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}}class rp{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=Ou,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=er()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let i=0,s=this.stride;ie.far||t.push({distance:l,point:Dc.clone(),uv:zi.getInterpolation(Dc,Lf,Oc,If,A1,ng,C1,new De),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 Df(r,e,t,n,i,s){ml.subVectors(r,t).addScalar(.5).multiply(n),i!==void 0?(Uc.x=s*ml.x-i*ml.y,Uc.y=i*ml.x+s*ml.y):Uc.copy(ml),r.copy(e),r.x+=Uc.x,r.y+=Uc.y,r.applyMatrix4(xM)}const Uf=new Y,R1=new Y;class SM extends jt{constructor(){super(),this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]},isLOD:{value:!0}}),this.autoUpdate=!0}copy(e){super.copy(e,!1);const t=e.levels;for(let n=0,i=t.length;n0){let n,i;for(n=1,i=t.length;n0){Uf.setFromMatrixPosition(this.matrixWorld);const i=e.ray.origin.distanceTo(Uf);this.getObjectForDistance(i).raycast(e,t)}}update(e){const t=this.levels;if(t.length>1){Uf.setFromMatrixPosition(e.matrixWorld),R1.setFromMatrixPosition(this.matrixWorld);const n=Uf.distanceTo(R1)/e.zoom;t[0].object.visible=!0;let i,s;for(i=1,s=t.length;i=o)t[i-1].object.visible=!1,t[i].object.visible=!0;else break}for(this._currentLevel=i-1;il)continue;p.applyMatrix4(this.matrixWorld);const P=e.ray.origin.distanceTo(p);Pe.far||t.push({distance:P,point:h.clone().applyMatrix4(this.matrixWorld),index:w,face:null,faceIndex:null,object:this})}}else{const g=Math.max(0,o.start),x=Math.min(y.count,o.start+o.count);for(let w=g,E=x-1;wl)continue;p.applyMatrix4(this.matrixWorld);const M=e.ray.origin.distanceTo(p);Me.far||t.push({distance:M,point:h.clone().applyMatrix4(this.matrixWorld),index:w,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=i.length;s0){const i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=i.length;si.far)return;s.push({distance:c,distanceToRay:Math.sqrt(a),point:l,index:e,face:null,object:o})}}class nU extends Sn{constructor(e,t,n,i,s,o,a,l,c){super(e,t,n,i,s,o,a,l,c),this.isVideoTexture=!0,this.minFilter=o!==void 0?o:fn,this.magFilter=s!==void 0?s:fn,this.generateMipmaps=!1;const u=this;function h(){u.needsUpdate=!0,e.requestVideoFrameCallback(h)}"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback(h)}clone(){return new this.constructor(this.image).copy(this)}update(){const e=this.image;"requestVideoFrameCallback"in e===!1&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}class iU extends Sn{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=Dn,this.minFilter=Dn,this.generateMipmaps=!1,this.needsUpdate=!0}}class py extends Sn{constructor(e,t,n,i,s,o,a,l,c,u,h,p){super(null,o,a,l,c,u,i,s,h,p),this.isCompressedTexture=!0,this.image={width:t,height:n},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}}class rU extends py{constructor(e,t,n,i,s,o){super(e,t,n,s,o),this.isCompressedArrayTexture=!0,this.image.depth=i,this.wrapR=vi}}class sU extends Sn{constructor(e,t,n,i,s,o,a,l,c){super(e,t,n,i,s,o,a,l,c),this.isCanvasTexture=!0,this.needsUpdate=!0}}class Vr{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){const n=this.getUtoTmapping(e);return this.getPoint(n,t)}getPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return t}getSpacedPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPointAt(n/e));return t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const t=[];let n,i=this.getPoint(0),s=0;t.push(0);for(let o=1;o<=e;o++)n=this.getPoint(o/e),s+=n.distanceTo(i),t.push(s),i=n;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){const n=this.getLengths();let i=0;const s=n.length;let o;t?o=t:o=e*n[s-1];let a=0,l=s-1,c;for(;a<=l;)if(i=Math.floor(a+(l-a)/2),c=n[i]-o,c<0)a=i+1;else if(c>0)l=i-1;else{l=i;break}if(i=l,n[i]===o)return i/(s-1);const u=n[i],p=n[i+1]-u,m=(o-u)/p;return(i+m)/(s-1)}getTangent(e,t){let i=e-1e-4,s=e+1e-4;i<0&&(i=0),s>1&&(s=1);const o=this.getPoint(i),a=this.getPoint(s),l=t||(o.isVector2?new De:new Y);return l.copy(a).sub(o).normalize(),l}getTangentAt(e,t){const n=this.getUtoTmapping(e);return this.getTangent(n,t)}computeFrenetFrames(e,t){const n=new Y,i=[],s=[],o=[],a=new Y,l=new yt;for(let m=0;m<=e;m++){const v=m/e;i[m]=this.getTangentAt(v,new Y)}s[0]=new Y,o[0]=new Y;let c=Number.MAX_VALUE;const u=Math.abs(i[0].x),h=Math.abs(i[0].y),p=Math.abs(i[0].z);u<=c&&(c=u,n.set(1,0,0)),h<=c&&(c=h,n.set(0,1,0)),p<=c&&n.set(0,0,1),a.crossVectors(i[0],n).normalize(),s[0].crossVectors(i[0],a),o[0].crossVectors(i[0],s[0]);for(let m=1;m<=e;m++){if(s[m]=s[m-1].clone(),o[m]=o[m-1].clone(),a.crossVectors(i[m-1],i[m]),a.length()>Number.EPSILON){a.normalize();const v=Math.acos(Tn(i[m-1].dot(i[m]),-1,1));s[m].applyMatrix4(l.makeRotationAxis(a,v))}o[m].crossVectors(i[m],s[m])}if(t===!0){let m=Math.acos(Tn(s[0].dot(s[e]),-1,1));m/=e,i[0].dot(a.crossVectors(s[0],s[e]))>0&&(m=-m);for(let v=1;v<=e;v++)s[v].applyMatrix4(l.makeRotationAxis(i[v],m*v)),o[v].crossVectors(i[v],s[v])}return{tangents:i,normals:s,binormals:o}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.6,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class op extends Vr{constructor(e=0,t=0,n=1,i=1,s=0,o=Math.PI*2,a=!1,l=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=n,this.yRadius=i,this.aStartAngle=s,this.aEndAngle=o,this.aClockwise=a,this.aRotation=l}getPoint(e,t){const n=t||new De,i=Math.PI*2;let s=this.aEndAngle-this.aStartAngle;const o=Math.abs(s)i;)s-=i;s0?0:(Math.floor(Math.abs(a)/s)+1)*s:l===0&&a===s-1&&(a=s-2,l=1);let c,u;this.closed||a>0?c=i[(a-1)%s]:(zf.subVectors(i[0],i[1]).add(i[0]),c=zf);const h=i[a%s],p=i[(a+1)%s];if(this.closed||a+2i.length-2?i.length-1:o+1],h=i[o>i.length-3?i.length-1:o+2];return n.set(X1(a,l.x,c.x,u.x,h.x),X1(a,l.y,c.y,u.y,h.y)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t=n){const o=i[s]-n,a=this.curves[s],l=a.getLength(),c=l===0?0:1-o/l;return a.getPointAt(c,t)}s++}return null}getLength(){const e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const e=[];let t=0;for(let n=0,i=this.curves.length;n1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,n=e.curves.length;t0){const h=c.getPoint(0);h.equals(this.currentPoint)||this.lineTo(h.x,h.y)}this.curves.push(c);const u=c.getPoint(1);return this.currentPoint.copy(u),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){const e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}}class ah extends Tt{constructor(e=[new De(0,-.5),new De(.5,0),new De(0,.5)],t=12,n=0,i=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:n,phiLength:i},t=Math.floor(t),i=Tn(i,0,Math.PI*2);const s=[],o=[],a=[],l=[],c=[],u=1/t,h=new Y,p=new De,m=new Y,v=new Y,_=new Y;let y=0,g=0;for(let x=0;x<=e.length-1;x++)switch(x){case 0:y=e[x+1].x-e[x].x,g=e[x+1].y-e[x].y,m.x=g*1,m.y=-y,m.z=g*0,_.copy(m),m.normalize(),l.push(m.x,m.y,m.z);break;case e.length-1:l.push(_.x,_.y,_.z);break;default:y=e[x+1].x-e[x].x,g=e[x+1].y-e[x].y,m.x=g*1,m.y=-y,m.z=g*0,v.copy(m),m.x+=_.x,m.y+=_.y,m.z+=_.z,m.normalize(),l.push(m.x,m.y,m.z),_.copy(v)}for(let x=0;x<=t;x++){const w=n+x*u*i,E=Math.sin(w),b=Math.cos(w);for(let M=0;M<=e.length-1;M++){h.x=e[M].x*E,h.y=e[M].y,h.z=e[M].x*b,o.push(h.x,h.y,h.z),p.x=x/t,p.y=M/(e.length-1),a.push(p.x,p.y);const A=l[3*M+0]*E,P=l[3*M+1],C=l[3*M+0]*b;c.push(A,P,C)}}for(let x=0;x0&&w(!0),t>0&&w(!1)),this.setIndex(u),this.setAttribute("position",new st(h,3)),this.setAttribute("normal",new st(p,3)),this.setAttribute("uv",new st(m,2));function x(){const E=new Y,b=new Y;let M=0;const A=(t-e)/n;for(let P=0;P<=s;P++){const C=[],L=P/s,F=L*(t-e)+e;for(let N=0;N<=i;N++){const I=N/i,X=I*l+a,q=Math.sin(X),W=Math.cos(X);b.x=F*q,b.y=-L*n+y,b.z=F*W,h.push(b.x,b.y,b.z),E.set(q,A,W).normalize(),p.push(E.x,E.y,E.z),m.push(I,1-L),C.push(v++)}_.push(C)}for(let P=0;P.9&&A<.1&&(w<.2&&(o[x+0]+=1),E<.2&&(o[x+2]+=1),b<.2&&(o[x+4]+=1))}}function p(x){s.push(x.x,x.y,x.z)}function m(x,w){const E=x*3;w.x=e[E+0],w.y=e[E+1],w.z=e[E+2]}function v(){const x=new Y,w=new Y,E=new Y,b=new Y,M=new De,A=new De,P=new De;for(let C=0,L=0;C80*t){a=c=r[0],l=u=r[1];for(let v=t;vc&&(c=h),p>u&&(u=p);m=Math.max(c-a,u-l),m=m!==0?32767/m:0}return Bu(s,o,t,a,l,m,0),o}};function IM(r,e,t,n,i){let s,o;if(i===RU(r,e,t,n)>0)for(s=e;s=e;s-=n)o=j1(s,r[s],r[s+1],o);return o&&dp(o,o.next)&&(Hu(o),o=o.next),o}function Ea(r,e){if(!r)return r;e||(e=r);let t=r,n;do if(n=!1,!t.steiner&&(dp(t,t.next)||yn(t.prev,t,t.next)===0)){if(Hu(t),t=e=t.prev,t===t.next)break;n=!0}else t=t.next;while(n||t!==e);return e}function Bu(r,e,t,n,i,s,o){if(!r)return;!o&&s&&EU(r,n,i,s);let a=r,l,c;for(;r.prev!==r.next;){if(l=r.prev,c=r.next,s?mU(r,n,i,s):pU(r)){e.push(l.i/t|0),e.push(r.i/t|0),e.push(c.i/t|0),Hu(r),r=c.next,a=c.next;continue}if(r=c,r===a){o?o===1?(r=gU(Ea(r),e,t),Bu(r,e,t,n,i,s,2)):o===2&&vU(r,e,t,n,i,s):Bu(Ea(r),e,t,n,i,s,1);break}}}function pU(r){const e=r.prev,t=r,n=r.next;if(yn(e,t,n)>=0)return!1;const i=e.x,s=t.x,o=n.x,a=e.y,l=t.y,c=n.y,u=is?i>o?i:o:s>o?s:o,m=a>l?a>c?a:c:l>c?l:c;let v=n.next;for(;v!==e;){if(v.x>=u&&v.x<=p&&v.y>=h&&v.y<=m&&Nl(i,a,s,l,o,c,v.x,v.y)&&yn(v.prev,v,v.next)>=0)return!1;v=v.next}return!0}function mU(r,e,t,n){const i=r.prev,s=r,o=r.next;if(yn(i,s,o)>=0)return!1;const a=i.x,l=s.x,c=o.x,u=i.y,h=s.y,p=o.y,m=al?a>c?a:c:l>c?l:c,y=u>h?u>p?u:p:h>p?h:p,g=hv(m,v,e,t,n),x=hv(_,y,e,t,n);let w=r.prevZ,E=r.nextZ;for(;w&&w.z>=g&&E&&E.z<=x;){if(w.x>=m&&w.x<=_&&w.y>=v&&w.y<=y&&w!==i&&w!==o&&Nl(a,u,l,h,c,p,w.x,w.y)&&yn(w.prev,w,w.next)>=0||(w=w.prevZ,E.x>=m&&E.x<=_&&E.y>=v&&E.y<=y&&E!==i&&E!==o&&Nl(a,u,l,h,c,p,E.x,E.y)&&yn(E.prev,E,E.next)>=0))return!1;E=E.nextZ}for(;w&&w.z>=g;){if(w.x>=m&&w.x<=_&&w.y>=v&&w.y<=y&&w!==i&&w!==o&&Nl(a,u,l,h,c,p,w.x,w.y)&&yn(w.prev,w,w.next)>=0)return!1;w=w.prevZ}for(;E&&E.z<=x;){if(E.x>=m&&E.x<=_&&E.y>=v&&E.y<=y&&E!==i&&E!==o&&Nl(a,u,l,h,c,p,E.x,E.y)&&yn(E.prev,E,E.next)>=0)return!1;E=E.nextZ}return!0}function gU(r,e,t){let n=r;do{const i=n.prev,s=n.next.next;!dp(i,s)&&DM(i,n,n.next,s)&&Gu(i,s)&&Gu(s,i)&&(e.push(i.i/t|0),e.push(n.i/t|0),e.push(s.i/t|0),Hu(n),Hu(n.next),n=r=s),n=n.next}while(n!==r);return Ea(n)}function vU(r,e,t,n,i,s){let o=r;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&TU(o,a)){let l=UM(o,a);o=Ea(o,o.next),l=Ea(l,l.next),Bu(o,e,t,n,i,s,0),Bu(l,e,t,n,i,s,0);return}a=a.next}o=o.next}while(o!==r)}function yU(r,e,t,n){const i=[];let s,o,a,l,c;for(s=0,o=e.length;s=t.next.y&&t.next.y!==t.y){const p=t.x+(o-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(p<=s&&p>n&&(n=p,i=t.x=t.x&&t.x>=l&&s!==t.x&&Nl(oi.x||t.x===i.x&&SU(i,t)))&&(i=t,u=h)),t=t.next;while(t!==a);return i}function SU(r,e){return yn(r.prev,r,e.prev)<0&&yn(e.next,r,r.next)<0}function EU(r,e,t,n){let i=r;do i.z===0&&(i.z=hv(i.x,i.y,e,t,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==r);i.prevZ.nextZ=null,i.prevZ=null,bU(i)}function bU(r){let e,t,n,i,s,o,a,l,c=1;do{for(t=r,r=null,s=null,o=0;t;){for(o++,n=t,a=0,e=0;e0||l>0&&n;)a!==0&&(l===0||!n||t.z<=n.z)?(i=t,t=t.nextZ,a--):(i=n,n=n.nextZ,l--),s?s.nextZ=i:r=i,i.prevZ=s,s=i;t=n}s.nextZ=null,c*=2}while(o>1);return r}function hv(r,e,t,n,i){return r=(r-t)*i|0,e=(e-n)*i|0,r=(r|r<<8)&16711935,r=(r|r<<4)&252645135,r=(r|r<<2)&858993459,r=(r|r<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,r|e<<1}function MU(r){let e=r,t=r;do(e.x=(r-o)*(s-a)&&(r-o)*(n-a)>=(t-o)*(e-a)&&(t-o)*(s-a)>=(i-o)*(n-a)}function TU(r,e){return r.next.i!==e.i&&r.prev.i!==e.i&&!AU(r,e)&&(Gu(r,e)&&Gu(e,r)&&CU(r,e)&&(yn(r.prev,r,e.prev)||yn(r,e.prev,e))||dp(r,e)&&yn(r.prev,r,r.next)>0&&yn(e.prev,e,e.next)>0)}function yn(r,e,t){return(e.y-r.y)*(t.x-e.x)-(e.x-r.x)*(t.y-e.y)}function dp(r,e){return r.x===e.x&&r.y===e.y}function DM(r,e,t,n){const i=Wf(yn(r,e,t)),s=Wf(yn(r,e,n)),o=Wf(yn(t,n,r)),a=Wf(yn(t,n,e));return!!(i!==s&&o!==a||i===0&&Vf(r,t,e)||s===0&&Vf(r,n,e)||o===0&&Vf(t,r,n)||a===0&&Vf(t,e,n))}function Vf(r,e,t){return e.x<=Math.max(r.x,t.x)&&e.x>=Math.min(r.x,t.x)&&e.y<=Math.max(r.y,t.y)&&e.y>=Math.min(r.y,t.y)}function Wf(r){return r>0?1:r<0?-1:0}function AU(r,e){let t=r;do{if(t.i!==r.i&&t.next.i!==r.i&&t.i!==e.i&&t.next.i!==e.i&&DM(t,t.next,r,e))return!0;t=t.next}while(t!==r);return!1}function Gu(r,e){return yn(r.prev,r,r.next)<0?yn(r,e,r.next)>=0&&yn(r,r.prev,e)>=0:yn(r,e,r.prev)<0||yn(r,r.next,e)<0}function CU(r,e){let t=r,n=!1;const i=(r.x+e.x)/2,s=(r.y+e.y)/2;do t.y>s!=t.next.y>s&&t.next.y!==t.y&&i<(t.next.x-t.x)*(s-t.y)/(t.next.y-t.y)+t.x&&(n=!n),t=t.next;while(t!==r);return n}function UM(r,e){const t=new fv(r.i,r.x,r.y),n=new fv(e.i,e.x,e.y),i=r.next,s=e.prev;return r.next=e,e.prev=r,t.next=i,i.prev=t,n.next=t,t.prev=n,s.next=n,n.prev=s,n}function j1(r,e,t,n){const i=new fv(r,e,t);return n?(i.next=n.next,i.prev=n,n.next.prev=i,n.next=i):(i.prev=i,i.next=i),i}function Hu(r){r.next.prev=r.prev,r.prev.next=r.next,r.prevZ&&(r.prevZ.nextZ=r.nextZ),r.nextZ&&(r.nextZ.prevZ=r.prevZ)}function fv(r,e,t){this.i=r,this.x=e,this.y=t,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function RU(r,e,t,n){let i=0;for(let s=e,o=t-n;s2&&r[e-1].equals(r[0])&&r.pop()}function q1(r,e){for(let t=0;tNumber.EPSILON){const H=Math.sqrt(He),ne=Math.sqrt(Le*Le+ge*ge),we=oe.x-Se/H,be=oe.y+de/H,Me=te.x-ge/ne,Fe=te.y+Le/ne,Ue=((Me-we)*ge-(Fe-be)*Le)/(de*ge-Se*Le);se=we+de*Ue-z.x,$=be+Se*Ue-z.y;const xe=se*se+$*$;if(xe<=2)return new De(se,$);Ie=Math.sqrt(xe/2)}else{let H=!1;de>Number.EPSILON?Le>Number.EPSILON&&(H=!0):de<-Number.EPSILON?Le<-Number.EPSILON&&(H=!0):Math.sign(Se)===Math.sign(ge)&&(H=!0),H?(se=-Se,$=de,Ie=Math.sqrt(He)):(se=de,$=Se,Ie=Math.sqrt(He/2))}return new De(se/Ie,$/Ie)}const G=[];for(let z=0,oe=X.length,te=oe-1,se=z+1;z=0;z--){const oe=z/y,te=m*Math.cos(oe*Math.PI/2),se=v*Math.sin(oe*Math.PI/2)+_;for(let $=0,Ie=X.length;$=0;){const se=te;let $=te-1;$<0&&($=z.length-1);for(let Ie=0,de=u+y*2;Ie0)&&m.push(w,E,M),(g!==n-1||l0!=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 zM extends oi{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new Ke(16777215),this.specular=new Ke(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ke(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Mo,this.normalScale=new De(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=ih,this.reflectivity=1,this.refractionRatio=.98,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.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class BM extends oi{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new Ke(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ke(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Mo,this.normalScale=new De(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.gradientMap=e.gradientMap,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}class GM extends oi{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Mo,this.normalScale=new De(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this}}class HM extends oi{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new Ke(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ke(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Mo,this.normalScale=new De(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=ih,this.reflectivity=1,this.refractionRatio=.98,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.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class VM extends oi{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new Ke(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Mo,this.normalScale=new De(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={MATCAP:""},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.flatShading=e.flatShading,this.fog=e.fog,this}}class WM extends Pi{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 yr(r,e,t){return Sy(r)?new r.constructor(r.subarray(e,t!==void 0?t:r.length)):r.slice(e,t)}function da(r,e,t){return!r||!t&&r.constructor===e?r:typeof e.BYTES_PER_ELEMENT=="number"?new e(r):Array.prototype.slice.call(r)}function Sy(r){return ArrayBuffer.isView(r)&&!(r instanceof DataView)}function XM(r){function e(i,s){return r[i]-r[s]}const t=r.length,n=new Array(t);for(let i=0;i!==t;++i)n[i]=i;return n.sort(e),n}function dv(r,e,t){const n=r.length,i=new r.constructor(n);for(let s=0,o=0;o!==n;++s){const a=t[s]*e;for(let l=0;l!==e;++l)i[o++]=r[a+l]}return i}function Ey(r,e,t,n){let i=1,s=r[0];for(;s!==void 0&&s[n]===void 0;)s=r[i++];if(s===void 0)return;let o=s[n];if(o!==void 0)if(Array.isArray(o))do o=s[n],o!==void 0&&(e.push(s.time),t.push.apply(t,o)),s=r[i++];while(s!==void 0);else if(o.toArray!==void 0)do o=s[n],o!==void 0&&(e.push(s.time),o.toArray(t,t.length)),s=r[i++];while(s!==void 0);else do o=s[n],o!==void 0&&(e.push(s.time),t.push(o)),s=r[i++];while(s!==void 0)}function DU(r,e,t,n,i=30){const s=r.clone();s.name=e;const o=[];for(let l=0;l=n)){h.push(c.times[m]);for(let _=0;_s.tracks[l].times[0]&&(a=s.tracks[l].times[0]);for(let l=0;l=a.times[v]){const g=v*h+u,x=g+h-u;_=yr(a.values,g,x)}else{const g=a.createInterpolant(),x=u,w=h-u;g.evaluate(s),_=yr(g.resultBuffer,x,w)}l==="quaternion"&&new si().fromArray(_).normalize().conjugate().toArray(_);const y=c.times.length;for(let g=0;g=s)){const a=t[1];e=s)break t}o=n,n=0;break n}break e}for(;n>>1;et;)--o;if(++o,s!==0||o!==i){s>=o&&(o=Math.max(o,1),s=o-1);const a=this.getValueSize();this.times=yr(n,s,o),this.values=yr(this.values,s*a,o*a)}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,i=this.values,s=n.length;s===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let o=null;for(let a=0;a!==s;a++){const l=n[a];if(typeof l=="number"&&isNaN(l)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,a,l),e=!1;break}if(o!==null&&o>l){console.error("THREE.KeyframeTrack: Out of order keys.",this,a,l,o),e=!1;break}o=l}if(i!==void 0&&Sy(i))for(let a=0,l=i.length;a!==l;++a){const c=i[a];if(isNaN(c)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,a,c),e=!1;break}}return e}optimize(){const e=yr(this.times),t=yr(this.values),n=this.getValueSize(),i=this.getInterpolation()===Sd,s=e.length-1;let o=1;for(let a=1;a0){e[o]=e[s];for(let a=s*n,l=o*n,c=0;c!==n;++c)t[l+c]=t[a+c];++o}return o!==e.length?(this.times=yr(e,0,o),this.values=yr(t,0,o*n)):(this.times=e,this.values=t),this}clone(){const e=yr(this.times,0),t=yr(this.values,0),n=this.constructor,i=new n(this.name,e,t);return i.createInterpolant=this.createInterpolant,i}}Wr.prototype.TimeBufferType=Float32Array;Wr.prototype.ValueBufferType=Float32Array;Wr.prototype.DefaultInterpolation=Du;class Ia extends Wr{}Ia.prototype.ValueTypeName="bool";Ia.prototype.ValueBufferType=Array;Ia.prototype.DefaultInterpolation=Iu;Ia.prototype.InterpolantFactoryMethodLinear=void 0;Ia.prototype.InterpolantFactoryMethodSmooth=void 0;class My extends Wr{}My.prototype.ValueTypeName="color";class Vu extends Wr{}Vu.prototype.ValueTypeName="number";class qM extends uh{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){const s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=(n-t)/(i-t);let c=e*a;for(let u=c+a;c!==u;c+=4)si.slerpFlat(s,0,o,c-a,o,c,l);return s}}class tc extends Wr{InterpolantFactoryMethodLinear(e){return new qM(this.times,this.values,this.getValueSize(),e)}}tc.prototype.ValueTypeName="quaternion";tc.prototype.DefaultInterpolation=Du;tc.prototype.InterpolantFactoryMethodSmooth=void 0;class Da extends Wr{}Da.prototype.ValueTypeName="string";Da.prototype.ValueBufferType=Array;Da.prototype.DefaultInterpolation=Iu;Da.prototype.InterpolantFactoryMethodLinear=void 0;Da.prototype.InterpolantFactoryMethodSmooth=void 0;class Wu extends Wr{}Wu.prototype.ValueTypeName="vector";class Xu{constructor(e,t=-1,n,i=$d){this.name=e,this.tracks=n,this.duration=t,this.blendMode=i,this.uuid=er(),this.duration<0&&this.resetDuration()}static parse(e){const t=[],n=e.tracks,i=1/(e.fps||1);for(let o=0,a=n.length;o!==a;++o)t.push(FU(n[o]).scale(i));const s=new this(e.name,e.duration,t,e.blendMode);return s.uuid=e.uuid,s}static toJSON(e){const t=[],n=e.tracks,i={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let s=0,o=n.length;s!==o;++s)t.push(Wr.toJSON(n[s]));return i}static CreateFromMorphTargetSequence(e,t,n,i){const s=t.length,o=[];for(let a=0;a1){const h=u[1];let p=i[h];p||(i[h]=p=[]),p.push(c)}}const o=[];for(const a in i)o.push(this.CreateFromMorphTargetSequence(a,i[a],t,n));return o}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const n=function(h,p,m,v,_){if(m.length!==0){const y=[],g=[];Ey(m,y,g,v),y.length!==0&&_.push(new h(p,y,g))}},i=[],s=e.name||"default",o=e.fps||30,a=e.blendMode;let l=e.length||-1;const c=e.hierarchy||[];for(let h=0;h{t&&t(s),this.manager.itemEnd(e)},0),s;if(Cs[e]!==void 0){Cs[e].push({onLoad:t,onProgress:n,onError:i});return}Cs[e]=[],Cs[e].push({onLoad:t,onProgress:n,onError:i});const o=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),a=this.mimeType,l=this.responseType;fetch(o).then(c=>{if(c.status===200||c.status===0){if(c.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||c.body===void 0||c.body.getReader===void 0)return c;const u=Cs[e],h=c.body.getReader(),p=c.headers.get("Content-Length")||c.headers.get("X-File-Size"),m=p?parseInt(p):0,v=m!==0;let _=0;const y=new ReadableStream({start(g){x();function x(){h.read().then(({done:w,value:E})=>{if(w)g.close();else{_+=E.byteLength;const b=new ProgressEvent("progress",{lengthComputable:v,loaded:_,total:m});for(let M=0,A=u.length;M{switch(l){case"arraybuffer":return c.arrayBuffer();case"blob":return c.blob();case"document":return c.text().then(u=>new DOMParser().parseFromString(u,a));case"json":return c.json();default:if(a===void 0)return c.text();{const h=/charset="?([^;"\s]*)"?/i.exec(a),p=h&&h[1]?h[1].toLowerCase():void 0,m=new TextDecoder(p);return c.arrayBuffer().then(v=>m.decode(v))}}}).then(c=>{Ma.add(e,c);const u=Cs[e];delete Cs[e];for(let h=0,p=u.length;h{const u=Cs[e];if(u===void 0)throw this.manager.itemError(e),c;delete Cs[e];for(let h=0,p=u.length;h{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}}class zU extends Gi{constructor(e){super(e)}load(e,t,n,i){const s=this,o=new Bs(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(a){try{t(s.parse(JSON.parse(a)))}catch(l){i?i(l):console.error(l),s.manager.itemError(e)}},n,i)}parse(e){const t=[];for(let n=0;n0:i.vertexColors=e.vertexColors),e.uniforms!==void 0)for(const s in e.uniforms){const o=e.uniforms[s];switch(i.uniforms[s]={},o.type){case"t":i.uniforms[s].value=n(o.value);break;case"c":i.uniforms[s].value=new Ke().setHex(o.value);break;case"v2":i.uniforms[s].value=new De().fromArray(o.value);break;case"v3":i.uniforms[s].value=new Y().fromArray(o.value);break;case"v4":i.uniforms[s].value=new Xt().fromArray(o.value);break;case"m3":i.uniforms[s].value=new Ct().fromArray(o.value);break;case"m4":i.uniforms[s].value=new yt().fromArray(o.value);break;default:i.uniforms[s].value=o.value}}if(e.defines!==void 0&&(i.defines=e.defines),e.vertexShader!==void 0&&(i.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(i.fragmentShader=e.fragmentShader),e.glslVersion!==void 0&&(i.glslVersion=e.glslVersion),e.extensions!==void 0)for(const s in e.extensions)i.extensions[s]=e.extensions[s];if(e.lights!==void 0&&(i.lights=e.lights),e.clipping!==void 0&&(i.clipping=e.clipping),e.size!==void 0&&(i.size=e.size),e.sizeAttenuation!==void 0&&(i.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(i.map=n(e.map)),e.matcap!==void 0&&(i.matcap=n(e.matcap)),e.alphaMap!==void 0&&(i.alphaMap=n(e.alphaMap)),e.bumpMap!==void 0&&(i.bumpMap=n(e.bumpMap)),e.bumpScale!==void 0&&(i.bumpScale=e.bumpScale),e.normalMap!==void 0&&(i.normalMap=n(e.normalMap)),e.normalMapType!==void 0&&(i.normalMapType=e.normalMapType),e.normalScale!==void 0){let s=e.normalScale;Array.isArray(s)===!1&&(s=[s,s]),i.normalScale=new De().fromArray(s)}return e.displacementMap!==void 0&&(i.displacementMap=n(e.displacementMap)),e.displacementScale!==void 0&&(i.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(i.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(i.roughnessMap=n(e.roughnessMap)),e.metalnessMap!==void 0&&(i.metalnessMap=n(e.metalnessMap)),e.emissiveMap!==void 0&&(i.emissiveMap=n(e.emissiveMap)),e.emissiveIntensity!==void 0&&(i.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(i.specularMap=n(e.specularMap)),e.specularIntensityMap!==void 0&&(i.specularIntensityMap=n(e.specularIntensityMap)),e.specularColorMap!==void 0&&(i.specularColorMap=n(e.specularColorMap)),e.envMap!==void 0&&(i.envMap=n(e.envMap)),e.envMapIntensity!==void 0&&(i.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(i.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(i.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(i.lightMap=n(e.lightMap)),e.lightMapIntensity!==void 0&&(i.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(i.aoMap=n(e.aoMap)),e.aoMapIntensity!==void 0&&(i.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(i.gradientMap=n(e.gradientMap)),e.clearcoatMap!==void 0&&(i.clearcoatMap=n(e.clearcoatMap)),e.clearcoatRoughnessMap!==void 0&&(i.clearcoatRoughnessMap=n(e.clearcoatRoughnessMap)),e.clearcoatNormalMap!==void 0&&(i.clearcoatNormalMap=n(e.clearcoatNormalMap)),e.clearcoatNormalScale!==void 0&&(i.clearcoatNormalScale=new De().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(i.iridescenceMap=n(e.iridescenceMap)),e.iridescenceThicknessMap!==void 0&&(i.iridescenceThicknessMap=n(e.iridescenceThicknessMap)),e.transmissionMap!==void 0&&(i.transmissionMap=n(e.transmissionMap)),e.thicknessMap!==void 0&&(i.thicknessMap=n(e.thicknessMap)),e.anisotropyMap!==void 0&&(i.anisotropyMap=n(e.anisotropyMap)),e.sheenColorMap!==void 0&&(i.sheenColorMap=n(e.sheenColorMap)),e.sheenRoughnessMap!==void 0&&(i.sheenRoughnessMap=n(e.sheenRoughnessMap)),i}setTextures(e){return this.textures=e,this}static createMaterialFromType(e){const t={ShadowMaterial:NM,SpriteMaterial:hy,RawShaderMaterial:FM,ShaderMaterial:cs,PointsMaterial:dy,MeshPhysicalMaterial:kM,MeshStandardMaterial:wy,MeshPhongMaterial:zM,MeshToonMaterial:BM,MeshNormalMaterial:GM,MeshLambertMaterial:HM,MeshDepthMaterial:ep,MeshDistanceMaterial:tp,MeshBasicMaterial:Vs,MeshMatcapMaterial:VM,LineDashedMaterial:WM,LineBasicMaterial:Pi,Material:oi};return new t[e]}}class pv{static decodeText(e){if(typeof TextDecoder<"u")return new TextDecoder().decode(e);let t="";for(let n=0,i=e.length;n0){const l=new Ty(t);s=new ju(l),s.setCrossOrigin(this.crossOrigin);for(let c=0,u=e.length;c0){i=new ju(this.manager),i.setCrossOrigin(this.crossOrigin);for(let o=0,a=e.length;o"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,i){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=this,o=Ma.get(e);if(o!==void 0)return s.manager.itemStart(e),setTimeout(function(){t&&t(o),s.manager.itemEnd(e)},0),o;const a={};a.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",a.headers=this.requestHeader,fetch(e,a).then(function(l){return l.blob()}).then(function(l){return createImageBitmap(l,Object.assign(s.options,{colorSpaceConversion:"none"}))}).then(function(l){Ma.add(e,l),t&&t(l),s.manager.itemEnd(e)}).catch(function(l){i&&i(l),s.manager.itemError(e),s.manager.itemEnd(e)}),s.manager.itemStart(e)}}let Xf;class Ry{static getContext(){return Xf===void 0&&(Xf=new(window.AudioContext||window.webkitAudioContext)),Xf}static setContext(e){Xf=e}}class ZU extends Gi{constructor(e){super(e)}load(e,t,n,i){const s=this,o=new Bs(this.manager);o.setResponseType("arraybuffer"),o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(l){try{const c=l.slice(0);Ry.getContext().decodeAudioData(c,function(h){t(h)},a)}catch(c){a(c)}},n,i);function a(l){i?i(l):console.error(l),s.manager.itemError(e)}}}class KU extends wp{constructor(e,t,n=1){super(void 0,n),this.isHemisphereLightProbe=!0;const i=new Ke().set(e),s=new Ke().set(t),o=new Y(i.r,i.g,i.b),a=new Y(s.r,s.g,s.b),l=Math.sqrt(Math.PI),c=l*Math.sqrt(.75);this.sh.coefficients[0].copy(o).add(a).multiplyScalar(l),this.sh.coefficients[1].copy(o).sub(a).multiplyScalar(c)}}class $U extends wp{constructor(e,t=1){super(void 0,t),this.isAmbientLightProbe=!0;const n=new Ke().set(e);this.sh.coefficients[0].set(n.r,n.g,n.b).multiplyScalar(2*Math.sqrt(Math.PI))}}const nw=new yt,iw=new yt,Zo=new yt;class JU{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new zn,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new zn,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}update(e){const t=this._cache;if(t.focus!==e.focus||t.fov!==e.fov||t.aspect!==e.aspect*this.aspect||t.near!==e.near||t.far!==e.far||t.zoom!==e.zoom||t.eyeSep!==this.eyeSep){t.focus=e.focus,t.fov=e.fov,t.aspect=e.aspect*this.aspect,t.near=e.near,t.far=e.far,t.zoom=e.zoom,t.eyeSep=this.eyeSep,Zo.copy(e.projectionMatrix);const i=t.eyeSep/2,s=i*t.near/t.focus,o=t.near*Math.tan(ma*t.fov*.5)/t.zoom;let a,l;iw.elements[12]=-i,nw.elements[12]=i,a=-o*t.aspect+s,l=o*t.aspect+s,Zo.elements[0]=2*t.near/(l-a),Zo.elements[8]=(l+a)/(l-a),this.cameraL.projectionMatrix.copy(Zo),a=-o*t.aspect-s,l=o*t.aspect-s,Zo.elements[0]=2*t.near/(l-a),Zo.elements[8]=(l+a)/(l-a),this.cameraR.projectionMatrix.copy(Zo)}this.cameraL.matrixWorld.copy(e.matrixWorld).multiply(iw),this.cameraR.matrixWorld.copy(e.matrixWorld).multiply(nw)}}class Py{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=rw(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let e=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){const t=rw();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}}function rw(){return(typeof performance>"u"?Date:performance).now()}const Ko=new Y,sw=new si,QU=new Y,$o=new Y;class e3 extends jt{constructor(){super(),this.type="AudioListener",this.context=Ry.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new Py}getInput(){return this.gain}removeFilter(){return this.filter!==null&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this}getFilter(){return this.filter}setFilter(e){return this.filter!==null?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=e,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}updateMatrixWorld(e){super.updateMatrixWorld(e);const t=this.context.listener,n=this.up;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(Ko,sw,QU),$o.set(0,0,-1).applyQuaternion(sw),t.positionX){const i=this.context.currentTime+this.timeDelta;t.positionX.linearRampToValueAtTime(Ko.x,i),t.positionY.linearRampToValueAtTime(Ko.y,i),t.positionZ.linearRampToValueAtTime(Ko.z,i),t.forwardX.linearRampToValueAtTime($o.x,i),t.forwardY.linearRampToValueAtTime($o.y,i),t.forwardZ.linearRampToValueAtTime($o.z,i),t.upX.linearRampToValueAtTime(n.x,i),t.upY.linearRampToValueAtTime(n.y,i),t.upZ.linearRampToValueAtTime(n.z,i)}else t.setPosition(Ko.x,Ko.y,Ko.z),t.setOrientation($o.x,$o.y,$o.z,n.x,n.y,n.z)}}class sT extends jt{constructor(e){super(),this.type="Audio",this.listener=e,this.context=e.context,this.gain=this.context.createGain(),this.gain.connect(e.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.source=null,this.sourceType="empty",this._startedAt=0,this._progress=0,this._connected=!1,this.filters=[]}getOutput(){return this.gain}setNodeSource(e){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=e,this.connect(),this}setMediaElementSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(e),this.connect(),this}setMediaStreamSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(e),this.connect(),this}setBuffer(e){return this.buffer=e,this.sourceType="buffer",this.autoplay&&this.play(),this}play(e=0){if(this.isPlaying===!0){console.warn("THREE.Audio: Audio is already playing.");return}if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}this._startedAt=this.context.currentTime+e;const t=this.context.createBufferSource();return t.buffer=this.buffer,t.loop=this.loop,t.loopStart=this.loopStart,t.loopEnd=this.loopEnd,t.onended=this.onEnded.bind(this),t.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=t,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.isPlaying===!0&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,this.loop===!0&&(this._progress=this._progress%(this.duration||this.buffer.duration)),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this}stop(){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this._progress=0,this.source!==null&&(this.source.stop(),this.source.onended=null),this.isPlaying=!1,this}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let e=1,t=this.filters.length;e0){this.source.disconnect(this.filters[0]);for(let e=1,t=this.filters.length;e0&&this._mixBufferRegionAdditive(n,i,this._addIndex*t,1,t);for(let l=t,c=t+t;l!==c;++l)if(n[l]!==n[l+t]){a.setValue(n,i);break}}saveOriginalState(){const e=this.binding,t=this.buffer,n=this.valueSize,i=n*this._origIndex;e.getValue(t,i);for(let s=n,o=i;s!==o;++s)t[s]=t[i+s%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){const e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let n=e;n=.5)for(let o=0;o!==s;++o)e[t+o]=e[n+o]}_slerp(e,t,n,i){si.slerpFlat(e,t,e,t,e,n,i)}_slerpAdditive(e,t,n,i,s){const o=this._workIndex*s;si.multiplyQuaternionsFlat(e,o,e,t,e,n),si.slerpFlat(e,t,e,t,e,o,i)}_lerp(e,t,n,i,s){const o=1-i;for(let a=0;a!==s;++a){const l=t+a;e[l]=e[l]*o+e[n+a]*i}}_lerpAdditive(e,t,n,i,s){for(let o=0;o!==s;++o){const a=t+o;e[a]=e[a]+e[n+o]*i}}}const Ly="\\[\\]\\.:\\/",r3=new RegExp("["+Ly+"]","g"),Iy="[^"+Ly+"]",s3="[^"+Ly.replace("\\.","")+"]",o3=/((?:WC+[\/:])*)/.source.replace("WC",Iy),a3=/(WCOD+)?/.source.replace("WCOD",s3),l3=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Iy),c3=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Iy),u3=new RegExp("^"+o3+a3+l3+c3+"$"),h3=["material","materials","bones","map"];class f3{constructor(e,t,n){const i=n||zt.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,i)}getValue(e,t){this.bind();const n=this._targetGroup.nCachedObjects_,i=this._bindings[n];i!==void 0&&i.getValue(e,t)}setValue(e,t){const n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,s=n.length;i!==s;++i)n[i].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 zt{constructor(e,t,n){this.path=t,this.parsedPath=n||zt.parseTrackName(t),this.node=zt.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 zt.Composite(e,t,n):new zt(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(r3,"")}static parseTrackName(e){const t=u3.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]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(i!==void 0&&i!==-1){const s=n.nodeName.substring(i+1);h3.indexOf(s)!==-1&&(n.nodeName=n.nodeName.substring(0,i),n.objectName=s)}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(s){for(let o=0;o=s){const h=s++,p=e[h];t[p.uuid]=u,e[u]=p,t[c]=h,e[h]=l;for(let m=0,v=i;m!==v;++m){const _=n[m],y=_[h],g=_[u];_[u]=y,_[h]=g}}}this.nCachedObjects_=s}uncache(){const e=this._objects,t=this._indicesByUUID,n=this._bindings,i=n.length;let s=this.nCachedObjects_,o=e.length;for(let a=0,l=arguments.length;a!==l;++a){const c=arguments[a],u=c.uuid,h=t[u];if(h!==void 0)if(delete t[u],h0&&(t[m.uuid]=h),e[h]=m,e.pop();for(let v=0,_=i;v!==_;++v){const y=n[v];y[h]=y[p],y.pop()}}}this.nCachedObjects_=s}subscribe_(e,t){const n=this._bindingsIndicesByPath;let i=n[e];const s=this._bindings;if(i!==void 0)return s[i];const o=this._paths,a=this._parsedPaths,l=this._objects,c=l.length,u=this.nCachedObjects_,h=new Array(c);i=s.length,n[e]=i,o.push(e),a.push(t),s.push(h);for(let p=u,m=l.length;p!==m;++p){const v=l[p];h[p]=new zt(v,e,t)}return h}unsubscribe_(e){const t=this._bindingsIndicesByPath,n=t[e];if(n!==void 0){const i=this._paths,s=this._parsedPaths,o=this._bindings,a=o.length-1,l=o[a],c=e[a];t[c]=n,o[n]=l,o.pop(),s[n]=s[a],s.pop(),i[n]=i[a],i.pop()}}}class aT{constructor(e,t,n=null,i=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=n,this.blendMode=i;const s=t.tracks,o=s.length,a=new Array(o),l={endingStart:ua,endingEnd:ua};for(let c=0;c!==o;++c){const u=s[c].createInterpolant(null);a[c]=u,u.settings=l}this._interpolantSettings=l,this._interpolants=a,this._propertyBindings=new Array(o),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=jb,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,n){if(e.fadeOut(t),this.fadeIn(t),n){const i=this._clip.duration,s=e._clip.duration,o=s/i,a=i/s;e.warp(1,o,t),this.warp(a,1,t)}return this}crossFadeTo(e,t,n){return e.crossFadeFrom(this,t,n)}stopFading(){const e=this._weightInterpolant;return e!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,n){const i=this._mixer,s=i.time,o=this.timeScale;let a=this._timeScaleInterpolant;a===null&&(a=i._lendControlInterpolant(),this._timeScaleInterpolant=a);const l=a.parameterPositions,c=a.sampleValues;return l[0]=s,l[1]=s+n,c[0]=e/o,c[1]=t/o,this}stopWarping(){const e=this._timeScaleInterpolant;return e!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,n,i){if(!this.enabled){this._updateWeight(e);return}const s=this._startTime;if(s!==null){const l=(e-s)*n;l<0||n===0?t=0:(this._startTime=null,t=n*l)}t*=this._updateTimeScale(e);const o=this._updateTime(t),a=this._updateWeight(e);if(a>0){const l=this._interpolants,c=this._propertyBindings;switch(this.blendMode){case Qv:for(let u=0,h=l.length;u!==h;++u)l[u].evaluate(o),c[u].accumulateAdditive(a);break;case $d:default:for(let u=0,h=l.length;u!==h;++u)l[u].evaluate(o),c[u].accumulate(i,a)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;const n=this._weightInterpolant;if(n!==null){const i=n.evaluate(e)[0];t*=i,e>n.parameterPositions[1]&&(this.stopFading(),i===0&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;const n=this._timeScaleInterpolant;if(n!==null){const i=n.evaluate(e)[0];t*=i,e>n.parameterPositions[1]&&(this.stopWarping(),t===0?this.paused=!0:this.timeScale=t)}}return this._effectiveTimeScale=t,t}_updateTime(e){const t=this._clip.duration,n=this.loop;let i=this.time+e,s=this._loopCount;const o=n===Yb;if(e===0)return s===-1?i:o&&(s&1)===1?t-i:i;if(n===Xb){s===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(i>=t)i=t;else if(i<0)i=0;else{this.time=i;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(s===-1&&(e>=0?(s=0,this._setEndings(!0,this.repetitions===0,o)):this._setEndings(this.repetitions===0,!0,o)),i>=t||i<0){const a=Math.floor(i/t);i-=t*a,s+=Math.abs(a);const l=this.repetitions-s;if(l<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,i=e>0?t:0,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(l===1){const c=e<0;this._setEndings(c,!c,o)}else this._setEndings(!1,!1,o);this._loopCount=s,this.time=i,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:a})}}else this.time=i;if(o&&(s&1)===1)return t-i}return i}_setEndings(e,t,n){const i=this._interpolantSettings;n?(i.endingStart=ha,i.endingEnd=ha):(e?i.endingStart=this.zeroSlopeAtStart?ha:ua:i.endingStart=Uu,t?i.endingEnd=this.zeroSlopeAtEnd?ha:ua:i.endingEnd=Uu)}_scheduleFading(e,t,n){const i=this._mixer,s=i.time;let o=this._weightInterpolant;o===null&&(o=i._lendControlInterpolant(),this._weightInterpolant=o);const a=o.parameterPositions,l=o.sampleValues;return a[0]=s,l[0]=t,a[1]=s+e,l[1]=n,this}}const p3=new Float32Array(1);class m3 extends Hs{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){const n=e._localRoot||this._root,i=e._clip.tracks,s=i.length,o=e._propertyBindings,a=e._interpolants,l=n.uuid,c=this._bindingsByRootAndName;let u=c[l];u===void 0&&(u={},c[l]=u);for(let h=0;h!==s;++h){const p=i[h],m=p.name;let v=u[m];if(v!==void 0)++v.referenceCount,o[h]=v;else{if(v=o[h],v!==void 0){v._cacheIndex===null&&(++v.referenceCount,this._addInactiveBinding(v,l,m));continue}const _=t&&t._propertyBindings[h].binding.parsedPath;v=new oT(zt.create(n,m,_),p.ValueTypeName,p.getValueSize()),++v.referenceCount,this._addInactiveBinding(v,l,m),o[h]=v}a[h].resultBuffer=v.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){const n=(e._localRoot||this._root).uuid,i=e._clip.uuid,s=this._actionsByClip[i];this._bindAction(e,s&&s.knownActions[0]),this._addInactiveAction(e,i,n)}const t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){const s=t[n];s.useCount++===0&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){const t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){const s=t[n];--s.useCount===0&&(s.restoreOriginalState(),this._takeBackBinding(s))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){const t=e._cacheIndex;return t!==null&&t=0;--n)e[n].stop();return this}update(e){e*=this.timeScale;const t=this._actions,n=this._nActiveActions,i=this.time+=e,s=Math.sign(e),o=this._accuIndex^=1;for(let c=0;c!==n;++c)t[c]._update(i,e,s,o);const a=this._bindings,l=this._nActiveBindings;for(let c=0;c!==l;++c)a[c].apply(o);return this}setTime(e){this.time=0;for(let t=0;tthis.max.x||e.ythis.max.y)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(e){return!(e.max.xthis.max.x||e.max.ythis.max.y)}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,lw).distanceTo(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}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 cw=new Y,jf=new Y;class S3{constructor(e=new Y,t=new Y){this.start=e,this.end=t}set(e,t){return this.start.copy(e),this.end.copy(t),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,t){return this.delta(t).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,t){cw.subVectors(e,this.start),jf.subVectors(this.end,this.start);const n=jf.dot(jf);let s=jf.dot(cw)/n;return t&&(s=Tn(s,0,1)),s}closestPointToPoint(e,t,n){const i=this.closestPointToPointParameter(e,t);return this.delta(n).multiplyScalar(i).add(this.start)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return new this.constructor().copy(this)}}const uw=new Y;class E3 extends jt{constructor(e,t){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";const n=new Tt,i=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let o=0,a=1,l=32;o1)for(let h=0;h.99999)this.quaternion.set(0,0,0,1);else if(e.y<-.99999)this.quaternion.set(1,0,0,0);else{mw.set(e.z,0,-e.x).normalize();const t=Math.acos(e.y);this.quaternion.setFromAxisAngle(mw,t)}}setLength(e,t=e*.2,n=t*.2){this.line.scale.set(1,Math.max(1e-4,e-t),1),this.line.updateMatrix(),this.cone.scale.set(n,t,n),this.cone.position.y=e,this.cone.updateMatrix()}setColor(e){this.line.material.color.set(e),this.cone.material.color.set(e)}copy(e){return super.copy(e,!1),this.line.copy(e.line),this.cone.copy(e.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}}class N3 extends hs{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],i=new Tt;i.setAttribute("position",new st(t,3)),i.setAttribute("color",new st(n,3));const s=new Pi({vertexColors:!0,toneMapped:!1});super(i,s),this.type="AxesHelper"}setColors(e,t,n){const i=new Ke,s=this.geometry.attributes.color.array;return i.set(e),i.toArray(s,0),i.toArray(s,3),i.set(t),i.toArray(s,6),i.toArray(s,9),i.set(n),i.toArray(s,12),i.toArray(s,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class F3{constructor(){this.type="ShapePath",this.color=new Ke,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new zu,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}quadraticCurveTo(e,t,n,i){return this.currentPath.quadraticCurveTo(e,t,n,i),this}bezierCurveTo(e,t,n,i,s,o){return this.currentPath.bezierCurveTo(e,t,n,i,s,o),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(e){function t(g){const x=[];for(let w=0,E=g.length;wNumber.EPSILON){if(L<0&&(A=x[M],C=-C,P=x[b],L=-L),g.yP.y)continue;if(g.y===A.y){if(g.x===A.x)return!0}else{const F=L*(g.x-A.x)-C*(g.y-A.y);if(F===0)return!0;if(F<0)continue;E=!E}}else{if(g.y!==A.y)continue;if(P.x<=g.x&&g.x<=A.x||A.x<=g.x&&g.x<=P.x)return!0}}return E}const i=as.isClockWise,s=this.subPaths;if(s.length===0)return[];let o,a,l;const c=[];if(s.length===1)return a=s[0],l=new va,l.curves=a.curves,c.push(l),c;let u=!i(s[0].getPoints());u=e?!u:u;const h=[],p=[];let m=[],v=0,_;p[v]=void 0,m[v]=[];for(let g=0,x=s.length;g1){let g=!1,x=0;for(let w=0,E=p.length;w0&&g===!1&&(m=h)}let y;for(let g=0,x=p.length;g{const h=typeof c=="function"?c(e):c;if(h!==e){const p=e;e=u?h:Object.assign({},e,h),t.forEach(m=>m(e,p))}},i=()=>e,s=(c,u=i,h=Object.is)=>{console.warn("[DEPRECATED] Please use `subscribeWithSelector` middleware");let p=u(e);function m(){const v=u(e);if(!h(p,v)){const _=p;c(p=v,_)}}return t.add(m),()=>t.delete(m)},l={setState:n,getState:i,subscribe:(c,u,h)=>u||h?s(c,u,h):(t.add(c),()=>t.delete(c)),destroy:()=>t.clear()};return e=r(n,i,l),l}const G3=typeof window>"u"||!window.navigator||/ServerSideRendering|^Deno\//.test(window.navigator.userAgent),yw=G3?K.useEffect:K.useLayoutEffect;function H3(r){const e=typeof r=="function"?B3(r):r,t=(n=e.getState,i=Object.is)=>{const[,s]=K.useReducer(y=>y+1,0),o=e.getState(),a=K.useRef(o),l=K.useRef(n),c=K.useRef(i),u=K.useRef(!1),h=K.useRef();h.current===void 0&&(h.current=n(o));let p,m=!1;(a.current!==o||l.current!==n||c.current!==i||u.current)&&(p=n(o),m=!i(h.current,p)),yw(()=>{m&&(h.current=p),a.current=o,l.current=n,c.current=i,u.current=!1});const v=K.useRef(o);yw(()=>{const y=()=>{try{const x=e.getState(),w=l.current(x);c.current(h.current,w)||(a.current=x,h.current=w,s())}catch{u.current=!0,s()}},g=e.subscribe(y);return e.getState()!==v.current&&y(),g},[]);const _=m?p:h.current;return K.useDebugValue(_),_};return Object.assign(t,e),t[Symbol.iterator]=function(){console.warn("[useStore, api] = create() is deprecated and will be removed in v4");const n=[t,e];return{next(){const i=n.length<=0;return{value:n.shift(),done:i}}}},t}var mg={exports:{}},gg={exports:{}},vg={};/** * @license React * scheduler.production.min.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var _w;function V3(){return _w||(_w=1,(function(r){function e(k,G){var B=k.length;k.push(G);e:for(;0>>1,V=k[D];if(0>>1;Di(ie,B))uei(ce,ie)?(k[D]=ce,k[ue]=B,D=ue):(k[D]=ie,k[ee]=B,D=ee);else if(uei(ce,B))k[D]=ce,k[ue]=B,D=ue;else break e}}return G}function i(k,G){var B=k.sortIndex-G.sortIndex;return B!==0?B:k.id-G.id}if(typeof performance=="object"&&typeof performance.now=="function"){var s=performance;r.unstable_now=function(){return s.now()}}else{var o=Date,a=o.now();r.unstable_now=function(){return o.now()-a}}var l=[],c=[],u=1,h=null,p=3,m=!1,v=!1,_=!1,y=typeof setTimeout=="function"?setTimeout:null,g=typeof clearTimeout=="function"?clearTimeout:null,x=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function w(k){for(var G=t(c);G!==null;){if(G.callback===null)n(c);else if(G.startTime<=k)n(c),G.sortIndex=G.expirationTime,e(l,G);else break;G=t(c)}}function E(k){if(_=!1,w(k),!v)if(t(l)!==null)v=!0,W(b);else{var G=t(c);G!==null&&O(E,G.startTime-k)}}function b(k,G){v=!1,_&&(_=!1,g(P),P=-1),m=!0;var B=p;try{for(w(G),h=t(l);h!==null&&(!(h.expirationTime>G)||k&&!F());){var D=h.callback;if(typeof D=="function"){h.callback=null,p=h.priorityLevel;var V=D(h.expirationTime<=G);G=r.unstable_now(),typeof V=="function"?h.callback=V:h===t(l)&&n(l),w(G)}else n(l);h=t(l)}if(h!==null)var Z=!0;else{var ee=t(c);ee!==null&&O(E,ee.startTime-G),Z=!1}return Z}finally{h=null,p=B,m=!1}}var M=!1,A=null,P=-1,C=5,L=-1;function F(){return!(r.unstable_now()-Lk||125D?(k.sortIndex=B,e(c,k),t(l)===null&&k===t(c)&&(_?(g(P),P=-1):_=!0,O(E,B-D))):(k.sortIndex=V,e(l,k),v||m||(v=!0,W(b))),k},r.unstable_shouldYield=F,r.unstable_wrapCallback=function(k){var G=p;return function(){var B=p;p=G;try{return k.apply(this,arguments)}finally{p=B}}}})(vg)),vg}var xw;function W3(){return xw||(xw=1,gg.exports=V3()),gg.exports}/** * @license React * react-reconciler.production.min.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var yg,ww;function X3(){return ww||(ww=1,yg=function(e){var t={},n=Hv(),i=W3(),s=Object.assign;function o(f){for(var d="https://reactjs.org/docs/error-decoder.html?invariant="+f,S=1;She||R[Q]!==U[he]){var Ce=` `+R[Q].replace(" at new "," at ");return f.displayName&&Ce.includes("")&&(Ce=Ce.replace("",f.displayName)),Ce}while(1<=Q&&0<=he);break}}}finally{Jt=!1,Error.prepareStackTrace=S}return(f=f?f.displayName||f.name:"")?ut(f):""}var Yn=Object.prototype.hasOwnProperty,ci=[],qt=-1;function mt(f){return{current:f}}function kt(f){0>qt||(f.current=ci[qt],ci[qt]=null,qt--)}function gt(f,d){qt++,ci[qt]=f.current,f.current=d}var Cn={},En=mt(Cn),cn=mt(!1),Ii=Cn;function Qt(f,d){var S=f.type.contextTypes;if(!S)return Cn;var T=f.stateNode;if(T&&T.__reactInternalMemoizedUnmaskedChildContext===d)return T.__reactInternalMemoizedMaskedChildContext;var R={},U;for(U in S)R[U]=d[U];return T&&(f=f.stateNode,f.__reactInternalMemoizedUnmaskedChildContext=d,f.__reactInternalMemoizedMaskedChildContext=R),R}function on(f){return f=f.childContextTypes,f!=null}function xi(){kt(cn),kt(En)}function Un(f,d,S){if(En.current!==Cn)throw Error(o(168));gt(En,d),gt(cn,S)}function Xr(f,d,S){var T=f.stateNode;if(d=d.childContextTypes,typeof T.getChildContext!="function")return S;T=T.getChildContext();for(var R in T)if(!(R in d))throw Error(o(108,P(f)||"Unknown",R));return s({},S,T)}function jr(f){return f=(f=f.stateNode)&&f.__reactInternalMemoizedMergedChildContext||Cn,Ii=En.current,gt(En,f),gt(cn,cn.current),!0}function ui(f,d,S){var T=f.stateNode;if(!T)throw Error(o(169));S?(f=Xr(f,d,Ii),T.__reactInternalMemoizedMergedChildContext=f,kt(cn),kt(En),gt(En,f)):kt(cn),gt(cn,S)}var Vi=Math.clz32?Math.clz32:xh,Oa=Math.log,Ro=Math.LN2;function xh(f){return f>>>=0,f===0?32:31-(Oa(f)/Ro|0)|0}var fs=64,ds=4194304;function ps(f){switch(f&-f){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return f&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return f&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return f}}function Po(f,d){var S=f.pendingLanes;if(S===0)return 0;var T=0,R=f.suspendedLanes,U=f.pingedLanes,Q=S&268435455;if(Q!==0){var he=Q&~R;he!==0?T=ps(he):(U&=Q,U!==0&&(T=ps(U)))}else Q=S&~R,Q!==0?T=ps(Q):U!==0&&(T=ps(U));if(T===0)return 0;if(d!==0&&d!==T&&(d&R)===0&&(R=T&-T,U=d&-d,R>=U||R===16&&(U&4194240)!==0))return d;if((T&4)!==0&&(T|=S&16),d=f.entangledLanes,d!==0)for(f=f.entanglements,d&=T;0S;S++)d.push(f);return d}function Yr(f,d,S){f.pendingLanes|=d,d!==536870912&&(f.suspendedLanes=0,f.pingedLanes=0),f=f.eventTimes,d=31-Vi(d),f[d]=S}function Ys(f,d){var S=f.pendingLanes&~d;f.pendingLanes=d,f.suspendedLanes=0,f.pingedLanes=0,f.expiredLanes&=d,f.mutableReadLanes&=d,f.entangledLanes&=d,d=f.entanglements;var T=f.eventTimes;for(f=f.expirationTimes;0>=Q,R-=Q,ys=1<<32-Vi(d)+R|S<Ht?($n=Et,Et=null):$n=Et.sibling;var Vt=ht(ye,Et,Te[Ht],et);if(Vt===null){Et===null&&(Et=$n);break}f&&Et&&Vt.alternate===null&&d(ye,Et),fe=U(Vt,fe,Ht),Pt===null?ot=Vt:Pt.sibling=Vt,Pt=Vt,Et=$n}if(Ht===Te.length)return S(ye,Et),un&&Fo(ye,Ht),ot;if(Et===null){for(;HtHt?($n=Et,Et=null):$n=Et.sibling;var no=ht(ye,Et,Vt.value,et);if(no===null){Et===null&&(Et=$n);break}f&&Et&&no.alternate===null&&d(ye,Et),fe=U(no,fe,Ht),Pt===null?ot=no:Pt.sibling=no,Pt=no,Et=$n}if(Vt.done)return S(ye,Et),un&&Fo(ye,Ht),ot;if(Et===null){for(;!Vt.done;Ht++,Vt=Te.next())Vt=St(ye,Vt.value,et),Vt!==null&&(fe=U(Vt,fe,Ht),Pt===null?ot=Vt:Pt.sibling=Vt,Pt=Vt);return un&&Fo(ye,Ht),ot}for(Et=T(ye,Et);!Vt.done;Ht++,Vt=Te.next())Vt=nn(Et,ye,Ht,Vt.value,et),Vt!==null&&(f&&Vt.alternate!==null&&Et.delete(Vt.key===null?Ht:Vt.key),fe=U(Vt,fe,Ht),Pt===null?ot=Vt:Pt.sibling=Vt,Pt=Vt);return f&&Et.forEach(function(Y2){return d(ye,Y2)}),un&&Fo(ye,Ht),ot}function dr(ye,fe,Te,et){if(typeof Te=="object"&&Te!==null&&Te.type===u&&Te.key===null&&(Te=Te.props.children),typeof Te=="object"&&Te!==null){switch(Te.$$typeof){case l:e:{for(var ot=Te.key,Pt=fe;Pt!==null;){if(Pt.key===ot){if(ot=Te.type,ot===u){if(Pt.tag===7){S(ye,Pt.sibling),fe=R(Pt,Te.props.children),fe.return=ye,ye=fe;break e}}else if(Pt.elementType===ot||typeof ot=="object"&&ot!==null&&ot.$$typeof===w&&A_(ot)===Pt.type){S(ye,Pt.sibling),fe=R(Pt,Te.props),fe.ref=pc(ye,Pt,Te),fe.return=ye,ye=fe;break e}S(ye,Pt);break}else d(ye,Pt);Pt=Pt.sibling}Te.type===u?(fe=Wo(Te.props.children,ye.mode,et,Te.key),fe.return=ye,ye=fe):(et=cf(Te.type,Te.key,Te.props,null,ye.mode,et),et.ref=pc(ye,fe,Te),et.return=ye,ye=et)}return Q(ye);case c:e:{for(Pt=Te.key;fe!==null;){if(fe.key===Pt)if(fe.tag===4&&fe.stateNode.containerInfo===Te.containerInfo&&fe.stateNode.implementation===Te.implementation){S(ye,fe.sibling),fe=R(fe,Te.children||[]),fe.return=ye,ye=fe;break e}else{S(ye,fe);break}else d(ye,fe);fe=fe.sibling}fe=Im(Te,ye.mode,et),fe.return=ye,ye=fe}return Q(ye);case w:return Pt=Te._init,dr(ye,fe,Pt(Te._payload),et)}if(q(Te))return at(ye,fe,Te,et);if(M(Te))return pi(ye,fe,Te,et);Lh(ye,Te)}return typeof Te=="string"&&Te!==""||typeof Te=="number"?(Te=""+Te,fe!==null&&fe.tag===6?(S(ye,fe.sibling),fe=R(fe,Te),fe.return=ye,ye=fe):(S(ye,fe),fe=Lm(Te,ye.mode,et),fe.return=ye,ye=fe),Q(ye)):S(ye,fe)}return dr}var Va=C_(!0),R_=C_(!1),mc={},cr=mt(mc),gc=mt(mc),Wa=mt(mc);function Kr(f){if(f===mc)throw Error(o(174));return f}function Zp(f,d){gt(Wa,d),gt(gc,f),gt(cr,mc),f=O(d),kt(cr),gt(cr,f)}function Xa(){kt(cr),kt(gc),kt(Wa)}function P_(f){var d=Kr(Wa.current),S=Kr(cr.current);d=k(S,f.type,d),S!==d&&(gt(gc,f),gt(cr,d))}function Kp(f){gc.current===f&&(kt(cr),kt(gc))}var mn=mt(0);function Ih(f){for(var d=f;d!==null;){if(d.tag===13){var S=d.memoizedState;if(S!==null&&(S=S.dehydrated,S===null||Bt(S)||sn(S)))return d}else if(d.tag===19&&d.memoizedProps.revealOrder!==void 0){if((d.flags&128)!==0)return d}else if(d.child!==null){d.child.return=d,d=d.child;continue}if(d===f)break;for(;d.sibling===null;){if(d.return===null||d.return===f)return null;d=d.return}d.sibling.return=d.return,d=d.sibling}return null}var $p=[];function Jp(){for(var f=0;f<$p.length;f++){var d=$p[f];Ee?d._workInProgressVersionPrimary=null:d._workInProgressVersionSecondary=null}$p.length=0}var Dh=a.ReactCurrentDispatcher,ur=a.ReactCurrentBatchConfig,ja=0,bn=null,hi=null,Kn=null,Uh=!1,vc=!1,yc=0,y2=0;function fi(){throw Error(o(321))}function Qp(f,d){if(d===null)return!1;for(var S=0;SS?S:4,f(!0);var T=ur.transition;ur.transition={};try{f(!1),d()}finally{Ut=S,ur.transition=T}}function W_(){return $r().memoizedState}function x2(f,d,S){var T=Qs(f);S={lane:T,action:S,hasEagerState:!1,eagerState:null,next:null},X_(f)?j_(d,S):(Y_(f,d,S),S=Ti(),f=hr(f,T,S),f!==null&&q_(f,d,T))}function w2(f,d,S){var T=Qs(f),R={lane:T,action:S,hasEagerState:!1,eagerState:null,next:null};if(X_(f))j_(d,R);else{Y_(f,d,R);var U=f.alternate;if(f.lanes===0&&(U===null||U.lanes===0)&&(U=d.lastRenderedReducer,U!==null))try{var Q=d.lastRenderedState,he=U(Q,S);if(R.hasEagerState=!0,R.eagerState=he,Xi(he,Q))return}catch{}finally{}S=Ti(),f=hr(f,T,S),f!==null&&q_(f,d,T)}}function X_(f){var d=f.alternate;return f===bn||d!==null&&d===bn}function j_(f,d){vc=Uh=!0;var S=f.pending;S===null?d.next=d:(d.next=S.next,S.next=d),f.pending=d}function Y_(f,d,S){On!==null&&(f.mode&1)!==0&&(Dt&2)===0?(f=d.interleaved,f===null?(S.next=S,ji===null?ji=[d]:ji.push(d)):(S.next=f.next,f.next=S),d.interleaved=S):(f=d.pending,f===null?S.next=S:(S.next=f.next,f.next=S),d.pending=S)}function q_(f,d,S){if((S&4194240)!==0){var T=d.lanes;T&=f.pendingLanes,S|=T,d.lanes=S,qr(f,S)}}var zh={readContext:Pn,useCallback:fi,useContext:fi,useEffect:fi,useImperativeHandle:fi,useInsertionEffect:fi,useLayoutEffect:fi,useMemo:fi,useReducer:fi,useRef:fi,useState:fi,useDebugValue:fi,useDeferredValue:fi,useTransition:fi,useMutableSource:fi,useSyncExternalStore:fi,useId:fi,unstable_isNewReconciler:!1},S2={readContext:Pn,useCallback:function(f,d){return xs().memoizedState=[f,d===void 0?null:d],f},useContext:Pn,useEffect:im,useImperativeHandle:function(f,d,S){return S=S!=null?S.concat([f]):null,Fh(4194308,4,B_.bind(null,d,f),S)},useLayoutEffect:function(f,d){return Fh(4194308,4,f,d)},useInsertionEffect:function(f,d){return Fh(4,2,f,d)},useMemo:function(f,d){var S=xs();return d=d===void 0?null:d,f=f(),S.memoizedState=[f,d],f},useReducer:function(f,d,S){var T=xs();return d=S!==void 0?S(d):d,T.memoizedState=T.baseState=d,f={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:f,lastRenderedState:d},T.queue=f,f=f.dispatch=x2.bind(null,bn,f),[T.memoizedState,f]},useRef:function(f){var d=xs();return f={current:f},d.memoizedState=f},useState:nm,useDebugValue:rm,useDeferredValue:function(f){var d=nm(f),S=d[0],T=d[1];return im(function(){var R=ur.transition;ur.transition={};try{T(f)}finally{ur.transition=R}},[f]),S},useTransition:function(){var f=nm(!1),d=f[0];return f=_2.bind(null,f[1]),xs().memoizedState=f,[d,f]},useMutableSource:function(){},useSyncExternalStore:function(f,d,S){var T=bn,R=xs();if(un){if(S===void 0)throw Error(o(407));S=S()}else{if(S=d(),On===null)throw Error(o(349));(ja&30)!==0||D_(T,d,S)}R.memoizedState=S;var U={value:S,getSnapshot:d};return R.queue=U,im(O_.bind(null,T,U,f),[f]),T.flags|=2048,_c(9,U_.bind(null,T,U,S,d),void 0,null),S},useId:function(){var f=xs(),d=On.identifierPrefix;if(un){var S=_s,T=ys;S=(T&~(1<<32-Vi(T)-1)).toString(32)+S,d=":"+d+"R"+S,S=yc++,0Em&&(d.flags|=128,T=!0,Ec(R,!1),d.lanes=4194304)}else{if(!T)if(f=Ih(U),f!==null){if(d.flags|=128,T=!0,f=f.updateQueue,f!==null&&(d.updateQueue=f,d.flags|=4),Ec(R,!0),R.tail===null&&R.tailMode==="hidden"&&!U.alternate&&!un)return di(d),null}else 2*pn()-R.renderingStartTime>Em&&S!==1073741824&&(d.flags|=128,T=!0,Ec(R,!1),d.lanes=4194304);R.isBackwards?(U.sibling=d.child,d.child=U):(f=R.last,f!==null?f.sibling=U:d.child=U,R.last=U)}return R.tail!==null?(d=R.tail,R.rendering=d,R.tail=d.sibling,R.renderingStartTime=pn(),d.sibling=null,f=mn.current,gt(mn,T?f&1|2:f&1),d):(di(d),null);case 22:case 23:return Cm(),T=d.memoizedState!==null,f!==null&&f.memoizedState!==null!==T&&(d.flags|=8192),T&&(d.mode&1)!==0?(Ki&1073741824)!==0&&(di(d),ae&&d.subtreeFlags&6&&(d.flags|=8192)):di(d),null;case 24:return null;case 25:return null}throw Error(o(156,d.tag))}var A2=a.ReactCurrentOwner,Zi=!1;function Mi(f,d,S,T){d.child=f===null?R_(d,null,S,T):Va(d,f.child,S,T)}function nx(f,d,S,T,R){S=S.render;var U=d.ref;return Rn(d,R),T=em(f,d,S,T,U,R),S=tm(),f!==null&&!Zi?(d.updateQueue=f.updateQueue,d.flags&=-2053,f.lanes&=~R,ws(f,d,R)):(un&&S&&Wp(d),d.flags|=1,Mi(f,d,T,R),d.child)}function ix(f,d,S,T,R){if(f===null){var U=S.type;return typeof U=="function"&&!Pm(U)&&U.defaultProps===void 0&&S.compare===null&&S.defaultProps===void 0?(d.tag=15,d.type=U,rx(f,d,U,T,R)):(f=cf(S.type,null,T,d,d.mode,R),f.ref=d.ref,f.return=d,d.child=f)}if(U=f.child,(f.lanes&R)===0){var Q=U.memoizedProps;if(S=S.compare,S=S!==null?S:Uo,S(Q,T)&&f.ref===d.ref)return ws(f,d,R)}return d.flags|=1,f=to(U,T),f.ref=d.ref,f.return=d,d.child=f}function rx(f,d,S,T,R){if(f!==null&&Uo(f.memoizedProps,T)&&f.ref===d.ref)if(Zi=!1,(f.lanes&R)!==0)(f.flags&131072)!==0&&(Zi=!0);else return d.lanes=f.lanes,ws(f,d,R);return am(f,d,S,T,R)}function sx(f,d,S){var T=d.pendingProps,R=T.children,U=f!==null?f.memoizedState:null;if(T.mode==="hidden")if((d.mode&1)===0)d.memoizedState={baseLanes:0,cachePool:null},gt(Ya,Ki),Ki|=S;else if((S&1073741824)!==0)d.memoizedState={baseLanes:0,cachePool:null},T=U!==null?U.baseLanes:S,gt(Ya,Ki),Ki|=T;else return f=U!==null?U.baseLanes|S:S,d.lanes=d.childLanes=1073741824,d.memoizedState={baseLanes:f,cachePool:null},d.updateQueue=null,gt(Ya,Ki),Ki|=f,null;else U!==null?(T=U.baseLanes|S,d.memoizedState=null):T=S,gt(Ya,Ki),Ki|=T;return Mi(f,d,R,S),d.child}function ox(f,d){var S=d.ref;(f===null&&S!==null||f!==null&&f.ref!==S)&&(d.flags|=512,d.flags|=2097152)}function am(f,d,S,T,R){var U=on(S)?Ii:En.current;return U=Qt(d,U),Rn(d,R),S=em(f,d,S,T,U,R),T=tm(),f!==null&&!Zi?(d.updateQueue=f.updateQueue,d.flags&=-2053,f.lanes&=~R,ws(f,d,R)):(un&&T&&Wp(d),d.flags|=1,Mi(f,d,S,R),d.child)}function ax(f,d,S,T,R){if(on(S)){var U=!0;jr(d)}else U=!1;if(Rn(d,R),d.stateNode===null)f!==null&&(f.alternate=null,d.alternate=null,d.flags|=2),w_(d,S,T),Vp(d,S,T,R),T=!0;else if(f===null){var Q=d.stateNode,he=d.memoizedProps;Q.props=he;var Ce=Q.context,Xe=S.contextType;typeof Xe=="object"&&Xe!==null?Xe=Pn(Xe):(Xe=on(S)?Ii:En.current,Xe=Qt(d,Xe));var rt=S.getDerivedStateFromProps,St=typeof rt=="function"||typeof Q.getSnapshotBeforeUpdate=="function";St||typeof Q.UNSAFE_componentWillReceiveProps!="function"&&typeof Q.componentWillReceiveProps!="function"||(he!==T||Ce!==Xe)&&S_(d,Q,T,Xe),Zs=!1;var ht=d.memoizedState;Q.state=ht,Ah(d,T,Q,R),Ce=d.memoizedState,he!==T||ht!==Ce||cn.current||Zs?(typeof rt=="function"&&(Hp(d,S,rt,T),Ce=d.memoizedState),(he=Zs||x_(d,S,he,T,ht,Ce,Xe))?(St||typeof Q.UNSAFE_componentWillMount!="function"&&typeof Q.componentWillMount!="function"||(typeof Q.componentWillMount=="function"&&Q.componentWillMount(),typeof Q.UNSAFE_componentWillMount=="function"&&Q.UNSAFE_componentWillMount()),typeof Q.componentDidMount=="function"&&(d.flags|=4194308)):(typeof Q.componentDidMount=="function"&&(d.flags|=4194308),d.memoizedProps=T,d.memoizedState=Ce),Q.props=T,Q.state=Ce,Q.context=Xe,T=he):(typeof Q.componentDidMount=="function"&&(d.flags|=4194308),T=!1)}else{Q=d.stateNode,g_(f,d),he=d.memoizedProps,Xe=d.type===d.elementType?he:Ei(d.type,he),Q.props=Xe,St=d.pendingProps,ht=Q.context,Ce=S.contextType,typeof Ce=="object"&&Ce!==null?Ce=Pn(Ce):(Ce=on(S)?Ii:En.current,Ce=Qt(d,Ce));var nn=S.getDerivedStateFromProps;(rt=typeof nn=="function"||typeof Q.getSnapshotBeforeUpdate=="function")||typeof Q.UNSAFE_componentWillReceiveProps!="function"&&typeof Q.componentWillReceiveProps!="function"||(he!==St||ht!==Ce)&&S_(d,Q,T,Ce),Zs=!1,ht=d.memoizedState,Q.state=ht,Ah(d,T,Q,R);var at=d.memoizedState;he!==St||ht!==at||cn.current||Zs?(typeof nn=="function"&&(Hp(d,S,nn,T),at=d.memoizedState),(Xe=Zs||x_(d,S,Xe,T,ht,at,Ce)||!1)?(rt||typeof Q.UNSAFE_componentWillUpdate!="function"&&typeof Q.componentWillUpdate!="function"||(typeof Q.componentWillUpdate=="function"&&Q.componentWillUpdate(T,at,Ce),typeof Q.UNSAFE_componentWillUpdate=="function"&&Q.UNSAFE_componentWillUpdate(T,at,Ce)),typeof Q.componentDidUpdate=="function"&&(d.flags|=4),typeof Q.getSnapshotBeforeUpdate=="function"&&(d.flags|=1024)):(typeof Q.componentDidUpdate!="function"||he===f.memoizedProps&&ht===f.memoizedState||(d.flags|=4),typeof Q.getSnapshotBeforeUpdate!="function"||he===f.memoizedProps&&ht===f.memoizedState||(d.flags|=1024),d.memoizedProps=T,d.memoizedState=at),Q.props=T,Q.state=at,Q.context=Ce,T=Xe):(typeof Q.componentDidUpdate!="function"||he===f.memoizedProps&&ht===f.memoizedState||(d.flags|=4),typeof Q.getSnapshotBeforeUpdate!="function"||he===f.memoizedProps&&ht===f.memoizedState||(d.flags|=1024),T=!1)}return lm(f,d,S,T,U,R)}function lm(f,d,S,T,R,U){ox(f,d);var Q=(d.flags&128)!==0;if(!T&&!Q)return R&&ui(d,S,!1),ws(f,d,U);T=d.stateNode,A2.current=d;var he=Q&&typeof S.getDerivedStateFromError!="function"?null:T.render();return d.flags|=1,f!==null&&Q?(d.child=Va(d,f.child,null,U),d.child=Va(d,null,he,U)):Mi(f,d,he,U),d.memoizedState=T.state,R&&ui(d,S,!0),d.child}function lx(f){var d=f.stateNode;d.pendingContext?Un(f,d.pendingContext,d.pendingContext!==d.context):d.context&&Un(f,d.context,!1),Zp(f,d.containerInfo)}function cx(f,d,S,T,R){return Ha(),qp(R),d.flags|=256,Mi(f,d,S,T),d.child}var Hh={dehydrated:null,treeContext:null,retryLane:0};function Vh(f){return{baseLanes:f,cachePool:null}}function ux(f,d,S){var T=d.pendingProps,R=mn.current,U=!1,Q=(d.flags&128)!==0,he;if((he=Q)||(he=f!==null&&f.memoizedState===null?!1:(R&2)!==0),he?(U=!0,d.flags&=-129):(f===null||f.memoizedState!==null)&&(R|=1),gt(mn,R&1),f===null)return Yp(d),f=d.memoizedState,f!==null&&(f=f.dehydrated,f!==null)?((d.mode&1)===0?d.lanes=1:sn(f)?d.lanes=8:d.lanes=1073741824,null):(R=T.children,f=T.fallback,U?(T=d.mode,U=d.child,R={mode:"hidden",children:R},(T&1)===0&&U!==null?(U.childLanes=0,U.pendingProps=R):U=uf(R,T,0,null),f=Wo(f,T,S,null),U.return=d,f.return=d,U.sibling=f,d.child=U,d.child.memoizedState=Vh(S),d.memoizedState=Hh,f):cm(d,R));if(R=f.memoizedState,R!==null){if(he=R.dehydrated,he!==null){if(Q)return d.flags&256?(d.flags&=-257,Wh(f,d,S,Error(o(422)))):d.memoizedState!==null?(d.child=f.child,d.flags|=128,null):(U=T.fallback,R=d.mode,T=uf({mode:"visible",children:T.children},R,0,null),U=Wo(U,R,S,null),U.flags|=2,T.return=d,U.return=d,T.sibling=U,d.child=T,(d.mode&1)!==0&&Va(d,f.child,null,S),d.child.memoizedState=Vh(S),d.memoizedState=Hh,U);if((d.mode&1)===0)d=Wh(f,d,S,null);else if(sn(he))d=Wh(f,d,S,Error(o(419)));else if(T=(S&f.childLanes)!==0,Zi||T){if(T=On,T!==null){switch(S&-S){case 4:U=2;break;case 16:U=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:U=32;break;case 536870912:U=268435456;break;default:U=0}T=(U&(T.suspendedLanes|S))!==0?0:U,T!==0&&T!==R.retryLane&&(R.retryLane=T,hr(f,T,-1))}Rm(),d=Wh(f,d,S,Error(o(421)))}else Bt(he)?(d.flags|=128,d.child=f.child,d=B2.bind(null,f),ti(he,d),d=null):(S=R.treeContext,oe&&(qi=sr(he),Yi=d,un=!0,Ar=null,fc=!1,S!==null&&(ar[lr++]=ys,ar[lr++]=_s,ar[lr++]=No,ys=S.id,_s=S.overflow,No=d)),d=cm(d,d.pendingProps.children),d.flags|=4096);return d}return U?(T=fx(f,d,T.children,T.fallback,S),U=d.child,R=f.child.memoizedState,U.memoizedState=R===null?Vh(S):{baseLanes:R.baseLanes|S,cachePool:null},U.childLanes=f.childLanes&~S,d.memoizedState=Hh,T):(S=hx(f,d,T.children,S),d.memoizedState=null,S)}return U?(T=fx(f,d,T.children,T.fallback,S),U=d.child,R=f.child.memoizedState,U.memoizedState=R===null?Vh(S):{baseLanes:R.baseLanes|S,cachePool:null},U.childLanes=f.childLanes&~S,d.memoizedState=Hh,T):(S=hx(f,d,T.children,S),d.memoizedState=null,S)}function cm(f,d){return d=uf({mode:"visible",children:d},f.mode,0,null),d.return=f,f.child=d}function hx(f,d,S,T){var R=f.child;return f=R.sibling,S=to(R,{mode:"visible",children:S}),(d.mode&1)===0&&(S.lanes=T),S.return=d,S.sibling=null,f!==null&&(T=d.deletions,T===null?(d.deletions=[f],d.flags|=16):T.push(f)),d.child=S}function fx(f,d,S,T,R){var U=d.mode;f=f.child;var Q=f.sibling,he={mode:"hidden",children:S};return(U&1)===0&&d.child!==f?(S=d.child,S.childLanes=0,S.pendingProps=he,d.deletions=null):(S=to(f,he),S.subtreeFlags=f.subtreeFlags&14680064),Q!==null?T=to(Q,T):(T=Wo(T,U,R,null),T.flags|=2),T.return=d,S.return=d,S.sibling=T,d.child=S,T}function Wh(f,d,S,T){return T!==null&&qp(T),Va(d,f.child,null,S),f=cm(d,d.pendingProps.children),f.flags|=2,d.memoizedState=null,f}function dx(f,d,S){f.lanes|=d;var T=f.alternate;T!==null&&(T.lanes|=d),bi(f.return,d,S)}function um(f,d,S,T,R){var U=f.memoizedState;U===null?f.memoizedState={isBackwards:d,rendering:null,renderingStartTime:0,last:T,tail:S,tailMode:R}:(U.isBackwards=d,U.rendering=null,U.renderingStartTime=0,U.last=T,U.tail=S,U.tailMode=R)}function px(f,d,S){var T=d.pendingProps,R=T.revealOrder,U=T.tail;if(Mi(f,d,T.children,S),T=mn.current,(T&2)!==0)T=T&1|2,d.flags|=128;else{if(f!==null&&(f.flags&128)!==0)e:for(f=d.child;f!==null;){if(f.tag===13)f.memoizedState!==null&&dx(f,S,d);else if(f.tag===19)dx(f,S,d);else if(f.child!==null){f.child.return=f,f=f.child;continue}if(f===d)break e;for(;f.sibling===null;){if(f.return===null||f.return===d)break e;f=f.return}f.sibling.return=f.return,f=f.sibling}T&=1}if(gt(mn,T),(d.mode&1)===0)d.memoizedState=null;else switch(R){case"forwards":for(S=d.child,R=null;S!==null;)f=S.alternate,f!==null&&Ih(f)===null&&(R=S),S=S.sibling;S=R,S===null?(R=d.child,d.child=null):(R=S.sibling,S.sibling=null),um(d,!1,R,S,U);break;case"backwards":for(S=null,R=d.child,d.child=null;R!==null;){if(f=R.alternate,f!==null&&Ih(f)===null){d.child=R;break}f=R.sibling,R.sibling=S,S=R,R=f}um(d,!0,S,null,U);break;case"together":um(d,!1,null,null,void 0);break;default:d.memoizedState=null}return d.child}function ws(f,d,S){if(f!==null&&(d.dependencies=f.dependencies),qa|=d.lanes,(S&d.childLanes)===0)return null;if(f!==null&&d.child!==f.child)throw Error(o(153));if(d.child!==null){for(f=d.child,S=to(f,f.pendingProps),d.child=S,S.return=d;f.sibling!==null;)f=f.sibling,S=S.sibling=to(f,f.pendingProps),S.return=d;S.sibling=null}return d.child}function C2(f,d,S){switch(d.tag){case 3:lx(d),Ha();break;case 5:P_(d);break;case 1:on(d.type)&&jr(d);break;case 4:Zp(d,d.stateNode.containerInfo);break;case 10:Mh(d,d.type._context,d.memoizedProps.value);break;case 13:var T=d.memoizedState;if(T!==null)return T.dehydrated!==null?(gt(mn,mn.current&1),d.flags|=128,null):(S&d.child.childLanes)!==0?ux(f,d,S):(gt(mn,mn.current&1),f=ws(f,d,S),f!==null?f.sibling:null);gt(mn,mn.current&1);break;case 19:if(T=(S&d.childLanes)!==0,(f.flags&128)!==0){if(T)return px(f,d,S);d.flags|=128}var R=d.memoizedState;if(R!==null&&(R.rendering=null,R.tail=null,R.lastEffect=null),gt(mn,mn.current),T)break;return null;case 22:case 23:return d.lanes=0,sx(f,d,S)}return ws(f,d,S)}function R2(f,d){switch(Xp(d),d.tag){case 1:return on(d.type)&&xi(),f=d.flags,f&65536?(d.flags=f&-65537|128,d):null;case 3:return Xa(),kt(cn),kt(En),Jp(),f=d.flags,(f&65536)!==0&&(f&128)===0?(d.flags=f&-65537|128,d):null;case 5:return Kp(d),null;case 13:if(kt(mn),f=d.memoizedState,f!==null&&f.dehydrated!==null){if(d.alternate===null)throw Error(o(340));Ha()}return f=d.flags,f&65536?(d.flags=f&-65537|128,d):null;case 19:return kt(mn),null;case 4:return Xa(),null;case 10:return Zn(d.type._context),null;case 22:case 23:return Cm(),null;case 24:return null;default:return null}}var Xh=!1,zo=!1,P2=typeof WeakSet=="function"?WeakSet:Set,Qe=null;function jh(f,d){var S=f.ref;if(S!==null)if(typeof S=="function")try{S(null)}catch(T){Ni(f,d,T)}else S.current=null}function hm(f,d,S){try{S()}catch(T){Ni(f,d,T)}}var mx=!1;function L2(f,d){for(G(f.containerInfo),Qe=d;Qe!==null;)if(f=Qe,d=f.child,(f.subtreeFlags&1028)!==0&&d!==null)d.return=f,Qe=d;else for(;Qe!==null;){f=Qe;try{var S=f.alternate;if((f.flags&1024)!==0)switch(f.tag){case 0:case 11:case 15:break;case 1:if(S!==null){var T=S.memoizedProps,R=S.memoizedState,U=f.stateNode,Q=U.getSnapshotBeforeUpdate(f.elementType===f.type?T:Ei(f.type,T),R);U.__reactInternalSnapshotBeforeUpdate=Q}break;case 3:ae&&Ge(f.stateNode.containerInfo);break;case 5:case 6:case 4:case 17:break;default:throw Error(o(163))}}catch(he){Ni(f,f.return,he)}if(d=f.sibling,d!==null){d.return=f.return,Qe=d;break}Qe=f.return}return S=mx,mx=!1,S}function Bo(f,d,S){var T=d.updateQueue;if(T=T!==null?T.lastEffect:null,T!==null){var R=T=T.next;do{if((R.tag&f)===f){var U=R.destroy;R.destroy=void 0,U!==void 0&&hm(d,S,U)}R=R.next}while(R!==T)}}function bc(f,d){if(d=d.updateQueue,d=d!==null?d.lastEffect:null,d!==null){var S=d=d.next;do{if((S.tag&f)===f){var T=S.create;S.destroy=T()}S=S.next}while(S!==d)}}function fm(f){var d=f.ref;if(d!==null){var S=f.stateNode;switch(f.tag){case 5:f=W(S);break;default:f=S}typeof d=="function"?d(f):d.current=f}}function gx(f,d,S){if(Wi&&typeof Wi.onCommitFiberUnmount=="function")try{Wi.onCommitFiberUnmount(Io,d)}catch{}switch(d.tag){case 0:case 11:case 14:case 15:if(f=d.updateQueue,f!==null&&(f=f.lastEffect,f!==null)){var T=f=f.next;do{var R=T,U=R.destroy;R=R.tag,U!==void 0&&((R&2)!==0||(R&4)!==0)&&hm(d,S,U),T=T.next}while(T!==f)}break;case 1:if(jh(d,S),f=d.stateNode,typeof f.componentWillUnmount=="function")try{f.props=d.memoizedProps,f.state=d.memoizedState,f.componentWillUnmount()}catch(Q){Ni(d,S,Q)}break;case 5:jh(d,S);break;case 4:ae?Sx(f,d,S):z&&z&&(d=d.stateNode.containerInfo,S=_t(d),Ot(d,S))}}function vx(f,d,S){for(var T=d;;)if(gx(f,T,S),T.child===null||ae&&T.tag===4){if(T===d)break;for(;T.sibling===null;){if(T.return===null||T.return===d)return;T=T.return}T.sibling.return=T.return,T=T.sibling}else T.child.return=T,T=T.child}function yx(f){var d=f.alternate;d!==null&&(f.alternate=null,yx(d)),f.child=null,f.deletions=null,f.sibling=null,f.tag===5&&(d=f.stateNode,d!==null&&Ie(d)),f.stateNode=null,f.return=null,f.dependencies=null,f.memoizedProps=null,f.memoizedState=null,f.pendingProps=null,f.stateNode=null,f.updateQueue=null}function _x(f){return f.tag===5||f.tag===3||f.tag===4}function xx(f){e:for(;;){for(;f.sibling===null;){if(f.return===null||_x(f.return))return null;f=f.return}for(f.sibling.return=f.return,f=f.sibling;f.tag!==5&&f.tag!==6&&f.tag!==18;){if(f.flags&2||f.child===null||f.tag===4)continue e;f.child.return=f,f=f.child}if(!(f.flags&2))return f.stateNode}}function wx(f){if(ae){e:{for(var d=f.return;d!==null;){if(_x(d))break e;d=d.return}throw Error(o(160))}var S=d;switch(S.tag){case 5:d=S.stateNode,S.flags&32&&(nt(d),S.flags&=-33),S=xx(f),pm(f,S,d);break;case 3:case 4:d=S.stateNode.containerInfo,S=xx(f),dm(f,S,d);break;default:throw Error(o(161))}}}function dm(f,d,S){var T=f.tag;if(T===5||T===6)f=f.stateNode,d?Ve(S,f,d):Fe(S,f);else if(T!==4&&(f=f.child,f!==null))for(dm(f,d,S),f=f.sibling;f!==null;)dm(f,d,S),f=f.sibling}function pm(f,d,S){var T=f.tag;if(T===5||T===6)f=f.stateNode,d?$e(S,f,d):Me(S,f);else if(T!==4&&(f=f.child,f!==null))for(pm(f,d,S),f=f.sibling;f!==null;)pm(f,d,S),f=f.sibling}function Sx(f,d,S){for(var T=d,R=!1,U,Q;;){if(!R){R=T.return;e:for(;;){if(R===null)throw Error(o(160));switch(U=R.stateNode,R.tag){case 5:Q=!1;break e;case 3:U=U.containerInfo,Q=!0;break e;case 4:U=U.containerInfo,Q=!0;break e}R=R.return}R=!0}if(T.tag===5||T.tag===6)vx(f,T,S),Q?We(U,T.stateNode):Oe(U,T.stateNode);else if(T.tag===18)Q?lt(U,T.stateNode):it(U,T.stateNode);else if(T.tag===4){if(T.child!==null){U=T.stateNode.containerInfo,Q=!0,T.child.return=T,T=T.child;continue}}else if(gx(f,T,S),T.child!==null){T.child.return=T,T=T.child;continue}if(T===d)break;for(;T.sibling===null;){if(T.return===null||T.return===d)return;T=T.return,T.tag===4&&(R=!1)}T.sibling.return=T.return,T=T.sibling}}function mm(f,d){if(ae){switch(d.tag){case 0:case 11:case 14:case 15:Bo(3,d,d.return),bc(3,d),Bo(5,d,d.return);return;case 1:return;case 5:var S=d.stateNode;if(S!=null){var T=d.memoizedProps;f=f!==null?f.memoizedProps:T;var R=d.type,U=d.updateQueue;d.updateQueue=null,U!==null&&Be(S,U,R,f,T,d)}return;case 6:if(d.stateNode===null)throw Error(o(162));S=d.memoizedProps,Ue(d.stateNode,f!==null?f.memoizedProps:S,S);return;case 3:oe&&f!==null&&f.memoizedState.isDehydrated&&pe(d.stateNode.containerInfo);return;case 12:return;case 13:Yh(d);return;case 19:Yh(d);return;case 17:return}throw Error(o(163))}switch(d.tag){case 0:case 11:case 14:case 15:Bo(3,d,d.return),bc(3,d),Bo(5,d,d.return);return;case 12:return;case 13:Yh(d);return;case 19:Yh(d);return;case 3:oe&&f!==null&&f.memoizedState.isDehydrated&&pe(d.stateNode.containerInfo);break;case 22:case 23:return}e:if(z){switch(d.tag){case 1:case 5:case 6:break e;case 3:case 4:d=d.stateNode,Ot(d.containerInfo,d.pendingChildren);break e}throw Error(o(163))}}function Yh(f){var d=f.updateQueue;if(d!==null){f.updateQueue=null;var S=f.stateNode;S===null&&(S=f.stateNode=new P2),d.forEach(function(T){var R=G2.bind(null,f,T);S.has(T)||(S.add(T),T.then(R,R))})}}function I2(f,d){for(Qe=d;Qe!==null;){d=Qe;var S=d.deletions;if(S!==null)for(var T=0;T";case Zh:return":has("+(ym(f)||"")+")";case Kh:return'[role="'+f.value+'"]';case Jh:return'"'+f.value+'"';case $h:return'[data-testname="'+f.value+'"]';default:throw Error(o(365))}}function Ax(f,d){var S=[];f=[f,0];for(var T=0;TR&&(R=Q),T&=~U}if(T=R,T=pn()-T,T=(120>T?120:480>T?480:1080>T?1080:1920>T?1920:3e3>T?3e3:4320>T?4320:1960*U2(T/1960))-T,10f?16:f,Js===null)var T=!1;else{if(f=Js,Js=null,rf=0,(Dt&6)!==0)throw Error(o(331));var R=Dt;for(Dt|=4,Qe=f.current;Qe!==null;){var U=Qe,Q=U.child;if((Qe.flags&16)!==0){var he=U.deletions;if(he!==null){for(var Ce=0;Cepn()-Sm?Go(f,0):wm|=S),Oi(f,d)}function Nx(f,d){d===0&&((f.mode&1)===0?d=1:(d=ds,ds<<=1,(ds&130023424)===0&&(ds=4194304)));var S=Ti();f=af(f,d),f!==null&&(Yr(f,d,S),Oi(f,S))}function B2(f){var d=f.memoizedState,S=0;d!==null&&(S=d.retryLane),Nx(f,S)}function G2(f,d){var S=0;switch(f.tag){case 13:var T=f.stateNode,R=f.memoizedState;R!==null&&(S=R.retryLane);break;case 19:T=f.stateNode;break;default:throw Error(o(314))}T!==null&&T.delete(d),Nx(f,S)}var Fx;Fx=function(f,d,S){if(f!==null)if(f.memoizedProps!==d.pendingProps||cn.current)Zi=!0;else{if((f.lanes&S)===0&&(d.flags&128)===0)return Zi=!1,C2(f,d,S);Zi=(f.flags&131072)!==0}else Zi=!1,un&&(d.flags&1048576)!==0&&E_(d,Ph,d.index);switch(d.lanes=0,d.tag){case 2:var T=d.type;f!==null&&(f.alternate=null,d.alternate=null,d.flags|=2),f=d.pendingProps;var R=Qt(d,En.current);Rn(d,S),R=em(null,d,T,f,R,S);var U=tm();return d.flags|=1,typeof R=="object"&&R!==null&&typeof R.render=="function"&&R.$$typeof===void 0?(d.tag=1,d.memoizedState=null,d.updateQueue=null,on(T)?(U=!0,jr(d)):U=!1,d.memoizedState=R.state!==null&&R.state!==void 0?R.state:null,Gp(d),R.updater=Ch,d.stateNode=R,R._reactInternals=d,Vp(d,T,f,S),d=lm(null,d,T,!0,U,S)):(d.tag=0,un&&U&&Wp(d),Mi(null,d,R,S),d=d.child),d;case 16:T=d.elementType;e:{switch(f!==null&&(f.alternate=null,d.alternate=null,d.flags|=2),f=d.pendingProps,R=T._init,T=R(T._payload),d.type=T,R=d.tag=V2(T),f=Ei(T,f),R){case 0:d=am(null,d,T,f,S);break e;case 1:d=ax(null,d,T,f,S);break e;case 11:d=nx(null,d,T,f,S);break e;case 14:d=ix(null,d,T,Ei(T.type,f),S);break e}throw Error(o(306,T,""))}return d;case 0:return T=d.type,R=d.pendingProps,R=d.elementType===T?R:Ei(T,R),am(f,d,T,R,S);case 1:return T=d.type,R=d.pendingProps,R=d.elementType===T?R:Ei(T,R),ax(f,d,T,R,S);case 3:e:{if(lx(d),f===null)throw Error(o(387));T=d.pendingProps,U=d.memoizedState,R=U.element,g_(f,d),Ah(d,T,null,S);var Q=d.memoizedState;if(T=Q.element,oe&&U.isDehydrated)if(U={element:T,isDehydrated:!1,cache:Q.cache,transitions:Q.transitions},d.updateQueue.baseState=U,d.memoizedState=U,d.flags&256){R=Error(o(423)),d=cx(f,d,T,S,R);break e}else if(T!==R){R=Error(o(424)),d=cx(f,d,T,S,R);break e}else for(oe&&(qi=Gn(d.stateNode.containerInfo),Yi=d,un=!0,Ar=null,fc=!1),S=R_(d,null,T,S),d.child=S;S;)S.flags=S.flags&-3|4096,S=S.sibling;else{if(Ha(),T===R){d=ws(f,d,S);break e}Mi(f,d,T,S)}d=d.child}return d;case 5:return P_(d),f===null&&Yp(d),T=d.type,R=d.pendingProps,U=f!==null?f.memoizedProps:null,Q=R.children,ie(T,R)?Q=null:U!==null&&ie(T,U)&&(d.flags|=32),ox(f,d),Mi(f,d,Q,S),d.child;case 6:return f===null&&Yp(d),null;case 13:return ux(f,d,S);case 4:return Zp(d,d.stateNode.containerInfo),T=d.pendingProps,f===null?d.child=Va(d,null,T,S):Mi(f,d,T,S),d.child;case 11:return T=d.type,R=d.pendingProps,R=d.elementType===T?R:Ei(T,R),nx(f,d,T,R,S);case 7:return Mi(f,d,d.pendingProps,S),d.child;case 8:return Mi(f,d,d.pendingProps.children,S),d.child;case 12:return Mi(f,d,d.pendingProps.children,S),d.child;case 10:e:{if(T=d.type._context,R=d.pendingProps,U=d.memoizedProps,Q=R.value,Mh(d,T,Q),U!==null)if(Xi(U.value,Q)){if(U.children===R.children&&!cn.current){d=ws(f,d,S);break e}}else for(U=d.child,U!==null&&(U.return=d);U!==null;){var he=U.dependencies;if(he!==null){Q=U.child;for(var Ce=he.firstContext;Ce!==null;){if(Ce.context===T){if(U.tag===1){Ce=vs(-1,S&-S),Ce.tag=2;var Xe=U.updateQueue;if(Xe!==null){Xe=Xe.shared;var rt=Xe.pending;rt===null?Ce.next=Ce:(Ce.next=rt.next,rt.next=Ce),Xe.pending=Ce}}U.lanes|=S,Ce=U.alternate,Ce!==null&&(Ce.lanes|=S),bi(U.return,S,d),he.lanes|=S;break}Ce=Ce.next}}else if(U.tag===10)Q=U.type===d.type?null:U.child;else if(U.tag===18){if(Q=U.return,Q===null)throw Error(o(341));Q.lanes|=S,he=Q.alternate,he!==null&&(he.lanes|=S),bi(Q,S,d),Q=U.sibling}else Q=U.child;if(Q!==null)Q.return=U;else for(Q=U;Q!==null;){if(Q===d){Q=null;break}if(U=Q.sibling,U!==null){U.return=Q.return,Q=U;break}Q=Q.return}U=Q}Mi(f,d,R.children,S),d=d.child}return d;case 9:return R=d.type,T=d.pendingProps.children,Rn(d,S),R=Pn(R),T=T(R),d.flags|=1,Mi(f,d,T,S),d.child;case 14:return T=d.type,R=Ei(T,d.pendingProps),R=Ei(T.type,R),ix(f,d,T,R,S);case 15:return rx(f,d,d.type,d.pendingProps,S);case 17:return T=d.type,R=d.pendingProps,R=d.elementType===T?R:Ei(T,R),f!==null&&(f.alternate=null,d.alternate=null,d.flags|=2),d.tag=1,on(T)?(f=!0,jr(d)):f=!1,Rn(d,S),w_(d,T,R),Vp(d,T,R,S),lm(null,d,T,!0,f,S);case 19:return px(f,d,S);case 22:return sx(f,d,S)}throw Error(o(156,d.tag))};function kx(f,d){return gs(f,d)}function H2(f,d,S,T){this.tag=f,this.key=S,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=d,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=T,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function fr(f,d,S,T){return new H2(f,d,S,T)}function Pm(f){return f=f.prototype,!(!f||!f.isReactComponent)}function V2(f){if(typeof f=="function")return Pm(f)?1:0;if(f!=null){if(f=f.$$typeof,f===_)return 11;if(f===x)return 14}return 2}function to(f,d){var S=f.alternate;return S===null?(S=fr(f.tag,d,f.key,f.mode),S.elementType=f.elementType,S.type=f.type,S.stateNode=f.stateNode,S.alternate=f,f.alternate=S):(S.pendingProps=d,S.type=f.type,S.flags=0,S.subtreeFlags=0,S.deletions=null),S.flags=f.flags&14680064,S.childLanes=f.childLanes,S.lanes=f.lanes,S.child=f.child,S.memoizedProps=f.memoizedProps,S.memoizedState=f.memoizedState,S.updateQueue=f.updateQueue,d=f.dependencies,S.dependencies=d===null?null:{lanes:d.lanes,firstContext:d.firstContext},S.sibling=f.sibling,S.index=f.index,S.ref=f.ref,S}function cf(f,d,S,T,R,U){var Q=2;if(T=f,typeof f=="function")Pm(f)&&(Q=1);else if(typeof f=="string")Q=5;else e:switch(f){case u:return Wo(S.children,R,U,d);case h:Q=8,R|=8;break;case p:return f=fr(12,S,d,R|2),f.elementType=p,f.lanes=U,f;case y:return f=fr(13,S,d,R),f.elementType=y,f.lanes=U,f;case g:return f=fr(19,S,d,R),f.elementType=g,f.lanes=U,f;case E:return uf(S,R,U,d);default:if(typeof f=="object"&&f!==null)switch(f.$$typeof){case m:Q=10;break e;case v:Q=9;break e;case _:Q=11;break e;case x:Q=14;break e;case w:Q=16,T=null;break e}throw Error(o(130,f==null?f:typeof f,""))}return d=fr(Q,S,d,R),d.elementType=f,d.type=T,d.lanes=U,d}function Wo(f,d,S,T){return f=fr(7,f,T,d),f.lanes=S,f}function uf(f,d,S,T){return f=fr(22,f,T,d),f.elementType=E,f.lanes=S,f.stateNode={},f}function Lm(f,d,S){return f=fr(6,f,null,d),f.lanes=S,f}function Im(f,d,S){return d=fr(4,f.children!==null?f.children:[],f.key,d),d.lanes=S,d.stateNode={containerInfo:f.containerInfo,pendingChildren:null,implementation:f.implementation},d}function W2(f,d,S,T,R){this.tag=d,this.containerInfo=f,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=Ae,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Na(0),this.expirationTimes=Na(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Na(0),this.identifierPrefix=T,this.onRecoverableError=R,oe&&(this.mutableSourceEagerHydrationData=null)}function zx(f,d,S,T,R,U,Q,he,Ce){return f=new W2(f,d,S,he,Ce),d===1?(d=1,U===!0&&(d|=8)):d=0,U=fr(3,null,null,d),f.current=U,U.stateNode=f,U.memoizedState={element:T,isDehydrated:S,cache:null,transitions:null},Gp(U),f}function Bx(f){if(!f)return Cn;f=f._reactInternals;e:{if(C(f)!==f||f.tag!==1)throw Error(o(170));var d=f;do{switch(d.tag){case 3:d=d.stateNode.context;break e;case 1:if(on(d.type)){d=d.stateNode.__reactInternalMemoizedMergedChildContext;break e}}d=d.return}while(d!==null);throw Error(o(171))}if(f.tag===1){var S=f.type;if(on(S))return Xr(f,S,d)}return d}function Gx(f){var d=f._reactInternals;if(d===void 0)throw typeof f.render=="function"?Error(o(188)):(f=Object.keys(f).join(","),Error(o(268,f)));return f=N(d),f===null?null:f.stateNode}function Hx(f,d){if(f=f.memoizedState,f!==null&&f.dehydrated!==null){var S=f.retryLane;f.retryLane=S!==0&&S=Xe&&U>=St&&R<=rt&&Q<=ht){f.splice(d,1);break}else if(T!==Xe||S.width!==Ce.width||htQ){if(!(U!==St||S.height!==Ce.height||rtR)){Xe>T&&(Ce.width+=Xe-T,Ce.x=T),rtU&&(Ce.height+=St-U,Ce.y=U),htS&&(S=Q)),Q ")+` No matching component was found for: `)+f.join(" > ")}return null},t.getPublicRootInstance=function(f){if(f=f.current,!f.child)return null;switch(f.child.tag){case 5:return W(f.child.stateNode);default:return f.child.stateNode}},t.injectIntoDevTools=function(f){if(f={bundleType:f.bundleType,version:f.version,rendererPackageName:f.rendererPackageName,rendererConfig:f.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:a.ReactCurrentDispatcher,findHostInstanceByFiber:X2,findFiberByHostInstance:f.findFiberByHostInstance||j2,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.0.0-fc46dba67-20220329"},typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u")f=!1;else{var d=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(d.isDisabled||!d.supportsFiber)f=!0;else{try{Io=d.inject(f),Wi=d}catch{}f=!!d.checkDCE}}return f},t.isAlreadyRendering=function(){return!1},t.observeVisibleRects=function(f,d,S,T){if(!Le)throw Error(o(363));f=_m(f,d);var R=be(f,S,T).disconnect;return{disconnect:function(){R()}}},t.registerMutableSourceForHydration=function(f,d){var S=d._getVersion;S=S(d._source),f.mutableSourceEagerHydrationData==null?f.mutableSourceEagerHydrationData=[d,S]:f.mutableSourceEagerHydrationData.push(d,S)},t.runWithPriority=function(f,d){var S=Ut;try{return Ut=f,d()}finally{Ut=S}},t.shouldError=function(){return null},t.shouldSuspend=function(){return!1},t.updateContainer=function(f,d,S,T){var R=d.current,U=Ti(),Q=Qs(R);return S=Bx(S),d.context===null?d.context=S:d.pendingContext=S,d=vs(U,Q),d.payload={element:f},T=T===void 0?null:T,T!==null&&(d.callback=T),Ks(R,d),f=hr(R,Q,U),f!==null&&Th(f,R,Q),Q},t}),yg}var Sw;function j3(){return Sw||(Sw=1,mg.exports=X3()),mg.exports}var Y3=j3();const q3=Hr(Y3);var _g={exports:{}},xg={};/** * @license React * scheduler.production.min.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var Ew;function Z3(){return Ew||(Ew=1,(function(r){function e(k,G){var B=k.length;k.push(G);e:for(;0>>1,V=k[D];if(0>>1;Di(ie,B))uei(ce,ie)?(k[D]=ce,k[ue]=B,D=ue):(k[D]=ie,k[ee]=B,D=ee);else if(uei(ce,B))k[D]=ce,k[ue]=B,D=ue;else break e}}return G}function i(k,G){var B=k.sortIndex-G.sortIndex;return B!==0?B:k.id-G.id}if(typeof performance=="object"&&typeof performance.now=="function"){var s=performance;r.unstable_now=function(){return s.now()}}else{var o=Date,a=o.now();r.unstable_now=function(){return o.now()-a}}var l=[],c=[],u=1,h=null,p=3,m=!1,v=!1,_=!1,y=typeof setTimeout=="function"?setTimeout:null,g=typeof clearTimeout=="function"?clearTimeout:null,x=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function w(k){for(var G=t(c);G!==null;){if(G.callback===null)n(c);else if(G.startTime<=k)n(c),G.sortIndex=G.expirationTime,e(l,G);else break;G=t(c)}}function E(k){if(_=!1,w(k),!v)if(t(l)!==null)v=!0,W(b);else{var G=t(c);G!==null&&O(E,G.startTime-k)}}function b(k,G){v=!1,_&&(_=!1,g(P),P=-1),m=!0;var B=p;try{for(w(G),h=t(l);h!==null&&(!(h.expirationTime>G)||k&&!F());){var D=h.callback;if(typeof D=="function"){h.callback=null,p=h.priorityLevel;var V=D(h.expirationTime<=G);G=r.unstable_now(),typeof V=="function"?h.callback=V:h===t(l)&&n(l),w(G)}else n(l);h=t(l)}if(h!==null)var Z=!0;else{var ee=t(c);ee!==null&&O(E,ee.startTime-G),Z=!1}return Z}finally{h=null,p=B,m=!1}}var M=!1,A=null,P=-1,C=5,L=-1;function F(){return!(r.unstable_now()-Lk||125D?(k.sortIndex=B,e(c,k),t(l)===null&&k===t(c)&&(_?(g(P),P=-1):_=!0,O(E,B-D))):(k.sortIndex=V,e(l,k),v||m||(v=!0,W(b))),k},r.unstable_shouldYield=F,r.unstable_wrapCallback=function(k){var G=p;return function(){var B=p;p=G;try{return k.apply(this,arguments)}finally{p=B}}}})(xg)),xg}var bw;function K3(){return bw||(bw=1,_g.exports=Z3()),_g.exports}var Mw=K3();const $3=r=>typeof r=="object"&&typeof r.then=="function",Jf=[];function J3(r,e,t=(n,i)=>n===i){if(r===e)return!0;if(!r||!e)return!1;const n=r.length;if(e.length!==n)return!1;for(let i=0;i0&&(s.timeout&&clearTimeout(s.timeout),s.timeout=setTimeout(s.remove,n.lifespan)),s.response;if(!t)throw s.promise}const i={keys:e,equal:n.equal,remove:()=>{const s=Jf.indexOf(i);s!==-1&&Jf.splice(s,1)},promise:($3(r)?r:r(...e)).then(s=>{i.response=s,n.lifespan&&n.lifespan>0&&(i.timeout=setTimeout(i.remove,n.lifespan))}).catch(s=>i.error=s)};if(Jf.push(i),!t)throw i.promise}const eO=(r,e,t)=>Q3(r,e,!1,t),Oy={},hT=r=>void Object.assign(Oy,r);function tO(r,e){function t(u,{args:h=[],attach:p,...m},v){let _=`${u[0].toUpperCase()}${u.slice(1)}`,y;if(u==="primitive"){if(m.object===void 0)throw new Error("R3F: Primitives without 'object' are invalid!");const g=m.object;y=Ll(g,{type:u,root:v,attach:p,primitive:!0})}else{const g=Oy[_];if(!g)throw new Error(`R3F: ${_} is not part of the THREE namespace! Did you forget to extend? See: https://docs.pmnd.rs/react-three-fiber/api/objects#using-3rd-party-objects-declaratively`);if(!Array.isArray(h))throw new Error("R3F: The args prop must be an array!");y=Ll(new g(...h),{type:u,root:v,attach:p,memoizedProps:{args:h}})}return y.__r3f.attach===void 0&&(y instanceof Tt?y.__r3f.attach="geometry":y instanceof oi&&(y.__r3f.attach="material")),_!=="inject"&&Eg(y,m),y}function n(u,h){let p=!1;if(h){var m,v;(m=h.__r3f)!=null&&m.attach?Sg(u,h,h.__r3f.attach):h.isObject3D&&u.isObject3D&&(u.add(h),p=!0),p||(v=u.__r3f)==null||v.objects.push(h),h.__r3f||Ll(h,{}),h.__r3f.parent=u,vv(h),Il(h)}}function i(u,h,p){let m=!1;if(h){var v,_;if((v=h.__r3f)!=null&&v.attach)Sg(u,h,h.__r3f.attach);else if(h.isObject3D&&u.isObject3D){h.parent=u,h.dispatchEvent({type:"added"});const y=u.children.filter(x=>x!==h),g=y.indexOf(p);u.children=[...y.slice(0,g),h,...y.slice(g)],m=!0}m||(_=u.__r3f)==null||_.objects.push(h),h.__r3f||Ll(h,{}),h.__r3f.parent=u,vv(h),Il(h)}}function s(u,h,p=!1){u&&[...u].forEach(m=>o(h,m,p))}function o(u,h,p){if(h){var m,v,_;if(h.__r3f&&(h.__r3f.parent=null),(m=u.__r3f)!=null&&m.objects&&(u.__r3f.objects=u.__r3f.objects.filter(E=>E!==h)),(v=h.__r3f)!=null&&v.attach)Pw(u,h,h.__r3f.attach);else if(h.isObject3D&&u.isObject3D){var y;u.remove(h),(y=h.__r3f)!=null&&y.root&&lO(h.__r3f.root,h)}const x=(_=h.__r3f)==null?void 0:_.primitive,w=p===void 0?h.dispose!==null&&!x:p;if(!x){var g;s((g=h.__r3f)==null?void 0:g.objects,h,w),s(h.children,h,w)}delete h.__r3f,w&&h.dispose&&h.type!=="Scene"&&Mw.unstable_scheduleCallback(Mw.unstable_IdlePriority,()=>{try{h.dispose()}catch{}}),Il(u)}}function a(u,h,p,m){var v;const _=(v=u.__r3f)==null?void 0:v.parent;if(!_)return;const y=t(h,p,u.__r3f.root);if(u.children){for(const g of u.children)g.__r3f&&n(y,g);u.children=u.children.filter(g=>!g.__r3f)}u.__r3f.objects.forEach(g=>n(y,g)),u.__r3f.objects=[],u.__r3f.autoRemovedBeforeAppend||o(_,u),y.parent&&(y.__r3f.autoRemovedBeforeAppend=!0),n(_,y),y.raycast&&y.__r3f.eventCount&&y.__r3f.root.getState().internal.interaction.push(y),[m,m.alternate].forEach(g=>{g!==null&&(g.stateNode=y,g.ref&&(typeof g.ref=="function"?g.ref(y):g.ref.current=y))})}const l=()=>console.warn("Text is not allowed in the R3F tree! This could be stray whitespace or characters.");return{reconciler:q3({createInstance:t,removeChild:o,appendChild:n,appendInitialChild:n,insertBefore:i,supportsMutation:!0,isPrimaryRenderer:!1,supportsPersistence:!1,supportsHydration:!1,noTimeout:-1,appendChildToContainer:(u,h)=>{if(!h)return;const p=u.getState().scene;p.__r3f&&(p.__r3f.root=u,n(p,h))},removeChildFromContainer:(u,h)=>{h&&o(u.getState().scene,h)},insertInContainerBefore:(u,h,p)=>{if(!h||!p)return;const m=u.getState().scene;m.__r3f&&i(m,h,p)},getRootHostContext:()=>null,getChildHostContext:u=>u,finalizeInitialChildren(u){var h;return!!((h=u==null?void 0:u.__r3f)!=null?h:{}).handlers},prepareUpdate(u,h,p,m){var v;if(((v=u==null?void 0:u.__r3f)!=null?v:{}).primitive&&m.object&&m.object!==u)return[!0];{const{args:y=[],children:g,...x}=m,{args:w=[],children:E,...b}=p;if(!Array.isArray(y))throw new Error("R3F: the args prop must be an array!");if(y.some((A,P)=>A!==w[P]))return[!0];const M=yT(u,x,b,!0);return M.changes.length?[!1,M]:null}},commitUpdate(u,[h,p],m,v,_,y){h?a(u,m,_,y):Eg(u,p)},commitMount(u,h,p,m){var v;const _=(v=u.__r3f)!=null?v:{};u.raycast&&_.handlers&&_.eventCount&&u.__r3f.root.getState().internal.interaction.push(u)},getPublicInstance:u=>u,prepareForCommit:()=>null,preparePortalMount:u=>Ll(u.getState().scene),resetAfterCommit:()=>{},shouldSetTextContent:()=>!1,clearContainer:()=>!1,hideInstance(u){var h;const{attach:p,parent:m}=(h=u.__r3f)!=null?h:{};p&&m&&Pw(m,u,p),u.isObject3D&&(u.visible=!1),Il(u)},unhideInstance(u,h){var p;const{attach:m,parent:v}=(p=u.__r3f)!=null?p:{};m&&v&&Sg(v,u,m),(u.isObject3D&&h.visible==null||h.visible)&&(u.visible=!0),Il(u)},createTextInstance:l,hideTextInstance:l,unhideTextInstance:l,getCurrentEventPriority:()=>e?e():Fl.DefaultEventPriority,beforeActiveInstanceBlur:()=>{},afterActiveInstanceBlur:()=>{},detachDeletedInstance:()=>{},now:typeof performance<"u"&&hn.fun(performance.now)?performance.now:hn.fun(Date.now)?Date.now:()=>0,scheduleTimeout:hn.fun(setTimeout)?setTimeout:void 0,cancelTimeout:hn.fun(clearTimeout)?clearTimeout:void 0}),applyProps:Eg}}var Tw,Aw;const wg=r=>"colorSpace"in r||"outputColorSpace"in r,fT=()=>{var r;return(r=Oy.ColorManagement)!=null?r:null},dT=r=>r&&r.isOrthographicCamera,nO=r=>r&&r.hasOwnProperty("current"),hh=typeof window<"u"&&((Tw=window.document)!=null&&Tw.createElement||((Aw=window.navigator)==null?void 0:Aw.product)==="ReactNative")?K.useLayoutEffect:K.useEffect;function pT(r){const e=K.useRef(r);return hh(()=>void(e.current=r),[r]),e}function iO({set:r}){return hh(()=>(r(new Promise(()=>null)),()=>r(!1)),[r]),null}class mT extends K.Component{constructor(...e){super(...e),this.state={error:!1}}componentDidCatch(e){this.props.set(e)}render(){return this.state.error?null:this.props.children}}mT.getDerivedStateFromError=()=>({error:!0});const gT="__default",Cw=new Map,rO=r=>r&&!!r.memoized&&!!r.changes;function vT(r){var e;const t=typeof window<"u"?(e=window.devicePixelRatio)!=null?e:2:1;return Array.isArray(r)?Math.min(Math.max(r[0],t),r[1]):r}const zc=r=>{var e;return(e=r.__r3f)==null?void 0:e.root.getState()},hn={obj:r=>r===Object(r)&&!hn.arr(r)&&typeof r!="function",fun:r=>typeof r=="function",str:r=>typeof r=="string",num:r=>typeof r=="number",boo:r=>typeof r=="boolean",und:r=>r===void 0,arr:r=>Array.isArray(r),equ(r,e,{arrays:t="shallow",objects:n="reference",strict:i=!0}={}){if(typeof r!=typeof e||!!r!=!!e)return!1;if(hn.str(r)||hn.num(r))return r===e;const s=hn.obj(r);if(s&&n==="reference")return r===e;const o=hn.arr(r);if(o&&t==="reference")return r===e;if((o||s)&&r===e)return!0;let a;for(a in r)if(!(a in e))return!1;if(s&&t==="shallow"&&n==="shallow"){for(a in i?e:r)if(!hn.equ(r[a],e[a],{strict:i,objects:"reference"}))return!1}else for(a in i?e:r)if(r[a]!==e[a])return!1;if(hn.und(a)){if(o&&r.length===0&&e.length===0||s&&Object.keys(r).length===0&&Object.keys(e).length===0)return!0;if(r!==e)return!1}return!0}};function sO(r){r.dispose&&r.type!=="Scene"&&r.dispose();for(const e in r)e.dispose==null||e.dispose(),delete r[e]}function Ll(r,e){const t=r;return t.__r3f={type:"",root:null,previousAttach:null,memoizedProps:{},eventCount:0,handlers:{},objects:[],parent:null,...e},r}function gv(r,e){let t=r;if(e.includes("-")){const n=e.split("-"),i=n.pop();return t=n.reduce((s,o)=>s[o],r),{target:t,key:i}}else return{target:t,key:e}}const Rw=/-\d+$/;function Sg(r,e,t){if(hn.str(t)){if(Rw.test(t)){const s=t.replace(Rw,""),{target:o,key:a}=gv(r,s);Array.isArray(o[a])||(o[a]=[])}const{target:n,key:i}=gv(r,t);e.__r3f.previousAttach=n[i],n[i]=e}else e.__r3f.previousAttach=t(r,e)}function Pw(r,e,t){var n,i;if(hn.str(t)){const{target:s,key:o}=gv(r,t),a=e.__r3f.previousAttach;a===void 0?delete s[o]:s[o]=a}else(n=e.__r3f)==null||n.previousAttach==null||n.previousAttach(r,e);(i=e.__r3f)==null||delete i.previousAttach}function yT(r,{children:e,key:t,ref:n,...i},{children:s,key:o,ref:a,...l}={},c=!1){var u;const h=(u=r==null?void 0:r.__r3f)!=null?u:{},p=Object.entries(i),m=[];if(c){const _=Object.keys(l);for(let y=0;y<_.length;y++)i.hasOwnProperty(_[y])||p.unshift([_[y],gT+"remove"])}p.forEach(([_,y])=>{var g;if((g=r.__r3f)!=null&&g.primitive&&_==="object"||hn.equ(y,l[_]))return;if(/^on(Pointer|Click|DoubleClick|ContextMenu|Wheel)/.test(_))return m.push([_,y,!0,[]]);let x=[];_.includes("-")&&(x=_.split("-")),m.push([_,y,!1,x]);for(const w in i){const E=i[w];w.startsWith(`${_}-`)&&m.push([w,E,!1,w.split("-")])}});const v={...i};return h.memoizedProps&&h.memoizedProps.args&&(v.args=h.memoizedProps.args),h.memoizedProps&&h.memoizedProps.attach&&(v.attach=h.memoizedProps.attach),{memoized:v,changes:m}}function Eg(r,e){var t,n,i;const s=(t=r.__r3f)!=null?t:{},o=s.root,a=(n=o==null||o.getState==null?void 0:o.getState())!=null?n:{},{memoized:l,changes:c}=rO(e)?e:yT(r,e),u=s.eventCount;r.__r3f&&(r.__r3f.memoizedProps=l);for(let p=0;pw[E],r),!(x&&x.set))){const[w,...E]=y.reverse();g=E.reverse().reduce((b,M)=>b[M],r),m=w}if(v===gT+"remove")if(g.constructor){let w=Cw.get(g.constructor);w||(w=new g.constructor,Cw.set(g.constructor,w)),v=w[m]}else v=0;if(_)v?s.handlers[m]=v:delete s.handlers[m],s.eventCount=Object.keys(s.handlers).length;else if(x&&x.set&&(x.copy||x instanceof ga)){if(Array.isArray(v))x.fromArray?x.fromArray(v):x.set(...v);else if(x.copy&&v&&v.constructor&&x.constructor===v.constructor)x.copy(v);else if(v!==void 0){const w=x instanceof Ke;!w&&x.setScalar?x.setScalar(v):x instanceof ga&&v instanceof ga?x.mask=v.mask:x.set(v),!fT()&&!a.linear&&w&&x.convertSRGBToLinear()}}else if(g[m]=v,g[m]instanceof Sn&&g[m].format===Bi&&g[m].type===os){const w=g[m];wg(w)&&wg(a.gl)?w.colorSpace=a.gl.outputColorSpace:w.encoding=a.gl.outputEncoding}Il(r)}if(s.parent&&a.internal&&r.raycast&&u!==s.eventCount){const p=a.internal.interaction.indexOf(r);p>-1&&a.internal.interaction.splice(p,1),s.eventCount&&a.internal.interaction.push(r)}return!(c.length===1&&c[0][0]==="onUpdate")&&c.length&&(i=r.__r3f)!=null&&i.parent&&vv(r),r}function Il(r){var e,t;const n=(e=r.__r3f)==null||(t=e.root)==null||t.getState==null?void 0:t.getState();n&&n.internal.frames===0&&n.invalidate()}function vv(r){r.onUpdate==null||r.onUpdate(r)}function oO(r,e){r.manual||(dT(r)?(r.left=e.width/-2,r.right=e.width/2,r.top=e.height/2,r.bottom=e.height/-2):r.aspect=e.width/e.height,r.updateProjectionMatrix(),r.updateMatrixWorld())}function Qf(r){return(r.eventObject||r.object).uuid+"/"+r.index+r.instanceId}function aO(){var r;const e=typeof self<"u"&&self||typeof window<"u"&&window;if(!e)return Fl.DefaultEventPriority;switch((r=e.event)==null?void 0:r.type){case"click":case"contextmenu":case"dblclick":case"pointercancel":case"pointerdown":case"pointerup":return Fl.DiscreteEventPriority;case"pointermove":case"pointerout":case"pointerover":case"pointerenter":case"pointerleave":case"wheel":return Fl.ContinuousEventPriority;default:return Fl.DefaultEventPriority}}function _T(r,e,t,n){const i=t.get(e);i&&(t.delete(e),t.size===0&&(r.delete(n),i.target.releasePointerCapture(n)))}function lO(r,e){const{internal:t}=r.getState();t.interaction=t.interaction.filter(n=>n!==e),t.initialHits=t.initialHits.filter(n=>n!==e),t.hovered.forEach((n,i)=>{(n.eventObject===e||n.object===e)&&t.hovered.delete(i)}),t.capturedMap.forEach((n,i)=>{_T(t.capturedMap,e,n,i)})}function cO(r){function e(l){const{internal:c}=r.getState(),u=l.offsetX-c.initialClick[0],h=l.offsetY-c.initialClick[1];return Math.round(Math.sqrt(u*u+h*h))}function t(l){return l.filter(c=>["Move","Over","Enter","Out","Leave"].some(u=>{var h;return(h=c.__r3f)==null?void 0:h.handlers["onPointer"+u]}))}function n(l,c){const u=r.getState(),h=new Set,p=[],m=c?c(u.internal.interaction):u.internal.interaction;for(let g=0;g{const w=zc(g.object),E=zc(x.object);return!w||!E?g.distance-x.distance:E.events.priority-w.events.priority||g.distance-x.distance}).filter(g=>{const x=Qf(g);return h.has(x)?!1:(h.add(x),!0)});u.events.filter&&(_=u.events.filter(_,u));for(const g of _){let x=g.object;for(;x;){var y;(y=x.__r3f)!=null&&y.eventCount&&p.push({...g,eventObject:x}),x=x.parent}}if("pointerId"in l&&u.internal.capturedMap.has(l.pointerId))for(let g of u.internal.capturedMap.get(l.pointerId).values())h.has(Qf(g.intersection))||p.push(g.intersection);return p}function i(l,c,u,h){const p=r.getState();if(l.length){const m={stopped:!1};for(const v of l){const _=zc(v.object)||p,{raycaster:y,pointer:g,camera:x,internal:w}=_,E=new Y(g.x,g.y,0).unproject(x),b=L=>{var F,N;return(F=(N=w.capturedMap.get(L))==null?void 0:N.has(v.eventObject))!=null?F:!1},M=L=>{const F={intersection:v,target:c.target};w.capturedMap.has(L)?w.capturedMap.get(L).set(v.eventObject,F):w.capturedMap.set(L,new Map([[v.eventObject,F]])),c.target.setPointerCapture(L)},A=L=>{const F=w.capturedMap.get(L);F&&_T(w.capturedMap,v.eventObject,F,L)};let P={};for(let L in c){let F=c[L];typeof F!="function"&&(P[L]=F)}let C={...v,...P,pointer:g,intersections:l,stopped:m.stopped,delta:u,unprojectedPoint:E,ray:y.ray,camera:x,stopPropagation(){const L="pointerId"in c&&w.capturedMap.get(c.pointerId);if((!L||L.has(v.eventObject))&&(C.stopped=m.stopped=!0,w.hovered.size&&Array.from(w.hovered.values()).find(F=>F.eventObject===v.eventObject))){const F=l.slice(0,l.indexOf(v));s([...F,v])}},target:{hasPointerCapture:b,setPointerCapture:M,releasePointerCapture:A},currentTarget:{hasPointerCapture:b,setPointerCapture:M,releasePointerCapture:A},nativeEvent:c};if(h(C),m.stopped===!0)break}}return l}function s(l){const{internal:c}=r.getState();for(const u of c.hovered.values())if(!l.length||!l.find(h=>h.object===u.object&&h.index===u.index&&h.instanceId===u.instanceId)){const p=u.eventObject.__r3f,m=p==null?void 0:p.handlers;if(c.hovered.delete(Qf(u)),p!=null&&p.eventCount){const v={...u,intersections:l};m.onPointerOut==null||m.onPointerOut(v),m.onPointerLeave==null||m.onPointerLeave(v)}}}function o(l,c){for(let u=0;us([]);case"onLostPointerCapture":return c=>{const{internal:u}=r.getState();"pointerId"in c&&u.capturedMap.has(c.pointerId)&&requestAnimationFrame(()=>{u.capturedMap.has(c.pointerId)&&(u.capturedMap.delete(c.pointerId),s([]))})}}return function(u){const{onPointerMissed:h,internal:p}=r.getState();p.lastEvent.current=u;const m=l==="onPointerMove",v=l==="onClick"||l==="onContextMenu"||l==="onDoubleClick",y=n(u,m?t:void 0),g=v?e(u):0;l==="onPointerDown"&&(p.initialClick=[u.offsetX,u.offsetY],p.initialHits=y.map(w=>w.eventObject)),v&&!y.length&&g<=2&&(o(u,p.interaction),h&&h(u)),m&&s(y);function x(w){const E=w.eventObject,b=E.__r3f,M=b==null?void 0:b.handlers;if(b!=null&&b.eventCount)if(m){if(M.onPointerOver||M.onPointerEnter||M.onPointerOut||M.onPointerLeave){const A=Qf(w),P=p.hovered.get(A);P?P.stopped&&w.stopPropagation():(p.hovered.set(A,w),M.onPointerOver==null||M.onPointerOver(w),M.onPointerEnter==null||M.onPointerEnter(w))}M.onPointerMove==null||M.onPointerMove(w)}else{const A=M[l];A?(!v||p.initialHits.includes(E))&&(o(u,p.interaction.filter(P=>!p.initialHits.includes(P))),A(w)):v&&p.initialHits.includes(E)&&o(u,p.interaction.filter(P=>!p.initialHits.includes(P)))}}i(y,u,g,x)}}return{handlePointer:a}}const xT=r=>!!(r!=null&&r.render),wT=K.createContext(null),uO=(r,e)=>{const t=H3((a,l)=>{const c=new Y,u=new Y,h=new Y;function p(g=l().camera,x=u,w=l().size){const{width:E,height:b,top:M,left:A}=w,P=E/b;x instanceof Y?h.copy(x):h.set(...x);const C=g.getWorldPosition(c).distanceTo(h);if(dT(g))return{width:E/g.zoom,height:b/g.zoom,top:M,left:A,factor:1,distance:C,aspect:P};{const L=g.fov*Math.PI/180,F=2*Math.tan(L/2)*C,N=F*(E/b);return{width:N,height:F,top:M,left:A,factor:E/N,distance:C,aspect:P}}}let m;const v=g=>a(x=>({performance:{...x.performance,current:g}})),_=new De;return{set:a,get:l,gl:null,camera:null,raycaster:null,events:{priority:1,enabled:!0,connected:!1},xr:null,scene:null,invalidate:(g=1)=>r(l(),g),advance:(g,x)=>e(g,x,l()),legacy:!1,linear:!1,flat:!1,controls:null,clock:new Py,pointer:_,mouse:_,frameloop:"always",onPointerMissed:void 0,performance:{current:1,min:.5,max:1,debounce:200,regress:()=>{const g=l();m&&clearTimeout(m),g.performance.current!==g.performance.min&&v(g.performance.min),m=setTimeout(()=>v(l().performance.max),g.performance.debounce)}},size:{width:0,height:0,top:0,left:0,updateStyle:!1},viewport:{initialDpr:0,dpr:0,width:0,height:0,top:0,left:0,aspect:0,distance:0,factor:0,getCurrentViewport:p},setEvents:g=>a(x=>({...x,events:{...x.events,...g}})),setSize:(g,x,w,E,b)=>{const M=l().camera,A={width:g,height:x,top:E||0,left:b||0,updateStyle:w};a(P=>({size:A,viewport:{...P.viewport,...p(M,u,A)}}))},setDpr:g=>a(x=>{const w=vT(g);return{viewport:{...x.viewport,dpr:w,initialDpr:x.viewport.initialDpr||w}}}),setFrameloop:(g="always")=>{const x=l().clock;x.stop(),x.elapsedTime=0,g!=="never"&&(x.start(),x.elapsedTime=0),a(()=>({frameloop:g}))},previousRoot:void 0,internal:{active:!1,priority:0,frames:0,lastEvent:K.createRef(),interaction:[],hovered:new Map,subscribers:[],initialClick:[0,0],initialHits:[],capturedMap:new Map,subscribe:(g,x,w)=>{const E=l().internal;return E.priority=E.priority+(x>0?1:0),E.subscribers.push({ref:g,priority:x,store:w}),E.subscribers=E.subscribers.sort((b,M)=>b.priority-M.priority),()=>{const b=l().internal;b!=null&&b.subscribers&&(b.priority=b.priority-(x>0?1:0),b.subscribers=b.subscribers.filter(M=>M.ref!==g))}}}}}),n=t.getState();let i=n.size,s=n.viewport.dpr,o=n.camera;return t.subscribe(()=>{const{camera:a,size:l,viewport:c,gl:u,set:h}=t.getState();if(l!==i||c.dpr!==s){var p;i=l,s=c.dpr,oO(a,l),u.setPixelRatio(c.dpr);const m=(p=l.updateStyle)!=null?p:typeof HTMLCanvasElement<"u"&&u.domElement instanceof HTMLCanvasElement;u.setSize(l.width,l.height,m)}a!==o&&(o=a,h(m=>({viewport:{...m.viewport,...m.viewport.getCurrentViewport(a)}})))}),t.subscribe(a=>r(a)),t};function hO(r,e){const t={callback:r};return e.add(t),()=>void e.delete(t)}let ed,ST=new Set,fO=new Set,dO=new Set;const pO=r=>hO(r,ST);function bg(r,e){if(r.size)for(const{callback:t}of r.values())t(e)}function Bc(r,e){switch(r){case"before":return bg(ST,e);case"after":return bg(fO,e);case"tail":return bg(dO,e)}}let Mg,Tg;function Ag(r,e,t){let n=e.clock.getDelta();for(e.frameloop==="never"&&typeof r=="number"&&(n=r-e.clock.elapsedTime,e.clock.oldTime=e.clock.elapsedTime,e.clock.elapsedTime=r),Mg=e.internal.subscribers,ed=0;ed0)&&!((c=i.gl.xr)!=null&&c.isPresenting)&&(t+=Ag(l,i))}if(Bc("after",l),t===0)return Bc("tail",l),e=!1,cancelAnimationFrame(n)}function o(l,c=1){var u;if(!l)return r.forEach(h=>o(h.store.getState()),c);(u=l.gl.xr)!=null&&u.isPresenting||!l.internal.active||l.frameloop==="never"||(l.internal.frames=Math.min(60,l.internal.frames+c),e||(e=!0,requestAnimationFrame(s)))}function a(l,c=!0,u,h){if(c&&Bc("before",l),u)Ag(l,u,h);else for(const p of r.values())Ag(l,p.store.getState());c&&Bc("after",l)}return{loop:s,invalidate:o,advance:a}}function ET(){const r=K.useContext(wT);if(!r)throw new Error("R3F: Hooks can only be used within the Canvas component!");return r}function Bn(r=t=>t,e){return ET()(r,e)}function Ep(r,e=0){const t=ET(),n=t.getState().internal.subscribe,i=pT(r);return hh(()=>n(i,e,t),[e,n,t]),null}const jl=new Map,{invalidate:Lw,advance:Iw}=mO(jl),{reconciler:Nd,applyProps:oa}=tO(jl,aO),yl={objects:"shallow",strict:!1},gO=(r,e)=>{const t=typeof r=="function"?r(e):r;return xT(t)?t:new uy({powerPreference:"high-performance",canvas:e,antialias:!0,alpha:!0,...r})};function vO(r,e){if(e)return e;if(typeof HTMLCanvasElement<"u"&&r instanceof HTMLCanvasElement&&r.parentElement){const{width:t,height:n,top:i,left:s}=r.parentElement.getBoundingClientRect();return{width:t,height:n,top:i,left:s}}else if(typeof OffscreenCanvas<"u"&&r instanceof OffscreenCanvas)return{width:r.width,height:r.height,top:0,left:0};return{width:0,height:0,top:0,left:0}}function yO(r){const e=jl.get(r),t=e==null?void 0:e.fiber,n=e==null?void 0:e.store;e&&console.warn("R3F.createRoot should only be called once!");const i=typeof reportError=="function"?reportError:console.error,s=n||uO(Lw,Iw),o=t||Nd.createContainer(s,Fl.ConcurrentRoot,null,!1,null,"",i,null);e||jl.set(r,{fiber:o,store:s});let a,l=!1,c;return{configure(u={}){let{gl:h,size:p,scene:m,events:v,onCreated:_,shadows:y=!1,linear:g=!1,flat:x=!1,legacy:w=!1,orthographic:E=!1,frameloop:b="always",dpr:M=[1,2],performance:A,raycaster:P,camera:C,onPointerMissed:L}=u,F=s.getState(),N=F.gl;F.gl||F.set({gl:N=gO(h,r)});let I=F.raycaster;I||F.set({raycaster:I=new Uy});const{params:X,...q}=P||{};if(hn.equ(q,I,yl)||oa(I,{...q}),hn.equ(X,I.params,yl)||oa(I,{params:{...I.params,...X}}),!F.camera||F.camera===c&&!hn.equ(c,C,yl)){c=C;const D=C instanceof rh,V=D?C:E?new Pa(0,0,0,0,.1,1e3):new zn(75,0,.1,1e3);D||(V.position.z=5,C&&oa(V,C),!F.camera&&!(C!=null&&C.rotation)&&V.lookAt(0,0,0)),F.set({camera:V})}if(!F.scene){let D;m instanceof ku?D=m:(D=new ku,m&&oa(D,m)),F.set({scene:Ll(D)})}if(!F.xr){const D=(ee,ie)=>{const ue=s.getState();ue.frameloop!=="never"&&Iw(ee,!0,ue,ie)},V=()=>{const ee=s.getState();ee.gl.xr.enabled=ee.gl.xr.isPresenting,ee.gl.xr.setAnimationLoop(ee.gl.xr.isPresenting?D:null),ee.gl.xr.isPresenting||Lw(ee)},Z={connect(){const ee=s.getState().gl;ee.xr.addEventListener("sessionstart",V),ee.xr.addEventListener("sessionend",V)},disconnect(){const ee=s.getState().gl;ee.xr.removeEventListener("sessionstart",V),ee.xr.removeEventListener("sessionend",V)}};N.xr&&Z.connect(),F.set({xr:Z})}if(N.shadowMap){const D=N.shadowMap.enabled,V=N.shadowMap.type;if(N.shadowMap.enabled=!!y,hn.boo(y))N.shadowMap.type=gu;else if(hn.str(y)){var W;const Z={basic:ub,percentage:qd,soft:gu,variance:Or};N.shadowMap.type=(W=Z[y])!=null?W:gu}else hn.obj(y)&&Object.assign(N.shadowMap,y);(D!==N.shadowMap.enabled||V!==N.shadowMap.type)&&(N.shadowMap.needsUpdate=!0)}const O=fT();O&&("enabled"in O?O.enabled=!w:"legacyMode"in O&&(O.legacyMode=w)),oa(N,{outputEncoding:g?3e3:3001,toneMapping:x?zr:Xv}),F.legacy!==w&&F.set(()=>({legacy:w})),F.linear!==g&&F.set(()=>({linear:g})),F.flat!==x&&F.set(()=>({flat:x})),h&&!hn.fun(h)&&!xT(h)&&!hn.equ(h,N,yl)&&oa(N,h),v&&!F.events.handlers&&F.set({events:v(s)});const B=vO(r,p);return hn.equ(B,F.size,yl)||F.setSize(B.width,B.height,B.updateStyle,B.top,B.left),M&&F.viewport.dpr!==vT(M)&&F.setDpr(M),F.frameloop!==b&&F.setFrameloop(b),F.onPointerMissed||F.set({onPointerMissed:L}),A&&!hn.equ(A,F.performance,yl)&&F.set(D=>({performance:{...D.performance,...A}})),a=_,l=!0,this},render(u){return l||this.configure(),Nd.updateContainer(K.createElement(_O,{store:s,children:u,onCreated:a,rootElement:r}),o,null,()=>{}),s},unmount(){bT(r)}}}function _O({store:r,children:e,onCreated:t,rootElement:n}){return hh(()=>{const i=r.getState();i.set(s=>({internal:{...s.internal,active:!0}})),t&&t(i),r.getState().events.connected||i.events.connect==null||i.events.connect(n)},[]),K.createElement(wT.Provider,{value:r},e)}function bT(r,e){const t=jl.get(r),n=t==null?void 0:t.fiber;if(n){const i=t==null?void 0:t.store.getState();i&&(i.internal.active=!1),Nd.updateContainer(null,n,null,()=>{i&&setTimeout(()=>{try{var s,o,a,l;i.events.disconnect==null||i.events.disconnect(),(s=i.gl)==null||(o=s.renderLists)==null||o.dispose==null||o.dispose(),(a=i.gl)==null||a.forceContextLoss==null||a.forceContextLoss(),(l=i.gl)!=null&&l.xr&&i.xr.disconnect(),sO(i),jl.delete(r)}catch{}},500)})}}Nd.injectIntoDevTools({bundleType:0,rendererPackageName:"@react-three/fiber",version:K.version});function Ta(){return Ta=Object.assign?Object.assign.bind():function(r){for(var e=1;e{window.clearTimeout(t),t=window.setTimeout(()=>r(...n),e)}}function xO({debounce:r,scroll:e,polyfill:t,offsetSize:n}={debounce:0,scroll:!1,offsetSize:!1}){const i=t||(typeof window>"u"?class{}:window.ResizeObserver);if(!i)throw new Error("This browser does not support ResizeObserver out of the box. See: https://github.com/react-spring/react-use-measure/#resize-observer-polyfills");const[s,o]=K.useState({left:0,top:0,width:0,height:0,bottom:0,right:0,x:0,y:0}),a=K.useRef({element:null,scrollContainers:null,resizeObserver:null,lastBounds:s,orientationHandler:null}),l=r?typeof r=="number"?r:r.scroll:null,c=r?typeof r=="number"?r:r.resize:null,u=K.useRef(!1);K.useEffect(()=>(u.current=!0,()=>void(u.current=!1)));const[h,p,m]=K.useMemo(()=>{const g=()=>{if(!a.current.element)return;const{left:x,top:w,width:E,height:b,bottom:M,right:A,x:P,y:C}=a.current.element.getBoundingClientRect(),L={left:x,top:w,width:E,height:b,bottom:M,right:A,x:P,y:C};a.current.element instanceof HTMLElement&&n&&(L.height=a.current.element.offsetHeight,L.width=a.current.element.offsetWidth),Object.freeze(L),u.current&&!bO(a.current.lastBounds,L)&&o(a.current.lastBounds=L)};return[g,c?Dw(g,c):g,l?Dw(g,l):g]},[o,n,l,c]);function v(){a.current.scrollContainers&&(a.current.scrollContainers.forEach(g=>g.removeEventListener("scroll",m,!0)),a.current.scrollContainers=null),a.current.resizeObserver&&(a.current.resizeObserver.disconnect(),a.current.resizeObserver=null),a.current.orientationHandler&&("orientation"in screen&&"removeEventListener"in screen.orientation?screen.orientation.removeEventListener("change",a.current.orientationHandler):"onorientationchange"in window&&window.removeEventListener("orientationchange",a.current.orientationHandler))}function _(){a.current.element&&(a.current.resizeObserver=new i(m),a.current.resizeObserver.observe(a.current.element),e&&a.current.scrollContainers&&a.current.scrollContainers.forEach(g=>g.addEventListener("scroll",m,{capture:!0,passive:!0})),a.current.orientationHandler=()=>{m()},"orientation"in screen&&"addEventListener"in screen.orientation?screen.orientation.addEventListener("change",a.current.orientationHandler):"onorientationchange"in window&&window.addEventListener("orientationchange",a.current.orientationHandler))}const y=g=>{!g||g===a.current.element||(v(),a.current.element=g,a.current.scrollContainers=MT(g),_())};return SO(m,!!e),wO(p),K.useEffect(()=>{v(),_()},[e,m,p]),K.useEffect(()=>v,[]),[y,s,h]}function wO(r){K.useEffect(()=>{const e=r;return window.addEventListener("resize",e),()=>void window.removeEventListener("resize",e)},[r])}function SO(r,e){K.useEffect(()=>{if(e){const t=r;return window.addEventListener("scroll",t,{capture:!0,passive:!0}),()=>void window.removeEventListener("scroll",t,!0)}},[r,e])}function MT(r){const e=[];if(!r||r===document.body)return e;const{overflow:t,overflowX:n,overflowY:i}=window.getComputedStyle(r);return[t,n,i].some(s=>s==="auto"||s==="scroll")&&e.push(r),[...e,...MT(r.parentElement)]}const EO=["x","y","top","bottom","left","right","width","height"],bO=(r,e)=>EO.every(t=>r[t]===e[t]);var MO=Object.defineProperty,TO=Object.defineProperties,AO=Object.getOwnPropertyDescriptors,Uw=Object.getOwnPropertySymbols,CO=Object.prototype.hasOwnProperty,RO=Object.prototype.propertyIsEnumerable,Ow=(r,e,t)=>e in r?MO(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Nw=(r,e)=>{for(var t in e||(e={}))CO.call(e,t)&&Ow(r,t,e[t]);if(Uw)for(var t of Uw(e))RO.call(e,t)&&Ow(r,t,e[t]);return r},PO=(r,e)=>TO(r,AO(e)),Fw,kw;typeof window<"u"&&((Fw=window.document)!=null&&Fw.createElement||((kw=window.navigator)==null?void 0:kw.product)==="ReactNative")?K.useLayoutEffect:K.useEffect;function TT(r,e,t){if(!r)return;if(t(r)===!0)return r;let n=r.child;for(;n;){const i=TT(n,e,t);if(i)return i;n=n.sibling}}function AT(r){try{return Object.defineProperties(r,{_currentRenderer:{get(){return null},set(){}},_currentRenderer2:{get(){return null},set(){}}})}catch{return r}}const zw=console.error;console.error=function(){const r=[...arguments].join("");if(r!=null&&r.startsWith("Warning:")&&r.includes("useContext")){console.error=zw;return}return zw.apply(this,arguments)};const Ny=AT(K.createContext(null));class CT extends K.Component{render(){return K.createElement(Ny.Provider,{value:this._reactInternals},this.props.children)}}function LO(){const r=K.useContext(Ny);if(r===null)throw new Error("its-fine: useFiber must be called within a !");const e=K.useId();return K.useMemo(()=>{for(const n of[r,r==null?void 0:r.alternate]){if(!n)continue;const i=TT(n,!1,s=>{let o=s.memoizedState;for(;o;){if(o.memoizedState===e)return!0;o=o.next}});if(i)return i}},[r,e])}function IO(){const r=LO(),[e]=K.useState(()=>new Map);e.clear();let t=r;for(;t;){if(t.type&&typeof t.type=="object"){const i=t.type._context===void 0&&t.type.Provider===t.type?t.type:t.type._context;i&&i!==Ny&&!e.has(i)&&e.set(i,K.useContext(AT(i)))}t=t.return}return e}function DO(){const r=IO();return K.useMemo(()=>Array.from(r.keys()).reduce((e,t)=>n=>K.createElement(e,null,K.createElement(t.Provider,PO(Nw({},n),{value:r.get(t)}))),e=>K.createElement(CT,Nw({},e))),[r])}const Cg={onClick:["click",!1],onContextMenu:["contextmenu",!1],onDoubleClick:["dblclick",!1],onWheel:["wheel",!0],onPointerDown:["pointerdown",!0],onPointerUp:["pointerup",!0],onPointerLeave:["pointerleave",!0],onPointerMove:["pointermove",!0],onPointerCancel:["pointercancel",!0],onLostPointerCapture:["lostpointercapture",!0]};function UO(r){const{handlePointer:e}=cO(r);return{priority:1,enabled:!0,compute(t,n,i){n.pointer.set(t.offsetX/n.size.width*2-1,-(t.offsetY/n.size.height)*2+1),n.raycaster.setFromCamera(n.pointer,n.camera)},connected:void 0,handlers:Object.keys(Cg).reduce((t,n)=>({...t,[n]:e(n)}),{}),update:()=>{var t;const{events:n,internal:i}=r.getState();(t=i.lastEvent)!=null&&t.current&&n.handlers&&n.handlers.onPointerMove(i.lastEvent.current)},connect:t=>{var n;const{set:i,events:s}=r.getState();s.disconnect==null||s.disconnect(),i(o=>({events:{...o.events,connected:t}})),Object.entries((n=s.handlers)!=null?n:[]).forEach(([o,a])=>{const[l,c]=Cg[o];t.addEventListener(l,a,{passive:c})})},disconnect:()=>{const{set:t,events:n}=r.getState();if(n.connected){var i;Object.entries((i=n.handlers)!=null?i:[]).forEach(([s,o])=>{if(n&&n.connected instanceof HTMLElement){const[a]=Cg[s];n.connected.removeEventListener(a,o)}}),t(s=>({events:{...s.events,connected:void 0}}))}}}}const OO=K.forwardRef(function({children:e,fallback:t,resize:n,style:i,gl:s,events:o=UO,eventSource:a,eventPrefix:l,shadows:c,linear:u,flat:h,legacy:p,orthographic:m,frameloop:v,dpr:_,performance:y,raycaster:g,camera:x,onPointerMissed:w,onCreated:E,...b},M){K.useMemo(()=>hT(uT),[]);const A=DO(),[P,C]=xO({scroll:!0,debounce:{scroll:50,resize:0},...n}),L=K.useRef(null),F=K.useRef(null);K.useImperativeHandle(M,()=>L.current);const N=pT(w),[I,X]=K.useState(!1),[q,W]=K.useState(!1);if(I)throw I;if(q)throw q;const O=K.useRef(null);hh(()=>{const G=L.current;C.width>0&&C.height>0&&G&&(O.current||(O.current=yO(G)),O.current.configure({gl:s,events:o,shadows:c,linear:u,flat:h,legacy:p,orthographic:m,frameloop:v,dpr:_,performance:y,raycaster:g,camera:x,size:C,onPointerMissed:(...B)=>N.current==null?void 0:N.current(...B),onCreated:B=>{B.events.connect==null||B.events.connect(a?nO(a)?a.current:a:F.current),l&&B.setEvents({compute:(D,V)=>{const Z=D[l+"X"],ee=D[l+"Y"];V.pointer.set(Z/V.size.width*2-1,-(ee/V.size.height)*2+1),V.raycaster.setFromCamera(V.pointer,V.camera)}}),E==null||E(B)}}),O.current.render(K.createElement(A,null,K.createElement(mT,{set:W},K.createElement(K.Suspense,{fallback:K.createElement(iO,{set:X})},e)))))}),K.useEffect(()=>{const G=L.current;if(G)return()=>bT(G)},[]);const k=a?"none":"auto";return K.createElement("div",Ta({ref:F,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden",pointerEvents:k,...i}},b),K.createElement("div",{ref:P,style:{width:"100%",height:"100%"}},K.createElement("canvas",{ref:L,style:{display:"block"}},t)))}),NO=K.forwardRef(function(e,t){return K.createElement(CT,null,K.createElement(OO,Ta({},e,{ref:t})))});function FO(r,e,t){var n,i=1;r==null&&(r=0),e==null&&(e=0),t==null&&(t=0);function s(){var o,a=n.length,l,c=0,u=0,h=0;for(o=0;o=(l=(o+a)/2))?o=l:a=l,n=i,!(i=i[h=+u]))return n[h]=s,r;if(c=+r._x.call(null,i.data),e===c)return s.next=i,n?n[h]=s:r._root=s,r;do n=n?n[h]=new Array(2):r._root=new Array(2),(u=e>=(l=(o+a)/2))?o=l:a=l;while((h=+u)==(p=+(c>=l)));return n[p]=i,n[h]=s,r}function zO(r){Array.isArray(r)||(r=Array.from(r));const e=r.length,t=new Float64Array(e);let n=1/0,i=-1/0;for(let s=0,o;si&&(i=o));if(n>i)return this;this.cover(n).cover(i);for(let s=0;sr||r>=t;)switch(o=+(ro||(s=c.x1)=h))&&(c=a[a.length-1],a[a.length-1]=a[a.length-1-u],a[a.length-1-u]=c)}else{var p=Math.abs(r-+this._x.call(null,l.data));p=(c=(o+a)/2))?o=c:a=c,e=t,!(t=t[h=+u]))return this;if(!t.length)break;e[h+1&1]&&(n=e,p=h)}for(;t.data!==r;)if(i=t,!(t=t.next))return this;return(s=t.next)&&delete t.next,i?(s?i.next=s:delete i.next,this):e?(s?e[h]=s:delete e[h],(t=e[0]||e[1])&&t===(e[1]||e[0])&&!t.length&&(n?n[p]=t:this._root=t),this):(this._root=s,this)}function XO(r){for(var e=0,t=r.length;e=(h=(a+c)/2))?a=h:c=h,(y=t>=(p=(l+u)/2))?l=p:u=p,i=s,!(s=s[g=y<<1|_]))return i[g]=o,r;if(m=+r._x.call(null,s.data),v=+r._y.call(null,s.data),e===m&&t===v)return o.next=s,i?i[g]=o:r._root=o,r;do i=i?i[g]=new Array(4):r._root=new Array(4),(_=e>=(h=(a+c)/2))?a=h:c=h,(y=t>=(p=(l+u)/2))?l=p:u=p;while((g=y<<1|_)===(x=(v>=p)<<1|m>=h));return i[x]=s,i[g]=o,r}function QO(r){var e,t,n=r.length,i,s,o=new Array(n),a=new Array(n),l=1/0,c=1/0,u=-1/0,h=-1/0;for(t=0;tu&&(u=i),sh&&(h=s));if(l>u||c>h)return this;for(this.cover(l,c).cover(u,h),t=0;tr||r>=i||n>e||e>=s;)switch(c=(eu||(a=v.y0)>h||(l=v.x1)=g)<<1|r>=y)&&(v=p[p.length-1],p[p.length-1]=p[p.length-1-_],p[p.length-1-_]=v)}else{var x=r-+this._x.call(null,m.data),w=e-+this._y.call(null,m.data),E=x*x+w*w;if(E=(p=(o+l)/2))?o=p:l=p,(_=h>=(m=(a+c)/2))?a=m:c=m,e=t,!(t=t[y=_<<1|v]))return this;if(!t.length)break;(e[y+1&3]||e[y+2&3]||e[y+3&3])&&(n=e,g=y)}for(;t.data!==r;)if(i=t,!(t=t.next))return this;return(s=t.next)&&delete t.next,i?(s?i.next=s:delete i.next,this):e?(s?e[y]=s:delete e[y],(t=e[0]||e[1]||e[2]||e[3])&&t===(e[3]||e[2]||e[1]||e[0])&&!t.length&&(n?n[g]=t:this._root=t),this):(this._root=s,this)}function sN(r){for(var e=0,t=r.length;e=(v=(l+h)/2))?l=v:h=v,(b=t>=(_=(c+p)/2))?c=_:p=_,(M=n>=(y=(u+m)/2))?u=y:m=y,s=o,!(o=o[A=M<<2|b<<1|E]))return s[A]=a,r;if(g=+r._x.call(null,o.data),x=+r._y.call(null,o.data),w=+r._z.call(null,o.data),e===g&&t===x&&n===w)return a.next=o,s?s[A]=a:r._root=a,r;do s=s?s[A]=new Array(8):r._root=new Array(8),(E=e>=(v=(l+h)/2))?l=v:h=v,(b=t>=(_=(c+p)/2))?c=_:p=_,(M=n>=(y=(u+m)/2))?u=y:m=y;while((A=M<<2|b<<1|E)===(P=(w>=y)<<2|(x>=_)<<1|g>=v));return s[P]=o,s[A]=a,r}function mN(r){Array.isArray(r)||(r=Array.from(r));const e=r.length,t=new Float64Array(e),n=new Float64Array(e),i=new Float64Array(e);let s=1/0,o=1/0,a=1/0,l=-1/0,c=-1/0,u=-1/0;for(let h=0,p,m,v,_;hl&&(l=m),vc&&(c=v),_u&&(u=_));if(s>l||o>c||a>u)return this;this.cover(s,o,a).cover(l,c,u);for(let h=0;hr||r>=o||i>e||e>=a||s>t||t>=l;)switch(p=(tv||(c=w.y0)>_||(u=w.z0)>y||(h=w.x1)=A)<<2|(e>=M)<<1|r>=b)&&(w=g[g.length-1],g[g.length-1]=g[g.length-1-E],g[g.length-1-E]=w)}else{var P=r-+this._x.call(null,x.data),C=e-+this._y.call(null,x.data),L=t-+this._z.call(null,x.data),F=P*P+C*C+L*L;if(FMath.sqrt((r-n)**2+(e-i)**2+(t-s)**2);function wN(r,e,t,n){const i=[],s=r-n,o=e-n,a=t-n,l=r+n,c=e+n,u=t+n;return this.visit((h,p,m,v,_,y,g)=>{if(!h.length)do{const x=h.data;xN(r,e,t,this._x(x),this._y(x),this._z(x))<=n&&i.push(x)}while(h=h.next);return p>l||m>c||v>u||_=(_=(o+c)/2))?o=_:c=_,(w=m>=(y=(a+u)/2))?a=y:u=y,(E=v>=(g=(l+h)/2))?l=g:h=g,e=t,!(t=t[b=E<<2|w<<1|x]))return this;if(!t.length)break;(e[b+1&7]||e[b+2&7]||e[b+3&7]||e[b+4&7]||e[b+5&7]||e[b+6&7]||e[b+7&7])&&(n=e,M=b)}for(;t.data!==r;)if(i=t,!(t=t.next))return this;return(s=t.next)&&delete t.next,i?(s?i.next=s:delete i.next,this):e?(s?e[b]=s:delete e[b],(t=e[0]||e[1]||e[2]||e[3]||e[4]||e[5]||e[6]||e[7])&&t===(e[7]||e[6]||e[5]||e[4]||e[3]||e[2]||e[1]||e[0])&&!t.length&&(n?n[M]=t:this._root=t),this):(this._root=s,this)}function EN(r){for(var e=0,t=r.length;e1&&(_=m.y+m.vy),t>2&&(y=m.z+m.vz),p.visit(E);function E(b,M,A,P,C,L,F){var N=[M,A,P,C,L,F],I=N[0],X=N[1],q=N[2],W=N[t],O=N[t+1],k=N[t+2],G=b.data,B=b.r,D=g+B;if(G){if(G.index>m.index){var V=v-G.x-G.vx,Z=t>1?_-G.y-G.vy:0,ee=t>2?y-G.z-G.vz:0,ie=V*V+Z*Z+ee*ee;ie1&&Z===0&&(Z=xr(i),ie+=Z*Z),t>2&&ee===0&&(ee=xr(i),ie+=ee*ee),ie=(D-(ie=Math.sqrt(ie)))/ie*s,m.vx+=(V*=ie)*(D=(B*=B)/(x+B)),t>1&&(m.vy+=(Z*=ie)*D),t>2&&(m.vz+=(ee*=ie)*D),G.vx-=V*(D=1-D),t>1&&(G.vy-=Z*D),t>2&&(G.vz-=ee*D))}return}return I>v+D||W1&&(X>_+D||O<_-D)||t>2&&(q>y+D||ku.r&&(u.r=u[h].r)}function c(){if(e){var u,h=e.length,p;for(n=new Array(h),u=0;utypeof p=="function")||Math.random,t=h.find(p=>[1,2,3].includes(p))||2,c()},a.iterations=function(u){return arguments.length?(o=+u,a):o},a.strength=function(u){return arguments.length?(s=+u,a):s},a.radius=function(u){return arguments.length?(r=typeof u=="function"?u:xn(+u),c(),a):r},a}function ON(r){return r.index}function Ww(r,e){var t=r.get(e);if(!t)throw new Error("node not found: "+e);return t}function DT(r){var e=ON,t=p,n,i=xn(30),s,o,a,l,c,u,h=1;r==null&&(r=[]);function p(g){return 1/Math.min(l[g.source.index],l[g.target.index])}function m(g){for(var x=0,w=r.length;x1&&(C=A.y+A.vy-M.y-M.vy||xr(u)),a>2&&(L=A.z+A.vz-M.z-M.vz||xr(u)),F=Math.sqrt(P*P+C*C+L*L),F=(F-s[E])/F*g*n[E],P*=F,C*=F,L*=F,A.vx-=P*(N=c[E]),a>1&&(A.vy-=C*N),a>2&&(A.vz-=L*N),M.vx+=P*(N=1-N),a>1&&(M.vy+=C*N),a>2&&(M.vz+=L*N)}function v(){if(o){var g,x=o.length,w=r.length,E=new Map(o.map((M,A)=>[e(M,A,o),M])),b;for(g=0,l=new Array(x);gtypeof w=="function")||Math.random,a=x.find(w=>[1,2,3].includes(w))||2,v()},m.links=function(g){return arguments.length?(r=g,v(),m):r},m.id=function(g){return arguments.length?(e=g,m):e},m.iterations=function(g){return arguments.length?(h=+g,m):h},m.strength=function(g){return arguments.length?(t=typeof g=="function"?g:xn(+g),_(),m):t},m.distance=function(g){return arguments.length?(i=typeof g=="function"?g:xn(+g),y(),m):i},m}var NN={value:()=>{}};function UT(){for(var r=0,e=arguments.length,t={},n;r=0&&(n=t.slice(i+1),t=t.slice(0,i)),t&&!e.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:n}})}Md.prototype=UT.prototype={constructor:Md,on:function(r,e){var t=this._,n=FN(r+"",t),i,s=-1,o=n.length;if(arguments.length<2){for(;++s0)for(var t=new Array(i),n=0,i,s;n=0&&r._call.call(void 0,e),r=r._next;--Yl}function jw(){Aa=(kd=Yu.now())+bp,Yl=du=0;try{BN()}finally{Yl=0,HN(),Aa=0}}function GN(){var r=Yu.now(),e=r-kd;e>OT&&(bp-=e,kd=r)}function HN(){for(var r,e=Fd,t,n=1/0;e;)e._call?(n>e._time&&(n=e._time),r=e,e=e._next):(t=e._next,e._next=null,e=r?r._next=t:Fd=t);pu=r,_v(n)}function _v(r){if(!Yl){du&&(du=clearTimeout(du));var e=r-Aa;e>24?(r<1/0&&(du=setTimeout(jw,r-Yu.now()-bp)),Gc&&(Gc=clearInterval(Gc))):(Gc||(kd=Yu.now(),Gc=setInterval(GN,OT)),Yl=1,NT(jw))}}const VN=1664525,WN=1013904223,Yw=4294967296;function XN(){let r=1;return()=>(r=(VN*r+WN)%Yw)/Yw}var qw=3;function Pg(r){return r.x}function Zw(r){return r.y}function jN(r){return r.z}var YN=10,qN=Math.PI*(3-Math.sqrt(5)),ZN=Math.PI*20/(9+Math.sqrt(221));function zT(r,e){e=e||2;var t=Math.min(qw,Math.max(1,Math.round(e))),n,i=1,s=.001,o=1-Math.pow(s,1/300),a=0,l=.6,c=new Map,u=kT(m),h=UT("tick","end"),p=XN();r==null&&(r=[]);function m(){v(),h.call("tick",n),i1&&(E.fy==null?E.y+=E.vy*=l:(E.y=E.fy,E.vy=0)),t>2&&(E.fz==null?E.z+=E.vz*=l:(E.z=E.fz,E.vz=0));return n}function _(){for(var g=0,x=r.length,w;g1&&isNaN(w.y)||t>2&&isNaN(w.z)){var E=YN*(t>2?Math.cbrt(.5+g):t>1?Math.sqrt(.5+g):g),b=g*qN,M=g*ZN;t===1?w.x=E:t===2?(w.x=E*Math.cos(b),w.y=E*Math.sin(b)):(w.x=E*Math.sin(b)*Math.cos(M),w.y=E*Math.cos(b),w.z=E*Math.sin(b)*Math.sin(M))}(isNaN(w.vx)||t>1&&isNaN(w.vy)||t>2&&isNaN(w.vz))&&(w.vx=0,t>1&&(w.vy=0),t>2&&(w.vz=0))}}function y(g){return g.initialize&&g.initialize(r,p,t),g}return _(),n={tick:v,restart:function(){return u.restart(m),n},stop:function(){return u.stop(),n},numDimensions:function(g){return arguments.length?(t=Math.min(qw,Math.max(1,Math.round(g))),c.forEach(y),n):t},nodes:function(g){return arguments.length?(r=g,_(),c.forEach(y),n):r},alpha:function(g){return arguments.length?(i=+g,n):i},alphaMin:function(g){return arguments.length?(s=+g,n):s},alphaDecay:function(g){return arguments.length?(o=+g,n):+o},alphaTarget:function(g){return arguments.length?(a=+g,n):a},velocityDecay:function(g){return arguments.length?(l=1-g,n):1-l},randomSource:function(g){return arguments.length?(p=g,c.forEach(y),n):p},force:function(g,x){return arguments.length>1?(x==null?c.delete(g):c.set(g,y(x)),n):c.get(g)},find:function(){var g=Array.prototype.slice.call(arguments),x=g.shift()||0,w=(t>1?g.shift():null)||0,E=(t>2?g.shift():null)||0,b=g.shift()||1/0,M=0,A=r.length,P,C,L,F,N,I;for(b*=b,M=0;M1?(h.on(g,x),n):h.on(g)}}}function BT(){var r,e,t,n,i,s=xn(-30),o,a=1,l=1/0,c=.81;function u(v){var _,y=r.length,g=(e===1?Fy(r,Pg):e===2?zy(r,Pg,Zw):e===3?Gy(r,Pg,Zw,jN):null).visitAfter(p);for(i=v,_=0;_1&&(v.y=E/x),e>2&&(v.z=b/x)}else{y=v,y.x=y.data.x,e>1&&(y.y=y.data.y),e>2&&(y.z=y.data.z);do _+=o[y.data.index];while(y=y.next)}v.value=_}function m(v,_,y,g,x){if(!v.value)return!0;var w=[y,g,x][e-1],E=v.x-t.x,b=e>1?v.y-t.y:0,M=e>2?v.z-t.z:0,A=w-_,P=E*E+b*b+M*M;if(A*A/c1&&b===0&&(b=xr(n),P+=b*b),e>2&&M===0&&(M=xr(n),P+=M*M),P1&&(t.vy+=b*v.value*i/P),e>2&&(t.vz+=M*v.value*i/P)),!0;if(v.length||P>=l)return;(v.data!==t||v.next)&&(E===0&&(E=xr(n),P+=E*E),e>1&&b===0&&(b=xr(n),P+=b*b),e>2&&M===0&&(M=xr(n),P+=M*M),P1&&(t.vy+=b*A),e>2&&(t.vz+=M*A));while(v=v.next)}return u.initialize=function(v,..._){r=v,n=_.find(y=>typeof y=="function")||Math.random,e=_.find(y=>[1,2,3].includes(y))||2,h()},u.strength=function(v){return arguments.length?(s=typeof v=="function"?v:xn(+v),h(),u):s},u.distanceMin=function(v){return arguments.length?(a=v*v,u):Math.sqrt(a)},u.distanceMax=function(v){return arguments.length?(l=v*v,u):Math.sqrt(l)},u.theta=function(v){return arguments.length?(c=v*v,u):Math.sqrt(c)},u}function KN(r,e,t,n){var i,s,o=xn(.1),a,l;typeof r!="function"&&(r=xn(+r)),e==null&&(e=0),t==null&&(t=0),n==null&&(n=0);function c(h){for(var p=0,m=i.length;p1&&(v.vy+=y*w),s>2&&(v.vz+=g*w)}}function u(){if(i){var h,p=i.length;for(a=new Array(p),l=new Array(p),h=0;h[1,2,3].includes(m))||2,u()},c.strength=function(h){return arguments.length?(o=typeof h=="function"?h:xn(+h),u(),c):o},c.radius=function(h){return arguments.length?(r=typeof h=="function"?h:xn(+h),u(),c):r},c.x=function(h){return arguments.length?(e=+h,c):e},c.y=function(h){return arguments.length?(t=+h,c):t},c.z=function(h){return arguments.length?(n=+h,c):n},c}function xv(r){var e=xn(.1),t,n,i;typeof r!="function"&&(r=xn(r==null?0:+r));function s(a){for(var l=0,c=t.length,u;l=0;)e+=t[n].value;r.value=e}function QN(){return this.eachAfter(JN)}function eF(r,e){let t=-1;for(const n of this)r.call(e,n,++t,this);return this}function tF(r,e){for(var t=this,n=[t],i,s,o=-1;t=n.pop();)if(r.call(e,t,++o,this),i=t.children)for(s=i.length-1;s>=0;--s)n.push(i[s]);return this}function nF(r,e){for(var t=this,n=[t],i=[],s,o,a,l=-1;t=n.pop();)if(i.push(t),s=t.children)for(o=0,a=s.length;o=0;)t+=n[i].value;e.value=t})}function sF(r){return this.eachBefore(function(e){e.children&&e.children.sort(r)})}function oF(r){for(var e=this,t=aF(e,r),n=[e];e!==t;)e=e.parent,n.push(e);for(var i=n.length;r!==t;)n.splice(i,0,r),r=r.parent;return n}function aF(r,e){if(r===e)return r;var t=r.ancestors(),n=e.ancestors(),i=null;for(r=t.pop(),e=n.pop();r===e;)i=r,r=t.pop(),e=n.pop();return i}function lF(){for(var r=this,e=[r];r=r.parent;)e.push(r);return e}function cF(){return Array.from(this)}function uF(){var r=[];return this.eachBefore(function(e){e.children||r.push(e)}),r}function hF(){var r=this,e=[];return r.each(function(t){t!==r&&e.push({source:t.parent,target:t})}),e}function*fF(){var r=this,e,t=[r],n,i,s;do for(e=t.reverse(),t=[];r=e.pop();)if(yield r,n=r.children)for(i=0,s=n.length;i=0;--a)i.push(s=o[a]=new ql(o[a])),s.parent=n,s.depth=n.depth+1;return t.eachBefore(GT)}function dF(){return Mp(this).eachBefore(gF)}function pF(r){return r.children}function mF(r){return Array.isArray(r)?r[1]:null}function gF(r){r.data.value!==void 0&&(r.value=r.data.value),r.data=r.data.data}function GT(r){var e=0;do r.height=e;while((r=r.parent)&&r.height<++e)}function ql(r){this.data=r,this.depth=this.height=0,this.parent=null}ql.prototype=Mp.prototype={constructor:ql,count:QN,each:eF,eachAfter:nF,eachBefore:tF,find:iF,sum:rF,sort:sF,path:oF,ancestors:lF,descendants:cF,leaves:uF,links:hF,copy:dF,[Symbol.iterator]:fF};function Lg(r){return r==null?null:HT(r)}function HT(r){if(typeof r!="function")throw new Error;return r}function Hc(){return 0}function Vc(r){return function(){return r}}function vF(r){r.x0=Math.round(r.x0),r.y0=Math.round(r.y0),r.x1=Math.round(r.x1),r.y1=Math.round(r.y1)}function yF(r,e,t,n,i){for(var s=r.children,o,a=-1,l=s.length,c=r.value&&(n-e)/r.value;++aEF(t(E,b,i))),x=g.map($w),w=new Set(g).add("");for(const E of x)w.has(E)||(w.add(E),g.push(E),x.push($w(E)),s.push(Ig));o=(E,b)=>g[b],a=(E,b)=>x[b]}for(u=0,l=s.length;u=0&&(m=s[g],m.data===Ig);--g)m.data=null}if(h.parent=_F,h.eachBefore(function(g){g.depth=g.parent.depth+1,--l}).eachBefore(GT),h.parent=null,l>0)throw new Error("cycle");return h}return n.id=function(i){return arguments.length?(r=Lg(i),n):r},n.parentId=function(i){return arguments.length?(e=Lg(i),n):e},n.path=function(i){return arguments.length?(t=Lg(i),n):t},n}function EF(r){r=`${r}`;let e=r.length;return Sv(r,e-1)&&!Sv(r,e-2)&&(r=r.slice(0,-1)),r[0]==="/"?r:`/${r}`}function $w(r){let e=r.length;if(e<2)return"";for(;--e>1&&!Sv(r,e););return r.slice(0,e)}function Sv(r,e){if(r[e]==="/"){let t=0;for(;e>0&&r[--e]==="\\";)++t;if((t&1)===0)return!0}return!1}function bF(r,e){return r.parent===e.parent?1:2}function Dg(r){var e=r.children;return e?e[0]:r.t}function Ug(r){var e=r.children;return e?e[e.length-1]:r.t}function MF(r,e,t){var n=t/(e.i-r.i);e.c-=n,e.s+=t,r.c+=n,e.z+=t,e.m+=t}function TF(r){for(var e=0,t=0,n=r.children,i=n.length,s;--i>=0;)s=n[i],s.z+=e,s.m+=e,e+=s.s+(t+=s.c)}function AF(r,e,t){return r.a.parent===e.parent?r.a:t}function Td(r,e){this._=r,this.parent=null,this.children=null,this.A=null,this.a=this,this.z=0,this.m=0,this.c=0,this.s=0,this.t=null,this.i=e}Td.prototype=Object.create(ql.prototype);function CF(r){for(var e=new Td(r,0),t,n=[e],i,s,o,a;t=n.pop();)if(s=t._.children)for(t.children=new Array(a=s.length),o=a-1;o>=0;--o)n.push(i=t.children[o]=new Td(s[o],o)),i.parent=t;return(e.parent=new Td(null,0)).children=[e],e}function RF(){var r=bF,e=1,t=1,n=null;function i(c){var u=CF(c);if(u.eachAfter(s),u.parent.m=-u.z,u.eachBefore(o),n)c.eachBefore(l);else{var h=c,p=c,m=c;c.eachBefore(function(x){x.xp.x&&(p=x),x.depth>m.depth&&(m=x)});var v=h===p?1:r(h,p)/2,_=v-h.x,y=e/(p.x+v+_),g=t/(m.depth||1);c.eachBefore(function(x){x.x=(x.x+_)*y,x.y=x.depth*g})}return c}function s(c){var u=c.children,h=c.parent.children,p=c.i?h[c.i-1]:null;if(u){TF(c);var m=(u[0].z+u[u.length-1].z)/2;p?(c.z=p.z+r(c._,p._),c.m=c.z-m):c.z=m}else p&&(c.z=p.z+r(c._,p._));c.parent.A=a(c,p,c.parent.A||h[0])}function o(c){c._.x=c.z+c.parent.m,c.m+=c.parent.m}function a(c,u,h){if(u){for(var p=c,m=c,v=u,_=p.parent.children[0],y=p.m,g=m.m,x=v.m,w=_.m,E;v=Ug(v),p=Dg(p),v&&p;)_=Dg(_),m=Ug(m),m.a=c,E=v.z+x-p.z-y+r(v._,p._),E>0&&(MF(AF(v,c,h),c,E),y+=E,g+=E),x+=v.m,y+=p.m,w+=_.m,g+=m.m;v&&!Ug(m)&&(m.t=v,m.m+=x-g),p&&!Dg(_)&&(_.t=p,_.m+=y-w,h=c)}return h}function l(c){c.x*=e,c.y=c.depth*t}return i.separation=function(c){return arguments.length?(r=c,i):r},i.size=function(c){return arguments.length?(n=!1,e=+c[0],t=+c[1],i):n?null:[e,t]},i.nodeSize=function(c){return arguments.length?(n=!0,e=+c[0],t=+c[1],i):n?[e,t]:null},i}function PF(r,e,t,n,i){for(var s=r.children,o,a=-1,l=s.length,c=r.value&&(i-t)/r.value;++ax&&(x=c),M=y*y*b,w=Math.max(x/M,M/g),w>E){y-=c;break}E=w}o.push(l={value:y,dice:m1?n:1)},t})(LF);function UF(){var r=DF,e=!1,t=1,n=1,i=[0],s=Hc,o=Hc,a=Hc,l=Hc,c=Hc;function u(p){return p.x0=p.y0=0,p.x1=t,p.y1=n,p.eachBefore(h),i=[0],e&&p.eachBefore(vF),p}function h(p){var m=i[p.depth],v=p.x0+m,_=p.y0+m,y=p.x1-m,g=p.y1-m;y1&&ae.has(Le))&&(k>1&&ae.add(Le),se=l[oe+r],Ie=l[oe+e],Se=l[oe+t],ge=se-te,He=Ie-$,j=Math.sqrt(ge*ge+He*He),H=j0?(A[oe]+=ge/j*(1+de),P[oe]+=He/j*(1+de)):(A[oe]+=I*s(),P[oe]+=X*s())));for(v=0,_=0;v"u"?i:c};typeof i=="function"&&(o=i);var a=function(c){return o(c[n])},l=function(){return o(void 0)};return typeof n=="string"?(s.fromAttributes=a,s.fromGraph=function(c,u){return a(c.getNodeAttributes(u))},s.fromEntry=function(c,u){return a(u)}):typeof n=="function"?(s.fromAttributes=function(){throw new Error("graphology-utils/getters/createNodeValueGetter: irrelevant usage.")},s.fromGraph=function(c,u){return o(n(u,c.getNodeAttributes(u)))},s.fromEntry=function(c,u){return o(n(c,u))}):(s.fromAttributes=l,s.fromGraph=l,s.fromEntry=l),s}function t(n,i){var s={},o=function(c){return typeof c>"u"?i:c};typeof i=="function"&&(o=i);var a=function(c){return o(c[n])},l=function(){return o(void 0)};return typeof n=="string"?(s.fromAttributes=a,s.fromGraph=function(c,u){return a(c.getEdgeAttributes(u))},s.fromEntry=function(c,u){return a(u)},s.fromPartialEntry=s.fromEntry,s.fromMinimalEntry=s.fromEntry):typeof n=="function"?(s.fromAttributes=function(){throw new Error("graphology-utils/getters/createEdgeValueGetter: irrelevant usage.")},s.fromGraph=function(c,u){var h=c.extremities(u);return o(n(u,c.getEdgeAttributes(u),h[0],h[1],c.getNodeAttributes(h[0]),c.getNodeAttributes(h[1]),c.isUndirected(u)))},s.fromEntry=function(c,u,h,p,m,v,_){return o(n(c,u,h,p,m,v,_))},s.fromPartialEntry=function(c,u,h,p){return o(n(c,u,h,p))},s.fromMinimalEntry=function(c,u){return o(n(c,u))}):(s.fromAttributes=l,s.fromGraph=l,s.fromEntry=l,s.fromMinimalEntry=l),s}return Wc.createNodeValueGetter=e,Wc.createEdgeValueGetter=t,Wc.createEdgeWeightGetter=function(n){return t(n,r)},Wc}var Gg,oS;function WF(){if(oS)return Gg;oS=1;var r=0,e=1,t=2,n=3,i=4,s=5,o=6,a=7,l=8,c=9,u=0,h=1,p=2,m=0,v=1,_=2,y=3,g=4,x=5,w=6,E=7,b=8,M=3,A=10,P=3,C=9,L=10;return Gg=function(N,I,X){var q,W,O,k,G,B,D,V,Z,ee,ie=I.length,ue=X.length,ce=N.adjustSizes,le=N.barnesHutTheta*N.barnesHutTheta,Ae,Ee,ae,z,oe,te,se,$=[];for(O=0;One?(Se-=(H-ne)/2,Le=Se+H):(Ie-=(ne-H)/2,de=Ie+ne),$[0+m]=-1,$[0+v]=(Ie+de)/2,$[0+_]=(Se+Le)/2,$[0+y]=Math.max(de-Ie,Le-Se),$[0+g]=-1,$[0+x]=-1,$[0+w]=0,$[0+E]=0,$[0+b]=0,q=1,O=0;O=0){I[O+r]<$[W+v]?I[O+e]<$[W+_]?ge=$[W+x]:ge=$[W+x]+C:I[O+e]<$[W+_]?ge=$[W+x]+C*2:ge=$[W+x]+C*3,$[W+E]=($[W+E]*$[W+w]+I[O+r]*I[O+o])/($[W+w]+I[O+o]),$[W+b]=($[W+b]*$[W+w]+I[O+e]*I[O+o])/($[W+w]+I[O+o]),$[W+w]+=I[O+o],W=ge;continue}else if($[W+m]<0){$[W+m]=O;break}else{if($[W+x]=q*C,V=$[W+y]/2,Z=$[W+x],$[Z+m]=-1,$[Z+v]=$[W+v]-V,$[Z+_]=$[W+_]-V,$[Z+y]=V,$[Z+g]=Z+C,$[Z+x]=-1,$[Z+w]=0,$[Z+E]=0,$[Z+b]=0,Z+=C,$[Z+m]=-1,$[Z+v]=$[W+v]-V,$[Z+_]=$[W+_]+V,$[Z+y]=V,$[Z+g]=Z+C,$[Z+x]=-1,$[Z+w]=0,$[Z+E]=0,$[Z+b]=0,Z+=C,$[Z+m]=-1,$[Z+v]=$[W+v]+V,$[Z+_]=$[W+_]-V,$[Z+y]=V,$[Z+g]=Z+C,$[Z+x]=-1,$[Z+w]=0,$[Z+E]=0,$[Z+b]=0,Z+=C,$[Z+m]=-1,$[Z+v]=$[W+v]+V,$[Z+_]=$[W+_]+V,$[Z+y]=V,$[Z+g]=$[W+g],$[Z+x]=-1,$[Z+w]=0,$[Z+E]=0,$[Z+b]=0,q+=4,I[$[W+m]+r]<$[W+v]?I[$[W+m]+e]<$[W+_]?ge=$[W+x]:ge=$[W+x]+C:I[$[W+m]+e]<$[W+_]?ge=$[W+x]+C*2:ge=$[W+x]+C*3,$[W+w]=I[$[W+m]+o],$[W+E]=I[$[W+m]+r],$[W+b]=I[$[W+m]+e],$[ge+m]=$[W+m],$[W+m]=-1,I[O+r]<$[W+v]?I[O+e]<$[W+_]?He=$[W+x]:He=$[W+x]+C:I[O+e]<$[W+_]?He=$[W+x]+C*2:He=$[W+x]+C*3,ge===He)if(j--){W=ge;continue}else{j=M;break}$[He+m]=O;break}}if(N.barnesHutOptimize)for(Ee=N.scalingRatio,O=0;O=0)if(te=Math.pow(I[O+r]-$[W+E],2)+Math.pow(I[O+e]-$[W+b],2),ee=$[W+y],4*ee*ee/te0?(se=Ee*I[O+o]*$[W+w]/te,I[O+t]+=ae*se,I[O+n]+=z*se):te<0&&(se=-Ee*I[O+o]*$[W+w]/Math.sqrt(te),I[O+t]+=ae*se,I[O+n]+=z*se):te>0&&(se=Ee*I[O+o]*$[W+w]/te,I[O+t]+=ae*se,I[O+n]+=z*se),W=$[W+g],W<0)break;continue}else{W=$[W+x];continue}else{if(B=$[W+m],B>=0&&B!==O&&(ae=I[O+r]-I[B+r],z=I[O+e]-I[B+e],te=ae*ae+z*z,ce===!0?te>0?(se=Ee*I[O+o]*I[B+o]/te,I[O+t]+=ae*se,I[O+n]+=z*se):te<0&&(se=-Ee*I[O+o]*I[B+o]/Math.sqrt(te),I[O+t]+=ae*se,I[O+n]+=z*se):te>0&&(se=Ee*I[O+o]*I[B+o]/te,I[O+t]+=ae*se,I[O+n]+=z*se)),W=$[W+g],W<0)break;continue}else for(Ee=N.scalingRatio,k=0;k0?(se=Ee*I[k+o]*I[G+o]/te/te,I[k+t]+=ae*se,I[k+n]+=z*se,I[G+t]-=ae*se,I[G+n]-=z*se):te<0&&(se=100*Ee*I[k+o]*I[G+o],I[k+t]+=ae*se,I[k+n]+=z*se,I[G+t]-=ae*se,I[G+n]-=z*se)):(te=Math.sqrt(ae*ae+z*z),te>0&&(se=Ee*I[k+o]*I[G+o]/te/te,I[k+t]+=ae*se,I[k+n]+=z*se,I[G+t]-=ae*se,I[G+n]-=z*se));for(Z=N.gravity/N.scalingRatio,Ee=N.scalingRatio,O=0;O0&&(se=Ee*I[O+o]*Z):te>0&&(se=Ee*I[O+o]*Z/te),I[O+t]-=ae*se,I[O+n]-=z*se;for(Ee=1*(N.outboundAttractionDistribution?Ae:1),D=0;D0&&(se=-Ee*oe*Math.log(1+te)/te/I[k+o]):te>0&&(se=-Ee*oe*Math.log(1+te)/te):N.outboundAttractionDistribution?te>0&&(se=-Ee*oe/I[k+o]):te>0&&(se=-Ee*oe)):(te=Math.sqrt(Math.pow(ae,2)+Math.pow(z,2)),N.linLogMode?N.outboundAttractionDistribution?te>0&&(se=-Ee*oe*Math.log(1+te)/te/I[k+o]):te>0&&(se=-Ee*oe*Math.log(1+te)/te):N.outboundAttractionDistribution?(te=1,se=-Ee*oe/I[k+o]):(te=1,se=-Ee*oe)),te>0&&(I[k+t]+=ae*se,I[k+n]+=z*se,I[G+t]-=ae*se,I[G+n]-=z*se);var we,be,Me,Fe,Ue,xe;if(ce===!0)for(O=0;OL&&(I[O+t]=I[O+t]*L/we,I[O+n]=I[O+n]*L/we),be=I[O+o]*Math.sqrt((I[O+i]-I[O+t])*(I[O+i]-I[O+t])+(I[O+s]-I[O+n])*(I[O+s]-I[O+n])),Me=Math.sqrt((I[O+i]+I[O+t])*(I[O+i]+I[O+t])+(I[O+s]+I[O+n])*(I[O+s]+I[O+n]))/2,Fe=.1*Math.log(1+Me)/(1+Math.sqrt(be)),Ue=I[O+r]+I[O+t]*(Fe/N.slowDown),I[O+r]=Ue,xe=I[O+e]+I[O+n]*(Fe/N.slowDown),I[O+e]=xe);else for(O=0;O=0)?{message:"the `scalingRatio` setting should be a number >= 0."}:"strongGravityMode"in t&&typeof t.strongGravityMode!="boolean"?{message:"the `strongGravityMode` setting should be a boolean."}:"gravity"in t&&!(typeof t.gravity=="number"&&t.gravity>=0)?{message:"the `gravity` setting should be a number >= 0."}:"slowDown"in t&&!(typeof t.slowDown=="number"||t.slowDown>=0)?{message:"the `slowDown` setting should be a number >= 0."}:"barnesHutOptimize"in t&&typeof t.barnesHutOptimize!="boolean"?{message:"the `barnesHutOptimize` setting should be a boolean."}:"barnesHutTheta"in t&&!(typeof t.barnesHutTheta=="number"&&t.barnesHutTheta>=0)?{message:"the `barnesHutTheta` setting should be a number >= 0."}:null},Rs.graphToByteArrays=function(t,n){var i=t.order,s=t.size,o={},a,l=new Float32Array(i*r),c=new Float32Array(s*e);return a=0,t.forEachNode(function(u,h){o[u]=a,l[a]=h.x,l[a+1]=h.y,l[a+2]=0,l[a+3]=0,l[a+4]=0,l[a+5]=0,l[a+6]=1,l[a+7]=1,l[a+8]=h.size||1,l[a+9]=h.fixed?1:0,a+=r}),a=0,t.forEachEdge(function(u,h,p,m,v,_,y){var g=o[p],x=o[m],w=n(u,h,p,m,v,_,y);l[g+6]+=w,l[x+6]+=w,c[a]=g,c[a+1]=x,c[a+2]=w,a+=e}),{nodes:l,edges:c}},Rs.assignLayoutChanges=function(t,n,i){var s=0;t.updateEachNodeAttributes(function(o,a){return a.x=n[s],a.y=n[s+1],s+=r,i?i(o,a):a})},Rs.readGraphPositions=function(t,n){var i=0;t.forEachNode(function(s,o){n[i]=o.x,n[i+1]=o.y,i+=r})},Rs.collectLayoutChanges=function(t,n,i){for(var s=t.nodes(),o={},a=0,l=0,c=n.length;a2e3,strongGravityMode:!0,gravity:.05,scalingRatio:10,slowDown:1+Math.log(c)}}var a=s.bind(null,!1);return a.assign=s.bind(null,!0),a.inferSettings=o,Vg=a,Vg}var qF=YF();const ZF=Hr(qF);var Wg,uS;function KF(){if(uS)return Wg;uS=1;var r=Vy(),e=Xs(),t={dimensions:["x","y"],center:.5,rng:Math.random,scale:1};function n(s,o,a){if(!e(o))throw new Error("graphology-layout/random: the given graph is not a valid graphology instance.");a=r(a,t);var l=a.dimensions;if(!Array.isArray(l)||l.length<1)throw new Error("graphology-layout/random: given dimensions are invalid.");var c=l.length,u=a.center,h=a.rng,p=a.scale,m=(u-.5)*p;function v(y){for(var g=0;g 4294967295 is not supported.")},r.getSignedPointerArray=function(l){var c=l-1;return c<=i?Int8Array:c<=s?Int16Array:c<=o?Int32Array:Float64Array},r.getNumberType=function(l){return l===(l|0)?Math.sign(l)===-1?l<=127&&l>=-128?Int8Array:l<=32767&&l>=-32768?Int16Array:Int32Array:l<=255?Uint8Array:l<=65535?Uint16Array:Uint32Array:Float64Array};var a={Uint8Array:1,Int8Array:2,Uint16Array:3,Int16Array:4,Uint32Array:5,Int32Array:6,Float32Array:7,Float64Array:8};r.getMinimalRepresentation=function(l,c){var u=null,h=0,p,m,v,_,y;for(_=0,y=l.length;_h&&(h=p,u=m);return u},r.isTypedArray=function(l){return typeof ArrayBuffer<"u"&&ArrayBuffer.isView(l)},r.concat=function(){var l=0,c,u,h;for(c=0,h=arguments.length;c{let e;const t=new Set,n=(l,c)=>{const u=typeof l=="function"?l(e):l;if(!Object.is(u,e)){const h=e;e=c??typeof u!="object"?u:Object.assign({},e,u),t.forEach(p=>p(e,h))}},i=()=>e,a={setState:n,getState:i,subscribe:l=>(t.add(l),()=>t.delete(l)),destroy:()=>{(sk?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),t.clear()}};return e=r(n,i,a),a},ok=r=>r?mS(r):mS;var Yg={exports:{}},qg={},Zg={exports:{}},Kg={};/** * @license React * use-sync-external-store-shim.production.min.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var gS;function ak(){if(gS)return Kg;gS=1;var r=Hv();function e(h,p){return h===p&&(h!==0||1/h===1/p)||h!==h&&p!==p}var t=typeof Object.is=="function"?Object.is:e,n=r.useState,i=r.useEffect,s=r.useLayoutEffect,o=r.useDebugValue;function a(h,p){var m=p(),v=n({inst:{value:m,getSnapshot:p}}),_=v[0].inst,y=v[1];return s(function(){_.value=m,_.getSnapshot=p,l(_)&&y({inst:_})},[h,m,p]),i(function(){return l(_)&&y({inst:_}),h(function(){l(_)&&y({inst:_})})},[h]),o(m),m}function l(h){var p=h.getSnapshot;h=h.value;try{var m=p();return!t(h,m)}catch{return!0}}function c(h,p){return p()}var u=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?c:a;return Kg.useSyncExternalStore=r.useSyncExternalStore!==void 0?r.useSyncExternalStore:u,Kg}var vS;function lk(){return vS||(vS=1,Zg.exports=ak()),Zg.exports}/** * @license React * use-sync-external-store-shim/with-selector.production.min.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var yS;function ck(){if(yS)return qg;yS=1;var r=Hv(),e=lk();function t(c,u){return c===u&&(c!==0||1/c===1/u)||c!==c&&u!==u}var n=typeof Object.is=="function"?Object.is:t,i=e.useSyncExternalStore,s=r.useRef,o=r.useEffect,a=r.useMemo,l=r.useDebugValue;return qg.useSyncExternalStoreWithSelector=function(c,u,h,p,m){var v=s(null);if(v.current===null){var _={hasValue:!1,value:null};v.current=_}else _=v.current;v=a(function(){function g(M){if(!x){if(x=!0,w=M,M=p(M),m!==void 0&&_.hasValue){var A=_.value;if(m(A,M))return E=A}return E=M}if(A=E,n(w,M))return A;var P=p(M);return m!==void 0&&m(A,P)?A:(w=M,E=P)}var x=!1,w,E,b=h===void 0?null:h;return[function(){return g(u())},b===null?void 0:function(){return g(b())}]},[u,h,p,m]);var y=i(c,v[0],v[1]);return o(function(){_.hasValue=!0,_.value=y},[y]),l(y),y},qg}var _S;function uk(){return _S||(_S=1,Yg.exports=ck()),Yg.exports}var hk=uk();const fk=Hr(hk),dk={},{useSyncExternalStoreWithSelector:pk}=fk;function WT(r,e=r.getState,t){const n=pk(r.subscribe,r.getState,r.getServerState||r.getState,e,t);return K.useDebugValue(n),n}const xS=r=>{(dk?"production":void 0)!=="production"&&typeof r!="function"&&console.warn("[DEPRECATED] Passing a vanilla store will be unsupported in a future version. Instead use `import { useStore } from 'zustand'`.");const e=typeof r=="function"?ok(r):r,t=(n,i)=>WT(e,n,i);return Object.assign(t,e),t},mk=r=>r?xS(r):xS,gk={};function vk(){(gk?"production":void 0)!=="production"&&console.warn("[DEPRECATED] `context` will be removed in a future version. Instead use `import { createStore, useStore } from 'zustand'`. See: https://github.com/pmndrs/zustand/discussions/1180.");const r=K.createContext(void 0);return{Provider:({createStore:i,children:s})=>{const o=K.useRef();return o.current||(o.current=i()),K.createElement(r.Provider,{value:o.current},s)},useStore:(i,s)=>{const o=K.useContext(r);if(!o)throw new Error("Seems like you have not used zustand provider as an ancestor.");return WT(o,i,s)},useStoreApi:()=>{const i=K.useContext(r);if(!i)throw new Error("Seems like you have not used zustand provider as an ancestor.");return K.useMemo(()=>({...i}),[i])}}}function yk(r,e,t){return Math.max(e,Math.min(r,t))}const ln={toVector(r,e){return r===void 0&&(r=e),Array.isArray(r)?r:[r,r]},add(r,e){return[r[0]+e[0],r[1]+e[1]]},sub(r,e){return[r[0]-e[0],r[1]-e[1]]},addTo(r,e){r[0]+=e[0],r[1]+=e[1]},subTo(r,e){r[0]-=e[0],r[1]-=e[1]}};function wS(r,e,t){return e===0||Math.abs(e)===1/0?Math.pow(r,t*5):r*e*t/(e+t*r)}function SS(r,e,t,n=.15){return n===0?yk(r,e,t):rt?+wS(r-t,t-e,n)+t:r}function _k(r,[e,t],[n,i]){const[[s,o],[a,l]]=r;return[SS(e,s,o,n),SS(t,a,l,i)]}function xk(r,e){if(typeof r!="object"||r===null)return r;var t=r[Symbol.toPrimitive];if(t!==void 0){var n=t.call(r,e);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(r)}function wk(r){var e=xk(r,"string");return typeof e=="symbol"?e:String(e)}function kn(r,e,t){return e=wk(e),e in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}function ES(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);e&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(r,i).enumerable})),t.push.apply(t,n)}return t}function wn(r){for(var e=1;e{var t,n;return e.target===r.currentTarget||((t=r.currentTarget)===null||t===void 0||(n=t.contains)===null||n===void 0?void 0:n.call(t,e.target))})}function Rk(r){return r.type==="touchend"||r.type==="touchcancel"?r.changedTouches:r.targetTouches}function YT(r){return Ap(r)?Rk(r)[0]:r}function Ev(r,e){try{const t=e.clientX-r.clientX,n=e.clientY-r.clientY,i=(e.clientX+r.clientX)/2,s=(e.clientY+r.clientY)/2,o=Math.hypot(t,n);return{angle:-(Math.atan2(t,n)*180)/Math.PI,distance:o,origin:[i,s]}}catch{}return null}function Pk(r){return Ck(r).map(e=>e.identifier)}function MS(r,e){const[t,n]=Array.from(r.touches).filter(i=>e.includes(i.identifier));return Ev(t,n)}function $g(r){const e=YT(r);return Ap(r)?e.identifier:e.pointerId}function Zl(r){const e=YT(r);return[e.clientX,e.clientY]}const TS=40,AS=800;function qT(r){let{deltaX:e,deltaY:t,deltaMode:n}=r;return n===1?(e*=TS,t*=TS):n===2&&(e*=AS,t*=AS),[e,t]}function Lk(r){var e,t;const{scrollX:n,scrollY:i,scrollLeft:s,scrollTop:o}=r.currentTarget;return[(e=n??s)!==null&&e!==void 0?e:0,(t=i??o)!==null&&t!==void 0?t:0]}function Ik(r){const e={};if("buttons"in r&&(e.buttons=r.buttons),"shiftKey"in r){const{shiftKey:t,altKey:n,metaKey:i,ctrlKey:s}=r;Object.assign(e,{shiftKey:t,altKey:n,metaKey:i,ctrlKey:s})}return e}function zd(r,...e){return typeof r=="function"?r(...e):r}function Dk(){}function Uk(...r){return r.length===0?Dk:r.length===1?r[0]:function(){let e;for(const t of r)e=t.apply(this,arguments)||e;return e}}function CS(r,e){return Object.assign({},e,r||{})}const Ok=32;class ZT{constructor(e,t,n){this.ctrl=e,this.args=t,this.key=n,this.state||(this.state={},this.computeValues([0,0]),this.computeInitial(),this.init&&this.init(),this.reset())}get state(){return this.ctrl.state[this.key]}set state(e){this.ctrl.state[this.key]=e}get shared(){return this.ctrl.state.shared}get eventStore(){return this.ctrl.gestureEventStores[this.key]}get timeoutStore(){return this.ctrl.gestureTimeoutStores[this.key]}get config(){return this.ctrl.config[this.key]}get sharedConfig(){return this.ctrl.config.shared}get handler(){return this.ctrl.handlers[this.key]}reset(){const{state:e,shared:t,ingKey:n,args:i}=this;t[n]=e._active=e.active=e._blocked=e._force=!1,e._step=[!1,!1],e.intentional=!1,e._movement=[0,0],e._distance=[0,0],e._direction=[0,0],e._delta=[0,0],e._bounds=[[-1/0,1/0],[-1/0,1/0]],e.args=i,e.axis=void 0,e.memo=void 0,e.elapsedTime=e.timeDelta=0,e.direction=[0,0],e.distance=[0,0],e.overflow=[0,0],e._movementBound=[!1,!1],e.velocity=[0,0],e.movement=[0,0],e.delta=[0,0],e.timeStamp=0}start(e){const t=this.state,n=this.config;t._active||(this.reset(),this.computeInitial(),t._active=!0,t.target=e.target,t.currentTarget=e.currentTarget,t.lastOffset=n.from?zd(n.from,t):t.offset,t.offset=t.lastOffset,t.startTime=t.timeStamp=e.timeStamp)}computeValues(e){const t=this.state;t._values=e,t.values=this.config.transform(e)}computeInitial(){const e=this.state;e._initial=e._values,e.initial=e.values}compute(e){const{state:t,config:n,shared:i}=this;t.args=this.args;let s=0;if(e&&(t.event=e,n.preventDefault&&e.cancelable&&t.event.preventDefault(),t.type=e.type,i.touches=this.ctrl.pointerIds.size||this.ctrl.touchIds.size,i.locked=!!document.pointerLockElement,Object.assign(i,Ik(e)),i.down=i.pressed=i.buttons%2===1||i.touches>0,s=e.timeStamp-t.timeStamp,t.timeStamp=e.timeStamp,t.elapsedTime=t.timeStamp-t.startTime),t._active){const M=t._delta.map(Math.abs);ln.addTo(t._distance,M)}this.axisIntent&&this.axisIntent(e);const[o,a]=t._movement,[l,c]=n.threshold,{_step:u,values:h}=t;if(n.hasCustomTransform?(u[0]===!1&&(u[0]=Math.abs(o)>=l&&h[0]),u[1]===!1&&(u[1]=Math.abs(a)>=c&&h[1])):(u[0]===!1&&(u[0]=Math.abs(o)>=l&&Math.sign(o)*l),u[1]===!1&&(u[1]=Math.abs(a)>=c&&Math.sign(a)*c)),t.intentional=u[0]!==!1||u[1]!==!1,!t.intentional)return;const p=[0,0];if(n.hasCustomTransform){const[M,A]=h;p[0]=u[0]!==!1?M-u[0]:0,p[1]=u[1]!==!1?A-u[1]:0}else p[0]=u[0]!==!1?o-u[0]:0,p[1]=u[1]!==!1?a-u[1]:0;this.restrictToAxis&&!t._blocked&&this.restrictToAxis(p);const m=t.offset,v=t._active&&!t._blocked||t.active;v&&(t.first=t._active&&!t.active,t.last=!t._active&&t.active,t.active=i[this.ingKey]=t._active,e&&(t.first&&("bounds"in n&&(t._bounds=zd(n.bounds,t)),this.setup&&this.setup()),t.movement=p,this.computeOffset()));const[_,y]=t.offset,[[g,x],[w,E]]=t._bounds;t.overflow=[_x?1:0,yE?1:0],t._movementBound[0]=t.overflow[0]?t._movementBound[0]===!1?t._movement[0]:t._movementBound[0]:!1,t._movementBound[1]=t.overflow[1]?t._movementBound[1]===!1?t._movement[1]:t._movementBound[1]:!1;const b=t._active?n.rubberband||[0,0]:[0,0];if(t.offset=_k(t._bounds,t.offset,b),t.delta=ln.sub(t.offset,m),this.computeMovement(),v&&(!t.last||s>Ok)){t.delta=ln.sub(t.offset,m);const M=t.delta.map(Math.abs);ln.addTo(t.distance,M),t.direction=t.delta.map(Math.sign),t._direction=t._delta.map(Math.sign),!t.first&&s>0&&(t.velocity=[M[0]/s,M[1]/s],t.timeDelta=s)}}emit(){const e=this.state,t=this.shared,n=this.config;if(e._active||this.clean(),(e._blocked||!e.intentional)&&!e._force&&!n.triggerAllEvents)return;const i=this.handler(wn(wn(wn({},t),e),{},{[this.aliasKey]:e.values}));i!==void 0&&(e.memo=i)}clean(){this.eventStore.clean(),this.timeoutStore.clean()}}function Nk([r,e],t){const n=Math.abs(r),i=Math.abs(e);if(n>i&&n>t)return"x";if(i>n&&i>t)return"y"}class fh extends ZT{constructor(...e){super(...e),kn(this,"aliasKey","xy")}reset(){super.reset(),this.state.axis=void 0}init(){this.state.offset=[0,0],this.state.lastOffset=[0,0]}computeOffset(){this.state.offset=ln.add(this.state.lastOffset,this.state.movement)}computeMovement(){this.state.movement=ln.sub(this.state.offset,this.state.lastOffset)}axisIntent(e){const t=this.state,n=this.config;if(!t.axis&&e){const i=typeof n.axisThreshold=="object"?n.axisThreshold[jT(e)]:n.axisThreshold;t.axis=Nk(t._movement,i)}t._blocked=(n.lockDirection||!!n.axis)&&!t.axis||!!n.axis&&n.axis!==t.axis}restrictToAxis(e){if(this.config.axis||this.config.lockDirection)switch(this.state.axis){case"x":e[1]=0;break;case"y":e[0]=0;break}}}const Fk=r=>r,RS=.15,KT={enabled(r=!0){return r},eventOptions(r,e,t){return wn(wn({},t.shared.eventOptions),r)},preventDefault(r=!1){return r},triggerAllEvents(r=!1){return r},rubberband(r=0){switch(r){case!0:return[RS,RS];case!1:return[0,0];default:return ln.toVector(r)}},from(r){if(typeof r=="function")return r;if(r!=null)return ln.toVector(r)},transform(r,e,t){const n=r||t.shared.transform;return this.hasCustomTransform=!!n,n||Fk},threshold(r){return ln.toVector(r,0)}},kk=0,Ua=wn(wn({},KT),{},{axis(r,e,{axis:t}){if(this.lockDirection=t==="lock",!this.lockDirection)return t},axisThreshold(r=kk){return r},bounds(r={}){if(typeof r=="function")return s=>Ua.bounds(r(s));if("current"in r)return()=>r.current;if(typeof HTMLElement=="function"&&r instanceof HTMLElement)return r;const{left:e=-1/0,right:t=1/0,top:n=-1/0,bottom:i=1/0}=r;return[[e,t],[n,i]]}}),PS={ArrowRight:(r,e=1)=>[r*e,0],ArrowLeft:(r,e=1)=>[-1*r*e,0],ArrowUp:(r,e=1)=>[0,-1*r*e],ArrowDown:(r,e=1)=>[0,r*e]};class zk extends fh{constructor(...e){super(...e),kn(this,"ingKey","dragging")}reset(){super.reset();const e=this.state;e._pointerId=void 0,e._pointerActive=!1,e._keyboardActive=!1,e._preventScroll=!1,e._delayed=!1,e.swipe=[0,0],e.tap=!1,e.canceled=!1,e.cancel=this.cancel.bind(this)}setup(){const e=this.state;if(e._bounds instanceof HTMLElement){const t=e._bounds.getBoundingClientRect(),n=e.currentTarget.getBoundingClientRect(),i={left:t.left-n.left+e.offset[0],right:t.right-n.right+e.offset[0],top:t.top-n.top+e.offset[1],bottom:t.bottom-n.bottom+e.offset[1]};e._bounds=Ua.bounds(i)}}cancel(){const e=this.state;e.canceled||(e.canceled=!0,e._active=!1,setTimeout(()=>{this.compute(),this.emit()},0))}setActive(){this.state._active=this.state._pointerActive||this.state._keyboardActive}clean(){this.pointerClean(),this.state._pointerActive=!1,this.state._keyboardActive=!1,super.clean()}pointerDown(e){const t=this.config,n=this.state;if(e.buttons!=null&&(Array.isArray(t.pointerButtons)?!t.pointerButtons.includes(e.buttons):t.pointerButtons!==-1&&t.pointerButtons!==e.buttons))return;const i=this.ctrl.setEventIds(e);t.pointerCapture&&e.target.setPointerCapture(e.pointerId),!(i&&i.size>1&&n._pointerActive)&&(this.start(e),this.setupPointer(e),n._pointerId=$g(e),n._pointerActive=!0,this.computeValues(Zl(e)),this.computeInitial(),t.preventScrollAxis&&jT(e)!=="mouse"?(n._active=!1,this.setupScrollPrevention(e)):t.delay>0?(this.setupDelayTrigger(e),t.triggerAllEvents&&(this.compute(e),this.emit())):this.startPointerDrag(e))}startPointerDrag(e){const t=this.state;t._active=!0,t._preventScroll=!0,t._delayed=!1,this.compute(e),this.emit()}pointerMove(e){const t=this.state,n=this.config;if(!t._pointerActive)return;const i=$g(e);if(t._pointerId!==void 0&&i!==t._pointerId)return;const s=Zl(e);if(document.pointerLockElement===e.target?t._delta=[e.movementX,e.movementY]:(t._delta=ln.sub(s,t._values),this.computeValues(s)),ln.addTo(t._movement,t._delta),this.compute(e),t._delayed&&t.intentional){this.timeoutStore.remove("dragDelay"),t.active=!1,this.startPointerDrag(e);return}if(n.preventScrollAxis&&!t._preventScroll)if(t.axis)if(t.axis===n.preventScrollAxis||n.preventScrollAxis==="xy"){t._active=!1,this.clean();return}else{this.timeoutStore.remove("startPointerDrag"),this.startPointerDrag(e);return}else return;this.emit()}pointerUp(e){this.ctrl.setEventIds(e);try{this.config.pointerCapture&&e.target.hasPointerCapture(e.pointerId)&&e.target.releasePointerCapture(e.pointerId)}catch{}const t=this.state,n=this.config;if(!t._active||!t._pointerActive)return;const i=$g(e);if(t._pointerId!==void 0&&i!==t._pointerId)return;this.state._pointerActive=!1,this.setActive(),this.compute(e);const[s,o]=t._distance;if(t.tap=s<=n.tapsThreshold&&o<=n.tapsThreshold,t.tap&&n.filterTaps)t._force=!0;else{const[a,l]=t._delta,[c,u]=t._movement,[h,p]=n.swipe.velocity,[m,v]=n.swipe.distance,_=n.swipe.duration;if(t.elapsedTime<_){const y=Math.abs(a/t.timeDelta),g=Math.abs(l/t.timeDelta);y>h&&Math.abs(c)>m&&(t.swipe[0]=Math.sign(a)),g>p&&Math.abs(u)>v&&(t.swipe[1]=Math.sign(l))}}this.emit()}pointerClick(e){!this.state.tap&&e.detail>0&&(e.preventDefault(),e.stopPropagation())}setupPointer(e){const t=this.config,n=t.device;t.pointerLock&&e.currentTarget.requestPointerLock(),t.pointerCapture||(this.eventStore.add(this.sharedConfig.window,n,"change",this.pointerMove.bind(this)),this.eventStore.add(this.sharedConfig.window,n,"end",this.pointerUp.bind(this)),this.eventStore.add(this.sharedConfig.window,n,"cancel",this.pointerUp.bind(this)))}pointerClean(){this.config.pointerLock&&document.pointerLockElement===this.state.currentTarget&&document.exitPointerLock()}preventScroll(e){this.state._preventScroll&&e.cancelable&&e.preventDefault()}setupScrollPrevention(e){this.state._preventScroll=!1,Bk(e);const t=this.eventStore.add(this.sharedConfig.window,"touch","change",this.preventScroll.bind(this),{passive:!1});this.eventStore.add(this.sharedConfig.window,"touch","end",t),this.eventStore.add(this.sharedConfig.window,"touch","cancel",t),this.timeoutStore.add("startPointerDrag",this.startPointerDrag.bind(this),this.config.preventScrollDelay,e)}setupDelayTrigger(e){this.state._delayed=!0,this.timeoutStore.add("dragDelay",()=>{this.state._step=[0,0],this.startPointerDrag(e)},this.config.delay)}keyDown(e){const t=PS[e.key];if(t){const n=this.state,i=e.shiftKey?10:e.altKey?.1:1;this.start(e),n._delta=t(this.config.keyboardDisplacement,i),n._keyboardActive=!0,ln.addTo(n._movement,n._delta),this.compute(e),this.emit()}}keyUp(e){e.key in PS&&(this.state._keyboardActive=!1,this.setActive(),this.compute(e),this.emit())}bind(e){const t=this.config.device;e(t,"start",this.pointerDown.bind(this)),this.config.pointerCapture&&(e(t,"change",this.pointerMove.bind(this)),e(t,"end",this.pointerUp.bind(this)),e(t,"cancel",this.pointerUp.bind(this)),e("lostPointerCapture","",this.pointerUp.bind(this))),this.config.keys&&(e("key","down",this.keyDown.bind(this)),e("key","up",this.keyUp.bind(this))),this.config.filterTaps&&e("click","",this.pointerClick.bind(this),{capture:!0,passive:!1})}}function Bk(r){"persist"in r&&typeof r.persist=="function"&&r.persist()}const dh=typeof window<"u"&&window.document&&window.document.createElement;function $T(){return dh&&"ontouchstart"in window}function Gk(){return $T()||dh&&window.navigator.maxTouchPoints>1}function Hk(){return dh&&"onpointerdown"in window}function Vk(){return dh&&"exitPointerLock"in window.document}function Wk(){try{return"constructor"in GestureEvent}catch{return!1}}const wr={isBrowser:dh,gesture:Wk(),touch:$T(),touchscreen:Gk(),pointer:Hk(),pointerLock:Vk()},Xk=250,jk=180,Yk=.5,qk=50,Zk=250,Kk=10,LS={mouse:0,touch:0,pen:8},$k=wn(wn({},Ua),{},{device(r,e,{pointer:{touch:t=!1,lock:n=!1,mouse:i=!1}={}}){return this.pointerLock=n&&wr.pointerLock,wr.touch&&t?"touch":this.pointerLock?"mouse":wr.pointer&&!i?"pointer":wr.touch?"touch":"mouse"},preventScrollAxis(r,e,{preventScroll:t}){if(this.preventScrollDelay=typeof t=="number"?t:t||t===void 0&&r?Xk:void 0,!(!wr.touchscreen||t===!1))return r||(t!==void 0?"y":void 0)},pointerCapture(r,e,{pointer:{capture:t=!0,buttons:n=1,keys:i=!0}={}}){return this.pointerButtons=n,this.keys=i,!this.pointerLock&&this.device==="pointer"&&t},threshold(r,e,{filterTaps:t=!1,tapsThreshold:n=3,axis:i=void 0}){const s=ln.toVector(r,t?n:i?1:0);return this.filterTaps=t,this.tapsThreshold=n,s},swipe({velocity:r=Yk,distance:e=qk,duration:t=Zk}={}){return{velocity:this.transform(ln.toVector(r)),distance:this.transform(ln.toVector(e)),duration:t}},delay(r=0){switch(r){case!0:return jk;case!1:return 0;default:return r}},axisThreshold(r){return r?wn(wn({},LS),r):LS},keyboardDisplacement(r=Kk){return r}});function JT(r){const[e,t]=r.overflow,[n,i]=r._delta,[s,o]=r._direction;(e<0&&n>0&&s<0||e>0&&n<0&&s>0)&&(r._movement[0]=r._movementBound[0]),(t<0&&i>0&&o<0||t>0&&i<0&&o>0)&&(r._movement[1]=r._movementBound[1])}const Jk=30,Qk=100;class ez extends ZT{constructor(...e){super(...e),kn(this,"ingKey","pinching"),kn(this,"aliasKey","da")}init(){this.state.offset=[1,0],this.state.lastOffset=[1,0],this.state._pointerEvents=new Map}reset(){super.reset();const e=this.state;e._touchIds=[],e.canceled=!1,e.cancel=this.cancel.bind(this),e.turns=0}computeOffset(){const{type:e,movement:t,lastOffset:n}=this.state;e==="wheel"?this.state.offset=ln.add(t,n):this.state.offset=[(1+t[0])*n[0],t[1]+n[1]]}computeMovement(){const{offset:e,lastOffset:t}=this.state;this.state.movement=[e[0]/t[0],e[1]-t[1]]}axisIntent(){const e=this.state,[t,n]=e._movement;if(!e.axis){const i=Math.abs(t)*Jk-Math.abs(n);i<0?e.axis="angle":i>0&&(e.axis="scale")}}restrictToAxis(e){this.config.lockDirection&&(this.state.axis==="scale"?e[1]=0:this.state.axis==="angle"&&(e[0]=0))}cancel(){const e=this.state;e.canceled||setTimeout(()=>{e.canceled=!0,e._active=!1,this.compute(),this.emit()},0)}touchStart(e){this.ctrl.setEventIds(e);const t=this.state,n=this.ctrl.touchIds;if(t._active&&t._touchIds.every(s=>n.has(s))||n.size<2)return;this.start(e),t._touchIds=Array.from(n).slice(0,2);const i=MS(e,t._touchIds);i&&this.pinchStart(e,i)}pointerStart(e){if(e.buttons!=null&&e.buttons%2!==1)return;this.ctrl.setEventIds(e),e.target.setPointerCapture(e.pointerId);const t=this.state,n=t._pointerEvents,i=this.ctrl.pointerIds;if(t._active&&Array.from(n.keys()).every(o=>i.has(o))||(n.size<2&&n.set(e.pointerId,e),t._pointerEvents.size<2))return;this.start(e);const s=Ev(...Array.from(n.values()));s&&this.pinchStart(e,s)}pinchStart(e,t){const n=this.state;n.origin=t.origin,this.computeValues([t.distance,t.angle]),this.computeInitial(),this.compute(e),this.emit()}touchMove(e){if(!this.state._active)return;const t=MS(e,this.state._touchIds);t&&this.pinchMove(e,t)}pointerMove(e){const t=this.state._pointerEvents;if(t.has(e.pointerId)&&t.set(e.pointerId,e),!this.state._active)return;const n=Ev(...Array.from(t.values()));n&&this.pinchMove(e,n)}pinchMove(e,t){const n=this.state,i=n._values[1],s=t.angle-i;let o=0;Math.abs(s)>270&&(o+=Math.sign(s)),this.computeValues([t.distance,t.angle-360*o]),n.origin=t.origin,n.turns=o,n._movement=[n._values[0]/n._initial[0]-1,n._values[1]-n._initial[1]],this.compute(e),this.emit()}touchEnd(e){this.ctrl.setEventIds(e),this.state._active&&this.state._touchIds.some(t=>!this.ctrl.touchIds.has(t))&&(this.state._active=!1,this.compute(e),this.emit())}pointerEnd(e){const t=this.state;this.ctrl.setEventIds(e);try{e.target.releasePointerCapture(e.pointerId)}catch{}t._pointerEvents.has(e.pointerId)&&t._pointerEvents.delete(e.pointerId),t._active&&t._pointerEvents.size<2&&(t._active=!1,this.compute(e),this.emit())}gestureStart(e){e.cancelable&&e.preventDefault();const t=this.state;t._active||(this.start(e),this.computeValues([e.scale,e.rotation]),t.origin=[e.clientX,e.clientY],this.compute(e),this.emit())}gestureMove(e){if(e.cancelable&&e.preventDefault(),!this.state._active)return;const t=this.state;this.computeValues([e.scale,e.rotation]),t.origin=[e.clientX,e.clientY];const n=t._movement;t._movement=[e.scale-1,e.rotation],t._delta=ln.sub(t._movement,n),this.compute(e),this.emit()}gestureEnd(e){this.state._active&&(this.state._active=!1,this.compute(e),this.emit())}wheel(e){const t=this.config.modifierKey;t&&(Array.isArray(t)?!t.find(n=>e[n]):!e[t])||(this.state._active?this.wheelChange(e):this.wheelStart(e),this.timeoutStore.add("wheelEnd",this.wheelEnd.bind(this)))}wheelStart(e){this.start(e),this.wheelChange(e)}wheelChange(e){"uv"in e||e.cancelable&&e.preventDefault();const n=this.state;n._delta=[-qT(e)[1]/Qk*n.offset[0],0],ln.addTo(n._movement,n._delta),JT(n),this.state.origin=[e.clientX,e.clientY],this.compute(e),this.emit()}wheelEnd(){this.state._active&&(this.state._active=!1,this.compute(),this.emit())}bind(e){const t=this.config.device;t&&(e(t,"start",this[t+"Start"].bind(this)),e(t,"change",this[t+"Move"].bind(this)),e(t,"end",this[t+"End"].bind(this)),e(t,"cancel",this[t+"End"].bind(this)),e("lostPointerCapture","",this[t+"End"].bind(this))),this.config.pinchOnWheel&&e("wheel","",this.wheel.bind(this),{passive:!1})}}const tz=wn(wn({},KT),{},{device(r,e,{shared:t,pointer:{touch:n=!1}={}}){if(t.target&&!wr.touch&&wr.gesture)return"gesture";if(wr.touch&&n)return"touch";if(wr.touchscreen){if(wr.pointer)return"pointer";if(wr.touch)return"touch"}},bounds(r,e,{scaleBounds:t={},angleBounds:n={}}){const i=o=>{const a=CS(zd(t,o),{min:-1/0,max:1/0});return[a.min,a.max]},s=o=>{const a=CS(zd(n,o),{min:-1/0,max:1/0});return[a.min,a.max]};return typeof t!="function"&&typeof n!="function"?[i(),s()]:o=>[i(o),s(o)]},threshold(r,e,t){return this.lockDirection=t.axis==="lock",ln.toVector(r,this.lockDirection?[.1,3]:0)},modifierKey(r){return r===void 0?"ctrlKey":r},pinchOnWheel(r=!0){return r}});class nz extends fh{constructor(...e){super(...e),kn(this,"ingKey","moving")}move(e){this.config.mouseOnly&&e.pointerType!=="mouse"||(this.state._active?this.moveChange(e):this.moveStart(e),this.timeoutStore.add("moveEnd",this.moveEnd.bind(this)))}moveStart(e){this.start(e),this.computeValues(Zl(e)),this.compute(e),this.computeInitial(),this.emit()}moveChange(e){if(!this.state._active)return;const t=Zl(e),n=this.state;n._delta=ln.sub(t,n._values),ln.addTo(n._movement,n._delta),this.computeValues(t),this.compute(e),this.emit()}moveEnd(e){this.state._active&&(this.state._active=!1,this.compute(e),this.emit())}bind(e){e("pointer","change",this.move.bind(this)),e("pointer","leave",this.moveEnd.bind(this))}}const iz=wn(wn({},Ua),{},{mouseOnly:(r=!0)=>r});class rz extends fh{constructor(...e){super(...e),kn(this,"ingKey","scrolling")}scroll(e){this.state._active||this.start(e),this.scrollChange(e),this.timeoutStore.add("scrollEnd",this.scrollEnd.bind(this))}scrollChange(e){e.cancelable&&e.preventDefault();const t=this.state,n=Lk(e);t._delta=ln.sub(n,t._values),ln.addTo(t._movement,t._delta),this.computeValues(n),this.compute(e),this.emit()}scrollEnd(){this.state._active&&(this.state._active=!1,this.compute(),this.emit())}bind(e){e("scroll","",this.scroll.bind(this))}}const sz=Ua;class oz extends fh{constructor(...e){super(...e),kn(this,"ingKey","wheeling")}wheel(e){this.state._active||this.start(e),this.wheelChange(e),this.timeoutStore.add("wheelEnd",this.wheelEnd.bind(this))}wheelChange(e){const t=this.state;t._delta=qT(e),ln.addTo(t._movement,t._delta),JT(t),this.compute(e),this.emit()}wheelEnd(){this.state._active&&(this.state._active=!1,this.compute(),this.emit())}bind(e){e("wheel","",this.wheel.bind(this))}}const az=Ua;class lz extends fh{constructor(...e){super(...e),kn(this,"ingKey","hovering")}enter(e){this.config.mouseOnly&&e.pointerType!=="mouse"||(this.start(e),this.computeValues(Zl(e)),this.compute(e),this.emit())}leave(e){if(this.config.mouseOnly&&e.pointerType!=="mouse")return;const t=this.state;if(!t._active)return;t._active=!1;const n=Zl(e);t._movement=t._delta=ln.sub(n,t._values),this.computeValues(n),this.compute(e),t.delta=t.movement,this.emit()}bind(e){e("pointer","enter",this.enter.bind(this)),e("pointer","leave",this.leave.bind(this))}}const cz=wn(wn({},Ua),{},{mouseOnly:(r=!0)=>r}),Wy=new Map,bv=new Map;function uz(r){Wy.set(r.key,r.engine),bv.set(r.key,r.resolver)}const hz={key:"drag",engine:zk,resolver:$k},fz={key:"hover",engine:lz,resolver:cz},dz={key:"move",engine:nz,resolver:iz},pz={key:"pinch",engine:ez,resolver:tz},mz={key:"scroll",engine:rz,resolver:sz},gz={key:"wheel",engine:oz,resolver:az};function vz(r,e){if(r==null)return{};var t={},n=Object.keys(r),i,s;for(s=0;s=0)&&(t[i]=r[i]);return t}function yz(r,e){if(r==null)return{};var t=vz(r,e),n,i;if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(r);for(i=0;i=0)&&Object.prototype.propertyIsEnumerable.call(r,n)&&(t[n]=r[n])}return t}const _z={target(r){if(r)return()=>"current"in r?r.current:r},enabled(r=!0){return r},window(r=wr.isBrowser?window:void 0){return r},eventOptions({passive:r=!0,capture:e=!1}={}){return{passive:r,capture:e}},transform(r){return r}},xz=["target","eventOptions","window","enabled","transform"];function Ad(r={},e){const t={};for(const[n,i]of Object.entries(e))switch(typeof i){case"function":t[n]=i.call(t,r[n],n,r);break;case"object":t[n]=Ad(r[n],i);break;case"boolean":i&&(t[n]=r[n]);break}return t}function wz(r,e,t={}){const n=r,{target:i,eventOptions:s,window:o,enabled:a,transform:l}=n,c=yz(n,xz);if(t.shared=Ad({target:i,eventOptions:s,window:o,enabled:a,transform:l},_z),e){const u=bv.get(e);t[e]=Ad(wn({shared:t.shared},c),u)}else for(const u in c){const h=bv.get(u);h&&(t[u]=Ad(wn({shared:t.shared},c[u]),h))}return t}class QT{constructor(e,t){kn(this,"_listeners",new Set),this._ctrl=e,this._gestureKey=t}add(e,t,n,i,s){const o=this._listeners,a=Ak(t,n),l=this._gestureKey?this._ctrl.config[this._gestureKey].eventOptions:{},c=wn(wn({},l),s);e.addEventListener(a,i,c);const u=()=>{e.removeEventListener(a,i,c),o.delete(u)};return o.add(u),u}clean(){this._listeners.forEach(e=>e()),this._listeners.clear()}}class Sz{constructor(){kn(this,"_timeouts",new Map)}add(e,t,n=140,...i){this.remove(e),this._timeouts.set(e,window.setTimeout(t,n,...i))}remove(e){const t=this._timeouts.get(e);t&&window.clearTimeout(t)}clean(){this._timeouts.forEach(e=>void window.clearTimeout(e)),this._timeouts.clear()}}let Ez=class{constructor(e){kn(this,"gestures",new Set),kn(this,"_targetEventStore",new QT(this)),kn(this,"gestureEventStores",{}),kn(this,"gestureTimeoutStores",{}),kn(this,"handlers",{}),kn(this,"config",{}),kn(this,"pointerIds",new Set),kn(this,"touchIds",new Set),kn(this,"state",{shared:{shiftKey:!1,metaKey:!1,ctrlKey:!1,altKey:!1}}),bz(this,e)}setEventIds(e){if(Ap(e))return this.touchIds=new Set(Pk(e)),this.touchIds;if("pointerId"in e)return e.type==="pointerup"||e.type==="pointercancel"?this.pointerIds.delete(e.pointerId):e.type==="pointerdown"&&this.pointerIds.add(e.pointerId),this.pointerIds}applyHandlers(e,t){this.handlers=e,this.nativeHandlers=t}applyConfig(e,t){this.config=wz(e,t,this.config)}clean(){this._targetEventStore.clean();for(const e of this.gestures)this.gestureEventStores[e].clean(),this.gestureTimeoutStores[e].clean()}effect(){return this.config.shared.target&&this.bind(),()=>this._targetEventStore.clean()}bind(...e){const t=this.config.shared,n={};let i;if(!(t.target&&(i=t.target(),!i))){if(t.enabled){for(const o of this.gestures){const a=this.config[o],l=IS(n,a.eventOptions,!!i);if(a.enabled){const c=Wy.get(o);new c(this,e,o).bind(l)}}const s=IS(n,t.eventOptions,!!i);for(const o in this.nativeHandlers)s(o,"",a=>this.nativeHandlers[o](wn(wn({},this.state.shared),{},{event:a,args:e})),void 0,!0)}for(const s in n)n[s]=Uk(...n[s]);if(!i)return n;for(const s in n){const{device:o,capture:a,passive:l}=Tk(s);this._targetEventStore.add(i,o,"",n[s],{capture:a,passive:l})}}}};function _l(r,e){r.gestures.add(e),r.gestureEventStores[e]=new QT(r,e),r.gestureTimeoutStores[e]=new Sz}function bz(r,e){e.drag&&_l(r,"drag"),e.wheel&&_l(r,"wheel"),e.scroll&&_l(r,"scroll"),e.move&&_l(r,"move"),e.pinch&&_l(r,"pinch"),e.hover&&_l(r,"hover")}const IS=(r,e,t)=>(n,i,s,o={},a=!1)=>{var l,c;const u=(l=o.capture)!==null&&l!==void 0?l:e.capture,h=(c=o.passive)!==null&&c!==void 0?c:e.passive;let p=a?n:bk(n,i,u);t&&h&&(p+="Passive"),r[p]=r[p]||[],r[p].push(s)},Mz=/^on(Drag|Wheel|Scroll|Move|Pinch|Hover)/;function Tz(r){const e={},t={},n=new Set;for(let i in r)Mz.test(i)?(n.add(RegExp.lastMatch),t[i]=r[i]):e[i]=r[i];return[t,e,n]}function xl(r,e,t,n,i,s){if(!r.has(t)||!Wy.has(n))return;const o=t+"Start",a=t+"End",l=c=>{let u;return c.first&&o in e&&e[o](c),t in e&&(u=e[t](c)),c.last&&a in e&&e[a](c),u};i[n]=l,s[n]=s[n]||{}}function Az(r,e){const[t,n,i]=Tz(r),s={};return xl(i,t,"onDrag","drag",s,e),xl(i,t,"onWheel","wheel",s,e),xl(i,t,"onScroll","scroll",s,e),xl(i,t,"onPinch","pinch",s,e),xl(i,t,"onMove","move",s,e),xl(i,t,"onHover","hover",s,e),{handlers:s,config:e,nativeHandlers:n}}function Cz(r,e={},t,n){const i=Um.useMemo(()=>new Ez(r),[]);if(i.applyHandlers(r,n),i.applyConfig(e,t),Um.useEffect(i.effect.bind(i)),Um.useEffect(()=>i.clean.bind(i),[]),e.target===void 0)return i.bind.bind(i)}function Rz(r){return r.forEach(uz),function(t,n){const{handlers:i,nativeHandlers:s,config:o}=Az(t,n||{});return Cz(i,o,void 0,s)}}function Pz(r,e){return Rz([hz,pz,mz,gz,dz,fz])(r,e||{})}var Lr={},ta={},Jg,DS;function Cp(){if(DS)return Jg;DS=1;function r(e){if(typeof e!="function")throw new Error("obliterator/iterator: expecting a function!");this.next=e}return typeof Symbol<"u"&&(r.prototype[Symbol.iterator]=function(){return this}),r.of=function(){var e=arguments,t=e.length,n=0;return new r(function(){return n>=t?{done:!0}:{done:!1,value:e[n++]}})},r.empty=function(){var e=new r(function(){return{done:!0}});return e},r.fromSequence=function(e){var t=0,n=e.length;return new r(function(){return t>=n?{done:!0}:{done:!1,value:e[t++]}})},r.is=function(e){return e instanceof r?!0:typeof e=="object"&&e!==null&&typeof e.next=="function"},Jg=r,Jg}var nd={},US;function eA(){return US||(US=1,nd.ARRAY_BUFFER_SUPPORT=typeof ArrayBuffer<"u",nd.SYMBOL_SUPPORT=typeof Symbol<"u"),nd}var Qg,OS;function Xy(){if(OS)return Qg;OS=1;var r=eA(),e=r.ARRAY_BUFFER_SUPPORT,t=r.SYMBOL_SUPPORT;return Qg=function(i,s){var o,a,l,c,u;if(!i)throw new Error("obliterator/forEach: invalid iterable.");if(typeof s!="function")throw new Error("obliterator/forEach: expecting a callback.");if(Array.isArray(i)||e&&ArrayBuffer.isView(i)||typeof i=="string"||i.toString()==="[object Arguments]"){for(l=0,c=i.length;l=this.items.length&&(this.items=this.items.slice(this.offset),this.offset=0),this.size--,n}},t.prototype.peek=function(){if(this.size)return this.items[this.offset]},t.prototype.forEach=function(n,i){i=arguments.length>1?i:this;for(var s=this.offset,o=0,a=this.items.length;s=n.length)return{done:!0};var s=n[i];return i++,{value:s,done:!1}})},t.prototype.entries=function(){var n=this.items,i=this.offset,s=0;return new r(function(){if(i>=n.length)return{done:!0};var o=n[i];return i++,{value:[s++,o],done:!1}})},typeof Symbol<"u"&&(t.prototype[Symbol.iterator]=t.prototype.values),t.prototype.toString=function(){return this.toArray().join(",")},t.prototype.toJSON=function(){return this.toArray()},t.prototype.inspect=function(){var n=this.toArray();return Object.defineProperty(n,"constructor",{value:t,enumerable:!1}),n},typeof Symbol<"u"&&(t.prototype[Symbol.for("nodejs.util.inspect.custom")]=t.prototype.inspect),t.from=function(n){var i=new t;return e(n,function(s){i.enqueue(s)}),i},t.of=function(){return t.from(arguments)},e0=t,e0}var t0,FS;function Iz(){return FS||(FS=1,t0=function(e,t){var n=t.length;if(n!==0){var i=e.length;e.length+=n;for(var s=0;ss?1:0},e=function(i,s){return is?-1:0};function t(i){return function(s,o){return i(o,s)}}function n(i){return i===2?function(s,o){return s[0]o[0]?1:s[1]o[1]?1:0}:function(s,o){for(var a=0;ao[a])return 1;a++}return 0}}return wl.DEFAULT_COMPARATOR=r,wl.DEFAULT_REVERSE_COMPARATOR=e,wl.reverseComparator=t,wl.createTupleComparator=n,wl}var Sl={},GS;function Nz(){if(GS)return Sl;GS=1;var r=Xy(),e=VT();function t(o){return Array.isArray(o)||e.isTypedArray(o)}function n(o){if(typeof o.length=="number")return o.length;if(typeof o.size=="number")return o.size}function i(o){var a=n(o),l=typeof a=="number"?new Array(a):[],c=0;return r(o,function(u){l[c++]=u}),l}function s(o){var a=n(o),l=typeof a=="number"?e.getPointerArray(a):Array,c=typeof a=="number"?new Array(a):[],u=typeof a=="number"?new l(a):[],h=0;return r(o,function(p){c[h]=p,u[h]=h++}),[c,u]}return Sl.isArrayLike=t,Sl.guessLength=n,Sl.toArray=i,Sl.toArrayWithIndices=s,Sl}var i0,HS;function tA(){if(HS)return i0;HS=1;var r=Xy(),e=Oz(),t=Nz(),n=e.DEFAULT_COMPARATOR,i=e.reverseComparator;function s(g,x,w,E){for(var b=x[E],M,A;E>w;){if(M=E-1>>1,A=x[M],g(b,A)<0){x[E]=A,E=M;continue}break}x[E]=b}function o(g,x,w){for(var E=x.length,b=w,M=x[w],A=2*w+1,P;A=0&&(A=P),x[w]=x[A],w=A,A=2*w+1;x[w]=M,s(g,x,b,w)}function a(g,x,w){x.push(w),s(g,x,0,x.length-1)}function l(g,x){var w=x.pop();if(x.length!==0){var E=x[0];return x[0]=w,o(g,x,0),E}return w}function c(g,x,w){if(x.length===0)throw new Error("mnemonist/heap.replace: cannot pop an empty heap.");var E=x[0];return x[0]=w,o(g,x,0),E}function u(g,x,w){var E;return x.length!==0&&g(x[0],w)<0&&(E=x[0],x[0]=w,w=E,o(g,x,0)),w}function h(g,x){for(var w=x.length,E=w>>1,b=E;--b>=0;)o(g,x,b)}function p(g,x){for(var w=x.length,E=0,b=new Array(w);E=w.length)return w.slice().sort(g);for(C=w.slice(0,x),h(E,C),b=x,M=w.length;b0&&c(E,C,w[b]);return C.sort(g)}var L=t.guessLength(w);return L!==null&&L0&&c(E,C,F)),b++}),C.length>b&&(C.length=b),C.sort(g)}function v(g,x,w){arguments.length===2&&(w=x,x=g,g=n);var E=i(g),b,M,A,P=-1/0,C;if(x===1){if(t.isArrayLike(w)){for(b=0,M=w.length;b0)&&(P=A);return C=new w.constructor(1),C[0]=P,C}return r(w,function(F){(P===-1/0||g(F,P)>0)&&(P=F)}),[P]}if(t.isArrayLike(w)){if(x>=w.length)return w.slice().sort(E);for(C=w.slice(0,x),h(g,C),b=x,M=w.length;b0&&c(g,C,w[b]);return C.sort(E)}var L=t.guessLength(w);return L!==null&&L0&&c(g,C,F)),b++}),C.length>b&&(C.length=b),C.sort(E)}function _(g){if(this.clear(),this.comparator=g||n,typeof this.comparator!="function")throw new Error("mnemonist/Heap.constructor: given comparator should be a function.")}_.prototype.clear=function(){this.items=[],this.size=0},_.prototype.push=function(g){return a(this.comparator,this.items,g),++this.size},_.prototype.peek=function(){return this.items[0]},_.prototype.pop=function(){return this.size!==0&&this.size--,l(this.comparator,this.items)},_.prototype.replace=function(g){return c(this.comparator,this.items,g)},_.prototype.pushpop=function(g){return u(this.comparator,this.items,g)},_.prototype.consume=function(){return this.size=0,p(this.comparator,this.items)},_.prototype.toArray=function(){return p(this.comparator,this.items.slice())},_.prototype.inspect=function(){var g=this.toArray();return Object.defineProperty(g,"constructor",{value:_,enumerable:!1}),g},typeof Symbol<"u"&&(_.prototype[Symbol.for("nodejs.util.inspect.custom")]=_.prototype.inspect);function y(g){if(this.clear(),this.comparator=g||n,typeof this.comparator!="function")throw new Error("mnemonist/MaxHeap.constructor: given comparator should be a function.");this.comparator=i(this.comparator)}return y.prototype=_.prototype,_.from=function(g,x){var w=new _(x),E;return t.isArrayLike(g)?E=g.slice():E=t.toArray(g),h(w.comparator,E),w.items=E,w.size=E.length,w},y.from=function(g,x){var w=new y(x),E;return t.isArrayLike(g)?E=g.slice():E=t.toArray(g),h(w.comparator,E),w.items=E,w.size=E.length,w},_.siftUp=o,_.siftDown=s,_.push=a,_.pop=l,_.replace=c,_.pushpop=u,_.heapify=h,_.consume=p,_.nsmallest=m,_.nlargest=v,_.MinHeap=_,_.MaxHeap=y,i0=_,i0}var VS;function Fz(){if(VS)return jc;VS=1;var r=Xs(),e=Tp().createEdgeWeightGetter,t=tA(),n="weight";function i(h,p){return h[0]>p[0]?1:h[0]p[1]?1:h[1]p[2]?1:h[2]p[0]?1:h[0]p[1]?1:h[1]p[2]?1:h[2]p[3]?1:h[3]L)&&(E=L,w=y[0][N].concat(y[1][N].slice(0,-1).reverse()))))}}return[1/0,null]}function a(h,p,m,v,_,y){if(!r(h))throw new Error("graphology-shortest-path/dijkstra: invalid graphology instance.");m=e(m||n).fromMinimalEntry;var g={},x={},w=new t(i),E=0,b,M,A,P,C,L,F,N,I,X,q;for(N=0,X=p.length;Na[0]?1:o[0]a[1]?1:o[1]h.cutoff||(v[F]=[L,P],m.push([L+P,p++,F,L,g]))}}for(;m.size!==0;){if(y=m.pop(),g=y[2],w=y[3],E=y[4],g===l){for(b=[g],M=E;M!==null;)b.push(M),M=_[M];return b.reverse(),b}_.hasOwnProperty(g)&&(_[g]===null||(A=v[g][0],A0&&(L=M[0]),L instanceof Error)throw L;var F=new Error("Unhandled error."+(L?" ("+L.message+")":""));throw F.context=L,F}var N=C[b];if(N===void 0)return!1;if(typeof N=="function")e(N,this,M);else for(var I=N.length,X=v(N,I),A=0;A0&&L.length>P&&!L.warned){L.warned=!0;var F=new Error("Possible EventEmitter memory leak detected. "+L.length+" "+String(b)+" listeners added. Use emitter.setMaxListeners() to increase limit");F.name="MaxListenersExceededWarning",F.emitter=E,F.type=b,F.count=L.length,n(F)}return E}s.prototype.addListener=function(b,M){return c(this,b,M,!1)},s.prototype.on=s.prototype.addListener,s.prototype.prependListener=function(b,M){return c(this,b,M,!0)};function u(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function h(E,b,M){var A={fired:!1,wrapFn:void 0,target:E,type:b,listener:M},P=u.bind(A);return P.listener=M,A.wrapFn=P,P}s.prototype.once=function(b,M){return a(M),this.on(b,h(this,b,M)),this},s.prototype.prependOnceListener=function(b,M){return a(M),this.prependListener(b,h(this,b,M)),this},s.prototype.removeListener=function(b,M){var A,P,C,L,F;if(a(M),P=this._events,P===void 0)return this;if(A=P[b],A===void 0)return this;if(A===M||A.listener===M)--this._eventsCount===0?this._events=Object.create(null):(delete P[b],P.removeListener&&this.emit("removeListener",b,A.listener||M));else if(typeof A!="function"){for(C=-1,L=A.length-1;L>=0;L--)if(A[L]===M||A[L].listener===M){F=A[L].listener,C=L;break}if(C<0)return this;C===0?A.shift():_(A,C),A.length===1&&(P[b]=A[0]),P.removeListener!==void 0&&this.emit("removeListener",b,F||M)}return this},s.prototype.off=s.prototype.removeListener,s.prototype.removeAllListeners=function(b){var M,A,P;if(A=this._events,A===void 0)return this;if(A.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):A[b]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete A[b]),this;if(arguments.length===0){var C=Object.keys(A),L;for(P=0;P=0;P--)this.removeListener(b,M[P]);return this};function p(E,b,M){var A=E._events;if(A===void 0)return[];var P=A[b];return P===void 0?[]:typeof P=="function"?M?[P.listener||P]:[P]:M?y(P):v(P,P.length)}s.prototype.listeners=function(b){return p(this,b,!0)},s.prototype.rawListeners=function(b){return p(this,b,!1)},s.listenerCount=function(E,b){return typeof E.listenerCount=="function"?E.listenerCount(b):m.call(E,b)},s.prototype.listenerCount=m;function m(E){var b=this._events;if(b!==void 0){var M=b[E];if(typeof M=="function")return 1;if(M!==void 0)return M.length}return 0}s.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]};function v(E,b){for(var M=new Array(b),A=0;A1?n:1/0,s=i!==1/0?new Array(i):[],o,a=0,l=r(t);;){if(a===i)return s;if(o=l.next(),o.done)return a!==n&&(s.length=a),s;s[a++]=o.value}},o0}var Wz=Vz();const iA=Hr(Wz);var a0,ZS;function Xz(){if(ZS)return a0;ZS=1;var r=Cp(),e=nA();return a0=function(){var n=arguments,i=null,s=-1;return new r(function(){var a=null;do{if(i===null){if(s++,s>=n.length)return{done:!0};i=e(n[s])}if(a=i.next(),a.done===!0){i=null;continue}break}while(!0);return a})},a0}var jz=Xz();const zs=Hr(jz);function Yz(){const r=arguments[0];for(let e=1,t=arguments.length;er++}class jy extends Error{constructor(e){super(),this.name="GraphError",this.message=e}}class tt extends jy{constructor(e){super(e),this.name="InvalidArgumentsGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,tt.prototype.constructor)}}class je extends jy{constructor(e){super(e),this.name="NotFoundGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,je.prototype.constructor)}}class ft extends jy{constructor(e){super(e),this.name="UsageGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,ft.prototype.constructor)}}function sA(r,e){this.key=r,this.attributes=e,this.clear()}sA.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.undirectedDegree=0,this.undirectedLoops=0,this.directedLoops=0,this.in={},this.out={},this.undirected={}};function oA(r,e){this.key=r,this.attributes=e,this.clear()}oA.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.directedLoops=0,this.in={},this.out={}};function aA(r,e){this.key=r,this.attributes=e,this.clear()}aA.prototype.clear=function(){this.undirectedDegree=0,this.undirectedLoops=0,this.undirected={}};function nc(r,e,t,n,i){this.key=e,this.attributes=i,this.undirected=r,this.source=t,this.target=n}nc.prototype.attach=function(){let r="out",e="in";this.undirected&&(r=e="undirected");const t=this.source.key,n=this.target.key;this.source[r][n]=this,!(this.undirected&&t===n)&&(this.target[e][t]=this)};nc.prototype.attachMulti=function(){let r="out",e="in";const t=this.source.key,n=this.target.key;this.undirected&&(r=e="undirected");const i=this.source[r],s=i[n];if(typeof s>"u"){i[n]=this,this.undirected&&t===n||(this.target[e][t]=this);return}s.previous=this,this.next=s,i[n]=this,this.target[e][t]=this};nc.prototype.detach=function(){const r=this.source.key,e=this.target.key;let t="out",n="in";this.undirected&&(t=n="undirected"),delete this.source[t][e],delete this.target[n][r]};nc.prototype.detachMulti=function(){const r=this.source.key,e=this.target.key;let t="out",n="in";this.undirected&&(t=n="undirected"),this.previous===void 0?this.next===void 0?(delete this.source[t][e],delete this.target[n][r]):(this.next.previous=void 0,this.source[t][e]=this.next,this.target[n][r]=this.next):(this.previous.next=this.next,this.next!==void 0&&(this.next.previous=this.previous))};const lA=0,cA=1,Zz=2,uA=3;function js(r,e,t,n,i,s,o){let a,l,c,u;if(n=""+n,t===lA){if(a=r._nodes.get(n),!a)throw new je(`Graph.${e}: could not find the "${n}" node in the graph.`);c=i,u=s}else if(t===uA){if(i=""+i,l=r._edges.get(i),!l)throw new je(`Graph.${e}: could not find the "${i}" edge in the graph.`);const h=l.source.key,p=l.target.key;if(n===h)a=l.target;else if(n===p)a=l.source;else throw new je(`Graph.${e}: the "${n}" node is not attached to the "${i}" edge (${h}, ${p}).`);c=s,u=o}else{if(l=r._edges.get(n),!l)throw new je(`Graph.${e}: could not find the "${n}" edge in the graph.`);t===cA?a=l.source:a=l.target,c=i,u=s}return[a,c,u]}function Kz(r,e,t){r.prototype[e]=function(n,i,s){const[o,a]=js(this,e,t,n,i,s);return o.attributes[a]}}function $z(r,e,t){r.prototype[e]=function(n,i){const[s]=js(this,e,t,n,i);return s.attributes}}function Jz(r,e,t){r.prototype[e]=function(n,i,s){const[o,a]=js(this,e,t,n,i,s);return o.attributes.hasOwnProperty(a)}}function Qz(r,e,t){r.prototype[e]=function(n,i,s,o){const[a,l,c]=js(this,e,t,n,i,s,o);return a.attributes[l]=c,this.emit("nodeAttributesUpdated",{key:a.key,type:"set",attributes:a.attributes,name:l}),this}}function eB(r,e,t){r.prototype[e]=function(n,i,s,o){const[a,l,c]=js(this,e,t,n,i,s,o);if(typeof c!="function")throw new tt(`Graph.${e}: updater should be a function.`);const u=a.attributes,h=c(u[l]);return u[l]=h,this.emit("nodeAttributesUpdated",{key:a.key,type:"set",attributes:a.attributes,name:l}),this}}function tB(r,e,t){r.prototype[e]=function(n,i,s){const[o,a]=js(this,e,t,n,i,s);return delete o.attributes[a],this.emit("nodeAttributesUpdated",{key:o.key,type:"remove",attributes:o.attributes,name:a}),this}}function nB(r,e,t){r.prototype[e]=function(n,i,s){const[o,a]=js(this,e,t,n,i,s);if(!ri(a))throw new tt(`Graph.${e}: provided attributes are not a plain object.`);return o.attributes=a,this.emit("nodeAttributesUpdated",{key:o.key,type:"replace",attributes:o.attributes}),this}}function iB(r,e,t){r.prototype[e]=function(n,i,s){const[o,a]=js(this,e,t,n,i,s);if(!ri(a))throw new tt(`Graph.${e}: provided attributes are not a plain object.`);return Vn(o.attributes,a),this.emit("nodeAttributesUpdated",{key:o.key,type:"merge",attributes:o.attributes,data:a}),this}}function rB(r,e,t){r.prototype[e]=function(n,i,s){const[o,a]=js(this,e,t,n,i,s);if(typeof a!="function")throw new tt(`Graph.${e}: provided updater is not a function.`);return o.attributes=a(o.attributes),this.emit("nodeAttributesUpdated",{key:o.key,type:"update",attributes:o.attributes}),this}}const sB=[{name:r=>`get${r}Attribute`,attacher:Kz},{name:r=>`get${r}Attributes`,attacher:$z},{name:r=>`has${r}Attribute`,attacher:Jz},{name:r=>`set${r}Attribute`,attacher:Qz},{name:r=>`update${r}Attribute`,attacher:eB},{name:r=>`remove${r}Attribute`,attacher:tB},{name:r=>`replace${r}Attributes`,attacher:nB},{name:r=>`merge${r}Attributes`,attacher:iB},{name:r=>`update${r}Attributes`,attacher:rB}];function oB(r){sB.forEach(function({name:e,attacher:t}){t(r,e("Node"),lA),t(r,e("Source"),cA),t(r,e("Target"),Zz),t(r,e("Opposite"),uA)})}function aB(r,e,t){r.prototype[e]=function(n,i){let s;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new ft(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new ft(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const o=""+n,a=""+i;if(i=arguments[2],s=br(this,o,a,t),!s)throw new je(`Graph.${e}: could not find an edge for the given path ("${o}" - "${a}").`)}else{if(t!=="mixed")throw new ft(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(n=""+n,s=this._edges.get(n),!s)throw new je(`Graph.${e}: could not find the "${n}" edge in the graph.`)}return s.attributes[i]}}function lB(r,e,t){r.prototype[e]=function(n){let i;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new ft(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>1){if(this.multi)throw new ft(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const s=""+n,o=""+arguments[1];if(i=br(this,s,o,t),!i)throw new je(`Graph.${e}: could not find an edge for the given path ("${s}" - "${o}").`)}else{if(t!=="mixed")throw new ft(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(n=""+n,i=this._edges.get(n),!i)throw new je(`Graph.${e}: could not find the "${n}" edge in the graph.`)}return i.attributes}}function cB(r,e,t){r.prototype[e]=function(n,i){let s;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new ft(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new ft(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const o=""+n,a=""+i;if(i=arguments[2],s=br(this,o,a,t),!s)throw new je(`Graph.${e}: could not find an edge for the given path ("${o}" - "${a}").`)}else{if(t!=="mixed")throw new ft(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(n=""+n,s=this._edges.get(n),!s)throw new je(`Graph.${e}: could not find the "${n}" edge in the graph.`)}return s.attributes.hasOwnProperty(i)}}function uB(r,e,t){r.prototype[e]=function(n,i,s){let o;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new ft(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new ft(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const a=""+n,l=""+i;if(i=arguments[2],s=arguments[3],o=br(this,a,l,t),!o)throw new je(`Graph.${e}: could not find an edge for the given path ("${a}" - "${l}").`)}else{if(t!=="mixed")throw new ft(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(n=""+n,o=this._edges.get(n),!o)throw new je(`Graph.${e}: could not find the "${n}" edge in the graph.`)}return o.attributes[i]=s,this.emit("edgeAttributesUpdated",{key:o.key,type:"set",attributes:o.attributes,name:i}),this}}function hB(r,e,t){r.prototype[e]=function(n,i,s){let o;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new ft(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new ft(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const a=""+n,l=""+i;if(i=arguments[2],s=arguments[3],o=br(this,a,l,t),!o)throw new je(`Graph.${e}: could not find an edge for the given path ("${a}" - "${l}").`)}else{if(t!=="mixed")throw new ft(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(n=""+n,o=this._edges.get(n),!o)throw new je(`Graph.${e}: could not find the "${n}" edge in the graph.`)}if(typeof s!="function")throw new tt(`Graph.${e}: updater should be a function.`);return o.attributes[i]=s(o.attributes[i]),this.emit("edgeAttributesUpdated",{key:o.key,type:"set",attributes:o.attributes,name:i}),this}}function fB(r,e,t){r.prototype[e]=function(n,i){let s;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new ft(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new ft(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const o=""+n,a=""+i;if(i=arguments[2],s=br(this,o,a,t),!s)throw new je(`Graph.${e}: could not find an edge for the given path ("${o}" - "${a}").`)}else{if(t!=="mixed")throw new ft(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(n=""+n,s=this._edges.get(n),!s)throw new je(`Graph.${e}: could not find the "${n}" edge in the graph.`)}return delete s.attributes[i],this.emit("edgeAttributesUpdated",{key:s.key,type:"remove",attributes:s.attributes,name:i}),this}}function dB(r,e,t){r.prototype[e]=function(n,i){let s;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new ft(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new ft(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const o=""+n,a=""+i;if(i=arguments[2],s=br(this,o,a,t),!s)throw new je(`Graph.${e}: could not find an edge for the given path ("${o}" - "${a}").`)}else{if(t!=="mixed")throw new ft(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(n=""+n,s=this._edges.get(n),!s)throw new je(`Graph.${e}: could not find the "${n}" edge in the graph.`)}if(!ri(i))throw new tt(`Graph.${e}: provided attributes are not a plain object.`);return s.attributes=i,this.emit("edgeAttributesUpdated",{key:s.key,type:"replace",attributes:s.attributes}),this}}function pB(r,e,t){r.prototype[e]=function(n,i){let s;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new ft(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new ft(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const o=""+n,a=""+i;if(i=arguments[2],s=br(this,o,a,t),!s)throw new je(`Graph.${e}: could not find an edge for the given path ("${o}" - "${a}").`)}else{if(t!=="mixed")throw new ft(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(n=""+n,s=this._edges.get(n),!s)throw new je(`Graph.${e}: could not find the "${n}" edge in the graph.`)}if(!ri(i))throw new tt(`Graph.${e}: provided attributes are not a plain object.`);return Vn(s.attributes,i),this.emit("edgeAttributesUpdated",{key:s.key,type:"merge",attributes:s.attributes,data:i}),this}}function mB(r,e,t){r.prototype[e]=function(n,i){let s;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new ft(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new ft(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const o=""+n,a=""+i;if(i=arguments[2],s=br(this,o,a,t),!s)throw new je(`Graph.${e}: could not find an edge for the given path ("${o}" - "${a}").`)}else{if(t!=="mixed")throw new ft(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(n=""+n,s=this._edges.get(n),!s)throw new je(`Graph.${e}: could not find the "${n}" edge in the graph.`)}if(typeof i!="function")throw new tt(`Graph.${e}: provided updater is not a function.`);return s.attributes=i(s.attributes),this.emit("edgeAttributesUpdated",{key:s.key,type:"update",attributes:s.attributes}),this}}const gB=[{name:r=>`get${r}Attribute`,attacher:aB},{name:r=>`get${r}Attributes`,attacher:lB},{name:r=>`has${r}Attribute`,attacher:cB},{name:r=>`set${r}Attribute`,attacher:uB},{name:r=>`update${r}Attribute`,attacher:hB},{name:r=>`remove${r}Attribute`,attacher:fB},{name:r=>`replace${r}Attributes`,attacher:dB},{name:r=>`merge${r}Attributes`,attacher:pB},{name:r=>`update${r}Attributes`,attacher:mB}];function vB(r){gB.forEach(function({name:e,attacher:t}){t(r,e("Edge"),"mixed"),t(r,e("DirectedEdge"),"directed"),t(r,e("UndirectedEdge"),"undirected")})}const yB=[{name:"edges",type:"mixed"},{name:"inEdges",type:"directed",direction:"in"},{name:"outEdges",type:"directed",direction:"out"},{name:"inboundEdges",type:"mixed",direction:"in"},{name:"outboundEdges",type:"mixed",direction:"out"},{name:"directedEdges",type:"directed"},{name:"undirectedEdges",type:"undirected"}];function _B(r,e,t,n){let i=!1;for(const s in e){if(s===n)continue;const o=e[s];if(i=t(o.key,o.attributes,o.source.key,o.target.key,o.source.attributes,o.target.attributes,o.undirected),r&&i)return o.key}}function xB(r,e,t,n){let i,s,o,a=!1;for(const l in e)if(l!==n){i=e[l];do{if(s=i.source,o=i.target,a=t(i.key,i.attributes,s.key,o.key,s.attributes,o.attributes,i.undirected),r&&a)return i.key;i=i.next}while(i!==void 0)}}function l0(r,e){const t=Object.keys(r),n=t.length;let i,s=0;return new Mr(function(){do if(i)i=i.next;else{if(s>=n)return{done:!0};const a=t[s++];if(a===e){i=void 0;continue}i=r[a]}while(!i);return{done:!1,value:{edge:i.key,attributes:i.attributes,source:i.source.key,target:i.target.key,sourceAttributes:i.source.attributes,targetAttributes:i.target.attributes,undirected:i.undirected}}})}function wB(r,e,t,n){const i=e[t];if(!i)return;const s=i.source,o=i.target;if(n(i.key,i.attributes,s.key,o.key,s.attributes,o.attributes,i.undirected)&&r)return i.key}function SB(r,e,t,n){let i=e[t];if(!i)return;let s=!1;do{if(s=n(i.key,i.attributes,i.source.key,i.target.key,i.source.attributes,i.target.attributes,i.undirected),r&&s)return i.key;i=i.next}while(i!==void 0)}function c0(r,e){let t=r[e];return t.next!==void 0?new Mr(function(){if(!t)return{done:!0};const n={edge:t.key,attributes:t.attributes,source:t.source.key,target:t.target.key,sourceAttributes:t.source.attributes,targetAttributes:t.target.attributes,undirected:t.undirected};return t=t.next,{done:!1,value:n}}):Mr.of({edge:t.key,attributes:t.attributes,source:t.source.key,target:t.target.key,sourceAttributes:t.source.attributes,targetAttributes:t.target.attributes,undirected:t.undirected})}function EB(r,e){if(r.size===0)return[];if(e==="mixed"||e===r.type)return typeof Array.from=="function"?Array.from(r._edges.keys()):iA(r._edges.keys(),r._edges.size);const t=e==="undirected"?r.undirectedSize:r.directedSize,n=new Array(t),i=e==="undirected",s=r._edges.values();let o=0,a,l;for(;a=s.next(),a.done!==!0;)l=a.value,l.undirected===i&&(n[o++]=l.key);return n}function hA(r,e,t,n){if(e.size===0)return;const i=t!=="mixed"&&t!==e.type,s=t==="undirected";let o,a,l=!1;const c=e._edges.values();for(;o=c.next(),o.done!==!0;){if(a=o.value,i&&a.undirected!==s)continue;const{key:u,attributes:h,source:p,target:m}=a;if(l=n(u,h,p.key,m.key,p.attributes,m.attributes,a.undirected),r&&l)return u}}function bB(r,e){if(r.size===0)return Mr.empty();const t=e!=="mixed"&&e!==r.type,n=e==="undirected",i=r._edges.values();return new Mr(function(){let o,a;for(;;){if(o=i.next(),o.done)return o;if(a=o.value,!(t&&a.undirected!==n))break}return{value:{edge:a.key,attributes:a.attributes,source:a.source.key,target:a.target.key,sourceAttributes:a.source.attributes,targetAttributes:a.target.attributes,undirected:a.undirected},done:!1}})}function Yy(r,e,t,n,i,s){const o=e?xB:_B;let a;if(t!=="undirected"&&(n!=="out"&&(a=o(r,i.in,s),r&&a)||n!=="in"&&(a=o(r,i.out,s,n?void 0:i.key),r&&a))||t!=="directed"&&(a=o(r,i.undirected,s),r&&a))return a}function MB(r,e,t,n){const i=[];return Yy(!1,r,e,t,n,function(s){i.push(s)}),i}function TB(r,e,t){let n=Mr.empty();return r!=="undirected"&&(e!=="out"&&typeof t.in<"u"&&(n=zs(n,l0(t.in))),e!=="in"&&typeof t.out<"u"&&(n=zs(n,l0(t.out,e?void 0:t.key)))),r!=="directed"&&typeof t.undirected<"u"&&(n=zs(n,l0(t.undirected))),n}function qy(r,e,t,n,i,s,o){const a=t?SB:wB;let l;if(e!=="undirected"&&(typeof i.in<"u"&&n!=="out"&&(l=a(r,i.in,s,o),r&&l)||typeof i.out<"u"&&n!=="in"&&(n||i.key!==s)&&(l=a(r,i.out,s,o),r&&l))||e!=="directed"&&typeof i.undirected<"u"&&(l=a(r,i.undirected,s,o),r&&l))return l}function AB(r,e,t,n,i){const s=[];return qy(!1,r,e,t,n,i,function(o){s.push(o)}),s}function CB(r,e,t,n){let i=Mr.empty();return r!=="undirected"&&(typeof t.in<"u"&&e!=="out"&&n in t.in&&(i=zs(i,c0(t.in,n))),typeof t.out<"u"&&e!=="in"&&n in t.out&&(e||t.key!==n)&&(i=zs(i,c0(t.out,n)))),r!=="directed"&&typeof t.undirected<"u"&&n in t.undirected&&(i=zs(i,c0(t.undirected,n))),i}function RB(r,e){const{name:t,type:n,direction:i}=e;r.prototype[t]=function(s,o){if(n!=="mixed"&&this.type!=="mixed"&&n!==this.type)return[];if(!arguments.length)return EB(this,n);if(arguments.length===1){s=""+s;const a=this._nodes.get(s);if(typeof a>"u")throw new je(`Graph.${t}: could not find the "${s}" node in the graph.`);return MB(this.multi,n==="mixed"?this.type:n,i,a)}if(arguments.length===2){s=""+s,o=""+o;const a=this._nodes.get(s);if(!a)throw new je(`Graph.${t}: could not find the "${s}" source node in the graph.`);if(!this._nodes.has(o))throw new je(`Graph.${t}: could not find the "${o}" target node in the graph.`);return AB(n,this.multi,i,a,o)}throw new tt(`Graph.${t}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function PB(r,e){const{name:t,type:n,direction:i}=e,s="forEach"+t[0].toUpperCase()+t.slice(1,-1);r.prototype[s]=function(c,u,h){if(!(n!=="mixed"&&this.type!=="mixed"&&n!==this.type)){if(arguments.length===1)return h=c,hA(!1,this,n,h);if(arguments.length===2){c=""+c,h=u;const p=this._nodes.get(c);if(typeof p>"u")throw new je(`Graph.${s}: could not find the "${c}" node in the graph.`);return Yy(!1,this.multi,n==="mixed"?this.type:n,i,p,h)}if(arguments.length===3){c=""+c,u=""+u;const p=this._nodes.get(c);if(!p)throw new je(`Graph.${s}: could not find the "${c}" source node in the graph.`);if(!this._nodes.has(u))throw new je(`Graph.${s}: could not find the "${u}" target node in the graph.`);return qy(!1,n,this.multi,i,p,u,h)}throw new tt(`Graph.${s}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)}};const o="map"+t[0].toUpperCase()+t.slice(1);r.prototype[o]=function(){const c=Array.prototype.slice.call(arguments),u=c.pop();let h;if(c.length===0){let p=0;n!=="directed"&&(p+=this.undirectedSize),n!=="undirected"&&(p+=this.directedSize),h=new Array(p);let m=0;c.push((v,_,y,g,x,w,E)=>{h[m++]=u(v,_,y,g,x,w,E)})}else h=[],c.push((p,m,v,_,y,g,x)=>{h.push(u(p,m,v,_,y,g,x))});return this[s].apply(this,c),h};const a="filter"+t[0].toUpperCase()+t.slice(1);r.prototype[a]=function(){const c=Array.prototype.slice.call(arguments),u=c.pop(),h=[];return c.push((p,m,v,_,y,g,x)=>{u(p,m,v,_,y,g,x)&&h.push(p)}),this[s].apply(this,c),h};const l="reduce"+t[0].toUpperCase()+t.slice(1);r.prototype[l]=function(){let c=Array.prototype.slice.call(arguments);if(c.length<2||c.length>4)throw new tt(`Graph.${l}: invalid number of arguments (expecting 2, 3 or 4 and got ${c.length}).`);if(typeof c[c.length-1]=="function"&&typeof c[c.length-2]!="function")throw new tt(`Graph.${l}: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.`);let u,h;c.length===2?(u=c[0],h=c[1],c=[]):c.length===3?(u=c[1],h=c[2],c=[c[0]]):c.length===4&&(u=c[2],h=c[3],c=[c[0],c[1]]);let p=h;return c.push((m,v,_,y,g,x,w)=>{p=u(p,m,v,_,y,g,x,w)}),this[s].apply(this,c),p}}function LB(r,e){const{name:t,type:n,direction:i}=e,s="find"+t[0].toUpperCase()+t.slice(1,-1);r.prototype[s]=function(l,c,u){if(n!=="mixed"&&this.type!=="mixed"&&n!==this.type)return!1;if(arguments.length===1)return u=l,hA(!0,this,n,u);if(arguments.length===2){l=""+l,u=c;const h=this._nodes.get(l);if(typeof h>"u")throw new je(`Graph.${s}: could not find the "${l}" node in the graph.`);return Yy(!0,this.multi,n==="mixed"?this.type:n,i,h,u)}if(arguments.length===3){l=""+l,c=""+c;const h=this._nodes.get(l);if(!h)throw new je(`Graph.${s}: could not find the "${l}" source node in the graph.`);if(!this._nodes.has(c))throw new je(`Graph.${s}: could not find the "${c}" target node in the graph.`);return qy(!0,n,this.multi,i,h,c,u)}throw new tt(`Graph.${s}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)};const o="some"+t[0].toUpperCase()+t.slice(1,-1);r.prototype[o]=function(){const l=Array.prototype.slice.call(arguments),c=l.pop();return l.push((h,p,m,v,_,y,g)=>c(h,p,m,v,_,y,g)),!!this[s].apply(this,l)};const a="every"+t[0].toUpperCase()+t.slice(1,-1);r.prototype[a]=function(){const l=Array.prototype.slice.call(arguments),c=l.pop();return l.push((h,p,m,v,_,y,g)=>!c(h,p,m,v,_,y,g)),!this[s].apply(this,l)}}function IB(r,e){const{name:t,type:n,direction:i}=e,s=t.slice(0,-1)+"Entries";r.prototype[s]=function(o,a){if(n!=="mixed"&&this.type!=="mixed"&&n!==this.type)return Mr.empty();if(!arguments.length)return bB(this,n);if(arguments.length===1){o=""+o;const l=this._nodes.get(o);if(!l)throw new je(`Graph.${s}: could not find the "${o}" node in the graph.`);return TB(n,i,l)}if(arguments.length===2){o=""+o,a=""+a;const l=this._nodes.get(o);if(!l)throw new je(`Graph.${s}: could not find the "${o}" source node in the graph.`);if(!this._nodes.has(a))throw new je(`Graph.${s}: could not find the "${a}" target node in the graph.`);return CB(n,i,l,a)}throw new tt(`Graph.${s}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function DB(r){yB.forEach(e=>{RB(r,e),PB(r,e),LB(r,e),IB(r,e)})}const UB=[{name:"neighbors",type:"mixed"},{name:"inNeighbors",type:"directed",direction:"in"},{name:"outNeighbors",type:"directed",direction:"out"},{name:"inboundNeighbors",type:"mixed",direction:"in"},{name:"outboundNeighbors",type:"mixed",direction:"out"},{name:"directedNeighbors",type:"directed"},{name:"undirectedNeighbors",type:"undirected"}];function Rp(){this.A=null,this.B=null}Rp.prototype.wrap=function(r){this.A===null?this.A=r:this.B===null&&(this.B=r)};Rp.prototype.has=function(r){return this.A!==null&&r in this.A||this.B!==null&&r in this.B};function Yc(r,e,t,n,i){for(const s in n){const o=n[s],a=o.source,l=o.target,c=a===t?l:a;if(e&&e.has(c.key))continue;const u=i(c.key,c.attributes);if(r&&u)return c.key}}function Zy(r,e,t,n,i){if(e!=="mixed"){if(e==="undirected")return Yc(r,null,n,n.undirected,i);if(typeof t=="string")return Yc(r,null,n,n[t],i)}const s=new Rp;let o;if(e!=="undirected"){if(t!=="out"){if(o=Yc(r,null,n,n.in,i),r&&o)return o;s.wrap(n.in)}if(t!=="in"){if(o=Yc(r,s,n,n.out,i),r&&o)return o;s.wrap(n.out)}}if(e!=="directed"&&(o=Yc(r,s,n,n.undirected,i),r&&o))return o}function OB(r,e,t){if(r!=="mixed"){if(r==="undirected")return Object.keys(t.undirected);if(typeof e=="string")return Object.keys(t[e])}const n=[];return Zy(!1,r,e,t,function(i){n.push(i)}),n}function qc(r,e,t){const n=Object.keys(t),i=n.length;let s=0;return new Mr(function(){let a=null;do{if(s>=i)return r&&r.wrap(t),{done:!0};const l=t[n[s++]],c=l.source,u=l.target;if(a=c===e?u:c,r&&r.has(a.key)){a=null;continue}}while(a===null);return{done:!1,value:{neighbor:a.key,attributes:a.attributes}}})}function NB(r,e,t){if(r!=="mixed"){if(r==="undirected")return qc(null,t,t.undirected);if(typeof e=="string")return qc(null,t,t[e])}let n=Mr.empty();const i=new Rp;return r!=="undirected"&&(e!=="out"&&(n=zs(n,qc(i,t,t.in))),e!=="in"&&(n=zs(n,qc(i,t,t.out)))),r!=="directed"&&(n=zs(n,qc(i,t,t.undirected))),n}function FB(r,e){const{name:t,type:n,direction:i}=e;r.prototype[t]=function(s){if(n!=="mixed"&&this.type!=="mixed"&&n!==this.type)return[];s=""+s;const o=this._nodes.get(s);if(typeof o>"u")throw new je(`Graph.${t}: could not find the "${s}" node in the graph.`);return OB(n==="mixed"?this.type:n,i,o)}}function kB(r,e){const{name:t,type:n,direction:i}=e,s="forEach"+t[0].toUpperCase()+t.slice(1,-1);r.prototype[s]=function(c,u){if(n!=="mixed"&&this.type!=="mixed"&&n!==this.type)return;c=""+c;const h=this._nodes.get(c);if(typeof h>"u")throw new je(`Graph.${s}: could not find the "${c}" node in the graph.`);Zy(!1,n==="mixed"?this.type:n,i,h,u)};const o="map"+t[0].toUpperCase()+t.slice(1);r.prototype[o]=function(c,u){const h=[];return this[s](c,(p,m)=>{h.push(u(p,m))}),h};const a="filter"+t[0].toUpperCase()+t.slice(1);r.prototype[a]=function(c,u){const h=[];return this[s](c,(p,m)=>{u(p,m)&&h.push(p)}),h};const l="reduce"+t[0].toUpperCase()+t.slice(1);r.prototype[l]=function(c,u,h){if(arguments.length<3)throw new tt(`Graph.${l}: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.`);let p=h;return this[s](c,(m,v)=>{p=u(p,m,v)}),p}}function zB(r,e){const{name:t,type:n,direction:i}=e,s=t[0].toUpperCase()+t.slice(1,-1),o="find"+s;r.prototype[o]=function(c,u){if(n!=="mixed"&&this.type!=="mixed"&&n!==this.type)return;c=""+c;const h=this._nodes.get(c);if(typeof h>"u")throw new je(`Graph.${o}: could not find the "${c}" node in the graph.`);return Zy(!0,n==="mixed"?this.type:n,i,h,u)};const a="some"+s;r.prototype[a]=function(c,u){return!!this[o](c,u)};const l="every"+s;r.prototype[l]=function(c,u){return!this[o](c,(p,m)=>!u(p,m))}}function BB(r,e){const{name:t,type:n,direction:i}=e,s=t.slice(0,-1)+"Entries";r.prototype[s]=function(o){if(n!=="mixed"&&this.type!=="mixed"&&n!==this.type)return Mr.empty();o=""+o;const a=this._nodes.get(o);if(typeof a>"u")throw new je(`Graph.${s}: could not find the "${o}" node in the graph.`);return NB(n==="mixed"?this.type:n,i,a)}}function GB(r){UB.forEach(e=>{FB(r,e),kB(r,e),zB(r,e),BB(r,e)})}function rd(r,e,t,n,i){const s=n._nodes.values(),o=n.type;let a,l,c,u,h,p;for(;a=s.next(),a.done!==!0;){let m=!1;if(l=a.value,o!=="undirected"){u=l.out;for(c in u){h=u[c];do p=h.target,m=!0,i(l.key,p.key,l.attributes,p.attributes,h.key,h.attributes,h.undirected),h=h.next;while(h)}}if(o!=="directed"){u=l.undirected;for(c in u)if(!(e&&l.key>c)){h=u[c];do p=h.target,p.key!==c&&(p=h.source),m=!0,i(l.key,p.key,l.attributes,p.attributes,h.key,h.attributes,h.undirected),h=h.next;while(h)}}t&&!m&&i(l.key,null,l.attributes,null,null,null,null)}}function HB(r,e){const t={key:r};return rA(e.attributes)||(t.attributes=Vn({},e.attributes)),t}function VB(r,e,t){const n={key:e,source:t.source.key,target:t.target.key};return rA(t.attributes)||(n.attributes=Vn({},t.attributes)),r==="mixed"&&t.undirected&&(n.undirected=!0),n}function WB(r){if(!ri(r))throw new tt('Graph.import: invalid serialized node. A serialized node should be a plain object with at least a "key" property.');if(!("key"in r))throw new tt("Graph.import: serialized node is missing its key.");if("attributes"in r&&(!ri(r.attributes)||r.attributes===null))throw new tt("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.")}function XB(r){if(!ri(r))throw new tt('Graph.import: invalid serialized edge. A serialized edge should be a plain object with at least a "source" & "target" property.');if(!("source"in r))throw new tt("Graph.import: serialized edge is missing its source.");if(!("target"in r))throw new tt("Graph.import: serialized edge is missing its target.");if("attributes"in r&&(!ri(r.attributes)||r.attributes===null))throw new tt("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.");if("undirected"in r&&typeof r.undirected!="boolean")throw new tt("Graph.import: invalid undirectedness information. Undirected should be boolean or omitted.")}const jB=qz(),YB=new Set(["directed","undirected","mixed"]),$S=new Set(["domain","_events","_eventsCount","_maxListeners"]),qB=[{name:r=>`${r}Edge`,generateKey:!0},{name:r=>`${r}DirectedEdge`,generateKey:!0,type:"directed"},{name:r=>`${r}UndirectedEdge`,generateKey:!0,type:"undirected"},{name:r=>`${r}EdgeWithKey`},{name:r=>`${r}DirectedEdgeWithKey`,type:"directed"},{name:r=>`${r}UndirectedEdgeWithKey`,type:"undirected"}],ZB={allowSelfLoops:!0,multi:!1,type:"mixed"};function KB(r,e,t){if(t&&!ri(t))throw new tt(`Graph.addNode: invalid attributes. Expecting an object but got "${t}"`);if(e=""+e,t=t||{},r._nodes.has(e))throw new ft(`Graph.addNode: the "${e}" node already exist in the graph.`);const n=new r.NodeDataClass(e,t);return r._nodes.set(e,n),r.emit("nodeAdded",{key:e,attributes:t}),n}function JS(r,e,t){const n=new r.NodeDataClass(e,t);return r._nodes.set(e,n),r.emit("nodeAdded",{key:e,attributes:t}),n}function fA(r,e,t,n,i,s,o,a){if(!n&&r.type==="undirected")throw new ft(`Graph.${e}: you cannot add a directed edge to an undirected graph. Use the #.addEdge or #.addUndirectedEdge instead.`);if(n&&r.type==="directed")throw new ft(`Graph.${e}: you cannot add an undirected edge to a directed graph. Use the #.addEdge or #.addDirectedEdge instead.`);if(a&&!ri(a))throw new tt(`Graph.${e}: invalid attributes. Expecting an object but got "${a}"`);if(s=""+s,o=""+o,a=a||{},!r.allowSelfLoops&&s===o)throw new ft(`Graph.${e}: source & target are the same ("${s}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);const l=r._nodes.get(s),c=r._nodes.get(o);if(!l)throw new je(`Graph.${e}: source node "${s}" not found.`);if(!c)throw new je(`Graph.${e}: target node "${o}" not found.`);const u={key:null,undirected:n,source:s,target:o,attributes:a};if(t)i=r._edgeKeyGenerator();else if(i=""+i,r._edges.has(i))throw new ft(`Graph.${e}: the "${i}" edge already exists in the graph.`);if(!r.multi&&(n?typeof l.undirected[o]<"u":typeof l.out[o]<"u"))throw new ft(`Graph.${e}: an edge linking "${s}" to "${o}" already exists. If you really want to add multiple edges linking those nodes, you should create a multi graph by using the 'multi' option.`);const h=new nc(n,i,l,c,a);r._edges.set(i,h);const p=s===o;return n?(l.undirectedDegree++,c.undirectedDegree++,p&&(l.undirectedLoops++,r._undirectedSelfLoopCount++)):(l.outDegree++,c.inDegree++,p&&(l.directedLoops++,r._directedSelfLoopCount++)),r.multi?h.attachMulti():h.attach(),n?r._undirectedSize++:r._directedSize++,u.key=i,r.emit("edgeAdded",u),i}function $B(r,e,t,n,i,s,o,a,l){if(!n&&r.type==="undirected")throw new ft(`Graph.${e}: you cannot merge/update a directed edge to an undirected graph. Use the #.mergeEdge/#.updateEdge or #.addUndirectedEdge instead.`);if(n&&r.type==="directed")throw new ft(`Graph.${e}: you cannot merge/update an undirected edge to a directed graph. Use the #.mergeEdge/#.updateEdge or #.addDirectedEdge instead.`);if(a){if(l){if(typeof a!="function")throw new tt(`Graph.${e}: invalid updater function. Expecting a function but got "${a}"`)}else if(!ri(a))throw new tt(`Graph.${e}: invalid attributes. Expecting an object but got "${a}"`)}s=""+s,o=""+o;let c;if(l&&(c=a,a=void 0),!r.allowSelfLoops&&s===o)throw new ft(`Graph.${e}: source & target are the same ("${s}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);let u=r._nodes.get(s),h=r._nodes.get(o),p,m;if(!t&&(p=r._edges.get(i),p)){if((p.source.key!==s||p.target.key!==o)&&(!n||p.source.key!==o||p.target.key!==s))throw new ft(`Graph.${e}: inconsistency detected when attempting to merge the "${i}" edge with "${s}" source & "${o}" target vs. ("${p.source.key}", "${p.target.key}").`);m=p}if(!m&&!r.multi&&u&&(m=n?u.undirected[o]:u.out[o]),m){const x=[m.key,!1,!1,!1];if(l?!c:!a)return x;if(l){const w=m.attributes;m.attributes=c(w),r.emit("edgeAttributesUpdated",{type:"replace",key:m.key,attributes:m.attributes})}else Vn(m.attributes,a),r.emit("edgeAttributesUpdated",{type:"merge",key:m.key,attributes:m.attributes,data:a});return x}a=a||{},l&&c&&(a=c(a));const v={key:null,undirected:n,source:s,target:o,attributes:a};if(t)i=r._edgeKeyGenerator();else if(i=""+i,r._edges.has(i))throw new ft(`Graph.${e}: the "${i}" edge already exists in the graph.`);let _=!1,y=!1;u||(u=JS(r,s,{}),_=!0,s===o&&(h=u,y=!0)),h||(h=JS(r,o,{}),y=!0),p=new nc(n,i,u,h,a),r._edges.set(i,p);const g=s===o;return n?(u.undirectedDegree++,h.undirectedDegree++,g&&(u.undirectedLoops++,r._undirectedSelfLoopCount++)):(u.outDegree++,h.inDegree++,g&&(u.directedLoops++,r._directedSelfLoopCount++)),r.multi?p.attachMulti():p.attach(),n?r._undirectedSize++:r._directedSize++,v.key=i,r.emit("edgeAdded",v),[i,!0,_,y]}function El(r,e){r._edges.delete(e.key);const{source:t,target:n,attributes:i}=e,s=e.undirected,o=t===n;s?(t.undirectedDegree--,n.undirectedDegree--,o&&(t.undirectedLoops--,r._undirectedSelfLoopCount--)):(t.outDegree--,n.inDegree--,o&&(t.directedLoops--,r._directedSelfLoopCount--)),r.multi?e.detachMulti():e.detach(),s?r._undirectedSize--:r._directedSize--,r.emit("edgeDropped",{key:e.key,attributes:i,source:t.key,target:n.key,undirected:s})}class en extends Gz.EventEmitter{constructor(e){if(super(),e=Vn({},ZB,e),typeof e.multi!="boolean")throw new tt(`Graph.constructor: invalid 'multi' option. Expecting a boolean but got "${e.multi}".`);if(!YB.has(e.type))throw new tt(`Graph.constructor: invalid 'type' option. Should be one of "mixed", "directed" or "undirected" but got "${e.type}".`);if(typeof e.allowSelfLoops!="boolean")throw new tt(`Graph.constructor: invalid 'allowSelfLoops' option. Expecting a boolean but got "${e.allowSelfLoops}".`);const t=e.type==="mixed"?sA:e.type==="directed"?oA:aA;mr(this,"NodeDataClass",t);const n="geid_"+jB()+"_";let i=0;const s=()=>{let o;do o=n+i++;while(this._edges.has(o));return o};mr(this,"_attributes",{}),mr(this,"_nodes",new Map),mr(this,"_edges",new Map),mr(this,"_directedSize",0),mr(this,"_undirectedSize",0),mr(this,"_directedSelfLoopCount",0),mr(this,"_undirectedSelfLoopCount",0),mr(this,"_edgeKeyGenerator",s),mr(this,"_options",e),$S.forEach(o=>mr(this,o,this[o])),Ir(this,"order",()=>this._nodes.size),Ir(this,"size",()=>this._edges.size),Ir(this,"directedSize",()=>this._directedSize),Ir(this,"undirectedSize",()=>this._undirectedSize),Ir(this,"selfLoopCount",()=>this._directedSelfLoopCount+this._undirectedSelfLoopCount),Ir(this,"directedSelfLoopCount",()=>this._directedSelfLoopCount),Ir(this,"undirectedSelfLoopCount",()=>this._undirectedSelfLoopCount),Ir(this,"multi",this._options.multi),Ir(this,"type",this._options.type),Ir(this,"allowSelfLoops",this._options.allowSelfLoops),Ir(this,"implementation",()=>"graphology")}_resetInstanceCounters(){this._directedSize=0,this._undirectedSize=0,this._directedSelfLoopCount=0,this._undirectedSelfLoopCount=0}hasNode(e){return this._nodes.has(""+e)}hasDirectedEdge(e,t){if(this.type==="undirected")return!1;if(arguments.length===1){const n=""+e,i=this._edges.get(n);return!!i&&!i.undirected}else if(arguments.length===2){e=""+e,t=""+t;const n=this._nodes.get(e);return n?n.out.hasOwnProperty(t):!1}throw new tt(`Graph.hasDirectedEdge: invalid arity (${arguments.length}, instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target.`)}hasUndirectedEdge(e,t){if(this.type==="directed")return!1;if(arguments.length===1){const n=""+e,i=this._edges.get(n);return!!i&&i.undirected}else if(arguments.length===2){e=""+e,t=""+t;const n=this._nodes.get(e);return n?n.undirected.hasOwnProperty(t):!1}throw new tt(`Graph.hasDirectedEdge: invalid arity (${arguments.length}, instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target.`)}hasEdge(e,t){if(arguments.length===1){const n=""+e;return this._edges.has(n)}else if(arguments.length===2){e=""+e,t=""+t;const n=this._nodes.get(e);return n?typeof n.out<"u"&&n.out.hasOwnProperty(t)||typeof n.undirected<"u"&&n.undirected.hasOwnProperty(t):!1}throw new tt(`Graph.hasEdge: invalid arity (${arguments.length}, instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target.`)}directedEdge(e,t){if(this.type==="undirected")return;if(e=""+e,t=""+t,this.multi)throw new ft("Graph.directedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.directedEdges instead.");const n=this._nodes.get(e);if(!n)throw new je(`Graph.directedEdge: could not find the "${e}" source node in the graph.`);if(!this._nodes.has(t))throw new je(`Graph.directedEdge: could not find the "${t}" target node in the graph.`);const i=n.out&&n.out[t]||void 0;if(i)return i.key}undirectedEdge(e,t){if(this.type==="directed")return;if(e=""+e,t=""+t,this.multi)throw new ft("Graph.undirectedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.undirectedEdges instead.");const n=this._nodes.get(e);if(!n)throw new je(`Graph.undirectedEdge: could not find the "${e}" source node in the graph.`);if(!this._nodes.has(t))throw new je(`Graph.undirectedEdge: could not find the "${t}" target node in the graph.`);const i=n.undirected&&n.undirected[t]||void 0;if(i)return i.key}edge(e,t){if(this.multi)throw new ft("Graph.edge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.edges instead.");e=""+e,t=""+t;const n=this._nodes.get(e);if(!n)throw new je(`Graph.edge: could not find the "${e}" source node in the graph.`);if(!this._nodes.has(t))throw new je(`Graph.edge: could not find the "${t}" target node in the graph.`);const i=n.out&&n.out[t]||n.undirected&&n.undirected[t]||void 0;if(i)return i.key}areDirectedNeighbors(e,t){e=""+e,t=""+t;const n=this._nodes.get(e);if(!n)throw new je(`Graph.areDirectedNeighbors: could not find the "${e}" node in the graph.`);return this.type==="undirected"?!1:t in n.in||t in n.out}areOutNeighbors(e,t){e=""+e,t=""+t;const n=this._nodes.get(e);if(!n)throw new je(`Graph.areOutNeighbors: could not find the "${e}" node in the graph.`);return this.type==="undirected"?!1:t in n.out}areInNeighbors(e,t){e=""+e,t=""+t;const n=this._nodes.get(e);if(!n)throw new je(`Graph.areInNeighbors: could not find the "${e}" node in the graph.`);return this.type==="undirected"?!1:t in n.in}areUndirectedNeighbors(e,t){e=""+e,t=""+t;const n=this._nodes.get(e);if(!n)throw new je(`Graph.areUndirectedNeighbors: could not find the "${e}" node in the graph.`);return this.type==="directed"?!1:t in n.undirected}areNeighbors(e,t){e=""+e,t=""+t;const n=this._nodes.get(e);if(!n)throw new je(`Graph.areNeighbors: could not find the "${e}" node in the graph.`);return this.type!=="undirected"&&(t in n.in||t in n.out)||this.type!=="directed"&&t in n.undirected}areInboundNeighbors(e,t){e=""+e,t=""+t;const n=this._nodes.get(e);if(!n)throw new je(`Graph.areInboundNeighbors: could not find the "${e}" node in the graph.`);return this.type!=="undirected"&&t in n.in||this.type!=="directed"&&t in n.undirected}areOutboundNeighbors(e,t){e=""+e,t=""+t;const n=this._nodes.get(e);if(!n)throw new je(`Graph.areOutboundNeighbors: could not find the "${e}" node in the graph.`);return this.type!=="undirected"&&t in n.out||this.type!=="directed"&&t in n.undirected}inDegree(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new je(`Graph.inDegree: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:t.inDegree}outDegree(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new je(`Graph.outDegree: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:t.outDegree}directedDegree(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new je(`Graph.directedDegree: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:t.inDegree+t.outDegree}undirectedDegree(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new je(`Graph.undirectedDegree: could not find the "${e}" node in the graph.`);return this.type==="directed"?0:t.undirectedDegree}inboundDegree(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new je(`Graph.inboundDegree: could not find the "${e}" node in the graph.`);let n=0;return this.type!=="directed"&&(n+=t.undirectedDegree),this.type!=="undirected"&&(n+=t.inDegree),n}outboundDegree(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new je(`Graph.outboundDegree: could not find the "${e}" node in the graph.`);let n=0;return this.type!=="directed"&&(n+=t.undirectedDegree),this.type!=="undirected"&&(n+=t.outDegree),n}degree(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new je(`Graph.degree: could not find the "${e}" node in the graph.`);let n=0;return this.type!=="directed"&&(n+=t.undirectedDegree),this.type!=="undirected"&&(n+=t.inDegree+t.outDegree),n}inDegreeWithoutSelfLoops(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new je(`Graph.inDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:t.inDegree-t.directedLoops}outDegreeWithoutSelfLoops(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new je(`Graph.outDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:t.outDegree-t.directedLoops}directedDegreeWithoutSelfLoops(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new je(`Graph.directedDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:t.inDegree+t.outDegree-t.directedLoops*2}undirectedDegreeWithoutSelfLoops(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new je(`Graph.undirectedDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);return this.type==="directed"?0:t.undirectedDegree-t.undirectedLoops*2}inboundDegreeWithoutSelfLoops(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new je(`Graph.inboundDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);let n=0,i=0;return this.type!=="directed"&&(n+=t.undirectedDegree,i+=t.undirectedLoops*2),this.type!=="undirected"&&(n+=t.inDegree,i+=t.directedLoops),n-i}outboundDegreeWithoutSelfLoops(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new je(`Graph.outboundDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);let n=0,i=0;return this.type!=="directed"&&(n+=t.undirectedDegree,i+=t.undirectedLoops*2),this.type!=="undirected"&&(n+=t.outDegree,i+=t.directedLoops),n-i}degreeWithoutSelfLoops(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new je(`Graph.degreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);let n=0,i=0;return this.type!=="directed"&&(n+=t.undirectedDegree,i+=t.undirectedLoops*2),this.type!=="undirected"&&(n+=t.inDegree+t.outDegree,i+=t.directedLoops*2),n-i}source(e){e=""+e;const t=this._edges.get(e);if(!t)throw new je(`Graph.source: could not find the "${e}" edge in the graph.`);return t.source.key}target(e){e=""+e;const t=this._edges.get(e);if(!t)throw new je(`Graph.target: could not find the "${e}" edge in the graph.`);return t.target.key}extremities(e){e=""+e;const t=this._edges.get(e);if(!t)throw new je(`Graph.extremities: could not find the "${e}" edge in the graph.`);return[t.source.key,t.target.key]}opposite(e,t){e=""+e,t=""+t;const n=this._edges.get(t);if(!n)throw new je(`Graph.opposite: could not find the "${t}" edge in the graph.`);const i=n.source.key,s=n.target.key;if(e===i)return s;if(e===s)return i;throw new je(`Graph.opposite: the "${e}" node is not attached to the "${t}" edge (${i}, ${s}).`)}hasExtremity(e,t){e=""+e,t=""+t;const n=this._edges.get(e);if(!n)throw new je(`Graph.hasExtremity: could not find the "${e}" edge in the graph.`);return n.source.key===t||n.target.key===t}isUndirected(e){e=""+e;const t=this._edges.get(e);if(!t)throw new je(`Graph.isUndirected: could not find the "${e}" edge in the graph.`);return t.undirected}isDirected(e){e=""+e;const t=this._edges.get(e);if(!t)throw new je(`Graph.isDirected: could not find the "${e}" edge in the graph.`);return!t.undirected}isSelfLoop(e){e=""+e;const t=this._edges.get(e);if(!t)throw new je(`Graph.isSelfLoop: could not find the "${e}" edge in the graph.`);return t.source===t.target}addNode(e,t){return KB(this,e,t).key}mergeNode(e,t){if(t&&!ri(t))throw new tt(`Graph.mergeNode: invalid attributes. Expecting an object but got "${t}"`);e=""+e,t=t||{};let n=this._nodes.get(e);return n?(t&&(Vn(n.attributes,t),this.emit("nodeAttributesUpdated",{type:"merge",key:e,attributes:n.attributes,data:t})),[e,!1]):(n=new this.NodeDataClass(e,t),this._nodes.set(e,n),this.emit("nodeAdded",{key:e,attributes:t}),[e,!0])}updateNode(e,t){if(t&&typeof t!="function")throw new tt(`Graph.updateNode: invalid updater function. Expecting a function but got "${t}"`);e=""+e;let n=this._nodes.get(e);if(n){if(t){const s=n.attributes;n.attributes=t(s),this.emit("nodeAttributesUpdated",{type:"replace",key:e,attributes:n.attributes})}return[e,!1]}const i=t?t({}):{};return n=new this.NodeDataClass(e,i),this._nodes.set(e,n),this.emit("nodeAdded",{key:e,attributes:i}),[e,!0]}dropNode(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new je(`Graph.dropNode: could not find the "${e}" node in the graph.`);let n;if(this.type!=="undirected"){for(const i in t.out){n=t.out[i];do El(this,n),n=n.next;while(n)}for(const i in t.in){n=t.in[i];do El(this,n),n=n.next;while(n)}}if(this.type!=="directed")for(const i in t.undirected){n=t.undirected[i];do El(this,n),n=n.next;while(n)}this._nodes.delete(e),this.emit("nodeDropped",{key:e,attributes:t.attributes})}dropEdge(e){let t;if(arguments.length>1){const n=""+arguments[0],i=""+arguments[1];if(t=br(this,n,i,this.type),!t)throw new je(`Graph.dropEdge: could not find the "${n}" -> "${i}" edge in the graph.`)}else if(e=""+e,t=this._edges.get(e),!t)throw new je(`Graph.dropEdge: could not find the "${e}" edge in the graph.`);return El(this,t),this}dropDirectedEdge(e,t){if(arguments.length<2)throw new ft("Graph.dropDirectedEdge: it does not make sense to try and drop a directed edge by key. What if the edge with this key is undirected? Use #.dropEdge for this purpose instead.");if(this.multi)throw new ft("Graph.dropDirectedEdge: cannot use a {source,target} combo when dropping an edge in a MultiGraph since we cannot infer the one you want to delete as there could be multiple ones.");e=""+e,t=""+t;const n=br(this,e,t,"directed");if(!n)throw new je(`Graph.dropDirectedEdge: could not find a "${e}" -> "${t}" edge in the graph.`);return El(this,n),this}dropUndirectedEdge(e,t){if(arguments.length<2)throw new ft("Graph.dropUndirectedEdge: it does not make sense to drop a directed edge by key. What if the edge with this key is undirected? Use #.dropEdge for this purpose instead.");if(this.multi)throw new ft("Graph.dropUndirectedEdge: cannot use a {source,target} combo when dropping an edge in a MultiGraph since we cannot infer the one you want to delete as there could be multiple ones.");const n=br(this,e,t,"undirected");if(!n)throw new je(`Graph.dropUndirectedEdge: could not find a "${e}" -> "${t}" edge in the graph.`);return El(this,n),this}clear(){this._edges.clear(),this._nodes.clear(),this._resetInstanceCounters(),this.emit("cleared")}clearEdges(){const e=this._nodes.values();let t;for(;t=e.next(),t.done!==!0;)t.value.clear();this._edges.clear(),this._resetInstanceCounters(),this.emit("edgesCleared")}getAttribute(e){return this._attributes[e]}getAttributes(){return this._attributes}hasAttribute(e){return this._attributes.hasOwnProperty(e)}setAttribute(e,t){return this._attributes[e]=t,this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:e}),this}updateAttribute(e,t){if(typeof t!="function")throw new tt("Graph.updateAttribute: updater should be a function.");const n=this._attributes[e];return this._attributes[e]=t(n),this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:e}),this}removeAttribute(e){return delete this._attributes[e],this.emit("attributesUpdated",{type:"remove",attributes:this._attributes,name:e}),this}replaceAttributes(e){if(!ri(e))throw new tt("Graph.replaceAttributes: provided attributes are not a plain object.");return this._attributes=e,this.emit("attributesUpdated",{type:"replace",attributes:this._attributes}),this}mergeAttributes(e){if(!ri(e))throw new tt("Graph.mergeAttributes: provided attributes are not a plain object.");return Vn(this._attributes,e),this.emit("attributesUpdated",{type:"merge",attributes:this._attributes,data:e}),this}updateAttributes(e){if(typeof e!="function")throw new tt("Graph.updateAttributes: provided updater is not a function.");return this._attributes=e(this._attributes),this.emit("attributesUpdated",{type:"update",attributes:this._attributes}),this}updateEachNodeAttributes(e,t){if(typeof e!="function")throw new tt("Graph.updateEachNodeAttributes: expecting an updater function.");if(t&&!KS(t))throw new tt("Graph.updateEachNodeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");const n=this._nodes.values();let i,s;for(;i=n.next(),i.done!==!0;)s=i.value,s.attributes=e(s.key,s.attributes);this.emit("eachNodeAttributesUpdated",{hints:t||null})}updateEachEdgeAttributes(e,t){if(typeof e!="function")throw new tt("Graph.updateEachEdgeAttributes: expecting an updater function.");if(t&&!KS(t))throw new tt("Graph.updateEachEdgeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");const n=this._edges.values();let i,s,o,a;for(;i=n.next(),i.done!==!0;)s=i.value,o=s.source,a=s.target,s.attributes=e(s.key,s.attributes,o.key,a.key,o.attributes,a.attributes,s.undirected);this.emit("eachEdgeAttributesUpdated",{hints:t||null})}forEachAdjacencyEntry(e){if(typeof e!="function")throw new tt("Graph.forEachAdjacencyEntry: expecting a callback.");rd(!1,!1,!1,this,e)}forEachAdjacencyEntryWithOrphans(e){if(typeof e!="function")throw new tt("Graph.forEachAdjacencyEntryWithOrphans: expecting a callback.");rd(!1,!1,!0,this,e)}forEachAssymetricAdjacencyEntry(e){if(typeof e!="function")throw new tt("Graph.forEachAssymetricAdjacencyEntry: expecting a callback.");rd(!1,!0,!1,this,e)}forEachAssymetricAdjacencyEntryWithOrphans(e){if(typeof e!="function")throw new tt("Graph.forEachAssymetricAdjacencyEntryWithOrphans: expecting a callback.");rd(!1,!0,!0,this,e)}nodes(){return typeof Array.from=="function"?Array.from(this._nodes.keys()):iA(this._nodes.keys(),this._nodes.size)}forEachNode(e){if(typeof e!="function")throw new tt("Graph.forEachNode: expecting a callback.");const t=this._nodes.values();let n,i;for(;n=t.next(),n.done!==!0;)i=n.value,e(i.key,i.attributes)}findNode(e){if(typeof e!="function")throw new tt("Graph.findNode: expecting a callback.");const t=this._nodes.values();let n,i;for(;n=t.next(),n.done!==!0;)if(i=n.value,e(i.key,i.attributes))return i.key}mapNodes(e){if(typeof e!="function")throw new tt("Graph.mapNode: expecting a callback.");const t=this._nodes.values();let n,i;const s=new Array(this.order);let o=0;for(;n=t.next(),n.done!==!0;)i=n.value,s[o++]=e(i.key,i.attributes);return s}someNode(e){if(typeof e!="function")throw new tt("Graph.someNode: expecting a callback.");const t=this._nodes.values();let n,i;for(;n=t.next(),n.done!==!0;)if(i=n.value,e(i.key,i.attributes))return!0;return!1}everyNode(e){if(typeof e!="function")throw new tt("Graph.everyNode: expecting a callback.");const t=this._nodes.values();let n,i;for(;n=t.next(),n.done!==!0;)if(i=n.value,!e(i.key,i.attributes))return!1;return!0}filterNodes(e){if(typeof e!="function")throw new tt("Graph.filterNodes: expecting a callback.");const t=this._nodes.values();let n,i;const s=[];for(;n=t.next(),n.done!==!0;)i=n.value,e(i.key,i.attributes)&&s.push(i.key);return s}reduceNodes(e,t){if(typeof e!="function")throw new tt("Graph.reduceNodes: expecting a callback.");if(arguments.length<2)throw new tt("Graph.reduceNodes: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.");let n=t;const i=this._nodes.values();let s,o;for(;s=i.next(),s.done!==!0;)o=s.value,n=e(n,o.key,o.attributes);return n}nodeEntries(){const e=this._nodes.values();return new Mr(()=>{const t=e.next();if(t.done)return t;const n=t.value;return{value:{node:n.key,attributes:n.attributes},done:!1}})}export(){const e=new Array(this._nodes.size);let t=0;this._nodes.forEach((i,s)=>{e[t++]=HB(s,i)});const n=new Array(this._edges.size);return t=0,this._edges.forEach((i,s)=>{n[t++]=VB(this.type,s,i)}),{options:{type:this.type,multi:this.multi,allowSelfLoops:this.allowSelfLoops},attributes:this.getAttributes(),nodes:e,edges:n}}import(e,t=!1){if(e instanceof en)return e.forEachNode((l,c)=>{t?this.mergeNode(l,c):this.addNode(l,c)}),e.forEachEdge((l,c,u,h,p,m,v)=>{t?v?this.mergeUndirectedEdgeWithKey(l,u,h,c):this.mergeDirectedEdgeWithKey(l,u,h,c):v?this.addUndirectedEdgeWithKey(l,u,h,c):this.addDirectedEdgeWithKey(l,u,h,c)}),this;if(!ri(e))throw new tt("Graph.import: invalid argument. Expecting a serialized graph or, alternatively, a Graph instance.");if(e.attributes){if(!ri(e.attributes))throw new tt("Graph.import: invalid attributes. Expecting a plain object.");t?this.mergeAttributes(e.attributes):this.replaceAttributes(e.attributes)}let n,i,s,o,a;if(e.nodes){if(s=e.nodes,!Array.isArray(s))throw new tt("Graph.import: invalid nodes. Expecting an array.");for(n=0,i=s.length;n{const s=Vn({},n.attributes);n=new t.NodeDataClass(i,s),t._nodes.set(i,n)}),t}copy(e){if(e=e||{},typeof e.type=="string"&&e.type!==this.type&&e.type!=="mixed")throw new ft(`Graph.copy: cannot create an incompatible copy from "${this.type}" type to "${e.type}" because this would mean losing information about the current graph.`);if(typeof e.multi=="boolean"&&e.multi!==this.multi&&e.multi!==!0)throw new ft("Graph.copy: cannot create an incompatible copy by downgrading a multi graph to a simple one because this would mean losing information about the current graph.");if(typeof e.allowSelfLoops=="boolean"&&e.allowSelfLoops!==this.allowSelfLoops&&e.allowSelfLoops!==!0)throw new ft("Graph.copy: cannot create an incompatible copy from a graph allowing self loops to one that does not because this would mean losing information about the current graph.");const t=this.emptyCopy(e),n=this._edges.values();let i,s;for(;i=n.next(),i.done!==!0;)s=i.value,fA(t,"copy",!1,s.undirected,s.key,s.source.key,s.target.key,Vn({},s.attributes));return t}toJSON(){return this.export()}toString(){return"[object Graph]"}inspect(){const e={};this._nodes.forEach((s,o)=>{e[o]=s.attributes});const t={},n={};this._edges.forEach((s,o)=>{const a=s.undirected?"--":"->";let l="",c=s.source.key,u=s.target.key,h;s.undirected&&c>u&&(h=c,c=u,u=h);const p=`(${c})${a}(${u})`;o.startsWith("geid_")?this.multi&&(typeof n[p]>"u"?n[p]=0:n[p]++,l+=`${n[p]}. `):l+=`[${o}]: `,l+=p,t[l]=s.attributes});const i={};for(const s in this)this.hasOwnProperty(s)&&!$S.has(s)&&typeof this[s]!="function"&&typeof s!="symbol"&&(i[s]=this[s]);return i.attributes=this._attributes,i.nodes=e,i.edges=t,mr(i,"constructor",this.constructor),i}}typeof Symbol<"u"&&(en.prototype[Symbol.for("nodejs.util.inspect.custom")]=en.prototype.inspect);qB.forEach(r=>{["add","merge","update"].forEach(e=>{const t=r.name(e),n=e==="add"?fA:$B;r.generateKey?en.prototype[t]=function(i,s,o){return n(this,t,!0,(r.type||this.type)==="undirected",null,i,s,o,e==="update")}:en.prototype[t]=function(i,s,o,a){return n(this,t,!1,(r.type||this.type)==="undirected",i,s,o,a,e==="update")}})});oB(en);vB(en);DB(en);GB(en);class dA extends en{constructor(e){const t=Vn({type:"directed"},e);if("multi"in t&&t.multi!==!1)throw new tt("DirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(t.type!=="directed")throw new tt('DirectedGraph.from: inconsistent "'+t.type+'" type in given options!');super(t)}}class pA extends en{constructor(e){const t=Vn({type:"undirected"},e);if("multi"in t&&t.multi!==!1)throw new tt("UndirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(t.type!=="undirected")throw new tt('UndirectedGraph.from: inconsistent "'+t.type+'" type in given options!');super(t)}}class mA extends en{constructor(e){const t=Vn({multi:!0},e);if("multi"in t&&t.multi!==!0)throw new tt("MultiGraph.from: inconsistent indication that the graph should be simple in given options!");super(t)}}class gA extends en{constructor(e){const t=Vn({type:"directed",multi:!0},e);if("multi"in t&&t.multi!==!0)throw new tt("MultiDirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(t.type!=="directed")throw new tt('MultiDirectedGraph.from: inconsistent "'+t.type+'" type in given options!');super(t)}}class vA extends en{constructor(e){const t=Vn({type:"undirected",multi:!0},e);if("multi"in t&&t.multi!==!0)throw new tt("MultiUndirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(t.type!=="undirected")throw new tt('MultiUndirectedGraph.from: inconsistent "'+t.type+'" type in given options!');super(t)}}function ic(r){r.from=function(e,t){const n=Vn({},e.options,t),i=new r(n);return i.import(e),i}}ic(en);ic(dA);ic(pA);ic(mA);ic(gA);ic(vA);en.Graph=en;en.DirectedGraph=dA;en.UndirectedGraph=pA;en.MultiGraph=mA;en.MultiDirectedGraph=gA;en.MultiUndirectedGraph=vA;en.InvalidArgumentsGraphError=tt;en.NotFoundGraphError=je;en.UsageGraphError=ft;const ph=new Y,Ky=new Y,JB=new Y;function QB(r,e,t){const n=ph.setFromMatrixPosition(r.matrixWorld);n.project(e);const i=t.width/2,s=t.height/2;return[n.x*i+i,-(n.y*s)+s]}function e4(r,e){const t=ph.setFromMatrixPosition(r.matrixWorld),n=Ky.setFromMatrixPosition(e.matrixWorld),i=t.sub(n),s=e.getWorldDirection(JB);return i.angleTo(s)>Math.PI/2}function t4(r,e,t,n){const i=ph.setFromMatrixPosition(r.matrixWorld),s=i.clone();s.project(e),t.setFromCamera(s,e);const o=t.intersectObjects(n,!0);if(o.length){const a=o[0].distance;return i.distanceTo(t.ray.origin)Math.abs(r)<1e-10?0:r;function yA(r,e,t=""){let n="matrix3d(";for(let i=0;i!==16;i++)n+=Mv(e[i]*r.elements[i])+(i!==15?",":")");return t+n}const r4=(r=>e=>yA(e,r))([1,-1,1,1,1,-1,1,1,1,-1,1,1,1,-1,1,1]),s4=(r=>(e,t)=>yA(e,r(t),"translate(-50%,-50%)"))(r=>[1/r,1/r,1/r,1,-1/r,-1/r,-1/r,-1,1/r,1/r,1/r,1,1,1,1,1]);function o4(r){return r&&typeof r=="object"&&"current"in r}const $y=K.forwardRef(({children:r,eps:e=.001,style:t,className:n,prepend:i,center:s,fullscreen:o,portal:a,distanceFactor:l,sprite:c=!1,transform:u=!1,occlude:h,onOcclude:p,castShadow:m,receiveShadow:v,material:_,geometry:y,zIndexRange:g=[16777271,0],calculatePosition:x=QB,as:w="div",wrapperClass:E,pointerEvents:b="auto",...M},A)=>{const{gl:P,camera:C,scene:L,size:F,raycaster:N,events:I,viewport:X}=Bn(),[q]=K.useState(()=>document.createElement(w)),W=K.useRef(),O=K.useRef(null),k=K.useRef(0),G=K.useRef([0,0]),B=K.useRef(null),D=K.useRef(null),V=(a==null?void 0:a.current)||I.connected||P.domElement.parentNode,Z=K.useRef(null),ee=K.useRef(!1),ie=K.useMemo(()=>h&&h!=="blending"||Array.isArray(h)&&h.length&&o4(h[0]),[h]);K.useLayoutEffect(()=>{const Ee=P.domElement;h&&h==="blending"?(Ee.style.zIndex=`${Math.floor(g[0]/2)}`,Ee.style.position="absolute",Ee.style.pointerEvents="none"):(Ee.style.zIndex=null,Ee.style.position=null,Ee.style.pointerEvents=null)},[h]),K.useLayoutEffect(()=>{if(O.current){const Ee=W.current=q2.createRoot(q);if(L.updateMatrixWorld(),u)q.style.cssText="position:absolute;top:0;left:0;pointer-events:none;overflow:hidden;";else{const ae=x(O.current,C,F);q.style.cssText=`position:absolute;top:0;left:0;transform:translate3d(${ae[0]}px,${ae[1]}px,0);transform-origin:0 0;`}return V&&(i?V.prepend(q):V.appendChild(q)),()=>{V&&V.removeChild(q),Ee.unmount()}}},[V,u]),K.useLayoutEffect(()=>{E&&(q.className=E)},[E]);const ue=K.useMemo(()=>u?{position:"absolute",top:0,left:0,width:F.width,height:F.height,transformStyle:"preserve-3d",pointerEvents:"none"}:{position:"absolute",transform:s?"translate3d(-50%,-50%,0)":"none",...o&&{top:-F.height/2,left:-F.width/2,width:F.width,height:F.height},...t},[t,s,o,F,u]),ce=K.useMemo(()=>({position:"absolute",pointerEvents:b}),[b]);K.useLayoutEffect(()=>{if(ee.current=!1,u){var Ee;(Ee=W.current)==null||Ee.render(K.createElement("div",{ref:B,style:ue},K.createElement("div",{ref:D,style:ce},K.createElement("div",{ref:A,className:n,style:t,children:r}))))}else{var ae;(ae=W.current)==null||ae.render(K.createElement("div",{ref:A,style:ue,className:n,children:r}))}});const le=K.useRef(!0);Ep(Ee=>{if(O.current){C.updateMatrixWorld(),O.current.updateWorldMatrix(!0,!1);const ae=u?G.current:x(O.current,C,F);if(u||Math.abs(k.current-C.zoom)>e||Math.abs(G.current[0]-ae[0])>e||Math.abs(G.current[1]-ae[1])>e){const z=e4(O.current,C);let oe=!1;ie&&(Array.isArray(h)?oe=h.map(Ie=>Ie.current):h!=="blending"&&(oe=[L]));const te=le.current;if(oe){const Ie=t4(O.current,C,N,oe);le.current=Ie&&!z}else le.current=!z;te!==le.current&&(p?p(!le.current):q.style.display=le.current?"block":"none");const se=Math.floor(g[0]/2),$=h?ie?[g[0],se]:[se-1,0]:g;if(q.style.zIndex=`${i4(O.current,C,$)}`,u){const[Ie,de]=[F.width/2,F.height/2],Se=C.projectionMatrix.elements[5]*de,{isOrthographicCamera:Le,top:ge,left:He,bottom:j,right:H}=C,ne=r4(C.matrixWorldInverse),we=Le?`scale(${Se})translate(${Mv(-(H+He)/2)}px,${Mv((ge+j)/2)}px)`:`translateZ(${Se}px)`;let be=O.current.matrixWorld;c&&(be=C.matrixWorldInverse.clone().transpose().copyPosition(be).scale(O.current.scale),be.elements[3]=be.elements[7]=be.elements[11]=0,be.elements[15]=1),q.style.width=F.width+"px",q.style.height=F.height+"px",q.style.perspective=Le?"":`${Se}px`,B.current&&D.current&&(B.current.style.transform=`${we}${ne}translate(${Ie}px,${de}px)`,D.current.style.transform=s4(be,1/((l||10)/400)))}else{const Ie=l===void 0?1:n4(O.current,C)*l;q.style.transform=`translate3d(${ae[0]}px,${ae[1]}px,0) scale(${Ie})`}G.current=ae,k.current=C.zoom}}if(!ie&&Z.current&&!ee.current)if(u){if(B.current){const ae=B.current.children[0];if(ae!=null&&ae.clientWidth&&ae!=null&&ae.clientHeight){const{isOrthographicCamera:z}=C;if(z||y)M.scale&&(Array.isArray(M.scale)?M.scale instanceof Y?Z.current.scale.copy(M.scale.clone().divideScalar(1)):Z.current.scale.set(1/M.scale[0],1/M.scale[1],1/M.scale[2]):Z.current.scale.setScalar(1/M.scale));else{const oe=(l||10)/400,te=ae.clientWidth*oe,se=ae.clientHeight*oe;Z.current.scale.set(te,se,1)}ee.current=!0}}}else{const ae=q.children[0];if(ae!=null&&ae.clientWidth&&ae!=null&&ae.clientHeight){const z=1/X.factor,oe=ae.clientWidth*z,te=ae.clientHeight*z;Z.current.scale.set(oe,te,1),ee.current=!0}Z.current.lookAt(Ee.camera.position)}});const Ae=K.useMemo(()=>({vertexShader:u?void 0:` /* This shader is from the THREE's SpriteMaterial. We need to turn the backing plane into a Sprite (make it always face the camera) if "transfrom" is false. */ #include void main() { vec2 center = vec2(0., 1.); float rotation = 0.0; // This is somewhat arbitrary, but it seems to work well // Need to figure out how to derive this dynamically if it even matters float size = 0.03; vec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 ); vec2 scale; scale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) ); scale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) ); bool isPerspective = isPerspectiveMatrix( projectionMatrix ); if ( isPerspective ) scale *= - mvPosition.z; vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale * size; vec2 rotatedPosition; rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y; rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y; mvPosition.xy += rotatedPosition; gl_Position = projectionMatrix * mvPosition; } `,fragmentShader:` void main() { gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0); } `}),[u]);return K.createElement("group",Ta({},M,{ref:O}),h&&!ie&&K.createElement("mesh",{castShadow:m,receiveShadow:v,ref:Z},y||K.createElement("planeGeometry",null),_||K.createElement("shaderMaterial",{side:vn,vertexShader:Ae.vertexShader,fragmentShader:Ae.fragmentShader})))});function ya(r,e="pointer",t="auto",n=document.body){K.useEffect(()=>{if(r)return n.style.cursor=e,()=>void(n.style.cursor=t)},[r])}let Jy=gh();const xt=r=>mh(r,Jy);let Qy=gh();xt.write=r=>mh(r,Qy);let Pp=gh();xt.onStart=r=>mh(r,Pp);let e_=gh();xt.onFrame=r=>mh(r,e_);let t_=gh();xt.onFinish=r=>mh(r,t_);let Gl=[];xt.setTimeout=(r,e)=>{let t=xt.now()+e,n=()=>{let s=Gl.findIndex(o=>o.cancel==n);~s&&Gl.splice(s,1),po-=~s?1:0},i={time:t,handler:r,cancel:n};return Gl.splice(_A(t),0,i),po+=1,xA(),i};let _A=r=>~(~Gl.findIndex(e=>e.time>r)||~Gl.length);xt.cancel=r=>{Pp.delete(r),e_.delete(r),t_.delete(r),Jy.delete(r),Qy.delete(r)};xt.sync=r=>{Tv=!0,xt.batchedUpdates(r),Tv=!1};xt.throttle=r=>{let e;function t(){try{r(...e)}finally{e=null}}function n(...i){e=i,xt.onStart(t)}return n.handler=r,n.cancel=()=>{Pp.delete(t),e=null},n};let n_=typeof window<"u"?window.requestAnimationFrame:()=>{};xt.use=r=>n_=r;xt.now=typeof performance<"u"?()=>performance.now():Date.now;xt.batchedUpdates=r=>r();xt.catch=console.error;xt.frameLoop="always";xt.advance=()=>{xt.frameLoop!=="demand"?console.warn("Cannot call the manual advancement of rafz whilst frameLoop is not set as demand"):SA()};let fo=-1,po=0,Tv=!1;function mh(r,e){Tv?(e.delete(r),r(0)):(e.add(r),xA())}function xA(){fo<0&&(fo=0,xt.frameLoop!=="demand"&&n_(wA))}function a4(){fo=-1}function wA(){~fo&&(n_(wA),xt.batchedUpdates(SA))}function SA(){let r=fo;fo=xt.now();let e=_A(fo);if(e&&(EA(Gl.splice(0,e),t=>t.handler()),po-=e),!po){a4();return}Pp.flush(),Jy.flush(r?Math.min(64,fo-r):16.667),e_.flush(),Qy.flush(),t_.flush()}function gh(){let r=new Set,e=r;return{add(t){po+=e==r&&!r.has(t)?1:0,r.add(t)},delete(t){return po-=e==r&&r.has(t)?1:0,r.delete(t)},flush(t){e.size&&(r=new Set,po-=e.size,EA(e,n=>n(t)&&r.add(n)),po+=r.size,e=r)}}}function EA(r,e){r.forEach(t=>{try{e(t)}catch(n){xt.catch(n)}})}function Av(){}const l4=(r,e,t)=>Object.defineProperty(r,e,{value:t,writable:!0,configurable:!0}),Ze={arr:Array.isArray,obj:r=>!!r&&r.constructor.name==="Object",fun:r=>typeof r=="function",str:r=>typeof r=="string",num:r=>typeof r=="number",und:r=>r===void 0};function Ds(r,e){if(Ze.arr(r)){if(!Ze.arr(e)||r.length!==e.length)return!1;for(let t=0;tr.forEach(e);function Gs(r,e,t){if(Ze.arr(r)){for(let n=0;nZe.und(r)?[]:Ze.arr(r)?r:[r];function Su(r,e){if(r.size){const t=Array.from(r);r.clear(),Kt(t,e)}}const mu=(r,...e)=>Su(r,t=>t(...e)),i_=()=>typeof window>"u"||!window.navigator||/ServerSideRendering|^Deno\//.test(window.navigator.userAgent);let r_,bA,_o=null,MA=!1,s_=Av;const c4=r=>{r.to&&(bA=r.to),r.now&&(xt.now=r.now),r.colors!==void 0&&(_o=r.colors),r.skipAnimation!=null&&(MA=r.skipAnimation),r.createStringInterpolator&&(r_=r.createStringInterpolator),r.requestAnimationFrame&&xt.use(r.requestAnimationFrame),r.batchedUpdates&&(xt.batchedUpdates=r.batchedUpdates),r.willAdvance&&(s_=r.willAdvance),r.frameLoop&&(xt.frameLoop=r.frameLoop)};var us=Object.freeze({__proto__:null,get createStringInterpolator(){return r_},get to(){return bA},get colors(){return _o},get skipAnimation(){return MA},get willAdvance(){return s_},assign:c4});const Eu=new Set;let Sr=[],u0=[],Bd=0;const Lp={get idle(){return!Eu.size&&!Sr.length},start(r){Bd>r.priority?(Eu.add(r),xt.onStart(u4)):(TA(r),xt(Cv))},advance:Cv,sort(r){if(Bd)xt.onFrame(()=>Lp.sort(r));else{const e=Sr.indexOf(r);~e&&(Sr.splice(e,1),AA(r))}},clear(){Sr=[],Eu.clear()}};function u4(){Eu.forEach(TA),Eu.clear(),xt(Cv)}function TA(r){Sr.includes(r)||AA(r)}function AA(r){Sr.splice(h4(Sr,e=>e.priority>r.priority),0,r)}function Cv(r){const e=u0;for(let t=0;t0}function h4(r,e){const t=r.findIndex(e);return t<0?r.length:t}const f4={transparent:0,aliceblue:4042850303,antiquewhite:4209760255,aqua:16777215,aquamarine:2147472639,azure:4043309055,beige:4126530815,bisque:4293182719,black:255,blanchedalmond:4293643775,blue:65535,blueviolet:2318131967,brown:2771004159,burlywood:3736635391,burntsienna:3934150143,cadetblue:1604231423,chartreuse:2147418367,chocolate:3530104575,coral:4286533887,cornflowerblue:1687547391,cornsilk:4294499583,crimson:3692313855,cyan:16777215,darkblue:35839,darkcyan:9145343,darkgoldenrod:3095792639,darkgray:2846468607,darkgreen:6553855,darkgrey:2846468607,darkkhaki:3182914559,darkmagenta:2332068863,darkolivegreen:1433087999,darkorange:4287365375,darkorchid:2570243327,darkred:2332033279,darksalmon:3918953215,darkseagreen:2411499519,darkslateblue:1211993087,darkslategray:793726975,darkslategrey:793726975,darkturquoise:13554175,darkviolet:2483082239,deeppink:4279538687,deepskyblue:12582911,dimgray:1768516095,dimgrey:1768516095,dodgerblue:512819199,firebrick:2988581631,floralwhite:4294635775,forestgreen:579543807,fuchsia:4278255615,gainsboro:3705462015,ghostwhite:4177068031,gold:4292280575,goldenrod:3668254975,gray:2155905279,green:8388863,greenyellow:2919182335,grey:2155905279,honeydew:4043305215,hotpink:4285117695,indianred:3445382399,indigo:1258324735,ivory:4294963455,khaki:4041641215,lavender:3873897215,lavenderblush:4293981695,lawngreen:2096890111,lemonchiffon:4294626815,lightblue:2916673279,lightcoral:4034953471,lightcyan:3774873599,lightgoldenrodyellow:4210742015,lightgray:3553874943,lightgreen:2431553791,lightgrey:3553874943,lightpink:4290167295,lightsalmon:4288707327,lightseagreen:548580095,lightskyblue:2278488831,lightslategray:2005441023,lightslategrey:2005441023,lightsteelblue:2965692159,lightyellow:4294959359,lime:16711935,limegreen:852308735,linen:4210091775,magenta:4278255615,maroon:2147483903,mediumaquamarine:1724754687,mediumblue:52735,mediumorchid:3126187007,mediumpurple:2473647103,mediumseagreen:1018393087,mediumslateblue:2070474495,mediumspringgreen:16423679,mediumturquoise:1221709055,mediumvioletred:3340076543,midnightblue:421097727,mintcream:4127193855,mistyrose:4293190143,moccasin:4293178879,navajowhite:4292783615,navy:33023,oldlace:4260751103,olive:2155872511,olivedrab:1804477439,orange:4289003775,orangered:4282712319,orchid:3664828159,palegoldenrod:4008225535,palegreen:2566625535,paleturquoise:2951671551,palevioletred:3681588223,papayawhip:4293907967,peachpuff:4292524543,peru:3448061951,pink:4290825215,plum:3718307327,powderblue:2967529215,purple:2147516671,rebeccapurple:1714657791,red:4278190335,rosybrown:3163525119,royalblue:1097458175,saddlebrown:2336560127,salmon:4202722047,sandybrown:4104413439,seagreen:780883967,seashell:4294307583,sienna:2689740287,silver:3233857791,skyblue:2278484991,slateblue:1784335871,slategray:1887473919,slategrey:1887473919,snow:4294638335,springgreen:16744447,steelblue:1182971135,tan:3535047935,teal:8421631,thistle:3636451583,tomato:4284696575,turquoise:1088475391,violet:4001558271,wheat:4125012991,white:4294967295,whitesmoke:4126537215,yellow:4294902015,yellowgreen:2597139199},kr="[-+]?\\d*\\.?\\d+",Gd=kr+"%";function Ip(...r){return"\\(\\s*("+r.join(")\\s*,\\s*(")+")\\s*\\)"}const d4=new RegExp("rgb"+Ip(kr,kr,kr)),p4=new RegExp("rgba"+Ip(kr,kr,kr,kr)),m4=new RegExp("hsl"+Ip(kr,Gd,Gd)),g4=new RegExp("hsla"+Ip(kr,Gd,Gd,kr)),v4=/^#([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,y4=/^#([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,_4=/^#([0-9a-fA-F]{6})$/,x4=/^#([0-9a-fA-F]{8})$/;function w4(r){let e;return typeof r=="number"?r>>>0===r&&r>=0&&r<=4294967295?r:null:(e=_4.exec(r))?parseInt(e[1]+"ff",16)>>>0:_o&&_o[r]!==void 0?_o[r]:(e=d4.exec(r))?(bl(e[1])<<24|bl(e[2])<<16|bl(e[3])<<8|255)>>>0:(e=p4.exec(r))?(bl(e[1])<<24|bl(e[2])<<16|bl(e[3])<<8|tE(e[4]))>>>0:(e=v4.exec(r))?parseInt(e[1]+e[1]+e[2]+e[2]+e[3]+e[3]+"ff",16)>>>0:(e=x4.exec(r))?parseInt(e[1],16)>>>0:(e=y4.exec(r))?parseInt(e[1]+e[1]+e[2]+e[2]+e[3]+e[3]+e[4]+e[4],16)>>>0:(e=m4.exec(r))?(QS(eE(e[1]),sd(e[2]),sd(e[3]))|255)>>>0:(e=g4.exec(r))?(QS(eE(e[1]),sd(e[2]),sd(e[3]))|tE(e[4]))>>>0:null}function h0(r,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?r+(e-r)*6*t:t<1/2?e:t<2/3?r+(e-r)*(2/3-t)*6:r}function QS(r,e,t){const n=t<.5?t*(1+e):t+e-t*e,i=2*t-n,s=h0(i,n,r+1/3),o=h0(i,n,r),a=h0(i,n,r-1/3);return Math.round(s*255)<<24|Math.round(o*255)<<16|Math.round(a*255)<<8}function bl(r){const e=parseInt(r,10);return e<0?0:e>255?255:e}function eE(r){return(parseFloat(r)%360+360)%360/360}function tE(r){const e=parseFloat(r);return e<0?0:e>1?255:Math.round(e*255)}function sd(r){const e=parseFloat(r);return e<0?0:e>100?1:e/100}function nE(r){let e=w4(r);if(e===null)return r;e=e||0;let t=(e&4278190080)>>>24,n=(e&16711680)>>>16,i=(e&65280)>>>8,s=(e&255)/255;return`rgba(${t}, ${n}, ${i}, ${s})`}const qu=(r,e,t)=>{if(Ze.fun(r))return r;if(Ze.arr(r))return qu({range:r,output:e,extrapolate:t});if(Ze.str(r.output[0]))return r_(r);const n=r,i=n.output,s=n.range||[0,1],o=n.extrapolateLeft||n.extrapolate||"extend",a=n.extrapolateRight||n.extrapolate||"extend",l=n.easing||(c=>c);return c=>{const u=E4(c,s);return S4(c,s[u],s[u+1],i[u],i[u+1],l,o,a,n.map)}};function S4(r,e,t,n,i,s,o,a,l){let c=l?l(r):r;if(ct){if(a==="identity")return c;a==="clamp"&&(c=t)}return n===i?n:e===t?r<=e?n:i:(e===-1/0?c=-c:t===1/0?c=c-e:c=(c-e)/(t-e),c=s(c),n===-1/0?c=-c:i===1/0?c=c+n:c=c*(i-n)+n,c)}function E4(r,e){for(var t=1;t=r);++t);return t-1}const b4={linear:r=>r};function Rv(){return Rv=Object.assign?Object.assign.bind():function(r){for(var e=1;e!!(r&&r[Kl]),_r=r=>r&&r[Kl]?r[Kl]():r,iE=r=>r[Ca]||null;function M4(r,e){r.eventObserved?r.eventObserved(e):r(e)}function Hd(r,e){let t=r[Ca];t&&t.forEach(n=>{M4(n,e)})}class T4{constructor(e){if(this[Kl]=void 0,this[Ca]=void 0,!e&&!(e=this.get))throw Error("Unknown getter");A4(this,e)}}const A4=(r,e)=>CA(r,Kl,e);function vh(r,e){if(r[Kl]){let t=r[Ca];t||CA(r,Ca,t=new Set),t.has(e)||(t.add(e),r.observerAdded&&r.observerAdded(t.size,e))}return e}function Vd(r,e){let t=r[Ca];if(t&&t.has(e)){const n=t.size-1;n?t.delete(e):r[Ca]=null,r.observerRemoved&&r.observerRemoved(n,e)}}const CA=(r,e,t)=>Object.defineProperty(r,e,{value:t,writable:!0,configurable:!0}),Cd=/[+\-]?(?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,C4=/(#(?:[0-9a-f]{2}){2,4}|(#[0-9a-f]{3})|(rgb|hsl)a?\((-?\d+%?[,\s]+){2,3}\s*[\d\.]+%?\))/gi,rE=new RegExp(`(${Cd.source})(%|[a-z]+)`,"i"),R4=/rgba\(([0-9\.-]+), ([0-9\.-]+), ([0-9\.-]+), ([0-9\.-]+)\)/gi,Dp=/var\((--[a-zA-Z0-9-_]+),? ?([a-zA-Z0-9 ()%#.,-]+)?\)/,RA=r=>{const[e,t]=P4(r);if(!e||i_())return r;const n=window.getComputedStyle(document.documentElement).getPropertyValue(e);if(n)return n.trim();if(t&&t.startsWith("--")){const i=window.getComputedStyle(document.documentElement).getPropertyValue(t);return i||r}else{if(t&&Dp.test(t))return RA(t);if(t)return t}return r},P4=r=>{const e=Dp.exec(r);if(!e)return[,];const[,t,n]=e;return[t,n]};let f0;const L4=(r,e,t,n,i)=>`rgba(${Math.round(e)}, ${Math.round(t)}, ${Math.round(n)}, ${i})`,PA=r=>{f0||(f0=_o?new RegExp(`(${Object.keys(_o).join("|")})(?!\\w)`,"g"):/^\b$/);const e=r.output.map(s=>_r(s).replace(Dp,RA).replace(C4,nE).replace(f0,nE)),t=e.map(s=>s.match(Cd).map(Number)),i=t[0].map((s,o)=>t.map(a=>{if(!(o in a))throw Error('The arity of each "output" value must be equal');return a[o]})).map(s=>qu(Rv({},r,{output:s})));return s=>{var o;const a=!rE.test(e[0])&&((o=e.find(c=>rE.test(c)))==null?void 0:o.replace(Cd,""));let l=0;return e[0].replace(Cd,()=>`${i[l++](s)}${a||""}`).replace(R4,L4)}},o_="react-spring: ",LA=r=>{const e=r;let t=!1;if(typeof e!="function")throw new TypeError(`${o_}once requires a function parameter`);return(...n)=>{t||(e(...n),t=!0)}},I4=LA(console.warn);function D4(){I4(`${o_}The "interpolate" function is deprecated in v9 (use "to" instead)`)}const U4=LA(console.warn);function O4(){U4(`${o_}Directly calling start instead of using the api object is deprecated in v9 (use ".start" instead), this will be removed in later 0.X.0 versions`)}function Up(r){return Ze.str(r)&&(r[0]=="#"||/\d/.test(r)||!i_()&&Dp.test(r)||r in(_o||{}))}const a_=i_()?K.useEffect:K.useLayoutEffect,N4=()=>{const r=K.useRef(!1);return a_(()=>(r.current=!0,()=>{r.current=!1}),[]),r};function IA(){const r=K.useState()[1],e=N4();return()=>{e.current&&r(Math.random())}}function F4(r,e){const[t]=K.useState(()=>({inputs:e,result:r()})),n=K.useRef(),i=n.current;let s=i;return s?e&&s.inputs&&k4(e,s.inputs)||(s={inputs:e,result:r()}):s=t,K.useEffect(()=>{n.current=s,i==t&&(t.inputs=t.result=void 0)},[s]),s.result}function k4(r,e){if(r.length!==e.length)return!1;for(let t=0;tK.useEffect(r,z4),z4=[];function sE(r){const e=K.useRef();return K.useEffect(()=>{e.current=r}),e.current}const Zu=Symbol.for("Animated:node"),B4=r=>!!r&&r[Zu]===r,ns=r=>r&&r[Zu],l_=(r,e)=>l4(r,Zu,e),Op=r=>r&&r[Zu]&&r[Zu].getPayload();class UA{constructor(){this.payload=void 0,l_(this,this)}getPayload(){return this.payload||[]}}class rc extends UA{constructor(e){super(),this.done=!0,this.elapsedTime=void 0,this.lastPosition=void 0,this.lastVelocity=void 0,this.v0=void 0,this.durationProgress=0,this._value=e,Ze.num(this._value)&&(this.lastPosition=this._value)}static create(e){return new rc(e)}getPayload(){return[this]}getValue(){return this._value}setValue(e,t){return Ze.num(e)&&(this.lastPosition=e,t&&(e=Math.round(e/t)*t,this.done&&(this.lastPosition=e))),this._value===e?!1:(this._value=e,!0)}reset(){const{done:e}=this;this.done=!1,Ze.num(this._value)&&(this.elapsedTime=0,this.durationProgress=0,this.lastPosition=this._value,e&&(this.lastVelocity=null),this.v0=null)}}class $l extends rc{constructor(e){super(0),this._string=null,this._toString=void 0,this._toString=qu({output:[e,e]})}static create(e){return new $l(e)}getValue(){let e=this._string;return e??(this._string=this._toString(this._value))}setValue(e){if(Ze.str(e)){if(e==this._string)return!1;this._string=e,this._value=1}else if(super.setValue(e))this._string=null;else return!1;return!0}reset(e){e&&(this._toString=qu({output:[this.getValue(),e]})),this._value=0,super.reset()}}const Wd={dependencies:null};class c_ extends UA{constructor(e){super(),this.source=e,this.setValue(e)}getValue(e){const t={};return Gs(this.source,(n,i)=>{B4(n)?t[i]=n.getValue(e):is(n)?t[i]=_r(n):e||(t[i]=n)}),t}setValue(e){this.source=e,this.payload=this._makePayload(e)}reset(){this.payload&&Kt(this.payload,e=>e.reset())}_makePayload(e){if(e){const t=new Set;return Gs(e,this._addToPayload,t),Array.from(t)}}_addToPayload(e){Wd.dependencies&&is(e)&&Wd.dependencies.add(e);const t=Op(e);t&&Kt(t,n=>this.add(n))}}class u_ extends c_{constructor(e){super(e)}static create(e){return new u_(e)}getValue(){return this.source.map(e=>e.getValue())}setValue(e){const t=this.getPayload();return e.length==t.length?t.map((n,i)=>n.setValue(e[i])).some(Boolean):(super.setValue(e.map(G4)),!0)}}function G4(r){return(Up(r)?$l:rc).create(r)}function Pv(r){const e=ns(r);return e?e.constructor:Ze.arr(r)?u_:Up(r)?$l:rc}function Xd(){return Xd=Object.assign?Object.assign.bind():function(r){for(var e=1;e{const t=!Ze.fun(r)||r.prototype&&r.prototype.isReactComponent;return K.forwardRef((n,i)=>{const s=K.useRef(null),o=t&&K.useCallback(v=>{s.current=W4(i,v)},[i]),[a,l]=V4(n,e),c=IA(),u=()=>{const v=s.current;if(t&&!v)return;(v?e.applyAnimatedValues(v,a.getValue(!0)):!1)===!1&&c()},h=new H4(u,l),p=K.useRef();a_(()=>(p.current=h,Kt(l,v=>vh(v,h)),()=>{p.current&&(Kt(p.current.deps,v=>Vd(v,p.current)),xt.cancel(p.current.update))})),K.useEffect(u,[]),DA(()=>()=>{const v=p.current;Kt(v.deps,_=>Vd(_,v))});const m=e.getComponentProps(a.getValue());return K.createElement(r,Xd({},m,{ref:o}))})};class H4{constructor(e,t){this.update=e,this.deps=t}eventObserved(e){e.type=="change"&&xt.write(this.update)}}function V4(r,e){const t=new Set;return Wd.dependencies=t,r.style&&(r=Xd({},r,{style:e.createAnimatedStyle(r.style)})),r=new c_(r),Wd.dependencies=null,[r,t]}function W4(r,e){return r&&(Ze.fun(r)?r(e):r.current=e),e}const aE=Symbol.for("AnimatedComponent"),X4=(r,{applyAnimatedValues:e=()=>!1,createAnimatedStyle:t=i=>new c_(i),getComponentProps:n=i=>i}={})=>{const i={applyAnimatedValues:e,createAnimatedStyle:t,getComponentProps:n},s=o=>{const a=lE(o)||"Anonymous";return Ze.str(o)?o=s[o]||(s[o]=oE(o,i)):o=o[aE]||(o[aE]=oE(o,i)),o.displayName=`Animated(${a})`,o};return Gs(r,(o,a)=>{Ze.arr(r)&&(a=lE(o)),s[a]=s(o)}),{animated:s}},lE=r=>Ze.str(r)?r:r&&Ze.str(r.displayName)?r.displayName:Ze.fun(r)&&r.name||null;function ei(){return ei=Object.assign?Object.assign.bind():function(r){for(var e=1;er===!0||!!(e&&r&&(Ze.fun(r)?r(e):Er(r).includes(e))),OA=(r,e)=>Ze.obj(r)?e&&r[e]:r,NA=(r,e)=>r.default===!0?r[e]:r.default?r.default[e]:void 0,j4=r=>r,h_=(r,e=j4)=>{let t=Y4;r.default&&r.default!==!0&&(r=r.default,t=Object.keys(r));const n={};for(const i of t){const s=e(r[i],i);Ze.und(s)||(n[i]=s)}return n},Y4=["config","onProps","onStart","onChange","onPause","onResume","onRest"],q4={config:1,from:1,to:1,ref:1,loop:1,reset:1,pause:1,cancel:1,reverse:1,immediate:1,default:1,delay:1,onProps:1,onStart:1,onChange:1,onPause:1,onResume:1,onRest:1,onResolve:1,items:1,trail:1,sort:1,expires:1,initial:1,enter:1,update:1,leave:1,children:1,onDestroyed:1,keys:1,callId:1,parentId:1};function Z4(r){const e={};let t=0;if(Gs(r,(n,i)=>{q4[i]||(e[i]=n,t++)}),t)return e}function FA(r){const e=Z4(r);if(e){const t={to:e};return Gs(r,(n,i)=>i in e||(t[i]=n)),t}return ei({},r)}function Ku(r){return r=_r(r),Ze.arr(r)?r.map(Ku):Up(r)?us.createStringInterpolator({range:[0,1],output:[r,r]})(1):r}function K4(r){for(const e in r)return!0;return!1}function Lv(r){return Ze.fun(r)||Ze.arr(r)&&Ze.obj(r[0])}function $4(r,e){var t;(t=r.ref)==null||t.delete(r),e==null||e.delete(r)}function J4(r,e){if(e&&r.ref!==e){var t;(t=r.ref)==null||t.delete(r),e.add(r),r.ref=e}}const Q4={default:{tension:170,friction:26}},Iv=ei({},Q4.default,{mass:1,damping:1,easing:b4.linear,clamp:!1});class eG{constructor(){this.tension=void 0,this.friction=void 0,this.frequency=void 0,this.damping=void 0,this.mass=void 0,this.velocity=0,this.restVelocity=void 0,this.precision=void 0,this.progress=void 0,this.duration=void 0,this.easing=void 0,this.clamp=void 0,this.bounce=void 0,this.decay=void 0,this.round=void 0,Object.assign(this,Iv)}}function tG(r,e,t){t&&(t=ei({},t),cE(t,e),e=ei({},t,e)),cE(r,e),Object.assign(r,e);for(const o in Iv)r[o]==null&&(r[o]=Iv[o]);let{mass:n,frequency:i,damping:s}=r;return Ze.und(i)||(i<.01&&(i=.01),s<0&&(s=0),r.tension=Math.pow(2*Math.PI/i,2)*n,r.friction=4*Math.PI*s*n/i),r}function cE(r,e){if(!Ze.und(e.decay))r.duration=void 0;else{const t=!Ze.und(e.tension)||!Ze.und(e.friction);(t||!Ze.und(e.frequency)||!Ze.und(e.damping)||!Ze.und(e.mass))&&(r.duration=void 0,r.decay=void 0),t&&(r.frequency=void 0)}}const uE=[];class nG{constructor(){this.changed=!1,this.values=uE,this.toValues=null,this.fromValues=uE,this.to=void 0,this.from=void 0,this.config=new eG,this.immediate=!1}}function kA(r,{key:e,props:t,defaultProps:n,state:i,actions:s}){return new Promise((o,a)=>{var l;let c,u,h=bu((l=t.cancel)!=null?l:n==null?void 0:n.cancel,e);if(h)v();else{Ze.und(t.pause)||(i.paused=bu(t.pause,e));let _=n==null?void 0:n.pause;_!==!0&&(_=i.paused||bu(_,e)),c=ca(t.delay||0,e),_?(i.resumeQueue.add(m),s.pause()):(s.resume(),m())}function p(){i.resumeQueue.add(m),i.timeouts.delete(u),u.cancel(),c=u.time-xt.now()}function m(){c>0&&!us.skipAnimation?(i.delayed=!0,u=xt.setTimeout(v,c),i.pauseQueue.add(p),i.timeouts.add(u)):v()}function v(){i.delayed&&(i.delayed=!1),i.pauseQueue.delete(p),i.timeouts.delete(u),r<=(i.cancelId||0)&&(h=!0);try{s.start(ei({},t,{callId:r,cancel:h}),o)}catch(_){a(_)}}})}const f_=(r,e)=>e.length==1?e[0]:e.some(t=>t.cancelled)?Hl(r.get()):e.every(t=>t.noop)?zA(r.get()):Fr(r.get(),e.every(t=>t.finished)),zA=r=>({value:r,noop:!0,finished:!0,cancelled:!1}),Fr=(r,e,t=!1)=>({value:r,finished:e,cancelled:t}),Hl=r=>({value:r,cancelled:!0,finished:!1});function BA(r,e,t,n){const{callId:i,parentId:s,onRest:o}=e,{asyncTo:a,promise:l}=t;return!s&&r===a&&!e.reset?l:t.promise=(async()=>{t.asyncId=i,t.asyncTo=r;const c=h_(e,(y,g)=>g==="onRest"?void 0:y);let u,h;const p=new Promise((y,g)=>(u=y,h=g)),m=y=>{const g=i<=(t.cancelId||0)&&Hl(n)||i!==t.asyncId&&Fr(n,!1);if(g)throw y.result=g,h(y),y},v=(y,g)=>{const x=new hE,w=new fE;return(async()=>{if(us.skipAnimation)throw $u(t),w.result=Fr(n,!1),h(w),w;m(x);const E=Ze.obj(y)?ei({},y):ei({},g,{to:y});E.parentId=i,Gs(c,(M,A)=>{Ze.und(E[A])&&(E[A]=M)});const b=await n.start(E);return m(x),t.paused&&await new Promise(M=>{t.resumeQueue.add(M)}),b})()};let _;if(us.skipAnimation)return $u(t),Fr(n,!1);try{let y;Ze.arr(r)?y=(async g=>{for(const x of g)await v(x)})(r):y=Promise.resolve(r(v,n.stop.bind(n))),await Promise.all([y.then(u),p]),_=Fr(n.get(),!0,!1)}catch(y){if(y instanceof hE)_=y.result;else if(y instanceof fE)_=y.result;else throw y}finally{i==t.asyncId&&(t.asyncId=s,t.asyncTo=s?a:void 0,t.promise=s?l:void 0)}return Ze.fun(o)&&xt.batchedUpdates(()=>{o(_,n,n.item)}),_})()}function $u(r,e){Su(r.timeouts,t=>t.cancel()),r.pauseQueue.clear(),r.resumeQueue.clear(),r.asyncId=r.asyncTo=r.promise=void 0,e&&(r.cancelId=e)}class hE extends Error{constructor(){super("An async animation has been interrupted. You see this error because you forgot to use `await` or `.catch(...)` on its returned promise."),this.result=void 0}}class fE extends Error{constructor(){super("SkipAnimationSignal"),this.result=void 0}}const Dv=r=>r instanceof d_;let iG=1;class d_ extends T4{constructor(...e){super(...e),this.id=iG++,this.key=void 0,this._priority=0}get priority(){return this._priority}set priority(e){this._priority!=e&&(this._priority=e,this._onPriorityChange(e))}get(){const e=ns(this);return e&&e.getValue()}to(...e){return us.to(this,e)}interpolate(...e){return D4(),us.to(this,e)}toJSON(){return this.get()}observerAdded(e){e==1&&this._attach()}observerRemoved(e){e==0&&this._detach()}_attach(){}_detach(){}_onChange(e,t=!1){Hd(this,{type:"change",parent:this,value:e,idle:t})}_onPriorityChange(e){this.idle||Lp.sort(this),Hd(this,{type:"priority",parent:this,priority:e})}}const Ra=Symbol.for("SpringPhase"),GA=1,Uv=2,Ov=4,d0=r=>(r[Ra]&GA)>0,co=r=>(r[Ra]&Uv)>0,Zc=r=>(r[Ra]&Ov)>0,dE=(r,e)=>e?r[Ra]|=Uv|GA:r[Ra]&=~Uv,pE=(r,e)=>e?r[Ra]|=Ov:r[Ra]&=~Ov;class rG extends d_{constructor(e,t){if(super(),this.key=void 0,this.animation=new nG,this.queue=void 0,this.defaultProps={},this._state={paused:!1,delayed:!1,pauseQueue:new Set,resumeQueue:new Set,timeouts:new Set},this._pendingCalls=new Set,this._lastCallId=0,this._lastToId=0,this._memoizedDuration=0,!Ze.und(e)||!Ze.und(t)){const n=Ze.obj(e)?ei({},e):ei({},t,{from:e});Ze.und(n.default)&&(n.default=!0),this.start(n)}}get idle(){return!(co(this)||this._state.asyncTo)||Zc(this)}get goal(){return _r(this.animation.to)}get velocity(){const e=ns(this);return e instanceof rc?e.lastVelocity||0:e.getPayload().map(t=>t.lastVelocity||0)}get hasAnimated(){return d0(this)}get isAnimating(){return co(this)}get isPaused(){return Zc(this)}get isDelayed(){return this._state.delayed}advance(e){let t=!0,n=!1;const i=this.animation;let{config:s,toValues:o}=i;const a=Op(i.to);!a&&is(i.to)&&(o=Er(_r(i.to))),i.values.forEach((u,h)=>{if(u.done)return;const p=u.constructor==$l?1:a?a[h].lastPosition:o[h];let m=i.immediate,v=p;if(!m){if(v=u.lastPosition,s.tension<=0){u.done=!0;return}let _=u.elapsedTime+=e;const y=i.fromValues[h],g=u.v0!=null?u.v0:u.v0=Ze.arr(s.velocity)?s.velocity[h]:s.velocity;let x;const w=s.precision||(y==p?.005:Math.min(1,Math.abs(p-y)*.001));if(Ze.und(s.duration))if(s.decay){const E=s.decay===!0?.998:s.decay,b=Math.exp(-(1-E)*_);v=y+g/(1-E)*(1-b),m=Math.abs(u.lastPosition-v)<=w,x=g*b}else{x=u.lastVelocity==null?g:u.lastVelocity;const E=s.restVelocity||w/10,b=s.clamp?0:s.bounce,M=!Ze.und(b),A=y==p?u.v0>0:yE,!(!P&&(m=Math.abs(p-v)<=w,m)));++N){M&&(C=v==p||v>p==A,C&&(x=-x*b,v=p));const I=-s.tension*1e-6*(v-p),X=-s.friction*.001*x,q=(I+X)/s.mass;x=x+q*L,v=v+x*L}}else{let E=1;s.duration>0&&(this._memoizedDuration!==s.duration&&(this._memoizedDuration=s.duration,u.durationProgress>0&&(u.elapsedTime=s.duration*u.durationProgress,_=u.elapsedTime+=e)),E=(s.progress||0)+_/this._memoizedDuration,E=E>1?1:E<0?0:E,u.durationProgress=E),v=y+s.easing(E)*(p-y),x=(v-u.lastPosition)/e,m=E==1}u.lastVelocity=x,Number.isNaN(v)&&(console.warn("Got NaN while animating:",this),m=!0)}a&&!a[h].done&&(m=!1),m?u.done=!0:t=!1,u.setValue(v,s.round)&&(n=!0)});const l=ns(this),c=l.getValue();if(t){const u=_r(i.to);(c!==u||n)&&!s.decay?(l.setValue(u),this._onChange(u)):n&&s.decay&&this._onChange(c),this._stop()}else n&&this._onChange(c)}set(e){return xt.batchedUpdates(()=>{this._stop(),this._focus(e),this._set(e)}),this}pause(){this._update({pause:!0})}resume(){this._update({pause:!1})}finish(){if(co(this)){const{to:e,config:t}=this.animation;xt.batchedUpdates(()=>{this._onStart(),t.decay||this._set(e,!1),this._stop()})}return this}update(e){return(this.queue||(this.queue=[])).push(e),this}start(e,t){let n;return Ze.und(e)?(n=this.queue||[],this.queue=[]):n=[Ze.obj(e)?e:ei({},t,{to:e})],Promise.all(n.map(i=>this._update(i))).then(i=>f_(this,i))}stop(e){const{to:t}=this.animation;return this._focus(this.get()),$u(this._state,e&&this._lastCallId),xt.batchedUpdates(()=>this._stop(t,e)),this}reset(){this._update({reset:!0})}eventObserved(e){e.type=="change"?this._start():e.type=="priority"&&(this.priority=e.priority+1)}_prepareNode(e){const t=this.key||"";let{to:n,from:i}=e;n=Ze.obj(n)?n[t]:n,(n==null||Lv(n))&&(n=void 0),i=Ze.obj(i)?i[t]:i,i==null&&(i=void 0);const s={to:n,from:i};return d0(this)||(e.reverse&&([n,i]=[i,n]),i=_r(i),Ze.und(i)?ns(this)||this._set(n):this._set(i)),s}_update(e,t){let n=ei({},e);const{key:i,defaultProps:s}=this;n.default&&Object.assign(s,h_(n,(l,c)=>/^on/.test(c)?OA(l,i):l)),gE(this,n,"onProps"),$c(this,"onProps",n,this);const o=this._prepareNode(n);if(Object.isFrozen(this))throw Error("Cannot animate a `SpringValue` object that is frozen. Did you forget to pass your component to `animated(...)` before animating its props?");const a=this._state;return kA(++this._lastCallId,{key:i,props:n,defaultProps:s,state:a,actions:{pause:()=>{Zc(this)||(pE(this,!0),mu(a.pauseQueue),$c(this,"onPause",Fr(this,Kc(this,this.animation.to)),this))},resume:()=>{Zc(this)&&(pE(this,!1),co(this)&&this._resume(),mu(a.resumeQueue),$c(this,"onResume",Fr(this,Kc(this,this.animation.to)),this))},start:this._merge.bind(this,o)}}).then(l=>{if(n.loop&&l.finished&&!(t&&l.noop)){const c=HA(n);if(c)return this._update(c,!0)}return l})}_merge(e,t,n){if(t.cancel)return this.stop(!0),n(Hl(this));const i=!Ze.und(e.to),s=!Ze.und(e.from);if(i||s)if(t.callId>this._lastToId)this._lastToId=t.callId;else return n(Hl(this));const{key:o,defaultProps:a,animation:l}=this,{to:c,from:u}=l;let{to:h=c,from:p=u}=e;s&&!i&&(!t.default||Ze.und(h))&&(h=p),t.reverse&&([h,p]=[p,h]);const m=!Ds(p,u);m&&(l.from=p),p=_r(p);const v=!Ds(h,c);v&&this._focus(h);const _=Lv(t.to),{config:y}=l,{decay:g,velocity:x}=y;(i||s)&&(y.velocity=0),t.config&&!_&&tG(y,ca(t.config,o),t.config!==a.config?ca(a.config,o):void 0);let w=ns(this);if(!w||Ze.und(h))return n(Fr(this,!0));const E=Ze.und(t.reset)?s&&!t.default:!Ze.und(p)&&bu(t.reset,o),b=E?p:this.get(),M=Ku(h),A=Ze.num(M)||Ze.arr(M)||Up(M),P=!_&&(!A||bu(a.immediate||t.immediate,o));if(v){const N=Pv(h);if(N!==w.constructor)if(P)w=this._set(M);else throw Error(`Cannot animate between ${w.constructor.name} and ${N.name}, as the "to" prop suggests`)}const C=w.constructor;let L=is(h),F=!1;if(!L){const N=E||!d0(this)&&m;(v||N)&&(F=Ds(Ku(b),M),L=!F),(!Ds(l.immediate,P)&&!P||!Ds(y.decay,g)||!Ds(y.velocity,x))&&(L=!0)}if(F&&co(this)&&(l.changed&&!E?L=!0:L||this._stop(c)),!_&&((L||is(c))&&(l.values=w.getPayload(),l.toValues=is(h)?null:C==$l?[1]:Er(M)),l.immediate!=P&&(l.immediate=P,!P&&!E&&this._set(c)),L)){const{onRest:N}=l;Kt(oG,X=>gE(this,t,X));const I=Fr(this,Kc(this,c));mu(this._pendingCalls,I),this._pendingCalls.add(n),l.changed&&xt.batchedUpdates(()=>{l.changed=!E,N==null||N(I,this),E?ca(a.onRest,I):l.onStart==null||l.onStart(I,this)})}E&&this._set(b),_?n(BA(t.to,t,this._state,this)):L?this._start():co(this)&&!v?this._pendingCalls.add(n):n(zA(b))}_focus(e){const t=this.animation;e!==t.to&&(iE(this)&&this._detach(),t.to=e,iE(this)&&this._attach())}_attach(){let e=0;const{to:t}=this.animation;is(t)&&(vh(t,this),Dv(t)&&(e=t.priority+1)),this.priority=e}_detach(){const{to:e}=this.animation;is(e)&&Vd(e,this)}_set(e,t=!0){const n=_r(e);if(!Ze.und(n)){const i=ns(this);if(!i||!Ds(n,i.getValue())){const s=Pv(n);!i||i.constructor!=s?l_(this,s.create(n)):i.setValue(n),i&&xt.batchedUpdates(()=>{this._onChange(n,t)})}}return ns(this)}_onStart(){const e=this.animation;e.changed||(e.changed=!0,$c(this,"onStart",Fr(this,Kc(this,e.to)),this))}_onChange(e,t){t||(this._onStart(),ca(this.animation.onChange,e,this)),ca(this.defaultProps.onChange,e,this),super._onChange(e,t)}_start(){const e=this.animation;ns(this).reset(_r(e.to)),e.immediate||(e.fromValues=e.values.map(t=>t.lastPosition)),co(this)||(dE(this,!0),Zc(this)||this._resume())}_resume(){us.skipAnimation?this.finish():Lp.start(this)}_stop(e,t){if(co(this)){dE(this,!1);const n=this.animation;Kt(n.values,s=>{s.done=!0}),n.toValues&&(n.onChange=n.onPause=n.onResume=void 0),Hd(this,{type:"idle",parent:this});const i=t?Hl(this.get()):Fr(this.get(),Kc(this,e??n.to));mu(this._pendingCalls,i),n.changed&&(n.changed=!1,$c(this,"onRest",i,this))}}}function Kc(r,e){const t=Ku(e),n=Ku(r.get());return Ds(n,t)}function HA(r,e=r.loop,t=r.to){let n=ca(e);if(n){const i=n!==!0&&FA(n),s=(i||r).reverse,o=!i||i.reset;return Ju(ei({},r,{loop:e,default:!1,pause:void 0,to:!s||Lv(t)?t:void 0,from:o?r.from:void 0,reset:o},i))}}function Ju(r){const{to:e,from:t}=r=FA(r),n=new Set;return Ze.obj(e)&&mE(e,n),Ze.obj(t)&&mE(t,n),r.keys=n.size?Array.from(n):null,r}function sG(r){const e=Ju(r);return Ze.und(e.default)&&(e.default=h_(e)),e}function mE(r,e){Gs(r,(t,n)=>t!=null&&e.add(n))}const oG=["onStart","onRest","onChange","onPause","onResume"];function gE(r,e,t){r.animation[t]=e[t]!==NA(e,t)?OA(e[t],r.key):void 0}function $c(r,e,...t){var n,i,s,o;(n=(i=r.animation)[e])==null||n.call(i,...t),(s=(o=r.defaultProps)[e])==null||s.call(o,...t)}const aG=["onStart","onChange","onRest"];let lG=1;class cG{constructor(e,t){this.id=lG++,this.springs={},this.queue=[],this.ref=void 0,this._flush=void 0,this._initialProps=void 0,this._lastAsyncId=0,this._active=new Set,this._changed=new Set,this._started=!1,this._item=void 0,this._state={paused:!1,pauseQueue:new Set,resumeQueue:new Set,timeouts:new Set},this._events={onStart:new Map,onChange:new Map,onRest:new Map},this._onFrame=this._onFrame.bind(this),t&&(this._flush=t),e&&this.start(ei({default:!0},e))}get idle(){return!this._state.asyncTo&&Object.values(this.springs).every(e=>e.idle&&!e.isDelayed&&!e.isPaused)}get item(){return this._item}set item(e){this._item=e}get(){const e={};return this.each((t,n)=>e[n]=t.get()),e}set(e){for(const t in e){const n=e[t];Ze.und(n)||this.springs[t].set(n)}}update(e){return e&&this.queue.push(Ju(e)),this}start(e){let{queue:t}=this;return e?t=Er(e).map(Ju):this.queue=[],this._flush?this._flush(this,t):(YA(this,t),Nv(this,t))}stop(e,t){if(e!==!!e&&(t=e),t){const n=this.springs;Kt(Er(t),i=>n[i].stop(!!e))}else $u(this._state,this._lastAsyncId),this.each(n=>n.stop(!!e));return this}pause(e){if(Ze.und(e))this.start({pause:!0});else{const t=this.springs;Kt(Er(e),n=>t[n].pause())}return this}resume(e){if(Ze.und(e))this.start({pause:!1});else{const t=this.springs;Kt(Er(e),n=>t[n].resume())}return this}each(e){Gs(this.springs,e)}_onFrame(){const{onStart:e,onChange:t,onRest:n}=this._events,i=this._active.size>0,s=this._changed.size>0;(i&&!this._started||s&&!this._started)&&(this._started=!0,Su(e,([l,c])=>{c.value=this.get(),l(c,this,this._item)}));const o=!i&&this._started,a=s||o&&n.size?this.get():null;s&&t.size&&Su(t,([l,c])=>{c.value=a,l(c,this,this._item)}),o&&(this._started=!1,Su(n,([l,c])=>{c.value=a,l(c,this,this._item)}))}eventObserved(e){if(e.type=="change")this._changed.add(e.parent),e.idle||this._active.add(e.parent);else if(e.type=="idle")this._active.delete(e.parent);else return;xt.onFrame(this._onFrame)}}function Nv(r,e){return Promise.all(e.map(t=>VA(r,t))).then(t=>f_(r,t))}async function VA(r,e,t){const{keys:n,to:i,from:s,loop:o,onRest:a,onResolve:l}=e,c=Ze.obj(e.default)&&e.default;o&&(e.loop=!1),i===!1&&(e.to=null),s===!1&&(e.from=null);const u=Ze.arr(i)||Ze.fun(i)?i:void 0;u?(e.to=void 0,e.onRest=void 0,c&&(c.onRest=void 0)):Kt(aG,_=>{const y=e[_];if(Ze.fun(y)){const g=r._events[_];e[_]=({finished:x,cancelled:w})=>{const E=g.get(y);E?(x||(E.finished=!1),w&&(E.cancelled=!0)):g.set(y,{value:null,finished:x||!1,cancelled:w||!1})},c&&(c[_]=e[_])}});const h=r._state;e.pause===!h.paused?(h.paused=e.pause,mu(e.pause?h.pauseQueue:h.resumeQueue)):h.paused&&(e.pause=!0);const p=(n||Object.keys(r.springs)).map(_=>r.springs[_].start(e)),m=e.cancel===!0||NA(e,"cancel")===!0;(u||m&&h.asyncId)&&p.push(kA(++r._lastAsyncId,{props:e,state:h,actions:{pause:Av,resume:Av,start(_,y){m?($u(h,r._lastAsyncId),y(Hl(r))):(_.onRest=a,y(BA(u,_,h,r)))}}})),h.paused&&await new Promise(_=>{h.resumeQueue.add(_)});const v=f_(r,await Promise.all(p));if(o&&v.finished&&!(t&&v.noop)){const _=HA(e,o,i);if(_)return YA(r,[_]),VA(r,_,!0)}return l&&xt.batchedUpdates(()=>l(v,r,r.item)),v}function vE(r,e){const t=ei({},r.springs);return e&&Kt(Er(e),n=>{Ze.und(n.keys)&&(n=Ju(n)),Ze.obj(n.to)||(n=ei({},n,{to:void 0})),jA(t,n,i=>XA(i))}),WA(r,t),t}function WA(r,e){Gs(e,(t,n)=>{r.springs[n]||(r.springs[n]=t,vh(t,r))})}function XA(r,e){const t=new rG;return t.key=r,e&&vh(t,e),t}function jA(r,e,t){e.keys&&Kt(e.keys,n=>{(r[n]||(r[n]=t(n)))._prepareNode(e)})}function YA(r,e){Kt(e,t=>{jA(r.springs,t,n=>XA(n,r))})}function uG(r,e){if(r==null)return{};var t={},n=Object.keys(r),i,s;for(s=0;s=0)&&(t[i]=r[i]);return t}const hG=["children"],Np=r=>{let{children:e}=r,t=uG(r,hG);const n=K.useContext(jd),i=t.pause||!!n.pause,s=t.immediate||!!n.immediate;t=F4(()=>({pause:i,immediate:s}),[i,s]);const{Provider:o}=jd;return K.createElement(o,{value:t},e)},jd=fG(Np,{});Np.Provider=jd.Provider;Np.Consumer=jd.Consumer;function fG(r,e){return Object.assign(r,K.createContext(e)),r.Provider._context=r,r.Consumer._context=r,r}const dG=()=>{const r=[],e=function(i){O4();const s=[];return Kt(r,(o,a)=>{if(Ze.und(i))s.push(o.start());else{const l=t(i,o,a);l&&s.push(o.start(l))}}),s};e.current=r,e.add=function(n){r.includes(n)||r.push(n)},e.delete=function(n){const i=r.indexOf(n);~i&&r.splice(i,1)},e.pause=function(){return Kt(r,n=>n.pause(...arguments)),this},e.resume=function(){return Kt(r,n=>n.resume(...arguments)),this},e.set=function(n){Kt(r,i=>i.set(n))},e.start=function(n){const i=[];return Kt(r,(s,o)=>{if(Ze.und(n))i.push(s.start());else{const a=this._getProps(n,s,o);a&&i.push(s.start(a))}}),i},e.stop=function(){return Kt(r,n=>n.stop(...arguments)),this},e.update=function(n){return Kt(r,(i,s)=>i.update(this._getProps(n,i,s))),this};const t=function(i,s,o){return Ze.fun(i)?i(o,s):i};return e._getProps=t,e};function pG(r,e,t){const n=Ze.fun(e)&&e;n&&!t&&(t=[]);const i=K.useMemo(()=>n||arguments.length==3?dG():void 0,[]),s=K.useRef(0),o=IA(),a=K.useMemo(()=>({ctrls:[],queue:[],flush(g,x){const w=vE(g,x);return s.current>0&&!a.queue.length&&!Object.keys(w).some(b=>!g.springs[b])?Nv(g,x):new Promise(b=>{WA(g,w),a.queue.push(()=>{b(Nv(g,x))}),o()})}}),[]),l=K.useRef([...a.ctrls]),c=[],u=sE(r)||0;K.useMemo(()=>{Kt(l.current.slice(r,u),g=>{$4(g,i),g.stop(!0)}),l.current.length=r,h(u,r)},[r]),K.useMemo(()=>{h(0,Math.min(u,r))},t);function h(g,x){for(let w=g;wvE(g,c[x])),m=K.useContext(Np),v=sE(m),_=m!==v&&K4(m);a_(()=>{s.current++,a.ctrls=l.current;const{queue:g}=a;g.length&&(a.queue=[],Kt(g,x=>x())),Kt(l.current,(x,w)=>{i==null||i.add(x),_&&x.start({default:m});const E=c[w];E&&(J4(x,E.ref),x.ref?x.queue.push(E):x.start(E))})}),DA(()=>()=>{Kt(a.ctrls,g=>g.stop(!0))});const y=p.map(g=>ei({},g));return i?[y,i]:y}function tr(r,e){const t=Ze.fun(r),[[n],i]=pG(1,t?r:[r],t?e||[]:e);return t||arguments.length==2?[n,i]:n}let yE;(function(r){r.MOUNT="mount",r.ENTER="enter",r.UPDATE="update",r.LEAVE="leave"})(yE||(yE={}));class mG extends d_{constructor(e,t){super(),this.key=void 0,this.idle=!0,this.calc=void 0,this._active=new Set,this.source=e,this.calc=qu(...t);const n=this._get(),i=Pv(n);l_(this,i.create(n))}advance(e){const t=this._get(),n=this.get();Ds(t,n)||(ns(this).setValue(t),this._onChange(t,this.idle)),!this.idle&&_E(this._active)&&p0(this)}_get(){const e=Ze.arr(this.source)?this.source.map(_r):Er(_r(this.source));return this.calc(...e)}_start(){this.idle&&!_E(this._active)&&(this.idle=!1,Kt(Op(this),e=>{e.done=!1}),us.skipAnimation?(xt.batchedUpdates(()=>this.advance()),p0(this)):Lp.start(this))}_attach(){let e=1;Kt(Er(this.source),t=>{is(t)&&vh(t,this),Dv(t)&&(t.idle||this._active.add(t),e=Math.max(e,t.priority+1))}),this.priority=e,this._start()}_detach(){Kt(Er(this.source),e=>{is(e)&&Vd(e,this)}),this._active.clear(),p0(this)}eventObserved(e){e.type=="change"?e.idle?this.advance():(this._active.add(e.parent),this._start()):e.type=="idle"?this._active.delete(e.parent):e.type=="priority"&&(this.priority=Er(this.source).reduce((t,n)=>Math.max(t,(Dv(n)?n.priority:0)+1),0))}}function gG(r){return r.idle!==!1}function _E(r){return!r.size||Array.from(r).every(gG)}function p0(r){r.idle||(r.idle=!0,Kt(Op(r),e=>{e.done=!0}),Hd(r,{type:"idle",parent:r}))}us.assign({createStringInterpolator:PA,to:(r,e)=>new mG(r,e)});const vG=["primitive"].concat(Object.keys(uT).filter(r=>/^[A-Z]/.test(r)).map(r=>r[0].toLowerCase()+r.slice(1)));us.assign({createStringInterpolator:PA,colors:f4,frameLoop:"demand"});pO(()=>{xt.advance()});const yG=X4(vG,{applyAnimatedValues:oa}),An=yG.animated,od=(r,e)=>{const t=r[0].index!==null,n=new Set(Object.keys(r[0].attributes)),i=new Set(Object.keys(r[0].morphAttributes)),s={},o={},a=r[0].morphTargetsRelative,l=new Tt;let c=0;if(r.forEach((u,h)=>{let p=0;if(t!==(u.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+h+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(let m in u.attributes){if(!n.has(m))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+h+'. All geometries must have compatible attributes; make sure "'+m+'" attribute exists among all geometries, or in none of them.'),null;s[m]===void 0&&(s[m]=[]),s[m].push(u.attributes[m]),p++}if(p!==n.size)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+h+". Make sure all geometries have the same number of attributes."),null;if(a!==u.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+h+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(let m in u.morphAttributes){if(!i.has(m))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+h+". .morphAttributes must be consistent throughout all geometries."),null;o[m]===void 0&&(o[m]=[]),o[m].push(u.morphAttributes[m])}if(l.userData.mergedUserData=l.userData.mergedUserData||[],l.userData.mergedUserData.push(u.userData),e){let m;if(u.index)m=u.index.count;else if(u.attributes.position!==void 0)m=u.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+h+". The geometry must have either an index or a position attribute"),null;l.addGroup(c,m,h),c+=m}}),t){let u=0;const h=[];r.forEach(p=>{const m=p.index;for(let v=0;v{let e,t,n,i=0;if(r.forEach(s=>{if(e===void 0&&(e=s.array.constructor),e!==s.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(t===void 0&&(t=s.itemSize),t!==s.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(n===void 0&&(n=s.normalized),n!==s.normalized)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;i+=s.array.length}),e&&t){const s=new e(i);let o=0;return r.forEach(a=>{s.set(a.array,o),o+=a.array.length}),new $t(s,t,n)}},m0=new oh,g0=new Y,Ml=new Y,Dr=new Y,Ps=new Y,Qr=new Y,Ls=new Y,Is=new Y,Jc=new Y,Qc=new Y,eu=new Y,ad=new Y,tu=new Y,nu=new Y,iu=new Y;class wE{constructor(e,t,n){this.camera=e,this.scene=t,this.startPoint=new Y,this.endPoint=new Y,this.collection=[],this.deep=n||Number.MAX_VALUE}select(e,t){return this.startPoint=e||this.startPoint,this.endPoint=t||this.endPoint,this.collection=[],this.updateFrustum(this.startPoint,this.endPoint),this.searchChildInFrustum(m0,this.scene),this.collection}updateFrustum(e,t){if(e=e||this.startPoint,t=t||this.endPoint,e.x===t.x&&(t.x+=Number.EPSILON),e.y===t.y&&(t.y+=Number.EPSILON),this.camera.updateProjectionMatrix(),this.camera.updateMatrixWorld(),this.camera.isPerspectiveCamera){Ml.copy(e),Ml.x=Math.min(e.x,t.x),Ml.y=Math.max(e.y,t.y),t.x=Math.max(e.x,t.x),t.y=Math.min(e.y,t.y),Dr.setFromMatrixPosition(this.camera.matrixWorld),Ps.copy(Ml),Qr.set(t.x,Ml.y,0),Ls.copy(t),Is.set(Ml.x,t.y,0),Ps.unproject(this.camera),Qr.unproject(this.camera),Ls.unproject(this.camera),Is.unproject(this.camera),tu.copy(Ps).sub(Dr),nu.copy(Qr).sub(Dr),iu.copy(Ls).sub(Dr),tu.normalize(),nu.normalize(),iu.normalize(),tu.multiplyScalar(this.deep),nu.multiplyScalar(this.deep),iu.multiplyScalar(this.deep),tu.add(Dr),nu.add(Dr),iu.add(Dr);var n=m0.planes;n[0].setFromCoplanarPoints(Dr,Ps,Qr),n[1].setFromCoplanarPoints(Dr,Qr,Ls),n[2].setFromCoplanarPoints(Ls,Is,Dr),n[3].setFromCoplanarPoints(Is,Ps,Dr),n[4].setFromCoplanarPoints(Qr,Ls,Is),n[5].setFromCoplanarPoints(iu,nu,tu),n[5].normal.multiplyScalar(-1)}else if(this.camera.isOrthographicCamera){const i=Math.min(e.x,t.x),s=Math.max(e.y,t.y),o=Math.max(e.x,t.x),a=Math.min(e.y,t.y);Ps.set(i,s,-1),Qr.set(o,s,-1),Ls.set(o,a,-1),Is.set(i,a,-1),Jc.set(i,s,1),Qc.set(o,s,1),eu.set(o,a,1),ad.set(i,a,1),Ps.unproject(this.camera),Qr.unproject(this.camera),Ls.unproject(this.camera),Is.unproject(this.camera),Jc.unproject(this.camera),Qc.unproject(this.camera),eu.unproject(this.camera),ad.unproject(this.camera);var n=m0.planes;n[0].setFromCoplanarPoints(Ps,Jc,Qc),n[1].setFromCoplanarPoints(Qr,Qc,eu),n[2].setFromCoplanarPoints(eu,ad,Is),n[3].setFromCoplanarPoints(ad,Jc,Ps),n[4].setFromCoplanarPoints(Qr,Ls,Is),n[5].setFromCoplanarPoints(eu,Qc,Jc),n[5].normal.multiplyScalar(-1)}else console.error("THREE.SelectionBox: Unsupported camera type.")}searchChildInFrustum(e,t){if((t.isMesh||t.isLine||t.isPoints)&&t.material!==void 0&&(t.geometry.boundingSphere===null&&t.geometry.computeBoundingSphere(),g0.copy(t.geometry.boundingSphere.center),g0.applyMatrix4(t.matrixWorld),e.containsPoint(g0)&&this.collection.push(t)),t.children.length>0)for(let n=0;n{if(!t||!c.current)return;const p=c.current.rotation.clone();c.current.updateMatrix(),c.current.updateWorldMatrix(!1,!1),c.current.getWorldQuaternion(u),h.getWorldQuaternion(l.current.quaternion).premultiply(u.invert()),n&&(c.current.rotation.x=p.x),i&&(c.current.rotation.y=p.y),s&&(c.current.rotation.z=p.z)}),K.useImperativeHandle(a,()=>c.current,[]),K.createElement("group",Ta({ref:c,matrixAutoUpdate:!1,matrixWorldAutoUpdate:!1},o),K.createElement("group",{ref:l},e))});function _G(){var r=Object.create(null);function e(i,s){var o=i.id,a=i.name,l=i.dependencies;l===void 0&&(l=[]);var c=i.init;c===void 0&&(c=function(){});var u=i.getTransferables;if(u===void 0&&(u=null),!r[o])try{l=l.map(function(p){return p&&p.isWorkerModule&&(e(p,function(m){if(m instanceof Error)throw m}),p=r[p.id].value),p}),c=n("<"+a+">.init",c),u&&(u=n("<"+a+">.getTransferables",u));var h=null;typeof c=="function"?h=c.apply(void 0,l):console.error("worker module init function failed to rehydrate"),r[o]={id:o,value:h,getTransferables:u},s(h)}catch(p){p&&p.noLog||console.error(p),s(p)}}function t(i,s){var o,a=i.id,l=i.args;(!r[a]||typeof r[a].value!="function")&&s(new Error("Worker module "+a+": not found or its 'init' did not return a function"));try{var c=(o=r[a]).value.apply(o,l);c&&typeof c.then=="function"?c.then(u,function(h){return s(h instanceof Error?h:new Error(""+h))}):u(c)}catch(h){s(h)}function u(h){try{var p=r[a].getTransferables&&r[a].getTransferables(h);(!p||!Array.isArray(p)||!p.length)&&(p=void 0),s(h,p)}catch(m){console.error(m),s(m)}}}function n(i,s){var o=void 0;self.troikaDefine=function(l){return o=l};var a=URL.createObjectURL(new Blob(["/** "+i.replace(/\*/g,"")+` **/ troikaDefine( `+s+` )`],{type:"application/javascript"}));try{importScripts(a)}catch(l){console.error(l)}return URL.revokeObjectURL(a),delete self.troikaDefine,o}self.addEventListener("message",function(i){var s=i.data,o=s.messageId,a=s.action,l=s.data;try{a==="registerModule"&&e(l,function(c){c instanceof Error?postMessage({messageId:o,success:!1,error:c.message}):postMessage({messageId:o,success:!0,result:{isCallable:typeof c=="function"}})}),a==="callModule"&&t(l,function(c,u){c instanceof Error?postMessage({messageId:o,success:!1,error:c.message}):postMessage({messageId:o,success:!0,result:c},u||void 0)})}catch(c){postMessage({messageId:o,success:!1,error:c.stack})}})}function xG(r){var e=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];return e._getInitResult().then(function(i){if(typeof i=="function")return i.apply(void 0,t);throw new Error("Worker module function was called but `init` did not return a callable function")})};return e._getInitResult=function(){var t=r.dependencies,n=r.init;t=Array.isArray(t)?t.map(function(s){return s&&s._getInitResult?s._getInitResult():s}):[];var i=Promise.all(t).then(function(s){return n.apply(null,s)});return e._getInitResult=function(){return i},i},e}var ZA=function(){var r=!1;if(typeof window<"u"&&typeof window.document<"u")try{var e=new Worker(URL.createObjectURL(new Blob([""],{type:"application/javascript"})));e.terminate(),r=!0}catch(t){console.log("Troika createWorkerModule: web workers not allowed; falling back to main thread execution. Cause: ["+t.message+"]")}return ZA=function(){return r},r},wG=0,SG=0,v0=!1,Mu=Object.create(null),Tu=Object.create(null),Fv=Object.create(null);function yh(r){if((!r||typeof r.init!="function")&&!v0)throw new Error("requires `options.init` function");var e=r.dependencies,t=r.init,n=r.getTransferables,i=r.workerId;if(!ZA())return xG(r);i==null&&(i="#default");var s="workerModule"+ ++wG,o=r.name||s,a=null;e=e&&e.map(function(c){return typeof c=="function"&&!c.workerModuleData&&(v0=!0,c=yh({workerId:i,name:"<"+o+"> function dependency: "+c.name,init:`function(){return ( `+Rd(c)+` )}`}),v0=!1),c&&c.workerModuleData&&(c=c.workerModuleData),c});function l(){for(var c=[],u=arguments.length;u--;)c[u]=arguments[u];if(!a){a=SE(i,"registerModule",l.workerModuleData);var h=function(){a=null,Tu[i].delete(h)};(Tu[i]||(Tu[i]=new Set)).add(h)}return a.then(function(p){var m=p.isCallable;if(m)return SE(i,"callModule",{id:s,args:c});throw new Error("Worker module function was called but `init` did not return a callable function")})}return l.workerModuleData={isWorkerModule:!0,id:s,name:o,dependencies:e,init:Rd(t),getTransferables:n&&Rd(n)},l}function EG(r){Tu[r]&&Tu[r].forEach(function(e){e()}),Mu[r]&&(Mu[r].terminate(),delete Mu[r])}function Rd(r){var e=r.toString();return!/^function/.test(e)&&/^\w+\s*\(/.test(e)&&(e="function "+e),e}function bG(r){var e=Mu[r];if(!e){var t=Rd(_G);e=Mu[r]=new Worker(URL.createObjectURL(new Blob(["/** Worker Module Bootstrap: "+r.replace(/\*/g,"")+` **/ ;(`+t+")()"],{type:"application/javascript"}))),e.onmessage=function(n){var i=n.data,s=i.messageId,o=Fv[s];if(!o)throw new Error("WorkerModule response with empty or unknown messageId");delete Fv[s],o(i)}}return e}function SE(r,e,t){return new Promise(function(n,i){var s=++SG;Fv[s]=function(o){o.success?n(o.result):i(new Error("Error in worker "+e+" call: "+o.error))},bG(r).postMessage({messageId:s,action:e,data:t})})}function KA(){var r=(function(e){function t(G,B,D,V,Z,ee,ie,ue){var ce=1-ie;ue.x=ce*ce*G+2*ce*ie*D+ie*ie*Z,ue.y=ce*ce*B+2*ce*ie*V+ie*ie*ee}function n(G,B,D,V,Z,ee,ie,ue,ce,le){var Ae=1-ce;le.x=Ae*Ae*Ae*G+3*Ae*Ae*ce*D+3*Ae*ce*ce*Z+ce*ce*ce*ie,le.y=Ae*Ae*Ae*B+3*Ae*Ae*ce*V+3*Ae*ce*ce*ee+ce*ce*ce*ue}function i(G,B){for(var D=/([MLQCZ])([^MLQCZ]*)/g,V,Z,ee,ie,ue;V=D.exec(G);){var ce=V[2].replace(/^\s*|\s*$/g,"").split(/[,\s]+/).map(function(le){return parseFloat(le)});switch(V[1]){case"M":ie=Z=ce[0],ue=ee=ce[1];break;case"L":(ce[0]!==ie||ce[1]!==ue)&&B("L",ie,ue,ie=ce[0],ue=ce[1]);break;case"Q":{B("Q",ie,ue,ie=ce[2],ue=ce[3],ce[0],ce[1]);break}case"C":{B("C",ie,ue,ie=ce[4],ue=ce[5],ce[0],ce[1],ce[2],ce[3]);break}case"Z":(ie!==Z||ue!==ee)&&B("L",ie,ue,Z,ee);break}}}function s(G,B,D){D===void 0&&(D=16);var V={x:0,y:0};i(G,function(Z,ee,ie,ue,ce,le,Ae,Ee,ae){switch(Z){case"L":B(ee,ie,ue,ce);break;case"Q":{for(var z=ee,oe=ie,te=1;te0;)be[Me]=arguments[Me+2];var Fe=Le[we]||(Le[we]=D.getUniformLocation(ge,we));D["uniform"+ne].apply(D,[Fe].concat(be))},setAttribute:function(ne,we,be,Me,Fe){var Ue=Se[ne];Ue||(Ue=Se[ne]={buf:D.createBuffer(),loc:D.getAttribLocation(ge,ne),data:null}),D.bindBuffer(D.ARRAY_BUFFER,Ue.buf),D.vertexAttribPointer(Ue.loc,we,D.FLOAT,!1,0,0),D.enableVertexAttribArray(Ue.loc),Z?D.vertexAttribDivisor(Ue.loc,Me):Ae("ANGLE_instanced_arrays").vertexAttribDivisorANGLE(Ue.loc,Me),Fe!==Ue.data&&(D.bufferData(D.ARRAY_BUFFER,Fe,be),Ue.data=Fe)}})}}}ie[se].transaction(de)},z=function(se,$){ce++;try{D.activeTexture(D.TEXTURE0+ce);var Ie=ue[se];Ie||(Ie=ue[se]=D.createTexture(),D.bindTexture(D.TEXTURE_2D,Ie),D.texParameteri(D.TEXTURE_2D,D.TEXTURE_MIN_FILTER,D.NEAREST),D.texParameteri(D.TEXTURE_2D,D.TEXTURE_MAG_FILTER,D.NEAREST)),D.bindTexture(D.TEXTURE_2D,Ie),$(Ie,ce)}finally{ce--}},oe=function(se,$,Ie){var de=D.createFramebuffer();le.push(de),D.bindFramebuffer(D.FRAMEBUFFER,de),D.activeTexture(D.TEXTURE0+$),D.bindTexture(D.TEXTURE_2D,se),D.framebufferTexture2D(D.FRAMEBUFFER,D.COLOR_ATTACHMENT0,D.TEXTURE_2D,se,0);try{Ie(de)}finally{D.deleteFramebuffer(de),D.bindFramebuffer(D.FRAMEBUFFER,le[--le.length-1]||null)}},te=function(){ee={},ie={},ue={},ce=-1,le.length=0};var Z=typeof WebGL2RenderingContext<"u"&&D instanceof WebGL2RenderingContext,ee={},ie={},ue={},ce=-1,le=[];D.canvas.addEventListener("webglcontextlost",function(se){te(),se.preventDefault()},!1),l.set(D,V={gl:D,isWebGL2:Z,getExtension:Ae,withProgram:ae,withTexture:z,withTextureFramebuffer:oe,handleContextLoss:te})}B(V)}function h(G,B,D,V,Z,ee,ie,ue){ie===void 0&&(ie=15),ue===void 0&&(ue=null),u(G,function(ce){var le=ce.gl,Ae=ce.withProgram,Ee=ce.withTexture;Ee("copy",function(ae,z){le.texImage2D(le.TEXTURE_2D,0,le.RGBA,Z,ee,0,le.RGBA,le.UNSIGNED_BYTE,B),Ae("copy",o,a,function(oe){var te=oe.setUniform,se=oe.setAttribute;se("aUV",2,le.STATIC_DRAW,0,new Float32Array([0,0,2,0,0,2])),te("1i","image",z),le.bindFramebuffer(le.FRAMEBUFFER,ue||null),le.disable(le.BLEND),le.colorMask(ie&8,ie&4,ie&2,ie&1),le.viewport(D,V,Z,ee),le.scissor(D,V,Z,ee),le.drawArrays(le.TRIANGLES,0,3)})})})}function p(G,B,D){var V=G.width,Z=G.height;u(G,function(ee){var ie=ee.gl,ue=new Uint8Array(V*Z*4);ie.readPixels(0,0,V,Z,ie.RGBA,ie.UNSIGNED_BYTE,ue),G.width=B,G.height=D,h(ie,ue,0,0,V,Z)})}var m=Object.freeze({__proto__:null,withWebGLContext:u,renderImageData:h,resizeWebGLCanvasWithoutClearing:p});function v(G,B,D,V,Z,ee){ee===void 0&&(ee=1);var ie=new Uint8Array(G*B),ue=V[2]-V[0],ce=V[3]-V[1],le=[];s(D,function(se,$,Ie,de){le.push({x1:se,y1:$,x2:Ie,y2:de,minX:Math.min(se,Ie),minY:Math.min($,de),maxX:Math.max(se,Ie),maxY:Math.max($,de)})}),le.sort(function(se,$){return se.maxX-$.maxX});for(var Ae=0;AeLe.minX&&$-deLe.minY){var ge=g(se,$,Le.x1,Le.y1,Le.x2,Le.y2);ge$!=Se.y2>$&&se<(Se.x2-Se.x1)*($-Se.y1)/(Se.y2-Se.y1)+Se.x1;Le&&(Ie+=Se.y1p.y!=seg.w>p.y)&&(p.x<(seg.z-seg.x)*(p.y-seg.y)/(seg.w-seg.y)+seg.x);bool crossingUp=crossing&&vLineSegment.y1,1e>2,u>2,2wt>1,1>1,1ge>1,1wp>1,1j>1,f>1,hm>1,1>1,u>1,u6>1,1>1,+5,28>1,w>1,1>1,+3,b8>1,1>1,+3,1>3,-1>-1,3>1,1>1,+2,1s>1,1>1,x>1,th>1,1>1,+2,db>1,1>1,+3,3>1,1>1,+2,14qm>1,1>1,+1,4q>1,1e>2,u>2,2>1,+1",canonical:"6f1>-6dx,6dy>-6dx,6ec>-6ed,6ee>-6ed,6ww>2jj,-2ji>2jj,14r4>-1e7l,1e7m>-1e7l,1e7m>-1e5c,1e5d>-1e5b,1e5c>-14qx,14qy>-14qx,14vn>-1ecg,1ech>-1ecg,1edu>-1ecg,1eci>-1ecg,1eda>-1ecg,1eci>-1ecg,1eci>-168q,168r>-168q,168s>-14ye,14yf>-14ye"};function _(de,Se){var Le=36,ge=0,He=new Map,j=Se&&new Map,H;return de.split(",").forEach(function ne(we){if(we.indexOf("+")!==-1)for(var be=+we;be--;)ne(H);else{H=we;var Me=we.split(">"),Fe=Me[0],Ue=Me[1];Fe=String.fromCodePoint(ge+=parseInt(Fe,Le)),Ue=String.fromCodePoint(ge+=parseInt(Ue,Le)),He.set(Fe,Ue),Se&&j.set(Ue,Fe)}}),{map:He,reverseMap:j}}var y,g,x;function w(){if(!y){var de=_(v.pairs,!0),Se=de.map,Le=de.reverseMap;y=Se,g=Le,x=_(v.canonical,!1).map}}function E(de){return w(),y.get(de)||null}function b(de){return w(),g.get(de)||null}function M(de){return w(),x.get(de)||null}var A=n.L,P=n.R,C=n.EN,L=n.ES,F=n.ET,N=n.AN,I=n.CS,X=n.B,q=n.S,W=n.ON,O=n.BN,k=n.NSM,G=n.AL,B=n.LRO,D=n.RLO,V=n.LRE,Z=n.RLE,ee=n.PDF,ie=n.LRI,ue=n.RLI,ce=n.FSI,le=n.PDI;function Ae(de,Se){for(var Le=125,ge=new Uint32Array(de.length),He=0;He0)We--;else if(pt>0){for(nt=0;!Ve[Ve.length-1]._isolate;)Ve.pop();var _t=Ve[Ve.length-1]._isolInitIndex;_t!=null&&(we.set(_t,re),we.set(re,_t)),Ve.pop(),pt--}Oe=Ve[Ve.length-1],ne[re]=Oe._level,Oe._override&&H(re,Oe._override)}else ze&ee?(We===0&&(nt>0?nt--:!Oe._isolate&&Ve.length>1&&(Ve.pop(),Oe=Ve[Ve.length-1])),ne[re]=Oe._level):ze&X&&(ne[re]=Me.level);else ne[re]=Oe._level,Oe._override&&ze!==O&&H(re,Oe._override)}for(var It=[],Ft=null,Ot=Me.start;Ot<=Me.end;Ot++){var Yt=ge[Ot];if(!(Yt&l)){var Nt=ne[Ot],Rt=Yt&s,li=Yt===le;Ft&&Nt===Ft._level?(Ft._end=Ot,Ft._endsWithIsolInit=Rt):It.push(Ft={_start:Ot,_end:Ot,_level:Nt,_startsWithPDI:li,_endsWithIsolInit:Rt})}}for(var jn=[],Bt=0;Bt=0;pe--)if(!(ge[pe]&l)){Re=ne[pe];break}var Pe=Gn[Gn.length-1],it=ne[Pe],lt=Me.level;if(!(ge[Pe]&s)){for(var ct=Pe+1;ct<=Me.end;ct++)if(!(ge[ct]&l)){lt=ne[ct];break}}jn.push({_seqIndices:Gn,_sosType:Math.max(Re,me)%2?P:A,_eosType:Math.max(lt,it)%2?P:A})}}for(var dt=0;dt=0;mt--)if(!(ge[ke[mt]]&l)){qt=ge[ke[mt]];break}H(ci,qt&(s|le)?W:qt)}}if(j.get(C))for(var kt=0;kt=-1;Cn--){var En=Cn===-1?ut:ge[ke[Cn]];if(En&o){En===G&&H(gt,N);break}}}if(j.get(G))for(var cn=0;cn=0&&(xi=ge[ke[Xr]],!!(xi&l));Xr--);for(var jr=Qt+1;jr=0&&ge[ke[Oa]]&(F|l);Oa--)H(ke[Oa],C);for(ui++;ui=0&&ge[ke[fs]]&l;fs--)H(ke[fs],W);for(var ds=Ro+1;ds=0;gs--){var Fa=Ys[gs].char;if(Fa===oc||Fa===b(M(Ut))||E(M(Fa))===Ut){Yr.push([Ys[gs].seqIndex,qr]),Ys.length=gs;break}}}Yr.sort(function(Zn,bi){return Zn[0]-bi[0]})}for(var ac=0;ac=0;cc--){var bh=ke[cc];if(ge[bh]&Na){var Xi=ge[bh]&ms?P:A;Xi!==Gt?wi=Xi:wi=Gt;break}}}if(wi){if(ge[ke[pn]]=ge[ke[Lo]]=wi,wi!==Gt){for(var Si=pn+1;Si=0;Do--)if(ge[ke[Do]]&l)uc=Do;else{Di=ge[ke[Do]]&ms?P:A;break}for(var Uo=Jt,Oo=or+1;Oo=0&&p(de[qs])&c;qs--)ne[qs]=Me.level}}return{levels:ne,paragraphs:be};function za(Zn,bi){for(var Rn=Zn;Rn=ne&&p(de[Me])&c;Me--)be[Me]=H.level;for(var Fe=H.level,Ue=1/0,xe=0;xeFe&&(Fe=Be),Be=Ue;$e--)for(var Ve=0;Ve=$e){for(var Oe=Ve;Ve+1=$e;)Ve++;Ve>Oe&&j.push([Oe+ne,Ve+ne])}}}),j}function $(de,Se,Le,ge){var He=Ie(de,Se,Le,ge),j=[].concat(de);return He.forEach(function(H,ne){j[ne]=(Se.levels[H]&1?oe(de[H]):null)||de[H]}),j.join("")}function Ie(de,Se,Le,ge){for(var He=se(de,Se,Le,ge),j=[],H=0;H/gm;function t(n,i){let s=bt[i];return s?kv(s):n}return r.replace(e,t)}const ii=[];for(let r=0;r<256;r++)ii[r]=(r<16?"0":"")+r.toString(16);function TG(){const r=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(ii[r&255]+ii[r>>8&255]+ii[r>>16&255]+ii[r>>24&255]+"-"+ii[e&255]+ii[e>>8&255]+"-"+ii[e>>16&15|64]+ii[e>>24&255]+"-"+ii[t&63|128]+ii[t>>8&255]+"-"+ii[t>>16&255]+ii[t>>24&255]+ii[n&255]+ii[n>>8&255]+ii[n>>16&255]+ii[n>>24&255]).toUpperCase()}const na=Object.assign||function(){let r=arguments[0];for(let e=1,t=arguments.length;e/gm,` //!BEGIN_POST_CHUNK $1 $& //!END_POST_CHUNK `),t=kv(t)),m){let _=m({vertexShader:e,fragmentShader:t});e=_.vertexShader,t=_.fragmentShader}if(p){let _=[];t=t.replace(/^\/\/!BEGIN_POST_CHUNK[^]+?^\/\/!END_POST_CHUNK/gm,y=>(_.push(y),"")),h=`${p} ${_.join(` `)} ${h}`}if(v){const _=` uniform float ${v}; `;s=_+s,c=_+c}return l&&(e=`vec3 troika_position_${i}; vec3 troika_normal_${i}; vec2 troika_uv_${i}; ${e} `,s=`${s} void troikaVertexTransform${i}(inout vec3 position, inout vec3 normal, inout vec2 uv) { ${l} } `,o=` troika_position_${i} = vec3(position); troika_normal_${i} = vec3(normal); troika_uv_${i} = vec2(uv); troikaVertexTransform${i}(troika_position_${i}, troika_normal_${i}, troika_uv_${i}); ${o} `,e=e.replace(/\b(position|normal|uv)\b/g,(_,y,g,x)=>/\battribute\s+vec[23]\s+$/.test(x.substr(0,g))?y:`troika_${y}_${i}`),r.map&&r.map.channel>0||(e=e.replace(/\bMAP_UV\b/g,`troika_uv_${i}`))),e=ME(e,i,s,o,a),t=ME(t,i,c,u,h),{vertexShader:e,fragmentShader:t}}function ME(r,e,t,n,i){return(n||i||t)&&(r=r.replace($A,` ${t} void troikaOrigMain${e}() {`),r+=` void main() { ${n} troikaOrigMain${e}(); ${i} }`),r}function PG(r,e){return r==="uniforms"?void 0:typeof e=="function"?e.toString():e}let LG=0;const TE=new Map;function IG(r){const e=JSON.stringify(r,PG);let t=TE.get(e);return t==null&&TE.set(e,t=++LG),t}function DG(r,e,t){const{defaultFontURL:n}=t,i=Object.create(null),s=1/0,o=/[\u00AD\u034F\u061C\u115F-\u1160\u17B4-\u17B5\u180B-\u180E\u200B-\u200F\u202A-\u202E\u2060-\u206F\u3164\uFE00-\uFE0F\uFEFF\uFFA0\uFFF0-\uFFF8]/,a="[^\\S\\u00A0]",l=new RegExp(`${a}|[\\-\\u007C\\u00AD\\u2010\\u2012-\\u2014\\u2027\\u2056\\u2E17\\u2E40]`);function c(x,w){function E(){const b=M=>{console.error(`Failure loading font ${x}${x===n?"":"; trying fallback"}`,M),x!==n&&(x=n,E())};try{const M=new XMLHttpRequest;M.open("get",x,!0),M.responseType="arraybuffer",M.onload=function(){if(M.status>=400)b(new Error(M.statusText));else if(M.status>0)try{const A=r(M.response);w(A)}catch(A){b(A)}},M.onerror=b,M.send()}catch(M){b(M)}}E()}function u(x,w){x||(x=n);let E=i[x];E?E.pending?E.pending.push(w):w(E):(i[x]={pending:[w]},c(x,b=>{let M=i[x].pending;i[x]=b,M.forEach(A=>A(b))}))}function h({text:x="",font:w=n,sdfGlyphSize:E=64,fontSize:b=1,letterSpacing:M=0,lineHeight:A="normal",maxWidth:P=s,direction:C,textAlign:L="left",textIndent:F=0,whiteSpace:N="normal",overflowWrap:I="normal",anchorX:X=0,anchorY:q=0,includeCaretPositions:W=!1,chunkedBoundsSize:O=8192,colorRanges:k=null},G,B=!1){const D=_(),V={fontLoad:0,typesetting:0};x.indexOf("\r")>-1&&(console.info("Typesetter: got text with \\r chars; normalizing to \\n"),x=x.replace(/\r\n/g,` `).replace(/\r/g,` `)),b=+b,M=+M,P=+P,A=A||"normal",F=+F,u(w,Z=>{const ee=isFinite(P);let ie=null,ue=null,ce=null,le=null,Ae=null,Ee=null,ae=null,z=0,oe=0,te=N!=="nowrap";const{ascender:se,descender:$,unitsPerEm:Ie,lineGap:de,capHeight:Se,xHeight:Le}=Z;V.fontLoad=_()-D;const ge=_(),He=b/Ie;A==="normal"&&(A=(se-$+de)/Ie),A=A*b;const j=(A-(se-$)*He)/2,H=-(se*He+j),ne=Math.min(A,(se-$)*He),we=(se+$)/2*He-ne/2;let be=F,Me=new y;const Fe=[Me];Z.forEachGlyph(x,b,M,(Be,$e,Ve)=>{const Oe=x.charAt(Ve),We=Be.advanceWidth*He,nt=Me.count;let pt;if("isEmpty"in Be||(Be.isWhitespace=!!Oe&&new RegExp(a).test(Oe),Be.canBreakAfter=!!Oe&&l.test(Oe),Be.isEmpty=Be.xMin===Be.xMax||Be.yMin===Be.yMax||o.test(Oe)),!Be.isWhitespace&&!Be.isEmpty&&oe++,te&&ee&&!Be.isWhitespace&&$e+We+be>P&&nt){if(Me.glyphAt(nt-1).glyphObj.canBreakAfter)pt=new y,be=-$e;else for(let ze=nt;ze--;)if(ze===0&&I==="break-word"){pt=new y,be=-$e;break}else if(Me.glyphAt(ze).glyphObj.canBreakAfter){pt=Me.splitAt(ze+1);const ve=pt.glyphAt(0).x;be-=ve;for(let Ge=pt.count;Ge--;)pt.glyphAt(Ge).x-=ve;break}pt&&(Me.isSoftWrapped=!0,Me=pt,Fe.push(Me),z=P)}let re=Me.glyphAt(Me.count);re.glyphObj=Be,re.x=$e+be,re.width=We,re.charIndex=Ve,Oe===` `&&(Me=new y,Fe.push(Me),be=-($e+We+M*b)+F)}),Fe.forEach(Be=>{for(let $e=Be.count;$e--;){let{glyphObj:Ve,x:Oe,width:We}=Be.glyphAt($e);if(!Ve.isWhitespace){Be.width=Oe+We,Be.width>z&&(z=Be.width);return}}});let Ue=0,xe=0;if(X&&(typeof X=="number"?Ue=-X:typeof X=="string"&&(Ue=-z*(X==="left"?0:X==="center"?.5:X==="right"?1:m(X)))),q){if(typeof q=="number")xe=-q;else if(typeof q=="string"){let Be=Fe.length*A;xe=q==="top"?0:q==="top-baseline"?-H:q==="top-cap"?-H-Se*He:q==="top-ex"?-H-Le*He:q==="middle"?Be/2:q==="bottom"?Be:q==="bottom-baseline"?Be-j+$*He:m(q)*Be}}if(!B){const Be=e.getEmbeddingLevels(x,C);ie=new Uint16Array(oe),ue=new Float32Array(oe*2),ce={},Ee=[s,s,-s,-s],ae=[];let $e=H;W&&(Ae=new Float32Array(x.length*3)),k&&(le=new Uint8Array(oe*3));let Ve=0,Oe=-1,We=-1,nt,pt;if(Fe.forEach((re,ze)=>{let{count:ve,width:Ge}=re;if(ve>0){let Ye=0;for(let Nt=ve;Nt--&&re.glyphAt(Nt).glyphObj.isWhitespace;)Ye++;let _t=0,It=0;if(L==="center")_t=(z-Ge)/2;else if(L==="right")_t=z-Ge;else if(L==="justify"&&re.isSoftWrapped){let Nt=0;for(let Rt=ve-Ye;Rt--;)re.glyphAt(Rt).glyphObj.isWhitespace&&Nt++;It=(z-Ge)/Nt}if(It||_t){let Nt=0;for(let Rt=0;Rt=Rt){let ti=sn,tn=sn;for(;tnli)break;tnOt=Nt;for(let Nt=0;Nt1&&v(Ae,Oe,tn),Oe=Bt}if(k){const{charIndex:Bt}=Rt;for(;Bt>We;)We++,k.hasOwnProperty(We)&&(pt=k[We])}if(!Ot.isWhitespace&&!Ot.isEmpty){const Bt=Ve++;ce[li]||(ce[li]={path:Ot.path,pathBounds:[Ot.xMin,Ot.yMin,Ot.xMax,Ot.yMax]});const sn=Rt.x+Ue,ti=$e+xe;ue[Bt*2]=sn,ue[Bt*2+1]=ti;const tn=sn+Ot.xMin*He,dn=ti+Ot.yMin*He,Gn=sn+Ot.xMax*He,sr=ti+Ot.yMax*He;tnEe[2]&&(Ee[2]=Gn),sr>Ee[3]&&(Ee[3]=sr),Bt%O===0&&(nt={start:Bt,end:Bt,rect:[s,s,-s,-s]},ae.push(nt)),nt.end++;const _i=nt.rect;if(tn<_i[0]&&(_i[0]=tn),dn<_i[1]&&(_i[1]=dn),Gn>_i[2]&&(_i[2]=Gn),sr>_i[3]&&(_i[3]=sr),ie[Bt]=li,k){const J=Bt*3;le[J]=pt>>16&255,le[J+1]=pt>>8&255,le[J+2]=pt&255}}}}$e-=A}),Ae){const re=x.length-Oe;re>1&&v(Ae,Oe,re)}}V.typesetting=_()-ge,G({glyphIds:ie,glyphPositions:ue,glyphData:ce,caretPositions:Ae,caretHeight:ne,glyphColors:le,chunkedBounds:ae,fontSize:b,unitsPerEm:Ie,ascender:se*He,descender:$*He,capHeight:Se*He,xHeight:Le*He,lineHeight:A,topBaseline:H,blockBounds:[Ue,xe-Fe.length*A,Ue+z,xe],visibleBounds:Ee,timings:V})})}function p(x,w){h(x,E=>{const[b,M,A,P]=E.blockBounds;w({width:A-b,height:P-M})},{})}function m(x){let w=x.match(/^([\d.]+)%$/),E=w?parseFloat(w[1]):NaN;return isNaN(E)?0:E/100}function v(x,w,E){const b=x[w*3],M=x[w*3+1],A=x[w*3+2],P=(M-b)/E;for(let C=0;C(Object.defineProperty(x,w,{get(){return this.data[this.index*g.length+E]},set(M){this.data[this.index*g.length+E]=M}}),x),{data:null,index:0}),{typeset:h,measure:p,loadFont:u}}const _a=()=>(self.performance||Date).now(),Fp=KA();let AE;function UG(r,e,t,n,i,s,o,a,l,c,u=!0){return u?NG(r,e,t,n,i,s,o,a,l,c).then(null,h=>(AE||(console.warn("WebGL SDF generation failed, falling back to JS",h),AE=!0),RE(r,e,t,n,i,s,o,a,l,c))):RE(r,e,t,n,i,s,o,a,l,c)}const Pd=[],OG=5;let Bv=0;function JA(){const r=_a();for(;Pd.length&&_a()-rnew Promise((e,t)=>{Pd.push(()=>{const n=_a();try{Fp.webgl.generateIntoCanvas(...r),e({timing:_a()-n})}catch(i){t(i)}}),Bv||(Bv=setTimeout(JA,0))}),FG=4,kG=2e3,CE={};let zG=0;function RE(r,e,t,n,i,s,o,a,l,c){const u="TroikaTextSDFGenerator_JS_"+zG++%FG;let h=CE[u];return h||(h=CE[u]={workerModule:yh({name:u,workerId:u,dependencies:[KA,_a],init(p,m){const v=p().javascript.generate;return function(..._){const y=m();return{textureData:v(..._),timing:m()-y}}},getTransferables(p){return[p.textureData.buffer]}}),requests:0,idleTimer:null}),h.requests++,clearTimeout(h.idleTimer),h.workerModule(r,e,t,n,i,s).then(({textureData:p,timing:m})=>{const v=_a(),_=new Uint8Array(p.length*4);for(let y=0;y{EG(u)},kG)),{timing:m}})}function BG(r){r._warm||(Fp.webgl.isSupported(r),r._warm=!0)}const GG=Fp.webglUtils.resizeWebGLCanvasWithoutClearing;/*! Custom build of Typr.ts (https://github.com/fredli74/Typr.ts) for use in Troika text rendering. Original MIT license applies: https://github.com/fredli74/Typr.ts/blob/master/LICENSE */function HG(){return typeof window>"u"&&(self.window=self),(function(r){var e={parse:function(i){var s=e._bin,o=new Uint8Array(i);if(s.readASCII(o,0,4)=="ttcf"){var a=4;s.readUshort(o,a),a+=2,s.readUshort(o,a),a+=2;var l=s.readUint(o,a);a+=4;for(var c=[],u=0;u>>o&1)!=0&&s++;return s},e._lctf.readClassDef=function(i,s){var o=e._bin,a=[],l=o.readUshort(i,s);if(s+=2,l==1){var c=o.readUshort(i,s);s+=2;var u=o.readUshort(i,s);s+=2;for(var h=0;h0&&(l.featureParams=a+c);var u=o.readUshort(i,s);s+=2,l.tab=[];for(var h=0;h255?-1:e.CFF.glyphByUnicode(i,e.CFF.tableSE[s])},e.CFF.readEncoding=function(i,s,o){e._bin;var a=[".notdef"],l=i[s];if(s++,l!=0)throw"error: unknown encoding format: "+l;var c=i[s];s++;for(var u=0;u>4,x=15&y;if(g!=15&&_.push(g),x!=15&&_.push(x),x==15)break}for(var w="",E=[0,1,2,3,4,5,6,7,8,9,".","e","e-","reserved","-","endOfNumber"],b=0;b<_.length;b++)w+=E[_[b]];v=parseFloat(w)}u<=21&&(m=["version","Notice","FullName","FamilyName","Weight","FontBBox","BlueValues","OtherBlues","FamilyBlues","FamilyOtherBlues","StdHW","StdVW","escape","UniqueID","XUID","charset","Encoding","CharStrings","Private","Subrs","defaultWidthX","nominalWidthX"][u],p=1,u==12&&(m=["Copyright","isFixedPitch","ItalicAngle","UnderlinePosition","UnderlineThickness","PaintType","CharstringType","FontMatrix","StrokeWidth","BlueScale","BlueShift","BlueFuzz","StemSnapH","StemSnapV","ForceBold",0,0,"LanguageGroup","ExpansionFactor","initialRandomSeed","SyntheticBase","PostScript","BaseFontName","BaseFontBlend",0,0,0,0,0,0,"ROS","CIDFontVersion","CIDFontRevision","CIDFontType","CIDCount","UIDBase","FDArray","FDSelect","FontName"][h],p=2)),m!=null?(l[m]=c.length==1?c[0]:c,c=[]):c.push(v),s+=p}return l},e.cmap={},e.cmap.parse=function(i,s,o){i=new Uint8Array(i.buffer,s,o),s=0;var a=e._bin,l={};a.readUshort(i,s),s+=2;var c=a.readUshort(i,s);s+=2;var u=[];l.tables=[];for(var h=0;h=c.xMax||c.yMin>=c.yMax)return null;if(c.noc>0){c.endPts=[];for(var u=0;u=1&&u.fmt<=2){p=l.readUshort(i,o),o+=2;var v=l.readUshort(i,o);o+=2,m=e._lctf.numOfOnes(p);var _=e._lctf.numOfOnes(v);if(u.fmt==1){u.pairsets=[];var y=l.readUshort(i,o);o+=2;for(var g=0;g=1&&u.fmt<=2){if(u.fmt==1)u.delta=l.readShort(i,o),o+=2;else if(u.fmt==2){var p=l.readUshort(i,o);o+=2,u.newg=l.readUshorts(i,o,p),o+=2*u.newg.length}}else if(s==4){u.vals=[],p=l.readUshort(i,o),o+=2;for(var m=0;m>>8;if((v&=15)!=0)throw"unknown kern table format: "+v;s=e.kern.readFormat0(i,s,h)}return h},e.kern.parseV1=function(i,s,o,a){var l=e._bin;l.readFixed(i,s),s+=4;var c=l.readUint(i,s);s+=4;for(var u={glyph1:[],rval:[]},h=0;h>>8;if((m&=15)!=0)throw"unknown kern table format: "+m;s=e.kern.readFormat0(i,s,u)}return u},e.kern.readFormat0=function(i,s,o){var a=e._bin,l=-1,c=a.readUshort(i,s);s+=2,a.readUshort(i,s),s+=2,a.readUshort(i,s),s+=2,a.readUshort(i,s),s+=2;for(var u=0;u=l.map.length?0:l.map[s];if(l.format==4){for(var c=-1,u=0;us?0:65535&(l.idRangeOffset[c]!=0?l.glyphIdArray[s-l.startCount[c]+(l.idRangeOffset[c]>>1)-(l.idRangeOffset.length-c)]:s+l.idDelta[c])}if(l.format==12){if(s>l.groups[l.groups.length-1][1])return 0;for(u=0;u-1?e.U._simpleGlyph(a,o):e.U._compoGlyph(a,s,o))},e.U._simpleGlyph=function(i,s){for(var o=0;ol)){for(var y=!0,g=0,x=0;x<_;x++){for(;i[s+g+(1+x)]==-1;)g++;v.chain[x]!=i[s+g+(1+x)]&&(y=!1)}if(y){for(i[s]=v.nglyph,x=0;x<_+g;x++)i[s+x+1]=-1;break}}}else if(o.ltype==5&&h.fmt==2)for(var w=e._lctf.getInterval(h.cDef,i[s]),E=h.cDef[w+2],b=h.scset[E],M=0;Ml)){for(y=!0,x=0;x>1,c.length=0,h=!0;else if(N=="o3"||N=="o23")c.length%2!=0&&!h&&(p=c.shift()+a.nominalWidthX),u+=c.length>>1,c.length=0,h=!0;else if(N=="o4")c.length>1&&!h&&(p=c.shift()+a.nominalWidthX,h=!0),m&&e.U.P.closePath(l),y+=c.pop(),e.U.P.moveTo(l,_,y),m=!0;else if(N=="o5")for(;c.length>0;)_+=c.shift(),y+=c.shift(),e.U.P.lineTo(l,_,y);else if(N=="o6"||N=="o7")for(var I=c.length,X=N=="o6",q=0;qMath.abs(P-y)?_=A+c.shift():y=P+c.shift(),e.U.P.curveTo(l,g,x,w,E,C,L),e.U.P.curveTo(l,b,M,A,P,_,y));else if(N=="o14"){if(c.length>0&&!h&&(p=c.shift()+o.nominalWidthX,h=!0),c.length==4){var k=c.shift(),G=c.shift(),B=c.shift(),D=c.shift(),V=e.CFF.glyphBySE(o,B),Z=e.CFF.glyphBySE(o,D);e.U._drawCFF(o.CharStrings[V],s,o,a,l),s.x=k,s.y=G,e.U._drawCFF(o.CharStrings[Z],s,o,a,l)}m&&(e.U.P.closePath(l),m=!1)}else if(N=="o19"||N=="o20")c.length%2!=0&&!h&&(p=c.shift()+a.nominalWidthX),u+=c.length>>1,c.length=0,h=!0,v+=u+7>>3;else if(N=="o21")c.length>2&&!h&&(p=c.shift()+a.nominalWidthX,h=!0),y+=c.pop(),_+=c.pop(),m&&e.U.P.closePath(l),e.U.P.moveTo(l,_,y),m=!0;else if(N=="o22")c.length>1&&!h&&(p=c.shift()+a.nominalWidthX,h=!0),_+=c.pop(),m&&e.U.P.closePath(l),e.U.P.moveTo(l,_,y),m=!0;else if(N=="o25"){for(;c.length>6;)_+=c.shift(),y+=c.shift(),e.U.P.lineTo(l,_,y);g=_+c.shift(),x=y+c.shift(),w=g+c.shift(),E=x+c.shift(),_=w+c.shift(),y=E+c.shift(),e.U.P.curveTo(l,g,x,w,E,_,y)}else if(N=="o26")for(c.length%2&&(_+=c.shift());c.length>0;)g=_,x=y+c.shift(),_=w=g+c.shift(),y=(E=x+c.shift())+c.shift(),e.U.P.curveTo(l,g,x,w,E,_,y);else if(N=="o27")for(c.length%2&&(y+=c.shift());c.length>0;)x=y,w=(g=_+c.shift())+c.shift(),E=x+c.shift(),_=w+c.shift(),y=E,e.U.P.curveTo(l,g,x,w,E,_,y);else if(N=="o10"||N=="o29"){var ee=N=="o10"?a:o;if(c.length==0)console.debug("error: empty stack");else{var ie=c.pop(),ue=ee.Subrs[ie+ee.Bias];s.x=_,s.y=y,s.nStems=u,s.haveWidth=h,s.width=p,s.open=m,e.U._drawCFF(ue,s,o,a,l),_=s.x,y=s.y,u=s.nStems,h=s.haveWidth,p=s.width,m=s.open}}else if(N=="o30"||N=="o31"){var ce=c.length,le=(O=0,N=="o31");for(O+=ce-(I=-3&ce);O>>1|(21845&m)<<1;v=(61680&(v=(52428&v)>>>2|(13107&v)<<2))>>>4|(3855&v)<<4,p[m]=((65280&v)>>>8|(255&v)<<8)>>>1}var _=function(N,I,X){for(var q=N.length,W=0,O=new t(I);W>>B]=D}return k},y=new e(288);for(m=0;m<144;++m)y[m]=8;for(m=144;m<256;++m)y[m]=9;for(m=256;m<280;++m)y[m]=7;for(m=280;m<288;++m)y[m]=8;var g=new e(32);for(m=0;m<32;++m)g[m]=5;var x=_(y,9),w=_(g,5),E=function(N){for(var I=N[0],X=1;XI&&(I=N[X]);return I},b=function(N,I,X){var q=I/8|0;return(N[q]|N[q+1]<<8)>>(7&I)&X},M=function(N,I){var X=I/8|0;return(N[X]|N[X+1]<<8|N[X+2]<<16)>>(7&I)},A=["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"],P=function(N,I,X){var q=new Error(I||A[N]);if(q.code=N,Error.captureStackTrace&&Error.captureStackTrace(q,P),!X)throw q;return q},C=function(N,I,X){var q=N.length;if(!q||X&&!X.l&&q<5)return I||new e(0);var W=!I||X,O=!X||X.i;X||(X={}),I||(I=new e(3*q));var k,G=function(Oe){var We=I.length;if(Oe>We){var nt=new e(Math.max(2*We,Oe));nt.set(I),I=nt}},B=X.f||0,D=X.p||0,V=X.b||0,Z=X.l,ee=X.d,ie=X.m,ue=X.n,ce=8*q;do{if(!Z){X.f=B=b(N,D,1);var le=b(N,D+1,3);if(D+=3,!le){var Ae=N[(Le=((k=D)/8|0)+(7&k&&1)+4)-4]|N[Le-3]<<8,Ee=Le+Ae;if(Ee>q){O&&P(0);break}W&&G(V+Ae),I.set(N.subarray(Le,Ee),V),X.b=V+=Ae,X.p=D=8*Ee;continue}if(le==1)Z=x,ee=w,ie=9,ue=5;else if(le==2){var ae=b(N,D,31)+257,z=b(N,D+10,15)+4,oe=ae+b(N,D+5,31)+1;D+=14;for(var te=new e(oe),se=new e(19),$=0;$>>4)<16)te[$++]=Le;else{var He=0,j=0;for(Le==16?(j=3+b(N,D,3),D+=2,He=te[$-1]):Le==17?(j=3+b(N,D,7),D+=3):Le==18&&(j=11+b(N,D,127),D+=7);j--;)te[$++]=He}}var H=te.subarray(0,ae),ne=te.subarray(ae);ie=E(H),ue=E(ne),Z=_(H,ie),ee=_(ne,ue)}else P(1);if(D>ce){O&&P(0);break}}W&&G(V+131072);for(var we=(1<>>4;if((D+=15&He)>ce){O&&P(0);break}if(He||P(2),Fe<256)I[V++]=Fe;else{if(Fe==256){Me=D,Z=null;break}var Ue=Fe-254;if(Fe>264){var xe=i[$=Fe-257];Ue=b(N,D,(1<>>4;if(Be||P(3),D+=15&Be,ne=h[$e],$e>3&&(xe=s[$e],ne+=M(N,D)&(1<ce){O&&P(0);break}W&&G(V+131072);for(var Ve=V+Ue;VOe.length)&&(nt=Oe.length);var pt=new(Oe instanceof t?t:Oe instanceof n?n:e)(nt-We);return pt.set(Oe.subarray(We,nt)),pt})(I,0,V)},L=new e(0),F=typeof TextDecoder<"u"&&new TextDecoder;try{F.decode(L,{stream:!0})}catch{}return r.convert_streams=function(N){var I=new DataView(N),X=0;function q(){var ae=I.getUint16(X);return X+=2,ae}function W(){var ae=I.getUint32(X);return X+=4,ae}function O(ae){Ae.setUint16(Ee,ae),Ee+=2}function k(ae){Ae.setUint32(Ee,ae),Ee+=4}for(var G={signature:W(),flavor:W(),length:W(),numTables:q(),reserved:q(),totalSfntSize:W(),majorVersion:q(),minorVersion:q(),metaOffset:W(),metaLength:W(),metaOrigLength:W(),privOffset:W(),privLength:W()},B=0;Math.pow(2,B)<=G.numTables;)B++;B--;for(var D=16*Math.pow(2,B),V=16*G.numTables-D,Z=12,ee=[],ie=0;ie{let[L,F]=C.split("+");L=parseInt(L,36),F=F?parseInt(F,36):0,u.set(P+=L,M[A]);for(let N=F;N--;)u.set(++P,M[A])})}}return u.get(b)||c}const p=1,m=2,v=3,_=4,y=[null,"isol","init","fina","medi"];function g(b){const M=new Uint8Array(b.length);let A=c,P=p,C=-1;for(let L=0;L65535&&L++)}return M}function x(b,M){const A=[];for(let C=0;C65535&&C++,A.push(r.U.codeToGlyph(b,L))}const P=b.GSUB;if(P){const{lookupList:C,featureList:L}=P;let F;const N=/^(rlig|liga|mset|isol|init|fina|medi|half|pres|blws)$/,I=[];L.forEach(X=>{if(N.test(X.tag))for(let q=0;q{if(D!==-1){let Z=M[D];if(!Z){const{cmds:ee,crds:ie}=r.U.glyphToPath(b,D);let ue="",ce=0;for(let z=0,oe=ee.length;z1?",":"")+ie[ce++]}let le,Ae,Ee,ae;if(ie.length){le=Ae=1/0,Ee=ae=-1/0;for(let z=0,oe=ie.length;zEe&&(Ee=te),se>ae&&(ae=se)}}else le=Ee=Ae=ae=0;Z=M[D]={index:D,advanceWidth:b.hmtx.aWidth[D],xMin:le,yMin:Ae,xMax:Ee,yMax:ae,path:ue,pathCommandCount:ee.length}}B!==-1&&(W+=r.U.getPairAdjustment(b,B,D)*O),q.call(null,Z,W,G),Z.advanceWidth&&(W+=Z.advanceWidth*O),X&&(W+=X*I),B=D}G+=N.codePointAt(G)>65535?2:1}),W}};return F}return function(M){const A=new Uint8Array(M,0,4),P=r._bin.readASCII(A,0,4);if(P==="wOFF")M=e(M);else if(P==="wOF2")throw new Error("woff2 fonts not supported");return E(r.parse(M)[0])}}const XG=yh({name:"Typr Font Parser",dependencies:[HG,VG,WG],init(r,e,t){const n=r(),i=e();return t(n,i)}}),kl={defaultFontURL:"https://fonts.gstatic.com/s/roboto/v18/KFOmCnqEu92Fr1Mu4mxM.woff",sdfGlyphSize:64,sdfMargin:1/16,sdfExponent:9,textureWidth:2048},jG=new Ke;function Tl(){return(self.performance||Date).now()}const PE=Object.create(null);function QA(r,e){r=ZG({},r);const t=Tl();if(r.font=KG(r.font||kl.defaultFontURL),r.text=""+r.text,r.sdfGlyphSize=r.sdfGlyphSize||kl.sdfGlyphSize,r.colorRanges!=null){let h={};for(let p in r.colorRanges)if(r.colorRanges.hasOwnProperty(p)){let m=r.colorRanges[p];typeof m!="number"&&(m=jG.set(m).getHex()),h[p]=m}r.colorRanges=h}Object.freeze(r);const{textureWidth:n,sdfExponent:i}=kl,{sdfGlyphSize:s}=r,o=n/s*4;let a=PE[s];if(!a){const h=document.createElement("canvas");h.width=n,h.height=s*256/o,a=PE[s]={glyphCount:0,sdfGlyphSize:s,sdfCanvas:h,sdfTexture:new Sn(h,void 0,void 0,void 0,fn,fn),contextLost:!1,glyphsByFont:new Map},a.sdfTexture.generateMipmaps=!1,YG(a)}const{sdfTexture:l,sdfCanvas:c}=a;let u=a.glyphsByFont.get(r.font);u||a.glyphsByFont.set(r.font,u=new Map),JG(r).then(h=>{const{glyphIds:p,glyphPositions:m,fontSize:v,unitsPerEm:_,timings:y}=h,g=[],x=new Float32Array(p.length*4),w=v/_;let E=0,b=0;const M=Tl();p.forEach((F,N)=>{let I=u.get(F);if(!I){const{path:O,pathBounds:k}=h.glyphData[F],G=Math.max(k[2]-k[0],k[3]-k[1])/s*(kl.sdfMargin*s+.5),B=a.glyphCount++,D=[k[0]-G,k[1]-G,k[2]+G,k[3]+G];u.set(F,I={path:O,atlasIndex:B,sdfViewBox:D}),g.push(I)}const{sdfViewBox:X}=I,q=m[b++],W=m[b++];x[E++]=q+X[0]*w,x[E++]=W+X[1]*w,x[E++]=q+X[2]*w,x[E++]=W+X[3]*w,p[N]=I.atlasIndex}),y.quads=(y.quads||0)+(Tl()-M);const A=Tl();y.sdf={};const P=c.height,C=Math.ceil(a.glyphCount/o),L=Math.pow(2,Math.ceil(Math.log2(C*s)));L>P&&(console.info(`Increasing SDF texture size ${P}->${L}`),GG(c,n,L),l.dispose()),Promise.all(g.map(F=>e2(F,a,r.gpuAccelerateSDF).then(({timing:N})=>{y.sdf[F.atlasIndex]=N}))).then(()=>{g.length&&!a.contextLost&&(t2(a),l.needsUpdate=!0),y.sdfTotal=Tl()-A,y.total=Tl()-t,e(Object.freeze({parameters:r,sdfTexture:l,sdfGlyphSize:s,sdfExponent:i,glyphBounds:x,glyphAtlasIndices:p,glyphColors:h.glyphColors,caretPositions:h.caretPositions,caretHeight:h.caretHeight,chunkedBounds:h.chunkedBounds,ascender:h.ascender,descender:h.descender,lineHeight:h.lineHeight,capHeight:h.capHeight,xHeight:h.xHeight,topBaseline:h.topBaseline,blockBounds:h.blockBounds,visibleBounds:h.visibleBounds,timings:h.timings}))})}),Promise.resolve().then(()=>{a.contextLost||BG(c)})}function e2({path:r,atlasIndex:e,sdfViewBox:t},{sdfGlyphSize:n,sdfCanvas:i,contextLost:s},o){if(s)return Promise.resolve({timing:-1});const{textureWidth:a,sdfExponent:l}=kl,c=Math.max(t[2]-t[0],t[3]-t[1]),u=Math.floor(e/4),h=u%(a/n)*n,p=Math.floor(u/(a/n))*n,m=e%4;return UG(n,n,r,t,c,l,i,h,p,m,o)}function YG(r){const e=r.sdfCanvas;e.addEventListener("webglcontextlost",t=>{console.log("Context Lost",t),t.preventDefault(),r.contextLost=!0}),e.addEventListener("webglcontextrestored",t=>{console.log("Context Restored",t),r.contextLost=!1;const n=[];r.glyphsByFont.forEach(i=>{i.forEach(s=>{n.push(e2(s,r,!0))})}),Promise.all(n).then(()=>{t2(r),r.sdfTexture.needsUpdate=!0})})}function qG({font:r,characters:e,sdfGlyphSize:t},n){let i=Array.isArray(e)?e.join(` `):""+e;QA({font:r,sdfGlyphSize:t,text:i},n)}function ZG(r,e){for(let t in e)e.hasOwnProperty(t)&&(r[t]=e[t]);return r}let ld;function KG(r){return ld||(ld=typeof document>"u"?{}:document.createElement("a")),ld.href=r,ld.href}function t2(r){if(typeof createImageBitmap!="function"){console.info("Safari<15: applying SDF canvas workaround");const{sdfCanvas:e,sdfTexture:t}=r,{width:n,height:i}=e,s=r.sdfCanvas.getContext("webgl");let o=t.image.data;(!o||o.length!==n*i*4)&&(o=new Uint8Array(n*i*4),t.image={width:n,height:i,data:o},t.flipY=!1,t.isDataTexture=!0),s.readPixels(0,0,n,i,s.RGBA,s.UNSIGNED_BYTE,o)}}const $G=yh({name:"Typesetter",dependencies:[kl,XG,DG,MG],init(r,e,t,n){const{defaultFontURL:i}=r;return t(e,n(),{defaultFontURL:i})}}),JG=yh({name:"Typesetter",dependencies:[$G],init(r){return function(e){return new Promise(t=>{r.typeset(e,t)})}},getTransferables(r){const e=[r.glyphPositions.buffer,r.glyphIds.buffer];return r.caretPositions&&e.push(r.caretPositions.buffer),r.glyphColors&&e.push(r.glyphColors.buffer),e}}),LE={};function QG(r){let e=LE[r];if(!e){const t=new To(1,1,r,r),n=t.clone(),i=t.attributes,s=n.attributes,o=new Tt,a=i.uv.count;for(let l=0;l{o.setAttribute(l,new st([...i[l].array,...s[l].array],i[l].itemSize))}),o.setIndex([...t.index.array,...n.index.array.map(l=>l+a)]),o.translate(.5,.5,0),e=LE[r]=o}return e}const e5="aTroikaGlyphBounds",IE="aTroikaGlyphIndex",t5="aTroikaGlyphColor";class n5 extends Cy{constructor(){super(),this.detail=1,this.curveRadius=0,this.groups=[{start:0,count:1/0,materialIndex:0},{start:0,count:1/0,materialIndex:1}],this.boundingSphere=new rr,this.boundingBox=new ir}computeBoundingSphere(){}computeBoundingBox(){}setSide(e){const t=this.getIndex().count;this.setDrawRange(e===yi?t/2:0,e===vn?t:t/2)}set detail(e){if(e!==this._detail){this._detail=e,(typeof e!="number"||e<1)&&(e=1);let t=QG(e);["position","normal","uv"].forEach(n=>{this.attributes[n]=t.attributes[n].clone()}),this.setIndex(t.getIndex().clone())}}get detail(){return this._detail}set curveRadius(e){e!==this._curveRadius&&(this._curveRadius=e,this._updateBounds())}get curveRadius(){return this._curveRadius}updateGlyphs(e,t,n,i,s){y0(this,e5,e,4),y0(this,IE,t,1),y0(this,t5,s,3),this._blockBounds=n,this._chunkedBounds=i,this.instanceCount=t.length,this._updateBounds()}_updateBounds(){const e=this._blockBounds;if(e){const{curveRadius:t,boundingBox:n}=this;if(t){const{PI:i,floor:s,min:o,max:a,sin:l,cos:c}=Math,u=i/2,h=i*2,p=Math.abs(t),m=e[0]/p,v=e[2]/p,_=s((m+u)/h)!==s((v+u)/h)?-p:o(l(m)*p,l(v)*p),y=s((m-u)/h)!==s((v-u)/h)?p:a(l(m)*p,l(v)*p),g=s((m+i)/h)!==s((v+i)/h)?p*2:a(p-c(m)*p,p-c(v)*p);n.min.set(_,e[1],t<0?-g:0),n.max.set(y,e[3],t<0?0:g)}else n.min.set(e[0],e[1],0),n.max.set(e[2],e[3],0);n.getBoundingSphere(this.boundingSphere)}}applyClipRect(e){let t=this.getAttribute(IE).count,n=this._chunkedBounds;if(n)for(let i=n.length;i--;){t=n[i].end;let s=n[i].rect;if(s[1]e.y&&s[0]e.x)break}this.instanceCount=t}}function y0(r,e,t,n){const i=r.getAttribute(e);t?i&&i.array.length===t.length?(i.array.set(t),i.needsUpdate=!0):(r.setAttribute(e,new Sa(t,n)),delete r._maxInstanceCount,r.dispose()):i&&r.deleteAttribute(e)}const i5=` uniform vec2 uTroikaSDFTextureSize; uniform float uTroikaSDFGlyphSize; uniform vec4 uTroikaTotalBounds; uniform vec4 uTroikaClipRect; uniform mat3 uTroikaOrient; uniform bool uTroikaUseGlyphColors; uniform float uTroikaDistanceOffset; uniform float uTroikaBlurRadius; uniform vec2 uTroikaPositionOffset; uniform float uTroikaCurveRadius; attribute vec4 aTroikaGlyphBounds; attribute float aTroikaGlyphIndex; attribute vec3 aTroikaGlyphColor; varying vec2 vTroikaGlyphUV; varying vec4 vTroikaTextureUVBounds; varying float vTroikaTextureChannel; varying vec3 vTroikaGlyphColor; varying vec2 vTroikaGlyphDimensions; `,r5=` vec4 bounds = aTroikaGlyphBounds; bounds.xz += uTroikaPositionOffset.x; bounds.yw -= uTroikaPositionOffset.y; vec4 outlineBounds = vec4( bounds.xy - uTroikaDistanceOffset - uTroikaBlurRadius, bounds.zw + uTroikaDistanceOffset + uTroikaBlurRadius ); vec4 clippedBounds = vec4( clamp(outlineBounds.xy, uTroikaClipRect.xy, uTroikaClipRect.zw), clamp(outlineBounds.zw, uTroikaClipRect.xy, uTroikaClipRect.zw) ); vec2 clippedXY = (mix(clippedBounds.xy, clippedBounds.zw, position.xy) - bounds.xy) / (bounds.zw - bounds.xy); position.xy = mix(bounds.xy, bounds.zw, clippedXY); uv = (position.xy - uTroikaTotalBounds.xy) / (uTroikaTotalBounds.zw - uTroikaTotalBounds.xy); float rad = uTroikaCurveRadius; if (rad != 0.0) { float angle = position.x / rad; position.xz = vec2(sin(angle) * rad, rad - cos(angle) * rad); normal.xz = vec2(sin(angle), cos(angle)); } position = uTroikaOrient * position; normal = uTroikaOrient * normal; vTroikaGlyphUV = clippedXY.xy; vTroikaGlyphDimensions = vec2(bounds[2] - bounds[0], bounds[3] - bounds[1]); float txCols = uTroikaSDFTextureSize.x / uTroikaSDFGlyphSize; vec2 txUvPerSquare = uTroikaSDFGlyphSize / uTroikaSDFTextureSize; vec2 txStartUV = txUvPerSquare * vec2( mod(floor(aTroikaGlyphIndex / 4.0), txCols), floor(floor(aTroikaGlyphIndex / 4.0) / txCols) ); vTroikaTextureUVBounds = vec4(txStartUV, vec2(txStartUV) + txUvPerSquare); vTroikaTextureChannel = mod(aTroikaGlyphIndex, 4.0); `,s5=` uniform sampler2D uTroikaSDFTexture; uniform vec2 uTroikaSDFTextureSize; uniform float uTroikaSDFGlyphSize; uniform float uTroikaSDFExponent; uniform float uTroikaDistanceOffset; uniform float uTroikaFillOpacity; uniform float uTroikaOutlineOpacity; uniform float uTroikaBlurRadius; uniform vec3 uTroikaStrokeColor; uniform float uTroikaStrokeWidth; uniform float uTroikaStrokeOpacity; uniform bool uTroikaSDFDebug; varying vec2 vTroikaGlyphUV; varying vec4 vTroikaTextureUVBounds; varying float vTroikaTextureChannel; varying vec2 vTroikaGlyphDimensions; float troikaSdfValueToSignedDistance(float alpha) { // Inverse of exponential encoding in webgl-sdf-generator float maxDimension = max(vTroikaGlyphDimensions.x, vTroikaGlyphDimensions.y); float absDist = (1.0 - pow(2.0 * (alpha > 0.5 ? 1.0 - alpha : alpha), 1.0 / uTroikaSDFExponent)) * maxDimension; float signedDist = absDist * (alpha > 0.5 ? -1.0 : 1.0); return signedDist; } float troikaGlyphUvToSdfValue(vec2 glyphUV) { vec2 textureUV = mix(vTroikaTextureUVBounds.xy, vTroikaTextureUVBounds.zw, glyphUV); vec4 rgba = texture2D(uTroikaSDFTexture, textureUV); float ch = floor(vTroikaTextureChannel + 0.5); //NOTE: can't use round() in WebGL1 return ch == 0.0 ? rgba.r : ch == 1.0 ? rgba.g : ch == 2.0 ? rgba.b : rgba.a; } float troikaGlyphUvToDistance(vec2 uv) { return troikaSdfValueToSignedDistance(troikaGlyphUvToSdfValue(uv)); } float troikaGetAADist() { #if defined(GL_OES_standard_derivatives) || __VERSION__ >= 300 return length(fwidth(vTroikaGlyphUV * vTroikaGlyphDimensions)) * 0.5; #else return vTroikaGlyphDimensions.x / 64.0; #endif } float troikaGetFragDistValue() { vec2 clampedGlyphUV = clamp(vTroikaGlyphUV, 0.5 / uTroikaSDFGlyphSize, 1.0 - 0.5 / uTroikaSDFGlyphSize); float distance = troikaGlyphUvToDistance(clampedGlyphUV); // Extrapolate distance when outside bounds: distance += clampedGlyphUV == vTroikaGlyphUV ? 0.0 : length((vTroikaGlyphUV - clampedGlyphUV) * vTroikaGlyphDimensions); return distance; } float troikaGetEdgeAlpha(float distance, float distanceOffset, float aaDist) { #if defined(IS_DEPTH_MATERIAL) || defined(IS_DISTANCE_MATERIAL) float alpha = step(-distanceOffset, -distance); #else float alpha = smoothstep( distanceOffset + aaDist, distanceOffset - aaDist, distance ); #endif return alpha; } `,o5=` float aaDist = troikaGetAADist(); float fragDistance = troikaGetFragDistValue(); float edgeAlpha = uTroikaSDFDebug ? troikaGlyphUvToSdfValue(vTroikaGlyphUV) : troikaGetEdgeAlpha(fragDistance, uTroikaDistanceOffset, max(aaDist, uTroikaBlurRadius)); #if !defined(IS_DEPTH_MATERIAL) && !defined(IS_DISTANCE_MATERIAL) vec4 fillRGBA = gl_FragColor; fillRGBA.a *= uTroikaFillOpacity; vec4 strokeRGBA = uTroikaStrokeWidth == 0.0 ? fillRGBA : vec4(uTroikaStrokeColor, uTroikaStrokeOpacity); if (fillRGBA.a == 0.0) fillRGBA.rgb = strokeRGBA.rgb; gl_FragColor = mix(fillRGBA, strokeRGBA, smoothstep( -uTroikaStrokeWidth - aaDist, -uTroikaStrokeWidth + aaDist, fragDistance )); gl_FragColor.a *= edgeAlpha; #endif if (edgeAlpha == 0.0) { discard; } `;function a5(r){const e=zv(r,{chained:!0,extensions:{derivatives:!0},uniforms:{uTroikaSDFTexture:{value:null},uTroikaSDFTextureSize:{value:new De},uTroikaSDFGlyphSize:{value:0},uTroikaSDFExponent:{value:0},uTroikaTotalBounds:{value:new Xt(0,0,0,0)},uTroikaClipRect:{value:new Xt(0,0,0,0)},uTroikaDistanceOffset:{value:0},uTroikaOutlineOpacity:{value:0},uTroikaFillOpacity:{value:1},uTroikaPositionOffset:{value:new De},uTroikaCurveRadius:{value:0},uTroikaBlurRadius:{value:0},uTroikaStrokeWidth:{value:0},uTroikaStrokeColor:{value:new Ke},uTroikaStrokeOpacity:{value:1},uTroikaOrient:{value:new Ct},uTroikaUseGlyphColors:{value:!0},uTroikaSDFDebug:{value:!1}},vertexDefs:i5,vertexTransform:r5,fragmentDefs:s5,fragmentColorTransform:o5,customRewriter({vertexShader:t,fragmentShader:n}){let i=/\buniform\s+vec3\s+diffuse\b/;return i.test(n)&&(n=n.replace(i,"varying vec3 vTroikaGlyphColor").replace(/\bdiffuse\b/g,"vTroikaGlyphColor"),i.test(t)||(t=t.replace($A,`uniform vec3 diffuse; $& vTroikaGlyphColor = uTroikaUseGlyphColors ? aTroikaGlyphColor / 255.0 : diffuse; `))),{vertexShader:t,fragmentShader:n}}});return e.transparent=!0,Object.defineProperties(e,{isTroikaTextMaterial:{value:!0},shadowSide:{get(){return this.side},set(){}}}),e}const p_=new Vs({color:16777215,side:vn,transparent:!0}),DE=8421504,UE=new yt,cd=new Y,_0=new Y,ru=[],l5=new Y,x0="+x+y";function OE(r){return Array.isArray(r)?r[0]:r}let n2=()=>{const r=new _n(new To(1,1),p_);return n2=()=>r,r},i2=()=>{const r=new _n(new To(1,1,32,1),p_);return i2=()=>r,r};const c5={type:"syncstart"},u5={type:"synccomplete"},r2=["font","fontSize","letterSpacing","lineHeight","maxWidth","overflowWrap","text","direction","textAlign","textIndent","whiteSpace","anchorX","anchorY","colorRanges","sdfGlyphSize"],h5=r2.concat("material","color","depthOffset","clipRect","curveRadius","orientation","glyphGeometryDetail");let s2=class extends _n{constructor(){const e=new n5;super(e,null),this.text="",this.anchorX=0,this.anchorY=0,this.curveRadius=0,this.direction="auto",this.font=null,this.fontSize=.1,this.letterSpacing=0,this.lineHeight="normal",this.maxWidth=1/0,this.overflowWrap="normal",this.textAlign="left",this.textIndent=0,this.whiteSpace="normal",this.material=null,this.color=null,this.colorRanges=null,this.outlineWidth=0,this.outlineColor=0,this.outlineOpacity=1,this.outlineBlur=0,this.outlineOffsetX=0,this.outlineOffsetY=0,this.strokeWidth=0,this.strokeColor=DE,this.strokeOpacity=1,this.fillOpacity=1,this.depthOffset=0,this.clipRect=null,this.orientation=x0,this.glyphGeometryDetail=1,this.sdfGlyphSize=null,this.gpuAccelerateSDF=!0,this.debugSDF=!1}sync(e){this._needsSync&&(this._needsSync=!1,this._isSyncing?(this._queuedSyncs||(this._queuedSyncs=[])).push(e):(this._isSyncing=!0,this.dispatchEvent(c5),QA({text:this.text,font:this.font,fontSize:this.fontSize||.1,letterSpacing:this.letterSpacing||0,lineHeight:this.lineHeight||"normal",maxWidth:this.maxWidth,direction:this.direction||"auto",textAlign:this.textAlign,textIndent:this.textIndent,whiteSpace:this.whiteSpace,overflowWrap:this.overflowWrap,anchorX:this.anchorX,anchorY:this.anchorY,colorRanges:this.colorRanges,includeCaretPositions:!0,sdfGlyphSize:this.sdfGlyphSize,gpuAccelerateSDF:this.gpuAccelerateSDF},t=>{this._isSyncing=!1,this._textRenderInfo=t,this.geometry.updateGlyphs(t.glyphBounds,t.glyphAtlasIndices,t.blockBounds,t.chunkedBounds,t.glyphColors);const n=this._queuedSyncs;n&&(this._queuedSyncs=null,this._needsSync=!0,this.sync(()=>{n.forEach(i=>i&&i())})),this.dispatchEvent(u5),e&&e()})))}onBeforeRender(e,t,n,i,s,o){this.sync(),s.isTroikaTextMaterial&&this._prepareForRender(s),s._hadOwnSide=s.hasOwnProperty("side"),this.geometry.setSide(s._actualSide=s.side),s.side=ls}onAfterRender(e,t,n,i,s,o){s._hadOwnSide?s.side=s._actualSide:delete s.side}dispose(){this.geometry.dispose()}get textRenderInfo(){return this._textRenderInfo||null}get material(){let e=this._derivedMaterial;const t=this._baseMaterial||this._defaultMaterial||(this._defaultMaterial=p_.clone());if((!e||e.baseMaterial!==t)&&(e=this._derivedMaterial=a5(t),t.addEventListener("dispose",function n(){t.removeEventListener("dispose",n),e.dispose()})),this.outlineWidth||this.outlineBlur||this.outlineOffsetX||this.outlineOffsetY){let n=e._outlineMtl;return n||(n=e._outlineMtl=Object.create(e,{id:{value:e.id+.1}}),n.isTextOutlineMaterial=!0,n.depthWrite=!1,n.map=null,e.addEventListener("dispose",function i(){e.removeEventListener("dispose",i),n.dispose()})),[n,e]}else return e}set material(e){e&&e.isTroikaTextMaterial?(this._derivedMaterial=e,this._baseMaterial=e.baseMaterial):this._baseMaterial=e}get glyphGeometryDetail(){return this.geometry.detail}set glyphGeometryDetail(e){this.geometry.detail=e}get curveRadius(){return this.geometry.curveRadius}set curveRadius(e){this.geometry.curveRadius=e}get customDepthMaterial(){return OE(this.material).getDepthMaterial()}get customDistanceMaterial(){return OE(this.material).getDistanceMaterial()}_prepareForRender(e){const t=e.isTextOutlineMaterial,n=e.uniforms,i=this.textRenderInfo;if(i){const{sdfTexture:a,blockBounds:l}=i;n.uTroikaSDFTexture.value=a,n.uTroikaSDFTextureSize.value.set(a.image.width,a.image.height),n.uTroikaSDFGlyphSize.value=i.sdfGlyphSize,n.uTroikaSDFExponent.value=i.sdfExponent,n.uTroikaTotalBounds.value.fromArray(l),n.uTroikaUseGlyphColors.value=!t&&!!i.glyphColors;let c=0,u=0,h=0,p,m,v,_=0,y=0;if(t){let{outlineWidth:x,outlineOffsetX:w,outlineOffsetY:E,outlineBlur:b,outlineOpacity:M}=this;c=this._parsePercent(x)||0,u=Math.max(0,this._parsePercent(b)||0),p=M,_=this._parsePercent(w)||0,y=this._parsePercent(E)||0}else h=Math.max(0,this._parsePercent(this.strokeWidth)||0),h&&(v=this.strokeColor,n.uTroikaStrokeColor.value.set(v??DE),m=this.strokeOpacity,m==null&&(m=1)),p=this.fillOpacity;n.uTroikaDistanceOffset.value=c,n.uTroikaPositionOffset.value.set(_,y),n.uTroikaBlurRadius.value=u,n.uTroikaStrokeWidth.value=h,n.uTroikaStrokeOpacity.value=m,n.uTroikaFillOpacity.value=p??1,n.uTroikaCurveRadius.value=this.curveRadius||0;let g=this.clipRect;if(g&&Array.isArray(g)&&g.length===4)n.uTroikaClipRect.value.fromArray(g);else{const x=(this.fontSize||.1)*100;n.uTroikaClipRect.value.set(l[0]-x,l[1]-x,l[2]+x,l[3]+x)}this.geometry.applyClipRect(n.uTroikaClipRect.value)}n.uTroikaSDFDebug.value=!!this.debugSDF,e.polygonOffset=!!this.depthOffset,e.polygonOffsetFactor=e.polygonOffsetUnits=this.depthOffset||0;const s=t?this.outlineColor||0:this.color;if(s==null)delete e.color;else{const a=e.hasOwnProperty("color")?e.color:e.color=new Ke;(s!==a._input||typeof s=="object")&&a.set(a._input=s)}let o=this.orientation||x0;if(o!==e._orientation){let a=n.uTroikaOrient.value;o=o.replace(/[^-+xyz]/g,"");let l=o!==x0&&o.match(/^([-+])([xyz])([-+])([xyz])$/);if(l){let[,c,u,h,p]=l;cd.set(0,0,0)[u]=c==="-"?1:-1,_0.set(0,0,0)[p]=h==="-"?-1:1,UE.lookAt(l5,cd.cross(_0),_0),a.setFromMatrix4(UE)}else a.identity();e._orientation=o}}_parsePercent(e){if(typeof e=="string"){let t=e.match(/^(-?[\d.]+)%$/),n=t?parseFloat(t[1]):NaN;e=(isNaN(n)?0:n/100)*this.fontSize}return e}localPositionToTextCoords(e,t=new De){t.copy(e);const n=this.curveRadius;return n&&(t.x=Math.atan2(e.x,Math.abs(n)-Math.abs(e.z))*Math.abs(n)),t}worldPositionToTextCoords(e,t=new De){return cd.copy(e),this.localPositionToTextCoords(this.worldToLocal(cd),t)}raycast(e,t){const{textRenderInfo:n,curveRadius:i}=this;if(n){const s=n.blockBounds,o=i?i2():n2(),a=o.geometry,{position:l,uv:c}=a.attributes;for(let u=0;u{this[n]=e[n]}),this}clone(){return new this.constructor().copy(this)}};r2.forEach(r=>{const e="_private_"+r;Object.defineProperty(s2.prototype,r,{get(){return this[e]},set(t){t!==this[e]&&(this[e]=t,this._needsSync=!0)}})});const f5=K.forwardRef(({sdfGlyphSize:r=64,anchorX:e="center",anchorY:t="middle",font:n,fontSize:i=1,children:s,characters:o,onSync:a,...l},c)=>{const u=Bn(({invalidate:v})=>v),[h]=K.useState(()=>new s2),[p,m]=K.useMemo(()=>{const v=[];let _="";return K.Children.forEach(s,y=>{typeof y=="string"||typeof y=="number"?_+=y:v.push(y)}),[v,_]},[s]);return eO(()=>new Promise(v=>qG({font:n,characters:o},v)),["troika-text",n,o]),K.useLayoutEffect(()=>void h.sync(()=>{u(),a&&a(h)})),K.useEffect(()=>()=>h.dispose(),[h]),K.createElement("primitive",Ta({object:h,ref:c,font:n,text:m,anchorX:e,anchorY:t,fontSize:i,sdfGlyphSize:r},l),p)});/*! * camera-controls * https://github.com/yomotsu/camera-controls * (c) 2017 @yomotsu * Released under the MIT License. */const gn={LEFT:1,RIGHT:2,MIDDLE:4},_e=Object.freeze({NONE:0,ROTATE:1,TRUCK:2,SCREEN_PAN:4,OFFSET:8,DOLLY:16,ZOOM:32,TOUCH_ROTATE:64,TOUCH_TRUCK:128,TOUCH_SCREEN_PAN:256,TOUCH_OFFSET:512,TOUCH_DOLLY:1024,TOUCH_ZOOM:2048,TOUCH_DOLLY_TRUCK:4096,TOUCH_DOLLY_SCREEN_PAN:8192,TOUCH_DOLLY_OFFSET:16384,TOUCH_DOLLY_ROTATE:32768,TOUCH_ZOOM_TRUCK:65536,TOUCH_ZOOM_OFFSET:131072,TOUCH_ZOOM_SCREEN_PAN:262144,TOUCH_ZOOM_ROTATE:524288}),Al={NONE:0,IN:1,OUT:-1};function ia(r){return r.isPerspectiveCamera}function ho(r){return r.isOrthographicCamera}const Cl=Math.PI*2,NE=Math.PI/2,o2=1e-5,su=Math.PI/180;function Ur(r,e,t){return Math.max(e,Math.min(t,r))}function an(r,e=o2){return Math.abs(r)0==m>u&&(m=u,t.value=(m-u)/s),m}function kE(r,e,t,n,i=1/0,s,o){n=Math.max(1e-4,n);const a=2/n,l=a*s,c=1/(1+l+.48*l*l+.235*l*l*l);let u=e.x,h=e.y,p=e.z,m=r.x-u,v=r.y-h,_=r.z-p;const y=u,g=h,x=p,w=i*n,E=w*w,b=m*m+v*v+_*_;if(b>E){const q=Math.sqrt(b);m=m/q*w,v=v/q*w,_=_/q*w}u=r.x-m,h=r.y-v,p=r.z-_;const M=(t.x+a*m)*s,A=(t.y+a*v)*s,P=(t.z+a*_)*s;t.x=(t.x-a*M)*c,t.y=(t.y-a*A)*c,t.z=(t.z-a*P)*c,o.x=u+(m+M)*c,o.y=h+(v+A)*c,o.z=p+(_+P)*c;const C=y-r.x,L=g-r.y,F=x-r.z,N=o.x-y,I=o.y-g,X=o.z-x;return C*N+L*I+F*X>0&&(o.x=y,o.y=g,o.z=x,t.x=(o.x-y)/s,t.y=(o.y-g)/s,t.z=(o.z-x)/s),o}function w0(r,e){e.set(0,0),r.forEach(t=>{e.x+=t.clientX,e.y+=t.clientY}),e.x/=r.length,e.y/=r.length}function S0(r,e){return ho(r)?(console.warn(`${e} is not supported in OrthographicCamera`),!0):!1}let d5=class{constructor(){this._listeners={}}addEventListener(e,t){const n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){const n=this._listeners;return n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){const i=this._listeners[e];if(i!==void 0){const s=i.indexOf(t);s!==-1&&i.splice(s,1)}}removeAllEventListeners(e){if(!e){this._listeners={};return}Array.isArray(this._listeners[e])&&(this._listeners[e].length=0)}dispatchEvent(e){const n=this._listeners[e.type];if(n!==void 0){e.target=this;const i=n.slice(0);for(let s=0,o=i.length;s{},this._enabled=!0,this._state=_e.NONE,this._viewport=null,this._changedDolly=0,this._changedZoom=0,this._hasRested=!0,this._boundaryEnclosesCamera=!1,this._needsUpdate=!0,this._updatedLastTime=!1,this._elementRect=new DOMRect,this._isDragging=!1,this._dragNeedsUpdate=!0,this._activePointers=[],this._lockedPointer=null,this._interactiveArea=new DOMRect(0,0,1,1),this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._isUserControllingOffset=!1,this._isUserControllingZoom=!1,this._lastDollyDirection=Al.NONE,this._thetaVelocity={value:0},this._phiVelocity={value:0},this._radiusVelocity={value:0},this._targetVelocity=new vt.Vector3,this._focalOffsetVelocity=new vt.Vector3,this._zoomVelocity={value:0},this._truckInternal=(g,x,w,E)=>{let b,M;if(ia(this._camera)){const A=At.copy(this._camera.position).sub(this._target),P=this._camera.getEffectiveFOV()*su,C=A.length()*Math.tan(P*.5);b=this.truckSpeed*g*C/this._elementRect.height,M=this.truckSpeed*x*C/this._elementRect.height}else if(ho(this._camera)){const A=this._camera;b=this.truckSpeed*g*(A.right-A.left)/A.zoom/this._elementRect.width,M=this.truckSpeed*x*(A.top-A.bottom)/A.zoom/this._elementRect.height}else return;E?(w?this.setFocalOffset(this._focalOffsetEnd.x+b,this._focalOffsetEnd.y,this._focalOffsetEnd.z,!0):this.truck(b,0,!0),this.forward(-M,!0)):w?this.setFocalOffset(this._focalOffsetEnd.x+b,this._focalOffsetEnd.y+M,this._focalOffsetEnd.z,!0):this.truck(b,M,!0)},this._rotateInternal=(g,x)=>{const w=Cl*this.azimuthRotateSpeed*g/this._elementRect.height,E=Cl*this.polarRotateSpeed*x/this._elementRect.height;this.rotate(w,E,!0)},this._dollyInternal=(g,x,w)=>{const E=Math.pow(.95,-g*this.dollySpeed),b=this._sphericalEnd.radius,M=this._sphericalEnd.radius*E,A=Ur(M,this.minDistance,this.maxDistance),P=A-M;this.infinityDolly&&this.dollyToCursor?this._dollyToNoClamp(M,!0):this.infinityDolly&&!this.dollyToCursor?(this.dollyInFixed(P,!0),this._dollyToNoClamp(A,!0)):this._dollyToNoClamp(A,!0),this.dollyToCursor&&(this._changedDolly+=(this.infinityDolly?M:A)-b,this._dollyControlCoord.set(x,w)),this._lastDollyDirection=Math.sign(-g)},this._zoomInternal=(g,x,w)=>{const E=Math.pow(.95,g*this.dollySpeed),b=this._zoom,M=this._zoom*E;this.zoomTo(M,!0),this.dollyToCursor&&(this._changedZoom+=M-b,this._dollyControlCoord.set(x,w))},typeof vt>"u"&&console.error("camera-controls: `THREE` is undefined. You must first run `CameraControls.install( { THREE: THREE } )`. Check the docs for further information."),this._camera=e,this._yAxisUpSpace=new vt.Quaternion().setFromUnitVectors(this._camera.up,fd),this._yAxisUpSpaceInverse=this._yAxisUpSpace.clone().invert(),this._state=_e.NONE,this._target=new vt.Vector3,this._targetEnd=this._target.clone(),this._focalOffset=new vt.Vector3,this._focalOffsetEnd=this._focalOffset.clone(),this._spherical=new vt.Spherical().setFromVector3(At.copy(this._camera.position).applyQuaternion(this._yAxisUpSpace)),this._sphericalEnd=this._spherical.clone(),this._lastDistance=this._spherical.radius,this._zoom=this._camera.zoom,this._zoomEnd=this._zoom,this._lastZoom=this._zoom,this._nearPlaneCorners=[new vt.Vector3,new vt.Vector3,new vt.Vector3,new vt.Vector3],this._updateNearPlaneCorners(),this._boundary=new vt.Box3(new vt.Vector3(-1/0,-1/0,-1/0),new vt.Vector3(1/0,1/0,1/0)),this._cameraUp0=this._camera.up.clone(),this._target0=this._target.clone(),this._position0=this._camera.position.clone(),this._zoom0=this._zoom,this._focalOffset0=this._focalOffset.clone(),this._dollyControlCoord=new vt.Vector2,this.mouseButtons={left:_e.ROTATE,middle:_e.DOLLY,right:_e.TRUCK,wheel:ia(this._camera)?_e.DOLLY:ho(this._camera)?_e.ZOOM:_e.NONE},this.touches={one:_e.TOUCH_ROTATE,two:ia(this._camera)?_e.TOUCH_DOLLY_TRUCK:ho(this._camera)?_e.TOUCH_ZOOM_TRUCK:_e.NONE,three:_e.TOUCH_TRUCK};const n=new vt.Vector2,i=new vt.Vector2,s=new vt.Vector2,o=g=>{if(!this._enabled||!this._domElement)return;if(this._interactiveArea.left!==0||this._interactiveArea.top!==0||this._interactiveArea.width!==1||this._interactiveArea.height!==1){const E=this._domElement.getBoundingClientRect(),b=g.clientX/E.width,M=g.clientY/E.height;if(bthis._interactiveArea.right||Mthis._interactiveArea.bottom)return}const x=g.pointerType!=="mouse"?null:(g.buttons&gn.LEFT)===gn.LEFT?gn.LEFT:(g.buttons&gn.MIDDLE)===gn.MIDDLE?gn.MIDDLE:(g.buttons&gn.RIGHT)===gn.RIGHT?gn.RIGHT:null;if(x!==null){const E=this._findPointerByMouseButton(x);E&&this._disposePointer(E)}if((g.buttons&gn.LEFT)===gn.LEFT&&this._lockedPointer)return;const w={pointerId:g.pointerId,clientX:g.clientX,clientY:g.clientY,deltaX:0,deltaY:0,mouseButton:x};this._activePointers.push(w),this._domElement.ownerDocument.removeEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",l),this._domElement.ownerDocument.addEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.addEventListener("pointerup",l),this._isDragging=!0,p(g)},a=g=>{g.cancelable&&g.preventDefault();const x=g.pointerId,w=this._lockedPointer||this._findPointerById(x);if(w){if(w.clientX=g.clientX,w.clientY=g.clientY,w.deltaX=g.movementX,w.deltaY=g.movementY,this._state=0,g.pointerType==="touch")switch(this._activePointers.length){case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three;break}else(!this._isDragging&&this._lockedPointer||this._isDragging&&(g.buttons&gn.LEFT)===gn.LEFT)&&(this._state=this._state|this.mouseButtons.left),this._isDragging&&(g.buttons&gn.MIDDLE)===gn.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),this._isDragging&&(g.buttons&gn.RIGHT)===gn.RIGHT&&(this._state=this._state|this.mouseButtons.right);m()}},l=g=>{const x=this._findPointerById(g.pointerId);if(!(x&&x===this._lockedPointer)){if(x&&this._disposePointer(x),g.pointerType==="touch")switch(this._activePointers.length){case 0:this._state=_e.NONE;break;case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three;break}else this._state=_e.NONE;v()}};let c=-1;const u=g=>{if(!this._domElement||!this._enabled||this.mouseButtons.wheel===_e.NONE)return;if(this._interactiveArea.left!==0||this._interactiveArea.top!==0||this._interactiveArea.width!==1||this._interactiveArea.height!==1){const M=this._domElement.getBoundingClientRect(),A=g.clientX/M.width,P=g.clientY/M.height;if(Athis._interactiveArea.right||Pthis._interactiveArea.bottom)return}if(g.preventDefault(),this.dollyToCursor||this.mouseButtons.wheel===_e.ROTATE||this.mouseButtons.wheel===_e.TRUCK){const M=performance.now();c-M<1e3&&this._getClientRect(this._elementRect),c=M}const x=m5?-1:-3,w=g.deltaMode===1||g.ctrlKey?g.deltaY/x:g.deltaY/(x*10),E=this.dollyToCursor?(g.clientX-this._elementRect.x)/this._elementRect.width*2-1:0,b=this.dollyToCursor?(g.clientY-this._elementRect.y)/this._elementRect.height*-2+1:0;switch(this.mouseButtons.wheel){case _e.ROTATE:{this._rotateInternal(g.deltaX,g.deltaY),this._isUserControllingRotate=!0;break}case _e.TRUCK:{this._truckInternal(g.deltaX,g.deltaY,!1,!1),this._isUserControllingTruck=!0;break}case _e.SCREEN_PAN:{this._truckInternal(g.deltaX,g.deltaY,!1,!0),this._isUserControllingTruck=!0;break}case _e.OFFSET:{this._truckInternal(g.deltaX,g.deltaY,!0,!1),this._isUserControllingOffset=!0;break}case _e.DOLLY:{this._dollyInternal(-w,E,b),this._isUserControllingDolly=!0;break}case _e.ZOOM:{this._zoomInternal(-w,E,b),this._isUserControllingZoom=!0;break}}this.dispatchEvent({type:"control"})},h=g=>{if(!(!this._domElement||!this._enabled)){if(this.mouseButtons.right===Gv.ACTION.NONE){const x=g instanceof PointerEvent?g.pointerId:0,w=this._findPointerById(x);w&&this._disposePointer(w),this._domElement.ownerDocument.removeEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",l);return}g.preventDefault()}},p=g=>{if(!this._enabled)return;if(w0(this._activePointers,Fi),this._getClientRect(this._elementRect),n.copy(Fi),i.copy(Fi),this._activePointers.length>=2){const w=Fi.x-this._activePointers[1].clientX,E=Fi.y-this._activePointers[1].clientY,b=Math.sqrt(w*w+E*E);s.set(0,b);const M=(this._activePointers[0].clientX+this._activePointers[1].clientX)*.5,A=(this._activePointers[0].clientY+this._activePointers[1].clientY)*.5;i.set(M,A)}if(this._state=0,!g)this._lockedPointer&&(this._state=this._state|this.mouseButtons.left);else if("pointerType"in g&&g.pointerType==="touch")switch(this._activePointers.length){case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three;break}else!this._lockedPointer&&(g.buttons&gn.LEFT)===gn.LEFT&&(this._state=this._state|this.mouseButtons.left),(g.buttons&gn.MIDDLE)===gn.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),(g.buttons&gn.RIGHT)===gn.RIGHT&&(this._state=this._state|this.mouseButtons.right);((this._state&_e.ROTATE)===_e.ROTATE||(this._state&_e.TOUCH_ROTATE)===_e.TOUCH_ROTATE||(this._state&_e.TOUCH_DOLLY_ROTATE)===_e.TOUCH_DOLLY_ROTATE||(this._state&_e.TOUCH_ZOOM_ROTATE)===_e.TOUCH_ZOOM_ROTATE)&&(this._sphericalEnd.theta=this._spherical.theta,this._sphericalEnd.phi=this._spherical.phi,this._thetaVelocity.value=0,this._phiVelocity.value=0),((this._state&_e.TRUCK)===_e.TRUCK||(this._state&_e.SCREEN_PAN)===_e.SCREEN_PAN||(this._state&_e.TOUCH_TRUCK)===_e.TOUCH_TRUCK||(this._state&_e.TOUCH_SCREEN_PAN)===_e.TOUCH_SCREEN_PAN||(this._state&_e.TOUCH_DOLLY_TRUCK)===_e.TOUCH_DOLLY_TRUCK||(this._state&_e.TOUCH_DOLLY_SCREEN_PAN)===_e.TOUCH_DOLLY_SCREEN_PAN||(this._state&_e.TOUCH_ZOOM_TRUCK)===_e.TOUCH_ZOOM_TRUCK||(this._state&_e.TOUCH_ZOOM_SCREEN_PAN)===_e.TOUCH_DOLLY_SCREEN_PAN)&&(this._targetEnd.copy(this._target),this._targetVelocity.set(0,0,0)),((this._state&_e.DOLLY)===_e.DOLLY||(this._state&_e.TOUCH_DOLLY)===_e.TOUCH_DOLLY||(this._state&_e.TOUCH_DOLLY_TRUCK)===_e.TOUCH_DOLLY_TRUCK||(this._state&_e.TOUCH_DOLLY_SCREEN_PAN)===_e.TOUCH_DOLLY_SCREEN_PAN||(this._state&_e.TOUCH_DOLLY_OFFSET)===_e.TOUCH_DOLLY_OFFSET||(this._state&_e.TOUCH_DOLLY_ROTATE)===_e.TOUCH_DOLLY_ROTATE)&&(this._sphericalEnd.radius=this._spherical.radius,this._radiusVelocity.value=0),((this._state&_e.ZOOM)===_e.ZOOM||(this._state&_e.TOUCH_ZOOM)===_e.TOUCH_ZOOM||(this._state&_e.TOUCH_ZOOM_TRUCK)===_e.TOUCH_ZOOM_TRUCK||(this._state&_e.TOUCH_ZOOM_SCREEN_PAN)===_e.TOUCH_ZOOM_SCREEN_PAN||(this._state&_e.TOUCH_ZOOM_OFFSET)===_e.TOUCH_ZOOM_OFFSET||(this._state&_e.TOUCH_ZOOM_ROTATE)===_e.TOUCH_ZOOM_ROTATE)&&(this._zoomEnd=this._zoom,this._zoomVelocity.value=0),((this._state&_e.OFFSET)===_e.OFFSET||(this._state&_e.TOUCH_OFFSET)===_e.TOUCH_OFFSET||(this._state&_e.TOUCH_DOLLY_OFFSET)===_e.TOUCH_DOLLY_OFFSET||(this._state&_e.TOUCH_ZOOM_OFFSET)===_e.TOUCH_ZOOM_OFFSET)&&(this._focalOffsetEnd.copy(this._focalOffset),this._focalOffsetVelocity.set(0,0,0)),this.dispatchEvent({type:"controlstart"})},m=()=>{if(!this._enabled||!this._dragNeedsUpdate)return;this._dragNeedsUpdate=!1,w0(this._activePointers,Fi);const x=this._domElement&&this._domElement.ownerDocument.pointerLockElement===this._domElement?this._lockedPointer||this._activePointers[0]:null,w=x?-x.deltaX:i.x-Fi.x,E=x?-x.deltaY:i.y-Fi.y;if(i.copy(Fi),((this._state&_e.ROTATE)===_e.ROTATE||(this._state&_e.TOUCH_ROTATE)===_e.TOUCH_ROTATE||(this._state&_e.TOUCH_DOLLY_ROTATE)===_e.TOUCH_DOLLY_ROTATE||(this._state&_e.TOUCH_ZOOM_ROTATE)===_e.TOUCH_ZOOM_ROTATE)&&(this._rotateInternal(w,E),this._isUserControllingRotate=!0),(this._state&_e.DOLLY)===_e.DOLLY||(this._state&_e.ZOOM)===_e.ZOOM){const b=this.dollyToCursor?(n.x-this._elementRect.x)/this._elementRect.width*2-1:0,M=this.dollyToCursor?(n.y-this._elementRect.y)/this._elementRect.height*-2+1:0,A=this.dollyDragInverted?-1:1;(this._state&_e.DOLLY)===_e.DOLLY?(this._dollyInternal(A*E*hd,b,M),this._isUserControllingDolly=!0):(this._zoomInternal(A*E*hd,b,M),this._isUserControllingZoom=!0)}if((this._state&_e.TOUCH_DOLLY)===_e.TOUCH_DOLLY||(this._state&_e.TOUCH_ZOOM)===_e.TOUCH_ZOOM||(this._state&_e.TOUCH_DOLLY_TRUCK)===_e.TOUCH_DOLLY_TRUCK||(this._state&_e.TOUCH_ZOOM_TRUCK)===_e.TOUCH_ZOOM_TRUCK||(this._state&_e.TOUCH_DOLLY_SCREEN_PAN)===_e.TOUCH_DOLLY_SCREEN_PAN||(this._state&_e.TOUCH_ZOOM_SCREEN_PAN)===_e.TOUCH_ZOOM_SCREEN_PAN||(this._state&_e.TOUCH_DOLLY_OFFSET)===_e.TOUCH_DOLLY_OFFSET||(this._state&_e.TOUCH_ZOOM_OFFSET)===_e.TOUCH_ZOOM_OFFSET||(this._state&_e.TOUCH_DOLLY_ROTATE)===_e.TOUCH_DOLLY_ROTATE||(this._state&_e.TOUCH_ZOOM_ROTATE)===_e.TOUCH_ZOOM_ROTATE){const b=Fi.x-this._activePointers[1].clientX,M=Fi.y-this._activePointers[1].clientY,A=Math.sqrt(b*b+M*M),P=s.y-A;s.set(0,A);const C=this.dollyToCursor?(i.x-this._elementRect.x)/this._elementRect.width*2-1:0,L=this.dollyToCursor?(i.y-this._elementRect.y)/this._elementRect.height*-2+1:0;(this._state&_e.TOUCH_DOLLY)===_e.TOUCH_DOLLY||(this._state&_e.TOUCH_DOLLY_ROTATE)===_e.TOUCH_DOLLY_ROTATE||(this._state&_e.TOUCH_DOLLY_TRUCK)===_e.TOUCH_DOLLY_TRUCK||(this._state&_e.TOUCH_DOLLY_SCREEN_PAN)===_e.TOUCH_DOLLY_SCREEN_PAN||(this._state&_e.TOUCH_DOLLY_OFFSET)===_e.TOUCH_DOLLY_OFFSET?(this._dollyInternal(P*hd,C,L),this._isUserControllingDolly=!0):(this._zoomInternal(P*hd,C,L),this._isUserControllingZoom=!0)}((this._state&_e.TRUCK)===_e.TRUCK||(this._state&_e.TOUCH_TRUCK)===_e.TOUCH_TRUCK||(this._state&_e.TOUCH_DOLLY_TRUCK)===_e.TOUCH_DOLLY_TRUCK||(this._state&_e.TOUCH_ZOOM_TRUCK)===_e.TOUCH_ZOOM_TRUCK)&&(this._truckInternal(w,E,!1,!1),this._isUserControllingTruck=!0),((this._state&_e.SCREEN_PAN)===_e.SCREEN_PAN||(this._state&_e.TOUCH_SCREEN_PAN)===_e.TOUCH_SCREEN_PAN||(this._state&_e.TOUCH_DOLLY_SCREEN_PAN)===_e.TOUCH_DOLLY_SCREEN_PAN||(this._state&_e.TOUCH_ZOOM_SCREEN_PAN)===_e.TOUCH_ZOOM_SCREEN_PAN)&&(this._truckInternal(w,E,!1,!0),this._isUserControllingTruck=!0),((this._state&_e.OFFSET)===_e.OFFSET||(this._state&_e.TOUCH_OFFSET)===_e.TOUCH_OFFSET||(this._state&_e.TOUCH_DOLLY_OFFSET)===_e.TOUCH_DOLLY_OFFSET||(this._state&_e.TOUCH_ZOOM_OFFSET)===_e.TOUCH_ZOOM_OFFSET)&&(this._truckInternal(w,E,!0,!1),this._isUserControllingOffset=!0),this.dispatchEvent({type:"control"})},v=()=>{w0(this._activePointers,Fi),i.copy(Fi),this._dragNeedsUpdate=!1,(this._activePointers.length===0||this._activePointers.length===1&&this._activePointers[0]===this._lockedPointer)&&(this._isDragging=!1),this._activePointers.length===0&&this._domElement&&(this._domElement.ownerDocument.removeEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",l),this.dispatchEvent({type:"controlend"}))};this.lockPointer=()=>{!this._enabled||!this._domElement||(this.cancel(),this._lockedPointer={pointerId:-1,clientX:0,clientY:0,deltaX:0,deltaY:0,mouseButton:null},this._activePointers.push(this._lockedPointer),this._domElement.ownerDocument.removeEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",l),this._domElement.requestPointerLock(),this._domElement.ownerDocument.addEventListener("pointerlockchange",_),this._domElement.ownerDocument.addEventListener("pointerlockerror",y),this._domElement.ownerDocument.addEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.addEventListener("pointerup",l),p())},this.unlockPointer=()=>{var g,x,w;this._lockedPointer!==null&&(this._disposePointer(this._lockedPointer),this._lockedPointer=null),(g=this._domElement)===null||g===void 0||g.ownerDocument.exitPointerLock(),(x=this._domElement)===null||x===void 0||x.ownerDocument.removeEventListener("pointerlockchange",_),(w=this._domElement)===null||w===void 0||w.ownerDocument.removeEventListener("pointerlockerror",y),this.cancel()};const _=()=>{this._domElement&&this._domElement.ownerDocument.pointerLockElement===this._domElement||this.unlockPointer()},y=()=>{this.unlockPointer()};this._addAllEventListeners=g=>{this._domElement=g,this._domElement.style.touchAction="none",this._domElement.style.userSelect="none",this._domElement.style.webkitUserSelect="none",this._domElement.addEventListener("pointerdown",o),this._domElement.addEventListener("pointercancel",l),this._domElement.addEventListener("wheel",u,{passive:!1}),this._domElement.addEventListener("contextmenu",h)},this._removeAllEventListeners=()=>{this._domElement&&(this._domElement.style.touchAction="",this._domElement.style.userSelect="",this._domElement.style.webkitUserSelect="",this._domElement.removeEventListener("pointerdown",o),this._domElement.removeEventListener("pointercancel",l),this._domElement.removeEventListener("wheel",u,{passive:!1}),this._domElement.removeEventListener("contextmenu",h),this._domElement.ownerDocument.removeEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",l),this._domElement.ownerDocument.removeEventListener("pointerlockchange",_),this._domElement.ownerDocument.removeEventListener("pointerlockerror",y))},this.cancel=()=>{this._state!==_e.NONE&&(this._state=_e.NONE,this._activePointers.length=0,v())},t&&this.connect(t),this.update(0)}get camera(){return this._camera}set camera(e){this._camera=e,this.updateCameraUp(),this._camera.updateProjectionMatrix(),this._updateNearPlaneCorners(),this._needsUpdate=!0}get enabled(){return this._enabled}set enabled(e){this._enabled=e,this._domElement&&(e?(this._domElement.style.touchAction="none",this._domElement.style.userSelect="none",this._domElement.style.webkitUserSelect="none"):(this.cancel(),this._domElement.style.touchAction="",this._domElement.style.userSelect="",this._domElement.style.webkitUserSelect=""))}get active(){return!this._hasRested}get currentAction(){return this._state}get distance(){return this._spherical.radius}set distance(e){this._spherical.radius===e&&this._sphericalEnd.radius===e||(this._spherical.radius=e,this._sphericalEnd.radius=e,this._needsUpdate=!0)}get azimuthAngle(){return this._spherical.theta}set azimuthAngle(e){this._spherical.theta===e&&this._sphericalEnd.theta===e||(this._spherical.theta=e,this._sphericalEnd.theta=e,this._needsUpdate=!0)}get polarAngle(){return this._spherical.phi}set polarAngle(e){this._spherical.phi===e&&this._sphericalEnd.phi===e||(this._spherical.phi=e,this._sphericalEnd.phi=e,this._needsUpdate=!0)}get boundaryEnclosesCamera(){return this._boundaryEnclosesCamera}set boundaryEnclosesCamera(e){this._boundaryEnclosesCamera=e,this._needsUpdate=!0}set interactiveArea(e){this._interactiveArea.width=Ur(e.width,0,1),this._interactiveArea.height=Ur(e.height,0,1),this._interactiveArea.x=Ur(e.x,0,1-this._interactiveArea.width),this._interactiveArea.y=Ur(e.y,0,1-this._interactiveArea.height)}addEventListener(e,t){super.addEventListener(e,t)}removeEventListener(e,t){super.removeEventListener(e,t)}rotate(e,t,n=!1){return this.rotateTo(this._sphericalEnd.theta+e,this._sphericalEnd.phi+t,n)}rotateAzimuthTo(e,t=!1){return this.rotateTo(e,this._sphericalEnd.phi,t)}rotatePolarTo(e,t=!1){return this.rotateTo(this._sphericalEnd.theta,e,t)}rotateTo(e,t,n=!1){this._isUserControllingRotate=!1;const i=Ur(e,this.minAzimuthAngle,this.maxAzimuthAngle),s=Ur(t,this.minPolarAngle,this.maxPolarAngle);this._sphericalEnd.theta=i,this._sphericalEnd.phi=s,this._sphericalEnd.makeSafe(),this._needsUpdate=!0,n||(this._spherical.theta=this._sphericalEnd.theta,this._spherical.phi=this._sphericalEnd.phi);const o=!n||Zt(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&Zt(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold);return this._createOnRestPromise(o)}dolly(e,t=!1){return this.dollyTo(this._sphericalEnd.radius-e,t)}dollyTo(e,t=!1){return this._isUserControllingDolly=!1,this._lastDollyDirection=Al.NONE,this._changedDolly=0,this._dollyToNoClamp(Ur(e,this.minDistance,this.maxDistance),t)}_dollyToNoClamp(e,t=!1){const n=this._sphericalEnd.radius;if(this.colliderMeshes.length>=1){const o=this._collisionTest(),a=Zt(o,this._spherical.radius);if(!(n>e)&&a)return Promise.resolve();this._sphericalEnd.radius=Math.min(e,o)}else this._sphericalEnd.radius=e;this._needsUpdate=!0,t||(this._spherical.radius=this._sphericalEnd.radius);const s=!t||Zt(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(s)}dollyInFixed(e,t=!1){this._targetEnd.add(this._getCameraDirection(lu).multiplyScalar(e)),t||this._target.copy(this._targetEnd);const n=!t||Zt(this._target.x,this._targetEnd.x,this.restThreshold)&&Zt(this._target.y,this._targetEnd.y,this.restThreshold)&&Zt(this._target.z,this._targetEnd.z,this.restThreshold);return this._createOnRestPromise(n)}zoom(e,t=!1){return this.zoomTo(this._zoomEnd+e,t)}zoomTo(e,t=!1){this._isUserControllingZoom=!1,this._zoomEnd=Ur(e,this.minZoom,this.maxZoom),this._needsUpdate=!0,t||(this._zoom=this._zoomEnd);const n=!t||Zt(this._zoom,this._zoomEnd,this.restThreshold);return this._changedZoom=0,this._createOnRestPromise(n)}pan(e,t,n=!1){return console.warn("`pan` has been renamed to `truck`"),this.truck(e,t,n)}truck(e,t,n=!1){this._camera.updateMatrix(),es.setFromMatrixColumn(this._camera.matrix,0),ts.setFromMatrixColumn(this._camera.matrix,1),es.multiplyScalar(e),ts.multiplyScalar(-t);const i=At.copy(es).add(ts),s=Wt.copy(this._targetEnd).add(i);return this.moveTo(s.x,s.y,s.z,n)}forward(e,t=!1){At.setFromMatrixColumn(this._camera.matrix,0),At.crossVectors(this._camera.up,At),At.multiplyScalar(e);const n=Wt.copy(this._targetEnd).add(At);return this.moveTo(n.x,n.y,n.z,t)}elevate(e,t=!1){return At.copy(this._camera.up).multiplyScalar(e),this.moveTo(this._targetEnd.x+At.x,this._targetEnd.y+At.y,this._targetEnd.z+At.z,t)}moveTo(e,t,n,i=!1){this._isUserControllingTruck=!1;const s=At.set(e,t,n).sub(this._targetEnd);this._encloseToBoundary(this._targetEnd,s,this.boundaryFriction),this._needsUpdate=!0,i||this._target.copy(this._targetEnd);const o=!i||Zt(this._target.x,this._targetEnd.x,this.restThreshold)&&Zt(this._target.y,this._targetEnd.y,this.restThreshold)&&Zt(this._target.z,this._targetEnd.z,this.restThreshold);return this._createOnRestPromise(o)}lookInDirectionOf(e,t,n,i=!1){const a=At.set(e,t,n).sub(this._targetEnd).normalize().multiplyScalar(-this._sphericalEnd.radius).add(this._targetEnd);return this.setPosition(a.x,a.y,a.z,i)}fitToBox(e,t,{cover:n=!1,paddingLeft:i=0,paddingRight:s=0,paddingBottom:o=0,paddingTop:a=0}={}){const l=[],c=e.isBox3?Pl.copy(e):Pl.setFromObject(e);c.isEmpty()&&(console.warn("camera-controls: fitTo() cannot be used with an empty box. Aborting"),Promise.resolve());const u=FE(this._sphericalEnd.theta,NE),h=FE(this._sphericalEnd.phi,NE);l.push(this.rotateTo(u,h,t));const p=At.setFromSpherical(this._sphericalEnd).normalize(),m=VE.setFromUnitVectors(p,b0),v=Zt(Math.abs(p.y),1);v&&m.multiply(T0.setFromAxisAngle(fd,u)),m.multiply(this._yAxisUpSpaceInverse);const _=HE.makeEmpty();Wt.copy(c.min).applyQuaternion(m),_.expandByPoint(Wt),Wt.copy(c.min).setX(c.max.x).applyQuaternion(m),_.expandByPoint(Wt),Wt.copy(c.min).setY(c.max.y).applyQuaternion(m),_.expandByPoint(Wt),Wt.copy(c.max).setZ(c.min.z).applyQuaternion(m),_.expandByPoint(Wt),Wt.copy(c.min).setZ(c.max.z).applyQuaternion(m),_.expandByPoint(Wt),Wt.copy(c.max).setY(c.min.y).applyQuaternion(m),_.expandByPoint(Wt),Wt.copy(c.max).setX(c.min.x).applyQuaternion(m),_.expandByPoint(Wt),Wt.copy(c.max).applyQuaternion(m),_.expandByPoint(Wt),_.min.x-=i,_.min.y-=o,_.max.x+=s,_.max.y+=a,m.setFromUnitVectors(b0,p),v&&m.premultiply(T0.invert()),m.premultiply(this._yAxisUpSpace);const y=_.getSize(At),g=_.getCenter(Wt).applyQuaternion(m);if(ia(this._camera)){const x=this.getDistanceToFitBox(y.x,y.y,y.z,n);l.push(this.moveTo(g.x,g.y,g.z,t)),l.push(this.dollyTo(x,t)),l.push(this.setFocalOffset(0,0,0,t))}else if(ho(this._camera)){const x=this._camera,w=x.right-x.left,E=x.top-x.bottom,b=n?Math.max(w/y.x,E/y.y):Math.min(w/y.x,E/y.y);l.push(this.moveTo(g.x,g.y,g.z,t)),l.push(this.zoomTo(b,t)),l.push(this.setFocalOffset(0,0,0,t))}return Promise.all(l)}fitToSphere(e,t){const n=[],s="isObject3D"in e?Gv.createBoundingSphere(e,M0):M0.copy(e);if(n.push(this.moveTo(s.center.x,s.center.y,s.center.z,t)),ia(this._camera)){const o=this.getDistanceToFitSphere(s.radius);n.push(this.dollyTo(o,t))}else if(ho(this._camera)){const o=this._camera.right-this._camera.left,a=this._camera.top-this._camera.bottom,l=2*s.radius,c=Math.min(o/l,a/l);n.push(this.zoomTo(c,t))}return n.push(this.setFocalOffset(0,0,0,t)),Promise.all(n)}setLookAt(e,t,n,i,s,o,a=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._lastDollyDirection=Al.NONE,this._changedDolly=0;const l=Wt.set(i,s,o),c=At.set(e,t,n);this._targetEnd.copy(l),this._sphericalEnd.setFromVector3(c.sub(l).applyQuaternion(this._yAxisUpSpace)),this.normalizeRotations(),this._needsUpdate=!0,a||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));const u=!a||Zt(this._target.x,this._targetEnd.x,this.restThreshold)&&Zt(this._target.y,this._targetEnd.y,this.restThreshold)&&Zt(this._target.z,this._targetEnd.z,this.restThreshold)&&Zt(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&Zt(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&Zt(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(u)}lerpLookAt(e,t,n,i,s,o,a,l,c,u,h,p,m,v=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._lastDollyDirection=Al.NONE,this._changedDolly=0;const _=At.set(i,s,o),y=Wt.set(e,t,n);gr.setFromVector3(y.sub(_).applyQuaternion(this._yAxisUpSpace));const g=Rl.set(u,h,p),x=Wt.set(a,l,c);cu.setFromVector3(x.sub(g).applyQuaternion(this._yAxisUpSpace)),this._targetEnd.copy(_.lerp(g,m));const w=cu.theta-gr.theta,E=cu.phi-gr.phi,b=cu.radius-gr.radius;this._sphericalEnd.set(gr.radius+b*m,gr.phi+E*m,gr.theta+w*m),this.normalizeRotations(),this._needsUpdate=!0,v||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));const M=!v||Zt(this._target.x,this._targetEnd.x,this.restThreshold)&&Zt(this._target.y,this._targetEnd.y,this.restThreshold)&&Zt(this._target.z,this._targetEnd.z,this.restThreshold)&&Zt(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&Zt(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&Zt(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(M)}setPosition(e,t,n,i=!1){return this.setLookAt(e,t,n,this._targetEnd.x,this._targetEnd.y,this._targetEnd.z,i)}setTarget(e,t,n,i=!1){const s=this.getPosition(At),o=this.setLookAt(s.x,s.y,s.z,e,t,n,i);return this._sphericalEnd.phi=Ur(this._sphericalEnd.phi,this.minPolarAngle,this.maxPolarAngle),o}setFocalOffset(e,t,n,i=!1){this._isUserControllingOffset=!1,this._focalOffsetEnd.set(e,t,n),this._needsUpdate=!0,i||this._focalOffset.copy(this._focalOffsetEnd);const s=!i||Zt(this._focalOffset.x,this._focalOffsetEnd.x,this.restThreshold)&&Zt(this._focalOffset.y,this._focalOffsetEnd.y,this.restThreshold)&&Zt(this._focalOffset.z,this._focalOffsetEnd.z,this.restThreshold);return this._createOnRestPromise(s)}setOrbitPoint(e,t,n){this._camera.updateMatrixWorld(),es.setFromMatrixColumn(this._camera.matrixWorldInverse,0),ts.setFromMatrixColumn(this._camera.matrixWorldInverse,1),ra.setFromMatrixColumn(this._camera.matrixWorldInverse,2);const i=At.set(e,t,n),s=i.distanceTo(this._camera.position),o=i.sub(this._camera.position);es.multiplyScalar(o.x),ts.multiplyScalar(o.y),ra.multiplyScalar(o.z),At.copy(es).add(ts).add(ra),At.z=At.z+s,this.dollyTo(s,!1),this.setFocalOffset(-At.x,At.y,-At.z,!1),this.moveTo(e,t,n,!1)}setBoundary(e){if(!e){this._boundary.min.set(-1/0,-1/0,-1/0),this._boundary.max.set(1/0,1/0,1/0),this._needsUpdate=!0;return}this._boundary.copy(e),this._boundary.clampPoint(this._targetEnd,this._targetEnd),this._needsUpdate=!0}setViewport(e,t,n,i){if(e===null){this._viewport=null;return}this._viewport=this._viewport||new vt.Vector4,typeof e=="number"?this._viewport.set(e,t,n,i):this._viewport.copy(e)}getDistanceToFitBox(e,t,n,i=!1){if(S0(this._camera,"getDistanceToFitBox"))return this._spherical.radius;const s=e/t,o=this._camera.getEffectiveFOV()*su,a=this._camera.aspect;return((i?s>a:st.pointerId===e)}_findPointerByMouseButton(e){return this._activePointers.find(t=>t.mouseButton===e)}_disposePointer(e){this._activePointers.splice(this._activePointers.indexOf(e),1)}_encloseToBoundary(e,t,n){const i=t.lengthSq();if(i===0)return e;const s=Wt.copy(t).add(e),a=this._boundary.clampPoint(s,Rl).sub(s),l=a.lengthSq();if(l===0)return e.add(t);if(l===i)return e;if(n===0)return e.add(t).add(a);{const c=1+n*l/t.dot(a);return e.add(Wt.copy(t).multiplyScalar(c)).add(a.multiplyScalar(1-n))}}_updateNearPlaneCorners(){if(ia(this._camera)){const e=this._camera,t=e.near,n=e.getEffectiveFOV()*su,i=Math.tan(n*.5)*t,s=i*e.aspect;this._nearPlaneCorners[0].set(-s,-i,0),this._nearPlaneCorners[1].set(s,-i,0),this._nearPlaneCorners[2].set(s,i,0),this._nearPlaneCorners[3].set(-s,i,0)}else if(ho(this._camera)){const e=this._camera,t=1/e.zoom,n=e.left*t,i=e.right*t,s=e.top*t,o=e.bottom*t;this._nearPlaneCorners[0].set(n,s,0),this._nearPlaneCorners[1].set(i,s,0),this._nearPlaneCorners[2].set(i,o,0),this._nearPlaneCorners[3].set(n,o,0)}}_collisionTest(){let e=1/0;if(!(this.colliderMeshes.length>=1)||S0(this._camera,"_collisionTest"))return e;const n=this._getTargetDirection(lu);A0.lookAt(zE,n,this._camera.up);for(let i=0;i<4;i++){const s=Wt.copy(this._nearPlaneCorners[i]);s.applyMatrix4(A0);const o=Rl.addVectors(this._target,s);dd.set(o,n),dd.far=this._spherical.radius+1;const a=dd.intersectObjects(this.colliderMeshes);a.length!==0&&a[0].distance{const n=()=>{this.removeEventListener("rest",n),t()};this.addEventListener("rest",n)}))}_addAllEventListeners(e){}_removeAllEventListeners(){}get dampingFactor(){return console.warn(".dampingFactor has been deprecated. use smoothTime (in seconds) instead."),0}set dampingFactor(e){console.warn(".dampingFactor has been deprecated. use smoothTime (in seconds) instead.")}get draggingDampingFactor(){return console.warn(".draggingDampingFactor has been deprecated. use draggingSmoothTime (in seconds) instead."),0}set draggingDampingFactor(e){console.warn(".draggingDampingFactor has been deprecated. use draggingSmoothTime (in seconds) instead.")}static createBoundingSphere(e,t=new vt.Sphere){const n=t,i=n.center;Pl.makeEmpty(),e.traverseVisible(o=>{o.isMesh&&Pl.expandByObject(o)}),Pl.getCenter(i);let s=0;return e.traverseVisible(o=>{if(!o.isMesh)return;const a=o;if(!a.geometry)return;const l=a.geometry.clone();l.applyMatrix4(a.matrixWorld);const u=l.attributes.position;for(let h=0,p=u.count;h"u")&&(s[o]=r[o]);return s.max=i||s.max,s.truncate=="middle"?e(n,s.max,s.ellipse,s.chars):t(n,s.max,s.ellipse,s.chars,s.truncate)},uu.exports.ellipsizeMiddle=e,uu.exports.ellipsize=t,uu.exports}var v5=g5();const y5=Hr(v5);/*! * hold-event * https://github.com/yomotsu/hold-event * (c) 2020 @yomotsu * Released under the MIT License. */var Au;(function(r){r.HOLD_START="holdStart",r.HOLD_END="holdEnd",r.HOLDING="holding"})(Au||(Au={}));class _5{constructor(){this._listeners={}}addEventListener(e,t){const n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}removeEventListener(e,t){const i=this._listeners[e];if(i!==void 0){const s=i.indexOf(t);s!==-1&&i.splice(s,1)}}dispatchEvent(e){const n=this._listeners[e.type];if(n!==void 0){e.target=this;const i=n.slice(0);for(let s=0,o=i.length;s{if(!this._enabled||this._holding)return;this._deltaTime=0,this._elapsedTime=0,this._lastTime=performance.now(),this.dispatchEvent({type:Au.HOLD_START,deltaTime:this._deltaTime,elapsedTime:this._elapsedTime,originalEvent:t}),this._holding=!0;const n=()=>{this._intervalId=this.holdIntervalDelay?window.setTimeout(n,this.holdIntervalDelay):window.requestAnimationFrame(n);const i=performance.now();this._deltaTime=i-this._lastTime,this._elapsedTime+=this._deltaTime,this._lastTime=performance.now(),this.dispatchEvent({type:Au.HOLDING,deltaTime:this._deltaTime,elapsedTime:this._elapsedTime,originalEvent:t})};this._intervalId=this.holdIntervalDelay?window.setTimeout(n,this.holdIntervalDelay):window.requestAnimationFrame(n)},this._holdEnd=t=>{if(!this._enabled||!this._holding)return;const n=performance.now();this._deltaTime=n-this._lastTime,this._elapsedTime+=this._deltaTime,this._lastTime=performance.now(),this.dispatchEvent({type:Au.HOLD_END,deltaTime:this._deltaTime,elapsedTime:this._elapsedTime,originalEvent:t}),window.clearTimeout(this._intervalId),window.cancelAnimationFrame(this._intervalId),this._holding=!1},this.holdIntervalDelay=e}get enabled(){return this._enabled}set enabled(e){this._enabled!==e&&(this._enabled=e,this._enabled||this._holdEnd())}}class kp extends x5{constructor(e,t){super(t),this._holdStart=this._holdStart.bind(this),this._holdEnd=this._holdEnd.bind(this);const n=s=>{w5(s)||s.keyCode===e&&this._holdStart(s)},i=s=>{s.keyCode===e&&this._holdEnd(s)};document.addEventListener("keydown",n),document.addEventListener("keyup",i),window.addEventListener("blur",this._holdEnd)}}function w5(r){const e=r.target;return e.tagName==="INPUT"||e.tagName==="SELECT"||e.tagName==="TEXTAREA"||e.isContentEditable}var C0={exports:{}};/*! Copyright (c) 2018 Jed Watson. Licensed under the MIT License (MIT), see http://jedwatson.github.io/classnames */var XE;function S5(){return XE||(XE=1,(function(r){(function(){var e={}.hasOwnProperty;function t(){for(var s="",o=0;o-1){const s=[...e.slice(i),n].map(o=>o.data.id);throw new Error(`Invalid Graph: Circular node path detected: ${s.join(" -> ")}.`)}t>n.depth&&(n.depth=t,a2(n.out,[...e,n]))}}function l2(r,e){let t=!1;const n=r.reduce((o,a)=>({...o,[a.id]:{data:a,out:[],depth:-1,ins:[]}}),{});try{for(const o of e){const a=o.source,l=o.target;if(!n.hasOwnProperty(a))throw new Error(`Missing source Node ${a}`);if(!n.hasOwnProperty(l))throw new Error(`Missing target Node ${l}`);const c=n[a],u=n[l];u.ins.push(c),c.out.push(u)}a2(Object.values(n))}catch{t=!0}const i=Object.keys(n).map(o=>n[o].depth),s=Math.max(...i);return{invalid:t,depths:n,maxDepth:s||1}}const qE=["radialin","radialout"];function E5({nodes:r,edges:e,mode:t="lr",nodeLevelRatio:n=2}){const{depths:i,maxDepth:s,invalid:o}=l2(r,e);if(o)return null;const a=qE.includes(t)?1:5,l=r.length/s*n*a;if(t){const c=(m,v)=>_=>m?(i[_.id].depth-s/2)*l*(v?-1:1):void 0,u=c(["lr","rl"].includes(t),t==="rl"),h=c(["td","bu"].includes(t),t==="td"),p=c(["zin","zout"].includes(t),t==="zout");r.forEach(m=>{m.fx=u(m),m.fy=h(m),m.fz=p(m)})}return qE.includes(t)?KN(c=>{const u=i[c.id];return(t==="radialin"?s-u.depth:u.depth)*l}).strength(1):null}function b5(r){return new Promise((e,t)=>{let n;function i(){n?e(n):(n=r.step(),i())}i()})}function _h(r){const e=[],t=[];return r.forEachNode((n,i)=>{e.push({...i,id:n,radius:i.size||1})}),r.forEachEdge((n,i)=>{t.push({...i,id:n})}),{nodes:e,edges:t}}function M5(){const r=O=>()=>O;let t=O=>O.index,n=[],i=[],s,o,a=[100,100],l=r(1),c=r(-1),u=r(100),h=r(.1),p={},m=.1,v=.001,_=[],y=[0,0],g,x=O=>O.cluster,w="treemap",E=!0,b=.1;function M(O){if(!E)return M;w==="force"&&(g.tick(),I());for(let k=0,G=n.length,B,D=O*b;kk.radius).sort(function(k,G){return G.height-k.height||G.value-k.value}),_=O(o).leaves(),I()}function q(){let O=0;n.length!==0&&i.forEach(function(k){let G,B;if(n){if(G=k.source,B=k.target,typeof k.source!="object"&&(G=n.find(D=>D.id===k.source)),typeof k.target!="object"&&(B=n.find(D=>D.id===k.target)),G===void 0||B===void 0)throw Error("Error setting links, couldnt find nodes for a link (see it on the console)");k.source=G,k.target=B,k.index=O++}})}function W(){let O;!n||!n.length||(q(),O=F(),s.size>0&&O.nodes.forEach(k=>{var G,B,D,V;k.fx=(B=(G=s.get(k.id))==null?void 0:G.position)==null?void 0:B.x,k.fy=(V=(D=s.get(k.id))==null?void 0:D.position)==null?void 0:V.y}),g=zT(O.nodes).force("x",xv(a[0]/2).strength(.1)).force("y",wv(a[1]/2).strength(.1)).force("collide",IT(k=>k.r).iterations(4)).force("charge",BT().strength(c)).force("links",DT(O.nodes.length?O.links:[]).distance(u).strength(h)),_=g.nodes(),I())}return M.template=function(O){return arguments.length?(w=O,A(),M):w},M.groupBy=function(O){return arguments.length?typeof O=="string"?(x=function(k){return k[O]},M):(x=O,M):x},M.enableGrouping=function(O){return arguments.length?(E=O,M):E},M.strength=function(O){return arguments.length?(b=O,M):b},M.getLinkStrength=function(O){return E?x(O.source)===x(O.target)?typeof m=="function"?m(O):m:typeof v=="function"?v(O):v:typeof m=="function"?m(O):m},M.id=function(O){return arguments.length?(t=O,M):t},M.size=function(O){return arguments.length?(a=O,M):a},M.linkStrengthInterCluster=function(O){return arguments.length?(v=O,M):v},M.linkStrengthIntraCluster=function(O){return arguments.length?(m=O,M):m},M.nodes=function(O){return arguments.length?(n=O,M):n},M.links=function(O){return arguments.length?(O===null?i=[]:i=O,A(),M):i},M.template=function(O){return arguments.length?(w=O,A(),M):w},M.forceNodeSize=function(O){return arguments.length?(l=typeof O=="function"?O:r(+O),A(),M):l},M.nodeSize=M.forceNodeSize,M.forceCharge=function(O){return arguments.length?(c=typeof O=="function"?O:r(+O),A(),M):c},M.forceLinkDistance=function(O){return arguments.length?(u=typeof O=="function"?O:r(+O),A(),M):u},M.forceLinkStrength=function(O){return arguments.length?(h=typeof O=="function"?O:r(+O),A(),M):h},M.offset=function(O){return arguments.length?(y=typeof O=="function"?O:r(+O),M):y},M.getFocis=I,M.setClusters=function(O){return s=O,M},M}function uo({graph:r,nodeLevelRatio:e=2,mode:t=null,dimensions:n=2,nodeStrength:i=-250,linkDistance:s=50,clusterStrength:o=.5,linkStrengthInterCluster:a=.01,linkStrengthIntraCluster:l=.5,forceLinkDistance:c=100,forceLinkStrength:u=.1,clusterType:h="force",forceCharge:p=-700,getNodePosition:m,drags:v,clusters:_,clusterAttribute:y,forceLayout:g}){const{nodes:x,edges:w}=_h(r),b=n===2&&w.length>25?i*2:i;let M,A;g==="forceDirected2d"?(M=xv(),A=wv()):(M=xv(600).strength(.05),A=wv(600).strength(.05));const P=zT().force("center",FO(0,0)).force("link",DT()).force("charge",BT().strength(b)).force("x",M).force("y",A).force("z",$N()).force("collide",IT(N=>N.radius+10)).force("dagRadial",E5({nodes:x,edges:w,mode:t,nodeLevelRatio:e})).stop();let C;if(y){let N=p;if(x!=null&&x.length){const I=Math.ceil(x.length/200);N=p*I}C=M5().setClusters(_).strength(o).template(h).groupBy(I=>I.data[y]).links(w).size([100,100]).linkStrengthInterCluster(a).linkStrengthIntraCluster(l).forceLinkDistance(c).forceLinkStrength(u).forceCharge(N).forceNodeSize(I=>I.radius)}let L=P.numDimensions(n).nodes(x);if(C&&(L=L.force("group",C)),s){let N=L.force("link");N&&(N.id(I=>I.id).links(w).distance(s),C&&(N=N.strength((C==null?void 0:C.getLinkStrength)??.1)))}const F=new Map(x.map(N=>[N.id,N]));return{step(){for(;P.alpha()>.01;)P.tick();return!0},getNodePosition(N){var I,X;if(m){const q=m(N,{graph:r,drags:v,nodes:x,edges:w});if(q)return q}return(I=v==null?void 0:v[N])!=null&&I.position?(X=v==null?void 0:v[N])==null?void 0:X.position:F.get(N)}}}function T5({graph:r,radius:e,drags:t,getNodePosition:n}){const i=FF(r,{scale:e}),{nodes:s,edges:o}=_h(r);return{step(){return!0},getNodePosition(a){var l,c;if(n){const u=n(a,{graph:r,drags:t,nodes:s,edges:o});if(u)return u}return(l=t==null?void 0:t[a])!=null&&l.position?(c=t==null?void 0:t[a])==null?void 0:c.position:i==null?void 0:i[a]}}}const A5={td:{x:"x",y:"y",factor:-1},lr:{x:"y",y:"x",factor:1}};function ZE({graph:r,drags:e,mode:t="td",nodeSeparation:n=1,nodeSize:i=[50,50],getNodePosition:s}){const{nodes:o,edges:a}=_h(r),{depths:l}=l2(o,a),c=Object.keys(l).map(_=>l[_]),u=SF().id(_=>_.data.id).parentId(_=>{var y,g,x;return(x=(g=(y=_.ins)==null?void 0:y[0])==null?void 0:g.data)==null?void 0:x.id})(c),p=RF().separation(()=>n).nodeSize(i)(Mp(u)).descendants(),m=A5[t],v=new Map(o.map(_=>{const{x:y,y:g}=p.find(x=>x.data.id===_.id);return[_.id,{..._,[m.x]:y*m.factor,[m.y]:g*m.factor,z:0}]}));return{step(){return!0},getNodePosition(_){var y,g;if(s){const x=s(_,{graph:r,drags:e,nodes:o,edges:a});if(x)return x}return(y=e==null?void 0:e[_])!=null&&y.position?(g=e==null?void 0:e[_])==null?void 0:g.position:v.get(_)}}}function C5({graph:r,margin:e,drags:t,getNodePosition:n,ratio:i,gridSize:s,maxIterations:o}){const{nodes:a,edges:l}=_h(r),c=VF(r,{maxIterations:o,inputReducer:(u,h)=>({...h,x:h.x||0,y:h.y||0}),settings:{ratio:i,margin:e,gridSize:s}});return{step(){return!0},getNodePosition(u){var h,p;if(n){const m=n(u,{graph:r,drags:t,nodes:a,edges:l});if(m)return m}return(h=t==null?void 0:t[u])!=null&&h.position?(p=t==null?void 0:t[u])==null?void 0:p.position:c==null?void 0:c[u]}}}function R5({graph:r,drags:e,iterations:t,...n}){JF.assign(r);const i=ZF(r,{iterations:t,settings:n});return{step(){return!0},getNodePosition(s){var o;return((o=e==null?void 0:e[s])==null?void 0:o.position)||(i==null?void 0:i[s])}}}function P5({graph:r,drags:e,getNodePosition:t}){const{nodes:n,edges:i}=_h(r);return{step(){return!0},getNodePosition(s){return t(s,{graph:r,drags:e,nodes:n,edges:i})}}}const L5=["forceDirected2d","treeTd2d","treeLr2d","radialOut2d","treeTd3d","treeLr3d","radialOut3d","forceDirected3d"];function I5({type:r,...e}){if(L5.includes(r)){const{nodeStrength:t,linkDistance:n,nodeLevelRatio:i}=e;if(r==="forceDirected2d")return uo({...e,dimensions:2,nodeLevelRatio:i||2,nodeStrength:t||-250,linkDistance:n,forceLayout:r});if(r==="treeTd2d")return uo({...e,mode:"td",dimensions:2,nodeLevelRatio:i||5,nodeStrength:t||-250,linkDistance:n||50,forceLayout:r});if(r==="treeLr2d")return uo({...e,mode:"lr",dimensions:2,nodeLevelRatio:i||5,nodeStrength:t||-250,linkDistance:n||50,forceLayout:r});if(r==="radialOut2d")return uo({...e,mode:"radialout",dimensions:2,nodeLevelRatio:i||5,nodeStrength:t||-500,linkDistance:n||100,forceLayout:r});if(r==="treeTd3d")return uo({...e,mode:"td",dimensions:3,nodeLevelRatio:i||2,nodeStrength:t||-500,linkDistance:n||50});if(r==="treeLr3d")return uo({...e,mode:"lr",dimensions:3,nodeLevelRatio:i||2,nodeStrength:t||-500,linkDistance:n||50,forceLayout:r});if(r==="radialOut3d")return uo({...e,mode:"radialout",dimensions:3,nodeLevelRatio:i||2,nodeStrength:t||-500,linkDistance:n||100,forceLayout:r});if(r==="forceDirected3d")return uo({...e,dimensions:3,nodeLevelRatio:i||2,nodeStrength:t||-250,linkDistance:n,forceLayout:r})}else if(r==="circular2d"){const{radius:t}=e;return T5({...e,radius:t||300})}else{if(r==="hierarchicalTd")return ZE({...e,mode:"td"});if(r==="hierarchicalLr")return ZE({...e,mode:"lr"});if(r==="nooverlap"){const{graph:t,maxIterations:n,ratio:i,margin:s,gridSize:o,...a}=e;return C5({graph:t,margin:s||10,maxIterations:n||50,ratio:i||10,gridSize:o||20,...a})}else if(r==="forceatlas2"){const{graph:t,iterations:n,gravity:i,scalingRatio:s,...o}=e;return R5({type:"forceatlas2",graph:t,...o,scalingRatio:s||100,gravity:i||10,iterations:n||50})}else if(r==="custom")return P5({...e})}throw new Error(`Layout ${r} not found.`)}function c2({nodeCount:r,nodePosition:e,labelType:t,camera:n}){return(i,s)=>{var o;if(n&&e&&((o=n==null?void 0:n.position)==null?void 0:o.z)/(n==null?void 0:n.zoom)-(e==null?void 0:e.z)>6e3)return!1;if(t==="all")return!0;if(t==="nodes"&&i==="node")return!0;if(t==="edges"&&i==="edge")return!0;if(t==="auto"&&i==="node"){if(s>7)return!0;if(n&&e&&n.position.z/n.zoom-e.z<3e3)return!0}return!1}}function u2(r,e){switch(e){case"above":return r;case"below":return-r;case"inline":case"natural":default:return 0}}function D5({graph:r}){const e=nk(r);return{ranks:e,getSizeForNode:t=>e[t]*80}}function U5({graph:r}){const e=rk.degreeCentrality(r);return{ranks:e,getSizeForNode:t=>e[t]*20}}function O5({graph:r,attribute:e,defaultSize:t}){const n=new Map;return e?r.forEachNode((i,s)=>{var o;const a=(o=s.data)==null?void 0:o[e];isNaN(a)&&console.warn(`Attribute ${a} is not a number for node ${s.id}`),n.set(i,a||0)}):console.warn("Attribute sizing configured but no attribute provided"),{getSizeForNode:i=>!e||!n?t:n.get(i)}}const KE={pagerank:D5,centrality:U5,attribute:O5,none:({defaultSize:r})=>({getSizeForNode:e=>r})};function N5({type:r,...e}){var t;const n=(t=KE[r])==null?void 0:t.call(KE,e);if(!n&&r!=="default")throw new Error(`Unknown sizing strategy: ${r}`);const{graph:i,minSize:s,maxSize:o}=e,a=new Map;let l,c;if(i.forEachNode((u,h)=>{let p;r==="default"?p=h.size||e.defaultSize:p=n.getSizeForNode(u),(l===void 0||pc)&&(c=p),a.set(u,p)}),r!=="none"){const u=Z2().domain([l,c]).rangeRound([s,o]);for(const[h,p]of a)a.set(h,u(p))}return a}function F5(r,e,t){r.clear();const n=new Set;for(const i of e)try{n.has(i.id)||(r.addNode(i.id,i),n.add(i.id))}catch(s){console.error(`[Graph] Error adding node '${i.id}`,s)}for(const i of t)if(!(!n.has(i.source)||!n.has(i.target)))try{r.addEdge(i.source,i.target,i)}catch(s){console.error(`[Graph] Error adding edge '${i.source} -> ${i.target}`,s)}return r}function k5({graph:r,layout:e,sizingType:t,labelType:n,sizingAttribute:i,defaultNodeSize:s,minNodeSize:o,maxNodeSize:a,clusterAttribute:l}){const c=[],u=[],h=new Map,p=N5({graph:r,type:t,attribute:i,minSize:o,maxSize:a,defaultSize:s}),m=r.nodes().length,v=c2({nodeCount:m,labelType:n});return r.forEachNode((_,y)=>{const g=e.getNodePosition(_),{data:x,fill:w,icon:E,label:b,size:M,...A}=y,P=p.get(y.id),C=v("node",P),F=(r.inboundNeighbors(y.id)||[]).map(I=>r.getNodeAttributes(I)),N={...y,size:P,labelVisible:C,label:b,icon:E,fill:w,cluster:l?x[l]:void 0,parents:F,data:{...A,...x??{}},position:{...g,x:g.x||0,y:g.y||0,z:g.z||1}};h.set(y.id,N),c.push(N)}),r.forEachEdge((_,y)=>{const g=h.get(y.source),x=h.get(y.target);if(g&&x){const{data:w,id:E,label:b,size:M,...A}=y,P=v("edge",M);u.push({...y,id:E,label:b,labelVisible:P,size:M,data:{...A,id:E,...w||{}}})}}),{nodes:c,edges:u}}const nr={mass:10,tension:1e3,friction:300,precision:.1};function h2(r,e,t){const n=e.getLength(),i=r==="end"?n:n/2,s=r==="end"?t/2:0,o=(i-s)/n,a=e.getPointAt(o),l=e.getTangentAt(o);return[a,l]}function f2(r){return[r+6,2+r/1.5]}const R0=.7;function d2(r,e,t=0){const n=new Y(r.x,r.y||0,r.z||0),i=new Y(e.x,e.y||0,e.z||0),s=new Y().addVectors(n,i).divideScalar(2);return s.setLength(s.length()+t)}function z5(r,e,t=-1){const n=r.clone(),i=e.clone(),s=new Y().subVectors(i,n),o=s.length(),a=s.clone().normalize(),l=new Y().subVectors(i,n).divideScalar(2),c=Math.abs(a.x)%1,u=new Y(-a.y,a.x-c*a.z,c*a.y).normalize(),h=new Y().add(n).add(l).add(u.multiplyScalar(o/4).multiplyScalar(t));return[r,h,e]}function Qu(r,e,t,n,i,s){const o=$E(r,t,e),a=$E(t,r,n);return i?new lp(...z5(o,a,s)):new vy(o,a)}function eh(r){return new Y(r.position.x,r.position.y,r.position.z||0)}function $E(r,e,t){const n=r.distanceTo(e);return r.clone().add(e.clone().sub(r).multiplyScalar(t/n))}function JE(r,e){return{...r,position:{...r.position,x:r.position.x+e.x,y:r.position.y+e.y,z:r.position.z+e.z}}}function B5({edge:r,edges:e,curved:t}){let n=t,i;const s=e.filter(o=>o.target===r.target&&o.source===r.source).map(o=>o.id);if(s.length>1){n=!0;const o=s.indexOf(r.id);s.length===2?i=o===0?R0:-R0:i=(o-Math.floor(s.length/2))*R0}return{curved:n,curveOffset:i}}function th(r){let e=Number.POSITIVE_INFINITY,t=Number.NEGATIVE_INFINITY,n=Number.POSITIVE_INFINITY,i=Number.NEGATIVE_INFINITY,s=Number.POSITIVE_INFINITY,o=Number.NEGATIVE_INFINITY;for(let a of r)e=Math.min(e,a.position.x),t=Math.max(t,a.position.x),n=Math.min(n,a.position.y),i=Math.max(i,a.position.y),s=Math.min(s,a.position.z),o=Math.max(o,a.position.z);return{height:i-n,width:t-e,minX:e,maxX:t,minY:n,maxY:i,minZ:s,maxZ:o,x:(t+e)/2,y:(i+n)/2,z:(o+s)/2}}function G5(r,e){return e?r.reduce((t,n)=>{const i=n.data[e];return i&&t.set(i,[...t.get(i)||[],n]),t},new Map):new Map}function H5({nodes:r,clusterAttribute:e}){const t=new Map;if(e){const n=G5(r,e);for(const[i,s]of n){const o=th(s);t.set(i,{label:i,nodes:s,position:o})}}return t}const m_=({sensitivity:r=7,interval:e=50,timeout:t=0,disabled:n,onPointerOver:i,onPointerOut:s})=>{const o=K.useRef(!1),a=K.useRef(null),l=K.useRef(0),c=K.useRef({x:null,y:null,px:null,py:null}),u=K.useCallback(y=>{c.current.x=y.clientX,c.current.y=y.clientY},[]),h=K.useCallback(y=>{a.current=clearTimeout(a.current);const{px:g,x,py:w,y:E}=c.current;Math.abs(g-x)+Math.abs(w-E)h(y),e))},[e,i,r]),p=K.useCallback(()=>{clearTimeout(a.current),typeof window<"u"&&document.removeEventListener("mousemove",u,!1)},[u]),m=K.useCallback(y=>{n||(o.current=!0,p(),l.current!==1&&(c.current.px=y.pointer.x,c.current.py=y.pointer.y,typeof window<"u"&&document.addEventListener("mousemove",u,!1),a.current=setTimeout(()=>h(y),t)))},[p,h,n,u,t]),v=K.useCallback(y=>{a.current=clearTimeout(a.current),l.current=0,s(y)},[s]),_=K.useCallback(y=>{o.current=!1,p(),l.current===1&&(a.current=setTimeout(()=>v(y),t))},[p,v,t]);return{pointerOver:m,pointerOut:_}},p2=({draggable:r,set:e,position:t,bounds:n,onDragStart:i,onDragEnd:s})=>{const o=Bn(y=>y.camera),a=Bn(y=>y.raycaster),l=Bn(y=>y.size),c=Bn(y=>y.gl),{mouse2D:u,mouse3D:h,offset:p,normal:m,plane:v}=K.useMemo(()=>({mouse2D:new De,mouse3D:new Y,offset:new Y,normal:new Y,plane:new Us}),[]),_=K.useMemo(()=>c.domElement.getBoundingClientRect(),[c.domElement]);return Pz({onDragStart:({event:y})=>{const{eventObject:g,point:x}=y;g.getWorldPosition(p).sub(x),h.copy(x),i()},onDrag:({xy:y,buttons:g,cancel:x})=>{if(g!==1){x();return}const w=(y[0]-((_==null?void 0:_.left)??0))/l.width*2-1,E=-((y[1]-((_==null?void 0:_.top)??0))/l.height)*2+1;u.set(w,E),a.setFromCamera(u,o),o.getWorldDirection(m).negate(),v.setFromNormalAndCoplanarPoint(m,h),a.ray.intersectPlane(v,h);const b=new Y(t.x,t.y,t.z).copy(h).add(p);if(n){const M=new Y((n.minX+n.maxX)/2,(n.minY+n.maxY)/2,(n.minZ+n.maxZ)/2),A=(n.maxX-n.minX)/2,P=b.clone().sub(M);P.length()>A&&(P.normalize().multiplyScalar(A),b.copy(M).add(P))}return e(b)},onDragEnd:s},{drag:{enabled:r,threshold:10}})},{Provider:V5,useStore:qe}=vk(),W5=({actives:r=[],selections:e=[],collapsedNodeIds:t=[],theme:n})=>mk(i=>({theme:{...n,edge:{...n.edge,label:{...n.edge.label,fontSize:n.edge.label.fontSize??6}}},edges:[],nodes:[],collapsedNodeIds:t,clusters:new Map,panning:!1,draggingIds:[],actives:r,edgeContextMenus:new Set,edgeMeshes:[],selections:e,hoveredNodeId:null,drags:{},graph:new en({multi:!0}),setTheme:s=>i(o=>({...o,theme:s})),setClusters:s=>i(o=>({...o,clusters:s})),setEdgeContextMenus:s=>i(o=>({...o,edgeContextMenus:s})),setEdgeMeshes:s=>i(o=>({...o,edgeMeshes:s})),setPanning:s=>i(o=>({...o,panning:s})),setDrags:s=>i(o=>({...o,drags:s})),addDraggingId:s=>i(o=>({...o,draggingIds:[...o.draggingIds,s]})),removeDraggingId:s=>i(o=>({...o,draggingIds:o.draggingIds.filter(a=>a!==s)})),setActives:s=>i(o=>({...o,actives:s})),setSelections:s=>i(o=>({...o,selections:s})),setHoveredNodeId:s=>i(o=>({...o,hoveredNodeId:s})),setNodes:s=>i(o=>({...o,nodes:s,centerPosition:th(s)})),setEdges:s=>i(o=>({...o,edges:s})),setNodePosition:(s,o)=>i(a=>{var l,c;const u=a.nodes.find(_=>_.id===s),h=eh(u),m=new Y(o.x,o.y,o.z).sub(h),v=[...a.nodes];if((l=a.selections)!=null&&l.includes(s))(c=a.selections)==null||c.forEach(_=>{const y=a.nodes.find(g=>g.id===_);if(y){const g=a.nodes.indexOf(y);v[g]=JE(y,m)}});else{const _=a.nodes.indexOf(u);v[_]=JE(u,m)}return{...a,drags:{...a.drags,[s]:u},nodes:v}}),setCollapsedNodeIds:(s=[])=>i(o=>({...o,collapsedNodeIds:s})),setClusterPosition:(s,o)=>i(a=>{const l=new Map(a.clusters),c=l.get(s);if(c){const u=c.position,h=new Y(o.x-u.x,o.y-u.y,o.z-(u.z??0)),p=[...a.nodes],m={...a.drags};p.forEach((y,g)=>{y.cluster===s&&(p[g]={...y,position:{...y.position,x:y.position.x+h.x,y:y.position.y+h.y,z:y.position.z+(h.z??0)}},m[y.id]=y)});const v=p.filter(y=>y.cluster===s),_=th(v);return l.set(s,{...c,position:_}),{...a,drags:{...m,[s]:c},clusters:l,nodes:p}}return a})}));function m2({nodeId:r,nodes:e,edges:t,currentHiddenNodes:n,currentHiddenEdges:i}){const s=[],o=[],a=n.map(m=>m.id),l=i.map(m=>m.id),c=t.filter(m=>m.source===r),u=c.map(m=>m.target);o.push(...c);for(const m of u){const v=t.filter(y=>y.target===m&&y.source!==r);let _=!1;if((v.length===0||v.length>0&&!a.includes(m)&&v.map(g=>g.id).every(g=>l.includes(g)))&&(_=!0),_){const y=e.find(x=>x.id===m);y&&s.push(y);const g=m2({nodeId:m,nodes:e,edges:t,currentHiddenEdges:o,currentHiddenNodes:s});o.push(...g.hiddenEdges),s.push(...g.hiddenNodes)}}const h=Object.values(o.reduce((m,v)=>({...m,[v.id]:v}),{})),p=Object.values(s.reduce((m,v)=>({...m,[v.id]:v}),{}));return{hiddenEdges:h,hiddenNodes:p}}const X5=({collapsedIds:r,nodes:e,edges:t})=>{const n=[],i=[];for(const c of r){const{hiddenEdges:u,hiddenNodes:h}=m2({nodeId:c,nodes:e,edges:t,currentHiddenEdges:i,currentHiddenNodes:n});n.push(...h),i.push(...u)}const s=n.map(c=>c.id),o=i.map(c=>c.id),a=e.filter(c=>!s.includes(c.id)),l=t.filter(c=>!o.includes(c.id));return{visibleNodes:a,visibleEdges:l}},j5=({layoutType:r,sizingType:e,labelType:t,sizingAttribute:n,clusterAttribute:i,selections:s,nodes:o,edges:a,actives:l,collapsedNodeIds:c,defaultNodeSize:u,maxNodeSize:h,minNodeSize:p,layoutOverrides:m,constrainDragging:v})=>{const _=qe(D=>D.graph),y=qe(D=>D.clusters),g=qe(D=>D.nodes),x=qe(D=>D.setClusters),w=qe(D=>D.collapsedNodeIds),E=qe(D=>D.setEdges),b=qe(D=>D.nodes),M=qe(D=>D.setNodes),A=qe(D=>D.setSelections),P=qe(D=>D.setActives),C=qe(D=>D.drags),L=qe(D=>D.setDrags),F=qe(D=>D.setCollapsedNodeIds),N=K.useRef(!1),I=K.useRef(null),X=Bn(D=>D.camera),q=K.useRef(C),W=K.useRef([]);K.useEffect(()=>{var D;if(!i)return;const V=g.map(ee=>ee.id),Z=o.find(ee=>!V.includes(ee.id));if(Z){const ee=Z.data[i],ie=y.get(ee),ue={...q.current};(D=ie==null?void 0:ie.nodes)==null||D.forEach(ce=>ue[ce.id]=void 0),q.current=ue,L(ue)}},[g,o,i,y,L]);const{visibleEdges:O,visibleNodes:k}=K.useMemo(()=>X5({collapsedIds:w,nodes:o,edges:a}),[w,o,a]),G=K.useCallback(D=>{const V={...q.current};D.forEach(Z=>V[Z.id]=Z),q.current=V,L(V)},[L]),B=K.useCallback(async D=>{I.current=D||I5({...m,type:r,graph:_,drags:q.current,clusters:W==null?void 0:W.current,clusterAttribute:i}),await b5(I.current);const V=k5({graph:_,layout:I.current,sizingType:e,labelType:t,sizingAttribute:n,maxNodeSize:h,minNodeSize:p,defaultNodeSize:u,clusterAttribute:i}),Z=H5({nodes:V.nodes,clusterAttribute:i});v&&Z.forEach(ee=>{var ie,ue;const ce=W.current.get(ee.label);(ce==null?void 0:ce.nodes.length)===ee.nodes.length&&(ee.position=((ue=(ie=W.current)==null?void 0:ie.get(ee.label))==null?void 0:ue.position)??ee.position)}),E(V.edges),M(V.nodes),x(Z),i&&G(V.nodes)},[m,r,i,e,t,n,h,p,u,E,M,x]);return K.useEffect(()=>{q.current=C},[C,i,B]),K.useEffect(()=>{W.current=y},[y]),K.useEffect(()=>{const D=b.map(Z=>({...Z,labelVisible:c2({nodeCount:b==null?void 0:b.length,labelType:t,camera:X,nodePosition:Z==null?void 0:Z.position})("node",Z==null?void 0:Z.size)}));D.some((Z,ee)=>Z.labelVisible!==b[ee].labelVisible)&&M(D)},[X,X.zoom,X.position.z,M,b,t]),K.useEffect(()=>{N.current&&A(s)},[s,A]),K.useEffect(()=>{N.current&&P(l)},[l,P]),K.useEffect(()=>{async function D(){N.current=!1,F5(_,k,O),await B(),requestAnimationFrame(()=>N.current=!0)}D()},[k,O]),K.useEffect(()=>{N.current&&F(c)},[c,F]),K.useEffect(()=>{N.current&&(q.current={},L({}),B())},[r,B,L]),K.useEffect(()=>{N.current&&B(I.current)},[e,n,t,B]),{updateLayout:B}},nh=({text:r,fontSize:e=7,fontUrl:t,color:n="#2A6475",opacity:i=1,stroke:s,active:o,ellipsis:a=75,rotation:l})=>{const c=a&&!o?y5(r,a):r,u=K.useMemo(()=>new Ke(n),[n]),h=K.useMemo(()=>s?new Ke(s):void 0,[s]);return Ne.jsx(qA,{position:[0,0,1],children:Ne.jsx(f5,{font:t,fontSize:e,color:u,fillOpacity:i,textAlign:"center",outlineWidth:s?1:0,outlineColor:h,depthOffset:0,maxWidth:100,overflowWrap:"break-word",rotation:l,children:c})})},Y5=({color:r="#D8E6EA",size:e=1,opacity:t=.5,animated:n,strokeWidth:i=5,innerRadius:s=4,segments:o=25})=>{const a=K.useMemo(()=>new Ke(r),[r]),{ringSize:l,ringOpacity:c}=tr({from:{ringOpacity:0,ringSize:[1e-5,1e-5,1e-5]},to:{ringOpacity:t,ringSize:[e/2,e/2,1]},config:{...nr,duration:n?void 0:0}}),u=i/10,h=s+u;return Ne.jsx(qA,{position:[0,0,1],children:Ne.jsxs(An.mesh,{scale:l,children:[Ne.jsx("ringGeometry",{attach:"geometry",args:[s,h,o]}),Ne.jsx(An.meshBasicMaterial,{attach:"material",color:a,transparent:!0,depthTest:!1,opacity:c,side:vn,fog:!0})]})})},q5=({color:r,id:e,size:t,selected:n,opacity:i=1,animated:s})=>{const{scale:o,nodeOpacity:a}=tr({from:{scale:[1e-5,1e-5,1e-5],nodeOpacity:0},to:{scale:[t,t,t],nodeOpacity:i},config:{...nr,duration:s?void 0:0}}),l=K.useMemo(()=>new Ke(r),[r]),c=qe(u=>u.theme);return Ne.jsxs(Ne.Fragment,{children:[Ne.jsxs(An.mesh,{userData:{id:e,type:"node"},scale:o,children:[Ne.jsx("sphereGeometry",{attach:"geometry",args:[1,25,25]}),Ne.jsx(An.meshPhongMaterial,{attach:"material",side:vn,transparent:!0,fog:!0,opacity:a,color:l})]}),Ne.jsx(Y5,{opacity:n?.5:0,size:t,animated:s,color:n?c.ring.activeFill:c.ring.fill})]})},g2=K.createContext({controls:null,resetControls:()=>{},zoomIn:()=>{},zoomOut:()=>{},dollyIn:()=>{},dollyOut:()=>{},panLeft:()=>{},panRight:()=>{},panUp:()=>{},panDown:()=>{},freeze:()=>{},unFreeze:()=>{}}),zp=()=>{const r=K.useContext(g2);if(r===void 0)throw new Error("`useCameraControls` hook must be used within a `ControlsProvider` component");return r};Qn.install({THREE:{MOUSE:ab,Vector2:De,Vector3:Y,Vector4:Xt,Quaternion:si,Matrix4:yt,Spherical:lT,Box3:ir,Sphere:rr,Raycaster:Uy,MathUtils:{DEG2RAD:(jE=Od)==null?void 0:jE.DEG2RAD,clamp:(YE=Od)==null?void 0:YE.clamp}}});hT({ThreeCameraControls:Qn});const Bp={ARROW_LEFT:37,ARROW_UP:38,ARROW_RIGHT:39,ARROW_DOWN:40},QE=new kp(Bp.ARROW_LEFT,100),eb=new kp(Bp.ARROW_RIGHT,100),tb=new kp(Bp.ARROW_UP,100),nb=new kp(Bp.ARROW_DOWN,100),Z5=K.forwardRef(({mode:r="rotate",children:e,animated:t,disabled:n,minDistance:i=1e3,maxDistance:s=5e4},o)=>{const a=K.useRef(null),l=Bn(F=>F.camera),c=Bn(F=>F.gl),u=r==="orbit",h=qe(F=>F.setPanning),p=qe(F=>F.draggingIds.length>0),m=K.useRef(0),[v,_]=K.useState(!1);Ep((F,N)=>{var I,X;(I=a.current)!=null&&I.enabled&&((X=a.current)==null||X.update(N)),u&&(a.current.azimuthAngle+=20*N*Od.DEG2RAD)},-1),K.useEffect(()=>()=>{var F;return(F=a.current)==null?void 0:F.dispose()},[]);const y=K.useCallback(()=>{var F;(F=a.current)==null||F.zoom(l.zoom/2,t)},[t,l.zoom]),g=K.useCallback(()=>{var F;(F=a.current)==null||F.zoom(-l.zoom/2,t)},[t,l.zoom]),x=K.useCallback(F=>{var N;(N=a.current)==null||N.dolly(F,t)},[t]),w=K.useCallback(F=>{var N;(N=a.current)==null||N.dolly(F,t)},[t]),E=K.useCallback(F=>{var N;u||(N=a.current)==null||N.truck(-.03*F.deltaTime,0,t)},[t,u]),b=K.useCallback(F=>{var N;u||(N=a.current)==null||N.truck(.03*F.deltaTime,0,t)},[t,u]),M=K.useCallback(F=>{var N;u||(N=a.current)==null||N.truck(0,.03*F.deltaTime,t)},[t,u]),A=K.useCallback(F=>{var N;u||(N=a.current)==null||N.truck(0,-.03*F.deltaTime,t)},[t,u]),P=K.useCallback(F=>{F.code==="Space"&&(r==="rotate"?a.current.mouseButtons.left=Qn.ACTION.TRUCK:a.current.mouseButtons.left=Qn.ACTION.ROTATE)},[r]),C=K.useCallback(F=>{F.code==="Space"&&(r==="rotate"?a.current.mouseButtons.left=Qn.ACTION.ROTATE:a.current.mouseButtons.left=Qn.ACTION.TRUCK)},[r]);K.useEffect(()=>(n||(QE.addEventListener("holding",b),eb.addEventListener("holding",E),tb.addEventListener("holding",M),nb.addEventListener("holding",A),typeof window<"u"&&(window.addEventListener("keydown",P),window.addEventListener("keyup",C))),()=>{QE.removeEventListener("holding",b),eb.removeEventListener("holding",E),tb.removeEventListener("holding",M),nb.removeEventListener("holding",A),typeof window<"u"&&(window.removeEventListener("keydown",P),window.removeEventListener("keyup",C))}),[n,P,C,A,b,E,M]),K.useEffect(()=>{n?(a.current.mouseButtons.left=Qn.ACTION.NONE,a.current.mouseButtons.middle=Qn.ACTION.NONE,a.current.mouseButtons.wheel=Qn.ACTION.NONE):(a.current.mouseButtons.left=Qn.ACTION.TRUCK,a.current.mouseButtons.middle=Qn.ACTION.TRUCK,a.current.mouseButtons.wheel=Qn.ACTION.DOLLY)},[n]),K.useEffect(()=>{const F=()=>h(!0),N=()=>h(!1),I=a.current;return I&&(I.addEventListener("control",F),I.addEventListener("controlend",N)),()=>{I&&(I.removeEventListener("control",F),I.removeEventListener("controlend",N))}},[a,h]),K.useEffect(()=>{p?(a.current.mouseButtons.left=Qn.ACTION.NONE,a.current.touches.one=Qn.ACTION.NONE):r==="rotate"?(a.current.mouseButtons.left=Qn.ACTION.ROTATE,a.current.touches.one=Qn.ACTION.TOUCH_ROTATE):(a.current.touches.one=Qn.ACTION.TOUCH_TRUCK,a.current.mouseButtons.left=Qn.ACTION.TRUCK)},[p,r]);const L=K.useMemo(()=>({controls:a.current,zoomIn:()=>y(),zoomOut:()=>g(),dollyIn:(F=1e3)=>x(F),dollyOut:(F=-1e3)=>w(F),panLeft:(F=100)=>b({deltaTime:F}),panRight:(F=100)=>E({deltaTime:F}),panDown:(F=100)=>A({deltaTime:F}),panUp:(F=100)=>M({deltaTime:F}),resetControls:F=>{var N;return(N=a.current)==null?void 0:N.reset(F)},freeze:()=>{a.current.truckSpeed&&(m.current=a.current.truckSpeed),a.current.truckSpeed=0},unFreeze:()=>a.current.truckSpeed=m.current}),[y,g,b,E,A,M,a.current]);return K.useImperativeHandle(o,()=>L),Ne.jsxs(g2.Provider,{value:L,children:[Ne.jsx("threeCameraControls",{ref:F=>{a.current=F,v||_(!0)},args:[l,c.domElement],smoothTime:.1,minDistance:i,dollyToCursor:!0,maxDistance:s}),e]})});function v2(r,e){const t=e.position.z;rl.x0&&(e==null?void 0:e.x)l.y0&&(e==null?void 0:e.y)Math.abs(n-r%Math.PI){const n=qe(_=>_.nodes),[i,s]=K.useState(!1),o=Bn(_=>_.invalidate),{controls:a}=zp(),l=Bn(_=>_.camera),c=K.useRef(!1),u=K.useCallback(async(_,y)=>{const g=(y==null?void 0:y.animated)!==void 0?y==null?void 0:y.animated:!0,x=(y==null?void 0:y.centerOnlyIfNodesNotInView)!==void 0?y==null?void 0:y.centerOnlyIfNodesNotInView:!1;if(!c.current||!x||x&&(_!=null&&_.some(w=>!ib(l,w.position)))){const{x:w,y:E,z:b}=th(_);await a.setTarget(w,E,b,g),i||s(!0),o()}},[o,a,n]),h=K.useCallback(async(_,y={animated:!0,fitOnlyIfNodesNotInView:!1})=>{const{fitOnlyIfNodesNotInView:g}=y;if(!g||g&&(_!=null&&_.some(x=>!ib(l,x.position)))){const{minX:x,maxX:w,minY:E,maxY:b,minZ:M,maxZ:A}=th(_);if(!t.includes("3d")){const{horizontalRotation:P,verticalRotation:C}=$5(a==null?void 0:a.azimuthAngle,a==null?void 0:a.polarAngle);a==null||a.rotate(P,C,!0)}await(a==null?void 0:a.zoomTo(1,y==null?void 0:y.animated)),await(a==null?void 0:a.fitToBox(new ir(new Y(x,E,M),new Y(w,b,A)),y==null?void 0:y.animated,{cover:!1,paddingLeft:pd,paddingRight:pd,paddingBottom:pd,paddingTop:pd}))}},[l,a,t]),p=K.useCallback(_=>{let y=null;return _!=null&&_.length&&(y=_.reduce((g,x)=>{const w=n.find(E=>E.id===x);if(w)g.push(w);else throw new Error(`Attempted to center ${x} but it was not found in the nodes`);return g},[])),y},[n]),m=K.useCallback((_,y)=>{const g=p(_);u(g||n,{animated:r,centerOnlyIfNodesNotInView:y==null?void 0:y.centerOnlyIfNodesNotInView})},[r,u,p,n]),v=K.useCallback(async(_,y)=>{const g=p(_);await h(g||n,{animated:r,...y})},[r,h,p,n]);return K.useLayoutEffect(()=>{async function _(){a&&(n!=null&&n.length)&&(c.current||(await u(n,{animated:!1}),await h(n,{animated:!1}),c.current=!0))}_()},[a,u,n,r,l,h]),{centerNodes:u,centerNodesById:m,fitNodesInViewById:v,isCentered:i}},Q5=({image:r,id:e,size:t,opacity:n=1,animated:i})=>{const s=K.useMemo(()=>new KM().load(r),[r]),{scale:o,spriteOpacity:a}=tr({from:{scale:[1e-5,1e-5,1e-5],spriteOpacity:0},to:{scale:[t,t,t],spriteOpacity:n},config:{...nr,duration:i?void 0:0}});return Ne.jsx(An.sprite,{userData:{id:e,type:"node"},scale:o,children:Ne.jsx(An.spriteMaterial,{attach:"material",opacity:a,fog:!0,depthTest:!1,transparent:!0,side:vn,children:Ne.jsx("primitive",{attach:"map",object:s,minFilter:fn})})})},eH=({animated:r,disabled:e,id:t,draggable:n=!1,labelFontUrl:i,contextMenu:s,onClick:o,onDoubleClick:a,onPointerOver:l,onDragged:c,onPointerOut:u,onContextMenu:h,renderNode:p,constrainDragging:m})=>{var v,_,y;const g=zp(),x=qe(ne=>ne.theme),w=qe(ne=>ne.nodes.find(we=>we.id===t)),E=qe(ne=>ne.edges),b=qe(ne=>ne.draggingIds),M=qe(ne=>ne.collapsedNodeIds),A=qe(ne=>ne.addDraggingId),P=qe(ne=>ne.removeDraggingId),C=qe(ne=>ne.setHoveredNodeId),L=qe(ne=>ne.setNodePosition),F=qe(ne=>ne.setCollapsedNodeIds),N=qe(ne=>ne.collapsedNodeIds.includes(t)),I=qe(ne=>{var we;return(we=ne.actives)==null?void 0:we.includes(t)}),X=qe(ne=>{var we;return(we=ne.selections)==null?void 0:we.includes(t)}),q=qe(ne=>{var we;return((we=ne.selections)==null?void 0:we.length)>0}),W=qe(ne=>ne.centerPosition),O=qe(ne=>ne.clusters.get(w.cluster)),k=b.includes(t),G=b.length>0,{position:B,label:D,subLabel:V,size:Z=7,labelVisible:ee=!0}=w,ie=K.useRef(null),[ue,ce]=K.useState(!1),[le,Ae]=K.useState(!1),Ee=ue||X||I,ae=q?Ee?x.node.selectedOpacity:x.node.inactiveOpacity:x.node.opacity,z=K.useMemo(()=>E.filter(we=>we.source===t).length>0||N,[E,t,N]),oe=K.useCallback(()=>{z&&F(N?M.filter(ne=>ne!==t):[...M,t])},[z,M,t,N,F]),[{nodePosition:te,labelPosition:se,subLabelPosition:$}]=tr(()=>({from:{nodePosition:W?[W.x,W.y,0]:[0,0,0],labelPosition:[0,-(Z+7),2],subLabelPosition:[0,-(Z+14),2]},to:{nodePosition:B?[B.x,B.y,Ee?B.z+1:B.z]:[0,0,0],labelPosition:[0,-(Z+7),2],subLabelPosition:[0,-(Z+14),2]},config:{...nr,duration:r&&!G?void 0:0}}),[k,B,r,Z,Ee]),Ie=p2({draggable:n,position:B,bounds:m?O==null?void 0:O.position:void 0,set:ne=>L(t,ne),onDragStart:()=>{A(t),ce(!0)},onDragEnd:()=>{P(t),c==null||c(w)}});ya(ue&&!G&&o!==void 0,"pointer"),ya(ue&&n&&!k&&o===void 0,"grab"),ya(k,"grabbing");const de=Ee||k,Se=de?x.node.activeFill:w.fill||x.node.fill,{pointerOver:Le,pointerOut:ge}=m_({disabled:e||k,onPointerOver:ne=>{g.freeze(),ce(!0),l==null||l(w,ne),C(t)},onPointerOut:ne=>{g.unFreeze(),ce(!1),u==null||u(w,ne),C(null)}}),He=K.useMemo(()=>p?p({id:t,color:Se,size:Z,active:de,opacity:ae,animated:r,selected:X,node:w}):Ne.jsx(Ne.Fragment,{children:w.icon?Ne.jsx(Q5,{id:t,image:w.icon||"",size:Z+8,opacity:ae,animated:r,color:Se,node:w,active:de,selected:X}):Ne.jsx(q5,{id:t,size:Z,opacity:ae,animated:r,color:Se,node:w,active:de,selected:X})}),[p,t,Se,Z,de,ae,r,X,w]),j=K.useMemo(()=>{var ne,we,be;return ee&&(ee||X||ue)&&D&&Ne.jsxs(Ne.Fragment,{children:[Ne.jsx(An.group,{position:se,children:Ne.jsx(nh,{text:D,fontUrl:i,opacity:ae,stroke:x.node.label.stroke,active:X||ue||k||I,color:X||ue||k||I?x.node.label.activeColor:x.node.label.color})}),V&&Ne.jsx(An.group,{position:$,children:Ne.jsx(nh,{text:V,fontUrl:i,fontSize:5,opacity:ae,stroke:(ne=x.node.subLabel)==null?void 0:ne.stroke,active:X||ue||k||I,color:X||ue||k||I?(we=x.node.subLabel)==null?void 0:we.activeColor:(be=x.node.subLabel)==null?void 0:be.color})})]})},[ue,I,k,X,D,i,se,ee,ae,V,$,x.node.label.activeColor,x.node.label.color,x.node.label.stroke,(v=x.node.subLabel)==null?void 0:v.activeColor,(_=x.node.subLabel)==null?void 0:_.color,(y=x.node.subLabel)==null?void 0:y.stroke]),H=K.useMemo(()=>le&&s&&Ne.jsx($y,{prepend:!0,center:!0,children:s({data:w,canCollapse:z,isCollapsed:N,onCollapse:oe,onClose:()=>Ae(!1)})}),[le,s,w,z,N,oe]);return Ne.jsxs(An.group,{renderOrder:1,userData:{id:t,type:"node"},ref:ie,position:te,onPointerOver:Le,onPointerOut:ge,onClick:ne=>{!e&&!k&&(o==null||o(w,{canCollapse:z,isCollapsed:N},ne))},onDoubleClick:ne=>{!e&&!k&&(a==null||a(w,ne))},onContextMenu:()=>{e||(Ae(!0),h==null||h(w,{canCollapse:z,isCollapsed:N,onCollapse:oe}))},...Ie(),children:[He,H,j]})},tH=({animated:r,color:e="#D8E6EA",length:t,opacity:n=.5,position:i,rotation:s,size:o=1,onActive:a,onContextMenu:l})=>{const c=K.useMemo(()=>new Ke(e),[e]),u=K.useRef(null),h=qe(y=>y.draggingIds.length>0),p=qe(y=>y.centerPosition),[{pos:m,arrowOpacity:v}]=tr(()=>({from:{pos:p?[p.x,p.y,p.z]:[0,0,0],arrowOpacity:0},to:{pos:[i.x,i.y,i.z],arrowOpacity:n},config:{...nr,duration:r&&!h?void 0:0}}),[r,h,n,i]),_=K.useCallback(()=>{var y;const g=new Y(0,1,0);(y=u.current)==null||y.quaternion.setFromUnitVectors(g,s)},[s,u]);return K.useEffect(()=>_(),[_]),Ne.jsxs(An.mesh,{position:m,ref:u,scale:[1,1,1],onPointerOver:()=>a(!0),onPointerOut:()=>a(!1),onPointerDown:y=>{y.nativeEvent.buttons===2&&(y.stopPropagation(),l())},children:[Ne.jsx("cylinderGeometry",{args:[0,o,t,20,1,!0],attach:"geometry"}),Ne.jsx(An.meshBasicMaterial,{attach:"material",color:c,depthTest:!1,opacity:v,transparent:!0,side:vn,fog:!0})]})},nH=({curveOffset:r,animated:e,color:t="#000",curve:n,curved:i=!1,id:s,opacity:o=1,size:a=1,onContextMenu:l,onClick:c,onPointerOver:u,onPointerOut:h})=>{const p=K.useRef(null),m=qe(x=>x.draggingIds.length>0),v=K.useMemo(()=>new Ke(t),[t]),_=qe(x=>x.centerPosition),y=K.useRef(!1),{lineOpacity:g}=tr({from:{lineOpacity:0},to:{lineOpacity:o},config:{...nr,duration:e?void 0:0}});return tr(()=>{const x=n.getPoint(0),w=n.getPoint(1);return{from:{fromVertices:y.current?[w==null?void 0:w.x,w==null?void 0:w.y,(w==null?void 0:w.z)||0]:[_==null?void 0:_.x,_==null?void 0:_.y,(_==null?void 0:_.z)||0],toVertices:[x==null?void 0:x.x,x==null?void 0:x.y,(x==null?void 0:x.z)||0]},to:{fromVertices:[x==null?void 0:x.x,x==null?void 0:x.y,(x==null?void 0:x.z)||0],toVertices:[w==null?void 0:w.x,w==null?void 0:w.y,(w==null?void 0:w.z)||0]},onChange:E=>{const{fromVertices:b,toVertices:M}=E.value,A=new Y(...b),P=new Y(...M),C=Qu(A,0,P,0,i,r);p.current.copy(new ba(C,20,a/2,5,!1))},config:{...nr,duration:e&&!m?void 0:0}}},[e,m,n,a]),K.useEffect(()=>{y.current=!0},[]),Ne.jsxs("mesh",{userData:{id:s,type:"edge"},onPointerOver:u,onPointerOut:h,onClick:c,onPointerDown:x=>{x.nativeEvent.buttons===2&&(x.stopPropagation(),l())},children:[Ne.jsx("tubeGeometry",{attach:"geometry",ref:p}),Ne.jsx(An.meshBasicMaterial,{attach:"material",opacity:g,fog:!0,transparent:!0,depthTest:!1,color:v})]})},sb=3,iH=({animated:r,arrowPlacement:e="end",contextMenu:t,disabled:n,labelPlacement:i="inline",id:s,interpolation:o,labelFontUrl:a,onContextMenu:l,onClick:c,onPointerOver:u,onPointerOut:h})=>{const p=qe(oe=>oe.theme),m=qe(oe=>oe.draggingIds.length>0),[v,_]=K.useState(!1),[y,g]=K.useState(!1),x=qe(oe=>oe.edges),w=x.find(oe=>oe.id===s),{target:E,source:b,label:M,labelVisible:A=!1,size:P=1,fill:C}=w,L=qe(oe=>oe.nodes.find(te=>te.id===b)),F=qe(oe=>oe.nodes.find(te=>te.id===E)),N=(P+p.edge.label.fontSize)/2,[I,X]=K.useMemo(()=>f2(P),[P]),{curveOffset:q,curved:W}=K.useMemo(()=>B5({edge:w,edges:x,curved:o==="curved"}),[w,x,o]),[O,k,G]=K.useMemo(()=>{const oe=eh(L),te=L.size,se=eh(F),$=F.size;let Ie=Qu(oe,te,se,$,W,q);const[de,Se]=h2(e,Ie,I);return e==="end"&&(Ie=Qu(oe,te,de,0,W,q)),[Ie,de,Se]},[L,F,W,q,e,I]),B=K.useMemo(()=>{let oe=d2(L.position,F.position,u2(N,i));if(W){const te=new Y().subVectors(oe,O.getPoint(.5));switch(i){case"above":te.y=te.y-sb;break;case"below":te.y=te.y+sb;break}oe=oe.sub(te)}return oe},[L.position,F.position,N,i,W,O]),D=qe(oe=>{var te;return(te=oe.selections)==null?void 0:te.includes(s)}),V=qe(oe=>{var te;return(te=oe.selections)==null?void 0:te.length}),Z=qe(oe=>{var te;return(te=oe.actives)==null?void 0:te.includes(s)}),ee=qe(oe=>oe.centerPosition),ie=V?D||Z?p.edge.selectedOpacity:p.edge.inactiveOpacity:p.edge.opacity,[{labelPosition:ue}]=tr(()=>({from:{labelPosition:ee?[ee.x,ee.y,ee.z]:[0,0,0]},to:{labelPosition:[B.x,B.y,B.z]},config:{...nr,duration:r&&!m?void 0:0}}),[B,r,m]),ce=K.useMemo(()=>new Eo(0,0,i==="natural"?0:Math.atan((F.position.y-L.position.y)/(F.position.x-L.position.x))),[F.position.x,F.position.y,L.position.x,L.position.y,i]);ya(v&&!m&&c!==void 0,"pointer");const{pointerOver:le,pointerOut:Ae}=m_({disabled:n,onPointerOver:oe=>{_(!0),u==null||u(w,oe)},onPointerOut:oe=>{_(!1),h==null||h(w,oe)}}),Ee=K.useMemo(()=>e!=="none"&&Ne.jsx(tH,{animated:r,color:D||v||Z?p.arrow.activeFill:C||p.arrow.fill,length:I,opacity:ie,position:k,rotation:G,size:X,onActive:_,onContextMenu:()=>{n||(g(!0),l==null||l(w))}}),[C,v,r,I,e,k,G,X,n,w,Z,D,l,ie,p.arrow.activeFill,p.arrow.fill]),ae=K.useMemo(()=>A&&M&&Ne.jsx(An.group,{position:ue,onContextMenu:()=>{n||(g(!0),l==null||l(w))},onPointerOver:le,onPointerOut:Ae,children:Ne.jsx(nh,{text:M,ellipsis:15,fontUrl:a,stroke:p.edge.label.stroke,color:D||v||Z?p.edge.label.activeColor:p.edge.label.color,opacity:ie,fontSize:p.edge.label.fontSize,rotation:ce})}),[v,n,w,Z,D,M,a,ue,ce,A,l,Ae,le,ie,p.edge.label.activeColor,p.edge.label.color,p.edge.label.fontSize,p.edge.label.stroke]),z=K.useMemo(()=>y&&t&&Ne.jsx($y,{prepend:!0,center:!0,position:B,children:t({data:w,onClose:()=>g(!1)})}),[y,t,B,w]);return Ne.jsxs("group",{children:[Ne.jsx(nH,{curveOffset:q,animated:r,color:D||v||Z?p.edge.activeFill:C||p.edge.fill,curve:O,curved:W,id:s,opacity:ie,size:P,onClick:oe=>{n||c==null||c(w,oe)},onPointerOver:le,onPointerOut:Ae,onContextMenu:()=>{n||(g(!0),l==null||l(w))}}),Ee,ae,z]})},ob=new Ws(0,0,0);function rH(r,e){const t=K.useRef(),n=qe(c=>c.theme);qe(c=>{t.current=c});const i=K.useRef(new Map);K.useRef(new Ws(0,0,0));const s=K.useRef(),o=e==="curved",a=K.useCallback(c=>{const u=[],h=i.current,{nodes:p}=t.current,m=new Map(p.map(_=>[_.id,_])),v=n.edge.label.fontSize;return r!=="none"&&!s.current&&(s.current=new La(0,1,1,20,1,!0)),c.forEach(_=>{const{target:y,source:g,size:x=1}=_,w=m.get(g),E=m.get(y);if(!w||!E)return;const b=`${w.position.x},${w.position.y},${E.position.x},${E.position.y},${x}`;if(h.has(b)){u.push(h.get(b));return}const M=eh(w),A=w.size+v,P=eh(E),C=E.size+v;let L=Qu(M,A,P,C,o),F=new ba(L,20,x/2,5,!1);if(r==="none"){u.push(F),h.set(b,F);return}const[N,I]=f2(x),X=s.current.clone();X.scale(I,N,I);const[q,W]=h2(r,L,N),O=new si;if(O.setFromUnitVectors(new Y(0,1,0),W),X.applyQuaternion(O),X.translate(q.x,q.y,q.z),r&&r==="end"){const G=Qu(M,A,q,0,o);F=new ba(G,20,x/2,5,!1)}const k=od([F,X]);u.push(k),h.set(b,k)}),u},[r,o,n.edge.label.fontSize]),l=K.useCallback((c,u)=>{const h=a(c),p=a(u);return od([p.length?od(p):ob,h.length?od(h):ob],!0)},[a]);return{getGeometries:a,getGeometry:l}}function sH(r,e,t){const n=K.useRef(r);K.useEffect(()=>{n.current=r},[r]);const i=qe(h=>h.edgeContextMenus),s=qe(K.useCallback(h=>h.setEdgeContextMenus,[])),o=K.useRef(!1),a=K.useCallback(()=>{o.current=!0},[]),l=K.useRef(!1),c=K.useCallback(()=>{l.current=!0},[]),u=K.useCallback((h,p)=>{const{onClick:m,onContextMenu:v,onPointerOver:_,onPointerOut:y}=n.current;if(m&&o.current&&!t){o.current=!1;for(const g of p)m(g)}if((e||v)&&l.current&&!t){l.current=!1;const g=new Set(i);let x=!1;for(const w of p)i.has(w.id)||(g.add(w.id),x=!0,v==null||v(w));x&&s(g)}_&&p.filter(x=>!h.includes(x)).forEach(x=>{_(x)}),y&&h.filter(x=>!p.includes(x)).forEach(x=>{y(x)})},[e,t,i,s]);return{handleClick:a,handleContextMenu:c,handleIntersections:u}}function oH(r,e){const t=K.useRef(r),n=K.useRef();K.useEffect(()=>{t.current=r;const o=r.getAttribute("position");n.current=new Float32Array(o.array.length)},[r]);const i=K.useCallback(()=>{const o=t.current.getAttribute("position");return{from:new Float32Array(o.array.length),to:o.array}},[]),s=K.useCallback(o=>{const a=n.current;a.set(o);const l=new $t(a,3,!1);t.current.setAttribute("position",l),l.needsUpdate=!0},[]);tr(()=>{if(!e)return null;const o=i();return{from:{positions:o.from},to:{positions:o.to},onChange:a=>{s(a.value.positions)},config:{...nr,duration:e?void 0:0}}},[e,i,s])}function aH(r,e,t){const[{activeOpacity:n,inactiveOpacity:i}]=tr(()=>({from:{activeOpacity:0,inactiveOpacity:0},to:{activeOpacity:e?t.edge.selectedOpacity:t.edge.opacity,inactiveOpacity:e?t.edge.inactiveOpacity:t.edge.opacity},config:{...nr,duration:r?void 0:0}}),[r,e,t]);return{activeOpacity:n,inactiveOpacity:i}}const lH=({animated:r,color:e,contextMenu:t,edge:n,labelFontUrl:i,labelPlacement:s="inline",opacity:o})=>{const a=qe(L=>L.theme),{target:l,source:c,label:u,labelVisible:h=!1,size:p=1}=n,m=qe(L=>L.nodes),[v,_]=K.useMemo(()=>[m.find(L=>L.id===c),m.find(L=>L.id===l)],[m,c,l]),y=qe(L=>L.draggingIds.length>0),g=K.useMemo(()=>(p+a.edge.label.fontSize)/2,[p,a.edge.label.fontSize]),x=K.useMemo(()=>d2(v.position,_.position,u2(g,s)),[v.position,_.position,g,s]),w=qe(L=>L.edgeContextMenus),E=qe(L=>L.setEdgeContextMenus),[{labelPosition:b}]=tr(()=>({from:{labelPosition:[0,0,0]},to:{labelPosition:[x.x,x.y,x.z]},config:{...nr,duration:r&&!y?void 0:0}}),[x,r,y]),M=K.useCallback(L=>{w.delete(L),E(new Set(w))},[w,E]),A=K.useMemo(()=>s==="natural"?new Eo(0,0,0):new Eo(0,0,Math.atan2(_.position.y-v.position.y,_.position.x-v.position.x)),[s,_.position.y,_.position.x,v.position.y,v.position.x]),P=K.useMemo(()=>({prepend:!0,center:!0,position:x}),[x]),C=K.useMemo(()=>({text:u,ellipsis:15,fontUrl:i,stroke:a.edge.label.stroke,color:e,opacity:o,fontSize:a.edge.label.fontSize,rotation:A}),[u,i,a.edge.label.stroke,e,o,a.edge.label.fontSize,A]);return Ne.jsxs("group",{children:[h&&u&&Ne.jsx(An.group,{position:b,children:Ne.jsx(nh,{...C})}),t&&w.has(n.id)&&Ne.jsx($y,{...P,children:t({data:n,onClose:()=>M(n.id)})})]})},cH=({interpolation:r="linear",arrowPlacement:e="end",labelPlacement:t="inline",animated:n,contextMenu:i,disabled:s,edges:o,labelFontUrl:a,onClick:l,onContextMenu:c,onPointerOut:u,onPointerOver:h})=>{const p=qe(B=>B.theme),{getGeometries:m,getGeometry:v}=rH(e,r),_=qe(B=>B.draggingIds),y=qe(B=>B.edgeMeshes),g=qe(B=>B.setEdgeMeshes),x=qe(B=>B.actives||[]),w=qe(B=>B.selections||[]),[E,b,M,A]=K.useMemo(()=>{const B=[],D=[],V=[],Z=[];return o.forEach(ee=>{if(_.includes(ee.source)||_.includes(ee.target)){w.includes(ee.id)||x.includes(ee.id)?V.push(ee):Z.push(ee);return}w.includes(ee.id)||x.includes(ee.id)?B.push(ee):D.push(ee)}),[B,D,V,Z]},[o,x,w,_]),P=!!w.length,C=K.useMemo(()=>v(E,b),[v,E,b]),{activeOpacity:L,inactiveOpacity:F}=aH(n,P,p);oH(C,n),K.useEffect(()=>{if(_.length===0){const D=m(o).map(V=>new _n(V));g(D)}},[m,g,o,_.length]);const N=K.useRef(new _n),I=K.useRef(new _n),X=K.useCallback(B=>{if(!B.camera)return[];const D=B.intersectObjects(y);return D.length?D.map(V=>o[y.indexOf(V.object)]):[]},[y,o]),{handleClick:q,handleContextMenu:W,handleIntersections:O}=sH({onClick:l,onContextMenu:c,onPointerOut:u,onPointerOver:h},i,s),k=K.useRef([]),G=K.useRef([]);return Ep(B=>{if(N.current.geometry=C,s)return;const D=k.current;if((_.length||_.length===0&&D!==null)&&(I.current.geometry=v(M,A)),k.current=_,_.length)return;const V=G.current,Z=X(B.raycaster);O(V,Z),Z.join()!==V.join()&&(I.current.geometry=v(Z,[])),G.current=Z}),Ne.jsxs("group",{onClick:q,onContextMenu:W,children:[Ne.jsxs("mesh",{ref:N,children:[Ne.jsx(An.meshBasicMaterial,{attach:"material-0",color:p.edge.fill,depthTest:!1,fog:!0,opacity:F,side:vn,transparent:!0}),Ne.jsx(An.meshBasicMaterial,{attach:"material-1",color:p.edge.activeFill,depthTest:!1,fog:!0,opacity:L,side:vn,transparent:!0})]}),Ne.jsxs("mesh",{ref:I,children:[Ne.jsx(An.meshBasicMaterial,{attach:"material-0",color:p.edge.fill,depthTest:!1,fog:!0,opacity:F,side:vn,transparent:!0}),Ne.jsx(An.meshBasicMaterial,{attach:"material-1",color:p.edge.activeFill,depthTest:!1,fog:!0,opacity:L,side:vn,transparent:!0})]}),o.map(B=>Ne.jsx(lH,{animated:n,contextMenu:i,color:p.edge.label.color,disabled:s,edge:B,labelFontUrl:a,labelPlacement:t},B.id))]})},uH=({outerRadius:r,innerRadius:e,padding:t,normalizedFill:n,normalizedStroke:i,opacity:s,animated:o,theme:a})=>{var l;const{opacity:c}=tr({from:{opacity:0},to:{opacity:s},config:{...nr,duration:o?void 0:0}});return Ne.jsxs(Ne.Fragment,{children:[Ne.jsxs("mesh",{children:[Ne.jsx("ringGeometry",{attach:"geometry",args:[r,0,128]}),Ne.jsx(An.meshBasicMaterial,{attach:"material",color:n,transparent:!0,depthTest:!1,opacity:(l=a.cluster)!=null&&l.fill?c:0,side:vn,fog:!0})]}),Ne.jsxs("mesh",{children:[Ne.jsx("ringGeometry",{attach:"geometry",args:[r,e+t,128]}),Ne.jsx(An.meshBasicMaterial,{attach:"material",color:i,transparent:!0,depthTest:!1,opacity:c,side:vn,fog:!0})]})]})},hH=({animated:r,position:e,padding:t=40,labelFontUrl:n,disabled:i,radius:s=2,nodes:o,label:a,onClick:l,onPointerOver:c,onPointerOut:u,draggable:h=!1,onDragged:p,onRender:m})=>{var v,_,y,g,x,w,E;const b=qe(z=>z.theme),M=Math.max(e.width,e.height)/2,A=M-s+t,[P,C]=K.useState(!1),L=qe(z=>z.centerPosition),F=qe(z=>z.nodes),N=zp(),I=qe(z=>z.draggingIds),X=I.includes(a),q=I.length>0,W=qe(z=>{var oe;return(oe=z.actives)==null?void 0:oe.some(te=>o.some(se=>se.id===te))}),O=qe(z=>z.hoveredNodeId),k=qe(z=>{var oe;return(oe=z.selections)==null?void 0:oe.some(te=>o.some(se=>se.id===te))}),B=qe(z=>{var oe;return((oe=z.selections)==null?void 0:oe.length)>0})?k||P||W?(v=b.cluster)==null?void 0:v.selectedOpacity:(_=b.cluster)==null?void 0:_.inactiveOpacity:(y=b.cluster)==null?void 0:y.opacity,D=K.useMemo(()=>{var z,oe;const te=[0,-A,2],se=(oe=(z=b.cluster)==null?void 0:z.label)==null?void 0:oe.offset;return se?[te[0]-se[0],te[1]-se[1],te[2]-se[2]]:te},[A,(x=(g=b.cluster)==null?void 0:g.label)==null?void 0:x.offset]),{circlePosition:V}=tr({from:{circlePosition:[L.x,L.y,-1]},to:{circlePosition:e?[e.x,e.y,-1]:[0,0,-1]},config:{...nr,duration:r&&!q?void 0:0}}),Z=K.useMemo(()=>{var z;return new Ke((z=b.cluster)==null?void 0:z.stroke)},[(w=b.cluster)==null?void 0:w.stroke]),ee=K.useMemo(()=>{var z;return new Ke((z=b.cluster)==null?void 0:z.fill)},[(E=b.cluster)==null?void 0:E.fill]),ie=qe(z=>z.addDraggingId),ue=qe(z=>z.removeDraggingId),ce=qe(z=>z.setClusterPosition),le=p2({draggable:h&&!O,position:{x:e.x,y:e.y,z:-1},set:z=>ce(a,z),onDragStart:()=>{ie(a),C(!0)},onDragEnd:()=>{ue(a),C(!1);const z=F.filter(oe=>oe.cluster===a);p==null||p({nodes:z,label:a})}});ya(P&&!q&&l!==void 0,"pointer"),ya(P&&h&&!X&&l===void 0,"grab"),ya(X,"grabbing");const{pointerOver:Ae,pointerOut:Ee}=m_({disabled:i,onPointerOver:z=>{C(!0),N.freeze(),c==null||c({nodes:o,label:a},z)},onPointerOut:z=>{C(!1),N.unFreeze(),u==null||u({nodes:o,label:a},z)}});return K.useMemo(()=>{var z,oe,te;return b.cluster&&Ne.jsx(An.group,{userData:{id:a,type:"cluster"},position:V,onPointerOver:Ae,onPointerOut:Ee,onClick:se=>{!i&&!X&&(l==null||l({nodes:o,label:a},se))},...le(),children:m?m({label:{position:D,text:a,opacity:B,fontUrl:n},opacity:B,outerRadius:A,innerRadius:M,padding:t,theme:b}):Ne.jsxs(Ne.Fragment,{children:[Ne.jsx(uH,{outerRadius:A,innerRadius:M,padding:t,normalizedFill:ee,normalizedStroke:Z,opacity:B,animated:r,theme:b}),((z=b.cluster)==null?void 0:z.label)&&Ne.jsx(An.group,{position:D,children:Ne.jsx(nh,{text:a,opacity:B,fontUrl:n,stroke:b.cluster.label.stroke,active:!1,color:(oe=b.cluster)==null?void 0:oe.label.color,fontSize:((te=b.cluster)==null?void 0:te.label.fontSize)??12})})]})})},[b,V,Ae,Ee,A,ee,M,t,Z,D,a,B,n,i,l,o,le,X,m,r])},fH=K.forwardRef(({onNodeClick:r,onNodeDoubleClick:e,onNodeContextMenu:t,onEdgeContextMenu:n,onEdgeClick:i,onEdgePointerOver:s,onEdgePointerOut:o,onNodePointerOver:a,onNodePointerOut:l,onClusterClick:c,onNodeDragged:u,onClusterDragged:h,onClusterPointerOver:p,onClusterPointerOut:m,contextMenu:v,animated:_,disabled:y,draggable:g,constrainDragging:x=!1,edgeLabelPosition:w,edgeArrowPosition:E,edgeInterpolation:b="linear",labelFontUrl:M,renderNode:A,onRenderCluster:P,...C},L)=>{const{layoutType:F,clusterAttribute:N}=C,I=Bn(le=>le.gl),X=Bn(le=>le.scene),q=Bn(le=>le.camera),{updateLayout:W}=j5({...C,constrainDragging:x});if(N&&!(F==="forceDirected2d"||F==="forceDirected3d"))throw new Error("Clustering is only supported for the force directed layouts.");const O=qe(le=>le.graph),k=qe(le=>le.nodes),G=qe(le=>le.edges),B=qe(le=>[...le.clusters.values()]),{centerNodesById:D,fitNodesInViewById:V,isCentered:Z}=J5({animated:_,disabled:y,layoutType:F});K.useImperativeHandle(L,()=>({centerGraph:D,fitNodesInView:V,graph:O,renderScene:()=>I.render(X,q)}),[D,V,O,I,X,q]);const ee=K.useCallback(le=>{u==null||u(le),N&&W()},[N,u,W]),ie=K.useMemo(()=>k.map(le=>Ne.jsx(eH,{id:le==null?void 0:le.id,labelFontUrl:M,draggable:g,constrainDragging:x,disabled:y,animated:_,contextMenu:v,renderNode:A,onClick:r,onDoubleClick:e,onContextMenu:t,onPointerOver:a,onPointerOut:l,onDragged:ee},le==null?void 0:le.id)),[x,_,v,y,g,M,k,r,t,e,ee,l,a,A]),ue=K.useMemo(()=>_?G.map(le=>Ne.jsx(iH,{id:le.id,disabled:y,animated:_,labelFontUrl:M,labelPlacement:w,arrowPlacement:E,interpolation:b,contextMenu:v,onClick:i,onContextMenu:n,onPointerOver:s,onPointerOut:o},le.id)):Ne.jsx(cH,{edges:G,disabled:y,animated:_,labelFontUrl:M,labelPlacement:w,arrowPlacement:E,interpolation:b,contextMenu:v,onClick:i,onContextMenu:n,onPointerOver:s,onPointerOut:o}),[_,v,y,E,b,w,G,M,i,n,o,s]),ce=K.useMemo(()=>B.map(le=>Ne.jsx(hH,{animated:_,disabled:y,draggable:g,labelFontUrl:M,onClick:c,onPointerOver:p,onPointerOut:m,onDragged:h,onRender:P,...le},le.label)),[_,B,y,g,M,c,m,p,h,P]);return Z&&Ne.jsxs(K.Fragment,{children:[ue,ie,ce]})}),dH={canvas:{background:"#1E2026"},node:{fill:"#7A8C9E",activeFill:"#1DE9AC",opacity:1,selectedOpacity:1,inactiveOpacity:.2,label:{stroke:"#1E2026",color:"#ACBAC7",activeColor:"#1DE9AC"},subLabel:{stroke:"#1E2026",color:"#ACBAC7",activeColor:"#1DE9AC"}},lasso:{border:"1px solid #55aaff",background:"rgba(75, 160, 255, 0.1)"},ring:{fill:"#54616D",activeFill:"#1DE9AC"},edge:{fill:"#474B56",activeFill:"#1DE9AC",opacity:1,selectedOpacity:1,inactiveOpacity:.1,label:{stroke:"#1E2026",color:"#ACBAC7",activeColor:"#1DE9AC",fontSize:6}},arrow:{fill:"#474B56",activeFill:"#1DE9AC"},cluster:{stroke:"#474B56",opacity:1,selectedOpacity:1,inactiveOpacity:.1,label:{stroke:"#1E2026",color:"#ACBAC7"}}},pH={canvas:{background:"#fff"},node:{fill:"#7CA0AB",activeFill:"#1DE9AC",opacity:1,selectedOpacity:1,inactiveOpacity:.2,label:{color:"#2A6475",stroke:"#fff",activeColor:"#1DE9AC"},subLabel:{color:"#ddd",stroke:"transparent",activeColor:"#1DE9AC"}},lasso:{border:"1px solid #55aaff",background:"rgba(75, 160, 255, 0.1)"},ring:{fill:"#D8E6EA",activeFill:"#1DE9AC"},edge:{fill:"#D8E6EA",activeFill:"#1DE9AC",opacity:1,selectedOpacity:1,inactiveOpacity:.1,label:{stroke:"#fff",color:"#2A6475",activeColor:"#1DE9AC",fontSize:6}},arrow:{fill:"#D8E6EA",activeFill:"#1DE9AC"},cluster:{stroke:"#D8E6EA",opacity:1,selectedOpacity:1,inactiveOpacity:.1,label:{stroke:"#fff",color:"#2A6475"}}};function md(r,e,t){const{offsetX:n,offsetY:i}=r,{width:s,height:o}=t;e.set(n/s*2-1,-(i/o)*2+1)}function mH(r){const e=document.createElement("div");return e.style.pointerEvents="none",e.style.border=r.lasso.border,e.style.backgroundColor=r.lasso.background,e.style.position="fixed",e}const gH=({children:r,type:e="none",onLasso:t,onLassoEnd:n,disabled:i})=>{var s;const o=qe(I=>I.theme),a=Bn(I=>I.camera),l=Bn(I=>I.gl),c=Bn(I=>I.setEvents),u=Bn(I=>I.size),h=Bn(I=>I.get),p=Bn(I=>I.scene),m=zp(),v=qe(I=>I.actives),_=qe(I=>I.setActives),y=qe(I=>I.edges),g=qe(I=>I.edgeMeshes),x=K.useRef(!1),w=K.useRef(null),E=K.useRef(null),b=K.useRef(mH(o)),M=K.useRef(null),A=K.useRef(!1),P=K.useRef(h().events.enabled),C=K.useRef((s=m.controls)==null?void 0:s.enabled);K.useEffect(()=>{x.current&&(t==null||t(v)),x.current=!0},[v,t]);const L=K.useCallback(I=>{if(A.current){const[X,q,W]=M.current;W.x=Math.max(X.x,I.clientX),W.y=Math.max(X.y,I.clientY),q.x=Math.min(X.x,I.clientX),q.y=Math.min(X.y,I.clientY),b.current.style.left=`${q.x}px`,b.current.style.top=`${q.y}px`,b.current.style.width=`${W.x-q.x}px`,b.current.style.height=`${W.y-q.y}px`,md(I,w.current.endPoint,u),md(I,E.current.endPoint,u);const O=[],k=E.current.select().sort(B=>B.uuid).map(B=>y[g.indexOf(B)].id);O.push(...k);const G=w.current.select().sort(B=>B.uuid).filter(B=>{var D,V;return B.isMesh&&((D=B.userData)==null?void 0:D.id)&&(((V=B.userData)==null?void 0:V.type)===e||e==="all")}).map(B=>B.userData.id);O.push(...G),requestAnimationFrame(()=>{_(O)}),document.addEventListener("pointermove",L,{passive:!0,capture:!0,once:!0})}},[y,g,_,u,e]),F=K.useCallback(()=>{var I;A.current&&(c({enabled:P.current}),A.current=!1,(I=b.current.parentElement)==null||I.removeChild(b.current),m.controls.enabled=C.current,n==null||n(v),document.removeEventListener("pointermove",L),document.removeEventListener("pointerup",F))},[c,m.controls,n,v,L]),N=K.useCallback(I=>{var X,q;if(I.shiftKey){P.current=h().events.enabled,C.current=(X=m.controls)==null?void 0:X.enabled,w.current=new wE(a,p);const W=new ku;g.length&&W.add(...g),E.current=new wE(a,W),M.current=[new De,new De,new De];const[O]=M.current;m.controls.enabled=!1,c({enabled:!1}),A.current=!0,(q=l.domElement.parentElement)==null||q.appendChild(b.current),b.current.style.left=`${I.clientX}px`,b.current.style.top=`${I.clientY}px`,b.current.style.width="0px",b.current.style.height="0px",O.x=I.clientX,O.y=I.clientY,md(I,w.current.startPoint,u),md(I,E.current.startPoint,u),document.addEventListener("pointermove",L,{passive:!0,capture:!0,once:!0}),document.addEventListener("pointerup",F,{passive:!0})}},[a,m.controls,g,h,l.domElement.parentElement,L,F,p,c,u]);return K.useEffect(()=>{if(!(i||e==="none"))return typeof window<"u"&&(document.addEventListener("pointerdown",N,{passive:!0}),document.addEventListener("pointermove",L,{passive:!0}),document.addEventListener("pointerup",F,{passive:!0})),()=>{typeof window<"u"&&(document.removeEventListener("pointerdown",N),document.removeEventListener("pointermove",L),document.removeEventListener("pointerup",F))}},[e,i,N,L,F]),Ne.jsx("group",{children:r})},vH="_canvas_670zp_1",yH={canvas:vH},_H={alpha:!0,antialias:!0},xH={position:[0,0,1e3],near:5,far:5e4,fov:10},wH=K.forwardRef(({cameraMode:r="pan",layoutType:e="forceDirected2d",sizingType:t="default",labelType:n="auto",theme:i=pH,animated:s=!0,defaultNodeSize:o=7,minNodeSize:a=5,maxNodeSize:l=15,lassoType:c="none",glOptions:u={},edges:h,children:p,nodes:m,minDistance:v,maxDistance:_,onCanvasClick:y,disabled:g,onLasso:x,onLassoEnd:w,...E},b)=>{var M,A;const P=K.useRef(null),C=K.useRef(null),L=K.useRef(null);K.useImperativeHandle(b,()=>({centerGraph:(W,O)=>{var k;return(k=P.current)==null?void 0:k.centerGraph(W,O)},fitNodesInView:(W,O)=>{var k;return(k=P.current)==null?void 0:k.fitNodesInView(W,O)},zoomIn:()=>{var W;return(W=C.current)==null?void 0:W.zoomIn()},zoomOut:()=>{var W;return(W=C.current)==null?void 0:W.zoomOut()},dollyIn:W=>{var O;return(O=C.current)==null?void 0:O.dollyIn(W)},dollyOut:W=>{var O;return(O=C.current)==null?void 0:O.dollyOut(W)},panLeft:()=>{var W;return(W=C.current)==null?void 0:W.panLeft()},panRight:()=>{var W;return(W=C.current)==null?void 0:W.panRight()},panDown:()=>{var W;return(W=C.current)==null?void 0:W.panDown()},panUp:()=>{var W;return(W=C.current)==null?void 0:W.panUp()},resetControls:W=>{var O;return(O=C.current)==null?void 0:O.resetControls(W)},getControls:()=>{var W;return(W=C.current)==null?void 0:W.controls},getGraph:()=>{var W;return(W=P.current)==null?void 0:W.graph},exportCanvas:()=>(P.current.renderScene(),L.current.toDataURL()),freeze:()=>{var W;return(W=C.current)==null?void 0:W.freeze()},unFreeze:()=>{var W;return(W=C.current)==null?void 0:W.unFreeze()}}));const{selections:F,actives:N,collapsedNodeIds:I}=E,X=h.length+m.length>400?!1:s,q=K.useMemo(()=>({...u,..._H}),[u]);return Ne.jsx("div",{className:yH.canvas,children:Ne.jsx(NO,{legacy:!0,linear:!0,ref:L,flat:!0,gl:q,camera:xH,onPointerMissed:y,children:Ne.jsxs(V5,{createStore:()=>W5({selections:F,actives:N,theme:i,collapsedNodeIds:I}),children:[((M=i.canvas)==null?void 0:M.background)&&Ne.jsx("color",{attach:"background",args:[i.canvas.background]}),Ne.jsx("ambientLight",{intensity:1}),p,((A=i.canvas)==null?void 0:A.fog)&&Ne.jsx("fog",{attach:"fog",args:[i.canvas.fog,4e3,9e3]}),Ne.jsx(Z5,{mode:r,ref:C,disabled:g,minDistance:v,maxDistance:_,animated:s,children:Ne.jsx(gH,{disabled:g,type:c,onLasso:x,onLassoEnd:w,children:Ne.jsx(K.Suspense,{children:Ne.jsx(fH,{ref:P,disabled:g,animated:X,edges:h,nodes:m,layoutType:e,sizingType:t,labelType:n,defaultNodeSize:o,minNodeSize:a,maxNodeSize:l,...E})})})})]})})})}),gd={identity:"#22d3ee",knowledge:"#6366f1",rules:"#a78bfa",events:"#fbbf24"},SH={identity:"Identität",knowledge:"Wissen",rules:"Regeln",events:"Ereignisse"},P0=new Set(["auto","agent","hermes"]);function PH({data:r,onDelete:e}){const[t,n]=K.useState(null),i=K.useMemo(()=>{const c={};return r.edges.forEach(u=>{c[u.source]=(c[u.source]||0)+1,c[u.target]=(c[u.target]||0)+1}),c},[r]),s=K.useMemo(()=>r.nodes.map(c=>({id:c.id,label:c.content.length>26?c.content.slice(0,25)+"…":c.content,fill:gd[c.category]||"#64748b",size:6+Math.min(i[c.id]||0,6)*2})),[r,i]),o=K.useMemo(()=>r.edges.map(c=>({id:`${c.source}->${c.target}`,source:c.source,target:c.target,size:.4+c.weight})),[r]),a=t?r.nodes.find(c=>c.id===t)??null:null,l=K.useMemo(()=>{if(!t)return[];const c=new Set;return r.edges.forEach(u=>{u.source===t&&c.add(u.target),u.target===t&&c.add(u.source)}),r.nodes.filter(u=>c.has(u.id))},[t,r]);return r.nodes.length?Ne.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-[1fr_280px] gap-3",children:[Ne.jsx("div",{className:"relative h-[480px] rounded-2xl border border-border/60 bg-[#070a0f] overflow-hidden",children:Ne.jsx(wH,{nodes:s,edges:o,theme:dH,layoutType:"forceDirected2d",labelType:"nodes",edgeArrowPosition:"none",draggable:!0,onNodeClick:c=>n(c.id),onCanvasClick:()=>n(null)})}),Ne.jsx("div",{className:"rounded-2xl border border-border/60 bg-card/45 backdrop-blur-md p-4 min-h-[480px]",children:a?Ne.jsxs(Ne.Fragment,{children:[Ne.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[Ne.jsx("span",{className:"w-3 h-3 rounded-full",style:{background:gd[a.category],boxShadow:`0 0 0 2px ${P0.has(a.source)?"#34d399":"#475569"}`}}),Ne.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider",style:{color:gd[a.category]},children:SH[a.category]||a.category}),Ne.jsxs("span",{className:`ml-auto text-[10px] font-mono flex items-center gap-1 ${P0.has(a.source)?"text-emerald-400":"text-muted-foreground/70"}`,children:[P0.has(a.source)&&Ne.jsx(K2,{className:"h-2.5 w-2.5"}),a.source]})]}),Ne.jsx("div",{className:"text-sm text-foreground leading-relaxed mb-4 break-words",children:a.content}),Ne.jsxs("div",{className:"text-[10px] font-bold uppercase tracking-wider text-muted-foreground/70 mb-2 flex items-center gap-1",children:[Ne.jsx(Vx,{className:"h-3 w-3"})," verwandte Fakten"]}),Ne.jsx("div",{className:"flex flex-col gap-1.5 mb-4",children:l.length?l.map(c=>Ne.jsxs("button",{onClick:()=>n(c.id),className:"flex items-center gap-2 text-[11px] text-muted-foreground hover:text-foreground text-left transition-colors",children:[Ne.jsx("span",{className:"w-1.5 h-1.5 rounded-full shrink-0",style:{background:gd[c.category]}}),Ne.jsx("span",{className:"truncate",children:c.content})]},c.id)):Ne.jsx("span",{className:"text-[11px] text-muted-foreground/60",children:"—"})}),Ne.jsxs("button",{onClick:()=>{e(a.id),n(null)},className:"flex items-center gap-1.5 text-[11px] text-red-400 border border-red-500/20 rounded-lg px-2.5 py-1.5 hover:bg-red-500/5 transition-all",children:[Ne.jsx($2,{className:"h-3.5 w-3.5"})," vergessen"]})]}):Ne.jsxs("div",{className:"h-full flex flex-col items-center justify-center text-center text-muted-foreground/70 gap-2 pt-24",children:[Ne.jsx(Vx,{className:"h-6 w-6"}),Ne.jsx("div",{className:"text-xs max-w-[180px] leading-relaxed",children:"Einen Knoten wählen, um den Fakt und seine semantischen Nachbarn zu sehen."})]})})]}):Ne.jsx("div",{className:"text-xs text-muted-foreground border border-dashed border-border/60 rounded-2xl p-12 text-center",children:"Noch keine Fakten — der Graph füllt sich, sobald Hermes lernt oder du Einträge anlegst."})}export{PH as GraphView};