@instruktlabs/kiln 1.2.0 → 1.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/.codex-plugin/plugin.json +1 -1
  3. package/CHANGELOG.md +27 -0
  4. package/README.md +11 -0
  5. package/dist/agent-run.mjs +5 -2
  6. package/dist/build.json +22 -22
  7. package/dist/cli.mjs +5 -2
  8. package/dist/mcp-engine.mjs +3 -4
  9. package/dist/mcp-server.mjs +6 -6
  10. package/dist/viewer/app.js +180 -180
  11. package/dist/viewer/chat.html +183 -183
  12. package/docs/install.md +7 -6
  13. package/docs/migration.md +16 -0
  14. package/docs/runtime.md +3 -3
  15. package/docs/sdk.md +2 -2
  16. package/lib/asset-widget-uri.d.ts +1 -1
  17. package/lib/asset-widget-uri.js +1 -1
  18. package/lib/engine-identity.d.ts +1 -1
  19. package/lib/engine-identity.js +1 -1
  20. package/lib/mcp-core.d.ts +1 -1
  21. package/lib/tools/registry.d.ts +1 -2
  22. package/lib/tools/registry.js +2 -1
  23. package/package.json +1 -1
  24. package/plugin.json +1 -1
  25. package/plugins/kiln-engine/.claude-plugin/plugin.json +1 -1
  26. package/plugins/kiln-engine/README.md +3 -3
  27. package/plugins/kiln-engine/package-provenance.json +6 -6
  28. package/plugins/kiln-engine/plugin.json +1 -1
  29. package/plugins/kiln-engine/runtime.json +1 -1
  30. package/skills/kiln-author-asset/SKILL.md +1 -1
  31. package/skills/kiln-author-asset/references/camera-cli.md +13 -0
  32. package/skills/kiln-author-asset/references/geometry-recipes.md +10 -0
  33. package/src/asset-widget-uri.ts +1 -1
  34. package/src/engine-identity.ts +1 -1
  35. package/src/generated/mcp-manifest.json +4 -4
  36. package/src/tools/registry.ts +2 -1
  37. package/src/viewer/chat-app.ts +6 -2
  38. package/src/viewer/glb-loader.ts +78 -0
  39. package/src/viewer/scene.ts +9 -26
@@ -122,13 +122,13 @@
122
122
  </div>
123
123
  <p id="status" role="status">Loading asset from Kiln…</p>
124
124
  <script type="module">
125
- var fd="186",Wi={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},Zi={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},dd=0,fl=1,pd=2;var ks=1,md=2,is=3,Xi=0,Qt=1,Cn=2,ii=0,Bs=1,dl=2,pl=3,ml=4,gd=5;var rs=100,_d=101,xd=102,yd=103,vd=104,bd=200,Sd=201,Md=202,wd=203,Ed=204,Td=205,Ad=206,Rd=207,Cd=208,Pd=209,Id=210,Ld=211,Nd=212,Dd=213,Od=214,Ud=0,Fd=1,zd=2,gl=3,kd=4,Bd=5,Gd=6,Hd=7,Vd=0,$d=1,Wd=2,Gn=0,_l=1,xl=2,yl=3,Gs=4,vl=5,bl=6,Sl=7;var ss=301,yr=302,xa=303,ya=304,Hs=306,os=1000,as=1001,va=1002,Hn=1003,ba=1004;var vr=1005;var $t=1006,cs=1007;var ri=1008;var Vn=1009,Zd=1010,Xd=1011,Vs=1012,Ml=1013,qi=1014,Ai=1015,si=1016,wl=1017,El=1018,ls=1020,qd=35902,jd=35899,Yd=1021,Kd=1022,oi=1023,br=1026,Sr=1027,Jd=1028,Tl=1029,Mr=1030,Al=1031;var Rl=1033,Sa=33776,Ma=33777,wa=33778,Ea=33779,Cl=35840,Pl=35841,Il=35842,Ll=35843,Nl=36196,Dl=37492,Ol=37496,Ul=37488,Fl=37489,Ta=37490,zl=37491,kl=37808,Bl=37809,Gl=37810,Hl=37811,Vl=37812,$l=37813,Wl=37814,Zl=37815,Xl=37816,ql=37817,jl=37818,Yl=37819,Kl=37820,Jl=37821,Ql=36492,eu=36494,tu=36495,nu=36283,iu=36284,Aa=36285,ru=36286;var su=2300,Ra=2301;var ou=0,$s=1,us=2;var au=0,Qd=1,wr="",ji="srgb",gn="srgb-linear",cu="linear",pt="srgb";var ep=512,tp=513,np=514,Ca=515,ip=516,rp=517,Pa=518,sp=519;var lu="300 es",uu=2000;function xv(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}function yv(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function es(e){return document.createElementNS("http://www.w3.org/1999/xhtml",e)}function op(){let e=es("canvas");return e.style.display="block",e}var Cf={},ts=null;function zs(...e){let t="THREE."+e.shift();if(ts)ts("log",t,...e);else console.log(t,...e)}function ap(e){let t=e[0];if(typeof t==="string"&&t.startsWith("TSL:")){let n=e[1];if(n&&n.isStackTrace)e[0]+=" "+n.getLocation();else e[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return e}function Pe(...e){e=ap(e);let t="THREE."+e.shift();if(ts)ts("warn",t,...e);else{let n=e[0];if(n&&n.isStackTrace)console.warn(n.getError(t));else console.warn(t,...e)}}function Fe(...e){e=ap(e);let t="THREE."+e.shift();if(ts)ts("error",t,...e);else{let n=e[0];if(n&&n.isStackTrace)console.error(n.getError(t));else console.error(t,...e)}}function _r(...e){let t=e.join(" ");if(t in Cf)return;Cf[t]=!0,Pe(...e)}function cp(e,t,n){return new Promise(function(i,r){function s(){switch(e.clientWaitSync(t,e.SYNC_FLUSH_COMMANDS_BIT,0)){case e.WAIT_FAILED:r();break;case e.TIMEOUT_EXPIRED:setTimeout(s,n);break;default:i()}}setTimeout(s,n)})}var lp={[0]:1,[2]:6,[4]:7,[3]:5,[1]:0,[6]:2,[7]:4,[5]:3};class $n{addEventListener(e,t){if(this._listeners===void 0)this._listeners={};let n=this._listeners;if(n[e]===void 0)n[e]=[];if(n[e].indexOf(t)===-1)n[e].push(t)}hasEventListener(e,t){let n=this._listeners;if(n===void 0)return!1;return n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){let n=this._listeners;if(n===void 0)return;let i=n[e];if(i!==void 0){let r=i.indexOf(t);if(r!==-1)i.splice(r,1)}}dispatchEvent(e){let t=this._listeners;if(t===void 0)return;let n=t[e.type];if(n!==void 0){e.target=this;let i=n.slice(0);for(let r=0,s=i.length;r<s;r++)i[r].call(this,e);e.target=null}}}var Kt=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"],Pf=1234567,Us=Math.PI/180,xr=180/Math.PI;function Bn(){let e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(Kt[e&255]+Kt[e>>8&255]+Kt[e>>16&255]+Kt[e>>24&255]+"-"+Kt[t&255]+Kt[t>>8&255]+"-"+Kt[t>>16&15|64]+Kt[t>>24&255]+"-"+Kt[n&63|128]+Kt[n>>8&255]+"-"+Kt[n>>16&255]+Kt[n>>24&255]+Kt[i&255]+Kt[i>>8&255]+Kt[i>>16&255]+Kt[i>>24&255]).toLowerCase()}function We(e,t,n){return Math.max(t,Math.min(n,e))}function hu(e,t){return(e%t+t)%t}function vv(e,t,n,i,r){return i+(e-t)*(r-i)/(n-t)}function bv(e,t,n){if(e!==t)return(n-e)/(t-e);else return 0}function Fs(e,t,n){return(1-n)*e+n*t}function Sv(e,t,n,i){return Fs(e,t,1-Math.exp(-n*i))}function Mv(e,t=1){return t-Math.abs(hu(e,t*2)-t)}function wv(e,t,n){if(e<=t)return 0;if(e>=n)return 1;return e=(e-t)/(n-t),e*e*(3-2*e)}function Ev(e,t,n){if(e<=t)return 0;if(e>=n)return 1;return e=(e-t)/(n-t),e*e*e*(e*(e*6-15)+10)}function Tv(e,t){return e+Math.floor(Math.random()*(t-e+1))}function Av(e,t){return e+Math.random()*(t-e)}function Rv(e){return e*(0.5-Math.random())}function Cv(e){if(e!==void 0)Pf=e;let t=Pf+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function Pv(e){return e*Us}function Iv(e){return e*xr}function Lv(e){return e>0&&Number.isInteger(e)&&2**Math.round(Math.log2(e))===e}function Nv(e){return Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))}function Dv(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))}function Ov(e,t,n,i,r){let{cos:s,sin:o}=Math,a=s(n/2),c=o(n/2),l=s((t+i)/2),u=o((t+i)/2),f=s((t-i)/2),h=o((t-i)/2),d=s((i-t)/2),g=o((i-t)/2);switch(r){case"XYX":e.set(a*u,c*f,c*h,a*l);break;case"YZY":e.set(c*h,a*u,c*f,a*l);break;case"ZXZ":e.set(c*f,c*h,a*u,a*l);break;case"XZX":e.set(a*u,c*g,c*d,a*l);break;case"YXY":e.set(c*d,a*u,c*g,a*l);break;case"ZYZ":e.set(c*g,c*d,a*u,a*l);break;default:Pe("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}function kn(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return e/4294967295;case Uint16Array:return e/65535;case Uint8Array:case Uint8ClampedArray:return e/255;case Int32Array:return Math.max(e/2147483647,-1);case Int16Array:return Math.max(e/32767,-1);case Int8Array:return Math.max(e/127,-1);default:throw Error("THREE.MathUtils: Invalid component type.")}}function at(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return Math.round(e*4294967295);case Uint16Array:return Math.round(e*65535);case Uint8Array:case Uint8ClampedArray:return Math.round(e*255);case Int32Array:return Math.round(e*2147483647);case Int16Array:return Math.round(e*32767);case Int8Array:return Math.round(e*127);default:throw Error("THREE.MathUtils: Invalid component type.")}}var Ws={DEG2RAD:Us,RAD2DEG:xr,generateUUID:Bn,clamp:We,euclideanModulo:hu,mapLinear:vv,inverseLerp:bv,lerp:Fs,damp:Sv,pingpong:Mv,smoothstep:wv,smootherstep:Ev,randInt:Tv,randFloat:Av,randFloatSpread:Rv,seededRandom:Cv,degToRad:Pv,radToDeg:Iv,isPowerOfTwo:Lv,ceilPowerOfTwo:Nv,floorPowerOfTwo:Dv,setQuaternionFromProperEuler:Ov,normalize:at,denormalize:kn};class Ne{static{Ne.prototype.isVector2=!0}constructor(e=0,t=0){this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw Error("THREE.Vector2: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw Error("THREE.Vector2: 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){let 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=We(this.x,e.x,t.x),this.y=We(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=We(this.x,e,t),this.y=We(this.y,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(We(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(We(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){let n=Math.cos(t),i=Math.sin(t),r=this.x-e.x,s=this.y-e.y;return this.x=r*n-s*i+e.x,this.y=r*i+s*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Ht{constructor(e=0,t=0,n=0,i=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=i}static slerpFlat(e,t,n,i,r,s,o){let a=n[i+0],c=n[i+1],l=n[i+2],u=n[i+3],f=r[s+0],h=r[s+1],d=r[s+2],g=r[s+3];if(u!==g||a!==f||c!==h||l!==d){let x=a*f+c*h+l*d+u*g;if(x<0)f=-f,h=-h,d=-d,g=-g,x=-x;let p=1-o;if(x<0.9995){let m=Math.acos(x),E=Math.sin(m);p=Math.sin(p*m)/E,o=Math.sin(o*m)/E,a=a*p+f*o,c=c*p+h*o,l=l*p+d*o,u=u*p+g*o}else{a=a*p+f*o,c=c*p+h*o,l=l*p+d*o,u=u*p+g*o;let m=1/Math.sqrt(a*a+c*c+l*l+u*u);a*=m,c*=m,l*=m,u*=m}}e[t]=a,e[t+1]=c,e[t+2]=l,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,i,r,s){let o=n[i],a=n[i+1],c=n[i+2],l=n[i+3],u=r[s],f=r[s+1],h=r[s+2],d=r[s+3];return e[t]=o*d+l*u+a*h-c*f,e[t+1]=a*d+l*f+c*u-o*h,e[t+2]=c*d+l*h+o*f-a*u,e[t+3]=l*d-o*u-a*f-c*h,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=!0){let{_x:n,_y:i,_z:r,_order:s}=e,{cos:o,sin:a}=Math,c=o(n/2),l=o(i/2),u=o(r/2),f=a(n/2),h=a(i/2),d=a(r/2);switch(s){case"XYZ":this._x=f*l*u+c*h*d,this._y=c*h*u-f*l*d,this._z=c*l*d+f*h*u,this._w=c*l*u-f*h*d;break;case"YXZ":this._x=f*l*u+c*h*d,this._y=c*h*u-f*l*d,this._z=c*l*d-f*h*u,this._w=c*l*u+f*h*d;break;case"ZXY":this._x=f*l*u-c*h*d,this._y=c*h*u+f*l*d,this._z=c*l*d+f*h*u,this._w=c*l*u-f*h*d;break;case"ZYX":this._x=f*l*u-c*h*d,this._y=c*h*u+f*l*d,this._z=c*l*d-f*h*u,this._w=c*l*u+f*h*d;break;case"YZX":this._x=f*l*u+c*h*d,this._y=c*h*u+f*l*d,this._z=c*l*d-f*h*u,this._w=c*l*u-f*h*d;break;case"XZY":this._x=f*l*u-c*h*d,this._y=c*h*u-f*l*d,this._z=c*l*d+f*h*u,this._w=c*l*u+f*h*d;break;default:Pe("Quaternion: .setFromEuler() encountered an unknown order: "+s)}if(t===!0)this._onChangeCallback();return this}setFromAxisAngle(e,t){let 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){let t=e.elements,n=t[0],i=t[4],r=t[8],s=t[1],o=t[5],a=t[9],c=t[2],l=t[6],u=t[10],f=n+o+u;if(f>0){let h=0.5/Math.sqrt(f+1);this._w=0.25/h,this._x=(l-a)*h,this._y=(r-c)*h,this._z=(s-i)*h}else if(n>o&&n>u){let h=2*Math.sqrt(1+n-o-u);this._w=(l-a)/h,this._x=0.25*h,this._y=(i+s)/h,this._z=(r+c)/h}else if(o>u){let h=2*Math.sqrt(1+o-n-u);this._w=(r-c)/h,this._x=(i+s)/h,this._y=0.25*h,this._z=(a+l)/h}else{let h=2*Math.sqrt(1+u-n-o);this._w=(s-i)/h,this._x=(r+c)/h,this._y=(a+l)/h,this._z=0.25*h}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;if(n<0.00000001)if(n=0,Math.abs(e.x)>Math.abs(e.z))this._x=-e.y,this._y=e.x,this._z=0,this._w=n;else this._x=0,this._y=-e.z,this._z=e.y,this._w=n;else 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;return this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(We(this.dot(e),-1,1)))}rotateTowards(e,t){let n=this.angleTo(e);if(n===0)return this;let 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();if(e===0)this._x=0,this._y=0,this._z=0,this._w=1;else e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e;return this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){let{_x:n,_y:i,_z:r,_w:s}=e,{_x:o,_y:a,_z:c,_w:l}=t;return this._x=n*l+s*o+i*c-r*a,this._y=i*l+s*a+r*o-n*c,this._z=r*l+s*c+n*a-i*o,this._w=s*l-n*o-i*a-r*c,this._onChangeCallback(),this}slerp(e,t){let{_x:n,_y:i,_z:r,_w:s}=e,o=this.dot(e);if(o<0)n=-n,i=-i,r=-r,s=-s,o=-o;let a=1-t;if(o<0.9995){let c=Math.acos(o),l=Math.sin(c);a=Math.sin(a*c)/l,t=Math.sin(t*c)/l,this._x=this._x*a+n*t,this._y=this._y*a+i*t,this._z=this._z*a+r*t,this._w=this._w*a+s*t,this._onChangeCallback()}else this._x=this._x*a+n*t,this._y=this._y*a+i*t,this._z=this._z*a+r*t,this._w=this._w*a+s*t,this.normalize();return this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){let e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),i=Math.sqrt(1-n),r=Math.sqrt(n);return this.set(i*Math.sin(e),i*Math.cos(e),r*Math.sin(t),r*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class D{static{D.prototype.isVector3=!0}constructor(e=0,t=0,n=0){this.x=e,this.y=t,this.z=n}set(e,t,n){if(n===void 0)n=this.z;return this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw Error("THREE.Vector3: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw Error("THREE.Vector3: 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(If.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(If.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6]*i,this.y=r[1]*t+r[4]*n+r[7]*i,this.z=r[2]*t+r[5]*n+r[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,n=this.y,i=this.z,r=e.elements,s=1/(r[3]*t+r[7]*n+r[11]*i+r[15]);return this.x=(r[0]*t+r[4]*n+r[8]*i+r[12])*s,this.y=(r[1]*t+r[5]*n+r[9]*i+r[13])*s,this.z=(r[2]*t+r[6]*n+r[10]*i+r[14])*s,this}applyQuaternion(e){let t=this.x,n=this.y,i=this.z,{x:r,y:s,z:o,w:a}=e,c=2*(s*i-o*n),l=2*(o*t-r*i),u=2*(r*n-s*t);return this.x=t+a*c+s*u-o*l,this.y=n+a*l+o*c-r*u,this.z=i+a*u+r*l-s*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[4]*n+r[8]*i,this.y=r[1]*t+r[5]*n+r[9]*i,this.z=r[2]*t+r[6]*n+r[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=We(this.x,e.x,t.x),this.y=We(this.y,e.y,t.y),this.z=We(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=We(this.x,e,t),this.y=We(this.y,e,t),this.z=We(this.z,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(We(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){let{x:n,y:i,z:r}=e,{x:s,y:o,z:a}=t;return this.x=i*a-r*o,this.y=r*s-n*a,this.z=n*o-i*s,this}projectOnVector(e){let t=e.lengthSq();if(t===0)return this.set(0,0,0);let n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return Gc.copy(this).projectOnVector(e),this.sub(Gc)}reflect(e){return this.sub(Gc.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(We(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let 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){let 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){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){let t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),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(){let e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}var Gc=new D,If=new Ht;class ke{static{ke.prototype.isMatrix3=!0}constructor(e,t,n,i,r,s,o,a,c){if(this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0)this.set(e,t,n,i,r,s,o,a,c)}set(e,t,n,i,r,s,o,a,c){let l=this.elements;return l[0]=e,l[1]=i,l[2]=o,l[3]=t,l[4]=r,l[5]=a,l[6]=n,l[7]=s,l[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){let t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,i=t.elements,r=this.elements,s=n[0],o=n[3],a=n[6],c=n[1],l=n[4],u=n[7],f=n[2],h=n[5],d=n[8],g=i[0],x=i[3],p=i[6],m=i[1],E=i[4],R=i[7],v=i[2],M=i[5],T=i[8];return r[0]=s*g+o*m+a*v,r[3]=s*x+o*E+a*M,r[6]=s*p+o*R+a*T,r[1]=c*g+l*m+u*v,r[4]=c*x+l*E+u*M,r[7]=c*p+l*R+u*T,r[2]=f*g+h*m+d*v,r[5]=f*x+h*E+d*M,r[8]=f*p+h*R+d*T,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],s=e[4],o=e[5],a=e[6],c=e[7],l=e[8];return t*s*l-t*o*c-n*r*l+n*o*a+i*r*c-i*s*a}invert(){let e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],s=e[4],o=e[5],a=e[6],c=e[7],l=e[8],u=l*s-o*c,f=o*a-l*r,h=c*r-s*a,d=t*u+n*f+i*h;if(d===0)return this.set(0,0,0,0,0,0,0,0,0);let g=1/d;return e[0]=u*g,e[1]=(i*c-l*n)*g,e[2]=(o*n-i*s)*g,e[3]=f*g,e[4]=(l*t-i*a)*g,e[5]=(i*r-o*t)*g,e[6]=h*g,e[7]=(n*a-c*t)*g,e[8]=(s*t-n*r)*g,this}transpose(){let e,t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){let t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,i,r,s,o){let a=Math.cos(r),c=Math.sin(r);return this.set(n*a,n*c,-n*(a*s+c*o)+s+e,-i*c,i*a,-i*(-c*s+a*o)+o+t,0,0,1),this}scale(e,t){return _r("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(Hc.makeScale(e,t)),this}rotate(e){return _r("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(Hc.makeRotation(-e)),this}translate(e,t){return _r("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(Hc.makeTranslation(e,t)),this}makeTranslation(e,t){if(e.isVector2)this.set(1,0,e.x,0,1,e.y,0,0,1);else this.set(1,0,e,0,1,t,0,0,1);return this}makeRotation(e){let 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){let 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){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}}var Hc=new ke,Lf=new ke().set(0.4123908,0.3575843,0.1804808,0.212639,0.7151687,0.0721923,0.0193308,0.1191948,0.9505322),Nf=new ke().set(3.2409699,-1.5373832,-0.4986108,-0.9692436,1.8759675,0.0415551,0.0556301,-0.203977,1.0569715);function Uv(){let e={enabled:!0,workingColorSpace:"srgb-linear",spaces:{},convert:function(r,s,o){if(this.enabled===!1||s===o||!s||!o)return r;if(this.spaces[s].transfer==="srgb")r.r=Ti(r.r),r.g=Ti(r.g),r.b=Ti(r.b);if(this.spaces[s].primaries!==this.spaces[o].primaries)r.applyMatrix3(this.spaces[s].toXYZ),r.applyMatrix3(this.spaces[o].fromXYZ);if(this.spaces[o].transfer==="srgb")r.r=Qr(r.r),r.g=Qr(r.g),r.b=Qr(r.b);return r},workingToColorSpace:function(r,s){return this.convert(r,this.workingColorSpace,s)},colorSpaceToWorking:function(r,s){return this.convert(r,s,this.workingColorSpace)},getPrimaries:function(r){return this.spaces[r].primaries},getTransfer:function(r){if(r==="")return"linear";return this.spaces[r].transfer},getToneMappingMode:function(r){return this.spaces[r].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(r,s=this.workingColorSpace){return r.fromArray(this.spaces[s].luminanceCoefficients)},define:function(r){Object.assign(this.spaces,r)},_getMatrix:function(r,s,o){return r.copy(this.spaces[s].toXYZ).multiply(this.spaces[o].fromXYZ)},_getDrawingBufferColorSpace:function(r){return this.spaces[r].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(r=this.workingColorSpace){return this.spaces[r].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(r,s){return _r("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),e.workingToColorSpace(r,s)},toWorkingColorSpace:function(r,s){return _r("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),e.colorSpaceToWorking(r,s)}},t=[0.64,0.33,0.3,0.6,0.15,0.06],n=[0.2126,0.7152,0.0722],i=[0.3127,0.329];return e.define({["srgb-linear"]:{primaries:t,whitePoint:i,transfer:"linear",toXYZ:Lf,fromXYZ:Nf,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:"srgb"},outputColorSpaceConfig:{drawingBufferColorSpace:"srgb"}},["srgb"]:{primaries:t,whitePoint:i,transfer:"srgb",toXYZ:Lf,fromXYZ:Nf,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:"srgb"}}}),e}var $e=Uv();function Ti(e){return e<0.04045?e*0.0773993808:Math.pow(e*0.9478672986+0.0521327014,2.4)}function Qr(e){return e<0.0031308?e*12.92:1.055*Math.pow(e,0.41666)-0.055}var kr;class fu{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src))return e.src;if(typeof HTMLCanvasElement>"u")return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{if(kr===void 0)kr=es("canvas");kr.width=e.width,kr.height=e.height;let i=kr.getContext("2d");if(e instanceof ImageData)i.putImageData(e,0,0);else i.drawImage(e,0,0,e.width,e.height);n=kr}return n.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){let t=es("canvas");t.width=e.width,t.height=e.height;let n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);let i=n.getImageData(0,0,e.width,e.height),r=i.data;for(let s=0;s<r.length;s++)r[s]=Ti(r[s]/255)*255;return n.putImageData(i,0,0),t}else if(e.data){let t=e.data.slice(0);for(let n=0;n<t.length;n++)if(t instanceof Uint8Array||t instanceof Uint8ClampedArray)t[n]=Math.floor(Ti(t[n]/255)*255);else t[n]=Ti(t[n]);return{data:t,width:e.width,height:e.height}}else return Pe("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}var Fv=0;class Zs{constructor(e=null){this.isTextureSource=!0,Object.defineProperty(this,"id",{value:Fv++}),this.uuid=Bn(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){let t=this.data;if(typeof HTMLVideoElement<"u"&&t instanceof HTMLVideoElement)e.set(t.videoWidth,t.videoHeight,0);else if(typeof VideoFrame<"u"&&t instanceof VideoFrame)e.set(t.displayWidth,t.displayHeight,0);else if(t!==null)e.set(t.width,t.height,t.depth||0);else e.set(0,0,0);return e}set needsUpdate(e){if(e===!0)this.version++}toJSON(e){let t=e===void 0||typeof e==="string";if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];let n={uuid:this.uuid,url:""},i=this.data;if(i!==null){let r;if(Array.isArray(i)){r=[];for(let s=0,o=i.length;s<o;s++)if(i[s].isDataTexture)r.push(Vc(i[s].image));else r.push(Vc(i[s]))}else r=Vc(i);n.url=r}if(!t)e.images[this.uuid]=n;return n}}function Vc(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap)return fu.getDataURL(e);else if(e.data)return{data:Array.from(e.data),width:e.width,height:e.height,type:e.data.constructor.name};else return Pe("Texture: Unable to serialize Texture."),{}}var zv=0,$c=new D;class At extends $n{constructor(e=At.DEFAULT_IMAGE,t=At.DEFAULT_MAPPING,n=1001,i=1001,r=1006,s=1008,o=1023,a=1009,c=At.DEFAULT_ANISOTROPY,l=""){super();this.isTexture=!0,Object.defineProperty(this,"id",{value:zv++}),this.uuid=Bn(),this.name="",this.source=new Zs(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=n,this.wrapT=i,this.magFilter=r,this.minFilter=s,this.anisotropy=c,this.format=o,this.internalFormat=null,this.type=a,this.offset=new Ne(0,0),this.repeat=new Ne(1,1),this.center=new Ne(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new ke,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=l,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=e&&e.depth&&e.depth>1?!0:!1,this.pmremVersion=0,this.normalized=!1}get width(){return this.source.getSize($c).x}get height(){return this.source.getSize($c).y}get depth(){return this.source.getSize($c).z}get image(){return this.source.data}set image(e){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.normalized=e.normalized,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(let t in e){let n=e[t];if(n===void 0){Pe(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}let i=this[t];if(i===void 0){Pe(`Texture.setValues(): property '${t}' does not exist.`);continue}if(i&&n&&(i.isVector2&&n.isVector2))i.copy(n);else if(i&&n&&(i.isVector3&&n.isVector3))i.copy(n);else if(i&&n&&(i.isMatrix3&&n.isMatrix3))i.copy(n);else this[t]=n}}toJSON(e){let t=e===void 0||typeof e==="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];let n={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,normalized:this.normalized,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};if(Object.keys(this.userData).length>0)n.userData=this.userData;if(!t)e.textures[this.uuid]=n;return n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==300)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case 1000:e.x=e.x-Math.floor(e.x);break;case 1001:e.x=e.x<0?0:1;break;case 1002:if(Math.abs(Math.floor(e.x)%2)===1)e.x=Math.ceil(e.x)-e.x;else e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case 1000:e.y=e.y-Math.floor(e.y);break;case 1001:e.y=e.y<0?0:1;break;case 1002:if(Math.abs(Math.floor(e.y)%2)===1)e.y=Math.ceil(e.y)-e.y;else e.y=e.y-Math.floor(e.y);break}if(this.flipY)e.y=1-e.y;return e}set needsUpdate(e){if(e===!0)this.version++,this.source.needsUpdate=!0}set needsPMREMUpdate(e){if(e===!0)this.pmremVersion++}}At.DEFAULT_IMAGE=null;At.DEFAULT_MAPPING=300;At.DEFAULT_ANISOTROPY=1;class ct{static{ct.prototype.isVector4=!0}constructor(e=0,t=0,n=0,i=1){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 Error("THREE.Vector4: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw Error("THREE.Vector4: 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){let t=this.x,n=this.y,i=this.z,r=this.w,s=e.elements;return this.x=s[0]*t+s[4]*n+s[8]*i+s[12]*r,this.y=s[1]*t+s[5]*n+s[9]*i+s[13]*r,this.z=s[2]*t+s[6]*n+s[10]*i+s[14]*r,this.w=s[3]*t+s[7]*n+s[11]*i+s[15]*r,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);let t=Math.sqrt(1-e.w*e.w);if(t<0.0001)this.x=1,this.y=0,this.z=0;else this.x=e.x/t,this.y=e.y/t,this.z=e.z/t;return this}setAxisAngleFromRotationMatrix(e){let t,n,i,r,s=0.01,o=0.1,a=e.elements,c=a[0],l=a[4],u=a[8],f=a[1],h=a[5],d=a[9],g=a[2],x=a[6],p=a[10];if(Math.abs(l-f)<0.01&&Math.abs(u-g)<0.01&&Math.abs(d-x)<0.01){if(Math.abs(l+f)<0.1&&Math.abs(u+g)<0.1&&Math.abs(d+x)<0.1&&Math.abs(c+h+p-3)<0.1)return this.set(1,0,0,0),this;t=Math.PI;let E=(c+1)/2,R=(h+1)/2,v=(p+1)/2,M=(l+f)/4,T=(u+g)/4,A=(d+x)/4;if(E>R&&E>v)if(E<0.01)n=0,i=0.707106781,r=0.707106781;else n=Math.sqrt(E),i=M/n,r=T/n;else if(R>v)if(R<0.01)n=0.707106781,i=0,r=0.707106781;else i=Math.sqrt(R),n=M/i,r=A/i;else if(v<0.01)n=0.707106781,i=0.707106781,r=0;else r=Math.sqrt(v),n=T/r,i=A/r;return this.set(n,i,r,t),this}let m=Math.sqrt((x-d)*(x-d)+(u-g)*(u-g)+(f-l)*(f-l));if(Math.abs(m)<0.001)m=1;return this.x=(x-d)/m,this.y=(u-g)/m,this.z=(f-l)/m,this.w=Math.acos((c+h+p-1)/2),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],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=We(this.x,e.x,t.x),this.y=We(this.y,e.y,t.y),this.z=We(this.z,e.z,t.z),this.w=We(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=We(this.x,e,t),this.y=We(this.y,e,t),this.z=We(this.z,e,t),this.w=We(this.w,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(We(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class du extends $n{constructor(e=1,t=1,n={}){super();n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:1006,depthBuffer:!0,stencilBuffer:!1,resolveColorBuffer:!0,resolveDepthBuffer:!0,resolveStencilBuffer:!0,storeMultisampledColorBuffer:!0,storeMultisampledDepthBuffer:!0,storeMultisampledStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1,useArrayDepthTexture:!1},n),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=n.depth,this.scissor=new ct(0,0,e,t),this.scissorTest=!1,this.viewport=new ct(0,0,e,t),this.textures=[];let i={width:e,height:t,depth:n.depth},r=new At(i),s=n.count;for(let o=0;o<s;o++)this.textures[o]=r.clone(),this.textures[o].isRenderTargetTexture=!0,this.textures[o].renderTarget=this;this._setTextureOptions(n),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveColorBuffer=n.resolveColorBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this.storeMultisampledColorBuffer=n.storeMultisampledColorBuffer,this.storeMultisampledDepthBuffer=n.storeMultisampledDepthBuffer,this.storeMultisampledStencilBuffer=n.storeMultisampledStencilBuffer,this._depthTexture=null,this.depthTexture=n.depthTexture,this.samples=n.samples,this.multiview=n.multiview,this.useArrayDepthTexture=n.useArrayDepthTexture}_setTextureOptions(e={}){let t={minFilter:1006,generateMipmaps:!1,flipY:!1,internalFormat:null};if(e.mapping!==void 0)t.mapping=e.mapping;if(e.wrapS!==void 0)t.wrapS=e.wrapS;if(e.wrapT!==void 0)t.wrapT=e.wrapT;if(e.wrapR!==void 0)t.wrapR=e.wrapR;if(e.magFilter!==void 0)t.magFilter=e.magFilter;if(e.minFilter!==void 0)t.minFilter=e.minFilter;if(e.format!==void 0)t.format=e.format;if(e.type!==void 0)t.type=e.type;if(e.anisotropy!==void 0)t.anisotropy=e.anisotropy;if(e.colorSpace!==void 0)t.colorSpace=e.colorSpace;if(e.flipY!==void 0)t.flipY=e.flipY;if(e.generateMipmaps!==void 0)t.generateMipmaps=e.generateMipmaps;if(e.internalFormat!==void 0)t.internalFormat=e.internalFormat;for(let n=0;n<this.textures.length;n++)this.textures[n].setValues(t)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){if(this._depthTexture!==null&&this._depthTexture.renderTarget===this)this._depthTexture.renderTarget=null;if(e!==null&&e.renderTarget===null)e.renderTarget=this;this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,t,n=1){if(this.width!==e||this.height!==t||this.depth!==n){this.width=e,this.height=t,this.depth=n;for(let i=0,r=this.textures.length;i<r;i++)if(this.textures[i].image.width=e,this.textures[i].image.height=t,this.textures[i].image.depth=n,this.textures[i].isData3DTexture!==!0)this.textures[i].isArrayTexture=this.textures[i].image.depth>1;this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,n=e.textures.length;t<n;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;let i=Object.assign({},e.textures[t].image);this.textures[t].source=new Zs(i)}if(this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveColorBuffer=e.resolveColorBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,this.storeMultisampledColorBuffer=e.storeMultisampledColorBuffer,this.storeMultisampledDepthBuffer=e.storeMultisampledDepthBuffer,this.storeMultisampledStencilBuffer=e.storeMultisampledStencilBuffer,e.depthTexture!==null)if(e.depthTexture.renderTarget===e){let t=e.depthTexture.clone();t.renderTarget=null,this.depthTexture=t}else this.depthTexture=e.depthTexture;return this.samples=e.samples,this.multiview=e.multiview,this.useArrayDepthTexture=e.useArrayDepthTexture,this}dispose(){this.dispatchEvent({type:"dispose"})}}class _n extends du{constructor(e=1,t=1,n={}){super(e,t,n);this.isWebGLRenderTarget=!0}}class Ia extends At{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=1003,this.minFilter=1003,this.wrapR=1001,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}copy(e){return super.copy(e),this.wrapR=e.wrapR,this}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class pu extends At{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=1003,this.minFilter=1003,this.wrapR=1001,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}copy(e){return super.copy(e),this.wrapR=e.wrapR,this}}class Ge{static{Ge.prototype.isMatrix4=!0}constructor(e,t,n,i,r,s,o,a,c,l,u,f,h,d,g,x){if(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,r,s,o,a,c,l,u,f,h,d,g,x)}set(e,t,n,i,r,s,o,a,c,l,u,f,h,d,g,x){let p=this.elements;return p[0]=e,p[4]=t,p[8]=n,p[12]=i,p[1]=r,p[5]=s,p[9]=o,p[13]=a,p[2]=c,p[6]=l,p[10]=u,p[14]=f,p[3]=h,p[7]=d,p[11]=g,p[15]=x,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 Ge().fromArray(this.elements)}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){let t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){let 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){if(this.determinantAffine()===0)return e.set(1,0,0),t.set(0,1,0),n.set(0,0,1),this;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){if(e.determinantAffine()===0)return this.identity();let t=this.elements,n=e.elements,i=1/Br.setFromMatrixColumn(e,0).length(),r=1/Br.setFromMatrixColumn(e,1).length(),s=1/Br.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]*r,t[5]=n[5]*r,t[6]=n[6]*r,t[7]=0,t[8]=n[8]*s,t[9]=n[9]*s,t[10]=n[10]*s,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){let t=this.elements,{x:n,y:i,z:r}=e,s=Math.cos(n),o=Math.sin(n),a=Math.cos(i),c=Math.sin(i),l=Math.cos(r),u=Math.sin(r);if(e.order==="XYZ"){let f=s*l,h=s*u,d=o*l,g=o*u;t[0]=a*l,t[4]=-a*u,t[8]=c,t[1]=h+d*c,t[5]=f-g*c,t[9]=-o*a,t[2]=g-f*c,t[6]=d+h*c,t[10]=s*a}else if(e.order==="YXZ"){let f=a*l,h=a*u,d=c*l,g=c*u;t[0]=f+g*o,t[4]=d*o-h,t[8]=s*c,t[1]=s*u,t[5]=s*l,t[9]=-o,t[2]=h*o-d,t[6]=g+f*o,t[10]=s*a}else if(e.order==="ZXY"){let f=a*l,h=a*u,d=c*l,g=c*u;t[0]=f-g*o,t[4]=-s*u,t[8]=d+h*o,t[1]=h+d*o,t[5]=s*l,t[9]=g-f*o,t[2]=-s*c,t[6]=o,t[10]=s*a}else if(e.order==="ZYX"){let f=s*l,h=s*u,d=o*l,g=o*u;t[0]=a*l,t[4]=d*c-h,t[8]=f*c+g,t[1]=a*u,t[5]=g*c+f,t[9]=h*c-d,t[2]=-c,t[6]=o*a,t[10]=s*a}else if(e.order==="YZX"){let f=s*a,h=s*c,d=o*a,g=o*c;t[0]=a*l,t[4]=g-f*u,t[8]=d*u+h,t[1]=u,t[5]=s*l,t[9]=-o*l,t[2]=-c*l,t[6]=h*u+d,t[10]=f-g*u}else if(e.order==="XZY"){let f=s*a,h=s*c,d=o*a,g=o*c;t[0]=a*l,t[4]=-u,t[8]=c*l,t[1]=f*u+g,t[5]=s*l,t[9]=h*u-d,t[2]=d*u-h,t[6]=o*l,t[10]=g*u+f}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(kv,e,Bv)}lookAt(e,t,n){let i=this.elements;if(pn.subVectors(e,t),pn.lengthSq()===0)pn.z=1;if(pn.normalize(),zi.crossVectors(n,pn),zi.lengthSq()===0){if(Math.abs(n.z)===1)pn.x+=0.0001;else pn.z+=0.0001;pn.normalize(),zi.crossVectors(n,pn)}return zi.normalize(),$o.crossVectors(pn,zi),i[0]=zi.x,i[4]=$o.x,i[8]=pn.x,i[1]=zi.y,i[5]=$o.y,i[9]=pn.y,i[2]=zi.z,i[6]=$o.z,i[10]=pn.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,i=t.elements,r=this.elements,s=n[0],o=n[4],a=n[8],c=n[12],l=n[1],u=n[5],f=n[9],h=n[13],d=n[2],g=n[6],x=n[10],p=n[14],m=n[3],E=n[7],R=n[11],v=n[15],M=i[0],T=i[4],A=i[8],_=i[12],S=i[1],k=i[5],C=i[9],U=i[13],ee=i[2],P=i[6],V=i[10],j=i[14],z=i[3],H=i[7],F=i[11],q=i[15];return r[0]=s*M+o*S+a*ee+c*z,r[4]=s*T+o*k+a*P+c*H,r[8]=s*A+o*C+a*V+c*F,r[12]=s*_+o*U+a*j+c*q,r[1]=l*M+u*S+f*ee+h*z,r[5]=l*T+u*k+f*P+h*H,r[9]=l*A+u*C+f*V+h*F,r[13]=l*_+u*U+f*j+h*q,r[2]=d*M+g*S+x*ee+p*z,r[6]=d*T+g*k+x*P+p*H,r[10]=d*A+g*C+x*V+p*F,r[14]=d*_+g*U+x*j+p*q,r[3]=m*M+E*S+R*ee+v*z,r[7]=m*T+E*k+R*P+v*H,r[11]=m*A+E*C+R*V+v*F,r[15]=m*_+E*U+R*j+v*q,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[4],i=e[8],r=e[12],s=e[1],o=e[5],a=e[9],c=e[13],l=e[2],u=e[6],f=e[10],h=e[14],d=e[3],g=e[7],x=e[11],p=e[15],m=a*h-c*f,E=o*h-c*u,R=o*f-a*u,v=s*h-c*l,M=s*f-a*l,T=s*u-o*l;return t*(g*m-x*E+p*R)-n*(d*m-x*v+p*M)+i*(d*E-g*v+p*T)-r*(d*R-g*M+x*T)}determinantAffine(){let e=this.elements,t=e[0],n=e[4],i=e[8],r=e[1],s=e[5],o=e[9],a=e[2],c=e[6],l=e[10];return t*(s*l-o*c)-n*(r*l-o*a)+i*(r*c-s*a)}transpose(){let e=this.elements,t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){let i=this.elements;if(e.isVector3)i[12]=e.x,i[13]=e.y,i[14]=e.z;else i[12]=e,i[13]=t,i[14]=n;return this}invert(){let e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],s=e[4],o=e[5],a=e[6],c=e[7],l=e[8],u=e[9],f=e[10],h=e[11],d=e[12],g=e[13],x=e[14],p=e[15],m=t*o-n*s,E=t*a-i*s,R=t*c-r*s,v=n*a-i*o,M=n*c-r*o,T=i*c-r*a,A=l*g-u*d,_=l*x-f*d,S=l*p-h*d,k=u*x-f*g,C=u*p-h*g,U=f*p-h*x,ee=m*U-E*C+R*k+v*S-M*_+T*A;if(ee===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let P=1/ee;return e[0]=(o*U-a*C+c*k)*P,e[1]=(i*C-n*U-r*k)*P,e[2]=(g*T-x*M+p*v)*P,e[3]=(f*M-u*T-h*v)*P,e[4]=(a*S-s*U-c*_)*P,e[5]=(t*U-i*S+r*_)*P,e[6]=(x*R-d*T-p*E)*P,e[7]=(l*T-f*R+h*E)*P,e[8]=(s*C-o*S+c*A)*P,e[9]=(n*S-t*C-r*A)*P,e[10]=(d*M-g*R+p*m)*P,e[11]=(u*R-l*M-h*m)*P,e[12]=(o*_-s*k-a*A)*P,e[13]=(t*k-n*_+i*A)*P,e[14]=(g*E-d*v-x*m)*P,e[15]=(l*v-u*E+f*m)*P,this}scale(e){let t=this.elements,{x:n,y:i,z:r}=e;return t[0]*=n,t[4]*=i,t[8]*=r,t[1]*=n,t[5]*=i,t[9]*=r,t[2]*=n,t[6]*=i,t[10]*=r,t[3]*=n,t[7]*=i,t[11]*=r,this}getMaxScaleOnAxis(){let e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],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){if(e.isVector3)this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1);else this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1);return this}makeRotationX(e){let t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){let n=Math.cos(t),i=Math.sin(t),r=1-n,{x:s,y:o,z:a}=e,c=r*s,l=r*o;return this.set(c*s+n,c*o-i*a,c*a+i*o,0,c*o+i*a,l*o+n,l*a-i*s,0,c*a-i*o,l*a+i*s,r*a*a+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,r,s){return this.set(1,n,r,0,e,1,s,0,t,i,1,0,0,0,0,1),this}compose(e,t,n){let i=this.elements,{_x:r,_y:s,_z:o,_w:a}=t,c=r+r,l=s+s,u=o+o,f=r*c,h=r*l,d=r*u,g=s*l,x=s*u,p=o*u,m=a*c,E=a*l,R=a*u,{x:v,y:M,z:T}=n;return i[0]=(1-(g+p))*v,i[1]=(h+R)*v,i[2]=(d-E)*v,i[3]=0,i[4]=(h-R)*M,i[5]=(1-(f+p))*M,i[6]=(x+m)*M,i[7]=0,i[8]=(d+E)*T,i[9]=(x-m)*T,i[10]=(1-(f+g))*T,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,t,n){let i=this.elements;e.x=i[12],e.y=i[13],e.z=i[14];let r=this.determinantAffine();if(r===0)return n.set(1,1,1),t.identity(),this;let s=Br.set(i[0],i[1],i[2]).length(),o=Br.set(i[4],i[5],i[6]).length(),a=Br.set(i[8],i[9],i[10]).length();if(r<0)s=-s;Un.copy(this);let c=1/s,l=1/o,u=1/a;return Un.elements[0]*=c,Un.elements[1]*=c,Un.elements[2]*=c,Un.elements[4]*=l,Un.elements[5]*=l,Un.elements[6]*=l,Un.elements[8]*=u,Un.elements[9]*=u,Un.elements[10]*=u,t.setFromRotationMatrix(Un),n.x=s,n.y=o,n.z=a,this}makePerspective(e,t,n,i,r,s,o=2000,a=!1){let c=this.elements,l=2*r/(t-e),u=2*r/(n-i),f=(t+e)/(t-e),h=(n+i)/(n-i),d,g;if(a)d=r/(s-r),g=s*r/(s-r);else if(o===2000)d=-(s+r)/(s-r),g=-2*s*r/(s-r);else if(o===2001)d=-s/(s-r),g=-s*r/(s-r);else throw Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return c[0]=l,c[4]=0,c[8]=f,c[12]=0,c[1]=0,c[5]=u,c[9]=h,c[13]=0,c[2]=0,c[6]=0,c[10]=d,c[14]=g,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,t,n,i,r,s,o=2000,a=!1){let c=this.elements,l=2/(t-e),u=2/(n-i),f=-(t+e)/(t-e),h=-(n+i)/(n-i),d,g;if(a)d=1/(s-r),g=s/(s-r);else if(o===2000)d=-2/(s-r),g=-(s+r)/(s-r);else if(o===2001)d=-1/(s-r),g=-r/(s-r);else throw Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return c[0]=l,c[4]=0,c[8]=0,c[12]=f,c[1]=0,c[5]=u,c[9]=0,c[13]=h,c[2]=0,c[6]=0,c[10]=d,c[14]=g,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){let 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){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}}var Br=new D,Un=new Ge,kv=new D(0,0,0),Bv=new D(1,1,1),zi=new D,$o=new D,pn=new D,Df=new Ge,Of=new Ht;class ni{constructor(e=0,t=0,n=0,i=ni.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){let i=e.elements,r=i[0],s=i[4],o=i[8],a=i[1],c=i[5],l=i[9],u=i[2],f=i[6],h=i[10];switch(t){case"XYZ":if(this._y=Math.asin(We(o,-1,1)),Math.abs(o)<0.9999999)this._x=Math.atan2(-l,h),this._z=Math.atan2(-s,r);else this._x=Math.atan2(f,c),this._z=0;break;case"YXZ":if(this._x=Math.asin(-We(l,-1,1)),Math.abs(l)<0.9999999)this._y=Math.atan2(o,h),this._z=Math.atan2(a,c);else this._y=Math.atan2(-u,r),this._z=0;break;case"ZXY":if(this._x=Math.asin(We(f,-1,1)),Math.abs(f)<0.9999999)this._y=Math.atan2(-u,h),this._z=Math.atan2(-s,c);else this._y=0,this._z=Math.atan2(a,r);break;case"ZYX":if(this._y=Math.asin(-We(u,-1,1)),Math.abs(u)<0.9999999)this._x=Math.atan2(f,h),this._z=Math.atan2(a,r);else this._x=0,this._z=Math.atan2(-s,c);break;case"YZX":if(this._z=Math.asin(We(a,-1,1)),Math.abs(a)<0.9999999)this._x=Math.atan2(-l,c),this._y=Math.atan2(-u,r);else this._x=0,this._y=Math.atan2(o,h);break;case"XZY":if(this._z=Math.asin(-We(s,-1,1)),Math.abs(s)<0.9999999)this._x=Math.atan2(f,c),this._y=Math.atan2(o,r);else this._x=Math.atan2(-l,h),this._y=0;break;default:Pe("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}if(this._order=t,n===!0)this._onChangeCallback();return this}setFromQuaternion(e,t,n){return Df.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Df,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return Of.setFromEuler(this),this.setFromQuaternion(Of,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){if(this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0)this._order=e[3];return 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}}ni.DEFAULT_ORDER="XYZ";class La{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}}var Gv=0,Uf=new D,Gr=new Ht,vi=new Ge,Wo=new D,Rs=new D,Hv=new D,Vv=new Ht,Ff=new D(1,0,0),zf=new D(0,1,0),kf=new D(0,0,1),Bf={type:"added"},$v={type:"removed"},Hr={type:"childadded",child:null},Wc={type:"childremoved",child:null};class ht extends $n{constructor(){super();this.isObject3D=!0,Object.defineProperty(this,"id",{value:Gv++}),this.uuid=Bn(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=ht.DEFAULT_UP.clone();let e=new D,t=new ni,n=new Ht,i=new D(1,1,1);function r(){n.setFromEuler(t,!1)}function s(){t.setFromQuaternion(n,void 0,!1)}t._onChange(r),n._onChange(s),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new Ge},normalMatrix:{value:new ke}}),this.matrix=new Ge,this.matrixWorld=new Ge,this.matrixAutoUpdate=ht.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=ht.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new La,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.static=!1,this.userData={},this.pivot=null}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){if(this.matrixAutoUpdate)this.updateMatrix();this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return Gr.setFromAxisAngle(e,t),this.quaternion.multiply(Gr),this}rotateOnWorldAxis(e,t){return Gr.setFromAxisAngle(e,t),this.quaternion.premultiply(Gr),this}rotateX(e){return this.rotateOnAxis(Ff,e)}rotateY(e){return this.rotateOnAxis(zf,e)}rotateZ(e){return this.rotateOnAxis(kf,e)}translateOnAxis(e,t){return Uf.copy(e).applyQuaternion(this.quaternion),this.position.add(Uf.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(Ff,e)}translateY(e){return this.translateOnAxis(zf,e)}translateZ(e){return this.translateOnAxis(kf,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(vi.copy(this.matrixWorld).invert())}lookAt(e,t,n){if(e.isVector3)Wo.copy(e);else Wo.set(e,t,n);let i=this.parent;if(this.updateWorldMatrix(!0,!1),Rs.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight)vi.lookAt(Rs,Wo,this.up);else vi.lookAt(Wo,Rs,this.up);if(this.quaternion.setFromRotationMatrix(vi),i)vi.extractRotation(i.matrixWorld),Gr.setFromRotationMatrix(vi),this.quaternion.premultiply(Gr.invert())}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}if(e===this)return Fe("Object3D.add: object can't be added as a child of itself.",e),this;if(e&&e.isObject3D)e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(Bf),Hr.child=e,this.dispatchEvent(Hr),Hr.child=null;else Fe("Object3D.add: object not an instance of THREE.Object3D.",e);return this}remove(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}let t=this.children.indexOf(e);if(t!==-1)e.parent=null,this.children.splice(t,1),e.dispatchEvent($v),Wc.child=e,this.dispatchEvent(Wc),Wc.child=null;return this}removeFromParent(){let e=this.parent;if(e!==null)e.remove(this);return this}clear(){return this.remove(...this.children)}attach(e){if(this.updateWorldMatrix(!0,!1),vi.copy(this.matrixWorld).invert(),e.parent!==null)e.parent.updateWorldMatrix(!0,!1),vi.multiply(e.parent.matrixWorld);return e.applyMatrix4(vi),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(Bf),Hr.child=e,this.dispatchEvent(Hr),Hr.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let n=0,i=this.children.length;n<i;n++){let s=this.children[n].getObjectByProperty(e,t);if(s!==void 0)return s}return}getObjectsByProperty(e,t,n=[]){if(this[e]===t)n.push(this);let i=this.children;for(let r=0,s=i.length;r<s;r++)i[r].getObjectsByProperty(e,t,n);return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Rs,e,Hv),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Rs,Vv,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);let t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}intersectsFrustum(){}traverse(e){e(this);let t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);let t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].traverseVisible(e)}traverseAncestors(e){let t=this.parent;if(t!==null)e(t),t.traverseAncestors(e)}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);let e=this.pivot;if(e!==null){let{x:t,y:n,z:i}=e,r=this.matrix.elements;r[12]+=t-r[0]*t-r[4]*n-r[8]*i,r[13]+=n-r[1]*t-r[5]*n-r[9]*i,r[14]+=i-r[2]*t-r[6]*n-r[10]*i}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){if(this.matrixAutoUpdate)this.updateMatrix();if(this.matrixWorldNeedsUpdate||e){if(this.matrixWorldAutoUpdate===!0)if(this.parent===null)this.matrixWorld.copy(this.matrix);else this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix);this.matrixWorldNeedsUpdate=!1,e=!0}let t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].updateMatrixWorld(e)}updateWorldMatrix(e,t,n=!1){let i=this.parent;if(e===!0&&i!==null)i.updateWorldMatrix(!0,!1);if(this.matrixAutoUpdate)this.updateMatrix();if(this.matrixWorldNeedsUpdate||n){if(this.matrixWorldAutoUpdate===!0)if(this.parent===null)this.matrixWorld.copy(this.matrix);else this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix);this.matrixWorldNeedsUpdate=!1,n=!0}if(t===!0){let r=this.children;for(let s=0,o=r.length;s<o;s++)r[s].updateWorldMatrix(!1,!0,n)}}toJSON(e){let t=e===void 0||typeof e==="string",n={};if(t)e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"};let i={};if(i.uuid=this.uuid,i.type=this.type,i.name=this.name,i.castShadow=this.castShadow,i.receiveShadow=this.receiveShadow,i.visible=this.visible,i.frustumCulled=this.frustumCulled,i.renderOrder=this.renderOrder,i.static=this.static,i.matrixAutoUpdate=this.matrixAutoUpdate,Object.keys(this.userData).length>0)i.userData=this.userData;if(i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.pivot!==null)i.pivot=this.pivot.toArray();if(this.morphTargetDictionary!==void 0)i.morphTargetDictionary=Object.assign({},this.morphTargetDictionary);if(this.morphTargetInfluences!==void 0)i.morphTargetInfluences=this.morphTargetInfluences.slice();if(this.isInstancedMesh){if(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null)i.instanceColor=this.instanceColor.toJSON()}if(this.isBatchedMesh){if(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.geometryInfo=this._geometryInfo.map((o)=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),i.instanceInfo=this._instanceInfo.map((o)=>({...o})),i.availableInstanceIds=this._availableInstanceIds.slice(),i.availableGeometryIds=this._availableGeometryIds.slice(),i.nextIndexStart=this._nextIndexStart,i.nextVertexStart=this._nextVertexStart,i.geometryCount=this._geometryCount,i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.matricesTexture=this._matricesTexture.toJSON(e),i.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null)i.colorsTexture=this._colorsTexture.toJSON(e);if(this.boundingSphere!==null)i.boundingSphere=this.boundingSphere.toJSON();if(this.boundingBox!==null)i.boundingBox=this.boundingBox.toJSON()}function r(o,a){if(o[a.uuid]===void 0)o[a.uuid]=a.toJSON(e);return a.uuid}if(this.isScene){if(this.background){if(this.background.isColor)i.background=this.background.toJSON();else if(this.background.isTexture)i.background=this.background.toJSON(e).uuid}if(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=r(e.geometries,this.geometry);let o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){let a=o.shapes;if(Array.isArray(a))for(let c=0,l=a.length;c<l;c++){let u=a[c];r(e.shapes,u)}else r(e.shapes,a)}}if(this.isSkinnedMesh){if(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0)r(e.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid}if(this.material!==void 0)if(Array.isArray(this.material)){let o=[];for(let a=0,c=this.material.length;a<c;a++)o.push(r(e.materials,this.material[a]));i.material=o}else i.material=r(e.materials,this.material);if(this.children.length>0){i.children=[];for(let o=0;o<this.children.length;o++)i.children.push(this.children[o].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let o=0;o<this.animations.length;o++){let a=this.animations[o];i.animations.push(r(e.animations,a))}}if(t){let o=s(e.geometries),a=s(e.materials),c=s(e.textures),l=s(e.images),u=s(e.shapes),f=s(e.skeletons),h=s(e.animations),d=s(e.nodes);if(o.length>0)n.geometries=o;if(a.length>0)n.materials=a;if(c.length>0)n.textures=c;if(l.length>0)n.images=l;if(u.length>0)n.shapes=u;if(f.length>0)n.skeletons=f;if(h.length>0)n.animations=h;if(d.length>0)n.nodes=d}return n.object=i,n;function s(o){let a=[];for(let c in o){let l=o[c];delete l.metadata,a.push(l)}return a}}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.pivot=e.pivot!==null?e.pivot.clone():null,this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;n<e.children.length;n++){let i=e.children[n];this.add(i.clone())}return this}dispose(){this.dispatchEvent({type:"dispose"})}}ht.DEFAULT_UP=new D(0,1,0);ht.DEFAULT_MATRIX_AUTO_UPDATE=!0;ht.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;class ei extends ht{constructor(){super();this.isGroup=!0,this.type="Group"}}var Wv={type:"move"};class Xs{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){if(this._hand===null)this._hand=new ei,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1};return this._hand}getTargetRaySpace(){if(this._targetRay===null)this._targetRay=new ei,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new D,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new D;return this._targetRay}getGripSpace(){if(this._grip===null)this._grip=new ei,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new D,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new D,this._grip.eventsEnabled=!1;return this._grip}dispatchEvent(e){if(this._targetRay!==null)this._targetRay.dispatchEvent(e);if(this._grip!==null)this._grip.dispatchEvent(e);if(this._hand!==null)this._hand.dispatchEvent(e);return this}connect(e){if(e&&e.hand){let t=this._hand;if(t)for(let n of e.hand.values())this._getHandJoint(t,n)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){if(this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null)this._targetRay.visible=!1;if(this._grip!==null)this._grip.visible=!1;if(this._hand!==null)this._hand.visible=!1;return this}update(e,t,n){let i=null,r=null,s=null,o=this._targetRay,a=this._grip,c=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(c&&e.hand){s=!0;for(let g of e.hand.values()){let x=t.getJointPose(g,n),p=this._getHandJoint(c,g);if(x!==null)p.matrix.fromArray(x.transform.matrix),p.matrix.decompose(p.position,p.rotation,p.scale),p.matrixWorldNeedsUpdate=!0,p.jointRadius=x.radius;p.visible=x!==null}let l=c.joints["index-finger-tip"],u=c.joints["thumb-tip"],f=l.position.distanceTo(u.position),h=0.02,d=0.005;if(c.inputState.pinching&&f>h+d)c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this});else if(!c.inputState.pinching&&f<=h-d)c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this})}else if(a!==null&&e.gripSpace){if(r=t.getPose(e.gripSpace,n),r!==null){if(a.matrix.fromArray(r.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,r.linearVelocity)a.hasLinearVelocity=!0,a.linearVelocity.copy(r.linearVelocity);else a.hasLinearVelocity=!1;if(r.angularVelocity)a.hasAngularVelocity=!0,a.angularVelocity.copy(r.angularVelocity);else a.hasAngularVelocity=!1;if(a.eventsEnabled)a.dispatchEvent({type:"gripUpdated",data:e,target:this})}}if(o!==null){if(i=t.getPose(e.targetRaySpace,n),i===null&&r!==null)i=r;if(i!==null){if(o.matrix.fromArray(i.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,i.linearVelocity)o.hasLinearVelocity=!0,o.linearVelocity.copy(i.linearVelocity);else o.hasLinearVelocity=!1;if(i.angularVelocity)o.hasAngularVelocity=!0,o.angularVelocity.copy(i.angularVelocity);else o.hasAngularVelocity=!1;this.dispatchEvent(Wv)}}}if(o!==null)o.visible=i!==null;if(a!==null)a.visible=r!==null;if(c!==null)c.visible=s!==null;return this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){let n=new ei;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}var up={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},ki={h:0,s:0,l:0},Zo={h:0,s:0,l:0};function Zc(e,t,n){if(n<0)n+=1;if(n>1)n-=1;if(n<0.16666666666666666)return e+(t-e)*6*n;if(n<0.5)return t;if(n<0.6666666666666666)return e+(t-e)*6*(0.6666666666666666-n);return e}class Ue{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){let i=e;if(i&&i.isColor)this.copy(i);else if(typeof i==="number")this.setHex(i);else if(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="srgb"){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,$e.colorSpaceToWorking(this,t),this}setRGB(e,t,n,i=$e.workingColorSpace){return this.r=e,this.g=t,this.b=n,$e.colorSpaceToWorking(this,i),this}setHSL(e,t,n,i=$e.workingColorSpace){if(e=hu(e,1),t=We(t,0,1),n=We(n,0,1),t===0)this.r=this.g=this.b=n;else{let r=n<=0.5?n*(1+t):n+t-n*t,s=2*n-r;this.r=Zc(s,r,e+0.3333333333333333),this.g=Zc(s,r,e),this.b=Zc(s,r,e-0.3333333333333333)}return $e.colorSpaceToWorking(this,i),this}setStyle(e,t="srgb"){function n(r){if(r===void 0)return;if(parseFloat(r)<1)Pe("Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let r,s=i[1],o=i[2];switch(s){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,t);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,t);break;default:Pe("Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){let r=i[1],s=r.length;if(s===3)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,t);else if(s===6)return this.setHex(parseInt(r,16),t);else Pe("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t="srgb"){let n=up[e.toLowerCase()];if(n!==void 0)this.setHex(n,t);else Pe("Color: Unknown color "+e);return 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=Ti(e.r),this.g=Ti(e.g),this.b=Ti(e.b),this}copyLinearToSRGB(e){return this.r=Qr(e.r),this.g=Qr(e.g),this.b=Qr(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e="srgb"){return $e.workingToColorSpace(Jt.copy(this),e),Math.round(We(Jt.r*255,0,255))*65536+Math.round(We(Jt.g*255,0,255))*256+Math.round(We(Jt.b*255,0,255))}getHexString(e="srgb"){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=$e.workingColorSpace){$e.workingToColorSpace(Jt.copy(this),t);let{r:n,g:i,b:r}=Jt,s=Math.max(n,i,r),o=Math.min(n,i,r),a,c,l=(o+s)/2;if(o===s)a=0,c=0;else{let u=s-o;switch(c=l<=0.5?u/(s+o):u/(2-s-o),s){case n:a=(i-r)/u+(i<r?6:0);break;case i:a=(r-n)/u+2;break;case r:a=(n-i)/u+4;break}a/=6}return e.h=a,e.s=c,e.l=l,e}getRGB(e,t=$e.workingColorSpace){return $e.workingToColorSpace(Jt.copy(this),t),e.r=Jt.r,e.g=Jt.g,e.b=Jt.b,e}getStyle(e="srgb"){$e.workingToColorSpace(Jt.copy(this),e);let{r:t,g:n,b:i}=Jt;if(e!=="srgb")return`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${i.toFixed(3)})`;return`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(i*255)})`}offsetHSL(e,t,n){return this.getHSL(ki),this.setHSL(ki.h+e,ki.s+t,ki.l+n)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(ki),e.getHSL(Zo);let n=Fs(ki.h,Zo.h,t),i=Fs(ki.s,Zo.s,t),r=Fs(ki.l,Zo.l,t);return this.setHSL(n,i,r),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){let t=this.r,n=this.g,i=this.b,r=e.elements;return this.r=r[0]*t+r[3]*n+r[6]*i,this.g=r[1]*t+r[4]*n+r[7]*i,this.b=r[2]*t+r[5]*n+r[8]*i,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}var Jt=new Ue;Ue.NAMES=up;class hs extends ht{constructor(){super();if(this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new ni,this.environmentIntensity=1,this.environmentRotation=new ni,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){if(super.copy(e,t),e.background!==null)this.background=e.background.clone();if(e.environment!==null)this.environment=e.environment.clone();if(e.fog!==null)this.fog=e.fog.clone();if(this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null)this.overrideMaterial=e.overrideMaterial.clone();return this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){let t=super.toJSON(e);if(this.fog!==null)t.object.fog=this.fog.toJSON();return t.object.backgroundBlurriness=this.backgroundBlurriness,t.object.backgroundIntensity=this.backgroundIntensity,t.object.backgroundRotation=this.backgroundRotation.toArray(),t.object.environmentIntensity=this.environmentIntensity,t.object.environmentRotation=this.environmentRotation.toArray(),t}}var Fn=new D,bi=new D,Xc=new D,Si=new D,Vr=new D,$r=new D,Gf=new D,qc=new D,jc=new D,Yc=new D,Kc=new ct,Jc=new ct,Qc=new ct;class Rn{constructor(e=new D,t=new D,n=new D){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,i){i.subVectors(n,t),Fn.subVectors(e,t),i.cross(Fn);let r=i.lengthSq();if(r>0)return i.multiplyScalar(1/Math.sqrt(r));return i.set(0,0,0)}static getBarycoord(e,t,n,i,r){Fn.subVectors(i,t),bi.subVectors(n,t),Xc.subVectors(e,t);let s=Fn.dot(Fn),o=Fn.dot(bi),a=Fn.dot(Xc),c=bi.dot(bi),l=bi.dot(Xc),u=s*c-o*o;if(u===0)return r.set(0,0,0),null;let f=1/u,h=(c*a-o*l)*f,d=(s*l-o*a)*f;return r.set(1-h-d,d,h)}static containsPoint(e,t,n,i){if(this.getBarycoord(e,t,n,i,Si)===null)return!1;return Si.x>=0&&Si.y>=0&&Si.x+Si.y<=1}static getInterpolation(e,t,n,i,r,s,o,a){if(this.getBarycoord(e,t,n,i,Si)===null){if(a.x=0,a.y=0,"z"in a)a.z=0;if("w"in a)a.w=0;return null}return a.setScalar(0),a.addScaledVector(r,Si.x),a.addScaledVector(s,Si.y),a.addScaledVector(o,Si.z),a}static getInterpolatedAttribute(e,t,n,i,r,s){return Kc.setScalar(0),Jc.setScalar(0),Qc.setScalar(0),Kc.fromBufferAttribute(e,t),Jc.fromBufferAttribute(e,n),Qc.fromBufferAttribute(e,i),s.setScalar(0),s.addScaledVector(Kc,r.x),s.addScaledVector(Jc,r.y),s.addScaledVector(Qc,r.z),s}static isFrontFacing(e,t,n,i){return Fn.subVectors(n,t),bi.subVectors(e,t),Fn.cross(bi).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 Fn.subVectors(this.c,this.b),bi.subVectors(this.a,this.b),Fn.cross(bi).length()*0.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(0.3333333333333333)}getNormal(e){return Rn.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return Rn.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,i,r){return Rn.getInterpolation(e,this.a,this.b,this.c,t,n,i,r)}containsPoint(e){return Rn.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Rn.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let n=this.a,i=this.b,r=this.c,s,o;Vr.subVectors(i,n),$r.subVectors(r,n),qc.subVectors(e,n);let a=Vr.dot(qc),c=$r.dot(qc);if(a<=0&&c<=0)return t.copy(n);jc.subVectors(e,i);let l=Vr.dot(jc),u=$r.dot(jc);if(l>=0&&u<=l)return t.copy(i);let f=a*u-l*c;if(f<=0&&a>=0&&l<=0)return s=a/(a-l),t.copy(n).addScaledVector(Vr,s);Yc.subVectors(e,r);let h=Vr.dot(Yc),d=$r.dot(Yc);if(d>=0&&h<=d)return t.copy(r);let g=h*c-a*d;if(g<=0&&c>=0&&d<=0)return o=c/(c-d),t.copy(n).addScaledVector($r,o);let x=l*d-h*u;if(x<=0&&u-l>=0&&h-d>=0)return Gf.subVectors(r,i),o=(u-l)/(u-l+(h-d)),t.copy(i).addScaledVector(Gf,o);let p=1/(x+g+f);return s=g*p,o=f*p,t.copy(n).addScaledVector(Vr,s).addScaledVector($r,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}class Ft{constructor(e=new D(1/0,1/0,1/0),t=new D(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t+=3)this.expandByPoint(zn.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(zn.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let n=zn.copy(t).multiplyScalar(0.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(0.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);let n=e.geometry;if(n!==void 0){let r=n.getAttribute("position");if(t===!0&&r!==void 0&&e.isInstancedMesh!==!0)for(let s=0,o=r.count;s<o;s++){if(e.isMesh===!0)e.getVertexPosition(s,zn);else zn.fromBufferAttribute(r,s);zn.applyMatrix4(e.matrixWorld),this.expandByPoint(zn)}else{if(e.boundingBox!==void 0){if(e.boundingBox===null)e.computeBoundingBox();Xo.copy(e.boundingBox)}else{if(n.boundingBox===null)n.computeBoundingBox();Xo.copy(n.boundingBox)}Xo.applyMatrix4(e.matrixWorld),this.union(Xo)}}let i=e.children;for(let r=0,s=i.length;r<s;r++)this.expandByObject(i[r],t);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,zn),zn.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;if(e.normal.x>0)t=e.normal.x*this.min.x,n=e.normal.x*this.max.x;else t=e.normal.x*this.max.x,n=e.normal.x*this.min.x;if(e.normal.y>0)t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y;else t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y;if(e.normal.z>0)t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z;else t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z;return t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Cs),qo.subVectors(this.max,Cs),Wr.subVectors(e.a,Cs),Zr.subVectors(e.b,Cs),Xr.subVectors(e.c,Cs),Bi.subVectors(Zr,Wr),Gi.subVectors(Xr,Zr),dr.subVectors(Wr,Xr);let t=[0,-Bi.z,Bi.y,0,-Gi.z,Gi.y,0,-dr.z,dr.y,Bi.z,0,-Bi.x,Gi.z,0,-Gi.x,dr.z,0,-dr.x,-Bi.y,Bi.x,0,-Gi.y,Gi.x,0,-dr.y,dr.x,0];if(!el(t,Wr,Zr,Xr,qo))return!1;if(t=[1,0,0,0,1,0,0,0,1],!el(t,Wr,Zr,Xr,qo))return!1;return jo.crossVectors(Bi,Gi),t=[jo.x,jo.y,jo.z],el(t,Wr,Zr,Xr,qo)}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,zn).distanceTo(e)}getBoundingSphere(e){if(this.isEmpty())e.makeEmpty();else this.getCenter(e.center),e.radius=this.getSize(zn).length()*0.5;return e}intersect(e){if(this.min.max(e.min),this.max.min(e.max),this.isEmpty())this.makeEmpty();return this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){if(this.isEmpty())return this;return Mi[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Mi[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Mi[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Mi[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Mi[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Mi[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Mi[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Mi[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Mi),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)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}}var Mi=[new D,new D,new D,new D,new D,new D,new D,new D],zn=new D,Xo=new Ft,Wr=new D,Zr=new D,Xr=new D,Bi=new D,Gi=new D,dr=new D,Cs=new D,qo=new D,jo=new D,pr=new D;function el(e,t,n,i,r){for(let s=0,o=e.length-3;s<=o;s+=3){pr.fromArray(e,s);let a=r.x*Math.abs(pr.x)+r.y*Math.abs(pr.y)+r.z*Math.abs(pr.z),c=t.dot(pr),l=n.dot(pr),u=i.dot(pr);if(Math.max(-Math.max(c,l,u),Math.min(c,l,u))>a)return!1}return!0}var Nt=new D,Yo=new Ne,Zv=0;class Vt extends $n{constructor(e,t,n=!1){super();if(Array.isArray(e))throw TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:Zv++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=35044,this.updateRanges=[],this.gpuType=1015,this.version=0}onUploadCallback(){}set needsUpdate(e){if(e===!0)this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let i=0,r=this.itemSize;i<r;i++)this.array[e+i]=t.array[n+i];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,n=this.count;t<n;t++)Yo.fromBufferAttribute(this,t),Yo.applyMatrix3(e),this.setXY(t,Yo.x,Yo.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)Nt.fromBufferAttribute(this,t),Nt.applyMatrix3(e),this.setXYZ(t,Nt.x,Nt.y,Nt.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)Nt.fromBufferAttribute(this,t),Nt.applyMatrix4(e),this.setXYZ(t,Nt.x,Nt.y,Nt.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)Nt.fromBufferAttribute(this,t),Nt.applyNormalMatrix(e),this.setXYZ(t,Nt.x,Nt.y,Nt.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)Nt.fromBufferAttribute(this,t),Nt.transformDirection(e),this.setXYZ(t,Nt.x,Nt.y,Nt.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let n=this.array[e*this.itemSize+t];if(this.normalized)n=kn(n,this.array);return n}setComponent(e,t,n){if(this.normalized)n=at(n,this.array);return this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];if(this.normalized)t=kn(t,this.array);return t}setX(e,t){if(this.normalized)t=at(t,this.array);return this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];if(this.normalized)t=kn(t,this.array);return t}setY(e,t){if(this.normalized)t=at(t,this.array);return this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];if(this.normalized)t=kn(t,this.array);return t}setZ(e,t){if(this.normalized)t=at(t,this.array);return this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];if(this.normalized)t=kn(t,this.array);return t}setW(e,t){if(this.normalized)t=at(t,this.array);return this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){if(e*=this.itemSize,this.normalized)t=at(t,this.array),n=at(n,this.array);return this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,i){if(e*=this.itemSize,this.normalized)t=at(t,this.array),n=at(n,this.array),i=at(i,this.array);return this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this}setXYZW(e,t,n,i,r){if(e*=this.itemSize,this.normalized)t=at(t,this.array),n=at(n,this.array),i=at(i,this.array),r=at(r,this.array);return this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this.array[e+3]=r,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){let e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return e.name=this.name,e.usage=this.usage,e.gpuType=this.gpuType,e}dispose(){this.dispatchEvent({type:"dispose"})}}class Na extends Vt{constructor(e,t,n){super(new Uint16Array(e),t,n)}}class Da extends Vt{constructor(e,t,n){super(new Uint32Array(e),t,n)}}class un extends Vt{constructor(e,t,n){super(new Float32Array(e),t,n)}}var Xv=new Ft,Ps=new D,tl=new D;class xn{constructor(e=new D,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){let n=this.center;if(t!==void 0)n.copy(t);else Xv.setFromPoints(e).getCenter(n);let i=0;for(let r=0,s=e.length;r<s;r++)i=Math.max(i,n.distanceToSquared(e[r]));return this.radius=Math.sqrt(i),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){let t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){let n=this.center.distanceToSquared(e);if(t.copy(e),n>this.radius*this.radius)t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center);return t}getBoundingBox(e){if(this.isEmpty())return e.makeEmpty(),e;return 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;Ps.subVectors(e,this.center);let t=Ps.lengthSq();if(t>this.radius*this.radius){let n=Math.sqrt(t),i=(n-this.radius)*0.5;this.center.addScaledVector(Ps,i/n),this.radius+=i}return this}union(e){if(e.isEmpty())return this;if(this.isEmpty())return this.copy(e),this;if(this.center.equals(e.center)===!0)this.radius=Math.max(this.radius,e.radius);else tl.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Ps.copy(e.center).add(tl)),this.expandByPoint(Ps.copy(e.center).sub(tl));return this}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}}var qv=0,Tn=new Ge,nl=new ht,qr=new D,mn=new Ft,Is=new Ft,Gt=new D;class en extends $n{constructor(){super();this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:qv++}),this.uuid=Bn(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={},this._transformed=!1}getIndex(){return this.index}setIndex(e){if(Array.isArray(e))this.index=new((xv(e))?Da:Na)(e,1);else this.index=e;return this}setIndirect(e,t=0){return this.indirect=e,this.indirectOffset=t,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){let t=this.attributes.position;if(t!==void 0)t.applyMatrix4(e),t.needsUpdate=!0;let n=this.attributes.normal;if(n!==void 0){let r=new ke().getNormalMatrix(e);n.applyNormalMatrix(r),n.needsUpdate=!0}let i=this.attributes.tangent;if(i!==void 0)i.transformDirection(e),i.needsUpdate=!0;if(this.boundingBox!==null)this.computeBoundingBox();if(this.boundingSphere!==null)this.computeBoundingSphere();return this._transformed=!0,this}applyQuaternion(e){return Tn.makeRotationFromQuaternion(e),this.applyMatrix4(Tn),this}rotateX(e){return Tn.makeRotationX(e),this.applyMatrix4(Tn),this}rotateY(e){return Tn.makeRotationY(e),this.applyMatrix4(Tn),this}rotateZ(e){return Tn.makeRotationZ(e),this.applyMatrix4(Tn),this}translate(e,t,n){return Tn.makeTranslation(e,t,n),this.applyMatrix4(Tn),this}scale(e,t,n){return Tn.makeScale(e,t,n),this.applyMatrix4(Tn),this}lookAt(e){return nl.lookAt(e),nl.updateMatrix(),this.applyMatrix4(nl.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(qr).negate(),this.translate(qr.x,qr.y,qr.z),this}setFromPoints(e){let t=this.getAttribute("position");if(t===void 0){let n=[];for(let i=0,r=e.length;i<r;i++){let s=e[i];n.push(s.x,s.y,s.z||0)}this.setAttribute("position",new un(n,3))}else{let n=Math.min(e.length,t.count);for(let i=0;i<n;i++){let r=e[i];t.setXYZ(i,r.x,r.y,r.z||0)}if(e.length>t.count)Pe("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry.");t.needsUpdate=!0}return this}computeBoundingBox(){if(this.boundingBox===null)this.boundingBox=new Ft;let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Fe("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new D(-1/0,-1/0,-1/0),new D(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,i=t.length;n<i;n++){let r=t[n];if(mn.setFromBufferAttribute(r),this.morphTargetsRelative)Gt.addVectors(this.boundingBox.min,mn.min),this.boundingBox.expandByPoint(Gt),Gt.addVectors(this.boundingBox.max,mn.max),this.boundingBox.expandByPoint(Gt);else this.boundingBox.expandByPoint(mn.min),this.boundingBox.expandByPoint(mn.max)}}else this.boundingBox.makeEmpty();if(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))Fe('BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){if(this.boundingSphere===null)this.boundingSphere=new xn;let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Fe("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new D,1/0);return}if(e){let n=this.boundingSphere.center;if(mn.setFromBufferAttribute(e),t)for(let r=0,s=t.length;r<s;r++){let o=t[r];if(Is.setFromBufferAttribute(o),this.morphTargetsRelative)Gt.addVectors(mn.min,Is.min),mn.expandByPoint(Gt),Gt.addVectors(mn.max,Is.max),mn.expandByPoint(Gt);else mn.expandByPoint(Is.min),mn.expandByPoint(Is.max)}mn.getCenter(n);let i=0;for(let r=0,s=e.count;r<s;r++)Gt.fromBufferAttribute(e,r),i=Math.max(i,n.distanceToSquared(Gt));if(t)for(let r=0,s=t.length;r<s;r++){let o=t[r],a=this.morphTargetsRelative;for(let c=0,l=o.count;c<l;c++){if(Gt.fromBufferAttribute(o,c),a)qr.fromBufferAttribute(e,c),Gt.add(qr);i=Math.max(i,n.distanceToSquared(Gt))}}if(this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius))Fe('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){let e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){Fe("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}let{position:n,normal:i,uv:r}=t,s=this.getAttribute("tangent");if(s===void 0||s.count!==n.count)s=new Vt(new Float32Array(4*n.count),4),this.setAttribute("tangent",s);let o=[],a=[];for(let A=0;A<n.count;A++)o[A]=new D,a[A]=new D;let c=new D,l=new D,u=new D,f=new Ne,h=new Ne,d=new Ne,g=new D,x=new D;function p(A,_,S){c.fromBufferAttribute(n,A),l.fromBufferAttribute(n,_),u.fromBufferAttribute(n,S),f.fromBufferAttribute(r,A),h.fromBufferAttribute(r,_),d.fromBufferAttribute(r,S),l.sub(c),u.sub(c),h.sub(f),d.sub(f);let k=1/(h.x*d.y-d.x*h.y);if(!isFinite(k))return;g.copy(l).multiplyScalar(d.y).addScaledVector(u,-h.y).multiplyScalar(k),x.copy(u).multiplyScalar(h.x).addScaledVector(l,-d.x).multiplyScalar(k),o[A].add(g),o[_].add(g),o[S].add(g),a[A].add(x),a[_].add(x),a[S].add(x)}let m=this.groups;if(m.length===0)m=[{start:0,count:e.count}];for(let A=0,_=m.length;A<_;++A){let S=m[A],{start:k,count:C}=S;for(let U=k,ee=k+C;U<ee;U+=3)p(e.getX(U+0),e.getX(U+1),e.getX(U+2))}let E=new D,R=new D,v=new D,M=new D;function T(A){v.fromBufferAttribute(i,A),M.copy(v);let _=o[A];E.copy(_),E.sub(v.multiplyScalar(v.dot(_))).normalize(),R.crossVectors(M,_);let k=R.dot(a[A])<0?-1:1;s.setXYZW(A,E.x,E.y,E.z,k)}for(let A=0,_=m.length;A<_;++A){let S=m[A],{start:k,count:C}=S;for(let U=k,ee=k+C;U<ee;U+=3)T(e.getX(U+0)),T(e.getX(U+1)),T(e.getX(U+2))}this._transformed=!0}computeVertexNormals(){let e=this.index,t=this.getAttribute("position");if(t!==void 0){let n=this.getAttribute("normal");if(n===void 0||n.count!==t.count)n=new Vt(new Float32Array(t.count*3),3),this.setAttribute("normal",n);else for(let f=0,h=n.count;f<h;f++)n.setXYZ(f,0,0,0);let i=new D,r=new D,s=new D,o=new D,a=new D,c=new D,l=new D,u=new D;if(e)for(let f=0,h=e.count;f<h;f+=3){let d=e.getX(f+0),g=e.getX(f+1),x=e.getX(f+2);i.fromBufferAttribute(t,d),r.fromBufferAttribute(t,g),s.fromBufferAttribute(t,x),l.subVectors(s,r),u.subVectors(i,r),l.cross(u),o.fromBufferAttribute(n,d),a.fromBufferAttribute(n,g),c.fromBufferAttribute(n,x),o.add(l),a.add(l),c.add(l),n.setXYZ(d,o.x,o.y,o.z),n.setXYZ(g,a.x,a.y,a.z),n.setXYZ(x,c.x,c.y,c.z)}else for(let f=0,h=t.count;f<h;f+=3)i.fromBufferAttribute(t,f+0),r.fromBufferAttribute(t,f+1),s.fromBufferAttribute(t,f+2),l.subVectors(s,r),u.subVectors(i,r),l.cross(u),n.setXYZ(f+0,l.x,l.y,l.z),n.setXYZ(f+1,l.x,l.y,l.z),n.setXYZ(f+2,l.x,l.y,l.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){let e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)Gt.fromBufferAttribute(e,t),Gt.normalize(),e.setXYZ(t,Gt.x,Gt.y,Gt.z)}toNonIndexed(){function e(o,a){let{array:c,itemSize:l,normalized:u}=o,f=new c.constructor(a.length*l),h=0,d=0;for(let g=0,x=a.length;g<x;g++){if(o.isInterleavedBufferAttribute)h=a[g]*o.data.stride+o.offset;else h=a[g]*l;for(let p=0;p<l;p++)f[d++]=c[h++]}return new Vt(f,l,u)}if(this.index===null)return Pe("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;let t=new en,n=this.index.array,i=this.attributes;for(let o in i){let a=i[o],c=e(a,n);t.setAttribute(o,c)}let r=this.morphAttributes;for(let o in r){let a=[],c=r[o];for(let l=0,u=c.length;l<u;l++){let f=c[l],h=e(f,n);a.push(h)}t.morphAttributes[o]=a}t.morphTargetsRelative=this.morphTargetsRelative;let s=this.groups;for(let o=0,a=s.length;o<a;o++){let c=s[o];t.addGroup(c.start,c.count,c.materialIndex)}return t}toJSON(){let e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.parameters!==void 0&&this._transformed===!0?"BufferGeometry":this.type,e.name=this.name,Object.keys(this.userData).length>0)e.userData=this.userData;if(this.parameters!==void 0&&this._transformed!==!0){let a=this.parameters;for(let c in a)if(a[c]!==void 0)e[c]=a[c];return e}e.data={attributes:{}};let t=this.index;if(t!==null)e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)};let n=this.attributes;for(let a in n){let c=n[a];e.data.attributes[a]=c.toJSON(e.data)}let i={},r=!1;for(let a in this.morphAttributes){let c=this.morphAttributes[a],l=[];for(let u=0,f=c.length;u<f;u++){let h=c[u];l.push(h.toJSON(e.data))}if(l.length>0)i[a]=l,r=!0}if(r)e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative;let s=this.groups;if(s.length>0)e.data.groups=JSON.parse(JSON.stringify(s));let o=this.boundingSphere;if(o!==null)e.data.boundingSphere=o.toJSON();return 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;let t={};this.name=e.name;let n=e.index;if(n!==null)this.setIndex(n.clone());let i=e.attributes;for(let c in i){let l=i[c];this.setAttribute(c,l.clone(t))}let r=e.morphAttributes;for(let c in r){let l=[],u=r[c];for(let f=0,h=u.length;f<h;f++)l.push(u[f].clone(t));this.morphAttributes[c]=l}this.morphTargetsRelative=e.morphTargetsRelative;let s=e.groups;for(let c=0,l=s.length;c<l;c++){let u=s[c];this.addGroup(u.start,u.count,u.materialIndex)}let o=e.boundingBox;if(o!==null)this.boundingBox=o.clone();let a=e.boundingSphere;if(a!==null)this.boundingSphere=a.clone();return this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this._transformed=e._transformed,this}dispose(){this.dispatchEvent({type:"dispose"})}}class qs{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=35044,this.updateRanges=[],this.version=0,this.uuid=Bn()}onUploadCallback(){}set needsUpdate(e){if(e===!0)this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let i=0,r=this.stride;i<r;i++)this.array[e+i]=t.array[n+i];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){if(e.arrayBuffers===void 0)e.arrayBuffers={};if(this.array.buffer._uuid===void 0)this.array.buffer._uuid=Bn();if(e.arrayBuffers[this.array.buffer._uuid]===void 0)e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer;let t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(t,this.stride);return n.setUsage(this.usage),n}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){if(e.arrayBuffers===void 0)e.arrayBuffers={};if(this.array.buffer._uuid===void 0)this.array.buffer._uuid=Bn();if(e.arrayBuffers[this.array.buffer._uuid]===void 0)e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer));let t={uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride};return t.usage=this.usage,t}}var sn=new D;class fs{constructor(e,t,n,i=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=n,this.normalized=i}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,n=this.data.count;t<n;t++)sn.fromBufferAttribute(this,t),sn.applyMatrix4(e),this.setXYZ(t,sn.x,sn.y,sn.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)sn.fromBufferAttribute(this,t),sn.applyNormalMatrix(e),this.setXYZ(t,sn.x,sn.y,sn.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)sn.fromBufferAttribute(this,t),sn.transformDirection(e),this.setXYZ(t,sn.x,sn.y,sn.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];if(this.normalized)n=kn(n,this.array);return n}setComponent(e,t,n){if(this.normalized)n=at(n,this.array);return this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){if(this.normalized)t=at(t,this.array);return this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){if(this.normalized)t=at(t,this.array);return this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){if(this.normalized)t=at(t,this.array);return this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){if(this.normalized)t=at(t,this.array);return this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];if(this.normalized)t=kn(t,this.array);return t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];if(this.normalized)t=kn(t,this.array);return t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];if(this.normalized)t=kn(t,this.array);return t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];if(this.normalized)t=kn(t,this.array);return t}setXY(e,t,n){if(e=e*this.data.stride+this.offset,this.normalized)t=at(t,this.array),n=at(n,this.array);return this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,i){if(e=e*this.data.stride+this.offset,this.normalized)t=at(t,this.array),n=at(n,this.array),i=at(i,this.array);return this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this}setXYZW(e,t,n,i,r){if(e=e*this.data.stride+this.offset,this.normalized)t=at(t,this.array),n=at(n,this.array),i=at(i,this.array),r=at(r,this.array);return this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this.data.array[e+3]=r,this}clone(e){if(e===void 0){zs("InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");let t=[];for(let n=0;n<this.count;n++){let i=n*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)t.push(this.data.array[i+r])}return new Vt(new this.array.constructor(t),this.itemSize,this.normalized)}else{if(e.interleavedBuffers===void 0)e.interleavedBuffers={};if(e.interleavedBuffers[this.data.uuid]===void 0)e.interleavedBuffers[this.data.uuid]=this.data.clone(e);return new fs(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}}toJSON(e){if(e===void 0){zs("InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");let t=[];for(let n=0;n<this.count;n++){let i=n*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)t.push(this.data.array[i+r])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else{if(e.interleavedBuffers===void 0)e.interleavedBuffers={};if(e.interleavedBuffers[this.data.uuid]===void 0)e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e);return{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}}var il=new D,jv=new D,Yv=new ke;class An{constructor(e=new D(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){let i=il.subVectors(n,t).cross(jv.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(i,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){let 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,n=!0){let i=e.delta(il),r=this.normal.dot(i);if(r===0){if(this.distanceToPoint(e.start)===0)return t.copy(e.start);return null}let s=-(e.start.dot(this.normal)+this.constant)/r;if(n===!0&&(s<0||s>1))return null;return t.copy(e.start).addScaledVector(i,s)}intersectsLine(e){let t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){let n=t||Yv.getNormalMatrix(e),i=this.coplanarPoint(il).applyMatrix4(e),r=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(r),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}toJSON(){return{normal:this.normal.toArray(),constant:this.constant}}fromJSON(e){return this.normal.fromArray(e.normal),this.constant=e.constant,this}}var Kv=0;class hn extends $n{constructor(){super();this.isMaterial=!0,Object.defineProperty(this,"id",{value:Kv++}),this.uuid=Bn(),this.name="",this.type="Material",this.blending=1,this.side=0,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=204,this.blendDst=205,this.blendEquation=100,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Ue(0,0,0),this.blendAlpha=0,this.depthFunc=3,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=519,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=7680,this.stencilZFail=7680,this.stencilZPass=7680,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.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){if(this._alphaTest>0!==e>0)this.version++;this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e===void 0)return;for(let t in e){let n=e[t];if(n===void 0){Pe(`Material: parameter '${t}' has value of undefined.`);continue}let i=this[t];if(i===void 0){Pe(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}if(i&&i.isColor)i.set(n);else if(i&&i.isVector2&&(n&&n.isVector2)||i&&i.isEuler&&(n&&n.isEuler)||i&&i.isVector3&&(n&&n.isVector3))i.copy(n);else this[t]=n}}toJSON(e){let t=e===void 0||typeof e==="string";if(t)e={textures:{},images:{}};let n={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};if(n.uuid=this.uuid,n.type=this.type,n.blending=this.blending,n.side=this.side,n.shadowSide=this.shadowSide,n.vertexColors=this.vertexColors,n.opacity=this.opacity,n.transparent=this.transparent,n.blendSrc=this.blendSrc,n.blendDst=this.blendDst,n.blendEquation=this.blendEquation,n.blendSrcAlpha=this.blendSrcAlpha,n.blendDstAlpha=this.blendDstAlpha,n.blendEquationAlpha=this.blendEquationAlpha,n.blendColor=this.blendColor.getHex(),n.blendAlpha=this.blendAlpha,n.depthFunc=this.depthFunc,n.depthTest=this.depthTest,n.depthWrite=this.depthWrite,n.colorWrite=this.colorWrite,n.clipIntersection=this.clipIntersection,n.clipShadows=this.clipShadows,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,n.stencilWrite=this.stencilWrite,n.polygonOffset=this.polygonOffset,n.polygonOffsetFactor=this.polygonOffsetFactor,n.polygonOffsetUnits=this.polygonOffsetUnits,n.dithering=this.dithering,n.alphaTest=this.alphaTest,n.alphaHash=this.alphaHash,n.alphaToCoverage=this.alphaToCoverage,n.premultipliedAlpha=this.premultipliedAlpha,n.forceSinglePass=this.forceSinglePass,n.allowOverride=this.allowOverride,n.visible=this.visible,n.toneMapped=this.toneMapped,n.name=this.name,this.color&&this.color.isColor)n.color=this.color.getHex();if(this.roughness!==void 0)n.roughness=this.roughness;if(this.metalness!==void 0)n.metalness=this.metalness;if(this.sheen!==void 0)n.sheen=this.sheen;if(this.sheenColor&&this.sheenColor.isColor)n.sheenColor=this.sheenColor.getHex();if(this.sheenRoughness!==void 0)n.sheenRoughness=this.sheenRoughness;if(this.emissive&&this.emissive.isColor)n.emissive=this.emissive.getHex();if(this.emissiveIntensity!==void 0)n.emissiveIntensity=this.emissiveIntensity;if(this.specular&&this.specular.isColor)n.specular=this.specular.getHex();if(this.specularIntensity!==void 0)n.specularIntensity=this.specularIntensity;if(this.specularColor&&this.specularColor.isColor)n.specularColor=this.specularColor.getHex();if(this.shininess!==void 0)n.shininess=this.shininess;if(this.clearcoat!==void 0)n.clearcoat=this.clearcoat;if(this.clearcoatRoughness!==void 0)n.clearcoatRoughness=this.clearcoatRoughness;if(this.clearcoatMap&&this.clearcoatMap.isTexture)n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid;if(this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture)n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid;if(this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture)n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray();if(this.sheenColorMap&&this.sheenColorMap.isTexture)n.sheenColorMap=this.sheenColorMap.toJSON(e).uuid;if(this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture)n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid;if(this.dispersion!==void 0)n.dispersion=this.dispersion;if(this.retroreflectivity!==void 0)n.retroreflectivity=this.retroreflectivity;if(this.iridescence!==void 0)n.iridescence=this.iridescence;if(this.iridescenceIOR!==void 0)n.iridescenceIOR=this.iridescenceIOR;if(this.iridescenceThicknessRange!==void 0)n.iridescenceThicknessRange=this.iridescenceThicknessRange;if(this.iridescenceMap&&this.iridescenceMap.isTexture)n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid;if(this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture)n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid;if(this.anisotropy!==void 0)n.anisotropy=this.anisotropy;if(this.anisotropyRotation!==void 0)n.anisotropyRotation=this.anisotropyRotation;if(this.anisotropyMap&&this.anisotropyMap.isTexture)n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid;if(this.map&&this.map.isTexture)n.map=this.map.toJSON(e).uuid;if(this.matcap&&this.matcap.isTexture)n.matcap=this.matcap.toJSON(e).uuid;if(this.alphaMap&&this.alphaMap.isTexture)n.alphaMap=this.alphaMap.toJSON(e).uuid;if(this.lightMap&&this.lightMap.isTexture)n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity;if(this.aoMap&&this.aoMap.isTexture)n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity;if(this.bumpMap&&this.bumpMap.isTexture)n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale;if(this.normalMap&&this.normalMap.isTexture)n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray();if(this.displacementMap&&this.displacementMap.isTexture)n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias;if(this.roughnessMap&&this.roughnessMap.isTexture)n.roughnessMap=this.roughnessMap.toJSON(e).uuid;if(this.metalnessMap&&this.metalnessMap.isTexture)n.metalnessMap=this.metalnessMap.toJSON(e).uuid;if(this.emissiveMap&&this.emissiveMap.isTexture)n.emissiveMap=this.emissiveMap.toJSON(e).uuid;if(this.specularMap&&this.specularMap.isTexture)n.specularMap=this.specularMap.toJSON(e).uuid;if(this.specularIntensityMap&&this.specularIntensityMap.isTexture)n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid;if(this.specularColorMap&&this.specularColorMap.isTexture)n.specularColorMap=this.specularColorMap.toJSON(e).uuid;if(this.envMap&&this.envMap.isTexture){if(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0)n.combine=this.combine}if(this.envMapRotation!==void 0)n.envMapRotation=this.envMapRotation.toArray();if(this.envMapIntensity!==void 0)n.envMapIntensity=this.envMapIntensity;if(this.reflectivity!==void 0)n.reflectivity=this.reflectivity;if(this.refractionRatio!==void 0)n.refractionRatio=this.refractionRatio;if(this.gradientMap&&this.gradientMap.isTexture)n.gradientMap=this.gradientMap.toJSON(e).uuid;if(this.transmission!==void 0)n.transmission=this.transmission;if(this.transmissionMap&&this.transmissionMap.isTexture)n.transmissionMap=this.transmissionMap.toJSON(e).uuid;if(this.thickness!==void 0)n.thickness=this.thickness;if(this.thicknessMap&&this.thicknessMap.isTexture)n.thicknessMap=this.thicknessMap.toJSON(e).uuid;if(this.attenuationDistance!==void 0)n.attenuationDistance=this.attenuationDistance;if(this.attenuationColor!==void 0)n.attenuationColor=this.attenuationColor.getHex();if(this.size!==void 0)n.size=this.size;if(this.sizeAttenuation!==void 0)n.sizeAttenuation=this.sizeAttenuation;if(Array.isArray(this.clippingPlanes)&&this.clippingPlanes.length>0)n.clippingPlanes=this.clippingPlanes.map((r)=>r.toJSON());if(this.rotation!==void 0)n.rotation=this.rotation;if(this.depthPacking!==void 0)n.depthPacking=this.depthPacking;if(this.linewidth!==void 0)n.linewidth=this.linewidth;if(this.linecap!==void 0)n.linecap=this.linecap;if(this.linejoin!==void 0)n.linejoin=this.linejoin;if(this.dashSize!==void 0)n.dashSize=this.dashSize;if(this.gapSize!==void 0)n.gapSize=this.gapSize;if(this.scale!==void 0)n.scale=this.scale;if(this.wireframe!==void 0)n.wireframe=this.wireframe;if(this.wireframeLinewidth!==void 0)n.wireframeLinewidth=this.wireframeLinewidth;if(this.wireframeLinecap!==void 0)n.wireframeLinecap=this.wireframeLinecap;if(this.wireframeLinejoin!==void 0)n.wireframeLinejoin=this.wireframeLinejoin;if(this.flatShading!==void 0)n.flatShading=this.flatShading;if(this.fog!==void 0)n.fog=this.fog;if(Object.keys(this.userData).length>0)n.userData=this.userData;function i(r){let s=[];for(let o in r){let a=r[o];delete a.metadata,s.push(a)}return s}if(t){let r=i(e.textures),s=i(e.images);if(r.length>0)n.textures=r;if(s.length>0)n.images=s}return n}fromJSON(e,t){if(e.uuid!==void 0)this.uuid=e.uuid;if(e.name!==void 0)this.name=e.name;if(e.color!==void 0&&this.color!==void 0)this.color.setHex(e.color);if(e.roughness!==void 0)this.roughness=e.roughness;if(e.metalness!==void 0)this.metalness=e.metalness;if(e.sheen!==void 0)this.sheen=e.sheen;if(e.sheenColor!==void 0)this.sheenColor=new Ue().setHex(e.sheenColor);if(e.sheenRoughness!==void 0)this.sheenRoughness=e.sheenRoughness;if(e.emissive!==void 0&&this.emissive!==void 0)this.emissive.setHex(e.emissive);if(e.specular!==void 0&&this.specular!==void 0)this.specular.setHex(e.specular);if(e.specularIntensity!==void 0)this.specularIntensity=e.specularIntensity;if(e.specularColor!==void 0&&this.specularColor!==void 0)this.specularColor.setHex(e.specularColor);if(e.shininess!==void 0)this.shininess=e.shininess;if(e.clearcoat!==void 0)this.clearcoat=e.clearcoat;if(e.clearcoatRoughness!==void 0)this.clearcoatRoughness=e.clearcoatRoughness;if(e.dispersion!==void 0)this.dispersion=e.dispersion;if(e.retroreflectivity!==void 0)this.retroreflectivity=e.retroreflectivity;if(e.iridescence!==void 0)this.iridescence=e.iridescence;if(e.iridescenceIOR!==void 0)this.iridescenceIOR=e.iridescenceIOR;if(e.iridescenceThicknessRange!==void 0)this.iridescenceThicknessRange=e.iridescenceThicknessRange;if(e.transmission!==void 0)this.transmission=e.transmission;if(e.thickness!==void 0)this.thickness=e.thickness;if(e.attenuationDistance!==void 0)this.attenuationDistance=e.attenuationDistance;if(e.attenuationColor!==void 0&&this.attenuationColor!==void 0)this.attenuationColor.setHex(e.attenuationColor);if(e.anisotropy!==void 0)this.anisotropy=e.anisotropy;if(e.anisotropyRotation!==void 0)this.anisotropyRotation=e.anisotropyRotation;if(e.fog!==void 0)this.fog=e.fog;if(e.flatShading!==void 0)this.flatShading=e.flatShading;if(e.blending!==void 0)this.blending=e.blending;if(e.combine!==void 0)this.combine=e.combine;if(e.side!==void 0)this.side=e.side;if(e.shadowSide!==void 0)this.shadowSide=e.shadowSide;if(e.opacity!==void 0)this.opacity=e.opacity;if(e.transparent!==void 0)this.transparent=e.transparent;if(e.alphaTest!==void 0)this.alphaTest=e.alphaTest;if(e.alphaHash!==void 0)this.alphaHash=e.alphaHash;if(e.depthFunc!==void 0)this.depthFunc=e.depthFunc;if(e.depthTest!==void 0)this.depthTest=e.depthTest;if(e.depthWrite!==void 0)this.depthWrite=e.depthWrite;if(e.colorWrite!==void 0)this.colorWrite=e.colorWrite;if(e.clippingPlanes!==void 0)this.clippingPlanes=e.clippingPlanes.map((n)=>new An().fromJSON(n));if(e.clipIntersection!==void 0)this.clipIntersection=e.clipIntersection;if(e.clipShadows!==void 0)this.clipShadows=e.clipShadows;if(e.depthPacking!==void 0)this.depthPacking=e.depthPacking;if(e.blendSrc!==void 0)this.blendSrc=e.blendSrc;if(e.blendDst!==void 0)this.blendDst=e.blendDst;if(e.blendEquation!==void 0)this.blendEquation=e.blendEquation;if(e.blendSrcAlpha!==void 0)this.blendSrcAlpha=e.blendSrcAlpha;if(e.blendDstAlpha!==void 0)this.blendDstAlpha=e.blendDstAlpha;if(e.blendEquationAlpha!==void 0)this.blendEquationAlpha=e.blendEquationAlpha;if(e.blendColor!==void 0&&this.blendColor!==void 0)this.blendColor.setHex(e.blendColor);if(e.blendAlpha!==void 0)this.blendAlpha=e.blendAlpha;if(e.stencilWriteMask!==void 0)this.stencilWriteMask=e.stencilWriteMask;if(e.stencilFunc!==void 0)this.stencilFunc=e.stencilFunc;if(e.stencilRef!==void 0)this.stencilRef=e.stencilRef;if(e.stencilFuncMask!==void 0)this.stencilFuncMask=e.stencilFuncMask;if(e.stencilFail!==void 0)this.stencilFail=e.stencilFail;if(e.stencilZFail!==void 0)this.stencilZFail=e.stencilZFail;if(e.stencilZPass!==void 0)this.stencilZPass=e.stencilZPass;if(e.stencilWrite!==void 0)this.stencilWrite=e.stencilWrite;if(e.wireframe!==void 0)this.wireframe=e.wireframe;if(e.wireframeLinewidth!==void 0)this.wireframeLinewidth=e.wireframeLinewidth;if(e.wireframeLinecap!==void 0)this.wireframeLinecap=e.wireframeLinecap;if(e.wireframeLinejoin!==void 0)this.wireframeLinejoin=e.wireframeLinejoin;if(e.rotation!==void 0)this.rotation=e.rotation;if(e.linewidth!==void 0)this.linewidth=e.linewidth;if(e.linecap!==void 0)this.linecap=e.linecap;if(e.linejoin!==void 0)this.linejoin=e.linejoin;if(e.dashSize!==void 0)this.dashSize=e.dashSize;if(e.gapSize!==void 0)this.gapSize=e.gapSize;if(e.scale!==void 0)this.scale=e.scale;if(e.polygonOffset!==void 0)this.polygonOffset=e.polygonOffset;if(e.polygonOffsetFactor!==void 0)this.polygonOffsetFactor=e.polygonOffsetFactor;if(e.polygonOffsetUnits!==void 0)this.polygonOffsetUnits=e.polygonOffsetUnits;if(e.dithering!==void 0)this.dithering=e.dithering;if(e.alphaToCoverage!==void 0)this.alphaToCoverage=e.alphaToCoverage;if(e.premultipliedAlpha!==void 0)this.premultipliedAlpha=e.premultipliedAlpha;if(e.forceSinglePass!==void 0)this.forceSinglePass=e.forceSinglePass;if(e.allowOverride!==void 0)this.allowOverride=e.allowOverride;if(e.visible!==void 0)this.visible=e.visible;if(e.toneMapped!==void 0)this.toneMapped=e.toneMapped;if(e.userData!==void 0)this.userData=e.userData;if(e.vertexColors!==void 0)if(typeof e.vertexColors==="number")this.vertexColors=e.vertexColors>0;else this.vertexColors=e.vertexColors;if(e.size!==void 0)this.size=e.size;if(e.sizeAttenuation!==void 0)this.sizeAttenuation=e.sizeAttenuation;if(e.map!==void 0)this.map=t[e.map]||null;if(e.matcap!==void 0)this.matcap=t[e.matcap]||null;if(e.alphaMap!==void 0)this.alphaMap=t[e.alphaMap]||null;if(e.bumpMap!==void 0)this.bumpMap=t[e.bumpMap]||null;if(e.bumpScale!==void 0)this.bumpScale=e.bumpScale;if(e.normalMap!==void 0)this.normalMap=t[e.normalMap]||null;if(e.normalMapType!==void 0)this.normalMapType=e.normalMapType;if(e.normalScale!==void 0){let n=e.normalScale;if(Array.isArray(n)===!1)n=[n,n];this.normalScale=new Ne().fromArray(n)}if(e.displacementMap!==void 0)this.displacementMap=t[e.displacementMap]||null;if(e.displacementScale!==void 0)this.displacementScale=e.displacementScale;if(e.displacementBias!==void 0)this.displacementBias=e.displacementBias;if(e.roughnessMap!==void 0)this.roughnessMap=t[e.roughnessMap]||null;if(e.metalnessMap!==void 0)this.metalnessMap=t[e.metalnessMap]||null;if(e.emissiveMap!==void 0)this.emissiveMap=t[e.emissiveMap]||null;if(e.emissiveIntensity!==void 0)this.emissiveIntensity=e.emissiveIntensity;if(e.specularMap!==void 0)this.specularMap=t[e.specularMap]||null;if(e.specularIntensityMap!==void 0)this.specularIntensityMap=t[e.specularIntensityMap]||null;if(e.specularColorMap!==void 0)this.specularColorMap=t[e.specularColorMap]||null;if(e.envMap!==void 0)this.envMap=t[e.envMap]||null;if(e.envMapRotation!==void 0)this.envMapRotation.fromArray(e.envMapRotation);if(e.envMapIntensity!==void 0)this.envMapIntensity=e.envMapIntensity;if(e.reflectivity!==void 0)this.reflectivity=e.reflectivity;if(e.refractionRatio!==void 0)this.refractionRatio=e.refractionRatio;if(e.lightMap!==void 0)this.lightMap=t[e.lightMap]||null;if(e.lightMapIntensity!==void 0)this.lightMapIntensity=e.lightMapIntensity;if(e.aoMap!==void 0)this.aoMap=t[e.aoMap]||null;if(e.aoMapIntensity!==void 0)this.aoMapIntensity=e.aoMapIntensity;if(e.gradientMap!==void 0)this.gradientMap=t[e.gradientMap]||null;if(e.clearcoatMap!==void 0)this.clearcoatMap=t[e.clearcoatMap]||null;if(e.clearcoatRoughnessMap!==void 0)this.clearcoatRoughnessMap=t[e.clearcoatRoughnessMap]||null;if(e.clearcoatNormalMap!==void 0)this.clearcoatNormalMap=t[e.clearcoatNormalMap]||null;if(e.clearcoatNormalScale!==void 0)this.clearcoatNormalScale=new Ne().fromArray(e.clearcoatNormalScale);if(e.iridescenceMap!==void 0)this.iridescenceMap=t[e.iridescenceMap]||null;if(e.iridescenceThicknessMap!==void 0)this.iridescenceThicknessMap=t[e.iridescenceThicknessMap]||null;if(e.transmissionMap!==void 0)this.transmissionMap=t[e.transmissionMap]||null;if(e.thicknessMap!==void 0)this.thicknessMap=t[e.thicknessMap]||null;if(e.anisotropyMap!==void 0)this.anisotropyMap=t[e.anisotropyMap]||null;if(e.sheenColorMap!==void 0)this.sheenColorMap=t[e.sheenColorMap]||null;if(e.sheenRoughnessMap!==void 0)this.sheenRoughnessMap=t[e.sheenRoughnessMap]||null;return this}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;let t=e.clippingPlanes,n=null;if(t!==null){let i=t.length;n=Array(i);for(let r=0;r!==i;++r)n[r]=t[r].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.allowOverride=e.allowOverride,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){if(e===!0)this.version++}}var wi=new D,rl=new D,Ko=new D,Jo=new D;class Yi{constructor(e=new D,t=new D(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,wi)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);let n=t.dot(this.direction);if(n<0)return t.copy(this.origin);return t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){let t=wi.subVectors(e,this.origin).dot(this.direction);if(t<0)return this.origin.distanceToSquared(e);return wi.copy(this.origin).addScaledVector(this.direction,t),wi.distanceToSquared(e)}distanceSqToSegment(e,t,n,i){rl.copy(e).add(t).multiplyScalar(0.5),Ko.copy(t).sub(e).normalize(),Jo.copy(this.origin).sub(rl);let r=e.distanceTo(t)*0.5,s=-this.direction.dot(Ko),o=Jo.dot(this.direction),a=-Jo.dot(Ko),c=Jo.lengthSq(),l=Math.abs(1-s*s),u,f,h,d;if(l>0)if(u=s*a-o,f=s*o-a,d=r*l,u>=0)if(f>=-d)if(f<=d){let g=1/l;u*=g,f*=g,h=u*(u+s*f+2*o)+f*(s*u+f+2*a)+c}else f=r,u=Math.max(0,-(s*f+o)),h=-u*u+f*(f+2*a)+c;else f=-r,u=Math.max(0,-(s*f+o)),h=-u*u+f*(f+2*a)+c;else if(f<=-d)u=Math.max(0,-(-s*r+o)),f=u>0?-r:Math.min(Math.max(-r,-a),r),h=-u*u+f*(f+2*a)+c;else if(f<=d)u=0,f=Math.min(Math.max(-r,-a),r),h=f*(f+2*a)+c;else u=Math.max(0,-(s*r+o)),f=u>0?r:Math.min(Math.max(-r,-a),r),h=-u*u+f*(f+2*a)+c;else f=s>0?-r:r,u=Math.max(0,-(s*f+o)),h=-u*u+f*(f+2*a)+c;if(n)n.copy(this.origin).addScaledVector(this.direction,u);if(i)i.copy(rl).addScaledVector(Ko,f);return h}intersectSphere(e,t){if(e.radius<0)return null;wi.subVectors(e.center,this.origin);let n=wi.dot(this.direction),i=wi.dot(wi)-n*n,r=e.radius*e.radius;if(i>r)return null;let s=Math.sqrt(r-i),o=n-s,a=n+s;if(a<0)return null;if(o<0)return this.at(a,t);return this.at(o,t)}intersectsSphere(e){if(e.radius<0)return!1;return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let t=e.normal.dot(this.direction);if(t===0){if(e.distanceToPoint(this.origin)===0)return 0;return null}let n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){let n=this.distanceToPlane(e);if(n===null)return null;return this.at(n,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);if(t===0)return!0;if(e.normal.dot(this.direction)*t<0)return!0;return!1}intersectBox(e,t){let n,i,r,s,o,a,c=1/this.direction.x,l=1/this.direction.y,u=1/this.direction.z,f=this.origin;if(c>=0)n=(e.min.x-f.x)*c,i=(e.max.x-f.x)*c;else n=(e.max.x-f.x)*c,i=(e.min.x-f.x)*c;if(l>=0)r=(e.min.y-f.y)*l,s=(e.max.y-f.y)*l;else r=(e.max.y-f.y)*l,s=(e.min.y-f.y)*l;if(n>s||r>i)return null;if(r>n||isNaN(n))n=r;if(s<i||isNaN(i))i=s;if(u>=0)o=(e.min.z-f.z)*u,a=(e.max.z-f.z)*u;else o=(e.max.z-f.z)*u,a=(e.min.z-f.z)*u;if(n>a||o>i)return null;if(o>n||n!==n)n=o;if(a<i||i!==i)i=a;if(i<0)return null;return this.at(n>=0?n:i,t)}intersectsBox(e){return this.intersectBox(e,wi)!==null}intersectTriangle(e,t,n,i,r){let s=this.origin,o=this.direction,{x:a,y:c,z:l}=o,u=e.x-s.x,f=e.y-s.y,h=e.z-s.z,d=t.x-s.x,g=t.y-s.y,x=t.z-s.z,p=n.x-s.x,m=n.y-s.y,E=n.z-s.z,R=Math.abs(a),v=Math.abs(c),M=Math.abs(l),T,A,_,S,k,C,U,ee,P,V,j,z;if(R>=v&&R>=M)if(_=a,C=u,P=d,z=p,a>=0)T=c,A=l,S=f,k=h,U=g,ee=x,V=m,j=E;else T=l,A=c,S=h,k=f,U=x,ee=g,V=E,j=m;else if(v>=M)if(_=c,C=f,P=g,z=m,c>=0)T=l,A=a,S=h,k=u,U=x,ee=d,V=E,j=p;else T=a,A=l,S=u,k=h,U=d,ee=x,V=p,j=E;else if(_=l,C=h,P=x,z=E,l>=0)T=a,A=c,S=u,k=f,U=d,ee=g,V=p,j=m;else T=c,A=a,S=f,k=u,U=g,ee=d,V=m,j=p;if(_===0)return null;let H=T/_,F=A/_,q=1/_,K=S-H*C,xe=k-F*C,ce=U-H*P,De=ee-F*P,ye=V-H*z,X=j-F*z,re=ye*De-X*ce,se=K*X-xe*ye,Te=ce*xe-De*K;if(i){if(re<0||se<0||Te<0)return null}else if((re<0||se<0||Te<0)&&(re>0||se>0||Te>0))return null;let Ie=re+se+Te;if(Ie===0)return null;let _e=q*(re*C+se*P+Te*z);if(Ie>0?_e<0:_e>0)return null;return this.at(_e/Ie,r)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class ai extends hn{constructor(e){super();this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Ue(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new ni,this.combine=0,this.reflectivity=1,this.refractionRatio=0.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}var Hf=new Ge,mr=new Yi,Qo=new xn,Vf=new D,ea=new D,ta=new D,na=new D,sl=new D,ia=new D,$f=new D,ra=new D;class xt extends ht{constructor(e=new en,t=new ai){super();this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){if(super.copy(e,t),e.morphTargetInfluences!==void 0)this.morphTargetInfluences=e.morphTargetInfluences.slice();if(e.morphTargetDictionary!==void 0)this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary);return this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,s=i.length;r<s;r++){let o=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}getVertexPosition(e,t){let n=this.geometry,i=n.attributes.position,r=n.morphAttributes.position,s=n.morphTargetsRelative;t.fromBufferAttribute(i,e);let o=this.morphTargetInfluences;if(r&&o){ia.set(0,0,0);for(let a=0,c=r.length;a<c;a++){let l=o[a],u=r[a];if(l===0)continue;if(sl.fromBufferAttribute(u,e),s)ia.addScaledVector(sl,l);else ia.addScaledVector(sl.sub(t),l)}t.add(ia)}return t}intersectsFrustum(e){return e.intersectsObject(this)}raycast(e,t){let n=this.geometry,i=this.material,r=this.matrixWorld;if(i===void 0)return;if(n.boundingSphere===null)n.computeBoundingSphere();if(Qo.copy(n.boundingSphere),Qo.applyMatrix4(r),mr.copy(e.ray).recast(e.near),Qo.containsPoint(mr.origin)===!1){if(mr.intersectSphere(Qo,Vf)===null)return;if(mr.origin.distanceToSquared(Vf)>(e.far-e.near)**2)return}if(Hf.copy(r).invert(),mr.copy(e.ray).applyMatrix4(Hf),n.boundingBox!==null){if(mr.intersectsBox(n.boundingBox)===!1)return}this._computeIntersections(e,t,mr)}_computeIntersections(e,t,n){let i,r=this.geometry,s=this.material,o=r.index,a=r.attributes.position,c=r.attributes.uv,l=r.attributes.uv1,u=r.attributes.normal,{groups:f,drawRange:h}=r;if(o!==null)if(Array.isArray(s))for(let d=0,g=f.length;d<g;d++){let x=f[d],p=s[x.materialIndex],m=Math.max(x.start,h.start),E=Math.min(o.count,Math.min(x.start+x.count,h.start+h.count));for(let R=m,v=E;R<v;R+=3){let M=o.getX(R),T=o.getX(R+1),A=o.getX(R+2);if(i=sa(this,p,e,n,c,l,u,M,T,A),i)i.faceIndex=Math.floor(R/3),i.face.materialIndex=x.materialIndex,t.push(i)}}else{let d=Math.max(0,h.start),g=Math.min(o.count,h.start+h.count);for(let x=d,p=g;x<p;x+=3){let m=o.getX(x),E=o.getX(x+1),R=o.getX(x+2);if(i=sa(this,s,e,n,c,l,u,m,E,R),i)i.faceIndex=Math.floor(x/3),t.push(i)}}else if(a!==void 0)if(Array.isArray(s))for(let d=0,g=f.length;d<g;d++){let x=f[d],p=s[x.materialIndex],m=Math.max(x.start,h.start),E=Math.min(a.count,Math.min(x.start+x.count,h.start+h.count));for(let R=m,v=E;R<v;R+=3){let M=R,T=R+1,A=R+2;if(i=sa(this,p,e,n,c,l,u,M,T,A),i)i.faceIndex=Math.floor(R/3),i.face.materialIndex=x.materialIndex,t.push(i)}}else{let d=Math.max(0,h.start),g=Math.min(a.count,h.start+h.count);for(let x=d,p=g;x<p;x+=3){let m=x,E=x+1,R=x+2;if(i=sa(this,s,e,n,c,l,u,m,E,R),i)i.faceIndex=Math.floor(x/3),t.push(i)}}}}function Jv(e,t,n,i,r,s,o,a){let c;if(t.side===1)c=i.intersectTriangle(o,s,r,!0,a);else c=i.intersectTriangle(r,s,o,t.side===0,a);if(c===null)return null;ra.copy(a),ra.applyMatrix4(e.matrixWorld);let l=n.ray.origin.distanceTo(ra);if(l<n.near||l>n.far)return null;return{distance:l,point:ra.clone(),object:e}}function sa(e,t,n,i,r,s,o,a,c,l){e.getVertexPosition(a,ea),e.getVertexPosition(c,ta),e.getVertexPosition(l,na);let u=Jv(e,t,n,i,ea,ta,na,$f);if(u){let f=new D;if(Rn.getBarycoord($f,ea,ta,na,f),r)u.uv=Rn.getInterpolatedAttribute(r,a,c,l,f,new Ne);if(s)u.uv1=Rn.getInterpolatedAttribute(s,a,c,l,f,new Ne);if(o){if(u.normal=Rn.getInterpolatedAttribute(o,a,c,l,f,new D),u.normal.dot(i.direction)>0)u.normal.multiplyScalar(-1)}let h={a,b:c,c:l,normal:new D,materialIndex:0};Rn.getNormal(ea,ta,na,h.normal),u.face=h,u.barycoord=f}return u}var Ls=new ct,Wf=new ct,Zf=new ct,Qv=new ct,Xf=new Ge,oa=new D,ol=new xn,qf=new Ge,al=new Yi;class Oa extends xt{constructor(e,t){super(e,t);this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode="attached",this.bindMatrix=new Ge,this.bindMatrixInverse=new Ge,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){let e=this.geometry;if(this.boundingBox===null)this.boundingBox=new Ft;this.boundingBox.makeEmpty();let t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,oa),this.boundingBox.expandByPoint(oa)}computeBoundingSphere(){let e=this.geometry;if(this.boundingSphere===null)this.boundingSphere=new xn;this.boundingSphere.makeEmpty();let t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,oa),this.boundingSphere.expandByPoint(oa)}copy(e,t){if(super.copy(e,t),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,e.boundingBox!==null)this.boundingBox=e.boundingBox.clone();if(e.boundingSphere!==null)this.boundingSphere=e.boundingSphere.clone();return this}raycast(e,t){let n=this.material,i=this.matrixWorld;if(n===void 0)return;if(this.boundingSphere===null)this.computeBoundingSphere();if(ol.copy(this.boundingSphere),ol.applyMatrix4(i),e.ray.intersectsSphere(ol)===!1)return;if(qf.copy(i).invert(),al.copy(e.ray).applyMatrix4(qf),this.boundingBox!==null){if(al.intersectsBox(this.boundingBox)===!1)return}this._computeIntersections(e,t,al)}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){if(this.skeleton=e,t===void 0)this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld;this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){let e=new ct,t=this.geometry.attributes.skinWeight;for(let n=0,i=t.count;n<i;n++){e.fromBufferAttribute(t,n);let r=1/e.manhattanLength();if(r!==1/0)e.multiplyScalar(r);else e.set(1,0,0,0);t.setXYZW(n,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){if(super.updateMatrixWorld(e),this.bindMode==="attached")this.bindMatrixInverse.copy(this.matrixWorld).invert();else if(this.bindMode==="detached")this.bindMatrixInverse.copy(this.bindMatrix).invert();else Pe("SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){let n=this.skeleton,i=this.geometry;if(Wf.fromBufferAttribute(i.attributes.skinIndex,e),Zf.fromBufferAttribute(i.attributes.skinWeight,e),t.isVector4)Ls.copy(t),t.set(0,0,0,0);else Ls.set(...t,1),t.set(0,0,0);Ls.applyMatrix4(this.bindMatrix);for(let r=0;r<4;r++){let s=Zf.getComponent(r);if(s!==0){let o=Wf.getComponent(r);Xf.multiplyMatrices(n.bones[o].matrixWorld,n.boneInverses[o]),t.addScaledVector(Qv.copy(Ls).applyMatrix4(Xf),s)}}if(t.isVector4)t.w=Ls.w;return t.applyMatrix4(this.bindMatrixInverse)}}class js extends ht{constructor(){super();this.isBone=!0,this.type="Bone"}}class Ys extends At{constructor(e=null,t=1,n=1,i,r,s,o,a,c=1003,l=1003,u,f){super(null,s,o,a,c,l,i,r,u,f);this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}var jf=new Ge,eb=new Ge;class Ks{constructor(e=[],t=[]){this.uuid=Bn(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){let e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){Pe("Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let n=0,i=this.bones.length;n<i;n++)this.boneInverses.push(new Ge)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){let n=new Ge;if(this.bones[e])n.copy(this.bones[e].matrixWorld).invert();this.boneInverses.push(n)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){let n=this.bones[e];if(n)n.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){let n=this.bones[e];if(n){if(n.parent&&n.parent.isBone)n.matrix.copy(n.parent.matrixWorld).invert(),n.matrix.multiply(n.matrixWorld);else n.matrix.copy(n.matrixWorld);n.matrix.decompose(n.position,n.quaternion,n.scale)}}}update(){let e=this.bones,t=this.boneInverses,n=this.boneMatrices,i=this.boneTexture;for(let r=0,s=e.length;r<s;r++){let o=e[r]?e[r].matrixWorld:eb;jf.multiplyMatrices(o,t[r]),jf.toArray(n,r*16)}if(i!==null)i.needsUpdate=!0}clone(){return new Ks(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);let t=new Float32Array(e*e*4);t.set(this.boneMatrices);let n=new Ys(t,e,e,1023,1015);return n.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=n,this}getBoneByName(e){for(let t=0,n=this.bones.length;t<n;t++){let i=this.bones[t];if(i.name===e)return i}return}dispose(){if(this.boneTexture!==null)this.boneTexture.dispose(),this.boneTexture=null}fromJSON(e,t){this.uuid=e.uuid;for(let n=0,i=e.bones.length;n<i;n++){let r=e.bones[n],s=t[r];if(s===void 0)Pe("Skeleton: No bone found with UUID:",r),s=new js;this.bones.push(s),this.boneInverses.push(new Ge().fromArray(e.boneInverses[n]))}return this.init(),this}toJSON(){let e={metadata:{version:4.7,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;let t=this.bones,n=this.boneInverses;for(let i=0,r=t.length;i<r;i++){let s=t[i];e.bones.push(s.uuid);let o=n[i];e.boneInverses.push(o.toArray())}return e}}class $i extends Vt{constructor(e,t,n,i=1){super(e,t,n);this.isInstancedBufferAttribute=!0,this.meshPerAttribute=i}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){let e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}}var jr=new Ge,Yf=new Ge,aa=[],Kf=new Ft,tb=new Ge,Ns=new xt,Ds=new xn;class ds extends xt{constructor(e,t,n){super(e,t);this.isInstancedMesh=!0,this.instanceMatrix=new $i(new Float32Array(n*16),16),this.instanceColor=null,this.morphTexture=null,this.count=n,this.boundingBox=null,this.boundingSphere=null;for(let i=0;i<n;i++)this.setMatrixAt(i,tb)}computeBoundingBox(){let e=this.geometry,t=this.count;if(this.boundingBox===null)this.boundingBox=new Ft;if(e.boundingBox===null)e.computeBoundingBox();this.boundingBox.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,jr),Kf.copy(e.boundingBox).applyMatrix4(jr),this.boundingBox.union(Kf)}computeBoundingSphere(){let e=this.geometry,t=this.count;if(this.boundingSphere===null)this.boundingSphere=new xn;if(e.boundingSphere===null)e.computeBoundingSphere();this.boundingSphere.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,jr),Ds.copy(e.boundingSphere).applyMatrix4(jr),this.boundingSphere.union(Ds)}copy(e,t){if(super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.morphTexture!==null)this.morphTexture=e.morphTexture.clone();if(e.instanceColor!==null)this.instanceColor=e.instanceColor.clone();if(this.count=e.count,e.boundingBox!==null)this.boundingBox=e.boundingBox.clone();if(e.boundingSphere!==null)this.boundingSphere=e.boundingSphere.clone();return this}getColorAt(e,t){if(this.instanceColor===null)return t.setRGB(1,1,1);else return t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){return t.fromArray(this.instanceMatrix.array,e*16)}getMorphAt(e,t){let n=t.morphTargetInfluences,i=this.morphTexture.source.data.data,r=n.length+1,s=e*r+1;for(let o=0;o<n.length;o++)n[o]=i[s+o]}raycast(e,t){let n=this.matrixWorld,i=this.count;if(Ns.geometry=this.geometry,Ns.material=this.material,Ns.material===void 0)return;if(this.boundingSphere===null)this.computeBoundingSphere();if(Ds.copy(this.boundingSphere),Ds.applyMatrix4(n),e.ray.intersectsSphere(Ds)===!1)return;for(let r=0;r<i;r++){this.getMatrixAt(r,jr),Yf.multiplyMatrices(n,jr),Ns.matrixWorld=Yf,Ns.raycast(e,aa);for(let s=0,o=aa.length;s<o;s++){let a=aa[s];a.instanceId=r,a.object=this,t.push(a)}aa.length=0}}setColorAt(e,t){if(this.instanceColor===null)this.instanceColor=new $i(new Float32Array(this.instanceMatrix.count*3).fill(1),3);return t.toArray(this.instanceColor.array,e*3),this}setMatrixAt(e,t){return t.toArray(this.instanceMatrix.array,e*16),this}setMorphAt(e,t){let n=t.morphTargetInfluences,i=n.length+1;if(this.morphTexture===null)this.morphTexture=new Ys(new Float32Array(i*this.count),i,this.count,1028,1015);let r=this.morphTexture.source.data.data,s=0;for(let c=0;c<n.length;c++)s+=n[c];let o=this.geometry.morphTargetsRelative?1:1-s,a=i*e;return r[a]=o,r.set(n,a+1),this}updateMorphTargets(){}dispose(){if(super.dispose(),this.morphTexture!==null)this.morphTexture.dispose(),this.morphTexture=null}}var gr=new xn,nb=new Ne(0.5,0.5),ca=new D;class Js{constructor(e=new An,t=new An,n=new An,i=new An,r=new An,s=new An){this.planes=[e,t,n,i,r,s]}set(e,t,n,i,r,s){let o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(n),o[3].copy(i),o[4].copy(r),o[5].copy(s),this}copy(e){let t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=2000,n=!1){let i=this.planes,r=e.elements,s=r[0],o=r[1],a=r[2],c=r[3],l=r[4],u=r[5],f=r[6],h=r[7],d=r[8],g=r[9],x=r[10],p=r[11],m=r[12],E=r[13],R=r[14],v=r[15];if(i[0].setComponents(c-s,h-l,p-d,v-m).normalize(),i[1].setComponents(c+s,h+l,p+d,v+m).normalize(),i[2].setComponents(c+o,h+u,p+g,v+E).normalize(),i[3].setComponents(c-o,h-u,p-g,v-E).normalize(),n)i[4].setComponents(a,f,x,R).normalize(),i[5].setComponents(c-a,h-f,p-x,v-R).normalize();else if(i[4].setComponents(c-a,h-f,p-x,v-R).normalize(),t===2000)i[5].setComponents(c+a,h+f,p+x,v+R).normalize();else if(t===2001)i[5].setComponents(a,f,x,R).normalize();else throw Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0){if(e.boundingSphere===null)e.computeBoundingSphere();gr.copy(e.boundingSphere).applyMatrix4(e.matrixWorld)}else{let t=e.geometry;if(t.boundingSphere===null)t.computeBoundingSphere();gr.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(gr)}intersectsSprite(e){gr.center.set(0,0,0);let t=nb.distanceTo(e.center);return gr.radius=0.7071067811865476+t,gr.applyMatrix4(e.matrixWorld),this.intersectsSphere(gr)}intersectsSphere(e){let t=this.planes,n=e.center,i=-e.radius;for(let r=0;r<6;r++)if(t[r].distanceToPoint(n)<i)return!1;return!0}intersectsBox(e){let t=this.planes;for(let n=0;n<6;n++){let i=t[n];if(ca.x=i.normal.x>0?e.max.x:e.min.x,ca.y=i.normal.y>0?e.max.y:e.min.y,ca.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(ca)<0)return!1}return!0}containsPoint(e){let t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}class Qs extends hn{constructor(e){super();this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Ue(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}var ga=new D,_a=new D,Jf=new Ge,Os=new Yi,la=new xn,cl=new D,Qf=new D;class Ki extends ht{constructor(e=new en,t=new Qs){super();this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[0];for(let i=1,r=t.count;i<r;i++)ga.fromBufferAttribute(t,i-1),_a.fromBufferAttribute(t,i),n[i]=n[i-1],n[i]+=ga.distanceTo(_a);e.setAttribute("lineDistance",new un(n,1))}else Pe("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}intersectsFrustum(e){return e.intersectsObject(this)}raycast(e,t){let n=this.geometry,i=this.matrixWorld,r=e.params.Line.threshold,s=n.drawRange;if(n.boundingSphere===null)n.computeBoundingSphere();if(la.copy(n.boundingSphere),la.applyMatrix4(i),la.radius+=r,e.ray.intersectsSphere(la)===!1)return;Jf.copy(i).invert(),Os.copy(e.ray).applyMatrix4(Jf);let o=r/((this.scale.x+this.scale.y+this.scale.z)/3),a=o*o,c=this.isLineSegments?2:1,l=n.index,f=n.attributes.position;if(l!==null){let h=Math.max(0,s.start),d=Math.min(l.count,s.start+s.count);for(let g=h,x=d-1;g<x;g+=c){let p=l.getX(g),m=l.getX(g+1),E=ua(this,e,Os,a,p,m,g);if(E)t.push(E)}if(this.isLineLoop){let g=l.getX(d-1),x=l.getX(h),p=ua(this,e,Os,a,g,x,d-1);if(p)t.push(p)}}else{let h=Math.max(0,s.start),d=Math.min(f.count,s.start+s.count);for(let g=h,x=d-1;g<x;g+=c){let p=ua(this,e,Os,a,g,g+1,g);if(p)t.push(p)}if(this.isLineLoop){let g=ua(this,e,Os,a,d-1,h,d-1);if(g)t.push(g)}}}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,s=i.length;r<s;r++){let o=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}}function ua(e,t,n,i,r,s,o){let a=e.geometry.attributes.position;if(ga.fromBufferAttribute(a,r),_a.fromBufferAttribute(a,s),n.distanceSqToSegment(ga,_a,cl,Qf)>i)return;cl.applyMatrix4(e.matrixWorld);let l=t.ray.origin.distanceTo(cl);if(l<t.near||l>t.far)return;return{distance:l,point:Qf.clone().applyMatrix4(e.matrixWorld),index:o,face:null,faceIndex:null,barycoord:null,object:e}}var ed=new D,td=new D;class Ua extends Ki{constructor(e,t){super(e,t);this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[];for(let i=0,r=t.count;i<r;i+=2)ed.fromBufferAttribute(t,i),td.fromBufferAttribute(t,i+1),n[i]=i===0?0:n[i-1],n[i+1]=n[i]+ed.distanceTo(td);e.setAttribute("lineDistance",new un(n,1))}else Pe("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class Fa extends Ki{constructor(e,t){super(e,t);this.isLineLoop=!0,this.type="LineLoop"}}class eo extends hn{constructor(e){super();this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new Ue(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}var nd=new Ge,hl=new Yi,ha=new xn,fa=new D;class ps extends ht{constructor(e=new en,t=new eo){super();this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}intersectsFrustum(e){return e.intersectsObject(this)}raycast(e,t){let n=this.geometry,i=this.matrixWorld,r=e.params.Points.threshold,s=n.drawRange;if(n.boundingSphere===null)n.computeBoundingSphere();if(ha.copy(n.boundingSphere),ha.applyMatrix4(i),ha.radius+=r,e.ray.intersectsSphere(ha)===!1)return;nd.copy(i).invert(),hl.copy(e.ray).applyMatrix4(nd);let o=r/((this.scale.x+this.scale.y+this.scale.z)/3),a=o*o,c=n.index,u=n.attributes.position;if(c!==null){let f=Math.max(0,s.start),h=Math.min(c.count,s.start+s.count);for(let d=f,g=h;d<g;d++){let x=c.getX(d);fa.fromBufferAttribute(u,x),id(fa,x,a,i,e,t,this)}}else{let f=Math.max(0,s.start),h=Math.min(u.count,s.start+s.count);for(let d=f,g=h;d<g;d++)fa.fromBufferAttribute(u,d),id(fa,d,a,i,e,t,this)}}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,s=i.length;r<s;r++){let o=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}}function id(e,t,n,i,r,s,o){let a=hl.distanceSqToPoint(e);if(a<n){let c=new D;hl.closestPointToPoint(e,c),c.applyMatrix4(i);let l=r.ray.origin.distanceTo(c);if(l<r.near||l>r.far)return;s.push({distance:l,distanceToRay:Math.sqrt(a),point:c,index:t,face:null,faceIndex:null,barycoord:null,object:o})}}class za extends At{constructor(e=[],t=301,n,i,r,s,o,a,c,l){super(e,t,n,i,r,s,o,a,c,l);this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class Er extends At{constructor(e,t,n=1014,i,r,s,o=1003,a=1003,c,l=1026,u=1){if(l!==1026&&l!==1027)throw Error("THREE.DepthTexture: format must be either THREE.DepthFormat or THREE.DepthStencilFormat");let f={width:e,height:t,depth:u};super(f,i,r,s,o,a,l,n,c);this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new Zs(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){let t=super.toJSON(e);return t.compareFunction=this.compareFunction,t}}class mu extends Er{constructor(e,t=1014,n=301,i,r,s=1003,o=1003,a,c=1026){let l={width:e,height:e,depth:1},u=[l,l,l,l,l,l];super(e,e,t,n,i,r,s,o,a,c);this.image=u,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}}class ka extends At{constructor(e=null){super();this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class Ji extends en{constructor(e=1,t=1,n=1,i=1,r=1,s=1){super();this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:i,heightSegments:r,depthSegments:s};let o=this;i=Math.floor(i),r=Math.floor(r),s=Math.floor(s);let a=[],c=[],l=[],u=[],f=0,h=0;d("z","y","x",-1,-1,n,t,e,s,r,0),d("z","y","x",1,-1,n,t,-e,s,r,1),d("x","z","y",1,1,e,n,t,i,s,2),d("x","z","y",1,-1,e,n,-t,i,s,3),d("x","y","z",1,-1,e,t,n,i,r,4),d("x","y","z",-1,-1,e,t,-n,i,r,5),this.setIndex(a),this.setAttribute("position",new un(c,3)),this.setAttribute("normal",new un(l,3)),this.setAttribute("uv",new un(u,2));function d(g,x,p,m,E,R,v,M,T,A,_){let S=R/T,k=v/A,C=R/2,U=v/2,ee=M/2,P=T+1,V=A+1,j=0,z=0,H=new D;for(let F=0;F<V;F++){let q=F*k-U;for(let K=0;K<P;K++){let xe=K*S-C;H[g]=xe*m,H[x]=q*E,H[p]=ee,c.push(H.x,H.y,H.z),H[g]=0,H[x]=0,H[p]=M>0?1:-1,l.push(H.x,H.y,H.z),u.push(K/T),u.push(1-F/A),j+=1}}for(let F=0;F<A;F++)for(let q=0;q<T;q++){let K=f+q+P*F,xe=f+q+P*(F+1),ce=f+(q+1)+P*(F+1),De=f+(q+1)+P*F;a.push(K,xe,De),a.push(xe,ce,De),z+=6}o.addGroup(h,z,_),h+=z,f+=j}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Ji(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}class to extends en{constructor(e=1,t=1,n=1,i=1){super();this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:i};let r=e/2,s=t/2,o=Math.floor(n),a=Math.floor(i),c=o+1,l=a+1,u=e/o,f=t/a,h=[],d=[],g=[],x=[];for(let p=0;p<l;p++){let m=p*f-s;for(let E=0;E<c;E++){let R=E*u-r;d.push(R,-m,0),g.push(0,0,1),x.push(E/o),x.push(1-p/a)}}for(let p=0;p<a;p++)for(let m=0;m<o;m++){let E=m+c*p,R=m+c*(p+1),v=m+1+c*(p+1),M=m+1+c*p;h.push(E,R,M),h.push(R,v,M)}this.setIndex(h),this.setAttribute("position",new un(d,3)),this.setAttribute("normal",new un(g,3)),this.setAttribute("uv",new un(x,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new to(e.width,e.height,e.widthSegments,e.heightSegments)}}function Tr(e){let t={};for(let n in e){t[n]={};for(let i in e[n]){let r=e[n][i];if(rd(r))if(r.isRenderTargetTexture)Pe("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),t[n][i]=null;else t[n][i]=r.clone();else if(Array.isArray(r))if(rd(r[0])){let s=[];for(let o=0,a=r.length;o<a;o++)s[o]=r[o].clone();t[n][i]=s}else t[n][i]=r.slice();else t[n][i]=r}}return t}function tn(e){let t={};for(let n=0;n<e.length;n++){let i=Tr(e[n]);for(let r in i)t[r]=i[r]}return t}function rd(e){return e&&(e.isColor||e.isMatrix3||e.isMatrix4||e.isVector2||e.isVector3||e.isVector4||e.isTexture||e.isQuaternion)}function ib(e){let t=[];for(let n=0;n<e.length;n++)t.push(e[n].clone());return t}function gu(e){let t=e.getRenderTarget();if(t===null)return e.outputColorSpace;if(t.isXRRenderTarget===!0)return t.texture.colorSpace;return $e.workingColorSpace}var hp={clone:Tr,merge:tn},rb=`void main() {
125
+ var dd="186",Zi={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},Xi={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},pd=0,dl=1,md=2;var Vs=1,gd=2,ss=3,qi=0,Qt=1,Pn=2,ii=0,$s=1,pl=2,ml=3,gl=4,_d=5;var os=100,xd=101,yd=102,vd=103,bd=104,Sd=200,Md=201,wd=202,Ed=203,Td=204,Ad=205,Rd=206,Cd=207,Pd=208,Id=209,Ld=210,Nd=211,Dd=212,Od=213,Ud=214,Fd=0,zd=1,kd=2,_l=3,Bd=4,Gd=5,Hd=6,Vd=7,$d=0,Wd=1,Zd=2,Hn=0,xl=1,yl=2,vl=3,Ws=4,bl=5,Sl=6,Ml=7;var as=301,vr=302,va=303,ba=304,Zs=306,cs=1000,ls=1001,Sa=1002,Vn=1003,Ma=1004;var br=1005;var $t=1006,us=1007;var ri=1008;var $n=1009,Xd=1010,qd=1011,Xs=1012,wl=1013,ji=1014,Ri=1015,si=1016,El=1017,Tl=1018,hs=1020,jd=35902,Yd=35899,Kd=1021,Jd=1022,oi=1023,Sr=1026,Mr=1027,Qd=1028,Al=1029,wr=1030,Rl=1031;var Cl=1033,wa=33776,Ea=33777,Ta=33778,Aa=33779,Pl=35840,Il=35841,Ll=35842,Nl=35843,Dl=36196,Ol=37492,Ul=37496,Fl=37488,zl=37489,Ra=37490,kl=37491,Bl=37808,Gl=37809,Hl=37810,Vl=37811,$l=37812,Wl=37813,Zl=37814,Xl=37815,ql=37816,jl=37817,Yl=37818,Kl=37819,Jl=37820,Ql=37821,eu=36492,tu=36494,nu=36495,iu=36283,ru=36284,Ca=36285,su=36286;var ou=2300,Pa=2301;var au=0,qs=1,fs=2;var cu=0,ep=1,Er="",Yi="srgb",gn="srgb-linear",lu="linear",dt="srgb";var tp=512,np=513,ip=514,Ia=515,rp=516,sp=517,La=518,op=519;var uu="300 es",hu=2000;function vv(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}function bv(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function ns(e){return document.createElementNS("http://www.w3.org/1999/xhtml",e)}function ap(){let e=ns("canvas");return e.style.display="block",e}var Pf={},is=null;function Hs(...e){let t="THREE."+e.shift();if(is)is("log",t,...e);else console.log(t,...e)}function cp(e){let t=e[0];if(typeof t==="string"&&t.startsWith("TSL:")){let n=e[1];if(n&&n.isStackTrace)e[0]+=" "+n.getLocation();else e[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return e}function Ie(...e){e=cp(e);let t="THREE."+e.shift();if(is)is("warn",t,...e);else{let n=e[0];if(n&&n.isStackTrace)console.warn(n.getError(t));else console.warn(t,...e)}}function Ue(...e){e=cp(e);let t="THREE."+e.shift();if(is)is("error",t,...e);else{let n=e[0];if(n&&n.isStackTrace)console.error(n.getError(t));else console.error(t,...e)}}function xr(...e){let t=e.join(" ");if(t in Pf)return;Pf[t]=!0,Ie(...e)}function lp(e,t,n){return new Promise(function(i,r){function s(){switch(e.clientWaitSync(t,e.SYNC_FLUSH_COMMANDS_BIT,0)){case e.WAIT_FAILED:r();break;case e.TIMEOUT_EXPIRED:setTimeout(s,n);break;default:i()}}setTimeout(s,n)})}var up={[0]:1,[2]:6,[4]:7,[3]:5,[1]:0,[6]:2,[7]:4,[5]:3};class Wn{addEventListener(e,t){if(this._listeners===void 0)this._listeners={};let n=this._listeners;if(n[e]===void 0)n[e]=[];if(n[e].indexOf(t)===-1)n[e].push(t)}hasEventListener(e,t){let n=this._listeners;if(n===void 0)return!1;return n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){let n=this._listeners;if(n===void 0)return;let i=n[e];if(i!==void 0){let r=i.indexOf(t);if(r!==-1)i.splice(r,1)}}dispatchEvent(e){let t=this._listeners;if(t===void 0)return;let n=t[e.type];if(n!==void 0){e.target=this;let i=n.slice(0);for(let r=0,s=i.length;r<s;r++)i[r].call(this,e);e.target=null}}}var Kt=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"],If=1234567,Bs=Math.PI/180,yr=180/Math.PI;function Gn(){let e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(Kt[e&255]+Kt[e>>8&255]+Kt[e>>16&255]+Kt[e>>24&255]+"-"+Kt[t&255]+Kt[t>>8&255]+"-"+Kt[t>>16&15|64]+Kt[t>>24&255]+"-"+Kt[n&63|128]+Kt[n>>8&255]+"-"+Kt[n>>16&255]+Kt[n>>24&255]+Kt[i&255]+Kt[i>>8&255]+Kt[i>>16&255]+Kt[i>>24&255]).toLowerCase()}function We(e,t,n){return Math.max(t,Math.min(n,e))}function fu(e,t){return(e%t+t)%t}function Sv(e,t,n,i,r){return i+(e-t)*(r-i)/(n-t)}function Mv(e,t,n){if(e!==t)return(n-e)/(t-e);else return 0}function Gs(e,t,n){return(1-n)*e+n*t}function wv(e,t,n,i){return Gs(e,t,1-Math.exp(-n*i))}function Ev(e,t=1){return t-Math.abs(fu(e,t*2)-t)}function Tv(e,t,n){if(e<=t)return 0;if(e>=n)return 1;return e=(e-t)/(n-t),e*e*(3-2*e)}function Av(e,t,n){if(e<=t)return 0;if(e>=n)return 1;return e=(e-t)/(n-t),e*e*e*(e*(e*6-15)+10)}function Rv(e,t){return e+Math.floor(Math.random()*(t-e+1))}function Cv(e,t){return e+Math.random()*(t-e)}function Pv(e){return e*(0.5-Math.random())}function Iv(e){if(e!==void 0)If=e;let t=If+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function Lv(e){return e*Bs}function Nv(e){return e*yr}function Dv(e){return e>0&&Number.isInteger(e)&&2**Math.round(Math.log2(e))===e}function Ov(e){return Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))}function Uv(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))}function Fv(e,t,n,i,r){let{cos:s,sin:o}=Math,a=s(n/2),c=o(n/2),l=s((t+i)/2),u=o((t+i)/2),f=s((t-i)/2),h=o((t-i)/2),d=s((i-t)/2),g=o((i-t)/2);switch(r){case"XYX":e.set(a*u,c*f,c*h,a*l);break;case"YZY":e.set(c*h,a*u,c*f,a*l);break;case"ZXZ":e.set(c*f,c*h,a*u,a*l);break;case"XZX":e.set(a*u,c*g,c*d,a*l);break;case"YXY":e.set(c*d,a*u,c*g,a*l);break;case"ZYZ":e.set(c*g,c*d,a*u,a*l);break;default:Ie("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}function Bn(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return e/4294967295;case Uint16Array:return e/65535;case Uint8Array:case Uint8ClampedArray:return e/255;case Int32Array:return Math.max(e/2147483647,-1);case Int16Array:return Math.max(e/32767,-1);case Int8Array:return Math.max(e/127,-1);default:throw Error("THREE.MathUtils: Invalid component type.")}}function ot(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return Math.round(e*4294967295);case Uint16Array:return Math.round(e*65535);case Uint8Array:case Uint8ClampedArray:return Math.round(e*255);case Int32Array:return Math.round(e*2147483647);case Int16Array:return Math.round(e*32767);case Int8Array:return Math.round(e*127);default:throw Error("THREE.MathUtils: Invalid component type.")}}var js={DEG2RAD:Bs,RAD2DEG:yr,generateUUID:Gn,clamp:We,euclideanModulo:fu,mapLinear:Sv,inverseLerp:Mv,lerp:Gs,damp:wv,pingpong:Ev,smoothstep:Tv,smootherstep:Av,randInt:Rv,randFloat:Cv,randFloatSpread:Pv,seededRandom:Iv,degToRad:Lv,radToDeg:Nv,isPowerOfTwo:Dv,ceilPowerOfTwo:Ov,floorPowerOfTwo:Uv,setQuaternionFromProperEuler:Fv,normalize:ot,denormalize:Bn};class Ne{static{Ne.prototype.isVector2=!0}constructor(e=0,t=0){this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw Error("THREE.Vector2: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw Error("THREE.Vector2: 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){let 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=We(this.x,e.x,t.x),this.y=We(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=We(this.x,e,t),this.y=We(this.y,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(We(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(We(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){let n=Math.cos(t),i=Math.sin(t),r=this.x-e.x,s=this.y-e.y;return this.x=r*n-s*i+e.x,this.y=r*i+s*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Ht{constructor(e=0,t=0,n=0,i=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=i}static slerpFlat(e,t,n,i,r,s,o){let a=n[i+0],c=n[i+1],l=n[i+2],u=n[i+3],f=r[s+0],h=r[s+1],d=r[s+2],g=r[s+3];if(u!==g||a!==f||c!==h||l!==d){let x=a*f+c*h+l*d+u*g;if(x<0)f=-f,h=-h,d=-d,g=-g,x=-x;let p=1-o;if(x<0.9995){let m=Math.acos(x),E=Math.sin(m);p=Math.sin(p*m)/E,o=Math.sin(o*m)/E,a=a*p+f*o,c=c*p+h*o,l=l*p+d*o,u=u*p+g*o}else{a=a*p+f*o,c=c*p+h*o,l=l*p+d*o,u=u*p+g*o;let m=1/Math.sqrt(a*a+c*c+l*l+u*u);a*=m,c*=m,l*=m,u*=m}}e[t]=a,e[t+1]=c,e[t+2]=l,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,i,r,s){let o=n[i],a=n[i+1],c=n[i+2],l=n[i+3],u=r[s],f=r[s+1],h=r[s+2],d=r[s+3];return e[t]=o*d+l*u+a*h-c*f,e[t+1]=a*d+l*f+c*u-o*h,e[t+2]=c*d+l*h+o*f-a*u,e[t+3]=l*d-o*u-a*f-c*h,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=!0){let{_x:n,_y:i,_z:r,_order:s}=e,{cos:o,sin:a}=Math,c=o(n/2),l=o(i/2),u=o(r/2),f=a(n/2),h=a(i/2),d=a(r/2);switch(s){case"XYZ":this._x=f*l*u+c*h*d,this._y=c*h*u-f*l*d,this._z=c*l*d+f*h*u,this._w=c*l*u-f*h*d;break;case"YXZ":this._x=f*l*u+c*h*d,this._y=c*h*u-f*l*d,this._z=c*l*d-f*h*u,this._w=c*l*u+f*h*d;break;case"ZXY":this._x=f*l*u-c*h*d,this._y=c*h*u+f*l*d,this._z=c*l*d+f*h*u,this._w=c*l*u-f*h*d;break;case"ZYX":this._x=f*l*u-c*h*d,this._y=c*h*u+f*l*d,this._z=c*l*d-f*h*u,this._w=c*l*u+f*h*d;break;case"YZX":this._x=f*l*u+c*h*d,this._y=c*h*u+f*l*d,this._z=c*l*d-f*h*u,this._w=c*l*u-f*h*d;break;case"XZY":this._x=f*l*u-c*h*d,this._y=c*h*u-f*l*d,this._z=c*l*d+f*h*u,this._w=c*l*u+f*h*d;break;default:Ie("Quaternion: .setFromEuler() encountered an unknown order: "+s)}if(t===!0)this._onChangeCallback();return this}setFromAxisAngle(e,t){let 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){let t=e.elements,n=t[0],i=t[4],r=t[8],s=t[1],o=t[5],a=t[9],c=t[2],l=t[6],u=t[10],f=n+o+u;if(f>0){let h=0.5/Math.sqrt(f+1);this._w=0.25/h,this._x=(l-a)*h,this._y=(r-c)*h,this._z=(s-i)*h}else if(n>o&&n>u){let h=2*Math.sqrt(1+n-o-u);this._w=(l-a)/h,this._x=0.25*h,this._y=(i+s)/h,this._z=(r+c)/h}else if(o>u){let h=2*Math.sqrt(1+o-n-u);this._w=(r-c)/h,this._x=(i+s)/h,this._y=0.25*h,this._z=(a+l)/h}else{let h=2*Math.sqrt(1+u-n-o);this._w=(s-i)/h,this._x=(r+c)/h,this._y=(a+l)/h,this._z=0.25*h}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;if(n<0.00000001)if(n=0,Math.abs(e.x)>Math.abs(e.z))this._x=-e.y,this._y=e.x,this._z=0,this._w=n;else this._x=0,this._y=-e.z,this._z=e.y,this._w=n;else 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;return this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(We(this.dot(e),-1,1)))}rotateTowards(e,t){let n=this.angleTo(e);if(n===0)return this;let 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();if(e===0)this._x=0,this._y=0,this._z=0,this._w=1;else e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e;return this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){let{_x:n,_y:i,_z:r,_w:s}=e,{_x:o,_y:a,_z:c,_w:l}=t;return this._x=n*l+s*o+i*c-r*a,this._y=i*l+s*a+r*o-n*c,this._z=r*l+s*c+n*a-i*o,this._w=s*l-n*o-i*a-r*c,this._onChangeCallback(),this}slerp(e,t){let{_x:n,_y:i,_z:r,_w:s}=e,o=this.dot(e);if(o<0)n=-n,i=-i,r=-r,s=-s,o=-o;let a=1-t;if(o<0.9995){let c=Math.acos(o),l=Math.sin(c);a=Math.sin(a*c)/l,t=Math.sin(t*c)/l,this._x=this._x*a+n*t,this._y=this._y*a+i*t,this._z=this._z*a+r*t,this._w=this._w*a+s*t,this._onChangeCallback()}else this._x=this._x*a+n*t,this._y=this._y*a+i*t,this._z=this._z*a+r*t,this._w=this._w*a+s*t,this.normalize();return this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){let e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),i=Math.sqrt(1-n),r=Math.sqrt(n);return this.set(i*Math.sin(e),i*Math.cos(e),r*Math.sin(t),r*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class O{static{O.prototype.isVector3=!0}constructor(e=0,t=0,n=0){this.x=e,this.y=t,this.z=n}set(e,t,n){if(n===void 0)n=this.z;return this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw Error("THREE.Vector3: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw Error("THREE.Vector3: 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(Lf.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Lf.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6]*i,this.y=r[1]*t+r[4]*n+r[7]*i,this.z=r[2]*t+r[5]*n+r[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,n=this.y,i=this.z,r=e.elements,s=1/(r[3]*t+r[7]*n+r[11]*i+r[15]);return this.x=(r[0]*t+r[4]*n+r[8]*i+r[12])*s,this.y=(r[1]*t+r[5]*n+r[9]*i+r[13])*s,this.z=(r[2]*t+r[6]*n+r[10]*i+r[14])*s,this}applyQuaternion(e){let t=this.x,n=this.y,i=this.z,{x:r,y:s,z:o,w:a}=e,c=2*(s*i-o*n),l=2*(o*t-r*i),u=2*(r*n-s*t);return this.x=t+a*c+s*u-o*l,this.y=n+a*l+o*c-r*u,this.z=i+a*u+r*l-s*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[4]*n+r[8]*i,this.y=r[1]*t+r[5]*n+r[9]*i,this.z=r[2]*t+r[6]*n+r[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=We(this.x,e.x,t.x),this.y=We(this.y,e.y,t.y),this.z=We(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=We(this.x,e,t),this.y=We(this.y,e,t),this.z=We(this.z,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(We(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){let{x:n,y:i,z:r}=e,{x:s,y:o,z:a}=t;return this.x=i*a-r*o,this.y=r*s-n*a,this.z=n*o-i*s,this}projectOnVector(e){let t=e.lengthSq();if(t===0)return this.set(0,0,0);let n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return Hc.copy(this).projectOnVector(e),this.sub(Hc)}reflect(e){return this.sub(Hc.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(We(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let 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){let 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){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){let t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),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(){let e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}var Hc=new O,Lf=new Ht;class ze{static{ze.prototype.isMatrix3=!0}constructor(e,t,n,i,r,s,o,a,c){if(this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0)this.set(e,t,n,i,r,s,o,a,c)}set(e,t,n,i,r,s,o,a,c){let l=this.elements;return l[0]=e,l[1]=i,l[2]=o,l[3]=t,l[4]=r,l[5]=a,l[6]=n,l[7]=s,l[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){let t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,i=t.elements,r=this.elements,s=n[0],o=n[3],a=n[6],c=n[1],l=n[4],u=n[7],f=n[2],h=n[5],d=n[8],g=i[0],x=i[3],p=i[6],m=i[1],E=i[4],R=i[7],v=i[2],M=i[5],T=i[8];return r[0]=s*g+o*m+a*v,r[3]=s*x+o*E+a*M,r[6]=s*p+o*R+a*T,r[1]=c*g+l*m+u*v,r[4]=c*x+l*E+u*M,r[7]=c*p+l*R+u*T,r[2]=f*g+h*m+d*v,r[5]=f*x+h*E+d*M,r[8]=f*p+h*R+d*T,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],s=e[4],o=e[5],a=e[6],c=e[7],l=e[8];return t*s*l-t*o*c-n*r*l+n*o*a+i*r*c-i*s*a}invert(){let e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],s=e[4],o=e[5],a=e[6],c=e[7],l=e[8],u=l*s-o*c,f=o*a-l*r,h=c*r-s*a,d=t*u+n*f+i*h;if(d===0)return this.set(0,0,0,0,0,0,0,0,0);let g=1/d;return e[0]=u*g,e[1]=(i*c-l*n)*g,e[2]=(o*n-i*s)*g,e[3]=f*g,e[4]=(l*t-i*a)*g,e[5]=(i*r-o*t)*g,e[6]=h*g,e[7]=(n*a-c*t)*g,e[8]=(s*t-n*r)*g,this}transpose(){let e,t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){let t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,i,r,s,o){let a=Math.cos(r),c=Math.sin(r);return this.set(n*a,n*c,-n*(a*s+c*o)+s+e,-i*c,i*a,-i*(-c*s+a*o)+o+t,0,0,1),this}scale(e,t){return xr("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(Vc.makeScale(e,t)),this}rotate(e){return xr("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(Vc.makeRotation(-e)),this}translate(e,t){return xr("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(Vc.makeTranslation(e,t)),this}makeTranslation(e,t){if(e.isVector2)this.set(1,0,e.x,0,1,e.y,0,0,1);else this.set(1,0,e,0,1,t,0,0,1);return this}makeRotation(e){let 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){let 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){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}}var Vc=new ze,Nf=new ze().set(0.4123908,0.3575843,0.1804808,0.212639,0.7151687,0.0721923,0.0193308,0.1191948,0.9505322),Df=new ze().set(3.2409699,-1.5373832,-0.4986108,-0.9692436,1.8759675,0.0415551,0.0556301,-0.203977,1.0569715);function zv(){let e={enabled:!0,workingColorSpace:"srgb-linear",spaces:{},convert:function(r,s,o){if(this.enabled===!1||s===o||!s||!o)return r;if(this.spaces[s].transfer==="srgb")r.r=Ai(r.r),r.g=Ai(r.g),r.b=Ai(r.b);if(this.spaces[s].primaries!==this.spaces[o].primaries)r.applyMatrix3(this.spaces[s].toXYZ),r.applyMatrix3(this.spaces[o].fromXYZ);if(this.spaces[o].transfer==="srgb")r.r=ts(r.r),r.g=ts(r.g),r.b=ts(r.b);return r},workingToColorSpace:function(r,s){return this.convert(r,this.workingColorSpace,s)},colorSpaceToWorking:function(r,s){return this.convert(r,s,this.workingColorSpace)},getPrimaries:function(r){return this.spaces[r].primaries},getTransfer:function(r){if(r==="")return"linear";return this.spaces[r].transfer},getToneMappingMode:function(r){return this.spaces[r].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(r,s=this.workingColorSpace){return r.fromArray(this.spaces[s].luminanceCoefficients)},define:function(r){Object.assign(this.spaces,r)},_getMatrix:function(r,s,o){return r.copy(this.spaces[s].toXYZ).multiply(this.spaces[o].fromXYZ)},_getDrawingBufferColorSpace:function(r){return this.spaces[r].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(r=this.workingColorSpace){return this.spaces[r].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(r,s){return xr("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),e.workingToColorSpace(r,s)},toWorkingColorSpace:function(r,s){return xr("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),e.colorSpaceToWorking(r,s)}},t=[0.64,0.33,0.3,0.6,0.15,0.06],n=[0.2126,0.7152,0.0722],i=[0.3127,0.329];return e.define({["srgb-linear"]:{primaries:t,whitePoint:i,transfer:"linear",toXYZ:Nf,fromXYZ:Df,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:"srgb"},outputColorSpaceConfig:{drawingBufferColorSpace:"srgb"}},["srgb"]:{primaries:t,whitePoint:i,transfer:"srgb",toXYZ:Nf,fromXYZ:Df,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:"srgb"}}}),e}var $e=zv();function Ai(e){return e<0.04045?e*0.0773993808:Math.pow(e*0.9478672986+0.0521327014,2.4)}function ts(e){return e<0.0031308?e*12.92:1.055*Math.pow(e,0.41666)-0.055}var Gr;class du{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src))return e.src;if(typeof HTMLCanvasElement>"u")return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{if(Gr===void 0)Gr=ns("canvas");Gr.width=e.width,Gr.height=e.height;let i=Gr.getContext("2d");if(e instanceof ImageData)i.putImageData(e,0,0);else i.drawImage(e,0,0,e.width,e.height);n=Gr}return n.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){let t=ns("canvas");t.width=e.width,t.height=e.height;let n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);let i=n.getImageData(0,0,e.width,e.height),r=i.data;for(let s=0;s<r.length;s++)r[s]=Ai(r[s]/255)*255;return n.putImageData(i,0,0),t}else if(e.data){let t=e.data.slice(0);for(let n=0;n<t.length;n++)if(t instanceof Uint8Array||t instanceof Uint8ClampedArray)t[n]=Math.floor(Ai(t[n]/255)*255);else t[n]=Ai(t[n]);return{data:t,width:e.width,height:e.height}}else return Ie("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}var kv=0;class Ys{constructor(e=null){this.isTextureSource=!0,Object.defineProperty(this,"id",{value:kv++}),this.uuid=Gn(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){let t=this.data;if(typeof HTMLVideoElement<"u"&&t instanceof HTMLVideoElement)e.set(t.videoWidth,t.videoHeight,0);else if(typeof VideoFrame<"u"&&t instanceof VideoFrame)e.set(t.displayWidth,t.displayHeight,0);else if(t!==null)e.set(t.width,t.height,t.depth||0);else e.set(0,0,0);return e}set needsUpdate(e){if(e===!0)this.version++}toJSON(e){let t=e===void 0||typeof e==="string";if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];let n={uuid:this.uuid,url:""},i=this.data;if(i!==null){let r;if(Array.isArray(i)){r=[];for(let s=0,o=i.length;s<o;s++)if(i[s].isDataTexture)r.push($c(i[s].image));else r.push($c(i[s]))}else r=$c(i);n.url=r}if(!t)e.images[this.uuid]=n;return n}}function $c(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap)return du.getDataURL(e);else if(e.data)return{data:Array.from(e.data),width:e.width,height:e.height,type:e.data.constructor.name};else return Ie("Texture: Unable to serialize Texture."),{}}var Bv=0,Wc=new O;class At extends Wn{constructor(e=At.DEFAULT_IMAGE,t=At.DEFAULT_MAPPING,n=1001,i=1001,r=1006,s=1008,o=1023,a=1009,c=At.DEFAULT_ANISOTROPY,l=""){super();this.isTexture=!0,Object.defineProperty(this,"id",{value:Bv++}),this.uuid=Gn(),this.name="",this.source=new Ys(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=n,this.wrapT=i,this.magFilter=r,this.minFilter=s,this.anisotropy=c,this.format=o,this.internalFormat=null,this.type=a,this.offset=new Ne(0,0),this.repeat=new Ne(1,1),this.center=new Ne(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new ze,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=l,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=e&&e.depth&&e.depth>1?!0:!1,this.pmremVersion=0,this.normalized=!1}get width(){return this.source.getSize(Wc).x}get height(){return this.source.getSize(Wc).y}get depth(){return this.source.getSize(Wc).z}get image(){return this.source.data}set image(e){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.normalized=e.normalized,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(let t in e){let n=e[t];if(n===void 0){Ie(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}let i=this[t];if(i===void 0){Ie(`Texture.setValues(): property '${t}' does not exist.`);continue}if(i&&n&&(i.isVector2&&n.isVector2))i.copy(n);else if(i&&n&&(i.isVector3&&n.isVector3))i.copy(n);else if(i&&n&&(i.isMatrix3&&n.isMatrix3))i.copy(n);else this[t]=n}}toJSON(e){let t=e===void 0||typeof e==="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];let n={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,normalized:this.normalized,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};if(Object.keys(this.userData).length>0)n.userData=this.userData;if(!t)e.textures[this.uuid]=n;return n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==300)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case 1000:e.x=e.x-Math.floor(e.x);break;case 1001:e.x=e.x<0?0:1;break;case 1002:if(Math.abs(Math.floor(e.x)%2)===1)e.x=Math.ceil(e.x)-e.x;else e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case 1000:e.y=e.y-Math.floor(e.y);break;case 1001:e.y=e.y<0?0:1;break;case 1002:if(Math.abs(Math.floor(e.y)%2)===1)e.y=Math.ceil(e.y)-e.y;else e.y=e.y-Math.floor(e.y);break}if(this.flipY)e.y=1-e.y;return e}set needsUpdate(e){if(e===!0)this.version++,this.source.needsUpdate=!0}set needsPMREMUpdate(e){if(e===!0)this.pmremVersion++}}At.DEFAULT_IMAGE=null;At.DEFAULT_MAPPING=300;At.DEFAULT_ANISOTROPY=1;class at{static{at.prototype.isVector4=!0}constructor(e=0,t=0,n=0,i=1){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 Error("THREE.Vector4: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw Error("THREE.Vector4: 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){let t=this.x,n=this.y,i=this.z,r=this.w,s=e.elements;return this.x=s[0]*t+s[4]*n+s[8]*i+s[12]*r,this.y=s[1]*t+s[5]*n+s[9]*i+s[13]*r,this.z=s[2]*t+s[6]*n+s[10]*i+s[14]*r,this.w=s[3]*t+s[7]*n+s[11]*i+s[15]*r,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);let t=Math.sqrt(1-e.w*e.w);if(t<0.0001)this.x=1,this.y=0,this.z=0;else this.x=e.x/t,this.y=e.y/t,this.z=e.z/t;return this}setAxisAngleFromRotationMatrix(e){let t,n,i,r,s=0.01,o=0.1,a=e.elements,c=a[0],l=a[4],u=a[8],f=a[1],h=a[5],d=a[9],g=a[2],x=a[6],p=a[10];if(Math.abs(l-f)<0.01&&Math.abs(u-g)<0.01&&Math.abs(d-x)<0.01){if(Math.abs(l+f)<0.1&&Math.abs(u+g)<0.1&&Math.abs(d+x)<0.1&&Math.abs(c+h+p-3)<0.1)return this.set(1,0,0,0),this;t=Math.PI;let E=(c+1)/2,R=(h+1)/2,v=(p+1)/2,M=(l+f)/4,T=(u+g)/4,A=(d+x)/4;if(E>R&&E>v)if(E<0.01)n=0,i=0.707106781,r=0.707106781;else n=Math.sqrt(E),i=M/n,r=T/n;else if(R>v)if(R<0.01)n=0.707106781,i=0,r=0.707106781;else i=Math.sqrt(R),n=M/i,r=A/i;else if(v<0.01)n=0.707106781,i=0.707106781,r=0;else r=Math.sqrt(v),n=T/r,i=A/r;return this.set(n,i,r,t),this}let m=Math.sqrt((x-d)*(x-d)+(u-g)*(u-g)+(f-l)*(f-l));if(Math.abs(m)<0.001)m=1;return this.x=(x-d)/m,this.y=(u-g)/m,this.z=(f-l)/m,this.w=Math.acos((c+h+p-1)/2),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],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=We(this.x,e.x,t.x),this.y=We(this.y,e.y,t.y),this.z=We(this.z,e.z,t.z),this.w=We(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=We(this.x,e,t),this.y=We(this.y,e,t),this.z=We(this.z,e,t),this.w=We(this.w,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(We(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class pu extends Wn{constructor(e=1,t=1,n={}){super();n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:1006,depthBuffer:!0,stencilBuffer:!1,resolveColorBuffer:!0,resolveDepthBuffer:!0,resolveStencilBuffer:!0,storeMultisampledColorBuffer:!0,storeMultisampledDepthBuffer:!0,storeMultisampledStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1,useArrayDepthTexture:!1},n),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=n.depth,this.scissor=new at(0,0,e,t),this.scissorTest=!1,this.viewport=new at(0,0,e,t),this.textures=[];let i={width:e,height:t,depth:n.depth},r=new At(i),s=n.count;for(let o=0;o<s;o++)this.textures[o]=r.clone(),this.textures[o].isRenderTargetTexture=!0,this.textures[o].renderTarget=this;this._setTextureOptions(n),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveColorBuffer=n.resolveColorBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this.storeMultisampledColorBuffer=n.storeMultisampledColorBuffer,this.storeMultisampledDepthBuffer=n.storeMultisampledDepthBuffer,this.storeMultisampledStencilBuffer=n.storeMultisampledStencilBuffer,this._depthTexture=null,this.depthTexture=n.depthTexture,this.samples=n.samples,this.multiview=n.multiview,this.useArrayDepthTexture=n.useArrayDepthTexture}_setTextureOptions(e={}){let t={minFilter:1006,generateMipmaps:!1,flipY:!1,internalFormat:null};if(e.mapping!==void 0)t.mapping=e.mapping;if(e.wrapS!==void 0)t.wrapS=e.wrapS;if(e.wrapT!==void 0)t.wrapT=e.wrapT;if(e.wrapR!==void 0)t.wrapR=e.wrapR;if(e.magFilter!==void 0)t.magFilter=e.magFilter;if(e.minFilter!==void 0)t.minFilter=e.minFilter;if(e.format!==void 0)t.format=e.format;if(e.type!==void 0)t.type=e.type;if(e.anisotropy!==void 0)t.anisotropy=e.anisotropy;if(e.colorSpace!==void 0)t.colorSpace=e.colorSpace;if(e.flipY!==void 0)t.flipY=e.flipY;if(e.generateMipmaps!==void 0)t.generateMipmaps=e.generateMipmaps;if(e.internalFormat!==void 0)t.internalFormat=e.internalFormat;for(let n=0;n<this.textures.length;n++)this.textures[n].setValues(t)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){if(this._depthTexture!==null&&this._depthTexture.renderTarget===this)this._depthTexture.renderTarget=null;if(e!==null&&e.renderTarget===null)e.renderTarget=this;this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,t,n=1){if(this.width!==e||this.height!==t||this.depth!==n){this.width=e,this.height=t,this.depth=n;for(let i=0,r=this.textures.length;i<r;i++)if(this.textures[i].image.width=e,this.textures[i].image.height=t,this.textures[i].image.depth=n,this.textures[i].isData3DTexture!==!0)this.textures[i].isArrayTexture=this.textures[i].image.depth>1;this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,n=e.textures.length;t<n;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;let i=Object.assign({},e.textures[t].image);this.textures[t].source=new Ys(i)}if(this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveColorBuffer=e.resolveColorBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,this.storeMultisampledColorBuffer=e.storeMultisampledColorBuffer,this.storeMultisampledDepthBuffer=e.storeMultisampledDepthBuffer,this.storeMultisampledStencilBuffer=e.storeMultisampledStencilBuffer,e.depthTexture!==null)if(e.depthTexture.renderTarget===e){let t=e.depthTexture.clone();t.renderTarget=null,this.depthTexture=t}else this.depthTexture=e.depthTexture;return this.samples=e.samples,this.multiview=e.multiview,this.useArrayDepthTexture=e.useArrayDepthTexture,this}dispose(){this.dispatchEvent({type:"dispose"})}}class _n extends pu{constructor(e=1,t=1,n={}){super(e,t,n);this.isWebGLRenderTarget=!0}}class Na extends At{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=1003,this.minFilter=1003,this.wrapR=1001,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}copy(e){return super.copy(e),this.wrapR=e.wrapR,this}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class mu extends At{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=1003,this.minFilter=1003,this.wrapR=1001,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}copy(e){return super.copy(e),this.wrapR=e.wrapR,this}}class Ge{static{Ge.prototype.isMatrix4=!0}constructor(e,t,n,i,r,s,o,a,c,l,u,f,h,d,g,x){if(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,r,s,o,a,c,l,u,f,h,d,g,x)}set(e,t,n,i,r,s,o,a,c,l,u,f,h,d,g,x){let p=this.elements;return p[0]=e,p[4]=t,p[8]=n,p[12]=i,p[1]=r,p[5]=s,p[9]=o,p[13]=a,p[2]=c,p[6]=l,p[10]=u,p[14]=f,p[3]=h,p[7]=d,p[11]=g,p[15]=x,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 Ge().fromArray(this.elements)}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){let t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){let 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){if(this.determinantAffine()===0)return e.set(1,0,0),t.set(0,1,0),n.set(0,0,1),this;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){if(e.determinantAffine()===0)return this.identity();let t=this.elements,n=e.elements,i=1/Hr.setFromMatrixColumn(e,0).length(),r=1/Hr.setFromMatrixColumn(e,1).length(),s=1/Hr.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]*r,t[5]=n[5]*r,t[6]=n[6]*r,t[7]=0,t[8]=n[8]*s,t[9]=n[9]*s,t[10]=n[10]*s,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){let t=this.elements,{x:n,y:i,z:r}=e,s=Math.cos(n),o=Math.sin(n),a=Math.cos(i),c=Math.sin(i),l=Math.cos(r),u=Math.sin(r);if(e.order==="XYZ"){let f=s*l,h=s*u,d=o*l,g=o*u;t[0]=a*l,t[4]=-a*u,t[8]=c,t[1]=h+d*c,t[5]=f-g*c,t[9]=-o*a,t[2]=g-f*c,t[6]=d+h*c,t[10]=s*a}else if(e.order==="YXZ"){let f=a*l,h=a*u,d=c*l,g=c*u;t[0]=f+g*o,t[4]=d*o-h,t[8]=s*c,t[1]=s*u,t[5]=s*l,t[9]=-o,t[2]=h*o-d,t[6]=g+f*o,t[10]=s*a}else if(e.order==="ZXY"){let f=a*l,h=a*u,d=c*l,g=c*u;t[0]=f-g*o,t[4]=-s*u,t[8]=d+h*o,t[1]=h+d*o,t[5]=s*l,t[9]=g-f*o,t[2]=-s*c,t[6]=o,t[10]=s*a}else if(e.order==="ZYX"){let f=s*l,h=s*u,d=o*l,g=o*u;t[0]=a*l,t[4]=d*c-h,t[8]=f*c+g,t[1]=a*u,t[5]=g*c+f,t[9]=h*c-d,t[2]=-c,t[6]=o*a,t[10]=s*a}else if(e.order==="YZX"){let f=s*a,h=s*c,d=o*a,g=o*c;t[0]=a*l,t[4]=g-f*u,t[8]=d*u+h,t[1]=u,t[5]=s*l,t[9]=-o*l,t[2]=-c*l,t[6]=h*u+d,t[10]=f-g*u}else if(e.order==="XZY"){let f=s*a,h=s*c,d=o*a,g=o*c;t[0]=a*l,t[4]=-u,t[8]=c*l,t[1]=f*u+g,t[5]=s*l,t[9]=h*u-d,t[2]=d*u-h,t[6]=o*l,t[10]=g*u+f}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(Gv,e,Hv)}lookAt(e,t,n){let i=this.elements;if(pn.subVectors(e,t),pn.lengthSq()===0)pn.z=1;if(pn.normalize(),ki.crossVectors(n,pn),ki.lengthSq()===0){if(Math.abs(n.z)===1)pn.x+=0.0001;else pn.z+=0.0001;pn.normalize(),ki.crossVectors(n,pn)}return ki.normalize(),Zo.crossVectors(pn,ki),i[0]=ki.x,i[4]=Zo.x,i[8]=pn.x,i[1]=ki.y,i[5]=Zo.y,i[9]=pn.y,i[2]=ki.z,i[6]=Zo.z,i[10]=pn.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,i=t.elements,r=this.elements,s=n[0],o=n[4],a=n[8],c=n[12],l=n[1],u=n[5],f=n[9],h=n[13],d=n[2],g=n[6],x=n[10],p=n[14],m=n[3],E=n[7],R=n[11],v=n[15],M=i[0],T=i[4],A=i[8],_=i[12],S=i[1],z=i[5],P=i[9],F=i[13],ee=i[2],I=i[6],H=i[10],q=i[14],C=i[3],X=i[7],k=i[11],Y=i[15];return r[0]=s*M+o*S+a*ee+c*C,r[4]=s*T+o*z+a*I+c*X,r[8]=s*A+o*P+a*H+c*k,r[12]=s*_+o*F+a*q+c*Y,r[1]=l*M+u*S+f*ee+h*C,r[5]=l*T+u*z+f*I+h*X,r[9]=l*A+u*P+f*H+h*k,r[13]=l*_+u*F+f*q+h*Y,r[2]=d*M+g*S+x*ee+p*C,r[6]=d*T+g*z+x*I+p*X,r[10]=d*A+g*P+x*H+p*k,r[14]=d*_+g*F+x*q+p*Y,r[3]=m*M+E*S+R*ee+v*C,r[7]=m*T+E*z+R*I+v*X,r[11]=m*A+E*P+R*H+v*k,r[15]=m*_+E*F+R*q+v*Y,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[4],i=e[8],r=e[12],s=e[1],o=e[5],a=e[9],c=e[13],l=e[2],u=e[6],f=e[10],h=e[14],d=e[3],g=e[7],x=e[11],p=e[15],m=a*h-c*f,E=o*h-c*u,R=o*f-a*u,v=s*h-c*l,M=s*f-a*l,T=s*u-o*l;return t*(g*m-x*E+p*R)-n*(d*m-x*v+p*M)+i*(d*E-g*v+p*T)-r*(d*R-g*M+x*T)}determinantAffine(){let e=this.elements,t=e[0],n=e[4],i=e[8],r=e[1],s=e[5],o=e[9],a=e[2],c=e[6],l=e[10];return t*(s*l-o*c)-n*(r*l-o*a)+i*(r*c-s*a)}transpose(){let e=this.elements,t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){let i=this.elements;if(e.isVector3)i[12]=e.x,i[13]=e.y,i[14]=e.z;else i[12]=e,i[13]=t,i[14]=n;return this}invert(){let e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],s=e[4],o=e[5],a=e[6],c=e[7],l=e[8],u=e[9],f=e[10],h=e[11],d=e[12],g=e[13],x=e[14],p=e[15],m=t*o-n*s,E=t*a-i*s,R=t*c-r*s,v=n*a-i*o,M=n*c-r*o,T=i*c-r*a,A=l*g-u*d,_=l*x-f*d,S=l*p-h*d,z=u*x-f*g,P=u*p-h*g,F=f*p-h*x,ee=m*F-E*P+R*z+v*S-M*_+T*A;if(ee===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let I=1/ee;return e[0]=(o*F-a*P+c*z)*I,e[1]=(i*P-n*F-r*z)*I,e[2]=(g*T-x*M+p*v)*I,e[3]=(f*M-u*T-h*v)*I,e[4]=(a*S-s*F-c*_)*I,e[5]=(t*F-i*S+r*_)*I,e[6]=(x*R-d*T-p*E)*I,e[7]=(l*T-f*R+h*E)*I,e[8]=(s*P-o*S+c*A)*I,e[9]=(n*S-t*P-r*A)*I,e[10]=(d*M-g*R+p*m)*I,e[11]=(u*R-l*M-h*m)*I,e[12]=(o*_-s*z-a*A)*I,e[13]=(t*z-n*_+i*A)*I,e[14]=(g*E-d*v-x*m)*I,e[15]=(l*v-u*E+f*m)*I,this}scale(e){let t=this.elements,{x:n,y:i,z:r}=e;return t[0]*=n,t[4]*=i,t[8]*=r,t[1]*=n,t[5]*=i,t[9]*=r,t[2]*=n,t[6]*=i,t[10]*=r,t[3]*=n,t[7]*=i,t[11]*=r,this}getMaxScaleOnAxis(){let e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],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){if(e.isVector3)this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1);else this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1);return this}makeRotationX(e){let t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){let n=Math.cos(t),i=Math.sin(t),r=1-n,{x:s,y:o,z:a}=e,c=r*s,l=r*o;return this.set(c*s+n,c*o-i*a,c*a+i*o,0,c*o+i*a,l*o+n,l*a-i*s,0,c*a-i*o,l*a+i*s,r*a*a+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,r,s){return this.set(1,n,r,0,e,1,s,0,t,i,1,0,0,0,0,1),this}compose(e,t,n){let i=this.elements,{_x:r,_y:s,_z:o,_w:a}=t,c=r+r,l=s+s,u=o+o,f=r*c,h=r*l,d=r*u,g=s*l,x=s*u,p=o*u,m=a*c,E=a*l,R=a*u,{x:v,y:M,z:T}=n;return i[0]=(1-(g+p))*v,i[1]=(h+R)*v,i[2]=(d-E)*v,i[3]=0,i[4]=(h-R)*M,i[5]=(1-(f+p))*M,i[6]=(x+m)*M,i[7]=0,i[8]=(d+E)*T,i[9]=(x-m)*T,i[10]=(1-(f+g))*T,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,t,n){let i=this.elements;e.x=i[12],e.y=i[13],e.z=i[14];let r=this.determinantAffine();if(r===0)return n.set(1,1,1),t.identity(),this;let s=Hr.set(i[0],i[1],i[2]).length(),o=Hr.set(i[4],i[5],i[6]).length(),a=Hr.set(i[8],i[9],i[10]).length();if(r<0)s=-s;Fn.copy(this);let c=1/s,l=1/o,u=1/a;return Fn.elements[0]*=c,Fn.elements[1]*=c,Fn.elements[2]*=c,Fn.elements[4]*=l,Fn.elements[5]*=l,Fn.elements[6]*=l,Fn.elements[8]*=u,Fn.elements[9]*=u,Fn.elements[10]*=u,t.setFromRotationMatrix(Fn),n.x=s,n.y=o,n.z=a,this}makePerspective(e,t,n,i,r,s,o=2000,a=!1){let c=this.elements,l=2*r/(t-e),u=2*r/(n-i),f=(t+e)/(t-e),h=(n+i)/(n-i),d,g;if(a)d=r/(s-r),g=s*r/(s-r);else if(o===2000)d=-(s+r)/(s-r),g=-2*s*r/(s-r);else if(o===2001)d=-s/(s-r),g=-s*r/(s-r);else throw Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return c[0]=l,c[4]=0,c[8]=f,c[12]=0,c[1]=0,c[5]=u,c[9]=h,c[13]=0,c[2]=0,c[6]=0,c[10]=d,c[14]=g,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,t,n,i,r,s,o=2000,a=!1){let c=this.elements,l=2/(t-e),u=2/(n-i),f=-(t+e)/(t-e),h=-(n+i)/(n-i),d,g;if(a)d=1/(s-r),g=s/(s-r);else if(o===2000)d=-2/(s-r),g=-(s+r)/(s-r);else if(o===2001)d=-1/(s-r),g=-r/(s-r);else throw Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return c[0]=l,c[4]=0,c[8]=0,c[12]=f,c[1]=0,c[5]=u,c[9]=0,c[13]=h,c[2]=0,c[6]=0,c[10]=d,c[14]=g,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){let 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){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}}var Hr=new O,Fn=new Ge,Gv=new O(0,0,0),Hv=new O(1,1,1),ki=new O,Zo=new O,pn=new O,Of=new Ge,Uf=new Ht;class ni{constructor(e=0,t=0,n=0,i=ni.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){let i=e.elements,r=i[0],s=i[4],o=i[8],a=i[1],c=i[5],l=i[9],u=i[2],f=i[6],h=i[10];switch(t){case"XYZ":if(this._y=Math.asin(We(o,-1,1)),Math.abs(o)<0.9999999)this._x=Math.atan2(-l,h),this._z=Math.atan2(-s,r);else this._x=Math.atan2(f,c),this._z=0;break;case"YXZ":if(this._x=Math.asin(-We(l,-1,1)),Math.abs(l)<0.9999999)this._y=Math.atan2(o,h),this._z=Math.atan2(a,c);else this._y=Math.atan2(-u,r),this._z=0;break;case"ZXY":if(this._x=Math.asin(We(f,-1,1)),Math.abs(f)<0.9999999)this._y=Math.atan2(-u,h),this._z=Math.atan2(-s,c);else this._y=0,this._z=Math.atan2(a,r);break;case"ZYX":if(this._y=Math.asin(-We(u,-1,1)),Math.abs(u)<0.9999999)this._x=Math.atan2(f,h),this._z=Math.atan2(a,r);else this._x=0,this._z=Math.atan2(-s,c);break;case"YZX":if(this._z=Math.asin(We(a,-1,1)),Math.abs(a)<0.9999999)this._x=Math.atan2(-l,c),this._y=Math.atan2(-u,r);else this._x=0,this._y=Math.atan2(o,h);break;case"XZY":if(this._z=Math.asin(-We(s,-1,1)),Math.abs(s)<0.9999999)this._x=Math.atan2(f,c),this._y=Math.atan2(o,r);else this._x=Math.atan2(-l,h),this._y=0;break;default:Ie("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}if(this._order=t,n===!0)this._onChangeCallback();return this}setFromQuaternion(e,t,n){return Of.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Of,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return Uf.setFromEuler(this),this.setFromQuaternion(Uf,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){if(this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0)this._order=e[3];return 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}}ni.DEFAULT_ORDER="XYZ";class Da{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}}var Vv=0,Ff=new O,Vr=new Ht,bi=new Ge,Xo=new O,Ls=new O,$v=new O,Wv=new Ht,zf=new O(1,0,0),kf=new O(0,1,0),Bf=new O(0,0,1),Gf={type:"added"},Zv={type:"removed"},$r={type:"childadded",child:null},Zc={type:"childremoved",child:null};class ut extends Wn{constructor(){super();this.isObject3D=!0,Object.defineProperty(this,"id",{value:Vv++}),this.uuid=Gn(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=ut.DEFAULT_UP.clone();let e=new O,t=new ni,n=new Ht,i=new O(1,1,1);function r(){n.setFromEuler(t,!1)}function s(){t.setFromQuaternion(n,void 0,!1)}t._onChange(r),n._onChange(s),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new Ge},normalMatrix:{value:new ze}}),this.matrix=new Ge,this.matrixWorld=new Ge,this.matrixAutoUpdate=ut.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=ut.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new Da,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.static=!1,this.userData={},this.pivot=null}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){if(this.matrixAutoUpdate)this.updateMatrix();this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return Vr.setFromAxisAngle(e,t),this.quaternion.multiply(Vr),this}rotateOnWorldAxis(e,t){return Vr.setFromAxisAngle(e,t),this.quaternion.premultiply(Vr),this}rotateX(e){return this.rotateOnAxis(zf,e)}rotateY(e){return this.rotateOnAxis(kf,e)}rotateZ(e){return this.rotateOnAxis(Bf,e)}translateOnAxis(e,t){return Ff.copy(e).applyQuaternion(this.quaternion),this.position.add(Ff.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(zf,e)}translateY(e){return this.translateOnAxis(kf,e)}translateZ(e){return this.translateOnAxis(Bf,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(bi.copy(this.matrixWorld).invert())}lookAt(e,t,n){if(e.isVector3)Xo.copy(e);else Xo.set(e,t,n);let i=this.parent;if(this.updateWorldMatrix(!0,!1),Ls.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight)bi.lookAt(Ls,Xo,this.up);else bi.lookAt(Xo,Ls,this.up);if(this.quaternion.setFromRotationMatrix(bi),i)bi.extractRotation(i.matrixWorld),Vr.setFromRotationMatrix(bi),this.quaternion.premultiply(Vr.invert())}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}if(e===this)return Ue("Object3D.add: object can't be added as a child of itself.",e),this;if(e&&e.isObject3D)e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(Gf),$r.child=e,this.dispatchEvent($r),$r.child=null;else Ue("Object3D.add: object not an instance of THREE.Object3D.",e);return this}remove(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}let t=this.children.indexOf(e);if(t!==-1)e.parent=null,this.children.splice(t,1),e.dispatchEvent(Zv),Zc.child=e,this.dispatchEvent(Zc),Zc.child=null;return this}removeFromParent(){let e=this.parent;if(e!==null)e.remove(this);return this}clear(){return this.remove(...this.children)}attach(e){if(this.updateWorldMatrix(!0,!1),bi.copy(this.matrixWorld).invert(),e.parent!==null)e.parent.updateWorldMatrix(!0,!1),bi.multiply(e.parent.matrixWorld);return e.applyMatrix4(bi),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(Gf),$r.child=e,this.dispatchEvent($r),$r.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let n=0,i=this.children.length;n<i;n++){let s=this.children[n].getObjectByProperty(e,t);if(s!==void 0)return s}return}getObjectsByProperty(e,t,n=[]){if(this[e]===t)n.push(this);let i=this.children;for(let r=0,s=i.length;r<s;r++)i[r].getObjectsByProperty(e,t,n);return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Ls,e,$v),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Ls,Wv,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);let t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}intersectsFrustum(){}traverse(e){e(this);let t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);let t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].traverseVisible(e)}traverseAncestors(e){let t=this.parent;if(t!==null)e(t),t.traverseAncestors(e)}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);let e=this.pivot;if(e!==null){let{x:t,y:n,z:i}=e,r=this.matrix.elements;r[12]+=t-r[0]*t-r[4]*n-r[8]*i,r[13]+=n-r[1]*t-r[5]*n-r[9]*i,r[14]+=i-r[2]*t-r[6]*n-r[10]*i}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){if(this.matrixAutoUpdate)this.updateMatrix();if(this.matrixWorldNeedsUpdate||e){if(this.matrixWorldAutoUpdate===!0)if(this.parent===null)this.matrixWorld.copy(this.matrix);else this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix);this.matrixWorldNeedsUpdate=!1,e=!0}let t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].updateMatrixWorld(e)}updateWorldMatrix(e,t,n=!1){let i=this.parent;if(e===!0&&i!==null)i.updateWorldMatrix(!0,!1);if(this.matrixAutoUpdate)this.updateMatrix();if(this.matrixWorldNeedsUpdate||n){if(this.matrixWorldAutoUpdate===!0)if(this.parent===null)this.matrixWorld.copy(this.matrix);else this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix);this.matrixWorldNeedsUpdate=!1,n=!0}if(t===!0){let r=this.children;for(let s=0,o=r.length;s<o;s++)r[s].updateWorldMatrix(!1,!0,n)}}toJSON(e){let t=e===void 0||typeof e==="string",n={};if(t)e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"};let i={};if(i.uuid=this.uuid,i.type=this.type,i.name=this.name,i.castShadow=this.castShadow,i.receiveShadow=this.receiveShadow,i.visible=this.visible,i.frustumCulled=this.frustumCulled,i.renderOrder=this.renderOrder,i.static=this.static,i.matrixAutoUpdate=this.matrixAutoUpdate,Object.keys(this.userData).length>0)i.userData=this.userData;if(i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.pivot!==null)i.pivot=this.pivot.toArray();if(this.morphTargetDictionary!==void 0)i.morphTargetDictionary=Object.assign({},this.morphTargetDictionary);if(this.morphTargetInfluences!==void 0)i.morphTargetInfluences=this.morphTargetInfluences.slice();if(this.isInstancedMesh){if(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null)i.instanceColor=this.instanceColor.toJSON()}if(this.isBatchedMesh){if(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.geometryInfo=this._geometryInfo.map((o)=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),i.instanceInfo=this._instanceInfo.map((o)=>({...o})),i.availableInstanceIds=this._availableInstanceIds.slice(),i.availableGeometryIds=this._availableGeometryIds.slice(),i.nextIndexStart=this._nextIndexStart,i.nextVertexStart=this._nextVertexStart,i.geometryCount=this._geometryCount,i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.matricesTexture=this._matricesTexture.toJSON(e),i.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null)i.colorsTexture=this._colorsTexture.toJSON(e);if(this.boundingSphere!==null)i.boundingSphere=this.boundingSphere.toJSON();if(this.boundingBox!==null)i.boundingBox=this.boundingBox.toJSON()}function r(o,a){if(o[a.uuid]===void 0)o[a.uuid]=a.toJSON(e);return a.uuid}if(this.isScene){if(this.background){if(this.background.isColor)i.background=this.background.toJSON();else if(this.background.isTexture)i.background=this.background.toJSON(e).uuid}if(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=r(e.geometries,this.geometry);let o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){let a=o.shapes;if(Array.isArray(a))for(let c=0,l=a.length;c<l;c++){let u=a[c];r(e.shapes,u)}else r(e.shapes,a)}}if(this.isSkinnedMesh){if(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0)r(e.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid}if(this.material!==void 0)if(Array.isArray(this.material)){let o=[];for(let a=0,c=this.material.length;a<c;a++)o.push(r(e.materials,this.material[a]));i.material=o}else i.material=r(e.materials,this.material);if(this.children.length>0){i.children=[];for(let o=0;o<this.children.length;o++)i.children.push(this.children[o].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let o=0;o<this.animations.length;o++){let a=this.animations[o];i.animations.push(r(e.animations,a))}}if(t){let o=s(e.geometries),a=s(e.materials),c=s(e.textures),l=s(e.images),u=s(e.shapes),f=s(e.skeletons),h=s(e.animations),d=s(e.nodes);if(o.length>0)n.geometries=o;if(a.length>0)n.materials=a;if(c.length>0)n.textures=c;if(l.length>0)n.images=l;if(u.length>0)n.shapes=u;if(f.length>0)n.skeletons=f;if(h.length>0)n.animations=h;if(d.length>0)n.nodes=d}return n.object=i,n;function s(o){let a=[];for(let c in o){let l=o[c];delete l.metadata,a.push(l)}return a}}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.pivot=e.pivot!==null?e.pivot.clone():null,this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;n<e.children.length;n++){let i=e.children[n];this.add(i.clone())}return this}dispose(){this.dispatchEvent({type:"dispose"})}}ut.DEFAULT_UP=new O(0,1,0);ut.DEFAULT_MATRIX_AUTO_UPDATE=!0;ut.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;class ei extends ut{constructor(){super();this.isGroup=!0,this.type="Group"}}var Xv={type:"move"};class Ks{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){if(this._hand===null)this._hand=new ei,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1};return this._hand}getTargetRaySpace(){if(this._targetRay===null)this._targetRay=new ei,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new O,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new O;return this._targetRay}getGripSpace(){if(this._grip===null)this._grip=new ei,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new O,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new O,this._grip.eventsEnabled=!1;return this._grip}dispatchEvent(e){if(this._targetRay!==null)this._targetRay.dispatchEvent(e);if(this._grip!==null)this._grip.dispatchEvent(e);if(this._hand!==null)this._hand.dispatchEvent(e);return this}connect(e){if(e&&e.hand){let t=this._hand;if(t)for(let n of e.hand.values())this._getHandJoint(t,n)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){if(this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null)this._targetRay.visible=!1;if(this._grip!==null)this._grip.visible=!1;if(this._hand!==null)this._hand.visible=!1;return this}update(e,t,n){let i=null,r=null,s=null,o=this._targetRay,a=this._grip,c=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(c&&e.hand){s=!0;for(let g of e.hand.values()){let x=t.getJointPose(g,n),p=this._getHandJoint(c,g);if(x!==null)p.matrix.fromArray(x.transform.matrix),p.matrix.decompose(p.position,p.rotation,p.scale),p.matrixWorldNeedsUpdate=!0,p.jointRadius=x.radius;p.visible=x!==null}let l=c.joints["index-finger-tip"],u=c.joints["thumb-tip"],f=l.position.distanceTo(u.position),h=0.02,d=0.005;if(c.inputState.pinching&&f>h+d)c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this});else if(!c.inputState.pinching&&f<=h-d)c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this})}else if(a!==null&&e.gripSpace){if(r=t.getPose(e.gripSpace,n),r!==null){if(a.matrix.fromArray(r.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,r.linearVelocity)a.hasLinearVelocity=!0,a.linearVelocity.copy(r.linearVelocity);else a.hasLinearVelocity=!1;if(r.angularVelocity)a.hasAngularVelocity=!0,a.angularVelocity.copy(r.angularVelocity);else a.hasAngularVelocity=!1;if(a.eventsEnabled)a.dispatchEvent({type:"gripUpdated",data:e,target:this})}}if(o!==null){if(i=t.getPose(e.targetRaySpace,n),i===null&&r!==null)i=r;if(i!==null){if(o.matrix.fromArray(i.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,i.linearVelocity)o.hasLinearVelocity=!0,o.linearVelocity.copy(i.linearVelocity);else o.hasLinearVelocity=!1;if(i.angularVelocity)o.hasAngularVelocity=!0,o.angularVelocity.copy(i.angularVelocity);else o.hasAngularVelocity=!1;this.dispatchEvent(Xv)}}}if(o!==null)o.visible=i!==null;if(a!==null)a.visible=r!==null;if(c!==null)c.visible=s!==null;return this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){let n=new ei;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}var hp={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},Bi={h:0,s:0,l:0},qo={h:0,s:0,l:0};function Xc(e,t,n){if(n<0)n+=1;if(n>1)n-=1;if(n<0.16666666666666666)return e+(t-e)*6*n;if(n<0.5)return t;if(n<0.6666666666666666)return e+(t-e)*6*(0.6666666666666666-n);return e}class Oe{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){let i=e;if(i&&i.isColor)this.copy(i);else if(typeof i==="number")this.setHex(i);else if(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="srgb"){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,$e.colorSpaceToWorking(this,t),this}setRGB(e,t,n,i=$e.workingColorSpace){return this.r=e,this.g=t,this.b=n,$e.colorSpaceToWorking(this,i),this}setHSL(e,t,n,i=$e.workingColorSpace){if(e=fu(e,1),t=We(t,0,1),n=We(n,0,1),t===0)this.r=this.g=this.b=n;else{let r=n<=0.5?n*(1+t):n+t-n*t,s=2*n-r;this.r=Xc(s,r,e+0.3333333333333333),this.g=Xc(s,r,e),this.b=Xc(s,r,e-0.3333333333333333)}return $e.colorSpaceToWorking(this,i),this}setStyle(e,t="srgb"){function n(r){if(r===void 0)return;if(parseFloat(r)<1)Ie("Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let r,s=i[1],o=i[2];switch(s){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,t);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,t);break;default:Ie("Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){let r=i[1],s=r.length;if(s===3)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,t);else if(s===6)return this.setHex(parseInt(r,16),t);else Ie("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t="srgb"){let n=hp[e.toLowerCase()];if(n!==void 0)this.setHex(n,t);else Ie("Color: Unknown color "+e);return 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=Ai(e.r),this.g=Ai(e.g),this.b=Ai(e.b),this}copyLinearToSRGB(e){return this.r=ts(e.r),this.g=ts(e.g),this.b=ts(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e="srgb"){return $e.workingToColorSpace(Jt.copy(this),e),Math.round(We(Jt.r*255,0,255))*65536+Math.round(We(Jt.g*255,0,255))*256+Math.round(We(Jt.b*255,0,255))}getHexString(e="srgb"){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=$e.workingColorSpace){$e.workingToColorSpace(Jt.copy(this),t);let{r:n,g:i,b:r}=Jt,s=Math.max(n,i,r),o=Math.min(n,i,r),a,c,l=(o+s)/2;if(o===s)a=0,c=0;else{let u=s-o;switch(c=l<=0.5?u/(s+o):u/(2-s-o),s){case n:a=(i-r)/u+(i<r?6:0);break;case i:a=(r-n)/u+2;break;case r:a=(n-i)/u+4;break}a/=6}return e.h=a,e.s=c,e.l=l,e}getRGB(e,t=$e.workingColorSpace){return $e.workingToColorSpace(Jt.copy(this),t),e.r=Jt.r,e.g=Jt.g,e.b=Jt.b,e}getStyle(e="srgb"){$e.workingToColorSpace(Jt.copy(this),e);let{r:t,g:n,b:i}=Jt;if(e!=="srgb")return`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${i.toFixed(3)})`;return`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(i*255)})`}offsetHSL(e,t,n){return this.getHSL(Bi),this.setHSL(Bi.h+e,Bi.s+t,Bi.l+n)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(Bi),e.getHSL(qo);let n=Gs(Bi.h,qo.h,t),i=Gs(Bi.s,qo.s,t),r=Gs(Bi.l,qo.l,t);return this.setHSL(n,i,r),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){let t=this.r,n=this.g,i=this.b,r=e.elements;return this.r=r[0]*t+r[3]*n+r[6]*i,this.g=r[1]*t+r[4]*n+r[7]*i,this.b=r[2]*t+r[5]*n+r[8]*i,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}var Jt=new Oe;Oe.NAMES=hp;class ds extends ut{constructor(){super();if(this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new ni,this.environmentIntensity=1,this.environmentRotation=new ni,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){if(super.copy(e,t),e.background!==null)this.background=e.background.clone();if(e.environment!==null)this.environment=e.environment.clone();if(e.fog!==null)this.fog=e.fog.clone();if(this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null)this.overrideMaterial=e.overrideMaterial.clone();return this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){let t=super.toJSON(e);if(this.fog!==null)t.object.fog=this.fog.toJSON();return t.object.backgroundBlurriness=this.backgroundBlurriness,t.object.backgroundIntensity=this.backgroundIntensity,t.object.backgroundRotation=this.backgroundRotation.toArray(),t.object.environmentIntensity=this.environmentIntensity,t.object.environmentRotation=this.environmentRotation.toArray(),t}}var zn=new O,Si=new O,qc=new O,Mi=new O,Wr=new O,Zr=new O,Hf=new O,jc=new O,Yc=new O,Kc=new O,Jc=new at,Qc=new at,el=new at;class Cn{constructor(e=new O,t=new O,n=new O){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,i){i.subVectors(n,t),zn.subVectors(e,t),i.cross(zn);let r=i.lengthSq();if(r>0)return i.multiplyScalar(1/Math.sqrt(r));return i.set(0,0,0)}static getBarycoord(e,t,n,i,r){zn.subVectors(i,t),Si.subVectors(n,t),qc.subVectors(e,t);let s=zn.dot(zn),o=zn.dot(Si),a=zn.dot(qc),c=Si.dot(Si),l=Si.dot(qc),u=s*c-o*o;if(u===0)return r.set(0,0,0),null;let f=1/u,h=(c*a-o*l)*f,d=(s*l-o*a)*f;return r.set(1-h-d,d,h)}static containsPoint(e,t,n,i){if(this.getBarycoord(e,t,n,i,Mi)===null)return!1;return Mi.x>=0&&Mi.y>=0&&Mi.x+Mi.y<=1}static getInterpolation(e,t,n,i,r,s,o,a){if(this.getBarycoord(e,t,n,i,Mi)===null){if(a.x=0,a.y=0,"z"in a)a.z=0;if("w"in a)a.w=0;return null}return a.setScalar(0),a.addScaledVector(r,Mi.x),a.addScaledVector(s,Mi.y),a.addScaledVector(o,Mi.z),a}static getInterpolatedAttribute(e,t,n,i,r,s){return Jc.setScalar(0),Qc.setScalar(0),el.setScalar(0),Jc.fromBufferAttribute(e,t),Qc.fromBufferAttribute(e,n),el.fromBufferAttribute(e,i),s.setScalar(0),s.addScaledVector(Jc,r.x),s.addScaledVector(Qc,r.y),s.addScaledVector(el,r.z),s}static isFrontFacing(e,t,n,i){return zn.subVectors(n,t),Si.subVectors(e,t),zn.cross(Si).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 zn.subVectors(this.c,this.b),Si.subVectors(this.a,this.b),zn.cross(Si).length()*0.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(0.3333333333333333)}getNormal(e){return Cn.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return Cn.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,i,r){return Cn.getInterpolation(e,this.a,this.b,this.c,t,n,i,r)}containsPoint(e){return Cn.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Cn.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let n=this.a,i=this.b,r=this.c,s,o;Wr.subVectors(i,n),Zr.subVectors(r,n),jc.subVectors(e,n);let a=Wr.dot(jc),c=Zr.dot(jc);if(a<=0&&c<=0)return t.copy(n);Yc.subVectors(e,i);let l=Wr.dot(Yc),u=Zr.dot(Yc);if(l>=0&&u<=l)return t.copy(i);let f=a*u-l*c;if(f<=0&&a>=0&&l<=0)return s=a/(a-l),t.copy(n).addScaledVector(Wr,s);Kc.subVectors(e,r);let h=Wr.dot(Kc),d=Zr.dot(Kc);if(d>=0&&h<=d)return t.copy(r);let g=h*c-a*d;if(g<=0&&c>=0&&d<=0)return o=c/(c-d),t.copy(n).addScaledVector(Zr,o);let x=l*d-h*u;if(x<=0&&u-l>=0&&h-d>=0)return Hf.subVectors(r,i),o=(u-l)/(u-l+(h-d)),t.copy(i).addScaledVector(Hf,o);let p=1/(x+g+f);return s=g*p,o=f*p,t.copy(n).addScaledVector(Wr,s).addScaledVector(Zr,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}class Ft{constructor(e=new O(1/0,1/0,1/0),t=new O(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t+=3)this.expandByPoint(kn.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(kn.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let n=kn.copy(t).multiplyScalar(0.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(0.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);let n=e.geometry;if(n!==void 0){let r=n.getAttribute("position");if(t===!0&&r!==void 0&&e.isInstancedMesh!==!0)for(let s=0,o=r.count;s<o;s++){if(e.isMesh===!0)e.getVertexPosition(s,kn);else kn.fromBufferAttribute(r,s);kn.applyMatrix4(e.matrixWorld),this.expandByPoint(kn)}else{if(e.boundingBox!==void 0){if(e.boundingBox===null)e.computeBoundingBox();jo.copy(e.boundingBox)}else{if(n.boundingBox===null)n.computeBoundingBox();jo.copy(n.boundingBox)}jo.applyMatrix4(e.matrixWorld),this.union(jo)}}let i=e.children;for(let r=0,s=i.length;r<s;r++)this.expandByObject(i[r],t);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,kn),kn.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;if(e.normal.x>0)t=e.normal.x*this.min.x,n=e.normal.x*this.max.x;else t=e.normal.x*this.max.x,n=e.normal.x*this.min.x;if(e.normal.y>0)t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y;else t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y;if(e.normal.z>0)t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z;else t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z;return t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Ns),Yo.subVectors(this.max,Ns),Xr.subVectors(e.a,Ns),qr.subVectors(e.b,Ns),jr.subVectors(e.c,Ns),Gi.subVectors(qr,Xr),Hi.subVectors(jr,qr),pr.subVectors(Xr,jr);let t=[0,-Gi.z,Gi.y,0,-Hi.z,Hi.y,0,-pr.z,pr.y,Gi.z,0,-Gi.x,Hi.z,0,-Hi.x,pr.z,0,-pr.x,-Gi.y,Gi.x,0,-Hi.y,Hi.x,0,-pr.y,pr.x,0];if(!tl(t,Xr,qr,jr,Yo))return!1;if(t=[1,0,0,0,1,0,0,0,1],!tl(t,Xr,qr,jr,Yo))return!1;return Ko.crossVectors(Gi,Hi),t=[Ko.x,Ko.y,Ko.z],tl(t,Xr,qr,jr,Yo)}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,kn).distanceTo(e)}getBoundingSphere(e){if(this.isEmpty())e.makeEmpty();else this.getCenter(e.center),e.radius=this.getSize(kn).length()*0.5;return e}intersect(e){if(this.min.max(e.min),this.max.min(e.max),this.isEmpty())this.makeEmpty();return this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){if(this.isEmpty())return this;return wi[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),wi[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),wi[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),wi[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),wi[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),wi[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),wi[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),wi[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(wi),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)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}}var wi=[new O,new O,new O,new O,new O,new O,new O,new O],kn=new O,jo=new Ft,Xr=new O,qr=new O,jr=new O,Gi=new O,Hi=new O,pr=new O,Ns=new O,Yo=new O,Ko=new O,mr=new O;function tl(e,t,n,i,r){for(let s=0,o=e.length-3;s<=o;s+=3){mr.fromArray(e,s);let a=r.x*Math.abs(mr.x)+r.y*Math.abs(mr.y)+r.z*Math.abs(mr.z),c=t.dot(mr),l=n.dot(mr),u=i.dot(mr);if(Math.max(-Math.max(c,l,u),Math.min(c,l,u))>a)return!1}return!0}var Nt=new O,Jo=new Ne,qv=0;class Vt extends Wn{constructor(e,t,n=!1){super();if(Array.isArray(e))throw TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:qv++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=35044,this.updateRanges=[],this.gpuType=1015,this.version=0}onUploadCallback(){}set needsUpdate(e){if(e===!0)this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let i=0,r=this.itemSize;i<r;i++)this.array[e+i]=t.array[n+i];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,n=this.count;t<n;t++)Jo.fromBufferAttribute(this,t),Jo.applyMatrix3(e),this.setXY(t,Jo.x,Jo.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)Nt.fromBufferAttribute(this,t),Nt.applyMatrix3(e),this.setXYZ(t,Nt.x,Nt.y,Nt.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)Nt.fromBufferAttribute(this,t),Nt.applyMatrix4(e),this.setXYZ(t,Nt.x,Nt.y,Nt.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)Nt.fromBufferAttribute(this,t),Nt.applyNormalMatrix(e),this.setXYZ(t,Nt.x,Nt.y,Nt.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)Nt.fromBufferAttribute(this,t),Nt.transformDirection(e),this.setXYZ(t,Nt.x,Nt.y,Nt.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let n=this.array[e*this.itemSize+t];if(this.normalized)n=Bn(n,this.array);return n}setComponent(e,t,n){if(this.normalized)n=ot(n,this.array);return this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];if(this.normalized)t=Bn(t,this.array);return t}setX(e,t){if(this.normalized)t=ot(t,this.array);return this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];if(this.normalized)t=Bn(t,this.array);return t}setY(e,t){if(this.normalized)t=ot(t,this.array);return this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];if(this.normalized)t=Bn(t,this.array);return t}setZ(e,t){if(this.normalized)t=ot(t,this.array);return this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];if(this.normalized)t=Bn(t,this.array);return t}setW(e,t){if(this.normalized)t=ot(t,this.array);return this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){if(e*=this.itemSize,this.normalized)t=ot(t,this.array),n=ot(n,this.array);return this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,i){if(e*=this.itemSize,this.normalized)t=ot(t,this.array),n=ot(n,this.array),i=ot(i,this.array);return this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this}setXYZW(e,t,n,i,r){if(e*=this.itemSize,this.normalized)t=ot(t,this.array),n=ot(n,this.array),i=ot(i,this.array),r=ot(r,this.array);return this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this.array[e+3]=r,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){let e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return e.name=this.name,e.usage=this.usage,e.gpuType=this.gpuType,e}dispose(){this.dispatchEvent({type:"dispose"})}}class Oa extends Vt{constructor(e,t,n){super(new Uint16Array(e),t,n)}}class Ua extends Vt{constructor(e,t,n){super(new Uint32Array(e),t,n)}}class un extends Vt{constructor(e,t,n){super(new Float32Array(e),t,n)}}var jv=new Ft,Ds=new O,nl=new O;class xn{constructor(e=new O,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){let n=this.center;if(t!==void 0)n.copy(t);else jv.setFromPoints(e).getCenter(n);let i=0;for(let r=0,s=e.length;r<s;r++)i=Math.max(i,n.distanceToSquared(e[r]));return this.radius=Math.sqrt(i),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){let t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){let n=this.center.distanceToSquared(e);if(t.copy(e),n>this.radius*this.radius)t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center);return t}getBoundingBox(e){if(this.isEmpty())return e.makeEmpty(),e;return 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;Ds.subVectors(e,this.center);let t=Ds.lengthSq();if(t>this.radius*this.radius){let n=Math.sqrt(t),i=(n-this.radius)*0.5;this.center.addScaledVector(Ds,i/n),this.radius+=i}return this}union(e){if(e.isEmpty())return this;if(this.isEmpty())return this.copy(e),this;if(this.center.equals(e.center)===!0)this.radius=Math.max(this.radius,e.radius);else nl.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Ds.copy(e.center).add(nl)),this.expandByPoint(Ds.copy(e.center).sub(nl));return this}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}}var Yv=0,An=new Ge,il=new ut,Yr=new O,mn=new Ft,Os=new Ft,Gt=new O;class en extends Wn{constructor(){super();this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Yv++}),this.uuid=Gn(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={},this._transformed=!1}getIndex(){return this.index}setIndex(e){if(Array.isArray(e))this.index=new((vv(e))?Ua:Oa)(e,1);else this.index=e;return this}setIndirect(e,t=0){return this.indirect=e,this.indirectOffset=t,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){let t=this.attributes.position;if(t!==void 0)t.applyMatrix4(e),t.needsUpdate=!0;let n=this.attributes.normal;if(n!==void 0){let r=new ze().getNormalMatrix(e);n.applyNormalMatrix(r),n.needsUpdate=!0}let i=this.attributes.tangent;if(i!==void 0)i.transformDirection(e),i.needsUpdate=!0;if(this.boundingBox!==null)this.computeBoundingBox();if(this.boundingSphere!==null)this.computeBoundingSphere();return this._transformed=!0,this}applyQuaternion(e){return An.makeRotationFromQuaternion(e),this.applyMatrix4(An),this}rotateX(e){return An.makeRotationX(e),this.applyMatrix4(An),this}rotateY(e){return An.makeRotationY(e),this.applyMatrix4(An),this}rotateZ(e){return An.makeRotationZ(e),this.applyMatrix4(An),this}translate(e,t,n){return An.makeTranslation(e,t,n),this.applyMatrix4(An),this}scale(e,t,n){return An.makeScale(e,t,n),this.applyMatrix4(An),this}lookAt(e){return il.lookAt(e),il.updateMatrix(),this.applyMatrix4(il.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Yr).negate(),this.translate(Yr.x,Yr.y,Yr.z),this}setFromPoints(e){let t=this.getAttribute("position");if(t===void 0){let n=[];for(let i=0,r=e.length;i<r;i++){let s=e[i];n.push(s.x,s.y,s.z||0)}this.setAttribute("position",new un(n,3))}else{let n=Math.min(e.length,t.count);for(let i=0;i<n;i++){let r=e[i];t.setXYZ(i,r.x,r.y,r.z||0)}if(e.length>t.count)Ie("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry.");t.needsUpdate=!0}return this}computeBoundingBox(){if(this.boundingBox===null)this.boundingBox=new Ft;let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Ue("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new O(-1/0,-1/0,-1/0),new O(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,i=t.length;n<i;n++){let r=t[n];if(mn.setFromBufferAttribute(r),this.morphTargetsRelative)Gt.addVectors(this.boundingBox.min,mn.min),this.boundingBox.expandByPoint(Gt),Gt.addVectors(this.boundingBox.max,mn.max),this.boundingBox.expandByPoint(Gt);else this.boundingBox.expandByPoint(mn.min),this.boundingBox.expandByPoint(mn.max)}}else this.boundingBox.makeEmpty();if(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))Ue('BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){if(this.boundingSphere===null)this.boundingSphere=new xn;let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Ue("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new O,1/0);return}if(e){let n=this.boundingSphere.center;if(mn.setFromBufferAttribute(e),t)for(let r=0,s=t.length;r<s;r++){let o=t[r];if(Os.setFromBufferAttribute(o),this.morphTargetsRelative)Gt.addVectors(mn.min,Os.min),mn.expandByPoint(Gt),Gt.addVectors(mn.max,Os.max),mn.expandByPoint(Gt);else mn.expandByPoint(Os.min),mn.expandByPoint(Os.max)}mn.getCenter(n);let i=0;for(let r=0,s=e.count;r<s;r++)Gt.fromBufferAttribute(e,r),i=Math.max(i,n.distanceToSquared(Gt));if(t)for(let r=0,s=t.length;r<s;r++){let o=t[r],a=this.morphTargetsRelative;for(let c=0,l=o.count;c<l;c++){if(Gt.fromBufferAttribute(o,c),a)Yr.fromBufferAttribute(e,c),Gt.add(Yr);i=Math.max(i,n.distanceToSquared(Gt))}}if(this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius))Ue('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){let e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){Ue("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}let{position:n,normal:i,uv:r}=t,s=this.getAttribute("tangent");if(s===void 0||s.count!==n.count)s=new Vt(new Float32Array(4*n.count),4),this.setAttribute("tangent",s);let o=[],a=[];for(let A=0;A<n.count;A++)o[A]=new O,a[A]=new O;let c=new O,l=new O,u=new O,f=new Ne,h=new Ne,d=new Ne,g=new O,x=new O;function p(A,_,S){c.fromBufferAttribute(n,A),l.fromBufferAttribute(n,_),u.fromBufferAttribute(n,S),f.fromBufferAttribute(r,A),h.fromBufferAttribute(r,_),d.fromBufferAttribute(r,S),l.sub(c),u.sub(c),h.sub(f),d.sub(f);let z=1/(h.x*d.y-d.x*h.y);if(!isFinite(z))return;g.copy(l).multiplyScalar(d.y).addScaledVector(u,-h.y).multiplyScalar(z),x.copy(u).multiplyScalar(h.x).addScaledVector(l,-d.x).multiplyScalar(z),o[A].add(g),o[_].add(g),o[S].add(g),a[A].add(x),a[_].add(x),a[S].add(x)}let m=this.groups;if(m.length===0)m=[{start:0,count:e.count}];for(let A=0,_=m.length;A<_;++A){let S=m[A],{start:z,count:P}=S;for(let F=z,ee=z+P;F<ee;F+=3)p(e.getX(F+0),e.getX(F+1),e.getX(F+2))}let E=new O,R=new O,v=new O,M=new O;function T(A){v.fromBufferAttribute(i,A),M.copy(v);let _=o[A];E.copy(_),E.sub(v.multiplyScalar(v.dot(_))).normalize(),R.crossVectors(M,_);let z=R.dot(a[A])<0?-1:1;s.setXYZW(A,E.x,E.y,E.z,z)}for(let A=0,_=m.length;A<_;++A){let S=m[A],{start:z,count:P}=S;for(let F=z,ee=z+P;F<ee;F+=3)T(e.getX(F+0)),T(e.getX(F+1)),T(e.getX(F+2))}this._transformed=!0}computeVertexNormals(){let e=this.index,t=this.getAttribute("position");if(t!==void 0){let n=this.getAttribute("normal");if(n===void 0||n.count!==t.count)n=new Vt(new Float32Array(t.count*3),3),this.setAttribute("normal",n);else for(let f=0,h=n.count;f<h;f++)n.setXYZ(f,0,0,0);let i=new O,r=new O,s=new O,o=new O,a=new O,c=new O,l=new O,u=new O;if(e)for(let f=0,h=e.count;f<h;f+=3){let d=e.getX(f+0),g=e.getX(f+1),x=e.getX(f+2);i.fromBufferAttribute(t,d),r.fromBufferAttribute(t,g),s.fromBufferAttribute(t,x),l.subVectors(s,r),u.subVectors(i,r),l.cross(u),o.fromBufferAttribute(n,d),a.fromBufferAttribute(n,g),c.fromBufferAttribute(n,x),o.add(l),a.add(l),c.add(l),n.setXYZ(d,o.x,o.y,o.z),n.setXYZ(g,a.x,a.y,a.z),n.setXYZ(x,c.x,c.y,c.z)}else for(let f=0,h=t.count;f<h;f+=3)i.fromBufferAttribute(t,f+0),r.fromBufferAttribute(t,f+1),s.fromBufferAttribute(t,f+2),l.subVectors(s,r),u.subVectors(i,r),l.cross(u),n.setXYZ(f+0,l.x,l.y,l.z),n.setXYZ(f+1,l.x,l.y,l.z),n.setXYZ(f+2,l.x,l.y,l.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){let e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)Gt.fromBufferAttribute(e,t),Gt.normalize(),e.setXYZ(t,Gt.x,Gt.y,Gt.z)}toNonIndexed(){function e(o,a){let{array:c,itemSize:l,normalized:u}=o,f=new c.constructor(a.length*l),h=0,d=0;for(let g=0,x=a.length;g<x;g++){if(o.isInterleavedBufferAttribute)h=a[g]*o.data.stride+o.offset;else h=a[g]*l;for(let p=0;p<l;p++)f[d++]=c[h++]}return new Vt(f,l,u)}if(this.index===null)return Ie("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;let t=new en,n=this.index.array,i=this.attributes;for(let o in i){let a=i[o],c=e(a,n);t.setAttribute(o,c)}let r=this.morphAttributes;for(let o in r){let a=[],c=r[o];for(let l=0,u=c.length;l<u;l++){let f=c[l],h=e(f,n);a.push(h)}t.morphAttributes[o]=a}t.morphTargetsRelative=this.morphTargetsRelative;let s=this.groups;for(let o=0,a=s.length;o<a;o++){let c=s[o];t.addGroup(c.start,c.count,c.materialIndex)}return t}toJSON(){let e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.parameters!==void 0&&this._transformed===!0?"BufferGeometry":this.type,e.name=this.name,Object.keys(this.userData).length>0)e.userData=this.userData;if(this.parameters!==void 0&&this._transformed!==!0){let a=this.parameters;for(let c in a)if(a[c]!==void 0)e[c]=a[c];return e}e.data={attributes:{}};let t=this.index;if(t!==null)e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)};let n=this.attributes;for(let a in n){let c=n[a];e.data.attributes[a]=c.toJSON(e.data)}let i={},r=!1;for(let a in this.morphAttributes){let c=this.morphAttributes[a],l=[];for(let u=0,f=c.length;u<f;u++){let h=c[u];l.push(h.toJSON(e.data))}if(l.length>0)i[a]=l,r=!0}if(r)e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative;let s=this.groups;if(s.length>0)e.data.groups=JSON.parse(JSON.stringify(s));let o=this.boundingSphere;if(o!==null)e.data.boundingSphere=o.toJSON();return 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;let t={};this.name=e.name;let n=e.index;if(n!==null)this.setIndex(n.clone());let i=e.attributes;for(let c in i){let l=i[c];this.setAttribute(c,l.clone(t))}let r=e.morphAttributes;for(let c in r){let l=[],u=r[c];for(let f=0,h=u.length;f<h;f++)l.push(u[f].clone(t));this.morphAttributes[c]=l}this.morphTargetsRelative=e.morphTargetsRelative;let s=e.groups;for(let c=0,l=s.length;c<l;c++){let u=s[c];this.addGroup(u.start,u.count,u.materialIndex)}let o=e.boundingBox;if(o!==null)this.boundingBox=o.clone();let a=e.boundingSphere;if(a!==null)this.boundingSphere=a.clone();return this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this._transformed=e._transformed,this}dispose(){this.dispatchEvent({type:"dispose"})}}class Js{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=35044,this.updateRanges=[],this.version=0,this.uuid=Gn()}onUploadCallback(){}set needsUpdate(e){if(e===!0)this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let i=0,r=this.stride;i<r;i++)this.array[e+i]=t.array[n+i];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){if(e.arrayBuffers===void 0)e.arrayBuffers={};if(this.array.buffer._uuid===void 0)this.array.buffer._uuid=Gn();if(e.arrayBuffers[this.array.buffer._uuid]===void 0)e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer;let t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(t,this.stride);return n.setUsage(this.usage),n}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){if(e.arrayBuffers===void 0)e.arrayBuffers={};if(this.array.buffer._uuid===void 0)this.array.buffer._uuid=Gn();if(e.arrayBuffers[this.array.buffer._uuid]===void 0)e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer));let t={uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride};return t.usage=this.usage,t}}var sn=new O;class ps{constructor(e,t,n,i=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=n,this.normalized=i}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,n=this.data.count;t<n;t++)sn.fromBufferAttribute(this,t),sn.applyMatrix4(e),this.setXYZ(t,sn.x,sn.y,sn.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)sn.fromBufferAttribute(this,t),sn.applyNormalMatrix(e),this.setXYZ(t,sn.x,sn.y,sn.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)sn.fromBufferAttribute(this,t),sn.transformDirection(e),this.setXYZ(t,sn.x,sn.y,sn.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];if(this.normalized)n=Bn(n,this.array);return n}setComponent(e,t,n){if(this.normalized)n=ot(n,this.array);return this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){if(this.normalized)t=ot(t,this.array);return this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){if(this.normalized)t=ot(t,this.array);return this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){if(this.normalized)t=ot(t,this.array);return this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){if(this.normalized)t=ot(t,this.array);return this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];if(this.normalized)t=Bn(t,this.array);return t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];if(this.normalized)t=Bn(t,this.array);return t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];if(this.normalized)t=Bn(t,this.array);return t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];if(this.normalized)t=Bn(t,this.array);return t}setXY(e,t,n){if(e=e*this.data.stride+this.offset,this.normalized)t=ot(t,this.array),n=ot(n,this.array);return this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,i){if(e=e*this.data.stride+this.offset,this.normalized)t=ot(t,this.array),n=ot(n,this.array),i=ot(i,this.array);return this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this}setXYZW(e,t,n,i,r){if(e=e*this.data.stride+this.offset,this.normalized)t=ot(t,this.array),n=ot(n,this.array),i=ot(i,this.array),r=ot(r,this.array);return this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this.data.array[e+3]=r,this}clone(e){if(e===void 0){Hs("InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");let t=[];for(let n=0;n<this.count;n++){let i=n*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)t.push(this.data.array[i+r])}return new Vt(new this.array.constructor(t),this.itemSize,this.normalized)}else{if(e.interleavedBuffers===void 0)e.interleavedBuffers={};if(e.interleavedBuffers[this.data.uuid]===void 0)e.interleavedBuffers[this.data.uuid]=this.data.clone(e);return new ps(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}}toJSON(e){if(e===void 0){Hs("InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");let t=[];for(let n=0;n<this.count;n++){let i=n*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)t.push(this.data.array[i+r])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else{if(e.interleavedBuffers===void 0)e.interleavedBuffers={};if(e.interleavedBuffers[this.data.uuid]===void 0)e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e);return{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}}var rl=new O,Kv=new O,Jv=new ze;class Rn{constructor(e=new O(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){let i=rl.subVectors(n,t).cross(Kv.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(i,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){let 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,n=!0){let i=e.delta(rl),r=this.normal.dot(i);if(r===0){if(this.distanceToPoint(e.start)===0)return t.copy(e.start);return null}let s=-(e.start.dot(this.normal)+this.constant)/r;if(n===!0&&(s<0||s>1))return null;return t.copy(e.start).addScaledVector(i,s)}intersectsLine(e){let t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){let n=t||Jv.getNormalMatrix(e),i=this.coplanarPoint(rl).applyMatrix4(e),r=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(r),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}toJSON(){return{normal:this.normal.toArray(),constant:this.constant}}fromJSON(e){return this.normal.fromArray(e.normal),this.constant=e.constant,this}}var Qv=0;class hn extends Wn{constructor(){super();this.isMaterial=!0,Object.defineProperty(this,"id",{value:Qv++}),this.uuid=Gn(),this.name="",this.type="Material",this.blending=1,this.side=0,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=204,this.blendDst=205,this.blendEquation=100,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Oe(0,0,0),this.blendAlpha=0,this.depthFunc=3,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=519,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=7680,this.stencilZFail=7680,this.stencilZPass=7680,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.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){if(this._alphaTest>0!==e>0)this.version++;this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e===void 0)return;for(let t in e){let n=e[t];if(n===void 0){Ie(`Material: parameter '${t}' has value of undefined.`);continue}let i=this[t];if(i===void 0){Ie(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}if(i&&i.isColor)i.set(n);else if(i&&i.isVector2&&(n&&n.isVector2)||i&&i.isEuler&&(n&&n.isEuler)||i&&i.isVector3&&(n&&n.isVector3))i.copy(n);else this[t]=n}}toJSON(e){let t=e===void 0||typeof e==="string";if(t)e={textures:{},images:{}};let n={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};if(n.uuid=this.uuid,n.type=this.type,n.blending=this.blending,n.side=this.side,n.shadowSide=this.shadowSide,n.vertexColors=this.vertexColors,n.opacity=this.opacity,n.transparent=this.transparent,n.blendSrc=this.blendSrc,n.blendDst=this.blendDst,n.blendEquation=this.blendEquation,n.blendSrcAlpha=this.blendSrcAlpha,n.blendDstAlpha=this.blendDstAlpha,n.blendEquationAlpha=this.blendEquationAlpha,n.blendColor=this.blendColor.getHex(),n.blendAlpha=this.blendAlpha,n.depthFunc=this.depthFunc,n.depthTest=this.depthTest,n.depthWrite=this.depthWrite,n.colorWrite=this.colorWrite,n.clipIntersection=this.clipIntersection,n.clipShadows=this.clipShadows,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,n.stencilWrite=this.stencilWrite,n.polygonOffset=this.polygonOffset,n.polygonOffsetFactor=this.polygonOffsetFactor,n.polygonOffsetUnits=this.polygonOffsetUnits,n.dithering=this.dithering,n.alphaTest=this.alphaTest,n.alphaHash=this.alphaHash,n.alphaToCoverage=this.alphaToCoverage,n.premultipliedAlpha=this.premultipliedAlpha,n.forceSinglePass=this.forceSinglePass,n.allowOverride=this.allowOverride,n.visible=this.visible,n.toneMapped=this.toneMapped,n.name=this.name,this.color&&this.color.isColor)n.color=this.color.getHex();if(this.roughness!==void 0)n.roughness=this.roughness;if(this.metalness!==void 0)n.metalness=this.metalness;if(this.sheen!==void 0)n.sheen=this.sheen;if(this.sheenColor&&this.sheenColor.isColor)n.sheenColor=this.sheenColor.getHex();if(this.sheenRoughness!==void 0)n.sheenRoughness=this.sheenRoughness;if(this.emissive&&this.emissive.isColor)n.emissive=this.emissive.getHex();if(this.emissiveIntensity!==void 0)n.emissiveIntensity=this.emissiveIntensity;if(this.specular&&this.specular.isColor)n.specular=this.specular.getHex();if(this.specularIntensity!==void 0)n.specularIntensity=this.specularIntensity;if(this.specularColor&&this.specularColor.isColor)n.specularColor=this.specularColor.getHex();if(this.shininess!==void 0)n.shininess=this.shininess;if(this.clearcoat!==void 0)n.clearcoat=this.clearcoat;if(this.clearcoatRoughness!==void 0)n.clearcoatRoughness=this.clearcoatRoughness;if(this.clearcoatMap&&this.clearcoatMap.isTexture)n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid;if(this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture)n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid;if(this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture)n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray();if(this.sheenColorMap&&this.sheenColorMap.isTexture)n.sheenColorMap=this.sheenColorMap.toJSON(e).uuid;if(this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture)n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid;if(this.dispersion!==void 0)n.dispersion=this.dispersion;if(this.retroreflectivity!==void 0)n.retroreflectivity=this.retroreflectivity;if(this.iridescence!==void 0)n.iridescence=this.iridescence;if(this.iridescenceIOR!==void 0)n.iridescenceIOR=this.iridescenceIOR;if(this.iridescenceThicknessRange!==void 0)n.iridescenceThicknessRange=this.iridescenceThicknessRange;if(this.iridescenceMap&&this.iridescenceMap.isTexture)n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid;if(this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture)n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid;if(this.anisotropy!==void 0)n.anisotropy=this.anisotropy;if(this.anisotropyRotation!==void 0)n.anisotropyRotation=this.anisotropyRotation;if(this.anisotropyMap&&this.anisotropyMap.isTexture)n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid;if(this.map&&this.map.isTexture)n.map=this.map.toJSON(e).uuid;if(this.matcap&&this.matcap.isTexture)n.matcap=this.matcap.toJSON(e).uuid;if(this.alphaMap&&this.alphaMap.isTexture)n.alphaMap=this.alphaMap.toJSON(e).uuid;if(this.lightMap&&this.lightMap.isTexture)n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity;if(this.aoMap&&this.aoMap.isTexture)n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity;if(this.bumpMap&&this.bumpMap.isTexture)n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale;if(this.normalMap&&this.normalMap.isTexture)n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray();if(this.displacementMap&&this.displacementMap.isTexture)n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias;if(this.roughnessMap&&this.roughnessMap.isTexture)n.roughnessMap=this.roughnessMap.toJSON(e).uuid;if(this.metalnessMap&&this.metalnessMap.isTexture)n.metalnessMap=this.metalnessMap.toJSON(e).uuid;if(this.emissiveMap&&this.emissiveMap.isTexture)n.emissiveMap=this.emissiveMap.toJSON(e).uuid;if(this.specularMap&&this.specularMap.isTexture)n.specularMap=this.specularMap.toJSON(e).uuid;if(this.specularIntensityMap&&this.specularIntensityMap.isTexture)n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid;if(this.specularColorMap&&this.specularColorMap.isTexture)n.specularColorMap=this.specularColorMap.toJSON(e).uuid;if(this.envMap&&this.envMap.isTexture){if(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0)n.combine=this.combine}if(this.envMapRotation!==void 0)n.envMapRotation=this.envMapRotation.toArray();if(this.envMapIntensity!==void 0)n.envMapIntensity=this.envMapIntensity;if(this.reflectivity!==void 0)n.reflectivity=this.reflectivity;if(this.refractionRatio!==void 0)n.refractionRatio=this.refractionRatio;if(this.gradientMap&&this.gradientMap.isTexture)n.gradientMap=this.gradientMap.toJSON(e).uuid;if(this.transmission!==void 0)n.transmission=this.transmission;if(this.transmissionMap&&this.transmissionMap.isTexture)n.transmissionMap=this.transmissionMap.toJSON(e).uuid;if(this.thickness!==void 0)n.thickness=this.thickness;if(this.thicknessMap&&this.thicknessMap.isTexture)n.thicknessMap=this.thicknessMap.toJSON(e).uuid;if(this.attenuationDistance!==void 0)n.attenuationDistance=this.attenuationDistance;if(this.attenuationColor!==void 0)n.attenuationColor=this.attenuationColor.getHex();if(this.size!==void 0)n.size=this.size;if(this.sizeAttenuation!==void 0)n.sizeAttenuation=this.sizeAttenuation;if(Array.isArray(this.clippingPlanes)&&this.clippingPlanes.length>0)n.clippingPlanes=this.clippingPlanes.map((r)=>r.toJSON());if(this.rotation!==void 0)n.rotation=this.rotation;if(this.depthPacking!==void 0)n.depthPacking=this.depthPacking;if(this.linewidth!==void 0)n.linewidth=this.linewidth;if(this.linecap!==void 0)n.linecap=this.linecap;if(this.linejoin!==void 0)n.linejoin=this.linejoin;if(this.dashSize!==void 0)n.dashSize=this.dashSize;if(this.gapSize!==void 0)n.gapSize=this.gapSize;if(this.scale!==void 0)n.scale=this.scale;if(this.wireframe!==void 0)n.wireframe=this.wireframe;if(this.wireframeLinewidth!==void 0)n.wireframeLinewidth=this.wireframeLinewidth;if(this.wireframeLinecap!==void 0)n.wireframeLinecap=this.wireframeLinecap;if(this.wireframeLinejoin!==void 0)n.wireframeLinejoin=this.wireframeLinejoin;if(this.flatShading!==void 0)n.flatShading=this.flatShading;if(this.fog!==void 0)n.fog=this.fog;if(Object.keys(this.userData).length>0)n.userData=this.userData;function i(r){let s=[];for(let o in r){let a=r[o];delete a.metadata,s.push(a)}return s}if(t){let r=i(e.textures),s=i(e.images);if(r.length>0)n.textures=r;if(s.length>0)n.images=s}return n}fromJSON(e,t){if(e.uuid!==void 0)this.uuid=e.uuid;if(e.name!==void 0)this.name=e.name;if(e.color!==void 0&&this.color!==void 0)this.color.setHex(e.color);if(e.roughness!==void 0)this.roughness=e.roughness;if(e.metalness!==void 0)this.metalness=e.metalness;if(e.sheen!==void 0)this.sheen=e.sheen;if(e.sheenColor!==void 0)this.sheenColor=new Oe().setHex(e.sheenColor);if(e.sheenRoughness!==void 0)this.sheenRoughness=e.sheenRoughness;if(e.emissive!==void 0&&this.emissive!==void 0)this.emissive.setHex(e.emissive);if(e.specular!==void 0&&this.specular!==void 0)this.specular.setHex(e.specular);if(e.specularIntensity!==void 0)this.specularIntensity=e.specularIntensity;if(e.specularColor!==void 0&&this.specularColor!==void 0)this.specularColor.setHex(e.specularColor);if(e.shininess!==void 0)this.shininess=e.shininess;if(e.clearcoat!==void 0)this.clearcoat=e.clearcoat;if(e.clearcoatRoughness!==void 0)this.clearcoatRoughness=e.clearcoatRoughness;if(e.dispersion!==void 0)this.dispersion=e.dispersion;if(e.retroreflectivity!==void 0)this.retroreflectivity=e.retroreflectivity;if(e.iridescence!==void 0)this.iridescence=e.iridescence;if(e.iridescenceIOR!==void 0)this.iridescenceIOR=e.iridescenceIOR;if(e.iridescenceThicknessRange!==void 0)this.iridescenceThicknessRange=e.iridescenceThicknessRange;if(e.transmission!==void 0)this.transmission=e.transmission;if(e.thickness!==void 0)this.thickness=e.thickness;if(e.attenuationDistance!==void 0)this.attenuationDistance=e.attenuationDistance;if(e.attenuationColor!==void 0&&this.attenuationColor!==void 0)this.attenuationColor.setHex(e.attenuationColor);if(e.anisotropy!==void 0)this.anisotropy=e.anisotropy;if(e.anisotropyRotation!==void 0)this.anisotropyRotation=e.anisotropyRotation;if(e.fog!==void 0)this.fog=e.fog;if(e.flatShading!==void 0)this.flatShading=e.flatShading;if(e.blending!==void 0)this.blending=e.blending;if(e.combine!==void 0)this.combine=e.combine;if(e.side!==void 0)this.side=e.side;if(e.shadowSide!==void 0)this.shadowSide=e.shadowSide;if(e.opacity!==void 0)this.opacity=e.opacity;if(e.transparent!==void 0)this.transparent=e.transparent;if(e.alphaTest!==void 0)this.alphaTest=e.alphaTest;if(e.alphaHash!==void 0)this.alphaHash=e.alphaHash;if(e.depthFunc!==void 0)this.depthFunc=e.depthFunc;if(e.depthTest!==void 0)this.depthTest=e.depthTest;if(e.depthWrite!==void 0)this.depthWrite=e.depthWrite;if(e.colorWrite!==void 0)this.colorWrite=e.colorWrite;if(e.clippingPlanes!==void 0)this.clippingPlanes=e.clippingPlanes.map((n)=>new Rn().fromJSON(n));if(e.clipIntersection!==void 0)this.clipIntersection=e.clipIntersection;if(e.clipShadows!==void 0)this.clipShadows=e.clipShadows;if(e.depthPacking!==void 0)this.depthPacking=e.depthPacking;if(e.blendSrc!==void 0)this.blendSrc=e.blendSrc;if(e.blendDst!==void 0)this.blendDst=e.blendDst;if(e.blendEquation!==void 0)this.blendEquation=e.blendEquation;if(e.blendSrcAlpha!==void 0)this.blendSrcAlpha=e.blendSrcAlpha;if(e.blendDstAlpha!==void 0)this.blendDstAlpha=e.blendDstAlpha;if(e.blendEquationAlpha!==void 0)this.blendEquationAlpha=e.blendEquationAlpha;if(e.blendColor!==void 0&&this.blendColor!==void 0)this.blendColor.setHex(e.blendColor);if(e.blendAlpha!==void 0)this.blendAlpha=e.blendAlpha;if(e.stencilWriteMask!==void 0)this.stencilWriteMask=e.stencilWriteMask;if(e.stencilFunc!==void 0)this.stencilFunc=e.stencilFunc;if(e.stencilRef!==void 0)this.stencilRef=e.stencilRef;if(e.stencilFuncMask!==void 0)this.stencilFuncMask=e.stencilFuncMask;if(e.stencilFail!==void 0)this.stencilFail=e.stencilFail;if(e.stencilZFail!==void 0)this.stencilZFail=e.stencilZFail;if(e.stencilZPass!==void 0)this.stencilZPass=e.stencilZPass;if(e.stencilWrite!==void 0)this.stencilWrite=e.stencilWrite;if(e.wireframe!==void 0)this.wireframe=e.wireframe;if(e.wireframeLinewidth!==void 0)this.wireframeLinewidth=e.wireframeLinewidth;if(e.wireframeLinecap!==void 0)this.wireframeLinecap=e.wireframeLinecap;if(e.wireframeLinejoin!==void 0)this.wireframeLinejoin=e.wireframeLinejoin;if(e.rotation!==void 0)this.rotation=e.rotation;if(e.linewidth!==void 0)this.linewidth=e.linewidth;if(e.linecap!==void 0)this.linecap=e.linecap;if(e.linejoin!==void 0)this.linejoin=e.linejoin;if(e.dashSize!==void 0)this.dashSize=e.dashSize;if(e.gapSize!==void 0)this.gapSize=e.gapSize;if(e.scale!==void 0)this.scale=e.scale;if(e.polygonOffset!==void 0)this.polygonOffset=e.polygonOffset;if(e.polygonOffsetFactor!==void 0)this.polygonOffsetFactor=e.polygonOffsetFactor;if(e.polygonOffsetUnits!==void 0)this.polygonOffsetUnits=e.polygonOffsetUnits;if(e.dithering!==void 0)this.dithering=e.dithering;if(e.alphaToCoverage!==void 0)this.alphaToCoverage=e.alphaToCoverage;if(e.premultipliedAlpha!==void 0)this.premultipliedAlpha=e.premultipliedAlpha;if(e.forceSinglePass!==void 0)this.forceSinglePass=e.forceSinglePass;if(e.allowOverride!==void 0)this.allowOverride=e.allowOverride;if(e.visible!==void 0)this.visible=e.visible;if(e.toneMapped!==void 0)this.toneMapped=e.toneMapped;if(e.userData!==void 0)this.userData=e.userData;if(e.vertexColors!==void 0)if(typeof e.vertexColors==="number")this.vertexColors=e.vertexColors>0;else this.vertexColors=e.vertexColors;if(e.size!==void 0)this.size=e.size;if(e.sizeAttenuation!==void 0)this.sizeAttenuation=e.sizeAttenuation;if(e.map!==void 0)this.map=t[e.map]||null;if(e.matcap!==void 0)this.matcap=t[e.matcap]||null;if(e.alphaMap!==void 0)this.alphaMap=t[e.alphaMap]||null;if(e.bumpMap!==void 0)this.bumpMap=t[e.bumpMap]||null;if(e.bumpScale!==void 0)this.bumpScale=e.bumpScale;if(e.normalMap!==void 0)this.normalMap=t[e.normalMap]||null;if(e.normalMapType!==void 0)this.normalMapType=e.normalMapType;if(e.normalScale!==void 0){let n=e.normalScale;if(Array.isArray(n)===!1)n=[n,n];this.normalScale=new Ne().fromArray(n)}if(e.displacementMap!==void 0)this.displacementMap=t[e.displacementMap]||null;if(e.displacementScale!==void 0)this.displacementScale=e.displacementScale;if(e.displacementBias!==void 0)this.displacementBias=e.displacementBias;if(e.roughnessMap!==void 0)this.roughnessMap=t[e.roughnessMap]||null;if(e.metalnessMap!==void 0)this.metalnessMap=t[e.metalnessMap]||null;if(e.emissiveMap!==void 0)this.emissiveMap=t[e.emissiveMap]||null;if(e.emissiveIntensity!==void 0)this.emissiveIntensity=e.emissiveIntensity;if(e.specularMap!==void 0)this.specularMap=t[e.specularMap]||null;if(e.specularIntensityMap!==void 0)this.specularIntensityMap=t[e.specularIntensityMap]||null;if(e.specularColorMap!==void 0)this.specularColorMap=t[e.specularColorMap]||null;if(e.envMap!==void 0)this.envMap=t[e.envMap]||null;if(e.envMapRotation!==void 0)this.envMapRotation.fromArray(e.envMapRotation);if(e.envMapIntensity!==void 0)this.envMapIntensity=e.envMapIntensity;if(e.reflectivity!==void 0)this.reflectivity=e.reflectivity;if(e.refractionRatio!==void 0)this.refractionRatio=e.refractionRatio;if(e.lightMap!==void 0)this.lightMap=t[e.lightMap]||null;if(e.lightMapIntensity!==void 0)this.lightMapIntensity=e.lightMapIntensity;if(e.aoMap!==void 0)this.aoMap=t[e.aoMap]||null;if(e.aoMapIntensity!==void 0)this.aoMapIntensity=e.aoMapIntensity;if(e.gradientMap!==void 0)this.gradientMap=t[e.gradientMap]||null;if(e.clearcoatMap!==void 0)this.clearcoatMap=t[e.clearcoatMap]||null;if(e.clearcoatRoughnessMap!==void 0)this.clearcoatRoughnessMap=t[e.clearcoatRoughnessMap]||null;if(e.clearcoatNormalMap!==void 0)this.clearcoatNormalMap=t[e.clearcoatNormalMap]||null;if(e.clearcoatNormalScale!==void 0)this.clearcoatNormalScale=new Ne().fromArray(e.clearcoatNormalScale);if(e.iridescenceMap!==void 0)this.iridescenceMap=t[e.iridescenceMap]||null;if(e.iridescenceThicknessMap!==void 0)this.iridescenceThicknessMap=t[e.iridescenceThicknessMap]||null;if(e.transmissionMap!==void 0)this.transmissionMap=t[e.transmissionMap]||null;if(e.thicknessMap!==void 0)this.thicknessMap=t[e.thicknessMap]||null;if(e.anisotropyMap!==void 0)this.anisotropyMap=t[e.anisotropyMap]||null;if(e.sheenColorMap!==void 0)this.sheenColorMap=t[e.sheenColorMap]||null;if(e.sheenRoughnessMap!==void 0)this.sheenRoughnessMap=t[e.sheenRoughnessMap]||null;return this}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;let t=e.clippingPlanes,n=null;if(t!==null){let i=t.length;n=Array(i);for(let r=0;r!==i;++r)n[r]=t[r].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.allowOverride=e.allowOverride,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){if(e===!0)this.version++}}var Ei=new O,sl=new O,Qo=new O,ea=new O;class Ki{constructor(e=new O,t=new O(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,Ei)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);let n=t.dot(this.direction);if(n<0)return t.copy(this.origin);return t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){let t=Ei.subVectors(e,this.origin).dot(this.direction);if(t<0)return this.origin.distanceToSquared(e);return Ei.copy(this.origin).addScaledVector(this.direction,t),Ei.distanceToSquared(e)}distanceSqToSegment(e,t,n,i){sl.copy(e).add(t).multiplyScalar(0.5),Qo.copy(t).sub(e).normalize(),ea.copy(this.origin).sub(sl);let r=e.distanceTo(t)*0.5,s=-this.direction.dot(Qo),o=ea.dot(this.direction),a=-ea.dot(Qo),c=ea.lengthSq(),l=Math.abs(1-s*s),u,f,h,d;if(l>0)if(u=s*a-o,f=s*o-a,d=r*l,u>=0)if(f>=-d)if(f<=d){let g=1/l;u*=g,f*=g,h=u*(u+s*f+2*o)+f*(s*u+f+2*a)+c}else f=r,u=Math.max(0,-(s*f+o)),h=-u*u+f*(f+2*a)+c;else f=-r,u=Math.max(0,-(s*f+o)),h=-u*u+f*(f+2*a)+c;else if(f<=-d)u=Math.max(0,-(-s*r+o)),f=u>0?-r:Math.min(Math.max(-r,-a),r),h=-u*u+f*(f+2*a)+c;else if(f<=d)u=0,f=Math.min(Math.max(-r,-a),r),h=f*(f+2*a)+c;else u=Math.max(0,-(s*r+o)),f=u>0?r:Math.min(Math.max(-r,-a),r),h=-u*u+f*(f+2*a)+c;else f=s>0?-r:r,u=Math.max(0,-(s*f+o)),h=-u*u+f*(f+2*a)+c;if(n)n.copy(this.origin).addScaledVector(this.direction,u);if(i)i.copy(sl).addScaledVector(Qo,f);return h}intersectSphere(e,t){if(e.radius<0)return null;Ei.subVectors(e.center,this.origin);let n=Ei.dot(this.direction),i=Ei.dot(Ei)-n*n,r=e.radius*e.radius;if(i>r)return null;let s=Math.sqrt(r-i),o=n-s,a=n+s;if(a<0)return null;if(o<0)return this.at(a,t);return this.at(o,t)}intersectsSphere(e){if(e.radius<0)return!1;return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let t=e.normal.dot(this.direction);if(t===0){if(e.distanceToPoint(this.origin)===0)return 0;return null}let n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){let n=this.distanceToPlane(e);if(n===null)return null;return this.at(n,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);if(t===0)return!0;if(e.normal.dot(this.direction)*t<0)return!0;return!1}intersectBox(e,t){let n,i,r,s,o,a,c=1/this.direction.x,l=1/this.direction.y,u=1/this.direction.z,f=this.origin;if(c>=0)n=(e.min.x-f.x)*c,i=(e.max.x-f.x)*c;else n=(e.max.x-f.x)*c,i=(e.min.x-f.x)*c;if(l>=0)r=(e.min.y-f.y)*l,s=(e.max.y-f.y)*l;else r=(e.max.y-f.y)*l,s=(e.min.y-f.y)*l;if(n>s||r>i)return null;if(r>n||isNaN(n))n=r;if(s<i||isNaN(i))i=s;if(u>=0)o=(e.min.z-f.z)*u,a=(e.max.z-f.z)*u;else o=(e.max.z-f.z)*u,a=(e.min.z-f.z)*u;if(n>a||o>i)return null;if(o>n||n!==n)n=o;if(a<i||i!==i)i=a;if(i<0)return null;return this.at(n>=0?n:i,t)}intersectsBox(e){return this.intersectBox(e,Ei)!==null}intersectTriangle(e,t,n,i,r){let s=this.origin,o=this.direction,{x:a,y:c,z:l}=o,u=e.x-s.x,f=e.y-s.y,h=e.z-s.z,d=t.x-s.x,g=t.y-s.y,x=t.z-s.z,p=n.x-s.x,m=n.y-s.y,E=n.z-s.z,R=Math.abs(a),v=Math.abs(c),M=Math.abs(l),T,A,_,S,z,P,F,ee,I,H,q,C;if(R>=v&&R>=M)if(_=a,P=u,I=d,C=p,a>=0)T=c,A=l,S=f,z=h,F=g,ee=x,H=m,q=E;else T=l,A=c,S=h,z=f,F=x,ee=g,H=E,q=m;else if(v>=M)if(_=c,P=f,I=g,C=m,c>=0)T=l,A=a,S=h,z=u,F=x,ee=d,H=E,q=p;else T=a,A=l,S=u,z=h,F=d,ee=x,H=p,q=E;else if(_=l,P=h,I=x,C=E,l>=0)T=a,A=c,S=u,z=f,F=d,ee=g,H=p,q=m;else T=c,A=a,S=f,z=u,F=g,ee=d,H=m,q=p;if(_===0)return null;let X=T/_,k=A/_,Y=1/_,Q=S-X*P,Se=z-k*P,ue=F-X*I,Fe=ee-k*I,Me=H-X*C,Z=q-k*C,re=Me*Fe-Z*ue,se=Q*Z-Se*Me,xe=ue*Se-Fe*Q;if(i){if(re<0||se<0||xe<0)return null}else if((re<0||se<0||xe<0)&&(re>0||se>0||xe>0))return null;let we=re+se+xe;if(we===0)return null;let Ee=Y*(re*P+se*I+xe*C);if(we>0?Ee<0:Ee>0)return null;return this.at(Ee/we,r)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class ai extends hn{constructor(e){super();this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Oe(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new ni,this.combine=0,this.reflectivity=1,this.refractionRatio=0.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}var Vf=new Ge,gr=new Ki,ta=new xn,$f=new O,na=new O,ia=new O,ra=new O,ol=new O,sa=new O,Wf=new O,oa=new O;class _t extends ut{constructor(e=new en,t=new ai){super();this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){if(super.copy(e,t),e.morphTargetInfluences!==void 0)this.morphTargetInfluences=e.morphTargetInfluences.slice();if(e.morphTargetDictionary!==void 0)this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary);return this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,s=i.length;r<s;r++){let o=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}getVertexPosition(e,t){let n=this.geometry,i=n.attributes.position,r=n.morphAttributes.position,s=n.morphTargetsRelative;t.fromBufferAttribute(i,e);let o=this.morphTargetInfluences;if(r&&o){sa.set(0,0,0);for(let a=0,c=r.length;a<c;a++){let l=o[a],u=r[a];if(l===0)continue;if(ol.fromBufferAttribute(u,e),s)sa.addScaledVector(ol,l);else sa.addScaledVector(ol.sub(t),l)}t.add(sa)}return t}intersectsFrustum(e){return e.intersectsObject(this)}raycast(e,t){let n=this.geometry,i=this.material,r=this.matrixWorld;if(i===void 0)return;if(n.boundingSphere===null)n.computeBoundingSphere();if(ta.copy(n.boundingSphere),ta.applyMatrix4(r),gr.copy(e.ray).recast(e.near),ta.containsPoint(gr.origin)===!1){if(gr.intersectSphere(ta,$f)===null)return;if(gr.origin.distanceToSquared($f)>(e.far-e.near)**2)return}if(Vf.copy(r).invert(),gr.copy(e.ray).applyMatrix4(Vf),n.boundingBox!==null){if(gr.intersectsBox(n.boundingBox)===!1)return}this._computeIntersections(e,t,gr)}_computeIntersections(e,t,n){let i,r=this.geometry,s=this.material,o=r.index,a=r.attributes.position,c=r.attributes.uv,l=r.attributes.uv1,u=r.attributes.normal,{groups:f,drawRange:h}=r;if(o!==null)if(Array.isArray(s))for(let d=0,g=f.length;d<g;d++){let x=f[d],p=s[x.materialIndex],m=Math.max(x.start,h.start),E=Math.min(o.count,Math.min(x.start+x.count,h.start+h.count));for(let R=m,v=E;R<v;R+=3){let M=o.getX(R),T=o.getX(R+1),A=o.getX(R+2);if(i=aa(this,p,e,n,c,l,u,M,T,A),i)i.faceIndex=Math.floor(R/3),i.face.materialIndex=x.materialIndex,t.push(i)}}else{let d=Math.max(0,h.start),g=Math.min(o.count,h.start+h.count);for(let x=d,p=g;x<p;x+=3){let m=o.getX(x),E=o.getX(x+1),R=o.getX(x+2);if(i=aa(this,s,e,n,c,l,u,m,E,R),i)i.faceIndex=Math.floor(x/3),t.push(i)}}else if(a!==void 0)if(Array.isArray(s))for(let d=0,g=f.length;d<g;d++){let x=f[d],p=s[x.materialIndex],m=Math.max(x.start,h.start),E=Math.min(a.count,Math.min(x.start+x.count,h.start+h.count));for(let R=m,v=E;R<v;R+=3){let M=R,T=R+1,A=R+2;if(i=aa(this,p,e,n,c,l,u,M,T,A),i)i.faceIndex=Math.floor(R/3),i.face.materialIndex=x.materialIndex,t.push(i)}}else{let d=Math.max(0,h.start),g=Math.min(a.count,h.start+h.count);for(let x=d,p=g;x<p;x+=3){let m=x,E=x+1,R=x+2;if(i=aa(this,s,e,n,c,l,u,m,E,R),i)i.faceIndex=Math.floor(x/3),t.push(i)}}}}function eb(e,t,n,i,r,s,o,a){let c;if(t.side===1)c=i.intersectTriangle(o,s,r,!0,a);else c=i.intersectTriangle(r,s,o,t.side===0,a);if(c===null)return null;oa.copy(a),oa.applyMatrix4(e.matrixWorld);let l=n.ray.origin.distanceTo(oa);if(l<n.near||l>n.far)return null;return{distance:l,point:oa.clone(),object:e}}function aa(e,t,n,i,r,s,o,a,c,l){e.getVertexPosition(a,na),e.getVertexPosition(c,ia),e.getVertexPosition(l,ra);let u=eb(e,t,n,i,na,ia,ra,Wf);if(u){let f=new O;if(Cn.getBarycoord(Wf,na,ia,ra,f),r)u.uv=Cn.getInterpolatedAttribute(r,a,c,l,f,new Ne);if(s)u.uv1=Cn.getInterpolatedAttribute(s,a,c,l,f,new Ne);if(o){if(u.normal=Cn.getInterpolatedAttribute(o,a,c,l,f,new O),u.normal.dot(i.direction)>0)u.normal.multiplyScalar(-1)}let h={a,b:c,c:l,normal:new O,materialIndex:0};Cn.getNormal(na,ia,ra,h.normal),u.face=h,u.barycoord=f}return u}var Us=new at,Zf=new at,Xf=new at,tb=new at,qf=new Ge,ca=new O,al=new xn,jf=new Ge,cl=new Ki;class Fa extends _t{constructor(e,t){super(e,t);this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode="attached",this.bindMatrix=new Ge,this.bindMatrixInverse=new Ge,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){let e=this.geometry;if(this.boundingBox===null)this.boundingBox=new Ft;this.boundingBox.makeEmpty();let t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,ca),this.boundingBox.expandByPoint(ca)}computeBoundingSphere(){let e=this.geometry;if(this.boundingSphere===null)this.boundingSphere=new xn;this.boundingSphere.makeEmpty();let t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,ca),this.boundingSphere.expandByPoint(ca)}copy(e,t){if(super.copy(e,t),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,e.boundingBox!==null)this.boundingBox=e.boundingBox.clone();if(e.boundingSphere!==null)this.boundingSphere=e.boundingSphere.clone();return this}raycast(e,t){let n=this.material,i=this.matrixWorld;if(n===void 0)return;if(this.boundingSphere===null)this.computeBoundingSphere();if(al.copy(this.boundingSphere),al.applyMatrix4(i),e.ray.intersectsSphere(al)===!1)return;if(jf.copy(i).invert(),cl.copy(e.ray).applyMatrix4(jf),this.boundingBox!==null){if(cl.intersectsBox(this.boundingBox)===!1)return}this._computeIntersections(e,t,cl)}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){if(this.skeleton=e,t===void 0)this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld;this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){let e=new at,t=this.geometry.attributes.skinWeight;for(let n=0,i=t.count;n<i;n++){e.fromBufferAttribute(t,n);let r=1/e.manhattanLength();if(r!==1/0)e.multiplyScalar(r);else e.set(1,0,0,0);t.setXYZW(n,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){if(super.updateMatrixWorld(e),this.bindMode==="attached")this.bindMatrixInverse.copy(this.matrixWorld).invert();else if(this.bindMode==="detached")this.bindMatrixInverse.copy(this.bindMatrix).invert();else Ie("SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){let n=this.skeleton,i=this.geometry;if(Zf.fromBufferAttribute(i.attributes.skinIndex,e),Xf.fromBufferAttribute(i.attributes.skinWeight,e),t.isVector4)Us.copy(t),t.set(0,0,0,0);else Us.set(...t,1),t.set(0,0,0);Us.applyMatrix4(this.bindMatrix);for(let r=0;r<4;r++){let s=Xf.getComponent(r);if(s!==0){let o=Zf.getComponent(r);qf.multiplyMatrices(n.bones[o].matrixWorld,n.boneInverses[o]),t.addScaledVector(tb.copy(Us).applyMatrix4(qf),s)}}if(t.isVector4)t.w=Us.w;return t.applyMatrix4(this.bindMatrixInverse)}}class Qs extends ut{constructor(){super();this.isBone=!0,this.type="Bone"}}class eo extends At{constructor(e=null,t=1,n=1,i,r,s,o,a,c=1003,l=1003,u,f){super(null,s,o,a,c,l,i,r,u,f);this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}var Yf=new Ge,nb=new Ge;class to{constructor(e=[],t=[]){this.uuid=Gn(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){let e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){Ie("Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let n=0,i=this.bones.length;n<i;n++)this.boneInverses.push(new Ge)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){let n=new Ge;if(this.bones[e])n.copy(this.bones[e].matrixWorld).invert();this.boneInverses.push(n)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){let n=this.bones[e];if(n)n.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){let n=this.bones[e];if(n){if(n.parent&&n.parent.isBone)n.matrix.copy(n.parent.matrixWorld).invert(),n.matrix.multiply(n.matrixWorld);else n.matrix.copy(n.matrixWorld);n.matrix.decompose(n.position,n.quaternion,n.scale)}}}update(){let e=this.bones,t=this.boneInverses,n=this.boneMatrices,i=this.boneTexture;for(let r=0,s=e.length;r<s;r++){let o=e[r]?e[r].matrixWorld:nb;Yf.multiplyMatrices(o,t[r]),Yf.toArray(n,r*16)}if(i!==null)i.needsUpdate=!0}clone(){return new to(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);let t=new Float32Array(e*e*4);t.set(this.boneMatrices);let n=new eo(t,e,e,1023,1015);return n.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=n,this}getBoneByName(e){for(let t=0,n=this.bones.length;t<n;t++){let i=this.bones[t];if(i.name===e)return i}return}dispose(){if(this.boneTexture!==null)this.boneTexture.dispose(),this.boneTexture=null}fromJSON(e,t){this.uuid=e.uuid;for(let n=0,i=e.bones.length;n<i;n++){let r=e.bones[n],s=t[r];if(s===void 0)Ie("Skeleton: No bone found with UUID:",r),s=new Qs;this.bones.push(s),this.boneInverses.push(new Ge().fromArray(e.boneInverses[n]))}return this.init(),this}toJSON(){let e={metadata:{version:4.7,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;let t=this.bones,n=this.boneInverses;for(let i=0,r=t.length;i<r;i++){let s=t[i];e.bones.push(s.uuid);let o=n[i];e.boneInverses.push(o.toArray())}return e}}class Wi extends Vt{constructor(e,t,n,i=1){super(e,t,n);this.isInstancedBufferAttribute=!0,this.meshPerAttribute=i}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){let e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}}var Kr=new Ge,Kf=new Ge,la=[],Jf=new Ft,ib=new Ge,Fs=new _t,zs=new xn;class ms extends _t{constructor(e,t,n){super(e,t);this.isInstancedMesh=!0,this.instanceMatrix=new Wi(new Float32Array(n*16),16),this.instanceColor=null,this.morphTexture=null,this.count=n,this.boundingBox=null,this.boundingSphere=null;for(let i=0;i<n;i++)this.setMatrixAt(i,ib)}computeBoundingBox(){let e=this.geometry,t=this.count;if(this.boundingBox===null)this.boundingBox=new Ft;if(e.boundingBox===null)e.computeBoundingBox();this.boundingBox.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,Kr),Jf.copy(e.boundingBox).applyMatrix4(Kr),this.boundingBox.union(Jf)}computeBoundingSphere(){let e=this.geometry,t=this.count;if(this.boundingSphere===null)this.boundingSphere=new xn;if(e.boundingSphere===null)e.computeBoundingSphere();this.boundingSphere.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,Kr),zs.copy(e.boundingSphere).applyMatrix4(Kr),this.boundingSphere.union(zs)}copy(e,t){if(super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.morphTexture!==null)this.morphTexture=e.morphTexture.clone();if(e.instanceColor!==null)this.instanceColor=e.instanceColor.clone();if(this.count=e.count,e.boundingBox!==null)this.boundingBox=e.boundingBox.clone();if(e.boundingSphere!==null)this.boundingSphere=e.boundingSphere.clone();return this}getColorAt(e,t){if(this.instanceColor===null)return t.setRGB(1,1,1);else return t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){return t.fromArray(this.instanceMatrix.array,e*16)}getMorphAt(e,t){let n=t.morphTargetInfluences,i=this.morphTexture.source.data.data,r=n.length+1,s=e*r+1;for(let o=0;o<n.length;o++)n[o]=i[s+o]}raycast(e,t){let n=this.matrixWorld,i=this.count;if(Fs.geometry=this.geometry,Fs.material=this.material,Fs.material===void 0)return;if(this.boundingSphere===null)this.computeBoundingSphere();if(zs.copy(this.boundingSphere),zs.applyMatrix4(n),e.ray.intersectsSphere(zs)===!1)return;for(let r=0;r<i;r++){this.getMatrixAt(r,Kr),Kf.multiplyMatrices(n,Kr),Fs.matrixWorld=Kf,Fs.raycast(e,la);for(let s=0,o=la.length;s<o;s++){let a=la[s];a.instanceId=r,a.object=this,t.push(a)}la.length=0}}setColorAt(e,t){if(this.instanceColor===null)this.instanceColor=new Wi(new Float32Array(this.instanceMatrix.count*3).fill(1),3);return t.toArray(this.instanceColor.array,e*3),this}setMatrixAt(e,t){return t.toArray(this.instanceMatrix.array,e*16),this}setMorphAt(e,t){let n=t.morphTargetInfluences,i=n.length+1;if(this.morphTexture===null)this.morphTexture=new eo(new Float32Array(i*this.count),i,this.count,1028,1015);let r=this.morphTexture.source.data.data,s=0;for(let c=0;c<n.length;c++)s+=n[c];let o=this.geometry.morphTargetsRelative?1:1-s,a=i*e;return r[a]=o,r.set(n,a+1),this}updateMorphTargets(){}dispose(){if(super.dispose(),this.morphTexture!==null)this.morphTexture.dispose(),this.morphTexture=null}}var _r=new xn,rb=new Ne(0.5,0.5),ua=new O;class no{constructor(e=new Rn,t=new Rn,n=new Rn,i=new Rn,r=new Rn,s=new Rn){this.planes=[e,t,n,i,r,s]}set(e,t,n,i,r,s){let o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(n),o[3].copy(i),o[4].copy(r),o[5].copy(s),this}copy(e){let t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=2000,n=!1){let i=this.planes,r=e.elements,s=r[0],o=r[1],a=r[2],c=r[3],l=r[4],u=r[5],f=r[6],h=r[7],d=r[8],g=r[9],x=r[10],p=r[11],m=r[12],E=r[13],R=r[14],v=r[15];if(i[0].setComponents(c-s,h-l,p-d,v-m).normalize(),i[1].setComponents(c+s,h+l,p+d,v+m).normalize(),i[2].setComponents(c+o,h+u,p+g,v+E).normalize(),i[3].setComponents(c-o,h-u,p-g,v-E).normalize(),n)i[4].setComponents(a,f,x,R).normalize(),i[5].setComponents(c-a,h-f,p-x,v-R).normalize();else if(i[4].setComponents(c-a,h-f,p-x,v-R).normalize(),t===2000)i[5].setComponents(c+a,h+f,p+x,v+R).normalize();else if(t===2001)i[5].setComponents(a,f,x,R).normalize();else throw Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0){if(e.boundingSphere===null)e.computeBoundingSphere();_r.copy(e.boundingSphere).applyMatrix4(e.matrixWorld)}else{let t=e.geometry;if(t.boundingSphere===null)t.computeBoundingSphere();_r.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(_r)}intersectsSprite(e){_r.center.set(0,0,0);let t=rb.distanceTo(e.center);return _r.radius=0.7071067811865476+t,_r.applyMatrix4(e.matrixWorld),this.intersectsSphere(_r)}intersectsSphere(e){let t=this.planes,n=e.center,i=-e.radius;for(let r=0;r<6;r++)if(t[r].distanceToPoint(n)<i)return!1;return!0}intersectsBox(e){let t=this.planes;for(let n=0;n<6;n++){let i=t[n];if(ua.x=i.normal.x>0?e.max.x:e.min.x,ua.y=i.normal.y>0?e.max.y:e.min.y,ua.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(ua)<0)return!1}return!0}containsPoint(e){let t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}class io extends hn{constructor(e){super();this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Oe(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}var xa=new O,ya=new O,Qf=new Ge,ks=new Ki,ha=new xn,ll=new O,ed=new O;class Ji extends ut{constructor(e=new en,t=new io){super();this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[0];for(let i=1,r=t.count;i<r;i++)xa.fromBufferAttribute(t,i-1),ya.fromBufferAttribute(t,i),n[i]=n[i-1],n[i]+=xa.distanceTo(ya);e.setAttribute("lineDistance",new un(n,1))}else Ie("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}intersectsFrustum(e){return e.intersectsObject(this)}raycast(e,t){let n=this.geometry,i=this.matrixWorld,r=e.params.Line.threshold,s=n.drawRange;if(n.boundingSphere===null)n.computeBoundingSphere();if(ha.copy(n.boundingSphere),ha.applyMatrix4(i),ha.radius+=r,e.ray.intersectsSphere(ha)===!1)return;Qf.copy(i).invert(),ks.copy(e.ray).applyMatrix4(Qf);let o=r/((this.scale.x+this.scale.y+this.scale.z)/3),a=o*o,c=this.isLineSegments?2:1,l=n.index,f=n.attributes.position;if(l!==null){let h=Math.max(0,s.start),d=Math.min(l.count,s.start+s.count);for(let g=h,x=d-1;g<x;g+=c){let p=l.getX(g),m=l.getX(g+1),E=fa(this,e,ks,a,p,m,g);if(E)t.push(E)}if(this.isLineLoop){let g=l.getX(d-1),x=l.getX(h),p=fa(this,e,ks,a,g,x,d-1);if(p)t.push(p)}}else{let h=Math.max(0,s.start),d=Math.min(f.count,s.start+s.count);for(let g=h,x=d-1;g<x;g+=c){let p=fa(this,e,ks,a,g,g+1,g);if(p)t.push(p)}if(this.isLineLoop){let g=fa(this,e,ks,a,d-1,h,d-1);if(g)t.push(g)}}}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,s=i.length;r<s;r++){let o=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}}function fa(e,t,n,i,r,s,o){let a=e.geometry.attributes.position;if(xa.fromBufferAttribute(a,r),ya.fromBufferAttribute(a,s),n.distanceSqToSegment(xa,ya,ll,ed)>i)return;ll.applyMatrix4(e.matrixWorld);let l=t.ray.origin.distanceTo(ll);if(l<t.near||l>t.far)return;return{distance:l,point:ed.clone().applyMatrix4(e.matrixWorld),index:o,face:null,faceIndex:null,barycoord:null,object:e}}var td=new O,nd=new O;class za extends Ji{constructor(e,t){super(e,t);this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[];for(let i=0,r=t.count;i<r;i+=2)td.fromBufferAttribute(t,i),nd.fromBufferAttribute(t,i+1),n[i]=i===0?0:n[i-1],n[i+1]=n[i]+td.distanceTo(nd);e.setAttribute("lineDistance",new un(n,1))}else Ie("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class ka extends Ji{constructor(e,t){super(e,t);this.isLineLoop=!0,this.type="LineLoop"}}class ro extends hn{constructor(e){super();this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new Oe(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}var id=new Ge,fl=new Ki,da=new xn,pa=new O;class gs extends ut{constructor(e=new en,t=new ro){super();this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}intersectsFrustum(e){return e.intersectsObject(this)}raycast(e,t){let n=this.geometry,i=this.matrixWorld,r=e.params.Points.threshold,s=n.drawRange;if(n.boundingSphere===null)n.computeBoundingSphere();if(da.copy(n.boundingSphere),da.applyMatrix4(i),da.radius+=r,e.ray.intersectsSphere(da)===!1)return;id.copy(i).invert(),fl.copy(e.ray).applyMatrix4(id);let o=r/((this.scale.x+this.scale.y+this.scale.z)/3),a=o*o,c=n.index,u=n.attributes.position;if(c!==null){let f=Math.max(0,s.start),h=Math.min(c.count,s.start+s.count);for(let d=f,g=h;d<g;d++){let x=c.getX(d);pa.fromBufferAttribute(u,x),rd(pa,x,a,i,e,t,this)}}else{let f=Math.max(0,s.start),h=Math.min(u.count,s.start+s.count);for(let d=f,g=h;d<g;d++)pa.fromBufferAttribute(u,d),rd(pa,d,a,i,e,t,this)}}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,s=i.length;r<s;r++){let o=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}}function rd(e,t,n,i,r,s,o){let a=fl.distanceSqToPoint(e);if(a<n){let c=new O;fl.closestPointToPoint(e,c),c.applyMatrix4(i);let l=r.ray.origin.distanceTo(c);if(l<r.near||l>r.far)return;s.push({distance:l,distanceToRay:Math.sqrt(a),point:c,index:t,face:null,faceIndex:null,barycoord:null,object:o})}}class Ba extends At{constructor(e=[],t=301,n,i,r,s,o,a,c,l){super(e,t,n,i,r,s,o,a,c,l);this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class Tr extends At{constructor(e,t,n=1014,i,r,s,o=1003,a=1003,c,l=1026,u=1){if(l!==1026&&l!==1027)throw Error("THREE.DepthTexture: format must be either THREE.DepthFormat or THREE.DepthStencilFormat");let f={width:e,height:t,depth:u};super(f,i,r,s,o,a,l,n,c);this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new Ys(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){let t=super.toJSON(e);return t.compareFunction=this.compareFunction,t}}class gu extends Tr{constructor(e,t=1014,n=301,i,r,s=1003,o=1003,a,c=1026){let l={width:e,height:e,depth:1},u=[l,l,l,l,l,l];super(e,e,t,n,i,r,s,o,a,c);this.image=u,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}}class Ga extends At{constructor(e=null){super();this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class Qi extends en{constructor(e=1,t=1,n=1,i=1,r=1,s=1){super();this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:i,heightSegments:r,depthSegments:s};let o=this;i=Math.floor(i),r=Math.floor(r),s=Math.floor(s);let a=[],c=[],l=[],u=[],f=0,h=0;d("z","y","x",-1,-1,n,t,e,s,r,0),d("z","y","x",1,-1,n,t,-e,s,r,1),d("x","z","y",1,1,e,n,t,i,s,2),d("x","z","y",1,-1,e,n,-t,i,s,3),d("x","y","z",1,-1,e,t,n,i,r,4),d("x","y","z",-1,-1,e,t,-n,i,r,5),this.setIndex(a),this.setAttribute("position",new un(c,3)),this.setAttribute("normal",new un(l,3)),this.setAttribute("uv",new un(u,2));function d(g,x,p,m,E,R,v,M,T,A,_){let S=R/T,z=v/A,P=R/2,F=v/2,ee=M/2,I=T+1,H=A+1,q=0,C=0,X=new O;for(let k=0;k<H;k++){let Y=k*z-F;for(let Q=0;Q<I;Q++){let Se=Q*S-P;X[g]=Se*m,X[x]=Y*E,X[p]=ee,c.push(X.x,X.y,X.z),X[g]=0,X[x]=0,X[p]=M>0?1:-1,l.push(X.x,X.y,X.z),u.push(Q/T),u.push(1-k/A),q+=1}}for(let k=0;k<A;k++)for(let Y=0;Y<T;Y++){let Q=f+Y+I*k,Se=f+Y+I*(k+1),ue=f+(Y+1)+I*(k+1),Fe=f+(Y+1)+I*k;a.push(Q,Se,Fe),a.push(Se,ue,Fe),C+=6}o.addGroup(h,C,_),h+=C,f+=q}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Qi(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}class so extends en{constructor(e=1,t=1,n=1,i=1){super();this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:i};let r=e/2,s=t/2,o=Math.floor(n),a=Math.floor(i),c=o+1,l=a+1,u=e/o,f=t/a,h=[],d=[],g=[],x=[];for(let p=0;p<l;p++){let m=p*f-s;for(let E=0;E<c;E++){let R=E*u-r;d.push(R,-m,0),g.push(0,0,1),x.push(E/o),x.push(1-p/a)}}for(let p=0;p<a;p++)for(let m=0;m<o;m++){let E=m+c*p,R=m+c*(p+1),v=m+1+c*(p+1),M=m+1+c*p;h.push(E,R,M),h.push(R,v,M)}this.setIndex(h),this.setAttribute("position",new un(d,3)),this.setAttribute("normal",new un(g,3)),this.setAttribute("uv",new un(x,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new so(e.width,e.height,e.widthSegments,e.heightSegments)}}function Ar(e){let t={};for(let n in e){t[n]={};for(let i in e[n]){let r=e[n][i];if(sd(r))if(r.isRenderTargetTexture)Ie("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),t[n][i]=null;else t[n][i]=r.clone();else if(Array.isArray(r))if(sd(r[0])){let s=[];for(let o=0,a=r.length;o<a;o++)s[o]=r[o].clone();t[n][i]=s}else t[n][i]=r.slice();else t[n][i]=r}}return t}function tn(e){let t={};for(let n=0;n<e.length;n++){let i=Ar(e[n]);for(let r in i)t[r]=i[r]}return t}function sd(e){return e&&(e.isColor||e.isMatrix3||e.isMatrix4||e.isVector2||e.isVector3||e.isVector4||e.isTexture||e.isQuaternion)}function sb(e){let t=[];for(let n=0;n<e.length;n++)t.push(e[n].clone());return t}function _u(e){let t=e.getRenderTarget();if(t===null)return e.outputColorSpace;if(t.isXRRenderTarget===!0)return t.texture.colorSpace;return $e.workingColorSpace}var fp={clone:Ar,merge:tn},ob=`void main() {
126
126
  gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
127
- }`,sb=`void main() {
127
+ }`,ab=`void main() {
128
128
  gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
129
- }`;class Pn extends hn{constructor(e){super();if(this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=rb,this.fragmentShader=sb,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={clipCullDistance:!1,multiDraw:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,e!==void 0)this.setValues(e)}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=Tr(e.uniforms),this.uniformsGroups=ib(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this.defaultAttributeValues=Object.assign({},e.defaultAttributeValues),this.index0AttributeName=e.index0AttributeName,this.uniformsNeedUpdate=e.uniformsNeedUpdate,this}toJSON(e){let t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(let i in this.uniforms){let s=this.uniforms[i].value;if(s&&s.isTexture)t.uniforms[i]={type:"t",value:s.toJSON(e).uuid};else if(s&&s.isColor)t.uniforms[i]={type:"c",value:s.getHex()};else if(s&&s.isVector2)t.uniforms[i]={type:"v2",value:s.toArray()};else if(s&&s.isVector3)t.uniforms[i]={type:"v3",value:s.toArray()};else if(s&&s.isVector4)t.uniforms[i]={type:"v4",value:s.toArray()};else if(s&&s.isMatrix3)t.uniforms[i]={type:"m3",value:s.toArray()};else if(s&&s.isMatrix4)t.uniforms[i]={type:"m4",value:s.toArray()};else t.uniforms[i]={value:s}}if(Object.keys(this.defines).length>0)t.defines=this.defines;t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;let n={};for(let i in this.extensions)if(this.extensions[i]===!0)n[i]=!0;if(Object.keys(n).length>0)t.extensions=n;return t}fromJSON(e,t){if(super.fromJSON(e,t),e.uniforms!==void 0)for(let n in e.uniforms){let i=e.uniforms[n];switch(this.uniforms[n]={},i.type){case"t":this.uniforms[n].value=t[i.value]||null;break;case"c":this.uniforms[n].value=new Ue().setHex(i.value);break;case"v2":this.uniforms[n].value=new Ne().fromArray(i.value);break;case"v3":this.uniforms[n].value=new D().fromArray(i.value);break;case"v4":this.uniforms[n].value=new ct().fromArray(i.value);break;case"m3":this.uniforms[n].value=new ke().fromArray(i.value);break;case"m4":this.uniforms[n].value=new Ge().fromArray(i.value);break;default:this.uniforms[n].value=i.value}}if(e.defines!==void 0)this.defines=e.defines;if(e.vertexShader!==void 0)this.vertexShader=e.vertexShader;if(e.fragmentShader!==void 0)this.fragmentShader=e.fragmentShader;if(e.glslVersion!==void 0)this.glslVersion=e.glslVersion;if(e.extensions!==void 0)for(let n in e.extensions)this.extensions[n]=e.extensions[n];if(e.lights!==void 0)this.lights=e.lights;if(e.clipping!==void 0)this.clipping=e.clipping;return this}}class _u extends Pn{constructor(e){super(e);this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class Ri extends hn{constructor(e){super();this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new Ue(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ue(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Ne(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new ni,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class yn extends Ri{constructor(e){super();this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new Ne(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return We(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+0.4*t)/(1-0.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new Ue(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new Ue(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new Ue(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._retroreflectivity=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){if(this._anisotropy>0!==e>0)this.version++;this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){if(this._clearcoat>0!==e>0)this.version++;this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){if(this._iridescence>0!==e>0)this.version++;this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){if(this._dispersion>0!==e>0)this.version++;this._dispersion=e}get retroreflectivity(){return this._retroreflectivity}set retroreflectivity(e){if(this._retroreflectivity>0!==e>0)this.version++;this._retroreflectivity=e}get sheen(){return this._sheen}set sheen(e){if(this._sheen>0!==e>0)this.version++;this._sheen=e}get transmission(){return this._transmission}set transmission(e){if(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.dispersion=e.dispersion,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.retroreflectivity=e.retroreflectivity,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 Ba extends hn{constructor(e){super();this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new Ue(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ue(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Ne(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new ni,this.combine=0,this.reflectivity=1,this.envMapIntensity=1,this.refractionRatio=0.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.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.envMapIntensity=e.envMapIntensity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class xu extends hn{constructor(e){super();this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=3200,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.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 yu extends hn{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}}function Vi(e,t){if(!e||e.constructor===t)return e;if(typeof t.BYTES_PER_ELEMENT==="number")return new t(e);return Array.prototype.slice.call(e)}function ma(e){return e!==void 0&&e.inTangents!==void 0&&e.outTangents!==void 0}function ob(e){function t(r,s){return e[r]-e[s]}let n=e.length,i=Array(n);for(let r=0;r!==n;++r)i[r]=r;return i.sort(t),i}function sd(e,t,n){let i=e.length,r=new e.constructor(i);for(let s=0,o=0;o!==i;++s){let a=n[s]*t;for(let c=0;c!==t;++c)r[o++]=e[a+c]}return r}function ab(e,t,n,i){let r=1,s=e[0];while(s!==void 0&&s[i]===void 0)s=e[r++];if(s===void 0)return;let o=s[i];if(o===void 0)return;if(Array.isArray(o))do{if(o=s[i],o!==void 0)t.push(s.time),n.push(...o);s=e[r++]}while(s!==void 0);else if(o.toArray!==void 0)do{if(o=s[i],o!==void 0)t.push(s.time),o.toArray(n,n.length);s=e[r++]}while(s!==void 0);else do{if(o=s[i],o!==void 0)t.push(s.time),n.push(o);s=e[r++]}while(s!==void 0)}class Ci{constructor(e,t,n,i){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=i!==void 0?i:new t.constructor(n),this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){let t=this.parameterPositions,n=this._cachedIndex,i=t[n],r=t[n-1];e:{t:{let s;n:{i:if(!(e<i)){for(let o=n+2;;){if(i===void 0){if(e<r)break i;return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===o)break;if(r=i,i=t[++n],e<i)break t}s=t.length;break n}if(!(e>=r)){let o=t[1];if(e<o)n=2,r=o;for(let a=n-2;;){if(r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===a)break;if(i=r,r=t[--n-1],e>=r)break t}s=n,n=0;break n}break e}while(n<s){let o=n+s>>>1;if(e<t[o])s=o;else n=o+1}if(i=t[n],r=t[n-1],r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===void 0)return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,r,i)}return this.interpolate_(n,r,e,i)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){let t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=e*i;for(let s=0;s!==i;++s)t[s]=n[r+s];return t}interpolate_(){throw Error("THREE.Interpolant: Call to abstract method.")}intervalChanged_(){}}class vu extends Ci{constructor(e,t,n,i){super(e,t,n,i);this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:2400,endingEnd:2400}}intervalChanged_(e,t,n){let i=this.parameterPositions,r=e-2,s=e+1,o=i[r],a=i[s];if(o===void 0)switch(this.getSettings_().endingStart){case 2401:r=e,o=2*t-n;break;case 2402:r=i.length-2,o=t+i[r]-i[r+1];break;default:r=e,o=n}if(a===void 0)switch(this.getSettings_().endingEnd){case 2401:s=e,a=2*n-t;break;case 2402:s=1,a=n+i[1]-i[0];break;default:s=e-1,a=t}let c=(n-t)*0.5,l=this.valueSize;this._weightPrev=c/(t-o),this._weightNext=c/(a-n),this._offsetPrev=r*l,this._offsetNext=s*l}interpolate_(e,t,n,i){let r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=e*o,c=a-o,l=this._offsetPrev,u=this._offsetNext,f=this._weightPrev,h=this._weightNext,d=(n-t)/(i-t),g=d*d,x=g*d,p=-f*x+2*f*g-f*d,m=(1+f)*x+(-1.5-2*f)*g+(-0.5+f)*d+1,E=(-1-h)*x+(1.5+h)*g+0.5*d,R=h*x-h*g;for(let v=0;v!==o;++v)r[v]=p*s[l+v]+m*s[c+v]+E*s[a+v]+R*s[u+v];return r}}class Ga extends Ci{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){let r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=e*o,c=a-o,l=(n-t)/(i-t),u=1-l;for(let f=0;f!==o;++f)r[f]=s[c+f]*u+s[a+f]*l;return r}}class bu extends Ci{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e){return this.copySampleValue_(e-1)}}class Su extends Ci{interpolate_(e,t,n,i){let r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=e*o,c=a-o,l=this.inTangents,u=this.outTangents;if(!l||!u){let d=(n-t)/(i-t),g=1-d;for(let x=0;x!==o;++x)r[x]=s[c+x]*g+s[a+x]*d;return r}let f=o*2,h=e-1;for(let d=0;d!==o;++d){let g=s[c+d],x=s[a+d],p=h*f+d*2,m=u[p],E=u[p+1],R=e*f+d*2,v=l[R],M=l[R+1],T=lb(n,t,m,v,i);r[d]=fp(T,g,E,M,x)}return r}}function fp(e,t,n,i,r){let s=1-e;return s*s*s*t+3*s*s*e*n+3*s*e*e*i+e*e*e*r}function cb(e,t,n,i,r){let s=1-e;return 3*s*s*(n-t)+6*s*e*(i-n)+3*e*e*(r-i)}function lb(e,t,n,i,r){let s=(e-t)/(r-t);for(let o=0;o<8;o++){let a=fp(s,t,n,i,r)-e;if(Math.abs(a)<0.0000000001)break;let c=cb(s,t,n,i,r);if(Math.abs(c)<0.0000000001)break;s=Math.max(0,Math.min(1,s-a/c))}return s}class vn{constructor(e,t,n,i){if(e===void 0)throw Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=Vi(t,this.TimeBufferType),this.values=Vi(n,this.ValueBufferType),this.setInterpolation(i||this.DefaultInterpolation)}static toJSON(e){let t=e.constructor,n;if(t.toJSON!==this.toJSON)n=t.toJSON(e);else{n={name:e.name,times:Vi(e.times,Array),values:Vi(e.values,Array)};let i=e.getInterpolation();if(i!==e.DefaultInterpolation)n.interpolation=i;if(ma(e.settings))n.settings={inTangents:Vi(e.settings.inTangents,Array),outTangents:Vi(e.settings.outTangents,Array)}}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new bu(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new Ga(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new vu(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodBezier(e){let t=new Su(this.times,this.values,this.getValueSize(),e);if(this.settings)t.inTangents=this.settings.inTangents,t.outTangents=this.settings.outTangents;return t}setInterpolation(e){let t;switch(e){case 2300:t=this.InterpolantFactoryMethodDiscrete;break;case 2301:t=this.InterpolantFactoryMethodLinear;break;case 2302:t=this.InterpolantFactoryMethodSmooth;break;case 2303:t=this.InterpolantFactoryMethodBezier;break}if(t===void 0){let n="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw Error(n);return Pe("KeyframeTrack:",n),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return 2300;case this.InterpolantFactoryMethodLinear:return 2301;case this.InterpolantFactoryMethodSmooth:return 2302;case this.InterpolantFactoryMethodBezier:return 2303}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){let t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]+=e}return this}scale(e){if(e!==1){let t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]*=e;if(ma(this.settings))od(this.settings.inTangents,e),od(this.settings.outTangents,e)}return this}trim(e,t){let n=this.times,i=n.length,r=0,s=i-1;while(r!==i&&n[r]<e)++r;while(s!==-1&&n[s]>t)--s;if(++s,r!==0||s!==i){if(r>=s)s=Math.max(s,1),r=s-1;let o=this.getValueSize();this.times=n.slice(r,s),this.values=this.values.slice(r*o,s*o)}return this}validate(){let e=!0,t=this.getValueSize();if(t-Math.floor(t)!==0)Fe("KeyframeTrack: Invalid value size in track.",this),e=!1;let n=this.times,i=this.values,r=n.length;if(r===0)Fe("KeyframeTrack: Track is empty.",this),e=!1;let s=null;for(let o=0;o!==r;o++){let a=n[o];if(typeof a==="number"&&isNaN(a)){Fe("KeyframeTrack: Time is not a valid number.",this,o,a),e=!1;break}if(s!==null&&s>a){Fe("KeyframeTrack: Out of order keys.",this,o,a,s),e=!1;break}s=a}if(i!==void 0){if(yv(i))for(let o=0,a=i.length;o!==a;++o){let c=i[o];if(isNaN(c)){Fe("KeyframeTrack: Value is not a valid number.",this,o,c),e=!1;break}}}return e}optimize(){let e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),i=this.getInterpolation()===2302,r=e.length-1,s=1;for(let o=1;o<r;++o){let a=!1,c=e[o],l=e[o+1];if(c!==l&&(o!==1||c!==e[0]))if(!i){let u=o*n,f=u-n,h=u+n;for(let d=0;d!==n;++d){let g=t[u+d];if(g!==t[f+d]||g!==t[h+d]){a=!0;break}}}else a=!0;if(a){if(o!==s){e[s]=e[o];let u=o*n,f=s*n;for(let h=0;h!==n;++h)t[f+h]=t[u+h]}++s}}if(r>0){e[s]=e[r];for(let o=r*n,a=s*n,c=0;c!==n;++c)t[a+c]=t[o+c];++s}if(s!==e.length)this.times=e.slice(0,s),this.values=t.slice(0,s*n);else this.times=e,this.values=t;return this}clone(){let e=this.times.slice(),t=this.values.slice(),i=new this.constructor(this.name,e,t);if(i.createInterpolant=this.createInterpolant,ma(this.settings))i.settings={inTangents:this.settings.inTangents.slice(),outTangents:this.settings.outTangents.slice()};return i}}function od(e,t){for(let n=0,i=e.length;n!==i;n+=2)e[n]*=t}vn.prototype.ValueTypeName="";vn.prototype.TimeBufferType=Float32Array;vn.prototype.ValueBufferType=Float32Array;vn.prototype.DefaultInterpolation=2301;class Qi extends vn{constructor(e,t,n){super(e,t,n)}}Qi.prototype.ValueTypeName="bool";Qi.prototype.ValueBufferType=Array;Qi.prototype.DefaultInterpolation=2300;Qi.prototype.InterpolantFactoryMethodLinear=void 0;Qi.prototype.InterpolantFactoryMethodSmooth=void 0;class Ha extends vn{constructor(e,t,n,i){super(e,t,n,i)}}Ha.prototype.ValueTypeName="color";class er extends vn{constructor(e,t,n,i){super(e,t,n,i)}}er.prototype.ValueTypeName="number";class Mu extends Ci{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){let r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=(n-t)/(i-t),c=e*o;for(let l=c+o;c!==l;c+=4)Ht.slerpFlat(r,0,s,c-o,s,c,a);return r}}class tr extends vn{constructor(e,t,n,i){super(e,t,n,i)}InterpolantFactoryMethodLinear(e){return new Mu(this.times,this.values,this.getValueSize(),e)}}tr.prototype.ValueTypeName="quaternion";tr.prototype.InterpolantFactoryMethodSmooth=void 0;class nr extends vn{constructor(e,t,n){super(e,t,n)}}nr.prototype.ValueTypeName="string";nr.prototype.ValueBufferType=Array;nr.prototype.DefaultInterpolation=2300;nr.prototype.InterpolantFactoryMethodLinear=void 0;nr.prototype.InterpolantFactoryMethodSmooth=void 0;class Ar extends vn{constructor(e,t,n,i){super(e,t,n,i)}}Ar.prototype.ValueTypeName="vector";class ns{constructor(e="",t=-1,n=[],i=2500){if(this.name=e,this.tracks=n,this.duration=t,this.blendMode=i,this.uuid=Bn(),this.userData={},this.duration<0)this.resetDuration()}static parse(e){let t=[],n=e.tracks,i=1/(e.fps||1);for(let s=0,o=n.length;s!==o;++s)t.push(hb(n[s]).scale(i));let r=new this(e.name,e.duration,t,e.blendMode);return r.uuid=e.uuid,r.userData=JSON.parse(e.userData||"{}"),r}static toJSON(e){let t=[],n=e.tracks,i={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode,userData:JSON.stringify(e.userData)};for(let r=0,s=n.length;r!==s;++r)t.push(vn.toJSON(n[r]));return i}static CreateFromMorphTargetSequence(e,t,n,i){let r=t.length,s=[];for(let o=0;o<r;o++){let a=[],c=[];a.push((o+r-1)%r,o,(o+1)%r),c.push(0,1,0);let l=ob(a);if(a=sd(a,1,l),c=sd(c,1,l),!i&&a[0]===0)a.push(r),c.push(c[0]);s.push(new er(".morphTargetInfluences["+t[o].name+"]",a,c).scale(1/n))}return new this(e,-1,s)}static findByName(e,t){let n=e;if(!Array.isArray(e)){let i=e;n=i.geometry&&i.geometry.animations||i.animations}for(let i=0;i<n.length;i++)if(n[i].name===t)return n[i];return null}static CreateClipsFromMorphTargetSequences(e,t,n){let i={},r=/^([\w-]*?)([\d]+)$/;for(let o=0,a=e.length;o<a;o++){let c=e[o],l=c.name.match(r);if(l&&l.length>1){let u=l[1],f=i[u];if(!f)i[u]=f=[];f.push(c)}}let s=[];for(let o in i)s.push(this.CreateFromMorphTargetSequence(o,i[o],t,n));return s}resetDuration(){let e=this.tracks,t=0;for(let n=0,i=e.length;n!==i;++n){let r=this.tracks[n];t=Math.max(t,r.times[r.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){let e=[];for(let n=0;n<this.tracks.length;n++)e.push(this.tracks[n].clone());let t=new this.constructor(this.name,this.duration,e,this.blendMode);return t.userData=JSON.parse(JSON.stringify(this.userData)),t}toJSON(){return this.constructor.toJSON(this)}}function ub(e){switch(e.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return er;case"vector":case"vector2":case"vector3":case"vector4":return Ar;case"color":return Ha;case"quaternion":return tr;case"bool":case"boolean":return Qi;case"string":return nr}throw Error("THREE.KeyframeTrack: Unsupported typeName: "+e)}function hb(e){if(e.type===void 0)throw Error("THREE.KeyframeTrack: track type undefined, can not parse");let t=ub(e.type);if(e.times===void 0){let i=[],r=[];ab(e.keys,i,r,"value"),e.times=i,e.values=r}let n;if(t.parse!==void 0)n=t.parse(e);else n=new t(e.name,e.times,e.values,e.interpolation);if(ma(e.settings))n.settings={inTangents:Vi(e.settings.inTangents,Float32Array),outTangents:Vi(e.settings.outTangents,Float32Array)};return n}var ti={enabled:!1,files:{},add:function(e,t){if(this.enabled===!1)return;if(ad(e))return;this.files[e]=t},get:function(e){if(this.enabled===!1)return;if(ad(e))return;return this.files[e]},remove:function(e){delete this.files[e]},clear:function(){this.files={}}};function ad(e){try{let t=e.slice(e.indexOf(":")+1);return new URL(t).protocol==="blob:"}catch(t){return!1}}class no{constructor(e,t,n){let i=this,r=!1,s=0,o=0,a=void 0,c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this._abortController=null,this.itemStart=function(l){if(o++,r===!1){if(i.onStart!==void 0)i.onStart(l,s,o)}r=!0},this.itemEnd=function(l){if(s++,i.onProgress!==void 0)i.onProgress(l,s,o);if(s===o){if(r=!1,i.onLoad!==void 0)i.onLoad()}},this.itemError=function(l){if(i.onError!==void 0)i.onError(l)},this.resolveURL=function(l){if(l=l.normalize("NFC"),a)return a(l);return l},this.setURLModifier=function(l){return a=l,this},this.addHandler=function(l,u){return c.push(l,u),this},this.removeHandler=function(l){let u=c.indexOf(l);if(u!==-1)c.splice(u,2);return this},this.getHandler=function(l){for(let u=0,f=c.length;u<f;u+=2){let h=c[u],d=c[u+1];if(h.global)h.lastIndex=0;if(h.test(l))return d}return null},this.abort=function(){return this.abortController.abort(),this._abortController=null,this}}get abortController(){if(!this._abortController)this._abortController=new AbortController;return this._abortController}}var dp=new no;class Pi{constructor(e){if(this.manager=e!==void 0?e:dp,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={},typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}load(){}loadAsync(e,t){let n=this;return new Promise(function(i,r){n.load(e,i,t,r)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}abort(){return this}}Pi.DEFAULT_MATERIAL_NAME="__DEFAULT";var Ei={};class pp extends Error{constructor(e,t){super(e);this.response=t}}class io extends Pi{constructor(e){super(e);this.mimeType="",this.responseType="",this._abortController=new AbortController}load(e,t,n,i){if(e===void 0)e="";if(this.path!==void 0)e=this.path+e;e=this.manager.resolveURL(e);let r=ti.get(`file:${e}`);if(r!==void 0){this.manager.itemStart(e),setTimeout(()=>{if(t)t(r);this.manager.itemEnd(e)},0);return}if(Ei[e]!==void 0){Ei[e].push({onLoad:t,onProgress:n,onError:i});return}Ei[e]=[],Ei[e].push({onLoad:t,onProgress:n,onError:i});let s=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin",signal:typeof AbortSignal.any==="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal}),o=this.mimeType,a=this.responseType;fetch(s).then((c)=>{if(c.status===200||c.status===0){if(c.status===0)Pe("FileLoader: HTTP Status 0 received.");if(typeof ReadableStream>"u"||c.body===void 0||c.body.getReader===void 0)return c;let l=Ei[e],u=c.body.getReader(),f=c.headers.get("X-File-Size")||c.headers.get("Content-Length"),h=f?parseInt(f):0,d=h!==0,g=0,x=new ReadableStream({start(p){m();function m(){u.read().then(({done:E,value:R})=>{if(E)p.close();else{g+=R.byteLength;let v=new ProgressEvent("progress",{lengthComputable:d,loaded:g,total:h});for(let M=0,T=l.length;M<T;M++){let A=l[M];if(A.onProgress)A.onProgress(v)}p.enqueue(R),m()}},(E)=>{p.error(E)})}}});return new Response(x)}else throw new pp(`fetch for "${c.url}" responded with ${c.status}: ${c.statusText}`,c)}).then((c)=>{switch(a){case"arraybuffer":return c.arrayBuffer();case"blob":return c.blob();case"document":return c.text().then((l)=>new DOMParser().parseFromString(l,o));case"json":return c.json();default:if(o==="")return c.text();else{let u=/charset="?([^;"\s]*)"?/i.exec(o),f=u&&u[1]?u[1].toLowerCase():void 0,h=new TextDecoder(f);return c.arrayBuffer().then((d)=>h.decode(d))}}}).then((c)=>{ti.add(`file:${e}`,c);let l=Ei[e];delete Ei[e];for(let u=0,f=l.length;u<f;u++){let h=l[u];if(h.onLoad)h.onLoad(c)}}).catch((c)=>{let l=Ei[e];if(l===void 0)throw this.manager.itemError(e),c;delete Ei[e];for(let u=0,f=l.length;u<f;u++){let h=l[u];if(h.onError)h.onError(c)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}var Yr=new WeakMap;class wu extends Pi{constructor(e){super(e)}load(e,t,n,i){if(this.path!==void 0)e=this.path+e;e=this.manager.resolveURL(e);let r=this,s=ti.get(`image:${e}`);if(s!==void 0){if(s.complete===!0)r.manager.itemStart(e),setTimeout(function(){if(t)t(s);r.manager.itemEnd(e)},0);else{let u=Yr.get(s);if(u===void 0)u=[],Yr.set(s,u);u.push({onLoad:t,onError:i})}return s}let o=es("img");function a(){if(l(),t)t(this);let u=Yr.get(this)||[];for(let f=0;f<u.length;f++){let h=u[f];if(h.onLoad)h.onLoad(this)}Yr.delete(this),r.manager.itemEnd(e)}function c(u){if(l(),i)i(u);ti.remove(`image:${e}`);let f=Yr.get(this)||[];for(let h=0;h<f.length;h++){let d=f[h];if(d.onError)d.onError(u)}Yr.delete(this),r.manager.itemError(e),r.manager.itemEnd(e)}function l(){o.removeEventListener("load",a,!1),o.removeEventListener("error",c,!1)}if(o.addEventListener("load",a,!1),o.addEventListener("error",c,!1),e.slice(0,5)!=="data:"){if(this.crossOrigin!==void 0)o.crossOrigin=this.crossOrigin}return ti.add(`image:${e}`,o),r.manager.itemStart(e),o.src=e,o}}class Va extends Pi{constructor(e){super(e)}load(e,t,n,i){let r=new At,s=new wu(this.manager);return s.setCrossOrigin(this.crossOrigin),s.setPath(this.path),s.load(e,function(o){if(r.image=o,r.needsUpdate=!0,t!==void 0)t(r)},n,i),r}}class ms extends ht{constructor(e,t=1){super();this.isLight=!0,this.type="Light",this.color=new Ue(e),this.intensity=t}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){let t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,t}}class $a extends ms{constructor(e,t,n){super(e,n);this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(ht.DEFAULT_UP),this.updateMatrix(),this.groundColor=new Ue(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}toJSON(e){let t=super.toJSON(e);return t.object.groundColor=this.groundColor.getHex(),t}}var ll=new Ge,cd=new D,ld=new D;class ro{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.biasNode=null,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Ne(512,512),this.mapType=1009,this.map=null,this.mapPass=null,this.matrix=new Ge,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Js,this._frameExtents=new Ne(1,1),this._viewportCount=1,this._viewports=[new ct(0,0,1,1)]}getViewportCount(){return this._viewportCount}getCamera(){return this.camera}getFrustum(){return this._frustum}updateMatrices(e){let t=this.camera;cd.setFromMatrixPosition(e.matrixWorld),t.position.copy(cd),ld.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(ld),t.updateMatrixWorld(),this._updateMatrix(t,this.matrix,this._frustum)}_updateMatrix(e,t,n,i){ll.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),n.setFromProjectionMatrix(ll,e.coordinateSystem,e.reversedDepth);let r=this._frameExtents,s=i?i.z/r.x:1,o=i?i.w/r.y:1,a=i?i.x/r.x:0,c=i?i.y/r.y:0;if(e.coordinateSystem===2001||e.reversedDepth)t.set(0.5*s,0,0,0.5*s+a,0,0.5*o,0,0.5*o+c,0,0,1,0,0,0,0,1);else t.set(0.5*s,0,0,0.5*s+a,0,0.5*o,0,0.5*o+c,0,0,0.5,0.5,0,0,0,1);t.multiply(ll)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){if(this.map)this.map.dispose();if(this.mapPass)this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.intensity=e.intensity,this.bias=e.bias,this.radius=e.radius,this.autoUpdate=e.autoUpdate,this.needsUpdate=e.needsUpdate,this.normalBias=e.normalBias,this.blurSamples=e.blurSamples,this.mapSize.copy(e.mapSize),this.biasNode=e.biasNode,this}clone(){return new this.constructor().copy(this)}toJSON(){let e={};return e.intensity=this.intensity,e.bias=this.bias,e.normalBias=this.normalBias,e.radius=this.radius,e.blurSamples=this.blurSamples,e.mapSize=this.mapSize.toArray(),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}var da=new D,pa=new Ht,Qn=new D;class Wa extends ht{constructor(){super();this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Ge,this.projectionMatrix=new Ge,this.projectionMatrixInverse=new Ge,this.coordinateSystem=2000,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}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){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){if(super.updateMatrixWorld(e),this.matrixWorld.decompose(da,pa,Qn),Qn.x===1&&Qn.y===1&&Qn.z===1)this.matrixWorldInverse.copy(this.matrixWorld).invert();else this.matrixWorldInverse.compose(da,pa,Qn.set(1,1,1)).invert()}updateWorldMatrix(e,t,n=!1){if(super.updateWorldMatrix(e,t,n),this.matrixWorld.decompose(da,pa,Qn),Qn.x===1&&Qn.y===1&&Qn.z===1)this.matrixWorldInverse.copy(this.matrixWorld).invert();else this.matrixWorldInverse.compose(da,pa,Qn.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}}var Hi=new D,ud=new Ne,hd=new Ne;class Ut extends Wa{constructor(e=50,t=1,n=0.1,i=2000){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){let t=0.5*this.getFilmHeight()/e;this.fov=xr*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan(Us*0.5*this.fov);return 0.5*this.getFilmHeight()/e}getEffectiveFOV(){return xr*2*Math.atan(Math.tan(Us*0.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,n){Hi.set(-1,-1,0.5).applyMatrix4(this.projectionMatrixInverse),t.set(Hi.x,Hi.y).multiplyScalar(-e/Hi.z),Hi.set(1,1,0.5).applyMatrix4(this.projectionMatrixInverse),n.set(Hi.x,Hi.y).multiplyScalar(-e/Hi.z)}getViewSize(e,t){return this.getViewBounds(e,ud,hd),t.subVectors(hd,ud)}setViewOffset(e,t,n,i,r,s){if(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=r,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){if(this.view!==null)this.view.enabled=!1;this.updateProjectionMatrix()}updateProjectionMatrix(){let e=this.near,t=e*Math.tan(Us*0.5*this.fov)/this.zoom,n=2*t,i=this.aspect*n,r=-0.5*i,s=this.view;if(this.view!==null&&this.view.enabled){let{fullWidth:a,fullHeight:c}=s;r+=s.offsetX*i/a,t-=s.offsetY*n/c,i*=s.width/a,n*=s.height/c}let o=this.filmOffset;if(o!==0)r+=e*o/this.getFilmWidth();this.projectionMatrix.makePerspective(r,r+i,t,t-n,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);if(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);return t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}class mp extends ro{constructor(){super(new Ut(50,1,0.5,500));this.isSpotLightShadow=!0,this.focus=1,this.aspect=1}updateMatrices(e){let t=this.camera,n=xr*2*e.angle*this.focus,i=this.mapSize.width/this.mapSize.height*this.aspect,r=e.distance||t.far;if(n!==t.fov||i!==t.aspect||r!==t.far)t.fov=n,t.aspect=i,t.far=r,t.updateProjectionMatrix();super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this.aspect=e.aspect,this}toJSON(){let e=super.toJSON();return e.focus=this.focus,e.aspect=this.aspect,e}}class Za extends ms{constructor(e,t,n=0,i=Math.PI/3,r=0,s=2){super(e,t);this.isSpotLight=!0,this.type="SpotLight",this.position.copy(ht.DEFAULT_UP),this.updateMatrix(),this.target=new ht,this.distance=n,this.angle=i,this.penumbra=r,this.decay=s,this.map=null,this.shadow=new mp}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){super.dispose(),this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.map=e.map,this.shadow=e.shadow.clone(),this}toJSON(e){let t=super.toJSON(e);if(t.object.distance=this.distance,t.object.angle=this.angle,t.object.decay=this.decay,t.object.penumbra=this.penumbra,t.object.target=this.target.uuid,this.map&&this.map.isTexture)t.object.map=this.map.toJSON(e).uuid;return t.object.shadow=this.shadow.toJSON(),t}}class gp extends ro{constructor(){super(new Ut(90,1,0.5,500));this.isPointLightShadow=!0}}class gs extends ms{constructor(e,t,n=0,i=2){super(e,t);this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=i,this.shadow=new gp}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){super.dispose(),this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}toJSON(e){let t=super.toJSON(e);return t.object.distance=this.distance,t.object.decay=this.decay,t.object.shadow=this.shadow.toJSON(),t}}class Rr extends Wa{constructor(e=-1,t=1,n=1,i=-1,r=0.1,s=2000){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=r,this.far=s,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,n,i,r,s){if(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=r,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){if(this.view!==null)this.view.enabled=!1;this.updateProjectionMatrix()}updateProjectionMatrix(){let 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,r=n-e,s=n+e,o=i+t,a=i-t;if(this.view!==null&&this.view.enabled){let c=(this.right-this.left)/this.view.fullWidth/this.zoom,l=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=c*this.view.offsetX,s=r+c*this.view.width,o-=l*this.view.offsetY,a=o-l*this.view.height}this.projectionMatrix.makeOrthographic(r,s,o,a,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);if(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);return t}}class _p extends ro{constructor(){super(new Rr(-5,5,5,-5,0.5,500));this.isDirectionalLightShadow=!0}}class _s extends ms{constructor(e,t){super(e,t);this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(ht.DEFAULT_UP),this.updateMatrix(),this.target=new ht,this.shadow=new _p}dispose(){super.dispose(),this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}toJSON(e){let t=super.toJSON(e);return t.object.shadow=this.shadow.toJSON(),t.object.target=this.target.uuid,t}}class ir{static extractUrlBase(e){let t=e.lastIndexOf("/");if(t===-1)return"./";return e.slice(0,t+1)}static resolveURL(e,t){if(typeof e!=="string"||e==="")return"";if(/^https?:\/\//i.test(t)&&/^\//.test(e))t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1");if(/^(https?:)?\/\//i.test(e))return e;if(/^data:.*,.*$/i.test(e))return e;if(/^blob:.*$/i.test(e))return e;return t+e}}var ul=new WeakMap;class Xa extends Pi{constructor(e){super(e);if(this.isImageBitmapLoader=!0,typeof createImageBitmap>"u")Pe("ImageBitmapLoader: createImageBitmap() not supported.");if(typeof fetch>"u")Pe("ImageBitmapLoader: fetch() not supported.");this.options={premultiplyAlpha:"none"},this._abortController=new AbortController}setOptions(e){return this.options=e,this}load(e,t,n,i){if(e===void 0)e="";if(this.path!==void 0)e=this.path+e;e=this.manager.resolveURL(e);let r=this,s=ti.get(`image-bitmap:${e}`);if(s!==void 0){if(r.manager.itemStart(e),s.then){s.then((c)=>{if(ul.has(s)===!0){if(i)i(ul.get(s));r.manager.itemError(e),r.manager.itemEnd(e)}else{if(t)t(c);r.manager.itemEnd(e)}});return}setTimeout(function(){if(t)t(s);r.manager.itemEnd(e)},0);return}let o={};o.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",o.headers=this.requestHeader,o.signal=typeof AbortSignal.any==="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal;let a=fetch(e,o).then(function(c){return c.blob()}).then(function(c){return createImageBitmap(c,Object.assign({},r.options,{colorSpaceConversion:"none"}))}).then(function(c){if(ti.add(`image-bitmap:${e}`,c),t)t(c);return r.manager.itemEnd(e),c}).catch(function(c){if(i)i(c);ul.set(a,c),ti.remove(`image-bitmap:${e}`),r.manager.itemError(e),r.manager.itemEnd(e)});ti.add(`image-bitmap:${e}`,a),r.manager.itemStart(e)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}var Kr=-90,Jr=1;class Eu extends ht{constructor(e,t,n){super();this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;let i=new Ut(Kr,Jr,e,t);i.layers=this.layers,this.add(i);let r=new Ut(Kr,Jr,e,t);r.layers=this.layers,this.add(r);let s=new Ut(Kr,Jr,e,t);s.layers=this.layers,this.add(s);let o=new Ut(Kr,Jr,e,t);o.layers=this.layers,this.add(o);let a=new Ut(Kr,Jr,e,t);a.layers=this.layers,this.add(a);let c=new Ut(Kr,Jr,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){let e=this.coordinateSystem,t=this.children.concat(),[n,i,r,s,o,a]=t;for(let c of t)this.remove(c);if(e===2000)n.up.set(0,1,0),n.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),s.up.set(0,0,1),s.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),a.up.set(0,1,0),a.lookAt(0,0,-1);else if(e===2001)n.up.set(0,-1,0),n.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),s.up.set(0,0,-1),s.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),a.up.set(0,-1,0),a.lookAt(0,0,-1);else throw Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(let c of t)this.add(c),c.updateMatrixWorld()}update(e,t){if(this.parent===null)this.updateMatrixWorld();let{renderTarget:n,activeMipmapLevel:i}=this;if(this.coordinateSystem!==e.coordinateSystem)this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem();let[r,s,o,a,c,l]=this.children,u=e.getRenderTarget(),f=e.getActiveCubeFace(),h=e.getActiveMipmapLevel(),d=e.xr.enabled;e.xr.enabled=!1;let g=n.texture.generateMipmaps;n.texture.generateMipmaps=!1;let x=!1;if(e.isWebGLRenderer===!0)x=e.state.buffers.depth.getReversed();else x=e.reversedDepthBuffer;if(e.setRenderTarget(n,0,i),x&&e.autoClear===!1)e.clearDepth();if(e.render(t,r),e.setRenderTarget(n,1,i),x&&e.autoClear===!1)e.clearDepth();if(e.render(t,s),e.setRenderTarget(n,2,i),x&&e.autoClear===!1)e.clearDepth();if(e.render(t,o),e.setRenderTarget(n,3,i),x&&e.autoClear===!1)e.clearDepth();if(e.render(t,a),e.setRenderTarget(n,4,i),x&&e.autoClear===!1)e.clearDepth();if(e.render(t,c),n.texture.generateMipmaps=g,e.setRenderTarget(n,5,i),x&&e.autoClear===!1)e.clearDepth();e.render(t,l),e.setRenderTarget(u,f,h),e.xr.enabled=d,n.texture.needsPMREMUpdate=!0}}class Tu extends Ut{constructor(e=[]){super();this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}class Au{constructor(e,t,n){this.binding=e,this.valueSize=n;let i,r,s;switch(t){case"quaternion":i=this._slerp,r=this._slerpAdditive,s=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(n*6),this._workIndex=5;break;case"string":case"bool":i=this._select,r=this._select,s=this._setAdditiveIdentityOther,this.buffer=Array(n*5);break;default:i=this._lerp,r=this._lerpAdditive,s=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(n*5)}this._mixBufferRegion=i,this._mixBufferRegionAdditive=r,this._setIdentity=s,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(e,t){let n=this.buffer,i=this.valueSize,r=e*i+i,s=this.cumulativeWeight;if(s===0){for(let o=0;o!==i;++o)n[r+o]=n[o];s=t}else{s+=t;let o=t/s;this._mixBufferRegion(n,r,0,o,i)}this.cumulativeWeight=s}accumulateAdditive(e){let t=this.buffer,n=this.valueSize,i=n*this._addIndex;if(this.cumulativeWeightAdditive===0)this._setIdentity();this._mixBufferRegionAdditive(t,i,0,e,n),this.cumulativeWeightAdditive+=e}apply(e){let t=this.valueSize,n=this.buffer,i=e*t+t,r=this.cumulativeWeight,s=this.cumulativeWeightAdditive,o=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,r<1){let a=t*this._origIndex;this._mixBufferRegion(n,i,a,1-r,t)}if(s>0)this._mixBufferRegionAdditive(n,i,this._addIndex*t,1,t);for(let a=t,c=t+t;a!==c;++a)if(n[a]!==n[a+t]){o.setValue(n,i);break}}saveOriginalState(){let e=this.binding,t=this.buffer,n=this.valueSize,i=n*this._origIndex;e.getValue(t,i);for(let r=n,s=i;r!==s;++r)t[r]=t[i+r%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){let e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){let e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let n=e;n<t;n++)this.buffer[n]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){let e=this._origIndex*this.valueSize,t=this._addIndex*this.valueSize;for(let n=0;n<this.valueSize;n++)this.buffer[t+n]=this.buffer[e+n]}_select(e,t,n,i,r){if(i>=0.5)for(let s=0;s!==r;++s)e[t+s]=e[n+s]}_slerp(e,t,n,i){Ht.slerpFlat(e,t,e,t,e,n,i)}_slerpAdditive(e,t,n,i,r){let s=this._workIndex*r;Ht.multiplyQuaternionsFlat(e,s,e,t,e,n),Ht.slerpFlat(e,t,e,t,e,s,i)}_lerp(e,t,n,i,r){let s=1-i;for(let o=0;o!==r;++o){let a=t+o;e[a]=e[a]*s+e[n+o]*i}}_lerpAdditive(e,t,n,i,r){for(let s=0;s!==r;++s){let o=t+s;e[o]=e[o]+e[n+s]*i}}}var Ru="\\[\\]\\.:\\/",fb=new RegExp("["+Ru+"]","g"),Cu="[^"+Ru+"]",db="[^"+Ru.replace("\\.","")+"]",pb=/((?:WC+[\/:])*)/.source.replace("WC",Cu),mb=/(WCOD+)?/.source.replace("WCOD",db),gb=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Cu),_b=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Cu),xb=new RegExp("^"+pb+mb+gb+_b+"$"),yb=["material","materials","bones","map"];class xp{constructor(e,t,n){let i=n||tt.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,i)}getValue(e,t){this.bind();let n=this._targetGroup.nCachedObjects_,i=this._bindings[n];if(i!==void 0)i.getValue(e,t)}setValue(e,t){let n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,r=n.length;i!==r;++i)n[i].setValue(e,t)}bind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}}class tt{constructor(e,t,n){this.path=t,this.parsedPath=n||tt.parseTrackName(t),this.node=tt.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){if(!(e&&e.isAnimationObjectGroup))return new tt(e,t,n);else return new tt.Composite(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(fb,"")}static parseTrackName(e){let t=xb.exec(e);if(t===null)throw Error("THREE.PropertyBinding: Cannot parse trackName: "+e);let 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){let r=n.nodeName.substring(i+1);if(yb.indexOf(r)!==-1)n.nodeName=n.nodeName.substring(0,i),n.objectName=r}if(n.propertyName===null||n.propertyName.length===0)throw Error("THREE.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){let n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){let n=function(r){for(let s=0;s<r.length;s++){let o=r[s];if(o.name===t||o.uuid===t)return o;let a=n(o.children);if(a)return a}return null},i=n(e.children);if(i)return i}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){let n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)e[t++]=n[i]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){let n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=e[t++]}_setValue_array_setNeedsUpdate(e,t){let n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){let n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node,t=this.parsedPath,{objectName:n,propertyName:i,propertyIndex:r}=t;if(!e)e=tt.findNode(this.rootNode,t.nodeName),this.node=e;if(this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){Pe("PropertyBinding: No target node found for track: "+this.path+".");return}if(n){let c=t.objectIndex;switch(n){case"materials":if(!e.material){Fe("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){Fe("PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){Fe("PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let l=0;l<e.length;l++)if(e[l].name===c){c=l;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){Fe("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){Fe("PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}e=e.material.map;break;default:if(e[n]===void 0){Fe("PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[n]}if(c!==void 0){if(e[c]===void 0){Fe("PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[c]}}let s=e[i];if(s===void 0){let c=t.nodeName;Fe("PropertyBinding: Trying to update property for track: "+c+"."+i+" but it wasn't found.",e);return}let o=this.Versioning.None;if(this.targetObject=e,e.isMaterial===!0)o=this.Versioning.NeedsUpdate;else if(e.isObject3D===!0)o=this.Versioning.MatrixWorldNeedsUpdate;let a=this.BindingType.Direct;if(r!==void 0){if(i==="morphTargetInfluences"){if(!e.geometry){Fe("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){Fe("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}if(e.morphTargetDictionary[r]!==void 0)r=e.morphTargetDictionary[r]}a=this.BindingType.ArrayElement,this.resolvedProperty=s,this.propertyIndex=r}else if(s.fromArray!==void 0&&s.toArray!==void 0)a=this.BindingType.HasFromToArray,this.resolvedProperty=s;else if(Array.isArray(s))a=this.BindingType.EntireArray,this.resolvedProperty=s;else this.propertyName=i;this.getValue=this.GetterByBindingType[a],this.setValue=this.SetterByBindingTypeAndVersioning[a][o]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}tt.Composite=xp;tt.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};tt.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};tt.prototype.GetterByBindingType=[tt.prototype._getValue_direct,tt.prototype._getValue_array,tt.prototype._getValue_arrayElement,tt.prototype._getValue_toArray];tt.prototype.SetterByBindingTypeAndVersioning=[[tt.prototype._setValue_direct,tt.prototype._setValue_direct_setNeedsUpdate,tt.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[tt.prototype._setValue_array,tt.prototype._setValue_array_setNeedsUpdate,tt.prototype._setValue_array_setMatrixWorldNeedsUpdate],[tt.prototype._setValue_arrayElement,tt.prototype._setValue_arrayElement_setNeedsUpdate,tt.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[tt.prototype._setValue_fromArray,tt.prototype._setValue_fromArray_setNeedsUpdate,tt.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class Pu{constructor(e,t,n=null,i=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=n,this.blendMode=i;let r=t.tracks,s=r.length,o=Array(s),a={endingStart:2400,endingEnd:2400};for(let c=0;c!==s;++c){let l=r[c].createInterpolant(null);o[c]=l,l.settings=a}this._interpolantSettings=a,this._interpolants=o,this._propertyBindings=Array(s),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._restoreTimeScale=null,this._weightInterpolant=null,this.loop=2201,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&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=!1){if(e.fadeOut(t),this.fadeIn(t),n===!0){let i=this._clip.duration,r=e._clip.duration,s=r/i,o=i/r;e._restoreTimeScale=e.timeScale,this._restoreTimeScale=this.timeScale,e.warp(1,s,t),this.warp(o,1,t)}return this}crossFadeTo(e,t,n=!1){return e.crossFadeFrom(this,t,n)}stopFading(){let e=this._weightInterpolant;if(e!==null)this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e);return this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,n){let i=this._mixer,r=i.time,s=this.timeScale,o=this._timeScaleInterpolant;if(o===null)o=i._lendControlInterpolant(),this._timeScaleInterpolant=o;let a=o.parameterPositions,c=o.sampleValues;return a[0]=r,a[1]=r+n,c[0]=e/s,c[1]=t/s,this}stopWarping(){let e=this._timeScaleInterpolant;if(e!==null)this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e);return this._restoreTimeScale=null,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}let r=this._startTime;if(r!==null){let a=(e-r)*n;if(a<0||n===0)t=0;else this._startTime=null,t=n*a}t*=this._updateTimeScale(e);let s=this._updateTime(t),o=this._updateWeight(e);if(o>0){let a=this._interpolants,c=this._propertyBindings;switch(this.blendMode){case 2501:for(let l=0,u=a.length;l!==u;++l)a[l].evaluate(s),c[l].accumulateAdditive(o);break;case 2500:default:for(let l=0,u=a.length;l!==u;++l)a[l].evaluate(s),c[l].accumulate(i,o)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;let n=this._weightInterpolant;if(n!==null){let i=n.evaluate(e)[0];if(t*=i,e>n.parameterPositions[1]){if(this.stopFading(),i===0)this.enabled=!1}}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;let n=this._timeScaleInterpolant;if(n!==null){let i=n.evaluate(e)[0];if(t*=i,e>n.parameterPositions[1]){if(t===0)this.paused=!0;else{if(this._restoreTimeScale!==null)t=this._restoreTimeScale;this.timeScale=t}this.stopWarping()}}}return this._effectiveTimeScale=t,t}_updateTime(e){let t=this._clip.duration,n=this.loop,i=this.time+e,r=this._loopCount,s=n===2202;if(e===0){if(r===-1)return i;return s&&(r&1)===1?t-i:i}if(n===2200){if(r===-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}if(this.clampWhenFinished)this.paused=!0;else this.enabled=!1;this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(r===-1)if(e>=0)r=0,this._setEndings(!0,this.repetitions===0,s);else this._setEndings(this.repetitions===0,!0,s);if(i>=t||i<0){let o=Math.floor(i/t);i-=t*o,r+=Math.abs(o);let a=this.repetitions-r;if(a<=0){if(this.clampWhenFinished)this.paused=!0;else 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(a===1){let c=e<0;this._setEndings(c,!c,s)}else this._setEndings(!1,!1,s);this._loopCount=r,this.time=i,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:o})}}else this._loopCount=r,this.time=i;if(s&&(r&1)===1)return t-i}return i}_setEndings(e,t,n){let i=this._interpolantSettings;if(n)i.endingStart=2401,i.endingEnd=2401;else{if(e)i.endingStart=this.zeroSlopeAtStart?2401:2400;else i.endingStart=2402;if(t)i.endingEnd=this.zeroSlopeAtEnd?2401:2400;else i.endingEnd=2402}}_scheduleFading(e,t,n){let i=this._mixer,r=i.time,s=this._weightInterpolant;if(s===null)s=i._lendControlInterpolant(),this._weightInterpolant=s;let o=s.parameterPositions,a=s.sampleValues;return o[0]=r,a[0]=t,o[1]=r+e,a[1]=n,this}}var vb=new Float32Array(1);class qa extends $n{constructor(e){super();if(this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1,typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}_bindAction(e,t){let n=e._localRoot||this._root,i=e._clip.tracks,r=i.length,{_propertyBindings:s,_interpolants:o}=e,a=n.uuid,c=this._bindingsByRootAndName,l=c[a];if(l===void 0)l={},c[a]=l;for(let u=0;u!==r;++u){let f=i[u],h=f.name,d=l[h];if(d!==void 0)++d.referenceCount,s[u]=d;else{if(d=s[u],d!==void 0){if(d._cacheIndex===null)++d.referenceCount,this._addInactiveBinding(d,a,h);continue}let g=t&&t._propertyBindings[u].binding.parsedPath;d=new Au(tt.create(n,h,g),f.ValueTypeName,f.getValueSize()),++d.referenceCount,this._addInactiveBinding(d,a,h),s[u]=d}o[u].resultBuffer=d.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){let n=(e._localRoot||this._root).uuid,i=e._clip.uuid,r=this._actionsByClip[i];this._bindAction(e,r&&r.knownActions[0]),this._addInactiveAction(e,i,n)}let t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){let r=t[n];if(r.useCount++===0)this._lendBinding(r),r.saveOriginalState()}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){let t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){let r=t[n];if(--r.useCount===0)r.restoreOriginalState(),this._takeBackBinding(r)}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;let e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){let t=e._cacheIndex;return t!==null&&t<this._nActiveActions}_addInactiveAction(e,t,n){let i=this._actions,r=this._actionsByClip,s=r[t];if(s===void 0)s={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,r[t]=s;else{let o=s.knownActions;e._byClipCacheIndex=o.length,o.push(e)}e._cacheIndex=i.length,i.push(e),s.actionByRoot[n]=e}_removeInactiveAction(e){let t=this._actions,n=t[t.length-1],i=e._cacheIndex;n._cacheIndex=i,t[i]=n,t.pop(),e._cacheIndex=null;let r=e._clip.uuid,s=this._actionsByClip,o=s[r],a=o.knownActions,c=a[a.length-1],l=e._byClipCacheIndex;c._byClipCacheIndex=l,a[l]=c,a.pop(),e._byClipCacheIndex=null;let u=o.actionByRoot,f=(e._localRoot||this._root).uuid;if(delete u[f],a.length===0)delete s[r];this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){let t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){let r=t[n];if(--r.referenceCount===0)this._removeInactiveBinding(r)}}_lendAction(e){let t=this._actions,n=e._cacheIndex,i=this._nActiveActions++,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_takeBackAction(e){let t=this._actions,n=e._cacheIndex,i=--this._nActiveActions,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_addInactiveBinding(e,t,n){let i=this._bindingsByRootAndName,r=this._bindings,s=i[t];if(s===void 0)s={},i[t]=s;s[n]=e,e._cacheIndex=r.length,r.push(e)}_removeInactiveBinding(e){let t=this._bindings,n=e.binding,i=n.rootNode.uuid,r=n.path,s=this._bindingsByRootAndName,o=s[i],a=t[t.length-1],c=e._cacheIndex;if(a._cacheIndex=c,t[c]=a,t.pop(),delete o[r],Object.keys(o).length===0)delete s[i]}_lendBinding(e){let t=this._bindings,n=e._cacheIndex,i=this._nActiveBindings++,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_takeBackBinding(e){let t=this._bindings,n=e._cacheIndex,i=--this._nActiveBindings,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_lendControlInterpolant(){let e=this._controlInterpolants,t=this._nActiveControlInterpolants++,n=e[t];if(n===void 0)n=new Ga(new Float32Array(2),new Float32Array(2),1,vb),n.__cacheIndex=t,e[t]=n;return n}_takeBackControlInterpolant(e){let t=this._controlInterpolants,n=e.__cacheIndex,i=--this._nActiveControlInterpolants,r=t[i];e.__cacheIndex=i,t[i]=e,r.__cacheIndex=n,t[n]=r}clipAction(e,t,n){let i=t||this._root,r=i.uuid,s=typeof e==="string"?ns.findByName(i,e):e,o=s!==null?s.uuid:e,a=this._actionsByClip[o],c=null;if(n===void 0)if(s!==null)n=s.blendMode;else n=2500;if(a!==void 0){let u=a.actionByRoot[r];if(u!==void 0&&u.blendMode===n)return u;if(c=a.knownActions[0],s===null)s=c._clip}if(s===null)return null;let l=new Pu(this,s,t,n);return this._bindAction(l,c),this._addInactiveAction(l,o,r),l}existingAction(e,t){let n=t||this._root,i=n.uuid,r=typeof e==="string"?ns.findByName(n,e):e,s=r?r.uuid:e,o=this._actionsByClip[s];if(o!==void 0)return o.actionByRoot[i]||null;return null}stopAllAction(){let e=this._actions,t=this._nActiveActions;for(let n=t-1;n>=0;--n)e[n].stop();return this}update(e){e*=this.timeScale;let t=this._actions,n=this._nActiveActions,i=this.time+=e,r=Math.sign(e),s=this._accuIndex^=1;for(let c=0;c!==n;++c)t[c]._update(i,e,r,s);let o=this._bindings,a=this._nActiveBindings;for(let c=0;c!==a;++c)o[c].apply(s);return this}setTime(e){this.time=0;for(let t=0;t<this._actions.length;t++)this._actions[t].time=0;return this.update(e)}getRoot(){return this._root}uncacheClip(e){let t=this._actions,n=e.uuid,i=this._actionsByClip,r=i[n];if(r!==void 0){let s=r.knownActions;for(let o=0,a=s.length;o!==a;++o){let c=s[o];this._deactivateAction(c);let l=c._cacheIndex,u=t[t.length-1];c._cacheIndex=null,c._byClipCacheIndex=null,u._cacheIndex=l,t[l]=u,t.pop(),this._removeInactiveBindingsForAction(c)}delete i[n]}}uncacheRoot(e){let t=e.uuid,n=this._actionsByClip;for(let s in n){let o=n[s].actionByRoot,a=o[t];if(a!==void 0)this._deactivateAction(a),this._removeInactiveAction(a)}let i=this._bindingsByRootAndName,r=i[t];if(r!==void 0)for(let s in r){let o=r[s];o.restoreOriginalState(),this._removeInactiveBinding(o)}}uncacheAction(e,t){let n=this.existingAction(e,t);if(n!==null)this._deactivateAction(n),this._removeInactiveAction(n)}}class so{constructor(e=1,t=0,n=0){this.radius=e,this.phi=t,this.theta=n}set(e,t,n){return this.radius=e,this.phi=t,this.theta=n,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=We(this.phi,0.000001,Math.PI-0.000001),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,n){if(this.radius=Math.sqrt(e*e+t*t+n*n),this.radius===0)this.theta=0,this.phi=0;else this.theta=Math.atan2(e,n),this.phi=Math.acos(We(t/this.radius,-1,1));return this}clone(){return new this.constructor().copy(this)}}class Iu{static{Iu.prototype.isMatrix2=!0}constructor(e,t,n,i){if(this.elements=[1,0,0,1],e!==void 0)this.set(e,t,n,i)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let n=0;n<4;n++)this.elements[n]=e[n+t];return this}set(e,t,n,i){let r=this.elements;return r[0]=e,r[2]=t,r[1]=n,r[3]=i,this}}class ja extends $n{constructor(e,t=null){super();this.object=e,this.domElement=t,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(e){if(this.domElement!==null)this.disconnect();this.domElement=e}disconnect(){}dispose(){}update(){}}function Lu(e,t,n,i){let r=bb(i);switch(n){case 1021:return e*t;case 1028:return e*t/r.components*r.byteLength;case 1029:return e*t/r.components*r.byteLength;case 1030:return e*t*2/r.components*r.byteLength;case 1031:return e*t*2/r.components*r.byteLength;case 1022:return e*t*3/r.components*r.byteLength;case 1023:return e*t*4/r.components*r.byteLength;case 1033:return e*t*4/r.components*r.byteLength;case 33776:case 33777:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*8;case 33778:case 33779:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*16;case 35841:case 35843:return Math.max(e,16)*Math.max(t,8)/4;case 35840:case 35842:return Math.max(e,8)*Math.max(t,8)/2;case 36196:case 37492:case 37488:case 37489:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*8;case 37496:case 37490:case 37491:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*16;case 37808:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*16;case 37809:return Math.floor((e+4)/5)*Math.floor((t+3)/4)*16;case 37810:return Math.floor((e+4)/5)*Math.floor((t+4)/5)*16;case 37811:return Math.floor((e+5)/6)*Math.floor((t+4)/5)*16;case 37812:return Math.floor((e+5)/6)*Math.floor((t+5)/6)*16;case 37813:return Math.floor((e+7)/8)*Math.floor((t+4)/5)*16;case 37814:return Math.floor((e+7)/8)*Math.floor((t+5)/6)*16;case 37815:return Math.floor((e+7)/8)*Math.floor((t+7)/8)*16;case 37816:return Math.floor((e+9)/10)*Math.floor((t+4)/5)*16;case 37817:return Math.floor((e+9)/10)*Math.floor((t+5)/6)*16;case 37818:return Math.floor((e+9)/10)*Math.floor((t+7)/8)*16;case 37819:return Math.floor((e+9)/10)*Math.floor((t+9)/10)*16;case 37820:return Math.floor((e+11)/12)*Math.floor((t+9)/10)*16;case 37821:return Math.floor((e+11)/12)*Math.floor((t+11)/12)*16;case 36492:case 36494:case 36495:return Math.ceil(e/4)*Math.ceil(t/4)*16;case 36283:case 36284:return Math.ceil(e/4)*Math.ceil(t/4)*8;case 36285:case 36286:return Math.ceil(e/4)*Math.ceil(t/4)*16}throw Error(`Unable to determine texture byte length for ${n} format.`)}function bb(e){switch(e){case 1009:case 1010:return{byteLength:1,components:1};case 1012:case 1011:case 1016:return{byteLength:2,components:1};case 1017:case 1018:return{byteLength:2,components:4};case 1014:case 1013:case 1015:return{byteLength:4,components:1};case 35902:case 35899:return{byteLength:4,components:3}}throw Error(`THREE.TextureUtils: Unknown texture type ${e}.`)}if(typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:"186"}}));if(typeof window<"u")if(window.__THREE__)Pe("WARNING: Multiple instances of Three.js being imported.");else window.__THREE__="186";function Bp(){let e=null,t=!1,n=null,i=null;function r(s,o){i=e.requestAnimationFrame(r),n(s,o)}return{start:function(){if(t===!0)return;if(n===null)return;if(e===null)return;i=e.requestAnimationFrame(r),t=!0},stop:function(){if(e!==null)e.cancelAnimationFrame(i);t=!1},setAnimationLoop:function(s){n=s},setContext:function(s){e=s}}}function Sb(e){let t=new WeakMap;function n(a,c){let{array:l,usage:u}=a,f=l.byteLength,h=e.createBuffer();e.bindBuffer(c,h),e.bufferData(c,l,u),a.onUploadCallback();let d;if(l instanceof Float32Array)d=e.FLOAT;else if(typeof Float16Array<"u"&&l instanceof Float16Array)d=e.HALF_FLOAT;else if(l instanceof Uint16Array)if(a.isFloat16BufferAttribute)d=e.HALF_FLOAT;else d=e.UNSIGNED_SHORT;else if(l instanceof Int16Array)d=e.SHORT;else if(l instanceof Uint32Array)d=e.UNSIGNED_INT;else if(l instanceof Int32Array)d=e.INT;else if(l instanceof Int8Array)d=e.BYTE;else if(l instanceof Uint8Array)d=e.UNSIGNED_BYTE;else if(l instanceof Uint8ClampedArray)d=e.UNSIGNED_BYTE;else throw Error("THREE.WebGLAttributes: Unsupported buffer data format: "+l);return{buffer:h,type:d,bytesPerElement:l.BYTES_PER_ELEMENT,version:a.version,size:f}}function i(a,c,l){let{array:u,updateRanges:f}=c;if(e.bindBuffer(l,a),f.length===0)e.bufferSubData(l,0,u);else{f.sort((d,g)=>d.start-g.start);let h=0;for(let d=1;d<f.length;d++){let g=f[h],x=f[d];if(x.start<=g.start+g.count+1)g.count=Math.max(g.count,x.start+x.count-g.start);else++h,f[h]=x}f.length=h+1;for(let d=0,g=f.length;d<g;d++){let x=f[d];e.bufferSubData(l,x.start*u.BYTES_PER_ELEMENT,u,x.start,x.count)}c.clearUpdateRanges()}c.onUploadCallback()}function r(a){if(a.isInterleavedBufferAttribute)a=a.data;return t.get(a)}function s(a){if(a.isInterleavedBufferAttribute)a=a.data;let c=t.get(a);if(c)e.deleteBuffer(c.buffer),t.delete(a)}function o(a,c){if(a.isInterleavedBufferAttribute)a=a.data;if(a.isGLBufferAttribute){let u=t.get(a);if(!u||u.version<a.version)t.set(a,{buffer:a.buffer,type:a.type,bytesPerElement:a.elementSize,version:a.version});return}let l=t.get(a);if(l===void 0)t.set(a,n(a,c));else if(l.version<a.version){if(l.size!==a.array.byteLength)throw Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");i(l.buffer,a,c),l.version=a.version}}return{get:r,remove:s,update:o}}var Mb=`#ifdef USE_ALPHAHASH
129
+ }`;class In extends hn{constructor(e){super();if(this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=ob,this.fragmentShader=ab,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={clipCullDistance:!1,multiDraw:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,e!==void 0)this.setValues(e)}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=Ar(e.uniforms),this.uniformsGroups=sb(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this.defaultAttributeValues=Object.assign({},e.defaultAttributeValues),this.index0AttributeName=e.index0AttributeName,this.uniformsNeedUpdate=e.uniformsNeedUpdate,this}toJSON(e){let t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(let i in this.uniforms){let s=this.uniforms[i].value;if(s&&s.isTexture)t.uniforms[i]={type:"t",value:s.toJSON(e).uuid};else if(s&&s.isColor)t.uniforms[i]={type:"c",value:s.getHex()};else if(s&&s.isVector2)t.uniforms[i]={type:"v2",value:s.toArray()};else if(s&&s.isVector3)t.uniforms[i]={type:"v3",value:s.toArray()};else if(s&&s.isVector4)t.uniforms[i]={type:"v4",value:s.toArray()};else if(s&&s.isMatrix3)t.uniforms[i]={type:"m3",value:s.toArray()};else if(s&&s.isMatrix4)t.uniforms[i]={type:"m4",value:s.toArray()};else t.uniforms[i]={value:s}}if(Object.keys(this.defines).length>0)t.defines=this.defines;t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;let n={};for(let i in this.extensions)if(this.extensions[i]===!0)n[i]=!0;if(Object.keys(n).length>0)t.extensions=n;return t}fromJSON(e,t){if(super.fromJSON(e,t),e.uniforms!==void 0)for(let n in e.uniforms){let i=e.uniforms[n];switch(this.uniforms[n]={},i.type){case"t":this.uniforms[n].value=t[i.value]||null;break;case"c":this.uniforms[n].value=new Oe().setHex(i.value);break;case"v2":this.uniforms[n].value=new Ne().fromArray(i.value);break;case"v3":this.uniforms[n].value=new O().fromArray(i.value);break;case"v4":this.uniforms[n].value=new at().fromArray(i.value);break;case"m3":this.uniforms[n].value=new ze().fromArray(i.value);break;case"m4":this.uniforms[n].value=new Ge().fromArray(i.value);break;default:this.uniforms[n].value=i.value}}if(e.defines!==void 0)this.defines=e.defines;if(e.vertexShader!==void 0)this.vertexShader=e.vertexShader;if(e.fragmentShader!==void 0)this.fragmentShader=e.fragmentShader;if(e.glslVersion!==void 0)this.glslVersion=e.glslVersion;if(e.extensions!==void 0)for(let n in e.extensions)this.extensions[n]=e.extensions[n];if(e.lights!==void 0)this.lights=e.lights;if(e.clipping!==void 0)this.clipping=e.clipping;return this}}class xu extends In{constructor(e){super(e);this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class Ci extends hn{constructor(e){super();this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new Oe(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Oe(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Ne(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new ni,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class yn extends Ci{constructor(e){super();this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new Ne(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return We(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+0.4*t)/(1-0.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new Oe(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new Oe(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new Oe(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._retroreflectivity=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){if(this._anisotropy>0!==e>0)this.version++;this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){if(this._clearcoat>0!==e>0)this.version++;this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){if(this._iridescence>0!==e>0)this.version++;this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){if(this._dispersion>0!==e>0)this.version++;this._dispersion=e}get retroreflectivity(){return this._retroreflectivity}set retroreflectivity(e){if(this._retroreflectivity>0!==e>0)this.version++;this._retroreflectivity=e}get sheen(){return this._sheen}set sheen(e){if(this._sheen>0!==e>0)this.version++;this._sheen=e}get transmission(){return this._transmission}set transmission(e){if(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.dispersion=e.dispersion,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.retroreflectivity=e.retroreflectivity,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 Ha extends hn{constructor(e){super();this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new Oe(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Oe(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Ne(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new ni,this.combine=0,this.reflectivity=1,this.envMapIntensity=1,this.refractionRatio=0.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.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.envMapIntensity=e.envMapIntensity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class yu extends hn{constructor(e){super();this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=3200,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.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 vu extends hn{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}}function $i(e,t){if(!e||e.constructor===t)return e;if(typeof t.BYTES_PER_ELEMENT==="number")return new t(e);return Array.prototype.slice.call(e)}function _a(e){return e!==void 0&&e.inTangents!==void 0&&e.outTangents!==void 0}function cb(e){function t(r,s){return e[r]-e[s]}let n=e.length,i=Array(n);for(let r=0;r!==n;++r)i[r]=r;return i.sort(t),i}function od(e,t,n){let i=e.length,r=new e.constructor(i);for(let s=0,o=0;o!==i;++s){let a=n[s]*t;for(let c=0;c!==t;++c)r[o++]=e[a+c]}return r}function lb(e,t,n,i){let r=1,s=e[0];while(s!==void 0&&s[i]===void 0)s=e[r++];if(s===void 0)return;let o=s[i];if(o===void 0)return;if(Array.isArray(o))do{if(o=s[i],o!==void 0)t.push(s.time),n.push(...o);s=e[r++]}while(s!==void 0);else if(o.toArray!==void 0)do{if(o=s[i],o!==void 0)t.push(s.time),o.toArray(n,n.length);s=e[r++]}while(s!==void 0);else do{if(o=s[i],o!==void 0)t.push(s.time),n.push(o);s=e[r++]}while(s!==void 0)}class Pi{constructor(e,t,n,i){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=i!==void 0?i:new t.constructor(n),this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){let t=this.parameterPositions,n=this._cachedIndex,i=t[n],r=t[n-1];e:{t:{let s;n:{i:if(!(e<i)){for(let o=n+2;;){if(i===void 0){if(e<r)break i;return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===o)break;if(r=i,i=t[++n],e<i)break t}s=t.length;break n}if(!(e>=r)){let o=t[1];if(e<o)n=2,r=o;for(let a=n-2;;){if(r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===a)break;if(i=r,r=t[--n-1],e>=r)break t}s=n,n=0;break n}break e}while(n<s){let o=n+s>>>1;if(e<t[o])s=o;else n=o+1}if(i=t[n],r=t[n-1],r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===void 0)return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,r,i)}return this.interpolate_(n,r,e,i)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){let t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=e*i;for(let s=0;s!==i;++s)t[s]=n[r+s];return t}interpolate_(){throw Error("THREE.Interpolant: Call to abstract method.")}intervalChanged_(){}}class bu extends Pi{constructor(e,t,n,i){super(e,t,n,i);this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:2400,endingEnd:2400}}intervalChanged_(e,t,n){let i=this.parameterPositions,r=e-2,s=e+1,o=i[r],a=i[s];if(o===void 0)switch(this.getSettings_().endingStart){case 2401:r=e,o=2*t-n;break;case 2402:r=i.length-2,o=t+i[r]-i[r+1];break;default:r=e,o=n}if(a===void 0)switch(this.getSettings_().endingEnd){case 2401:s=e,a=2*n-t;break;case 2402:s=1,a=n+i[1]-i[0];break;default:s=e-1,a=t}let c=(n-t)*0.5,l=this.valueSize;this._weightPrev=c/(t-o),this._weightNext=c/(a-n),this._offsetPrev=r*l,this._offsetNext=s*l}interpolate_(e,t,n,i){let r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=e*o,c=a-o,l=this._offsetPrev,u=this._offsetNext,f=this._weightPrev,h=this._weightNext,d=(n-t)/(i-t),g=d*d,x=g*d,p=-f*x+2*f*g-f*d,m=(1+f)*x+(-1.5-2*f)*g+(-0.5+f)*d+1,E=(-1-h)*x+(1.5+h)*g+0.5*d,R=h*x-h*g;for(let v=0;v!==o;++v)r[v]=p*s[l+v]+m*s[c+v]+E*s[a+v]+R*s[u+v];return r}}class Va extends Pi{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){let r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=e*o,c=a-o,l=(n-t)/(i-t),u=1-l;for(let f=0;f!==o;++f)r[f]=s[c+f]*u+s[a+f]*l;return r}}class Su extends Pi{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e){return this.copySampleValue_(e-1)}}class Mu extends Pi{interpolate_(e,t,n,i){let r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=e*o,c=a-o,l=this.inTangents,u=this.outTangents;if(!l||!u){let d=(n-t)/(i-t),g=1-d;for(let x=0;x!==o;++x)r[x]=s[c+x]*g+s[a+x]*d;return r}let f=o*2,h=e-1;for(let d=0;d!==o;++d){let g=s[c+d],x=s[a+d],p=h*f+d*2,m=u[p],E=u[p+1],R=e*f+d*2,v=l[R],M=l[R+1],T=hb(n,t,m,v,i);r[d]=dp(T,g,E,M,x)}return r}}function dp(e,t,n,i,r){let s=1-e;return s*s*s*t+3*s*s*e*n+3*s*e*e*i+e*e*e*r}function ub(e,t,n,i,r){let s=1-e;return 3*s*s*(n-t)+6*s*e*(i-n)+3*e*e*(r-i)}function hb(e,t,n,i,r){let s=(e-t)/(r-t);for(let o=0;o<8;o++){let a=dp(s,t,n,i,r)-e;if(Math.abs(a)<0.0000000001)break;let c=ub(s,t,n,i,r);if(Math.abs(c)<0.0000000001)break;s=Math.max(0,Math.min(1,s-a/c))}return s}class vn{constructor(e,t,n,i){if(e===void 0)throw Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=$i(t,this.TimeBufferType),this.values=$i(n,this.ValueBufferType),this.setInterpolation(i||this.DefaultInterpolation)}static toJSON(e){let t=e.constructor,n;if(t.toJSON!==this.toJSON)n=t.toJSON(e);else{n={name:e.name,times:$i(e.times,Array),values:$i(e.values,Array)};let i=e.getInterpolation();if(i!==e.DefaultInterpolation)n.interpolation=i;if(_a(e.settings))n.settings={inTangents:$i(e.settings.inTangents,Array),outTangents:$i(e.settings.outTangents,Array)}}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new Su(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new Va(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new bu(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodBezier(e){let t=new Mu(this.times,this.values,this.getValueSize(),e);if(this.settings)t.inTangents=this.settings.inTangents,t.outTangents=this.settings.outTangents;return t}setInterpolation(e){let t;switch(e){case 2300:t=this.InterpolantFactoryMethodDiscrete;break;case 2301:t=this.InterpolantFactoryMethodLinear;break;case 2302:t=this.InterpolantFactoryMethodSmooth;break;case 2303:t=this.InterpolantFactoryMethodBezier;break}if(t===void 0){let n="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw Error(n);return Ie("KeyframeTrack:",n),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return 2300;case this.InterpolantFactoryMethodLinear:return 2301;case this.InterpolantFactoryMethodSmooth:return 2302;case this.InterpolantFactoryMethodBezier:return 2303}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){let t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]+=e}return this}scale(e){if(e!==1){let t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]*=e;if(_a(this.settings))ad(this.settings.inTangents,e),ad(this.settings.outTangents,e)}return this}trim(e,t){let n=this.times,i=n.length,r=0,s=i-1;while(r!==i&&n[r]<e)++r;while(s!==-1&&n[s]>t)--s;if(++s,r!==0||s!==i){if(r>=s)s=Math.max(s,1),r=s-1;let o=this.getValueSize();this.times=n.slice(r,s),this.values=this.values.slice(r*o,s*o)}return this}validate(){let e=!0,t=this.getValueSize();if(t-Math.floor(t)!==0)Ue("KeyframeTrack: Invalid value size in track.",this),e=!1;let n=this.times,i=this.values,r=n.length;if(r===0)Ue("KeyframeTrack: Track is empty.",this),e=!1;let s=null;for(let o=0;o!==r;o++){let a=n[o];if(typeof a==="number"&&isNaN(a)){Ue("KeyframeTrack: Time is not a valid number.",this,o,a),e=!1;break}if(s!==null&&s>a){Ue("KeyframeTrack: Out of order keys.",this,o,a,s),e=!1;break}s=a}if(i!==void 0){if(bv(i))for(let o=0,a=i.length;o!==a;++o){let c=i[o];if(isNaN(c)){Ue("KeyframeTrack: Value is not a valid number.",this,o,c),e=!1;break}}}return e}optimize(){let e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),i=this.getInterpolation()===2302,r=e.length-1,s=1;for(let o=1;o<r;++o){let a=!1,c=e[o],l=e[o+1];if(c!==l&&(o!==1||c!==e[0]))if(!i){let u=o*n,f=u-n,h=u+n;for(let d=0;d!==n;++d){let g=t[u+d];if(g!==t[f+d]||g!==t[h+d]){a=!0;break}}}else a=!0;if(a){if(o!==s){e[s]=e[o];let u=o*n,f=s*n;for(let h=0;h!==n;++h)t[f+h]=t[u+h]}++s}}if(r>0){e[s]=e[r];for(let o=r*n,a=s*n,c=0;c!==n;++c)t[a+c]=t[o+c];++s}if(s!==e.length)this.times=e.slice(0,s),this.values=t.slice(0,s*n);else this.times=e,this.values=t;return this}clone(){let e=this.times.slice(),t=this.values.slice(),i=new this.constructor(this.name,e,t);if(i.createInterpolant=this.createInterpolant,_a(this.settings))i.settings={inTangents:this.settings.inTangents.slice(),outTangents:this.settings.outTangents.slice()};return i}}function ad(e,t){for(let n=0,i=e.length;n!==i;n+=2)e[n]*=t}vn.prototype.ValueTypeName="";vn.prototype.TimeBufferType=Float32Array;vn.prototype.ValueBufferType=Float32Array;vn.prototype.DefaultInterpolation=2301;class er extends vn{constructor(e,t,n){super(e,t,n)}}er.prototype.ValueTypeName="bool";er.prototype.ValueBufferType=Array;er.prototype.DefaultInterpolation=2300;er.prototype.InterpolantFactoryMethodLinear=void 0;er.prototype.InterpolantFactoryMethodSmooth=void 0;class $a extends vn{constructor(e,t,n,i){super(e,t,n,i)}}$a.prototype.ValueTypeName="color";class tr extends vn{constructor(e,t,n,i){super(e,t,n,i)}}tr.prototype.ValueTypeName="number";class wu extends Pi{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){let r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=(n-t)/(i-t),c=e*o;for(let l=c+o;c!==l;c+=4)Ht.slerpFlat(r,0,s,c-o,s,c,a);return r}}class nr extends vn{constructor(e,t,n,i){super(e,t,n,i)}InterpolantFactoryMethodLinear(e){return new wu(this.times,this.values,this.getValueSize(),e)}}nr.prototype.ValueTypeName="quaternion";nr.prototype.InterpolantFactoryMethodSmooth=void 0;class ir extends vn{constructor(e,t,n){super(e,t,n)}}ir.prototype.ValueTypeName="string";ir.prototype.ValueBufferType=Array;ir.prototype.DefaultInterpolation=2300;ir.prototype.InterpolantFactoryMethodLinear=void 0;ir.prototype.InterpolantFactoryMethodSmooth=void 0;class Rr extends vn{constructor(e,t,n,i){super(e,t,n,i)}}Rr.prototype.ValueTypeName="vector";class rs{constructor(e="",t=-1,n=[],i=2500){if(this.name=e,this.tracks=n,this.duration=t,this.blendMode=i,this.uuid=Gn(),this.userData={},this.duration<0)this.resetDuration()}static parse(e){let t=[],n=e.tracks,i=1/(e.fps||1);for(let s=0,o=n.length;s!==o;++s)t.push(db(n[s]).scale(i));let r=new this(e.name,e.duration,t,e.blendMode);return r.uuid=e.uuid,r.userData=JSON.parse(e.userData||"{}"),r}static toJSON(e){let t=[],n=e.tracks,i={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode,userData:JSON.stringify(e.userData)};for(let r=0,s=n.length;r!==s;++r)t.push(vn.toJSON(n[r]));return i}static CreateFromMorphTargetSequence(e,t,n,i){let r=t.length,s=[];for(let o=0;o<r;o++){let a=[],c=[];a.push((o+r-1)%r,o,(o+1)%r),c.push(0,1,0);let l=cb(a);if(a=od(a,1,l),c=od(c,1,l),!i&&a[0]===0)a.push(r),c.push(c[0]);s.push(new tr(".morphTargetInfluences["+t[o].name+"]",a,c).scale(1/n))}return new this(e,-1,s)}static findByName(e,t){let n=e;if(!Array.isArray(e)){let i=e;n=i.geometry&&i.geometry.animations||i.animations}for(let i=0;i<n.length;i++)if(n[i].name===t)return n[i];return null}static CreateClipsFromMorphTargetSequences(e,t,n){let i={},r=/^([\w-]*?)([\d]+)$/;for(let o=0,a=e.length;o<a;o++){let c=e[o],l=c.name.match(r);if(l&&l.length>1){let u=l[1],f=i[u];if(!f)i[u]=f=[];f.push(c)}}let s=[];for(let o in i)s.push(this.CreateFromMorphTargetSequence(o,i[o],t,n));return s}resetDuration(){let e=this.tracks,t=0;for(let n=0,i=e.length;n!==i;++n){let r=this.tracks[n];t=Math.max(t,r.times[r.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){let e=[];for(let n=0;n<this.tracks.length;n++)e.push(this.tracks[n].clone());let t=new this.constructor(this.name,this.duration,e,this.blendMode);return t.userData=JSON.parse(JSON.stringify(this.userData)),t}toJSON(){return this.constructor.toJSON(this)}}function fb(e){switch(e.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return tr;case"vector":case"vector2":case"vector3":case"vector4":return Rr;case"color":return $a;case"quaternion":return nr;case"bool":case"boolean":return er;case"string":return ir}throw Error("THREE.KeyframeTrack: Unsupported typeName: "+e)}function db(e){if(e.type===void 0)throw Error("THREE.KeyframeTrack: track type undefined, can not parse");let t=fb(e.type);if(e.times===void 0){let i=[],r=[];lb(e.keys,i,r,"value"),e.times=i,e.values=r}let n;if(t.parse!==void 0)n=t.parse(e);else n=new t(e.name,e.times,e.values,e.interpolation);if(_a(e.settings))n.settings={inTangents:$i(e.settings.inTangents,Float32Array),outTangents:$i(e.settings.outTangents,Float32Array)};return n}var ti={enabled:!1,files:{},add:function(e,t){if(this.enabled===!1)return;if(cd(e))return;this.files[e]=t},get:function(e){if(this.enabled===!1)return;if(cd(e))return;return this.files[e]},remove:function(e){delete this.files[e]},clear:function(){this.files={}}};function cd(e){try{let t=e.slice(e.indexOf(":")+1);return new URL(t).protocol==="blob:"}catch(t){return!1}}class oo{constructor(e,t,n){let i=this,r=!1,s=0,o=0,a=void 0,c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this._abortController=null,this.itemStart=function(l){if(o++,r===!1){if(i.onStart!==void 0)i.onStart(l,s,o)}r=!0},this.itemEnd=function(l){if(s++,i.onProgress!==void 0)i.onProgress(l,s,o);if(s===o){if(r=!1,i.onLoad!==void 0)i.onLoad()}},this.itemError=function(l){if(i.onError!==void 0)i.onError(l)},this.resolveURL=function(l){if(l=l.normalize("NFC"),a)return a(l);return l},this.setURLModifier=function(l){return a=l,this},this.addHandler=function(l,u){return c.push(l,u),this},this.removeHandler=function(l){let u=c.indexOf(l);if(u!==-1)c.splice(u,2);return this},this.getHandler=function(l){for(let u=0,f=c.length;u<f;u+=2){let h=c[u],d=c[u+1];if(h.global)h.lastIndex=0;if(h.test(l))return d}return null},this.abort=function(){return this.abortController.abort(),this._abortController=null,this}}get abortController(){if(!this._abortController)this._abortController=new AbortController;return this._abortController}}var pp=new oo;class Ii{constructor(e){if(this.manager=e!==void 0?e:pp,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={},typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}load(){}loadAsync(e,t){let n=this;return new Promise(function(i,r){n.load(e,i,t,r)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}abort(){return this}}Ii.DEFAULT_MATERIAL_NAME="__DEFAULT";var Ti={};class mp extends Error{constructor(e,t){super(e);this.response=t}}class ao extends Ii{constructor(e){super(e);this.mimeType="",this.responseType="",this._abortController=new AbortController}load(e,t,n,i){if(e===void 0)e="";if(this.path!==void 0)e=this.path+e;e=this.manager.resolveURL(e);let r=ti.get(`file:${e}`);if(r!==void 0){this.manager.itemStart(e),setTimeout(()=>{if(t)t(r);this.manager.itemEnd(e)},0);return}if(Ti[e]!==void 0){Ti[e].push({onLoad:t,onProgress:n,onError:i});return}Ti[e]=[],Ti[e].push({onLoad:t,onProgress:n,onError:i});let s=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin",signal:typeof AbortSignal.any==="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal}),o=this.mimeType,a=this.responseType;fetch(s).then((c)=>{if(c.status===200||c.status===0){if(c.status===0)Ie("FileLoader: HTTP Status 0 received.");if(typeof ReadableStream>"u"||c.body===void 0||c.body.getReader===void 0)return c;let l=Ti[e],u=c.body.getReader(),f=c.headers.get("X-File-Size")||c.headers.get("Content-Length"),h=f?parseInt(f):0,d=h!==0,g=0,x=new ReadableStream({start(p){m();function m(){u.read().then(({done:E,value:R})=>{if(E)p.close();else{g+=R.byteLength;let v=new ProgressEvent("progress",{lengthComputable:d,loaded:g,total:h});for(let M=0,T=l.length;M<T;M++){let A=l[M];if(A.onProgress)A.onProgress(v)}p.enqueue(R),m()}},(E)=>{p.error(E)})}}});return new Response(x)}else throw new mp(`fetch for "${c.url}" responded with ${c.status}: ${c.statusText}`,c)}).then((c)=>{switch(a){case"arraybuffer":return c.arrayBuffer();case"blob":return c.blob();case"document":return c.text().then((l)=>new DOMParser().parseFromString(l,o));case"json":return c.json();default:if(o==="")return c.text();else{let u=/charset="?([^;"\s]*)"?/i.exec(o),f=u&&u[1]?u[1].toLowerCase():void 0,h=new TextDecoder(f);return c.arrayBuffer().then((d)=>h.decode(d))}}}).then((c)=>{ti.add(`file:${e}`,c);let l=Ti[e];delete Ti[e];for(let u=0,f=l.length;u<f;u++){let h=l[u];if(h.onLoad)h.onLoad(c)}}).catch((c)=>{let l=Ti[e];if(l===void 0)throw this.manager.itemError(e),c;delete Ti[e];for(let u=0,f=l.length;u<f;u++){let h=l[u];if(h.onError)h.onError(c)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}var Jr=new WeakMap;class Eu extends Ii{constructor(e){super(e)}load(e,t,n,i){if(this.path!==void 0)e=this.path+e;e=this.manager.resolveURL(e);let r=this,s=ti.get(`image:${e}`);if(s!==void 0){if(s.complete===!0)r.manager.itemStart(e),setTimeout(function(){if(t)t(s);r.manager.itemEnd(e)},0);else{let u=Jr.get(s);if(u===void 0)u=[],Jr.set(s,u);u.push({onLoad:t,onError:i})}return s}let o=ns("img");function a(){if(l(),t)t(this);let u=Jr.get(this)||[];for(let f=0;f<u.length;f++){let h=u[f];if(h.onLoad)h.onLoad(this)}Jr.delete(this),r.manager.itemEnd(e)}function c(u){if(l(),i)i(u);ti.remove(`image:${e}`);let f=Jr.get(this)||[];for(let h=0;h<f.length;h++){let d=f[h];if(d.onError)d.onError(u)}Jr.delete(this),r.manager.itemError(e),r.manager.itemEnd(e)}function l(){o.removeEventListener("load",a,!1),o.removeEventListener("error",c,!1)}if(o.addEventListener("load",a,!1),o.addEventListener("error",c,!1),e.slice(0,5)!=="data:"){if(this.crossOrigin!==void 0)o.crossOrigin=this.crossOrigin}return ti.add(`image:${e}`,o),r.manager.itemStart(e),o.src=e,o}}class _s extends Ii{constructor(e){super(e)}load(e,t,n,i){let r=new At,s=new Eu(this.manager);return s.setCrossOrigin(this.crossOrigin),s.setPath(this.path),s.load(e,function(o){if(r.image=o,r.needsUpdate=!0,t!==void 0)t(r)},n,i),r}}class xs extends ut{constructor(e,t=1){super();this.isLight=!0,this.type="Light",this.color=new Oe(e),this.intensity=t}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){let t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,t}}class Wa extends xs{constructor(e,t,n){super(e,n);this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(ut.DEFAULT_UP),this.updateMatrix(),this.groundColor=new Oe(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}toJSON(e){let t=super.toJSON(e);return t.object.groundColor=this.groundColor.getHex(),t}}var ul=new Ge,ld=new O,ud=new O;class co{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.biasNode=null,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Ne(512,512),this.mapType=1009,this.map=null,this.mapPass=null,this.matrix=new Ge,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new no,this._frameExtents=new Ne(1,1),this._viewportCount=1,this._viewports=[new at(0,0,1,1)]}getViewportCount(){return this._viewportCount}getCamera(){return this.camera}getFrustum(){return this._frustum}updateMatrices(e){let t=this.camera;ld.setFromMatrixPosition(e.matrixWorld),t.position.copy(ld),ud.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(ud),t.updateMatrixWorld(),this._updateMatrix(t,this.matrix,this._frustum)}_updateMatrix(e,t,n,i){ul.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),n.setFromProjectionMatrix(ul,e.coordinateSystem,e.reversedDepth);let r=this._frameExtents,s=i?i.z/r.x:1,o=i?i.w/r.y:1,a=i?i.x/r.x:0,c=i?i.y/r.y:0;if(e.coordinateSystem===2001||e.reversedDepth)t.set(0.5*s,0,0,0.5*s+a,0,0.5*o,0,0.5*o+c,0,0,1,0,0,0,0,1);else t.set(0.5*s,0,0,0.5*s+a,0,0.5*o,0,0.5*o+c,0,0,0.5,0.5,0,0,0,1);t.multiply(ul)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){if(this.map)this.map.dispose();if(this.mapPass)this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.intensity=e.intensity,this.bias=e.bias,this.radius=e.radius,this.autoUpdate=e.autoUpdate,this.needsUpdate=e.needsUpdate,this.normalBias=e.normalBias,this.blurSamples=e.blurSamples,this.mapSize.copy(e.mapSize),this.biasNode=e.biasNode,this}clone(){return new this.constructor().copy(this)}toJSON(){let e={};return e.intensity=this.intensity,e.bias=this.bias,e.normalBias=this.normalBias,e.radius=this.radius,e.blurSamples=this.blurSamples,e.mapSize=this.mapSize.toArray(),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}var ma=new O,ga=new Ht,Qn=new O;class Za extends ut{constructor(){super();this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Ge,this.projectionMatrix=new Ge,this.projectionMatrixInverse=new Ge,this.coordinateSystem=2000,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}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){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){if(super.updateMatrixWorld(e),this.matrixWorld.decompose(ma,ga,Qn),Qn.x===1&&Qn.y===1&&Qn.z===1)this.matrixWorldInverse.copy(this.matrixWorld).invert();else this.matrixWorldInverse.compose(ma,ga,Qn.set(1,1,1)).invert()}updateWorldMatrix(e,t,n=!1){if(super.updateWorldMatrix(e,t,n),this.matrixWorld.decompose(ma,ga,Qn),Qn.x===1&&Qn.y===1&&Qn.z===1)this.matrixWorldInverse.copy(this.matrixWorld).invert();else this.matrixWorldInverse.compose(ma,ga,Qn.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}}var Vi=new O,hd=new Ne,fd=new Ne;class Ut extends Za{constructor(e=50,t=1,n=0.1,i=2000){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){let t=0.5*this.getFilmHeight()/e;this.fov=yr*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan(Bs*0.5*this.fov);return 0.5*this.getFilmHeight()/e}getEffectiveFOV(){return yr*2*Math.atan(Math.tan(Bs*0.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,n){Vi.set(-1,-1,0.5).applyMatrix4(this.projectionMatrixInverse),t.set(Vi.x,Vi.y).multiplyScalar(-e/Vi.z),Vi.set(1,1,0.5).applyMatrix4(this.projectionMatrixInverse),n.set(Vi.x,Vi.y).multiplyScalar(-e/Vi.z)}getViewSize(e,t){return this.getViewBounds(e,hd,fd),t.subVectors(fd,hd)}setViewOffset(e,t,n,i,r,s){if(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=r,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){if(this.view!==null)this.view.enabled=!1;this.updateProjectionMatrix()}updateProjectionMatrix(){let e=this.near,t=e*Math.tan(Bs*0.5*this.fov)/this.zoom,n=2*t,i=this.aspect*n,r=-0.5*i,s=this.view;if(this.view!==null&&this.view.enabled){let{fullWidth:a,fullHeight:c}=s;r+=s.offsetX*i/a,t-=s.offsetY*n/c,i*=s.width/a,n*=s.height/c}let o=this.filmOffset;if(o!==0)r+=e*o/this.getFilmWidth();this.projectionMatrix.makePerspective(r,r+i,t,t-n,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);if(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);return t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}class gp extends co{constructor(){super(new Ut(50,1,0.5,500));this.isSpotLightShadow=!0,this.focus=1,this.aspect=1}updateMatrices(e){let t=this.camera,n=yr*2*e.angle*this.focus,i=this.mapSize.width/this.mapSize.height*this.aspect,r=e.distance||t.far;if(n!==t.fov||i!==t.aspect||r!==t.far)t.fov=n,t.aspect=i,t.far=r,t.updateProjectionMatrix();super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this.aspect=e.aspect,this}toJSON(){let e=super.toJSON();return e.focus=this.focus,e.aspect=this.aspect,e}}class Xa extends xs{constructor(e,t,n=0,i=Math.PI/3,r=0,s=2){super(e,t);this.isSpotLight=!0,this.type="SpotLight",this.position.copy(ut.DEFAULT_UP),this.updateMatrix(),this.target=new ut,this.distance=n,this.angle=i,this.penumbra=r,this.decay=s,this.map=null,this.shadow=new gp}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){super.dispose(),this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.map=e.map,this.shadow=e.shadow.clone(),this}toJSON(e){let t=super.toJSON(e);if(t.object.distance=this.distance,t.object.angle=this.angle,t.object.decay=this.decay,t.object.penumbra=this.penumbra,t.object.target=this.target.uuid,this.map&&this.map.isTexture)t.object.map=this.map.toJSON(e).uuid;return t.object.shadow=this.shadow.toJSON(),t}}class _p extends co{constructor(){super(new Ut(90,1,0.5,500));this.isPointLightShadow=!0}}class ys extends xs{constructor(e,t,n=0,i=2){super(e,t);this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=i,this.shadow=new _p}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){super.dispose(),this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}toJSON(e){let t=super.toJSON(e);return t.object.distance=this.distance,t.object.decay=this.decay,t.object.shadow=this.shadow.toJSON(),t}}class Cr extends Za{constructor(e=-1,t=1,n=1,i=-1,r=0.1,s=2000){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=r,this.far=s,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,n,i,r,s){if(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=r,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){if(this.view!==null)this.view.enabled=!1;this.updateProjectionMatrix()}updateProjectionMatrix(){let 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,r=n-e,s=n+e,o=i+t,a=i-t;if(this.view!==null&&this.view.enabled){let c=(this.right-this.left)/this.view.fullWidth/this.zoom,l=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=c*this.view.offsetX,s=r+c*this.view.width,o-=l*this.view.offsetY,a=o-l*this.view.height}this.projectionMatrix.makeOrthographic(r,s,o,a,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);if(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);return t}}class xp extends co{constructor(){super(new Cr(-5,5,5,-5,0.5,500));this.isDirectionalLightShadow=!0}}class vs extends xs{constructor(e,t){super(e,t);this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(ut.DEFAULT_UP),this.updateMatrix(),this.target=new ut,this.shadow=new xp}dispose(){super.dispose(),this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}toJSON(e){let t=super.toJSON(e);return t.object.shadow=this.shadow.toJSON(),t.object.target=this.target.uuid,t}}class rr{static extractUrlBase(e){let t=e.lastIndexOf("/");if(t===-1)return"./";return e.slice(0,t+1)}static resolveURL(e,t){if(typeof e!=="string"||e==="")return"";if(/^https?:\/\//i.test(t)&&/^\//.test(e))t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1");if(/^(https?:)?\/\//i.test(e))return e;if(/^data:.*,.*$/i.test(e))return e;if(/^blob:.*$/i.test(e))return e;return t+e}}var hl=new WeakMap;class qa extends Ii{constructor(e){super(e);if(this.isImageBitmapLoader=!0,typeof createImageBitmap>"u")Ie("ImageBitmapLoader: createImageBitmap() not supported.");if(typeof fetch>"u")Ie("ImageBitmapLoader: fetch() not supported.");this.options={premultiplyAlpha:"none"},this._abortController=new AbortController}setOptions(e){return this.options=e,this}load(e,t,n,i){if(e===void 0)e="";if(this.path!==void 0)e=this.path+e;e=this.manager.resolveURL(e);let r=this,s=ti.get(`image-bitmap:${e}`);if(s!==void 0){if(r.manager.itemStart(e),s.then){s.then((c)=>{if(hl.has(s)===!0){if(i)i(hl.get(s));r.manager.itemError(e),r.manager.itemEnd(e)}else{if(t)t(c);r.manager.itemEnd(e)}});return}setTimeout(function(){if(t)t(s);r.manager.itemEnd(e)},0);return}let o={};o.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",o.headers=this.requestHeader,o.signal=typeof AbortSignal.any==="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal;let a=fetch(e,o).then(function(c){return c.blob()}).then(function(c){return createImageBitmap(c,Object.assign({},r.options,{colorSpaceConversion:"none"}))}).then(function(c){if(ti.add(`image-bitmap:${e}`,c),t)t(c);return r.manager.itemEnd(e),c}).catch(function(c){if(i)i(c);hl.set(a,c),ti.remove(`image-bitmap:${e}`),r.manager.itemError(e),r.manager.itemEnd(e)});ti.add(`image-bitmap:${e}`,a),r.manager.itemStart(e)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}var Qr=-90,es=1;class Tu extends ut{constructor(e,t,n){super();this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;let i=new Ut(Qr,es,e,t);i.layers=this.layers,this.add(i);let r=new Ut(Qr,es,e,t);r.layers=this.layers,this.add(r);let s=new Ut(Qr,es,e,t);s.layers=this.layers,this.add(s);let o=new Ut(Qr,es,e,t);o.layers=this.layers,this.add(o);let a=new Ut(Qr,es,e,t);a.layers=this.layers,this.add(a);let c=new Ut(Qr,es,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){let e=this.coordinateSystem,t=this.children.concat(),[n,i,r,s,o,a]=t;for(let c of t)this.remove(c);if(e===2000)n.up.set(0,1,0),n.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),s.up.set(0,0,1),s.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),a.up.set(0,1,0),a.lookAt(0,0,-1);else if(e===2001)n.up.set(0,-1,0),n.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),s.up.set(0,0,-1),s.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),a.up.set(0,-1,0),a.lookAt(0,0,-1);else throw Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(let c of t)this.add(c),c.updateMatrixWorld()}update(e,t){if(this.parent===null)this.updateMatrixWorld();let{renderTarget:n,activeMipmapLevel:i}=this;if(this.coordinateSystem!==e.coordinateSystem)this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem();let[r,s,o,a,c,l]=this.children,u=e.getRenderTarget(),f=e.getActiveCubeFace(),h=e.getActiveMipmapLevel(),d=e.xr.enabled;e.xr.enabled=!1;let g=n.texture.generateMipmaps;n.texture.generateMipmaps=!1;let x=!1;if(e.isWebGLRenderer===!0)x=e.state.buffers.depth.getReversed();else x=e.reversedDepthBuffer;if(e.setRenderTarget(n,0,i),x&&e.autoClear===!1)e.clearDepth();if(e.render(t,r),e.setRenderTarget(n,1,i),x&&e.autoClear===!1)e.clearDepth();if(e.render(t,s),e.setRenderTarget(n,2,i),x&&e.autoClear===!1)e.clearDepth();if(e.render(t,o),e.setRenderTarget(n,3,i),x&&e.autoClear===!1)e.clearDepth();if(e.render(t,a),e.setRenderTarget(n,4,i),x&&e.autoClear===!1)e.clearDepth();if(e.render(t,c),n.texture.generateMipmaps=g,e.setRenderTarget(n,5,i),x&&e.autoClear===!1)e.clearDepth();e.render(t,l),e.setRenderTarget(u,f,h),e.xr.enabled=d,n.texture.needsPMREMUpdate=!0}}class Au extends Ut{constructor(e=[]){super();this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}class Ru{constructor(e,t,n){this.binding=e,this.valueSize=n;let i,r,s;switch(t){case"quaternion":i=this._slerp,r=this._slerpAdditive,s=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(n*6),this._workIndex=5;break;case"string":case"bool":i=this._select,r=this._select,s=this._setAdditiveIdentityOther,this.buffer=Array(n*5);break;default:i=this._lerp,r=this._lerpAdditive,s=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(n*5)}this._mixBufferRegion=i,this._mixBufferRegionAdditive=r,this._setIdentity=s,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(e,t){let n=this.buffer,i=this.valueSize,r=e*i+i,s=this.cumulativeWeight;if(s===0){for(let o=0;o!==i;++o)n[r+o]=n[o];s=t}else{s+=t;let o=t/s;this._mixBufferRegion(n,r,0,o,i)}this.cumulativeWeight=s}accumulateAdditive(e){let t=this.buffer,n=this.valueSize,i=n*this._addIndex;if(this.cumulativeWeightAdditive===0)this._setIdentity();this._mixBufferRegionAdditive(t,i,0,e,n),this.cumulativeWeightAdditive+=e}apply(e){let t=this.valueSize,n=this.buffer,i=e*t+t,r=this.cumulativeWeight,s=this.cumulativeWeightAdditive,o=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,r<1){let a=t*this._origIndex;this._mixBufferRegion(n,i,a,1-r,t)}if(s>0)this._mixBufferRegionAdditive(n,i,this._addIndex*t,1,t);for(let a=t,c=t+t;a!==c;++a)if(n[a]!==n[a+t]){o.setValue(n,i);break}}saveOriginalState(){let e=this.binding,t=this.buffer,n=this.valueSize,i=n*this._origIndex;e.getValue(t,i);for(let r=n,s=i;r!==s;++r)t[r]=t[i+r%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){let e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){let e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let n=e;n<t;n++)this.buffer[n]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){let e=this._origIndex*this.valueSize,t=this._addIndex*this.valueSize;for(let n=0;n<this.valueSize;n++)this.buffer[t+n]=this.buffer[e+n]}_select(e,t,n,i,r){if(i>=0.5)for(let s=0;s!==r;++s)e[t+s]=e[n+s]}_slerp(e,t,n,i){Ht.slerpFlat(e,t,e,t,e,n,i)}_slerpAdditive(e,t,n,i,r){let s=this._workIndex*r;Ht.multiplyQuaternionsFlat(e,s,e,t,e,n),Ht.slerpFlat(e,t,e,t,e,s,i)}_lerp(e,t,n,i,r){let s=1-i;for(let o=0;o!==r;++o){let a=t+o;e[a]=e[a]*s+e[n+o]*i}}_lerpAdditive(e,t,n,i,r){for(let s=0;s!==r;++s){let o=t+s;e[o]=e[o]+e[n+s]*i}}}var Cu="\\[\\]\\.:\\/",pb=new RegExp("["+Cu+"]","g"),Pu="[^"+Cu+"]",mb="[^"+Cu.replace("\\.","")+"]",gb=/((?:WC+[\/:])*)/.source.replace("WC",Pu),_b=/(WCOD+)?/.source.replace("WCOD",mb),xb=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Pu),yb=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Pu),vb=new RegExp("^"+gb+_b+xb+yb+"$"),bb=["material","materials","bones","map"];class yp{constructor(e,t,n){let i=n||et.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,i)}getValue(e,t){this.bind();let n=this._targetGroup.nCachedObjects_,i=this._bindings[n];if(i!==void 0)i.getValue(e,t)}setValue(e,t){let n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,r=n.length;i!==r;++i)n[i].setValue(e,t)}bind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}}class et{constructor(e,t,n){this.path=t,this.parsedPath=n||et.parseTrackName(t),this.node=et.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){if(!(e&&e.isAnimationObjectGroup))return new et(e,t,n);else return new et.Composite(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(pb,"")}static parseTrackName(e){let t=vb.exec(e);if(t===null)throw Error("THREE.PropertyBinding: Cannot parse trackName: "+e);let 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){let r=n.nodeName.substring(i+1);if(bb.indexOf(r)!==-1)n.nodeName=n.nodeName.substring(0,i),n.objectName=r}if(n.propertyName===null||n.propertyName.length===0)throw Error("THREE.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){let n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){let n=function(r){for(let s=0;s<r.length;s++){let o=r[s];if(o.name===t||o.uuid===t)return o;let a=n(o.children);if(a)return a}return null},i=n(e.children);if(i)return i}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){let n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)e[t++]=n[i]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){let n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=e[t++]}_setValue_array_setNeedsUpdate(e,t){let n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){let n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node,t=this.parsedPath,{objectName:n,propertyName:i,propertyIndex:r}=t;if(!e)e=et.findNode(this.rootNode,t.nodeName),this.node=e;if(this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){Ie("PropertyBinding: No target node found for track: "+this.path+".");return}if(n){let c=t.objectIndex;switch(n){case"materials":if(!e.material){Ue("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){Ue("PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){Ue("PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let l=0;l<e.length;l++)if(e[l].name===c){c=l;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){Ue("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){Ue("PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}e=e.material.map;break;default:if(e[n]===void 0){Ue("PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[n]}if(c!==void 0){if(e[c]===void 0){Ue("PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[c]}}let s=e[i];if(s===void 0){let c=t.nodeName;Ue("PropertyBinding: Trying to update property for track: "+c+"."+i+" but it wasn't found.",e);return}let o=this.Versioning.None;if(this.targetObject=e,e.isMaterial===!0)o=this.Versioning.NeedsUpdate;else if(e.isObject3D===!0)o=this.Versioning.MatrixWorldNeedsUpdate;let a=this.BindingType.Direct;if(r!==void 0){if(i==="morphTargetInfluences"){if(!e.geometry){Ue("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){Ue("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}if(e.morphTargetDictionary[r]!==void 0)r=e.morphTargetDictionary[r]}a=this.BindingType.ArrayElement,this.resolvedProperty=s,this.propertyIndex=r}else if(s.fromArray!==void 0&&s.toArray!==void 0)a=this.BindingType.HasFromToArray,this.resolvedProperty=s;else if(Array.isArray(s))a=this.BindingType.EntireArray,this.resolvedProperty=s;else this.propertyName=i;this.getValue=this.GetterByBindingType[a],this.setValue=this.SetterByBindingTypeAndVersioning[a][o]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}et.Composite=yp;et.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};et.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};et.prototype.GetterByBindingType=[et.prototype._getValue_direct,et.prototype._getValue_array,et.prototype._getValue_arrayElement,et.prototype._getValue_toArray];et.prototype.SetterByBindingTypeAndVersioning=[[et.prototype._setValue_direct,et.prototype._setValue_direct_setNeedsUpdate,et.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[et.prototype._setValue_array,et.prototype._setValue_array_setNeedsUpdate,et.prototype._setValue_array_setMatrixWorldNeedsUpdate],[et.prototype._setValue_arrayElement,et.prototype._setValue_arrayElement_setNeedsUpdate,et.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[et.prototype._setValue_fromArray,et.prototype._setValue_fromArray_setNeedsUpdate,et.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class Iu{constructor(e,t,n=null,i=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=n,this.blendMode=i;let r=t.tracks,s=r.length,o=Array(s),a={endingStart:2400,endingEnd:2400};for(let c=0;c!==s;++c){let l=r[c].createInterpolant(null);o[c]=l,l.settings=a}this._interpolantSettings=a,this._interpolants=o,this._propertyBindings=Array(s),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._restoreTimeScale=null,this._weightInterpolant=null,this.loop=2201,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&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=!1){if(e.fadeOut(t),this.fadeIn(t),n===!0){let i=this._clip.duration,r=e._clip.duration,s=r/i,o=i/r;e._restoreTimeScale=e.timeScale,this._restoreTimeScale=this.timeScale,e.warp(1,s,t),this.warp(o,1,t)}return this}crossFadeTo(e,t,n=!1){return e.crossFadeFrom(this,t,n)}stopFading(){let e=this._weightInterpolant;if(e!==null)this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e);return this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,n){let i=this._mixer,r=i.time,s=this.timeScale,o=this._timeScaleInterpolant;if(o===null)o=i._lendControlInterpolant(),this._timeScaleInterpolant=o;let a=o.parameterPositions,c=o.sampleValues;return a[0]=r,a[1]=r+n,c[0]=e/s,c[1]=t/s,this}stopWarping(){let e=this._timeScaleInterpolant;if(e!==null)this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e);return this._restoreTimeScale=null,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}let r=this._startTime;if(r!==null){let a=(e-r)*n;if(a<0||n===0)t=0;else this._startTime=null,t=n*a}t*=this._updateTimeScale(e);let s=this._updateTime(t),o=this._updateWeight(e);if(o>0){let a=this._interpolants,c=this._propertyBindings;switch(this.blendMode){case 2501:for(let l=0,u=a.length;l!==u;++l)a[l].evaluate(s),c[l].accumulateAdditive(o);break;case 2500:default:for(let l=0,u=a.length;l!==u;++l)a[l].evaluate(s),c[l].accumulate(i,o)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;let n=this._weightInterpolant;if(n!==null){let i=n.evaluate(e)[0];if(t*=i,e>n.parameterPositions[1]){if(this.stopFading(),i===0)this.enabled=!1}}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;let n=this._timeScaleInterpolant;if(n!==null){let i=n.evaluate(e)[0];if(t*=i,e>n.parameterPositions[1]){if(t===0)this.paused=!0;else{if(this._restoreTimeScale!==null)t=this._restoreTimeScale;this.timeScale=t}this.stopWarping()}}}return this._effectiveTimeScale=t,t}_updateTime(e){let t=this._clip.duration,n=this.loop,i=this.time+e,r=this._loopCount,s=n===2202;if(e===0){if(r===-1)return i;return s&&(r&1)===1?t-i:i}if(n===2200){if(r===-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}if(this.clampWhenFinished)this.paused=!0;else this.enabled=!1;this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(r===-1)if(e>=0)r=0,this._setEndings(!0,this.repetitions===0,s);else this._setEndings(this.repetitions===0,!0,s);if(i>=t||i<0){let o=Math.floor(i/t);i-=t*o,r+=Math.abs(o);let a=this.repetitions-r;if(a<=0){if(this.clampWhenFinished)this.paused=!0;else 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(a===1){let c=e<0;this._setEndings(c,!c,s)}else this._setEndings(!1,!1,s);this._loopCount=r,this.time=i,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:o})}}else this._loopCount=r,this.time=i;if(s&&(r&1)===1)return t-i}return i}_setEndings(e,t,n){let i=this._interpolantSettings;if(n)i.endingStart=2401,i.endingEnd=2401;else{if(e)i.endingStart=this.zeroSlopeAtStart?2401:2400;else i.endingStart=2402;if(t)i.endingEnd=this.zeroSlopeAtEnd?2401:2400;else i.endingEnd=2402}}_scheduleFading(e,t,n){let i=this._mixer,r=i.time,s=this._weightInterpolant;if(s===null)s=i._lendControlInterpolant(),this._weightInterpolant=s;let o=s.parameterPositions,a=s.sampleValues;return o[0]=r,a[0]=t,o[1]=r+e,a[1]=n,this}}var Sb=new Float32Array(1);class ja extends Wn{constructor(e){super();if(this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1,typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}_bindAction(e,t){let n=e._localRoot||this._root,i=e._clip.tracks,r=i.length,{_propertyBindings:s,_interpolants:o}=e,a=n.uuid,c=this._bindingsByRootAndName,l=c[a];if(l===void 0)l={},c[a]=l;for(let u=0;u!==r;++u){let f=i[u],h=f.name,d=l[h];if(d!==void 0)++d.referenceCount,s[u]=d;else{if(d=s[u],d!==void 0){if(d._cacheIndex===null)++d.referenceCount,this._addInactiveBinding(d,a,h);continue}let g=t&&t._propertyBindings[u].binding.parsedPath;d=new Ru(et.create(n,h,g),f.ValueTypeName,f.getValueSize()),++d.referenceCount,this._addInactiveBinding(d,a,h),s[u]=d}o[u].resultBuffer=d.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){let n=(e._localRoot||this._root).uuid,i=e._clip.uuid,r=this._actionsByClip[i];this._bindAction(e,r&&r.knownActions[0]),this._addInactiveAction(e,i,n)}let t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){let r=t[n];if(r.useCount++===0)this._lendBinding(r),r.saveOriginalState()}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){let t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){let r=t[n];if(--r.useCount===0)r.restoreOriginalState(),this._takeBackBinding(r)}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;let e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){let t=e._cacheIndex;return t!==null&&t<this._nActiveActions}_addInactiveAction(e,t,n){let i=this._actions,r=this._actionsByClip,s=r[t];if(s===void 0)s={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,r[t]=s;else{let o=s.knownActions;e._byClipCacheIndex=o.length,o.push(e)}e._cacheIndex=i.length,i.push(e),s.actionByRoot[n]=e}_removeInactiveAction(e){let t=this._actions,n=t[t.length-1],i=e._cacheIndex;n._cacheIndex=i,t[i]=n,t.pop(),e._cacheIndex=null;let r=e._clip.uuid,s=this._actionsByClip,o=s[r],a=o.knownActions,c=a[a.length-1],l=e._byClipCacheIndex;c._byClipCacheIndex=l,a[l]=c,a.pop(),e._byClipCacheIndex=null;let u=o.actionByRoot,f=(e._localRoot||this._root).uuid;if(delete u[f],a.length===0)delete s[r];this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){let t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){let r=t[n];if(--r.referenceCount===0)this._removeInactiveBinding(r)}}_lendAction(e){let t=this._actions,n=e._cacheIndex,i=this._nActiveActions++,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_takeBackAction(e){let t=this._actions,n=e._cacheIndex,i=--this._nActiveActions,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_addInactiveBinding(e,t,n){let i=this._bindingsByRootAndName,r=this._bindings,s=i[t];if(s===void 0)s={},i[t]=s;s[n]=e,e._cacheIndex=r.length,r.push(e)}_removeInactiveBinding(e){let t=this._bindings,n=e.binding,i=n.rootNode.uuid,r=n.path,s=this._bindingsByRootAndName,o=s[i],a=t[t.length-1],c=e._cacheIndex;if(a._cacheIndex=c,t[c]=a,t.pop(),delete o[r],Object.keys(o).length===0)delete s[i]}_lendBinding(e){let t=this._bindings,n=e._cacheIndex,i=this._nActiveBindings++,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_takeBackBinding(e){let t=this._bindings,n=e._cacheIndex,i=--this._nActiveBindings,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_lendControlInterpolant(){let e=this._controlInterpolants,t=this._nActiveControlInterpolants++,n=e[t];if(n===void 0)n=new Va(new Float32Array(2),new Float32Array(2),1,Sb),n.__cacheIndex=t,e[t]=n;return n}_takeBackControlInterpolant(e){let t=this._controlInterpolants,n=e.__cacheIndex,i=--this._nActiveControlInterpolants,r=t[i];e.__cacheIndex=i,t[i]=e,r.__cacheIndex=n,t[n]=r}clipAction(e,t,n){let i=t||this._root,r=i.uuid,s=typeof e==="string"?rs.findByName(i,e):e,o=s!==null?s.uuid:e,a=this._actionsByClip[o],c=null;if(n===void 0)if(s!==null)n=s.blendMode;else n=2500;if(a!==void 0){let u=a.actionByRoot[r];if(u!==void 0&&u.blendMode===n)return u;if(c=a.knownActions[0],s===null)s=c._clip}if(s===null)return null;let l=new Iu(this,s,t,n);return this._bindAction(l,c),this._addInactiveAction(l,o,r),l}existingAction(e,t){let n=t||this._root,i=n.uuid,r=typeof e==="string"?rs.findByName(n,e):e,s=r?r.uuid:e,o=this._actionsByClip[s];if(o!==void 0)return o.actionByRoot[i]||null;return null}stopAllAction(){let e=this._actions,t=this._nActiveActions;for(let n=t-1;n>=0;--n)e[n].stop();return this}update(e){e*=this.timeScale;let t=this._actions,n=this._nActiveActions,i=this.time+=e,r=Math.sign(e),s=this._accuIndex^=1;for(let c=0;c!==n;++c)t[c]._update(i,e,r,s);let o=this._bindings,a=this._nActiveBindings;for(let c=0;c!==a;++c)o[c].apply(s);return this}setTime(e){this.time=0;for(let t=0;t<this._actions.length;t++)this._actions[t].time=0;return this.update(e)}getRoot(){return this._root}uncacheClip(e){let t=this._actions,n=e.uuid,i=this._actionsByClip,r=i[n];if(r!==void 0){let s=r.knownActions;for(let o=0,a=s.length;o!==a;++o){let c=s[o];this._deactivateAction(c);let l=c._cacheIndex,u=t[t.length-1];c._cacheIndex=null,c._byClipCacheIndex=null,u._cacheIndex=l,t[l]=u,t.pop(),this._removeInactiveBindingsForAction(c)}delete i[n]}}uncacheRoot(e){let t=e.uuid,n=this._actionsByClip;for(let s in n){let o=n[s].actionByRoot,a=o[t];if(a!==void 0)this._deactivateAction(a),this._removeInactiveAction(a)}let i=this._bindingsByRootAndName,r=i[t];if(r!==void 0)for(let s in r){let o=r[s];o.restoreOriginalState(),this._removeInactiveBinding(o)}}uncacheAction(e,t){let n=this.existingAction(e,t);if(n!==null)this._deactivateAction(n),this._removeInactiveAction(n)}}class lo{constructor(e=1,t=0,n=0){this.radius=e,this.phi=t,this.theta=n}set(e,t,n){return this.radius=e,this.phi=t,this.theta=n,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=We(this.phi,0.000001,Math.PI-0.000001),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,n){if(this.radius=Math.sqrt(e*e+t*t+n*n),this.radius===0)this.theta=0,this.phi=0;else this.theta=Math.atan2(e,n),this.phi=Math.acos(We(t/this.radius,-1,1));return this}clone(){return new this.constructor().copy(this)}}class Lu{static{Lu.prototype.isMatrix2=!0}constructor(e,t,n,i){if(this.elements=[1,0,0,1],e!==void 0)this.set(e,t,n,i)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let n=0;n<4;n++)this.elements[n]=e[n+t];return this}set(e,t,n,i){let r=this.elements;return r[0]=e,r[2]=t,r[1]=n,r[3]=i,this}}class Ya extends Wn{constructor(e,t=null){super();this.object=e,this.domElement=t,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(e){if(this.domElement!==null)this.disconnect();this.domElement=e}disconnect(){}dispose(){}update(){}}function Nu(e,t,n,i){let r=Mb(i);switch(n){case 1021:return e*t;case 1028:return e*t/r.components*r.byteLength;case 1029:return e*t/r.components*r.byteLength;case 1030:return e*t*2/r.components*r.byteLength;case 1031:return e*t*2/r.components*r.byteLength;case 1022:return e*t*3/r.components*r.byteLength;case 1023:return e*t*4/r.components*r.byteLength;case 1033:return e*t*4/r.components*r.byteLength;case 33776:case 33777:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*8;case 33778:case 33779:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*16;case 35841:case 35843:return Math.max(e,16)*Math.max(t,8)/4;case 35840:case 35842:return Math.max(e,8)*Math.max(t,8)/2;case 36196:case 37492:case 37488:case 37489:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*8;case 37496:case 37490:case 37491:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*16;case 37808:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*16;case 37809:return Math.floor((e+4)/5)*Math.floor((t+3)/4)*16;case 37810:return Math.floor((e+4)/5)*Math.floor((t+4)/5)*16;case 37811:return Math.floor((e+5)/6)*Math.floor((t+4)/5)*16;case 37812:return Math.floor((e+5)/6)*Math.floor((t+5)/6)*16;case 37813:return Math.floor((e+7)/8)*Math.floor((t+4)/5)*16;case 37814:return Math.floor((e+7)/8)*Math.floor((t+5)/6)*16;case 37815:return Math.floor((e+7)/8)*Math.floor((t+7)/8)*16;case 37816:return Math.floor((e+9)/10)*Math.floor((t+4)/5)*16;case 37817:return Math.floor((e+9)/10)*Math.floor((t+5)/6)*16;case 37818:return Math.floor((e+9)/10)*Math.floor((t+7)/8)*16;case 37819:return Math.floor((e+9)/10)*Math.floor((t+9)/10)*16;case 37820:return Math.floor((e+11)/12)*Math.floor((t+9)/10)*16;case 37821:return Math.floor((e+11)/12)*Math.floor((t+11)/12)*16;case 36492:case 36494:case 36495:return Math.ceil(e/4)*Math.ceil(t/4)*16;case 36283:case 36284:return Math.ceil(e/4)*Math.ceil(t/4)*8;case 36285:case 36286:return Math.ceil(e/4)*Math.ceil(t/4)*16}throw Error(`Unable to determine texture byte length for ${n} format.`)}function Mb(e){switch(e){case 1009:case 1010:return{byteLength:1,components:1};case 1012:case 1011:case 1016:return{byteLength:2,components:1};case 1017:case 1018:return{byteLength:2,components:4};case 1014:case 1013:case 1015:return{byteLength:4,components:1};case 35902:case 35899:return{byteLength:4,components:3}}throw Error(`THREE.TextureUtils: Unknown texture type ${e}.`)}if(typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:"186"}}));if(typeof window<"u")if(window.__THREE__)Ie("WARNING: Multiple instances of Three.js being imported.");else window.__THREE__="186";function Gp(){let e=null,t=!1,n=null,i=null;function r(s,o){i=e.requestAnimationFrame(r),n(s,o)}return{start:function(){if(t===!0)return;if(n===null)return;if(e===null)return;i=e.requestAnimationFrame(r),t=!0},stop:function(){if(e!==null)e.cancelAnimationFrame(i);t=!1},setAnimationLoop:function(s){n=s},setContext:function(s){e=s}}}function wb(e){let t=new WeakMap;function n(a,c){let{array:l,usage:u}=a,f=l.byteLength,h=e.createBuffer();e.bindBuffer(c,h),e.bufferData(c,l,u),a.onUploadCallback();let d;if(l instanceof Float32Array)d=e.FLOAT;else if(typeof Float16Array<"u"&&l instanceof Float16Array)d=e.HALF_FLOAT;else if(l instanceof Uint16Array)if(a.isFloat16BufferAttribute)d=e.HALF_FLOAT;else d=e.UNSIGNED_SHORT;else if(l instanceof Int16Array)d=e.SHORT;else if(l instanceof Uint32Array)d=e.UNSIGNED_INT;else if(l instanceof Int32Array)d=e.INT;else if(l instanceof Int8Array)d=e.BYTE;else if(l instanceof Uint8Array)d=e.UNSIGNED_BYTE;else if(l instanceof Uint8ClampedArray)d=e.UNSIGNED_BYTE;else throw Error("THREE.WebGLAttributes: Unsupported buffer data format: "+l);return{buffer:h,type:d,bytesPerElement:l.BYTES_PER_ELEMENT,version:a.version,size:f}}function i(a,c,l){let{array:u,updateRanges:f}=c;if(e.bindBuffer(l,a),f.length===0)e.bufferSubData(l,0,u);else{f.sort((d,g)=>d.start-g.start);let h=0;for(let d=1;d<f.length;d++){let g=f[h],x=f[d];if(x.start<=g.start+g.count+1)g.count=Math.max(g.count,x.start+x.count-g.start);else++h,f[h]=x}f.length=h+1;for(let d=0,g=f.length;d<g;d++){let x=f[d];e.bufferSubData(l,x.start*u.BYTES_PER_ELEMENT,u,x.start,x.count)}c.clearUpdateRanges()}c.onUploadCallback()}function r(a){if(a.isInterleavedBufferAttribute)a=a.data;return t.get(a)}function s(a){if(a.isInterleavedBufferAttribute)a=a.data;let c=t.get(a);if(c)e.deleteBuffer(c.buffer),t.delete(a)}function o(a,c){if(a.isInterleavedBufferAttribute)a=a.data;if(a.isGLBufferAttribute){let u=t.get(a);if(!u||u.version<a.version)t.set(a,{buffer:a.buffer,type:a.type,bytesPerElement:a.elementSize,version:a.version});return}let l=t.get(a);if(l===void 0)t.set(a,n(a,c));else if(l.version<a.version){if(l.size!==a.array.byteLength)throw Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");i(l.buffer,a,c),l.version=a.version}}return{get:r,remove:s,update:o}}var Eb=`#ifdef USE_ALPHAHASH
130
130
  if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
131
- #endif`,wb=`#ifdef USE_ALPHAHASH
131
+ #endif`,Tb=`#ifdef USE_ALPHAHASH
132
132
  const float ALPHA_HASH_SCALE = 0.05;
133
133
  float hash2D( vec2 value ) {
134
134
  return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
@@ -163,20 +163,20 @@
163
163
  : cases.z;
164
164
  return clamp( threshold , 1.0e-6, 1.0 );
165
165
  }
166
- #endif`,Eb=`#ifdef USE_ALPHAMAP
166
+ #endif`,Ab=`#ifdef USE_ALPHAMAP
167
167
  diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
168
- #endif`,Tb=`#ifdef USE_ALPHAMAP
168
+ #endif`,Rb=`#ifdef USE_ALPHAMAP
169
169
  uniform sampler2D alphaMap;
170
- #endif`,Ab=`#ifdef USE_ALPHATEST
170
+ #endif`,Cb=`#ifdef USE_ALPHATEST
171
171
  #ifdef ALPHA_TO_COVERAGE
172
172
  diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );
173
173
  if ( diffuseColor.a == 0.0 ) discard;
174
174
  #else
175
175
  if ( diffuseColor.a < alphaTest ) discard;
176
176
  #endif
177
- #endif`,Rb=`#ifdef USE_ALPHATEST
177
+ #endif`,Pb=`#ifdef USE_ALPHATEST
178
178
  uniform float alphaTest;
179
- #endif`,Cb=`#ifdef USE_AOMAP
179
+ #endif`,Ib=`#ifdef USE_AOMAP
180
180
  float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
181
181
  reflectedLight.indirectDiffuse *= ambientOcclusion;
182
182
  #if defined( USE_CLEARCOAT )
@@ -189,10 +189,10 @@
189
189
  float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
190
190
  reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
191
191
  #endif
192
- #endif`,Pb=`#ifdef USE_AOMAP
192
+ #endif`,Lb=`#ifdef USE_AOMAP
193
193
  uniform sampler2D aoMap;
194
194
  uniform float aoMapIntensity;
195
- #endif`,Ib=`#ifdef USE_BATCHING
195
+ #endif`,Nb=`#ifdef USE_BATCHING
196
196
  #if ! defined( GL_ANGLE_multi_draw )
197
197
  #define gl_DrawID _gl_DrawID
198
198
  uniform int _gl_DrawID;
@@ -226,15 +226,15 @@
226
226
  int y = j / size;
227
227
  return texelFetch( batchingColorTexture, ivec2( x, y ), 0 );
228
228
  }
229
- #endif`,Lb=`#ifdef USE_BATCHING
229
+ #endif`,Db=`#ifdef USE_BATCHING
230
230
  mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
231
- #endif`,Nb=`vec3 transformed = vec3( position );
231
+ #endif`,Ob=`vec3 transformed = vec3( position );
232
232
  #ifdef USE_ALPHAHASH
233
233
  vPosition = vec3( position );
234
- #endif`,Db=`vec3 objectNormal = vec3( normal );
234
+ #endif`,Ub=`vec3 objectNormal = vec3( normal );
235
235
  #ifdef USE_TANGENT
236
236
  vec3 objectTangent = vec3( tangent.xyz );
237
- #endif`,Ob=`float G_BlinnPhong_Implicit( ) {
237
+ #endif`,Fb=`float G_BlinnPhong_Implicit( ) {
238
238
  return 0.25;
239
239
  }
240
240
  float D_BlinnPhong( const in float shininess, const in float dotNH ) {
@@ -248,7 +248,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
248
248
  float G = G_BlinnPhong_Implicit( );
249
249
  float D = D_BlinnPhong( shininess, dotNH );
250
250
  return F * ( G * D );
251
- } // validated`,Ub=`#ifdef USE_IRIDESCENCE
251
+ } // validated`,zb=`#ifdef USE_IRIDESCENCE
252
252
  const mat3 XYZ_TO_REC709 = mat3(
253
253
  3.2404542, -0.9692660, 0.0556434,
254
254
  -1.5371385, 1.8760108, -0.2040259,
@@ -311,7 +311,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
311
311
  }
312
312
  return max( I, vec3( 0.0 ) );
313
313
  }
314
- #endif`,Fb=`#ifdef USE_BUMPMAP
314
+ #endif`,kb=`#ifdef USE_BUMPMAP
315
315
  uniform sampler2D bumpMap;
316
316
  uniform float bumpScale;
317
317
  vec2 dHdxy_fwd() {
@@ -332,7 +332,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
332
332
  vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
333
333
  return normalize( abs( fDet ) * surf_norm - vGrad );
334
334
  }
335
- #endif`,zb=`#if NUM_CLIPPING_PLANES > 0
335
+ #endif`,Bb=`#if NUM_CLIPPING_PLANES > 0
336
336
  vec4 plane;
337
337
  #ifdef ALPHA_TO_COVERAGE
338
338
  float distanceToPlane, distanceGradient;
@@ -378,20 +378,20 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
378
378
  if ( clipped ) discard;
379
379
  #endif
380
380
  #endif
381
- #endif`,kb=`#if NUM_CLIPPING_PLANES > 0
381
+ #endif`,Gb=`#if NUM_CLIPPING_PLANES > 0
382
382
  varying vec3 vClipPosition;
383
383
  uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
384
- #endif`,Bb=`#if NUM_CLIPPING_PLANES > 0
384
+ #endif`,Hb=`#if NUM_CLIPPING_PLANES > 0
385
385
  varying vec3 vClipPosition;
386
- #endif`,Gb=`#if NUM_CLIPPING_PLANES > 0
386
+ #endif`,Vb=`#if NUM_CLIPPING_PLANES > 0
387
387
  vClipPosition = - mvPosition.xyz;
388
- #endif`,Hb=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
388
+ #endif`,$b=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
389
389
  diffuseColor *= vColor;
390
- #endif`,Vb=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
390
+ #endif`,Wb=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
391
391
  varying vec4 vColor;
392
- #endif`,$b=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
392
+ #endif`,Zb=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
393
393
  varying vec4 vColor;
394
- #endif`,Wb=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
394
+ #endif`,Xb=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
395
395
  vColor = vec4( 1.0 );
396
396
  #endif
397
397
  #ifdef USE_COLOR_ALPHA
@@ -404,7 +404,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
404
404
  #endif
405
405
  #ifdef USE_BATCHING_COLOR
406
406
  vColor *= getBatchingColor( getIndirectIndex( gl_DrawID ) );
407
- #endif`,Zb=`#define PI 3.141592653589793
407
+ #endif`,qb=`#define PI 3.141592653589793
408
408
  #define PI2 6.283185307179586
409
409
  #define PI_HALF 1.5707963267948966
410
410
  #define RECIPROCAL_PI 0.3183098861837907
@@ -475,7 +475,7 @@ vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
475
475
  float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
476
476
  float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
477
477
  return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
478
- } // validated`,Xb=`#ifdef ENVMAP_TYPE_CUBE_UV
478
+ } // validated`,jb=`#ifdef ENVMAP_TYPE_CUBE_UV
479
479
  #define cubeUV_minMipLevel 4.0
480
480
  #define cubeUV_minTileSize 16.0
481
481
  float getFace( vec3 direction ) {
@@ -568,7 +568,7 @@ float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
568
568
  return vec4( mix( color0, color1, mipF ), 1.0 );
569
569
  }
570
570
  }
571
- #endif`,qb=`vec3 transformedNormal = objectNormal;
571
+ #endif`,Yb=`vec3 transformedNormal = objectNormal;
572
572
  #ifdef USE_TANGENT
573
573
  vec3 transformedTangent = objectTangent;
574
574
  #endif
@@ -594,21 +594,21 @@ transformedNormal = normalMatrix * transformedNormal;
594
594
  #endif
595
595
  #ifdef USE_TANGENT
596
596
  transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
597
- #endif`,jb=`#ifdef USE_DISPLACEMENTMAP
597
+ #endif`,Kb=`#ifdef USE_DISPLACEMENTMAP
598
598
  uniform sampler2D displacementMap;
599
599
  uniform float displacementScale;
600
600
  uniform float displacementBias;
601
- #endif`,Yb=`#ifdef USE_DISPLACEMENTMAP
601
+ #endif`,Jb=`#ifdef USE_DISPLACEMENTMAP
602
602
  transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
603
- #endif`,Kb=`#ifdef USE_EMISSIVEMAP
603
+ #endif`,Qb=`#ifdef USE_EMISSIVEMAP
604
604
  vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
605
605
  #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
606
606
  emissiveColor = sRGBTransferEOTF( emissiveColor );
607
607
  #endif
608
608
  totalEmissiveRadiance *= emissiveColor.rgb;
609
- #endif`,Jb=`#ifdef USE_EMISSIVEMAP
609
+ #endif`,eS=`#ifdef USE_EMISSIVEMAP
610
610
  uniform sampler2D emissiveMap;
611
- #endif`,Qb="gl_FragColor = linearToOutputTexel( gl_FragColor );",eS=`vec4 LinearTransferOETF( in vec4 value ) {
611
+ #endif`,tS="gl_FragColor = linearToOutputTexel( gl_FragColor );",nS=`vec4 LinearTransferOETF( in vec4 value ) {
612
612
  return value;
613
613
  }
614
614
  vec4 sRGBTransferEOTF( in vec4 value ) {
@@ -616,7 +616,7 @@ vec4 sRGBTransferEOTF( in vec4 value ) {
616
616
  }
617
617
  vec4 sRGBTransferOETF( in vec4 value ) {
618
618
  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 );
619
- }`,tS=`#ifdef USE_ENVMAP
619
+ }`,iS=`#ifdef USE_ENVMAP
620
620
  #ifdef ENV_WORLDPOS
621
621
  vec3 cameraToFrag;
622
622
  if ( isOrthographic ) {
@@ -643,7 +643,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
643
643
  outgoingLight += envColor.xyz * specularStrength * reflectivity;
644
644
  #endif
645
645
  #endif
646
- #endif`,nS=`#ifdef USE_ENVMAP
646
+ #endif`,rS=`#ifdef USE_ENVMAP
647
647
  uniform float envMapIntensity;
648
648
  uniform mat3 envMapRotation;
649
649
  #ifdef ENVMAP_TYPE_CUBE
@@ -651,7 +651,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
651
651
  #else
652
652
  uniform sampler2D envMap;
653
653
  #endif
654
- #endif`,iS=`#ifdef USE_ENVMAP
654
+ #endif`,sS=`#ifdef USE_ENVMAP
655
655
  uniform float reflectivity;
656
656
  #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
657
657
  #define ENV_WORLDPOS
@@ -662,7 +662,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
662
662
  #else
663
663
  varying vec3 vReflect;
664
664
  #endif
665
- #endif`,rS=`#ifdef USE_ENVMAP
665
+ #endif`,oS=`#ifdef USE_ENVMAP
666
666
  #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
667
667
  #define ENV_WORLDPOS
668
668
  #endif
@@ -673,7 +673,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
673
673
  varying vec3 vReflect;
674
674
  uniform float refractionRatio;
675
675
  #endif
676
- #endif`,sS=`#ifdef USE_ENVMAP
676
+ #endif`,aS=`#ifdef USE_ENVMAP
677
677
  #ifdef ENV_WORLDPOS
678
678
  vWorldPosition = worldPosition.xyz;
679
679
  #else
@@ -690,18 +690,18 @@ vec4 sRGBTransferOETF( in vec4 value ) {
690
690
  vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
691
691
  #endif
692
692
  #endif
693
- #endif`,oS=`#ifdef USE_FOG
693
+ #endif`,cS=`#ifdef USE_FOG
694
694
  vFogDepth = - mvPosition.z;
695
- #endif`,aS=`#ifdef USE_FOG
695
+ #endif`,lS=`#ifdef USE_FOG
696
696
  varying float vFogDepth;
697
- #endif`,cS=`#ifdef USE_FOG
697
+ #endif`,uS=`#ifdef USE_FOG
698
698
  #ifdef FOG_EXP2
699
699
  float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
700
700
  #else
701
701
  float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
702
702
  #endif
703
703
  gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
704
- #endif`,lS=`#ifdef USE_FOG
704
+ #endif`,hS=`#ifdef USE_FOG
705
705
  uniform vec3 fogColor;
706
706
  varying float vFogDepth;
707
707
  #ifdef FOG_EXP2
@@ -710,7 +710,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
710
710
  uniform float fogNear;
711
711
  uniform float fogFar;
712
712
  #endif
713
- #endif`,uS=`#ifdef USE_GRADIENTMAP
713
+ #endif`,fS=`#ifdef USE_GRADIENTMAP
714
714
  uniform sampler2D gradientMap;
715
715
  #endif
716
716
  vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
@@ -722,12 +722,12 @@ vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
722
722
  vec2 fw = fwidth( coord ) * 0.5;
723
723
  return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
724
724
  #endif
725
- }`,hS=`#ifdef USE_LIGHTMAP
725
+ }`,dS=`#ifdef USE_LIGHTMAP
726
726
  uniform sampler2D lightMap;
727
727
  uniform float lightMapIntensity;
728
- #endif`,fS=`LambertMaterial material;
728
+ #endif`,pS=`LambertMaterial material;
729
729
  material.diffuseColor = diffuseColor.rgb;
730
- material.specularStrength = specularStrength;`,dS=`varying vec3 vViewPosition;
730
+ material.specularStrength = specularStrength;`,mS=`varying vec3 vViewPosition;
731
731
  struct LambertMaterial {
732
732
  vec3 diffuseColor;
733
733
  float specularStrength;
@@ -741,7 +741,7 @@ void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometr
741
741
  reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
742
742
  }
743
743
  #define RE_Direct RE_Direct_Lambert
744
- #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,pS=`uniform bool receiveShadow;
744
+ #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,gS=`uniform bool receiveShadow;
745
745
  uniform vec3 ambientLightColor;
746
746
  #if defined( USE_LIGHT_PROBES )
747
747
  uniform vec3 lightProbe[ 9 ];
@@ -870,7 +870,7 @@ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosi
870
870
  return irradiance;
871
871
  }
872
872
  #endif
873
- #include <lightprobes_pars_fragment>`,mS=`#ifdef USE_ENVMAP
873
+ #include <lightprobes_pars_fragment>`,_S=`#ifdef USE_ENVMAP
874
874
  vec3 getIBLIrradiance( const in vec3 normal ) {
875
875
  #ifdef ENVMAP_TYPE_CUBE_UV
876
876
  vec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix );
@@ -927,8 +927,8 @@ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosi
927
927
  }
928
928
  #endif
929
929
  #endif
930
- #endif`,gS=`ToonMaterial material;
931
- material.diffuseColor = diffuseColor.rgb;`,_S=`varying vec3 vViewPosition;
930
+ #endif`,xS=`ToonMaterial material;
931
+ material.diffuseColor = diffuseColor.rgb;`,yS=`varying vec3 vViewPosition;
932
932
  struct ToonMaterial {
933
933
  vec3 diffuseColor;
934
934
  };
@@ -940,11 +940,11 @@ void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPo
940
940
  reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
941
941
  }
942
942
  #define RE_Direct RE_Direct_Toon
943
- #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,xS=`BlinnPhongMaterial material;
943
+ #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,vS=`BlinnPhongMaterial material;
944
944
  material.diffuseColor = diffuseColor.rgb;
945
945
  material.specularColor = specular;
946
946
  material.specularShininess = shininess;
947
- material.specularStrength = specularStrength;`,yS=`varying vec3 vViewPosition;
947
+ material.specularStrength = specularStrength;`,bS=`varying vec3 vViewPosition;
948
948
  struct BlinnPhongMaterial {
949
949
  vec3 diffuseColor;
950
950
  vec3 specularColor;
@@ -961,7 +961,7 @@ void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geom
961
961
  reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
962
962
  }
963
963
  #define RE_Direct RE_Direct_BlinnPhong
964
- #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,vS=`PhysicalMaterial material;
964
+ #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,SS=`PhysicalMaterial material;
965
965
  material.diffuseColor = diffuseColor.rgb;
966
966
  material.diffuseContribution = diffuseColor.rgb * ( 1.0 - metalnessFactor );
967
967
  material.metalness = metalnessFactor;
@@ -1054,7 +1054,7 @@ material.roughness = min( material.roughness, 1.0 );
1054
1054
  material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
1055
1055
  material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
1056
1056
  material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
1057
- #endif`,bS=`uniform sampler2D dfgLUT;
1057
+ #endif`,MS=`uniform sampler2D dfgLUT;
1058
1058
  struct PhysicalMaterial {
1059
1059
  vec3 diffuseColor;
1060
1060
  vec3 diffuseContribution;
@@ -1421,7 +1421,7 @@ void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradia
1421
1421
  #define RE_IndirectSpecular RE_IndirectSpecular_Physical
1422
1422
  float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
1423
1423
  return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
1424
- }`,SS=`
1424
+ }`,wS=`
1425
1425
  vec3 geometryPosition = - vViewPosition;
1426
1426
  vec3 geometryNormal = normal;
1427
1427
  vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
@@ -1569,7 +1569,7 @@ IncidentLight directLight;
1569
1569
  #if defined( RE_IndirectSpecular )
1570
1570
  vec3 radiance = vec3( 0.0 );
1571
1571
  vec3 clearcoatRadiance = vec3( 0.0 );
1572
- #endif`,MS=`#if defined( RE_IndirectDiffuse )
1572
+ #endif`,ES=`#if defined( RE_IndirectDiffuse )
1573
1573
  #ifdef USE_LIGHTMAP
1574
1574
  vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
1575
1575
  vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
@@ -1599,7 +1599,7 @@ IncidentLight directLight;
1599
1599
  #ifdef USE_CLEARCOAT
1600
1600
  clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
1601
1601
  #endif
1602
- #endif`,wS=`#if defined( RE_IndirectDiffuse )
1602
+ #endif`,TS=`#if defined( RE_IndirectDiffuse )
1603
1603
  #if defined( LAMBERT ) || defined( PHONG )
1604
1604
  irradiance += iblIrradiance;
1605
1605
  #endif
@@ -1607,7 +1607,7 @@ IncidentLight directLight;
1607
1607
  #endif
1608
1608
  #if defined( RE_IndirectSpecular )
1609
1609
  RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
1610
- #endif`,ES=`#ifdef USE_LIGHT_PROBES_GRID
1610
+ #endif`,AS=`#ifdef USE_LIGHT_PROBES_GRID
1611
1611
  uniform highp sampler3D probesSH;
1612
1612
  uniform vec3 probesMin;
1613
1613
  uniform vec3 probesMax;
@@ -1652,27 +1652,27 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
1652
1652
  result += c8 * 0.429043 * ( x * x - y * y );
1653
1653
  return max( result, vec3( 0.0 ) );
1654
1654
  }
1655
- #endif`,TS=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
1655
+ #endif`,RS=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
1656
1656
  gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
1657
- #endif`,AS=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
1657
+ #endif`,CS=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
1658
1658
  uniform float logDepthBufFC;
1659
1659
  varying float vFragDepth;
1660
1660
  varying float vIsPerspective;
1661
- #endif`,RS=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
1661
+ #endif`,PS=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
1662
1662
  varying float vFragDepth;
1663
1663
  varying float vIsPerspective;
1664
- #endif`,CS=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
1664
+ #endif`,IS=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
1665
1665
  vFragDepth = 1.0 + gl_Position.w;
1666
1666
  vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
1667
- #endif`,PS=`#ifdef USE_MAP
1667
+ #endif`,LS=`#ifdef USE_MAP
1668
1668
  vec4 sampledDiffuseColor = texture2D( map, vMapUv );
1669
1669
  #ifdef DECODE_VIDEO_TEXTURE
1670
1670
  sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
1671
1671
  #endif
1672
1672
  diffuseColor *= sampledDiffuseColor;
1673
- #endif`,IS=`#ifdef USE_MAP
1673
+ #endif`,NS=`#ifdef USE_MAP
1674
1674
  uniform sampler2D map;
1675
- #endif`,LS=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
1675
+ #endif`,DS=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
1676
1676
  #if defined( USE_POINTS_UV )
1677
1677
  vec2 uv = vUv;
1678
1678
  #else
@@ -1684,7 +1684,7 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
1684
1684
  #endif
1685
1685
  #ifdef USE_ALPHAMAP
1686
1686
  diffuseColor.a *= texture2D( alphaMap, uv ).g;
1687
- #endif`,NS=`#if defined( USE_POINTS_UV )
1687
+ #endif`,OS=`#if defined( USE_POINTS_UV )
1688
1688
  varying vec2 vUv;
1689
1689
  #else
1690
1690
  #if defined( USE_MAP ) || defined( USE_ALPHAMAP )
@@ -1696,19 +1696,19 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
1696
1696
  #endif
1697
1697
  #ifdef USE_ALPHAMAP
1698
1698
  uniform sampler2D alphaMap;
1699
- #endif`,DS=`float metalnessFactor = metalness;
1699
+ #endif`,US=`float metalnessFactor = metalness;
1700
1700
  #ifdef USE_METALNESSMAP
1701
1701
  vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
1702
1702
  metalnessFactor *= texelMetalness.b;
1703
- #endif`,OS=`#ifdef USE_METALNESSMAP
1703
+ #endif`,FS=`#ifdef USE_METALNESSMAP
1704
1704
  uniform sampler2D metalnessMap;
1705
- #endif`,US=`#ifdef USE_INSTANCING_MORPH
1705
+ #endif`,zS=`#ifdef USE_INSTANCING_MORPH
1706
1706
  float morphTargetInfluences[ MORPHTARGETS_COUNT ];
1707
1707
  float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;
1708
1708
  for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1709
1709
  morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;
1710
1710
  }
1711
- #endif`,FS=`#if defined( USE_MORPHCOLORS )
1711
+ #endif`,kS=`#if defined( USE_MORPHCOLORS )
1712
1712
  vColor *= morphTargetBaseInfluence;
1713
1713
  for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1714
1714
  #if defined( USE_COLOR_ALPHA )
@@ -1717,12 +1717,12 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
1717
1717
  if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
1718
1718
  #endif
1719
1719
  }
1720
- #endif`,zS=`#ifdef USE_MORPHNORMALS
1720
+ #endif`,BS=`#ifdef USE_MORPHNORMALS
1721
1721
  objectNormal *= morphTargetBaseInfluence;
1722
1722
  for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1723
1723
  if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
1724
1724
  }
1725
- #endif`,kS=`#ifdef USE_MORPHTARGETS
1725
+ #endif`,GS=`#ifdef USE_MORPHTARGETS
1726
1726
  #ifndef USE_INSTANCING_MORPH
1727
1727
  uniform float morphTargetBaseInfluence;
1728
1728
  uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
@@ -1736,12 +1736,12 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
1736
1736
  ivec3 morphUV = ivec3( x, y, morphTargetIndex );
1737
1737
  return texelFetch( morphTargetsTexture, morphUV, 0 );
1738
1738
  }
1739
- #endif`,BS=`#ifdef USE_MORPHTARGETS
1739
+ #endif`,HS=`#ifdef USE_MORPHTARGETS
1740
1740
  transformed *= morphTargetBaseInfluence;
1741
1741
  for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1742
1742
  if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
1743
1743
  }
1744
- #endif`,GS=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
1744
+ #endif`,VS=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
1745
1745
  #ifdef FLAT_SHADED
1746
1746
  vec3 fdx = dFdx( vViewPosition );
1747
1747
  vec3 fdy = dFdy( vViewPosition );
@@ -1782,7 +1782,7 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
1782
1782
  tbn2[1] *= faceDirection;
1783
1783
  #endif
1784
1784
  #endif
1785
- vec3 nonPerturbedNormal = normal;`,HS=`#ifdef USE_NORMALMAP_OBJECTSPACE
1785
+ vec3 nonPerturbedNormal = normal;`,$S=`#ifdef USE_NORMALMAP_OBJECTSPACE
1786
1786
  normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
1787
1787
  #ifdef FLIP_SIDED
1788
1788
  normal = - normal;
@@ -1800,19 +1800,19 @@ vec3 nonPerturbedNormal = normal;`,HS=`#ifdef USE_NORMALMAP_OBJECTSPACE
1800
1800
  normal = normalize( tbn * mapN );
1801
1801
  #elif defined( USE_BUMPMAP )
1802
1802
  normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
1803
- #endif`,VS=`#ifndef FLAT_SHADED
1803
+ #endif`,WS=`#ifndef FLAT_SHADED
1804
1804
  varying vec3 vNormal;
1805
1805
  #ifdef USE_TANGENT
1806
1806
  varying vec3 vTangent;
1807
1807
  varying vec3 vBitangent;
1808
1808
  #endif
1809
- #endif`,$S=`#ifndef FLAT_SHADED
1809
+ #endif`,ZS=`#ifndef FLAT_SHADED
1810
1810
  varying vec3 vNormal;
1811
1811
  #ifdef USE_TANGENT
1812
1812
  varying vec3 vTangent;
1813
1813
  varying vec3 vBitangent;
1814
1814
  #endif
1815
- #endif`,WS=`#ifndef FLAT_SHADED
1815
+ #endif`,XS=`#ifndef FLAT_SHADED
1816
1816
  vNormal = normalize( transformedNormal );
1817
1817
  #ifdef USE_TANGENT
1818
1818
  vTangent = normalize( transformedTangent );
@@ -1821,7 +1821,7 @@ vec3 nonPerturbedNormal = normal;`,HS=`#ifdef USE_NORMALMAP_OBJECTSPACE
1821
1821
  vBitangent = - vBitangent;
1822
1822
  #endif
1823
1823
  #endif
1824
- #endif`,ZS=`#ifdef USE_NORMALMAP
1824
+ #endif`,qS=`#ifdef USE_NORMALMAP
1825
1825
  uniform sampler2D normalMap;
1826
1826
  uniform vec2 normalScale;
1827
1827
  #endif
@@ -1843,13 +1843,13 @@ vec3 nonPerturbedNormal = normal;`,HS=`#ifdef USE_NORMALMAP_OBJECTSPACE
1843
1843
  float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
1844
1844
  return mat3( T * scale, B * scale, N );
1845
1845
  }
1846
- #endif`,XS=`#ifdef USE_CLEARCOAT
1846
+ #endif`,jS=`#ifdef USE_CLEARCOAT
1847
1847
  vec3 clearcoatNormal = nonPerturbedNormal;
1848
- #endif`,qS=`#ifdef USE_CLEARCOAT_NORMALMAP
1848
+ #endif`,YS=`#ifdef USE_CLEARCOAT_NORMALMAP
1849
1849
  vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
1850
1850
  clearcoatMapN.xy *= clearcoatNormalScale;
1851
1851
  clearcoatNormal = normalize( tbn2 * clearcoatMapN );
1852
- #endif`,jS=`#ifdef USE_CLEARCOATMAP
1852
+ #endif`,KS=`#ifdef USE_CLEARCOATMAP
1853
1853
  uniform sampler2D clearcoatMap;
1854
1854
  #endif
1855
1855
  #ifdef USE_CLEARCOAT_NORMALMAP
@@ -1858,18 +1858,18 @@ vec3 nonPerturbedNormal = normal;`,HS=`#ifdef USE_NORMALMAP_OBJECTSPACE
1858
1858
  #endif
1859
1859
  #ifdef USE_CLEARCOAT_ROUGHNESSMAP
1860
1860
  uniform sampler2D clearcoatRoughnessMap;
1861
- #endif`,YS=`#ifdef USE_IRIDESCENCEMAP
1861
+ #endif`,JS=`#ifdef USE_IRIDESCENCEMAP
1862
1862
  uniform sampler2D iridescenceMap;
1863
1863
  #endif
1864
1864
  #ifdef USE_IRIDESCENCE_THICKNESSMAP
1865
1865
  uniform sampler2D iridescenceThicknessMap;
1866
- #endif`,KS=`#ifdef OPAQUE
1866
+ #endif`,QS=`#ifdef OPAQUE
1867
1867
  diffuseColor.a = 1.0;
1868
1868
  #endif
1869
1869
  #ifdef USE_TRANSMISSION
1870
1870
  diffuseColor.a *= material.transmissionAlpha;
1871
1871
  #endif
1872
- gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,JS=`vec3 packNormalToRGB( const in vec3 normal ) {
1872
+ gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,eM=`vec3 packNormalToRGB( const in vec3 normal ) {
1873
1873
  return normalize( normal ) * 0.5 + 0.5;
1874
1874
  }
1875
1875
  vec3 unpackRGBToNormal( const in vec3 rgb ) {
@@ -1948,9 +1948,9 @@ float perspectiveDepthToViewZ( const in float depth, const in float near, const
1948
1948
  #else
1949
1949
  return ( near * far ) / ( ( far - near ) * depth - far );
1950
1950
  #endif
1951
- }`,QS=`#ifdef PREMULTIPLIED_ALPHA
1951
+ }`,tM=`#ifdef PREMULTIPLIED_ALPHA
1952
1952
  gl_FragColor.rgb *= gl_FragColor.a;
1953
- #endif`,eM=`vec4 mvPosition = vec4( transformed, 1.0 );
1953
+ #endif`,nM=`vec4 mvPosition = vec4( transformed, 1.0 );
1954
1954
  #ifdef USE_BATCHING
1955
1955
  mvPosition = batchingMatrix * mvPosition;
1956
1956
  #endif
@@ -1958,22 +1958,22 @@ float perspectiveDepthToViewZ( const in float depth, const in float near, const
1958
1958
  mvPosition = instanceMatrix * mvPosition;
1959
1959
  #endif
1960
1960
  mvPosition = modelViewMatrix * mvPosition;
1961
- gl_Position = projectionMatrix * mvPosition;`,tM=`#ifdef DITHERING
1961
+ gl_Position = projectionMatrix * mvPosition;`,iM=`#ifdef DITHERING
1962
1962
  gl_FragColor.rgb = dithering( gl_FragColor.rgb );
1963
- #endif`,nM=`#ifdef DITHERING
1963
+ #endif`,rM=`#ifdef DITHERING
1964
1964
  vec3 dithering( vec3 color ) {
1965
1965
  float grid_position = rand( gl_FragCoord.xy );
1966
1966
  vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
1967
1967
  dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
1968
1968
  return color + dither_shift_RGB;
1969
1969
  }
1970
- #endif`,iM=`float roughnessFactor = roughness;
1970
+ #endif`,sM=`float roughnessFactor = roughness;
1971
1971
  #ifdef USE_ROUGHNESSMAP
1972
1972
  vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
1973
1973
  roughnessFactor *= texelRoughness.g;
1974
- #endif`,rM=`#ifdef USE_ROUGHNESSMAP
1974
+ #endif`,oM=`#ifdef USE_ROUGHNESSMAP
1975
1975
  uniform sampler2D roughnessMap;
1976
- #endif`,sM=`#if NUM_SPOT_LIGHT_COORDS > 0
1976
+ #endif`,aM=`#if NUM_SPOT_LIGHT_COORDS > 0
1977
1977
  varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
1978
1978
  #endif
1979
1979
  #if NUM_SPOT_LIGHT_MAPS > 0
@@ -2224,7 +2224,7 @@ gl_Position = projectionMatrix * mvPosition;`,tM=`#ifdef DITHERING
2224
2224
  }
2225
2225
  #endif
2226
2226
  #endif
2227
- #endif`,oM=`#if NUM_SPOT_LIGHT_COORDS > 0
2227
+ #endif`,cM=`#if NUM_SPOT_LIGHT_COORDS > 0
2228
2228
  uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
2229
2229
  varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
2230
2230
  #endif
@@ -2269,7 +2269,7 @@ gl_Position = projectionMatrix * mvPosition;`,tM=`#ifdef DITHERING
2269
2269
  };
2270
2270
  uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
2271
2271
  #endif
2272
- #endif`,aM=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_SUN_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
2272
+ #endif`,lM=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_SUN_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
2273
2273
  #ifdef HAS_NORMAL
2274
2274
  vec3 shadowWorldNormal = transformNormalByInverseViewMatrix( transformedNormal, viewMatrix );
2275
2275
  #else
@@ -2309,7 +2309,7 @@ gl_Position = projectionMatrix * mvPosition;`,tM=`#ifdef DITHERING
2309
2309
  vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
2310
2310
  }
2311
2311
  #pragma unroll_loop_end
2312
- #endif`,cM=`float getShadowMask() {
2312
+ #endif`,uM=`float getShadowMask() {
2313
2313
  float shadow = 1.0;
2314
2314
  #ifdef USE_SHADOWMAP
2315
2315
  #if NUM_SUN_LIGHT_SHADOWS > 0
@@ -2350,12 +2350,12 @@ gl_Position = projectionMatrix * mvPosition;`,tM=`#ifdef DITHERING
2350
2350
  #endif
2351
2351
  #endif
2352
2352
  return shadow;
2353
- }`,lM=`#ifdef USE_SKINNING
2353
+ }`,hM=`#ifdef USE_SKINNING
2354
2354
  mat4 boneMatX = getBoneMatrix( skinIndex.x );
2355
2355
  mat4 boneMatY = getBoneMatrix( skinIndex.y );
2356
2356
  mat4 boneMatZ = getBoneMatrix( skinIndex.z );
2357
2357
  mat4 boneMatW = getBoneMatrix( skinIndex.w );
2358
- #endif`,uM=`#ifdef USE_SKINNING
2358
+ #endif`,fM=`#ifdef USE_SKINNING
2359
2359
  uniform mat4 bindMatrix;
2360
2360
  uniform mat4 bindMatrixInverse;
2361
2361
  uniform highp sampler2D boneTexture;
@@ -2370,7 +2370,7 @@ gl_Position = projectionMatrix * mvPosition;`,tM=`#ifdef DITHERING
2370
2370
  vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
2371
2371
  return mat4( v1, v2, v3, v4 );
2372
2372
  }
2373
- #endif`,hM=`#ifdef USE_SKINNING
2373
+ #endif`,dM=`#ifdef USE_SKINNING
2374
2374
  vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
2375
2375
  vec4 skinned = vec4( 0.0 );
2376
2376
  skinned += boneMatX * skinVertex * skinWeight.x;
@@ -2378,7 +2378,7 @@ gl_Position = projectionMatrix * mvPosition;`,tM=`#ifdef DITHERING
2378
2378
  skinned += boneMatZ * skinVertex * skinWeight.z;
2379
2379
  skinned += boneMatW * skinVertex * skinWeight.w;
2380
2380
  transformed = ( bindMatrixInverse * skinned ).xyz;
2381
- #endif`,fM=`#ifdef USE_SKINNING
2381
+ #endif`,pM=`#ifdef USE_SKINNING
2382
2382
  mat4 skinMatrix = mat4( 0.0 );
2383
2383
  skinMatrix += skinWeight.x * boneMatX;
2384
2384
  skinMatrix += skinWeight.y * boneMatY;
@@ -2389,17 +2389,17 @@ gl_Position = projectionMatrix * mvPosition;`,tM=`#ifdef DITHERING
2389
2389
  #ifdef USE_TANGENT
2390
2390
  objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
2391
2391
  #endif
2392
- #endif`,dM=`float specularStrength;
2392
+ #endif`,mM=`float specularStrength;
2393
2393
  #ifdef USE_SPECULARMAP
2394
2394
  vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
2395
2395
  specularStrength = texelSpecular.r;
2396
2396
  #else
2397
2397
  specularStrength = 1.0;
2398
- #endif`,pM=`#ifdef USE_SPECULARMAP
2398
+ #endif`,gM=`#ifdef USE_SPECULARMAP
2399
2399
  uniform sampler2D specularMap;
2400
- #endif`,mM=`#if defined( TONE_MAPPING )
2400
+ #endif`,_M=`#if defined( TONE_MAPPING )
2401
2401
  gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
2402
- #endif`,gM=`#ifndef saturate
2402
+ #endif`,xM=`#ifndef saturate
2403
2403
  #define saturate( a ) clamp( a, 0.0, 1.0 )
2404
2404
  #endif
2405
2405
  uniform float toneMappingExposure;
@@ -2496,7 +2496,7 @@ vec3 NeutralToneMapping( vec3 color ) {
2496
2496
  float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );
2497
2497
  return mix( color, vec3( newPeak ), g );
2498
2498
  }
2499
- vec3 CustomToneMapping( vec3 color ) { return color; }`,_M=`#ifdef USE_TRANSMISSION
2499
+ vec3 CustomToneMapping( vec3 color ) { return color; }`,yM=`#ifdef USE_TRANSMISSION
2500
2500
  material.transmission = transmission;
2501
2501
  material.transmissionAlpha = 1.0;
2502
2502
  material.thickness = thickness;
@@ -2517,7 +2517,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,_M=`#ifdef USE_TRANSMISS
2517
2517
  material.attenuationColor, material.attenuationDistance );
2518
2518
  material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
2519
2519
  totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
2520
- #endif`,xM=`#ifdef USE_TRANSMISSION
2520
+ #endif`,vM=`#ifdef USE_TRANSMISSION
2521
2521
  uniform float transmission;
2522
2522
  uniform float thickness;
2523
2523
  uniform float attenuationDistance;
@@ -2643,7 +2643,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,_M=`#ifdef USE_TRANSMISS
2643
2643
  float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
2644
2644
  return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
2645
2645
  }
2646
- #endif`,yM=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2646
+ #endif`,bM=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2647
2647
  varying vec2 vUv;
2648
2648
  #endif
2649
2649
  #ifdef USE_MAP
@@ -2713,7 +2713,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,_M=`#ifdef USE_TRANSMISS
2713
2713
  #ifdef USE_THICKNESSMAP
2714
2714
  uniform mat3 thicknessMapTransform;
2715
2715
  varying vec2 vThicknessMapUv;
2716
- #endif`,vM=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2716
+ #endif`,SM=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2717
2717
  varying vec2 vUv;
2718
2718
  #endif
2719
2719
  #ifdef USE_MAP
@@ -2807,7 +2807,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,_M=`#ifdef USE_TRANSMISS
2807
2807
  #ifdef USE_THICKNESSMAP
2808
2808
  uniform mat3 thicknessMapTransform;
2809
2809
  varying vec2 vThicknessMapUv;
2810
- #endif`,bM=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2810
+ #endif`,MM=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2811
2811
  vUv = vec3( uv, 1 ).xy;
2812
2812
  #endif
2813
2813
  #ifdef USE_MAP
@@ -2878,7 +2878,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,_M=`#ifdef USE_TRANSMISS
2878
2878
  #endif
2879
2879
  #ifdef USE_THICKNESSMAP
2880
2880
  vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
2881
- #endif`;var SM=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
2881
+ #endif`;var wM=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
2882
2882
  vec4 worldPosition = vec4( transformed, 1.0 );
2883
2883
  #ifdef USE_BATCHING
2884
2884
  worldPosition = batchingMatrix * worldPosition;
@@ -2887,12 +2887,12 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,_M=`#ifdef USE_TRANSMISS
2887
2887
  worldPosition = instanceMatrix * worldPosition;
2888
2888
  #endif
2889
2889
  worldPosition = modelMatrix * worldPosition;
2890
- #endif`,MM=`varying vec2 vUv;
2890
+ #endif`,EM=`varying vec2 vUv;
2891
2891
  uniform mat3 uvTransform;
2892
2892
  void main() {
2893
2893
  vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
2894
2894
  gl_Position = vec4( position.xy, 1.0, 1.0 );
2895
- }`,wM=`uniform sampler2D t2D;
2895
+ }`,TM=`uniform sampler2D t2D;
2896
2896
  uniform float backgroundIntensity;
2897
2897
  varying vec2 vUv;
2898
2898
  void main() {
@@ -2904,14 +2904,14 @@ void main() {
2904
2904
  gl_FragColor = texColor;
2905
2905
  #include <tonemapping_fragment>
2906
2906
  #include <colorspace_fragment>
2907
- }`,EM=`varying vec3 vWorldDirection;
2907
+ }`,AM=`varying vec3 vWorldDirection;
2908
2908
  #include <common>
2909
2909
  void main() {
2910
2910
  vWorldDirection = transformDirection( position, modelMatrix );
2911
2911
  #include <begin_vertex>
2912
2912
  #include <project_vertex>
2913
2913
  gl_Position.z = gl_Position.w;
2914
- }`,TM=`#ifdef ENVMAP_TYPE_CUBE
2914
+ }`,RM=`#ifdef ENVMAP_TYPE_CUBE
2915
2915
  uniform samplerCube envMap;
2916
2916
  #elif defined( ENVMAP_TYPE_CUBE_UV )
2917
2917
  uniform sampler2D envMap;
@@ -2933,14 +2933,14 @@ void main() {
2933
2933
  gl_FragColor = texColor;
2934
2934
  #include <tonemapping_fragment>
2935
2935
  #include <colorspace_fragment>
2936
- }`,AM=`varying vec3 vWorldDirection;
2936
+ }`,CM=`varying vec3 vWorldDirection;
2937
2937
  #include <common>
2938
2938
  void main() {
2939
2939
  vWorldDirection = transformDirection( position, modelMatrix );
2940
2940
  #include <begin_vertex>
2941
2941
  #include <project_vertex>
2942
2942
  gl_Position.z = gl_Position.w;
2943
- }`,RM=`uniform samplerCube tCube;
2943
+ }`,PM=`uniform samplerCube tCube;
2944
2944
  uniform float tFlip;
2945
2945
  uniform float opacity;
2946
2946
  varying vec3 vWorldDirection;
@@ -2950,7 +2950,7 @@ void main() {
2950
2950
  gl_FragColor.a *= opacity;
2951
2951
  #include <tonemapping_fragment>
2952
2952
  #include <colorspace_fragment>
2953
- }`,CM=`#include <common>
2953
+ }`,IM=`#include <common>
2954
2954
  #include <batching_pars_vertex>
2955
2955
  #include <uv_pars_vertex>
2956
2956
  #include <displacementmap_pars_vertex>
@@ -2977,7 +2977,7 @@ void main() {
2977
2977
  #include <logdepthbuf_vertex>
2978
2978
  #include <clipping_planes_vertex>
2979
2979
  vHighPrecisionZW = gl_Position.zw;
2980
- }`,PM=`#if DEPTH_PACKING == 3200
2980
+ }`,LM=`#if DEPTH_PACKING == 3200
2981
2981
  uniform float opacity;
2982
2982
  #endif
2983
2983
  #include <common>
@@ -3015,7 +3015,7 @@ void main() {
3015
3015
  #elif DEPTH_PACKING == 3203
3016
3016
  gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );
3017
3017
  #endif
3018
- }`,IM=`#define DISTANCE
3018
+ }`,NM=`#define DISTANCE
3019
3019
  varying vec3 vWorldPosition;
3020
3020
  #include <common>
3021
3021
  #include <batching_pars_vertex>
@@ -3042,7 +3042,7 @@ void main() {
3042
3042
  #include <worldpos_vertex>
3043
3043
  #include <clipping_planes_vertex>
3044
3044
  vWorldPosition = worldPosition.xyz;
3045
- }`,LM=`#define DISTANCE
3045
+ }`,DM=`#define DISTANCE
3046
3046
  uniform vec3 referencePosition;
3047
3047
  uniform float nearDistance;
3048
3048
  uniform float farDistance;
@@ -3065,13 +3065,13 @@ void main() {
3065
3065
  dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
3066
3066
  dist = saturate( dist );
3067
3067
  gl_FragColor = vec4( dist, 0.0, 0.0, 1.0 );
3068
- }`,NM=`varying vec3 vWorldDirection;
3068
+ }`,OM=`varying vec3 vWorldDirection;
3069
3069
  #include <common>
3070
3070
  void main() {
3071
3071
  vWorldDirection = transformDirection( position, modelMatrix );
3072
3072
  #include <begin_vertex>
3073
3073
  #include <project_vertex>
3074
- }`,DM=`uniform sampler2D tEquirect;
3074
+ }`,UM=`uniform sampler2D tEquirect;
3075
3075
  varying vec3 vWorldDirection;
3076
3076
  #include <common>
3077
3077
  void main() {
@@ -3080,7 +3080,7 @@ void main() {
3080
3080
  gl_FragColor = texture2D( tEquirect, sampleUV );
3081
3081
  #include <tonemapping_fragment>
3082
3082
  #include <colorspace_fragment>
3083
- }`,OM=`uniform float scale;
3083
+ }`,FM=`uniform float scale;
3084
3084
  attribute float lineDistance;
3085
3085
  varying float vLineDistance;
3086
3086
  #include <common>
@@ -3102,7 +3102,7 @@ void main() {
3102
3102
  #include <logdepthbuf_vertex>
3103
3103
  #include <clipping_planes_vertex>
3104
3104
  #include <fog_vertex>
3105
- }`,UM=`uniform vec3 diffuse;
3105
+ }`,zM=`uniform vec3 diffuse;
3106
3106
  uniform float opacity;
3107
3107
  uniform float dashSize;
3108
3108
  uniform float totalSize;
@@ -3130,7 +3130,7 @@ void main() {
3130
3130
  #include <colorspace_fragment>
3131
3131
  #include <fog_fragment>
3132
3132
  #include <premultiplied_alpha_fragment>
3133
- }`,FM=`#include <common>
3133
+ }`,kM=`#include <common>
3134
3134
  #include <batching_pars_vertex>
3135
3135
  #include <uv_pars_vertex>
3136
3136
  #include <envmap_pars_vertex>
@@ -3162,7 +3162,7 @@ void main() {
3162
3162
  #include <worldpos_vertex>
3163
3163
  #include <envmap_vertex>
3164
3164
  #include <fog_vertex>
3165
- }`,zM=`uniform vec3 diffuse;
3165
+ }`,BM=`uniform vec3 diffuse;
3166
3166
  uniform float opacity;
3167
3167
  #ifndef FLAT_SHADED
3168
3168
  varying vec3 vNormal;
@@ -3210,7 +3210,7 @@ void main() {
3210
3210
  #include <fog_fragment>
3211
3211
  #include <premultiplied_alpha_fragment>
3212
3212
  #include <dithering_fragment>
3213
- }`,kM=`#define LAMBERT
3213
+ }`,GM=`#define LAMBERT
3214
3214
  varying vec3 vViewPosition;
3215
3215
  #include <common>
3216
3216
  #include <batching_pars_vertex>
@@ -3249,7 +3249,7 @@ void main() {
3249
3249
  #include <envmap_vertex>
3250
3250
  #include <shadowmap_vertex>
3251
3251
  #include <fog_vertex>
3252
- }`,BM=`#define LAMBERT
3252
+ }`,HM=`#define LAMBERT
3253
3253
  uniform vec3 diffuse;
3254
3254
  uniform vec3 emissive;
3255
3255
  uniform float opacity;
@@ -3307,7 +3307,7 @@ void main() {
3307
3307
  #include <fog_fragment>
3308
3308
  #include <premultiplied_alpha_fragment>
3309
3309
  #include <dithering_fragment>
3310
- }`,GM=`#define MATCAP
3310
+ }`,VM=`#define MATCAP
3311
3311
  varying vec3 vViewPosition;
3312
3312
  #include <common>
3313
3313
  #include <batching_pars_vertex>
@@ -3341,7 +3341,7 @@ void main() {
3341
3341
  #include <clipping_planes_vertex>
3342
3342
  #include <fog_vertex>
3343
3343
  vViewPosition = - mvPosition.xyz;
3344
- }`,HM=`#define MATCAP
3344
+ }`,$M=`#define MATCAP
3345
3345
  uniform vec3 diffuse;
3346
3346
  uniform float opacity;
3347
3347
  uniform sampler2D matcap;
@@ -3387,7 +3387,7 @@ void main() {
3387
3387
  #include <fog_fragment>
3388
3388
  #include <premultiplied_alpha_fragment>
3389
3389
  #include <dithering_fragment>
3390
- }`,VM=`#define NORMAL
3390
+ }`,WM=`#define NORMAL
3391
3391
  #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
3392
3392
  varying vec3 vViewPosition;
3393
3393
  #endif
@@ -3420,7 +3420,7 @@ void main() {
3420
3420
  #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
3421
3421
  vViewPosition = - mvPosition.xyz;
3422
3422
  #endif
3423
- }`,$M=`#define NORMAL
3423
+ }`,ZM=`#define NORMAL
3424
3424
  uniform float opacity;
3425
3425
  #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
3426
3426
  varying vec3 vViewPosition;
@@ -3441,7 +3441,7 @@ void main() {
3441
3441
  #ifdef OPAQUE
3442
3442
  gl_FragColor.a = 1.0;
3443
3443
  #endif
3444
- }`,WM=`#define PHONG
3444
+ }`,XM=`#define PHONG
3445
3445
  varying vec3 vViewPosition;
3446
3446
  #include <common>
3447
3447
  #include <batching_pars_vertex>
@@ -3480,7 +3480,7 @@ void main() {
3480
3480
  #include <envmap_vertex>
3481
3481
  #include <shadowmap_vertex>
3482
3482
  #include <fog_vertex>
3483
- }`,ZM=`#define PHONG
3483
+ }`,qM=`#define PHONG
3484
3484
  uniform vec3 diffuse;
3485
3485
  uniform vec3 emissive;
3486
3486
  uniform vec3 specular;
@@ -3540,7 +3540,7 @@ void main() {
3540
3540
  #include <fog_fragment>
3541
3541
  #include <premultiplied_alpha_fragment>
3542
3542
  #include <dithering_fragment>
3543
- }`,XM=`#define STANDARD
3543
+ }`,jM=`#define STANDARD
3544
3544
  varying vec3 vViewPosition;
3545
3545
  #ifdef USE_TRANSMISSION
3546
3546
  varying vec3 vWorldPosition;
@@ -3583,7 +3583,7 @@ void main() {
3583
3583
  #ifdef USE_TRANSMISSION
3584
3584
  vWorldPosition = worldPosition.xyz;
3585
3585
  #endif
3586
- }`,qM=`#define STANDARD
3586
+ }`,YM=`#define STANDARD
3587
3587
  #ifdef PHYSICAL
3588
3588
  #define IOR
3589
3589
  #define USE_SPECULAR
@@ -3711,7 +3711,7 @@ void main() {
3711
3711
  #include <fog_fragment>
3712
3712
  #include <premultiplied_alpha_fragment>
3713
3713
  #include <dithering_fragment>
3714
- }`,jM=`#define TOON
3714
+ }`,KM=`#define TOON
3715
3715
  varying vec3 vViewPosition;
3716
3716
  #include <common>
3717
3717
  #include <batching_pars_vertex>
@@ -3748,7 +3748,7 @@ void main() {
3748
3748
  #include <worldpos_vertex>
3749
3749
  #include <shadowmap_vertex>
3750
3750
  #include <fog_vertex>
3751
- }`,YM=`#define TOON
3751
+ }`,JM=`#define TOON
3752
3752
  uniform vec3 diffuse;
3753
3753
  uniform vec3 emissive;
3754
3754
  uniform float opacity;
@@ -3800,7 +3800,7 @@ void main() {
3800
3800
  #include <fog_fragment>
3801
3801
  #include <premultiplied_alpha_fragment>
3802
3802
  #include <dithering_fragment>
3803
- }`,KM=`uniform float size;
3803
+ }`,QM=`uniform float size;
3804
3804
  uniform float scale;
3805
3805
  #include <common>
3806
3806
  #include <color_pars_vertex>
@@ -3831,7 +3831,7 @@ void main() {
3831
3831
  #include <clipping_planes_vertex>
3832
3832
  #include <worldpos_vertex>
3833
3833
  #include <fog_vertex>
3834
- }`,JM=`uniform vec3 diffuse;
3834
+ }`,ew=`uniform vec3 diffuse;
3835
3835
  uniform float opacity;
3836
3836
  #include <common>
3837
3837
  #include <color_pars_fragment>
@@ -3856,7 +3856,7 @@ void main() {
3856
3856
  #include <colorspace_fragment>
3857
3857
  #include <fog_fragment>
3858
3858
  #include <premultiplied_alpha_fragment>
3859
- }`,QM=`#include <common>
3859
+ }`,tw=`#include <common>
3860
3860
  #include <batching_pars_vertex>
3861
3861
  #include <fog_pars_vertex>
3862
3862
  #include <morphtarget_pars_vertex>
@@ -3879,7 +3879,7 @@ void main() {
3879
3879
  #include <worldpos_vertex>
3880
3880
  #include <shadowmap_vertex>
3881
3881
  #include <fog_vertex>
3882
- }`,ew=`uniform vec3 color;
3882
+ }`,nw=`uniform vec3 color;
3883
3883
  uniform float opacity;
3884
3884
  #include <common>
3885
3885
  #include <fog_pars_fragment>
@@ -3895,7 +3895,7 @@ void main() {
3895
3895
  #include <colorspace_fragment>
3896
3896
  #include <fog_fragment>
3897
3897
  #include <premultiplied_alpha_fragment>
3898
- }`,tw=`uniform float rotation;
3898
+ }`,iw=`uniform float rotation;
3899
3899
  uniform vec2 center;
3900
3900
  #include <common>
3901
3901
  #include <uv_pars_vertex>
@@ -3919,7 +3919,7 @@ void main() {
3919
3919
  #include <logdepthbuf_vertex>
3920
3920
  #include <clipping_planes_vertex>
3921
3921
  #include <fog_vertex>
3922
- }`,nw=`uniform vec3 diffuse;
3922
+ }`,rw=`uniform vec3 diffuse;
3923
3923
  uniform float opacity;
3924
3924
  #include <common>
3925
3925
  #include <uv_pars_fragment>
@@ -3944,7 +3944,7 @@ void main() {
3944
3944
  #include <tonemapping_fragment>
3945
3945
  #include <colorspace_fragment>
3946
3946
  #include <fog_fragment>
3947
- }`,Ve={alphahash_fragment:Mb,alphahash_pars_fragment:wb,alphamap_fragment:Eb,alphamap_pars_fragment:Tb,alphatest_fragment:Ab,alphatest_pars_fragment:Rb,aomap_fragment:Cb,aomap_pars_fragment:Pb,batching_pars_vertex:Ib,batching_vertex:Lb,begin_vertex:Nb,beginnormal_vertex:Db,bsdfs:Ob,iridescence_fragment:Ub,bumpmap_pars_fragment:Fb,clipping_planes_fragment:zb,clipping_planes_pars_fragment:kb,clipping_planes_pars_vertex:Bb,clipping_planes_vertex:Gb,color_fragment:Hb,color_pars_fragment:Vb,color_pars_vertex:$b,color_vertex:Wb,common:Zb,cube_uv_reflection_fragment:Xb,defaultnormal_vertex:qb,displacementmap_pars_vertex:jb,displacementmap_vertex:Yb,emissivemap_fragment:Kb,emissivemap_pars_fragment:Jb,colorspace_fragment:Qb,colorspace_pars_fragment:eS,envmap_fragment:tS,envmap_common_pars_fragment:nS,envmap_pars_fragment:iS,envmap_pars_vertex:rS,envmap_physical_pars_fragment:mS,envmap_vertex:sS,fog_vertex:oS,fog_pars_vertex:aS,fog_fragment:cS,fog_pars_fragment:lS,gradientmap_pars_fragment:uS,lightmap_pars_fragment:hS,lights_lambert_fragment:fS,lights_lambert_pars_fragment:dS,lights_pars_begin:pS,lights_toon_fragment:gS,lights_toon_pars_fragment:_S,lights_phong_fragment:xS,lights_phong_pars_fragment:yS,lights_physical_fragment:vS,lights_physical_pars_fragment:bS,lights_fragment_begin:SS,lights_fragment_maps:MS,lights_fragment_end:wS,lightprobes_pars_fragment:ES,logdepthbuf_fragment:TS,logdepthbuf_pars_fragment:AS,logdepthbuf_pars_vertex:RS,logdepthbuf_vertex:CS,map_fragment:PS,map_pars_fragment:IS,map_particle_fragment:LS,map_particle_pars_fragment:NS,metalnessmap_fragment:DS,metalnessmap_pars_fragment:OS,morphinstance_vertex:US,morphcolor_vertex:FS,morphnormal_vertex:zS,morphtarget_pars_vertex:kS,morphtarget_vertex:BS,normal_fragment_begin:GS,normal_fragment_maps:HS,normal_pars_fragment:VS,normal_pars_vertex:$S,normal_vertex:WS,normalmap_pars_fragment:ZS,clearcoat_normal_fragment_begin:XS,clearcoat_normal_fragment_maps:qS,clearcoat_pars_fragment:jS,iridescence_pars_fragment:YS,opaque_fragment:KS,packing:JS,premultiplied_alpha_fragment:QS,project_vertex:eM,dithering_fragment:tM,dithering_pars_fragment:nM,roughnessmap_fragment:iM,roughnessmap_pars_fragment:rM,shadowmap_pars_fragment:sM,shadowmap_pars_vertex:oM,shadowmap_vertex:aM,shadowmask_pars_fragment:cM,skinbase_vertex:lM,skinning_pars_vertex:uM,skinning_vertex:hM,skinnormal_vertex:fM,specularmap_fragment:dM,specularmap_pars_fragment:pM,tonemapping_fragment:mM,tonemapping_pars_fragment:gM,transmission_fragment:_M,transmission_pars_fragment:xM,uv_pars_fragment:yM,uv_pars_vertex:vM,uv_vertex:bM,worldpos_vertex:SM,background_vert:MM,background_frag:wM,backgroundCube_vert:EM,backgroundCube_frag:TM,cube_vert:AM,cube_frag:RM,depth_vert:CM,depth_frag:PM,distance_vert:IM,distance_frag:LM,equirect_vert:NM,equirect_frag:DM,linedashed_vert:OM,linedashed_frag:UM,meshbasic_vert:FM,meshbasic_frag:zM,meshlambert_vert:kM,meshlambert_frag:BM,meshmatcap_vert:GM,meshmatcap_frag:HM,meshnormal_vert:VM,meshnormal_frag:$M,meshphong_vert:WM,meshphong_frag:ZM,meshphysical_vert:XM,meshphysical_frag:qM,meshtoon_vert:jM,meshtoon_frag:YM,points_vert:KM,points_frag:JM,shadow_vert:QM,shadow_frag:ew,sprite_vert:tw,sprite_frag:nw},de={common:{diffuse:{value:new Ue(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new ke},alphaMap:{value:null},alphaMapTransform:{value:new ke},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new ke}},envmap:{envMap:{value:null},envMapRotation:{value:new ke},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:0.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new ke}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new ke}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new ke},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new ke},normalScale:{value:new Ne(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new ke},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new ke}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new ke}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new ke}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:0.00025},fogNear:{value:1},fogFar:{value:2000},fogColor:{value:new Ue(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},sunLights:{value:[],properties:{direction:{},color:{}}},sunLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},sunShadowMatrix:{value:[]},sunShadowCascade:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null},probesSH:{value:null},probesMin:{value:new D},probesMax:{value:new D},probesResolution:{value:new D}},points:{diffuse:{value:new Ue(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new ke},alphaTest:{value:0},uvTransform:{value:new ke}},sprite:{diffuse:{value:new Ue(16777215)},opacity:{value:1},center:{value:new Ne(0.5,0.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new ke},alphaMap:{value:null},alphaMapTransform:{value:new ke},alphaTest:{value:0}}},li={basic:{uniforms:tn([de.common,de.specularmap,de.envmap,de.aomap,de.lightmap,de.fog]),vertexShader:Ve.meshbasic_vert,fragmentShader:Ve.meshbasic_frag},lambert:{uniforms:tn([de.common,de.specularmap,de.envmap,de.aomap,de.lightmap,de.emissivemap,de.bumpmap,de.normalmap,de.displacementmap,de.fog,de.lights,{emissive:{value:new Ue(0)},envMapIntensity:{value:1}}]),vertexShader:Ve.meshlambert_vert,fragmentShader:Ve.meshlambert_frag},phong:{uniforms:tn([de.common,de.specularmap,de.envmap,de.aomap,de.lightmap,de.emissivemap,de.bumpmap,de.normalmap,de.displacementmap,de.fog,de.lights,{emissive:{value:new Ue(0)},specular:{value:new Ue(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:Ve.meshphong_vert,fragmentShader:Ve.meshphong_frag},standard:{uniforms:tn([de.common,de.envmap,de.aomap,de.lightmap,de.emissivemap,de.bumpmap,de.normalmap,de.displacementmap,de.roughnessmap,de.metalnessmap,de.fog,de.lights,{emissive:{value:new Ue(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Ve.meshphysical_vert,fragmentShader:Ve.meshphysical_frag},toon:{uniforms:tn([de.common,de.aomap,de.lightmap,de.emissivemap,de.bumpmap,de.normalmap,de.displacementmap,de.gradientmap,de.fog,de.lights,{emissive:{value:new Ue(0)}}]),vertexShader:Ve.meshtoon_vert,fragmentShader:Ve.meshtoon_frag},matcap:{uniforms:tn([de.common,de.bumpmap,de.normalmap,de.displacementmap,de.fog,{matcap:{value:null}}]),vertexShader:Ve.meshmatcap_vert,fragmentShader:Ve.meshmatcap_frag},points:{uniforms:tn([de.points,de.fog]),vertexShader:Ve.points_vert,fragmentShader:Ve.points_frag},dashed:{uniforms:tn([de.common,de.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Ve.linedashed_vert,fragmentShader:Ve.linedashed_frag},depth:{uniforms:tn([de.common,de.displacementmap]),vertexShader:Ve.depth_vert,fragmentShader:Ve.depth_frag},normal:{uniforms:tn([de.common,de.bumpmap,de.normalmap,de.displacementmap,{opacity:{value:1}}]),vertexShader:Ve.meshnormal_vert,fragmentShader:Ve.meshnormal_frag},sprite:{uniforms:tn([de.sprite,de.fog]),vertexShader:Ve.sprite_vert,fragmentShader:Ve.sprite_frag},background:{uniforms:{uvTransform:{value:new ke},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Ve.background_vert,fragmentShader:Ve.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new ke}},vertexShader:Ve.backgroundCube_vert,fragmentShader:Ve.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Ve.cube_vert,fragmentShader:Ve.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Ve.equirect_vert,fragmentShader:Ve.equirect_frag},distance:{uniforms:tn([de.common,de.displacementmap,{referencePosition:{value:new D},nearDistance:{value:1},farDistance:{value:1000}}]),vertexShader:Ve.distance_vert,fragmentShader:Ve.distance_frag},shadow:{uniforms:tn([de.lights,de.fog,{color:{value:new Ue(0)},opacity:{value:1}}]),vertexShader:Ve.shadow_vert,fragmentShader:Ve.shadow_frag}};li.physical={uniforms:tn([li.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new ke},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new ke},clearcoatNormalScale:{value:new Ne(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new ke},dispersion:{value:0},retroreflectivity:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new ke},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new ke},sheen:{value:0},sheenColor:{value:new Ue(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new ke},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new ke},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new ke},transmissionSamplerSize:{value:new Ne},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new ke},attenuationDistance:{value:0},attenuationColor:{value:new Ue(0)},specularColor:{value:new Ue(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new ke},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new ke},anisotropyVector:{value:new Ne},anisotropyMap:{value:null},anisotropyMapTransform:{value:new ke}}]),vertexShader:Ve.meshphysical_vert,fragmentShader:Ve.meshphysical_frag};var Ya={r:0,b:0,g:0},iw=new Ge,Gp=new ke;Gp.set(-1,0,0,0,1,0,0,0,1);function rw(e,t,n,i,r,s){let o=new Ue(0),a=r===!0?0:1,c,l,u=null,f=0,h=null;function d(E){let R=E.isScene===!0?E.background:null;if(R&&R.isTexture){let v=E.backgroundBlurriness>0;R=t.get(R,v)}return R}function g(E){let R=!1,v=d(E);if(v===null)p(o,a);else if(v&&v.isColor)p(v,1),R=!0;let M=e.xr.getEnvironmentBlendMode();if(M==="additive")n.buffers.color.setClear(0,0,0,1,s);else if(M==="alpha-blend")n.buffers.color.setClear(0,0,0,0,s);if(e.autoClear||R)n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil)}function x(E,R){let v=d(R);if(v&&(v.isCubeTexture||v.mapping===Hs)){if(l===void 0)l=new xt(new Ji(1,1,1),new Pn({name:"BackgroundCubeMaterial",uniforms:Tr(li.backgroundCube.uniforms),vertexShader:li.backgroundCube.vertexShader,fragmentShader:li.backgroundCube.fragmentShader,side:Qt,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(M,T,A){this.matrixWorld.copyPosition(A.matrixWorld)},Object.defineProperty(l.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(l);if(l.material.uniforms.envMap.value=v,l.material.uniforms.backgroundBlurriness.value=R.backgroundBlurriness,l.material.uniforms.backgroundIntensity.value=R.backgroundIntensity,l.material.uniforms.backgroundRotation.value.setFromMatrix4(iw.makeRotationFromEuler(R.backgroundRotation)).transpose(),v.isCubeTexture&&v.isRenderTargetTexture===!1)l.material.uniforms.backgroundRotation.value.premultiply(Gp);if(l.material.toneMapped=$e.getTransfer(v.colorSpace)!==pt,u!==v||f!==v.version||h!==e.toneMapping)l.material.needsUpdate=!0,u=v,f=v.version,h=e.toneMapping;l.layers.enableAll(),E.unshift(l,l.geometry,l.material,0,0,null)}else if(v&&v.isTexture){if(c===void 0)c=new xt(new to(2,2),new Pn({name:"BackgroundMaterial",uniforms:Tr(li.background.uniforms),vertexShader:li.background.vertexShader,fragmentShader:li.background.fragmentShader,side:Xi,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(c);if(c.material.uniforms.t2D.value=v,c.material.uniforms.backgroundIntensity.value=R.backgroundIntensity,c.material.toneMapped=$e.getTransfer(v.colorSpace)!==pt,v.matrixAutoUpdate===!0)v.updateMatrix();if(c.material.uniforms.uvTransform.value.copy(v.matrix),u!==v||f!==v.version||h!==e.toneMapping)c.material.needsUpdate=!0,u=v,f=v.version,h=e.toneMapping;c.layers.enableAll(),E.unshift(c,c.geometry,c.material,0,0,null)}}function p(E,R){E.getRGB(Ya,gu(e)),n.buffers.color.setClear(Ya.r,Ya.g,Ya.b,R,s)}function m(){if(l!==void 0)l.geometry.dispose(),l.material.dispose(),l=void 0;if(c!==void 0)c.geometry.dispose(),c.material.dispose(),c=void 0}return{getClearColor:function(){return o},setClearColor:function(E,R=1){o.set(E),a=R,p(o,a)},getClearAlpha:function(){return a},setClearAlpha:function(E){a=E,p(o,a)},render:g,addToRenderList:x,dispose:m}}function sw(e,t){let n=e.getParameter(e.MAX_VERTEX_ATTRIBS),i={},r=h(null),s=r,o=!1;function a(C,U,ee,P,V){let j=!1,z=f(C,P,ee,U);if(s!==z)s=z,l(s.object);if(j=d(C,P,ee,V),j)g(C,P,ee,V);if(V!==null)t.update(V,e.ELEMENT_ARRAY_BUFFER);if(j||o){if(o=!1,v(C,U,ee,P),V!==null)e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,t.get(V).buffer)}}function c(){return e.createVertexArray()}function l(C){return e.bindVertexArray(C)}function u(C){return e.deleteVertexArray(C)}function f(C,U,ee,P){let V=P.wireframe===!0,j=i[U.id];if(j===void 0)j={},i[U.id]=j;let z=C.isInstancedMesh===!0?C.id:0,H=j[z];if(H===void 0)H={},j[z]=H;let F=H[ee.id];if(F===void 0)F={},H[ee.id]=F;let q=F[V];if(q===void 0)q=h(c()),F[V]=q;return q}function h(C){let U=[],ee=[],P=[];for(let V=0;V<n;V++)U[V]=0,ee[V]=0,P[V]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:U,enabledAttributes:ee,attributeDivisors:P,object:C,attributes:{},index:null}}function d(C,U,ee,P){let V=s.attributes,j=U.attributes,z=0,H=ee.getAttributes();for(let F in H)if(H[F].location>=0){let K=V[F],xe=j[F];if(xe===void 0){if(F==="instanceMatrix"&&C.instanceMatrix)xe=C.instanceMatrix;if(F==="instanceColor"&&C.instanceColor)xe=C.instanceColor}if(K===void 0)return!0;if(K.attribute!==xe)return!0;if(xe&&K.data!==xe.data)return!0;z++}if(s.attributesNum!==z)return!0;if(s.index!==P)return!0;return!1}function g(C,U,ee,P){let V={},j=U.attributes,z=0,H=ee.getAttributes();for(let F in H)if(H[F].location>=0){let K=j[F];if(K===void 0){if(F==="instanceMatrix"&&C.instanceMatrix)K=C.instanceMatrix;if(F==="instanceColor"&&C.instanceColor)K=C.instanceColor}let xe={};if(xe.attribute=K,K&&K.data)xe.data=K.data;V[F]=xe,z++}s.attributes=V,s.attributesNum=z,s.index=P}function x(){let C=s.newAttributes;for(let U=0,ee=C.length;U<ee;U++)C[U]=0}function p(C){m(C,0)}function m(C,U){let ee=s.newAttributes,P=s.enabledAttributes,V=s.attributeDivisors;if(ee[C]=1,P[C]===0)e.enableVertexAttribArray(C),P[C]=1;if(V[C]!==U)e.vertexAttribDivisor(C,U),V[C]=U}function E(){let C=s.newAttributes,U=s.enabledAttributes;for(let ee=0,P=U.length;ee<P;ee++)if(U[ee]!==C[ee])e.disableVertexAttribArray(ee),U[ee]=0}function R(C,U,ee,P,V,j,z){if(z===!0)e.vertexAttribIPointer(C,U,ee,V,j);else e.vertexAttribPointer(C,U,ee,P,V,j)}function v(C,U,ee,P){x();let V=P.attributes,j=ee.getAttributes(),z=U.defaultAttributeValues;for(let H in j){let F=j[H];if(F.location>=0){let q=V[H];if(q===void 0){if(H==="instanceMatrix"&&C.instanceMatrix)q=C.instanceMatrix;if(H==="instanceColor"&&C.instanceColor)q=C.instanceColor}if(q!==void 0){let K=q.normalized,xe=q.itemSize,ce=t.get(q);if(ce===void 0)continue;let{buffer:De,type:ye,bytesPerElement:X}=ce,re=ye===e.INT||ye===e.UNSIGNED_INT||q.gpuType===Ml;if(q.isInterleavedBufferAttribute){let se=q.data,Te=se.stride,Ie=q.offset;if(se.isInstancedInterleavedBuffer){for(let _e=0;_e<F.locationSize;_e++)m(F.location+_e,se.meshPerAttribute);if(C.isInstancedMesh!==!0&&P._maxInstanceCount===void 0)P._maxInstanceCount=se.meshPerAttribute*se.count}else for(let _e=0;_e<F.locationSize;_e++)p(F.location+_e);e.bindBuffer(e.ARRAY_BUFFER,De);for(let _e=0;_e<F.locationSize;_e++)R(F.location+_e,xe/F.locationSize,ye,K,Te*X,(Ie+xe/F.locationSize*_e)*X,re)}else{if(q.isInstancedBufferAttribute){for(let se=0;se<F.locationSize;se++)m(F.location+se,q.meshPerAttribute);if(C.isInstancedMesh!==!0&&P._maxInstanceCount===void 0)P._maxInstanceCount=q.meshPerAttribute*q.count}else for(let se=0;se<F.locationSize;se++)p(F.location+se);e.bindBuffer(e.ARRAY_BUFFER,De);for(let se=0;se<F.locationSize;se++)R(F.location+se,xe/F.locationSize,ye,K,xe*X,xe/F.locationSize*se*X,re)}}else if(z!==void 0){let K=z[H];if(K!==void 0)switch(K.length){case 2:e.vertexAttrib2fv(F.location,K);break;case 3:e.vertexAttrib3fv(F.location,K);break;case 4:e.vertexAttrib4fv(F.location,K);break;default:e.vertexAttrib1fv(F.location,K)}}}}E()}function M(){S();for(let C in i){let U=i[C];for(let ee in U){let P=U[ee];for(let V in P){let j=P[V];for(let z in j)u(j[z].object),delete j[z];delete P[V]}}delete i[C]}}function T(C){if(i[C.id]===void 0)return;let U=i[C.id];for(let ee in U){let P=U[ee];for(let V in P){let j=P[V];for(let z in j)u(j[z].object),delete j[z];delete P[V]}}delete i[C.id]}function A(C){for(let U in i){let ee=i[U];for(let P in ee){let V=ee[P];if(V[C.id]===void 0)continue;let j=V[C.id];for(let z in j)u(j[z].object),delete j[z];delete V[C.id]}}}function _(C){for(let U in i){let ee=i[U],P=C.isInstancedMesh===!0?C.id:0,V=ee[P];if(V===void 0)continue;for(let j in V){let z=V[j];for(let H in z)u(z[H].object),delete z[H];delete V[j]}if(delete ee[P],Object.keys(ee).length===0)delete i[U]}}function S(){if(k(),o=!0,s===r)return;s=r,l(s.object)}function k(){r.geometry=null,r.program=null,r.wireframe=!1}return{setup:a,reset:S,resetDefaultState:k,dispose:M,releaseStatesOfGeometry:T,releaseStatesOfObject:_,releaseStatesOfProgram:A,initAttributes:x,enableAttribute:p,disableUnusedAttributes:E}}function ow(e,t,n){let i;function r(c){i=c}function s(c,l){e.drawArrays(i,c,l),n.update(l,i,1)}function o(c,l,u){if(u===0)return;e.drawArraysInstanced(i,c,l,u),n.update(l,i,u)}function a(c,l,u){if(u===0)return;t.get("WEBGL_multi_draw").multiDrawArraysWEBGL(i,c,0,l,0,u);let h=0;for(let d=0;d<u;d++)h+=l[d];n.update(h,i,1)}this.setMode=r,this.render=s,this.renderInstances=o,this.renderMultiDraw=a}function aw(e,t,n,i){let r;function s(){if(r!==void 0)return r;if(t.has("EXT_texture_filter_anisotropic")===!0){let A=t.get("EXT_texture_filter_anisotropic");r=e.getParameter(A.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r}function o(A){if(A!==oi&&i.convert(A)!==e.getParameter(e.IMPLEMENTATION_COLOR_READ_FORMAT))return!1;return!0}function a(A){let _=A===si&&(t.has("EXT_color_buffer_half_float")||t.has("EXT_color_buffer_float"));if(A!==Vn&&A!==Ai&&!_&&i.convert(A)!==e.getParameter(e.IMPLEMENTATION_COLOR_READ_TYPE))return!1;return!0}function c(A){if(A==="highp"){if(e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.HIGH_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT).precision>0)return"highp";A="mediump"}if(A==="mediump"){if(e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.MEDIUM_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.MEDIUM_FLOAT).precision>0)return"mediump"}return"lowp"}let l=n.precision!==void 0?n.precision:"highp",u=c(l);if(u!==l)Pe("WebGLRenderer:",l,"not supported, using",u,"instead."),l=u;let f=n.logarithmicDepthBuffer===!0,h=n.reversedDepthBuffer===!0&&t.has("EXT_clip_control");if(n.reversedDepthBuffer===!0&&h===!1)Pe("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.");let d=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),g=e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS),x=e.getParameter(e.MAX_TEXTURE_SIZE),p=e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE),m=e.getParameter(e.MAX_VERTEX_ATTRIBS),E=e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),R=e.getParameter(e.MAX_VARYING_VECTORS),v=e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),M=e.getParameter(e.MAX_SAMPLES),T=e.getParameter(e.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:c,textureFormatReadable:o,textureTypeReadable:a,precision:l,logarithmicDepthBuffer:f,reversedDepthBuffer:h,maxTextures:d,maxVertexTextures:g,maxTextureSize:x,maxCubemapSize:p,maxAttributes:m,maxVertexUniforms:E,maxVaryings:R,maxFragmentUniforms:v,maxSamples:M,samples:T}}function cw(e){let t=this,n=null,i=0,r=!1,s=!1,o=new An,a=new ke,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(f,h){let d=f.length!==0||h||i!==0||r;return r=h,i=f.length,d},this.beginShadows=function(){s=!0,u(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(f,h){n=u(f,h,0)},this.setState=function(f,h,d){let{clippingPlanes:g,clipIntersection:x,clipShadows:p}=f,m=e.get(f);if(!r||g===null||g.length===0||s&&!p)if(s)u(null);else l();else{let E=s?0:i,R=E*4,v=m.clippingState||null;c.value=v,v=u(g,h,R,d);for(let M=0;M!==R;++M)v[M]=n[M];m.clippingState=v,this.numIntersection=x?this.numPlanes:0,this.numPlanes+=E}};function l(){if(c.value!==n)c.value=n,c.needsUpdate=i>0;t.numPlanes=i,t.numIntersection=0}function u(f,h,d,g){let x=f!==null?f.length:0,p=null;if(x!==0){if(p=c.value,g!==!0||p===null){let m=d+x*4,E=h.matrixWorldInverse;if(a.getNormalMatrix(E),p===null||p.length<m)p=new Float32Array(m);for(let R=0,v=d;R!==x;++R,v+=4)o.copy(f[R]).applyMatrix4(E,a),o.normal.toArray(p,v),p[v+3]=o.constant}c.value=p,c.needsUpdate=!0}return t.numPlanes=x,t.numIntersection=0,p}}var ys=4,lw=6,uw=20,hw=256,oo=new Rr,yp=new Ue,Nu=null,Du=0,Ou=0,Uu=!1,fw=new D,Cr=new D;class uo{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(e,t=0,n=0.1,i=100,r={}){let{size:s=256,position:o=fw}=r;Nu=this._renderer.getRenderTarget(),Du=this._renderer.getActiveCubeFace(),Ou=this._renderer.getActiveMipmapLevel(),Uu=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(s);let a=this._allocateTargets();if(a.depthBuffer=!0,this._sceneToCubeUV(e,n,i,a,o),t>0)this._blur(a,0,0,t);return this._applyPMREM(a),this._cleanup(a),a}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){if(this._cubemapMaterial===null)this._cubemapMaterial=Sp(),this._compileMaterial(this._cubemapMaterial)}compileEquirectangularShader(){if(this._equirectMaterial===null)this._equirectMaterial=bp(),this._compileMaterial(this._equirectMaterial)}dispose(){if(this._dispose(),this._cubemapMaterial!==null)this._cubemapMaterial.dispose();if(this._equirectMaterial!==null)this._equirectMaterial.dispose();if(this._backgroundBox!==null)this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose()}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){if(this._blurMaterial!==null)this._blurMaterial.dispose();if(this._ggxMaterial!==null)this._ggxMaterial.dispose();if(this._pingPongRenderTarget!==null)this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodMeshes.length;e++)this._lodMeshes[e].geometry.dispose()}_cleanup(e){this._renderer.setRenderTarget(Nu,Du,Ou),this._renderer.xr.enabled=Uu,e.scissorTest=!1,xs(e,0,0,e.width,e.height)}_fromTexture(e,t){if(e.mapping===ss||e.mapping===yr)this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width);else this._setSize(e.image.width/4);Nu=this._renderer.getRenderTarget(),Du=this._renderer.getActiveCubeFace(),Ou=this._renderer.getActiveMipmapLevel(),Uu=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;let n=t||this._allocateTargets();return this._textureToCubeUV(e,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){let e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,n={magFilter:$t,minFilter:$t,generateMipmaps:!1,type:si,format:oi,colorSpace:gn,depthBuffer:!1},i=vp(e,t,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){if(this._pingPongRenderTarget!==null)this._dispose();this._pingPongRenderTarget=vp(e,t,n);let{_lodMax:r}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods}=dw(r)),this._blurMaterial=mw(r,e,t),this._ggxMaterial=pw(r,e,t)}return i}_compileMaterial(e){let t=new xt(new en,e);this._renderer.compile(t,oo)}_sceneToCubeUV(e,t,n,i,r){let a=new Ut(90,1,t,n),c=[1,-1,1,1,1,1],l=[1,1,1,-1,-1,-1],u=this._renderer,{autoClear:f,toneMapping:h}=u;if(u.getClearColor(yp),u.toneMapping=Gn,u.autoClear=!1,u.state.buffers.depth.getReversed())u.setRenderTarget(i),u.clearDepth(),u.setRenderTarget(null);if(this._backgroundBox===null)this._backgroundBox=new xt(new Ji,new ai({name:"PMREM.Background",side:Qt,depthWrite:!1,depthTest:!1}));let g=this._backgroundBox,x=g.material,p=!1,m=e.background;if(m){if(m.isColor)x.color.copy(m),e.background=null,p=!0}else x.color.copy(yp),p=!0;for(let E=0;E<6;E++){let R=E%3;if(R===0)a.up.set(0,c[E],0),a.position.set(r.x,r.y,r.z),a.lookAt(r.x+l[E],r.y,r.z);else if(R===1)a.up.set(0,0,c[E]),a.position.set(r.x,r.y,r.z),a.lookAt(r.x,r.y+l[E],r.z);else a.up.set(0,c[E],0),a.position.set(r.x,r.y,r.z),a.lookAt(r.x,r.y,r.z+l[E]);let v=this._cubeSize;if(xs(i,R*v,E>2?v:0,v,v),u.setRenderTarget(i),p)u.render(g,a);u.render(e,a)}u.toneMapping=h,u.autoClear=f,e.background=m}_textureToCubeUV(e,t){let n=this._renderer,i=e.mapping===ss||e.mapping===yr;if(i){if(this._cubemapMaterial===null)this._cubemapMaterial=Sp();this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1}else if(this._equirectMaterial===null)this._equirectMaterial=bp();let r=i?this._cubemapMaterial:this._equirectMaterial,s=this._lodMeshes[0];s.material=r;let o=r.uniforms;o.envMap.value=e;let a=this._cubeSize;xs(t,0,0,3*a,2*a),n.setRenderTarget(t),n.render(s,oo)}_applyPMREM(e){let t=this._renderer,n=t.autoClear;t.autoClear=!1;let i=this._lodMeshes.length;for(let r=1;r<i;r++)this._applyGGXFilter(e,r-1,r);t.autoClear=n}_applyGGXFilter(e,t,n){let i=this._renderer,r=this._pingPongRenderTarget,s=this._ggxMaterial,o=this._lodMeshes[n];o.material=s;let a=s.uniforms,c=n/(this._lodMeshes.length-1),l=t/(this._lodMeshes.length-1),u=Math.sqrt(c*c-l*l),f=c*1.25,h=u*f,{_lodMax:d}=this,g=this._sizeLods[n],x=3*g*(n>d-ys?n-d+ys:0),p=4*(this._cubeSize-g);a.envMap.value=e.texture,a.roughness.value=h,a.mipInt.value=d-t,xs(r,x,p,3*g,2*g),i.setRenderTarget(r),i.render(o,oo),a.envMap.value=r.texture,a.roughness.value=0,a.mipInt.value=d-n,xs(e,x,p,3*g,2*g),i.setRenderTarget(e),i.render(o,oo)}_blur(e,t,n,i){let r=this._pingPongRenderTarget,s=Math.min(i,Math.PI)/Math.SQRT2;this._blurPass(e,r,t,n,s),this._blurPass(r,e,n,n,s)}_blurPass(e,t,n,i,r){let s=this._renderer,o=this._blurMaterial,a=this._lodMeshes[i];a.material=o;let c=o.uniforms;c.envMap.value=e.texture,c.sigma.value=r,c.mipInt.value=this._lodMax-n;let l=this._sizeLods[i],u=3*l*(i>this._lodMax-ys?i-this._lodMax+ys:0),f=4*(this._cubeSize-l);xs(t,u,f,3*l,2*l),s.setRenderTarget(t),s.render(a,oo)}}function dw(e){let t=[],n=[],i=e,r=e-ys+1+lw;for(let s=0;s<r;s++){let o=Math.pow(2,i);t.push(o);let a=1/(o-2),c=-a,l=1+a,u=[c,c,l,c,l,l,c,c,l,l,c,l],f=6,h=6,d=3,g=new Float32Array(d*h*f),x=new Float32Array(d*h*f);for(let m=0;m<f;m++){let E=m%3*2/3-1,R=m>2?0:-1,v=[E,R,0,E+0.6666666666666666,R,0,E+0.6666666666666666,R+1,0,E,R,0,E+0.6666666666666666,R+1,0,E,R+1,0];g.set(v,d*h*m);for(let M=0;M<h;M++){let T=u[M*2]*2-1,A=u[M*2+1]*2-1;if(m===0)Cr.set(1,A,T);else if(m===1)Cr.set(-T,1,-A);else if(m===2)Cr.set(-T,A,1);else if(m===3)Cr.set(-1,A,-T);else if(m===4)Cr.set(-T,-1,A);else Cr.set(T,A,-1);Cr.toArray(x,(m*h+M)*d)}}let p=new en;if(p.setAttribute("position",new Vt(g,d)),p.setAttribute("outputDirection",new Vt(x,d)),n.push(new xt(p,null)),i>ys)i--}return{lodMeshes:n,sizeLods:t}}function vp(e,t,n){let i=new _n(e,t,n);return i.texture.mapping=Hs,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function xs(e,t,n,i,r){e.viewport.set(t,n,i,r),e.scissor.set(t,n,i,r)}function pw(e,t,n){return new Pn({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:hw,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${e}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:Ja(),fragmentShader:`
3947
+ }`,Ve={alphahash_fragment:Eb,alphahash_pars_fragment:Tb,alphamap_fragment:Ab,alphamap_pars_fragment:Rb,alphatest_fragment:Cb,alphatest_pars_fragment:Pb,aomap_fragment:Ib,aomap_pars_fragment:Lb,batching_pars_vertex:Nb,batching_vertex:Db,begin_vertex:Ob,beginnormal_vertex:Ub,bsdfs:Fb,iridescence_fragment:zb,bumpmap_pars_fragment:kb,clipping_planes_fragment:Bb,clipping_planes_pars_fragment:Gb,clipping_planes_pars_vertex:Hb,clipping_planes_vertex:Vb,color_fragment:$b,color_pars_fragment:Wb,color_pars_vertex:Zb,color_vertex:Xb,common:qb,cube_uv_reflection_fragment:jb,defaultnormal_vertex:Yb,displacementmap_pars_vertex:Kb,displacementmap_vertex:Jb,emissivemap_fragment:Qb,emissivemap_pars_fragment:eS,colorspace_fragment:tS,colorspace_pars_fragment:nS,envmap_fragment:iS,envmap_common_pars_fragment:rS,envmap_pars_fragment:sS,envmap_pars_vertex:oS,envmap_physical_pars_fragment:_S,envmap_vertex:aS,fog_vertex:cS,fog_pars_vertex:lS,fog_fragment:uS,fog_pars_fragment:hS,gradientmap_pars_fragment:fS,lightmap_pars_fragment:dS,lights_lambert_fragment:pS,lights_lambert_pars_fragment:mS,lights_pars_begin:gS,lights_toon_fragment:xS,lights_toon_pars_fragment:yS,lights_phong_fragment:vS,lights_phong_pars_fragment:bS,lights_physical_fragment:SS,lights_physical_pars_fragment:MS,lights_fragment_begin:wS,lights_fragment_maps:ES,lights_fragment_end:TS,lightprobes_pars_fragment:AS,logdepthbuf_fragment:RS,logdepthbuf_pars_fragment:CS,logdepthbuf_pars_vertex:PS,logdepthbuf_vertex:IS,map_fragment:LS,map_pars_fragment:NS,map_particle_fragment:DS,map_particle_pars_fragment:OS,metalnessmap_fragment:US,metalnessmap_pars_fragment:FS,morphinstance_vertex:zS,morphcolor_vertex:kS,morphnormal_vertex:BS,morphtarget_pars_vertex:GS,morphtarget_vertex:HS,normal_fragment_begin:VS,normal_fragment_maps:$S,normal_pars_fragment:WS,normal_pars_vertex:ZS,normal_vertex:XS,normalmap_pars_fragment:qS,clearcoat_normal_fragment_begin:jS,clearcoat_normal_fragment_maps:YS,clearcoat_pars_fragment:KS,iridescence_pars_fragment:JS,opaque_fragment:QS,packing:eM,premultiplied_alpha_fragment:tM,project_vertex:nM,dithering_fragment:iM,dithering_pars_fragment:rM,roughnessmap_fragment:sM,roughnessmap_pars_fragment:oM,shadowmap_pars_fragment:aM,shadowmap_pars_vertex:cM,shadowmap_vertex:lM,shadowmask_pars_fragment:uM,skinbase_vertex:hM,skinning_pars_vertex:fM,skinning_vertex:dM,skinnormal_vertex:pM,specularmap_fragment:mM,specularmap_pars_fragment:gM,tonemapping_fragment:_M,tonemapping_pars_fragment:xM,transmission_fragment:yM,transmission_pars_fragment:vM,uv_pars_fragment:bM,uv_pars_vertex:SM,uv_vertex:MM,worldpos_vertex:wM,background_vert:EM,background_frag:TM,backgroundCube_vert:AM,backgroundCube_frag:RM,cube_vert:CM,cube_frag:PM,depth_vert:IM,depth_frag:LM,distance_vert:NM,distance_frag:DM,equirect_vert:OM,equirect_frag:UM,linedashed_vert:FM,linedashed_frag:zM,meshbasic_vert:kM,meshbasic_frag:BM,meshlambert_vert:GM,meshlambert_frag:HM,meshmatcap_vert:VM,meshmatcap_frag:$M,meshnormal_vert:WM,meshnormal_frag:ZM,meshphong_vert:XM,meshphong_frag:qM,meshphysical_vert:jM,meshphysical_frag:YM,meshtoon_vert:KM,meshtoon_frag:JM,points_vert:QM,points_frag:ew,shadow_vert:tw,shadow_frag:nw,sprite_vert:iw,sprite_frag:rw},de={common:{diffuse:{value:new Oe(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new ze},alphaMap:{value:null},alphaMapTransform:{value:new ze},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new ze}},envmap:{envMap:{value:null},envMapRotation:{value:new ze},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:0.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new ze}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new ze}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new ze},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new ze},normalScale:{value:new Ne(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new ze},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new ze}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new ze}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new ze}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:0.00025},fogNear:{value:1},fogFar:{value:2000},fogColor:{value:new Oe(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},sunLights:{value:[],properties:{direction:{},color:{}}},sunLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},sunShadowMatrix:{value:[]},sunShadowCascade:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null},probesSH:{value:null},probesMin:{value:new O},probesMax:{value:new O},probesResolution:{value:new O}},points:{diffuse:{value:new Oe(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new ze},alphaTest:{value:0},uvTransform:{value:new ze}},sprite:{diffuse:{value:new Oe(16777215)},opacity:{value:1},center:{value:new Ne(0.5,0.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new ze},alphaMap:{value:null},alphaMapTransform:{value:new ze},alphaTest:{value:0}}},li={basic:{uniforms:tn([de.common,de.specularmap,de.envmap,de.aomap,de.lightmap,de.fog]),vertexShader:Ve.meshbasic_vert,fragmentShader:Ve.meshbasic_frag},lambert:{uniforms:tn([de.common,de.specularmap,de.envmap,de.aomap,de.lightmap,de.emissivemap,de.bumpmap,de.normalmap,de.displacementmap,de.fog,de.lights,{emissive:{value:new Oe(0)},envMapIntensity:{value:1}}]),vertexShader:Ve.meshlambert_vert,fragmentShader:Ve.meshlambert_frag},phong:{uniforms:tn([de.common,de.specularmap,de.envmap,de.aomap,de.lightmap,de.emissivemap,de.bumpmap,de.normalmap,de.displacementmap,de.fog,de.lights,{emissive:{value:new Oe(0)},specular:{value:new Oe(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:Ve.meshphong_vert,fragmentShader:Ve.meshphong_frag},standard:{uniforms:tn([de.common,de.envmap,de.aomap,de.lightmap,de.emissivemap,de.bumpmap,de.normalmap,de.displacementmap,de.roughnessmap,de.metalnessmap,de.fog,de.lights,{emissive:{value:new Oe(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Ve.meshphysical_vert,fragmentShader:Ve.meshphysical_frag},toon:{uniforms:tn([de.common,de.aomap,de.lightmap,de.emissivemap,de.bumpmap,de.normalmap,de.displacementmap,de.gradientmap,de.fog,de.lights,{emissive:{value:new Oe(0)}}]),vertexShader:Ve.meshtoon_vert,fragmentShader:Ve.meshtoon_frag},matcap:{uniforms:tn([de.common,de.bumpmap,de.normalmap,de.displacementmap,de.fog,{matcap:{value:null}}]),vertexShader:Ve.meshmatcap_vert,fragmentShader:Ve.meshmatcap_frag},points:{uniforms:tn([de.points,de.fog]),vertexShader:Ve.points_vert,fragmentShader:Ve.points_frag},dashed:{uniforms:tn([de.common,de.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Ve.linedashed_vert,fragmentShader:Ve.linedashed_frag},depth:{uniforms:tn([de.common,de.displacementmap]),vertexShader:Ve.depth_vert,fragmentShader:Ve.depth_frag},normal:{uniforms:tn([de.common,de.bumpmap,de.normalmap,de.displacementmap,{opacity:{value:1}}]),vertexShader:Ve.meshnormal_vert,fragmentShader:Ve.meshnormal_frag},sprite:{uniforms:tn([de.sprite,de.fog]),vertexShader:Ve.sprite_vert,fragmentShader:Ve.sprite_frag},background:{uniforms:{uvTransform:{value:new ze},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Ve.background_vert,fragmentShader:Ve.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new ze}},vertexShader:Ve.backgroundCube_vert,fragmentShader:Ve.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Ve.cube_vert,fragmentShader:Ve.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Ve.equirect_vert,fragmentShader:Ve.equirect_frag},distance:{uniforms:tn([de.common,de.displacementmap,{referencePosition:{value:new O},nearDistance:{value:1},farDistance:{value:1000}}]),vertexShader:Ve.distance_vert,fragmentShader:Ve.distance_frag},shadow:{uniforms:tn([de.lights,de.fog,{color:{value:new Oe(0)},opacity:{value:1}}]),vertexShader:Ve.shadow_vert,fragmentShader:Ve.shadow_frag}};li.physical={uniforms:tn([li.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new ze},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new ze},clearcoatNormalScale:{value:new Ne(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new ze},dispersion:{value:0},retroreflectivity:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new ze},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new ze},sheen:{value:0},sheenColor:{value:new Oe(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new ze},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new ze},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new ze},transmissionSamplerSize:{value:new Ne},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new ze},attenuationDistance:{value:0},attenuationColor:{value:new Oe(0)},specularColor:{value:new Oe(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new ze},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new ze},anisotropyVector:{value:new Ne},anisotropyMap:{value:null},anisotropyMapTransform:{value:new ze}}]),vertexShader:Ve.meshphysical_vert,fragmentShader:Ve.meshphysical_frag};var Ka={r:0,b:0,g:0},sw=new Ge,Hp=new ze;Hp.set(-1,0,0,0,1,0,0,0,1);function ow(e,t,n,i,r,s){let o=new Oe(0),a=r===!0?0:1,c,l,u=null,f=0,h=null;function d(E){let R=E.isScene===!0?E.background:null;if(R&&R.isTexture){let v=E.backgroundBlurriness>0;R=t.get(R,v)}return R}function g(E){let R=!1,v=d(E);if(v===null)p(o,a);else if(v&&v.isColor)p(v,1),R=!0;let M=e.xr.getEnvironmentBlendMode();if(M==="additive")n.buffers.color.setClear(0,0,0,1,s);else if(M==="alpha-blend")n.buffers.color.setClear(0,0,0,0,s);if(e.autoClear||R)n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil)}function x(E,R){let v=d(R);if(v&&(v.isCubeTexture||v.mapping===Zs)){if(l===void 0)l=new _t(new Qi(1,1,1),new In({name:"BackgroundCubeMaterial",uniforms:Ar(li.backgroundCube.uniforms),vertexShader:li.backgroundCube.vertexShader,fragmentShader:li.backgroundCube.fragmentShader,side:Qt,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(M,T,A){this.matrixWorld.copyPosition(A.matrixWorld)},Object.defineProperty(l.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(l);if(l.material.uniforms.envMap.value=v,l.material.uniforms.backgroundBlurriness.value=R.backgroundBlurriness,l.material.uniforms.backgroundIntensity.value=R.backgroundIntensity,l.material.uniforms.backgroundRotation.value.setFromMatrix4(sw.makeRotationFromEuler(R.backgroundRotation)).transpose(),v.isCubeTexture&&v.isRenderTargetTexture===!1)l.material.uniforms.backgroundRotation.value.premultiply(Hp);if(l.material.toneMapped=$e.getTransfer(v.colorSpace)!==dt,u!==v||f!==v.version||h!==e.toneMapping)l.material.needsUpdate=!0,u=v,f=v.version,h=e.toneMapping;l.layers.enableAll(),E.unshift(l,l.geometry,l.material,0,0,null)}else if(v&&v.isTexture){if(c===void 0)c=new _t(new so(2,2),new In({name:"BackgroundMaterial",uniforms:Ar(li.background.uniforms),vertexShader:li.background.vertexShader,fragmentShader:li.background.fragmentShader,side:qi,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(c);if(c.material.uniforms.t2D.value=v,c.material.uniforms.backgroundIntensity.value=R.backgroundIntensity,c.material.toneMapped=$e.getTransfer(v.colorSpace)!==dt,v.matrixAutoUpdate===!0)v.updateMatrix();if(c.material.uniforms.uvTransform.value.copy(v.matrix),u!==v||f!==v.version||h!==e.toneMapping)c.material.needsUpdate=!0,u=v,f=v.version,h=e.toneMapping;c.layers.enableAll(),E.unshift(c,c.geometry,c.material,0,0,null)}}function p(E,R){E.getRGB(Ka,_u(e)),n.buffers.color.setClear(Ka.r,Ka.g,Ka.b,R,s)}function m(){if(l!==void 0)l.geometry.dispose(),l.material.dispose(),l=void 0;if(c!==void 0)c.geometry.dispose(),c.material.dispose(),c=void 0}return{getClearColor:function(){return o},setClearColor:function(E,R=1){o.set(E),a=R,p(o,a)},getClearAlpha:function(){return a},setClearAlpha:function(E){a=E,p(o,a)},render:g,addToRenderList:x,dispose:m}}function aw(e,t){let n=e.getParameter(e.MAX_VERTEX_ATTRIBS),i={},r=h(null),s=r,o=!1;function a(P,F,ee,I,H){let q=!1,C=f(P,I,ee,F);if(s!==C)s=C,l(s.object);if(q=d(P,I,ee,H),q)g(P,I,ee,H);if(H!==null)t.update(H,e.ELEMENT_ARRAY_BUFFER);if(q||o){if(o=!1,v(P,F,ee,I),H!==null)e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,t.get(H).buffer)}}function c(){return e.createVertexArray()}function l(P){return e.bindVertexArray(P)}function u(P){return e.deleteVertexArray(P)}function f(P,F,ee,I){let H=I.wireframe===!0,q=i[F.id];if(q===void 0)q={},i[F.id]=q;let C=P.isInstancedMesh===!0?P.id:0,X=q[C];if(X===void 0)X={},q[C]=X;let k=X[ee.id];if(k===void 0)k={},X[ee.id]=k;let Y=k[H];if(Y===void 0)Y=h(c()),k[H]=Y;return Y}function h(P){let F=[],ee=[],I=[];for(let H=0;H<n;H++)F[H]=0,ee[H]=0,I[H]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:F,enabledAttributes:ee,attributeDivisors:I,object:P,attributes:{},index:null}}function d(P,F,ee,I){let H=s.attributes,q=F.attributes,C=0,X=ee.getAttributes();for(let k in X)if(X[k].location>=0){let Q=H[k],Se=q[k];if(Se===void 0){if(k==="instanceMatrix"&&P.instanceMatrix)Se=P.instanceMatrix;if(k==="instanceColor"&&P.instanceColor)Se=P.instanceColor}if(Q===void 0)return!0;if(Q.attribute!==Se)return!0;if(Se&&Q.data!==Se.data)return!0;C++}if(s.attributesNum!==C)return!0;if(s.index!==I)return!0;return!1}function g(P,F,ee,I){let H={},q=F.attributes,C=0,X=ee.getAttributes();for(let k in X)if(X[k].location>=0){let Q=q[k];if(Q===void 0){if(k==="instanceMatrix"&&P.instanceMatrix)Q=P.instanceMatrix;if(k==="instanceColor"&&P.instanceColor)Q=P.instanceColor}let Se={};if(Se.attribute=Q,Q&&Q.data)Se.data=Q.data;H[k]=Se,C++}s.attributes=H,s.attributesNum=C,s.index=I}function x(){let P=s.newAttributes;for(let F=0,ee=P.length;F<ee;F++)P[F]=0}function p(P){m(P,0)}function m(P,F){let ee=s.newAttributes,I=s.enabledAttributes,H=s.attributeDivisors;if(ee[P]=1,I[P]===0)e.enableVertexAttribArray(P),I[P]=1;if(H[P]!==F)e.vertexAttribDivisor(P,F),H[P]=F}function E(){let P=s.newAttributes,F=s.enabledAttributes;for(let ee=0,I=F.length;ee<I;ee++)if(F[ee]!==P[ee])e.disableVertexAttribArray(ee),F[ee]=0}function R(P,F,ee,I,H,q,C){if(C===!0)e.vertexAttribIPointer(P,F,ee,H,q);else e.vertexAttribPointer(P,F,ee,I,H,q)}function v(P,F,ee,I){x();let H=I.attributes,q=ee.getAttributes(),C=F.defaultAttributeValues;for(let X in q){let k=q[X];if(k.location>=0){let Y=H[X];if(Y===void 0){if(X==="instanceMatrix"&&P.instanceMatrix)Y=P.instanceMatrix;if(X==="instanceColor"&&P.instanceColor)Y=P.instanceColor}if(Y!==void 0){let Q=Y.normalized,Se=Y.itemSize,ue=t.get(Y);if(ue===void 0)continue;let{buffer:Fe,type:Me,bytesPerElement:Z}=ue,re=Me===e.INT||Me===e.UNSIGNED_INT||Y.gpuType===wl;if(Y.isInterleavedBufferAttribute){let se=Y.data,xe=se.stride,we=Y.offset;if(se.isInstancedInterleavedBuffer){for(let Ee=0;Ee<k.locationSize;Ee++)m(k.location+Ee,se.meshPerAttribute);if(P.isInstancedMesh!==!0&&I._maxInstanceCount===void 0)I._maxInstanceCount=se.meshPerAttribute*se.count}else for(let Ee=0;Ee<k.locationSize;Ee++)p(k.location+Ee);e.bindBuffer(e.ARRAY_BUFFER,Fe);for(let Ee=0;Ee<k.locationSize;Ee++)R(k.location+Ee,Se/k.locationSize,Me,Q,xe*Z,(we+Se/k.locationSize*Ee)*Z,re)}else{if(Y.isInstancedBufferAttribute){for(let se=0;se<k.locationSize;se++)m(k.location+se,Y.meshPerAttribute);if(P.isInstancedMesh!==!0&&I._maxInstanceCount===void 0)I._maxInstanceCount=Y.meshPerAttribute*Y.count}else for(let se=0;se<k.locationSize;se++)p(k.location+se);e.bindBuffer(e.ARRAY_BUFFER,Fe);for(let se=0;se<k.locationSize;se++)R(k.location+se,Se/k.locationSize,Me,Q,Se*Z,Se/k.locationSize*se*Z,re)}}else if(C!==void 0){let Q=C[X];if(Q!==void 0)switch(Q.length){case 2:e.vertexAttrib2fv(k.location,Q);break;case 3:e.vertexAttrib3fv(k.location,Q);break;case 4:e.vertexAttrib4fv(k.location,Q);break;default:e.vertexAttrib1fv(k.location,Q)}}}}E()}function M(){S();for(let P in i){let F=i[P];for(let ee in F){let I=F[ee];for(let H in I){let q=I[H];for(let C in q)u(q[C].object),delete q[C];delete I[H]}}delete i[P]}}function T(P){if(i[P.id]===void 0)return;let F=i[P.id];for(let ee in F){let I=F[ee];for(let H in I){let q=I[H];for(let C in q)u(q[C].object),delete q[C];delete I[H]}}delete i[P.id]}function A(P){for(let F in i){let ee=i[F];for(let I in ee){let H=ee[I];if(H[P.id]===void 0)continue;let q=H[P.id];for(let C in q)u(q[C].object),delete q[C];delete H[P.id]}}}function _(P){for(let F in i){let ee=i[F],I=P.isInstancedMesh===!0?P.id:0,H=ee[I];if(H===void 0)continue;for(let q in H){let C=H[q];for(let X in C)u(C[X].object),delete C[X];delete H[q]}if(delete ee[I],Object.keys(ee).length===0)delete i[F]}}function S(){if(z(),o=!0,s===r)return;s=r,l(s.object)}function z(){r.geometry=null,r.program=null,r.wireframe=!1}return{setup:a,reset:S,resetDefaultState:z,dispose:M,releaseStatesOfGeometry:T,releaseStatesOfObject:_,releaseStatesOfProgram:A,initAttributes:x,enableAttribute:p,disableUnusedAttributes:E}}function cw(e,t,n){let i;function r(c){i=c}function s(c,l){e.drawArrays(i,c,l),n.update(l,i,1)}function o(c,l,u){if(u===0)return;e.drawArraysInstanced(i,c,l,u),n.update(l,i,u)}function a(c,l,u){if(u===0)return;t.get("WEBGL_multi_draw").multiDrawArraysWEBGL(i,c,0,l,0,u);let h=0;for(let d=0;d<u;d++)h+=l[d];n.update(h,i,1)}this.setMode=r,this.render=s,this.renderInstances=o,this.renderMultiDraw=a}function lw(e,t,n,i){let r;function s(){if(r!==void 0)return r;if(t.has("EXT_texture_filter_anisotropic")===!0){let A=t.get("EXT_texture_filter_anisotropic");r=e.getParameter(A.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r}function o(A){if(A!==oi&&i.convert(A)!==e.getParameter(e.IMPLEMENTATION_COLOR_READ_FORMAT))return!1;return!0}function a(A){let _=A===si&&(t.has("EXT_color_buffer_half_float")||t.has("EXT_color_buffer_float"));if(A!==$n&&A!==Ri&&!_&&i.convert(A)!==e.getParameter(e.IMPLEMENTATION_COLOR_READ_TYPE))return!1;return!0}function c(A){if(A==="highp"){if(e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.HIGH_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT).precision>0)return"highp";A="mediump"}if(A==="mediump"){if(e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.MEDIUM_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.MEDIUM_FLOAT).precision>0)return"mediump"}return"lowp"}let l=n.precision!==void 0?n.precision:"highp",u=c(l);if(u!==l)Ie("WebGLRenderer:",l,"not supported, using",u,"instead."),l=u;let f=n.logarithmicDepthBuffer===!0,h=n.reversedDepthBuffer===!0&&t.has("EXT_clip_control");if(n.reversedDepthBuffer===!0&&h===!1)Ie("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.");let d=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),g=e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS),x=e.getParameter(e.MAX_TEXTURE_SIZE),p=e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE),m=e.getParameter(e.MAX_VERTEX_ATTRIBS),E=e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),R=e.getParameter(e.MAX_VARYING_VECTORS),v=e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),M=e.getParameter(e.MAX_SAMPLES),T=e.getParameter(e.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:c,textureFormatReadable:o,textureTypeReadable:a,precision:l,logarithmicDepthBuffer:f,reversedDepthBuffer:h,maxTextures:d,maxVertexTextures:g,maxTextureSize:x,maxCubemapSize:p,maxAttributes:m,maxVertexUniforms:E,maxVaryings:R,maxFragmentUniforms:v,maxSamples:M,samples:T}}function uw(e){let t=this,n=null,i=0,r=!1,s=!1,o=new Rn,a=new ze,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(f,h){let d=f.length!==0||h||i!==0||r;return r=h,i=f.length,d},this.beginShadows=function(){s=!0,u(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(f,h){n=u(f,h,0)},this.setState=function(f,h,d){let{clippingPlanes:g,clipIntersection:x,clipShadows:p}=f,m=e.get(f);if(!r||g===null||g.length===0||s&&!p)if(s)u(null);else l();else{let E=s?0:i,R=E*4,v=m.clippingState||null;c.value=v,v=u(g,h,R,d);for(let M=0;M!==R;++M)v[M]=n[M];m.clippingState=v,this.numIntersection=x?this.numPlanes:0,this.numPlanes+=E}};function l(){if(c.value!==n)c.value=n,c.needsUpdate=i>0;t.numPlanes=i,t.numIntersection=0}function u(f,h,d,g){let x=f!==null?f.length:0,p=null;if(x!==0){if(p=c.value,g!==!0||p===null){let m=d+x*4,E=h.matrixWorldInverse;if(a.getNormalMatrix(E),p===null||p.length<m)p=new Float32Array(m);for(let R=0,v=d;R!==x;++R,v+=4)o.copy(f[R]).applyMatrix4(E,a),o.normal.toArray(p,v),p[v+3]=o.constant}c.value=p,c.needsUpdate=!0}return t.numPlanes=x,t.numIntersection=0,p}}var Ss=4,hw=6,fw=20,dw=256,uo=new Cr,vp=new Oe,Du=null,Ou=0,Uu=0,Fu=!1,pw=new O,Pr=new O;class mo{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(e,t=0,n=0.1,i=100,r={}){let{size:s=256,position:o=pw}=r;Du=this._renderer.getRenderTarget(),Ou=this._renderer.getActiveCubeFace(),Uu=this._renderer.getActiveMipmapLevel(),Fu=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(s);let a=this._allocateTargets();if(a.depthBuffer=!0,this._sceneToCubeUV(e,n,i,a,o),t>0)this._blur(a,0,0,t);return this._applyPMREM(a),this._cleanup(a),a}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){if(this._cubemapMaterial===null)this._cubemapMaterial=Mp(),this._compileMaterial(this._cubemapMaterial)}compileEquirectangularShader(){if(this._equirectMaterial===null)this._equirectMaterial=Sp(),this._compileMaterial(this._equirectMaterial)}dispose(){if(this._dispose(),this._cubemapMaterial!==null)this._cubemapMaterial.dispose();if(this._equirectMaterial!==null)this._equirectMaterial.dispose();if(this._backgroundBox!==null)this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose()}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){if(this._blurMaterial!==null)this._blurMaterial.dispose();if(this._ggxMaterial!==null)this._ggxMaterial.dispose();if(this._pingPongRenderTarget!==null)this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodMeshes.length;e++)this._lodMeshes[e].geometry.dispose()}_cleanup(e){this._renderer.setRenderTarget(Du,Ou,Uu),this._renderer.xr.enabled=Fu,e.scissorTest=!1,bs(e,0,0,e.width,e.height)}_fromTexture(e,t){if(e.mapping===as||e.mapping===vr)this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width);else this._setSize(e.image.width/4);Du=this._renderer.getRenderTarget(),Ou=this._renderer.getActiveCubeFace(),Uu=this._renderer.getActiveMipmapLevel(),Fu=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;let n=t||this._allocateTargets();return this._textureToCubeUV(e,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){let e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,n={magFilter:$t,minFilter:$t,generateMipmaps:!1,type:si,format:oi,colorSpace:gn,depthBuffer:!1},i=bp(e,t,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){if(this._pingPongRenderTarget!==null)this._dispose();this._pingPongRenderTarget=bp(e,t,n);let{_lodMax:r}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods}=mw(r)),this._blurMaterial=_w(r,e,t),this._ggxMaterial=gw(r,e,t)}return i}_compileMaterial(e){let t=new _t(new en,e);this._renderer.compile(t,uo)}_sceneToCubeUV(e,t,n,i,r){let a=new Ut(90,1,t,n),c=[1,-1,1,1,1,1],l=[1,1,1,-1,-1,-1],u=this._renderer,{autoClear:f,toneMapping:h}=u;if(u.getClearColor(vp),u.toneMapping=Hn,u.autoClear=!1,u.state.buffers.depth.getReversed())u.setRenderTarget(i),u.clearDepth(),u.setRenderTarget(null);if(this._backgroundBox===null)this._backgroundBox=new _t(new Qi,new ai({name:"PMREM.Background",side:Qt,depthWrite:!1,depthTest:!1}));let g=this._backgroundBox,x=g.material,p=!1,m=e.background;if(m){if(m.isColor)x.color.copy(m),e.background=null,p=!0}else x.color.copy(vp),p=!0;for(let E=0;E<6;E++){let R=E%3;if(R===0)a.up.set(0,c[E],0),a.position.set(r.x,r.y,r.z),a.lookAt(r.x+l[E],r.y,r.z);else if(R===1)a.up.set(0,0,c[E]),a.position.set(r.x,r.y,r.z),a.lookAt(r.x,r.y+l[E],r.z);else a.up.set(0,c[E],0),a.position.set(r.x,r.y,r.z),a.lookAt(r.x,r.y,r.z+l[E]);let v=this._cubeSize;if(bs(i,R*v,E>2?v:0,v,v),u.setRenderTarget(i),p)u.render(g,a);u.render(e,a)}u.toneMapping=h,u.autoClear=f,e.background=m}_textureToCubeUV(e,t){let n=this._renderer,i=e.mapping===as||e.mapping===vr;if(i){if(this._cubemapMaterial===null)this._cubemapMaterial=Mp();this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1}else if(this._equirectMaterial===null)this._equirectMaterial=Sp();let r=i?this._cubemapMaterial:this._equirectMaterial,s=this._lodMeshes[0];s.material=r;let o=r.uniforms;o.envMap.value=e;let a=this._cubeSize;bs(t,0,0,3*a,2*a),n.setRenderTarget(t),n.render(s,uo)}_applyPMREM(e){let t=this._renderer,n=t.autoClear;t.autoClear=!1;let i=this._lodMeshes.length;for(let r=1;r<i;r++)this._applyGGXFilter(e,r-1,r);t.autoClear=n}_applyGGXFilter(e,t,n){let i=this._renderer,r=this._pingPongRenderTarget,s=this._ggxMaterial,o=this._lodMeshes[n];o.material=s;let a=s.uniforms,c=n/(this._lodMeshes.length-1),l=t/(this._lodMeshes.length-1),u=Math.sqrt(c*c-l*l),f=c*1.25,h=u*f,{_lodMax:d}=this,g=this._sizeLods[n],x=3*g*(n>d-Ss?n-d+Ss:0),p=4*(this._cubeSize-g);a.envMap.value=e.texture,a.roughness.value=h,a.mipInt.value=d-t,bs(r,x,p,3*g,2*g),i.setRenderTarget(r),i.render(o,uo),a.envMap.value=r.texture,a.roughness.value=0,a.mipInt.value=d-n,bs(e,x,p,3*g,2*g),i.setRenderTarget(e),i.render(o,uo)}_blur(e,t,n,i){let r=this._pingPongRenderTarget,s=Math.min(i,Math.PI)/Math.SQRT2;this._blurPass(e,r,t,n,s),this._blurPass(r,e,n,n,s)}_blurPass(e,t,n,i,r){let s=this._renderer,o=this._blurMaterial,a=this._lodMeshes[i];a.material=o;let c=o.uniforms;c.envMap.value=e.texture,c.sigma.value=r,c.mipInt.value=this._lodMax-n;let l=this._sizeLods[i],u=3*l*(i>this._lodMax-Ss?i-this._lodMax+Ss:0),f=4*(this._cubeSize-l);bs(t,u,f,3*l,2*l),s.setRenderTarget(t),s.render(a,uo)}}function mw(e){let t=[],n=[],i=e,r=e-Ss+1+hw;for(let s=0;s<r;s++){let o=Math.pow(2,i);t.push(o);let a=1/(o-2),c=-a,l=1+a,u=[c,c,l,c,l,l,c,c,l,l,c,l],f=6,h=6,d=3,g=new Float32Array(d*h*f),x=new Float32Array(d*h*f);for(let m=0;m<f;m++){let E=m%3*2/3-1,R=m>2?0:-1,v=[E,R,0,E+0.6666666666666666,R,0,E+0.6666666666666666,R+1,0,E,R,0,E+0.6666666666666666,R+1,0,E,R+1,0];g.set(v,d*h*m);for(let M=0;M<h;M++){let T=u[M*2]*2-1,A=u[M*2+1]*2-1;if(m===0)Pr.set(1,A,T);else if(m===1)Pr.set(-T,1,-A);else if(m===2)Pr.set(-T,A,1);else if(m===3)Pr.set(-1,A,-T);else if(m===4)Pr.set(-T,-1,A);else Pr.set(T,A,-1);Pr.toArray(x,(m*h+M)*d)}}let p=new en;if(p.setAttribute("position",new Vt(g,d)),p.setAttribute("outputDirection",new Vt(x,d)),n.push(new _t(p,null)),i>Ss)i--}return{lodMeshes:n,sizeLods:t}}function bp(e,t,n){let i=new _n(e,t,n);return i.texture.mapping=Zs,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function bs(e,t,n,i,r){e.viewport.set(t,n,i,r),e.scissor.set(t,n,i,r)}function gw(e,t,n){return new In({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:dw,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${e}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:Qa(),fragmentShader:`
3948
3948
 
3949
3949
  precision highp float;
3950
3950
  precision highp int;
@@ -4048,7 +4048,7 @@ void main() {
4048
4048
 
4049
4049
  gl_FragColor = vec4(prefilteredColor, 1.0);
4050
4050
  }
4051
- `,blending:ii,depthTest:!1,depthWrite:!1})}function mw(e,t,n){return new Pn({name:"SphericalGaussianBlur",defines:{SAMPLES:uw,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${e}.0`},uniforms:{envMap:{value:null},sigma:{value:0},mipInt:{value:0}},vertexShader:Ja(),fragmentShader:`
4051
+ `,blending:ii,depthTest:!1,depthWrite:!1})}function _w(e,t,n){return new In({name:"SphericalGaussianBlur",defines:{SAMPLES:fw,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${e}.0`},uniforms:{envMap:{value:null},sigma:{value:0},mipInt:{value:0}},vertexShader:Qa(),fragmentShader:`
4052
4052
 
4053
4053
  precision highp float;
4054
4054
  precision highp int;
@@ -4108,7 +4108,7 @@ void main() {
4108
4108
  gl_FragColor = vec4( accumColor / accumWeight, 1.0 );
4109
4109
 
4110
4110
  }
4111
- `,blending:ii,depthTest:!1,depthWrite:!1})}function bp(){return new Pn({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Ja(),fragmentShader:`
4111
+ `,blending:ii,depthTest:!1,depthWrite:!1})}function Sp(){return new In({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Qa(),fragmentShader:`
4112
4112
 
4113
4113
  precision mediump float;
4114
4114
  precision mediump int;
@@ -4127,7 +4127,7 @@ void main() {
4127
4127
  gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
4128
4128
 
4129
4129
  }
4130
- `,blending:ii,depthTest:!1,depthWrite:!1})}function Sp(){return new Pn({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Ja(),fragmentShader:`
4130
+ `,blending:ii,depthTest:!1,depthWrite:!1})}function Mp(){return new In({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Qa(),fragmentShader:`
4131
4131
 
4132
4132
  precision mediump float;
4133
4133
  precision mediump int;
@@ -4143,7 +4143,7 @@ void main() {
4143
4143
  gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
4144
4144
 
4145
4145
  }
4146
- `,blending:ii,depthTest:!1,depthWrite:!1})}function Ja(){return`
4146
+ `,blending:ii,depthTest:!1,depthWrite:!1})}function Qa(){return`
4147
4147
 
4148
4148
  precision mediump float;
4149
4149
  precision mediump int;
@@ -4158,7 +4158,7 @@ void main() {
4158
4158
  gl_Position = vec4( position, 1.0 );
4159
4159
 
4160
4160
  }
4161
- `}class Gu extends _n{constructor(e=1,t={}){super(e,e,t);this.isWebGLCubeRenderTarget=!0;let n={width:e,height:e,depth:1},i=[n,n,n,n,n,n];this.texture=new za(i),this._setTextureOptions(t),this.texture.isRenderTargetTexture=!0}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;let n={uniforms:{tEquirect:{value:null}},vertexShader:`
4161
+ `}class Hu extends _n{constructor(e=1,t={}){super(e,e,t);this.isWebGLCubeRenderTarget=!0;let n={width:e,height:e,depth:1},i=[n,n,n,n,n,n];this.texture=new Ba(i),this._setTextureOptions(t),this.texture.isRenderTargetTexture=!0}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;let n={uniforms:{tEquirect:{value:null}},vertexShader:`
4162
4162
 
4163
4163
  varying vec3 vWorldDirection;
4164
4164
 
@@ -4193,7 +4193,7 @@ void main() {
4193
4193
  gl_FragColor = texture2D( tEquirect, sampleUV );
4194
4194
 
4195
4195
  }
4196
- `},i=new Ji(5,5,5),r=new Pn({name:"CubemapFromEquirect",uniforms:Tr(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:Qt,blending:ii});r.uniforms.tEquirect.value=t;let s=new xt(i,r),o=t.minFilter;if(t.minFilter===ri)t.minFilter=$t;return new Eu(1,10,this).update(e,s),t.minFilter=o,s.geometry.dispose(),s.material.dispose(),this}clear(e,t=!0,n=!0,i=!0){let r=e.getRenderTarget();for(let s=0;s<6;s++)e.setRenderTarget(this,s),e.clear(t,n,i);e.setRenderTarget(r)}}function gw(e){let t=new WeakMap,n=new WeakMap,i=null;function r(h,d=!1){if(h===null||h===void 0)return null;if(d)return o(h);return s(h)}function s(h){if(h&&h.isTexture){let d=h.mapping;if(d===xa||d===ya)if(t.has(h)){let g=t.get(h).texture;return a(g,h.mapping)}else{let g=h.image;if(g&&g.height>0){let x=new Gu(g.height);return x.fromEquirectangularTexture(e,h),t.set(h,x),h.addEventListener("dispose",l),a(x.texture,h.mapping)}else return null}}return h}function o(h){if(h&&h.isTexture){let d=h.mapping,g=d===xa||d===ya,x=d===ss||d===yr;if(g||x){let p=n.get(h),m=p!==void 0?p.texture.pmremVersion:0;if(h.isRenderTargetTexture&&h.pmremVersion!==m){if(i===null)i=new uo(e);return p=g?i.fromEquirectangular(h,p):i.fromCubemap(h,p),p.texture.pmremVersion=h.pmremVersion,n.set(h,p),p.texture}else if(p!==void 0)return p.texture;else{let E=h.image;if(g&&E&&E.height>0||x&&E&&c(E)){if(i===null)i=new uo(e);return p=g?i.fromEquirectangular(h):i.fromCubemap(h),p.texture.pmremVersion=h.pmremVersion,n.set(h,p),h.addEventListener("dispose",u),p.texture}else return null}}}return h}function a(h,d){if(d===xa)h.mapping=ss;else if(d===ya)h.mapping=yr;return h}function c(h){let d=0,g=6;for(let x=0;x<g;x++)if(h[x]!==void 0)d++;return d===g}function l(h){let d=h.target;d.removeEventListener("dispose",l);let g=t.get(d);if(g!==void 0)t.delete(d),g.dispose()}function u(h){let d=h.target;d.removeEventListener("dispose",u);let g=n.get(d);if(g!==void 0)n.delete(d),g.dispose()}function f(){if(t=new WeakMap,n=new WeakMap,i!==null)i.dispose(),i=null}return{get:r,dispose:f}}function _w(e){let t={};function n(i){if(t[i]!==void 0)return t[i];let r=e.getExtension(i);return t[i]=r,r}return{has:function(i){return n(i)!==null},init:function(){n("EXT_color_buffer_float"),n("WEBGL_clip_cull_distance"),n("OES_texture_float_linear"),n("EXT_color_buffer_half_float"),n("WEBGL_multisampled_render_to_texture"),n("WEBGL_render_shared_exponent")},get:function(i){let r=n(i);if(r===null)_r("WebGLRenderer: "+i+" extension not supported.");return r}}}function xw(e,t,n,i){let r={},s=new WeakMap;function o(f){let h=f.target;if(h.index!==null)t.remove(h.index);for(let g in h.attributes)t.remove(h.attributes[g]);h.removeEventListener("dispose",o),delete r[h.id];let d=s.get(h);if(d)t.remove(d),s.delete(h);if(i.releaseStatesOfGeometry(h),h.isInstancedBufferGeometry===!0)delete h._maxInstanceCount;n.memory.geometries--}function a(f,h){if(r[h.id]===!0)return h;return h.addEventListener("dispose",o),r[h.id]=!0,n.memory.geometries++,h}function c(f){let h=f.attributes;for(let d in h)t.update(h[d],e.ARRAY_BUFFER)}function l(f){let h=[],d=f.index,g=f.attributes.position,x=0;if(g===void 0)return;if(d!==null){let E=d.array;x=d.version;for(let R=0,v=E.length;R<v;R+=3){let M=E[R+0],T=E[R+1],A=E[R+2];h.push(M,T,T,A,A,M)}}else{let E=g.array;x=g.version;for(let R=0,v=E.length/3-1;R<v;R+=3){let M=R+0,T=R+1,A=R+2;h.push(M,T,T,A,A,M)}}let p=new(g.count>=65535?Da:Na)(h,1);p.version=x;let m=s.get(f);if(m)t.remove(m);s.set(f,p)}function u(f){let h=s.get(f);if(h){let d=f.index;if(d!==null){if(h.version<d.version)l(f)}}else l(f);return s.get(f)}return{get:a,update:c,getWireframeAttribute:u}}function yw(e,t,n){let i;function r(f){i=f}let s,o;function a(f){s=f.type,o=f.bytesPerElement}function c(f,h){e.drawElements(i,h,s,f*o),n.update(h,i,1)}function l(f,h,d){if(d===0)return;e.drawElementsInstanced(i,h,s,f*o,d),n.update(h,i,d)}function u(f,h,d){if(d===0)return;t.get("WEBGL_multi_draw").multiDrawElementsWEBGL(i,h,0,s,f,0,d);let x=0;for(let p=0;p<d;p++)x+=h[p];n.update(x,i,1)}this.setMode=r,this.setIndex=a,this.render=c,this.renderInstances=l,this.renderMultiDraw=u}function vw(e){let t={geometries:0,textures:0},n={frame:0,calls:0,triangles:0,points:0,lines:0};function i(s,o,a){switch(n.calls++,o){case e.TRIANGLES:n.triangles+=a*(s/3);break;case e.LINES:n.lines+=a*(s/2);break;case e.LINE_STRIP:n.lines+=a*(s-1);break;case e.LINE_LOOP:n.lines+=a*s;break;case e.POINTS:n.points+=a*s;break;default:Fe("WebGLInfo: Unknown draw mode:",o);break}}function r(){n.calls=0,n.triangles=0,n.points=0,n.lines=0}return{memory:t,render:n,programs:null,autoReset:!0,reset:r,update:i}}function bw(e,t,n){let i=new WeakMap,r=new ct;function s(o,a,c){let l=o.morphTargetInfluences,u=a.morphAttributes.position||a.morphAttributes.normal||a.morphAttributes.color,f=u!==void 0?u.length:0,h=i.get(a);if(h===void 0||h.count!==f){let S=function(){A.dispose(),i.delete(a),a.removeEventListener("dispose",S)};if(h!==void 0)h.texture.dispose();let d=a.morphAttributes.position!==void 0,g=a.morphAttributes.normal!==void 0,x=a.morphAttributes.color!==void 0,p=a.morphAttributes.position||[],m=a.morphAttributes.normal||[],E=a.morphAttributes.color||[],R=0;if(d===!0)R=1;if(g===!0)R=2;if(x===!0)R=3;let v=a.attributes.position.count*R,M=1;if(v>t.maxTextureSize)M=Math.ceil(v/t.maxTextureSize),v=t.maxTextureSize;let T=new Float32Array(v*M*4*f),A=new Ia(T,v,M,f);A.type=Ai,A.needsUpdate=!0;let _=R*4;for(let k=0;k<f;k++){let C=p[k],U=m[k],ee=E[k],P=v*M*4*k;for(let V=0;V<C.count;V++){let j=V*_;if(d===!0)r.fromBufferAttribute(C,V),T[P+j+0]=r.x,T[P+j+1]=r.y,T[P+j+2]=r.z,T[P+j+3]=0;if(g===!0)r.fromBufferAttribute(U,V),T[P+j+4]=r.x,T[P+j+5]=r.y,T[P+j+6]=r.z,T[P+j+7]=0;if(x===!0)r.fromBufferAttribute(ee,V),T[P+j+8]=r.x,T[P+j+9]=r.y,T[P+j+10]=r.z,T[P+j+11]=ee.itemSize===4?r.w:1}}h={count:f,texture:A,size:new Ne(v,M)},i.set(a,h),a.addEventListener("dispose",S)}if(o.isInstancedMesh===!0&&o.morphTexture!==null)c.getUniforms().setValue(e,"morphTexture",o.morphTexture,n);else{let d=0;for(let x=0;x<l.length;x++)d+=l[x];let g=a.morphTargetsRelative?1:1-d;c.getUniforms().setValue(e,"morphTargetBaseInfluence",g),c.getUniforms().setValue(e,"morphTargetInfluences",l)}c.getUniforms().setValue(e,"morphTargetsTexture",h.texture,n),c.getUniforms().setValue(e,"morphTargetsTextureSize",h.size)}return{update:s}}function Sw(e,t,n,i,r){let s=new WeakMap;function o(l){let u=r.render.frame,f=l.geometry,h=t.get(l,f);if(s.get(h)!==u)t.update(h),s.set(h,u);if(l.isInstancedMesh){if(l.hasEventListener("dispose",c)===!1)l.addEventListener("dispose",c);if(s.get(l)!==u){if(n.update(l.instanceMatrix,e.ARRAY_BUFFER),l.instanceColor!==null)n.update(l.instanceColor,e.ARRAY_BUFFER);s.set(l,u)}}if(l.isSkinnedMesh){let d=l.skeleton;if(s.get(d)!==u)d.update(),s.set(d,u)}return h}function a(){s=new WeakMap}function c(l){let u=l.target;if(u.removeEventListener("dispose",c),i.releaseStatesOfObject(u),n.remove(u.instanceMatrix),u.instanceColor!==null)n.remove(u.instanceColor)}return{update:o,dispose:a}}var Mw={[_l]:"LINEAR_TONE_MAPPING",[xl]:"REINHARD_TONE_MAPPING",[yl]:"CINEON_TONE_MAPPING",[Gs]:"ACES_FILMIC_TONE_MAPPING",[bl]:"AGX_TONE_MAPPING",[Sl]:"NEUTRAL_TONE_MAPPING",[vl]:"CUSTOM_TONE_MAPPING"};function ww(e,t,n,i,r,s){let o=new _n(t,n,{type:e,depthBuffer:r,stencilBuffer:s,samples:i?4:0,storeMultisampledDepthBuffer:!1,storeMultisampledStencilBuffer:!1,resolveDepthBuffer:!1,resolveStencilBuffer:!1}),a=null,c=null,l=new en;l.setAttribute("position",new un([-1,3,0,-1,-1,0,3,-1,0],3)),l.setAttribute("uv",new un([0,2,0,0,2,0],2));let u=new _u({uniforms:{tDiffuse:{value:null}},vertexShader:`
4196
+ `},i=new Qi(5,5,5),r=new In({name:"CubemapFromEquirect",uniforms:Ar(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:Qt,blending:ii});r.uniforms.tEquirect.value=t;let s=new _t(i,r),o=t.minFilter;if(t.minFilter===ri)t.minFilter=$t;return new Tu(1,10,this).update(e,s),t.minFilter=o,s.geometry.dispose(),s.material.dispose(),this}clear(e,t=!0,n=!0,i=!0){let r=e.getRenderTarget();for(let s=0;s<6;s++)e.setRenderTarget(this,s),e.clear(t,n,i);e.setRenderTarget(r)}}function xw(e){let t=new WeakMap,n=new WeakMap,i=null;function r(h,d=!1){if(h===null||h===void 0)return null;if(d)return o(h);return s(h)}function s(h){if(h&&h.isTexture){let d=h.mapping;if(d===va||d===ba)if(t.has(h)){let g=t.get(h).texture;return a(g,h.mapping)}else{let g=h.image;if(g&&g.height>0){let x=new Hu(g.height);return x.fromEquirectangularTexture(e,h),t.set(h,x),h.addEventListener("dispose",l),a(x.texture,h.mapping)}else return null}}return h}function o(h){if(h&&h.isTexture){let d=h.mapping,g=d===va||d===ba,x=d===as||d===vr;if(g||x){let p=n.get(h),m=p!==void 0?p.texture.pmremVersion:0;if(h.isRenderTargetTexture&&h.pmremVersion!==m){if(i===null)i=new mo(e);return p=g?i.fromEquirectangular(h,p):i.fromCubemap(h,p),p.texture.pmremVersion=h.pmremVersion,n.set(h,p),p.texture}else if(p!==void 0)return p.texture;else{let E=h.image;if(g&&E&&E.height>0||x&&E&&c(E)){if(i===null)i=new mo(e);return p=g?i.fromEquirectangular(h):i.fromCubemap(h),p.texture.pmremVersion=h.pmremVersion,n.set(h,p),h.addEventListener("dispose",u),p.texture}else return null}}}return h}function a(h,d){if(d===va)h.mapping=as;else if(d===ba)h.mapping=vr;return h}function c(h){let d=0,g=6;for(let x=0;x<g;x++)if(h[x]!==void 0)d++;return d===g}function l(h){let d=h.target;d.removeEventListener("dispose",l);let g=t.get(d);if(g!==void 0)t.delete(d),g.dispose()}function u(h){let d=h.target;d.removeEventListener("dispose",u);let g=n.get(d);if(g!==void 0)n.delete(d),g.dispose()}function f(){if(t=new WeakMap,n=new WeakMap,i!==null)i.dispose(),i=null}return{get:r,dispose:f}}function yw(e){let t={};function n(i){if(t[i]!==void 0)return t[i];let r=e.getExtension(i);return t[i]=r,r}return{has:function(i){return n(i)!==null},init:function(){n("EXT_color_buffer_float"),n("WEBGL_clip_cull_distance"),n("OES_texture_float_linear"),n("EXT_color_buffer_half_float"),n("WEBGL_multisampled_render_to_texture"),n("WEBGL_render_shared_exponent")},get:function(i){let r=n(i);if(r===null)xr("WebGLRenderer: "+i+" extension not supported.");return r}}}function vw(e,t,n,i){let r={},s=new WeakMap;function o(f){let h=f.target;if(h.index!==null)t.remove(h.index);for(let g in h.attributes)t.remove(h.attributes[g]);h.removeEventListener("dispose",o),delete r[h.id];let d=s.get(h);if(d)t.remove(d),s.delete(h);if(i.releaseStatesOfGeometry(h),h.isInstancedBufferGeometry===!0)delete h._maxInstanceCount;n.memory.geometries--}function a(f,h){if(r[h.id]===!0)return h;return h.addEventListener("dispose",o),r[h.id]=!0,n.memory.geometries++,h}function c(f){let h=f.attributes;for(let d in h)t.update(h[d],e.ARRAY_BUFFER)}function l(f){let h=[],d=f.index,g=f.attributes.position,x=0;if(g===void 0)return;if(d!==null){let E=d.array;x=d.version;for(let R=0,v=E.length;R<v;R+=3){let M=E[R+0],T=E[R+1],A=E[R+2];h.push(M,T,T,A,A,M)}}else{let E=g.array;x=g.version;for(let R=0,v=E.length/3-1;R<v;R+=3){let M=R+0,T=R+1,A=R+2;h.push(M,T,T,A,A,M)}}let p=new(g.count>=65535?Ua:Oa)(h,1);p.version=x;let m=s.get(f);if(m)t.remove(m);s.set(f,p)}function u(f){let h=s.get(f);if(h){let d=f.index;if(d!==null){if(h.version<d.version)l(f)}}else l(f);return s.get(f)}return{get:a,update:c,getWireframeAttribute:u}}function bw(e,t,n){let i;function r(f){i=f}let s,o;function a(f){s=f.type,o=f.bytesPerElement}function c(f,h){e.drawElements(i,h,s,f*o),n.update(h,i,1)}function l(f,h,d){if(d===0)return;e.drawElementsInstanced(i,h,s,f*o,d),n.update(h,i,d)}function u(f,h,d){if(d===0)return;t.get("WEBGL_multi_draw").multiDrawElementsWEBGL(i,h,0,s,f,0,d);let x=0;for(let p=0;p<d;p++)x+=h[p];n.update(x,i,1)}this.setMode=r,this.setIndex=a,this.render=c,this.renderInstances=l,this.renderMultiDraw=u}function Sw(e){let t={geometries:0,textures:0},n={frame:0,calls:0,triangles:0,points:0,lines:0};function i(s,o,a){switch(n.calls++,o){case e.TRIANGLES:n.triangles+=a*(s/3);break;case e.LINES:n.lines+=a*(s/2);break;case e.LINE_STRIP:n.lines+=a*(s-1);break;case e.LINE_LOOP:n.lines+=a*s;break;case e.POINTS:n.points+=a*s;break;default:Ue("WebGLInfo: Unknown draw mode:",o);break}}function r(){n.calls=0,n.triangles=0,n.points=0,n.lines=0}return{memory:t,render:n,programs:null,autoReset:!0,reset:r,update:i}}function Mw(e,t,n){let i=new WeakMap,r=new at;function s(o,a,c){let l=o.morphTargetInfluences,u=a.morphAttributes.position||a.morphAttributes.normal||a.morphAttributes.color,f=u!==void 0?u.length:0,h=i.get(a);if(h===void 0||h.count!==f){let S=function(){A.dispose(),i.delete(a),a.removeEventListener("dispose",S)};if(h!==void 0)h.texture.dispose();let d=a.morphAttributes.position!==void 0,g=a.morphAttributes.normal!==void 0,x=a.morphAttributes.color!==void 0,p=a.morphAttributes.position||[],m=a.morphAttributes.normal||[],E=a.morphAttributes.color||[],R=0;if(d===!0)R=1;if(g===!0)R=2;if(x===!0)R=3;let v=a.attributes.position.count*R,M=1;if(v>t.maxTextureSize)M=Math.ceil(v/t.maxTextureSize),v=t.maxTextureSize;let T=new Float32Array(v*M*4*f),A=new Na(T,v,M,f);A.type=Ri,A.needsUpdate=!0;let _=R*4;for(let z=0;z<f;z++){let P=p[z],F=m[z],ee=E[z],I=v*M*4*z;for(let H=0;H<P.count;H++){let q=H*_;if(d===!0)r.fromBufferAttribute(P,H),T[I+q+0]=r.x,T[I+q+1]=r.y,T[I+q+2]=r.z,T[I+q+3]=0;if(g===!0)r.fromBufferAttribute(F,H),T[I+q+4]=r.x,T[I+q+5]=r.y,T[I+q+6]=r.z,T[I+q+7]=0;if(x===!0)r.fromBufferAttribute(ee,H),T[I+q+8]=r.x,T[I+q+9]=r.y,T[I+q+10]=r.z,T[I+q+11]=ee.itemSize===4?r.w:1}}h={count:f,texture:A,size:new Ne(v,M)},i.set(a,h),a.addEventListener("dispose",S)}if(o.isInstancedMesh===!0&&o.morphTexture!==null)c.getUniforms().setValue(e,"morphTexture",o.morphTexture,n);else{let d=0;for(let x=0;x<l.length;x++)d+=l[x];let g=a.morphTargetsRelative?1:1-d;c.getUniforms().setValue(e,"morphTargetBaseInfluence",g),c.getUniforms().setValue(e,"morphTargetInfluences",l)}c.getUniforms().setValue(e,"morphTargetsTexture",h.texture,n),c.getUniforms().setValue(e,"morphTargetsTextureSize",h.size)}return{update:s}}function ww(e,t,n,i,r){let s=new WeakMap;function o(l){let u=r.render.frame,f=l.geometry,h=t.get(l,f);if(s.get(h)!==u)t.update(h),s.set(h,u);if(l.isInstancedMesh){if(l.hasEventListener("dispose",c)===!1)l.addEventListener("dispose",c);if(s.get(l)!==u){if(n.update(l.instanceMatrix,e.ARRAY_BUFFER),l.instanceColor!==null)n.update(l.instanceColor,e.ARRAY_BUFFER);s.set(l,u)}}if(l.isSkinnedMesh){let d=l.skeleton;if(s.get(d)!==u)d.update(),s.set(d,u)}return h}function a(){s=new WeakMap}function c(l){let u=l.target;if(u.removeEventListener("dispose",c),i.releaseStatesOfObject(u),n.remove(u.instanceMatrix),u.instanceColor!==null)n.remove(u.instanceColor)}return{update:o,dispose:a}}var Ew={[xl]:"LINEAR_TONE_MAPPING",[yl]:"REINHARD_TONE_MAPPING",[vl]:"CINEON_TONE_MAPPING",[Ws]:"ACES_FILMIC_TONE_MAPPING",[Sl]:"AGX_TONE_MAPPING",[Ml]:"NEUTRAL_TONE_MAPPING",[bl]:"CUSTOM_TONE_MAPPING"};function Tw(e,t,n,i,r,s){let o=new _n(t,n,{type:e,depthBuffer:r,stencilBuffer:s,samples:i?4:0,storeMultisampledDepthBuffer:!1,storeMultisampledStencilBuffer:!1,resolveDepthBuffer:!1,resolveStencilBuffer:!1}),a=null,c=null,l=new en;l.setAttribute("position",new un([-1,3,0,-1,-1,0,3,-1,0],3)),l.setAttribute("uv",new un([0,2,0,0,2,0],2));let u=new xu({uniforms:{tDiffuse:{value:null}},vertexShader:`
4197
4197
  precision highp float;
4198
4198
 
4199
4199
  uniform mat4 modelViewMatrix;
@@ -4239,17 +4239,17 @@ void main() {
4239
4239
  #ifdef SRGB_TRANSFER
4240
4240
  gl_FragColor = sRGBTransferOETF( gl_FragColor );
4241
4241
  #endif
4242
- }`,depthTest:!1,depthWrite:!1}),f=new xt(l,u),h=new Rr(-1,1,1,-1,0,1),d=null,g=null,x=!1,p,m=null,E=[],R=!1;this.setSize=function(v,M){if(o.setSize(v,M),a!==null)a.setSize(v,M);if(c!==null)c.setSize(v,M);for(let T=0;T<E.length;T++){let A=E[T];if(A.setSize)A.setSize(v,M)}},this.setEffects=function(v){E=v,R=E.length>0&&E[0].isRenderPass===!0;let{width:M,height:T}=o;if(E.length>0&&a===null)a=new _n(M,T,{type:si,depthBuffer:!1,stencilBuffer:!1}),c=new _n(M,T,{type:si,depthBuffer:!1,stencilBuffer:!1});for(let A=0;A<E.length;A++){let _=E[A];if(_.setSize)_.setSize(M,T)}},this.begin=function(v,M){if(x)return!1;if(v.toneMapping===Gn&&E.length===0)return!1;if(m=M,M!==null){let{width:T,height:A}=M;if(o.width!==T||o.height!==A)this.setSize(T,A)}if(R===!1)v.setRenderTarget(o);return p=v.toneMapping,v.toneMapping=Gn,!0},this.hasRenderPass=function(){return R},this.end=function(v,M){v.toneMapping=p,x=!0;let T=o,A=a;for(let _=0;_<E.length;_++){let S=E[_];if(S.enabled===!1)continue;if(S.render(v,A,T,M),S.needsSwap!==!1)T=A,A=A===a?c:a}if(d!==v.outputColorSpace||g!==v.toneMapping){if(d=v.outputColorSpace,g=v.toneMapping,u.defines={},$e.getTransfer(d)===pt)u.defines.SRGB_TRANSFER="";let _=Mw[g];if(_)u.defines[_]="";u.needsUpdate=!0}u.uniforms.tDiffuse.value=T.texture,v.setRenderTarget(m),v.render(f,h),m=null,x=!1},this.isCompositing=function(){return x},this.dispose=function(){if(o.dispose(),a!==null)a.dispose();if(c!==null)c.dispose();l.dispose(),u.dispose()}}var Hp=new At,ku=new Er(1,1),Vp=new Ia,$p=new pu,Wp=new za,Mp=[],wp=[],Ep=new Float32Array(16),Tp=new Float32Array(9),Ap=new Float32Array(4);function vs(e,t,n){let i=e[0];if(i<=0||i>0)return e;let r=t*n,s=Mp[r];if(s===void 0)s=new Float32Array(r),Mp[r]=s;if(t!==0){i.toArray(s,0);for(let o=1,a=0;o!==t;++o)a+=n,e[o].toArray(s,a)}return s}function zt(e,t){if(e.length!==t.length)return!1;for(let n=0,i=e.length;n<i;n++)if(e[n]!==t[n])return!1;return!0}function kt(e,t){for(let n=0,i=t.length;n<i;n++)e[n]=t[n]}function Qa(e,t){let n=wp[t];if(n===void 0)n=new Int32Array(t),wp[t]=n;for(let i=0;i!==t;++i)n[i]=e.allocateTextureUnit();return n}function Ew(e,t){let n=this.cache;if(n[0]===t)return;e.uniform1f(this.addr,t),n[0]=t}function Tw(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y)e.uniform2f(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y}else{if(zt(n,t))return;e.uniform2fv(this.addr,t),kt(n,t)}}function Aw(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z)e.uniform3f(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z}else if(t.r!==void 0){if(n[0]!==t.r||n[1]!==t.g||n[2]!==t.b)e.uniform3f(this.addr,t.r,t.g,t.b),n[0]=t.r,n[1]=t.g,n[2]=t.b}else{if(zt(n,t))return;e.uniform3fv(this.addr,t),kt(n,t)}}function Rw(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z||n[3]!==t.w)e.uniform4f(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w}else{if(zt(n,t))return;e.uniform4fv(this.addr,t),kt(n,t)}}function Cw(e,t){let n=this.cache,i=t.elements;if(i===void 0){if(zt(n,t))return;e.uniformMatrix2fv(this.addr,!1,t),kt(n,t)}else{if(zt(n,i))return;Ap.set(i),e.uniformMatrix2fv(this.addr,!1,Ap),kt(n,i)}}function Pw(e,t){let n=this.cache,i=t.elements;if(i===void 0){if(zt(n,t))return;e.uniformMatrix3fv(this.addr,!1,t),kt(n,t)}else{if(zt(n,i))return;Tp.set(i),e.uniformMatrix3fv(this.addr,!1,Tp),kt(n,i)}}function Iw(e,t){let n=this.cache,i=t.elements;if(i===void 0){if(zt(n,t))return;e.uniformMatrix4fv(this.addr,!1,t),kt(n,t)}else{if(zt(n,i))return;Ep.set(i),e.uniformMatrix4fv(this.addr,!1,Ep),kt(n,i)}}function Lw(e,t){let n=this.cache;if(n[0]===t)return;e.uniform1i(this.addr,t),n[0]=t}function Nw(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y)e.uniform2i(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y}else{if(zt(n,t))return;e.uniform2iv(this.addr,t),kt(n,t)}}function Dw(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z)e.uniform3i(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z}else{if(zt(n,t))return;e.uniform3iv(this.addr,t),kt(n,t)}}function Ow(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z||n[3]!==t.w)e.uniform4i(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w}else{if(zt(n,t))return;e.uniform4iv(this.addr,t),kt(n,t)}}function Uw(e,t){let n=this.cache;if(n[0]===t)return;e.uniform1ui(this.addr,t),n[0]=t}function Fw(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y)e.uniform2ui(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y}else{if(zt(n,t))return;e.uniform2uiv(this.addr,t),kt(n,t)}}function zw(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z)e.uniform3ui(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z}else{if(zt(n,t))return;e.uniform3uiv(this.addr,t),kt(n,t)}}function kw(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z||n[3]!==t.w)e.uniform4ui(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w}else{if(zt(n,t))return;e.uniform4uiv(this.addr,t),kt(n,t)}}function Bw(e,t,n){let i=this.cache,r=n.allocateTextureUnit();if(i[0]!==r)e.uniform1i(this.addr,r),i[0]=r;let s;if(this.type===e.SAMPLER_2D_SHADOW)ku.compareFunction=n.isReversedDepthBuffer()?Pa:Ca,s=ku;else s=Hp;n.setTexture2D(t||s,r)}function Gw(e,t,n){let i=this.cache,r=n.allocateTextureUnit();if(i[0]!==r)e.uniform1i(this.addr,r),i[0]=r;n.setTexture3D(t||$p,r)}function Hw(e,t,n){let i=this.cache,r=n.allocateTextureUnit();if(i[0]!==r)e.uniform1i(this.addr,r),i[0]=r;n.setTextureCube(t||Wp,r)}function Vw(e,t,n){let i=this.cache,r=n.allocateTextureUnit();if(i[0]!==r)e.uniform1i(this.addr,r),i[0]=r;n.setTexture2DArray(t||Vp,r)}function $w(e){switch(e){case 5126:return Ew;case 35664:return Tw;case 35665:return Aw;case 35666:return Rw;case 35674:return Cw;case 35675:return Pw;case 35676:return Iw;case 5124:case 35670:return Lw;case 35667:case 35671:return Nw;case 35668:case 35672:return Dw;case 35669:case 35673:return Ow;case 5125:return Uw;case 36294:return Fw;case 36295:return zw;case 36296:return kw;case 35678:case 36198:case 36298:case 36306:case 35682:return Bw;case 35679:case 36299:case 36307:return Gw;case 35680:case 36300:case 36308:case 36293:return Hw;case 36289:case 36303:case 36311:case 36292:return Vw}}function Ww(e,t){e.uniform1fv(this.addr,t)}function Zw(e,t){let n=vs(t,this.size,2);e.uniform2fv(this.addr,n)}function Xw(e,t){let n=vs(t,this.size,3);e.uniform3fv(this.addr,n)}function qw(e,t){let n=vs(t,this.size,4);e.uniform4fv(this.addr,n)}function jw(e,t){let n=vs(t,this.size,4);e.uniformMatrix2fv(this.addr,!1,n)}function Yw(e,t){let n=vs(t,this.size,9);e.uniformMatrix3fv(this.addr,!1,n)}function Kw(e,t){let n=vs(t,this.size,16);e.uniformMatrix4fv(this.addr,!1,n)}function Jw(e,t){e.uniform1iv(this.addr,t)}function Qw(e,t){e.uniform2iv(this.addr,t)}function eE(e,t){e.uniform3iv(this.addr,t)}function tE(e,t){e.uniform4iv(this.addr,t)}function nE(e,t){e.uniform1uiv(this.addr,t)}function iE(e,t){e.uniform2uiv(this.addr,t)}function rE(e,t){e.uniform3uiv(this.addr,t)}function sE(e,t){e.uniform4uiv(this.addr,t)}function oE(e,t,n){let i=this.cache,r=t.length,s=Qa(n,r);if(!zt(i,s))e.uniform1iv(this.addr,s),kt(i,s);let o;if(this.type===e.SAMPLER_2D_SHADOW)o=ku;else o=Hp;for(let a=0;a!==r;++a)n.setTexture2D(t[a]||o,s[a])}function aE(e,t,n){let i=this.cache,r=t.length,s=Qa(n,r);if(!zt(i,s))e.uniform1iv(this.addr,s),kt(i,s);for(let o=0;o!==r;++o)n.setTexture3D(t[o]||$p,s[o])}function cE(e,t,n){let i=this.cache,r=t.length,s=Qa(n,r);if(!zt(i,s))e.uniform1iv(this.addr,s),kt(i,s);for(let o=0;o!==r;++o)n.setTextureCube(t[o]||Wp,s[o])}function lE(e,t,n){let i=this.cache,r=t.length,s=Qa(n,r);if(!zt(i,s))e.uniform1iv(this.addr,s),kt(i,s);for(let o=0;o!==r;++o)n.setTexture2DArray(t[o]||Vp,s[o])}function uE(e){switch(e){case 5126:return Ww;case 35664:return Zw;case 35665:return Xw;case 35666:return qw;case 35674:return jw;case 35675:return Yw;case 35676:return Kw;case 5124:case 35670:return Jw;case 35667:case 35671:return Qw;case 35668:case 35672:return eE;case 35669:case 35673:return tE;case 5125:return nE;case 36294:return iE;case 36295:return rE;case 36296:return sE;case 35678:case 36198:case 36298:case 36306:case 35682:return oE;case 35679:case 36299:case 36307:return aE;case 35680:case 36300:case 36308:case 36293:return cE;case 36289:case 36303:case 36311:case 36292:return lE}}class Zp{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.setValue=$w(t.type)}}class Xp{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=uE(t.type)}}class qp{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,n){let i=this.seq;for(let r=0,s=i.length;r!==s;++r){let o=i[r];o.setValue(e,t[o.id],n)}}}var Fu=/(\w+)(\])?(\[|\.)?/g;function Rp(e,t){e.seq.push(t),e.map[t.id]=t}function hE(e,t,n){let i=e.name,r=i.length;Fu.lastIndex=0;while(!0){let s=Fu.exec(i),o=Fu.lastIndex,a=s[1],c=s[2]==="]",l=s[3];if(c)a=a|0;if(l===void 0||l==="["&&o+2===r){Rp(n,l===void 0?new Zp(a,e,t):new Xp(a,e,t));break}else{let f=n.map[a];if(f===void 0)f=new qp(a),Rp(n,f);n=f}}}class lo{constructor(e,t){this.seq=[],this.map={};let n=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let s=0;s<n;++s){let o=e.getActiveUniform(t,s),a=e.getUniformLocation(t,o.name);hE(o,a,this)}let i=[],r=[];for(let s of this.seq)if(s.type===e.SAMPLER_2D_SHADOW||s.type===e.SAMPLER_CUBE_SHADOW||s.type===e.SAMPLER_2D_ARRAY_SHADOW)i.push(s);else r.push(s);if(i.length>0)this.seq=i.concat(r)}setValue(e,t,n,i){let r=this.map[t];if(r!==void 0)r.setValue(e,n,i)}setOptional(e,t,n){let i=t[n];if(i!==void 0)this.setValue(e,n,i)}static upload(e,t,n,i){for(let r=0,s=t.length;r!==s;++r){let o=t[r],a=n[o.id];if(a.needsUpdate!==!1)o.setValue(e,a.value,i)}}static seqWithValue(e,t){let n=[];for(let i=0,r=e.length;i!==r;++i){let s=e[i];if(s.id in t)n.push(s)}return n}}function Cp(e,t,n){let i=e.createShader(t);return e.shaderSource(i,n),e.compileShader(i),i}var fE=37297,dE=0;function pE(e,t){let n=e.split(`
4242
+ }`,depthTest:!1,depthWrite:!1}),f=new _t(l,u),h=new Cr(-1,1,1,-1,0,1),d=null,g=null,x=!1,p,m=null,E=[],R=!1;this.setSize=function(v,M){if(o.setSize(v,M),a!==null)a.setSize(v,M);if(c!==null)c.setSize(v,M);for(let T=0;T<E.length;T++){let A=E[T];if(A.setSize)A.setSize(v,M)}},this.setEffects=function(v){E=v,R=E.length>0&&E[0].isRenderPass===!0;let{width:M,height:T}=o;if(E.length>0&&a===null)a=new _n(M,T,{type:si,depthBuffer:!1,stencilBuffer:!1}),c=new _n(M,T,{type:si,depthBuffer:!1,stencilBuffer:!1});for(let A=0;A<E.length;A++){let _=E[A];if(_.setSize)_.setSize(M,T)}},this.begin=function(v,M){if(x)return!1;if(v.toneMapping===Hn&&E.length===0)return!1;if(m=M,M!==null){let{width:T,height:A}=M;if(o.width!==T||o.height!==A)this.setSize(T,A)}if(R===!1)v.setRenderTarget(o);return p=v.toneMapping,v.toneMapping=Hn,!0},this.hasRenderPass=function(){return R},this.end=function(v,M){v.toneMapping=p,x=!0;let T=o,A=a;for(let _=0;_<E.length;_++){let S=E[_];if(S.enabled===!1)continue;if(S.render(v,A,T,M),S.needsSwap!==!1)T=A,A=A===a?c:a}if(d!==v.outputColorSpace||g!==v.toneMapping){if(d=v.outputColorSpace,g=v.toneMapping,u.defines={},$e.getTransfer(d)===dt)u.defines.SRGB_TRANSFER="";let _=Ew[g];if(_)u.defines[_]="";u.needsUpdate=!0}u.uniforms.tDiffuse.value=T.texture,v.setRenderTarget(m),v.render(f,h),m=null,x=!1},this.isCompositing=function(){return x},this.dispose=function(){if(o.dispose(),a!==null)a.dispose();if(c!==null)c.dispose();l.dispose(),u.dispose()}}var Vp=new At,Bu=new Tr(1,1),$p=new Na,Wp=new mu,Zp=new Ba,wp=[],Ep=[],Tp=new Float32Array(16),Ap=new Float32Array(9),Rp=new Float32Array(4);function Ms(e,t,n){let i=e[0];if(i<=0||i>0)return e;let r=t*n,s=wp[r];if(s===void 0)s=new Float32Array(r),wp[r]=s;if(t!==0){i.toArray(s,0);for(let o=1,a=0;o!==t;++o)a+=n,e[o].toArray(s,a)}return s}function zt(e,t){if(e.length!==t.length)return!1;for(let n=0,i=e.length;n<i;n++)if(e[n]!==t[n])return!1;return!0}function kt(e,t){for(let n=0,i=t.length;n<i;n++)e[n]=t[n]}function ec(e,t){let n=Ep[t];if(n===void 0)n=new Int32Array(t),Ep[t]=n;for(let i=0;i!==t;++i)n[i]=e.allocateTextureUnit();return n}function Aw(e,t){let n=this.cache;if(n[0]===t)return;e.uniform1f(this.addr,t),n[0]=t}function Rw(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y)e.uniform2f(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y}else{if(zt(n,t))return;e.uniform2fv(this.addr,t),kt(n,t)}}function Cw(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z)e.uniform3f(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z}else if(t.r!==void 0){if(n[0]!==t.r||n[1]!==t.g||n[2]!==t.b)e.uniform3f(this.addr,t.r,t.g,t.b),n[0]=t.r,n[1]=t.g,n[2]=t.b}else{if(zt(n,t))return;e.uniform3fv(this.addr,t),kt(n,t)}}function Pw(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z||n[3]!==t.w)e.uniform4f(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w}else{if(zt(n,t))return;e.uniform4fv(this.addr,t),kt(n,t)}}function Iw(e,t){let n=this.cache,i=t.elements;if(i===void 0){if(zt(n,t))return;e.uniformMatrix2fv(this.addr,!1,t),kt(n,t)}else{if(zt(n,i))return;Rp.set(i),e.uniformMatrix2fv(this.addr,!1,Rp),kt(n,i)}}function Lw(e,t){let n=this.cache,i=t.elements;if(i===void 0){if(zt(n,t))return;e.uniformMatrix3fv(this.addr,!1,t),kt(n,t)}else{if(zt(n,i))return;Ap.set(i),e.uniformMatrix3fv(this.addr,!1,Ap),kt(n,i)}}function Nw(e,t){let n=this.cache,i=t.elements;if(i===void 0){if(zt(n,t))return;e.uniformMatrix4fv(this.addr,!1,t),kt(n,t)}else{if(zt(n,i))return;Tp.set(i),e.uniformMatrix4fv(this.addr,!1,Tp),kt(n,i)}}function Dw(e,t){let n=this.cache;if(n[0]===t)return;e.uniform1i(this.addr,t),n[0]=t}function Ow(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y)e.uniform2i(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y}else{if(zt(n,t))return;e.uniform2iv(this.addr,t),kt(n,t)}}function Uw(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z)e.uniform3i(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z}else{if(zt(n,t))return;e.uniform3iv(this.addr,t),kt(n,t)}}function Fw(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z||n[3]!==t.w)e.uniform4i(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w}else{if(zt(n,t))return;e.uniform4iv(this.addr,t),kt(n,t)}}function zw(e,t){let n=this.cache;if(n[0]===t)return;e.uniform1ui(this.addr,t),n[0]=t}function kw(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y)e.uniform2ui(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y}else{if(zt(n,t))return;e.uniform2uiv(this.addr,t),kt(n,t)}}function Bw(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z)e.uniform3ui(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z}else{if(zt(n,t))return;e.uniform3uiv(this.addr,t),kt(n,t)}}function Gw(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z||n[3]!==t.w)e.uniform4ui(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w}else{if(zt(n,t))return;e.uniform4uiv(this.addr,t),kt(n,t)}}function Hw(e,t,n){let i=this.cache,r=n.allocateTextureUnit();if(i[0]!==r)e.uniform1i(this.addr,r),i[0]=r;let s;if(this.type===e.SAMPLER_2D_SHADOW)Bu.compareFunction=n.isReversedDepthBuffer()?La:Ia,s=Bu;else s=Vp;n.setTexture2D(t||s,r)}function Vw(e,t,n){let i=this.cache,r=n.allocateTextureUnit();if(i[0]!==r)e.uniform1i(this.addr,r),i[0]=r;n.setTexture3D(t||Wp,r)}function $w(e,t,n){let i=this.cache,r=n.allocateTextureUnit();if(i[0]!==r)e.uniform1i(this.addr,r),i[0]=r;n.setTextureCube(t||Zp,r)}function Ww(e,t,n){let i=this.cache,r=n.allocateTextureUnit();if(i[0]!==r)e.uniform1i(this.addr,r),i[0]=r;n.setTexture2DArray(t||$p,r)}function Zw(e){switch(e){case 5126:return Aw;case 35664:return Rw;case 35665:return Cw;case 35666:return Pw;case 35674:return Iw;case 35675:return Lw;case 35676:return Nw;case 5124:case 35670:return Dw;case 35667:case 35671:return Ow;case 35668:case 35672:return Uw;case 35669:case 35673:return Fw;case 5125:return zw;case 36294:return kw;case 36295:return Bw;case 36296:return Gw;case 35678:case 36198:case 36298:case 36306:case 35682:return Hw;case 35679:case 36299:case 36307:return Vw;case 35680:case 36300:case 36308:case 36293:return $w;case 36289:case 36303:case 36311:case 36292:return Ww}}function Xw(e,t){e.uniform1fv(this.addr,t)}function qw(e,t){let n=Ms(t,this.size,2);e.uniform2fv(this.addr,n)}function jw(e,t){let n=Ms(t,this.size,3);e.uniform3fv(this.addr,n)}function Yw(e,t){let n=Ms(t,this.size,4);e.uniform4fv(this.addr,n)}function Kw(e,t){let n=Ms(t,this.size,4);e.uniformMatrix2fv(this.addr,!1,n)}function Jw(e,t){let n=Ms(t,this.size,9);e.uniformMatrix3fv(this.addr,!1,n)}function Qw(e,t){let n=Ms(t,this.size,16);e.uniformMatrix4fv(this.addr,!1,n)}function eE(e,t){e.uniform1iv(this.addr,t)}function tE(e,t){e.uniform2iv(this.addr,t)}function nE(e,t){e.uniform3iv(this.addr,t)}function iE(e,t){e.uniform4iv(this.addr,t)}function rE(e,t){e.uniform1uiv(this.addr,t)}function sE(e,t){e.uniform2uiv(this.addr,t)}function oE(e,t){e.uniform3uiv(this.addr,t)}function aE(e,t){e.uniform4uiv(this.addr,t)}function cE(e,t,n){let i=this.cache,r=t.length,s=ec(n,r);if(!zt(i,s))e.uniform1iv(this.addr,s),kt(i,s);let o;if(this.type===e.SAMPLER_2D_SHADOW)o=Bu;else o=Vp;for(let a=0;a!==r;++a)n.setTexture2D(t[a]||o,s[a])}function lE(e,t,n){let i=this.cache,r=t.length,s=ec(n,r);if(!zt(i,s))e.uniform1iv(this.addr,s),kt(i,s);for(let o=0;o!==r;++o)n.setTexture3D(t[o]||Wp,s[o])}function uE(e,t,n){let i=this.cache,r=t.length,s=ec(n,r);if(!zt(i,s))e.uniform1iv(this.addr,s),kt(i,s);for(let o=0;o!==r;++o)n.setTextureCube(t[o]||Zp,s[o])}function hE(e,t,n){let i=this.cache,r=t.length,s=ec(n,r);if(!zt(i,s))e.uniform1iv(this.addr,s),kt(i,s);for(let o=0;o!==r;++o)n.setTexture2DArray(t[o]||$p,s[o])}function fE(e){switch(e){case 5126:return Xw;case 35664:return qw;case 35665:return jw;case 35666:return Yw;case 35674:return Kw;case 35675:return Jw;case 35676:return Qw;case 5124:case 35670:return eE;case 35667:case 35671:return tE;case 35668:case 35672:return nE;case 35669:case 35673:return iE;case 5125:return rE;case 36294:return sE;case 36295:return oE;case 36296:return aE;case 35678:case 36198:case 36298:case 36306:case 35682:return cE;case 35679:case 36299:case 36307:return lE;case 35680:case 36300:case 36308:case 36293:return uE;case 36289:case 36303:case 36311:case 36292:return hE}}class Xp{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.setValue=Zw(t.type)}}class qp{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=fE(t.type)}}class jp{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,n){let i=this.seq;for(let r=0,s=i.length;r!==s;++r){let o=i[r];o.setValue(e,t[o.id],n)}}}var zu=/(\w+)(\])?(\[|\.)?/g;function Cp(e,t){e.seq.push(t),e.map[t.id]=t}function dE(e,t,n){let i=e.name,r=i.length;zu.lastIndex=0;while(!0){let s=zu.exec(i),o=zu.lastIndex,a=s[1],c=s[2]==="]",l=s[3];if(c)a=a|0;if(l===void 0||l==="["&&o+2===r){Cp(n,l===void 0?new Xp(a,e,t):new qp(a,e,t));break}else{let f=n.map[a];if(f===void 0)f=new jp(a),Cp(n,f);n=f}}}class po{constructor(e,t){this.seq=[],this.map={};let n=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let s=0;s<n;++s){let o=e.getActiveUniform(t,s),a=e.getUniformLocation(t,o.name);dE(o,a,this)}let i=[],r=[];for(let s of this.seq)if(s.type===e.SAMPLER_2D_SHADOW||s.type===e.SAMPLER_CUBE_SHADOW||s.type===e.SAMPLER_2D_ARRAY_SHADOW)i.push(s);else r.push(s);if(i.length>0)this.seq=i.concat(r)}setValue(e,t,n,i){let r=this.map[t];if(r!==void 0)r.setValue(e,n,i)}setOptional(e,t,n){let i=t[n];if(i!==void 0)this.setValue(e,n,i)}static upload(e,t,n,i){for(let r=0,s=t.length;r!==s;++r){let o=t[r],a=n[o.id];if(a.needsUpdate!==!1)o.setValue(e,a.value,i)}}static seqWithValue(e,t){let n=[];for(let i=0,r=e.length;i!==r;++i){let s=e[i];if(s.id in t)n.push(s)}return n}}function Pp(e,t,n){let i=e.createShader(t);return e.shaderSource(i,n),e.compileShader(i),i}var pE=37297,mE=0;function gE(e,t){let n=e.split(`
4243
4243
  `),i=[],r=Math.max(t-6,0),s=Math.min(t+6,n.length);for(let o=r;o<s;o++){let a=o+1;i.push(`${a===t?">":" "} ${a}: ${n[o]}`)}return i.join(`
4244
- `)}var Pp=new ke;function mE(e){$e._getMatrix(Pp,$e.workingColorSpace,e);let t=`mat3( ${Pp.elements.map((n)=>n.toFixed(4))} )`;switch($e.getTransfer(e)){case cu:return[t,"LinearTransferOETF"];case pt:return[t,"sRGBTransferOETF"];default:return Pe("WebGLProgram: Unsupported color space: ",e),[t,"LinearTransferOETF"]}}function Ip(e,t,n){let i=e.getShaderParameter(t,e.COMPILE_STATUS),s=(e.getShaderInfoLog(t)||"").trim();if(i&&s==="")return"";let o=/ERROR: 0:(\d+)/.exec(s);if(o){let a=parseInt(o[1]);return n.toUpperCase()+`
4244
+ `)}var Ip=new ze;function _E(e){$e._getMatrix(Ip,$e.workingColorSpace,e);let t=`mat3( ${Ip.elements.map((n)=>n.toFixed(4))} )`;switch($e.getTransfer(e)){case lu:return[t,"LinearTransferOETF"];case dt:return[t,"sRGBTransferOETF"];default:return Ie("WebGLProgram: Unsupported color space: ",e),[t,"LinearTransferOETF"]}}function Lp(e,t,n){let i=e.getShaderParameter(t,e.COMPILE_STATUS),s=(e.getShaderInfoLog(t)||"").trim();if(i&&s==="")return"";let o=/ERROR: 0:(\d+)/.exec(s);if(o){let a=parseInt(o[1]);return n.toUpperCase()+`
4245
4245
 
4246
4246
  `+s+`
4247
4247
 
4248
- `+pE(e.getShaderSource(t),a)}else return s}function gE(e,t){let n=mE(t);return[`vec4 ${e}( vec4 value ) {`,` return ${n[1]}( vec4( value.rgb * ${n[0]}, value.a ) );`,"}"].join(`
4249
- `)}var _E={[_l]:"Linear",[xl]:"Reinhard",[yl]:"Cineon",[Gs]:"ACESFilmic",[bl]:"AgX",[Sl]:"Neutral",[vl]:"Custom"};function xE(e,t){let n=_E[t];if(n===void 0)return Pe("WebGLProgram: Unsupported toneMapping:",t),"vec3 "+e+"( vec3 color ) { return LinearToneMapping( color ); }";return"vec3 "+e+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}var Ka=new D;function yE(){$e.getLuminanceCoefficients(Ka);let e=Ka.x.toFixed(4),t=Ka.y.toFixed(4),n=Ka.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${e}, ${t}, ${n} );`,"\treturn dot( weights, rgb );","}"].join(`
4250
- `)}function vE(e){return[e.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",e.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(co).join(`
4251
- `)}function bE(e){let t=[];for(let n in e){let i=e[n];if(i===!1)continue;t.push("#define "+n+" "+i)}return t.join(`
4252
- `)}function SE(e,t){let n={},i=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES);for(let r=0;r<i;r++){let s=e.getActiveAttrib(t,r),o=s.name,a=1;if(s.type===e.FLOAT_MAT2)a=2;if(s.type===e.FLOAT_MAT3)a=3;if(s.type===e.FLOAT_MAT4)a=4;n[o]={type:s.type,location:e.getAttribLocation(t,o),locationSize:a}}return n}function co(e){return e!==""}function Lp(e,t){let n=t.numSpotLightShadows+t.numSpotLightMaps-t.numSpotLightShadowsWithMaps;return e.replace(/NUM_SUN_LIGHTS/g,t.numSunLights).replace(/NUM_DIR_LIGHTS/g,t.numDirLights).replace(/NUM_SPOT_LIGHTS/g,t.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,t.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,n).replace(/NUM_RECT_AREA_LIGHTS/g,t.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,t.numPointLights).replace(/NUM_HEMI_LIGHTS/g,t.numHemiLights).replace(/NUM_SUN_LIGHT_SHADOWS/g,t.numSunLightShadows).replace(/NUM_DIR_LIGHT_SHADOWS/g,t.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,t.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,t.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,t.numPointLightShadows)}function Np(e,t){return e.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}var ME=/^[ \t]*#include +<([\w\d./]+)>/gm;function Bu(e){return e.replace(ME,EE)}var wE=new Map;function EE(e,t){let n=Ve[t];if(n===void 0){let i=wE.get(t);if(i!==void 0)n=Ve[i],Pe('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',t,i);else throw Error("THREE.WebGLProgram: Can not resolve #include <"+t+">")}return Bu(n)}var TE=/#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 Dp(e){return e.replace(TE,AE)}function AE(e,t,n,i){let r="";for(let s=parseInt(t);s<parseInt(n);s++)r+=i.replace(/\[\s*i\s*\]/g,"[ "+s+" ]").replace(/UNROLLED_LOOP_INDEX/g,s);return r}function Op(e){let t=`precision ${e.precision} float;
4248
+ `+gE(e.getShaderSource(t),a)}else return s}function xE(e,t){let n=_E(t);return[`vec4 ${e}( vec4 value ) {`,` return ${n[1]}( vec4( value.rgb * ${n[0]}, value.a ) );`,"}"].join(`
4249
+ `)}var yE={[xl]:"Linear",[yl]:"Reinhard",[vl]:"Cineon",[Ws]:"ACESFilmic",[Sl]:"AgX",[Ml]:"Neutral",[bl]:"Custom"};function vE(e,t){let n=yE[t];if(n===void 0)return Ie("WebGLProgram: Unsupported toneMapping:",t),"vec3 "+e+"( vec3 color ) { return LinearToneMapping( color ); }";return"vec3 "+e+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}var Ja=new O;function bE(){$e.getLuminanceCoefficients(Ja);let e=Ja.x.toFixed(4),t=Ja.y.toFixed(4),n=Ja.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${e}, ${t}, ${n} );`,"\treturn dot( weights, rgb );","}"].join(`
4250
+ `)}function SE(e){return[e.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",e.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(fo).join(`
4251
+ `)}function ME(e){let t=[];for(let n in e){let i=e[n];if(i===!1)continue;t.push("#define "+n+" "+i)}return t.join(`
4252
+ `)}function wE(e,t){let n={},i=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES);for(let r=0;r<i;r++){let s=e.getActiveAttrib(t,r),o=s.name,a=1;if(s.type===e.FLOAT_MAT2)a=2;if(s.type===e.FLOAT_MAT3)a=3;if(s.type===e.FLOAT_MAT4)a=4;n[o]={type:s.type,location:e.getAttribLocation(t,o),locationSize:a}}return n}function fo(e){return e!==""}function Np(e,t){let n=t.numSpotLightShadows+t.numSpotLightMaps-t.numSpotLightShadowsWithMaps;return e.replace(/NUM_SUN_LIGHTS/g,t.numSunLights).replace(/NUM_DIR_LIGHTS/g,t.numDirLights).replace(/NUM_SPOT_LIGHTS/g,t.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,t.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,n).replace(/NUM_RECT_AREA_LIGHTS/g,t.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,t.numPointLights).replace(/NUM_HEMI_LIGHTS/g,t.numHemiLights).replace(/NUM_SUN_LIGHT_SHADOWS/g,t.numSunLightShadows).replace(/NUM_DIR_LIGHT_SHADOWS/g,t.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,t.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,t.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,t.numPointLightShadows)}function Dp(e,t){return e.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}var EE=/^[ \t]*#include +<([\w\d./]+)>/gm;function Gu(e){return e.replace(EE,AE)}var TE=new Map;function AE(e,t){let n=Ve[t];if(n===void 0){let i=TE.get(t);if(i!==void 0)n=Ve[i],Ie('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',t,i);else throw Error("THREE.WebGLProgram: Can not resolve #include <"+t+">")}return Gu(n)}var RE=/#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 Op(e){return e.replace(RE,CE)}function CE(e,t,n,i){let r="";for(let s=parseInt(t);s<parseInt(n);s++)r+=i.replace(/\[\s*i\s*\]/g,"[ "+s+" ]").replace(/UNROLLED_LOOP_INDEX/g,s);return r}function Up(e){let t=`precision ${e.precision} float;
4253
4253
  precision ${e.precision} int;
4254
4254
  precision ${e.precision} sampler2D;
4255
4255
  precision ${e.precision} samplerCube;
@@ -4269,30 +4269,30 @@ void main() {
4269
4269
  `;if(e.precision==="highp")t+=`
4270
4270
  #define HIGH_PRECISION`;else if(e.precision==="mediump")t+=`
4271
4271
  #define MEDIUM_PRECISION`;else if(e.precision==="lowp")t+=`
4272
- #define LOW_PRECISION`;return t}var RE={[ks]:"SHADOWMAP_TYPE_PCF",[is]:"SHADOWMAP_TYPE_VSM"};function CE(e){return RE[e.shadowMapType]||"SHADOWMAP_TYPE_BASIC"}var PE={[ss]:"ENVMAP_TYPE_CUBE",[yr]:"ENVMAP_TYPE_CUBE",[Hs]:"ENVMAP_TYPE_CUBE_UV"};function IE(e){if(e.envMap===!1)return"ENVMAP_TYPE_CUBE";return PE[e.envMapMode]||"ENVMAP_TYPE_CUBE"}var LE={[yr]:"ENVMAP_MODE_REFRACTION"};function NE(e){if(e.envMap===!1)return"ENVMAP_MODE_REFLECTION";return LE[e.envMapMode]||"ENVMAP_MODE_REFLECTION"}var DE={[Vd]:"ENVMAP_BLENDING_MULTIPLY",[$d]:"ENVMAP_BLENDING_MIX",[Wd]:"ENVMAP_BLENDING_ADD"};function OE(e){if(e.envMap===!1)return"ENVMAP_BLENDING_NONE";return DE[e.combine]||"ENVMAP_BLENDING_NONE"}function UE(e){let t=e.envMapCubeUVHeight;if(t===null)return null;let n=Math.log2(t)-2,i=1/t;return{texelWidth:1/(3*Math.max(Math.pow(2,n),112)),texelHeight:i,maxMip:n}}function FE(e,t,n,i){let r=e.getContext(),{defines:s,vertexShader:o,fragmentShader:a}=n,c=CE(n),l=IE(n),u=NE(n),f=OE(n),h=UE(n),d=vE(n),g=bE(s),x=r.createProgram(),p,m,E=n.glslVersion?"#version "+n.glslVersion+`
4273
- `:"";if(n.isRawShaderMaterial){if(p=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,g].filter(co).join(`
4272
+ #define LOW_PRECISION`;return t}var PE={[Vs]:"SHADOWMAP_TYPE_PCF",[ss]:"SHADOWMAP_TYPE_VSM"};function IE(e){return PE[e.shadowMapType]||"SHADOWMAP_TYPE_BASIC"}var LE={[as]:"ENVMAP_TYPE_CUBE",[vr]:"ENVMAP_TYPE_CUBE",[Zs]:"ENVMAP_TYPE_CUBE_UV"};function NE(e){if(e.envMap===!1)return"ENVMAP_TYPE_CUBE";return LE[e.envMapMode]||"ENVMAP_TYPE_CUBE"}var DE={[vr]:"ENVMAP_MODE_REFRACTION"};function OE(e){if(e.envMap===!1)return"ENVMAP_MODE_REFLECTION";return DE[e.envMapMode]||"ENVMAP_MODE_REFLECTION"}var UE={[$d]:"ENVMAP_BLENDING_MULTIPLY",[Wd]:"ENVMAP_BLENDING_MIX",[Zd]:"ENVMAP_BLENDING_ADD"};function FE(e){if(e.envMap===!1)return"ENVMAP_BLENDING_NONE";return UE[e.combine]||"ENVMAP_BLENDING_NONE"}function zE(e){let t=e.envMapCubeUVHeight;if(t===null)return null;let n=Math.log2(t)-2,i=1/t;return{texelWidth:1/(3*Math.max(Math.pow(2,n),112)),texelHeight:i,maxMip:n}}function kE(e,t,n,i){let r=e.getContext(),{defines:s,vertexShader:o,fragmentShader:a}=n,c=IE(n),l=NE(n),u=OE(n),f=FE(n),h=zE(n),d=SE(n),g=ME(s),x=r.createProgram(),p,m,E=n.glslVersion?"#version "+n.glslVersion+`
4273
+ `:"";if(n.isRawShaderMaterial){if(p=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,g].filter(fo).join(`
4274
4274
  `),p.length>0)p+=`
4275
- `;if(m=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,g].filter(co).join(`
4275
+ `;if(m=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,g].filter(fo).join(`
4276
4276
  `),m.length>0)m+=`
4277
- `}else p=[Op(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,g,n.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",n.batching?"#define USE_BATCHING":"",n.batchingColor?"#define USE_BATCHING_COLOR":"",n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.instancingMorph?"#define USE_INSTANCING_MORPH":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+u:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexNormals?"#define HAS_NORMAL":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&n.flatShading===!1?"#define USE_MORPHNORMALS":"",n.morphColors?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING","\tattribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR","\tattribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH","\tuniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1","\tattribute vec2 uv1;","#endif","#ifdef USE_UV2","\tattribute vec2 uv2;","#endif","#ifdef USE_UV3","\tattribute vec2 uv3;","#endif","#ifdef USE_TANGENT","\tattribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )","\tattribute vec4 color;","#elif defined( USE_COLOR )","\tattribute vec3 color;","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif",`
4278
- `].filter(co).join(`
4279
- `),m=[Op(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,g,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+l:"",n.envMap?"#define "+u:"",n.envMap?"#define "+f:"",h?"#define CUBEUV_TEXEL_WIDTH "+h.texelWidth:"",h?"#define CUBEUV_TEXEL_HEIGHT "+h.texelHeight:"",h?"#define CUBEUV_MAX_MIP "+h.maxMip+".0":"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.packedNormalMap?"#define USE_PACKED_NORMALMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.dispersion?"#define USE_DISPERSION":"",n.retroreflection?"#define USE_RETROREFLECTION":"",n.iridescence?"#define USE_IRIDESCENCE":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor?"#define USE_COLOR":"",n.vertexAlphas||n.batchingColor?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.numLightProbeGrids>0?"#define USE_LIGHT_PROBES_GRID":"",n.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",n.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",n.toneMapping!==Gn?"#define TONE_MAPPING":"",n.toneMapping!==Gn?Ve.tonemapping_pars_fragment:"",n.toneMapping!==Gn?xE("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",Ve.colorspace_pars_fragment,gE("linearToOutputTexel",n.outputColorSpace),yE(),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",`
4280
- `].filter(co).join(`
4281
- `);if(o=Bu(o),o=Lp(o,n),o=Np(o,n),a=Bu(a),a=Lp(a,n),a=Np(a,n),o=Dp(o),a=Dp(a),n.isRawShaderMaterial!==!0)E=`#version 300 es
4277
+ `}else p=[Up(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,g,n.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",n.batching?"#define USE_BATCHING":"",n.batchingColor?"#define USE_BATCHING_COLOR":"",n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.instancingMorph?"#define USE_INSTANCING_MORPH":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+u:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexNormals?"#define HAS_NORMAL":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&n.flatShading===!1?"#define USE_MORPHNORMALS":"",n.morphColors?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING","\tattribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR","\tattribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH","\tuniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1","\tattribute vec2 uv1;","#endif","#ifdef USE_UV2","\tattribute vec2 uv2;","#endif","#ifdef USE_UV3","\tattribute vec2 uv3;","#endif","#ifdef USE_TANGENT","\tattribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )","\tattribute vec4 color;","#elif defined( USE_COLOR )","\tattribute vec3 color;","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif",`
4278
+ `].filter(fo).join(`
4279
+ `),m=[Up(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,g,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+l:"",n.envMap?"#define "+u:"",n.envMap?"#define "+f:"",h?"#define CUBEUV_TEXEL_WIDTH "+h.texelWidth:"",h?"#define CUBEUV_TEXEL_HEIGHT "+h.texelHeight:"",h?"#define CUBEUV_MAX_MIP "+h.maxMip+".0":"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.packedNormalMap?"#define USE_PACKED_NORMALMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.dispersion?"#define USE_DISPERSION":"",n.retroreflection?"#define USE_RETROREFLECTION":"",n.iridescence?"#define USE_IRIDESCENCE":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor?"#define USE_COLOR":"",n.vertexAlphas||n.batchingColor?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.numLightProbeGrids>0?"#define USE_LIGHT_PROBES_GRID":"",n.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",n.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",n.toneMapping!==Hn?"#define TONE_MAPPING":"",n.toneMapping!==Hn?Ve.tonemapping_pars_fragment:"",n.toneMapping!==Hn?vE("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",Ve.colorspace_pars_fragment,xE("linearToOutputTexel",n.outputColorSpace),bE(),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",`
4280
+ `].filter(fo).join(`
4281
+ `);if(o=Gu(o),o=Np(o,n),o=Dp(o,n),a=Gu(a),a=Np(a,n),a=Dp(a,n),o=Op(o),a=Op(a),n.isRawShaderMaterial!==!0)E=`#version 300 es
4282
4282
  `,p=[d,"#define attribute in","#define varying out","#define texture2D texture"].join(`
4283
4283
  `)+`
4284
- `+p,m=["#define varying in",n.glslVersion===lu?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===lu?"":"#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(`
4284
+ `+p,m=["#define varying in",n.glslVersion===uu?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===uu?"":"#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(`
4285
4285
  `)+`
4286
- `+m;let R=E+p+o,v=E+m+a,M=Cp(r,r.VERTEX_SHADER,R),T=Cp(r,r.FRAGMENT_SHADER,v);if(r.attachShader(x,M),r.attachShader(x,T),n.index0AttributeName!==void 0)r.bindAttribLocation(x,0,n.index0AttributeName);else if(n.hasPositionAttribute===!0)r.bindAttribLocation(x,0,"position");r.linkProgram(x);function A(C){if(e.debug.checkShaderErrors){let U=r.getProgramInfoLog(x)||"",ee=r.getShaderInfoLog(M)||"",P=r.getShaderInfoLog(T)||"",V=U.trim(),j=ee.trim(),z=P.trim(),H=!0,F=!0;if(r.getProgramParameter(x,r.LINK_STATUS)===!1)if(H=!1,typeof e.debug.onShaderError==="function")e.debug.onShaderError(r,x,M,T);else{let q=Ip(r,M,"vertex"),K=Ip(r,T,"fragment");Fe("WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(x,r.VALIDATE_STATUS)+`
4286
+ `+m;let R=E+p+o,v=E+m+a,M=Pp(r,r.VERTEX_SHADER,R),T=Pp(r,r.FRAGMENT_SHADER,v);if(r.attachShader(x,M),r.attachShader(x,T),n.index0AttributeName!==void 0)r.bindAttribLocation(x,0,n.index0AttributeName);else if(n.hasPositionAttribute===!0)r.bindAttribLocation(x,0,"position");r.linkProgram(x);function A(P){if(e.debug.checkShaderErrors){let F=r.getProgramInfoLog(x)||"",ee=r.getShaderInfoLog(M)||"",I=r.getShaderInfoLog(T)||"",H=F.trim(),q=ee.trim(),C=I.trim(),X=!0,k=!0;if(r.getProgramParameter(x,r.LINK_STATUS)===!1)if(X=!1,typeof e.debug.onShaderError==="function")e.debug.onShaderError(r,x,M,T);else{let Y=Lp(r,M,"vertex"),Q=Lp(r,T,"fragment");Ue("WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(x,r.VALIDATE_STATUS)+`
4287
4287
 
4288
- Material Name: `+C.name+`
4289
- Material Type: `+C.type+`
4288
+ Material Name: `+P.name+`
4289
+ Material Type: `+P.type+`
4290
4290
 
4291
- Program Info Log: `+V+`
4292
- `+q+`
4293
- `+K)}else if(V!=="")Pe("WebGLProgram: Program Info Log:",V);else if(j===""||z==="")F=!1;if(F)C.diagnostics={runnable:H,programLog:V,vertexShader:{log:j,prefix:p},fragmentShader:{log:z,prefix:m}}}r.deleteShader(M),r.deleteShader(T),_=new lo(r,x),S=SE(r,x)}let _;this.getUniforms=function(){if(_===void 0)A(this);return _};let S;this.getAttributes=function(){if(S===void 0)A(this);return S};let k=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){if(k===!1)k=r.getProgramParameter(x,fE);return k},this.destroy=function(){i.releaseStatesOfProgram(this),r.deleteProgram(x),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=dE++,this.cacheKey=t,this.usedTimes=1,this.program=x,this.vertexShader=M,this.fragmentShader=T,this}var zE=0;class jp{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e,t,n){let i=this._getShaderCacheForMaterial(e);if(i.has(t)===!1)i.add(t),t.usedTimes++;if(i.has(n)===!1)i.add(n),n.usedTimes++;return this}remove(e){let t=this.materialCache.get(e);for(let n of t)if(n.usedTimes--,n.usedTimes===0)this.shaderCache.delete(n.code);return this.materialCache.delete(e),this}getVertexShaderStage(e){return this._getShaderStage(e.vertexShader)}getFragmentShaderStage(e){return this._getShaderStage(e.fragmentShader)}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){let t=this.materialCache,n=t.get(e);if(n===void 0)n=new Set,t.set(e,n);return n}_getShaderStage(e){let t=this.shaderCache,n=t.get(e);if(n===void 0)n=new Yp(e),t.set(e,n);return n}}class Yp{constructor(e){this.id=zE++,this.code=e,this.usedTimes=0}}function kE(e){return e===Mr||e===Ta||e===Aa}function BE(e,t,n,i,r,s){let o=new La,a=new jp,c=new Set,l=[],u=new Map,{logarithmicDepthBuffer:f,precision:h}=i,d={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distance",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 g(_){if(c.add(_),_===0)return"uv";return`uv${_}`}function x(_,S,k,C,U,ee){let P=C.fog,V=U.geometry,j=_.isMeshStandardMaterial||_.isMeshLambertMaterial||_.isMeshPhongMaterial?C.environment:null,z=_.isMeshStandardMaterial||_.isMeshLambertMaterial&&!_.envMap||_.isMeshPhongMaterial&&!_.envMap,H=t.get(_.envMap||j,z),F=!!H&&H.mapping===Hs?H.image.height:null,q=d[_.type];if(_.precision!==null){if(h=i.getMaxPrecision(_.precision),h!==_.precision)Pe("WebGLProgram.getParameters:",_.precision,"not supported, using",h,"instead.")}let K=V.morphAttributes.position||V.morphAttributes.normal||V.morphAttributes.color,xe=K!==void 0?K.length:0,ce=0;if(V.morphAttributes.position!==void 0)ce=1;if(V.morphAttributes.normal!==void 0)ce=2;if(V.morphAttributes.color!==void 0)ce=3;let De,ye,X,re;if(q){let gt=li[q];De=gt.vertexShader,ye=gt.fragmentShader}else{De=_.vertexShader,ye=_.fragmentShader;let gt=a.getVertexShaderStage(_),rt=a.getFragmentShaderStage(_);a.update(_,gt,rt),X=gt.id,re=rt.id}let se=e.getRenderTarget(),Te=e.state.buffers.depth.getReversed(),Ie=U.isInstancedMesh===!0,_e=U.isBatchedMesh===!0,Qe=!!_.map,ze=!!_.matcap,Ze=!!H,ot=!!_.aoMap,Ye=!!_.lightMap,Zt=!!_.bumpMap&&_.wireframe===!1,yt=!!_.normalMap,cn=!!_.displacementMap,Dt=!!_.emissiveMap,Ot=!!_.metalnessMap,L=!!_.roughnessMap,ln=_.anisotropy>0,it=_.clearcoat>0,wt=_.dispersion>0,w=_.retroreflectivity>0,y=_.iridescence>0,I=_.sheen>0,W=_.transmission>0,ie=ln&&!!_.anisotropyMap,ae=it&&!!_.clearcoatMap,he=it&&!!_.clearcoatNormalMap,Y=it&&!!_.clearcoatRoughnessMap,te=y&&!!_.iridescenceMap,ve=y&&!!_.iridescenceThicknessMap,Ce=I&&!!_.sheenColorMap,fe=I&&!!_.sheenRoughnessMap,oe=!!_.specularMap,Le=!!_.specularColorMap,Oe=!!_.specularIntensityMap,et=W&&!!_.transmissionMap,O=W&&!!_.thicknessMap,le=!!_.gradientMap,J=!!_.alphaMap,ue=_.alphaTest>0,be=!!_.alphaHash,ne=!!_.extensions,pe=Gn;if(_.toneMapped){if(se===null||se.isXRRenderTarget===!0)pe=e.toneMapping}let Be={shaderID:q,shaderType:_.type,shaderName:_.name,vertexShader:De,fragmentShader:ye,defines:_.defines,customVertexShaderID:X,customFragmentShaderID:re,isRawShaderMaterial:_.isRawShaderMaterial===!0,glslVersion:_.glslVersion,precision:h,batching:_e,batchingColor:_e&&U._colorsTexture!==null,instancing:Ie,instancingColor:Ie&&U.instanceColor!==null,instancingMorph:Ie&&U.morphTexture!==null,outputColorSpace:se===null?e.outputColorSpace:se.isXRRenderTarget===!0?se.texture.colorSpace:$e.workingColorSpace,alphaToCoverage:!!_.alphaToCoverage,map:Qe,matcap:ze,envMap:Ze,envMapMode:Ze&&H.mapping,envMapCubeUVHeight:F,aoMap:ot,lightMap:Ye,bumpMap:Zt,normalMap:yt,displacementMap:cn,emissiveMap:Dt,normalMapObjectSpace:yt&&_.normalMapType===Qd,normalMapTangentSpace:yt&&_.normalMapType===au,packedNormalMap:yt&&_.normalMapType===au&&kE(_.normalMap.format),metalnessMap:Ot,roughnessMap:L,anisotropy:ln,anisotropyMap:ie,clearcoat:it,clearcoatMap:ae,clearcoatNormalMap:he,clearcoatRoughnessMap:Y,dispersion:wt,retroreflection:w,iridescence:y,iridescenceMap:te,iridescenceThicknessMap:ve,sheen:I,sheenColorMap:Ce,sheenRoughnessMap:fe,specularMap:oe,specularColorMap:Le,specularIntensityMap:Oe,transmission:W,transmissionMap:et,thicknessMap:O,gradientMap:le,opaque:_.transparent===!1&&_.blending===Bs&&_.alphaToCoverage===!1,alphaMap:J,alphaTest:ue,alphaHash:be,combine:_.combine,mapUv:Qe&&g(_.map.channel),aoMapUv:ot&&g(_.aoMap.channel),lightMapUv:Ye&&g(_.lightMap.channel),bumpMapUv:Zt&&g(_.bumpMap.channel),normalMapUv:yt&&g(_.normalMap.channel),displacementMapUv:cn&&g(_.displacementMap.channel),emissiveMapUv:Dt&&g(_.emissiveMap.channel),metalnessMapUv:Ot&&g(_.metalnessMap.channel),roughnessMapUv:L&&g(_.roughnessMap.channel),anisotropyMapUv:ie&&g(_.anisotropyMap.channel),clearcoatMapUv:ae&&g(_.clearcoatMap.channel),clearcoatNormalMapUv:he&&g(_.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Y&&g(_.clearcoatRoughnessMap.channel),iridescenceMapUv:te&&g(_.iridescenceMap.channel),iridescenceThicknessMapUv:ve&&g(_.iridescenceThicknessMap.channel),sheenColorMapUv:Ce&&g(_.sheenColorMap.channel),sheenRoughnessMapUv:fe&&g(_.sheenRoughnessMap.channel),specularMapUv:oe&&g(_.specularMap.channel),specularColorMapUv:Le&&g(_.specularColorMap.channel),specularIntensityMapUv:Oe&&g(_.specularIntensityMap.channel),transmissionMapUv:et&&g(_.transmissionMap.channel),thicknessMapUv:O&&g(_.thicknessMap.channel),alphaMapUv:J&&g(_.alphaMap.channel),vertexTangents:!!V.attributes.tangent&&(yt||ln),vertexNormals:!!V.attributes.normal,vertexColors:_.vertexColors,vertexAlphas:_.vertexColors===!0&&!!V.attributes.color&&V.attributes.color.itemSize===4,pointsUvs:U.isPoints===!0&&!!V.attributes.uv&&(Qe||J),fog:!!P,useFog:_.fog===!0,fogExp2:!!P&&P.isFogExp2,flatShading:_.wireframe===!1&&(_.flatShading===!0||V.attributes.normal===void 0&&yt===!1&&(_.isMeshLambertMaterial||_.isMeshPhongMaterial||_.isMeshStandardMaterial||_.isMeshPhysicalMaterial)),sizeAttenuation:_.sizeAttenuation===!0,logarithmicDepthBuffer:f,reversedDepthBuffer:Te,skinning:U.isSkinnedMesh===!0,hasPositionAttribute:V.attributes.position!==void 0,morphTargets:V.morphAttributes.position!==void 0,morphNormals:V.morphAttributes.normal!==void 0,morphColors:V.morphAttributes.color!==void 0,morphTargetsCount:xe,morphTextureStride:ce,numSunLights:S.sun.length,numDirLights:S.directional.length,numPointLights:S.point.length,numSpotLights:S.spot.length,numSpotLightMaps:S.spotLightMap.length,numRectAreaLights:S.rectArea.length,numHemiLights:S.hemi.length,numSunLightShadows:S.sunShadowMap.length,numDirLightShadows:S.directionalShadowMap.length,numPointLightShadows:S.pointShadowMap.length,numSpotLightShadows:S.spotShadowMap.length,numSpotLightShadowsWithMaps:S.numSpotLightShadowsWithMaps,numLightProbes:S.numLightProbes,numLightProbeGrids:ee.length,numClippingPlanes:s.numPlanes,numClipIntersection:s.numIntersection,dithering:_.dithering,shadowMapEnabled:e.shadowMap.enabled&&k.length>0,shadowMapType:e.shadowMap.type,toneMapping:pe,decodeVideoTexture:Qe&&_.map.isVideoTexture===!0&&$e.getTransfer(_.map.colorSpace)===pt,decodeVideoTextureEmissive:Dt&&_.emissiveMap.isVideoTexture===!0&&$e.getTransfer(_.emissiveMap.colorSpace)===pt,premultipliedAlpha:_.premultipliedAlpha,doubleSided:_.side===Cn,flipSided:_.side===Qt,useDepthPacking:_.depthPacking>=0,depthPacking:_.depthPacking||0,index0AttributeName:_.index0AttributeName,extensionClipCullDistance:ne&&_.extensions.clipCullDistance===!0&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(ne&&_.extensions.multiDraw===!0||_e)&&n.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:_.customProgramCacheKey()};return Be.vertexUv1s=c.has(1),Be.vertexUv2s=c.has(2),Be.vertexUv3s=c.has(3),c.clear(),Be}function p(_){let S=[];if(_.shaderID)S.push(_.shaderID);else S.push(_.customVertexShaderID),S.push(_.customFragmentShaderID);if(_.defines!==void 0)for(let k in _.defines)S.push(k),S.push(_.defines[k]);if(_.isRawShaderMaterial===!1)m(S,_),E(S,_),S.push(e.outputColorSpace);return S.push(_.customProgramCacheKey),S.join()}function m(_,S){_.push(S.precision),_.push(S.outputColorSpace),_.push(S.envMapMode),_.push(S.envMapCubeUVHeight),_.push(S.mapUv),_.push(S.alphaMapUv),_.push(S.lightMapUv),_.push(S.aoMapUv),_.push(S.bumpMapUv),_.push(S.normalMapUv),_.push(S.displacementMapUv),_.push(S.emissiveMapUv),_.push(S.metalnessMapUv),_.push(S.roughnessMapUv),_.push(S.anisotropyMapUv),_.push(S.clearcoatMapUv),_.push(S.clearcoatNormalMapUv),_.push(S.clearcoatRoughnessMapUv),_.push(S.iridescenceMapUv),_.push(S.iridescenceThicknessMapUv),_.push(S.sheenColorMapUv),_.push(S.sheenRoughnessMapUv),_.push(S.specularMapUv),_.push(S.specularColorMapUv),_.push(S.specularIntensityMapUv),_.push(S.transmissionMapUv),_.push(S.thicknessMapUv),_.push(S.combine),_.push(S.fogExp2),_.push(S.sizeAttenuation),_.push(S.morphTargetsCount),_.push(S.morphAttributeCount),_.push(S.numSunLights),_.push(S.numDirLights),_.push(S.numPointLights),_.push(S.numSpotLights),_.push(S.numSpotLightMaps),_.push(S.numHemiLights),_.push(S.numRectAreaLights),_.push(S.numSunLightShadows),_.push(S.numDirLightShadows),_.push(S.numPointLightShadows),_.push(S.numSpotLightShadows),_.push(S.numSpotLightShadowsWithMaps),_.push(S.numLightProbes),_.push(S.shadowMapType),_.push(S.toneMapping),_.push(S.numClippingPlanes),_.push(S.numClipIntersection),_.push(S.depthPacking)}function E(_,S){if(o.disableAll(),S.instancing)o.enable(0);if(S.instancingColor)o.enable(1);if(S.instancingMorph)o.enable(2);if(S.matcap)o.enable(3);if(S.envMap)o.enable(4);if(S.normalMapObjectSpace)o.enable(5);if(S.normalMapTangentSpace)o.enable(6);if(S.clearcoat)o.enable(7);if(S.iridescence)o.enable(8);if(S.alphaTest)o.enable(9);if(S.vertexColors)o.enable(10);if(S.vertexAlphas)o.enable(11);if(S.vertexUv1s)o.enable(12);if(S.vertexUv2s)o.enable(13);if(S.vertexUv3s)o.enable(14);if(S.vertexTangents)o.enable(15);if(S.anisotropy)o.enable(16);if(S.alphaHash)o.enable(17);if(S.batching)o.enable(18);if(S.dispersion)o.enable(19);if(S.retroreflection)o.enable(24);if(S.batchingColor)o.enable(20);if(S.gradientMap)o.enable(21);if(S.packedNormalMap)o.enable(22);if(S.vertexNormals)o.enable(23);if(_.push(o.mask),o.disableAll(),S.fog)o.enable(0);if(S.useFog)o.enable(1);if(S.flatShading)o.enable(2);if(S.logarithmicDepthBuffer)o.enable(3);if(S.reversedDepthBuffer)o.enable(4);if(S.skinning)o.enable(5);if(S.morphTargets)o.enable(6);if(S.morphNormals)o.enable(7);if(S.morphColors)o.enable(8);if(S.premultipliedAlpha)o.enable(9);if(S.shadowMapEnabled)o.enable(10);if(S.doubleSided)o.enable(11);if(S.flipSided)o.enable(12);if(S.useDepthPacking)o.enable(13);if(S.dithering)o.enable(14);if(S.transmission)o.enable(15);if(S.sheen)o.enable(16);if(S.opaque)o.enable(17);if(S.pointsUvs)o.enable(18);if(S.decodeVideoTexture)o.enable(19);if(S.decodeVideoTextureEmissive)o.enable(20);if(S.alphaToCoverage)o.enable(21);if(S.numLightProbeGrids>0)o.enable(22);if(S.hasPositionAttribute)o.enable(23);_.push(o.mask)}function R(_){let S=d[_.type],k;if(S){let C=li[S];k=hp.clone(C.uniforms)}else k=_.uniforms;return k}function v(_,S){let k=u.get(S);if(k!==void 0)++k.usedTimes;else k=new FE(e,S,_,r),l.push(k),u.set(S,k);return k}function M(_){if(--_.usedTimes===0){let S=l.indexOf(_);l[S]=l[l.length-1],l.pop(),u.delete(_.cacheKey),_.destroy()}}function T(_){a.remove(_)}function A(){a.dispose()}return{getParameters:x,getProgramCacheKey:p,getUniforms:R,acquireProgram:v,releaseProgram:M,releaseShaderCache:T,programs:l,dispose:A}}function GE(){let e=new WeakMap;function t(o){return e.has(o)}function n(o){let a=e.get(o);if(a===void 0)a={},e.set(o,a);return a}function i(o){e.delete(o)}function r(o,a,c){e.get(o)[a]=c}function s(){e=new WeakMap}return{has:t,get:n,remove:i,update:r,dispose:s}}function HE(e,t){if(e.groupOrder!==t.groupOrder)return e.groupOrder-t.groupOrder;else if(e.renderOrder!==t.renderOrder)return e.renderOrder-t.renderOrder;else if(e.material.id!==t.material.id)return e.material.id-t.material.id;else if(e.materialVariant!==t.materialVariant)return e.materialVariant-t.materialVariant;else if(e.z!==t.z)return e.z-t.z;else return e.id-t.id}function Up(e,t){if(e.groupOrder!==t.groupOrder)return e.groupOrder-t.groupOrder;else if(e.renderOrder!==t.renderOrder)return e.renderOrder-t.renderOrder;else if(e.z!==t.z)return t.z-e.z;else return e.id-t.id}function Fp(){let e=[],t=0,n=[],i=[],r=[];function s(){t=0,n.length=0,i.length=0,r.length=0}function o(h){let d=0;if(h.isInstancedMesh)d+=2;if(h.isSkinnedMesh)d+=1;return d}function a(h,d,g,x,p,m){let E=e[t];if(E===void 0)E={id:h.id,object:h,geometry:d,material:g,materialVariant:o(h),groupOrder:x,renderOrder:h.renderOrder,z:p,group:m},e[t]=E;else E.id=h.id,E.object=h,E.geometry=d,E.material=g,E.materialVariant=o(h),E.groupOrder=x,E.renderOrder=h.renderOrder,E.z=p,E.group=m;return t++,E}function c(h,d,g,x,p,m,E){if(E.reversedDepth===!0)p=-p;let R=a(h,d,g,x,p,m);if(g.transmission>0)i.push(R);else if(g.transparent===!0)r.push(R);else n.push(R)}function l(h,d,g,x,p,m){let E=a(h,d,g,x,p,m);if(g.transmission>0)i.unshift(E);else if(g.transparent===!0)r.unshift(E);else n.unshift(E)}function u(h,d){if(n.length>1)n.sort(h||HE);if(i.length>1)i.sort(d||Up);if(r.length>1)r.sort(d||Up)}function f(){for(let h=t,d=e.length;h<d;h++){let g=e[h];if(g.id===null)break;g.id=null,g.object=null,g.geometry=null,g.material=null,g.group=null}}return{opaque:n,transmissive:i,transparent:r,init:s,push:c,unshift:l,finish:f,sort:u}}function VE(){let e=new WeakMap;function t(i,r){let s=e.get(i),o;if(s===void 0)o=new Fp,e.set(i,[o]);else if(r>=s.length)o=new Fp,s.push(o);else o=s[r];return o}function n(){e=new WeakMap}return{get:t,dispose:n}}function $E(){let e={};return{get:function(t){if(e[t.id]!==void 0)return e[t.id];let n;switch(t.type){case"SunLight":case"DirectionalLight":n={direction:new D,color:new Ue};break;case"SpotLight":n={position:new D,direction:new D,color:new Ue,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new D,color:new Ue,distance:0,decay:0};break;case"HemisphereLight":n={direction:new D,skyColor:new Ue,groundColor:new Ue};break;case"RectAreaLight":n={color:new Ue,position:new D,halfWidth:new D,halfHeight:new D};break}return e[t.id]=n,n}}}function WE(){let e={};return{get:function(t){if(e[t.id]!==void 0)return e[t.id];let n;switch(t.type){case"SunLight":case"DirectionalLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ne};break;case"SpotLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ne};break;case"PointLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ne,shadowCameraNear:1,shadowCameraFar:1000};break}return e[t.id]=n,n}}}var ZE=0;function XE(e,t){return(t.castShadow?2:0)-(e.castShadow?2:0)+(t.map?1:0)-(e.map?1:0)}function qE(e){let t=new $E,n=WE(),i={version:0,hash:{sunLength:-1,directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numSunShadows:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],sun:[],sunShadow:[],sunShadowMap:[],sunShadowMatrix:[],sunShadowCascade:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let l=0;l<9;l++)i.probe.push(new D);let r=new D,s=new Ge,o=new Ge;function a(l){let u=0,f=0,h=0;for(let U=0;U<9;U++)i.probe[U].set(0,0,0);let d=0,g=0,x=0,p=0,m=0,E=0,R=0,v=0,M=0,T=0,A=0,_=0,S=0,k=0;l.sort(XE);for(let U=0,ee=l.length;U<ee;U++){let P=l[U],{color:V,intensity:j,distance:z}=P,H=null;if(P.shadow&&P.shadow.map)if(P.shadow.map.texture.format===Mr)H=P.shadow.map.texture;else H=P.shadow.map.depthTexture||P.shadow.map.texture;if(P.isAmbientLight)u+=V.r*j,f+=V.g*j,h+=V.b*j;else if(P.isLightProbe){for(let F=0;F<9;F++)i.probe[F].addScaledVector(P.sh.coefficients[F],j);k++}else if(P.isSunLight){let F=t.get(P);if(F.color.copy(P.color).multiplyScalar(P.intensity),P.castShadow){let q=P.shadow,K=n.get(P);K.shadowIntensity=q.intensity,K.shadowBias=q.bias,K.shadowNormalBias=q.normalBias,K.shadowRadius=q.radius,K.shadowMapSize.copy(q.mapSize).multiply(q.getFrameExtents()),i.sunShadow[g]=K,i.sunShadowMap[g]=H;let xe=q.getViewportCount();for(let ce=0;ce<xe;ce++)i.sunShadowMatrix[x+ce]=q.getMatrix(ce),i.sunShadowCascade[x+ce]=q._cascadeData[ce];x+=xe,g++}i.sun[d]=F,d++}else if(P.isDirectionalLight){let F=t.get(P);if(F.color.copy(P.color).multiplyScalar(P.intensity),P.castShadow){let q=P.shadow,K=n.get(P);K.shadowIntensity=q.intensity,K.shadowBias=q.bias,K.shadowNormalBias=q.normalBias,K.shadowRadius=q.radius,K.shadowMapSize=q.mapSize,i.directionalShadow[p]=K,i.directionalShadowMap[p]=H,i.directionalShadowMatrix[p]=P.shadow.matrix,M++}i.directional[p]=F,p++}else if(P.isSpotLight){let F=t.get(P);F.position.setFromMatrixPosition(P.matrixWorld),F.color.copy(V).multiplyScalar(j),F.distance=z,F.coneCos=Math.cos(P.angle),F.penumbraCos=Math.cos(P.angle*(1-P.penumbra)),F.decay=P.decay,i.spot[E]=F;let q=P.shadow;if(P.map){if(i.spotLightMap[_]=P.map,_++,q.updateMatrices(P),P.castShadow)S++}if(i.spotLightMatrix[E]=q.matrix,P.castShadow){let K=n.get(P);K.shadowIntensity=q.intensity,K.shadowBias=q.bias,K.shadowNormalBias=q.normalBias,K.shadowRadius=q.radius,K.shadowMapSize=q.mapSize,i.spotShadow[E]=K,i.spotShadowMap[E]=H,A++}E++}else if(P.isRectAreaLight){let F=t.get(P);F.color.copy(V).multiplyScalar(j),F.halfWidth.set(P.width*0.5,0,0),F.halfHeight.set(0,P.height*0.5,0),i.rectArea[R]=F,R++}else if(P.isPointLight){let F=t.get(P);if(F.color.copy(P.color).multiplyScalar(P.intensity),F.distance=P.distance,F.decay=P.decay,P.castShadow){let q=P.shadow,K=n.get(P);K.shadowIntensity=q.intensity,K.shadowBias=q.bias,K.shadowNormalBias=q.normalBias,K.shadowRadius=q.radius,K.shadowMapSize=q.mapSize,K.shadowCameraNear=q.camera.near,K.shadowCameraFar=q.camera.far,i.pointShadow[m]=K,i.pointShadowMap[m]=H,i.pointShadowMatrix[m]=P.shadow.matrix,T++}i.point[m]=F,m++}else if(P.isHemisphereLight){let F=t.get(P);F.skyColor.copy(P.color).multiplyScalar(j),F.groundColor.copy(P.groundColor).multiplyScalar(j),i.hemi[v]=F,v++}}if(R>0)if(e.has("OES_texture_float_linear")===!0)i.rectAreaLTC1=de.LTC_FLOAT_1,i.rectAreaLTC2=de.LTC_FLOAT_2;else i.rectAreaLTC1=de.LTC_HALF_1,i.rectAreaLTC2=de.LTC_HALF_2;i.ambient[0]=u,i.ambient[1]=f,i.ambient[2]=h;let C=i.hash;if(C.sunLength!==d||C.directionalLength!==p||C.pointLength!==m||C.spotLength!==E||C.rectAreaLength!==R||C.hemiLength!==v||C.numSunShadows!==g||C.numDirectionalShadows!==M||C.numPointShadows!==T||C.numSpotShadows!==A||C.numSpotMaps!==_||C.numLightProbes!==k)i.sun.length=d,i.directional.length=p,i.spot.length=E,i.rectArea.length=R,i.point.length=m,i.hemi.length=v,i.sunShadow.length=g,i.sunShadowMap.length=g,i.sunShadowMatrix.length=x,i.sunShadowCascade.length=x,i.directionalShadow.length=M,i.directionalShadowMap.length=M,i.directionalShadowMatrix.length=M,i.pointShadow.length=T,i.pointShadowMap.length=T,i.pointShadowMatrix.length=T,i.spotShadow.length=A,i.spotShadowMap.length=A,i.spotLightMatrix.length=A+_-S,i.spotLightMap.length=_,i.numSpotLightShadowsWithMaps=S,i.numLightProbes=k,C.sunLength=d,C.directionalLength=p,C.pointLength=m,C.spotLength=E,C.rectAreaLength=R,C.hemiLength=v,C.numSunShadows=g,C.numDirectionalShadows=M,C.numPointShadows=T,C.numSpotShadows=A,C.numSpotMaps=_,C.numLightProbes=k,i.version=ZE++}function c(l,u){let f=0,h=0,d=0,g=0,x=0,p=0,m=u.matrixWorldInverse;for(let E=0,R=l.length;E<R;E++){let v=l[E];if(v.isSunLight){let M=i.sun[f];M.direction.setFromMatrixPosition(v.matrixWorld),M.direction.transformDirection(m),f++}else if(v.isDirectionalLight){let M=i.directional[h];M.direction.setFromMatrixPosition(v.matrixWorld),r.setFromMatrixPosition(v.target.matrixWorld),M.direction.sub(r),M.direction.transformDirection(m),h++}else if(v.isSpotLight){let M=i.spot[g];M.position.setFromMatrixPosition(v.matrixWorld),M.position.applyMatrix4(m),M.direction.setFromMatrixPosition(v.matrixWorld),r.setFromMatrixPosition(v.target.matrixWorld),M.direction.sub(r),M.direction.transformDirection(m),g++}else if(v.isRectAreaLight){let M=i.rectArea[x];M.position.setFromMatrixPosition(v.matrixWorld),M.position.applyMatrix4(m),o.identity(),s.copy(v.matrixWorld),s.premultiply(m),o.extractRotation(s),M.halfWidth.set(v.width*0.5,0,0),M.halfHeight.set(0,v.height*0.5,0),M.halfWidth.applyMatrix4(o),M.halfHeight.applyMatrix4(o),x++}else if(v.isPointLight){let M=i.point[d];M.position.setFromMatrixPosition(v.matrixWorld),M.position.applyMatrix4(m),d++}else if(v.isHemisphereLight){let M=i.hemi[p];M.direction.setFromMatrixPosition(v.matrixWorld),M.direction.transformDirection(m),p++}}}return{setup:a,setupView:c,state:i}}function zp(e){let t=new qE(e),n=[],i=[],r=[];function s(h){f.camera=h,n.length=0,i.length=0,r.length=0}function o(h){n.push(h)}function a(h){i.push(h)}function c(h){r.push(h)}function l(){t.setup(n)}function u(h){t.setupView(n,h)}let f={lightsArray:n,shadowsArray:i,lightProbeGridArray:r,camera:null,lights:t,transmissionRenderTarget:{},textureUnits:0};return{init:s,state:f,setupLights:l,setupLightsView:u,pushLight:o,pushShadow:a,pushLightProbeGrid:c}}function jE(e){let t=new WeakMap;function n(r,s=0){let o=t.get(r),a;if(o===void 0)a=new zp(e),t.set(r,[a]);else if(s>=o.length)a=new zp(e),o.push(a);else a=o[s];return a}function i(){t=new WeakMap}return{get:n,dispose:i}}var YE=`void main() {
4291
+ Program Info Log: `+H+`
4292
+ `+Y+`
4293
+ `+Q)}else if(H!=="")Ie("WebGLProgram: Program Info Log:",H);else if(q===""||C==="")k=!1;if(k)P.diagnostics={runnable:X,programLog:H,vertexShader:{log:q,prefix:p},fragmentShader:{log:C,prefix:m}}}r.deleteShader(M),r.deleteShader(T),_=new po(r,x),S=wE(r,x)}let _;this.getUniforms=function(){if(_===void 0)A(this);return _};let S;this.getAttributes=function(){if(S===void 0)A(this);return S};let z=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){if(z===!1)z=r.getProgramParameter(x,pE);return z},this.destroy=function(){i.releaseStatesOfProgram(this),r.deleteProgram(x),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=mE++,this.cacheKey=t,this.usedTimes=1,this.program=x,this.vertexShader=M,this.fragmentShader=T,this}var BE=0;class Yp{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e,t,n){let i=this._getShaderCacheForMaterial(e);if(i.has(t)===!1)i.add(t),t.usedTimes++;if(i.has(n)===!1)i.add(n),n.usedTimes++;return this}remove(e){let t=this.materialCache.get(e);for(let n of t)if(n.usedTimes--,n.usedTimes===0)this.shaderCache.delete(n.code);return this.materialCache.delete(e),this}getVertexShaderStage(e){return this._getShaderStage(e.vertexShader)}getFragmentShaderStage(e){return this._getShaderStage(e.fragmentShader)}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){let t=this.materialCache,n=t.get(e);if(n===void 0)n=new Set,t.set(e,n);return n}_getShaderStage(e){let t=this.shaderCache,n=t.get(e);if(n===void 0)n=new Kp(e),t.set(e,n);return n}}class Kp{constructor(e){this.id=BE++,this.code=e,this.usedTimes=0}}function GE(e){return e===wr||e===Ra||e===Ca}function HE(e,t,n,i,r,s){let o=new Da,a=new Yp,c=new Set,l=[],u=new Map,{logarithmicDepthBuffer:f,precision:h}=i,d={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distance",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 g(_){if(c.add(_),_===0)return"uv";return`uv${_}`}function x(_,S,z,P,F,ee){let I=P.fog,H=F.geometry,q=_.isMeshStandardMaterial||_.isMeshLambertMaterial||_.isMeshPhongMaterial?P.environment:null,C=_.isMeshStandardMaterial||_.isMeshLambertMaterial&&!_.envMap||_.isMeshPhongMaterial&&!_.envMap,X=t.get(_.envMap||q,C),k=!!X&&X.mapping===Zs?X.image.height:null,Y=d[_.type];if(_.precision!==null){if(h=i.getMaxPrecision(_.precision),h!==_.precision)Ie("WebGLProgram.getParameters:",_.precision,"not supported, using",h,"instead.")}let Q=H.morphAttributes.position||H.morphAttributes.normal||H.morphAttributes.color,Se=Q!==void 0?Q.length:0,ue=0;if(H.morphAttributes.position!==void 0)ue=1;if(H.morphAttributes.normal!==void 0)ue=2;if(H.morphAttributes.color!==void 0)ue=3;let Fe,Me,Z,re;if(Y){let mt=li[Y];Fe=mt.vertexShader,Me=mt.fragmentShader}else{Fe=_.vertexShader,Me=_.fragmentShader;let mt=a.getVertexShaderStage(_),it=a.getFragmentShaderStage(_);a.update(_,mt,it),Z=mt.id,re=it.id}let se=e.getRenderTarget(),xe=e.state.buffers.depth.getReversed(),we=F.isInstancedMesh===!0,Ee=F.isBatchedMesh===!0,xt=!!_.map,ke=!!_.matcap,Ze=!!X,st=!!_.aoMap,Ye=!!_.lightMap,Zt=!!_.bumpMap&&_.wireframe===!1,yt=!!_.normalMap,cn=!!_.displacementMap,Dt=!!_.emissiveMap,Ot=!!_.metalnessMap,N=!!_.roughnessMap,ln=_.anisotropy>0,nt=_.clearcoat>0,wt=_.dispersion>0,w=_.retroreflectivity>0,y=_.iridescence>0,L=_.sheen>0,V=_.transmission>0,ie=ln&&!!_.anisotropyMap,ae=nt&&!!_.clearcoatMap,he=nt&&!!_.clearcoatNormalMap,j=nt&&!!_.clearcoatRoughnessMap,te=y&&!!_.iridescenceMap,_e=y&&!!_.iridescenceThicknessMap,Pe=L&&!!_.sheenColorMap,fe=L&&!!_.sheenRoughnessMap,oe=!!_.specularMap,Le=!!_.specularColorMap,De=!!_.specularIntensityMap,Qe=V&&!!_.transmissionMap,U=V&&!!_.thicknessMap,ce=!!_.gradientMap,K=!!_.alphaMap,le=_.alphaTest>0,ye=!!_.alphaHash,ne=!!_.extensions,pe=Hn;if(_.toneMapped){if(se===null||se.isXRRenderTarget===!0)pe=e.toneMapping}let Be={shaderID:Y,shaderType:_.type,shaderName:_.name,vertexShader:Fe,fragmentShader:Me,defines:_.defines,customVertexShaderID:Z,customFragmentShaderID:re,isRawShaderMaterial:_.isRawShaderMaterial===!0,glslVersion:_.glslVersion,precision:h,batching:Ee,batchingColor:Ee&&F._colorsTexture!==null,instancing:we,instancingColor:we&&F.instanceColor!==null,instancingMorph:we&&F.morphTexture!==null,outputColorSpace:se===null?e.outputColorSpace:se.isXRRenderTarget===!0?se.texture.colorSpace:$e.workingColorSpace,alphaToCoverage:!!_.alphaToCoverage,map:xt,matcap:ke,envMap:Ze,envMapMode:Ze&&X.mapping,envMapCubeUVHeight:k,aoMap:st,lightMap:Ye,bumpMap:Zt,normalMap:yt,displacementMap:cn,emissiveMap:Dt,normalMapObjectSpace:yt&&_.normalMapType===ep,normalMapTangentSpace:yt&&_.normalMapType===cu,packedNormalMap:yt&&_.normalMapType===cu&&GE(_.normalMap.format),metalnessMap:Ot,roughnessMap:N,anisotropy:ln,anisotropyMap:ie,clearcoat:nt,clearcoatMap:ae,clearcoatNormalMap:he,clearcoatRoughnessMap:j,dispersion:wt,retroreflection:w,iridescence:y,iridescenceMap:te,iridescenceThicknessMap:_e,sheen:L,sheenColorMap:Pe,sheenRoughnessMap:fe,specularMap:oe,specularColorMap:Le,specularIntensityMap:De,transmission:V,transmissionMap:Qe,thicknessMap:U,gradientMap:ce,opaque:_.transparent===!1&&_.blending===$s&&_.alphaToCoverage===!1,alphaMap:K,alphaTest:le,alphaHash:ye,combine:_.combine,mapUv:xt&&g(_.map.channel),aoMapUv:st&&g(_.aoMap.channel),lightMapUv:Ye&&g(_.lightMap.channel),bumpMapUv:Zt&&g(_.bumpMap.channel),normalMapUv:yt&&g(_.normalMap.channel),displacementMapUv:cn&&g(_.displacementMap.channel),emissiveMapUv:Dt&&g(_.emissiveMap.channel),metalnessMapUv:Ot&&g(_.metalnessMap.channel),roughnessMapUv:N&&g(_.roughnessMap.channel),anisotropyMapUv:ie&&g(_.anisotropyMap.channel),clearcoatMapUv:ae&&g(_.clearcoatMap.channel),clearcoatNormalMapUv:he&&g(_.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:j&&g(_.clearcoatRoughnessMap.channel),iridescenceMapUv:te&&g(_.iridescenceMap.channel),iridescenceThicknessMapUv:_e&&g(_.iridescenceThicknessMap.channel),sheenColorMapUv:Pe&&g(_.sheenColorMap.channel),sheenRoughnessMapUv:fe&&g(_.sheenRoughnessMap.channel),specularMapUv:oe&&g(_.specularMap.channel),specularColorMapUv:Le&&g(_.specularColorMap.channel),specularIntensityMapUv:De&&g(_.specularIntensityMap.channel),transmissionMapUv:Qe&&g(_.transmissionMap.channel),thicknessMapUv:U&&g(_.thicknessMap.channel),alphaMapUv:K&&g(_.alphaMap.channel),vertexTangents:!!H.attributes.tangent&&(yt||ln),vertexNormals:!!H.attributes.normal,vertexColors:_.vertexColors,vertexAlphas:_.vertexColors===!0&&!!H.attributes.color&&H.attributes.color.itemSize===4,pointsUvs:F.isPoints===!0&&!!H.attributes.uv&&(xt||K),fog:!!I,useFog:_.fog===!0,fogExp2:!!I&&I.isFogExp2,flatShading:_.wireframe===!1&&(_.flatShading===!0||H.attributes.normal===void 0&&yt===!1&&(_.isMeshLambertMaterial||_.isMeshPhongMaterial||_.isMeshStandardMaterial||_.isMeshPhysicalMaterial)),sizeAttenuation:_.sizeAttenuation===!0,logarithmicDepthBuffer:f,reversedDepthBuffer:xe,skinning:F.isSkinnedMesh===!0,hasPositionAttribute:H.attributes.position!==void 0,morphTargets:H.morphAttributes.position!==void 0,morphNormals:H.morphAttributes.normal!==void 0,morphColors:H.morphAttributes.color!==void 0,morphTargetsCount:Se,morphTextureStride:ue,numSunLights:S.sun.length,numDirLights:S.directional.length,numPointLights:S.point.length,numSpotLights:S.spot.length,numSpotLightMaps:S.spotLightMap.length,numRectAreaLights:S.rectArea.length,numHemiLights:S.hemi.length,numSunLightShadows:S.sunShadowMap.length,numDirLightShadows:S.directionalShadowMap.length,numPointLightShadows:S.pointShadowMap.length,numSpotLightShadows:S.spotShadowMap.length,numSpotLightShadowsWithMaps:S.numSpotLightShadowsWithMaps,numLightProbes:S.numLightProbes,numLightProbeGrids:ee.length,numClippingPlanes:s.numPlanes,numClipIntersection:s.numIntersection,dithering:_.dithering,shadowMapEnabled:e.shadowMap.enabled&&z.length>0,shadowMapType:e.shadowMap.type,toneMapping:pe,decodeVideoTexture:xt&&_.map.isVideoTexture===!0&&$e.getTransfer(_.map.colorSpace)===dt,decodeVideoTextureEmissive:Dt&&_.emissiveMap.isVideoTexture===!0&&$e.getTransfer(_.emissiveMap.colorSpace)===dt,premultipliedAlpha:_.premultipliedAlpha,doubleSided:_.side===Pn,flipSided:_.side===Qt,useDepthPacking:_.depthPacking>=0,depthPacking:_.depthPacking||0,index0AttributeName:_.index0AttributeName,extensionClipCullDistance:ne&&_.extensions.clipCullDistance===!0&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(ne&&_.extensions.multiDraw===!0||Ee)&&n.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:_.customProgramCacheKey()};return Be.vertexUv1s=c.has(1),Be.vertexUv2s=c.has(2),Be.vertexUv3s=c.has(3),c.clear(),Be}function p(_){let S=[];if(_.shaderID)S.push(_.shaderID);else S.push(_.customVertexShaderID),S.push(_.customFragmentShaderID);if(_.defines!==void 0)for(let z in _.defines)S.push(z),S.push(_.defines[z]);if(_.isRawShaderMaterial===!1)m(S,_),E(S,_),S.push(e.outputColorSpace);return S.push(_.customProgramCacheKey),S.join()}function m(_,S){_.push(S.precision),_.push(S.outputColorSpace),_.push(S.envMapMode),_.push(S.envMapCubeUVHeight),_.push(S.mapUv),_.push(S.alphaMapUv),_.push(S.lightMapUv),_.push(S.aoMapUv),_.push(S.bumpMapUv),_.push(S.normalMapUv),_.push(S.displacementMapUv),_.push(S.emissiveMapUv),_.push(S.metalnessMapUv),_.push(S.roughnessMapUv),_.push(S.anisotropyMapUv),_.push(S.clearcoatMapUv),_.push(S.clearcoatNormalMapUv),_.push(S.clearcoatRoughnessMapUv),_.push(S.iridescenceMapUv),_.push(S.iridescenceThicknessMapUv),_.push(S.sheenColorMapUv),_.push(S.sheenRoughnessMapUv),_.push(S.specularMapUv),_.push(S.specularColorMapUv),_.push(S.specularIntensityMapUv),_.push(S.transmissionMapUv),_.push(S.thicknessMapUv),_.push(S.combine),_.push(S.fogExp2),_.push(S.sizeAttenuation),_.push(S.morphTargetsCount),_.push(S.morphAttributeCount),_.push(S.numSunLights),_.push(S.numDirLights),_.push(S.numPointLights),_.push(S.numSpotLights),_.push(S.numSpotLightMaps),_.push(S.numHemiLights),_.push(S.numRectAreaLights),_.push(S.numSunLightShadows),_.push(S.numDirLightShadows),_.push(S.numPointLightShadows),_.push(S.numSpotLightShadows),_.push(S.numSpotLightShadowsWithMaps),_.push(S.numLightProbes),_.push(S.shadowMapType),_.push(S.toneMapping),_.push(S.numClippingPlanes),_.push(S.numClipIntersection),_.push(S.depthPacking)}function E(_,S){if(o.disableAll(),S.instancing)o.enable(0);if(S.instancingColor)o.enable(1);if(S.instancingMorph)o.enable(2);if(S.matcap)o.enable(3);if(S.envMap)o.enable(4);if(S.normalMapObjectSpace)o.enable(5);if(S.normalMapTangentSpace)o.enable(6);if(S.clearcoat)o.enable(7);if(S.iridescence)o.enable(8);if(S.alphaTest)o.enable(9);if(S.vertexColors)o.enable(10);if(S.vertexAlphas)o.enable(11);if(S.vertexUv1s)o.enable(12);if(S.vertexUv2s)o.enable(13);if(S.vertexUv3s)o.enable(14);if(S.vertexTangents)o.enable(15);if(S.anisotropy)o.enable(16);if(S.alphaHash)o.enable(17);if(S.batching)o.enable(18);if(S.dispersion)o.enable(19);if(S.retroreflection)o.enable(24);if(S.batchingColor)o.enable(20);if(S.gradientMap)o.enable(21);if(S.packedNormalMap)o.enable(22);if(S.vertexNormals)o.enable(23);if(_.push(o.mask),o.disableAll(),S.fog)o.enable(0);if(S.useFog)o.enable(1);if(S.flatShading)o.enable(2);if(S.logarithmicDepthBuffer)o.enable(3);if(S.reversedDepthBuffer)o.enable(4);if(S.skinning)o.enable(5);if(S.morphTargets)o.enable(6);if(S.morphNormals)o.enable(7);if(S.morphColors)o.enable(8);if(S.premultipliedAlpha)o.enable(9);if(S.shadowMapEnabled)o.enable(10);if(S.doubleSided)o.enable(11);if(S.flipSided)o.enable(12);if(S.useDepthPacking)o.enable(13);if(S.dithering)o.enable(14);if(S.transmission)o.enable(15);if(S.sheen)o.enable(16);if(S.opaque)o.enable(17);if(S.pointsUvs)o.enable(18);if(S.decodeVideoTexture)o.enable(19);if(S.decodeVideoTextureEmissive)o.enable(20);if(S.alphaToCoverage)o.enable(21);if(S.numLightProbeGrids>0)o.enable(22);if(S.hasPositionAttribute)o.enable(23);_.push(o.mask)}function R(_){let S=d[_.type],z;if(S){let P=li[S];z=fp.clone(P.uniforms)}else z=_.uniforms;return z}function v(_,S){let z=u.get(S);if(z!==void 0)++z.usedTimes;else z=new kE(e,S,_,r),l.push(z),u.set(S,z);return z}function M(_){if(--_.usedTimes===0){let S=l.indexOf(_);l[S]=l[l.length-1],l.pop(),u.delete(_.cacheKey),_.destroy()}}function T(_){a.remove(_)}function A(){a.dispose()}return{getParameters:x,getProgramCacheKey:p,getUniforms:R,acquireProgram:v,releaseProgram:M,releaseShaderCache:T,programs:l,dispose:A}}function VE(){let e=new WeakMap;function t(o){return e.has(o)}function n(o){let a=e.get(o);if(a===void 0)a={},e.set(o,a);return a}function i(o){e.delete(o)}function r(o,a,c){e.get(o)[a]=c}function s(){e=new WeakMap}return{has:t,get:n,remove:i,update:r,dispose:s}}function $E(e,t){if(e.groupOrder!==t.groupOrder)return e.groupOrder-t.groupOrder;else if(e.renderOrder!==t.renderOrder)return e.renderOrder-t.renderOrder;else if(e.material.id!==t.material.id)return e.material.id-t.material.id;else if(e.materialVariant!==t.materialVariant)return e.materialVariant-t.materialVariant;else if(e.z!==t.z)return e.z-t.z;else return e.id-t.id}function Fp(e,t){if(e.groupOrder!==t.groupOrder)return e.groupOrder-t.groupOrder;else if(e.renderOrder!==t.renderOrder)return e.renderOrder-t.renderOrder;else if(e.z!==t.z)return t.z-e.z;else return e.id-t.id}function zp(){let e=[],t=0,n=[],i=[],r=[];function s(){t=0,n.length=0,i.length=0,r.length=0}function o(h){let d=0;if(h.isInstancedMesh)d+=2;if(h.isSkinnedMesh)d+=1;return d}function a(h,d,g,x,p,m){let E=e[t];if(E===void 0)E={id:h.id,object:h,geometry:d,material:g,materialVariant:o(h),groupOrder:x,renderOrder:h.renderOrder,z:p,group:m},e[t]=E;else E.id=h.id,E.object=h,E.geometry=d,E.material=g,E.materialVariant=o(h),E.groupOrder=x,E.renderOrder=h.renderOrder,E.z=p,E.group=m;return t++,E}function c(h,d,g,x,p,m,E){if(E.reversedDepth===!0)p=-p;let R=a(h,d,g,x,p,m);if(g.transmission>0)i.push(R);else if(g.transparent===!0)r.push(R);else n.push(R)}function l(h,d,g,x,p,m){let E=a(h,d,g,x,p,m);if(g.transmission>0)i.unshift(E);else if(g.transparent===!0)r.unshift(E);else n.unshift(E)}function u(h,d){if(n.length>1)n.sort(h||$E);if(i.length>1)i.sort(d||Fp);if(r.length>1)r.sort(d||Fp)}function f(){for(let h=t,d=e.length;h<d;h++){let g=e[h];if(g.id===null)break;g.id=null,g.object=null,g.geometry=null,g.material=null,g.group=null}}return{opaque:n,transmissive:i,transparent:r,init:s,push:c,unshift:l,finish:f,sort:u}}function WE(){let e=new WeakMap;function t(i,r){let s=e.get(i),o;if(s===void 0)o=new zp,e.set(i,[o]);else if(r>=s.length)o=new zp,s.push(o);else o=s[r];return o}function n(){e=new WeakMap}return{get:t,dispose:n}}function ZE(){let e={};return{get:function(t){if(e[t.id]!==void 0)return e[t.id];let n;switch(t.type){case"SunLight":case"DirectionalLight":n={direction:new O,color:new Oe};break;case"SpotLight":n={position:new O,direction:new O,color:new Oe,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new O,color:new Oe,distance:0,decay:0};break;case"HemisphereLight":n={direction:new O,skyColor:new Oe,groundColor:new Oe};break;case"RectAreaLight":n={color:new Oe,position:new O,halfWidth:new O,halfHeight:new O};break}return e[t.id]=n,n}}}function XE(){let e={};return{get:function(t){if(e[t.id]!==void 0)return e[t.id];let n;switch(t.type){case"SunLight":case"DirectionalLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ne};break;case"SpotLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ne};break;case"PointLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ne,shadowCameraNear:1,shadowCameraFar:1000};break}return e[t.id]=n,n}}}var qE=0;function jE(e,t){return(t.castShadow?2:0)-(e.castShadow?2:0)+(t.map?1:0)-(e.map?1:0)}function YE(e){let t=new ZE,n=XE(),i={version:0,hash:{sunLength:-1,directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numSunShadows:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],sun:[],sunShadow:[],sunShadowMap:[],sunShadowMatrix:[],sunShadowCascade:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let l=0;l<9;l++)i.probe.push(new O);let r=new O,s=new Ge,o=new Ge;function a(l){let u=0,f=0,h=0;for(let F=0;F<9;F++)i.probe[F].set(0,0,0);let d=0,g=0,x=0,p=0,m=0,E=0,R=0,v=0,M=0,T=0,A=0,_=0,S=0,z=0;l.sort(jE);for(let F=0,ee=l.length;F<ee;F++){let I=l[F],{color:H,intensity:q,distance:C}=I,X=null;if(I.shadow&&I.shadow.map)if(I.shadow.map.texture.format===wr)X=I.shadow.map.texture;else X=I.shadow.map.depthTexture||I.shadow.map.texture;if(I.isAmbientLight)u+=H.r*q,f+=H.g*q,h+=H.b*q;else if(I.isLightProbe){for(let k=0;k<9;k++)i.probe[k].addScaledVector(I.sh.coefficients[k],q);z++}else if(I.isSunLight){let k=t.get(I);if(k.color.copy(I.color).multiplyScalar(I.intensity),I.castShadow){let Y=I.shadow,Q=n.get(I);Q.shadowIntensity=Y.intensity,Q.shadowBias=Y.bias,Q.shadowNormalBias=Y.normalBias,Q.shadowRadius=Y.radius,Q.shadowMapSize.copy(Y.mapSize).multiply(Y.getFrameExtents()),i.sunShadow[g]=Q,i.sunShadowMap[g]=X;let Se=Y.getViewportCount();for(let ue=0;ue<Se;ue++)i.sunShadowMatrix[x+ue]=Y.getMatrix(ue),i.sunShadowCascade[x+ue]=Y._cascadeData[ue];x+=Se,g++}i.sun[d]=k,d++}else if(I.isDirectionalLight){let k=t.get(I);if(k.color.copy(I.color).multiplyScalar(I.intensity),I.castShadow){let Y=I.shadow,Q=n.get(I);Q.shadowIntensity=Y.intensity,Q.shadowBias=Y.bias,Q.shadowNormalBias=Y.normalBias,Q.shadowRadius=Y.radius,Q.shadowMapSize=Y.mapSize,i.directionalShadow[p]=Q,i.directionalShadowMap[p]=X,i.directionalShadowMatrix[p]=I.shadow.matrix,M++}i.directional[p]=k,p++}else if(I.isSpotLight){let k=t.get(I);k.position.setFromMatrixPosition(I.matrixWorld),k.color.copy(H).multiplyScalar(q),k.distance=C,k.coneCos=Math.cos(I.angle),k.penumbraCos=Math.cos(I.angle*(1-I.penumbra)),k.decay=I.decay,i.spot[E]=k;let Y=I.shadow;if(I.map){if(i.spotLightMap[_]=I.map,_++,Y.updateMatrices(I),I.castShadow)S++}if(i.spotLightMatrix[E]=Y.matrix,I.castShadow){let Q=n.get(I);Q.shadowIntensity=Y.intensity,Q.shadowBias=Y.bias,Q.shadowNormalBias=Y.normalBias,Q.shadowRadius=Y.radius,Q.shadowMapSize=Y.mapSize,i.spotShadow[E]=Q,i.spotShadowMap[E]=X,A++}E++}else if(I.isRectAreaLight){let k=t.get(I);k.color.copy(H).multiplyScalar(q),k.halfWidth.set(I.width*0.5,0,0),k.halfHeight.set(0,I.height*0.5,0),i.rectArea[R]=k,R++}else if(I.isPointLight){let k=t.get(I);if(k.color.copy(I.color).multiplyScalar(I.intensity),k.distance=I.distance,k.decay=I.decay,I.castShadow){let Y=I.shadow,Q=n.get(I);Q.shadowIntensity=Y.intensity,Q.shadowBias=Y.bias,Q.shadowNormalBias=Y.normalBias,Q.shadowRadius=Y.radius,Q.shadowMapSize=Y.mapSize,Q.shadowCameraNear=Y.camera.near,Q.shadowCameraFar=Y.camera.far,i.pointShadow[m]=Q,i.pointShadowMap[m]=X,i.pointShadowMatrix[m]=I.shadow.matrix,T++}i.point[m]=k,m++}else if(I.isHemisphereLight){let k=t.get(I);k.skyColor.copy(I.color).multiplyScalar(q),k.groundColor.copy(I.groundColor).multiplyScalar(q),i.hemi[v]=k,v++}}if(R>0)if(e.has("OES_texture_float_linear")===!0)i.rectAreaLTC1=de.LTC_FLOAT_1,i.rectAreaLTC2=de.LTC_FLOAT_2;else i.rectAreaLTC1=de.LTC_HALF_1,i.rectAreaLTC2=de.LTC_HALF_2;i.ambient[0]=u,i.ambient[1]=f,i.ambient[2]=h;let P=i.hash;if(P.sunLength!==d||P.directionalLength!==p||P.pointLength!==m||P.spotLength!==E||P.rectAreaLength!==R||P.hemiLength!==v||P.numSunShadows!==g||P.numDirectionalShadows!==M||P.numPointShadows!==T||P.numSpotShadows!==A||P.numSpotMaps!==_||P.numLightProbes!==z)i.sun.length=d,i.directional.length=p,i.spot.length=E,i.rectArea.length=R,i.point.length=m,i.hemi.length=v,i.sunShadow.length=g,i.sunShadowMap.length=g,i.sunShadowMatrix.length=x,i.sunShadowCascade.length=x,i.directionalShadow.length=M,i.directionalShadowMap.length=M,i.directionalShadowMatrix.length=M,i.pointShadow.length=T,i.pointShadowMap.length=T,i.pointShadowMatrix.length=T,i.spotShadow.length=A,i.spotShadowMap.length=A,i.spotLightMatrix.length=A+_-S,i.spotLightMap.length=_,i.numSpotLightShadowsWithMaps=S,i.numLightProbes=z,P.sunLength=d,P.directionalLength=p,P.pointLength=m,P.spotLength=E,P.rectAreaLength=R,P.hemiLength=v,P.numSunShadows=g,P.numDirectionalShadows=M,P.numPointShadows=T,P.numSpotShadows=A,P.numSpotMaps=_,P.numLightProbes=z,i.version=qE++}function c(l,u){let f=0,h=0,d=0,g=0,x=0,p=0,m=u.matrixWorldInverse;for(let E=0,R=l.length;E<R;E++){let v=l[E];if(v.isSunLight){let M=i.sun[f];M.direction.setFromMatrixPosition(v.matrixWorld),M.direction.transformDirection(m),f++}else if(v.isDirectionalLight){let M=i.directional[h];M.direction.setFromMatrixPosition(v.matrixWorld),r.setFromMatrixPosition(v.target.matrixWorld),M.direction.sub(r),M.direction.transformDirection(m),h++}else if(v.isSpotLight){let M=i.spot[g];M.position.setFromMatrixPosition(v.matrixWorld),M.position.applyMatrix4(m),M.direction.setFromMatrixPosition(v.matrixWorld),r.setFromMatrixPosition(v.target.matrixWorld),M.direction.sub(r),M.direction.transformDirection(m),g++}else if(v.isRectAreaLight){let M=i.rectArea[x];M.position.setFromMatrixPosition(v.matrixWorld),M.position.applyMatrix4(m),o.identity(),s.copy(v.matrixWorld),s.premultiply(m),o.extractRotation(s),M.halfWidth.set(v.width*0.5,0,0),M.halfHeight.set(0,v.height*0.5,0),M.halfWidth.applyMatrix4(o),M.halfHeight.applyMatrix4(o),x++}else if(v.isPointLight){let M=i.point[d];M.position.setFromMatrixPosition(v.matrixWorld),M.position.applyMatrix4(m),d++}else if(v.isHemisphereLight){let M=i.hemi[p];M.direction.setFromMatrixPosition(v.matrixWorld),M.direction.transformDirection(m),p++}}}return{setup:a,setupView:c,state:i}}function kp(e){let t=new YE(e),n=[],i=[],r=[];function s(h){f.camera=h,n.length=0,i.length=0,r.length=0}function o(h){n.push(h)}function a(h){i.push(h)}function c(h){r.push(h)}function l(){t.setup(n)}function u(h){t.setupView(n,h)}let f={lightsArray:n,shadowsArray:i,lightProbeGridArray:r,camera:null,lights:t,transmissionRenderTarget:{},textureUnits:0};return{init:s,state:f,setupLights:l,setupLightsView:u,pushLight:o,pushShadow:a,pushLightProbeGrid:c}}function KE(e){let t=new WeakMap;function n(r,s=0){let o=t.get(r),a;if(o===void 0)a=new kp(e),t.set(r,[a]);else if(s>=o.length)a=new kp(e),o.push(a);else a=o[s];return a}function i(){t=new WeakMap}return{get:n,dispose:i}}var JE=`void main() {
4294
4294
  gl_Position = vec4( position, 1.0 );
4295
- }`,KE=`uniform sampler2D shadow_pass;
4295
+ }`,QE=`uniform sampler2D shadow_pass;
4296
4296
  uniform vec2 resolution;
4297
4297
  uniform float radius;
4298
4298
  void main() {
@@ -4317,12 +4317,12 @@ void main() {
4317
4317
  squared_mean = squared_mean / samples;
4318
4318
  float std_dev = sqrt( max( 0.0, squared_mean - mean * mean ) );
4319
4319
  gl_FragColor = vec4( mean, std_dev, 0.0, 1.0 );
4320
- }`,JE=[new D(1,0,0),new D(-1,0,0),new D(0,1,0),new D(0,-1,0),new D(0,0,1),new D(0,0,-1)],QE=[new D(0,-1,0),new D(0,-1,0),new D(0,0,1),new D(0,0,-1),new D(0,-1,0),new D(0,-1,0)],kp=new Ge,ao=new D,zu=new D;function eT(e,t,n){let i=new Js,r=new Ne,s=new Ne,o=new ct,a=new xu,c=new yu,l={},u=n.maxTextureSize,f={[Xi]:Qt,[Qt]:Xi,[Cn]:Cn},h=new Pn({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Ne},radius:{value:4}},vertexShader:YE,fragmentShader:KE}),d=h.clone();d.defines.HORIZONTAL_PASS=1;let g=new en;g.setAttribute("position",new Vt(new Float32Array([-1,-1,0.5,3,-1,0.5,-1,3,0.5]),3));let x=new xt(g,h),p=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=ks;let m=this.type;this.render=function(T,A,_){if(p.enabled===!1)return;if(p.autoUpdate===!1&&p.needsUpdate===!1)return;if(T.length===0)return;if(this.type===md)Pe("WebGLShadowMap: PCFSoftShadowMap has been removed. Using PCFShadowMap instead."),this.type=ks;let S=e.getRenderTarget(),k=e.getActiveCubeFace(),C=e.getActiveMipmapLevel(),U=e.state;if(U.setBlending(ii),U.buffers.depth.getReversed()===!0)U.buffers.color.setClear(0,0,0,0);else U.buffers.color.setClear(1,1,1,1);U.buffers.depth.setTest(!0),U.setScissorTest(!1);let ee=m!==this.type;if(ee)A.traverse(function(P){if(P.material)if(Array.isArray(P.material))P.material.forEach((V)=>V.needsUpdate=!0);else P.material.needsUpdate=!0});for(let P=0,V=T.length;P<V;P++){let j=T[P],z=j.shadow;if(z===void 0){Pe("WebGLShadowMap:",j,"has no shadow.");continue}if(z.autoUpdate===!1&&z.needsUpdate===!1)continue;r.copy(z.mapSize);let H=z.getFrameExtents();if(r.multiply(H),s.copy(z.mapSize),r.x>u||r.y>u){if(r.x>u)s.x=Math.floor(u/H.x),r.x=s.x*H.x,z.mapSize.x=s.x;if(r.y>u)s.y=Math.floor(u/H.y),r.y=s.y*H.y,z.mapSize.y=s.y}let F=e.state.buffers.depth.getReversed();if(z.camera._reversedDepth=F,z.map===null||ee===!0){if(z.map!==null){if(z.map.depthTexture!==null)z.map.depthTexture.dispose(),z.map.depthTexture=null;z.map.dispose()}if(this.type===is){if(j.isPointLight){Pe("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}z.map=new _n(r.x,r.y,{format:Mr,type:si,minFilter:$t,magFilter:$t,generateMipmaps:!1}),z.map.texture.name=j.name+".shadowMap",z.map.depthTexture=new Er(r.x,r.y,Ai),z.map.depthTexture.name=j.name+".shadowMapDepth",z.map.depthTexture.format=br,z.map.depthTexture.compareFunction=null,z.map.depthTexture.minFilter=Hn,z.map.depthTexture.magFilter=Hn}else{if(j.isPointLight)z.map=new Gu(r.x),z.map.depthTexture=new mu(r.x,qi);else z.map=new _n(r.x,r.y),z.map.depthTexture=new Er(r.x,r.y,qi);if(z.map.depthTexture.name=j.name+".shadowMap",z.map.depthTexture.format=br,this.type===ks)z.map.depthTexture.compareFunction=F?Pa:Ca,z.map.depthTexture.minFilter=$t,z.map.depthTexture.magFilter=$t;else z.map.depthTexture.compareFunction=null,z.map.depthTexture.minFilter=Hn,z.map.depthTexture.magFilter=Hn}z.camera.updateProjectionMatrix()}if(z.map.isWebGLCubeRenderTarget!==!0&&(z.map.width!==r.x||z.map.height!==r.y))z.map.setSize(r.x,r.y);let q=z.map.isWebGLCubeRenderTarget?6:z.getViewportCount();if(j.isPointLight!==!0)z.updateMatrices(j,_);for(let K=0;K<q;K++){let xe=z.getCamera(K);if(j.isPointLight){let{camera:ce,matrix:De}=z,ye=j.distance||ce.far;if(ye!==ce.far)ce.far=ye,ce.updateProjectionMatrix();ao.setFromMatrixPosition(j.matrixWorld),ce.position.copy(ao),zu.copy(ce.position),zu.add(JE[K]),ce.up.copy(QE[K]),ce.lookAt(zu),ce.updateMatrixWorld(),De.makeTranslation(-ao.x,-ao.y,-ao.z),kp.multiplyMatrices(ce.projectionMatrix,ce.matrixWorldInverse),z._frustum.setFromProjectionMatrix(kp,ce.coordinateSystem,ce.reversedDepth)}if(z.map.isWebGLCubeRenderTarget)e.setRenderTarget(z.map,K),e.clear();else{if(K===0)e.setRenderTarget(z.map),e.clear();let ce=z.getViewport(K);o.set(s.x*ce.x,s.y*ce.y,s.x*ce.z,s.y*ce.w),U.viewport(o)}i=z.getFrustum(K),v(A,_,xe,j,this.type)}if(z.isPointLightShadow!==!0&&this.type===is)E(z,_);z.needsUpdate=!1}m=this.type,p.needsUpdate=!1,e.setRenderTarget(S,k,C)};function E(T,A){let _=t.update(x);if(h.defines.VSM_SAMPLES!==T.blurSamples)h.defines.VSM_SAMPLES=T.blurSamples,d.defines.VSM_SAMPLES=T.blurSamples,h.needsUpdate=!0,d.needsUpdate=!0;if(T.mapPass===null)T.mapPass=new _n(r.x,r.y,{format:Mr,type:si});else if(T.mapPass.width!==T.map.width||T.mapPass.height!==T.map.height)T.mapPass.setSize(T.map.width,T.map.height);h.uniforms.shadow_pass.value=T.map.depthTexture,h.uniforms.resolution.value.set(T.map.width,T.map.height),h.uniforms.radius.value=T.radius,e.setRenderTarget(T.mapPass),e.clear(),e.renderBufferDirect(A,null,_,h,x,null),d.uniforms.shadow_pass.value=T.mapPass.texture,d.uniforms.resolution.value.set(T.map.width,T.map.height),d.uniforms.radius.value=T.radius,e.setRenderTarget(T.map),e.clear(),e.renderBufferDirect(A,null,_,d,x,null)}function R(T,A,_,S){let k=null,C=_.isPointLight===!0?T.customDistanceMaterial:T.customDepthMaterial;if(C!==void 0)k=C;else if(k=_.isPointLight===!0?c:a,e.localClippingEnabled&&A.clipShadows===!0&&Array.isArray(A.clippingPlanes)&&A.clippingPlanes.length!==0||A.displacementMap&&A.displacementScale!==0||A.alphaMap&&A.alphaTest>0||A.map&&A.alphaTest>0||A.alphaToCoverage===!0){let U=k.uuid,ee=A.uuid,P=l[U];if(P===void 0)P={},l[U]=P;let V=P[ee];if(V===void 0)V=k.clone(),P[ee]=V,A.addEventListener("dispose",M);k=V}if(k.visible=A.visible,k.wireframe=A.wireframe,S===is)k.side=A.shadowSide!==null?A.shadowSide:A.side;else k.side=A.shadowSide!==null?A.shadowSide:f[A.side];if(k.alphaMap=A.alphaMap,k.alphaTest=A.alphaToCoverage===!0?0.5:A.alphaTest,k.map=A.map,k.clipShadows=A.clipShadows,k.clippingPlanes=A.clippingPlanes,k.clipIntersection=A.clipIntersection,k.displacementMap=A.displacementMap,k.displacementScale=A.displacementScale,k.displacementBias=A.displacementBias,k.wireframeLinewidth=A.wireframeLinewidth,k.linewidth=A.linewidth,_.isPointLight===!0&&k.isMeshDistanceMaterial===!0){let U=e.properties.get(k);U.light=_}return k}function v(T,A,_,S,k){if(T.visible===!1)return;if(T.layers.test(A.layers)&&(T.isMesh||T.isLine||T.isPoints)){if((T.castShadow||T.receiveShadow&&k===is)&&(!T.frustumCulled||T.intersectsFrustum(i))){T.modelViewMatrix.multiplyMatrices(_.matrixWorldInverse,T.matrixWorld);let ee=t.update(T),P=T.material;if(Array.isArray(P)){let V=ee.groups;for(let j=0,z=V.length;j<z;j++){let H=V[j],F=P[H.materialIndex];if(F&&F.visible){let q=R(T,F,S,k);T.onBeforeShadow(e,T,A,_,ee,q,H),e.renderBufferDirect(_,null,ee,q,T,H),T.onAfterShadow(e,T,A,_,ee,q,H)}}}else if(P.visible){let V=R(T,P,S,k);T.onBeforeShadow(e,T,A,_,ee,V,null),e.renderBufferDirect(_,null,ee,V,T,null),T.onAfterShadow(e,T,A,_,ee,V,null)}}}let U=T.children;for(let ee=0,P=U.length;ee<P;ee++)v(U[ee],A,_,S,k)}function M(T){T.target.removeEventListener("dispose",M);for(let _ in l){let S=l[_],k=T.target.uuid;if(k in S)S[k].dispose(),delete S[k]}}}function tT(e,t){function n(){let O=!1,le=new ct,J=null,ue=new ct(0,0,0,0);return{setMask:function(be){if(J!==be&&!O)e.colorMask(be,be,be,be),J=be},setLocked:function(be){O=be},setClear:function(be,ne,pe,Be,gt){if(gt===!0)be*=Be,ne*=Be,pe*=Be;if(le.set(be,ne,pe,Be),ue.equals(le)===!1)e.clearColor(be,ne,pe,Be),ue.copy(le)},reset:function(){O=!1,J=null,ue.set(-1,0,0,0)}}}function i(){let O=!1,le=!1,J=null,ue=null,be=null;return{setReversed:function(ne){if(le!==ne){let pe=t.get("EXT_clip_control");if(ne)pe.clipControlEXT(pe.LOWER_LEFT_EXT,pe.ZERO_TO_ONE_EXT);else pe.clipControlEXT(pe.LOWER_LEFT_EXT,pe.NEGATIVE_ONE_TO_ONE_EXT);le=ne;let Be=be;be=null,this.setClear(Be)}},getReversed:function(){return le},setTest:function(ne){if(ne)se(e.DEPTH_TEST);else Te(e.DEPTH_TEST)},setMask:function(ne){if(J!==ne&&!O)e.depthMask(ne),J=ne},setFunc:function(ne){if(le)ne=lp[ne];if(ue!==ne){switch(ne){case Ud:e.depthFunc(e.NEVER);break;case Fd:e.depthFunc(e.ALWAYS);break;case zd:e.depthFunc(e.LESS);break;case gl:e.depthFunc(e.LEQUAL);break;case kd:e.depthFunc(e.EQUAL);break;case Bd:e.depthFunc(e.GEQUAL);break;case Gd:e.depthFunc(e.GREATER);break;case Hd:e.depthFunc(e.NOTEQUAL);break;default:e.depthFunc(e.LEQUAL)}ue=ne}},setLocked:function(ne){O=ne},setClear:function(ne){if(be!==ne){if(be=ne,le)ne=1-ne;e.clearDepth(ne)}},reset:function(){O=!1,J=null,ue=null,be=null,le=!1}}}function r(){let O=!1,le=null,J=null,ue=null,be=null,ne=null,pe=null,Be=null,gt=null;return{setTest:function(rt){if(!O)if(rt)se(e.STENCIL_TEST);else Te(e.STENCIL_TEST)},setMask:function(rt){if(le!==rt&&!O)e.stencilMask(rt),le=rt},setFunc:function(rt,Kn,yi){if(J!==rt||ue!==Kn||be!==yi)e.stencilFunc(rt,Kn,yi),J=rt,ue=Kn,be=yi},setOp:function(rt,Kn,yi){if(ne!==rt||pe!==Kn||Be!==yi)e.stencilOp(rt,Kn,yi),ne=rt,pe=Kn,Be=yi},setLocked:function(rt){O=rt},setClear:function(rt){if(gt!==rt)e.clearStencil(rt),gt=rt},reset:function(){O=!1,le=null,J=null,ue=null,be=null,ne=null,pe=null,Be=null,gt=null}}}let s=new n,o=new i,a=new r,c=new WeakMap,l=new WeakMap,u={},f={},h={},d=new WeakMap,g=[],x=null,p=!1,m=null,E=null,R=null,v=null,M=null,T=null,A=null,_=new Ue(0,0,0),S=0,k=!1,C=null,U=null,ee=null,P=null,V=null,j=e.getParameter(e.MAX_COMBINED_TEXTURE_IMAGE_UNITS),z=!1,H=0,F=e.getParameter(e.VERSION);if(F.indexOf("WebGL")!==-1)H=parseFloat(/^WebGL (\d)/.exec(F)[1]),z=H>=1;else if(F.indexOf("OpenGL ES")!==-1)H=parseFloat(/^OpenGL ES (\d)/.exec(F)[1]),z=H>=2;let q=null,K={},xe=e.getParameter(e.SCISSOR_BOX),ce=e.getParameter(e.VIEWPORT),De=new ct().fromArray(xe),ye=new ct().fromArray(ce);function X(O,le,J,ue){let be=new Uint8Array(4),ne=e.createTexture();e.bindTexture(O,ne),e.texParameteri(O,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(O,e.TEXTURE_MAG_FILTER,e.NEAREST);for(let pe=0;pe<J;pe++)if(O===e.TEXTURE_3D||O===e.TEXTURE_2D_ARRAY)e.texImage3D(le,0,e.RGBA,1,1,ue,0,e.RGBA,e.UNSIGNED_BYTE,be);else e.texImage2D(le+pe,0,e.RGBA,1,1,0,e.RGBA,e.UNSIGNED_BYTE,be);return ne}let re={};re[e.TEXTURE_2D]=X(e.TEXTURE_2D,e.TEXTURE_2D,1),re[e.TEXTURE_CUBE_MAP]=X(e.TEXTURE_CUBE_MAP,e.TEXTURE_CUBE_MAP_POSITIVE_X,6),re[e.TEXTURE_2D_ARRAY]=X(e.TEXTURE_2D_ARRAY,e.TEXTURE_2D_ARRAY,1,1),re[e.TEXTURE_3D]=X(e.TEXTURE_3D,e.TEXTURE_3D,1,1),s.setClear(0,0,0,1),o.setClear(1),a.setClear(0),se(e.DEPTH_TEST),o.setFunc(gl),Zt(!1),yt(fl),se(e.CULL_FACE),ot(ii);function se(O){if(u[O]!==!0)e.enable(O),u[O]=!0}function Te(O){if(u[O]!==!1)e.disable(O),u[O]=!1}function Ie(O,le){if(h[O]!==le){if(e.bindFramebuffer(O,le),h[O]=le,O===e.DRAW_FRAMEBUFFER)h[e.FRAMEBUFFER]=le;if(O===e.FRAMEBUFFER)h[e.DRAW_FRAMEBUFFER]=le;return!0}return!1}function _e(O,le){let J=g,ue=!1;if(O){if(J=d.get(le),J===void 0)J=[],d.set(le,J);let be=O.textures;if(J.length!==be.length||J[0]!==e.COLOR_ATTACHMENT0){for(let ne=0,pe=be.length;ne<pe;ne++)J[ne]=e.COLOR_ATTACHMENT0+ne;J.length=be.length,ue=!0}}else if(J[0]!==e.BACK)J[0]=e.BACK,ue=!0;if(ue)e.drawBuffers(J)}function Qe(O){if(x!==O)return e.useProgram(O),x=O,!0;return!1}let ze={[rs]:e.FUNC_ADD,[_d]:e.FUNC_SUBTRACT,[xd]:e.FUNC_REVERSE_SUBTRACT};ze[yd]=e.MIN,ze[vd]=e.MAX;let Ze={[bd]:e.ZERO,[Sd]:e.ONE,[Md]:e.SRC_COLOR,[Ed]:e.SRC_ALPHA,[Id]:e.SRC_ALPHA_SATURATE,[Cd]:e.DST_COLOR,[Ad]:e.DST_ALPHA,[wd]:e.ONE_MINUS_SRC_COLOR,[Td]:e.ONE_MINUS_SRC_ALPHA,[Pd]:e.ONE_MINUS_DST_COLOR,[Rd]:e.ONE_MINUS_DST_ALPHA,[Ld]:e.CONSTANT_COLOR,[Nd]:e.ONE_MINUS_CONSTANT_COLOR,[Dd]:e.CONSTANT_ALPHA,[Od]:e.ONE_MINUS_CONSTANT_ALPHA};function ot(O,le,J,ue,be,ne,pe,Be,gt,rt){if(O===ii){if(p===!0)Te(e.BLEND),p=!1;return}if(p===!1)se(e.BLEND),p=!0;if(O!==gd){if(O!==m||rt!==k){if(E!==rs||M!==rs)e.blendEquation(e.FUNC_ADD),E=rs,M=rs;if(rt)switch(O){case Bs:e.blendFuncSeparate(e.ONE,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case dl:e.blendFunc(e.ONE,e.ONE);break;case pl:e.blendFuncSeparate(e.ZERO,e.ONE_MINUS_SRC_COLOR,e.ZERO,e.ONE);break;case ml:e.blendFuncSeparate(e.DST_COLOR,e.ONE_MINUS_SRC_ALPHA,e.ZERO,e.ONE);break;default:Fe("WebGLState: Invalid blending: ",O);break}else switch(O){case Bs:e.blendFuncSeparate(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case dl:e.blendFuncSeparate(e.SRC_ALPHA,e.ONE,e.ONE,e.ONE);break;case pl:Fe("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case ml:Fe("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:Fe("WebGLState: Invalid blending: ",O);break}R=null,v=null,T=null,A=null,_.set(0,0,0),S=0,m=O,k=rt}return}if(be=be||le,ne=ne||J,pe=pe||ue,le!==E||be!==M)e.blendEquationSeparate(ze[le],ze[be]),E=le,M=be;if(J!==R||ue!==v||ne!==T||pe!==A)e.blendFuncSeparate(Ze[J],Ze[ue],Ze[ne],Ze[pe]),R=J,v=ue,T=ne,A=pe;if(Be.equals(_)===!1||gt!==S)e.blendColor(Be.r,Be.g,Be.b,gt),_.copy(Be),S=gt;m=O,k=!1}function Ye(O,le){O.side===Cn?Te(e.CULL_FACE):se(e.CULL_FACE);let J=O.side===Qt;if(le)J=!J;Zt(J),O.blending===Bs&&O.transparent===!1?ot(ii):ot(O.blending,O.blendEquation,O.blendSrc,O.blendDst,O.blendEquationAlpha,O.blendSrcAlpha,O.blendDstAlpha,O.blendColor,O.blendAlpha,O.premultipliedAlpha),o.setFunc(O.depthFunc),o.setTest(O.depthTest),o.setMask(O.depthWrite),s.setMask(O.colorWrite);let ue=O.stencilWrite;if(a.setTest(ue),ue)a.setMask(O.stencilWriteMask),a.setFunc(O.stencilFunc,O.stencilRef,O.stencilFuncMask),a.setOp(O.stencilFail,O.stencilZFail,O.stencilZPass);Dt(O.polygonOffset,O.polygonOffsetFactor,O.polygonOffsetUnits),O.alphaToCoverage===!0?se(e.SAMPLE_ALPHA_TO_COVERAGE):Te(e.SAMPLE_ALPHA_TO_COVERAGE)}function Zt(O){if(C!==O){if(O)e.frontFace(e.CW);else e.frontFace(e.CCW);C=O}}function yt(O){if(O!==dd){if(se(e.CULL_FACE),O!==U)if(O===fl)e.cullFace(e.BACK);else if(O===pd)e.cullFace(e.FRONT);else e.cullFace(e.FRONT_AND_BACK)}else Te(e.CULL_FACE);U=O}function cn(O){if(O!==ee){if(z)e.lineWidth(O);ee=O}}function Dt(O,le,J){if(O){if(se(e.POLYGON_OFFSET_FILL),P!==le||V!==J){if(P=le,V=J,o.getReversed())le=-le;e.polygonOffset(le,J)}}else Te(e.POLYGON_OFFSET_FILL)}function Ot(O){if(O)se(e.SCISSOR_TEST);else Te(e.SCISSOR_TEST)}function L(O){if(O===void 0)O=e.TEXTURE0+j-1;if(q!==O)e.activeTexture(O),q=O}function ln(O,le,J){if(J===void 0)if(q===null)J=e.TEXTURE0+j-1;else J=q;let ue=K[J];if(ue===void 0)ue={type:void 0,texture:void 0},K[J]=ue;if(ue.type!==O||ue.texture!==le){if(q!==J)e.activeTexture(J),q=J;e.bindTexture(O,le||re[O]),ue.type=O,ue.texture=le}}function it(){let O=K[q];if(O!==void 0&&O.type!==void 0)e.bindTexture(O.type,null),O.type=void 0,O.texture=void 0}function wt(){try{e.compressedTexImage2D(...arguments)}catch(O){Fe("WebGLState:",O)}}function w(){try{e.compressedTexImage3D(...arguments)}catch(O){Fe("WebGLState:",O)}}function y(){try{e.texSubImage2D(...arguments)}catch(O){Fe("WebGLState:",O)}}function I(){try{e.texSubImage3D(...arguments)}catch(O){Fe("WebGLState:",O)}}function W(){try{e.compressedTexSubImage2D(...arguments)}catch(O){Fe("WebGLState:",O)}}function ie(){try{e.compressedTexSubImage3D(...arguments)}catch(O){Fe("WebGLState:",O)}}function ae(){try{e.texStorage2D(...arguments)}catch(O){Fe("WebGLState:",O)}}function he(){try{e.texStorage3D(...arguments)}catch(O){Fe("WebGLState:",O)}}function Y(){try{e.texImage2D(...arguments)}catch(O){Fe("WebGLState:",O)}}function te(){try{e.texImage3D(...arguments)}catch(O){Fe("WebGLState:",O)}}function ve(O){if(f[O]!==void 0)return f[O];else return e.getParameter(O)}function Ce(O,le){if(f[O]!==le)e.pixelStorei(O,le),f[O]=le}function fe(O){if(De.equals(O)===!1)e.scissor(O.x,O.y,O.z,O.w),De.copy(O)}function oe(O){if(ye.equals(O)===!1)e.viewport(O.x,O.y,O.z,O.w),ye.copy(O)}function Le(O,le){let J=l.get(le);if(J===void 0)J=new WeakMap,l.set(le,J);let ue=J.get(O);if(ue===void 0)ue=e.getUniformBlockIndex(le,O.name),J.set(O,ue)}function Oe(O,le){let ue=l.get(le).get(O);if(c.get(le)!==ue)e.uniformBlockBinding(le,ue,O.__bindingPointIndex),c.set(le,ue)}function et(){e.disable(e.BLEND),e.disable(e.CULL_FACE),e.disable(e.DEPTH_TEST),e.disable(e.POLYGON_OFFSET_FILL),e.disable(e.SCISSOR_TEST),e.disable(e.STENCIL_TEST),e.disable(e.SAMPLE_ALPHA_TO_COVERAGE),e.blendEquation(e.FUNC_ADD),e.blendFunc(e.ONE,e.ZERO),e.blendFuncSeparate(e.ONE,e.ZERO,e.ONE,e.ZERO),e.blendColor(0,0,0,0),e.colorMask(!0,!0,!0,!0),e.clearColor(0,0,0,0),e.depthMask(!0),e.depthFunc(e.LESS),o.setReversed(!1),e.clearDepth(1),e.stencilMask(4294967295),e.stencilFunc(e.ALWAYS,0,4294967295),e.stencilOp(e.KEEP,e.KEEP,e.KEEP),e.clearStencil(0),e.cullFace(e.BACK),e.frontFace(e.CCW),e.polygonOffset(0,0),e.activeTexture(e.TEXTURE0),e.bindFramebuffer(e.FRAMEBUFFER,null),e.bindFramebuffer(e.DRAW_FRAMEBUFFER,null),e.bindFramebuffer(e.READ_FRAMEBUFFER,null),e.useProgram(null),e.lineWidth(1),e.scissor(0,0,e.canvas.width,e.canvas.height),e.viewport(0,0,e.canvas.width,e.canvas.height),e.pixelStorei(e.PACK_ALIGNMENT,4),e.pixelStorei(e.UNPACK_ALIGNMENT,4),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,!1),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,e.BROWSER_DEFAULT_WEBGL),e.pixelStorei(e.PACK_ROW_LENGTH,0),e.pixelStorei(e.PACK_SKIP_PIXELS,0),e.pixelStorei(e.PACK_SKIP_ROWS,0),e.pixelStorei(e.UNPACK_ROW_LENGTH,0),e.pixelStorei(e.UNPACK_IMAGE_HEIGHT,0),e.pixelStorei(e.UNPACK_SKIP_PIXELS,0),e.pixelStorei(e.UNPACK_SKIP_ROWS,0),e.pixelStorei(e.UNPACK_SKIP_IMAGES,0),u={},f={},q=null,K={},h={},d=new WeakMap,g=[],x=null,p=!1,m=null,E=null,R=null,v=null,M=null,T=null,A=null,_=new Ue(0,0,0),S=0,k=!1,C=null,U=null,ee=null,P=null,V=null,De.set(0,0,e.canvas.width,e.canvas.height),ye.set(0,0,e.canvas.width,e.canvas.height),s.reset(),o.reset(),a.reset()}return{buffers:{color:s,depth:o,stencil:a},enable:se,disable:Te,bindFramebuffer:Ie,drawBuffers:_e,useProgram:Qe,setBlending:ot,setMaterial:Ye,setFlipSided:Zt,setCullFace:yt,setLineWidth:cn,setPolygonOffset:Dt,setScissorTest:Ot,activeTexture:L,bindTexture:ln,unbindTexture:it,compressedTexImage2D:wt,compressedTexImage3D:w,texImage2D:Y,texImage3D:te,pixelStorei:Ce,getParameter:ve,updateUBOMapping:Le,uniformBlockBinding:Oe,texStorage2D:ae,texStorage3D:he,texSubImage2D:y,texSubImage3D:I,compressedTexSubImage2D:W,compressedTexSubImage3D:ie,scissor:fe,viewport:oe,reset:et}}function nT(e,t,n,i,r,s,o){let a=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):null,c=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),l=new Ne,u=new WeakMap,f=new Set,h,d=new WeakMap,g=!1;try{g=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch(w){}function x(w,y){return g?new OffscreenCanvas(w,y):es("canvas")}function p(w,y,I){let W=1,ie=wt(w);if(ie.width>I||ie.height>I)W=I/Math.max(ie.width,ie.height);if(W<1)if(typeof HTMLImageElement<"u"&&w instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&w instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&w instanceof ImageBitmap||typeof VideoFrame<"u"&&w instanceof VideoFrame){let ae=Math.floor(W*ie.width),he=Math.floor(W*ie.height);if(h===void 0)h=x(ae,he);let Y=y?x(ae,he):h;return Y.width=ae,Y.height=he,Y.getContext("2d").drawImage(w,0,0,ae,he),Pe("WebGLRenderer: Texture has been resized from ("+ie.width+"x"+ie.height+") to ("+ae+"x"+he+")."),Y}else{if("data"in w)Pe("WebGLRenderer: Image in DataTexture is too big ("+ie.width+"x"+ie.height+").");return w}return w}function m(w){return w.generateMipmaps}function E(w){e.generateMipmap(w)}function R(w){if(w.isWebGLCubeRenderTarget)return e.TEXTURE_CUBE_MAP;if(w.isWebGL3DRenderTarget)return e.TEXTURE_3D;if(w.isWebGLArrayRenderTarget||w.isCompressedArrayTexture)return e.TEXTURE_2D_ARRAY;return e.TEXTURE_2D}function v(w,y,I,W,ie,ae=!1){if(w!==null){if(e[w]!==void 0)return e[w];Pe("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+w+"'")}let he;if(W){if(he=t.get("EXT_texture_norm16"),!he)Pe("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension")}let Y=y;if(y===e.RED){if(I===e.FLOAT)Y=e.R32F;if(I===e.HALF_FLOAT)Y=e.R16F;if(I===e.UNSIGNED_BYTE)Y=e.R8;if(I===e.UNSIGNED_SHORT&&he)Y=he.R16_EXT;if(I===e.SHORT&&he)Y=he.R16_SNORM_EXT}if(y===e.RED_INTEGER){if(I===e.UNSIGNED_BYTE)Y=e.R8UI;if(I===e.UNSIGNED_SHORT)Y=e.R16UI;if(I===e.UNSIGNED_INT)Y=e.R32UI;if(I===e.BYTE)Y=e.R8I;if(I===e.SHORT)Y=e.R16I;if(I===e.INT)Y=e.R32I}if(y===e.RG){if(I===e.FLOAT)Y=e.RG32F;if(I===e.HALF_FLOAT)Y=e.RG16F;if(I===e.UNSIGNED_BYTE)Y=e.RG8;if(I===e.UNSIGNED_SHORT&&he)Y=he.RG16_EXT;if(I===e.SHORT&&he)Y=he.RG16_SNORM_EXT}if(y===e.RG_INTEGER){if(I===e.UNSIGNED_BYTE)Y=e.RG8UI;if(I===e.UNSIGNED_SHORT)Y=e.RG16UI;if(I===e.UNSIGNED_INT)Y=e.RG32UI;if(I===e.BYTE)Y=e.RG8I;if(I===e.SHORT)Y=e.RG16I;if(I===e.INT)Y=e.RG32I}if(y===e.RGB_INTEGER){if(I===e.UNSIGNED_BYTE)Y=e.RGB8UI;if(I===e.UNSIGNED_SHORT)Y=e.RGB16UI;if(I===e.UNSIGNED_INT)Y=e.RGB32UI;if(I===e.BYTE)Y=e.RGB8I;if(I===e.SHORT)Y=e.RGB16I;if(I===e.INT)Y=e.RGB32I}if(y===e.RGBA_INTEGER){if(I===e.UNSIGNED_BYTE)Y=e.RGBA8UI;if(I===e.UNSIGNED_SHORT)Y=e.RGBA16UI;if(I===e.UNSIGNED_INT)Y=e.RGBA32UI;if(I===e.BYTE)Y=e.RGBA8I;if(I===e.SHORT)Y=e.RGBA16I;if(I===e.INT)Y=e.RGBA32I}if(y===e.RGB){if(I===e.UNSIGNED_SHORT&&he)Y=he.RGB16_EXT;if(I===e.SHORT&&he)Y=he.RGB16_SNORM_EXT;if(I===e.UNSIGNED_INT_5_9_9_9_REV)Y=e.RGB9_E5;if(I===e.UNSIGNED_INT_10F_11F_11F_REV)Y=e.R11F_G11F_B10F}if(y===e.RGBA){let te=ae?cu:$e.getTransfer(ie);if(I===e.FLOAT)Y=e.RGBA32F;if(I===e.HALF_FLOAT)Y=e.RGBA16F;if(I===e.UNSIGNED_BYTE)Y=te===pt?e.SRGB8_ALPHA8:e.RGBA8;if(I===e.UNSIGNED_SHORT&&he)Y=he.RGBA16_EXT;if(I===e.SHORT&&he)Y=he.RGBA16_SNORM_EXT;if(I===e.UNSIGNED_SHORT_4_4_4_4)Y=e.RGBA4;if(I===e.UNSIGNED_SHORT_5_5_5_1)Y=e.RGB5_A1}if(Y===e.R16F||Y===e.R32F||Y===e.RG16F||Y===e.RG32F||Y===e.RGBA16F||Y===e.RGBA32F)t.get("EXT_color_buffer_float");return Y}function M(w,y){let I;if(w){if(y===null||y===qi||y===ls)I=e.DEPTH24_STENCIL8;else if(y===Ai)I=e.DEPTH32F_STENCIL8;else if(y===Vs)I=e.DEPTH24_STENCIL8,Pe("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")}else if(y===null||y===qi||y===ls)I=e.DEPTH_COMPONENT24;else if(y===Ai)I=e.DEPTH_COMPONENT32F;else if(y===Vs)I=e.DEPTH_COMPONENT16;return I}function T(w,y){if(m(w)===!0||w.isFramebufferTexture&&w.minFilter!==Hn&&w.minFilter!==$t)return Math.log2(Math.max(y.width,y.height))+1;else if(w.mipmaps!==void 0&&w.mipmaps.length>0)return w.mipmaps.length;else if(w.isCompressedTexture&&Array.isArray(w.image))return y.mipmaps.length;else return 1}function A(w){let y=w.target;if(y.removeEventListener("dispose",A),S(y),y.isVideoTexture)u.delete(y);if(y.isHTMLTexture)f.delete(y)}function _(w){let y=w.target;y.removeEventListener("dispose",_),C(y)}function S(w){let y=i.get(w);if(y.__webglInit===void 0)return;let I=w.source,W=d.get(I);if(W){let ie=W[y.__cacheKey];if(ie.usedTimes--,ie.usedTimes===0)k(w);if(Object.keys(W).length===0)d.delete(I)}i.remove(w)}function k(w){let y=i.get(w);e.deleteTexture(y.__webglTexture);let I=w.source,W=d.get(I);delete W[y.__cacheKey],o.memory.textures--}function C(w){let y=i.get(w);if(w.depthTexture)w.depthTexture.dispose(),i.remove(w.depthTexture);if(w.isWebGLCubeRenderTarget)for(let W=0;W<6;W++){if(Array.isArray(y.__webglFramebuffer[W]))for(let ie=0;ie<y.__webglFramebuffer[W].length;ie++)e.deleteFramebuffer(y.__webglFramebuffer[W][ie]);else e.deleteFramebuffer(y.__webglFramebuffer[W]);if(y.__webglDepthbuffer)e.deleteRenderbuffer(y.__webglDepthbuffer[W])}else{if(Array.isArray(y.__webglFramebuffer))for(let W=0;W<y.__webglFramebuffer.length;W++)e.deleteFramebuffer(y.__webglFramebuffer[W]);else e.deleteFramebuffer(y.__webglFramebuffer);if(y.__webglDepthbuffer)e.deleteRenderbuffer(y.__webglDepthbuffer);if(y.__webglMultisampledFramebuffer)e.deleteFramebuffer(y.__webglMultisampledFramebuffer);if(y.__webglColorRenderbuffer){for(let W=0;W<y.__webglColorRenderbuffer.length;W++)if(y.__webglColorRenderbuffer[W])e.deleteRenderbuffer(y.__webglColorRenderbuffer[W])}if(y.__webglDepthRenderbuffer)e.deleteRenderbuffer(y.__webglDepthRenderbuffer)}let I=w.textures;for(let W=0,ie=I.length;W<ie;W++){let ae=i.get(I[W]);if(ae.__webglTexture)e.deleteTexture(ae.__webglTexture),o.memory.textures--;i.remove(I[W])}i.remove(w)}let U=0;function ee(){U=0}function P(){return U}function V(w){U=w}function j(){let w=U;if(w>=r.maxTextures)Pe("WebGLTextures: Trying to use "+(w+1)+" texture units while this GPU supports only "+r.maxTextures);return U+=1,w}function z(w){let y=[];return y.push(w.wrapS),y.push(w.wrapT),y.push(w.wrapR||0),y.push(w.magFilter),y.push(w.minFilter),y.push(w.anisotropy),y.push(w.internalFormat),y.push(w.format),y.push(w.type),y.push(w.generateMipmaps),y.push(w.premultiplyAlpha),y.push(w.flipY),y.push(w.unpackAlignment),y.push(w.colorSpace),y.join()}function H(w,y){let I=i.get(w);if(w.isVideoTexture)ln(w);if(w.isRenderTargetTexture===!1&&w.isExternalTexture!==!0&&w.version>0&&I.__version!==w.version){let W=w.image;if(W===null)Pe("WebGLRenderer: Texture marked for update but no image data found.");else if(W.complete===!1)Pe("WebGLRenderer: Texture marked for update but image is incomplete");else{Te(I,w,y);return}}else if(w.isExternalTexture)I.__webglTexture=w.sourceTexture?w.sourceTexture:null;n.bindTexture(e.TEXTURE_2D,I.__webglTexture,e.TEXTURE0+y)}function F(w,y){let I=i.get(w);if(w.isRenderTargetTexture===!1&&w.version>0&&I.__version!==w.version){Te(I,w,y);return}else if(w.isExternalTexture)I.__webglTexture=w.sourceTexture?w.sourceTexture:null;n.bindTexture(e.TEXTURE_2D_ARRAY,I.__webglTexture,e.TEXTURE0+y)}function q(w,y){let I=i.get(w);if(w.isRenderTargetTexture===!1&&w.version>0&&I.__version!==w.version){Te(I,w,y);return}n.bindTexture(e.TEXTURE_3D,I.__webglTexture,e.TEXTURE0+y)}function K(w,y){let I=i.get(w);if(w.isCubeDepthTexture!==!0&&w.version>0&&I.__version!==w.version){Ie(I,w,y);return}n.bindTexture(e.TEXTURE_CUBE_MAP,I.__webglTexture,e.TEXTURE0+y)}let xe={[os]:e.REPEAT,[as]:e.CLAMP_TO_EDGE,[va]:e.MIRRORED_REPEAT},ce={[Hn]:e.NEAREST,[ba]:e.NEAREST_MIPMAP_NEAREST,[vr]:e.NEAREST_MIPMAP_LINEAR,[$t]:e.LINEAR,[cs]:e.LINEAR_MIPMAP_NEAREST,[ri]:e.LINEAR_MIPMAP_LINEAR},De={[ep]:e.NEVER,[sp]:e.ALWAYS,[tp]:e.LESS,[Ca]:e.LEQUAL,[np]:e.EQUAL,[Pa]:e.GEQUAL,[ip]:e.GREATER,[rp]:e.NOTEQUAL};function ye(w,y){if(y.type===Ai&&t.has("OES_texture_float_linear")===!1&&(y.magFilter===$t||y.magFilter===cs||y.magFilter===vr||y.magFilter===ri||y.minFilter===$t||y.minFilter===cs||y.minFilter===vr||y.minFilter===ri))Pe("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device.");if(e.texParameteri(w,e.TEXTURE_WRAP_S,xe[y.wrapS]),e.texParameteri(w,e.TEXTURE_WRAP_T,xe[y.wrapT]),w===e.TEXTURE_3D||w===e.TEXTURE_2D_ARRAY)e.texParameteri(w,e.TEXTURE_WRAP_R,xe[y.wrapR]);if(e.texParameteri(w,e.TEXTURE_MAG_FILTER,ce[y.magFilter]),e.texParameteri(w,e.TEXTURE_MIN_FILTER,ce[y.minFilter]),y.compareFunction)e.texParameteri(w,e.TEXTURE_COMPARE_MODE,e.COMPARE_REF_TO_TEXTURE),e.texParameteri(w,e.TEXTURE_COMPARE_FUNC,De[y.compareFunction]);if(t.has("EXT_texture_filter_anisotropic")===!0){if(y.magFilter===Hn)return;if(y.minFilter!==vr&&y.minFilter!==ri)return;if(y.type===Ai&&t.has("OES_texture_float_linear")===!1)return;if(y.anisotropy>1||i.get(y).__currentAnisotropy){let I=t.get("EXT_texture_filter_anisotropic");e.texParameterf(w,I.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(y.anisotropy,r.getMaxAnisotropy())),i.get(y).__currentAnisotropy=y.anisotropy}}}function X(w,y){let I=!1;if(w.__webglInit===void 0)w.__webglInit=!0,y.addEventListener("dispose",A);let W=y.source,ie=d.get(W);if(ie===void 0)ie={},d.set(W,ie);let ae=z(y);if(ae!==w.__cacheKey){if(ie[ae]===void 0)ie[ae]={texture:e.createTexture(),usedTimes:0},o.memory.textures++,I=!0;ie[ae].usedTimes++;let he=ie[w.__cacheKey];if(he!==void 0){if(ie[w.__cacheKey].usedTimes--,he.usedTimes===0)k(y)}w.__cacheKey=ae,w.__webglTexture=ie[ae].texture}return I}function re(w,y,I){return Math.floor(Math.floor(w/I)/y)}function se(w,y,I,W){let ae=w.updateRanges;if(ae.length===0)n.texSubImage2D(e.TEXTURE_2D,0,0,0,y.width,y.height,I,W,y.data);else{ae.sort((Ce,fe)=>Ce.start-fe.start);let he=0;for(let Ce=1;Ce<ae.length;Ce++){let fe=ae[he],oe=ae[Ce],Le=fe.start+fe.count,Oe=re(oe.start,y.width,4),et=re(fe.start,y.width,4);if(oe.start<=Le+1&&Oe===et&&re(oe.start+oe.count-1,y.width,4)===Oe)fe.count=Math.max(fe.count,oe.start+oe.count-fe.start);else++he,ae[he]=oe}ae.length=he+1;let Y=n.getParameter(e.UNPACK_ROW_LENGTH),te=n.getParameter(e.UNPACK_SKIP_PIXELS),ve=n.getParameter(e.UNPACK_SKIP_ROWS);n.pixelStorei(e.UNPACK_ROW_LENGTH,y.width);for(let Ce=0,fe=ae.length;Ce<fe;Ce++){let oe=ae[Ce],Le=Math.floor(oe.start/4),Oe=Math.ceil(oe.count/4),et=Le%y.width,O=Math.floor(Le/y.width),le=Oe,J=1;n.pixelStorei(e.UNPACK_SKIP_PIXELS,et),n.pixelStorei(e.UNPACK_SKIP_ROWS,O),n.texSubImage2D(e.TEXTURE_2D,0,et,O,le,1,I,W,y.data)}w.clearUpdateRanges(),n.pixelStorei(e.UNPACK_ROW_LENGTH,Y),n.pixelStorei(e.UNPACK_SKIP_PIXELS,te),n.pixelStorei(e.UNPACK_SKIP_ROWS,ve)}}function Te(w,y,I){let W=e.TEXTURE_2D;if(y.isDataArrayTexture||y.isCompressedArrayTexture)W=e.TEXTURE_2D_ARRAY;if(y.isData3DTexture)W=e.TEXTURE_3D;let ie=X(w,y),ae=y.source;n.bindTexture(W,w.__webglTexture,e.TEXTURE0+I);let he=i.get(ae);if(ae.version!==he.__version||ie===!0){if(n.activeTexture(e.TEXTURE0+I),(typeof ImageBitmap<"u"&&y.image instanceof ImageBitmap)===!1){let J=$e.getPrimaries($e.workingColorSpace),ue=y.colorSpace===wr?null:$e.getPrimaries(y.colorSpace),be=y.colorSpace===wr||J===ue?e.NONE:e.BROWSER_DEFAULT_WEBGL;n.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,y.flipY),n.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,y.premultiplyAlpha),n.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,be)}n.pixelStorei(e.UNPACK_ALIGNMENT,y.unpackAlignment);let te=p(y.image,!1,r.maxTextureSize);te=it(y,te);let ve=s.convert(y.format,y.colorSpace),Ce=s.convert(y.type),fe=v(y.internalFormat,ve,Ce,y.normalized,y.colorSpace,y.isVideoTexture);ye(W,y);let oe,Le=y.mipmaps,Oe=y.isVideoTexture!==!0,et=he.__version===void 0||ie===!0,O=ae.dataReady,le=T(y,te);if(y.isDepthTexture){if(fe=M(y.format===Sr,y.type),et)if(Oe)n.texStorage2D(e.TEXTURE_2D,1,fe,te.width,te.height);else n.texImage2D(e.TEXTURE_2D,0,fe,te.width,te.height,0,ve,Ce,null)}else if(y.isDataTexture)if(Le.length>0){if(Oe&&et)n.texStorage2D(e.TEXTURE_2D,le,fe,Le[0].width,Le[0].height);for(let J=0,ue=Le.length;J<ue;J++)if(oe=Le[J],Oe){if(O)n.texSubImage2D(e.TEXTURE_2D,J,0,0,oe.width,oe.height,ve,Ce,oe.data)}else n.texImage2D(e.TEXTURE_2D,J,fe,oe.width,oe.height,0,ve,Ce,oe.data);y.generateMipmaps=!1}else if(Oe){if(et)n.texStorage2D(e.TEXTURE_2D,le,fe,te.width,te.height);if(O)se(y,te,ve,Ce)}else n.texImage2D(e.TEXTURE_2D,0,fe,te.width,te.height,0,ve,Ce,te.data);else if(y.isCompressedTexture)if(y.isCompressedArrayTexture){if(Oe&&et)n.texStorage3D(e.TEXTURE_2D_ARRAY,le,fe,Le[0].width,Le[0].height,te.depth);for(let J=0,ue=Le.length;J<ue;J++)if(oe=Le[J],y.format!==oi)if(ve!==null)if(Oe){if(O)if(y.layerUpdates.size>0){let be=Lu(oe.width,oe.height,y.format,y.type);for(let ne of y.layerUpdates){let pe=oe.data.subarray(ne*be/oe.data.BYTES_PER_ELEMENT,(ne+1)*be/oe.data.BYTES_PER_ELEMENT);n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,J,0,0,ne,oe.width,oe.height,1,ve,pe)}}else n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,J,0,0,0,oe.width,oe.height,te.depth,ve,oe.data)}else n.compressedTexImage3D(e.TEXTURE_2D_ARRAY,J,fe,oe.width,oe.height,te.depth,0,oe.data,0,0);else Pe("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else if(Oe){if(O)n.texSubImage3D(e.TEXTURE_2D_ARRAY,J,0,0,0,oe.width,oe.height,te.depth,ve,Ce,oe.data)}else n.texImage3D(e.TEXTURE_2D_ARRAY,J,fe,oe.width,oe.height,te.depth,0,ve,Ce,oe.data);if(y.layerUpdates.size>0)y.clearLayerUpdates()}else{if(Oe&&et)n.texStorage2D(e.TEXTURE_2D,le,fe,Le[0].width,Le[0].height);for(let J=0,ue=Le.length;J<ue;J++)if(oe=Le[J],y.format!==oi)if(ve!==null)if(Oe){if(O)n.compressedTexSubImage2D(e.TEXTURE_2D,J,0,0,oe.width,oe.height,ve,oe.data)}else n.compressedTexImage2D(e.TEXTURE_2D,J,fe,oe.width,oe.height,0,oe.data);else Pe("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else if(Oe){if(O)n.texSubImage2D(e.TEXTURE_2D,J,0,0,oe.width,oe.height,ve,Ce,oe.data)}else n.texImage2D(e.TEXTURE_2D,J,fe,oe.width,oe.height,0,ve,Ce,oe.data)}else if(y.isDataArrayTexture)if(Oe){if(et)n.texStorage3D(e.TEXTURE_2D_ARRAY,le,fe,te.width,te.height,te.depth);if(O)if(y.layerUpdates.size>0){let J=Lu(te.width,te.height,y.format,y.type);for(let ue of y.layerUpdates){let be=te.data.subarray(ue*J/te.data.BYTES_PER_ELEMENT,(ue+1)*J/te.data.BYTES_PER_ELEMENT);n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,ue,te.width,te.height,1,ve,Ce,be)}y.clearLayerUpdates()}else n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,0,te.width,te.height,te.depth,ve,Ce,te.data)}else n.texImage3D(e.TEXTURE_2D_ARRAY,0,fe,te.width,te.height,te.depth,0,ve,Ce,te.data);else if(y.isData3DTexture)if(Oe){if(et)n.texStorage3D(e.TEXTURE_3D,le,fe,te.width,te.height,te.depth);if(O)n.texSubImage3D(e.TEXTURE_3D,0,0,0,0,te.width,te.height,te.depth,ve,Ce,te.data)}else n.texImage3D(e.TEXTURE_3D,0,fe,te.width,te.height,te.depth,0,ve,Ce,te.data);else if(y.isFramebufferTexture){if(et)if(Oe)n.texStorage2D(e.TEXTURE_2D,le,fe,te.width,te.height);else{let J=te.width,ue=te.height;for(let be=0;be<le;be++)n.texImage2D(e.TEXTURE_2D,be,fe,J,ue,0,ve,Ce,null),J>>=1,ue>>=1}}else if(y.isHTMLTexture){if("texElementImage2D"in e){let J=e.canvas;if(!J.hasAttribute("layoutsubtree"))J.setAttribute("layoutsubtree","true");if(te.parentNode!==J){J.appendChild(te),f.add(y),J.onpaint=(ue)=>{let be=ue.changedElements;for(let ne of f)if(be.includes(ne.image))ne.needsUpdate=!0},J.requestPaint();return}if(e.texElementImage2D.length===3)e.texElementImage2D(e.TEXTURE_2D,e.RGBA8,te);else{let{RGBA:be,RGBA:ne,UNSIGNED_BYTE:pe}=e;e.texElementImage2D(e.TEXTURE_2D,0,be,ne,pe,te)}e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE)}}else if(Le.length>0){if(Oe&&et){let J=wt(Le[0]);n.texStorage2D(e.TEXTURE_2D,le,fe,J.width,J.height)}for(let J=0,ue=Le.length;J<ue;J++)if(oe=Le[J],Oe){if(O)n.texSubImage2D(e.TEXTURE_2D,J,0,0,ve,Ce,oe)}else n.texImage2D(e.TEXTURE_2D,J,fe,ve,Ce,oe);y.generateMipmaps=!1}else if(Oe){if(et){let J=wt(te);n.texStorage2D(e.TEXTURE_2D,le,fe,J.width,J.height)}if(O)n.texSubImage2D(e.TEXTURE_2D,0,0,0,ve,Ce,te)}else n.texImage2D(e.TEXTURE_2D,0,fe,ve,Ce,te);if(m(y))E(W);if(he.__version=ae.version,y.onUpdate)y.onUpdate(y)}w.__version=y.version}function Ie(w,y,I){if(y.image.length!==6)return;let W=X(w,y),ie=y.source;n.bindTexture(e.TEXTURE_CUBE_MAP,w.__webglTexture,e.TEXTURE0+I);let ae=i.get(ie);if(ie.version!==ae.__version||W===!0){n.activeTexture(e.TEXTURE0+I);let he=$e.getPrimaries($e.workingColorSpace),Y=y.colorSpace===wr?null:$e.getPrimaries(y.colorSpace),te=y.colorSpace===wr||he===Y?e.NONE:e.BROWSER_DEFAULT_WEBGL;n.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,y.flipY),n.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,y.premultiplyAlpha),n.pixelStorei(e.UNPACK_ALIGNMENT,y.unpackAlignment),n.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,te);let ve=y.isCompressedTexture||y.image[0].isCompressedTexture,Ce=y.image[0]&&y.image[0].isDataTexture,fe=[];for(let ne=0;ne<6;ne++){if(!ve&&!Ce)fe[ne]=p(y.image[ne],!0,r.maxCubemapSize);else fe[ne]=Ce?y.image[ne].image:y.image[ne];fe[ne]=it(y,fe[ne])}let oe=fe[0],Le=s.convert(y.format,y.colorSpace),Oe=s.convert(y.type),et=v(y.internalFormat,Le,Oe,y.normalized,y.colorSpace),O=y.isVideoTexture!==!0,le=ae.__version===void 0||W===!0,J=ie.dataReady,ue=T(y,oe);ye(e.TEXTURE_CUBE_MAP,y);let be;if(ve){if(O&&le)n.texStorage2D(e.TEXTURE_CUBE_MAP,ue,et,oe.width,oe.height);for(let ne=0;ne<6;ne++){be=fe[ne].mipmaps;for(let pe=0;pe<be.length;pe++){let Be=be[pe];if(y.format!==oi)if(Le!==null)if(O){if(J)n.compressedTexSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,pe,0,0,Be.width,Be.height,Le,Be.data)}else n.compressedTexImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,pe,et,Be.width,Be.height,0,Be.data);else Pe("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()");else if(O){if(J)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,pe,0,0,Be.width,Be.height,Le,Oe,Be.data)}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,pe,et,Be.width,Be.height,0,Le,Oe,Be.data)}}}else{if(be=y.mipmaps,O&&le){if(be.length>0)ue++;let ne=wt(fe[0]);n.texStorage2D(e.TEXTURE_CUBE_MAP,ue,et,ne.width,ne.height)}for(let ne=0;ne<6;ne++)if(Ce){if(O){if(J)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,0,0,0,fe[ne].width,fe[ne].height,Le,Oe,fe[ne].data)}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,0,et,fe[ne].width,fe[ne].height,0,Le,Oe,fe[ne].data);for(let pe=0;pe<be.length;pe++){let gt=be[pe].image[ne].image;if(O){if(J)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,pe+1,0,0,gt.width,gt.height,Le,Oe,gt.data)}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,pe+1,et,gt.width,gt.height,0,Le,Oe,gt.data)}}else{if(O){if(J)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,0,0,0,Le,Oe,fe[ne])}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,0,et,Le,Oe,fe[ne]);for(let pe=0;pe<be.length;pe++){let Be=be[pe];if(O){if(J)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,pe+1,0,0,Le,Oe,Be.image[ne])}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,pe+1,et,Le,Oe,Be.image[ne])}}}if(m(y))E(e.TEXTURE_CUBE_MAP);if(ae.__version=ie.version,y.onUpdate)y.onUpdate(y)}w.__version=y.version}function _e(w,y,I,W,ie,ae){let he=s.convert(I.format,I.colorSpace),Y=s.convert(I.type),te=v(I.internalFormat,he,Y,I.normalized,I.colorSpace),ve=i.get(y),Ce=i.get(I);if(Ce.__renderTarget=y,!ve.__hasExternalTextures){let fe=Math.max(1,y.width>>ae),oe=Math.max(1,y.height>>ae);if(ie===e.TEXTURE_3D||ie===e.TEXTURE_2D_ARRAY)n.texImage3D(ie,ae,te,fe,oe,y.depth,0,he,Y,null);else n.texImage2D(ie,ae,te,fe,oe,0,he,Y,null)}if(n.bindFramebuffer(e.FRAMEBUFFER,w),L(y))a.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,W,ie,Ce.__webglTexture,0,Ot(y));else if(ie===e.TEXTURE_2D||ie>=e.TEXTURE_CUBE_MAP_POSITIVE_X&&ie<=e.TEXTURE_CUBE_MAP_NEGATIVE_Z)e.framebufferTexture2D(e.FRAMEBUFFER,W,ie,Ce.__webglTexture,ae);n.bindFramebuffer(e.FRAMEBUFFER,null)}function Qe(w,y,I){if(e.bindRenderbuffer(e.RENDERBUFFER,w),y.depthBuffer){let W=y.depthTexture,ie=W&&W.isDepthTexture?W.type:null,ae=M(y.stencilBuffer,ie),he=y.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;if(L(y))a.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,Ot(y),ae,y.width,y.height);else if(I)e.renderbufferStorageMultisample(e.RENDERBUFFER,Ot(y),ae,y.width,y.height);else e.renderbufferStorage(e.RENDERBUFFER,ae,y.width,y.height);e.framebufferRenderbuffer(e.FRAMEBUFFER,he,e.RENDERBUFFER,w)}else{let W=y.textures;for(let ie=0;ie<W.length;ie++){let ae=W[ie],he=s.convert(ae.format,ae.colorSpace),Y=s.convert(ae.type),te=v(ae.internalFormat,he,Y,ae.normalized,ae.colorSpace);if(L(y))a.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,Ot(y),te,y.width,y.height);else if(I)e.renderbufferStorageMultisample(e.RENDERBUFFER,Ot(y),te,y.width,y.height);else e.renderbufferStorage(e.RENDERBUFFER,te,y.width,y.height)}}e.bindRenderbuffer(e.RENDERBUFFER,null)}function ze(w,y,I){let W=y.isWebGLCubeRenderTarget===!0;if(n.bindFramebuffer(e.FRAMEBUFFER,w),!(y.depthTexture&&y.depthTexture.isDepthTexture))throw Error("THREE.WebGLTextures: renderTarget.depthTexture must be an instance of THREE.DepthTexture.");let ie=i.get(y.depthTexture);if(ie.__renderTarget=y,!ie.__webglTexture||y.depthTexture.image.width!==y.width||y.depthTexture.image.height!==y.height)y.depthTexture.image.width=y.width,y.depthTexture.image.height=y.height,y.depthTexture.needsUpdate=!0;if(W){if(ie.__webglInit===void 0)ie.__webglInit=!0,y.depthTexture.addEventListener("dispose",A);if(ie.__webglTexture===void 0){ie.__webglTexture=e.createTexture(),n.bindTexture(e.TEXTURE_CUBE_MAP,ie.__webglTexture),ye(e.TEXTURE_CUBE_MAP,y.depthTexture);let ve=s.convert(y.depthTexture.format),Ce=s.convert(y.depthTexture.type),fe;if(y.depthTexture.format===br)fe=e.DEPTH_COMPONENT24;else if(y.depthTexture.format===Sr)fe=e.DEPTH24_STENCIL8;for(let oe=0;oe<6;oe++)e.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+oe,0,fe,y.width,y.height,0,ve,Ce,null)}}else H(y.depthTexture,0);let ae=ie.__webglTexture,he=Ot(y),Y=W?e.TEXTURE_CUBE_MAP_POSITIVE_X+I:e.TEXTURE_2D,te=y.depthTexture.format===Sr?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;if(y.depthTexture.format===br)if(L(y))a.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,te,Y,ae,0,he);else e.framebufferTexture2D(e.FRAMEBUFFER,te,Y,ae,0);else if(y.depthTexture.format===Sr)if(L(y))a.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,te,Y,ae,0,he);else e.framebufferTexture2D(e.FRAMEBUFFER,te,Y,ae,0);else throw Error("THREE.WebGLTextures: Unknown depthTexture format.")}function Ze(w){let y=i.get(w),I=w.isWebGLCubeRenderTarget===!0;if(y.__boundDepthTexture!==w.depthTexture){let W=w.depthTexture;if(y.__depthDisposeCallback)y.__depthDisposeCallback();if(W){let ie=()=>{delete y.__boundDepthTexture,delete y.__depthDisposeCallback,W.removeEventListener("dispose",ie)};W.addEventListener("dispose",ie),y.__depthDisposeCallback=ie}y.__boundDepthTexture=W}if(w.depthTexture&&!y.__autoAllocateDepthBuffer)if(I)for(let W=0;W<6;W++)ze(y.__webglFramebuffer[W],w,W);else{let W=w.texture.mipmaps;if(W&&W.length>0)ze(y.__webglFramebuffer[0],w,0);else ze(y.__webglFramebuffer,w,0)}else if(I){y.__webglDepthbuffer=[];for(let W=0;W<6;W++)if(n.bindFramebuffer(e.FRAMEBUFFER,y.__webglFramebuffer[W]),y.__webglDepthbuffer[W]===void 0)y.__webglDepthbuffer[W]=e.createRenderbuffer(),Qe(y.__webglDepthbuffer[W],w,!1);else{let ie=w.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,ae=y.__webglDepthbuffer[W];e.bindRenderbuffer(e.RENDERBUFFER,ae),e.framebufferRenderbuffer(e.FRAMEBUFFER,ie,e.RENDERBUFFER,ae)}}else{let W=w.texture.mipmaps;if(W&&W.length>0)n.bindFramebuffer(e.FRAMEBUFFER,y.__webglFramebuffer[0]);else n.bindFramebuffer(e.FRAMEBUFFER,y.__webglFramebuffer);if(y.__webglDepthbuffer===void 0)y.__webglDepthbuffer=e.createRenderbuffer(),Qe(y.__webglDepthbuffer,w,!1);else{let ie=w.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,ae=y.__webglDepthbuffer;e.bindRenderbuffer(e.RENDERBUFFER,ae),e.framebufferRenderbuffer(e.FRAMEBUFFER,ie,e.RENDERBUFFER,ae)}}n.bindFramebuffer(e.FRAMEBUFFER,null)}function ot(w,y,I){let W=i.get(w);if(y!==void 0)_e(W.__webglFramebuffer,w,w.texture,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,0);if(I!==void 0)Ze(w)}function Ye(w){let y=w.texture,I=i.get(w),W=i.get(y);w.addEventListener("dispose",_);let ie=w.textures,ae=w.isWebGLCubeRenderTarget===!0,he=ie.length>1;if(!he){if(W.__webglTexture===void 0)W.__webglTexture=e.createTexture();W.__version=y.version,o.memory.textures++}if(ae){I.__webglFramebuffer=[];for(let Y=0;Y<6;Y++)if(y.mipmaps&&y.mipmaps.length>0){I.__webglFramebuffer[Y]=[];for(let te=0;te<y.mipmaps.length;te++)I.__webglFramebuffer[Y][te]=e.createFramebuffer()}else I.__webglFramebuffer[Y]=e.createFramebuffer()}else{if(y.mipmaps&&y.mipmaps.length>0){I.__webglFramebuffer=[];for(let Y=0;Y<y.mipmaps.length;Y++)I.__webglFramebuffer[Y]=e.createFramebuffer()}else I.__webglFramebuffer=e.createFramebuffer();if(he)for(let Y=0,te=ie.length;Y<te;Y++){let ve=i.get(ie[Y]);if(ve.__webglTexture===void 0)ve.__webglTexture=e.createTexture(),o.memory.textures++}if(w.samples>0&&L(w)===!1){I.__webglMultisampledFramebuffer=e.createFramebuffer(),I.__webglColorRenderbuffer=[],n.bindFramebuffer(e.FRAMEBUFFER,I.__webglMultisampledFramebuffer);for(let Y=0;Y<ie.length;Y++){let te=ie[Y];I.__webglColorRenderbuffer[Y]=e.createRenderbuffer(),e.bindRenderbuffer(e.RENDERBUFFER,I.__webglColorRenderbuffer[Y]);let ve=s.convert(te.format,te.colorSpace),Ce=s.convert(te.type),fe=v(te.internalFormat,ve,Ce,te.normalized,te.colorSpace,w.isXRRenderTarget===!0),oe=Ot(w);e.renderbufferStorageMultisample(e.RENDERBUFFER,oe,fe,w.width,w.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+Y,e.RENDERBUFFER,I.__webglColorRenderbuffer[Y])}if(e.bindRenderbuffer(e.RENDERBUFFER,null),w.depthBuffer)I.__webglDepthRenderbuffer=e.createRenderbuffer(),Qe(I.__webglDepthRenderbuffer,w,!0);n.bindFramebuffer(e.FRAMEBUFFER,null)}}if(ae){n.bindTexture(e.TEXTURE_CUBE_MAP,W.__webglTexture),ye(e.TEXTURE_CUBE_MAP,y);for(let Y=0;Y<6;Y++)if(y.mipmaps&&y.mipmaps.length>0)for(let te=0;te<y.mipmaps.length;te++)_e(I.__webglFramebuffer[Y][te],w,y,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+Y,te);else _e(I.__webglFramebuffer[Y],w,y,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+Y,0);if(m(y))E(e.TEXTURE_CUBE_MAP);n.unbindTexture()}else if(he){for(let Y=0,te=ie.length;Y<te;Y++){let ve=ie[Y],Ce=i.get(ve),fe=e.TEXTURE_2D;if(w.isWebGL3DRenderTarget||w.isWebGLArrayRenderTarget)fe=w.isWebGL3DRenderTarget?e.TEXTURE_3D:e.TEXTURE_2D_ARRAY;if(n.bindTexture(fe,Ce.__webglTexture),ye(fe,ve),_e(I.__webglFramebuffer,w,ve,e.COLOR_ATTACHMENT0+Y,fe,0),m(ve))E(fe)}n.unbindTexture()}else{let Y=e.TEXTURE_2D;if(w.isWebGL3DRenderTarget||w.isWebGLArrayRenderTarget)Y=w.isWebGL3DRenderTarget?e.TEXTURE_3D:e.TEXTURE_2D_ARRAY;if(n.bindTexture(Y,W.__webglTexture),ye(Y,y),y.mipmaps&&y.mipmaps.length>0)for(let te=0;te<y.mipmaps.length;te++)_e(I.__webglFramebuffer[te],w,y,e.COLOR_ATTACHMENT0,Y,te);else _e(I.__webglFramebuffer,w,y,e.COLOR_ATTACHMENT0,Y,0);if(m(y))E(Y);n.unbindTexture()}if(w.depthBuffer)Ze(w)}function Zt(w){let y=w.textures;for(let I=0,W=y.length;I<W;I++){let ie=y[I];if(m(ie)){let ae=R(w),he=i.get(ie).__webglTexture;n.bindTexture(ae,he),E(ae),n.unbindTexture()}}}let yt=[],cn=[];function Dt(w){if(w.samples>0){if(L(w)===!1){let{textures:y,width:I,height:W}=w,ie=e.COLOR_BUFFER_BIT,ae=w.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,he=i.get(w),Y=y.length>1;if(Y)for(let ve=0;ve<y.length;ve++)n.bindFramebuffer(e.FRAMEBUFFER,he.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+ve,e.RENDERBUFFER,null),n.bindFramebuffer(e.FRAMEBUFFER,he.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+ve,e.TEXTURE_2D,null,0);n.bindFramebuffer(e.READ_FRAMEBUFFER,he.__webglMultisampledFramebuffer);let te=w.texture.mipmaps;if(te&&te.length>0)n.bindFramebuffer(e.DRAW_FRAMEBUFFER,he.__webglFramebuffer[0]);else n.bindFramebuffer(e.DRAW_FRAMEBUFFER,he.__webglFramebuffer);for(let ve=0;ve<y.length;ve++){if(w.resolveDepthBuffer){if(w.depthBuffer)ie|=e.DEPTH_BUFFER_BIT;if(w.stencilBuffer&&w.resolveStencilBuffer)ie|=e.STENCIL_BUFFER_BIT}if(Y){e.framebufferRenderbuffer(e.READ_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.RENDERBUFFER,he.__webglColorRenderbuffer[ve]);let Ce=i.get(y[ve]).__webglTexture;e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,Ce,0)}if(e.blitFramebuffer(0,0,I,W,0,0,I,W,ie,e.NEAREST),c===!0){if(yt.length=0,cn.length=0,yt.push(e.COLOR_ATTACHMENT0+ve),w.depthBuffer&&w.storeMultisampledDepthBuffer===!1)yt.push(ae),cn.push(ae),e.invalidateFramebuffer(e.DRAW_FRAMEBUFFER,cn);e.invalidateFramebuffer(e.READ_FRAMEBUFFER,yt)}}if(n.bindFramebuffer(e.READ_FRAMEBUFFER,null),n.bindFramebuffer(e.DRAW_FRAMEBUFFER,null),Y)for(let ve=0;ve<y.length;ve++){n.bindFramebuffer(e.FRAMEBUFFER,he.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+ve,e.RENDERBUFFER,he.__webglColorRenderbuffer[ve]);let Ce=i.get(y[ve]).__webglTexture;n.bindFramebuffer(e.FRAMEBUFFER,he.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+ve,e.TEXTURE_2D,Ce,0)}n.bindFramebuffer(e.DRAW_FRAMEBUFFER,he.__webglMultisampledFramebuffer)}else if(w.depthBuffer&&w.storeMultisampledDepthBuffer===!1&&c){let y=w.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;e.invalidateFramebuffer(e.DRAW_FRAMEBUFFER,[y])}}}function Ot(w){return Math.min(r.maxSamples,w.samples)}function L(w){let y=i.get(w);return w.samples>0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&y.__useRenderToTexture!==!1}function ln(w){let y=o.render.frame;if(u.get(w)!==y)u.set(w,y),w.update()}function it(w,y){let{colorSpace:I,format:W,type:ie}=w;if(w.isCompressedTexture===!0||w.isVideoTexture===!0)return y;if(I!==gn&&I!==wr)if($e.getTransfer(I)===pt){if(W!==oi||ie!==Vn)Pe("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType.")}else Fe("WebGLTextures: Unsupported texture color space:",I);return y}function wt(w){if(typeof HTMLImageElement<"u"&&w instanceof HTMLImageElement)l.width=w.naturalWidth||w.width,l.height=w.naturalHeight||w.height;else if(typeof VideoFrame<"u"&&w instanceof VideoFrame)l.width=w.displayWidth,l.height=w.displayHeight;else l.width=w.width,l.height=w.height;return l}this.allocateTextureUnit=j,this.resetTextureUnits=ee,this.getTextureUnits=P,this.setTextureUnits=V,this.setTexture2D=H,this.setTexture2DArray=F,this.setTexture3D=q,this.setTextureCube=K,this.rebindTextures=ot,this.setupRenderTarget=Ye,this.updateRenderTargetMipmap=Zt,this.updateMultisampleRenderTarget=Dt,this.setupDepthRenderbuffer=Ze,this.setupFrameBufferTexture=_e,this.useMultisampledRTT=L,this.isReversedDepthBuffer=function(){return n.buffers.depth.getReversed()}}function iT(e,t){function n(i,r=wr){let s,o=$e.getTransfer(r);if(i===Vn)return e.UNSIGNED_BYTE;if(i===wl)return e.UNSIGNED_SHORT_4_4_4_4;if(i===El)return e.UNSIGNED_SHORT_5_5_5_1;if(i===qd)return e.UNSIGNED_INT_5_9_9_9_REV;if(i===jd)return e.UNSIGNED_INT_10F_11F_11F_REV;if(i===Zd)return e.BYTE;if(i===Xd)return e.SHORT;if(i===Vs)return e.UNSIGNED_SHORT;if(i===Ml)return e.INT;if(i===qi)return e.UNSIGNED_INT;if(i===Ai)return e.FLOAT;if(i===si)return e.HALF_FLOAT;if(i===Yd)return e.ALPHA;if(i===Kd)return e.RGB;if(i===oi)return e.RGBA;if(i===br)return e.DEPTH_COMPONENT;if(i===Sr)return e.DEPTH_STENCIL;if(i===Jd)return e.RED;if(i===Tl)return e.RED_INTEGER;if(i===Mr)return e.RG;if(i===Al)return e.RG_INTEGER;if(i===Rl)return e.RGBA_INTEGER;if(i===Sa||i===Ma||i===wa||i===Ea)if(o===pt)if(s=t.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(i===Sa)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===Ma)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===wa)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===Ea)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=t.get("WEBGL_compressed_texture_s3tc"),s!==null){if(i===Sa)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===Ma)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===wa)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===Ea)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(i===Cl||i===Pl||i===Il||i===Ll)if(s=t.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(i===Cl)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===Pl)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===Il)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===Ll)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(i===Nl||i===Dl||i===Ol||i===Ul||i===Fl||i===Ta||i===zl)if(s=t.get("WEBGL_compressed_texture_etc"),s!==null){if(i===Nl||i===Dl)return o===pt?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(i===Ol)return o===pt?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC;if(i===Ul)return s.COMPRESSED_R11_EAC;if(i===Fl)return s.COMPRESSED_SIGNED_R11_EAC;if(i===Ta)return s.COMPRESSED_RG11_EAC;if(i===zl)return s.COMPRESSED_SIGNED_RG11_EAC}else return null;if(i===kl||i===Bl||i===Gl||i===Hl||i===Vl||i===$l||i===Wl||i===Zl||i===Xl||i===ql||i===jl||i===Yl||i===Kl||i===Jl)if(s=t.get("WEBGL_compressed_texture_astc"),s!==null){if(i===kl)return o===pt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===Bl)return o===pt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===Gl)return o===pt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===Hl)return o===pt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===Vl)return o===pt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===$l)return o===pt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===Wl)return o===pt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===Zl)return o===pt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===Xl)return o===pt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===ql)return o===pt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===jl)return o===pt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===Yl)return o===pt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===Kl)return o===pt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===Jl)return o===pt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(i===Ql||i===eu||i===tu)if(s=t.get("EXT_texture_compression_bptc"),s!==null){if(i===Ql)return o===pt?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===eu)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===tu)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(i===nu||i===iu||i===Aa||i===ru)if(s=t.get("EXT_texture_compression_rgtc"),s!==null){if(i===nu)return s.COMPRESSED_RED_RGTC1_EXT;if(i===iu)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===Aa)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===ru)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;if(i===ls)return e.UNSIGNED_INT_24_8;return e[i]!==void 0?e[i]:null}return{convert:n}}var rT=`
4320
+ }`,eT=[new O(1,0,0),new O(-1,0,0),new O(0,1,0),new O(0,-1,0),new O(0,0,1),new O(0,0,-1)],tT=[new O(0,-1,0),new O(0,-1,0),new O(0,0,1),new O(0,0,-1),new O(0,-1,0),new O(0,-1,0)],Bp=new Ge,ho=new O,ku=new O;function nT(e,t,n){let i=new no,r=new Ne,s=new Ne,o=new at,a=new yu,c=new vu,l={},u=n.maxTextureSize,f={[qi]:Qt,[Qt]:qi,[Pn]:Pn},h=new In({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Ne},radius:{value:4}},vertexShader:JE,fragmentShader:QE}),d=h.clone();d.defines.HORIZONTAL_PASS=1;let g=new en;g.setAttribute("position",new Vt(new Float32Array([-1,-1,0.5,3,-1,0.5,-1,3,0.5]),3));let x=new _t(g,h),p=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Vs;let m=this.type;this.render=function(T,A,_){if(p.enabled===!1)return;if(p.autoUpdate===!1&&p.needsUpdate===!1)return;if(T.length===0)return;if(this.type===gd)Ie("WebGLShadowMap: PCFSoftShadowMap has been removed. Using PCFShadowMap instead."),this.type=Vs;let S=e.getRenderTarget(),z=e.getActiveCubeFace(),P=e.getActiveMipmapLevel(),F=e.state;if(F.setBlending(ii),F.buffers.depth.getReversed()===!0)F.buffers.color.setClear(0,0,0,0);else F.buffers.color.setClear(1,1,1,1);F.buffers.depth.setTest(!0),F.setScissorTest(!1);let ee=m!==this.type;if(ee)A.traverse(function(I){if(I.material)if(Array.isArray(I.material))I.material.forEach((H)=>H.needsUpdate=!0);else I.material.needsUpdate=!0});for(let I=0,H=T.length;I<H;I++){let q=T[I],C=q.shadow;if(C===void 0){Ie("WebGLShadowMap:",q,"has no shadow.");continue}if(C.autoUpdate===!1&&C.needsUpdate===!1)continue;r.copy(C.mapSize);let X=C.getFrameExtents();if(r.multiply(X),s.copy(C.mapSize),r.x>u||r.y>u){if(r.x>u)s.x=Math.floor(u/X.x),r.x=s.x*X.x,C.mapSize.x=s.x;if(r.y>u)s.y=Math.floor(u/X.y),r.y=s.y*X.y,C.mapSize.y=s.y}let k=e.state.buffers.depth.getReversed();if(C.camera._reversedDepth=k,C.map===null||ee===!0){if(C.map!==null){if(C.map.depthTexture!==null)C.map.depthTexture.dispose(),C.map.depthTexture=null;C.map.dispose()}if(this.type===ss){if(q.isPointLight){Ie("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}C.map=new _n(r.x,r.y,{format:wr,type:si,minFilter:$t,magFilter:$t,generateMipmaps:!1}),C.map.texture.name=q.name+".shadowMap",C.map.depthTexture=new Tr(r.x,r.y,Ri),C.map.depthTexture.name=q.name+".shadowMapDepth",C.map.depthTexture.format=Sr,C.map.depthTexture.compareFunction=null,C.map.depthTexture.minFilter=Vn,C.map.depthTexture.magFilter=Vn}else{if(q.isPointLight)C.map=new Hu(r.x),C.map.depthTexture=new gu(r.x,ji);else C.map=new _n(r.x,r.y),C.map.depthTexture=new Tr(r.x,r.y,ji);if(C.map.depthTexture.name=q.name+".shadowMap",C.map.depthTexture.format=Sr,this.type===Vs)C.map.depthTexture.compareFunction=k?La:Ia,C.map.depthTexture.minFilter=$t,C.map.depthTexture.magFilter=$t;else C.map.depthTexture.compareFunction=null,C.map.depthTexture.minFilter=Vn,C.map.depthTexture.magFilter=Vn}C.camera.updateProjectionMatrix()}if(C.map.isWebGLCubeRenderTarget!==!0&&(C.map.width!==r.x||C.map.height!==r.y))C.map.setSize(r.x,r.y);let Y=C.map.isWebGLCubeRenderTarget?6:C.getViewportCount();if(q.isPointLight!==!0)C.updateMatrices(q,_);for(let Q=0;Q<Y;Q++){let Se=C.getCamera(Q);if(q.isPointLight){let{camera:ue,matrix:Fe}=C,Me=q.distance||ue.far;if(Me!==ue.far)ue.far=Me,ue.updateProjectionMatrix();ho.setFromMatrixPosition(q.matrixWorld),ue.position.copy(ho),ku.copy(ue.position),ku.add(eT[Q]),ue.up.copy(tT[Q]),ue.lookAt(ku),ue.updateMatrixWorld(),Fe.makeTranslation(-ho.x,-ho.y,-ho.z),Bp.multiplyMatrices(ue.projectionMatrix,ue.matrixWorldInverse),C._frustum.setFromProjectionMatrix(Bp,ue.coordinateSystem,ue.reversedDepth)}if(C.map.isWebGLCubeRenderTarget)e.setRenderTarget(C.map,Q),e.clear();else{if(Q===0)e.setRenderTarget(C.map),e.clear();let ue=C.getViewport(Q);o.set(s.x*ue.x,s.y*ue.y,s.x*ue.z,s.y*ue.w),F.viewport(o)}i=C.getFrustum(Q),v(A,_,Se,q,this.type)}if(C.isPointLightShadow!==!0&&this.type===ss)E(C,_);C.needsUpdate=!1}m=this.type,p.needsUpdate=!1,e.setRenderTarget(S,z,P)};function E(T,A){let _=t.update(x);if(h.defines.VSM_SAMPLES!==T.blurSamples)h.defines.VSM_SAMPLES=T.blurSamples,d.defines.VSM_SAMPLES=T.blurSamples,h.needsUpdate=!0,d.needsUpdate=!0;if(T.mapPass===null)T.mapPass=new _n(r.x,r.y,{format:wr,type:si});else if(T.mapPass.width!==T.map.width||T.mapPass.height!==T.map.height)T.mapPass.setSize(T.map.width,T.map.height);h.uniforms.shadow_pass.value=T.map.depthTexture,h.uniforms.resolution.value.set(T.map.width,T.map.height),h.uniforms.radius.value=T.radius,e.setRenderTarget(T.mapPass),e.clear(),e.renderBufferDirect(A,null,_,h,x,null),d.uniforms.shadow_pass.value=T.mapPass.texture,d.uniforms.resolution.value.set(T.map.width,T.map.height),d.uniforms.radius.value=T.radius,e.setRenderTarget(T.map),e.clear(),e.renderBufferDirect(A,null,_,d,x,null)}function R(T,A,_,S){let z=null,P=_.isPointLight===!0?T.customDistanceMaterial:T.customDepthMaterial;if(P!==void 0)z=P;else if(z=_.isPointLight===!0?c:a,e.localClippingEnabled&&A.clipShadows===!0&&Array.isArray(A.clippingPlanes)&&A.clippingPlanes.length!==0||A.displacementMap&&A.displacementScale!==0||A.alphaMap&&A.alphaTest>0||A.map&&A.alphaTest>0||A.alphaToCoverage===!0){let F=z.uuid,ee=A.uuid,I=l[F];if(I===void 0)I={},l[F]=I;let H=I[ee];if(H===void 0)H=z.clone(),I[ee]=H,A.addEventListener("dispose",M);z=H}if(z.visible=A.visible,z.wireframe=A.wireframe,S===ss)z.side=A.shadowSide!==null?A.shadowSide:A.side;else z.side=A.shadowSide!==null?A.shadowSide:f[A.side];if(z.alphaMap=A.alphaMap,z.alphaTest=A.alphaToCoverage===!0?0.5:A.alphaTest,z.map=A.map,z.clipShadows=A.clipShadows,z.clippingPlanes=A.clippingPlanes,z.clipIntersection=A.clipIntersection,z.displacementMap=A.displacementMap,z.displacementScale=A.displacementScale,z.displacementBias=A.displacementBias,z.wireframeLinewidth=A.wireframeLinewidth,z.linewidth=A.linewidth,_.isPointLight===!0&&z.isMeshDistanceMaterial===!0){let F=e.properties.get(z);F.light=_}return z}function v(T,A,_,S,z){if(T.visible===!1)return;if(T.layers.test(A.layers)&&(T.isMesh||T.isLine||T.isPoints)){if((T.castShadow||T.receiveShadow&&z===ss)&&(!T.frustumCulled||T.intersectsFrustum(i))){T.modelViewMatrix.multiplyMatrices(_.matrixWorldInverse,T.matrixWorld);let ee=t.update(T),I=T.material;if(Array.isArray(I)){let H=ee.groups;for(let q=0,C=H.length;q<C;q++){let X=H[q],k=I[X.materialIndex];if(k&&k.visible){let Y=R(T,k,S,z);T.onBeforeShadow(e,T,A,_,ee,Y,X),e.renderBufferDirect(_,null,ee,Y,T,X),T.onAfterShadow(e,T,A,_,ee,Y,X)}}}else if(I.visible){let H=R(T,I,S,z);T.onBeforeShadow(e,T,A,_,ee,H,null),e.renderBufferDirect(_,null,ee,H,T,null),T.onAfterShadow(e,T,A,_,ee,H,null)}}}let F=T.children;for(let ee=0,I=F.length;ee<I;ee++)v(F[ee],A,_,S,z)}function M(T){T.target.removeEventListener("dispose",M);for(let _ in l){let S=l[_],z=T.target.uuid;if(z in S)S[z].dispose(),delete S[z]}}}function iT(e,t){function n(){let U=!1,ce=new at,K=null,le=new at(0,0,0,0);return{setMask:function(ye){if(K!==ye&&!U)e.colorMask(ye,ye,ye,ye),K=ye},setLocked:function(ye){U=ye},setClear:function(ye,ne,pe,Be,mt){if(mt===!0)ye*=Be,ne*=Be,pe*=Be;if(ce.set(ye,ne,pe,Be),le.equals(ce)===!1)e.clearColor(ye,ne,pe,Be),le.copy(ce)},reset:function(){U=!1,K=null,le.set(-1,0,0,0)}}}function i(){let U=!1,ce=!1,K=null,le=null,ye=null;return{setReversed:function(ne){if(ce!==ne){let pe=t.get("EXT_clip_control");if(ne)pe.clipControlEXT(pe.LOWER_LEFT_EXT,pe.ZERO_TO_ONE_EXT);else pe.clipControlEXT(pe.LOWER_LEFT_EXT,pe.NEGATIVE_ONE_TO_ONE_EXT);ce=ne;let Be=ye;ye=null,this.setClear(Be)}},getReversed:function(){return ce},setTest:function(ne){if(ne)se(e.DEPTH_TEST);else xe(e.DEPTH_TEST)},setMask:function(ne){if(K!==ne&&!U)e.depthMask(ne),K=ne},setFunc:function(ne){if(ce)ne=up[ne];if(le!==ne){switch(ne){case Fd:e.depthFunc(e.NEVER);break;case zd:e.depthFunc(e.ALWAYS);break;case kd:e.depthFunc(e.LESS);break;case _l:e.depthFunc(e.LEQUAL);break;case Bd:e.depthFunc(e.EQUAL);break;case Gd:e.depthFunc(e.GEQUAL);break;case Hd:e.depthFunc(e.GREATER);break;case Vd:e.depthFunc(e.NOTEQUAL);break;default:e.depthFunc(e.LEQUAL)}le=ne}},setLocked:function(ne){U=ne},setClear:function(ne){if(ye!==ne){if(ye=ne,ce)ne=1-ne;e.clearDepth(ne)}},reset:function(){U=!1,K=null,le=null,ye=null,ce=!1}}}function r(){let U=!1,ce=null,K=null,le=null,ye=null,ne=null,pe=null,Be=null,mt=null;return{setTest:function(it){if(!U)if(it)se(e.STENCIL_TEST);else xe(e.STENCIL_TEST)},setMask:function(it){if(ce!==it&&!U)e.stencilMask(it),ce=it},setFunc:function(it,Kn,vi){if(K!==it||le!==Kn||ye!==vi)e.stencilFunc(it,Kn,vi),K=it,le=Kn,ye=vi},setOp:function(it,Kn,vi){if(ne!==it||pe!==Kn||Be!==vi)e.stencilOp(it,Kn,vi),ne=it,pe=Kn,Be=vi},setLocked:function(it){U=it},setClear:function(it){if(mt!==it)e.clearStencil(it),mt=it},reset:function(){U=!1,ce=null,K=null,le=null,ye=null,ne=null,pe=null,Be=null,mt=null}}}let s=new n,o=new i,a=new r,c=new WeakMap,l=new WeakMap,u={},f={},h={},d=new WeakMap,g=[],x=null,p=!1,m=null,E=null,R=null,v=null,M=null,T=null,A=null,_=new Oe(0,0,0),S=0,z=!1,P=null,F=null,ee=null,I=null,H=null,q=e.getParameter(e.MAX_COMBINED_TEXTURE_IMAGE_UNITS),C=!1,X=0,k=e.getParameter(e.VERSION);if(k.indexOf("WebGL")!==-1)X=parseFloat(/^WebGL (\d)/.exec(k)[1]),C=X>=1;else if(k.indexOf("OpenGL ES")!==-1)X=parseFloat(/^OpenGL ES (\d)/.exec(k)[1]),C=X>=2;let Y=null,Q={},Se=e.getParameter(e.SCISSOR_BOX),ue=e.getParameter(e.VIEWPORT),Fe=new at().fromArray(Se),Me=new at().fromArray(ue);function Z(U,ce,K,le){let ye=new Uint8Array(4),ne=e.createTexture();e.bindTexture(U,ne),e.texParameteri(U,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(U,e.TEXTURE_MAG_FILTER,e.NEAREST);for(let pe=0;pe<K;pe++)if(U===e.TEXTURE_3D||U===e.TEXTURE_2D_ARRAY)e.texImage3D(ce,0,e.RGBA,1,1,le,0,e.RGBA,e.UNSIGNED_BYTE,ye);else e.texImage2D(ce+pe,0,e.RGBA,1,1,0,e.RGBA,e.UNSIGNED_BYTE,ye);return ne}let re={};re[e.TEXTURE_2D]=Z(e.TEXTURE_2D,e.TEXTURE_2D,1),re[e.TEXTURE_CUBE_MAP]=Z(e.TEXTURE_CUBE_MAP,e.TEXTURE_CUBE_MAP_POSITIVE_X,6),re[e.TEXTURE_2D_ARRAY]=Z(e.TEXTURE_2D_ARRAY,e.TEXTURE_2D_ARRAY,1,1),re[e.TEXTURE_3D]=Z(e.TEXTURE_3D,e.TEXTURE_3D,1,1),s.setClear(0,0,0,1),o.setClear(1),a.setClear(0),se(e.DEPTH_TEST),o.setFunc(_l),Zt(!1),yt(dl),se(e.CULL_FACE),st(ii);function se(U){if(u[U]!==!0)e.enable(U),u[U]=!0}function xe(U){if(u[U]!==!1)e.disable(U),u[U]=!1}function we(U,ce){if(h[U]!==ce){if(e.bindFramebuffer(U,ce),h[U]=ce,U===e.DRAW_FRAMEBUFFER)h[e.FRAMEBUFFER]=ce;if(U===e.FRAMEBUFFER)h[e.DRAW_FRAMEBUFFER]=ce;return!0}return!1}function Ee(U,ce){let K=g,le=!1;if(U){if(K=d.get(ce),K===void 0)K=[],d.set(ce,K);let ye=U.textures;if(K.length!==ye.length||K[0]!==e.COLOR_ATTACHMENT0){for(let ne=0,pe=ye.length;ne<pe;ne++)K[ne]=e.COLOR_ATTACHMENT0+ne;K.length=ye.length,le=!0}}else if(K[0]!==e.BACK)K[0]=e.BACK,le=!0;if(le)e.drawBuffers(K)}function xt(U){if(x!==U)return e.useProgram(U),x=U,!0;return!1}let ke={[os]:e.FUNC_ADD,[xd]:e.FUNC_SUBTRACT,[yd]:e.FUNC_REVERSE_SUBTRACT};ke[vd]=e.MIN,ke[bd]=e.MAX;let Ze={[Sd]:e.ZERO,[Md]:e.ONE,[wd]:e.SRC_COLOR,[Td]:e.SRC_ALPHA,[Ld]:e.SRC_ALPHA_SATURATE,[Pd]:e.DST_COLOR,[Rd]:e.DST_ALPHA,[Ed]:e.ONE_MINUS_SRC_COLOR,[Ad]:e.ONE_MINUS_SRC_ALPHA,[Id]:e.ONE_MINUS_DST_COLOR,[Cd]:e.ONE_MINUS_DST_ALPHA,[Nd]:e.CONSTANT_COLOR,[Dd]:e.ONE_MINUS_CONSTANT_COLOR,[Od]:e.CONSTANT_ALPHA,[Ud]:e.ONE_MINUS_CONSTANT_ALPHA};function st(U,ce,K,le,ye,ne,pe,Be,mt,it){if(U===ii){if(p===!0)xe(e.BLEND),p=!1;return}if(p===!1)se(e.BLEND),p=!0;if(U!==_d){if(U!==m||it!==z){if(E!==os||M!==os)e.blendEquation(e.FUNC_ADD),E=os,M=os;if(it)switch(U){case $s:e.blendFuncSeparate(e.ONE,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case pl:e.blendFunc(e.ONE,e.ONE);break;case ml:e.blendFuncSeparate(e.ZERO,e.ONE_MINUS_SRC_COLOR,e.ZERO,e.ONE);break;case gl:e.blendFuncSeparate(e.DST_COLOR,e.ONE_MINUS_SRC_ALPHA,e.ZERO,e.ONE);break;default:Ue("WebGLState: Invalid blending: ",U);break}else switch(U){case $s:e.blendFuncSeparate(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case pl:e.blendFuncSeparate(e.SRC_ALPHA,e.ONE,e.ONE,e.ONE);break;case ml:Ue("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case gl:Ue("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:Ue("WebGLState: Invalid blending: ",U);break}R=null,v=null,T=null,A=null,_.set(0,0,0),S=0,m=U,z=it}return}if(ye=ye||ce,ne=ne||K,pe=pe||le,ce!==E||ye!==M)e.blendEquationSeparate(ke[ce],ke[ye]),E=ce,M=ye;if(K!==R||le!==v||ne!==T||pe!==A)e.blendFuncSeparate(Ze[K],Ze[le],Ze[ne],Ze[pe]),R=K,v=le,T=ne,A=pe;if(Be.equals(_)===!1||mt!==S)e.blendColor(Be.r,Be.g,Be.b,mt),_.copy(Be),S=mt;m=U,z=!1}function Ye(U,ce){U.side===Pn?xe(e.CULL_FACE):se(e.CULL_FACE);let K=U.side===Qt;if(ce)K=!K;Zt(K),U.blending===$s&&U.transparent===!1?st(ii):st(U.blending,U.blendEquation,U.blendSrc,U.blendDst,U.blendEquationAlpha,U.blendSrcAlpha,U.blendDstAlpha,U.blendColor,U.blendAlpha,U.premultipliedAlpha),o.setFunc(U.depthFunc),o.setTest(U.depthTest),o.setMask(U.depthWrite),s.setMask(U.colorWrite);let le=U.stencilWrite;if(a.setTest(le),le)a.setMask(U.stencilWriteMask),a.setFunc(U.stencilFunc,U.stencilRef,U.stencilFuncMask),a.setOp(U.stencilFail,U.stencilZFail,U.stencilZPass);Dt(U.polygonOffset,U.polygonOffsetFactor,U.polygonOffsetUnits),U.alphaToCoverage===!0?se(e.SAMPLE_ALPHA_TO_COVERAGE):xe(e.SAMPLE_ALPHA_TO_COVERAGE)}function Zt(U){if(P!==U){if(U)e.frontFace(e.CW);else e.frontFace(e.CCW);P=U}}function yt(U){if(U!==pd){if(se(e.CULL_FACE),U!==F)if(U===dl)e.cullFace(e.BACK);else if(U===md)e.cullFace(e.FRONT);else e.cullFace(e.FRONT_AND_BACK)}else xe(e.CULL_FACE);F=U}function cn(U){if(U!==ee){if(C)e.lineWidth(U);ee=U}}function Dt(U,ce,K){if(U){if(se(e.POLYGON_OFFSET_FILL),I!==ce||H!==K){if(I=ce,H=K,o.getReversed())ce=-ce;e.polygonOffset(ce,K)}}else xe(e.POLYGON_OFFSET_FILL)}function Ot(U){if(U)se(e.SCISSOR_TEST);else xe(e.SCISSOR_TEST)}function N(U){if(U===void 0)U=e.TEXTURE0+q-1;if(Y!==U)e.activeTexture(U),Y=U}function ln(U,ce,K){if(K===void 0)if(Y===null)K=e.TEXTURE0+q-1;else K=Y;let le=Q[K];if(le===void 0)le={type:void 0,texture:void 0},Q[K]=le;if(le.type!==U||le.texture!==ce){if(Y!==K)e.activeTexture(K),Y=K;e.bindTexture(U,ce||re[U]),le.type=U,le.texture=ce}}function nt(){let U=Q[Y];if(U!==void 0&&U.type!==void 0)e.bindTexture(U.type,null),U.type=void 0,U.texture=void 0}function wt(){try{e.compressedTexImage2D(...arguments)}catch(U){Ue("WebGLState:",U)}}function w(){try{e.compressedTexImage3D(...arguments)}catch(U){Ue("WebGLState:",U)}}function y(){try{e.texSubImage2D(...arguments)}catch(U){Ue("WebGLState:",U)}}function L(){try{e.texSubImage3D(...arguments)}catch(U){Ue("WebGLState:",U)}}function V(){try{e.compressedTexSubImage2D(...arguments)}catch(U){Ue("WebGLState:",U)}}function ie(){try{e.compressedTexSubImage3D(...arguments)}catch(U){Ue("WebGLState:",U)}}function ae(){try{e.texStorage2D(...arguments)}catch(U){Ue("WebGLState:",U)}}function he(){try{e.texStorage3D(...arguments)}catch(U){Ue("WebGLState:",U)}}function j(){try{e.texImage2D(...arguments)}catch(U){Ue("WebGLState:",U)}}function te(){try{e.texImage3D(...arguments)}catch(U){Ue("WebGLState:",U)}}function _e(U){if(f[U]!==void 0)return f[U];else return e.getParameter(U)}function Pe(U,ce){if(f[U]!==ce)e.pixelStorei(U,ce),f[U]=ce}function fe(U){if(Fe.equals(U)===!1)e.scissor(U.x,U.y,U.z,U.w),Fe.copy(U)}function oe(U){if(Me.equals(U)===!1)e.viewport(U.x,U.y,U.z,U.w),Me.copy(U)}function Le(U,ce){let K=l.get(ce);if(K===void 0)K=new WeakMap,l.set(ce,K);let le=K.get(U);if(le===void 0)le=e.getUniformBlockIndex(ce,U.name),K.set(U,le)}function De(U,ce){let le=l.get(ce).get(U);if(c.get(ce)!==le)e.uniformBlockBinding(ce,le,U.__bindingPointIndex),c.set(ce,le)}function Qe(){e.disable(e.BLEND),e.disable(e.CULL_FACE),e.disable(e.DEPTH_TEST),e.disable(e.POLYGON_OFFSET_FILL),e.disable(e.SCISSOR_TEST),e.disable(e.STENCIL_TEST),e.disable(e.SAMPLE_ALPHA_TO_COVERAGE),e.blendEquation(e.FUNC_ADD),e.blendFunc(e.ONE,e.ZERO),e.blendFuncSeparate(e.ONE,e.ZERO,e.ONE,e.ZERO),e.blendColor(0,0,0,0),e.colorMask(!0,!0,!0,!0),e.clearColor(0,0,0,0),e.depthMask(!0),e.depthFunc(e.LESS),o.setReversed(!1),e.clearDepth(1),e.stencilMask(4294967295),e.stencilFunc(e.ALWAYS,0,4294967295),e.stencilOp(e.KEEP,e.KEEP,e.KEEP),e.clearStencil(0),e.cullFace(e.BACK),e.frontFace(e.CCW),e.polygonOffset(0,0),e.activeTexture(e.TEXTURE0),e.bindFramebuffer(e.FRAMEBUFFER,null),e.bindFramebuffer(e.DRAW_FRAMEBUFFER,null),e.bindFramebuffer(e.READ_FRAMEBUFFER,null),e.useProgram(null),e.lineWidth(1),e.scissor(0,0,e.canvas.width,e.canvas.height),e.viewport(0,0,e.canvas.width,e.canvas.height),e.pixelStorei(e.PACK_ALIGNMENT,4),e.pixelStorei(e.UNPACK_ALIGNMENT,4),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,!1),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,e.BROWSER_DEFAULT_WEBGL),e.pixelStorei(e.PACK_ROW_LENGTH,0),e.pixelStorei(e.PACK_SKIP_PIXELS,0),e.pixelStorei(e.PACK_SKIP_ROWS,0),e.pixelStorei(e.UNPACK_ROW_LENGTH,0),e.pixelStorei(e.UNPACK_IMAGE_HEIGHT,0),e.pixelStorei(e.UNPACK_SKIP_PIXELS,0),e.pixelStorei(e.UNPACK_SKIP_ROWS,0),e.pixelStorei(e.UNPACK_SKIP_IMAGES,0),u={},f={},Y=null,Q={},h={},d=new WeakMap,g=[],x=null,p=!1,m=null,E=null,R=null,v=null,M=null,T=null,A=null,_=new Oe(0,0,0),S=0,z=!1,P=null,F=null,ee=null,I=null,H=null,Fe.set(0,0,e.canvas.width,e.canvas.height),Me.set(0,0,e.canvas.width,e.canvas.height),s.reset(),o.reset(),a.reset()}return{buffers:{color:s,depth:o,stencil:a},enable:se,disable:xe,bindFramebuffer:we,drawBuffers:Ee,useProgram:xt,setBlending:st,setMaterial:Ye,setFlipSided:Zt,setCullFace:yt,setLineWidth:cn,setPolygonOffset:Dt,setScissorTest:Ot,activeTexture:N,bindTexture:ln,unbindTexture:nt,compressedTexImage2D:wt,compressedTexImage3D:w,texImage2D:j,texImage3D:te,pixelStorei:Pe,getParameter:_e,updateUBOMapping:Le,uniformBlockBinding:De,texStorage2D:ae,texStorage3D:he,texSubImage2D:y,texSubImage3D:L,compressedTexSubImage2D:V,compressedTexSubImage3D:ie,scissor:fe,viewport:oe,reset:Qe}}function rT(e,t,n,i,r,s,o){let a=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):null,c=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),l=new Ne,u=new WeakMap,f=new Set,h,d=new WeakMap,g=!1;try{g=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch(w){}function x(w,y){return g?new OffscreenCanvas(w,y):ns("canvas")}function p(w,y,L){let V=1,ie=wt(w);if(ie.width>L||ie.height>L)V=L/Math.max(ie.width,ie.height);if(V<1)if(typeof HTMLImageElement<"u"&&w instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&w instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&w instanceof ImageBitmap||typeof VideoFrame<"u"&&w instanceof VideoFrame){let ae=Math.floor(V*ie.width),he=Math.floor(V*ie.height);if(h===void 0)h=x(ae,he);let j=y?x(ae,he):h;return j.width=ae,j.height=he,j.getContext("2d").drawImage(w,0,0,ae,he),Ie("WebGLRenderer: Texture has been resized from ("+ie.width+"x"+ie.height+") to ("+ae+"x"+he+")."),j}else{if("data"in w)Ie("WebGLRenderer: Image in DataTexture is too big ("+ie.width+"x"+ie.height+").");return w}return w}function m(w){return w.generateMipmaps}function E(w){e.generateMipmap(w)}function R(w){if(w.isWebGLCubeRenderTarget)return e.TEXTURE_CUBE_MAP;if(w.isWebGL3DRenderTarget)return e.TEXTURE_3D;if(w.isWebGLArrayRenderTarget||w.isCompressedArrayTexture)return e.TEXTURE_2D_ARRAY;return e.TEXTURE_2D}function v(w,y,L,V,ie,ae=!1){if(w!==null){if(e[w]!==void 0)return e[w];Ie("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+w+"'")}let he;if(V){if(he=t.get("EXT_texture_norm16"),!he)Ie("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension")}let j=y;if(y===e.RED){if(L===e.FLOAT)j=e.R32F;if(L===e.HALF_FLOAT)j=e.R16F;if(L===e.UNSIGNED_BYTE)j=e.R8;if(L===e.UNSIGNED_SHORT&&he)j=he.R16_EXT;if(L===e.SHORT&&he)j=he.R16_SNORM_EXT}if(y===e.RED_INTEGER){if(L===e.UNSIGNED_BYTE)j=e.R8UI;if(L===e.UNSIGNED_SHORT)j=e.R16UI;if(L===e.UNSIGNED_INT)j=e.R32UI;if(L===e.BYTE)j=e.R8I;if(L===e.SHORT)j=e.R16I;if(L===e.INT)j=e.R32I}if(y===e.RG){if(L===e.FLOAT)j=e.RG32F;if(L===e.HALF_FLOAT)j=e.RG16F;if(L===e.UNSIGNED_BYTE)j=e.RG8;if(L===e.UNSIGNED_SHORT&&he)j=he.RG16_EXT;if(L===e.SHORT&&he)j=he.RG16_SNORM_EXT}if(y===e.RG_INTEGER){if(L===e.UNSIGNED_BYTE)j=e.RG8UI;if(L===e.UNSIGNED_SHORT)j=e.RG16UI;if(L===e.UNSIGNED_INT)j=e.RG32UI;if(L===e.BYTE)j=e.RG8I;if(L===e.SHORT)j=e.RG16I;if(L===e.INT)j=e.RG32I}if(y===e.RGB_INTEGER){if(L===e.UNSIGNED_BYTE)j=e.RGB8UI;if(L===e.UNSIGNED_SHORT)j=e.RGB16UI;if(L===e.UNSIGNED_INT)j=e.RGB32UI;if(L===e.BYTE)j=e.RGB8I;if(L===e.SHORT)j=e.RGB16I;if(L===e.INT)j=e.RGB32I}if(y===e.RGBA_INTEGER){if(L===e.UNSIGNED_BYTE)j=e.RGBA8UI;if(L===e.UNSIGNED_SHORT)j=e.RGBA16UI;if(L===e.UNSIGNED_INT)j=e.RGBA32UI;if(L===e.BYTE)j=e.RGBA8I;if(L===e.SHORT)j=e.RGBA16I;if(L===e.INT)j=e.RGBA32I}if(y===e.RGB){if(L===e.UNSIGNED_SHORT&&he)j=he.RGB16_EXT;if(L===e.SHORT&&he)j=he.RGB16_SNORM_EXT;if(L===e.UNSIGNED_INT_5_9_9_9_REV)j=e.RGB9_E5;if(L===e.UNSIGNED_INT_10F_11F_11F_REV)j=e.R11F_G11F_B10F}if(y===e.RGBA){let te=ae?lu:$e.getTransfer(ie);if(L===e.FLOAT)j=e.RGBA32F;if(L===e.HALF_FLOAT)j=e.RGBA16F;if(L===e.UNSIGNED_BYTE)j=te===dt?e.SRGB8_ALPHA8:e.RGBA8;if(L===e.UNSIGNED_SHORT&&he)j=he.RGBA16_EXT;if(L===e.SHORT&&he)j=he.RGBA16_SNORM_EXT;if(L===e.UNSIGNED_SHORT_4_4_4_4)j=e.RGBA4;if(L===e.UNSIGNED_SHORT_5_5_5_1)j=e.RGB5_A1}if(j===e.R16F||j===e.R32F||j===e.RG16F||j===e.RG32F||j===e.RGBA16F||j===e.RGBA32F)t.get("EXT_color_buffer_float");return j}function M(w,y){let L;if(w){if(y===null||y===ji||y===hs)L=e.DEPTH24_STENCIL8;else if(y===Ri)L=e.DEPTH32F_STENCIL8;else if(y===Xs)L=e.DEPTH24_STENCIL8,Ie("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")}else if(y===null||y===ji||y===hs)L=e.DEPTH_COMPONENT24;else if(y===Ri)L=e.DEPTH_COMPONENT32F;else if(y===Xs)L=e.DEPTH_COMPONENT16;return L}function T(w,y){if(m(w)===!0||w.isFramebufferTexture&&w.minFilter!==Vn&&w.minFilter!==$t)return Math.log2(Math.max(y.width,y.height))+1;else if(w.mipmaps!==void 0&&w.mipmaps.length>0)return w.mipmaps.length;else if(w.isCompressedTexture&&Array.isArray(w.image))return y.mipmaps.length;else return 1}function A(w){let y=w.target;if(y.removeEventListener("dispose",A),S(y),y.isVideoTexture)u.delete(y);if(y.isHTMLTexture)f.delete(y)}function _(w){let y=w.target;y.removeEventListener("dispose",_),P(y)}function S(w){let y=i.get(w);if(y.__webglInit===void 0)return;let L=w.source,V=d.get(L);if(V){let ie=V[y.__cacheKey];if(ie.usedTimes--,ie.usedTimes===0)z(w);if(Object.keys(V).length===0)d.delete(L)}i.remove(w)}function z(w){let y=i.get(w);e.deleteTexture(y.__webglTexture);let L=w.source,V=d.get(L);delete V[y.__cacheKey],o.memory.textures--}function P(w){let y=i.get(w);if(w.depthTexture)w.depthTexture.dispose(),i.remove(w.depthTexture);if(w.isWebGLCubeRenderTarget)for(let V=0;V<6;V++){if(Array.isArray(y.__webglFramebuffer[V]))for(let ie=0;ie<y.__webglFramebuffer[V].length;ie++)e.deleteFramebuffer(y.__webglFramebuffer[V][ie]);else e.deleteFramebuffer(y.__webglFramebuffer[V]);if(y.__webglDepthbuffer)e.deleteRenderbuffer(y.__webglDepthbuffer[V])}else{if(Array.isArray(y.__webglFramebuffer))for(let V=0;V<y.__webglFramebuffer.length;V++)e.deleteFramebuffer(y.__webglFramebuffer[V]);else e.deleteFramebuffer(y.__webglFramebuffer);if(y.__webglDepthbuffer)e.deleteRenderbuffer(y.__webglDepthbuffer);if(y.__webglMultisampledFramebuffer)e.deleteFramebuffer(y.__webglMultisampledFramebuffer);if(y.__webglColorRenderbuffer){for(let V=0;V<y.__webglColorRenderbuffer.length;V++)if(y.__webglColorRenderbuffer[V])e.deleteRenderbuffer(y.__webglColorRenderbuffer[V])}if(y.__webglDepthRenderbuffer)e.deleteRenderbuffer(y.__webglDepthRenderbuffer)}let L=w.textures;for(let V=0,ie=L.length;V<ie;V++){let ae=i.get(L[V]);if(ae.__webglTexture)e.deleteTexture(ae.__webglTexture),o.memory.textures--;i.remove(L[V])}i.remove(w)}let F=0;function ee(){F=0}function I(){return F}function H(w){F=w}function q(){let w=F;if(w>=r.maxTextures)Ie("WebGLTextures: Trying to use "+(w+1)+" texture units while this GPU supports only "+r.maxTextures);return F+=1,w}function C(w){let y=[];return y.push(w.wrapS),y.push(w.wrapT),y.push(w.wrapR||0),y.push(w.magFilter),y.push(w.minFilter),y.push(w.anisotropy),y.push(w.internalFormat),y.push(w.format),y.push(w.type),y.push(w.generateMipmaps),y.push(w.premultiplyAlpha),y.push(w.flipY),y.push(w.unpackAlignment),y.push(w.colorSpace),y.join()}function X(w,y){let L=i.get(w);if(w.isVideoTexture)ln(w);if(w.isRenderTargetTexture===!1&&w.isExternalTexture!==!0&&w.version>0&&L.__version!==w.version){let V=w.image;if(V===null)Ie("WebGLRenderer: Texture marked for update but no image data found.");else if(V.complete===!1)Ie("WebGLRenderer: Texture marked for update but image is incomplete");else{xe(L,w,y);return}}else if(w.isExternalTexture)L.__webglTexture=w.sourceTexture?w.sourceTexture:null;n.bindTexture(e.TEXTURE_2D,L.__webglTexture,e.TEXTURE0+y)}function k(w,y){let L=i.get(w);if(w.isRenderTargetTexture===!1&&w.version>0&&L.__version!==w.version){xe(L,w,y);return}else if(w.isExternalTexture)L.__webglTexture=w.sourceTexture?w.sourceTexture:null;n.bindTexture(e.TEXTURE_2D_ARRAY,L.__webglTexture,e.TEXTURE0+y)}function Y(w,y){let L=i.get(w);if(w.isRenderTargetTexture===!1&&w.version>0&&L.__version!==w.version){xe(L,w,y);return}n.bindTexture(e.TEXTURE_3D,L.__webglTexture,e.TEXTURE0+y)}function Q(w,y){let L=i.get(w);if(w.isCubeDepthTexture!==!0&&w.version>0&&L.__version!==w.version){we(L,w,y);return}n.bindTexture(e.TEXTURE_CUBE_MAP,L.__webglTexture,e.TEXTURE0+y)}let Se={[cs]:e.REPEAT,[ls]:e.CLAMP_TO_EDGE,[Sa]:e.MIRRORED_REPEAT},ue={[Vn]:e.NEAREST,[Ma]:e.NEAREST_MIPMAP_NEAREST,[br]:e.NEAREST_MIPMAP_LINEAR,[$t]:e.LINEAR,[us]:e.LINEAR_MIPMAP_NEAREST,[ri]:e.LINEAR_MIPMAP_LINEAR},Fe={[tp]:e.NEVER,[op]:e.ALWAYS,[np]:e.LESS,[Ia]:e.LEQUAL,[ip]:e.EQUAL,[La]:e.GEQUAL,[rp]:e.GREATER,[sp]:e.NOTEQUAL};function Me(w,y){if(y.type===Ri&&t.has("OES_texture_float_linear")===!1&&(y.magFilter===$t||y.magFilter===us||y.magFilter===br||y.magFilter===ri||y.minFilter===$t||y.minFilter===us||y.minFilter===br||y.minFilter===ri))Ie("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device.");if(e.texParameteri(w,e.TEXTURE_WRAP_S,Se[y.wrapS]),e.texParameteri(w,e.TEXTURE_WRAP_T,Se[y.wrapT]),w===e.TEXTURE_3D||w===e.TEXTURE_2D_ARRAY)e.texParameteri(w,e.TEXTURE_WRAP_R,Se[y.wrapR]);if(e.texParameteri(w,e.TEXTURE_MAG_FILTER,ue[y.magFilter]),e.texParameteri(w,e.TEXTURE_MIN_FILTER,ue[y.minFilter]),y.compareFunction)e.texParameteri(w,e.TEXTURE_COMPARE_MODE,e.COMPARE_REF_TO_TEXTURE),e.texParameteri(w,e.TEXTURE_COMPARE_FUNC,Fe[y.compareFunction]);if(t.has("EXT_texture_filter_anisotropic")===!0){if(y.magFilter===Vn)return;if(y.minFilter!==br&&y.minFilter!==ri)return;if(y.type===Ri&&t.has("OES_texture_float_linear")===!1)return;if(y.anisotropy>1||i.get(y).__currentAnisotropy){let L=t.get("EXT_texture_filter_anisotropic");e.texParameterf(w,L.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(y.anisotropy,r.getMaxAnisotropy())),i.get(y).__currentAnisotropy=y.anisotropy}}}function Z(w,y){let L=!1;if(w.__webglInit===void 0)w.__webglInit=!0,y.addEventListener("dispose",A);let V=y.source,ie=d.get(V);if(ie===void 0)ie={},d.set(V,ie);let ae=C(y);if(ae!==w.__cacheKey){if(ie[ae]===void 0)ie[ae]={texture:e.createTexture(),usedTimes:0},o.memory.textures++,L=!0;ie[ae].usedTimes++;let he=ie[w.__cacheKey];if(he!==void 0){if(ie[w.__cacheKey].usedTimes--,he.usedTimes===0)z(y)}w.__cacheKey=ae,w.__webglTexture=ie[ae].texture}return L}function re(w,y,L){return Math.floor(Math.floor(w/L)/y)}function se(w,y,L,V){let ae=w.updateRanges;if(ae.length===0)n.texSubImage2D(e.TEXTURE_2D,0,0,0,y.width,y.height,L,V,y.data);else{ae.sort((Pe,fe)=>Pe.start-fe.start);let he=0;for(let Pe=1;Pe<ae.length;Pe++){let fe=ae[he],oe=ae[Pe],Le=fe.start+fe.count,De=re(oe.start,y.width,4),Qe=re(fe.start,y.width,4);if(oe.start<=Le+1&&De===Qe&&re(oe.start+oe.count-1,y.width,4)===De)fe.count=Math.max(fe.count,oe.start+oe.count-fe.start);else++he,ae[he]=oe}ae.length=he+1;let j=n.getParameter(e.UNPACK_ROW_LENGTH),te=n.getParameter(e.UNPACK_SKIP_PIXELS),_e=n.getParameter(e.UNPACK_SKIP_ROWS);n.pixelStorei(e.UNPACK_ROW_LENGTH,y.width);for(let Pe=0,fe=ae.length;Pe<fe;Pe++){let oe=ae[Pe],Le=Math.floor(oe.start/4),De=Math.ceil(oe.count/4),Qe=Le%y.width,U=Math.floor(Le/y.width),ce=De,K=1;n.pixelStorei(e.UNPACK_SKIP_PIXELS,Qe),n.pixelStorei(e.UNPACK_SKIP_ROWS,U),n.texSubImage2D(e.TEXTURE_2D,0,Qe,U,ce,1,L,V,y.data)}w.clearUpdateRanges(),n.pixelStorei(e.UNPACK_ROW_LENGTH,j),n.pixelStorei(e.UNPACK_SKIP_PIXELS,te),n.pixelStorei(e.UNPACK_SKIP_ROWS,_e)}}function xe(w,y,L){let V=e.TEXTURE_2D;if(y.isDataArrayTexture||y.isCompressedArrayTexture)V=e.TEXTURE_2D_ARRAY;if(y.isData3DTexture)V=e.TEXTURE_3D;let ie=Z(w,y),ae=y.source;n.bindTexture(V,w.__webglTexture,e.TEXTURE0+L);let he=i.get(ae);if(ae.version!==he.__version||ie===!0){if(n.activeTexture(e.TEXTURE0+L),(typeof ImageBitmap<"u"&&y.image instanceof ImageBitmap)===!1){let K=$e.getPrimaries($e.workingColorSpace),le=y.colorSpace===Er?null:$e.getPrimaries(y.colorSpace),ye=y.colorSpace===Er||K===le?e.NONE:e.BROWSER_DEFAULT_WEBGL;n.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,y.flipY),n.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,y.premultiplyAlpha),n.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,ye)}n.pixelStorei(e.UNPACK_ALIGNMENT,y.unpackAlignment);let te=p(y.image,!1,r.maxTextureSize);te=nt(y,te);let _e=s.convert(y.format,y.colorSpace),Pe=s.convert(y.type),fe=v(y.internalFormat,_e,Pe,y.normalized,y.colorSpace,y.isVideoTexture);Me(V,y);let oe,Le=y.mipmaps,De=y.isVideoTexture!==!0,Qe=he.__version===void 0||ie===!0,U=ae.dataReady,ce=T(y,te);if(y.isDepthTexture){if(fe=M(y.format===Mr,y.type),Qe)if(De)n.texStorage2D(e.TEXTURE_2D,1,fe,te.width,te.height);else n.texImage2D(e.TEXTURE_2D,0,fe,te.width,te.height,0,_e,Pe,null)}else if(y.isDataTexture)if(Le.length>0){if(De&&Qe)n.texStorage2D(e.TEXTURE_2D,ce,fe,Le[0].width,Le[0].height);for(let K=0,le=Le.length;K<le;K++)if(oe=Le[K],De){if(U)n.texSubImage2D(e.TEXTURE_2D,K,0,0,oe.width,oe.height,_e,Pe,oe.data)}else n.texImage2D(e.TEXTURE_2D,K,fe,oe.width,oe.height,0,_e,Pe,oe.data);y.generateMipmaps=!1}else if(De){if(Qe)n.texStorage2D(e.TEXTURE_2D,ce,fe,te.width,te.height);if(U)se(y,te,_e,Pe)}else n.texImage2D(e.TEXTURE_2D,0,fe,te.width,te.height,0,_e,Pe,te.data);else if(y.isCompressedTexture)if(y.isCompressedArrayTexture){if(De&&Qe)n.texStorage3D(e.TEXTURE_2D_ARRAY,ce,fe,Le[0].width,Le[0].height,te.depth);for(let K=0,le=Le.length;K<le;K++)if(oe=Le[K],y.format!==oi)if(_e!==null)if(De){if(U)if(y.layerUpdates.size>0){let ye=Nu(oe.width,oe.height,y.format,y.type);for(let ne of y.layerUpdates){let pe=oe.data.subarray(ne*ye/oe.data.BYTES_PER_ELEMENT,(ne+1)*ye/oe.data.BYTES_PER_ELEMENT);n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,K,0,0,ne,oe.width,oe.height,1,_e,pe)}}else n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,K,0,0,0,oe.width,oe.height,te.depth,_e,oe.data)}else n.compressedTexImage3D(e.TEXTURE_2D_ARRAY,K,fe,oe.width,oe.height,te.depth,0,oe.data,0,0);else Ie("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else if(De){if(U)n.texSubImage3D(e.TEXTURE_2D_ARRAY,K,0,0,0,oe.width,oe.height,te.depth,_e,Pe,oe.data)}else n.texImage3D(e.TEXTURE_2D_ARRAY,K,fe,oe.width,oe.height,te.depth,0,_e,Pe,oe.data);if(y.layerUpdates.size>0)y.clearLayerUpdates()}else{if(De&&Qe)n.texStorage2D(e.TEXTURE_2D,ce,fe,Le[0].width,Le[0].height);for(let K=0,le=Le.length;K<le;K++)if(oe=Le[K],y.format!==oi)if(_e!==null)if(De){if(U)n.compressedTexSubImage2D(e.TEXTURE_2D,K,0,0,oe.width,oe.height,_e,oe.data)}else n.compressedTexImage2D(e.TEXTURE_2D,K,fe,oe.width,oe.height,0,oe.data);else Ie("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else if(De){if(U)n.texSubImage2D(e.TEXTURE_2D,K,0,0,oe.width,oe.height,_e,Pe,oe.data)}else n.texImage2D(e.TEXTURE_2D,K,fe,oe.width,oe.height,0,_e,Pe,oe.data)}else if(y.isDataArrayTexture)if(De){if(Qe)n.texStorage3D(e.TEXTURE_2D_ARRAY,ce,fe,te.width,te.height,te.depth);if(U)if(y.layerUpdates.size>0){let K=Nu(te.width,te.height,y.format,y.type);for(let le of y.layerUpdates){let ye=te.data.subarray(le*K/te.data.BYTES_PER_ELEMENT,(le+1)*K/te.data.BYTES_PER_ELEMENT);n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,le,te.width,te.height,1,_e,Pe,ye)}y.clearLayerUpdates()}else n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,0,te.width,te.height,te.depth,_e,Pe,te.data)}else n.texImage3D(e.TEXTURE_2D_ARRAY,0,fe,te.width,te.height,te.depth,0,_e,Pe,te.data);else if(y.isData3DTexture)if(De){if(Qe)n.texStorage3D(e.TEXTURE_3D,ce,fe,te.width,te.height,te.depth);if(U)n.texSubImage3D(e.TEXTURE_3D,0,0,0,0,te.width,te.height,te.depth,_e,Pe,te.data)}else n.texImage3D(e.TEXTURE_3D,0,fe,te.width,te.height,te.depth,0,_e,Pe,te.data);else if(y.isFramebufferTexture){if(Qe)if(De)n.texStorage2D(e.TEXTURE_2D,ce,fe,te.width,te.height);else{let K=te.width,le=te.height;for(let ye=0;ye<ce;ye++)n.texImage2D(e.TEXTURE_2D,ye,fe,K,le,0,_e,Pe,null),K>>=1,le>>=1}}else if(y.isHTMLTexture){if("texElementImage2D"in e){let K=e.canvas;if(!K.hasAttribute("layoutsubtree"))K.setAttribute("layoutsubtree","true");if(te.parentNode!==K){K.appendChild(te),f.add(y),K.onpaint=(le)=>{let ye=le.changedElements;for(let ne of f)if(ye.includes(ne.image))ne.needsUpdate=!0},K.requestPaint();return}if(e.texElementImage2D.length===3)e.texElementImage2D(e.TEXTURE_2D,e.RGBA8,te);else{let{RGBA:ye,RGBA:ne,UNSIGNED_BYTE:pe}=e;e.texElementImage2D(e.TEXTURE_2D,0,ye,ne,pe,te)}e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE)}}else if(Le.length>0){if(De&&Qe){let K=wt(Le[0]);n.texStorage2D(e.TEXTURE_2D,ce,fe,K.width,K.height)}for(let K=0,le=Le.length;K<le;K++)if(oe=Le[K],De){if(U)n.texSubImage2D(e.TEXTURE_2D,K,0,0,_e,Pe,oe)}else n.texImage2D(e.TEXTURE_2D,K,fe,_e,Pe,oe);y.generateMipmaps=!1}else if(De){if(Qe){let K=wt(te);n.texStorage2D(e.TEXTURE_2D,ce,fe,K.width,K.height)}if(U)n.texSubImage2D(e.TEXTURE_2D,0,0,0,_e,Pe,te)}else n.texImage2D(e.TEXTURE_2D,0,fe,_e,Pe,te);if(m(y))E(V);if(he.__version=ae.version,y.onUpdate)y.onUpdate(y)}w.__version=y.version}function we(w,y,L){if(y.image.length!==6)return;let V=Z(w,y),ie=y.source;n.bindTexture(e.TEXTURE_CUBE_MAP,w.__webglTexture,e.TEXTURE0+L);let ae=i.get(ie);if(ie.version!==ae.__version||V===!0){n.activeTexture(e.TEXTURE0+L);let he=$e.getPrimaries($e.workingColorSpace),j=y.colorSpace===Er?null:$e.getPrimaries(y.colorSpace),te=y.colorSpace===Er||he===j?e.NONE:e.BROWSER_DEFAULT_WEBGL;n.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,y.flipY),n.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,y.premultiplyAlpha),n.pixelStorei(e.UNPACK_ALIGNMENT,y.unpackAlignment),n.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,te);let _e=y.isCompressedTexture||y.image[0].isCompressedTexture,Pe=y.image[0]&&y.image[0].isDataTexture,fe=[];for(let ne=0;ne<6;ne++){if(!_e&&!Pe)fe[ne]=p(y.image[ne],!0,r.maxCubemapSize);else fe[ne]=Pe?y.image[ne].image:y.image[ne];fe[ne]=nt(y,fe[ne])}let oe=fe[0],Le=s.convert(y.format,y.colorSpace),De=s.convert(y.type),Qe=v(y.internalFormat,Le,De,y.normalized,y.colorSpace),U=y.isVideoTexture!==!0,ce=ae.__version===void 0||V===!0,K=ie.dataReady,le=T(y,oe);Me(e.TEXTURE_CUBE_MAP,y);let ye;if(_e){if(U&&ce)n.texStorage2D(e.TEXTURE_CUBE_MAP,le,Qe,oe.width,oe.height);for(let ne=0;ne<6;ne++){ye=fe[ne].mipmaps;for(let pe=0;pe<ye.length;pe++){let Be=ye[pe];if(y.format!==oi)if(Le!==null)if(U){if(K)n.compressedTexSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,pe,0,0,Be.width,Be.height,Le,Be.data)}else n.compressedTexImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,pe,Qe,Be.width,Be.height,0,Be.data);else Ie("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()");else if(U){if(K)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,pe,0,0,Be.width,Be.height,Le,De,Be.data)}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,pe,Qe,Be.width,Be.height,0,Le,De,Be.data)}}}else{if(ye=y.mipmaps,U&&ce){if(ye.length>0)le++;let ne=wt(fe[0]);n.texStorage2D(e.TEXTURE_CUBE_MAP,le,Qe,ne.width,ne.height)}for(let ne=0;ne<6;ne++)if(Pe){if(U){if(K)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,0,0,0,fe[ne].width,fe[ne].height,Le,De,fe[ne].data)}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,0,Qe,fe[ne].width,fe[ne].height,0,Le,De,fe[ne].data);for(let pe=0;pe<ye.length;pe++){let mt=ye[pe].image[ne].image;if(U){if(K)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,pe+1,0,0,mt.width,mt.height,Le,De,mt.data)}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,pe+1,Qe,mt.width,mt.height,0,Le,De,mt.data)}}else{if(U){if(K)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,0,0,0,Le,De,fe[ne])}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,0,Qe,Le,De,fe[ne]);for(let pe=0;pe<ye.length;pe++){let Be=ye[pe];if(U){if(K)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,pe+1,0,0,Le,De,Be.image[ne])}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,pe+1,Qe,Le,De,Be.image[ne])}}}if(m(y))E(e.TEXTURE_CUBE_MAP);if(ae.__version=ie.version,y.onUpdate)y.onUpdate(y)}w.__version=y.version}function Ee(w,y,L,V,ie,ae){let he=s.convert(L.format,L.colorSpace),j=s.convert(L.type),te=v(L.internalFormat,he,j,L.normalized,L.colorSpace),_e=i.get(y),Pe=i.get(L);if(Pe.__renderTarget=y,!_e.__hasExternalTextures){let fe=Math.max(1,y.width>>ae),oe=Math.max(1,y.height>>ae);if(ie===e.TEXTURE_3D||ie===e.TEXTURE_2D_ARRAY)n.texImage3D(ie,ae,te,fe,oe,y.depth,0,he,j,null);else n.texImage2D(ie,ae,te,fe,oe,0,he,j,null)}if(n.bindFramebuffer(e.FRAMEBUFFER,w),N(y))a.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,V,ie,Pe.__webglTexture,0,Ot(y));else if(ie===e.TEXTURE_2D||ie>=e.TEXTURE_CUBE_MAP_POSITIVE_X&&ie<=e.TEXTURE_CUBE_MAP_NEGATIVE_Z)e.framebufferTexture2D(e.FRAMEBUFFER,V,ie,Pe.__webglTexture,ae);n.bindFramebuffer(e.FRAMEBUFFER,null)}function xt(w,y,L){if(e.bindRenderbuffer(e.RENDERBUFFER,w),y.depthBuffer){let V=y.depthTexture,ie=V&&V.isDepthTexture?V.type:null,ae=M(y.stencilBuffer,ie),he=y.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;if(N(y))a.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,Ot(y),ae,y.width,y.height);else if(L)e.renderbufferStorageMultisample(e.RENDERBUFFER,Ot(y),ae,y.width,y.height);else e.renderbufferStorage(e.RENDERBUFFER,ae,y.width,y.height);e.framebufferRenderbuffer(e.FRAMEBUFFER,he,e.RENDERBUFFER,w)}else{let V=y.textures;for(let ie=0;ie<V.length;ie++){let ae=V[ie],he=s.convert(ae.format,ae.colorSpace),j=s.convert(ae.type),te=v(ae.internalFormat,he,j,ae.normalized,ae.colorSpace);if(N(y))a.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,Ot(y),te,y.width,y.height);else if(L)e.renderbufferStorageMultisample(e.RENDERBUFFER,Ot(y),te,y.width,y.height);else e.renderbufferStorage(e.RENDERBUFFER,te,y.width,y.height)}}e.bindRenderbuffer(e.RENDERBUFFER,null)}function ke(w,y,L){let V=y.isWebGLCubeRenderTarget===!0;if(n.bindFramebuffer(e.FRAMEBUFFER,w),!(y.depthTexture&&y.depthTexture.isDepthTexture))throw Error("THREE.WebGLTextures: renderTarget.depthTexture must be an instance of THREE.DepthTexture.");let ie=i.get(y.depthTexture);if(ie.__renderTarget=y,!ie.__webglTexture||y.depthTexture.image.width!==y.width||y.depthTexture.image.height!==y.height)y.depthTexture.image.width=y.width,y.depthTexture.image.height=y.height,y.depthTexture.needsUpdate=!0;if(V){if(ie.__webglInit===void 0)ie.__webglInit=!0,y.depthTexture.addEventListener("dispose",A);if(ie.__webglTexture===void 0){ie.__webglTexture=e.createTexture(),n.bindTexture(e.TEXTURE_CUBE_MAP,ie.__webglTexture),Me(e.TEXTURE_CUBE_MAP,y.depthTexture);let _e=s.convert(y.depthTexture.format),Pe=s.convert(y.depthTexture.type),fe;if(y.depthTexture.format===Sr)fe=e.DEPTH_COMPONENT24;else if(y.depthTexture.format===Mr)fe=e.DEPTH24_STENCIL8;for(let oe=0;oe<6;oe++)e.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+oe,0,fe,y.width,y.height,0,_e,Pe,null)}}else X(y.depthTexture,0);let ae=ie.__webglTexture,he=Ot(y),j=V?e.TEXTURE_CUBE_MAP_POSITIVE_X+L:e.TEXTURE_2D,te=y.depthTexture.format===Mr?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;if(y.depthTexture.format===Sr)if(N(y))a.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,te,j,ae,0,he);else e.framebufferTexture2D(e.FRAMEBUFFER,te,j,ae,0);else if(y.depthTexture.format===Mr)if(N(y))a.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,te,j,ae,0,he);else e.framebufferTexture2D(e.FRAMEBUFFER,te,j,ae,0);else throw Error("THREE.WebGLTextures: Unknown depthTexture format.")}function Ze(w){let y=i.get(w),L=w.isWebGLCubeRenderTarget===!0;if(y.__boundDepthTexture!==w.depthTexture){let V=w.depthTexture;if(y.__depthDisposeCallback)y.__depthDisposeCallback();if(V){let ie=()=>{delete y.__boundDepthTexture,delete y.__depthDisposeCallback,V.removeEventListener("dispose",ie)};V.addEventListener("dispose",ie),y.__depthDisposeCallback=ie}y.__boundDepthTexture=V}if(w.depthTexture&&!y.__autoAllocateDepthBuffer)if(L)for(let V=0;V<6;V++)ke(y.__webglFramebuffer[V],w,V);else{let V=w.texture.mipmaps;if(V&&V.length>0)ke(y.__webglFramebuffer[0],w,0);else ke(y.__webglFramebuffer,w,0)}else if(L){y.__webglDepthbuffer=[];for(let V=0;V<6;V++)if(n.bindFramebuffer(e.FRAMEBUFFER,y.__webglFramebuffer[V]),y.__webglDepthbuffer[V]===void 0)y.__webglDepthbuffer[V]=e.createRenderbuffer(),xt(y.__webglDepthbuffer[V],w,!1);else{let ie=w.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,ae=y.__webglDepthbuffer[V];e.bindRenderbuffer(e.RENDERBUFFER,ae),e.framebufferRenderbuffer(e.FRAMEBUFFER,ie,e.RENDERBUFFER,ae)}}else{let V=w.texture.mipmaps;if(V&&V.length>0)n.bindFramebuffer(e.FRAMEBUFFER,y.__webglFramebuffer[0]);else n.bindFramebuffer(e.FRAMEBUFFER,y.__webglFramebuffer);if(y.__webglDepthbuffer===void 0)y.__webglDepthbuffer=e.createRenderbuffer(),xt(y.__webglDepthbuffer,w,!1);else{let ie=w.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,ae=y.__webglDepthbuffer;e.bindRenderbuffer(e.RENDERBUFFER,ae),e.framebufferRenderbuffer(e.FRAMEBUFFER,ie,e.RENDERBUFFER,ae)}}n.bindFramebuffer(e.FRAMEBUFFER,null)}function st(w,y,L){let V=i.get(w);if(y!==void 0)Ee(V.__webglFramebuffer,w,w.texture,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,0);if(L!==void 0)Ze(w)}function Ye(w){let y=w.texture,L=i.get(w),V=i.get(y);w.addEventListener("dispose",_);let ie=w.textures,ae=w.isWebGLCubeRenderTarget===!0,he=ie.length>1;if(!he){if(V.__webglTexture===void 0)V.__webglTexture=e.createTexture();V.__version=y.version,o.memory.textures++}if(ae){L.__webglFramebuffer=[];for(let j=0;j<6;j++)if(y.mipmaps&&y.mipmaps.length>0){L.__webglFramebuffer[j]=[];for(let te=0;te<y.mipmaps.length;te++)L.__webglFramebuffer[j][te]=e.createFramebuffer()}else L.__webglFramebuffer[j]=e.createFramebuffer()}else{if(y.mipmaps&&y.mipmaps.length>0){L.__webglFramebuffer=[];for(let j=0;j<y.mipmaps.length;j++)L.__webglFramebuffer[j]=e.createFramebuffer()}else L.__webglFramebuffer=e.createFramebuffer();if(he)for(let j=0,te=ie.length;j<te;j++){let _e=i.get(ie[j]);if(_e.__webglTexture===void 0)_e.__webglTexture=e.createTexture(),o.memory.textures++}if(w.samples>0&&N(w)===!1){L.__webglMultisampledFramebuffer=e.createFramebuffer(),L.__webglColorRenderbuffer=[],n.bindFramebuffer(e.FRAMEBUFFER,L.__webglMultisampledFramebuffer);for(let j=0;j<ie.length;j++){let te=ie[j];L.__webglColorRenderbuffer[j]=e.createRenderbuffer(),e.bindRenderbuffer(e.RENDERBUFFER,L.__webglColorRenderbuffer[j]);let _e=s.convert(te.format,te.colorSpace),Pe=s.convert(te.type),fe=v(te.internalFormat,_e,Pe,te.normalized,te.colorSpace,w.isXRRenderTarget===!0),oe=Ot(w);e.renderbufferStorageMultisample(e.RENDERBUFFER,oe,fe,w.width,w.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+j,e.RENDERBUFFER,L.__webglColorRenderbuffer[j])}if(e.bindRenderbuffer(e.RENDERBUFFER,null),w.depthBuffer)L.__webglDepthRenderbuffer=e.createRenderbuffer(),xt(L.__webglDepthRenderbuffer,w,!0);n.bindFramebuffer(e.FRAMEBUFFER,null)}}if(ae){n.bindTexture(e.TEXTURE_CUBE_MAP,V.__webglTexture),Me(e.TEXTURE_CUBE_MAP,y);for(let j=0;j<6;j++)if(y.mipmaps&&y.mipmaps.length>0)for(let te=0;te<y.mipmaps.length;te++)Ee(L.__webglFramebuffer[j][te],w,y,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+j,te);else Ee(L.__webglFramebuffer[j],w,y,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+j,0);if(m(y))E(e.TEXTURE_CUBE_MAP);n.unbindTexture()}else if(he){for(let j=0,te=ie.length;j<te;j++){let _e=ie[j],Pe=i.get(_e),fe=e.TEXTURE_2D;if(w.isWebGL3DRenderTarget||w.isWebGLArrayRenderTarget)fe=w.isWebGL3DRenderTarget?e.TEXTURE_3D:e.TEXTURE_2D_ARRAY;if(n.bindTexture(fe,Pe.__webglTexture),Me(fe,_e),Ee(L.__webglFramebuffer,w,_e,e.COLOR_ATTACHMENT0+j,fe,0),m(_e))E(fe)}n.unbindTexture()}else{let j=e.TEXTURE_2D;if(w.isWebGL3DRenderTarget||w.isWebGLArrayRenderTarget)j=w.isWebGL3DRenderTarget?e.TEXTURE_3D:e.TEXTURE_2D_ARRAY;if(n.bindTexture(j,V.__webglTexture),Me(j,y),y.mipmaps&&y.mipmaps.length>0)for(let te=0;te<y.mipmaps.length;te++)Ee(L.__webglFramebuffer[te],w,y,e.COLOR_ATTACHMENT0,j,te);else Ee(L.__webglFramebuffer,w,y,e.COLOR_ATTACHMENT0,j,0);if(m(y))E(j);n.unbindTexture()}if(w.depthBuffer)Ze(w)}function Zt(w){let y=w.textures;for(let L=0,V=y.length;L<V;L++){let ie=y[L];if(m(ie)){let ae=R(w),he=i.get(ie).__webglTexture;n.bindTexture(ae,he),E(ae),n.unbindTexture()}}}let yt=[],cn=[];function Dt(w){if(w.samples>0){if(N(w)===!1){let{textures:y,width:L,height:V}=w,ie=e.COLOR_BUFFER_BIT,ae=w.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,he=i.get(w),j=y.length>1;if(j)for(let _e=0;_e<y.length;_e++)n.bindFramebuffer(e.FRAMEBUFFER,he.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+_e,e.RENDERBUFFER,null),n.bindFramebuffer(e.FRAMEBUFFER,he.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+_e,e.TEXTURE_2D,null,0);n.bindFramebuffer(e.READ_FRAMEBUFFER,he.__webglMultisampledFramebuffer);let te=w.texture.mipmaps;if(te&&te.length>0)n.bindFramebuffer(e.DRAW_FRAMEBUFFER,he.__webglFramebuffer[0]);else n.bindFramebuffer(e.DRAW_FRAMEBUFFER,he.__webglFramebuffer);for(let _e=0;_e<y.length;_e++){if(w.resolveDepthBuffer){if(w.depthBuffer)ie|=e.DEPTH_BUFFER_BIT;if(w.stencilBuffer&&w.resolveStencilBuffer)ie|=e.STENCIL_BUFFER_BIT}if(j){e.framebufferRenderbuffer(e.READ_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.RENDERBUFFER,he.__webglColorRenderbuffer[_e]);let Pe=i.get(y[_e]).__webglTexture;e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,Pe,0)}if(e.blitFramebuffer(0,0,L,V,0,0,L,V,ie,e.NEAREST),c===!0){if(yt.length=0,cn.length=0,yt.push(e.COLOR_ATTACHMENT0+_e),w.depthBuffer&&w.storeMultisampledDepthBuffer===!1)yt.push(ae),cn.push(ae),e.invalidateFramebuffer(e.DRAW_FRAMEBUFFER,cn);e.invalidateFramebuffer(e.READ_FRAMEBUFFER,yt)}}if(n.bindFramebuffer(e.READ_FRAMEBUFFER,null),n.bindFramebuffer(e.DRAW_FRAMEBUFFER,null),j)for(let _e=0;_e<y.length;_e++){n.bindFramebuffer(e.FRAMEBUFFER,he.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+_e,e.RENDERBUFFER,he.__webglColorRenderbuffer[_e]);let Pe=i.get(y[_e]).__webglTexture;n.bindFramebuffer(e.FRAMEBUFFER,he.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+_e,e.TEXTURE_2D,Pe,0)}n.bindFramebuffer(e.DRAW_FRAMEBUFFER,he.__webglMultisampledFramebuffer)}else if(w.depthBuffer&&w.storeMultisampledDepthBuffer===!1&&c){let y=w.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;e.invalidateFramebuffer(e.DRAW_FRAMEBUFFER,[y])}}}function Ot(w){return Math.min(r.maxSamples,w.samples)}function N(w){let y=i.get(w);return w.samples>0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&y.__useRenderToTexture!==!1}function ln(w){let y=o.render.frame;if(u.get(w)!==y)u.set(w,y),w.update()}function nt(w,y){let{colorSpace:L,format:V,type:ie}=w;if(w.isCompressedTexture===!0||w.isVideoTexture===!0)return y;if(L!==gn&&L!==Er)if($e.getTransfer(L)===dt){if(V!==oi||ie!==$n)Ie("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType.")}else Ue("WebGLTextures: Unsupported texture color space:",L);return y}function wt(w){if(typeof HTMLImageElement<"u"&&w instanceof HTMLImageElement)l.width=w.naturalWidth||w.width,l.height=w.naturalHeight||w.height;else if(typeof VideoFrame<"u"&&w instanceof VideoFrame)l.width=w.displayWidth,l.height=w.displayHeight;else l.width=w.width,l.height=w.height;return l}this.allocateTextureUnit=q,this.resetTextureUnits=ee,this.getTextureUnits=I,this.setTextureUnits=H,this.setTexture2D=X,this.setTexture2DArray=k,this.setTexture3D=Y,this.setTextureCube=Q,this.rebindTextures=st,this.setupRenderTarget=Ye,this.updateRenderTargetMipmap=Zt,this.updateMultisampleRenderTarget=Dt,this.setupDepthRenderbuffer=Ze,this.setupFrameBufferTexture=Ee,this.useMultisampledRTT=N,this.isReversedDepthBuffer=function(){return n.buffers.depth.getReversed()}}function sT(e,t){function n(i,r=Er){let s,o=$e.getTransfer(r);if(i===$n)return e.UNSIGNED_BYTE;if(i===El)return e.UNSIGNED_SHORT_4_4_4_4;if(i===Tl)return e.UNSIGNED_SHORT_5_5_5_1;if(i===jd)return e.UNSIGNED_INT_5_9_9_9_REV;if(i===Yd)return e.UNSIGNED_INT_10F_11F_11F_REV;if(i===Xd)return e.BYTE;if(i===qd)return e.SHORT;if(i===Xs)return e.UNSIGNED_SHORT;if(i===wl)return e.INT;if(i===ji)return e.UNSIGNED_INT;if(i===Ri)return e.FLOAT;if(i===si)return e.HALF_FLOAT;if(i===Kd)return e.ALPHA;if(i===Jd)return e.RGB;if(i===oi)return e.RGBA;if(i===Sr)return e.DEPTH_COMPONENT;if(i===Mr)return e.DEPTH_STENCIL;if(i===Qd)return e.RED;if(i===Al)return e.RED_INTEGER;if(i===wr)return e.RG;if(i===Rl)return e.RG_INTEGER;if(i===Cl)return e.RGBA_INTEGER;if(i===wa||i===Ea||i===Ta||i===Aa)if(o===dt)if(s=t.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(i===wa)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===Ea)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===Ta)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===Aa)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=t.get("WEBGL_compressed_texture_s3tc"),s!==null){if(i===wa)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===Ea)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===Ta)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===Aa)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(i===Pl||i===Il||i===Ll||i===Nl)if(s=t.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(i===Pl)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===Il)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===Ll)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===Nl)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(i===Dl||i===Ol||i===Ul||i===Fl||i===zl||i===Ra||i===kl)if(s=t.get("WEBGL_compressed_texture_etc"),s!==null){if(i===Dl||i===Ol)return o===dt?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(i===Ul)return o===dt?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC;if(i===Fl)return s.COMPRESSED_R11_EAC;if(i===zl)return s.COMPRESSED_SIGNED_R11_EAC;if(i===Ra)return s.COMPRESSED_RG11_EAC;if(i===kl)return s.COMPRESSED_SIGNED_RG11_EAC}else return null;if(i===Bl||i===Gl||i===Hl||i===Vl||i===$l||i===Wl||i===Zl||i===Xl||i===ql||i===jl||i===Yl||i===Kl||i===Jl||i===Ql)if(s=t.get("WEBGL_compressed_texture_astc"),s!==null){if(i===Bl)return o===dt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===Gl)return o===dt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===Hl)return o===dt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===Vl)return o===dt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===$l)return o===dt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===Wl)return o===dt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===Zl)return o===dt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===Xl)return o===dt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===ql)return o===dt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===jl)return o===dt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===Yl)return o===dt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===Kl)return o===dt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===Jl)return o===dt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===Ql)return o===dt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(i===eu||i===tu||i===nu)if(s=t.get("EXT_texture_compression_bptc"),s!==null){if(i===eu)return o===dt?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===tu)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===nu)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(i===iu||i===ru||i===Ca||i===su)if(s=t.get("EXT_texture_compression_rgtc"),s!==null){if(i===iu)return s.COMPRESSED_RED_RGTC1_EXT;if(i===ru)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===Ca)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===su)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;if(i===hs)return e.UNSIGNED_INT_24_8;return e[i]!==void 0?e[i]:null}return{convert:n}}var oT=`
4321
4321
  void main() {
4322
4322
 
4323
4323
  gl_Position = vec4( position, 1.0 );
4324
4324
 
4325
- }`,sT=`
4325
+ }`,aT=`
4326
4326
  uniform sampler2DArray depthColor;
4327
4327
  uniform float depthWidth;
4328
4328
  uniform float depthHeight;
@@ -4341,11 +4341,11 @@ void main() {
4341
4341
 
4342
4342
  }
4343
4343
 
4344
- }`;class Kp{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){let n=new ka(e.texture);if(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)this.depthNear=e.depthNear,this.depthFar=e.depthFar;this.texture=n}}getMesh(e){if(this.texture!==null){if(this.mesh===null){let t=e.cameras[0].viewport,n=new Pn({vertexShader:rT,fragmentShader:sT,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new xt(new to(20,20),n)}}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class Jp extends $n{constructor(e,t){super();let n=this,i=null,r=1,s=null,o="local-floor",a=1,c=null,l=null,u=null,f=null,h=null,d=null,g=typeof XRWebGLBinding<"u",x=new Kp,p={},m=t.getContextAttributes(),E=null,R=null,v=[],M=[],T=new Ne,A=null,_=null,S=new Ut;S.viewport=new ct;let k=new Ut;k.viewport=new ct;let C=[S,k],U=new Tu,ee=null,P=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(X){let re=v[X];if(re===void 0)re=new Xs,v[X]=re;return re.getTargetRaySpace()},this.getControllerGrip=function(X){let re=v[X];if(re===void 0)re=new Xs,v[X]=re;return re.getGripSpace()},this.getHand=function(X){let re=v[X];if(re===void 0)re=new Xs,v[X]=re;return re.getHandSpace()};function V(X){let re=M.indexOf(X.inputSource);if(re===-1)return;let se=v[re];if(se!==void 0)se.update(X.inputSource,X.frame,c||s),se.dispatchEvent({type:X.type,data:X.inputSource})}function j(){i.removeEventListener("select",V),i.removeEventListener("selectstart",V),i.removeEventListener("selectend",V),i.removeEventListener("squeeze",V),i.removeEventListener("squeezestart",V),i.removeEventListener("squeezeend",V),i.removeEventListener("end",j),i.removeEventListener("inputsourceschange",z);for(let X=0;X<v.length;X++){let re=M[X];if(re===null)continue;M[X]=null,v[X].disconnect(re)}ee=null,P=null,x.reset();for(let X in p)delete p[X];if(e.setRenderTarget(E),h=null,f=null,u=null,i=null,R=null,ye.stop(),n.isPresenting=!1,e.setPixelRatio(A),e.setSize(T.width,T.height,!1),_!==null){let X=_.camera;X.fov=_.fov,X.zoom=_.zoom,X.updateProjectionMatrix(),_=null}n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(X){if(r=X,n.isPresenting===!0)Pe("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(X){if(o=X,n.isPresenting===!0)Pe("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||s},this.setReferenceSpace=function(X){c=X},this.getBaseLayer=function(){return f!==null?f:h},this.getBinding=function(){if(u===null&&g)u=new XRWebGLBinding(i,t);return u},this.getFrame=function(){return d},this.getSession=function(){return i},this.setSession=async function(X){if(i=X,i!==null){if(E=e.getRenderTarget(),i.addEventListener("select",V),i.addEventListener("selectstart",V),i.addEventListener("selectend",V),i.addEventListener("squeeze",V),i.addEventListener("squeezestart",V),i.addEventListener("squeezeend",V),i.addEventListener("end",j),i.addEventListener("inputsourceschange",z),m.xrCompatible!==!0)await t.makeXRCompatible();if(A=e.getPixelRatio(),e.getSize(T),!(g&&("createProjectionLayer"in XRWebGLBinding.prototype))){let se={antialias:m.antialias,alpha:!0,depth:m.depth,stencil:m.stencil,framebufferScaleFactor:r};h=new XRWebGLLayer(i,t,se),i.updateRenderState({baseLayer:h}),e.setPixelRatio(1),e.setSize(h.framebufferWidth,h.framebufferHeight,!1),R=new _n(h.framebufferWidth,h.framebufferHeight,{format:oi,type:Vn,colorSpace:e.outputColorSpace,stencilBuffer:m.stencil,resolveDepthBuffer:h.ignoreDepthValues===!1,resolveStencilBuffer:h.ignoreDepthValues===!1,storeMultisampledDepthBuffer:h.ignoreDepthValues===!1,storeMultisampledStencilBuffer:h.ignoreDepthValues===!1})}else{let se=null,Te=null,Ie=null;if(m.depth)Ie=m.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,se=m.stencil?Sr:br,Te=m.stencil?ls:qi;let _e={colorFormat:t.RGBA8,depthFormat:Ie,scaleFactor:r};u=this.getBinding(),f=u.createProjectionLayer(_e),i.updateRenderState({layers:[f]}),e.setPixelRatio(1),e.setSize(f.textureWidth,f.textureHeight,!1),R=new _n(f.textureWidth,f.textureHeight,{format:oi,type:Vn,depthTexture:new Er(f.textureWidth,f.textureHeight,Te,void 0,void 0,void 0,void 0,void 0,void 0,se),stencilBuffer:m.stencil,colorSpace:e.outputColorSpace,samples:m.antialias?4:0,resolveDepthBuffer:f.ignoreDepthValues===!1,resolveStencilBuffer:f.ignoreDepthValues===!1,storeMultisampledDepthBuffer:f.ignoreDepthValues===!1,storeMultisampledStencilBuffer:f.ignoreDepthValues===!1})}R.isXRRenderTarget=!0,this.setFoveation(a),c=null,s=await i.requestReferenceSpace(o),ye.setContext(i),ye.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode},this.getDepthTexture=function(){return x.getDepthTexture()};function z(X){for(let re=0;re<X.removed.length;re++){let se=X.removed[re],Te=M.indexOf(se);if(Te>=0)M[Te]=null,v[Te].disconnect(se)}for(let re=0;re<X.added.length;re++){let se=X.added[re],Te=M.indexOf(se);if(Te===-1){for(let _e=0;_e<v.length;_e++)if(_e>=M.length){M.push(se),Te=_e;break}else if(M[_e]===null){M[_e]=se,Te=_e;break}if(Te===-1)break}let Ie=v[Te];if(Ie)Ie.connect(se)}}let H=new D,F=new D;function q(X,re,se){H.setFromMatrixPosition(re.matrixWorld),F.setFromMatrixPosition(se.matrixWorld);let Te=H.distanceTo(F),Ie=re.projectionMatrix.elements,_e=se.projectionMatrix.elements,Qe=Ie[14]/(Ie[10]-1),ze=Ie[14]/(Ie[10]+1),Ze=(Ie[9]+1)/Ie[5],ot=(Ie[9]-1)/Ie[5],Ye=(Ie[8]-1)/Ie[0],Zt=(_e[8]+1)/_e[0],yt=Qe*Ye,cn=Qe*Zt,Dt=Te/(-Ye+Zt),Ot=Dt*-Ye;if(re.matrixWorld.decompose(X.position,X.quaternion,X.scale),X.translateX(Ot),X.translateZ(Dt),X.matrixWorld.compose(X.position,X.quaternion,X.scale),X.matrixWorldInverse.copy(X.matrixWorld).invert(),Ie[10]===-1)X.projectionMatrix.copy(re.projectionMatrix),X.projectionMatrixInverse.copy(re.projectionMatrixInverse);else{let L=Qe+Dt,ln=ze+Dt,it=yt-Ot,wt=cn+(Te-Ot),w=Ze*ze/ln*L,y=ot*ze/ln*L;X.projectionMatrix.makePerspective(it,wt,w,y,L,ln),X.projectionMatrixInverse.copy(X.projectionMatrix).invert()}}function K(X,re){if(re===null)X.matrixWorld.copy(X.matrix);else X.matrixWorld.multiplyMatrices(re.matrixWorld,X.matrix);X.matrixWorldInverse.copy(X.matrixWorld).invert()}this.updateCamera=function(X){if(i===null)return;let{near:re,far:se}=X;if(x.texture!==null){if(x.depthNear>0)re=x.depthNear;if(x.depthFar>0)se=x.depthFar}if(U.near=k.near=S.near=re,U.far=k.far=S.far=se,ee!==U.near||P!==U.far)i.updateRenderState({depthNear:U.near,depthFar:U.far}),ee=U.near,P=U.far;U.layers.mask=X.layers.mask|6,S.layers.mask=U.layers.mask&-5,k.layers.mask=U.layers.mask&-3;let Te=X.parent,Ie=U.cameras;K(U,Te);for(let _e=0;_e<Ie.length;_e++)K(Ie[_e],Te);if(Ie.length===2)q(U,S,k);else U.projectionMatrix.copy(S.projectionMatrix);if(_===null&&X.isPerspectiveCamera)_={camera:X,fov:X.fov,zoom:X.zoom};xe(X,U,Te)};function xe(X,re,se){if(se===null)X.matrix.copy(re.matrixWorld);else X.matrix.copy(se.matrixWorld),X.matrix.invert(),X.matrix.multiply(re.matrixWorld);if(X.matrix.decompose(X.position,X.quaternion,X.scale),X.updateMatrixWorld(!0),X.projectionMatrix.copy(re.projectionMatrix),X.projectionMatrixInverse.copy(re.projectionMatrixInverse),X.isPerspectiveCamera)X.fov=xr*2*Math.atan(1/X.projectionMatrix.elements[5]),X.zoom=1}this.getCamera=function(){return U},this.getFoveation=function(){if(f===null&&h===null)return;return a},this.setFoveation=function(X){if(a=X,f!==null)f.fixedFoveation=X;if(h!==null&&h.fixedFoveation!==void 0)h.fixedFoveation=X},this.hasDepthSensing=function(){return x.texture!==null},this.getDepthSensingMesh=function(){return x.getMesh(U)},this.getCameraTexture=function(X){return p[X]};let ce=null;function De(X,re){if(l=re.getViewerPose(c||s),d=re,l!==null){let se=l.views;if(h!==null)e.setRenderTargetFramebuffer(R,h.framebuffer),e.setRenderTarget(R);let Te=!1;if(se.length!==U.cameras.length)U.cameras.length=0,Te=!0;for(let ze=0;ze<se.length;ze++){let Ze=se[ze],ot=null;if(h!==null)ot=h.getViewport(Ze);else{let Zt=u.getViewSubImage(f,Ze);if(ot=Zt.viewport,ze===0)e.setRenderTargetTextures(R,Zt.colorTexture,Zt.depthStencilTexture),e.setRenderTarget(R)}let Ye=C[ze];if(Ye===void 0)Ye=new Ut,Ye.layers.enable(ze),Ye.viewport=new ct,C[ze]=Ye;if(Ye.matrix.fromArray(Ze.transform.matrix),Ye.matrix.decompose(Ye.position,Ye.quaternion,Ye.scale),Ye.projectionMatrix.fromArray(Ze.projectionMatrix),Ye.projectionMatrixInverse.copy(Ye.projectionMatrix).invert(),Ye.viewport.set(ot.x,ot.y,ot.width,ot.height),ze===0)U.matrix.copy(Ye.matrix),U.matrix.decompose(U.position,U.quaternion,U.scale);if(Te===!0)U.cameras.push(Ye)}let Ie=i.enabledFeatures;if(Ie&&Ie.includes("depth-sensing")&&i.depthUsage=="gpu-optimized"&&g){u=n.getBinding();let ze=u.getDepthInformation(se[0]);if(ze&&ze.isValid&&ze.texture)x.init(ze,i.renderState)}if(Ie&&Ie.includes("camera-access")&&g){e.state.unbindTexture(),u=n.getBinding();for(let ze=0;ze<se.length;ze++){let Ze=se[ze].camera;if(Ze){let ot=p[Ze];if(!ot)ot=new ka,p[Ze]=ot;let Ye=u.getCameraImage(Ze);ot.sourceTexture=Ye}}}}for(let se=0;se<v.length;se++){let Te=M[se],Ie=v[se];if(Te!==null&&Ie!==void 0)Ie.update(Te,re,c||s)}if(ce)ce(X,re);if(re.detectedPlanes)n.dispatchEvent({type:"planesdetected",data:re});d=null}let ye=new Bp;ye.setAnimationLoop(De),this.setAnimationLoop=function(X){ce=X},this.dispose=function(){}}}var oT=new Ge,Qp=new ke;Qp.set(-1,0,0,0,1,0,0,0,1);function aT(e,t){function n(p,m){if(p.matrixAutoUpdate===!0)p.updateMatrix();m.value.copy(p.matrix)}function i(p,m){if(m.color.getRGB(p.fogColor.value,gu(e)),m.isFog)p.fogNear.value=m.near,p.fogFar.value=m.far;else if(m.isFogExp2)p.fogDensity.value=m.density}function r(p,m,E,R,v){if(m.isNodeMaterial)m.uniformsNeedUpdate=!1;else if(m.isMeshBasicMaterial)s(p,m);else if(m.isMeshLambertMaterial){if(s(p,m),m.envMap)p.envMapIntensity.value=m.envMapIntensity}else if(m.isMeshToonMaterial)s(p,m),f(p,m);else if(m.isMeshPhongMaterial){if(s(p,m),u(p,m),m.envMap)p.envMapIntensity.value=m.envMapIntensity}else if(m.isMeshStandardMaterial){if(s(p,m),h(p,m),m.isMeshPhysicalMaterial)d(p,m,v)}else if(m.isMeshMatcapMaterial)s(p,m),g(p,m);else if(m.isMeshDepthMaterial)s(p,m);else if(m.isMeshDistanceMaterial)s(p,m),x(p,m);else if(m.isMeshNormalMaterial)s(p,m);else if(m.isLineBasicMaterial){if(o(p,m),m.isLineDashedMaterial)a(p,m)}else if(m.isPointsMaterial)c(p,m,E,R);else if(m.isSpriteMaterial)l(p,m);else if(m.isShadowMaterial)p.color.value.copy(m.color),p.opacity.value=m.opacity;else if(m.isShaderMaterial)m.uniformsNeedUpdate=!1}function s(p,m){if(p.opacity.value=m.opacity,m.color)p.diffuse.value.copy(m.color);if(m.emissive)p.emissive.value.copy(m.emissive).multiplyScalar(m.emissiveIntensity);if(m.map)p.map.value=m.map,n(m.map,p.mapTransform);if(m.alphaMap)p.alphaMap.value=m.alphaMap,n(m.alphaMap,p.alphaMapTransform);if(m.bumpMap){if(p.bumpMap.value=m.bumpMap,n(m.bumpMap,p.bumpMapTransform),p.bumpScale.value=m.bumpScale,m.side===Qt)p.bumpScale.value*=-1}if(m.normalMap){if(p.normalMap.value=m.normalMap,n(m.normalMap,p.normalMapTransform),p.normalScale.value.copy(m.normalScale),m.side===Qt)p.normalScale.value.negate()}if(m.displacementMap)p.displacementMap.value=m.displacementMap,n(m.displacementMap,p.displacementMapTransform),p.displacementScale.value=m.displacementScale,p.displacementBias.value=m.displacementBias;if(m.emissiveMap)p.emissiveMap.value=m.emissiveMap,n(m.emissiveMap,p.emissiveMapTransform);if(m.specularMap)p.specularMap.value=m.specularMap,n(m.specularMap,p.specularMapTransform);if(m.alphaTest>0)p.alphaTest.value=m.alphaTest;let E=t.get(m),{envMap:R,envMapRotation:v}=E;if(R){if(p.envMap.value=R,p.envMapRotation.value.setFromMatrix4(oT.makeRotationFromEuler(v)).transpose(),R.isCubeTexture&&R.isRenderTargetTexture===!1)p.envMapRotation.value.premultiply(Qp);p.reflectivity.value=m.reflectivity,p.ior.value=m.ior,p.refractionRatio.value=m.refractionRatio}if(m.lightMap)p.lightMap.value=m.lightMap,p.lightMapIntensity.value=m.lightMapIntensity,n(m.lightMap,p.lightMapTransform);if(m.aoMap)p.aoMap.value=m.aoMap,p.aoMapIntensity.value=m.aoMapIntensity,n(m.aoMap,p.aoMapTransform)}function o(p,m){if(p.diffuse.value.copy(m.color),p.opacity.value=m.opacity,m.map)p.map.value=m.map,n(m.map,p.mapTransform)}function a(p,m){p.dashSize.value=m.dashSize,p.totalSize.value=m.dashSize+m.gapSize,p.scale.value=m.scale}function c(p,m,E,R){if(p.diffuse.value.copy(m.color),p.opacity.value=m.opacity,p.size.value=m.size*E,p.scale.value=R*0.5,m.map)p.map.value=m.map,n(m.map,p.uvTransform);if(m.alphaMap)p.alphaMap.value=m.alphaMap,n(m.alphaMap,p.alphaMapTransform);if(m.alphaTest>0)p.alphaTest.value=m.alphaTest}function l(p,m){if(p.diffuse.value.copy(m.color),p.opacity.value=m.opacity,p.rotation.value=m.rotation,m.map)p.map.value=m.map,n(m.map,p.mapTransform);if(m.alphaMap)p.alphaMap.value=m.alphaMap,n(m.alphaMap,p.alphaMapTransform);if(m.alphaTest>0)p.alphaTest.value=m.alphaTest}function u(p,m){p.specular.value.copy(m.specular),p.shininess.value=Math.max(m.shininess,0.0001)}function f(p,m){if(m.gradientMap)p.gradientMap.value=m.gradientMap}function h(p,m){if(p.metalness.value=m.metalness,m.metalnessMap)p.metalnessMap.value=m.metalnessMap,n(m.metalnessMap,p.metalnessMapTransform);if(p.roughness.value=m.roughness,m.roughnessMap)p.roughnessMap.value=m.roughnessMap,n(m.roughnessMap,p.roughnessMapTransform);if(m.envMap)p.envMapIntensity.value=m.envMapIntensity}function d(p,m,E){if(p.ior.value=m.ior,m.sheen>0){if(p.sheenColor.value.copy(m.sheenColor).multiplyScalar(m.sheen),p.sheenRoughness.value=m.sheenRoughness,m.sheenColorMap)p.sheenColorMap.value=m.sheenColorMap,n(m.sheenColorMap,p.sheenColorMapTransform);if(m.sheenRoughnessMap)p.sheenRoughnessMap.value=m.sheenRoughnessMap,n(m.sheenRoughnessMap,p.sheenRoughnessMapTransform)}if(m.clearcoat>0){if(p.clearcoat.value=m.clearcoat,p.clearcoatRoughness.value=m.clearcoatRoughness,m.clearcoatMap)p.clearcoatMap.value=m.clearcoatMap,n(m.clearcoatMap,p.clearcoatMapTransform);if(m.clearcoatRoughnessMap)p.clearcoatRoughnessMap.value=m.clearcoatRoughnessMap,n(m.clearcoatRoughnessMap,p.clearcoatRoughnessMapTransform);if(m.clearcoatNormalMap){if(p.clearcoatNormalMap.value=m.clearcoatNormalMap,n(m.clearcoatNormalMap,p.clearcoatNormalMapTransform),p.clearcoatNormalScale.value.copy(m.clearcoatNormalScale),m.side===Qt)p.clearcoatNormalScale.value.negate()}}if(m.dispersion>0)p.dispersion.value=m.dispersion;if(m.retroreflectivity>0)p.retroreflectivity.value=m.retroreflectivity;if(m.iridescence>0){if(p.iridescence.value=m.iridescence,p.iridescenceIOR.value=m.iridescenceIOR,p.iridescenceThicknessMinimum.value=m.iridescenceThicknessRange[0],p.iridescenceThicknessMaximum.value=m.iridescenceThicknessRange[1],m.iridescenceMap)p.iridescenceMap.value=m.iridescenceMap,n(m.iridescenceMap,p.iridescenceMapTransform);if(m.iridescenceThicknessMap)p.iridescenceThicknessMap.value=m.iridescenceThicknessMap,n(m.iridescenceThicknessMap,p.iridescenceThicknessMapTransform)}if(m.transmission>0){if(p.transmission.value=m.transmission,p.transmissionSamplerMap.value=E.texture,p.transmissionSamplerSize.value.set(E.width,E.height),m.transmissionMap)p.transmissionMap.value=m.transmissionMap,n(m.transmissionMap,p.transmissionMapTransform);if(p.thickness.value=m.thickness,m.thicknessMap)p.thicknessMap.value=m.thicknessMap,n(m.thicknessMap,p.thicknessMapTransform);p.attenuationDistance.value=m.attenuationDistance,p.attenuationColor.value.copy(m.attenuationColor)}if(m.anisotropy>0){if(p.anisotropyVector.value.set(m.anisotropy*Math.cos(m.anisotropyRotation),m.anisotropy*Math.sin(m.anisotropyRotation)),m.anisotropyMap)p.anisotropyMap.value=m.anisotropyMap,n(m.anisotropyMap,p.anisotropyMapTransform)}if(p.specularIntensity.value=m.specularIntensity,p.specularColor.value.copy(m.specularColor),m.specularColorMap)p.specularColorMap.value=m.specularColorMap,n(m.specularColorMap,p.specularColorMapTransform);if(m.specularIntensityMap)p.specularIntensityMap.value=m.specularIntensityMap,n(m.specularIntensityMap,p.specularIntensityMapTransform)}function g(p,m){if(m.matcap)p.matcap.value=m.matcap}function x(p,m){let E=t.get(m).light;p.referencePosition.value.setFromMatrixPosition(E.matrixWorld),p.nearDistance.value=E.shadow.camera.near,p.farDistance.value=E.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:r}}function cT(e,t,n,i){let r={},s={},o=[],a=e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS);function c(v,M){let T=M.program;i.uniformBlockBinding(v,T)}function l(v,M){let T=r[v.id];if(T===void 0)p(v),T=u(v),r[v.id]=T,v.addEventListener("dispose",E);let A=M.program;i.updateUBOMapping(v,A);let _=t.render.frame;if(s[v.id]!==_)h(v),s[v.id]=_}function u(v){let M=f();v.__bindingPointIndex=M;let T=e.createBuffer(),{__size:A,usage:_}=v;return e.bindBuffer(e.UNIFORM_BUFFER,T),e.bufferData(e.UNIFORM_BUFFER,A,_),e.bindBuffer(e.UNIFORM_BUFFER,null),e.bindBufferBase(e.UNIFORM_BUFFER,M,T),T}function f(){for(let v=0;v<a;v++)if(o.indexOf(v)===-1)return o.push(v),v;return Fe("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function h(v){let M=r[v.id],{uniforms:T,__cache:A}=v;e.bindBuffer(e.UNIFORM_BUFFER,M);for(let _=0,S=T.length;_<S;_++){let k=T[_];if(Array.isArray(k))for(let C=0,U=k.length;C<U;C++)d(k[C],_,C,A);else d(k,_,0,A)}e.bindBuffer(e.UNIFORM_BUFFER,null)}function d(v,M,T,A){if(x(v,M,T,A)===!0){let{__offset:_,value:S}=v;if(Array.isArray(S)){let k=0;for(let C=0;C<S.length;C++){let U=S[C],ee=m(U);if(g(U,v.__data,k),typeof U!=="number"&&typeof U!=="boolean"&&!U.isMatrix3&&!ArrayBuffer.isView(U))k+=ee.storage/Float32Array.BYTES_PER_ELEMENT}}else g(S,v.__data,0);e.bufferSubData(e.UNIFORM_BUFFER,_,v.__data)}}function g(v,M,T){if(typeof v==="number"||typeof v==="boolean")M[0]=v;else if(v.isMatrix3)M[0]=v.elements[0],M[1]=v.elements[1],M[2]=v.elements[2],M[3]=0,M[4]=v.elements[3],M[5]=v.elements[4],M[6]=v.elements[5],M[7]=0,M[8]=v.elements[6],M[9]=v.elements[7],M[10]=v.elements[8],M[11]=0;else if(ArrayBuffer.isView(v))M.set(new v.constructor(v.buffer,v.byteOffset,M.length));else v.toArray(M,T)}function x(v,M,T,A){let _=v.value,S=M+"_"+T;if(A[S]===void 0){if(typeof _==="number"||typeof _==="boolean")A[S]=_;else if(ArrayBuffer.isView(_))A[S]=_.slice();else A[S]=_.clone();return!0}else{let k=A[S];if(typeof _==="number"||typeof _==="boolean"){if(k!==_)return A[S]=_,!0}else if(ArrayBuffer.isView(_))return!0;else if(k.equals(_)===!1)return k.copy(_),!0}return!1}function p(v){let M=v.uniforms,T=0,A=16;for(let S=0,k=M.length;S<k;S++){let C=Array.isArray(M[S])?M[S]:[M[S]];for(let U=0,ee=C.length;U<ee;U++){let P=C[U],V=Array.isArray(P.value)?P.value:[P.value];for(let j=0,z=V.length;j<z;j++){let H=V[j],F=m(H),q=T%A,K=q%F.boundary,xe=q+K;if(T+=K,xe!==0&&A-xe<F.storage)T+=A-xe;P.__data=new Float32Array(F.storage/Float32Array.BYTES_PER_ELEMENT),P.__offset=T,T+=F.storage}}}let _=T%A;if(_>0)T+=A-_;return v.__size=T,v.__cache={},this}function m(v){let M={boundary:0,storage:0};if(typeof v==="number"||typeof v==="boolean")M.boundary=4,M.storage=4;else if(v.isVector2)M.boundary=8,M.storage=8;else if(v.isVector3||v.isColor)M.boundary=16,M.storage=12;else if(v.isVector4)M.boundary=16,M.storage=16;else if(v.isMatrix3)M.boundary=48,M.storage=48;else if(v.isMatrix4)M.boundary=64,M.storage=64;else if(v.isTexture)Pe("WebGLRenderer: Texture samplers can not be part of an uniforms group.");else if(ArrayBuffer.isView(v))M.boundary=16,M.storage=v.byteLength;else Pe("WebGLRenderer: Unsupported uniform value type.",v);return M}function E(v){let M=v.target;M.removeEventListener("dispose",E);let T=o.indexOf(M.__bindingPointIndex);o.splice(T,1),e.deleteBuffer(r[M.id]),delete r[M.id],delete s[M.id]}function R(){for(let v in r)e.deleteBuffer(r[v]);o=[],r={},s={}}return{bind:c,update:l,dispose:R}}var lT=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]),ci=null;function uT(){if(ci===null)ci=new Ys(lT,16,16,Mr,si),ci.name="DFG_LUT",ci.minFilter=$t,ci.magFilter=$t,ci.wrapS=as,ci.wrapT=as,ci.generateMipmaps=!1,ci.needsUpdate=!0;return ci}class Hu{constructor(e={}){let{canvas:t=op(),context:n=null,depth:i=!0,stencil:r=!1,alpha:s=!1,antialias:o=!1,premultipliedAlpha:a=!0,preserveDrawingBuffer:c=!1,powerPreference:l="default",failIfMajorPerformanceCaveat:u=!1,reversedDepthBuffer:f=!1,outputBufferType:h=Vn}=e;this.isWebGLRenderer=!0;let d;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");d=n.getContextAttributes().alpha}else d=s;let g=h,x=new Set([Rl,Al,Tl]),p=new Set([Vn,qi,Vs,ls,wl,El]),m=new Uint32Array(4),E=new Int32Array(4),R=new D,v=null,M=null,T=[],A=[],_=null;this.domElement=t,this.debug={checkShaderErrors:!0,diagnostics:{keywords:!1},onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=Gn,this.toneMappingExposure=1,this.transmissionResolutionScale=1;let S=this,k=!1,C=null,U=null,ee=null,P=null;this._outputColorSpace=ji;let V=0,j=0,z=null,H=-1,F=null,q=new ct,K=new ct,xe=null,ce=new Ue(0),De=0,{width:ye,height:X}=t,re=1,se=null,Te=null,Ie=new ct(0,0,ye,X),_e=new ct(0,0,ye,X),Qe=!1,ze=new Js,Ze=!1,ot=!1,Ye=new Ge,Zt=new D,yt=new ct,cn={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},Dt=!1;function Ot(){return z===null?re:1}let L=n;function ln(b,N){return t.getContext(b,N)}let it,wt,w,y,I,W,ie,ae,he,Y,te,ve,Ce,fe,oe,Le,Oe,et,O,le,J,ue,be;try{let b={alpha:!0,depth:i,stencil:r,antialias:o,premultipliedAlpha:a,preserveDrawingBuffer:c,powerPreference:l,failIfMajorPerformanceCaveat:u};if("setAttribute"in t)t.setAttribute("data-engine",`three.js r${fd}`);if(t.addEventListener("webglcontextlost",Be,!1),t.addEventListener("webglcontextrestored",gt,!1),t.addEventListener("webglcontextcreationerror",rt,!1),L===null){if(L=ln("webgl2",b),L===null)if(ln("webgl2"))throw Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes.");else throw Error("THREE.WebGLRenderer: Error creating WebGL context.")}ne()}catch(b){throw t.removeEventListener("webglcontextlost",Be,!1),t.removeEventListener("webglcontextrestored",gt,!1),t.removeEventListener("webglcontextcreationerror",rt,!1),Fe("WebGLRenderer: "+b.message),b}function ne(){if(it=new _w(L),it.init(),J=new iT(L,it),wt=new aw(L,it,e,J),w=new tT(L,it),wt.reversedDepthBuffer&&f)w.buffers.depth.setReversed(!0);U=L.createFramebuffer(),ee=L.createFramebuffer(),P=L.createFramebuffer(),y=new vw(L),I=new GE,W=new nT(L,it,w,I,wt,J,y),ie=new gw(S),ae=new Sb(L),ue=new sw(L,ae),he=new xw(L,ae,y,ue),Y=new Sw(L,he,ae,ue,y),et=new bw(L,wt,W),oe=new cw(I),te=new BE(S,ie,it,wt,ue,oe),ve=new aT(S,I),Ce=new VE,fe=new jE(it),Oe=new rw(S,ie,w,Y,d,a),Le=new eT(S,Y,wt),be=new cT(L,y,wt,w),O=new ow(L,it,y),le=new yw(L,it,y),y.programs=te.programs,S.capabilities=wt,S.extensions=it,S.properties=I,S.renderLists=Ce,S.shadowMap=Le,S.state=w,S.info=y}if(g!==Vn)_=new ww(g,t.width,t.height,o,i,r);let pe=new Jp(S,L);this.xr=pe,this.getContext=function(){return L},this.getContextAttributes=function(){return L.getContextAttributes()},this.forceContextLoss=function(){let b=it.get("WEBGL_lose_context");if(b)b.loseContext()},this.forceContextRestore=function(){let b=it.get("WEBGL_lose_context");if(b)b.restoreContext()},this.getPixelRatio=function(){return re},this.setPixelRatio=function(b){if(b===void 0)return;re=b,this.setSize(ye,X,!1)},this.getSize=function(b){return b.set(ye,X)},this.setSize=function(b,N,Z=!0){if(pe.isPresenting){Pe("WebGLRenderer: Can't change size while VR device is presenting.");return}if(ye=b,X=N,t.width=Math.floor(b*re),t.height=Math.floor(N*re),Z===!0)t.style.width=b+"px",t.style.height=N+"px";if(_!==null)_.setSize(t.width,t.height);this.setViewport(0,0,b,N)},this.getDrawingBufferSize=function(b){return b.set(ye*re,X*re).floor()},this.setDrawingBufferSize=function(b,N,Z){ye=b,X=N,re=Z,t.width=Math.floor(b*Z),t.height=Math.floor(N*Z),this.setViewport(0,0,b,N)},this.setEffects=function(b){if(g===Vn){Fe("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(b){for(let N=0;N<b.length;N++)if(b[N].isOutputPass===!0){Pe("WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}_.setEffects(b||[])},this.getCurrentViewport=function(b){return b.copy(q)},this.getViewport=function(b){return b.copy(Ie)},this.setViewport=function(b,N,Z,B){if(b.isVector4)Ie.set(b.x,b.y,b.z,b.w);else Ie.set(b,N,Z,B);w.viewport(q.copy(Ie).multiplyScalar(re).round())},this.getScissor=function(b){return b.copy(_e)},this.setScissor=function(b,N,Z,B){if(b.isVector4)_e.set(b.x,b.y,b.z,b.w);else _e.set(b,N,Z,B);w.scissor(K.copy(_e).multiplyScalar(re).round())},this.getScissorTest=function(){return Qe},this.setScissorTest=function(b){w.setScissorTest(Qe=b)},this.setOpaqueSort=function(b){se=b},this.setTransparentSort=function(b){Te=b},this.getClearColor=function(b){return b.copy(Oe.getClearColor())},this.setClearColor=function(){Oe.setClearColor(...arguments)},this.getClearAlpha=function(){return Oe.getClearAlpha()},this.setClearAlpha=function(){Oe.setClearAlpha(...arguments)},this.clear=function(b=!0,N=!0,Z=!0){let B=0;if(b){let G=!1;if(z!==null){let ge=z.texture.format;G=x.has(ge)}if(G){let ge=z.texture.type,Me=p.has(ge),me=Oe.getClearColor(),we=Oe.getClearAlpha(),{r:Ae,g:He,b:qe}=me;if(Me)m[0]=Ae,m[1]=He,m[2]=qe,m[3]=we,L.clearBufferuiv(L.COLOR,0,m);else E[0]=Ae,E[1]=He,E[2]=qe,E[3]=we,L.clearBufferiv(L.COLOR,0,E)}else B|=L.COLOR_BUFFER_BIT}if(N)B|=L.DEPTH_BUFFER_BIT,this.state.buffers.depth.setMask(!0);if(Z)B|=L.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295);if(B!==0)L.clear(B)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.setNodesHandler=function(b){b.setRenderer(this),C=b},this.dispose=function(){t.removeEventListener("webglcontextlost",Be,!1),t.removeEventListener("webglcontextrestored",gt,!1),t.removeEventListener("webglcontextcreationerror",rt,!1),Oe.dispose(),Ce.dispose(),fe.dispose(),I.dispose(),ie.dispose(),Y.dispose(),ue.dispose(),be.dispose(),te.dispose(),pe.dispose(),pe.removeEventListener("sessionstart",vf),pe.removeEventListener("sessionend",bf),fr.stop()};function Be(b){b.preventDefault(),zs("WebGLRenderer: Context Lost."),k=!0}function gt(){zs("WebGLRenderer: Context Restored."),k=!1;let b=y.autoReset,N=Le.enabled,Z=Le.autoUpdate,B=Le.needsUpdate,G=Le.type;ne(),y.autoReset=b,Le.enabled=N,Le.autoUpdate=Z,Le.needsUpdate=B,Le.type=G}function rt(b){Fe("WebGLRenderer: A WebGL context could not be created. Reason: ",b.statusMessage)}function Kn(b){let N=b.target;N.removeEventListener("dispose",Kn),yi(N)}function yi(b){fv(b),I.remove(b)}function fv(b){let N=I.get(b).programs;if(N!==void 0){if(N.forEach(function(Z){te.releaseProgram(Z)}),b.isShaderMaterial)te.releaseShaderCache(b)}}this.renderBufferDirect=function(b,N,Z,B,G,ge){if(N===null)N=cn;let Me=G.isMesh&&G.matrixWorld.determinantAffine()<0,me=mv(b,N,Z,B,G);w.setMaterial(B,Me);let we=Z.index,Ae=1;if(B.wireframe===!0){if(we=he.getWireframeAttribute(Z),we===void 0)return;Ae=2}let He=Z.drawRange,qe=Z.attributes.position,Ee=He.start*Ae,st=(He.start+He.count)*Ae;if(ge!==null)Ee=Math.max(Ee,ge.start*Ae),st=Math.min(st,(ge.start+ge.count)*Ae);if(we!==null)Ee=Math.max(Ee,0),st=Math.min(st,we.count);else if(qe!==void 0&&qe!==null)Ee=Math.max(Ee,0),st=Math.min(st,qe.count);let Lt=st-Ee;if(Lt<0||Lt===1/0)return;ue.setup(G,B,me,Z,we);let vt,dt=O;if(we!==null)vt=ae.get(we),dt=le,dt.setIndex(vt);if(G.isMesh)if(B.wireframe===!0)w.setLineWidth(B.wireframeLinewidth*Ot()),dt.setMode(L.LINES);else dt.setMode(L.TRIANGLES);else if(G.isLine){let Yt=B.linewidth;if(Yt===void 0)Yt=1;if(w.setLineWidth(Yt*Ot()),G.isLineSegments)dt.setMode(L.LINES);else if(G.isLineLoop)dt.setMode(L.LINE_LOOP);else dt.setMode(L.LINE_STRIP)}else if(G.isPoints)dt.setMode(L.POINTS);else if(G.isSprite)dt.setMode(L.TRIANGLES);if(G.isBatchedMesh)if(!it.get("WEBGL_multi_draw")){let{_multiDrawStarts:Yt,_multiDrawCounts:Se,_multiDrawCount:rn}=G,Ke=we?ae.get(we).bytesPerElement:1,En=I.get(B).currentProgram.getUniforms();for(let Jn=0;Jn<rn;Jn++)En.setValue(L,"_gl_DrawID",Jn),dt.render(Yt[Jn]/Ke,Se[Jn])}else dt.renderMultiDraw(G._multiDrawStarts,G._multiDrawCounts,G._multiDrawCount);else if(G.isInstancedMesh)dt.renderInstances(Ee,Lt,G.count);else if(Z.isInstancedBufferGeometry){let Yt=Z._maxInstanceCount!==void 0?Z._maxInstanceCount:1/0,Se=Math.min(Z.instanceCount,Yt);dt.renderInstances(Ee,Lt,Se)}else dt.render(Ee,Lt)};function yf(b,N,Z,B){if(C!==null&&b.isNodeMaterial)C.setObject(B,b);if(Ze===!0)oe.setState(b,Z,!1);if(b.transparent===!0&&b.side===Cn&&b.forceSinglePass===!1)b.side=Qt,b.needsUpdate=!0,Vo(b,N,B),b.side=Xi,b.needsUpdate=!0,Vo(b,N,B),b.side=Cn;else Vo(b,N,B)}this.compile=function(b,N,Z=null){if(Z===null)Z=b;if(C!==null)C.renderStart(b,N,Z);if(M=fe.get(Z),M.init(N),A.push(M),Z.traverseVisible(function(G){if(G.isLight&&G.layers.test(N.layers)){if(M.pushLight(G),G.castShadow)M.pushShadow(G)}}),b!==Z)b.traverseVisible(function(G){if(G.isLight&&G.layers.test(N.layers)){if(M.pushLight(G),G.castShadow)M.pushShadow(G)}});if(M.setupLights(),C!==null)C.updateLights(M.state.lightsArray);if(ot=this.localClippingEnabled,Ze=oe.init(this.clippingPlanes,ot),Ze===!0)oe.setGlobalState(this.clippingPlanes,N);if(C!==null)Le.render(M.state.shadowsArray,Z,N);let B=new Set;if(b.traverse(function(G){if(!(G.isMesh||G.isPoints||G.isLine||G.isSprite))return;let ge=G.material;if(ge)if(Array.isArray(ge))for(let Me=0;Me<ge.length;Me++){let me=ge[Me];yf(me,Z,N,G),B.add(me)}else yf(ge,Z,N,G),B.add(ge)}),M=A.pop(),C!==null)C.renderEnd();return B},this.compileAsync=function(b,N,Z=null){let B=this.compile(b,N,Z);return new Promise((G)=>{function ge(){if(B.forEach(function(Me){let we=I.get(Me).currentProgram;if(we===void 0||we.isReady())B.delete(Me)}),B.size===0){G(b);return}setTimeout(ge,10)}if(it.get("KHR_parallel_shader_compile")!==null)ge();else setTimeout(ge,10)})};let kc=null;function dv(b){if(kc)kc(b)}function vf(){fr.stop()}function bf(){fr.start()}let fr=new Bp;if(fr.setAnimationLoop(dv),typeof self<"u")fr.setContext(self);this.setAnimationLoop=function(b){kc=b,pe.setAnimationLoop(b),b===null?fr.stop():fr.start()},pe.addEventListener("sessionstart",vf),pe.addEventListener("sessionend",bf),this.render=function(b,N){if(N!==void 0&&N.isCamera!==!0){Fe("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(k===!0)return;if(C!==null)C.renderStart(b,N);let Z=pe.enabled===!0&&pe.isPresenting===!0,B=_!==null&&(z===null||Z)&&_.begin(S,z);if(b.matrixWorldAutoUpdate===!0)b.updateMatrixWorld();if(N.parent===null&&N.matrixWorldAutoUpdate===!0)N.updateMatrixWorld();if(pe.enabled===!0&&pe.isPresenting===!0&&(_===null||_.isCompositing()===!1)){if(pe.cameraAutoUpdate===!0)pe.updateCamera(N);N=pe.getCamera()}if(b.isScene===!0)b.onBeforeRender(S,b,N,z);if(M=fe.get(b,A.length),M.init(N),M.state.textureUnits=W.getTextureUnits(),A.push(M),Ye.multiplyMatrices(N.projectionMatrix,N.matrixWorldInverse),ze.setFromProjectionMatrix(Ye,uu,N.reversedDepth),ot=this.localClippingEnabled,Ze=oe.init(this.clippingPlanes,ot),v=Ce.get(b,T.length),v.init(),T.push(v),pe.enabled===!0&&pe.isPresenting===!0){let Me=S.xr.getDepthSensingMesh();if(Me!==null)Bc(Me,N,-1/0,S.sortObjects)}if(Bc(b,N,0,S.sortObjects),v.finish(),C!==null)C.updateLights(M.state.lightsArray);if(S.sortObjects===!0)v.sort(se,Te);if(Dt=pe.enabled===!1||pe.isPresenting===!1||pe.hasDepthSensing()===!1,Dt)Oe.addToRenderList(v,b);if(this.info.render.frame++,this.info.autoReset===!0)this.info.reset();if(Ze===!0)oe.beginShadows();let G=M.state.shadowsArray;if(Le.render(G,b,N),Ze===!0)oe.endShadows();if((B&&_.hasRenderPass())===!1){let Me=v.opaque,me=v.transmissive;if(M.setupLights(),N.isArrayCamera){let we=N.cameras;if(me.length>0)for(let Ae=0,He=we.length;Ae<He;Ae++){let qe=we[Ae];Mf(Me,me,b,qe)}if(Dt)Oe.render(b);for(let Ae=0,He=we.length;Ae<He;Ae++){let qe=we[Ae];Sf(v,b,qe,qe.viewport)}}else{if(me.length>0)Mf(Me,me,b,N);if(Dt)Oe.render(b);Sf(v,b,N)}}if(z!==null&&j===0)W.updateMultisampleRenderTarget(z),W.updateRenderTargetMipmap(z);if(B)_.end(S);if(b.isScene===!0)b.onAfterRender(S,b,N);if(ue.resetDefaultState(),H=-1,F=null,A.pop(),A.length>0){if(M=A[A.length-1],W.setTextureUnits(M.state.textureUnits),Ze===!0)oe.setGlobalState(S.clippingPlanes,M.state.camera)}else M=null;if(T.pop(),T.length>0)v=T[T.length-1];else v=null;if(C!==null)C.renderEnd()};function Bc(b,N,Z,B){if(b.visible===!1)return;if(b.layers.test(N.layers)){if(b.isGroup)Z=b.renderOrder;else if(b.isLOD){if(b.autoUpdate===!0)b.update(N)}else if(b.isLightProbeGrid)M.pushLightProbeGrid(b);else if(b.isLight){if(M.pushLight(b),b.castShadow)M.pushShadow(b)}else if(b.isSprite){if(!b.frustumCulled||b.intersectsFrustum(ze)){if(B)yt.setFromMatrixPosition(b.matrixWorld).applyMatrix4(Ye);let Me=Y.update(b),me=b.material;if(me.visible)v.push(b,Me,me,Z,yt.z,null,N)}}else if(b.isMesh||b.isLine||b.isPoints){if(!b.frustumCulled||b.intersectsFrustum(ze)){let Me=Y.update(b),me=b.material;if(B){if(b.boundingSphere!==void 0){if(b.boundingSphere===null)b.computeBoundingSphere();yt.copy(b.boundingSphere.center)}else{if(Me.boundingSphere===null)Me.computeBoundingSphere();yt.copy(Me.boundingSphere.center)}yt.applyMatrix4(b.matrixWorld).applyMatrix4(Ye)}if(Array.isArray(me)){let we=Me.groups;for(let Ae=0,He=we.length;Ae<He;Ae++){let qe=we[Ae],Ee=me[qe.materialIndex];if(Ee&&Ee.visible)v.push(b,Me,Ee,Z,yt.z,qe,N)}}else if(me.visible)v.push(b,Me,me,Z,yt.z,null,N)}}}let ge=b.children;for(let Me=0,me=ge.length;Me<me;Me++)Bc(ge[Me],N,Z,B)}function Sf(b,N,Z,B){let{opaque:G,transmissive:ge,transparent:Me}=b;if(M.setupLightsView(Z),Ze===!0)oe.setGlobalState(S.clippingPlanes,Z);if(B)w.viewport(q.copy(B));if(G.length>0)Ho(G,N,Z);if(ge.length>0)Ho(ge,N,Z);if(Me.length>0)Ho(Me,N,Z);w.buffers.depth.setTest(!0),w.buffers.depth.setMask(!0),w.buffers.color.setMask(!0),w.setPolygonOffset(!1)}function Mf(b,N,Z,B){if((Z.isScene===!0?Z.overrideMaterial:null)!==null)return;if(M.state.transmissionRenderTarget[B.id]===void 0){let Ee=it.has("EXT_color_buffer_half_float")||it.has("EXT_color_buffer_float");M.state.transmissionRenderTarget[B.id]=new _n(1,1,{generateMipmaps:!0,type:Ee?si:Vn,minFilter:ri,samples:Math.max(4,wt.samples),stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,storeMultisampledDepthBuffer:!1,storeMultisampledStencilBuffer:!1,colorSpace:$e.workingColorSpace})}let ge=M.state.transmissionRenderTarget[B.id],Me=B.viewport||q;ge.setSize(Me.z*S.transmissionResolutionScale,Me.w*S.transmissionResolutionScale);let me=S.getRenderTarget(),we=S.getActiveCubeFace(),Ae=S.getActiveMipmapLevel();if(S.setRenderTarget(ge),S.getClearColor(ce),De=S.getClearAlpha(),De<1)S.setClearColor(16777215,0.5);if(S.clear(),Dt)Oe.render(Z);let He=S.toneMapping;S.toneMapping=Gn;let qe=B.viewport;if(B.viewport!==void 0)B.viewport=void 0;if(M.setupLightsView(B),Ze===!0)oe.setGlobalState(S.clippingPlanes,B);if(Ho(b,Z,B),W.updateMultisampleRenderTarget(ge),W.updateRenderTargetMipmap(ge),it.has("WEBGL_multisampled_render_to_texture")===!1){let Ee=!1;for(let st=0,Lt=N.length;st<Lt;st++){let vt=N[st],{object:dt,geometry:Yt,material:Se,group:rn}=vt;if(Se.side===Cn&&dt.layers.test(B.layers)){let Ke=Se.side;Se.side=Qt,Se.needsUpdate=!0,wf(dt,Z,B,Yt,Se,rn),Se.side=Ke,Se.needsUpdate=!0,Ee=!0}}if(Ee===!0)W.updateMultisampleRenderTarget(ge),W.updateRenderTargetMipmap(ge)}if(S.setRenderTarget(me,we,Ae),S.setClearColor(ce,De),qe!==void 0)B.viewport=qe;S.toneMapping=He}function Ho(b,N,Z){let B=N.isScene===!0?N.overrideMaterial:null;for(let G=0,ge=b.length;G<ge;G++){let Me=b[G],{object:me,geometry:we,group:Ae}=Me,He=Me.material;if(He.allowOverride===!0&&B!==null)He=B;if(me.layers.test(Z.layers))wf(me,N,Z,we,He,Ae)}}function wf(b,N,Z,B,G,ge){if(C!==null&&G.isNodeMaterial)C.setObject(b,G);if(b.onBeforeRender(S,N,Z,B,G,ge),b.modelViewMatrix.multiplyMatrices(Z.matrixWorldInverse,b.matrixWorld),b.normalMatrix.getNormalMatrix(b.modelViewMatrix),G.onBeforeRender(S,N,Z,B,b,ge),G.transparent===!0&&G.side===Cn&&G.forceSinglePass===!1)G.side=Qt,G.needsUpdate=!0,S.renderBufferDirect(Z,N,B,G,b,ge),G.side=Xi,G.needsUpdate=!0,S.renderBufferDirect(Z,N,B,G,b,ge),G.side=Cn;else S.renderBufferDirect(Z,N,B,G,b,ge);b.onAfterRender(S,N,Z,B,G,ge)}function Vo(b,N,Z){if(N.isScene!==!0)N=cn;let B=I.get(b),G=M.state.lights,ge=M.state.shadowsArray,Me=G.state.version,me=te.getParameters(b,G.state,ge,N,Z,M.state.lightProbeGridArray),we=te.getProgramCacheKey(me),Ae=B.programs;B.environment=b.isMeshStandardMaterial||b.isMeshLambertMaterial||b.isMeshPhongMaterial?N.environment:null,B.fog=N.fog;let He=b.isMeshStandardMaterial||b.isMeshLambertMaterial&&!b.envMap||b.isMeshPhongMaterial&&!b.envMap;if(B.envMap=ie.get(b.envMap||B.environment,He),B.envMapRotation=B.environment!==null&&b.envMap===null?N.environmentRotation:b.envMapRotation,Ae===void 0)b.addEventListener("dispose",Kn),Ae=new Map,B.programs=Ae;let qe=Ae.get(we);if(qe!==void 0){if(B.currentProgram===qe&&B.lightsStateVersion===Me)return Tf(b,me),qe}else{if(me.uniforms=te.getUniforms(b),C!==null&&b.isNodeMaterial)C.build(b,Z,me);b.onBeforeCompile(me,S),qe=te.acquireProgram(me,we),Ae.set(we,qe),B.uniforms=me.uniforms}let Ee=B.uniforms;if(!b.isShaderMaterial&&!b.isRawShaderMaterial||b.clipping===!0)Ee.clippingPlanes=oe.uniform;if(Tf(b,me),B.needsLights=_v(b),B.lightsStateVersion=Me,B.needsLights)Ee.ambientLightColor.value=G.state.ambient,Ee.lightProbe.value=G.state.probe,Ee.sunLights.value=G.state.sun,Ee.sunLightShadows.value=G.state.sunShadow,Ee.directionalLights.value=G.state.directional,Ee.directionalLightShadows.value=G.state.directionalShadow,Ee.spotLights.value=G.state.spot,Ee.spotLightShadows.value=G.state.spotShadow,Ee.rectAreaLights.value=G.state.rectArea,Ee.ltc_1.value=G.state.rectAreaLTC1,Ee.ltc_2.value=G.state.rectAreaLTC2,Ee.pointLights.value=G.state.point,Ee.pointLightShadows.value=G.state.pointShadow,Ee.hemisphereLights.value=G.state.hemi,Ee.sunShadowMatrix.value=G.state.sunShadowMatrix,Ee.sunShadowCascade.value=G.state.sunShadowCascade,Ee.directionalShadowMatrix.value=G.state.directionalShadowMatrix,Ee.spotLightMatrix.value=G.state.spotLightMatrix,Ee.spotLightMap.value=G.state.spotLightMap,Ee.pointShadowMatrix.value=G.state.pointShadowMatrix;return B.lightProbeGrid=M.state.lightProbeGridArray.length>0,B.currentProgram=qe,B.uniformsList=null,qe}function Ef(b){if(b.uniformsList===null){let N=b.currentProgram.getUniforms();b.uniformsList=lo.seqWithValue(N.seq,b.uniforms)}return b.uniformsList}function Tf(b,N){let Z=I.get(b);Z.outputColorSpace=N.outputColorSpace,Z.batching=N.batching,Z.batchingColor=N.batchingColor,Z.instancing=N.instancing,Z.instancingColor=N.instancingColor,Z.instancingMorph=N.instancingMorph,Z.skinning=N.skinning,Z.morphTargets=N.morphTargets,Z.morphNormals=N.morphNormals,Z.morphColors=N.morphColors,Z.morphTargetsCount=N.morphTargetsCount,Z.numClippingPlanes=N.numClippingPlanes,Z.numIntersection=N.numClipIntersection,Z.vertexAlphas=N.vertexAlphas,Z.vertexTangents=N.vertexTangents,Z.toneMapping=N.toneMapping}function pv(b,N){if(b.length===0)return null;if(b.length===1)return b[0].texture!==null?b[0]:null;R.setFromMatrixPosition(N.matrixWorld);for(let Z=0,B=b.length;Z<B;Z++){let G=b[Z];if(G.texture!==null&&G.boundingBox.containsPoint(R))return G}return null}function mv(b,N,Z,B,G){if(N.isScene!==!0)N=cn;W.resetTextureUnits();let ge=N.fog,Me=B.isMeshStandardMaterial||B.isMeshLambertMaterial||B.isMeshPhongMaterial?N.environment:null,me=z===null?S.outputColorSpace:z.isXRRenderTarget===!0?z.texture.colorSpace:$e.workingColorSpace,we=B.isMeshStandardMaterial||B.isMeshLambertMaterial&&!B.envMap||B.isMeshPhongMaterial&&!B.envMap,Ae=ie.get(B.envMap||Me,we),He=B.vertexColors===!0&&!!Z.attributes.color&&Z.attributes.color.itemSize===4,qe=!!Z.attributes.tangent&&(!!B.normalMap||B.anisotropy>0),Ee=!!Z.morphAttributes.position,st=!!Z.morphAttributes.normal,Lt=!!Z.morphAttributes.color,vt=Gn;if(B.toneMapped){if(z===null||z.isXRRenderTarget===!0)vt=S.toneMapping}let dt=Z.morphAttributes.position||Z.morphAttributes.normal||Z.morphAttributes.color,Yt=dt!==void 0?dt.length:0,Se=I.get(B),rn=M.state.lights;if(Ze===!0){if(ot===!0||b!==F){let _t=b===F&&B.id===H;oe.setState(B,b,_t)}}let Ke=!1;if(B.version===Se.__version){if(Se.needsLights&&Se.lightsStateVersion!==rn.state.version)Ke=!0;else if(Se.outputColorSpace!==me)Ke=!0;else if(G.isBatchedMesh&&Se.batching===!1)Ke=!0;else if(!G.isBatchedMesh&&Se.batching===!0)Ke=!0;else if(G.isBatchedMesh&&Se.batchingColor===!0&&G._colorsTexture===null)Ke=!0;else if(G.isBatchedMesh&&Se.batchingColor===!1&&G._colorsTexture!==null)Ke=!0;else if(G.isInstancedMesh&&Se.instancing===!1)Ke=!0;else if(!G.isInstancedMesh&&Se.instancing===!0)Ke=!0;else if(G.isSkinnedMesh&&Se.skinning===!1)Ke=!0;else if(!G.isSkinnedMesh&&Se.skinning===!0)Ke=!0;else if(G.isInstancedMesh&&Se.instancingColor===!0&&G.instanceColor===null)Ke=!0;else if(G.isInstancedMesh&&Se.instancingColor===!1&&G.instanceColor!==null)Ke=!0;else if(G.isInstancedMesh&&Se.instancingMorph===!0&&G.morphTexture===null)Ke=!0;else if(G.isInstancedMesh&&Se.instancingMorph===!1&&G.morphTexture!==null)Ke=!0;else if(Se.envMap!==Ae)Ke=!0;else if(B.fog===!0&&Se.fog!==ge)Ke=!0;else if(Se.numClippingPlanes!==void 0&&(Se.numClippingPlanes!==oe.numPlanes||Se.numIntersection!==oe.numIntersection))Ke=!0;else if(Se.vertexAlphas!==He)Ke=!0;else if(Se.vertexTangents!==qe)Ke=!0;else if(Se.morphTargets!==Ee)Ke=!0;else if(Se.morphNormals!==st)Ke=!0;else if(Se.morphColors!==Lt)Ke=!0;else if(Se.toneMapping!==vt)Ke=!0;else if(Se.morphTargetsCount!==Yt)Ke=!0;else if(!!Se.lightProbeGrid!==M.state.lightProbeGridArray.length>0)Ke=!0}else Ke=!0,Se.__version=B.version;let En=Se.currentProgram;if(Ke===!0){if(En=Vo(B,N,G),C&&B.isNodeMaterial)C.onUpdateProgram(B,En,Se)}let Jn=!1,Oi=!1,Fr=!1,ut=En.getUniforms(),Ct=Se.uniforms;if(w.useProgram(En.program))Jn=!0,Oi=!0,Fr=!0;if(B.id!==H)H=B.id,Oi=!0;if(Se.needsLights){let _t=pv(M.state.lightProbeGridArray,G);if(Se.lightProbeGrid!==_t)Se.lightProbeGrid=_t,Oi=!0}if(Jn||F!==b){if(w.buffers.depth.getReversed()&&b.reversedDepth!==!0)b._reversedDepth=!0,b.updateProjectionMatrix();ut.setValue(L,"projectionMatrix",b.projectionMatrix),ut.setValue(L,"viewMatrix",b.matrixWorldInverse);let Fi=ut.map.cameraPosition;if(Fi!==void 0)Fi.setValue(L,Zt.setFromMatrixPosition(b.matrixWorld));if(wt.logarithmicDepthBuffer)ut.setValue(L,"logDepthBufFC",2/(Math.log(b.far+1)/Math.LN2));if(B.isMeshPhongMaterial||B.isMeshToonMaterial||B.isMeshLambertMaterial||B.isMeshBasicMaterial||B.isMeshStandardMaterial||B.isShaderMaterial)ut.setValue(L,"isOrthographic",b.isOrthographicCamera===!0);if(F!==b)F=b,Oi=!0,Fr=!0}if(Se.needsLights){if(rn.state.sunShadowMap.length>0)ut.setValue(L,"sunShadowMap",rn.state.sunShadowMap,W);if(rn.state.directionalShadowMap.length>0)ut.setValue(L,"directionalShadowMap",rn.state.directionalShadowMap,W);if(rn.state.spotShadowMap.length>0)ut.setValue(L,"spotShadowMap",rn.state.spotShadowMap,W);if(rn.state.pointShadowMap.length>0)ut.setValue(L,"pointShadowMap",rn.state.pointShadowMap,W)}if(G.isSkinnedMesh){ut.setOptional(L,G,"bindMatrix"),ut.setOptional(L,G,"bindMatrixInverse");let _t=G.skeleton;if(_t){if(_t.boneTexture===null)_t.computeBoneTexture();ut.setValue(L,"boneTexture",_t.boneTexture,W)}}if(G.isBatchedMesh){if(ut.setOptional(L,G,"batchingTexture"),ut.setValue(L,"batchingTexture",G._matricesTexture,W),ut.setOptional(L,G,"batchingIdTexture"),ut.setValue(L,"batchingIdTexture",G._indirectTexture,W),ut.setOptional(L,G,"batchingColorTexture"),G._colorsTexture!==null)ut.setValue(L,"batchingColorTexture",G._colorsTexture,W)}let Ui=Z.morphAttributes;if(Ui.position!==void 0||Ui.normal!==void 0||Ui.color!==void 0)et.update(G,Z,En);if(Oi||Se.receiveShadow!==G.receiveShadow)Se.receiveShadow=G.receiveShadow,ut.setValue(L,"receiveShadow",G.receiveShadow);if((B.isMeshStandardMaterial||B.isMeshLambertMaterial||B.isMeshPhongMaterial)&&B.envMap===null&&N.environment!==null)Ct.envMapIntensity.value=N.environmentIntensity;if(Ct.dfgLUT!==void 0)Ct.dfgLUT.value=uT();if(Oi){if(ut.setValue(L,"toneMappingExposure",S.toneMappingExposure),Se.needsLights)gv(Ct,Fr);if(ge&&B.fog===!0)ve.refreshFogUniforms(Ct,ge);if(ve.refreshMaterialUniforms(Ct,B,re,X,M.state.transmissionRenderTarget[b.id]),Se.needsLights&&Se.lightProbeGrid){let _t=Se.lightProbeGrid;Ct.probesSH.value=_t.texture,Ct.probesMin.value.copy(_t.boundingBox.min),Ct.probesMax.value.copy(_t.boundingBox.max),Ct.probesResolution.value.copy(_t.resolution)}lo.upload(L,Ef(Se),Ct,W)}if(B.isShaderMaterial&&B.uniformsNeedUpdate===!0)lo.upload(L,Ef(Se),Ct,W),B.uniformsNeedUpdate=!1;if(B.isSpriteMaterial)ut.setValue(L,"center",G.center);if(ut.setValue(L,"modelViewMatrix",G.modelViewMatrix),ut.setValue(L,"normalMatrix",G.normalMatrix),ut.setValue(L,"modelMatrix",G.matrixWorld),B.uniformsGroups!==void 0){let _t=B.uniformsGroups;for(let Fi=0,zr=_t.length;Fi<zr;Fi++){let Rf=_t[Fi];be.update(Rf,En),be.bind(Rf,En)}}return En}function gv(b,N){b.ambientLightColor.needsUpdate=N,b.lightProbe.needsUpdate=N,b.sunLights.needsUpdate=N,b.sunLightShadows.needsUpdate=N,b.directionalLights.needsUpdate=N,b.directionalLightShadows.needsUpdate=N,b.pointLights.needsUpdate=N,b.pointLightShadows.needsUpdate=N,b.spotLights.needsUpdate=N,b.spotLightShadows.needsUpdate=N,b.rectAreaLights.needsUpdate=N,b.hemisphereLights.needsUpdate=N}function _v(b){return b.isMeshLambertMaterial||b.isMeshToonMaterial||b.isMeshPhongMaterial||b.isMeshStandardMaterial||b.isShadowMaterial||b.isShaderMaterial&&b.lights===!0}this.getActiveCubeFace=function(){return V},this.getActiveMipmapLevel=function(){return j},this.getRenderTarget=function(){return z},this.setRenderTargetTextures=function(b,N,Z){let B=I.get(b);if(B.__autoAllocateDepthBuffer=b.resolveDepthBuffer===!1,B.__autoAllocateDepthBuffer===!1)B.__useRenderToTexture=!1;I.get(b.texture).__webglTexture=N,I.get(b.depthTexture).__webglTexture=B.__autoAllocateDepthBuffer?void 0:Z,B.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(b,N){let Z=I.get(b);Z.__webglFramebuffer=N,Z.__useDefaultFramebuffer=N===void 0},this.setRenderTarget=function(b,N=0,Z=0){z=b,V=N,j=Z;let B=null,G=!1,ge=!1;if(b){let me=I.get(b);if(me.__useDefaultFramebuffer!==void 0){w.bindFramebuffer(L.FRAMEBUFFER,me.__webglFramebuffer),q.copy(b.viewport),K.copy(b.scissor),xe=b.scissorTest,w.viewport(q),w.scissor(K),w.setScissorTest(xe),H=-1;return}else if(me.__webglFramebuffer===void 0)W.setupRenderTarget(b);else if(me.__hasExternalTextures)W.rebindTextures(b,I.get(b.texture).__webglTexture,I.get(b.depthTexture).__webglTexture);else if(b.depthBuffer){let He=b.depthTexture;if(me.__boundDepthTexture!==He){if(He!==null&&I.has(He)&&(b.width!==He.image.width||b.height!==He.image.height))throw Error("THREE.WebGLRenderer: Attached DepthTexture is initialized to the incorrect size.");W.setupDepthRenderbuffer(b)}}let we=b.texture;if(we.isData3DTexture||we.isDataArrayTexture||we.isCompressedArrayTexture)ge=!0;let Ae=I.get(b).__webglFramebuffer;if(b.isWebGLCubeRenderTarget){if(Array.isArray(Ae[N]))B=Ae[N][Z];else B=Ae[N];G=!0}else if(b.samples>0&&W.useMultisampledRTT(b)===!1)B=I.get(b).__webglMultisampledFramebuffer;else if(Array.isArray(Ae))B=Ae[Z];else B=Ae;q.copy(b.viewport),K.copy(b.scissor),xe=b.scissorTest}else q.copy(Ie).multiplyScalar(re).floor(),K.copy(_e).multiplyScalar(re).floor(),xe=Qe;if(Z!==0)B=U;if(w.bindFramebuffer(L.FRAMEBUFFER,B))w.drawBuffers(b,B);if(w.viewport(q),w.scissor(K),w.setScissorTest(xe),G){let me=I.get(b.texture);L.framebufferTexture2D(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_CUBE_MAP_POSITIVE_X+N,me.__webglTexture,Z)}else if(ge){let me=N;for(let we=0;we<b.textures.length;we++){let Ae=I.get(b.textures[we]);L.framebufferTextureLayer(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0+we,Ae.__webglTexture,Z,me)}}else if(b!==null&&Z!==0){let me=I.get(b.texture);L.framebufferTexture2D(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_2D,me.__webglTexture,Z)}H=-1};function Af(b){let N=I.get(b);if(N.__readFormat!==b.format||N.__readType!==b.type)N.__readFormat=b.format,N.__readType=b.type,N.__formatReadable=wt.textureFormatReadable(b.format),N.__typeReadable=wt.textureTypeReadable(b.type);return N}if(this.readRenderTargetPixels=function(b,N,Z,B,G,ge,Me,me=0){if(!(b&&b.isWebGLRenderTarget)){Fe("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let we=I.get(b).__webglFramebuffer;if(b.isWebGLCubeRenderTarget&&Me!==void 0)we=we[Me];if(we){w.bindFramebuffer(L.FRAMEBUFFER,we);try{let Ae=b.textures[me],{format:He,type:qe}=Ae;if(b.textures.length>1)L.readBuffer(L.COLOR_ATTACHMENT0+me);let Ee=Af(Ae);if(Ee.__formatReadable===!1){Fe("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(Ee.__typeReadable===!1){Fe("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}if(N>=0&&N<=b.width-B&&(Z>=0&&Z<=b.height-G))L.readPixels(N,Z,B,G,J.convert(He),J.convert(qe),ge)}finally{let Ae=z!==null?I.get(z).__webglFramebuffer:null;w.bindFramebuffer(L.FRAMEBUFFER,Ae)}}},this.readRenderTargetPixelsAsync=async function(b,N,Z,B,G,ge,Me,me=0){if(!(b&&b.isWebGLRenderTarget))throw Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let we=I.get(b).__webglFramebuffer;if(b.isWebGLCubeRenderTarget&&Me!==void 0)we=we[Me];if(we)if(N>=0&&N<=b.width-B&&(Z>=0&&Z<=b.height-G)){w.bindFramebuffer(L.FRAMEBUFFER,we);let Ae=b.textures[me],{format:He,type:qe}=Ae;if(b.textures.length>1)L.readBuffer(L.COLOR_ATTACHMENT0+me);let Ee=Af(Ae);if(Ee.__formatReadable===!1)throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(Ee.__typeReadable===!1)throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");let st=L.createBuffer();L.bindBuffer(L.PIXEL_PACK_BUFFER,st),L.bufferData(L.PIXEL_PACK_BUFFER,ge.byteLength,L.STREAM_READ),L.readPixels(N,Z,B,G,J.convert(He),J.convert(qe),0),L.bindBuffer(L.PIXEL_PACK_BUFFER,null);let Lt=z!==null?I.get(z).__webglFramebuffer:null;w.bindFramebuffer(L.FRAMEBUFFER,Lt);let vt=L.fenceSync(L.SYNC_GPU_COMMANDS_COMPLETE,0);return L.flush(),await cp(L,vt,4),L.bindBuffer(L.PIXEL_PACK_BUFFER,st),L.getBufferSubData(L.PIXEL_PACK_BUFFER,0,ge),L.bindBuffer(L.PIXEL_PACK_BUFFER,null),L.deleteBuffer(st),L.deleteSync(vt),ge}else throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(b,N=null,Z=0){let B=Math.pow(2,-Z),G=Math.floor(b.image.width*B),ge=Math.floor(b.image.height*B),Me=N!==null?N.x:0,me=N!==null?N.y:0;W.setTexture2D(b,0),L.copyTexSubImage2D(L.TEXTURE_2D,Z,0,0,Me,me,G,ge),w.unbindTexture()},this.copyTextureToTexture=function(b,N,Z=null,B=null,G=0,ge=0){let Me,me,we,Ae,He,qe,Ee,st,Lt,vt=b.isCompressedTexture?b.mipmaps[ge]:b.image;if(Z!==null)Me=Z.max.x-Z.min.x,me=Z.max.y-Z.min.y,we=Z.isBox3?Z.max.z-Z.min.z:1,Ae=Z.min.x,He=Z.min.y,qe=Z.isBox3?Z.min.z:0;else{let Ct=Math.pow(2,-G);if(Me=Math.floor(vt.width*Ct),me=Math.floor(vt.height*Ct),b.isDataArrayTexture)we=vt.depth;else if(b.isData3DTexture)we=Math.floor(vt.depth*Ct);else we=1;Ae=0,He=0,qe=0}if(B!==null)Ee=B.x,st=B.y,Lt=B.z;else Ee=0,st=0,Lt=0;let dt=J.convert(N.format),Yt=J.convert(N.type),Se;if(N.isData3DTexture)W.setTexture3D(N,0),Se=L.TEXTURE_3D;else if(N.isDataArrayTexture||N.isCompressedArrayTexture)W.setTexture2DArray(N,0),Se=L.TEXTURE_2D_ARRAY;else W.setTexture2D(N,0),Se=L.TEXTURE_2D;w.activeTexture(L.TEXTURE0),w.pixelStorei(L.UNPACK_FLIP_Y_WEBGL,N.flipY),w.pixelStorei(L.UNPACK_PREMULTIPLY_ALPHA_WEBGL,N.premultiplyAlpha),w.pixelStorei(L.UNPACK_ALIGNMENT,N.unpackAlignment);let rn=w.getParameter(L.UNPACK_ROW_LENGTH),Ke=w.getParameter(L.UNPACK_IMAGE_HEIGHT),En=w.getParameter(L.UNPACK_SKIP_PIXELS),Jn=w.getParameter(L.UNPACK_SKIP_ROWS),Oi=w.getParameter(L.UNPACK_SKIP_IMAGES);w.pixelStorei(L.UNPACK_ROW_LENGTH,vt.width),w.pixelStorei(L.UNPACK_IMAGE_HEIGHT,vt.height),w.pixelStorei(L.UNPACK_SKIP_PIXELS,Ae),w.pixelStorei(L.UNPACK_SKIP_ROWS,He),w.pixelStorei(L.UNPACK_SKIP_IMAGES,qe);let Fr=b.isDataArrayTexture||b.isData3DTexture,ut=N.isDataArrayTexture||N.isData3DTexture;if(b.isDepthTexture){let Ct=I.get(b),Ui=I.get(N),_t=I.get(Ct.__renderTarget),Fi=I.get(Ui.__renderTarget);w.bindFramebuffer(L.READ_FRAMEBUFFER,_t.__webglFramebuffer),w.bindFramebuffer(L.DRAW_FRAMEBUFFER,Fi.__webglFramebuffer);for(let zr=0;zr<we;zr++){if(Fr)L.framebufferTextureLayer(L.READ_FRAMEBUFFER,L.COLOR_ATTACHMENT0,I.get(b).__webglTexture,G,qe+zr),L.framebufferTextureLayer(L.DRAW_FRAMEBUFFER,L.COLOR_ATTACHMENT0,I.get(N).__webglTexture,ge,Lt+zr);L.blitFramebuffer(Ae,He,Me,me,Ee,st,Me,me,L.DEPTH_BUFFER_BIT,L.NEAREST)}w.bindFramebuffer(L.READ_FRAMEBUFFER,null),w.bindFramebuffer(L.DRAW_FRAMEBUFFER,null)}else if(G!==0||b.isRenderTargetTexture||I.has(b)){let Ct=I.get(b),Ui=I.get(N);w.bindFramebuffer(L.READ_FRAMEBUFFER,ee),w.bindFramebuffer(L.DRAW_FRAMEBUFFER,P);for(let _t=0;_t<we;_t++){if(Fr)L.framebufferTextureLayer(L.READ_FRAMEBUFFER,L.COLOR_ATTACHMENT0,Ct.__webglTexture,G,qe+_t);else L.framebufferTexture2D(L.READ_FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_2D,Ct.__webglTexture,G);if(ut)L.framebufferTextureLayer(L.DRAW_FRAMEBUFFER,L.COLOR_ATTACHMENT0,Ui.__webglTexture,ge,Lt+_t);else L.framebufferTexture2D(L.DRAW_FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_2D,Ui.__webglTexture,ge);if(G!==0)L.blitFramebuffer(Ae,He,Me,me,Ee,st,Me,me,L.COLOR_BUFFER_BIT,L.NEAREST);else if(ut)L.copyTexSubImage3D(Se,ge,Ee,st,Lt+_t,Ae,He,Me,me);else L.copyTexSubImage2D(Se,ge,Ee,st,Ae,He,Me,me)}w.bindFramebuffer(L.READ_FRAMEBUFFER,null),w.bindFramebuffer(L.DRAW_FRAMEBUFFER,null)}else if(ut)if(b.isDataTexture||b.isData3DTexture)L.texSubImage3D(Se,ge,Ee,st,Lt,Me,me,we,dt,Yt,vt.data);else if(N.isCompressedArrayTexture)L.compressedTexSubImage3D(Se,ge,Ee,st,Lt,Me,me,we,dt,vt.data);else L.texSubImage3D(Se,ge,Ee,st,Lt,Me,me,we,dt,Yt,vt);else if(b.isDataTexture)L.texSubImage2D(L.TEXTURE_2D,ge,Ee,st,Me,me,dt,Yt,vt.data);else if(b.isCompressedTexture)L.compressedTexSubImage2D(L.TEXTURE_2D,ge,Ee,st,vt.width,vt.height,dt,vt.data);else L.texSubImage2D(L.TEXTURE_2D,ge,Ee,st,Me,me,dt,Yt,vt);if(w.pixelStorei(L.UNPACK_ROW_LENGTH,rn),w.pixelStorei(L.UNPACK_IMAGE_HEIGHT,Ke),w.pixelStorei(L.UNPACK_SKIP_PIXELS,En),w.pixelStorei(L.UNPACK_SKIP_ROWS,Jn),w.pixelStorei(L.UNPACK_SKIP_IMAGES,Oi),ge===0&&N.generateMipmaps)L.generateMipmap(Se);w.unbindTexture()},this.initRenderTarget=function(b){if(I.get(b).__webglFramebuffer===void 0)W.setupRenderTarget(b)},this.initTexture=function(b){if(b.isCubeTexture)W.setTextureCube(b,0);else if(b.isData3DTexture)W.setTexture3D(b,0);else if(b.isDataArrayTexture||b.isCompressedArrayTexture)W.setTexture2DArray(b,0);else W.setTexture2D(b,0);w.unbindTexture()},this.resetState=function(){V=0,j=0,z=null,w.reset(),ue.reset()},typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return uu}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;let t=this.getContext();t.drawingBufferColorSpace=$e._getDrawingBufferColorSpace(e),t.unpackColorSpace=$e._getUnpackColorSpace()}}function Vu(e,t){if(t===ou)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),e;if(t===us||t===$s){let n=e.getIndex();if(n===null){let s=[],o=e.getAttribute("position");if(o!==void 0){for(let a=0;a<o.count;a++)s.push(a);e.setIndex(s),n=e.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),e}let i=n.count-2,r=[];if(t===us)for(let s=1;s<=i;s++)r.push(n.getX(0)),r.push(n.getX(s)),r.push(n.getX(s+1));else for(let s=0;s<i;s++)if(s%2===0)r.push(n.getX(s)),r.push(n.getX(s+1)),r.push(n.getX(s+2));else r.push(n.getX(s+2)),r.push(n.getX(s+1)),r.push(n.getX(s));if(r.length/3!==i)console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");return e.setIndex(r),e.clearGroups(),e}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",t),e}function tm(e){let t=new Map,n=new Map,i=e.clone();return nm(e,i,function(r,s){t.set(s,r),n.set(r,s)}),i.traverse(function(r){if(!r.isSkinnedMesh)return;let s=r,o=t.get(r),a=o.skeleton.bones;s.skeleton=o.skeleton.clone(),s.bindMatrix.copy(o.bindMatrix),s.skeleton.bones=a.map(function(c){return n.get(c)}),s.bind(s.skeleton,s.bindMatrix)}),i}function nm(e,t,n){n(e,t);for(let i=0;i<e.children.length;i++)nm(e.children[i],t.children[i],n)}class Yu extends Pi{constructor(e){super(e);this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new um(t)}),this.register(function(t){return new hm(t)}),this.register(function(t){return new vm(t)}),this.register(function(t){return new bm(t)}),this.register(function(t){return new Sm(t)}),this.register(function(t){return new dm(t)}),this.register(function(t){return new pm(t)}),this.register(function(t){return new mm(t)}),this.register(function(t){return new gm(t)}),this.register(function(t){return new lm(t)}),this.register(function(t){return new _m(t)}),this.register(function(t){return new fm(t)}),this.register(function(t){return new ym(t)}),this.register(function(t){return new xm(t)}),this.register(function(t){return new am(t)}),this.register(function(t){return new Xu(t,Xe.EXT_MESHOPT_COMPRESSION)}),this.register(function(t){return new Xu(t,Xe.KHR_MESHOPT_COMPRESSION)}),this.register(function(t){return new Mm(t)})}load(e,t,n,i){let r=this,s;if(this.resourcePath!=="")s=this.resourcePath;else if(this.path!==""){let c=ir.extractUrlBase(e);s=ir.resolveURL(c,this.path)}else s=ir.extractUrlBase(e);this.manager.itemStart(e);let o=function(c){if(i)i(c);else console.error(c);r.manager.itemError(e),r.manager.itemEnd(e)},a=new io(this.manager);a.setPath(this.path),a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(c){try{r.parse(c,s,function(l){t(l),r.manager.itemEnd(e)},o)}catch(l){o(l)}},n,o)}setDRACOLoader(e){return this.dracoLoader=e,this}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){if(this.pluginCallbacks.indexOf(e)===-1)this.pluginCallbacks.push(e);return this}unregister(e){if(this.pluginCallbacks.indexOf(e)!==-1)this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1);return this}parse(e,t,n,i){let r,s={},o={},a=new TextDecoder;if(typeof e==="string")r=JSON.parse(e);else if(e instanceof ArrayBuffer)if(a.decode(new Uint8Array(e,0,4))===wm){try{s[Xe.KHR_BINARY_GLTF]=new Em(e)}catch(u){if(i)i(u);return}r=JSON.parse(s[Xe.KHR_BINARY_GLTF].content)}else r=JSON.parse(a.decode(e));else r=e;if(r.asset===void 0||r.asset.version[0]<2){if(i)i(Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}let c=new Pm(r,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let l=0;l<this.pluginCallbacks.length;l++){let u=this.pluginCallbacks[l](c);if(!u.name)console.error("THREE.GLTFLoader: Invalid plugin found: missing name");o[u.name]=u,s[u.name]=!0}if(r.extensionsUsed)for(let l=0;l<r.extensionsUsed.length;++l){let u=r.extensionsUsed[l],f=r.extensionsRequired||[];switch(u){case Xe.KHR_MATERIALS_UNLIT:s[u]=new cm;break;case Xe.KHR_DRACO_MESH_COMPRESSION:s[u]=new Tm(r,this.dracoLoader);break;case Xe.KHR_TEXTURE_TRANSFORM:s[u]=new Am;break;case Xe.KHR_MESH_QUANTIZATION:s[u]=new Rm;break;default:if(f.indexOf(u)>=0&&o[u]===void 0)console.warn('THREE.GLTFLoader: Unknown extension "'+u+'".')}}c.setExtensions(s),c.setPlugins(o),c.parse(n,i)}parseAsync(e,t){let n=this;return new Promise(function(i,r){n.parse(e,t,i,r)})}}function hT(){let e={};return{get:function(t){return e[t]},add:function(t,n){e[t]=n},remove:function(t){delete e[t]},removeAll:function(){e={}}}}function Pt(e,t,n){let i=e.json.materials[t];if(i.extensions&&i.extensions[n])return i.extensions[n];return null}var Xe={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",KHR_MESHOPT_COMPRESSION:"KHR_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class am{constructor(e){this.parser=e,this.name=Xe.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){let e=this.parser,t=this.parser.json.nodes||[];for(let n=0,i=t.length;n<i;n++){let r=t[n];if(r.extensions&&r.extensions[this.name]&&r.extensions[this.name].light!==void 0)e._addNodeRef(this.cache,r.extensions[this.name].light)}}_loadLight(e){let t=this.parser,n="light:"+e,i=t.cache.get(n);if(i)return i;let r=t.json,a=((r.extensions&&r.extensions[this.name]||{}).lights||[])[e],c,l=new Ue(16777215);if(a.color!==void 0)l.setRGB(a.color[0],a.color[1],a.color[2],gn);let u=a.range!==void 0?a.range:0;switch(a.type){case"directional":c=new _s(l),c.target.position.set(0,0,-1),c.add(c.target);break;case"point":c=new gs(l),c.distance=u;break;case"spot":c=new Za(l),c.distance=u,a.spot=a.spot||{},a.spot.innerConeAngle=a.spot.innerConeAngle!==void 0?a.spot.innerConeAngle:0,a.spot.outerConeAngle=a.spot.outerConeAngle!==void 0?a.spot.outerConeAngle:Math.PI/4,c.angle=a.spot.outerConeAngle,c.penumbra=1-a.spot.innerConeAngle/a.spot.outerConeAngle,c.target.position.set(0,0,-1),c.add(c.target);break;default:throw Error("THREE.GLTFLoader: Unexpected light type: "+a.type)}if(c.position.set(0,0,0),ui(c,a),a.intensity!==void 0)c.intensity=a.intensity;return c.name=t.createUniqueName(a.name||"light_"+e),i=Promise.resolve(c),t.cache.add(n,i),i}getDependency(e,t){if(e!=="light")return;return this._loadLight(t)}createNodeAttachment(e){let t=this,n=this.parser,r=n.json.nodes[e],o=(r.extensions&&r.extensions[this.name]||{}).light;if(o===void 0)return null;return this._loadLight(o).then(function(a){return n._getNodeRef(t.cache,o,a)})}}class cm{constructor(){this.name=Xe.KHR_MATERIALS_UNLIT}getMaterialType(){return ai}extendParams(e,t,n){let i=[];e.color=new Ue(1,1,1),e.opacity=1;let r=t.pbrMetallicRoughness;if(r){if(Array.isArray(r.baseColorFactor)){let s=r.baseColorFactor;e.color.setRGB(s[0],s[1],s[2],gn),e.opacity=s[3]}if(r.baseColorTexture!==void 0)i.push(n.assignTexture(e,"map",r.baseColorTexture,ji))}return Promise.all(i)}}class lm{constructor(e){this.parser=e,this.name=Xe.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){let n=Pt(this.parser,e,this.name);if(n===null)return Promise.resolve();if(n.emissiveStrength!==void 0)t.emissiveIntensity=n.emissiveStrength;return Promise.resolve()}}class um{constructor(e){this.parser=e,this.name=Xe.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){return Pt(this.parser,e,this.name)!==null?yn:null}extendMaterialParams(e,t){let n=Pt(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(n.clearcoatFactor!==void 0)t.clearcoat=n.clearcoatFactor;if(n.clearcoatTexture!==void 0)i.push(this.parser.assignTexture(t,"clearcoatMap",n.clearcoatTexture));if(n.clearcoatRoughnessFactor!==void 0)t.clearcoatRoughness=n.clearcoatRoughnessFactor;if(n.clearcoatRoughnessTexture!==void 0)i.push(this.parser.assignTexture(t,"clearcoatRoughnessMap",n.clearcoatRoughnessTexture));if(n.clearcoatNormalTexture!==void 0){if(i.push(this.parser.assignTexture(t,"clearcoatNormalMap",n.clearcoatNormalTexture)),n.clearcoatNormalTexture.scale!==void 0){let r=n.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new Ne(r,r)}}return Promise.all(i)}}class hm{constructor(e){this.parser=e,this.name=Xe.KHR_MATERIALS_DISPERSION}getMaterialType(e){return Pt(this.parser,e,this.name)!==null?yn:null}extendMaterialParams(e,t){let n=Pt(this.parser,e,this.name);if(n===null)return Promise.resolve();return t.dispersion=n.dispersion!==void 0?n.dispersion:0,Promise.resolve()}}class fm{constructor(e){this.parser=e,this.name=Xe.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){return Pt(this.parser,e,this.name)!==null?yn:null}extendMaterialParams(e,t){let n=Pt(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(n.iridescenceFactor!==void 0)t.iridescence=n.iridescenceFactor;if(n.iridescenceTexture!==void 0)i.push(this.parser.assignTexture(t,"iridescenceMap",n.iridescenceTexture));if(n.iridescenceIor!==void 0)t.iridescenceIOR=n.iridescenceIor;if(t.iridescenceThicknessRange===void 0)t.iridescenceThicknessRange=[100,400];if(n.iridescenceThicknessMinimum!==void 0)t.iridescenceThicknessRange[0]=n.iridescenceThicknessMinimum;if(n.iridescenceThicknessMaximum!==void 0)t.iridescenceThicknessRange[1]=n.iridescenceThicknessMaximum;if(n.iridescenceThicknessTexture!==void 0)i.push(this.parser.assignTexture(t,"iridescenceThicknessMap",n.iridescenceThicknessTexture));return Promise.all(i)}}class dm{constructor(e){this.parser=e,this.name=Xe.KHR_MATERIALS_SHEEN}getMaterialType(e){return Pt(this.parser,e,this.name)!==null?yn:null}extendMaterialParams(e,t){let n=Pt(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(t.sheenColor=new Ue(0,0,0),t.sheenRoughness=0,t.sheen=1,n.sheenColorFactor!==void 0){let r=n.sheenColorFactor;t.sheenColor.setRGB(r[0],r[1],r[2],gn)}if(n.sheenRoughnessFactor!==void 0)t.sheenRoughness=n.sheenRoughnessFactor;if(n.sheenColorTexture!==void 0)i.push(this.parser.assignTexture(t,"sheenColorMap",n.sheenColorTexture,ji));if(n.sheenRoughnessTexture!==void 0)i.push(this.parser.assignTexture(t,"sheenRoughnessMap",n.sheenRoughnessTexture));return Promise.all(i)}}class pm{constructor(e){this.parser=e,this.name=Xe.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){return Pt(this.parser,e,this.name)!==null?yn:null}extendMaterialParams(e,t){let n=Pt(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(n.transmissionFactor!==void 0)t.transmission=n.transmissionFactor;if(n.transmissionTexture!==void 0)i.push(this.parser.assignTexture(t,"transmissionMap",n.transmissionTexture));return Promise.all(i)}}class mm{constructor(e){this.parser=e,this.name=Xe.KHR_MATERIALS_VOLUME}getMaterialType(e){return Pt(this.parser,e,this.name)!==null?yn:null}extendMaterialParams(e,t){let n=Pt(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(t.thickness=n.thicknessFactor!==void 0?n.thicknessFactor:0,n.thicknessTexture!==void 0)i.push(this.parser.assignTexture(t,"thicknessMap",n.thicknessTexture));t.attenuationDistance=n.attenuationDistance||1/0;let r=n.attenuationColor||[1,1,1];return t.attenuationColor=new Ue().setRGB(r[0],r[1],r[2],gn),Promise.all(i)}}class gm{constructor(e){this.parser=e,this.name=Xe.KHR_MATERIALS_IOR}getMaterialType(e){return Pt(this.parser,e,this.name)!==null?yn:null}extendMaterialParams(e,t){let n=Pt(this.parser,e,this.name);if(n===null)return Promise.resolve();if(t.ior=n.ior!==void 0?n.ior:1.5,t.ior===0)t.ior=1000;return Promise.resolve()}}class _m{constructor(e){this.parser=e,this.name=Xe.KHR_MATERIALS_SPECULAR}getMaterialType(e){return Pt(this.parser,e,this.name)!==null?yn:null}extendMaterialParams(e,t){let n=Pt(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(t.specularIntensity=n.specularFactor!==void 0?n.specularFactor:1,n.specularTexture!==void 0)i.push(this.parser.assignTexture(t,"specularIntensityMap",n.specularTexture));let r=n.specularColorFactor||[1,1,1];if(t.specularColor=new Ue().setRGB(r[0],r[1],r[2],gn),n.specularColorTexture!==void 0)i.push(this.parser.assignTexture(t,"specularColorMap",n.specularColorTexture,ji));return Promise.all(i)}}class xm{constructor(e){this.parser=e,this.name=Xe.EXT_MATERIALS_BUMP}getMaterialType(e){return Pt(this.parser,e,this.name)!==null?yn:null}extendMaterialParams(e,t){let n=Pt(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(t.bumpScale=n.bumpFactor!==void 0?n.bumpFactor:1,n.bumpTexture!==void 0)i.push(this.parser.assignTexture(t,"bumpMap",n.bumpTexture));return Promise.all(i)}}class ym{constructor(e){this.parser=e,this.name=Xe.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){return Pt(this.parser,e,this.name)!==null?yn:null}extendMaterialParams(e,t){let n=Pt(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(n.anisotropyStrength!==void 0)t.anisotropy=n.anisotropyStrength;if(n.anisotropyRotation!==void 0)t.anisotropyRotation=n.anisotropyRotation;if(n.anisotropyTexture!==void 0)i.push(this.parser.assignTexture(t,"anisotropyMap",n.anisotropyTexture));return Promise.all(i)}}class vm{constructor(e){this.parser=e,this.name=Xe.KHR_TEXTURE_BASISU}loadTexture(e){let t=this.parser,n=t.json,i=n.textures[e];if(!i.extensions||!i.extensions[this.name])return null;let r=i.extensions[this.name],s=t.options.ktx2Loader;if(!s)if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");else return null;return t.loadTextureImage(e,r.source,s)}}class bm{constructor(e){this.parser=e,this.name=Xe.EXT_TEXTURE_WEBP}loadTexture(e){let t=this.name,n=this.parser,i=n.json,r=i.textures[e];if(!r.extensions||!r.extensions[t])return null;let s=r.extensions[t],o=i.images[s.source],a=n.textureLoader;if(o.uri){let c=n.options.manager.getHandler(o.uri);if(c!==null)a=c}return n.loadTextureImage(e,s.source,a)}}class Sm{constructor(e){this.parser=e,this.name=Xe.EXT_TEXTURE_AVIF}loadTexture(e){let t=this.name,n=this.parser,i=n.json,r=i.textures[e];if(!r.extensions||!r.extensions[t])return null;let s=r.extensions[t],o=i.images[s.source],a=n.textureLoader;if(o.uri){let c=n.options.manager.getHandler(o.uri);if(c!==null)a=c}return n.loadTextureImage(e,s.source,a)}}class Xu{constructor(e,t){this.name=t,this.parser=e}loadBufferView(e){let t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){let i=n.extensions[this.name],r=this.parser.getDependency("buffer",i.buffer),s=this.parser.options.meshoptDecoder;if(!s||!s.supported)if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");else return null;return r.then(function(o){let a=i.byteOffset||0,c=i.byteLength||0,{count:l,byteStride:u}=i,f=new Uint8Array(o,a,c);if(s.decodeGltfBufferAsync)return s.decodeGltfBufferAsync(l,u,f,i.mode,i.filter).then(function(h){return h.buffer});else return s.ready.then(function(){let h=new ArrayBuffer(l*u);return s.decodeGltfBuffer(new Uint8Array(h),l,u,f,i.mode,i.filter),h})})}else return null}}class Mm{constructor(e){this.name=Xe.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){let t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||n.mesh===void 0)return null;let i=t.meshes[n.mesh];for(let c of i.primitives)if(c.mode!==In.TRIANGLES&&c.mode!==In.TRIANGLE_STRIP&&c.mode!==In.TRIANGLE_FAN&&c.mode!==void 0)return null;let s=n.extensions[this.name].attributes,o=[],a={};for(let c in s)o.push(this.parser.getDependency("accessor",s[c]).then((l)=>(a[c]=l,a[c])));if(o.length<1)return null;return o.push(this.parser.createNodeMesh(e)),Promise.all(o).then((c)=>{let l=c.pop(),u=l.isGroup?l.children:[l],f=c[0].count,h=[];for(let d of u){let g=new Ge,x=new D,p=new Ht,m=new D(1,1,1),E=new ds(d.geometry,d.material,f);for(let v=0;v<f;v++){if(a.TRANSLATION)x.fromBufferAttribute(a.TRANSLATION,v);if(a.ROTATION)p.fromBufferAttribute(a.ROTATION,v);if(a.SCALE)m.fromBufferAttribute(a.SCALE,v);E.setMatrixAt(v,g.compose(x,p,m))}let R=null;for(let v in a)if(v==="_COLOR_0"){let M=a[v];E.instanceColor=new $i(M.array,M.itemSize,M.normalized)}else if(v!=="TRANSLATION"&&v!=="ROTATION"&&v!=="SCALE"){if(R===null){let T=E.geometry;R=new en,R.name=T.name;for(let A in T.attributes)R.setAttribute(A,T.attributes[A]);for(let A in T.morphAttributes)R.morphAttributes[A]=T.morphAttributes[A];if(T.index!==null)R.setIndex(T.index);R.morphTargetsRelative=T.morphTargetsRelative;for(let A of T.groups)R.addGroup(A.start,A.count,A.materialIndex);if(T.boundingBox!==null)R.boundingBox=T.boundingBox.clone();if(T.boundingSphere!==null)R.boundingSphere=T.boundingSphere.clone();R.drawRange.start=T.drawRange.start,R.drawRange.count=T.drawRange.count,R.userData=Object.assign({},T.userData),E.geometry=R}let M=a[v];R.setAttribute(v,new $i(M.array,M.itemSize,M.normalized))}ht.prototype.copy.call(E,d),this.parser.assignFinalMaterial(E),h.push(E)}if(l.isGroup)return l.clear(),l.add(...h),l;return h[0]})}}var wm="glTF",ho=12,im={JSON:1313821514,BIN:5130562};class Em{constructor(e){this.name=Xe.KHR_BINARY_GLTF,this.content=null,this.body=null;let t=new DataView(e,0,ho),n=new TextDecoder;if(this.header={magic:n.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==wm)throw Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");else if(this.header.version<2)throw Error("THREE.GLTFLoader: Legacy binary file detected.");let i=this.header.length-ho,r=new DataView(e,ho),s=0;while(s<i){let o=r.getUint32(s,!0);s+=4;let a=r.getUint32(s,!0);if(s+=4,a===im.JSON){let c=new Uint8Array(e,ho+s,o);this.content=n.decode(c)}else if(a===im.BIN){let c=ho+s;this.body=e.slice(c,c+o)}s+=o}if(this.content===null)throw Error("THREE.GLTFLoader: JSON content not found.")}}class Tm{constructor(e,t){if(!t)throw Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=Xe.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){let n=this.json,i=this.dracoLoader,r=e.extensions[this.name].bufferView,s=e.extensions[this.name].attributes,o={},a={},c={};for(let l in s){let u=qu[l]||l.toLowerCase();o[u]=s[l]}for(let l in e.attributes){let u=qu[l]||l.toLowerCase();if(s[l]!==void 0){let f=n.accessors[e.attributes[l]],h=bs[f.componentType];c[u]=h.name,a[u]=f.normalized===!0}}return t.getDependency("bufferView",r).then(function(l){return new Promise(function(u,f){i.decodeDracoFile(l,function(h){for(let d in h.attributes){let g=h.attributes[d],x=a[d];if(x!==void 0)g.normalized=x}u(h)},o,c,gn,f)})})}}class Am{constructor(){this.name=Xe.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){if((t.texCoord===void 0||t.texCoord===e.channel)&&t.offset===void 0&&t.rotation===void 0&&t.scale===void 0)return e;if(e=e.clone(),t.texCoord!==void 0)e.channel=t.texCoord;if(t.offset!==void 0)e.offset.fromArray(t.offset);if(t.rotation!==void 0)e.rotation=t.rotation;if(t.scale!==void 0)e.repeat.fromArray(t.scale);if(t.rotation!==void 0){let n=Math.cos(e.rotation),i=Math.sin(e.rotation);e.matrix.set(e.repeat.x*n,e.repeat.y*i,e.offset.x,-e.repeat.x*i,e.repeat.y*n,e.offset.y,0,0,1),e.matrixAutoUpdate=!1}return e.needsUpdate=!0,e}}class Rm{constructor(){this.name=Xe.KHR_MESH_QUANTIZATION}}class Ku extends Ci{constructor(e,t,n,i){super(e,t,n,i)}copySampleValue_(e){let t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=e*i*3+i;for(let s=0;s!==i;s++)t[s]=n[r+s];return t}interpolate_(e,t,n,i){let r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=o*2,c=o*3,l=i-t,u=(n-t)/l,f=u*u,h=f*u,d=e*c,g=d-c,x=-2*h+3*f,p=h-f,m=1-x,E=p-f+u;for(let R=0;R!==o;R++){let v=s[g+R+o],M=s[g+R+a]*l,T=s[d+R+o],A=s[d+R]*l;r[R]=m*v+E*M+x*T+p*A}return r}}var fT=new Ht;class Cm extends Ku{interpolate_(e,t,n,i){let r=super.interpolate_(e,t,n,i);return fT.fromArray(r).normalize().toArray(r),r}}var In={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},bs={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},rm={9728:Hn,9729:$t,9984:ba,9985:cs,9986:vr,9987:ri},sm={33071:as,33648:va,10497:os},$u={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},qu={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},rr={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},dT={CUBICSPLINE:void 0,LINEAR:Ra,STEP:su},Wu={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function pT(e){if(e.DefaultMaterial===void 0)e.DefaultMaterial=new Ri({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:Xi});return e.DefaultMaterial}function Pr(e,t,n){for(let i in n.extensions)if(e[i]===void 0)t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[i]=n.extensions[i]}function ui(e,t){if(t.extras!==void 0)if(typeof t.extras==="object")Object.assign(e.userData,t.extras);else console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+t.extras)}function mT(e,t,n){let i=!1,r=!1,s=!1;for(let l=0,u=t.length;l<u;l++){let f=t[l];if(f.POSITION!==void 0)i=!0;if(f.NORMAL!==void 0)r=!0;if(f.COLOR_0!==void 0)s=!0;if(i&&r&&s)break}if(!i&&!r&&!s)return Promise.resolve(e);let o=[],a=[],c=[];for(let l=0,u=t.length;l<u;l++){let f=t[l];if(i){let h=f.POSITION!==void 0?n.getDependency("accessor",f.POSITION):e.attributes.position;o.push(h)}if(r){let h=f.NORMAL!==void 0?n.getDependency("accessor",f.NORMAL):e.attributes.normal;a.push(h)}if(s){let h=f.COLOR_0!==void 0?n.getDependency("accessor",f.COLOR_0):e.attributes.color;c.push(h)}}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(c)]).then(function(l){let u=l[0],f=l[1],h=l[2];if(i)e.morphAttributes.position=u;if(r)e.morphAttributes.normal=f;if(s)e.morphAttributes.color=h;return e.morphTargetsRelative=!0,e})}function gT(e,t){if(e.updateMorphTargets(),t.weights!==void 0)for(let n=0,i=t.weights.length;n<i;n++)e.morphTargetInfluences[n]=t.weights[n];if(t.extras&&Array.isArray(t.extras.targetNames)){let n=t.extras.targetNames;if(e.morphTargetInfluences.length===n.length){e.morphTargetDictionary={};for(let i=0,r=n.length;i<r;i++)e.morphTargetDictionary[n[i]]=i}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function _T(e){let t,n=e.extensions&&e.extensions[Xe.KHR_DRACO_MESH_COMPRESSION];if(n)t="draco:"+n.bufferView+":"+n.indices+":"+Zu(n.attributes);else t=e.indices+":"+Zu(e.attributes)+":"+e.mode;if(e.targets!==void 0)for(let i=0,r=e.targets.length;i<r;i++)t+=":"+Zu(e.targets[i]);return t}function Zu(e){let t="",n=Object.keys(e).sort();for(let i=0,r=n.length;i<r;i++)t+=n[i]+":"+e[n[i]]+";";return t}function ju(e){switch(e){case Int8Array:return 0.007874015748031496;case Uint8Array:return 0.00392156862745098;case Int16Array:return 0.00003051850947599719;case Uint16Array:return 0.000015259021896696422;default:throw Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function xT(e){if(e.search(/\.jpe?g($|\?)/i)>0||e.search(/^data\:image\/jpeg/)===0)return"image/jpeg";if(e.search(/\.webp($|\?)/i)>0||e.search(/^data\:image\/webp/)===0)return"image/webp";if(e.search(/\.ktx2($|\?)/i)>0||e.search(/^data\:image\/ktx2/)===0)return"image/ktx2";return"image/png"}var yT=new Ge;class Pm{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new hT,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let n=!1,i=-1,r=!1,s=-1;if(typeof navigator<"u"&&typeof navigator.userAgent<"u"){let o=navigator.userAgent;n=/^((?!chrome|android).)*safari/i.test(o)===!0;let a=o.match(/Version\/(\d+)/);i=n&&a?parseInt(a[1],10):-1,r=o.indexOf("Firefox")>-1,s=r?o.match(/Firefox\/([0-9]+)\./)[1]:-1}if(typeof createImageBitmap>"u"||n&&i<17||r&&s<98)this.textureLoader=new Va(this.options.manager);else this.textureLoader=new Xa(this.options.manager);if(this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new io(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials")this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){let n=this,i=this.json,r=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(s){return s._markDefs&&s._markDefs()}),Promise.all(this._invokeAll(function(s){return s.beforeRoot&&s.beforeRoot()})).then(function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(s){let o={scene:s[0][i.scene||0],scenes:s[0],animations:s[1],cameras:s[2],asset:i.asset,parser:n,userData:{}};return Pr(r,o,i),ui(o,i),Promise.all(n._invokeAll(function(a){return a.afterRoot&&a.afterRoot(o)})).then(function(){for(let a of o.scenes)a.updateMatrixWorld();e(o)})}).catch(t)}_markDefs(){let e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let i=0,r=t.length;i<r;i++){let s=t[i].joints;for(let o=0,a=s.length;o<a;o++)e[s[o]].isBone=!0}for(let i=0,r=e.length;i<r;i++){let s=e[i];if(s.mesh!==void 0){if(this._addNodeRef(this.meshCache,s.mesh),s.skin!==void 0)n[s.mesh].isSkinnedMesh=!0}if(s.camera!==void 0)this._addNodeRef(this.cameraCache,s.camera)}}_addNodeRef(e,t){if(t===void 0)return;if(e.refs[t]===void 0)e.refs[t]=e.uses[t]=0;e.refs[t]++}_getNodeRef(e,t,n){if(e.refs[t]<=1)return n;let i=n.clone(),r=(s,o)=>{let a=this.associations.get(s);if(a!=null)this.associations.set(o,a);for(let[c,l]of s.children.entries())r(l,o.children[c])};return r(n,i),i.name+="_instance_"+e.uses[t]++,i}_invokeOne(e){let t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){let i=e(t[n]);if(i)return i}return null}_invokeAll(e){let t=Object.values(this.plugins);t.unshift(this);let n=[];for(let i=0;i<t.length;i++){let r=e(t[i]);if(r)n.push(r)}return n}getDependency(e,t){let n=e+":"+t,i=this.cache.get(n);if(!i){switch(e){case"scene":i=this.loadScene(t);break;case"node":i=this._invokeOne(function(r){return r.loadNode&&r.loadNode(t)});break;case"mesh":i=this._invokeOne(function(r){return r.loadMesh&&r.loadMesh(t)});break;case"accessor":i=this.loadAccessor(t);break;case"bufferView":i=this._invokeOne(function(r){return r.loadBufferView&&r.loadBufferView(t)});break;case"buffer":i=this.loadBuffer(t);break;case"material":i=this._invokeOne(function(r){return r.loadMaterial&&r.loadMaterial(t)});break;case"texture":i=this._invokeOne(function(r){return r.loadTexture&&r.loadTexture(t)});break;case"skin":i=this.loadSkin(t);break;case"animation":i=this._invokeOne(function(r){return r.loadAnimation&&r.loadAnimation(t)});break;case"camera":i=this.loadCamera(t);break;default:if(i=this._invokeOne(function(r){return r!=this&&r.getDependency&&r.getDependency(e,t)}),!i)throw Error("Unknown type: "+e);break}this.cache.add(n,i)}return i}getDependencies(e){let t=this.cache.get(e);if(!t){let n=this,i=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(i.map(function(r,s){return n.getDependency(e,s)})),this.cache.add(e,t)}return t}loadBuffer(e){let t=this.json.buffers[e],n=this.fileLoader;if(t.type&&t.type!=="arraybuffer")throw Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[Xe.KHR_BINARY_GLTF].body);let i=this.options;return new Promise(function(r,s){n.load(ir.resolveURL(t.uri,i.path),r,void 0,function(){s(Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){let t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(n){let i=t.byteLength||0,r=t.byteOffset||0;return n.slice(r,r+i)})}loadAccessor(e){let t=this,n=this.json,i=this.json.accessors[e];if(i.bufferView===void 0&&i.sparse===void 0){let s=$u[i.type],o=bs[i.componentType],a=i.normalized===!0,c=new o(i.count*s);return Promise.resolve(new Vt(c,s,a))}let r=[];if(i.bufferView!==void 0)r.push(this.getDependency("bufferView",i.bufferView));else r.push(null);if(i.sparse!==void 0)r.push(this.getDependency("bufferView",i.sparse.indices.bufferView)),r.push(this.getDependency("bufferView",i.sparse.values.bufferView));return Promise.all(r).then(function(s){let o=s[0],a=$u[i.type],c=bs[i.componentType],l=c.BYTES_PER_ELEMENT,u=l*a,f=i.byteOffset||0,h=i.bufferView!==void 0?n.bufferViews[i.bufferView].byteStride:void 0,d=i.normalized===!0,g,x;if(h&&h!==u){let p=Math.floor(f/h),m="InterleavedBuffer:"+i.bufferView+":"+i.componentType+":"+p+":"+i.count,E=t.cache.get(m);if(!E)g=new c(o,p*h,i.count*h/l),E=new qs(g,h/l),t.cache.add(m,E);x=new fs(E,a,f%h/l,d)}else{if(o===null)g=new c(i.count*a);else g=new c(o,f,i.count*a);x=new Vt(g,a,d)}if(i.sparse!==void 0){let p=$u.SCALAR,m=bs[i.sparse.indices.componentType],E=i.sparse.indices.byteOffset||0,R=i.sparse.values.byteOffset||0,v=new m(s[1],E,i.sparse.count*p),M=new c(s[2],R,i.sparse.count*a);if(o!==null)x=new Vt(x.array.slice(),x.itemSize,x.normalized);x.normalized=!1;for(let T=0,A=v.length;T<A;T++){let _=v[T];if(x.setX(_,M[T*a]),a>=2)x.setY(_,M[T*a+1]);if(a>=3)x.setZ(_,M[T*a+2]);if(a>=4)x.setW(_,M[T*a+3]);if(a>=5)throw Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}x.normalized=d}return x})}loadTexture(e){let t=this.json,n=this.options,r=t.textures[e].source,s=t.images[r],o=this.textureLoader;if(s.uri){let a=n.manager.getHandler(s.uri);if(a!==null)o=a}return this.loadTextureImage(e,r,o)}loadTextureImage(e,t,n){let i=this,r=this.json,s=r.textures[e],o=r.images[t],a=(o.uri||o.bufferView)+":"+s.sampler;if(this.textureCache[a])return this.textureCache[a];let c=this.loadImageSource(t,n).then(function(l){if(l.flipY=!1,l.name=s.name||o.name||"",l.name===""&&typeof o.uri==="string"&&o.uri.startsWith("data:image/")===!1)l.name=o.uri;let f=(r.samplers||{})[s.sampler]||{};return l.magFilter=rm[f.magFilter]||$t,l.minFilter=rm[f.minFilter]||ri,l.wrapS=sm[f.wrapS]||os,l.wrapT=sm[f.wrapT]||os,l.generateMipmaps=!l.isCompressedTexture&&l.minFilter!==Hn&&l.minFilter!==$t,i.associations.set(l,{textures:e}),l}).catch(function(){return null});return this.textureCache[a]=c,c}loadImageSource(e,t){let n=this,i=this.json,r=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then((u)=>u.clone());let s=i.images[e],o=self.URL||self.webkitURL,a=s.uri||"",c=!1;if(s.bufferView!==void 0)a=n.getDependency("bufferView",s.bufferView).then(function(u){c=!0;let f=new Blob([u],{type:s.mimeType});return a=o.createObjectURL(f),a});else if(s.uri===void 0)throw Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");let l=Promise.resolve(a).then(function(u){return new Promise(function(f,h){let d=f;if(t.isImageBitmapLoader===!0)d=function(g){let x=new At(g);x.needsUpdate=!0,f(x)};t.load(ir.resolveURL(u,r.path),d,void 0,h)})}).then(function(u){if(c===!0)o.revokeObjectURL(a);return ui(u,s),u.userData.mimeType=s.mimeType||xT(s.uri),u}).catch(function(u){throw console.error("THREE.GLTFLoader: Couldn't load texture",a),u});return this.sourceCache[e]=l,l}assignTexture(e,t,n,i){let r=this;return this.getDependency("texture",n.index).then(function(s){if(!s)return null;if(n.texCoord!==void 0&&n.texCoord>0)s=s.clone(),s.channel=n.texCoord;if(r.extensions[Xe.KHR_TEXTURE_TRANSFORM]){let o=n.extensions!==void 0?n.extensions[Xe.KHR_TEXTURE_TRANSFORM]:void 0;if(o){let a=r.associations.get(s);s=r.extensions[Xe.KHR_TEXTURE_TRANSFORM].extendTexture(s,o),r.associations.set(s,a)}}if(i!==void 0)s.colorSpace=i;return e[t]=s,s})}assignFinalMaterial(e){let{geometry:t,material:n}=e,i=t.attributes.tangent===void 0,r=t.attributes.color!==void 0,s=t.attributes.normal===void 0;if(e.isPoints){let o="PointsMaterial:"+n.uuid,a=this.cache.get(o);if(!a)a=new eo,hn.prototype.copy.call(a,n),a.color.copy(n.color),a.map=n.map,a.sizeAttenuation=!1,this.cache.add(o,a);n=a}else if(e.isLine){let o="LineBasicMaterial:"+n.uuid,a=this.cache.get(o);if(!a)a=new Qs,hn.prototype.copy.call(a,n),a.color.copy(n.color),a.map=n.map,this.cache.add(o,a);n=a}if(i||r||s){let o="ClonedMaterial:"+n.uuid+":";if(i)o+="derivative-tangents:";if(r)o+="vertex-colors:";if(s)o+="flat-shading:";let a=this.cache.get(o);if(!a){if(a=n.clone(),r)a.vertexColors=!0;if(s)a.flatShading=!0;if(i){if(a.normalScale)a.normalScale.y*=-1;if(a.clearcoatNormalScale)a.clearcoatNormalScale.y*=-1}this.cache.add(o,a),this.associations.set(a,this.associations.get(n))}n=a}e.material=n}getMaterialType(){return Ri}loadMaterial(e){let t=this,n=this.json,i=this.extensions,r=n.materials[e],s,o={},a=r.extensions||{},c=[];if(a[Xe.KHR_MATERIALS_UNLIT]){let u=i[Xe.KHR_MATERIALS_UNLIT];s=u.getMaterialType(),c.push(u.extendParams(o,r,t))}else{let u=r.pbrMetallicRoughness||{};if(o.color=new Ue(1,1,1),o.opacity=1,Array.isArray(u.baseColorFactor)){let f=u.baseColorFactor;o.color.setRGB(f[0],f[1],f[2],gn),o.opacity=f[3]}if(u.baseColorTexture!==void 0)c.push(t.assignTexture(o,"map",u.baseColorTexture,ji));if(o.metalness=u.metallicFactor!==void 0?u.metallicFactor:1,o.roughness=u.roughnessFactor!==void 0?u.roughnessFactor:1,u.metallicRoughnessTexture!==void 0)c.push(t.assignTexture(o,"metalnessMap",u.metallicRoughnessTexture)),c.push(t.assignTexture(o,"roughnessMap",u.metallicRoughnessTexture));s=this._invokeOne(function(f){return f.getMaterialType&&f.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(f){return f.extendMaterialParams&&f.extendMaterialParams(e,o)})))}if(r.doubleSided===!0)o.side=Cn;let l=r.alphaMode||Wu.OPAQUE;if(l===Wu.BLEND)o.transparent=!0,o.depthWrite=!1;else if(o.transparent=!1,l===Wu.MASK)o.alphaTest=r.alphaCutoff!==void 0?r.alphaCutoff:0.5;if(r.normalTexture!==void 0&&s!==ai){if(c.push(t.assignTexture(o,"normalMap",r.normalTexture)),o.normalScale=new Ne(1,1),r.normalTexture.scale!==void 0){let u=r.normalTexture.scale;o.normalScale.set(u,u)}}if(r.occlusionTexture!==void 0&&s!==ai){if(c.push(t.assignTexture(o,"aoMap",r.occlusionTexture)),r.occlusionTexture.strength!==void 0)o.aoMapIntensity=r.occlusionTexture.strength}if(r.emissiveFactor!==void 0&&s!==ai){let u=r.emissiveFactor;o.emissive=new Ue().setRGB(u[0],u[1],u[2],gn)}if(r.emissiveTexture!==void 0&&s!==ai)c.push(t.assignTexture(o,"emissiveMap",r.emissiveTexture,ji));return Promise.all(c).then(function(){let u=new s(o);if(r.name)u.name=r.name;if(ui(u,r),t.associations.set(u,{materials:e}),r.extensions)Pr(i,u,r);return u})}createUniqueName(e){let t=tt.sanitizeNodeName(e||"");if(t in this.nodeNamesUsed)return t+"_"+ ++this.nodeNamesUsed[t];else return this.nodeNamesUsed[t]=0,t}loadGeometries(e){let t=this,n=this.extensions,i=this.primitiveCache;function r(o){return n[Xe.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(o,t).then(function(a){return om(a,o,t)})}let s=[];for(let o=0,a=e.length;o<a;o++){let c=e[o],l=_T(c),u=i[l];if(u)s.push(u.promise);else{let f;if(c.extensions&&c.extensions[Xe.KHR_DRACO_MESH_COMPRESSION])f=r(c);else f=om(new en,c,t);if(c.mode===In.TRIANGLE_STRIP)f=f.then((h)=>Vu(h,$s));else if(c.mode===In.TRIANGLE_FAN)f=f.then((h)=>Vu(h,us));i[l]={primitive:c,promise:f},s.push(f)}}return Promise.all(s)}loadMesh(e){let t=this,n=this.json,i=this.extensions,r=n.meshes[e],s=r.primitives,o=[];for(let a=0,c=s.length;a<c;a++){let l=s[a].material===void 0?pT(this.cache):this.getDependency("material",s[a].material);o.push(l)}return o.push(t.loadGeometries(s)),Promise.all(o).then(async function(a){let c=a.slice(0,a.length-1),l=a[a.length-1],u=[];for(let h=0,d=l.length;h<d;h++){let g=l[h],x=s[h],p,m=c[h];if(x.mode===In.TRIANGLES||x.mode===In.TRIANGLE_STRIP||x.mode===In.TRIANGLE_FAN||x.mode===void 0){let E=r.isSkinnedMesh===!0,R=g.hasAttribute("skinIndex")&&g.hasAttribute("skinWeight");if(E&&R===!1)console.warn("THREE.GLTFLoader: Missing skinIndex or skinWeight attributes. Skinning disabled.");if(p=E&&R?new Oa(g,m):new xt(g,m),p.isSkinnedMesh===!0)p.normalizeSkinWeights()}else if(x.mode===In.LINES)p=new Ua(g,m);else if(x.mode===In.LINE_STRIP)p=new Ki(g,m);else if(x.mode===In.LINE_LOOP)p=new Fa(g,m);else if(x.mode===In.POINTS)p=new ps(g,m);else throw Error("THREE.GLTFLoader: Primitive mode unsupported: "+x.mode);if(Object.keys(p.geometry.morphAttributes).length>0)gT(p,r);if(p.name=t.createUniqueName(r.name||"mesh_"+e),ui(p,r),x.extensions)Pr(i,p,x);t.assignFinalMaterial(p),u.push(p)}for(let h=0,d=u.length;h<d;h++)t.associations.set(u[h],{meshes:e,primitives:h});if(u.length===1){if(r.extensions)Pr(i,u[0],r);return u[0]}let f=new ei;if(r.extensions)Pr(i,f,r);t.associations.set(f,{meshes:e});for(let h=0,d=u.length;h<d;h++)f.add(u[h]);return f})}loadCamera(e){let t,n=this.json.cameras[e],i=n[n.type];if(!i){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}if(n.type==="perspective")t=new Ut(Ws.radToDeg(i.yfov),i.aspectRatio||1,i.znear||1,i.zfar||2000000);else if(n.type==="orthographic")t=new Rr(-i.xmag,i.xmag,i.ymag,-i.ymag,i.znear,i.zfar);if(n.name)t.name=this.createUniqueName(n.name);return ui(t,n),Promise.resolve(t)}loadSkin(e){let t=this.json.skins[e],n=[];for(let i=0,r=t.joints.length;i<r;i++)n.push(this._loadNodeShallow(t.joints[i]));if(t.inverseBindMatrices!==void 0)n.push(this.getDependency("accessor",t.inverseBindMatrices));else n.push(null);return Promise.all(n).then(function(i){let r=i.pop(),s=i,o=[],a=[];for(let c=0,l=s.length;c<l;c++){let u=s[c];if(u){o.push(u);let f=new Ge;if(r!==null)f.fromArray(r.array,c*16);a.push(f)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[c])}return new Ks(o,a)})}loadAnimation(e){let t=this.json,n=this,i=t.animations[e],r=i.name?i.name:"animation_"+e,s=[],o=[],a=[],c=[],l=[];for(let u=0,f=i.channels.length;u<f;u++){let h=i.channels[u],d=i.samplers[h.sampler],g=h.target,x=g.node,p=i.parameters!==void 0?i.parameters[d.input]:d.input,m=i.parameters!==void 0?i.parameters[d.output]:d.output;if(g.node===void 0)continue;s.push(this.getDependency("node",x)),o.push(this.getDependency("accessor",p)),a.push(this.getDependency("accessor",m)),c.push(d),l.push(g)}return Promise.all([Promise.all(s),Promise.all(o),Promise.all(a),Promise.all(c),Promise.all(l)]).then(function(u){let f=u[0],h=u[1],d=u[2],g=u[3],x=u[4],p=[];for(let E=0,R=f.length;E<R;E++){let v=f[E],M=h[E],T=d[E],A=g[E],_=x[E];if(v===void 0)continue;if(v.updateMatrix)v.updateMatrix();let S=n._createAnimationTracks(v,M,T,A,_);if(S)for(let k=0;k<S.length;k++)p.push(S[k])}let m=new ns(r,void 0,p);return ui(m,i),m})}createNodeMesh(e){let t=this.json,n=this,i=t.nodes[e];if(i.mesh===void 0)return null;return n.getDependency("mesh",i.mesh).then(function(r){let s=n._getNodeRef(n.meshCache,i.mesh,r);if(i.weights!==void 0)s.traverse(function(o){if(!o.isMesh)return;for(let a=0,c=i.weights.length;a<c;a++)o.morphTargetInfluences[a]=i.weights[a]});return s})}loadNode(e){let t=this.json,n=this,i=t.nodes[e],r=n._loadNodeShallow(e),s=[],o=i.children||[];for(let c=0,l=o.length;c<l;c++)s.push(n.getDependency("node",o[c]));let a=i.skin===void 0?Promise.resolve(null):n.getDependency("skin",i.skin);return Promise.all([r,Promise.all(s),a]).then(function(c){let l=c[0],u=c[1],f=c[2];if(f!==null)l.traverse(function(h){if(!h.isSkinnedMesh)return;h.bind(f,yT)});for(let h=0,d=u.length;h<d;h++)l.add(u[h]);if(l.userData.pivot!==void 0&&u.length>0){let h=l.userData.pivot,d=u[0];l.pivot=new D().fromArray(h),l.position.x-=h[0],l.position.y-=h[1],l.position.z-=h[2],d.position.set(0,0,0),delete l.userData.pivot}return l})}_loadNodeShallow(e){let t=this.json,n=this.extensions,i=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];let r=t.nodes[e],s=r.name?i.createUniqueName(r.name):"",o=[],a=i._invokeOne(function(c){return c.createNodeMesh&&c.createNodeMesh(e)});if(a)o.push(a);if(r.camera!==void 0)o.push(i.getDependency("camera",r.camera).then(function(c){return i._getNodeRef(i.cameraCache,r.camera,c)}));return i._invokeAll(function(c){return c.createNodeAttachment&&c.createNodeAttachment(e)}).forEach(function(c){o.push(c)}),this.nodeCache[e]=Promise.all(o).then(function(c){let l;if(r.isBone===!0)l=new js;else if(c.length>1)l=new ei;else if(c.length===1)l=c[0];else l=new ht;if(l!==c[0])for(let u=0,f=c.length;u<f;u++)l.add(c[u]);if(r.name)l.userData.name=r.name,l.name=s;if(ui(l,r),r.extensions)Pr(n,l,r);if(r.matrix!==void 0){let u=new Ge;u.fromArray(r.matrix),l.applyMatrix4(u)}else{if(r.translation!==void 0)l.position.fromArray(r.translation);if(r.rotation!==void 0)l.quaternion.fromArray(r.rotation);if(r.scale!==void 0)l.scale.fromArray(r.scale)}if(!i.associations.has(l))i.associations.set(l,{});else if(r.mesh!==void 0&&i.meshCache.refs[r.mesh]>1){let u=i.associations.get(l);i.associations.set(l,{...u})}return i.associations.get(l).nodes=e,l}),this.nodeCache[e]}loadScene(e){let t=this.extensions,n=this.json.scenes[e],i=this,r=new ei;if(n.name)r.name=i.createUniqueName(n.name);if(ui(r,n),n.extensions)Pr(t,r,n);let s=n.nodes||[],o=[];for(let a=0,c=s.length;a<c;a++)o.push(i.getDependency("node",s[a]));return Promise.all(o).then(function(a){for(let l=0,u=a.length;l<u;l++){let f=a[l];if(f.parent!==null)r.add(tm(f));else r.add(f)}let c=(l)=>{let u=new Map;for(let[f,h]of i.associations)if(f instanceof hn||f instanceof At)u.set(f,h);return l.traverse((f)=>{let h=i.associations.get(f);if(h!=null)u.set(f,h)}),u};return i.associations=c(r),r})}_createAnimationTracks(e,t,n,i,r){let s=[],o=e.name?e.name:e.uuid,a=[];function c(h){if(h.morphTargetInfluences)a.push(h.name?h.name:h.uuid)}if(rr[r.path]===rr.weights){if(c(e),e.isGroup)e.children.forEach(c)}else a.push(o);let l;switch(rr[r.path]){case rr.weights:l=er;break;case rr.rotation:l=tr;break;case rr.translation:case rr.scale:l=Ar;break;default:switch(n.itemSize){case 1:l=er;break;case 2:case 3:default:l=Ar;break}break}let u=i.interpolation!==void 0?dT[i.interpolation]:Ra,f=this._getArrayFromAccessor(n);for(let h=0,d=a.length;h<d;h++){let g=new l(a[h]+"."+rr[r.path],t.array,f,u);if(i.interpolation==="CUBICSPLINE")this._createCubicSplineTrackInterpolant(g);s.push(g)}return s}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){let n=ju(t.constructor),i=new Float32Array(t.length);for(let r=0,s=t.length;r<s;r++)i[r]=t[r]*n;t=i}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(n){return new(this instanceof tr?Cm:Ku)(this.times,this.values,this.getValueSize()/3,n)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function vT(e,t,n){let i=t.attributes,r=new Ft;if(i.POSITION!==void 0){let a=n.json.accessors[i.POSITION],{min:c,max:l}=a;if(c!==void 0&&l!==void 0){if(r.set(new D(c[0],c[1],c[2]),new D(l[0],l[1],l[2])),a.normalized){let u=ju(bs[a.componentType]);r.min.multiplyScalar(u),r.max.multiplyScalar(u)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;let s=t.targets;if(s!==void 0){let a=new D,c=new D;for(let l=0,u=s.length;l<u;l++){let f=s[l];if(f.POSITION!==void 0){let h=n.json.accessors[f.POSITION],{min:d,max:g}=h;if(d!==void 0&&g!==void 0){if(c.setX(Math.max(Math.abs(d[0]),Math.abs(g[0]))),c.setY(Math.max(Math.abs(d[1]),Math.abs(g[1]))),c.setZ(Math.max(Math.abs(d[2]),Math.abs(g[2]))),h.normalized){let x=ju(bs[h.componentType]);c.multiplyScalar(x)}a.max(c)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}r.expandByVector(a)}e.boundingBox=r;let o=new xn;r.getCenter(o.center),o.radius=r.min.distanceTo(r.max)/2,e.boundingSphere=o}function om(e,t,n){let i=t.attributes,r=[];function s(o,a){return n.getDependency("accessor",o).then(function(c){e.setAttribute(a,c)})}for(let o in i){let a=qu[o]||o.toLowerCase();if(a in e.attributes)continue;r.push(s(i[o],a))}if(t.indices!==void 0&&!e.index){let o=n.getDependency("accessor",t.indices).then(function(a){e.setIndex(a)});r.push(o)}if($e.workingColorSpace!==gn&&"COLOR_0"in i)console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${$e.workingColorSpace}" not supported.`);return ui(e,t),vT(e,t,n),Promise.all(r).then(function(){return t.targets!==void 0?mT(e,t.targets,n):e})}var Im={type:"change"},Qu={type:"start"},Nm={type:"end"},ec=new Yi,Lm=new An,bT=Math.cos(70*Ws.DEG2RAD),Bt=new D,fn=2*Math.PI,lt={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},Ju=0.000001;class eh extends ja{constructor(e,t=null){super(e,t);if(this.state=lt.NONE,this.target=new D,this.cursor=new D,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=0.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.keyRotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:Wi.ROTATE,MIDDLE:Wi.DOLLY,RIGHT:Wi.PAN},this.touches={ONE:Zi.ROTATE,TWO:Zi.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._cursorStyle="auto",this._domElementKeyEvents=null,this._lastPosition=new D,this._lastQuaternion=new Ht,this._lastTargetPosition=new D,this._quat=new Ht().setFromUnitVectors(e.up,new D(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new so,this._sphericalDelta=new so,this._scale=1,this._panOffset=new D,this._rotateStart=new Ne,this._rotateEnd=new Ne,this._rotateDelta=new Ne,this._panStart=new Ne,this._panEnd=new Ne,this._panDelta=new Ne,this._dollyStart=new Ne,this._dollyEnd=new Ne,this._dollyDelta=new Ne,this._dollyDirection=new D,this._mouse=new Ne,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=MT.bind(this),this._onPointerDown=ST.bind(this),this._onPointerUp=wT.bind(this),this._onContextMenu=IT.bind(this),this._onMouseWheel=AT.bind(this),this._onKeyDown=RT.bind(this),this._onTouchStart=CT.bind(this),this._onTouchMove=PT.bind(this),this._onMouseDown=ET.bind(this),this._onMouseMove=TT.bind(this),this._interceptControlDown=LT.bind(this),this._interceptControlUp=NT.bind(this),this.domElement!==null)this.connect(this.domElement);this.update()}set cursorStyle(e){if(this._cursorStyle=e,e==="grab")this.domElement.style.cursor="grab";else this.domElement.style.cursor="auto"}get cursorStyle(){return this._cursorStyle}connect(e){super.connect(e),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.state=lt.NONE,this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents();let e=this.domElement.getRootNode();e.removeEventListener("keydown",this._interceptControlDown,{capture:!0}),e.removeEventListener("keyup",this._interceptControlUp,{capture:!0}),this._controlActive=!1,this._pointers.length=0,this._pointerPositions={},this.domElement.style.touchAction="",this.domElement.style.cursor="auto"}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(e){e.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=e}stopListenToKeyEvents(){if(this._domElementKeyEvents!==null)this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(Im),this.update(),this.state=lt.NONE}pan(e,t){this._pan(e,t),this.update()}dollyIn(e){this._dollyIn(e),this.update()}dollyOut(e){this._dollyOut(e),this.update()}rotateLeft(e){this._rotateLeft(e),this.update()}rotateUp(e){this._rotateUp(e),this.update()}update(e=null){let t=this.object.position;if(Bt.copy(t).sub(this.target),Bt.applyQuaternion(this._quat),this._spherical.setFromVector3(Bt),this.autoRotate&&this.state===lt.NONE)this._rotateLeft(this._getAutoRotationAngle(e));if(this.enableDamping)this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor;else this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi;let n=this.minAzimuthAngle,i=this.maxAzimuthAngle;if(isFinite(n)&&isFinite(i)){if(n<-Math.PI)n+=fn;else if(n>Math.PI)n-=fn;if(i<-Math.PI)i+=fn;else if(i>Math.PI)i-=fn;if(n<=i)this._spherical.theta=Math.max(n,Math.min(i,this._spherical.theta));else this._spherical.theta=this._spherical.theta>(n+i)/2?Math.max(n,this._spherical.theta):Math.min(i,this._spherical.theta)}if(this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0)this.target.addScaledVector(this._panOffset,this.dampingFactor);else this.target.add(this._panOffset);this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let r=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{let s=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),r=s!=this._spherical.radius}if(Bt.setFromSpherical(this._spherical),Bt.applyQuaternion(this._quatInverse),t.copy(this.target).add(Bt),this.object.lookAt(this.target),this.enableDamping===!0)this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor);else this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0);if(this.zoomToCursor&&this._performCursorZoom){let s=null;if(this.object.isPerspectiveCamera){let o=Bt.length();s=this._clampDistance(o*this._scale);let a=o-s;this.object.position.addScaledVector(this._dollyDirection,a),this.object.updateMatrixWorld(),r=!!a}else if(this.object.isOrthographicCamera){let o=new D(this._mouse.x,this._mouse.y,0);o.unproject(this.object);let a=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),r=a!==this.object.zoom;let c=new D(this._mouse.x,this._mouse.y,0);c.unproject(this.object),this.object.position.sub(c).add(o),this.object.updateMatrixWorld(),s=Bt.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;if(s!==null)if(this.screenSpacePanning)this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(s).add(this.object.position);else if(ec.origin.copy(this.object.position),ec.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(ec.direction))<bT)this.object.lookAt(this.target);else Lm.setFromNormalAndCoplanarPoint(this.object.up,this.target),ec.intersectPlane(Lm,this.target)}else if(this.object.isOrthographicCamera){let s=this.object.zoom;if(this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),s!==this.object.zoom)this.object.updateProjectionMatrix(),r=!0}if(this._scale=1,this._performCursorZoom=!1,r||this._lastPosition.distanceToSquared(this.object.position)>Ju||8*(1-this._lastQuaternion.dot(this.object.quaternion))>Ju||this._lastTargetPosition.distanceToSquared(this.target)>Ju)return this.dispatchEvent(Im),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0;return!1}_getAutoRotationAngle(e){if(e!==null)return fn/60*this.autoRotateSpeed*e;else return fn/60/60*this.autoRotateSpeed}_getZoomScale(e){let t=Math.abs(e*0.01);return Math.pow(0.95,this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){Bt.setFromMatrixColumn(t,0),Bt.multiplyScalar(-e),this._panOffset.add(Bt)}_panUp(e,t){if(this.screenSpacePanning===!0)Bt.setFromMatrixColumn(t,1);else Bt.setFromMatrixColumn(t,0),Bt.crossVectors(this.object.up,Bt);Bt.multiplyScalar(e),this._panOffset.add(Bt)}_pan(e,t){let n=this.domElement;if(this.object.isPerspectiveCamera){let i=this.object.position;Bt.copy(i).sub(this.target);let r=Bt.length();r*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*r/n.clientHeight,this.object.matrix),this._panUp(2*t*r/n.clientHeight,this.object.matrix)}else if(this.object.isOrthographicCamera)this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/n.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/n.clientHeight,this.object.matrix);else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1}_dollyOut(e){if(this.object.isPerspectiveCamera||this.object.isOrthographicCamera)this._scale/=e;else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1}_dollyIn(e){if(this.object.isPerspectiveCamera||this.object.isOrthographicCamera)this._scale*=e;else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;let n=this.domElement.getBoundingClientRect(),i=e-n.left,r=t-n.top,{width:s,height:o}=n;this._mouse.x=i/s*2-1,this._mouse.y=-(r/o)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);let t=this.domElement;this._rotateLeft(fn*this._rotateDelta.x/t.clientHeight),this._rotateUp(fn*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){if(this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0)this._dollyOut(this._getZoomScale(this._dollyDelta.y));else if(this._dollyDelta.y<0)this._dollyIn(this._getZoomScale(this._dollyDelta.y));this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){if(this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0)this._dollyIn(this._getZoomScale(e.deltaY));else if(e.deltaY>0)this._dollyOut(this._getZoomScale(e.deltaY));this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enableRotate)this._rotateUp(fn*this.keyRotateSpeed/this.domElement.clientHeight)}else if(this.enablePan)this._pan(0,this.keyPanSpeed);t=!0;break;case this.keys.BOTTOM:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enableRotate)this._rotateUp(-fn*this.keyRotateSpeed/this.domElement.clientHeight)}else if(this.enablePan)this._pan(0,-this.keyPanSpeed);t=!0;break;case this.keys.LEFT:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enableRotate)this._rotateLeft(fn*this.keyRotateSpeed/this.domElement.clientHeight)}else if(this.enablePan)this._pan(this.keyPanSpeed,0);t=!0;break;case this.keys.RIGHT:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enableRotate)this._rotateLeft(-fn*this.keyRotateSpeed/this.domElement.clientHeight)}else if(this.enablePan)this._pan(-this.keyPanSpeed,0);t=!0;break}if(t)e.preventDefault(),this.update()}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=0.5*(e.pageX+t.x),i=0.5*(e.pageY+t.y);this._rotateStart.set(n,i)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=0.5*(e.pageX+t.x),i=0.5*(e.pageY+t.y);this._panStart.set(n,i)}}_handleTouchStartDolly(e){let t=this._getSecondPointerPosition(e),n=e.pageX-t.x,i=e.pageY-t.y,r=Math.sqrt(n*n+i*i);this._dollyStart.set(0,r)}_handleTouchStartDollyPan(e){if(this.enableZoom)this._handleTouchStartDolly(e);if(this.enablePan)this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){if(this.enableZoom)this._handleTouchStartDolly(e);if(this.enableRotate)this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{let n=this._getSecondPointerPosition(e),i=0.5*(e.pageX+n.x),r=0.5*(e.pageY+n.y);this._rotateEnd.set(i,r)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);let t=this.domElement;this._rotateLeft(fn*this._rotateDelta.x/t.clientHeight),this._rotateUp(fn*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=0.5*(e.pageX+t.x),i=0.5*(e.pageY+t.y);this._panEnd.set(n,i)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){let t=this._getSecondPointerPosition(e),n=e.pageX-t.x,i=e.pageY-t.y,r=Math.sqrt(n*n+i*i);this._dollyEnd.set(0,r),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);let s=(e.pageX+t.x)*0.5,o=(e.pageY+t.y)*0.5;this._updateZoomParameters(s,o)}_handleTouchMoveDollyPan(e){if(this.enableZoom)this._handleTouchMoveDolly(e);if(this.enablePan)this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){if(this.enableZoom)this._handleTouchMoveDolly(e);if(this.enableRotate)this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId){this._pointers.splice(t,1);return}}_isTrackingPointer(e){for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId)return!0;return!1}_trackPointer(e){let t=this._pointerPositions[e.pointerId];if(t===void 0)t=new Ne,this._pointerPositions[e.pointerId]=t;t.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){let t=e.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[t]}_customWheelEvent(e){let t=e.deltaMode,n={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(t){case 1:n.deltaY*=16;break;case 2:n.deltaY*=100;break}if(e.ctrlKey&&!this._controlActive)n.deltaY*=10;return n}}function ST(e){if(this.enabled===!1)return;if(this._pointers.length===0)this.domElement.setPointerCapture(e.pointerId),this.domElement.ownerDocument.addEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this._onPointerUp);if(this._isTrackingPointer(e))return;if(this._addPointer(e),e.pointerType==="touch")this._onTouchStart(e);else this._onMouseDown(e);if(this._cursorStyle==="grab")this.domElement.style.cursor="grabbing"}function MT(e){if(this.enabled===!1)return;if(e.pointerType==="touch")this._onTouchMove(e);else this._onMouseMove(e)}function wT(e){switch(this._removePointer(e),this._pointers.length){case 0:if(this.domElement.releasePointerCapture(e.pointerId),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(Nm),this.state=lt.NONE,this._cursorStyle==="grab")this.domElement.style.cursor="grab";break;case 1:let t=this._pointers[0],n=this._pointerPositions[t];this._onTouchStart({pointerId:t,pageX:n.x,pageY:n.y});break}}function ET(e){let t;switch(e.button){case 0:t=this.mouseButtons.LEFT;break;case 1:t=this.mouseButtons.MIDDLE;break;case 2:t=this.mouseButtons.RIGHT;break;default:t=-1}switch(t){case Wi.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(e),this.state=lt.DOLLY;break;case Wi.ROTATE:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(e),this.state=lt.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(e),this.state=lt.ROTATE}break;case Wi.PAN:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(e),this.state=lt.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(e),this.state=lt.PAN}break;default:this.state=lt.NONE}if(this.state!==lt.NONE)this.dispatchEvent(Qu)}function TT(e){switch(this.state){case lt.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(e);break;case lt.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(e);break;case lt.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(e);break}}function AT(e){if(this.enabled===!1||this.enableZoom===!1||this.state!==lt.NONE)return;e.preventDefault(),this.dispatchEvent(Qu),this._handleMouseWheel(this._customWheelEvent(e)),this.dispatchEvent(Nm)}function RT(e){if(this.enabled===!1)return;this._handleKeyDown(e)}function CT(e){switch(this._trackPointer(e),this._pointers.length){case 1:switch(this.touches.ONE){case Zi.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(e),this.state=lt.TOUCH_ROTATE;break;case Zi.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(e),this.state=lt.TOUCH_PAN;break;default:this.state=lt.NONE}break;case 2:switch(this.touches.TWO){case Zi.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(e),this.state=lt.TOUCH_DOLLY_PAN;break;case Zi.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(e),this.state=lt.TOUCH_DOLLY_ROTATE;break;default:this.state=lt.NONE}break;default:this.state=lt.NONE}if(this.state!==lt.NONE)this.dispatchEvent(Qu)}function PT(e){switch(this._trackPointer(e),this.state){case lt.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(e),this.update();break;case lt.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(e),this.update();break;case lt.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(e),this.update();break;case lt.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(e),this.update();break;default:this.state=lt.NONE}}function IT(e){if(this.enabled===!1)return;e.preventDefault()}function LT(e){if(e.key==="Control")this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0})}function NT(e){if(e.key==="Control")this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0})}class th extends hs{constructor(){super();this.name="RoomEnvironment",this.position.y=-3.5;let e=new Ji;e.deleteAttribute("uv");let t=new Ri({side:Qt}),n=new Ri,i=new gs(16777215,900,28,2);i.position.set(0.418,16.199,0.3),this.add(i);let r=new xt(e,t);r.position.set(-0.757,13.219,0.717),r.scale.set(31.713,28.305,28.591),this.add(r);let s=new ds(e,n,6),o=new ht;o.position.set(-10.906,2.009,1.846),o.rotation.set(0,-0.195,0),o.scale.set(2.328,7.905,4.651),o.updateMatrix(),s.setMatrixAt(0,o.matrix),o.position.set(-5.607,-0.754,-0.758),o.rotation.set(0,0.994,0),o.scale.set(1.97,1.534,3.955),o.updateMatrix(),s.setMatrixAt(1,o.matrix),o.position.set(6.167,0.857,7.803),o.rotation.set(0,0.561,0),o.scale.set(3.927,6.285,3.687),o.updateMatrix(),s.setMatrixAt(2,o.matrix),o.position.set(-2.017,0.018,6.124),o.rotation.set(0,0.333,0),o.scale.set(2.002,4.566,2.064),o.updateMatrix(),s.setMatrixAt(3,o.matrix),o.position.set(2.291,-0.756,-2.621),o.rotation.set(0,-0.286,0),o.scale.set(1.546,1.552,1.496),o.updateMatrix(),s.setMatrixAt(4,o.matrix),o.position.set(-2.193,-0.369,-5.547),o.rotation.set(0,0.516,0),o.scale.set(3.875,3.487,2.986),o.updateMatrix(),s.setMatrixAt(5,o.matrix),this.add(s);let a=new xt(e,Ss(50));a.position.set(-16.116,14.37,8.208),a.scale.set(0.1,2.428,2.739),this.add(a);let c=new xt(e,Ss(50));c.position.set(-16.109,18.021,-8.207),c.scale.set(0.1,2.425,2.751),this.add(c);let l=new xt(e,Ss(17));l.position.set(14.904,12.198,-1.832),l.scale.set(0.15,4.265,6.331),this.add(l);let u=new xt(e,Ss(43));u.position.set(-0.462,8.89,14.52),u.scale.set(4.38,5.441,0.088),this.add(u);let f=new xt(e,Ss(20));f.position.set(3.235,11.486,-12.541),f.scale.set(2.5,2,0.1),this.add(f);let h=new xt(e,Ss(100));h.position.set(0,20,0),h.scale.set(1,0.1,1),this.add(h)}dispose(){let e=new Set;this.traverse((t)=>{if(t.isMesh)e.add(t.geometry),e.add(t.material)});for(let t of e)t.dispose()}}function Ss(e){return new Ba({color:0,emissive:16777215,emissiveIntensity:e})}function po(e){let t=Object.values(e).filter((i)=>typeof i==="number");return Object.entries(e).filter(([i,r])=>t.indexOf(+i)===-1).map(([i,r])=>r)}function ih(e,t="|"){return e.map((n)=>oh(n)).join(t)}function mo(e,t){if(typeof t==="bigint")return t.toString();return t}class Dm{constructor(e){this._getter=e,this._value=void 0}get value(){let e=this._getter;if(e!==void 0)this._value=e(),this._getter=void 0;return this._value}}function go(e){return new Dm(e)}function Om(e){return e===null||e===void 0}function tc(e){let t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function Um(e,t){let n=e/t,i=Math.round(n),r=4*Number.EPSILON*Math.max(Math.abs(n),1);if(Math.abs(n-i)<r)return 0;return n-i}function Ln(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function _o(e){let t=Object.getOwnPropertyDescriptor(e,"shape");return t?.get?t.get.raw:t?.value}function Ii(e){return _o(e._zod.def)??e._zod.def.shape}function Fm(e,t,n){Object.defineProperty(e,t,{get(){let i=n();return Ln(this,t,i),i},enumerable:!0,configurable:!0})}function zm(e,t,n){if(t in e)Ln(e,t,n);else e[t]=n}function Ir(e,t,n,i){let r=Ii(t);for(let s of n){let o=Object.getOwnPropertyDescriptor(r,s);if(!o.enumerable)continue;if(o.get)Fm(e,s,()=>{let a=t._zod.def.shape[s];return i?i(a,s):a});else zm(e,s,i?i(o.value,s):o.value)}}function DT(e,t){for(let n of Reflect.ownKeys(t)){let i=Object.getOwnPropertyDescriptor(t,n);if(!i.enumerable)continue;if(i.get)Fm(e,n,()=>t[n]);else zm(e,n,i.value)}}function bn(...e){let t={};for(let n of e){let i=Object.getOwnPropertyDescriptors(n);Object.assign(t,i)}return Object.defineProperties({},t)}function km(e){return JSON.stringify(e)}function Bm(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var rh="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Ms(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}var Gm=go(()=>{if(dn.jitless)return!1;if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}});function Lr(e){if(Ms(e)===!1)return!1;let t=e.constructor;if(t===void 0)return!0;if(typeof t!=="function")return!0;let n=t.prototype;if(Ms(n)===!1)return!1;if(Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)return!1;return!0}function sh(e){if(Lr(e))return{...e};if(Array.isArray(e))return[...e];if(e instanceof Map)return new Map(e);if(e instanceof Set)return new Set(e);return e}var Hm=new Set(["string","number","symbol"]);function or(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function hi(e,t,n){let i=new e._zod.constr(t??e._zod.def);if(!t||n?.parent)i._zod.parent=e;return i}function Re(e){let t=e;if(!t)return{};if(typeof t==="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}if(delete t.message,typeof t.error==="string")return{...t,error:()=>t.error};return t}function oh(e){if(typeof e==="bigint")return e.toString()+"n";if(typeof e==="string")return`"${e}"`;return`${e}`}function Vm(e){return Object.keys(e).filter((t)=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}var nc=(()=>({safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-340282346638528860000000000000000000000,340282346638528860000000000000000000000],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]}))(),ah={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function OT(e,t){let n=e._zod.def,i=n.checks;if(i&&i.length>0)throw Error(".pick() cannot be used on object schemas containing refinements");let s={};return Ir(s,e,ic(e,t)),hi(e,bn(n,{shape:s,checks:[]}))}function ic(e,t){let n=Ii(e),i=[];for(let r of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(n,r)?.enumerable)throw Error(`Unrecognized key: "${String(r)}"`);if(t[r])i.push(r)}return i}function UT(e,t){let n=e._zod.def,i=n.checks;if(i&&i.length>0)throw Error(".omit() cannot be used on object schemas containing refinements");let s=new Set(ic(e,t)),o={};return Ir(o,e,Reflect.ownKeys(Ii(e)).filter((a)=>!s.has(a))),hi(e,bn(n,{shape:o,checks:[]}))}function FT(e,t){if(!Lr(t))throw Error("Invalid input to extend: expected a plain object");let n=e._zod.def.checks;if(n&&n.length>0){let r=Ii(e);for(let s of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(r,s)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return hi(e,bn(e._zod.def,{shape:$m(e,t)}))}function $m(e,t){let n={};return Ir(n,e,Reflect.ownKeys(Ii(e))),DT(n,t),n}function zT(e,t){if(!Lr(t))throw Error("Invalid input to safeExtend: expected a plain object");return hi(e,bn(e._zod.def,{shape:$m(e,t)}))}function kT(e,t){if(!t?._zod?.def)throw Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let n={};Ir(n,e,Reflect.ownKeys(Ii(e))),Ir(n,t,Reflect.ownKeys(Ii(t)));let i=bn(e._zod.def,{shape:n,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return hi(e,i)}function Wm(e,t,n,i="partial"){let s=t._zod.def.checks;if(s&&s.length>0)throw Error(`.${i}() cannot be used on object schemas containing refinements`);let a=n?new Set(ic(t,n)):void 0,c={};return Ir(c,t,Reflect.ownKeys(Ii(t)),e&&((l,u)=>a&&!a.has(u)?l:new e({type:"optional",innerType:l}))),hi(t,bn(t._zod.def,{shape:c,checks:[]}))}function BT(e,t,n){let i=n?new Set(ic(t,n)):void 0,r={};return Ir(r,t,Reflect.ownKeys(Ii(t)),(s,o)=>i&&!i.has(o)?s:new e({type:"nonoptional",innerType:s})),hi(t,bn(t._zod.def,{shape:r}))}function fi(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function Zm(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function ar(e,t){return t.map((n)=>{var i;return(i=n).path??(i.path=[]),n.path.unshift(e),n})}function fo(e){return typeof e==="string"?e:e?.message}function ch(e,t,n){var i;for(let r=t;r<e.length;r++)(i=e[r]).schema??(i.schema=n)}function di(e,t,n){var i;let r=e.inst?._zod?.traits;if(r?.has("$ZodType"))if(r.has("$ZodCheck"))(i=e).schema??(i.schema=e.inst);else e.schema=e.inst;let s=e.schema!==e.inst?e.schema?._zod.def?.error:void 0,o=e.message?e.message:fo(e.inst?._zod.def?.error?.(e))??fo(s?.(e))??fo(t?.error?.(e))??fo(n.customError?.(e))??fo(n.localeError?.(e))??"Invalid input",a={};for(let c of Object.keys(e)){if(c==="inst"||c==="schema"||c==="continue"||c==="input"||c==="__proto__")continue;a[c]=e[c]}if(a.path??(a.path=[]),a.message=o,t?.reportInput)a.input=e.input;return a}var GT=/[\uD800-\uDBFF]/;function rc(e){let t=e.length;if(!GT.test(e))return t;let n=t;for(let i=0;i<t-1;i++)if((e.charCodeAt(i)&64512)===55296&&(e.charCodeAt(i+1)&64512)===56320)n--,i++;return n}function sc(e){if(Array.isArray(e))return"array";if(typeof e==="string")return"string";return"unknown"}function Xm(e){let t=typeof e;switch(t){case"number":return Number.isNaN(e)?"nan":"number";case"object":{if(e===null)return"null";if(Array.isArray(e))return"array";let n=e;if(n&&Object.getPrototypeOf(n)!==Object.prototype&&"constructor"in n&&n.constructor)return n.constructor.name}}return t}function Nr(...e){let[t,n,i]=e;if(typeof t==="string")return{message:t,code:"custom",input:n,inst:i};return{...t}}function qm(e,t){for(let n in t){let i=Object.getOwnPropertyDescriptor(t,n);if(i.get)Object.defineProperty(e,n,{...i,enumerable:!1});else HT(e,n,i.value)}}function Li(e,t,n,i=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:i,value:n}),n}function oc(e,t,n){return Li(e,t,n,!1)}function jm(e,t){for(let n in e){let i=e[n];Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get(){return Li(this,n,i(this))},set(r){Li(this,n,r)}})}return t}function HT(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:Li(this,t,n.bind(this))},set(i){Li(this,t,i)}})}function VT(e,t){let n=Object.getPrototypeOf(e);return t in n?void 0:n}var nh,sr=!1,$T={configurable:!0,get(){sr=!0;return}};function nt(e,t,n){let i=Object.getPrototypeOf(e._zod);if(t in i&&nh!==e._zod){nh=void 0;return}nh=e._zod,Object.defineProperty(i,t,{configurable:!0,get(){Object.defineProperty(this,t,$T);let r=sr;sr=!1;try{let s=n(this);if(sr)delete this[t];else Object.defineProperty(this,t,{configurable:!0,writable:!0,value:s});return sr=sr||r,s}catch(s){throw delete this[t],sr=sr||r,s}},set(r){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:r})}})}function WT(e,t,n,i){let r=VT(e,t);if(!r)return;Object.defineProperty(r,t,{configurable:!0,get(){let s={configurable:!0,writable:!0,enumerable:i,value:void 0};return Object.defineProperty(this,t,s),s.value=n(this),Object.defineProperty(this,t,s),s.value},set(s){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:i,value:s})}})}var ZT="~constantCatch";function Ym(e){let t=()=>e;return t[ZT]=!0,t}var Km;var lh={value:void 0,enumerable:!1},Jm="captureStackTrace"in Error?Error:null;function XT(e){let t=Jm;if(t){let n=t.stackTraceLimit;if(typeof n==="number"){try{t.stackTraceLimit=0}catch{return Jm=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function Q(e,t,n,i){let r={};function s(h){this.def=h,this.constr=f,this.traits=new Set}s.prototype=r;let o=n,a=o&&new WeakSet;function c(h,d){if(!h._zod){lh.value=new s(d);try{Object.defineProperty(h,"_zod",lh)}finally{lh.value=void 0}}else if(h._zod.traits.has(e))return;if(h._zod.traits.add(e),t(h,d),a){let x=Object.getPrototypeOf(h),p=h._zod.constr.prototype,m=x;while(m&&m!==p)m=Object.getPrototypeOf(m);let E=m??x;if(!a.has(E))a.add(E),qm(E,o)}let g=f.prototype;for(let x in g){if(!Object.prototype.hasOwnProperty.call(g,x))continue;if(!(x in h))h[x]=g[x].bind(h)}}let l=i?.Parent??Object;class u extends l{}Object.defineProperty(u,"name",{value:e});function f(h){let d=i?.Parent?XT(u):this;c(d,h);let g=d._zod.deferred;if(g){for(let p of g)p();d._zod.deferred=void 0}let x=globalThis.__zod_globalConfig?.postProcessor;if(x)x(d);return d}return Object.defineProperty(f,"init",{value:c}),Object.defineProperty(f,Symbol.hasInstance,{value:(h)=>{if(i?.Parent&&h instanceof i.Parent)return!0;return h?._zod?.traits?.has(e)}}),Object.defineProperty(f,"name",{value:e}),f}class pi extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class xo extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`);this.name="ZodEncodeError"}}(Km=globalThis).__zod_globalConfig??(Km.__zod_globalConfig={});var dn=globalThis.__zod_globalConfig;function Sn(e){if(e)Object.assign(dn,e);return dn}function qT(){let e=this._zod;return e.message??(e.message=JSON.stringify(e.def,mo,2)),e.message}function jT(e){this._zod.message=e}var YT={get:qT,set:jT,enumerable:!0,configurable:!0},hh={value:void 0,enumerable:!1},Qm=new WeakSet([Object.prototype,Error.prototype]),eg=(e,t)=>{e.name="$ZodError",hh.value=t,Object.defineProperty(e,"issues",hh),hh.value=void 0,Object.defineProperty(e,"message",YT);let n=Object.getPrototypeOf(e);if(!Qm.has(n))Qm.add(n),Object.defineProperty(n,"toString",{configurable:!0,enumerable:!1,get(){let i=()=>this.message;return Object.defineProperty(this,"toString",{value:i,configurable:!0,writable:!0}),i},set(i){Object.defineProperty(this,"toString",{value:i,configurable:!0,writable:!0})}})},tg=Q("$ZodError",eg),XI=Q("$ZodError",eg,void 0,{Parent:Error});function KT(e,t,n){if(!Object.prototype.hasOwnProperty.call(e,t))if(t==="__proto__")Object.defineProperty(e,t,{value:n(),writable:!0,enumerable:!0,configurable:!0});else e[t]=n();return e[t]}function ng(e,t=(n)=>n.message){let n={},i=[];for(let r of e.issues)if(r.path.length>0)KT(n,r.path[0],()=>[]).push(t(r));else i.push(t(r));return{formErrors:i,fieldErrors:n}}function ig(e,t=(n)=>n.message){let n={_errors:[]},i=(r,s=[])=>{for(let o of r.issues)if(o.code==="invalid_union"&&o.errors.length)o.errors.map((a)=>i({issues:a},[...s,...o.path]));else if(o.code==="invalid_key")i({issues:o.issues},[...s,...o.path]);else if(o.code==="invalid_element")i({issues:o.issues},[...s,...o.path]);else{let a=[...s,...o.path];if(a.length===0)n._errors.push(t(o));else{let c=n,l=0;while(l<a.length){let u=a[l],f=l===a.length-1;if(u==="_errors"){if(f)c._errors.push(t(o));l++;continue}if(!Object.prototype.hasOwnProperty.call(c,u))Object.defineProperty(c,u,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let h=c[u];if(f)h._errors.push(t(o));c=h,l++}}}};return i(e),n}function ac(e,t){return{callee:t?.callee??e,Err:t?.Err}}var cc=(e)=>{let t=(n,i,r,s)=>{let o=r?{...r,async:!1}:{async:!1},a=n._zod.run({value:i,issues:[]},o);if(a instanceof Promise)throw new pi;if(a.issues.length){let c=new(s?.Err??e)(a.issues.map((l)=>di(l,o,Sn())));throw rh(c,s?.callee??t),c}return a.value};return t};var lc=(e)=>{let t=async(n,i,r,s)=>{let o=r?{...r,async:!0}:{async:!0},a=n._zod.run({value:i,issues:[]},o);if(a instanceof Promise)a=await a;if(a.issues.length){let c=new(s?.Err??e)(a.issues.map((l)=>di(l,o,Sn())));throw rh(c,s?.callee??t),c}return a.value};return t};var uc=(e)=>(t,n,i)=>{let r=i?{...i,async:!1}:{async:!1},s=t._zod.run({value:n,issues:[]},r);if(s instanceof Promise)throw new pi;return s.issues.length?rg(e,s.issues,r):{success:!0,data:s.value}};function rg(e,t,n){let i;return{success:!1,get error(){if(!i)i=new e(t.map((r)=>di(r,n,Sn()))),t=void 0,n=void 0;return i},set error(r){i=r,t=void 0,n=void 0}}}var hc=(e)=>async(t,n,i)=>{let r=i?{...i,async:!0}:{async:!0},s=t._zod.run({value:n,issues:[]},r);if(s instanceof Promise)s=await s;return s.issues.length?rg(e,s.issues,r):{success:!0,data:s.value}};var JT=Symbol.for("zod.compile.invalid"),QT=Symbol.for("zod.compile.fallback"),fh=(e,t,n)=>{let i=e._zod.bag.validator;if(i!==void 0){if(i(t)!==JT)return!0;if(i.definite===!0&&n===void 0)return!1}return eA(e,t,n)};function eA(e,t,n){let i=n?{...n,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},r=e._zod.bag.fallbackRun,s;if(r)i[QT]=!0,s=r({value:t,issues:[]},i);else s=e._zod.run({value:t,issues:[]},i);if(s instanceof Promise)throw new pi;return s.issues.length===0}var dh=async(e,t,n)=>{let i=n?{...n,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},r=e._zod.run({value:t,issues:[]},i);if(r instanceof Promise)r=await r;return r.issues.length===0},sg=(e)=>{let t=cc(e),n=(i,r,s,o)=>{let a=s?{...s,direction:"backward"}:{direction:"backward"};return t(i,r,a,ac(n,o))};return n};var og=(e)=>{let t=cc(e),n=(i,r,s,o)=>t(i,r,s,ac(n,o));return n};var ag=(e)=>{let t=lc(e),n=async(i,r,s,o)=>{let a=s?{...s,direction:"backward"}:{direction:"backward"};return await t(i,r,a,ac(n,o))};return n};var cg=(e)=>{let t=lc(e),n=async(i,r,s,o)=>await t(i,r,s,ac(n,o));return n};var lg=(e)=>(t,n,i)=>{let r=i?{...i,direction:"backward"}:{direction:"backward"};return uc(e)(t,n,r)};var ug=(e)=>(t,n,i)=>uc(e)(t,n,i);var hg=(e)=>async(t,n,i)=>{let r=i?{...i,direction:"backward"}:{direction:"backward"};return hc(e)(t,n,r)};var fg=(e)=>async(t,n,i)=>hc(e)(t,n,i);var dg=/^[cC][0-9a-z]{6,}$/,pg=/^[0-9a-z]+$/,mg=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,gg=/^[0-9a-vA-V]{20}$/,_g=/^[A-Za-z0-9]{27}$/,xg=/^[a-zA-Z0-9_-]{21}$/;function yg(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}var vg=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var bg=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,mh=(e)=>{if(!e)return/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`)};var Sg=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var tA="^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function Mg(){return new RegExp(tA,"u")}var wg=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Eg=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/;var Tg=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,Ag=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Rg=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Cg=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/;var Pg=/^https?$/,Ig=/^\+[1-9]\d{6,14}$/;var Lg="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))";function nA(e){return new RegExp(`^${e}$`)}var Ng=nA(Lg);function ph(e){return typeof e.precision==="number"?e.precision===-1?"(?:[01]\\d|2[0-3]):[0-5]\\d":e.precision===0?"(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d":`(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?"(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?":"(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?"}function Dg(e){return new RegExp(`^${ph(e)}$`)}function Og(e){let t=["Z"];if(e.offset)t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let n=`${ph({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,i=e.local?`${n}|${ph({precision:e.precision})}`:n;return new RegExp(`^${Lg}T(?:${i})$`)}var Ug=/^[\s\S]{0,}$/;var gh=/^-?\d+$/,yo=/^-?\d+(?:\.\d+)?$/,Fg=/^(?:true|false)$/i;var zg=/^[^A-Z]*$/,kg=/^[^a-z]*$/;var Xt=Q("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])});var _h=(e)=>{let t=e.value;return!Om(t)&&t.length!==void 0},fc={number:"number",bigint:"bigint",object:"date"},xh=Q("$ZodCheckLessThan",(e,t)=>{Xt.init(e,t);let n=fc[typeof t.value];e._zod.check=(i)=>{if(t.inclusive?i.value<=t.value:i.value<t.value)return;i.issues.push({origin:fc[typeof i.value]??n,code:"too_big",maximum:typeof t.value==="object"?t.value.getTime():t.value,input:i.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),yh=Q("$ZodCheckGreaterThan",(e,t)=>{Xt.init(e,t);let n=fc[typeof t.value];e._zod.check=(i)=>{if(t.inclusive?i.value>=t.value:i.value>t.value)return;i.issues.push({origin:fc[typeof i.value]??n,code:"too_small",minimum:typeof t.value==="object"?t.value.getTime():t.value,input:i.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Bg=Q("$ZodCheckMultipleOf",(e,t)=>{Xt.init(e,t),e._zod.check=(n)=>{if(typeof n.value!==typeof t.value)throw Error("Cannot mix number and bigint in multiple_of check.");if(typeof n.value==="bigint"?t.value!==BigInt(0)&&n.value%t.value===BigInt(0):Um(n.value,t.value)===0)return;n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),Gg=Q("$ZodCheckNumberFormat",(e,t)=>{Xt.init(e,t),t.format=t.format||"float64";let n=t.format?.includes("int"),i=n?"int":"number",[r,s]=nc[t.format];e._zod.check=(o)=>{let a=o.value;if(n){if(!Number.isInteger(a)){o.issues.push({expected:i,format:t.format,code:"invalid_type",continue:!1,input:a,inst:e});return}if(!Number.isSafeInteger(a)){if(a>0)o.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:i,inclusive:!0,continue:!t.abort});else o.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:i,inclusive:!0,continue:!t.abort});return}}if(a<r)o.issues.push({origin:"number",input:a,code:"too_small",minimum:r,inclusive:!0,inst:e,continue:!t.abort});if(a>s)o.issues.push({origin:"number",input:a,code:"too_big",maximum:s,inclusive:!0,inst:e,continue:!t.abort})}});var Hg=Q("$ZodCheckMaxLength",(e,t)=>{var n;Xt.init(e,t),(n=e._zod.def).when??(n.when=_h),e._zod.check=(i)=>{let r=i.value,s=r.length;if((typeof r==="string"&&s>t.maximum?rc(r):s)<=t.maximum)return;let a=sc(r);i.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Vg=Q("$ZodCheckMinLength",(e,t)=>{var n;Xt.init(e,t),(n=e._zod.def).when??(n.when=_h),e._zod.check=(i)=>{let r=i.value,s=r.length;if((typeof r==="string"&&s>=t.minimum&&s<t.minimum*2?rc(r):s)>=t.minimum)return;let a=sc(r);i.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),$g=Q("$ZodCheckLengthEquals",(e,t)=>{var n;Xt.init(e,t),(n=e._zod.def).when??(n.when=_h),e._zod.check=(i)=>{let r=i.value,s=r.length,o=typeof r==="string"&&s>=t.length&&s<=t.length*2?rc(r):s;if(o===t.length)return;let a=sc(r),c=o>t.length;i.issues.push({origin:a,...c?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:i.value,inst:e,continue:!t.abort})}}),bo=Q("$ZodCheckStringFormat",(e,t)=>{var n,i;if(Xt.init(e,t),t.pattern)(n=e._zod).check??(n.check=(r)=>{if(t.pattern.lastIndex=0,t.pattern.test(r.value))return;r.issues.push({origin:"string",code:"invalid_format",format:t.format,input:r.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})});else(i=e._zod).check??(i.check=()=>{})}),Wg=Q("$ZodCheckRegex",(e,t)=>{bo.init(e,t),e._zod.check=(n)=>{if(t.pattern.lastIndex=0,t.pattern.test(n.value))return;n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Zg=Q("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=zg),bo.init(e,t)}),Xg=Q("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=kg),bo.init(e,t)}),qg=Q("$ZodCheckIncludes",(e,t)=>{Xt.init(e,t);let n=or(t.includes),i=new RegExp(typeof t.position==="number"?`^.{${t.position},}${n}`:n);t.pattern=i,e._zod.check=(r)=>{if(r.value.includes(t.includes,t.position))return;r.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:r.value,inst:e,continue:!t.abort})}}),jg=Q("$ZodCheckStartsWith",(e,t)=>{Xt.init(e,t);let n=new RegExp(`^${or(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.check=(i)=>{if(i.value.startsWith(t.prefix))return;i.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:i.value,inst:e,continue:!t.abort})}}),Yg=Q("$ZodCheckEndsWith",(e,t)=>{Xt.init(e,t);let n=new RegExp(`.*${or(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.check=(i)=>{if(i.value.endsWith(t.suffix))return;i.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:i.value,inst:e,continue:!t.abort})}});var Kg=Q("$ZodCheckOverwrite",(e,t)=>{Xt.init(e,t),e._zod.check=(n)=>{n.value=t.tx(n.value)}});class vh{constructor(e=[],t={}){this.content=[],this.indent=0,this.args=e,this.closed=t}indented(e){this.indent+=1;try{e(this)}finally{this.indent-=1}}write(e){if(typeof e==="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}let n=e.split(`
4344
+ }`;class Jp{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){let n=new Ga(e.texture);if(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)this.depthNear=e.depthNear,this.depthFar=e.depthFar;this.texture=n}}getMesh(e){if(this.texture!==null){if(this.mesh===null){let t=e.cameras[0].viewport,n=new In({vertexShader:oT,fragmentShader:aT,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new _t(new so(20,20),n)}}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class Qp extends Wn{constructor(e,t){super();let n=this,i=null,r=1,s=null,o="local-floor",a=1,c=null,l=null,u=null,f=null,h=null,d=null,g=typeof XRWebGLBinding<"u",x=new Jp,p={},m=t.getContextAttributes(),E=null,R=null,v=[],M=[],T=new Ne,A=null,_=null,S=new Ut;S.viewport=new at;let z=new Ut;z.viewport=new at;let P=[S,z],F=new Au,ee=null,I=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(Z){let re=v[Z];if(re===void 0)re=new Ks,v[Z]=re;return re.getTargetRaySpace()},this.getControllerGrip=function(Z){let re=v[Z];if(re===void 0)re=new Ks,v[Z]=re;return re.getGripSpace()},this.getHand=function(Z){let re=v[Z];if(re===void 0)re=new Ks,v[Z]=re;return re.getHandSpace()};function H(Z){let re=M.indexOf(Z.inputSource);if(re===-1)return;let se=v[re];if(se!==void 0)se.update(Z.inputSource,Z.frame,c||s),se.dispatchEvent({type:Z.type,data:Z.inputSource})}function q(){i.removeEventListener("select",H),i.removeEventListener("selectstart",H),i.removeEventListener("selectend",H),i.removeEventListener("squeeze",H),i.removeEventListener("squeezestart",H),i.removeEventListener("squeezeend",H),i.removeEventListener("end",q),i.removeEventListener("inputsourceschange",C);for(let Z=0;Z<v.length;Z++){let re=M[Z];if(re===null)continue;M[Z]=null,v[Z].disconnect(re)}ee=null,I=null,x.reset();for(let Z in p)delete p[Z];if(e.setRenderTarget(E),h=null,f=null,u=null,i=null,R=null,Me.stop(),n.isPresenting=!1,e.setPixelRatio(A),e.setSize(T.width,T.height,!1),_!==null){let Z=_.camera;Z.fov=_.fov,Z.zoom=_.zoom,Z.updateProjectionMatrix(),_=null}n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(Z){if(r=Z,n.isPresenting===!0)Ie("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(Z){if(o=Z,n.isPresenting===!0)Ie("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||s},this.setReferenceSpace=function(Z){c=Z},this.getBaseLayer=function(){return f!==null?f:h},this.getBinding=function(){if(u===null&&g)u=new XRWebGLBinding(i,t);return u},this.getFrame=function(){return d},this.getSession=function(){return i},this.setSession=async function(Z){if(i=Z,i!==null){if(E=e.getRenderTarget(),i.addEventListener("select",H),i.addEventListener("selectstart",H),i.addEventListener("selectend",H),i.addEventListener("squeeze",H),i.addEventListener("squeezestart",H),i.addEventListener("squeezeend",H),i.addEventListener("end",q),i.addEventListener("inputsourceschange",C),m.xrCompatible!==!0)await t.makeXRCompatible();if(A=e.getPixelRatio(),e.getSize(T),!(g&&("createProjectionLayer"in XRWebGLBinding.prototype))){let se={antialias:m.antialias,alpha:!0,depth:m.depth,stencil:m.stencil,framebufferScaleFactor:r};h=new XRWebGLLayer(i,t,se),i.updateRenderState({baseLayer:h}),e.setPixelRatio(1),e.setSize(h.framebufferWidth,h.framebufferHeight,!1),R=new _n(h.framebufferWidth,h.framebufferHeight,{format:oi,type:$n,colorSpace:e.outputColorSpace,stencilBuffer:m.stencil,resolveDepthBuffer:h.ignoreDepthValues===!1,resolveStencilBuffer:h.ignoreDepthValues===!1,storeMultisampledDepthBuffer:h.ignoreDepthValues===!1,storeMultisampledStencilBuffer:h.ignoreDepthValues===!1})}else{let se=null,xe=null,we=null;if(m.depth)we=m.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,se=m.stencil?Mr:Sr,xe=m.stencil?hs:ji;let Ee={colorFormat:t.RGBA8,depthFormat:we,scaleFactor:r};u=this.getBinding(),f=u.createProjectionLayer(Ee),i.updateRenderState({layers:[f]}),e.setPixelRatio(1),e.setSize(f.textureWidth,f.textureHeight,!1),R=new _n(f.textureWidth,f.textureHeight,{format:oi,type:$n,depthTexture:new Tr(f.textureWidth,f.textureHeight,xe,void 0,void 0,void 0,void 0,void 0,void 0,se),stencilBuffer:m.stencil,colorSpace:e.outputColorSpace,samples:m.antialias?4:0,resolveDepthBuffer:f.ignoreDepthValues===!1,resolveStencilBuffer:f.ignoreDepthValues===!1,storeMultisampledDepthBuffer:f.ignoreDepthValues===!1,storeMultisampledStencilBuffer:f.ignoreDepthValues===!1})}R.isXRRenderTarget=!0,this.setFoveation(a),c=null,s=await i.requestReferenceSpace(o),Me.setContext(i),Me.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode},this.getDepthTexture=function(){return x.getDepthTexture()};function C(Z){for(let re=0;re<Z.removed.length;re++){let se=Z.removed[re],xe=M.indexOf(se);if(xe>=0)M[xe]=null,v[xe].disconnect(se)}for(let re=0;re<Z.added.length;re++){let se=Z.added[re],xe=M.indexOf(se);if(xe===-1){for(let Ee=0;Ee<v.length;Ee++)if(Ee>=M.length){M.push(se),xe=Ee;break}else if(M[Ee]===null){M[Ee]=se,xe=Ee;break}if(xe===-1)break}let we=v[xe];if(we)we.connect(se)}}let X=new O,k=new O;function Y(Z,re,se){X.setFromMatrixPosition(re.matrixWorld),k.setFromMatrixPosition(se.matrixWorld);let xe=X.distanceTo(k),we=re.projectionMatrix.elements,Ee=se.projectionMatrix.elements,xt=we[14]/(we[10]-1),ke=we[14]/(we[10]+1),Ze=(we[9]+1)/we[5],st=(we[9]-1)/we[5],Ye=(we[8]-1)/we[0],Zt=(Ee[8]+1)/Ee[0],yt=xt*Ye,cn=xt*Zt,Dt=xe/(-Ye+Zt),Ot=Dt*-Ye;if(re.matrixWorld.decompose(Z.position,Z.quaternion,Z.scale),Z.translateX(Ot),Z.translateZ(Dt),Z.matrixWorld.compose(Z.position,Z.quaternion,Z.scale),Z.matrixWorldInverse.copy(Z.matrixWorld).invert(),we[10]===-1)Z.projectionMatrix.copy(re.projectionMatrix),Z.projectionMatrixInverse.copy(re.projectionMatrixInverse);else{let N=xt+Dt,ln=ke+Dt,nt=yt-Ot,wt=cn+(xe-Ot),w=Ze*ke/ln*N,y=st*ke/ln*N;Z.projectionMatrix.makePerspective(nt,wt,w,y,N,ln),Z.projectionMatrixInverse.copy(Z.projectionMatrix).invert()}}function Q(Z,re){if(re===null)Z.matrixWorld.copy(Z.matrix);else Z.matrixWorld.multiplyMatrices(re.matrixWorld,Z.matrix);Z.matrixWorldInverse.copy(Z.matrixWorld).invert()}this.updateCamera=function(Z){if(i===null)return;let{near:re,far:se}=Z;if(x.texture!==null){if(x.depthNear>0)re=x.depthNear;if(x.depthFar>0)se=x.depthFar}if(F.near=z.near=S.near=re,F.far=z.far=S.far=se,ee!==F.near||I!==F.far)i.updateRenderState({depthNear:F.near,depthFar:F.far}),ee=F.near,I=F.far;F.layers.mask=Z.layers.mask|6,S.layers.mask=F.layers.mask&-5,z.layers.mask=F.layers.mask&-3;let xe=Z.parent,we=F.cameras;Q(F,xe);for(let Ee=0;Ee<we.length;Ee++)Q(we[Ee],xe);if(we.length===2)Y(F,S,z);else F.projectionMatrix.copy(S.projectionMatrix);if(_===null&&Z.isPerspectiveCamera)_={camera:Z,fov:Z.fov,zoom:Z.zoom};Se(Z,F,xe)};function Se(Z,re,se){if(se===null)Z.matrix.copy(re.matrixWorld);else Z.matrix.copy(se.matrixWorld),Z.matrix.invert(),Z.matrix.multiply(re.matrixWorld);if(Z.matrix.decompose(Z.position,Z.quaternion,Z.scale),Z.updateMatrixWorld(!0),Z.projectionMatrix.copy(re.projectionMatrix),Z.projectionMatrixInverse.copy(re.projectionMatrixInverse),Z.isPerspectiveCamera)Z.fov=yr*2*Math.atan(1/Z.projectionMatrix.elements[5]),Z.zoom=1}this.getCamera=function(){return F},this.getFoveation=function(){if(f===null&&h===null)return;return a},this.setFoveation=function(Z){if(a=Z,f!==null)f.fixedFoveation=Z;if(h!==null&&h.fixedFoveation!==void 0)h.fixedFoveation=Z},this.hasDepthSensing=function(){return x.texture!==null},this.getDepthSensingMesh=function(){return x.getMesh(F)},this.getCameraTexture=function(Z){return p[Z]};let ue=null;function Fe(Z,re){if(l=re.getViewerPose(c||s),d=re,l!==null){let se=l.views;if(h!==null)e.setRenderTargetFramebuffer(R,h.framebuffer),e.setRenderTarget(R);let xe=!1;if(se.length!==F.cameras.length)F.cameras.length=0,xe=!0;for(let ke=0;ke<se.length;ke++){let Ze=se[ke],st=null;if(h!==null)st=h.getViewport(Ze);else{let Zt=u.getViewSubImage(f,Ze);if(st=Zt.viewport,ke===0)e.setRenderTargetTextures(R,Zt.colorTexture,Zt.depthStencilTexture),e.setRenderTarget(R)}let Ye=P[ke];if(Ye===void 0)Ye=new Ut,Ye.layers.enable(ke),Ye.viewport=new at,P[ke]=Ye;if(Ye.matrix.fromArray(Ze.transform.matrix),Ye.matrix.decompose(Ye.position,Ye.quaternion,Ye.scale),Ye.projectionMatrix.fromArray(Ze.projectionMatrix),Ye.projectionMatrixInverse.copy(Ye.projectionMatrix).invert(),Ye.viewport.set(st.x,st.y,st.width,st.height),ke===0)F.matrix.copy(Ye.matrix),F.matrix.decompose(F.position,F.quaternion,F.scale);if(xe===!0)F.cameras.push(Ye)}let we=i.enabledFeatures;if(we&&we.includes("depth-sensing")&&i.depthUsage=="gpu-optimized"&&g){u=n.getBinding();let ke=u.getDepthInformation(se[0]);if(ke&&ke.isValid&&ke.texture)x.init(ke,i.renderState)}if(we&&we.includes("camera-access")&&g){e.state.unbindTexture(),u=n.getBinding();for(let ke=0;ke<se.length;ke++){let Ze=se[ke].camera;if(Ze){let st=p[Ze];if(!st)st=new Ga,p[Ze]=st;let Ye=u.getCameraImage(Ze);st.sourceTexture=Ye}}}}for(let se=0;se<v.length;se++){let xe=M[se],we=v[se];if(xe!==null&&we!==void 0)we.update(xe,re,c||s)}if(ue)ue(Z,re);if(re.detectedPlanes)n.dispatchEvent({type:"planesdetected",data:re});d=null}let Me=new Gp;Me.setAnimationLoop(Fe),this.setAnimationLoop=function(Z){ue=Z},this.dispose=function(){}}}var cT=new Ge,em=new ze;em.set(-1,0,0,0,1,0,0,0,1);function lT(e,t){function n(p,m){if(p.matrixAutoUpdate===!0)p.updateMatrix();m.value.copy(p.matrix)}function i(p,m){if(m.color.getRGB(p.fogColor.value,_u(e)),m.isFog)p.fogNear.value=m.near,p.fogFar.value=m.far;else if(m.isFogExp2)p.fogDensity.value=m.density}function r(p,m,E,R,v){if(m.isNodeMaterial)m.uniformsNeedUpdate=!1;else if(m.isMeshBasicMaterial)s(p,m);else if(m.isMeshLambertMaterial){if(s(p,m),m.envMap)p.envMapIntensity.value=m.envMapIntensity}else if(m.isMeshToonMaterial)s(p,m),f(p,m);else if(m.isMeshPhongMaterial){if(s(p,m),u(p,m),m.envMap)p.envMapIntensity.value=m.envMapIntensity}else if(m.isMeshStandardMaterial){if(s(p,m),h(p,m),m.isMeshPhysicalMaterial)d(p,m,v)}else if(m.isMeshMatcapMaterial)s(p,m),g(p,m);else if(m.isMeshDepthMaterial)s(p,m);else if(m.isMeshDistanceMaterial)s(p,m),x(p,m);else if(m.isMeshNormalMaterial)s(p,m);else if(m.isLineBasicMaterial){if(o(p,m),m.isLineDashedMaterial)a(p,m)}else if(m.isPointsMaterial)c(p,m,E,R);else if(m.isSpriteMaterial)l(p,m);else if(m.isShadowMaterial)p.color.value.copy(m.color),p.opacity.value=m.opacity;else if(m.isShaderMaterial)m.uniformsNeedUpdate=!1}function s(p,m){if(p.opacity.value=m.opacity,m.color)p.diffuse.value.copy(m.color);if(m.emissive)p.emissive.value.copy(m.emissive).multiplyScalar(m.emissiveIntensity);if(m.map)p.map.value=m.map,n(m.map,p.mapTransform);if(m.alphaMap)p.alphaMap.value=m.alphaMap,n(m.alphaMap,p.alphaMapTransform);if(m.bumpMap){if(p.bumpMap.value=m.bumpMap,n(m.bumpMap,p.bumpMapTransform),p.bumpScale.value=m.bumpScale,m.side===Qt)p.bumpScale.value*=-1}if(m.normalMap){if(p.normalMap.value=m.normalMap,n(m.normalMap,p.normalMapTransform),p.normalScale.value.copy(m.normalScale),m.side===Qt)p.normalScale.value.negate()}if(m.displacementMap)p.displacementMap.value=m.displacementMap,n(m.displacementMap,p.displacementMapTransform),p.displacementScale.value=m.displacementScale,p.displacementBias.value=m.displacementBias;if(m.emissiveMap)p.emissiveMap.value=m.emissiveMap,n(m.emissiveMap,p.emissiveMapTransform);if(m.specularMap)p.specularMap.value=m.specularMap,n(m.specularMap,p.specularMapTransform);if(m.alphaTest>0)p.alphaTest.value=m.alphaTest;let E=t.get(m),{envMap:R,envMapRotation:v}=E;if(R){if(p.envMap.value=R,p.envMapRotation.value.setFromMatrix4(cT.makeRotationFromEuler(v)).transpose(),R.isCubeTexture&&R.isRenderTargetTexture===!1)p.envMapRotation.value.premultiply(em);p.reflectivity.value=m.reflectivity,p.ior.value=m.ior,p.refractionRatio.value=m.refractionRatio}if(m.lightMap)p.lightMap.value=m.lightMap,p.lightMapIntensity.value=m.lightMapIntensity,n(m.lightMap,p.lightMapTransform);if(m.aoMap)p.aoMap.value=m.aoMap,p.aoMapIntensity.value=m.aoMapIntensity,n(m.aoMap,p.aoMapTransform)}function o(p,m){if(p.diffuse.value.copy(m.color),p.opacity.value=m.opacity,m.map)p.map.value=m.map,n(m.map,p.mapTransform)}function a(p,m){p.dashSize.value=m.dashSize,p.totalSize.value=m.dashSize+m.gapSize,p.scale.value=m.scale}function c(p,m,E,R){if(p.diffuse.value.copy(m.color),p.opacity.value=m.opacity,p.size.value=m.size*E,p.scale.value=R*0.5,m.map)p.map.value=m.map,n(m.map,p.uvTransform);if(m.alphaMap)p.alphaMap.value=m.alphaMap,n(m.alphaMap,p.alphaMapTransform);if(m.alphaTest>0)p.alphaTest.value=m.alphaTest}function l(p,m){if(p.diffuse.value.copy(m.color),p.opacity.value=m.opacity,p.rotation.value=m.rotation,m.map)p.map.value=m.map,n(m.map,p.mapTransform);if(m.alphaMap)p.alphaMap.value=m.alphaMap,n(m.alphaMap,p.alphaMapTransform);if(m.alphaTest>0)p.alphaTest.value=m.alphaTest}function u(p,m){p.specular.value.copy(m.specular),p.shininess.value=Math.max(m.shininess,0.0001)}function f(p,m){if(m.gradientMap)p.gradientMap.value=m.gradientMap}function h(p,m){if(p.metalness.value=m.metalness,m.metalnessMap)p.metalnessMap.value=m.metalnessMap,n(m.metalnessMap,p.metalnessMapTransform);if(p.roughness.value=m.roughness,m.roughnessMap)p.roughnessMap.value=m.roughnessMap,n(m.roughnessMap,p.roughnessMapTransform);if(m.envMap)p.envMapIntensity.value=m.envMapIntensity}function d(p,m,E){if(p.ior.value=m.ior,m.sheen>0){if(p.sheenColor.value.copy(m.sheenColor).multiplyScalar(m.sheen),p.sheenRoughness.value=m.sheenRoughness,m.sheenColorMap)p.sheenColorMap.value=m.sheenColorMap,n(m.sheenColorMap,p.sheenColorMapTransform);if(m.sheenRoughnessMap)p.sheenRoughnessMap.value=m.sheenRoughnessMap,n(m.sheenRoughnessMap,p.sheenRoughnessMapTransform)}if(m.clearcoat>0){if(p.clearcoat.value=m.clearcoat,p.clearcoatRoughness.value=m.clearcoatRoughness,m.clearcoatMap)p.clearcoatMap.value=m.clearcoatMap,n(m.clearcoatMap,p.clearcoatMapTransform);if(m.clearcoatRoughnessMap)p.clearcoatRoughnessMap.value=m.clearcoatRoughnessMap,n(m.clearcoatRoughnessMap,p.clearcoatRoughnessMapTransform);if(m.clearcoatNormalMap){if(p.clearcoatNormalMap.value=m.clearcoatNormalMap,n(m.clearcoatNormalMap,p.clearcoatNormalMapTransform),p.clearcoatNormalScale.value.copy(m.clearcoatNormalScale),m.side===Qt)p.clearcoatNormalScale.value.negate()}}if(m.dispersion>0)p.dispersion.value=m.dispersion;if(m.retroreflectivity>0)p.retroreflectivity.value=m.retroreflectivity;if(m.iridescence>0){if(p.iridescence.value=m.iridescence,p.iridescenceIOR.value=m.iridescenceIOR,p.iridescenceThicknessMinimum.value=m.iridescenceThicknessRange[0],p.iridescenceThicknessMaximum.value=m.iridescenceThicknessRange[1],m.iridescenceMap)p.iridescenceMap.value=m.iridescenceMap,n(m.iridescenceMap,p.iridescenceMapTransform);if(m.iridescenceThicknessMap)p.iridescenceThicknessMap.value=m.iridescenceThicknessMap,n(m.iridescenceThicknessMap,p.iridescenceThicknessMapTransform)}if(m.transmission>0){if(p.transmission.value=m.transmission,p.transmissionSamplerMap.value=E.texture,p.transmissionSamplerSize.value.set(E.width,E.height),m.transmissionMap)p.transmissionMap.value=m.transmissionMap,n(m.transmissionMap,p.transmissionMapTransform);if(p.thickness.value=m.thickness,m.thicknessMap)p.thicknessMap.value=m.thicknessMap,n(m.thicknessMap,p.thicknessMapTransform);p.attenuationDistance.value=m.attenuationDistance,p.attenuationColor.value.copy(m.attenuationColor)}if(m.anisotropy>0){if(p.anisotropyVector.value.set(m.anisotropy*Math.cos(m.anisotropyRotation),m.anisotropy*Math.sin(m.anisotropyRotation)),m.anisotropyMap)p.anisotropyMap.value=m.anisotropyMap,n(m.anisotropyMap,p.anisotropyMapTransform)}if(p.specularIntensity.value=m.specularIntensity,p.specularColor.value.copy(m.specularColor),m.specularColorMap)p.specularColorMap.value=m.specularColorMap,n(m.specularColorMap,p.specularColorMapTransform);if(m.specularIntensityMap)p.specularIntensityMap.value=m.specularIntensityMap,n(m.specularIntensityMap,p.specularIntensityMapTransform)}function g(p,m){if(m.matcap)p.matcap.value=m.matcap}function x(p,m){let E=t.get(m).light;p.referencePosition.value.setFromMatrixPosition(E.matrixWorld),p.nearDistance.value=E.shadow.camera.near,p.farDistance.value=E.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:r}}function uT(e,t,n,i){let r={},s={},o=[],a=e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS);function c(v,M){let T=M.program;i.uniformBlockBinding(v,T)}function l(v,M){let T=r[v.id];if(T===void 0)p(v),T=u(v),r[v.id]=T,v.addEventListener("dispose",E);let A=M.program;i.updateUBOMapping(v,A);let _=t.render.frame;if(s[v.id]!==_)h(v),s[v.id]=_}function u(v){let M=f();v.__bindingPointIndex=M;let T=e.createBuffer(),{__size:A,usage:_}=v;return e.bindBuffer(e.UNIFORM_BUFFER,T),e.bufferData(e.UNIFORM_BUFFER,A,_),e.bindBuffer(e.UNIFORM_BUFFER,null),e.bindBufferBase(e.UNIFORM_BUFFER,M,T),T}function f(){for(let v=0;v<a;v++)if(o.indexOf(v)===-1)return o.push(v),v;return Ue("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function h(v){let M=r[v.id],{uniforms:T,__cache:A}=v;e.bindBuffer(e.UNIFORM_BUFFER,M);for(let _=0,S=T.length;_<S;_++){let z=T[_];if(Array.isArray(z))for(let P=0,F=z.length;P<F;P++)d(z[P],_,P,A);else d(z,_,0,A)}e.bindBuffer(e.UNIFORM_BUFFER,null)}function d(v,M,T,A){if(x(v,M,T,A)===!0){let{__offset:_,value:S}=v;if(Array.isArray(S)){let z=0;for(let P=0;P<S.length;P++){let F=S[P],ee=m(F);if(g(F,v.__data,z),typeof F!=="number"&&typeof F!=="boolean"&&!F.isMatrix3&&!ArrayBuffer.isView(F))z+=ee.storage/Float32Array.BYTES_PER_ELEMENT}}else g(S,v.__data,0);e.bufferSubData(e.UNIFORM_BUFFER,_,v.__data)}}function g(v,M,T){if(typeof v==="number"||typeof v==="boolean")M[0]=v;else if(v.isMatrix3)M[0]=v.elements[0],M[1]=v.elements[1],M[2]=v.elements[2],M[3]=0,M[4]=v.elements[3],M[5]=v.elements[4],M[6]=v.elements[5],M[7]=0,M[8]=v.elements[6],M[9]=v.elements[7],M[10]=v.elements[8],M[11]=0;else if(ArrayBuffer.isView(v))M.set(new v.constructor(v.buffer,v.byteOffset,M.length));else v.toArray(M,T)}function x(v,M,T,A){let _=v.value,S=M+"_"+T;if(A[S]===void 0){if(typeof _==="number"||typeof _==="boolean")A[S]=_;else if(ArrayBuffer.isView(_))A[S]=_.slice();else A[S]=_.clone();return!0}else{let z=A[S];if(typeof _==="number"||typeof _==="boolean"){if(z!==_)return A[S]=_,!0}else if(ArrayBuffer.isView(_))return!0;else if(z.equals(_)===!1)return z.copy(_),!0}return!1}function p(v){let M=v.uniforms,T=0,A=16;for(let S=0,z=M.length;S<z;S++){let P=Array.isArray(M[S])?M[S]:[M[S]];for(let F=0,ee=P.length;F<ee;F++){let I=P[F],H=Array.isArray(I.value)?I.value:[I.value];for(let q=0,C=H.length;q<C;q++){let X=H[q],k=m(X),Y=T%A,Q=Y%k.boundary,Se=Y+Q;if(T+=Q,Se!==0&&A-Se<k.storage)T+=A-Se;I.__data=new Float32Array(k.storage/Float32Array.BYTES_PER_ELEMENT),I.__offset=T,T+=k.storage}}}let _=T%A;if(_>0)T+=A-_;return v.__size=T,v.__cache={},this}function m(v){let M={boundary:0,storage:0};if(typeof v==="number"||typeof v==="boolean")M.boundary=4,M.storage=4;else if(v.isVector2)M.boundary=8,M.storage=8;else if(v.isVector3||v.isColor)M.boundary=16,M.storage=12;else if(v.isVector4)M.boundary=16,M.storage=16;else if(v.isMatrix3)M.boundary=48,M.storage=48;else if(v.isMatrix4)M.boundary=64,M.storage=64;else if(v.isTexture)Ie("WebGLRenderer: Texture samplers can not be part of an uniforms group.");else if(ArrayBuffer.isView(v))M.boundary=16,M.storage=v.byteLength;else Ie("WebGLRenderer: Unsupported uniform value type.",v);return M}function E(v){let M=v.target;M.removeEventListener("dispose",E);let T=o.indexOf(M.__bindingPointIndex);o.splice(T,1),e.deleteBuffer(r[M.id]),delete r[M.id],delete s[M.id]}function R(){for(let v in r)e.deleteBuffer(r[v]);o=[],r={},s={}}return{bind:c,update:l,dispose:R}}var hT=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]),ci=null;function fT(){if(ci===null)ci=new eo(hT,16,16,wr,si),ci.name="DFG_LUT",ci.minFilter=$t,ci.magFilter=$t,ci.wrapS=ls,ci.wrapT=ls,ci.generateMipmaps=!1,ci.needsUpdate=!0;return ci}class Vu{constructor(e={}){let{canvas:t=ap(),context:n=null,depth:i=!0,stencil:r=!1,alpha:s=!1,antialias:o=!1,premultipliedAlpha:a=!0,preserveDrawingBuffer:c=!1,powerPreference:l="default",failIfMajorPerformanceCaveat:u=!1,reversedDepthBuffer:f=!1,outputBufferType:h=$n}=e;this.isWebGLRenderer=!0;let d;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");d=n.getContextAttributes().alpha}else d=s;let g=h,x=new Set([Cl,Rl,Al]),p=new Set([$n,ji,Xs,hs,El,Tl]),m=new Uint32Array(4),E=new Int32Array(4),R=new O,v=null,M=null,T=[],A=[],_=null;this.domElement=t,this.debug={checkShaderErrors:!0,diagnostics:{keywords:!1},onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=Hn,this.toneMappingExposure=1,this.transmissionResolutionScale=1;let S=this,z=!1,P=null,F=null,ee=null,I=null;this._outputColorSpace=Yi;let H=0,q=0,C=null,X=-1,k=null,Y=new at,Q=new at,Se=null,ue=new Oe(0),Fe=0,{width:Me,height:Z}=t,re=1,se=null,xe=null,we=new at(0,0,Me,Z),Ee=new at(0,0,Me,Z),xt=!1,ke=new no,Ze=!1,st=!1,Ye=new Ge,Zt=new O,yt=new at,cn={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},Dt=!1;function Ot(){return C===null?re:1}let N=n;function ln(b,D){return t.getContext(b,D)}let nt,wt,w,y,L,V,ie,ae,he,j,te,_e,Pe,fe,oe,Le,De,Qe,U,ce,K,le,ye;try{let b={alpha:!0,depth:i,stencil:r,antialias:o,premultipliedAlpha:a,preserveDrawingBuffer:c,powerPreference:l,failIfMajorPerformanceCaveat:u};if("setAttribute"in t)t.setAttribute("data-engine",`three.js r${dd}`);if(t.addEventListener("webglcontextlost",Be,!1),t.addEventListener("webglcontextrestored",mt,!1),t.addEventListener("webglcontextcreationerror",it,!1),N===null){if(N=ln("webgl2",b),N===null)if(ln("webgl2"))throw Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes.");else throw Error("THREE.WebGLRenderer: Error creating WebGL context.")}ne()}catch(b){throw t.removeEventListener("webglcontextlost",Be,!1),t.removeEventListener("webglcontextrestored",mt,!1),t.removeEventListener("webglcontextcreationerror",it,!1),Ue("WebGLRenderer: "+b.message),b}function ne(){if(nt=new yw(N),nt.init(),K=new sT(N,nt),wt=new lw(N,nt,e,K),w=new iT(N,nt),wt.reversedDepthBuffer&&f)w.buffers.depth.setReversed(!0);F=N.createFramebuffer(),ee=N.createFramebuffer(),I=N.createFramebuffer(),y=new Sw(N),L=new VE,V=new rT(N,nt,w,L,wt,K,y),ie=new xw(S),ae=new wb(N),le=new aw(N,ae),he=new vw(N,ae,y,le),j=new ww(N,he,ae,le,y),Qe=new Mw(N,wt,V),oe=new uw(L),te=new HE(S,ie,nt,wt,le,oe),_e=new lT(S,L),Pe=new WE,fe=new KE(nt),De=new ow(S,ie,w,j,d,a),Le=new nT(S,j,wt),ye=new uT(N,y,wt,w),U=new cw(N,nt,y),ce=new bw(N,nt,y),y.programs=te.programs,S.capabilities=wt,S.extensions=nt,S.properties=L,S.renderLists=Pe,S.shadowMap=Le,S.state=w,S.info=y}if(g!==$n)_=new Tw(g,t.width,t.height,o,i,r);let pe=new Qp(S,N);this.xr=pe,this.getContext=function(){return N},this.getContextAttributes=function(){return N.getContextAttributes()},this.forceContextLoss=function(){let b=nt.get("WEBGL_lose_context");if(b)b.loseContext()},this.forceContextRestore=function(){let b=nt.get("WEBGL_lose_context");if(b)b.restoreContext()},this.getPixelRatio=function(){return re},this.setPixelRatio=function(b){if(b===void 0)return;re=b,this.setSize(Me,Z,!1)},this.getSize=function(b){return b.set(Me,Z)},this.setSize=function(b,D,W=!0){if(pe.isPresenting){Ie("WebGLRenderer: Can't change size while VR device is presenting.");return}if(Me=b,Z=D,t.width=Math.floor(b*re),t.height=Math.floor(D*re),W===!0)t.style.width=b+"px",t.style.height=D+"px";if(_!==null)_.setSize(t.width,t.height);this.setViewport(0,0,b,D)},this.getDrawingBufferSize=function(b){return b.set(Me*re,Z*re).floor()},this.setDrawingBufferSize=function(b,D,W){Me=b,Z=D,re=W,t.width=Math.floor(b*W),t.height=Math.floor(D*W),this.setViewport(0,0,b,D)},this.setEffects=function(b){if(g===$n){Ue("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(b){for(let D=0;D<b.length;D++)if(b[D].isOutputPass===!0){Ie("WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}_.setEffects(b||[])},this.getCurrentViewport=function(b){return b.copy(Y)},this.getViewport=function(b){return b.copy(we)},this.setViewport=function(b,D,W,B){if(b.isVector4)we.set(b.x,b.y,b.z,b.w);else we.set(b,D,W,B);w.viewport(Y.copy(we).multiplyScalar(re).round())},this.getScissor=function(b){return b.copy(Ee)},this.setScissor=function(b,D,W,B){if(b.isVector4)Ee.set(b.x,b.y,b.z,b.w);else Ee.set(b,D,W,B);w.scissor(Q.copy(Ee).multiplyScalar(re).round())},this.getScissorTest=function(){return xt},this.setScissorTest=function(b){w.setScissorTest(xt=b)},this.setOpaqueSort=function(b){se=b},this.setTransparentSort=function(b){xe=b},this.getClearColor=function(b){return b.copy(De.getClearColor())},this.setClearColor=function(){De.setClearColor(...arguments)},this.getClearAlpha=function(){return De.getClearAlpha()},this.setClearAlpha=function(){De.setClearAlpha(...arguments)},this.clear=function(b=!0,D=!0,W=!0){let B=0;if(b){let G=!1;if(C!==null){let ge=C.texture.format;G=x.has(ge)}if(G){let ge=C.texture.type,be=p.has(ge),me=De.getClearColor(),Te=De.getClearAlpha(),{r:Re,g:He,b:qe}=me;if(be)m[0]=Re,m[1]=He,m[2]=qe,m[3]=Te,N.clearBufferuiv(N.COLOR,0,m);else E[0]=Re,E[1]=He,E[2]=qe,E[3]=Te,N.clearBufferiv(N.COLOR,0,E)}else B|=N.COLOR_BUFFER_BIT}if(D)B|=N.DEPTH_BUFFER_BIT,this.state.buffers.depth.setMask(!0);if(W)B|=N.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295);if(B!==0)N.clear(B)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.setNodesHandler=function(b){b.setRenderer(this),P=b},this.dispose=function(){t.removeEventListener("webglcontextlost",Be,!1),t.removeEventListener("webglcontextrestored",mt,!1),t.removeEventListener("webglcontextcreationerror",it,!1),De.dispose(),Pe.dispose(),fe.dispose(),L.dispose(),ie.dispose(),j.dispose(),le.dispose(),ye.dispose(),te.dispose(),pe.dispose(),pe.removeEventListener("sessionstart",bf),pe.removeEventListener("sessionend",Sf),dr.stop()};function Be(b){b.preventDefault(),Hs("WebGLRenderer: Context Lost."),z=!0}function mt(){Hs("WebGLRenderer: Context Restored."),z=!1;let b=y.autoReset,D=Le.enabled,W=Le.autoUpdate,B=Le.needsUpdate,G=Le.type;ne(),y.autoReset=b,Le.enabled=D,Le.autoUpdate=W,Le.needsUpdate=B,Le.type=G}function it(b){Ue("WebGLRenderer: A WebGL context could not be created. Reason: ",b.statusMessage)}function Kn(b){let D=b.target;D.removeEventListener("dispose",Kn),vi(D)}function vi(b){pv(b),L.remove(b)}function pv(b){let D=L.get(b).programs;if(D!==void 0){if(D.forEach(function(W){te.releaseProgram(W)}),b.isShaderMaterial)te.releaseShaderCache(b)}}this.renderBufferDirect=function(b,D,W,B,G,ge){if(D===null)D=cn;let be=G.isMesh&&G.matrixWorld.determinantAffine()<0,me=_v(b,D,W,B,G);w.setMaterial(B,be);let Te=W.index,Re=1;if(B.wireframe===!0){if(Te=he.getWireframeAttribute(W),Te===void 0)return;Re=2}let He=W.drawRange,qe=W.attributes.position,Ae=He.start*Re,rt=(He.start+He.count)*Re;if(ge!==null)Ae=Math.max(Ae,ge.start*Re),rt=Math.min(rt,(ge.start+ge.count)*Re);if(Te!==null)Ae=Math.max(Ae,0),rt=Math.min(rt,Te.count);else if(qe!==void 0&&qe!==null)Ae=Math.max(Ae,0),rt=Math.min(rt,qe.count);let Lt=rt-Ae;if(Lt<0||Lt===1/0)return;le.setup(G,B,me,W,Te);let vt,ft=U;if(Te!==null)vt=ae.get(Te),ft=ce,ft.setIndex(vt);if(G.isMesh)if(B.wireframe===!0)w.setLineWidth(B.wireframeLinewidth*Ot()),ft.setMode(N.LINES);else ft.setMode(N.TRIANGLES);else if(G.isLine){let Yt=B.linewidth;if(Yt===void 0)Yt=1;if(w.setLineWidth(Yt*Ot()),G.isLineSegments)ft.setMode(N.LINES);else if(G.isLineLoop)ft.setMode(N.LINE_LOOP);else ft.setMode(N.LINE_STRIP)}else if(G.isPoints)ft.setMode(N.POINTS);else if(G.isSprite)ft.setMode(N.TRIANGLES);if(G.isBatchedMesh)if(!nt.get("WEBGL_multi_draw")){let{_multiDrawStarts:Yt,_multiDrawCounts:ve,_multiDrawCount:rn}=G,Ke=Te?ae.get(Te).bytesPerElement:1,Tn=L.get(B).currentProgram.getUniforms();for(let Jn=0;Jn<rn;Jn++)Tn.setValue(N,"_gl_DrawID",Jn),ft.render(Yt[Jn]/Ke,ve[Jn])}else ft.renderMultiDraw(G._multiDrawStarts,G._multiDrawCounts,G._multiDrawCount);else if(G.isInstancedMesh)ft.renderInstances(Ae,Lt,G.count);else if(W.isInstancedBufferGeometry){let Yt=W._maxInstanceCount!==void 0?W._maxInstanceCount:1/0,ve=Math.min(W.instanceCount,Yt);ft.renderInstances(Ae,Lt,ve)}else ft.render(Ae,Lt)};function vf(b,D,W,B){if(P!==null&&b.isNodeMaterial)P.setObject(B,b);if(Ze===!0)oe.setState(b,W,!1);if(b.transparent===!0&&b.side===Pn&&b.forceSinglePass===!1)b.side=Qt,b.needsUpdate=!0,Wo(b,D,B),b.side=qi,b.needsUpdate=!0,Wo(b,D,B),b.side=Pn;else Wo(b,D,B)}this.compile=function(b,D,W=null){if(W===null)W=b;if(P!==null)P.renderStart(b,D,W);if(M=fe.get(W),M.init(D),A.push(M),W.traverseVisible(function(G){if(G.isLight&&G.layers.test(D.layers)){if(M.pushLight(G),G.castShadow)M.pushShadow(G)}}),b!==W)b.traverseVisible(function(G){if(G.isLight&&G.layers.test(D.layers)){if(M.pushLight(G),G.castShadow)M.pushShadow(G)}});if(M.setupLights(),P!==null)P.updateLights(M.state.lightsArray);if(st=this.localClippingEnabled,Ze=oe.init(this.clippingPlanes,st),Ze===!0)oe.setGlobalState(this.clippingPlanes,D);if(P!==null)Le.render(M.state.shadowsArray,W,D);let B=new Set;if(b.traverse(function(G){if(!(G.isMesh||G.isPoints||G.isLine||G.isSprite))return;let ge=G.material;if(ge)if(Array.isArray(ge))for(let be=0;be<ge.length;be++){let me=ge[be];vf(me,W,D,G),B.add(me)}else vf(ge,W,D,G),B.add(ge)}),M=A.pop(),P!==null)P.renderEnd();return B},this.compileAsync=function(b,D,W=null){let B=this.compile(b,D,W);return new Promise((G)=>{function ge(){if(B.forEach(function(be){let Te=L.get(be).currentProgram;if(Te===void 0||Te.isReady())B.delete(be)}),B.size===0){G(b);return}setTimeout(ge,10)}if(nt.get("KHR_parallel_shader_compile")!==null)ge();else setTimeout(ge,10)})};let Bc=null;function mv(b){if(Bc)Bc(b)}function bf(){dr.stop()}function Sf(){dr.start()}let dr=new Gp;if(dr.setAnimationLoop(mv),typeof self<"u")dr.setContext(self);this.setAnimationLoop=function(b){Bc=b,pe.setAnimationLoop(b),b===null?dr.stop():dr.start()},pe.addEventListener("sessionstart",bf),pe.addEventListener("sessionend",Sf),this.render=function(b,D){if(D!==void 0&&D.isCamera!==!0){Ue("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(z===!0)return;if(P!==null)P.renderStart(b,D);let W=pe.enabled===!0&&pe.isPresenting===!0,B=_!==null&&(C===null||W)&&_.begin(S,C);if(b.matrixWorldAutoUpdate===!0)b.updateMatrixWorld();if(D.parent===null&&D.matrixWorldAutoUpdate===!0)D.updateMatrixWorld();if(pe.enabled===!0&&pe.isPresenting===!0&&(_===null||_.isCompositing()===!1)){if(pe.cameraAutoUpdate===!0)pe.updateCamera(D);D=pe.getCamera()}if(b.isScene===!0)b.onBeforeRender(S,b,D,C);if(M=fe.get(b,A.length),M.init(D),M.state.textureUnits=V.getTextureUnits(),A.push(M),Ye.multiplyMatrices(D.projectionMatrix,D.matrixWorldInverse),ke.setFromProjectionMatrix(Ye,hu,D.reversedDepth),st=this.localClippingEnabled,Ze=oe.init(this.clippingPlanes,st),v=Pe.get(b,T.length),v.init(),T.push(v),pe.enabled===!0&&pe.isPresenting===!0){let be=S.xr.getDepthSensingMesh();if(be!==null)Gc(be,D,-1/0,S.sortObjects)}if(Gc(b,D,0,S.sortObjects),v.finish(),P!==null)P.updateLights(M.state.lightsArray);if(S.sortObjects===!0)v.sort(se,xe);if(Dt=pe.enabled===!1||pe.isPresenting===!1||pe.hasDepthSensing()===!1,Dt)De.addToRenderList(v,b);if(this.info.render.frame++,this.info.autoReset===!0)this.info.reset();if(Ze===!0)oe.beginShadows();let G=M.state.shadowsArray;if(Le.render(G,b,D),Ze===!0)oe.endShadows();if((B&&_.hasRenderPass())===!1){let be=v.opaque,me=v.transmissive;if(M.setupLights(),D.isArrayCamera){let Te=D.cameras;if(me.length>0)for(let Re=0,He=Te.length;Re<He;Re++){let qe=Te[Re];wf(be,me,b,qe)}if(Dt)De.render(b);for(let Re=0,He=Te.length;Re<He;Re++){let qe=Te[Re];Mf(v,b,qe,qe.viewport)}}else{if(me.length>0)wf(be,me,b,D);if(Dt)De.render(b);Mf(v,b,D)}}if(C!==null&&q===0)V.updateMultisampleRenderTarget(C),V.updateRenderTargetMipmap(C);if(B)_.end(S);if(b.isScene===!0)b.onAfterRender(S,b,D);if(le.resetDefaultState(),X=-1,k=null,A.pop(),A.length>0){if(M=A[A.length-1],V.setTextureUnits(M.state.textureUnits),Ze===!0)oe.setGlobalState(S.clippingPlanes,M.state.camera)}else M=null;if(T.pop(),T.length>0)v=T[T.length-1];else v=null;if(P!==null)P.renderEnd()};function Gc(b,D,W,B){if(b.visible===!1)return;if(b.layers.test(D.layers)){if(b.isGroup)W=b.renderOrder;else if(b.isLOD){if(b.autoUpdate===!0)b.update(D)}else if(b.isLightProbeGrid)M.pushLightProbeGrid(b);else if(b.isLight){if(M.pushLight(b),b.castShadow)M.pushShadow(b)}else if(b.isSprite){if(!b.frustumCulled||b.intersectsFrustum(ke)){if(B)yt.setFromMatrixPosition(b.matrixWorld).applyMatrix4(Ye);let be=j.update(b),me=b.material;if(me.visible)v.push(b,be,me,W,yt.z,null,D)}}else if(b.isMesh||b.isLine||b.isPoints){if(!b.frustumCulled||b.intersectsFrustum(ke)){let be=j.update(b),me=b.material;if(B){if(b.boundingSphere!==void 0){if(b.boundingSphere===null)b.computeBoundingSphere();yt.copy(b.boundingSphere.center)}else{if(be.boundingSphere===null)be.computeBoundingSphere();yt.copy(be.boundingSphere.center)}yt.applyMatrix4(b.matrixWorld).applyMatrix4(Ye)}if(Array.isArray(me)){let Te=be.groups;for(let Re=0,He=Te.length;Re<He;Re++){let qe=Te[Re],Ae=me[qe.materialIndex];if(Ae&&Ae.visible)v.push(b,be,Ae,W,yt.z,qe,D)}}else if(me.visible)v.push(b,be,me,W,yt.z,null,D)}}}let ge=b.children;for(let be=0,me=ge.length;be<me;be++)Gc(ge[be],D,W,B)}function Mf(b,D,W,B){let{opaque:G,transmissive:ge,transparent:be}=b;if(M.setupLightsView(W),Ze===!0)oe.setGlobalState(S.clippingPlanes,W);if(B)w.viewport(Y.copy(B));if(G.length>0)$o(G,D,W);if(ge.length>0)$o(ge,D,W);if(be.length>0)$o(be,D,W);w.buffers.depth.setTest(!0),w.buffers.depth.setMask(!0),w.buffers.color.setMask(!0),w.setPolygonOffset(!1)}function wf(b,D,W,B){if((W.isScene===!0?W.overrideMaterial:null)!==null)return;if(M.state.transmissionRenderTarget[B.id]===void 0){let Ae=nt.has("EXT_color_buffer_half_float")||nt.has("EXT_color_buffer_float");M.state.transmissionRenderTarget[B.id]=new _n(1,1,{generateMipmaps:!0,type:Ae?si:$n,minFilter:ri,samples:Math.max(4,wt.samples),stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,storeMultisampledDepthBuffer:!1,storeMultisampledStencilBuffer:!1,colorSpace:$e.workingColorSpace})}let ge=M.state.transmissionRenderTarget[B.id],be=B.viewport||Y;ge.setSize(be.z*S.transmissionResolutionScale,be.w*S.transmissionResolutionScale);let me=S.getRenderTarget(),Te=S.getActiveCubeFace(),Re=S.getActiveMipmapLevel();if(S.setRenderTarget(ge),S.getClearColor(ue),Fe=S.getClearAlpha(),Fe<1)S.setClearColor(16777215,0.5);if(S.clear(),Dt)De.render(W);let He=S.toneMapping;S.toneMapping=Hn;let qe=B.viewport;if(B.viewport!==void 0)B.viewport=void 0;if(M.setupLightsView(B),Ze===!0)oe.setGlobalState(S.clippingPlanes,B);if($o(b,W,B),V.updateMultisampleRenderTarget(ge),V.updateRenderTargetMipmap(ge),nt.has("WEBGL_multisampled_render_to_texture")===!1){let Ae=!1;for(let rt=0,Lt=D.length;rt<Lt;rt++){let vt=D[rt],{object:ft,geometry:Yt,material:ve,group:rn}=vt;if(ve.side===Pn&&ft.layers.test(B.layers)){let Ke=ve.side;ve.side=Qt,ve.needsUpdate=!0,Ef(ft,W,B,Yt,ve,rn),ve.side=Ke,ve.needsUpdate=!0,Ae=!0}}if(Ae===!0)V.updateMultisampleRenderTarget(ge),V.updateRenderTargetMipmap(ge)}if(S.setRenderTarget(me,Te,Re),S.setClearColor(ue,Fe),qe!==void 0)B.viewport=qe;S.toneMapping=He}function $o(b,D,W){let B=D.isScene===!0?D.overrideMaterial:null;for(let G=0,ge=b.length;G<ge;G++){let be=b[G],{object:me,geometry:Te,group:Re}=be,He=be.material;if(He.allowOverride===!0&&B!==null)He=B;if(me.layers.test(W.layers))Ef(me,D,W,Te,He,Re)}}function Ef(b,D,W,B,G,ge){if(P!==null&&G.isNodeMaterial)P.setObject(b,G);if(b.onBeforeRender(S,D,W,B,G,ge),b.modelViewMatrix.multiplyMatrices(W.matrixWorldInverse,b.matrixWorld),b.normalMatrix.getNormalMatrix(b.modelViewMatrix),G.onBeforeRender(S,D,W,B,b,ge),G.transparent===!0&&G.side===Pn&&G.forceSinglePass===!1)G.side=Qt,G.needsUpdate=!0,S.renderBufferDirect(W,D,B,G,b,ge),G.side=qi,G.needsUpdate=!0,S.renderBufferDirect(W,D,B,G,b,ge),G.side=Pn;else S.renderBufferDirect(W,D,B,G,b,ge);b.onAfterRender(S,D,W,B,G,ge)}function Wo(b,D,W){if(D.isScene!==!0)D=cn;let B=L.get(b),G=M.state.lights,ge=M.state.shadowsArray,be=G.state.version,me=te.getParameters(b,G.state,ge,D,W,M.state.lightProbeGridArray),Te=te.getProgramCacheKey(me),Re=B.programs;B.environment=b.isMeshStandardMaterial||b.isMeshLambertMaterial||b.isMeshPhongMaterial?D.environment:null,B.fog=D.fog;let He=b.isMeshStandardMaterial||b.isMeshLambertMaterial&&!b.envMap||b.isMeshPhongMaterial&&!b.envMap;if(B.envMap=ie.get(b.envMap||B.environment,He),B.envMapRotation=B.environment!==null&&b.envMap===null?D.environmentRotation:b.envMapRotation,Re===void 0)b.addEventListener("dispose",Kn),Re=new Map,B.programs=Re;let qe=Re.get(Te);if(qe!==void 0){if(B.currentProgram===qe&&B.lightsStateVersion===be)return Af(b,me),qe}else{if(me.uniforms=te.getUniforms(b),P!==null&&b.isNodeMaterial)P.build(b,W,me);b.onBeforeCompile(me,S),qe=te.acquireProgram(me,Te),Re.set(Te,qe),B.uniforms=me.uniforms}let Ae=B.uniforms;if(!b.isShaderMaterial&&!b.isRawShaderMaterial||b.clipping===!0)Ae.clippingPlanes=oe.uniform;if(Af(b,me),B.needsLights=yv(b),B.lightsStateVersion=be,B.needsLights)Ae.ambientLightColor.value=G.state.ambient,Ae.lightProbe.value=G.state.probe,Ae.sunLights.value=G.state.sun,Ae.sunLightShadows.value=G.state.sunShadow,Ae.directionalLights.value=G.state.directional,Ae.directionalLightShadows.value=G.state.directionalShadow,Ae.spotLights.value=G.state.spot,Ae.spotLightShadows.value=G.state.spotShadow,Ae.rectAreaLights.value=G.state.rectArea,Ae.ltc_1.value=G.state.rectAreaLTC1,Ae.ltc_2.value=G.state.rectAreaLTC2,Ae.pointLights.value=G.state.point,Ae.pointLightShadows.value=G.state.pointShadow,Ae.hemisphereLights.value=G.state.hemi,Ae.sunShadowMatrix.value=G.state.sunShadowMatrix,Ae.sunShadowCascade.value=G.state.sunShadowCascade,Ae.directionalShadowMatrix.value=G.state.directionalShadowMatrix,Ae.spotLightMatrix.value=G.state.spotLightMatrix,Ae.spotLightMap.value=G.state.spotLightMap,Ae.pointShadowMatrix.value=G.state.pointShadowMatrix;return B.lightProbeGrid=M.state.lightProbeGridArray.length>0,B.currentProgram=qe,B.uniformsList=null,qe}function Tf(b){if(b.uniformsList===null){let D=b.currentProgram.getUniforms();b.uniformsList=po.seqWithValue(D.seq,b.uniforms)}return b.uniformsList}function Af(b,D){let W=L.get(b);W.outputColorSpace=D.outputColorSpace,W.batching=D.batching,W.batchingColor=D.batchingColor,W.instancing=D.instancing,W.instancingColor=D.instancingColor,W.instancingMorph=D.instancingMorph,W.skinning=D.skinning,W.morphTargets=D.morphTargets,W.morphNormals=D.morphNormals,W.morphColors=D.morphColors,W.morphTargetsCount=D.morphTargetsCount,W.numClippingPlanes=D.numClippingPlanes,W.numIntersection=D.numClipIntersection,W.vertexAlphas=D.vertexAlphas,W.vertexTangents=D.vertexTangents,W.toneMapping=D.toneMapping}function gv(b,D){if(b.length===0)return null;if(b.length===1)return b[0].texture!==null?b[0]:null;R.setFromMatrixPosition(D.matrixWorld);for(let W=0,B=b.length;W<B;W++){let G=b[W];if(G.texture!==null&&G.boundingBox.containsPoint(R))return G}return null}function _v(b,D,W,B,G){if(D.isScene!==!0)D=cn;V.resetTextureUnits();let ge=D.fog,be=B.isMeshStandardMaterial||B.isMeshLambertMaterial||B.isMeshPhongMaterial?D.environment:null,me=C===null?S.outputColorSpace:C.isXRRenderTarget===!0?C.texture.colorSpace:$e.workingColorSpace,Te=B.isMeshStandardMaterial||B.isMeshLambertMaterial&&!B.envMap||B.isMeshPhongMaterial&&!B.envMap,Re=ie.get(B.envMap||be,Te),He=B.vertexColors===!0&&!!W.attributes.color&&W.attributes.color.itemSize===4,qe=!!W.attributes.tangent&&(!!B.normalMap||B.anisotropy>0),Ae=!!W.morphAttributes.position,rt=!!W.morphAttributes.normal,Lt=!!W.morphAttributes.color,vt=Hn;if(B.toneMapped){if(C===null||C.isXRRenderTarget===!0)vt=S.toneMapping}let ft=W.morphAttributes.position||W.morphAttributes.normal||W.morphAttributes.color,Yt=ft!==void 0?ft.length:0,ve=L.get(B),rn=M.state.lights;if(Ze===!0){if(st===!0||b!==k){let gt=b===k&&B.id===X;oe.setState(B,b,gt)}}let Ke=!1;if(B.version===ve.__version){if(ve.needsLights&&ve.lightsStateVersion!==rn.state.version)Ke=!0;else if(ve.outputColorSpace!==me)Ke=!0;else if(G.isBatchedMesh&&ve.batching===!1)Ke=!0;else if(!G.isBatchedMesh&&ve.batching===!0)Ke=!0;else if(G.isBatchedMesh&&ve.batchingColor===!0&&G._colorsTexture===null)Ke=!0;else if(G.isBatchedMesh&&ve.batchingColor===!1&&G._colorsTexture!==null)Ke=!0;else if(G.isInstancedMesh&&ve.instancing===!1)Ke=!0;else if(!G.isInstancedMesh&&ve.instancing===!0)Ke=!0;else if(G.isSkinnedMesh&&ve.skinning===!1)Ke=!0;else if(!G.isSkinnedMesh&&ve.skinning===!0)Ke=!0;else if(G.isInstancedMesh&&ve.instancingColor===!0&&G.instanceColor===null)Ke=!0;else if(G.isInstancedMesh&&ve.instancingColor===!1&&G.instanceColor!==null)Ke=!0;else if(G.isInstancedMesh&&ve.instancingMorph===!0&&G.morphTexture===null)Ke=!0;else if(G.isInstancedMesh&&ve.instancingMorph===!1&&G.morphTexture!==null)Ke=!0;else if(ve.envMap!==Re)Ke=!0;else if(B.fog===!0&&ve.fog!==ge)Ke=!0;else if(ve.numClippingPlanes!==void 0&&(ve.numClippingPlanes!==oe.numPlanes||ve.numIntersection!==oe.numIntersection))Ke=!0;else if(ve.vertexAlphas!==He)Ke=!0;else if(ve.vertexTangents!==qe)Ke=!0;else if(ve.morphTargets!==Ae)Ke=!0;else if(ve.morphNormals!==rt)Ke=!0;else if(ve.morphColors!==Lt)Ke=!0;else if(ve.toneMapping!==vt)Ke=!0;else if(ve.morphTargetsCount!==Yt)Ke=!0;else if(!!ve.lightProbeGrid!==M.state.lightProbeGridArray.length>0)Ke=!0}else Ke=!0,ve.__version=B.version;let Tn=ve.currentProgram;if(Ke===!0){if(Tn=Wo(B,D,G),P&&B.isNodeMaterial)P.onUpdateProgram(B,Tn,ve)}let Jn=!1,Ui=!1,kr=!1,lt=Tn.getUniforms(),Ct=ve.uniforms;if(w.useProgram(Tn.program))Jn=!0,Ui=!0,kr=!0;if(B.id!==X)X=B.id,Ui=!0;if(ve.needsLights){let gt=gv(M.state.lightProbeGridArray,G);if(ve.lightProbeGrid!==gt)ve.lightProbeGrid=gt,Ui=!0}if(Jn||k!==b){if(w.buffers.depth.getReversed()&&b.reversedDepth!==!0)b._reversedDepth=!0,b.updateProjectionMatrix();lt.setValue(N,"projectionMatrix",b.projectionMatrix),lt.setValue(N,"viewMatrix",b.matrixWorldInverse);let zi=lt.map.cameraPosition;if(zi!==void 0)zi.setValue(N,Zt.setFromMatrixPosition(b.matrixWorld));if(wt.logarithmicDepthBuffer)lt.setValue(N,"logDepthBufFC",2/(Math.log(b.far+1)/Math.LN2));if(B.isMeshPhongMaterial||B.isMeshToonMaterial||B.isMeshLambertMaterial||B.isMeshBasicMaterial||B.isMeshStandardMaterial||B.isShaderMaterial)lt.setValue(N,"isOrthographic",b.isOrthographicCamera===!0);if(k!==b)k=b,Ui=!0,kr=!0}if(ve.needsLights){if(rn.state.sunShadowMap.length>0)lt.setValue(N,"sunShadowMap",rn.state.sunShadowMap,V);if(rn.state.directionalShadowMap.length>0)lt.setValue(N,"directionalShadowMap",rn.state.directionalShadowMap,V);if(rn.state.spotShadowMap.length>0)lt.setValue(N,"spotShadowMap",rn.state.spotShadowMap,V);if(rn.state.pointShadowMap.length>0)lt.setValue(N,"pointShadowMap",rn.state.pointShadowMap,V)}if(G.isSkinnedMesh){lt.setOptional(N,G,"bindMatrix"),lt.setOptional(N,G,"bindMatrixInverse");let gt=G.skeleton;if(gt){if(gt.boneTexture===null)gt.computeBoneTexture();lt.setValue(N,"boneTexture",gt.boneTexture,V)}}if(G.isBatchedMesh){if(lt.setOptional(N,G,"batchingTexture"),lt.setValue(N,"batchingTexture",G._matricesTexture,V),lt.setOptional(N,G,"batchingIdTexture"),lt.setValue(N,"batchingIdTexture",G._indirectTexture,V),lt.setOptional(N,G,"batchingColorTexture"),G._colorsTexture!==null)lt.setValue(N,"batchingColorTexture",G._colorsTexture,V)}let Fi=W.morphAttributes;if(Fi.position!==void 0||Fi.normal!==void 0||Fi.color!==void 0)Qe.update(G,W,Tn);if(Ui||ve.receiveShadow!==G.receiveShadow)ve.receiveShadow=G.receiveShadow,lt.setValue(N,"receiveShadow",G.receiveShadow);if((B.isMeshStandardMaterial||B.isMeshLambertMaterial||B.isMeshPhongMaterial)&&B.envMap===null&&D.environment!==null)Ct.envMapIntensity.value=D.environmentIntensity;if(Ct.dfgLUT!==void 0)Ct.dfgLUT.value=fT();if(Ui){if(lt.setValue(N,"toneMappingExposure",S.toneMappingExposure),ve.needsLights)xv(Ct,kr);if(ge&&B.fog===!0)_e.refreshFogUniforms(Ct,ge);if(_e.refreshMaterialUniforms(Ct,B,re,Z,M.state.transmissionRenderTarget[b.id]),ve.needsLights&&ve.lightProbeGrid){let gt=ve.lightProbeGrid;Ct.probesSH.value=gt.texture,Ct.probesMin.value.copy(gt.boundingBox.min),Ct.probesMax.value.copy(gt.boundingBox.max),Ct.probesResolution.value.copy(gt.resolution)}po.upload(N,Tf(ve),Ct,V)}if(B.isShaderMaterial&&B.uniformsNeedUpdate===!0)po.upload(N,Tf(ve),Ct,V),B.uniformsNeedUpdate=!1;if(B.isSpriteMaterial)lt.setValue(N,"center",G.center);if(lt.setValue(N,"modelViewMatrix",G.modelViewMatrix),lt.setValue(N,"normalMatrix",G.normalMatrix),lt.setValue(N,"modelMatrix",G.matrixWorld),B.uniformsGroups!==void 0){let gt=B.uniformsGroups;for(let zi=0,Br=gt.length;zi<Br;zi++){let Cf=gt[zi];ye.update(Cf,Tn),ye.bind(Cf,Tn)}}return Tn}function xv(b,D){b.ambientLightColor.needsUpdate=D,b.lightProbe.needsUpdate=D,b.sunLights.needsUpdate=D,b.sunLightShadows.needsUpdate=D,b.directionalLights.needsUpdate=D,b.directionalLightShadows.needsUpdate=D,b.pointLights.needsUpdate=D,b.pointLightShadows.needsUpdate=D,b.spotLights.needsUpdate=D,b.spotLightShadows.needsUpdate=D,b.rectAreaLights.needsUpdate=D,b.hemisphereLights.needsUpdate=D}function yv(b){return b.isMeshLambertMaterial||b.isMeshToonMaterial||b.isMeshPhongMaterial||b.isMeshStandardMaterial||b.isShadowMaterial||b.isShaderMaterial&&b.lights===!0}this.getActiveCubeFace=function(){return H},this.getActiveMipmapLevel=function(){return q},this.getRenderTarget=function(){return C},this.setRenderTargetTextures=function(b,D,W){let B=L.get(b);if(B.__autoAllocateDepthBuffer=b.resolveDepthBuffer===!1,B.__autoAllocateDepthBuffer===!1)B.__useRenderToTexture=!1;L.get(b.texture).__webglTexture=D,L.get(b.depthTexture).__webglTexture=B.__autoAllocateDepthBuffer?void 0:W,B.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(b,D){let W=L.get(b);W.__webglFramebuffer=D,W.__useDefaultFramebuffer=D===void 0},this.setRenderTarget=function(b,D=0,W=0){C=b,H=D,q=W;let B=null,G=!1,ge=!1;if(b){let me=L.get(b);if(me.__useDefaultFramebuffer!==void 0){w.bindFramebuffer(N.FRAMEBUFFER,me.__webglFramebuffer),Y.copy(b.viewport),Q.copy(b.scissor),Se=b.scissorTest,w.viewport(Y),w.scissor(Q),w.setScissorTest(Se),X=-1;return}else if(me.__webglFramebuffer===void 0)V.setupRenderTarget(b);else if(me.__hasExternalTextures)V.rebindTextures(b,L.get(b.texture).__webglTexture,L.get(b.depthTexture).__webglTexture);else if(b.depthBuffer){let He=b.depthTexture;if(me.__boundDepthTexture!==He){if(He!==null&&L.has(He)&&(b.width!==He.image.width||b.height!==He.image.height))throw Error("THREE.WebGLRenderer: Attached DepthTexture is initialized to the incorrect size.");V.setupDepthRenderbuffer(b)}}let Te=b.texture;if(Te.isData3DTexture||Te.isDataArrayTexture||Te.isCompressedArrayTexture)ge=!0;let Re=L.get(b).__webglFramebuffer;if(b.isWebGLCubeRenderTarget){if(Array.isArray(Re[D]))B=Re[D][W];else B=Re[D];G=!0}else if(b.samples>0&&V.useMultisampledRTT(b)===!1)B=L.get(b).__webglMultisampledFramebuffer;else if(Array.isArray(Re))B=Re[W];else B=Re;Y.copy(b.viewport),Q.copy(b.scissor),Se=b.scissorTest}else Y.copy(we).multiplyScalar(re).floor(),Q.copy(Ee).multiplyScalar(re).floor(),Se=xt;if(W!==0)B=F;if(w.bindFramebuffer(N.FRAMEBUFFER,B))w.drawBuffers(b,B);if(w.viewport(Y),w.scissor(Q),w.setScissorTest(Se),G){let me=L.get(b.texture);N.framebufferTexture2D(N.FRAMEBUFFER,N.COLOR_ATTACHMENT0,N.TEXTURE_CUBE_MAP_POSITIVE_X+D,me.__webglTexture,W)}else if(ge){let me=D;for(let Te=0;Te<b.textures.length;Te++){let Re=L.get(b.textures[Te]);N.framebufferTextureLayer(N.FRAMEBUFFER,N.COLOR_ATTACHMENT0+Te,Re.__webglTexture,W,me)}}else if(b!==null&&W!==0){let me=L.get(b.texture);N.framebufferTexture2D(N.FRAMEBUFFER,N.COLOR_ATTACHMENT0,N.TEXTURE_2D,me.__webglTexture,W)}X=-1};function Rf(b){let D=L.get(b);if(D.__readFormat!==b.format||D.__readType!==b.type)D.__readFormat=b.format,D.__readType=b.type,D.__formatReadable=wt.textureFormatReadable(b.format),D.__typeReadable=wt.textureTypeReadable(b.type);return D}if(this.readRenderTargetPixels=function(b,D,W,B,G,ge,be,me=0){if(!(b&&b.isWebGLRenderTarget)){Ue("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Te=L.get(b).__webglFramebuffer;if(b.isWebGLCubeRenderTarget&&be!==void 0)Te=Te[be];if(Te){w.bindFramebuffer(N.FRAMEBUFFER,Te);try{let Re=b.textures[me],{format:He,type:qe}=Re;if(b.textures.length>1)N.readBuffer(N.COLOR_ATTACHMENT0+me);let Ae=Rf(Re);if(Ae.__formatReadable===!1){Ue("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(Ae.__typeReadable===!1){Ue("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}if(D>=0&&D<=b.width-B&&(W>=0&&W<=b.height-G))N.readPixels(D,W,B,G,K.convert(He),K.convert(qe),ge)}finally{let Re=C!==null?L.get(C).__webglFramebuffer:null;w.bindFramebuffer(N.FRAMEBUFFER,Re)}}},this.readRenderTargetPixelsAsync=async function(b,D,W,B,G,ge,be,me=0){if(!(b&&b.isWebGLRenderTarget))throw Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Te=L.get(b).__webglFramebuffer;if(b.isWebGLCubeRenderTarget&&be!==void 0)Te=Te[be];if(Te)if(D>=0&&D<=b.width-B&&(W>=0&&W<=b.height-G)){w.bindFramebuffer(N.FRAMEBUFFER,Te);let Re=b.textures[me],{format:He,type:qe}=Re;if(b.textures.length>1)N.readBuffer(N.COLOR_ATTACHMENT0+me);let Ae=Rf(Re);if(Ae.__formatReadable===!1)throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(Ae.__typeReadable===!1)throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");let rt=N.createBuffer();N.bindBuffer(N.PIXEL_PACK_BUFFER,rt),N.bufferData(N.PIXEL_PACK_BUFFER,ge.byteLength,N.STREAM_READ),N.readPixels(D,W,B,G,K.convert(He),K.convert(qe),0),N.bindBuffer(N.PIXEL_PACK_BUFFER,null);let Lt=C!==null?L.get(C).__webglFramebuffer:null;w.bindFramebuffer(N.FRAMEBUFFER,Lt);let vt=N.fenceSync(N.SYNC_GPU_COMMANDS_COMPLETE,0);return N.flush(),await lp(N,vt,4),N.bindBuffer(N.PIXEL_PACK_BUFFER,rt),N.getBufferSubData(N.PIXEL_PACK_BUFFER,0,ge),N.bindBuffer(N.PIXEL_PACK_BUFFER,null),N.deleteBuffer(rt),N.deleteSync(vt),ge}else throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(b,D=null,W=0){let B=Math.pow(2,-W),G=Math.floor(b.image.width*B),ge=Math.floor(b.image.height*B),be=D!==null?D.x:0,me=D!==null?D.y:0;V.setTexture2D(b,0),N.copyTexSubImage2D(N.TEXTURE_2D,W,0,0,be,me,G,ge),w.unbindTexture()},this.copyTextureToTexture=function(b,D,W=null,B=null,G=0,ge=0){let be,me,Te,Re,He,qe,Ae,rt,Lt,vt=b.isCompressedTexture?b.mipmaps[ge]:b.image;if(W!==null)be=W.max.x-W.min.x,me=W.max.y-W.min.y,Te=W.isBox3?W.max.z-W.min.z:1,Re=W.min.x,He=W.min.y,qe=W.isBox3?W.min.z:0;else{let Ct=Math.pow(2,-G);if(be=Math.floor(vt.width*Ct),me=Math.floor(vt.height*Ct),b.isDataArrayTexture)Te=vt.depth;else if(b.isData3DTexture)Te=Math.floor(vt.depth*Ct);else Te=1;Re=0,He=0,qe=0}if(B!==null)Ae=B.x,rt=B.y,Lt=B.z;else Ae=0,rt=0,Lt=0;let ft=K.convert(D.format),Yt=K.convert(D.type),ve;if(D.isData3DTexture)V.setTexture3D(D,0),ve=N.TEXTURE_3D;else if(D.isDataArrayTexture||D.isCompressedArrayTexture)V.setTexture2DArray(D,0),ve=N.TEXTURE_2D_ARRAY;else V.setTexture2D(D,0),ve=N.TEXTURE_2D;w.activeTexture(N.TEXTURE0),w.pixelStorei(N.UNPACK_FLIP_Y_WEBGL,D.flipY),w.pixelStorei(N.UNPACK_PREMULTIPLY_ALPHA_WEBGL,D.premultiplyAlpha),w.pixelStorei(N.UNPACK_ALIGNMENT,D.unpackAlignment);let rn=w.getParameter(N.UNPACK_ROW_LENGTH),Ke=w.getParameter(N.UNPACK_IMAGE_HEIGHT),Tn=w.getParameter(N.UNPACK_SKIP_PIXELS),Jn=w.getParameter(N.UNPACK_SKIP_ROWS),Ui=w.getParameter(N.UNPACK_SKIP_IMAGES);w.pixelStorei(N.UNPACK_ROW_LENGTH,vt.width),w.pixelStorei(N.UNPACK_IMAGE_HEIGHT,vt.height),w.pixelStorei(N.UNPACK_SKIP_PIXELS,Re),w.pixelStorei(N.UNPACK_SKIP_ROWS,He),w.pixelStorei(N.UNPACK_SKIP_IMAGES,qe);let kr=b.isDataArrayTexture||b.isData3DTexture,lt=D.isDataArrayTexture||D.isData3DTexture;if(b.isDepthTexture){let Ct=L.get(b),Fi=L.get(D),gt=L.get(Ct.__renderTarget),zi=L.get(Fi.__renderTarget);w.bindFramebuffer(N.READ_FRAMEBUFFER,gt.__webglFramebuffer),w.bindFramebuffer(N.DRAW_FRAMEBUFFER,zi.__webglFramebuffer);for(let Br=0;Br<Te;Br++){if(kr)N.framebufferTextureLayer(N.READ_FRAMEBUFFER,N.COLOR_ATTACHMENT0,L.get(b).__webglTexture,G,qe+Br),N.framebufferTextureLayer(N.DRAW_FRAMEBUFFER,N.COLOR_ATTACHMENT0,L.get(D).__webglTexture,ge,Lt+Br);N.blitFramebuffer(Re,He,be,me,Ae,rt,be,me,N.DEPTH_BUFFER_BIT,N.NEAREST)}w.bindFramebuffer(N.READ_FRAMEBUFFER,null),w.bindFramebuffer(N.DRAW_FRAMEBUFFER,null)}else if(G!==0||b.isRenderTargetTexture||L.has(b)){let Ct=L.get(b),Fi=L.get(D);w.bindFramebuffer(N.READ_FRAMEBUFFER,ee),w.bindFramebuffer(N.DRAW_FRAMEBUFFER,I);for(let gt=0;gt<Te;gt++){if(kr)N.framebufferTextureLayer(N.READ_FRAMEBUFFER,N.COLOR_ATTACHMENT0,Ct.__webglTexture,G,qe+gt);else N.framebufferTexture2D(N.READ_FRAMEBUFFER,N.COLOR_ATTACHMENT0,N.TEXTURE_2D,Ct.__webglTexture,G);if(lt)N.framebufferTextureLayer(N.DRAW_FRAMEBUFFER,N.COLOR_ATTACHMENT0,Fi.__webglTexture,ge,Lt+gt);else N.framebufferTexture2D(N.DRAW_FRAMEBUFFER,N.COLOR_ATTACHMENT0,N.TEXTURE_2D,Fi.__webglTexture,ge);if(G!==0)N.blitFramebuffer(Re,He,be,me,Ae,rt,be,me,N.COLOR_BUFFER_BIT,N.NEAREST);else if(lt)N.copyTexSubImage3D(ve,ge,Ae,rt,Lt+gt,Re,He,be,me);else N.copyTexSubImage2D(ve,ge,Ae,rt,Re,He,be,me)}w.bindFramebuffer(N.READ_FRAMEBUFFER,null),w.bindFramebuffer(N.DRAW_FRAMEBUFFER,null)}else if(lt)if(b.isDataTexture||b.isData3DTexture)N.texSubImage3D(ve,ge,Ae,rt,Lt,be,me,Te,ft,Yt,vt.data);else if(D.isCompressedArrayTexture)N.compressedTexSubImage3D(ve,ge,Ae,rt,Lt,be,me,Te,ft,vt.data);else N.texSubImage3D(ve,ge,Ae,rt,Lt,be,me,Te,ft,Yt,vt);else if(b.isDataTexture)N.texSubImage2D(N.TEXTURE_2D,ge,Ae,rt,be,me,ft,Yt,vt.data);else if(b.isCompressedTexture)N.compressedTexSubImage2D(N.TEXTURE_2D,ge,Ae,rt,vt.width,vt.height,ft,vt.data);else N.texSubImage2D(N.TEXTURE_2D,ge,Ae,rt,be,me,ft,Yt,vt);if(w.pixelStorei(N.UNPACK_ROW_LENGTH,rn),w.pixelStorei(N.UNPACK_IMAGE_HEIGHT,Ke),w.pixelStorei(N.UNPACK_SKIP_PIXELS,Tn),w.pixelStorei(N.UNPACK_SKIP_ROWS,Jn),w.pixelStorei(N.UNPACK_SKIP_IMAGES,Ui),ge===0&&D.generateMipmaps)N.generateMipmap(ve);w.unbindTexture()},this.initRenderTarget=function(b){if(L.get(b).__webglFramebuffer===void 0)V.setupRenderTarget(b)},this.initTexture=function(b){if(b.isCubeTexture)V.setTextureCube(b,0);else if(b.isData3DTexture)V.setTexture3D(b,0);else if(b.isDataArrayTexture||b.isCompressedArrayTexture)V.setTexture2DArray(b,0);else V.setTexture2D(b,0);w.unbindTexture()},this.resetState=function(){H=0,q=0,C=null,w.reset(),le.reset()},typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return hu}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;let t=this.getContext();t.drawingBufferColorSpace=$e._getDrawingBufferColorSpace(e),t.unpackColorSpace=$e._getUnpackColorSpace()}}var nm={type:"change"},Wu={type:"start"},rm={type:"end"},tc=new Ki,im=new Rn,dT=Math.cos(70*js.DEG2RAD),Bt=new O,fn=2*Math.PI,ct={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},$u=0.000001;class Zu extends Ya{constructor(e,t=null){super(e,t);if(this.state=ct.NONE,this.target=new O,this.cursor=new O,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=0.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.keyRotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:Zi.ROTATE,MIDDLE:Zi.DOLLY,RIGHT:Zi.PAN},this.touches={ONE:Xi.ROTATE,TWO:Xi.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._cursorStyle="auto",this._domElementKeyEvents=null,this._lastPosition=new O,this._lastQuaternion=new Ht,this._lastTargetPosition=new O,this._quat=new Ht().setFromUnitVectors(e.up,new O(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new lo,this._sphericalDelta=new lo,this._scale=1,this._panOffset=new O,this._rotateStart=new Ne,this._rotateEnd=new Ne,this._rotateDelta=new Ne,this._panStart=new Ne,this._panEnd=new Ne,this._panDelta=new Ne,this._dollyStart=new Ne,this._dollyEnd=new Ne,this._dollyDelta=new Ne,this._dollyDirection=new O,this._mouse=new Ne,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=mT.bind(this),this._onPointerDown=pT.bind(this),this._onPointerUp=gT.bind(this),this._onContextMenu=MT.bind(this),this._onMouseWheel=yT.bind(this),this._onKeyDown=vT.bind(this),this._onTouchStart=bT.bind(this),this._onTouchMove=ST.bind(this),this._onMouseDown=_T.bind(this),this._onMouseMove=xT.bind(this),this._interceptControlDown=wT.bind(this),this._interceptControlUp=ET.bind(this),this.domElement!==null)this.connect(this.domElement);this.update()}set cursorStyle(e){if(this._cursorStyle=e,e==="grab")this.domElement.style.cursor="grab";else this.domElement.style.cursor="auto"}get cursorStyle(){return this._cursorStyle}connect(e){super.connect(e),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.state=ct.NONE,this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents();let e=this.domElement.getRootNode();e.removeEventListener("keydown",this._interceptControlDown,{capture:!0}),e.removeEventListener("keyup",this._interceptControlUp,{capture:!0}),this._controlActive=!1,this._pointers.length=0,this._pointerPositions={},this.domElement.style.touchAction="",this.domElement.style.cursor="auto"}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(e){e.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=e}stopListenToKeyEvents(){if(this._domElementKeyEvents!==null)this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(nm),this.update(),this.state=ct.NONE}pan(e,t){this._pan(e,t),this.update()}dollyIn(e){this._dollyIn(e),this.update()}dollyOut(e){this._dollyOut(e),this.update()}rotateLeft(e){this._rotateLeft(e),this.update()}rotateUp(e){this._rotateUp(e),this.update()}update(e=null){let t=this.object.position;if(Bt.copy(t).sub(this.target),Bt.applyQuaternion(this._quat),this._spherical.setFromVector3(Bt),this.autoRotate&&this.state===ct.NONE)this._rotateLeft(this._getAutoRotationAngle(e));if(this.enableDamping)this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor;else this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi;let n=this.minAzimuthAngle,i=this.maxAzimuthAngle;if(isFinite(n)&&isFinite(i)){if(n<-Math.PI)n+=fn;else if(n>Math.PI)n-=fn;if(i<-Math.PI)i+=fn;else if(i>Math.PI)i-=fn;if(n<=i)this._spherical.theta=Math.max(n,Math.min(i,this._spherical.theta));else this._spherical.theta=this._spherical.theta>(n+i)/2?Math.max(n,this._spherical.theta):Math.min(i,this._spherical.theta)}if(this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0)this.target.addScaledVector(this._panOffset,this.dampingFactor);else this.target.add(this._panOffset);this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let r=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{let s=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),r=s!=this._spherical.radius}if(Bt.setFromSpherical(this._spherical),Bt.applyQuaternion(this._quatInverse),t.copy(this.target).add(Bt),this.object.lookAt(this.target),this.enableDamping===!0)this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor);else this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0);if(this.zoomToCursor&&this._performCursorZoom){let s=null;if(this.object.isPerspectiveCamera){let o=Bt.length();s=this._clampDistance(o*this._scale);let a=o-s;this.object.position.addScaledVector(this._dollyDirection,a),this.object.updateMatrixWorld(),r=!!a}else if(this.object.isOrthographicCamera){let o=new O(this._mouse.x,this._mouse.y,0);o.unproject(this.object);let a=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),r=a!==this.object.zoom;let c=new O(this._mouse.x,this._mouse.y,0);c.unproject(this.object),this.object.position.sub(c).add(o),this.object.updateMatrixWorld(),s=Bt.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;if(s!==null)if(this.screenSpacePanning)this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(s).add(this.object.position);else if(tc.origin.copy(this.object.position),tc.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(tc.direction))<dT)this.object.lookAt(this.target);else im.setFromNormalAndCoplanarPoint(this.object.up,this.target),tc.intersectPlane(im,this.target)}else if(this.object.isOrthographicCamera){let s=this.object.zoom;if(this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),s!==this.object.zoom)this.object.updateProjectionMatrix(),r=!0}if(this._scale=1,this._performCursorZoom=!1,r||this._lastPosition.distanceToSquared(this.object.position)>$u||8*(1-this._lastQuaternion.dot(this.object.quaternion))>$u||this._lastTargetPosition.distanceToSquared(this.target)>$u)return this.dispatchEvent(nm),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0;return!1}_getAutoRotationAngle(e){if(e!==null)return fn/60*this.autoRotateSpeed*e;else return fn/60/60*this.autoRotateSpeed}_getZoomScale(e){let t=Math.abs(e*0.01);return Math.pow(0.95,this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){Bt.setFromMatrixColumn(t,0),Bt.multiplyScalar(-e),this._panOffset.add(Bt)}_panUp(e,t){if(this.screenSpacePanning===!0)Bt.setFromMatrixColumn(t,1);else Bt.setFromMatrixColumn(t,0),Bt.crossVectors(this.object.up,Bt);Bt.multiplyScalar(e),this._panOffset.add(Bt)}_pan(e,t){let n=this.domElement;if(this.object.isPerspectiveCamera){let i=this.object.position;Bt.copy(i).sub(this.target);let r=Bt.length();r*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*r/n.clientHeight,this.object.matrix),this._panUp(2*t*r/n.clientHeight,this.object.matrix)}else if(this.object.isOrthographicCamera)this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/n.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/n.clientHeight,this.object.matrix);else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1}_dollyOut(e){if(this.object.isPerspectiveCamera||this.object.isOrthographicCamera)this._scale/=e;else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1}_dollyIn(e){if(this.object.isPerspectiveCamera||this.object.isOrthographicCamera)this._scale*=e;else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;let n=this.domElement.getBoundingClientRect(),i=e-n.left,r=t-n.top,{width:s,height:o}=n;this._mouse.x=i/s*2-1,this._mouse.y=-(r/o)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);let t=this.domElement;this._rotateLeft(fn*this._rotateDelta.x/t.clientHeight),this._rotateUp(fn*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){if(this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0)this._dollyOut(this._getZoomScale(this._dollyDelta.y));else if(this._dollyDelta.y<0)this._dollyIn(this._getZoomScale(this._dollyDelta.y));this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){if(this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0)this._dollyIn(this._getZoomScale(e.deltaY));else if(e.deltaY>0)this._dollyOut(this._getZoomScale(e.deltaY));this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enableRotate)this._rotateUp(fn*this.keyRotateSpeed/this.domElement.clientHeight)}else if(this.enablePan)this._pan(0,this.keyPanSpeed);t=!0;break;case this.keys.BOTTOM:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enableRotate)this._rotateUp(-fn*this.keyRotateSpeed/this.domElement.clientHeight)}else if(this.enablePan)this._pan(0,-this.keyPanSpeed);t=!0;break;case this.keys.LEFT:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enableRotate)this._rotateLeft(fn*this.keyRotateSpeed/this.domElement.clientHeight)}else if(this.enablePan)this._pan(this.keyPanSpeed,0);t=!0;break;case this.keys.RIGHT:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enableRotate)this._rotateLeft(-fn*this.keyRotateSpeed/this.domElement.clientHeight)}else if(this.enablePan)this._pan(-this.keyPanSpeed,0);t=!0;break}if(t)e.preventDefault(),this.update()}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=0.5*(e.pageX+t.x),i=0.5*(e.pageY+t.y);this._rotateStart.set(n,i)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=0.5*(e.pageX+t.x),i=0.5*(e.pageY+t.y);this._panStart.set(n,i)}}_handleTouchStartDolly(e){let t=this._getSecondPointerPosition(e),n=e.pageX-t.x,i=e.pageY-t.y,r=Math.sqrt(n*n+i*i);this._dollyStart.set(0,r)}_handleTouchStartDollyPan(e){if(this.enableZoom)this._handleTouchStartDolly(e);if(this.enablePan)this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){if(this.enableZoom)this._handleTouchStartDolly(e);if(this.enableRotate)this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{let n=this._getSecondPointerPosition(e),i=0.5*(e.pageX+n.x),r=0.5*(e.pageY+n.y);this._rotateEnd.set(i,r)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);let t=this.domElement;this._rotateLeft(fn*this._rotateDelta.x/t.clientHeight),this._rotateUp(fn*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=0.5*(e.pageX+t.x),i=0.5*(e.pageY+t.y);this._panEnd.set(n,i)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){let t=this._getSecondPointerPosition(e),n=e.pageX-t.x,i=e.pageY-t.y,r=Math.sqrt(n*n+i*i);this._dollyEnd.set(0,r),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);let s=(e.pageX+t.x)*0.5,o=(e.pageY+t.y)*0.5;this._updateZoomParameters(s,o)}_handleTouchMoveDollyPan(e){if(this.enableZoom)this._handleTouchMoveDolly(e);if(this.enablePan)this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){if(this.enableZoom)this._handleTouchMoveDolly(e);if(this.enableRotate)this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId){this._pointers.splice(t,1);return}}_isTrackingPointer(e){for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId)return!0;return!1}_trackPointer(e){let t=this._pointerPositions[e.pointerId];if(t===void 0)t=new Ne,this._pointerPositions[e.pointerId]=t;t.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){let t=e.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[t]}_customWheelEvent(e){let t=e.deltaMode,n={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(t){case 1:n.deltaY*=16;break;case 2:n.deltaY*=100;break}if(e.ctrlKey&&!this._controlActive)n.deltaY*=10;return n}}function pT(e){if(this.enabled===!1)return;if(this._pointers.length===0)this.domElement.setPointerCapture(e.pointerId),this.domElement.ownerDocument.addEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this._onPointerUp);if(this._isTrackingPointer(e))return;if(this._addPointer(e),e.pointerType==="touch")this._onTouchStart(e);else this._onMouseDown(e);if(this._cursorStyle==="grab")this.domElement.style.cursor="grabbing"}function mT(e){if(this.enabled===!1)return;if(e.pointerType==="touch")this._onTouchMove(e);else this._onMouseMove(e)}function gT(e){switch(this._removePointer(e),this._pointers.length){case 0:if(this.domElement.releasePointerCapture(e.pointerId),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(rm),this.state=ct.NONE,this._cursorStyle==="grab")this.domElement.style.cursor="grab";break;case 1:let t=this._pointers[0],n=this._pointerPositions[t];this._onTouchStart({pointerId:t,pageX:n.x,pageY:n.y});break}}function _T(e){let t;switch(e.button){case 0:t=this.mouseButtons.LEFT;break;case 1:t=this.mouseButtons.MIDDLE;break;case 2:t=this.mouseButtons.RIGHT;break;default:t=-1}switch(t){case Zi.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(e),this.state=ct.DOLLY;break;case Zi.ROTATE:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(e),this.state=ct.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(e),this.state=ct.ROTATE}break;case Zi.PAN:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(e),this.state=ct.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(e),this.state=ct.PAN}break;default:this.state=ct.NONE}if(this.state!==ct.NONE)this.dispatchEvent(Wu)}function xT(e){switch(this.state){case ct.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(e);break;case ct.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(e);break;case ct.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(e);break}}function yT(e){if(this.enabled===!1||this.enableZoom===!1||this.state!==ct.NONE)return;e.preventDefault(),this.dispatchEvent(Wu),this._handleMouseWheel(this._customWheelEvent(e)),this.dispatchEvent(rm)}function vT(e){if(this.enabled===!1)return;this._handleKeyDown(e)}function bT(e){switch(this._trackPointer(e),this._pointers.length){case 1:switch(this.touches.ONE){case Xi.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(e),this.state=ct.TOUCH_ROTATE;break;case Xi.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(e),this.state=ct.TOUCH_PAN;break;default:this.state=ct.NONE}break;case 2:switch(this.touches.TWO){case Xi.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(e),this.state=ct.TOUCH_DOLLY_PAN;break;case Xi.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(e),this.state=ct.TOUCH_DOLLY_ROTATE;break;default:this.state=ct.NONE}break;default:this.state=ct.NONE}if(this.state!==ct.NONE)this.dispatchEvent(Wu)}function ST(e){switch(this._trackPointer(e),this.state){case ct.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(e),this.update();break;case ct.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(e),this.update();break;case ct.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(e),this.update();break;case ct.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(e),this.update();break;default:this.state=ct.NONE}}function MT(e){if(this.enabled===!1)return;e.preventDefault()}function wT(e){if(e.key==="Control")this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0})}function ET(e){if(e.key==="Control")this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0})}class Xu extends ds{constructor(){super();this.name="RoomEnvironment",this.position.y=-3.5;let e=new Qi;e.deleteAttribute("uv");let t=new Ci({side:Qt}),n=new Ci,i=new ys(16777215,900,28,2);i.position.set(0.418,16.199,0.3),this.add(i);let r=new _t(e,t);r.position.set(-0.757,13.219,0.717),r.scale.set(31.713,28.305,28.591),this.add(r);let s=new ms(e,n,6),o=new ut;o.position.set(-10.906,2.009,1.846),o.rotation.set(0,-0.195,0),o.scale.set(2.328,7.905,4.651),o.updateMatrix(),s.setMatrixAt(0,o.matrix),o.position.set(-5.607,-0.754,-0.758),o.rotation.set(0,0.994,0),o.scale.set(1.97,1.534,3.955),o.updateMatrix(),s.setMatrixAt(1,o.matrix),o.position.set(6.167,0.857,7.803),o.rotation.set(0,0.561,0),o.scale.set(3.927,6.285,3.687),o.updateMatrix(),s.setMatrixAt(2,o.matrix),o.position.set(-2.017,0.018,6.124),o.rotation.set(0,0.333,0),o.scale.set(2.002,4.566,2.064),o.updateMatrix(),s.setMatrixAt(3,o.matrix),o.position.set(2.291,-0.756,-2.621),o.rotation.set(0,-0.286,0),o.scale.set(1.546,1.552,1.496),o.updateMatrix(),s.setMatrixAt(4,o.matrix),o.position.set(-2.193,-0.369,-5.547),o.rotation.set(0,0.516,0),o.scale.set(3.875,3.487,2.986),o.updateMatrix(),s.setMatrixAt(5,o.matrix),this.add(s);let a=new _t(e,ws(50));a.position.set(-16.116,14.37,8.208),a.scale.set(0.1,2.428,2.739),this.add(a);let c=new _t(e,ws(50));c.position.set(-16.109,18.021,-8.207),c.scale.set(0.1,2.425,2.751),this.add(c);let l=new _t(e,ws(17));l.position.set(14.904,12.198,-1.832),l.scale.set(0.15,4.265,6.331),this.add(l);let u=new _t(e,ws(43));u.position.set(-0.462,8.89,14.52),u.scale.set(4.38,5.441,0.088),this.add(u);let f=new _t(e,ws(20));f.position.set(3.235,11.486,-12.541),f.scale.set(2.5,2,0.1),this.add(f);let h=new _t(e,ws(100));h.position.set(0,20,0),h.scale.set(1,0.1,1),this.add(h)}dispose(){let e=new Set;this.traverse((t)=>{if(t.isMesh)e.add(t.geometry),e.add(t.material)});for(let t of e)t.dispose()}}function ws(e){return new Ha({color:0,emissive:16777215,emissiveIntensity:e})}function qu(e,t){if(t===au)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),e;if(t===fs||t===qs){let n=e.getIndex();if(n===null){let s=[],o=e.getAttribute("position");if(o!==void 0){for(let a=0;a<o.count;a++)s.push(a);e.setIndex(s),n=e.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),e}let i=n.count-2,r=[];if(t===fs)for(let s=1;s<=i;s++)r.push(n.getX(0)),r.push(n.getX(s)),r.push(n.getX(s+1));else for(let s=0;s<i;s++)if(s%2===0)r.push(n.getX(s)),r.push(n.getX(s+1)),r.push(n.getX(s+2));else r.push(n.getX(s+2)),r.push(n.getX(s+1)),r.push(n.getX(s));if(r.length/3!==i)console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");return e.setIndex(r),e.clearGroups(),e}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",t),e}function sm(e){let t=new Map,n=new Map,i=e.clone();return om(e,i,function(r,s){t.set(s,r),n.set(r,s)}),i.traverse(function(r){if(!r.isSkinnedMesh)return;let s=r,o=t.get(r),a=o.skeleton.bones;s.skeleton=o.skeleton.clone(),s.bindMatrix.copy(o.bindMatrix),s.skeleton.bones=a.map(function(c){return n.get(c)}),s.bind(s.skeleton,s.bindMatrix)}),i}function om(e,t,n){n(e,t);for(let i=0;i<e.children.length;i++)om(e.children[i],t.children[i],n)}class th extends Ii{constructor(e){super(e);this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new pm(t)}),this.register(function(t){return new mm(t)}),this.register(function(t){return new wm(t)}),this.register(function(t){return new Em(t)}),this.register(function(t){return new Tm(t)}),this.register(function(t){return new _m(t)}),this.register(function(t){return new xm(t)}),this.register(function(t){return new ym(t)}),this.register(function(t){return new vm(t)}),this.register(function(t){return new dm(t)}),this.register(function(t){return new bm(t)}),this.register(function(t){return new gm(t)}),this.register(function(t){return new Mm(t)}),this.register(function(t){return new Sm(t)}),this.register(function(t){return new hm(t)}),this.register(function(t){return new Ju(t,Xe.EXT_MESHOPT_COMPRESSION)}),this.register(function(t){return new Ju(t,Xe.KHR_MESHOPT_COMPRESSION)}),this.register(function(t){return new Am(t)})}load(e,t,n,i){let r=this,s;if(this.resourcePath!=="")s=this.resourcePath;else if(this.path!==""){let c=rr.extractUrlBase(e);s=rr.resolveURL(c,this.path)}else s=rr.extractUrlBase(e);this.manager.itemStart(e);let o=function(c){if(i)i(c);else console.error(c);r.manager.itemError(e),r.manager.itemEnd(e)},a=new ao(this.manager);a.setPath(this.path),a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(c){try{r.parse(c,s,function(l){t(l),r.manager.itemEnd(e)},o)}catch(l){o(l)}},n,o)}setDRACOLoader(e){return this.dracoLoader=e,this}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){if(this.pluginCallbacks.indexOf(e)===-1)this.pluginCallbacks.push(e);return this}unregister(e){if(this.pluginCallbacks.indexOf(e)!==-1)this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1);return this}parse(e,t,n,i){let r,s={},o={},a=new TextDecoder;if(typeof e==="string")r=JSON.parse(e);else if(e instanceof ArrayBuffer)if(a.decode(new Uint8Array(e,0,4))===Rm){try{s[Xe.KHR_BINARY_GLTF]=new Cm(e)}catch(u){if(i)i(u);return}r=JSON.parse(s[Xe.KHR_BINARY_GLTF].content)}else r=JSON.parse(a.decode(e));else r=e;if(r.asset===void 0||r.asset.version[0]<2){if(i)i(Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}let c=new Dm(r,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let l=0;l<this.pluginCallbacks.length;l++){let u=this.pluginCallbacks[l](c);if(!u.name)console.error("THREE.GLTFLoader: Invalid plugin found: missing name");o[u.name]=u,s[u.name]=!0}if(r.extensionsUsed)for(let l=0;l<r.extensionsUsed.length;++l){let u=r.extensionsUsed[l],f=r.extensionsRequired||[];switch(u){case Xe.KHR_MATERIALS_UNLIT:s[u]=new fm;break;case Xe.KHR_DRACO_MESH_COMPRESSION:s[u]=new Pm(r,this.dracoLoader);break;case Xe.KHR_TEXTURE_TRANSFORM:s[u]=new Im;break;case Xe.KHR_MESH_QUANTIZATION:s[u]=new Lm;break;default:if(f.indexOf(u)>=0&&o[u]===void 0)console.warn('THREE.GLTFLoader: Unknown extension "'+u+'".')}}c.setExtensions(s),c.setPlugins(o),c.parse(n,i)}parseAsync(e,t){let n=this;return new Promise(function(i,r){n.parse(e,t,i,r)})}}function TT(){let e={};return{get:function(t){return e[t]},add:function(t,n){e[t]=n},remove:function(t){delete e[t]},removeAll:function(){e={}}}}function Pt(e,t,n){let i=e.json.materials[t];if(i.extensions&&i.extensions[n])return i.extensions[n];return null}var Xe={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",KHR_MESHOPT_COMPRESSION:"KHR_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class hm{constructor(e){this.parser=e,this.name=Xe.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){let e=this.parser,t=this.parser.json.nodes||[];for(let n=0,i=t.length;n<i;n++){let r=t[n];if(r.extensions&&r.extensions[this.name]&&r.extensions[this.name].light!==void 0)e._addNodeRef(this.cache,r.extensions[this.name].light)}}_loadLight(e){let t=this.parser,n="light:"+e,i=t.cache.get(n);if(i)return i;let r=t.json,a=((r.extensions&&r.extensions[this.name]||{}).lights||[])[e],c,l=new Oe(16777215);if(a.color!==void 0)l.setRGB(a.color[0],a.color[1],a.color[2],gn);let u=a.range!==void 0?a.range:0;switch(a.type){case"directional":c=new vs(l),c.target.position.set(0,0,-1),c.add(c.target);break;case"point":c=new ys(l),c.distance=u;break;case"spot":c=new Xa(l),c.distance=u,a.spot=a.spot||{},a.spot.innerConeAngle=a.spot.innerConeAngle!==void 0?a.spot.innerConeAngle:0,a.spot.outerConeAngle=a.spot.outerConeAngle!==void 0?a.spot.outerConeAngle:Math.PI/4,c.angle=a.spot.outerConeAngle,c.penumbra=1-a.spot.innerConeAngle/a.spot.outerConeAngle,c.target.position.set(0,0,-1),c.add(c.target);break;default:throw Error("THREE.GLTFLoader: Unexpected light type: "+a.type)}if(c.position.set(0,0,0),ui(c,a),a.intensity!==void 0)c.intensity=a.intensity;return c.name=t.createUniqueName(a.name||"light_"+e),i=Promise.resolve(c),t.cache.add(n,i),i}getDependency(e,t){if(e!=="light")return;return this._loadLight(t)}createNodeAttachment(e){let t=this,n=this.parser,r=n.json.nodes[e],o=(r.extensions&&r.extensions[this.name]||{}).light;if(o===void 0)return null;return this._loadLight(o).then(function(a){return n._getNodeRef(t.cache,o,a)})}}class fm{constructor(){this.name=Xe.KHR_MATERIALS_UNLIT}getMaterialType(){return ai}extendParams(e,t,n){let i=[];e.color=new Oe(1,1,1),e.opacity=1;let r=t.pbrMetallicRoughness;if(r){if(Array.isArray(r.baseColorFactor)){let s=r.baseColorFactor;e.color.setRGB(s[0],s[1],s[2],gn),e.opacity=s[3]}if(r.baseColorTexture!==void 0)i.push(n.assignTexture(e,"map",r.baseColorTexture,Yi))}return Promise.all(i)}}class dm{constructor(e){this.parser=e,this.name=Xe.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){let n=Pt(this.parser,e,this.name);if(n===null)return Promise.resolve();if(n.emissiveStrength!==void 0)t.emissiveIntensity=n.emissiveStrength;return Promise.resolve()}}class pm{constructor(e){this.parser=e,this.name=Xe.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){return Pt(this.parser,e,this.name)!==null?yn:null}extendMaterialParams(e,t){let n=Pt(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(n.clearcoatFactor!==void 0)t.clearcoat=n.clearcoatFactor;if(n.clearcoatTexture!==void 0)i.push(this.parser.assignTexture(t,"clearcoatMap",n.clearcoatTexture));if(n.clearcoatRoughnessFactor!==void 0)t.clearcoatRoughness=n.clearcoatRoughnessFactor;if(n.clearcoatRoughnessTexture!==void 0)i.push(this.parser.assignTexture(t,"clearcoatRoughnessMap",n.clearcoatRoughnessTexture));if(n.clearcoatNormalTexture!==void 0){if(i.push(this.parser.assignTexture(t,"clearcoatNormalMap",n.clearcoatNormalTexture)),n.clearcoatNormalTexture.scale!==void 0){let r=n.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new Ne(r,r)}}return Promise.all(i)}}class mm{constructor(e){this.parser=e,this.name=Xe.KHR_MATERIALS_DISPERSION}getMaterialType(e){return Pt(this.parser,e,this.name)!==null?yn:null}extendMaterialParams(e,t){let n=Pt(this.parser,e,this.name);if(n===null)return Promise.resolve();return t.dispersion=n.dispersion!==void 0?n.dispersion:0,Promise.resolve()}}class gm{constructor(e){this.parser=e,this.name=Xe.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){return Pt(this.parser,e,this.name)!==null?yn:null}extendMaterialParams(e,t){let n=Pt(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(n.iridescenceFactor!==void 0)t.iridescence=n.iridescenceFactor;if(n.iridescenceTexture!==void 0)i.push(this.parser.assignTexture(t,"iridescenceMap",n.iridescenceTexture));if(n.iridescenceIor!==void 0)t.iridescenceIOR=n.iridescenceIor;if(t.iridescenceThicknessRange===void 0)t.iridescenceThicknessRange=[100,400];if(n.iridescenceThicknessMinimum!==void 0)t.iridescenceThicknessRange[0]=n.iridescenceThicknessMinimum;if(n.iridescenceThicknessMaximum!==void 0)t.iridescenceThicknessRange[1]=n.iridescenceThicknessMaximum;if(n.iridescenceThicknessTexture!==void 0)i.push(this.parser.assignTexture(t,"iridescenceThicknessMap",n.iridescenceThicknessTexture));return Promise.all(i)}}class _m{constructor(e){this.parser=e,this.name=Xe.KHR_MATERIALS_SHEEN}getMaterialType(e){return Pt(this.parser,e,this.name)!==null?yn:null}extendMaterialParams(e,t){let n=Pt(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(t.sheenColor=new Oe(0,0,0),t.sheenRoughness=0,t.sheen=1,n.sheenColorFactor!==void 0){let r=n.sheenColorFactor;t.sheenColor.setRGB(r[0],r[1],r[2],gn)}if(n.sheenRoughnessFactor!==void 0)t.sheenRoughness=n.sheenRoughnessFactor;if(n.sheenColorTexture!==void 0)i.push(this.parser.assignTexture(t,"sheenColorMap",n.sheenColorTexture,Yi));if(n.sheenRoughnessTexture!==void 0)i.push(this.parser.assignTexture(t,"sheenRoughnessMap",n.sheenRoughnessTexture));return Promise.all(i)}}class xm{constructor(e){this.parser=e,this.name=Xe.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){return Pt(this.parser,e,this.name)!==null?yn:null}extendMaterialParams(e,t){let n=Pt(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(n.transmissionFactor!==void 0)t.transmission=n.transmissionFactor;if(n.transmissionTexture!==void 0)i.push(this.parser.assignTexture(t,"transmissionMap",n.transmissionTexture));return Promise.all(i)}}class ym{constructor(e){this.parser=e,this.name=Xe.KHR_MATERIALS_VOLUME}getMaterialType(e){return Pt(this.parser,e,this.name)!==null?yn:null}extendMaterialParams(e,t){let n=Pt(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(t.thickness=n.thicknessFactor!==void 0?n.thicknessFactor:0,n.thicknessTexture!==void 0)i.push(this.parser.assignTexture(t,"thicknessMap",n.thicknessTexture));t.attenuationDistance=n.attenuationDistance||1/0;let r=n.attenuationColor||[1,1,1];return t.attenuationColor=new Oe().setRGB(r[0],r[1],r[2],gn),Promise.all(i)}}class vm{constructor(e){this.parser=e,this.name=Xe.KHR_MATERIALS_IOR}getMaterialType(e){return Pt(this.parser,e,this.name)!==null?yn:null}extendMaterialParams(e,t){let n=Pt(this.parser,e,this.name);if(n===null)return Promise.resolve();if(t.ior=n.ior!==void 0?n.ior:1.5,t.ior===0)t.ior=1000;return Promise.resolve()}}class bm{constructor(e){this.parser=e,this.name=Xe.KHR_MATERIALS_SPECULAR}getMaterialType(e){return Pt(this.parser,e,this.name)!==null?yn:null}extendMaterialParams(e,t){let n=Pt(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(t.specularIntensity=n.specularFactor!==void 0?n.specularFactor:1,n.specularTexture!==void 0)i.push(this.parser.assignTexture(t,"specularIntensityMap",n.specularTexture));let r=n.specularColorFactor||[1,1,1];if(t.specularColor=new Oe().setRGB(r[0],r[1],r[2],gn),n.specularColorTexture!==void 0)i.push(this.parser.assignTexture(t,"specularColorMap",n.specularColorTexture,Yi));return Promise.all(i)}}class Sm{constructor(e){this.parser=e,this.name=Xe.EXT_MATERIALS_BUMP}getMaterialType(e){return Pt(this.parser,e,this.name)!==null?yn:null}extendMaterialParams(e,t){let n=Pt(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(t.bumpScale=n.bumpFactor!==void 0?n.bumpFactor:1,n.bumpTexture!==void 0)i.push(this.parser.assignTexture(t,"bumpMap",n.bumpTexture));return Promise.all(i)}}class Mm{constructor(e){this.parser=e,this.name=Xe.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){return Pt(this.parser,e,this.name)!==null?yn:null}extendMaterialParams(e,t){let n=Pt(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(n.anisotropyStrength!==void 0)t.anisotropy=n.anisotropyStrength;if(n.anisotropyRotation!==void 0)t.anisotropyRotation=n.anisotropyRotation;if(n.anisotropyTexture!==void 0)i.push(this.parser.assignTexture(t,"anisotropyMap",n.anisotropyTexture));return Promise.all(i)}}class wm{constructor(e){this.parser=e,this.name=Xe.KHR_TEXTURE_BASISU}loadTexture(e){let t=this.parser,n=t.json,i=n.textures[e];if(!i.extensions||!i.extensions[this.name])return null;let r=i.extensions[this.name],s=t.options.ktx2Loader;if(!s)if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");else return null;return t.loadTextureImage(e,r.source,s)}}class Em{constructor(e){this.parser=e,this.name=Xe.EXT_TEXTURE_WEBP}loadTexture(e){let t=this.name,n=this.parser,i=n.json,r=i.textures[e];if(!r.extensions||!r.extensions[t])return null;let s=r.extensions[t],o=i.images[s.source],a=n.textureLoader;if(o.uri){let c=n.options.manager.getHandler(o.uri);if(c!==null)a=c}return n.loadTextureImage(e,s.source,a)}}class Tm{constructor(e){this.parser=e,this.name=Xe.EXT_TEXTURE_AVIF}loadTexture(e){let t=this.name,n=this.parser,i=n.json,r=i.textures[e];if(!r.extensions||!r.extensions[t])return null;let s=r.extensions[t],o=i.images[s.source],a=n.textureLoader;if(o.uri){let c=n.options.manager.getHandler(o.uri);if(c!==null)a=c}return n.loadTextureImage(e,s.source,a)}}class Ju{constructor(e,t){this.name=t,this.parser=e}loadBufferView(e){let t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){let i=n.extensions[this.name],r=this.parser.getDependency("buffer",i.buffer),s=this.parser.options.meshoptDecoder;if(!s||!s.supported)if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");else return null;return r.then(function(o){let a=i.byteOffset||0,c=i.byteLength||0,{count:l,byteStride:u}=i,f=new Uint8Array(o,a,c);if(s.decodeGltfBufferAsync)return s.decodeGltfBufferAsync(l,u,f,i.mode,i.filter).then(function(h){return h.buffer});else return s.ready.then(function(){let h=new ArrayBuffer(l*u);return s.decodeGltfBuffer(new Uint8Array(h),l,u,f,i.mode,i.filter),h})})}else return null}}class Am{constructor(e){this.name=Xe.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){let t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||n.mesh===void 0)return null;let i=t.meshes[n.mesh];for(let c of i.primitives)if(c.mode!==Ln.TRIANGLES&&c.mode!==Ln.TRIANGLE_STRIP&&c.mode!==Ln.TRIANGLE_FAN&&c.mode!==void 0)return null;let s=n.extensions[this.name].attributes,o=[],a={};for(let c in s)o.push(this.parser.getDependency("accessor",s[c]).then((l)=>(a[c]=l,a[c])));if(o.length<1)return null;return o.push(this.parser.createNodeMesh(e)),Promise.all(o).then((c)=>{let l=c.pop(),u=l.isGroup?l.children:[l],f=c[0].count,h=[];for(let d of u){let g=new Ge,x=new O,p=new Ht,m=new O(1,1,1),E=new ms(d.geometry,d.material,f);for(let v=0;v<f;v++){if(a.TRANSLATION)x.fromBufferAttribute(a.TRANSLATION,v);if(a.ROTATION)p.fromBufferAttribute(a.ROTATION,v);if(a.SCALE)m.fromBufferAttribute(a.SCALE,v);E.setMatrixAt(v,g.compose(x,p,m))}let R=null;for(let v in a)if(v==="_COLOR_0"){let M=a[v];E.instanceColor=new Wi(M.array,M.itemSize,M.normalized)}else if(v!=="TRANSLATION"&&v!=="ROTATION"&&v!=="SCALE"){if(R===null){let T=E.geometry;R=new en,R.name=T.name;for(let A in T.attributes)R.setAttribute(A,T.attributes[A]);for(let A in T.morphAttributes)R.morphAttributes[A]=T.morphAttributes[A];if(T.index!==null)R.setIndex(T.index);R.morphTargetsRelative=T.morphTargetsRelative;for(let A of T.groups)R.addGroup(A.start,A.count,A.materialIndex);if(T.boundingBox!==null)R.boundingBox=T.boundingBox.clone();if(T.boundingSphere!==null)R.boundingSphere=T.boundingSphere.clone();R.drawRange.start=T.drawRange.start,R.drawRange.count=T.drawRange.count,R.userData=Object.assign({},T.userData),E.geometry=R}let M=a[v];R.setAttribute(v,new Wi(M.array,M.itemSize,M.normalized))}ut.prototype.copy.call(E,d),this.parser.assignFinalMaterial(E),h.push(E)}if(l.isGroup)return l.clear(),l.add(...h),l;return h[0]})}}var Rm="glTF",go=12,am={JSON:1313821514,BIN:5130562};class Cm{constructor(e){this.name=Xe.KHR_BINARY_GLTF,this.content=null,this.body=null;let t=new DataView(e,0,go),n=new TextDecoder;if(this.header={magic:n.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==Rm)throw Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");else if(this.header.version<2)throw Error("THREE.GLTFLoader: Legacy binary file detected.");let i=this.header.length-go,r=new DataView(e,go),s=0;while(s<i){let o=r.getUint32(s,!0);s+=4;let a=r.getUint32(s,!0);if(s+=4,a===am.JSON){let c=new Uint8Array(e,go+s,o);this.content=n.decode(c)}else if(a===am.BIN){let c=go+s;this.body=e.slice(c,c+o)}s+=o}if(this.content===null)throw Error("THREE.GLTFLoader: JSON content not found.")}}class Pm{constructor(e,t){if(!t)throw Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=Xe.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){let n=this.json,i=this.dracoLoader,r=e.extensions[this.name].bufferView,s=e.extensions[this.name].attributes,o={},a={},c={};for(let l in s){let u=Qu[l]||l.toLowerCase();o[u]=s[l]}for(let l in e.attributes){let u=Qu[l]||l.toLowerCase();if(s[l]!==void 0){let f=n.accessors[e.attributes[l]],h=Es[f.componentType];c[u]=h.name,a[u]=f.normalized===!0}}return t.getDependency("bufferView",r).then(function(l){return new Promise(function(u,f){i.decodeDracoFile(l,function(h){for(let d in h.attributes){let g=h.attributes[d],x=a[d];if(x!==void 0)g.normalized=x}u(h)},o,c,gn,f)})})}}class Im{constructor(){this.name=Xe.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){if((t.texCoord===void 0||t.texCoord===e.channel)&&t.offset===void 0&&t.rotation===void 0&&t.scale===void 0)return e;if(e=e.clone(),t.texCoord!==void 0)e.channel=t.texCoord;if(t.offset!==void 0)e.offset.fromArray(t.offset);if(t.rotation!==void 0)e.rotation=t.rotation;if(t.scale!==void 0)e.repeat.fromArray(t.scale);if(t.rotation!==void 0){let n=Math.cos(e.rotation),i=Math.sin(e.rotation);e.matrix.set(e.repeat.x*n,e.repeat.y*i,e.offset.x,-e.repeat.x*i,e.repeat.y*n,e.offset.y,0,0,1),e.matrixAutoUpdate=!1}return e.needsUpdate=!0,e}}class Lm{constructor(){this.name=Xe.KHR_MESH_QUANTIZATION}}class nh extends Pi{constructor(e,t,n,i){super(e,t,n,i)}copySampleValue_(e){let t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=e*i*3+i;for(let s=0;s!==i;s++)t[s]=n[r+s];return t}interpolate_(e,t,n,i){let r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=o*2,c=o*3,l=i-t,u=(n-t)/l,f=u*u,h=f*u,d=e*c,g=d-c,x=-2*h+3*f,p=h-f,m=1-x,E=p-f+u;for(let R=0;R!==o;R++){let v=s[g+R+o],M=s[g+R+a]*l,T=s[d+R+o],A=s[d+R]*l;r[R]=m*v+E*M+x*T+p*A}return r}}var AT=new Ht;class Nm extends nh{interpolate_(e,t,n,i){let r=super.interpolate_(e,t,n,i);return AT.fromArray(r).normalize().toArray(r),r}}var Ln={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},Es={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},cm={9728:Vn,9729:$t,9984:Ma,9985:us,9986:br,9987:ri},lm={33071:ls,33648:Sa,10497:cs},ju={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Qu={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},sr={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},RT={CUBICSPLINE:void 0,LINEAR:Pa,STEP:ou},Yu={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function CT(e){if(e.DefaultMaterial===void 0)e.DefaultMaterial=new Ci({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:qi});return e.DefaultMaterial}function Ir(e,t,n){for(let i in n.extensions)if(e[i]===void 0)t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[i]=n.extensions[i]}function ui(e,t){if(t.extras!==void 0)if(typeof t.extras==="object")Object.assign(e.userData,t.extras);else console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+t.extras)}function PT(e,t,n){let i=!1,r=!1,s=!1;for(let l=0,u=t.length;l<u;l++){let f=t[l];if(f.POSITION!==void 0)i=!0;if(f.NORMAL!==void 0)r=!0;if(f.COLOR_0!==void 0)s=!0;if(i&&r&&s)break}if(!i&&!r&&!s)return Promise.resolve(e);let o=[],a=[],c=[];for(let l=0,u=t.length;l<u;l++){let f=t[l];if(i){let h=f.POSITION!==void 0?n.getDependency("accessor",f.POSITION):e.attributes.position;o.push(h)}if(r){let h=f.NORMAL!==void 0?n.getDependency("accessor",f.NORMAL):e.attributes.normal;a.push(h)}if(s){let h=f.COLOR_0!==void 0?n.getDependency("accessor",f.COLOR_0):e.attributes.color;c.push(h)}}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(c)]).then(function(l){let u=l[0],f=l[1],h=l[2];if(i)e.morphAttributes.position=u;if(r)e.morphAttributes.normal=f;if(s)e.morphAttributes.color=h;return e.morphTargetsRelative=!0,e})}function IT(e,t){if(e.updateMorphTargets(),t.weights!==void 0)for(let n=0,i=t.weights.length;n<i;n++)e.morphTargetInfluences[n]=t.weights[n];if(t.extras&&Array.isArray(t.extras.targetNames)){let n=t.extras.targetNames;if(e.morphTargetInfluences.length===n.length){e.morphTargetDictionary={};for(let i=0,r=n.length;i<r;i++)e.morphTargetDictionary[n[i]]=i}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function LT(e){let t,n=e.extensions&&e.extensions[Xe.KHR_DRACO_MESH_COMPRESSION];if(n)t="draco:"+n.bufferView+":"+n.indices+":"+Ku(n.attributes);else t=e.indices+":"+Ku(e.attributes)+":"+e.mode;if(e.targets!==void 0)for(let i=0,r=e.targets.length;i<r;i++)t+=":"+Ku(e.targets[i]);return t}function Ku(e){let t="",n=Object.keys(e).sort();for(let i=0,r=n.length;i<r;i++)t+=n[i]+":"+e[n[i]]+";";return t}function eh(e){switch(e){case Int8Array:return 0.007874015748031496;case Uint8Array:return 0.00392156862745098;case Int16Array:return 0.00003051850947599719;case Uint16Array:return 0.000015259021896696422;default:throw Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function NT(e){if(e.search(/\.jpe?g($|\?)/i)>0||e.search(/^data\:image\/jpeg/)===0)return"image/jpeg";if(e.search(/\.webp($|\?)/i)>0||e.search(/^data\:image\/webp/)===0)return"image/webp";if(e.search(/\.ktx2($|\?)/i)>0||e.search(/^data\:image\/ktx2/)===0)return"image/ktx2";return"image/png"}var DT=new Ge;class Dm{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new TT,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let n=!1,i=-1,r=!1,s=-1;if(typeof navigator<"u"&&typeof navigator.userAgent<"u"){let o=navigator.userAgent;n=/^((?!chrome|android).)*safari/i.test(o)===!0;let a=o.match(/Version\/(\d+)/);i=n&&a?parseInt(a[1],10):-1,r=o.indexOf("Firefox")>-1,s=r?o.match(/Firefox\/([0-9]+)\./)[1]:-1}if(typeof createImageBitmap>"u"||n&&i<17||r&&s<98)this.textureLoader=new _s(this.options.manager);else this.textureLoader=new qa(this.options.manager);if(this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new ao(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials")this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){let n=this,i=this.json,r=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(s){return s._markDefs&&s._markDefs()}),Promise.all(this._invokeAll(function(s){return s.beforeRoot&&s.beforeRoot()})).then(function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(s){let o={scene:s[0][i.scene||0],scenes:s[0],animations:s[1],cameras:s[2],asset:i.asset,parser:n,userData:{}};return Ir(r,o,i),ui(o,i),Promise.all(n._invokeAll(function(a){return a.afterRoot&&a.afterRoot(o)})).then(function(){for(let a of o.scenes)a.updateMatrixWorld();e(o)})}).catch(t)}_markDefs(){let e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let i=0,r=t.length;i<r;i++){let s=t[i].joints;for(let o=0,a=s.length;o<a;o++)e[s[o]].isBone=!0}for(let i=0,r=e.length;i<r;i++){let s=e[i];if(s.mesh!==void 0){if(this._addNodeRef(this.meshCache,s.mesh),s.skin!==void 0)n[s.mesh].isSkinnedMesh=!0}if(s.camera!==void 0)this._addNodeRef(this.cameraCache,s.camera)}}_addNodeRef(e,t){if(t===void 0)return;if(e.refs[t]===void 0)e.refs[t]=e.uses[t]=0;e.refs[t]++}_getNodeRef(e,t,n){if(e.refs[t]<=1)return n;let i=n.clone(),r=(s,o)=>{let a=this.associations.get(s);if(a!=null)this.associations.set(o,a);for(let[c,l]of s.children.entries())r(l,o.children[c])};return r(n,i),i.name+="_instance_"+e.uses[t]++,i}_invokeOne(e){let t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){let i=e(t[n]);if(i)return i}return null}_invokeAll(e){let t=Object.values(this.plugins);t.unshift(this);let n=[];for(let i=0;i<t.length;i++){let r=e(t[i]);if(r)n.push(r)}return n}getDependency(e,t){let n=e+":"+t,i=this.cache.get(n);if(!i){switch(e){case"scene":i=this.loadScene(t);break;case"node":i=this._invokeOne(function(r){return r.loadNode&&r.loadNode(t)});break;case"mesh":i=this._invokeOne(function(r){return r.loadMesh&&r.loadMesh(t)});break;case"accessor":i=this.loadAccessor(t);break;case"bufferView":i=this._invokeOne(function(r){return r.loadBufferView&&r.loadBufferView(t)});break;case"buffer":i=this.loadBuffer(t);break;case"material":i=this._invokeOne(function(r){return r.loadMaterial&&r.loadMaterial(t)});break;case"texture":i=this._invokeOne(function(r){return r.loadTexture&&r.loadTexture(t)});break;case"skin":i=this.loadSkin(t);break;case"animation":i=this._invokeOne(function(r){return r.loadAnimation&&r.loadAnimation(t)});break;case"camera":i=this.loadCamera(t);break;default:if(i=this._invokeOne(function(r){return r!=this&&r.getDependency&&r.getDependency(e,t)}),!i)throw Error("Unknown type: "+e);break}this.cache.add(n,i)}return i}getDependencies(e){let t=this.cache.get(e);if(!t){let n=this,i=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(i.map(function(r,s){return n.getDependency(e,s)})),this.cache.add(e,t)}return t}loadBuffer(e){let t=this.json.buffers[e],n=this.fileLoader;if(t.type&&t.type!=="arraybuffer")throw Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[Xe.KHR_BINARY_GLTF].body);let i=this.options;return new Promise(function(r,s){n.load(rr.resolveURL(t.uri,i.path),r,void 0,function(){s(Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){let t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(n){let i=t.byteLength||0,r=t.byteOffset||0;return n.slice(r,r+i)})}loadAccessor(e){let t=this,n=this.json,i=this.json.accessors[e];if(i.bufferView===void 0&&i.sparse===void 0){let s=ju[i.type],o=Es[i.componentType],a=i.normalized===!0,c=new o(i.count*s);return Promise.resolve(new Vt(c,s,a))}let r=[];if(i.bufferView!==void 0)r.push(this.getDependency("bufferView",i.bufferView));else r.push(null);if(i.sparse!==void 0)r.push(this.getDependency("bufferView",i.sparse.indices.bufferView)),r.push(this.getDependency("bufferView",i.sparse.values.bufferView));return Promise.all(r).then(function(s){let o=s[0],a=ju[i.type],c=Es[i.componentType],l=c.BYTES_PER_ELEMENT,u=l*a,f=i.byteOffset||0,h=i.bufferView!==void 0?n.bufferViews[i.bufferView].byteStride:void 0,d=i.normalized===!0,g,x;if(h&&h!==u){let p=Math.floor(f/h),m="InterleavedBuffer:"+i.bufferView+":"+i.componentType+":"+p+":"+i.count,E=t.cache.get(m);if(!E)g=new c(o,p*h,i.count*h/l),E=new Js(g,h/l),t.cache.add(m,E);x=new ps(E,a,f%h/l,d)}else{if(o===null)g=new c(i.count*a);else g=new c(o,f,i.count*a);x=new Vt(g,a,d)}if(i.sparse!==void 0){let p=ju.SCALAR,m=Es[i.sparse.indices.componentType],E=i.sparse.indices.byteOffset||0,R=i.sparse.values.byteOffset||0,v=new m(s[1],E,i.sparse.count*p),M=new c(s[2],R,i.sparse.count*a);if(o!==null)x=new Vt(x.array.slice(),x.itemSize,x.normalized);x.normalized=!1;for(let T=0,A=v.length;T<A;T++){let _=v[T];if(x.setX(_,M[T*a]),a>=2)x.setY(_,M[T*a+1]);if(a>=3)x.setZ(_,M[T*a+2]);if(a>=4)x.setW(_,M[T*a+3]);if(a>=5)throw Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}x.normalized=d}return x})}loadTexture(e){let t=this.json,n=this.options,r=t.textures[e].source,s=t.images[r],o=this.textureLoader;if(s.uri){let a=n.manager.getHandler(s.uri);if(a!==null)o=a}return this.loadTextureImage(e,r,o)}loadTextureImage(e,t,n){let i=this,r=this.json,s=r.textures[e],o=r.images[t],a=(o.uri||o.bufferView)+":"+s.sampler;if(this.textureCache[a])return this.textureCache[a];let c=this.loadImageSource(t,n).then(function(l){if(l.flipY=!1,l.name=s.name||o.name||"",l.name===""&&typeof o.uri==="string"&&o.uri.startsWith("data:image/")===!1)l.name=o.uri;let f=(r.samplers||{})[s.sampler]||{};return l.magFilter=cm[f.magFilter]||$t,l.minFilter=cm[f.minFilter]||ri,l.wrapS=lm[f.wrapS]||cs,l.wrapT=lm[f.wrapT]||cs,l.generateMipmaps=!l.isCompressedTexture&&l.minFilter!==Vn&&l.minFilter!==$t,i.associations.set(l,{textures:e}),l}).catch(function(){return null});return this.textureCache[a]=c,c}loadImageSource(e,t){let n=this,i=this.json,r=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then((u)=>u.clone());let s=i.images[e],o=self.URL||self.webkitURL,a=s.uri||"",c=!1;if(s.bufferView!==void 0)a=n.getDependency("bufferView",s.bufferView).then(function(u){c=!0;let f=new Blob([u],{type:s.mimeType});return a=o.createObjectURL(f),a});else if(s.uri===void 0)throw Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");let l=Promise.resolve(a).then(function(u){return new Promise(function(f,h){let d=f;if(t.isImageBitmapLoader===!0)d=function(g){let x=new At(g);x.needsUpdate=!0,f(x)};t.load(rr.resolveURL(u,r.path),d,void 0,h)})}).then(function(u){if(c===!0)o.revokeObjectURL(a);return ui(u,s),u.userData.mimeType=s.mimeType||NT(s.uri),u}).catch(function(u){throw console.error("THREE.GLTFLoader: Couldn't load texture",a),u});return this.sourceCache[e]=l,l}assignTexture(e,t,n,i){let r=this;return this.getDependency("texture",n.index).then(function(s){if(!s)return null;if(n.texCoord!==void 0&&n.texCoord>0)s=s.clone(),s.channel=n.texCoord;if(r.extensions[Xe.KHR_TEXTURE_TRANSFORM]){let o=n.extensions!==void 0?n.extensions[Xe.KHR_TEXTURE_TRANSFORM]:void 0;if(o){let a=r.associations.get(s);s=r.extensions[Xe.KHR_TEXTURE_TRANSFORM].extendTexture(s,o),r.associations.set(s,a)}}if(i!==void 0)s.colorSpace=i;return e[t]=s,s})}assignFinalMaterial(e){let{geometry:t,material:n}=e,i=t.attributes.tangent===void 0,r=t.attributes.color!==void 0,s=t.attributes.normal===void 0;if(e.isPoints){let o="PointsMaterial:"+n.uuid,a=this.cache.get(o);if(!a)a=new ro,hn.prototype.copy.call(a,n),a.color.copy(n.color),a.map=n.map,a.sizeAttenuation=!1,this.cache.add(o,a);n=a}else if(e.isLine){let o="LineBasicMaterial:"+n.uuid,a=this.cache.get(o);if(!a)a=new io,hn.prototype.copy.call(a,n),a.color.copy(n.color),a.map=n.map,this.cache.add(o,a);n=a}if(i||r||s){let o="ClonedMaterial:"+n.uuid+":";if(i)o+="derivative-tangents:";if(r)o+="vertex-colors:";if(s)o+="flat-shading:";let a=this.cache.get(o);if(!a){if(a=n.clone(),r)a.vertexColors=!0;if(s)a.flatShading=!0;if(i){if(a.normalScale)a.normalScale.y*=-1;if(a.clearcoatNormalScale)a.clearcoatNormalScale.y*=-1}this.cache.add(o,a),this.associations.set(a,this.associations.get(n))}n=a}e.material=n}getMaterialType(){return Ci}loadMaterial(e){let t=this,n=this.json,i=this.extensions,r=n.materials[e],s,o={},a=r.extensions||{},c=[];if(a[Xe.KHR_MATERIALS_UNLIT]){let u=i[Xe.KHR_MATERIALS_UNLIT];s=u.getMaterialType(),c.push(u.extendParams(o,r,t))}else{let u=r.pbrMetallicRoughness||{};if(o.color=new Oe(1,1,1),o.opacity=1,Array.isArray(u.baseColorFactor)){let f=u.baseColorFactor;o.color.setRGB(f[0],f[1],f[2],gn),o.opacity=f[3]}if(u.baseColorTexture!==void 0)c.push(t.assignTexture(o,"map",u.baseColorTexture,Yi));if(o.metalness=u.metallicFactor!==void 0?u.metallicFactor:1,o.roughness=u.roughnessFactor!==void 0?u.roughnessFactor:1,u.metallicRoughnessTexture!==void 0)c.push(t.assignTexture(o,"metalnessMap",u.metallicRoughnessTexture)),c.push(t.assignTexture(o,"roughnessMap",u.metallicRoughnessTexture));s=this._invokeOne(function(f){return f.getMaterialType&&f.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(f){return f.extendMaterialParams&&f.extendMaterialParams(e,o)})))}if(r.doubleSided===!0)o.side=Pn;let l=r.alphaMode||Yu.OPAQUE;if(l===Yu.BLEND)o.transparent=!0,o.depthWrite=!1;else if(o.transparent=!1,l===Yu.MASK)o.alphaTest=r.alphaCutoff!==void 0?r.alphaCutoff:0.5;if(r.normalTexture!==void 0&&s!==ai){if(c.push(t.assignTexture(o,"normalMap",r.normalTexture)),o.normalScale=new Ne(1,1),r.normalTexture.scale!==void 0){let u=r.normalTexture.scale;o.normalScale.set(u,u)}}if(r.occlusionTexture!==void 0&&s!==ai){if(c.push(t.assignTexture(o,"aoMap",r.occlusionTexture)),r.occlusionTexture.strength!==void 0)o.aoMapIntensity=r.occlusionTexture.strength}if(r.emissiveFactor!==void 0&&s!==ai){let u=r.emissiveFactor;o.emissive=new Oe().setRGB(u[0],u[1],u[2],gn)}if(r.emissiveTexture!==void 0&&s!==ai)c.push(t.assignTexture(o,"emissiveMap",r.emissiveTexture,Yi));return Promise.all(c).then(function(){let u=new s(o);if(r.name)u.name=r.name;if(ui(u,r),t.associations.set(u,{materials:e}),r.extensions)Ir(i,u,r);return u})}createUniqueName(e){let t=et.sanitizeNodeName(e||"");if(t in this.nodeNamesUsed)return t+"_"+ ++this.nodeNamesUsed[t];else return this.nodeNamesUsed[t]=0,t}loadGeometries(e){let t=this,n=this.extensions,i=this.primitiveCache;function r(o){return n[Xe.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(o,t).then(function(a){return um(a,o,t)})}let s=[];for(let o=0,a=e.length;o<a;o++){let c=e[o],l=LT(c),u=i[l];if(u)s.push(u.promise);else{let f;if(c.extensions&&c.extensions[Xe.KHR_DRACO_MESH_COMPRESSION])f=r(c);else f=um(new en,c,t);if(c.mode===Ln.TRIANGLE_STRIP)f=f.then((h)=>qu(h,qs));else if(c.mode===Ln.TRIANGLE_FAN)f=f.then((h)=>qu(h,fs));i[l]={primitive:c,promise:f},s.push(f)}}return Promise.all(s)}loadMesh(e){let t=this,n=this.json,i=this.extensions,r=n.meshes[e],s=r.primitives,o=[];for(let a=0,c=s.length;a<c;a++){let l=s[a].material===void 0?CT(this.cache):this.getDependency("material",s[a].material);o.push(l)}return o.push(t.loadGeometries(s)),Promise.all(o).then(async function(a){let c=a.slice(0,a.length-1),l=a[a.length-1],u=[];for(let h=0,d=l.length;h<d;h++){let g=l[h],x=s[h],p,m=c[h];if(x.mode===Ln.TRIANGLES||x.mode===Ln.TRIANGLE_STRIP||x.mode===Ln.TRIANGLE_FAN||x.mode===void 0){let E=r.isSkinnedMesh===!0,R=g.hasAttribute("skinIndex")&&g.hasAttribute("skinWeight");if(E&&R===!1)console.warn("THREE.GLTFLoader: Missing skinIndex or skinWeight attributes. Skinning disabled.");if(p=E&&R?new Fa(g,m):new _t(g,m),p.isSkinnedMesh===!0)p.normalizeSkinWeights()}else if(x.mode===Ln.LINES)p=new za(g,m);else if(x.mode===Ln.LINE_STRIP)p=new Ji(g,m);else if(x.mode===Ln.LINE_LOOP)p=new ka(g,m);else if(x.mode===Ln.POINTS)p=new gs(g,m);else throw Error("THREE.GLTFLoader: Primitive mode unsupported: "+x.mode);if(Object.keys(p.geometry.morphAttributes).length>0)IT(p,r);if(p.name=t.createUniqueName(r.name||"mesh_"+e),ui(p,r),x.extensions)Ir(i,p,x);t.assignFinalMaterial(p),u.push(p)}for(let h=0,d=u.length;h<d;h++)t.associations.set(u[h],{meshes:e,primitives:h});if(u.length===1){if(r.extensions)Ir(i,u[0],r);return u[0]}let f=new ei;if(r.extensions)Ir(i,f,r);t.associations.set(f,{meshes:e});for(let h=0,d=u.length;h<d;h++)f.add(u[h]);return f})}loadCamera(e){let t,n=this.json.cameras[e],i=n[n.type];if(!i){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}if(n.type==="perspective")t=new Ut(js.radToDeg(i.yfov),i.aspectRatio||1,i.znear||1,i.zfar||2000000);else if(n.type==="orthographic")t=new Cr(-i.xmag,i.xmag,i.ymag,-i.ymag,i.znear,i.zfar);if(n.name)t.name=this.createUniqueName(n.name);return ui(t,n),Promise.resolve(t)}loadSkin(e){let t=this.json.skins[e],n=[];for(let i=0,r=t.joints.length;i<r;i++)n.push(this._loadNodeShallow(t.joints[i]));if(t.inverseBindMatrices!==void 0)n.push(this.getDependency("accessor",t.inverseBindMatrices));else n.push(null);return Promise.all(n).then(function(i){let r=i.pop(),s=i,o=[],a=[];for(let c=0,l=s.length;c<l;c++){let u=s[c];if(u){o.push(u);let f=new Ge;if(r!==null)f.fromArray(r.array,c*16);a.push(f)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[c])}return new to(o,a)})}loadAnimation(e){let t=this.json,n=this,i=t.animations[e],r=i.name?i.name:"animation_"+e,s=[],o=[],a=[],c=[],l=[];for(let u=0,f=i.channels.length;u<f;u++){let h=i.channels[u],d=i.samplers[h.sampler],g=h.target,x=g.node,p=i.parameters!==void 0?i.parameters[d.input]:d.input,m=i.parameters!==void 0?i.parameters[d.output]:d.output;if(g.node===void 0)continue;s.push(this.getDependency("node",x)),o.push(this.getDependency("accessor",p)),a.push(this.getDependency("accessor",m)),c.push(d),l.push(g)}return Promise.all([Promise.all(s),Promise.all(o),Promise.all(a),Promise.all(c),Promise.all(l)]).then(function(u){let f=u[0],h=u[1],d=u[2],g=u[3],x=u[4],p=[];for(let E=0,R=f.length;E<R;E++){let v=f[E],M=h[E],T=d[E],A=g[E],_=x[E];if(v===void 0)continue;if(v.updateMatrix)v.updateMatrix();let S=n._createAnimationTracks(v,M,T,A,_);if(S)for(let z=0;z<S.length;z++)p.push(S[z])}let m=new rs(r,void 0,p);return ui(m,i),m})}createNodeMesh(e){let t=this.json,n=this,i=t.nodes[e];if(i.mesh===void 0)return null;return n.getDependency("mesh",i.mesh).then(function(r){let s=n._getNodeRef(n.meshCache,i.mesh,r);if(i.weights!==void 0)s.traverse(function(o){if(!o.isMesh)return;for(let a=0,c=i.weights.length;a<c;a++)o.morphTargetInfluences[a]=i.weights[a]});return s})}loadNode(e){let t=this.json,n=this,i=t.nodes[e],r=n._loadNodeShallow(e),s=[],o=i.children||[];for(let c=0,l=o.length;c<l;c++)s.push(n.getDependency("node",o[c]));let a=i.skin===void 0?Promise.resolve(null):n.getDependency("skin",i.skin);return Promise.all([r,Promise.all(s),a]).then(function(c){let l=c[0],u=c[1],f=c[2];if(f!==null)l.traverse(function(h){if(!h.isSkinnedMesh)return;h.bind(f,DT)});for(let h=0,d=u.length;h<d;h++)l.add(u[h]);if(l.userData.pivot!==void 0&&u.length>0){let h=l.userData.pivot,d=u[0];l.pivot=new O().fromArray(h),l.position.x-=h[0],l.position.y-=h[1],l.position.z-=h[2],d.position.set(0,0,0),delete l.userData.pivot}return l})}_loadNodeShallow(e){let t=this.json,n=this.extensions,i=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];let r=t.nodes[e],s=r.name?i.createUniqueName(r.name):"",o=[],a=i._invokeOne(function(c){return c.createNodeMesh&&c.createNodeMesh(e)});if(a)o.push(a);if(r.camera!==void 0)o.push(i.getDependency("camera",r.camera).then(function(c){return i._getNodeRef(i.cameraCache,r.camera,c)}));return i._invokeAll(function(c){return c.createNodeAttachment&&c.createNodeAttachment(e)}).forEach(function(c){o.push(c)}),this.nodeCache[e]=Promise.all(o).then(function(c){let l;if(r.isBone===!0)l=new Qs;else if(c.length>1)l=new ei;else if(c.length===1)l=c[0];else l=new ut;if(l!==c[0])for(let u=0,f=c.length;u<f;u++)l.add(c[u]);if(r.name)l.userData.name=r.name,l.name=s;if(ui(l,r),r.extensions)Ir(n,l,r);if(r.matrix!==void 0){let u=new Ge;u.fromArray(r.matrix),l.applyMatrix4(u)}else{if(r.translation!==void 0)l.position.fromArray(r.translation);if(r.rotation!==void 0)l.quaternion.fromArray(r.rotation);if(r.scale!==void 0)l.scale.fromArray(r.scale)}if(!i.associations.has(l))i.associations.set(l,{});else if(r.mesh!==void 0&&i.meshCache.refs[r.mesh]>1){let u=i.associations.get(l);i.associations.set(l,{...u})}return i.associations.get(l).nodes=e,l}),this.nodeCache[e]}loadScene(e){let t=this.extensions,n=this.json.scenes[e],i=this,r=new ei;if(n.name)r.name=i.createUniqueName(n.name);if(ui(r,n),n.extensions)Ir(t,r,n);let s=n.nodes||[],o=[];for(let a=0,c=s.length;a<c;a++)o.push(i.getDependency("node",s[a]));return Promise.all(o).then(function(a){for(let l=0,u=a.length;l<u;l++){let f=a[l];if(f.parent!==null)r.add(sm(f));else r.add(f)}let c=(l)=>{let u=new Map;for(let[f,h]of i.associations)if(f instanceof hn||f instanceof At)u.set(f,h);return l.traverse((f)=>{let h=i.associations.get(f);if(h!=null)u.set(f,h)}),u};return i.associations=c(r),r})}_createAnimationTracks(e,t,n,i,r){let s=[],o=e.name?e.name:e.uuid,a=[];function c(h){if(h.morphTargetInfluences)a.push(h.name?h.name:h.uuid)}if(sr[r.path]===sr.weights){if(c(e),e.isGroup)e.children.forEach(c)}else a.push(o);let l;switch(sr[r.path]){case sr.weights:l=tr;break;case sr.rotation:l=nr;break;case sr.translation:case sr.scale:l=Rr;break;default:switch(n.itemSize){case 1:l=tr;break;case 2:case 3:default:l=Rr;break}break}let u=i.interpolation!==void 0?RT[i.interpolation]:Pa,f=this._getArrayFromAccessor(n);for(let h=0,d=a.length;h<d;h++){let g=new l(a[h]+"."+sr[r.path],t.array,f,u);if(i.interpolation==="CUBICSPLINE")this._createCubicSplineTrackInterpolant(g);s.push(g)}return s}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){let n=eh(t.constructor),i=new Float32Array(t.length);for(let r=0,s=t.length;r<s;r++)i[r]=t[r]*n;t=i}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(n){return new(this instanceof nr?Nm:nh)(this.times,this.values,this.getValueSize()/3,n)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function OT(e,t,n){let i=t.attributes,r=new Ft;if(i.POSITION!==void 0){let a=n.json.accessors[i.POSITION],{min:c,max:l}=a;if(c!==void 0&&l!==void 0){if(r.set(new O(c[0],c[1],c[2]),new O(l[0],l[1],l[2])),a.normalized){let u=eh(Es[a.componentType]);r.min.multiplyScalar(u),r.max.multiplyScalar(u)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;let s=t.targets;if(s!==void 0){let a=new O,c=new O;for(let l=0,u=s.length;l<u;l++){let f=s[l];if(f.POSITION!==void 0){let h=n.json.accessors[f.POSITION],{min:d,max:g}=h;if(d!==void 0&&g!==void 0){if(c.setX(Math.max(Math.abs(d[0]),Math.abs(g[0]))),c.setY(Math.max(Math.abs(d[1]),Math.abs(g[1]))),c.setZ(Math.max(Math.abs(d[2]),Math.abs(g[2]))),h.normalized){let x=eh(Es[h.componentType]);c.multiplyScalar(x)}a.max(c)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}r.expandByVector(a)}e.boundingBox=r;let o=new xn;r.getCenter(o.center),o.radius=r.min.distanceTo(r.max)/2,e.boundingSphere=o}function um(e,t,n){let i=t.attributes,r=[];function s(o,a){return n.getDependency("accessor",o).then(function(c){e.setAttribute(a,c)})}for(let o in i){let a=Qu[o]||o.toLowerCase();if(a in e.attributes)continue;r.push(s(i[o],a))}if(t.indices!==void 0&&!e.index){let o=n.getDependency("accessor",t.indices).then(function(a){e.setIndex(a)});r.push(o)}if($e.workingColorSpace!==gn&&"COLOR_0"in i)console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${$e.workingColorSpace}" not supported.`);return ui(e,t),OT(e,t,n),Promise.all(r).then(function(){return t.targets!==void 0?PT(e,t.targets,n):e})}function xo(e){let t=Object.values(e).filter((i)=>typeof i==="number");return Object.entries(e).filter(([i,r])=>t.indexOf(+i)===-1).map(([i,r])=>r)}function rh(e,t="|"){return e.map((n)=>ah(n)).join(t)}function yo(e,t){if(typeof t==="bigint")return t.toString();return t}class Om{constructor(e){this._getter=e,this._value=void 0}get value(){let e=this._getter;if(e!==void 0)this._value=e(),this._getter=void 0;return this._value}}function vo(e){return new Om(e)}function Um(e){return e===null||e===void 0}function nc(e){let t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function Fm(e,t){let n=e/t,i=Math.round(n),r=4*Number.EPSILON*Math.max(Math.abs(n),1);if(Math.abs(n-i)<r)return 0;return n-i}function Nn(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function bo(e){let t=Object.getOwnPropertyDescriptor(e,"shape");return t?.get?t.get.raw:t?.value}function Li(e){return bo(e._zod.def)??e._zod.def.shape}function zm(e,t,n){Object.defineProperty(e,t,{get(){let i=n();return Nn(this,t,i),i},enumerable:!0,configurable:!0})}function km(e,t,n){if(t in e)Nn(e,t,n);else e[t]=n}function Lr(e,t,n,i){let r=Li(t);for(let s of n){let o=Object.getOwnPropertyDescriptor(r,s);if(!o.enumerable)continue;if(o.get)zm(e,s,()=>{let a=t._zod.def.shape[s];return i?i(a,s):a});else km(e,s,i?i(o.value,s):o.value)}}function UT(e,t){for(let n of Reflect.ownKeys(t)){let i=Object.getOwnPropertyDescriptor(t,n);if(!i.enumerable)continue;if(i.get)zm(e,n,()=>t[n]);else km(e,n,i.value)}}function bn(...e){let t={};for(let n of e){let i=Object.getOwnPropertyDescriptors(n);Object.assign(t,i)}return Object.defineProperties({},t)}function Bm(e){return JSON.stringify(e)}function Gm(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var sh="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Ts(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}var Hm=vo(()=>{if(dn.jitless)return!1;if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}});function Nr(e){if(Ts(e)===!1)return!1;let t=e.constructor;if(t===void 0)return!0;if(typeof t!=="function")return!0;let n=t.prototype;if(Ts(n)===!1)return!1;if(Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)return!1;return!0}function oh(e){if(Nr(e))return{...e};if(Array.isArray(e))return[...e];if(e instanceof Map)return new Map(e);if(e instanceof Set)return new Set(e);return e}var Vm=new Set(["string","number","symbol"]);function ar(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function hi(e,t,n){let i=new e._zod.constr(t??e._zod.def);if(!t||n?.parent)i._zod.parent=e;return i}function Ce(e){let t=e;if(!t)return{};if(typeof t==="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}if(delete t.message,typeof t.error==="string")return{...t,error:()=>t.error};return t}function ah(e){if(typeof e==="bigint")return e.toString()+"n";if(typeof e==="string")return`"${e}"`;return`${e}`}function $m(e){return Object.keys(e).filter((t)=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}var ic=(()=>({safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-340282346638528860000000000000000000000,340282346638528860000000000000000000000],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]}))(),ch={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function FT(e,t){let n=e._zod.def,i=n.checks;if(i&&i.length>0)throw Error(".pick() cannot be used on object schemas containing refinements");let s={};return Lr(s,e,rc(e,t)),hi(e,bn(n,{shape:s,checks:[]}))}function rc(e,t){let n=Li(e),i=[];for(let r of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(n,r)?.enumerable)throw Error(`Unrecognized key: "${String(r)}"`);if(t[r])i.push(r)}return i}function zT(e,t){let n=e._zod.def,i=n.checks;if(i&&i.length>0)throw Error(".omit() cannot be used on object schemas containing refinements");let s=new Set(rc(e,t)),o={};return Lr(o,e,Reflect.ownKeys(Li(e)).filter((a)=>!s.has(a))),hi(e,bn(n,{shape:o,checks:[]}))}function kT(e,t){if(!Nr(t))throw Error("Invalid input to extend: expected a plain object");let n=e._zod.def.checks;if(n&&n.length>0){let r=Li(e);for(let s of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(r,s)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return hi(e,bn(e._zod.def,{shape:Wm(e,t)}))}function Wm(e,t){let n={};return Lr(n,e,Reflect.ownKeys(Li(e))),UT(n,t),n}function BT(e,t){if(!Nr(t))throw Error("Invalid input to safeExtend: expected a plain object");return hi(e,bn(e._zod.def,{shape:Wm(e,t)}))}function GT(e,t){if(!t?._zod?.def)throw Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let n={};Lr(n,e,Reflect.ownKeys(Li(e))),Lr(n,t,Reflect.ownKeys(Li(t)));let i=bn(e._zod.def,{shape:n,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return hi(e,i)}function Zm(e,t,n,i="partial"){let s=t._zod.def.checks;if(s&&s.length>0)throw Error(`.${i}() cannot be used on object schemas containing refinements`);let a=n?new Set(rc(t,n)):void 0,c={};return Lr(c,t,Reflect.ownKeys(Li(t)),e&&((l,u)=>a&&!a.has(u)?l:new e({type:"optional",innerType:l}))),hi(t,bn(t._zod.def,{shape:c,checks:[]}))}function HT(e,t,n){let i=n?new Set(rc(t,n)):void 0,r={};return Lr(r,t,Reflect.ownKeys(Li(t)),(s,o)=>i&&!i.has(o)?s:new e({type:"nonoptional",innerType:s})),hi(t,bn(t._zod.def,{shape:r}))}function fi(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function Xm(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function cr(e,t){return t.map((n)=>{var i;return(i=n).path??(i.path=[]),n.path.unshift(e),n})}function _o(e){return typeof e==="string"?e:e?.message}function lh(e,t,n){var i;for(let r=t;r<e.length;r++)(i=e[r]).schema??(i.schema=n)}function di(e,t,n){var i;let r=e.inst?._zod?.traits;if(r?.has("$ZodType"))if(r.has("$ZodCheck"))(i=e).schema??(i.schema=e.inst);else e.schema=e.inst;let s=e.schema!==e.inst?e.schema?._zod.def?.error:void 0,o=e.message?e.message:_o(e.inst?._zod.def?.error?.(e))??_o(s?.(e))??_o(t?.error?.(e))??_o(n.customError?.(e))??_o(n.localeError?.(e))??"Invalid input",a={};for(let c of Object.keys(e)){if(c==="inst"||c==="schema"||c==="continue"||c==="input"||c==="__proto__")continue;a[c]=e[c]}if(a.path??(a.path=[]),a.message=o,t?.reportInput)a.input=e.input;return a}var VT=/[\uD800-\uDBFF]/;function sc(e){let t=e.length;if(!VT.test(e))return t;let n=t;for(let i=0;i<t-1;i++)if((e.charCodeAt(i)&64512)===55296&&(e.charCodeAt(i+1)&64512)===56320)n--,i++;return n}function oc(e){if(Array.isArray(e))return"array";if(typeof e==="string")return"string";return"unknown"}function qm(e){let t=typeof e;switch(t){case"number":return Number.isNaN(e)?"nan":"number";case"object":{if(e===null)return"null";if(Array.isArray(e))return"array";let n=e;if(n&&Object.getPrototypeOf(n)!==Object.prototype&&"constructor"in n&&n.constructor)return n.constructor.name}}return t}function Dr(...e){let[t,n,i]=e;if(typeof t==="string")return{message:t,code:"custom",input:n,inst:i};return{...t}}function jm(e,t){for(let n in t){let i=Object.getOwnPropertyDescriptor(t,n);if(i.get)Object.defineProperty(e,n,{...i,enumerable:!1});else $T(e,n,i.value)}}function Ni(e,t,n,i=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:i,value:n}),n}function ac(e,t,n){return Ni(e,t,n,!1)}function Ym(e,t){for(let n in e){let i=e[n];Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get(){return Ni(this,n,i(this))},set(r){Ni(this,n,r)}})}return t}function $T(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:Ni(this,t,n.bind(this))},set(i){Ni(this,t,i)}})}function WT(e,t){let n=Object.getPrototypeOf(e);return t in n?void 0:n}var ih,or=!1,ZT={configurable:!0,get(){or=!0;return}};function tt(e,t,n){let i=Object.getPrototypeOf(e._zod);if(t in i&&ih!==e._zod){ih=void 0;return}ih=e._zod,Object.defineProperty(i,t,{configurable:!0,get(){Object.defineProperty(this,t,ZT);let r=or;or=!1;try{let s=n(this);if(or)delete this[t];else Object.defineProperty(this,t,{configurable:!0,writable:!0,value:s});return or=or||r,s}catch(s){throw delete this[t],or=or||r,s}},set(r){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:r})}})}function XT(e,t,n,i){let r=WT(e,t);if(!r)return;Object.defineProperty(r,t,{configurable:!0,get(){let s={configurable:!0,writable:!0,enumerable:i,value:void 0};return Object.defineProperty(this,t,s),s.value=n(this),Object.defineProperty(this,t,s),s.value},set(s){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:i,value:s})}})}var qT="~constantCatch";function Km(e){let t=()=>e;return t[qT]=!0,t}var Jm;var uh={value:void 0,enumerable:!1},Qm="captureStackTrace"in Error?Error:null;function jT(e){let t=Qm;if(t){let n=t.stackTraceLimit;if(typeof n==="number"){try{t.stackTraceLimit=0}catch{return Qm=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function J(e,t,n,i){let r={};function s(h){this.def=h,this.constr=f,this.traits=new Set}s.prototype=r;let o=n,a=o&&new WeakSet;function c(h,d){if(!h._zod){uh.value=new s(d);try{Object.defineProperty(h,"_zod",uh)}finally{uh.value=void 0}}else if(h._zod.traits.has(e))return;if(h._zod.traits.add(e),t(h,d),a){let x=Object.getPrototypeOf(h),p=h._zod.constr.prototype,m=x;while(m&&m!==p)m=Object.getPrototypeOf(m);let E=m??x;if(!a.has(E))a.add(E),jm(E,o)}let g=f.prototype;for(let x in g){if(!Object.prototype.hasOwnProperty.call(g,x))continue;if(!(x in h))h[x]=g[x].bind(h)}}let l=i?.Parent??Object;class u extends l{}Object.defineProperty(u,"name",{value:e});function f(h){let d=i?.Parent?jT(u):this;c(d,h);let g=d._zod.deferred;if(g){for(let p of g)p();d._zod.deferred=void 0}let x=globalThis.__zod_globalConfig?.postProcessor;if(x)x(d);return d}return Object.defineProperty(f,"init",{value:c}),Object.defineProperty(f,Symbol.hasInstance,{value:(h)=>{if(i?.Parent&&h instanceof i.Parent)return!0;return h?._zod?.traits?.has(e)}}),Object.defineProperty(f,"name",{value:e}),f}class pi extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class So extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`);this.name="ZodEncodeError"}}(Jm=globalThis).__zod_globalConfig??(Jm.__zod_globalConfig={});var dn=globalThis.__zod_globalConfig;function Sn(e){if(e)Object.assign(dn,e);return dn}function YT(){let e=this._zod;return e.message??(e.message=JSON.stringify(e.def,yo,2)),e.message}function KT(e){this._zod.message=e}var JT={get:YT,set:KT,enumerable:!0,configurable:!0},fh={value:void 0,enumerable:!1},eg=new WeakSet([Object.prototype,Error.prototype]),tg=(e,t)=>{e.name="$ZodError",fh.value=t,Object.defineProperty(e,"issues",fh),fh.value=void 0,Object.defineProperty(e,"message",JT);let n=Object.getPrototypeOf(e);if(!eg.has(n))eg.add(n),Object.defineProperty(n,"toString",{configurable:!0,enumerable:!1,get(){let i=()=>this.message;return Object.defineProperty(this,"toString",{value:i,configurable:!0,writable:!0}),i},set(i){Object.defineProperty(this,"toString",{value:i,configurable:!0,writable:!0})}})},ng=J("$ZodError",tg),jI=J("$ZodError",tg,void 0,{Parent:Error});function QT(e,t,n){if(!Object.prototype.hasOwnProperty.call(e,t))if(t==="__proto__")Object.defineProperty(e,t,{value:n(),writable:!0,enumerable:!0,configurable:!0});else e[t]=n();return e[t]}function ig(e,t=(n)=>n.message){let n={},i=[];for(let r of e.issues)if(r.path.length>0)QT(n,r.path[0],()=>[]).push(t(r));else i.push(t(r));return{formErrors:i,fieldErrors:n}}function rg(e,t=(n)=>n.message){let n={_errors:[]},i=(r,s=[])=>{for(let o of r.issues)if(o.code==="invalid_union"&&o.errors.length)o.errors.map((a)=>i({issues:a},[...s,...o.path]));else if(o.code==="invalid_key")i({issues:o.issues},[...s,...o.path]);else if(o.code==="invalid_element")i({issues:o.issues},[...s,...o.path]);else{let a=[...s,...o.path];if(a.length===0)n._errors.push(t(o));else{let c=n,l=0;while(l<a.length){let u=a[l],f=l===a.length-1;if(u==="_errors"){if(f)c._errors.push(t(o));l++;continue}if(!Object.prototype.hasOwnProperty.call(c,u))Object.defineProperty(c,u,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let h=c[u];if(f)h._errors.push(t(o));c=h,l++}}}};return i(e),n}function cc(e,t){return{callee:t?.callee??e,Err:t?.Err}}var lc=(e)=>{let t=(n,i,r,s)=>{let o=r?{...r,async:!1}:{async:!1},a=n._zod.run({value:i,issues:[]},o);if(a instanceof Promise)throw new pi;if(a.issues.length){let c=new(s?.Err??e)(a.issues.map((l)=>di(l,o,Sn())));throw sh(c,s?.callee??t),c}return a.value};return t};var uc=(e)=>{let t=async(n,i,r,s)=>{let o=r?{...r,async:!0}:{async:!0},a=n._zod.run({value:i,issues:[]},o);if(a instanceof Promise)a=await a;if(a.issues.length){let c=new(s?.Err??e)(a.issues.map((l)=>di(l,o,Sn())));throw sh(c,s?.callee??t),c}return a.value};return t};var hc=(e)=>(t,n,i)=>{let r=i?{...i,async:!1}:{async:!1},s=t._zod.run({value:n,issues:[]},r);if(s instanceof Promise)throw new pi;return s.issues.length?sg(e,s.issues,r):{success:!0,data:s.value}};function sg(e,t,n){let i;return{success:!1,get error(){if(!i)i=new e(t.map((r)=>di(r,n,Sn()))),t=void 0,n=void 0;return i},set error(r){i=r,t=void 0,n=void 0}}}var fc=(e)=>async(t,n,i)=>{let r=i?{...i,async:!0}:{async:!0},s=t._zod.run({value:n,issues:[]},r);if(s instanceof Promise)s=await s;return s.issues.length?sg(e,s.issues,r):{success:!0,data:s.value}};var eA=Symbol.for("zod.compile.invalid"),tA=Symbol.for("zod.compile.fallback"),dh=(e,t,n)=>{let i=e._zod.bag.validator;if(i!==void 0){if(i(t)!==eA)return!0;if(i.definite===!0&&n===void 0)return!1}return nA(e,t,n)};function nA(e,t,n){let i=n?{...n,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},r=e._zod.bag.fallbackRun,s;if(r)i[tA]=!0,s=r({value:t,issues:[]},i);else s=e._zod.run({value:t,issues:[]},i);if(s instanceof Promise)throw new pi;return s.issues.length===0}var ph=async(e,t,n)=>{let i=n?{...n,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},r=e._zod.run({value:t,issues:[]},i);if(r instanceof Promise)r=await r;return r.issues.length===0},og=(e)=>{let t=lc(e),n=(i,r,s,o)=>{let a=s?{...s,direction:"backward"}:{direction:"backward"};return t(i,r,a,cc(n,o))};return n};var ag=(e)=>{let t=lc(e),n=(i,r,s,o)=>t(i,r,s,cc(n,o));return n};var cg=(e)=>{let t=uc(e),n=async(i,r,s,o)=>{let a=s?{...s,direction:"backward"}:{direction:"backward"};return await t(i,r,a,cc(n,o))};return n};var lg=(e)=>{let t=uc(e),n=async(i,r,s,o)=>await t(i,r,s,cc(n,o));return n};var ug=(e)=>(t,n,i)=>{let r=i?{...i,direction:"backward"}:{direction:"backward"};return hc(e)(t,n,r)};var hg=(e)=>(t,n,i)=>hc(e)(t,n,i);var fg=(e)=>async(t,n,i)=>{let r=i?{...i,direction:"backward"}:{direction:"backward"};return fc(e)(t,n,r)};var dg=(e)=>async(t,n,i)=>fc(e)(t,n,i);var pg=/^[cC][0-9a-z]{6,}$/,mg=/^[0-9a-z]+$/,gg=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,_g=/^[0-9a-vA-V]{20}$/,xg=/^[A-Za-z0-9]{27}$/,yg=/^[a-zA-Z0-9_-]{21}$/;function vg(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}var bg=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var Sg=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,gh=(e)=>{if(!e)return/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`)};var Mg=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var iA="^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function wg(){return new RegExp(iA,"u")}var Eg=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Tg=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/;var Ag=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,Rg=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Cg=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Pg=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/;var Ig=/^https?$/,Lg=/^\+[1-9]\d{6,14}$/;var Ng="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))";function rA(e){return new RegExp(`^${e}$`)}var Dg=rA(Ng);function mh(e){return typeof e.precision==="number"?e.precision===-1?"(?:[01]\\d|2[0-3]):[0-5]\\d":e.precision===0?"(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d":`(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?"(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?":"(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?"}function Og(e){return new RegExp(`^${mh(e)}$`)}function Ug(e){let t=["Z"];if(e.offset)t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let n=`${mh({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,i=e.local?`${n}|${mh({precision:e.precision})}`:n;return new RegExp(`^${Ng}T(?:${i})$`)}var Fg=/^[\s\S]{0,}$/;var _h=/^-?\d+$/,Mo=/^-?\d+(?:\.\d+)?$/,zg=/^(?:true|false)$/i;var kg=/^[^A-Z]*$/,Bg=/^[^a-z]*$/;var Xt=J("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])});var xh=(e)=>{let t=e.value;return!Um(t)&&t.length!==void 0},dc={number:"number",bigint:"bigint",object:"date"},yh=J("$ZodCheckLessThan",(e,t)=>{Xt.init(e,t);let n=dc[typeof t.value];e._zod.check=(i)=>{if(t.inclusive?i.value<=t.value:i.value<t.value)return;i.issues.push({origin:dc[typeof i.value]??n,code:"too_big",maximum:typeof t.value==="object"?t.value.getTime():t.value,input:i.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),vh=J("$ZodCheckGreaterThan",(e,t)=>{Xt.init(e,t);let n=dc[typeof t.value];e._zod.check=(i)=>{if(t.inclusive?i.value>=t.value:i.value>t.value)return;i.issues.push({origin:dc[typeof i.value]??n,code:"too_small",minimum:typeof t.value==="object"?t.value.getTime():t.value,input:i.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Gg=J("$ZodCheckMultipleOf",(e,t)=>{Xt.init(e,t),e._zod.check=(n)=>{if(typeof n.value!==typeof t.value)throw Error("Cannot mix number and bigint in multiple_of check.");if(typeof n.value==="bigint"?t.value!==BigInt(0)&&n.value%t.value===BigInt(0):Fm(n.value,t.value)===0)return;n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),Hg=J("$ZodCheckNumberFormat",(e,t)=>{Xt.init(e,t),t.format=t.format||"float64";let n=t.format?.includes("int"),i=n?"int":"number",[r,s]=ic[t.format];e._zod.check=(o)=>{let a=o.value;if(n){if(!Number.isInteger(a)){o.issues.push({expected:i,format:t.format,code:"invalid_type",continue:!1,input:a,inst:e});return}if(!Number.isSafeInteger(a)){if(a>0)o.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:i,inclusive:!0,continue:!t.abort});else o.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:i,inclusive:!0,continue:!t.abort});return}}if(a<r)o.issues.push({origin:"number",input:a,code:"too_small",minimum:r,inclusive:!0,inst:e,continue:!t.abort});if(a>s)o.issues.push({origin:"number",input:a,code:"too_big",maximum:s,inclusive:!0,inst:e,continue:!t.abort})}});var Vg=J("$ZodCheckMaxLength",(e,t)=>{var n;Xt.init(e,t),(n=e._zod.def).when??(n.when=xh),e._zod.check=(i)=>{let r=i.value,s=r.length;if((typeof r==="string"&&s>t.maximum?sc(r):s)<=t.maximum)return;let a=oc(r);i.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),$g=J("$ZodCheckMinLength",(e,t)=>{var n;Xt.init(e,t),(n=e._zod.def).when??(n.when=xh),e._zod.check=(i)=>{let r=i.value,s=r.length;if((typeof r==="string"&&s>=t.minimum&&s<t.minimum*2?sc(r):s)>=t.minimum)return;let a=oc(r);i.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Wg=J("$ZodCheckLengthEquals",(e,t)=>{var n;Xt.init(e,t),(n=e._zod.def).when??(n.when=xh),e._zod.check=(i)=>{let r=i.value,s=r.length,o=typeof r==="string"&&s>=t.length&&s<=t.length*2?sc(r):s;if(o===t.length)return;let a=oc(r),c=o>t.length;i.issues.push({origin:a,...c?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:i.value,inst:e,continue:!t.abort})}}),Eo=J("$ZodCheckStringFormat",(e,t)=>{var n,i;if(Xt.init(e,t),t.pattern)(n=e._zod).check??(n.check=(r)=>{if(t.pattern.lastIndex=0,t.pattern.test(r.value))return;r.issues.push({origin:"string",code:"invalid_format",format:t.format,input:r.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})});else(i=e._zod).check??(i.check=()=>{})}),Zg=J("$ZodCheckRegex",(e,t)=>{Eo.init(e,t),e._zod.check=(n)=>{if(t.pattern.lastIndex=0,t.pattern.test(n.value))return;n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Xg=J("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=kg),Eo.init(e,t)}),qg=J("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Bg),Eo.init(e,t)}),jg=J("$ZodCheckIncludes",(e,t)=>{Xt.init(e,t);let n=ar(t.includes),i=new RegExp(typeof t.position==="number"?`^.{${t.position},}${n}`:n);t.pattern=i,e._zod.check=(r)=>{if(r.value.includes(t.includes,t.position))return;r.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:r.value,inst:e,continue:!t.abort})}}),Yg=J("$ZodCheckStartsWith",(e,t)=>{Xt.init(e,t);let n=new RegExp(`^${ar(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.check=(i)=>{if(i.value.startsWith(t.prefix))return;i.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:i.value,inst:e,continue:!t.abort})}}),Kg=J("$ZodCheckEndsWith",(e,t)=>{Xt.init(e,t);let n=new RegExp(`.*${ar(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.check=(i)=>{if(i.value.endsWith(t.suffix))return;i.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:i.value,inst:e,continue:!t.abort})}});var Jg=J("$ZodCheckOverwrite",(e,t)=>{Xt.init(e,t),e._zod.check=(n)=>{n.value=t.tx(n.value)}});class bh{constructor(e=[],t={}){this.content=[],this.indent=0,this.args=e,this.closed=t}indented(e){this.indent+=1;try{e(this)}finally{this.indent-=1}}write(e){if(typeof e==="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}let n=e.split(`
4345
4345
  `).filter((s)=>s),i=Math.min(...n.map((s)=>s.length-s.trimStart().length)),r=n.map((s)=>s.slice(i)).map((s)=>" ".repeat(this.indent*2)+s);for(let s of r)this.content.push(s)}compile(){let e=Function,t=this?.content??[""];return new e(...Object.keys(this.closed),`return function (${this.args.join(", ")}) {
4346
4346
  ${t.join(`
4347
4347
  `)}
4348
- };`)(...Object.values(this.closed))}}var Qg={major:4,minor:6,patch:5};var Mt=Q("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Qg;let i=e._zod.def.checks,r=e._zod.traits.has("$ZodCheck")?[e,...i??[]]:i?.length?[...i]:[];for(let s of r)for(let o of s._zod.onattach)o(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let s=(a,c,l)=>{if(a.memo)return a;let u=fi(a),f;for(let h of c){if(h._zod.def.when){if(Zm(a))continue;if(!h._zod.def.when(a))continue}else if(u)continue;let d=a.issues.length,g=h._zod.check(a);if(g instanceof Promise&&l?.async===!1)throw new pi;if(f||g instanceof Promise)f=(f??Promise.resolve()).then(async()=>{if(await g,a.issues.length===d)return;if(ch(a.issues,d,e),!u)u=fi(a,d)});else{if(a.issues.length===d)continue;if(ch(a.issues,d,e),!u)u=fi(a,d)}}if(f)return f.then(()=>a);return a},o=(a,c,l)=>{if(fi(a))return a.aborted=!0,a;let u=s(c,r,l);if(u instanceof Promise){if(l.async===!1)throw new pi;return u.then((f)=>e._zod.parse(f,l))}return e._zod.parse(u,l)};e._zod.run=(a,c)=>{if(c.skipChecks)return e._zod.parse(a,c);if(c.direction==="backward"){let u=e._zod.parse({value:a.value,issues:[]},{...c,skipChecks:!0});if(u instanceof Promise)return u.then((f)=>o(f,a,c));return o(u,a,c)}let l=e._zod.parse(a,c);if(l instanceof Promise){if(c.async===!1)throw new pi;return l.then((u)=>s(u,r,c))}return s(l,r,c)}}},{get "~standard"(){return oc(this,"~standard",Sh(this))},set "~standard"(e){Li(this,"~standard",e)}}),u_=(e,t)=>e.issues.length?{issues:e.issues.map((n)=>di(n,t,Sn()))}:{value:e.value};async function iA(e,t){let n={async:!0};return u_(await e._zod.run({value:t,issues:[]},n),n)}function Sh(e){return{validate:(t)=>{let n={async:!1};try{let i=e._zod.run({value:t,issues:[]},n);if(!(i instanceof Promise))return u_(i,n)}catch(i){}return iA(e,t)},vendor:"zod",version:1}}var gc=Q("$ZodString",(e,t)=>{Mt.init(e,t),e._zod.pattern=t.pattern??Ug,e._zod.parse=(n,i)=>{if(t.coerce)try{n.value=String(n.value)}catch(r){}if(typeof n.value==="string")return n;return n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),bt=Q("$ZodStringFormat",(e,t)=>{bo.init(e,t),gc.init(e,t)}),h_=Q("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=bg),bt.init(e,t)}),f_=Q("$ZodUUID",(e,t)=>{if(t.version){let i={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(i===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=mh(i))}else t.pattern??(t.pattern=mh());bt.init(e,t)}),d_=Q("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Sg),bt.init(e,t)}),p_=1,pc=2;function m_(e){try{if(typeof URL<"u"&&typeof URL.canParse==="function")return URL.canParse(e);return new URL(e),!0}catch{return!1}}function rA(e,t){if(!("normalize"in t)&&!("hostname"in t)&&!("protocol"in t))return m_(e)||pc;return sA(e,t)}function sA(e,t){if(!t.normalize&&t.protocol?.source===Pg.source&&!/^https?:\/\//i.test(e))return p_;try{if(typeof URL<"u"){let n=URL;if(typeof n.parse==="function")return n.parse(e)??pc}return new URL(e)}catch{return pc}}var oA=/[\t\n\r]/g;function e_(e){return e.replace(oA,"")}function aA(e,t){return t.lastIndex=0,t.test(e.hostname)}function cA(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}var g_=Q("$ZodURL",(e,t)=>{bt.init(e,t),e._zod.check=(n)=>{try{let i=n.value.trim(),r=rA(i,t);if(r===p_){n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort});return}if(r===pc){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort});return}if(r===!0){n.value=e_(i);return}if(t.hostname&&!aA(r,t.hostname))n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort});if(t.protocol&&!cA(r,t.protocol))n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort});n.value=t.normalize?r.href:e_(i);return}catch(i){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),__=Q("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=Mg()),bt.init(e,t)}),x_=Q("$ZodNanoID",(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw Error(`Invalid nanoid length: ${t.length}`);t.pattern??(t.pattern=t.length===void 0?xg:yg(t.length)),bt.init(e,t)}),y_=Q("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=dg),bt.init(e,t)}),v_=Q("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=pg),bt.init(e,t)}),b_=Q("$ZodULID",(e,t)=>{t.pattern??(t.pattern=mg),bt.init(e,t)}),S_=Q("$ZodXID",(e,t)=>{t.pattern??(t.pattern=gg),bt.init(e,t)}),M_=Q("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=_g),bt.init(e,t)}),w_=Q("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=Og(t)),bt.init(e,t)}),E_=Q("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Ng),bt.init(e,t)}),T_=Q("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=Dg(t)),bt.init(e,t)}),A_=Q("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=vg),bt.init(e,t)}),R_=Q("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=wg),bt.init(e,t)}),lA=/^[0-9a-fA-F:.]+$/;function C_(e){if(!lA.test(e))return!1;return m_(`http://[${e}]`)}var P_=Q("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Eg),bt.init(e,t),e._zod.check=(n)=>{if(!C_(n.value))n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}});var I_=Q("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Tg),bt.init(e,t)});function uA(e){let t=e.split("/");if(t.length!==2)return!1;let[n,i]=t;if(!i)return!1;let r=Number(i);if(`${r}`!==i)return!1;if(r<0||r>128)return!1;return C_(n)}var L_=Q("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Ag),bt.init(e,t),e._zod.check=(n)=>{if(!uA(n.value))n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}});function N_(e){if(e==="")return!0;if(/\s/.test(e))return!1;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var Mh=/^[0-9a-zA-Z+/]*={0,2}$/,D_=Q("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=Mh),bt.init(e,t),e._zod.check=(n)=>{if(N_(n.value))return;n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}}),_c=/^[A-Za-z0-9_-]*$/;function hA(e){if(!_c.test(e))return!1;let t=e.replace(/[-_]/g,(i)=>i==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return N_(n)}var O_=Q("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=_c),bt.init(e,t),e._zod.check=(n)=>{if(hA(n.value))return;n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),U_=Q("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Ig),bt.init(e,t)});function fA(e,t=null){try{let n=e.split(".");if(n.length!==3)return!1;let[i]=n;if(!i)return!1;let r=JSON.parse(atob(i));if("typ"in r&&r?.typ!=="JWT")return!1;if(!r.alg)return!1;if(t&&(!("alg"in r)||r.alg!==t))return!1;return!0}catch{return!1}}var F_=Q("$ZodJWT",(e,t)=>{bt.init(e,t),e._zod.check=(n)=>{if(fA(n.value,t.alg))return;n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}});var wh=Q("$ZodNumber",(e,t)=>{Mt.init(e,t),e._zod.pattern=yo,e._zod.parse=(n,i)=>{if(t.coerce)try{n.value=Number(n.value)}catch(o){}let r=n.value;if(typeof r==="number"&&!Number.isNaN(r)&&Number.isFinite(r))return n;let s=typeof r==="number"?Number.isNaN(r)?"NaN":!Number.isFinite(r)?String(r):void 0:void 0;return n.issues.push({expected:"number",code:"invalid_type",input:r,inst:e,...s?{received:s}:{}}),n}}),z_=Q("$ZodNumberFormat",(e,t)=>{Gg.init(e,t),wh.init(e,t)}),k_=Q("$ZodBoolean",(e,t)=>{Mt.init(e,t),e._zod.pattern=Fg,e._zod.parse=(n,i)=>{if(t.coerce)try{n.value=Boolean(n.value)}catch(s){}let r=n.value;if(typeof r==="boolean")return n;return n.issues.push({expected:"boolean",code:"invalid_type",input:r,inst:e}),n}});var B_=Q("$ZodUnknown",(e,t)=>{Mt.init(e,t),e._zod.parse=(n)=>n}),G_=Q("$ZodNever",(e,t)=>{Mt.init(e,t),e._zod.parse=(n,i)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function t_(e,t,n){if(e.issues.length)t.issues.push(...ar(n,e.issues));t.value[n]=e.value}var H_=Q("$ZodArray",(e,t)=>{Mt.init(e,t);let n=dn.memoizer;n?.attach(e),e._zod.parse=(i,r)=>{let s=i.value;if(!Array.isArray(s))return i.issues.push({expected:"array",code:"invalid_type",input:s,inst:e}),i;i.value=n?n.alloc(e,i,Array(s.length),r):Array(s.length);let o=[],a=r?.abortEarly;for(let c=0;c<s.length;c++){let l=s[c],u=t.element._zod.run({value:l,issues:[]},r);if(u instanceof Promise)o.push(u.then((f)=>t_(f,i,c)));else if(t_(u,i,c),a&&u.issues.length!==0&&fi(u))break}if(o.length)return Promise.all(o).then(()=>i);return i}});function mc(e,t,n,i,r,s){let o=n in i,a=s==="optional";if(!o&&a&&r==="optional")return;if(e.issues.length){if(r!==void 0&&a&&!o)return;t.issues.push(...ar(n,e.issues))}if(!o&&r===void 0){if(!e.issues.length)t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[n]});return}if(e.value===void 0){if(o||r==="defaulted"&&!a)t.value[n]=void 0}else t.value[n]=e.value}var dA=[];function V_(e){let t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),i=n.length?n:dA,r=i.length?[...t,...i]:t;for(let o of r)if(!e.shape?.[o]?._zod?.traits?.has("$ZodType"))throw Error(`Invalid element at key "${String(o)}": expected a Zod schema`);let s=Vm(e.shape);return{...e,allKeys:r,symbolKeys:i,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(s)}}function $_(e,t,n,i,r,s,o){let a=[],c=r.keySet,l=r.catchall._zod,u=l.def.type,{optin:f,optout:h}=l,d=0;for(let g in t){if(o&&n.issues.length!==d){if(fi(n,d))break;d=n.issues.length}if(c.has(g))continue;if(g==="__proto__"){if(u==="never")a.push(g);continue}if(u==="never"){a.push(g);continue}let x=l.run({value:t[g],issues:[]},i);if(x instanceof Promise)e.push(x.then((p)=>mc(p,n,g,t,f,h)));else mc(x,n,g,t,f,h)}if(a.length)n.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:s,continue:!0});if(!e.length)return n;return Promise.all(e).then(()=>n)}var pA=Q("$ZodObject",(e,t)=>{Mt.init(e,t);let n=Object.getOwnPropertyDescriptor(t,"shape"),i=n?.get?n.get.raw:t.shape??{};if(i){let l=()=>{let u={...i};return Object.defineProperty(t,"shape",{value:u}),l.raw=u,u};l.raw=i,Object.defineProperty(t,"shape",{get:l})}let r=go(()=>V_(t));nt(e,"propValues",(l)=>{let u=l.def.shape,f={};for(let h in u){let d=u[h]._zod;if(d.values){if(!Object.prototype.hasOwnProperty.call(f,h))Ln(f,h,new Set);for(let g of d.values)f[h].add(g);if(d.optin!==void 0)f[h].add(void 0)}}return f});let s=Ms,o=t.catchall,a,c=dn.memoizer;c?.attach(e),e._zod.parse=(l,u)=>{a??(a=r.value);let f=l.value;if(!s(f))return l.issues.push({expected:"object",code:"invalid_type",input:f,inst:e}),l;l.value=c?c.alloc(e,l,{},u):{};let h=[],d=a.shape,g=u?.abortEarly,x=l.issues.length;for(let p of a.allKeys){if(g&&l.issues.length!==x){if(fi(l,x))break;x=l.issues.length}if(p==="__proto__")continue;let m=d[p],E=m._zod.optin,R=m._zod.optout,v=m._zod.run({value:f[p],issues:[]},u);if(v instanceof Promise)h.push(v.then((M)=>mc(M,l,p,f,E,R)));else mc(v,l,p,f,E,R)}if(!o)return h.length?Promise.all(h).then(()=>l):l;return $_(h,f,l,u,r.value,e,g===!0)}}),W_=Q("$ZodObjectJIT",(e,t)=>{pA.init(e,t);let n=e._zod.parse,i=go(()=>V_(t)),r=dn.memoizer,s=(d)=>{let g=i.value,x=g.symbolKeys,p=new vh(["payload","ctx"],{shape:d,inst:e,memo:r,syms:x}),m=(M)=>`shape[${M}]._zod.run({ value: input[${M}], issues: [] }, ctx)`,E=(M,T)=>`
4348
+ };`)(...Object.values(this.closed))}}var e_={major:4,minor:6,patch:5};var Mt=J("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=e_;let i=e._zod.def.checks,r=e._zod.traits.has("$ZodCheck")?[e,...i??[]]:i?.length?[...i]:[];for(let s of r)for(let o of s._zod.onattach)o(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let s=(a,c,l)=>{if(a.memo)return a;let u=fi(a),f;for(let h of c){if(h._zod.def.when){if(Xm(a))continue;if(!h._zod.def.when(a))continue}else if(u)continue;let d=a.issues.length,g=h._zod.check(a);if(g instanceof Promise&&l?.async===!1)throw new pi;if(f||g instanceof Promise)f=(f??Promise.resolve()).then(async()=>{if(await g,a.issues.length===d)return;if(lh(a.issues,d,e),!u)u=fi(a,d)});else{if(a.issues.length===d)continue;if(lh(a.issues,d,e),!u)u=fi(a,d)}}if(f)return f.then(()=>a);return a},o=(a,c,l)=>{if(fi(a))return a.aborted=!0,a;let u=s(c,r,l);if(u instanceof Promise){if(l.async===!1)throw new pi;return u.then((f)=>e._zod.parse(f,l))}return e._zod.parse(u,l)};e._zod.run=(a,c)=>{if(c.skipChecks)return e._zod.parse(a,c);if(c.direction==="backward"){let u=e._zod.parse({value:a.value,issues:[]},{...c,skipChecks:!0});if(u instanceof Promise)return u.then((f)=>o(f,a,c));return o(u,a,c)}let l=e._zod.parse(a,c);if(l instanceof Promise){if(c.async===!1)throw new pi;return l.then((u)=>s(u,r,c))}return s(l,r,c)}}},{get "~standard"(){return ac(this,"~standard",Mh(this))},set "~standard"(e){Ni(this,"~standard",e)}}),h_=(e,t)=>e.issues.length?{issues:e.issues.map((n)=>di(n,t,Sn()))}:{value:e.value};async function sA(e,t){let n={async:!0};return h_(await e._zod.run({value:t,issues:[]},n),n)}function Mh(e){return{validate:(t)=>{let n={async:!1};try{let i=e._zod.run({value:t,issues:[]},n);if(!(i instanceof Promise))return h_(i,n)}catch(i){}return sA(e,t)},vendor:"zod",version:1}}var _c=J("$ZodString",(e,t)=>{Mt.init(e,t),e._zod.pattern=t.pattern??Fg,e._zod.parse=(n,i)=>{if(t.coerce)try{n.value=String(n.value)}catch(r){}if(typeof n.value==="string")return n;return n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),bt=J("$ZodStringFormat",(e,t)=>{Eo.init(e,t),_c.init(e,t)}),f_=J("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Sg),bt.init(e,t)}),d_=J("$ZodUUID",(e,t)=>{if(t.version){let i={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(i===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=gh(i))}else t.pattern??(t.pattern=gh());bt.init(e,t)}),p_=J("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Mg),bt.init(e,t)}),m_=1,mc=2;function g_(e){try{if(typeof URL<"u"&&typeof URL.canParse==="function")return URL.canParse(e);return new URL(e),!0}catch{return!1}}function oA(e,t){if(!("normalize"in t)&&!("hostname"in t)&&!("protocol"in t))return g_(e)||mc;return aA(e,t)}function aA(e,t){if(!t.normalize&&t.protocol?.source===Ig.source&&!/^https?:\/\//i.test(e))return m_;try{if(typeof URL<"u"){let n=URL;if(typeof n.parse==="function")return n.parse(e)??mc}return new URL(e)}catch{return mc}}var cA=/[\t\n\r]/g;function t_(e){return e.replace(cA,"")}function lA(e,t){return t.lastIndex=0,t.test(e.hostname)}function uA(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}var __=J("$ZodURL",(e,t)=>{bt.init(e,t),e._zod.check=(n)=>{try{let i=n.value.trim(),r=oA(i,t);if(r===m_){n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort});return}if(r===mc){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort});return}if(r===!0){n.value=t_(i);return}if(t.hostname&&!lA(r,t.hostname))n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort});if(t.protocol&&!uA(r,t.protocol))n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort});n.value=t.normalize?r.href:t_(i);return}catch(i){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),x_=J("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=wg()),bt.init(e,t)}),y_=J("$ZodNanoID",(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw Error(`Invalid nanoid length: ${t.length}`);t.pattern??(t.pattern=t.length===void 0?yg:vg(t.length)),bt.init(e,t)}),v_=J("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=pg),bt.init(e,t)}),b_=J("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=mg),bt.init(e,t)}),S_=J("$ZodULID",(e,t)=>{t.pattern??(t.pattern=gg),bt.init(e,t)}),M_=J("$ZodXID",(e,t)=>{t.pattern??(t.pattern=_g),bt.init(e,t)}),w_=J("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=xg),bt.init(e,t)}),E_=J("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=Ug(t)),bt.init(e,t)}),T_=J("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Dg),bt.init(e,t)}),A_=J("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=Og(t)),bt.init(e,t)}),R_=J("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=bg),bt.init(e,t)}),C_=J("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Eg),bt.init(e,t)}),hA=/^[0-9a-fA-F:.]+$/;function P_(e){if(!hA.test(e))return!1;return g_(`http://[${e}]`)}var I_=J("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Tg),bt.init(e,t),e._zod.check=(n)=>{if(!P_(n.value))n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}});var L_=J("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Ag),bt.init(e,t)});function fA(e){let t=e.split("/");if(t.length!==2)return!1;let[n,i]=t;if(!i)return!1;let r=Number(i);if(`${r}`!==i)return!1;if(r<0||r>128)return!1;return P_(n)}var N_=J("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Rg),bt.init(e,t),e._zod.check=(n)=>{if(!fA(n.value))n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}});function D_(e){if(e==="")return!0;if(/\s/.test(e))return!1;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var wh=/^[0-9a-zA-Z+/]*={0,2}$/,O_=J("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=wh),bt.init(e,t),e._zod.check=(n)=>{if(D_(n.value))return;n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}}),xc=/^[A-Za-z0-9_-]*$/;function dA(e){if(!xc.test(e))return!1;let t=e.replace(/[-_]/g,(i)=>i==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return D_(n)}var U_=J("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=xc),bt.init(e,t),e._zod.check=(n)=>{if(dA(n.value))return;n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),F_=J("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Lg),bt.init(e,t)});function pA(e,t=null){try{let n=e.split(".");if(n.length!==3)return!1;let[i]=n;if(!i)return!1;let r=JSON.parse(atob(i));if("typ"in r&&r?.typ!=="JWT")return!1;if(!r.alg)return!1;if(t&&(!("alg"in r)||r.alg!==t))return!1;return!0}catch{return!1}}var z_=J("$ZodJWT",(e,t)=>{bt.init(e,t),e._zod.check=(n)=>{if(pA(n.value,t.alg))return;n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}});var Eh=J("$ZodNumber",(e,t)=>{Mt.init(e,t),e._zod.pattern=Mo,e._zod.parse=(n,i)=>{if(t.coerce)try{n.value=Number(n.value)}catch(o){}let r=n.value;if(typeof r==="number"&&!Number.isNaN(r)&&Number.isFinite(r))return n;let s=typeof r==="number"?Number.isNaN(r)?"NaN":!Number.isFinite(r)?String(r):void 0:void 0;return n.issues.push({expected:"number",code:"invalid_type",input:r,inst:e,...s?{received:s}:{}}),n}}),k_=J("$ZodNumberFormat",(e,t)=>{Hg.init(e,t),Eh.init(e,t)}),B_=J("$ZodBoolean",(e,t)=>{Mt.init(e,t),e._zod.pattern=zg,e._zod.parse=(n,i)=>{if(t.coerce)try{n.value=Boolean(n.value)}catch(s){}let r=n.value;if(typeof r==="boolean")return n;return n.issues.push({expected:"boolean",code:"invalid_type",input:r,inst:e}),n}});var G_=J("$ZodUnknown",(e,t)=>{Mt.init(e,t),e._zod.parse=(n)=>n}),H_=J("$ZodNever",(e,t)=>{Mt.init(e,t),e._zod.parse=(n,i)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function n_(e,t,n){if(e.issues.length)t.issues.push(...cr(n,e.issues));t.value[n]=e.value}var V_=J("$ZodArray",(e,t)=>{Mt.init(e,t);let n=dn.memoizer;n?.attach(e),e._zod.parse=(i,r)=>{let s=i.value;if(!Array.isArray(s))return i.issues.push({expected:"array",code:"invalid_type",input:s,inst:e}),i;i.value=n?n.alloc(e,i,Array(s.length),r):Array(s.length);let o=[],a=r?.abortEarly;for(let c=0;c<s.length;c++){let l=s[c],u=t.element._zod.run({value:l,issues:[]},r);if(u instanceof Promise)o.push(u.then((f)=>n_(f,i,c)));else if(n_(u,i,c),a&&u.issues.length!==0&&fi(u))break}if(o.length)return Promise.all(o).then(()=>i);return i}});function gc(e,t,n,i,r,s){let o=n in i,a=s==="optional";if(!o&&a&&r==="optional")return;if(e.issues.length){if(r!==void 0&&a&&!o)return;t.issues.push(...cr(n,e.issues))}if(!o&&r===void 0){if(!e.issues.length)t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[n]});return}if(e.value===void 0){if(o||r==="defaulted"&&!a)t.value[n]=void 0}else t.value[n]=e.value}var mA=[];function $_(e){let t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),i=n.length?n:mA,r=i.length?[...t,...i]:t;for(let o of r)if(!e.shape?.[o]?._zod?.traits?.has("$ZodType"))throw Error(`Invalid element at key "${String(o)}": expected a Zod schema`);let s=$m(e.shape);return{...e,allKeys:r,symbolKeys:i,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(s)}}function W_(e,t,n,i,r,s,o){let a=[],c=r.keySet,l=r.catchall._zod,u=l.def.type,{optin:f,optout:h}=l,d=0;for(let g in t){if(o&&n.issues.length!==d){if(fi(n,d))break;d=n.issues.length}if(c.has(g))continue;if(g==="__proto__"){if(u==="never")a.push(g);continue}if(u==="never"){a.push(g);continue}let x=l.run({value:t[g],issues:[]},i);if(x instanceof Promise)e.push(x.then((p)=>gc(p,n,g,t,f,h)));else gc(x,n,g,t,f,h)}if(a.length)n.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:s,continue:!0});if(!e.length)return n;return Promise.all(e).then(()=>n)}var gA=J("$ZodObject",(e,t)=>{Mt.init(e,t);let n=Object.getOwnPropertyDescriptor(t,"shape"),i=n?.get?n.get.raw:t.shape??{};if(i){let l=()=>{let u={...i};return Object.defineProperty(t,"shape",{value:u}),l.raw=u,u};l.raw=i,Object.defineProperty(t,"shape",{get:l})}let r=vo(()=>$_(t));tt(e,"propValues",(l)=>{let u=l.def.shape,f={};for(let h in u){let d=u[h]._zod;if(d.values){if(!Object.prototype.hasOwnProperty.call(f,h))Nn(f,h,new Set);for(let g of d.values)f[h].add(g);if(d.optin!==void 0)f[h].add(void 0)}}return f});let s=Ts,o=t.catchall,a,c=dn.memoizer;c?.attach(e),e._zod.parse=(l,u)=>{a??(a=r.value);let f=l.value;if(!s(f))return l.issues.push({expected:"object",code:"invalid_type",input:f,inst:e}),l;l.value=c?c.alloc(e,l,{},u):{};let h=[],d=a.shape,g=u?.abortEarly,x=l.issues.length;for(let p of a.allKeys){if(g&&l.issues.length!==x){if(fi(l,x))break;x=l.issues.length}if(p==="__proto__")continue;let m=d[p],E=m._zod.optin,R=m._zod.optout,v=m._zod.run({value:f[p],issues:[]},u);if(v instanceof Promise)h.push(v.then((M)=>gc(M,l,p,f,E,R)));else gc(v,l,p,f,E,R)}if(!o)return h.length?Promise.all(h).then(()=>l):l;return W_(h,f,l,u,r.value,e,g===!0)}}),Z_=J("$ZodObjectJIT",(e,t)=>{gA.init(e,t);let n=e._zod.parse,i=vo(()=>$_(t)),r=dn.memoizer,s=(d)=>{let g=i.value,x=g.symbolKeys,p=new bh(["payload","ctx"],{shape:d,inst:e,memo:r,syms:x}),m=(M)=>`shape[${M}]._zod.run({ value: input[${M}], issues: [] }, ctx)`,E=(M,T)=>`
4349
4349
  let ${M}_ab = false;
4350
4350
  for (let i = 0; i < ${M}.issues.length; i++) {
4351
4351
  const iss = ${M}.issues[i];
@@ -4356,7 +4356,7 @@ ${t.join(`
4356
4356
  if (${M}_ab && ctx && ctx.abortEarly) {
4357
4357
  payload.value = newResult;
4358
4358
  return payload;
4359
- }`;p.write("const input = payload.value;");let R=Object.create(null),v=0;for(let M of g.allKeys)R[M]=`key_${v++}`;p.write(r?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};");for(let M of g.allKeys){if(M==="__proto__")continue;let T=R[M],A=typeof M==="symbol"?`syms[${x.indexOf(M)}]`:km(M),_=`${A} in input`,S=d[M],k=S?._zod?.optin,C=k!==void 0,U=S?._zod?.optout==="optional";if(p.write(`const ${T} = ${m(A)};`),C&&U){let ee=k==="optional"?`${T}_present`:`${T}.value !== undefined || ${T}_present`;p.write(`
4359
+ }`;p.write("const input = payload.value;");let R=Object.create(null),v=0;for(let M of g.allKeys)R[M]=`key_${v++}`;p.write(r?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};");for(let M of g.allKeys){if(M==="__proto__")continue;let T=R[M],A=typeof M==="symbol"?`syms[${x.indexOf(M)}]`:Bm(M),_=`${A} in input`,S=d[M],z=S?._zod?.optin,P=z!==void 0,F=S?._zod?.optout==="optional";if(p.write(`const ${T} = ${m(A)};`),P&&F){let ee=z==="optional"?`${T}_present`:`${T}.value !== undefined || ${T}_present`;p.write(`
4360
4360
  const ${T}_present = ${_};
4361
4361
  if (!${T}.issues.length || ${T}_present) {
4362
4362
  if (${T}.issues.length) {${E(T,A)}
@@ -4367,7 +4367,7 @@ ${t.join(`
4367
4367
  }
4368
4368
  }
4369
4369
 
4370
- `)}else if(!C)p.write(`
4370
+ `)}else if(!P)p.write(`
4371
4371
  const ${T}_present = ${_};
4372
4372
  if (${T}.issues.length) {${E(T,A)}
4373
4373
  }
@@ -4391,18 +4391,18 @@ ${t.join(`
4391
4391
  `);else if(p.write(`
4392
4392
  if (${T}.issues.length) {${E(T,A)}
4393
4393
  }
4394
- `),k==="defaulted")p.write(`newResult[${A}] = ${T}.value;`);else p.write(`
4394
+ `),z==="defaulted")p.write(`newResult[${A}] = ${T}.value;`);else p.write(`
4395
4395
  if (${T}.value !== undefined || ${_}) {
4396
4396
  newResult[${A}] = ${T}.value;
4397
4397
  }
4398
- `)}return p.write("payload.value = newResult;"),p.write("return payload;"),p.compile()},o,a=Ms,c=!dn.jitless,u=c&&Gm.value,f=t.catchall,h;e._zod.parse=(d,g)=>{h??(h=i.value);let x=d.value;if(!a(x))return d.issues.push({expected:"object",code:"invalid_type",input:x,inst:e}),d;if(c&&u&&g?.async===!1&&g.jitless!==!0){if(!o)o=s(t.shape);if(d=o(d,g),!f)return d;return $_([],x,d,g,h,e,g?.abortEarly===!0)}return n(d,g)}});function n_(e,t,n,i){for(let s of e)if(s.issues.length===0)return t.value=s.value,t;let r=e.filter((s)=>!fi(s));if(r.length===1)return t.value=r[0].value,r[0];return t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map((s)=>s.issues.map((o)=>di(o,i,Sn())))}),t}var Eh=Q("$ZodUnion",(e,t)=>{Mt.init(e,t),nt(e,"optin",(i)=>i.def.options.some((r)=>r._zod.optin==="defaulted")?"defaulted":i.def.options.some((r)=>r._zod.optin!==void 0)?"optional":void 0),nt(e,"optout",(i)=>i.def.options.some((r)=>r._zod.optout==="optional")?"optional":void 0),nt(e,"values",(i)=>{if(i.def.options.every((r)=>r._zod.values))return new Set(i.def.options.flatMap((r)=>Array.from(r._zod.values)));return}),nt(e,"pattern",(i)=>{if(i.def.options.every((r)=>r._zod.pattern)){let r=i.def.options.map((s)=>s._zod.pattern);return new RegExp(`^(${r.map((s)=>tc(s.source)).join("|")})$`)}return});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(i,r)=>{if(n)return n(i,r);let s=!1,o=[];for(let a of t.options){let c=a._zod.run({value:i.value,issues:[]},r);if(c instanceof Promise)o.push(c),s=!0;else{if(c.issues.length===0)return c;o.push(c)}}if(!s)return n_(o,i,e,r);return Promise.all(o).then((a)=>n_(a,i,e,r))}});function mA(e){let t=new Map;for(let n of e.options){let i=n._zod.propValues?.[e.discriminator];if(!i||i.size===0)throw Error(`Invalid discriminated union option at index "${e.options.indexOf(n)}"`);for(let r of i)if(t.has(r)){if(r!==void 0)throw Error(`Duplicate discriminator value "${String(r)}"`);t.set(r,null)}else t.set(r,n)}return t}var Z_=Q("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,Eh.init(e,t);let n=e._zod.parse;nt(e,"propValues",(r)=>{let s={},o=0;for(let a of r.def.options){let c=a._zod.propValues;if(!c||Object.keys(c).length===0)throw Error(`Invalid discriminated union option at index "${r.def.options.indexOf(a)}"`);if(c[r.def.discriminator]?.has(void 0))o++;for(let[l,u]of Object.entries(c)){if(!Object.prototype.hasOwnProperty.call(s,l))Ln(s,l,new Set);for(let f of u)s[l].add(f)}}if(!r.def.unionFallback&&o>1)s[r.def.discriminator]?.delete(void 0);return s}),t.options.forEach((r,s)=>{let o=_o(r._zod.def);if(o&&!Object.prototype.hasOwnProperty.call(o,t.discriminator))throw Error(`Invalid discriminated union option at index "${s}"`)});let i=go(()=>mA(t));e._zod.parse=(r,s)=>{let o=r.value;if(!Ms(o))return r.issues.push({code:"invalid_type",expected:"object",input:o,inst:e}),r;let a=o?.[t.discriminator],c=i.value.get(a);if(c&&(a!==void 0||s.direction!=="backward"))return c._zod.run(r,s);if(t.unionFallback||s.direction==="backward")return n(r,s);return r.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(i.value.keys()).filter((l)=>i.value.get(l)!==null),input:o,path:[t.discriminator],inst:e}),r}}),X_=Q("$ZodIntersection",(e,t)=>{Mt.init(e,t),e._zod.parse=(n,i)=>{let r=n.value,s=t.left._zod.run({value:r,issues:[]},i),o=t.right._zod.run({value:r,issues:[]},i);if(s instanceof Promise||o instanceof Promise)return Promise.all([s,o]).then(([c,l])=>i_(n,c,l));return i_(n,s,o)}});function bh(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e===+t)return{valid:!0,data:e};if(Lr(e)&&Lr(t)){let n=Object.keys(t),i=Object.keys(e).filter((s)=>n.indexOf(s)!==-1),r={...e,...t};if(Object.prototype.hasOwnProperty.call(r,"__proto__"))delete r.__proto__;for(let s of i){if(s==="__proto__")continue;let o=bh(e[s],t[s]);if(!o.valid)return{valid:!1,mergeErrorPath:[s,...o.mergeErrorPath]};r[s]=o.data}return{valid:!0,data:r}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let i=0;i<e.length;i++){let r=e[i],s=t[i],o=bh(r,s);if(!o.valid)return{valid:!1,mergeErrorPath:[i,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function i_(e,t,n){let i=new Map,r,s=new Map,o=(l,u)=>{let f;if(l.code==="unrecognized_keys"&&!l.path?.length)r??(r=l),f=l.keys;else if(l.code==="invalid_key"&&l.origin==="record"&&l.path?.length===1){let h=String(l.path[0]);if(!s.has(h))s.set(h,l);f=[h]}else return!1;for(let h of f){if(!i.has(h))i.set(h,{});i.get(h)[u]=!0}return!0};for(let l of t.issues)if(!o(l,"l"))e.issues.push(l);for(let l of n.issues)if(!o(l,"r"))e.issues.push(l);let a=[...i].filter(([,l])=>l.l&&l.r).map(([l])=>l);if(a.length){let l=r?a.filter((u)=>r.keys.includes(u)):[];if(l.length)e.issues.push({...r,keys:l});for(let u of a)if(!l.includes(u)&&s.has(u))e.issues.push(s.get(u))}let c=bh(t.value,n.value);if(!c.valid){if(fi(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}var q_=Q("$ZodRecord",(e,t)=>{Mt.init(e,t);let n=dn.memoizer;n?.attach(e),e._zod.parse=(i,r)=>{let s=i.value;if(!Lr(s))return i.issues.push({expected:"record",code:"invalid_type",input:s,inst:e}),i;let o=[],a=t.keyType._zod.values;if(a&&!t.partial){i.value=n?n.alloc(e,i,{},r):{};let c=new Set;for(let u of a)if(typeof u==="string"||typeof u==="number"||typeof u==="symbol"){if(c.add(typeof u==="number"?u.toString():u),u==="__proto__")continue;let f=t.keyType._zod.run({value:u,issues:[]},r);if(f instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(f.issues.length){i.issues.push({code:"invalid_key",origin:"record",issues:f.issues.map((g)=>di(g,r,Sn())),input:u,path:[u],inst:e});continue}let h=f.value;if(h==="__proto__")continue;let d=t.valueType._zod.run({value:s[u],issues:[]},r);if(d instanceof Promise)o.push(d.then((g)=>{if(g.issues.length)i.issues.push(...ar(u,g.issues));i.value[h]=g.value}));else{if(d.issues.length)i.issues.push(...ar(u,d.issues));i.value[h]=d.value}}let l;for(let u in s)if(!c.has(u))if(t.mode==="loose"){if(u==="__proto__")continue;i.value[u]=s[u]}else l=l??[],l.push(u);if(l&&l.length>0)i.issues.push({code:"unrecognized_keys",input:s,inst:e,keys:l,continue:!0})}else{i.value=n?n.alloc(e,i,{},r):{};let c;for(let l of Reflect.ownKeys(s)){if(l==="__proto__")continue;if(!Object.prototype.propertyIsEnumerable.call(s,l))continue;let u=t.keyType._zod.run({value:l,issues:[]},r);if(u instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(typeof l==="string"&&yo.test(l)&&u.issues.length){let g=t.keyType._zod.run({value:Number(l),issues:[]},r);if(g instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(g.issues.length===0)u=g}if(u.issues.length){if(t.mode==="loose")i.value[l]=s[l];else if(a)c=c??[],c.push(l);else i.issues.push({code:"invalid_key",origin:"record",issues:u.issues.map((g)=>di(g,r,Sn())),input:l,path:[l],inst:e});continue}let h=u.value;if(h==="__proto__")continue;let d=t.valueType._zod.run({value:s[l],issues:[]},r);if(d instanceof Promise)o.push(d.then((g)=>{if(g.issues.length)i.issues.push(...ar(l,g.issues));i.value[h]=g.value}));else{if(d.issues.length)i.issues.push(...ar(l,d.issues));i.value[h]=d.value}}if(c&&c.length>0)i.issues.push({code:"unrecognized_keys",input:s,inst:e,keys:c,continue:!0})}if(o.length)return Promise.all(o).then(()=>i);return i}});var j_=Q("$ZodEnum",(e,t)=>{Mt.init(e,t);let n=po(t.entries),i=new Set(n);e._zod.values=i,nt(e,"pattern",(r)=>{let s=po(r.def.entries).filter((o)=>Hm.has(typeof o));return new RegExp(s.length?`^(${s.map((o)=>or(o.toString())).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(r,s)=>{let o=r.value;if(i.has(o))return r;return r.issues.push({code:"invalid_value",values:n,input:o,inst:e}),r}}),Y_=Q("$ZodLiteral",(e,t)=>{Mt.init(e,t);let n=new Set(t.values);e._zod.values=n,nt(e,"pattern",(i)=>{let r=i.def.values;return new RegExp(r.length?`^(${r.map((s)=>typeof s==="string"?or(s):s?or(s.toString()):String(s)).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(i,r)=>{let s=i.value;if(n.has(s))return i;return i.issues.push({code:"invalid_value",values:t.values,input:s,inst:e}),i}});var K_=Q("$ZodTransform",(e,t)=>{Mt.init(e,t),e._zod.optin="optional",dn.memoizer?.guard(e),e._zod.parse=(n,i)=>{if(i.direction==="backward")throw new xo(e.constructor.name);let r=t.transform(n.value,n);if(i.async)return(r instanceof Promise?r:Promise.resolve(r)).then((o)=>(n.value=o,n));if(r instanceof Promise)throw new pi;return n.value=r,n}});function r_(e,t){return e.value=t.issues.length?void 0:t.value,e}var Th=Q("$ZodOptional",(e,t)=>{Mt.init(e,t),nt(e,"optin",(n)=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",nt(e,"values",(n)=>{let i=n.def.innerType._zod.values;return i?new Set([...i,void 0]):void 0}),nt(e,"pattern",(n)=>{let i=n.def.innerType._zod.pattern;return i?new RegExp(`^(${tc(i.source)})?$`):void 0}),e._zod.parse=(n,i)=>{if(n.value===void 0){if(t.innerType._zod.optin!=="defaulted")return n;let r=t.innerType._zod.run({value:n.value,issues:[]},i);if(r instanceof Promise)return r.then((s)=>r_(n,s));return r_(n,r)}return t.innerType._zod.run(n,i)}}),J_=Q("$ZodExactOptional",(e,t)=>{Th.init(e,t),nt(e,"values",(n)=>n.def.innerType._zod.values),nt(e,"pattern",(n)=>n.def.innerType._zod.pattern),e._zod.parse=(n,i)=>t.innerType._zod.run(n,i)}),Q_=Q("$ZodNullable",(e,t)=>{Mt.init(e,t),nt(e,"optin",(n)=>n.def.innerType._zod.optin),nt(e,"optout",(n)=>n.def.innerType._zod.optout),nt(e,"pattern",(n)=>{let i=n.def.innerType._zod.pattern;return i?new RegExp(`^(${tc(i.source)}|null)$`):void 0}),nt(e,"values",(n)=>n.def.innerType._zod.values?new Set([...n.def.innerType._zod.values,null]):void 0),e._zod.parse=(n,i)=>{if(n.value===null)return n;return t.innerType._zod.run(n,i)}}),e0=Q("$ZodDefault",(e,t)=>{Mt.init(e,t),e._zod.optin="defaulted",nt(e,"values",(n)=>n.def.innerType._zod.values),e._zod.parse=(n,i)=>{if(i.direction==="backward")return t.innerType._zod.run(n,i);if(n.value===void 0)return n.value=t.defaultValue,n;let r=t.innerType._zod.run(n,i);if(r instanceof Promise)return r.then((s)=>s_(s,t));return s_(r,t)}});function s_(e,t){if(e.value===void 0)e.value=t.defaultValue;return e}var t0=Q("$ZodPrefault",(e,t)=>{Mt.init(e,t),e._zod.optin="defaulted",nt(e,"values",(n)=>n.def.innerType._zod.values),e._zod.parse=(n,i)=>{if(i.direction==="backward")return t.innerType._zod.run(n,i);if(n.value===void 0)n.value=t.defaultValue;return t.innerType._zod.run(n,i)}}),n0=Q("$ZodNonOptional",(e,t)=>{Mt.init(e,t),nt(e,"values",(n)=>{let i=n.def.innerType._zod.values;return i?new Set([...i].filter((r)=>r!==void 0)):void 0}),e._zod.parse=(n,i)=>{let r=t.innerType._zod.run(n,i);if(r instanceof Promise)return r.then((s)=>o_(s,e));return o_(r,e)}});function o_(e,t){if(!e.issues.length&&e.value===void 0)e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t});return e}function a_(e,t,n,i){if(!t.issues.length){if(e.value=t.value,t.memo)e.memo=!0;return e}return e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map((r)=>di(r,i,Sn()))},input:e.value}),e}var i0=Q("$ZodCatch",(e,t)=>{Mt.init(e,t),nt(e,"optin",(n)=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),nt(e,"optout",(n)=>n.def.innerType._zod.optout),nt(e,"values",(n)=>n.def.innerType._zod.values),e._zod.parse=(n,i)=>{if(i.direction==="backward")return t.innerType._zod.run(n,i);let r=t.innerType._zod.run({value:n.value,issues:[]},i);if(r instanceof Promise)return r.then((s)=>a_(n,s,t,i));return a_(n,r,t,i)}});var r0=Q("$ZodPipe",(e,t)=>{Mt.init(e,t),nt(e,"values",(n)=>n.def.in._zod.values),nt(e,"optin",(n)=>n.def.in._zod.optin),nt(e,"optout",(n)=>n.def.out._zod.optout),nt(e,"propValues",(n)=>n.def.in._zod.propValues),e._zod.parse=(n,i)=>{if(i.direction==="backward"){let s=t.out._zod.run(n,i);if(s instanceof Promise)return s.then((o)=>dc(o,t.in,i));return dc(s,t.in,i)}let r=t.in._zod.run(n,i);if(r instanceof Promise)return r.then((s)=>dc(s,t.out,i));return dc(r,t.out,i)}});function dc(e,t,n){if(e.issues.some((i)=>i.code!=="unrecognized_keys"))return e.aborted=!0,e;return t._zod.run({value:e.value,issues:e.issues},n)}var s0=Q("$ZodReadonly",(e,t)=>{Mt.init(e,t),nt(e,"propValues",(n)=>n.def.innerType._zod.propValues),nt(e,"values",(n)=>n.def.innerType._zod.values),nt(e,"optin",(n)=>n.def.innerType?._zod?.optin),nt(e,"optout",(n)=>n.def.innerType?._zod?.optout),e._zod.parse=(n,i)=>{if(i.direction==="backward")return t.innerType._zod.run(n,i);let r=t.innerType._zod.run(n,i);if(r instanceof Promise)return r.then(c_);return c_(r)}});function c_(e){if(!e.memo)e.value=Object.freeze(e.value);return e}var o0=Q("$ZodCustom",(e,t)=>{Xt.init(e,t),Mt.init(e,t),e._zod.parse=(n,i)=>n,e._zod.check=(n)=>{let i=n.value,r=t.fn(i);if(r instanceof Promise)return r.then((s)=>l_(s,n,i,e));l_(r,n,i,e);return}});function l_(e,t,n,i){if(!e){let r={code:"custom",input:n,inst:i,path:[...i._zod.def.path??[]],continue:!i._zod.def.abort};if(i._zod.def.params)r.params=i._zod.def.params;t.issues.push(Nr(r))}}class c0 extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform");this.name="ZodCyclicError"}}var Rh="~memo",a0=[];function l0(e){return e!==null&&typeof e==="object"}function Ah(e){return e.map((t)=>t.path?{...t,path:t.path.slice()}:{...t})}var u0=new WeakMap,So=0,vc=1,Mo=2;function bc(e,t,n){let i=u0.get(e);if(i!==void 0)return i?Mo:So;if(t.has(e))return Mo;t.add(e);let r=So,s=(u)=>{if(r!==Mo&&u?._zod){let f=bc(u,t,n);if(f>r)r=f}},o=(u,f)=>{let h=So;for(let d of Reflect.ownKeys(u)){let g=Object.getOwnPropertyDescriptor(u,d);if(f&&!g.enumerable)continue;let x=g.get?vc:g.value?._zod?bc(g.value,t,n):So;if(x>h)h=x}return h},a=(u)=>{if(u>r)r=u},c=e._zod.def,l=c.type;switch(l){case"object":{let u=_o(c);a(u?o(u,!0):vc),s(c.catchall);break}case"array":s(c.element);break;case"tuple":for(let u of c.items)s(u);s(c.rest);break;case"record":case"map":s(c.keyType),s(c.valueType);break;case"set":s(c.valueType);break;case"union":for(let u of c.options)s(u);break;case"intersection":s(c.left),s(c.right);break;case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":s(c.innerType);break;case"pipe":s(c.in),s(c.out);break;case"function":s(c.input),s(c.output);break;case"lazy":{let u=c._cachedInner??(n?e._zod.innerType:void 0);a(u?bc(u,t,!1):vc);break}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":break;default:for(let u in c){let f=Object.getOwnPropertyDescriptor(c,u);if(!f||f.get)continue;let h=f.value;if(!h||typeof h!=="object")continue;if(h._zod)s(h);else if(Array.isArray(h))for(let d of h)s(d)}}return t.delete(e),gA(e,r)}function gA(e,t){if(t!==vc)u0.set(e,t===Mo);return t}function _A(e,t){let n=e.buckets.get(t);if(!n)n=new WeakMap,e.buckets.set(t,n);return n}var xc,yc=[],xA={alloc(e,t,n){let i=xc;if(!i)return n;xc=void 0;let r={value:n,issues:null};return i.set(t.value,r),yc.push(r),n},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let n=e._zod.parse,i=(r,s)=>{if(s.direction!=="backward"&&yA(s,r.value))throw new c0;return n(r,s)};if(e._zod.parse=i,e._zod.run===n)e._zod.run=i})},attach(e){var t;let n,i=!1,r,s;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let o=e._zod.parse,a=(c,l)=>{if(n===void 0){let m=bc(e,new Set,!1);if(m===So){if(e._zod.parse=o,e._zod.run===a)e._zod.run=o;return o(c,l)}if(m===Mo||i)n=!0;else i=!0}let u=c.value;if(!l0(u))return o(c,l);let f=l[Rh];if(!f)f={buckets:new WeakMap,backEdges:void 0},l[Rh]=f;let h;if(r===l)h=s;else h=_A(f,e),r=l,s=h;let d=h.get(u);if(d){if(c.value=d.value,d.issues){if(d.issues.length)c.issues.push(...Ah(d.issues))}else c.memo=!0,f.backEdges??(f.backEdges=new WeakSet),f.backEdges.add(d.value);return c}xc=h;let g=yc.length,x=o(c,l);xc=void 0;let p=yc.length>g?yc.pop():void 0;if(x instanceof Promise)return x.then((m)=>{if(p)p.issues=m.issues.length?Ah(m.issues):a0;return m});if(p)p.issues=x.issues.length?Ah(x.issues):a0;return x};if(e._zod.parse=a,e._zod.run===o)e._zod.run=a})}};function h0(){return xA}function yA(e,t){let n=e[Rh]?.backEdges;return n!==void 0&&l0(t)&&n.has(t)}var vA=()=>{let e={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function t(s){return e[s]??null}let n={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",currency_code:"currency code",credit_card:"credit card number",iban:"IBAN",jwt:"JWT",template_literal:"input"},i={nan:"NaN"};function r(s,o){if(s==="number"&&typeof o==="number"&&!Number.isFinite(o))return String(o);return i[s]??s}return(s)=>{switch(s.code){case"invalid_type":{let o=r(s.expected),a=Xm(s.input),c=r(a,s.input);return`Invalid input: expected ${o}, received ${c}`}case"invalid_value":if(s.values.length===1)return`Invalid input: expected ${oh(s.values[0])}`;return`Invalid option: expected one of ${ih(s.values,"|")}`;case"too_big":{let o=s.exact?"exactly ":s.inclusive?"<=":"<",a=t(s.origin);if(a)return`Too big: expected ${s.origin??"value"} to have ${o}${s.maximum.toString()} ${a.unit??"elements"}`;return`Too big: expected ${s.origin??"value"} to be ${o}${s.maximum.toString()}`}case"too_small":{let o=s.exact?"exactly ":s.inclusive?">=":">",a=t(s.origin);if(a)return`Too small: expected ${s.origin} to have ${o}${s.minimum.toString()} ${a.unit}`;return`Too small: expected ${s.origin} to be ${o}${s.minimum.toString()}`}case"invalid_format":{let o=s;if(o.format==="starts_with")return`Invalid string: must start with "${o.prefix}"`;if(o.format==="ends_with")return`Invalid string: must end with "${o.suffix}"`;if(o.format==="includes")return`Invalid string: must include "${o.includes}"`;if(o.format==="regex")return`Invalid string: must match pattern ${o.pattern}`;return`Invalid ${n[o.format]??s.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${s.divisor}`;case"unrecognized_keys":return`Unrecognized key${s.keys.length>1?"s":""}: ${ih(s.keys,", ")}`;case"invalid_key":return`Invalid key in ${s.origin}`;case"invalid_union":if(s.options&&Array.isArray(s.options)&&s.options.length>0)return`Invalid discriminator value. Expected ${s.options.map((a)=>`'${a}'`).join(" | ")}`;if(s.inclusive===!1)return"Invalid input: more than one option matched";return"Invalid input";case"invalid_element":return`Invalid value in ${s.origin}`;default:return"Invalid input"}}};function Ch(){return{localeError:vA()}}var f0;class d0{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];if(this._map.set(e,n),n&&typeof n==="object"&&"id"in n)this._idmap.set(n.id,e);return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);if(t&&typeof t==="object"&&"id"in t)this._idmap.delete(t.id);return this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let i={...n,...this._map.get(e)};return Object.keys(i).length?i:void 0}return this._map.get(e)}has(e){return this._map.has(e)}}function bA(){return new d0}(f0=globalThis).__zod_globalRegistry??(f0.__zod_globalRegistry=bA());var Dr=globalThis.__zod_globalRegistry;function p0(e){if(e.checks)e.checks=[...e.checks];return e}function m0(e,t){return new e(p0({type:"string",...Re(t)}))}function g0(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...Re(t)})}function _0(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...Re(t)})}function x0(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...Re(t)})}function y0(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...Re(t)})}function v0(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...Re(t)})}function b0(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...Re(t)})}function S0(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...Re(t)})}function M0(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...Re(t)})}function w0(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...Re(t)})}function E0(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...Re(t)})}function T0(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...Re(t)})}function A0(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...Re(t)})}function R0(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...Re(t)})}function C0(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...Re(t)})}function P0(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...Re(t)})}function I0(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...Re(t)})}function L0(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...Re(t)})}function N0(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...Re(t)})}function D0(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...Re(t)})}function O0(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...Re(t)})}function U0(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...Re(t)})}function F0(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...Re(t)})}function z0(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...Re(t)})}function k0(e,t){return new e({type:"string",format:"date",check:"string_format",...Re(t)})}function B0(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...Re(t)})}function G0(e,t){return new e({type:"string",format:"duration",check:"string_format",...Re(t)})}function H0(e,t){return new e(p0({type:"number",checks:[],...Re(t)}))}function V0(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...Re(t)})}function $0(e,t){return new e({type:"boolean",...Re(t)})}function W0(e){return new e({type:"unknown"})}function Z0(e,t){return new e({type:"never",...Re(t)})}function Sc(e,t){return new xh({check:"less_than",...Re(t),value:e,inclusive:!1})}function wo(e,t){return new xh({check:"less_than",...Re(t),value:e,inclusive:!0})}function Mc(e,t){return new yh({check:"greater_than",...Re(t),value:e,inclusive:!1})}function Eo(e,t){return new yh({check:"greater_than",...Re(t),value:e,inclusive:!0})}function wc(e,t){return new Bg({check:"multiple_of",...Re(t),value:e})}function Ec(e,t){return new Hg({check:"max_length",...Re(t),maximum:e})}function ws(e,t){return new Vg({check:"min_length",...Re(t),minimum:e})}function Tc(e,t){return new $g({check:"length_equals",...Re(t),length:e})}function Ph(e,t){return new Wg({check:"string_format",format:"regex",...Re(t),pattern:e})}function Ih(e){return new Zg({check:"string_format",format:"lowercase",...Re(e)})}function Lh(e){return new Xg({check:"string_format",format:"uppercase",...Re(e)})}function Nh(e,t){return new qg({check:"string_format",format:"includes",...Re(t),includes:e})}function Dh(e,t){return new jg({check:"string_format",format:"starts_with",...Re(t),prefix:e})}function Oh(e,t){return new Yg({check:"string_format",format:"ends_with",...Re(t),suffix:e})}function cr(e){return new Kg({check:"overwrite",tx:e})}function Uh(e){return cr((t)=>t.normalize(e))}function Fh(){return cr((e)=>e.trim())}function zh(){return cr((e)=>e.toLowerCase())}function kh(){return cr((e)=>e.toUpperCase())}function Bh(){return cr((e)=>Bm(e))}function X0(e,t,n){return new e({type:"array",element:t,...Re(n)})}function q0(e,t,n){return new e({type:"custom",check:"custom",fn:t,...Re(n)})}function j0(e,t){let n=SA((i)=>(i.addIssue=(r)=>{if(typeof r==="string")i.issues.push(Nr(r,i.value,n._zod.def));else{let s=r;if(s.fatal)s.continue=!1;if(s.code??(s.code="custom"),!("input"in s))s.input=i.value;s.inst??(s.inst=n),s.continue??(s.continue=!n._zod.def.abort),i.issues.push(Nr(s))}},e(i.value,i)),t);return n}function SA(e,t){let n=new Xt({check:"custom",...Re(t)});return n._zod.check=e,n}function To(e,...t){for(let n of t)for(let i of Reflect.ownKeys(n))if(Object.prototype.propertyIsEnumerable.call(n,i))Ln(e,i,n[i]);return e}function Hh(e){let t=e?.target??"draft-2020-12";if(t==="draft-4")t="draft-04";if(t==="draft-7")t="draft-07";return{processors:e.processors??{},metadataRegistry:e?.metadata??Dr,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??"ref",reused:e?.reused??"inline",intersections:[],deferred:[],external:e?.external??void 0}}function Ni(e,t,n,i,r){let s=typeof t.unrepresentable==="function"?t.unrepresentable({zodSchema:e,path:i.path,message:r}):t.unrepresentable;if(s==="any")return!1;if(s===void 0||s==="throw")throw Error(r);return Object.assign(n,s),!0}function It(e,t,n={path:[],schemaPath:[]}){var i;let r=e._zod.def,s=t.seen.get(e);if(s){if(s.count++,n.schemaPath.includes(e))s.cycle=n.path;return s.schema}let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let a=e._zod.toJSONSchema?.();if(a)o.schema=a;else{let u={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,u);else{let h=o.schema,d=t.processors[r.type];if(!d)throw Error(`[toJSONSchema]: Non-representable type encountered: ${r.type}`);d(e,t,h,u)}let f=e._zod.parent;if(f){if(!o.ref)o.ref=f;It(f,t,u),t.seen.get(f).isParent=!0}}let c=t.metadataRegistry.get(e);if(c)To(o.schema,c);if(t.io==="input"&&on(e))delete o.schema.examples,delete o.schema.default;if(t.io==="input"&&"_prefault"in o.schema)(i=o.schema).default??(i.default=o.schema._prefault);return delete o.schema._prefault,t.seen.get(e).schema}function Y0(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function Vh(e,t){let n=e.seen.get(t);if(!n)throw Error("Unprocessed schema. This is a bug in Zod.");if(e.external&&e.sharedDefsExtractedFor===e.external)return;let i=new Map;for(let o of e.seen.entries()){let a=e.metadataRegistry.get(o[0])?.id;if(a){let c=i.get(a);if(c&&c!==o[0])throw Error(`Duplicate schema id "${a}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);i.set(a,o[0])}}let r=(o)=>{let a=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let f=e.external.registry.get(o[0])?.id,h=e.external.uri??((g)=>g);if(f)return{ref:h(f)};let d=o[1].defId??o[1].schema.id??`schema${e.counter++}`;return o[1].defId=d,{defId:d,ref:`${h("__shared")}#/${a}/${Y0(d)}`}}let c="#",l=`${c}/${a}/`;if(o[1]===n&&!o[1].schema.id)return{ref:c};let u=o[1].schema.id??`__schema${e.counter++}`;return{defId:u,ref:l+Y0(u)}},s=(o)=>{if(o[1].schema.$ref)return;let a=o[1],{ref:c,defId:l}=r(o);if(a.def={...a.schema},l)a.defId=l;let u=a.schema;for(let f in u)delete u[f];u.$ref=c};if(e.cycles==="throw")for(let o of e.seen.entries()){let a=o[1];if(a.cycle)throw Error(`Cycle detected: #/${a.cycle?.join("/")}/<root>
4398
+ `)}return p.write("payload.value = newResult;"),p.write("return payload;"),p.compile()},o,a=Ts,c=!dn.jitless,u=c&&Hm.value,f=t.catchall,h;e._zod.parse=(d,g)=>{h??(h=i.value);let x=d.value;if(!a(x))return d.issues.push({expected:"object",code:"invalid_type",input:x,inst:e}),d;if(c&&u&&g?.async===!1&&g.jitless!==!0){if(!o)o=s(t.shape);if(d=o(d,g),!f)return d;return W_([],x,d,g,h,e,g?.abortEarly===!0)}return n(d,g)}});function i_(e,t,n,i){for(let s of e)if(s.issues.length===0)return t.value=s.value,t;let r=e.filter((s)=>!fi(s));if(r.length===1)return t.value=r[0].value,r[0];return t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map((s)=>s.issues.map((o)=>di(o,i,Sn())))}),t}var Th=J("$ZodUnion",(e,t)=>{Mt.init(e,t),tt(e,"optin",(i)=>i.def.options.some((r)=>r._zod.optin==="defaulted")?"defaulted":i.def.options.some((r)=>r._zod.optin!==void 0)?"optional":void 0),tt(e,"optout",(i)=>i.def.options.some((r)=>r._zod.optout==="optional")?"optional":void 0),tt(e,"values",(i)=>{if(i.def.options.every((r)=>r._zod.values))return new Set(i.def.options.flatMap((r)=>Array.from(r._zod.values)));return}),tt(e,"pattern",(i)=>{if(i.def.options.every((r)=>r._zod.pattern)){let r=i.def.options.map((s)=>s._zod.pattern);return new RegExp(`^(${r.map((s)=>nc(s.source)).join("|")})$`)}return});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(i,r)=>{if(n)return n(i,r);let s=!1,o=[];for(let a of t.options){let c=a._zod.run({value:i.value,issues:[]},r);if(c instanceof Promise)o.push(c),s=!0;else{if(c.issues.length===0)return c;o.push(c)}}if(!s)return i_(o,i,e,r);return Promise.all(o).then((a)=>i_(a,i,e,r))}});function _A(e){let t=new Map;for(let n of e.options){let i=n._zod.propValues?.[e.discriminator];if(!i||i.size===0)throw Error(`Invalid discriminated union option at index "${e.options.indexOf(n)}"`);for(let r of i)if(t.has(r)){if(r!==void 0)throw Error(`Duplicate discriminator value "${String(r)}"`);t.set(r,null)}else t.set(r,n)}return t}var X_=J("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,Th.init(e,t);let n=e._zod.parse;tt(e,"propValues",(r)=>{let s={},o=0;for(let a of r.def.options){let c=a._zod.propValues;if(!c||Object.keys(c).length===0)throw Error(`Invalid discriminated union option at index "${r.def.options.indexOf(a)}"`);if(c[r.def.discriminator]?.has(void 0))o++;for(let[l,u]of Object.entries(c)){if(!Object.prototype.hasOwnProperty.call(s,l))Nn(s,l,new Set);for(let f of u)s[l].add(f)}}if(!r.def.unionFallback&&o>1)s[r.def.discriminator]?.delete(void 0);return s}),t.options.forEach((r,s)=>{let o=bo(r._zod.def);if(o&&!Object.prototype.hasOwnProperty.call(o,t.discriminator))throw Error(`Invalid discriminated union option at index "${s}"`)});let i=vo(()=>_A(t));e._zod.parse=(r,s)=>{let o=r.value;if(!Ts(o))return r.issues.push({code:"invalid_type",expected:"object",input:o,inst:e}),r;let a=o?.[t.discriminator],c=i.value.get(a);if(c&&(a!==void 0||s.direction!=="backward"))return c._zod.run(r,s);if(t.unionFallback||s.direction==="backward")return n(r,s);return r.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(i.value.keys()).filter((l)=>i.value.get(l)!==null),input:o,path:[t.discriminator],inst:e}),r}}),q_=J("$ZodIntersection",(e,t)=>{Mt.init(e,t),e._zod.parse=(n,i)=>{let r=n.value,s=t.left._zod.run({value:r,issues:[]},i),o=t.right._zod.run({value:r,issues:[]},i);if(s instanceof Promise||o instanceof Promise)return Promise.all([s,o]).then(([c,l])=>r_(n,c,l));return r_(n,s,o)}});function Sh(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e===+t)return{valid:!0,data:e};if(Nr(e)&&Nr(t)){let n=Object.keys(t),i=Object.keys(e).filter((s)=>n.indexOf(s)!==-1),r={...e,...t};if(Object.prototype.hasOwnProperty.call(r,"__proto__"))delete r.__proto__;for(let s of i){if(s==="__proto__")continue;let o=Sh(e[s],t[s]);if(!o.valid)return{valid:!1,mergeErrorPath:[s,...o.mergeErrorPath]};r[s]=o.data}return{valid:!0,data:r}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let i=0;i<e.length;i++){let r=e[i],s=t[i],o=Sh(r,s);if(!o.valid)return{valid:!1,mergeErrorPath:[i,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function r_(e,t,n){let i=new Map,r,s=new Map,o=(l,u)=>{let f;if(l.code==="unrecognized_keys"&&!l.path?.length)r??(r=l),f=l.keys;else if(l.code==="invalid_key"&&l.origin==="record"&&l.path?.length===1){let h=String(l.path[0]);if(!s.has(h))s.set(h,l);f=[h]}else return!1;for(let h of f){if(!i.has(h))i.set(h,{});i.get(h)[u]=!0}return!0};for(let l of t.issues)if(!o(l,"l"))e.issues.push(l);for(let l of n.issues)if(!o(l,"r"))e.issues.push(l);let a=[...i].filter(([,l])=>l.l&&l.r).map(([l])=>l);if(a.length){let l=r?a.filter((u)=>r.keys.includes(u)):[];if(l.length)e.issues.push({...r,keys:l});for(let u of a)if(!l.includes(u)&&s.has(u))e.issues.push(s.get(u))}let c=Sh(t.value,n.value);if(!c.valid){if(fi(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}var j_=J("$ZodRecord",(e,t)=>{Mt.init(e,t);let n=dn.memoizer;n?.attach(e),e._zod.parse=(i,r)=>{let s=i.value;if(!Nr(s))return i.issues.push({expected:"record",code:"invalid_type",input:s,inst:e}),i;let o=[],a=t.keyType._zod.values;if(a&&!t.partial){i.value=n?n.alloc(e,i,{},r):{};let c=new Set;for(let u of a)if(typeof u==="string"||typeof u==="number"||typeof u==="symbol"){if(c.add(typeof u==="number"?u.toString():u),u==="__proto__")continue;let f=t.keyType._zod.run({value:u,issues:[]},r);if(f instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(f.issues.length){i.issues.push({code:"invalid_key",origin:"record",issues:f.issues.map((g)=>di(g,r,Sn())),input:u,path:[u],inst:e});continue}let h=f.value;if(h==="__proto__")continue;let d=t.valueType._zod.run({value:s[u],issues:[]},r);if(d instanceof Promise)o.push(d.then((g)=>{if(g.issues.length)i.issues.push(...cr(u,g.issues));i.value[h]=g.value}));else{if(d.issues.length)i.issues.push(...cr(u,d.issues));i.value[h]=d.value}}let l;for(let u in s)if(!c.has(u))if(t.mode==="loose"){if(u==="__proto__")continue;i.value[u]=s[u]}else l=l??[],l.push(u);if(l&&l.length>0)i.issues.push({code:"unrecognized_keys",input:s,inst:e,keys:l,continue:!0})}else{i.value=n?n.alloc(e,i,{},r):{};let c;for(let l of Reflect.ownKeys(s)){if(l==="__proto__")continue;if(!Object.prototype.propertyIsEnumerable.call(s,l))continue;let u=t.keyType._zod.run({value:l,issues:[]},r);if(u instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(typeof l==="string"&&Mo.test(l)&&u.issues.length){let g=t.keyType._zod.run({value:Number(l),issues:[]},r);if(g instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(g.issues.length===0)u=g}if(u.issues.length){if(t.mode==="loose")i.value[l]=s[l];else if(a)c=c??[],c.push(l);else i.issues.push({code:"invalid_key",origin:"record",issues:u.issues.map((g)=>di(g,r,Sn())),input:l,path:[l],inst:e});continue}let h=u.value;if(h==="__proto__")continue;let d=t.valueType._zod.run({value:s[l],issues:[]},r);if(d instanceof Promise)o.push(d.then((g)=>{if(g.issues.length)i.issues.push(...cr(l,g.issues));i.value[h]=g.value}));else{if(d.issues.length)i.issues.push(...cr(l,d.issues));i.value[h]=d.value}}if(c&&c.length>0)i.issues.push({code:"unrecognized_keys",input:s,inst:e,keys:c,continue:!0})}if(o.length)return Promise.all(o).then(()=>i);return i}});var Y_=J("$ZodEnum",(e,t)=>{Mt.init(e,t);let n=xo(t.entries),i=new Set(n);e._zod.values=i,tt(e,"pattern",(r)=>{let s=xo(r.def.entries).filter((o)=>Vm.has(typeof o));return new RegExp(s.length?`^(${s.map((o)=>ar(o.toString())).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(r,s)=>{let o=r.value;if(i.has(o))return r;return r.issues.push({code:"invalid_value",values:n,input:o,inst:e}),r}}),K_=J("$ZodLiteral",(e,t)=>{Mt.init(e,t);let n=new Set(t.values);e._zod.values=n,tt(e,"pattern",(i)=>{let r=i.def.values;return new RegExp(r.length?`^(${r.map((s)=>typeof s==="string"?ar(s):s?ar(s.toString()):String(s)).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(i,r)=>{let s=i.value;if(n.has(s))return i;return i.issues.push({code:"invalid_value",values:t.values,input:s,inst:e}),i}});var J_=J("$ZodTransform",(e,t)=>{Mt.init(e,t),e._zod.optin="optional",dn.memoizer?.guard(e),e._zod.parse=(n,i)=>{if(i.direction==="backward")throw new So(e.constructor.name);let r=t.transform(n.value,n);if(i.async)return(r instanceof Promise?r:Promise.resolve(r)).then((o)=>(n.value=o,n));if(r instanceof Promise)throw new pi;return n.value=r,n}});function s_(e,t){return e.value=t.issues.length?void 0:t.value,e}var Ah=J("$ZodOptional",(e,t)=>{Mt.init(e,t),tt(e,"optin",(n)=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",tt(e,"values",(n)=>{let i=n.def.innerType._zod.values;return i?new Set([...i,void 0]):void 0}),tt(e,"pattern",(n)=>{let i=n.def.innerType._zod.pattern;return i?new RegExp(`^(${nc(i.source)})?$`):void 0}),e._zod.parse=(n,i)=>{if(n.value===void 0){if(t.innerType._zod.optin!=="defaulted")return n;let r=t.innerType._zod.run({value:n.value,issues:[]},i);if(r instanceof Promise)return r.then((s)=>s_(n,s));return s_(n,r)}return t.innerType._zod.run(n,i)}}),Q_=J("$ZodExactOptional",(e,t)=>{Ah.init(e,t),tt(e,"values",(n)=>n.def.innerType._zod.values),tt(e,"pattern",(n)=>n.def.innerType._zod.pattern),e._zod.parse=(n,i)=>t.innerType._zod.run(n,i)}),e0=J("$ZodNullable",(e,t)=>{Mt.init(e,t),tt(e,"optin",(n)=>n.def.innerType._zod.optin),tt(e,"optout",(n)=>n.def.innerType._zod.optout),tt(e,"pattern",(n)=>{let i=n.def.innerType._zod.pattern;return i?new RegExp(`^(${nc(i.source)}|null)$`):void 0}),tt(e,"values",(n)=>n.def.innerType._zod.values?new Set([...n.def.innerType._zod.values,null]):void 0),e._zod.parse=(n,i)=>{if(n.value===null)return n;return t.innerType._zod.run(n,i)}}),t0=J("$ZodDefault",(e,t)=>{Mt.init(e,t),e._zod.optin="defaulted",tt(e,"values",(n)=>n.def.innerType._zod.values),e._zod.parse=(n,i)=>{if(i.direction==="backward")return t.innerType._zod.run(n,i);if(n.value===void 0)return n.value=t.defaultValue,n;let r=t.innerType._zod.run(n,i);if(r instanceof Promise)return r.then((s)=>o_(s,t));return o_(r,t)}});function o_(e,t){if(e.value===void 0)e.value=t.defaultValue;return e}var n0=J("$ZodPrefault",(e,t)=>{Mt.init(e,t),e._zod.optin="defaulted",tt(e,"values",(n)=>n.def.innerType._zod.values),e._zod.parse=(n,i)=>{if(i.direction==="backward")return t.innerType._zod.run(n,i);if(n.value===void 0)n.value=t.defaultValue;return t.innerType._zod.run(n,i)}}),i0=J("$ZodNonOptional",(e,t)=>{Mt.init(e,t),tt(e,"values",(n)=>{let i=n.def.innerType._zod.values;return i?new Set([...i].filter((r)=>r!==void 0)):void 0}),e._zod.parse=(n,i)=>{let r=t.innerType._zod.run(n,i);if(r instanceof Promise)return r.then((s)=>a_(s,e));return a_(r,e)}});function a_(e,t){if(!e.issues.length&&e.value===void 0)e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t});return e}function c_(e,t,n,i){if(!t.issues.length){if(e.value=t.value,t.memo)e.memo=!0;return e}return e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map((r)=>di(r,i,Sn()))},input:e.value}),e}var r0=J("$ZodCatch",(e,t)=>{Mt.init(e,t),tt(e,"optin",(n)=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),tt(e,"optout",(n)=>n.def.innerType._zod.optout),tt(e,"values",(n)=>n.def.innerType._zod.values),e._zod.parse=(n,i)=>{if(i.direction==="backward")return t.innerType._zod.run(n,i);let r=t.innerType._zod.run({value:n.value,issues:[]},i);if(r instanceof Promise)return r.then((s)=>c_(n,s,t,i));return c_(n,r,t,i)}});var s0=J("$ZodPipe",(e,t)=>{Mt.init(e,t),tt(e,"values",(n)=>n.def.in._zod.values),tt(e,"optin",(n)=>n.def.in._zod.optin),tt(e,"optout",(n)=>n.def.out._zod.optout),tt(e,"propValues",(n)=>n.def.in._zod.propValues),e._zod.parse=(n,i)=>{if(i.direction==="backward"){let s=t.out._zod.run(n,i);if(s instanceof Promise)return s.then((o)=>pc(o,t.in,i));return pc(s,t.in,i)}let r=t.in._zod.run(n,i);if(r instanceof Promise)return r.then((s)=>pc(s,t.out,i));return pc(r,t.out,i)}});function pc(e,t,n){if(e.issues.some((i)=>i.code!=="unrecognized_keys"))return e.aborted=!0,e;return t._zod.run({value:e.value,issues:e.issues},n)}var o0=J("$ZodReadonly",(e,t)=>{Mt.init(e,t),tt(e,"propValues",(n)=>n.def.innerType._zod.propValues),tt(e,"values",(n)=>n.def.innerType._zod.values),tt(e,"optin",(n)=>n.def.innerType?._zod?.optin),tt(e,"optout",(n)=>n.def.innerType?._zod?.optout),e._zod.parse=(n,i)=>{if(i.direction==="backward")return t.innerType._zod.run(n,i);let r=t.innerType._zod.run(n,i);if(r instanceof Promise)return r.then(l_);return l_(r)}});function l_(e){if(!e.memo)e.value=Object.freeze(e.value);return e}var a0=J("$ZodCustom",(e,t)=>{Xt.init(e,t),Mt.init(e,t),e._zod.parse=(n,i)=>n,e._zod.check=(n)=>{let i=n.value,r=t.fn(i);if(r instanceof Promise)return r.then((s)=>u_(s,n,i,e));u_(r,n,i,e);return}});function u_(e,t,n,i){if(!e){let r={code:"custom",input:n,inst:i,path:[...i._zod.def.path??[]],continue:!i._zod.def.abort};if(i._zod.def.params)r.params=i._zod.def.params;t.issues.push(Dr(r))}}class l0 extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform");this.name="ZodCyclicError"}}var Ch="~memo",c0=[];function u0(e){return e!==null&&typeof e==="object"}function Rh(e){return e.map((t)=>t.path?{...t,path:t.path.slice()}:{...t})}var h0=new WeakMap,To=0,bc=1,Ao=2;function Sc(e,t,n){let i=h0.get(e);if(i!==void 0)return i?Ao:To;if(t.has(e))return Ao;t.add(e);let r=To,s=(u)=>{if(r!==Ao&&u?._zod){let f=Sc(u,t,n);if(f>r)r=f}},o=(u,f)=>{let h=To;for(let d of Reflect.ownKeys(u)){let g=Object.getOwnPropertyDescriptor(u,d);if(f&&!g.enumerable)continue;let x=g.get?bc:g.value?._zod?Sc(g.value,t,n):To;if(x>h)h=x}return h},a=(u)=>{if(u>r)r=u},c=e._zod.def,l=c.type;switch(l){case"object":{let u=bo(c);a(u?o(u,!0):bc),s(c.catchall);break}case"array":s(c.element);break;case"tuple":for(let u of c.items)s(u);s(c.rest);break;case"record":case"map":s(c.keyType),s(c.valueType);break;case"set":s(c.valueType);break;case"union":for(let u of c.options)s(u);break;case"intersection":s(c.left),s(c.right);break;case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":s(c.innerType);break;case"pipe":s(c.in),s(c.out);break;case"function":s(c.input),s(c.output);break;case"lazy":{let u=c._cachedInner??(n?e._zod.innerType:void 0);a(u?Sc(u,t,!1):bc);break}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":break;default:for(let u in c){let f=Object.getOwnPropertyDescriptor(c,u);if(!f||f.get)continue;let h=f.value;if(!h||typeof h!=="object")continue;if(h._zod)s(h);else if(Array.isArray(h))for(let d of h)s(d)}}return t.delete(e),xA(e,r)}function xA(e,t){if(t!==bc)h0.set(e,t===Ao);return t}function yA(e,t){let n=e.buckets.get(t);if(!n)n=new WeakMap,e.buckets.set(t,n);return n}var yc,vc=[],vA={alloc(e,t,n){let i=yc;if(!i)return n;yc=void 0;let r={value:n,issues:null};return i.set(t.value,r),vc.push(r),n},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let n=e._zod.parse,i=(r,s)=>{if(s.direction!=="backward"&&bA(s,r.value))throw new l0;return n(r,s)};if(e._zod.parse=i,e._zod.run===n)e._zod.run=i})},attach(e){var t;let n,i=!1,r,s;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let o=e._zod.parse,a=(c,l)=>{if(n===void 0){let m=Sc(e,new Set,!1);if(m===To){if(e._zod.parse=o,e._zod.run===a)e._zod.run=o;return o(c,l)}if(m===Ao||i)n=!0;else i=!0}let u=c.value;if(!u0(u))return o(c,l);let f=l[Ch];if(!f)f={buckets:new WeakMap,backEdges:void 0},l[Ch]=f;let h;if(r===l)h=s;else h=yA(f,e),r=l,s=h;let d=h.get(u);if(d){if(c.value=d.value,d.issues){if(d.issues.length)c.issues.push(...Rh(d.issues))}else c.memo=!0,f.backEdges??(f.backEdges=new WeakSet),f.backEdges.add(d.value);return c}yc=h;let g=vc.length,x=o(c,l);yc=void 0;let p=vc.length>g?vc.pop():void 0;if(x instanceof Promise)return x.then((m)=>{if(p)p.issues=m.issues.length?Rh(m.issues):c0;return m});if(p)p.issues=x.issues.length?Rh(x.issues):c0;return x};if(e._zod.parse=a,e._zod.run===o)e._zod.run=a})}};function f0(){return vA}function bA(e,t){let n=e[Ch]?.backEdges;return n!==void 0&&u0(t)&&n.has(t)}var SA=()=>{let e={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function t(s){return e[s]??null}let n={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",currency_code:"currency code",credit_card:"credit card number",iban:"IBAN",jwt:"JWT",template_literal:"input"},i={nan:"NaN"};function r(s,o){if(s==="number"&&typeof o==="number"&&!Number.isFinite(o))return String(o);return i[s]??s}return(s)=>{switch(s.code){case"invalid_type":{let o=r(s.expected),a=qm(s.input),c=r(a,s.input);return`Invalid input: expected ${o}, received ${c}`}case"invalid_value":if(s.values.length===1)return`Invalid input: expected ${ah(s.values[0])}`;return`Invalid option: expected one of ${rh(s.values,"|")}`;case"too_big":{let o=s.exact?"exactly ":s.inclusive?"<=":"<",a=t(s.origin);if(a)return`Too big: expected ${s.origin??"value"} to have ${o}${s.maximum.toString()} ${a.unit??"elements"}`;return`Too big: expected ${s.origin??"value"} to be ${o}${s.maximum.toString()}`}case"too_small":{let o=s.exact?"exactly ":s.inclusive?">=":">",a=t(s.origin);if(a)return`Too small: expected ${s.origin} to have ${o}${s.minimum.toString()} ${a.unit}`;return`Too small: expected ${s.origin} to be ${o}${s.minimum.toString()}`}case"invalid_format":{let o=s;if(o.format==="starts_with")return`Invalid string: must start with "${o.prefix}"`;if(o.format==="ends_with")return`Invalid string: must end with "${o.suffix}"`;if(o.format==="includes")return`Invalid string: must include "${o.includes}"`;if(o.format==="regex")return`Invalid string: must match pattern ${o.pattern}`;return`Invalid ${n[o.format]??s.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${s.divisor}`;case"unrecognized_keys":return`Unrecognized key${s.keys.length>1?"s":""}: ${rh(s.keys,", ")}`;case"invalid_key":return`Invalid key in ${s.origin}`;case"invalid_union":if(s.options&&Array.isArray(s.options)&&s.options.length>0)return`Invalid discriminator value. Expected ${s.options.map((a)=>`'${a}'`).join(" | ")}`;if(s.inclusive===!1)return"Invalid input: more than one option matched";return"Invalid input";case"invalid_element":return`Invalid value in ${s.origin}`;default:return"Invalid input"}}};function Ph(){return{localeError:SA()}}var d0;class p0{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];if(this._map.set(e,n),n&&typeof n==="object"&&"id"in n)this._idmap.set(n.id,e);return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);if(t&&typeof t==="object"&&"id"in t)this._idmap.delete(t.id);return this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let i={...n,...this._map.get(e)};return Object.keys(i).length?i:void 0}return this._map.get(e)}has(e){return this._map.has(e)}}function MA(){return new p0}(d0=globalThis).__zod_globalRegistry??(d0.__zod_globalRegistry=MA());var Or=globalThis.__zod_globalRegistry;function m0(e){if(e.checks)e.checks=[...e.checks];return e}function g0(e,t){return new e(m0({type:"string",...Ce(t)}))}function _0(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...Ce(t)})}function x0(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...Ce(t)})}function y0(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...Ce(t)})}function v0(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...Ce(t)})}function b0(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...Ce(t)})}function S0(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...Ce(t)})}function M0(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...Ce(t)})}function w0(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...Ce(t)})}function E0(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...Ce(t)})}function T0(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...Ce(t)})}function A0(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...Ce(t)})}function R0(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...Ce(t)})}function C0(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...Ce(t)})}function P0(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...Ce(t)})}function I0(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...Ce(t)})}function L0(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...Ce(t)})}function N0(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...Ce(t)})}function D0(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...Ce(t)})}function O0(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...Ce(t)})}function U0(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...Ce(t)})}function F0(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...Ce(t)})}function z0(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...Ce(t)})}function k0(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...Ce(t)})}function B0(e,t){return new e({type:"string",format:"date",check:"string_format",...Ce(t)})}function G0(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...Ce(t)})}function H0(e,t){return new e({type:"string",format:"duration",check:"string_format",...Ce(t)})}function V0(e,t){return new e(m0({type:"number",checks:[],...Ce(t)}))}function $0(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...Ce(t)})}function W0(e,t){return new e({type:"boolean",...Ce(t)})}function Z0(e){return new e({type:"unknown"})}function X0(e,t){return new e({type:"never",...Ce(t)})}function Mc(e,t){return new yh({check:"less_than",...Ce(t),value:e,inclusive:!1})}function Ro(e,t){return new yh({check:"less_than",...Ce(t),value:e,inclusive:!0})}function wc(e,t){return new vh({check:"greater_than",...Ce(t),value:e,inclusive:!1})}function Co(e,t){return new vh({check:"greater_than",...Ce(t),value:e,inclusive:!0})}function Ec(e,t){return new Gg({check:"multiple_of",...Ce(t),value:e})}function Tc(e,t){return new Vg({check:"max_length",...Ce(t),maximum:e})}function As(e,t){return new $g({check:"min_length",...Ce(t),minimum:e})}function Ac(e,t){return new Wg({check:"length_equals",...Ce(t),length:e})}function Ih(e,t){return new Zg({check:"string_format",format:"regex",...Ce(t),pattern:e})}function Lh(e){return new Xg({check:"string_format",format:"lowercase",...Ce(e)})}function Nh(e){return new qg({check:"string_format",format:"uppercase",...Ce(e)})}function Dh(e,t){return new jg({check:"string_format",format:"includes",...Ce(t),includes:e})}function Oh(e,t){return new Yg({check:"string_format",format:"starts_with",...Ce(t),prefix:e})}function Uh(e,t){return new Kg({check:"string_format",format:"ends_with",...Ce(t),suffix:e})}function lr(e){return new Jg({check:"overwrite",tx:e})}function Fh(e){return lr((t)=>t.normalize(e))}function zh(){return lr((e)=>e.trim())}function kh(){return lr((e)=>e.toLowerCase())}function Bh(){return lr((e)=>e.toUpperCase())}function Gh(){return lr((e)=>Gm(e))}function q0(e,t,n){return new e({type:"array",element:t,...Ce(n)})}function j0(e,t,n){return new e({type:"custom",check:"custom",fn:t,...Ce(n)})}function Y0(e,t){let n=wA((i)=>(i.addIssue=(r)=>{if(typeof r==="string")i.issues.push(Dr(r,i.value,n._zod.def));else{let s=r;if(s.fatal)s.continue=!1;if(s.code??(s.code="custom"),!("input"in s))s.input=i.value;s.inst??(s.inst=n),s.continue??(s.continue=!n._zod.def.abort),i.issues.push(Dr(s))}},e(i.value,i)),t);return n}function wA(e,t){let n=new Xt({check:"custom",...Ce(t)});return n._zod.check=e,n}function Po(e,...t){for(let n of t)for(let i of Reflect.ownKeys(n))if(Object.prototype.propertyIsEnumerable.call(n,i))Nn(e,i,n[i]);return e}function Vh(e){let t=e?.target??"draft-2020-12";if(t==="draft-4")t="draft-04";if(t==="draft-7")t="draft-07";return{processors:e.processors??{},metadataRegistry:e?.metadata??Or,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??"ref",reused:e?.reused??"inline",intersections:[],deferred:[],external:e?.external??void 0}}function Di(e,t,n,i,r){let s=typeof t.unrepresentable==="function"?t.unrepresentable({zodSchema:e,path:i.path,message:r}):t.unrepresentable;if(s==="any")return!1;if(s===void 0||s==="throw")throw Error(r);return Object.assign(n,s),!0}function It(e,t,n={path:[],schemaPath:[]}){var i;let r=e._zod.def,s=t.seen.get(e);if(s){if(s.count++,n.schemaPath.includes(e))s.cycle=n.path;return s.schema}let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let a=e._zod.toJSONSchema?.();if(a)o.schema=a;else{let u={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,u);else{let h=o.schema,d=t.processors[r.type];if(!d)throw Error(`[toJSONSchema]: Non-representable type encountered: ${r.type}`);d(e,t,h,u)}let f=e._zod.parent;if(f){if(!o.ref)o.ref=f;It(f,t,u),t.seen.get(f).isParent=!0}}let c=t.metadataRegistry.get(e);if(c)Po(o.schema,c);if(t.io==="input"&&on(e))delete o.schema.examples,delete o.schema.default;if(t.io==="input"&&"_prefault"in o.schema)(i=o.schema).default??(i.default=o.schema._prefault);return delete o.schema._prefault,t.seen.get(e).schema}function K0(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function $h(e,t){let n=e.seen.get(t);if(!n)throw Error("Unprocessed schema. This is a bug in Zod.");if(e.external&&e.sharedDefsExtractedFor===e.external)return;let i=new Map;for(let o of e.seen.entries()){let a=e.metadataRegistry.get(o[0])?.id;if(a){let c=i.get(a);if(c&&c!==o[0])throw Error(`Duplicate schema id "${a}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);i.set(a,o[0])}}let r=(o)=>{let a=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let f=e.external.registry.get(o[0])?.id,h=e.external.uri??((g)=>g);if(f)return{ref:h(f)};let d=o[1].defId??o[1].schema.id??`schema${e.counter++}`;return o[1].defId=d,{defId:d,ref:`${h("__shared")}#/${a}/${K0(d)}`}}let c="#",l=`${c}/${a}/`;if(o[1]===n&&!o[1].schema.id)return{ref:c};let u=o[1].schema.id??`__schema${e.counter++}`;return{defId:u,ref:l+K0(u)}},s=(o)=>{if(o[1].schema.$ref)return;let a=o[1],{ref:c,defId:l}=r(o);if(a.def={...a.schema},l)a.defId=l;let u=a.schema;for(let f in u)delete u[f];u.$ref=c};if(e.cycles==="throw")for(let o of e.seen.entries()){let a=o[1];if(a.cycle)throw Error(`Cycle detected: #/${a.cycle?.join("/")}/<root>
4399
4399
 
4400
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let o of e.seen.entries()){let a=o[1];if(t===o[0]){s(o);continue}if(e.external){let l=e.external.registry.get(o[0])?.id;if(t!==o[0]&&l){s(o);continue}}if(e.metadataRegistry.get(o[0])?.id){s(o);continue}if(a.cycle){s(o);continue}if(a.count>1){if(e.reused==="ref")s(o)}}if(e.external)e.sharedDefsExtractedFor=e.external}function Q0(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let n=[];for(let i of t){if(!i||typeof i!=="object")return;Q0(i);let r=Object.keys(i);if(r.length!==1||r[0]!=="type")return;let s=i.type;for(let o of Array.isArray(s)?s:[s]){if(typeof o!=="string")return;if(!n.includes(o))n.push(o)}}delete e.anyOf,e.type=n.length===1?n[0]:n}var ex=new Set(["type","properties","required","additionalProperties"]),K0=["oneOf","anyOf"];function J0(e){let t=e.additionalProperties;if(t===void 0||t===!1||typeof t!=="object"||t===null)return null;return Object.keys(t).length?t:null}function Gh(e){let t=[];for(let s of e){if(typeof s!=="object"||s.type!=="object")return null;for(let o in s)if(!ex.has(o))return null;t.push(s)}let n={},i=new Set;for(let s of t){for(let o in s.properties){if(Object.prototype.hasOwnProperty.call(n,o))continue;let a=[];for(let l of t){let u=l.properties?.[o]??J0(l);if(u===null||u===void 0)continue;if(!a.some((f)=>JSON.stringify(f)===JSON.stringify(u)))a.push(u)}let c=a.length===1?a[0]:Gh(a)??{allOf:a};Ln(n,o,c)}for(let o of s.required??[])i.add(o)}let r={type:"object",properties:n};if(i.size)r.required=[...i];if(t.every((s)=>s.additionalProperties===!1))r.additionalProperties=!1;else{let s=[];for(let o of t){let a=J0(o);if(a&&!s.some((c)=>JSON.stringify(c)===JSON.stringify(a)))s.push(a)}if(s.length===1)r.additionalProperties=s[0];else if(s.length>1)r.additionalProperties={allOf:s}}return r}function MA(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let r of ex)if(r in e)return;let n=t.filter((r)=>K0.some((s)=>Array.isArray(r[s]))),i=null;if(!n.length)i=Gh(t);else{let r=n[0],s=K0.find((c)=>Array.isArray(r[c]));if(Object.keys(r).length!==1)return;let o=t.filter((c)=>c!==r),a=r[s].map((c)=>Gh([...o,c]));if(a.some((c)=>!c))return;i={[s]:a}}if(!i)return;delete e.allOf,To(e,i)}function $h(e,t){let n=e.seen.get(t);if(!n)throw Error("Unprocessed schema. This is a bug in Zod.");let i=(a)=>{let c=e.seen.get(a);if(c.ref===null)return;let l=c.def??c.schema,u={...l},f=c.ref;if(c.ref=null,f){i(f);let d=e.seen.get(f),g=d.schema;if(g.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"))l.allOf=l.allOf??[],l.allOf.push(g);else To(l,g);if(To(l,u),a._zod.parent===f)for(let p in l){if(p==="$ref"||p==="allOf")continue;if(!(p in u))delete l[p]}if(g.$ref&&d.def)for(let p in l){if(p==="$ref"||p==="allOf")continue;if(p in d.def&&JSON.stringify(l[p])===JSON.stringify(d.def[p]))delete l[p]}}let h=a._zod.parent;if(h&&h!==f){i(h);let d=e.seen.get(h);if(d?.schema.$ref){if(l.$ref=d.schema.$ref,d.def)for(let g in l){if(g==="$ref"||g==="allOf")continue;if(g in d.def&&JSON.stringify(l[g])===JSON.stringify(d.def[g]))delete l[g]}}}e.override({zodSchema:a,jsonSchema:l,path:c.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let a of[...e.seen.entries()].reverse())i(a[0]);if(e.target!=="openapi-3.0")for(let a of e.seen.entries())Q0(a[1].def??a[1].schema);for(let a of e.deferred)a();if(e.intersections.length){let a=new Map;for(let c of e.seen.values())for(let l of[c.schema,c.def]){let u=l?.allOf;if(!Array.isArray(u))continue;let f=a.get(u);if(f)f.push(l);else a.set(u,[l])}for(let c of e.intersections)for(let l of a.get(c)??[])MA(l)}}let r={};if(e.target==="draft-2020-12")r.$schema="https://json-schema.org/draft/2020-12/schema";else if(e.target==="draft-07")r.$schema="http://json-schema.org/draft-07/schema#";else if(e.target==="draft-04")r.$schema="http://json-schema.org/draft-04/schema#";else if(e.target==="openapi-3.0");if(e.external?.uri){let a=e.external.registry.get(t)?.id;if(!a)throw Error("Schema is missing an `id` property");r.$id=e.external.uri(a)}To(r,n.defId?n.schema:n.def??n.schema);let s=e.metadataRegistry.get(t)?.id;if(s!==void 0&&r.id===s)delete r.id;let o=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let a of e.seen.entries()){let c=a[1];if(c.def&&c.defId){if(c.def.id===c.defId)delete c.def.id;Ln(o,c.defId,c.def)}}if(e.external)e.sharedEmitDoneFor=e.external;if(e.external);else if(Object.keys(o).length>0)if(e.target==="draft-2020-12")r.$defs=o;else r.definitions=o;try{let a=JSON.parse(JSON.stringify(r));return Object.defineProperty(a,"~standard",{value:{...t["~standard"],jsonSchema:{input:Ao(t,"input",e.processors),output:Ao(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch(a){throw Error("Error converting schema to JSON.")}}function on(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let i=e._zod.def;if(i.type==="transform")return!0;if(i.type==="array")return on(i.element,n);if(i.type==="set")return on(i.valueType,n);if(i.type==="lazy")return on(i.getter(),n);if(i.type==="promise"||i.type==="optional"||i.type==="nonoptional"||i.type==="nullable"||i.type==="readonly"||i.type==="default"||i.type==="prefault"||i.type==="catch")return on(i.innerType,n);if(i.type==="intersection")return on(i.left,n)||on(i.right,n);if(i.type==="record"||i.type==="map")return on(i.keyType,n)||on(i.valueType,n);if(i.type==="pipe"){if(e._zod.traits.has("$ZodCodec"))return!0;return on(i.in,n)||on(i.out,n)}if(i.type==="object"){for(let r in i.shape)if(on(i.shape[r],n))return!0;return!1}if(i.type==="union"){for(let r of i.options)if(on(r,n))return!0;return!1}if(i.type==="tuple"){for(let r of i.items)if(on(r,n))return!0;if(i.rest&&on(i.rest,n))return!0;return!1}return!1}var tx=(e,t={})=>(n)=>{let i=Hh({...n,processors:t});return It(e,i),Vh(i,e),$h(i,e)},Ao=(e,t,n={})=>(i)=>{let{libraryOptions:r,target:s}=i??{},o=Hh({...r??{},target:s,io:t,processors:n});return It(e,o),Vh(o,e),$h(o,e)};var Es=(e,t,n)=>{if(e[t]===void 0||n>e[t])e[t]=n},Ts=(e,t,n)=>{if(e[t]===void 0||n<e[t])e[t]=n},nx=(e,t)=>{Es(e,"minimum",t),Ts(e,"maximum",t)},ox=(e,t)=>{if(e.multipleOf??(e.multipleOf=[]),!e.multipleOf.includes(t))e.multipleOf.push(t)},ax=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},cx=(e,t)=>{e.mime=e.mime?e.mime.filter((n)=>t.includes(n)):[...t]},lx=(e,t)=>{if(e.format=t,t.includes("int"))e.isInt=!0},ix=(e,t)=>Es(e,"minimum",t.minimum),rx=(e,t)=>Ts(e,"maximum",t.maximum),sx=(e)=>(t,n)=>{lx(t,n.format);let[i,r]=e[n.format];Es(t,"minimum",i),Ts(t,"maximum",r)},wA={greater_than:(e,t)=>Es(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>Ts(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>ox(e,t.value),number_format:sx(nc),bigint_format:sx(ah),min_length:ix,max_length:rx,length_equals:(e,t)=>nx(e,t.length),min_size:ix,max_size:rx,size_equals:(e,t)=>nx(e,t.size),string_format:(e,t)=>{if(lx(e,t.format),t.pattern)ax(e,t.pattern);if(t.format==="base64"||t.format==="base64url")e.contentEncoding=t.format;if(t.local||t.precision===-1)e.laxFormat=!0},mime_type:(e,t)=>cx(e,t.mime)};function Nn(e){let t={},n=e._zod.def,i=e._zod.traits.has("$ZodCheck")?[e,...n.checks??[]]:n.checks??[];for(let s of i)wA[s._zod.def.check]?.(t,s._zod.def);let r=e._zod.bag;if(r.minimum!==void 0)Es(t,"minimum",r.minimum);if(r.exclusiveMinimum!==void 0)Es(t,"exclusiveMinimum",r.exclusiveMinimum);if(r.maximum!==void 0)Ts(t,"maximum",r.maximum);if(r.exclusiveMaximum!==void 0)Ts(t,"exclusiveMaximum",r.exclusiveMaximum);if(r.multipleOf!==void 0)ox(t,r.multipleOf);if(r.format!==void 0){if(t.format??(t.format=r.format),r.format.includes("int"))t.isInt=!0}if(r.mime)cx(t,r.mime);for(let s of r.patterns??[])ax(t,s);return t}var EA={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},TA=new Map([[Mh,Rg],[_c,Cg]]),ux=(e)=>TA.get(e)??e,hx=(e,t,n,i)=>{let r=n;r.type="string";let{minimum:s,maximum:o,format:a,patterns:c,contentEncoding:l,laxFormat:u}=Nn(e);if(typeof s==="number")r.minLength=s;if(typeof o==="number")r.maxLength=o;if(a){if(r.format=EA[a]??a,r.format==="")delete r.format;if(a==="time"||u)delete r.format}if(l)r.contentEncoding=l;if(c&&c.size>0){let f=[...c].map(ux);if(f.length===1)r.pattern=f[0].source;else if(f.length>1)r.allOf=[...f.map((h)=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:h.source}))]}},fx=(e,t,n,i)=>{let r=n,{minimum:s,maximum:o,multipleOf:a,exclusiveMaximum:c,exclusiveMinimum:l,isInt:u}=Nn(e);r.type=u?"integer":"number";let f=typeof l==="number"&&l>=(s??Number.NEGATIVE_INFINITY),h=typeof c==="number"&&c<=(o??Number.POSITIVE_INFINITY),d=t.target==="draft-04"||t.target==="openapi-3.0";if(f)if(d)r.minimum=l,r.exclusiveMinimum=!0;else r.exclusiveMinimum=l;else if(typeof s==="number")r.minimum=s;if(h)if(d)r.maximum=c,r.exclusiveMaximum=!0;else r.exclusiveMaximum=c;else if(typeof o==="number")r.maximum=o;if(a){let g=new Set;for(let m of a)if(Number.isFinite(m)&&m!==0)g.add(Math.abs(m));else Ni(e,t,r,i,`A multipleOf divisor of ${m} cannot be represented in JSON Schema`);let[x,...p]=g;if(x!==void 0)r.multipleOf=x;if(p.length)r.allOf=[...r.allOf??[],...p.map((m)=>({multipleOf:m}))]}},dx=(e,t,n,i)=>{n.type="boolean"};var px=(e,t,n,i)=>{n.not={}};var mx=(e,t,n,i)=>{};var gx=(e,t,n,i)=>{let r=e._zod.def,s=po(r.entries);if(s.length===0){n.not={};return}if(s.every((o)=>typeof o==="number"))n.type="number";if(s.every((o)=>typeof o==="string"))n.type="string";n.enum=s},_x=(e,t,n,i)=>{let r=e._zod.def;if(r.values.length===0){n.not={};return}let s=[];for(let o of r.values)if(o===void 0){if(Ni(e,t,n,i,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof o==="bigint"){if(Ni(e,t,n,i,"BigInt literals cannot be represented in JSON Schema"))return;s.push(Number(o))}else s.push(o);if(s.length===0);else if(s.length===1){let o=s[0];if(n.type=o===null?"null":typeof o,t.target==="draft-04"||t.target==="openapi-3.0")n.enum=[o];else n.const=o}else{if(s.every((o)=>typeof o==="number"))n.type="number";if(s.every((o)=>typeof o==="string"))n.type="string";if(s.every((o)=>typeof o==="boolean"))n.type="boolean";if(s.every((o)=>o===null))n.type="null";n.enum=s}};var xx=(e,t,n,i)=>{Ni(e,t,n,i,"Custom types cannot be represented in JSON Schema")};var yx=(e,t,n,i)=>{Ni(e,t,n,i,"Transforms cannot be represented in JSON Schema")};var vx=(e,t,n,i)=>{let r=n,s=e._zod.def,{minimum:o,maximum:a}=Nn(e);if(typeof o==="number")r.minItems=o;if(typeof a==="number")r.maxItems=a;r.type="array",r.items=It(s.element,t,{...i,path:[...i.path,"items"]})};function Ac(e){let t=e._zod.def;if(t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform"))return Ac(t.out);if(t.type==="catch")return Ac(t.innerType);return e._zod.optin}var bx=(e,t,n,i)=>{let r=n,s=e._zod.def,o=s.shape;if(Object.getOwnPropertySymbols(o).length&&Ni(e,t,r,i,"Symbol keys cannot be represented in JSON Schema"))return;r.type="object",r.properties={};for(let l in o)Ln(r.properties,l,It(o[l],t,{...i,path:[...i.path,"properties",l]}));let c=[];for(let l of Object.keys(o)){let u=s.shape[l];if(t.io==="input"?Ac(u)===void 0:u._zod.optout===void 0)c.push(l)}if(c.length>0)r.required=c;if(s.catchall?._zod.def.type==="never")r.additionalProperties=!1;else if(!s.catchall){if(t.io==="output")r.additionalProperties=!1}else if(s.catchall)r.additionalProperties=It(s.catchall,t,{...i,path:[...i.path,"additionalProperties"]})},Sx=(e,t,n,i)=>{let r=e._zod.def,s=r.inclusive===!1,o=r.options.map((a,c)=>It(a,t,{...i,path:[...i.path,s?"oneOf":"anyOf",c]}));if(s)n.oneOf=o;else n.anyOf=o},Mx=(e,t,n,i)=>{let r=e._zod.def,s=It(r.left,t,{...i,path:[...i.path,"allOf",0]}),o=It(r.right,t,{...i,path:[...i.path,"allOf",1]}),a=(l)=>("allOf"in l)&&Object.keys(l).length===1,c=[...a(s)?s.allOf:[s],...a(o)?o.allOf:[o]];n.allOf=c,t.intersections.push(c)};function Wh(e,t,n){if(t.$ref){if(n.has(t))return t;n.add(t);let g=e.get(t)?.def;if(!g)return t;let x=Wh(e,g,n);return x===g?t:x}for(let g of["anyOf","oneOf"]){let x=t[g];if(!Array.isArray(x))continue;let p=x.map((m)=>Wh(e,m,n));if(p.some((m,E)=>m!==x[E]))t={...t,[g]:p}}let i=Array.isArray(t.type)?t.type:[t.type],r=!i.includes("string")&&i.some((g)=>g==="number"||g==="integer"),s=t.enum??(t.const!==void 0?[t.const]:void 0);if(!r&&!s?.some((g)=>typeof g==="number"))return t;let{minimum:o,maximum:a,exclusiveMinimum:c,exclusiveMaximum:l,multipleOf:u,format:f,id:h,...d}=t;if(d.enum)d.enum=d.enum.map((g)=>typeof g==="number"?String(g):g);else if(typeof d.const==="number")d.const=String(d.const);if(!r)return d;if(d.type="string",!s)d.pattern=(i.includes("number")?yo:gh).source;return d}var Zh=new WeakMap;function AA(e){let t=new Map;for(let i of e.seen.values())if(i.def&&!t.has(i.schema))t.set(i.schema,i);let n=new Map;for(let i of Zh.get(e)??[]){let r=e.seen.get(i),s=(r?.def??r?.schema)?.propertyNames;if(!s||s===!0||n.has(s))continue;let o=Wh(t,s,new Set);if(o!==s)n.set(s,o)}if(!n.size)return;for(let i of e.seen.values())for(let r of[i.schema,i.def]){let s=r&&n.get(r.propertyNames);if(s)r.propertyNames=s}}var wx=(e,t,n,i)=>{let r=n,s=e._zod.def;r.type="object";let o=s.keyType,a=Nn(o).patterns;if(s.mode==="loose"&&a&&a.size>0){let u=It(s.valueType,t,{...i,path:[...i.path,"patternProperties","*"]});r.patternProperties={};for(let f of a)Ln(r.patternProperties,ux(f).source,u)}else{if(t.target==="draft-07"||t.target==="draft-2020-12"){r.propertyNames=It(s.keyType,t,{...i,path:[...i.path,"propertyNames"]});let u=Zh.get(t);if(!u)u=[],Zh.set(t,u),t.deferred.push(()=>AA(t));u.push(e)}r.additionalProperties=It(s.valueType,t,{...i,path:[...i.path,"additionalProperties"]})}let c=o._zod.values,l=t.io==="input"&&Ac(s.valueType)!==void 0;if(c&&!s.partial&&!l){let u=[...c].filter((f)=>typeof f==="string"||typeof f==="number");if(u.length>0)r.required=u.map(String)}},Ex=(e,t,n,i)=>{let r=e._zod.def,s=It(r.innerType,t,i),o=t.seen.get(e);if(t.target==="openapi-3.0")o.ref=r.innerType,n.nullable=!0;else n.anyOf=[s,{type:"null"}]},Tx=(e,t,n,i)=>{let r=e._zod.def;It(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType},Xh=Symbol();function Ax(e,t,n,i,r){let s=!1,o=JSON.stringify(e,(a,c)=>{if(typeof c!=="bigint")return c;return s=!0,null});if(!s)return JSON.parse(o);return Ni(t,n,i,r,"BigInt defaults cannot be represented in JSON Schema"),Xh}var Rx=(e,t,n,i)=>{let r=e._zod.def;It(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType;let o=Ax(r.defaultValue,e,t,n,i);if(o!==Xh)n.default=o},Cx=(e,t,n,i)=>{let r=e._zod.def;It(r.innerType,t,i);let s=t.seen.get(e);if(s.ref=r.innerType,t.io!=="input")return;let o=Ax(r.defaultValue,e,t,n,i);if(o!==Xh)n._prefault=o},Px=(e,t,n,i)=>{let r=e._zod.def;It(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType;let o;try{o=r.catchValue(void 0)}catch{Ni(e,t,n,i,"Dynamic catch values are not supported in JSON Schema");return}n.default=o},Ix=(e,t,n,i)=>{let r=e._zod.def,s=r.in._zod.traits.has("$ZodTransform"),o=t.io==="input"?s?r.out:r.in:r.out;It(o,t,i);let a=t.seen.get(e);a.ref=o},Lx=(e,t,n,i)=>{let r=e._zod.def;It(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType,n.readOnly=!0};var qh=(e,t,n,i)=>{let r=e._zod.def;It(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType};var Nx=new WeakSet([Object.prototype,Error.prototype]);function Rc(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let i=n(this);return Object.defineProperty(this,t,{value:i,configurable:!0,writable:!0}),i},set(i){Object.defineProperty(this,t,{value:i,configurable:!0,writable:!0})}})}var OA=(e,t)=>{tg.init(e,t),e.name="ZodError";let n=Object.getPrototypeOf(e);if(Nx.has(n))return;Nx.add(n),Rc(n,"format",(i)=>(r)=>ig(i,r)),Rc(n,"flatten",(i)=>(r)=>ng(i,r)),Rc(n,"addIssue",(i)=>(r)=>{i.issues.push(r),i.message=JSON.stringify(i.issues,mo,2)}),Rc(n,"addIssues",(i)=>(r)=>{i.issues.push(...r),i.message=JSON.stringify(i.issues,mo,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}})};var Mn=Q("ZodError",OA,void 0,{Parent:Error});var Dx=cc(Mn),Ox=lc(Mn),Ux=uc(Mn),Fx=hc(Mn),zx=sg(Mn),kx=og(Mn),Bx=ag(Mn),Gx=cg(Mn),Hx=lg(Mn),Vx=ug(Mn),$x=hg(Mn),Wx=fg(Mn);function FA(){if(!dn.localeError)Sn(Ch())}function Pc(){if(!dn.memoizer)Sn({memoizer:h0()})}var Et=Q("ZodType",(e,t)=>(FA(),Mt.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(bn(t,{checks:[...t.checks??[],...e.map((n)=>typeof n==="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return hi(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(D1(e,t))},superRefine(e,t){return this.check(O1(e,t))},overwrite(e){return this.check(cr(e))},optional(){return qx(this)},exactOptional(){return b1(this)},nullable(){return jx(this)},nullish(){return qx(jx(this))},nonoptional(e){return A1(this,e)},array(){return an(this)},or(e){return ey([this,e])},and(e){return _1(this,e)},transform(e){return Yx(this,v1(e))},default(e){return w1(this,e)},prefault(e){return T1(this,e)},catch(e){return C1(this,e)},pipe(e){return Yx(this,e)},readonly(){return L1(this)},describe(e){let t=this.clone();return Dr.add(t,{description:e}),t},meta(...e){if(e.length===0)return Dr.get(this);let t=this.clone();return Dr.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get "~standard"(){return oc(this,"~standard",{...Sh(this),jsonSchema:{input:Ao(this,"input"),output:Ao(this,"output")}})},set "~standard"(e){Li(this,"~standard",e)},parse:function e(t,n){return Dx(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await Ox(this,t,n,{callee:e})},safeParse(e,t){return Ux(this,e,t)},async safeParseAsync(e,t){return Fx(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){Li(this,"spa",e)},validate(e,t){return fh(this,e,t)},validateAsync(e,t){return dh(this,e,t)},encode:function e(t,n){return zx(this,t,n,{callee:e})},decode:function e(t,n){return kx(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await Bx(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await Gx(this,t,n,{callee:e})},safeEncode(e,t){return Hx(this,e,t)},safeDecode(e,t){return Vx(this,e,t)},async safeEncodeAsync(e,t){return $x(this,e,t)},async safeDecodeAsync(e,t){return Wx(this,e,t)},toJSONSchema(e){return tx(this,{})(e)},get description(){return Dr.get(this)?.description},get _def(){return this._zod.def}}),Kx=Q("_ZodString",(e,t)=>{gc.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,r)=>hx(e,n,i,r)},jm({format:(e)=>Nn(e).format??null,minLength:(e)=>Nn(e).minimum??null,maxLength:(e)=>Nn(e).maximum??null},{regex(...e){return this.check(Ph(...e))},includes(...e){return this.check(Nh(...e))},startsWith(...e){return this.check(Dh(...e))},endsWith(...e){return this.check(Oh(...e))},min(...e){return this.check(ws(...e))},max(...e){return this.check(Ec(...e))},length(...e){return this.check(Tc(...e))},nonempty(...e){return this.check(ws(1,...e))},lowercase(e){return this.check(Ih(e))},uppercase(e){return this.check(Lh(e))},trim(){return this.check(Fh())},normalize(...e){return this.check(Uh(...e))},toLowerCase(){return this.check(zh())},toUpperCase(){return this.check(kh())},slugify(){return this.check(Bh())}})),zA=Q("ZodString",(e,t)=>{gc.init(e,t),Kx.init(e,t)},{email(e){return this.check(g0(VA,e))},url(e){return this.check(S0(WA,e))},jwt(e){return this.check(F0(o1,e))},emoji(e){return this.check(M0(ZA,e))},guid(e){return this.check(_0($A,e))},uuid(e){return this.check(x0(Cc,e))},uuidv4(e){return this.check(y0(Cc,e))},uuidv6(e){return this.check(v0(Cc,e))},uuidv7(e){return this.check(b0(Cc,e))},nanoid(e){return this.check(w0(XA,e))},cuid(e){return this.check(E0(qA,e))},cuid2(e){return this.check(T0(jA,e))},ulid(e){return this.check(A0(YA,e))},base64(e){return this.check(D0(i1,e))},base64url(e){return this.check(O0(r1,e))},xid(e){return this.check(R0(KA,e))},ksuid(e){return this.check(C0(JA,e))},ipv4(e){return this.check(P0(QA,e))},ipv6(e){return this.check(I0(e1,e))},cidrv4(e){return this.check(L0(t1,e))},cidrv6(e){return this.check(N0(n1,e))},e164(e){return this.check(U0(s1,e))},datetime(e){return this.check(z0(kA,e))},date(e){return this.check(k0(BA,e))},time(e){return this.check(B0(GA,e))},duration(e){return this.check(G0(HA,e))}});function Je(e){return m0(zA,e)}var Tt=Q("ZodStringFormat",(e,t)=>{bt.init(e,t),Kx.init(e,t)}),kA=Q("ZodISODateTime",(e,t)=>{w_.init(e,t),Tt.init(e,t)}),BA=Q("ZodISODate",(e,t)=>{E_.init(e,t),Tt.init(e,t)}),GA=Q("ZodISOTime",(e,t)=>{T_.init(e,t),Tt.init(e,t)}),HA=Q("ZodISODuration",(e,t)=>{A_.init(e,t),Tt.init(e,t)}),VA=Q("ZodEmail",(e,t)=>{d_.init(e,t),Tt.init(e,t)});var $A=Q("ZodGUID",(e,t)=>{h_.init(e,t),Tt.init(e,t)});var Cc=Q("ZodUUID",(e,t)=>{f_.init(e,t),Tt.init(e,t)});var WA=Q("ZodURL",(e,t)=>{g_.init(e,t),Tt.init(e,t)});var ZA=Q("ZodEmoji",(e,t)=>{__.init(e,t),Tt.init(e,t)});var XA=Q("ZodNanoID",(e,t)=>{x_.init(e,t),Tt.init(e,t)});var qA=Q("ZodCUID",(e,t)=>{y_.init(e,t),Tt.init(e,t)});var jA=Q("ZodCUID2",(e,t)=>{v_.init(e,t),Tt.init(e,t)});var YA=Q("ZodULID",(e,t)=>{b_.init(e,t),Tt.init(e,t)});var KA=Q("ZodXID",(e,t)=>{S_.init(e,t),Tt.init(e,t)});var JA=Q("ZodKSUID",(e,t)=>{M_.init(e,t),Tt.init(e,t)});var QA=Q("ZodIPv4",(e,t)=>{R_.init(e,t),Tt.init(e,t)});var e1=Q("ZodIPv6",(e,t)=>{P_.init(e,t),Tt.init(e,t)});var t1=Q("ZodCIDRv4",(e,t)=>{I_.init(e,t),Tt.init(e,t)});var n1=Q("ZodCIDRv6",(e,t)=>{L_.init(e,t),Tt.init(e,t)});var i1=Q("ZodBase64",(e,t)=>{D_.init(e,t),Tt.init(e,t)});var r1=Q("ZodBase64URL",(e,t)=>{O_.init(e,t),Tt.init(e,t)});var s1=Q("ZodE164",(e,t)=>{U_.init(e,t),Tt.init(e,t)});var o1=Q("ZodJWT",(e,t)=>{F_.init(e,t),Tt.init(e,t)});var Jx=Q("ZodNumber",(e,t)=>{wh.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,r)=>fx(e,n,i,r),e.isFinite=!0},jm({minValue:(e)=>{let{minimum:t,exclusiveMinimum:n}=Nn(e);return Math.max(t??Number.NEGATIVE_INFINITY,n??Number.NEGATIVE_INFINITY)},maxValue:(e)=>{let{maximum:t,exclusiveMaximum:n}=Nn(e);return Math.min(t??Number.POSITIVE_INFINITY,n??Number.POSITIVE_INFINITY)},isInt:(e)=>{let{isInt:t,multipleOf:n}=Nn(e);return!!t||!!n?.some(Number.isSafeInteger)},format:(e)=>Nn(e).format??null},{gt(e,t){return this.check(Mc(e,t))},gte(e,t){return this.check(Eo(e,t))},min(e,t){return this.check(Eo(e,t))},lt(e,t){return this.check(Sc(e,t))},lte(e,t){return this.check(wo(e,t))},max(e,t){return this.check(wo(e,t))},int(e){return this.check(Zx(e))},safe(e){return this.check(Zx(e))},positive(e){return this.check(Mc(0,e))},nonnegative(e){return this.check(Eo(0,e))},negative(e){return this.check(Sc(0,e))},nonpositive(e){return this.check(wo(0,e))},multipleOf(e,t){return this.check(wc(e,t))},step(e,t){return this.check(wc(e,t))},finite(){return this}}));function mt(e){return H0(Jx,e)}var a1=Q("ZodNumberFormat",(e,t)=>{z_.init(e,t),Jx.init(e,t)});function Zx(e){return V0(a1,e)}var c1=Q("ZodBoolean",(e,t)=>{k_.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,r)=>dx(e,n,i,r)});function Ro(e){return $0(c1,e)}var l1=Q("ZodUnknown",(e,t)=>{B_.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,r)=>mx(e,n,i,r)});function Or(){return W0(l1)}var u1=Q("ZodNever",(e,t)=>{G_.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,r)=>px(e,n,i,r)});function h1(e){return Z0(u1,e)}var f1=Q("ZodArray",(e,t)=>{Pc(),H_.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,r)=>vx(e,n,i,r),e.element=t.element},{min(e,t){return this.check(ws(e,t))},nonempty(e){return this.check(ws(1,e))},max(e,t){return this.check(Ec(e,t))},length(e,t){return this.check(Tc(e,t))},unwrap(){return this.element}});function an(e,t){return X0(f1,e,t)}var d1=Q("ZodObject",(e,t)=>{Pc(),W_.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,r)=>bx(e,n,i,r),WT(e,"shape",(n)=>n._zod.def.shape,!1)},{keyof(){return Dn(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(bn(this._zod.def,{catchall:e}))},passthrough(){return this.clone(bn(this._zod.def,{catchall:Or()}))},loose(){return this.clone(bn(this._zod.def,{catchall:Or()}))},strict(){return this.clone(bn(this._zod.def,{catchall:h1()}))},strip(){return this.clone(bn(this._zod.def,{catchall:void 0}))},extend(e){return FT(this,e)},safeExtend(e){return zT(this,e)},merge(e){return kT(this,e)},pick(e){return OT(this,e)},omit(e){return UT(this,e)},partial(...e){return Wm(ty,this,e[0])},exactPartial(...e){return Wm(ny,this,e[0],"exactPartial")},required(...e){return BT(iy,this,e[0])}});function ft(e,t){let n={type:"object",shape:e??{},...Re(t)};return new d1(n)}var Qx=Q("ZodUnion",(e,t)=>{Eh.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Sx(e,n,i,r),e.options=t.options});function ey(e,t){return new Qx({type:"union",options:e,...Re(t)})}var p1=Q("ZodDiscriminatedUnion",(e,t)=>{Qx.init(e,t),Z_.init(e,t)});function m1(e,t,n){return new p1({type:"union",options:t,discriminator:e,...Re(n)})}var g1=Q("ZodIntersection",(e,t)=>{X_.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Mx(e,n,i,r)});function _1(e,t){return new g1({type:"intersection",left:e,right:t})}var Xx=Q("ZodRecord",(e,t)=>{Pc(),q_.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,r)=>wx(e,n,i,r),e.keyType=t.keyType,e.valueType=t.valueType});function Ic(e,t,n){if(!t||!t._zod)return new Xx({type:"record",keyType:Je(),valueType:e,...Re(t)});return new Xx({type:"record",keyType:e,valueType:t,...Re(n)})}var Yh=Q("ZodEnum",(e,t)=>{j_.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(i,r,s)=>gx(e,i,r,s),e.enum=t.entries,e.options=[...e._zod.values];let n=new Set(Object.keys(t.entries));e.extract=(i,r)=>{let s={};for(let o of i)if(n.has(o))s[o]=t.entries[o];else throw Error(`Key ${o} not found in enum`);return new Yh({...t,checks:[],...Re(r),entries:s})},e.exclude=(i,r)=>{let s={...t.entries};for(let o of i)if(n.has(o))delete s[o];else throw Error(`Key ${o} not found in enum`);return new Yh({...t,checks:[],...Re(r),entries:s})}});function Dn(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map((i)=>[i,i])):e;return new Yh({type:"enum",entries:n,...Re(t)})}var x1=Q("ZodLiteral",(e,t)=>{Y_.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,r)=>_x(e,n,i,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function qt(e,t){return new x1({type:"literal",values:Array.isArray(e)?e:[e],...Re(t)})}var y1=Q("ZodTransform",(e,t)=>{Pc(),K_.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,r)=>yx(e,n,i,r),e._zod.parse=(n,i)=>{if(i.direction==="backward")throw new xo(e.constructor.name);n.addIssue=(s)=>{if(typeof s==="string")n.issues.push(Nr(s,n.value,t));else{let o=s;if(o.fatal)o.continue=!1;if(o.code??(o.code="custom"),!("input"in o))o.input=n.value;o.inst??(o.inst=e),n.issues.push(Nr(o))}};let r=t.transform(n.value,n);if(r instanceof Promise)return r.then((s)=>(n.value=s,n));return n.value=r,n}});function v1(e){return new y1({type:"transform",transform:e})}var ty=Q("ZodOptional",(e,t)=>{Th.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,r)=>qh(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function qx(e){return new ty({type:"optional",innerType:e})}var ny=Q("ZodExactOptional",(e,t)=>{J_.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,r)=>qh(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function b1(e){return new ny({type:"optional",innerType:e})}var S1=Q("ZodNullable",(e,t)=>{Q_.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Ex(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function jx(e){return new S1({type:"nullable",innerType:e})}var M1=Q("ZodDefault",(e,t)=>{e0.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Rx(e,n,i,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function w1(e,t){return new M1({type:"default",innerType:e,get defaultValue(){return typeof t==="function"?t():sh(t)}})}var E1=Q("ZodPrefault",(e,t)=>{t0.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Cx(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function T1(e,t){return new E1({type:"prefault",innerType:e,get defaultValue(){return typeof t==="function"?t():sh(t)}})}var iy=Q("ZodNonOptional",(e,t)=>{n0.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Tx(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function A1(e,t){return new iy({type:"nonoptional",innerType:e,...Re(t)})}var R1=Q("ZodCatch",(e,t)=>{i0.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Px(e,n,i,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function C1(e,t){return new R1({type:"catch",innerType:e,catchValue:typeof t==="function"?t:Ym(t)})}var P1=Q("ZodPipe",(e,t)=>{r0.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Ix(e,n,i,r),e.in=t.in,e.out=t.out});function Yx(e,t){return new P1({type:"pipe",in:e,out:t})}var I1=Q("ZodReadonly",(e,t)=>{s0.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Lx(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function L1(e){return new I1({type:"readonly",innerType:e})}var N1=Q("ZodCustom",(e,t)=>{o0.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,r)=>xx(e,n,i,r)});function D1(e,t={}){return q0(N1,e,t)}function O1(e,t){return j0(e,t)}var sy=["neutral","dark","light"];var Kh=(e,t)=>Object.freeze({id:e,rgb:Object.freeze([...t]),hex:`#${t.map((n)=>n.toString(16).padStart(2,"0")).join("")}`}),oy=Object.freeze({neutral:Kh("neutral",[170,177,188]),dark:Kh("dark",[26,26,26]),light:Kh("light",[223,227,232])});var gD=oy.neutral.rgb,_D=oy.neutral.hex;/*!
4400
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let o of e.seen.entries()){let a=o[1];if(t===o[0]){s(o);continue}if(e.external){let l=e.external.registry.get(o[0])?.id;if(t!==o[0]&&l){s(o);continue}}if(e.metadataRegistry.get(o[0])?.id){s(o);continue}if(a.cycle){s(o);continue}if(a.count>1){if(e.reused==="ref")s(o)}}if(e.external)e.sharedDefsExtractedFor=e.external}function ex(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let n=[];for(let i of t){if(!i||typeof i!=="object")return;ex(i);let r=Object.keys(i);if(r.length!==1||r[0]!=="type")return;let s=i.type;for(let o of Array.isArray(s)?s:[s]){if(typeof o!=="string")return;if(!n.includes(o))n.push(o)}}delete e.anyOf,e.type=n.length===1?n[0]:n}var tx=new Set(["type","properties","required","additionalProperties"]),J0=["oneOf","anyOf"];function Q0(e){let t=e.additionalProperties;if(t===void 0||t===!1||typeof t!=="object"||t===null)return null;return Object.keys(t).length?t:null}function Hh(e){let t=[];for(let s of e){if(typeof s!=="object"||s.type!=="object")return null;for(let o in s)if(!tx.has(o))return null;t.push(s)}let n={},i=new Set;for(let s of t){for(let o in s.properties){if(Object.prototype.hasOwnProperty.call(n,o))continue;let a=[];for(let l of t){let u=l.properties?.[o]??Q0(l);if(u===null||u===void 0)continue;if(!a.some((f)=>JSON.stringify(f)===JSON.stringify(u)))a.push(u)}let c=a.length===1?a[0]:Hh(a)??{allOf:a};Nn(n,o,c)}for(let o of s.required??[])i.add(o)}let r={type:"object",properties:n};if(i.size)r.required=[...i];if(t.every((s)=>s.additionalProperties===!1))r.additionalProperties=!1;else{let s=[];for(let o of t){let a=Q0(o);if(a&&!s.some((c)=>JSON.stringify(c)===JSON.stringify(a)))s.push(a)}if(s.length===1)r.additionalProperties=s[0];else if(s.length>1)r.additionalProperties={allOf:s}}return r}function EA(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let r of tx)if(r in e)return;let n=t.filter((r)=>J0.some((s)=>Array.isArray(r[s]))),i=null;if(!n.length)i=Hh(t);else{let r=n[0],s=J0.find((c)=>Array.isArray(r[c]));if(Object.keys(r).length!==1)return;let o=t.filter((c)=>c!==r),a=r[s].map((c)=>Hh([...o,c]));if(a.some((c)=>!c))return;i={[s]:a}}if(!i)return;delete e.allOf,Po(e,i)}function Wh(e,t){let n=e.seen.get(t);if(!n)throw Error("Unprocessed schema. This is a bug in Zod.");let i=(a)=>{let c=e.seen.get(a);if(c.ref===null)return;let l=c.def??c.schema,u={...l},f=c.ref;if(c.ref=null,f){i(f);let d=e.seen.get(f),g=d.schema;if(g.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"))l.allOf=l.allOf??[],l.allOf.push(g);else Po(l,g);if(Po(l,u),a._zod.parent===f)for(let p in l){if(p==="$ref"||p==="allOf")continue;if(!(p in u))delete l[p]}if(g.$ref&&d.def)for(let p in l){if(p==="$ref"||p==="allOf")continue;if(p in d.def&&JSON.stringify(l[p])===JSON.stringify(d.def[p]))delete l[p]}}let h=a._zod.parent;if(h&&h!==f){i(h);let d=e.seen.get(h);if(d?.schema.$ref){if(l.$ref=d.schema.$ref,d.def)for(let g in l){if(g==="$ref"||g==="allOf")continue;if(g in d.def&&JSON.stringify(l[g])===JSON.stringify(d.def[g]))delete l[g]}}}e.override({zodSchema:a,jsonSchema:l,path:c.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let a of[...e.seen.entries()].reverse())i(a[0]);if(e.target!=="openapi-3.0")for(let a of e.seen.entries())ex(a[1].def??a[1].schema);for(let a of e.deferred)a();if(e.intersections.length){let a=new Map;for(let c of e.seen.values())for(let l of[c.schema,c.def]){let u=l?.allOf;if(!Array.isArray(u))continue;let f=a.get(u);if(f)f.push(l);else a.set(u,[l])}for(let c of e.intersections)for(let l of a.get(c)??[])EA(l)}}let r={};if(e.target==="draft-2020-12")r.$schema="https://json-schema.org/draft/2020-12/schema";else if(e.target==="draft-07")r.$schema="http://json-schema.org/draft-07/schema#";else if(e.target==="draft-04")r.$schema="http://json-schema.org/draft-04/schema#";else if(e.target==="openapi-3.0");if(e.external?.uri){let a=e.external.registry.get(t)?.id;if(!a)throw Error("Schema is missing an `id` property");r.$id=e.external.uri(a)}Po(r,n.defId?n.schema:n.def??n.schema);let s=e.metadataRegistry.get(t)?.id;if(s!==void 0&&r.id===s)delete r.id;let o=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let a of e.seen.entries()){let c=a[1];if(c.def&&c.defId){if(c.def.id===c.defId)delete c.def.id;Nn(o,c.defId,c.def)}}if(e.external)e.sharedEmitDoneFor=e.external;if(e.external);else if(Object.keys(o).length>0)if(e.target==="draft-2020-12")r.$defs=o;else r.definitions=o;try{let a=JSON.parse(JSON.stringify(r));return Object.defineProperty(a,"~standard",{value:{...t["~standard"],jsonSchema:{input:Io(t,"input",e.processors),output:Io(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch(a){throw Error("Error converting schema to JSON.")}}function on(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let i=e._zod.def;if(i.type==="transform")return!0;if(i.type==="array")return on(i.element,n);if(i.type==="set")return on(i.valueType,n);if(i.type==="lazy")return on(i.getter(),n);if(i.type==="promise"||i.type==="optional"||i.type==="nonoptional"||i.type==="nullable"||i.type==="readonly"||i.type==="default"||i.type==="prefault"||i.type==="catch")return on(i.innerType,n);if(i.type==="intersection")return on(i.left,n)||on(i.right,n);if(i.type==="record"||i.type==="map")return on(i.keyType,n)||on(i.valueType,n);if(i.type==="pipe"){if(e._zod.traits.has("$ZodCodec"))return!0;return on(i.in,n)||on(i.out,n)}if(i.type==="object"){for(let r in i.shape)if(on(i.shape[r],n))return!0;return!1}if(i.type==="union"){for(let r of i.options)if(on(r,n))return!0;return!1}if(i.type==="tuple"){for(let r of i.items)if(on(r,n))return!0;if(i.rest&&on(i.rest,n))return!0;return!1}return!1}var nx=(e,t={})=>(n)=>{let i=Vh({...n,processors:t});return It(e,i),$h(i,e),Wh(i,e)},Io=(e,t,n={})=>(i)=>{let{libraryOptions:r,target:s}=i??{},o=Vh({...r??{},target:s,io:t,processors:n});return It(e,o),$h(o,e),Wh(o,e)};var Rs=(e,t,n)=>{if(e[t]===void 0||n>e[t])e[t]=n},Cs=(e,t,n)=>{if(e[t]===void 0||n<e[t])e[t]=n},ix=(e,t)=>{Rs(e,"minimum",t),Cs(e,"maximum",t)},ax=(e,t)=>{if(e.multipleOf??(e.multipleOf=[]),!e.multipleOf.includes(t))e.multipleOf.push(t)},cx=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},lx=(e,t)=>{e.mime=e.mime?e.mime.filter((n)=>t.includes(n)):[...t]},ux=(e,t)=>{if(e.format=t,t.includes("int"))e.isInt=!0},rx=(e,t)=>Rs(e,"minimum",t.minimum),sx=(e,t)=>Cs(e,"maximum",t.maximum),ox=(e)=>(t,n)=>{ux(t,n.format);let[i,r]=e[n.format];Rs(t,"minimum",i),Cs(t,"maximum",r)},TA={greater_than:(e,t)=>Rs(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>Cs(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>ax(e,t.value),number_format:ox(ic),bigint_format:ox(ch),min_length:rx,max_length:sx,length_equals:(e,t)=>ix(e,t.length),min_size:rx,max_size:sx,size_equals:(e,t)=>ix(e,t.size),string_format:(e,t)=>{if(ux(e,t.format),t.pattern)cx(e,t.pattern);if(t.format==="base64"||t.format==="base64url")e.contentEncoding=t.format;if(t.local||t.precision===-1)e.laxFormat=!0},mime_type:(e,t)=>lx(e,t.mime)};function Dn(e){let t={},n=e._zod.def,i=e._zod.traits.has("$ZodCheck")?[e,...n.checks??[]]:n.checks??[];for(let s of i)TA[s._zod.def.check]?.(t,s._zod.def);let r=e._zod.bag;if(r.minimum!==void 0)Rs(t,"minimum",r.minimum);if(r.exclusiveMinimum!==void 0)Rs(t,"exclusiveMinimum",r.exclusiveMinimum);if(r.maximum!==void 0)Cs(t,"maximum",r.maximum);if(r.exclusiveMaximum!==void 0)Cs(t,"exclusiveMaximum",r.exclusiveMaximum);if(r.multipleOf!==void 0)ax(t,r.multipleOf);if(r.format!==void 0){if(t.format??(t.format=r.format),r.format.includes("int"))t.isInt=!0}if(r.mime)lx(t,r.mime);for(let s of r.patterns??[])cx(t,s);return t}var AA={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},RA=new Map([[wh,Cg],[xc,Pg]]),hx=(e)=>RA.get(e)??e,fx=(e,t,n,i)=>{let r=n;r.type="string";let{minimum:s,maximum:o,format:a,patterns:c,contentEncoding:l,laxFormat:u}=Dn(e);if(typeof s==="number")r.minLength=s;if(typeof o==="number")r.maxLength=o;if(a){if(r.format=AA[a]??a,r.format==="")delete r.format;if(a==="time"||u)delete r.format}if(l)r.contentEncoding=l;if(c&&c.size>0){let f=[...c].map(hx);if(f.length===1)r.pattern=f[0].source;else if(f.length>1)r.allOf=[...f.map((h)=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:h.source}))]}},dx=(e,t,n,i)=>{let r=n,{minimum:s,maximum:o,multipleOf:a,exclusiveMaximum:c,exclusiveMinimum:l,isInt:u}=Dn(e);r.type=u?"integer":"number";let f=typeof l==="number"&&l>=(s??Number.NEGATIVE_INFINITY),h=typeof c==="number"&&c<=(o??Number.POSITIVE_INFINITY),d=t.target==="draft-04"||t.target==="openapi-3.0";if(f)if(d)r.minimum=l,r.exclusiveMinimum=!0;else r.exclusiveMinimum=l;else if(typeof s==="number")r.minimum=s;if(h)if(d)r.maximum=c,r.exclusiveMaximum=!0;else r.exclusiveMaximum=c;else if(typeof o==="number")r.maximum=o;if(a){let g=new Set;for(let m of a)if(Number.isFinite(m)&&m!==0)g.add(Math.abs(m));else Di(e,t,r,i,`A multipleOf divisor of ${m} cannot be represented in JSON Schema`);let[x,...p]=g;if(x!==void 0)r.multipleOf=x;if(p.length)r.allOf=[...r.allOf??[],...p.map((m)=>({multipleOf:m}))]}},px=(e,t,n,i)=>{n.type="boolean"};var mx=(e,t,n,i)=>{n.not={}};var gx=(e,t,n,i)=>{};var _x=(e,t,n,i)=>{let r=e._zod.def,s=xo(r.entries);if(s.length===0){n.not={};return}if(s.every((o)=>typeof o==="number"))n.type="number";if(s.every((o)=>typeof o==="string"))n.type="string";n.enum=s},xx=(e,t,n,i)=>{let r=e._zod.def;if(r.values.length===0){n.not={};return}let s=[];for(let o of r.values)if(o===void 0){if(Di(e,t,n,i,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof o==="bigint"){if(Di(e,t,n,i,"BigInt literals cannot be represented in JSON Schema"))return;s.push(Number(o))}else s.push(o);if(s.length===0);else if(s.length===1){let o=s[0];if(n.type=o===null?"null":typeof o,t.target==="draft-04"||t.target==="openapi-3.0")n.enum=[o];else n.const=o}else{if(s.every((o)=>typeof o==="number"))n.type="number";if(s.every((o)=>typeof o==="string"))n.type="string";if(s.every((o)=>typeof o==="boolean"))n.type="boolean";if(s.every((o)=>o===null))n.type="null";n.enum=s}};var yx=(e,t,n,i)=>{Di(e,t,n,i,"Custom types cannot be represented in JSON Schema")};var vx=(e,t,n,i)=>{Di(e,t,n,i,"Transforms cannot be represented in JSON Schema")};var bx=(e,t,n,i)=>{let r=n,s=e._zod.def,{minimum:o,maximum:a}=Dn(e);if(typeof o==="number")r.minItems=o;if(typeof a==="number")r.maxItems=a;r.type="array",r.items=It(s.element,t,{...i,path:[...i.path,"items"]})};function Rc(e){let t=e._zod.def;if(t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform"))return Rc(t.out);if(t.type==="catch")return Rc(t.innerType);return e._zod.optin}var Sx=(e,t,n,i)=>{let r=n,s=e._zod.def,o=s.shape;if(Object.getOwnPropertySymbols(o).length&&Di(e,t,r,i,"Symbol keys cannot be represented in JSON Schema"))return;r.type="object",r.properties={};for(let l in o)Nn(r.properties,l,It(o[l],t,{...i,path:[...i.path,"properties",l]}));let c=[];for(let l of Object.keys(o)){let u=s.shape[l];if(t.io==="input"?Rc(u)===void 0:u._zod.optout===void 0)c.push(l)}if(c.length>0)r.required=c;if(s.catchall?._zod.def.type==="never")r.additionalProperties=!1;else if(!s.catchall){if(t.io==="output")r.additionalProperties=!1}else if(s.catchall)r.additionalProperties=It(s.catchall,t,{...i,path:[...i.path,"additionalProperties"]})},Mx=(e,t,n,i)=>{let r=e._zod.def,s=r.inclusive===!1,o=r.options.map((a,c)=>It(a,t,{...i,path:[...i.path,s?"oneOf":"anyOf",c]}));if(s)n.oneOf=o;else n.anyOf=o},wx=(e,t,n,i)=>{let r=e._zod.def,s=It(r.left,t,{...i,path:[...i.path,"allOf",0]}),o=It(r.right,t,{...i,path:[...i.path,"allOf",1]}),a=(l)=>("allOf"in l)&&Object.keys(l).length===1,c=[...a(s)?s.allOf:[s],...a(o)?o.allOf:[o]];n.allOf=c,t.intersections.push(c)};function Zh(e,t,n){if(t.$ref){if(n.has(t))return t;n.add(t);let g=e.get(t)?.def;if(!g)return t;let x=Zh(e,g,n);return x===g?t:x}for(let g of["anyOf","oneOf"]){let x=t[g];if(!Array.isArray(x))continue;let p=x.map((m)=>Zh(e,m,n));if(p.some((m,E)=>m!==x[E]))t={...t,[g]:p}}let i=Array.isArray(t.type)?t.type:[t.type],r=!i.includes("string")&&i.some((g)=>g==="number"||g==="integer"),s=t.enum??(t.const!==void 0?[t.const]:void 0);if(!r&&!s?.some((g)=>typeof g==="number"))return t;let{minimum:o,maximum:a,exclusiveMinimum:c,exclusiveMaximum:l,multipleOf:u,format:f,id:h,...d}=t;if(d.enum)d.enum=d.enum.map((g)=>typeof g==="number"?String(g):g);else if(typeof d.const==="number")d.const=String(d.const);if(!r)return d;if(d.type="string",!s)d.pattern=(i.includes("number")?Mo:_h).source;return d}var Xh=new WeakMap;function CA(e){let t=new Map;for(let i of e.seen.values())if(i.def&&!t.has(i.schema))t.set(i.schema,i);let n=new Map;for(let i of Xh.get(e)??[]){let r=e.seen.get(i),s=(r?.def??r?.schema)?.propertyNames;if(!s||s===!0||n.has(s))continue;let o=Zh(t,s,new Set);if(o!==s)n.set(s,o)}if(!n.size)return;for(let i of e.seen.values())for(let r of[i.schema,i.def]){let s=r&&n.get(r.propertyNames);if(s)r.propertyNames=s}}var Ex=(e,t,n,i)=>{let r=n,s=e._zod.def;r.type="object";let o=s.keyType,a=Dn(o).patterns;if(s.mode==="loose"&&a&&a.size>0){let u=It(s.valueType,t,{...i,path:[...i.path,"patternProperties","*"]});r.patternProperties={};for(let f of a)Nn(r.patternProperties,hx(f).source,u)}else{if(t.target==="draft-07"||t.target==="draft-2020-12"){r.propertyNames=It(s.keyType,t,{...i,path:[...i.path,"propertyNames"]});let u=Xh.get(t);if(!u)u=[],Xh.set(t,u),t.deferred.push(()=>CA(t));u.push(e)}r.additionalProperties=It(s.valueType,t,{...i,path:[...i.path,"additionalProperties"]})}let c=o._zod.values,l=t.io==="input"&&Rc(s.valueType)!==void 0;if(c&&!s.partial&&!l){let u=[...c].filter((f)=>typeof f==="string"||typeof f==="number");if(u.length>0)r.required=u.map(String)}},Tx=(e,t,n,i)=>{let r=e._zod.def,s=It(r.innerType,t,i),o=t.seen.get(e);if(t.target==="openapi-3.0")o.ref=r.innerType,n.nullable=!0;else n.anyOf=[s,{type:"null"}]},Ax=(e,t,n,i)=>{let r=e._zod.def;It(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType},qh=Symbol();function Rx(e,t,n,i,r){let s=!1,o=JSON.stringify(e,(a,c)=>{if(typeof c!=="bigint")return c;return s=!0,null});if(!s)return JSON.parse(o);return Di(t,n,i,r,"BigInt defaults cannot be represented in JSON Schema"),qh}var Cx=(e,t,n,i)=>{let r=e._zod.def;It(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType;let o=Rx(r.defaultValue,e,t,n,i);if(o!==qh)n.default=o},Px=(e,t,n,i)=>{let r=e._zod.def;It(r.innerType,t,i);let s=t.seen.get(e);if(s.ref=r.innerType,t.io!=="input")return;let o=Rx(r.defaultValue,e,t,n,i);if(o!==qh)n._prefault=o},Ix=(e,t,n,i)=>{let r=e._zod.def;It(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType;let o;try{o=r.catchValue(void 0)}catch{Di(e,t,n,i,"Dynamic catch values are not supported in JSON Schema");return}n.default=o},Lx=(e,t,n,i)=>{let r=e._zod.def,s=r.in._zod.traits.has("$ZodTransform"),o=t.io==="input"?s?r.out:r.in:r.out;It(o,t,i);let a=t.seen.get(e);a.ref=o},Nx=(e,t,n,i)=>{let r=e._zod.def;It(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType,n.readOnly=!0};var jh=(e,t,n,i)=>{let r=e._zod.def;It(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType};var Dx=new WeakSet([Object.prototype,Error.prototype]);function Cc(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let i=n(this);return Object.defineProperty(this,t,{value:i,configurable:!0,writable:!0}),i},set(i){Object.defineProperty(this,t,{value:i,configurable:!0,writable:!0})}})}var FA=(e,t)=>{ng.init(e,t),e.name="ZodError";let n=Object.getPrototypeOf(e);if(Dx.has(n))return;Dx.add(n),Cc(n,"format",(i)=>(r)=>rg(i,r)),Cc(n,"flatten",(i)=>(r)=>ig(i,r)),Cc(n,"addIssue",(i)=>(r)=>{i.issues.push(r),i.message=JSON.stringify(i.issues,yo,2)}),Cc(n,"addIssues",(i)=>(r)=>{i.issues.push(...r),i.message=JSON.stringify(i.issues,yo,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}})};var Mn=J("ZodError",FA,void 0,{Parent:Error});var Ox=lc(Mn),Ux=uc(Mn),Fx=hc(Mn),zx=fc(Mn),kx=og(Mn),Bx=ag(Mn),Gx=cg(Mn),Hx=lg(Mn),Vx=ug(Mn),$x=hg(Mn),Wx=fg(Mn),Zx=dg(Mn);function kA(){if(!dn.localeError)Sn(Ph())}function Ic(){if(!dn.memoizer)Sn({memoizer:f0()})}var Et=J("ZodType",(e,t)=>(kA(),Mt.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(bn(t,{checks:[...t.checks??[],...e.map((n)=>typeof n==="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return hi(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(U1(e,t))},superRefine(e,t){return this.check(F1(e,t))},overwrite(e){return this.check(lr(e))},optional(){return jx(this)},exactOptional(){return M1(this)},nullable(){return Yx(this)},nullish(){return jx(Yx(this))},nonoptional(e){return C1(this,e)},array(){return an(this)},or(e){return ty([this,e])},and(e){return y1(this,e)},transform(e){return Kx(this,S1(e))},default(e){return T1(this,e)},prefault(e){return R1(this,e)},catch(e){return I1(this,e)},pipe(e){return Kx(this,e)},readonly(){return D1(this)},describe(e){let t=this.clone();return Or.add(t,{description:e}),t},meta(...e){if(e.length===0)return Or.get(this);let t=this.clone();return Or.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get "~standard"(){return ac(this,"~standard",{...Mh(this),jsonSchema:{input:Io(this,"input"),output:Io(this,"output")}})},set "~standard"(e){Ni(this,"~standard",e)},parse:function e(t,n){return Ox(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await Ux(this,t,n,{callee:e})},safeParse(e,t){return Fx(this,e,t)},async safeParseAsync(e,t){return zx(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){Ni(this,"spa",e)},validate(e,t){return dh(this,e,t)},validateAsync(e,t){return ph(this,e,t)},encode:function e(t,n){return kx(this,t,n,{callee:e})},decode:function e(t,n){return Bx(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await Gx(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await Hx(this,t,n,{callee:e})},safeEncode(e,t){return Vx(this,e,t)},safeDecode(e,t){return $x(this,e,t)},async safeEncodeAsync(e,t){return Wx(this,e,t)},async safeDecodeAsync(e,t){return Zx(this,e,t)},toJSONSchema(e){return nx(this,{})(e)},get description(){return Or.get(this)?.description},get _def(){return this._zod.def}}),Jx=J("_ZodString",(e,t)=>{_c.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,r)=>fx(e,n,i,r)},Ym({format:(e)=>Dn(e).format??null,minLength:(e)=>Dn(e).minimum??null,maxLength:(e)=>Dn(e).maximum??null},{regex(...e){return this.check(Ih(...e))},includes(...e){return this.check(Dh(...e))},startsWith(...e){return this.check(Oh(...e))},endsWith(...e){return this.check(Uh(...e))},min(...e){return this.check(As(...e))},max(...e){return this.check(Tc(...e))},length(...e){return this.check(Ac(...e))},nonempty(...e){return this.check(As(1,...e))},lowercase(e){return this.check(Lh(e))},uppercase(e){return this.check(Nh(e))},trim(){return this.check(zh())},normalize(...e){return this.check(Fh(...e))},toLowerCase(){return this.check(kh())},toUpperCase(){return this.check(Bh())},slugify(){return this.check(Gh())}})),BA=J("ZodString",(e,t)=>{_c.init(e,t),Jx.init(e,t)},{email(e){return this.check(_0(WA,e))},url(e){return this.check(M0(XA,e))},jwt(e){return this.check(z0(c1,e))},emoji(e){return this.check(w0(qA,e))},guid(e){return this.check(x0(ZA,e))},uuid(e){return this.check(y0(Pc,e))},uuidv4(e){return this.check(v0(Pc,e))},uuidv6(e){return this.check(b0(Pc,e))},uuidv7(e){return this.check(S0(Pc,e))},nanoid(e){return this.check(E0(jA,e))},cuid(e){return this.check(T0(YA,e))},cuid2(e){return this.check(A0(KA,e))},ulid(e){return this.check(R0(JA,e))},base64(e){return this.check(O0(s1,e))},base64url(e){return this.check(U0(o1,e))},xid(e){return this.check(C0(QA,e))},ksuid(e){return this.check(P0(e1,e))},ipv4(e){return this.check(I0(t1,e))},ipv6(e){return this.check(L0(n1,e))},cidrv4(e){return this.check(N0(i1,e))},cidrv6(e){return this.check(D0(r1,e))},e164(e){return this.check(F0(a1,e))},datetime(e){return this.check(k0(GA,e))},date(e){return this.check(B0(HA,e))},time(e){return this.check(G0(VA,e))},duration(e){return this.check(H0($A,e))}});function Je(e){return g0(BA,e)}var Tt=J("ZodStringFormat",(e,t)=>{bt.init(e,t),Jx.init(e,t)}),GA=J("ZodISODateTime",(e,t)=>{E_.init(e,t),Tt.init(e,t)}),HA=J("ZodISODate",(e,t)=>{T_.init(e,t),Tt.init(e,t)}),VA=J("ZodISOTime",(e,t)=>{A_.init(e,t),Tt.init(e,t)}),$A=J("ZodISODuration",(e,t)=>{R_.init(e,t),Tt.init(e,t)}),WA=J("ZodEmail",(e,t)=>{p_.init(e,t),Tt.init(e,t)});var ZA=J("ZodGUID",(e,t)=>{f_.init(e,t),Tt.init(e,t)});var Pc=J("ZodUUID",(e,t)=>{d_.init(e,t),Tt.init(e,t)});var XA=J("ZodURL",(e,t)=>{__.init(e,t),Tt.init(e,t)});var qA=J("ZodEmoji",(e,t)=>{x_.init(e,t),Tt.init(e,t)});var jA=J("ZodNanoID",(e,t)=>{y_.init(e,t),Tt.init(e,t)});var YA=J("ZodCUID",(e,t)=>{v_.init(e,t),Tt.init(e,t)});var KA=J("ZodCUID2",(e,t)=>{b_.init(e,t),Tt.init(e,t)});var JA=J("ZodULID",(e,t)=>{S_.init(e,t),Tt.init(e,t)});var QA=J("ZodXID",(e,t)=>{M_.init(e,t),Tt.init(e,t)});var e1=J("ZodKSUID",(e,t)=>{w_.init(e,t),Tt.init(e,t)});var t1=J("ZodIPv4",(e,t)=>{C_.init(e,t),Tt.init(e,t)});var n1=J("ZodIPv6",(e,t)=>{I_.init(e,t),Tt.init(e,t)});var i1=J("ZodCIDRv4",(e,t)=>{L_.init(e,t),Tt.init(e,t)});var r1=J("ZodCIDRv6",(e,t)=>{N_.init(e,t),Tt.init(e,t)});var s1=J("ZodBase64",(e,t)=>{O_.init(e,t),Tt.init(e,t)});var o1=J("ZodBase64URL",(e,t)=>{U_.init(e,t),Tt.init(e,t)});var a1=J("ZodE164",(e,t)=>{F_.init(e,t),Tt.init(e,t)});var c1=J("ZodJWT",(e,t)=>{z_.init(e,t),Tt.init(e,t)});var Qx=J("ZodNumber",(e,t)=>{Eh.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,r)=>dx(e,n,i,r),e.isFinite=!0},Ym({minValue:(e)=>{let{minimum:t,exclusiveMinimum:n}=Dn(e);return Math.max(t??Number.NEGATIVE_INFINITY,n??Number.NEGATIVE_INFINITY)},maxValue:(e)=>{let{maximum:t,exclusiveMaximum:n}=Dn(e);return Math.min(t??Number.POSITIVE_INFINITY,n??Number.POSITIVE_INFINITY)},isInt:(e)=>{let{isInt:t,multipleOf:n}=Dn(e);return!!t||!!n?.some(Number.isSafeInteger)},format:(e)=>Dn(e).format??null},{gt(e,t){return this.check(wc(e,t))},gte(e,t){return this.check(Co(e,t))},min(e,t){return this.check(Co(e,t))},lt(e,t){return this.check(Mc(e,t))},lte(e,t){return this.check(Ro(e,t))},max(e,t){return this.check(Ro(e,t))},int(e){return this.check(Xx(e))},safe(e){return this.check(Xx(e))},positive(e){return this.check(wc(0,e))},nonnegative(e){return this.check(Co(0,e))},negative(e){return this.check(Mc(0,e))},nonpositive(e){return this.check(Ro(0,e))},multipleOf(e,t){return this.check(Ec(e,t))},step(e,t){return this.check(Ec(e,t))},finite(){return this}}));function pt(e){return V0(Qx,e)}var l1=J("ZodNumberFormat",(e,t)=>{k_.init(e,t),Qx.init(e,t)});function Xx(e){return $0(l1,e)}var u1=J("ZodBoolean",(e,t)=>{B_.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,r)=>px(e,n,i,r)});function Lo(e){return W0(u1,e)}var h1=J("ZodUnknown",(e,t)=>{G_.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,r)=>gx(e,n,i,r)});function Ur(){return Z0(h1)}var f1=J("ZodNever",(e,t)=>{H_.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,r)=>mx(e,n,i,r)});function d1(e){return X0(f1,e)}var p1=J("ZodArray",(e,t)=>{Ic(),V_.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,r)=>bx(e,n,i,r),e.element=t.element},{min(e,t){return this.check(As(e,t))},nonempty(e){return this.check(As(1,e))},max(e,t){return this.check(Tc(e,t))},length(e,t){return this.check(Ac(e,t))},unwrap(){return this.element}});function an(e,t){return q0(p1,e,t)}var m1=J("ZodObject",(e,t)=>{Ic(),Z_.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Sx(e,n,i,r),XT(e,"shape",(n)=>n._zod.def.shape,!1)},{keyof(){return On(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(bn(this._zod.def,{catchall:e}))},passthrough(){return this.clone(bn(this._zod.def,{catchall:Ur()}))},loose(){return this.clone(bn(this._zod.def,{catchall:Ur()}))},strict(){return this.clone(bn(this._zod.def,{catchall:d1()}))},strip(){return this.clone(bn(this._zod.def,{catchall:void 0}))},extend(e){return kT(this,e)},safeExtend(e){return BT(this,e)},merge(e){return GT(this,e)},pick(e){return FT(this,e)},omit(e){return zT(this,e)},partial(...e){return Zm(ny,this,e[0])},exactPartial(...e){return Zm(iy,this,e[0],"exactPartial")},required(...e){return HT(ry,this,e[0])}});function ht(e,t){let n={type:"object",shape:e??{},...Ce(t)};return new m1(n)}var ey=J("ZodUnion",(e,t)=>{Th.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Mx(e,n,i,r),e.options=t.options});function ty(e,t){return new ey({type:"union",options:e,...Ce(t)})}var g1=J("ZodDiscriminatedUnion",(e,t)=>{ey.init(e,t),X_.init(e,t)});function _1(e,t,n){return new g1({type:"union",options:t,discriminator:e,...Ce(n)})}var x1=J("ZodIntersection",(e,t)=>{q_.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,r)=>wx(e,n,i,r)});function y1(e,t){return new x1({type:"intersection",left:e,right:t})}var qx=J("ZodRecord",(e,t)=>{Ic(),j_.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Ex(e,n,i,r),e.keyType=t.keyType,e.valueType=t.valueType});function Lc(e,t,n){if(!t||!t._zod)return new qx({type:"record",keyType:Je(),valueType:e,...Ce(t)});return new qx({type:"record",keyType:e,valueType:t,...Ce(n)})}var Kh=J("ZodEnum",(e,t)=>{Y_.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(i,r,s)=>_x(e,i,r,s),e.enum=t.entries,e.options=[...e._zod.values];let n=new Set(Object.keys(t.entries));e.extract=(i,r)=>{let s={};for(let o of i)if(n.has(o))s[o]=t.entries[o];else throw Error(`Key ${o} not found in enum`);return new Kh({...t,checks:[],...Ce(r),entries:s})},e.exclude=(i,r)=>{let s={...t.entries};for(let o of i)if(n.has(o))delete s[o];else throw Error(`Key ${o} not found in enum`);return new Kh({...t,checks:[],...Ce(r),entries:s})}});function On(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map((i)=>[i,i])):e;return new Kh({type:"enum",entries:n,...Ce(t)})}var v1=J("ZodLiteral",(e,t)=>{K_.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,r)=>xx(e,n,i,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function qt(e,t){return new v1({type:"literal",values:Array.isArray(e)?e:[e],...Ce(t)})}var b1=J("ZodTransform",(e,t)=>{Ic(),J_.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,r)=>vx(e,n,i,r),e._zod.parse=(n,i)=>{if(i.direction==="backward")throw new So(e.constructor.name);n.addIssue=(s)=>{if(typeof s==="string")n.issues.push(Dr(s,n.value,t));else{let o=s;if(o.fatal)o.continue=!1;if(o.code??(o.code="custom"),!("input"in o))o.input=n.value;o.inst??(o.inst=e),n.issues.push(Dr(o))}};let r=t.transform(n.value,n);if(r instanceof Promise)return r.then((s)=>(n.value=s,n));return n.value=r,n}});function S1(e){return new b1({type:"transform",transform:e})}var ny=J("ZodOptional",(e,t)=>{Ah.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,r)=>jh(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function jx(e){return new ny({type:"optional",innerType:e})}var iy=J("ZodExactOptional",(e,t)=>{Q_.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,r)=>jh(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function M1(e){return new iy({type:"optional",innerType:e})}var w1=J("ZodNullable",(e,t)=>{e0.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Tx(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function Yx(e){return new w1({type:"nullable",innerType:e})}var E1=J("ZodDefault",(e,t)=>{t0.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Cx(e,n,i,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function T1(e,t){return new E1({type:"default",innerType:e,get defaultValue(){return typeof t==="function"?t():oh(t)}})}var A1=J("ZodPrefault",(e,t)=>{n0.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Px(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function R1(e,t){return new A1({type:"prefault",innerType:e,get defaultValue(){return typeof t==="function"?t():oh(t)}})}var ry=J("ZodNonOptional",(e,t)=>{i0.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Ax(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function C1(e,t){return new ry({type:"nonoptional",innerType:e,...Ce(t)})}var P1=J("ZodCatch",(e,t)=>{r0.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Ix(e,n,i,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function I1(e,t){return new P1({type:"catch",innerType:e,catchValue:typeof t==="function"?t:Km(t)})}var L1=J("ZodPipe",(e,t)=>{s0.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Lx(e,n,i,r),e.in=t.in,e.out=t.out});function Kx(e,t){return new L1({type:"pipe",in:e,out:t})}var N1=J("ZodReadonly",(e,t)=>{o0.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Nx(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function D1(e){return new N1({type:"readonly",innerType:e})}var O1=J("ZodCustom",(e,t)=>{a0.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,r)=>yx(e,n,i,r)});function U1(e,t={}){return j0(O1,e,t)}function F1(e,t){return Y0(e,t)}var oy=["neutral","dark","light"];var Jh=(e,t)=>Object.freeze({id:e,rgb:Object.freeze([...t]),hex:`#${t.map((n)=>n.toString(16).padStart(2,"0")).join("")}`}),ay=Object.freeze({neutral:Jh("neutral",[170,177,188]),dark:Jh("dark",[26,26,26]),light:Jh("light",[223,227,232])});var xD=ay.neutral.rgb,yD=ay.neutral.hex;/*!
4401
4401
  fflate - fast JavaScript compression/decompression
4402
4402
  <https://101arrowz.github.io/fflate>
4403
4403
  Licensed under MIT. https://github.com/101arrowz/fflate/blob/master/LICENSE
4404
4404
  version 0.8.2
4405
- */var Rt=Uint8Array,wn=Uint16Array,af=Int32Array,Lc=new Rt([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Nc=new Rt([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),tf=new Rt([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),dy=function(e,t){var n=new wn(31);for(var i=0;i<31;++i)n[i]=t+=1<<e[i-1];var r=new af(n[30]);for(var i=1;i<30;++i)for(var s=n[i];s<n[i+1];++s)r[s]=s-n[i]<<5|i;return{b:n,r}},py=dy(Lc,2),{b:my,r:nf}=py;my[28]=258,nf[258]=28;var gy=dy(Nc,0),{b:U1,r:ay}=gy,rf=new wn(32768);for(je=0;je<32768;++je)mi=(je&43690)>>1|(je&21845)<<1,mi=(mi&52428)>>2|(mi&13107)<<2,mi=(mi&61680)>>4|(mi&3855)<<4,rf[je]=((mi&65280)>>8|(mi&255)<<8)>>1;var mi,je,gi=function(e,t,n){var i=e.length,r=0,s=new wn(t);for(;r<i;++r)if(e[r])++s[e[r]-1];var o=new wn(t);for(r=1;r<t;++r)o[r]=o[r-1]+s[r-1]<<1;var a;if(n){a=new wn(1<<t);var c=15-t;for(r=0;r<i;++r)if(e[r]){var l=r<<4|e[r],u=t-e[r],f=o[e[r]-1]++<<u;for(var h=f|(1<<u)-1;f<=h;++f)a[rf[f]>>c]=l}}else{a=new wn(i);for(r=0;r<i;++r)if(e[r])a[r]=rf[o[e[r]-1]++]>>15-e[r]}return a},lr=new Rt(288);for(je=0;je<144;++je)lr[je]=8;var je;for(je=144;je<256;++je)lr[je]=9;var je;for(je=256;je<280;++je)lr[je]=7;var je;for(je=280;je<288;++je)lr[je]=8;var je,Io=new Rt(32);for(je=0;je<32;++je)Io[je]=5;var je,F1=gi(lr,9,0),z1=gi(lr,9,1),k1=gi(Io,5,0),B1=gi(Io,5,1),Jh=function(e){var t=e[0];for(var n=1;n<e.length;++n)if(e[n]>t)t=e[n];return t},Zn=function(e,t,n){var i=t/8|0;return(e[i]|e[i+1]<<8)>>(t&7)&n},Qh=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(t&7)},cf=function(e){return(e+7)/8|0},lf=function(e,t,n){if(t==null||t<0)t=0;if(n==null||n>e.length)n=e.length;return new Rt(e.subarray(t,n))};var G1=["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"],On=function(e,t,n){var i=Error(t||G1[e]);if(i.code=e,Error.captureStackTrace)Error.captureStackTrace(i,On);if(!n)throw i;return i},H1=function(e,t,n,i){var r=e.length,s=i?i.length:0;if(!r||t.f&&!t.l)return n||new Rt(0);var o=!n,a=o||t.i!=2,c=t.i;if(o)n=new Rt(r*3);var l=function(_e){var Qe=n.length;if(_e>Qe){var ze=new Rt(Math.max(Qe*2,_e));ze.set(n),n=ze}},u=t.f||0,f=t.p||0,h=t.b||0,{l:d,d:g,m:x,n:p}=t,m=r*8;do{if(!d){u=Zn(e,f,1);var E=Zn(e,f+1,3);if(f+=3,!E){var R=cf(f)+4,v=e[R-4]|e[R-3]<<8,M=R+v;if(M>r){if(c)On(0);break}if(a)l(h+v);n.set(e.subarray(R,M),h),t.b=h+=v,t.p=f=M*8,t.f=u;continue}else if(E==1)d=z1,g=B1,x=9,p=5;else if(E==2){var T=Zn(e,f,31)+257,A=Zn(e,f+10,15)+4,_=T+Zn(e,f+5,31)+1;f+=14;var S=new Rt(_),k=new Rt(19);for(var C=0;C<A;++C)k[tf[C]]=Zn(e,f+C*3,7);f+=A*3;var U=Jh(k),ee=(1<<U)-1,P=gi(k,U,1);for(var C=0;C<_;){var V=P[Zn(e,f,ee)];f+=V&15;var R=V>>4;if(R<16)S[C++]=R;else{var j=0,z=0;if(R==16)z=3+Zn(e,f,3),f+=2,j=S[C-1];else if(R==17)z=3+Zn(e,f,7),f+=3;else if(R==18)z=11+Zn(e,f,127),f+=7;while(z--)S[C++]=j}}var H=S.subarray(0,T),F=S.subarray(T);x=Jh(H),p=Jh(F),d=gi(H,x,1),g=gi(F,p,1)}else On(1);if(f>m){if(c)On(0);break}}if(a)l(h+131072);var q=(1<<x)-1,K=(1<<p)-1,xe=f;for(;;xe=f){var j=d[Qh(e,f)&q],ce=j>>4;if(f+=j&15,f>m){if(c)On(0);break}if(!j)On(2);if(ce<256)n[h++]=ce;else if(ce==256){xe=f,d=null;break}else{var De=ce-254;if(ce>264){var C=ce-257,ye=Lc[C];De=Zn(e,f,(1<<ye)-1)+my[C],f+=ye}var X=g[Qh(e,f)&K],re=X>>4;if(!X)On(3);f+=X&15;var F=U1[re];if(re>3){var ye=Nc[re];F+=Qh(e,f)&(1<<ye)-1,f+=ye}if(f>m){if(c)On(0);break}if(a)l(h+131072);var se=h+De;if(h<F){var Te=s-F,Ie=Math.min(F,se);if(Te+h<0)On(3);for(;h<Ie;++h)n[h]=i[Te+h]}for(;h<se;++h)n[h]=n[h-F]}}if(t.l=d,t.p=xe,t.b=h,t.f=u,d)u=1,t.m=x,t.d=g,t.n=p}while(!u);return h!=n.length&&o?lf(n,0,h):n.subarray(0,h)},Di=function(e,t,n){n<<=t&7;var i=t/8|0;e[i]|=n,e[i+1]|=n>>8},Co=function(e,t,n){n<<=t&7;var i=t/8|0;e[i]|=n,e[i+1]|=n>>8,e[i+2]|=n>>16},ef=function(e,t){var n=[];for(var i=0;i<e.length;++i)if(e[i])n.push({s:i,f:e[i]});var r=n.length,s=n.slice();if(!r)return{t:xy,l:0};if(r==1){var o=new Rt(n[0].s+1);return o[n[0].s]=1,{t:o,l:1}}n.sort(function(M,T){return M.f-T.f}),n.push({s:-1,f:25001});var a=n[0],c=n[1],l=0,u=1,f=2;n[0]={s:-1,f:a.f+c.f,l:a,r:c};while(u!=r-1)a=n[n[l].f<n[f].f?l++:f++],c=n[l!=u&&n[l].f<n[f].f?l++:f++],n[u++]={s:-1,f:a.f+c.f,l:a,r:c};var h=s[0].s;for(var i=1;i<r;++i)if(s[i].s>h)h=s[i].s;var d=new wn(h+1),g=sf(n[u-1],d,0);if(g>t){var i=0,x=0,p=g-t,m=1<<p;s.sort(function(T,A){return d[A.s]-d[T.s]||T.f-A.f});for(;i<r;++i){var E=s[i].s;if(d[E]>t)x+=m-(1<<g-d[E]),d[E]=t;else break}x>>=p;while(x>0){var R=s[i].s;if(d[R]<t)x-=1<<t-d[R]++-1;else++i}for(;i>=0&&x;--i){var v=s[i].s;if(d[v]==t)--d[v],++x}g=t}return{t:new Rt(d),l:g}},sf=function(e,t,n){return e.s==-1?Math.max(sf(e.l,t,n+1),sf(e.r,t,n+1)):t[e.s]=n},cy=function(e){var t=e.length;while(t&&!e[--t]);var n=new wn(++t),i=0,r=e[0],s=1,o=function(c){n[i++]=c};for(var a=1;a<=t;++a)if(e[a]==r&&a!=t)++s;else{if(!r&&s>2){for(;s>138;s-=138)o(32754);if(s>2)o(s>10?s-11<<5|28690:s-3<<5|12305),s=0}else if(s>3){o(r),--s;for(;s>6;s-=6)o(8304);if(s>2)o(s-3<<5|8208),s=0}while(s--)o(r);s=1,r=e[a]}return{c:n.subarray(0,i),n:t}},Po=function(e,t){var n=0;for(var i=0;i<t.length;++i)n+=e[i]*t[i];return n},_y=function(e,t,n){var i=n.length,r=cf(t+2);e[r]=i&255,e[r+1]=i>>8,e[r+2]=e[r]^255,e[r+3]=e[r+1]^255;for(var s=0;s<i;++s)e[r+s+4]=n[s];return(r+4+i)*8},ly=function(e,t,n,i,r,s,o,a,c,l,u){Di(t,u++,n),++r[256];var f=ef(r,15),{t:h,l:d}=f,g=ef(s,15),{t:x,l:p}=g,m=cy(h),{c:E,n:R}=m,v=cy(x),{c:M,n:T}=v,A=new wn(19);for(var _=0;_<E.length;++_)++A[E[_]&31];for(var _=0;_<M.length;++_)++A[M[_]&31];var S=ef(A,7),{t:k,l:C}=S,U=19;for(;U>4&&!k[tf[U-1]];--U);var ee=l+5<<3,P=Po(r,lr)+Po(s,Io)+o,V=Po(r,h)+Po(s,x)+o+14+3*U+Po(A,k)+2*A[16]+3*A[17]+7*A[18];if(c>=0&&ee<=P&&ee<=V)return _y(t,u,e.subarray(c,c+l));var j,z,H,F;if(Di(t,u,1+(V<P)),u+=2,V<P){j=gi(h,d,0),z=h,H=gi(x,p,0),F=x;var q=gi(k,C,0);Di(t,u,R-257),Di(t,u+5,T-1),Di(t,u+10,U-4),u+=14;for(var _=0;_<U;++_)Di(t,u+3*_,k[tf[_]]);u+=3*U;var K=[E,M];for(var xe=0;xe<2;++xe){var ce=K[xe];for(var _=0;_<ce.length;++_){var De=ce[_]&31;if(Di(t,u,q[De]),u+=k[De],De>15)Di(t,u,ce[_]>>5&127),u+=ce[_]>>12}}}else j=F1,z=lr,H=k1,F=Io;for(var _=0;_<a;++_){var ye=i[_];if(ye>255){var De=ye>>18&31;if(Co(t,u,j[De+257]),u+=z[De+257],De>7)Di(t,u,ye>>23&31),u+=Lc[De];var X=ye&31;if(Co(t,u,H[X]),u+=F[X],X>3)Co(t,u,ye>>5&8191),u+=Nc[X]}else Co(t,u,j[ye]),u+=z[ye]}return Co(t,u,j[256]),u+z[256]},V1=new af([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),xy=new Rt(0),$1=function(e,t,n,i,r,s){var o=s.z||e.length,a=new Rt(i+o+5*(1+Math.ceil(o/7000))+r),c=a.subarray(i,a.length-r),l=s.l,u=(s.r||0)&7;if(t){if(u)c[0]=s.r>>3;var f=V1[t-1],h=f>>13,d=f&8191,g=(1<<n)-1,x=s.p||new wn(32768),p=s.h||new wn(g+1),m=Math.ceil(n/3),E=2*m,R=function(Ze){return(e[Ze]^e[Ze+1]<<m^e[Ze+2]<<E)&g},v=new af(25000),M=new wn(288),T=new wn(32),A=0,_=0,S=s.i||0,k=0,C=s.w||0,U=0;for(;S+2<o;++S){var ee=R(S),P=S&32767,V=p[ee];if(x[P]=V,p[ee]=P,C<=S){var j=o-S;if((A>7000||k>24576)&&(j>423||!l)){u=ly(e,c,0,v,M,T,_,k,U,S-U,u),k=A=_=0,U=S;for(var z=0;z<286;++z)M[z]=0;for(var z=0;z<30;++z)T[z]=0}var H=2,F=0,q=d,K=P-V&32767;if(j>2&&ee==R(S-K)){var xe=Math.min(h,j)-1,ce=Math.min(32767,S),De=Math.min(258,j);while(K<=ce&&--q&&P!=V){if(e[S+H]==e[S+H-K]){var ye=0;for(;ye<De&&e[S+ye]==e[S+ye-K];++ye);if(ye>H){if(H=ye,F=K,ye>xe)break;var X=Math.min(K,ye-2),re=0;for(var z=0;z<X;++z){var se=S-K+z&32767,Te=x[se],Ie=se-Te&32767;if(Ie>re)re=Ie,V=se}}}P=V,V=x[P],K+=P-V&32767}}if(F){v[k++]=268435456|nf[H]<<18|ay[F];var _e=nf[H]&31,Qe=ay[F]&31;_+=Lc[_e]+Nc[Qe],++M[257+_e],++T[Qe],C=S+H,++A}else v[k++]=e[S],++M[e[S]]}}for(S=Math.max(S,C);S<o;++S)v[k++]=e[S],++M[e[S]];if(u=ly(e,c,l,v,M,T,_,k,U,S-U,u),!l)s.r=u&7|c[u/8|0]<<3,u-=7,s.h=p,s.p=x,s.i=S,s.w=C}else{for(var S=s.w||0;S<o+l;S+=65535){var ze=S+65535;if(ze>=o)c[u/8|0]=l,ze=o;u=_y(c,u+1,e.subarray(S,ze))}s.i=o}return lf(a,0,i+cf(u)+r)},W1=function(){var e=new Int32Array(256);for(var t=0;t<256;++t){var n=t,i=9;while(--i)n=(n&1&&-306674912)^n>>>1;e[t]=n}return e}(),Z1=function(){var e=-1;return{p:function(t){var n=e;for(var i=0;i<t.length;++i)n=W1[n&255^t[i]]^n>>>8;e=n},d:function(){return~e}}};var X1=function(e,t,n,i,r){if(!r){if(r={l:1},t.dictionary){var s=t.dictionary.subarray(-32768),o=new Rt(s.length+e.length);o.set(s),o.set(e,s.length),e=o,r.w=s.length}}return $1(e,t.level==null?6:t.level,t.mem==null?r.l?Math.ceil(Math.max(8,Math.min(13,Math.log(e.length)))*1.5):20:12+t.mem,n,i,r)},yy=function(e,t){var n={};for(var i in e)n[i]=e[i];for(var i in t)n[i]=t[i];return n};var jt=function(e,t,n){for(;n;++t)e[t]=n,n>>>=8};function vy(e,t){return X1(e,t||{},0,0)}function by(e,t){return H1(e,{i:2},t&&t.out,t&&t.dictionary)}var Sy=function(e,t,n,i){for(var r in e){var s=e[r],o=t+r,a=i;if(Array.isArray(s))a=yy(i,s[1]),s=s[0];if(s instanceof Rt)n[o]=[s,a];else n[o+="/"]=[new Rt(0),a],Sy(s,o,n,i)}},uy=typeof TextEncoder<"u"&&new TextEncoder,q1=typeof TextDecoder<"u"&&new TextDecoder,j1=0;try{q1.decode(xy,{stream:!0}),j1=1}catch(e){}function hy(e,t){if(t){var n=new Rt(e.length);for(var i=0;i<e.length;++i)n[i]=e.charCodeAt(i);return n}if(uy)return uy.encode(e);var r=e.length,s=new Rt(e.length+(e.length>>1)),o=0,a=function(u){s[o++]=u};for(var i=0;i<r;++i){if(o+5>s.length){var c=new Rt(o+8+(r-i<<1));c.set(s),s=c}var l=e.charCodeAt(i);if(l<128||t)a(l);else if(l<2048)a(192|l>>6),a(128|l&63);else if(l>55295&&l<57344)l=65536+(l&1047552)|e.charCodeAt(++i)&1023,a(240|l>>18),a(128|l>>12&63),a(128|l>>6&63),a(128|l&63);else a(224|l>>12),a(128|l>>6&63),a(128|l&63)}return lf(s,0,o)}var of=function(e){var t=0;if(e)for(var n in e){var i=e[n].length;if(i>65535)On(9);t+=i+4}return t},fy=function(e,t,n,i,r,s,o,a){var c=i.length,l=n.extra,u=a&&a.length,f=of(l);if(jt(e,t,o!=null?33639248:67324752),t+=4,o!=null)e[t++]=20,e[t++]=n.os;e[t]=20,t+=2,e[t++]=n.flag<<1|(s<0&&8),e[t++]=r&&8,e[t++]=n.compression&255,e[t++]=n.compression>>8;var h=new Date(n.mtime==null?Date.now():n.mtime),d=h.getFullYear()-1980;if(d<0||d>119)On(10);if(jt(e,t,d<<25|h.getMonth()+1<<21|h.getDate()<<16|h.getHours()<<11|h.getMinutes()<<5|h.getSeconds()>>1),t+=4,s!=-1)jt(e,t,n.crc),jt(e,t+4,s<0?-s-2:s),jt(e,t+8,n.size);if(jt(e,t+12,c),jt(e,t+14,f),t+=16,o!=null)jt(e,t,u),jt(e,t+6,n.attrs),jt(e,t+10,o),t+=14;if(e.set(i,t),t+=c,f)for(var g in l){var x=l[g],p=x.length;jt(e,t,+g),jt(e,t+2,p),e.set(x,t+4),t+=4+p}if(u)e.set(a,t),t+=u;return t},Y1=function(e,t,n,i,r){jt(e,t,101010256),jt(e,t+8,n),jt(e,t+10,n),jt(e,t+12,i),jt(e,t+16,r)};function My(e,t){if(!t)t={};var n={},i=[];Sy(e,"",n,t);var r=0,s=0;for(var o in n){var a=n[o],c=a[0],l=a[1],u=l.level==0?0:8,f=hy(o),h=f.length,d=l.comment,g=d&&hy(d),x=g&&g.length,p=of(l.extra);if(h>65535)On(11);var m=u?vy(c,l):c,E=m.length,R=Z1();R.p(c),i.push(yy(l,{size:c.length,crc:R.d(),c:m,f,m:g,u:h!=o.length||g&&d.length!=x,o:r,compression:u})),r+=30+h+p+E,s+=76+2*(h+p)+(x||0)+E}var v=new Rt(s+22),M=r,T=s-r;for(var A=0;A<i.length;++A){var f=i[A];fy(v,f.o,f,f.f,f.u,f.c.length);var _=30+f.f.length+of(f.extra);v.set(f.c,f.o+_),fy(v,r,f,f.f,f.u,f.c.length,f.o,f.m),r+=16+_+(f.m?f.m.length:0)}return Y1(v,r,i.length,T,M),v}var uf=["albedo","emissive","normal","roughness","metalness","metallicRoughness","occlusion"];function K1(e){if(e==="UNINITIALIZED_BINDING")return"A const, let or class binding was read before its declaration ran (temporal dead zone). Move the declaration above the first code that reads it; top-level constants must be declared before other top-level code uses them. kiln_validate names the binding and line when the read runs immediately.";if(e==="LOD_SET")return'Levels of detail: sibling nodes whose names share a stem and carry LOD0, LOD1, ... tokens (Body_LOD0, Body_LOD1) form one set. A set needs LOD0 and consecutive levels under one parent, outside any other tier, and one defineLod([lod0, lod1, ...], { screenCoverage: [...] }) call listing its tiers in level order with one value per level, each from 0 to 1 and strictly decreasing; the last may be 0, which never culls. Build one tier without LOD tokens unless the brief asks for levels. Call kiln_discover with ids ["defineLod"].';if(e==="OPEN_SHELL")return'markOpenShell(part, reason) marks a part as intentionally open: part is the mesh createPart returned or a group whose meshes it covers, and reason is a non-empty string of at most 200 characters saying why, for example markOpenShell(rail, "C-channel closed by the end plates"). The engine owns the kilnOpenShell userData key; set it only through markOpenShell. Call kiln_discover with ids ["markOpenShell"].';if(e==="BUILD_RESULT")return'Define a top-level function build() (it may be async) that returns the root Object3D, for example const root = createRoot("Name"); ...; return root;. A build() that returns nothing, or returns a geometry or material, is rejected.';if(e==="MATERIAL_RECIPE_OVERRIDE")return'materialRecipe takes a listed kiln.material.*.v1 ID and only the overrides that recipe allows; the allowed overrides differ by recipe (the emissive recipe has no metalness). Call kiln_discover with ids ["materialRecipe"] to see what each recipe allows; kiln_validate names the recipe and key when both are literals.';if(e==="PROGRAM_TYPE_ERROR")return"The program or a helper it called threw a TypeError: a value had the wrong type. Usually something is undefined (a function without a return, an un-awaited async helper such as roundedBoxGeo, extrudeProfile or materialRecipe, or a misspelt property) or a non-function was called. Run kiln_validate, then check the helper contract with kiln_discover.";if(e==="PROGRAM_RANGE_ERROR")return"The program or a helper it called threw a RangeError: a number was outside its allowed range, for example a non-positive size, an invalid array length or segment count, or unbounded recursion. Check the helper arguments against kiln_discover.";if(e==="MESH_DATA_NONFINITE")return"meshGeo positions, normals, UVs and tangents must contain finite numbers representable in Float32. Check missing XYZ components, undefined values, division by zero and overflowing calculations before constructing the arrays. Do not replace invalid values blindly with zero; correct the source calculation. Call kiln_discover for the exact meshGeo data contract.";if(e==="PORTABLE_COLOR_ARGUMENT")return"compilePortableMaterialSpecV2 baseColor and emissive must be numeric color integers from 0x000000 to 0xffffff, for example baseColor: 0x8a867c. CSS strings and materialRecipe hex-string overrides use different contracts. Omit these fields for their defaults, or call kiln_discover for the exact helper contract.";if(e==="MATERIAL_RECIPE_TEXTURE_BINDING")return"materialRecipe textureResources maps portable slots to approved resource ID strings. Slots are baseColor, normal, metallicRoughness, emissive and occlusion. albedo is a pbrMaterial field, not a recipe slot. Use kiln_discover to check each resource allowedSlots and recipeIds before binding it; no slot or resource substitution is applied.";if(e==="PORTABLE_TEXTURE_REFERENCE")return'compilePortableMaterialSpecV2 textures require typed references: { kind: "resource", resourceId: "kiln.texture..." } for an approved resource, or { kind: "procedural", spec: { schemaVersion: 2, ... } } for a procedural texture. Bare resource ID strings are invalid here. Use portable slots such as baseColor and check the exact helper/resource contracts with kiln_discover.';if(e==="TAPER_CONE_AXIS")return'taperConeGeo(radiusBottom, radiusTop, height, axis, segments): the fourth argument is axis, "x", "y" or "z" (default "y"). Segment count is the fifth argument, for example taperConeGeo(0.03, 0.02, 0.01, "x", 12). Call kiln_discover for the full contract.';if(e==="PROCEDURAL_TEXTURE_BLEND")return'proceduralTexture layer blend must be normal, multiply, screen, or overlay. Omit blend for normal compositing. Call kiln_discover with ids ["proceduralTexture"] for the supported layer fields.';if(e==="PART_NAME_ARGUMENT")return"createPart(name, geometry, material, options?): the first argument is a string name. Put the parent Object3D in the fourth argument as { parent: root }.";if(e==="PART_GEOMETRY_ARGUMENT")return"createPart(name, geometry, material, options?): the second argument must be a BufferGeometry. Call geometry helpers, for example boxGeo(1, 1, 1), instead of passing the function. For async helpers such as roundedBoxGeo, extrudeProfile and revolveProfile, await the result inside async build() before passing it to createPart. Call kiln_discover for the exact return contract.";if(e==="PART_MATERIAL_ARGUMENT")return"createPart(name, geometry, material, options?): the third argument must be a Three.js material. Wrap a color with gameMaterial(0x808080); a number or settings object alone is not a material. Call kiln_discover for the chosen material helper contract.";if(e==="SOLID_FLOAT32_COLLAPSE")return"Solid output cannot retain valid faces at Float32 precision. Simplify subprecision features or recenter local geometry; review coincident cut boundaries. Smoothing or replacing normals does not repair collapsed triangles. Kiln did not export a partially repaired solid.";if(e==="PROFILE_BEVEL_COLLAPSE")return"extrudeProfile or revolveProfile: bevel is too large for this profile; erosion leaves nothing. Reduce bevel below half the narrowest section width, set bevel to 0, or widen the profile. Dimensions and bevel use the same asset units.";if(e==="TUBE_RADIUS")return"curveToMesh and pipeAlongPath require an explicit positive finite radius representable in Float32, in asset units. A missing or undefined radius is invalid; check the referenced dimension. Radius is half the tube diameter.";if(e==="MATERIAL_ALPHA_MODE")return'pbrMaterial and portable material specs require lowercase alphaMode: "opaque", "mask", or "blend". Omit it for opaque. Exported glTF uses uppercase mode names; those are not authoring input values.';if(e==="MATERIAL_COLOR_ARGUMENT")return"gameMaterial, basicMaterial, glassMaterial and lambertMaterial take a color first: a hex number or CSS string. Settings belong in the second argument, for example gameMaterial(0x9a9a96, { roughness: 0.4, metalness: 0.8 }). pbrMaterial uses a different object-form contract; call kiln_discover for its texture and material fields.";if(e==="MATERIAL_PACKED_CHANNELS")return'pbrMaterial requires one packed texture with G=roughness and B=metalness. Generate or load it for usage "metallicRoughness" and pass metallicRoughness, or pass the same packed texture in both roughness and metalness. Do not combine those forms or pass a texture in only one scalar slot. Plain roughness and metalness values are 0..1 numbers. Call kiln_discover for the exact texture contract.';if(e==="REMOVED_HELPER")return"Generated source references a retired Kiln global. Call kiln_validate for name-specific migration guidance, then kiln_discover for the replacement contract. No compatibility aliases are provided.";if(e==="UNBOUND_VARIABLE")return"Check variable spelling and scope: generated code used an undeclared variable. Read the current source and check declarations before retrying. If it was meant to be a Kiln helper, call kiln_discover to confirm the exact name and signature; the sandbox exposes only those globals.";if(e==="ROUNDED_BOX_RADIUS")return"roundedBoxGeo: radius must be less than half the smallest dimension. Reduce radius or increase the smallest dimension; equality is invalid.";if(e==="GEAR_RADII_ORDER")return"gearGeo requires boreRadius < rootRadius < tipRadius; specify rootRadius when changing tipRadius. Omitted radii keep their absolute defaults.";if(e==="PROCEDURAL_TEXTURE_UNKNOWN_KEY")return'Remove unsupported proceduralTexture fields. Call kiln_discover with ids ["proceduralTexture"] and use only the documented fields for the selected layer op.';if(e==="MATERIAL_FRACTION_RANGE")return"Material fractions must be finite numbers between 0 and 1, inclusive. In proceduralTexture, mortarWidth and stagger are fractions, not pixels; opacity uses the same range. materialRecipe roughness, metalness, opacity, alphaCutoff and emissiveIntensity use 0..1. portableMaterial roughness, metalness and alphaCutoff also use 0..1; its emissiveIntensity has a separate 0..64 range. Call kiln_discover for the exact field contracts.";if(e==="PROFILE_HOLES_UNSUPPORTED")return"loftProfiles and sweepProfile: holes are unsupported in options or sections. Use extrudeProfile for a holed cross-section with optional twist/taper; independently varying contours need explicit geometry or solid subtraction. cap:false does not create inner walls or thickness.";if(e==="PROFILE_CORRESPONDENCE_COLLAPSE")return"loftProfiles or sweepProfile: corresponding profile edges collapse between stations. Check matching start vertices and vertex order; for an intended twist, add intermediate sections or path stations. No automatic correspondence repair is applied. Other self-intersections remain unchecked.";return e==="PARAMETRIC_PERIODIC_ENDPOINT"?"Periodic parametricSurface endpoints must return matching positions. For periodicU, sample(uMin, v) and sample(uMax, v) must match; for periodicV, sample(u, vMin) and sample(u, vMax) must match.":""}class hf extends Error{diagnostic;constructor(e,t=K1(e)){super(t);this.diagnostic=e;this.name="AuthoringDiagnosticError"}}var wy=1024,Ey=4,Ty=8,J1=6,Ay=80,Lo=256;class St extends hf{constructor(e,t){super(t,e);this.name="ProceduralTextureError"}}var Ry=["solid","checker","stripes","gradient","bricks","noise"],Cy=["normal","multiply","screen","overlay"],Q1=new Set(["__proto__","prototype","constructor"]);function Dc(e,t){if(!e||typeof e!=="object"||Array.isArray(e))throw new St(`${t} must be a plain JSON object.`);let n=Object.getPrototypeOf(e);if(n!==Object.prototype&&n!==null)throw new St(`${t} must be a plain JSON object with no custom prototype.`);for(let i of Reflect.ownKeys(e)){if(typeof i!=="string")throw new St(`${t} must not contain symbol keys.`);if(Q1.has(i))throw new St(`${t} contains forbidden key ${JSON.stringify(i)}.`);if(!Object.prototype.propertyIsEnumerable.call(e,i))throw new St(`${t}.${i} must be an enumerable JSON field.`);let r=Object.getOwnPropertyDescriptor(e,i);if(!r||!("value"in r))throw new St(`${t}.${i} must be a plain JSON data field.`)}return e}function eR(e,t){if(!Array.isArray(e)||Object.getPrototypeOf(e)!==Array.prototype)throw new St(`${t} must be a plain JSON array.`);for(let n of Reflect.ownKeys(e)){if(typeof n!=="string")throw new St(`${t} must not contain symbol keys.`);if(n==="length")continue;if(!/^(0|[1-9][0-9]*)$/.test(n)||Number(n)>=e.length)throw new St(`${t} has non-index JSON array key ${JSON.stringify(n)}.`)}for(let n=0;n<e.length;n++)if(!Object.hasOwn(e,n))throw new St(`${t} must be a dense JSON array (missing index ${n}).`);return e}function ur(e,t,n){let i=new Set(t);for(let r of Object.keys(e))if(!i.has(r))throw new St(`${n} has unknown key ${JSON.stringify(r)}.`,"PROCEDURAL_TEXTURE_UNKNOWN_KEY")}function Xn(e,t,n){if(typeof e!=="number"||!Number.isInteger(e)||e<0||e>16777215)throw new St(`${t} must be a color integer between 0x000000 and 0xffffff, got ${JSON.stringify(e)}.`,n);return e}function Ur(e,t,n,i,r){if(e===void 0)return n;if(typeof e!=="number"||!Number.isInteger(e)||e<i||e>r)throw new St(`${t} must be a whole number between ${i} and ${r}, got ${JSON.stringify(e)}.`);return e}function Iy(e,t,n,i,r,s){if(e===void 0)return n;if(typeof e!=="number"||!Number.isFinite(e)||e<i||e>r)throw new St(`${t} must be a finite number between ${i} and ${r}, got ${JSON.stringify(e)}.`,s);return e}function ff(e,t,n){return Iy(e,t,n,0,1,"MATERIAL_FRACTION_RANGE")}function tR(e,t){if(e===void 0)return;let n=typeof e==="string"&&[...e].some((i)=>{let r=i.charCodeAt(0);return r<32||r===127});if(typeof e!=="string"||e.length===0||e.length>Ay||n)throw new St(`${t} must be 1..${Ay} visible characters.`);return e}function nR(e,t,n){if(e===void 0)return n;if(!uf.includes(e))throw new St(`${t} must be one of ${uf.join(", ")}, got ${JSON.stringify(e)}.`);return e}function Py(e,t){let i=(Iy(e,t,0,-36000,36000)%360+360)%360;return Object.is(i,-0)?0:i}function iR(e,t){let n=e.blend??"normal";if(!Cy.includes(n))throw new St(`${t}.blend ${JSON.stringify(n)} is not one of ${Cy.join(", ")}.`,"PROCEDURAL_TEXTURE_BLEND");return n}function rR(e,t){let n=`proceduralTexture.layers[${t}]`,i=Dc(e,n),r=i.op;if(!Ry.includes(r))throw new St(`${n}.op ${JSON.stringify(r)} is not one of ${Ry.join(", ")}.`);let s=iR(i,n),o=ff(i.opacity,`${n}.opacity`,1),a={blend:t===0?"normal":s,opacity:t===0?1:o};switch(r){case"solid":return ur(i,["op","color","blend","opacity"],n),{op:r,color:Xn(i.color,`${n}.color`),...a};case"checker":return ur(i,["op","colorA","colorB","squares","blend","opacity"],n),{op:r,colorA:Xn(i.colorA,`${n}.colorA`),colorB:Xn(i.colorB,`${n}.colorB`),squares:Ur(i.squares,`${n}.squares`,8,1,Lo),...a};case"stripes":return ur(i,["op","colorA","colorB","count","angleDeg","blend","opacity"],n),{op:r,colorA:Xn(i.colorA,`${n}.colorA`),colorB:Xn(i.colorB,`${n}.colorB`),count:Ur(i.count,`${n}.count`,8,1,Lo),angleDeg:Py(i.angleDeg,`${n}.angleDeg`),...a};case"gradient":return ur(i,["op","from","to","angleDeg","blend","opacity"],n),{op:r,from:Xn(i.from,`${n}.from`),to:Xn(i.to,`${n}.to`),angleDeg:Py(i.angleDeg,`${n}.angleDeg`),...a};case"bricks":return ur(i,["op","brick","mortar","rows","cols","mortarWidth","stagger","blend","opacity"],n),{op:r,brick:Xn(i.brick,`${n}.brick`),mortar:Xn(i.mortar,`${n}.mortar`),rows:Ur(i.rows,`${n}.rows`,8,1,Lo),cols:Ur(i.cols,`${n}.cols`,4,1,Lo),mortarWidth:ff(i.mortarWidth,`${n}.mortarWidth`,0.06),stagger:ff(i.stagger,`${n}.stagger`,0.5),...a};case"noise":return ur(i,["op","colorA","colorB","scale","octaves","seed","blend","opacity"],n),{op:r,colorA:Xn(i.colorA,`${n}.colorA`),colorB:Xn(i.colorB,`${n}.colorB`),scale:Ur(i.scale,`${n}.scale`,8,1,Lo),octaves:Ur(i.octaves,`${n}.octaves`,3,1,J1),seed:Ur(i.seed,`${n}.seed`,0,-2147483648,2147483647),...a};default:throw new St(`${n}.op is unsupported.`)}}function sR(e){let t=Dc(e,"proceduralTexture");if(ur(t,["schemaVersion","size","usage","name","layers"],"proceduralTexture"),t.schemaVersion!==void 0&&t.schemaVersion!==1)throw new St(`proceduralTexture.schemaVersion must be 1 or absent for V1 migration, got ${JSON.stringify(t.schemaVersion)}.`);return{schemaVersion:2,...t.size!==void 0?{size:t.size}:{},...t.usage!==void 0?{usage:t.usage}:{},...t.name!==void 0?{name:t.name}:{},layers:t.layers}}function Ly(e){let t=Dc(e,"proceduralTexture"),n=t.schemaVersion===void 0||t.schemaVersion===1?Dc(sR(t),"proceduralTexture"):t;if(ur(n,["schemaVersion","size","usage","name","layers"],"proceduralTexture"),n.schemaVersion!==2)throw new St(`proceduralTexture.schemaVersion must be 2, got ${JSON.stringify(n.schemaVersion)}.`);let i=n.size??256;if(typeof i!=="number"||!Number.isInteger(i)||i<Ey||i>wy||(i&i-1)!==0)throw new St(`proceduralTexture.size must be a power of two between ${Ey} and ${wy}, got ${JSON.stringify(n.size)}.`);let r=n.layers;if(!Array.isArray(r)||r.length===0)throw new St("proceduralTexture.layers must be a non-empty array — the bottom layer is the base pattern.");let s=eR(r,"proceduralTexture.layers");if(s.length>Ty)throw new St(`proceduralTexture: ${s.length} layers exceeds the maximum of ${Ty}.`);let o=tR(n.name,"proceduralTexture.name");return{schemaVersion:2,size:i,usage:nR(n.usage,"proceduralTexture.usage","albedo"),...o!==void 0?{name:o}:{},layers:s.map(rR)}}var wD=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);var jn=Object.freeze({maxMapBytes:8388608,maxRecordBytes:33554432,maxManifestBytes:262144,maxMapEdge:4096,maxRecordPixels:8388608,maxPayloadBytes:16777216,maxPayloadPixels:16777216,maxPayloadRecords:16}),Dy=["baseColor","normal","metallicRoughness","emissive","occlusion"],oR={baseColor:"albedo",normal:"normal",metallicRoughness:"metallicRoughness",emissive:"emissive",occlusion:"occlusion"};var Do=Je().regex(/^[a-z][a-z0-9_-]{0,79}$/),Oo=Je().regex(/^sha256:[a-f0-9]{64}$/),hr=Je().min(1).max(1000),Ny=Je().max(2000).url().refine((e)=>/^https?:\/\//.test(e),"Provenance URL must be HTTP(S)"),Oy=ft({id:Do,kind:Dn(["external","procedural"]),provider:hr,creator:hr,assetId:hr.optional(),assetUrl:Ny.optional(),accessedAt:Je().datetime().optional(),license:ft({spdx:hr,url:Ny,attribution:Je().max(4000)}).strict(),originalFiles:an(ft({name:Je().min(1).max(200),sha256:Oo,bytes:mt().int().positive().max(1073741824)}).strict()).max(20)}).strict().superRefine((e,t)=>{if(e.kind==="external"&&(!e.assetUrl||!e.originalFiles.length))t.addIssue({code:"custom",message:"External materials require a source URL and original file hashes"});if(new Set(e.originalFiles.map((n)=>n.name)).size!==e.originalFiles.length)t.addIssue({code:"custom",message:"Duplicate original filename"})}),Uy=ft({operation:hr,tool:hr,version:hr,parameters:Ic(Je().max(100),ey([Je().max(2000),mt().finite(),Ro()])).optional()}).strict(),qn=mt().int().min(0).max(16777215),No=mt().int().min(1).max(256),As={blend:Dn(["normal","multiply","screen","overlay"]).default("normal"),opacity:mt().min(0).max(1).default(1)},Fy=ft({schemaVersion:qt(2),size:mt().int().min(4).max(1024).default(256),usage:Dn(["albedo","normal","roughness","metalness","metallicRoughness","emissive","occlusion"]).default("albedo"),name:Je().min(1).max(80).optional(),layers:an(m1("op",[ft({op:qt("solid"),color:qn,...As}).strict(),ft({op:qt("checker"),colorA:qn,colorB:qn,squares:No.default(8),...As}).strict(),ft({op:qt("stripes"),colorA:qn,colorB:qn,count:No.default(8),angleDeg:mt().min(-36000).max(36000).default(0),...As}).strict(),ft({op:qt("gradient"),from:qn,to:qn,angleDeg:mt().min(-36000).max(36000).default(0),...As}).strict(),ft({op:qt("bricks"),brick:qn,mortar:qn,rows:No.default(8),cols:No.default(4),mortarWidth:mt().min(0).max(1).default(0.06),stagger:mt().min(0).max(1).default(0.5),...As}).strict(),ft({op:qt("noise"),colorA:qn,colorB:qn,scale:No.default(8),octaves:mt().int().min(1).max(6).default(3),seed:mt().int().min(-2147483648).max(2147483647).default(0),...As}).strict()])).min(1).max(8)}).strict(),zy=ft({kind:qt("normal-from-height"),strength:mt().finite().positive().max(64)}).strict(),aR=ft({compiler:qt("kiln.procedural-texture.v2"),spec:Fy,derive:zy.optional(),recipeHash:Oo,pixelHash:Oo,encoder:ft({name:qt("sharp"),version:hr}).strict()}).strict(),ky=ft({baseColor:mt().int().min(0).max(16777215).optional(),roughness:mt().min(0).max(1).default(1),metalness:mt().min(0).max(1).default(0),emissive:mt().int().min(0).max(16777215).optional(),emissiveIntensity:mt().min(0).max(64).default(1),alphaMode:Dn(["opaque","mask","blend"]).default("opaque"),alphaCutoff:mt().min(0).max(1).default(0.5),doubleSided:Ro().default(!1)}).strict(),By=ft({schemaVersion:qt(1),materialId:Do,revisionId:Oo,name:Je().min(1).max(200),tags:an(Je().min(1).max(80)).max(30),tileable:Ro(),physicalSizeMeters:ft({width:mt().finite().positive().max(1e5),height:mt().finite().positive().max(1e5)}).strict().optional(),parameters:ky,sources:an(Oy).min(1).max(20),maps:an(ft({slot:Dn(Dy),file:Dn(["baseColor.png","normal.png","metallicRoughness.png","emissive.png","occlusion.png"]),sha256:Oo,bytes:mt().int().positive().max(jn.maxMapBytes),width:mt().int().positive().max(jn.maxMapEdge),height:mt().int().positive().max(jn.maxMapEdge),usage:Dn(["albedo","normal","metallicRoughness","emissive","occlusion"]),colorSpace:Dn(["srgb","linear"]),normalConvention:qt("opengl").optional(),channelPacking:qt("r-occlusion-g-roughness-b-metallic").optional(),sourceId:Do,originalFile:Je().min(1).max(200).optional(),transforms:an(Uy).max(30),procedural:aR.optional()}).strict()).min(1).max(5)}).strict(),RD=ft({materialId:Do,name:Je().min(1).max(200),tags:an(Je().min(1).max(80)).max(30).optional(),tileable:Ro(),physicalSizeMeters:ft({width:mt().finite().positive().max(1e5),height:mt().finite().positive().max(1e5)}).strict().optional(),parameters:ky.partial().optional(),sources:an(Oy).min(1).max(20),maps:an(ft({slot:Dn(Dy),sourceId:Do,transforms:an(Uy).max(30),normalConvention:qt("opengl").optional(),channelPacking:qt("r-occlusion-g-roughness-b-metallic").optional(),procedural:Fy,derive:zy.optional()}).strict()).min(1).max(5)}).strict(),Gy=ft({schemaVersion:qt(1),records:an(ft({manifest:By,files:Ic(Je().regex(/^(baseColor|normal|metallicRoughness|emissive|occlusion)\.png$/),Je().max(Math.ceil(jn.maxMapBytes/3)*4))}).strict()).max(jn.maxPayloadRecords)}).strict();function Fo(e,t=!1,n=0){if(n>30)throw Error("Material JSON exceeds nesting limit");if(e===null||typeof e==="string"||typeof e==="boolean")return;if(typeof e==="number"&&Number.isFinite(e))return;if(t&&e instanceof Uint8Array)return;if(!e||typeof e!=="object")throw Error("Material values must be plain JSON data");let i=Array.isArray(e),r=Object.getPrototypeOf(e);if(i?r!==Array.prototype:r!==Object.prototype&&r!==null)throw Error("Material values must have plain JSON prototypes");if(i&&e.length>1e4)throw Error("Material JSON array exceeds limit");for(let s of Reflect.ownKeys(e)){if(i&&s==="length")continue;if(typeof s!=="string"||["__proto__","prototype","constructor"].includes(s))throw Error("Material JSON contains a forbidden key");if(i&&(!/^(0|[1-9][0-9]*)$/.test(s)||Number(s)>=e.length))throw Error("Material arrays must contain only indexed data");let o=Object.getOwnPropertyDescriptor(e,s);if(!("value"in o)||!o.enumerable)throw Error("Material JSON accessors or hidden fields are not allowed");Fo(o.value,t,n+1)}if(i&&Object.keys(e).length!==e.length)throw Error("Material JSON arrays must be dense")}function Uo(e){Fo(e);let t=(n)=>Array.isArray(n)?n.map(t):n!==null&&typeof n==="object"?Object.fromEntries(Object.entries(n).sort(([i],[r])=>i<r?-1:i>r?1:0).map(([i,r])=>[i,t(r)])):n;return JSON.stringify(t(e))}function Hy(e){if(Fo(e),new TextEncoder().encode(JSON.stringify(e)).length>jn.maxManifestBytes)throw Error("Material manifest exceeds size limit");let t=By.parse(e);if(new Set(t.sources.map((r)=>r.id)).size!==t.sources.length)throw Error("Duplicate material source identity");if(new Set(t.maps.map((r)=>r.slot)).size!==t.maps.length)throw Error("Duplicate material map slot");let n=0,i=0;for(let r of t.maps){let s=r.slot==="baseColor"||r.slot==="emissive";if(r.file!==`${r.slot}.png`||r.usage!==oR[r.slot]||r.colorSpace!==(s?"srgb":"linear"))throw Error("Material map filename, usage or color convention mismatch");if(r.slot==="normal"!==(r.normalConvention==="opengl")||r.slot==="metallicRoughness"!==(r.channelPacking==="r-occlusion-g-roughness-b-metallic"))throw Error("Material map convention is missing or invalid");let o=t.sources.find((a)=>a.id===r.sourceId);if(!o)throw Error("Material map source is missing");if(r.procedural){if(r.procedural.derive&&r.slot!=="normal")throw Error("Height derivation requires a normal map slot");if(Uo(r.procedural.spec)!==Uo(Ly(r.procedural.spec)))throw Error("Stored procedural material recipe must be canonical");if(o.kind!=="procedural"||r.originalFile||r.procedural.spec.usage!==r.usage||r.procedural.spec.size!==r.width||r.width!==r.height)throw Error("Procedural material source or map convention mismatch")}else if(o.kind!=="external"||!o.originalFiles.some((a)=>a.name===r.originalFile))throw Error("Material map must reference an original source file");n+=r.bytes,i+=r.width*r.height}if(n>jn.maxRecordBytes||i>jn.maxRecordPixels)throw Error("Material record exceeds byte or pixel budget");return t}var Oc=67108864,df=Je().regex(/^[a-z][a-z0-9_-]{0,79}$/),cR=Je().regex(/^sha256:[a-f0-9]{64}$/),pf=ft({version:qt("kiln.asset.v1"),assetId:df,revisionId:df,parentRevision:df.optional(),name:Je().min(1).max(200),tags:an(Je().max(80)).max(30),createdAt:Je().datetime(),description:Je().max(4000).optional(),brief:Je().max(8000).optional(),attribution:ft({model:Je().max(200).optional(),harness:Je().max(200).optional(),author:Je().max(200).optional()}).optional(),editable:Ro(),files:Ic(Je(),ft({sha256:cR,bytes:mt().int().nonnegative().max(Oc)})),build:ft({engine:Je(),options:Ic(Je(),Or()),warnings:an(Je()),integration:Or().optional(),qa:Or().optional(),dependencies:an(Or()).optional(),rebuild:Dn(["engine-required","external-dependencies-required"])}).optional(),preview:ft({fidelity:Or().optional(),error:Je().optional(),backdrop:Dn(sy).optional()}).optional()}),lR="materials.kiln.json",uR=25165824;function Vy(e,t=!1){let n=(e.manifest.build?.dependencies??[]).filter((c)=>c&&typeof c==="object"&&c.kind==="kiln.material.v1"),i=new Map(n.map((c)=>{if(c.delivery!=="runtime")throw Error("Invalid saved material dependency");let l=Hy(c.manifest);return[`${l.materialId}/${l.revisionId}`,Uo(l)]}));if(!e.materialResources){if(t&&i.size)throw Error("Editable asset material closure unavailable");return}Fo(e.materialResources);let r=Gy.parse(e.materialResources),s=0,o=0,a=new Set;for(let c of r.records){let l=`${c.manifest.materialId}/${c.manifest.revisionId}`;if(a.has(l)||i.get(l)!==Uo(c.manifest))throw Error("Asset material closure mismatch");if(a.add(l),Object.keys(c.files).length!==c.manifest.maps.length)throw Error("Asset material map inventory mismatch");for(let u of c.manifest.maps){if(c.files[u.file]?.length!==Math.ceil(u.bytes/3)*4)throw Error("Asset material map size mismatch");s+=u.bytes,o+=u.width*u.height}}if(a.size!==i.size)throw Error("Asset material closure incomplete");if(s>jn.maxPayloadBytes||o>jn.maxPayloadPixels)throw Error("Asset material closure exceeds allocation limits")}var hR=new Set(["asset.glb","source.kiln.js","preview.png"]);function fR(e){let t=pf.parse(e.manifest),n=Object.keys(e.files);if(n.length!==Object.keys(t.files).length||!n.includes("asset.glb"))throw Error("Asset file inventory mismatch");let i=0;for(let r of n){if(!hR.has(r)||!t.files[r]||t.files[r].bytes!==e.files[r].length)throw Error("Invalid asset file inventory");i+=e.files[r].length}if(i>Oc||t.editable!==n.includes("source.kiln.js"))throw Error("Invalid asset size or source inventory");if((e.files["source.kiln.js"]?.length??0)>1048576)throw Error("Source exceeds 1 MiB");mf(e.files["asset.glb"]),Vy(e)}function mf(e){if(e.length<20||e.length>Oc)throw Error("Invalid GLB size");let t=new DataView(e.buffer,e.byteOffset,e.byteLength);if(t.getUint32(0,!0)!==1179937895||t.getUint32(4,!0)!==2||t.getUint32(8,!0)!==e.length||t.getUint32(16,!0)!==1313821514)throw Error("Invalid GLB header");let n=20+t.getUint32(12,!0);if(n>e.length)throw Error("Invalid GLB JSON length");let i=JSON.parse(new TextDecoder().decode(e.subarray(20,n)));for(let r of[...i.buffers??[],...i.images??[]])if(r.uri&&!String(r.uri).startsWith("data:"))throw Error("GLB must embed its resources")}function $y(e){if(!e.length||e.length>100)throw Error("Bundle requires 1..100 revisions");let t={},n=0;for(let i of e){fR(i),Vy(i,!0);let r=`${i.manifest.assetId}/${i.manifest.revisionId}/`;if(t[`${r}manifest.json`])throw Error("Duplicate bundle revision");t[`${r}manifest.json`]=new TextEncoder().encode(JSON.stringify(i.manifest,null,2));for(let[s,o]of Object.entries(i.files))t[r+s]=o;if(i.materialResources){let s=new TextEncoder().encode(JSON.stringify(i.materialResources));if(s.length>uR)throw Error("Asset material payload exceeds byte limit");t[r+lR]=s}}for(let i of Object.values(t))n+=i.length;if(n>Oc)throw Error("Bundle exceeds 64 MiB");return My(t,{level:0})}function Wy(e,t,n=40,i=[e]){let r=e.getCenter(new D),s=Math.max(e.getSize(new D).length()/2,0.01),o=new D(1,0.65,1.25).normalize(),a=new D().crossVectors(new D(0,1,0),o).normalize(),c=new D().crossVectors(o,a),l=[];for(let E of i.length?i:[e])for(let R of[E.min.x,E.max.x])for(let v of[E.min.y,E.max.y])for(let M of[E.min.z,E.max.z])l.push(new D(R,v,M));let u=1/0,f=-1/0,h=1/0,d=-1/0;for(let E of l){let R=E.clone().sub(r),v=R.dot(a),M=R.dot(c);u=Math.min(u,v),f=Math.max(f,v),h=Math.min(h,M),d=Math.max(d,M)}r.addScaledVector(a,(u+f)/2),r.addScaledVector(c,(h+d)/2);let g=Math.tan(n*Math.PI/360),x=g*t,p=s;for(let E of l){let R=E.clone().sub(r),v=R.dot(o);p=Math.max(p,v+Math.abs(R.dot(a))*1.12/x,v+Math.abs(R.dot(c))*1.12/g)}let m=r.clone().addScaledVector(o,p);return{center:r,radius:s,distance:p,position:m}}function gf(e,t){return{position:e.position.clone(),target:t.clone()}}function _f(e,t,n,i){e.position.copy(n.position),t.copy(n.target);let r=Math.max(i.getSize(new D).length(),0.001);e.near=Math.min(0.01,Math.max(r/1e5,0.00001)),e.far=Math.max(e.position.distanceTo(i.getCenter(new D))+r*20,10),e.updateProjectionMatrix()}function Zy(e,t,n){let i=e.getWorldDirection(new D);if(i.y=0,i.lengthSq()<0.00000001)i.set(0,0,-1);i.normalize();let r=i.clone().cross(new D(0,1,0)),s=new D;if(t.has("KeyW")||t.has("ArrowUp"))s.add(i);if(t.has("KeyS")||t.has("ArrowDown"))s.sub(i);if(t.has("KeyD")||t.has("ArrowRight"))s.add(r);if(t.has("KeyA")||t.has("ArrowLeft"))s.sub(r);if(t.has("KeyE"))s.y++;if(t.has("KeyQ"))s.y--;return s.normalize().multiplyScalar(n)}function Xy(e){let t=e.filter((i)=>Number.isFinite(i)&&i>0).sort((i,r)=>i-r);if(!t.length)throw Error("No frame timing evidence was collected.");let n=(i)=>t[Math.max(0,Math.ceil(t.length*i)-1)];return{samples:t.length,min:t[0],p50:n(0.5),p95:n(0.95),max:t.at(-1)}}function qy(e,t,n){if(t())return e;n(e);return}function Uc(e,t){let n=e.parser.json.nodes??[],i=new Set;if(n.forEach((s,o)=>{if(s?.extensions?.KHR_node_visibility?.visible===!1)i.add(o)}),i.size===0)return 0;let r=0;for(let s of t)s.traverse((o)=>{let a=e.parser.associations.get(o)?.nodes;if(a===void 0||!i.has(a))return;o.visible=!1,r++});return r}function Fc(e){let t=!1;if(e.traverse((s)=>{if(!s.visible)t=!0}),!t)return new Ft().setFromObject(e,!0);e.updateWorldMatrix(!0,!0);let n=new Ft,i=new Ft,r=new D;return e.traverseVisible((s)=>{let o=s,a=o.geometry;if(!a)return;let c=a.getAttribute("position");if(c&&o.isInstancedMesh!==!0){for(let u=0;u<c.count;u++){if(o.isMesh)o.getVertexPosition(u,r);else r.fromBufferAttribute(c,u);n.expandByPoint(r.applyMatrix4(s.matrixWorld))}return}let l=s;if(l.boundingBox!==void 0){if(l.boundingBox===null)l.computeBoundingBox();i.copy(l.boundingBox)}else{if(a.boundingBox===null)a.computeBoundingBox();i.copy(a.boundingBox)}n.union(i.applyMatrix4(s.matrixWorld))}),n.isEmpty()?new Ft().setFromObject(e,!0):n}function zo(e){let t=0;return e.traverseVisible((n)=>{let i=n;if(!i.isMesh)return;let r=i.geometry.index?.count??i.geometry.attributes.position?.count??0;t+=r/3*(i.isInstancedMesh?i.count:1)}),t}async function jy(e){let t=e.parser.json.nodes??[],n=new Map;e.scene.traverse((c)=>{let l=e.parser.associations.get(c)?.nodes;if(l!==void 0&&!n.has(l))n.set(l,c)});let i=new Set,r=[];for(let[c,l]of n){let u=t[c]?.extensions?.MSFT_lod?.ids;if(!Array.isArray(u)||u.length===0)continue;if(u.some((g)=>!Number.isInteger(g)||!t[g]||n.has(g)))continue;let f=l.parent;while(f&&!i.has(f))f=f.parent;if(f)continue;let h=[l];for(let g of u)h.push(await e.parser.getDependency("node",g));Uc(e,h.slice(1)),i.add(l);let d=(l.name.replace(/[_ -]?LOD0$/i,"")||l.parent?.name||`Part ${c}`).replace(/^Mesh_/,"");r.push({id:String(c),label:d,levels:h})}if(r.length===0)return;let s=zo(e.scene)-r.reduce((c,l)=>c+xf(l,0),0),o=Math.max(...r.map((c)=>c.levels.length)),a=Array.from({length:o},(c,l)=>s+r.reduce((u,f)=>u+xf(f,l),0));return{chains:r,triangles:a}}var Yy=(e,t)=>e.levels[Math.min(Math.max(Number.isFinite(t)?Math.floor(t):0,0),e.levels.length-1)];function xf(e,t){let n=e.levels.find((i)=>i.parent)?.parent;while(n){if(!n.visible)return 0;n=n.parent}return zo(Yy(e,t))}function Ky(e,t){let n=Yy(e,t),i=e.levels.find((s)=>s.parent!==null);if(!i||i===n)return;let r=i.parent;r.children[r.children.indexOf(i)]=n,n.parent=r,i.parent=null}function Jy(e,t){for(let n of e.chains)Ky(n,t)}function Qy(e,t,n){let i=e.chains.find((r)=>r.id===t);if(!i)return!1;return Ky(i,n),!0}function ev(e,t){if(!e)return;return{triangles:zo(t),levels:e.triangles,chains:e.chains.map((n)=>({id:n.id,label:n.label,level:n.levels.findIndex((i)=>i.parent!==null),triangles:n.levels.map((i,r)=>xf(n,r))}))}}function ko(e){return(e?.chains??[]).flatMap((t)=>t.levels.filter((n)=>n.parent===null))}function tv(e){let t=new Hu({antialias:!0,alpha:!1});t.setPixelRatio(Math.min(devicePixelRatio,2)),t.setClearColor(1382930),t.toneMapping=Gs,t.toneMappingExposure=1.15,e.replaceChildren(t.domElement);let n=new hs,i=new Ut(40,1,0.01,1000),r=new eh(i,t.domElement);r.enableDamping=!0,t.domElement.tabIndex=0,t.domElement.setAttribute("aria-label","Interactive 3D asset. Drag to orbit or use Explore navigation.");let s=new Set,o=!1,a=1,c=new Set(["KeyW","KeyA","KeyS","KeyD","KeyQ","KeyE","ArrowUp","ArrowDown","ArrowLeft","ArrowRight","ShiftLeft","ShiftRight"]),l=(H)=>{if(!o||!c.has(H.code))return;H.preventDefault(),s.add(H.code)},u=(H)=>s.delete(H.code),f=()=>s.clear();t.domElement.addEventListener("keydown",l),t.domElement.addEventListener("keyup",u),t.domElement.addEventListener("blur",f);let h=new uo(t),d=new th,g=h.fromScene(d,0.04);n.environment=g.texture,d.dispose(),h.dispose();let x=new _s(16773591,2.4);x.position.set(4,8,5),n.add(x),n.add(new $a(14806490,5065021,1.7));let p,m,E,R=[],v=!0,M=performance.now(),T=0,A=0,_=!1,S,k,C,U=(H)=>{if(!C)return;clearTimeout(C.timeout),C.reject(Error(H)),C=void 0},ee=(H)=>{let F=t.getContext(),q=F.getExtension("WEBGL_debug_renderer_info");return{version:"kiln.viewer-performance.v1",measuredAt:new Date().toISOString(),windowMs:H-C.started,frameMs:Xy(C.samples),...k===void 0?{}:{loadToFirstFrameMs:k},drawCalls:t.info.render.calls,triangles:t.info.render.triangles,lines:t.info.render.lines,points:t.info.render.points,geometryObjects:t.info.memory.geometries,textureObjects:t.info.memory.textures,shaderPrograms:t.info.programs?.length??0,viewport:{cssWidth:e.clientWidth,cssHeight:e.clientHeight,bufferWidth:t.domElement.width,bufferHeight:t.domElement.height,devicePixelRatio:t.getPixelRatio()},renderer:{version:String(F.getParameter(F.VERSION)),vendor:String(F.getParameter(F.VENDOR)),renderer:String(F.getParameter(F.RENDERER)),browser:navigator.userAgent,...q?{unmaskedVendor:String(F.getParameter(q.UNMASKED_VENDOR_WEBGL)),unmaskedRenderer:String(F.getParameter(q.UNMASKED_RENDERER_WEBGL))}:{}},camera:{position:i.position.toArray(),target:r.target.toArray(),fov:i.fov},limitations:["Exploratory measurement: workloads outside this page are uncontrolled. This is not an isolated performance baseline or budget acceptance.","Frame intervals measure browser requestAnimationFrame pacing, including scheduling and vertical sync; they are not GPU execution time.","Load-to-first-frame begins at GLB parsing and ends after the first render submission; it excludes download time and does not measure presentation latency.","Draw and resource counts come from this Three.js renderer, including studio lighting resources. Object counts are not GPU memory bytes.","This receipt describes this viewport, camera and device only. It is not a performance qualification for other consumers or hardware."]}},P=(H)=>{let F=new Set,q=new Set,K=new Set;H.traverse((xe)=>{let ce=xe;if(!ce.isMesh)return;F.add(ce.geometry);for(let De of Array.isArray(ce.material)?ce.material:[ce.material]){q.add(De);for(let ye of Object.values(De))if(ye instanceof At)K.add(ye)}});for(let xe of[...F,...q,...K])xe.dispose()},V=()=>{if(!p)return;let H=Fc(p),F=[];p.traverseVisible((De)=>{if(De instanceof xt||De instanceof Ki||De instanceof ps){let ye=new Ft().setFromObject(De,!0);if(!ye.isEmpty())F.push(ye)}});let{center:q,radius:K,distance:xe,position:ce}=Wy(H,i.aspect,i.fov,F);if(r.target.copy(q),i.position.copy(ce),i.near=Math.max(K/1000,0.0001),i.far=xe+K*100,r.minDistance=K*0.1,r.maxDistance=K*80,a=Math.max(K*0.35,0.01),o)r.minDistance=K*0.00001;i.updateProjectionMatrix(),r.update()},j=new ResizeObserver(()=>{let{clientWidth:H,clientHeight:F}=e;if(!H||!F)return;t.setSize(H,F),i.aspect=H/F,i.updateProjectionMatrix()});j.observe(e);let z=(H)=>{if(_)return;let F=Math.min((H-M)/1000,0.1);if(M=H,e.clientWidth&&e.clientHeight){if(v)E?.update(F);if(o&&s.size){let q=Zy(i,s,F*a*(s.has("ShiftLeft")||s.has("ShiftRight")?3:1));i.position.add(q),r.target.add(q)}if(r.update(),t.render(n,i),S!==void 0)k=performance.now()-S,S=void 0;if(C){if(C.previous>0&&C.samples.length<1800)C.samples.push(H-C.previous);if(C.previous=H,H-C.started>=C.duration&&C.samples.length){let q=ee(H);clearTimeout(C.timeout),C.resolve(q),C=void 0}}}else s.clear(),U("Keep the measured viewport visible for the complete sampling window.");T=requestAnimationFrame(z)};return T=requestAnimationFrame(z),{async load(H,F={}){let q=performance.now(),K=++A;U("The artifact changed during measurement. Measure the new revision again."),mf(H);let xe=new no;xe.setURLModifier((_e)=>{if(!_e.startsWith("blob:")&&!_e.startsWith("data:"))throw Error("External model resources are not loaded");return _e});let ce=await new Yu(xe).parseAsync(Uint8Array.from(H).buffer,"");Uc(ce,[ce.scene]);let De=await jy(ce),ye=qy(ce,()=>!_&&K===A&&F.isCurrent?.()!==!1,(_e)=>{P(_e.scene);for(let Qe of ko(De))P(Qe)});if(!ye)return;let X=p&&F.preserveView?gf(i,r.target):void 0;if(p){E?.stopAllAction(),E?.uncacheRoot(p),n.remove(p),P(p);for(let _e of ko(m))P(_e)}p=ye.scene,m=De,S=q,k=void 0,n.add(p),R=ye.animations,E=new qa(p),v=!0;let{clientWidth:re,clientHeight:se}=e;if(t.setSize(re,se),i.aspect=re&&se?re/se:i.aspect,V(),X)_f(i,r.target,X,Fc(p)),r.update();let Te=0,Ie=new Set;return p.traverseVisible((_e)=>{let Qe=_e;if(!Qe.isMesh)return;Te++;for(let ze of Array.isArray(Qe.material)?Qe.material:[Qe.material])Ie.add(ze)}),F.onCommit?.(),{triangles:zo(p),meshes:Te,materials:Ie.size,clips:R.map((_e)=>_e.name),...m?{levels:m.triangles}:{}}},level(H){if(U("The level of detail changed. Measure the displayed combination again."),m)Jy(m,H)},partLevel(H,F){if(U("The level of detail changed. Measure the displayed combination again."),m)Qy(m,H,F)},lod(){return p?ev(m,p):void 0},reset:V,cancelMeasurement:U,measure(H=3000){if(_||!p||!e.clientWidth||!e.clientHeight)return Promise.reject(Error("Load an artifact in a visible viewport before measuring."));if(!Number.isFinite(H)||H<1000||H>5000)return Promise.reject(Error("Measurement duration must be 1–5 seconds."));if(C)return Promise.reject(Error("A measurement is already running."));return new Promise((F,q)=>{C={started:performance.now(),previous:0,duration:H,samples:[],resolve:F,reject:q,timeout:setTimeout(()=>U("Measurement was interrupted or the browser stopped delivering frames."),H+2000)}})},view(){return gf(i,r.target)},setView(H){if(!p)return;_f(i,r.target,H,Fc(p)),r.update()},navigation(H){if(o=H==="explore",s.clear(),r.minDistance=o?0.00001:a/3.5,o)i.near=0.0001,i.updateProjectionMatrix()},wire(H){for(let F of p?[p,...ko(m)]:[])F.traverse((q)=>{let K=q;if(K.isMesh){for(let xe of Array.isArray(K.material)?K.material:[K.material])if("wireframe"in xe)xe.wireframe=H}})},lighting(H){t.toneMappingExposure=H==="bright"?1.65:H==="soft"?0.85:1.15,x.intensity=H==="soft"?0.8:2.4},clip(H){if(E?.stopAllAction(),R[H])E?.clipAction(R[H]).play()},pause(H){v=!H},dispose(){if(U("The viewport closed before measurement finished."),_=!0,A++,cancelAnimationFrame(T),j.disconnect(),r.dispose(),t.domElement.removeEventListener("keydown",l),t.domElement.removeEventListener("keyup",u),t.domElement.removeEventListener("blur",f),p)P(p);for(let H of ko(m))P(H);g.dispose(),t.dispose(),e.replaceChildren()}}}var nv=["127.0.0.1","localhost","[::1]"];async function iv(e,t,n,i,r,s){let o="";for(let a=0;a<e.length;a+=8192)o+=String.fromCharCode(...e.subarray(a,a+8192));try{if((await i("ui/download-file",{contents:[{type:"resource",resource:{uri:`file:///${t}`,mimeType:n,blob:btoa(o)}}]}))?.isError)throw Error("The chat host could not download this file.");return{}}catch(a){if(a.code!==-32601)throw a;if(s){let f=new URL(s);if(f.protocol!=="https:"&&!(f.protocol==="http:"&&nv.includes(f.hostname)))throw Error("Invalid host download URL");return{downloadUrl:f.href}}if(!r)throw a;let c=new File([Uint8Array.from(e)],t,{type:n}),{fileId:l}=await r.uploadFile(c),{downloadUrl:u}=await r.getFileDownloadUrl({fileId:l});if(new URL(u).protocol!=="https:")throw Error("Invalid host download URL");return{downloadUrl:u}}}var sv=16777216,ov=Math.ceil(sv/3)*4,Wt=(e)=>{throw Error(`Asset transfer ${e}. Present the saved asset again or open it in Kiln; the saved files are unchanged.`)};function dR(e){let t="";for(let n=0;n<e.length;n+=8192)t+=String.fromCharCode(...e.subarray(n,n+8192));return btoa(t)}function rv(e){if(typeof e!=="string"||e.length>ov)return Wt("exceeds the encoded size limit");if(e.length%4||!/^[A-Za-z0-9+/]*={0,2}$/.test(e))Wt("contains damaged base64 data");let t;try{t=atob(e)}catch{return Wt("contains damaged base64 data")}let n=Uint8Array.from(t,(i)=>i.charCodeAt(0));if(dR(n)!==e)Wt("contains noncanonical base64 data");return n}function Bo(e){return!!e&&typeof e==="object"&&!Array.isArray(e)}async function av(e){if(!Bo(e))return Wt("metadata is missing");if(typeof e.error==="string")throw Error(e.error);let t=pf.safeParse(e.manifest);if(!t.success||!Bo(e.files))return Wt("metadata is malformed");let n=t.data,i=Object.entries(e.files);if(!i.length||i.length>16||!Object.hasOwn(e.files,"asset.glb"))return Wt("file list is missing or invalid");let r=0,s=0;for(let[c,l]of i){if(!/^[a-z0-9][a-z0-9._-]{0,127}$/.test(c)||!Object.hasOwn(n.files,c))return Wt("file metadata is missing");if(r+=n.files[c].bytes,r>sv)return Wt("exceeds the decoded size limit");let u=typeof l==="string"?l:Bo(l)?l.data:void 0;if(typeof u!=="string")return Wt("file encoding is malformed");if(s+=u.length,s>ov)return Wt("exceeds the encoded size limit")}let o={};for(let[c,l]of i){let u=n.files[c],f;if(typeof l==="string")f=rv(l);else{if(!Bo(l)||l.encoding!=="kiln.deflate-base64.v1")return Wt("encoding is unsupported");let g=rv(l.data);try{f=by(g,{out:new Uint8Array(u.bytes+1)})}catch{return Wt("compressed data is damaged")}}if(f.length!==u.bytes)return Wt("byte count does not match the saved file");let h=await crypto.subtle.digest("SHA-256",Uint8Array.from(f));if(`sha256:${Array.from(new Uint8Array(h),(g)=>g.toString(16).padStart(2,"0")).join("")}`!==u.sha256)return Wt("integrity check failed");o[c]=f}for(let c of Object.keys(n.files))if(!Object.hasOwn(o,c))return Wt("is missing a saved file");let a={};if(e.downloadUrls!==void 0){if(!Bo(e.downloadUrls))return Wt("download metadata is malformed");for(let[c,l]of Object.entries(e.downloadUrls)){if(typeof l!=="string")return Wt("download metadata is malformed");a[c]=l}}return{record:{manifest:n,files:o},downloadUrls:a}}function cv(e){let t=e.attribution;if(!t)return[];return[t.model?{label:"Model",value:t.model}:null,t.harness?{label:"Harness",value:t.harness}:null,t.author?{label:"Author",value:t.author}:null].filter((n)=>n!==null)}var Yn=(e)=>document.getElementById(e),_i=Yn("status"),nn,uv={},Go,pR=0,xi=0,zc=new Map;function hv(e,t){let n=++pR;return new Promise((i,r)=>{let s=setTimeout(()=>{zc.delete(n),r(Error("Chat host did not respond."))},20000);zc.set(n,{resolve(o){clearTimeout(s),i(o)},reject(o){clearTimeout(s),r(o)}}),window.parent.postMessage({jsonrpc:"2.0",id:n,method:e,params:t},"*")})}function lv(e,t={}){window.parent.postMessage({jsonrpc:"2.0",method:e,params:t},"*")}function mR(e){let t="";for(let n=0;n<e.length;n+=8192)t+=String.fromCharCode(...e.subarray(n,n+8192));return btoa(t)}async function gR(e){let t=++xi;nn=void 0;for(let n of document.querySelectorAll("button[data-download]"))n.disabled=!0;try{if(!e||typeof e!=="object"||Array.isArray(e))throw Error("Asset transfer metadata is missing. Present the saved asset again.");await _R(e,t)}catch(n){if(t!==xi)return;_i.textContent=n instanceof Error?n.message:"Asset transfer failed. Present the saved asset again."}}async function _R(e,t){if(e.isError){_i.textContent=e.content?.find((i)=>i.type==="text")?.text??"This asset could not be opened.";return}let n;try{n=await av(e._meta?.kilnAsset)}catch(i){if(t!==xi)return;_i.textContent=i instanceof Error?i.message:"Asset transfer failed. Present the saved asset again.";return}if(t!==xi)return;nn=n.record,Yn("name").textContent=nn.manifest.name,uv=n.downloadUrls,Yn("revision").textContent=`${nn.manifest.editable?"Editable source included":"GLB asset"} · ${nn.manifest.revisionId.slice(0,10)}`,Yn("attribution").textContent=cv(nn.manifest).map(({label:i,value:r})=>`${i}: ${r}`).join(" · ");try{Go??=tv(Yn("stage"));let i=await Go.load(nn.files["asset.glb"]);if(t!==xi)return;if(i){Yn("stats").textContent=`${i.triangles.toLocaleString()} triangles · ${i.materials} materials · ${(nn.files["asset.glb"].length/1024).toFixed(0)} KB`;let r=Yn("clips");r.replaceChildren(new Option("Rest pose","-1"),...i.clips.map((s,o)=>new Option(s,String(o)))),r.hidden=!i.clips.length}_i.textContent="Drag to orbit · Scroll to zoom"}catch(i){if(t!==xi)return;let r=nn.files["preview.png"];if(r){let s=new Image;s.alt=nn.manifest.name,s.src=`data:image/png;base64,${mR(r)}`,Yn("stage").replaceChildren(s)}_i.textContent=`3D preview unavailable: ${String(i)}`}for(let i of document.querySelectorAll("button[data-download]"))i.disabled=!1;Yn("source").hidden=!nn.files["source.kiln.js"]}window.addEventListener("message",(e)=>{if(e.source!==window.parent||e.data?.jsonrpc!=="2.0")return;let t=e.data;if(t.id!==void 0&&!t.method){let n=zc.get(t.id);if(zc.delete(t.id),t.error)n?.reject(Object.assign(Error(t.error.message),{code:t.error.code}));else n?.resolve(t.result)}if(t.method==="ui/notifications/tool-result")gR(t.params);if(t.method==="ui/resource-teardown")Go?.dispose(),window.parent.postMessage({jsonrpc:"2.0",id:t.id,result:{}},"*")});Yn("reset").onclick=()=>Go?.reset();Yn("clips").onchange=(e)=>Go?.clip(Number(e.target.value));for(let e of document.querySelectorAll("button[data-download]"))e.onclick=async()=>{if(!nn)return;let t=xi,n=e.dataset.download,i=n==="bundle"?"editable.zip":n==="source"?"source.kiln.js":"asset.glb",r=n==="bundle"?$y([nn]):nn.files[i],s=n==="bundle"?"application/zip":n==="source"?"text/javascript":"model/gltf-binary",o=nn.manifest.name.replace(/[^a-zA-Z0-9_-]+/g,"-").slice(0,80);e.disabled=!0,_i.textContent="Requesting download…";try{let a=typeof window.openai?.uploadFile==="function"&&typeof window.openai?.getFileDownloadUrl==="function"?window.openai:void 0,c=await iv(r,`${o}-${i}`,s,hv,a,uv[i]);if(t!==xi)return;if(c.downloadUrl){let l=document.createElement("a");l.href=c.downloadUrl,l.textContent=`Save ${o}-${i}`,l.style.color="#d5f4a2",l.target="_blank",l.rel="noopener noreferrer",l.onclick=(u)=>{if(window.openai?.openExternal)u.preventDefault(),window.openai.openExternal({href:c.downloadUrl})},_i.replaceChildren("Download ready. ",l)}else _i.textContent="Download requested."}catch(a){if(t===xi)_i.textContent=`Download unavailable in this host: ${a.message}`}finally{e.disabled=!nn||t!==xi}};hv("ui/initialize",{appInfo:{name:"Kiln Asset Viewer",version:"0.6.0"},appCapabilities:{},protocolVersion:"2026-01-26"}).then(()=>{lv("ui/notifications/initialized"),lv("ui/notifications/size-changed",{height:document.documentElement.scrollHeight})}).catch((e)=>{_i.textContent=e.message});
4405
+ */var Rt=Uint8Array,wn=Uint16Array,cf=Int32Array,Nc=new Rt([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Dc=new Rt([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),nf=new Rt([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),py=function(e,t){var n=new wn(31);for(var i=0;i<31;++i)n[i]=t+=1<<e[i-1];var r=new cf(n[30]);for(var i=1;i<30;++i)for(var s=n[i];s<n[i+1];++s)r[s]=s-n[i]<<5|i;return{b:n,r}},my=py(Nc,2),{b:gy,r:rf}=my;gy[28]=258,rf[258]=28;var _y=py(Dc,0),{b:z1,r:cy}=_y,sf=new wn(32768);for(je=0;je<32768;++je)mi=(je&43690)>>1|(je&21845)<<1,mi=(mi&52428)>>2|(mi&13107)<<2,mi=(mi&61680)>>4|(mi&3855)<<4,sf[je]=((mi&65280)>>8|(mi&255)<<8)>>1;var mi,je,gi=function(e,t,n){var i=e.length,r=0,s=new wn(t);for(;r<i;++r)if(e[r])++s[e[r]-1];var o=new wn(t);for(r=1;r<t;++r)o[r]=o[r-1]+s[r-1]<<1;var a;if(n){a=new wn(1<<t);var c=15-t;for(r=0;r<i;++r)if(e[r]){var l=r<<4|e[r],u=t-e[r],f=o[e[r]-1]++<<u;for(var h=f|(1<<u)-1;f<=h;++f)a[sf[f]>>c]=l}}else{a=new wn(i);for(r=0;r<i;++r)if(e[r])a[r]=sf[o[e[r]-1]++]>>15-e[r]}return a},ur=new Rt(288);for(je=0;je<144;++je)ur[je]=8;var je;for(je=144;je<256;++je)ur[je]=9;var je;for(je=256;je<280;++je)ur[je]=7;var je;for(je=280;je<288;++je)ur[je]=8;var je,Oo=new Rt(32);for(je=0;je<32;++je)Oo[je]=5;var je,k1=gi(ur,9,0),B1=gi(ur,9,1),G1=gi(Oo,5,0),H1=gi(Oo,5,1),Qh=function(e){var t=e[0];for(var n=1;n<e.length;++n)if(e[n]>t)t=e[n];return t},Xn=function(e,t,n){var i=t/8|0;return(e[i]|e[i+1]<<8)>>(t&7)&n},ef=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(t&7)},lf=function(e){return(e+7)/8|0},uf=function(e,t,n){if(t==null||t<0)t=0;if(n==null||n>e.length)n=e.length;return new Rt(e.subarray(t,n))};var V1=["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"],Un=function(e,t,n){var i=Error(t||V1[e]);if(i.code=e,Error.captureStackTrace)Error.captureStackTrace(i,Un);if(!n)throw i;return i},$1=function(e,t,n,i){var r=e.length,s=i?i.length:0;if(!r||t.f&&!t.l)return n||new Rt(0);var o=!n,a=o||t.i!=2,c=t.i;if(o)n=new Rt(r*3);var l=function(Ee){var xt=n.length;if(Ee>xt){var ke=new Rt(Math.max(xt*2,Ee));ke.set(n),n=ke}},u=t.f||0,f=t.p||0,h=t.b||0,{l:d,d:g,m:x,n:p}=t,m=r*8;do{if(!d){u=Xn(e,f,1);var E=Xn(e,f+1,3);if(f+=3,!E){var R=lf(f)+4,v=e[R-4]|e[R-3]<<8,M=R+v;if(M>r){if(c)Un(0);break}if(a)l(h+v);n.set(e.subarray(R,M),h),t.b=h+=v,t.p=f=M*8,t.f=u;continue}else if(E==1)d=B1,g=H1,x=9,p=5;else if(E==2){var T=Xn(e,f,31)+257,A=Xn(e,f+10,15)+4,_=T+Xn(e,f+5,31)+1;f+=14;var S=new Rt(_),z=new Rt(19);for(var P=0;P<A;++P)z[nf[P]]=Xn(e,f+P*3,7);f+=A*3;var F=Qh(z),ee=(1<<F)-1,I=gi(z,F,1);for(var P=0;P<_;){var H=I[Xn(e,f,ee)];f+=H&15;var R=H>>4;if(R<16)S[P++]=R;else{var q=0,C=0;if(R==16)C=3+Xn(e,f,3),f+=2,q=S[P-1];else if(R==17)C=3+Xn(e,f,7),f+=3;else if(R==18)C=11+Xn(e,f,127),f+=7;while(C--)S[P++]=q}}var X=S.subarray(0,T),k=S.subarray(T);x=Qh(X),p=Qh(k),d=gi(X,x,1),g=gi(k,p,1)}else Un(1);if(f>m){if(c)Un(0);break}}if(a)l(h+131072);var Y=(1<<x)-1,Q=(1<<p)-1,Se=f;for(;;Se=f){var q=d[ef(e,f)&Y],ue=q>>4;if(f+=q&15,f>m){if(c)Un(0);break}if(!q)Un(2);if(ue<256)n[h++]=ue;else if(ue==256){Se=f,d=null;break}else{var Fe=ue-254;if(ue>264){var P=ue-257,Me=Nc[P];Fe=Xn(e,f,(1<<Me)-1)+gy[P],f+=Me}var Z=g[ef(e,f)&Q],re=Z>>4;if(!Z)Un(3);f+=Z&15;var k=z1[re];if(re>3){var Me=Dc[re];k+=ef(e,f)&(1<<Me)-1,f+=Me}if(f>m){if(c)Un(0);break}if(a)l(h+131072);var se=h+Fe;if(h<k){var xe=s-k,we=Math.min(k,se);if(xe+h<0)Un(3);for(;h<we;++h)n[h]=i[xe+h]}for(;h<se;++h)n[h]=n[h-k]}}if(t.l=d,t.p=Se,t.b=h,t.f=u,d)u=1,t.m=x,t.d=g,t.n=p}while(!u);return h!=n.length&&o?uf(n,0,h):n.subarray(0,h)},Oi=function(e,t,n){n<<=t&7;var i=t/8|0;e[i]|=n,e[i+1]|=n>>8},No=function(e,t,n){n<<=t&7;var i=t/8|0;e[i]|=n,e[i+1]|=n>>8,e[i+2]|=n>>16},tf=function(e,t){var n=[];for(var i=0;i<e.length;++i)if(e[i])n.push({s:i,f:e[i]});var r=n.length,s=n.slice();if(!r)return{t:yy,l:0};if(r==1){var o=new Rt(n[0].s+1);return o[n[0].s]=1,{t:o,l:1}}n.sort(function(M,T){return M.f-T.f}),n.push({s:-1,f:25001});var a=n[0],c=n[1],l=0,u=1,f=2;n[0]={s:-1,f:a.f+c.f,l:a,r:c};while(u!=r-1)a=n[n[l].f<n[f].f?l++:f++],c=n[l!=u&&n[l].f<n[f].f?l++:f++],n[u++]={s:-1,f:a.f+c.f,l:a,r:c};var h=s[0].s;for(var i=1;i<r;++i)if(s[i].s>h)h=s[i].s;var d=new wn(h+1),g=of(n[u-1],d,0);if(g>t){var i=0,x=0,p=g-t,m=1<<p;s.sort(function(T,A){return d[A.s]-d[T.s]||T.f-A.f});for(;i<r;++i){var E=s[i].s;if(d[E]>t)x+=m-(1<<g-d[E]),d[E]=t;else break}x>>=p;while(x>0){var R=s[i].s;if(d[R]<t)x-=1<<t-d[R]++-1;else++i}for(;i>=0&&x;--i){var v=s[i].s;if(d[v]==t)--d[v],++x}g=t}return{t:new Rt(d),l:g}},of=function(e,t,n){return e.s==-1?Math.max(of(e.l,t,n+1),of(e.r,t,n+1)):t[e.s]=n},ly=function(e){var t=e.length;while(t&&!e[--t]);var n=new wn(++t),i=0,r=e[0],s=1,o=function(c){n[i++]=c};for(var a=1;a<=t;++a)if(e[a]==r&&a!=t)++s;else{if(!r&&s>2){for(;s>138;s-=138)o(32754);if(s>2)o(s>10?s-11<<5|28690:s-3<<5|12305),s=0}else if(s>3){o(r),--s;for(;s>6;s-=6)o(8304);if(s>2)o(s-3<<5|8208),s=0}while(s--)o(r);s=1,r=e[a]}return{c:n.subarray(0,i),n:t}},Do=function(e,t){var n=0;for(var i=0;i<t.length;++i)n+=e[i]*t[i];return n},xy=function(e,t,n){var i=n.length,r=lf(t+2);e[r]=i&255,e[r+1]=i>>8,e[r+2]=e[r]^255,e[r+3]=e[r+1]^255;for(var s=0;s<i;++s)e[r+s+4]=n[s];return(r+4+i)*8},uy=function(e,t,n,i,r,s,o,a,c,l,u){Oi(t,u++,n),++r[256];var f=tf(r,15),{t:h,l:d}=f,g=tf(s,15),{t:x,l:p}=g,m=ly(h),{c:E,n:R}=m,v=ly(x),{c:M,n:T}=v,A=new wn(19);for(var _=0;_<E.length;++_)++A[E[_]&31];for(var _=0;_<M.length;++_)++A[M[_]&31];var S=tf(A,7),{t:z,l:P}=S,F=19;for(;F>4&&!z[nf[F-1]];--F);var ee=l+5<<3,I=Do(r,ur)+Do(s,Oo)+o,H=Do(r,h)+Do(s,x)+o+14+3*F+Do(A,z)+2*A[16]+3*A[17]+7*A[18];if(c>=0&&ee<=I&&ee<=H)return xy(t,u,e.subarray(c,c+l));var q,C,X,k;if(Oi(t,u,1+(H<I)),u+=2,H<I){q=gi(h,d,0),C=h,X=gi(x,p,0),k=x;var Y=gi(z,P,0);Oi(t,u,R-257),Oi(t,u+5,T-1),Oi(t,u+10,F-4),u+=14;for(var _=0;_<F;++_)Oi(t,u+3*_,z[nf[_]]);u+=3*F;var Q=[E,M];for(var Se=0;Se<2;++Se){var ue=Q[Se];for(var _=0;_<ue.length;++_){var Fe=ue[_]&31;if(Oi(t,u,Y[Fe]),u+=z[Fe],Fe>15)Oi(t,u,ue[_]>>5&127),u+=ue[_]>>12}}}else q=k1,C=ur,X=G1,k=Oo;for(var _=0;_<a;++_){var Me=i[_];if(Me>255){var Fe=Me>>18&31;if(No(t,u,q[Fe+257]),u+=C[Fe+257],Fe>7)Oi(t,u,Me>>23&31),u+=Nc[Fe];var Z=Me&31;if(No(t,u,X[Z]),u+=k[Z],Z>3)No(t,u,Me>>5&8191),u+=Dc[Z]}else No(t,u,q[Me]),u+=C[Me]}return No(t,u,q[256]),u+C[256]},W1=new cf([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),yy=new Rt(0),Z1=function(e,t,n,i,r,s){var o=s.z||e.length,a=new Rt(i+o+5*(1+Math.ceil(o/7000))+r),c=a.subarray(i,a.length-r),l=s.l,u=(s.r||0)&7;if(t){if(u)c[0]=s.r>>3;var f=W1[t-1],h=f>>13,d=f&8191,g=(1<<n)-1,x=s.p||new wn(32768),p=s.h||new wn(g+1),m=Math.ceil(n/3),E=2*m,R=function(Ze){return(e[Ze]^e[Ze+1]<<m^e[Ze+2]<<E)&g},v=new cf(25000),M=new wn(288),T=new wn(32),A=0,_=0,S=s.i||0,z=0,P=s.w||0,F=0;for(;S+2<o;++S){var ee=R(S),I=S&32767,H=p[ee];if(x[I]=H,p[ee]=I,P<=S){var q=o-S;if((A>7000||z>24576)&&(q>423||!l)){u=uy(e,c,0,v,M,T,_,z,F,S-F,u),z=A=_=0,F=S;for(var C=0;C<286;++C)M[C]=0;for(var C=0;C<30;++C)T[C]=0}var X=2,k=0,Y=d,Q=I-H&32767;if(q>2&&ee==R(S-Q)){var Se=Math.min(h,q)-1,ue=Math.min(32767,S),Fe=Math.min(258,q);while(Q<=ue&&--Y&&I!=H){if(e[S+X]==e[S+X-Q]){var Me=0;for(;Me<Fe&&e[S+Me]==e[S+Me-Q];++Me);if(Me>X){if(X=Me,k=Q,Me>Se)break;var Z=Math.min(Q,Me-2),re=0;for(var C=0;C<Z;++C){var se=S-Q+C&32767,xe=x[se],we=se-xe&32767;if(we>re)re=we,H=se}}}I=H,H=x[I],Q+=I-H&32767}}if(k){v[z++]=268435456|rf[X]<<18|cy[k];var Ee=rf[X]&31,xt=cy[k]&31;_+=Nc[Ee]+Dc[xt],++M[257+Ee],++T[xt],P=S+X,++A}else v[z++]=e[S],++M[e[S]]}}for(S=Math.max(S,P);S<o;++S)v[z++]=e[S],++M[e[S]];if(u=uy(e,c,l,v,M,T,_,z,F,S-F,u),!l)s.r=u&7|c[u/8|0]<<3,u-=7,s.h=p,s.p=x,s.i=S,s.w=P}else{for(var S=s.w||0;S<o+l;S+=65535){var ke=S+65535;if(ke>=o)c[u/8|0]=l,ke=o;u=xy(c,u+1,e.subarray(S,ke))}s.i=o}return uf(a,0,i+lf(u)+r)},X1=function(){var e=new Int32Array(256);for(var t=0;t<256;++t){var n=t,i=9;while(--i)n=(n&1&&-306674912)^n>>>1;e[t]=n}return e}(),q1=function(){var e=-1;return{p:function(t){var n=e;for(var i=0;i<t.length;++i)n=X1[n&255^t[i]]^n>>>8;e=n},d:function(){return~e}}};var j1=function(e,t,n,i,r){if(!r){if(r={l:1},t.dictionary){var s=t.dictionary.subarray(-32768),o=new Rt(s.length+e.length);o.set(s),o.set(e,s.length),e=o,r.w=s.length}}return Z1(e,t.level==null?6:t.level,t.mem==null?r.l?Math.ceil(Math.max(8,Math.min(13,Math.log(e.length)))*1.5):20:12+t.mem,n,i,r)},vy=function(e,t){var n={};for(var i in e)n[i]=e[i];for(var i in t)n[i]=t[i];return n};var jt=function(e,t,n){for(;n;++t)e[t]=n,n>>>=8};function by(e,t){return j1(e,t||{},0,0)}function Sy(e,t){return $1(e,{i:2},t&&t.out,t&&t.dictionary)}var My=function(e,t,n,i){for(var r in e){var s=e[r],o=t+r,a=i;if(Array.isArray(s))a=vy(i,s[1]),s=s[0];if(s instanceof Rt)n[o]=[s,a];else n[o+="/"]=[new Rt(0),a],My(s,o,n,i)}},hy=typeof TextEncoder<"u"&&new TextEncoder,Y1=typeof TextDecoder<"u"&&new TextDecoder,K1=0;try{Y1.decode(yy,{stream:!0}),K1=1}catch(e){}function fy(e,t){if(t){var n=new Rt(e.length);for(var i=0;i<e.length;++i)n[i]=e.charCodeAt(i);return n}if(hy)return hy.encode(e);var r=e.length,s=new Rt(e.length+(e.length>>1)),o=0,a=function(u){s[o++]=u};for(var i=0;i<r;++i){if(o+5>s.length){var c=new Rt(o+8+(r-i<<1));c.set(s),s=c}var l=e.charCodeAt(i);if(l<128||t)a(l);else if(l<2048)a(192|l>>6),a(128|l&63);else if(l>55295&&l<57344)l=65536+(l&1047552)|e.charCodeAt(++i)&1023,a(240|l>>18),a(128|l>>12&63),a(128|l>>6&63),a(128|l&63);else a(224|l>>12),a(128|l>>6&63),a(128|l&63)}return uf(s,0,o)}var af=function(e){var t=0;if(e)for(var n in e){var i=e[n].length;if(i>65535)Un(9);t+=i+4}return t},dy=function(e,t,n,i,r,s,o,a){var c=i.length,l=n.extra,u=a&&a.length,f=af(l);if(jt(e,t,o!=null?33639248:67324752),t+=4,o!=null)e[t++]=20,e[t++]=n.os;e[t]=20,t+=2,e[t++]=n.flag<<1|(s<0&&8),e[t++]=r&&8,e[t++]=n.compression&255,e[t++]=n.compression>>8;var h=new Date(n.mtime==null?Date.now():n.mtime),d=h.getFullYear()-1980;if(d<0||d>119)Un(10);if(jt(e,t,d<<25|h.getMonth()+1<<21|h.getDate()<<16|h.getHours()<<11|h.getMinutes()<<5|h.getSeconds()>>1),t+=4,s!=-1)jt(e,t,n.crc),jt(e,t+4,s<0?-s-2:s),jt(e,t+8,n.size);if(jt(e,t+12,c),jt(e,t+14,f),t+=16,o!=null)jt(e,t,u),jt(e,t+6,n.attrs),jt(e,t+10,o),t+=14;if(e.set(i,t),t+=c,f)for(var g in l){var x=l[g],p=x.length;jt(e,t,+g),jt(e,t+2,p),e.set(x,t+4),t+=4+p}if(u)e.set(a,t),t+=u;return t},J1=function(e,t,n,i,r){jt(e,t,101010256),jt(e,t+8,n),jt(e,t+10,n),jt(e,t+12,i),jt(e,t+16,r)};function wy(e,t){if(!t)t={};var n={},i=[];My(e,"",n,t);var r=0,s=0;for(var o in n){var a=n[o],c=a[0],l=a[1],u=l.level==0?0:8,f=fy(o),h=f.length,d=l.comment,g=d&&fy(d),x=g&&g.length,p=af(l.extra);if(h>65535)Un(11);var m=u?by(c,l):c,E=m.length,R=q1();R.p(c),i.push(vy(l,{size:c.length,crc:R.d(),c:m,f,m:g,u:h!=o.length||g&&d.length!=x,o:r,compression:u})),r+=30+h+p+E,s+=76+2*(h+p)+(x||0)+E}var v=new Rt(s+22),M=r,T=s-r;for(var A=0;A<i.length;++A){var f=i[A];dy(v,f.o,f,f.f,f.u,f.c.length);var _=30+f.f.length+af(f.extra);v.set(f.c,f.o+_),dy(v,r,f,f.f,f.u,f.c.length,f.o,f.m),r+=16+_+(f.m?f.m.length:0)}return J1(v,r,i.length,T,M),v}var hf=["albedo","emissive","normal","roughness","metalness","metallicRoughness","occlusion"];function Q1(e){if(e==="UNINITIALIZED_BINDING")return"A const, let or class binding was read before its declaration ran (temporal dead zone). Move the declaration above the first code that reads it; top-level constants must be declared before other top-level code uses them. kiln_validate names the binding and line when the read runs immediately.";if(e==="LOD_SET")return'Levels of detail: sibling nodes whose names share a stem and carry LOD0, LOD1, ... tokens (Body_LOD0, Body_LOD1) form one set. A set needs LOD0 and consecutive levels under one parent, outside any other tier, and one defineLod([lod0, lod1, ...], { screenCoverage: [...] }) call listing its tiers in level order with one value per level, each from 0 to 1 and strictly decreasing; the last may be 0, which never culls. Build one tier without LOD tokens unless the brief asks for levels. Call kiln_discover with ids ["defineLod"].';if(e==="OPEN_SHELL")return'markOpenShell(part, reason) marks a part as intentionally open: part is the mesh createPart returned or a group whose meshes it covers, and reason is a non-empty string of at most 200 characters saying why, for example markOpenShell(rail, "C-channel closed by the end plates"). The engine owns the kilnOpenShell userData key; set it only through markOpenShell. Call kiln_discover with ids ["markOpenShell"].';if(e==="BUILD_RESULT")return'Define a top-level function build() (it may be async) that returns the root Object3D, for example const root = createRoot("Name"); ...; return root;. A build() that returns nothing, or returns a geometry or material, is rejected.';if(e==="MATERIAL_RECIPE_OVERRIDE")return'materialRecipe takes a listed kiln.material.*.v1 ID and only the overrides that recipe allows; the allowed overrides differ by recipe (the emissive recipe has no metalness). Call kiln_discover with ids ["materialRecipe"] to see what each recipe allows; kiln_validate names the recipe and key when both are literals.';if(e==="PROGRAM_TYPE_ERROR")return"The program or a helper it called threw a TypeError: a value had the wrong type. Usually something is undefined (a function without a return, an un-awaited async helper such as roundedBoxGeo, extrudeProfile or materialRecipe, or a misspelt property) or a non-function was called. Run kiln_validate, then check the helper contract with kiln_discover.";if(e==="PROGRAM_RANGE_ERROR")return"The program or a helper it called threw a RangeError: a number was outside its allowed range, for example a non-positive size, an invalid array length or segment count, or unbounded recursion. Check the helper arguments against kiln_discover.";if(e==="MESH_DATA_NONFINITE")return"meshGeo positions, normals, UVs and tangents must contain finite numbers representable in Float32. Check missing XYZ components, undefined values, division by zero and overflowing calculations before constructing the arrays. Do not replace invalid values blindly with zero; correct the source calculation. Call kiln_discover for the exact meshGeo data contract.";if(e==="PORTABLE_COLOR_ARGUMENT")return"compilePortableMaterialSpecV2 baseColor and emissive must be numeric color integers from 0x000000 to 0xffffff, for example baseColor: 0x8a867c. CSS strings and materialRecipe hex-string overrides use different contracts. Omit these fields for their defaults, or call kiln_discover for the exact helper contract.";if(e==="MATERIAL_RECIPE_TEXTURE_BINDING")return"materialRecipe textureResources maps portable slots to approved resource ID strings. Slots are baseColor, normal, metallicRoughness, emissive and occlusion. albedo is a pbrMaterial field, not a recipe slot. Use kiln_discover to check each resource allowedSlots and recipeIds before binding it; no slot or resource substitution is applied.";if(e==="PORTABLE_TEXTURE_REFERENCE")return'compilePortableMaterialSpecV2 textures require typed references: { kind: "resource", resourceId: "kiln.texture..." } for an approved resource, or { kind: "procedural", spec: { schemaVersion: 2, ... } } for a procedural texture. Bare resource ID strings are invalid here. Use portable slots such as baseColor and check the exact helper/resource contracts with kiln_discover.';if(e==="TAPER_CONE_AXIS")return'taperConeGeo(radiusBottom, radiusTop, height, axis, segments): the fourth argument is axis, "x", "y" or "z" (default "y"). Segment count is the fifth argument, for example taperConeGeo(0.03, 0.02, 0.01, "x", 12). Call kiln_discover for the full contract.';if(e==="PROCEDURAL_TEXTURE_BLEND")return'proceduralTexture layer blend must be normal, multiply, screen, or overlay. Omit blend for normal compositing. Call kiln_discover with ids ["proceduralTexture"] for the supported layer fields.';if(e==="PART_NAME_ARGUMENT")return"createPart(name, geometry, material, options?): the first argument is a string name. Put the parent Object3D in the fourth argument as { parent: root }.";if(e==="PART_GEOMETRY_ARGUMENT")return"createPart(name, geometry, material, options?): the second argument must be a BufferGeometry. Call geometry helpers, for example boxGeo(1, 1, 1), instead of passing the function. For async helpers such as roundedBoxGeo, extrudeProfile and revolveProfile, await the result inside async build() before passing it to createPart. Call kiln_discover for the exact return contract.";if(e==="PART_MATERIAL_ARGUMENT")return"createPart(name, geometry, material, options?): the third argument must be a Three.js material. Wrap a color with gameMaterial(0x808080); a number or settings object alone is not a material. Call kiln_discover for the chosen material helper contract.";if(e==="SOLID_FLOAT32_COLLAPSE")return"Solid output cannot retain valid faces at Float32 precision. Simplify subprecision features or recenter local geometry; review coincident cut boundaries. Smoothing or replacing normals does not repair collapsed triangles. Kiln did not export a partially repaired solid.";if(e==="PROFILE_BEVEL_COLLAPSE")return"extrudeProfile or revolveProfile: bevel is too large for this profile; erosion leaves nothing. Reduce bevel below half the narrowest section width, set bevel to 0, or widen the profile. Dimensions and bevel use the same asset units.";if(e==="TUBE_RADIUS")return"curveToMesh and pipeAlongPath require an explicit positive finite radius representable in Float32, in asset units. A missing or undefined radius is invalid; check the referenced dimension. Radius is half the tube diameter.";if(e==="MATERIAL_ALPHA_MODE")return'pbrMaterial and portable material specs require lowercase alphaMode: "opaque", "mask", or "blend". Omit it for opaque. Exported glTF uses uppercase mode names; those are not authoring input values.';if(e==="MATERIAL_COLOR_ARGUMENT")return"gameMaterial, basicMaterial, glassMaterial and lambertMaterial take a color first: a hex number or CSS string. Settings belong in the second argument, for example gameMaterial(0x9a9a96, { roughness: 0.4, metalness: 0.8 }). pbrMaterial uses a different object-form contract; call kiln_discover for its texture and material fields.";if(e==="MATERIAL_PACKED_CHANNELS")return'pbrMaterial requires one packed texture with G=roughness and B=metalness. Generate or load it for usage "metallicRoughness" and pass metallicRoughness, or pass the same packed texture in both roughness and metalness. Do not combine those forms or pass a texture in only one scalar slot. Plain roughness and metalness values are 0..1 numbers. Call kiln_discover for the exact texture contract.';if(e==="REMOVED_HELPER")return"Generated source references a retired Kiln global. Call kiln_validate for name-specific migration guidance, then kiln_discover for the replacement contract. No compatibility aliases are provided.";if(e==="UNBOUND_VARIABLE")return"Check variable spelling and scope: generated code used an undeclared variable. Read the current source and check declarations before retrying. If it was meant to be a Kiln helper, call kiln_discover to confirm the exact name and signature; the sandbox exposes only those globals.";if(e==="ROUNDED_BOX_RADIUS")return"roundedBoxGeo: radius must be less than half the smallest dimension. Reduce radius or increase the smallest dimension; equality is invalid.";if(e==="GEAR_RADII_ORDER")return"gearGeo requires boreRadius < rootRadius < tipRadius; specify rootRadius when changing tipRadius. Omitted radii keep their absolute defaults.";if(e==="PROCEDURAL_TEXTURE_UNKNOWN_KEY")return'Remove unsupported proceduralTexture fields. Call kiln_discover with ids ["proceduralTexture"] and use only the documented fields for the selected layer op.';if(e==="MATERIAL_FRACTION_RANGE")return"Material fractions must be finite numbers between 0 and 1, inclusive. In proceduralTexture, mortarWidth and stagger are fractions, not pixels; opacity uses the same range. materialRecipe roughness, metalness, opacity, alphaCutoff and emissiveIntensity use 0..1. portableMaterial roughness, metalness and alphaCutoff also use 0..1; its emissiveIntensity has a separate 0..64 range. Call kiln_discover for the exact field contracts.";if(e==="PROFILE_HOLES_UNSUPPORTED")return"loftProfiles and sweepProfile: holes are unsupported in options or sections. Use extrudeProfile for a holed cross-section with optional twist/taper; independently varying contours need explicit geometry or solid subtraction. cap:false does not create inner walls or thickness.";if(e==="PROFILE_CORRESPONDENCE_COLLAPSE")return"loftProfiles or sweepProfile: corresponding profile edges collapse between stations. Check matching start vertices and vertex order; for an intended twist, add intermediate sections or path stations. No automatic correspondence repair is applied. Other self-intersections remain unchecked.";return e==="PARAMETRIC_PERIODIC_ENDPOINT"?"Periodic parametricSurface endpoints must return matching positions. For periodicU, sample(uMin, v) and sample(uMax, v) must match; for periodicV, sample(u, vMin) and sample(u, vMax) must match.":""}class ff extends Error{diagnostic;constructor(e,t=Q1(e)){super(t);this.diagnostic=e;this.name="AuthoringDiagnosticError"}}var Ey=1024,Ty=4,Ay=8,eR=6,Ry=80,Uo=256;class St extends ff{constructor(e,t){super(t,e);this.name="ProceduralTextureError"}}var Cy=["solid","checker","stripes","gradient","bricks","noise"],Py=["normal","multiply","screen","overlay"],tR=new Set(["__proto__","prototype","constructor"]);function Oc(e,t){if(!e||typeof e!=="object"||Array.isArray(e))throw new St(`${t} must be a plain JSON object.`);let n=Object.getPrototypeOf(e);if(n!==Object.prototype&&n!==null)throw new St(`${t} must be a plain JSON object with no custom prototype.`);for(let i of Reflect.ownKeys(e)){if(typeof i!=="string")throw new St(`${t} must not contain symbol keys.`);if(tR.has(i))throw new St(`${t} contains forbidden key ${JSON.stringify(i)}.`);if(!Object.prototype.propertyIsEnumerable.call(e,i))throw new St(`${t}.${i} must be an enumerable JSON field.`);let r=Object.getOwnPropertyDescriptor(e,i);if(!r||!("value"in r))throw new St(`${t}.${i} must be a plain JSON data field.`)}return e}function nR(e,t){if(!Array.isArray(e)||Object.getPrototypeOf(e)!==Array.prototype)throw new St(`${t} must be a plain JSON array.`);for(let n of Reflect.ownKeys(e)){if(typeof n!=="string")throw new St(`${t} must not contain symbol keys.`);if(n==="length")continue;if(!/^(0|[1-9][0-9]*)$/.test(n)||Number(n)>=e.length)throw new St(`${t} has non-index JSON array key ${JSON.stringify(n)}.`)}for(let n=0;n<e.length;n++)if(!Object.hasOwn(e,n))throw new St(`${t} must be a dense JSON array (missing index ${n}).`);return e}function hr(e,t,n){let i=new Set(t);for(let r of Object.keys(e))if(!i.has(r))throw new St(`${n} has unknown key ${JSON.stringify(r)}.`,"PROCEDURAL_TEXTURE_UNKNOWN_KEY")}function qn(e,t,n){if(typeof e!=="number"||!Number.isInteger(e)||e<0||e>16777215)throw new St(`${t} must be a color integer between 0x000000 and 0xffffff, got ${JSON.stringify(e)}.`,n);return e}function Fr(e,t,n,i,r){if(e===void 0)return n;if(typeof e!=="number"||!Number.isInteger(e)||e<i||e>r)throw new St(`${t} must be a whole number between ${i} and ${r}, got ${JSON.stringify(e)}.`);return e}function Ly(e,t,n,i,r,s){if(e===void 0)return n;if(typeof e!=="number"||!Number.isFinite(e)||e<i||e>r)throw new St(`${t} must be a finite number between ${i} and ${r}, got ${JSON.stringify(e)}.`,s);return e}function df(e,t,n){return Ly(e,t,n,0,1,"MATERIAL_FRACTION_RANGE")}function iR(e,t){if(e===void 0)return;let n=typeof e==="string"&&[...e].some((i)=>{let r=i.charCodeAt(0);return r<32||r===127});if(typeof e!=="string"||e.length===0||e.length>Ry||n)throw new St(`${t} must be 1..${Ry} visible characters.`);return e}function rR(e,t,n){if(e===void 0)return n;if(!hf.includes(e))throw new St(`${t} must be one of ${hf.join(", ")}, got ${JSON.stringify(e)}.`);return e}function Iy(e,t){let i=(Ly(e,t,0,-36000,36000)%360+360)%360;return Object.is(i,-0)?0:i}function sR(e,t){let n=e.blend??"normal";if(!Py.includes(n))throw new St(`${t}.blend ${JSON.stringify(n)} is not one of ${Py.join(", ")}.`,"PROCEDURAL_TEXTURE_BLEND");return n}function oR(e,t){let n=`proceduralTexture.layers[${t}]`,i=Oc(e,n),r=i.op;if(!Cy.includes(r))throw new St(`${n}.op ${JSON.stringify(r)} is not one of ${Cy.join(", ")}.`);let s=sR(i,n),o=df(i.opacity,`${n}.opacity`,1),a={blend:t===0?"normal":s,opacity:t===0?1:o};switch(r){case"solid":return hr(i,["op","color","blend","opacity"],n),{op:r,color:qn(i.color,`${n}.color`),...a};case"checker":return hr(i,["op","colorA","colorB","squares","blend","opacity"],n),{op:r,colorA:qn(i.colorA,`${n}.colorA`),colorB:qn(i.colorB,`${n}.colorB`),squares:Fr(i.squares,`${n}.squares`,8,1,Uo),...a};case"stripes":return hr(i,["op","colorA","colorB","count","angleDeg","blend","opacity"],n),{op:r,colorA:qn(i.colorA,`${n}.colorA`),colorB:qn(i.colorB,`${n}.colorB`),count:Fr(i.count,`${n}.count`,8,1,Uo),angleDeg:Iy(i.angleDeg,`${n}.angleDeg`),...a};case"gradient":return hr(i,["op","from","to","angleDeg","blend","opacity"],n),{op:r,from:qn(i.from,`${n}.from`),to:qn(i.to,`${n}.to`),angleDeg:Iy(i.angleDeg,`${n}.angleDeg`),...a};case"bricks":return hr(i,["op","brick","mortar","rows","cols","mortarWidth","stagger","blend","opacity"],n),{op:r,brick:qn(i.brick,`${n}.brick`),mortar:qn(i.mortar,`${n}.mortar`),rows:Fr(i.rows,`${n}.rows`,8,1,Uo),cols:Fr(i.cols,`${n}.cols`,4,1,Uo),mortarWidth:df(i.mortarWidth,`${n}.mortarWidth`,0.06),stagger:df(i.stagger,`${n}.stagger`,0.5),...a};case"noise":return hr(i,["op","colorA","colorB","scale","octaves","seed","blend","opacity"],n),{op:r,colorA:qn(i.colorA,`${n}.colorA`),colorB:qn(i.colorB,`${n}.colorB`),scale:Fr(i.scale,`${n}.scale`,8,1,Uo),octaves:Fr(i.octaves,`${n}.octaves`,3,1,eR),seed:Fr(i.seed,`${n}.seed`,0,-2147483648,2147483647),...a};default:throw new St(`${n}.op is unsupported.`)}}function aR(e){let t=Oc(e,"proceduralTexture");if(hr(t,["schemaVersion","size","usage","name","layers"],"proceduralTexture"),t.schemaVersion!==void 0&&t.schemaVersion!==1)throw new St(`proceduralTexture.schemaVersion must be 1 or absent for V1 migration, got ${JSON.stringify(t.schemaVersion)}.`);return{schemaVersion:2,...t.size!==void 0?{size:t.size}:{},...t.usage!==void 0?{usage:t.usage}:{},...t.name!==void 0?{name:t.name}:{},layers:t.layers}}function Ny(e){let t=Oc(e,"proceduralTexture"),n=t.schemaVersion===void 0||t.schemaVersion===1?Oc(aR(t),"proceduralTexture"):t;if(hr(n,["schemaVersion","size","usage","name","layers"],"proceduralTexture"),n.schemaVersion!==2)throw new St(`proceduralTexture.schemaVersion must be 2, got ${JSON.stringify(n.schemaVersion)}.`);let i=n.size??256;if(typeof i!=="number"||!Number.isInteger(i)||i<Ty||i>Ey||(i&i-1)!==0)throw new St(`proceduralTexture.size must be a power of two between ${Ty} and ${Ey}, got ${JSON.stringify(n.size)}.`);let r=n.layers;if(!Array.isArray(r)||r.length===0)throw new St("proceduralTexture.layers must be a non-empty array — the bottom layer is the base pattern.");let s=nR(r,"proceduralTexture.layers");if(s.length>Ay)throw new St(`proceduralTexture: ${s.length} layers exceeds the maximum of ${Ay}.`);let o=iR(n.name,"proceduralTexture.name");return{schemaVersion:2,size:i,usage:rR(n.usage,"proceduralTexture.usage","albedo"),...o!==void 0?{name:o}:{},layers:s.map(oR)}}var TD=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);var Yn=Object.freeze({maxMapBytes:8388608,maxRecordBytes:33554432,maxManifestBytes:262144,maxMapEdge:4096,maxRecordPixels:8388608,maxPayloadBytes:16777216,maxPayloadPixels:16777216,maxPayloadRecords:16}),Oy=["baseColor","normal","metallicRoughness","emissive","occlusion"],cR={baseColor:"albedo",normal:"normal",metallicRoughness:"metallicRoughness",emissive:"emissive",occlusion:"occlusion"};var zo=Je().regex(/^[a-z][a-z0-9_-]{0,79}$/),ko=Je().regex(/^sha256:[a-f0-9]{64}$/),fr=Je().min(1).max(1000),Dy=Je().max(2000).url().refine((e)=>/^https?:\/\//.test(e),"Provenance URL must be HTTP(S)"),Uy=ht({id:zo,kind:On(["external","procedural"]),provider:fr,creator:fr,assetId:fr.optional(),assetUrl:Dy.optional(),accessedAt:Je().datetime().optional(),license:ht({spdx:fr,url:Dy,attribution:Je().max(4000)}).strict(),originalFiles:an(ht({name:Je().min(1).max(200),sha256:ko,bytes:pt().int().positive().max(1073741824)}).strict()).max(20)}).strict().superRefine((e,t)=>{if(e.kind==="external"&&(!e.assetUrl||!e.originalFiles.length))t.addIssue({code:"custom",message:"External materials require a source URL and original file hashes"});if(new Set(e.originalFiles.map((n)=>n.name)).size!==e.originalFiles.length)t.addIssue({code:"custom",message:"Duplicate original filename"})}),Fy=ht({operation:fr,tool:fr,version:fr,parameters:Lc(Je().max(100),ty([Je().max(2000),pt().finite(),Lo()])).optional()}).strict(),jn=pt().int().min(0).max(16777215),Fo=pt().int().min(1).max(256),Ps={blend:On(["normal","multiply","screen","overlay"]).default("normal"),opacity:pt().min(0).max(1).default(1)},zy=ht({schemaVersion:qt(2),size:pt().int().min(4).max(1024).default(256),usage:On(["albedo","normal","roughness","metalness","metallicRoughness","emissive","occlusion"]).default("albedo"),name:Je().min(1).max(80).optional(),layers:an(_1("op",[ht({op:qt("solid"),color:jn,...Ps}).strict(),ht({op:qt("checker"),colorA:jn,colorB:jn,squares:Fo.default(8),...Ps}).strict(),ht({op:qt("stripes"),colorA:jn,colorB:jn,count:Fo.default(8),angleDeg:pt().min(-36000).max(36000).default(0),...Ps}).strict(),ht({op:qt("gradient"),from:jn,to:jn,angleDeg:pt().min(-36000).max(36000).default(0),...Ps}).strict(),ht({op:qt("bricks"),brick:jn,mortar:jn,rows:Fo.default(8),cols:Fo.default(4),mortarWidth:pt().min(0).max(1).default(0.06),stagger:pt().min(0).max(1).default(0.5),...Ps}).strict(),ht({op:qt("noise"),colorA:jn,colorB:jn,scale:Fo.default(8),octaves:pt().int().min(1).max(6).default(3),seed:pt().int().min(-2147483648).max(2147483647).default(0),...Ps}).strict()])).min(1).max(8)}).strict(),ky=ht({kind:qt("normal-from-height"),strength:pt().finite().positive().max(64)}).strict(),lR=ht({compiler:qt("kiln.procedural-texture.v2"),spec:zy,derive:ky.optional(),recipeHash:ko,pixelHash:ko,encoder:ht({name:qt("sharp"),version:fr}).strict()}).strict(),By=ht({baseColor:pt().int().min(0).max(16777215).optional(),roughness:pt().min(0).max(1).default(1),metalness:pt().min(0).max(1).default(0),emissive:pt().int().min(0).max(16777215).optional(),emissiveIntensity:pt().min(0).max(64).default(1),alphaMode:On(["opaque","mask","blend"]).default("opaque"),alphaCutoff:pt().min(0).max(1).default(0.5),doubleSided:Lo().default(!1)}).strict(),Gy=ht({schemaVersion:qt(1),materialId:zo,revisionId:ko,name:Je().min(1).max(200),tags:an(Je().min(1).max(80)).max(30),tileable:Lo(),physicalSizeMeters:ht({width:pt().finite().positive().max(1e5),height:pt().finite().positive().max(1e5)}).strict().optional(),parameters:By,sources:an(Uy).min(1).max(20),maps:an(ht({slot:On(Oy),file:On(["baseColor.png","normal.png","metallicRoughness.png","emissive.png","occlusion.png"]),sha256:ko,bytes:pt().int().positive().max(Yn.maxMapBytes),width:pt().int().positive().max(Yn.maxMapEdge),height:pt().int().positive().max(Yn.maxMapEdge),usage:On(["albedo","normal","metallicRoughness","emissive","occlusion"]),colorSpace:On(["srgb","linear"]),normalConvention:qt("opengl").optional(),channelPacking:qt("r-occlusion-g-roughness-b-metallic").optional(),sourceId:zo,originalFile:Je().min(1).max(200).optional(),transforms:an(Fy).max(30),procedural:lR.optional()}).strict()).min(1).max(5)}).strict(),PD=ht({materialId:zo,name:Je().min(1).max(200),tags:an(Je().min(1).max(80)).max(30).optional(),tileable:Lo(),physicalSizeMeters:ht({width:pt().finite().positive().max(1e5),height:pt().finite().positive().max(1e5)}).strict().optional(),parameters:By.partial().optional(),sources:an(Uy).min(1).max(20),maps:an(ht({slot:On(Oy),sourceId:zo,transforms:an(Fy).max(30),normalConvention:qt("opengl").optional(),channelPacking:qt("r-occlusion-g-roughness-b-metallic").optional(),procedural:zy,derive:ky.optional()}).strict()).min(1).max(5)}).strict(),Hy=ht({schemaVersion:qt(1),records:an(ht({manifest:Gy,files:Lc(Je().regex(/^(baseColor|normal|metallicRoughness|emissive|occlusion)\.png$/),Je().max(Math.ceil(Yn.maxMapBytes/3)*4))}).strict()).max(Yn.maxPayloadRecords)}).strict();function Go(e,t=!1,n=0){if(n>30)throw Error("Material JSON exceeds nesting limit");if(e===null||typeof e==="string"||typeof e==="boolean")return;if(typeof e==="number"&&Number.isFinite(e))return;if(t&&e instanceof Uint8Array)return;if(!e||typeof e!=="object")throw Error("Material values must be plain JSON data");let i=Array.isArray(e),r=Object.getPrototypeOf(e);if(i?r!==Array.prototype:r!==Object.prototype&&r!==null)throw Error("Material values must have plain JSON prototypes");if(i&&e.length>1e4)throw Error("Material JSON array exceeds limit");for(let s of Reflect.ownKeys(e)){if(i&&s==="length")continue;if(typeof s!=="string"||["__proto__","prototype","constructor"].includes(s))throw Error("Material JSON contains a forbidden key");if(i&&(!/^(0|[1-9][0-9]*)$/.test(s)||Number(s)>=e.length))throw Error("Material arrays must contain only indexed data");let o=Object.getOwnPropertyDescriptor(e,s);if(!("value"in o)||!o.enumerable)throw Error("Material JSON accessors or hidden fields are not allowed");Go(o.value,t,n+1)}if(i&&Object.keys(e).length!==e.length)throw Error("Material JSON arrays must be dense")}function Bo(e){Go(e);let t=(n)=>Array.isArray(n)?n.map(t):n!==null&&typeof n==="object"?Object.fromEntries(Object.entries(n).sort(([i],[r])=>i<r?-1:i>r?1:0).map(([i,r])=>[i,t(r)])):n;return JSON.stringify(t(e))}function Vy(e){if(Go(e),new TextEncoder().encode(JSON.stringify(e)).length>Yn.maxManifestBytes)throw Error("Material manifest exceeds size limit");let t=Gy.parse(e);if(new Set(t.sources.map((r)=>r.id)).size!==t.sources.length)throw Error("Duplicate material source identity");if(new Set(t.maps.map((r)=>r.slot)).size!==t.maps.length)throw Error("Duplicate material map slot");let n=0,i=0;for(let r of t.maps){let s=r.slot==="baseColor"||r.slot==="emissive";if(r.file!==`${r.slot}.png`||r.usage!==cR[r.slot]||r.colorSpace!==(s?"srgb":"linear"))throw Error("Material map filename, usage or color convention mismatch");if(r.slot==="normal"!==(r.normalConvention==="opengl")||r.slot==="metallicRoughness"!==(r.channelPacking==="r-occlusion-g-roughness-b-metallic"))throw Error("Material map convention is missing or invalid");let o=t.sources.find((a)=>a.id===r.sourceId);if(!o)throw Error("Material map source is missing");if(r.procedural){if(r.procedural.derive&&r.slot!=="normal")throw Error("Height derivation requires a normal map slot");if(Bo(r.procedural.spec)!==Bo(Ny(r.procedural.spec)))throw Error("Stored procedural material recipe must be canonical");if(o.kind!=="procedural"||r.originalFile||r.procedural.spec.usage!==r.usage||r.procedural.spec.size!==r.width||r.width!==r.height)throw Error("Procedural material source or map convention mismatch")}else if(o.kind!=="external"||!o.originalFiles.some((a)=>a.name===r.originalFile))throw Error("Material map must reference an original source file");n+=r.bytes,i+=r.width*r.height}if(n>Yn.maxRecordBytes||i>Yn.maxRecordPixels)throw Error("Material record exceeds byte or pixel budget");return t}var Uc=67108864,pf=Je().regex(/^[a-z][a-z0-9_-]{0,79}$/),uR=Je().regex(/^sha256:[a-f0-9]{64}$/),mf=ht({version:qt("kiln.asset.v1"),assetId:pf,revisionId:pf,parentRevision:pf.optional(),name:Je().min(1).max(200),tags:an(Je().max(80)).max(30),createdAt:Je().datetime(),description:Je().max(4000).optional(),brief:Je().max(8000).optional(),attribution:ht({model:Je().max(200).optional(),harness:Je().max(200).optional(),author:Je().max(200).optional()}).optional(),editable:Lo(),files:Lc(Je(),ht({sha256:uR,bytes:pt().int().nonnegative().max(Uc)})),build:ht({engine:Je(),options:Lc(Je(),Ur()),warnings:an(Je()),integration:Ur().optional(),qa:Ur().optional(),dependencies:an(Ur()).optional(),rebuild:On(["engine-required","external-dependencies-required"])}).optional(),preview:ht({fidelity:Ur().optional(),error:Je().optional(),backdrop:On(oy).optional()}).optional()}),hR="materials.kiln.json",fR=25165824;function $y(e,t=!1){let n=(e.manifest.build?.dependencies??[]).filter((c)=>c&&typeof c==="object"&&c.kind==="kiln.material.v1"),i=new Map(n.map((c)=>{if(c.delivery!=="runtime")throw Error("Invalid saved material dependency");let l=Vy(c.manifest);return[`${l.materialId}/${l.revisionId}`,Bo(l)]}));if(!e.materialResources){if(t&&i.size)throw Error("Editable asset material closure unavailable");return}Go(e.materialResources);let r=Hy.parse(e.materialResources),s=0,o=0,a=new Set;for(let c of r.records){let l=`${c.manifest.materialId}/${c.manifest.revisionId}`;if(a.has(l)||i.get(l)!==Bo(c.manifest))throw Error("Asset material closure mismatch");if(a.add(l),Object.keys(c.files).length!==c.manifest.maps.length)throw Error("Asset material map inventory mismatch");for(let u of c.manifest.maps){if(c.files[u.file]?.length!==Math.ceil(u.bytes/3)*4)throw Error("Asset material map size mismatch");s+=u.bytes,o+=u.width*u.height}}if(a.size!==i.size)throw Error("Asset material closure incomplete");if(s>Yn.maxPayloadBytes||o>Yn.maxPayloadPixels)throw Error("Asset material closure exceeds allocation limits")}var dR=new Set(["asset.glb","source.kiln.js","preview.png"]);function pR(e){let t=mf.parse(e.manifest),n=Object.keys(e.files);if(n.length!==Object.keys(t.files).length||!n.includes("asset.glb"))throw Error("Asset file inventory mismatch");let i=0;for(let r of n){if(!dR.has(r)||!t.files[r]||t.files[r].bytes!==e.files[r].length)throw Error("Invalid asset file inventory");i+=e.files[r].length}if(i>Uc||t.editable!==n.includes("source.kiln.js"))throw Error("Invalid asset size or source inventory");if((e.files["source.kiln.js"]?.length??0)>1048576)throw Error("Source exceeds 1 MiB");gf(e.files["asset.glb"]),$y(e)}function gf(e){if(e.length<20||e.length>Uc)throw Error("Invalid GLB size");let t=new DataView(e.buffer,e.byteOffset,e.byteLength);if(t.getUint32(0,!0)!==1179937895||t.getUint32(4,!0)!==2||t.getUint32(8,!0)!==e.length||t.getUint32(16,!0)!==1313821514)throw Error("Invalid GLB header");let n=20+t.getUint32(12,!0);if(n>e.length)throw Error("Invalid GLB JSON length");let i=JSON.parse(new TextDecoder().decode(e.subarray(20,n)));for(let r of[...i.buffers??[],...i.images??[]])if(r.uri&&!String(r.uri).startsWith("data:"))throw Error("GLB must embed its resources")}function Wy(e){if(!e.length||e.length>100)throw Error("Bundle requires 1..100 revisions");let t={},n=0;for(let i of e){pR(i),$y(i,!0);let r=`${i.manifest.assetId}/${i.manifest.revisionId}/`;if(t[`${r}manifest.json`])throw Error("Duplicate bundle revision");t[`${r}manifest.json`]=new TextEncoder().encode(JSON.stringify(i.manifest,null,2));for(let[s,o]of Object.entries(i.files))t[r+s]=o;if(i.materialResources){let s=new TextEncoder().encode(JSON.stringify(i.materialResources));if(s.length>fR)throw Error("Asset material payload exceeds byte limit");t[r+hR]=s}}for(let i of Object.values(t))n+=i.length;if(n>Uc)throw Error("Bundle exceeds 64 MiB");return wy(t,{level:0})}function _i(e){let t=new Set,n=new Set,i=new Set;e.traverse((r)=>{let s=r;if(!s.isMesh)return;t.add(s.geometry);for(let o of Array.isArray(s.material)?s.material:[s.material]){n.add(o);for(let a of Object.values(o))if(a instanceof At)i.add(a)}});for(let r of[...t,...n,...i])r.dispose()}async function Zy(e){gf(e);let t=new oo,n=!1;t.onError=()=>{n=!0},t.addHandler(/^data:image\//,new _s(t)),t.setURLModifier((s)=>{if(!s.startsWith("blob:")&&!s.startsWith("data:"))throw Error("External model resources are not loaded");return s});let i=new th(t);i.register((s)=>({name:"KILN_embedded_images",async beforeRoot(){for(let o of s.json.images??[]){if(o.bufferView===void 0)continue;let a=new Uint8Array(await s.getDependency("bufferView",o.bufferView)),c="";for(let l=0;l<a.length;l+=8192)c+=String.fromCharCode(...a.subarray(l,l+8192));if(!/^image\/(png|jpeg|webp|avif)$/.test(o.mimeType??""))throw Error("Unsupported embedded image type");o.uri=`data:${o.mimeType};base64,${btoa(c)}`,delete o.bufferView}}}));let r=await i.parseAsync(Uint8Array.from(e).buffer,"");if(n){for(let s of r.scenes)_i(s);throw Error("An embedded texture could not be decoded.")}return Object.assign(r,{assertTexturesLoaded(){if(n)throw Error("An embedded texture could not be decoded.")}})}function Xy(e,t,n=40,i=[e]){let r=e.getCenter(new O),s=Math.max(e.getSize(new O).length()/2,0.01),o=new O(1,0.65,1.25).normalize(),a=new O().crossVectors(new O(0,1,0),o).normalize(),c=new O().crossVectors(o,a),l=[];for(let E of i.length?i:[e])for(let R of[E.min.x,E.max.x])for(let v of[E.min.y,E.max.y])for(let M of[E.min.z,E.max.z])l.push(new O(R,v,M));let u=1/0,f=-1/0,h=1/0,d=-1/0;for(let E of l){let R=E.clone().sub(r),v=R.dot(a),M=R.dot(c);u=Math.min(u,v),f=Math.max(f,v),h=Math.min(h,M),d=Math.max(d,M)}r.addScaledVector(a,(u+f)/2),r.addScaledVector(c,(h+d)/2);let g=Math.tan(n*Math.PI/360),x=g*t,p=s;for(let E of l){let R=E.clone().sub(r),v=R.dot(o);p=Math.max(p,v+Math.abs(R.dot(a))*1.12/x,v+Math.abs(R.dot(c))*1.12/g)}let m=r.clone().addScaledVector(o,p);return{center:r,radius:s,distance:p,position:m}}function _f(e,t){return{position:e.position.clone(),target:t.clone()}}function xf(e,t,n,i){e.position.copy(n.position),t.copy(n.target);let r=Math.max(i.getSize(new O).length(),0.001);e.near=Math.min(0.01,Math.max(r/1e5,0.00001)),e.far=Math.max(e.position.distanceTo(i.getCenter(new O))+r*20,10),e.updateProjectionMatrix()}function qy(e,t,n){let i=e.getWorldDirection(new O);if(i.y=0,i.lengthSq()<0.00000001)i.set(0,0,-1);i.normalize();let r=i.clone().cross(new O(0,1,0)),s=new O;if(t.has("KeyW")||t.has("ArrowUp"))s.add(i);if(t.has("KeyS")||t.has("ArrowDown"))s.sub(i);if(t.has("KeyD")||t.has("ArrowRight"))s.add(r);if(t.has("KeyA")||t.has("ArrowLeft"))s.sub(r);if(t.has("KeyE"))s.y++;if(t.has("KeyQ"))s.y--;return s.normalize().multiplyScalar(n)}function jy(e){let t=e.filter((i)=>Number.isFinite(i)&&i>0).sort((i,r)=>i-r);if(!t.length)throw Error("No frame timing evidence was collected.");let n=(i)=>t[Math.max(0,Math.ceil(t.length*i)-1)];return{samples:t.length,min:t[0],p50:n(0.5),p95:n(0.95),max:t.at(-1)}}function Yy(e,t,n){if(t())return e;n(e);return}function Fc(e,t){let n=e.parser.json.nodes??[],i=new Set;if(n.forEach((s,o)=>{if(s?.extensions?.KHR_node_visibility?.visible===!1)i.add(o)}),i.size===0)return 0;let r=0;for(let s of t)s.traverse((o)=>{let a=e.parser.associations.get(o)?.nodes;if(a===void 0||!i.has(a))return;o.visible=!1,r++});return r}function zc(e){let t=!1;if(e.traverse((s)=>{if(!s.visible)t=!0}),!t)return new Ft().setFromObject(e,!0);e.updateWorldMatrix(!0,!0);let n=new Ft,i=new Ft,r=new O;return e.traverseVisible((s)=>{let o=s,a=o.geometry;if(!a)return;let c=a.getAttribute("position");if(c&&o.isInstancedMesh!==!0){for(let u=0;u<c.count;u++){if(o.isMesh)o.getVertexPosition(u,r);else r.fromBufferAttribute(c,u);n.expandByPoint(r.applyMatrix4(s.matrixWorld))}return}let l=s;if(l.boundingBox!==void 0){if(l.boundingBox===null)l.computeBoundingBox();i.copy(l.boundingBox)}else{if(a.boundingBox===null)a.computeBoundingBox();i.copy(a.boundingBox)}n.union(i.applyMatrix4(s.matrixWorld))}),n.isEmpty()?new Ft().setFromObject(e,!0):n}function Ho(e){let t=0;return e.traverseVisible((n)=>{let i=n;if(!i.isMesh)return;let r=i.geometry.index?.count??i.geometry.attributes.position?.count??0;t+=r/3*(i.isInstancedMesh?i.count:1)}),t}async function Ky(e){let t=e.parser.json.nodes??[],n=new Map;e.scene.traverse((c)=>{let l=e.parser.associations.get(c)?.nodes;if(l!==void 0&&!n.has(l))n.set(l,c)});let i=new Set,r=[];for(let[c,l]of n){let u=t[c]?.extensions?.MSFT_lod?.ids;if(!Array.isArray(u)||u.length===0)continue;if(u.some((g)=>!Number.isInteger(g)||!t[g]||n.has(g)))continue;let f=l.parent;while(f&&!i.has(f))f=f.parent;if(f)continue;let h=[l];for(let g of u)h.push(await e.parser.getDependency("node",g));Fc(e,h.slice(1)),i.add(l);let d=(l.name.replace(/[_ -]?LOD0$/i,"")||l.parent?.name||`Part ${c}`).replace(/^Mesh_/,"");r.push({id:String(c),label:d,levels:h})}if(r.length===0)return;let s=Ho(e.scene)-r.reduce((c,l)=>c+yf(l,0),0),o=Math.max(...r.map((c)=>c.levels.length)),a=Array.from({length:o},(c,l)=>s+r.reduce((u,f)=>u+yf(f,l),0));return{chains:r,triangles:a}}var Jy=(e,t)=>e.levels[Math.min(Math.max(Number.isFinite(t)?Math.floor(t):0,0),e.levels.length-1)];function yf(e,t){let n=e.levels.find((i)=>i.parent)?.parent;while(n){if(!n.visible)return 0;n=n.parent}return Ho(Jy(e,t))}function Qy(e,t){let n=Jy(e,t),i=e.levels.find((s)=>s.parent!==null);if(!i||i===n)return;let r=i.parent;r.children[r.children.indexOf(i)]=n,n.parent=r,i.parent=null}function ev(e,t){for(let n of e.chains)Qy(n,t)}function tv(e,t,n){let i=e.chains.find((r)=>r.id===t);if(!i)return!1;return Qy(i,n),!0}function nv(e,t){if(!e)return;return{triangles:Ho(t),levels:e.triangles,chains:e.chains.map((n)=>({id:n.id,label:n.label,level:n.levels.findIndex((i)=>i.parent!==null),triangles:n.levels.map((i,r)=>yf(n,r))}))}}function Is(e){return(e?.chains??[]).flatMap((t)=>t.levels.filter((n)=>n.parent===null))}function iv(e){let t=new Vu({antialias:!0,alpha:!1});t.setPixelRatio(Math.min(devicePixelRatio,2)),t.setClearColor(1382930),t.toneMapping=Ws,t.toneMappingExposure=1.15,e.replaceChildren(t.domElement);let n=new ds,i=new Ut(40,1,0.01,1000),r=new Zu(i,t.domElement);r.enableDamping=!0,t.domElement.tabIndex=0,t.domElement.setAttribute("aria-label","Interactive 3D asset. Drag to orbit or use Explore navigation.");let s=new Set,o=!1,a=1,c=new Set(["KeyW","KeyA","KeyS","KeyD","KeyQ","KeyE","ArrowUp","ArrowDown","ArrowLeft","ArrowRight","ShiftLeft","ShiftRight"]),l=(C)=>{if(!o||!c.has(C.code))return;C.preventDefault(),s.add(C.code)},u=(C)=>s.delete(C.code),f=()=>s.clear();t.domElement.addEventListener("keydown",l),t.domElement.addEventListener("keyup",u),t.domElement.addEventListener("blur",f);let h=new mo(t),d=new Xu,g=h.fromScene(d,0.04);n.environment=g.texture,d.dispose(),h.dispose();let x=new vs(16773591,2.4);x.position.set(4,8,5),n.add(x),n.add(new Wa(14806490,5065021,1.7));let p,m,E,R=[],v=!0,M=performance.now(),T=0,A=0,_=!1,S,z,P,F=(C)=>{if(!P)return;clearTimeout(P.timeout),P.reject(Error(C)),P=void 0},ee=(C)=>{let X=t.getContext(),k=X.getExtension("WEBGL_debug_renderer_info");return{version:"kiln.viewer-performance.v1",measuredAt:new Date().toISOString(),windowMs:C-P.started,frameMs:jy(P.samples),...z===void 0?{}:{loadToFirstFrameMs:z},drawCalls:t.info.render.calls,triangles:t.info.render.triangles,lines:t.info.render.lines,points:t.info.render.points,geometryObjects:t.info.memory.geometries,textureObjects:t.info.memory.textures,shaderPrograms:t.info.programs?.length??0,viewport:{cssWidth:e.clientWidth,cssHeight:e.clientHeight,bufferWidth:t.domElement.width,bufferHeight:t.domElement.height,devicePixelRatio:t.getPixelRatio()},renderer:{version:String(X.getParameter(X.VERSION)),vendor:String(X.getParameter(X.VENDOR)),renderer:String(X.getParameter(X.RENDERER)),browser:navigator.userAgent,...k?{unmaskedVendor:String(X.getParameter(k.UNMASKED_VENDOR_WEBGL)),unmaskedRenderer:String(X.getParameter(k.UNMASKED_RENDERER_WEBGL))}:{}},camera:{position:i.position.toArray(),target:r.target.toArray(),fov:i.fov},limitations:["Exploratory measurement: workloads outside this page are uncontrolled. This is not an isolated performance baseline or budget acceptance.","Frame intervals measure browser requestAnimationFrame pacing, including scheduling and vertical sync; they are not GPU execution time.","Load-to-first-frame begins at GLB parsing and ends after the first render submission; it excludes download time and does not measure presentation latency.","Draw and resource counts come from this Three.js renderer, including studio lighting resources. Object counts are not GPU memory bytes.","This receipt describes this viewport, camera and device only. It is not a performance qualification for other consumers or hardware."]}},I=()=>{if(!p)return;let C=zc(p),X=[];p.traverseVisible((ue)=>{if(ue instanceof _t||ue instanceof Ji||ue instanceof gs){let Fe=new Ft().setFromObject(ue,!0);if(!Fe.isEmpty())X.push(Fe)}});let{center:k,radius:Y,distance:Q,position:Se}=Xy(C,i.aspect,i.fov,X);if(r.target.copy(k),i.position.copy(Se),i.near=Math.max(Y/1000,0.0001),i.far=Q+Y*100,r.minDistance=Y*0.1,r.maxDistance=Y*80,a=Math.max(Y*0.35,0.01),o)r.minDistance=Y*0.00001;i.updateProjectionMatrix(),r.update()},H=new ResizeObserver(()=>{let{clientWidth:C,clientHeight:X}=e;if(!C||!X)return;t.setSize(C,X),i.aspect=C/X,i.updateProjectionMatrix()});H.observe(e);let q=(C)=>{if(_)return;let X=Math.min((C-M)/1000,0.1);if(M=C,e.clientWidth&&e.clientHeight){if(v)E?.update(X);if(o&&s.size){let k=qy(i,s,X*a*(s.has("ShiftLeft")||s.has("ShiftRight")?3:1));i.position.add(k),r.target.add(k)}if(r.update(),t.render(n,i),S!==void 0)z=performance.now()-S,S=void 0;if(P){if(P.previous>0&&P.samples.length<1800)P.samples.push(C-P.previous);if(P.previous=C,C-P.started>=P.duration&&P.samples.length){let k=ee(C);clearTimeout(P.timeout),P.resolve(k),P=void 0}}}else s.clear(),F("Keep the measured viewport visible for the complete sampling window.");T=requestAnimationFrame(q)};return T=requestAnimationFrame(q),{async load(C,X={}){let k=performance.now(),Y=++A;F("The artifact changed during measurement. Measure the new revision again.");let Q=await Zy(C);Fc(Q,[Q.scene]);let Se=await Ky(Q);try{Q.assertTexturesLoaded()}catch(xe){_i(Q.scene);for(let we of Is(Se))_i(we);throw xe}let ue=Yy(Q,()=>!_&&Y===A&&X.isCurrent?.()!==!1,(xe)=>{_i(xe.scene);for(let we of Is(Se))_i(we)});if(!ue)return;let Fe=p&&X.preserveView?_f(i,r.target):void 0;if(p){E?.stopAllAction(),E?.uncacheRoot(p),n.remove(p),_i(p);for(let xe of Is(m))_i(xe)}p=ue.scene,m=Se,S=k,z=void 0,n.add(p),R=ue.animations,E=new ja(p),v=!0;let{clientWidth:Me,clientHeight:Z}=e;if(t.setSize(Me,Z),i.aspect=Me&&Z?Me/Z:i.aspect,I(),Fe)xf(i,r.target,Fe,zc(p)),r.update();let re=0,se=new Set;return p.traverseVisible((xe)=>{let we=xe;if(!we.isMesh)return;re++;for(let Ee of Array.isArray(we.material)?we.material:[we.material])se.add(Ee)}),X.onCommit?.(),{triangles:Ho(p),meshes:re,materials:se.size,clips:R.map((xe)=>xe.name),...m?{levels:m.triangles}:{}}},level(C){if(F("The level of detail changed. Measure the displayed combination again."),m)ev(m,C)},partLevel(C,X){if(F("The level of detail changed. Measure the displayed combination again."),m)tv(m,C,X)},lod(){return p?nv(m,p):void 0},reset:I,cancelMeasurement:F,measure(C=3000){if(_||!p||!e.clientWidth||!e.clientHeight)return Promise.reject(Error("Load an artifact in a visible viewport before measuring."));if(!Number.isFinite(C)||C<1000||C>5000)return Promise.reject(Error("Measurement duration must be 1–5 seconds."));if(P)return Promise.reject(Error("A measurement is already running."));return new Promise((X,k)=>{P={started:performance.now(),previous:0,duration:C,samples:[],resolve:X,reject:k,timeout:setTimeout(()=>F("Measurement was interrupted or the browser stopped delivering frames."),C+2000)}})},view(){return _f(i,r.target)},setView(C){if(!p)return;xf(i,r.target,C,zc(p)),r.update()},navigation(C){if(o=C==="explore",s.clear(),r.minDistance=o?0.00001:a/3.5,o)i.near=0.0001,i.updateProjectionMatrix()},wire(C){for(let X of p?[p,...Is(m)]:[])X.traverse((k)=>{let Y=k;if(Y.isMesh){for(let Q of Array.isArray(Y.material)?Y.material:[Y.material])if("wireframe"in Q)Q.wireframe=C}})},lighting(C){t.toneMappingExposure=C==="bright"?1.65:C==="soft"?0.85:1.15,x.intensity=C==="soft"?0.8:2.4},clip(C){if(E?.stopAllAction(),R[C])E?.clipAction(R[C]).play()},pause(C){v=!C},dispose(){if(F("The viewport closed before measurement finished."),_=!0,A++,cancelAnimationFrame(T),H.disconnect(),r.dispose(),t.domElement.removeEventListener("keydown",l),t.domElement.removeEventListener("keyup",u),t.domElement.removeEventListener("blur",f),p)_i(p);for(let C of Is(m))_i(C);g.dispose(),t.dispose(),e.replaceChildren()}}}var rv=["127.0.0.1","localhost","[::1]"];async function sv(e,t,n,i,r,s){let o="";for(let a=0;a<e.length;a+=8192)o+=String.fromCharCode(...e.subarray(a,a+8192));try{if((await i("ui/download-file",{contents:[{type:"resource",resource:{uri:`file:///${t}`,mimeType:n,blob:btoa(o)}}]}))?.isError)throw Error("The chat host could not download this file.");return{}}catch(a){if(a.code!==-32601)throw a;if(s){let f=new URL(s);if(f.protocol!=="https:"&&!(f.protocol==="http:"&&rv.includes(f.hostname)))throw Error("Invalid host download URL");return{downloadUrl:f.href}}if(!r)throw a;let c=new File([Uint8Array.from(e)],t,{type:n}),{fileId:l}=await r.uploadFile(c),{downloadUrl:u}=await r.getFileDownloadUrl({fileId:l});if(new URL(u).protocol!=="https:")throw Error("Invalid host download URL");return{downloadUrl:u}}}var av=16777216,cv=Math.ceil(av/3)*4,Wt=(e)=>{throw Error(`Asset transfer ${e}. Present the saved asset again or open it in Kiln; the saved files are unchanged.`)};function mR(e){let t="";for(let n=0;n<e.length;n+=8192)t+=String.fromCharCode(...e.subarray(n,n+8192));return btoa(t)}function ov(e){if(typeof e!=="string"||e.length>cv)return Wt("exceeds the encoded size limit");if(e.length%4||!/^[A-Za-z0-9+/]*={0,2}$/.test(e))Wt("contains damaged base64 data");let t;try{t=atob(e)}catch{return Wt("contains damaged base64 data")}let n=Uint8Array.from(t,(i)=>i.charCodeAt(0));if(mR(n)!==e)Wt("contains noncanonical base64 data");return n}function Vo(e){return!!e&&typeof e==="object"&&!Array.isArray(e)}async function lv(e){if(!Vo(e))return Wt("metadata is missing");if(typeof e.error==="string")throw Error(e.error);let t=mf.safeParse(e.manifest);if(!t.success||!Vo(e.files))return Wt("metadata is malformed");let n=t.data,i=Object.entries(e.files);if(!i.length||i.length>16||!Object.hasOwn(e.files,"asset.glb"))return Wt("file list is missing or invalid");let r=0,s=0;for(let[c,l]of i){if(!/^[a-z0-9][a-z0-9._-]{0,127}$/.test(c)||!Object.hasOwn(n.files,c))return Wt("file metadata is missing");if(r+=n.files[c].bytes,r>av)return Wt("exceeds the decoded size limit");let u=typeof l==="string"?l:Vo(l)?l.data:void 0;if(typeof u!=="string")return Wt("file encoding is malformed");if(s+=u.length,s>cv)return Wt("exceeds the encoded size limit")}let o={};for(let[c,l]of i){let u=n.files[c],f;if(typeof l==="string")f=ov(l);else{if(!Vo(l)||l.encoding!=="kiln.deflate-base64.v1")return Wt("encoding is unsupported");let g=ov(l.data);try{f=Sy(g,{out:new Uint8Array(u.bytes+1)})}catch{return Wt("compressed data is damaged")}}if(f.length!==u.bytes)return Wt("byte count does not match the saved file");let h=await crypto.subtle.digest("SHA-256",Uint8Array.from(f));if(`sha256:${Array.from(new Uint8Array(h),(g)=>g.toString(16).padStart(2,"0")).join("")}`!==u.sha256)return Wt("integrity check failed");o[c]=f}for(let c of Object.keys(n.files))if(!Object.hasOwn(o,c))return Wt("is missing a saved file");let a={};if(e.downloadUrls!==void 0){if(!Vo(e.downloadUrls))return Wt("download metadata is malformed");for(let[c,l]of Object.entries(e.downloadUrls)){if(typeof l!=="string")return Wt("download metadata is malformed");a[c]=l}}return{record:{manifest:n,files:o},downloadUrls:a}}function uv(e){let t=e.attribution;if(!t)return[];return[t.model?{label:"Model",value:t.model}:null,t.harness?{label:"Harness",value:t.harness}:null,t.author?{label:"Author",value:t.author}:null].filter((n)=>n!==null)}var En=(e)=>document.getElementById(e),xi=En("status"),nn,fv={},zr,gR=0,yi=0,kc=new Map;function dv(e,t){let n=++gR;return new Promise((i,r)=>{let s=setTimeout(()=>{kc.delete(n),r(Error("Chat host did not respond."))},20000);kc.set(n,{resolve(o){clearTimeout(s),i(o)},reject(o){clearTimeout(s),r(o)}}),window.parent.postMessage({jsonrpc:"2.0",id:n,method:e,params:t},"*")})}function hv(e,t={}){window.parent.postMessage({jsonrpc:"2.0",method:e,params:t},"*")}function _R(e){let t="";for(let n=0;n<e.length;n+=8192)t+=String.fromCharCode(...e.subarray(n,n+8192));return btoa(t)}async function xR(e){let t=++yi;nn=void 0,En("stats").textContent="",En("clips").hidden=!0;for(let n of document.querySelectorAll("button[data-download]"))n.disabled=!0;try{if(!e||typeof e!=="object"||Array.isArray(e))throw Error("Asset transfer metadata is missing. Present the saved asset again.");await yR(e,t)}catch(n){if(t!==yi)return;xi.textContent=n instanceof Error?n.message:"Asset transfer failed. Present the saved asset again."}}async function yR(e,t){if(e.isError){xi.textContent=e.content?.find((i)=>i.type==="text")?.text??"This asset could not be opened.";return}let n;try{n=await lv(e._meta?.kilnAsset)}catch(i){if(t!==yi)return;xi.textContent=i instanceof Error?i.message:"Asset transfer failed. Present the saved asset again.";return}if(t!==yi)return;nn=n.record,En("name").textContent=nn.manifest.name,fv=n.downloadUrls,En("revision").textContent=`${nn.manifest.editable?"Editable source included":"GLB asset"} · ${nn.manifest.revisionId.slice(0,10)}`,En("attribution").textContent=uv(nn.manifest).map(({label:i,value:r})=>`${i}: ${r}`).join(" · ");try{zr??=iv(En("stage"));let i=await zr.load(nn.files["asset.glb"]);if(t!==yi)return;if(i){En("stats").textContent=`${i.triangles.toLocaleString()} triangles · ${i.materials} materials · ${(nn.files["asset.glb"].length/1024).toFixed(0)} KB`;let r=En("clips");r.replaceChildren(new Option("Rest pose","-1"),...i.clips.map((s,o)=>new Option(s,String(o)))),r.hidden=!i.clips.length}xi.textContent="Drag to orbit · Scroll to zoom"}catch(i){if(t!==yi)return;zr?.dispose(),zr=void 0;let r=nn.files["preview.png"];if(r){let s=new Image;s.alt=`${nn.manifest.name} · saved preview image`,s.src=`data:image/png;base64,${_R(r)}`,En("stage").replaceChildren(s)}xi.textContent=`${r?"Showing saved preview. ":""}3D preview unavailable: ${String(i)}`}for(let i of document.querySelectorAll("button[data-download]"))i.disabled=!1;En("source").hidden=!nn.files["source.kiln.js"]}window.addEventListener("message",(e)=>{if(e.source!==window.parent||e.data?.jsonrpc!=="2.0")return;let t=e.data;if(t.id!==void 0&&!t.method){let n=kc.get(t.id);if(kc.delete(t.id),t.error)n?.reject(Object.assign(Error(t.error.message),{code:t.error.code}));else n?.resolve(t.result)}if(t.method==="ui/notifications/tool-result")xR(t.params);if(t.method==="ui/resource-teardown")zr?.dispose(),window.parent.postMessage({jsonrpc:"2.0",id:t.id,result:{}},"*")});En("reset").onclick=()=>zr?.reset();En("clips").onchange=(e)=>zr?.clip(Number(e.target.value));for(let e of document.querySelectorAll("button[data-download]"))e.onclick=async()=>{if(!nn)return;let t=yi,n=e.dataset.download,i=n==="bundle"?"editable.zip":n==="source"?"source.kiln.js":"asset.glb",r=n==="bundle"?Wy([nn]):nn.files[i],s=n==="bundle"?"application/zip":n==="source"?"text/javascript":"model/gltf-binary",o=nn.manifest.name.replace(/[^a-zA-Z0-9_-]+/g,"-").slice(0,80);e.disabled=!0,xi.textContent="Requesting download…";try{let a=typeof window.openai?.uploadFile==="function"&&typeof window.openai?.getFileDownloadUrl==="function"?window.openai:void 0,c=await sv(r,`${o}-${i}`,s,dv,a,fv[i]);if(t!==yi)return;if(c.downloadUrl){let l=document.createElement("a");l.href=c.downloadUrl,l.textContent=`Save ${o}-${i}`,l.style.color="#d5f4a2",l.target="_blank",l.rel="noopener noreferrer",l.onclick=(u)=>{if(window.openai?.openExternal)u.preventDefault(),window.openai.openExternal({href:c.downloadUrl})},xi.replaceChildren("Download ready. ",l)}else xi.textContent="Download requested."}catch(a){if(t===yi)xi.textContent=`Download unavailable in this host: ${a.message}`}finally{e.disabled=!nn||t!==yi}};dv("ui/initialize",{appInfo:{name:"Kiln Asset Viewer",version:"0.6.0"},appCapabilities:{},protocolVersion:"2026-01-26"}).then(()=>{hv("ui/notifications/initialized"),hv("ui/notifications/size-changed",{height:document.documentElement.scrollHeight})}).catch((e)=>{xi.textContent=e.message});
4406
4406
 
4407
4407
  </script>
4408
4408
  </body>