import{H as e,V as t,Y as n,ct as r,dt as i,ft as a,mt as o,ot as s,st as c,ut as l,z as u}from"./index-CM0zIqrs.js";var d=o(l(),1);function f(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function p(e,t,n){return t=w(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function m(e,t){return _(e)||f(e,t)||y(e,t)||S()}function h(e){return g(e)||v(e)||y(e)||x()}function g(e){if(Array.isArray(e))return b(e)}function _(e){if(Array.isArray(e))return e}function v(e){if(typeof Symbol<`u`&&e[Symbol.iterator]!=null||e[`@@iterator`]!=null)return Array.from(e)}function y(e,t){if(e){if(typeof e==`string`)return b(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`)return Array.from(e);if(n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return b(e,t)}}function b(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);ne,methodNames:r=[],initPropNames:i=[]}={}){return(0,d.forwardRef)((a,o)=>{let s=(0,d.useRef)(),c=(0,d.useMemo)(()=>e(Object.fromEntries(i.filter(e=>a.hasOwnProperty(e)).map(e=>[e,a[e]]))),[]);D(()=>{c(n(s.current))},d.useLayoutEffect),D(()=>c._destructor instanceof Function?c._destructor:void 0);let l=(0,d.useCallback)((e,...t)=>c[e]instanceof Function?c[e](...t):void 0,[c]),u=(0,d.useRef)({});return Object.keys(T(a,[...r,...i])).filter(e=>u.current[e]!==a[e]).forEach(e=>l(e,a[e])),u.current=a,(0,d.useImperativeHandle)(o,()=>Object.fromEntries(r.map(e=>[e,(...t)=>l(e,...t)])),[l]),d.createElement(t,{ref:s})})}function D(e,t=d.useEffect){let n=(0,d.useRef)(),r=(0,d.useRef)(!1),i=(0,d.useRef)(!1),[a,o]=(0,d.useState)(0);r.current&&(i.current=!0),t(()=>(r.current||=(n.current=e(),!0),o(e=>e+1),()=>{i.current&&=(n.current&&n.current(),n.current=void 0,r.current=!1,!1)}),[])}var O={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},k={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},A=1e3,j=1001,M=1002,N=1003,ee=1004,te=1005,ne=1006,re=1007,ie=1008,ae=1008,oe=1009,se=1010,ce=1011,le=1012,ue=1013,de=1014,fe=1015,pe=1016,me=1017,he=1018,ge=1020,_e=35902,ve=35899,ye=1021,be=1022,xe=1023,Se=1026,Ce=1027,we=1028,Te=1029,Ee=1030,De=1031,Oe=1032,ke=1033,Ae=33776,je=33777,Me=33778,Ne=33779,Pe=35840,P=35841,Fe=35842,Ie=35843,Le=36196,Re=37492,ze=37496,Be=37488,Ve=37489,He=37490,Ue=37491,We=37808,Ge=37809,Ke=37810,qe=37811,Je=37812,Ye=37813,Xe=37814,Ze=37815,Qe=37816,$e=37817,et=37818,tt=37819,nt=37820,rt=37821,it=36492,at=36494,ot=36495,st=36283,ct=36284,lt=36285,ut=36286,dt=2300,ft=2301,pt=2302,mt=2303,ht=2400,gt=2401,_t=2402,vt=3200,yt=`srgb`,bt=`srgb-linear`,xt=`linear`,St=`srgb`,Ct=7680,wt=7681,Tt=7682,Et=7683,Dt=34055,Ot=34056,kt=5386,At=35044,jt=35048,Mt=2e3,Nt=2001,Pt={COMPUTE:`compute`,RENDER:`render`},Ft={TEXTURE_COMPARE:`depthTextureCompare`};function It(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}function Lt(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function Rt(e){return document.createElementNS(`http://www.w3.org/1999/xhtml`,e)}function zt(){let e=Rt(`canvas`);return e.style.display=`block`,e}var Bt={},Vt=null;function Ht(...e){let t=`THREE.`+e.shift();Vt?Vt(`log`,t,...e):console.log(t,...e)}function Ut(e){let t=e[0];if(typeof t==`string`&&t.startsWith(`TSL:`)){let t=e[1];t&&t.isStackTrace?e[0]+=` `+t.getLocation():e[1]=`Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.`}return e}function F(...e){e=Ut(e);let t=`THREE.`+e.shift();if(Vt)Vt(`warn`,t,...e);else{let n=e[0];n&&n.isStackTrace?console.warn(n.getError(t)):console.warn(t,...e)}}function I(...e){e=Ut(e);let t=`THREE.`+e.shift();if(Vt)Vt(`error`,t,...e);else{let n=e[0];n&&n.isStackTrace?console.error(n.getError(t)):console.error(t,...e)}}function Wt(...e){let t=e.join(` `);t in Bt||(Bt[t]=!0,F(...e))}function Gt(){return typeof self<`u`&&self.scheduler!==void 0&&self.scheduler.yield!==void 0?self.scheduler.yield():new Promise(e=>{requestAnimationFrame(e)})}function Kt(e,t,n){return new Promise(function(r,i){function a(){switch(e.clientWaitSync(t,e.SYNC_FLUSH_COMMANDS_BIT,0)){case e.WAIT_FAILED:i();break;case e.TIMEOUT_EXPIRED:setTimeout(a,n);break;default:r()}}setTimeout(a,n)})}var qt={0:1,2:6,4:7,3:5,1:0,6:2,7:4,5:3},Jt=class{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});let n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){let n=this._listeners;return n===void 0?!1:n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){let n=this._listeners;if(n===void 0)return;let r=n[e];if(r!==void 0){let e=r.indexOf(t);e!==-1&&r.splice(e,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 t=n.slice(0);for(let n=0,r=t.length;n>8&255]+Yt[e>>16&255]+Yt[e>>24&255]+`-`+Yt[t&255]+Yt[t>>8&255]+`-`+Yt[t>>16&15|64]+Yt[t>>24&255]+`-`+Yt[n&63|128]+Yt[n>>8&255]+`-`+Yt[n>>16&255]+Yt[n>>24&255]+Yt[r&255]+Yt[r>>8&255]+Yt[r>>16&255]+Yt[r>>24&255]).toLowerCase()}function en(e,t,n){return Math.max(t,Math.min(n,e))}function tn(e,t){return(e%t+t)%t}function nn(e,t,n,r,i){return r+(e-t)*(i-r)/(n-t)}function rn(e,t,n){return e===t?0:(n-e)/(t-e)}function an(e,t,n){return(1-n)*e+n*t}function on(e,t,n,r){return an(e,t,1-Math.exp(-n*r))}function sn(e,t=1){return t-Math.abs(tn(e,t*2)-t)}function cn(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t),e*e*(3-2*e))}function ln(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t),e*e*e*(e*(e*6-15)+10))}function un(e,t){return e+Math.floor(Math.random()*(t-e+1))}function dn(e,t){return e+Math.random()*(t-e)}function fn(e){return e*(.5-Math.random())}function pn(e){e!==void 0&&(Xt=e);let t=Xt+=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 mn(e){return e*Zt}function hn(e){return e*Qt}function gn(e){return(e&e-1)==0&&e!==0}function _n(e){return 2**Math.ceil(Math.log(e)/Math.LN2)}function vn(e){return 2**Math.floor(Math.log(e)/Math.LN2)}function yn(e,t,n,r,i){let a=Math.cos,o=Math.sin,s=a(n/2),c=o(n/2),l=a((t+r)/2),u=o((t+r)/2),d=a((t-r)/2),f=o((t-r)/2),p=a((r-t)/2),m=o((r-t)/2);switch(i){case`XYX`:e.set(s*u,c*d,c*f,s*l);break;case`YZY`:e.set(c*f,s*u,c*d,s*l);break;case`ZXZ`:e.set(c*d,c*f,s*u,s*l);break;case`XZX`:e.set(s*u,c*m,c*p,s*l);break;case`YXY`:e.set(c*p,s*u,c*m,s*l);break;case`ZYZ`:e.set(c*m,c*p,s*u,s*l);break;default:F(`MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: `+i)}}function bn(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return e/4294967295;case Uint16Array:return e/65535;case Uint8Array: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 xn(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: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 Sn={DEG2RAD:Zt,RAD2DEG:Qt,generateUUID:$t,clamp:en,euclideanModulo:tn,mapLinear:nn,inverseLerp:rn,lerp:an,damp:on,pingpong:sn,smoothstep:cn,smootherstep:ln,randInt:un,randFloat:dn,randFloatSpread:fn,seededRandom:pn,degToRad:mn,radToDeg:hn,isPowerOfTwo:gn,ceilPowerOfTwo:_n,floorPowerOfTwo:vn,setQuaternionFromProperEuler:yn,normalize:xn,denormalize:bn},L=class e{static#e=e.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,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6],this.y=r[1]*t+r[4]*n+r[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=en(this.x,e.x,t.x),this.y=en(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=en(this.x,e,t),this.y=en(this.y,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(en(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(en(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),r=Math.sin(t),i=this.x-e.x,a=this.y-e.y;return this.x=i*n-a*r+e.x,this.y=i*r+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},Cn=class{constructor(e=0,t=0,n=0,r=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=r}static slerpFlat(e,t,n,r,i,a,o){let s=n[r+0],c=n[r+1],l=n[r+2],u=n[r+3],d=i[a+0],f=i[a+1],p=i[a+2],m=i[a+3];if(u!==m||s!==d||c!==f||l!==p){let e=s*d+c*f+l*p+u*m;e<0&&(d=-d,f=-f,p=-p,m=-m,e=-e);let t=1-o;if(e<.9995){let n=Math.acos(e),r=Math.sin(n);t=Math.sin(t*n)/r,o=Math.sin(o*n)/r,s=s*t+d*o,c=c*t+f*o,l=l*t+p*o,u=u*t+m*o}else{s=s*t+d*o,c=c*t+f*o,l=l*t+p*o,u=u*t+m*o;let e=1/Math.sqrt(s*s+c*c+l*l+u*u);s*=e,c*=e,l*=e,u*=e}}e[t]=s,e[t+1]=c,e[t+2]=l,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,r,i,a){let o=n[r],s=n[r+1],c=n[r+2],l=n[r+3],u=i[a],d=i[a+1],f=i[a+2],p=i[a+3];return e[t]=o*p+l*u+s*f-c*d,e[t+1]=s*p+l*d+c*u-o*f,e[t+2]=c*p+l*f+o*d-s*u,e[t+3]=l*p-o*u-s*d-c*f,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,r){return this._x=e,this._y=t,this._z=n,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){let n=e._x,r=e._y,i=e._z,a=e._order,o=Math.cos,s=Math.sin,c=o(n/2),l=o(r/2),u=o(i/2),d=s(n/2),f=s(r/2),p=s(i/2);switch(a){case`XYZ`:this._x=d*l*u+c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u-d*f*p;break;case`YXZ`:this._x=d*l*u+c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u+d*f*p;break;case`ZXY`:this._x=d*l*u-c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u-d*f*p;break;case`ZYX`:this._x=d*l*u-c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u+d*f*p;break;case`YZX`:this._x=d*l*u+c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u-d*f*p;break;case`XZY`:this._x=d*l*u-c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u+d*f*p;break;default:F(`Quaternion: .setFromEuler() encountered an unknown order: `+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){let n=t/2,r=Math.sin(n);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,n=t[0],r=t[4],i=t[8],a=t[1],o=t[5],s=t[9],c=t[2],l=t[6],u=t[10],d=n+o+u;if(d>0){let e=.5/Math.sqrt(d+1);this._w=.25/e,this._x=(l-s)*e,this._y=(i-c)*e,this._z=(a-r)*e}else if(n>o&&n>u){let e=2*Math.sqrt(1+n-o-u);this._w=(l-s)/e,this._x=.25*e,this._y=(r+a)/e,this._z=(i+c)/e}else if(o>u){let e=2*Math.sqrt(1+o-n-u);this._w=(i-c)/e,this._x=(r+a)/e,this._y=.25*e,this._z=(s+l)/e}else{let e=2*Math.sqrt(1+u-n-o);this._w=(a-r)/e,this._x=(i+c)/e,this._y=(s+l)/e,this._z=.25*e}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<1e-8?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(en(this.dot(e),-1,1)))}rotateTowards(e,t){let n=this.angleTo(e);if(n===0)return this;let r=Math.min(1,t/n);return this.slerp(e,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x*=e,this._y*=e,this._z*=e,this._w*=e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){let n=e._x,r=e._y,i=e._z,a=e._w,o=t._x,s=t._y,c=t._z,l=t._w;return this._x=n*l+a*o+r*c-i*s,this._y=r*l+a*s+i*o-n*c,this._z=i*l+a*c+n*s-r*o,this._w=a*l-n*o-r*s-i*c,this._onChangeCallback(),this}slerp(e,t){let n=e._x,r=e._y,i=e._z,a=e._w,o=this.dot(e);o<0&&(n=-n,r=-r,i=-i,a=-a,o=-o);let s=1-t;if(o<.9995){let e=Math.acos(o),c=Math.sin(e);s=Math.sin(s*e)/c,t=Math.sin(t*e)/c,this._x=this._x*s+n*t,this._y=this._y*s+r*t,this._z=this._z*s+i*t,this._w=this._w*s+a*t,this._onChangeCallback()}else this._x=this._x*s+n*t,this._y=this._y*s+r*t,this._z=this._z*s+i*t,this._w=this._w*s+a*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(),r=Math.sqrt(1-n),i=Math.sqrt(n);return this.set(r*Math.sin(e),r*Math.cos(e),i*Math.sin(t),i*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}},R=class e{static#e=e.prototype.isVector3=!0;constructor(e=0,t=0,n=0){this.x=e,this.y=t,this.z=n}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw 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(Tn.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Tn.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6]*r,this.y=i[1]*t+i[4]*n+i[7]*r,this.z=i[2]*t+i[5]*n+i[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,n=this.y,r=this.z,i=e.elements,a=1/(i[3]*t+i[7]*n+i[11]*r+i[15]);return this.x=(i[0]*t+i[4]*n+i[8]*r+i[12])*a,this.y=(i[1]*t+i[5]*n+i[9]*r+i[13])*a,this.z=(i[2]*t+i[6]*n+i[10]*r+i[14])*a,this}applyQuaternion(e){let t=this.x,n=this.y,r=this.z,i=e.x,a=e.y,o=e.z,s=e.w,c=2*(a*r-o*n),l=2*(o*t-i*r),u=2*(i*n-a*t);return this.x=t+s*c+a*u-o*l,this.y=n+s*l+o*c-i*u,this.z=r+s*u+i*l-a*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,r=this.z,i=e.elements;return this.x=i[0]*t+i[4]*n+i[8]*r,this.y=i[1]*t+i[5]*n+i[9]*r,this.z=i[2]*t+i[6]*n+i[10]*r,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=en(this.x,e.x,t.x),this.y=en(this.y,e.y,t.y),this.z=en(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=en(this.x,e,t),this.y=en(this.y,e,t),this.z=en(this.z,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(en(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 n=e.x,r=e.y,i=e.z,a=t.x,o=t.y,s=t.z;return this.x=r*s-i*o,this.y=i*a-n*s,this.z=n*o-r*a,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 wn.copy(this).projectOnVector(e),this.sub(wn)}reflect(e){return this.sub(wn.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(en(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y,r=this.z-e.z;return t*t+n*n+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){let r=Math.sin(t)*e;return this.x=r*Math.sin(n),this.y=Math.cos(t)*e,this.z=r*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){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(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=r,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){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}},wn=new R,Tn=new Cn,En=class e{static#e=e.prototype.isMatrix3=!0;constructor(e,t,n,r,i,a,o,s,c){this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,r,i,a,o,s,c)}set(e,t,n,r,i,a,o,s,c){let l=this.elements;return l[0]=e,l[1]=r,l[2]=o,l[3]=t,l[4]=i,l[5]=s,l[6]=n,l[7]=a,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,r=t.elements,i=this.elements,a=n[0],o=n[3],s=n[6],c=n[1],l=n[4],u=n[7],d=n[2],f=n[5],p=n[8],m=r[0],h=r[3],g=r[6],_=r[1],v=r[4],y=r[7],b=r[2],x=r[5],S=r[8];return i[0]=a*m+o*_+s*b,i[3]=a*h+o*v+s*x,i[6]=a*g+o*y+s*S,i[1]=c*m+l*_+u*b,i[4]=c*h+l*v+u*x,i[7]=c*g+l*y+u*S,i[2]=d*m+f*_+p*b,i[5]=d*h+f*v+p*x,i[8]=d*g+f*y+p*S,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],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8];return t*a*l-t*o*c-n*i*l+n*o*s+r*i*c-r*a*s}invert(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8],u=l*a-o*c,d=o*s-l*i,f=c*i-a*s,p=t*u+n*d+r*f;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);let m=1/p;return e[0]=u*m,e[1]=(r*c-l*n)*m,e[2]=(o*n-r*a)*m,e[3]=d*m,e[4]=(l*t-r*s)*m,e[5]=(r*i-o*t)*m,e[6]=f*m,e[7]=(n*s-c*t)*m,e[8]=(a*t-n*i)*m,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,r,i,a,o){let s=Math.cos(i),c=Math.sin(i);return this.set(n*s,n*c,-n*(s*a+c*o)+a+e,-r*c,r*s,-r*(-c*a+s*o)+o+t,0,0,1),this}scale(e,t){return Wt(`Matrix3: .scale() is deprecated. Use .makeScale() instead.`),this.premultiply(Dn.makeScale(e,t)),this}rotate(e){return Wt(`Matrix3: .rotate() is deprecated. Use .makeRotation() instead.`),this.premultiply(Dn.makeRotation(-e)),this}translate(e,t){return Wt(`Matrix3: .translate() is deprecated. Use .makeTranslation() instead.`),this.premultiply(Dn.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){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 e=0;e<9;e++)if(t[e]!==n[e])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)}},Dn=new En,On=new En().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),kn=new En().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function An(){let e={enabled:!0,workingColorSpace:bt,spaces:{},convert:function(e,t,n){return this.enabled===!1||t===n||!t||!n?e:(this.spaces[t].transfer===`srgb`&&(e.r=Mn(e.r),e.g=Mn(e.g),e.b=Mn(e.b)),this.spaces[t].primaries!==this.spaces[n].primaries&&(e.applyMatrix3(this.spaces[t].toXYZ),e.applyMatrix3(this.spaces[n].fromXYZ)),this.spaces[n].transfer===`srgb`&&(e.r=Nn(e.r),e.g=Nn(e.g),e.b=Nn(e.b)),e)},workingToColorSpace:function(e,t){return this.convert(e,this.workingColorSpace,t)},colorSpaceToWorking:function(e,t){return this.convert(e,t,this.workingColorSpace)},getPrimaries:function(e){return this.spaces[e].primaries},getTransfer:function(e){return e===``?xt:this.spaces[e].transfer},getToneMappingMode:function(e){return this.spaces[e].outputColorSpaceConfig.toneMappingMode||`standard`},getLuminanceCoefficients:function(e,t=this.workingColorSpace){return e.fromArray(this.spaces[t].luminanceCoefficients)},define:function(e){Object.assign(this.spaces,e)},_getMatrix:function(e,t,n){return e.copy(this.spaces[t].toXYZ).multiply(this.spaces[n].fromXYZ)},_getDrawingBufferColorSpace:function(e){return this.spaces[e].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(e=this.workingColorSpace){return this.spaces[e].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(t,n){return Wt(`ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace().`),e.workingToColorSpace(t,n)},toWorkingColorSpace:function(t,n){return Wt(`ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking().`),e.colorSpaceToWorking(t,n)}},t=[.64,.33,.3,.6,.15,.06],n=[.2126,.7152,.0722],r=[.3127,.329];return e.define({[bt]:{primaries:t,whitePoint:r,transfer:xt,toXYZ:On,fromXYZ:kn,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:yt},outputColorSpaceConfig:{drawingBufferColorSpace:yt}},[yt]:{primaries:t,whitePoint:r,transfer:St,toXYZ:On,fromXYZ:kn,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:yt}}}),e}var jn=An();function Mn(e){return e<.04045?e*.0773993808:(e*.9478672986+.0521327014)**2.4}function Nn(e){return e<.0031308?e*12.92:1.055*e**.41666-.055}var Pn,Fn=class{static getDataURL(e,t=`image/png`){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>`u`)return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{Pn===void 0&&(Pn=Rt(`canvas`)),Pn.width=e.width,Pn.height=e.height;let t=Pn.getContext(`2d`);e instanceof ImageData?t.putImageData(e,0,0):t.drawImage(e,0,0,e.width,e.height),n=Pn}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=Rt(`canvas`);t.width=e.width,t.height=e.height;let n=t.getContext(`2d`);n.drawImage(e,0,0,e.width,e.height);let r=n.getImageData(0,0,e.width,e.height),i=r.data;for(let e=0;e1),this.pmremVersion=0,this.normalized=!1}get width(){return this.source.getSize(Bn).x}get height(){return this.source.getSize(Bn).y}get depth(){return this.source.getSize(Bn).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){F(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}let r=this[t];if(r===void 0){F(`Texture.setValues(): property '${t}' does not exist.`);continue}r&&n&&r.isVector2&&n.isVector2||r&&n&&r.isVector3&&n.isVector3||r&&n&&r.isMatrix3&&n.isMatrix3?r.copy(n):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};return Object.keys(this.userData).length>0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:`dispose`})}transformUv(e){if(this.mapping!==300)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case A:e.x-=Math.floor(e.x);break;case j:e.x=e.x<0?0:1;break;case M:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x-=Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case A:e.y-=Math.floor(e.y);break;case j:e.y=e.y<0?0:1;break;case M:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y-=Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}};Vn.DEFAULT_IMAGE=null,Vn.DEFAULT_MAPPING=300,Vn.DEFAULT_ANISOTROPY=1;var Hn=class e{static#e=e.prototype.isVector4=!0;constructor(e=0,t=0,n=0,r=1){this.x=e,this.y=t,this.z=n,this.w=r}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,r){return this.x=e,this.y=t,this.z=n,this.w=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw 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?1:e.w,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,r=this.z,i=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*r+a[12]*i,this.y=a[1]*t+a[5]*n+a[9]*r+a[13]*i,this.z=a[2]*t+a[6]*n+a[10]*r+a[14]*i,this.w=a[3]*t+a[7]*n+a[11]*r+a[15]*i,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);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,r,i,a=.01,o=.1,s=e.elements,c=s[0],l=s[4],u=s[8],d=s[1],f=s[5],p=s[9],m=s[2],h=s[6],g=s[10];if(Math.abs(l-d)s&&e>_?e_?s1);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>>0}enable(e){this.mask|=1<1){for(let e=0;e1){for(let e=0;e0&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),r.up=this.up.toArray(),this.pivot!==null&&(r.pivot=this.pivot.toArray()),this.matrixAutoUpdate===!1&&(r.matrixAutoUpdate=!1),this.morphTargetDictionary!==void 0&&(r.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(r.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(r.type=`InstancedMesh`,r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(r.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(r.type=`BatchedMesh`,r.perObjectFrustumCulled=this.perObjectFrustumCulled,r.sortObjects=this.sortObjects,r.drawRanges=this._drawRanges,r.reservedRanges=this._reservedRanges,r.geometryInfo=this._geometryInfo.map(e=>({...e,boundingBox:e.boundingBox?e.boundingBox.toJSON():void 0,boundingSphere:e.boundingSphere?e.boundingSphere.toJSON():void 0})),r.instanceInfo=this._instanceInfo.map(e=>({...e})),r.availableInstanceIds=this._availableInstanceIds.slice(),r.availableGeometryIds=this._availableGeometryIds.slice(),r.nextIndexStart=this._nextIndexStart,r.nextVertexStart=this._nextVertexStart,r.geometryCount=this._geometryCount,r.maxInstanceCount=this._maxInstanceCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.matricesTexture=this._matricesTexture.toJSON(e),r.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(r.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(r.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(r.boundingBox=this.boundingBox.toJSON()));function i(t,n){return t[n.uuid]===void 0&&(t[n.uuid]=n.toJSON(e)),n.uuid}if(this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=i(e.geometries,this.geometry);let t=this.geometry.parameters;if(t!==void 0&&t.shapes!==void 0){let n=t.shapes;if(Array.isArray(n))for(let t=0,r=n.length;t0){r.children=[];for(let t=0;t0){r.animations=[];for(let t=0;t0&&(n.geometries=t),r.length>0&&(n.materials=r),i.length>0&&(n.textures=i),o.length>0&&(n.images=o),s.length>0&&(n.shapes=s),c.length>0&&(n.skeletons=c),l.length>0&&(n.animations=l),u.length>0&&(n.nodes=u)}return n.object=r,n;function a(e){let t=[];for(let n in e){let r=e[n];delete r.metadata,t.push(r)}return t}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.pivot=e.pivot===null?null:e.pivot.clone(),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 t=0;ts+l?(c.inputState.pinching=!1,this.dispatchEvent({type:`pinchend`,handedness:e.handedness,target:this})):!c.inputState.pinching&&o<=s-l&&(c.inputState.pinching=!0,this.dispatchEvent({type:`pinchstart`,handedness:e.handedness,target:this}))}else s!==null&&e.gripSpace&&(i=t.getPose(e.gripSpace,n),i!==null&&(s.matrix.fromArray(i.transform.matrix),s.matrix.decompose(s.position,s.rotation,s.scale),s.matrixWorldNeedsUpdate=!0,i.linearVelocity?(s.hasLinearVelocity=!0,s.linearVelocity.copy(i.linearVelocity)):s.hasLinearVelocity=!1,i.angularVelocity?(s.hasAngularVelocity=!0,s.angularVelocity.copy(i.angularVelocity)):s.hasAngularVelocity=!1,s.eventsEnabled&&s.dispatchEvent({type:`gripUpdated`,data:e,target:this})));o!==null&&(r=t.getPose(e.targetRaySpace,n),r===null&&i!==null&&(r=i),r!==null&&(o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,r.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(r.linearVelocity)):o.hasLinearVelocity=!1,r.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(r.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(br)))}return o!==null&&(o.visible=r!==null),s!==null&&(s.visible=i!==null),c!==null&&(c.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){let n=new B;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}},Sr={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},Cr={h:0,s:0,l:0},wr={h:0,s:0,l:0};function Tr(e,t,n){return n<0&&(n+=1),n>1&&--n,n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*6*(2/3-n):e}var Er=class{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 t=e;t&&t.isColor?this.copy(t):typeof t==`number`?this.setHex(t):typeof t==`string`&&this.setStyle(t)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=yt){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,jn.colorSpaceToWorking(this,t),this}setRGB(e,t,n,r=jn.workingColorSpace){return this.r=e,this.g=t,this.b=n,jn.colorSpaceToWorking(this,r),this}setHSL(e,t,n,r=jn.workingColorSpace){if(e=tn(e,1),t=en(t,0,1),n=en(n,0,1),t===0)this.r=this.g=this.b=n;else{let r=n<=.5?n*(1+t):n+t-n*t,i=2*n-r;this.r=Tr(i,r,e+1/3),this.g=Tr(i,r,e),this.b=Tr(i,r,e-1/3)}return jn.colorSpaceToWorking(this,r),this}setStyle(e,t=yt){function n(t){t!==void 0&&parseFloat(t)<1&&F(`Color: Alpha component of `+e+` will be ignored.`)}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let i,a=r[1],o=r[2];switch(a){case`rgb`:case`rgba`:if(i=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setRGB(Math.min(255,parseInt(i[1],10))/255,Math.min(255,parseInt(i[2],10))/255,Math.min(255,parseInt(i[3],10))/255,t);if(i=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setRGB(Math.min(100,parseInt(i[1],10))/100,Math.min(100,parseInt(i[2],10))/100,Math.min(100,parseInt(i[3],10))/100,t);break;case`hsl`:case`hsla`:if(i=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setHSL(parseFloat(i[1])/360,parseFloat(i[2])/100,parseFloat(i[3])/100,t);break;default:F(`Color: Unknown color model `+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){let n=r[1],i=n.length;if(i===3)return this.setRGB(parseInt(n.charAt(0),16)/15,parseInt(n.charAt(1),16)/15,parseInt(n.charAt(2),16)/15,t);if(i===6)return this.setHex(parseInt(n,16),t);F(`Color: Invalid hex color `+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=yt){let n=Sr[e.toLowerCase()];return n===void 0?F(`Color: Unknown color `+e):this.setHex(n,t),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=Mn(e.r),this.g=Mn(e.g),this.b=Mn(e.b),this}copyLinearToSRGB(e){return this.r=Nn(e.r),this.g=Nn(e.g),this.b=Nn(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=yt){return jn.workingToColorSpace(Dr.copy(this),e),Math.round(en(Dr.r*255,0,255))*65536+Math.round(en(Dr.g*255,0,255))*256+Math.round(en(Dr.b*255,0,255))}getHexString(e=yt){return(`000000`+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=jn.workingColorSpace){jn.workingToColorSpace(Dr.copy(this),t);let n=Dr.r,r=Dr.g,i=Dr.b,a=Math.max(n,r,i),o=Math.min(n,r,i),s,c,l=(o+a)/2;if(o===a)s=0,c=0;else{let e=a-o;switch(c=l<=.5?e/(a+o):e/(2-a-o),a){case n:s=(r-i)/e+(r0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}},kr=new R,Ar=new R,jr=new R,Mr=new R,Nr=new R,Pr=new R,Fr=new R,Ir=new R,Lr=new R,Rr=new R,zr=new Hn,Br=new Hn,Vr=new Hn,Hr=class e{constructor(e=new R,t=new R,n=new R){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,r){r.subVectors(n,t),kr.subVectors(e,t),r.cross(kr);let i=r.lengthSq();return i>0?r.multiplyScalar(1/Math.sqrt(i)):r.set(0,0,0)}static getBarycoord(e,t,n,r,i){kr.subVectors(r,t),Ar.subVectors(n,t),jr.subVectors(e,t);let a=kr.dot(kr),o=kr.dot(Ar),s=kr.dot(jr),c=Ar.dot(Ar),l=Ar.dot(jr),u=a*c-o*o;if(u===0)return i.set(0,0,0),null;let d=1/u,f=(c*s-o*l)*d,p=(a*l-o*s)*d;return i.set(1-f-p,p,f)}static containsPoint(e,t,n,r){return this.getBarycoord(e,t,n,r,Mr)===null?!1:Mr.x>=0&&Mr.y>=0&&Mr.x+Mr.y<=1}static getInterpolation(e,t,n,r,i,a,o,s){return this.getBarycoord(e,t,n,r,Mr)===null?(s.x=0,s.y=0,`z`in s&&(s.z=0),`w`in s&&(s.w=0),null):(s.setScalar(0),s.addScaledVector(i,Mr.x),s.addScaledVector(a,Mr.y),s.addScaledVector(o,Mr.z),s)}static getInterpolatedAttribute(e,t,n,r,i,a){return zr.setScalar(0),Br.setScalar(0),Vr.setScalar(0),zr.fromBufferAttribute(e,t),Br.fromBufferAttribute(e,n),Vr.fromBufferAttribute(e,r),a.setScalar(0),a.addScaledVector(zr,i.x),a.addScaledVector(Br,i.y),a.addScaledVector(Vr,i.z),a}static isFrontFacing(e,t,n,r){return kr.subVectors(n,t),Ar.subVectors(e,t),kr.cross(Ar).dot(r)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,r){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,t,n,r){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,r),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return kr.subVectors(this.c,this.b),Ar.subVectors(this.a,this.b),kr.cross(Ar).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return e.getNormal(this.a,this.b,this.c,t)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,n){return e.getBarycoord(t,this.a,this.b,this.c,n)}getInterpolation(t,n,r,i,a){return e.getInterpolation(t,this.a,this.b,this.c,n,r,i,a)}containsPoint(t){return e.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return e.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let n=this.a,r=this.b,i=this.c,a,o;Nr.subVectors(r,n),Pr.subVectors(i,n),Ir.subVectors(e,n);let s=Nr.dot(Ir),c=Pr.dot(Ir);if(s<=0&&c<=0)return t.copy(n);Lr.subVectors(e,r);let l=Nr.dot(Lr),u=Pr.dot(Lr);if(l>=0&&u<=l)return t.copy(r);let d=s*u-l*c;if(d<=0&&s>=0&&l<=0)return a=s/(s-l),t.copy(n).addScaledVector(Nr,a);Rr.subVectors(e,i);let f=Nr.dot(Rr),p=Pr.dot(Rr);if(p>=0&&f<=p)return t.copy(i);let m=f*c-s*p;if(m<=0&&c>=0&&p<=0)return o=c/(c-p),t.copy(n).addScaledVector(Pr,o);let h=l*p-f*u;if(h<=0&&u-l>=0&&f-p>=0)return Fr.subVectors(i,r),o=(u-l)/(u-l+(f-p)),t.copy(r).addScaledVector(Fr,o);let g=1/(h+m+d);return a=m*g,o=d*g,t.copy(n).addScaledVector(Nr,a).addScaledVector(Pr,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}},Ur=class{constructor(e=new R(1/0,1/0,1/0),t=new R(-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=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,Gr),Gr.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter($r),ei.subVectors(this.max,$r),qr.subVectors(e.a,$r),Jr.subVectors(e.b,$r),Yr.subVectors(e.c,$r),Xr.subVectors(Jr,qr),Zr.subVectors(Yr,Jr),Qr.subVectors(qr,Yr);let t=[0,-Xr.z,Xr.y,0,-Zr.z,Zr.y,0,-Qr.z,Qr.y,Xr.z,0,-Xr.x,Zr.z,0,-Zr.x,Qr.z,0,-Qr.x,-Xr.y,Xr.x,0,-Zr.y,Zr.x,0,-Qr.y,Qr.x,0];return!ri(t,qr,Jr,Yr,ei)||(t=[1,0,0,0,1,0,0,0,1],!ri(t,qr,Jr,Yr,ei))?!1:(ti.crossVectors(Xr,Zr),t=[ti.x,ti.y,ti.z],ri(t,qr,Jr,Yr,ei))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Gr).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Gr).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(Wr[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Wr[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Wr[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Wr[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Wr[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Wr[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Wr[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Wr[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Wr),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}},Wr=[new R,new R,new R,new R,new R,new R,new R,new R],Gr=new R,Kr=new Ur,qr=new R,Jr=new R,Yr=new R,Xr=new R,Zr=new R,Qr=new R,$r=new R,ei=new R,ti=new R,ni=new R;function ri(e,t,n,r,i){for(let a=0,o=e.length-3;a<=o;a+=3){ni.fromArray(e,a);let o=i.x*Math.abs(ni.x)+i.y*Math.abs(ni.y)+i.z*Math.abs(ni.z),s=t.dot(ni),c=n.dot(ni),l=r.dot(ni);if(Math.max(-Math.max(s,c,l),Math.min(s,c,l))>o)return!1}return!0}var ii=ai();function ai(){let e=new ArrayBuffer(4),t=new Float32Array(e),n=new Uint32Array(e),r=new Uint32Array(512),i=new Uint32Array(512);for(let e=0;e<256;++e){let t=e-127;t<-27?(r[e]=0,r[e|256]=32768,i[e]=24,i[e|256]=24):t<-14?(r[e]=1024>>-t-14,r[e|256]=1024>>-t-14|32768,i[e]=-t-1,i[e|256]=-t-1):t<=15?(r[e]=t+15<<10,r[e|256]=t+15<<10|32768,i[e]=13,i[e|256]=13):t<128?(r[e]=31744,r[e|256]=64512,i[e]=24,i[e|256]=24):(r[e]=31744,r[e|256]=64512,i[e]=13,i[e|256]=13)}let a=new Uint32Array(2048),o=new Uint32Array(64),s=new Uint32Array(64);for(let e=1;e<1024;++e){let t=e<<13,n=0;for(;!(t&8388608);)t<<=1,n-=8388608;t&=-8388609,n+=947912704,a[e]=t|n}for(let e=1024;e<2048;++e)a[e]=939524096+(e-1024<<13);for(let e=1;e<31;++e)o[e]=e<<23;o[31]=1199570944,o[32]=2147483648;for(let e=33;e<63;++e)o[e]=2147483648+(e-32<<23);o[63]=3347054592;for(let e=1;e<64;++e)e!==32&&(s[e]=1024);return{floatView:t,uint32View:n,baseTable:r,shiftTable:i,mantissaTable:a,exponentTable:o,offsetTable:s}}function oi(e){Math.abs(e)>65504&&F(`DataUtils.toHalfFloat(): Value out of range.`),e=en(e,-65504,65504),ii.floatView[0]=e;let t=ii.uint32View[0],n=t>>23&511;return ii.baseTable[n]+((t&8388607)>>ii.shiftTable[n])}function si(e){let t=e>>10;return ii.uint32View[0]=ii.mantissaTable[ii.offsetTable[t]+(e&1023)]+ii.exponentTable[t],ii.floatView[0]}var ci=new R,li=new L,ui=0,di=class extends Jt{constructor(e,t,n=!1){if(super(),Array.isArray(e))throw TypeError(`THREE.BufferAttribute: array should be a Typed Array.`);this.isBufferAttribute=!0,Object.defineProperty(this,`id`,{value:ui++}),this.name=``,this.array=e,this.itemSize=t,this.count=e===void 0?0:e.length/t,this.normalized=n,this.usage=At,this.updateRanges=[],this.gpuType=fe,this.version=0}onUploadCallback(){}set needsUpdate(e){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 r=0,i=this.itemSize;rthis.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius*=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;_i.subVectors(e,this.center);let t=_i.lengthSq();if(t>this.radius*this.radius){let e=Math.sqrt(t),n=(e-this.radius)*.5;this.center.addScaledVector(_i,n/e),this.radius+=n}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(vi.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(_i.copy(e.center).add(vi)),this.expandByPoint(_i.copy(e.center).sub(vi))),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}},bi=0,xi=new qn,Si=new z,Ci=new R,wi=new Ur,Ti=new Ur,Ei=new R,Di=class e extends Jt{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,`id`,{value:bi++}),this.uuid=$t(),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){return Array.isArray(e)?this.index=new(It(e)?pi:fi)(e,1):this.index=e,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;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);let n=this.attributes.normal;if(n!==void 0){let t=new En().getNormalMatrix(e);n.applyNormalMatrix(t),n.needsUpdate=!0}let r=this.attributes.tangent;return r!==void 0&&(r.transformDirection(e),r.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this._transformed=!0,this}applyQuaternion(e){return xi.makeRotationFromQuaternion(e),this.applyMatrix4(xi),this}rotateX(e){return xi.makeRotationX(e),this.applyMatrix4(xi),this}rotateY(e){return xi.makeRotationY(e),this.applyMatrix4(xi),this}rotateZ(e){return xi.makeRotationZ(e),this.applyMatrix4(xi),this}translate(e,t,n){return xi.makeTranslation(e,t,n),this.applyMatrix4(xi),this}scale(e,t,n){return xi.makeScale(e,t,n),this.applyMatrix4(xi),this}lookAt(e){return Si.lookAt(e),Si.updateMatrix(),this.applyMatrix4(Si.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Ci).negate(),this.translate(Ci.x,Ci.y,Ci.z),this}setFromPoints(e){let t=this.getAttribute(`position`);if(t===void 0){let t=[];for(let n=0,r=e.length;nt.count&&F(`BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry.`),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Ur);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){I(`BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.`,this),this.boundingBox.set(new R(-1/0,-1/0,-1/0),new R(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let e=0,n=t.length;e0&&(e.userData=this.userData),this.parameters!==void 0&&this._transformed!==!0){let t=this.parameters;for(let n in t)t[n]!==void 0&&(e[n]=t[n]);return e}e.data={attributes:{}};let t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});let n=this.attributes;for(let t in n){let r=n[t];e.data.attributes[t]=r.toJSON(e.data)}let r={},i=!1;for(let t in this.morphAttributes){let n=this.morphAttributes[t],a=[];for(let t=0,r=n.length;t0&&(r[t]=a,i=!0)}i&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);let a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));let o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.toJSON()),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;n!==null&&this.setIndex(n.clone());let r=e.attributes;for(let e in r){let n=r[e];this.setAttribute(e,n.clone(t))}let i=e.morphAttributes;for(let e in i){let n=[],r=i[e];for(let e=0,i=r.length;e0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(let t in e){let n=e[t];if(n===void 0){F(`Material: parameter '${t}' has value of undefined.`);continue}let r=this[t];if(r===void 0){F(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}r&&r.isColor?r.set(n):r&&r.isVector2&&n&&n.isVector2||r&&r.isEuler&&n&&n.isEuler||r&&r.isVector3&&n&&n.isVector3?r.copy(n):this[t]=n}}toJSON(e){let t=e===void 0||typeof e==`string`;t&&(e={textures:{},images:{}});let n={metadata:{version:4.7,type:`Material`,generator:`Material.toJSON`}};n.uuid=this.uuid,n.type=this.type,this.name!==``&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(n.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==1&&(n.blending=this.blending),this.side!==0&&(n.side=this.side),this.vertexColors===!0&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=!0),this.blendSrc!==204&&(n.blendSrc=this.blendSrc),this.blendDst!==205&&(n.blendDst=this.blendDst),this.blendEquation!==100&&(n.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(n.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(n.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==3&&(n.depthFunc=this.depthFunc),this.depthTest===!1&&(n.depthTest=this.depthTest),this.depthWrite===!1&&(n.depthWrite=this.depthWrite),this.colorWrite===!1&&(n.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==519&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==7680&&(n.stencilFail=this.stencilFail),this.stencilZFail!==7680&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==7680&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.allowOverride===!1&&(n.allowOverride=!1),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!==`round`&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!==`round`&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function r(e){let t=[];for(let n in e){let r=e[n];delete r.metadata,t.push(r)}return t}if(t){let t=r(e.textures),i=r(e.images);t.length>0&&(n.textures=t),i.length>0&&(n.images=i)}return n}fromJSON(e,t){if(e.uuid!==void 0&&(this.uuid=e.uuid),e.name!==void 0&&(this.name=e.name),e.color!==void 0&&this.color!==void 0&&this.color.setHex(e.color),e.roughness!==void 0&&(this.roughness=e.roughness),e.metalness!==void 0&&(this.metalness=e.metalness),e.sheen!==void 0&&(this.sheen=e.sheen),e.sheenColor!==void 0&&(this.sheenColor=new Er().setHex(e.sheenColor)),e.sheenRoughness!==void 0&&(this.sheenRoughness=e.sheenRoughness),e.emissive!==void 0&&this.emissive!==void 0&&this.emissive.setHex(e.emissive),e.specular!==void 0&&this.specular!==void 0&&this.specular.setHex(e.specular),e.specularIntensity!==void 0&&(this.specularIntensity=e.specularIntensity),e.specularColor!==void 0&&this.specularColor!==void 0&&this.specularColor.setHex(e.specularColor),e.shininess!==void 0&&(this.shininess=e.shininess),e.clearcoat!==void 0&&(this.clearcoat=e.clearcoat),e.clearcoatRoughness!==void 0&&(this.clearcoatRoughness=e.clearcoatRoughness),e.dispersion!==void 0&&(this.dispersion=e.dispersion),e.iridescence!==void 0&&(this.iridescence=e.iridescence),e.iridescenceIOR!==void 0&&(this.iridescenceIOR=e.iridescenceIOR),e.iridescenceThicknessRange!==void 0&&(this.iridescenceThicknessRange=e.iridescenceThicknessRange),e.transmission!==void 0&&(this.transmission=e.transmission),e.thickness!==void 0&&(this.thickness=e.thickness),e.attenuationDistance!==void 0&&(this.attenuationDistance=e.attenuationDistance),e.attenuationColor!==void 0&&this.attenuationColor!==void 0&&this.attenuationColor.setHex(e.attenuationColor),e.anisotropy!==void 0&&(this.anisotropy=e.anisotropy),e.anisotropyRotation!==void 0&&(this.anisotropyRotation=e.anisotropyRotation),e.fog!==void 0&&(this.fog=e.fog),e.flatShading!==void 0&&(this.flatShading=e.flatShading),e.blending!==void 0&&(this.blending=e.blending),e.combine!==void 0&&(this.combine=e.combine),e.side!==void 0&&(this.side=e.side),e.shadowSide!==void 0&&(this.shadowSide=e.shadowSide),e.opacity!==void 0&&(this.opacity=e.opacity),e.transparent!==void 0&&(this.transparent=e.transparent),e.alphaTest!==void 0&&(this.alphaTest=e.alphaTest),e.alphaHash!==void 0&&(this.alphaHash=e.alphaHash),e.depthFunc!==void 0&&(this.depthFunc=e.depthFunc),e.depthTest!==void 0&&(this.depthTest=e.depthTest),e.depthWrite!==void 0&&(this.depthWrite=e.depthWrite),e.colorWrite!==void 0&&(this.colorWrite=e.colorWrite),e.blendSrc!==void 0&&(this.blendSrc=e.blendSrc),e.blendDst!==void 0&&(this.blendDst=e.blendDst),e.blendEquation!==void 0&&(this.blendEquation=e.blendEquation),e.blendSrcAlpha!==void 0&&(this.blendSrcAlpha=e.blendSrcAlpha),e.blendDstAlpha!==void 0&&(this.blendDstAlpha=e.blendDstAlpha),e.blendEquationAlpha!==void 0&&(this.blendEquationAlpha=e.blendEquationAlpha),e.blendColor!==void 0&&this.blendColor!==void 0&&this.blendColor.setHex(e.blendColor),e.blendAlpha!==void 0&&(this.blendAlpha=e.blendAlpha),e.stencilWriteMask!==void 0&&(this.stencilWriteMask=e.stencilWriteMask),e.stencilFunc!==void 0&&(this.stencilFunc=e.stencilFunc),e.stencilRef!==void 0&&(this.stencilRef=e.stencilRef),e.stencilFuncMask!==void 0&&(this.stencilFuncMask=e.stencilFuncMask),e.stencilFail!==void 0&&(this.stencilFail=e.stencilFail),e.stencilZFail!==void 0&&(this.stencilZFail=e.stencilZFail),e.stencilZPass!==void 0&&(this.stencilZPass=e.stencilZPass),e.stencilWrite!==void 0&&(this.stencilWrite=e.stencilWrite),e.wireframe!==void 0&&(this.wireframe=e.wireframe),e.wireframeLinewidth!==void 0&&(this.wireframeLinewidth=e.wireframeLinewidth),e.wireframeLinecap!==void 0&&(this.wireframeLinecap=e.wireframeLinecap),e.wireframeLinejoin!==void 0&&(this.wireframeLinejoin=e.wireframeLinejoin),e.rotation!==void 0&&(this.rotation=e.rotation),e.linewidth!==void 0&&(this.linewidth=e.linewidth),e.dashSize!==void 0&&(this.dashSize=e.dashSize),e.gapSize!==void 0&&(this.gapSize=e.gapSize),e.scale!==void 0&&(this.scale=e.scale),e.polygonOffset!==void 0&&(this.polygonOffset=e.polygonOffset),e.polygonOffsetFactor!==void 0&&(this.polygonOffsetFactor=e.polygonOffsetFactor),e.polygonOffsetUnits!==void 0&&(this.polygonOffsetUnits=e.polygonOffsetUnits),e.dithering!==void 0&&(this.dithering=e.dithering),e.alphaToCoverage!==void 0&&(this.alphaToCoverage=e.alphaToCoverage),e.premultipliedAlpha!==void 0&&(this.premultipliedAlpha=e.premultipliedAlpha),e.forceSinglePass!==void 0&&(this.forceSinglePass=e.forceSinglePass),e.allowOverride!==void 0&&(this.allowOverride=e.allowOverride),e.visible!==void 0&&(this.visible=e.visible),e.toneMapped!==void 0&&(this.toneMapped=e.toneMapped),e.userData!==void 0&&(this.userData=e.userData),e.vertexColors!==void 0&&(typeof e.vertexColors==`number`?this.vertexColors=e.vertexColors>0:this.vertexColors=e.vertexColors),e.size!==void 0&&(this.size=e.size),e.sizeAttenuation!==void 0&&(this.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(this.map=t[e.map]||null),e.matcap!==void 0&&(this.matcap=t[e.matcap]||null),e.alphaMap!==void 0&&(this.alphaMap=t[e.alphaMap]||null),e.bumpMap!==void 0&&(this.bumpMap=t[e.bumpMap]||null),e.bumpScale!==void 0&&(this.bumpScale=e.bumpScale),e.normalMap!==void 0&&(this.normalMap=t[e.normalMap]||null),e.normalMapType!==void 0&&(this.normalMapType=e.normalMapType),e.normalScale!==void 0){let t=e.normalScale;Array.isArray(t)===!1&&(t=[t,t]),this.normalScale=new L().fromArray(t)}return e.displacementMap!==void 0&&(this.displacementMap=t[e.displacementMap]||null),e.displacementScale!==void 0&&(this.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(this.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(this.roughnessMap=t[e.roughnessMap]||null),e.metalnessMap!==void 0&&(this.metalnessMap=t[e.metalnessMap]||null),e.emissiveMap!==void 0&&(this.emissiveMap=t[e.emissiveMap]||null),e.emissiveIntensity!==void 0&&(this.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(this.specularMap=t[e.specularMap]||null),e.specularIntensityMap!==void 0&&(this.specularIntensityMap=t[e.specularIntensityMap]||null),e.specularColorMap!==void 0&&(this.specularColorMap=t[e.specularColorMap]||null),e.envMap!==void 0&&(this.envMap=t[e.envMap]||null),e.envMapRotation!==void 0&&this.envMapRotation.fromArray(e.envMapRotation),e.envMapIntensity!==void 0&&(this.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(this.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(this.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(this.lightMap=t[e.lightMap]||null),e.lightMapIntensity!==void 0&&(this.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(this.aoMap=t[e.aoMap]||null),e.aoMapIntensity!==void 0&&(this.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(this.gradientMap=t[e.gradientMap]||null),e.clearcoatMap!==void 0&&(this.clearcoatMap=t[e.clearcoatMap]||null),e.clearcoatRoughnessMap!==void 0&&(this.clearcoatRoughnessMap=t[e.clearcoatRoughnessMap]||null),e.clearcoatNormalMap!==void 0&&(this.clearcoatNormalMap=t[e.clearcoatNormalMap]||null),e.clearcoatNormalScale!==void 0&&(this.clearcoatNormalScale=new L().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(this.iridescenceMap=t[e.iridescenceMap]||null),e.iridescenceThicknessMap!==void 0&&(this.iridescenceThicknessMap=t[e.iridescenceThicknessMap]||null),e.transmissionMap!==void 0&&(this.transmissionMap=t[e.transmissionMap]||null),e.thicknessMap!==void 0&&(this.thicknessMap=t[e.thicknessMap]||null),e.anisotropyMap!==void 0&&(this.anisotropyMap=t[e.anisotropyMap]||null),e.sheenColorMap!==void 0&&(this.sheenColorMap=t[e.sheenColorMap]||null),e.sheenRoughnessMap!==void 0&&(this.sheenRoughnessMap=t[e.sheenRoughnessMap]||null),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 e=t.length;n=Array(e);for(let r=0;r!==e;++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){e===!0&&this.version++}},Ni=class extends Mi{constructor(e){super(),this.isSpriteMaterial=!0,this.type=`SpriteMaterial`,this.color=new Er(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}},Pi=new R,Fi=new R,Ii=new R,Li=new R,Ri=new R,zi=new R,Bi=new R,Vi=class{constructor(e=new R,t=new R(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,Pi)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);let n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){let t=Pi.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Pi.copy(this.origin).addScaledVector(this.direction,t),Pi.distanceToSquared(e))}distanceSqToSegment(e,t,n,r){Fi.copy(e).add(t).multiplyScalar(.5),Ii.copy(t).sub(e).normalize(),Li.copy(this.origin).sub(Fi);let i=e.distanceTo(t)*.5,a=-this.direction.dot(Ii),o=Li.dot(this.direction),s=-Li.dot(Ii),c=Li.lengthSq(),l=Math.abs(1-a*a),u,d,f,p;if(l>0)if(u=a*s-o,d=a*o-s,p=i*l,u>=0)if(d>=-p)if(d<=p){let e=1/l;u*=e,d*=e,f=u*(u+a*d+2*o)+d*(a*u+d+2*s)+c}else d=i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c;else d=-i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c;else d<=-p?(u=Math.max(0,-(-a*i+o)),d=u>0?-i:Math.min(Math.max(-i,-s),i),f=-u*u+d*(d+2*s)+c):d<=p?(u=0,d=Math.min(Math.max(-i,-s),i),f=d*(d+2*s)+c):(u=Math.max(0,-(a*i+o)),d=u>0?i:Math.min(Math.max(-i,-s),i),f=-u*u+d*(d+2*s)+c);else d=a>0?-i:i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,u),r&&r.copy(Fi).addScaledVector(Ii,d),f}intersectSphere(e,t){Pi.subVectors(e.center,this.origin);let n=Pi.dot(this.direction),r=Pi.dot(Pi)-n*n,i=e.radius*e.radius;if(r>i)return null;let a=Math.sqrt(i-r),o=n-a,s=n+a;return s<0?null:o<0?this.at(s,t):this.at(o,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;let n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){let n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,r,i,a,o,s,c=1/this.direction.x,l=1/this.direction.y,u=1/this.direction.z,d=this.origin;return c>=0?(n=(e.min.x-d.x)*c,r=(e.max.x-d.x)*c):(n=(e.max.x-d.x)*c,r=(e.min.x-d.x)*c),l>=0?(i=(e.min.y-d.y)*l,a=(e.max.y-d.y)*l):(i=(e.max.y-d.y)*l,a=(e.min.y-d.y)*l),n>a||i>r||((i>n||isNaN(n))&&(n=i),(a=0?(o=(e.min.z-d.z)*u,s=(e.max.z-d.z)*u):(o=(e.max.z-d.z)*u,s=(e.min.z-d.z)*u),n>s||o>r)||((o>n||n!==n)&&(n=o),(s=0?n:r,t)}intersectsBox(e){return this.intersectBox(e,Pi)!==null}intersectTriangle(e,t,n,r,i){Ri.subVectors(t,e),zi.subVectors(n,e),Bi.crossVectors(Ri,zi);let a=this.direction.dot(Bi),o;if(a>0){if(r)return null;o=1}else if(a<0)o=-1,a=-a;else return null;Li.subVectors(this.origin,e);let s=o*this.direction.dot(zi.crossVectors(Li,zi));if(s<0)return null;let c=o*this.direction.dot(Ri.cross(Li));if(c<0||s+c>a)return null;let l=-o*Li.dot(Bi);return l<0?null:this.at(l/a,i)}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)}},Hi=class extends Mi{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type=`MeshBasicMaterial`,this.color=new Er(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 rr,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap=`round`,this.wireframeLinejoin=`round`,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}},Ui=new qn,Wi=new Vi,Gi=new yi,Ki=new R,qi=new R,Ji=new R,Yi=new R,Xi=new R,Zi=new R,Qi=new R,$i=new R,ea=class extends z{constructor(e=new Di,t=new Hi){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){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){let e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){let n=e[t[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e(e.far-e.near)**2))&&(Ui.copy(i).invert(),Wi.copy(e.ray).applyMatrix4(Ui),!(n.boundingBox!==null&&Wi.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,Wi)))}_computeIntersections(e,t,n){let r,i=this.geometry,a=this.material,o=i.index,s=i.attributes.position,c=i.attributes.uv,l=i.attributes.uv1,u=i.attributes.normal,d=i.groups,f=i.drawRange;if(o!==null)if(Array.isArray(a))for(let i=0,s=d.length;in.far?null:{distance:l,point:$i.clone(),object:e}}function na(e,t,n,r,i,a,o,s,c,l){e.getVertexPosition(s,qi),e.getVertexPosition(c,Ji),e.getVertexPosition(l,Yi);let u=ta(e,t,n,r,qi,Ji,Yi,Qi);if(u){let e=new R;Hr.getBarycoord(Qi,qi,Ji,Yi,e),i&&(u.uv=Hr.getInterpolatedAttribute(i,s,c,l,e,new L)),a&&(u.uv1=Hr.getInterpolatedAttribute(a,s,c,l,e,new L)),o&&(u.normal=Hr.getInterpolatedAttribute(o,s,c,l,e,new R),u.normal.dot(r.direction)>0&&u.normal.multiplyScalar(-1));let t={a:s,b:c,c:l,normal:new R,materialIndex:0};Hr.getNormal(qi,Ji,Yi,t.normal),u.face=t,u.barycoord=e}return u}var ra=class extends Vn{constructor(e=null,t=1,n=1,r,i,a,o,s,c=N,l=N,u,d){super(null,a,o,s,c,l,r,i,u,d),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},ia=class extends di{constructor(e,t,n,r=1){super(e,t,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=r}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){let e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}},aa=new R,oa=new R,sa=new En,ca=class{constructor(e=new R(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,r){return this.normal.set(e,t,n),this.constant=r,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){let r=aa.subVectors(n,t).cross(oa.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(r,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 r=e.delta(aa),i=this.normal.dot(r);if(i===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;let a=-(e.start.dot(this.normal)+this.constant)/i;return n===!0&&(a<0||a>1)?null:t.copy(e.start).addScaledVector(r,a)}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||sa.getNormalMatrix(e),r=this.coplanarPoint(aa).applyMatrix4(e),i=this.normal.applyMatrix3(n).normalize();return this.constant=-r.dot(i),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)}},la=new yi,ua=new L(.5,.5),da=new R,fa=class{constructor(e=new ca,t=new ca,n=new ca,r=new ca,i=new ca,a=new ca){this.planes=[e,t,n,r,i,a]}set(e,t,n,r,i,a){let o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(n),o[3].copy(r),o[4].copy(i),o[5].copy(a),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=Mt,n=!1){let r=this.planes,i=e.elements,a=i[0],o=i[1],s=i[2],c=i[3],l=i[4],u=i[5],d=i[6],f=i[7],p=i[8],m=i[9],h=i[10],g=i[11],_=i[12],v=i[13],y=i[14],b=i[15];if(r[0].setComponents(c-a,f-l,g-p,b-_).normalize(),r[1].setComponents(c+a,f+l,g+p,b+_).normalize(),r[2].setComponents(c+o,f+u,g+m,b+v).normalize(),r[3].setComponents(c-o,f-u,g-m,b-v).normalize(),n)r[4].setComponents(s,d,h,y).normalize(),r[5].setComponents(c-s,f-d,g-h,b-y).normalize();else if(r[4].setComponents(c-s,f-d,g-h,b-y).normalize(),t===2e3)r[5].setComponents(c+s,f+d,g+h,b+y).normalize();else if(t===2001)r[5].setComponents(s,d,h,y).normalize();else throw Error(`THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: `+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),la.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{let t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),la.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(la)}intersectsSprite(e){return la.center.set(0,0,0),la.radius=.7071067811865476+ua.distanceTo(e.center),la.applyMatrix4(e.matrixWorld),this.intersectsSphere(la)}intersectsSphere(e){let t=this.planes,n=e.center,r=-e.radius;for(let e=0;e<6;e++)if(t[e].distanceToPoint(n)0?e.max.x:e.min.x,da.y=r.normal.y>0?e.max.y:e.min.y,da.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(da)<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)}},pa=new qn,ma=class e{constructor(){this.coordinateSystem=Mt,this._frustums=[],this._count=0}setFromArrayCamera(e){let t=e.cameras,n=this._frustums;for(let e=0;e0){let n=e[t[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;er)return;xa.applyMatrix4(e.matrixWorld);let c=t.ray.origin.distanceTo(xa);if(!(ct.far))return{distance:c,point:Sa.clone().applyMatrix4(e.matrixWorld),index:o,face:null,faceIndex:null,barycoord:null,object:e}}var Ta=new R,Ea=new R,Da=class extends Ca{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 e=0,r=t.count;e0){let n=e[t[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;ei.far)return;a.push({distance:c,distanceToRay:Math.sqrt(s),point:n,index:t,face:null,faceIndex:null,barycoord:null,object:o})}}var Fa=class extends Vn{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=N,this.minFilter=N,this.generateMipmaps=!1,this.needsUpdate=!0}},Ia=class extends Vn{constructor(e=[],t=301,n,r,i,a,o,s,c,l){super(e,t,n,r,i,a,o,s,c,l),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}},La=class extends Vn{constructor(e,t,n=de,r,i,a,o=N,s=N,c,l=Se,u=1){if(l!==1026&&l!==1027)throw Error(`THREE.DepthTexture: format must be either THREE.DepthFormat or THREE.DepthStencilFormat`);super({width:e,height:t,depth:u},r,i,a,o,s,l,n,c),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new Ln(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){let t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}},Ra=class extends La{constructor(e,t=de,n=301,r,i,a=N,o=N,s,c=Se){let l={width:e,height:e,depth:1},u=[l,l,l,l,l,l];super(e,e,t,n,r,i,a,o,s,c),this.image=u,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}},za=class extends Vn{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}},Ba=class e extends Di{constructor(e=1,t=1,n=1,r=1,i=1,a=1){super(),this.type=`BoxGeometry`,this.parameters={width:e,height:t,depth:n,widthSegments:r,heightSegments:i,depthSegments:a};let o=this;r=Math.floor(r),i=Math.floor(i),a=Math.floor(a);let s=[],c=[],l=[],u=[],d=0,f=0;p(`z`,`y`,`x`,-1,-1,n,t,e,a,i,0),p(`z`,`y`,`x`,1,-1,n,t,-e,a,i,1),p(`x`,`z`,`y`,1,1,e,n,t,r,a,2),p(`x`,`z`,`y`,1,-1,e,n,-t,r,a,3),p(`x`,`y`,`z`,1,-1,e,t,n,r,i,4),p(`x`,`y`,`z`,-1,-1,e,t,-n,r,i,5),this.setIndex(s),this.setAttribute(`position`,new hi(c,3)),this.setAttribute(`normal`,new hi(l,3)),this.setAttribute(`uv`,new hi(u,2));function p(e,t,n,r,i,a,p,m,h,g,_){let v=a/h,y=p/g,b=a/2,x=p/2,S=m/2,C=h+1,w=g+1,T=0,E=0,D=new R;for(let a=0;a0?1:-1,l.push(D.x,D.y,D.z),u.push(s/h),u.push(1-a/g),T+=1}for(let e=0;e0&&v(!0),t>0&&v(!1)),this.setIndex(l),this.setAttribute(`position`,new hi(u,3)),this.setAttribute(`normal`,new hi(d,3)),this.setAttribute(`uv`,new hi(f,2));function _(){let a=new R,_=new R,v=0,y=(t-e)/n;for(let c=0;c<=i;c++){let l=[],g=c/i,v=g*(t-e)+e;for(let e=0;e<=r;e++){let t=e/r,i=t*s+o,c=Math.sin(i),m=Math.cos(i);_.x=v*c,_.y=-g*n+h,_.z=v*m,u.push(_.x,_.y,_.z),a.set(c,y,m).normalize(),d.push(a.x,a.y,a.z),f.push(t,1-g),l.push(p++)}m.push(l)}for(let n=0;n0||r!==0)&&(l.push(a,o,c),v+=3),(t>0||r!==i-1)&&(l.push(o,s,c),v+=3)}c.addGroup(g,v,0),g+=v}function v(n){let i=p,a=new L,m=new R,_=0,v=n===!0?e:t,y=n===!0?1:-1;for(let e=1;e<=r;e++)u.push(0,h*y,0),d.push(0,y,0),f.push(.5,.5),p++;let b=p;for(let e=0;e<=r;e++){let t=e/r*s+o,n=Math.cos(t),i=Math.sin(t);m.x=v*i,m.y=h*y,m.z=v*n,u.push(m.x,m.y,m.z),d.push(0,y,0),a.x=n*.5+.5,a.y=i*.5*y+.5,f.push(a.x,a.y),p++}for(let e=0;e0)s=r-1;else{s=r;break}if(r=s,n[r]===a)return r/(i-1);let l=n[r],u=n[r+1]-l,d=(a-l)/u;return(r+d)/(i-1)}getTangent(e,t){let n=1e-4,r=e-n,i=e+n;r<0&&(r=0),i>1&&(i=1);let a=this.getPoint(r),o=this.getPoint(i),s=t||(a.isVector2?new L:new R);return s.copy(o).sub(a).normalize(),s}getTangentAt(e,t){let n=this.getUtoTmapping(e);return this.getTangent(n,t)}computeFrenetFrames(e,t=!1){let n=new R,r=[],i=[],a=[],o=new R,s=new qn;for(let t=0;t<=e;t++){let n=t/e;r[t]=this.getTangentAt(n,new R)}i[0]=new R,a[0]=new R;let c=Number.MAX_VALUE,l=Math.abs(r[0].x),u=Math.abs(r[0].y),d=Math.abs(r[0].z);l<=c&&(c=l,n.set(1,0,0)),u<=c&&(c=u,n.set(0,1,0)),d<=c&&n.set(0,0,1),o.crossVectors(r[0],n).normalize(),i[0].crossVectors(r[0],o),a[0].crossVectors(r[0],i[0]);for(let t=1;t<=e;t++){if(i[t]=i[t-1].clone(),a[t]=a[t-1].clone(),o.crossVectors(r[t-1],r[t]),o.length()>2**-52){o.normalize();let e=Math.acos(en(r[t-1].dot(r[t]),-1,1));i[t].applyMatrix4(s.makeRotationAxis(o,e))}a[t].crossVectors(r[t],i[t])}if(t===!0){let t=Math.acos(en(i[0].dot(i[e]),-1,1));t/=e,r[0].dot(o.crossVectors(i[0],i[e]))>0&&(t=-t);for(let n=1;n<=e;n++)i[n].applyMatrix4(s.makeRotationAxis(r[n],t*n)),a[n].crossVectors(r[n],i[n])}return{tangents:r,normals:i,binormals:a}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){let e={metadata:{version:4.7,type:`Curve`,generator:`Curve.toJSON`}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}},Wa=class extends Ua{constructor(e=0,t=0,n=1,r=1,i=0,a=Math.PI*2,o=!1,s=0){super(),this.isEllipseCurve=!0,this.type=`EllipseCurve`,this.aX=e,this.aY=t,this.xRadius=n,this.yRadius=r,this.aStartAngle=i,this.aEndAngle=a,this.aClockwise=o,this.aRotation=s}getPoint(e,t=new L){let n=t,r=Math.PI*2,i=this.aEndAngle-this.aStartAngle,a=Math.abs(i)<2**-52;for(;i<0;)i+=r;for(;i>r;)i-=r;i<2**-52&&(i=a?0:r),this.aClockwise===!0&&!a&&(i===r?i=-r:i-=r);let o=this.aStartAngle+e*i,s=this.aX+this.xRadius*Math.cos(o),c=this.aY+this.yRadius*Math.sin(o);if(this.aRotation!==0){let e=Math.cos(this.aRotation),t=Math.sin(this.aRotation),n=s-this.aX,r=c-this.aY;s=n*e-r*t+this.aX,c=n*t+r*e+this.aY}return n.set(s,c)}copy(e){return super.copy(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}toJSON(){let e=super.toJSON();return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e}fromJSON(e){return super.fromJSON(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}},Ga=class extends Wa{constructor(e,t,n,r,i,a){super(e,t,n,n,r,i,a),this.isArcCurve=!0,this.type=`ArcCurve`}};function Ka(){let e=0,t=0,n=0,r=0;function i(i,a,o,s){e=i,t=o,n=-3*i+3*a-2*o-s,r=2*i-2*a+o+s}return{initCatmullRom:function(e,t,n,r,a){i(t,n,a*(n-e),a*(r-t))},initNonuniformCatmullRom:function(e,t,n,r,a,o,s){let c=(t-e)/a-(n-e)/(a+o)+(n-t)/o,l=(n-t)/o-(r-t)/(o+s)+(r-n)/s;c*=o,l*=o,i(t,n,c,l)},calc:function(i){let a=i*i,o=a*i;return e+t*i+n*a+r*o}}}var qa=new R,Ja=new R,Ya=new Ka,Xa=new Ka,Za=new Ka,Qa=class extends Ua{constructor(e=[],t=!1,n=`centripetal`,r=.5){super(),this.isCatmullRomCurve3=!0,this.type=`CatmullRomCurve3`,this.points=e,this.closed=t,this.curveType=n,this.tension=r}getPoint(e,t=new R){let n=t,r=this.points,i=r.length,a=(i-(this.closed?0:1))*e,o=Math.floor(a),s=a-o;this.closed?o+=o>0?0:(Math.floor(Math.abs(o)/i)+1)*i:s===0&&o===i-1&&(o=i-2,s=1);let c,l;this.closed||o>0?c=r[(o-1)%i]:(Ja.subVectors(r[0],r[1]).add(r[0]),c=Ja);let u=r[o%i],d=r[(o+1)%i];if(this.closed||o+2r.length-2?r.length-1:a+1],u=r[a>r.length-3?r.length-1:a+2];return n.set($a(o,s.x,c.x,l.x,u.x),$a(o,s.y,c.y,l.y,u.y)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t=n){let e=r[i]-n,a=this.curves[i],o=a.getLength(),s=o===0?0:1-e/o;return a.getPointAt(s,t)}i++}return null}getLength(){let e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;let e=[],t=0;for(let n=0,r=this.curves.length;n1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,n=e.curves.length;t0){let e=c.getPoint(0);e.equals(this.currentPoint)||this.lineTo(e.x,e.y)}this.curves.push(c);let l=c.getPoint(1);return this.currentPoint.copy(l),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){let e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}},bo=class extends yo{constructor(e){super(e),this.uuid=$t(),this.type=`Shape`,this.holes=[]}getPointsHoles(e){let t=[];for(let n=0,r=this.holes.length;n80*n){s=e[0],c=e[1];let t=s,r=c;for(let a=n;at&&(t=n),i>r&&(r=i)}l=Math.max(t-s,r-c),l=l===0?0:32767/l}return wo(a,o,n,s,c,l,0),o}function So(e,t,n,r,i){let a;if(i===$o(e,t,n,r)>0)for(let i=t;i=t;i-=r)a=Xo(i/r|0,e[i],e[i+1],a);return a&&Ho(a,a.next)&&(Zo(a),a=a.next),a}function Co(e,t){if(!e)return e;t||=e;let n=e,r;do if(r=!1,!n.steiner&&(Ho(n,n.next)||Vo(n.prev,n,n.next)===0)){if(Zo(n),n=t=n.prev,n===n.next)break;r=!0}else n=n.next;while(r||n!==t);return t}function wo(e,t,n,r,i,a,o){if(!e)return;!o&&a&&Po(e,r,i,a);let s=e;for(;e.prev!==e.next;){let c=e.prev,l=e.next;if(a?Eo(e,r,i,a):To(e)){t.push(c.i,e.i,l.i),Zo(e),e=l.next,s=l.next;continue}if(e=l,e===s){o?o===1?(e=Do(Co(e),t),wo(e,t,n,r,i,a,2)):o===2&&Oo(e,t,n,r,i,a):wo(Co(e),t,n,r,i,a,1);break}}}function To(e){let t=e.prev,n=e,r=e.next;if(Vo(t,n,r)>=0)return!1;let i=t.x,a=n.x,o=r.x,s=t.y,c=n.y,l=r.y,u=Math.min(i,a,o),d=Math.min(s,c,l),f=Math.max(i,a,o),p=Math.max(s,c,l),m=r.next;for(;m!==t;){if(m.x>=u&&m.x<=f&&m.y>=d&&m.y<=p&&zo(i,s,a,c,o,l,m.x,m.y)&&Vo(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function Eo(e,t,n,r){let i=e.prev,a=e,o=e.next;if(Vo(i,a,o)>=0)return!1;let s=i.x,c=a.x,l=o.x,u=i.y,d=a.y,f=o.y,p=Math.min(s,c,l),m=Math.min(u,d,f),h=Math.max(s,c,l),g=Math.max(u,d,f),_=Io(p,m,t,n,r),v=Io(h,g,t,n,r),y=e.prevZ,b=e.nextZ;for(;y&&y.z>=_&&b&&b.z<=v;){if(y.x>=p&&y.x<=h&&y.y>=m&&y.y<=g&&y!==i&&y!==o&&zo(s,u,c,d,l,f,y.x,y.y)&&Vo(y.prev,y,y.next)>=0||(y=y.prevZ,b.x>=p&&b.x<=h&&b.y>=m&&b.y<=g&&b!==i&&b!==o&&zo(s,u,c,d,l,f,b.x,b.y)&&Vo(b.prev,b,b.next)>=0))return!1;b=b.nextZ}for(;y&&y.z>=_;){if(y.x>=p&&y.x<=h&&y.y>=m&&y.y<=g&&y!==i&&y!==o&&zo(s,u,c,d,l,f,y.x,y.y)&&Vo(y.prev,y,y.next)>=0)return!1;y=y.prevZ}for(;b&&b.z<=v;){if(b.x>=p&&b.x<=h&&b.y>=m&&b.y<=g&&b!==i&&b!==o&&zo(s,u,c,d,l,f,b.x,b.y)&&Vo(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function Do(e,t){let n=e;do{let r=n.prev,i=n.next.next;!Ho(r,i)&&Uo(r,n,n.next,i)&&qo(r,i)&&qo(i,r)&&(t.push(r.i,n.i,i.i),Zo(n),Zo(n.next),n=e=i),n=n.next}while(n!==e);return Co(n)}function Oo(e,t,n,r,i,a){let o=e;do{let e=o.next.next;for(;e!==o.prev;){if(o.i!==e.i&&Bo(o,e)){let s=Yo(o,e);o=Co(o,o.next),s=Co(s,s.next),wo(o,t,n,r,i,a,0),wo(s,t,n,r,i,a,0);return}e=e.next}o=o.next}while(o!==e)}function ko(e,t,n,r){let i=[];for(let n=0,a=t.length;n=n.next.y&&n.next.y!==n.y){let e=n.x+(i-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(e<=r&&e>a&&(a=e,o=n.x=n.x&&n.x>=c&&r!==n.x&&Ro(io.x||n.x===o.x&&No(o,n)))&&(o=n,u=t)}n=n.next}while(n!==s);return o}function No(e,t){return Vo(e.prev,e,t.prev)<0&&Vo(t.next,e,e.next)<0}function Po(e,t,n,r){let i=e;do i.z===0&&(i.z=Io(i.x,i.y,t,n,r)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==e);i.prevZ.nextZ=null,i.prevZ=null,Fo(i)}function Fo(e){let t,n=1;do{let r=e,i;e=null;let a=null;for(t=0;r;){t++;let o=r,s=0;for(let e=0;e0||c>0&&o;)s!==0&&(c===0||!o||r.z<=o.z)?(i=r,r=r.nextZ,s--):(i=o,o=o.nextZ,c--),a?a.nextZ=i:e=i,i.prevZ=a,a=i;r=o}a.nextZ=null,n*=2}while(t>1);return e}function Io(e,t,n,r,i){return e=(e-n)*i|0,t=(t-r)*i|0,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,e|t<<1}function Lo(e){let t=e,n=e;do(t.x=(e-o)*(a-s)&&(e-o)*(r-s)>=(n-o)*(t-s)&&(n-o)*(a-s)>=(i-o)*(r-s)}function zo(e,t,n,r,i,a,o,s){return!(e===o&&t===s)&&Ro(e,t,n,r,i,a,o,s)}function Bo(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!Ko(e,t)&&(qo(e,t)&&qo(t,e)&&Jo(e,t)&&(Vo(e.prev,e,t.prev)||Vo(e,t.prev,t))||Ho(e,t)&&Vo(e.prev,e,e.next)>0&&Vo(t.prev,t,t.next)>0)}function Vo(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function Ho(e,t){return e.x===t.x&&e.y===t.y}function Uo(e,t,n,r){let i=Go(Vo(e,t,n)),a=Go(Vo(e,t,r)),o=Go(Vo(n,r,e)),s=Go(Vo(n,r,t));return!!(i!==a&&o!==s||i===0&&Wo(e,n,t)||a===0&&Wo(e,r,t)||o===0&&Wo(n,e,r)||s===0&&Wo(n,t,r))}function Wo(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function Go(e){return e>0?1:e<0?-1:0}function Ko(e,t){let n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&Uo(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}function qo(e,t){return Vo(e.prev,e,e.next)<0?Vo(e,t,e.next)>=0&&Vo(e,e.prev,t)>=0:Vo(e,t,e.prev)<0||Vo(e,e.next,t)<0}function Jo(e,t){let n=e,r=!1,i=(e.x+t.x)/2,a=(e.y+t.y)/2;do n.y>a!=n.next.y>a&&n.next.y!==n.y&&i<(n.next.x-n.x)*(a-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next;while(n!==e);return r}function Yo(e,t){let n=Qo(e.i,e.x,e.y),r=Qo(t.i,t.x,t.y),i=e.next,a=t.prev;return e.next=t,t.prev=e,n.next=i,i.prev=n,r.next=n,n.prev=r,a.next=r,r.prev=a,r}function Xo(e,t,n,r){let i=Qo(e,t,n);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function Zo(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function Qo(e,t,n){return{i:e,x:t,y:n,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function $o(e,t,n,r){let i=0;for(let a=t,o=n-r;a2&&e[t-1].equals(e[0])&&e.pop()}function rs(e,t){for(let n=0;n2**-52){let d=Math.sqrt(u),f=Math.sqrt(c*c+l*l),p=t.x-s/d,m=t.y+o/d,h=n.x-l/f,g=n.y+c/f,_=((h-p)*l-(g-m)*c)/(o*l-s*c);r=p+o*_-e.x,i=m+s*_-e.y;let v=r*r+i*i;if(v<=2)return new L(r,i);a=Math.sqrt(v/2)}else{let e=!1;o>2**-52?c>2**-52&&(e=!0):o<-(2**-52)?c<-(2**-52)&&(e=!0):Math.sign(s)===Math.sign(l)&&(e=!0),e?(r=-s,i=o,a=Math.sqrt(u)):(r=o,i=s,a=Math.sqrt(u/2))}return new L(r/a,i/a)}let j=[];for(let e=0,t=D.length,n=t-1,r=e+1;e=0;e--){let t=e/p,n=u*Math.cos(t*Math.PI/2),r=d*Math.sin(t*Math.PI/2)+f;for(let e=0,t=D.length;e=0;){let r=n,i=n-1;i<0&&(i=e.length-1);for(let e=0,n=s+p*2;e0)&&f.push(t,i,c),(e!==n-1||s0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;let n={};for(let e in this.extensions)this.extensions[e]===!0&&(n[e]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}fromJSON(e,t){if(super.fromJSON(e,t),e.uniforms!==void 0)for(let n in e.uniforms){let r=e.uniforms[n];switch(this.uniforms[n]={},r.type){case`t`:this.uniforms[n].value=t[r.value]||null;break;case`c`:this.uniforms[n].value=new Er().setHex(r.value);break;case`v2`:this.uniforms[n].value=new L().fromArray(r.value);break;case`v3`:this.uniforms[n].value=new R().fromArray(r.value);break;case`v4`:this.uniforms[n].value=new Hn().fromArray(r.value);break;case`m3`:this.uniforms[n].value=new En().fromArray(r.value);break;case`m4`:this.uniforms[n].value=new qn().fromArray(r.value);break;default:this.uniforms[n].value=r.value}}if(e.defines!==void 0&&(this.defines=e.defines),e.vertexShader!==void 0&&(this.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(this.fragmentShader=e.fragmentShader),e.glslVersion!==void 0&&(this.glslVersion=e.glslVersion),e.extensions!==void 0)for(let t in e.extensions)this.extensions[t]=e.extensions[t];return e.lights!==void 0&&(this.lights=e.lights),e.clipping!==void 0&&(this.clipping=e.clipping),this}},Ss=class extends xs{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type=`RawShaderMaterial`}},Cs=class extends Mi{constructor(e){super(),this.isMeshStandardMaterial=!0,this.type=`MeshStandardMaterial`,this.defines={STANDARD:``},this.color=new Er(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 Er(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new L(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 rr,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}},ws=class extends Cs{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 L(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,`reflectivity`,{get:function(){return en(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(e){this.ior=(1+.4*e)/(1-.4*e)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new Er(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 Er(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new Er(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){this._anisotropy>0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){this._dispersion>0!=e>0&&this.version++,this._dispersion=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:``,PHYSICAL:``},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.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.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}},Ts=class extends Mi{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type=`MeshPhongMaterial`,this.color=new Er(16777215),this.specular=new Er(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Er(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new L(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new rr,this.combine=0,this.reflectivity=1,this.envMapIntensity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap=`round`,this.wireframeLinejoin=`round`,this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.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}},Es=class extends Mi{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:``},this.type=`MeshToonMaterial`,this.color=new Er(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Er(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new L(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap=`round`,this.wireframeLinejoin=`round`,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.gradientMap=e.gradientMap,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}},Ds=class extends Mi{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type=`MeshNormalMaterial`,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new L(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this}},Os=class extends Mi{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type=`MeshLambertMaterial`,this.color=new Er(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Er(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new L(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new rr,this.combine=0,this.reflectivity=1,this.envMapIntensity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap=`round`,this.wireframeLinejoin=`round`,this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.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}},ks=class extends Mi{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type=`MeshDepthMaterial`,this.depthPacking=vt,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}},As=class extends Mi{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}},js=class extends Mi{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:``},this.type=`MeshMatcapMaterial`,this.color=new Er(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new L(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={MATCAP:``},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this.fog=e.fog,this}},Ms=class extends ha{constructor(e){super(),this.isLineDashedMaterial=!0,this.type=`LineDashedMaterial`,this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}};function Ns(e,t){return!e||e.constructor===t?e:typeof t.BYTES_PER_ELEMENT==`number`?new t(e):Array.prototype.slice.call(e)}var Ps=class{constructor(e,t,n,r){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=r===void 0?new t.constructor(n):r,this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){let t=this.parameterPositions,n=this._cachedIndex,r=t[n],i=t[n-1];validate_interval:{seek:{let a;linear_scan:{forward_scan:if(!(e=i)){let o=t[1];e=i)break seek}a=n,n=0;break linear_scan}break validate_interval}for(;n>>1;et;)--a;if(++a,i!==0||a!==r){i>=a&&(a=Math.max(a,1),i=a-1);let e=this.getValueSize();this.times=n.slice(i,a),this.values=this.values.slice(i*e,a*e)}return this}validate(){let e=!0,t=this.getValueSize();t-Math.floor(t)!==0&&(I(`KeyframeTrack: Invalid value size in track.`,this),e=!1);let n=this.times,r=this.values,i=n.length;i===0&&(I(`KeyframeTrack: Track is empty.`,this),e=!1);let a=null;for(let t=0;t!==i;t++){let r=n[t];if(typeof r==`number`&&isNaN(r)){I(`KeyframeTrack: Time is not a valid number.`,this,t,r),e=!1;break}if(a!==null&&a>r){I(`KeyframeTrack: Out of order keys.`,this,t,r,a),e=!1;break}a=r}if(r!==void 0&&Lt(r))for(let t=0,n=r.length;t!==n;++t){let n=r[t];if(isNaN(n)){I(`KeyframeTrack: Value is not a valid number.`,this,t,n),e=!1;break}}return e}optimize(){let e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),r=this.getInterpolation()===pt,i=e.length-1,a=1;for(let o=1;o0){e[a]=e[i];for(let e=i*n,r=a*n,o=0;o!==n;++o)t[r+o]=t[e+o];++a}return a===e.length?(this.times=e,this.values=t):(this.times=e.slice(0,a),this.values=t.slice(0,a*n)),this}clone(){let e=this.times.slice(),t=this.values.slice(),n=this.constructor,r=new n(this.name,e,t);return r.createInterpolant=this.createInterpolant,r}};zs.prototype.ValueTypeName=``,zs.prototype.TimeBufferType=Float32Array,zs.prototype.ValueBufferType=Float32Array,zs.prototype.DefaultInterpolation=ft;var Bs=class extends zs{constructor(e,t,n){super(e,t,n)}};Bs.prototype.ValueTypeName=`bool`,Bs.prototype.ValueBufferType=Array,Bs.prototype.DefaultInterpolation=dt,Bs.prototype.InterpolantFactoryMethodLinear=void 0,Bs.prototype.InterpolantFactoryMethodSmooth=void 0;var Vs=class extends zs{constructor(e,t,n,r){super(e,t,n,r)}};Vs.prototype.ValueTypeName=`color`;var Hs=class extends zs{constructor(e,t,n,r){super(e,t,n,r)}};Hs.prototype.ValueTypeName=`number`;var Us=class extends Ps{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e,t,n,r){let i=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=(n-t)/(r-t),c=e*o;for(let e=c+o;c!==e;c+=4)Cn.slerpFlat(i,0,a,c-o,a,c,s);return i}},Ws=class extends zs{constructor(e,t,n,r){super(e,t,n,r)}InterpolantFactoryMethodLinear(e){return new Us(this.times,this.values,this.getValueSize(),e)}};Ws.prototype.ValueTypeName=`quaternion`,Ws.prototype.InterpolantFactoryMethodSmooth=void 0;var Gs=class extends zs{constructor(e,t,n){super(e,t,n)}};Gs.prototype.ValueTypeName=`string`,Gs.prototype.ValueBufferType=Array,Gs.prototype.DefaultInterpolation=dt,Gs.prototype.InterpolantFactoryMethodLinear=void 0,Gs.prototype.InterpolantFactoryMethodSmooth=void 0;var Ks=class extends zs{constructor(e,t,n,r){super(e,t,n,r)}};Ks.prototype.ValueTypeName=`vector`;var qs={enabled:!1,files:{},add:function(e,t){this.enabled!==!1&&(Js(e)||(this.files[e]=t))},get:function(e){if(this.enabled!==!1&&!Js(e))return this.files[e]},remove:function(e){delete this.files[e]},clear:function(){this.files={}}};function Js(e){try{let t=e.slice(e.indexOf(`:`)+1);return new URL(t).protocol===`blob:`}catch{return!1}}var Ys=new class{constructor(e,t,n){let r=this,i=!1,a=0,o=0,s,c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this._abortController=null,this.itemStart=function(e){o++,i===!1&&r.onStart!==void 0&&r.onStart(e,a,o),i=!0},this.itemEnd=function(e){a++,r.onProgress!==void 0&&r.onProgress(e,a,o),a===o&&(i=!1,r.onLoad!==void 0&&r.onLoad())},this.itemError=function(e){r.onError!==void 0&&r.onError(e)},this.resolveURL=function(e){return e=e.normalize(`NFC`),s?s(e):e},this.setURLModifier=function(e){return s=e,this},this.addHandler=function(e,t){return c.push(e,t),this},this.removeHandler=function(e){let t=c.indexOf(e);return t!==-1&&c.splice(t,2),this},this.getHandler=function(e){for(let t=0,n=c.length;t=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Zc).distanceTo(e)}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}},$c=new R,el=new R,tl=new R,nl=new R,rl=new R,il=new R,al=new R,ol=class{constructor(e=new R,t=new R){this.start=e,this.end=t}set(e,t){return this.start.copy(e),this.end.copy(t),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,t){return this.delta(t).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,t){$c.subVectors(e,this.start),el.subVectors(this.end,this.start);let n=el.dot(el);if(n===0)return 0;let r=el.dot($c)/n;return t&&(r=en(r,0,1)),r}closestPointToPoint(e,t,n){let r=this.closestPointToPointParameter(e,t);return this.delta(n).multiplyScalar(r).add(this.start)}distanceSqToLine3(e,t=il,n=al){let r=1e-8*1e-8,i,a,o=this.start,s=e.start,c=this.end,l=e.end;tl.subVectors(c,o),nl.subVectors(l,s),rl.subVectors(o,s);let u=tl.dot(tl),d=nl.dot(nl),f=nl.dot(rl);if(u<=r&&d<=r)return t.copy(o),n.copy(s),t.sub(n),t.dot(t);if(u<=r)i=0,a=f/d,a=en(a,0,1);else{let e=tl.dot(rl);if(d<=r)a=0,i=en(-e/u,0,1);else{let t=tl.dot(nl),n=u*d-t*t;i=n===0?0:en((t*f-e*d)/n,0,1),a=(t*i+f)/d,a<0?(a=0,i=en(-e/u,0,1)):a>1&&(a=1,i=en((t-e)/u,0,1))}}return t.copy(o).addScaledVector(tl,i),n.copy(s).addScaledVector(nl,a),t.distanceToSquared(n)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return new this.constructor().copy(this)}},sl=class{constructor(){this.type=`ShapePath`,this.color=new Er,this.subPaths=[],this.currentPath=null,this.userData={}}moveTo(e,t){return this.currentPath=new yo,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}quadraticCurveTo(e,t,n,r){return this.currentPath.quadraticCurveTo(e,t,n,r),this}bezierCurveTo(e,t,n,r,i,a){return this.currentPath.bezierCurveTo(e,t,n,r,i,a),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(){function e(e,t){let n=!1,r=t.length;for(let i=0,a=r-1;ie.y!=o.y>e.y&&e.x<(o.x-r.x)*(e.y-r.y)/(o.y-r.y)+r.x&&(n=!n)}return n}function t(t,n){let r=n.getCenter(new L);if(e(r,t))return r;let i=r.y,a=[],o=t.length;for(let e=0;ei!=r.y>i){let e=n.x+(i-n.y)*(r.x-n.x)/(r.y-n.y);a.push(e)}}return a.length>1&&(a.sort((e,t)=>e-t),r.x=(a[0]+a[1])/2),r}let n=this.userData.style&&this.userData.style.fillRule||`nonzero`;n!==`nonzero`&&n!==`evenodd`&&(F(`Fill-rule "`+n+`" is not supported, falling back to "nonzero".`),n=`nonzero`);let r=n===`nonzero`?(e=>e!==0):(e=>(e&1)!=0),i=[];for(let e of this.subPaths){let n=e.getPoints();if(n.length<3)continue;let r=ts.area(n);if(r===0)continue;let a=new Qc;for(let e=0;et.absArea-e.absArea);for(let t=0;t=0;r--){let t=i[r];if(t.boundingBox.containsBox(n.boundingBox)&&e(n.interiorPoint,t.points)){n.container=t.exclude?t.container:t,a=t.winding,n.winding+=a;break}}r(n.winding)===r(a)&&(n.exclude=!0)}for(let e of i)e.exclude||(e.role=e.container===null||e.container.role===`hole`?`outer`:`hole`);let a=[],o=new Map;for(let e of i){if(e.exclude||e.role!==`outer`)continue;let t=new bo;t.curves=e.subPath.curves,a.push(t),o.set(e,t)}for(let e of i){if(e.exclude||e.role!==`hole`)continue;let t=o.get(e.container);if(!t)continue;let n=new yo;n.curves=e.subPath.curves,t.holes.push(n)}return a}},cl=class extends Jt{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(e===void 0){F(`Controls: connect() now requires an element.`);return}this.domElement!==null&&this.disconnect(),this.domElement=e}disconnect(){}dispose(){}update(){}};function ll(e,t,n,r){let i=ul(r);switch(n){case ye:return e*t;case we:return e*t/i.components*i.byteLength;case Te:return e*t/i.components*i.byteLength;case Ee:return e*t*2/i.components*i.byteLength;case De:return e*t*2/i.components*i.byteLength;case be:return e*t*3/i.components*i.byteLength;case xe:return e*t*4/i.components*i.byteLength;case ke:return e*t*4/i.components*i.byteLength;case Ae:case je:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*8;case Me:case Ne:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*16;case P:case Ie:return Math.max(e,16)*Math.max(t,8)/4;case Pe:case Fe:return Math.max(e,8)*Math.max(t,8)/2;case Le:case Re:case Be:case Ve:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*8;case ze:case He:case Ue:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*16;case We:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*16;case Ge:return Math.floor((e+4)/5)*Math.floor((t+3)/4)*16;case Ke:return Math.floor((e+4)/5)*Math.floor((t+4)/5)*16;case qe:return Math.floor((e+5)/6)*Math.floor((t+4)/5)*16;case Je:return Math.floor((e+5)/6)*Math.floor((t+5)/6)*16;case Ye:return Math.floor((e+7)/8)*Math.floor((t+4)/5)*16;case Xe:return Math.floor((e+7)/8)*Math.floor((t+5)/6)*16;case Ze:return Math.floor((e+7)/8)*Math.floor((t+7)/8)*16;case Qe:return Math.floor((e+9)/10)*Math.floor((t+4)/5)*16;case $e:return Math.floor((e+9)/10)*Math.floor((t+5)/6)*16;case et:return Math.floor((e+9)/10)*Math.floor((t+7)/8)*16;case tt:return Math.floor((e+9)/10)*Math.floor((t+9)/10)*16;case nt:return Math.floor((e+11)/12)*Math.floor((t+9)/10)*16;case rt:return Math.floor((e+11)/12)*Math.floor((t+11)/12)*16;case it:case at:case ot:return Math.ceil(e/4)*Math.ceil(t/4)*16;case st:case ct:return Math.ceil(e/4)*Math.ceil(t/4)*8;case lt:case ut:return Math.ceil(e/4)*Math.ceil(t/4)*16}throw Error(`Unable to determine texture byte length for ${n} format.`)}function ul(e){switch(e){case oe:case se:return{byteLength:1,components:1};case le:case ce:case pe:return{byteLength:2,components:1};case me:case he:return{byteLength:2,components:4};case de:case ue:case fe:return{byteLength:4,components:1};case _e:case ve:return{byteLength:4,components:3}}throw Error(`THREE.TextureUtils: Unknown texture type ${e}.`)}typeof __THREE_DEVTOOLS__<`u`&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent(`register`,{detail:{revision:`185`}})),typeof window<`u`&&(window.__THREE__?F(`WARNING: Multiple instances of Three.js being imported.`):window.__THREE__=`185`);function dl(){let e=null,t=!1,n=null,r=null;function i(t,a){n(t,a),r=e.requestAnimationFrame(i)}return{start:function(){t!==!0&&n!==null&&e!==null&&(r=e.requestAnimationFrame(i),t=!0)},stop:function(){e!==null&&e.cancelAnimationFrame(r),t=!1},setAnimationLoop:function(e){n=e},setContext:function(t){e=t}}}function fl(e){let t=new WeakMap;function n(t,n){let r=t.array,i=t.usage,a=r.byteLength,o=e.createBuffer();e.bindBuffer(n,o),e.bufferData(n,r,i),t.onUploadCallback();let s;if(r instanceof Float32Array)s=e.FLOAT;else if(typeof Float16Array<`u`&&r instanceof Float16Array)s=e.HALF_FLOAT;else if(r instanceof Uint16Array)s=t.isFloat16BufferAttribute?e.HALF_FLOAT:e.UNSIGNED_SHORT;else if(r instanceof Int16Array)s=e.SHORT;else if(r instanceof Uint32Array)s=e.UNSIGNED_INT;else if(r instanceof Int32Array)s=e.INT;else if(r instanceof Int8Array)s=e.BYTE;else if(r instanceof Uint8Array)s=e.UNSIGNED_BYTE;else if(r instanceof Uint8ClampedArray)s=e.UNSIGNED_BYTE;else throw Error(`THREE.WebGLAttributes: Unsupported buffer data format: `+r);return{buffer:o,type:s,bytesPerElement:r.BYTES_PER_ELEMENT,version:t.version,size:a}}function r(t,n,r){let i=n.array,a=n.updateRanges;if(e.bindBuffer(r,t),a.length===0)e.bufferSubData(r,0,i);else{a.sort((e,t)=>e.start-t.start);let t=0;for(let e=1;e 0 vec4 plane; #ifdef ALPHA_TO_COVERAGE float distanceToPlane, distanceGradient; float clipOpacity = 1.0; #pragma unroll_loop_start for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) { plane = clippingPlanes[ i ]; distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w; distanceGradient = fwidth( distanceToPlane ) / 2.0; clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane ); if ( clipOpacity == 0.0 ) discard; } #pragma unroll_loop_end #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES float unionClipOpacity = 1.0; #pragma unroll_loop_start for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) { plane = clippingPlanes[ i ]; distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w; distanceGradient = fwidth( distanceToPlane ) / 2.0; unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane ); } #pragma unroll_loop_end clipOpacity *= 1.0 - unionClipOpacity; #endif diffuseColor.a *= clipOpacity; if ( diffuseColor.a == 0.0 ) discard; #else #pragma unroll_loop_start for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) { plane = clippingPlanes[ i ]; if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard; } #pragma unroll_loop_end #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES bool clipped = true; #pragma unroll_loop_start for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) { plane = clippingPlanes[ i ]; clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped; } #pragma unroll_loop_end if ( clipped ) discard; #endif #endif #endif`,clipping_planes_pars_fragment:`#if NUM_CLIPPING_PLANES > 0 varying vec3 vClipPosition; uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ]; #endif`,clipping_planes_pars_vertex:`#if NUM_CLIPPING_PLANES > 0 varying vec3 vClipPosition; #endif`,clipping_planes_vertex:`#if NUM_CLIPPING_PLANES > 0 vClipPosition = - mvPosition.xyz; #endif`,color_fragment:`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) diffuseColor *= vColor; #endif`,color_pars_fragment:`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) varying vec4 vColor; #endif`,color_pars_vertex:`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) varying vec4 vColor; #endif`,color_vertex:`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) vColor = vec4( 1.0 ); #endif #ifdef USE_COLOR_ALPHA vColor *= color; #elif defined( USE_COLOR ) vColor.rgb *= color; #endif #ifdef USE_INSTANCING_COLOR vColor.rgb *= instanceColor.rgb; #endif #ifdef USE_BATCHING_COLOR vColor *= getBatchingColor( getIndirectIndex( gl_DrawID ) ); #endif`,common:`#define PI 3.141592653589793 #define PI2 6.283185307179586 #define PI_HALF 1.5707963267948966 #define RECIPROCAL_PI 0.3183098861837907 #define RECIPROCAL_PI2 0.15915494309189535 #define EPSILON 1e-6 #ifndef saturate #define saturate( a ) clamp( a, 0.0, 1.0 ) #endif #define whiteComplement( a ) ( 1.0 - saturate( a ) ) float pow2( const in float x ) { return x*x; } vec3 pow2( const in vec3 x ) { return x*x; } float pow3( const in float x ) { return x*x*x; } float pow4( const in float x ) { float x2 = x*x; return x2*x2; } float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); } float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); } highp float rand( const in vec2 uv ) { const highp float a = 12.9898, b = 78.233, c = 43758.5453; highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI ); return fract( sin( sn ) * c ); } #ifdef HIGH_PRECISION float precisionSafeLength( vec3 v ) { return length( v ); } #else float precisionSafeLength( vec3 v ) { float maxComponent = max3( abs( v ) ); return length( v / maxComponent ) * maxComponent; } #endif struct IncidentLight { vec3 color; vec3 direction; bool visible; }; struct ReflectedLight { vec3 directDiffuse; vec3 directSpecular; vec3 indirectDiffuse; vec3 indirectSpecular; }; #ifdef USE_ALPHAHASH varying vec3 vPosition; #endif vec3 transformDirection( in vec3 dir, in mat4 matrix ) { return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); } #define inverseTransformDirection transformDirectionByInverseViewMatrix vec3 transformNormalByInverseViewMatrix( in vec3 normal, in mat4 viewMatrix ) { return normalize( ( vec4( normal, 0.0 ) * viewMatrix ).xyz ); } vec3 transformDirectionByInverseViewMatrix( in vec3 dir, in mat4 viewMatrix ) { return normalize( ( vec4( dir, 0.0 ) * viewMatrix ).xyz ); } bool isPerspectiveMatrix( mat4 m ) { return m[ 2 ][ 3 ] == - 1.0; } vec2 equirectUv( in vec3 dir ) { float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5; float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5; return vec2( u, v ); } vec3 BRDF_Lambert( const in vec3 diffuseColor ) { return RECIPROCAL_PI * diffuseColor; } vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) { float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH ); return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel ); } float F_Schlick( const in float f0, const in float f90, const in float dotVH ) { float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH ); return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel ); } // validated`,cube_uv_reflection_fragment:`#ifdef ENVMAP_TYPE_CUBE_UV #define cubeUV_minMipLevel 4.0 #define cubeUV_minTileSize 16.0 float getFace( vec3 direction ) { vec3 absDirection = abs( direction ); float face = - 1.0; if ( absDirection.x > absDirection.z ) { if ( absDirection.x > absDirection.y ) face = direction.x > 0.0 ? 0.0 : 3.0; else face = direction.y > 0.0 ? 1.0 : 4.0; } else { if ( absDirection.z > absDirection.y ) face = direction.z > 0.0 ? 2.0 : 5.0; else face = direction.y > 0.0 ? 1.0 : 4.0; } return face; } vec2 getUV( vec3 direction, float face ) { vec2 uv; if ( face == 0.0 ) { uv = vec2( direction.z, direction.y ) / abs( direction.x ); } else if ( face == 1.0 ) { uv = vec2( - direction.x, - direction.z ) / abs( direction.y ); } else if ( face == 2.0 ) { uv = vec2( - direction.x, direction.y ) / abs( direction.z ); } else if ( face == 3.0 ) { uv = vec2( - direction.z, direction.y ) / abs( direction.x ); } else if ( face == 4.0 ) { uv = vec2( - direction.x, direction.z ) / abs( direction.y ); } else { uv = vec2( direction.x, direction.y ) / abs( direction.z ); } return 0.5 * ( uv + 1.0 ); } vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) { float face = getFace( direction ); float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 ); mipInt = max( mipInt, cubeUV_minMipLevel ); float faceSize = exp2( mipInt ); highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0; if ( face > 2.0 ) { uv.y += faceSize; face -= 3.0; } uv.x += face * faceSize; uv.x += filterInt * 3.0 * cubeUV_minTileSize; uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize ); uv.x *= CUBEUV_TEXEL_WIDTH; uv.y *= CUBEUV_TEXEL_HEIGHT; #ifdef texture2DGradEXT return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb; #else return texture2D( envMap, uv ).rgb; #endif } #define cubeUV_r0 1.0 #define cubeUV_m0 - 2.0 #define cubeUV_r1 0.8 #define cubeUV_m1 - 1.0 #define cubeUV_r4 0.4 #define cubeUV_m4 2.0 #define cubeUV_r5 0.305 #define cubeUV_m5 3.0 #define cubeUV_r6 0.21 #define cubeUV_m6 4.0 float roughnessToMip( float roughness ) { float mip = 0.0; if ( roughness >= cubeUV_r1 ) { mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0; } else if ( roughness >= cubeUV_r4 ) { mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1; } else if ( roughness >= cubeUV_r5 ) { mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4; } else if ( roughness >= cubeUV_r6 ) { mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5; } else { mip = - 2.0 * log2( 1.16 * roughness ); } return mip; } vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) { float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP ); float mipF = fract( mip ); float mipInt = floor( mip ); vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt ); if ( mipF == 0.0 ) { return vec4( color0, 1.0 ); } else { vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 ); return vec4( mix( color0, color1, mipF ), 1.0 ); } } #endif`,defaultnormal_vertex:`vec3 transformedNormal = objectNormal; #ifdef USE_TANGENT vec3 transformedTangent = objectTangent; #endif #ifdef USE_BATCHING mat3 bm = mat3( batchingMatrix ); transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) ); transformedNormal = bm * transformedNormal; #ifdef USE_TANGENT transformedTangent = bm * transformedTangent; #endif #endif #ifdef USE_INSTANCING mat3 im = mat3( instanceMatrix ); transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) ); transformedNormal = im * transformedNormal; #ifdef USE_TANGENT transformedTangent = im * transformedTangent; #endif #endif transformedNormal = normalMatrix * transformedNormal; #ifdef FLIP_SIDED transformedNormal = - transformedNormal; #endif #ifdef USE_TANGENT transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz; #endif`,displacementmap_pars_vertex:`#ifdef USE_DISPLACEMENTMAP uniform sampler2D displacementMap; uniform float displacementScale; uniform float displacementBias; #endif`,displacementmap_vertex:`#ifdef USE_DISPLACEMENTMAP transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias ); #endif`,emissivemap_fragment:`#ifdef USE_EMISSIVEMAP vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv ); #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE emissiveColor = sRGBTransferEOTF( emissiveColor ); #endif totalEmissiveRadiance *= emissiveColor.rgb; #endif`,emissivemap_pars_fragment:`#ifdef USE_EMISSIVEMAP uniform sampler2D emissiveMap; #endif`,colorspace_fragment:`gl_FragColor = linearToOutputTexel( gl_FragColor );`,colorspace_pars_fragment:`vec4 LinearTransferOETF( in vec4 value ) { return value; } vec4 sRGBTransferEOTF( in vec4 value ) { return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a ); } vec4 sRGBTransferOETF( in vec4 value ) { return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a ); }`,envmap_fragment:`#ifdef USE_ENVMAP #ifdef ENV_WORLDPOS vec3 cameraToFrag; if ( isOrthographic ) { cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); } else { cameraToFrag = normalize( vWorldPosition - cameraPosition ); } vec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix ); #ifdef ENVMAP_MODE_REFLECTION vec3 reflectVec = reflect( cameraToFrag, worldNormal ); #else vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio ); #endif #else vec3 reflectVec = vReflect; #endif #ifdef ENVMAP_TYPE_CUBE vec4 envColor = textureCube( envMap, envMapRotation * reflectVec ); #ifdef ENVMAP_BLENDING_MULTIPLY outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity ); #elif defined( ENVMAP_BLENDING_MIX ) outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity ); #elif defined( ENVMAP_BLENDING_ADD ) outgoingLight += envColor.xyz * specularStrength * reflectivity; #endif #endif #endif`,envmap_common_pars_fragment:`#ifdef USE_ENVMAP uniform float envMapIntensity; uniform mat3 envMapRotation; #ifdef ENVMAP_TYPE_CUBE uniform samplerCube envMap; #else uniform sampler2D envMap; #endif #endif`,envmap_pars_fragment:`#ifdef USE_ENVMAP uniform float reflectivity; #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) #define ENV_WORLDPOS #endif #ifdef ENV_WORLDPOS varying vec3 vWorldPosition; uniform float refractionRatio; #else varying vec3 vReflect; #endif #endif`,envmap_pars_vertex:`#ifdef USE_ENVMAP #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) #define ENV_WORLDPOS #endif #ifdef ENV_WORLDPOS varying vec3 vWorldPosition; #else varying vec3 vReflect; uniform float refractionRatio; #endif #endif`,envmap_physical_pars_fragment:`#ifdef USE_ENVMAP vec3 getIBLIrradiance( const in vec3 normal ) { #ifdef ENVMAP_TYPE_CUBE_UV vec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix ); vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 ); return PI * envMapColor.rgb * envMapIntensity; #else return vec3( 0.0 ); #endif } vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) { #ifdef ENVMAP_TYPE_CUBE_UV vec3 reflectVec = reflect( - viewDir, normal ); reflectVec = normalize( mix( reflectVec, normal, pow4( roughness ) ) ); reflectVec = transformDirectionByInverseViewMatrix( reflectVec, viewMatrix ); vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness ); return envMapColor.rgb * envMapIntensity; #else return vec3( 0.0 ); #endif } #ifdef USE_ANISOTROPY vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) { #ifdef ENVMAP_TYPE_CUBE_UV vec3 bentNormal = cross( bitangent, viewDir ); bentNormal = normalize( cross( bentNormal, bitangent ) ); bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) ); return getIBLRadiance( viewDir, bentNormal, roughness ); #else return vec3( 0.0 ); #endif } #endif #endif`,envmap_vertex:`#ifdef USE_ENVMAP #ifdef ENV_WORLDPOS vWorldPosition = worldPosition.xyz; #else vec3 cameraToVertex; if ( isOrthographic ) { cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); } else { cameraToVertex = normalize( worldPosition.xyz - cameraPosition ); } vec3 worldNormal = transformNormalByInverseViewMatrix( transformedNormal, viewMatrix ); #ifdef ENVMAP_MODE_REFLECTION vReflect = reflect( cameraToVertex, worldNormal ); #else vReflect = refract( cameraToVertex, worldNormal, refractionRatio ); #endif #endif #endif`,fog_vertex:`#ifdef USE_FOG vFogDepth = - mvPosition.z; #endif`,fog_pars_vertex:`#ifdef USE_FOG varying float vFogDepth; #endif`,fog_fragment:`#ifdef USE_FOG #ifdef FOG_EXP2 float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth ); #else float fogFactor = smoothstep( fogNear, fogFar, vFogDepth ); #endif gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor ); #endif`,fog_pars_fragment:`#ifdef USE_FOG uniform vec3 fogColor; varying float vFogDepth; #ifdef FOG_EXP2 uniform float fogDensity; #else uniform float fogNear; uniform float fogFar; #endif #endif`,gradientmap_pars_fragment:`#ifdef USE_GRADIENTMAP uniform sampler2D gradientMap; #endif vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) { float dotNL = dot( normal, lightDirection ); vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 ); #ifdef USE_GRADIENTMAP return vec3( texture2D( gradientMap, coord ).r ); #else vec2 fw = fwidth( coord ) * 0.5; return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) ); #endif }`,lightmap_pars_fragment:`#ifdef USE_LIGHTMAP uniform sampler2D lightMap; uniform float lightMapIntensity; #endif`,lights_lambert_fragment:`LambertMaterial material; material.diffuseColor = diffuseColor.rgb; material.specularStrength = specularStrength;`,lights_lambert_pars_fragment:`varying vec3 vViewPosition; struct LambertMaterial { vec3 diffuseColor; float specularStrength; }; void RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) { float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); vec3 irradiance = dotNL * directLight.color; reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) { reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } #define RE_Direct RE_Direct_Lambert #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,lights_pars_begin:`uniform bool receiveShadow; uniform vec3 ambientLightColor; #if defined( USE_LIGHT_PROBES ) uniform vec3 lightProbe[ 9 ]; #endif vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) { float x = normal.x, y = normal.y, z = normal.z; vec3 result = shCoefficients[ 0 ] * 0.886227; result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y; result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z; result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x; result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y; result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z; result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 ); result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z; result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y ); return result; } vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) { vec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix ); vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe ); return irradiance; } vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) { vec3 irradiance = ambientLightColor; return irradiance; } float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) { float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 ); if ( cutoffDistance > 0.0 ) { distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) ); } return distanceFalloff; } float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) { return smoothstep( coneCosine, penumbraCosine, angleCosine ); } #if NUM_DIR_LIGHTS > 0 struct DirectionalLight { vec3 direction; vec3 color; }; uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ]; void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) { light.color = directionalLight.color; light.direction = directionalLight.direction; light.visible = true; } #endif #if NUM_POINT_LIGHTS > 0 struct PointLight { vec3 position; vec3 color; float distance; float decay; }; uniform PointLight pointLights[ NUM_POINT_LIGHTS ]; void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) { vec3 lVector = pointLight.position - geometryPosition; light.direction = normalize( lVector ); float lightDistance = length( lVector ); light.color = pointLight.color; light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay ); light.visible = ( light.color != vec3( 0.0 ) ); } #endif #if NUM_SPOT_LIGHTS > 0 struct SpotLight { vec3 position; vec3 direction; vec3 color; float distance; float decay; float coneCos; float penumbraCos; }; uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ]; void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) { vec3 lVector = spotLight.position - geometryPosition; light.direction = normalize( lVector ); float angleCos = dot( light.direction, spotLight.direction ); float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos ); if ( spotAttenuation > 0.0 ) { float lightDistance = length( lVector ); light.color = spotLight.color * spotAttenuation; light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay ); light.visible = ( light.color != vec3( 0.0 ) ); } else { light.color = vec3( 0.0 ); light.visible = false; } } #endif #if NUM_RECT_AREA_LIGHTS > 0 struct RectAreaLight { vec3 color; vec3 position; vec3 halfWidth; vec3 halfHeight; }; uniform sampler2D ltc_1; uniform sampler2D ltc_2; uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ]; #endif #if NUM_HEMI_LIGHTS > 0 struct HemisphereLight { vec3 direction; vec3 skyColor; vec3 groundColor; }; uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ]; vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) { float dotNL = dot( normal, hemiLight.direction ); float hemiDiffuseWeight = 0.5 * dotNL + 0.5; vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight ); return irradiance; } #endif #include `,lights_toon_fragment:`ToonMaterial material; material.diffuseColor = diffuseColor.rgb;`,lights_toon_pars_fragment:`varying vec3 vViewPosition; struct ToonMaterial { vec3 diffuseColor; }; void RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color; reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } #define RE_Direct RE_Direct_Toon #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,lights_phong_fragment:`BlinnPhongMaterial material; material.diffuseColor = diffuseColor.rgb; material.specularColor = specular; material.specularShininess = shininess; material.specularStrength = specularStrength;`,lights_phong_pars_fragment:`varying vec3 vViewPosition; struct BlinnPhongMaterial { vec3 diffuseColor; vec3 specularColor; float specularShininess; float specularStrength; }; void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); vec3 irradiance = dotNL * directLight.color; reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength; } void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } #define RE_Direct RE_Direct_BlinnPhong #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,lights_physical_fragment:`PhysicalMaterial material; material.diffuseColor = diffuseColor.rgb; material.diffuseContribution = diffuseColor.rgb * ( 1.0 - metalnessFactor ); material.metalness = metalnessFactor; vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) ); float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z ); material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness; material.roughness = min( material.roughness, 1.0 ); #ifdef IOR material.ior = ior; #ifdef USE_SPECULAR float specularIntensityFactor = specularIntensity; vec3 specularColorFactor = specularColor; #ifdef USE_SPECULAR_COLORMAP specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb; #endif #ifdef USE_SPECULAR_INTENSITYMAP specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a; #endif material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor ); #else float specularIntensityFactor = 1.0; vec3 specularColorFactor = vec3( 1.0 ); material.specularF90 = 1.0; #endif material.specularColor = min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor; material.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor ); #else material.specularColor = vec3( 0.04 ); material.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor ); material.specularF90 = 1.0; #endif #ifdef USE_CLEARCOAT material.clearcoat = clearcoat; material.clearcoatRoughness = clearcoatRoughness; material.clearcoatF0 = vec3( 0.04 ); material.clearcoatF90 = 1.0; #ifdef USE_CLEARCOATMAP material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x; #endif #ifdef USE_CLEARCOAT_ROUGHNESSMAP material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y; #endif material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 ); material.clearcoatRoughness += geometryRoughness; material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 ); #endif #ifdef USE_DISPERSION material.dispersion = dispersion; #endif #ifdef USE_IRIDESCENCE material.iridescence = iridescence; material.iridescenceIOR = iridescenceIOR; #ifdef USE_IRIDESCENCEMAP material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r; #endif #ifdef USE_IRIDESCENCE_THICKNESSMAP material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum; #else material.iridescenceThickness = iridescenceThicknessMaximum; #endif #endif #ifdef USE_SHEEN material.sheenColor = sheenColor; #ifdef USE_SHEEN_COLORMAP material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb; #endif material.sheenRoughness = clamp( sheenRoughness, 0.0001, 1.0 ); #ifdef USE_SHEEN_ROUGHNESSMAP material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a; #endif #endif #ifdef USE_ANISOTROPY #ifdef USE_ANISOTROPYMAP mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x ); vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb; vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b; #else vec2 anisotropyV = anisotropyVector; #endif material.anisotropy = length( anisotropyV ); if( material.anisotropy == 0.0 ) { anisotropyV = vec2( 1.0, 0.0 ); } else { anisotropyV /= material.anisotropy; material.anisotropy = saturate( material.anisotropy ); } material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) ); material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y; material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y; #endif`,lights_physical_pars_fragment:`uniform sampler2D dfgLUT; struct PhysicalMaterial { vec3 diffuseColor; vec3 diffuseContribution; vec3 specularColor; vec3 specularColorBlended; float roughness; float metalness; float specularF90; float dispersion; #ifdef USE_CLEARCOAT float clearcoat; float clearcoatRoughness; vec3 clearcoatF0; float clearcoatF90; #endif #ifdef USE_IRIDESCENCE float iridescence; float iridescenceIOR; float iridescenceThickness; vec3 iridescenceFresnel; vec3 iridescenceF0; vec3 iridescenceFresnelDielectric; vec3 iridescenceFresnelMetallic; #endif #ifdef USE_SHEEN vec3 sheenColor; float sheenRoughness; #endif #ifdef IOR float ior; #endif #ifdef USE_TRANSMISSION float transmission; float transmissionAlpha; float thickness; float attenuationDistance; vec3 attenuationColor; #endif #ifdef USE_ANISOTROPY float anisotropy; float alphaT; vec3 anisotropyT; vec3 anisotropyB; #endif }; vec3 clearcoatSpecularDirect = vec3( 0.0 ); vec3 clearcoatSpecularIndirect = vec3( 0.0 ); vec3 sheenSpecularDirect = vec3( 0.0 ); vec3 sheenSpecularIndirect = vec3(0.0 ); vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) { float x = clamp( 1.0 - dotVH, 0.0, 1.0 ); float x2 = x * x; float x5 = clamp( x * x2 * x2, 0.0, 0.9999 ); return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 ); } float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) { float a2 = pow2( alpha ); float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) ); float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) ); return 0.5 / max( gv + gl, EPSILON ); } float D_GGX( const in float alpha, const in float dotNH ) { float a2 = pow2( alpha ); float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0; return RECIPROCAL_PI * a2 / pow2( denom ); } #ifdef USE_ANISOTROPY float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) { float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) ); float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) ); return 0.5 / max( gv + gl, EPSILON ); } float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) { float a2 = alphaT * alphaB; highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH ); highp float v2 = dot( v, v ); float w2 = a2 / v2; return RECIPROCAL_PI * a2 * pow2 ( w2 ); } #endif #ifdef USE_CLEARCOAT vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) { vec3 f0 = material.clearcoatF0; float f90 = material.clearcoatF90; float roughness = material.clearcoatRoughness; float alpha = pow2( roughness ); vec3 halfDir = normalize( lightDir + viewDir ); float dotNL = saturate( dot( normal, lightDir ) ); float dotNV = saturate( dot( normal, viewDir ) ); float dotNH = saturate( dot( normal, halfDir ) ); float dotVH = saturate( dot( viewDir, halfDir ) ); vec3 F = F_Schlick( f0, f90, dotVH ); float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); float D = D_GGX( alpha, dotNH ); return F * ( V * D ); } #endif vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) { vec3 f0 = material.specularColorBlended; float f90 = material.specularF90; float roughness = material.roughness; float alpha = pow2( roughness ); vec3 halfDir = normalize( lightDir + viewDir ); float dotNL = saturate( dot( normal, lightDir ) ); float dotNV = saturate( dot( normal, viewDir ) ); float dotNH = saturate( dot( normal, halfDir ) ); float dotVH = saturate( dot( viewDir, halfDir ) ); vec3 F = F_Schlick( f0, f90, dotVH ); #ifdef USE_IRIDESCENCE F = mix( F, material.iridescenceFresnel, material.iridescence ); #endif #ifdef USE_ANISOTROPY float dotTL = dot( material.anisotropyT, lightDir ); float dotTV = dot( material.anisotropyT, viewDir ); float dotTH = dot( material.anisotropyT, halfDir ); float dotBL = dot( material.anisotropyB, lightDir ); float dotBV = dot( material.anisotropyB, viewDir ); float dotBH = dot( material.anisotropyB, halfDir ); float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL ); float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH ); #else float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); float D = D_GGX( alpha, dotNH ); #endif return F * ( V * D ); } vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) { const float LUT_SIZE = 64.0; const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE; const float LUT_BIAS = 0.5 / LUT_SIZE; float dotNV = saturate( dot( N, V ) ); vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) ); uv = uv * LUT_SCALE + LUT_BIAS; return uv; } float LTC_ClippedSphereFormFactor( const in vec3 f ) { float l = length( f ); return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 ); } vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) { float x = dot( v1, v2 ); float y = abs( x ); float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y; float b = 3.4175940 + ( 4.1616724 + y ) * y; float v = a / b; float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v; return cross( v1, v2 ) * theta_sintheta; } vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) { vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ]; vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ]; vec3 lightNormal = cross( v1, v2 ); if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 ); vec3 T1, T2; T1 = normalize( V - N * dot( V, N ) ); T2 = - cross( N, T1 ); mat3 mat = mInv * transpose( mat3( T1, T2, N ) ); vec3 coords[ 4 ]; coords[ 0 ] = mat * ( rectCoords[ 0 ] - P ); coords[ 1 ] = mat * ( rectCoords[ 1 ] - P ); coords[ 2 ] = mat * ( rectCoords[ 2 ] - P ); coords[ 3 ] = mat * ( rectCoords[ 3 ] - P ); coords[ 0 ] = normalize( coords[ 0 ] ); coords[ 1 ] = normalize( coords[ 1 ] ); coords[ 2 ] = normalize( coords[ 2 ] ); coords[ 3 ] = normalize( coords[ 3 ] ); vec3 vectorFormFactor = vec3( 0.0 ); vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] ); vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] ); vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] ); vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] ); float result = LTC_ClippedSphereFormFactor( vectorFormFactor ); return vec3( result ); } #if defined( USE_SHEEN ) float D_Charlie( float roughness, float dotNH ) { float alpha = pow2( roughness ); float invAlpha = 1.0 / alpha; float cos2h = dotNH * dotNH; float sin2h = max( 1.0 - cos2h, 0.0078125 ); return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI ); } float V_Neubelt( float dotNV, float dotNL ) { return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) ); } vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) { vec3 halfDir = normalize( lightDir + viewDir ); float dotNL = saturate( dot( normal, lightDir ) ); float dotNV = saturate( dot( normal, viewDir ) ); float dotNH = saturate( dot( normal, halfDir ) ); float D = D_Charlie( sheenRoughness, dotNH ); float V = V_Neubelt( dotNV, dotNL ); return sheenColor * ( D * V ); } #endif float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) { float dotNV = saturate( dot( normal, viewDir ) ); float r2 = roughness * roughness; float rInv = 1.0 / ( roughness + 0.1 ); float a = -1.9362 + 1.0678 * roughness + 0.4573 * r2 - 0.8469 * rInv; float b = -0.6014 + 0.5538 * roughness - 0.4670 * r2 - 0.1255 * rInv; float DG = exp( a * dotNV + b ); return saturate( DG ); } vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) { float dotNV = saturate( dot( normal, viewDir ) ); vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg; return specularColor * fab.x + specularF90 * fab.y; } #ifdef USE_IRIDESCENCE void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { #else void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { #endif float dotNV = saturate( dot( normal, viewDir ) ); vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg; #ifdef USE_IRIDESCENCE vec3 Fr = mix( specularColor, iridescenceF0, iridescence ); #else vec3 Fr = specularColor; #endif vec3 FssEss = Fr * fab.x + specularF90 * fab.y; float Ess = fab.x + fab.y; float Ems = 1.0 - Ess; vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg ); singleScatter += FssEss; multiScatter += Fms * Ems; } vec3 BRDF_GGX_Multiscatter( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) { vec3 singleScatter = BRDF_GGX( lightDir, viewDir, normal, material ); float dotNL = saturate( dot( normal, lightDir ) ); float dotNV = saturate( dot( normal, viewDir ) ); vec2 dfgV = texture2D( dfgLUT, vec2( material.roughness, dotNV ) ).rg; vec2 dfgL = texture2D( dfgLUT, vec2( material.roughness, dotNL ) ).rg; vec3 FssEss_V = material.specularColorBlended * dfgV.x + material.specularF90 * dfgV.y; vec3 FssEss_L = material.specularColorBlended * dfgL.x + material.specularF90 * dfgL.y; float Ess_V = dfgV.x + dfgV.y; float Ess_L = dfgL.x + dfgL.y; float Ems_V = 1.0 - Ess_V; float Ems_L = 1.0 - Ess_L; vec3 Favg = material.specularColorBlended + ( 1.0 - material.specularColorBlended ) * 0.047619; vec3 Fms = FssEss_V * FssEss_L * Favg / ( 1.0 - Ems_V * Ems_L * Favg + EPSILON ); float compensationFactor = Ems_V * Ems_L; vec3 multiScatter = Fms * compensationFactor; return singleScatter + multiScatter; } #if NUM_RECT_AREA_LIGHTS > 0 void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { vec3 normal = geometryNormal; vec3 viewDir = geometryViewDir; vec3 position = geometryPosition; vec3 lightPos = rectAreaLight.position; vec3 halfWidth = rectAreaLight.halfWidth; vec3 halfHeight = rectAreaLight.halfHeight; vec3 lightColor = rectAreaLight.color; float roughness = material.roughness; vec3 rectCoords[ 4 ]; rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight; rectCoords[ 2 ] = lightPos - halfWidth + halfHeight; rectCoords[ 3 ] = lightPos + halfWidth + halfHeight; vec2 uv = LTC_Uv( normal, viewDir, roughness ); vec4 t1 = texture2D( ltc_1, uv ); vec4 t2 = texture2D( ltc_2, uv ); mat3 mInv = mat3( vec3( t1.x, 0, t1.y ), vec3( 0, 1, 0 ), vec3( t1.z, 0, t1.w ) ); vec3 fresnel = ( material.specularColorBlended * t2.x + ( material.specularF90 - material.specularColorBlended ) * t2.y ); reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords ); reflectedLight.directDiffuse += lightColor * material.diffuseContribution * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords ); #ifdef USE_CLEARCOAT vec3 Ncc = geometryClearcoatNormal; vec2 uvClearcoat = LTC_Uv( Ncc, viewDir, material.clearcoatRoughness ); vec4 t1Clearcoat = texture2D( ltc_1, uvClearcoat ); vec4 t2Clearcoat = texture2D( ltc_2, uvClearcoat ); mat3 mInvClearcoat = mat3( vec3( t1Clearcoat.x, 0, t1Clearcoat.y ), vec3( 0, 1, 0 ), vec3( t1Clearcoat.z, 0, t1Clearcoat.w ) ); vec3 fresnelClearcoat = material.clearcoatF0 * t2Clearcoat.x + ( material.clearcoatF90 - material.clearcoatF0 ) * t2Clearcoat.y; clearcoatSpecularDirect += lightColor * fresnelClearcoat * LTC_Evaluate( Ncc, viewDir, position, mInvClearcoat, rectCoords ); #endif } #endif void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); vec3 irradiance = dotNL * directLight.color; #ifdef USE_CLEARCOAT float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) ); vec3 ccIrradiance = dotNLcc * directLight.color; clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material ); #endif #ifdef USE_SHEEN sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness ); float sheenAlbedoV = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); float sheenAlbedoL = IBLSheenBRDF( geometryNormal, directLight.direction, material.sheenRoughness ); float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * max( sheenAlbedoV, sheenAlbedoL ); irradiance *= sheenEnergyComp; #endif reflectedLight.directSpecular += irradiance * BRDF_GGX_Multiscatter( directLight.direction, geometryViewDir, geometryNormal, material ); reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseContribution ); } void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { vec3 diffuse = irradiance * BRDF_Lambert( material.diffuseContribution ); #ifdef USE_SHEEN float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo; diffuse *= sheenEnergyComp; #endif reflectedLight.indirectDiffuse += diffuse; } void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) { #ifdef USE_CLEARCOAT clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness ); #endif #ifdef USE_SHEEN sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ) * RECIPROCAL_PI; #endif vec3 singleScatteringDielectric = vec3( 0.0 ); vec3 multiScatteringDielectric = vec3( 0.0 ); vec3 singleScatteringMetallic = vec3( 0.0 ); vec3 multiScatteringMetallic = vec3( 0.0 ); #ifdef USE_IRIDESCENCE computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnelDielectric, material.roughness, singleScatteringDielectric, multiScatteringDielectric ); computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.iridescence, material.iridescenceFresnelMetallic, material.roughness, singleScatteringMetallic, multiScatteringMetallic ); #else computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScatteringDielectric, multiScatteringDielectric ); computeMultiscattering( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.roughness, singleScatteringMetallic, multiScatteringMetallic ); #endif vec3 singleScattering = mix( singleScatteringDielectric, singleScatteringMetallic, material.metalness ); vec3 multiScattering = mix( multiScatteringDielectric, multiScatteringMetallic, material.metalness ); vec3 totalScatteringDielectric = singleScatteringDielectric + multiScatteringDielectric; vec3 diffuse = material.diffuseContribution * ( 1.0 - totalScatteringDielectric ); vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI; vec3 indirectSpecular = radiance * singleScattering; indirectSpecular += multiScattering * cosineWeightedIrradiance; vec3 indirectDiffuse = diffuse * cosineWeightedIrradiance; #ifdef USE_SHEEN float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo; indirectSpecular *= sheenEnergyComp; indirectDiffuse *= sheenEnergyComp; #endif reflectedLight.indirectSpecular += indirectSpecular; reflectedLight.indirectDiffuse += indirectDiffuse; } #define RE_Direct RE_Direct_Physical #define RE_Direct_RectArea RE_Direct_RectArea_Physical #define RE_IndirectDiffuse RE_IndirectDiffuse_Physical #define RE_IndirectSpecular RE_IndirectSpecular_Physical float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) { return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion ); }`,lights_fragment_begin:` vec3 geometryPosition = - vViewPosition; vec3 geometryNormal = normal; vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition ); vec3 geometryClearcoatNormal = vec3( 0.0 ); #ifdef USE_CLEARCOAT geometryClearcoatNormal = clearcoatNormal; #endif #ifdef USE_IRIDESCENCE float dotNVi = saturate( dot( normal, geometryViewDir ) ); if ( material.iridescenceThickness == 0.0 ) { material.iridescence = 0.0; } else { material.iridescence = saturate( material.iridescence ); } if ( material.iridescence > 0.0 ) { material.iridescenceFresnelDielectric = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor ); material.iridescenceFresnelMetallic = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.diffuseColor ); material.iridescenceFresnel = mix( material.iridescenceFresnelDielectric, material.iridescenceFresnelMetallic, material.metalness ); material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi ); } #endif IncidentLight directLight; #if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct ) PointLight pointLight; #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0 PointLightShadow pointLightShadow; #endif #pragma unroll_loop_start for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) { pointLight = pointLights[ i ]; getPointLightInfo( pointLight, geometryPosition, directLight ); #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) ) pointLightShadow = pointLightShadows[ i ]; directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0; #endif RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); } #pragma unroll_loop_end #endif #if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct ) SpotLight spotLight; vec4 spotColor; vec3 spotLightCoord; bool inSpotLightMap; #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0 SpotLightShadow spotLightShadow; #endif #pragma unroll_loop_start for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) { spotLight = spotLights[ i ]; getSpotLightInfo( spotLight, geometryPosition, directLight ); #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS #else #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) #endif #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS ) spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w; inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) ); spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy ); directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color; #endif #undef SPOT_LIGHT_MAP_INDEX #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) spotLightShadow = spotLightShadows[ i ]; directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; #endif RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); } #pragma unroll_loop_end #endif #if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct ) DirectionalLight directionalLight; #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0 DirectionalLightShadow directionalLightShadow; #endif #pragma unroll_loop_start for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) { directionalLight = directionalLights[ i ]; getDirectionalLightInfo( directionalLight, directLight ); #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS ) directionalLightShadow = directionalLightShadows[ i ]; directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; #endif RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); } #pragma unroll_loop_end #endif #if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea ) RectAreaLight rectAreaLight; #pragma unroll_loop_start for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) { rectAreaLight = rectAreaLights[ i ]; RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); } #pragma unroll_loop_end #endif #if defined( RE_IndirectDiffuse ) vec3 iblIrradiance = vec3( 0.0 ); vec3 irradiance = getAmbientLightIrradiance( ambientLightColor ); #if defined( USE_LIGHT_PROBES ) irradiance += getLightProbeIrradiance( lightProbe, geometryNormal ); #endif #if ( NUM_HEMI_LIGHTS > 0 ) #pragma unroll_loop_start for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) { irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal ); } #pragma unroll_loop_end #endif #ifdef USE_LIGHT_PROBES_GRID vec3 probeWorldPos = ( ( vec4( geometryPosition, 1.0 ) - viewMatrix[ 3 ] ) * viewMatrix ).xyz; vec3 probeWorldNormal = transformNormalByInverseViewMatrix( geometryNormal, viewMatrix ); irradiance += getLightProbeGridIrradiance( probeWorldPos, probeWorldNormal ); #endif #endif #if defined( RE_IndirectSpecular ) vec3 radiance = vec3( 0.0 ); vec3 clearcoatRadiance = vec3( 0.0 ); #endif`,lights_fragment_maps:`#if defined( RE_IndirectDiffuse ) #ifdef USE_LIGHTMAP vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity; irradiance += lightMapIrradiance; #endif #if defined( USE_ENVMAP ) && defined( ENVMAP_TYPE_CUBE_UV ) #if defined( STANDARD ) || defined( LAMBERT ) || defined( PHONG ) iblIrradiance += getIBLIrradiance( geometryNormal ); #endif #endif #endif #if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular ) #ifdef USE_ANISOTROPY radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy ); #else radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness ); #endif #ifdef USE_CLEARCOAT clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness ); #endif #endif`,lights_fragment_end:`#if defined( RE_IndirectDiffuse ) #if defined( LAMBERT ) || defined( PHONG ) irradiance += iblIrradiance; #endif RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); #endif #if defined( RE_IndirectSpecular ) RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); #endif`,lightprobes_pars_fragment:`#ifdef USE_LIGHT_PROBES_GRID uniform highp sampler3D probesSH; uniform vec3 probesMin; uniform vec3 probesMax; uniform vec3 probesResolution; vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) { vec3 res = probesResolution; vec3 gridRange = probesMax - probesMin; vec3 resMinusOne = res - 1.0; vec3 probeSpacing = gridRange / resMinusOne; vec3 samplePos = worldPos + worldNormal * probeSpacing * 0.5; vec3 uvw = clamp( ( samplePos - probesMin ) / gridRange, 0.0, 1.0 ); uvw = uvw * resMinusOne / res + 0.5 / res; float nz = res.z; float paddedSlices = nz + 2.0; float atlasDepth = 7.0 * paddedSlices; float uvZBase = uvw.z * nz + 1.0; vec4 s0 = texture( probesSH, vec3( uvw.xy, ( uvZBase ) / atlasDepth ) ); vec4 s1 = texture( probesSH, vec3( uvw.xy, ( uvZBase + paddedSlices ) / atlasDepth ) ); vec4 s2 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 2.0 * paddedSlices ) / atlasDepth ) ); vec4 s3 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 3.0 * paddedSlices ) / atlasDepth ) ); vec4 s4 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 4.0 * paddedSlices ) / atlasDepth ) ); vec4 s5 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 5.0 * paddedSlices ) / atlasDepth ) ); vec4 s6 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 6.0 * paddedSlices ) / atlasDepth ) ); vec3 c0 = s0.xyz; vec3 c1 = vec3( s0.w, s1.xy ); vec3 c2 = vec3( s1.zw, s2.x ); vec3 c3 = s2.yzw; vec3 c4 = s3.xyz; vec3 c5 = vec3( s3.w, s4.xy ); vec3 c6 = vec3( s4.zw, s5.x ); vec3 c7 = s5.yzw; vec3 c8 = s6.xyz; float x = worldNormal.x, y = worldNormal.y, z = worldNormal.z; vec3 result = c0 * 0.886227; result += c1 * 2.0 * 0.511664 * y; result += c2 * 2.0 * 0.511664 * z; result += c3 * 2.0 * 0.511664 * x; result += c4 * 2.0 * 0.429043 * x * y; result += c5 * 2.0 * 0.429043 * y * z; result += c6 * ( 0.743125 * z * z - 0.247708 ); result += c7 * 2.0 * 0.429043 * x * z; result += c8 * 0.429043 * ( x * x - y * y ); return max( result, vec3( 0.0 ) ); } #endif`,logdepthbuf_fragment:`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER ) gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5; #endif`,logdepthbuf_pars_fragment:`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER ) uniform float logDepthBufFC; varying float vFragDepth; varying float vIsPerspective; #endif`,logdepthbuf_pars_vertex:`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER varying float vFragDepth; varying float vIsPerspective; #endif`,logdepthbuf_vertex:`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER vFragDepth = 1.0 + gl_Position.w; vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) ); #endif`,map_fragment:`#ifdef USE_MAP vec4 sampledDiffuseColor = texture2D( map, vMapUv ); #ifdef DECODE_VIDEO_TEXTURE sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor ); #endif diffuseColor *= sampledDiffuseColor; #endif`,map_pars_fragment:`#ifdef USE_MAP uniform sampler2D map; #endif`,map_particle_fragment:`#if defined( USE_MAP ) || defined( USE_ALPHAMAP ) #if defined( USE_POINTS_UV ) vec2 uv = vUv; #else vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy; #endif #endif #ifdef USE_MAP diffuseColor *= texture2D( map, uv ); #endif #ifdef USE_ALPHAMAP diffuseColor.a *= texture2D( alphaMap, uv ).g; #endif`,map_particle_pars_fragment:`#if defined( USE_POINTS_UV ) varying vec2 vUv; #else #if defined( USE_MAP ) || defined( USE_ALPHAMAP ) uniform mat3 uvTransform; #endif #endif #ifdef USE_MAP uniform sampler2D map; #endif #ifdef USE_ALPHAMAP uniform sampler2D alphaMap; #endif`,metalnessmap_fragment:`float metalnessFactor = metalness; #ifdef USE_METALNESSMAP vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv ); metalnessFactor *= texelMetalness.b; #endif`,metalnessmap_pars_fragment:`#ifdef USE_METALNESSMAP uniform sampler2D metalnessMap; #endif`,morphinstance_vertex:`#ifdef USE_INSTANCING_MORPH float morphTargetInfluences[ MORPHTARGETS_COUNT ]; float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r; for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r; } #endif`,morphcolor_vertex:`#if defined( USE_MORPHCOLORS ) vColor *= morphTargetBaseInfluence; for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { #if defined( USE_COLOR_ALPHA ) if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ]; #elif defined( USE_COLOR ) if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ]; #endif } #endif`,morphnormal_vertex:`#ifdef USE_MORPHNORMALS objectNormal *= morphTargetBaseInfluence; for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ]; } #endif`,morphtarget_pars_vertex:`#ifdef USE_MORPHTARGETS #ifndef USE_INSTANCING_MORPH uniform float morphTargetBaseInfluence; uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ]; #endif uniform sampler2DArray morphTargetsTexture; uniform ivec2 morphTargetsTextureSize; vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) { int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset; int y = texelIndex / morphTargetsTextureSize.x; int x = texelIndex - y * morphTargetsTextureSize.x; ivec3 morphUV = ivec3( x, y, morphTargetIndex ); return texelFetch( morphTargetsTexture, morphUV, 0 ); } #endif`,morphtarget_vertex:`#ifdef USE_MORPHTARGETS transformed *= morphTargetBaseInfluence; for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ]; } #endif`,normal_fragment_begin:`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0; #ifdef FLAT_SHADED vec3 fdx = dFdx( vViewPosition ); vec3 fdy = dFdy( vViewPosition ); vec3 normal = normalize( cross( fdx, fdy ) ); #else vec3 normal = normalize( vNormal ); #ifdef DOUBLE_SIDED normal *= faceDirection; #endif #endif #if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) #ifdef USE_TANGENT mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal ); #else mat3 tbn = getTangentFrame( - vViewPosition, normal, #if defined( USE_NORMALMAP ) vNormalMapUv #elif defined( USE_CLEARCOAT_NORMALMAP ) vClearcoatNormalMapUv #else vUv #endif ); #endif #ifdef DOUBLE_SIDED tbn[0] *= faceDirection; tbn[1] *= faceDirection; #endif #endif #ifdef USE_CLEARCOAT_NORMALMAP #ifdef USE_TANGENT mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal ); #else mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv ); #endif #ifdef DOUBLE_SIDED tbn2[0] *= faceDirection; tbn2[1] *= faceDirection; #endif #endif vec3 nonPerturbedNormal = normal;`,normal_fragment_maps:`#ifdef USE_NORMALMAP_OBJECTSPACE normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0; #ifdef FLIP_SIDED normal = - normal; #endif #ifdef DOUBLE_SIDED normal = normal * faceDirection; #endif normal = normalize( normalMatrix * normal ); #elif defined( USE_NORMALMAP_TANGENTSPACE ) vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0; #if defined( USE_PACKED_NORMALMAP ) mapN = vec3( mapN.xy, sqrt( saturate( 1.0 - dot( mapN.xy, mapN.xy ) ) ) ); #endif mapN.xy *= normalScale; normal = normalize( tbn * mapN ); #elif defined( USE_BUMPMAP ) normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection ); #endif`,normal_pars_fragment:`#ifndef FLAT_SHADED varying vec3 vNormal; #ifdef USE_TANGENT varying vec3 vTangent; varying vec3 vBitangent; #endif #endif`,normal_pars_vertex:`#ifndef FLAT_SHADED varying vec3 vNormal; #ifdef USE_TANGENT varying vec3 vTangent; varying vec3 vBitangent; #endif #endif`,normal_vertex:`#ifndef FLAT_SHADED vNormal = normalize( transformedNormal ); #ifdef USE_TANGENT vTangent = normalize( transformedTangent ); vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w ); #ifdef FLIP_SIDED vBitangent = - vBitangent; #endif #endif #endif`,normalmap_pars_fragment:`#ifdef USE_NORMALMAP uniform sampler2D normalMap; uniform vec2 normalScale; #endif #ifdef USE_NORMALMAP_OBJECTSPACE uniform mat3 normalMatrix; #endif #if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) ) mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) { vec3 q0 = dFdx( eye_pos.xyz ); vec3 q1 = dFdy( eye_pos.xyz ); vec2 st0 = dFdx( uv.st ); vec2 st1 = dFdy( uv.st ); vec3 N = surf_norm; vec3 q1perp = cross( q1, N ); vec3 q0perp = cross( N, q0 ); vec3 T = q1perp * st0.x + q0perp * st1.x; vec3 B = q1perp * st0.y + q0perp * st1.y; float det = max( dot( T, T ), dot( B, B ) ); float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det ); return mat3( T * scale, B * scale, N ); } #endif`,clearcoat_normal_fragment_begin:`#ifdef USE_CLEARCOAT vec3 clearcoatNormal = nonPerturbedNormal; #endif`,clearcoat_normal_fragment_maps:`#ifdef USE_CLEARCOAT_NORMALMAP vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0; clearcoatMapN.xy *= clearcoatNormalScale; clearcoatNormal = normalize( tbn2 * clearcoatMapN ); #endif`,clearcoat_pars_fragment:`#ifdef USE_CLEARCOATMAP uniform sampler2D clearcoatMap; #endif #ifdef USE_CLEARCOAT_NORMALMAP uniform sampler2D clearcoatNormalMap; uniform vec2 clearcoatNormalScale; #endif #ifdef USE_CLEARCOAT_ROUGHNESSMAP uniform sampler2D clearcoatRoughnessMap; #endif`,iridescence_pars_fragment:`#ifdef USE_IRIDESCENCEMAP uniform sampler2D iridescenceMap; #endif #ifdef USE_IRIDESCENCE_THICKNESSMAP uniform sampler2D iridescenceThicknessMap; #endif`,opaque_fragment:`#ifdef OPAQUE diffuseColor.a = 1.0; #endif #ifdef USE_TRANSMISSION diffuseColor.a *= material.transmissionAlpha; #endif gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,packing:`vec3 packNormalToRGB( const in vec3 normal ) { return normalize( normal ) * 0.5 + 0.5; } vec3 unpackRGBToNormal( const in vec3 rgb ) { return 2.0 * rgb.xyz - 1.0; } const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.; const float Inv255 = 1. / 255.; const vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 ); const vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g ); const vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b ); const vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a ); vec4 packDepthToRGBA( const in float v ) { if( v <= 0.0 ) return vec4( 0., 0., 0., 0. ); if( v >= 1.0 ) return vec4( 1., 1., 1., 1. ); float vuf; float af = modf( v * PackFactors.a, vuf ); float bf = modf( vuf * ShiftRight8, vuf ); float gf = modf( vuf * ShiftRight8, vuf ); return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af ); } vec3 packDepthToRGB( const in float v ) { if( v <= 0.0 ) return vec3( 0., 0., 0. ); if( v >= 1.0 ) return vec3( 1., 1., 1. ); float vuf; float bf = modf( v * PackFactors.b, vuf ); float gf = modf( vuf * ShiftRight8, vuf ); return vec3( vuf * Inv255, gf * PackUpscale, bf ); } vec2 packDepthToRG( const in float v ) { if( v <= 0.0 ) return vec2( 0., 0. ); if( v >= 1.0 ) return vec2( 1., 1. ); float vuf; float gf = modf( v * 256., vuf ); return vec2( vuf * Inv255, gf ); } float unpackRGBAToDepth( const in vec4 v ) { return dot( v, UnpackFactors4 ); } float unpackRGBToDepth( const in vec3 v ) { return dot( v, UnpackFactors3 ); } float unpackRGToDepth( const in vec2 v ) { return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g; } vec4 pack2HalfToRGBA( const in vec2 v ) { vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) ); return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w ); } vec2 unpackRGBATo2Half( const in vec4 v ) { return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) ); } float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) { return ( viewZ + near ) / ( near - far ); } float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) { #ifdef USE_REVERSED_DEPTH_BUFFER return depth * ( far - near ) - far; #else return depth * ( near - far ) - near; #endif } float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) { return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ ); } float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) { #ifdef USE_REVERSED_DEPTH_BUFFER return ( near * far ) / ( ( near - far ) * depth - near ); #else return ( near * far ) / ( ( far - near ) * depth - far ); #endif }`,premultiplied_alpha_fragment:`#ifdef PREMULTIPLIED_ALPHA gl_FragColor.rgb *= gl_FragColor.a; #endif`,project_vertex:`vec4 mvPosition = vec4( transformed, 1.0 ); #ifdef USE_BATCHING mvPosition = batchingMatrix * mvPosition; #endif #ifdef USE_INSTANCING mvPosition = instanceMatrix * mvPosition; #endif mvPosition = modelViewMatrix * mvPosition; gl_Position = projectionMatrix * mvPosition;`,dithering_fragment:`#ifdef DITHERING gl_FragColor.rgb = dithering( gl_FragColor.rgb ); #endif`,dithering_pars_fragment:`#ifdef DITHERING vec3 dithering( vec3 color ) { float grid_position = rand( gl_FragCoord.xy ); vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 ); dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position ); return color + dither_shift_RGB; } #endif`,roughnessmap_fragment:`float roughnessFactor = roughness; #ifdef USE_ROUGHNESSMAP vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv ); roughnessFactor *= texelRoughness.g; #endif`,roughnessmap_pars_fragment:`#ifdef USE_ROUGHNESSMAP uniform sampler2D roughnessMap; #endif`,shadowmap_pars_fragment:`#if NUM_SPOT_LIGHT_COORDS > 0 varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; #endif #if NUM_SPOT_LIGHT_MAPS > 0 uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ]; #endif #ifdef USE_SHADOWMAP #if NUM_DIR_LIGHT_SHADOWS > 0 #if defined( SHADOWMAP_TYPE_PCF ) uniform sampler2DShadow directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ]; #else uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ]; #endif varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; struct DirectionalLightShadow { float shadowIntensity; float shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; }; uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; #endif #if NUM_SPOT_LIGHT_SHADOWS > 0 #if defined( SHADOWMAP_TYPE_PCF ) uniform sampler2DShadow spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ]; #else uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ]; #endif struct SpotLightShadow { float shadowIntensity; float shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; }; uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; #endif #if NUM_POINT_LIGHT_SHADOWS > 0 #if defined( SHADOWMAP_TYPE_PCF ) uniform samplerCubeShadow pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ]; #elif defined( SHADOWMAP_TYPE_BASIC ) uniform samplerCube pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ]; #endif varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; struct PointLightShadow { float shadowIntensity; float shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; float shadowCameraNear; float shadowCameraFar; }; uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; #endif #if defined( SHADOWMAP_TYPE_PCF ) float interleavedGradientNoise( vec2 position ) { return fract( 52.9829189 * fract( dot( position, vec2( 0.06711056, 0.00583715 ) ) ) ); } vec2 vogelDiskSample( int sampleIndex, int samplesCount, float phi ) { const float goldenAngle = 2.399963229728653; float r = sqrt( ( float( sampleIndex ) + 0.5 ) / float( samplesCount ) ); float theta = float( sampleIndex ) * goldenAngle + phi; return vec2( cos( theta ), sin( theta ) ) * r; } #endif #if defined( SHADOWMAP_TYPE_PCF ) float getShadow( sampler2DShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) { float shadow = 1.0; shadowCoord.xyz /= shadowCoord.w; shadowCoord.z += shadowBias; bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; bool frustumTest = inFrustum && shadowCoord.z <= 1.0; if ( frustumTest ) { vec2 texelSize = vec2( 1.0 ) / shadowMapSize; float radius = shadowRadius * texelSize.x; float phi = interleavedGradientNoise( gl_FragCoord.xy ) * PI2; shadow = ( texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 0, 5, phi ) * radius, shadowCoord.z ) ) + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 1, 5, phi ) * radius, shadowCoord.z ) ) + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 2, 5, phi ) * radius, shadowCoord.z ) ) + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 3, 5, phi ) * radius, shadowCoord.z ) ) + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 4, 5, phi ) * radius, shadowCoord.z ) ) ) * 0.2; } return mix( 1.0, shadow, shadowIntensity ); } #elif defined( SHADOWMAP_TYPE_VSM ) float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) { float shadow = 1.0; shadowCoord.xyz /= shadowCoord.w; #ifdef USE_REVERSED_DEPTH_BUFFER shadowCoord.z -= shadowBias; #else shadowCoord.z += shadowBias; #endif bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; bool frustumTest = inFrustum && shadowCoord.z <= 1.0; if ( frustumTest ) { vec2 distribution = texture2D( shadowMap, shadowCoord.xy ).rg; float mean = distribution.x; float variance = distribution.y * distribution.y; #ifdef USE_REVERSED_DEPTH_BUFFER float hard_shadow = step( mean, shadowCoord.z ); #else float hard_shadow = step( shadowCoord.z, mean ); #endif if ( hard_shadow == 1.0 ) { shadow = 1.0; } else { variance = max( variance, 0.0000001 ); float d = shadowCoord.z - mean; float p_max = variance / ( variance + d * d ); p_max = clamp( ( p_max - 0.3 ) / 0.65, 0.0, 1.0 ); shadow = max( hard_shadow, p_max ); } } return mix( 1.0, shadow, shadowIntensity ); } #else float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) { float shadow = 1.0; shadowCoord.xyz /= shadowCoord.w; #ifdef USE_REVERSED_DEPTH_BUFFER shadowCoord.z -= shadowBias; #else shadowCoord.z += shadowBias; #endif bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; bool frustumTest = inFrustum && shadowCoord.z <= 1.0; if ( frustumTest ) { float depth = texture2D( shadowMap, shadowCoord.xy ).r; #ifdef USE_REVERSED_DEPTH_BUFFER shadow = step( depth, shadowCoord.z ); #else shadow = step( shadowCoord.z, depth ); #endif } return mix( 1.0, shadow, shadowIntensity ); } #endif #if NUM_POINT_LIGHT_SHADOWS > 0 #if defined( SHADOWMAP_TYPE_PCF ) float getPointShadow( samplerCubeShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) { float shadow = 1.0; vec3 lightToPosition = shadowCoord.xyz; vec3 bd3D = normalize( lightToPosition ); vec3 absVec = abs( lightToPosition ); float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z ); if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) { #ifdef USE_REVERSED_DEPTH_BUFFER float dp = ( shadowCameraNear * ( shadowCameraFar - viewSpaceZ ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) ); dp -= shadowBias; #else float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) ); dp += shadowBias; #endif float texelSize = shadowRadius / shadowMapSize.x; vec3 absDir = abs( bd3D ); vec3 tangent = absDir.x > absDir.z ? vec3( 0.0, 1.0, 0.0 ) : vec3( 1.0, 0.0, 0.0 ); tangent = normalize( cross( bd3D, tangent ) ); vec3 bitangent = cross( bd3D, tangent ); float phi = interleavedGradientNoise( gl_FragCoord.xy ) * PI2; vec2 sample0 = vogelDiskSample( 0, 5, phi ); vec2 sample1 = vogelDiskSample( 1, 5, phi ); vec2 sample2 = vogelDiskSample( 2, 5, phi ); vec2 sample3 = vogelDiskSample( 3, 5, phi ); vec2 sample4 = vogelDiskSample( 4, 5, phi ); shadow = ( texture( shadowMap, vec4( bd3D + ( tangent * sample0.x + bitangent * sample0.y ) * texelSize, dp ) ) + texture( shadowMap, vec4( bd3D + ( tangent * sample1.x + bitangent * sample1.y ) * texelSize, dp ) ) + texture( shadowMap, vec4( bd3D + ( tangent * sample2.x + bitangent * sample2.y ) * texelSize, dp ) ) + texture( shadowMap, vec4( bd3D + ( tangent * sample3.x + bitangent * sample3.y ) * texelSize, dp ) ) + texture( shadowMap, vec4( bd3D + ( tangent * sample4.x + bitangent * sample4.y ) * texelSize, dp ) ) ) * 0.2; } return mix( 1.0, shadow, shadowIntensity ); } #elif defined( SHADOWMAP_TYPE_BASIC ) float getPointShadow( samplerCube shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) { float shadow = 1.0; vec3 lightToPosition = shadowCoord.xyz; vec3 absVec = abs( lightToPosition ); float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z ); if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) { float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) ); dp += shadowBias; vec3 bd3D = normalize( lightToPosition ); float depth = textureCube( shadowMap, bd3D ).r; #ifdef USE_REVERSED_DEPTH_BUFFER depth = 1.0 - depth; #endif shadow = step( dp, depth ); } return mix( 1.0, shadow, shadowIntensity ); } #endif #endif #endif`,shadowmap_pars_vertex:`#if NUM_SPOT_LIGHT_COORDS > 0 uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ]; varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; #endif #ifdef USE_SHADOWMAP #if NUM_DIR_LIGHT_SHADOWS > 0 uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ]; varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; struct DirectionalLightShadow { float shadowIntensity; float shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; }; uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; #endif #if NUM_SPOT_LIGHT_SHADOWS > 0 struct SpotLightShadow { float shadowIntensity; float shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; }; uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; #endif #if NUM_POINT_LIGHT_SHADOWS > 0 uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ]; varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; struct PointLightShadow { float shadowIntensity; float shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; float shadowCameraNear; float shadowCameraFar; }; uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; #endif #endif`,shadowmap_vertex:`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 ) #ifdef HAS_NORMAL vec3 shadowWorldNormal = transformNormalByInverseViewMatrix( transformedNormal, viewMatrix ); #else vec3 shadowWorldNormal = vec3( 0.0 ); #endif vec4 shadowWorldPosition; #endif #if defined( USE_SHADOWMAP ) #if NUM_DIR_LIGHT_SHADOWS > 0 #pragma unroll_loop_start for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 ); vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition; } #pragma unroll_loop_end #endif #if NUM_POINT_LIGHT_SHADOWS > 0 #pragma unroll_loop_start for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 ); vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition; } #pragma unroll_loop_end #endif #endif #if NUM_SPOT_LIGHT_COORDS > 0 #pragma unroll_loop_start for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) { shadowWorldPosition = worldPosition; #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias; #endif vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition; } #pragma unroll_loop_end #endif`,shadowmask_pars_fragment:`float getShadowMask() { float shadow = 1.0; #ifdef USE_SHADOWMAP #if NUM_DIR_LIGHT_SHADOWS > 0 DirectionalLightShadow directionalLight; #pragma unroll_loop_start for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { directionalLight = directionalLightShadows[ i ]; shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; } #pragma unroll_loop_end #endif #if NUM_SPOT_LIGHT_SHADOWS > 0 SpotLightShadow spotLight; #pragma unroll_loop_start for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) { spotLight = spotLightShadows[ i ]; shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; } #pragma unroll_loop_end #endif #if NUM_POINT_LIGHT_SHADOWS > 0 && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) ) PointLightShadow pointLight; #pragma unroll_loop_start for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { pointLight = pointLightShadows[ i ]; shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0; } #pragma unroll_loop_end #endif #endif return shadow; }`,skinbase_vertex:`#ifdef USE_SKINNING mat4 boneMatX = getBoneMatrix( skinIndex.x ); mat4 boneMatY = getBoneMatrix( skinIndex.y ); mat4 boneMatZ = getBoneMatrix( skinIndex.z ); mat4 boneMatW = getBoneMatrix( skinIndex.w ); #endif`,skinning_pars_vertex:`#ifdef USE_SKINNING uniform mat4 bindMatrix; uniform mat4 bindMatrixInverse; uniform highp sampler2D boneTexture; mat4 getBoneMatrix( const in float i ) { int size = textureSize( boneTexture, 0 ).x; int j = int( i ) * 4; int x = j % size; int y = j / size; vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 ); vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 ); vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 ); vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 ); return mat4( v1, v2, v3, v4 ); } #endif`,skinning_vertex:`#ifdef USE_SKINNING vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 ); vec4 skinned = vec4( 0.0 ); skinned += boneMatX * skinVertex * skinWeight.x; skinned += boneMatY * skinVertex * skinWeight.y; skinned += boneMatZ * skinVertex * skinWeight.z; skinned += boneMatW * skinVertex * skinWeight.w; transformed = ( bindMatrixInverse * skinned ).xyz; #endif`,skinnormal_vertex:`#ifdef USE_SKINNING mat4 skinMatrix = mat4( 0.0 ); skinMatrix += skinWeight.x * boneMatX; skinMatrix += skinWeight.y * boneMatY; skinMatrix += skinWeight.z * boneMatZ; skinMatrix += skinWeight.w * boneMatW; skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix; objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz; #ifdef USE_TANGENT objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz; #endif #endif`,specularmap_fragment:`float specularStrength; #ifdef USE_SPECULARMAP vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv ); specularStrength = texelSpecular.r; #else specularStrength = 1.0; #endif`,specularmap_pars_fragment:`#ifdef USE_SPECULARMAP uniform sampler2D specularMap; #endif`,tonemapping_fragment:`#if defined( TONE_MAPPING ) gl_FragColor.rgb = toneMapping( gl_FragColor.rgb ); #endif`,tonemapping_pars_fragment:`#ifndef saturate #define saturate( a ) clamp( a, 0.0, 1.0 ) #endif uniform float toneMappingExposure; vec3 LinearToneMapping( vec3 color ) { return saturate( toneMappingExposure * color ); } vec3 ReinhardToneMapping( vec3 color ) { color *= toneMappingExposure; return saturate( color / ( vec3( 1.0 ) + color ) ); } vec3 CineonToneMapping( vec3 color ) { color *= toneMappingExposure; color = max( vec3( 0.0 ), color - 0.004 ); return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) ); } vec3 RRTAndODTFit( vec3 v ) { vec3 a = v * ( v + 0.0245786 ) - 0.000090537; vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081; return a / b; } vec3 ACESFilmicToneMapping( vec3 color ) { const mat3 ACESInputMat = mat3( vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ), vec3( 0.04823, 0.01566, 0.83777 ) ); const mat3 ACESOutputMat = mat3( vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ), vec3( -0.07367, -0.00605, 1.07602 ) ); color *= toneMappingExposure / 0.6; color = ACESInputMat * color; color = RRTAndODTFit( color ); color = ACESOutputMat * color; return saturate( color ); } const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3( vec3( 1.6605, - 0.1246, - 0.0182 ), vec3( - 0.5876, 1.1329, - 0.1006 ), vec3( - 0.0728, - 0.0083, 1.1187 ) ); const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3( vec3( 0.6274, 0.0691, 0.0164 ), vec3( 0.3293, 0.9195, 0.0880 ), vec3( 0.0433, 0.0113, 0.8956 ) ); vec3 agxDefaultContrastApprox( vec3 x ) { vec3 x2 = x * x; vec3 x4 = x2 * x2; return + 15.5 * x4 * x2 - 40.14 * x4 * x + 31.96 * x4 - 6.868 * x2 * x + 0.4298 * x2 + 0.1191 * x - 0.00232; } vec3 AgXToneMapping( vec3 color ) { const mat3 AgXInsetMatrix = mat3( vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ), vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ), vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 ) ); const mat3 AgXOutsetMatrix = mat3( vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ), vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ), vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 ) ); const float AgxMinEv = - 12.47393; const float AgxMaxEv = 4.026069; color *= toneMappingExposure; color = LINEAR_SRGB_TO_LINEAR_REC2020 * color; color = AgXInsetMatrix * color; color = max( color, 1e-10 ); color = log2( color ); color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv ); color = clamp( color, 0.0, 1.0 ); color = agxDefaultContrastApprox( color ); color = AgXOutsetMatrix * color; color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) ); color = LINEAR_REC2020_TO_LINEAR_SRGB * color; color = clamp( color, 0.0, 1.0 ); return color; } vec3 NeutralToneMapping( vec3 color ) { const float StartCompression = 0.8 - 0.04; const float Desaturation = 0.15; color *= toneMappingExposure; float x = min( color.r, min( color.g, color.b ) ); float offset = x < 0.08 ? x - 6.25 * x * x : 0.04; color -= offset; float peak = max( color.r, max( color.g, color.b ) ); if ( peak < StartCompression ) return color; float d = 1. - StartCompression; float newPeak = 1. - d * d / ( peak + d - StartCompression ); color *= newPeak / peak; float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. ); return mix( color, vec3( newPeak ), g ); } vec3 CustomToneMapping( vec3 color ) { return color; }`,transmission_fragment:`#ifdef USE_TRANSMISSION material.transmission = transmission; material.transmissionAlpha = 1.0; material.thickness = thickness; material.attenuationDistance = attenuationDistance; material.attenuationColor = attenuationColor; #ifdef USE_TRANSMISSIONMAP material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r; #endif #ifdef USE_THICKNESSMAP material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g; #endif vec3 pos = vWorldPosition; vec3 v = normalize( cameraPosition - pos ); vec3 n = transformNormalByInverseViewMatrix( normal, viewMatrix ); vec4 transmitted = getIBLVolumeRefraction( n, v, material.roughness, material.diffuseContribution, material.specularColorBlended, material.specularF90, pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness, material.attenuationColor, material.attenuationDistance ); material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission ); totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission ); #endif`,transmission_pars_fragment:`#ifdef USE_TRANSMISSION uniform float transmission; uniform float thickness; uniform float attenuationDistance; uniform vec3 attenuationColor; #ifdef USE_TRANSMISSIONMAP uniform sampler2D transmissionMap; #endif #ifdef USE_THICKNESSMAP uniform sampler2D thicknessMap; #endif uniform vec2 transmissionSamplerSize; uniform sampler2D transmissionSamplerMap; uniform mat4 modelMatrix; uniform mat4 projectionMatrix; varying vec3 vWorldPosition; float w0( float a ) { return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 ); } float w1( float a ) { return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 ); } float w2( float a ){ return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 ); } float w3( float a ) { return ( 1.0 / 6.0 ) * ( a * a * a ); } float g0( float a ) { return w0( a ) + w1( a ); } float g1( float a ) { return w2( a ) + w3( a ); } float h0( float a ) { return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) ); } float h1( float a ) { return 1.0 + w3( a ) / ( w2( a ) + w3( a ) ); } vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) { uv = uv * texelSize.zw + 0.5; vec2 iuv = floor( uv ); vec2 fuv = fract( uv ); float g0x = g0( fuv.x ); float g1x = g1( fuv.x ); float h0x = h0( fuv.x ); float h1x = h1( fuv.x ); float h0y = h0( fuv.y ); float h1y = h1( fuv.y ); vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy; vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy; vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy; vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy; return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) + g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) ); } vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) { vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) ); vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) ); vec2 fLodSizeInv = 1.0 / fLodSize; vec2 cLodSizeInv = 1.0 / cLodSize; vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) ); vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) ); return mix( fSample, cSample, fract( lod ) ); } vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) { vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior ); vec3 modelScale; modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) ); modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) ); modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) ); return normalize( refractionVector ) * thickness * modelScale; } float applyIorToRoughness( const in float roughness, const in float ior ) { return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 ); } vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) { float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior ); return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod ); } vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) { if ( isinf( attenuationDistance ) ) { return vec3( 1.0 ); } else { vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance; vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance; } } vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor, const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix, const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness, const in vec3 attenuationColor, const in float attenuationDistance ) { vec4 transmittedLight; vec3 transmittance; #ifdef USE_DISPERSION float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion; vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread ); for ( int i = 0; i < 3; i ++ ) { vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix ); vec3 refractedRayExit = position + transmissionRay; vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 ); vec2 refractionCoords = ndcPos.xy / ndcPos.w; refractionCoords += 1.0; refractionCoords /= 2.0; vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] ); transmittedLight[ i ] = transmissionSample[ i ]; transmittedLight.a += transmissionSample.a; transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ]; } transmittedLight.a /= 3.0; #else vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix ); vec3 refractedRayExit = position + transmissionRay; vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 ); vec2 refractionCoords = ndcPos.xy / ndcPos.w; refractionCoords += 1.0; refractionCoords /= 2.0; transmittedLight = getTransmissionSample( refractionCoords, roughness, ior ); transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance ); #endif vec3 attenuatedColor = transmittance * transmittedLight.rgb; vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness ); float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0; return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor ); } #endif`,uv_pars_fragment:`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) varying vec2 vUv; #endif #ifdef USE_MAP varying vec2 vMapUv; #endif #ifdef USE_ALPHAMAP varying vec2 vAlphaMapUv; #endif #ifdef USE_LIGHTMAP varying vec2 vLightMapUv; #endif #ifdef USE_AOMAP varying vec2 vAoMapUv; #endif #ifdef USE_BUMPMAP varying vec2 vBumpMapUv; #endif #ifdef USE_NORMALMAP varying vec2 vNormalMapUv; #endif #ifdef USE_EMISSIVEMAP varying vec2 vEmissiveMapUv; #endif #ifdef USE_METALNESSMAP varying vec2 vMetalnessMapUv; #endif #ifdef USE_ROUGHNESSMAP varying vec2 vRoughnessMapUv; #endif #ifdef USE_ANISOTROPYMAP varying vec2 vAnisotropyMapUv; #endif #ifdef USE_CLEARCOATMAP varying vec2 vClearcoatMapUv; #endif #ifdef USE_CLEARCOAT_NORMALMAP varying vec2 vClearcoatNormalMapUv; #endif #ifdef USE_CLEARCOAT_ROUGHNESSMAP varying vec2 vClearcoatRoughnessMapUv; #endif #ifdef USE_IRIDESCENCEMAP varying vec2 vIridescenceMapUv; #endif #ifdef USE_IRIDESCENCE_THICKNESSMAP varying vec2 vIridescenceThicknessMapUv; #endif #ifdef USE_SHEEN_COLORMAP varying vec2 vSheenColorMapUv; #endif #ifdef USE_SHEEN_ROUGHNESSMAP varying vec2 vSheenRoughnessMapUv; #endif #ifdef USE_SPECULARMAP varying vec2 vSpecularMapUv; #endif #ifdef USE_SPECULAR_COLORMAP varying vec2 vSpecularColorMapUv; #endif #ifdef USE_SPECULAR_INTENSITYMAP varying vec2 vSpecularIntensityMapUv; #endif #ifdef USE_TRANSMISSIONMAP uniform mat3 transmissionMapTransform; varying vec2 vTransmissionMapUv; #endif #ifdef USE_THICKNESSMAP uniform mat3 thicknessMapTransform; varying vec2 vThicknessMapUv; #endif`,uv_pars_vertex:`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) varying vec2 vUv; #endif #ifdef USE_MAP uniform mat3 mapTransform; varying vec2 vMapUv; #endif #ifdef USE_ALPHAMAP uniform mat3 alphaMapTransform; varying vec2 vAlphaMapUv; #endif #ifdef USE_LIGHTMAP uniform mat3 lightMapTransform; varying vec2 vLightMapUv; #endif #ifdef USE_AOMAP uniform mat3 aoMapTransform; varying vec2 vAoMapUv; #endif #ifdef USE_BUMPMAP uniform mat3 bumpMapTransform; varying vec2 vBumpMapUv; #endif #ifdef USE_NORMALMAP uniform mat3 normalMapTransform; varying vec2 vNormalMapUv; #endif #ifdef USE_DISPLACEMENTMAP uniform mat3 displacementMapTransform; varying vec2 vDisplacementMapUv; #endif #ifdef USE_EMISSIVEMAP uniform mat3 emissiveMapTransform; varying vec2 vEmissiveMapUv; #endif #ifdef USE_METALNESSMAP uniform mat3 metalnessMapTransform; varying vec2 vMetalnessMapUv; #endif #ifdef USE_ROUGHNESSMAP uniform mat3 roughnessMapTransform; varying vec2 vRoughnessMapUv; #endif #ifdef USE_ANISOTROPYMAP uniform mat3 anisotropyMapTransform; varying vec2 vAnisotropyMapUv; #endif #ifdef USE_CLEARCOATMAP uniform mat3 clearcoatMapTransform; varying vec2 vClearcoatMapUv; #endif #ifdef USE_CLEARCOAT_NORMALMAP uniform mat3 clearcoatNormalMapTransform; varying vec2 vClearcoatNormalMapUv; #endif #ifdef USE_CLEARCOAT_ROUGHNESSMAP uniform mat3 clearcoatRoughnessMapTransform; varying vec2 vClearcoatRoughnessMapUv; #endif #ifdef USE_SHEEN_COLORMAP uniform mat3 sheenColorMapTransform; varying vec2 vSheenColorMapUv; #endif #ifdef USE_SHEEN_ROUGHNESSMAP uniform mat3 sheenRoughnessMapTransform; varying vec2 vSheenRoughnessMapUv; #endif #ifdef USE_IRIDESCENCEMAP uniform mat3 iridescenceMapTransform; varying vec2 vIridescenceMapUv; #endif #ifdef USE_IRIDESCENCE_THICKNESSMAP uniform mat3 iridescenceThicknessMapTransform; varying vec2 vIridescenceThicknessMapUv; #endif #ifdef USE_SPECULARMAP uniform mat3 specularMapTransform; varying vec2 vSpecularMapUv; #endif #ifdef USE_SPECULAR_COLORMAP uniform mat3 specularColorMapTransform; varying vec2 vSpecularColorMapUv; #endif #ifdef USE_SPECULAR_INTENSITYMAP uniform mat3 specularIntensityMapTransform; varying vec2 vSpecularIntensityMapUv; #endif #ifdef USE_TRANSMISSIONMAP uniform mat3 transmissionMapTransform; varying vec2 vTransmissionMapUv; #endif #ifdef USE_THICKNESSMAP uniform mat3 thicknessMapTransform; varying vec2 vThicknessMapUv; #endif`,uv_vertex:`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) vUv = vec3( uv, 1 ).xy; #endif #ifdef USE_MAP vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy; #endif #ifdef USE_ALPHAMAP vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy; #endif #ifdef USE_LIGHTMAP vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy; #endif #ifdef USE_AOMAP vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy; #endif #ifdef USE_BUMPMAP vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy; #endif #ifdef USE_NORMALMAP vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy; #endif #ifdef USE_DISPLACEMENTMAP vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy; #endif #ifdef USE_EMISSIVEMAP vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy; #endif #ifdef USE_METALNESSMAP vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy; #endif #ifdef USE_ROUGHNESSMAP vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy; #endif #ifdef USE_ANISOTROPYMAP vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy; #endif #ifdef USE_CLEARCOATMAP vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy; #endif #ifdef USE_CLEARCOAT_NORMALMAP vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy; #endif #ifdef USE_CLEARCOAT_ROUGHNESSMAP vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy; #endif #ifdef USE_IRIDESCENCEMAP vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy; #endif #ifdef USE_IRIDESCENCE_THICKNESSMAP vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy; #endif #ifdef USE_SHEEN_COLORMAP vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy; #endif #ifdef USE_SHEEN_ROUGHNESSMAP vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy; #endif #ifdef USE_SPECULARMAP vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy; #endif #ifdef USE_SPECULAR_COLORMAP vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy; #endif #ifdef USE_SPECULAR_INTENSITYMAP vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy; #endif #ifdef USE_TRANSMISSIONMAP vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy; #endif #ifdef USE_THICKNESSMAP vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy; #endif`,worldpos_vertex:`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0 vec4 worldPosition = vec4( transformed, 1.0 ); #ifdef USE_BATCHING worldPosition = batchingMatrix * worldPosition; #endif #ifdef USE_INSTANCING worldPosition = instanceMatrix * worldPosition; #endif worldPosition = modelMatrix * worldPosition; #endif`,background_vert:`varying vec2 vUv; uniform mat3 uvTransform; void main() { vUv = ( uvTransform * vec3( uv, 1 ) ).xy; gl_Position = vec4( position.xy, 1.0, 1.0 ); }`,background_frag:`uniform sampler2D t2D; uniform float backgroundIntensity; varying vec2 vUv; void main() { vec4 texColor = texture2D( t2D, vUv ); #ifdef DECODE_VIDEO_TEXTURE texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w ); #endif texColor.rgb *= backgroundIntensity; gl_FragColor = texColor; #include #include }`,backgroundCube_vert:`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include gl_Position.z = gl_Position.w; }`,backgroundCube_frag:`#ifdef ENVMAP_TYPE_CUBE uniform samplerCube envMap; #elif defined( ENVMAP_TYPE_CUBE_UV ) uniform sampler2D envMap; #endif uniform float backgroundBlurriness; uniform float backgroundIntensity; uniform mat3 backgroundRotation; varying vec3 vWorldDirection; #include void main() { #ifdef ENVMAP_TYPE_CUBE vec4 texColor = textureCube( envMap, backgroundRotation * vWorldDirection ); #elif defined( ENVMAP_TYPE_CUBE_UV ) vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness ); #else vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 ); #endif texColor.rgb *= backgroundIntensity; gl_FragColor = texColor; #include #include }`,cube_vert:`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include gl_Position.z = gl_Position.w; }`,cube_frag:`uniform samplerCube tCube; uniform float tFlip; uniform float opacity; varying vec3 vWorldDirection; void main() { vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) ); gl_FragColor = texColor; gl_FragColor.a *= opacity; #include #include }`,depth_vert:`#include #include #include #include #include #include #include #include varying vec2 vHighPrecisionZW; void main() { #include #include #include #include #ifdef USE_DISPLACEMENTMAP #include #include #include #endif #include #include #include #include #include #include #include vHighPrecisionZW = gl_Position.zw; }`,depth_frag:`#if DEPTH_PACKING == 3200 uniform float opacity; #endif #include #include #include #include #include #include #include #include #include varying vec2 vHighPrecisionZW; void main() { vec4 diffuseColor = vec4( 1.0 ); #include #if DEPTH_PACKING == 3200 diffuseColor.a = opacity; #endif #include #include #include #include #include #ifdef USE_REVERSED_DEPTH_BUFFER float fragCoordZ = vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ]; #else float fragCoordZ = 0.5 * vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ] + 0.5; #endif #if DEPTH_PACKING == 3200 gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity ); #elif DEPTH_PACKING == 3201 gl_FragColor = packDepthToRGBA( fragCoordZ ); #elif DEPTH_PACKING == 3202 gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 ); #elif DEPTH_PACKING == 3203 gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 ); #endif }`,distance_vert:`#define DISTANCE varying vec3 vWorldPosition; #include #include #include #include #include #include #include void main() { #include #include #include #include #ifdef USE_DISPLACEMENTMAP #include #include #include #endif #include #include #include #include #include #include #include vWorldPosition = worldPosition.xyz; }`,distance_frag:`#define DISTANCE uniform vec3 referencePosition; uniform float nearDistance; uniform float farDistance; varying vec3 vWorldPosition; #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( 1.0 ); #include #include #include #include #include float dist = length( vWorldPosition - referencePosition ); dist = ( dist - nearDistance ) / ( farDistance - nearDistance ); dist = saturate( dist ); gl_FragColor = vec4( dist, 0.0, 0.0, 1.0 ); }`,equirect_vert:`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include }`,equirect_frag:`uniform sampler2D tEquirect; varying vec3 vWorldDirection; #include void main() { vec3 direction = normalize( vWorldDirection ); vec2 sampleUV = equirectUv( direction ); gl_FragColor = texture2D( tEquirect, sampleUV ); #include #include }`,linedashed_vert:`uniform float scale; attribute float lineDistance; varying float vLineDistance; #include #include #include #include #include #include #include void main() { vLineDistance = scale * lineDistance; #include #include #include #include #include #include #include #include #include #include }`,linedashed_frag:`uniform vec3 diffuse; uniform float opacity; uniform float dashSize; uniform float totalSize; varying float vLineDistance; #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include if ( mod( vLineDistance, totalSize ) > dashSize ) { discard; } vec3 outgoingLight = vec3( 0.0 ); #include #include #include outgoingLight = diffuseColor.rgb; #include #include #include #include #include }`,meshbasic_vert:`#include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING ) #include #include #include #include #include #endif #include #include #include #include #include #include #include #include #include }`,meshbasic_frag:`uniform vec3 diffuse; uniform float opacity; #ifndef FLAT_SHADED varying vec3 vNormal; #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include #include #include #include #include #include #include #include ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); #ifdef USE_LIGHTMAP vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI; #else reflectedLight.indirectDiffuse += vec3( 1.0 ); #endif #include reflectedLight.indirectDiffuse *= diffuseColor.rgb; vec3 outgoingLight = reflectedLight.indirectDiffuse; #include #include #include #include #include #include #include }`,meshlambert_vert:`#define LAMBERT varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; #include #include #include #include }`,meshlambert_frag:`#define LAMBERT uniform vec3 diffuse; uniform vec3 emissive; uniform float opacity; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); vec3 totalEmissiveRadiance = emissive; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; #include #include #include #include #include #include #include }`,meshmatcap_vert:`#define MATCAP varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; }`,meshmatcap_frag:`#define MATCAP uniform vec3 diffuse; uniform float opacity; uniform sampler2D matcap; varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include #include #include #include #include #include #include #include #include vec3 viewDir = normalize( vViewPosition ); vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) ); vec3 y = cross( viewDir, x ); vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5; #ifdef USE_MATCAP vec4 matcapColor = texture2D( matcap, uv ); #else vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 ); #endif vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb; #include #include #include #include #include #include }`,meshnormal_vert:`#define NORMAL #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) varying vec3 vViewPosition; #endif #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) vViewPosition = - mvPosition.xyz; #endif }`,meshnormal_frag:`#define NORMAL uniform float opacity; #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) varying vec3 vViewPosition; #endif #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity ); #include #include #include #include gl_FragColor = vec4( normalize( normal ) * 0.5 + 0.5, diffuseColor.a ); #ifdef OPAQUE gl_FragColor.a = 1.0; #endif }`,meshphong_vert:`#define PHONG varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; #include #include #include #include }`,meshphong_frag:`#define PHONG uniform vec3 diffuse; uniform vec3 emissive; uniform vec3 specular; uniform float shininess; uniform float opacity; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); vec3 totalEmissiveRadiance = emissive; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance; #include #include #include #include #include #include #include }`,meshphysical_vert:`#define STANDARD varying vec3 vViewPosition; #ifdef USE_TRANSMISSION varying vec3 vWorldPosition; #endif #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; #include #include #include #ifdef USE_TRANSMISSION vWorldPosition = worldPosition.xyz; #endif }`,meshphysical_frag:`#define STANDARD #ifdef PHYSICAL #define IOR #define USE_SPECULAR #endif uniform vec3 diffuse; uniform vec3 emissive; uniform float roughness; uniform float metalness; uniform float opacity; #ifdef IOR uniform float ior; #endif #ifdef USE_SPECULAR uniform float specularIntensity; uniform vec3 specularColor; #ifdef USE_SPECULAR_COLORMAP uniform sampler2D specularColorMap; #endif #ifdef USE_SPECULAR_INTENSITYMAP uniform sampler2D specularIntensityMap; #endif #endif #ifdef USE_CLEARCOAT uniform float clearcoat; uniform float clearcoatRoughness; #endif #ifdef USE_DISPERSION uniform float dispersion; #endif #ifdef USE_IRIDESCENCE uniform float iridescence; uniform float iridescenceIOR; uniform float iridescenceThicknessMinimum; uniform float iridescenceThicknessMaximum; #endif #ifdef USE_SHEEN uniform vec3 sheenColor; uniform float sheenRoughness; #ifdef USE_SHEEN_COLORMAP uniform sampler2D sheenColorMap; #endif #ifdef USE_SHEEN_ROUGHNESSMAP uniform sampler2D sheenRoughnessMap; #endif #endif #ifdef USE_ANISOTROPY uniform vec2 anisotropyVector; #ifdef USE_ANISOTROPYMAP uniform sampler2D anisotropyMap; #endif #endif varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); vec3 totalEmissiveRadiance = emissive; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse; vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular; #include vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance; #ifdef USE_SHEEN outgoingLight = outgoingLight + sheenSpecularDirect + sheenSpecularIndirect; #endif #ifdef USE_CLEARCOAT float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) ); vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc ); outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat; #endif #include #include #include #include #include #include }`,meshtoon_vert:`#define TOON varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; #include #include #include }`,meshtoon_frag:`#define TOON uniform vec3 diffuse; uniform vec3 emissive; uniform float opacity; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); vec3 totalEmissiveRadiance = emissive; #include #include #include #include #include #include #include #include #include #include #include #include #include #include vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; #include #include #include #include #include #include }`,points_vert:`uniform float size; uniform float scale; #include #include #include #include #include #include #ifdef USE_POINTS_UV varying vec2 vUv; uniform mat3 uvTransform; #endif void main() { #ifdef USE_POINTS_UV vUv = ( uvTransform * vec3( uv, 1 ) ).xy; #endif #include #include #include #include #include #include gl_PointSize = size; #ifdef USE_SIZEATTENUATION bool isPerspective = isPerspectiveMatrix( projectionMatrix ); if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z ); #endif #include #include #include #include }`,points_frag:`uniform vec3 diffuse; uniform float opacity; #include #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include vec3 outgoingLight = vec3( 0.0 ); #include #include #include #include #include outgoingLight = diffuseColor.rgb; #include #include #include #include #include }`,shadow_vert:`#include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include }`,shadow_frag:`uniform vec3 color; uniform float opacity; #include #include #include #include #include #include #include void main() { #include gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) ); #include #include #include #include }`,sprite_vert:`uniform float rotation; uniform vec2 center; #include #include #include #include #include void main() { #include vec4 mvPosition = modelViewMatrix[ 3 ]; vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) ); #ifndef USE_SIZEATTENUATION bool isPerspective = isPerspectiveMatrix( projectionMatrix ); if ( isPerspective ) scale *= - mvPosition.z; #endif vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale; vec2 rotatedPosition; rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y; rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y; mvPosition.xy += rotatedPosition; gl_Position = projectionMatrix * mvPosition; #include #include #include }`,sprite_frag:`uniform vec3 diffuse; uniform float opacity; #include #include #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include vec3 outgoingLight = vec3( 0.0 ); #include #include #include #include #include outgoingLight = diffuseColor.rgb; #include #include #include #include }`},ml={common:{diffuse:{value:new Er(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new En},alphaMap:{value:null},alphaMapTransform:{value:new En},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new En}},envmap:{envMap:{value:null},envMapRotation:{value:new En},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new En}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new En}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new En},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new En},normalScale:{value:new L(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new En},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new En}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new En}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new En}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Er(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{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 R},probesMax:{value:new R},probesResolution:{value:new R}},points:{diffuse:{value:new Er(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new En},alphaTest:{value:0},uvTransform:{value:new En}},sprite:{diffuse:{value:new Er(16777215)},opacity:{value:1},center:{value:new L(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new En},alphaMap:{value:null},alphaMapTransform:{value:new En},alphaTest:{value:0}}},hl={basic:{uniforms:ms([ml.common,ml.specularmap,ml.envmap,ml.aomap,ml.lightmap,ml.fog]),vertexShader:pl.meshbasic_vert,fragmentShader:pl.meshbasic_frag},lambert:{uniforms:ms([ml.common,ml.specularmap,ml.envmap,ml.aomap,ml.lightmap,ml.emissivemap,ml.bumpmap,ml.normalmap,ml.displacementmap,ml.fog,ml.lights,{emissive:{value:new Er(0)},envMapIntensity:{value:1}}]),vertexShader:pl.meshlambert_vert,fragmentShader:pl.meshlambert_frag},phong:{uniforms:ms([ml.common,ml.specularmap,ml.envmap,ml.aomap,ml.lightmap,ml.emissivemap,ml.bumpmap,ml.normalmap,ml.displacementmap,ml.fog,ml.lights,{emissive:{value:new Er(0)},specular:{value:new Er(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:pl.meshphong_vert,fragmentShader:pl.meshphong_frag},standard:{uniforms:ms([ml.common,ml.envmap,ml.aomap,ml.lightmap,ml.emissivemap,ml.bumpmap,ml.normalmap,ml.displacementmap,ml.roughnessmap,ml.metalnessmap,ml.fog,ml.lights,{emissive:{value:new Er(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:pl.meshphysical_vert,fragmentShader:pl.meshphysical_frag},toon:{uniforms:ms([ml.common,ml.aomap,ml.lightmap,ml.emissivemap,ml.bumpmap,ml.normalmap,ml.displacementmap,ml.gradientmap,ml.fog,ml.lights,{emissive:{value:new Er(0)}}]),vertexShader:pl.meshtoon_vert,fragmentShader:pl.meshtoon_frag},matcap:{uniforms:ms([ml.common,ml.bumpmap,ml.normalmap,ml.displacementmap,ml.fog,{matcap:{value:null}}]),vertexShader:pl.meshmatcap_vert,fragmentShader:pl.meshmatcap_frag},points:{uniforms:ms([ml.points,ml.fog]),vertexShader:pl.points_vert,fragmentShader:pl.points_frag},dashed:{uniforms:ms([ml.common,ml.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:pl.linedashed_vert,fragmentShader:pl.linedashed_frag},depth:{uniforms:ms([ml.common,ml.displacementmap]),vertexShader:pl.depth_vert,fragmentShader:pl.depth_frag},normal:{uniforms:ms([ml.common,ml.bumpmap,ml.normalmap,ml.displacementmap,{opacity:{value:1}}]),vertexShader:pl.meshnormal_vert,fragmentShader:pl.meshnormal_frag},sprite:{uniforms:ms([ml.sprite,ml.fog]),vertexShader:pl.sprite_vert,fragmentShader:pl.sprite_frag},background:{uniforms:{uvTransform:{value:new En},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:pl.background_vert,fragmentShader:pl.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new En}},vertexShader:pl.backgroundCube_vert,fragmentShader:pl.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:pl.cube_vert,fragmentShader:pl.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:pl.equirect_vert,fragmentShader:pl.equirect_frag},distance:{uniforms:ms([ml.common,ml.displacementmap,{referencePosition:{value:new R},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:pl.distance_vert,fragmentShader:pl.distance_frag},shadow:{uniforms:ms([ml.lights,ml.fog,{color:{value:new Er(0)},opacity:{value:1}}]),vertexShader:pl.shadow_vert,fragmentShader:pl.shadow_frag}};hl.physical={uniforms:ms([hl.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new En},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new En},clearcoatNormalScale:{value:new L(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new En},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new En},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new En},sheen:{value:0},sheenColor:{value:new Er(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new En},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new En},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new En},transmissionSamplerSize:{value:new L},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new En},attenuationDistance:{value:0},attenuationColor:{value:new Er(0)},specularColor:{value:new Er(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new En},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new En},anisotropyVector:{value:new L},anisotropyMap:{value:null},anisotropyMapTransform:{value:new En}}]),vertexShader:pl.meshphysical_vert,fragmentShader:pl.meshphysical_frag};var gl={r:0,b:0,g:0},_l=new qn,vl=new En;vl.set(-1,0,0,0,1,0,0,0,1);function yl(e,t,n,r,i,a){let o=new Er(0),s=i===!0?0:1,c,l,u=null,d=0,f=null;function p(e){let n=e.isScene===!0?e.background:null;if(n&&n.isTexture){let r=e.backgroundBlurriness>0;n=t.get(n,r)}return n}function m(t){let r=!1,i=p(t);i===null?g(o,s):i&&i.isColor&&(g(i,1),r=!0);let c=e.xr.getEnvironmentBlendMode();c===`additive`?n.buffers.color.setClear(0,0,0,1,a):c===`alpha-blend`&&n.buffers.color.setClear(0,0,0,0,a),(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 h(t,n){let i=p(n);i&&(i.isCubeTexture||i.mapping===306)?(l===void 0&&(l=new ea(new Ba(1,1,1),new xs({name:`BackgroundCubeMaterial`,uniforms:ps(hl.backgroundCube.uniforms),vertexShader:hl.backgroundCube.vertexShader,fragmentShader:hl.backgroundCube.fragmentShader,side:1,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute(`normal`),l.geometry.deleteAttribute(`uv`),l.onBeforeRender=function(e,t,n){this.matrixWorld.copyPosition(n.matrixWorld)},Object.defineProperty(l.material,`envMap`,{get:function(){return this.uniforms.envMap.value}}),r.update(l)),l.material.uniforms.envMap.value=i,l.material.uniforms.backgroundBlurriness.value=n.backgroundBlurriness,l.material.uniforms.backgroundIntensity.value=n.backgroundIntensity,l.material.uniforms.backgroundRotation.value.setFromMatrix4(_l.makeRotationFromEuler(n.backgroundRotation)).transpose(),i.isCubeTexture&&i.isRenderTargetTexture===!1&&l.material.uniforms.backgroundRotation.value.premultiply(vl),l.material.toneMapped=jn.getTransfer(i.colorSpace)!==St,(u!==i||d!==i.version||f!==e.toneMapping)&&(l.material.needsUpdate=!0,u=i,d=i.version,f=e.toneMapping),l.layers.enableAll(),t.unshift(l,l.geometry,l.material,0,0,null)):i&&i.isTexture&&(c===void 0&&(c=new ea(new ss(2,2),new xs({name:`BackgroundMaterial`,uniforms:ps(hl.background.uniforms),vertexShader:hl.background.vertexShader,fragmentShader:hl.background.fragmentShader,side:0,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute(`normal`),Object.defineProperty(c.material,`map`,{get:function(){return this.uniforms.t2D.value}}),r.update(c)),c.material.uniforms.t2D.value=i,c.material.uniforms.backgroundIntensity.value=n.backgroundIntensity,c.material.toneMapped=jn.getTransfer(i.colorSpace)!==St,i.matrixAutoUpdate===!0&&i.updateMatrix(),c.material.uniforms.uvTransform.value.copy(i.matrix),(u!==i||d!==i.version||f!==e.toneMapping)&&(c.material.needsUpdate=!0,u=i,d=i.version,f=e.toneMapping),c.layers.enableAll(),t.unshift(c,c.geometry,c.material,0,0,null))}function g(t,r){t.getRGB(gl,_s(e)),n.buffers.color.setClear(gl.r,gl.g,gl.b,r,a)}function _(){l!==void 0&&(l.geometry.dispose(),l.material.dispose(),l=void 0),c!==void 0&&(c.geometry.dispose(),c.material.dispose(),c=void 0)}return{getClearColor:function(){return o},setClearColor:function(e,t=1){o.set(e),s=t,g(o,s)},getClearAlpha:function(){return s},setClearAlpha:function(e){s=e,g(o,s)},render:m,addToRenderList:h,dispose:_}}function bl(e,t){let n=e.getParameter(e.MAX_VERTEX_ATTRIBS),r={},i=f(null),a=i,o=!1;function s(n,r,i,s,c){let u=!1,f=d(n,s,i,r);a!==f&&(a=f,l(a.object)),u=p(n,s,i,c),u&&m(n,s,i,c),c!==null&&t.update(c,e.ELEMENT_ARRAY_BUFFER),(u||o)&&(o=!1,b(n,r,i,s),c!==null&&e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,t.get(c).buffer))}function c(){return e.createVertexArray()}function l(t){return e.bindVertexArray(t)}function u(t){return e.deleteVertexArray(t)}function d(e,t,n,i){let a=i.wireframe===!0,o=r[t.id];o===void 0&&(o={},r[t.id]=o);let s=e.isInstancedMesh===!0?e.id:0,l=o[s];l===void 0&&(l={},o[s]=l);let u=l[n.id];u===void 0&&(u={},l[n.id]=u);let d=u[a];return d===void 0&&(d=f(c()),u[a]=d),d}function f(e){let t=[],r=[],i=[];for(let e=0;e=0){let n=i[t],r=o[t];if(r===void 0&&(t===`instanceMatrix`&&e.instanceMatrix&&(r=e.instanceMatrix),t===`instanceColor`&&e.instanceColor&&(r=e.instanceColor)),n===void 0||n.attribute!==r||r&&n.data!==r.data)return!0;s++}return a.attributesNum!==s||a.index!==r}function m(e,t,n,r){let i={},o=t.attributes,s=0,c=n.getAttributes();for(let t in c)if(c[t].location>=0){let n=o[t];n===void 0&&(t===`instanceMatrix`&&e.instanceMatrix&&(n=e.instanceMatrix),t===`instanceColor`&&e.instanceColor&&(n=e.instanceColor));let r={};r.attribute=n,n&&n.data&&(r.data=n.data),i[t]=r,s++}a.attributes=i,a.attributesNum=s,a.index=r}function h(){let e=a.newAttributes;for(let t=0,n=e.length;t=0){let s=o[r];if(s===void 0&&(r===`instanceMatrix`&&n.instanceMatrix&&(s=n.instanceMatrix),r===`instanceColor`&&n.instanceColor&&(s=n.instanceColor)),s!==void 0){let r=s.normalized,o=s.itemSize,c=t.get(s);if(c===void 0)continue;let l=c.buffer,u=c.type,d=c.bytesPerElement,f=u===e.INT||u===e.UNSIGNED_INT||s.gpuType===1013;if(s.isInterleavedBufferAttribute){let t=s.data,c=t.stride,p=s.offset;if(t.isInstancedInterleavedBuffer){for(let e=0;e0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT).precision>0)return`highp`;t=`mediump`}return t===`mediump`&&e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.MEDIUM_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.MEDIUM_FLOAT).precision>0?`mediump`:`lowp`}let l=n.precision===void 0?`highp`:n.precision,u=c(l);u!==l&&(F(`WebGLRenderer:`,l,`not supported, using`,u,`instead.`),l=u);let d=n.logarithmicDepthBuffer===!0,f=n.reversedDepthBuffer===!0&&t.has(`EXT_clip_control`);n.reversedDepthBuffer===!0&&f===!1&&F(`WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.`);let p=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),m=e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS),h=e.getParameter(e.MAX_TEXTURE_SIZE),g=e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE),_=e.getParameter(e.MAX_VERTEX_ATTRIBS),v=e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),y=e.getParameter(e.MAX_VARYING_VECTORS),b=e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),x=e.getParameter(e.MAX_SAMPLES),S=e.getParameter(e.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:a,getMaxPrecision:c,textureFormatReadable:o,textureTypeReadable:s,precision:l,logarithmicDepthBuffer:d,reversedDepthBuffer:f,maxTextures:p,maxVertexTextures:m,maxTextureSize:h,maxCubemapSize:g,maxAttributes:_,maxVertexUniforms:v,maxVaryings:y,maxFragmentUniforms:b,maxSamples:x,samples:S}}function Cl(e){let t=this,n=null,r=0,i=!1,a=!1,o=new ca,s=new En,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(e,t){let n=e.length!==0||t||r!==0||i;return i=t,r=e.length,n},this.beginShadows=function(){a=!0,u(null)},this.endShadows=function(){a=!1},this.setGlobalState=function(e,t){n=u(e,t,0)},this.setState=function(t,o,s){let d=t.clippingPlanes,f=t.clipIntersection,p=t.clipShadows,m=e.get(t);if(!i||d===null||d.length===0||a&&!p)a?u(null):l();else{let e=a?0:r,t=e*4,i=m.clippingState||null;c.value=i,i=u(d,o,t,s);for(let e=0;e!==t;++e)i[e]=n[e];m.clippingState=i,this.numIntersection=f?this.numPlanes:0,this.numPlanes+=e}};function l(){c.value!==n&&(c.value=n,c.needsUpdate=r>0),t.numPlanes=r,t.numIntersection=0}function u(e,n,r,i){let a=e===null?0:e.length,l=null;if(a!==0){if(l=c.value,i!==!0||l===null){let t=r+a*4,i=n.matrixWorldInverse;s.getNormalMatrix(i),(l===null||l.length0&&this._blur(s,0,0,t),this._applyPMREM(s),this._cleanup(s),s}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=Hl(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Vl(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=2**this._lodMax}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._ggxMaterial!==null&&this._ggxMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e2?l:0,l,l),c.setRenderTarget(r),p&&c.render(d,a),c.render(e,a)}c.toneMapping=u,c.autoClear=l,e.background=m}_textureToCubeUV(e,t){let n=this._renderer,r=e.mapping===301||e.mapping===302;r?(this._cubemapMaterial===null&&(this._cubemapMaterial=Hl()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=Vl());let i=r?this._cubemapMaterial:this._equirectMaterial,a=this._lodMeshes[0];a.material=i;let o=i.uniforms;o.envMap.value=e;let s=this._cubeSize;Rl(t,0,0,3*s,2*s),n.setRenderTarget(t),n.render(a,Ol)}_applyPMREM(e){let t=this._renderer,n=t.autoClear;t.autoClear=!1;let r=this._lodMeshes.length;for(let t=1;td-wl?n-d+wl:0),m=4*(this._cubeSize-f);s.envMap.value=e.texture,s.roughness.value=u,s.mipInt.value=d-t,Rl(i,p,m,3*f,2*f),r.setRenderTarget(i),r.render(o,Ol),s.envMap.value=i.texture,s.roughness.value=0,s.mipInt.value=d-n,Rl(e,p,m,3*f,2*f),r.setRenderTarget(e),r.render(o,Ol)}_blur(e,t,n,r,i){let a=this._pingPongRenderTarget;this._halfBlur(e,a,t,n,r,`latitudinal`,i),this._halfBlur(a,e,n,n,r,`longitudinal`,i)}_halfBlur(e,t,n,r,i,a,o){let s=this._renderer,c=this._blurMaterial;a!==`latitudinal`&&a!==`longitudinal`&&I(`blur direction must be either latitudinal or longitudinal!`);let l=this._lodMeshes[r];l.material=c;let u=c.uniforms,d=this._sizeLods[n]-1,f=isFinite(i)?Math.PI/(2*d):2*Math.PI/(2*El-1),p=i/f,m=isFinite(i)?1+Math.floor(3*p):El;m>El&&F(`sigmaRadians, ${i}, is too large and will clip, as it requested ${m} samples when the maximum is set to ${El}`);let h=[],g=0;for(let e=0;e_-wl?r-_+wl:0),4*(this._cubeSize-v),3*v,2*v),s.setRenderTarget(t),s.render(l,Ol)}};function Il(e){let t=[],n=[],r=[],i=e,a=e-wl+1+Tl.length;for(let o=0;oe-wl?s=Tl[o-e+wl-1]:o===0&&(s=0),n.push(s);let c=1/(a-2),l=-c,u=1+c,d=[l,l,u,l,u,u,l,l,u,u,l,u],f=new Float32Array(108),p=new Float32Array(72),m=new Float32Array(36);for(let e=0;e<6;e++){let t=e%3*2/3-1,n=e>2?0:-1,r=[t,n,0,t+2/3,n,0,t+2/3,n+1,0,t,n,0,t+2/3,n+1,0,t,n+1,0];f.set(r,18*e),p.set(d,12*e);let i=[e,e,e,e,e,e];m.set(i,6*e)}let h=new Di;h.setAttribute(`position`,new di(f,3)),h.setAttribute(`uv`,new di(p,2)),h.setAttribute(`faceIndex`,new di(m,1)),r.push(new ea(h,null)),i>wl&&i--}return{lodMeshes:r,sizeLods:t,sigmas:n}}function Ll(e,t,n){let r=new Wn(e,t,n);return r.texture.mapping=306,r.texture.name=`PMREM.cubeUv`,r.scissorTest=!0,r}function Rl(e,t,n,r,i){e.viewport.set(t,n,r,i),e.scissor.set(t,n,r,i)}function zl(e,t,n){return new xs({name:`PMREMGGXConvolution`,defines:{GGX_SAMPLES:Dl,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:Ul(),fragmentShader:` precision highp float; precision highp int; varying vec3 vOutputDirection; uniform sampler2D envMap; uniform float roughness; uniform float mipInt; #define ENVMAP_TYPE_CUBE_UV #include #define PI 3.14159265359 // Van der Corput radical inverse float radicalInverse_VdC(uint bits) { bits = (bits << 16u) | (bits >> 16u); bits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u); bits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u); bits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u); bits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u); return float(bits) * 2.3283064365386963e-10; // / 0x100000000 } // Hammersley sequence vec2 hammersley(uint i, uint N) { return vec2(float(i) / float(N), radicalInverse_VdC(i)); } // GGX VNDF importance sampling (Eric Heitz 2018) // "Sampling the GGX Distribution of Visible Normals" // https://jcgt.org/published/0007/04/01/ vec3 importanceSampleGGX_VNDF(vec2 Xi, vec3 V, float roughness) { float alpha = roughness * roughness; // Section 4.1: Orthonormal basis vec3 T1 = vec3(1.0, 0.0, 0.0); vec3 T2 = cross(V, T1); // Section 4.2: Parameterization of projected area float r = sqrt(Xi.x); float phi = 2.0 * PI * Xi.y; float t1 = r * cos(phi); float t2 = r * sin(phi); float s = 0.5 * (1.0 + V.z); t2 = (1.0 - s) * sqrt(1.0 - t1 * t1) + s * t2; // Section 4.3: Reprojection onto hemisphere vec3 Nh = t1 * T1 + t2 * T2 + sqrt(max(0.0, 1.0 - t1 * t1 - t2 * t2)) * V; // Section 3.4: Transform back to ellipsoid configuration return normalize(vec3(alpha * Nh.x, alpha * Nh.y, max(0.0, Nh.z))); } void main() { vec3 N = normalize(vOutputDirection); vec3 V = N; // Assume view direction equals normal for pre-filtering vec3 prefilteredColor = vec3(0.0); float totalWeight = 0.0; // For very low roughness, just sample the environment directly if (roughness < 0.001) { gl_FragColor = vec4(bilinearCubeUV(envMap, N, mipInt), 1.0); return; } // Tangent space basis for VNDF sampling vec3 up = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0); vec3 tangent = normalize(cross(up, N)); vec3 bitangent = cross(N, tangent); for(uint i = 0u; i < uint(GGX_SAMPLES); i++) { vec2 Xi = hammersley(i, uint(GGX_SAMPLES)); // For PMREM, V = N, so in tangent space V is always (0, 0, 1) vec3 H_tangent = importanceSampleGGX_VNDF(Xi, vec3(0.0, 0.0, 1.0), roughness); // Transform H back to world space vec3 H = normalize(tangent * H_tangent.x + bitangent * H_tangent.y + N * H_tangent.z); vec3 L = normalize(2.0 * dot(V, H) * H - V); float NdotL = max(dot(N, L), 0.0); if(NdotL > 0.0) { // Sample environment at fixed mip level // VNDF importance sampling handles the distribution filtering vec3 sampleColor = bilinearCubeUV(envMap, L, mipInt); // Weight by NdotL for the split-sum approximation // VNDF PDF naturally accounts for the visible microfacet distribution prefilteredColor += sampleColor * NdotL; totalWeight += NdotL; } } if (totalWeight > 0.0) { prefilteredColor = prefilteredColor / totalWeight; } gl_FragColor = vec4(prefilteredColor, 1.0); } `,blending:0,depthTest:!1,depthWrite:!1})}function Bl(e,t,n){let r=new Float32Array(El),i=new R(0,1,0);return new xs({name:`SphericalGaussianBlur`,defines:{n:El,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${e}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:r},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:i}},vertexShader:Ul(),fragmentShader:` precision mediump float; precision mediump int; varying vec3 vOutputDirection; uniform sampler2D envMap; uniform int samples; uniform float weights[ n ]; uniform bool latitudinal; uniform float dTheta; uniform float mipInt; uniform vec3 poleAxis; #define ENVMAP_TYPE_CUBE_UV #include vec3 getSample( float theta, vec3 axis ) { float cosTheta = cos( theta ); // Rodrigues' axis-angle rotation vec3 sampleDirection = vOutputDirection * cosTheta + cross( axis, vOutputDirection ) * sin( theta ) + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta ); return bilinearCubeUV( envMap, sampleDirection, mipInt ); } void main() { vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection ); if ( all( equal( axis, vec3( 0.0 ) ) ) ) { axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x ); } axis = normalize( axis ); gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 ); gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis ); for ( int i = 1; i < n; i++ ) { if ( i >= samples ) { break; } float theta = dTheta * float( i ); gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis ); gl_FragColor.rgb += weights[ i ] * getSample( theta, axis ); } } `,blending:0,depthTest:!1,depthWrite:!1})}function Vl(){return new xs({name:`EquirectangularToCubeUV`,uniforms:{envMap:{value:null}},vertexShader:Ul(),fragmentShader:` precision mediump float; precision mediump int; varying vec3 vOutputDirection; uniform sampler2D envMap; #include void main() { vec3 outputDirection = normalize( vOutputDirection ); vec2 uv = equirectUv( outputDirection ); gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 ); } `,blending:0,depthTest:!1,depthWrite:!1})}function Hl(){return new xs({name:`CubemapToCubeUV`,uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Ul(),fragmentShader:` precision mediump float; precision mediump int; uniform float flipEnvMap; varying vec3 vOutputDirection; uniform samplerCube envMap; void main() { gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) ); } `,blending:0,depthTest:!1,depthWrite:!1})}function Ul(){return` precision mediump float; precision mediump int; attribute float faceIndex; varying vec3 vOutputDirection; // RH coordinate system; PMREM face-indexing convention vec3 getDirection( vec2 uv, float face ) { uv = 2.0 * uv - 1.0; vec3 direction = vec3( uv, 1.0 ); if ( face == 0.0 ) { direction = direction.zyx; // ( 1, v, u ) pos x } else if ( face == 1.0 ) { direction = direction.xzy; direction.xz *= -1.0; // ( -u, 1, -v ) pos y } else if ( face == 2.0 ) { direction.x *= -1.0; // ( -u, v, 1 ) pos z } else if ( face == 3.0 ) { direction = direction.zyx; direction.xz *= -1.0; // ( -1, v, -u ) neg x } else if ( face == 4.0 ) { direction = direction.xzy; direction.xy *= -1.0; // ( -u, -1, v ) neg y } else if ( face == 5.0 ) { direction.z *= -1.0; // ( u, v, -1 ) neg z } return direction; } void main() { vOutputDirection = getDirection( uv, faceIndex ); gl_Position = vec4( position, 1.0 ); } `}var Wl=class extends Wn{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;let n={width:e,height:e,depth:1};this.texture=new Ia([n,n,n,n,n,n]),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:` varying vec3 vWorldDirection; vec3 transformDirection( in vec3 dir, in mat4 matrix ) { return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); } void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include } `,fragmentShader:` uniform sampler2D tEquirect; varying vec3 vWorldDirection; #include void main() { vec3 direction = normalize( vWorldDirection ); vec2 sampleUV = equirectUv( direction ); gl_FragColor = texture2D( tEquirect, sampleUV ); } `},r=new Ba(5,5,5),i=new xs({name:`CubemapFromEquirect`,uniforms:ps(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:1,blending:0});i.uniforms.tEquirect.value=t;let a=new ea(r,i),o=t.minFilter;return t.minFilter===1008&&(t.minFilter=ne),new Oc(1,10,this).update(e,a),t.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(e,t=!0,n=!0,r=!0){let i=e.getRenderTarget();for(let i=0;i<6;i++)e.setRenderTarget(this,i),e.clear(t,n,r);e.setRenderTarget(i)}};function Gl(e){let t=new WeakMap,n=new WeakMap,r=null;function i(e,t=!1){return e==null?null:t?o(e):a(e)}function a(n){if(n&&n.isTexture){let r=n.mapping;if(r===303||r===304)if(t.has(n)){let e=t.get(n).texture;return s(e,n.mapping)}else{let r=n.image;if(r&&r.height>0){let i=new Wl(r.height);return i.fromEquirectangularTexture(e,n),t.set(n,i),n.addEventListener(`dispose`,l),s(i.texture,n.mapping)}else return null}}return n}function o(t){if(t&&t.isTexture){let i=t.mapping,a=i===303||i===304,o=i===301||i===302;if(a||o){let i=n.get(t),s=i===void 0?0:i.texture.pmremVersion;if(t.isRenderTargetTexture&&t.pmremVersion!==s)return r===null&&(r=new Fl(e)),i=a?r.fromEquirectangular(t,i):r.fromCubemap(t,i),i.texture.pmremVersion=t.pmremVersion,n.set(t,i),i.texture;if(i!==void 0)return i.texture;{let s=t.image;return a&&s&&s.height>0||o&&s&&c(s)?(r===null&&(r=new Fl(e)),i=a?r.fromEquirectangular(t):r.fromCubemap(t),i.texture.pmremVersion=t.pmremVersion,n.set(t,i),t.addEventListener(`dispose`,u),i.texture):null}}}return t}function s(e,t){return t===303?e.mapping=301:t===304&&(e.mapping=302),e}function c(e){let t=0;for(let n=0;n<6;n++)e[n]!==void 0&&t++;return t===6}function l(e){let n=e.target;n.removeEventListener(`dispose`,l);let r=t.get(n);r!==void 0&&(t.delete(n),r.dispose())}function u(e){let t=e.target;t.removeEventListener(`dispose`,u);let r=n.get(t);r!==void 0&&(n.delete(t),r.dispose())}function d(){t=new WeakMap,n=new WeakMap,r!==null&&(r.dispose(),r=null)}return{get:i,dispose:d}}function Kl(e){let t={};function n(n){if(t[n]!==void 0)return t[n];let r=e.getExtension(n);return t[n]=r,r}return{has:function(e){return n(e)!==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(e){let t=n(e);return t===null&&Wt(`WebGLRenderer: `+e+` extension not supported.`),t}}}function ql(e,t,n,r){let i={},a=new WeakMap;function o(e){let s=e.target;for(let e in s.index!==null&&t.remove(s.index),s.attributes)t.remove(s.attributes[e]);s.removeEventListener(`dispose`,o),delete i[s.id];let c=a.get(s);c&&(t.remove(c),a.delete(s)),r.releaseStatesOfGeometry(s),s.isInstancedBufferGeometry===!0&&delete s._maxInstanceCount,n.memory.geometries--}function s(e,t){return i[t.id]===!0?t:(t.addEventListener(`dispose`,o),i[t.id]=!0,n.memory.geometries++,t)}function c(n){let r=n.attributes;for(let n in r)t.update(r[n],e.ARRAY_BUFFER)}function l(e){let n=[],r=e.index,i=e.attributes.position,o=0;if(i===void 0)return;if(r!==null){let e=r.array;o=r.version;for(let t=0,r=e.length;t=65535?pi:fi)(n,1);s.version=o;let c=a.get(e);c&&t.remove(c),a.set(e,s)}function u(e){let t=a.get(e);if(t){let n=e.index;n!==null&&t.versiont.maxTextureSize&&(m=Math.ceil(p/t.maxTextureSize),p=t.maxTextureSize);let h=new Float32Array(p*m*4*u),g=new Gn(h,p,m,u);g.type=fe,g.needsUpdate=!0;let _=f*4;for(let t=0;t #include void main() { gl_FragColor = texture2D( tDiffuse, vUv ); #ifdef LINEAR_TONE_MAPPING gl_FragColor.rgb = LinearToneMapping( gl_FragColor.rgb ); #elif defined( REINHARD_TONE_MAPPING ) gl_FragColor.rgb = ReinhardToneMapping( gl_FragColor.rgb ); #elif defined( CINEON_TONE_MAPPING ) gl_FragColor.rgb = CineonToneMapping( gl_FragColor.rgb ); #elif defined( ACES_FILMIC_TONE_MAPPING ) gl_FragColor.rgb = ACESFilmicToneMapping( gl_FragColor.rgb ); #elif defined( AGX_TONE_MAPPING ) gl_FragColor.rgb = AgXToneMapping( gl_FragColor.rgb ); #elif defined( NEUTRAL_TONE_MAPPING ) gl_FragColor.rgb = NeutralToneMapping( gl_FragColor.rgb ); #elif defined( CUSTOM_TONE_MAPPING ) gl_FragColor.rgb = CustomToneMapping( gl_FragColor.rgb ); #endif #ifdef SRGB_TRANSFER gl_FragColor = sRGBTransferOETF( gl_FragColor ); #endif }`,depthTest:!1,depthWrite:!1}),u=new ea(c,l),d=new vc(-1,1,1,-1,0,1),f=null,p=null,m=!1,h,g=null,_=[],v=!1;this.setSize=function(e,t){o.setSize(e,t),s.setSize(e,t);for(let n=0;n<_.length;n++){let r=_[n];r.setSize&&r.setSize(e,t)}},this.setEffects=function(e){_=e,v=_.length>0&&_[0].isRenderPass===!0;let t=o.width,n=o.height;for(let e=0;e<_.length;e++){let r=_[e];r.setSize&&r.setSize(t,n)}},this.begin=function(e,t){if(m||e.toneMapping===0&&_.length===0)return!1;if(g=t,t!==null){let e=t.width,n=t.height;(o.width!==e||o.height!==n)&&this.setSize(e,n)}return v===!1&&e.setRenderTarget(o),h=e.toneMapping,e.toneMapping=0,!0},this.hasRenderPass=function(){return v},this.end=function(e,t){e.toneMapping=h,m=!0;let n=o,r=s;for(let i=0;i<_.length;i++){let a=_[i];if(a.enabled!==!1&&(a.render(e,r,n,t),a.needsSwap!==!1)){let e=n;n=r,r=e}}if(f!==e.outputColorSpace||p!==e.toneMapping){f=e.outputColorSpace,p=e.toneMapping,l.defines={},jn.getTransfer(f)===`srgb`&&(l.defines.SRGB_TRANSFER=``);let t=Ql[p];t&&(l.defines[t]=``),l.needsUpdate=!0}l.uniforms.tDiffuse.value=n.texture,e.setRenderTarget(g),e.render(u,d),g=null,m=!1},this.isCompositing=function(){return m},this.dispose=function(){o.depthTexture&&o.depthTexture.dispose(),o.dispose(),s.dispose(),c.dispose(),l.dispose()}}var eu=new Vn,tu=new La(1,1),nu=new Gn,ru=new Kn,iu=new Ia,au=[],ou=[],su=new Float32Array(16),cu=new Float32Array(9),lu=new Float32Array(4);function uu(e,t,n){let r=e[0];if(r<=0||r>0)return e;let i=t*n,a=au[i];if(a===void 0&&(a=new Float32Array(i),au[i]=a),t!==0){r.toArray(a,0);for(let r=1,i=0;r!==t;++r)i+=n,e[r].toArray(a,i)}return a}function du(e,t){if(e.length!==t.length)return!1;for(let n=0,r=e.length;n0&&(this.seq=r.concat(i))}setValue(e,t,n,r){let i=this.map[t];i!==void 0&&i.setValue(e,n,r)}setOptional(e,t,n){let r=t[n];r!==void 0&&this.setValue(e,n,r)}static upload(e,t,n,r){for(let i=0,a=t.length;i!==a;++i){let a=t[i],o=n[a.id];o.needsUpdate!==!1&&a.setValue(e,o.value,r)}}static seqWithValue(e,t){let n=[];for(let r=0,i=e.length;r!==i;++r){let i=e[r];i.id in t&&n.push(i)}return n}};function rd(e,t,n){let r=e.createShader(t);return e.shaderSource(r,n),e.compileShader(r),r}var id=37297,ad=0;function od(e,t){let n=e.split(` `),r=[],i=Math.max(t-6,0),a=Math.min(t+6,n.length);for(let e=i;e`:` `} ${i}: ${n[e]}`)}return r.join(` `)}var sd=new En;function cd(e){jn._getMatrix(sd,jn.workingColorSpace,e);let t=`mat3( ${sd.elements.map(e=>e.toFixed(4))} )`;switch(jn.getTransfer(e)){case xt:return[t,`LinearTransferOETF`];case St:return[t,`sRGBTransferOETF`];default:return F(`WebGLProgram: Unsupported color space: `,e),[t,`LinearTransferOETF`]}}function ld(e,t,n){let r=e.getShaderParameter(t,e.COMPILE_STATUS),i=(e.getShaderInfoLog(t)||``).trim();if(r&&i===``)return``;let a=/ERROR: 0:(\d+)/.exec(i);if(a){let r=parseInt(a[1]);return n.toUpperCase()+` `+i+` `+od(e.getShaderSource(t),r)}else return i}function ud(e,t){let n=cd(t);return[`vec4 ${e}( vec4 value ) {`,` return ${n[1]}( vec4( value.rgb * ${n[0]}, value.a ) );`,`}`].join(` `)}var dd={1:`Linear`,2:`Reinhard`,3:`Cineon`,4:`ACESFilmic`,6:`AgX`,7:`Neutral`,5:`Custom`};function fd(e,t){let n=dd[t];return n===void 0?(F(`WebGLProgram: Unsupported toneMapping:`,t),`vec3 `+e+`( vec3 color ) { return LinearToneMapping( color ); }`):`vec3 `+e+`( vec3 color ) { return `+n+`ToneMapping( color ); }`}var pd=new R;function md(){return jn.getLuminanceCoefficients(pd),[`float luminance( const in vec3 rgb ) {`,` const vec3 weights = vec3( ${pd.x.toFixed(4)}, ${pd.y.toFixed(4)}, ${pd.z.toFixed(4)} );`,` return dot( weights, rgb );`,`}`].join(` `)}function hd(e){return[e.extensionClipCullDistance?`#extension GL_ANGLE_clip_cull_distance : require`:``,e.extensionMultiDraw?`#extension GL_ANGLE_multi_draw : require`:``].filter(vd).join(` `)}function gd(e){let t=[];for(let n in e){let r=e[n];r!==!1&&t.push(`#define `+n+` `+r)}return t.join(` `)}function _d(e,t){let n={},r=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES);for(let i=0;i/gm;function Sd(e){return e.replace(xd,wd)}var Cd=new Map;function wd(e,t){let n=pl[t];if(n===void 0){let e=Cd.get(t);if(e!==void 0)n=pl[e],F(`WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.`,t,e);else throw Error(`THREE.WebGLProgram: Can not resolve #include <`+t+`>`)}return Sd(n)}var Td=/#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 Ed(e){return e.replace(Td,Dd)}function Dd(e,t,n,r){let i=``;for(let e=parseInt(t);e0&&(g+=` `),_=[`#define SHADER_TYPE `+n.shaderType,`#define SHADER_NAME `+n.shaderName,m].filter(vd).join(` `),_.length>0&&(_+=` `)):(g=[Od(n),`#define SHADER_TYPE `+n.shaderType,`#define SHADER_NAME `+n.shaderName,m,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`,` attribute mat4 instanceMatrix;`,`#endif`,`#ifdef USE_INSTANCING_COLOR`,` attribute vec3 instanceColor;`,`#endif`,`#ifdef USE_INSTANCING_MORPH`,` uniform sampler2D morphTexture;`,`#endif`,`attribute vec3 position;`,`attribute vec3 normal;`,`attribute vec2 uv;`,`#ifdef USE_UV1`,` attribute vec2 uv1;`,`#endif`,`#ifdef USE_UV2`,` attribute vec2 uv2;`,`#endif`,`#ifdef USE_UV3`,` attribute vec2 uv3;`,`#endif`,`#ifdef USE_TANGENT`,` attribute vec4 tangent;`,`#endif`,`#if defined( USE_COLOR_ALPHA )`,` attribute vec4 color;`,`#elif defined( USE_COLOR )`,` attribute vec3 color;`,`#endif`,`#ifdef USE_SKINNING`,` attribute vec4 skinIndex;`,` attribute vec4 skinWeight;`,`#endif`,` `].filter(vd).join(` `),_=[Od(n),`#define SHADER_TYPE `+n.shaderType,`#define SHADER_NAME `+n.shaderName,m,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 `+d:``,f?`#define CUBEUV_TEXEL_WIDTH `+f.texelWidth:``,f?`#define CUBEUV_TEXEL_HEIGHT `+f.texelHeight:``,f?`#define CUBEUV_MAX_MIP `+f.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.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===0?``:`#define TONE_MAPPING`,n.toneMapping===0?``:pl.tonemapping_pars_fragment,n.toneMapping===0?``:fd(`toneMapping`,n.toneMapping),n.dithering?`#define DITHERING`:``,n.opaque?`#define OPAQUE`:``,pl.colorspace_pars_fragment,ud(`linearToOutputTexel`,n.outputColorSpace),md(),n.useDepthPacking?`#define DEPTH_PACKING `+n.depthPacking:``,` `].filter(vd).join(` `)),o=Sd(o),o=yd(o,n),o=bd(o,n),s=Sd(s),s=yd(s,n),s=bd(s,n),o=Ed(o),s=Ed(s),n.isRawShaderMaterial!==!0&&(v=`#version 300 es `,g=[p,`#define attribute in`,`#define varying out`,`#define texture2D texture`].join(` `)+` `+g,_=[`#define varying in`,n.glslVersion===`300 es`?``:`layout(location = 0) out highp vec4 pc_fragColor;`,n.glslVersion===`300 es`?``:`#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(` `)+` `+_);let y=v+g+o,b=v+_+s,x=rd(i,i.VERTEX_SHADER,y),S=rd(i,i.FRAGMENT_SHADER,b);i.attachShader(h,x),i.attachShader(h,S),n.index0AttributeName===void 0?n.hasPositionAttribute===!0&&i.bindAttribLocation(h,0,`position`):i.bindAttribLocation(h,0,n.index0AttributeName),i.linkProgram(h);function C(t){if(e.debug.checkShaderErrors){let n=i.getProgramInfoLog(h)||``,r=i.getShaderInfoLog(x)||``,a=i.getShaderInfoLog(S)||``,o=n.trim(),s=r.trim(),c=a.trim(),l=!0,u=!0;if(i.getProgramParameter(h,i.LINK_STATUS)===!1)if(l=!1,typeof e.debug.onShaderError==`function`)e.debug.onShaderError(i,h,x,S);else{let e=ld(i,x,`vertex`),n=ld(i,S,`fragment`);I(`WebGLProgram: Shader Error `+i.getError()+` - VALIDATE_STATUS `+i.getProgramParameter(h,i.VALIDATE_STATUS)+` Material Name: `+t.name+` Material Type: `+t.type+` Program Info Log: `+o+` `+e+` `+n)}else o===``?(s===``||c===``)&&(u=!1):F(`WebGLProgram: Program Info Log:`,o);u&&(t.diagnostics={runnable:l,programLog:o,vertexShader:{log:s,prefix:g},fragmentShader:{log:c,prefix:_}})}i.deleteShader(x),i.deleteShader(S),w=new nd(i,h),T=_d(i,h)}let w;this.getUniforms=function(){return w===void 0&&C(this),w};let T;this.getAttributes=function(){return T===void 0&&C(this),T};let E=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return E===!1&&(E=i.getProgramParameter(h,id)),E},this.destroy=function(){r.releaseStatesOfProgram(this),i.deleteProgram(h),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=ad++,this.cacheKey=t,this.usedTimes=1,this.program=h,this.vertexShader=x,this.fragmentShader=S,this}var zd=0,Bd=class{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e,t,n){let r=this._getShaderCacheForMaterial(e);return r.has(t)===!1&&(r.add(t),t.usedTimes++),r.has(n)===!1&&(r.add(n),n.usedTimes++),this}remove(e){let t=this.materialCache.get(e);for(let e of t)e.usedTimes--,e.usedTimes===0&&this.shaderCache.delete(e.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);return n===void 0&&(n=new Set,t.set(e,n)),n}_getShaderStage(e){let t=this.shaderCache,n=t.get(e);return n===void 0&&(n=new Vd(e),t.set(e,n)),n}},Vd=class{constructor(e){this.id=zd++,this.code=e,this.usedTimes=0}};function Hd(e){return e===1030||e===37490||e===36285}function Ud(e,t,n,r,i,a){let o=new ir,s=new Bd,c=new Set,l=[],u=new Map,d=r.logarithmicDepthBuffer,f=r.precision,p={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 m(e){return c.add(e),e===0?`uv`:`uv${e}`}function h(i,o,l,u,h,g){let _=u.fog,v=h.geometry,y=i.isMeshStandardMaterial||i.isMeshLambertMaterial||i.isMeshPhongMaterial?u.environment:null,b=i.isMeshStandardMaterial||i.isMeshLambertMaterial&&!i.envMap||i.isMeshPhongMaterial&&!i.envMap,x=t.get(i.envMap||y,b),S=x&&x.mapping===306?x.image.height:null,C=p[i.type];i.precision!==null&&(f=r.getMaxPrecision(i.precision),f!==i.precision&&F(`WebGLProgram.getParameters:`,i.precision,`not supported, using`,f,`instead.`));let w=v.morphAttributes.position||v.morphAttributes.normal||v.morphAttributes.color,T=w===void 0?0:w.length,E=0;v.morphAttributes.position!==void 0&&(E=1),v.morphAttributes.normal!==void 0&&(E=2),v.morphAttributes.color!==void 0&&(E=3);let D,O,k,A;if(C){let e=hl[C];D=e.vertexShader,O=e.fragmentShader}else{D=i.vertexShader,O=i.fragmentShader;let e=s.getVertexShaderStage(i),t=s.getFragmentShaderStage(i);s.update(i,e,t),k=e.id,A=t.id}let j=e.getRenderTarget(),M=e.state.buffers.depth.getReversed(),N=h.isInstancedMesh===!0,ee=h.isBatchedMesh===!0,te=!!i.map,ne=!!i.matcap,re=!!x,ie=!!i.aoMap,ae=!!i.lightMap,oe=!!i.bumpMap&&i.wireframe===!1,se=!!i.normalMap,ce=!!i.displacementMap,le=!!i.emissiveMap,ue=!!i.metalnessMap,de=!!i.roughnessMap,fe=i.anisotropy>0,pe=i.clearcoat>0,me=i.dispersion>0,he=i.iridescence>0,ge=i.sheen>0,_e=i.transmission>0,ve=fe&&!!i.anisotropyMap,ye=pe&&!!i.clearcoatMap,be=pe&&!!i.clearcoatNormalMap,xe=pe&&!!i.clearcoatRoughnessMap,Se=he&&!!i.iridescenceMap,Ce=he&&!!i.iridescenceThicknessMap,we=ge&&!!i.sheenColorMap,Te=ge&&!!i.sheenRoughnessMap,Ee=!!i.specularMap,De=!!i.specularColorMap,Oe=!!i.specularIntensityMap,ke=_e&&!!i.transmissionMap,Ae=_e&&!!i.thicknessMap,je=!!i.gradientMap,Me=!!i.alphaMap,Ne=i.alphaTest>0,Pe=!!i.alphaHash,P=!!i.extensions,Fe=0;i.toneMapped&&(j===null||j.isXRRenderTarget===!0)&&(Fe=e.toneMapping);let Ie={shaderID:C,shaderType:i.type,shaderName:i.name,vertexShader:D,fragmentShader:O,defines:i.defines,customVertexShaderID:k,customFragmentShaderID:A,isRawShaderMaterial:i.isRawShaderMaterial===!0,glslVersion:i.glslVersion,precision:f,batching:ee,batchingColor:ee&&h._colorsTexture!==null,instancing:N,instancingColor:N&&h.instanceColor!==null,instancingMorph:N&&h.morphTexture!==null,outputColorSpace:j===null?e.outputColorSpace:j.isXRRenderTarget===!0?j.texture.colorSpace:jn.workingColorSpace,alphaToCoverage:!!i.alphaToCoverage,map:te,matcap:ne,envMap:re,envMapMode:re&&x.mapping,envMapCubeUVHeight:S,aoMap:ie,lightMap:ae,bumpMap:oe,normalMap:se,displacementMap:ce,emissiveMap:le,normalMapObjectSpace:se&&i.normalMapType===1,normalMapTangentSpace:se&&i.normalMapType===0,packedNormalMap:se&&i.normalMapType===0&&Hd(i.normalMap.format),metalnessMap:ue,roughnessMap:de,anisotropy:fe,anisotropyMap:ve,clearcoat:pe,clearcoatMap:ye,clearcoatNormalMap:be,clearcoatRoughnessMap:xe,dispersion:me,iridescence:he,iridescenceMap:Se,iridescenceThicknessMap:Ce,sheen:ge,sheenColorMap:we,sheenRoughnessMap:Te,specularMap:Ee,specularColorMap:De,specularIntensityMap:Oe,transmission:_e,transmissionMap:ke,thicknessMap:Ae,gradientMap:je,opaque:i.transparent===!1&&i.blending===1&&i.alphaToCoverage===!1,alphaMap:Me,alphaTest:Ne,alphaHash:Pe,combine:i.combine,mapUv:te&&m(i.map.channel),aoMapUv:ie&&m(i.aoMap.channel),lightMapUv:ae&&m(i.lightMap.channel),bumpMapUv:oe&&m(i.bumpMap.channel),normalMapUv:se&&m(i.normalMap.channel),displacementMapUv:ce&&m(i.displacementMap.channel),emissiveMapUv:le&&m(i.emissiveMap.channel),metalnessMapUv:ue&&m(i.metalnessMap.channel),roughnessMapUv:de&&m(i.roughnessMap.channel),anisotropyMapUv:ve&&m(i.anisotropyMap.channel),clearcoatMapUv:ye&&m(i.clearcoatMap.channel),clearcoatNormalMapUv:be&&m(i.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:xe&&m(i.clearcoatRoughnessMap.channel),iridescenceMapUv:Se&&m(i.iridescenceMap.channel),iridescenceThicknessMapUv:Ce&&m(i.iridescenceThicknessMap.channel),sheenColorMapUv:we&&m(i.sheenColorMap.channel),sheenRoughnessMapUv:Te&&m(i.sheenRoughnessMap.channel),specularMapUv:Ee&&m(i.specularMap.channel),specularColorMapUv:De&&m(i.specularColorMap.channel),specularIntensityMapUv:Oe&&m(i.specularIntensityMap.channel),transmissionMapUv:ke&&m(i.transmissionMap.channel),thicknessMapUv:Ae&&m(i.thicknessMap.channel),alphaMapUv:Me&&m(i.alphaMap.channel),vertexTangents:!!v.attributes.tangent&&(se||fe),vertexNormals:!!v.attributes.normal,vertexColors:i.vertexColors,vertexAlphas:i.vertexColors===!0&&!!v.attributes.color&&v.attributes.color.itemSize===4,pointsUvs:h.isPoints===!0&&!!v.attributes.uv&&(te||Me),fog:!!_,useFog:i.fog===!0,fogExp2:!!_&&_.isFogExp2,flatShading:i.wireframe===!1&&(i.flatShading===!0||v.attributes.normal===void 0&&se===!1&&(i.isMeshLambertMaterial||i.isMeshPhongMaterial||i.isMeshStandardMaterial||i.isMeshPhysicalMaterial)),sizeAttenuation:i.sizeAttenuation===!0,logarithmicDepthBuffer:d,reversedDepthBuffer:M,skinning:h.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:T,morphTextureStride:E,numDirLights:o.directional.length,numPointLights:o.point.length,numSpotLights:o.spot.length,numSpotLightMaps:o.spotLightMap.length,numRectAreaLights:o.rectArea.length,numHemiLights:o.hemi.length,numDirLightShadows:o.directionalShadowMap.length,numPointLightShadows:o.pointShadowMap.length,numSpotLightShadows:o.spotShadowMap.length,numSpotLightShadowsWithMaps:o.numSpotLightShadowsWithMaps,numLightProbes:o.numLightProbes,numLightProbeGrids:g.length,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:i.dithering,shadowMapEnabled:e.shadowMap.enabled&&l.length>0,shadowMapType:e.shadowMap.type,toneMapping:Fe,decodeVideoTexture:te&&i.map.isVideoTexture===!0&&jn.getTransfer(i.map.colorSpace)===`srgb`,decodeVideoTextureEmissive:le&&i.emissiveMap.isVideoTexture===!0&&jn.getTransfer(i.emissiveMap.colorSpace)===`srgb`,premultipliedAlpha:i.premultipliedAlpha,doubleSided:i.side===2,flipSided:i.side===1,useDepthPacking:i.depthPacking>=0,depthPacking:i.depthPacking||0,index0AttributeName:i.index0AttributeName,extensionClipCullDistance:P&&i.extensions.clipCullDistance===!0&&n.has(`WEBGL_clip_cull_distance`),extensionMultiDraw:(P&&i.extensions.multiDraw===!0||ee)&&n.has(`WEBGL_multi_draw`),rendererExtensionParallelShaderCompile:n.has(`KHR_parallel_shader_compile`),customProgramCacheKey:i.customProgramCacheKey()};return Ie.vertexUv1s=c.has(1),Ie.vertexUv2s=c.has(2),Ie.vertexUv3s=c.has(3),c.clear(),Ie}function g(t){let n=[];if(t.shaderID?n.push(t.shaderID):(n.push(t.customVertexShaderID),n.push(t.customFragmentShaderID)),t.defines!==void 0)for(let e in t.defines)n.push(e),n.push(t.defines[e]);return t.isRawShaderMaterial===!1&&(_(n,t),v(n,t),n.push(e.outputColorSpace)),n.push(t.customProgramCacheKey),n.join()}function _(e,t){e.push(t.precision),e.push(t.outputColorSpace),e.push(t.envMapMode),e.push(t.envMapCubeUVHeight),e.push(t.mapUv),e.push(t.alphaMapUv),e.push(t.lightMapUv),e.push(t.aoMapUv),e.push(t.bumpMapUv),e.push(t.normalMapUv),e.push(t.displacementMapUv),e.push(t.emissiveMapUv),e.push(t.metalnessMapUv),e.push(t.roughnessMapUv),e.push(t.anisotropyMapUv),e.push(t.clearcoatMapUv),e.push(t.clearcoatNormalMapUv),e.push(t.clearcoatRoughnessMapUv),e.push(t.iridescenceMapUv),e.push(t.iridescenceThicknessMapUv),e.push(t.sheenColorMapUv),e.push(t.sheenRoughnessMapUv),e.push(t.specularMapUv),e.push(t.specularColorMapUv),e.push(t.specularIntensityMapUv),e.push(t.transmissionMapUv),e.push(t.thicknessMapUv),e.push(t.combine),e.push(t.fogExp2),e.push(t.sizeAttenuation),e.push(t.morphTargetsCount),e.push(t.morphAttributeCount),e.push(t.numDirLights),e.push(t.numPointLights),e.push(t.numSpotLights),e.push(t.numSpotLightMaps),e.push(t.numHemiLights),e.push(t.numRectAreaLights),e.push(t.numDirLightShadows),e.push(t.numPointLightShadows),e.push(t.numSpotLightShadows),e.push(t.numSpotLightShadowsWithMaps),e.push(t.numLightProbes),e.push(t.shadowMapType),e.push(t.toneMapping),e.push(t.numClippingPlanes),e.push(t.numClipIntersection),e.push(t.depthPacking)}function v(e,t){o.disableAll(),t.instancing&&o.enable(0),t.instancingColor&&o.enable(1),t.instancingMorph&&o.enable(2),t.matcap&&o.enable(3),t.envMap&&o.enable(4),t.normalMapObjectSpace&&o.enable(5),t.normalMapTangentSpace&&o.enable(6),t.clearcoat&&o.enable(7),t.iridescence&&o.enable(8),t.alphaTest&&o.enable(9),t.vertexColors&&o.enable(10),t.vertexAlphas&&o.enable(11),t.vertexUv1s&&o.enable(12),t.vertexUv2s&&o.enable(13),t.vertexUv3s&&o.enable(14),t.vertexTangents&&o.enable(15),t.anisotropy&&o.enable(16),t.alphaHash&&o.enable(17),t.batching&&o.enable(18),t.dispersion&&o.enable(19),t.batchingColor&&o.enable(20),t.gradientMap&&o.enable(21),t.packedNormalMap&&o.enable(22),t.vertexNormals&&o.enable(23),e.push(o.mask),o.disableAll(),t.fog&&o.enable(0),t.useFog&&o.enable(1),t.flatShading&&o.enable(2),t.logarithmicDepthBuffer&&o.enable(3),t.reversedDepthBuffer&&o.enable(4),t.skinning&&o.enable(5),t.morphTargets&&o.enable(6),t.morphNormals&&o.enable(7),t.morphColors&&o.enable(8),t.premultipliedAlpha&&o.enable(9),t.shadowMapEnabled&&o.enable(10),t.doubleSided&&o.enable(11),t.flipSided&&o.enable(12),t.useDepthPacking&&o.enable(13),t.dithering&&o.enable(14),t.transmission&&o.enable(15),t.sheen&&o.enable(16),t.opaque&&o.enable(17),t.pointsUvs&&o.enable(18),t.decodeVideoTexture&&o.enable(19),t.decodeVideoTextureEmissive&&o.enable(20),t.alphaToCoverage&&o.enable(21),t.numLightProbeGrids>0&&o.enable(22),t.hasPositionAttribute&&o.enable(23),e.push(o.mask)}function y(e){let t=p[e.type],n;if(t){let e=hl[t];n=vs.clone(e.uniforms)}else n=e.uniforms;return n}function b(t,n){let r=u.get(n);return r===void 0?(r=new Rd(e,n,t,i),l.push(r),u.set(n,r)):++r.usedTimes,r}function x(e){if(--e.usedTimes===0){let t=l.indexOf(e);l[t]=l[l.length-1],l.pop(),u.delete(e.cacheKey),e.destroy()}}function S(e){s.remove(e)}function C(){s.dispose()}return{getParameters:h,getProgramCacheKey:g,getUniforms:y,acquireProgram:b,releaseProgram:x,releaseShaderCache:S,programs:l,dispose:C}}function Wd(){let e=new WeakMap;function t(t){return e.has(t)}function n(t){let n=e.get(t);return n===void 0&&(n={},e.set(t,n)),n}function r(t){e.delete(t)}function i(t,n,r){e.get(t)[n]=r}function a(){e=new WeakMap}return{has:t,get:n,remove:r,update:i,dispose:a}}function Gd(e,t){return e.groupOrder===t.groupOrder?e.renderOrder===t.renderOrder?e.material.id===t.material.id?e.materialVariant===t.materialVariant?e.z===t.z?e.id-t.id:e.z-t.z:e.materialVariant-t.materialVariant:e.material.id-t.material.id:e.renderOrder-t.renderOrder:e.groupOrder-t.groupOrder}function Kd(e,t){return e.groupOrder===t.groupOrder?e.renderOrder===t.renderOrder?e.z===t.z?e.id-t.id:t.z-e.z:e.renderOrder-t.renderOrder:e.groupOrder-t.groupOrder}function qd(){let e=[],t=0,n=[],r=[],i=[];function a(){t=0,n.length=0,r.length=0,i.length=0}function o(e){let t=0;return e.isInstancedMesh&&(t+=2),e.isSkinnedMesh&&(t+=1),t}function s(n,r,i,a,s,c){let l=e[t];return l===void 0?(l={id:n.id,object:n,geometry:r,material:i,materialVariant:o(n),groupOrder:a,renderOrder:n.renderOrder,z:s,group:c},e[t]=l):(l.id=n.id,l.object=n,l.geometry=r,l.material=i,l.materialVariant=o(n),l.groupOrder=a,l.renderOrder=n.renderOrder,l.z=s,l.group=c),t++,l}function c(e,t,a,o,c,l){let u=s(e,t,a,o,c,l);a.transmission>0?r.push(u):a.transparent===!0?i.push(u):n.push(u)}function l(e,t,a,o,c,l){let u=s(e,t,a,o,c,l);a.transmission>0?r.unshift(u):a.transparent===!0?i.unshift(u):n.unshift(u)}function u(e,t,a){n.length>1&&n.sort(e||Gd),r.length>1&&r.sort(t||Kd),i.length>1&&i.sort(t||Kd),a&&(n.reverse(),r.reverse(),i.reverse())}function d(){for(let n=t,r=e.length;n=r.length?(i=new qd,r.push(i)):i=r[n],i}function n(){e=new WeakMap}return{get:t,dispose:n}}function Yd(){let e={};return{get:function(t){if(e[t.id]!==void 0)return e[t.id];let n;switch(t.type){case`DirectionalLight`:n={direction:new R,color:new Er};break;case`SpotLight`:n={position:new R,direction:new R,color:new Er,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case`PointLight`:n={position:new R,color:new Er,distance:0,decay:0};break;case`HemisphereLight`:n={direction:new R,skyColor:new Er,groundColor:new Er};break;case`RectAreaLight`:n={color:new Er,position:new R,halfWidth:new R,halfHeight:new R};break}return e[t.id]=n,n}}}function Xd(){let e={};return{get:function(t){if(e[t.id]!==void 0)return e[t.id];let n;switch(t.type){case`DirectionalLight`:n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new L};break;case`SpotLight`:n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new L};break;case`PointLight`:n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new L,shadowCameraNear:1,shadowCameraFar:1e3};break}return e[t.id]=n,n}}}var Zd=0;function Qd(e,t){return(t.castShadow?2:0)-(e.castShadow?2:0)+(t.map?1:0)-(e.map?1:0)}function $d(e){let t=new Yd,n=Xd(),r={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let e=0;e<9;e++)r.probe.push(new R);let i=new R,a=new qn,o=new qn;function s(i){let a=0,o=0,s=0;for(let e=0;e<9;e++)r.probe[e].set(0,0,0);let c=0,l=0,u=0,d=0,f=0,p=0,m=0,h=0,g=0,_=0,v=0;i.sort(Qd);for(let e=0,y=i.length;e0&&(e.has(`OES_texture_float_linear`)===!0?(r.rectAreaLTC1=ml.LTC_FLOAT_1,r.rectAreaLTC2=ml.LTC_FLOAT_2):(r.rectAreaLTC1=ml.LTC_HALF_1,r.rectAreaLTC2=ml.LTC_HALF_2)),r.ambient[0]=a,r.ambient[1]=o,r.ambient[2]=s;let y=r.hash;(y.directionalLength!==c||y.pointLength!==l||y.spotLength!==u||y.rectAreaLength!==d||y.hemiLength!==f||y.numDirectionalShadows!==p||y.numPointShadows!==m||y.numSpotShadows!==h||y.numSpotMaps!==g||y.numLightProbes!==v)&&(r.directional.length=c,r.spot.length=u,r.rectArea.length=d,r.point.length=l,r.hemi.length=f,r.directionalShadow.length=p,r.directionalShadowMap.length=p,r.pointShadow.length=m,r.pointShadowMap.length=m,r.spotShadow.length=h,r.spotShadowMap.length=h,r.directionalShadowMatrix.length=p,r.pointShadowMatrix.length=m,r.spotLightMatrix.length=h+g-_,r.spotLightMap.length=g,r.numSpotLightShadowsWithMaps=_,r.numLightProbes=v,y.directionalLength=c,y.pointLength=l,y.spotLength=u,y.rectAreaLength=d,y.hemiLength=f,y.numDirectionalShadows=p,y.numPointShadows=m,y.numSpotShadows=h,y.numSpotMaps=g,y.numLightProbes=v,r.version=Zd++)}function c(e,t){let n=0,s=0,c=0,l=0,u=0,d=t.matrixWorldInverse;for(let t=0,f=e.length;t=i.length?(a=new ef(e),i.push(a)):a=i[r],a}function r(){t=new WeakMap}return{get:n,dispose:r}}var nf=`void main() { gl_Position = vec4( position, 1.0 ); }`,rf=`uniform sampler2D shadow_pass; uniform vec2 resolution; uniform float radius; void main() { const float samples = float( VSM_SAMPLES ); float mean = 0.0; float squared_mean = 0.0; float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 ); float uvStart = samples <= 1.0 ? 0.0 : - 1.0; for ( float i = 0.0; i < samples; i ++ ) { float uvOffset = uvStart + i * uvStride; #ifdef HORIZONTAL_PASS vec2 distribution = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ).rg; mean += distribution.x; squared_mean += distribution.y * distribution.y + distribution.x * distribution.x; #else float depth = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ).r; mean += depth; squared_mean += depth * depth; #endif } mean = mean / samples; squared_mean = squared_mean / samples; float std_dev = sqrt( max( 0.0, squared_mean - mean * mean ) ); gl_FragColor = vec4( mean, std_dev, 0.0, 1.0 ); }`,af=[new R(1,0,0),new R(-1,0,0),new R(0,1,0),new R(0,-1,0),new R(0,0,1),new R(0,0,-1)],of=[new R(0,-1,0),new R(0,-1,0),new R(0,0,1),new R(0,0,-1),new R(0,-1,0),new R(0,-1,0)],sf=new qn,cf=new R,lf=new R;function uf(e,t,n){let r=new fa,i=new L,a=new L,o=new Hn,s=new ks,c=new As,l={},u=n.maxTextureSize,d={0:1,1:0,2:2},f=new xs({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new L},radius:{value:4}},vertexShader:nf,fragmentShader:rf}),p=f.clone();p.defines.HORIZONTAL_PASS=1;let m=new Di;m.setAttribute(`position`,new di(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let h=new ea(m,f),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=1;let _=this.type;this.render=function(t,n,s){if(g.enabled===!1||g.autoUpdate===!1&&g.needsUpdate===!1||t.length===0)return;this.type===2&&(F(`WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead.`),this.type=1);let c=e.getRenderTarget(),l=e.getActiveCubeFace(),d=e.getActiveMipmapLevel(),f=e.state;f.setBlending(0),f.buffers.depth.getReversed()===!0?f.buffers.color.setClear(0,0,0,0):f.buffers.color.setClear(1,1,1,1),f.buffers.depth.setTest(!0),f.setScissorTest(!1);let p=_!==this.type;p&&n.traverse(function(e){e.material&&(Array.isArray(e.material)?e.material.forEach(e=>e.needsUpdate=!0):e.material.needsUpdate=!0)});for(let c=0,l=t.length;cu||i.y>u)&&(i.x>u&&(a.x=Math.floor(u/m.x),i.x=a.x*m.x,d.mapSize.x=a.x),i.y>u&&(a.y=Math.floor(u/m.y),i.y=a.y*m.y,d.mapSize.y=a.y));let h=e.state.buffers.depth.getReversed();if(d.camera._reversedDepth=h,d.map===null||p===!0){if(d.map!==null&&(d.map.depthTexture!==null&&(d.map.depthTexture.dispose(),d.map.depthTexture=null),d.map.dispose()),this.type===3){if(l.isPointLight){F(`WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.`);continue}d.map=new Wn(i.x,i.y,{format:Ee,type:pe,minFilter:ne,magFilter:ne,generateMipmaps:!1}),d.map.texture.name=l.name+`.shadowMap`,d.map.depthTexture=new La(i.x,i.y,fe),d.map.depthTexture.name=l.name+`.shadowMapDepth`,d.map.depthTexture.format=Se,d.map.depthTexture.compareFunction=null,d.map.depthTexture.minFilter=N,d.map.depthTexture.magFilter=N}else l.isPointLight?(d.map=new Wl(i.x),d.map.depthTexture=new Ra(i.x,de)):(d.map=new Wn(i.x,i.y),d.map.depthTexture=new La(i.x,i.y,de)),d.map.depthTexture.name=l.name+`.shadowMap`,d.map.depthTexture.format=Se,this.type===1?(d.map.depthTexture.compareFunction=h?518:515,d.map.depthTexture.minFilter=ne,d.map.depthTexture.magFilter=ne):(d.map.depthTexture.compareFunction=null,d.map.depthTexture.minFilter=N,d.map.depthTexture.magFilter=N);d.camera.updateProjectionMatrix()}let g=d.map.isWebGLCubeRenderTarget?6:1;for(let t=0;t0||n.map&&n.alphaTest>0||n.alphaToCoverage===!0){let e=a.uuid,t=n.uuid,r=l[e];r===void 0&&(r={},l[e]=r);let i=r[t];i===void 0&&(i=a.clone(),r[t]=i,n.addEventListener(`dispose`,x)),a=i}if(a.visible=n.visible,a.wireframe=n.wireframe,i===3?a.side=n.shadowSide===null?n.side:n.shadowSide:a.side=n.shadowSide===null?d[n.side]:n.shadowSide,a.alphaMap=n.alphaMap,a.alphaTest=n.alphaToCoverage===!0?.5:n.alphaTest,a.map=n.map,a.clipShadows=n.clipShadows,a.clippingPlanes=n.clippingPlanes,a.clipIntersection=n.clipIntersection,a.displacementMap=n.displacementMap,a.displacementScale=n.displacementScale,a.displacementBias=n.displacementBias,a.wireframeLinewidth=n.wireframeLinewidth,a.linewidth=n.linewidth,r.isPointLight===!0&&a.isMeshDistanceMaterial===!0){let t=e.properties.get(a);t.light=r}return a}function b(n,i,a,o,s){if(n.visible===!1)return;if(n.layers.test(i.layers)&&(n.isMesh||n.isLine||n.isPoints)&&(n.castShadow||n.receiveShadow&&s===3)&&(!n.frustumCulled||r.intersectsObject(n))){n.modelViewMatrix.multiplyMatrices(a.matrixWorldInverse,n.matrixWorld);let r=t.update(n),c=n.material;if(Array.isArray(c)){let t=r.groups;for(let l=0,u=t.length;l=2):(ee=parseFloat(/^WebGL (\d)/.exec(te)[1]),N=ee>=1);let ne=null,re={},ie=e.getParameter(e.SCISSOR_BOX),ae=e.getParameter(e.VIEWPORT),oe=new Hn().fromArray(ie),se=new Hn().fromArray(ae);function ce(t,n,r,i){let a=new Uint8Array(4),o=e.createTexture();e.bindTexture(t,o),e.texParameteri(t,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(t,e.TEXTURE_MAG_FILTER,e.NEAREST);for(let o=0;o`u`?!1:/OculusBrowser/g.test(navigator.userAgent),l=new L,u=new WeakMap,d=new Set,f,p=new WeakMap,m=!1;try{m=typeof OffscreenCanvas<`u`&&new OffscreenCanvas(1,1).getContext(`2d`)!==null}catch{}function h(e,t){return m?new OffscreenCanvas(e,t):Rt(`canvas`)}function g(e,t,n){let r=1,i=Ie(e);if((i.width>n||i.height>n)&&(r=n/Math.max(i.width,i.height)),r<1)if(typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement||typeof ImageBitmap<`u`&&e instanceof ImageBitmap||typeof VideoFrame<`u`&&e instanceof VideoFrame){let n=Math.floor(r*i.width),a=Math.floor(r*i.height);f===void 0&&(f=h(n,a));let o=t?h(n,a):f;return o.width=n,o.height=a,o.getContext(`2d`).drawImage(e,0,0,n,a),F(`WebGLRenderer: Texture has been resized from (`+i.width+`x`+i.height+`) to (`+n+`x`+a+`).`),o}else return`data`in e&&F(`WebGLRenderer: Image in DataTexture is too big (`+i.width+`x`+i.height+`).`),e;return e}function _(e){return e.generateMipmaps}function v(t){e.generateMipmap(t)}function y(t){return t.isWebGLCubeRenderTarget?e.TEXTURE_CUBE_MAP:t.isWebGL3DRenderTarget?e.TEXTURE_3D:t.isWebGLArrayRenderTarget||t.isCompressedArrayTexture?e.TEXTURE_2D_ARRAY:e.TEXTURE_2D}function b(n,r,i,a,o,s=!1){if(n!==null){if(e[n]!==void 0)return e[n];F(`WebGLRenderer: Attempt to use non-existing WebGL internal format '`+n+`'`)}let c;a&&(c=t.get(`EXT_texture_norm16`),c||F(`WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension`));let l=r;if(r===e.RED&&(i===e.FLOAT&&(l=e.R32F),i===e.HALF_FLOAT&&(l=e.R16F),i===e.UNSIGNED_BYTE&&(l=e.R8),i===e.UNSIGNED_SHORT&&c&&(l=c.R16_EXT),i===e.SHORT&&c&&(l=c.R16_SNORM_EXT)),r===e.RED_INTEGER&&(i===e.UNSIGNED_BYTE&&(l=e.R8UI),i===e.UNSIGNED_SHORT&&(l=e.R16UI),i===e.UNSIGNED_INT&&(l=e.R32UI),i===e.BYTE&&(l=e.R8I),i===e.SHORT&&(l=e.R16I),i===e.INT&&(l=e.R32I)),r===e.RG&&(i===e.FLOAT&&(l=e.RG32F),i===e.HALF_FLOAT&&(l=e.RG16F),i===e.UNSIGNED_BYTE&&(l=e.RG8),i===e.UNSIGNED_SHORT&&c&&(l=c.RG16_EXT),i===e.SHORT&&c&&(l=c.RG16_SNORM_EXT)),r===e.RG_INTEGER&&(i===e.UNSIGNED_BYTE&&(l=e.RG8UI),i===e.UNSIGNED_SHORT&&(l=e.RG16UI),i===e.UNSIGNED_INT&&(l=e.RG32UI),i===e.BYTE&&(l=e.RG8I),i===e.SHORT&&(l=e.RG16I),i===e.INT&&(l=e.RG32I)),r===e.RGB_INTEGER&&(i===e.UNSIGNED_BYTE&&(l=e.RGB8UI),i===e.UNSIGNED_SHORT&&(l=e.RGB16UI),i===e.UNSIGNED_INT&&(l=e.RGB32UI),i===e.BYTE&&(l=e.RGB8I),i===e.SHORT&&(l=e.RGB16I),i===e.INT&&(l=e.RGB32I)),r===e.RGBA_INTEGER&&(i===e.UNSIGNED_BYTE&&(l=e.RGBA8UI),i===e.UNSIGNED_SHORT&&(l=e.RGBA16UI),i===e.UNSIGNED_INT&&(l=e.RGBA32UI),i===e.BYTE&&(l=e.RGBA8I),i===e.SHORT&&(l=e.RGBA16I),i===e.INT&&(l=e.RGBA32I)),r===e.RGB&&(i===e.UNSIGNED_SHORT&&c&&(l=c.RGB16_EXT),i===e.SHORT&&c&&(l=c.RGB16_SNORM_EXT),i===e.UNSIGNED_INT_5_9_9_9_REV&&(l=e.RGB9_E5),i===e.UNSIGNED_INT_10F_11F_11F_REV&&(l=e.R11F_G11F_B10F)),r===e.RGBA){let t=s?xt:jn.getTransfer(o);i===e.FLOAT&&(l=e.RGBA32F),i===e.HALF_FLOAT&&(l=e.RGBA16F),i===e.UNSIGNED_BYTE&&(l=t===`srgb`?e.SRGB8_ALPHA8:e.RGBA8),i===e.UNSIGNED_SHORT&&c&&(l=c.RGBA16_EXT),i===e.SHORT&&c&&(l=c.RGBA16_SNORM_EXT),i===e.UNSIGNED_SHORT_4_4_4_4&&(l=e.RGBA4),i===e.UNSIGNED_SHORT_5_5_5_1&&(l=e.RGB5_A1)}return(l===e.R16F||l===e.R32F||l===e.RG16F||l===e.RG32F||l===e.RGBA16F||l===e.RGBA32F)&&t.get(`EXT_color_buffer_float`),l}function x(t,n){let r;return t?n===null||n===1014||n===1020?r=e.DEPTH24_STENCIL8:n===1015?r=e.DEPTH32F_STENCIL8:n===1012&&(r=e.DEPTH24_STENCIL8,F(`DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.`)):n===null||n===1014||n===1020?r=e.DEPTH_COMPONENT24:n===1015?r=e.DEPTH_COMPONENT32F:n===1012&&(r=e.DEPTH_COMPONENT16),r}function S(e,t){return _(e)===!0||e.isFramebufferTexture&&e.minFilter!==1003&&e.minFilter!==1006?Math.log2(Math.max(t.width,t.height))+1:e.mipmaps!==void 0&&e.mipmaps.length>0?e.mipmaps.length:e.isCompressedTexture&&Array.isArray(e.image)?t.mipmaps.length:1}function C(e){let t=e.target;t.removeEventListener(`dispose`,C),T(t),t.isVideoTexture&&u.delete(t),t.isHTMLTexture&&d.delete(t)}function w(e){let t=e.target;t.removeEventListener(`dispose`,w),D(t)}function T(e){let t=r.get(e);if(t.__webglInit===void 0)return;let n=e.source,i=p.get(n);if(i){let r=i[t.__cacheKey];r.usedTimes--,r.usedTimes===0&&E(e),Object.keys(i).length===0&&p.delete(n)}r.remove(e)}function E(t){let n=r.get(t);e.deleteTexture(n.__webglTexture);let i=t.source,a=p.get(i);delete a[n.__cacheKey],o.memory.textures--}function D(t){let n=r.get(t);if(t.depthTexture&&(t.depthTexture.dispose(),r.remove(t.depthTexture)),t.isWebGLCubeRenderTarget)for(let t=0;t<6;t++){if(Array.isArray(n.__webglFramebuffer[t]))for(let r=0;r=i.maxTextures&&F(`WebGLTextures: Trying to use `+e+` texture units while this GPU supports only `+i.maxTextures),O+=1,e}function ce(e){let t=[];return t.push(e.wrapS),t.push(e.wrapT),t.push(e.wrapR||0),t.push(e.magFilter),t.push(e.minFilter),t.push(e.anisotropy),t.push(e.internalFormat),t.push(e.format),t.push(e.type),t.push(e.generateMipmaps),t.push(e.premultiplyAlpha),t.push(e.flipY),t.push(e.unpackAlignment),t.push(e.colorSpace),t.join()}function le(t,i){let a=r.get(t);if(t.isVideoTexture&&P(t),t.isRenderTargetTexture===!1&&t.isExternalTexture!==!0&&t.version>0&&a.__version!==t.version){let e=t.image;if(e===null)F(`WebGLRenderer: Texture marked for update but no image data found.`);else if(e.complete===!1)F(`WebGLRenderer: Texture marked for update but image is incomplete`);else{be(a,t,i);return}}else t.isExternalTexture&&(a.__webglTexture=t.sourceTexture?t.sourceTexture:null);n.bindTexture(e.TEXTURE_2D,a.__webglTexture,e.TEXTURE0+i)}function ue(t,i){let a=r.get(t);if(t.isRenderTargetTexture===!1&&t.version>0&&a.__version!==t.version){be(a,t,i);return}else t.isExternalTexture&&(a.__webglTexture=t.sourceTexture?t.sourceTexture:null);n.bindTexture(e.TEXTURE_2D_ARRAY,a.__webglTexture,e.TEXTURE0+i)}function de(t,i){let a=r.get(t);if(t.isRenderTargetTexture===!1&&t.version>0&&a.__version!==t.version){be(a,t,i);return}n.bindTexture(e.TEXTURE_3D,a.__webglTexture,e.TEXTURE0+i)}function fe(t,i){let a=r.get(t);if(t.isCubeDepthTexture!==!0&&t.version>0&&a.__version!==t.version){xe(a,t,i);return}n.bindTexture(e.TEXTURE_CUBE_MAP,a.__webglTexture,e.TEXTURE0+i)}let pe={[A]:e.REPEAT,[j]:e.CLAMP_TO_EDGE,[M]:e.MIRRORED_REPEAT},me={[N]:e.NEAREST,[ee]:e.NEAREST_MIPMAP_NEAREST,[te]:e.NEAREST_MIPMAP_LINEAR,[ne]:e.LINEAR,[re]:e.LINEAR_MIPMAP_NEAREST,[ie]:e.LINEAR_MIPMAP_LINEAR},he={512:e.NEVER,519:e.ALWAYS,513:e.LESS,515:e.LEQUAL,514:e.EQUAL,518:e.GEQUAL,516:e.GREATER,517:e.NOTEQUAL};function ge(n,a){if(a.type===1015&&t.has(`OES_texture_float_linear`)===!1&&(a.magFilter===1006||a.magFilter===1007||a.magFilter===1005||a.magFilter===1008||a.minFilter===1006||a.minFilter===1007||a.minFilter===1005||a.minFilter===1008)&&F(`WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device.`),e.texParameteri(n,e.TEXTURE_WRAP_S,pe[a.wrapS]),e.texParameteri(n,e.TEXTURE_WRAP_T,pe[a.wrapT]),(n===e.TEXTURE_3D||n===e.TEXTURE_2D_ARRAY)&&e.texParameteri(n,e.TEXTURE_WRAP_R,pe[a.wrapR]),e.texParameteri(n,e.TEXTURE_MAG_FILTER,me[a.magFilter]),e.texParameteri(n,e.TEXTURE_MIN_FILTER,me[a.minFilter]),a.compareFunction&&(e.texParameteri(n,e.TEXTURE_COMPARE_MODE,e.COMPARE_REF_TO_TEXTURE),e.texParameteri(n,e.TEXTURE_COMPARE_FUNC,he[a.compareFunction])),t.has(`EXT_texture_filter_anisotropic`)===!0){if(a.magFilter===1003||a.minFilter!==1005&&a.minFilter!==1008||a.type===1015&&t.has(`OES_texture_float_linear`)===!1)return;if(a.anisotropy>1||r.get(a).__currentAnisotropy){let o=t.get(`EXT_texture_filter_anisotropic`);e.texParameterf(n,o.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(a.anisotropy,i.getMaxAnisotropy())),r.get(a).__currentAnisotropy=a.anisotropy}}}function _e(t,n){let r=!1;t.__webglInit===void 0&&(t.__webglInit=!0,n.addEventListener(`dispose`,C));let i=n.source,a=p.get(i);a===void 0&&(a={},p.set(i,a));let s=ce(n);if(s!==t.__cacheKey){a[s]===void 0&&(a[s]={texture:e.createTexture(),usedTimes:0},o.memory.textures++,r=!0),a[s].usedTimes++;let i=a[t.__cacheKey];i!==void 0&&(a[t.__cacheKey].usedTimes--,i.usedTimes===0&&E(n)),t.__cacheKey=s,t.__webglTexture=a[s].texture}return r}function ve(e,t,n){return Math.floor(Math.floor(e/n)/t)}function ye(t,r,i,a){let o=t.updateRanges;if(o.length===0)n.texSubImage2D(e.TEXTURE_2D,0,0,0,r.width,r.height,i,a,r.data);else{o.sort((e,t)=>e.start-t.start);let s=0;for(let e=1;e0){C&&w&&n.texStorage2D(e.TEXTURE_2D,E,m,y[0].width,y[0].height);for(let t=0,i=y.length;t0){let t=ll(h.width,h.height,o.format,o.type);for(let a of o.layerUpdates){let o=h.data.subarray(a*t/h.data.BYTES_PER_ELEMENT,(a+1)*t/h.data.BYTES_PER_ELEMENT);n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,i,0,0,a,h.width,h.height,1,r,o)}o.clearLayerUpdates()}else n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,i,0,0,0,h.width,h.height,t.depth,r,h.data)}else n.compressedTexImage3D(e.TEXTURE_2D_ARRAY,i,m,h.width,h.height,t.depth,0,h.data,0,0);else F(`WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()`);else C?T&&n.texSubImage3D(e.TEXTURE_2D_ARRAY,i,0,0,0,h.width,h.height,t.depth,r,p,h.data):n.texImage3D(e.TEXTURE_2D_ARRAY,i,m,h.width,h.height,t.depth,0,r,p,h.data)}else{C&&w&&n.texStorage2D(e.TEXTURE_2D,E,m,y[0].width,y[0].height);for(let t=0,i=y.length;t0){let i=ll(t.width,t.height,o.format,o.type);for(let a of o.layerUpdates){let o=t.data.subarray(a*i/t.data.BYTES_PER_ELEMENT,(a+1)*i/t.data.BYTES_PER_ELEMENT);n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,a,t.width,t.height,1,r,p,o)}o.clearLayerUpdates()}else n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,0,t.width,t.height,t.depth,r,p,t.data)}else n.texImage3D(e.TEXTURE_2D_ARRAY,0,m,t.width,t.height,t.depth,0,r,p,t.data);else if(o.isData3DTexture)C?(w&&n.texStorage3D(e.TEXTURE_3D,E,m,t.width,t.height,t.depth),T&&n.texSubImage3D(e.TEXTURE_3D,0,0,0,0,t.width,t.height,t.depth,r,p,t.data)):n.texImage3D(e.TEXTURE_3D,0,m,t.width,t.height,t.depth,0,r,p,t.data);else if(o.isFramebufferTexture){if(w)if(C)n.texStorage2D(e.TEXTURE_2D,E,m,t.width,t.height);else{let i=t.width,a=t.height;for(let t=0;t>=1,a>>=1}}else if(o.isHTMLTexture){if(`texElementImage2D`in e){let n=e.canvas;if(n.hasAttribute(`layoutsubtree`)||n.setAttribute(`layoutsubtree`,`true`),t.parentNode!==n){n.appendChild(t),d.add(o),n.onpaint=e=>{let t=e.changedElements;for(let e of d)t.includes(e.image)&&(e.needsUpdate=!0)},n.requestPaint();return}if(e.texElementImage2D.length===3)e.texElementImage2D(e.TEXTURE_2D,e.RGBA8,t);else{let n=e.RGBA,r=e.RGBA,i=e.UNSIGNED_BYTE;e.texElementImage2D(e.TEXTURE_2D,0,n,r,i,t)}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(y.length>0){if(C&&w){let t=Ie(y[0]);n.texStorage2D(e.TEXTURE_2D,E,m,t.width,t.height)}for(let t=0,i=y.length;t0&&D++;let t=Ie(m[0]);n.texStorage2D(e.TEXTURE_CUBE_MAP,D,C,t.width,t.height)}for(let t=0;t<6;t++)if(p){w?E&&n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,0,0,m[t].width,m[t].height,y,x,m[t].data):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,C,m[t].width,m[t].height,0,y,x,m[t].data);for(let r=0;r>u),r=Math.max(1,i.height>>u);l===e.TEXTURE_3D||l===e.TEXTURE_2D_ARRAY?n.texImage3D(l,u,p,t,r,i.depth,0,d,f,null):n.texImage2D(l,u,p,t,r,0,d,f,null)}n.bindFramebuffer(e.FRAMEBUFFER,t),Pe(i)?s.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,c,l,h.__webglTexture,0,Ne(i)):(l===e.TEXTURE_2D||l>=e.TEXTURE_CUBE_MAP_POSITIVE_X&&l<=e.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&e.framebufferTexture2D(e.FRAMEBUFFER,c,l,h.__webglTexture,u),n.bindFramebuffer(e.FRAMEBUFFER,null)}function we(t,n,r){if(e.bindRenderbuffer(e.RENDERBUFFER,t),n.depthBuffer){let i=n.depthTexture,a=i&&i.isDepthTexture?i.type:null,o=x(n.stencilBuffer,a),c=n.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;Pe(n)?s.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,Ne(n),o,n.width,n.height):r?e.renderbufferStorageMultisample(e.RENDERBUFFER,Ne(n),o,n.width,n.height):e.renderbufferStorage(e.RENDERBUFFER,o,n.width,n.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,c,e.RENDERBUFFER,t)}else{let t=n.textures;for(let i=0;i{delete i.__boundDepthTexture,delete i.__depthDisposeCallback,e.removeEventListener(`dispose`,t)};e.addEventListener(`dispose`,t),i.__depthDisposeCallback=t}i.__boundDepthTexture=e}if(t.depthTexture&&!i.__autoAllocateDepthBuffer)if(a)for(let e=0;e<6;e++)Te(i.__webglFramebuffer[e],t,e);else{let e=t.texture.mipmaps;e&&e.length>0?Te(i.__webglFramebuffer[0],t,0):Te(i.__webglFramebuffer,t,0)}else if(a){i.__webglDepthbuffer=[];for(let r=0;r<6;r++)if(n.bindFramebuffer(e.FRAMEBUFFER,i.__webglFramebuffer[r]),i.__webglDepthbuffer[r]===void 0)i.__webglDepthbuffer[r]=e.createRenderbuffer(),we(i.__webglDepthbuffer[r],t,!1);else{let n=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,a=i.__webglDepthbuffer[r];e.bindRenderbuffer(e.RENDERBUFFER,a),e.framebufferRenderbuffer(e.FRAMEBUFFER,n,e.RENDERBUFFER,a)}}else{let r=t.texture.mipmaps;if(r&&r.length>0?n.bindFramebuffer(e.FRAMEBUFFER,i.__webglFramebuffer[0]):n.bindFramebuffer(e.FRAMEBUFFER,i.__webglFramebuffer),i.__webglDepthbuffer===void 0)i.__webglDepthbuffer=e.createRenderbuffer(),we(i.__webglDepthbuffer,t,!1);else{let n=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,r=i.__webglDepthbuffer;e.bindRenderbuffer(e.RENDERBUFFER,r),e.framebufferRenderbuffer(e.FRAMEBUFFER,n,e.RENDERBUFFER,r)}}n.bindFramebuffer(e.FRAMEBUFFER,null)}function De(t,n,i){let a=r.get(t);n!==void 0&&Se(a.__webglFramebuffer,t,t.texture,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,0),i!==void 0&&Ee(t)}function Oe(t){let i=t.texture,s=r.get(t),c=r.get(i);t.addEventListener(`dispose`,w);let l=t.textures,u=t.isWebGLCubeRenderTarget===!0,d=l.length>1;if(d||(c.__webglTexture===void 0&&(c.__webglTexture=e.createTexture()),c.__version=i.version,o.memory.textures++),u){s.__webglFramebuffer=[];for(let t=0;t<6;t++)if(i.mipmaps&&i.mipmaps.length>0){s.__webglFramebuffer[t]=[];for(let n=0;n0){s.__webglFramebuffer=[];for(let t=0;t0&&Pe(t)===!1){s.__webglMultisampledFramebuffer=e.createFramebuffer(),s.__webglColorRenderbuffer=[],n.bindFramebuffer(e.FRAMEBUFFER,s.__webglMultisampledFramebuffer);for(let n=0;n0)for(let r=0;r0)for(let n=0;n0){if(Pe(t)===!1){let i=t.textures,a=t.width,o=t.height,s=e.COLOR_BUFFER_BIT,l=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,u=r.get(t),d=i.length>1;if(d)for(let t=0;t0?n.bindFramebuffer(e.DRAW_FRAMEBUFFER,u.__webglFramebuffer[0]):n.bindFramebuffer(e.DRAW_FRAMEBUFFER,u.__webglFramebuffer);for(let n=0;n0&&t.has(`WEBGL_multisampled_render_to_texture`)===!0&&n.__useRenderToTexture!==!1}function P(e){let t=o.render.frame;u.get(e)!==t&&(u.set(e,t),e.update())}function Fe(e,t){let n=e.colorSpace,r=e.format,i=e.type;return e.isCompressedTexture===!0||e.isVideoTexture===!0||n!==`srgb-linear`&&n!==``&&(jn.getTransfer(n)===`srgb`?(r!==1023||i!==1009)&&F(`WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType.`):I(`WebGLTextures: Unsupported texture color space:`,n)),t}function Ie(e){return typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement?(l.width=e.naturalWidth||e.width,l.height=e.naturalHeight||e.height):typeof VideoFrame<`u`&&e instanceof VideoFrame?(l.width=e.displayWidth,l.height=e.displayHeight):(l.width=e.width,l.height=e.height),l}this.allocateTextureUnit=se,this.resetTextureUnits=k,this.getTextureUnits=ae,this.setTextureUnits=oe,this.setTexture2D=le,this.setTexture2DArray=ue,this.setTexture3D=de,this.setTextureCube=fe,this.rebindTextures=De,this.setupRenderTarget=Oe,this.updateRenderTargetMipmap=ke,this.updateMultisampleRenderTarget=Me,this.setupDepthRenderbuffer=Ee,this.setupFrameBufferTexture=Se,this.useMultisampledRTT=Pe,this.isReversedDepthBuffer=function(){return n.buffers.depth.getReversed()}}function iee(e,t){function n(n,r=``){let i,a=jn.getTransfer(r);if(n===1009)return e.UNSIGNED_BYTE;if(n===1017)return e.UNSIGNED_SHORT_4_4_4_4;if(n===1018)return e.UNSIGNED_SHORT_5_5_5_1;if(n===35902)return e.UNSIGNED_INT_5_9_9_9_REV;if(n===35899)return e.UNSIGNED_INT_10F_11F_11F_REV;if(n===1010)return e.BYTE;if(n===1011)return e.SHORT;if(n===1012)return e.UNSIGNED_SHORT;if(n===1013)return e.INT;if(n===1014)return e.UNSIGNED_INT;if(n===1015)return e.FLOAT;if(n===1016)return e.HALF_FLOAT;if(n===1021)return e.ALPHA;if(n===1022)return e.RGB;if(n===1023)return e.RGBA;if(n===1026)return e.DEPTH_COMPONENT;if(n===1027)return e.DEPTH_STENCIL;if(n===1028)return e.RED;if(n===1029)return e.RED_INTEGER;if(n===1030)return e.RG;if(n===1031)return e.RG_INTEGER;if(n===1033)return e.RGBA_INTEGER;if(n===33776||n===33777||n===33778||n===33779)if(a===`srgb`)if(i=t.get(`WEBGL_compressed_texture_s3tc_srgb`),i!==null){if(n===33776)return i.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===33777)return i.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===33778)return i.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===33779)return i.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(i=t.get(`WEBGL_compressed_texture_s3tc`),i!==null){if(n===33776)return i.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===33777)return i.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===33778)return i.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===33779)return i.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===35840||n===35841||n===35842||n===35843)if(i=t.get(`WEBGL_compressed_texture_pvrtc`),i!==null){if(n===35840)return i.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===35841)return i.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===35842)return i.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===35843)return i.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===36196||n===37492||n===37496||n===37488||n===37489||n===37490||n===37491)if(i=t.get(`WEBGL_compressed_texture_etc`),i!==null){if(n===36196||n===37492)return a===`srgb`?i.COMPRESSED_SRGB8_ETC2:i.COMPRESSED_RGB8_ETC2;if(n===37496)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:i.COMPRESSED_RGBA8_ETC2_EAC;if(n===37488)return i.COMPRESSED_R11_EAC;if(n===37489)return i.COMPRESSED_SIGNED_R11_EAC;if(n===37490)return i.COMPRESSED_RG11_EAC;if(n===37491)return i.COMPRESSED_SIGNED_RG11_EAC}else return null;if(n===37808||n===37809||n===37810||n===37811||n===37812||n===37813||n===37814||n===37815||n===37816||n===37817||n===37818||n===37819||n===37820||n===37821)if(i=t.get(`WEBGL_compressed_texture_astc`),i!==null){if(n===37808)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:i.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===37809)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:i.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===37810)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:i.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===37811)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:i.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===37812)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:i.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===37813)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:i.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===37814)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:i.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===37815)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:i.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===37816)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:i.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===37817)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:i.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===37818)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:i.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===37819)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:i.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===37820)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:i.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===37821)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:i.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===36492||n===36494||n===36495)if(i=t.get(`EXT_texture_compression_bptc`),i!==null){if(n===36492)return a===`srgb`?i.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:i.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===36494)return i.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===36495)return i.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===36283||n===36284||n===36285||n===36286)if(i=t.get(`EXT_texture_compression_rgtc`),i!==null){if(n===36283)return i.COMPRESSED_RED_RGTC1_EXT;if(n===36284)return i.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===36285)return i.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===36286)return i.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===1020?e.UNSIGNED_INT_24_8:e[n]===void 0?null:e[n]}return{convert:n}}var aee=` void main() { gl_Position = vec4( position, 1.0 ); }`,oee=` uniform sampler2DArray depthColor; uniform float depthWidth; uniform float depthHeight; void main() { vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight ); if ( coord.x >= 1.0 ) { gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r; } else { gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r; } }`,see=class{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){let n=new za(e.texture);(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&&this.mesh===null){let t=e.cameras[0].viewport,n=new xs({vertexShader:aee,fragmentShader:oee,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new ea(new ss(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}},cee=class extends Jt{constructor(e,t){super();let n=this,r=null,i=1,a=null,o=`local-floor`,s=1,c=null,l=null,u=null,d=null,f=null,p=null,m=typeof XRWebGLBinding<`u`,h=new see,g={},_=t.getContextAttributes(),v=null,y=null,b=[],x=[],S=new L,C=null,w=new pc;w.viewport=new Hn;let T=new pc;T.viewport=new Hn;let E=[w,T],D=new kc,O=null,k=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(e){let t=b[e];return t===void 0&&(t=new xr,b[e]=t),t.getTargetRaySpace()},this.getControllerGrip=function(e){let t=b[e];return t===void 0&&(t=new xr,b[e]=t),t.getGripSpace()},this.getHand=function(e){let t=b[e];return t===void 0&&(t=new xr,b[e]=t),t.getHandSpace()};function A(e){let t=x.indexOf(e.inputSource);if(t===-1)return;let n=b[t];n!==void 0&&(n.update(e.inputSource,e.frame,c||a),n.dispatchEvent({type:e.type,data:e.inputSource}))}function j(){r.removeEventListener(`select`,A),r.removeEventListener(`selectstart`,A),r.removeEventListener(`selectend`,A),r.removeEventListener(`squeeze`,A),r.removeEventListener(`squeezestart`,A),r.removeEventListener(`squeezeend`,A),r.removeEventListener(`end`,j),r.removeEventListener(`inputsourceschange`,M);for(let e=0;e=0&&(x[r]=null,b[r].disconnect(n))}for(let t=0;t=x.length){x.push(n),r=e;break}else if(x[e]===null){x[e]=n,r=e;break}if(r===-1)break}let i=b[r];i&&i.connect(n)}}let N=new R,ee=new R;function te(e,t,n){N.setFromMatrixPosition(t.matrixWorld),ee.setFromMatrixPosition(n.matrixWorld);let r=N.distanceTo(ee),i=t.projectionMatrix.elements,a=n.projectionMatrix.elements,o=i[14]/(i[10]-1),s=i[14]/(i[10]+1),c=(i[9]+1)/i[5],l=(i[9]-1)/i[5],u=(i[8]-1)/i[0],d=(a[8]+1)/a[0],f=o*u,p=o*d,m=r/(-u+d),h=m*-u;if(t.matrixWorld.decompose(e.position,e.quaternion,e.scale),e.translateX(h),e.translateZ(m),e.matrixWorld.compose(e.position,e.quaternion,e.scale),e.matrixWorldInverse.copy(e.matrixWorld).invert(),i[10]===-1)e.projectionMatrix.copy(t.projectionMatrix),e.projectionMatrixInverse.copy(t.projectionMatrixInverse);else{let t=o+m,n=s+m,i=f-h,a=p+(r-h),u=c*s/n*t,d=l*s/n*t;e.projectionMatrix.makePerspective(i,a,u,d,t,n),e.projectionMatrixInverse.copy(e.projectionMatrix).invert()}}function ne(e,t){t===null?e.matrixWorld.copy(e.matrix):e.matrixWorld.multiplyMatrices(t.matrixWorld,e.matrix),e.matrixWorldInverse.copy(e.matrixWorld).invert()}this.updateCamera=function(e){if(r===null)return;let t=e.near,n=e.far;h.texture!==null&&(h.depthNear>0&&(t=h.depthNear),h.depthFar>0&&(n=h.depthFar)),D.near=T.near=w.near=t,D.far=T.far=w.far=n,(O!==D.near||k!==D.far)&&(r.updateRenderState({depthNear:D.near,depthFar:D.far}),O=D.near,k=D.far),D.layers.mask=e.layers.mask|6,w.layers.mask=D.layers.mask&-5,T.layers.mask=D.layers.mask&-3;let i=e.parent,a=D.cameras;ne(D,i);for(let e=0;e0&&(e.alphaTest.value=r.alphaTest);let i=t.get(r),a=i.envMap,o=i.envMapRotation;a&&(e.envMap.value=a,e.envMapRotation.value.setFromMatrix4(lee.makeRotationFromEuler(o)).transpose(),a.isCubeTexture&&a.isRenderTargetTexture===!1&&e.envMapRotation.value.premultiply(pf),e.reflectivity.value=r.reflectivity,e.ior.value=r.ior,e.refractionRatio.value=r.refractionRatio),r.lightMap&&(e.lightMap.value=r.lightMap,e.lightMapIntensity.value=r.lightMapIntensity,n(r.lightMap,e.lightMapTransform)),r.aoMap&&(e.aoMap.value=r.aoMap,e.aoMapIntensity.value=r.aoMapIntensity,n(r.aoMap,e.aoMapTransform))}function o(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,t.map&&(e.map.value=t.map,n(t.map,e.mapTransform))}function s(e,t){e.dashSize.value=t.dashSize,e.totalSize.value=t.dashSize+t.gapSize,e.scale.value=t.scale}function c(e,t,r,i){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.size.value=t.size*r,e.scale.value=i*.5,t.map&&(e.map.value=t.map,n(t.map,e.uvTransform)),t.alphaMap&&(e.alphaMap.value=t.alphaMap,n(t.alphaMap,e.alphaMapTransform)),t.alphaTest>0&&(e.alphaTest.value=t.alphaTest)}function l(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.rotation.value=t.rotation,t.map&&(e.map.value=t.map,n(t.map,e.mapTransform)),t.alphaMap&&(e.alphaMap.value=t.alphaMap,n(t.alphaMap,e.alphaMapTransform)),t.alphaTest>0&&(e.alphaTest.value=t.alphaTest)}function u(e,t){e.specular.value.copy(t.specular),e.shininess.value=Math.max(t.shininess,1e-4)}function d(e,t){t.gradientMap&&(e.gradientMap.value=t.gradientMap)}function f(e,t){e.metalness.value=t.metalness,t.metalnessMap&&(e.metalnessMap.value=t.metalnessMap,n(t.metalnessMap,e.metalnessMapTransform)),e.roughness.value=t.roughness,t.roughnessMap&&(e.roughnessMap.value=t.roughnessMap,n(t.roughnessMap,e.roughnessMapTransform)),t.envMap&&(e.envMapIntensity.value=t.envMapIntensity)}function p(e,t,r){e.ior.value=t.ior,t.sheen>0&&(e.sheenColor.value.copy(t.sheenColor).multiplyScalar(t.sheen),e.sheenRoughness.value=t.sheenRoughness,t.sheenColorMap&&(e.sheenColorMap.value=t.sheenColorMap,n(t.sheenColorMap,e.sheenColorMapTransform)),t.sheenRoughnessMap&&(e.sheenRoughnessMap.value=t.sheenRoughnessMap,n(t.sheenRoughnessMap,e.sheenRoughnessMapTransform))),t.clearcoat>0&&(e.clearcoat.value=t.clearcoat,e.clearcoatRoughness.value=t.clearcoatRoughness,t.clearcoatMap&&(e.clearcoatMap.value=t.clearcoatMap,n(t.clearcoatMap,e.clearcoatMapTransform)),t.clearcoatRoughnessMap&&(e.clearcoatRoughnessMap.value=t.clearcoatRoughnessMap,n(t.clearcoatRoughnessMap,e.clearcoatRoughnessMapTransform)),t.clearcoatNormalMap&&(e.clearcoatNormalMap.value=t.clearcoatNormalMap,n(t.clearcoatNormalMap,e.clearcoatNormalMapTransform),e.clearcoatNormalScale.value.copy(t.clearcoatNormalScale),t.side===1&&e.clearcoatNormalScale.value.negate())),t.dispersion>0&&(e.dispersion.value=t.dispersion),t.iridescence>0&&(e.iridescence.value=t.iridescence,e.iridescenceIOR.value=t.iridescenceIOR,e.iridescenceThicknessMinimum.value=t.iridescenceThicknessRange[0],e.iridescenceThicknessMaximum.value=t.iridescenceThicknessRange[1],t.iridescenceMap&&(e.iridescenceMap.value=t.iridescenceMap,n(t.iridescenceMap,e.iridescenceMapTransform)),t.iridescenceThicknessMap&&(e.iridescenceThicknessMap.value=t.iridescenceThicknessMap,n(t.iridescenceThicknessMap,e.iridescenceThicknessMapTransform))),t.transmission>0&&(e.transmission.value=t.transmission,e.transmissionSamplerMap.value=r.texture,e.transmissionSamplerSize.value.set(r.width,r.height),t.transmissionMap&&(e.transmissionMap.value=t.transmissionMap,n(t.transmissionMap,e.transmissionMapTransform)),e.thickness.value=t.thickness,t.thicknessMap&&(e.thicknessMap.value=t.thicknessMap,n(t.thicknessMap,e.thicknessMapTransform)),e.attenuationDistance.value=t.attenuationDistance,e.attenuationColor.value.copy(t.attenuationColor)),t.anisotropy>0&&(e.anisotropyVector.value.set(t.anisotropy*Math.cos(t.anisotropyRotation),t.anisotropy*Math.sin(t.anisotropyRotation)),t.anisotropyMap&&(e.anisotropyMap.value=t.anisotropyMap,n(t.anisotropyMap,e.anisotropyMapTransform))),e.specularIntensity.value=t.specularIntensity,e.specularColor.value.copy(t.specularColor),t.specularColorMap&&(e.specularColorMap.value=t.specularColorMap,n(t.specularColorMap,e.specularColorMapTransform)),t.specularIntensityMap&&(e.specularIntensityMap.value=t.specularIntensityMap,n(t.specularIntensityMap,e.specularIntensityMapTransform))}function m(e,t){t.matcap&&(e.matcap.value=t.matcap)}function h(e,n){let r=t.get(n).light;e.referencePosition.value.setFromMatrixPosition(r.matrixWorld),e.nearDistance.value=r.shadow.camera.near,e.farDistance.value=r.shadow.camera.far}return{refreshFogUniforms:r,refreshMaterialUniforms:i}}function dee(e,t,n,r){let i={},a={},o=[],s=e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS);function c(e,t){let n=t.program;r.uniformBlockBinding(e,n)}function l(e,n){let o=i[e.id];o===void 0&&(g(e),o=u(e),i[e.id]=o,e.addEventListener(`dispose`,v));let s=n.program;r.updateUBOMapping(e,s);let c=t.render.frame;a[e.id]!==c&&(f(e),a[e.id]=c)}function u(t){let n=d();t.__bindingPointIndex=n;let r=e.createBuffer(),i=t.__size,a=t.usage;return e.bindBuffer(e.UNIFORM_BUFFER,r),e.bufferData(e.UNIFORM_BUFFER,i,a),e.bindBuffer(e.UNIFORM_BUFFER,null),e.bindBufferBase(e.UNIFORM_BUFFER,n,r),r}function d(){for(let e=0;e0&&(n+=16-r),e.__size=n,e.__cache={},this}function _(e){let t={boundary:0,storage:0};return typeof e==`number`||typeof e==`boolean`?(t.boundary=4,t.storage=4):e.isVector2?(t.boundary=8,t.storage=8):e.isVector3||e.isColor?(t.boundary=16,t.storage=12):e.isVector4?(t.boundary=16,t.storage=16):e.isMatrix3?(t.boundary=48,t.storage=48):e.isMatrix4?(t.boundary=64,t.storage=64):e.isTexture?F(`WebGLRenderer: Texture samplers can not be part of an uniforms group.`):ArrayBuffer.isView(e)?(t.boundary=16,t.storage=e.byteLength):F(`WebGLRenderer: Unsupported uniform value type.`,e),t}function v(t){let n=t.target;n.removeEventListener(`dispose`,v);let r=o.indexOf(n.__bindingPointIndex);o.splice(r,1),e.deleteBuffer(i[n.id]),delete i[n.id],delete a[n.id]}function y(){for(let t in i)e.deleteBuffer(i[t]);o=[],i={},a={}}return{bind:c,update:l,dispose:y}}var mf=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]),hf=null;function gf(){return hf===null&&(hf=new ra(mf,16,16,Ee,pe),hf.name=`DFG_LUT`,hf.minFilter=ne,hf.magFilter=ne,hf.wrapS=j,hf.wrapT=j,hf.generateMipmaps=!1,hf.needsUpdate=!0),hf}var _f=class{constructor(e={}){let{canvas:t=zt(),context:n=null,depth:r=!0,stencil:i=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:s=!0,preserveDrawingBuffer:c=!1,powerPreference:l=`default`,failIfMajorPerformanceCaveat:u=!1,reversedDepthBuffer:d=!1,outputBufferType:f=oe}=e;this.isWebGLRenderer=!0;let p;if(n!==null){if(typeof WebGLRenderingContext<`u`&&n instanceof WebGLRenderingContext)throw Error(`THREE.WebGLRenderer: WebGL 1 is not supported since r163.`);p=n.getContextAttributes().alpha}else p=a;let m=f,h=new Set([ke,De,Te]),g=new Set([oe,de,le,ge,me,he]),_=new Uint32Array(4),v=new Int32Array(4),y=new R,b=null,x=null,S=[],C=[],w=null;this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=0,this.toneMappingExposure=1,this.transmissionResolutionScale=1;let T=this,E=!1,D=null,O=null,k=null,A=null;this._outputColorSpace=yt;let j=0,M=0,N=null,ee=-1,te=null,ne=new Hn,re=new Hn,ae=null,se=new Er(0),ce=0,ue=t.width,fe=t.height,_e=1,ve=null,ye=null,be=new Hn(0,0,ue,fe),xe=new Hn(0,0,ue,fe),Se=!1,Ce=new fa,we=!1,Ee=!1,Oe=new qn,Ae=new R,je=new Hn,Me={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},Ne=!1;function Pe(){return N===null?_e:1}let P=n;function Fe(e,n){return t.getContext(e,n)}try{let e={alpha:!0,depth:r,stencil:i,antialias:o,premultipliedAlpha:s,preserveDrawingBuffer:c,powerPreference:l,failIfMajorPerformanceCaveat:u};if(`setAttribute`in t&&t.setAttribute(`data-engine`,`three.js r185`),t.addEventListener(`webglcontextlost`,st,!1),t.addEventListener(`webglcontextrestored`,ct,!1),t.addEventListener(`webglcontextcreationerror`,lt,!1),P===null){let t=`webgl2`;if(P=Fe(t,e),P===null)throw Fe(t)?Error(`THREE.WebGLRenderer: Error creating WebGL context with your selected attributes.`):Error(`THREE.WebGLRenderer: Error creating WebGL context.`)}}catch(e){throw I(`WebGLRenderer: `+e.message),e}let Ie,Le,Re,ze,Be,Ve,He,Ue,We,Ge,Ke,qe,Je,Ye,Xe,Ze,Qe,$e,et,tt,nt,rt,it;function at(){Ie=new Kl(P),Ie.init(),nt=new iee(P,Ie),Le=new Sl(P,Ie,e,nt),Re=new df(P,Ie),Le.reversedDepthBuffer&&d&&Re.buffers.depth.setReversed(!0),O=P.createFramebuffer(),k=P.createFramebuffer(),A=P.createFramebuffer(),ze=new Yl(P),Be=new Wd,Ve=new ff(P,Ie,Re,Be,Le,nt,ze),He=new Gl(T),Ue=new fl(P),rt=new bl(P,Ue),We=new ql(P,Ue,ze,rt),Ge=new Zl(P,We,Ue,rt,ze),$e=new Xl(P,Le,Ve),Xe=new Cl(Be),Ke=new Ud(T,He,Ie,Le,rt,Xe),qe=new uee(T,Be),Je=new Jd,Ye=new tf(Ie),Qe=new yl(T,He,Re,Ge,p,s),Ze=new uf(T,Ge,Le),it=new dee(P,ze,Le,Re),et=new xl(P,Ie,ze),tt=new Jl(P,Ie,ze),ze.programs=Ke.programs,T.capabilities=Le,T.extensions=Ie,T.properties=Be,T.renderLists=Je,T.shadowMap=Ze,T.state=Re,T.info=ze}at(),m!==1009&&(w=new $l(m,t.width,t.height,o,r,i));let ot=new cee(T,P);this.xr=ot,this.getContext=function(){return P},this.getContextAttributes=function(){return P.getContextAttributes()},this.forceContextLoss=function(){let e=Ie.get(`WEBGL_lose_context`);e&&e.loseContext()},this.forceContextRestore=function(){let e=Ie.get(`WEBGL_lose_context`);e&&e.restoreContext()},this.getPixelRatio=function(){return _e},this.setPixelRatio=function(e){e!==void 0&&(_e=e,this.setSize(ue,fe,!1))},this.getSize=function(e){return e.set(ue,fe)},this.setSize=function(e,n,r=!0){if(ot.isPresenting){F(`WebGLRenderer: Can't change size while VR device is presenting.`);return}ue=e,fe=n,t.width=Math.floor(e*_e),t.height=Math.floor(n*_e),r===!0&&(t.style.width=e+`px`,t.style.height=n+`px`),w!==null&&w.setSize(t.width,t.height),this.setViewport(0,0,e,n)},this.getDrawingBufferSize=function(e){return e.set(ue*_e,fe*_e).floor()},this.setDrawingBufferSize=function(e,n,r){ue=e,fe=n,_e=r,t.width=Math.floor(e*r),t.height=Math.floor(n*r),this.setViewport(0,0,e,n)},this.setEffects=function(e){if(m===1009){I(`WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.`);return}if(e){for(let t=0;t{function n(){if(r.forEach(function(e){Be.get(e).currentProgram.isReady()&&r.delete(e)}),r.size===0){t(e);return}setTimeout(n,10)}Ie.get(`KHR_parallel_shader_compile`)===null?setTimeout(n,10):n()})};let mt=null;function ht(e){mt&&mt(e)}function gt(){vt.stop()}function _t(){vt.start()}let vt=new dl;vt.setAnimationLoop(ht),typeof self<`u`&&vt.setContext(self),this.setAnimationLoop=function(e){mt=e,ot.setAnimationLoop(e),e===null?vt.stop():vt.start()},ot.addEventListener(`sessionstart`,gt),ot.addEventListener(`sessionend`,_t),this.render=function(e,t){if(t!==void 0&&t.isCamera!==!0){I(`WebGLRenderer.render: camera is not an instance of THREE.Camera.`);return}if(E===!0)return;D!==null&&D.renderStart(e,t);let n=ot.enabled===!0&&ot.isPresenting===!0,r=w!==null&&(N===null||n)&&w.begin(T,N);if(e.matrixWorldAutoUpdate===!0&&e.updateMatrixWorld(),t.parent===null&&t.matrixWorldAutoUpdate===!0&&t.updateMatrixWorld(),ot.enabled===!0&&ot.isPresenting===!0&&(w===null||w.isCompositing()===!1)&&(ot.cameraAutoUpdate===!0&&ot.updateCamera(t),t=ot.getCamera()),e.isScene===!0&&e.onBeforeRender(T,e,t,N),x=Ye.get(e,C.length),x.init(t),x.state.textureUnits=Ve.getTextureUnits(),C.push(x),Oe.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),Ce.setFromProjectionMatrix(Oe,Mt,t.reversedDepth),Ee=this.localClippingEnabled,we=Xe.init(this.clippingPlanes,Ee),b=Je.get(e,S.length),b.init(),S.push(b),ot.enabled===!0&&ot.isPresenting===!0){let e=T.xr.getDepthSensingMesh();e!==null&&bt(e,t,-1/0,T.sortObjects)}bt(e,t,0,T.sortObjects),b.finish(),T.sortObjects===!0&&b.sort(ve,ye,t.reversedDepth),Ne=ot.enabled===!1||ot.isPresenting===!1||ot.hasDepthSensing()===!1,Ne&&Qe.addToRenderList(b,e),this.info.render.frame++,this.info.autoReset===!0&&this.info.reset(),we===!0&&Xe.beginShadows();let i=x.state.shadowsArray;if(Ze.render(i,e,t),we===!0&&Xe.endShadows(),(r&&w.hasRenderPass())===!1){let n=b.opaque,r=b.transmissive;if(x.setupLights(),t.isArrayCamera){let i=t.cameras;if(r.length>0)for(let t=0,a=i.length;t0&&St(n,r,e,t),Ne&&Qe.render(e),xt(b,e,t)}N!==null&&M===0&&(Ve.updateMultisampleRenderTarget(N),Ve.updateRenderTargetMipmap(N)),r&&w.end(T),e.isScene===!0&&e.onAfterRender(T,e,t),rt.resetDefaultState(),ee=-1,te=null,C.pop(),C.length>0?(x=C[C.length-1],Ve.setTextureUnits(x.state.textureUnits),we===!0&&Xe.setGlobalState(T.clippingPlanes,x.state.camera)):x=null,S.pop(),b=S.length>0?S[S.length-1]:null,D!==null&&D.renderEnd()};function bt(e,t,n,r){if(e.visible===!1)return;if(e.layers.test(t.layers)){if(e.isGroup)n=e.renderOrder;else if(e.isLOD)e.autoUpdate===!0&&e.update(t);else if(e.isLightProbeGrid)x.pushLightProbeGrid(e);else if(e.isLight)x.pushLight(e),e.castShadow&&x.pushShadow(e);else if(e.isSprite){if(!e.frustumCulled||Ce.intersectsSprite(e)){r&&je.setFromMatrixPosition(e.matrixWorld).applyMatrix4(Oe);let t=Ge.update(e),i=e.material;i.visible&&b.push(e,t,i,n,je.z,null)}}else if((e.isMesh||e.isLine||e.isPoints)&&(!e.frustumCulled||Ce.intersectsObject(e))){let t=Ge.update(e),i=e.material;if(r&&(e.boundingSphere===void 0?(t.boundingSphere===null&&t.computeBoundingSphere(),je.copy(t.boundingSphere.center)):(e.boundingSphere===null&&e.computeBoundingSphere(),je.copy(e.boundingSphere.center)),je.applyMatrix4(e.matrixWorld).applyMatrix4(Oe)),Array.isArray(i)){let r=t.groups;for(let a=0,o=r.length;a0&&Ct(i,t,n),a.length>0&&Ct(a,t,n),o.length>0&&Ct(o,t,n),Re.buffers.depth.setTest(!0),Re.buffers.depth.setMask(!0),Re.buffers.color.setMask(!0),Re.setPolygonOffset(!1)}function St(e,t,n,r){if((n.isScene===!0?n.overrideMaterial:null)!==null)return;if(x.state.transmissionRenderTarget[r.id]===void 0){let e=Ie.has(`EXT_color_buffer_half_float`)||Ie.has(`EXT_color_buffer_float`);x.state.transmissionRenderTarget[r.id]=new Wn(1,1,{generateMipmaps:!0,type:e?pe:oe,minFilter:ie,samples:Math.max(4,Le.samples),stencilBuffer:i,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:jn.workingColorSpace})}let a=x.state.transmissionRenderTarget[r.id],o=r.viewport||ne;a.setSize(o.z*T.transmissionResolutionScale,o.w*T.transmissionResolutionScale);let s=T.getRenderTarget(),c=T.getActiveCubeFace(),l=T.getActiveMipmapLevel();T.setRenderTarget(a),T.getClearColor(se),ce=T.getClearAlpha(),ce<1&&T.setClearColor(16777215,.5),T.clear(),Ne&&Qe.render(n);let u=T.toneMapping;T.toneMapping=0;let d=r.viewport;if(r.viewport!==void 0&&(r.viewport=void 0),x.setupLightsView(r),we===!0&&Xe.setGlobalState(T.clippingPlanes,r),Ct(e,n,r),Ve.updateMultisampleRenderTarget(a),Ve.updateRenderTargetMipmap(a),Ie.has(`WEBGL_multisampled_render_to_texture`)===!1){let e=!1;for(let i=0,a=t.length;i0,r.currentProgram=d,r.uniformsList=null,d}function Et(e){if(e.uniformsList===null){let t=e.currentProgram.getUniforms();e.uniformsList=nd.seqWithValue(t.seq,e.uniforms)}return e.uniformsList}function Dt(e,t){let n=Be.get(e);n.outputColorSpace=t.outputColorSpace,n.batching=t.batching,n.batchingColor=t.batchingColor,n.instancing=t.instancing,n.instancingColor=t.instancingColor,n.instancingMorph=t.instancingMorph,n.skinning=t.skinning,n.morphTargets=t.morphTargets,n.morphNormals=t.morphNormals,n.morphColors=t.morphColors,n.morphTargetsCount=t.morphTargetsCount,n.numClippingPlanes=t.numClippingPlanes,n.numIntersection=t.numClipIntersection,n.vertexAlphas=t.vertexAlphas,n.vertexTangents=t.vertexTangents,n.toneMapping=t.toneMapping}function Ot(e,t){if(e.length===0)return null;if(e.length===1)return e[0].texture===null?null:e[0];y.setFromMatrixPosition(t.matrixWorld);for(let t=0,n=e.length;t0),f=!!n.morphAttributes.position,p=!!n.morphAttributes.normal,m=!!n.morphAttributes.color,h=0;r.toneMapped&&(N===null||N.isXRRenderTarget===!0)&&(h=T.toneMapping);let g=n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color,_=g===void 0?0:g.length,v=Be.get(r),y=x.state.lights;if(we===!0&&(Ee===!0||e!==te)){let t=e===te&&r.id===ee;Xe.setState(r,e,t)}let b=!1;r.version===v.__version?v.needsLights&&v.lightsStateVersion!==y.state.version?b=!0:v.outputColorSpace===s?i.isBatchedMesh&&v.batching===!1||!i.isBatchedMesh&&v.batching===!0||i.isBatchedMesh&&v.batchingColor===!0&&i.colorTexture===null||i.isBatchedMesh&&v.batchingColor===!1&&i.colorTexture!==null||i.isInstancedMesh&&v.instancing===!1||!i.isInstancedMesh&&v.instancing===!0||i.isSkinnedMesh&&v.skinning===!1||!i.isSkinnedMesh&&v.skinning===!0||i.isInstancedMesh&&v.instancingColor===!0&&i.instanceColor===null||i.isInstancedMesh&&v.instancingColor===!1&&i.instanceColor!==null||i.isInstancedMesh&&v.instancingMorph===!0&&i.morphTexture===null||i.isInstancedMesh&&v.instancingMorph===!1&&i.morphTexture!==null?b=!0:v.envMap===l?r.fog===!0&&v.fog!==a||v.numClippingPlanes!==void 0&&(v.numClippingPlanes!==Xe.numPlanes||v.numIntersection!==Xe.numIntersection)?b=!0:v.vertexAlphas===u&&v.vertexTangents===d&&v.morphTargets===f&&v.morphNormals===p&&v.morphColors===m&&v.toneMapping===h&&v.morphTargetsCount===_?!!v.lightProbeGrid!=x.state.lightProbeGridArray.length>0&&(b=!0):b=!0:b=!0:b=!0:(b=!0,v.__version=r.version);let S=v.currentProgram;b===!0&&(S=Tt(r,t,i),D&&r.isNodeMaterial&&D.onUpdateProgram(r,S,v));let C=!1,w=!1,E=!1,O=S.getUniforms(),k=v.uniforms;if(Re.useProgram(S.program)&&(C=!0,w=!0,E=!0),r.id!==ee&&(ee=r.id,w=!0),v.needsLights){let e=Ot(x.state.lightProbeGridArray,i);v.lightProbeGrid!==e&&(v.lightProbeGrid=e,w=!0)}if(C||te!==e){Re.buffers.depth.getReversed()&&e.reversedDepth!==!0&&(e._reversedDepth=!0,e.updateProjectionMatrix()),O.setValue(P,`projectionMatrix`,e.projectionMatrix),O.setValue(P,`viewMatrix`,e.matrixWorldInverse);let t=O.map.cameraPosition;t!==void 0&&t.setValue(P,Ae.setFromMatrixPosition(e.matrixWorld)),Le.logarithmicDepthBuffer&&O.setValue(P,`logDepthBufFC`,2/(Math.log(e.far+1)/Math.LN2)),(r.isMeshPhongMaterial||r.isMeshToonMaterial||r.isMeshLambertMaterial||r.isMeshBasicMaterial||r.isMeshStandardMaterial||r.isShaderMaterial)&&O.setValue(P,`isOrthographic`,e.isOrthographicCamera===!0),te!==e&&(te=e,w=!0,E=!0)}if(v.needsLights&&(y.state.directionalShadowMap.length>0&&O.setValue(P,`directionalShadowMap`,y.state.directionalShadowMap,Ve),y.state.spotShadowMap.length>0&&O.setValue(P,`spotShadowMap`,y.state.spotShadowMap,Ve),y.state.pointShadowMap.length>0&&O.setValue(P,`pointShadowMap`,y.state.pointShadowMap,Ve)),i.isSkinnedMesh){O.setOptional(P,i,`bindMatrix`),O.setOptional(P,i,`bindMatrixInverse`);let e=i.skeleton;e&&(e.boneTexture===null&&e.computeBoneTexture(),O.setValue(P,`boneTexture`,e.boneTexture,Ve))}i.isBatchedMesh&&(O.setOptional(P,i,`batchingTexture`),O.setValue(P,`batchingTexture`,i._matricesTexture,Ve),O.setOptional(P,i,`batchingIdTexture`),O.setValue(P,`batchingIdTexture`,i._indirectTexture,Ve),O.setOptional(P,i,`batchingColorTexture`),i._colorsTexture!==null&&O.setValue(P,`batchingColorTexture`,i._colorsTexture,Ve));let A=n.morphAttributes;if((A.position!==void 0||A.normal!==void 0||A.color!==void 0)&&$e.update(i,n,S),(w||v.receiveShadow!==i.receiveShadow)&&(v.receiveShadow=i.receiveShadow,O.setValue(P,`receiveShadow`,i.receiveShadow)),(r.isMeshStandardMaterial||r.isMeshLambertMaterial||r.isMeshPhongMaterial)&&r.envMap===null&&t.environment!==null&&(k.envMapIntensity.value=t.environmentIntensity),k.dfgLUT!==void 0&&(k.dfgLUT.value=gf()),w){if(O.setValue(P,`toneMappingExposure`,T.toneMappingExposure),v.needsLights&&At(k,E),a&&r.fog===!0&&qe.refreshFogUniforms(k,a),qe.refreshMaterialUniforms(k,r,_e,fe,x.state.transmissionRenderTarget[e.id]),v.needsLights&&v.lightProbeGrid){let e=v.lightProbeGrid;k.probesSH.value=e.texture,k.probesMin.value.copy(e.boundingBox.min),k.probesMax.value.copy(e.boundingBox.max),k.probesResolution.value.copy(e.resolution)}nd.upload(P,Et(v),k,Ve)}if(r.isShaderMaterial&&r.uniformsNeedUpdate===!0&&(nd.upload(P,Et(v),k,Ve),r.uniformsNeedUpdate=!1),r.isSpriteMaterial&&O.setValue(P,`center`,i.center),O.setValue(P,`modelViewMatrix`,i.modelViewMatrix),O.setValue(P,`normalMatrix`,i.normalMatrix),O.setValue(P,`modelMatrix`,i.matrixWorld),r.uniformsGroups!==void 0){let e=r.uniformsGroups;for(let t=0,n=e.length;t0&&Ve.useMultisampledRTT(e)===!1?Be.get(e).__webglMultisampledFramebuffer:Array.isArray(c)?c[n]:c,ne.copy(e.viewport),re.copy(e.scissor),ae=e.scissorTest}else ne.copy(be).multiplyScalar(_e).floor(),re.copy(xe).multiplyScalar(_e).floor(),ae=Se;if(n!==0&&(r=O),Re.bindFramebuffer(P.FRAMEBUFFER,r)&&Re.drawBuffers(e,r),Re.viewport(ne),Re.scissor(re),Re.setScissorTest(ae),i){let r=Be.get(e.texture);P.framebufferTexture2D(P.FRAMEBUFFER,P.COLOR_ATTACHMENT0,P.TEXTURE_CUBE_MAP_POSITIVE_X+t,r.__webglTexture,n)}else if(a){let r=t;for(let t=0;t1&&P.readBuffer(P.COLOR_ATTACHMENT0+s),!Le.textureFormatReadable(c)){I(`WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.`);return}if(!Le.textureTypeReadable(l)){I(`WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.`);return}t>=0&&t<=e.width-r&&n>=0&&n<=e.height-i&&P.readPixels(t,n,r,i,nt.convert(c),nt.convert(l),a)}finally{let e=N===null?null:Be.get(N).__webglFramebuffer;Re.bindFramebuffer(P.FRAMEBUFFER,e)}}},this.readRenderTargetPixelsAsync=async function(e,t,n,r,i,a,o,s=0){if(!(e&&e.isWebGLRenderTarget))throw Error(`THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.`);let c=Be.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&o!==void 0&&(c=c[o]),c)if(t>=0&&t<=e.width-r&&n>=0&&n<=e.height-i){Re.bindFramebuffer(P.FRAMEBUFFER,c);let o=e.textures[s],l=o.format,u=o.type;if(e.textures.length>1&&P.readBuffer(P.COLOR_ATTACHMENT0+s),!Le.textureFormatReadable(l))throw Error(`THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.`);if(!Le.textureTypeReadable(u))throw Error(`THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.`);let d=P.createBuffer();P.bindBuffer(P.PIXEL_PACK_BUFFER,d),P.bufferData(P.PIXEL_PACK_BUFFER,a.byteLength,P.STREAM_READ),P.readPixels(t,n,r,i,nt.convert(l),nt.convert(u),0);let f=N===null?null:Be.get(N).__webglFramebuffer;Re.bindFramebuffer(P.FRAMEBUFFER,f);let p=P.fenceSync(P.SYNC_GPU_COMMANDS_COMPLETE,0);return P.flush(),await Kt(P,p,4),P.bindBuffer(P.PIXEL_PACK_BUFFER,d),P.getBufferSubData(P.PIXEL_PACK_BUFFER,0,a),P.deleteBuffer(d),P.deleteSync(p),a}else throw Error(`THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.`)},this.copyFramebufferToTexture=function(e,t=null,n=0){let r=2**-n,i=Math.floor(e.image.width*r),a=Math.floor(e.image.height*r),o=t===null?0:t.x,s=t===null?0:t.y;Ve.setTexture2D(e,0),P.copyTexSubImage2D(P.TEXTURE_2D,n,0,0,o,s,i,a),Re.unbindTexture()},this.copyTextureToTexture=function(e,t,n=null,r=null,i=0,a=0){let o,s,c,l,u,d,f,p,m,h=e.isCompressedTexture?e.mipmaps[a]:e.image;if(n!==null)o=n.max.x-n.min.x,s=n.max.y-n.min.y,c=n.isBox3?n.max.z-n.min.z:1,l=n.min.x,u=n.min.y,d=n.isBox3?n.min.z:0;else{let t=2**-i;o=Math.floor(h.width*t),s=Math.floor(h.height*t),c=e.isDataArrayTexture?h.depth:e.isData3DTexture?Math.floor(h.depth*t):1,l=0,u=0,d=0}r===null?(f=0,p=0,m=0):(f=r.x,p=r.y,m=r.z);let g=nt.convert(t.format),_=nt.convert(t.type),v;t.isData3DTexture?(Ve.setTexture3D(t,0),v=P.TEXTURE_3D):t.isDataArrayTexture||t.isCompressedArrayTexture?(Ve.setTexture2DArray(t,0),v=P.TEXTURE_2D_ARRAY):(Ve.setTexture2D(t,0),v=P.TEXTURE_2D),Re.activeTexture(P.TEXTURE0),Re.pixelStorei(P.UNPACK_FLIP_Y_WEBGL,t.flipY),Re.pixelStorei(P.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),Re.pixelStorei(P.UNPACK_ALIGNMENT,t.unpackAlignment);let y=Re.getParameter(P.UNPACK_ROW_LENGTH),b=Re.getParameter(P.UNPACK_IMAGE_HEIGHT),x=Re.getParameter(P.UNPACK_SKIP_PIXELS),S=Re.getParameter(P.UNPACK_SKIP_ROWS),C=Re.getParameter(P.UNPACK_SKIP_IMAGES);Re.pixelStorei(P.UNPACK_ROW_LENGTH,h.width),Re.pixelStorei(P.UNPACK_IMAGE_HEIGHT,h.height),Re.pixelStorei(P.UNPACK_SKIP_PIXELS,l),Re.pixelStorei(P.UNPACK_SKIP_ROWS,u),Re.pixelStorei(P.UNPACK_SKIP_IMAGES,d);let w=e.isDataArrayTexture||e.isData3DTexture,T=t.isDataArrayTexture||t.isData3DTexture;if(e.isDepthTexture){let n=Be.get(e),r=Be.get(t),h=Be.get(n.__renderTarget),g=Be.get(r.__renderTarget);Re.bindFramebuffer(P.READ_FRAMEBUFFER,h.__webglFramebuffer),Re.bindFramebuffer(P.DRAW_FRAMEBUFFER,g.__webglFramebuffer);for(let n=0;n=-1&&yf.z<=1&&e.layers.test(r.layers)===!0,l=e.element;l.style.display=c===!0?``:`none`,c===!0&&(e.onBeforeRender(t,n,r),l.style.transform=`translate(`+-100*e.center.x+`%,`+-100*e.center.y+`%)translate(`+(yf.x*i+i)+`px,`+(-yf.y*a+a)+`px)`,l.parentNode!==s&&s.appendChild(l),e.onAfterRender(t,n,r));let d={distanceToCameraSquared:u(r,e)};o.objects.set(e,d)}for(let t=0,i=e.children.length;t=t||n<0||d&&r>=a}function _(){var e=Af();if(g(e))return v(e);s=setTimeout(_,h(e))}function v(e){return s=void 0,f&&r?p(e):(r=i=void 0,o)}function y(){s!==void 0&&clearTimeout(s),l=0,r=c=i=s=void 0}function b(){return s===void 0?o:v(Af())}function x(){var e=Af(),n=g(e);if(r=arguments,i=this,c=e,n){if(s===void 0)return m(c);if(d)return clearTimeout(s),s=setTimeout(_,t),p(c)}return s===void 0&&(s=setTimeout(_,t)),o}return x.cancel=y,x.flush=b,x}var mp=pp;function hp(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n1e4?1e4:e,{In:function(t){return t**+e},Out:function(t){return 1-(1-t)**e},InOut:function(t){return t<.5?(t*2)**e/2:(1-(2-t*2)**e)/2+.5}}}}),Ep=function(){return performance.now()},Dp=function(){function e(){var e=[...arguments];this._tweens={},this._tweensAddedDuringUpdate={},this.add.apply(this,e)}return e.prototype.getAll=function(){var e=this;return Object.keys(this._tweens).map(function(t){return e._tweens[t]})},e.prototype.removeAll=function(){this._tweens={}},e.prototype.add=function(){for(var e,t=[],n=0;n0;){this._tweensAddedDuringUpdate={};for(var r=0;r1?a(e[n],e[n-1],n-r):a(e[i],e[i+1>n?n:i+1],r-i)},Bezier:function(e,t){for(var n=0,r=e.length-1,i=Math.pow,a=Op.Utils.Bernstein,o=0;o<=r;o++)n+=i(1-t,r-o)*i(t,o)*e[o]*a(r,o);return n},CatmullRom:function(e,t){var n=e.length-1,r=n*t,i=Math.floor(r),a=Op.Utils.CatmullRom;return e[0]===e[n]?(t<0&&(i=Math.floor(r=n*(1+t))),a(e[(i-1+n)%n],e[i],e[(i+1)%n],e[(i+2)%n],r-i)):t<0?e[0]-(a(e[0],e[0],e[1],e[1],-r)-e[0]):t>1?e[n]-(a(e[n],e[n],e[n-1],e[n-1],r-n)-e[n]):a(e[i?i-1:0],e[i],e[n1;r--)n*=r;return e[t]=n,n}})(),CatmullRom:function(e,t,n,r,i){var a=(n-e)*.5,o=(r-t)*.5,s=i*i,c=i*s;return(2*t-2*n+a+o)*c+(-3*t+3*n-2*a-o)*s+a*i+t}}},kp=function(){function e(){}return e.nextId=function(){return e._nextId++},e._nextId=0,e}(),Ap=new Dp,jp=function(){function e(e,t){this._isPaused=!1,this._pauseStart=0,this._valuesStart={},this._valuesEnd={},this._valuesStartRepeat={},this._duration=1e3,this._isDynamic=!1,this._initialRepeat=0,this._repeat=0,this._yoyo=!1,this._isPlaying=!1,this._reversed=!1,this._delayTime=0,this._startTime=0,this._easingFunction=Tp.Linear.None,this._interpolationFunction=Op.Linear,this._chainedTweens=[],this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._id=kp.nextId(),this._isChainStopped=!1,this._propertiesAreSetUp=!1,this._goToEnd=!1,this._object=e,typeof t==`object`?(this._group=t,t.add(this)):t===!0&&(this._group=Ap,Ap.add(this))}return e.prototype.getId=function(){return this._id},e.prototype.isPlaying=function(){return this._isPlaying},e.prototype.isPaused=function(){return this._isPaused},e.prototype.getDuration=function(){return this._duration},e.prototype.to=function(e,t){if(t===void 0&&(t=1e3),this._isPlaying)throw Error(`Can not call Tween.to() while Tween is already started or paused. Stop the Tween first.`);return this._valuesEnd=e,this._propertiesAreSetUp=!1,this._duration=t<0?0:t,this},e.prototype.duration=function(e){return e===void 0&&(e=1e3),this._duration=e<0?0:e,this},e.prototype.dynamic=function(e){return e===void 0&&(e=!1),this._isDynamic=e,this},e.prototype.start=function(e,t){if(e===void 0&&(e=Ep()),t===void 0&&(t=!1),this._isPlaying)return this;if(this._repeat=this._initialRepeat,this._reversed)for(var n in this._reversed=!1,this._valuesStartRepeat)this._swapEndStartRepeatValues(n),this._valuesStart[n]=this._valuesStartRepeat[n];if(this._isPlaying=!0,this._isPaused=!1,this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._isChainStopped=!1,this._startTime=e,this._startTime+=this._delayTime,!this._propertiesAreSetUp||t){if(this._propertiesAreSetUp=!0,!this._isDynamic){var r={};for(var i in this._valuesEnd)r[i]=this._valuesEnd[i];this._valuesEnd=r}this._setupProperties(this._object,this._valuesStart,this._valuesEnd,this._valuesStartRepeat,t)}return this},e.prototype.startFromCurrentValues=function(e){return this.start(e,!0)},e.prototype._setupProperties=function(e,t,n,r,i){for(var a in n){var o=e[a],s=Array.isArray(o),c=s?`array`:typeof o,l=!s&&Array.isArray(n[a]);if(!(c===`undefined`||c===`function`)){if(l){var u=n[a];if(u.length===0)continue;for(var d=[o],f=0,p=u.length;fs)return 1;var e=a-Math.trunc(a/o)*o,t=Math.min(e/r._duration,1);return t===0&&a===r._duration?1:t}(),l=this._easingFunction(c);if(this._updateProperties(this._object,this._valuesStart,this._valuesEnd,l),this._onUpdateCallback&&this._onUpdateCallback(this._object,c),this._duration===0||a>=this._duration)if(this._repeat>0){var u=Math.min(Math.trunc((a-this._duration)/o)+1,this._repeat);for(i in isFinite(this._repeat)&&(this._repeat-=u),this._valuesStartRepeat)!this._yoyo&&typeof this._valuesEnd[i]==`string`&&(this._valuesStartRepeat[i]=this._valuesStartRepeat[i]+parseFloat(this._valuesEnd[i])),this._yoyo&&this._swapEndStartRepeatValues(i),this._valuesStart[i]=this._valuesStartRepeat[i];return this._yoyo&&(this._reversed=!this._reversed),this._startTime+=o*u,this._onRepeatCallback&&this._onRepeatCallback(this._object),this._onEveryStartCallbackFired=!1,!0}else{this._onCompleteCallback&&this._onCompleteCallback(this._object);for(var d=0,f=this._chainedTweens.length;d=(m=(c+d)/2))?c=m:d=m,(x=n>=(h=(l+f)/2))?l=h:f=h,(S=r>=(g=(u+p)/2))?u=g:p=g,a=o,!(o=o[C=S<<2|x<<1|b]))return a[C]=s,e;if(_=+e._x.call(null,o.data),v=+e._y.call(null,o.data),y=+e._z.call(null,o.data),t===_&&n===v&&r===y)return s.next=o,a?a[C]=s:e._root=s,e;do a=a?a[C]=Array(8):e._root=Array(8),(b=t>=(m=(c+d)/2))?c=m:d=m,(x=n>=(h=(l+f)/2))?l=h:f=h,(S=r>=(g=(u+p)/2))?u=g:p=g;while((C=S<<2|x<<1|b)==(w=(y>=g)<<2|(v>=h)<<1|_>=m));return a[w]=o,a[C]=s,e}function Fp(e){Array.isArray(e)||(e=Array.from(e));let t=e.length,n=new Float64Array(t),r=new Float64Array(t),i=new Float64Array(t),a=1/0,o=1/0,s=1/0,c=-1/0,l=-1/0,u=-1/0;for(let d=0,f,p,m,h;dc&&(c=p),ml&&(l=m),hu&&(u=h));if(a>c||o>l||s>u)return this;this.cover(a,o,s).cover(c,l,u);for(let a=0;ae||e>=o||i>t||t>=s||a>n||n>=c;)switch(f=(nm||(l=y.y0)>h||(u=y.z0)>g||(d=y.x1)=C)<<2|(t>=S)<<1|e>=x)&&(y=_[_.length-1],_[_.length-1]=_[_.length-1-b],_[_.length-1-b]=y)}else{var w=e-+this._x.call(null,v.data),T=t-+this._y.call(null,v.data),E=n-+this._z.call(null,v.data),D=w*w+T*T+E*E;if(DMath.sqrt((e-r)**2+(t-i)**2+(n-a)**2);function Hp(e,t,n,r){let i=[],a=e-r,o=t-r,s=n-r,c=e+r,l=t+r,u=n+r;return this.visit((d,f,p,m,h,g,_)=>{if(!d.length)do{let a=d.data;Vp(e,t,n,this._x(a),this._y(a),this._z(a))<=r&&i.push(a)}while(d=d.next);return f>c||p>l||m>u||h=(h=(o+l)/2))?o=h:l=h,(y=p>=(g=(s+u)/2))?s=g:u=g,(b=m>=(_=(c+d)/2))?c=_:d=_,t=n,!(n=n[x=b<<2|y<<1|v]))return this;if(!n.length)break;(t[x+1&7]||t[x+2&7]||t[x+3&7]||t[x+4&7]||t[x+5&7]||t[x+6&7]||t[x+7&7])&&(r=t,S=x)}for(;n.data!==e;)if(i=n,!(n=n.next))return this;return(a=n.next)&&delete n.next,i?(a?i.next=a:delete i.next,this):t?(a?t[x]=a:delete t[x],(n=t[0]||t[1]||t[2]||t[3]||t[4]||t[5]||t[6]||t[7])&&n===(t[7]||t[6]||t[5]||t[4]||t[3]||t[2]||t[1]||t[0])&&!n.length&&(r?r[S]=n:this._root=n),this):(this._root=a,this)}function Wp(e){for(var t=0,n=e.length;tt?1:e>=t?0:NaN}function om(e,t){return e==null||t==null?NaN:te?1:t>=e?0:NaN}function sm(e){let t,n,r;e.length===2?(t=e===am||e===om?e:cm,n=e,r=e):(t=am,n=(t,n)=>am(e(t),n),r=(t,n)=>e(t)-n);function i(e,r,i=0,a=e.length){if(i>>1;n(e[t],r)<0?i=t+1:a=t}while(i>>1;n(e[t],r)<=0?i=t+1:a=t}while(in&&r(e[o-1],t)>-r(e[o],t)?o-1:o}return{left:i,center:o,right:a}}function cm(){return 0}function lm(e){return e===null?NaN:+e}var um=sm(am);const dm=um.right;um.left,sm(lm).center;var fm=dm;function pm(e,t){let n,r;if(t===void 0)for(let t of e)t!=null&&(n===void 0?t>=t&&(n=r=t):(n>t&&(n=t),r=a&&(n=r=a):(n>a&&(n=a),r0){for(a=e[--t];t>0&&(n=a,r=e[--t],a=n+r,i=r-(a-n),!i););t>0&&(i<0&&e[t-1]<0||i>0&&e[t-1]>0)&&(r=i*2,n=a+r,r==n-a&&(a=n))}return a}},hm=Math.sqrt(50),gm=Math.sqrt(10),_m=Math.sqrt(2);function vm(e,t,n){let r=(t-e)/Math.max(0,n),i=Math.floor(Math.log10(r)),a=r/10**i,o=a>=hm?10:a>=gm?5:a>=_m?2:1,s,c,l;return i<0?(l=10**-i/o,s=Math.round(e*l),c=Math.round(t*l),s/lt&&--c,l=-l):(l=10**i*o,s=Math.round(e/l),c=Math.round(t/l),s*lt&&--c),c0))return[];if(e===t)return[e];let r=t=i))return[];let s=a-i+1,c=Array(s);if(r)if(o<0)for(let e=0;e=t)&&(n=t);else{let r=-1;for(let i of e)(i=t(i,++r,e))!=null&&(n=i)&&(n=i)}return n}function Cm(e,t){let n=0,r=0;if(t===void 0)for(let t of e)t!=null&&(t=+t)>=t&&(++n,r+=t);else{let i=-1;for(let a of e)(a=t(a,++i,e))!=null&&(a=+a)>=a&&(++n,r+=a)}if(n)return r/n}function*wm(e){for(let t of e)yield*t}function Tm(e){return Array.from(wm(e))}function Em(e,t,n){e=+e,t=+t,n=(i=arguments.length)<2?(t=e,e=0,1):i<3?1:+n;for(var r=-1,i=Math.max(0,Math.ceil((t-e)/n))|0,a=Array(i);++r>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?Zm(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?Zm(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=Rm.exec(e))?new eh(t[1],t[2],t[3],1):(t=zm.exec(e))?new eh(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=Bm.exec(e))?Zm(t[1],t[2],t[3],t[4]):(t=Vm.exec(e))?Zm(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=Hm.exec(e))?sh(t[1],t[2]/100,t[3]/100,1):(t=Um.exec(e))?sh(t[1],t[2]/100,t[3]/100,t[4]):Wm.hasOwnProperty(e)?Xm(Wm[e]):e===`transparent`?new eh(NaN,NaN,NaN,0):null}function Xm(e){return new eh(e>>16&255,e>>8&255,e&255,1)}function Zm(e,t,n,r){return r<=0&&(e=t=n=NaN),new eh(e,t,n,r)}function Qm(e){return e instanceof jm||(e=Ym(e)),e?(e=e.rgb(),new eh(e.r,e.g,e.b,e.opacity)):new eh}function $m(e,t,n,r){return arguments.length===1?Qm(e):new eh(e,t,n,r??1)}function eh(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}km(eh,$m,Am(jm,{brighter(e){return e=e==null?Nm:Nm**+e,new eh(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Mm:Mm**+e,new eh(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new eh(ah(this.r),ah(this.g),ah(this.b),ih(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:th,formatHex:th,formatHex8:nh,formatRgb:rh,toString:rh}));function th(){return`#${oh(this.r)}${oh(this.g)}${oh(this.b)}`}function nh(){return`#${oh(this.r)}${oh(this.g)}${oh(this.b)}${oh((isNaN(this.opacity)?1:this.opacity)*255)}`}function rh(){let e=ih(this.opacity);return`${e===1?`rgb(`:`rgba(`}${ah(this.r)}, ${ah(this.g)}, ${ah(this.b)}${e===1?`)`:`, ${e})`}`}function ih(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function ah(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function oh(e){return e=ah(e),(e<16?`0`:``)+e.toString(16)}function sh(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new uh(e,t,n,r)}function ch(e){if(e instanceof uh)return new uh(e.h,e.s,e.l,e.opacity);if(e instanceof jm||(e=Ym(e)),!e)return new uh;if(e instanceof uh)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,i=Math.min(t,n,r),a=Math.max(t,n,r),o=NaN,s=a-i,c=(a+i)/2;return s?(o=t===a?(n-r)/s+(n0&&c<1?0:o,new uh(o,s,c,e.opacity)}function lh(e,t,n,r){return arguments.length===1?ch(e):new uh(e,t,n,r??1)}function uh(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}km(uh,lh,Am(jm,{brighter(e){return e=e==null?Nm:Nm**+e,new uh(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Mm:Mm**+e,new uh(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,i=2*n-r;return new eh(ph(e>=240?e-240:e+120,i,r),ph(e,i,r),ph(e<120?e+240:e-120,i,r),this.opacity)},clamp(){return new uh(dh(this.h),fh(this.s),fh(this.l),ih(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){let e=ih(this.opacity);return`${e===1?`hsl(`:`hsla(`}${dh(this.h)}, ${fh(this.s)*100}%, ${fh(this.l)*100}%${e===1?`)`:`, ${e})`}`}}));function dh(e){return e=(e||0)%360,e<0?e+360:e}function fh(e){return Math.max(0,Math.min(1,e||0))}function ph(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}var mh=e=>()=>e;function hh(e,t){return function(n){return e+n*t}}function gh(e,t,n){return e**=+n,t=t**+n-e,n=1/n,function(r){return(e+r*t)**+n}}function _h(e){return(e=+e)==1?vh:function(t,n){return n-t?gh(t,n,e):mh(isNaN(t)?n:t)}}function vh(e,t){var n=t-e;return n?hh(e,n):mh(isNaN(e)?t:e)}var yh=(function e(t){var n=_h(t);function r(e,t){var r=n((e=$m(e)).r,(t=$m(t)).r),i=n(e.g,t.g),a=n(e.b,t.b),o=vh(e.opacity,t.opacity);return function(t){return e.r=r(t),e.g=i(t),e.b=a(t),e.opacity=o(t),e+``}}return r.gamma=e,r})(1);function bh(e,t){t||=[];var n=e?Math.min(t.length,e.length):0,r=t.slice(),i;return function(a){for(i=0;in&&(a=t.slice(n,a),s[o]?s[o]+=a:s[++o]=a),(r=r[0])===(i=i[0])?s[o]?s[o]+=i:s[++o]=i:(s[++o]=null,c.push({i:o,x:Th(r,i)})),n=Oh.lastIndex;return nt&&(n=e,e=t,t=n),function(n){return Math.max(e,Math.min(t,n))}}function Bh(e,t,n){var r=e[0],i=e[1],a=t[0],o=t[1];return i2?Vh:Bh,c=l=null,d}function d(i){return i==null||isNaN(i=+i)?a:(c||=s(e.map(r),t,n))(r(o(i)))}return d.invert=function(n){return o(i((l||=s(t,e.map(r),Th))(n)))},d.domain=function(t){return arguments.length?(e=Array.from(t,Fh),u()):e.slice()},d.range=function(e){return arguments.length?(t=Array.from(e),u()):t.slice()},d.rangeRound=function(e){return t=Array.from(e),n=Nh,u()},d.clamp=function(e){return arguments.length?(o=e?!0:Lh,u()):o!==Lh},d.interpolate=function(e){return arguments.length?(n=e,u()):n},d.unknown=function(e){return arguments.length?(a=e,d):a},function(e,t){return r=e,i=t,u()}}function Wh(){return Uh()(Lh,Lh)}function Gh(e){return Math.abs(e=Math.round(e))>=1e21?e.toLocaleString(`en`).replace(/,/g,``):e.toString(10)}function Kh(e,t){if(!isFinite(e)||e===0)return null;var n=(e=t?e.toExponential(t-1):e.toExponential()).indexOf(`e`),r=e.slice(0,n);return[r.length>1?r[0]+r.slice(2):r,+e.slice(n+1)]}function qh(e){return e=Kh(Math.abs(e)),e?e[1]:NaN}function Jh(e,t){return function(n,r){for(var i=n.length,a=[],o=0,s=e[0],c=0;i>0&&s>0&&(c+s+1>r&&(s=Math.max(1,r-c)),a.push(n.substring(i-=s,i+s)),!((c+=s+1)>r));)s=e[o=(o+1)%e.length];return a.reverse().join(t)}}function Yh(e){return function(t){return t.replace(/[0-9]/g,function(t){return e[+t]})}}var Xh=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function Zh(e){if(!(t=Xh.exec(e)))throw Error(`invalid format: `+e);var t;return new Qh({fill:t[1],align:t[2],sign:t[3],symbol:t[4],zero:t[5],width:t[6],comma:t[7],precision:t[8]&&t[8].slice(1),trim:t[9],type:t[10]})}Zh.prototype=Qh.prototype;function Qh(e){this.fill=e.fill===void 0?` `:e.fill+``,this.align=e.align===void 0?`>`:e.align+``,this.sign=e.sign===void 0?`-`:e.sign+``,this.symbol=e.symbol===void 0?``:e.symbol+``,this.zero=!!e.zero,this.width=e.width===void 0?void 0:+e.width,this.comma=!!e.comma,this.precision=e.precision===void 0?void 0:+e.precision,this.trim=!!e.trim,this.type=e.type===void 0?``:e.type+``}Qh.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?`0`:``)+(this.width===void 0?``:Math.max(1,this.width|0))+(this.comma?`,`:``)+(this.precision===void 0?``:`.`+Math.max(0,this.precision|0))+(this.trim?`~`:``)+this.type};function $h(e){out:for(var t=e.length,n=1,r=-1,i;n0&&(r=0);break}return r>0?e.slice(0,r)+e.slice(i+1):e}var eg;function tg(e,t){var n=Kh(e,t);if(!n)return eg=void 0,e.toPrecision(t);var r=n[0],i=n[1],a=i-(eg=Math.max(-8,Math.min(8,Math.floor(i/3)))*3)+1,o=r.length;return a===o?r:a>o?r+Array(a-o+1).join(`0`):a>0?r.slice(0,a)+`.`+r.slice(a):`0.`+Array(1-a).join(`0`)+Kh(e,Math.max(0,t+a-1))[0]}function ng(e,t){var n=Kh(e,t);if(!n)return e+``;var r=n[0],i=n[1];return i<0?`0.`+Array(-i).join(`0`)+r:r.length>i+1?r.slice(0,i+1)+`.`+r.slice(i+1):r+Array(i-r.length+2).join(`0`)}var rg={"%":(e,t)=>(e*100).toFixed(t),b:e=>Math.round(e).toString(2),c:e=>e+``,d:Gh,e:(e,t)=>e.toExponential(t),f:(e,t)=>e.toFixed(t),g:(e,t)=>e.toPrecision(t),o:e=>Math.round(e).toString(8),p:(e,t)=>ng(e*100,t),r:ng,s:tg,X:e=>Math.round(e).toString(16).toUpperCase(),x:e=>Math.round(e).toString(16)};function ig(e){return e}var ag=Array.prototype.map,og=[`y`,`z`,`a`,`f`,`p`,`n`,`µ`,`m`,``,`k`,`M`,`G`,`T`,`P`,`E`,`Z`,`Y`];function sg(e){var t=e.grouping===void 0||e.thousands===void 0?ig:Jh(ag.call(e.grouping,Number),e.thousands+``),n=e.currency===void 0?``:e.currency[0]+``,r=e.currency===void 0?``:e.currency[1]+``,i=e.decimal===void 0?`.`:e.decimal+``,a=e.numerals===void 0?ig:Yh(ag.call(e.numerals,String)),o=e.percent===void 0?`%`:e.percent+``,s=e.minus===void 0?`−`:e.minus+``,c=e.nan===void 0?`NaN`:e.nan+``;function l(e,l){e=Zh(e);var u=e.fill,d=e.align,f=e.sign,p=e.symbol,m=e.zero,h=e.width,g=e.comma,_=e.precision,v=e.trim,y=e.type;y===`n`?(g=!0,y=`g`):rg[y]||(_===void 0&&(_=12),v=!0,y=`g`),(m||u===`0`&&d===`=`)&&(m=!0,u=`0`,d=`=`);var b=(l&&l.prefix!==void 0?l.prefix:``)+(p===`$`?n:p===`#`&&/[boxX]/.test(y)?`0`+y.toLowerCase():``),x=(p===`$`?r:/[%p]/.test(y)?o:``)+(l&&l.suffix!==void 0?l.suffix:``),S=rg[y],C=/[defgprs%]/.test(y);_=_===void 0?6:/[gprs]/.test(y)?Math.max(1,Math.min(21,_)):Math.max(0,Math.min(20,_));function w(e){var n=b,r=x,o,l,p;if(y===`c`)r=S(e)+r,e=``;else{e=+e;var w=e<0||1/e<0;if(e=isNaN(e)?c:S(Math.abs(e),_),v&&(e=$h(e)),w&&+e==0&&f!==`+`&&(w=!1),n=(w?f===`(`?f:s:f===`-`||f===`(`?``:f)+n,r=(y===`s`&&!isNaN(e)&&eg!==void 0?og[8+eg/3]:``)+r+(w&&f===`(`?`)`:``),C){for(o=-1,l=e.length;++op||p>57){r=(p===46?i+e.slice(o+1):e.slice(o))+r,e=e.slice(0,o);break}}}g&&!m&&(e=t(e,1/0));var T=n.length+e.length+r.length,E=T>1)+n+e+r+E.slice(T);break;default:e=E+n+e+r;break}return a(e)}return w.toString=function(){return e+``},w}function u(e,t){var n=Math.max(-8,Math.min(8,Math.floor(qh(t)/3)))*3,r=10**-n,i=l((e=Zh(e),e.type=`f`,e),{suffix:og[8+n/3]});return function(e){return i(r*e)}}return{format:l,formatPrefix:u}}var cg,lg,ug;dg({thousands:`,`,grouping:[3],currency:[`$`,``]});function dg(e){return cg=sg(e),lg=cg.format,ug=cg.formatPrefix,cg}function fg(e){return Math.max(0,-qh(Math.abs(e)))}function pg(e,t){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(qh(t)/3)))*3-qh(Math.abs(e)))}function mg(e,t){return e=Math.abs(e),t=Math.abs(t)-e,Math.max(0,qh(t)-qh(e))+1}function hg(e,t,n,r){var i=xm(e,t,n),a;switch(r=Zh(r??`,f`),r.type){case`s`:var o=Math.max(Math.abs(e),Math.abs(t));return r.precision==null&&!isNaN(a=pg(i,o))&&(r.precision=a),ug(r,o);case``:case`e`:case`g`:case`p`:case`r`:r.precision==null&&!isNaN(a=mg(i,Math.max(Math.abs(e),Math.abs(t))))&&(r.precision=a-(r.type===`e`));break;case`f`:case`%`:r.precision==null&&!isNaN(a=fg(i))&&(r.precision=a-(r.type===`%`)*2);break}return lg(r)}function gg(e){var t=e.domain;return e.ticks=function(e){var n=t();return ym(n[0],n[n.length-1],e??10)},e.tickFormat=function(e,n){var r=t();return hg(r[0],r[r.length-1],e??10,n)},e.nice=function(n){n??=10;var r=t(),i=0,a=r.length-1,o=r[i],s=r[a],c,l,u=10;for(s0;){if(l=bm(o,s,n),l===c)return r[i]=o,r[a]=s,t(r);if(l>0)o=Math.floor(o/l)*l,s=Math.ceil(s/l)*l;else if(l<0)o=Math.ceil(o*l)/l,s=Math.floor(s*l)/l;else break;c=l}return e},e}function _g(){var e=Wh();return e.copy=function(){return Hh(e,_g())},Om.apply(e,arguments),gg(e)}function vg(){var e=0,t=1,n=1,r=[.5],i=[0,1],a;function o(e){return e!=null&&e<=e?i[fm(r,e,0,n)]:a}function s(){var i=-1;for(r=Array(n);++i=n?[r[n-1],t]:[r[o-1],r[o]]},o.unknown=function(e){return arguments.length&&(a=e),o},o.thresholds=function(){return r.slice()},o.copy=function(){return vg().domain([e,t]).range(i).unknown(a)},Om.apply(gg(o),arguments)}var yg=1e-6,bg=Math.PI,xg=bg/2,Sg=bg/4,Cg=bg*2,wg=180/bg,Tg=bg/180,Eg=Math.abs,Dg=Math.atan,Og=Math.atan2,kg=Math.cos,Ag=Math.ceil,jg=Math.exp,Mg=Math.hypot,Ng=Math.log,Pg=Math.sin,Fg=Math.sign||function(e){return e>0?1:e<0?-1:0},Ig=Math.sqrt,Lg=Math.tan;function Rg(e){return e>1?0:e<-1?bg:Math.acos(e)}function zg(e){return e>1?xg:e<-1?-xg:Math.asin(e)}function Bg(e){return(e=Pg(e/2))*e}function Vg(){}function Hg(e,t){e&&Wg.hasOwnProperty(e.type)&&Wg[e.type](e,t)}var Ug={Feature:function(e,t){Hg(e.geometry,t)},FeatureCollection:function(e,t){for(var n=e.features,r=-1,i=n.length;++r=0?1:-1,i=r*n,a=kg(t),o=Pg(t),s=e_*o,c=$g*a+s*kg(i),l=s*r*Pg(i);Jg.add(Og(l,c)),Qg=e,$g=a,e_=o}function o_(e){return[Og(e[1],e[0]),zg(e[2])]}function s_(e){var t=e[0],n=e[1],r=kg(n);return[r*kg(t),r*Pg(t),Pg(n)]}function c_(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function l_(e,t){return[e[1]*t[2]-e[2]*t[1],e[2]*t[0]-e[0]*t[2],e[0]*t[1]-e[1]*t[0]]}function u_(e,t){e[0]+=t[0],e[1]+=t[1],e[2]+=t[2]}function d_(e,t){return[e[0]*t,e[1]*t,e[2]*t]}function f_(e){var t=Ig(e[0]*e[0]+e[1]*e[1]+e[2]*e[2]);e[0]/=t,e[1]/=t,e[2]/=t}var p_,m_,h_,g_,__,v_,y_,b_,x_,S_,C_,w_={point:T_,lineStart:D_,lineEnd:O_,polygonStart:function(){w_.point=k_,w_.lineStart=A_,w_.lineEnd=j_,x_=new mm,t_.polygonStart()},polygonEnd:function(){t_.polygonEnd(),w_.point=T_,w_.lineStart=D_,w_.lineEnd=O_,Jg<0?(p_=-(h_=180),m_=-(g_=90)):x_>1e-6?g_=90:x_<-1e-6&&(m_=-90),C_[0]=p_,C_[1]=h_},sphere:function(){p_=-(h_=180),m_=-(g_=90)}};function T_(e,t){S_.push(C_=[p_=e,h_=e]),tg_&&(g_=t)}function E_(e,t){var n=s_([e*Tg,t*Tg]);if(b_){var r=l_(b_,n),i=l_([r[1],-r[0],0],r);f_(i),i=o_(i);var a=e-__,o=a>0?1:-1,s=i[0]*wg*o,c,l=Eg(a)>180;l^(o*__g_&&(g_=c)):(s=(s+360)%360-180,l^(o*__g_&&(g_=t))),l?e<__?M_(p_,e)>M_(p_,h_)&&(h_=e):M_(e,h_)>M_(p_,h_)&&(p_=e):h_>=p_?(eh_&&(h_=e)):e>__?M_(p_,e)>M_(p_,h_)&&(h_=e):M_(e,h_)>M_(p_,h_)&&(p_=e)}else S_.push(C_=[p_=e,h_=e]);tg_&&(g_=t),b_=n,__=e}function D_(){w_.point=E_}function O_(){C_[0]=p_,C_[1]=h_,w_.point=T_,b_=null}function k_(e,t){if(b_){var n=e-__;x_.add(Eg(n)>180?n+(n>0?360:-360):n)}else v_=e,y_=t;t_.point(e,t),E_(e,t)}function A_(){t_.lineStart()}function j_(){k_(v_,y_),t_.lineEnd(),Eg(x_)>1e-6&&(p_=-(h_=180)),C_[0]=p_,C_[1]=h_,b_=null}function M_(e,t){return(t-=e)<0?t+360:t}function N_(e,t){return e[0]-t[0]}function P_(e,t){return e[0]<=e[1]?e[0]<=t&&t<=e[1]:tM_(r[0],r[1])&&(r[1]=i[1]),M_(i[0],r[1])>M_(r[0],r[1])&&(r[0]=i[0])):a.push(r=i);for(o=-1/0,n=a.length-1,t=0,r=a[n];t<=n;r=i,++t)i=a[t],(s=M_(r[1],i[0]))>o&&(o=s,p_=i[0],h_=r[1])}return S_=C_=null,p_===1/0||m_===1/0?[[NaN,NaN],[NaN,NaN]]:[[p_,m_],[h_,g_]]}var I_,L_,R_,z_,B_,V_,H_,U_,W_,G_,K_,q_,J_,Y_,X_,Z_,Q_={sphere:Vg,point:$_,lineStart:tv,lineEnd:iv,polygonStart:function(){Q_.lineStart=av,Q_.lineEnd=ov},polygonEnd:function(){Q_.lineStart=tv,Q_.lineEnd=iv}};function $_(e,t){e*=Tg,t*=Tg;var n=kg(t);ev(n*kg(e),n*Pg(e),Pg(t))}function ev(e,t,n){++I_,R_+=(e-R_)/I_,z_+=(t-z_)/I_,B_+=(n-B_)/I_}function tv(){Q_.point=nv}function nv(e,t){e*=Tg,t*=Tg;var n=kg(t);Y_=n*kg(e),X_=n*Pg(e),Z_=Pg(t),Q_.point=rv,ev(Y_,X_,Z_)}function rv(e,t){e*=Tg,t*=Tg;var n=kg(t),r=n*kg(e),i=n*Pg(e),a=Pg(t),o=Og(Ig((o=X_*a-Z_*i)*o+(o=Z_*r-Y_*a)*o+(o=Y_*i-X_*r)*o),Y_*r+X_*i+Z_*a);L_+=o,V_+=o*(Y_+(Y_=r)),H_+=o*(X_+(X_=i)),U_+=o*(Z_+(Z_=a)),ev(Y_,X_,Z_)}function iv(){Q_.point=$_}function av(){Q_.point=sv}function ov(){cv(q_,J_),Q_.point=$_}function sv(e,t){q_=e,J_=t,e*=Tg,t*=Tg,Q_.point=cv;var n=kg(t);Y_=n*kg(e),X_=n*Pg(e),Z_=Pg(t),ev(Y_,X_,Z_)}function cv(e,t){e*=Tg,t*=Tg;var n=kg(t),r=n*kg(e),i=n*Pg(e),a=Pg(t),o=X_*a-Z_*i,s=Z_*r-Y_*a,c=Y_*i-X_*r,l=Mg(o,s,c),u=zg(l),d=l&&-u/l;W_.add(d*o),G_.add(d*s),K_.add(d*c),L_+=u,V_+=u*(Y_+(Y_=r)),H_+=u*(X_+(X_=i)),U_+=u*(Z_+(Z_=a)),ev(Y_,X_,Z_)}function lv(e){I_=L_=R_=z_=B_=V_=H_=U_=0,W_=new mm,G_=new mm,K_=new mm,qg(e,Q_);var t=+W_,n=+G_,r=+K_,i=Mg(t,n,r);return i<1e-12&&(t=V_,n=H_,r=U_,L_<1e-6&&(t=R_,n=z_,r=B_),i=Mg(t,n,r),i<1e-12)?[NaN,NaN]:[Og(n,t)*wg,zg(r/i)*wg]}function uv(e,t){function n(n,r){return n=e(n,r),t(n[0],n[1])}return e.invert&&t.invert&&(n.invert=function(n,r){return n=t.invert(n,r),n&&e.invert(n[0],n[1])}),n}function dv(e,t){return Eg(e)>bg&&(e-=Math.round(e/Cg)*Cg),[e,t]}dv.invert=dv;function fv(e,t,n){return(e%=Cg)?t||n?uv(mv(e),hv(t,n)):mv(e):t||n?hv(t,n):dv}function pv(e){return function(t,n){return t+=e,Eg(t)>bg&&(t-=Math.round(t/Cg)*Cg),[t,n]}}function mv(e){var t=pv(e);return t.invert=pv(-e),t}function hv(e,t){var n=kg(e),r=Pg(e),i=kg(t),a=Pg(t);function o(e,t){var o=kg(t),s=kg(e)*o,c=Pg(e)*o,l=Pg(t),u=l*n+s*r;return[Og(c*i-u*a,s*n-l*r),zg(u*i+c*a)]}return o.invert=function(e,t){var o=kg(t),s=kg(e)*o,c=Pg(e)*o,l=Pg(t),u=l*i-c*a;return[Og(c*i+l*a,s*n+u*r),zg(u*n-s*r)]},o}function gv(e){e=fv(e[0]*Tg,e[1]*Tg,e.length>2?e[2]*Tg:0);function t(t){return t=e(t[0]*Tg,t[1]*Tg),t[0]*=wg,t[1]*=wg,t}return t.invert=function(t){return t=e.invert(t[0]*Tg,t[1]*Tg),t[0]*=wg,t[1]*=wg,t},t}function _v(e,t,n,r,i,a){if(n){var o=kg(t),s=Pg(t),c=r*n;i==null?(i=t+r*Cg,a=t-c/2):(i=vv(o,i),a=vv(o,a),(r>0?ia)&&(i+=r*Cg));for(var l,u=i;r>0?u>a:u1&&e.push(e.pop().concat(e.shift()))},result:function(){var n=e;return e=[],t=null,n}}}function bv(e,t){return Eg(e[0]-t[0])<1e-6&&Eg(e[1]-t[1])<1e-6}function xv(e,t,n,r){this.x=e,this.z=t,this.o=n,this.e=r,this.v=!1,this.n=this.p=null}function Sv(e,t,n,r,i){var a=[],o=[],s,c;if(e.forEach(function(e){if(!((t=e.length-1)<=0)){var t,n=e[0],r=e[t],c;if(bv(n,r)){if(!n[2]&&!r[2]){for(i.lineStart(),s=0;s=0;--s)i.point((d=u[s])[0],d[1]);else r(f.x,f.p.x,-1,i);f=f.p}f=f.o,u=f.z,p=!p}while(!f.v);i.lineEnd()}}}function Cv(e){if(t=e.length){for(var t,n=0,r=e[0],i;++n=0?1:-1,E=T*w,D=E>bg,O=g*S;if(c.add(Og(O*T*Pg(E),_*C+O*kg(E))),o+=D?w+T*Cg:w,D^m>=n^b>=n){var k=l_(s_(p),s_(y));f_(k);var A=l_(a,k);f_(A);var j=(D^w>=0?-1:1)*zg(A[2]);(r>j||r===j&&(k[0]||k[1]))&&(s+=D^w>=0?1:-1)}}return(o<-1e-6||o<1e-6&&c<-1e-12)^s&1}function Ev(e,t,n,r){return function(i){var a=t(i),o=yv(),s=t(o),c=!1,l,u,d,f={point:p,lineStart:h,lineEnd:g,polygonStart:function(){f.point=_,f.lineStart=v,f.lineEnd=y,u=[],l=[]},polygonEnd:function(){f.point=p,f.lineStart=h,f.lineEnd=g,u=Tm(u);var e=Tv(l,r);u.length?(c||=(i.polygonStart(),!0),Sv(u,Ov,e,n,i)):e&&(c||=(i.polygonStart(),!0),i.lineStart(),n(null,null,1,i),i.lineEnd()),c&&=(i.polygonEnd(),!1),u=l=null},sphere:function(){i.polygonStart(),i.lineStart(),n(null,null,1,i),i.lineEnd(),i.polygonEnd()}};function p(t,n){e(t,n)&&i.point(t,n)}function m(e,t){a.point(e,t)}function h(){f.point=m,a.lineStart()}function g(){f.point=p,a.lineEnd()}function _(e,t){d.push([e,t]),s.point(e,t)}function v(){s.lineStart(),d=[]}function y(){_(d[0][0],d[0][1]),s.lineEnd();var e=s.clean(),t=o.result(),n,r=t.length,a,f,p;if(d.pop(),l.push(d),d=null,r){if(e&1){if(f=t[0],(a=f.length-1)>0){for(c||=(i.polygonStart(),!0),i.lineStart(),n=0;n1&&e&2&&t.push(t.pop().concat(t.shift())),u.push(t.filter(Dv))}}return f}}function Dv(e){return e.length>1}function Ov(e,t){return((e=e.x)[0]<0?e[1]-xg-yg:xg-e[1])-((t=t.x)[0]<0?t[1]-xg-yg:xg-t[1])}var kv=Ev(function(){return!0},Av,Mv,[-bg,-xg]);function Av(e){var t=NaN,n=NaN,r=NaN,i;return{lineStart:function(){e.lineStart(),i=1},point:function(a,o){var s=a>0?bg:-bg,c=Eg(a-t);Eg(c-bg)<1e-6?(e.point(t,n=(n+o)/2>0?xg:-xg),e.point(r,n),e.lineEnd(),e.lineStart(),e.point(s,n),e.point(a,n),i=0):r!==s&&c>=bg&&(Eg(t-r)<1e-6&&(t-=r*yg),Eg(a-s)<1e-6&&(a-=s*yg),n=jv(t,n,a,o),e.point(r,n),e.lineEnd(),e.lineStart(),e.point(s,n),i=0),e.point(t=a,n=o),r=s},lineEnd:function(){e.lineEnd(),t=n=NaN},clean:function(){return 2-i}}}function jv(e,t,n,r){var i,a,o=Pg(e-n);return Eg(o)>1e-6?Dg((Pg(t)*(a=kg(r))*Pg(n)-Pg(r)*(i=kg(t))*Pg(e))/(i*a*o)):(t+r)/2}function Mv(e,t,n,r){var i;if(e==null)i=n*xg,r.point(-bg,i),r.point(0,i),r.point(bg,i),r.point(bg,0),r.point(bg,-i),r.point(0,-i),r.point(-bg,-i),r.point(-bg,0),r.point(-bg,i);else if(Eg(e[0]-t[0])>1e-6){var a=e[0]0,i=Eg(t)>yg;function a(t,r,i,a){_v(a,e,n,i,t,r)}function o(e,n){return kg(e)*kg(n)>t}function s(e){var t,n,a,s,u;return{lineStart:function(){s=a=!1,u=1},point:function(d,f){var p=[d,f],m,h=o(d,f),g=r?h?0:l(d,f):h?l(d+(d<0?bg:-bg),f):0;if(!t&&(s=a=h)&&e.lineStart(),h!==a&&(m=c(t,p),(!m||bv(t,m)||bv(p,m))&&(p[2]=1)),h!==a)u=0,h?(e.lineStart(),m=c(p,t),e.point(m[0],m[1])):(m=c(t,p),e.point(m[0],m[1],2),e.lineEnd()),t=m;else if(i&&t&&r^h){var _;!(g&n)&&(_=c(p,t,!0))&&(u=0,r?(e.lineStart(),e.point(_[0][0],_[0][1]),e.point(_[1][0],_[1][1]),e.lineEnd()):(e.point(_[1][0],_[1][1]),e.lineEnd(),e.lineStart(),e.point(_[0][0],_[0][1],3)))}h&&(!t||!bv(t,p))&&e.point(p[0],p[1]),t=p,a=h,n=g},lineEnd:function(){a&&e.lineEnd(),t=null},clean:function(){return u|(s&&a)<<1}}}function c(e,n,r){var i=s_(e),a=s_(n),o=[1,0,0],s=l_(i,a),c=c_(s,s),l=s[0],u=c-l*l;if(!u)return!r&&e;var d=t*c/u,f=-t*l/u,p=l_(o,s),m=d_(o,d);u_(m,d_(s,f));var h=p,g=c_(m,h),_=c_(h,h),v=g*g-_*(c_(m,m)-1);if(!(v<0)){var y=Ig(v),b=d_(h,(-g-y)/_);if(u_(b,m),b=o_(b),!r)return b;var x=e[0],S=n[0],C=e[1],w=n[1],T;S0^b[1]<(Eg(b[0]-x)<1e-6?C:w):C<=b[1]&&b[1]<=w:E>bg^(x<=b[0]&&b[0]<=S)){var k=d_(h,(-g+y)/_);return u_(k,m),[b,o_(k)]}}}function l(t,n){var i=r?e:bg-e,a=0;return t<-i?a|=1:t>i&&(a|=2),n<-i?a|=4:n>i&&(a|=8),a}return Ev(o,s,a,r?[0,-e]:[-bg,e-bg])}function Pv(e,t,n,r,i,a){var o=e[0],s=e[1],c=t[0],l=t[1],u=0,d=1,f=c-o,p=l-s,m=n-o;if(!(!f&&m>0)){if(m/=f,f<0){if(m0){if(m>d)return;m>u&&(u=m)}if(m=i-o,!(!f&&m<0)){if(m/=f,f<0){if(m>d)return;m>u&&(u=m)}else if(f>0){if(m0)){if(m/=p,p<0){if(m0){if(m>d)return;m>u&&(u=m)}if(m=a-s,!(!p&&m<0)){if(m/=p,p<0){if(m>d)return;m>u&&(u=m)}else if(p>0){if(m0&&(e[0]=o+u*f,e[1]=s+u*p),d<1&&(t[0]=o+d*f,t[1]=s+d*p),!0}}}}}var Fv=1e9,Iv=-Fv;function Lv(e,t,n,r){function i(i,a){return e<=i&&i<=n&&t<=a&&a<=r}function a(i,a,s,l){var u=0,d=0;if(i==null||(u=o(i,s))!==(d=o(a,s))||c(i,a)<0^s>0)do l.point(u===0||u===3?e:n,u>1?r:t);while((u=(u+s+4)%4)!==d);else l.point(a[0],a[1])}function o(r,i){return Eg(r[0]-e)<1e-6?i>0?0:3:Eg(r[0]-n)<1e-6?i>0?2:1:Eg(r[1]-t)<1e-6?i>0?1:0:i>0?3:2}function s(e,t){return c(e.x,t.x)}function c(e,t){var n=o(e,1),r=o(t,1);return n===r?n===0?t[1]-e[1]:n===1?e[0]-t[0]:n===2?e[1]-t[1]:t[0]-e[0]:n-r}return function(o){var c=o,l=yv(),u,d,f,p,m,h,g,_,v,y,b,x={point:S,lineStart:E,lineEnd:D,polygonStart:w,polygonEnd:T};function S(e,t){i(e,t)&&c.point(e,t)}function C(){for(var t=0,n=0,i=d.length;nr&&(f-l)*(r-u)>(p-u)*(e-l)&&++t:p<=r&&(f-l)*(r-u)<(p-u)*(e-l)&&--t;return t}function w(){c=l,u=[],d=[],b=!0}function T(){var e=C(),t=b&&e,n=(u=Tm(u)).length;(t||n)&&(o.polygonStart(),t&&(o.lineStart(),a(null,null,1,o),o.lineEnd()),n&&Sv(u,s,e,a,o),o.polygonEnd()),c=o,u=d=f=null}function E(){x.point=O,d&&d.push(f=[]),y=!0,v=!1,g=_=NaN}function D(){u&&(O(p,m),h&&v&&l.rejoin(),u.push(l.result())),x.point=S,v&&c.lineEnd()}function O(a,o){var s=i(a,o);if(d&&f.push([a,o]),y)p=a,m=o,h=s,y=!1,s&&(c.lineStart(),c.point(a,o));else if(s&&v)c.point(a,o);else{var l=[g=Math.max(Iv,Math.min(Fv,g)),_=Math.max(Iv,Math.min(Fv,_))],u=[a=Math.max(Iv,Math.min(Fv,a)),o=Math.max(Iv,Math.min(Fv,o))];Pv(l,u,e,t,n,r)?(v||(c.lineStart(),c.point(l[0],l[1])),c.point(u[0],u[1]),s||c.lineEnd(),b=!1):s&&(c.lineStart(),c.point(a,o),b=!1)}g=a,_=o,v=s}return x}}var Rv,zv,Bv,Vv,Hv={sphere:Vg,point:Vg,lineStart:Uv,lineEnd:Vg,polygonStart:Vg,polygonEnd:Vg};function Uv(){Hv.point=Gv,Hv.lineEnd=Wv}function Wv(){Hv.point=Hv.lineEnd=Vg}function Gv(e,t){e*=Tg,t*=Tg,zv=e,Bv=Pg(t),Vv=kg(t),Hv.point=Kv}function Kv(e,t){e*=Tg,t*=Tg;var n=Pg(t),r=kg(t),i=Eg(e-zv),a=kg(i),o=r*Pg(i),s=Vv*n-Bv*r*a,c=Bv*n+Vv*r*a;Rv.add(Og(Ig(o*o+s*s),c)),zv=e,Bv=n,Vv=r}function qv(e){return Rv=new mm,qg(e,Hv),+Rv}var Jv=[null,null],Yv={type:`LineString`,coordinates:Jv};function Xv(e,t){return Jv[0]=e,Jv[1]=t,qv(Yv)}var Zv={Feature:function(e,t){return $v(e.geometry,t)},FeatureCollection:function(e,t){for(var n=e.features,r=-1,i=n.length;++r0&&(i=Xv(e[a],e[a-1]),i>0&&n<=i&&r<=i&&(n+r-i)*(1-((n-r)/i)**2)<1e-12*i))return!0;n=r}return!1}function ny(e,t){return!!Tv(e.map(ry),iy(t))}function ry(e){return e=e.map(iy),e.pop(),e}function iy(e){return[e[0]*Tg,e[1]*Tg]}function ay(e,t){return(e&&Zv.hasOwnProperty(e.type)?Zv[e.type]:$v)(e,t)}function oy(e,t,n){var r=Em(e,t-yg,n).concat(t);return function(e){return r.map(function(t){return[e,t]})}}function sy(e,t,n){var r=Em(e,t-yg,n).concat(t);return function(e){return r.map(function(t){return[t,e]})}}function cy(){var e,t,n,r,i,a,o,s,c=10,l=c,u=90,d=360,f,p,m,h,g=2.5;function _(){return{type:`MultiLineString`,coordinates:v()}}function v(){return Em(Ag(r/u)*u,n,u).map(m).concat(Em(Ag(s/d)*d,o,d).map(h)).concat(Em(Ag(t/c)*c,e,c).filter(function(e){return Eg(e%u)>yg}).map(f)).concat(Em(Ag(a/l)*l,i,l).filter(function(e){return Eg(e%d)>yg}).map(p))}return _.lines=function(){return v().map(function(e){return{type:`LineString`,coordinates:e}})},_.outline=function(){return{type:`Polygon`,coordinates:[m(r).concat(h(o).slice(1),m(n).reverse().slice(1),h(s).reverse().slice(1))]}},_.extent=function(e){return arguments.length?_.extentMajor(e).extentMinor(e):_.extentMinor()},_.extentMajor=function(e){return arguments.length?(r=+e[0][0],n=+e[1][0],s=+e[0][1],o=+e[1][1],r>n&&(e=r,r=n,n=e),s>o&&(e=s,s=o,o=e),_.precision(g)):[[r,s],[n,o]]},_.extentMinor=function(n){return arguments.length?(t=+n[0][0],e=+n[1][0],a=+n[0][1],i=+n[1][1],t>e&&(n=t,t=e,e=n),a>i&&(n=a,a=i,i=n),_.precision(g)):[[t,a],[e,i]]},_.step=function(e){return arguments.length?_.stepMajor(e).stepMinor(e):_.stepMinor()},_.stepMajor=function(e){return arguments.length?(u=+e[0],d=+e[1],_):[u,d]},_.stepMinor=function(e){return arguments.length?(c=+e[0],l=+e[1],_):[c,l]},_.precision=function(c){return arguments.length?(g=+c,f=oy(a,i,90),p=sy(t,e,g),m=oy(s,o,90),h=sy(r,n,g),_):g},_.extentMajor([[-180,-90+yg],[180,90-yg]]).extentMinor([[-180,-80-yg],[180,80+yg]])}function ly(){return cy()()}function uy(e,t){var n=e[0]*Tg,r=e[1]*Tg,i=t[0]*Tg,a=t[1]*Tg,o=kg(r),s=Pg(r),c=kg(a),l=Pg(a),u=o*kg(n),d=o*Pg(n),f=c*kg(i),p=c*Pg(i),m=2*zg(Ig(Bg(a-r)+o*c*Bg(i-n))),h=Pg(m),g=m?function(e){var t=Pg(e*=m)/h,n=Pg(m-e)/h,r=n*u+t*f,i=n*d+t*p,a=n*s+t*l;return[Og(i,r)*wg,Og(a,Ig(r*r+i*i))*wg]}:function(){return[n*wg,r*wg]};return g.distance=m,g}var dy=e=>e,fy=1/0,py=fy,my=-fy,hy=my,gy={point:_y,lineStart:Vg,lineEnd:Vg,polygonStart:Vg,polygonEnd:Vg,result:function(){var e=[[fy,py],[my,hy]];return my=hy=-(py=fy=1/0),e}};function _y(e,t){emy&&(my=e),thy&&(hy=t)}var vy=gy;function yy(e){return function(t){var n=new by;for(var r in e)n[r]=e[r];return n.stream=t,n}}function by(){}by.prototype={constructor:by,point:function(e,t){this.stream.point(e,t)},sphere:function(){this.stream.sphere()},lineStart:function(){this.stream.lineStart()},lineEnd:function(){this.stream.lineEnd()},polygonStart:function(){this.stream.polygonStart()},polygonEnd:function(){this.stream.polygonEnd()}};function xy(e,t,n){var r=e.clipExtent&&e.clipExtent();return e.scale(150).translate([0,0]),r!=null&&e.clipExtent(null),qg(n,e.stream(vy)),t(vy.result()),r!=null&&e.clipExtent(r),e}function Sy(e,t,n){return xy(e,function(n){var r=t[1][0]-t[0][0],i=t[1][1]-t[0][1],a=Math.min(r/(n[1][0]-n[0][0]),i/(n[1][1]-n[0][1])),o=+t[0][0]+(r-a*(n[1][0]+n[0][0]))/2,s=+t[0][1]+(i-a*(n[1][1]+n[0][1]))/2;e.scale(150*a).translate([o,s])},n)}function Cy(e,t,n){return Sy(e,[[0,0],t],n)}function wy(e,t,n){return xy(e,function(n){var r=+t,i=r/(n[1][0]-n[0][0]),a=(r-i*(n[1][0]+n[0][0]))/2,o=-i*n[0][1];e.scale(150*i).translate([a,o])},n)}function Ty(e,t,n){return xy(e,function(n){var r=+t,i=r/(n[1][1]-n[0][1]),a=-i*n[0][0],o=(r-i*(n[1][1]+n[0][1]))/2;e.scale(150*i).translate([a,o])},n)}var Ey=16,Dy=kg(30*Tg);function Oy(e,t){return+t?Ay(e,t):ky(e)}function ky(e){return yy({point:function(t,n){t=e(t,n),this.stream.point(t[0],t[1])}})}function Ay(e,t){function n(r,i,a,o,s,c,l,u,d,f,p,m,h,g){var _=l-r,v=u-i,y=_*_+v*v;if(y>4*t&&h--){var b=o+f,x=s+p,S=c+m,C=Ig(b*b+x*x+S*S),w=zg(S/=C),T=Eg(Eg(S)-1)<1e-6||Eg(a-d)<1e-6?(a+d)/2:Og(x,b),E=e(T,w),D=E[0],O=E[1],k=D-r,A=O-i,j=v*k-_*A;(j*j/y>t||Eg((_*k+v*A)/y-.5)>.3||o*f+s*p+c*m2?e[2]%360*Tg:0,k()):[s*wg,c*wg,l*wg]},D.angle=function(e){return arguments.length?(d=e%360*Tg,k()):d*wg},D.reflectX=function(e){return arguments.length?(f=e?-1:1,k()):f<0},D.reflectY=function(e){return arguments.length?(p=e?-1:1,k()):p<0},D.precision=function(e){return arguments.length?(S=Oy(C,x=e*e),A()):Ig(x)},D.fitExtent=function(e,t){return Sy(D,e,t)},D.fitSize=function(e,t){return Cy(D,e,t)},D.fitWidth=function(e,t){return wy(D,e,t)},D.fitHeight=function(e,t){return Ty(D,e,t)};function k(){var e=Py(n,0,0,f,p,d).apply(null,t(a,o)),m=Py(n,r-e[0],i-e[1],f,p,d);return u=fv(s,c,l),C=uv(t,m),w=uv(u,C),S=Oy(C,x),A()}function A(){return T=E=null,D}return function(){return t=e.apply(this,arguments),D.invert=t.invert&&O,k()}}function Ly(e){return function(t,n){var r=Ig(t*t+n*n),i=e(r),a=Pg(i),o=kg(i);return[Og(t*a,r*o),zg(r&&n*a/r)]}}function Ry(e,t){return[e,Ng(Lg((xg+t)/2))]}Ry.invert=function(e,t){return[e,2*Dg(jg(t))-xg]};function zy(e,t){var n=kg(t),r=1+kg(e)*n;return[n*Pg(e)/r,Pg(t)/r]}zy.invert=Ly(function(e){return 2*Dg(e)});function By(){return Fy(zy).scale(250).clipAngle(142)}function Vy(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n1&&arguments[1]!==void 0?arguments[1]:0,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,r=_g().domain([1,0]).range([t,n]).clamp(!0),i=_g().domain([Sb(t),Sb(n)]).range([1,0]).clamp(!0),a=function(e){return i(Sb(r(e)))},o=e.array,s=0,c=o.length;s2&&arguments[2]!==void 0?arguments[2]:0,r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0,i=arguments.length>4?arguments[4]:void 0,a=arguments.length>5?arguments[5]:void 0,o=[],s=2**e,c=360/s,l=180/s,u=i===void 0?s-1:i,d=a===void 0?s-1:a,f=n,p=Math.min(s-1,u);f<=p;f++)for(var m=r,h=Math.min(s-1,d);m<=h;m++){var g=m,_=l;t&&(g=m===0?m:Cb(m/s)*s,_=((m+1===s?m+1:Cb((m+1)/s)*s)-g)*180/s);var v=-180+(f+.5)*c,y=90-(g*180/s+_/2),b=_;o.push({x:f,y:m,lng:v,lat:y,latLen:b})}return o},Db=6,Ob=7,kb=3,fee=90,Ab=new WeakMap,jb=new WeakMap,Mb=new WeakMap,Nb=new WeakMap,Pb=new WeakMap,Fb=new WeakMap,Ib=new WeakMap,Lb=new WeakMap,Rb=new WeakSet,zb=function(e){function t(e){var n,r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=r.tileUrl,a=r.minLevel,o=a===void 0?0:a,s=r.maxLevel,c=s===void 0?17:s,l=r.mercatorProjection,u=l===void 0?!0:l;return Jy(this,t),n=Ky(this,t),Qy(n,Rb),Xy(n,Ab,void 0),Xy(n,jb,void 0),Xy(n,Mb,void 0),Xy(n,Nb,void 0),Xy(n,Pb,{}),Xy(n,Fb,void 0),Xy(n,Ib,void 0),Xy(n,Lb,void 0),tb(n,`minLevel`,void 0),tb(n,`maxLevel`,void 0),tb(n,`thresholds`,fb(Array(30)).map(function(e,t){return 8/2**t})),tb(n,`curvatureResolution`,5),tb(n,`tileMargin`,0),tb(n,`clearTiles`,function(){Object.values(Yy(Pb,n)).forEach(function(e){e.forEach(function(e){e.obj&&(n.remove(e.obj),_b(e.obj),delete e.obj)})}),Zy(Pb,n,{})}),Zy(Ab,n,e),n.tileUrl=i,Zy(jb,n,u),n.minLevel=o,n.maxLevel=c,n.level=0,n.add(Zy(Lb,n,new ea(new cs(Yy(Ab,n)*.99,180,90),new Hi({color:0})))),Yy(Lb,n).visible=!1,Yy(Lb,n).material.polygonOffset=!0,Yy(Lb,n).material.polygonOffsetUnits=3,Yy(Lb,n).material.polygonOffsetFactor=1,n}return rb(t,e),eb(t,[{key:`tileUrl`,get:function(){return Yy(Mb,this)},set:function(e){Zy(Mb,this,e),this.updatePov(Yy(Ib,this))}},{key:`level`,get:function(){return Yy(Nb,this)},set:function(e){var t,n=this;Yy(Pb,this)[e]||Wy(Rb,this,Bb).call(this,e);var r=Yy(Nb,this);if(Zy(Nb,this,e),!(e===r||r===void 0)){if(Yy(Lb,this).visible=e>0,Yy(Pb,this)[e].forEach(function(e){return e.obj&&(e.obj.material.depthWrite=!0)}),re)for(var i=e+1;i<=r;i++)Yy(Pb,this)[i]&&Yy(Pb,this)[i].forEach(function(e){e.obj&&(n.remove(e.obj),_b(e.obj),delete e.obj)});Wy(Rb,this,Vb).call(this)}}},{key:`updatePov`,value:function(e){var t=this;if(!(!e||!(e instanceof lc))){Zy(Ib,this,e);var n;if(Zy(Fb,this,function(r){if(!r.hullPnts){var i=360/2**t.level,a=r.lng,o=r.lat,s=r.latLen,c=a-i/2,l=a+i/2,u=o-s/2,d=o+s/2;r.hullPnts=[[o,a],[u,c],[d,c],[u,l],[d,l]].map(function(e){var n=db(e,2),r=n[0],i=n[1];return vb(r,i,Yy(Ab,t))}).map(function(e){var t=e.x,n=e.y,r=e.z;return new R(t,n,r)})}return n||(n=new fa,e.updateMatrix(),e.updateMatrixWorld(),n.setFromProjectionMatrix(new qn().multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse))),r.hullPnts.some(function(e){return n.containsPoint(e.clone().applyMatrix4(t.matrixWorld))})}),this.tileUrl){var r=(e.position.clone().distanceTo(this.getWorldPosition(new R))-Yy(Ab,this))/Yy(Ab,this),i=this.thresholds.findIndex(function(e){return e&&e<=r});this.level=Math.min(this.maxLevel,Math.max(this.minLevel,i<0?this.thresholds.length:i)),Wy(Rb,this,Vb).call(this)}}}}])}(B);function Bb(e){var t=this;if(e>Ob){Yy(Pb,this)[e]=[];return}var n=Yy(Pb,this)[e]=Eb(e,Yy(jb,this));n.forEach(function(e){return e.centroid=vb(e.lat,e.lng,Yy(Ab,t))}),n.octree=tm().x(function(e){return e.centroid.x}).y(function(e){return e.centroid.y}).z(function(e){return e.centroid.z}).addAll(n)}function Vb(){var e=this;if(!(!this.tileUrl||this.level===void 0||!Yy(Pb,this).hasOwnProperty(this.level))&&!(!Yy(Fb,this)&&this.level>Db)){var t=Yy(Pb,this)[this.level];if(Yy(Ib,this)){var n=this.worldToLocal(Yy(Ib,this).position.clone());if(t.octree){var r,i=this.worldToLocal(Yy(Ib,this).position.clone()),a=(i.length()-Yy(Ab,this))*kb;t=(r=t.octree).findAllWithinRadius.apply(r,fb(i).concat([a]))}else{var o=yb(n),s=(o.r/Yy(Ab,this)-1)*fee,c=s/Math.cos(bb(o.lat)),l=[o.lng-c,o.lng+c],u=[o.lat+s,o.lat-s],d=db(Tb(this.level,Yy(jb,this),l[0],u[0]),2),f=d[0],p=d[1],m=db(Tb(this.level,Yy(jb,this),l[1],u[1]),2),h=m[0],g=m[1];!t.record&&(t.record={});var _=t.record;if(!_.hasOwnProperty(`${Math.round((f+h)/2)}_${Math.round((p+g)/2)}`))t=Eb(this.level,Yy(jb,this),f,p,h,g).map(function(e){var n=`${e.x}_${e.y}`;return _.hasOwnProperty(n)?_[n]:(_[n]=e,t.push(e),e)});else{for(var v=[],y=f;y<=h;y++)for(var b=p;b<=g;b++){var x=`${y}_${b}`;_.hasOwnProperty(x)||(_[x]=Eb(this.level,Yy(jb,this),y,b,y,b)[0],t.push(_[x])),v.push(_[x])}t=v}}}t.filter(function(e){return!e.obj}).filter(Yy(Fb,this)||function(){return!0}).forEach(function(t){var n=t.x,r=t.y,i=t.lng,a=t.lat,o=t.latLen,s=360/2**e.level;if(!t.obj){var c=s*(1-e.tileMargin),l=o*(1-e.tileMargin),u=bb(i),d=bb(-a),f=new ea(new cs(Yy(Ab,e),Math.ceil(c/e.curvatureResolution),Math.ceil(l/e.curvatureResolution),bb(90-c/2)+u,bb(c),bb(90-l/2)+d,bb(l)),new Os);if(Yy(jb,e)){var p=db([a+o/2,a-o/2].map(function(e){return .5-e/180}),2),m=p[0],h=p[1];wb(f.geometry.attributes.uv,m,h)}t.obj=f}t.loading||(t.loading=!0,new $s().load(e.tileUrl(n,r,e.level),function(n){var r=t.obj;r&&(n.colorSpace=yt,r.material.map=n,r.material.color=null,r.material.needsUpdate=!0,e.add(r)),t.loading=!1}))})}}var Hb=new Set,Ub=!1;function Wb(e,t,n=2){let r=t&&t.length,i=r?t[0]*n:e.length;Hb.size&&Hb.clear();let a=Gb(e,0,i,n,!0),o=[];if(!a||a.next===a.prev)return o;let s=0,c=0,l=0;if(r&&(a=$b(e,t,a,n)),e.length>80*n){s=e[0],c=e[1];let t=s,r=c;for(let a=n;at&&(t=n),i>r&&(r=i)}l=Math.max(t-s,r-c),l=l===0?0:32767/l}return qb(a,o,s,c,l),o}function Gb(e,t,n,r,i){let a=null;if(i===Lx(e,t,n,r)>0)for(let i=t;i=t;i-=r)a=Px(i/r|0,e[i],e[i+1],a);return a&&Dx(a,a.next)&&(Fx(a),a=a.next),a}function Kb(e,t=e){let n=t===e,r=e,i;do i=!1,r!==r.next&&(Hb.size===0||!Hb.has(r))&&(Dx(r,r.next)||Ex(r.prev,r,r.next)===0)?((n||r===t)&&(t=r.prev),Ub=!0,Fx(r),r=r.prev,i=!0):(n||r!==t)&&(r=r.next,i=!n);while(i||r!==t);return t}function qb(e,t,n,r,i){i&&yx(e,n,r,i);let a=e,o=!1;for(;e.prev!==e.next;){let s=e.prev,c=e.next;if(Ex(s,e,c)<0&&(i?Yb(e,n,r,i):Jb(e))){t.push(s.i,e.i,c.i),Fx(e),e=c,a=c;continue}if(e=c,e===a){if(Ub=!1,e=Kb(e),Ub){a=e;continue}if(!o){e=Xb(e,t),a=e,o=!0;continue}Zb(e,t,n,r,i);break}}}function Jb(e){let t=e.prev,n=e,r=e.next,i=t.x,a=n.x,o=r.x,s=t.y,c=n.y,l=r.y,u=Math.min(i,a,o),d=Math.min(s,c,l),f=Math.max(i,a,o),p=Math.max(s,c,l),m=r.next;for(;m!==t;){if(m.x>=u&&m.x<=f&&m.y>=d&&m.y<=p&&!(i===m.x&&s===m.y)&&wx(i,s,a,c,o,l,m.x,m.y)&&Ex(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function Yb(e,t,n,r){let i=e.prev,a=e,o=e.next,s=i.x,c=a.x,l=o.x,u=i.y,d=a.y,f=o.y,p=Math.min(s,c,l),m=Math.min(u,d,f),h=Math.max(s,c,l),g=Math.max(u,d,f),_=Sx(p,m,t,n,r),v=Sx(h,g,t,n,r),y=e.prevZ;for(;y&&y.z>=_;){if(y.x>=p&&y.x<=h&&y.y>=m&&y.y<=g&&y!==o&&!(s===y.x&&u===y.y)&&wx(s,u,c,d,l,f,y.x,y.y)&&Ex(y.prev,y,y.next)>=0)return!1;y=y.prevZ}let b=e.nextZ;for(;b&&b.z<=v;){if(b.x>=p&&b.x<=h&&b.y>=m&&b.y<=g&&b!==o&&!(s===b.x&&u===b.y)&&wx(s,u,c,d,l,f,b.x,b.y)&&Ex(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function Xb(e,t){let n=e,r=!1;do{let i=n.prev,a=n.next.next;Ox(i,n,n.next,a,!1)&&jx(i,a)&&jx(a,i)&&(t.push(i.i,n.i,a.i),Fx(n),Fx(n.next),n=e=a,r=!0),n=n.next}while(n!==e);return r?Kb(n):n}function Zb(e,t,n,r,i){let a=e;do{let e=a.next.next;for(;e!==a.prev;){if(a.i!==e.i&&Tx(a,e)){let o=Nx(a,e);a=Kb(a,a.next),o=Kb(o,o.next),qb(a,t,n,r,i),qb(o,t,n,r,i);return}e=e.next}a=a.next}while(a!==e)}var Qb=!1;function $b(e,t,n,r){let i=[];for(let n=0,a=t.length;na&&(a=n.x),n.yo&&(o=n.y),t.xa&&(a=t.x),t.yo&&(o=t.y),n=t}while(++srx[n+2]&&(rx[n+2]=t.x),t.y>rx[n+3]&&(rx[n+3]=t.y)}function ux(e){let t=ox[e];for(;t.prev.next!==t;)t=t.next;return ox[e]=t,t}function dx(e){let t=ax[e];for(;t.prev.next!==t;)t=t.next;return ax[e]=t,t}function fx(e,t){let n=t,r=e.x,i=e.y,a=-1/0,o;if(Dx(e,n))return n;for(let t=0,s=0;trx[s+3]||rx[s]>r||rx[s+2]<=a)continue;let c=ux(t);n=dx(t);do{if(n.prev.next===n){if(Dx(e,n.next))return n.next;if(i<=n.y&&i>=n.next.y&&n.next.y!==n.y){let e=n.x+(i-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(e<=r&&e>a&&(a=e,o=n.xr||rx[f+3]u)continue;let p=ux(t);n=dx(t);do{if(n.prev.next===n&&r>=n.x&&n.x>=s&&r!==n.x&&wx(ir)&&(to.x||n.x===o.x&&px(o,n)))&&(o=n,d=t)}n=n.next}while(n!==p)}return o}function px(e,t){return Ex(e.prev,e,t.prev)<0&&Ex(t.next,e,e.next)<0}var mx=[],hx=[],gx=new Uint32Array,_x=new Uint32Array,vx=new Uint32Array(256);function yx(e,t,n,r){let i=e,a=0;do i.z=Sx(i.x,i.y,t,n,r),mx[a++]=i,i=i.next;while(i!==e);bx(a);let o=null;for(let e=0;e=0&&mx[r].z>n;)mx[r+1]=mx[r],r--;mx[r+1]=e}return}gx.length>>a&255]++;let o=0;for(let e=0;e<256;e++){let t=vx[e];vx[e]=o,o+=t}for(let o=0;o>>a&255]++;r[s]=t[o],i[s]=e}}function Sx(e,t,n,r,i){return e=(e-n)*i|0,t=(t-r)*i|0,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,e|t<<1}function Cx(e){let t=e,n=e;do(t.x=(e-o)*(a-s)&&(e-o)*(r-s)>=(n-o)*(t-s)&&(n-o)*(a-s)>=(i-o)*(r-s)}function Tx(e,t){let n=Dx(e,t)&&Ex(e.prev,e,e.next)>0&&Ex(t.prev,t,t.next)>0;return e.next.i!==t.i&&(n||jx(e,t)&&jx(t,e)&&(Ex(e.prev,e,t.prev)!==0||Ex(e,t.prev,t)!==0))&&!Ax(e,t)&&(n||Mx(e,t))}function Ex(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function Dx(e,t){return e.x===t.x&&e.y===t.y}function Ox(e,t,n,r,i=!0){let a=Ex(e,t,n),o=Ex(e,t,r),s=Ex(n,r,e),c=Ex(n,r,t);return(a>0&&o<0||a<0&&o>0)&&(s>0&&c<0||s<0&&c>0)?!0:i?!!(a===0&&kx(e,n,t)||o===0&&kx(e,r,t)||s===0&&kx(n,e,r)||c===0&&kx(n,t,r)):!1}function kx(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function Ax(e,t){let n=Math.min(e.x,t.x),r=Math.max(e.x,t.x),i=Math.min(e.y,t.y),a=Math.max(e.y,t.y),o=e;do{let s=o.next;if(o.x>r&&s.x>r||o.xa&&s.y>a||o.y=0&&Ex(e,e.prev,t)>=0:Ex(e,t,e.prev)<0||Ex(e,e.next,t)<0}function Mx(e,t){let n=e,r=!1,i=(e.x+t.x)/2,a=(e.y+t.y)/2;do{let e=n.next;n.y>a!=e.y>a&&i<(e.x-n.x)*(a-n.y)/(e.y-n.y)+n.x&&(r=!r),n=e}while(n!==e);return r}function Nx(e,t){let n=Ix(e.i,e.x,e.y),r=Ix(t.i,t.x,t.y),i=e.next,a=t.prev;return e.next=t,t.prev=e,n.next=i,i.prev=n,r.next=n,n.prev=r,a.next=r,r.prev=a,r}function Px(e,t,n,r){let i=Ix(e,t,n);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function Fx(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ),Qb&&lx(e.prev,e.next)}function Ix(e,t,n){return{i:e,x:t,y:n,prev:null,next:null,z:0,prevZ:null,nextZ:null}}function Lx(e,t,n,r){let i=0;for(let a=t,o=n-r;ae.length)&&(t=e.length);for(var n=0,r=Array(t);n=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw TypeError(`Invalid attempt to iterate non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||n.return==null||n.return()}finally{if(s)throw a}}}}function qx(e){return qx=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},qx(e)}function Jx(e,t){if(typeof t!=`function`&&t!==null)throw TypeError(`Super expression must either be null or a function`);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,`prototype`,{writable:!1}),t&&tS(e,t)}function Yx(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Yx=function(){return!!e})()}function Xx(e){if(typeof Symbol<`u`&&e[Symbol.iterator]!=null||e[`@@iterator`]!=null)return Array.from(e)}function Zx(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function Qx(){throw TypeError(`Invalid attempt to destructure non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function $x(){throw TypeError(`Invalid attempt to spread non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function eS(e,t){if(t&&(typeof t==`object`||typeof t==`function`))return t;if(t!==void 0)throw TypeError(`Derived constructors may only return object or undefined`);return Hx(e)}function tS(e,t){return tS=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},tS(e,t)}function nS(e,t){return Bx(e)||Zx(e,t)||iS(e,t)||Qx()}function rS(e){return Vx(e)||Xx(e)||iS(e)||$x()}function iS(e,t){if(e){if(typeof e==`string`)return zx(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?zx(e,t):void 0}}var aS=function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,n=[],r=null;return e.forEach(function(e){if(r){var i=Xv(e,r)*180/Math.PI;if(i>t)for(var a=uy(r,e),o=r.length>2||e.length>2?Th(r[2]||0,e[2]||0):null,s=o?function(e){return[].concat(rS(a(e)),[o(e)])}:a,c=1/Math.ceil(i/t),l=c;l<1;)n.push(s(l)),l+=c}n.push(r=e)}),n},oS=typeof window<`u`&&window.THREE?window.THREE:{BufferGeometry:Di,Float32BufferAttribute:hi},sS=new oS.BufferGeometry().setAttribute?`setAttribute`:`addAttribute`,cS=function(e){function t(e){var n,r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:5;Wx(this,t),n=Ux(this,t),n.type=`GeoJsonGeometry`,n.parameters={geoJson:e,radius:r,resolution:i};var a=({Point:l,MultiPoint:u,LineString:d,MultiLineString:f,Polygon:p,MultiPolygon:m}[e.type]||function(){return[]})(e.coordinates,r),o=[],s=[],c=0;a.forEach(function(e){var t=o.length;lS({indices:o,vertices:s},e),n.addGroup(t,o.length-t,c++)}),o.length&&n.setIndex(o),s.length&&n[sS](`position`,new oS.Float32BufferAttribute(s,3));function l(e,t){return[{vertices:dS(e[1],e[0],t+(e[2]||0)),indices:[]}]}function u(e,t){var n={vertices:[],indices:[]};return e.map(function(e){return l(e,t)}).forEach(function(e){var t=nS(e,1)[0];lS(n,t)}),[n]}function d(e,t){for(var n=Rx([aS(e,i).map(function(e){var n=nS(e,3),r=n[0],i=n[1],a=n[2];return dS(i,r,t+(a===void 0?0:a))})]).vertices,r=Math.round(n.length/3),a=[],o=1;o2&&arguments[2]!==void 0?arguments[2]:0,r=(90-e)*Math.PI/180,i=(90-t)*Math.PI/180;return[n*Math.sin(r)*Math.cos(i),n*Math.cos(r),n*Math.sin(r)*Math.sin(i)]}var fS=a({computeMikkTSpaceTangents:()=>pS,computeMorphedAttributes:()=>CS,deepCloneAttribute:()=>gS,deinterleaveAttribute:()=>vS,deinterleaveGeometry:()=>yS,estimateBytesUsed:()=>bS,interleaveAttributes:()=>_S,mergeAttributes:()=>hS,mergeGeometries:()=>mS,mergeGroups:()=>wS,mergeVertices:()=>xS,toCreasedNormals:()=>TS,toTrianglesDrawMode:()=>SS});function pS(e,t,n=!0){if(!t||!t.isReady)throw Error(`THREE.BufferGeometryUtils: Initialized MikkTSpace library required.`);if(!e.hasAttribute(`position`)||!e.hasAttribute(`normal`)||!e.hasAttribute(`uv`))throw Error(`THREE.BufferGeometryUtils: Tangents require "position", "normal", and "uv" attributes.`);function r(e){if(e.normalized||e.isInterleavedBufferAttribute){let t=new Float32Array(e.count*e.itemSize);for(let n=0,r=0;n2&&(t[r++]=e.getZ(n));return t}return e.array instanceof Float32Array?e.array:new Float32Array(e.array)}let i=e.index?e.toNonIndexed():e,a=t.generateTangents(r(i.attributes.position),r(i.attributes.normal),r(i.attributes.uv));if(n)for(let e=3;e=2&&o.setY(t,e.getY(t)),r>=3&&o.setZ(t,e.getZ(t)),r>=4&&o.setW(t,e.getW(t));return o}function yS(e){let t=e.attributes,n=e.morphTargets,r=new Map;for(let e in t){let n=t[e];n.isInterleavedBufferAttribute&&(r.has(n)||r.set(n,vS(n)),t[e]=r.get(n))}for(let e in n){let t=n[e];t.isInterleavedBufferAttribute&&(r.has(t)||r.set(t,vS(t)),n[e]=r.get(t))}}function bS(e){let t=0;for(let n in e.attributes){let r=e.getAttribute(n);t+=r.count*r.itemSize*r.array.BYTES_PER_ELEMENT}let n=e.getIndex();return t+=n?n.count*n.itemSize*n.array.BYTES_PER_ELEMENT:0,t}function xS(e,t=1e-4){t=Math.max(t,2**-52);let n={},r=e.getIndex(),i=e.getAttribute(`position`),a=r?r.count:i.count,o=0,s=Object.keys(e.attributes),c={},l={},u=[],d=[`getX`,`getY`,`getZ`,`getW`],f=[`setX`,`setY`,`setZ`,`setW`];for(let t=0,n=s.length;t{let r=new e.array.constructor(e.count*e.itemSize);l[n][t]=new e.constructor(r,e.itemSize,e.normalized)}))}let p=t*.5,m=10**Math.log10(1/t),h=p*m;for(let t=0;te.materialIndex===t.materialIndex?e.start-t.start:e.materialIndex-t.materialIndex),e.getIndex()===null){let t=e.getAttribute(`position`),n=[];for(let e=0;eo&&(c+=a,d+=s,f+=u)}let p=1/(Math.sqrt(c*c+d*d+f*f)||1);y[3*a+0]=c*p,y[3*a+1]=d*p,y[3*a+2]=f*p}}return n.setAttribute(`normal`,new di(y,3,!1)),n}var V=(function(e){return typeof e==`function`?e:typeof e==`string`?function(t){return t[e]}:function(t){return e}});function ES(e){"@babel/helpers - typeof";return ES=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},ES(e)}var DS=/^\s+/,OS=/\s+$/;function kS(e,t){if(e||=``,t||={},e instanceof kS)return e;if(!(this instanceof kS))return new kS(e,t);var n=AS(e);this._originalInput=e,this._r=n.r,this._g=n.g,this._b=n.b,this._a=n.a,this._roundA=Math.round(100*this._a)/100,this._format=t.format||n.format,this._gradientType=t.gradientType,this._r<1&&(this._r=Math.round(this._r)),this._g<1&&(this._g=Math.round(this._g)),this._b<1&&(this._b=Math.round(this._b)),this._ok=n.ok}kS.prototype={isDark:function(){return this.getBrightness()<128},isLight:function(){return!this.isDark()},isValid:function(){return this._ok},getOriginalInput:function(){return this._originalInput},getFormat:function(){return this._format},getAlpha:function(){return this._a},getBrightness:function(){var e=this.toRgb();return(e.r*299+e.g*587+e.b*114)/1e3},getLuminance:function(){var e=this.toRgb(),t=e.r/255,n=e.g/255,r=e.b/255,i=t<=.03928?t/12.92:((t+.055)/1.055)**2.4,a=n<=.03928?n/12.92:((n+.055)/1.055)**2.4,o=r<=.03928?r/12.92:((r+.055)/1.055)**2.4;return .2126*i+.7152*a+.0722*o},setAlpha:function(e){return this._a=eC(e),this._roundA=Math.round(100*this._a)/100,this},toHsv:function(){var e=PS(this._r,this._g,this._b);return{h:e.h*360,s:e.s,v:e.v,a:this._a}},toHsvString:function(){var e=PS(this._r,this._g,this._b),t=Math.round(e.h*360),n=Math.round(e.s*100),r=Math.round(e.v*100);return this._a==1?`hsv(`+t+`, `+n+`%, `+r+`%)`:`hsva(`+t+`, `+n+`%, `+r+`%, `+this._roundA+`)`},toHsl:function(){var e=MS(this._r,this._g,this._b);return{h:e.h*360,s:e.s,l:e.l,a:this._a}},toHslString:function(){var e=MS(this._r,this._g,this._b),t=Math.round(e.h*360),n=Math.round(e.s*100),r=Math.round(e.l*100);return this._a==1?`hsl(`+t+`, `+n+`%, `+r+`%)`:`hsla(`+t+`, `+n+`%, `+r+`%, `+this._roundA+`)`},toHex:function(e){return IS(this._r,this._g,this._b,e)},toHexString:function(e){return`#`+this.toHex(e)},toHex8:function(e){return LS(this._r,this._g,this._b,this._a,e)},toHex8String:function(e){return`#`+this.toHex8(e)},toRgb:function(){return{r:Math.round(this._r),g:Math.round(this._g),b:Math.round(this._b),a:this._a}},toRgbString:function(){return this._a==1?`rgb(`+Math.round(this._r)+`, `+Math.round(this._g)+`, `+Math.round(this._b)+`)`:`rgba(`+Math.round(this._r)+`, `+Math.round(this._g)+`, `+Math.round(this._b)+`, `+this._roundA+`)`},toPercentageRgb:function(){return{r:Math.round(tC(this._r,255)*100)+`%`,g:Math.round(tC(this._g,255)*100)+`%`,b:Math.round(tC(this._b,255)*100)+`%`,a:this._a}},toPercentageRgbString:function(){return this._a==1?`rgb(`+Math.round(tC(this._r,255)*100)+`%, `+Math.round(tC(this._g,255)*100)+`%, `+Math.round(tC(this._b,255)*100)+`%)`:`rgba(`+Math.round(tC(this._r,255)*100)+`%, `+Math.round(tC(this._g,255)*100)+`%, `+Math.round(tC(this._b,255)*100)+`%, `+this._roundA+`)`},toName:function(){return this._a===0?`transparent`:this._a<1?!1:QS[IS(this._r,this._g,this._b,!0)]||!1},toFilter:function(e){var t=`#`+RS(this._r,this._g,this._b,this._a),n=t,r=this._gradientType?`GradientType = 1, `:``;if(e){var i=kS(e);n=`#`+RS(i._r,i._g,i._b,i._a)}return`progid:DXImageTransform.Microsoft.gradient(`+r+`startColorstr=`+t+`,endColorstr=`+n+`)`},toString:function(e){var t=!!e;e||=this._format;var n=!1,r=this._a<1&&this._a>=0;return!t&&r&&(e===`hex`||e===`hex6`||e===`hex3`||e===`hex4`||e===`hex8`||e===`name`)?e===`name`&&this._a===0?this.toName():this.toRgbString():(e===`rgb`&&(n=this.toRgbString()),e===`prgb`&&(n=this.toPercentageRgbString()),(e===`hex`||e===`hex6`)&&(n=this.toHexString()),e===`hex3`&&(n=this.toHexString(!0)),e===`hex4`&&(n=this.toHex8String(!0)),e===`hex8`&&(n=this.toHex8String()),e===`name`&&(n=this.toName()),e===`hsl`&&(n=this.toHslString()),e===`hsv`&&(n=this.toHsvString()),n||this.toHexString())},clone:function(){return kS(this.toString())},_applyModification:function(e,t){var n=e.apply(null,[this].concat([].slice.call(t)));return this._r=n._r,this._g=n._g,this._b=n._b,this.setAlpha(n._a),this},lighten:function(){return this._applyModification(HS,arguments)},brighten:function(){return this._applyModification(US,arguments)},darken:function(){return this._applyModification(WS,arguments)},desaturate:function(){return this._applyModification(zS,arguments)},saturate:function(){return this._applyModification(BS,arguments)},greyscale:function(){return this._applyModification(VS,arguments)},spin:function(){return this._applyModification(GS,arguments)},_applyCombination:function(e,t){return e.apply(null,[this].concat([].slice.call(t)))},analogous:function(){return this._applyCombination(YS,arguments)},complement:function(){return this._applyCombination(KS,arguments)},monochromatic:function(){return this._applyCombination(XS,arguments)},splitcomplement:function(){return this._applyCombination(JS,arguments)},triad:function(){return this._applyCombination(qS,[3])},tetrad:function(){return this._applyCombination(qS,[4])}},kS.fromRatio=function(e,t){if(ES(e)==`object`){var n={};for(var r in e)e.hasOwnProperty(r)&&(r===`a`?n[r]=e[r]:n[r]=sC(e[r]));e=n}return kS(e,t)};function AS(e){var t={r:0,g:0,b:0},n=1,r=null,i=null,a=null,o=!1,s=!1;return typeof e==`string`&&(e=fC(e)),ES(e)==`object`&&(dC(e.r)&&dC(e.g)&&dC(e.b)?(t=jS(e.r,e.g,e.b),o=!0,s=String(e.r).substr(-1)===`%`?`prgb`:`rgb`):dC(e.h)&&dC(e.s)&&dC(e.v)?(r=sC(e.s),i=sC(e.v),t=FS(e.h,r,i),o=!0,s=`hsv`):dC(e.h)&&dC(e.s)&&dC(e.l)&&(r=sC(e.s),a=sC(e.l),t=NS(e.h,r,a),o=!0,s=`hsl`),e.hasOwnProperty(`a`)&&(n=e.a)),n=eC(n),{ok:o,format:e.format||s,r:Math.min(255,Math.max(t.r,0)),g:Math.min(255,Math.max(t.g,0)),b:Math.min(255,Math.max(t.b,0)),a:n}}function jS(e,t,n){return{r:tC(e,255)*255,g:tC(t,255)*255,b:tC(n,255)*255}}function MS(e,t,n){e=tC(e,255),t=tC(t,255),n=tC(n,255);var r=Math.max(e,t,n),i=Math.min(e,t,n),a,o,s=(r+i)/2;if(r==i)a=o=0;else{var c=r-i;switch(o=s>.5?c/(2-r-i):c/(r+i),r){case e:a=(t-n)/c+(t1&&--n,n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*(2/3-n)*6:e}if(t===0)r=i=a=n;else{var s=n<.5?n*(1+t):n+t-n*t,c=2*n-s;r=o(c,s,e+1/3),i=o(c,s,e),a=o(c,s,e-1/3)}return{r:r*255,g:i*255,b:a*255}}function PS(e,t,n){e=tC(e,255),t=tC(t,255),n=tC(n,255);var r=Math.max(e,t,n),i=Math.min(e,t,n),a,o,s=r,c=r-i;if(o=r===0?0:c/r,r==i)a=0;else{switch(r){case e:a=(t-n)/c+(t>1)+720)%360;--t;)r.h=(r.h+i)%360,a.push(kS(r));return a}function XS(e,t){t||=6;for(var n=kS(e).toHsv(),r=n.h,i=n.s,a=n.v,o=[],s=1/t;t--;)o.push(kS({h:r,s:i,v:a})),a=(a+s)%1;return o}kS.mix=function(e,t,n){n=n===0?0:n||50;var r=kS(e).toRgb(),i=kS(t).toRgb(),a=n/100;return kS({r:(i.r-r.r)*a+r.r,g:(i.g-r.g)*a+r.g,b:(i.b-r.b)*a+r.b,a:(i.a-r.a)*a+r.a})},kS.readability=function(e,t){var n=kS(e),r=kS(t);return(Math.max(n.getLuminance(),r.getLuminance())+.05)/(Math.min(n.getLuminance(),r.getLuminance())+.05)},kS.isReadable=function(e,t,n){var r=kS.readability(e,t),i,a=!1;switch(i=pC(n),i.level+i.size){case`AAsmall`:case`AAAlarge`:a=r>=4.5;break;case`AAlarge`:a=r>=3;break;case`AAAsmall`:a=r>=7;break}return a},kS.mostReadable=function(e,t,n){var r=null,i=0,a,o,s,c;n||={},o=n.includeFallbackColors,s=n.level,c=n.size;for(var l=0;li&&(i=a,r=kS(t[l]));return kS.isReadable(e,r,{level:s,size:c})||!o?r:(n.includeFallbackColors=!1,kS.mostReadable(e,[`#fff`,`#000`],n))};var ZS=kS.names={aliceblue:`f0f8ff`,antiquewhite:`faebd7`,aqua:`0ff`,aquamarine:`7fffd4`,azure:`f0ffff`,beige:`f5f5dc`,bisque:`ffe4c4`,black:`000`,blanchedalmond:`ffebcd`,blue:`00f`,blueviolet:`8a2be2`,brown:`a52a2a`,burlywood:`deb887`,burntsienna:`ea7e5d`,cadetblue:`5f9ea0`,chartreuse:`7fff00`,chocolate:`d2691e`,coral:`ff7f50`,cornflowerblue:`6495ed`,cornsilk:`fff8dc`,crimson:`dc143c`,cyan:`0ff`,darkblue:`00008b`,darkcyan:`008b8b`,darkgoldenrod:`b8860b`,darkgray:`a9a9a9`,darkgreen:`006400`,darkgrey:`a9a9a9`,darkkhaki:`bdb76b`,darkmagenta:`8b008b`,darkolivegreen:`556b2f`,darkorange:`ff8c00`,darkorchid:`9932cc`,darkred:`8b0000`,darksalmon:`e9967a`,darkseagreen:`8fbc8f`,darkslateblue:`483d8b`,darkslategray:`2f4f4f`,darkslategrey:`2f4f4f`,darkturquoise:`00ced1`,darkviolet:`9400d3`,deeppink:`ff1493`,deepskyblue:`00bfff`,dimgray:`696969`,dimgrey:`696969`,dodgerblue:`1e90ff`,firebrick:`b22222`,floralwhite:`fffaf0`,forestgreen:`228b22`,fuchsia:`f0f`,gainsboro:`dcdcdc`,ghostwhite:`f8f8ff`,gold:`ffd700`,goldenrod:`daa520`,gray:`808080`,green:`008000`,greenyellow:`adff2f`,grey:`808080`,honeydew:`f0fff0`,hotpink:`ff69b4`,indianred:`cd5c5c`,indigo:`4b0082`,ivory:`fffff0`,khaki:`f0e68c`,lavender:`e6e6fa`,lavenderblush:`fff0f5`,lawngreen:`7cfc00`,lemonchiffon:`fffacd`,lightblue:`add8e6`,lightcoral:`f08080`,lightcyan:`e0ffff`,lightgoldenrodyellow:`fafad2`,lightgray:`d3d3d3`,lightgreen:`90ee90`,lightgrey:`d3d3d3`,lightpink:`ffb6c1`,lightsalmon:`ffa07a`,lightseagreen:`20b2aa`,lightskyblue:`87cefa`,lightslategray:`789`,lightslategrey:`789`,lightsteelblue:`b0c4de`,lightyellow:`ffffe0`,lime:`0f0`,limegreen:`32cd32`,linen:`faf0e6`,magenta:`f0f`,maroon:`800000`,mediumaquamarine:`66cdaa`,mediumblue:`0000cd`,mediumorchid:`ba55d3`,mediumpurple:`9370db`,mediumseagreen:`3cb371`,mediumslateblue:`7b68ee`,mediumspringgreen:`00fa9a`,mediumturquoise:`48d1cc`,mediumvioletred:`c71585`,midnightblue:`191970`,mintcream:`f5fffa`,mistyrose:`ffe4e1`,moccasin:`ffe4b5`,navajowhite:`ffdead`,navy:`000080`,oldlace:`fdf5e6`,olive:`808000`,olivedrab:`6b8e23`,orange:`ffa500`,orangered:`ff4500`,orchid:`da70d6`,palegoldenrod:`eee8aa`,palegreen:`98fb98`,paleturquoise:`afeeee`,palevioletred:`db7093`,papayawhip:`ffefd5`,peachpuff:`ffdab9`,peru:`cd853f`,pink:`ffc0cb`,plum:`dda0dd`,powderblue:`b0e0e6`,purple:`800080`,rebeccapurple:`663399`,red:`f00`,rosybrown:`bc8f8f`,royalblue:`4169e1`,saddlebrown:`8b4513`,salmon:`fa8072`,sandybrown:`f4a460`,seagreen:`2e8b57`,seashell:`fff5ee`,sienna:`a0522d`,silver:`c0c0c0`,skyblue:`87ceeb`,slateblue:`6a5acd`,slategray:`708090`,slategrey:`708090`,snow:`fffafa`,springgreen:`00ff7f`,steelblue:`4682b4`,tan:`d2b48c`,teal:`008080`,thistle:`d8bfd8`,tomato:`ff6347`,turquoise:`40e0d0`,violet:`ee82ee`,wheat:`f5deb3`,white:`fff`,whitesmoke:`f5f5f5`,yellow:`ff0`,yellowgreen:`9acd32`},QS=kS.hexNames=$S(ZS);function $S(e){var t={};for(var n in e)e.hasOwnProperty(n)&&(t[e[n]]=n);return t}function eC(e){return e=parseFloat(e),(isNaN(e)||e<0||e>1)&&(e=1),e}function tC(e,t){iC(e)&&(e=`100%`);var n=aC(e);return e=Math.min(t,Math.max(0,parseFloat(e))),n&&(e=parseInt(e*t,10)/100),Math.abs(e-t)<1e-6?1:e%t/parseFloat(t)}function nC(e){return Math.min(1,Math.max(0,e))}function rC(e){return parseInt(e,16)}function iC(e){return typeof e==`string`&&e.indexOf(`.`)!=-1&&parseFloat(e)===1}function aC(e){return typeof e==`string`&&e.indexOf(`%`)!=-1}function oC(e){return e.length==1?`0`+e:``+e}function sC(e){return e<=1&&(e=e*100+`%`),e}function cC(e){return Math.round(parseFloat(e)*255).toString(16)}function lC(e){return rC(e)/255}var uC=function(){var e=`(?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?)`,t=`[\\s|\\(]+(`+e+`)[,|\\s]+(`+e+`)[,|\\s]+(`+e+`)\\s*\\)?`,n=`[\\s|\\(]+(`+e+`)[,|\\s]+(`+e+`)[,|\\s]+(`+e+`)[,|\\s]+(`+e+`)\\s*\\)?`;return{CSS_UNIT:new RegExp(e),rgb:RegExp(`rgb`+t),rgba:RegExp(`rgba`+n),hsl:RegExp(`hsl`+t),hsla:RegExp(`hsla`+n),hsv:RegExp(`hsv`+t),hsva:RegExp(`hsva`+n),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex4:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/}}();function dC(e){return!!uC.CSS_UNIT.exec(e)}function fC(e){e=e.replace(DS,``).replace(OS,``).toLowerCase();var t=!1;if(ZS[e])e=ZS[e],t=!0;else if(e==`transparent`)return{r:0,g:0,b:0,a:0,format:`name`};var n;return(n=uC.rgb.exec(e))?{r:n[1],g:n[2],b:n[3]}:(n=uC.rgba.exec(e))?{r:n[1],g:n[2],b:n[3],a:n[4]}:(n=uC.hsl.exec(e))?{h:n[1],s:n[2],l:n[3]}:(n=uC.hsla.exec(e))?{h:n[1],s:n[2],l:n[3],a:n[4]}:(n=uC.hsv.exec(e))?{h:n[1],s:n[2],v:n[3]}:(n=uC.hsva.exec(e))?{h:n[1],s:n[2],v:n[3],a:n[4]}:(n=uC.hex8.exec(e))?{r:rC(n[1]),g:rC(n[2]),b:rC(n[3]),a:lC(n[4]),format:t?`name`:`hex8`}:(n=uC.hex6.exec(e))?{r:rC(n[1]),g:rC(n[2]),b:rC(n[3]),format:t?`name`:`hex`}:(n=uC.hex4.exec(e))?{r:rC(n[1]+``+n[1]),g:rC(n[2]+``+n[2]),b:rC(n[3]+``+n[3]),a:lC(n[4]+``+n[4]),format:t?`name`:`hex8`}:(n=uC.hex3.exec(e))?{r:rC(n[1]+``+n[1]),g:rC(n[2]+``+n[2]),b:rC(n[3]+``+n[3]),format:t?`name`:`hex`}:!1}function pC(e){var t,n;return e||={level:`AA`,size:`small`},t=(e.level||`AA`).toUpperCase(),n=(e.size||`small`).toLowerCase(),t!==`AA`&&t!==`AAA`&&(t=`AA`),n!==`small`&&n!==`large`&&(n=`small`),{level:t,size:n}}function mC(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n{(function(n,r){typeof e==`object`&&typeof t==`object`?t.exports=r():typeof define==`function`&&define.amd?define(`FrameTicker`,[],r):typeof e==`object`?e.FrameTicker=r():n.FrameTicker=r()})(e,function(){return function(e){function t(r){if(n[r])return n[r].exports;var i=n[r]={exports:{},id:r,loaded:!1};return e[r].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var n={};return t.m=e,t.c=n,t.p=``,t(0)}([function(e,t,n){var r=n(1),i=function(){function e(e,t,n){e===void 0&&(e=NaN),t===void 0&&(t=NaN),n===void 0&&(n=!1),this._minFPS=t,this._maxFPS=e,this._timeScale=1,this._currentTick=0,this._currentTime=0,this._tickDeltaTime=0,this._isRunning=!1,this._maxInterval=isNaN(this._minFPS)?NaN:1e3/this._minFPS,this._minInterval=isNaN(this._maxFPS)?NaN:1e3/this._maxFPS,this._onResume=new r.default,this._onPause=new r.default,this._onTick=new r.default,this._onTickOncePerFrame=new r.default,n||this.resume()}return e.prototype.updateOnce=function(e){e(this.currentTimeSeconds,this.tickDeltaTimeSeconds,this.currentTick)},e.prototype.resume=function(){this._isRunning||(this._isRunning=!0,this._lastTimeUpdated=this.getTimer(),this._onResume.dispatch(),this.animateOnce())},e.prototype.pause=function(){this._isRunning&&(this._isRunning=!1,this._onPause.dispatch(),window.cancelAnimationFrame(this._animationFrameHandle))},e.prototype.dispose=function(){this.pause(),this._onResume.removeAll(),this._onPause.removeAll(),this._onTick.removeAll()},Object.defineProperty(e.prototype,`currentTick`,{get:function(){return this._currentTick},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,`currentTimeSeconds`,{get:function(){return this._currentTime/1e3},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,`tickDeltaTimeSeconds`,{get:function(){return this._tickDeltaTime/1e3},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,`timeScale`,{get:function(){return this._timeScale},set:function(e){this._timeScale!==e&&(this._timeScale=e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,`onResume`,{get:function(){return this._onResume},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,`onPause`,{get:function(){return this._onPause},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,`onTick`,{get:function(){return this._onTick},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,`onTickOncePerFrame`,{get:function(){return this._onTickOncePerFrame},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,`isRunning`,{get:function(){return this._isRunning},enumerable:!0,configurable:!0}),e.prototype.animateOnce=function(){var e=this;this._animationFrameHandle=window.requestAnimationFrame(function(){return e.onFrame()})},e.prototype.onFrame=function(){if(this._now=this.getTimer(),this._frameDeltaTime=this._now-this._lastTimeUpdated,isNaN(this._minInterval)||this._frameDeltaTime>=this._minInterval)if(isNaN(this._maxInterval))this.update(this._frameDeltaTime*this._timeScale,!0),this._lastTimeUpdated=this._now;else for(this._interval=Math.min(this._frameDeltaTime,this._maxInterval);this._now>=this._lastTimeUpdated+this._interval;)this.update(this._interval*this._timeScale,this._now<=this._lastTimeUpdated+2*this._maxInterval),this._lastTimeUpdated+=this._interval;this._isRunning&&this.animateOnce()},e.prototype.update=function(e,t){t===void 0&&(t=!0),this._currentTick++,this._currentTime+=e,this._tickDeltaTime=e,this._onTick.dispatch(this.currentTimeSeconds,this.tickDeltaTimeSeconds,this.currentTick),t&&this._onTickOncePerFrame.dispatch(this.currentTimeSeconds,this.tickDeltaTimeSeconds,this.currentTick)},e.prototype.getTimer=function(){return Date.now()},e}();Object.defineProperty(t,`__esModule`,{value:!0}),t.default=i},function(e,t,n){(function(t,n){e.exports=n()})(this,function(){return function(e){function t(r){if(n[r])return n[r].exports;var i=n[r]={exports:{},id:r,loaded:!1};return e[r].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var n={};return t.m=e,t.c=n,t.p=``,t(0)}([function(e,t){var n=function(){function e(){this.functions=[]}return e.prototype.add=function(e){return this.functions.indexOf(e)===-1&&(this.functions.push(e),!0)},e.prototype.remove=function(e){var t=this.functions.indexOf(e);return t>-1&&(this.functions.splice(t,1),!0)},e.prototype.removeAll=function(){return this.functions.length>0&&(this.functions.length=0,!0)},e.prototype.dispatch=function(){var e=[...arguments];this.functions.concat().forEach(function(t){t.apply(void 0,e)})},Object.defineProperty(e.prototype,`numItems`,{get:function(){return this.functions.length},enumerable:!0,configurable:!0}),e}();Object.defineProperty(t,`__esModule`,{value:!0}),t.default=n}])})}])})}))(),1);const HC=11102230246251565e-32,UC=134217729;(3+8*HC)*HC;function WC(e,t,n,r,i){let a,o,s,c,l=t[0],u=r[0],d=0,f=0;u>l==u>-l?(a=l,l=t[++d]):(a=u,u=r[++f]);let p=0;if(dl==u>-l?(o=l+a,s=a-(o-l),l=t[++d]):(o=u+a,s=a-(o-u),u=r[++f]),a=o,s!==0&&(i[p++]=s);dl==u>-l?(o=a+l,c=o-a,s=a-(o-c)+(l-c),l=t[++d]):(o=a+u,c=o-a,s=a-(o-c)+(u-c),u=r[++f]),a=o,s!==0&&(i[p++]=s);for(;d=A||-k>=A||(d=e-T,s=e-(T+d)+(d-i),d=n-E,l=n-(E+d)+(d-i),d=t-D,c=t-(D+d)+(d-a),d=r-O,u=r-(O+d)+(d-a),s===0&&c===0&&l===0&&u===0)||(A=gee*o+33306690738754706e-32*Math.abs(k),k+=T*u+O*s-(D*l+E*c),k>=A||-k>=A))return k;b=s*O,f=UC*s,p=f-(f-s),m=s-p,f=UC*O,h=f-(f-O),g=O-h,x=m*g-(b-p*h-m*h-p*g),S=c*E,f=UC*c,p=f-(f-c),m=c-p,f=UC*E,h=f-(f-E),g=E-h,C=m*g-(S-p*h-m*h-p*g),_=x-C,d=x-_,XC[0]=x-(_+d)+(d-C),v=b+_,d=v-b,y=b-(v-d)+(_-d),_=y-S,d=y-_,XC[1]=y-(_+d)+(d-S),w=v+_,d=w-v,XC[2]=v-(w-d)+(_-d),XC[3]=w;let j=WC(4,KC,4,XC,qC);b=T*u,f=UC*T,p=f-(f-T),m=T-p,f=UC*u,h=f-(f-u),g=u-h,x=m*g-(b-p*h-m*h-p*g),S=D*l,f=UC*D,p=f-(f-D),m=D-p,f=UC*l,h=f-(f-l),g=l-h,C=m*g-(S-p*h-m*h-p*g),_=x-C,d=x-_,XC[0]=x-(_+d)+(d-C),v=b+_,d=v-b,y=b-(v-d)+(_-d),_=y-S,d=y-_,XC[1]=y-(_+d)+(d-S),w=v+_,d=w-v,XC[2]=v-(w-d)+(_-d),XC[3]=w;let M=WC(j,qC,4,XC,JC);return b=s*u,f=UC*s,p=f-(f-s),m=s-p,f=UC*u,h=f-(f-u),g=u-h,x=m*g-(b-p*h-m*h-p*g),S=c*l,f=UC*c,p=f-(f-c),m=c-p,f=UC*l,h=f-(f-l),g=l-h,C=m*g-(S-p*h-m*h-p*g),_=x-C,d=x-_,XC[0]=x-(_+d)+(d-C),v=b+_,d=v-b,y=b-(v-d)+(_-d),_=y-S,d=y-_,XC[1]=y-(_+d)+(d-S),w=v+_,d=w-v,XC[2]=v-(w-d)+(_-d),XC[3]=w,YC[WC(M,JC,4,XC,YC)-1]}function QC(e,t,n,r,i,a){let o=(t-a)*(n-i),s=(e-i)*(r-a),c=o-s,l=Math.abs(o+s);return Math.abs(c)>=mee*l?c:-ZC(e,t,n,r,i,a,l)}(7+56*HC)*HC,(3+28*HC)*HC,(26+288*HC)*HC*HC,GC(4),GC(4),GC(4),GC(4),GC(4),GC(4),GC(4),GC(4),GC(4),GC(8),GC(8),GC(8),GC(4),GC(8),GC(8),GC(16),GC(12),GC(192),GC(192),(10+96*HC)*HC,(4+48*HC)*HC,(44+576*HC)*HC*HC,GC(4),GC(4),GC(4),GC(4),GC(4),GC(4),GC(4),GC(4),GC(8),GC(8),GC(8),GC(8),GC(8),GC(8),GC(8),GC(8),GC(8),GC(4),GC(4),GC(4),GC(8),GC(16),GC(16),GC(16),GC(32),GC(32),GC(48),GC(64),GC(1152),GC(1152),(16+224*HC)*HC,(5+72*HC)*HC,(71+1408*HC)*HC*HC,GC(4),GC(4),GC(4),GC(4),GC(4),GC(4),GC(4),GC(4),GC(4),GC(4),GC(24),GC(24),GC(24),GC(24),GC(24),GC(24),GC(24),GC(24),GC(24),GC(24),GC(1152),GC(1152),GC(1152),GC(1152),GC(1152),GC(2304),GC(2304),GC(3456),GC(5760),GC(8),GC(8),GC(8),GC(16),GC(24),GC(48),GC(48),GC(96),GC(192),GC(384),GC(384),GC(384),GC(768),GC(96),GC(96),GC(96),GC(1152);var $C=2**-52,ew=new Uint32Array(512),tw=class e{static from(t,n=_ee,r=lw){let i=t.length,a=new Float64Array(i*2);for(let e=0;e>1;if(t>0&&typeof e[0]!=`number`)throw Error(`Expected coords to contain numbers.`);this.coords=e;let n=Math.max(2*t-5,0);this._triangles=new Uint32Array(n*3),this._halfedges=new Int32Array(n*3),this._hashSize=Math.ceil(Math.sqrt(t)),this._hullPrev=new Uint32Array(t),this._hullNext=new Uint32Array(t),this._hullTri=new Uint32Array(t),this._hullHash=new Int32Array(this._hashSize),this._ids=new Uint32Array(t),this._dists=new Float64Array(t),this.trianglesLen=0,this._cx=0,this._cy=0,this._hullStart=0,this.hull=this._triangles,this.triangles=this._triangles,this.halfedges=this._halfedges,this.update()}update(){let{coords:e,_hullPrev:t,_hullNext:n,_hullTri:r,_hullHash:i}=this,a=e.length>>1,o=1/0,s=1/0,c=-1/0,l=-1/0;for(let t=0;tc&&(c=n),r>l&&(l=r),this._ids[t]=t}let u=(o+c)/2,d=(s+l)/2,f=0,p=0,m=0;for(let t=0,n=1/0;t0&&(p=t,n=r)}let _=e[2*p],v=e[2*p+1],y=1/0;for(let t=0;tr&&(t[n++]=i,r=a)}this.hull=t.subarray(0,n),this.triangles=new Uint32Array,this.halfedges=new Int32Array;return}if(QC(h,g,_,v,b,x)<0){let e=p,t=_,n=v;p=m,_=b,v=x,m=e,b=t,x=n}let S=ow(h,g,_,v,b,x);this._cx=S.x,this._cy=S.y;for(let t=0;t0&&Math.abs(l-o)<=$C&&Math.abs(u-s)<=$C||(o=l,s=u,c===f||c===p||c===m))continue;let d=0;for(let e=0,t=this._hashKey(l,u);e=0;)if(h=g,h===d){h=-1;break}if(h===-1)continue;let _=this._addTriangle(h,c,n[h],-1,-1,r[h]);r[c]=this._legalize(_+2),r[h]=_,C++;let v=n[h];for(;g=n[v],QC(l,u,e[2*v],e[2*v+1],e[2*g],e[2*g+1])<0;)_=this._addTriangle(v,c,g,r[c],-1,r[v]),r[c]=this._legalize(_+2),n[v]=v,C--,v=g;if(h===d)for(;g=t[h],QC(l,u,e[2*g],e[2*g+1],e[2*h],e[2*h+1])<0;)_=this._addTriangle(g,c,h,-1,r[h],r[g]),this._legalize(_+2),r[g]=_,n[h]=h,C--,h=g;this._hullStart=t[c]=h,n[h]=t[v]=c,n[c]=v,i[this._hashKey(l,u)]=c,i[this._hashKey(e[2*h],e[2*h+1])]=h}this.hull=new Uint32Array(C);for(let e=0,t=this._hullStart;e0?3-n:1+n)/4}function rw(e,t,n,r){let i=e-n,a=t-r;return i*i+a*a}function iw(e,t,n,r,i,a,o,s){let c=e-o,l=t-s,u=n-o,d=r-s,f=i-o,p=a-s,m=c*c+l*l,h=u*u+d*d,g=f*f+p*p;return c*(d*g-h*p)-l*(u*g-h*f)+m*(u*p-d*f)<0}function aw(e,t,n,r,i,a){let o=n-e,s=r-t,c=i-e,l=a-t,u=o*o+s*s,d=c*c+l*l,f=.5/(o*l-s*c),p=(l*u-s*d)*f,m=(o*d-c*u)*f;return p*p+m*m}function ow(e,t,n,r,i,a){let o=n-e,s=r-t,c=i-e,l=a-t,u=o*o+s*s,d=c*c+l*l,f=.5/(o*l-s*c);return{x:e+(l*u-s*d)*f,y:t+(o*d-c*u)*f}}function sw(e,t,n,r){if(r-n<=20)for(let i=n+1;i<=r;i++){let r=e[i],a=t[r],o=i-1;for(;o>=n&&t[e[o]]>a;)e[o+1]=e[o--];e[o+1]=r}else{let i=n+r>>1,a=n+1,o=r;cw(e,i,a),t[e[n]]>t[e[r]]&&cw(e,n,r),t[e[a]]>t[e[r]]&&cw(e,a,r),t[e[n]]>t[e[a]]&&cw(e,n,a);let s=e[a],c=t[s];for(;;){do a++;while(t[e[a]]c);if(o=o-n?(sw(e,t,a,r),sw(e,t,n,o-1)):(sw(e,t,n,o-1),sw(e,t,a,r))}}function cw(e,t,n){let r=e[t];e[t]=e[n],e[n]=r}function _ee(e){return e[0]}function lw(e){return e[1]}function uw(e,t){var n,r,i=0,a,o,s,c,l,u,d,f=e[0],p=e[1],m=t.length;for(n=0;n=0||o<=0&&c>=0)return 0}else if(l>=0&&s<=0||l<=0&&s>=0){if(a=QC(o,c,s,l,0,0),a===0)return 0;(a>0&&l>0&&s<=0||a<0&&l<=0&&s>0)&&i++}u=d,s=l,o=c}}return i%2!=0}function dw(e){if(!e)throw Error(`coord is required`);if(!Array.isArray(e)){if(e.type===`Feature`&&e.geometry!==null&&e.geometry.type===`Point`)return[...e.geometry.coordinates];if(e.type===`Point`)return[...e.coordinates]}if(Array.isArray(e)&&e.length>=2&&!Array.isArray(e[0])&&!Array.isArray(e[1]))return[...e];throw Error(`coord must be GeoJSON Point or an Array of numbers`)}function fw(e){return e.type===`Feature`?e.geometry:e}function pw(e,t,n={}){if(!e)throw Error(`point is required`);if(!t)throw Error(`polygon is required`);let r=dw(e),i=fw(t),a=i.type,o=t.bbox,s=i.coordinates;if(o&&mw(r,o)===!1)return!1;a===`Polygon`&&(s=[s]);let c=!1;for(var l=0;l=e[0]&&t[3]>=e[1]}var hw=pw,gw=1e-6,_w=class{constructor(){this._x0=this._y0=this._x1=this._y1=null,this._=``}moveTo(e,t){this._+=`M${this._x0=this._x1=+e},${this._y0=this._y1=+t}`}closePath(){this._x1!==null&&(this._x1=this._x0,this._y1=this._y0,this._+=`Z`)}lineTo(e,t){this._+=`L${this._x1=+e},${this._y1=+t}`}arc(e,t,n){e=+e,t=+t,n=+n;let r=e+n,i=t;if(n<0)throw Error(`negative radius`);this._x1===null?this._+=`M${r},${i}`:(Math.abs(this._x1-r)>gw||Math.abs(this._y1-i)>gw)&&(this._+=`L`+r+`,`+i),n&&(this._+=`A${n},${n},0,1,1,${e-n},${t}A${n},${n},0,1,1,${this._x1=r},${this._y1=i}`)}rect(e,t,n,r){this._+=`M${this._x0=this._x1=+e},${this._y0=this._y1=+t}h${+n}v${+r}h${-n}Z`}value(){return this._||null}},vw=class{constructor(){this._=[]}moveTo(e,t){this._.push([e,t])}closePath(){this._.push(this._[0].slice())}lineTo(e,t){this._.push([e,t])}value(){return this._.length?this._:null}},yw=class{constructor(e,[t,n,r,i]=[0,0,960,500]){if(!((r=+r)>=(t=+t))||!((i=+i)>=(n=+n)))throw Error(`invalid bounds`);this.delaunay=e,this._circumcenters=new Float64Array(e.points.length*2),this.vectors=new Float64Array(e.points.length*2),this.xmax=r,this.xmin=t,this.ymax=i,this.ymin=n,this._init()}update(){return this.delaunay.update(),this._init(),this}_init(){let{delaunay:{points:e,hull:t,triangles:n},vectors:r}=this,i,a,o=this.circumcenters=this._circumcenters.subarray(0,n.length/3*2);for(let r=0,s=0,c=n.length,l,u;r1;)i-=2;for(let e=2;e0){if(t>=this.ymax)return null;(a=(this.ymax-t)/r)0){if(e>=this.xmax)return null;(a=(this.xmax-e)/n)this.xmax?2:0)|(tthis.ymax?8:0)}_simplify(e){if(e&&e.length>4){for(let t=0;t1e-10)return!1}return!0}function Tw(e,t,n){return[e+Math.sin(e+t)*n,t+Math.cos(e-t)*n]}var Ew=class e{static from(t,n=Sw,r=Cw,i){return new e(`length`in t?Dw(t,n,r,i):Float64Array.from(Ow(t,n,r,i)))}constructor(e){this._delaunator=new tw(e),this.inedges=new Int32Array(e.length/2),this._hullIndex=new Int32Array(e.length/2),this.points=this._delaunator.coords,this._init()}update(){return this._delaunator.update(),this._init(),this}_init(){let e=this._delaunator,t=this.points;if(e.hull&&e.hull.length>2&&ww(e)){this.collinear=Int32Array.from({length:t.length/2},(e,t)=>t).sort((e,n)=>t[2*e]-t[2*n]||t[2*e+1]-t[2*n+1]);let e=this.collinear[0],n=this.collinear[this.collinear.length-1],r=[t[2*e],t[2*e+1],t[2*n],t[2*n+1]],i=1e-8*Math.hypot(r[3]-r[1],r[2]-r[0]);for(let e=0,n=t.length/2;e0&&(this.triangles=new Int32Array(3).fill(-1),this.halfedges=new Int32Array(3).fill(-1),this.triangles[0]=r[0],a[r[0]]=1,r.length===2&&(a[r[1]]=0,this.triangles[1]=r[1],this.triangles[2]=r[1]))}voronoi(e){return new yw(this,e)}*neighbors(e){let{inedges:t,hull:n,_hullIndex:r,halfedges:i,triangles:a,collinear:o}=this;if(o){let t=o.indexOf(e);t>0&&(yield o[t-1]),t=0&&i!==n&&i!==r;)n=i;return i}_step(e,t,n){let{inedges:r,hull:i,_hullIndex:a,halfedges:o,triangles:s,points:c}=this;if(r[e]===-1||!c.length)return(e+1)%(c.length>>1);let l=e,u=xw(t-c[e*2],2)+xw(n-c[e*2+1],2),d=r[e],f=d;do{let r=s[f],d=xw(t-c[r*2],2)+xw(n-c[r*2+1],2);if(d0?1:e<0?-1:0},zw=Math.sqrt;function Bw(e){return e>1?Aw:e<-1?-Aw:Math.asin(e)}function Vw(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function Hw(e,t){return[e[1]*t[2]-e[2]*t[1],e[2]*t[0]-e[0]*t[2],e[0]*t[1]-e[1]*t[0]]}function Uw(e,t){return[e[0]+t[0],e[1]+t[1],e[2]+t[2]]}function Ww(e){var t=zw(e[0]*e[0]+e[1]*e[1]+e[2]*e[2]);return[e[0]/t,e[1]/t,e[2]/t]}function Gw(e){return[Nw(e[1],e[0])*jw,Bw(Fw(-1,Iw(1,e[2])))*jw]}function Kw(e){let t=e[0]*Mw,n=e[1]*Mw,r=Pw(n);return[r*Pw(t),r*Lw(t),Lw(n)]}function qw(e){return e=e.map(e=>Kw(e)),Vw(e[0],Hw(e[2],e[1]))}function Jw(e){let t=Xw(e),n=Qw(t),r=Zw(n,e),i=eT(n,e.length),a=Yw(i,e),{polygons:o,centers:s}=tT($w(n,e),n,e);return{delaunay:t,edges:r,triangles:n,centers:s,neighbors:i,polygons:o,mesh:vee(o),hull:iT(n,e),urquhart:rT(r,n),find:a}}function Yw(e,t){function n(e,t){let n=e[0]-t[0],r=e[1]-t[1],i=e[2]-t[2];return n*n+r*r+i*i}return function(r,i,a){a===void 0&&(a=0);let o,s,c=a,l=Kw([r,i]);do o=a,a=null,s=n(l,Kw(t[o])),e[o].forEach(e=>{let r=n(l,Kw(t[e]));if(r1e32?i.push(t):n>a&&(a=n)}let o=1e6*zw(a);i.forEach(t=>e[t]=[o,0]),e.push([0,o]),e.push([-o,0]),e.push([0,-o]);let s=Ew.from(e);s.projection=r;let{triangles:c,halfedges:l,inedges:u}=s,d=[];for(let n=0,r=l.length;ne.length-3-1&&(c[n]=t);return s}function Zw(e,t){let n=new Set;return t.length===2?[[0,1]]:(e.forEach(e=>{if(e[0]!==e[1]&&!(qw(e.map(e=>t[e]))<0))for(let t=0,r;t<3;t++)r=(t+1)%3,n.add(pm([e[t],e[r]]).join(`-`))}),Array.from(n,e=>e.split(`-`).map(Number)))}function Qw(e){let{triangles:t}=e;if(!t)return[];let n=[];for(let e=0,r=t.length/3;e{let n=e.map(e=>t[e]).map(Kw);return Gw(Ww(Uw(Uw(Hw(n[1],n[0]),Hw(n[2],n[1])),Hw(n[0],n[2]))))})}function eT(e,t){let n=[];return e.forEach(e=>{for(let t=0;t<3;t++){let r=e[t],i=e[(t+1)%3];n[r]=n[r]||[],n[r].push(i)}}),e.length===0&&(t===2?(n[0]=[1],n[1]=[0]):t===1&&(n[0]=[])),n}function tT(e,t,n){let r=[],i=e.slice();if(t.length===0){if(n.length<2)return{polygons:r,centers:i};if(n.length===2){let e=Kw(n[0]),t=Kw(n[1]),a=Ww(Uw(e,t)),s=Hw(a,Ww(Hw(e,t))),c=[a,Hw(a,s),Hw(Hw(a,s),s),Hw(Hw(Hw(a,s),s),s)].map(Gw).map(o);return r.push(c),r.push(c.slice().reverse()),{polygons:r,centers:i}}}t.forEach((e,t)=>{for(let n=0;n<3;n++){let i=e[n],a=e[(n+1)%3],o=e[(n+2)%3];r[i]=r[i]||[],r[i].push([a,o,t,[i,a,o]])}});let a=r.map(e=>{let t=[e[0][2]],r=e[0][1];for(let n=1;n2)return t;if(t.length==2){let r=nT(n[e[0][3][0]],n[e[0][3][1]],i[t[0]]),a=nT(n[e[0][3][2]],n[e[0][3][0]],i[t[0]]),s=o(r),c=o(a);return[t[0],c,t[1],s]}});function o(e){let n=-1;return i.slice(t.length,1/0).forEach((r,i)=>{r[0]===e[0]&&r[1]===e[1]&&(n=i+t.length)}),n<0&&(n=i.length,i.push(e)),n}return{polygons:a,centers:i}}function nT(e,t,n){e=Kw(e),t=Kw(t),n=Kw(n);let r=Rw(Vw(Hw(t,e),n));return Gw(Ww(Uw(e,t)).map(e=>r*e))}function vee(e){let t=[];return e.forEach(e=>{if(!e)return;let n=e[e.length-1];for(let r of e)r>n&&t.push([n,r]),n=r}),t}function rT(e,t){return function(n){let r=new Map,i=new Map;return e.forEach((e,t)=>{let a=e.join(`-`);r.set(a,n[t]),i.set(a,!0)}),t.forEach(e=>{let t=0,n=-1;for(let i=0;i<3;i++){let a=pm([e[i],e[(i+1)%3]]).join(`-`);r.get(a)>t&&(t=r.get(a),n=a)}i.set(n,!1)}),e.map(e=>i.get(e.join(`-`)))}}function iT(e,t){let n=new Set,r=[];e.map(e=>{if(!(qw(e.map(e=>t[e>t.length?0:e]))>1e-12))for(let t=0;t<3;t++){let r=[e[t],e[(t+1)%3]],i=`${r[0]}-${r[1]}`;n.has(i)?n.delete(i):n.add(`${r[1]}-${r[0]}`)}});let i=new Map,a;if(n.forEach(e=>{e=e.split(`-`).map(Number),i.set(e[0],e[1]),a=e[0]}),a===void 0)return r;let o=a;do{r.push(o);let e=i.get(o);i.set(o,-1),o=e}while(o>-1&&o!==a);return r}function aT(e){let t=function(e){if(t.delaunay=null,t._data=e,typeof t._data==`object`&&t._data.type===`FeatureCollection`&&(t._data=t._data.features),typeof t._data==`object`){let e=t._data.map(e=>[t._vx(e),t._vy(e),e]).filter(e=>isFinite(e[0]+e[1]));t.points=e.map(e=>[e[0],e[1]]),t.valid=e.map(e=>e[2]),t.delaunay=Jw(t.points)}return t};return t._vx=function(e){if(typeof e==`object`&&`type`in e)return lv(e)[0];if(0 in e)return e[0]},t._vy=function(e){if(typeof e==`object`&&`type`in e)return lv(e)[1];if(1 in e)return e[1]},t.x=function(e){return e?(t._vx=e,t):t._vx},t.y=function(e){return e?(t._vy=e,t):t._vy},t.polygons=function(e){if(e!==void 0&&t(e),!t.delaunay)return!1;let n={type:`FeatureCollection`,features:[]};return t.valid.length===0?n:(t.delaunay.polygons.forEach((e,r)=>n.features.push({type:`Feature`,geometry:e?{type:`Polygon`,coordinates:[[...e,e[0]].map(e=>t.delaunay.centers[e])]}:null,properties:{site:t.valid[r],sitecoordinates:t.points[r],neighbours:t.delaunay.neighbors[r]}})),t.valid.length===1&&n.features.push({type:`Feature`,geometry:{type:`Sphere`},properties:{site:t.valid[0],sitecoordinates:t.points[0],neighbours:[]}}),n)},t.triangles=function(e){return e!==void 0&&t(e),t.delaunay?{type:`FeatureCollection`,features:t.delaunay.triangles.map((e,n)=>(e=e.map(e=>t.points[e]),e.center=t.delaunay.centers[n],e)).filter(e=>qw(e)>0).map(e=>({type:`Feature`,properties:{circumcenter:e.center},geometry:{type:`Polygon`,coordinates:[[...e,e[0]]]}}))}:!1},t.links=function(e){if(e!==void 0&&t(e),!t.delaunay)return!1;let n=t.delaunay.edges.map(e=>Xv(t.points[e[0]],t.points[e[1]])),r=t.delaunay.urquhart(n);return{type:`FeatureCollection`,features:t.delaunay.edges.map((e,i)=>({type:`Feature`,properties:{source:t.valid[e[0]],target:t.valid[e[1]],length:n[i],urquhart:!!r[i]},geometry:{type:`LineString`,coordinates:[t.points[e[0]],t.points[e[1]]]}}))}},t.mesh=function(e){return e!==void 0&&t(e),t.delaunay?{type:`MultiLineString`,coordinates:t.delaunay.edges.map(e=>[t.points[e[0]],t.points[e[1]]])}:!1},t.cellMesh=function(e){if(e!==void 0&&t(e),!t.delaunay)return!1;let{centers:n,polygons:r}=t.delaunay,i=[];for(let e of r)if(e)for(let t=e.length,r=e[t-1],a=e[0],o=0;or&&i.push([n[r],n[a]]);return{type:`MultiLineString`,coordinates:i}},t._found=void 0,t.find=function(e,n,r){if(t._found=t.delaunay.find(e,n,t._found),!r||Xv([e,n],t.points[t._found])r[e]),r[n[0]]]]}},e?t(e):t}function oT(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n1&&arguments[1]!==void 0?arguments[1]:{}).resolution,n=t===void 0?1/0:t,r=ET(e,n),i=Tm(r),a=DT(e,n),o=[].concat(CT(i),CT(a)),s={type:`Polygon`,coordinates:e},c=ST(F_(s),2),l=ST(c[0],2),u=l[0],d=l[1],f=ST(c[1],2),p=f[0],m=f[1],h=u>p||m>=89||d<=-89,g=[];if(h){var _=aT(o).triangles(),v=new Map(o.map(function(e,t){var n=ST(e,2);return[`${n[0]}-${n[1]}`,t]}));_.features.forEach(function(e){var t,n=e.geometry.coordinates[0].slice(0,3).reverse(),r=[];if(n.forEach(function(e){var t=ST(e,2),n=`${t[0]}-${t[1]}`;v.has(n)&&r.push(v.get(n))}),r.length===3){if(r.some(function(e){return et)for(var a=uy(r,e),o=1/Math.ceil(i/t),s=o;s<1;)n.push(a(s)),s+=o}n.push(r=e)}),n})}function DT(e,t){var n={type:`Polygon`,coordinates:e},r=ST(F_(n),2),i=ST(r[0],2),a=i[0],o=i[1],s=ST(r[1],2),c=s[0],l=s[1];if(Math.min(Math.abs(c-a),Math.abs(l-o))c||l>=89||o<=-89;return OT(t,{minLng:a,maxLng:c,minLat:o,maxLat:l}).filter(function(e){return kT(e,n,u)})}function OT(e){for(var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=t.minLng,r=t.maxLng,i=t.minLat,a=t.maxLat,o=Math.round((360/e)**2/Math.PI),s=(1+Math.sqrt(5))/2,c=function(e){return e/s*360%360-180},l=function(e){return Math.acos(2*e/o-1)/Math.PI*180-90},u=function(e){return o*(Math.cos((e+90)*Math.PI/180)+1)/2},d=[a===void 0?0:Math.ceil(u(a)),i===void 0?o-1:Math.floor(u(i))],f=n===void 0&&r===void 0?function(){return!0}:n===void 0?function(e){return e<=r}:r===void 0?function(e){return e>=n}:r>=n?function(e){return e>=n&&e<=r}:function(e){return e>=n||e<=r},p=[],m=d[0];m<=d[1];m++){var h=c(m);f(h)&&p.push([h,l(m)])}return p}function kT(e,t){return arguments.length>2&&arguments[2]!==void 0&&arguments[2]?ay(t,e):hw(e,t)}var AT=window.THREE?window.THREE:{BufferGeometry:Di,Float32BufferAttribute:hi},jT=new AT.BufferGeometry().setAttribute?`setAttribute`:`addAttribute`,MT=function(e){function t(e,n,r,i,a,o,s){var c;dT(this,t),c=uT(this,t),c.type=`ConicPolygonGeometry`,c.parameters={polygonGeoJson:e,bottomHeight:n,topHeight:r,closedBottom:i,closedTop:a,includeSides:o,curvatureResolution:s},n||=0,r||=1,i=i===void 0?!0:i,a=a===void 0?!0:a,o=o===void 0?!0:o,s||=5;var l=TT(e,{resolution:s}),u=l.contour,d=l.triangles,f=Tm(d.uvs),p=[],m=[],h=[],g=0,_=function(e){var t=Math.round(p.length/3),n=h.length;p=p.concat(e.vertices),m=m.concat(e.uvs),h=h.concat(t?e.indices.map(function(e){return e+t}):e.indices),c.addGroup(n,h.length-n,g++)};o&&_(y()),i&&_(b(n,!1)),a&&_(b(r,!0)),c.setIndex(h),c[jT](`position`,new AT.Float32BufferAttribute(p,3)),c[jT](`uv`,new AT.Float32BufferAttribute(m,2)),c.computeVertexNormals();function v(e,t){var n=typeof t==`function`?t:function(){return t};return Rx(e.map(function(e){return e.map(function(e){var t=ST(e,2),r=t[0],i=t[1];return NT(i,r,n(r,i))})}))}function y(){for(var e=v(u,n),t=e.vertices,i=e.holes,a=v(u,r).vertices,o=Tm([a,t]),s=Math.round(a.length/3),c=new Set(i),l=0,d=[],f=0;f=0;g--)for(var _=0;_1&&arguments[1]!==void 0)||arguments[1]?d.indices:d.indices.slice().reverse(),vertices:v([d.points],e).vertices,uvs:f}}return c}return mT(t,e),fT(t)}(AT.BufferGeometry);function NT(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,r=(90-e)*Math.PI/180,i=(90-t)*Math.PI/180;return[n*Math.sin(r)*Math.cos(i),n*Math.cos(r),n*Math.sin(r)*Math.sin(i)]}function PT(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n0&&arguments[0]!==void 0?arguments[0]:[],t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1,i=(t instanceof Array?t.length?t:[void 0]:[t]).map(function(e){return{keyAccessor:e,isProp:!(e instanceof Function)}}),a=e.reduce(function(e,t){var r=e,a=t;return i.forEach(function(e,t){var o=e.keyAccessor,s=e.isProp,c;if(s){var l=a,u=l[o],d=VT(l,[o].map(KT));c=u,a=d}else c=o(a,t);t+11&&arguments[1]!==void 0?arguments[1]:1;r===i.length?Object.keys(t).forEach(function(e){return t[e]=n(t[e])}):Object.values(t).forEach(function(t){return e(t,r+1)})})(a);var o=a;return r&&(o=[],(function e(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];n.length===i.length?o.push({keys:n,vals:t}):Object.entries(t).forEach(function(t){var r=UT(t,2),i=r[0],a=r[1];return e(a,[].concat(WT(n),[i]))})})(a),t instanceof Array&&t.length===0&&o.length===1&&(o[0].keys=[])),o}),YT=function(e){e||={};var t=e===void 0?{}:e,n={},r;for(r in t)t.hasOwnProperty(r)&&(n[r]=t[r]);var i=[],a=``;function o(e){return t.locateFile?t.locateFile(e,a):a+e}var s;typeof document<`u`&&document.currentScript&&(a=document.currentScript.src),a=a.indexOf(`blob:`)===0?``:a.substr(0,a.lastIndexOf(`/`)+1),s=function(e,t,n){var r=new XMLHttpRequest;r.open(`GET`,e,!0),r.responseType=`arraybuffer`,r.onload=function(){if(r.status==200||r.status==0&&r.response){t(r.response);return}var i=Ue(e);if(i){t(i.buffer);return}n()},r.onerror=n,r.send(null)};var c=t.print||console.log.bind(console),l=t.printErr||console.warn.bind(console);for(r in n)n.hasOwnProperty(r)&&(t[r]=n[r]);n=null,t.arguments&&(i=t.arguments);var u=0,d=function(e){u=e},f=function(){return u},p=8;function m(e,t,n,r){switch(n||=`i8`,n.charAt(n.length-1)===`*`&&(n=`i32`),n){case`i1`:k[e>>0]=t;break;case`i8`:k[e>>0]=t;break;case`i16`:j[e>>1]=t;break;case`i32`:M[e>>2]=t;break;case`i64`:ke=[t>>>0,(Oe=t,+ge(Oe)>=1?Oe>0?(ye(+ve(Oe/4294967296),4294967295)|0)>>>0:~~+_e((Oe-+(~~Oe>>>0))/4294967296)>>>0:0)],M[e>>2]=ke[0],M[e+4>>2]=ke[1];break;case`float`:N[e>>2]=t;break;case`double`:ee[e>>3]=t;break;default:tt(`invalid type for setValue: `+n)}}function h(e,t,n){switch(t||=`i8`,t.charAt(t.length-1)===`*`&&(t=`i32`),t){case`i1`:return k[e>>0];case`i8`:return k[e>>0];case`i16`:return j[e>>1];case`i32`:return M[e>>2];case`i64`:return M[e>>2];case`float`:return N[e>>2];case`double`:return ee[e>>3];default:tt(`invalid type for getValue: `+t)}return null}var g=!1;function _(e,t){e||tt(`Assertion failed: `+t)}function v(e){var n=t[`_`+e];return _(n,`Cannot call unknown function `+e+`, make sure it is exported`),n}function y(e,t,n,r,i){var a={string:function(e){var t=0;if(e!=null&&e!==0){var n=(e.length<<2)+1;t=Ke(n),T(e,t,n)}return t},array:function(e){var t=Ke(e.length);return E(e,t),t}};function o(e){return t===`string`?C(e):t===`boolean`?!!e:e}var s=v(e),c=[],l=0;if(r)for(var u=0;u=r);)++i;if(i-t>16&&e.subarray&&x)return x.decode(e.subarray(t,i));for(var a=``;t>10,56320|l&1023)}}return a}function C(e,t){return e?S(A,e,t):``}function w(e,t,n,r){if(!(r>0))return 0;for(var i=n,a=n+r-1,o=0;o=55296&&s<=57343){var c=e.charCodeAt(++o);s=65536+((s&1023)<<10)|c&1023}if(s<=127){if(n>=a)break;t[n++]=s}else if(s<=2047){if(n+1>=a)break;t[n++]=192|s>>6,t[n++]=128|s&63}else if(s<=65535){if(n+2>=a)break;t[n++]=224|s>>12,t[n++]=128|s>>6&63,t[n++]=128|s&63}else{if(n+3>=a)break;t[n++]=240|s>>18,t[n++]=128|s>>12&63,t[n++]=128|s>>6&63,t[n++]=128|s&63}}return t[n]=0,n-i}function T(e,t,n){return w(e,A,t,n)}typeof TextDecoder<`u`&&new TextDecoder(`utf-16le`);function E(e,t){k.set(e,t)}function D(e,t){return e%t>0&&(e+=t-e%t),e}var O,k,A,j,M,N,ee;function te(e){O=e,t.HEAP8=k=new Int8Array(e),t.HEAP16=j=new Int16Array(e),t.HEAP32=M=new Int32Array(e),t.HEAPU8=A=new Uint8Array(e),t.HEAPU16=new Uint16Array(e),t.HEAPU32=new Uint32Array(e),t.HEAPF32=N=new Float32Array(e),t.HEAPF64=ee=new Float64Array(e)}var ne=5271296,re=28384,ie=t.TOTAL_MEMORY||33554432;O=t.buffer?t.buffer:new ArrayBuffer(ie),ie=O.byteLength,te(O),M[re>>2]=ne;function ae(e){for(;e.length>0;){var n=e.shift();if(typeof n==`function`){n();continue}var r=n.func;typeof r==`number`?n.arg===void 0?t.dynCall_v(r):t.dynCall_vi(r,n.arg):r(n.arg===void 0?null:n.arg)}}var oe=[],se=[],ce=[],le=[];function ue(){if(t.preRun)for(typeof t.preRun==`function`&&(t.preRun=[t.preRun]);t.preRun.length;)me(t.preRun.shift());ae(oe)}function de(){ae(se)}function fe(){ae(ce)}function pe(){if(t.postRun)for(typeof t.postRun==`function`&&(t.postRun=[t.postRun]);t.postRun.length;)he(t.postRun.shift());ae(le)}function me(e){oe.unshift(e)}function he(e){le.unshift(e)}var ge=Math.abs,_e=Math.ceil,ve=Math.floor,ye=Math.min,be=0,xe=null,Se=null;function Ce(e){be++,t.monitorRunDependencies&&t.monitorRunDependencies(be)}function we(e){if(be--,t.monitorRunDependencies&&t.monitorRunDependencies(be),be==0&&(xe!==null&&(clearInterval(xe),xe=null),Se)){var n=Se;Se=null,n()}}t.preloadedImages={},t.preloadedAudios={};var Te=null,Ee=`data:application/octet-stream;base64,`;function De(e){return String.prototype.startsWith?e.startsWith(Ee):e.indexOf(Ee)===0}var Oe,ke;Te=`data:application/octet-stream;base64,AAAAAAAAAAAAAAAAAQAAAAIAAAADAAAABAAAAAUAAAAGAAAAAQAAAAQAAAADAAAABgAAAAUAAAACAAAAAAAAAAIAAAADAAAAAQAAAAQAAAAGAAAAAAAAAAUAAAADAAAABgAAAAQAAAAFAAAAAAAAAAEAAAACAAAABAAAAAUAAAAGAAAAAAAAAAIAAAADAAAAAQAAAAUAAAACAAAAAAAAAAEAAAADAAAABgAAAAQAAAAGAAAAAAAAAAUAAAACAAAAAQAAAAQAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAEAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAIAAAADAAAAAAAAAAAAAAACAAAAAAAAAAEAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABAAAAAYAAAAAAAAABQAAAAAAAAAAAAAABAAAAAUAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAYAAAAAAAAABgAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAgAAAAMAAAAEAAAABQAAAAYAAAABAAAAAgAAAAMAAAAEAAAABQAAAAYAAAAAAAAAAgAAAAMAAAAEAAAABQAAAAYAAAAAAAAAAQAAAAMAAAAEAAAABQAAAAYAAAAAAAAAAQAAAAIAAAAEAAAABQAAAAYAAAAAAAAAAQAAAAIAAAADAAAABQAAAAYAAAAAAAAAAQAAAAIAAAADAAAABAAAAAYAAAAAAAAAAQAAAAIAAAADAAAABAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAwAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAgAAAAIAAAAAAAAAAAAAAAYAAAAAAAAAAwAAAAIAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAFAAAABAAAAAAAAAABAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAYAAAAAAAAABAAAAAAAAAAGAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAFAAAAAgAAAAQAAAADAAAACAAAAAEAAAAHAAAABgAAAAkAAAAAAAAAAwAAAAIAAAACAAAABgAAAAoAAAALAAAAAAAAAAEAAAAFAAAAAwAAAA0AAAABAAAABwAAAAQAAAAMAAAAAAAAAAQAAAB/AAAADwAAAAgAAAADAAAAAAAAAAwAAAAFAAAAAgAAABIAAAAKAAAACAAAAAAAAAAQAAAABgAAAA4AAAALAAAAEQAAAAEAAAAJAAAAAgAAAAcAAAAVAAAACQAAABMAAAADAAAADQAAAAEAAAAIAAAABQAAABYAAAAQAAAABAAAAAAAAAAPAAAACQAAABMAAAAOAAAAFAAAAAEAAAAHAAAABgAAAAoAAAALAAAAGAAAABcAAAAFAAAAAgAAABIAAAALAAAAEQAAABcAAAAZAAAAAgAAAAYAAAAKAAAADAAAABwAAAANAAAAGgAAAAQAAAAPAAAAAwAAAA0AAAAaAAAAFQAAAB0AAAADAAAADAAAAAcAAAAOAAAAfwAAABEAAAAbAAAACQAAABQAAAAGAAAADwAAABYAAAAcAAAAHwAAAAQAAAAIAAAADAAAABAAAAASAAAAIQAAAB4AAAAIAAAABQAAABYAAAARAAAACwAAAA4AAAAGAAAAIwAAABkAAAAbAAAAEgAAABgAAAAeAAAAIAAAAAUAAAAKAAAAEAAAABMAAAAiAAAAFAAAACQAAAAHAAAAFQAAAAkAAAAUAAAADgAAABMAAAAJAAAAKAAAABsAAAAkAAAAFQAAACYAAAATAAAAIgAAAA0AAAAdAAAABwAAABYAAAAQAAAAKQAAACEAAAAPAAAACAAAAB8AAAAXAAAAGAAAAAsAAAAKAAAAJwAAACUAAAAZAAAAGAAAAH8AAAAgAAAAJQAAAAoAAAAXAAAAEgAAABkAAAAXAAAAEQAAAAsAAAAtAAAAJwAAACMAAAAaAAAAKgAAAB0AAAArAAAADAAAABwAAAANAAAAGwAAACgAAAAjAAAALgAAAA4AAAAUAAAAEQAAABwAAAAfAAAAKgAAACwAAAAMAAAADwAAABoAAAAdAAAAKwAAACYAAAAvAAAADQAAABoAAAAVAAAAHgAAACAAAAAwAAAAMgAAABAAAAASAAAAIQAAAB8AAAApAAAALAAAADUAAAAPAAAAFgAAABwAAAAgAAAAHgAAABgAAAASAAAANAAAADIAAAAlAAAAIQAAAB4AAAAxAAAAMAAAABYAAAAQAAAAKQAAACIAAAATAAAAJgAAABUAAAA2AAAAJAAAADMAAAAjAAAALgAAAC0AAAA4AAAAEQAAABsAAAAZAAAAJAAAABQAAAAiAAAAEwAAADcAAAAoAAAANgAAACUAAAAnAAAANAAAADkAAAAYAAAAFwAAACAAAAAmAAAAfwAAACIAAAAzAAAAHQAAAC8AAAAVAAAAJwAAACUAAAAZAAAAFwAAADsAAAA5AAAALQAAACgAAAAbAAAAJAAAABQAAAA8AAAALgAAADcAAAApAAAAMQAAADUAAAA9AAAAFgAAACEAAAAfAAAAKgAAADoAAAArAAAAPgAAABwAAAAsAAAAGgAAACsAAAA+AAAALwAAAEAAAAAaAAAAKgAAAB0AAAAsAAAANQAAADoAAABBAAAAHAAAAB8AAAAqAAAALQAAACcAAAAjAAAAGQAAAD8AAAA7AAAAOAAAAC4AAAA8AAAAOAAAAEQAAAAbAAAAKAAAACMAAAAvAAAAJgAAACsAAAAdAAAARQAAADMAAABAAAAAMAAAADEAAAAeAAAAIQAAAEMAAABCAAAAMgAAADEAAAB/AAAAPQAAAEIAAAAhAAAAMAAAACkAAAAyAAAAMAAAACAAAAAeAAAARgAAAEMAAAA0AAAAMwAAAEUAAAA2AAAARwAAACYAAAAvAAAAIgAAADQAAAA5AAAARgAAAEoAAAAgAAAAJQAAADIAAAA1AAAAPQAAAEEAAABLAAAAHwAAACkAAAAsAAAANgAAAEcAAAA3AAAASQAAACIAAAAzAAAAJAAAADcAAAAoAAAANgAAACQAAABIAAAAPAAAAEkAAAA4AAAARAAAAD8AAABNAAAAIwAAAC4AAAAtAAAAOQAAADsAAABKAAAATgAAACUAAAAnAAAANAAAADoAAAB/AAAAPgAAAEwAAAAsAAAAQQAAACoAAAA7AAAAPwAAAE4AAABPAAAAJwAAAC0AAAA5AAAAPAAAAEgAAABEAAAAUAAAACgAAAA3AAAALgAAAD0AAAA1AAAAMQAAACkAAABRAAAASwAAAEIAAAA+AAAAKwAAADoAAAAqAAAAUgAAAEAAAABMAAAAPwAAAH8AAAA4AAAALQAAAE8AAAA7AAAATQAAAEAAAAAvAAAAPgAAACsAAABUAAAARQAAAFIAAABBAAAAOgAAADUAAAAsAAAAVgAAAEwAAABLAAAAQgAAAEMAAABRAAAAVQAAADEAAAAwAAAAPQAAAEMAAABCAAAAMgAAADAAAABXAAAAVQAAAEYAAABEAAAAOAAAADwAAAAuAAAAWgAAAE0AAABQAAAARQAAADMAAABAAAAALwAAAFkAAABHAAAAVAAAAEYAAABDAAAANAAAADIAAABTAAAAVwAAAEoAAABHAAAAWQAAAEkAAABbAAAAMwAAAEUAAAA2AAAASAAAAH8AAABJAAAANwAAAFAAAAA8AAAAWAAAAEkAAABbAAAASAAAAFgAAAA2AAAARwAAADcAAABKAAAATgAAAFMAAABcAAAANAAAADkAAABGAAAASwAAAEEAAAA9AAAANQAAAF4AAABWAAAAUQAAAEwAAABWAAAAUgAAAGAAAAA6AAAAQQAAAD4AAABNAAAAPwAAAEQAAAA4AAAAXQAAAE8AAABaAAAATgAAAEoAAAA7AAAAOQAAAF8AAABcAAAATwAAAE8AAABOAAAAPwAAADsAAABdAAAAXwAAAE0AAABQAAAARAAAAEgAAAA8AAAAYwAAAFoAAABYAAAAUQAAAFUAAABeAAAAZQAAAD0AAABCAAAASwAAAFIAAABgAAAAVAAAAGIAAAA+AAAATAAAAEAAAABTAAAAfwAAAEoAAABGAAAAZAAAAFcAAABcAAAAVAAAAEUAAABSAAAAQAAAAGEAAABZAAAAYgAAAFUAAABXAAAAZQAAAGYAAABCAAAAQwAAAFEAAABWAAAATAAAAEsAAABBAAAAaAAAAGAAAABeAAAAVwAAAFMAAABmAAAAZAAAAEMAAABGAAAAVQAAAFgAAABIAAAAWwAAAEkAAABjAAAAUAAAAGkAAABZAAAAYQAAAFsAAABnAAAARQAAAFQAAABHAAAAWgAAAE0AAABQAAAARAAAAGoAAABdAAAAYwAAAFsAAABJAAAAWQAAAEcAAABpAAAAWAAAAGcAAABcAAAAUwAAAE4AAABKAAAAbAAAAGQAAABfAAAAXQAAAE8AAABaAAAATQAAAG0AAABfAAAAagAAAF4AAABWAAAAUQAAAEsAAABrAAAAaAAAAGUAAABfAAAAXAAAAE8AAABOAAAAbQAAAGwAAABdAAAAYAAAAGgAAABiAAAAbgAAAEwAAABWAAAAUgAAAGEAAAB/AAAAYgAAAFQAAABnAAAAWQAAAG8AAABiAAAAbgAAAGEAAABvAAAAUgAAAGAAAABUAAAAYwAAAFAAAABpAAAAWAAAAGoAAABaAAAAcQAAAGQAAABmAAAAUwAAAFcAAABsAAAAcgAAAFwAAABlAAAAZgAAAGsAAABwAAAAUQAAAFUAAABeAAAAZgAAAGUAAABXAAAAVQAAAHIAAABwAAAAZAAAAGcAAABbAAAAYQAAAFkAAAB0AAAAaQAAAG8AAABoAAAAawAAAG4AAABzAAAAVgAAAF4AAABgAAAAaQAAAFgAAABnAAAAWwAAAHEAAABjAAAAdAAAAGoAAABdAAAAYwAAAFoAAAB1AAAAbQAAAHEAAABrAAAAfwAAAGUAAABeAAAAcwAAAGgAAABwAAAAbAAAAGQAAABfAAAAXAAAAHYAAAByAAAAbQAAAG0AAABsAAAAXQAAAF8AAAB1AAAAdgAAAGoAAABuAAAAYgAAAGgAAABgAAAAdwAAAG8AAABzAAAAbwAAAGEAAABuAAAAYgAAAHQAAABnAAAAdwAAAHAAAABrAAAAZgAAAGUAAAB4AAAAcwAAAHIAAABxAAAAYwAAAHQAAABpAAAAdQAAAGoAAAB5AAAAcgAAAHAAAABkAAAAZgAAAHYAAAB4AAAAbAAAAHMAAABuAAAAawAAAGgAAAB4AAAAdwAAAHAAAAB0AAAAZwAAAHcAAABvAAAAcQAAAGkAAAB5AAAAdQAAAH8AAABtAAAAdgAAAHEAAAB5AAAAagAAAHYAAAB4AAAAbAAAAHIAAAB1AAAAeQAAAG0AAAB3AAAAbwAAAHMAAABuAAAAeQAAAHQAAAB4AAAAeAAAAHMAAAByAAAAcAAAAHkAAAB3AAAAdgAAAHkAAAB0AAAAeAAAAHcAAAB1AAAAcQAAAHYAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAABAAAABQAAAAEAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAACAAAABQAAAAEAAAAAAAAA/////wEAAAAAAAAAAwAAAAQAAAACAAAAAAAAAAAAAAABAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAMAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAFAAAAAQAAAAAAAAAAAAAAAQAAAAMAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAADAAAAAAAAAAAAAAABAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAADAAAABQAAAAEAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAABAAAAAAAAAP////8DAAAAAAAAAAUAAAACAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAEAAAABQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAFAAAABQAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAD/////AwAAAAAAAAAFAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAAAAAABAAAAAwAAAAAAAAAAAAAAAQAAAAAAAAADAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAQAAAAMAAAAAAAAAAAAAAAEAAAAAAAAAAwAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAADAAAAAAAAAP////8DAAAAAAAAAAUAAAACAAAAAAAAAAAAAAADAAAAAAAAAAAAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAUAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAFAAAABQAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAwAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAADAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAAAAAAA/////wMAAAAAAAAABQAAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAA/////wMAAAAAAAAABQAAAAIAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAMAAAADAAAAAAAAAAAAAAADAAAAAwAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAMAAAADAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAD/////AwAAAAAAAAAFAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAADAAAAAAAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAAAAAD/////AwAAAAAAAAAFAAAAAgAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAADAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAFAAAAAAAAAAAAAAADAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAADAAAAAQAAAAAAAAABAAAAAAAAAAAAAAABAAAAAwAAAAEAAAAAAAAAAQAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAADAAAAAAAAAP////8DAAAAAAAAAAUAAAACAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAAAAAADAAAAAwAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAUAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAFAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAA/////wMAAAAAAAAABQAAAAIAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAAFAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAEAAAADAAAAAQAAAAAAAAABAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAADAAAAAQAAAAAAAAABAAAAAAAAAAMAAAADAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAAAAAAAAwAAAAUAAAABAAAAAAAAAP////8DAAAAAAAAAAUAAAACAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAABAAAAAUAAAABAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAIAAAAFAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAADAAAAAQAAAAAAAAABAAAAAAAAAAUAAAAAAAAAAAAAAAUAAAAFAAAAAAAAAAAAAAD/////AQAAAAAAAAADAAAABAAAAAIAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAUAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAFAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAUAAAABAAAAAAAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAAAAAAEAAAD//////////wEAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAADAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAsAAAACAAAAAAAAAAAAAAABAAAAAgAAAAYAAAAEAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAYAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAcAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAYAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAKAAAAAgAAAAAAAAAAAAAAAQAAAAEAAAAFAAAABgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAALAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAABwAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAsAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACgAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAACAAAAAAAAAAAAAAABAAAAAwAAAAcAAAAGAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAABwAAAAEAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAGAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAADgAAAAIAAAAAAAAAAAAAAAEAAAAAAAAACQAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACgAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAMAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAABwAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAsAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAKAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADQAAAAIAAAAAAAAAAAAAAAEAAAAEAAAACAAAAAoAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAALAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAACQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAGAAAAAgAAAAAAAAAAAAAAAQAAAAsAAAAPAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAkAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAOAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAEAAAAAAAAAAQAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAIAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAABQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAAAAgAAAAAAAAAAAAAAAQAAAAwAAAAQAAAADAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAoAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAJAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAPAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAADwAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAADQAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAACAAAAAAAAAAAAAAABAAAACgAAABMAAAAIAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAkAAAABAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAEQAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEQAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAAAAAA8AAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAQAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAACQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAANAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAIAAAAAAAAAAAAAAAEAAAANAAAAEQAAAA0AAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAARAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAEwAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAA4AAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAATAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAAEQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAA0AAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAARAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAkAAAACAAAAAAAAAAAAAAABAAAADgAAABIAAAAPAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAADwAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABIAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAASAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAEwAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAABEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAATAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEgAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAABIAAAABAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAATAAAAAgAAAAAAAAAAAAAAAQAAAP//////////EwAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAATAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAEgAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAASAAAAAAAAABgAAAAAAAAAIQAAAAAAAAAeAAAAAAAAACAAAAADAAAAMQAAAAEAAAAwAAAAAwAAADIAAAADAAAACAAAAAAAAAAFAAAABQAAAAoAAAAFAAAAFgAAAAAAAAAQAAAAAAAAABIAAAAAAAAAKQAAAAEAAAAhAAAAAAAAAB4AAAAAAAAABAAAAAAAAAAAAAAABQAAAAIAAAAFAAAADwAAAAEAAAAIAAAAAAAAAAUAAAAFAAAAHwAAAAEAAAAWAAAAAAAAABAAAAAAAAAAAgAAAAAAAAAGAAAAAAAAAA4AAAAAAAAACgAAAAAAAAALAAAAAAAAABEAAAADAAAAGAAAAAEAAAAXAAAAAwAAABkAAAADAAAAAAAAAAAAAAABAAAABQAAAAkAAAAFAAAABQAAAAAAAAACAAAAAAAAAAYAAAAAAAAAEgAAAAEAAAAKAAAAAAAAAAsAAAAAAAAABAAAAAEAAAADAAAABQAAAAcAAAAFAAAACAAAAAEAAAAAAAAAAAAAAAEAAAAFAAAAEAAAAAEAAAAFAAAAAAAAAAIAAAAAAAAABwAAAAAAAAAVAAAAAAAAACYAAAAAAAAACQAAAAAAAAATAAAAAAAAACIAAAADAAAADgAAAAEAAAAUAAAAAwAAACQAAAADAAAAAwAAAAAAAAANAAAABQAAAB0AAAAFAAAAAQAAAAAAAAAHAAAAAAAAABUAAAAAAAAABgAAAAEAAAAJAAAAAAAAABMAAAAAAAAABAAAAAIAAAAMAAAABQAAABoAAAAFAAAAAAAAAAEAAAADAAAAAAAAAA0AAAAFAAAAAgAAAAEAAAABAAAAAAAAAAcAAAAAAAAAGgAAAAAAAAAqAAAAAAAAADoAAAAAAAAAHQAAAAAAAAArAAAAAAAAAD4AAAADAAAAJgAAAAEAAAAvAAAAAwAAAEAAAAADAAAADAAAAAAAAAAcAAAABQAAACwAAAAFAAAADQAAAAAAAAAaAAAAAAAAACoAAAAAAAAAFQAAAAEAAAAdAAAAAAAAACsAAAAAAAAABAAAAAMAAAAPAAAABQAAAB8AAAAFAAAAAwAAAAEAAAAMAAAAAAAAABwAAAAFAAAABwAAAAEAAAANAAAAAAAAABoAAAAAAAAAHwAAAAAAAAApAAAAAAAAADEAAAAAAAAALAAAAAAAAAA1AAAAAAAAAD0AAAADAAAAOgAAAAEAAABBAAAAAwAAAEsAAAADAAAADwAAAAAAAAAWAAAABQAAACEAAAAFAAAAHAAAAAAAAAAfAAAAAAAAACkAAAAAAAAAKgAAAAEAAAAsAAAAAAAAADUAAAAAAAAABAAAAAQAAAAIAAAABQAAABAAAAAFAAAADAAAAAEAAAAPAAAAAAAAABYAAAAFAAAAGgAAAAEAAAAcAAAAAAAAAB8AAAAAAAAAMgAAAAAAAAAwAAAAAAAAADEAAAADAAAAIAAAAAAAAAAeAAAAAwAAACEAAAADAAAAGAAAAAMAAAASAAAAAwAAABAAAAADAAAARgAAAAAAAABDAAAAAAAAAEIAAAADAAAANAAAAAMAAAAyAAAAAAAAADAAAAAAAAAAJQAAAAMAAAAgAAAAAAAAAB4AAAADAAAAUwAAAAAAAABXAAAAAwAAAFUAAAADAAAASgAAAAMAAABGAAAAAAAAAEMAAAAAAAAAOQAAAAEAAAA0AAAAAwAAADIAAAAAAAAAGQAAAAAAAAAXAAAAAAAAABgAAAADAAAAEQAAAAAAAAALAAAAAwAAAAoAAAADAAAADgAAAAMAAAAGAAAAAwAAAAIAAAADAAAALQAAAAAAAAAnAAAAAAAAACUAAAADAAAAIwAAAAMAAAAZAAAAAAAAABcAAAAAAAAAGwAAAAMAAAARAAAAAAAAAAsAAAADAAAAPwAAAAAAAAA7AAAAAwAAADkAAAADAAAAOAAAAAMAAAAtAAAAAAAAACcAAAAAAAAALgAAAAMAAAAjAAAAAwAAABkAAAAAAAAAJAAAAAAAAAAUAAAAAAAAAA4AAAADAAAAIgAAAAAAAAATAAAAAwAAAAkAAAADAAAAJgAAAAMAAAAVAAAAAwAAAAcAAAADAAAANwAAAAAAAAAoAAAAAAAAABsAAAADAAAANgAAAAMAAAAkAAAAAAAAABQAAAAAAAAAMwAAAAMAAAAiAAAAAAAAABMAAAADAAAASAAAAAAAAAA8AAAAAwAAAC4AAAADAAAASQAAAAMAAAA3AAAAAAAAACgAAAAAAAAARwAAAAMAAAA2AAAAAwAAACQAAAAAAAAAQAAAAAAAAAAvAAAAAAAAACYAAAADAAAAPgAAAAAAAAArAAAAAwAAAB0AAAADAAAAOgAAAAMAAAAqAAAAAwAAABoAAAADAAAAVAAAAAAAAABFAAAAAAAAADMAAAADAAAAUgAAAAMAAABAAAAAAAAAAC8AAAAAAAAATAAAAAMAAAA+AAAAAAAAACsAAAADAAAAYQAAAAAAAABZAAAAAwAAAEcAAAADAAAAYgAAAAMAAABUAAAAAAAAAEUAAAAAAAAAYAAAAAMAAABSAAAAAwAAAEAAAAAAAAAASwAAAAAAAABBAAAAAAAAADoAAAADAAAAPQAAAAAAAAA1AAAAAwAAACwAAAADAAAAMQAAAAMAAAApAAAAAwAAAB8AAAADAAAAXgAAAAAAAABWAAAAAAAAAEwAAAADAAAAUQAAAAMAAABLAAAAAAAAAEEAAAAAAAAAQgAAAAMAAAA9AAAAAAAAADUAAAADAAAAawAAAAAAAABoAAAAAwAAAGAAAAADAAAAZQAAAAMAAABeAAAAAAAAAFYAAAAAAAAAVQAAAAMAAABRAAAAAwAAAEsAAAAAAAAAOQAAAAAAAAA7AAAAAAAAAD8AAAADAAAASgAAAAAAAABOAAAAAwAAAE8AAAADAAAAUwAAAAMAAABcAAAAAwAAAF8AAAADAAAAJQAAAAAAAAAnAAAAAwAAAC0AAAADAAAANAAAAAAAAAA5AAAAAAAAADsAAAAAAAAARgAAAAMAAABKAAAAAAAAAE4AAAADAAAAGAAAAAAAAAAXAAAAAwAAABkAAAADAAAAIAAAAAMAAAAlAAAAAAAAACcAAAADAAAAMgAAAAMAAAA0AAAAAAAAADkAAAAAAAAALgAAAAAAAAA8AAAAAAAAAEgAAAADAAAAOAAAAAAAAABEAAAAAwAAAFAAAAADAAAAPwAAAAMAAABNAAAAAwAAAFoAAAADAAAAGwAAAAAAAAAoAAAAAwAAADcAAAADAAAAIwAAAAAAAAAuAAAAAAAAADwAAAAAAAAALQAAAAMAAAA4AAAAAAAAAEQAAAADAAAADgAAAAAAAAAUAAAAAwAAACQAAAADAAAAEQAAAAMAAAAbAAAAAAAAACgAAAADAAAAGQAAAAMAAAAjAAAAAAAAAC4AAAAAAAAARwAAAAAAAABZAAAAAAAAAGEAAAADAAAASQAAAAAAAABbAAAAAwAAAGcAAAADAAAASAAAAAMAAABYAAAAAwAAAGkAAAADAAAAMwAAAAAAAABFAAAAAwAAAFQAAAADAAAANgAAAAAAAABHAAAAAAAAAFkAAAAAAAAANwAAAAMAAABJAAAAAAAAAFsAAAADAAAAJgAAAAAAAAAvAAAAAwAAAEAAAAADAAAAIgAAAAMAAAAzAAAAAAAAAEUAAAADAAAAJAAAAAMAAAA2AAAAAAAAAEcAAAAAAAAAYAAAAAAAAABoAAAAAAAAAGsAAAADAAAAYgAAAAAAAABuAAAAAwAAAHMAAAADAAAAYQAAAAMAAABvAAAAAwAAAHcAAAADAAAATAAAAAAAAABWAAAAAwAAAF4AAAADAAAAUgAAAAAAAABgAAAAAAAAAGgAAAAAAAAAVAAAAAMAAABiAAAAAAAAAG4AAAADAAAAOgAAAAAAAABBAAAAAwAAAEsAAAADAAAAPgAAAAMAAABMAAAAAAAAAFYAAAADAAAAQAAAAAMAAABSAAAAAAAAAGAAAAAAAAAAVQAAAAAAAABXAAAAAAAAAFMAAAADAAAAZQAAAAAAAABmAAAAAwAAAGQAAAADAAAAawAAAAMAAABwAAAAAwAAAHIAAAADAAAAQgAAAAAAAABDAAAAAwAAAEYAAAADAAAAUQAAAAAAAABVAAAAAAAAAFcAAAAAAAAAXgAAAAMAAABlAAAAAAAAAGYAAAADAAAAMQAAAAAAAAAwAAAAAwAAADIAAAADAAAAPQAAAAMAAABCAAAAAAAAAEMAAAADAAAASwAAAAMAAABRAAAAAAAAAFUAAAAAAAAAXwAAAAAAAABcAAAAAAAAAFMAAAAAAAAATwAAAAAAAABOAAAAAAAAAEoAAAADAAAAPwAAAAEAAAA7AAAAAwAAADkAAAADAAAAbQAAAAAAAABsAAAAAAAAAGQAAAAFAAAAXQAAAAEAAABfAAAAAAAAAFwAAAAAAAAATQAAAAEAAABPAAAAAAAAAE4AAAAAAAAAdQAAAAQAAAB2AAAABQAAAHIAAAAFAAAAagAAAAEAAABtAAAAAAAAAGwAAAAAAAAAWgAAAAEAAABdAAAAAQAAAF8AAAAAAAAAWgAAAAAAAABNAAAAAAAAAD8AAAAAAAAAUAAAAAAAAABEAAAAAAAAADgAAAADAAAASAAAAAEAAAA8AAAAAwAAAC4AAAADAAAAagAAAAAAAABdAAAAAAAAAE8AAAAFAAAAYwAAAAEAAABaAAAAAAAAAE0AAAAAAAAAWAAAAAEAAABQAAAAAAAAAEQAAAAAAAAAdQAAAAMAAABtAAAABQAAAF8AAAAFAAAAcQAAAAEAAABqAAAAAAAAAF0AAAAAAAAAaQAAAAEAAABjAAAAAQAAAFoAAAAAAAAAaQAAAAAAAABYAAAAAAAAAEgAAAAAAAAAZwAAAAAAAABbAAAAAAAAAEkAAAADAAAAYQAAAAEAAABZAAAAAwAAAEcAAAADAAAAcQAAAAAAAABjAAAAAAAAAFAAAAAFAAAAdAAAAAEAAABpAAAAAAAAAFgAAAAAAAAAbwAAAAEAAABnAAAAAAAAAFsAAAAAAAAAdQAAAAIAAABqAAAABQAAAFoAAAAFAAAAeQAAAAEAAABxAAAAAAAAAGMAAAAAAAAAdwAAAAEAAAB0AAAAAQAAAGkAAAAAAAAAdwAAAAAAAABvAAAAAAAAAGEAAAAAAAAAcwAAAAAAAABuAAAAAAAAAGIAAAADAAAAawAAAAEAAABoAAAAAwAAAGAAAAADAAAAeQAAAAAAAAB0AAAAAAAAAGcAAAAFAAAAeAAAAAEAAAB3AAAAAAAAAG8AAAAAAAAAcAAAAAEAAABzAAAAAAAAAG4AAAAAAAAAdQAAAAEAAABxAAAABQAAAGkAAAAFAAAAdgAAAAEAAAB5AAAAAAAAAHQAAAAAAAAAcgAAAAEAAAB4AAAAAQAAAHcAAAAAAAAAcgAAAAAAAABwAAAAAAAAAGsAAAAAAAAAZAAAAAAAAABmAAAAAAAAAGUAAAADAAAAUwAAAAEAAABXAAAAAwAAAFUAAAADAAAAdgAAAAAAAAB4AAAAAAAAAHMAAAAFAAAAbAAAAAEAAAByAAAAAAAAAHAAAAAAAAAAXAAAAAEAAABkAAAAAAAAAGYAAAAAAAAAdQAAAAAAAAB5AAAABQAAAHcAAAAFAAAAbQAAAAEAAAB2AAAAAAAAAHgAAAAAAAAAXwAAAAEAAABsAAAAAQAAAHIAAAAAAAAAGC1EVPsh+T8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABgtRFT7Ifk/GC1EVPsh+T8AAAAAAAAAAAAAAAAAAAAAGC1EVPsh+T8AAAAAAAAAABgtRFT7IQlAGC1EVPsh+T8AAAAAAAAAAAAAAAAAAAAAGC1EVPshCUAAAAAAAAAAABgtRFT7Ifm/GC1EVPsh+T8AAAAAAAAAAAAAAAAAAAAAGC1EVPsh+b8AAAAAAAAAAAAAAAAAAAAAGC1EVPsh+b8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABgtRFT7Ifm/GC1EVPsh+b8AAAAAAAAAAAAAAAAAAAAAGC1EVPsh+b8AAAAAAAAAABgtRFT7IQnAGC1EVPsh+b8AAAAAAAAAAAAAAAAAAAAAGC1EVPshCcAAAAAAAAAAABgtRFT7Ifk/GC1EVPsh+b8AAAAAAAAAAAAAAAAAAAAAGC1EVPsh+T8AAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAGAAAAAgAAAAUAAAABAAAABAAAAAAAAAAAAAAABQAAAAMAAAABAAAABgAAAAQAAAACAAAAAAAAAMpi5RexJsw/BlIKPVwR5T95Wyu0/QjnP5PjoT7YYcu/mBhKZ6zrwj8wRYS7NebuP3qW6geh+Ls/SLrixebL3r+pcyymN9XrPwmkNHp7xec/GWNMZVAA17+82s+x2BLiPwn2ytbJ9ek/LgEH1sMS1j8yp/2LhTfeP+SnWwtQBbu/d38gkp5X7z8ytsuHaADGPzUYObdf1+m/7IauECWhwz+cjSACjzniP76Z+wUhN9K/1+GEKzup67+/GYr/04baPw6idWOvsuc/ZedTWsRa5b/EJQOuRzi0v/OncYhHPes/h49PixY53j+i8wWfC03Nvw2idWOvsue/ZedTWsRa5T/EJQOuRzi0P/KncYhHPeu/iY9PixY53r+i8wWfC03NP9anWwtQBbs/d38gkp5X778ytsuHaADGvzUYObdf1+k/74auECWhw7+cjSACjzniv8CZ+wUhN9I/1uGEKzup6z+/GYr/04bavwmkNHp7xee/F2NMZVAA1z+82s+x2BLivwr2ytbJ9em/KwEH1sMS1r8yp/2LhTfev81i5RexJsy/BlIKPVwR5b95Wyu0/Qjnv5DjoT7YYcs/nBhKZ6zrwr8wRYS7Nebuv3OW6geh+Lu/SLrixebL3j+pcyymN9Xrv8rHIFfWehZAMBwUdlo0DECTUc17EOb2PxpVB1SWChdAzjbhb9pTDUDQhmdvECX5P9FlMKCC9+g/IIAzjELgE0DajDngMv8GQFhWDmDPjNs/y1guLh96EkAxPi8k7DIEQJCc4URlhRhA3eLKKLwkEECqpNAyTBD/P6xpjXcDiwVAFtl//cQm4z+Ibt3XKiYTQM7mCLUb3QdAoM1t8yVv7D8aLZv2Nk8UQEAJPV5nQwxAtSsfTCoE9z9TPjXLXIIWQBVanC5W9AtAYM3d7Adm9j++5mQz1FoWQBUThyaVBghAwH5muQsV7T89Q1qv82MUQJoWGOfNuBdAzrkClkmwDkDQjKq77t37Py+g0dtitsE/ZwAMTwVPEUBojepluNwBQGYbtuW+t9w/HNWIJs6MEkDTNuQUSlgEQKxktPP5TcQ/ixbLB8JjEUCwuWjXMQYCQAS/R09FkRdAowpiZjhhDkB7LmlczD/7P01iQmhhsAVAnrtTwDy84z/Z6jfQ2TgTQChOCXMnWwpAhrW3daoz8z/HYJvVPI4VQLT3ik5FcA5Angi7LOZd+z+NNVzDy5gXQBXdvVTFUA1AYNMgOeYe+T8+qHXGCwkXQKQTOKwa5AJA8gFVoEMW0T+FwzJyttIRQAEAAAD/////BwAAAP////8xAAAA/////1cBAAD/////YQkAAP////+nQQAA/////5HLAQD/////95AMAP/////B9lcAAAAAAAAAAAAAAAAAAgAAAP////8OAAAA/////2IAAAD/////rgIAAP/////CEgAA/////06DAAD/////IpcDAP/////uIRkA/////4LtrwAAAAAAAAAAAAAAAAAAAAAAAgAAAP//////////AQAAAAMAAAD//////////////////////////////////////////////////////////////////////////wEAAAAAAAAAAgAAAP///////////////wMAAAD//////////////////////////////////////////////////////////////////////////wEAAAAAAAAAAgAAAP///////////////wMAAAD//////////////////////////////////////////////////////////////////////////wEAAAAAAAAAAgAAAP///////////////wMAAAD//////////////////////////////////////////////////////////wIAAAD//////////wEAAAAAAAAA/////////////////////wMAAAD/////////////////////////////////////////////////////AwAAAP////////////////////8AAAAA/////////////////////wEAAAD///////////////8CAAAA////////////////////////////////AwAAAP////////////////////8AAAAA////////////////AgAAAAEAAAD/////////////////////////////////////////////////////AwAAAP////////////////////8AAAAA////////////////AgAAAAEAAAD/////////////////////////////////////////////////////AwAAAP////////////////////8AAAAA////////////////AgAAAAEAAAD/////////////////////////////////////////////////////AwAAAP////////////////////8AAAAA////////////////AgAAAAEAAAD/////////////////////////////////////////////////////AQAAAAIAAAD///////////////8AAAAA/////////////////////wMAAAD/////////////////////////////////////////////////////AQAAAAIAAAD///////////////8AAAAA/////////////////////wMAAAD/////////////////////////////////////////////////////AQAAAAIAAAD///////////////8AAAAA/////////////////////wMAAAD/////////////////////////////////////////////////////AQAAAAIAAAD///////////////8AAAAA/////////////////////wMAAAD///////////////////////////////8CAAAA////////////////AQAAAP////////////////////8AAAAA/////////////////////wMAAAD/////////////////////////////////////////////////////AwAAAP////////////////////8AAAAAAQAAAP//////////AgAAAP//////////////////////////////////////////////////////////AwAAAP///////////////wIAAAAAAAAAAQAAAP//////////////////////////////////////////////////////////////////////////AwAAAP///////////////wIAAAAAAAAAAQAAAP//////////////////////////////////////////////////////////////////////////AwAAAP///////////////wIAAAAAAAAAAQAAAP//////////////////////////////////////////////////////////////////////////AwAAAAEAAAD//////////wIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAgAAAAAAAAACAAAAAQAAAAEAAAACAAAAAgAAAAAAAAAFAAAABQAAAAAAAAACAAAAAgAAAAMAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAIAAAABAAAAAgAAAAIAAAACAAAAAAAAAAUAAAAGAAAAAAAAAAIAAAACAAAAAwAAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAIAAAAAAAAAAgAAAAEAAAADAAAAAgAAAAIAAAAAAAAABQAAAAcAAAAAAAAAAgAAAAIAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAgAAAAAAAAACAAAAAQAAAAQAAAACAAAAAgAAAAAAAAAFAAAACAAAAAAAAAACAAAAAgAAAAMAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAACAAAAAAAAAAIAAAABAAAAAAAAAAIAAAACAAAAAAAAAAUAAAAJAAAAAAAAAAIAAAACAAAAAwAAAAUAAAAAAAAAAAAAAAAAAAAAAAAACgAAAAIAAAACAAAAAAAAAAMAAAAOAAAAAgAAAAAAAAACAAAAAwAAAAAAAAAAAAAAAgAAAAIAAAADAAAABgAAAAAAAAAAAAAAAAAAAAAAAAALAAAAAgAAAAIAAAAAAAAAAwAAAAoAAAACAAAAAAAAAAIAAAADAAAAAQAAAAAAAAACAAAAAgAAAAMAAAAHAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAACAAAAAgAAAAAAAAADAAAACwAAAAIAAAAAAAAAAgAAAAMAAAACAAAAAAAAAAIAAAACAAAAAwAAAAgAAAAAAAAAAAAAAAAAAAAAAAAADQAAAAIAAAACAAAAAAAAAAMAAAAMAAAAAgAAAAAAAAACAAAAAwAAAAMAAAAAAAAAAgAAAAIAAAADAAAACQAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAgAAAAIAAAAAAAAAAwAAAA0AAAACAAAAAAAAAAIAAAADAAAABAAAAAAAAAACAAAAAgAAAAMAAAAKAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAACAAAAAgAAAAAAAAADAAAABgAAAAIAAAAAAAAAAgAAAAMAAAAPAAAAAAAAAAIAAAACAAAAAwAAAAsAAAAAAAAAAAAAAAAAAAAAAAAABgAAAAIAAAACAAAAAAAAAAMAAAAHAAAAAgAAAAAAAAACAAAAAwAAABAAAAAAAAAAAgAAAAIAAAADAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAHAAAAAgAAAAIAAAAAAAAAAwAAAAgAAAACAAAAAAAAAAIAAAADAAAAEQAAAAAAAAACAAAAAgAAAAMAAAANAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAACAAAAAgAAAAAAAAADAAAACQAAAAIAAAAAAAAAAgAAAAMAAAASAAAAAAAAAAIAAAACAAAAAwAAAA4AAAAAAAAAAAAAAAAAAAAAAAAACQAAAAIAAAACAAAAAAAAAAMAAAAFAAAAAgAAAAAAAAACAAAAAwAAABMAAAAAAAAAAgAAAAIAAAADAAAADwAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAgAAAAAAAAACAAAAAQAAABMAAAACAAAAAgAAAAAAAAAFAAAACgAAAAAAAAACAAAAAgAAAAMAAAAQAAAAAAAAAAAAAAAAAAAAAAAAABEAAAACAAAAAAAAAAIAAAABAAAADwAAAAIAAAACAAAAAAAAAAUAAAALAAAAAAAAAAIAAAACAAAAAwAAABEAAAAAAAAAAAAAAAAAAAAAAAAAEgAAAAIAAAAAAAAAAgAAAAEAAAAQAAAAAgAAAAIAAAAAAAAABQAAAAwAAAAAAAAAAgAAAAIAAAADAAAAEgAAAAAAAAAAAAAAAAAAAAAAAAATAAAAAgAAAAAAAAACAAAAAQAAABEAAAACAAAAAgAAAAAAAAAFAAAADQAAAAAAAAACAAAAAgAAAAMAAAATAAAAAAAAAAAAAAAAAAAAAAAAAA8AAAACAAAAAAAAAAIAAAABAAAAEgAAAAIAAAACAAAAAAAAAAUAAAAOAAAAAAAAAAIAAAACAAAAAwAAAAIAAAABAAAAAAAAAAEAAAACAAAAAAAAAAAAAAACAAAAAQAAAAAAAAABAAAAAgAAAAEAAAAAAAAAAgAAAAAAAAAFAAAABAAAAAAAAAABAAAABQAAAAAAAAAAAAAABQAAAAQAAAAAAAAAAQAAAAUAAAAEAAAAAAAAAAUAAAAAAAAAAgAAAAEAAAAAAAAAAQAAAAIAAAAAAAAAAAAAAAIAAAABAAAAAAAAAAEAAAACAAAAAQAAAAAAAAACAAAAAgAAAAAAAAABAAAAAAAAAAAAAAAFAAAABAAAAAAAAAABAAAABQAAAAAAAAAAAAAABQAAAAQAAAAAAAAAAQAAAAUAAAAEAAAAAAAAAAUAAAAFAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAQAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAABAAAAAAAAAAABAAAAAAEAAAAAAAAAAAEAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAQAAAAAAAAAAAAEAAAAAAAAAAAAAOgehWlKfUEEz1zLi+JsiQa2og3wcMfVAWCbHorc0yEDi+Yn/Y6mbQJ11/mfsnG9At6bnG4UQQkBvMCQWKqUUQJVmwwswmOc/3hVgVBL3uj//qqOEOdGOPw/WDN4gnGE/H3ANkCUgND+AA8btKgAHPwTXBqJVSdo+XfRQAqsKrj4fc+zLYbSPQklEmCZHv2FCUP+uDso1NEKYtPhwphUHQptxnyFXYdpB7CddZAMmrkGAt1AxSTqBQUibBVdTsFNBSuX3MV+AJkFocv82SLf5QAqmgj7AY81A23VDSEnLoEDGEJVSeDFzQDYrqvBk70VA8U157pcRGUBWfEF+ZKbsP6phvycGBZRAJbod0OgwfkCp+L8jatBmQCjl3pGrPlFAfMWm114SOkButwtqS7UjQHQwbcjXyw1A8jnLuuyA9j9KwjL0VwHhPyotk0lcs8k/Q5PvEs9rsz+SfsOQEVqdPzUAKDojLoY/WJz/kcjCcD8YFu070FRZPyoLC2BdJEM/YOXQAuiMM0HIBz1bw3sdQdV46aaHRwZByatzjDPX8EDb3Jie8HXZQCJxj6ULP8NAUaG6uRAZrUCWdmou5/mVQLb9huRPm4BAhvoCHygZaUCuX/I3SPdSQC9/bC/1qTxAfKxsYQ6pJUCuslH+N14QQMS/cv7SvPg/Ol8maYKx4j8AAAAA/////wAAAAAAAAAAAAAAAAAAAAAAAAAA/////////////////////////////////////wAAAAD/////AAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAA/////wAAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAP////8AAAAABQAAAAAAAAAAAAAAAAAAAAAAAAD/////BQAAAAUAAAAAAAAAAAAAAAAAAAAAAAAA/////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP////////////////////////////////////8AAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////////////////////////////AAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAABQAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/////////////////////////////////////wAAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAABAAAAAQAAAAAAAAABAAAAAAAAAAUAAAABAAAAAQAAAAAAAAAAAAAAAQAAAAEAAAAAAAAAAQAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQEAAAAAAAEAAQAAAQEAAAAAAAEAAAABAAAAAQABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAAAAAABAAAAAQAAAAEAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAKriWFiWZfg/Y2nmTbY/8z8MHSPSqmnjv6hnn18HR3c/quJYWJZl+D/jq5TzDdzyPwwdI9KqaeO/u0kC1eFSBECq4lhYlmX4P69pJmt7c/E/NnkJi6jSBsDESFlzKkr6P33ArMz7sfY/o2q2uqM08D+oZ59fB0d3PzEqCi3qrvK/kmm4ANp49D+4wS2wzhzvP9WJvyAnx+E/upcY75RVx7+95t+9y0T1P9L18g1caO0/k6CkRyVzAEBf99+e/GjxP6QMsuuLQ/U/PlP4Qr8q7j8Mb/GO2GMCwLl2K/DQIghAePiwytEp9D9UHrsuI/nqPzjMedJ+yuy/k6xgf58n/L+XoQtn22DzP2lzCnsYk+s/JhUSDI4P8z+8lFcBhgTcPxOqKRxEX/M/89MEdoPQ6j8OKQaXDob7vzWwNvblgAPAzGkxMcl88j9Nm4okPkbpP0vI89vxSgRAdac2Z6W2/T+6UFOMC3zyP/+2XEF3hug/QqhELwGKCMAwdlQerEoEQFcr/B+VnvE/hB1hfFzT5j8wdsE/Da64P0hIvnF/sOC/KH/hrXUg8T9bI5OQHaLlP+mYzla7td6/CtKG6iOm8b8FW3TV8oXwP8ORhtNuJ+c/q8JrTMz/AcC8PaUl+PUFwAXv9rkMT/A/m+sAswr15D+7hk/O3yvkP6c/yVsOHKI/qqAX9idJ8D/8hNz1KNPiP7xSXh3Ggvg/epbkiKr57T/23/LB1GLvP4GTTeNZi+M/W4TqlTheBcDupZgIdYUIQGwlcW3YZO8/tQvDXQ3H4j8Bt+sf9DkAQMdFie+nNvg/Z5Uh1wDX7j9h5X2d4KjhPxMJ1ZVT4Pa/evqB8xB//7+W183U9QLsPwzNxsC7AOA/af/LqCnK/r/lPceQ0FQDwHoY0nYIW+w/bHNSHrTg4D/DFcMAdabuv2sz5Ojhnve/FvLf01HN6z/tEDL2Hz/gP0bBv0KUhPA/pd7sEnMc4D8EGon4Lo7sP5NVbYtSON8/DAMC50odBkB+Z2J8MGYCQIhlM1gubOo/FssiPwWy4D8OIlGqRnkCQAd1vopp6f4/QS1keLLK6T9rfoBuT7LZP3KQbH5ugwjAjqVPXTmbBUBL/JxcqR3qP3oSeovuktg/Y6pRhJmqy7+0kwuU0Yjmv2wvsfFmQ+g/R98lJFqQ2T/IGb5gjLkCwK3mNff3kQbAqDznPFM86T+iiP0FfsvYP7fzKG6Mls0/h7+at2btzL8tsUTgk+LmP/YEIrTDINU/WmwKoVjA5L9aC02r6FHxvzzFCT/Qg+Y/nx0V97en0j8+1toJOm77P1kZ7h8KjfQ/GBbbqxgk5j9RGXM79G/SP+beHsWmweQ/9REi4eX0xD/V9s+kmMHkP+pb9yNs09A/c5ERjVDTAECqEr3OBCH7P14ILfMECOU/piRx4P8P0j+JYU//bfL0Pw62fw28B+w/l5YW2Ga45D9+CyKRbenOP5cH6fHy1/S/o/egk03++r91nTYRL/bjP3fHN6OJVdA/7xXQh1XLBcAB3g6tBdUIQKW2KnGYjeQ/SqIpagclyz8F9P3YgNL6v9H6NBsZ8QDAW2k5L5Qs4z/0axa1l6zLP1GE65Mu4wNAwfX+BYmWAEBBgJP90M3hP6/03qhPLdA/zqo5bJz2778/ESlPCTn1v7JkhGyvzuE/DM7sj5twwz/6xbXLavYGQH29RFRGkgNA7bOXVSJ54T9fEhTHO/TDP+8t+HMOiwDAxa0SbGTtA8Atii7y0mLgP4cecHFB3sM/uPUpyv+K7j8nktD1/WvhP2cWmi772d8/Fj7uU9kEvD8oKOESLzKmvwSdCqrHdNu/XCluGsvI3T929OW5md+uP9dP6rXcZNq/gXM+ggzL6b+eKjsPgJncP6i1e9aVu7E/2CnPNJyD1D/DnyGgSe+xvy8k7g9bp9s/nYmLvHn1sz9cFOwApH8IwGa6Mjy9cgZAJr95SiSW2z8rCkhOFvqdP3SIKmO/UwPAEy0zkN7bBsCds8Hg/13YP1zv413hVGi/FVtqixSn6L9XAPQGul3yv7SGu2BoCNk/n94bv7Maj79p13T6X9z3P45MPCW3WvI/rU/8/LRj1T9cgR6SXd+ZPymL2DstbPI/8s/pAkIz6z/fmoB+8efYPz2XyfWgYaa/6wys72AW/j8LZImhgrf3P729Zla/n9U/ySB8B3PBqL8O2nhevvbxv17+5A+n6fe/YrGIqEGB1T+wCEGbkhaxv989QHVE5wFAzd12PTu3/T9AHUPZY2DUP3SQDST0zq2/JCxAlIoj5T+Mhe1IJkrQP/cRpl8QhtU/amc4seFts79khiUSVaz3vxYfWtjPwf2/CHscxQqD0j/ctUBQ9my3v0POnFiyXv2/pjjn2Ju/AcDk45DwBhPRP/GjwlCrv7m/aT2ciwolBsAQOzHr/wUJQCzpq5UYvtI/gDCf3SlCwb+4i7S+mukEQBDA1f8mowFA2utnRN3KyT9T+9EYAVG6v9/IVZ0enrE/7NbRtdGfzr/8y8GpRz7LP3U0vTSk18e/JzHEcwiBB0AGm8Q7AJkEQNLciyt4Esk/gLou5zoQxr+RrOfM91oBwEzd36KybgTAgLou5zoQxj/S3IsreBLJv1gCch0OHO8/FD+RxSLN4j91NL00pNfHP/zLwalHPsu/nL7/By4Pyr8tSP5h7CPiv1P70RgBUbo/2utnRN3Kyb/KfllfCpUIwLkP5zj+NwdAgDCf3SlCwT8s6auVGL7Sv2aFPlaC4eC/XrS5UVH77b/xo8JQq7+5P+TjkPAGE9G/Q30/RYbn1z8FF/ISafuLv9y1QFD2bLc/CHscxQqD0r/fi+tPROX0P6vRc+19ie0/amc4seFtsz/3EaZfEIbVv77TYpahl/o/DDsu0CaC9D90kA0k9M6tP0AdQ9ljYNS/CCI0rxjZA8BgfCaLthgHwLAIQZuSFrE/YrGIqEGB1b8kvQ982+rsv4J8EWu7jPS/ySB8B3PBqD+9vWZWv5/VvwrAByWcJgBAxFujmE9a+j89l8n1oGGmP9+agH7x59i/N03cuJUt9L8X9v4GdIz6v1yBHpJd35m/rU/8/LRj1b8mz69sydf/vyu5idMqVQLAn94bv7Majz8AhrtgaAjZv+aCE66WZ/q/lA1Mgz/p/79c7+Nd4VRoP52zweD/Xdi/TJZpMTb4AkDLWZShPOb/PysKSE4W+p2/Jr95SiSW27/PkmbE7zjnP6UAiCDmMNI/nYmLvHn1s78vJO4PW6fbv5MWA2vqSrQ/V5WLwPB51b+otXvWlbuxv54qOw+Amdy/1keqzYeRBsApIEMHgZIIQHb05bmZ366/XCluGsvI3b8W44a9X9UFQEeQtDM4rwJAFj7uU9kEvL9nFpou+9nfv3Co+JcyyQhAcdkCX2KzBUCHHnBxQd7Dvy2KLvLSYuC/o6+5YTt/AcCHCNDW+8YEwF8SFMc79MO/7bOXVSJ54b9E/pfA2S3xPzD9xaBb0uQ/DM7sj5tww7+yZIRsr87hv7c4c0SEXNG/Tr79/9M+5r+v9N6oTy3Qv5uAk/3QzeG/XcI1OVQkAUAQSV9Z7Qr9P/RrFrWXrMu/W2k5L5Qs479Zo2IBM/vkv6FuipzkFvG/SqIpagcly7+ltipxmI3kv0pmis91cfc/gWQecsRh8D93xzejiVXQv3WdNhEv9uO/D7mgYy612j+PyVPNaT2jv34LIpFt6c6/l5YW2Ga45L+LUp+2A2z9P39i5xSpRfc/piRx4P8P0r9eCC3zBAjlv5n4OKmIUf2/jj/kUAwgAsDqW/cjbNPQv9X2z6SYweS/aTdljlWd8L94R8vZ8SL3v1EZczv0b9K/GBbbqxgk5r9XdfyikfEDwPILMvas0gfAnx0V97en0r88xQk/0IPmvxGErZ681fa/9kCaiOy2/b/2BCK0wyDVvy2xROCT4ua/+5EBLOXxA0B7p53+BnkAQKKI/QV+y9i/qDznPFM86b/snWGNkkgHwC+ByugkUwdAR98lJFqQ2b9sL7HxZkPovyJNGM67oek/HzNy6BqA1D96EnqL7pLYv0v8nFypHeq/axL/u1FnB0AkSEHvxn8DQGt+gG5Pstm/QS1keLLK6b/Sk/O6mtGzPxU8pLcPNty/FssiPwWy4L+IZTNYLmzqvw4szKfSouq/G+XJHY1a87+TVW2LUjjfvwQaifgujuy/3VARaoMl2L9NFodfK+/qv+0QMvYfP+C/FvLf01HN67+ETOQysd8AwH71iI/eGgXAbHNSHrTg4L96GNJ2CFvsv6BnExReeAFA5CakvxSl+j8MzcbAuwDgv5bXzdT1Auy/uVq8/8x58z+uvPMNqzTnP2HlfZ3gqOG/Z5Uh1wDX7r8PUbMSo2P7P9VfBrXlxPI/tQvDXQ3H4r9sJXFt2GTvvyDssGgO0PG/WxT/uE4N+r+Bk03jWYvjv/bf8sHUYu+/rUXN8hUe3j9m5HB1yZCzv/yE3PUo0+K/qqAX9idJ8L9mByqLMMH5v4kHC7KQowHAm+sAswr15L8F7/a5DE/wv2JLsGADFwTAKQjVGovZCMDDkYbTbifnvwVbdNXyhfC/malhH7yI7D+oevd0GWDZP1sjk5AdouW/KH/hrXUg8b8KWmrpQ0sFQAzEAF/pTgBAhB1hfFzT5r9XK/wflZ7xv18hRuqKXAjA/5rUd9v1BED/tlxBd4bov7pQU4wLfPK/4pnwn0T/sj/c277XPF3jv02biiQ+Rum/zGkxMcl88r8Yk0HhJVzjv62yUUFRjfS/89MEdoPQ6r8TqikcRF/zvxQxghHovfY/cfM1eFWE5j9pcwp7GJPrv5ehC2fbYPO/KUV2nGg0/795OhmUaqEFwFQeuy4j+eq/ePiwytEp9L8DuqWfW+8BQLytJylXHPY/PlP4Qr8q7r+kDLLri0P1vxT4ShWL+Oo/DMsWg0zlv7/S9fINXGjtv73m373LRPW/+xg/Gaxd8b94MdQEfW0AwLjBLbDOHO+/kmm4ANp49L+cShSMMbAEwKyjUgWirAdAo2q2uqM08L99wKzM+7H2v3RdlNBXFgnA8S9+ewyV/z+vaSZre3Pxv6riWFiWZfi/2J7VSZZ60j+LES81zPn3v+OrlPMN3PK/quJYWJZl+L/OZbufkEcEQLCNB/1lPOO/Y2nmTbY/87+q4lhYlmX4v7CNB/1lPOO/zmW7n5BHBEBwKD1Aa57LP/XsSsw7RbU/PMDPJGsfoD/TqningGKIPzFtCLYmb3I/qYfrJr7eWz9pQmleXRFFP0rWlJkA2i8/pCvcttgTGD9Dt8IWbjMCPyCG4GRlhOs+1JI2GhDN1D7ns8cGvXK/Pi8m8UTJxac+hNTfA2z4kT7GI8kjLyt7Pv//////HwAI//////8zEAj/////fzIgCP////9vMjAI/////2MyQAj///8/YjJQCP///zdiMmAI////M2IycAj//78zYjKACP//qzNiMpAI/3+rM2IyoAj/D6szYjKwCP8DqzNiMsAIvwOrM2Iy0AifA6szYjLgCJkDqzNiMvAI//////8/Dwj//////ysfCP////9/KS8I/////z8pPwj/////OSlPCP///z84KV8I////Dzgpbwj///8OOCl/CP//Hw44KY8I//8PDjgpnwj/fw0OOCmvCP8PDQ44Kb8I/w0NDjgpzwj/DA0OOCnfCMcMDQ44Ke8IxAwNDjgp/wgHAAAABwAAAAEAAAACAAAABAAAAAMAAAAAAAAAAAAAAAcAAAADAAAAAQAAAAIAAAAFAAAABAAAAAAAAAAAAAAABAAAAAQAAAAAAAAAAgAAAAEAAAADAAAADgAAAAYAAAALAAAAAgAAAAcAAAABAAAAGAAAAAUAAAAKAAAAAQAAAAYAAAAAAAAAJgAAAAcAAAAMAAAAAwAAAAgAAAACAAAAMQAAAAkAAAAOAAAAAAAAAAUAAAAEAAAAOgAAAAgAAAANAAAABAAAAAkAAAADAAAAPwAAAAsAAAAGAAAADwAAAAoAAAAQAAAASAAAAAwAAAAHAAAAEAAAAAsAAAARAAAAUwAAAAoAAAAFAAAAEwAAAA4AAAAPAAAAYQAAAA0AAAAIAAAAEQAAAAwAAAASAAAAawAAAA4AAAAJAAAAEgAAAA0AAAATAAAAdQAAAA8AAAATAAAAEQAAABIAAAAQAAAABgAAAAIAAAADAAAABQAAAAQAAAAAAAAAAAAAAAAAAAAGAAAAAgAAAAMAAAABAAAABQAAAAQAAAAAAAAAAAAAAAcAAAAFAAAAAwAAAAQAAAABAAAAAAAAAAIAAAAAAAAAAgAAAAMAAAABAAAABQAAAAQAAAAGAAAAAAAAAAAAAAAYLURU+yH5PxgtRFT7Ifm/GC1EVPshCUAYLURU+yEJwGFsZ29zLmMAaDNOZWlnaGJvclJvdGF0aW9ucwBjZWxsc1RvTXVsdGlQb2x5LmMAY2VsbFRvRWRnZUFyY3MAAAEDAgQABAMFAQJjYW5jZWxBcmNQYWlycwBjcmVhdGVTb3J0YWJsZUxvb3AAZGlyZWN0ZWRFZGdlLmMAZGlyZWN0ZWRFZGdlVG9Cb3VuZGFyeQBhZGphY2VudEZhY2VEaXJbdG1wRmlqay5mYWNlXVtmaWprLmZhY2VdID09IEtJAGZhY2VpamsuYwBfZmFjZUlqa1BlbnRUb0NlbGxCb3VuZGFyeQBhZGphY2VudEZhY2VEaXJbY2VudGVySUpLLmZhY2VdW2ZhY2UyXSA9PSBLSQBfZmFjZUlqa1RvQ2VsbEJvdW5kYXJ5AGgzSW5kZXguYwBjb21wYWN0Q2VsbHMAdmVjM1RvQ2VsbABjZWxsVG9DaGlsZFBvcwB2YWxpZGF0ZUNoaWxkUG9zAHJldkRpciAhPSBJTlZBTElEX0RJR0lUAGxvY2FsaWouYwBjZWxsVG9Mb2NhbElqawBiYXNlQ2VsbCAhPSBvcmlnaW5CYXNlQ2VsbAAhKG9yaWdpbk9uUGVudCAmJiBpbmRleE9uUGVudCkAYmFzZUNlbGwgPT0gb3JpZ2luQmFzZUNlbGwALi4vaW5jbHVkZS9jb29yZGlqay5oAF91cEFwN0NoZWNrZWQAX3VwQXA3ckNoZWNrZWQAYmFzZUNlbGwgIT0gSU5WQUxJRF9CQVNFX0NFTEwAbG9jYWxJamtUb0NlbGwAIV9pc0Jhc2VDZWxsUGVudGFnb24oYmFzZUNlbGwpAGJhc2VDZWxsUm90YXRpb25zID49IDAAZ3JpZFBhdGhDZWxsc0ludGVycG9sYXRlAHBvbHlmaWxsLmMAaXRlclN0ZXBQb2x5Z29uQ29tcGFjdAAwAHZlcnRleC5jAHZlcnRleFJvdGF0aW9ucwBjZWxsVG9WZXJ0ZXg=`;var Ae=28400;function je(e){return e}function Me(e){return e.replace(/\b__Z[\w\d_]+/g,function(e){var t=je(e);return e===t?e:t+` [`+e+`]`})}function Ne(){var e=Error();if(!e.stack){try{throw Error(0)}catch(t){e=t}if(!e.stack)return`(no stack trace available)`}return e.stack.toString()}function Pe(){var e=Ne();return t.extraStackTrace&&(e+=` `+t.extraStackTrace()),Me(e)}function P(e,t,n,r){tt(`Assertion failed: `+C(e)+`, at: `+[t?C(t):`unknown filename`,n,r?C(r):`unknown function`])}function Fe(){return k.length}function Ie(e,t,n){A.set(A.subarray(t,t+n),e)}function Le(e){return t.___errno_location&&(M[t.___errno_location()>>2]=e),e}function Re(e){tt(`OOM`)}function ze(e){try{var t=new ArrayBuffer(e);return t.byteLength==e?(new Int8Array(t).set(k),Ge(t),te(t),1):void 0}catch{}}function Be(e){var t=Fe(),n=16777216,r=2147483648-n;if(e>r)return!1;for(var i=Math.max(t,16777216);i>4,i=(s&15)<<4|c>>2,a=(c&3)<<6|l,n+=String.fromCharCode(r),c!==64&&(n+=String.fromCharCode(i)),l!==64&&(n+=String.fromCharCode(a));while(u13780509?(t=rn(15,t)|0,t|0):(n=((e|0)<0)<<31>>31,a=gr(e|0,n|0,3,0)|0,r=T()|0,n=ur(e|0,n|0,1,0)|0,n=gr(a|0,r|0,n|0,T()|0)|0,n=ur(n|0,T()|0,1,0)|0,e=T()|0,i[t>>2]=n,i[t+4>>2]=e,t=0,t|0)}function ae(e,t,n,r){return e|=0,t|=0,n|=0,r|=0,oe(e,t,n,r,0)|0}function oe(e,t,n,r,a){e|=0,t|=0,n|=0,r|=0,a|=0;var o=0,s=0,c=0,l=0,u=0;if(l=M,M=M+16|0,s=l,!(se(e,t,n,r,a)|0))return r=0,M=l,r|0;do if((n|0)>=0){if((n|0)>13780509){if(o=rn(15,s)|0,o|0)break;c=s,s=i[c>>2]|0,c=i[c+4>>2]|0}else o=((n|0)<0)<<31>>31,u=gr(n|0,o|0,3,0)|0,c=T()|0,o=ur(n|0,o|0,1,0)|0,o=gr(u|0,c|0,o|0,T()|0)|0,o=ur(o|0,T()|0,1,0)|0,c=T()|0,i[s>>2]=o,i[s+4>>2]=c,s=o;if(Er(r|0,0,s<<3|0)|0,a|0){Er(a|0,0,s<<2|0)|0,o=ce(e,t,n,r,a,s,c,0)|0;break}o=or(s,4)|0,o?(u=ce(e,t,n,r,o,s,c,0)|0,ar(o),o=u):o=13}else o=2;while(0);return u=o,M=l,u|0}function se(e,t,n,r,a){e|=0,t|=0,n|=0,r|=0,a|=0;var o=0,s=0,c=0,l=0,u=0,d=0,f=0,p=0,m=0,h=0,g=0;if(g=M,M=M+16|0,m=g,h=g+8|0,p=m,i[p>>2]=e,i[p+4>>2]=t,(n|0)<0)return h=2,M=g,h|0;if(o=r,i[o>>2]=e,i[o+4>>2]=t,o=(a|0)!=0,o&&(i[a>>2]=0),xt(e,t)|0)return h=9,M=g,h|0;i[h>>2]=0;a:do if((n|0)>=1)if(o)for(d=1,u=0,f=0,p=1,o=e;;){if(!(u|f)){if(o=le(o,t,4,h,m)|0,o|0)break a;if(t=m,o=i[t>>2]|0,t=i[t+4>>2]|0,xt(o,t)|0){o=9;break a}}if(o=le(o,t,i[26864+(f<<2)>>2]|0,h,m)|0,o|0)break a;if(t=m,o=i[t>>2]|0,t=i[t+4>>2]|0,e=r+(d<<3)|0,i[e>>2]=o,i[e+4>>2]=t,i[a+(d<<2)>>2]=p,e=u+1|0,s=(e|0)==(p|0),c=f+1|0,l=(c|0)==6,xt(o,t)|0){o=9;break a}if(p=p+(l&s&1)|0,(p|0)>(n|0)){o=0;break}else d=d+1|0,u=s?0:e,f=s?l?0:c:f}else for(d=1,u=0,f=0,p=1,o=e;;){if(!(u|f)){if(o=le(o,t,4,h,m)|0,o|0)break a;if(t=m,o=i[t>>2]|0,t=i[t+4>>2]|0,xt(o,t)|0){o=9;break a}}if(o=le(o,t,i[26864+(f<<2)>>2]|0,h,m)|0,o|0)break a;if(t=m,o=i[t>>2]|0,t=i[t+4>>2]|0,e=r+(d<<3)|0,i[e>>2]=o,i[e+4>>2]=t,e=u+1|0,s=(e|0)==(p|0),c=f+1|0,l=(c|0)==6,xt(o,t)|0){o=9;break a}if(p=p+(l&s&1)|0,(p|0)>(n|0)){o=0;break}else d=d+1|0,u=s?0:e,f=s?l?0:c:f}else o=0;while(0);return h=o,M=g,h|0}function ce(e,t,n,r,a,o,s,c){e|=0,t|=0,n|=0,r|=0,a|=0,o|=0,s|=0,c|=0;var l=0,u=0,d=0,f=0,p=0,m=0,h=0,g=0,_=0,v=0;if(g=M,M=M+16|0,m=g+8|0,h=g,l=vr(e|0,t|0,o|0,s|0)|0,d=T()|0,f=r+(l<<3)|0,_=f,v=i[_>>2]|0,_=i[_+4>>2]|0,u=(v|0)==(e|0)&(_|0)==(t|0),!((v|0)==0&(_|0)==0|u))do l=ur(l|0,d|0,1,0)|0,l=_r(l|0,T()|0,o|0,s|0)|0,d=T()|0,f=r+(l<<3)|0,v=f,_=i[v>>2]|0,v=i[v+4>>2]|0,u=(_|0)==(e|0)&(v|0)==(t|0);while(!((_|0)==0&(v|0)==0|u));if(l=a+(l<<2)|0,u&&(i[l>>2]|0)<=(c|0)||(v=f,i[v>>2]=e,i[v+4>>2]=t,i[l>>2]=c,(c|0)>=(n|0)))return v=0,M=g,v|0;switch(u=c+1|0,i[m>>2]=0,l=le(e,t,2,m,h)|0,l|0){case 9:p=9;break;case 0:l=h,l=ce(i[l>>2]|0,i[l+4>>2]|0,n,r,a,o,s,u)|0,l||(p=9);break;default:}a:do if((p|0)==9){switch(i[m>>2]=0,l=le(e,t,3,m,h)|0,l|0){case 9:break;case 0:if(l=h,l=ce(i[l>>2]|0,i[l+4>>2]|0,n,r,a,o,s,u)|0,l|0)break a;break;default:break a}switch(i[m>>2]=0,l=le(e,t,1,m,h)|0,l|0){case 9:break;case 0:if(l=h,l=ce(i[l>>2]|0,i[l+4>>2]|0,n,r,a,o,s,u)|0,l|0)break a;break;default:break a}switch(i[m>>2]=0,l=le(e,t,5,m,h)|0,l|0){case 9:break;case 0:if(l=h,l=ce(i[l>>2]|0,i[l+4>>2]|0,n,r,a,o,s,u)|0,l|0)break a;break;default:break a}switch(i[m>>2]=0,l=le(e,t,4,m,h)|0,l|0){case 9:break;case 0:if(l=h,l=ce(i[l>>2]|0,i[l+4>>2]|0,n,r,a,o,s,u)|0,l|0)break a;break;default:break a}switch(i[m>>2]=0,l=le(e,t,6,m,h)|0,l|0){case 9:break;case 0:if(l=h,l=ce(i[l>>2]|0,i[l+4>>2]|0,n,r,a,o,s,u)|0,l|0)break a;break;default:break a}return v=0,M=g,v|0}while(0);return v=l,M=g,v|0}function le(e,t,n,r,a){e|=0,t|=0,n|=0,r|=0,a|=0;var o=0,s=0,c=0,l=0,u=0,d=0,f=0,p=0,m=0,h=0;if(n>>>0>6)return a=1,a|0;s=(i[r>>2]|0)%6|0,i[r>>2]=s;a:do if((s|0)>0)for(o=0;;){switch(n|0){case 1:n=5;break;case 5:n=4;break;case 4:n=6;break;case 6:n=2;break;case 2:n=3;break;case 3:n=1;break;default:}if(o=o+1|0,(o|0)==(s|0))break a}while(0);if(f=z(e|0,t|0,45)|0,T()|0,d=f&127,d>>>0>121)return a=5,a|0;l=kt(e,t)|0,o=z(e|0,t|0,52)|0,T()|0,o&=15;b:do if(!o)u=15;else{for(;;){if(s=(15-o|0)*3|0,c=z(e|0,t|0,s|0)|0,T()|0,c&=7,(c|0)==7){t=5;break}if(h=(Ft(o)|0)==0,o=o+-1|0,p=B(7,0,s|0)|0,t&=~(T()|0),m=B(i[(h?432:16)+(c*28|0)+(n<<2)>>2]|0,0,s|0)|0,s=T()|0,n=i[(h?640:224)+(c*28|0)+(n<<2)>>2]|0,e=m|e&~p,t=s|t,!n){n=0;break b}if(!o){u=15;break b}}return t|0}while(0);(u|0)==15&&(h=i[848+(d*28|0)+(n<<2)>>2]|0,m=B(h|0,0,45)|0,e=m|e,t=T()|0|t&-1040385,n=i[4272+(d*28|0)+(n<<2)>>2]|0,(h&127|0)==127&&(h=B(i[848+(d*28|0)+20>>2]|0,0,45)|0,t=T()|0|t&-1040385,n=i[4272+(d*28|0)+20>>2]|0,e=jt(h|e,t)|0,t=T()|0,i[r>>2]=(i[r>>2]|0)+1)),c=z(e|0,t|0,45)|0,T()|0,c&=127;c:do if(Se(c)|0){d:do if((kt(e,t)|0)==1){if((d|0)!=(c|0))if(Oe(c,i[7696+(d*28|0)>>2]|0)|0){e=Nt(e,t)|0,s=1,t=T()|0;break}else E(27634,26928,533,26936);switch(l|0){case 3:e=jt(e,t)|0,t=T()|0,i[r>>2]=(i[r>>2]|0)+1,s=0;break d;case 5:e=Nt(e,t)|0,t=T()|0,i[r>>2]=(i[r>>2]|0)+5,s=0;break d;case 0:return h=9,h|0;default:return h=1,h|0}}else s=0;while(0);if((n|0)>0){o=0;do e=At(e,t)|0,t=T()|0,o=o+1|0;while((o|0)!=(n|0))}if((d|0)!=(c|0)){if(!(Ce(c)|0)){if((s|0)!=0|(kt(e,t)|0)!=5)break;i[r>>2]=(i[r>>2]|0)+1;break}switch(f&127){case 8:case 118:break c;default:}(kt(e,t)|0)!=3&&(i[r>>2]=(i[r>>2]|0)+1)}}else if((n|0)>0){o=0;do e=jt(e,t)|0,t=T()|0,o=o+1|0;while((o|0)!=(n|0))}while(0);return i[r>>2]=((i[r>>2]|0)+n|0)%6|0,h=a,i[h>>2]=e,i[h+4>>2]=t,h=0,h|0}function ue(e,t,n,r){return e|=0,t|=0,n|=0,r|=0,de(e,t,n,r)|0?(Er(r|0,0,n*48|0)|0,r=fe(e,t,n,r)|0,r|0):(r=0,r|0)}function de(e,t,n,r){e|=0,t|=0,n|=0,r|=0;var a=0,o=0,s=0,c=0,l=0,u=0,d=0,f=0,p=0,m=0,h=0;if(h=M,M=M+16|0,p=h,m=h+8|0,f=p,i[f>>2]=e,i[f+4>>2]=t,(n|0)<0)return m=2,M=h,m|0;if(!n)return m=r,i[m>>2]=e,i[m+4>>2]=t,m=0,M=h,m|0;i[m>>2]=0;a:do if(xt(e,t)|0)e=9;else{a=0,f=e;do{if(e=le(f,t,4,m,p)|0,e|0)break a;if(t=p,f=i[t>>2]|0,t=i[t+4>>2]|0,a=a+1|0,xt(f,t)|0){e=9;break a}}while((a|0)<(n|0));d=r,i[d>>2]=f,i[d+4>>2]=t,d=n+-1|0,u=0,e=1;do{if(a=26864+(u<<2)|0,(u|0)==5)for(s=i[a>>2]|0,o=0,a=e;;){if(e=p,e=le(i[e>>2]|0,i[e+4>>2]|0,s,m,p)|0,e|0)break a;if((o|0)!=(d|0))if(l=p,c=i[l>>2]|0,l=i[l+4>>2]|0,e=r+(a<<3)|0,i[e>>2]=c,i[e+4>>2]=l,!(xt(c,l)|0))e=a+1|0;else{e=9;break a}else e=a;if(o=o+1|0,(o|0)>=(n|0))break;a=e}else for(s=p,l=i[a>>2]|0,c=0,a=e,o=i[s>>2]|0,s=i[s+4>>2]|0;;){if(e=le(o,s,l,m,p)|0,e|0)break a;if(s=p,o=i[s>>2]|0,s=i[s+4>>2]|0,e=r+(a<<3)|0,i[e>>2]=o,i[e+4>>2]=s,e=a+1|0,xt(o,s)|0){e=9;break a}if(c=c+1|0,(c|0)>=(n|0))break;a=e}u=u+1|0}while(u>>>0<6);e=p,e=(f|0)==(i[e>>2]|0)&&(t|0)==(i[e+4>>2]|0)?0:9}while(0);return m=e,M=h,m|0}function fe(e,t,n,r){e|=0,t|=0,n|=0,r|=0;var a=0,o=0,s=0,c=0,l=0,u=0,d=0,f=0,p=0;if(f=M,M=M+16|0,s=f,!n)return i[r>>2]=e,i[r+4>>2]=t,r=0,M=f,r|0;do if((n|0)>=0){if((n|0)>13780509){if(a=rn(15,s)|0,a|0)break;o=s,a=i[o>>2]|0,o=i[o+4>>2]|0}else a=((n|0)<0)<<31>>31,d=gr(n|0,a|0,3,0)|0,o=T()|0,a=ur(n|0,a|0,1,0)|0,a=gr(d|0,o|0,a|0,T()|0)|0,a=ur(a|0,T()|0,1,0)|0,o=T()|0,d=s,i[d>>2]=a,i[d+4>>2]=o;if(u=or(a,8)|0,!u)a=13;else{if(d=or(a,4)|0,!d){ar(u),a=13;break}if(a=ce(e,t,n,u,d,a,o,0)|0,a|0){ar(u),ar(d);break}if(t=i[s>>2]|0,s=i[s+4>>2]|0,(s|0)>0|(s|0)==0&t>>>0>0){a=0,c=0,l=0;do e=u+(c<<3)|0,o=i[e>>2]|0,e=i[e+4>>2]|0,!((o|0)==0&(e|0)==0)&&(i[d+(c<<2)>>2]|0)==(n|0)&&(p=r+(a<<3)|0,i[p>>2]=o,i[p+4>>2]=e,a=a+1|0),c=ur(c|0,l|0,1,0)|0,l=T()|0;while((l|0)<(s|0)|(l|0)==(s|0)&c>>>0>>0)}ar(u),ar(d),a=0}}else a=2;while(0);return p=a,M=f,p|0}function pe(e,t,n,r){e|=0,t|=0,n|=0,r|=0;var a=0,o=0,s=0,c=0,l=0,u=0;for(c=M,M=M+16|0,o=c,s=c+8|0,a=(xt(e,t)|0)==0,a=a?1:2;;){if(i[s>>2]=0,u=(le(e,t,a,s,o)|0)==0,l=o,u&((i[l>>2]|0)==(n|0)?(i[l+4>>2]|0)==(r|0):0)){e=4;break}if(a=a+1|0,a>>>0>=7){a=7,e=4;break}}return(e|0)==4?(M=c,a|0):0}function me(e,t,n,r){e|=0,t|=0,n|=0,r|=0;var a=0,o=0,s=0,c=0,l=0,u=0;if(c=M,M=M+48|0,a=c+16|0,o=c+8|0,s=c,n=Tn(n)|0,n|0)return s=n,M=c,s|0;if(u=e,l=i[u+4>>2]|0,n=o,i[n>>2]=i[u>>2],i[n+4>>2]=l,wn(o,a),n=Be(a,t,s)|0,!n){if(t=i[o>>2]|0,o=i[e+8>>2]|0,(o|0)>0){a=i[e+12>>2]|0,n=0;do t=(i[a+(n<<3)>>2]|0)+t|0,n=n+1|0;while((n|0)<(o|0))}n=s,a=i[n>>2]|0,n=i[n+4>>2]|0,o=((t|0)<0)<<31>>31,(n|0)<(o|0)|(n|0)==(o|0)&a>>>0>>0?(n=s,i[n>>2]=t,i[n+4>>2]=o,n=o):t=a,l=ur(t|0,n|0,12,0)|0,u=T()|0,n=s,i[n>>2]=l,i[n+4>>2]=u,n=r,i[n>>2]=l,i[n+4>>2]=u,n=0}return u=n,M=c,u|0}function he(e,t,n,r,o,s,c){e|=0,t|=0,n|=0,r|=0,o|=0,s|=0,c|=0;var l=0,u=0,d=0,f=0,p=0,m=0,h=0,g=0,_=0,v=0,y=0,b=0,x=0,S=0,C=0,w=0,E=0,D=0,O=0,k=0,A=0,j=0,N=0,ee=0,te=0,ne=0,re=0,ie=0,ae=0;if(te=M,M=M+64|0,A=te+48|0,j=te+32|0,N=te+24|0,C=te+8|0,w=te,u=i[e>>2]|0,(u|0)<=0)return ee=0,M=te,ee|0;for(E=e+4|0,D=A+8|0,O=j+8|0,k=C+8|0,l=0,x=0;;){d=i[E>>2]|0,b=d+(x<<4)|0,i[A>>2]=i[b>>2],i[A+4>>2]=i[b+4>>2],i[A+8>>2]=i[b+8>>2],i[A+12>>2]=i[b+12>>2],(x|0)==(u+-1|0)?(i[j>>2]=i[d>>2],i[j+4>>2]=i[d+4>>2],i[j+8>>2]=i[d+8>>2],i[j+12>>2]=i[d+12>>2]):(b=d+(x+1<<4)|0,i[j>>2]=i[b>>2],i[j+4>>2]=i[b+4>>2],i[j+8>>2]=i[b+8>>2],i[j+12>>2]=i[b+12>>2]),u=Ve(A,j,r,N)|0;a:do if(u)d=0,l=u;else if(u=N,d=i[u>>2]|0,u=i[u+4>>2]|0,(u|0)>0|(u|0)==0&d>>>0>0){y=0,b=0;b:for(;;){if(re=1/(+(d>>>0)+4294967296*(u|0)),ae=+a[A>>3],u=dr(d|0,u|0,y|0,b|0)|0,ie=+(u>>>0)+4294967296*(T()|0),ne=+(y>>>0)+4294967296*(b|0),a[C>>3]=re*(ae*ie)+re*(+a[j>>3]*ne),a[k>>3]=re*(+a[D>>3]*ie)+re*(+a[O>>3]*ne),u=It(C,r,w)|0,u|0){l=u;break}v=w,_=i[v>>2]|0,v=i[v+4>>2]|0,m=vr(_|0,v|0,t|0,n|0)|0,f=T()|0,u=c+(m<<3)|0,p=u,d=i[p>>2]|0,p=i[p+4>>2]|0;c:do if((d|0)==0&(p|0)==0)S=u,ee=16;else for(h=0,g=0;;){if((h|0)>(n|0)|(h|0)==(n|0)&g>>>0>t>>>0){l=1;break b}if((d|0)==(_|0)&(p|0)==(v|0))break c;if(u=ur(m|0,f|0,1,0)|0,m=_r(u|0,T()|0,t|0,n|0)|0,f=T()|0,g=ur(g|0,h|0,1,0)|0,h=T()|0,u=c+(m<<3)|0,p=u,d=i[p>>2]|0,p=i[p+4>>2]|0,(d|0)==0&(p|0)==0){S=u,ee=16;break}}while(0);if((ee|0)==16&&(ee=0,!((_|0)==0&(v|0)==0))&&(g=S,i[g>>2]=_,i[g+4>>2]=v,g=s+(i[o>>2]<<3)|0,i[g>>2]=_,i[g+4>>2]=v,g=o,g=ur(i[g>>2]|0,i[g+4>>2]|0,1,0)|0,_=T()|0,v=o,i[v>>2]=g,i[v+4>>2]=_),y=ur(y|0,b|0,1,0)|0,b=T()|0,u=N,d=i[u>>2]|0,u=i[u+4>>2]|0,!((u|0)>(b|0)|(u|0)==(b|0)&d>>>0>y>>>0)){d=1;break a}}d=0}else d=1;while(0);if(x=x+1|0,!d){ee=21;break}if(u=i[e>>2]|0,(x|0)>=(u|0)){l=0,ee=21;break}}return(ee|0)==21?(M=te,l|0):0}function ge(e,t,n,r){e|=0,t|=0,n|=0,r|=0;var a=0,o=0,s=0,c=0,l=0,u=0,d=0,f=0,p=0,m=0,h=0,g=0,_=0,v=0,y=0,b=0,x=0,S=0,C=0,w=0,E=0,D=0,O=0,k=0,A=0,j=0,N=0,ee=0,te=0,ne=0,re=0;if(re=M,M=M+112|0,N=re+80|0,l=re+72|0,ee=re,te=re+56|0,a=Tn(n)|0,a|0)return ne=a,M=re,ne|0;if(u=e+8|0,ne=ir((i[u>>2]<<5)+32|0)|0,!ne)return ne=13,M=re,ne|0;if(En(e,ne),a=Tn(n)|0,!a){if(A=e,j=i[A+4>>2]|0,a=l,i[a>>2]=i[A>>2],i[a+4>>2]=j,wn(l,N),a=Be(N,t,ee)|0,a)A=0,j=0;else{if(a=i[l>>2]|0,o=i[u>>2]|0,(o|0)>0){s=i[e+12>>2]|0,n=0;do a=(i[s+(n<<3)>>2]|0)+a|0,n=n+1|0;while((n|0)!=(o|0));n=a}else n=a;a=ee,o=i[a>>2]|0,a=i[a+4>>2]|0,s=((n|0)<0)<<31>>31,(a|0)<(s|0)|(a|0)==(s|0)&o>>>0>>0?(a=ee,i[a>>2]=n,i[a+4>>2]=s,a=s):n=o,A=ur(n|0,a|0,12,0)|0,j=T()|0,a=ee,i[a>>2]=A,i[a+4>>2]=j,a=0}if(!a){if(n=or(A,8)|0,!n)return ar(ne),ne=13,M=re,ne|0;if(c=or(A,8)|0,!c)return ar(ne),ar(n),ne=13,M=re,ne|0;O=N,i[O>>2]=0,i[O+4>>2]=0,O=e,k=i[O+4>>2]|0,a=l,i[a>>2]=i[O>>2],i[a+4>>2]=k,a=he(l,A,j,t,N,n,c)|0;a:do if(a)ar(n),ar(c),ar(ne);else{b:do if((i[u>>2]|0)>0){for(s=e+12|0,o=0;a=he((i[s>>2]|0)+(o<<3)|0,A,j,t,N,n,c)|0,o=o+1|0,!(a|0);)if((o|0)>=(i[u>>2]|0))break b;ar(n),ar(c),ar(ne);break a}while(0);(j|0)>0|(j|0)==0&A>>>0>0&&Er(c|0,0,A<<3|0)|0,k=N,O=i[k+4>>2]|0;c:do if((O|0)>0|(O|0)==0&(i[k>>2]|0)>>>0>0){w=n,E=c,D=n,O=c,k=n,a=n,x=n,S=c,C=c,n=c;d:for(;;){for(_=0,v=0,y=0,b=0,o=0,s=0;;){c=ee,l=c+56|0;do i[c>>2]=0,c=c+4|0;while((c|0)<(l|0));if(t=w+(_<<3)|0,u=i[t>>2]|0,t=i[t+4>>2]|0,se(u,t,1,ee,0)|0){c=ee,l=c+56|0;do i[c>>2]=0,c=c+4|0;while((c|0)<(l|0));c=or(7,4)|0,c|0&&(ce(u,t,1,ee,c,7,0,0)|0,ar(c))}for(g=0;;){h=ee+(g<<3)|0,m=i[h>>2]|0,h=i[h+4>>2]|0;e:do if((m|0)==0&(h|0)==0)c=o,l=s;else{if(d=vr(m|0,h|0,A|0,j|0)|0,u=T()|0,c=r+(d<<3)|0,t=c,l=i[t>>2]|0,t=i[t+4>>2]|0,!((l|0)==0&(t|0)==0)){f=0,p=0;do{if((f|0)>(j|0)|(f|0)==(j|0)&p>>>0>A>>>0)break d;if((l|0)==(m|0)&(t|0)==(h|0)){c=o,l=s;break e}c=ur(d|0,u|0,1,0)|0,d=_r(c|0,T()|0,A|0,j|0)|0,u=T()|0,p=ur(p|0,f|0,1,0)|0,f=T()|0,c=r+(d<<3)|0,t=c,l=i[t>>2]|0,t=i[t+4>>2]|0}while(!((l|0)==0&(t|0)==0))}if((m|0)==0&(h|0)==0){c=o,l=s;break}zt(m,h,te)|0,Dn(e,ne,te)|0&&(p=ur(o|0,s|0,1,0)|0,s=T()|0,f=c,i[f>>2]=m,i[f+4>>2]=h,o=E+(o<<3)|0,i[o>>2]=m,i[o+4>>2]=h,o=p),c=o,l=s}while(0);if(g=g+1|0,g>>>0>=7)break;o=c,s=l}if(_=ur(_|0,v|0,1,0)|0,v=T()|0,y=ur(y|0,b|0,1,0)|0,b=T()|0,s=N,o=i[s>>2]|0,s=i[s+4>>2]|0,(b|0)<(s|0)|(b|0)==(s|0)&y>>>0>>0)o=c,s=l;else break}if((s|0)>0|(s|0)==0&o>>>0>0){o=0,s=0;do b=w+(o<<3)|0,i[b>>2]=0,i[b+4>>2]=0,o=ur(o|0,s|0,1,0)|0,s=T()|0,b=N,y=i[b+4>>2]|0;while((s|0)<(y|0)|((s|0)==(y|0)?o>>>0<(i[b>>2]|0)>>>0:0))}if(b=N,i[b>>2]=c,i[b+4>>2]=l,(l|0)>0|(l|0)==0&c>>>0>0)g=n,_=C,v=k,y=S,b=E,n=x,C=a,S=D,x=g,a=_,k=O,O=v,D=y,E=w,w=b;else break c}ar(D),ar(O),ar(ne),a=1;break a}else a=c;while(0);ar(ne),ar(n),ar(a),a=0}while(0);return ne=a,M=re,ne|0}}return ar(ne),ne=a,M=re,ne|0}function _e(e,t,n){e|=0,t|=0,n|=0;var r=0,a=0,o=0,s=0,c=0,l=0,u=0;if(c=M,M=M+16|0,s=c,e=Ue(e,t,((t|0)<0)<<31>>31,s)|0,e|0)return s=e,M=c,s|0;if(o=ln(s,n)|0,n=s+4|0,(i[s>>2]|0)>0){t=0;do{if(a=i[n>>2]|0,r=a+(t<<4)+4|0,ar(i[r>>2]|0),i[r>>2]=0,i[a+(t<<4)>>2]=0,r=a+(t<<4)+8|0,a=a+(t<<4)+12|0,(i[r>>2]|0)>0){e=0;do l=i[a>>2]|0,u=l+(e<<3)+4|0,ar(i[u>>2]|0),i[u>>2]=0,i[l+(e<<3)>>2]=0,e=e+1|0;while((e|0)<(i[r>>2]|0))}ar(i[a>>2]|0),i[a>>2]=0,i[r>>2]=0,t=t+1|0}while((t|0)<(i[s>>2]|0))}return ar(i[n>>2]|0),i[n>>2]=0,i[s>>2]=0,u=o,M=c,u|0}function ve(e,t){e|=0,t|=0;var n=0,r=0,o=0,s=0,c=0,l=0,u=0,p=0,m=0,h=0;if(c=i[e>>2]|0,(c|0)<=0)return o=0,r=0,c=o<0,r=12.566370614359172-r,r=o+r,o=c?r:o,a[t>>3]=o,0;if(s=i[e+4>>2]|0,e=(c|0)!=1&1,l=a[s>>3]*.5+.7853981633974483,o=a[s+(e<<4)>>3]*.5+.7853981633974483,n=f(+l)*+f(+o),r=a[s+(e<<4)+8>>3]-+a[s+8>>3],n=_(+(+f(+r)*n),+(d(+l)*+d(+o)+ +d(+r)*n))*-2,r=n+0,n=r-n,(c|0)==1)return l=r,o=n,c=l<0,o=12.566370614359172-o,o=l+o,l=c?o:l,a[t>>3]=l,0;for(e=1,o=r;m=e,e=e+1|0,h=(e|0)%(c|0)|0,p=a[s+(m<<4)>>3]*.5+.7853981633974483,u=a[s+(h<<4)>>3]*.5+.7853981633974483,r=f(+p)*+f(+u),l=a[s+(h<<4)+8>>3]-+a[s+(m<<4)+8>>3],n=_(+(+f(+l)*r),+(d(+p)*+d(+u)+ +d(+l)*r))*-2-n,r=o+n,n=r-o-n,!((e|0)>=(c|0));)o=r;return h=r<0,p=12.566370614359172-n,p=r+p,p=h?p:r,a[t>>3]=p,0}function ye(e,t,n){e|=0,t|=0,n|=0;var r=0,a=0,o=0,s=0;return s=M,M=M+192|0,r=s+176|0,a=s,o=s+168|0,e=Bt(e,t,a)|0,e|0?(o=e,M=s,o|0):(i[o>>2]=i[a>>2],i[o+4>>2]=a+8,i[r>>2]=i[o>>2],i[r+4>>2]=i[o+4>>2],ve(r,n)|0,o=0,M=s,o|0)}function be(e,t,n){e|=0,t|=0,n|=0;var r=0,o=0,s=0,c=0;return c=M,M=M+192|0,r=c+176|0,o=c,s=c+168|0,e=Bt(e,t,o)|0,e?(s=e,M=c,s|0):(i[s>>2]=i[o>>2],i[s+4>>2]=o+8,i[r>>2]=i[s>>2],i[r+4>>2]=i[s+4>>2],ve(r,n)|0,a[n>>3]=a[n>>3]*40589732.49931477,s=0,M=c,s|0)}function xe(e,t,n){e|=0,t|=0,n|=0;var r=0,o=0,s=0,c=0;return c=M,M=M+192|0,r=c+176|0,o=c,s=c+168|0,e=Bt(e,t,o)|0,e?(s=e,M=c,s|0):(i[s>>2]=i[o>>2],i[s+4>>2]=o+8,i[r>>2]=i[s>>2],i[r+4>>2]=i[s+4>>2],ve(r,n)|0,a[n>>3]=a[n>>3]*40589732.49931477*1e6,s=0,M=c,s|0)}function Se(e){return e|=0,e>>>0>121?(e=0,e|0):(e=i[7696+(e*28|0)+16>>2]|0,e|0)}function Ce(e){return e|=0,(e|0)==4|(e|0)==117|0}function we(e){return e|=0,i[11120+((i[e>>2]|0)*216|0)+((i[e+4>>2]|0)*72|0)+((i[e+8>>2]|0)*24|0)+(i[e+12>>2]<<3)>>2]|0}function Te(e){return e|=0,i[11120+((i[e>>2]|0)*216|0)+((i[e+4>>2]|0)*72|0)+((i[e+8>>2]|0)*24|0)+(i[e+12>>2]<<3)+4>>2]|0}function Ee(e,t){e|=0,t|=0,e=7696+(e*28|0)|0,i[t>>2]=i[e>>2],i[t+4>>2]=i[e+4>>2],i[t+8>>2]=i[e+8>>2],i[t+12>>2]=i[e+12>>2]}function De(e,t){e|=0,t|=0;var n=0,r=0;if(t>>>0>20)return t=-1,t|0;do if((i[11120+(t*216|0)>>2]|0)!=(e|0))if((i[11120+(t*216|0)+8>>2]|0)!=(e|0))if((i[11120+(t*216|0)+16>>2]|0)!=(e|0))if((i[11120+(t*216|0)+24>>2]|0)!=(e|0))if((i[11120+(t*216|0)+32>>2]|0)!=(e|0))if((i[11120+(t*216|0)+40>>2]|0)!=(e|0))if((i[11120+(t*216|0)+48>>2]|0)!=(e|0))if((i[11120+(t*216|0)+56>>2]|0)!=(e|0))if((i[11120+(t*216|0)+64>>2]|0)!=(e|0))if((i[11120+(t*216|0)+72>>2]|0)!=(e|0))if((i[11120+(t*216|0)+80>>2]|0)!=(e|0))if((i[11120+(t*216|0)+88>>2]|0)!=(e|0))if((i[11120+(t*216|0)+96>>2]|0)!=(e|0))if((i[11120+(t*216|0)+104>>2]|0)!=(e|0))if((i[11120+(t*216|0)+112>>2]|0)!=(e|0))if((i[11120+(t*216|0)+120>>2]|0)!=(e|0))if((i[11120+(t*216|0)+128>>2]|0)!=(e|0))if((i[11120+(t*216|0)+136>>2]|0)==(e|0))e=2,n=1,r=2;else{if((i[11120+(t*216|0)+144>>2]|0)==(e|0)){e=0,n=2,r=0;break}if((i[11120+(t*216|0)+152>>2]|0)==(e|0)){e=0,n=2,r=1;break}if((i[11120+(t*216|0)+160>>2]|0)==(e|0)){e=0,n=2,r=2;break}if((i[11120+(t*216|0)+168>>2]|0)==(e|0)){e=1,n=2,r=0;break}if((i[11120+(t*216|0)+176>>2]|0)==(e|0)){e=1,n=2,r=1;break}if((i[11120+(t*216|0)+184>>2]|0)==(e|0)){e=1,n=2,r=2;break}if((i[11120+(t*216|0)+192>>2]|0)==(e|0)){e=2,n=2,r=0;break}if((i[11120+(t*216|0)+200>>2]|0)==(e|0)){e=2,n=2,r=1;break}if((i[11120+(t*216|0)+208>>2]|0)==(e|0)){e=2,n=2,r=2;break}else e=-1;return e|0}else e=2,n=1,r=1;else e=2,n=1,r=0;else e=1,n=1,r=2;else e=1,n=1,r=1;else e=1,n=1,r=0;else e=0,n=1,r=2;else e=0,n=1,r=1;else e=0,n=1,r=0;else e=2,n=0,r=2;else e=2,n=0,r=1;else e=2,n=0,r=0;else e=1,n=0,r=2;else e=1,n=0,r=1;else e=1,n=0,r=0;else e=0,n=0,r=2;else e=0,n=0,r=1;else e=0,n=0,r=0;while(0);return t=i[11120+(t*216|0)+(n*72|0)+(e*24|0)+(r<<3)+4>>2]|0,t|0}function Oe(e,t){return e|=0,t|=0,(i[7696+(e*28|0)+20>>2]|0)==(t|0)?(t=1,t|0):(t=(i[7696+(e*28|0)+24>>2]|0)==(t|0),t|0)}function ke(e,t){return e|=0,t|=0,i[848+(e*28|0)+(t<<2)>>2]|0}function Ae(e,t){return e|=0,t|=0,(i[848+(e*28|0)>>2]|0)==(t|0)?(t=0,t|0):(i[848+(e*28|0)+4>>2]|0)==(t|0)?(t=1,t|0):(i[848+(e*28|0)+8>>2]|0)==(t|0)?(t=2,t|0):(i[848+(e*28|0)+12>>2]|0)==(t|0)?(t=3,t|0):(i[848+(e*28|0)+16>>2]|0)==(t|0)?(t=4,t|0):(i[848+(e*28|0)+20>>2]|0)==(t|0)?(t=5,t|0):((i[848+(e*28|0)+24>>2]|0)==(t|0)?6:7)|0}function je(){return 122}function Me(e){e|=0;var t=0,n=0,r=0;t=0;do B(t|0,0,45)|0,r=T()|134225919,n=e+(t<<3)|0,i[n>>2]=-1,i[n+4>>2]=r,t=t+1|0;while((t|0)!=122);return 0}function Ne(e){e|=0;var t=0,n=0,r=0;return r=+a[e+16>>3],n=+a[e+24>>3],t=r-n,+(r>3]<+a[e+24>>3]|0}function P(e){return e|=0,+(a[e>>3]-+a[e+8>>3])}function Fe(e,t){e|=0,t|=0;var n=0,r=0,i=0;return n=+a[t>>3],!(n>=+a[e+8>>3])||!(n<=+a[e>>3])?(t=0,t|0):(r=+a[e+16>>3],n=+a[e+24>>3],i=+a[t+8>>3],t=i>=n,e=i<=r&1,r>3]<+a[t+8>>3]||+a[e+8>>3]>+a[t>>3]?(r=0,r|0):(o=+a[e+16>>3],n=e+24|0,d=+a[n>>3],s=o>3],i=t+24|0,l=+a[i>>3],c=u>3],t)||(d=+Yt(+a[n>>3],e),d>+Yt(+a[r>>3],t))?(c=0,c|0):(c=1,c|0))}function Le(e,t,n,r){e|=0,t|=0,n|=0,r|=0;var o=0,s=0,c=0,l=0,u=0;s=+a[e+16>>3],u=+a[e+24>>3],e=s>3],c=+a[t+24>>3],o=l>2]=e?o|t?1:2:0,i[r>>2]=o?e?1:t?2:1:0}function Re(e,t){e|=0,t|=0;var n=0,r=0,i=0,o=0,s=0,c=0,l=0,u=0,d=0;return+a[e>>3]<+a[t>>3]||+a[e+8>>3]>+a[t+8>>3]?(r=0,r|0):(r=e+16|0,l=+a[r>>3],o=+a[e+24>>3],s=l>3],i=t+24|0,u=+a[i>>3],c=d>3],t)?(d=+Yt(+a[r>>3],e),c=d>=+Yt(+a[n>>3],t),c|0):(c=0,c|0))}function ze(e,t){e|=0,t|=0;var n=0,r=0,o=0,s=0,c=0,l=0;o=M,M=M+176|0,r=o,i[r>>2]=4,l=+a[t>>3],a[r+8>>3]=l,s=+a[t+16>>3],a[r+16>>3]=s,a[r+24>>3]=l,l=+a[t+24>>3],a[r+32>>3]=l,c=+a[t+8>>3],a[r+40>>3]=c,a[r+48>>3]=l,a[r+56>>3]=c,a[r+64>>3]=s,t=r+72|0,n=t+96|0;do i[t>>2]=0,t=t+4|0;while((t|0)<(n|0));wr(e|0,r|0,168)|0,M=o}function Be(e,t,n){e|=0,t|=0,n|=0;var r=0,s=0,u=0,d=0,f=0,p=0,m=0,h=0,g=0,_=0,y=0,x=0,S=0,C=0;x=M,M=M+288|0,h=x+264|0,g=x+96|0,m=x,f=m,p=f+96|0;do i[f>>2]=0,f=f+4|0;while((f|0)<(p|0));return t=F(t,m)|0,t|0?(y=t,M=x,y|0):(p=m,m=i[p>>2]|0,p=i[p+4>>2]|0,zt(m,p,h)|0,Bt(m,p,g)|0,d=+Zt(h,g+8|0),a[h>>3]=+a[e>>3],p=h+8|0,a[p>>3]=+a[e+16>>3],a[g>>3]=+a[e+8>>3],m=g+8|0,a[m>>3]=+a[e+24>>3],s=+Zt(h,g),C=a[p>>3]-+a[m>>3],u=+l(+C),S=a[h>>3]-+a[g>>3],r=+l(+S),!(C==0|S==0)&&(C=+xr(+u,+r),C=+v(+(s*s/+Sr(+(C/+Sr(+u,+r)),3)/(d*(d*2.59807621135)*.8))),a[o>>3]=C,_=~~C>>>0,y=+l(C)>=1?C>0?~~+b(+c(C/4294967296),4294967295)>>>0:~~+v((C-+(~~C>>>0))/4294967296)>>>0:0,(i[o+4>>2]&2146435072|0)!=2146435072)?(g=(_|0)==0&(y|0)==0,t=n,i[t>>2]=g?1:_,i[t+4>>2]=g?0:y,t=0):t=1,y=t,M=x,y|0)}function Ve(e,t,n,r){e|=0,t|=0,n|=0,r|=0;var s=0,u=0,d=0,f=0,p=0,m=0,h=0;m=M,M=M+288|0,d=m+264|0,f=m+96|0,p=m,s=p,u=s+96|0;do i[s>>2]=0,s=s+4|0;while((s|0)<(u|0));return n=F(n,p)|0,n|0?(r=n,M=m,r|0):(n=p,s=i[n>>2]|0,n=i[n+4>>2]|0,zt(s,n,d)|0,Bt(s,n,f)|0,h=+Zt(d,f+8|0),h=+v(+(Zt(e,t)/(h*2))),a[o>>3]=h,n=~~h>>>0,s=+l(h)>=1?h>0?~~+b(+c(h/4294967296),4294967295)>>>0:~~+v((h-+(~~h>>>0))/4294967296)>>>0:0,(i[o+4>>2]&2146435072|0)==2146435072?(r=1,M=m,r|0):(p=(n|0)==0&(s|0)==0,i[r>>2]=p?1:n,i[r+4>>2]=p?0:s,r=0,M=m,r|0))}function He(e,t){e|=0,t=+t;var n=0,r=0,i=0,o=0,s=0,c=0,l=0,u=0,d=0;o=e+16|0,s=+a[o>>3],n=e+24|0,i=+a[n>>3],r=s-i,r=s>3],c=e+8|0,l=+a[c>>3],d=u-l,r=(r*t-r)*.5,t=(d*t-d)*.5,u+=t,a[e>>3]=u>1.5707963267948966?1.5707963267948966:u,t=l-t,a[c>>3]=t<-1.5707963267948966?-1.5707963267948966:t,t=s+r,t=t>3.141592653589793?t+-6.283185307179586:t,a[o>>3]=t<-3.141592653589793?t+6.283185307179586:t,t=i-r,t=t>3.141592653589793?t+-6.283185307179586:t,a[n>>3]=t<-3.141592653589793?t+6.283185307179586:t}function Ue(e,t,n,o){e|=0,t|=0,n|=0,o|=0;var s=0,c=0,l=0,u=0,d=0,f=0,p=0,m=0,h=0,g=0,_=0,v=0,y=0,b=0,x=0,S=0,C=0,w=0,D=0,O=0,k=0,A=0,j=0,N=0,ee=0,te=0;if(te=M,M=M+224|0,A=te,w=te+48|0,d=(n|0)>0|(n|0)==0&t>>>0>0,d&(n>>>0>0|(n|0)==0&t>>>0>17895697))return ee=14,M=te,ee|0;if((n|0)<0)return ee=2,M=te,ee|0;if((t|0)==0&(n|0)==0)return i[o>>2]=0,i[o+4>>2]=0,ee=0,M=te,ee|0;for(s=e,s=ft(i[s>>2]|0,i[s+4>>2]|0)|0,l=0,u=0;;){if(c=e+(l<<3)|0,ee=c,!(gt(i[ee>>2]|0,i[ee+4>>2]|0)|0)){s=5,j=159;break}if(ee=c,ee=(ft(i[ee>>2]|0,i[ee+4>>2]|0)|0)==(s|0),l=ur(l|0,u|0,1,0)|0,u=T()|0,!ee){s=12,j=159;break}if(!((u|0)<(n|0)|(u|0)==(n|0)&l>>>0>>0)){j=8;break}}if((j|0)==8){do if((n|0)>0|(n|0)==0&t>>>0>1){if(s=t<<3,l=ir(s)|0,!l)return ee=13,M=te,ee|0;for(wr(l|0,e|0,s|0)|0,Yn(l,t,8,1),s=1,c=0;N=l+(s<<3)|0,ee=l+(s+-1<<3)|0,ee=(i[N>>2]|0)==(i[ee>>2]|0)?(i[N+4>>2]|0)==(i[ee+4>>2]|0):0,s=ur(s|0,c|0,1,0)|0,c=T()|0,!ee;)if(!((c|0)<(n|0)|(c|0)==(n|0)&s>>>0>>0)){j=14;break}if((j|0)==14){ar(l);break}return ar(l),ee=10,M=te,ee|0}while(0);if(s=gr(t|0,n|0,6,0)|0,c=T()|0,d){l=0,u=0;do ee=e+(u<<3)|0,ee=((xt(i[ee>>2]|0,i[ee+4>>2]|0)|0)!=0)<<31>>31,s=ur(s|0,c|0,ee|0,((ee|0)<0)<<31>>31|0)|0,c=T()|0,u=ur(u|0,l|0,1,0)|0,l=T()|0;while((l|0)<(n|0)|(l|0)==(n|0)&u>>>0>>0);C=s,S=c}else C=s,S=c;if(b=gr(C|0,S|0,10,0)|0,x=T()|0,N=ir(C<<5)|0,!N)return ee=13,M=te,ee|0;if(ee=or(b,4)|0,!ee)return ar(N),ee=13,M=te,ee|0;a:do if(d){for(k=e,et(i[k>>2]|0,i[k+4>>2]|0,A)|0,g=N,_=0,v=0,s=0,y=0;;){d=A,d=(i[d>>2]|0)==0&(i[d+4>>2]|0)==0,c=d?26990:26995,l=d?5:6,u=0,d=A+((d&1)<<3)|0,f=ur(l|0,u|0,-1,-1)|0,p=T()|0,m=0,h=0;do O=d+(m<<3)|0,D=i[O+4>>2]|0,k=g+(m<<5)|0,i[k>>2]=i[O>>2],i[k+4>>2]=D,r[g+(m<<5)+9>>0]=0,r[g+(m<<5)+8>>0]=0,i[g+(m<<5)+20>>2]=g,k=g+(m<<5)+24|0,i[k>>2]=1,i[k+4>>2]=0,k=r[c+m>>0]|0,D=ur(f|0,p|0,m|0,h|0)|0,D=vr(D|0,T()|0,l|0,u|0)|0,T()|0,D=r[c+D>>0]|0,m=ur(m|0,h|0,1,0)|0,h=T()|0,O=r[c+((m|0)==(l|0)&(h|0)==(u|0)?0:m)>>0]|0,k&=255,i[g+(k<<5)+16>>2]=g+((D&255)<<5),i[g+(k<<5)+12>>2]=g+((O&255)<<5);while(h>>>0>>0|(h|0)==(u|0)&m>>>0>>0);if(_=ur(_|0,v|0,1,0)|0,v=T()|0,s=ur(l|0,u|0,s|0,y|0)|0,y=T()|0,!((v|0)<(n|0)|(v|0)==(n|0)&_>>>0>>0))break a;k=e+(_<<3)|0,et(i[k>>2]|0,i[k+4>>2]|0,A)|0||(g=N+(s<<5)|0)}E(27634,26956,108,26975)}while(0);if((S|0)>0|(S|0)==0&C>>>0>0){u=0,d=0;do{if(c=N+(u<<5)|0,l=i[c>>2]|0,c=i[c+4>>2]|0,s=z(l|0,c|0,30)|0,c=gr(s^l|0,(T()|0)^c|0,484763065,-1084733587)|0,l=T()|0,s=z(c|0,l|0,27)|0,l=gr(s^c|0,(T()|0)^l|0,321982955,-1798288965)|0,c=T()|0,s=z(l|0,c|0,31)|0,c=vr(s^l|0,(T()|0)^c|0,b|0,x|0)|0,l=T()|0,s=ee+(c<<2)|0,i[s>>2]|0)do s=ur(c|0,l|0,1,0)|0,c=_r(s|0,T()|0,b|0,x|0)|0,l=T()|0,s=ee+(c<<2)|0;while(i[s>>2]|0);i[s>>2]=N+(u<<5),u=ur(u|0,d|0,1,0)|0,d=T()|0}while((d|0)<(S|0)|(d|0)==(S|0)&u>>>0>>0);m=0,h=0;do{if(u=N+(m<<5)|0,d=N+(m<<5)+9|0,!(r[d>>0]|0)){if(k=u,nt(i[k>>2]|0,i[k+4>>2]|0,A)|0){j=39;break}p=A,f=i[p>>2]|0,p=i[p+4>>2]|0,c=z(f|0,p|0,30)|0,c=gr(c^f|0,(T()|0)^p|0,484763065,-1084733587)|0,l=T()|0,s=z(c|0,l|0,27)|0,l=gr(s^c|0,(T()|0)^l|0,321982955,-1798288965)|0,c=T()|0,s=z(l|0,c|0,31)|0,c=vr(s^l|0,(T()|0)^c|0,b|0,x|0)|0,l=T()|0,s=i[ee+(c<<2)>>2]|0;b:do if(s|0){for(;k=s,!((i[k>>2]|0)==(f|0)&&(i[k+4>>2]|0)==(p|0));)if(s=ur(c|0,l|0,1,0)|0,c=_r(s|0,T()|0,b|0,x|0)|0,l=T()|0,s=i[ee+(c<<2)>>2]|0,!s)break b;r[d>>0]=1,r[s+9>>0]=1,c=s+16|0,k=N+(m<<5)+12|0,i[(i[k>>2]|0)+16>>2]=i[c>>2],n=s+12|0,O=i[N+(m<<5)+16>>2]|0,i[O+12>>2]=i[n>>2],i[(i[n>>2]|0)+16>>2]=O,i[(i[c>>2]|0)+12>>2]=i[k>>2],c=Ge(u)|0,k=Ge(s)|0,s=c+24|0,n=i[s+4>>2]|0,O=k+24|0,D=i[O+4>>2]|0,O=(n|0)<(D|0)|((n|0)==(D|0)?(i[s>>2]|0)>>>0<(i[O>>2]|0)>>>0:0),s=O?c:k,c=O?k:c,(c|0)!=(s|0)&&(D=s+24|0,k=c+24|0,O=k,D=ur(i[O>>2]|0,i[O+4>>2]|0,i[D>>2]|0,i[D+4>>2]|0)|0,O=T()|0,i[k>>2]=D,i[k+4>>2]=O,i[s+20>>2]=c)}while(0)}m=ur(m|0,h|0,1,0)|0,h=T()|0}while((h|0)<(S|0)|(h|0)==(S|0)&m>>>0>>0);(j|0)==39&&E(27634,26956,258,27001),s=0,c=0;do r[N+(s<<5)+8>>0]=0,s=ur(s|0,c|0,1,0)|0,c=T()|0;while((c|0)<(S|0)|(c|0)==(S|0)&s>>>0>>0);for(f=0,l=0,d=0,p=0;;){if(s=N+(f<<5)|0,!(r[N+(f<<5)+8>>0]|0)&&!(r[N+(f<<5)+9>>0]|0)){u=s,c=i[u>>2]|0,u=i[u+4>>2]|0;do r[s+8>>0]=1,s=i[s+12>>2]|0,k=s;while(!((i[k>>2]|0)==(c|0)&&(i[k+4>>2]|0)==(u|0)));l=ur(l|0,d|0,1,0)|0,u=T()|0}else u=d;if(f=ur(f|0,p|0,1,0)|0,p=T()|0,(p|0)<(S|0)|(p|0)==(S|0)&f>>>0>>0)d=u;else break}s=0,c=0;do r[N+(s<<5)+8>>0]=0,s=ur(s|0,c|0,1,0)|0,c=T()|0;while((c|0)<(S|0)|(c|0)==(S|0)&s>>>0>>0);O=l,D=u,s=1}else O=0,D=0,s=0;k=ir(O*24|0)|0;c:do if(k|0){d:do if(s){e=0,b=0,n=0,t=0;e:for(;;){if(s=N+(e<<5)|0,!(r[N+(e<<5)+8>>0]|0)&&!(r[N+(e<<5)+9>>0]|0)){y=s,v=i[y>>2]|0,y=i[y+4>>2]|0,c=0,l=0;do c=ur(c|0,l|0,2,0)|0,l=T()|0,s=i[s+12>>2]|0,x=s;while(!((i[x>>2]|0)==(v|0)&&(i[x+4>>2]|0)==(y|0)));if(_=ir(c<<4)|0,!_)break;c=v,l=y,g=0,h=0,u=0,d=0;do{if(tt(c,l,w)|0){j=69;break e}if(x=i[w>>2]|0,p=x+-1|0,m=((p|0)<0)<<31>>31,(x|0)>1){l=u,f=0,c=d,u=0;do x=_+(l<<4)|0,d=w+8+(f<<4)|0,i[x>>2]=i[d>>2],i[x+4>>2]=i[d+4>>2],i[x+8>>2]=i[d+8>>2],i[x+12>>2]=i[d+12>>2],l=ur(l|0,c|0,1,0)|0,c=T()|0,f=ur(f|0,u|0,1,0)|0,u=T()|0;while((u|0)<(m|0)|(u|0)==(m|0)&f>>>0

>>0);u=l,d=c}g=ur(g|0,h|0,p|0,m|0)|0,h=T()|0,r[s+8>>0]=1,s=i[s+12>>2]|0,l=s,c=i[l>>2]|0,l=i[l+4>>2]|0}while(!((c|0)==(v|0)&(l|0)==(y|0)));if(c=sr(_,g<<4)|0,!c){j=75;break}y=Ge(s)|0,x=i[y+4>>2]|0,s=k+(n*24|0)|0,i[s>>2]=i[y>>2],i[s+4>>2]=x,s=k+(n*24|0)+16|0,i[s>>2]=g,i[k+(n*24|0)+20>>2]=c,i[A>>2]=i[s>>2],i[A+4>>2]=i[s+4>>2],ve(A,k+(n*24|0)+8|0)|0,c=ur(n|0,b|0,1,0)|0,s=T()|0}else c=n,s=b;if(e=ur(e|0,t|0,1,0)|0,t=T()|0,(t|0)<(S|0)|(t|0)==(S|0)&e>>>0>>0)b=s,n=c;else break d}if((j|0)==69?E(27634,26956,351,27016):(j|0)==75&&ar(_),(b|0)>0|(b|0)==0&n>>>0>0)for(u=0,d=0,s=n,l=b;c=i[k+(u*24|0)+20>>2]|0,c?(ar(c),c=b,s=n):c=l,u=ur(u|0,d|0,1,0)|0,d=T()|0,(d|0)<(c|0)|(d|0)==(c|0)&u>>>0>>0;)l=c;ar(k);break c}while(0);Yn(k,O,24,2);f:do if((O|0)==0&(D|0)==0){if(x=ir(192)|0,x|0){if(i[x+16>>2]=0,i[x+20>>2]=0,h=x+8|0,i[h>>2]=3,s=ir(48)|0,g=x+12|0,i[g>>2]=s,s|0){i[s>>2]=i[3860],i[s+4>>2]=i[3861],i[s+8>>2]=i[3862],i[s+12>>2]=i[3863],m=s+16|0,i[m>>2]=i[3864],i[m+4>>2]=i[3865],i[m+8>>2]=i[3866],i[m+12>>2]=i[3867],m=s+32|0,i[m>>2]=i[3868],i[m+4>>2]=i[3869],i[m+8>>2]=i[3870],i[m+12>>2]=i[3871],i[A>>2]=i[h>>2],i[A+4>>2]=i[h+4>>2],ve(A,x)|0,i[x+40>>2]=0,i[x+44>>2]=0,m=x+32|0,i[m>>2]=3,s=ir(48)|0,_=x+36|0,i[_>>2]=s;do if(!s)u=0,d=1;else{if(i[s>>2]=i[3872],i[s+4>>2]=i[3873],i[s+8>>2]=i[3874],i[s+12>>2]=i[3875],p=s+16|0,i[p>>2]=i[3876],i[p+4>>2]=i[3877],i[p+8>>2]=i[3878],i[p+12>>2]=i[3879],p=s+32|0,i[p>>2]=i[3880],i[p+4>>2]=i[3881],i[p+8>>2]=i[3882],i[p+12>>2]=i[3883],i[A>>2]=i[m>>2],i[A+4>>2]=i[m+4>>2],ve(A,x+24|0)|0,i[x+64>>2]=0,i[x+68>>2]=0,p=x+56|0,i[p>>2]=3,s=ir(48)|0,v=x+60|0,i[v>>2]=s,!s){u=0,d=2;break}if(i[s>>2]=i[3884],i[s+4>>2]=i[3885],i[s+8>>2]=i[3886],i[s+12>>2]=i[3887],f=s+16|0,i[f>>2]=i[3888],i[f+4>>2]=i[3889],i[f+8>>2]=i[3890],i[f+12>>2]=i[3891],f=s+32|0,i[f>>2]=i[3892],i[f+4>>2]=i[3893],i[f+8>>2]=i[3894],i[f+12>>2]=i[3895],i[A>>2]=i[p>>2],i[A+4>>2]=i[p+4>>2],ve(A,x+48|0)|0,i[x+88>>2]=0,i[x+92>>2]=0,f=x+80|0,i[f>>2]=3,s=ir(48)|0,y=x+84|0,i[y>>2]=s,!s){u=0,d=3;break}if(i[s>>2]=i[3896],i[s+4>>2]=i[3897],i[s+8>>2]=i[3898],i[s+12>>2]=i[3899],d=s+16|0,i[d>>2]=i[3900],i[d+4>>2]=i[3901],i[d+8>>2]=i[3902],i[d+12>>2]=i[3903],d=s+32|0,i[d>>2]=i[3904],i[d+4>>2]=i[3905],i[d+8>>2]=i[3906],i[d+12>>2]=i[3907],i[A>>2]=i[f>>2],i[A+4>>2]=i[f+4>>2],ve(A,x+72|0)|0,i[x+112>>2]=0,i[x+116>>2]=0,d=x+104|0,i[d>>2]=3,s=ir(48)|0,e=x+108|0,i[e>>2]=s,!s){u=0,d=4;break}if(i[s>>2]=i[3908],i[s+4>>2]=i[3909],i[s+8>>2]=i[3910],i[s+12>>2]=i[3911],u=s+16|0,i[u>>2]=i[3912],i[u+4>>2]=i[3913],i[u+8>>2]=i[3914],i[u+12>>2]=i[3915],u=s+32|0,i[u>>2]=i[3916],i[u+4>>2]=i[3917],i[u+8>>2]=i[3918],i[u+12>>2]=i[3919],i[A>>2]=i[d>>2],i[A+4>>2]=i[d+4>>2],ve(A,x+96|0)|0,i[x+136>>2]=0,i[x+140>>2]=0,u=x+128|0,i[u>>2]=3,s=ir(48)|0,t=x+132|0,i[t>>2]=s,!s){u=0,d=5;break}if(i[s>>2]=i[3920],i[s+4>>2]=i[3921],i[s+8>>2]=i[3922],i[s+12>>2]=i[3923],l=s+16|0,i[l>>2]=i[3924],i[l+4>>2]=i[3925],i[l+8>>2]=i[3926],i[l+12>>2]=i[3927],l=s+32|0,i[l>>2]=i[3928],i[l+4>>2]=i[3929],i[l+8>>2]=i[3930],i[l+12>>2]=i[3931],i[A>>2]=i[u>>2],i[A+4>>2]=i[u+4>>2],ve(A,x+120|0)|0,i[x+160>>2]=0,i[x+164>>2]=0,l=x+152|0,i[l>>2]=3,s=ir(48)|0,n=x+156|0,i[n>>2]=s,!s){u=0,d=6;break}if(i[s>>2]=i[3932],i[s+4>>2]=i[3933],i[s+8>>2]=i[3934],i[s+12>>2]=i[3935],c=s+16|0,i[c>>2]=i[3936],i[c+4>>2]=i[3937],i[c+8>>2]=i[3938],i[c+12>>2]=i[3939],c=s+32|0,i[c>>2]=i[3940],i[c+4>>2]=i[3941],i[c+8>>2]=i[3942],i[c+12>>2]=i[3943],i[A>>2]=i[l>>2],i[A+4>>2]=i[l+4>>2],ve(A,x+144|0)|0,i[x+184>>2]=0,i[x+188>>2]=0,c=x+176|0,i[c>>2]=3,s=ir(48)|0,b=x+180|0,i[b>>2]=s,!s){u=0,d=7;break}if(i[s>>2]=i[3944],i[s+4>>2]=i[3945],i[s+8>>2]=i[3946],i[s+12>>2]=i[3947],w=s+16|0,i[w>>2]=i[3948],i[w+4>>2]=i[3949],i[w+8>>2]=i[3950],i[w+12>>2]=i[3951],s=s+32|0,i[s>>2]=i[3952],i[s+4>>2]=i[3953],i[s+8>>2]=i[3954],i[s+12>>2]=i[3955],i[A>>2]=i[c>>2],i[A+4>>2]=i[c+4>>2],ve(A,x+168|0)|0,Yn(x,8,24,3),s=ir(128)|0,i[o+4>>2]=s,s|0){i[o>>2]=8,i[s>>2]=i[h>>2],i[s+4>>2]=i[h+4>>2],i[s+8>>2]=i[h+8>>2],i[s+12>>2]=i[h+12>>2],j=s+16|0,i[j>>2]=i[m>>2],i[j+4>>2]=i[m+4>>2],i[j+8>>2]=i[m+8>>2],i[j+12>>2]=i[m+12>>2],j=s+32|0,i[j>>2]=i[p>>2],i[j+4>>2]=i[p+4>>2],i[j+8>>2]=i[p+8>>2],i[j+12>>2]=i[p+12>>2],j=s+48|0,i[j>>2]=i[f>>2],i[j+4>>2]=i[f+4>>2],i[j+8>>2]=i[f+8>>2],i[j+12>>2]=i[f+12>>2],j=s+64|0,i[j>>2]=i[d>>2],i[j+4>>2]=i[d+4>>2],i[j+8>>2]=i[d+8>>2],i[j+12>>2]=i[d+12>>2],j=s+80|0,i[j>>2]=i[u>>2],i[j+4>>2]=i[u+4>>2],i[j+8>>2]=i[u+8>>2],i[j+12>>2]=i[u+12>>2],j=s+96|0,i[j>>2]=i[l>>2],i[j+4>>2]=i[l+4>>2],i[j+8>>2]=i[l+8>>2],i[j+12>>2]=i[l+12>>2],j=s+112|0,i[j>>2]=i[c>>2],i[j+4>>2]=i[c+4>>2],i[j+8>>2]=i[c+8>>2],i[j+12>>2]=i[c+12>>2],ar(x),j=158;break f}s=i[g>>2]|0,s|0&&ar(s),s=i[_>>2]|0,s|0&&ar(s),s=i[v>>2]|0,s|0&&ar(s),s=i[y>>2]|0,s|0&&ar(s),s=i[e>>2]|0,s|0&&ar(s),s=i[t>>2]|0,s|0&&ar(s),s=i[n>>2]|0,s|0&&ar(s),s=i[b>>2]|0,s|0&&ar(s),ar(x);break f}while(0);s=0,l=0;do c=i[x+(s*24|0)+12>>2]|0,c|0&&ar(c),s=ur(s|0,l|0,1,0)|0,l=T()|0;while(l>>>0>>0|(l|0)==(u|0)&s>>>0>>0)}ar(x),j=152}}else{if((D|0)>0|(D|0)==0&O>>>0>0){l=0,u=0,d=0,c=0,s=0,f=0;do w=k+(l*24|0)|0,A=u,u=i[w>>2]|0,j=d,d=i[w+4>>2]|0,c=ur(c|0,s|0,((u|0)!=(A|0)|(d|0)!=(j|0))&1|0,0)|0,s=T()|0,l=ur(l|0,f|0,1,0)|0,f=T()|0;while((f|0)<(D|0)|(f|0)==(D|0)&l>>>0>>0);y=c,v=s}else y=0,v=0;if(e=ir(y*24|0)|0,e){g:do if((D|0)>=0){for(h=0,g=0,c=0,l=0,_=0,u=0;;){if(!((h|0)==(O|0)&(g|0)==(D|0))&&(A=k+(c*24|0)|0,j=k+(h*24|0)|0,(i[A>>2]|0)==(i[j>>2]|0)&&(i[A+4>>2]|0)==(i[j+4>>2]|0)))s=_;else{if(p=k+(c*24|0)|0,j=dr(h|0,g|0,c|0,l|0)|0,A=T()|0,m=ur(j|0,A|0,-1,-1)|0,l=T()|0,(A|0)>0|(A|0)==0&j>>>0>1){if(s=ir(m<<3)|0,!s)break;d=0,f=0;do j=d,d=ur(d|0,f|0,1,0)|0,f=T()|0,w=p+(d*24|0)+16|0,A=i[w+4>>2]|0,j=s+(j<<3)|0,i[j>>2]=i[w>>2],i[j+4>>2]=A;while((f|0)<(l|0)|(f|0)==(l|0)&d>>>0>>0)}else s=0;A=k+(c*24|0)+16|0,j=i[A+4>>2]|0,l=e+(u*24|0)+8|0,i[l>>2]=i[A>>2],i[l+4>>2]=j,i[e+(u*24|0)+16>>2]=m,i[e+(u*24|0)+20>>2]=s,a[e+(u*24|0)>>3]=+a[k+(c*24|0)+8>>3],u=ur(u|0,_|0,1,0)|0,c=h,l=g,s=T()|0}if(j=h,h=ur(h|0,g|0,1,0)|0,A=g,g=T()|0,(A|0)<(D|0)|(A|0)==(D|0)&j>>>0>>0)_=s;else break g}if((_|0)>0|(_|0)==0&u>>>0>0){s=0,l=0;do c=i[e+(s*24|0)+20>>2]|0,c|0&&ar(c),s=ur(s|0,l|0,1,0)|0,l=T()|0;while((l|0)<(_|0)|(l|0)==(_|0)&s>>>0>>0)}ar(e),j=152;break f}while(0);if(Yn(e,y,24,3),s=ir(y<<4)|0,l=o+4|0,i[l>>2]=s,s){i[o>>2]=y;do if((v|0)>0|(v|0)==0&y>>>0>0){if(o=e+8|0,i[s>>2]=i[o>>2],i[s+4>>2]=i[o+4>>2],i[s+8>>2]=i[o+8>>2],i[s+12>>2]=i[o+12>>2],(y|0)==1&(v|0)==0||(o=s+16|0,j=e+32|0,i[o>>2]=i[j>>2],i[o+4>>2]=i[j+4>>2],i[o+8>>2]=i[j+8>>2],i[o+12>>2]=i[j+12>>2],!((v|0)>0|(v|0)==0&y>>>0>2)))break;s=2,c=0;do o=(i[l>>2]|0)+(s<<4)|0,j=e+(s*24|0)+8|0,i[o>>2]=i[j>>2],i[o+4>>2]=i[j+4>>2],i[o+8>>2]=i[j+8>>2],i[o+12>>2]=i[j+12>>2],s=ur(s|0,c|0,1,0)|0,c=T()|0;while((c|0)<(v|0)|(c|0)==(v|0)&s>>>0>>0)}while(0);ar(e),j=158;break}else{if((v|0)>0|(v|0)==0&y>>>0>0){s=0,l=0;do c=i[e+(s*24|0)+20>>2]|0,c|0&&ar(c),s=ur(s|0,l|0,1,0)|0,l=T()|0;while((l|0)<(v|0)|(l|0)==(v|0)&s>>>0>>0)}ar(e),j=152;break}}else j=152}while(0);if((j|0)==158)return ar(N),ar(ee),ar(k),ee=0,M=te,ee|0;if((j|0)==152&&(D|0)>0|(D|0)==0&O>>>0>0)for(u=0,d=0,s=O,l=D;c=i[k+(u*24|0)+20>>2]|0,c?(ar(c),c=D,s=O):c=l,u=ur(u|0,d|0,1,0)|0,d=T()|0,(d|0)<(c|0)|(d|0)==(c|0)&u>>>0>>0;)l=c;return ar(k),ar(N),ar(ee),ee=13,M=te,ee|0}while(0);return ar(N),ar(ee),ee=13,M=te,ee|0}else if((j|0)==159)return M=te,s|0;return 0}function We(e,t){e|=0,t|=0;var n=0,r=0;return r=e,e=i[r>>2]|0,r=i[r+4>>2]|0,n=t,t=i[n>>2]|0,n=i[n+4>>2]|0,(r>>>0>>0|(r|0)==(n|0)&e>>>0>>0?-1:(r>>>0>n>>>0|(r|0)==(n|0)&e>>>0>t>>>0)&1)|0}function Ge(e){e|=0;var t=0,n=0;return t=e+20|0,n=i[t>>2]|0,(n|0)==(e|0)?e|0:(n=Ge(n)|0,i[t>>2]=n,n|0)}function Ke(e,t){e|=0,t|=0;var n=0,r=0,o=0,s=0,c=0,l=0;return l=e,c=i[l>>2]|0,l=i[l+4>>2]|0,s=t,o=i[s>>2]|0,s=i[s+4>>2]|0,l>>>0>>0|(l|0)==(s|0)&c>>>0>>0?(t=-1,t|0):l>>>0>s>>>0|(l|0)==(s|0)&c>>>0>o>>>0?(t=1,t|0):(r=+a[e+8>>3],n=+a[t+8>>3],rn&1,t|0))}function qe(e,t){e|=0,t|=0;var n=0,r=0;return r=+a[e>>3],n=+a[t>>3],(r>n?-1:r>2]=0,a=0,M=f,a|0;if(s=z(e|0,t|0,52)|0,T()|0,s&=15,u=z(n|0,r|0,52)|0,T()|0,(s|0)!=(u&15|0))return a=12,M=f,a|0;if(o=s+-1|0,s>>>0>1){yt(e,t,o,d)|0,yt(n,r,o,c)|0,u=d,l=i[u>>2]|0,u=i[u+4>>2]|0;a:do if((l|0)==(i[c>>2]|0)&&(u|0)==(i[c+4>>2]|0)){s=(s^15)*3|0,o=z(e|0,t|0,s|0)|0,T()|0,o&=7,s=z(n|0,r|0,s|0)|0,T()|0,s&=7;do if((o|0)==0|(s|0)==0)i[a>>2]=1,o=0;else if((o|0)==7)o=5;else{if((o|0)==1|(s|0)==1&&xt(l,u)|0){o=5;break}if((i[15824+(o<<2)>>2]|0)!=(s|0)&&(i[15856+(o<<2)>>2]|0)!=(s|0))break a;i[a>>2]=1,o=0}while(0);return a=o,M=f,a|0}while(0)}o=d,s=o+56|0;do i[o>>2]=0,o=o+4|0;while((o|0)<(s|0));return ae(e,t,1,d)|0,t=d,!((i[t>>2]|0)==(n|0)&&(i[t+4>>2]|0)==(r|0))&&(t=d+8|0,!((i[t>>2]|0)==(n|0)&&(i[t+4>>2]|0)==(r|0)))&&(t=d+16|0,!((i[t>>2]|0)==(n|0)&&(i[t+4>>2]|0)==(r|0)))&&(t=d+24|0,!((i[t>>2]|0)==(n|0)&&(i[t+4>>2]|0)==(r|0)))&&(t=d+32|0,!((i[t>>2]|0)==(n|0)&&(i[t+4>>2]|0)==(r|0)))&&(t=d+40|0,!((i[t>>2]|0)==(n|0)&&(i[t+4>>2]|0)==(r|0)))?(o=d+48|0,o=((i[o>>2]|0)==(n|0)?(i[o+4>>2]|0)==(r|0):0)&1):o=1,i[a>>2]=o,a=0,M=f,a|0}function Ye(e,t,n,r,a){return e|=0,t|=0,n|=0,r|=0,a|=0,n=pe(e,t,n,r)|0,(n|0)==7?(a=11,a|0):(r=B(n|0,0,56)|0,t=t&-2130706433|(T()|0)|268435456,i[a>>2]=e|r,i[a+4>>2]=t,a=0,a|0)}function Xe(e,t,n){return e|=0,t|=0,n|=0,!0&(t&2013265920|0)==268435456?(i[n>>2]=e,i[n+4>>2]=t&-2130706433|134217728,n=0,n|0):(n=6,n|0)}function Ze(e,t,n){e|=0,t|=0,n|=0;var r=0,a=0,o=0;return a=M,M=M+16|0,r=a,i[r>>2]=0,!0&(t&2013265920|0)==268435456?(o=z(e|0,t|0,56)|0,T()|0,r=le(e,t&-2130706433|134217728,o&7,r,n)|0,M=a,r|0):(r=6,M=a,r|0)}function Qe(e,t){e|=0,t|=0;var n=0;switch(n=z(e|0,t|0,56)|0,T()|0,n&7){case 0:case 7:return n=0,n|0;default:}return n=t&-2130706433|134217728,!(!0&(t&2013265920|0)==268435456)||!0&(t&117440512|0)==16777216&(xt(e,n)|0)!=0?(n=0,n|0):(n=gt(e,n)|0,n|0)}function $e(e,t,n){e|=0,t|=0,n|=0;var r=0,a=0,o=0,s=0;return a=M,M=M+16|0,r=a,!0&(t&2013265920|0)==268435456?(o=t&-2130706433|134217728,s=n,i[s>>2]=e,i[s+4>>2]=o,i[r>>2]=0,t=z(e|0,t|0,56)|0,T()|0,r=le(e,o,t&7,r,n+8|0)|0,M=a,r|0):(r=6,M=a,r|0)}function et(e,t,n){e|=0,t|=0,n|=0;var r=0,a=0;return a=(xt(e,t)|0)==0,t&=-2130706433,r=n,i[r>>2]=a?e:0,i[r+4>>2]=a?t|285212672:0,r=n+8|0,i[r>>2]=e,i[r+4>>2]=t|301989888,r=n+16|0,i[r>>2]=e,i[r+4>>2]=t|318767104,r=n+24|0,i[r>>2]=e,i[r+4>>2]=t|335544320,r=n+32|0,i[r>>2]=e,i[r+4>>2]=t|352321536,n=n+40|0,i[n>>2]=e,i[n+4>>2]=t|369098752,0}function tt(e,t,n){e|=0,t|=0,n|=0;var r=0,a=0,o=0,s=0;return s=M,M=M+16|0,a=s,o=t&-2130706433|134217728,!0&(t&2013265920|0)==268435456?(r=z(e|0,t|0,56)|0,T()|0,r=Hn(e,o,r&7)|0,(r|0)==-1?(i[n>>2]=0,o=6,M=s,o|0):(Rt(e,o,a)|0&&E(27634,27035,282,27050),t=z(e|0,t|0,52)|0,T()|0,t&=15,xt(e,o)|0?ot(a,t,r,2,n):ut(a,t,r,2,n),o=0,M=s,o|0)):(o=6,M=s,o|0)}function nt(e,t,n){e|=0,t|=0,n|=0;var r=0,a=0,o=0,s=0;return s=M,M=M+16|0,r=s+8|0,a=s,o=t&-2130706433|134217728,!0&(t&2013265920|0)==268435456?(i[r>>2]=0,t=z(e|0,t|0,56)|0,T()|0,t=le(e,o,t&7,r,a)|0,t|0?(n=t,M=s,n|0):(r=i[a>>2]|0,a=i[a+4>>2]|0,t=pe(r,a,e,o)|0,(t|0)==7?(n=11,M=s,n|0):(e=B(t|0,0,56)|0,o=a&-2130706433|(T()|0)|268435456,i[n>>2]=r|e,i[n+4>>2]=o,n=0,M=s,n|0))):(n=6,M=s,n|0)}function rt(e,t,n){e|=0,t|=0,n|=0;var r=0,o=0,s=0,c=0,h=0,g=0,v=0,y=0,b=0,x=0,S=0,C=0,w=0,E=0,D=0,O=0,k=0,A=0,j=0;i[n>>2]=0,v=+a[e>>3],y=+a[e+8>>3],g=+a[e+16>>3],o=0,s=5,r=5,e=0;do w=+a[15888+(o*24|0)>>3]-v,C=+a[15888+(o*24|0)+8>>3]-y,c=+a[15888+(o*24|0)+16>>3]-g,c=w*w+C*C+c*c,c>2]=o,s=c,e=o,r=c),o=o+1|0;while((o|0)!=20);if(s=+m(+(1-s*.5)),s<1e-16)g=0,c=0;else{if(A=+a[16368+(e*24|0)>>3],O=+a[15888+(e*24|0)>>3],k=+a[15888+(e*24|0)+8>>3],D=+a[15888+(e*24|0)+16>>3],j=-(D+(O*0+k*0)),c=O*j+0,w=k*j+0,j=D*j+1,E=+u(+(j*j+(c*c+w*w))),E=E>0?1/E:0,c*=E,w*=E,E=j*E,j=-(v*O+y*k+g*D),C=v+O*j,r=y+k*j,v=g+D*j,y=+u(+(v*v+(C*C+r*r))),y=y>0?1/y:0,C*=y,r*=y,y=v*y,r=+Jt(A-+Jt(+_(+(y*(k*c-O*w)+(C*(D*w-k*E)+r*(O*E-D*c))),+(E*y+(c*C+w*r))))),c=Ft(t)|0?+Jt(r+-.3334731722518321):r,r=p(+s)*2.618033988749896,(t|0)>0){e=0;do r*=2.6457513110645907,e=e+1|0;while((e|0)!=(t|0))}g=+d(+c)*r,c=+f(+c)*r}t=n+4|0,S=n+12|0,i[S>>2]=0,s=l(+c)*1.1547005383792515,r=+l(+g)+s*.5,e=~~r,o=~~s,r-=+(e|0),s-=+(o|0);do if(r<.5)if(r<.3333333333333333)if(i[t>>2]=e,s<(r+1)*.5){i[n+8>>2]=o;break}else{o=o+1|0,i[n+8>>2]=o;break}else if(j=1-r,o=(!(s>2]=o,j<=s&s>2]=e;break}else{i[t>>2]=e;break}else{if(!(r<.6666666666666666))if(e=e+1|0,i[t>>2]=e,s>2]=o;break}else{o=o+1|0,i[n+8>>2]=o;break}if(s<1-r){if(i[n+8>>2]=o,r*2+-1>2]=e;break}}else o=o+1|0,i[n+8>>2]=o;e=e+1|0,i[t>>2]=e}while(0);do if(g<0)if(o&1){x=(o+1|0)/2|0,x=dr(e|0,((e|0)<0)<<31>>31|0,x|0,((x|0)<0)<<31>>31|0)|0,e=~~((e|0)-((+(x>>>0)+4294967296*(T()|0))*2+1)),i[t>>2]=e,x=t;break}else{x=(o|0)/2|0,x=dr(e|0,((e|0)<0)<<31>>31|0,x|0,((x|0)<0)<<31>>31|0)|0,e=~~((e|0)-(+(x>>>0)+4294967296*(T()|0))*2),i[t>>2]=e,x=t;break}else x=t;while(0);b=n+8|0,t=0-o|0,c<0?(n=e-((o<<1|1)/2|0)|0,i[x>>2]=n,i[b>>2]=t,o=t):n=e,e=o-n|0,t=0-n|0,(n|0)<0?(i[b>>2]=e,i[S>>2]=t,i[x>>2]=0,h=0):(e=o,h=n,t=0),n=h-e|0,o=t-e|0,(e|0)<0?(i[x>>2]=n,i[S>>2]=o,i[b>>2]=0,h=n,e=0):o=t,n=h-o|0,t=e-o|0,(o|0)<0?(i[x>>2]=n,i[b>>2]=t,i[S>>2]=0,o=0):(t=e,n=h),e=(t|0)<(n|0)?t:n,e=(o|0)<(e|0)?o:e,!((e|0)<=0)&&(i[x>>2]=n-e,i[b>>2]=t-e,i[S>>2]=o-e)}function it(e,t,n){e|=0,t|=0,n|=0;var r=0,o=0,s=0,c=0;r=M,M=M+16|0,o=r,c=i[e+12>>2]|0,s=+((i[e+8>>2]|0)-c|0),a[o>>3]=((i[e+4>>2]|0)-c|0)-s*.5,a[o+8>>3]=s*.8660254037844386,at(o,i[e>>2]|0,t,0,n),M=r}function at(e,t,n,r,o){e|=0,t|=0,n|=0,r|=0,o|=0;var s=0,c=0,l=0,p=0,m=0,h=0,v=0,y=0,b=0,x=0,S=0,C=0;if(s=+zn(e),s<1e-16){t=15888+(t*24|0)|0,i[o>>2]=i[t>>2],i[o+4>>2]=i[t+4>>2],i[o+8>>2]=i[t+8>>2],i[o+12>>2]=i[t+12>>2],i[o+16>>2]=i[t+16>>2],i[o+20>>2]=i[t+20>>2];return}if(c=+_(+ +a[e+8>>3],+ +a[e>>3]),(n|0)>0){e=0;do s*=.37796447300922725,e=e+1|0;while((e|0)!=(n|0))}l=s*.3333333333333333,r?(n=(Ft(n)|0)==0,s=+g(+((n?l:l*.37796447300922725)*.381966011250105))):(s=+g(+(s*.381966011250105)),Ft(n)|0&&(c=+Jt(c+.3334731722518321))),v=+Jt(+a[16368+(t*24|0)>>3]-c),l=+a[15888+(t*24|0)>>3],h=+a[15888+(t*24|0)+8>>3],S=+a[15888+(t*24|0)+16>>3],b=-(S+(l*0+h*0)),m=l*b+0,c=h*b+0,b=S*b+1,y=+u(+(b*b+(m*m+c*c))),y=y>0?1/y:0,m*=y,c*=y,y=b*y,b=+d(+v),v=+f(+v),C=+d(+s),x=+f(+s),p=C*l+x*(b*m+v*(S*c-h*y)),s=C*h+x*(b*c+v*(l*y-S*m)),c=C*S+x*(b*y+v*(h*m-l*c)),l=+u(+(c*c+(p*p+s*s))),l=l>0?1/l:0,a[o>>3]=p*l,a[o+8>>3]=s*l,a[o+16>>3]=c*l}function ot(e,t,n,r,o){e|=0,t|=0,n|=0,r|=0,o|=0;var s=0,c=0,l=0,u=0,d=0,f=0,p=0,m=0,g=0,v=0,b=0,x=0,S=0,C=0,w=0,T=0,D=0,O=0,k=0,A=0,j=0,N=0,ee=0,te=0,ne=0,re=0,ie=0,ae=0,oe=0,se=0,ce=0,le=0,ue=0,de=0,fe=0,pe=0,me=0,he=0,ge=0,_e=0,ve=0,ye=0;if(pe=M,M=M+256|0,s=pe+240|0,re=pe+224|0,ue=pe,de=pe+208|0,fe=pe+192|0,ie=pe+168|0,ae=pe+152|0,oe=pe+136|0,se=pe+120|0,ce=pe+104|0,le=pe+80|0,i[s>>2]=t,i[re>>2]=i[e>>2],i[re+4>>2]=i[e+4>>2],i[re+8>>2]=i[e+8>>2],i[re+12>>2]=i[e+12>>2],st(re,s,ue),i[o>>2]=0,re=r+n+((r|0)==5&1)|0,(re|0)<=(n|0)){M=pe;return}T=i[s>>2]|0,w=de+4|0,S=de+8|0,C=de+12|0,D=fe+8|0,O=n+5|0,k=16848+(T<<2)|0,A=ie+8|0,j=16928+(T<<2)|0,N=ae+8|0,ee=oe+8|0,te=se+8|0,ne=fe+8|0,g=ie+8|0,b=ie+16|0,v=le+8|0,x=le+16|0,m=n,r=0,c=0,l=0,u=0;a:for(;;){p=ue+(((m|0)%5|0)<<4)|0,i[de>>2]=i[p>>2],i[de+4>>2]=i[p+4>>2],i[de+8>>2]=i[p+8>>2],i[de+12>>2]=i[p+12>>2];do;while((ct(de,T,0,1)|0)==2);if((m|0)>(n|0)&(Ft(t)|0)!=0){if(p=i[de>>2]|0,e=i[w>>2]|0,d=i[S>>2]|0,s=i[C>>2]|0,me=+(l-u|0),a[fe>>3]=(c-u|0)-me*.5,a[D>>3]=me*.8660254037844386,u=i[17008+(p*80|0)+(r<<2)>>2]|0,f=i[18608+(p*80|0)+(u*20|0)>>2]|0,l=i[18608+(p*80|0)+(u*20|0)+16>>2]|0,(l|0)>0){c=0,r=d;do _e=s+e|0,ve=(_e|0)<0,d=r+e-(ve?_e:0)|0,ge=(d|0)<0,he=s+r-(ve?_e:0)-(ge?d:0)|0,s=(he|0)<0,e=(ve?0:_e)-(ge?d:0)-(s?he:0)|0,r=(ge?0:d)-(s?he:0)|0,he=s?0:he,s=(r|0)<(e|0)?r:e,s=(he|0)<(s|0)?he:s,d=(s|0)>0,e=e-(d?s:0)|0,r=r-(d?s:0)|0,s=he-(d?s:0)|0,c=c+1|0;while((c|0)<(l|0))}else r=d;switch(ve=(i[k>>2]|0)*3|0,he=(y(ve,i[18608+(p*80|0)+(u*20|0)+4>>2]|0)|0)+e|0,d=(y(ve,i[18608+(p*80|0)+(u*20|0)+8>>2]|0)|0)+r|0,ve=(y(ve,i[18608+(p*80|0)+(u*20|0)+12>>2]|0)|0)+s|0,u=(he|0)<0,d=d-(u?he:0)|0,ge=(d|0)<0,ve=ve+(u?0-he|0:0)+(ge?0-d|0:0)|0,_e=(ve|0)<0,he=(u?0:he)-(ge?d:0)-(_e?ve:0)|0,d=(ge?0:d)-(_e?ve:0)|0,ve=_e?0:ve,_e=(d|0)<(he|0)?d:he,_e=(ve|0)<(_e|0)?ve:_e,ge=(_e|0)>0,ve=ve-(ge?_e:0)|0,me=+(d-(ge?_e:0)-ve|0),a[ie>>3]=(he-(ge?_e:0)-ve|0)-me*.5,a[A>>3]=me*.8660254037844386,me=+(i[j>>2]|0),a[ae>>3]=me*3,a[N>>3]=0,ye=me*-1.5,a[oe>>3]=ye,a[ee>>3]=me*2.598076211353316,a[se>>3]=ye,a[te>>3]=me*-2.598076211353316,i[17008+(f*80|0)+(p<<2)>>2]|0){case 1:e=oe,r=ae;break;case 3:e=se,r=oe;break;case 2:e=ae,r=se;break;default:e=12;break a}Bn(fe,ie,r,e,ce),at(ce,f,T,1,le),ve=i[o>>2]|0,me=+h(+ +a[x>>3]),ye=+_(+ +a[v>>3],+ +a[le>>3]),a[o+8+(ve<<4)>>3]=me,a[o+8+(ve<<4)+8>>3]=ye,i[o>>2]=(i[o>>2]|0)+1}if((m|0)<(O|0)&&(ve=i[C>>2]|0,me=+((i[S>>2]|0)-ve|0),a[fe>>3]=((i[w>>2]|0)-ve|0)-me*.5,a[ne>>3]=me*.8660254037844386,at(fe,i[de>>2]|0,T,1,ie),ve=i[o>>2]|0,me=+h(+ +a[b>>3]),ye=+_(+ +a[g>>3],+ +a[ie>>3]),a[o+8+(ve<<4)>>3]=me,a[o+8+(ve<<4)+8>>3]=ye,i[o>>2]=(i[o>>2]|0)+1),m=m+1|0,(m|0)>=(re|0)){e=3;break}else r=i[de>>2]|0,c=i[w>>2]|0,l=i[S>>2]|0,u=i[C>>2]|0}if((e|0)==3){M=pe;return}else (e|0)==12&&E(27073,27120,599,27130)}function st(e,t,n){e|=0,t|=0,n|=0;var r=0,a=0,o=0,s=0,c=0,l=0,u=0,d=0,f=0,p=0,m=0,h=0;h=M,M=M+128|0,r=h+64|0,a=h,o=r,s=20208,c=o+60|0;do i[o>>2]=i[s>>2],o=o+4|0,s=s+4|0;while((o|0)<(c|0));o=a,s=20272,c=o+60|0;do i[o>>2]=i[s>>2],o=o+4|0,s=s+4|0;while((o|0)<(c|0));if(d=(Ft(i[t>>2]|0)|0)==0,d=d?r:a,m=e+4|0,o=i[m>>2]|0,f=e+8|0,r=i[f>>2]|0,p=e+12|0,a=i[p>>2]|0,s=r+(o<<1)|0,i[m>>2]=s,r=a+(r<<1)|0,i[f>>2]=r,o=(a<<1)+o|0,i[p>>2]=o,a=r-s|0,c=o-s|0,(s|0)<0&&(i[f>>2]=a,i[p>>2]=c,i[m>>2]=0,r=a,s=0,o=c),c=s-r|0,a=o-r|0,(r|0)<0?(i[m>>2]=c,i[p>>2]=a,i[f>>2]=0,r=0):(a=o,c=s),s=c-a|0,o=r-a|0,(a|0)<0?(i[m>>2]=s,i[f>>2]=o,i[p>>2]=0,a=0):(o=r,s=c),r=(o|0)<(s|0)?o:s,r=(a|0)<(r|0)?a:r,(r|0)>0&&(a=a-r|0,o=o-r|0,s=s-r|0,i[m>>2]=s,i[f>>2]=o,i[p>>2]=a),l=(o<<1)+s|0,c=a+(s<<1)|0,i[m>>2]=c,i[f>>2]=l,o=(a<<1)+o|0,i[p>>2]=o,r=l-c|0,a=o-c|0,(c|0)<0?(i[f>>2]=r,i[p>>2]=a,i[m>>2]=0,c=0,o=a):r=l,s=c-r|0,a=o-r|0,(r|0)<0?(i[m>>2]=s,i[p>>2]=a,i[f>>2]=0,c=s,r=0):a=o,s=c-a|0,o=r-a|0,(a|0)<0?(i[m>>2]=s,i[f>>2]=o,i[p>>2]=0,a=0):(o=r,s=c),r=(o|0)<(s|0)?o:s,r=(a|0)<(r|0)?a:r,(r|0)>0&&(i[m>>2]=s-r,i[f>>2]=o-r,i[p>>2]=a-r),Ft(i[t>>2]|0)|0&&(o=i[m>>2]|0,s=i[f>>2]|0,a=i[p>>2]|0,r=(s*3|0)+o|0,o=a+(o*3|0)|0,i[m>>2]=o,i[f>>2]=r,s=(a*3|0)+s|0,i[p>>2]=s,a=r-o|0,c=s-o|0,(o|0)<0?(i[f>>2]=a,i[p>>2]=c,i[m>>2]=0,r=a,l=0):(l=o,c=s),o=l-r|0,a=c-r|0,(r|0)<0?(i[m>>2]=o,i[p>>2]=a,i[f>>2]=0,l=o,s=0):(s=r,a=c),o=l-a|0,r=s-a|0,(a|0)<0?(i[m>>2]=o,i[f>>2]=r,i[p>>2]=0,s=r,a=0):o=l,r=(s|0)<(o|0)?s:o,r=(a|0)<(r|0)?a:r,(r|0)>0&&(i[m>>2]=o-r,i[f>>2]=s-r,i[p>>2]=a-r),i[t>>2]=(i[t>>2]|0)+1),i[n>>2]=i[e>>2],a=i[f>>2]|0,r=i[p>>2]|0,t=i[d+4>>2]|0,u=i[d+8>>2]|0,s=(i[d>>2]|0)+(i[m>>2]|0)|0,l=n+4|0,i[l>>2]=s,a=t+a|0,t=n+8|0,i[t>>2]=a,r=u+r|0,u=n+12|0,i[u>>2]=r,o=a-s|0,(s|0)<0&&(r=r-s|0,i[t>>2]=o,i[u>>2]=r,i[l>>2]=0,a=o,s=0),(a|0)<0&&(s=s-a|0,i[l>>2]=s,r=r-a|0,i[u>>2]=r,i[t>>2]=0,a=0),c=s-r|0,o=a-r|0,(r|0)<0?(i[l>>2]=c,i[t>>2]=o,i[u>>2]=0,s=c,r=0):o=a,a=(o|0)<(s|0)?o:s,a=(r|0)<(a|0)?r:a,(a|0)>0&&(i[l>>2]=s-a,i[t>>2]=o-a,i[u>>2]=r-a),i[n+16>>2]=i[e>>2],a=i[f>>2]|0,r=i[p>>2]|0,t=i[d+16>>2]|0,u=i[d+20>>2]|0,s=(i[d+12>>2]|0)+(i[m>>2]|0)|0,l=n+20|0,i[l>>2]=s,a=t+a|0,t=n+24|0,i[t>>2]=a,r=u+r|0,u=n+28|0,i[u>>2]=r,o=a-s|0,(s|0)<0&&(r=r-s|0,i[t>>2]=o,i[u>>2]=r,i[l>>2]=0,a=o,s=0),(a|0)<0&&(s=s-a|0,i[l>>2]=s,r=r-a|0,i[u>>2]=r,i[t>>2]=0,a=0),c=s-r|0,o=a-r|0,(r|0)<0?(i[l>>2]=c,i[t>>2]=o,i[u>>2]=0,s=c,r=0):o=a,a=(o|0)<(s|0)?o:s,a=(r|0)<(a|0)?r:a,(a|0)>0&&(i[l>>2]=s-a,i[t>>2]=o-a,i[u>>2]=r-a),i[n+32>>2]=i[e>>2],a=i[f>>2]|0,r=i[p>>2]|0,t=i[d+28>>2]|0,u=i[d+32>>2]|0,s=(i[d+24>>2]|0)+(i[m>>2]|0)|0,l=n+36|0,i[l>>2]=s,a=t+a|0,t=n+40|0,i[t>>2]=a,r=u+r|0,u=n+44|0,i[u>>2]=r,o=a-s|0,(s|0)<0&&(r=r-s|0,i[t>>2]=o,i[u>>2]=r,i[l>>2]=0,a=o,s=0),(a|0)<0&&(s=s-a|0,i[l>>2]=s,r=r-a|0,i[u>>2]=r,i[t>>2]=0,a=0),c=s-r|0,o=a-r|0,(r|0)<0?(i[l>>2]=c,i[t>>2]=o,i[u>>2]=0,s=c,r=0):o=a,a=(o|0)<(s|0)?o:s,a=(r|0)<(a|0)?r:a,(a|0)>0&&(i[l>>2]=s-a,i[t>>2]=o-a,i[u>>2]=r-a),i[n+48>>2]=i[e>>2],a=i[f>>2]|0,r=i[p>>2]|0,t=i[d+40>>2]|0,u=i[d+44>>2]|0,s=(i[d+36>>2]|0)+(i[m>>2]|0)|0,l=n+52|0,i[l>>2]=s,a=t+a|0,t=n+56|0,i[t>>2]=a,r=u+r|0,u=n+60|0,i[u>>2]=r,o=a-s|0,(s|0)<0&&(r=r-s|0,i[t>>2]=o,i[u>>2]=r,i[l>>2]=0,a=o,s=0),(a|0)<0&&(s=s-a|0,i[l>>2]=s,r=r-a|0,i[u>>2]=r,i[t>>2]=0,a=0),c=s-r|0,o=a-r|0,(r|0)<0?(i[l>>2]=c,i[t>>2]=o,i[u>>2]=0,s=c,r=0):o=a,a=(o|0)<(s|0)?o:s,a=(r|0)<(a|0)?r:a,(a|0)>0&&(i[l>>2]=s-a,i[t>>2]=o-a,i[u>>2]=r-a),i[n+64>>2]=i[e>>2],o=i[f>>2]|0,r=i[p>>2]|0,u=i[d+52>>2]|0,l=i[d+56>>2]|0,s=(i[d+48>>2]|0)+(i[m>>2]|0)|0,t=n+68|0,i[t>>2]=s,o=u+o|0,u=n+72|0,i[u>>2]=o,r=l+r|0,l=n+76|0,i[l>>2]=r,a=o-s|0,(s|0)<0?(r=r-s|0,i[u>>2]=a,i[l>>2]=r,i[t>>2]=0,o=0):(a=o,o=s),(a|0)<0&&(o=o-a|0,i[t>>2]=o,r=r-a|0,i[l>>2]=r,i[u>>2]=0,a=0),c=o-r|0,s=a-r|0,(r|0)<0?(i[t>>2]=c,i[u>>2]=s,i[l>>2]=0,o=c,r=0):s=a,a=(s|0)<(o|0)?s:o,a=(r|0)<(a|0)?r:a,(a|0)<=0){M=h;return}i[t>>2]=o-a,i[u>>2]=s-a,i[l>>2]=r-a,M=h}function ct(e,t,n,r){e|=0,t|=0,n|=0,r|=0;var a=0,o=0,s=0,c=0,l=0,u=0,d=0,f=0,p=0,m=0,h=0,g=0,_=0,v=0;if(p=i[16928+(t<<2)>>2]|0,f=(r|0)!=0,p=f?p*3|0:p,d=e+4|0,c=i[d>>2]|0,u=e+8|0,o=i[u>>2]|0,f){if(s=e+12|0,r=i[s>>2]|0,a=o+c+r|0,(a|0)==(p|0))return p=1,p|0;l=s}else l=e+12|0,a=i[l>>2]|0,r=a,a=o+c+a|0;if((a|0)<=(p|0))return p=0,p|0;do if((r|0)>0){if(a=i[e>>2]|0,(o|0)>0){a=18608+(a*80|0)+60|0,s=c;break}a=18608+(a*80|0)+40|0,n?(s=c-p|0,n=o+s|0,m=(n|0)<0,o=r+o-(m?n:0)|0,c=(o|0)<0,r=r+s-(m?n:0)-(c?o:0)|0,s=(r|0)<0,n=(m?0:n)-(c?o:0)-(s?r:0)|0,o=(c?0:o)-(s?r:0)|0,r=s?0:r,s=(o|0)<(n|0)?o:n,s=(r|0)<(s|0)?r:s,c=(s|0)>0,o=o-(c?s:0)|0,r=r-(c?s:0)|0,s=n-(c?s:0)+p|0,i[d>>2]=s,i[u>>2]=o,i[l>>2]=r):s=c}else a=18608+((i[e>>2]|0)*80|0)+20|0,s=c;while(0);if(i[e>>2]=i[a>>2],c=i[a+16>>2]|0,(c|0)>0){n=0;do m=r+s|0,h=(m|0)<0,v=h?m:0,g=o+s-v|0,_=(g|0)<0,e=_?g:0,s=r+o-v-e|0,o=(s|0)<0,r=o?0:s,s=o?s:0,o=(_?0:g)-s|0,s=(h?0:m)-e-s|0,e=(o|0)<(s|0)?o:s,e=(r|0)<(e|0)?r:e,(e|0)>0&&(s=s-e|0,o=o-e|0,r=r-e|0),n=n+1|0;while((n|0)<(c|0));i[d>>2]=s,i[u>>2]=o,i[l>>2]=r}return g=i[16848+(t<<2)>>2]|0,g=f?g*3|0:g,_=y(g,i[a+8>>2]|0)|0,v=y(g,i[a+12>>2]|0)|0,s=(y(g,i[a+4>>2]|0)|0)+s|0,i[d>>2]=s,o=_+o|0,i[u>>2]=o,r=v+r|0,i[l>>2]=r,a=o-s|0,(s|0)<0?(r=r-s|0,i[u>>2]=a,i[l>>2]=r,i[d>>2]=0,o=0):(a=o,o=s),(a|0)<0?(e=o-a|0,i[d>>2]=e,r=r-a|0,i[l>>2]=r,i[u>>2]=0,s=0):(e=o,s=a),o=e-r|0,a=s-r|0,(r|0)<0?(i[d>>2]=o,i[u>>2]=a,i[l>>2]=0,r=0):(a=s,o=e),s=(a|0)<(o|0)?a:o,s=(r|0)<(s|0)?r:s,(s|0)>0&&(o=o-s|0,a=a-s|0,r=r-s|0,i[d>>2]=o,i[u>>2]=a,i[l>>2]=r),f?(v=(a+o+r|0)==(p|0)?1:2,v|0):(v=2,v|0)}function lt(e,t){e|=0,t|=0;var n=0;do n=ct(e,t,0,1)|0;while((n|0)==2);return n|0}function ut(e,t,n,r,o){e|=0,t|=0,n|=0,r|=0,o|=0;var s=0,c=0,l=0,u=0,d=0,f=0,p=0,m=0,g=0,v=0,y=0,b=0,x=0,S=0,C=0,w=0,T=0,D=0,O=0,k=0,A=0,j=0,N=0,ee=0,te=0,ne=0,re=0,ie=0,ae=0,oe=0,se=0,ce=0,le=0,ue=0,de=0;if(ce=M,M=M+272|0,s=ce+256|0,c=ce+240|0,ae=ce,oe=ce+224|0,se=ce+208|0,j=ce+184|0,N=ce+168|0,ee=ce+152|0,te=ce+136|0,ne=ce+120|0,re=ce+96|0,i[s>>2]=t,i[c>>2]=i[e>>2],i[c+4>>2]=i[e+4>>2],i[c+8>>2]=i[e+8>>2],i[c+12>>2]=i[e+12>>2],dt(c,s,ae),i[o>>2]=0,A=r+n+((r|0)==6&1)|0,(A|0)<=(n|0)){M=ce;return}x=i[s>>2]|0,S=n+6|0,C=se+8|0,w=j+8|0,T=16928+(x<<2)|0,D=N+8|0,O=ee+8|0,k=te+8|0,y=i[c>>2]|0,m=oe+4|0,g=oe+8|0,v=oe+12|0,b=se+8|0,u=j+8|0,f=j+16|0,d=re+8|0,p=re+16|0,c=0,l=n,r=-1;a:for(;;){if(s=(l|0)%6|0,e=ae+(s<<4)|0,i[oe>>2]=i[e>>2],i[oe+4>>2]=i[e+4>>2],i[oe+8>>2]=i[e+8>>2],i[oe+12>>2]=i[e+12>>2],e=c,c=ct(oe,x,0,1)|0,(l|0)>(n|0)&(Ft(t)|0)!=0&&(ie=i[oe>>2]|0,(e|0)!=1&(ie|0)!=(r|0))){switch(de=(s+5|0)%6|0,e=i[ae+(de<<4)+12>>2]|0,le=+((i[ae+(de<<4)+8>>2]|0)-e|0),a[se>>3]=((i[ae+(de<<4)+4>>2]|0)-e|0)-le*.5,a[C>>3]=le*.8660254037844386,e=i[ae+(s<<4)+12>>2]|0,le=+((i[ae+(s<<4)+8>>2]|0)-e|0),a[j>>3]=((i[ae+(s<<4)+4>>2]|0)-e|0)-le*.5,a[w>>3]=le*.8660254037844386,le=+(i[T>>2]|0),a[N>>3]=le*3,a[D>>3]=0,ue=le*-1.5,a[ee>>3]=ue,a[O>>3]=le*2.598076211353316,a[te>>3]=ue,a[k>>3]=le*-2.598076211353316,i[17008+(y*80|0)+(((r|0)==(y|0)?ie:r)<<2)>>2]|0){case 1:e=ee,r=N;break;case 3:e=te,r=ee;break;case 2:e=N,r=te;break;default:e=8;break a}Bn(se,j,r,e,ne),!(Vn(se,ne)|0)&&!(Vn(j,ne)|0)&&(at(ne,y,x,1,re),de=i[o>>2]|0,le=+h(+ +a[p>>3]),ue=+_(+ +a[d>>3],+ +a[re>>3]),a[o+8+(de<<4)>>3]=le,a[o+8+(de<<4)+8>>3]=ue,i[o>>2]=(i[o>>2]|0)+1)}if((l|0)<(S|0)&&(de=i[v>>2]|0,le=+((i[g>>2]|0)-de|0),a[se>>3]=((i[m>>2]|0)-de|0)-le*.5,a[b>>3]=le*.8660254037844386,at(se,i[oe>>2]|0,x,1,j),de=i[o>>2]|0,le=+h(+ +a[f>>3]),ue=+_(+ +a[u>>3],+ +a[j>>3]),a[o+8+(de<<4)>>3]=le,a[o+8+(de<<4)+8>>3]=ue,i[o>>2]=(i[o>>2]|0)+1),l=l+1|0,(l|0)>=(A|0)){e=3;break}else r=i[oe>>2]|0}if((e|0)==3){M=ce;return}else (e|0)==8&&E(27157,27120,766,27202)}function dt(e,t,n){e|=0,t|=0,n|=0;var r=0,a=0,o=0,s=0,c=0,l=0,u=0,d=0,f=0,p=0,m=0,h=0,g=0;g=M,M=M+160|0,r=g+80|0,a=g,o=r,s=20336,c=o+72|0;do i[o>>2]=i[s>>2],o=o+4|0,s=s+4|0;while((o|0)<(c|0));o=a,s=20416,c=o+72|0;do i[o>>2]=i[s>>2],o=o+4|0,s=s+4|0;while((o|0)<(c|0));f=(Ft(i[t>>2]|0)|0)==0,f=f?r:a,h=e+4|0,o=i[h>>2]|0,p=e+8|0,r=i[p>>2]|0,m=e+12|0,a=i[m>>2]|0,s=r+(o<<1)|0,i[h>>2]=s,r=a+(r<<1)|0,i[p>>2]=r,o=(a<<1)+o|0,i[m>>2]=o,a=r-s|0,c=o-s|0,(s|0)<0&&(i[p>>2]=a,i[m>>2]=c,i[h>>2]=0,r=a,s=0,o=c),c=s-r|0,a=o-r|0,(r|0)<0?(i[h>>2]=c,i[m>>2]=a,i[p>>2]=0,r=0):(a=o,c=s),s=c-a|0,o=r-a|0,(a|0)<0?(i[h>>2]=s,i[p>>2]=o,i[m>>2]=0,a=0):(o=r,s=c),r=(o|0)<(s|0)?o:s,r=(a|0)<(r|0)?a:r,(r|0)>0&&(a=a-r|0,o=o-r|0,s=s-r|0,i[h>>2]=s,i[p>>2]=o,i[m>>2]=a),l=(o<<1)+s|0,c=a+(s<<1)|0,i[h>>2]=c,i[p>>2]=l,o=(a<<1)+o|0,i[m>>2]=o,r=l-c|0,a=o-c|0,(c|0)<0?(i[p>>2]=r,i[m>>2]=a,i[h>>2]=0,c=0,o=a):r=l,s=c-r|0,a=o-r|0,(r|0)<0?(i[h>>2]=s,i[m>>2]=a,i[p>>2]=0,c=s,r=0):a=o,s=c-a|0,o=r-a|0,(a|0)<0?(i[h>>2]=s,i[p>>2]=o,i[m>>2]=0,a=0):(o=r,s=c),r=(o|0)<(s|0)?o:s,r=(a|0)<(r|0)?a:r,(r|0)>0&&(i[h>>2]=s-r,i[p>>2]=o-r,i[m>>2]=a-r),Ft(i[t>>2]|0)|0&&(o=i[h>>2]|0,s=i[p>>2]|0,a=i[m>>2]|0,r=(s*3|0)+o|0,o=a+(o*3|0)|0,i[h>>2]=o,i[p>>2]=r,s=(a*3|0)+s|0,i[m>>2]=s,a=r-o|0,c=s-o|0,(o|0)<0?(i[p>>2]=a,i[m>>2]=c,i[h>>2]=0,r=a,l=0):(l=o,c=s),o=l-r|0,a=c-r|0,(r|0)<0?(i[h>>2]=o,i[m>>2]=a,i[p>>2]=0,l=o,s=0):(s=r,a=c),o=l-a|0,r=s-a|0,(a|0)<0?(i[h>>2]=o,i[p>>2]=r,i[m>>2]=0,s=r,a=0):o=l,r=(s|0)<(o|0)?s:o,r=(a|0)<(r|0)?a:r,(r|0)>0&&(i[h>>2]=o-r,i[p>>2]=s-r,i[m>>2]=a-r),i[t>>2]=(i[t>>2]|0)+1),l=0;do i[n+(l<<4)>>2]=i[e>>2],a=i[p>>2]|0,r=i[m>>2]|0,u=i[f+(l*12|0)+4>>2]|0,d=i[f+(l*12|0)+8>>2]|0,s=(i[f+(l*12|0)>>2]|0)+(i[h>>2]|0)|0,t=n+(l<<4)+4|0,i[t>>2]=s,a=u+a|0,u=n+(l<<4)+8|0,i[u>>2]=a,r=d+r|0,d=n+(l<<4)+12|0,i[d>>2]=r,o=a-s|0,(s|0)<0&&(r=r-s|0,i[u>>2]=o,i[d>>2]=r,i[t>>2]=0,a=o,s=0),(a|0)<0&&(s=s-a|0,i[t>>2]=s,r=r-a|0,i[d>>2]=r,i[u>>2]=0,a=0),c=s-r|0,o=a-r|0,(r|0)<0?(i[t>>2]=c,i[u>>2]=o,i[d>>2]=0,s=c,r=0):o=a,a=(o|0)<(s|0)?o:s,a=(r|0)<(a|0)?r:a,(a|0)>0&&(i[t>>2]=s-a,i[u>>2]=o-a,i[d>>2]=r-a),l=l+1|0;while((l|0)!=6);M=g}function ft(e,t){return e|=0,t|=0,t=z(e|0,t|0,52)|0,T()|0,t&15|0}function pt(e,t){return e|=0,t|=0,t=z(e|0,t|0,45)|0,T()|0,t&127|0}function mt(e,t,n,r){return e|=0,t|=0,n|=0,r|=0,(n+-1|0)>>>0>14?(r=4,r|0):(n=z(e|0,t|0,(15-n|0)*3|0)|0,T()|0,i[r>>2]=n&7,r=0,r|0)}function ht(e,t,n,a){e|=0,t|=0,n|=0,a|=0;var o=0,s=0,c=0,l=0,u=0,d=0;if(e>>>0>15)return a=4,a|0;if(t>>>0>121)return a=17,a|0;c=B(e|0,0,52)|0,o=T()|0,l=B(t|0,0,45)|0,o=o|(T()|0)|134225919;a:do if((e|0)>=1){for(l=1,c=(r[20496+t>>0]|0)!=0,s=-1;;){if(t=i[n+(l+-1<<2)>>2]|0,t>>>0>6){o=18,t=10;break}if(!((t|0)==0|c^1))if((t|0)==1){o=19,t=10;break}else c=0;if(d=(15-l|0)*3|0,u=B(7,0,d|0)|0,o&=~(T()|0),t=B(t|0,((t|0)<0)<<31>>31|0,d|0)|0,s=t|s&~u,o=T()|0|o,(l|0)<(e|0))l=l+1|0;else break a}if((t|0)==10)return o|0}else s=-1;while(0);return d=a,i[d>>2]=s,i[d+4>>2]=o,d=0,d|0}function gt(e,t){e|=0,t|=0;var n=0,i=0,a=0,o=0,s=0;return!(!0&(t&-16777216|0)==134217728)||(i=z(e|0,t|0,52)|0,T()|0,i&=15,n=z(e|0,t|0,45)|0,T()|0,n&=127,n>>>0>121)?(e=0,e|0):(s=(i^15)*3|0,a=z(e|0,t|0,s|0)|0,s=B(a|0,T()|0,s|0)|0,a=T()|0,o=dr(-1227133514,-1171,s|0,a|0)|0,!((s&613566756&o|0)==0&(a&4681&(T()|0)|0)==0)||(s=(i*3|0)+19|0,o=B(~e|0,~t|0,s|0)|0,s=z(o|0,T()|0,s|0)|0,!((i|0)==15|(s|0)==0&(T()|0)==0))?(s=0,s|0):!(r[20496+n>>0]|0)||(t&=8191,(e|0)==0&(t|0)==0)?(s=1,s|0):(s=br(e|0,t|0,0)|0,T()|0,((63-s|0)%3|0)!=0|0))}function _t(e,t){e|=0,t|=0;var n=0,i=0,a=0,o=0,s=0;return!0&(t&-16777216|0)==134217728&&(i=z(e|0,t|0,52)|0,T()|0,i&=15,n=z(e|0,t|0,45)|0,T()|0,n&=127,n>>>0<=121)&&(s=(i^15)*3|0,a=z(e|0,t|0,s|0)|0,s=B(a|0,T()|0,s|0)|0,a=T()|0,o=dr(-1227133514,-1171,s|0,a|0)|0,(s&613566756&o|0)==0&(a&4681&(T()|0)|0)==0)&&(s=(i*3|0)+19|0,o=B(~e|0,~t|0,s|0)|0,s=z(o|0,T()|0,s|0)|0,(i|0)==15|(s|0)==0&(T()|0)==0)&&(!(r[20496+n>>0]|0)||(n=t&8191,(e|0)==0&(n|0)==0)||(s=br(e|0,n|0,0)|0,T()|0,(63-s|0)%3|0))||Qe(e,t)|0?(s=1,s|0):(s=(qn(e,t)|0)!=0&1,s|0)}function vt(e,t,n,r){e|=0,t|=0,n|=0,r|=0;var a=0,o=0,s=0,c=0;if(a=B(t|0,0,52)|0,o=T()|0,n=B(n|0,0,45)|0,n=o|(T()|0)|134225919,(t|0)<1){o=-1,r=n,t=e,i[t>>2]=o,e=e+4|0,i[e>>2]=r;return}for(o=1,a=-1;s=(15-o|0)*3|0,c=B(7,0,s|0)|0,n&=~(T()|0),s=B(r|0,0,s|0)|0,a=a&~c|s,n|=T()|0,(o|0)!=(t|0);)o=o+1|0;c=e,s=c,i[s>>2]=a,c=c+4|0,i[c>>2]=n}function yt(e,t,n,r){e|=0,t|=0,n|=0,r|=0;var a=0,o=0;if(o=z(e|0,t|0,52)|0,T()|0,o&=15,n>>>0>15)return r=4,r|0;if((o|0)<(n|0))return r=12,r|0;if((o|0)==(n|0))return i[r>>2]=e,i[r+4>>2]=t,r=0,r|0;if(a=B(n|0,0,52)|0,a|=e,e=T()|0|t&-15728641,(o|0)>(n|0))do t=B(7,0,(14-n|0)*3|0)|0,n=n+1|0,a=t|a,e=T()|0|e;while((n|0)<(o|0));return i[r>>2]=a,i[r+4>>2]=e,r=0,r|0}function bt(e,t,n,r){e|=0,t|=0,n|=0,r|=0;var a=0,o=0,s=0;if(o=z(e|0,t|0,52)|0,T()|0,o&=15,!((n|0)<16&(o|0)<=(n|0)))return r=4,r|0;a=n-o|0,n=z(e|0,t|0,45)|0,T()|0;a:do if(!(Se(n&127)|0))n=vn(7,0,a,((a|0)<0)<<31>>31)|0,a=T()|0;else{b:do if(o|0){for(n=1;s=B(7,0,(15-n|0)*3|0)|0,(s&e|0)==0&((T()|0)&t|0)==0;)if(n>>>0>>0)n=n+1|0;else break b;n=vn(7,0,a,((a|0)<0)<<31>>31)|0,a=T()|0;break a}while(0);n=vn(7,0,a,((a|0)<0)<<31>>31)|0,n=gr(n|0,T()|0,5,0)|0,n=ur(n|0,T()|0,-5,-1)|0,n=mr(n|0,T()|0,6,0)|0,n=ur(n|0,T()|0,1,0)|0,a=T()|0}while(0);return s=r,i[s>>2]=n,i[s+4>>2]=a,s=0,s|0}function xt(e,t){e|=0,t|=0;var n=0,r=0,i=0;if(i=z(e|0,t|0,45)|0,T()|0,!(Se(i&127)|0))return i=0,i|0;i=z(e|0,t|0,52)|0,T()|0,i&=15;a:do if(!i)n=0;else for(r=1;;){if(n=z(e|0,t|0,(15-r|0)*3|0)|0,T()|0,n&=7,n|0)break a;if(r>>>0>>0)r=r+1|0;else{n=0;break}}while(0);return i=(n|0)==0&1,i|0}function St(e,t,n,r){e|=0,t|=0,n|=0,r|=0;var a=0,o=0,s=0,c=0;if(s=M,M=M+16|0,o=s,Gt(o,e,t,n),t=o,e=i[t>>2]|0,t=i[t+4>>2]|0,(e|0)==0&(t|0)==0)return M=s,0;a=0,n=0;do c=r+(a<<3)|0,i[c>>2]=e,i[c+4>>2]=t,a=ur(a|0,n|0,1,0)|0,n=T()|0,qt(o),c=o,e=i[c>>2]|0,t=i[c+4>>2]|0;while(!((e|0)==0&(t|0)==0));return M=s,0}function Ct(e,t,n,r){return e|=0,t|=0,n|=0,r|=0,(r|0)<(n|0)?(n=t,r=e,w(n|0),r|0):(n=B(-1,-1,((r-n|0)*3|0)+3|0)|0,r=B(~n|0,~(T()|0)|0,(15-r|0)*3|0)|0,n=~(T()|0)&t,r=~r&e,w(n|0),r|0)}function wt(e,t,n,r){e|=0,t|=0,n|=0,r|=0;var a=0;return a=z(e|0,t|0,52)|0,T()|0,a&=15,(n|0)<16&(a|0)<=(n|0)?((a|0)<(n|0)&&(a=B(-1,-1,((n+-1-a|0)*3|0)+3|0)|0,a=B(~a|0,~(T()|0)|0,(15-n|0)*3|0)|0,t=~(T()|0)&t,e=~a&e),a=B(n|0,0,52)|0,n=t&-15728641|(T()|0),i[r>>2]=e|a,i[r+4>>2]=n,r=0,r|0):(r=4,r|0)}function Tt(e,t,n,r){e|=0,t|=0,n|=0,r|=0;var a=0,o=0,s=0,c=0,l=0,u=0,d=0,f=0,p=0,m=0,h=0,g=0,_=0,v=0,y=0,b=0,x=0,S=0,C=0,w=0,D=0,O=0,k=0,A=0,j=0,M=0;if((n|0)==0&(r|0)==0)return M=0,M|0;if(a=e,o=i[a>>2]|0,a=i[a+4>>2]|0,!0&(a&15728640|0)==0){if(!((r|0)>0|(r|0)==0&n>>>0>0)||(M=t,i[M>>2]=o,i[M+4>>2]=a,(n|0)==1&(r|0)==0))return M=0,M|0;a=1,o=0;do A=e+(a<<3)|0,j=i[A+4>>2]|0,M=t+(a<<3)|0,i[M>>2]=i[A>>2],i[M+4>>2]=j,a=ur(a|0,o|0,1,0)|0,o=T()|0;while((o|0)<(r|0)|(o|0)==(r|0)&a>>>0>>0);return a=0,a|0}if(k=n<<3,j=ir(k)|0,!j)return M=13,M|0;if(wr(j|0,e|0,k|0)|0,A=or(n,8)|0,!A)return ar(j),M=13,M|0;a:for(;;){a=j,u=i[a>>2]|0,a=i[a+4>>2]|0,D=z(u|0,a|0,52)|0,T()|0,D&=15,O=D+-1|0,w=(D|0)!=0,C=(r|0)>0|(r|0)==0&n>>>0>0;b:do if(w&C){if(y=B(O|0,0,52)|0,b=T()|0,O>>>0>15){if(!((u|0)==0&(a|0)==0)){M=16;break a}for(o=0,e=0;;){if(o=ur(o|0,e|0,1,0)|0,e=T()|0,!((e|0)<(r|0)|(e|0)==(r|0)&o>>>0>>0))break b;if(s=j+(o<<3)|0,S=i[s>>2]|0,s=i[s+4>>2]|0,!((S|0)==0&(s|0)==0)){a=s,M=16;break a}}}for(c=u,e=a,o=0,s=0;;){if(!((c|0)==0&(e|0)==0)){if(!(!0&(e&117440512|0)==0)){M=21;break a}if(d=z(c|0,e|0,52)|0,T()|0,d&=15,(d|0)<(O|0)){a=12,M=27;break a}if((d|0)!=(O|0)&&(c|=y,e=e&-15728641|b,d>>>0>=D>>>0)){l=O;do S=B(7,0,(14-l|0)*3|0)|0,l=l+1|0,c=S|c,e=T()|0|e;while(l>>>0>>0)}if(p=vr(c|0,e|0,n|0,r|0)|0,m=T()|0,l=A+(p<<3)|0,d=l,f=i[d>>2]|0,d=i[d+4>>2]|0,!((f|0)==0&(d|0)==0)){_=0,v=0;do{if((_|0)>(r|0)|(_|0)==(r|0)&v>>>0>n>>>0){M=31;break a}if((f|0)==(c|0)&(d&-117440513|0)==(e|0)){h=z(f|0,d|0,56)|0,T()|0,h&=7,g=h+1|0,S=z(f|0,d|0,45)|0,T()|0;c:do if(!(Se(S&127)|0))d=7;else{if(f=z(f|0,d|0,52)|0,T()|0,f&=15,!f){d=6;break}for(d=1;;){if(S=B(7,0,(15-d|0)*3|0)|0,!((S&c|0)==0&((T()|0)&e|0)==0)){d=7;break c}if(d>>>0>>0)d=d+1|0;else{d=6;break}}}while(0);if((h+2|0)>>>0>d>>>0){M=41;break a}S=B(g|0,0,56)|0,e=T()|0|e&-117440513,x=l,i[x>>2]=0,i[x+4>>2]=0,c=S|c}else p=ur(p|0,m|0,1,0)|0,p=_r(p|0,T()|0,n|0,r|0)|0,m=T()|0;v=ur(v|0,_|0,1,0)|0,_=T()|0,l=A+(p<<3)|0,d=l,f=i[d>>2]|0,d=i[d+4>>2]|0}while(!((f|0)==0&(d|0)==0))}S=l,i[S>>2]=c,i[S+4>>2]=e}if(o=ur(o|0,s|0,1,0)|0,s=T()|0,!((s|0)<(r|0)|(s|0)==(r|0)&o>>>0>>0))break b;e=j+(o<<3)|0,c=i[e>>2]|0,e=i[e+4>>2]|0}}while(0);if(S=ur(n|0,r|0,5,0)|0,x=T()|0,x>>>0<0|(x|0)==0&S>>>0<11){M=85;break}if(S=mr(n|0,r|0,6,0)|0,T()|0,S=or(S,8)|0,!S){M=48;break}do if(C){for(g=0,e=0,h=0,_=0;;){if(d=A+(g<<3)|0,s=d,o=i[s>>2]|0,s=i[s+4>>2]|0,(o|0)==0&(s|0)==0)x=h;else{f=z(o|0,s|0,56)|0,T()|0,f&=7,c=f+1|0,p=s&-117440513,x=z(o|0,s|0,45)|0,T()|0;d:do if(Se(x&127)|0){if(m=z(o|0,s|0,52)|0,T()|0,m&=15,m|0)for(l=1;;){if(x=B(7,0,(15-l|0)*3|0)|0,!((o&x|0)==0&(p&(T()|0)|0)==0))break d;if(l>>>0>>0)l=l+1|0;else break}s=B(c|0,0,56)|0,o=s|o,s=T()|0|p,c=d,i[c>>2]=o,i[c+4>>2]=s,c=f+2|0}while(0);(c|0)==7?(x=S+(e<<3)|0,i[x>>2]=o,i[x+4>>2]=s&-117440513,e=ur(e|0,h|0,1,0)|0,x=T()|0):x=h}if(g=ur(g|0,_|0,1,0)|0,_=T()|0,(_|0)<(r|0)|(_|0)==(r|0)&g>>>0>>0)h=x;else break}if(C){if(v=O>>>0>15,y=B(O|0,0,52)|0,b=T()|0,!w){for(o=0,l=0,c=0,s=0;(u|0)==0&(a|0)==0||(O=t+(o<<3)|0,i[O>>2]=u,i[O+4>>2]=a,o=ur(o|0,l|0,1,0)|0,l=T()|0),c=ur(c|0,s|0,1,0)|0,s=T()|0,(s|0)<(r|0)|(s|0)==(r|0)&c>>>0>>0;)a=j+(c<<3)|0,u=i[a>>2]|0,a=i[a+4>>2]|0;a=x;break}for(o=0,l=0,s=0,c=0;;){do if(!((u|0)==0&(a|0)==0)){if(m=z(u|0,a|0,52)|0,T()|0,m&=15,v|(m|0)<(O|0)){M=80;break a}if((m|0)!=(O|0)){if(d=u|y,f=a&-15728641|b,m>>>0>=D>>>0){p=O;do w=B(7,0,(14-p|0)*3|0)|0,p=p+1|0,d=w|d,f=T()|0|f;while(p>>>0>>0)}}else d=u,f=a;h=vr(d|0,f|0,n|0,r|0)|0,p=0,m=0,_=T()|0;do{if((p|0)>(r|0)|(p|0)==(r|0)&m>>>0>n>>>0){M=81;break a}if(w=A+(h<<3)|0,g=i[w+4>>2]|0,(g&-117440513|0)==(f|0)&&(i[w>>2]|0)==(d|0)){M=65;break}w=ur(h|0,_|0,1,0)|0,h=_r(w|0,T()|0,n|0,r|0)|0,_=T()|0,m=ur(m|0,p|0,1,0)|0,p=T()|0,w=A+(h<<3)|0}while(!((i[w>>2]|0)==(d|0)&&(i[w+4>>2]|0)==(f|0)));if((M|0)==65&&(M=0,!0&(g&117440512|0)==100663296))break;w=t+(o<<3)|0,i[w>>2]=u,i[w+4>>2]=a,o=ur(o|0,l|0,1,0)|0,l=T()|0}while(0);if(s=ur(s|0,c|0,1,0)|0,c=T()|0,!((c|0)<(r|0)|(c|0)==(r|0)&s>>>0>>0))break;a=j+(s<<3)|0,u=i[a>>2]|0,a=i[a+4>>2]|0}a=x}else o=0,a=x}else o=0,e=0,a=0;while(0);if(Er(A|0,0,k|0)|0,wr(j|0,S|0,e<<3|0)|0,ar(S),(e|0)==0&(a|0)==0){M=89;break}else t=t+(o<<3)|0,r=a,n=e}if((M|0)==16)!0&(a&117440512|0)==0?(a=4,M=27):M=21;else if((M|0)==31)E(27634,27225,620,27235);else if((M|0)==41)return ar(j),ar(A),M=10,M|0;else if((M|0)==48)return ar(j),ar(A),M=13,M|0;else (M|0)==80?E(27634,27225,711,27235):(M|0)==81?E(27634,27225,723,27235):(M|0)==85&&(wr(t|0,j|0,n<<3|0)|0,M=89);return(M|0)==21?(ar(j),ar(A),M=5,M|0):(M|0)==27?(ar(j),ar(A),M=a,M|0):(M|0)==89?(ar(j),ar(A),M=0,M|0):0}function Et(e,t,n,r,a,o,s){e|=0,t|=0,n|=0,r|=0,a|=0,o|=0,s|=0;var c=0,l=0,u=0,d=0,f=0,p=0,m=0,h=0,g=0;if(g=M,M=M+16|0,h=g,!((n|0)>0|(n|0)==0&t>>>0>0))return h=0,M=g,h|0;if((s|0)>=16)return h=12,M=g,h|0;p=0,m=0,f=0,c=0;a:for(;;){if(u=e+(p<<3)|0,l=i[u>>2]|0,u=i[u+4>>2]|0,d=z(l|0,u|0,52)|0,T()|0,(d&15|0)>(s|0)){c=12,l=11;break}if(Gt(h,l,u,s),d=h,u=i[d>>2]|0,d=i[d+4>>2]|0,(u|0)==0&(d|0)==0)l=f;else{l=f;do{if(!((c|0)<(o|0)|(c|0)==(o|0)&l>>>0>>0)){l=10;break a}f=r+(l<<3)|0,i[f>>2]=u,i[f+4>>2]=d,l=ur(l|0,c|0,1,0)|0,c=T()|0,qt(h),f=h,u=i[f>>2]|0,d=i[f+4>>2]|0}while(!((u|0)==0&(d|0)==0))}if(p=ur(p|0,m|0,1,0)|0,m=T()|0,(m|0)<(n|0)|(m|0)==(n|0)&p>>>0>>0)f=l;else{c=0,l=11;break}}return(l|0)==10?(h=14,M=g,h|0):(l|0)==11?(M=g,c|0):0}function Dt(e,t,n,r,a){e|=0,t|=0,n|=0,r|=0,a|=0;var o=0,s=0,c=0,l=0,u=0,d=0,f=0,p=0;p=M,M=M+16|0,f=p;a:do if((n|0)>0|(n|0)==0&t>>>0>0){for(u=0,s=0,o=0,d=0;;){if(l=e+(u<<3)|0,c=i[l>>2]|0,l=i[l+4>>2]|0,!((c|0)==0&(l|0)==0)&&(l=(bt(c,l,r,f)|0)==0,c=f,s=ur(i[c>>2]|0,i[c+4>>2]|0,s|0,o|0)|0,o=T()|0,!l)){o=12;break}if(u=ur(u|0,d|0,1,0)|0,d=T()|0,!((d|0)<(n|0)|(d|0)==(n|0)&u>>>0>>0))break a}return M=p,o|0}else s=0,o=0;while(0);return i[a>>2]=s,i[a+4>>2]=o,a=0,M=p,a|0}function Ot(e,t){return e|=0,t|=0,t=z(e|0,t|0,52)|0,T()|0,t&1|0}function kt(e,t){e|=0,t|=0;var n=0,r=0,i=0;if(i=z(e|0,t|0,52)|0,T()|0,i&=15,!i)return i=0,i|0;for(r=1;;){if(n=z(e|0,t|0,(15-r|0)*3|0)|0,T()|0,n&=7,n|0){r=5;break}if(r>>>0>>0)r=r+1|0;else{n=0,r=5;break}}return(r|0)==5?n|0:0}function At(e,t){e|=0,t|=0;var n=0,r=0,i=0,a=0,o=0,s=0,c=0,l=0,u=0;if(u=z(e|0,t|0,52)|0,T()|0,u&=15,!u)return l=t,u=e,w(l|0),u|0;for(l=1,n=0;;){switch(r=(15-l|0)*3|0,s=B(7,0,r|0)|0,c=T()|0,a=e&~s,o=t&~c,e=z(e|0,t|0,r|0)|0,T()|0,e&7){case 1:e=5;break;case 5:e=4;break;case 4:e=6;break;case 6:e=2;break;case 2:e=3;break;case 3:e=1;break;default:e&=7}r=B(e|0,0,r|0)|0,i=T()|0,e=r|a,t=i|o;a:do if(!n)if((r&s|0)==0&(i&c|0)==0)n=0;else if(o=z(e|0,t|0,52)|0,T()|0,o&=15,!o)n=1;else{n=1;b:for(;;){switch(c=z(e|0,t|0,(15-n|0)*3|0)|0,T()|0,c&7){case 1:break b;case 0:break;default:n=1;break a}if(n>>>0>>0)n=n+1|0;else{n=1;break a}}for(a=1;;){switch(i=(15-a|0)*3|0,n=z(e|0,t|0,i|0)|0,T()|0,r=B(7,0,i|0)|0,r=e&~r,t&=~(T()|0),n&7){case 1:e=5;break;case 5:e=4;break;case 4:e=6;break;case 6:e=2;break;case 2:e=3;break;case 3:e=1;break;default:e=n&7}if(e=B(e|0,0,i|0)|0,e|=r,t=T()|0|t,a>>>0>>0)a=a+1|0;else{n=1;break a}}}while(0);if(l>>>0>>0)l=l+1|0;else break}return w(t|0),e|0}function jt(e,t){e|=0,t|=0;var n=0,r=0,i=0,a=0,o=0;if(o=z(e|0,t|0,52)|0,T()|0,o&=15,!o)return a=t,o=e,w(a|0),o|0;for(a=1;;){switch(i=(15-a|0)*3|0,n=z(e|0,t|0,i|0)|0,T()|0,r=B(7,0,i|0)|0,r=e&~r,t&=~(T()|0),n&7){case 1:e=5;break;case 5:e=4;break;case 4:e=6;break;case 6:e=2;break;case 2:e=3;break;case 3:e=1;break;default:e=n&7}if(e=B(e|0,0,i|0)|0,e|=r,t=T()|0|t,a>>>0>>0)a=a+1|0;else break}return w(t|0),e|0}function Mt(e,t){e|=0,t|=0;var n=0,r=0,i=0,a=0,o=0,s=0,c=0,l=0,u=0;if(u=z(e|0,t|0,52)|0,T()|0,u&=15,!u)return l=t,u=e,w(l|0),u|0;for(l=1,n=0;;){switch(r=(15-l|0)*3|0,s=B(7,0,r|0)|0,c=T()|0,a=e&~s,o=t&~c,e=z(e|0,t|0,r|0)|0,T()|0,e&7){case 1:e=3;break;case 3:e=2;break;case 2:e=6;break;case 6:e=4;break;case 4:e=5;break;case 5:e=1;break;default:e&=7}r=B(e|0,0,r|0)|0,i=T()|0,e=r|a,t=i|o;a:do if(!n)if((r&s|0)==0&(i&c|0)==0)n=0;else if(o=z(e|0,t|0,52)|0,T()|0,o&=15,!o)n=1;else{n=1;b:for(;;){switch(c=z(e|0,t|0,(15-n|0)*3|0)|0,T()|0,c&7){case 1:break b;case 0:break;default:n=1;break a}if(n>>>0>>0)n=n+1|0;else{n=1;break a}}for(a=1;;){switch(n=(15-a|0)*3|0,r=B(7,0,n|0)|0,r=e&~r,i=t&~(T()|0),e=z(e|0,t|0,n|0)|0,T()|0,e&7){case 1:e=3;break;case 3:e=2;break;case 2:e=6;break;case 6:e=4;break;case 4:e=5;break;case 5:e=1;break;default:e&=7}if(e=B(e|0,0,n|0)|0,e|=r,t=T()|0|i,a>>>0>>0)a=a+1|0;else{n=1;break a}}}while(0);if(l>>>0>>0)l=l+1|0;else break}return w(t|0),e|0}function Nt(e,t){e|=0,t|=0;var n=0,r=0,i=0,a=0,o=0;if(o=z(e|0,t|0,52)|0,T()|0,o&=15,!o)return a=t,o=e,w(a|0),o|0;for(a=1;;){switch(r=(15-a|0)*3|0,n=B(7,0,r|0)|0,n=e&~n,i=t&~(T()|0),e=z(e|0,t|0,r|0)|0,T()|0,e&7){case 1:e=3;break;case 3:e=2;break;case 2:e=6;break;case 6:e=4;break;case 4:e=5;break;case 5:e=1;break;default:e&=7}if(e=B(e|0,0,r|0)|0,e|=n,t=T()|0|i,a>>>0>>0)a=a+1|0;else break}return w(t|0),e|0}function Pt(e,t){e|=0,t|=0;var n=0,r=0,a=0,o=0,s=0,c=0,l=0,u=0,d=0,f=0,p=0,m=0,h=0,g=0,_=0,v=0,y=0,b=0,x=0,S=0,C=0,E=0;if(x=M,M=M+16|0,b=x,B(t|0,0,52)|0,n=T()|134225919,!t)return(i[e+4>>2]|0)>2||(i[e+8>>2]|0)>2||(i[e+12>>2]|0)>2?(y=0,b=0,w(y|0),M=x,b|0):(B(we(e)|0,0,45)|0,y=T()|0|n,b=-1,w(y|0),M=x,b|0);i[b>>2]=i[e>>2],i[b+4>>2]=i[e+4>>2],i[b+8>>2]=i[e+8>>2],i[b+12>>2]=i[e+12>>2],y=b+4|0;a:do if((t|0)>0)for(g=b+8|0,_=b+12|0,h=t,f=i[g>>2]|0,p=i[_>>2]|0,t=-1,d=i[b+4>>2]|0;;){m=h,h=h+-1|0,e=d-p|0,r=f-p|0,m&1?(o=rr(((e*3|0)-r|0)*.14285714285714285)|0,i[y>>2]=o,e=rr(((r<<1)+e|0)*.14285714285714285)|0,i[g>>2]=e,i[_>>2]=0,r=e-o|0,a=0-o|0,(o|0)<0?(i[g>>2]=r,i[_>>2]=a,i[y>>2]=0,e=r,s=0):(s=o,a=0),o=s-e|0,r=a-e|0,(e|0)<0?(i[y>>2]=o,i[_>>2]=r,i[g>>2]=0,s=o,o=0):(r=a,o=e),e=s-r|0,a=o-r|0,(r|0)<0?(i[y>>2]=e,i[g>>2]=a,i[_>>2]=0,o=0):(a=o,e=s,o=r),r=(a|0)<(e|0)?a:e,r=(o|0)<(r|0)?o:r,(r|0)>0&&(o=o-r|0,a=a-r|0,e=e-r|0,i[y>>2]=e,i[g>>2]=a,i[_>>2]=o),C=a+(e*3|0)|0,S=(C|0)<0,u=o+(a*3|0)-(S?C:0)|0,l=(u|0)<0,r=(o*3|0)+e-(S?C:0)-(l?u:0)|0,c=(r|0)<0,E=c?0:r,s=(l?0:u)-(c?r:0)|0,r=(S?0:C)-(l?u:0)-(c?r:0)|0,c=(s|0)<(r|0)?s:r,c=(E|0)<(c|0)?E:c,u=(c|0)>0,l=u?c:0,s=s-(u?c:0)|0,c=E-(u?c:0)|0,u=o):(c=rr(((e<<1)+r|0)*.14285714285714285)|0,i[y>>2]=c,a=rr(((r*3|0)-e|0)*.14285714285714285)|0,i[g>>2]=a,i[_>>2]=0,r=a-c|0,e=0-c|0,(c|0)<0?(i[g>>2]=r,i[_>>2]=e,i[y>>2]=0,a=r,c=0):e=0,s=c-a|0,r=e-a|0,(a|0)<0?(i[y>>2]=s,i[_>>2]=r,i[g>>2]=0,o=r,a=0):(o=e,s=c),e=s-o|0,r=a-o|0,(o|0)<0?(i[y>>2]=e,i[g>>2]=r,i[_>>2]=0,a=r,o=0):e=s,r=(a|0)<(e|0)?a:e,r=(o|0)<(r|0)?o:r,(r|0)>0&&(o=o-r|0,a=a-r|0,e=e-r|0,i[y>>2]=e,i[g>>2]=a,i[_>>2]=o),C=o+(e*3|0)|0,E=(C|0)<0,u=(a*3|0)+e-(E?C:0)|0,l=(u|0)<0,r=(o*3|0)+a-(E?C:0)-(l?u:0)|0,c=(r|0)<0,S=c?0:r,s=(l?0:u)-(c?r:0)|0,r=(E?0:C)-(l?u:0)-(c?r:0)|0,c=(s|0)<(r|0)?s:r,c=(S|0)<(c|0)?S:c,u=(c|0)>0,l=u?c:0,s=s-(u?c:0)|0,c=S-(u?c:0)|0,u=o),r=d+(l-r)|0,o=(r|0)<0,l=f-s-(o?r:0)|0,s=(l|0)<0,p=p-c+(o?0-r|0:0)+(s?0-l|0:0)|0,d=(p|0)<0,c=d?0:p,E=(s?0:l)-(d?p:0)|0,p=(o?0:r)-(s?l:0)-(d?p:0)|0,d=(E|0)<(p|0)?E:p,d=(c|0)<(d|0)?c:d,l=(d|0)>0,p=p-(l?d:0)|0,s=(15-m|0)*3|0,r=B(7,0,s|0)|0,r=t&~r,o=n&~(T()|0),f=(p|0)<0,C=f?p:0,E=E-(l?d:0)-C|0,S=(E|0)<0,C=(S?0-E|0:0)+(c-(l?d:0)-C)|0,n=(C|0)<0,t=n?0:C,C=n?C:0,n=(S?0:E)-C|0,C=(f?0:p)-(S?E:0)-C|0,E=(n|0)<(C|0)?n:C,E=(t|0)<(E|0)?t:E,E=(E|0)>0?E:0,t=t-E|0,n=n-E|0;b:do switch(C-E|0){case 0:switch(n|0){case 0:t=t|0?(t|0)==1?1:7:0;break b;case 1:t=t|0?(t|0)==1?3:7:2;break b;default:v=36;break b}case 1:switch(n|0){case 0:t=t|0?(t|0)==1?5:7:4;break b;case 1:if(t){v=36;break b}else{t=6;break b}default:v=36;break b}default:v=36}while(0);if((v|0)==36&&(v=0,t=7),t=B(t|0,0,s|0)|0,t|=r,n=T()|0|o,(m|0)<=1)break a;f=a,p=u,d=e}else t=-1,e=i[y>>2]|0;while(0);c:do if((e|0)<=2&&(i[b+8>>2]|0)<=2&&(i[b+12>>2]|0)<=2){if(r=we(b)|0,e=B(r|0,0,45)|0,t=e|t,e=T()|0|n&-1040385,l=Te(b)|0,!(Se(r)|0)){if((l|0)<=0)break;for(c=0;;){s=z(t|0,e|0,52)|0,T()|0,s&=15;d:do if(s)for(o=1;;){switch(a=(15-o|0)*3|0,n=z(t|0,e|0,a|0)|0,T()|0,r=B(7,0,a|0)|0,t&=~r,r=e&~(T()|0),n&7){case 1:e=5;break;case 5:e=4;break;case 4:e=6;break;case 6:e=2;break;case 2:e=3;break;case 3:e=1;break;default:e=n&7}if(e=B(e|0,0,a|0)|0,t=e|t,e=T()|0|r,o>>>0>>0)o=o+1|0;else break d}while(0);if(c=c+1|0,(c|0)==(l|0))break c}}s=z(t|0,e|0,52)|0,T()|0,s&=15;e:do if(s){n=1;f:for(;;){switch(E=z(t|0,e|0,(15-n|0)*3|0)|0,T()|0,E&7){case 1:break f;case 0:break;default:break e}if(n>>>0>>0)n=n+1|0;else break e}if(Oe(r,i[b>>2]|0)|0)for(o=1;;){switch(n=(15-o|0)*3|0,r=B(7,0,n|0)|0,r=t&~r,a=e&~(T()|0),e=z(t|0,e|0,n|0)|0,T()|0,e&7){case 1:e=3;break;case 3:e=2;break;case 2:e=6;break;case 6:e=4;break;case 4:e=5;break;case 5:e=1;break;default:e&=7}if(t=B(e|0,0,n|0)|0,t|=r,e=T()|0|a,o>>>0>>0)o=o+1|0;else break e}else for(o=1;;){switch(a=(15-o|0)*3|0,n=z(t|0,e|0,a|0)|0,T()|0,r=B(7,0,a|0)|0,t&=~r,r=e&~(T()|0),n&7){case 1:e=5;break;case 5:e=4;break;case 4:e=6;break;case 6:e=2;break;case 2:e=3;break;case 3:e=1;break;default:e=n&7}if(e=B(e|0,0,a|0)|0,t=e|t,e=T()|0|r,o>>>0>>0)o=o+1|0;else break e}}while(0);if((l|0)>0){n=0;do t=At(t,e)|0,e=T()|0,n=n+1|0;while((n|0)!=(l|0))}}else t=0,e=0;while(0);return C=e,E=t,w(C|0),M=x,E|0}function Ft(e){return e|=0,(e|0)%2|0}function It(e,t,n){e|=0,t|=0,n|=0;var r=0,s=0,c=0,l=0,u=0,p=0,m=0,h=0,g=0;if(h=M,M=M+64|0,u=h+24|0,p=h+48|0,m=h,t>>>0>15)return m=4,M=h,m|0;if(c=+a[e>>3],a[o>>3]=c,(i[o+4>>2]&2146435072|0)==2146435072||(r=+a[e+8>>3],a[o>>3]=r,(i[o+4>>2]&2146435072|0)==2146435072))return m=3,M=h,m|0;s=+d(+c),g=s*+d(+r),s*=+f(+r),r=+f(+c),a[m>>3]=g,a[m+8>>3]=s,a[m+16>>3]=r,a[o>>3]=g;do if((i[o+4>>2]&2146435072|0)!=2146435072&&(a[o>>3]=r,e=i[o+4>>2]|0,a[o>>3]=s,!((i[o+4>>2]&2146435072|0)==2146435072|!0&(e&2146435072|0)==2146435072)))if(i[u>>2]=i[m>>2],i[u+4>>2]=i[m+4>>2],i[u+8>>2]=i[m+8>>2],i[u+12>>2]=i[m+12>>2],i[u+16>>2]=i[m+16>>2],i[u+20>>2]=i[m+20>>2],rt(u,t,p),p=Pt(p,t)|0,m=T()|0,i[n>>2]=p,i[n+4>>2]=m,(p|0)==0&(m|0)==0)E(27634,27225,1073,27248);else{l=0;break}else l=2;while(0);return m=l,M=h,m|0}function Lt(e,t,n){e|=0,t|=0,n|=0;var r=0,a=0,o=0,s=0,c=0,l=0,u=0,d=0,f=0,p=0,m=0,h=0;if(m=n+4|0,h=z(e|0,t|0,52)|0,T()|0,h&=15,p=z(e|0,t|0,45)|0,T()|0,r=(h|0)==0,Se(p&127)|0){if(r)return h=1,h|0;r=1}else{if(r)return h=0,h|0;r=!(i[m>>2]|0)&&!(i[n+8>>2]|0)?(i[n+12>>2]|0)!=0&1:1}for(p=n+8|0,f=n+12|0,d=1,n=i[m>>2]|0,s=i[p>>2]|0,o=i[f>>2]|0;a=n*3|0,c=s*3|0,u=o*3|0,d&1?(l=s+a|0,i[m>>2]=l,o=o+c|0,i[p>>2]=o,a=u+n|0,i[f>>2]=a,n=o-l|0,s=a-l|0,(l|0)<0?(i[p>>2]=n,i[f>>2]=s,i[m>>2]=0,c=0,a=s):(n=o,c=l),s=c-n|0,o=a-n|0,(n|0)<0?(i[m>>2]=s,i[f>>2]=o,i[p>>2]=0,c=s,a=0):(o=a,a=n),n=c-o|0,s=a-o|0,(o|0)<0?(i[m>>2]=n,i[p>>2]=s,i[f>>2]=0,o=0):(s=a,n=c),a=(s|0)<(n|0)?s:n,a=(o|0)<(a|0)?o:a,(a|0)>0&&(o=o-a|0,s=s-a|0,n=n-a|0,i[m>>2]=n,i[p>>2]=s,i[f>>2]=o)):(l=c+n|0,c=o+a|0,i[m>>2]=c,i[p>>2]=l,a=u+s|0,i[f>>2]=a,n=l-c|0,o=a-c|0,(c|0)<0?(i[p>>2]=n,i[f>>2]=o,i[m>>2]=0,c=0,a=o):n=l,s=c-n|0,o=a-n|0,(n|0)<0?(i[m>>2]=s,i[f>>2]=o,i[p>>2]=0,c=s,a=0):(o=a,a=n),n=c-o|0,s=a-o|0,(o|0)<0?(i[m>>2]=n,i[p>>2]=s,i[f>>2]=0,o=0):(s=a,n=c),a=(s|0)<(n|0)?s:n,a=(o|0)<(a|0)?o:a,(a|0)>0&&(o=o-a|0,s=s-a|0,n=n-a|0,i[m>>2]=n,i[p>>2]=s,i[f>>2]=o)),a=z(e|0,t|0,(15-d|0)*3|0)|0,T()|0,a&=7,(a+-1|0)>>>0<6&&(l=i[22032+(a*12|0)+4>>2]|0,u=i[22032+(a*12|0)+8>>2]|0,c=(i[22032+(a*12|0)>>2]|0)+n|0,i[m>>2]=c,s=l+s|0,i[p>>2]=s,n=u+o|0,i[f>>2]=n,o=s-c|0,a=n-c|0,(c|0)<0&&(i[p>>2]=o,i[f>>2]=a,i[m>>2]=0,c=0,n=a,s=o),a=c-s|0,o=n-s|0,(s|0)<0?(i[m>>2]=a,i[f>>2]=o,i[p>>2]=0,c=a,s=0):o=n,n=c-o|0,a=s-o|0,(o|0)<0?(i[m>>2]=n,i[p>>2]=a,i[f>>2]=0,s=a,o=0):n=c,a=(s|0)<(n|0)?s:n,a=(o|0)<(a|0)?o:a,(a|0)>0&&(o=o-a|0,s=s-a|0,n=n-a|0,i[m>>2]=n,i[p>>2]=s,i[f>>2]=o)),d>>>0>>0;)d=d+1|0;return r|0}function Rt(e,t,n){e|=0,t|=0,n|=0;var r=0,a=0,o=0,s=0,c=0,l=0,u=0,d=0,f=0,p=0,m=0,h=0;if(h=M,M=M+16|0,f=h,p=z(e|0,t|0,45)|0,T()|0,p&=127,p>>>0>121)return i[n>>2]=0,i[n+4>>2]=0,i[n+8>>2]=0,i[n+12>>2]=0,m=5,M=h,m|0;a:do if(Se(p)|0&&(c=z(e|0,t|0,52)|0,T()|0,c&=15,c|0)){r=1;b:for(;;){switch(m=z(e|0,t|0,(15-r|0)*3|0)|0,T()|0,m&7){case 5:break b;case 0:break;default:u=t;break a}if(r>>>0>>0)r=r+1|0;else{u=t;break a}}for(s=1,r=t;;){switch(t=(15-s|0)*3|0,a=B(7,0,t|0)|0,a=e&~a,o=r&~(T()|0),r=z(e|0,r|0,t|0)|0,T()|0,r&7){case 1:r=3;break;case 3:r=2;break;case 2:r=6;break;case 6:r=4;break;case 4:r=5;break;case 5:r=1;break;default:r&=7}if(e=B(r|0,0,t|0)|0,e|=a,r=T()|0|o,s>>>0>>0)s=s+1|0;else{u=r;break a}}}else u=t;while(0);if(m=7696+(p*28|0)|0,i[n>>2]=i[m>>2],i[n+4>>2]=i[m+4>>2],i[n+8>>2]=i[m+8>>2],i[n+12>>2]=i[m+12>>2],!(Lt(e,u,n)|0))return m=0,M=h,m|0;if(m=n+4|0,i[f>>2]=i[m>>2],i[f+4>>2]=i[m+4>>2],i[f+8>>2]=i[m+8>>2],l=z(e|0,u|0,52)|0,T()|0,d=l&15,l&1?(o=i[m>>2]|0,c=n+8|0,a=i[c>>2]|0,l=n+12|0,t=i[l>>2]|0,r=(a*3|0)+o|0,o=t+(o*3|0)|0,i[m>>2]=o,i[c>>2]=r,a=(t*3|0)+a|0,i[l>>2]=a,t=r-o|0,s=a-o|0,(o|0)<0&&(i[c>>2]=t,i[l>>2]=s,i[m>>2]=0,r=t,o=0,a=s),s=o-r|0,t=a-r|0,(r|0)<0?(i[m>>2]=s,i[l>>2]=t,i[c>>2]=0,r=0):(t=a,s=o),o=s-t|0,a=r-t|0,(t|0)<0?(i[m>>2]=o,i[c>>2]=a,i[l>>2]=0,t=0):(a=r,o=s),r=(a|0)<(o|0)?a:o,r=(t|0)<(r|0)?t:r,(r|0)>0&&(i[m>>2]=o-r,i[c>>2]=a-r,i[l>>2]=t-r),a=d+1|0):a=d,!(Se(p)|0))r=0;else{c:do if(!d)r=0;else for(t=1;;){if(r=z(e|0,u|0,(15-t|0)*3|0)|0,T()|0,r&=7,r|0)break c;if(t>>>0>>0)t=t+1|0;else{r=0;break}}while(0);r=(r|0)==4&1}if(!(ct(n,a,r,0)|0))(a|0)!=(d|0)&&(i[m>>2]=i[f>>2],i[m+4>>2]=i[f+4>>2],i[m+8>>2]=i[f+8>>2]);else{if(Se(p)|0)do;while(ct(n,a,0,0)|0);(a|0)!=(d|0)&&(c=n+12|0,e=i[c>>2]|0,r=(i[m>>2]|0)-e|0,s=n+8|0,e=(i[s>>2]|0)-e|0,t=rr(((r<<1)+e|0)*.14285714285714285)|0,i[m>>2]=t,r=rr(((e*3|0)-r|0)*.14285714285714285)|0,i[s>>2]=r,i[c>>2]=0,e=r-t|0,a=0-t|0,(t|0)<0?(i[s>>2]=e,i[c>>2]=a,i[m>>2]=0,r=e,t=0):a=0,o=t-r|0,e=a-r|0,(r|0)<0?(i[m>>2]=o,i[c>>2]=e,i[s>>2]=0,t=o,r=0):e=a,o=t-e|0,a=r-e|0,(e|0)<0?(i[m>>2]=o,i[s>>2]=a,i[c>>2]=0,t=o,e=0):a=r,r=(a|0)<(t|0)?a:t,r=(e|0)<(r|0)?e:r,(r|0)>0&&(i[m>>2]=t-r,i[s>>2]=a-r,i[c>>2]=e-r))}return m=0,M=h,m|0}function zt(e,t,n){e|=0,t|=0,n|=0;var r=0,i=0,o=0,s=0,c=0,l=0;return s=M,M=M+48|0,r=s+24|0,i=s,o=Rt(e,t,r)|0,o?(M=s,o|0):(o=z(e|0,t|0,52)|0,T()|0,it(r,o&15,i),l=+h(+ +a[i+16>>3]),c=+_(+ +a[i+8>>3],+ +a[i>>3]),a[n>>3]=l,a[n+8>>3]=c,o=0,M=s,o|0)}function Bt(e,t,n){e|=0,t|=0,n|=0;var r=0,i=0,a=0,o=0,s=0;if(o=M,M=M+16|0,a=o,r=Rt(e,t,a)|0,r|0)return a=r,M=o,a|0;r=z(e|0,t|0,45)|0,T()|0,r=(Se(r&127)|0)==0,i=z(e|0,t|0,52)|0,T()|0,i&=15;a:do if(!r){if(i|0)for(r=1;;){if(s=B(7,0,(15-r|0)*3|0)|0,!((s&e|0)==0&((T()|0)&t|0)==0))break a;if(r>>>0>>0)r=r+1|0;else break}return ot(a,i,0,5,n),s=0,M=o,s|0}while(0);return ut(a,i,0,6,n),s=0,M=o,s|0}function Vt(e,t,n){e|=0,t|=0,n|=0;var r=0,a=0,o=0;if(a=z(e|0,t|0,45)|0,T()|0,!(Se(a&127)|0))return a=2,i[n>>2]=a,0;if(a=z(e|0,t|0,52)|0,T()|0,a&=15,!a)return a=5,i[n>>2]=a,0;for(r=1;;){if(o=B(7,0,(15-r|0)*3|0)|0,!((o&e|0)==0&((T()|0)&t|0)==0)){r=2,e=6;break}if(r>>>0>>0)r=r+1|0;else{r=5,e=6;break}}return(e|0)==6&&(i[n>>2]=r),0}function Ht(e,t,n){e|=0,t|=0,n|=0;var r=0,a=0,o=0,s=0,c=0,l=0,u=0,d=0,f=0;f=M,M=M+128|0,u=f+112|0,o=f+96|0,d=f,a=z(e|0,t|0,52)|0,T()|0,c=a&15,i[u>>2]=c,s=z(e|0,t|0,45)|0,T()|0,s&=127;a:do if(Se(s)|0){if(c|0)for(r=1;;){if(l=B(7,0,(15-r|0)*3|0)|0,!((l&e|0)==0&((T()|0)&t|0)==0)){a=0;break a}if(r>>>0>>0)r=r+1|0;else break}if(a&1)a=1;else return l=B(c+1|0,0,52)|0,d=T()|0|t&-15728641,u=B(7,0,(14-c|0)*3|0)|0,d=Ht((l|e)&~u,d&~(T()|0),n)|0,M=f,d|0}else a=0;while(0);if(r=Rt(e,t,o)|0,!r){a?(st(o,u,d),l=5):(dt(o,u,d),l=6);b:do if(Se(s)|0)if(!c)e=5;else for(r=1;;){if(s=B(7,0,(15-r|0)*3|0)|0,!((s&e|0)==0&((T()|0)&t|0)==0)){e=2;break b}if(r>>>0>>0)r=r+1|0;else{e=5;break}}else e=2;while(0);Er(n|0,-1,e<<2|0)|0;c:do if(a)for(o=0;;){if(s=d+(o<<4)|0,lt(s,i[u>>2]|0)|0,s=i[s>>2]|0,c=i[n>>2]|0,(c|0)==-1|(c|0)==(s|0))r=n;else{a=0;do{if(a=a+1|0,a>>>0>=e>>>0){r=1;break c}r=n+(a<<2)|0,c=i[r>>2]|0}while(!((c|0)==-1|(c|0)==(s|0)))}if(i[r>>2]=s,o=o+1|0,o>>>0>=l>>>0){r=0;break}}else for(o=0;;){if(s=d+(o<<4)|0,ct(s,i[u>>2]|0,0,1)|0,s=i[s>>2]|0,c=i[n>>2]|0,(c|0)==-1|(c|0)==(s|0))r=n;else{a=0;do{if(a=a+1|0,a>>>0>=e>>>0){r=1;break c}r=n+(a<<2)|0,c=i[r>>2]|0}while(!((c|0)==-1|(c|0)==(s|0)))}if(i[r>>2]=s,o=o+1|0,o>>>0>=l>>>0){r=0;break}}while(0)}return d=r,M=f,d|0}function Ut(){return 12}function F(e,t){e|=0,t|=0;var n=0,r=0,a=0,o=0,s=0,c=0,l=0;if(e>>>0>15)return c=4,c|0;if(B(e|0,0,52)|0,c=T()|134225919,!e){n=0,r=0;do Se(r)|0&&(B(r|0,0,45)|0,s=c|(T()|0),e=t+(n<<3)|0,i[e>>2]=-1,i[e+4>>2]=s,n=n+1|0),r=r+1|0;while((r|0)!=122);return n=0,n|0}n=0,s=0;do{if(Se(s)|0){for(B(s|0,0,45)|0,r=1,a=-1,o=c|(T()|0);l=B(7,0,(15-r|0)*3|0)|0,a&=~l,o&=~(T()|0),(r|0)!=(e|0);)r=r+1|0;l=t+(n<<3)|0,i[l>>2]=a,i[l+4>>2]=o,n=n+1|0}s=s+1|0}while((s|0)!=122);return n=0,n|0}function I(e,t,n,r){e|=0,t|=0,n|=0,r|=0;var a=0,o=0,s=0,c=0,l=0,u=0,d=0,f=0,p=0,m=0,h=0,g=0,_=0,v=0,y=0;if(y=M,M=M+16|0,_=y,v=z(e|0,t|0,52)|0,T()|0,v&=15,n>>>0>15)return v=4,M=y,v|0;if((v|0)<(n|0))return v=12,M=y,v|0;if((v|0)!=(n|0))if(o=B(n|0,0,52)|0,o|=e,c=T()|0|t&-15728641,(v|0)>(n|0)){l=n;do g=B(7,0,(14-l|0)*3|0)|0,l=l+1|0,o=g|o,c=T()|0|c;while((l|0)<(v|0));g=o}else g=o;else g=e,c=t;h=z(g|0,c|0,45)|0,T()|0;a:do if(Se(h&127)|0){if(l=z(g|0,c|0,52)|0,T()|0,l&=15,l|0)for(o=1;;){if(h=B(7,0,(15-o|0)*3|0)|0,!((h&g|0)==0&((T()|0)&c|0)==0)){u=33;break a}if(o>>>0>>0)o=o+1|0;else break}if(h=r,i[h>>2]=0,i[h+4>>2]=0,(v|0)>(n|0)){for(h=t&-15728641,m=v;;){if(p=m,m=m+-1|0,m>>>0>15|(v|0)<(m|0)){u=19;break}if((v|0)!=(m|0))if(o=B(m|0,0,52)|0,o|=e,l=T()|0|h,(v|0)<(p|0))f=o;else{u=m;do f=B(7,0,(14-u|0)*3|0)|0,u=u+1|0,o=f|o,l=T()|0|l;while((u|0)<(v|0));f=o}else f=e,l=t;if(d=z(f|0,l|0,45)|0,T()|0,!(Se(d&127)|0))o=0;else{d=z(f|0,l|0,52)|0,T()|0,d&=15;b:do if(!d)o=0;else for(u=1;;){if(o=z(f|0,l|0,(15-u|0)*3|0)|0,T()|0,o&=7,o|0)break b;if(u>>>0>>0)u=u+1|0;else{o=0;break}}while(0);o=(o|0)==0&1}if(l=z(e|0,t|0,(15-p|0)*3|0)|0,T()|0,l&=7,(l|0)==7){a=5,u=42;break}if(o=(o|0)!=0,(l|0)==1&o){a=5,u=42;break}if(f=l+(((l|0)!=0&o)<<31>>31)|0,f|0&&(u=v-p|0,u=vn(7,0,u,((u|0)<0)<<31>>31)|0,d=T()|0,o?(o=gr(u|0,d|0,5,0)|0,o=ur(o|0,T()|0,-5,-1)|0,o=mr(o|0,T()|0,6,0)|0,o=ur(o|0,T()|0,1,0)|0,l=T()|0):(o=u,l=d),p=f+-1|0,p=gr(u|0,d|0,p|0,((p|0)<0)<<31>>31|0)|0,p=ur(o|0,l|0,p|0,T()|0)|0,f=T()|0,d=r,d=ur(p|0,f|0,i[d>>2]|0,i[d+4>>2]|0)|0,f=T()|0,p=r,i[p>>2]=d,i[p+4>>2]=f),(m|0)<=(n|0)){u=37;break}}if((u|0)==19)E(27634,27225,1407,27259);else if((u|0)==37){s=r,a=i[s+4>>2]|0,s=i[s>>2]|0;break}else if((u|0)==42)return M=y,a|0}else a=0,s=0}else u=33;while(0);c:do if((u|0)==33)if(h=r,i[h>>2]=0,i[h+4>>2]=0,(v|0)>(n|0)){for(o=v;;){if(a=z(e|0,t|0,(15-o|0)*3|0)|0,T()|0,a&=7,(a|0)==7){a=5;break}if(s=v-o|0,s=vn(7,0,s,((s|0)<0)<<31>>31)|0,a=gr(s|0,T()|0,a|0,0)|0,s=T()|0,h=r,s=ur(i[h>>2]|0,i[h+4>>2]|0,a|0,s|0)|0,a=T()|0,h=r,i[h>>2]=s,i[h+4>>2]=a,o=o+-1|0,(o|0)<=(n|0))break c}return M=y,a|0}else a=0,s=0;while(0);return bt(g,c,v,_)|0&&E(27634,27225,1367,27274),v=_,_=i[v+4>>2]|0,((a|0)>-1|(a|0)==-1&s>>>0>4294967295)&((_|0)>(a|0)|((_|0)==(a|0)?(i[v>>2]|0)>>>0>s>>>0:0))?(v=0,M=y,v|0):(E(27634,27225,1447,27259),0)}function Wt(e,t,n,r,a,o){e|=0,t|=0,n|=0,r|=0,a|=0,o|=0;var s=0,c=0,l=0,u=0,d=0,f=0,p=0,m=0,h=0,g=0;if(f=M,M=M+16|0,s=f,a>>>0>15)return o=4,M=f,o|0;if(c=z(n|0,r|0,52)|0,T()|0,c&=15,(c|0)>(a|0))return o=12,M=f,o|0;if(bt(n,r,a,s)|0&&E(27634,27225,1367,27274),d=s,u=i[d+4>>2]|0,!(((t|0)>-1|(t|0)==-1&e>>>0>4294967295)&((u|0)>(t|0)|((u|0)==(t|0)?(i[d>>2]|0)>>>0>e>>>0:0))))return o=2,M=f,o|0;d=a-c|0,a=B(a|0,0,52)|0,l=T()|0|r&-15728641,u=o,i[u>>2]=a|n,i[u+4>>2]=l,u=z(n|0,r|0,45)|0,T()|0;a:do if(Se(u&127)|0){if(c|0)for(s=1;;){if(u=B(7,0,(15-s|0)*3|0)|0,!((u&n|0)==0&((T()|0)&r|0)==0))break a;if(s>>>0>>0)s=s+1|0;else break}if((d|0)<1)return o=0,M=f,o|0;for(u=c^15,r=-1,l=1,s=1;;){c=d-l|0,c=vn(7,0,c,((c|0)<0)<<31>>31)|0,n=T()|0;do if(s)if(s=gr(c|0,n|0,5,0)|0,s=ur(s|0,T()|0,-5,-1)|0,s=mr(s|0,T()|0,6,0)|0,a=T()|0,(t|0)>(a|0)|(t|0)==(a|0)&e>>>0>s>>>0){t=ur(e|0,t|0,-1,-1)|0,t=dr(t|0,T()|0,s|0,a|0)|0,s=T()|0,p=o,h=i[p>>2]|0,p=i[p+4>>2]|0,g=(u+r|0)*3|0,m=B(7,0,g|0)|0,p&=~(T()|0),r=mr(t|0,s|0,c|0,n|0)|0,e=T()|0,a=ur(r|0,e|0,2,0)|0,g=B(a|0,T()|0,g|0)|0,p=T()|0|p,a=o,i[a>>2]=g|h&~m,i[a+4>>2]=p,e=gr(r|0,e|0,c|0,n|0)|0,e=dr(t|0,s|0,e|0,T()|0)|0,s=0,t=T()|0;break}else{g=o,m=i[g>>2]|0,g=i[g+4>>2]|0,h=B(7,0,(u+r|0)*3|0)|0,g&=~(T()|0),s=o,i[s>>2]=m&~h,i[s+4>>2]=g,s=1;break}else m=o,a=i[m>>2]|0,m=i[m+4>>2]|0,r=(u+r|0)*3|0,p=B(7,0,r|0)|0,m&=~(T()|0),g=mr(e|0,t|0,c|0,n|0)|0,s=T()|0,r=B(g|0,s|0,r|0)|0,m=T()|0|m,h=o,i[h>>2]=r|a&~p,i[h+4>>2]=m,s=gr(g|0,s|0,c|0,n|0)|0,e=dr(e|0,t|0,s|0,T()|0)|0,s=0,t=T()|0;while(0);if((d|0)>(l|0))r=~l,l=l+1|0;else{t=0;break}}return M=f,t|0}while(0);if((d|0)<1)return g=0,M=f,g|0;for(a=c^15,s=1;;)if(h=d-s|0,h=vn(7,0,h,((h|0)<0)<<31>>31)|0,g=T()|0,l=o,n=i[l>>2]|0,l=i[l+4>>2]|0,c=(a-s|0)*3|0,r=B(7,0,c|0)|0,l&=~(T()|0),p=mr(e|0,t|0,h|0,g|0)|0,m=T()|0,c=B(p|0,m|0,c|0)|0,l=T()|0|l,u=o,i[u>>2]=c|n&~r,i[u+4>>2]=l,g=gr(p|0,m|0,h|0,g|0)|0,e=dr(e|0,t|0,g|0,T()|0)|0,t=T()|0,(d|0)<=(s|0)){t=0;break}else s=s+1|0;return M=f,t|0}function Gt(e,t,n,r){e|=0,t|=0,n|=0,r|=0;var a=0,o=0,s=0;a=z(t|0,n|0,52)|0,T()|0,a&=15,(t|0)==0&(n|0)==0|((r|0)>15|(a|0)>(r|0))?(o=-1,t=-1,n=0,a=0):(t=Ct(t,n,a+1|0,r)|0,s=(T()|0)&-15728641,n=B(r|0,0,52)|0,n=t|n,s|=T()|0,t=(xt(n,s)|0)==0,o=a,t=t?-1:r,a=s),s=e,i[s>>2]=n,i[s+4>>2]=a,i[e+8>>2]=o,i[e+12>>2]=t}function Kt(e,t,n,r){e|=0,t|=0,n|=0,r|=0;var a=0,o=0;if(a=z(e|0,t|0,52)|0,T()|0,a&=15,o=r+8|0,i[o>>2]=a,(e|0)==0&(t|0)==0|((n|0)>15|(a|0)>(n|0))){n=r,i[n>>2]=0,i[n+4>>2]=0,i[o>>2]=-1,i[r+12>>2]=-1;return}if(e=Ct(e,t,a+1|0,n)|0,o=(T()|0)&-15728641,a=B(n|0,0,52)|0,a=e|a,o|=T()|0,e=r,i[e>>2]=a,i[e+4>>2]=o,e=r+12|0,xt(a,o)|0){i[e>>2]=n;return}else{i[e>>2]=-1;return}}function qt(e){e|=0;var t=0,n=0,r=0,a=0,o=0,s=0,c=0,l=0,u=0;if(n=e,t=i[n>>2]|0,n=i[n+4>>2]|0,!((t|0)==0&(n|0)==0)&&(r=z(t|0,n|0,52)|0,T()|0,r&=15,c=B(1,0,(r^15)*3|0)|0,t=ur(c|0,T()|0,t|0,n|0)|0,n=T()|0,c=e,i[c>>2]=t,i[c+4>>2]=n,c=e+8|0,s=i[c>>2]|0,!((r|0)<(s|0)))){for(l=e+12|0,o=r;;){if((o|0)==(s|0)){r=5;break}if(u=(o|0)==(i[l>>2]|0),a=(15-o|0)*3|0,r=z(t|0,n|0,a|0)|0,T()|0,r&=7,u&((r|0)==1&!0)){r=7;break}if(!((r|0)==7&!0)){r=10;break}if(u=B(1,0,a|0)|0,t=ur(t|0,n|0,u|0,T()|0)|0,n=T()|0,u=e,i[u>>2]=t,i[u+4>>2]=n,(o|0)>(s|0))o=o+-1|0;else{r=10;break}}if((r|0)==5){u=e,i[u>>2]=0,i[u+4>>2]=0,i[c>>2]=-1,i[l>>2]=-1;return}else if((r|0)==7){s=B(1,0,a|0)|0,s=ur(t|0,n|0,s|0,T()|0)|0,c=T()|0,u=e,i[u>>2]=s,i[u+4>>2]=c,i[l>>2]=o+-1;return}else if((r|0)==10)return}}function Jt(e){e=+e;var t=0;return t=e<0?e+6.283185307179586:e,+(e>=6.283185307179586?t+-6.283185307179586:t)}function Yt(e,t){switch(e=+e,t|=0,t|0){case 1:e=e<0?e+6.283185307179586:e;break;case 2:e=e>0?e+-6.283185307179586:e;break;default:}return+e}function Xt(e,t){e|=0,t|=0;var n=0,r=0,i=0,o=0;return i=+a[t>>3],r=+a[e>>3],o=+f(+((i-r)*.5)),n=+f(+((a[t+8>>3]-+a[e+8>>3])*.5)),n=o*o+n*(d(+i)*+d(+r)*n),+(_(+ +u(+n),+ +u(+(1-n)))*2)}function Zt(e,t){e|=0,t|=0;var n=0,r=0,i=0,o=0;return i=+a[t>>3],r=+a[e>>3],o=+f(+((i-r)*.5)),n=+f(+((a[t+8>>3]-+a[e+8>>3])*.5)),n=o*o+n*(d(+i)*+d(+r)*n),+(_(+ +u(+n),+ +u(+(1-n)))*2*6371.007180918475)}function Qt(e,t){e|=0,t|=0;var n=0,r=0,i=0,o=0;return i=+a[t>>3],r=+a[e>>3],o=+f(+((i-r)*.5)),n=+f(+((a[t+8>>3]-+a[e+8>>3])*.5)),n=o*o+n*(d(+i)*+d(+r)*n),+(_(+ +u(+n),+ +u(+(1-n)))*2*6371.007180918475*1e3)}function $t(e,t){return e|=0,t|=0,e>>>0>15?(t=4,t|0):(a[t>>3]=+a[20624+(e<<3)>>3],t=0,t|0)}function en(e,t){return e|=0,t|=0,e>>>0>15?(t=4,t|0):(a[t>>3]=+a[20752+(e<<3)>>3],t=0,t|0)}function tn(e,t){return e|=0,t|=0,e>>>0>15?(t=4,t|0):(a[t>>3]=+a[20880+(e<<3)>>3],t=0,t|0)}function nn(e,t){return e|=0,t|=0,e>>>0>15?(t=4,t|0):(a[t>>3]=+a[21008+(e<<3)>>3],t=0,t|0)}function rn(e,t){e|=0,t|=0;var n=0;return e>>>0>15?(t=4,t|0):(n=vn(7,0,e,((e|0)<0)<<31>>31)|0,n=gr(n|0,T()|0,120,0)|0,e=T()|0,i[t>>2]=n|2,i[t+4>>2]=e,t=0,t|0)}function an(e,t,n){e|=0,t|=0,n|=0;var r=0,o=0,s=0,c=0,l=0,p=0,m=0,h=0;if(l=M,M=M+176|0,c=l,e=tt(e,t,c)|0,e|0)return c=e,M=l,c|0;if(a[n>>3]=0,e=i[c>>2]|0,(e|0)<=1)return c=0,M=l,c|0;t=e+-1|0,e=0,r=+a[c+8>>3],o=+a[c+16>>3],s=0;do e=e+1|0,m=r,r=+a[c+8+(e<<4)>>3],h=+f(+((r-m)*.5)),p=o,o=+a[c+8+(e<<4)+8>>3],p=+f(+((o-p)*.5)),p=h*h+p*(d(+r)*+d(+m)*p),s+=_(+ +u(+p),+ +u(+(1-p)))*2;while((e|0)<(t|0));return a[n>>3]=s,c=0,M=l,c|0}function on(e,t,n){e|=0,t|=0,n|=0;var r=0,o=0,s=0,c=0,l=0,p=0,m=0,h=0;if(l=M,M=M+176|0,c=l,e=tt(e,t,c)|0,e|0)return c=e,s=+a[n>>3],s*=6371.007180918475,a[n>>3]=s,M=l,c|0;if(a[n>>3]=0,e=i[c>>2]|0,(e|0)<=1)return c=0,s=0,s*=6371.007180918475,a[n>>3]=s,M=l,c|0;t=e+-1|0,e=0,r=+a[c+8>>3],o=+a[c+16>>3],s=0;do e=e+1|0,m=r,r=+a[c+8+(e<<4)>>3],h=+f(+((r-m)*.5)),p=o,o=+a[c+8+(e<<4)+8>>3],p=+f(+((o-p)*.5)),p=h*h+p*(d(+m)*+d(+r)*p),s+=_(+ +u(+p),+ +u(+(1-p)))*2;while((e|0)!=(t|0));return a[n>>3]=s,c=0,h=s,h*=6371.007180918475,a[n>>3]=h,M=l,c|0}function sn(e,t,n){e|=0,t|=0,n|=0;var r=0,o=0,s=0,c=0,l=0,p=0,m=0,h=0;if(l=M,M=M+176|0,c=l,e=tt(e,t,c)|0,e|0)return c=e,s=+a[n>>3],s*=6371.007180918475,s*=1e3,a[n>>3]=s,M=l,c|0;if(a[n>>3]=0,e=i[c>>2]|0,(e|0)<=1)return c=0,s=0,s*=6371.007180918475,s*=1e3,a[n>>3]=s,M=l,c|0;t=e+-1|0,e=0,r=+a[c+8>>3],o=+a[c+16>>3],s=0;do e=e+1|0,m=r,r=+a[c+8+(e<<4)>>3],h=+f(+((r-m)*.5)),p=o,o=+a[c+8+(e<<4)+8>>3],p=+f(+((o-p)*.5)),p=h*h+p*(d(+m)*+d(+r)*p),s+=_(+ +u(+p),+ +u(+(1-p)))*2;while((e|0)!=(t|0));return a[n>>3]=s,c=0,h=s,h*=6371.007180918475,h*=1e3,a[n>>3]=h,M=l,c|0}function cn(e){e|=0;var t=0,n=0,r=0,a=0,o=0,s=0,c=0;if(e)for(o=e+4|0,s=e+8|0,r=1,a=e;;){if(t=i[a>>2]|0,t|0)do{if(n=i[t>>2]|0,n|0)do c=n,n=i[n+16>>2]|0,ar(c);while(n|0);c=t,t=i[t+8>>2]|0,ar(c)}while(t|0);if(t=a,a=i[a+8>>2]|0,r?(i[e>>2]=0,i[o>>2]=0,i[s>>2]=0):ar(t),a)r=0;else break}}function ln(e,t){e|=0,t|=0;var n=0,r=0,a=0,o=0,s=0,c=0,l=0,u=0,d=0,f=0,p=0,m=0,h=0,g=0,_=0,v=0;if(i[t>>2]=0,_=t+4|0,i[_>>2]=0,v=t+8|0,i[v>>2]=0,g=i[e>>2]|0,(g|0)<=0)return t=0,t|0;h=e+4|0,e=t,m=0;a:for(;;){if(m){if(n=or(1,12)|0,!n){n=5;break}i[e+8>>2]=n,e=n}if(l=i[h>>2]|0,u=or(1,12)|0,!u){e=13,n=37;break}if(p=e+4|0,r=i[p>>2]|0,i[(r|0?r+8|0:e)>>2]=u,i[p>>2]=u,r=i[l+(m<<4)>>2]|0,(r|0)<3){e=1,n=37;break}a=l+(m<<4)+4|0,o=u+4|0,n=0,s=0;do{if(c=s,s=ir(24)|0,!s){e=13,n=37;break a}Tr(s|0,(i[a>>2]|0)+(n<<4)|0,16)|0,i[s+16>>2]=0,c?i[c+16>>2]=s:i[u>>2]=s,i[o>>2]=s,n=n+1|0}while((n|0)<(r|0));if(f=i[l+(m<<4)+8>>2]|0,(f|0)>0){d=l+(m<<4)+12|0,l=0;do{if(r=i[d>>2]|0,n=u,u=or(1,12)|0,!u){e=13,n=37;break a}if(i[n+8>>2]=u,i[p>>2]=u,c=i[r+(l<<3)>>2]|0,(c|0)<3){e=1,n=37;break a}r=r+(l<<3)+4|0,a=u+4|0,n=0,o=0;do{if(s=o,o=ir(24)|0,!o){e=13,n=37;break a}Tr(o|0,(i[r>>2]|0)+(n<<4)|0,16)|0,i[o+16>>2]=0,s?i[s+16>>2]=o:i[u>>2]=o,i[a>>2]=o,n=n+1|0}while((n|0)<(c|0));l=l+1|0}while((l|0)<(f|0))}if(m=m+1|0,(m|0)>=(g|0)){e=0,n=50;break}}if((n|0)==5){if(!t)return t=13,t|0;for(r=1,a=t;;){if(e=i[a>>2]|0,e|0)do{if(n=i[e>>2]|0,n|0)do g=n,n=i[n+16>>2]|0,ar(g);while(n|0);g=e,e=i[e+8>>2]|0,ar(g)}while(e|0);if(e=a,a=i[a+8>>2]|0,r?(i[t>>2]=0,i[_>>2]=0,i[v>>2]=0):ar(e),a)r=0;else{e=13;break}}return e|0}else if((n|0)==37){if(!t)return t=e,t|0;for(a=1,o=t;;){if(n=i[o>>2]|0,n|0)do{if(r=i[n>>2]|0,r|0)do g=r,r=i[r+16>>2]|0,ar(g);while(r|0);g=n,n=i[n+8>>2]|0,ar(g)}while(n|0);if(n=o,o=i[o+8>>2]|0,a?(i[t>>2]=0,i[_>>2]=0,i[v>>2]=0):ar(n),o)a=0;else break}return e|0}else if((n|0)==50)return e|0;return 0}function un(e,t,n,a,o){e|=0,t|=0,n|=0,a|=0,o|=0;var s=0,c=0,l=0,u=0,d=0,f=0,p=0,m=0,h=0,g=0,_=0,v=0,y=0,b=0;if(y=M,M=M+16|0,v=y,f=z(e|0,t|0,52)|0,T()|0,f&=15,h=z(n|0,a|0,52)|0,T()|0,(f|0)!=(h&15|0))return v=12,M=y,v|0;if(u=z(e|0,t|0,45)|0,T()|0,u&=127,d=z(n|0,a|0,45)|0,T()|0,d&=127,u>>>0>121|d>>>0>121)return v=5,M=y,v|0;if(h=(u|0)!=(d|0),h){if(c=Ae(u,d)|0,(c|0)==7)return v=1,M=y,v|0;l=Ae(d,u)|0,(l|0)==7?E(27291,27315,164,27325):(_=c,s=l)}else _=0,s=0;p=Se(u)|0,m=Se(d)|0,i[v>>2]=0,i[v+4>>2]=0,i[v+8>>2]=0,i[v+12>>2]=0;do if(_){d=i[4272+(u*28|0)+(_<<2)>>2]|0,c=(d|0)>0;a:do if(m)if(c)for(u=0,l=n,c=a;;){switch(l=Mt(l,c)|0,c=T()|0,s|0){case 5:case 1:s=3;break;case 3:s=2;break;case 2:s=6;break;case 6:s=4;break;case 4:s=5;break;default:}if(u=u+1|0,(u|0)==(d|0)){d=s,u=l,l=c;break a}}else d=s,u=n,l=a;else if(c)for(u=0,l=n,c=a;;){switch(l=Nt(l,c)|0,c=T()|0,s|0){case 1:s=3;break;case 3:s=2;break;case 2:s=6;break;case 6:s=4;break;case 4:s=5;break;case 5:s=1;break;default:}if(u=u+1|0,(u|0)==(d|0)){d=s,u=l,l=c;break a}}else d=s,u=n,l=a;while(0);if(Lt(u,l,v)|0,h||E(27340,27315,194,27325),c=(p|0)!=0,s=(m|0)!=0,c&s&&E(27367,27315,195,27325),c){if(s=kt(e,t)|0,(s|0)==7){s=5;break}if(r[21968+(s*7|0)+_>>0]|0){s=1;break}m=i[21136+(s*28|0)+(_<<2)>>2]|0,h=m}else if(s){if(s=kt(u,l)|0,(s|0)==7){s=5;break}if(r[21968+(s*7|0)+d>>0]|0){s=1;break}h=0,m=i[21136+(d*28|0)+(s<<2)>>2]|0}else h=0,m=0;if((h|m|0)>=0){if((m|0)>0){n=v+4|0,a=v+8|0,p=v+12|0,d=0,l=i[n>>2]|0,c=i[a>>2]|0,s=i[p>>2]|0;do g=c+l|0,t=(g|0)<0,b=t?g:0,c=s+c-b|0,e=(c|0)<0,u=e?c:0,l=s+l-b-u|0,b=(l|0)<0,s=b?0:l,l=b?l:0,c=(e?0:c)-l|0,l=(t?0:g)-u-l|0,u=(c|0)<(l|0)?c:l,u=(s|0)<(u|0)?s:u,(u|0)>0&&(l=l-u|0,c=c-u|0,s=s-u|0),d=d+1|0;while((d|0)!=(m|0));i[n>>2]=l,i[a>>2]=c,i[p>>2]=s}if((_+-1|0)>>>0<6?(s=i[22032+(_*12|0)>>2]|0,l=i[22032+(_*12|0)+4>>2]|0,b=i[22032+(_*12|0)+8>>2]|0,c=(l|0)<(s|0)?l:s,c=(b|0)<(c|0)?b:c,c=(c|0)>0?c:0,s=s-c|0,l=l-c|0,c=b-c|0):(s=0,l=0,c=0),f)for(;;)if(u=s*3|0,d=l*3|0,n=c*3|0,Ft(f)|0?(t=u+l|0,e=(t|0)<0,b=d+c-(e?t:0)|0,g=(b|0)<0,l=s+n-(e?t:0)-(g?b:0)|0,c=(l|0)<0,_=c?0:l,u=(g?0:b)-(c?l:0)|0,l=(e?0:t)-(g?b:0)-(c?l:0)|0,c=(u|0)<(l|0)?u:l,c=(_|0)<(c|0)?_:c,b=(c|0)>0,s=b?c:0,u=u-(b?c:0)|0,c=_-(b?c:0)|0):(g=u+c|0,t=(g|0)<0,b=d+s-(t?g:0)|0,s=(b|0)<0,l=n+l-(t?g:0)-(s?b:0)|0,c=(l|0)<0,_=c?0:l,u=(s?0:b)-(c?l:0)|0,l=(t?0:g)-(s?b:0)-(c?l:0)|0,c=(u|0)<(l|0)?u:l,c=(_|0)<(c|0)?_:c,b=(c|0)>0,s=b?c:0,u=u-(b?c:0)|0,c=_-(b?c:0)|0),s=l-s|0,(f|0)>1)f=f+-1|0,l=u;else{l=u;break}if((h|0)>0){u=0;do t=s+l|0,e=(t|0)<0,b=l+c-(e?t:0)|0,g=(b|0)<0,_=s+c-(e?t:0)-(g?b:0)|0,s=(_|0)<0,c=s?0:_,l=(g?0:b)-(s?_:0)|0,_=(e?0:t)-(g?b:0)-(s?_:0)|0,s=(l|0)<(_|0)?l:_,s=(c|0)<(s|0)?c:s,b=(s|0)>0,c=c-(b?s:0)|0,l=l-(b?s:0)|0,s=_-(b?s:0)|0,u=u+1|0;while((u|0)!=(h|0))}n=v+4|0,f=v+8|0,_=i[f>>2]|0,a=v+12|0,b=i[a>>2]|0,u=(i[n>>2]|0)+s|0,i[n>>2]=u,l=_+l|0,i[f>>2]=l,s=b+c|0,i[a>>2]=s,c=l-u|0,(u|0)<0?(s=s-u|0,i[f>>2]=c,i[a>>2]=s,i[n>>2]=0,l=0):(c=l,l=u),(c|0)<0&&(l=l-c|0,i[n>>2]=l,s=s-c|0,i[a>>2]=s,i[f>>2]=0,c=0),d=l-s|0,u=c-s|0,(s|0)<0?(i[n>>2]=d,i[f>>2]=u,i[a>>2]=0,l=d,s=0):u=c,c=(u|0)<(l|0)?u:l,c=(s|0)<(c|0)?s:c,(c|0)>0?(i[n>>2]=l-c,i[f>>2]=u-c,i[a>>2]=s-c,g=77):g=77}else s=5}else if(Lt(n,a,v)|0,(p|0)!=0&(m|0)!=0)if((d|0)!=(u|0)&&E(27398,27315,264,27325),c=kt(e,t)|0,s=kt(n,a)|0,(c|0)==7|(s|0)==7)s=5;else if(r[21968+(c*7|0)+s>>0]|0)s=1;else if(n=i[21136+(c*28|0)+(s<<2)>>2]|0,(n|0)>0){f=v+4|0,a=v+8|0,p=v+12|0,d=0,l=i[f>>2]|0,c=i[a>>2]|0,s=i[p>>2]|0;do _=c+l|0,g=(_|0)<0,e=g?_:0,c=s+c-e|0,t=(c|0)<0,u=t?c:0,l=s+l-e-u|0,e=(l|0)<0,s=e?0:l,l=e?l:0,c=(t?0:c)-l|0,l=(g?0:_)-u-l|0,u=(c|0)<(l|0)?c:l,u=(s|0)<(u|0)?s:u,(u|0)>0&&(l=l-u|0,c=c-u|0,s=s-u|0),d=d+1|0;while((d|0)!=(n|0));i[f>>2]=l,i[a>>2]=c,i[p>>2]=s,g=77}else g=77;else g=77;while(0);return(g|0)==77&&(s=v+4|0,i[o>>2]=i[s>>2],i[o+4>>2]=i[s+4>>2],i[o+8>>2]=i[s+8>>2],s=0),b=s,M=y,b|0}function dn(e,t,n,r){e|=0,t|=0,n|=0,r|=0;var a=0,o=0,s=0,c=0,l=0,u=0,d=0,f=0,p=0,m=0,h=0,g=0,_=0,v=0,y=0,b=0,x=0,S=0,C=0,w=0,D=0;if(o=z(e|0,t|0,52)|0,T()|0,o&=15,x=z(e|0,t|0,45)|0,T()|0,x&=127,x>>>0>121)return r=5,r|0;if(_=Se(x)|0,B(o|0,0,52)|0,c=T()|134225919,s=r,i[s>>2]=-1,i[s+4>>2]=c,s=i[n>>2]|0,c=i[n+4>>2]|0,n=i[n+8>>2]|0,!o){t=(s|0)<0,v=t?s:0,b=c-v|0,_=(b|0)<0,v=(_?0-b|0:0)+(n-v)|0,n=(v|0)<0,a=n?0:v,v=n?v:0,n=(_?0:b)-v|0,v=(t?0:s)-(_?b:0)-v|0,b=(n|0)<(v|0)?n:v,b=(a|0)<(b|0)?a:b,b=(b|0)>0?b:0,a=a-b|0,n=n-b|0;a:do switch(v-b|0){case 0:switch(n|0){case 0:if(a){a=(a|0)==1?1:7,y=11;break a}else{a=0;break a}case 1:if(a){a=(a|0)==1?3:7,y=11;break a}else{a=2;break a}default:return r=1,r|0}case 1:switch(n|0){case 0:if(a){a=(a|0)==1?5:7,y=11;break a}else{a=4;break a}case 1:if(a)a=1;else{a=6;break a}return a|0;default:return r=1,r|0}default:return r=1,r|0}while(0);return(y|0)==11&&(a|0)==7||(a=ke(x,a)|0,(a|0)==127)?(r=1,r|0):(b=B(a|0,0,45)|0,x=T()|0,y=r,x=i[y+4>>2]&-1040385|x,i[r>>2]=i[y>>2]|b,i[r+4>>2]=x,r=0,r|0)}for(;;){if(g=o,o=o+-1|0,h=s-n|0,m=c-n|0,l=h>>>0>715827881|m>>>0>715827881,Ft(g)|0){if(l){if(d=(h|0)>0,f=2147483647-h|0,p=-2147483648-h|0,d?(f|0)<(h|0):(p|0)>(h|0)){a=1,y=107;break}if(D=h<<1,d?(2147483647-D|0)<(h|0):(-2147483648-D|0)>(h|0)){a=1,y=107;break}if((m|0)>0?(2147483647-m|0)<(m|0):(-2147483648-m|0)>(m|0)){a=1,y=107;break}if(l=h*3|0,u=m<<1,(d?(f|0)<(u|0):(p|0)>(u|0))||((h|0)>-1?(l|-2147483648)>=(m|0):(l^-2147483648|0)<(m|0))){a=1,y=107;break}}else l=h*3|0,u=m<<1;if(f=rr((l-m|0)*.14285714285714285)|0,d=rr((u+h|0)*.14285714285714285)|0,u=(d|0)<(f|0),l=u?f:d,u=u?d:f,(u|0)<0){if((u|0)==-2147483648||((l|0)>0?(2147483647-l|0)<(u|0):(-2147483648-l|0)>(u|0))){y=24;break}if((l|0)>-1?(l|-2147483648)>=(u|0):(l^-2147483648|0)<(u|0)){y=24;break}}p=(f|0)<0,m=d-(p?f:0)|0,C=(m|0)<0,S=(p?0-f|0:0)-(C?m:0)|0,h=(S|0)<0,p=(p?0:f)-(C?m:0)-(h?S:0)|0,m=(C?0:m)-(h?S:0)|0,S=h?0:S,h=(m|0)<(p|0)?m:p,h=(S|0)<(h|0)?S:h,C=(h|0)>0,p=p-(C?h:0)|0,m=m-(C?h:0)|0,h=S-(C?h:0)|0,C=(p*3|0)+m|0,S=(C|0)<0,D=(m*3|0)+h-(S?C:0)|0,l=(D|0)<0,f=(h*3|0)+p-(S?C:0)-(l?D:0)|0,d=(f|0)<0,w=d?0:f,u=(l?0:D)-(d?f:0)|0,f=(S?0:C)-(l?D:0)-(d?f:0)|0,d=(u|0)<(f|0)?u:f,d=(w|0)<(d|0)?w:d,D=(d|0)>0,l=D?d:0,u=u-(D?d:0)|0,d=w-(D?d:0)|0}else{if(l){if(u=(h|0)>0,u?(2147483647-h|0)<(h|0):(-2147483648-h|0)>(h|0)){a=1,y=107;break}if(l=h<<1,d=(m|0)>0,d?(2147483647-m|0)<(m|0):(-2147483648-m|0)>(m|0)){a=1,y=107;break}if(p=m<<1,d?(2147483647-p|0)<(m|0):(-2147483648-p|0)>(m|0)){a=1,y=107;break}if(u?(2147483647-l|0)<(m|0):(-2147483648-l|0)>(m|0)){a=1,y=107;break}if(u=m*3|0,(m|0)>-1?(u|-2147483648)>=(h|0):(u^-2147483648|0)<(h|0)){a=1,y=107;break}}else l=h<<1,u=m*3|0;if(f=rr((l+m|0)*.14285714285714285)|0,d=rr((u-h|0)*.14285714285714285)|0,u=(d|0)<(f|0),l=u?f:d,u=u?d:f,(u|0)<0){if((u|0)==-2147483648||((l|0)>0?(2147483647-l|0)<(u|0):(-2147483648-l|0)>(u|0))){y=36;break}if((l|0)>-1?(l|-2147483648)>=(u|0):(l^-2147483648|0)<(u|0)){y=36;break}}p=(f|0)<0,m=d-(p?f:0)|0,w=(m|0)<0,D=(p?0-f|0:0)-(w?m:0)|0,h=(D|0)<0,p=(p?0:f)-(w?m:0)-(h?D:0)|0,m=(w?0:m)-(h?D:0)|0,D=h?0:D,h=(m|0)<(p|0)?m:p,h=(D|0)<(h|0)?D:h,w=(h|0)>0,p=p-(w?h:0)|0,m=m-(w?h:0)|0,h=D-(w?h:0)|0,w=(p*3|0)+h|0,D=(w|0)<0,S=(m*3|0)+p-(D?w:0)|0,l=(S|0)<0,f=(h*3|0)+m-(D?w:0)-(l?S:0)|0,d=(f|0)<0,C=d?0:f,u=(l?0:S)-(d?f:0)|0,f=(D?0:w)-(l?S:0)-(d?f:0)|0,d=(u|0)<(f|0)?u:f,d=(C|0)<(d|0)?C:d,S=(d|0)>0,l=S?d:0,u=u-(S?d:0)|0,d=C-(S?d:0)|0}l=s+(l-f)|0,w=(l|0)<0,u=c-u-(w?l:0)|0,f=(u|0)<0,S=n-d+(w?0-l|0:0)+(f?0-u|0:0)|0,s=(S|0)<0,d=s?0:S,D=(f?0:u)-(s?S:0)|0,S=(w?0:l)-(f?u:0)-(s?S:0)|0,s=(D|0)<(S|0)?D:S,s=(d|0)<(s|0)?d:s,n=(s|0)>0,S=S-(n?s:0)|0,u=r,f=i[u>>2]|0,u=i[u+4>>2]|0,c=(15-g|0)*3|0,l=B(7,0,c|0)|0,l=f&~l,u&=~(T()|0),f=(S|0)<0,w=f?S:0,D=D-(n?s:0)-w|0,C=(D|0)<0,w=(C?0-D|0:0)+(d-(n?s:0)-w)|0,s=(w|0)<0,n=s?0:w,w=s?w:0,s=(C?0:D)-w|0,w=(f?0:S)-(C?D:0)-w|0,D=(s|0)<(w|0)?s:w,D=(n|0)<(D|0)?n:D,D=(D|0)>0?D:0,n=n-D|0,s=s-D|0;b:do switch(w-D|0){case 0:switch(s|0){case 0:n=n|0?(n|0)==1?1:7:0;break b;case 1:n=n|0?(n|0)==1?3:7:2;break b;default:y=45;break b}case 1:switch(s|0){case 0:n=n|0?(n|0)==1?5:7:4;break b;case 1:if(n){y=45;break b}else{n=6;break b}default:y=45;break b}default:y=45}while(0);if((y|0)==45&&(y=0,n=7),C=B(n|0,0,c|0)|0,w=T()|0|u,D=r,i[D>>2]=C|l,i[D+4>>2]=w,(g|0)<=1){y=47;break}else s=p,c=m,n=h}if((y|0)==24)E(27634,27425,416,27447);else if((y|0)==36)E(27634,27425,464,27461);else if((y|0)==47){if((p|0)>1|(m|0)>1|(h|0)>1)return D=1,D|0;S=(p|0)<0,w=S?p:0,D=m-w|0,C=(D|0)<0,w=(C?0-D|0:0)+(h-w)|0,o=(w|0)<0,n=o?0:w,w=o?w:0,o=(C?0:D)-w|0,w=(S?0:p)-(C?D:0)-w|0,D=(o|0)<(w|0)?o:w,D=(n|0)<(D|0)?n:D,D=(D|0)>0?D:0,n=n-D|0,o=o-D|0;c:do switch(w-D|0){case 0:switch(o|0){case 0:o=n|0?(n|0)==1?1:7:0;break c;case 1:o=n|0?(n|0)==1?3:7:2;break c;default:y=55;break c}case 1:switch(o|0){case 0:o=n|0?(n|0)==1?5:7:4;break c;case 1:if(n){y=55;break c}else{o=6;break c}default:y=55;break c}default:y=55}while(0);(y|0)==55&&(o=7),c=ke(x,o)|0,u=(c|0)==127?0:Se(c)|0;d:do if(o){if(_){if(n=kt(e,t)|0,(n|0)==7)return D=5,D|0;s=i[21344+(n*28|0)+(o<<2)>>2]|0;e:do if((s|0)>0)for(n=o,o=0;;){switch(n|0){case 1:n=5;break;case 5:n=4;break;case 4:n=6;break;case 6:n=2;break;case 2:n=3;break;case 3:n=1;break;default:}if(o=o+1|0,(o|0)==(s|0))break e}else n=o;while(0);if((n|0)==1)return D=9,D|0;o=ke(x,n)|0,(o|0)==127&&E(27476,27315,415,27506),Se(o)|0?E(27521,27315,416,27506):(a=o,b=s,v=n)}else a=c,b=0,v=o;if(l=i[4272+(x*28|0)+(v<<2)>>2]|0,(l|0)<=-1&&E(27552,27315,423,27506),!u){if((b|0)<0)return D=5,D|0;if(b|0){s=r,n=0,o=i[s>>2]|0,s=i[s+4>>2]|0;do o=jt(o,s)|0,s=T()|0,D=r,i[D>>2]=o,i[D+4>>2]=s,n=n+1|0;while((n|0)<(b|0))}if((l|0)<=0){y=104;break}for(s=r,n=0,o=i[s>>2]|0,s=i[s+4>>2]|0;;)if(o=jt(o,s)|0,s=T()|0,D=r,i[D>>2]=o,i[D+4>>2]=s,n=n+1|0,(n|0)==(l|0)){y=104;break d}}if(c=Ae(a,x)|0,(c|0)==7&&E(27291,27315,432,27506),n=r,o=i[n>>2]|0,n=i[n+4>>2]|0,(l|0)>0){s=0;do o=jt(o,n)|0,n=T()|0,D=r,i[D>>2]=o,i[D+4>>2]=n,s=s+1|0;while((s|0)!=(l|0))}if(n=kt(o,n)|0,(n|0)==7&&E(27634,27315,444,27506),o=Ce(a)|0,o=i[(o?21760:21552)+(c*28|0)+(n<<2)>>2]|0,(o|0)<0&&E(27634,27315,458,27506),!o)y=104;else{c=r,n=0,s=i[c>>2]|0,c=i[c+4>>2]|0;do s=At(s,c)|0,c=T()|0,D=r,i[D>>2]=s,i[D+4>>2]=c,n=n+1|0;while((n|0)<(o|0));y=104}}else if((_|0)!=0&(u|0)!=0){if(a=kt(e,t)|0,n=r,n=kt(i[n>>2]|0,i[n+4>>2]|0)|0,(a|0)==7|(n|0)==7||(n=i[21344+(a*28|0)+(n<<2)>>2]|0,(n|0)<0))return D=5,D|0;if(!n)a=c,y=105;else{s=r,a=0,o=i[s>>2]|0,s=i[s+4>>2]|0;do o=jt(o,s)|0,s=T()|0,D=r,i[D>>2]=o,i[D+4>>2]=s,a=a+1|0;while((a|0)<(n|0));a=c,y=104}}else a=c,y=104;while(0);return(y|0)==104&&u&&(y=105),(y|0)==105&&(D=r,(kt(i[D>>2]|0,i[D+4>>2]|0)|0)==1)?(D=9,D|0):(w=r,S=i[w>>2]|0,w=i[w+4>>2]&-1040385,C=B(a|0,0,45)|0,w|=T()|0,D=r,i[D>>2]=S|C,i[D+4>>2]=w,D=0,D|0)}else if((y|0)==107)return a|0;return 0}function fn(e,t,n,r,a,o){e|=0,t|=0,n|=0,r|=0,a|=0,o|=0;var s=0,c=0;return c=M,M=M+16|0,s=c,a|0?(s=15,M=c,s|0):(e=un(e,t,n,r,s)|0,e||=(a=i[s+4>>2]|0,e=i[s+8>>2]|0,i[o>>2]=(i[s>>2]|0)-e,i[o+4>>2]=a-e,0),s=e,M=c,s|0)}function pn(e,t,n,r,a){e|=0,t|=0,n|=0,r|=0,a|=0;var o=0,s=0,c=0,l=0,u=0,d=0,f=0;return f=M,M=M+16|0,d=f,r|0?(d=15,M=f,d|0):(c=i[n>>2]|0,s=i[n+4>>2]|0,i[d>>2]=c,l=d+4|0,i[l>>2]=s,u=d+8|0,i[u>>2]=0,n=(s|0)<(c|0),r=n?c:s,n=n?s:c,(n|0)<0?!((n|0)==-2147483648||((r|0)>0?(2147483647-r|0)<(n|0):(-2147483648-r|0)>(n|0)))&&!((r|0)>-1?(r|-2147483648)>=(n|0):(r^-2147483648|0)<(n|0))?o=5:r=1:o=5,(o|0)==5&&(r=s-c|0,o=0-c|0,(c|0)<0?(i[l>>2]=r,i[u>>2]=o,i[d>>2]=0,c=0):(r=s,o=0),s=c-r|0,n=o-r|0,(r|0)<0?(i[d>>2]=s,i[u>>2]=n,i[l>>2]=0,c=s,r=0):n=o,s=c-n|0,o=r-n|0,(n|0)<0?(i[d>>2]=s,i[l>>2]=o,i[u>>2]=0,n=0):(o=r,s=c),r=(o|0)<(s|0)?o:s,r=(n|0)<(r|0)?n:r,(r|0)>0&&(i[d>>2]=s-r,i[l>>2]=o-r,i[u>>2]=n-r),r=dn(e,t,d,a)|0),d=r,M=f,d|0)}function mn(e,t,n,r,a){e|=0,t|=0,n|=0,r|=0,a|=0;var o=0,s=0,c=0,l=0,u=0;return l=M,M=M+32|0,s=l+12|0,c=l,o=un(e,t,e,t,s)|0,o|0?(c=o,M=l,c|0):(e=un(e,t,n,r,c)|0,e|0?(c=e,M=l,c|0):(e=(i[s>>2]|0)-(i[c>>2]|0)|0,u=(e|0)<0,r=u?0-e|0:0,n=r+((i[s+4>>2]|0)-(i[c+4>>2]|0))|0,t=(n|0)<0,r=(i[s+8>>2]|0)-(i[c+8>>2]|0)+r+(t?0-n|0:0)|0,o=(r|0)<0,s=o?0:r,r=o?r:0,o=(t?0:n)-r|0,r=(u?0:e)-(t?n:0)-r|0,c=(o|0)<(r|0)?o:r,c=(s|0)<(c|0)?s:c,c=(c|0)>0?c:0,s=s-c|0,o=o-c|0,c=r-c|0,c=(c|0)>-1?c:0-c|0,o=(o|0)>-1?o:0-o|0,s=(s|0)>-1?s:0-s|0,s=(o|0)>(s|0)?o:s,s=(c|0)>(s|0)?c:s,c=a,i[c>>2]=s,i[c+4>>2]=((s|0)<0)<<31>>31,c=0,M=l,c|0))}function hn(e,t,n,r,a){e|=0,t|=0,n|=0,r|=0,a|=0;var o=0,s=0;return s=M,M=M+16|0,o=s,e=mn(e,t,n,r,o)|0,e|0?(o=e,M=s,o|0):(n=o,n=ur(i[n>>2]|0,i[n+4>>2]|0,1,0)|0,r=T()|0,o=a,i[o>>2]=n,i[o+4>>2]=r,o=0,M=s,o|0)}function gn(e,t,n,r,a){e|=0,t|=0,n|=0,r|=0,a|=0;var o=0,s=0,c=0,l=0;return l=M,M=M+16|0,o=l,s=mn(e,t,n,r,o)|0,s|0?(a=s,M=l,a|0):(s=o,o=i[s>>2]|0,s=i[s+4>>2]|0,(o|0)==0&(s|0)==0?(i[a>>2]=e,i[a+4>>2]=t,a=0,M=l,a|0):(c=_n(e,t,n,r,o,s,a,0,0,1,0)|0,c?(a=(_n(n,r,e,t,o,s,a,o,s,-1,-1)|0)==0,a=a?0:c,M=l,a|0):(a=0,M=l,a|0)))}function _n(e,t,n,r,a,o,s,c,u,d,f){e|=0,t|=0,n|=0,r|=0,a|=0,o|=0,s|=0,c|=0,u|=0,d|=0,f|=0;var p=0,m=0,h=0,g=0,_=0,v=0,y=0,b=0,x=0,S=0,C=0,w=0,D=0,O=0,k=0,A=0,j=0,N=0;if(j=M,M=M+48|0,p=j+24|0,m=j+12|0,A=j,i[p>>2]=0,i[p+4>>2]=0,i[p+8>>2]=0,i[m>>2]=0,i[m+4>>2]=0,i[m+8>>2]=0,un(e,t,e,t,p)|0&&E(27634,27315,696,27575),un(e,t,n,r,m)|0&&E(27634,27315,701,27575),_=p+8|0,r=i[_>>2]|0,n=r-(i[p>>2]|0)|0,i[p>>2]=n,k=p+4|0,r=(i[k>>2]|0)-r|0,i[k>>2]=r,k=r+n|0,p=0-k|0,i[_>>2]=p,_=m+8|0,b=i[_>>2]|0,y=b-(i[m>>2]|0)|0,i[m>>2]=y,O=m+4|0,b=(i[O>>2]|0)-b|0,i[O>>2]=b,O=b+y|0,i[_>>2]=0-O,D=1/(+(a>>>0)+4294967296*(o|0)),C=D*+(y-n|0),w=D*+(b-r|0),D*=+(k-O|0),i[A>>2]=n,O=A+4|0,i[O>>2]=r,k=A+8|0,i[k>>2]=p,(o|0)<0)return d=0,M=j,d|0;for(S=+(n|0),x=+(r|0),v=+(p|0),y=0,b=0;;){if(g=+(y>>>0)+4294967296*(b|0),N=C*g+S,h=w*g+x,g=D*g+v,r=~~+Cr(+N),p=~~+Cr(+h),n=~~+Cr(+g),N=+l(+(+(r|0)-N)),h=+l(+(+(p|0)-h)),g=+l(+(+(n|0)-g)),N>h&N>g?(m=n+p|0,r=0-m|0):(m=0-r|0,h>g&&(p=m-n|0)),i[O>>2]=p,i[A>>2]=m,i[k>>2]=0,n=r+p|0,(r|0)>0?(i[O>>2]=n,i[k>>2]=r,i[A>>2]=0,m=0):(n=p,r=0),(n|0)<0?(p=m-n|0,i[A>>2]=p,r=r-n|0,i[k>>2]=r,i[O>>2]=0,m=p-r|0,n=0-r|0,(r|0)<0?(i[A>>2]=m,i[O>>2]=n,i[k>>2]=0,_=n,r=0):(_=0,m=p)):_=n,n=(_|0)<(m|0)?_:m,n=(r|0)<(n|0)?r:n,(n|0)>0&&(i[A>>2]=m-n,i[O>>2]=_-n,i[k>>2]=r-n),n=gr(y|0,b|0,d|0,f|0)|0,n=ur(n|0,T()|0,c|0,u|0)|0,T()|0,n=dn(e,t,A,s+(n<<3)|0)|0,n|0){r=20;break}if(_=y,y=ur(y|0,b|0,1,0)|0,m=b,b=T()|0,!((m|0)<(o|0)|(m|0)==(o|0)&_>>>0>>0)){n=0,r=20;break}}return(r|0)==20?(M=j,n|0):0}function vn(e,t,n,r){e|=0,t|=0,n|=0,r|=0;var i=0,a=0,o=0;if((n|0)==0&(r|0)==0)return i=0,a=1,w(i|0),a|0;a=e,i=t,e=1,t=0;do o=(n&1|0)==0&!0,e=gr((o?1:a)|0,(o?0:i)|0,e|0,t|0)|0,t=T()|0,n=yr(n|0,r|0,1)|0,r=T()|0,a=gr(a|0,i|0,a|0,i|0)|0,i=T()|0;while(!((n|0)==0&(r|0)==0));return w(t|0),e|0}function yn(e,t,n,r){e|=0,t|=0,n|=0,r|=0;var o=0,s=0,c=0,l=0,u=0,f=0,p=0;l=M,M=M+16|0,s=l,c=z(e|0,t|0,52)|0,T()|0,c&=15;do if(c){if(o=zt(e,t,s)|0,!o){f=+a[s>>3],u=1/d(+f),p=+a[26032+(c<<3)>>3],a[n>>3]=f+p,a[n+8>>3]=f-p,f=+a[s+8>>3],u=p*u,a[n+16>>3]=u+f,a[n+24>>3]=f-u;break}return c=o,M=l,c|0}else{if(o=z(e|0,t|0,45)|0,T()|0,o&=127,o>>>0>121)return c=5,M=l,c|0;s=22128+(o<<5)|0,i[n>>2]=i[s>>2],i[n+4>>2]=i[s+4>>2],i[n+8>>2]=i[s+8>>2],i[n+12>>2]=i[s+12>>2],i[n+16>>2]=i[s+16>>2],i[n+20>>2]=i[s+20>>2],i[n+24>>2]=i[s+24>>2],i[n+28>>2]=i[s+28>>2];break}while(0);return He(n,r?1.4:1.1),r=26160+(c<<3)|0,(i[r>>2]|0)==(e|0)&&(i[r+4>>2]|0)==(t|0)&&(a[n>>3]=1.5707963267948966),c=26288+(c<<3)|0,(i[c>>2]|0)==(e|0)&&(i[c+4>>2]|0)==(t|0)&&(a[n+8>>3]=-1.5707963267948966),+a[n>>3]!=1.5707963267948966&&+a[n+8>>3]!=-1.5707963267948966?(c=0,M=l,c|0):(a[n+16>>3]=3.141592653589793,a[n+24>>3]=-3.141592653589793,c=0,M=l,c|0)}function bn(e,t,n,a){e|=0,t|=0,n|=0,a|=0;var o=0,s=0,c=0,l=0,u=0,d=0,f=0;d=M,M=M+48|0,c=d+32|0,s=d+40|0,l=d,vt(c,0,0,0),u=i[c>>2]|0,c=i[c+4>>2]|0;do if(n>>>0<=15){if(o=Tn(a)|0,o|0){a=l,i[a>>2]=0,i[a+4>>2]=0,i[l+8>>2]=o,i[l+12>>2]=-1,a=l+16|0,u=l+29|0,i[a>>2]=0,i[a+4>>2]=0,i[a+8>>2]=0,r[a+12>>0]=0,r[u>>0]=r[s>>0]|0,r[u+1>>0]=r[s+1>>0]|0,r[u+2>>0]=r[s+2>>0]|0;break}if(o=or((i[t+8>>2]|0)+1|0,32)|0,o){En(t,o),f=l,i[f>>2]=u,i[f+4>>2]=c,i[l+8>>2]=0,i[l+12>>2]=n,i[l+16>>2]=a,i[l+20>>2]=t,i[l+24>>2]=o,r[l+28>>0]=0,u=l+29|0,r[u>>0]=r[s>>0]|0,r[u+1>>0]=r[s+1>>0]|0,r[u+2>>0]=r[s+2>>0]|0;break}else{a=l,i[a>>2]=0,i[a+4>>2]=0,i[l+8>>2]=13,i[l+12>>2]=-1,a=l+16|0,u=l+29|0,i[a>>2]=0,i[a+4>>2]=0,i[a+8>>2]=0,r[a+12>>0]=0,r[u>>0]=r[s>>0]|0,r[u+1>>0]=r[s+1>>0]|0,r[u+2>>0]=r[s+2>>0]|0;break}}else u=l,i[u>>2]=0,i[u+4>>2]=0,i[l+8>>2]=4,i[l+12>>2]=-1,u=l+16|0,f=l+29|0,i[u>>2]=0,i[u+4>>2]=0,i[u+8>>2]=0,r[u+12>>0]=0,r[f>>0]=r[s>>0]|0,r[f+1>>0]=r[s+1>>0]|0,r[f+2>>0]=r[s+2>>0]|0;while(0);xn(l),i[e>>2]=i[l>>2],i[e+4>>2]=i[l+4>>2],i[e+8>>2]=i[l+8>>2],i[e+12>>2]=i[l+12>>2],i[e+16>>2]=i[l+16>>2],i[e+20>>2]=i[l+20>>2],i[e+24>>2]=i[l+24>>2],i[e+28>>2]=i[l+28>>2],M=d}function xn(e){e|=0;var t=0,n=0,a=0,o=0,s=0,c=0,l=0,u=0,d=0,f=0,p=0,m=0,h=0,g=0,_=0,v=0,y=0,b=0,x=0,S=0;if(S=M,M=M+336|0,h=S+168|0,g=S,a=e,n=i[a>>2]|0,a=i[a+4>>2]|0,(n|0)==0&(a|0)==0){M=S;return}if(t=e+28|0,r[t>>0]|0?(n=Sn(n,a)|0,a=T()|0):r[t>>0]=1,x=e+20|0,!(i[i[x>>2]>>2]|0)){t=e+24|0,n=i[t>>2]|0,n|0&&ar(n),b=e,i[b>>2]=0,i[b+4>>2]=0,i[e+8>>2]=0,i[x>>2]=0,i[e+12>>2]=-1,i[e+16>>2]=0,i[t>>2]=0,M=S;return}b=e+16|0,t=i[b>>2]|0,o=t&15;a:do if((n|0)==0&(a|0)==0)y=e+24|0;else{_=e+12|0,p=(o|0)==3,f=t&255,u=(o|1)==3,m=e+24|0,d=(o+-1|0)>>>0<3,c=(o|2)==3,l=g+8|0;b:for(;;){if(s=z(n|0,a|0,52)|0,T()|0,s&=15,(s|0)==(i[_>>2]|0)){switch(f&15){case 0:case 2:case 3:if(o=zt(n,a,h)|0,o|0){v=15;break b}if(Dn(i[x>>2]|0,i[m>>2]|0,h)|0){v=19;break b}break;default:}if(u&&(o=i[(i[x>>2]|0)+4>>2]|0,i[h>>2]=i[o>>2],i[h+4>>2]=i[o+4>>2],i[h+8>>2]=i[o+8>>2],i[h+12>>2]=i[o+12>>2],Fe(26896,h)|0)){if(It(i[(i[x>>2]|0)+4>>2]|0,s,g)|0){v=25;break}if(o=g,(i[o>>2]|0)==(n|0)&&(i[o+4>>2]|0)==(a|0)){v=29;break}}if(d){if(o=Bt(n,a,h)|0,o|0){v=32;break}if(yn(n,a,g,0)|0){v=36;break}if(c&&On(i[x>>2]|0,i[m>>2]|0,h,g)|0){v=42;break}if(u&&An(i[x>>2]|0,i[m>>2]|0,h,g)|0){v=42;break}}if(p){if(t=yn(n,a,h,1)|0,o=i[m>>2]|0,t|0){v=45;break}if(Ie(o,h)|0){if(ze(g,h),Re(h,i[m>>2]|0)|0){v=53;break}if(Dn(i[x>>2]|0,i[m>>2]|0,l)|0){v=53;break}if(An(i[x>>2]|0,i[m>>2]|0,g,h)|0){v=53;break}}}}do if((s|0)<(i[_>>2]|0)){if(t=yn(n,a,h,1)|0,o=i[m>>2]|0,t|0){v=58;break b}if(!(Ie(o,h)|0)){v=73;break}if(Re(i[m>>2]|0,h)|0&&(ze(g,h),On(i[x>>2]|0,i[m>>2]|0,g,h)|0)){v=65;break b}if(n=wt(n,a,s+1|0,g)|0,n|0){v=67;break b}a=g,n=i[a>>2]|0,a=i[a+4>>2]|0}else v=73;while(0);if((v|0)==73&&(v=0,n=Sn(n,a)|0,a=T()|0),(n|0)==0&(a|0)==0){y=m;break a}}switch(v|0){case 15:t=i[m>>2]|0,t|0&&ar(t),v=e,i[v>>2]=0,i[v+4>>2]=0,i[x>>2]=0,i[_>>2]=-1,i[b>>2]=0,i[m>>2]=0,i[e+8>>2]=o,v=20;break;case 19:i[e>>2]=n,i[e+4>>2]=a,v=20;break;case 25:E(27634,27600,470,27611);break;case 29:i[e>>2]=n,i[e+4>>2]=a,M=S;return;case 32:t=i[m>>2]|0,t|0&&ar(t),y=e,i[y>>2]=0,i[y+4>>2]=0,i[x>>2]=0,i[_>>2]=-1,i[b>>2]=0,i[m>>2]=0,i[e+8>>2]=o,M=S;return;case 36:E(27634,27600,493,27611);break;case 42:i[e>>2]=n,i[e+4>>2]=a,M=S;return;case 45:o|0&&ar(o),v=e,i[v>>2]=0,i[v+4>>2]=0,i[x>>2]=0,i[_>>2]=-1,i[b>>2]=0,i[m>>2]=0,i[e+8>>2]=t,v=55;break;case 53:i[e>>2]=n,i[e+4>>2]=a,v=55;break;case 58:o|0&&ar(o),v=e,i[v>>2]=0,i[v+4>>2]=0,i[x>>2]=0,i[_>>2]=-1,i[b>>2]=0,i[m>>2]=0,i[e+8>>2]=t,v=71;break;case 65:i[e>>2]=n,i[e+4>>2]=a,v=71;break;case 67:t=i[m>>2]|0,t|0&&ar(t),y=e,i[y>>2]=0,i[y+4>>2]=0,i[x>>2]=0,i[_>>2]=-1,i[b>>2]=0,i[m>>2]=0,i[e+8>>2]=n,M=S;return}if((v|0)==20){M=S;return}else if((v|0)==55){M=S;return}else if((v|0)==71){M=S;return}}while(0);t=i[y>>2]|0,t|0&&ar(t),v=e,i[v>>2]=0,i[v+4>>2]=0,i[e+8>>2]=0,i[x>>2]=0,i[e+12>>2]=-1,i[b>>2]=0,i[y>>2]=0,M=S}function Sn(e,t){e|=0,t|=0;var n=0,r=0,a=0,o=0,s=0,c=0,l=0,u=0,d=0,f=0;f=M,M=M+16|0,d=f,r=z(e|0,t|0,52)|0,T()|0,r&=15,n=z(e|0,t|0,45)|0,T()|0;do if(r){for(;n=B(r+4095|0,0,52)|0,a=T()|0|t&-15728641,o=(15-r|0)*3|0,s=B(7,0,o|0)|0,c=T()|0,n=n|e|s,a|=c,l=z(e|0,t|0,o|0)|0,T()|0,l&=7,r=r+-1|0,!(l>>>0<6);)if(r)t=a,e=n;else{u=4;break}if((u|0)==4){n=z(n|0,a|0,45)|0,T()|0;break}return d=(l|0)==0&(xt(n,a)|0)!=0,d=B((d?2:1)+l|0,0,o|0)|0,u=T()|0|t&~c,d|=e&~s,w(u|0),M=f,d|0}while(0);return n&=127,n>>>0>120?(u=0,d=0,w(u|0),M=f,d|0):(vt(d,0,n+1|0,0),u=i[d+4>>2]|0,d=i[d>>2]|0,w(u|0),M=f,d|0)}function L(e,t,n,r,a,o){e|=0,t|=0,n|=0,r|=0,a|=0,o|=0;var s=0,c=0,l=0,u=0,d=0,f=0,p=0,m=0,h=0,g=0,_=0;_=M,M=M+160|0,f=_+80|0,c=_+64|0,p=_+112|0,g=_,bn(f,e,t,n),u=f,Gt(c,i[u>>2]|0,i[u+4>>2]|0,t),u=c,l=i[u>>2]|0,u=i[u+4>>2]|0,s=i[f+8>>2]|0,m=p+4|0,i[m>>2]=i[f>>2],i[m+4>>2]=i[f+4>>2],i[m+8>>2]=i[f+8>>2],i[m+12>>2]=i[f+12>>2],i[m+16>>2]=i[f+16>>2],i[m+20>>2]=i[f+20>>2],i[m+24>>2]=i[f+24>>2],i[m+28>>2]=i[f+28>>2],m=g,i[m>>2]=l,i[m+4>>2]=u,m=g+8|0,i[m>>2]=s,e=g+12|0,t=p,n=e+36|0;do i[e>>2]=i[t>>2],e=e+4|0,t=t+4|0;while((e|0)<(n|0));if(p=g+48|0,i[p>>2]=i[c>>2],i[p+4>>2]=i[c+4>>2],i[p+8>>2]=i[c+8>>2],i[p+12>>2]=i[c+12>>2],(l|0)==0&(u|0)==0)return g=s,M=_,g|0;n=g+16|0,d=g+24|0,f=g+28|0,s=0,c=0,t=l,e=u;do{if(!((s|0)<(a|0)|(s|0)==(a|0)&c>>>0>>0)){h=4;break}if(u=c,c=ur(c|0,s|0,1,0)|0,s=T()|0,u=o+(u<<3)|0,i[u>>2]=t,i[u+4>>2]=e,qt(p),e=p,t=i[e>>2]|0,e=i[e+4>>2]|0,(t|0)==0&(e|0)==0){if(xn(n),t=n,e=i[t>>2]|0,t=i[t+4>>2]|0,(e|0)==0&(t|0)==0){h=10;break}Kt(e,t,i[f>>2]|0,p),e=p,t=i[e>>2]|0,e=i[e+4>>2]|0}u=g,i[u>>2]=t,i[u+4>>2]=e}while(!((t|0)==0&(e|0)==0));return(h|0)==4?(e=g+40|0,t=i[e>>2]|0,t|0&&ar(t),h=g+16|0,i[h>>2]=0,i[h+4>>2]=0,i[d>>2]=0,i[g+36>>2]=0,i[f>>2]=-1,i[g+32>>2]=0,i[e>>2]=0,Kt(0,0,0,p),i[g>>2]=0,i[g+4>>2]=0,i[m>>2]=0,g=14,M=_,g|0):((h|0)==10&&(i[g>>2]=0,i[g+4>>2]=0,i[m>>2]=i[d>>2]),g=i[m>>2]|0,M=_,g|0)}function Cn(e,t,n,o){e|=0,t|=0,n|=0,o|=0;var s=0,c=0,u=0,f=0,p=0,m=0,h=0,g=0,_=0,v=0;if(g=M,M=M+48|0,p=g+32|0,f=g+40|0,m=g,!(i[e>>2]|0))return h=o,i[h>>2]=0,i[h+4>>2]=0,h=0,M=g,h|0;vt(p,0,0,0),u=p,s=i[u>>2]|0,u=i[u+4>>2]|0;do if(t>>>0>15)h=m,i[h>>2]=0,i[h+4>>2]=0,i[m+8>>2]=4,i[m+12>>2]=-1,h=m+16|0,n=m+29|0,i[h>>2]=0,i[h+4>>2]=0,i[h+8>>2]=0,r[h+12>>0]=0,r[n>>0]=r[f>>0]|0,r[n+1>>0]=r[f+1>>0]|0,r[n+2>>0]=r[f+2>>0]|0,n=4,h=9;else{if(n=Tn(n)|0,n|0){p=m,i[p>>2]=0,i[p+4>>2]=0,i[m+8>>2]=n,i[m+12>>2]=-1,p=m+16|0,h=m+29|0,i[p>>2]=0,i[p+4>>2]=0,i[p+8>>2]=0,r[p+12>>0]=0,r[h>>0]=r[f>>0]|0,r[h+1>>0]=r[f+1>>0]|0,r[h+2>>0]=r[f+2>>0]|0,h=9;break}if(n=or((i[e+8>>2]|0)+1|0,32)|0,!n){h=m,i[h>>2]=0,i[h+4>>2]=0,i[m+8>>2]=13,i[m+12>>2]=-1,h=m+16|0,n=m+29|0,i[h>>2]=0,i[h+4>>2]=0,i[h+8>>2]=0,r[h+12>>0]=0,r[n>>0]=r[f>>0]|0,r[n+1>>0]=r[f+1>>0]|0,r[n+2>>0]=r[f+2>>0]|0,n=13,h=9;break}En(e,n),v=m,i[v>>2]=s,i[v+4>>2]=u,u=m+8|0,i[u>>2]=0,i[m+12>>2]=t,i[m+20>>2]=e,i[m+24>>2]=n,r[m+28>>0]=0,s=m+29|0,r[s>>0]=r[f>>0]|0,r[s+1>>0]=r[f+1>>0]|0,r[s+2>>0]=r[f+2>>0]|0,i[m+16>>2]=3,_=+P(n),_*=+Ne(n),c=+l(+ +a[n>>3]),c=_/+d(+ +Sr(+c,+ +l(+ +a[n+8>>3])))*6371.007180918475*6371.007180918475,s=m+12|0,n=i[s>>2]|0;a:do if((n|0)>0)do{if($t(n+-1|0,p)|0,!(c/+a[p>>3]>10))break a;v=i[s>>2]|0,n=v+-1|0,i[s>>2]=n}while((v|0)>1);while(0);if(xn(m),s=o,i[s>>2]=0,i[s+4>>2]=0,s=m,n=i[s>>2]|0,s=i[s+4>>2]|0,!((n|0)==0&(s|0)==0))do bt(n,s,t,p)|0,f=p,e=o,f=ur(i[e>>2]|0,i[e+4>>2]|0,i[f>>2]|0,i[f+4>>2]|0)|0,e=T()|0,v=o,i[v>>2]=f,i[v+4>>2]=e,xn(m),v=m,n=i[v>>2]|0,s=i[v+4>>2]|0;while(!((n|0)==0&(s|0)==0));n=i[u>>2]|0}while(0);return v=n,M=g,v|0}function R(e,t,n){e|=0,t|=0,n|=0;var r=0,o=0,s=0,c=0,l=0,u=0,d=0,f=0,p=0,m=0;if(!(Fe(t,n)|0)||(t=Pe(t)|0,r=+a[n>>3],o=+a[n+8>>3],o=t&o<0?o+6.283185307179586:o,m=i[e>>2]|0,(m|0)<=0))return m=0,m|0;if(p=i[e+4>>2]|0,t){t=0,f=o,n=-1,e=0;a:for(;;){for(d=e;c=+a[p+(d<<4)>>3],o=+a[p+(d<<4)+8>>3],e=(n+2|0)%(m|0)|0,s=+a[p+(e<<4)>>3],l=+a[p+(e<<4)+8>>3],c>s?(u=c,c=l):(u=s,s=c,c=o,o=l),r=r==s|r==u?r+2220446049250313e-31:r,ru;)if(n=d+1|0,(n|0)>=(m|0)){n=22;break a}else e=d,d=n,n=e;if(l=c<0?c+6.283185307179586:c,c=o<0?o+6.283185307179586:o,f=l==f|c==f?f+-2220446049250313e-31:f,u=l+(c-l)*((r-s)/(u-s)),(u<0?u+6.283185307179586:u)>f&&(t^=1),e=d+1|0,(e|0)>=(m|0)){n=22;break}else n=d}if((n|0)==22)return t|0}else{t=0,f=o,n=-1,e=0;b:for(;;){for(d=e;c=+a[p+(d<<4)>>3],o=+a[p+(d<<4)+8>>3],e=(n+2|0)%(m|0)|0,s=+a[p+(e<<4)>>3],l=+a[p+(e<<4)+8>>3],c>s?(u=c,c=l):(u=s,s=c,c=o,o=l),r=r==s|r==u?r+2220446049250313e-31:r,ru;)if(n=d+1|0,(n|0)>=(m|0)){n=22;break b}else e=d,d=n,n=e;if(f=c==f|o==f?f+-2220446049250313e-31:f,c+(o-c)*((r-s)/(u-s))>f&&(t^=1),e=d+1|0,(e|0)>=(m|0)){n=22;break}else n=d}if((n|0)==22)return t|0}return 0}function wn(e,t){e|=0,t|=0;var n=0,r=0,o=0,s=0,c=0,u=0,d=0,f=0,p=0,m=0,h=0,g=0,_=0,v=0,y=0,b=0,x=0;if(_=i[e>>2]|0,!_){i[t>>2]=0,i[t+4>>2]=0,i[t+8>>2]=0,i[t+12>>2]=0,i[t+16>>2]=0,i[t+20>>2]=0,i[t+24>>2]=0,i[t+28>>2]=0;return}if(v=t+8|0,a[v>>3]=17976931348623157e292,y=t+24|0,a[y>>3]=17976931348623157e292,a[t>>3]=-17976931348623157e292,b=t+16|0,a[b>>3]=-17976931348623157e292,!((_|0)<=0)){for(h=i[e+4>>2]|0,f=17976931348623157e292,p=-17976931348623157e292,m=0,e=-1,s=17976931348623157e292,c=17976931348623157e292,d=-17976931348623157e292,r=-17976931348623157e292,g=0;n=+a[h+(g<<4)>>3],u=+a[h+(g<<4)+8>>3],e=e+2|0,o=+a[h+(((e|0)==(_|0)?0:e)<<4)+8>>3],n>3]=n,s=n),u>3]=u,c=u),n>d?a[t>>3]=n:n=d,u>r&&(a[b>>3]=u,r=u),f=u>0&up?u:p,m|=+l(+(u-o))>3.141592653589793,e=g+1|0,(e|0)!=(_|0);)x=g,d=n,g=e,e=x;m&&(a[b>>3]=p,a[y>>3]=f)}}function Tn(e){return e|=0,(e>>>0<4?0:15)|0}function En(e,t){e|=0,t|=0;var n=0,r=0,o=0,s=0,c=0,u=0,d=0,f=0,p=0,m=0,h=0,g=0,_=0,v=0,y=0,b=0,x=0,S=0,C=0,w=0,T=0,E=0;if(_=i[e>>2]|0,_){if(v=t+8|0,a[v>>3]=17976931348623157e292,y=t+24|0,a[y>>3]=17976931348623157e292,a[t>>3]=-17976931348623157e292,b=t+16|0,a[b>>3]=-17976931348623157e292,(_|0)>0){for(o=i[e+4>>2]|0,h=17976931348623157e292,g=-17976931348623157e292,r=0,n=-1,d=17976931348623157e292,f=17976931348623157e292,m=-17976931348623157e292,c=-17976931348623157e292,x=0;s=+a[o+(x<<4)>>3],p=+a[o+(x<<4)+8>>3],T=n+2|0,u=+a[o+(((T|0)==(_|0)?0:T)<<4)+8>>3],s>3]=s,d=s),p>3]=p,f=p),s>m?a[t>>3]=s:s=m,p>c&&(a[b>>3]=p,c=p),h=p>0&pg?p:g,r|=+l(+(p-u))>3.141592653589793,n=x+1|0,(n|0)!=(_|0);)T=x,m=s,x=n,n=T;r&&(a[b>>3]=g,a[y>>3]=h)}}else i[t>>2]=0,i[t+4>>2]=0,i[t+8>>2]=0,i[t+12>>2]=0,i[t+16>>2]=0,i[t+20>>2]=0,i[t+24>>2]=0,i[t+28>>2]=0;if(T=e+8|0,n=i[T>>2]|0,!((n|0)<=0)){w=e+12|0,C=0;do if(o=i[w>>2]|0,r=C,C=C+1|0,y=t+(C<<5)|0,b=i[o+(r<<3)>>2]|0,b){if(x=t+(C<<5)+8|0,a[x>>3]=17976931348623157e292,e=t+(C<<5)+24|0,a[e>>3]=17976931348623157e292,a[y>>3]=-17976931348623157e292,S=t+(C<<5)+16|0,a[S>>3]=-17976931348623157e292,(b|0)>0){for(_=i[o+(r<<3)+4>>2]|0,h=17976931348623157e292,g=-17976931348623157e292,o=0,r=-1,v=0,d=17976931348623157e292,f=17976931348623157e292,p=-17976931348623157e292,c=-17976931348623157e292;s=+a[_+(v<<4)>>3],m=+a[_+(v<<4)+8>>3],r=r+2|0,u=+a[_+(((r|0)==(b|0)?0:r)<<4)+8>>3],s>3]=s,d=s),m>3]=m,f=m),s>p?a[y>>3]=s:s=p,m>c&&(a[S>>3]=m,c=m),h=m>0&mg?m:g,o|=+l(+(m-u))>3.141592653589793,r=v+1|0,(r|0)!=(b|0);)E=v,v=r,p=s,r=E;o&&(a[S>>3]=g,a[e>>3]=h)}}else i[y>>2]=0,i[y+4>>2]=0,i[y+8>>2]=0,i[y+12>>2]=0,i[y+16>>2]=0,i[y+20>>2]=0,i[y+24>>2]=0,i[y+28>>2]=0,n=i[T>>2]|0;while((C|0)<(n|0))}}function Dn(e,t,n){e|=0,t|=0,n|=0;var r=0,a=0,o=0;if(!(R(e,t,n)|0))return a=0,a|0;if(a=e+8|0,(i[a>>2]|0)<=0)return a=1,a|0;for(r=e+12|0,e=0;;){if(o=e,e=e+1|0,R((i[r>>2]|0)+(o<<3)|0,t+(e<<5)|0,n)|0){e=0,r=6;break}if((e|0)>=(i[a>>2]|0)){e=1,r=6;break}}return(r|0)==6?e|0:0}function On(e,t,n,r){e|=0,t|=0,n|=0,r|=0;var a=0,o=0,s=0,c=0,l=0,u=0,d=0;if(u=M,M=M+16|0,c=u,s=n+8|0,!(R(e,t,s)|0))return l=0,M=u,l|0;l=e+8|0;a:do if((i[l>>2]|0)>0){for(o=e+12|0,a=0;;){if(d=a,a=a+1|0,R((i[o>>2]|0)+(d<<3)|0,t+(a<<5)|0,s)|0){a=0;break}if((a|0)>=(i[l>>2]|0))break a}return M=u,a|0}while(0);if(kn(e,t,n,r)|0)return d=0,M=u,d|0;i[c>>2]=i[n>>2],i[c+4>>2]=s,a=i[l>>2]|0;b:do if((a|0)>0)for(e=e+12|0,s=0,o=a;;){if(a=i[e>>2]|0,(i[a+(s<<3)>>2]|0)>0){if(R(c,r,i[a+(s<<3)+4>>2]|0)|0){a=0;break b}if(a=s+1|0,kn((i[e>>2]|0)+(s<<3)|0,t+(a<<5)|0,n,r)|0){a=0;break b}o=i[l>>2]|0}else a=s+1|0;if((a|0)<(o|0))s=a;else{a=1;break}}else a=1;while(0);return d=a,M=u,d|0}function kn(e,t,n,r){e|=0,t|=0,n|=0,r|=0;var o=0,s=0,c=0,l=0,u=0,d=0,f=0,p=0,m=0,h=0,g=0,_=0,v=0,y=0,b=0,x=0,S=0,C=0,w=0,T=0,E=0;if(w=M,M=M+176|0,b=w+172|0,o=w+168|0,x=w,!(Ie(t,r)|0))return e=0,M=w,e|0;if(Le(t,r,b,o),wr(x|0,n|0,168)|0,(i[n>>2]|0)>0){t=0;do T=x+8+(t<<4)+8|0,y=+Yt(+a[T>>3],i[o>>2]|0),a[T>>3]=y,t=t+1|0;while((t|0)<(i[n>>2]|0))}_=+a[r>>3],v=+a[r+8>>3],y=+Yt(+a[r+16>>3],i[o>>2]|0),h=+Yt(+a[r+24>>3],i[o>>2]|0);a:do if((i[e>>2]|0)>0){if(r=e+4|0,o=i[x>>2]|0,(o|0)<=0){for(t=0;;)if(t=t+1|0,(t|0)>=(i[e>>2]|0)){t=0;break a}}for(n=0;;){if(t=i[r>>2]|0,m=+a[t+(n<<4)>>3],g=+Yt(+a[t+(n<<4)+8>>3],i[b>>2]|0),t=i[r>>2]|0,n=n+1|0,T=(n|0)%(i[e>>2]|0)|0,s=+a[t+(T<<4)>>3],c=+Yt(+a[t+(T<<4)+8>>3],i[b>>2]|0),!(m>=_)|!(s>=_)&&!(m<=v)|!(s<=v)&&!(g<=h)|!(c<=h)&&!(g>=y)|!(c>=y)){p=s-m,d=c-g,t=0;do if(E=t,t=t+1|0,T=(t|0)==(o|0)?0:t,s=+a[x+8+(E<<4)+8>>3],c=+a[x+8+(T<<4)+8>>3]-s,l=+a[x+8+(E<<4)>>3],u=+a[x+8+(T<<4)>>3]-l,f=p*c-d*u,f!=0&&(S=g-s,C=m-l,u=(S*u-c*C)/f,!(u<0|u>1))&&(f=(p*S-d*C)/f,f>=0&f<=1)){t=1;break a}while((t|0)<(o|0))}if((n|0)>=(i[e>>2]|0)){t=0;break}}}else t=0;while(0);return E=t,M=w,E|0}function An(e,t,n,r){e|=0,t|=0,n|=0,r|=0;var a=0,o=0,s=0;if(kn(e,t,n,r)|0)return o=1,o|0;if(o=e+8|0,(i[o>>2]|0)<=0)return o=0,o|0;for(a=e+12|0,e=0;;){if(s=e,e=e+1|0,kn((i[a>>2]|0)+(s<<3)|0,t+(e<<5)|0,n,r)|0){e=1,a=6;break}if((e|0)>=(i[o>>2]|0)){e=0,a=6;break}}return(a|0)==6?e|0:0}function jn(){return 8}function Mn(){return 16}function Nn(){return 168}function Pn(){return 8}function Fn(){return 16}function In(){return 12}function Ln(){return 8}function Rn(e){return e|=0,+(+((i[e>>2]|0)>>>0)+4294967296*(i[e+4>>2]|0))}function zn(e){e|=0;var t=0,n=0;return n=+a[e>>3],t=+a[e+8>>3],+ +u(+(n*n+t*t))}function Bn(e,t,n,r,i){e|=0,t|=0,n|=0,r|=0,i|=0;var o=0,s=0,c=0,l=0,u=0,d=0,f=0,p=0;u=+a[e>>3],l=+a[t>>3]-u,c=+a[e+8>>3],s=+a[t+8>>3]-c,f=+a[n>>3],o=+a[r>>3]-f,p=+a[n+8>>3],d=+a[r+8>>3]-p,o=(o*(c-p)-(u-f)*d)/(l*d-s*o),a[i>>3]=u+l*o,a[i+8>>3]=c+s*o}function Vn(e,t){return e|=0,t|=0,+l(+(a[e>>3]-+a[t>>3]))<1.1920928955078125e-7?(t=+l(+(a[e+8>>3]-+a[t+8>>3]))<1.1920928955078125e-7,t|0):(t=0,t|0)}function Hn(e,t,n){e|=0,t|=0,n|=0;var r=0,a=0,o=0;if(o=M,M=M+16|0,a=o,r=xt(e,t)|0,(n+-1|0)>>>0>5||(r=(r|0)!=0,(n|0)==1&r))return a=-1,M=o,a|0;do if(Un(e,t,a)|0)r=-1;else if(r){r=((i[26416+(n<<2)>>2]|0)+5-(i[a>>2]|0)|0)%5|0;break}else{r=((i[26448+(n<<2)>>2]|0)+6-(i[a>>2]|0)|0)%6|0;break}while(0);return a=r,M=o,a|0}function Un(e,t,n){e|=0,t|=0,n|=0;var r=0,a=0,o=0,s=0,c=0,l=0,u=0,d=0;if(d=M,M=M+32|0,c=d+16|0,l=d,r=Rt(e,t,c)|0,r|0)return n=r,M=d,n|0;o=pt(e,t)|0,u=kt(e,t)|0,Ee(o,l),r=De(o,i[c>>2]|0)|0;do if(Se(o)|0){do switch(o|0){case 4:a=0;break;case 14:a=1;break;case 24:a=2;break;case 38:a=3;break;case 49:a=4;break;case 58:a=5;break;case 63:a=6;break;case 72:a=7;break;case 83:a=8;break;case 97:a=9;break;case 107:a=10;break;case 117:a=11;break;default:E(27634,27636,75,27645)}while(0);if(s=i[26480+(a*24|0)+8>>2]|0,t=i[26480+(a*24|0)+16>>2]|0,e=i[c>>2]|0,(e|0)!=(i[l>>2]|0)&&(l=Ce(o)|0,e=i[c>>2]|0,l|(e|0)==(t|0)&&(r=(r+1|0)%6|0)),(u|0)==3&(e|0)==(t|0)){r=(r+5|0)%6|0;break}(u|0)==5&(e|0)==(s|0)&&(r=(r+1|0)%6|0)}while(0);return i[n>>2]=r,n=0,M=d,n|0}function Wn(e,t,n,r){e|=0,t|=0,n|=0,r|=0;var a=0,o=0,s=0,c=0,l=0,u=0,d=0,f=0,p=0,m=0,h=0,g=0,_=0,v=0,y=0,b=0;if(b=M,M=M+32|0,y=b+24|0,_=b+20|0,h=b+8|0,m=b+16|0,p=b,l=(xt(e,t)|0)==0,l=l?6:5,d=z(e|0,t|0,52)|0,T()|0,d&=15,l>>>0<=n>>>0)return r=2,M=b,r|0;f=(d|0)==0,!f&&(g=B(7,0,(d^15)*3|0)|0,(g&e|0)==0&((T()|0)&t|0)==0)?a=n:o=4;a:do if((o|0)==4){if(a=(xt(e,t)|0)!=0,((a?4:5)|0)<(n|0)||Un(e,t,y)|0||(o=(i[y>>2]|0)+n|0,a=a?26768+(((o|0)%5|0)<<2)|0:26800+(((o|0)%6|0)<<2)|0,g=i[a>>2]|0,(g|0)==7))return r=1,M=b,r|0;i[_>>2]=0,a=le(e,t,g,_,h)|0;do if(!a){if(c=h,u=i[c>>2]|0,c=i[c+4>>2]|0,s=c>>>0>>0|(c|0)==(t|0)&u>>>0>>0,o=s?u:e,s=s?c:t,!f&&(f=B(7,0,(d^15)*3|0)|0,(u&f|0)==0&(c&(T()|0)|0)==0))a=n;else{if(c=(n+-1+l|0)%(l|0)|0,a=xt(e,t)|0,(c|0)<0&&E(27634,27636,248,27661),l=(a|0)!=0,((l?4:5)|0)<(c|0)&&E(27634,27636,248,27661),Un(e,t,y)|0&&E(27634,27636,248,27661),a=(i[y>>2]|0)+c|0,a=l?26768+(((a|0)%5|0)<<2)|0:26800+(((a|0)%6|0)<<2)|0,c=i[a>>2]|0,(c|0)==7&&E(27634,27636,248,27661),i[m>>2]=0,a=le(e,t,c,m,p)|0,a|0)break;u=p,l=i[u>>2]|0,u=i[u+4>>2]|0;do if(u>>>0>>0|(u|0)==(s|0)&l>>>0>>0){if(o=xt(l,u)|0?pe(l,u,e,t)|0:i[26864+((((i[m>>2]|0)+(i[26832+(c<<2)>>2]|0)|0)%6|0)<<2)>>2]|0,a=xt(l,u)|0,(o+-1|0)>>>0>5){a=-1,o=l,s=u;break}if(a=(a|0)!=0,(o|0)==1&a){a=-1,o=l,s=u;break}do if(Un(l,u,y)|0)a=-1;else if(a){a=((i[26416+(o<<2)>>2]|0)+5-(i[y>>2]|0)|0)%5|0;break}else{a=((i[26448+(o<<2)>>2]|0)+6-(i[y>>2]|0)|0)%6|0;break}while(0);o=l,s=u}else a=n;while(0);c=h,u=i[c>>2]|0,c=i[c+4>>2]|0}if((o|0)==(u|0)&(s|0)==(c|0)){if(l=(xt(u,c)|0)!=0,e=l?pe(u,c,e,t)|0:i[26864+((((i[_>>2]|0)+(i[26832+(g<<2)>>2]|0)|0)%6|0)<<2)>>2]|0,a=xt(u,c)|0,(e+-1|0)>>>0<=5&&(v=(a|0)!=0,!((e|0)==1&v)))do if(Un(u,c,y)|0)a=-1;else if(v){a=((i[26416+(e<<2)>>2]|0)+5-(i[y>>2]|0)|0)%5|0;break}else{a=((i[26448+(e<<2)>>2]|0)+6-(i[y>>2]|0)|0)%6|0;break}while(0);else a=-1;a=a+1|0,a=(a|0)==6|l&(a|0)==5?0:a}t=s,e=o;break a}while(0);return r=a,M=b,r|0}while(0);return v=B(a|0,0,56)|0,y=T()|0|t&-2130706433|536870912,i[r>>2]=v|e,i[r+4>>2]=y,r=0,M=b,r|0}function Gn(e,t,n){e|=0,t|=0,n|=0;var r=0,a=0,o=0;return o=(xt(e,t)|0)==0,r=Wn(e,t,0,n)|0,a=(r|0)==0,o?!a||(r=Wn(e,t,1,n+8|0)|0,r|0)||(r=Wn(e,t,2,n+16|0)|0,r|0)||(r=Wn(e,t,3,n+24|0)|0,r|0)||(r=Wn(e,t,4,n+32|0)|0,r)?(o=r,o|0):Wn(e,t,5,n+40|0)|0:!a||(r=Wn(e,t,1,n+8|0)|0,r|0)||(r=Wn(e,t,2,n+16|0)|0,r|0)||(r=Wn(e,t,3,n+24|0)|0,r|0)||(r=Wn(e,t,4,n+32|0)|0,r|0)?(o=r,o|0):(o=n+40|0,i[o>>2]=0,i[o+4>>2]=0,o=0,o|0)}function Kn(e,t,n){e|=0,t|=0,n|=0;var r=0,a=0,o=0,s=0,c=0,l=0;return l=M,M=M+192|0,a=l,o=l+168|0,s=z(e|0,t|0,56)|0,T()|0,s&=7,c=t&-2130706433|134217728,r=Rt(e,c,o)|0,r|0?(c=r,M=l,c|0):(t=z(e|0,t|0,52)|0,T()|0,t&=15,xt(e,c)|0?ot(o,t,s,1,a):ut(o,t,s,1,a),c=a+8|0,i[n>>2]=i[c>>2],i[n+4>>2]=i[c+4>>2],i[n+8>>2]=i[c+8>>2],i[n+12>>2]=i[c+12>>2],c=0,M=l,c|0)}function qn(e,t){e|=0,t|=0;var n=0,r=0,a=0,o=0;return a=M,M=M+16|0,n=a,!(!0&(t&2013265920|0)==536870912)||(r=t&-2130706433|134217728,!(gt(e,r)|0))?(r=0,M=a,r|0):(o=z(e|0,t|0,56)|0,T()|0,o=(Wn(e,r,o&7,n)|0)==0,r=n,r=o&((i[r>>2]|0)==(e|0)?(i[r+4>>2]|0)==(t|0):0)&1,M=a,r|0)}function Jn(){return 27680}function Yn(e,t,n,r){e|=0,t|=0,n|=0,r|=0;var a=0,o=0,s=0,c=0,l=0,u=0,d=0,f=0,p=0;f=M,M=M+208|0,l=f,u=f+192|0,s=y(n,t)|0,c=u,i[c>>2]=1,i[c+4>>2]=0;a:do if(s|0){for(c=0-n|0,i[l+4>>2]=n,i[l>>2]=n,a=2,t=n,o=n;t=t+n+o|0,i[l+(a<<2)>>2]=t,t>>>0>>0;)p=o,a=a+1|0,o=t,t=p;if(o=e+s+c|0,o>>>0>e>>>0){s=o,a=1,t=1;do{do if((t&3|0)!=3)if(t=a+-1|0,(i[l+(t<<2)>>2]|0)>>>0<(s-e|0)>>>0?Xn(e,n,r,a,l):Qn(e,n,r,u,a,0,l),(a|0)==1){$n(u,1),a=0;break}else{$n(u,t),a=1;break}else Xn(e,n,r,a,l),Zn(u,2),a=a+2|0;while(0);t=i[u>>2]|1,i[u>>2]=t,e=e+n|0}while(e>>>0>>0)}else a=1,t=1;for(Qn(e,n,r,u,a,0,l),o=u+4|0;;){if((a|0)==1&(t|0)==1)if(i[o>>2]|0)d=19;else break a;else (a|0)<2?d=19:($n(u,2),p=a+-2|0,i[u>>2]=i[u>>2]^7,Zn(u,1),Qn(e+(0-(i[l+(p<<2)>>2]|0))+c|0,n,r,u,a+-1|0,1,l),$n(u,1),t=i[u>>2]|1,i[u>>2]=t,e=e+c|0,Qn(e,n,r,u,p,1,l),a=p);(d|0)==19&&(d=0,t=er(u)|0,Zn(u,t),e=e+c|0,a=t+a|0,t=i[u>>2]|0)}}while(0);M=f}function Xn(e,t,n,r,a){e|=0,t|=0,n|=0,r|=0,a|=0;var o=0,s=0,c=0,l=0,u=0,d=0,f=0;f=M,M=M+240|0,d=f,i[d>>2]=e;a:do if((r|0)>1)for(u=0-t|0,c=e,o=r,r=1,s=e;;){if(c=c+u|0,l=o+-2|0,e=c+(0-(i[a+(l<<2)>>2]|0))|0,(jr[n&3](s,e)|0)>-1&&(jr[n&3](s,c)|0)>-1||(s=d+(r<<2)|0,(jr[n&3](e,c)|0)>-1?(i[s>>2]=e,o=o+-1|0):(i[s>>2]=c,e=c,o=l),r=r+1|0,(o|0)<=1))break a;c=e,s=i[d>>2]|0}else r=1;while(0);nr(t,d,r),M=f}function Zn(e,t){e|=0,t|=0;var n=0,r=0,a=0;a=e+4|0,t>>>0>31?(r=i[a>>2]|0,i[e>>2]=r,i[a>>2]=0,t=t+-32|0,n=0):(n=i[a>>2]|0,r=i[e>>2]|0),i[e>>2]=n<<32-t|r>>>t,i[a>>2]=n>>>t}function Qn(e,t,n,r,a,o,s){e|=0,t|=0,n|=0,r|=0,a|=0,o|=0,s|=0;var c=0,l=0,u=0,d=0,f=0,p=0,m=0,h=0;m=M,M=M+240|0,f=m+232|0,p=m,h=i[r>>2]|0,i[f>>2]=h,l=i[r+4>>2]|0,u=f+4|0,i[u>>2]=l,i[p>>2]=e;a:do if((h|0)!=1|(l|0)!=0&&(d=0-t|0,c=e+(0-(i[s+(a<<2)>>2]|0))|0,(jr[n&3](c,e)|0)>=1))for(r=1,o=(o|0)==0,l=c;;){if(o&(a|0)>1){if(o=e+d|0,c=i[s+(a+-2<<2)>>2]|0,(jr[n&3](o,l)|0)>-1){c=10;break a}if((jr[n&3](o+(0-c)|0,l)|0)>-1){c=10;break a}}if(o=r+1|0,i[p+(r<<2)>>2]=l,h=er(f)|0,Zn(f,h),a=h+a|0,!((i[f>>2]|0)!=1|(i[u>>2]|0)!=0)){r=o,e=l,c=10;break a}if(e=l+(0-(i[s+(a<<2)>>2]|0))|0,(jr[n&3](e,i[p>>2]|0)|0)<1){e=l,r=o,o=0,c=9;break}else h=l,r=o,o=1,l=e,e=h}else r=1,c=9;while(0);(c|0)==9&&!(o|0)&&(c=10),(c|0)==10&&(nr(t,p,r),Xn(e,t,n,a,s)),M=m}function $n(e,t){e|=0,t|=0;var n=0,r=0,a=0;a=e+4|0,t>>>0>31?(r=i[e>>2]|0,i[a>>2]=r,i[e>>2]=0,t=t+-32|0,n=0):(n=i[e>>2]|0,r=i[a>>2]|0),i[a>>2]=n>>>(32-t|0)|r<>2]=n<>2]|0)+-1|0)|0,t?t|0:(t=tr(i[e+4>>2]|0)|0,(t|0?t+32|0:0)|0)}function tr(e){e|=0;var t=0;if(e)if(e&1)e=0;else for(t=e,e=0;e=e+1|0,!(t&2);)t>>>=1;else e=32;return e|0}function nr(e,t,n){e|=0,t|=0,n|=0;var r=0,a=0,o=0,s=0,c=0;s=M,M=M+256|0,r=s;a:do if((n|0)>=2&&(o=t+(n<<2)|0,i[o>>2]=r,e|0))for(;;){a=e>>>0<256?e:256,wr(r|0,i[t>>2]|0,a|0)|0,r=0;do c=t+(r<<2)|0,r=r+1|0,wr(i[c>>2]|0,i[t+(r<<2)>>2]|0,a|0)|0,i[c>>2]=(i[c>>2]|0)+a;while((r|0)!=(n|0));if(e=e-a|0,!e)break a;r=i[o>>2]|0}while(0);M=s}function rr(e){return e=+e,~~+Dr(+e)|0}function ir(e){e|=0;var t=0,n=0,r=0,a=0,o=0,s=0,c=0,l=0,u=0,d=0,f=0,p=0,m=0,h=0,g=0,_=0,v=0,y=0,b=0,x=0,S=0;S=M,M=M+16|0,p=S;do if(e>>>0<245){if(u=e>>>0<11?16:e+11&-8,e=u>>>3,f=i[6921]|0,n=f>>>e,n&3|0)return t=(n&1^1)+e|0,e=27724+(t<<1<<2)|0,n=e+8|0,r=i[n>>2]|0,a=r+8|0,o=i[a>>2]|0,(o|0)==(e|0)?i[6921]=f&~(1<>2]=e,i[n>>2]=o),x=t<<3,i[r+4>>2]=x|3,x=r+x+4|0,i[x>>2]=i[x>>2]|1,x=a,M=S,x|0;if(d=i[6923]|0,u>>>0>d>>>0){if(n|0)return t=2<>>12&16,t>>>=c,n=t>>>5&8,t>>>=n,o=t>>>2&4,t>>>=o,e=t>>>1&2,t>>>=e,r=t>>>1&1,r=(n|c|o|e|r)+(t>>>r)|0,t=27724+(r<<1<<2)|0,e=t+8|0,o=i[e>>2]|0,c=o+8|0,n=i[c>>2]|0,(n|0)==(t|0)?(e=f&~(1<>2]=t,i[e>>2]=n,e=f),x=r<<3,s=x-u|0,i[o+4>>2]=u|3,a=o+u|0,i[a+4>>2]=s|1,i[o+x>>2]=s,d|0&&(r=i[6926]|0,t=d>>>3,n=27724+(t<<1<<2)|0,t=1<>2]|0):(i[6921]=e|t,t=n,e=n+8|0),i[e>>2]=r,i[t+12>>2]=r,i[r+8>>2]=t,i[r+12>>2]=n),i[6923]=s,i[6926]=a,x=c,M=S,x|0;if(o=i[6922]|0,o){for(n=(o&0-o)+-1|0,a=n>>>12&16,n>>>=a,r=n>>>5&8,n>>>=r,s=n>>>2&4,n>>>=s,c=n>>>1&2,n>>>=c,l=n>>>1&1,l=i[27988+((r|a|s|c|l)+(n>>>l)<<2)>>2]|0,n=l,c=l,l=(i[l+4>>2]&-8)-u|0;e=i[n+16>>2]|0,!(!e&&(e=i[n+20>>2]|0,!e));)s=(i[e+4>>2]&-8)-u|0,a=s>>>0>>0,n=e,c=a?e:c,l=a?s:l;if(s=c+u|0,s>>>0>c>>>0){a=i[c+24>>2]|0,t=i[c+12>>2]|0;do if((t|0)==(c|0)){if(e=c+20|0,t=i[e>>2]|0,!t&&(e=c+16|0,t=i[e>>2]|0,!t)){n=0;break}for(;;)if(r=t+20|0,n=i[r>>2]|0,n)t=n,e=r;else if(r=t+16|0,n=i[r>>2]|0,n)t=n,e=r;else break;i[e>>2]=0,n=t}else n=i[c+8>>2]|0,i[n+12>>2]=t,i[t+8>>2]=n,n=t;while(0);do if(a|0){if(t=i[c+28>>2]|0,e=27988+(t<<2)|0,(c|0)==(i[e>>2]|0)){if(i[e>>2]=n,!n){i[6922]=o&~(1<>2]|0)==(c|0)?x:a+20|0)>>2]=n,!n)break;i[n+24>>2]=a,t=i[c+16>>2]|0,t|0&&(i[n+16>>2]=t,i[t+24>>2]=n),t=i[c+20>>2]|0,t|0&&(i[n+20>>2]=t,i[t+24>>2]=n)}while(0);return l>>>0<16?(x=l+u|0,i[c+4>>2]=x|3,x=c+x+4|0,i[x>>2]=i[x>>2]|1):(i[c+4>>2]=u|3,i[s+4>>2]=l|1,i[s+l>>2]=l,d|0&&(r=i[6926]|0,t=d>>>3,n=27724+(t<<1<<2)|0,t=1<>2]|0):(i[6921]=t|f,t=n,e=n+8|0),i[e>>2]=r,i[t+12>>2]=r,i[r+8>>2]=t,i[r+12>>2]=n),i[6923]=l,i[6926]=s),x=c+8|0,M=S,x|0}else f=u}else f=u}else f=u}else if(e>>>0<=4294967231)if(e=e+11|0,u=e&-8,r=i[6922]|0,r){a=0-u|0,e>>>=8,e?u>>>0>16777215?l=31:(f=(e+1048320|0)>>>16&8,g=e<>>16&4,g<<=c,l=(g+245760|0)>>>16&2,l=14-(c|f|l)+(g<>>15)|0,l=u>>>(l+7|0)&1|l<<1):l=0,n=i[27988+(l<<2)>>2]|0;a:do if(!n)n=0,e=0,g=61;else for(e=0,c=u<<((l|0)==31?0:25-(l>>>1)|0),o=0;;){if(s=(i[n+4>>2]&-8)-u|0,s>>>0>>0)if(s)e=n,a=s;else{e=n,a=0,g=65;break a}if(g=i[n+20>>2]|0,n=i[n+16+(c>>>31<<2)>>2]|0,o=(g|0)==0|(g|0)==(n|0)?o:g,n)c<<=1;else{n=o,g=61;break}}while(0);if((g|0)==61){if((n|0)==0&(e|0)==0){if(e=2<>>12&16,f>>>=s,o=f>>>5&8,f>>>=o,c=f>>>2&4,f>>>=c,l=f>>>1&2,f>>>=l,n=f>>>1&1,e=0,n=i[27988+((o|s|c|l|n)+(f>>>n)<<2)>>2]|0}n?g=65:(c=e,s=a)}if((g|0)==65)for(o=n;;)if(f=(i[o+4>>2]&-8)-u|0,n=f>>>0>>0,a=n?f:a,e=n?o:e,n=i[o+16>>2]|0,n||=i[o+20>>2]|0,n)o=n;else{c=e,s=a;break}if(c|0&&s>>>0<((i[6923]|0)-u|0)>>>0&&(d=c+u|0,d>>>0>c>>>0)){o=i[c+24>>2]|0,t=i[c+12>>2]|0;do if((t|0)==(c|0)){if(e=c+20|0,t=i[e>>2]|0,!t&&(e=c+16|0,t=i[e>>2]|0,!t)){t=0;break}for(;;)if(a=t+20|0,n=i[a>>2]|0,n)t=n,e=a;else if(a=t+16|0,n=i[a>>2]|0,n)t=n,e=a;else break;i[e>>2]=0}else x=i[c+8>>2]|0,i[x+12>>2]=t,i[t+8>>2]=x;while(0);do if(o){if(e=i[c+28>>2]|0,n=27988+(e<<2)|0,(c|0)==(i[n>>2]|0)){if(i[n>>2]=t,!t){r&=~(1<>2]|0)==(c|0)?x:o+20|0)>>2]=t,!t)break;i[t+24>>2]=o,e=i[c+16>>2]|0,e|0&&(i[t+16>>2]=e,i[e+24>>2]=t),e=i[c+20>>2]|0,e&&(i[t+20>>2]=e,i[e+24>>2]=t)}while(0);b:do if(s>>>0<16)x=s+u|0,i[c+4>>2]=x|3,x=c+x+4|0,i[x>>2]=i[x>>2]|1;else{if(i[c+4>>2]=u|3,i[d+4>>2]=s|1,i[d+s>>2]=s,t=s>>>3,s>>>0<256){n=27724+(t<<1<<2)|0,e=i[6921]|0,t=1<>2]|0):(i[6921]=e|t,t=n,e=n+8|0),i[e>>2]=d,i[t+12>>2]=d,i[d+8>>2]=t,i[d+12>>2]=n;break}if(t=s>>>8,t?s>>>0>16777215?n=31:(b=(t+1048320|0)>>>16&8,x=t<>>16&4,x<<=y,n=(x+245760|0)>>>16&2,n=14-(y|b|n)+(x<>>15)|0,n=s>>>(n+7|0)&1|n<<1):n=0,t=27988+(n<<2)|0,i[d+28>>2]=n,e=d+16|0,i[e+4>>2]=0,i[e>>2]=0,e=1<>2]=d,i[d+24>>2]=t,i[d+12>>2]=d,i[d+8>>2]=d;break}t=i[t>>2]|0;c:do if((i[t+4>>2]&-8|0)!=(s|0)){for(r=s<<((n|0)==31?0:25-(n>>>1)|0);n=t+16+(r>>>31<<2)|0,e=i[n>>2]|0,e;)if((i[e+4>>2]&-8|0)==(s|0)){t=e;break c}else r<<=1,t=e;i[n>>2]=d,i[d+24>>2]=t,i[d+12>>2]=d,i[d+8>>2]=d;break b}while(0);b=t+8|0,x=i[b>>2]|0,i[x+12>>2]=d,i[b>>2]=d,i[d+8>>2]=x,i[d+12>>2]=t,i[d+24>>2]=0}while(0);return x=c+8|0,M=S,x|0}else f=u}else f=u;else f=-1;while(0);if(n=i[6923]|0,n>>>0>=f>>>0)return t=n-f|0,e=i[6926]|0,t>>>0>15?(x=e+f|0,i[6926]=x,i[6923]=t,i[x+4>>2]=t|1,i[e+n>>2]=t,i[e+4>>2]=f|3):(i[6923]=0,i[6926]=0,i[e+4>>2]=n|3,x=e+n+4|0,i[x>>2]=i[x>>2]|1),x=e+8|0,M=S,x|0;if(s=i[6924]|0,s>>>0>f>>>0)return y=s-f|0,i[6924]=y,x=i[6927]|0,b=x+f|0,i[6927]=b,i[b+4>>2]=y|1,i[x+4>>2]=f|3,x=x+8|0,M=S,x|0;if(i[7039]|0?e=i[7041]|0:(i[7041]=4096,i[7040]=4096,i[7042]=-1,i[7043]=-1,i[7044]=0,i[7032]=0,i[7039]=p&-16^1431655768,e=4096),c=f+48|0,l=f+47|0,o=e+l|0,a=0-e|0,u=o&a,u>>>0<=f>>>0||(e=i[7031]|0,e|0&&(d=i[7029]|0,p=d+u|0,p>>>0<=d>>>0|p>>>0>e>>>0)))return x=0,M=S,x|0;d:do if(i[7032]&4)t=0,g=143;else{n=i[6927]|0;e:do if(n){for(r=28132;p=i[r>>2]|0,!(p>>>0<=n>>>0&&(p+(i[r+4>>2]|0)|0)>>>0>n>>>0);)if(e=i[r+8>>2]|0,e)r=e;else{g=128;break e}if(t=o-s&a,t>>>0<2147483647)if(e=Or(t|0)|0,(e|0)==((i[r>>2]|0)+(i[r+4>>2]|0)|0)){if((e|0)!=-1){s=t,o=e,g=145;break d}}else r=e,g=136;else t=0}else g=128;while(0);do if((g|0)==128)if(n=Or(0)|0,(n|0)!=-1&&(t=n,m=i[7040]|0,h=m+-1|0,t=(h&t|0?(h+t&0-m)-t|0:0)+u|0,m=i[7029]|0,h=t+m|0,t>>>0>f>>>0&t>>>0<2147483647)){if(p=i[7031]|0,p|0&&h>>>0<=m>>>0|h>>>0>p>>>0){t=0;break}if(e=Or(t|0)|0,(e|0)==(n|0)){s=t,o=n,g=145;break d}else r=e,g=136}else t=0;while(0);do if((g|0)==136){if(n=0-t|0,!(c>>>0>t>>>0&(t>>>0<2147483647&(r|0)!=-1)))if((r|0)==-1){t=0;break}else{s=t,o=r,g=145;break d}if(e=i[7041]|0,e=l-t+e&0-e,e>>>0>=2147483647){s=t,o=r,g=145;break d}if((Or(e|0)|0)==-1){Or(n|0)|0,t=0;break}else{s=e+t|0,o=r,g=145;break d}}while(0);i[7032]|=4,g=143}while(0);if((g|0)==143&&u>>>0<2147483647&&(y=Or(u|0)|0,h=Or(0)|0,_=h-y|0,v=_>>>0>(f+40|0)>>>0,!((y|0)==-1|v^1|y>>>0>>0&((y|0)!=-1&(h|0)!=-1)^1))&&(s=v?_:t,o=y,g=145),(g|0)==145){t=(i[7029]|0)+s|0,i[7029]=t,t>>>0>(i[7030]|0)>>>0&&(i[7030]=t),l=i[6927]|0;f:do if(l){for(t=28132;;){if(e=i[t>>2]|0,n=i[t+4>>2]|0,(o|0)==(e+n|0)){g=154;break}if(r=i[t+8>>2]|0,r)t=r;else break}if((g|0)==154&&(b=t+4|0,!(i[t+12>>2]&8|0))&&o>>>0>l>>>0&e>>>0<=l>>>0){i[b>>2]=n+s,x=(i[6924]|0)+s|0,y=l+8|0,y=y&7|0?0-y&7:0,b=l+y|0,y=x-y|0,i[6927]=b,i[6924]=y,i[b+4>>2]=y|1,i[l+x+4>>2]=40,i[6928]=i[7043];break}for(o>>>0<(i[6925]|0)>>>0&&(i[6925]=o),n=o+s|0,t=28132;;){if((i[t>>2]|0)==(n|0)){g=162;break}if(e=i[t+8>>2]|0,e)t=e;else break}if((g|0)==162&&!(i[t+12>>2]&8|0)){i[t>>2]=o,d=t+4|0,i[d>>2]=(i[d>>2]|0)+s,d=o+8|0,d=o+(d&7|0?0-d&7:0)|0,t=n+8|0,t=n+(t&7|0?0-t&7:0)|0,u=d+f|0,c=t-d-f|0,i[d+4>>2]=f|3;g:do if((l|0)==(t|0))x=(i[6924]|0)+c|0,i[6924]=x,i[6927]=u,i[u+4>>2]=x|1;else{if((i[6926]|0)==(t|0)){x=(i[6923]|0)+c|0,i[6923]=x,i[6926]=u,i[u+4>>2]=x|1,i[u+x>>2]=x;break}if(e=i[t+4>>2]|0,(e&3|0)==1){s=e&-8,r=e>>>3;h:do if(e>>>0<256)if(e=i[t+8>>2]|0,n=i[t+12>>2]|0,(n|0)==(e|0)){i[6921]&=~(1<>2]=n,i[n+8>>2]=e;break}else{o=i[t+24>>2]|0,e=i[t+12>>2]|0;do if((e|0)==(t|0)){if(n=t+16|0,r=n+4|0,e=i[r>>2]|0,e)n=r;else if(e=i[n>>2]|0,!e){e=0;break}for(;;)if(a=e+20|0,r=i[a>>2]|0,r)e=r,n=a;else if(a=e+16|0,r=i[a>>2]|0,r)e=r,n=a;else break;i[n>>2]=0}else x=i[t+8>>2]|0,i[x+12>>2]=e,i[e+8>>2]=x;while(0);if(!o)break;n=i[t+28>>2]|0,r=27988+(n<<2)|0;do if((i[r>>2]|0)!=(t|0)){if(x=o+16|0,i[((i[x>>2]|0)==(t|0)?x:o+20|0)>>2]=e,!e)break h}else{if(i[r>>2]=e,e|0)break;i[6922]&=~(1<>2]=o,n=t+16|0,r=i[n>>2]|0,r|0&&(i[e+16>>2]=r,i[r+24>>2]=e),n=i[n+4>>2]|0,!n)break;i[e+20>>2]=n,i[n+24>>2]=e}while(0);t=t+s|0,a=s+c|0}else a=c;if(t=t+4|0,i[t>>2]=i[t>>2]&-2,i[u+4>>2]=a|1,i[u+a>>2]=a,t=a>>>3,a>>>0<256){n=27724+(t<<1<<2)|0,e=i[6921]|0,t=1<>2]|0):(i[6921]=e|t,t=n,e=n+8|0),i[e>>2]=u,i[t+12>>2]=u,i[u+8>>2]=t,i[u+12>>2]=n;break}t=a>>>8;do if(!t)r=0;else{if(a>>>0>16777215){r=31;break}b=(t+1048320|0)>>>16&8,x=t<>>16&4,x<<=y,r=(x+245760|0)>>>16&2,r=14-(y|b|r)+(x<>>15)|0,r=a>>>(r+7|0)&1|r<<1}while(0);if(t=27988+(r<<2)|0,i[u+28>>2]=r,e=u+16|0,i[e+4>>2]=0,i[e>>2]=0,e=i[6922]|0,n=1<>2]=u,i[u+24>>2]=t,i[u+12>>2]=u,i[u+8>>2]=u;break}t=i[t>>2]|0;i:do if((i[t+4>>2]&-8|0)!=(a|0)){for(r=a<<((r|0)==31?0:25-(r>>>1)|0);n=t+16+(r>>>31<<2)|0,e=i[n>>2]|0,e;)if((i[e+4>>2]&-8|0)==(a|0)){t=e;break i}else r<<=1,t=e;i[n>>2]=u,i[u+24>>2]=t,i[u+12>>2]=u,i[u+8>>2]=u;break g}while(0);b=t+8|0,x=i[b>>2]|0,i[x+12>>2]=u,i[b>>2]=u,i[u+8>>2]=x,i[u+12>>2]=t,i[u+24>>2]=0}while(0);return x=d+8|0,M=S,x|0}for(t=28132;e=i[t>>2]|0,!(e>>>0<=l>>>0&&(x=e+(i[t+4>>2]|0)|0,x>>>0>l>>>0));)t=i[t+8>>2]|0;a=x+-47|0,e=a+8|0,e=a+(e&7|0?0-e&7:0)|0,a=l+16|0,e=e>>>0>>0?l:e,t=e+8|0,n=s+-40|0,y=o+8|0,y=y&7|0?0-y&7:0,b=o+y|0,y=n-y|0,i[6927]=b,i[6924]=y,i[b+4>>2]=y|1,i[o+n+4>>2]=40,i[6928]=i[7043],n=e+4|0,i[n>>2]=27,i[t>>2]=i[7033],i[t+4>>2]=i[7034],i[t+8>>2]=i[7035],i[t+12>>2]=i[7036],i[7033]=o,i[7034]=s,i[7036]=0,i[7035]=t,t=e+24|0;do b=t,t=t+4|0,i[t>>2]=7;while((b+8|0)>>>0>>0);if((e|0)!=(l|0)){if(o=e-l|0,i[n>>2]=i[n>>2]&-2,i[l+4>>2]=o|1,i[e>>2]=o,t=o>>>3,o>>>0<256){n=27724+(t<<1<<2)|0,e=i[6921]|0,t=1<>2]|0):(i[6921]=e|t,t=n,e=n+8|0),i[e>>2]=l,i[t+12>>2]=l,i[l+8>>2]=t,i[l+12>>2]=n;break}if(t=o>>>8,t?o>>>0>16777215?r=31:(b=(t+1048320|0)>>>16&8,x=t<>>16&4,x<<=y,r=(x+245760|0)>>>16&2,r=14-(y|b|r)+(x<>>15)|0,r=o>>>(r+7|0)&1|r<<1):r=0,n=27988+(r<<2)|0,i[l+28>>2]=r,i[l+20>>2]=0,i[a>>2]=0,t=i[6922]|0,e=1<>2]=l,i[l+24>>2]=n,i[l+12>>2]=l,i[l+8>>2]=l;break}t=i[n>>2]|0;j:do if((i[t+4>>2]&-8|0)!=(o|0)){for(r=o<<((r|0)==31?0:25-(r>>>1)|0);n=t+16+(r>>>31<<2)|0,e=i[n>>2]|0,e;)if((i[e+4>>2]&-8|0)==(o|0)){t=e;break j}else r<<=1,t=e;i[n>>2]=l,i[l+24>>2]=t,i[l+12>>2]=l,i[l+8>>2]=l;break f}while(0);b=t+8|0,x=i[b>>2]|0,i[x+12>>2]=l,i[b>>2]=l,i[l+8>>2]=x,i[l+12>>2]=t,i[l+24>>2]=0}}else x=i[6925]|0,(x|0)==0|o>>>0>>0&&(i[6925]=o),i[7033]=o,i[7034]=s,i[7036]=0,i[6930]=i[7039],i[6929]=-1,i[6934]=27724,i[6933]=27724,i[6936]=27732,i[6935]=27732,i[6938]=27740,i[6937]=27740,i[6940]=27748,i[6939]=27748,i[6942]=27756,i[6941]=27756,i[6944]=27764,i[6943]=27764,i[6946]=27772,i[6945]=27772,i[6948]=27780,i[6947]=27780,i[6950]=27788,i[6949]=27788,i[6952]=27796,i[6951]=27796,i[6954]=27804,i[6953]=27804,i[6956]=27812,i[6955]=27812,i[6958]=27820,i[6957]=27820,i[6960]=27828,i[6959]=27828,i[6962]=27836,i[6961]=27836,i[6964]=27844,i[6963]=27844,i[6966]=27852,i[6965]=27852,i[6968]=27860,i[6967]=27860,i[6970]=27868,i[6969]=27868,i[6972]=27876,i[6971]=27876,i[6974]=27884,i[6973]=27884,i[6976]=27892,i[6975]=27892,i[6978]=27900,i[6977]=27900,i[6980]=27908,i[6979]=27908,i[6982]=27916,i[6981]=27916,i[6984]=27924,i[6983]=27924,i[6986]=27932,i[6985]=27932,i[6988]=27940,i[6987]=27940,i[6990]=27948,i[6989]=27948,i[6992]=27956,i[6991]=27956,i[6994]=27964,i[6993]=27964,i[6996]=27972,i[6995]=27972,x=s+-40|0,y=o+8|0,y=y&7|0?0-y&7:0,b=o+y|0,y=x-y|0,i[6927]=b,i[6924]=y,i[b+4>>2]=y|1,i[o+x+4>>2]=40,i[6928]=i[7043];while(0);if(t=i[6924]|0,t>>>0>f>>>0)return y=t-f|0,i[6924]=y,x=i[6927]|0,b=x+f|0,i[6927]=b,i[b+4>>2]=y|1,i[x+4>>2]=f|3,x=x+8|0,M=S,x|0}return x=Jn()|0,i[x>>2]=12,x=0,M=S,x|0}function ar(e){e|=0;var t=0,n=0,r=0,a=0,o=0,s=0,c=0,l=0;if(e){n=e+-8|0,a=i[6925]|0,e=i[e+-4>>2]|0,t=e&-8,l=n+t|0;do if(e&1)c=n,s=n;else{if(r=i[n>>2]|0,!(e&3)||(s=n+(0-r)|0,o=r+t|0,s>>>0>>0))return;if((i[6926]|0)==(s|0)){if(e=l+4|0,t=i[e>>2]|0,(t&3|0)!=3){c=s,t=o;break}i[6923]=o,i[e>>2]=t&-2,i[s+4>>2]=o|1,i[s+o>>2]=o;return}if(n=r>>>3,r>>>0<256)if(e=i[s+8>>2]|0,t=i[s+12>>2]|0,(t|0)==(e|0)){i[6921]&=~(1<>2]=t,i[t+8>>2]=e,c=s,t=o;break}a=i[s+24>>2]|0,e=i[s+12>>2]|0;do if((e|0)==(s|0)){if(t=s+16|0,n=t+4|0,e=i[n>>2]|0,e)t=n;else if(e=i[t>>2]|0,!e){e=0;break}for(;;)if(r=e+20|0,n=i[r>>2]|0,n)e=n,t=r;else if(r=e+16|0,n=i[r>>2]|0,n)e=n,t=r;else break;i[t>>2]=0}else c=i[s+8>>2]|0,i[c+12>>2]=e,i[e+8>>2]=c;while(0);if(a){if(t=i[s+28>>2]|0,n=27988+(t<<2)|0,(i[n>>2]|0)==(s|0)){if(i[n>>2]=e,!e){i[6922]&=~(1<>2]|0)==(s|0)?c:a+20|0)>>2]=e,!e){c=s,t=o;break}i[e+24>>2]=a,t=s+16|0,n=i[t>>2]|0,n|0&&(i[e+16>>2]=n,i[n+24>>2]=e),t=i[t+4>>2]|0,t?(i[e+20>>2]=t,i[t+24>>2]=e,c=s,t=o):(c=s,t=o)}else c=s,t=o}while(0);if(!(s>>>0>=l>>>0)&&(e=l+4|0,r=i[e>>2]|0,r&1)){if(r&2)i[e>>2]=r&-2,i[c+4>>2]=t|1,i[s+t>>2]=t,a=t;else{if((i[6927]|0)==(l|0)){if(l=(i[6924]|0)+t|0,i[6924]=l,i[6927]=c,i[c+4>>2]=l|1,(c|0)!=(i[6926]|0))return;i[6926]=0,i[6923]=0;return}if((i[6926]|0)==(l|0)){l=(i[6923]|0)+t|0,i[6923]=l,i[6926]=s,i[c+4>>2]=l|1,i[s+l>>2]=l;return}a=(r&-8)+t|0,n=r>>>3;do if(r>>>0<256)if(t=i[l+8>>2]|0,e=i[l+12>>2]|0,(e|0)==(t|0)){i[6921]&=~(1<>2]=e,i[e+8>>2]=t;break}else{o=i[l+24>>2]|0,e=i[l+12>>2]|0;do if((e|0)==(l|0)){if(t=l+16|0,n=t+4|0,e=i[n>>2]|0,e)t=n;else if(e=i[t>>2]|0,!e){n=0;break}for(;;)if(r=e+20|0,n=i[r>>2]|0,n)e=n,t=r;else if(r=e+16|0,n=i[r>>2]|0,n)e=n,t=r;else break;i[t>>2]=0,n=e}else n=i[l+8>>2]|0,i[n+12>>2]=e,i[e+8>>2]=n,n=e;while(0);if(o|0){if(e=i[l+28>>2]|0,t=27988+(e<<2)|0,(i[t>>2]|0)==(l|0)){if(i[t>>2]=n,!n){i[6922]&=~(1<>2]|0)==(l|0)?r:o+20|0)>>2]=n,!n)break;i[n+24>>2]=o,e=l+16|0,t=i[e>>2]|0,t|0&&(i[n+16>>2]=t,i[t+24>>2]=n),e=i[e+4>>2]|0,e|0&&(i[n+20>>2]=e,i[e+24>>2]=n)}}while(0);if(i[c+4>>2]=a|1,i[s+a>>2]=a,(c|0)==(i[6926]|0)){i[6923]=a;return}}if(e=a>>>3,a>>>0<256){n=27724+(e<<1<<2)|0,t=i[6921]|0,e=1<>2]|0):(i[6921]=t|e,e=n,t=n+8|0),i[t>>2]=c,i[e+12>>2]=c,i[c+8>>2]=e,i[c+12>>2]=n;return}e=a>>>8,e?a>>>0>16777215?r=31:(s=(e+1048320|0)>>>16&8,l=e<>>16&4,l<<=o,r=(l+245760|0)>>>16&2,r=14-(o|s|r)+(l<>>15)|0,r=a>>>(r+7|0)&1|r<<1):r=0,e=27988+(r<<2)|0,i[c+28>>2]=r,i[c+20>>2]=0,i[c+16>>2]=0,t=i[6922]|0,n=1<>2]=c,i[c+24>>2]=e,i[c+12>>2]=c,i[c+8>>2]=c;else{e=i[e>>2]|0;b:do if((i[e+4>>2]&-8|0)!=(a|0)){for(r=a<<((r|0)==31?0:25-(r>>>1)|0);n=e+16+(r>>>31<<2)|0,t=i[n>>2]|0,t;)if((i[t+4>>2]&-8|0)==(a|0)){e=t;break b}else r<<=1,e=t;i[n>>2]=c,i[c+24>>2]=e,i[c+12>>2]=c,i[c+8>>2]=c;break a}while(0);s=e+8|0,l=i[s>>2]|0,i[l+12>>2]=c,i[s>>2]=c,i[c+8>>2]=l,i[c+12>>2]=e,i[c+24>>2]=0}while(0);if(l=(i[6929]|0)+-1|0,i[6929]=l,!(l|0)){for(e=28140;e=i[e>>2]|0,e;)e=e+8|0;i[6929]=-1}}}}function or(e,t){e|=0,t|=0;var n=0;return e?(n=y(t,e)|0,(t|e)>>>0>65535&&(n=((n>>>0)/(e>>>0)|0)==(t|0)?n:-1)):n=0,e=ir(n)|0,!e||!(i[e+-4>>2]&3)||Er(e|0,0,n|0)|0,e|0}function sr(e,t){e|=0,t|=0;var n=0,r=0;return e?t>>>0>4294967231?(t=Jn()|0,i[t>>2]=12,t=0,t|0):(n=cr(e+-8|0,t>>>0<11?16:t+11&-8)|0,n|0?(t=n+8|0,t|0):(n=ir(t)|0,n?(r=i[e+-4>>2]|0,r=(r&-8)-(r&3|0?4:8)|0,wr(n|0,e|0,(r>>>0>>0?r:t)|0)|0,ar(e),t=n,t|0):(t=0,t|0))):(t=ir(t)|0,t|0)}function cr(e,t){e|=0,t|=0;var n=0,r=0,a=0,o=0,s=0,c=0,l=0,u=0,d=0,f=0;if(d=e+4|0,f=i[d>>2]|0,n=f&-8,c=e+n|0,!(f&3))return t>>>0<256?(e=0,e|0):(n>>>0>=(t+4|0)>>>0&&(n-t|0)>>>0<=i[7041]<<1>>>0||(e=0),e|0);if(n>>>0>=t>>>0)return n=n-t|0,n>>>0<=15?e|0:(u=e+t|0,i[d>>2]=f&1|t|2,i[u+4>>2]=n|3,f=c+4|0,i[f>>2]=i[f>>2]|1,lr(u,n),e|0);if((i[6927]|0)==(c|0))return u=(i[6924]|0)+n|0,n=u-t|0,r=e+t|0,u>>>0<=t>>>0?(e=0,e|0):(i[d>>2]=f&1|t|2,i[r+4>>2]=n|1,i[6927]=r,i[6924]=n,e|0);if((i[6926]|0)==(c|0))return r=(i[6923]|0)+n|0,r>>>0>>0?(e=0,e|0):(n=r-t|0,n>>>0>15?(u=e+t|0,r=e+r|0,i[d>>2]=f&1|t|2,i[u+4>>2]=n|1,i[r>>2]=n,r=r+4|0,i[r>>2]=i[r>>2]&-2,r=u):(i[d>>2]=f&1|r|2,r=e+r+4|0,i[r>>2]=i[r>>2]|1,r=0,n=0),i[6923]=n,i[6926]=r,e|0);if(r=i[c+4>>2]|0,r&2|0||(l=(r&-8)+n|0,l>>>0>>0))return e=0,e|0;u=l-t|0,a=r>>>3;do if(r>>>0<256)if(r=i[c+8>>2]|0,n=i[c+12>>2]|0,(n|0)==(r|0)){i[6921]&=~(1<>2]=n,i[n+8>>2]=r;break}else{s=i[c+24>>2]|0,n=i[c+12>>2]|0;do if((n|0)==(c|0)){if(r=c+16|0,a=r+4|0,n=i[a>>2]|0,n)r=a;else if(n=i[r>>2]|0,!n){a=0;break}for(;;)if(o=n+20|0,a=i[o>>2]|0,a)n=a,r=o;else if(o=n+16|0,a=i[o>>2]|0,a)n=a,r=o;else break;i[r>>2]=0,a=n}else a=i[c+8>>2]|0,i[a+12>>2]=n,i[n+8>>2]=a,a=n;while(0);if(s|0){if(n=i[c+28>>2]|0,r=27988+(n<<2)|0,(i[r>>2]|0)==(c|0)){if(i[r>>2]=a,!a){i[6922]&=~(1<>2]|0)==(c|0)?o:s+20|0)>>2]=a,!a)break;i[a+24>>2]=s,n=c+16|0,r=i[n>>2]|0,r|0&&(i[a+16>>2]=r,i[r+24>>2]=a),n=i[n+4>>2]|0,n|0&&(i[a+20>>2]=n,i[n+24>>2]=a)}}while(0);return u>>>0<16?(i[d>>2]=f&1|l|2,f=e+l+4|0,i[f>>2]=i[f>>2]|1,e|0):(c=e+t|0,i[d>>2]=f&1|t|2,i[c+4>>2]=u|3,f=e+l+4|0,i[f>>2]=i[f>>2]|1,lr(c,u),e|0)}function lr(e,t){e|=0,t|=0;var n=0,r=0,a=0,o=0,s=0,c=0;c=e+t|0,n=i[e+4>>2]|0;do if(n&1)s=e;else{if(a=i[e>>2]|0,!(n&3))return;if(s=e+(0-a)|0,t=a+t|0,(i[6926]|0)==(s|0)){if(e=c+4|0,n=i[e>>2]|0,(n&3|0)!=3)break;i[6923]=t,i[e>>2]=n&-2,i[s+4>>2]=t|1,i[c>>2]=t;return}if(r=a>>>3,a>>>0<256)if(e=i[s+8>>2]|0,n=i[s+12>>2]|0,(n|0)==(e|0)){i[6921]&=~(1<>2]=n,i[n+8>>2]=e;break}o=i[s+24>>2]|0,e=i[s+12>>2]|0;do if((e|0)==(s|0)){if(n=s+16|0,r=n+4|0,e=i[r>>2]|0,e)n=r;else if(e=i[n>>2]|0,!e){e=0;break}for(;;)if(a=e+20|0,r=i[a>>2]|0,r)e=r,n=a;else if(a=e+16|0,r=i[a>>2]|0,r)e=r,n=a;else break;i[n>>2]=0}else a=i[s+8>>2]|0,i[a+12>>2]=e,i[e+8>>2]=a;while(0);if(o){if(n=i[s+28>>2]|0,r=27988+(n<<2)|0,(i[r>>2]|0)==(s|0)){if(i[r>>2]=e,!e){i[6922]&=~(1<>2]|0)==(s|0)?a:o+20|0)>>2]=e,!e)break;i[e+24>>2]=o,n=s+16|0,r=i[n>>2]|0,r|0&&(i[e+16>>2]=r,i[r+24>>2]=e),n=i[n+4>>2]|0,n&&(i[e+20>>2]=n,i[n+24>>2]=e)}}while(0);if(e=c+4|0,r=i[e>>2]|0,r&2)i[e>>2]=r&-2,i[s+4>>2]=t|1,i[s+t>>2]=t,a=t;else{if((i[6927]|0)==(c|0)){if(c=(i[6924]|0)+t|0,i[6924]=c,i[6927]=s,i[s+4>>2]=c|1,(s|0)!=(i[6926]|0))return;i[6926]=0,i[6923]=0;return}if((i[6926]|0)==(c|0)){c=(i[6923]|0)+t|0,i[6923]=c,i[6926]=s,i[s+4>>2]=c|1,i[s+c>>2]=c;return}a=(r&-8)+t|0,n=r>>>3;do if(r>>>0<256)if(e=i[c+8>>2]|0,t=i[c+12>>2]|0,(t|0)==(e|0)){i[6921]&=~(1<>2]=t,i[t+8>>2]=e;break}else{o=i[c+24>>2]|0,t=i[c+12>>2]|0;do if((t|0)==(c|0)){if(e=c+16|0,n=e+4|0,t=i[n>>2]|0,t)e=n;else if(t=i[e>>2]|0,!t){n=0;break}for(;;)if(r=t+20|0,n=i[r>>2]|0,n)t=n,e=r;else if(r=t+16|0,n=i[r>>2]|0,n)t=n,e=r;else break;i[e>>2]=0,n=t}else n=i[c+8>>2]|0,i[n+12>>2]=t,i[t+8>>2]=n,n=t;while(0);if(o|0){if(t=i[c+28>>2]|0,e=27988+(t<<2)|0,(i[e>>2]|0)==(c|0)){if(i[e>>2]=n,!n){i[6922]&=~(1<>2]|0)==(c|0)?r:o+20|0)>>2]=n,!n)break;i[n+24>>2]=o,t=c+16|0,e=i[t>>2]|0,e|0&&(i[n+16>>2]=e,i[e+24>>2]=n),t=i[t+4>>2]|0,t|0&&(i[n+20>>2]=t,i[t+24>>2]=n)}}while(0);if(i[s+4>>2]=a|1,i[s+a>>2]=a,(s|0)==(i[6926]|0)){i[6923]=a;return}}if(t=a>>>3,a>>>0<256){n=27724+(t<<1<<2)|0,e=i[6921]|0,t=1<>2]|0):(i[6921]=e|t,t=n,e=n+8|0),i[e>>2]=s,i[t+12>>2]=s,i[s+8>>2]=t,i[s+12>>2]=n;return}if(t=a>>>8,t?a>>>0>16777215?r=31:(o=(t+1048320|0)>>>16&8,c=t<>>16&4,c<<=n,r=(c+245760|0)>>>16&2,r=14-(n|o|r)+(c<>>15)|0,r=a>>>(r+7|0)&1|r<<1):r=0,t=27988+(r<<2)|0,i[s+28>>2]=r,i[s+20>>2]=0,i[s+16>>2]=0,e=i[6922]|0,n=1<>2]=s,i[s+24>>2]=t,i[s+12>>2]=s,i[s+8>>2]=s;return}t=i[t>>2]|0;a:do if((i[t+4>>2]&-8|0)!=(a|0)){for(r=a<<((r|0)==31?0:25-(r>>>1)|0);n=t+16+(r>>>31<<2)|0,e=i[n>>2]|0,e;)if((i[e+4>>2]&-8|0)==(a|0)){t=e;break a}else r<<=1,t=e;i[n>>2]=s,i[s+24>>2]=t,i[s+12>>2]=s,i[s+8>>2]=s;return}while(0);o=t+8|0,c=i[o>>2]|0,i[c+12>>2]=s,i[o>>2]=s,i[s+8>>2]=c,i[s+12>>2]=t,i[s+24>>2]=0}function ur(e,t,n,r){return e|=0,t|=0,n|=0,r|=0,n=e+n>>>0,(w(t+r+(n>>>0>>0|0)>>>0|0),n|0)|0}function dr(e,t,n,r){return e|=0,t|=0,n|=0,r|=0,r=t-r-(n>>>0>e>>>0|0)>>>0,(w(r|0),e-n>>>0|0)|0}function fr(e){return e|=0,(e?31-(S(e^e-1)|0)|0:32)|0}function pr(e,t,n,r,a){e|=0,t|=0,n|=0,r|=0,a|=0;var o=0,s=0,c=0,l=0,u=0,d=0,f=0,p=0,m=0,h=0;if(d=e,l=t,u=l,s=n,p=r,c=p,!u)return o=(a|0)!=0,c?o?(i[a>>2]=e|0,i[a+4>>2]=t&0,p=0,a=0,(w(p|0),a)|0):(p=0,a=0,(w(p|0),a)|0):(o&&(i[a>>2]=(d>>>0)%(s>>>0),i[a+4>>2]=0),p=0,a=(d>>>0)/(s>>>0)>>>0,(w(p|0),a)|0);o=(c|0)==0;do if(s){if(!o){if(o=(S(c|0)|0)-(S(u|0)|0)|0,o>>>0<=31){f=o+1|0,c=31-o|0,t=o-31>>31,s=f,e=d>>>(f>>>0)&t|u<>>(f>>>0)&t,o=0,c=d<>2]=e|0,i[a+4>>2]=l|t&0,p=0,a=0,(w(p|0),a)|0):(p=0,a=0,(w(p|0),a)|0)}if(o=s-1|0,o&s|0){c=(S(s|0)|0)+33-(S(u|0)|0)|0,h=64-c|0,f=32-c|0,l=f>>31,m=c-32|0,t=m>>31,s=c,e=f-1>>31&u>>>(m>>>0)|(u<>>(c>>>0))&t,t&=u>>>(c>>>0),o=d<>>(m>>>0))&l|d<>31;break}return a|0&&(i[a>>2]=o&d,i[a+4>>2]=0),(s|0)==1?(m=l|t&0,h=e|0,(w(m|0),h)|0):(h=fr(s|0)|0,m=u>>>(h>>>0)|0,h=u<<32-h|d>>>(h>>>0)|0,(w(m|0),h)|0)}else{if(o)return a|0&&(i[a>>2]=(u>>>0)%(s>>>0),i[a+4>>2]=0),m=0,h=(u>>>0)/(s>>>0)>>>0,(w(m|0),h)|0;if(!d)return a|0&&(i[a>>2]=0,i[a+4>>2]=(u>>>0)%(c>>>0)),m=0,h=(u>>>0)/(c>>>0)>>>0,(w(m|0),h)|0;if(o=c-1|0,!(o&c))return a|0&&(i[a>>2]=e|0,i[a+4>>2]=o&u|t&0),m=0,h=u>>>((fr(c|0)|0)>>>0),(w(m|0),h)|0;if(o=(S(c|0)|0)-(S(u|0)|0)|0,o>>>0<=30){t=o+1|0,c=31-o|0,s=t,e=u<>>(t>>>0),t=u>>>(t>>>0),o=0,c=d<>2]=e|0,i[a+4>>2]=l|t&0,m=0,h=0,(w(m|0),h)|0):(m=0,h=0,(w(m|0),h)|0)}while(0);if(!s)u=c,l=0,c=0;else{f=n|0,d=p|r&0,u=ur(f|0,d|0,-1,-1)|0,n=T()|0,l=c,c=0;do r=l,l=o>>>31|l<<1,o=c|o<<1,r=e<<1|r>>>31|0,p=e>>>31|t<<1|0,dr(u|0,n|0,r|0,p|0)|0,h=T()|0,m=h>>31|((h|0)<0?-1:0)<<1,c=m&1,e=dr(r|0,p|0,m&f|0,(((h|0)<0?-1:0)>>31|((h|0)<0?-1:0)<<1)&d|0)|0,t=T()|0,s=s-1|0;while(s|0);u=l,l=0}return s=0,a|0&&(i[a>>2]=e,i[a+4>>2]=t),m=(o|0)>>>31|(u|s)<<1|(s<<1|o>>>31)&0|l,h=(o<<1|0)&-2|c,(w(m|0),h)|0}function mr(e,t,n,r){e|=0,t|=0,n|=0,r|=0;var i=0,a=0,o=0,s=0,c=0,l=0;return l=t>>31|((t|0)<0?-1:0)<<1,c=((t|0)<0?-1:0)>>31|((t|0)<0?-1:0)<<1,a=r>>31|((r|0)<0?-1:0)<<1,i=((r|0)<0?-1:0)>>31|((r|0)<0?-1:0)<<1,s=dr(l^e|0,c^t|0,l|0,c|0)|0,o=T()|0,e=a^l,t=i^c,dr((pr(s,o,dr(a^n|0,i^r|0,a|0,i|0)|0,T()|0,0)|0)^e|0,(T()|0)^t|0,e|0,t|0)|0}function hr(e,t){e|=0,t|=0;var n=0,r=0,i=0,a=0;return a=e&65535,i=t&65535,n=y(i,a)|0,r=e>>>16,e=(n>>>16)+(y(i,r)|0)|0,i=t>>>16,t=y(i,a)|0,(w((e>>>16)+(y(i,r)|0)+(((e&65535)+t|0)>>>16)|0),e+t<<16|n&65535|0)|0}function gr(e,t,n,r){e|=0,t|=0,n|=0,r|=0;var i=0,a=0;return i=e,a=n,n=hr(i,a)|0,e=T()|0,(w((y(t,a)|0)+(y(r,i)|0)+e|e&0|0),n|0)|0}function _r(e,t,n,r){e|=0,t|=0,n|=0,r|=0;var a=0,o=0,s=0,c=0,l=0,u=0;return a=M,M=M+16|0,c=a|0,s=t>>31|((t|0)<0?-1:0)<<1,o=((t|0)<0?-1:0)>>31|((t|0)<0?-1:0)<<1,u=r>>31|((r|0)<0?-1:0)<<1,l=((r|0)<0?-1:0)>>31|((r|0)<0?-1:0)<<1,e=dr(s^e|0,o^t|0,s|0,o|0)|0,t=T()|0,pr(e,t,dr(u^n|0,l^r|0,u|0,l|0)|0,T()|0,c)|0,r=dr(i[c>>2]^s|0,i[c+4>>2]^o|0,s|0,o|0)|0,n=T()|0,M=a,(w(n|0),r)|0}function vr(e,t,n,r){e|=0,t|=0,n|=0,r|=0;var a=0,o=0;return o=M,M=M+16|0,a=o|0,pr(e,t,n,r,a)|0,M=o,(w(i[a+4>>2]|0),i[a>>2]|0)|0}function yr(e,t,n){return e|=0,t|=0,n|=0,(n|0)<32?(w(t>>n|0),e>>>n|(t&(1<>n-32|0)}function z(e,t,n){return e|=0,t|=0,n|=0,(n|0)<32?(w(t>>>n|0),e>>>n|(t&(1<>>n-32|0)}function B(e,t,n){return e|=0,t|=0,n|=0,(n|0)<32?(w(t<>>32-n|0),e<=0?+c(e+.5):+v(e-.5)}function wr(e,t,n){e|=0,t|=0,n|=0;var a=0,o=0,s=0;if((n|0)>=8192)return k(e|0,t|0,n|0)|0,e|0;if(s=e|0,o=e+n|0,(e&3)==(t&3)){for(;e&3;){if(!n)return s|0;r[e>>0]=r[t>>0]|0,e=e+1|0,t=t+1|0,n=n-1|0}for(n=o&-4|0,a=n-64|0;(e|0)<=(a|0);)i[e>>2]=i[t>>2],i[e+4>>2]=i[t+4>>2],i[e+8>>2]=i[t+8>>2],i[e+12>>2]=i[t+12>>2],i[e+16>>2]=i[t+16>>2],i[e+20>>2]=i[t+20>>2],i[e+24>>2]=i[t+24>>2],i[e+28>>2]=i[t+28>>2],i[e+32>>2]=i[t+32>>2],i[e+36>>2]=i[t+36>>2],i[e+40>>2]=i[t+40>>2],i[e+44>>2]=i[t+44>>2],i[e+48>>2]=i[t+48>>2],i[e+52>>2]=i[t+52>>2],i[e+56>>2]=i[t+56>>2],i[e+60>>2]=i[t+60>>2],e=e+64|0,t=t+64|0;for(;(e|0)<(n|0);)i[e>>2]=i[t>>2],e=e+4|0,t=t+4|0}else for(n=o-4|0;(e|0)<(n|0);)r[e>>0]=r[t>>0]|0,r[e+1>>0]=r[t+1>>0]|0,r[e+2>>0]=r[t+2>>0]|0,r[e+3>>0]=r[t+3>>0]|0,e=e+4|0,t=t+4|0;for(;(e|0)<(o|0);)r[e>>0]=r[t>>0]|0,e=e+1|0,t=t+1|0;return s|0}function Tr(e,t,n){e|=0,t|=0,n|=0;var i=0;if((t|0)<(e|0)&(e|0)<(t+n|0)){for(i=e,t=t+n|0,e=e+n|0;(n|0)>0;)e=e-1|0,t=t-1|0,n=n-1|0,r[e>>0]=r[t>>0]|0;e=i}else wr(e,t,n)|0;return e|0}function Er(e,t,n){e|=0,t|=0,n|=0;var a=0,o=0,s=0,c=0;if(s=e+n|0,t&=255,(n|0)>=67){for(;e&3;)r[e>>0]=t,e=e+1|0;for(a=s&-4|0,c=t|t<<8|t<<16|t<<24,o=a-64|0;(e|0)<=(o|0);)i[e>>2]=c,i[e+4>>2]=c,i[e+8>>2]=c,i[e+12>>2]=c,i[e+16>>2]=c,i[e+20>>2]=c,i[e+24>>2]=c,i[e+28>>2]=c,i[e+32>>2]=c,i[e+36>>2]=c,i[e+40>>2]=c,i[e+44>>2]=c,i[e+48>>2]=c,i[e+52>>2]=c,i[e+56>>2]=c,i[e+60>>2]=c,e=e+64|0;for(;(e|0)<(a|0);)i[e>>2]=c,e=e+4|0}for(;(e|0)<(s|0);)r[e>>0]=t,e=e+1|0;return s-n|0}function Dr(e){return e=+e,e>=0?+c(e+.5):+v(e-.5)}function Or(e){e|=0;var t=0,n=0,r=0;return r=O()|0,n=i[s>>2]|0,t=n+e|0,(e|0)>0&(t|0)<(n|0)|(t|0)<0?(j(t|0)|0,D(12),-1):(t|0)>(r|0)&&!(A(t|0)|0)?(D(12),-1):(i[s>>2]=t,n|0)}function kr(e,t,n){return e|=0,t|=0,n|=0,jr[e&3](t|0,n|0)|0}function Ar(e,t){return e|=0,t|=0,C(0),0}var jr=[Ar,We,Ke,qe];return{___divdi3:mr,___muldi3:gr,___remdi3:_r,___uremdi3:vr,_areNeighborCells:Je,_bitshift64Ashr:yr,_bitshift64Lshr:z,_bitshift64Shl:B,_calloc:or,_cellAreaKm2:be,_cellAreaM2:xe,_cellAreaRads2:ye,_cellToBoundary:Bt,_cellToCenterChild:wt,_cellToChildPos:I,_cellToChildren:St,_cellToChildrenSize:bt,_cellToLatLng:zt,_cellToLocalIj:fn,_cellToParent:yt,_cellToVertex:Wn,_cellToVertexes:Gn,_cellsToDirectedEdge:Ye,_cellsToLinkedMultiPolygon:_e,_childPosToCell:Wt,_compactCells:Tt,_constructCell:ht,_destroyLinkedMultiPolygon:cn,_directedEdgeToBoundary:tt,_directedEdgeToCells:$e,_edgeLengthKm:on,_edgeLengthM:sn,_edgeLengthRads:an,_emscripten_replace_memory:N,_free:ar,_getBaseCellNumber:pt,_getDirectedEdgeDestination:Ze,_getDirectedEdgeOrigin:Xe,_getHexagonAreaAvgKm2:$t,_getHexagonAreaAvgM2:en,_getHexagonEdgeLengthAvgKm:tn,_getHexagonEdgeLengthAvgM:nn,_getIcosahedronFaces:Ht,_getIndexDigit:mt,_getNumCells:rn,_getPentagons:F,_getRes0Cells:Me,_getResolution:ft,_greatCircleDistanceKm:Zt,_greatCircleDistanceM:Qt,_greatCircleDistanceRads:Xt,_gridDisk:ae,_gridDiskDistances:oe,_gridDistance:mn,_gridPathCells:gn,_gridPathCellsSize:hn,_gridRing:ue,_gridRingUnsafe:de,_i64Add:ur,_i64Subtract:dr,_isPentagon:xt,_isResClassIII:Ot,_isValidCell:gt,_isValidDirectedEdge:Qe,_isValidIndex:_t,_isValidVertex:qn,_latLngToCell:It,_llvm_ctlz_i64:br,_llvm_maxnum_f64:xr,_llvm_minnum_f64:Sr,_llvm_round_f64:Cr,_localIjToCell:pn,_malloc:ir,_maxFaceCount:Vt,_maxGridDiskSize:ie,_maxPolygonToCellsSize:me,_maxPolygonToCellsSizeExperimental:Cn,_memcpy:wr,_memmove:Tr,_memset:Er,_originToDirectedEdges:et,_pentagonCount:Ut,_polygonToCells:ge,_polygonToCellsExperimental:L,_readInt64AsDoubleFromPointer:Rn,_res0CellCount:je,_reverseDirectedEdge:nt,_round:Dr,_sbrk:Or,_sizeOfCellBoundary:Nn,_sizeOfCoordIJ:Ln,_sizeOfGeoLoop:Pn,_sizeOfGeoPolygon:Fn,_sizeOfH3Index:jn,_sizeOfLatLng:Mn,_sizeOfLinkedGeoPolygon:In,_uncompactCells:Et,_uncompactCellsSize:Dt,_vertexToLatLng:Kn,dynCall_iii:kr,establishStackSpace:re,stackAlloc:ee,stackRestore:ne,stackSave:te}})({Math,Int8Array,Int32Array,Uint8Array,Float32Array,Float64Array},{a:tt,b:d,c:f,d:P,e:Le,f:Fe,g:Ie,h:Be,i:Re,j:je,k:Me,l:ze,m:Ne,n:Pe,o:Ae,p:re},O);t.___divdi3=We.___divdi3,t.___muldi3=We.___muldi3,t.___remdi3=We.___remdi3,t.___uremdi3=We.___uremdi3,t._areNeighborCells=We._areNeighborCells,t._bitshift64Ashr=We._bitshift64Ashr,t._bitshift64Lshr=We._bitshift64Lshr,t._bitshift64Shl=We._bitshift64Shl,t._calloc=We._calloc,t._cellAreaKm2=We._cellAreaKm2,t._cellAreaM2=We._cellAreaM2,t._cellAreaRads2=We._cellAreaRads2,t._cellToBoundary=We._cellToBoundary,t._cellToCenterChild=We._cellToCenterChild,t._cellToChildPos=We._cellToChildPos,t._cellToChildren=We._cellToChildren,t._cellToChildrenSize=We._cellToChildrenSize,t._cellToLatLng=We._cellToLatLng,t._cellToLocalIj=We._cellToLocalIj,t._cellToParent=We._cellToParent,t._cellToVertex=We._cellToVertex,t._cellToVertexes=We._cellToVertexes,t._cellsToDirectedEdge=We._cellsToDirectedEdge,t._cellsToLinkedMultiPolygon=We._cellsToLinkedMultiPolygon,t._childPosToCell=We._childPosToCell,t._compactCells=We._compactCells,t._constructCell=We._constructCell,t._destroyLinkedMultiPolygon=We._destroyLinkedMultiPolygon,t._directedEdgeToBoundary=We._directedEdgeToBoundary,t._directedEdgeToCells=We._directedEdgeToCells,t._edgeLengthKm=We._edgeLengthKm,t._edgeLengthM=We._edgeLengthM,t._edgeLengthRads=We._edgeLengthRads;var Ge=t._emscripten_replace_memory=We._emscripten_replace_memory;t._free=We._free,t._getBaseCellNumber=We._getBaseCellNumber,t._getDirectedEdgeDestination=We._getDirectedEdgeDestination,t._getDirectedEdgeOrigin=We._getDirectedEdgeOrigin,t._getHexagonAreaAvgKm2=We._getHexagonAreaAvgKm2,t._getHexagonAreaAvgM2=We._getHexagonAreaAvgM2,t._getHexagonEdgeLengthAvgKm=We._getHexagonEdgeLengthAvgKm,t._getHexagonEdgeLengthAvgM=We._getHexagonEdgeLengthAvgM,t._getIcosahedronFaces=We._getIcosahedronFaces,t._getIndexDigit=We._getIndexDigit,t._getNumCells=We._getNumCells,t._getPentagons=We._getPentagons,t._getRes0Cells=We._getRes0Cells,t._getResolution=We._getResolution,t._greatCircleDistanceKm=We._greatCircleDistanceKm,t._greatCircleDistanceM=We._greatCircleDistanceM,t._greatCircleDistanceRads=We._greatCircleDistanceRads,t._gridDisk=We._gridDisk,t._gridDiskDistances=We._gridDiskDistances,t._gridDistance=We._gridDistance,t._gridPathCells=We._gridPathCells,t._gridPathCellsSize=We._gridPathCellsSize,t._gridRing=We._gridRing,t._gridRingUnsafe=We._gridRingUnsafe,t._i64Add=We._i64Add,t._i64Subtract=We._i64Subtract,t._isPentagon=We._isPentagon,t._isResClassIII=We._isResClassIII,t._isValidCell=We._isValidCell,t._isValidDirectedEdge=We._isValidDirectedEdge,t._isValidIndex=We._isValidIndex,t._isValidVertex=We._isValidVertex,t._latLngToCell=We._latLngToCell,t._llvm_ctlz_i64=We._llvm_ctlz_i64,t._llvm_maxnum_f64=We._llvm_maxnum_f64,t._llvm_minnum_f64=We._llvm_minnum_f64,t._llvm_round_f64=We._llvm_round_f64,t._localIjToCell=We._localIjToCell,t._malloc=We._malloc,t._maxFaceCount=We._maxFaceCount,t._maxGridDiskSize=We._maxGridDiskSize,t._maxPolygonToCellsSize=We._maxPolygonToCellsSize,t._maxPolygonToCellsSizeExperimental=We._maxPolygonToCellsSizeExperimental,t._memcpy=We._memcpy,t._memmove=We._memmove,t._memset=We._memset,t._originToDirectedEdges=We._originToDirectedEdges,t._pentagonCount=We._pentagonCount,t._polygonToCells=We._polygonToCells,t._polygonToCellsExperimental=We._polygonToCellsExperimental,t._readInt64AsDoubleFromPointer=We._readInt64AsDoubleFromPointer,t._res0CellCount=We._res0CellCount,t._reverseDirectedEdge=We._reverseDirectedEdge,t._round=We._round,t._sbrk=We._sbrk,t._sizeOfCellBoundary=We._sizeOfCellBoundary,t._sizeOfCoordIJ=We._sizeOfCoordIJ,t._sizeOfGeoLoop=We._sizeOfGeoLoop,t._sizeOfGeoPolygon=We._sizeOfGeoPolygon,t._sizeOfH3Index=We._sizeOfH3Index,t._sizeOfLatLng=We._sizeOfLatLng,t._sizeOfLinkedGeoPolygon=We._sizeOfLinkedGeoPolygon,t._uncompactCells=We._uncompactCells,t._uncompactCellsSize=We._uncompactCellsSize,t._vertexToLatLng=We._vertexToLatLng,t.establishStackSpace=We.establishStackSpace;var Ke=t.stackAlloc=We.stackAlloc,qe=t.stackRestore=We.stackRestore,Je=t.stackSave=We.stackSave;if(t.dynCall_iii=We.dynCall_iii,t.asm=We,t.cwrap=b,t.setValue=m,t.getValue=h,Te){De(Te)||(Te=o(Te)),Ce(`memory initializer`);var Ye=function(e){e.byteLength&&(e=new Uint8Array(e)),A.set(e,p),t.memoryInitializerRequest&&delete t.memoryInitializerRequest.response,we(`memory initializer`)},Xe=function(){s(Te,Ye,function(){throw`could not load memory initializer `+Te})},Ze=Ue(Te);if(Ze)Ye(Ze.buffer);else if(t.memoryInitializerRequest){var Qe=function(){var e=t.memoryInitializerRequest,n=e.response;if(e.status!==200&&e.status!==0){var r=Ue(t.memoryInitializerRequestURL);if(r)n=r.buffer;else{console.warn(`a problem seems to have happened with Module.memoryInitializerRequest, status: `+e.status+`, retrying `+Te),Xe();return}}Ye(n)};t.memoryInitializerRequest.response?setTimeout(Qe,0):t.memoryInitializerRequest.addEventListener(`load`,Qe)}else Xe()}var $e;Se=function e(){$e||et(),$e||(Se=e)};function et(e){if(e||=i,be>0||(ue(),be>0))return;function n(){$e||($e=!0,!g&&(de(),fe(),t.onRuntimeInitialized&&t.onRuntimeInitialized(),pe()))}t.setStatus?(t.setStatus(`Running...`),setTimeout(function(){setTimeout(function(){t.setStatus(``)},1),n()},1)):n()}t.run=et;function tt(e){throw t.onAbort&&t.onAbort(e),e+=``,c(e),l(e),g=!0,`abort(`+e+`). Build with -s ASSERTIONS=1 for more info.`}if(t.abort=tt,t.preInit)for(typeof t.preInit==`function`&&(t.preInit=[t.preInit]);t.preInit.length>0;)t.preInit.pop()();return et(),e}(typeof YT==`object`?YT:{}),XT=`number`,ZT=XT,QT=XT,$T=XT,eE=XT,tE=XT,nE=XT,rE=[[`sizeOfH3Index`,XT],[`sizeOfLatLng`,XT],[`sizeOfCellBoundary`,XT],[`sizeOfGeoLoop`,XT],[`sizeOfGeoPolygon`,XT],[`sizeOfLinkedGeoPolygon`,XT],[`sizeOfCoordIJ`,XT],[`readInt64AsDoubleFromPointer`,XT],[`isValidCell`,QT,[$T,eE]],[`isValidIndex`,QT,[$T,eE]],[`latLngToCell`,ZT,[XT,XT,tE,nE]],[`cellToLatLng`,ZT,[$T,eE,nE]],[`cellToBoundary`,ZT,[$T,eE,nE]],[`maxGridDiskSize`,ZT,[XT,nE]],[`gridDisk`,ZT,[$T,eE,XT,nE]],[`gridDiskDistances`,ZT,[$T,eE,XT,nE,nE]],[`gridRing`,ZT,[$T,eE,XT,nE]],[`gridRingUnsafe`,ZT,[$T,eE,XT,nE]],[`maxPolygonToCellsSize`,ZT,[nE,tE,XT,nE]],[`polygonToCells`,ZT,[nE,tE,XT,nE]],[`maxPolygonToCellsSizeExperimental`,ZT,[nE,tE,XT,nE]],[`polygonToCellsExperimental`,ZT,[nE,tE,XT,XT,XT,nE]],[`cellsToLinkedMultiPolygon`,ZT,[nE,XT,nE]],[`destroyLinkedMultiPolygon`,null,[nE]],[`compactCells`,ZT,[nE,nE,XT,XT]],[`uncompactCells`,ZT,[nE,XT,XT,nE,XT,tE]],[`uncompactCellsSize`,ZT,[nE,XT,XT,tE,nE]],[`isPentagon`,QT,[$T,eE]],[`isResClassIII`,QT,[$T,eE]],[`getBaseCellNumber`,XT,[$T,eE]],[`getResolution`,XT,[$T,eE]],[`getIndexDigit`,XT,[$T,eE,XT]],[`constructCell`,ZT,[XT,XT,nE,nE]],[`maxFaceCount`,ZT,[$T,eE,nE]],[`getIcosahedronFaces`,ZT,[$T,eE,nE]],[`cellToParent`,ZT,[$T,eE,tE,nE]],[`cellToChildren`,ZT,[$T,eE,tE,nE]],[`cellToCenterChild`,ZT,[$T,eE,tE,nE]],[`cellToChildrenSize`,ZT,[$T,eE,tE,nE]],[`cellToChildPos`,ZT,[$T,eE,tE,nE]],[`childPosToCell`,ZT,[XT,XT,$T,eE,tE,nE]],[`areNeighborCells`,ZT,[$T,eE,$T,eE,nE]],[`cellsToDirectedEdge`,ZT,[$T,eE,$T,eE,nE]],[`getDirectedEdgeOrigin`,ZT,[$T,eE,nE]],[`getDirectedEdgeDestination`,ZT,[$T,eE,nE]],[`isValidDirectedEdge`,QT,[$T,eE]],[`directedEdgeToCells`,ZT,[$T,eE,nE]],[`originToDirectedEdges`,ZT,[$T,eE,nE]],[`directedEdgeToBoundary`,ZT,[$T,eE,nE]],[`reverseDirectedEdge`,ZT,[$T,eE,nE]],[`gridDistance`,ZT,[$T,eE,$T,eE,nE]],[`gridPathCells`,ZT,[$T,eE,$T,eE,nE]],[`gridPathCellsSize`,ZT,[$T,eE,$T,eE,nE]],[`cellToLocalIj`,ZT,[$T,eE,$T,eE,XT,nE]],[`localIjToCell`,ZT,[$T,eE,nE,XT,nE]],[`getHexagonAreaAvgM2`,ZT,[tE,nE]],[`getHexagonAreaAvgKm2`,ZT,[tE,nE]],[`getHexagonEdgeLengthAvgM`,ZT,[tE,nE]],[`getHexagonEdgeLengthAvgKm`,ZT,[tE,nE]],[`greatCircleDistanceM`,XT,[nE,nE]],[`greatCircleDistanceKm`,XT,[nE,nE]],[`greatCircleDistanceRads`,XT,[nE,nE]],[`cellAreaM2`,ZT,[$T,eE,nE]],[`cellAreaKm2`,ZT,[$T,eE,nE]],[`cellAreaRads2`,ZT,[$T,eE,nE]],[`edgeLengthM`,ZT,[$T,eE,nE]],[`edgeLengthKm`,ZT,[$T,eE,nE]],[`edgeLengthRads`,ZT,[$T,eE,nE]],[`getNumCells`,ZT,[tE,nE]],[`getRes0Cells`,ZT,[nE]],[`res0CellCount`,XT],[`getPentagons`,ZT,[XT,nE]],[`pentagonCount`,XT],[`cellToVertex`,ZT,[$T,eE,XT,nE]],[`cellToVertexes`,ZT,[$T,eE,nE]],[`vertexToLatLng`,ZT,[$T,eE,nE]],[`isValidVertex`,QT,[$T,eE]]],iE=0,aE=1,oE=2,sE=3,cE=4,lE=5,uE=6,dE=7,fE=8,pE=9,mE=10,hE=11,gE=12,_E=13,vE=14,yE=15,bE=16,xE=17,SE=18,CE=19,wE={};wE[iE]=`Success`,wE[aE]=`The operation failed but a more specific error is not available`,wE[oE]=`Argument was outside of acceptable range`,wE[sE]=`Latitude or longitude arguments were outside of acceptable range`,wE[cE]=`Resolution argument was outside of acceptable range`,wE[lE]=`Cell argument was not valid`,wE[uE]=`Directed edge argument was not valid`,wE[dE]=`Undirected edge argument was not valid`,wE[fE]=`Vertex argument was not valid`,wE[pE]=`Pentagon distortion was encountered`,wE[mE]=`Duplicate input`,wE[hE]=`Cell arguments were not neighbors`,wE[gE]=`Cell arguments had incompatible resolutions`,wE[_E]=`Memory allocation failed`,wE[vE]=`Bounds of provided memory were insufficient`,wE[yE]=`Mode or flags argument was not valid`,wE[bE]=`Index argument was not valid`,wE[xE]=`Base cell number was outside of acceptable range`,wE[SE]=`Child indexing digits invalid`,wE[CE]=`Child indexing digits refer to a deleted subsequence`;var TE=1e3,EE=1001,DE=1002,OE={};OE[TE]=`Unknown unit`,OE[EE]=`Array length out of bounds`,OE[DE]=`Got unexpected null value for H3 index`;var kE=`Unknown error`;function AE(e,t,n){var r=n&&`value`in n,i=Error((e[t]||kE)+` (code: `+t+(r?`, value: `+n.value:``)+`)`);return i.code=t,i}function jE(e,t){return AE(wE,e,arguments.length===2?{value:t}:{})}function ME(e,t){return AE(OE,e,arguments.length===2?{value:t}:{})}function NE(e){if(e!==0)throw jE(e)}var PE={};rE.forEach(function(e){PE[e[0]]=YT.cwrap.apply(YT,e)});var FE=16,IE=4,LE=8,RE=8,zE=PE.sizeOfH3Index(),BE=PE.sizeOfLatLng(),VE=PE.sizeOfCellBoundary(),HE=PE.sizeOfGeoPolygon(),UE=PE.sizeOfGeoLoop();PE.sizeOfLinkedGeoPolygon(),PE.sizeOfCoordIJ();function WE(e){if(typeof e!=`number`||e<0||e>15||Math.floor(e)!==e)throw jE(cE,e);return e}function GE(e){if(!e)throw ME(DE);return e}var KE=2**32-1;function qE(e){if(e>KE)throw ME(EE,e);return e}var JE=/[^0-9a-fA-F]/;function YE(e){if(Array.isArray(e)&&e.length===2&&Number.isInteger(e[0])&&Number.isInteger(e[1]))return e;if(typeof e!=`string`||JE.test(e))return[0,0];var t=parseInt(e.substring(0,e.length-8),FE);return[parseInt(e.substring(e.length-8),FE),t]}function XE(e){if(e>=0)return e.toString(FE);e&=2147483647;var t=QE(8,e.toString(FE));return t=(parseInt(t[0],FE)+8).toString(FE)+t.substring(1),t}function ZE(e,t){return XE(t)+QE(8,XE(e))}function QE(e,t){for(var n=e-t.length,r=``,i=0;i0){s=YT._calloc(n,UE);for(var c=0;c0){for(var o=YT.getValue(e+r,`i32`),s=0;s0){let{width:n,height:r}=e.context;t.bufferWidth=n,t.bufferHeight=r}let{environmentIntensity:i,environmentRotation:a}=e.scene;t.environmentIntensity=i,t.environmentRotation=a.clone(),t.lights=this.getLightsData(e.lightsNode.getLights(),[]),this.renderObjects.set(e,t)}return t}getAttributesData(e){let t={};for(let n in e){let r=e[n];t[n]={id:r.isInterleavedBufferAttribute?r.data.uuid:r.id,version:r.isInterleavedBufferAttribute?r.data.version:r.version}}return t}containsNode(e){let t=e.material;for(let e in t)if(t[e]&&t[e].isNode)return!0;return!!(e.context.modelViewMatrix||e.context.modelNormalViewMatrix||e.context.getAO||e.context.getShadow)}getGeometryData(e){let t=yD.get(e);return t===void 0&&(t={_renderId:-1,_equal:!1,attributes:this.getAttributesData(e.attributes),indexId:e.index?e.index.id:null,indexVersion:e.index?e.index.version:null,drawRange:{start:e.drawRange.start,count:e.drawRange.count}},yD.set(e,t)),t}getMaterialData(e){let t=vD.get(e);if(t===void 0){t={_renderId:-1,_equal:!1};for(let n of this.refreshUniforms){let r=e[n];r!=null&&(typeof r==`object`&&r.clone!==void 0?r.isTexture===!0?t[n]={id:r.id,version:0}:t[n]=r.clone():t[n]=r)}vD.set(e,t)}return t}equals(e,t,n){let{object:r,material:i,geometry:a}=e,o=this.getRenderObjectData(e);if(o.worldMatrix.equals(r.matrixWorld)!==!0)return o.worldMatrix.copy(r.matrixWorld),!1;let s=this.getMaterialData(e.material);if(s._renderId!==n){for(let e in s._renderId=n,s){let t=s[e],n=i[e];if(e!==`_renderId`&&e!==`_equal`){if(t.equals!==void 0){if(t.equals(n)===!1)return t.copy(n),s._equal=!1,!1}else if(n.isTexture===!0){if(t.id!==n.id||t.version!==n.version)return t.id=n.id,t.version=n.version,s._equal=!1,!1}else if(t!==n)return s[e]=n,s._equal=!1,!1}}if(s.transmission>0){let{width:t,height:n}=e.context;if(o.bufferWidth!==t||o.bufferHeight!==n)return o.bufferWidth=t,o.bufferHeight=n,s._equal=!1,!1}s._equal=!0}else if(s._equal===!1)return!1;if(o.geometryId!==a.id)return o.geometryId=a.id,!1;let c=this.getGeometryData(e.geometry);if(c._renderId!==n){c._renderId=n;let e=a.attributes,t=c.attributes,r=0,i=0;for(let t in e)r++;for(let n in t){i++;let r=t[n],a=e[n];if(a===void 0)return delete t[n],c._equal=!1,!1;let o=a.isInterleavedBufferAttribute?a.data.uuid:a.id,s=a.isInterleavedBufferAttribute?a.data.version:a.version;if(r.id!==o||r.version!==s)return r.id=o,r.version=s,c._equal=!1,!1}if(i!==r)return c.attributes=this.getAttributesData(e),c._equal=!1,!1;let o=a.index,s=c.indexId,l=c.indexVersion,u=o?o.id:null,d=o?o.version:null;if(s!==u||l!==d)return c.indexId=u,c.indexVersion=d,c._equal=!1,!1;if(c.drawRange.start!==a.drawRange.start||c.drawRange.count!==a.drawRange.count)return c.drawRange.start=a.drawRange.start,c.drawRange.count=a.drawRange.count,c._equal=!1,!1;c._equal=!0}else if(c._equal===!1)return!1;if(o.morphTargetInfluences){let e=!1;for(let t=0;t{let n=e.match(t);if(!n)return null;let r=n[1]||n[2]||``,i=n[3].split(`?`)[0],a=parseInt(n[4],10),o=parseInt(n[5],10);return{fn:r,file:i.split(`/`).pop(),line:a,column:o}}).filter(e=>e&&!xD.some(t=>t.test(e.file)))}var CD=class{constructor(e=null){this.isStackTrace=!0,this.stack=SD(e||Error().stack)}getLocation(){if(this.stack.length===0)return`[Unknown location]`;let e=this.stack[0],t=e.fn;return`${t?`"${t}()" at `:``}"${e.file}:${e.line}"`}getError(e){return this.stack.length===0?e:`${e}\n${this.stack.map(e=>{let t=`${e.file}:${e.line}:${e.column}`;return e.fn?` at ${e.fn} (${t})`:` at ${t}`}).join(` `)}`}};function wD(e,t=0){let n=3735928559^t,r=1103547991^t;if(Array.isArray(e))for(let t=0,i;t>>16,2246822507),n^=Math.imul(r^r>>>13,3266489909),r=Math.imul(r^r>>>16,2246822507),r^=Math.imul(n^n>>>13,3266489909),4294967296*(2097151&r)+(n>>>0)}var TD=e=>wD(e),ED=e=>wD(e),DD=(...e)=>wD(e),OD=new Map([[1,`float`],[2,`vec2`],[3,`vec3`],[4,`vec4`],[9,`mat3`],[16,`mat4`]]),kD=new WeakMap;function AD(e){return OD.get(e)}function jD(e){if(/[iu]?vec\d/.test(e))return e.startsWith(`ivec`)?Int32Array:e.startsWith(`uvec`)?Uint32Array:Float32Array;if(/mat\d/.test(e)||/float/.test(e))return Float32Array;if(/uint/.test(e))return Uint32Array;if(/int/.test(e))return Int32Array;throw Error(`THREE.NodeUtils: Unsupported type: ${e}`)}function MD(e){if(/float|int|uint|bool/.test(e))return 1;if(/vec2/.test(e))return 2;if(/vec3/.test(e))return 3;if(/vec4/.test(e)||/mat2/.test(e))return 4;if(/mat3/.test(e))return 9;if(/mat4/.test(e))return 16;I(`TSL: Unsupported type: ${e}`,new CD)}function ND(e){if(/float|int|uint|bool/.test(e))return 1;if(/vec2/.test(e))return 2;if(/vec3/.test(e))return 3;if(/vec4/.test(e)||/mat2/.test(e))return 4;if(/mat3/.test(e))return 12;if(/mat4/.test(e))return 16;I(`TSL: Unsupported type: ${e}`,new CD)}function PD(e){if(/float|int|uint|bool/.test(e))return 1;if(/vec2/.test(e))return 2;if(/vec3/.test(e)||/vec4/.test(e))return 4;if(/mat2/.test(e))return 2;if(/mat3/.test(e)||/mat4/.test(e))return 4;I(`TSL: Unsupported type: ${e}`,new CD)}function FD(e){if(e==null)return null;let t=typeof e;return e.isNode===!0?`node`:t===`number`?`float`:t===`boolean`?`bool`:t===`string`?`string`:t===`function`?`shader`:e.isVector2===!0?`vec2`:e.isVector3===!0?`vec3`:e.isVector4===!0?`vec4`:e.isMatrix2===!0?`mat2`:e.isMatrix3===!0?`mat3`:e.isMatrix4===!0?`mat4`:e.isColor===!0?`color`:e instanceof ArrayBuffer?`ArrayBuffer`:null}function ID(e,...t){let n=e?e.slice(-4):void 0;return t.length===1&&(n===`vec2`?t=[t[0],t[0]]:n===`vec3`?t=[t[0],t[0],t[0]]:n===`vec4`&&(t=[t[0],t[0],t[0],t[0]])),e===`color`?new Er(...t):n===`vec2`?new L(...t):n===`vec3`?new R(...t):n===`vec4`?new Hn(...t):n===`mat2`?new Xc(...t):n===`mat3`?new En(...t):n===`mat4`?new qn(...t):e===`bool`?t[0]||!1:e===`float`||e===`int`||e===`uint`?t[0]||0:e===`string`?t[0]||``:e===`ArrayBuffer`?zD(t[0]):null}function LD(e){let t=kD.get(e);return t===void 0&&(t={},kD.set(e,t)),t}function RD(e){let t=``,n=new Uint8Array(e);for(let e=0;ee.charCodeAt(0)).buffer}var BD={VERTEX:`vertex`,FRAGMENT:`fragment`},VD={NONE:`none`,FRAME:`frame`,RENDER:`render`,OBJECT:`object`},HD={BOOLEAN:`bool`,INTEGER:`int`,FLOAT:`float`,VECTOR2:`vec2`,VECTOR3:`vec3`,VECTOR4:`vec4`,MATRIX2:`mat2`,MATRIX3:`mat3`,MATRIX4:`mat4`},UD={READ_ONLY:`readOnly`,WRITE_ONLY:`writeOnly`,READ_WRITE:`readWrite`},WD=[`fragment`,`vertex`],GD=[`setup`,`analyze`,`generate`],KD=[...WD,`compute`],qD=[`x`,`y`,`z`,`w`],JD={analyze:`setup`,generate:`analyze`},YD=0,XD=class e extends Jt{static get type(){return`Node`}constructor(t=null){super(),this.nodeType=t,this.updateType=VD.NONE,this.updateBeforeType=VD.NONE,this.updateAfterType=VD.NONE,this.version=0,this.name=``,this.global=!1,this.parents=!1,this.isNode=!0,this._beforeNodes=null,this._cacheKey=null,this._uuid=null,this._cacheKeyVersion=0,this.id=YD++,this.stackTrace=null,e.captureStackTrace===!0&&(this.stackTrace=new CD)}set needsUpdate(e){e===!0&&this.version++}get uuid(){return this._uuid===null&&(this._uuid=Sn.generateUUID()),this._uuid}get type(){return this.constructor.type}onUpdate(e,t){return this.updateType=t,this.update=e.bind(this),this}onFrameUpdate(e){return this.onUpdate(e,VD.FRAME)}onRenderUpdate(e){return this.onUpdate(e,VD.RENDER)}onObjectUpdate(e){return this.onUpdate(e,VD.OBJECT)}onReference(e){return this.updateReference=e.bind(this),this}updateReference(){return this}isGlobal(){return this.global}*getChildren(){for(let{childNode:e}of this._getChildren())yield e}dispose(){this.dispatchEvent({type:`dispose`})}traverse(e){e(this);for(let t of this.getChildren())t.traverse(e)}_getChildren(e=new Set){let t=[];e.add(this);for(let n of Object.getOwnPropertyNames(this)){let r=this[n];if(!(n.startsWith(`_`)===!0||e.has(r))){if(Array.isArray(r)===!0)for(let e=0;e0&&(e.inputNodes=n)}deserialize(e){if(e.inputNodes!==void 0){let t=e.meta.nodes;for(let n in e.inputNodes)if(Array.isArray(e.inputNodes[n])){let r=[];for(let i of e.inputNodes[n])r.push(t[i]);this[n]=r}else if(typeof e.inputNodes[n]==`object`){let r={};for(let i in e.inputNodes[n])r[i]=t[e.inputNodes[n][i]];this[n]=r}else this[n]=t[e.inputNodes[n]]}}toJSON(e){let{uuid:t,type:n}=this,r=e===void 0||typeof e==`string`;r&&(e={textures:{},images:{},nodes:{}});let i=e.nodes[t];i===void 0&&(i={uuid:t,type:n,meta:e,metadata:{version:4.7,type:`Node`,generator:`Node.toJSON`}},r!==!0&&(e.nodes[i.uuid]=i),this.serialize(i),delete i.meta);function a(e){let t=[];for(let n in e){let r=e[n];delete r.metadata,t.push(r)}return t}if(r){let t=a(e.textures),n=a(e.images),r=a(e.nodes);t.length>0&&(i.textures=t),n.length>0&&(i.images=n),r.length>0&&(i.nodes=r)}return i}};XD.captureStackTrace=!1;var ZD=class extends XD{static get type(){return`ArrayElementNode`}constructor(e,t){super(),this.node=e,this.indexNode=t,this.isArrayElementNode=!0}generateNodeType(e){return this.node.getElementType(e)}getMemberType(e,t){return this.node.getMemberType(e,t)}generate(e){let t=this.indexNode.getNodeType(e);return`${this.node.build(e)}[ ${this.indexNode.build(e,!e.isVector(t)&&e.isInteger(t)?t:`uint`)} ]`}},QD=class extends XD{static get type(){return`ConvertNode`}constructor(e,t){super(),this.node=e,this.convertTo=t}generateNodeType(e){let t=this.node.getNodeType(e),n=null;for(let r of this.convertTo.split(`|`))(n===null||e.getTypeLength(t)===e.getTypeLength(r))&&(n=r);return n}serialize(e){super.serialize(e),e.convertTo=this.convertTo}deserialize(e){super.deserialize(e),this.convertTo=e.convertTo}generate(e,t){let n=this.node,r=this.getNodeType(e),i=n.build(e,r);return e.format(i,r,t)}},$D=class extends XD{static get type(){return`TempNode`}constructor(e=null){super(e),this.isTempNode=!0}hasDependencies(e){return e.getDataFromNode(this).usageCount>1}build(e,t){if(e.getBuildStage()===`generate`){let n=e.getVectorType(this.getNodeType(e,t)),r=e.getDataFromNode(this);if(r.propertyName!==void 0)return e.format(r.propertyName,n,t);if(n!==`void`&&t!==`void`&&this.hasDependencies(e)){let i=super.build(e,n),a=e.getVarFromNode(this,null,n),o=e.getPropertyName(a);return e.addLineFlowCode(`${o} = ${i}`,this),r.snippet=i,r.propertyName=o,e.format(r.propertyName,n,t)}}return super.build(e,t)}},eO=class extends $D{static get type(){return`JoinNode`}constructor(e=[],t=null){super(t),this.nodes=e}generateNodeType(e){return this.nodeType===null?e.getTypeFromLength(this.nodes.reduce((t,n)=>t+e.getTypeLength(n.getNodeType(e)),0)):e.getVectorType(this.nodeType)}generate(e,t){let n=this.getNodeType(e),r=e.getTypeLength(n),i=this.nodes,a=e.getComponentType(n),o=[],s=0;for(let t of i){if(s>=r){I(`TSL: Length of parameters exceeds maximum length of function '${n}()' type.`,this.stackTrace);break}let i=t.getNodeType(e),c=e.getTypeLength(i),l;if(s+c>r&&(I(`TSL: Length of '${n}()' data exceeds maximum length of output type.`,this.stackTrace),c=r-s,i=e.getTypeFromLength(c)),s+=c,l=t.build(e,i),e.getComponentType(i)!==a){let t=e.getTypeFromLength(c,a);l=e.format(l,i,t)}o.push(l)}let c=`${e.getType(n)}( ${o.join(`, `)} )`;return e.format(c,n,t)}},tO=qD.join(``),nO=class extends XD{static get type(){return`SplitNode`}constructor(e,t=`x`){super(),this.node=e,this.components=t,this.isSplitNode=!0}getVectorLength(){let e=this.components.length;for(let t of this.components)e=Math.max(qD.indexOf(t)+1,e);return e}getComponentType(e){return e.getComponentType(this.node.getNodeType(e))}generateNodeType(e){return e.getTypeFromLength(this.components.length,this.getComponentType(e))}getScope(){return this.node.getScope()}generate(e,t){let n=this.node,r=e.getTypeLength(n.getNodeType(e)),i=null;if(r>1){let a=null;this.getVectorLength()>=r&&(a=e.getTypeFromLength(this.getVectorLength(),this.getComponentType(e)));let o=n.build(e,a);i=this.components.length===r&&this.components===tO.slice(0,this.components.length)?e.format(o,a,t):e.format(`${o}.${this.components}`,this.getNodeType(e),t)}else i=n.build(e,t);return i}serialize(e){super.serialize(e),e.components=this.components}deserialize(e){super.deserialize(e),this.components=e.components}},rO=class extends $D{static get type(){return`SetNode`}constructor(e,t,n){super(),this.sourceNode=e,this.components=t,this.targetNode=n}generateNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){let{sourceNode:t,components:n,targetNode:r}=this,i=this.getNodeType(e),a=e.getComponentType(r.getNodeType(e)),o=e.getTypeFromLength(n.length,a),s=r.build(e,o),c=t.build(e,i),l=e.getTypeLength(i),u=[];for(let e=0;ee.replace(/r|s/g,`x`).replace(/g|t/g,`y`).replace(/b|p/g,`z`).replace(/a|q/g,`w`),fO=e=>dO(e).split(``).sort().join(``);XD.prototype.assign=function(...e){if(this.isStackNode!==!0)return lO===null?I(`TSL: No stack defined for assign operation. Make sure the assign is inside a Fn().`,new CD):lO.assign(this,...e),this;{let t=uO.get(`assign`);return this.addToStack(t(...e))}},XD.prototype.toVarIntent=function(){return this},XD.prototype.get=function(e){return new cO(this,e)};var pO={};function mO(e,t,n){pO[e]=pO[t]=pO[n]={get(){this._cache=this._cache||{};let t=this._cache[e];return t===void 0&&(t=new nO(this,e),this._cache[e]=t),t},set(t){this[e].assign(UO(t))}};let r=e.toUpperCase(),i=t.toUpperCase(),a=n.toUpperCase();XD.prototype[`set`+r]=XD.prototype[`set`+i]=XD.prototype[`set`+a]=function(t){let n=fO(e);return new rO(this,n,UO(t))},XD.prototype[`flip`+r]=XD.prototype[`flip`+i]=XD.prototype[`flip`+a]=function(){let t=fO(e);return new iO(this,t)}}var hO=[`x`,`y`,`z`,`w`],gO=[`r`,`g`,`b`,`a`],_O=[`s`,`t`,`p`,`q`];for(let e=0;e<4;e++){let t=hO[e],n=gO[e],r=_O[e];mO(t,n,r);for(let i=0;i<4;i++){t=hO[e]+hO[i],n=gO[e]+gO[i],r=_O[e]+_O[i],mO(t,n,r);for(let a=0;a<4;a++){t=hO[e]+hO[i]+hO[a],n=gO[e]+gO[i]+gO[a],r=_O[e]+_O[i]+_O[a],mO(t,n,r);for(let o=0;o<4;o++)t=hO[e]+hO[i]+hO[a]+hO[o],n=gO[e]+gO[i]+gO[a]+gO[o],r=_O[e]+_O[i]+_O[a]+_O[o],mO(t,n,r)}}}for(let e=0;e<32;e++)pO[e]={get(){this._cache=this._cache||{};let t=this._cache[e];return t===void 0&&(t=new ZD(this,new sO(e,`uint`)),this._cache[e]=t),t},set(t){this[e].assign(UO(t))}};Object.defineProperties(XD.prototype,pO);var vO=function(e,t=null){let n=FD(e);return n===`node`?e:t===null&&(n===`float`||n===`boolean`)||n&&n!==`shader`&&n!==`string`?UO(RO(e,t)):n===`shader`?e.isFn?e:W(e):e},yO=function(e,t=null){for(let n in e)e[n]=UO(e[n],t);return e},bO=function(e,t=null){let n=e.length;for(let r=0;rc?(I(`TSL: "${n}" parameter length exceeds limit.`,new CD),t.slice(0,c)):t}return t===null?a=(...t)=>i(new e(...KO(l(t)))):n===null?a=(...n)=>i(new e(t,...KO(l(n)))):(n=UO(n),a=(...r)=>i(new e(t,...KO(l(r)),n))),a.setParameterLength=(...e)=>(e.length===1?s=c=e[0]:e.length===2&&([s,c]=e),a),a.setName=e=>(o=e,a),a},SO=function(e,...t){return new e(...KO(t))},CO=class extends XD{constructor(e,t){super(),this.shaderNode=e,this.rawInputs=t,this.isShaderCallNodeInternal=!0}generateNodeType(e){return this.shaderNode.nodeType||this.getOutputNode(e).getNodeType(e)}getElementType(e){return this.getOutputNode(e).getElementType(e)}getMemberType(e,t){return this.getOutputNode(e).getMemberType(e,t)}call(e){let{shaderNode:t,rawInputs:n}=this,r=e.getNodeProperties(t),i=e.getClosestSubBuild(t.subBuilds)||``,a=i||`default`;if(r[a])return r[a];let o=e.subBuildFn,s=e.fnCall;e.subBuildFn=i,e.fnCall=this;let c=null;if(t.layout){if(n){let r=t.layout.inputs;if(wO(n)){let t=n;for(let n=0;n{let r;return r=Symbol.iterator===t?function*(){yield void 0}:Reflect.get(e,t,n),r}}),i=n?EO(n):null,a=Array.isArray(n)?n.length>0:n!==null,o=t.jsFunc;c=UO(a||o.length>1?o(i,r):o(r))}return e.subBuildFn=o,e.fnCall=s,t.once&&(r[a]=c),c}setupOutput(e){return e.addStack(),e.stack.outputNode=this.call(e),e.removeStack()}getOutputNode(e){let t=e.getNodeProperties(this),n=e.getSubBuildOutput(this);return t[n]=t[n]||this.setupOutput(e),t[n].subBuild=e.getClosestSubBuild(this),t[n]}build(e,t=null){let n=null,r=e.getBuildStage(),i=e.getNodeProperties(this),a=e.getSubBuildOutput(this),o=this.getOutputNode(e),s=e.fnCall;if(e.fnCall=this,r===`setup`){let t=e.getSubBuildProperty(`initialized`,this);if(i[t]!==!0&&(i[t]=!0,i[a]=this.getOutputNode(e),i[a].build(e),this.shaderNode.subBuilds))for(let t of e.chaining){let n=e.getDataFromNode(t,`any`);n.subBuilds=n.subBuilds||new Set;for(let e of this.shaderNode.subBuilds)n.subBuilds.add(e)}n=i[a]}else r===`analyze`?o.build(e,t):r===`generate`&&(n=o.build(e,t)||``);return e.fnCall=s,n}};function wO(e){return e[0]&&(e[0].isNode||Object.getPrototypeOf(e[0])!==Object.prototype)}function TO(e){let t;return GO(e),t=wO(e)?[...e]:e[0],t}function EO(e){let t=0;return GO(e),new Proxy(e,{get:(n,r,i)=>{let a;if(r===`length`)return a=e.length,a;if(Symbol.iterator===r)a=function*(){for(let t of e)yield UO(t)};else{if(e.length>0)if(Object.getPrototypeOf(e[0])===Object.prototype){let n=e[0];a=n[r]===void 0?n[t++]:Reflect.get(n,r,i)}else e[0]instanceof XD&&(a=e[r]===void 0?e[t++]:Reflect.get(e,r,i));else a=Reflect.get(n,r,i);a=UO(a)}return a}})}var DO=class extends XD{constructor(e,t){super(t),this.jsFunc=e,this.layout=null,this.global=!0,this.once=!1}setLayout(e){return this.layout=e,this}getLayout(){return this.layout}call(e=null){return new CO(this,e)}setup(){return this.call()}},OO=[!1,!0],kO=[0,1,2,3],AO=[-1,-2],jO=[.5,1.5,1/3,1e-6,1e6,Math.PI,Math.PI*2,1/Math.PI,2/Math.PI,1/(Math.PI*2),Math.PI/2],MO=new Map;for(let e of OO)MO.set(e,new sO(e));var NO=new Map;for(let e of kO)NO.set(e,new sO(e,`uint`));var PO=new Map([...NO].map(e=>new sO(e.value,`int`)));for(let e of AO)PO.set(e,new sO(e,`int`));var FO=new Map([...PO].map(e=>new sO(e.value)));for(let e of jO)FO.set(e,new sO(e));for(let e of jO)FO.set(-e,new sO(-e));var IO={bool:MO,uint:NO,ints:PO,float:FO},LO=new Map([...MO,...FO]),RO=(e,t)=>LO.has(e)?LO.get(e):e.isNode===!0?e:new sO(e,t),zO=function(e,t=null){return(...n)=>{for(let t of n)if(t===void 0)return I(`TSL: Invalid parameter for the type "${e}".`,new CD),new sO(0,e);if((n.length===0||![`bool`,`float`,`int`,`uint`].includes(e)&&n.every(e=>{let t=typeof e;return t!==`object`&&t!==`function`}))&&(n=[ID(e,...n)]),n.length===1&&t!==null&&t.has(n[0]))return WO(t.get(n[0]));if(n.length===1){let t=RO(n[0],e);return t.nodeType===e?WO(t):WO(new QD(t,e))}return WO(new eO(n.map(e=>RO(e)),e))}};function BO(e){return e&&e.isNode&&e.traverse(t=>{t.isConstNode&&(e=t.value)}),!!e}var VO=e=>e==null?null:e.nodeType||e.convertTo||(typeof e==`string`?e:null);function HO(e,t){return new DO(e,t)}var UO=(e,t=null)=>vO(e,t),WO=(e,t=null)=>UO(e,t).toVarIntent(),GO=(e,t=null)=>new yO(e,t),KO=(e,t=null)=>new bO(e,t),qO=(e,t=null,n=null,r=null)=>new xO(e,t,n,r),JO=(e,...t)=>new SO(e,...t),U=(e,t=null,n=null,r={})=>new xO(e,t,n,{...r,intent:!0}),YO=(e,t)=>new Proxy(e,{get(e,n,r){return Reflect.get(t,n,r)},set(e,n,r){return Reflect.set(t,n,r)}}),yee=0,XO=class extends XD{constructor(e,t=null){super();let n=null;t!==null&&(typeof t==`object`?n=t.return:(typeof t==`string`?n=t:I(`TSL: Invalid layout type.`,new CD),t=null)),this.shaderNode=new HO(e,n),t!==null&&this.setLayout(t),this.isFn=!0}setLayout(e){let t=this.shaderNode.nodeType;if(typeof e.inputs!=`object`){let n={name:`fn`+ yee++,type:t,inputs:[]};for(let t in e)t!==`return`&&n.inputs.push({name:t,type:e[t]});e=n}return this.shaderNode.setLayout(e),this}generateNodeType(e){return this.shaderNode.getNodeType(e)||`float`}call(...e){let t=this.shaderNode.call(e);return this.shaderNode.nodeType===`void`&&t.toStack(),t.toVarIntent()}once(e=null){return this.shaderNode.once=!0,this.shaderNode.subBuilds=e,this}generate(e){let t=this.getNodeType(e);return I(`TSL: "Fn()" was declared but not invoked. Try calling it like "Fn()( ...params )".`,this.stackTrace),e.generateConst(t)}};function W(e,t=null){let n=new XO(e,t);return new Proxy(()=>{},{apply(e,t,r){return n.call(...r)},get(e,t,r){return Reflect.get(n,t,r)},set(e,t,r,i){return Reflect.set(n,t,r,i)}})}var ZO=e=>{lO=e},QO=()=>lO,$O=(...e)=>lO.If(...e),ek=(...e)=>lO.Switch(...e);function tk(e){return lO&&lO.addToStack(e),e}H(`toStack`,tk);var nk=new zO(`color`),G=new zO(`float`,IO.float),K=new zO(`int`,IO.ints),q=new zO(`uint`,IO.uint),rk=new zO(`bool`,IO.bool),ik=new zO(`vec2`),ak=new zO(`ivec2`),ok=new zO(`uvec2`),sk=new zO(`bvec2`),J=new zO(`vec3`),ck=new zO(`ivec3`),lk=new zO(`uvec3`),uk=new zO(`bvec3`),dk=new zO(`vec4`),fk=new zO(`ivec4`),pk=new zO(`uvec4`),mk=new zO(`bvec4`),hk=new zO(`mat2`),gk=new zO(`mat3`),_k=new zO(`mat4`);H(`toColor`,nk),H(`toFloat`,G),H(`toInt`,K),H(`toUint`,q),H(`toBool`,rk),H(`toVec2`,ik),H(`toIVec2`,ak),H(`toUVec2`,ok),H(`toBVec2`,sk),H(`toVec3`,J),H(`toIVec3`,ck),H(`toUVec3`,lk),H(`toBVec3`,uk),H(`toVec4`,dk),H(`toIVec4`,fk),H(`toUVec4`,pk),H(`toBVec4`,mk),H(`toMat2`,hk),H(`toMat3`,gk),H(`toMat4`,_k);var vk=qO(ZD).setParameterLength(2),yk=(e,t)=>new QD(UO(e),t),bk=(e,t)=>new nO(UO(e),t);H(`element`,vk),H(`convert`,yk);var xk=e=>(F(`TSL: append() has been renamed to Stack().`,new CD),tk(e));H(`append`,e=>(F(`TSL: .append() has been renamed to .toStack().`,new CD),tk(e)));var Sk=class extends XD{static get type(){return`PropertyNode`}constructor(e,t=null,n=!1,r=null){super(e),this.name=t,this.varying=n,this.placeholderNode=UO(r),this.isPropertyNode=!0,this.global=!0}getNodeType(e){let t=super.getNodeType(e);return t===`output`?e.getOutputType():t}customCacheKey(){return TD(this.type+`:`+(this.name||``)+`:`+(this.varying?`1`:`0`))}getHash(e){return this.name||super.getHash(e)}generate(e){let t;if(this.varying===!0)t=e.getVaryingFromNode(this,this.name),t.needsInterpolation=!0;else if(t=e.getVarFromNode(this,this.name),this.placeholderNode!==null&&e.hasWriteUsage(this)===!1){let n=this.placeholderNode.build(e,this.getNodeType(e));e.addLineFlowCode(`${e.getPropertyName(t)} = ${n}`,this)}return e.getPropertyName(t)}},Ck=(e,t,n=null)=>new Sk(e,t,!1,n),wk=(e,t,n=null)=>new Sk(e,t,!0,n),Tk=JO(Sk,`vec4`,`DiffuseColor`),Ek=JO(Sk,`vec3`,`DiffuseContribution`),Dk=JO(Sk,`vec3`,`EmissiveColor`),Ok=JO(Sk,`float`,`Roughness`),kk=JO(Sk,`float`,`Metalness`),Ak=JO(Sk,`float`,`Clearcoat`),jk=JO(Sk,`float`,`ClearcoatRoughness`),Mk=JO(Sk,`vec3`,`Sheen`),Nk=JO(Sk,`float`,`SheenRoughness`),Pk=JO(Sk,`float`,`Iridescence`),Fk=JO(Sk,`float`,`IridescenceIOR`),Ik=JO(Sk,`float`,`IridescenceThickness`),Lk=JO(Sk,`float`,`AlphaT`),Rk=JO(Sk,`float`,`Anisotropy`),zk=JO(Sk,`vec3`,`AnisotropyT`),Bk=JO(Sk,`vec3`,`AnisotropyB`),Vk=JO(Sk,`color`,`SpecularColor`),Hk=JO(Sk,`color`,`SpecularColorBlended`),Uk=JO(Sk,`float`,`SpecularF90`),Wk=JO(Sk,`float`,`Shininess`),Gk=JO(Sk,`output`,`Output`),Kk=JO(Sk,`float`,`dashSize`),qk=JO(Sk,`float`,`gapSize`),Jk=JO(Sk,`float`,`pointWidth`),Yk=JO(Sk,`float`,`IOR`),Xk=JO(Sk,`float`,`Transmission`),Zk=JO(Sk,`float`,`Thickness`),Qk=JO(Sk,`float`,`AttenuationDistance`),$k=JO(Sk,`color`,`AttenuationColor`),eA=JO(Sk,`float`,`Dispersion`),tA=JO(Sk,`float`,`AmbientOcclusion`,!1,1),nA=class extends XD{static get type(){return`UniformGroupNode`}constructor(e,t=!1,n=1,r=null){super(`string`),this.name=e,this.shared=t,this.order=n,this.updateType=r,this.isUniformGroup=!0}update(){this.needsUpdate=!0}serialize(e){super.serialize(e),e.name=this.name,e.version=this.version,e.shared=this.shared}deserialize(e){super.deserialize(e),this.name=e.name,this.version=e.version,this.shared=e.shared}},rA=(e,t=1,n=null)=>new nA(e,!1,t,n),iA=(e,t=0,n=null)=>new nA(e,!0,t,n),aA=iA(`frame`,0,VD.FRAME),oA=iA(`render`,0,VD.RENDER),sA=rA(`object`,1,VD.OBJECT),cA=class extends aO{static get type(){return`UniformNode`}constructor(e,t=null){super(e,t),this.isUniformNode=!0,this.name=``,this.groupNode=sA}setName(e){return this.name=e,this}label(e){return F(`TSL: "label()" has been deprecated. Use "setName()" instead.`,new CD),this.setName(e)}setGroup(e){return this.groupNode=e,this}getGroup(){return this.groupNode}getUniformHash(e){return this.getHash(e)}onUpdate(e,t){return e=e.bind(this),super.onUpdate(t=>{let n=e(t,this);n!==void 0&&(this.value=n)},t)}getInputType(e){let t=super.getInputType(e);return t===`bool`&&(t=`uint`),t}generate(e,t){let n=this.getNodeType(e),r=this.getUniformHash(e),i=e.getNodeFromHash(r);i===void 0&&(e.setHashNode(this,r),i=this);let a=i.getInputType(e),o=e.getUniformFromNode(i,a,e.shaderStage,this.name||e.context.nodeName),s=e.getPropertyName(o);e.context.nodeName!==void 0&&delete e.context.nodeName;let c=s;if(n===`bool`){let t=e.getDataFromNode(this),r=t.propertyName;if(r===void 0){let i=e.getVarFromNode(this,null,`bool`);r=e.getPropertyName(i),t.propertyName=r,c=e.format(s,a,n),e.addLineFlowCode(`${r} = ${c}`,this)}c=r}return e.format(c,n,t)}},lA=(e,t)=>{let n=VO(t||e);if(n===e&&(e=ID(n)),e&&e.isNode===!0){let t=e.value;e.traverse(e=>{e.isConstNode===!0&&(t=e.value)}),e=t}return new cA(e,n)},uA=class extends $D{static get type(){return`ArrayNode`}constructor(e,t,n=null){super(e),this.count=t,this.values=n,this.isArrayNode=!0}getArrayCount(){return this.count}generateNodeType(e){return this.nodeType===null?this.values[0].getNodeType(e):this.nodeType}getElementType(e){return this.getNodeType(e)}getMemberType(e,t){return this.nodeType===null?this.values[0].getMemberType(e,t):super.getMemberType(e,t)}generate(e){let t=this.getNodeType(e);return e.generateArray(t,this.count,this.values)}},dA=(...e)=>{let t;if(e.length===1){let n=e[0];t=new uA(null,n.length,n)}else{let n=e[0],r=e[1];t=new uA(n,r)}return UO(t)};H(`toArray`,(e,t)=>dA(Array(t).fill(e)));var fA=qO(class extends $D{static get type(){return`AssignNode`}constructor(e,t){super(),this.targetNode=e,this.sourceNode=t,this.isAssignNode=!0}hasDependencies(){return!1}generateNodeType(e,t){return t===`void`?`void`:this.targetNode.getNodeType(e)}needsSplitAssign(e){let{targetNode:t}=this;if(e.isAvailable(`swizzleAssign`)===!1&&t.isSplitNode&&t.components.length>1){let n=e.getTypeLength(t.node.getNodeType(e));return qD.join(``).slice(0,n)!==t.components}return!1}setup(e){let{targetNode:t,sourceNode:n}=this,r=t.getScope(),i=e.getDataFromNode(r);i.assign=!0;let a=e.getNodeProperties(this);a.sourceNode=n,a.targetNode=t.context({assign:!0})}generate(e,t){let{targetNode:n,sourceNode:r}=e.getNodeProperties(this),i=this.needsSplitAssign(e),a=n.build(e),o=n.getNodeType(e),s=r.build(e,o),c=r.getNodeType(e),l=e.getDataFromNode(this),u;if(l.initialized===!0)t!==`void`&&(u=a);else if(i){let r=e.getVarFromNode(this,null,o),i=e.getPropertyName(r);e.addLineFlowCode(`${i} = ${s}`,this);let c=n.node,l=c.node.context({assign:!0}).build(e);for(let t=0;t{let r=n.type,i=r===`pointer`,a;return a=i?`&`+t.build(e):t.build(e,r),a};if(Array.isArray(i)){if(i.length>r.length)I(`TSL: The number of provided parameters exceeds the expected number of inputs in 'Fn()'.`),i.length=r.length;else if(i.length(t=t.length>1||t[0]&&t[0].isNode===!0?KO(t):GO(t[0]),new pA(UO(e),t));H(`call`,mA);var hA={"==":`equal`,"!=":`notEqual`,"<":`lessThan`,">":`greaterThan`,"<=":`lessThanEqual`,">=":`greaterThanEqual`,"%":`mod`},gA=class e extends $D{static get type(){return`OperatorNode`}constructor(t,n,r,...i){if(super(),i.length>0){let a=new e(t,n,r);for(let n=0;n>`||n===`<<`)return e.getIntegerType(a);if(n===`&&`||n===`||`||n===`^^`)return`bool`;if(n===`!`){let t=e.getTypeLength(a);return t>1?`bvec${t}`:`bool`}else if(n===`==`||n===`!=`||n===`<`||n===`>`||n===`<=`||n===`>=`){let t=Math.max(e.getTypeLength(a),e.getTypeLength(o));return t>1?`bvec${t}`:`bool`}else{if(e.isMatrix(a)){if(o===`float`)return a;if(e.isVector(o))return e.getVectorFromMatrix(a);if(e.isMatrix(o))return a}else if(e.isMatrix(o)){if(a===`float`)return o;if(e.isVector(a))return e.getVectorFromMatrix(o)}return e.getTypeLength(o)>e.getTypeLength(a)?o:a}}generate(e,t){let n=this.op,{aNode:r,bNode:i}=this,a=this.getNodeType(e,t),o=null,s=null;a===`void`?o=s=a:(o=r.getNodeType(e),s=i?i.getNodeType(e):null,n===`<`||n===`>`||n===`<=`||n===`>=`||n===`==`||n===`!=`?e.isVector(o)?s=o:e.isVector(s)?o=s:o!==s&&(o=s=`float`):n===`>>`||n===`<<`?(o=a,s=e.changeComponentType(s,`uint`)):n===`%`?(o=a,s=e.isInteger(o)&&e.isInteger(s)?s:o):e.isMatrix(o)?s===`float`?s=`float`:e.isVector(s)?s=e.getVectorFromMatrix(o):e.isMatrix(s)||(o=s=a):o=e.isMatrix(s)?o===`float`?`float`:e.isVector(o)?e.getVectorFromMatrix(s):s=a:s=a);let c=r.build(e,o),l=i?i.build(e,s):null,u=e.getFunctionOperator(n);if(t!==`void`){let r=e.renderer.coordinateSystem===Mt;if(n===`==`||n===`!=`||n===`<`||n===`>`||n===`<=`||n===`>=`)return r&&e.isVector(o)?e.format(`${this.getOperatorMethod(e,t)}( ${c}, ${l} )`,a,t):e.format(`( ${c} ${n} ${l} )`,a,t);if(n===`%`)return e.isInteger(s)?e.format(`( ${c} % ${l} )`,a,t):e.format(`${this.getOperatorMethod(e,a)}( ${c}, ${l} )`,a,t);if(n===`!`)return r&&e.isVector(o)?e.format(`not( ${c} )`,t):e.format(`( ${n} ${c} )`,o,t);if(n===`~`)return e.format(`( ${n} ${c} )`,o,t);if(u)return e.format(`${u}( ${c}, ${l} )`,a,t);if(e.isMatrix(o)&&s===`float`)return e.format(`( ${l} ${n} ${c} )`,a,t);if(o===`float`&&e.isMatrix(s))return e.format(`${c} ${n} ${l}`,a,t);{let i=`( ${c} ${n} ${l} )`;return!r&&a===`bool`&&e.isVector(o)&&e.isVector(s)&&(i=`all${i}`),e.format(i,a,t)}}else if(o!==`void`)return u?e.format(`${u}( ${c}, ${l} )`,a,t):e.isMatrix(o)&&s===`float`?e.format(`${l} ${n} ${c}`,a,t):e.format(`${c} ${n} ${l}`,a,t)}serialize(e){super.serialize(e),e.op=this.op}deserialize(e){super.deserialize(e),this.op=e.op}},_A=U(gA,`+`).setParameterLength(2,1/0).setName(`add`),vA=U(gA,`-`).setParameterLength(2,1/0).setName(`sub`),yA=U(gA,`*`).setParameterLength(2,1/0).setName(`mul`),bA=U(gA,`/`).setParameterLength(2,1/0).setName(`div`),xA=U(gA,`%`).setParameterLength(2).setName(`mod`),SA=U(gA,`==`).setParameterLength(2).setName(`equal`),CA=U(gA,`!=`).setParameterLength(2).setName(`notEqual`),wA=U(gA,`<`).setParameterLength(2).setName(`lessThan`),TA=U(gA,`>`).setParameterLength(2).setName(`greaterThan`),EA=U(gA,`<=`).setParameterLength(2).setName(`lessThanEqual`),DA=U(gA,`>=`).setParameterLength(2).setName(`greaterThanEqual`),OA=U(gA,`&&`).setParameterLength(2,1/0).setName(`and`),kA=U(gA,`||`).setParameterLength(2,1/0).setName(`or`),AA=U(gA,`!`).setParameterLength(1).setName(`not`),jA=U(gA,`^^`).setParameterLength(2).setName(`xor`),MA=U(gA,`&`).setParameterLength(2).setName(`bitAnd`),NA=U(gA,`~`).setParameterLength(1).setName(`bitNot`),PA=U(gA,`|`).setParameterLength(2).setName(`bitOr`),FA=U(gA,`^`).setParameterLength(2).setName(`bitXor`),IA=U(gA,`<<`).setParameterLength(2).setName(`shiftLeft`),LA=U(gA,`>>`).setParameterLength(2).setName(`shiftRight`),RA=W(([e])=>(e.addAssign(1),e)),zA=W(([e])=>(e.subAssign(1),e)),BA=W(([e])=>{let t=K(e).toConst();return e.addAssign(1),t}),VA=W(([e])=>{let t=K(e).toConst();return e.subAssign(1),t});H(`add`,_A),H(`sub`,vA),H(`mul`,yA),H(`div`,bA),H(`mod`,xA),H(`equal`,SA),H(`notEqual`,CA),H(`lessThan`,wA),H(`greaterThan`,TA),H(`lessThanEqual`,EA),H(`greaterThanEqual`,DA),H(`and`,OA),H(`or`,kA),H(`not`,AA),H(`xor`,jA),H(`bitAnd`,MA),H(`bitNot`,NA),H(`bitOr`,PA),H(`bitXor`,FA),H(`shiftLeft`,IA),H(`shiftRight`,LA),H(`incrementBefore`,RA),H(`decrementBefore`,zA),H(`increment`,BA),H(`decrement`,VA);var Y=class e extends $D{static get type(){return`MathNode`}constructor(t,n,r=null,i=null){if(super(),(t===e.MAX||t===e.MIN)&&arguments.length>3){let a=new e(t,n,r);for(let n=3;na&&i>o?t:a>o?n:o>i?r:t}generateNodeType(t){let n=this.method;return n===e.LENGTH||n===e.DISTANCE||n===e.DOT?`float`:n===e.CROSS?`vec3`:n===e.ALL||n===e.ANY?`bool`:n===e.EQUALS?t.changeComponentType(this.aNode.getNodeType(t),`bool`):this.getInputType(t)}setup(t){let{aNode:n,bNode:r,method:i}=this,a=null;if(i===e.ONE_MINUS)a=vA(1,n);else if(i===e.RECIPROCAL)a=bA(1,n);else if(i===e.DIFFERENCE)a=bj(vA(n,r));else if(i===e.TRANSFORM_DIRECTION){let e,i;t.isMatrix(n.getNodeType(t))?(e=n,i=r):(e=r,i=n),a=oj(yA(e,dk(J(i),0)).xyz)}return a===null?super.setup(t):a}generate(t,n){if(t.getNodeProperties(this).outputNode)return super.generate(t,n);let r=this.method,i=this.getNodeType(t),a=this.getInputType(t),o=this.aNode,s=this.bNode,c=this.cNode,l=t.renderer.coordinateSystem;if(r===e.NEGATE)return t.format(`( - `+o.build(t,a)+` )`,i,n);{let u=[];return r===e.CROSS?u.push(o.build(t,i),s.build(t,i)):l===2e3&&r===e.STEP?u.push(o.build(t,t.getTypeLength(o.getNodeType(t))===1?`float`:a),s.build(t,a)):l===2e3&&(r===e.MIN||r===e.MAX)?u.push(o.build(t,a),s.build(t,t.getTypeLength(s.getNodeType(t))===1?`float`:a)):r===e.REFRACT?u.push(o.build(t,a),s.build(t,a),c.build(t,`float`)):r===e.MIX?u.push(o.build(t,a),s.build(t,a),c.build(t,t.getTypeLength(c.getNodeType(t))===1?`float`:a)):(l===2001&&r===e.ATAN&&s!==null&&(r=`atan2`),t.shaderStage!==`fragment`&&(r===e.DFDX||r===e.DFDY)&&(F(`TSL: '${r}' is not supported in the ${t.shaderStage} stage.`,this.stackTrace),r=`/*`+r+`*/`),u.push(o.build(t,a)),s!==null&&u.push(s.build(t,a)),c!==null&&u.push(c.build(t,a))),t.format(`${t.getMethod(r,i)}( ${u.join(`, `)} )`,i,n)}}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}};Y.ALL=`all`,Y.ANY=`any`,Y.RADIANS=`radians`,Y.DEGREES=`degrees`,Y.EXP=`exp`,Y.EXP2=`exp2`,Y.LOG=`log`,Y.LOG2=`log2`,Y.SQRT=`sqrt`,Y.INVERSE_SQRT=`inversesqrt`,Y.FLOOR=`floor`,Y.CEIL=`ceil`,Y.NORMALIZE=`normalize`,Y.FRACT=`fract`,Y.SIN=`sin`,Y.SINH=`sinh`,Y.COS=`cos`,Y.COSH=`cosh`,Y.TAN=`tan`,Y.TANH=`tanh`,Y.ASIN=`asin`,Y.ASINH=`asinh`,Y.ACOS=`acos`,Y.ACOSH=`acosh`,Y.ATAN=`atan`,Y.ATANH=`atanh`,Y.ABS=`abs`,Y.SIGN=`sign`,Y.LENGTH=`length`,Y.NEGATE=`negate`,Y.ONE_MINUS=`oneMinus`,Y.DFDX=`dFdx`,Y.DFDY=`dFdy`,Y.ROUND=`round`,Y.RECIPROCAL=`reciprocal`,Y.TRUNC=`trunc`,Y.FWIDTH=`fwidth`,Y.TRANSPOSE=`transpose`,Y.DETERMINANT=`determinant`,Y.INVERSE=`inverse`,Y.EQUALS=`equals`,Y.MIN=`min`,Y.MAX=`max`,Y.STEP=`step`,Y.REFLECT=`reflect`,Y.DISTANCE=`distance`,Y.DIFFERENCE=`difference`,Y.DOT=`dot`,Y.CROSS=`cross`,Y.POW=`pow`,Y.TRANSFORM_DIRECTION=`transformDirection`,Y.MIX=`mix`,Y.CLAMP=`clamp`,Y.REFRACT=`refract`,Y.SMOOTHSTEP=`smoothstep`,Y.FACEFORWARD=`faceforward`;var HA=G(1e-6),UA=G(1e6),WA=G(Math.PI),GA=G(Math.PI*2),KA=G(Math.PI*2),qA=G(Math.PI*.5),JA=U(Y,Y.ALL).setParameterLength(1),YA=U(Y,Y.ANY).setParameterLength(1),XA=U(Y,Y.RADIANS).setParameterLength(1),ZA=U(Y,Y.DEGREES).setParameterLength(1),QA=U(Y,Y.EXP).setParameterLength(1),$A=U(Y,Y.EXP2).setParameterLength(1),ej=U(Y,Y.LOG).setParameterLength(1),tj=U(Y,Y.LOG2).setParameterLength(1),nj=U(Y,Y.SQRT).setParameterLength(1),rj=U(Y,Y.INVERSE_SQRT).setParameterLength(1),ij=U(Y,Y.FLOOR).setParameterLength(1),aj=U(Y,Y.CEIL).setParameterLength(1),oj=U(Y,Y.NORMALIZE).setParameterLength(1),sj=U(Y,Y.FRACT).setParameterLength(1),cj=U(Y,Y.SIN).setParameterLength(1),lj=U(Y,Y.SINH).setParameterLength(1),uj=U(Y,Y.COS).setParameterLength(1),dj=U(Y,Y.COSH).setParameterLength(1),fj=U(Y,Y.TAN).setParameterLength(1),pj=U(Y,Y.TANH).setParameterLength(1),mj=U(Y,Y.ASIN).setParameterLength(1),hj=U(Y,Y.ASINH).setParameterLength(1),gj=U(Y,Y.ACOS).setParameterLength(1),_j=U(Y,Y.ACOSH).setParameterLength(1),vj=U(Y,Y.ATAN).setParameterLength(1,2),yj=U(Y,Y.ATANH).setParameterLength(1),bj=U(Y,Y.ABS).setParameterLength(1),xj=U(Y,Y.SIGN).setParameterLength(1),Sj=U(Y,Y.LENGTH).setParameterLength(1),Cj=U(Y,Y.NEGATE).setParameterLength(1),wj=U(Y,Y.ONE_MINUS).setParameterLength(1),Tj=U(Y,Y.DFDX).setParameterLength(1),Ej=U(Y,Y.DFDY).setParameterLength(1),Dj=U(Y,Y.ROUND).setParameterLength(1),Oj=U(Y,Y.RECIPROCAL).setParameterLength(1),kj=U(Y,Y.TRUNC).setParameterLength(1),Aj=U(Y,Y.FWIDTH).setParameterLength(1),jj=U(Y,Y.TRANSPOSE).setParameterLength(1),Mj=U(Y,Y.DETERMINANT).setParameterLength(1),Nj=U(Y,Y.INVERSE).setParameterLength(1),Pj=U(Y,Y.MIN).setParameterLength(2,1/0),Fj=U(Y,Y.MAX).setParameterLength(2,1/0),Ij=U(Y,Y.STEP).setParameterLength(2),Lj=U(Y,Y.REFLECT).setParameterLength(2),Rj=U(Y,Y.DISTANCE).setParameterLength(2),zj=U(Y,Y.DIFFERENCE).setParameterLength(2),Bj=U(Y,Y.DOT).setParameterLength(2),Vj=U(Y,Y.CROSS).setParameterLength(2),Hj=U(Y,Y.POW).setParameterLength(2),Uj=e=>yA(e,e),Wj=e=>yA(e,e,e),Gj=e=>yA(e,e,e,e),Kj=U(Y,Y.TRANSFORM_DIRECTION).setParameterLength(2),qj=(e,t)=>oj(yA(t,dk(J(e),0)).xyz),Jj=(e,t)=>oj(dk(J(e),0).mul(t).xyz),Yj=e=>yA(xj(e),Hj(bj(e),1/3)),Xj=e=>Bj(e,e),Zj=U(Y,Y.MIX).setParameterLength(3),Qj=(e,t=0,n=1)=>new Y(Y.CLAMP,UO(e),UO(t),UO(n)),$j=e=>Qj(e),eM=U(Y,Y.REFRACT).setParameterLength(3),tM=U(Y,Y.SMOOTHSTEP).setParameterLength(3),nM=U(Y,Y.FACEFORWARD).setParameterLength(3),rM=W(([e])=>sj(cj(xA(Bj(e.xy,ik(12.9898,78.233)),WA)).mul(43758.5453))),iM=(e,t,n)=>Zj(t,n,e),aM=(e,t,n)=>tM(t,n,e),oM=(e,t)=>Ij(t,e),sM=nM,cM=rj;H(`all`,JA),H(`any`,YA),H(`radians`,XA),H(`degrees`,ZA),H(`exp`,QA),H(`exp2`,$A),H(`log`,ej),H(`log2`,tj),H(`sqrt`,nj),H(`inverseSqrt`,rj),H(`floor`,ij),H(`ceil`,aj),H(`normalize`,oj),H(`fract`,sj),H(`sin`,cj),H(`sinh`,lj),H(`cos`,uj),H(`cosh`,dj),H(`tan`,fj),H(`tanh`,pj),H(`asin`,mj),H(`asinh`,hj),H(`acos`,gj),H(`acosh`,_j),H(`atan`,vj),H(`atanh`,yj),H(`abs`,bj),H(`sign`,xj),H(`length`,Sj),H(`lengthSq`,Xj),H(`negate`,Cj),H(`oneMinus`,wj),H(`dFdx`,Tj),H(`dFdy`,Ej),H(`round`,Dj),H(`reciprocal`,Oj),H(`trunc`,kj),H(`fwidth`,Aj),H(`min`,Pj),H(`max`,Fj),H(`step`,oM),H(`reflect`,Lj),H(`distance`,Rj),H(`dot`,Bj),H(`cross`,Vj),H(`pow`,Hj),H(`pow2`,Uj),H(`pow3`,Wj),H(`pow4`,Gj),H(`transformDirection`,Kj),H(`transformNormalByViewMatrix`,qj),H(`transformNormalByInverseViewMatrix`,Jj),H(`mix`,iM),H(`clamp`,Qj),H(`refract`,eM),H(`smoothstep`,aM),H(`faceForward`,nM),H(`difference`,zj),H(`saturate`,$j),H(`cbrt`,Yj),H(`transpose`,jj),H(`determinant`,Mj),H(`inverse`,Nj),H(`rand`,rM);var lM=qO(class extends XD{static get type(){return`ConditionalNode`}constructor(e,t,n=null){super(),this.condNode=e,this.ifNode=t,this.elseNode=n}generateNodeType(e){let{ifNode:t,elseNode:n}=e.getNodeProperties(this);if(t===void 0)return e.flowBuildStage(this,`setup`),this.getNodeType(e);let r=t.getNodeType(e);if(n!==null){let t=n.getNodeType(e);if(e.getTypeLength(t)>e.getTypeLength(r))return t}return r}setup(e){let t=this.condNode,n=this.ifNode.isolate(),r=this.elseNode?this.elseNode.isolate():null,i=e.context.nodeBlock;e.getDataFromNode(n).parentNodeBlock=i,r!==null&&(e.getDataFromNode(r).parentNodeBlock=i);let a=e.context.uniformFlow,o=e.getNodeProperties(this);o.condNode=t,o.ifNode=a?n:n.context({nodeBlock:n}),o.elseNode=r?a?r:r.context({nodeBlock:r}):null}generate(e,t){let n=this.getNodeType(e),r=e.getDataFromNode(this);if(r.nodeProperty!==void 0)return r.nodeProperty;let{condNode:i,ifNode:a,elseNode:o}=e.getNodeProperties(this),s=e.currentFunctionNode,c=t!==`void`,l=c?Ck(n).build(e):``;r.nodeProperty=l;let u=i.build(e,`bool`);if(e.context.uniformFlow&&o!==null){let r=a.build(e,n),i=o.build(e,n),s=e.getTernary(u,r,i);return e.format(s,n,t)}e.addFlowCode(`\n${e.tab}if ( ${u} ) {\n\n`).addFlowTab();let d=a.build(e,n);if(d&&(c?d=l+` = `+d+`;`:(d=`return `+d+`;`,s===null&&(F(`TSL: Return statement used in an inline 'Fn()'. Define a layout struct to allow return values.`,this.stackTrace),d=`// `+d))),e.removeFlowTab().addFlowCode(e.tab+` `+d+` `+e.tab+`}`),o!==null){e.addFlowCode(` else { `).addFlowTab();let t=o.build(e,n);t&&(c?t=l+` = `+t+`;`:(t=`return `+t+`;`,s===null&&(F(`TSL: Return statement used in an inline 'Fn()'. Define a layout struct to allow return values.`,this.stackTrace),t=`// `+t))),e.removeFlowTab().addFlowCode(e.tab+` `+t+` `+e.tab+`} `)}else e.addFlowCode(` `);return e.format(l,n,t)}}).setParameterLength(2,3);H(`select`,lM);var uM=class extends XD{static get type(){return`ContextNode`}constructor(e=null,t={}){super(),this.isContextNode=!0,this.node=e,this.value=t}getScope(){return this.node.getScope()}generateNodeType(e){return this.node.getNodeType(e)}getFlowContextData(){let e=[];return this.traverse(t=>{t.isContextNode===!0&&e.push(t.value)}),Object.assign({},...e)}getMemberType(e,t){return this.node.getMemberType(e,t)}analyze(e){let t=e.addContext(this.value);this.node.build(e),e.setContext(t)}setup(e){let t=e.addContext(this.value);this.node.build(e),e.setContext(t)}generate(e,t){let n=e.addContext(this.value),r=this.node.build(e,t);return e.setContext(n),r}},dM=(e=null,t={})=>{let n=e;return(n===null||n.isNode!==!0)&&(t=n||t,n=null),new uM(n,t)},fM=e=>dM(e,{uniformFlow:!0}),pM=(e,t)=>dM(e,{nodeName:t});function mM(e,t,n=null){return dM(n,{getShadow:({light:n,shadowColorNode:r})=>t===n?r.mul(e):r})}function hM(e,t=null){return dM(t,{getAO:(t,{material:n})=>n.transparent===!0?t:t===null?e:t.mul(e)})}function gM(e,t){return F(`TSL: "label()" has been deprecated. Use "setName()" instead.`),pM(e,t)}H(`context`,dM),H(`label`,gM),H(`uniformFlow`,fM),H(`setName`,pM),H(`builtinShadowContext`,(e,t,n)=>mM(t,n,e)),H(`builtinAOContext`,(e,t)=>hM(t,e));var _M=class extends XD{static get type(){return`VarNode`}constructor(e,t=null,n=!1){super(),this.node=e,this.name=t,this.global=!0,this.isVarNode=!0,this.readOnly=n,this.parents=!0,this.intent=!1}setIntent(e){return this.intent=e,this}isIntent(e){return e.getDataFromNode(this).forceDeclaration===!0?!1:this.intent}getIntent(){return this.intent}getMemberType(e,t){return this.node.getMemberType(e,t)}getElementType(e){return this.node.getElementType(e)}generateNodeType(e){return this.node.getNodeType(e)}getArrayCount(e){return this.node.getArrayCount(e)}isAssign(e){return e.getDataFromNode(this).assign}build(...e){let t=e[0],n=this.getShared(t);if(this!==n)return n.build(...e);if(this._hasStack(t)===!1&&t.buildStage===`setup`&&(t.context.nodeLoop||t.context.nodeBlock)){let e=!1;if(this.node.isShaderCallNodeInternal&&this.node.shaderNode.getLayout()===null&&t.fnCall&&t.fnCall.shaderNode&&t.getDataFromNode(this.node.shaderNode).hasLoop){let n=t.getDataFromNode(this);n.forceDeclaration=!0,e=!0}let n=t.getBaseStack();e?n.addToStackBefore(this):n.addToStack(this)}return this.isIntent(t)&&this.isAssign(t)!==!0?this.node.build(...e):super.build(...e)}generate(e){let{node:t,name:n,readOnly:r}=this,{renderer:i}=e,a=i.backend.isWebGPUBackend===!0,o=!1,s=!1;r&&(o=e.isDeterministic(t),s=a?r:o);let c=this.getNodeType(e);if(c==`void`)return this.isIntent(e)!==!0&&I(`TSL: ".toVar()" can not be used with void type.`,this.stackTrace),t.build(e);let l=e.getVectorType(c),u=t.build(e,l),d=e.getVarFromNode(this,n,l,void 0,s),f=e.getPropertyName(d),p=f;if(s)if(a)p=o?`const ${f}`:`let ${f}`;else{let n=t.getArrayCount(e);p=`const ${e.getVar(d.type,f,n)}`}return e.addLineFlowCode(`${p} = ${u}`,this),f}_hasStack(e){return e.getDataFromNode(this).stack!==void 0}},vM=qO(_M),yM=(e,t=null)=>vM(e,t).toStack(),bM=(e,t=null)=>vM(e,t,!0).toStack(),xM=e=>vM(e).setIntent(!0).toStack();H(`toVar`,yM),H(`toConst`,bM),H(`toVarIntent`,xM);var SM=class extends XD{static get type(){return`SubBuild`}constructor(e,t,n=null){super(n),this.node=e,this.name=t,this.isSubBuildNode=!0}generateNodeType(e){if(this.nodeType!==null)return this.nodeType;e.addSubBuild(this.name);let t=this.node.getNodeType(e);return e.removeSubBuild(),t}build(e,...t){e.addSubBuild(this.name);let n=this.node.build(e,...t);return e.removeSubBuild(),n}},CM=(e,t,n=null)=>new SM(UO(e),t,n),wM=qO(class extends XD{static get type(){return`VaryingNode`}constructor(e,t=null){super(),this.node=CM(e,`VERTEX`),this.name=t,this.isVaryingNode=!0,this.interpolationType=null,this.interpolationSampling=null,this.global=!0}setInterpolation(e,t=null){return this.interpolationType=e,this.interpolationSampling=t,this}getHash(e){return this.name||super.getHash(e)}generateNodeType(e){return this.node.getNodeType(e)}setupVarying(e){let t=e.getNodeProperties(this),n=t.varying;if(n===void 0){let r=this.name,i=this.getNodeType(e),a=this.interpolationType,o=this.interpolationSampling;t.varying=n=e.getVaryingFromNode(this,r,i,a,o),t.node=CM(this.node,`VERTEX`)}return n.needsInterpolation||=e.shaderStage===`fragment`,n}setup(e){this.setupVarying(e),e.flowNodeFromShaderStage(BD.VERTEX,this.node)}analyze(e){this.setupVarying(e),e.flowNodeFromShaderStage(BD.VERTEX,this.node)}generate(e){let t=e.getSubBuildProperty(`property`,e.currentStack),n=e.getNodeProperties(this),r=this.setupVarying(e);if(n[t]===void 0){let i=this.getNodeType(e),a=e.getPropertyName(r,BD.VERTEX);if(e.shaderStage===BD.VERTEX){let t=n.node.build(e,i);e.addLineFlowCode(`${a} = ${t}`,this)}else e.flowNodeFromShaderStage(BD.VERTEX,n.node,i,a);n[t]=a}return e.getPropertyName(r)}}).setParameterLength(1,2),TM=e=>wM(e);H(`toVarying`,wM),H(`toVertexStage`,TM);var EM=W(([e])=>Zj(e.mul(.9478672986).add(.0521327014).pow(2.4),e.mul(.0773993808),e.lessThanEqual(.04045))).setLayout({name:`sRGBTransferEOTF`,type:`vec3`,inputs:[{name:`color`,type:`vec3`}]}),DM=W(([e])=>Zj(e.pow(.41666).mul(1.055).sub(.055),e.mul(12.92),e.lessThanEqual(.0031308))).setLayout({name:`sRGBTransferOETF`,type:`vec3`,inputs:[{name:`color`,type:`vec3`}]}),OM=`WorkingColorSpace`,kM=`OutputColorSpace`,AM=class extends $D{static get type(){return`ColorSpaceNode`}constructor(e,t,n){super(`vec4`),this.colorNode=e,this.source=t,this.target=n}resolveColorSpace(e,t){return t===OM?jn.workingColorSpace:t===kM?e.context.outputColorSpace||e.renderer.outputColorSpace:t}setup(e){let{colorNode:t}=this,n=this.resolveColorSpace(e,this.source),r=this.resolveColorSpace(e,this.target),i=t;return jn.enabled===!1||n===r||!n||!r?i:(jn.getTransfer(n)===`srgb`&&(i=dk(EM(i.rgb),i.a)),jn.getPrimaries(n)!==jn.getPrimaries(r)&&(i=dk(gk(jn._getMatrix(new En,n,r)).mul(i.rgb),i.a)),jn.getTransfer(r)===`srgb`&&(i=dk(DM(i.rgb),i.a)),i)}},jM=(e,t)=>new AM(UO(e),OM,t),MM=(e,t)=>new AM(UO(e),t,OM),NM=(e,t,n)=>new AM(UO(e),t,n);H(`workingToColorSpace`,jM),H(`colorSpaceToWorking`,MM);var PM=class extends ZD{static get type(){return`ReferenceElementNode`}constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}generateNodeType(){return this.referenceNode.uniformType}generate(e){let t=super.generate(e),n=this.referenceNode.getNodeType(),r=this.getNodeType();return e.format(t,n,r)}},FM=class extends XD{static get type(){return`ReferenceBaseNode`}constructor(e,t,n=null,r=null){super(),this.property=e,this.uniformType=t,this.object=n,this.count=r,this.properties=e.split(`.`),this.reference=n,this.node=null,this.group=null,this.updateType=VD.OBJECT}setGroup(e){return this.group=e,this}element(e){return new PM(this,UO(e))}setNodeType(e){let t=lA(null,e);this.group!==null&&t.setGroup(this.group),this.node=t}generateNodeType(e){return this.node===null&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){let{properties:t}=this,n=e[t[0]];for(let e=1;enew FM(e,t,n),LM=class extends FM{static get type(){return`RendererReferenceNode`}constructor(e,t,n=null){super(e,t,n),this.renderer=n,this.setGroup(oA)}updateReference(e){return this.reference=this.renderer===null?e.renderer:this.renderer,this.reference}},RM=(e,t,n=null)=>new LM(e,t,n),zM=class extends $D{static get type(){return`ToneMappingNode`}constructor(e,t=VM,n=null){super(`vec3`),this._toneMapping=e,this.exposureNode=t,this.colorNode=n}customCacheKey(){return DD(this._toneMapping)}setToneMapping(e){return this._toneMapping=e,this}getToneMapping(){return this._toneMapping}setup(e){let t=this.colorNode||e.context.color,n=this._toneMapping;if(n===0)return t;let r=null,i=e.renderer.library.getToneMappingFunction(n);return i===null?(I(`ToneMappingNode: Unsupported Tone Mapping configuration.`,n),r=t):r=dk(i(t.rgb,this.exposureNode),t.a),r}},BM=(e,t,n)=>new zM(e,UO(t),UO(n)),VM=RM(`toneMappingExposure`,`float`);H(`toneMapping`,(e,t,n)=>BM(t,n,e));var HM=new WeakMap;function UM(e,t){let n=HM.get(e);return n===void 0&&(n=new Oi(e,t),HM.set(e,n)),n}var WM=class extends aO{static get type(){return`BufferAttributeNode`}constructor(e,t=null,n=0,r=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferStride=n,this.bufferOffset=r,this.usage=At,this.instanced=!1,this.attribute=null,this.global=!0,e&&e.isBufferAttribute===!0&&e.itemSize<=4&&(this.attribute=e,this.usage=e.usage,this.instanced=e.isInstancedBufferAttribute)}getHash(e){let t;if(this.bufferStride===0&&this.bufferOffset===0){let n=e.globalCache.getData(this.value);n===void 0&&(n={node:this},e.globalCache.setData(this.value,n)),t=n.node.id}else t=this.id;return String(t)}generateNodeType(e){return this.bufferType===null&&(this.bufferType=e.getTypeFromAttribute(this.attribute)),this.bufferType}setup(e){if(this.attribute!==null)return;let t=this.getNodeType(e),n=e.getTypeLength(t),r=this.value,i=this.bufferStride||n,a=this.bufferOffset,o;o=r.isInterleavedBuffer===!0?r:r.isBufferAttribute===!0?UM(r.array,i):UM(r,i);let s=new Ai(o,n,a);o.setUsage(this.usage),this.attribute=s,this.attribute.isInstancedBufferAttribute=this.instanced}generate(e){let t=this.getNodeType(e),n=e.context.nodeName;n!==void 0&&delete e.context.nodeName;let r=e.getBufferAttributeFromNode(this,t,n),i=e.getPropertyName(r),a=null;if(e.shaderStage===`vertex`||e.shaderStage===`compute`)this.name=i,a=i;else{let r;n&&(r=n+`Varying`),a=wM(this,r).build(e,t)}return a}getInputType(){return`bufferAttribute`}setUsage(e){return this.usage=e,this.attribute&&this.attribute.isBufferAttribute===!0&&(this.attribute.usage=e),this}setInstanced(e){return this.instanced=e,this}};function GM(e,t=null,n=0,r=0,i=At,a=!1){return t===`mat3`||t===null&&e.itemSize===9?gk(new WM(e,`vec3`,9,0).setUsage(i).setInstanced(a),new WM(e,`vec3`,9,3).setUsage(i).setInstanced(a),new WM(e,`vec3`,9,6).setUsage(i).setInstanced(a)):t===`mat4`||t===null&&e.itemSize===16?_k(new WM(e,`vec4`,16,0).setUsage(i).setInstanced(a),new WM(e,`vec4`,16,4).setUsage(i).setInstanced(a),new WM(e,`vec4`,16,8).setUsage(i).setInstanced(a),new WM(e,`vec4`,16,12).setUsage(i).setInstanced(a)):new WM(e,t,n,r).setUsage(i)}var KM=(e,t=null,n=0,r=0)=>GM(e,t,n,r),qM=(e,t=null,n=0,r=0)=>GM(e,t,n,r,jt),JM=(e,t=null,n=0,r=0)=>GM(e,t,n,r,At,!0),YM=(e,t=null,n=0,r=0)=>GM(e,t,n,r,jt,!0);H(`toAttribute`,e=>KM(e.value));var XM=class e extends XD{static get type(){return`IndexNode`}constructor(e){super(`uint`),this.scope=e,this.isIndexNode=!0}generate(t){let n=this.getNodeType(t),r=this.scope,i;if(r===e.VERTEX)i=t.getVertexIndex();else if(r===e.INSTANCE)i=t.getInstanceIndex();else if(r===e.DRAW)i=t.getDrawIndex();else if(r===e.INVOCATION_LOCAL)i=t.getInvocationLocalIndex();else if(r===e.INVOCATION_SUBGROUP)i=t.getInvocationSubgroupIndex();else if(r===e.SUBGROUP)i=t.getSubgroupIndex();else throw Error(`THREE.IndexNode: Unknown scope: `+r);let a;return a=t.shaderStage===`vertex`||t.shaderStage===`compute`?i:wM(this).build(t,n),a}};XM.VERTEX=`vertex`,XM.INSTANCE=`instance`,XM.SUBGROUP=`subgroup`,XM.INVOCATION_LOCAL=`invocationLocal`,XM.INVOCATION_SUBGROUP=`invocationSubgroup`,XM.DRAW=`draw`;var ZM=JO(XM,XM.VERTEX),QM=JO(XM,XM.INSTANCE),$M=JO(XM,XM.SUBGROUP),eN=JO(XM,XM.INVOCATION_SUBGROUP),tN=JO(XM,XM.INVOCATION_LOCAL),nN=JO(XM,XM.DRAW),rN=class extends XD{static get type(){return`ComputeNode`}constructor(e,t){super(`void`),this.isComputeNode=!0,this.computeNode=e,this.workgroupSize=t,this.count=null,this.dispatchSize=null,this.version=1,this.name=``,this.updateBeforeType=VD.OBJECT,this.onInitFunction=null,this.countNode=null}dispose(){this.dispatchEvent({type:`dispose`})}setName(e){return this.name=e,this}label(e){return F(`TSL: "label()" has been deprecated. Use "setName()" instead.`,new CD),this.setName(e)}onInit(e){return this.onInitFunction=e,this}updateBefore({renderer:e}){e.compute(this)}setup(e){this.count!==null&&this.countNode===null&&(this.countNode=lA(this.count,`uint`).onObjectUpdate(()=>this.count));let t=this.computeNode.build(e);if(t){let n=e.getNodeProperties(this);n.outputComputeNode=t.outputNode,t.outputNode=null}return t}generate(e,t){let{shaderStage:n}=e;if(n===`compute`){let t=this.computeNode.build(e,`void`);if(t!==``&&e.addLineFlowCode(t,this),this.count!==null&&e.allowEarlyReturns===!0){let t=this.countNode.build(e,`uint`),n=QM.build(e,`uint`);e.flow.code=`${e.tab}if ( ${n} >= ${t} ) { return; }\n\n${e.flow.code}`}}else{let n=e.getNodeProperties(this).outputComputeNode;if(n)return n.build(e,t)}}},iN=(e,t=[64])=>{(t.length===0||t.length>3)&&I(`TSL: compute() workgroupSize must have 1, 2, or 3 elements`,new CD);for(let e=0;e{let r=iN(e,n);return typeof t==`number`?r.count=t:r.dispatchSize=t,r};H(`compute`,aN),H(`computeKernel`,iN);var oN=class extends XD{static get type(){return`IsolateNode`}constructor(e,t=!0){super(),this.node=e,this.parent=t,this.isIsolateNode=!0}generateNodeType(e){let t=e.getCache(),n=e.getCacheFromNode(this,this.parent);e.setCache(n);let r=this.node.getNodeType(e);return e.setCache(t),r}build(e,...t){let n=e.getCache(),r=e.getCacheFromNode(this,this.parent);e.setCache(r);let i=this.node.build(e,...t);return e.setCache(n),i}setParent(e){return this.parent=e,this}getParent(){return this.parent}},sN=e=>new oN(UO(e));function cN(e,t=!0){return F(`TSL: "cache()" has been deprecated. Use "isolate()" instead.`),sN(e).setParent(t)}H(`cache`,cN),H(`isolate`,sN);var lN=qO(class extends XD{static get type(){return`BypassNode`}constructor(e,t){super(),this.isBypassNode=!0,this.outputNode=e,this.callNode=t}generateNodeType(e){return this.outputNode.getNodeType(e)}generate(e){let t=this.callNode.build(e,`void`);return t!==``&&e.addLineFlowCode(t,this),this.outputNode.build(e)}}).setParameterLength(2);H(`bypass`,lN);var uN=W(([e,t,n,r=G(0),i=G(1),a=rk(!1)])=>{let o=e.sub(t).div(n.sub(t));return BO(a)&&(o=o.clamp()),o.mul(i.sub(r)).add(r)});function dN(e,t,n,r=G(0),i=G(1)){return uN(e,t,n,r,i,!0)}H(`remap`,uN),H(`remapClamp`,dN);var fN=class extends XD{static get type(){return`ExpressionNode`}constructor(e=``,t=`void`){super(t),this.snippet=e}generate(e,t){let n=this.getNodeType(e),r=this.snippet;if(n===`void`)e.addLineFlowCode(r,this);else return e.format(r,n,t)}},pN=qO(fN).setParameterLength(1,2),mN=e=>(e?lM(e,pN(`discard`)):pN(`discard`)).toStack(),hN=()=>pN(`return`).toStack();H(`discard`,mN);var gN=W(([e])=>dk(e.rgb.mul(e.a),e.a),{color:`vec4`,return:`vec4`}),_N=W(([e])=>e.a.equal(0).select(dk(0),dk(e.rgb.div(e.a),e.a)),{color:`vec4`,return:`vec4`}),vN=class extends $D{static get type(){return`RenderOutputNode`}constructor(e,t,n){super(`vec4`),this.colorNode=e,this._toneMapping=t,this.outputColorSpace=n,this.isRenderOutputNode=!0}setToneMapping(e){return this._toneMapping=e,this}getToneMapping(){return this._toneMapping}setup({context:e}){let t=this.colorNode||e.color;t=dk(t.rgb,t.a.clamp(0,1)),t=_N(t);let n=(this._toneMapping===null?e.toneMapping:this._toneMapping)||0,r=(this.outputColorSpace===null?e.outputColorSpace:this.outputColorSpace)||``;return n!==0&&(t=t.toneMapping(n)),r!==``&&r!==jn.workingColorSpace&&(t=t.workingToColorSpace(r)),t=gN(t),t}},yN=(e,t=null,n=null)=>new vN(UO(e),t,n);H(`renderOutput`,yN);var bN=class extends $D{static get type(){return`DebugNode`}constructor(e,t=null){super(),this.node=e,this.callback=t}generateNodeType(e){return this.node.getNodeType(e)}setup(e){return this.node.build(e)}analyze(e){return this.node.build(e)}generate(e){let t=this.callback,n=this.node.build(e);if(t!==null)t(e,n);else{let t=`--- TSL debug - `+e.shaderStage+` shader ---`,r=`-`.repeat(t.length),i=``;i+=`// #`+t+`# `,i+=e.flow.code.replace(/^\t/gm,``)+` `,i+=`/* ... */ `+n+` /* ... */ `,i+=`// #`+r+`# `,Ht(i)}return n}},xN=(e,t=null)=>new bN(UO(e),t).toStack();H(`debug`,xN);var SN=class extends Jt{constructor(){super(),this._renderer=null,this.currentFrame=null}get nodeFrame(){return this._renderer._nodes.nodeFrame}setRenderer(e){return this._renderer=e,this}getRenderer(){return this._renderer}init(){}begin(){}finish(){}inspect(){}computeAsync(){}beginCompute(){}finishCompute(){}beginRender(){}finishRender(){}copyTextureToTexture(){}copyFramebufferToTexture(){}},CN=class extends XD{static get type(){return`InspectorNode`}constructor(e,t=``,n=null){super(),this.node=e,this.name=t,this.callback=n,this.updateType=VD.FRAME,this.isInspectorNode=!0}getName(){return this.name||this.node.name}update(e){e.renderer.inspector.inspect(this)}generateNodeType(e){return this.node.getNodeType(e)}setup(e){let t=this.node;return e.context.inspector===!0&&this.callback!==null&&(t=this.callback(t)),e.renderer.backend.isWebGPUBackend!==!0&&e.renderer.inspector.constructor!==SN&&Wt(`TSL: ".toInspector()" is only available with WebGPU.`),t}};function wN(e,t=``,n=null){return e=UO(e),e.before(new CN(e,t,n))}H(`toInspector`,wN);function TN(e){F(`TSL: AddNodeElement has been removed in favor of tree-shaking. Trying add`,e)}var EN=class extends XD{static get type(){return`AttributeNode`}constructor(e,t=null){super(t),this.global=!0,this._attributeName=e}getHash(e){return this.getAttributeName(e)}generateNodeType(e){let t=this.nodeType;if(t===null){let n=this.getAttributeName(e);if(e.hasGeometryAttribute(n)){let r=e.geometry.getAttribute(n);t=e.getTypeFromAttribute(r)}else t=`float`}return t}setAttributeName(e){return this._attributeName=e,this}getAttributeName(){return this._attributeName}generate(e){let t=this.getAttributeName(e),n=this.getNodeType(e);if(e.hasGeometryAttribute(t)===!0){let r=e.geometry.getAttribute(t),i=e.getTypeFromAttribute(r),a=e.getAttribute(t,i);return e.shaderStage===`vertex`?e.format(a.name,i,n):wM(this).build(e,n)}else return F(`AttributeNode: Vertex attribute "${t}" not found on geometry.`),e.generateConst(n)}serialize(e){super.serialize(e),e.global=this.global,e._attributeName=this._attributeName}deserialize(e){super.deserialize(e),this.global=e.global,this._attributeName=e._attributeName}},DN=(e,t=null)=>new EN(e,t),ON=(e=0)=>DN(`uv`+(e>0?e:``),`vec2`),kN=qO(class extends XD{static get type(){return`TextureSizeNode`}constructor(e,t=null){super(`uvec2`),this.isTextureSizeNode=!0,this.textureNode=e,this.levelNode=t}generate(e,t){let n=this.textureNode.build(e,`property`),r=this.levelNode===null?`0`:this.levelNode.build(e,`int`);return e.format(`${e.getMethod(`textureDimensions`)}( ${n}, ${r} )`,this.getNodeType(e),t)}}).setParameterLength(1,2),AN=qO(class extends cA{static get type(){return`MaxMipLevelNode`}constructor(e){super(0),this._textureNode=e,this.updateType=VD.FRAME}get textureNode(){return this._textureNode}get texture(){return this._textureNode.value}update(){let e=this.texture,t=e.images,n=t&&t.length>0?t[0]&&t[0].image||t[0]:e.image;if(n&&n.width!==void 0){let{width:e,height:t}=n;this.value=Math.log2(Math.max(e,t))}}}).setParameterLength(1),jN=class extends Error{constructor(e,t=null){super(e),this.name=`NodeError`,this.stackTrace=t}},MN=new Vn,NN=class extends cA{static get type(){return`TextureNode`}constructor(e=MN,t=null,n=null,r=null){super(e),this.isTextureNode=!0,this.uvNode=t,this.levelNode=n,this.biasNode=r,this.compareNode=null,this.depthNode=null,this.gradNode=null,this.gatherNode=null,this.offsetNode=null,this.sampler=!0,this.updateMatrix=!1,this.updateType=VD.NONE,this.referenceNode=null,this._value=e,this._matrixUniform=null,this._flipYUniform=null,this.setUpdateMatrix(t===null)}set value(e){this.referenceNode?this.referenceNode.value=e:this._value=e}get value(){return this.referenceNode?this.referenceNode.value:this._value}getUniformHash(){return this.value.uuid}generateNodeType(){return this.value.isDepthTexture===!0?this.gatherNode===null?`float`:`vec4`:this.value.type===1014?`uvec4`:this.value.type===1013?`ivec4`:`vec4`}getInputType(){return`texture`}getDefaultUV(){return ON(this.value.channel)}updateReference(){return this.value}getTransformedUV(e){return this._matrixUniform===null&&(this._matrixUniform=lA(this.value.matrix)),this._matrixUniform.mul(J(e,1)).xy}setUpdateMatrix(e){return this.updateMatrix=e,this}setupUV(e,t){return e.isFlipY()&&(this._flipYUniform===null&&(this._flipYUniform=lA(!1)),t=t.toVar(),t=this.sampler?this._flipYUniform.select(t.flipY(),t):this._flipYUniform.select(t.setY(K(kN(this,this.levelNode).y).sub(t.y).sub(1)),t)),t}setup(e){let t=e.getNodeProperties(this);t.referenceNode=this.referenceNode;let n=this.value;if(!n||n.isTexture!==!0)throw new jN("THREE.TSL: `texture( value )` function expects a valid instance of THREE.Texture().",this.stackTrace);let r=W(()=>{let t=this.uvNode;return(t===null||e.context.forceUVContext===!0)&&e.context.getUV&&(t=e.context.getUV(this,e)),t||=this.getDefaultUV(),this.updateMatrix===!0&&(t=this.getTransformedUV(t)),t=this.setupUV(e,t),this.updateType=this._matrixUniform!==null||this._flipYUniform!==null?VD.OBJECT:VD.NONE,t})(),i=this.levelNode;i===null&&e.context.getTextureLevel&&(i=e.context.getTextureLevel(this));let a=null,o=null;if(this.compareNode!==null)if(e.renderer.hasCompatibility(Ft.TEXTURE_COMPARE))a=this.compareNode;else{let e=n.compareFunction;e===null||e===513||e===515||e===516||e===518?o=this.compareNode:(a=this.compareNode,Wt(`TSL: Only "LessCompare", "LessEqualCompare", "GreaterCompare" and "GreaterEqualCompare" are supported for depth texture comparison fallback.`))}t.uvNode=r,t.levelNode=i,t.biasNode=this.biasNode,t.compareNode=a,t.compareStepNode=o,t.gradNode=this.gradNode,t.gatherNode=this.gatherNode,t.depthNode=this.depthNode,t.offsetNode=this.offsetNode}generateUV(e,t){return t.build(e,this.sampler===!0?`vec2`:`ivec2`)}generateOffset(e,t){return t.build(e,`ivec2`)}generateSnippet(e,t,n,r,i,a,o,s,c,l,u){let d=this.value,f;return f=i?e.generateTextureBias(d,t,n,i,a,l):s?e.generateTextureGrad(d,t,n,s,a,l):c?o?e.generateTextureGatherCompare(d,t,n,o,a,l,u):e.generateTextureGather(d,t,n,c,a,l,u):o?e.generateTextureCompare(d,t,n,o,a,l):this.sampler===!1?e.generateTextureLoad(d,t,n,r,a,l):r?e.generateTextureLevel(d,t,n,r,a,l):e.generateTexture(d,t,n,a,l),f}generate(e,t){let n=this.value,r=e.getNodeProperties(this),i=super.generate(e,`property`);if(/^sampler/.test(t))return i+`_sampler`;if(e.isReference(t))return i;{let a=e.getDataFromNode(this),o=this.getNodeType(e),s=a.propertyName;if(s===void 0){let{uvNode:t,levelNode:c,biasNode:l,compareNode:u,compareStepNode:d,depthNode:f,gradNode:p,gatherNode:m,offsetNode:h}=r,g=this.generateUV(e,t),_=c?c.build(e,`float`):null,v=l?l.build(e,`float`):null,y=f?f.build(e,`int`):null,b=u?u.build(e,`float`):null,x=d?d.build(e,`float`):null,S=p?[p[0].build(e,`vec2`),p[1].build(e,`vec2`)]:null,C=m?m.build(e,`int`):null,w=h?this.generateOffset(e,h):null,T=this._flipYUniform?this._flipYUniform.build(e,`bool`):null;C&&(o=`vec4`);let E=y;E===null&&n.isArrayTexture&&this.isTexture3DNode!==!0&&(E=`0`);let D=e.getVarFromNode(this);s=e.getPropertyName(D);let O=this.generateSnippet(e,i,g,_,v,E,b,S,C,w,T);if(x!==null){let t=n.compareFunction;O=t===516||t===518?Ij(pN(O,o),pN(x,`float`)).build(e,o):Ij(pN(x,`float`),pN(O,o)).build(e,o)}e.addLineFlowCode(`${s} = ${O}`,this),a.snippet=O,a.propertyName=s}let c=s;return e.needsToWorkingColorSpace(n)&&(c=MM(pN(c,o),n.colorSpace).setup(e).build(e,o)),e.format(c,o,t)}}setSampler(e){return this.sampler=e,this}getSampler(){return this.sampler}sample(e){let t=this.clone();return t.uvNode=UO(e),t.referenceNode=this.getBase(),UO(t)}load(e){return this.sample(e).setSampler(!1)}blur(e){let t=this.clone();t.biasNode=UO(e).mul(AN(t)),t.referenceNode=this.getBase();let n=t.value;return t.generateMipmaps===!1&&(n&&n.generateMipmaps===!1||n.minFilter===1003||n.magFilter===1003)&&(F(`TSL: texture().blur() requires mipmaps and sampling. Use .generateMipmaps=true and .minFilter/.magFilter=THREE.LinearFilter in the Texture.`),t.biasNode=null),UO(t)}level(e){let t=this.clone();return t.levelNode=UO(e),t.referenceNode=this.getBase(),UO(t)}size(e){return kN(this,e)}bias(e){let t=this.clone();return t.biasNode=UO(e),t.referenceNode=this.getBase(),UO(t)}getBase(){return this.referenceNode?this.referenceNode.getBase():this}compare(e){let t=this.clone();return t.compareNode=UO(e),t.referenceNode=this.getBase(),UO(t)}grad(e,t){let n=this.clone();return n.gradNode=[UO(e),UO(t)],n.referenceNode=this.getBase(),UO(n)}gather(e=0){let t=this.clone();return t.gatherNode=UO(e),t.referenceNode=this.getBase(),UO(t)}depth(e){let t=this.clone();return t.depthNode=UO(e),t.referenceNode=this.getBase(),UO(t)}offset(e){let t=this.clone();return t.offsetNode=UO(e),t.referenceNode=this.getBase(),UO(t)}serialize(e){super.serialize(e),e.value=this.value.toJSON(e.meta).uuid,e.sampler=this.sampler,e.updateMatrix=this.updateMatrix,e.updateType=this.updateType}deserialize(e){super.deserialize(e),this.value=e.meta.textures[e.value],this.sampler=e.sampler,this.updateMatrix=e.updateMatrix,this.updateType=e.updateType}update(){let e=this.value,t=this._matrixUniform;t!==null&&(t.value=e.matrix),e.matrixAutoUpdate===!0&&e.updateMatrix();let n=this._flipYUniform;n!==null&&(n.value=e.image instanceof ImageBitmap&&e.flipY===!0||e.isRenderTargetTexture===!0||e.isFramebufferTexture===!0||e.isDepthTexture===!0)}clone(){let e=new this.constructor(this.value,this.uvNode,this.levelNode,this.biasNode);return e.sampler=this.sampler,e.depthNode=this.depthNode,e.compareNode=this.compareNode,e.gradNode=this.gradNode,e.gatherNode=this.gatherNode,e.offsetNode=this.offsetNode,e}},PN=qO(NN).setParameterLength(1,4).setName(`texture`),FN=(e=MN,t=null,n=null,r=null)=>{let i;return e&&e.isTextureNode===!0?(i=UO(e.clone()),i.referenceNode=e.getBase(),t!==null&&(i.uvNode=UO(t)),n!==null&&(i.levelNode=UO(n)),r!==null&&(i.biasNode=UO(r))):i=PN(e,t,n,r),i},IN=(e=MN)=>FN(e),LN=(...e)=>FN(...e).setSampler(!1),RN=(e,t,n)=>FN(e,t).level(n),zN=e=>(e.isNode===!0?e:FN(e)).convert(`sampler`),BN=e=>(e.isNode===!0?e:FN(e)).convert(`samplerComparison`),VN=class extends cA{static get type(){return`BufferNode`}constructor(e,t,n=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferCount=n,this.updateRanges=[]}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}getElementType(e){return this.getNodeType(e)}getInputType(){return`buffer`}},HN=(e,t,n)=>new VN(e,t,n),UN=class extends ZD{static get type(){return`UniformArrayElementNode`}constructor(e,t){super(e,t),this.isArrayBufferElementNode=!0}generate(e){let t=super.generate(e),n=this.getNodeType(e),r=this.node.getPaddedType();return e.format(t,r,n)}},WN=class extends VN{static get type(){return`UniformArrayNode`}constructor(e,t=null){super(null),this.array=e,this.elementType=t===null?FD(e[0]):t,this.paddedType=this.getPaddedType(),this.updateType=VD.RENDER,this.isArrayBufferNode=!0}generateNodeType(){return this.paddedType}getElementType(){return this.elementType}getPaddedType(){let e=this.elementType,t=`vec4`;return e===`mat2`?t=`mat2`:/mat/.test(e)===!0?t=`mat4`:e.charAt(0)===`i`?t=`ivec4`:e.charAt(0)===`u`&&(t=`uvec4`),t}update(){let{array:e,value:t}=this,n=this.elementType;if(n===`float`||n===`int`||n===`uint`)for(let n=0;nnew WN(e,t),KN=qO(class extends XD{constructor(e){super(`float`),this.name=e,this.isBuiltinNode=!0}generate(){return this.name}}).setParameterLength(1),qN,JN,YN=class e extends XD{static get type(){return`ScreenNode`}constructor(e){super(),this.scope=e,this._output=null,this.isViewportNode=!0}generateNodeType(){return this.scope===e.DPR?`float`:this.scope===e.VIEWPORT?`vec4`:`vec2`}getUpdateType(){let t=VD.NONE;return(this.scope===e.SIZE||this.scope===e.VIEWPORT||this.scope===e.DPR)&&(t=VD.RENDER),this.updateType=t,t}update({renderer:t}){let n=t.getRenderTarget();this.scope===e.VIEWPORT?n===null?(t.getViewport(JN),JN.multiplyScalar(t.getPixelRatio())):JN.copy(n.viewport):this.scope===e.DPR?this._output.value=t.getPixelRatio():n===null?t.getDrawingBufferSize(qN):(qN.width=n.width,qN.height=n.height)}setup(){let t=this.scope,n=null;return n=t===e.SIZE?lA(qN||=new L):t===e.VIEWPORT?lA(JN||=new Hn):t===e.DPR?lA(1):ik($N.div(QN)),this._output=n,n}generate(t){if(this.scope===e.COORDINATE){let e=t.getFragCoord();if(t.isFlipY()){let n=t.getNodeProperties(QN).outputNode.build(t);e=`${t.getType(`vec2`)}( ${e}.x, ${n}.y - ${e}.y )`}return e}return super.generate(t)}};YN.COORDINATE=`coordinate`,YN.VIEWPORT=`viewport`,YN.SIZE=`size`,YN.UV=`uv`,YN.DPR=`dpr`;var XN=JO(YN,YN.DPR),ZN=JO(YN,YN.UV),QN=JO(YN,YN.SIZE),$N=JO(YN,YN.COORDINATE),eP=JO(YN,YN.VIEWPORT),tP=eP.zw,nP=$N.sub(eP.xy),rP=nP.div(tP),iP=W(()=>(F(`TSL: "viewportResolution" is deprecated. Use "screenSize" instead.`,new CD),QN),`vec2`).once()(),aP=null,oP=null,sP=null,cP=null,lP=null,uP=null,dP=null,fP=null,pP=null,mP=null,hP=null,gP=null,_P=null,vP=null,yP=lA(0,`uint`).setName(`u_cameraIndex`).setGroup(iA(`cameraIndex`)).toVarying(`v_cameraIndex`),bP=lA(`float`).setName(`cameraNear`).setGroup(oA).onRenderUpdate(({camera:e})=>e.near),xP=lA(`float`).setName(`cameraFar`).setGroup(oA).onRenderUpdate(({camera:e})=>e.far),SP=W(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){let n=[];for(let t of e.cameras)n.push(t.projectionMatrix);oP===null?oP=GN(n).setGroup(oA).setName(`cameraProjectionMatrices`):oP.array=n,t=oP.element(e.isMultiViewCamera?KN(`gl_ViewID_OVR`):yP)}else aP===null&&(aP=lA(e.projectionMatrix).setName(`cameraProjectionMatrix`).setGroup(oA).onRenderUpdate(({camera:e})=>e.projectionMatrix)),t=aP;return t}).once()(),CP=W(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){let n=[];for(let t of e.cameras)n.push(t.projectionMatrixInverse);cP===null?cP=GN(n).setGroup(oA).setName(`cameraProjectionMatricesInverse`):cP.array=n,t=cP.element(e.isMultiViewCamera?KN(`gl_ViewID_OVR`):yP)}else sP===null&&(sP=lA(e.projectionMatrixInverse).setName(`cameraProjectionMatrixInverse`).setGroup(oA).onRenderUpdate(({camera:e})=>e.projectionMatrixInverse)),t=sP;return t}).once()(),wP=W(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){let n=[];for(let t of e.cameras)n.push(t.matrixWorldInverse);uP===null?uP=GN(n).setGroup(oA).setName(`cameraViewMatrices`):uP.array=n,t=uP.element(e.isMultiViewCamera?KN(`gl_ViewID_OVR`):yP)}else lP===null&&(lP=lA(e.matrixWorldInverse).setName(`cameraViewMatrix`).setGroup(oA).onRenderUpdate(({camera:e})=>e.matrixWorldInverse)),t=lP;return t}).once()(),TP=W(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){let n=[];for(let t of e.cameras)n.push(t.matrixWorld);fP===null?fP=GN(n).setGroup(oA).setName(`cameraWorldMatrices`):fP.array=n,t=fP.element(e.isMultiViewCamera?KN(`gl_ViewID_OVR`):yP)}else dP===null&&(dP=lA(e.matrixWorld).setName(`cameraWorldMatrix`).setGroup(oA).onRenderUpdate(({camera:e})=>e.matrixWorld)),t=dP;return t}).once()(),EP=W(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){let n=[];for(let t of e.cameras)n.push(t.normalMatrix);mP===null?mP=GN(n).setGroup(oA).setName(`cameraNormalMatrices`):mP.array=n,t=mP.element(e.isMultiViewCamera?KN(`gl_ViewID_OVR`):yP)}else pP===null&&(pP=lA(e.normalMatrix).setName(`cameraNormalMatrix`).setGroup(oA).onRenderUpdate(({camera:e})=>e.normalMatrix)),t=pP;return t}).once()(),DP=W(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){let n=[];for(let t=0,r=e.cameras.length;t{let n=e.cameras,r=t.array;for(let e=0,t=n.length;et.value.setFromMatrixPosition(e.matrixWorld))),t=hP;return t}).once()(),OP=W(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){let n=[];for(let t of e.cameras)n.push(t.viewport);vP===null?vP=GN(n,`vec4`).setGroup(oA).setName(`cameraViewports`):vP.array=n,t=vP.element(yP)}else _P===null&&(_P=dk(0,0,QN.x,QN.y).toConst(`cameraViewport`)),t=_P;return t}).once()(),kP=new yi,AP=class e extends XD{static get type(){return`Object3DNode`}constructor(e,t=null){super(),this.scope=e,this.object3d=t,this.updateType=VD.OBJECT,this.uniformNode=new cA(null)}generateNodeType(){let t=this.scope;if(t===e.WORLD_MATRIX)return`mat4`;if(t===e.POSITION||t===e.VIEW_POSITION||t===e.DIRECTION||t===e.SCALE)return`vec3`;if(t===e.RADIUS)return`float`}update(t){let n=this.object3d,r=this.uniformNode,i=this.scope;if(i===e.WORLD_MATRIX)r.value=n.matrixWorld;else if(i===e.POSITION)r.value=r.value||new R,r.value.setFromMatrixPosition(n.matrixWorld);else if(i===e.SCALE)r.value=r.value||new R,r.value.setFromMatrixScale(n.matrixWorld);else if(i===e.DIRECTION)r.value=r.value||new R,n.getWorldDirection(r.value);else if(i===e.VIEW_POSITION){let e=t.camera;r.value=r.value||new R,r.value.setFromMatrixPosition(n.matrixWorld),r.value.applyMatrix4(e.matrixWorldInverse)}else if(i===e.RADIUS){let e=t.object.geometry;e.boundingSphere===null&&e.computeBoundingSphere(),kP.copy(e.boundingSphere).applyMatrix4(n.matrixWorld),r.value=kP.radius}}generate(t){let n=this.scope;return n===e.WORLD_MATRIX?this.uniformNode.nodeType=`mat4`:n===e.POSITION||n===e.VIEW_POSITION||n===e.DIRECTION||n===e.SCALE?this.uniformNode.nodeType=`vec3`:n===e.RADIUS&&(this.uniformNode.nodeType=`float`),this.uniformNode.build(t)}serialize(e){super.serialize(e),e.scope=this.scope}deserialize(e){super.deserialize(e),this.scope=e.scope}};AP.WORLD_MATRIX=`worldMatrix`,AP.POSITION=`position`,AP.SCALE=`scale`,AP.VIEW_POSITION=`viewPosition`,AP.DIRECTION=`direction`,AP.RADIUS=`radius`;var jP=qO(AP,AP.DIRECTION).setParameterLength(1),MP=qO(AP,AP.WORLD_MATRIX).setParameterLength(1),NP=qO(AP,AP.POSITION).setParameterLength(1),PP=qO(AP,AP.SCALE).setParameterLength(1),FP=qO(AP,AP.VIEW_POSITION).setParameterLength(1),IP=qO(AP,AP.RADIUS).setParameterLength(1),LP=class extends AP{static get type(){return`ModelNode`}constructor(e){super(e)}update(e){this.object3d=e.object,super.update(e)}},RP=JO(LP,LP.DIRECTION),zP=JO(LP,LP.WORLD_MATRIX),BP=JO(LP,LP.POSITION),VP=JO(LP,LP.SCALE),HP=JO(LP,LP.VIEW_POSITION),UP=JO(LP,LP.RADIUS),WP=lA(new En).onObjectUpdate(({object:e},t)=>t.value.getNormalMatrix(e.matrixWorld)),GP=lA(new qn).onObjectUpdate(({object:e},t)=>t.value.copy(e.matrixWorld).invert()),KP=W(e=>e.context.modelViewMatrix||qP).once()().toVar(`modelViewMatrix`),qP=wP.mul(zP),JP=W(e=>(e.context.isHighPrecisionModelViewMatrix=!0,lA(`mat4`).onObjectUpdate(({object:e,camera:t})=>e.modelViewMatrix.multiplyMatrices(t.matrixWorldInverse,e.matrixWorld)))).once()().toVar(`highpModelViewMatrix`),YP=W(e=>{let t=e.context.isHighPrecisionModelViewMatrix;return lA(`mat3`).onObjectUpdate(({object:e,camera:n})=>(t!==!0&&e.modelViewMatrix.multiplyMatrices(n.matrixWorldInverse,e.matrixWorld),e.normalMatrix.getNormalMatrix(e.modelViewMatrix)))}).once()().toVar(`highpModelNormalViewMatrix`),XP=W(e=>e.shaderStage===`fragment`?e.context.clipSpace.toVarying(`v_clipSpace`):(Wt("TSL: `clipSpace` is only available in fragment stage."),dk())).once()(),ZP=DN(`position`,`vec3`),QP=ZP.toVarying(`positionLocal`),$P=ZP.toVarying(`positionPrevious`),eF=W(e=>zP.mul(QP).xyz.toVarying(e.getSubBuildProperty(`v_positionWorld`)),`vec3`).once([`POSITION`])(),tF=W(()=>QP.transformDirection(zP).toVarying(`v_positionWorldDirection`).normalize().toVar(`positionWorldDirection`),`vec3`).once([`POSITION`])(),nF=W(e=>{if(e.shaderStage===`fragment`&&e.material.vertexNode){let e=CP.mul(XP);return e.xyz.div(e.w).toVar(`positionView`)}return e.context.setupPositionView().toVarying(`v_positionView`)},`vec3`).once([`POSITION`,`VERTEX`])(),rF=W(e=>{let t;return t=e.camera.isOrthographicCamera?J(0,0,1):nF.negate().toVarying(`v_positionViewDirection`).normalize(),t.toVar(`positionViewDirection`)},`vec3`).once([`POSITION`])(),iF=JO(class extends XD{static get type(){return`FrontFacingNode`}constructor(){super(`bool`),this.isFrontFacingNode=!0}generate(e){if(e.shaderStage!==`fragment`)return`true`;let{material:t}=e;return t.side===1?`false`:e.getFrontFacing()}}),aF=G(iF).mul(2).sub(1),oF=W(([e],{material:t})=>{let n=t.side;return n===1?e=e.mul(-1):n===2&&(e=e.mul(aF)),e}),sF=e=>(Wt(`TSL: "directionToFaceDirection()" has been renamed to "negateOnBackSide()".`),oF(e)),cF=DN(`normal`,`vec3`),lF=W(e=>e.geometry.hasAttribute(`normal`)===!1?(F(`TSL: Vertex attribute "normal" not found on geometry.`),J(0,1,0)):cF,`vec3`).once()().toVar(`normalLocal`),uF=nF.dFdx().cross(nF.dFdy()).normalize().toVar(`normalFlat`),dF=W(e=>{let t;return t=e.isFlatShading()?uF:_F(lF).toVarying(`v_normalViewGeometry`).normalize(),t},`vec3`).once()().toVar(`normalViewGeometry`),fF=W(e=>{let t=dF.transformNormalByInverseViewMatrix(wP);return e.isFlatShading()!==!0&&(t=t.toVarying(`v_normalWorldGeometry`)),t.normalize().toVar(`normalWorldGeometry`)},`vec3`).once()(),pF=W(e=>{let t;return e.subBuildFn===`NORMAL`||e.subBuildFn===`VERTEX`?(t=dF,e.isFlatShading()!==!0&&(t=oF(t))):t=e.context.setupNormal().context({getUV:null,getTextureLevel:null}),t},`vec3`).once([`NORMAL`,`VERTEX`])().toVar(`normalView`),mF=pF.transformNormalByInverseViewMatrix(wP).toVar(`normalWorld`),hF=W(({subBuildFn:e,context:t})=>{let n;return n=e===`NORMAL`||e===`VERTEX`?pF:t.setupClearcoatNormal().context({getUV:null,getTextureLevel:null}),n},`vec3`).once([`NORMAL`,`VERTEX`])().toVar(`clearcoatNormalView`),gF=W(([e,t=zP])=>gk(t).inverse().transpose().mul(e).normalize());H(`transformNormal`,gF);var _F=W(([e],t)=>{let n=t.context.modelNormalViewMatrix;return n?e.transformNormalByViewMatrix(n):WP.mul(e).transformNormalByViewMatrix(wP)}),vF=W(()=>(F(`TSL: "transformedNormalView" is deprecated. Use "normalView" instead.`),pF)).once([`NORMAL`,`VERTEX`])(),yF=W(()=>(F(`TSL: "transformedNormalWorld" is deprecated. Use "normalWorld" instead.`),mF)).once([`NORMAL`,`VERTEX`])(),bF=W(()=>(F(`TSL: "transformedClearcoatNormalView" is deprecated. Use "clearcoatNormalView" instead.`),hF)).once([`NORMAL`,`VERTEX`])(),xF=new qn,SF=lA(0).onReference(({material:e})=>e).onObjectUpdate(({material:e})=>e.refractionRatio),CF=lA(1).onReference(({material:e})=>e).onObjectUpdate(function({material:e,scene:t}){return e.envMap?e.envMapIntensity:t.environmentIntensity}),wF=lA(new qn).onReference(function(e){return e.material}).onObjectUpdate(function({material:e,scene:t}){let n=(t.environment!==null||t.environmentNode&&t.environmentNode.isNode)&&e.envMap===null?t.environmentRotation:e.envMapRotation;return n?xF.makeRotationFromEuler(n).transpose():xF.identity(),xF}),TF=rF.negate().reflect(pF),EF=rF.negate().refract(pF,SF),DF=TF.transformDirection(TP).toVar(`reflectVector`),OF=EF.transformDirection(TP).toVar(`refractVector`),kF=new Ia,AF=qO(class extends NN{static get type(){return`CubeTextureNode`}constructor(e,t=null,n=null,r=null){super(e,t,n,r),this.isCubeTextureNode=!0}getInputType(){return this.value.isDepthTexture===!0?`cubeDepthTexture`:`cubeTexture`}getDefaultUV(){let e=this.value;return e.mapping===301?DF:e.mapping===302?OF:(I(`CubeTextureNode: Mapping "%s" not supported.`,e.mapping),J(0,0,0))}setUpdateMatrix(){}setupUV(e,t){let n=this.value;return n.isDepthTexture===!0?e.renderer.coordinateSystem===2001?J(t.x,t.y.negate(),t.z):t:(t=wF.mul(t),(e.renderer.coordinateSystem===2001||!n.isRenderTargetTexture)&&(t=J(t.x.negate(),t.yz)),t)}generateUV(e,t){return t.build(e,this.sampler===!0?`vec3`:`ivec3`)}}).setParameterLength(1,4).setName(`cubeTexture`),jF=(e=kF,t=null,n=null,r=null)=>{let i;return e&&e.isCubeTextureNode===!0?(i=UO(e.clone()),i.referenceNode=e,t!==null&&(i.uvNode=UO(t)),n!==null&&(i.levelNode=UO(n)),r!==null&&(i.biasNode=UO(r))):i=AF(e,t,n,r),i},MF=(e=kF)=>AF(e),NF=class extends ZD{static get type(){return`ReferenceElementNode`}constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}generateNodeType(){return this.referenceNode.uniformType}generate(e){let t=super.generate(e),n=this.referenceNode.getNodeType(e),r=this.getNodeType(e);return e.format(t,n,r)}},PF=class extends XD{static get type(){return`ReferenceNode`}constructor(e,t,n=null,r=null){super(),this.property=e,this.uniformType=t,this.object=n,this.count=r,this.properties=e.split(`.`),this.reference=n,this.node=null,this.group=null,this.name=null,this.updateType=VD.OBJECT}element(e){return new NF(this,UO(e))}setGroup(e){return this.group=e,this}setName(e){return this.name=e,this}label(e){return F(`TSL: "label()" has been deprecated. Use "setName()" instead.`),this.setName(e)}setNodeType(e){let t=null;this.count===null?Array.isArray(this.getValueFromReference())?(t=GN(null,e),t.updateType=VD.OBJECT):t=e===`texture`?FN(null):e===`cubeTexture`?jF(null):lA(null,e):t=HN(null,e,this.count),this.group!==null&&t.setGroup(this.group),this.name!==null&&t.setName(this.name),this.node=t}generateNodeType(e){return this.node===null&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){let{properties:t}=this,n=e[t[0]];for(let e=1;enew PF(e,t,n),IF=(e,t,n,r)=>new PF(e,t,r,n),LF=class extends PF{static get type(){return`MaterialReferenceNode`}constructor(e,t,n=null){super(e,t,n),this.material=n,this.isMaterialReferenceNode=!0}updateReference(e){return this.reference=this.material===null?e.material:this.material,this.reference}},RF=(e,t,n=null)=>new LF(e,t,n),zF=ON(),BF=nF.dFdx(),VF=nF.dFdy(),HF=zF.dFdx(),UF=zF.dFdy(),WF=pF,GF=VF.cross(WF),KF=WF.cross(BF),qF=GF.mul(HF.x).add(KF.mul(UF.x)),JF=GF.mul(HF.y).add(KF.mul(UF.y)),YF=qF.dot(qF).max(JF.dot(JF)),XF=YF.equal(0).select(0,YF.inverseSqrt()),ZF=qF.mul(XF).toVar(`tangentViewFrame`),QF=JF.mul(XF).toVar(`bitangentViewFrame`),$F=DN(`tangent`,`vec4`),eI=$F.xyz.toVar(`tangentLocal`),tI=W(e=>{let t;return t=e.subBuildFn===`VERTEX`||e.geometry.hasAttribute(`tangent`)?KP.mul(dk(eI,0)).xyz.toVarying(`v_tangentView`).normalize():ZF,e.isFlatShading()!==!0&&(t=oF(t)),t},`vec3`).once([`NORMAL`,`VERTEX`])().toVar(`tangentView`),nI=tI.transformDirection(TP).toVarying(`v_tangentWorld`).normalize().toVar(`tangentWorld`),rI=W(([e,t],n)=>{let r=e.mul($F.w).xyz;return n.subBuildFn===`NORMAL`&&n.isFlatShading()!==!0&&(r=r.toVarying(t)),r}).once([`NORMAL`]),iI=rI(cF.cross($F),`v_bitangentGeometry`).normalize().toVar(`bitangentGeometry`),aI=rI(lF.cross(eI),`v_bitangentLocal`).normalize().toVar(`bitangentLocal`),oI=W(e=>{let t;return t=e.subBuildFn===`VERTEX`||e.geometry.hasAttribute(`tangent`)?rI(pF.cross(tI),`v_bitangentView`).normalize():QF,e.isFlatShading()!==!0&&(t=oF(t)),t},`vec3`).once([`NORMAL`,`VERTEX`])().toVar(`bitangentView`),sI=rI(mF.cross(nI),`v_bitangentWorld`).normalize().toVar(`bitangentWorld`),cI=gk(tI,oI,pF).toVar(`TBNViewMatrix`),lI=rF.mul(cI),uI=(e,t)=>e.sub(lI.mul(t)),dI=W(()=>{let e=Bk.cross(rF);return e=e.cross(Bk).normalize(),e=Zj(e,pF,Rk.mul(Ok.oneMinus()).oneMinus().pow2().pow2()).normalize(),e}).once()(),fI=e=>UO(e).mul(.5).add(.5),pI=e=>UO(e).mul(2).sub(1),mI=e=>J(e,nj($j(G(1).sub(Bj(e,e))))),hI=e=>(Wt(`TSL: "directionToColor()" has been renamed to "packNormalToRGB()".`),fI(e)),gI=e=>(Wt(`TSL: "colorToDirection()" has been renamed to "unpackRGBToNormal()".`),pI(e)),_I=qO(class extends $D{static get type(){return`NormalMapNode`}constructor(e,t=null){super(`vec3`),this.node=e,this.scaleNode=t,this.normalMapType=0,this.unpackNormalMode=``}setup(e){let{normalMapType:t,scaleNode:n,unpackNormalMode:r}=this,i=this.node.mul(2).sub(1);if(t===0?r===`rg`?i=mI(i.xy):r===`ga`?i=mI(i.yw):r!==``&&I(`THREE.NodeMaterial: Unexpected unpack normal mode: ${r}`):r!==``&&I(`THREE.NodeMaterial: Normal map type '${t}' is not compatible with unpack normal mode '${r}'`),n!==null){let t=n;e.isFlatShading()===!0&&(t=oF(t)),i=J(i.xy.mul(t),i.z)}let a=null;return t===1?a=_F(i):t===0?a=cI.mul(i).normalize():(I(`NodeMaterial: Unsupported normal map type: ${t}`),a=pF),a}}).setParameterLength(1,2),vI=W(({textureNode:e,bumpScale:t})=>{let n=t=>e.isolate().context({getUV:e=>t(e.uvNode||ON()),forceUVContext:!0}),r=G(n(e=>e));return ik(G(n(e=>e.add(e.dFdx()))).sub(r),G(n(e=>e.add(e.dFdy()))).sub(r)).mul(t)}),yI=W(e=>{let{surf_pos:t,surf_norm:n,dHdxy:r}=e,i=t.dFdx().normalize(),a=t.dFdy().normalize(),o=n,s=a.cross(o),c=o.cross(i),l=i.dot(s).mul(aF),u=l.sign().mul(r.x.mul(s).add(r.y.mul(c)));return l.abs().mul(n).sub(u).normalize()}),bI=qO(class extends $D{static get type(){return`BumpMapNode`}constructor(e,t=null){super(`vec3`),this.textureNode=e,this.scaleNode=t}setup(e){if(e.material.wireframe===!0)return pF;let t=this.scaleNode===null?1:this.scaleNode;return yI({surf_pos:nF,surf_norm:pF,dHdxy:vI({textureNode:this.textureNode,bumpScale:t})})}}).setParameterLength(1,2),xI=new Map,X=class e extends XD{static get type(){return`MaterialNode`}constructor(e){super(),this.scope=e}getCache(e,t){let n=xI.get(e);return n===void 0&&(n=RF(e,t),xI.set(e,n)),n}getFloat(e){return this.getCache(e,`float`)}getColor(e){return this.getCache(e,`color`)}getTexture(e){return this.getCache(e===`map`?`map`:e+`Map`,`texture`)}setup(t){let n=t.context.material,r=this.scope,i=null;if(r===e.COLOR){let e=n.color===void 0?J():this.getColor(r);i=n.map&&n.map.isTexture===!0?e.mul(this.getTexture(`map`)):e}else if(r===e.OPACITY){let e=this.getFloat(r);i=n.alphaMap&&n.alphaMap.isTexture===!0?e.mul(this.getTexture(`alpha`)):e}else if(r===e.SPECULAR_STRENGTH)i=n.specularMap&&n.specularMap.isTexture===!0?this.getTexture(`specular`).r:G(1);else if(r===e.SPECULAR_INTENSITY){let e=this.getFloat(r);i=n.specularIntensityMap&&n.specularIntensityMap.isTexture===!0?e.mul(this.getTexture(r).a):e}else if(r===e.SPECULAR_COLOR){let e=this.getColor(r);i=n.specularColorMap&&n.specularColorMap.isTexture===!0?e.mul(this.getTexture(r).rgb):e}else if(r===e.ROUGHNESS){let e=this.getFloat(r);i=n.roughnessMap&&n.roughnessMap.isTexture===!0?e.mul(this.getTexture(r).g):e}else if(r===e.METALNESS){let e=this.getFloat(r);i=n.metalnessMap&&n.metalnessMap.isTexture===!0?e.mul(this.getTexture(r).b):e}else if(r===e.EMISSIVE){let e=this.getFloat(`emissiveIntensity`),t=this.getColor(r).mul(e);i=n.emissiveMap&&n.emissiveMap.isTexture===!0?t.mul(this.getTexture(r)):t}else if(r===e.NORMAL)n.normalMap?(i=_I(this.getTexture(`normal`),this.getCache(`normalScale`,`vec2`)),i.normalMapType=n.normalMapType,(n.normalMap.format==1030||n.normalMap.format==36285||n.normalMap.format==37490)&&(i.unpackNormalMode=`rg`)):i=n.bumpMap?bI(this.getTexture(`bump`).r,this.getFloat(`bumpScale`)):pF;else if(r===e.CLEARCOAT){let e=this.getFloat(r);i=n.clearcoatMap&&n.clearcoatMap.isTexture===!0?e.mul(this.getTexture(r).r):e}else if(r===e.CLEARCOAT_ROUGHNESS){let e=this.getFloat(r);i=n.clearcoatRoughnessMap&&n.clearcoatRoughnessMap.isTexture===!0?e.mul(this.getTexture(r).r):e}else if(r===e.CLEARCOAT_NORMAL)i=n.clearcoatNormalMap?_I(this.getTexture(r),this.getCache(r+`Scale`,`vec2`)):pF;else if(r===e.SHEEN){let e=this.getColor(`sheenColor`).mul(this.getFloat(`sheen`));i=n.sheenColorMap&&n.sheenColorMap.isTexture===!0?e.mul(this.getTexture(`sheenColor`).rgb):e}else if(r===e.SHEEN_ROUGHNESS){let e=this.getFloat(r);i=n.sheenRoughnessMap&&n.sheenRoughnessMap.isTexture===!0?e.mul(this.getTexture(r).a):e,i=i.clamp(1e-4,1)}else if(r===e.ANISOTROPY)if(n.anisotropyMap&&n.anisotropyMap.isTexture===!0){let e=this.getTexture(r);i=hk(aL.x,aL.y,aL.y.negate(),aL.x).mul(e.rg.mul(2).sub(ik(1)).normalize().mul(e.b))}else i=aL;else if(r===e.IRIDESCENCE_THICKNESS){let e=FF(`1`,`float`,n.iridescenceThicknessRange);if(n.iridescenceThicknessMap){let t=FF(`0`,`float`,n.iridescenceThicknessRange);i=e.sub(t).mul(this.getTexture(r).g).add(t)}else i=e}else if(r===e.TRANSMISSION){let e=this.getFloat(r);i=n.transmissionMap?e.mul(this.getTexture(r).r):e}else if(r===e.THICKNESS){let e=this.getFloat(r);i=n.thicknessMap?e.mul(this.getTexture(r).g):e}else if(r===e.IOR)i=this.getFloat(r);else if(r===e.LIGHT_MAP)i=n.lightMap?this.getTexture(r).rgb.mul(this.getFloat(`lightMapIntensity`)):J(0);else if(r===e.AO)i=n.aoMap?this.getTexture(r).r.sub(1).mul(this.getFloat(`aoMapIntensity`)).add(1):G(1);else if(r===e.LINE_DASH_OFFSET)i=n.dashOffset?this.getFloat(r):G(0);else{let e=this.getNodeType(t);i=this.getCache(r,e)}return i}};X.ALPHA_TEST=`alphaTest`,X.COLOR=`color`,X.OPACITY=`opacity`,X.SHININESS=`shininess`,X.SPECULAR=`specular`,X.SPECULAR_STRENGTH=`specularStrength`,X.SPECULAR_INTENSITY=`specularIntensity`,X.SPECULAR_COLOR=`specularColor`,X.REFLECTIVITY=`reflectivity`,X.ROUGHNESS=`roughness`,X.METALNESS=`metalness`,X.NORMAL=`normal`,X.CLEARCOAT=`clearcoat`,X.CLEARCOAT_ROUGHNESS=`clearcoatRoughness`,X.CLEARCOAT_NORMAL=`clearcoatNormal`,X.EMISSIVE=`emissive`,X.ROTATION=`rotation`,X.SHEEN=`sheen`,X.SHEEN_ROUGHNESS=`sheenRoughness`,X.ANISOTROPY=`anisotropy`,X.IRIDESCENCE=`iridescence`,X.IRIDESCENCE_IOR=`iridescenceIOR`,X.IRIDESCENCE_THICKNESS=`iridescenceThickness`,X.IOR=`ior`,X.TRANSMISSION=`transmission`,X.THICKNESS=`thickness`,X.ATTENUATION_DISTANCE=`attenuationDistance`,X.ATTENUATION_COLOR=`attenuationColor`,X.LINE_SCALE=`scale`,X.LINE_DASH_SIZE=`dashSize`,X.LINE_GAP_SIZE=`gapSize`,X.LINE_WIDTH=`linewidth`,X.LINE_DASH_OFFSET=`dashOffset`,X.POINT_SIZE=`size`,X.DISPERSION=`dispersion`,X.LIGHT_MAP=`light`,X.AO=`ao`;var SI=JO(X,X.ALPHA_TEST),CI=JO(X,X.COLOR),wI=JO(X,X.SHININESS),TI=JO(X,X.EMISSIVE),EI=JO(X,X.OPACITY),DI=JO(X,X.SPECULAR),OI=JO(X,X.SPECULAR_INTENSITY),kI=JO(X,X.SPECULAR_COLOR),AI=JO(X,X.SPECULAR_STRENGTH),jI=JO(X,X.REFLECTIVITY),MI=JO(X,X.ROUGHNESS),NI=JO(X,X.METALNESS),PI=JO(X,X.NORMAL),FI=JO(X,X.CLEARCOAT),II=JO(X,X.CLEARCOAT_ROUGHNESS),LI=JO(X,X.CLEARCOAT_NORMAL),RI=JO(X,X.ROTATION),zI=JO(X,X.SHEEN),BI=JO(X,X.SHEEN_ROUGHNESS),VI=JO(X,X.ANISOTROPY),HI=JO(X,X.IRIDESCENCE),UI=JO(X,X.IRIDESCENCE_IOR),WI=JO(X,X.IRIDESCENCE_THICKNESS),GI=JO(X,X.TRANSMISSION),KI=JO(X,X.THICKNESS),qI=JO(X,X.IOR),JI=JO(X,X.ATTENUATION_DISTANCE),YI=JO(X,X.ATTENUATION_COLOR),XI=JO(X,X.LINE_SCALE),ZI=JO(X,X.LINE_DASH_SIZE),QI=JO(X,X.LINE_GAP_SIZE),$I=JO(X,X.LINE_WIDTH),eL=JO(X,X.LINE_DASH_OFFSET),tL=JO(X,X.POINT_SIZE),nL=JO(X,X.DISPERSION),rL=JO(X,X.LIGHT_MAP),iL=JO(X,X.AO),aL=lA(new L).onReference(function(e){return e.material}).onRenderUpdate(function({material:e}){this.value.set(e.anisotropy*Math.cos(e.anisotropyRotation),e.anisotropy*Math.sin(e.anisotropyRotation))}),oL=W(e=>e.context.setupModelViewProjection(),`vec4`).once()().toVarying(`v_modelViewProjection`),sL=class e extends XD{static get type(){return`EventNode`}constructor(t,n){super(`void`),this.eventType=t,this.callback=n,t===e.OBJECT?this.updateType=VD.OBJECT:t===e.MATERIAL?this.updateType=VD.RENDER:t===e.FRAME?this.updateType=VD.FRAME:t===e.BEFORE_OBJECT?this.updateBeforeType=VD.OBJECT:t===e.BEFORE_MATERIAL?this.updateBeforeType=VD.RENDER:t===e.BEFORE_FRAME&&(this.updateBeforeType=VD.FRAME)}update(e){this.callback(e)}updateBefore(e){this.callback(e)}};sL.OBJECT=`object`,sL.MATERIAL=`material`,sL.FRAME=`frame`,sL.BEFORE_OBJECT=`beforeObject`,sL.BEFORE_MATERIAL=`beforeMaterial`,sL.BEFORE_FRAME=`beforeFrame`;var cL=(e,t)=>new sL(e,t).toStack(),lL=e=>cL(sL.OBJECT,e),uL=e=>cL(sL.MATERIAL,e),dL=e=>cL(sL.FRAME,e),fL=e=>cL(sL.BEFORE_OBJECT,e),pL=e=>cL(sL.BEFORE_MATERIAL,e),mL=e=>cL(sL.BEFORE_FRAME,e),hL=qO(class extends ZD{static get type(){return`StorageArrayElementNode`}constructor(e,t){super(e,t),this.isStorageArrayElementNode=!0}set storageBufferNode(e){this.node=e}get storageBufferNode(){return this.node}getMemberType(e,t){let n=this.storageBufferNode.structTypeNode;return n?n.getMemberType(e,t):`void`}setup(e){return e.isAvailable(`storageBuffer`)===!1&&this.node.isPBO===!0&&e.setupPBO(this.node),super.setup(e)}generate(e,t){let n,r=e.isContextAssign();if(n=e.isAvailable(`storageBuffer`)===!1?this.node.isPBO===!0&&r!==!0&&(this.node.value.isInstancedBufferAttribute||e.shaderStage!==`compute`)?e.generatePBO(this):this.node.build(e):super.generate(e),r!==!0){let r=this.getNodeType(e);n=e.format(n,r,t)}return n}}).setParameterLength(2),gL=class extends VN{static get type(){return`StorageBufferNode`}constructor(e,t=null,n=0){let r,i=null;t&&t.isStructTypeNode?(r=`struct`,i=t,(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)&&(n=e.count)):t===null&&(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)?(r=AD(e.itemSize),n=e.count):r=t,super(e,r,n),this.isStorageBufferNode=!0,this.structTypeNode=i,this.access=UD.READ_WRITE,this.isAtomic=!1,this.isPBO=!1,this._attribute=null,this._varying=null,this.global=!0,e.isStorageBufferAttribute!==!0&&e.isStorageInstancedBufferAttribute!==!0&&(e.isInstancedBufferAttribute?e.isStorageInstancedBufferAttribute=!0:e.isStorageBufferAttribute=!0)}getHash(e){let t;if(this.bufferCount===0){let n=e.globalCache.getData(this.value);n===void 0&&(n={node:this},e.globalCache.setData(this.value,n)),t=n.node.id}else t=this.id;return String(t)}getInputType(){return this.value.isIndirectStorageBufferAttribute?`indirectStorageBuffer`:`storageBuffer`}element(e){return hL(this,e)}setPBO(e){return this.isPBO=e,this}getPBO(){return this.isPBO}setAccess(e){return this.access=e,this}toReadOnly(){return this.setAccess(UD.READ_ONLY)}setAtomic(e){return this.isAtomic=e,this}toAtomic(){return this.setAtomic(!0)}getAttributeData(){return this._attribute===null&&(this._attribute=KM(this.value),this._varying=wM(this._attribute)),{attribute:this._attribute,varying:this._varying}}generateNodeType(e){if(this.structTypeNode!==null)return this.structTypeNode.getNodeType(e);if(e.isAvailable(`storageBuffer`)||e.isAvailable(`indirectStorageBuffer`))return super.generateNodeType(e);let{attribute:t}=this.getAttributeData();return t.getNodeType(e)}getMemberType(e,t){return this.structTypeNode===null?`void`:this.structTypeNode.getMemberType(e,t)}generate(e){if(this.structTypeNode!==null&&this.structTypeNode.build(e),e.isAvailable(`storageBuffer`)||e.isAvailable(`indirectStorageBuffer`))return super.generate(e);let{attribute:t,varying:n}=this.getAttributeData(),r=n.build(e);return e.registerTransform(r,t),r}},_L=(e,t=null,n=0)=>new gL(e,t,n),vL=new WeakMap,yL=new WeakMap,bL=new WeakMap;function xL(e,t){let n,r=Math.max(t.count,1);if(t.isStorageInstancedBufferAttribute===!0)n=_L(t,`mat4`,r).element(QM);else if(r*16*4<=e.getUniformBufferLimit())n=HN(t.array,`mat4`,r).element(QM);else{let e=vL.get(t);e||(e=new Wc(t.array,16,1),vL.set(t,e));let r=t.usage===35048?YM:JM;n=_k(r(e,`vec4`,16,0),r(e,`vec4`,16,4),r(e,`vec4`,16,8),r(e,`vec4`,16,12))}return n}function SL(e,t,n){let r=bL.get(e);if(r===void 0){let i=t.clone();r={previousInstanceMatrix:i,node:xL(n,i)},bL.set(e,r)}return r.node}var CL=wk(`vec3`,`vInstanceColor`),wL=W(([e,t=null],n)=>{let r=e.isStorageInstancedBufferAttribute===!0,i=t&&t.isStorageInstancedBufferAttribute===!0,a=xL(n,e),o=null;r||Math.max(e.count,1)*16*4>n.getUniformBufferLimit()&&(o=vL.get(e));let s=null,c=null;if(t)if(i)s=_L(t,`vec3`,Math.max(t.count,1)).element(QM);else{let e=yL.get(t);e||(e=new ia(t.array,3),yL.set(t,e)),c=e,s=J((t.usage===35048?YM:JM)(e,`vec3`,3,0))}(o!==null||c!==null)&&dL(()=>{o!==null&&(o.clearUpdateRanges(),o.updateRanges.push(...e.updateRanges),e.version!==o.version&&(o.version=e.version)),t&&c!==null&&(c.clearUpdateRanges(),c.updateRanges.push(...t.updateRanges),t.version!==c.version&&(c.version=t.version))});let l=a.mul(QP).xyz;if(QP.assign(l),n.needsPreviousData()){let t=n.object;lL(({object:t})=>{bL.get(t).previousInstanceMatrix.array.set(e.array)});let r=SL(t,e,n);$P.assign(r.mul($P).xyz)}if(n.hasGeometryAttribute(`normal`)){let e=gF(lF,a);lF.assign(e)}s!==null&&CL.assign(s)},`void`),TL=W(([e])=>{let{instanceMatrix:t,instanceColor:n}=e;wL(t,n)},`void`),EL=W(([e,t])=>{let n=K(kN(LN(e),0).x).toConst(),r=K(t);return LN(e,ak(r.mod(n).toConst(),r.div(n).toConst()))}),DL=W(([e,t])=>{let n=K(kN(LN(e),0).x).toConst();return LN(e,ak(K(t).mod(n).toConst(),K(t).div(n).toConst())).x}),OL=wk(`vec4`,`vBatchColor`),kL=W(([e],t)=>{let n=t.getDrawIndex()===null?QM:nN,r=DL(e._indirectTexture,K(n)),i=e._matricesTexture,a=K(kN(LN(i),0).x).toConst(),o=G(r).mul(4).toInt().toConst(),s=o.mod(a).toConst(),c=o.div(a).toConst(),l=_k(LN(i,ak(s,c)),LN(i,ak(s.add(1),c)),LN(i,ak(s.add(2),c)),LN(i,ak(s.add(3),c))),u=e._colorsTexture;if(u!==null){let e=EL(u,r);OL.assign(e)}let d=gk(l);QP.assign(l.mul(QP));let f=lF.div(J(d[0].dot(d[0]),d[1].dot(d[1]),d[2].dot(d[2]))),p=d.mul(f).xyz;lF.assign(p),t.hasGeometryAttribute(`tangent`)&&eI.mulAssign(d)},`void`),AL=new WeakMap,jL=new WeakMap;function ML(e,t,n,r,i,a){let o=e.element(i.x),s=e.element(i.y),c=e.element(i.z),l=e.element(i.w),u=n.mul(t),d=_A(o.mul(a.x).mul(u),s.mul(a.y).mul(u),c.mul(a.z).mul(u),l.mul(a.w).mul(u));return r.mul(d).xyz}function NL(e,t,n,r,i,a,o){let s=e.element(a.x),c=e.element(a.y),l=e.element(a.z),u=e.element(a.w),d=_A(o.x.mul(s),o.y.mul(c),o.z.mul(l),o.w.mul(u));return d=i.mul(d).mul(r),{skinNormal:d.transformDirection(t).xyz,skinTangent:d.transformDirection(n).xyz}}function PL(e,t,n,r,i){let a=e.skeleton,o=jL.get(a);if(o===void 0){a.update();let e=new Float32Array(a.boneMatrices);o={previousBoneMatrices:e,node:HN(e,`mat4`,a.bones.length)},jL.set(a,o)}return ML(o.node,$P,t,n,r,i)}var FL=W(([e],t)=>{let n=DN(`skinIndex`,`uvec4`),r=DN(`skinWeight`,`vec4`),i=FF(`bindMatrix`,`mat4`),a=FF(`bindMatrixInverse`,`mat4`),o=IF(`skeleton.boneMatrices`,`mat4`,e.skeleton.bones.length);if(lL(({object:e,frameId:t})=>{let n=e.skeleton;if(AL.get(n)!==t){AL.set(n,t);let e=jL.get(n);e!==void 0&&e.previousBoneMatrices.set(n.boneMatrices),n.update()}}),t.needsPreviousData()){let t=PL(e,i,a,n,r);$P.assign(t)}let s=ML(o,QP,i,a,n,r);if(QP.assign(s),t.hasGeometryAttribute(`normal`)){let{skinNormal:e,skinTangent:s}=NL(o,lF,eI,i,a,n,r);lF.assign(e),t.hasGeometryAttribute(`tangent`)&&eI.assign(s)}},`void`),IL=W(([e,t=null],n)=>{let r=_L(new ia(e.geometry.getAttribute(`position`).array,3),`vec3`).setPBO(!0).toReadOnly().element(QM).toVar(),i=_L(new ia(new Uint32Array(e.geometry.getAttribute(`skinIndex`).array),4),`uvec4`).setPBO(!0).toReadOnly().element(QM).toVar(),a=_L(new ia(e.geometry.getAttribute(`skinWeight`).array,4),`vec4`).setPBO(!0).toReadOnly().element(QM).toVar(),o=lA(e.bindMatrix,`mat4`),s=lA(e.bindMatrixInverse,`mat4`),c=HN(e.skeleton.boneMatrices,`mat4`,e.skeleton.bones.length),l=e.skeleton;if(lL(({frameId:e})=>{if(AL.get(l)!==e){AL.set(l,e);let t=jL.get(l);t!==void 0&&t.previousBoneMatrices.set(l.boneMatrices),l.update()}}),n.needsPreviousData()){let t=PL(e,o,s,i,a);$P.assign(t)}let u=ML(c,r,o,s,i,a);if(t!==null&&t.assign(u),n.hasGeometryAttribute(`normal`)){let{skinNormal:e,skinTangent:t}=NL(c,lF,eI,o,s,i,a);lF.assign(e),n.hasGeometryAttribute(`tangent`)&&eI.assign(t)}return u}),LL=class extends XD{static get type(){return`LoopNode`}constructor(e=[]){super(`void`),this.params=e}getVarName(e){return String.fromCharCode(105+e)}getProperties(e){let t=e.getNodeProperties(this);if(t.stackNode!==void 0)return t;let n={};for(let e=0,t=this.params.length-1;e=`):s!==void 0&&o===void 0&&(o=`0`,u=`<`),u===void 0&&(u=Number(o)>Number(s)?`>=`:`<`));let f;if(a)f=`while ( ${s} )`;else{let n={start:o,end:s},r=n.start,i=n.end,a,p=()=>u.includes(`<`)?`+=`:`-=`;if(d!=null)switch(typeof d){case`function`:a=e.flowStagesNode(t.updateNode,`void`).code.replace(/\t|;/g,``);break;case`number`:a=c+` `+p()+` `+e.generateConst(l,d);break;case`string`:a=c+` `+d;break;default:d.isNode?a=c+` `+p()+` `+d.build(e):(I(`TSL: 'Loop( { update: ... } )' is not a function, string or number.`,this.stackTrace),a=`break /* invalid update */`)}else d=l===`int`||l===`uint`?u.includes(`<`)?`++`:`--`:p()+` 1.`,a=c+` `+d;f=`for ( ${e.getVar(l,c)+` = `+r}; ${c+` `+u+` `+i}; ${a} )`}e.addFlowCode((r===0?` `:``)+e.tab+f+` { `).addFlowTab()}let i=r.build(e,`void`);t.returnsNode.build(e,`void`),e.removeFlowTab().addFlowCode(` `+e.tab+i);for(let t=0,n=this.params.length-1;tnew LL(KO(e,`int`)).toStack(),zL=()=>pN(`continue`).toStack(),BL=()=>pN(`break`).toStack(),VL=new WeakMap,HL=new Hn,UL=new WeakMap,WL=W(({bufferMap:e,influence:t,stride:n,width:r,depth:i,offset:a})=>{let o=K(ZM).mul(n).add(a),s=o.div(r);return LN(e,ak(o.sub(s.mul(r)),s)).depth(i).xyz.mul(t)});function GL(e){let t=e.morphAttributes.position!==void 0,n=e.morphAttributes.normal!==void 0,r=e.morphAttributes.color!==void 0,i=e.morphAttributes.position||e.morphAttributes.normal||e.morphAttributes.color,a=i===void 0?0:i.length,o=VL.get(e);if(o===void 0||o.count!==a){o!==void 0&&o.texture.dispose();let i=e.morphAttributes.position||[],s=e.morphAttributes.normal||[],c=e.morphAttributes.color||[],l=0;t===!0&&(l=1),n===!0&&(l=2),r===!0&&(l=3);let u=e.attributes.position.count*l,d=1,f=4096;u>f&&(d=Math.ceil(u/f),u=f);let p=new Float32Array(u*d*4*a),m=new Gn(p,u,d,a);m.type=fe,m.needsUpdate=!0;let h=l*4;for(let e=0;e{let{geometry:t}=e,n=t.morphAttributes.position!==void 0,r=t.hasAttribute(`normal`)&&t.morphAttributes.normal!==void 0,i=t.morphAttributes.position||t.morphAttributes.normal||t.morphAttributes.color,a=i===void 0?0:i.length;if(a===0)return;let o=UL.get(e);(o===void 0||o.count!==a)&&(o={base:lA(1),influences:e.morphTargetInfluences?GN(e.morphTargetInfluences,`float`):null,count:a},UL.set(e,o));let{base:s,influences:c}=o,{texture:l,stride:u,size:d}=GL(t);n===!0&&QP.mulAssign(s),r===!0&&lF.mulAssign(s);let f=K(d.width);RL(a,({i:t})=>{let i=G(0).toVar();e.count>1&&e.morphTexture!==null&&e.morphTexture!==void 0?i.assign(LN(e.morphTexture,ak(K(t).add(1),K(QM))).r):i.assign(c.element(t).toVar()),$O(i.notEqual(0),()=>{n===!0&&QP.addAssign(WL({bufferMap:l,influence:i,stride:u,width:f,depth:t,offset:K(0)})),r===!0&&lF.addAssign(WL({bufferMap:l,influence:i,stride:u,width:f,depth:t,offset:K(1)}))})}),lL(({object:e})=>{let{base:t,influences:n}=o;e.geometry.morphTargetsRelative?t.value=1:t.value=1-e.morphTargetInfluences.reduce((e,t)=>e+t,0),n&&(n.array=e.morphTargetInfluences,n.update())})},`void`),qL=class extends XD{static get type(){return`LightingNode`}constructor(){super(`vec3`),this.isLightingNode=!0}},JL=class extends qL{static get type(){return`AONode`}constructor(e=null){super(),this.aoNode=e}setup(e){e.context.ambientOcclusion.mulAssign(this.aoNode)}},YL=qO(class extends uM{static get type(){return`LightingContextNode`}constructor(e,t=null,n=[],r=null,i=null){super(e),this.lightingModel=t,this.materialLightings=n,this.backdropNode=r,this.backdropAlphaNode=i,this._value=null}getContext(){let{materialLightings:e,backdropNode:t,backdropAlphaNode:n}=this,r={directDiffuse:J().toVar(`directDiffuse`),directSpecular:J().toVar(`directSpecular`),indirectDiffuse:J().toVar(`indirectDiffuse`),indirectSpecular:J().toVar(`indirectSpecular`)};return{radiance:J().toVar(`radiance`),irradiance:J().toVar(`irradiance`),iblIrradiance:J().toVar(`iblIrradiance`),ambientOcclusion:G(1).toVar(`ambientOcclusion`),reflectedLight:r,materialLightings:e,backdrop:t,backdropAlpha:n}}setup(e){return this.value=this._value||=this.getContext(),this.value.lightingModel=this.lightingModel||e.context.lightingModel,super.setup(e)}}),XL=class extends qL{static get type(){return`IrradianceNode`}constructor(e){super(),this.node=e}setup(e){e.context.irradiance.addAssign(this.node)}},ZL=new L,QL=class extends NN{static get type(){return`ViewportTextureNode`}constructor(e=ZN,t=null,n=null){let r=null;n===null?(r=new Fa,r.minFilter=ie,n=r):r=n,super(n,e,t),this.generateMipmaps=!1,this.defaultFramebuffer=r,this.isOutputTextureNode=!0,this.updateBeforeType=VD.RENDER,this._cacheTextures=new WeakMap}getTextureForReference(e=null){let t,n;if(this.referenceNode?(t=this.referenceNode.defaultFramebuffer,n=this.referenceNode._cacheTextures):(t=this.defaultFramebuffer,n=this._cacheTextures),e===null)return t;if(n.has(e)===!1){let r=t.clone();n.set(e,r)}return n.get(e)}updateReference(e){let t=e.renderer,n=t.getRenderTarget(),r=t.getCanvasTarget(),i=n||r;return this.value=this.getTextureForReference(i),this.value}updateBefore(e){let t=e.renderer,n=t.getRenderTarget(),r=t.getCanvasTarget(),i=n||r;i===null?t.getDrawingBufferSize(ZL):i.getDrawingBufferSize?i.getDrawingBufferSize(ZL):ZL.set(i.width,i.height);let a=this.getTextureForReference(i);(a.image.width!==ZL.width||a.image.height!==ZL.height)&&(a.image.width=ZL.width,a.image.height=ZL.height,a.needsUpdate=!0);let o=a.generateMipmaps;a.generateMipmaps=this.generateMipmaps,t.copyFramebufferToTexture(a),a.generateMipmaps=o}clone(){let e=new this.constructor(this.uvNode,this.levelNode,this.value);return e.generateMipmaps=this.generateMipmaps,e}},$L=qO(QL).setParameterLength(0,3),eR=qO(QL,null,null,{generateMipmaps:!0}).setParameterLength(0,3),tR=eR(),nR=(e=ZN,t=null)=>tR.sample(e,t),rR=null,iR=qO(class extends QL{static get type(){return`ViewportDepthTextureNode`}constructor(e=ZN,t=null,n=null){n===null&&(rR===null&&(rR=new La),n=rR),super(e,t,n)}}).setParameterLength(0,3),aR=class e extends XD{static get type(){return`ViewportDepthNode`}constructor(e,t=null){super(`float`),this.scope=e,this.valueNode=t,this.isViewportDepthNode=!0}generate(t){let{scope:n}=this;return n===e.DEPTH_BASE?t.getFragDepth():super.generate(t)}setup({camera:t}){let{scope:n}=this,r=this.valueNode,i=null;return n===e.DEPTH_BASE?r!==null&&(i=mR().assign(r)):n===e.DEPTH?i=t.isPerspectiveCamera?lR(nF.z,bP,xP):oR(nF.z,bP,xP):n===e.LINEAR_DEPTH&&(i=r===null?oR(nF.z,bP,xP):t.isPerspectiveCamera?oR(dR(r,bP,xP),bP,xP):r),i}};aR.DEPTH_BASE=`depthBase`,aR.DEPTH=`depth`,aR.LINEAR_DEPTH=`linearDepth`;var oR=(e,t,n)=>e.add(t).div(t.sub(n)),sR=(e,t,n)=>e.add(n).div(n.sub(t)),cR=W(([e,t,n],r)=>r.renderer.reversedDepthBuffer===!0?n.sub(t).mul(e).sub(n):t.sub(n).mul(e).sub(t)),lR=(e,t,n)=>t.add(e).mul(n).div(n.sub(t).mul(e)),uR=(e,t,n)=>t.mul(e.add(n)).div(e.mul(t.sub(n))),dR=W(([e,t,n],r)=>r.renderer.reversedDepthBuffer===!0?t.mul(n).div(t.sub(n).mul(e).sub(t)):t.mul(n).div(n.sub(t).mul(e).sub(n))),fR=(e,t,n)=>{t=t.max(1e-6).toVar();let r=tj(e.negate().div(t)),i=tj(n.div(t));return r.div(i)},pR=(e,t,n)=>{let r=e.mul(ej(n.div(t)));return G(Math.E).pow(r).mul(t).negate()},mR=qO(aR,aR.DEPTH_BASE),hR=JO(aR,aR.DEPTH),gR=qO(aR,aR.LINEAR_DEPTH).setParameterLength(0,1),_R=gR(iR());hR.assign=e=>mR(e);var vR=class e extends XD{static get type(){return`ClippingNode`}constructor(t=e.DEFAULT){super(),this.scope=t}setup(t){super.setup(t);let{intersectionPlanes:n,unionPlanes:r}=t.clippingContext;return this.hardwareClipping=t.hardwareClipping,this.scope===e.ALPHA_TO_COVERAGE?this.setupAlphaToCoverage(n,r):this.scope===e.HARDWARE?this.setupHardwareClipping(r,t):this.setupDefault(n,r)}setupAlphaToCoverage(e,t){return W(()=>{let n=G().toVar(`distanceToPlane`),r=G().toVar(`distanceToGradient`),i=G(1).toVar(`clipOpacity`),a=t.length;if(this.hardwareClipping===!1&&a>0){let e=GN(t).setGroup(oA);RL(a,({i:t})=>{let a=e.element(t);n.assign(nF.dot(a.xyz).negate().add(a.w)),r.assign(n.fwidth().div(2)),i.mulAssign(tM(r.negate(),r,n))})}let o=e.length;if(o>0){let t=GN(e).setGroup(oA),a=G(1).toVar(`intersectionClipOpacity`);RL(o,({i:e})=>{let i=t.element(e);n.assign(nF.dot(i.xyz).negate().add(i.w)),r.assign(n.fwidth().div(2)),a.mulAssign(tM(r.negate(),r,n).oneMinus())}),i.mulAssign(a.oneMinus())}Tk.a.mulAssign(i),Tk.a.equal(0).discard()})()}setupDefault(e,t){return W(()=>{let n=t.length;if(this.hardwareClipping===!1&&n>0){let e=GN(t).setGroup(oA);RL(n,({i:t})=>{let n=e.element(t);nF.dot(n.xyz).greaterThan(n.w).discard()})}let r=e.length;if(r>0){let t=GN(e).setGroup(oA),n=rk(!0).toVar(`clipped`);RL(r,({i:e})=>{let r=t.element(e);n.assign(nF.dot(r.xyz).greaterThan(r.w).and(n))}),n.discard()}})()}setupHardwareClipping(e,t){let n=e.length;return t.enableHardwareClipping(n),W(()=>{let r=GN(e).setGroup(oA),i=KN(t.getClipDistance());RL(n,({i:e})=>{let t=r.element(e),n=nF.dot(t.xyz).sub(t.w).negate();i.element(e).assign(n)})})()}};vR.ALPHA_TO_COVERAGE=`alphaToCoverage`,vR.DEFAULT=`default`,vR.HARDWARE=`hardware`;var yR=()=>new vR,bR=()=>new vR(vR.ALPHA_TO_COVERAGE),xR=()=>new vR(vR.HARDWARE),SR=.05,CR=W(([e])=>sj(yA(1e4,cj(yA(17,e.x).add(yA(.1,e.y)))).mul(_A(.1,bj(cj(yA(13,e.y).add(e.x))))))),wR=W(([e])=>CR(ik(CR(e.xy),e.z))),TR=W(([e])=>{let t=Fj(Sj(Tj(e.xyz)),Sj(Ej(e.xyz))),n=G(1).div(G(SR).mul(t)).toVar(`pixScale`),r=ik($A(ij(tj(n))),$A(aj(tj(n)))),i=ik(wR(ij(r.x.mul(e.xyz))),wR(ij(r.y.mul(e.xyz)))),a=sj(tj(n)),o=_A(yA(a.oneMinus(),i.x),yA(a,i.y)),s=Pj(a,a.oneMinus()),c=J(o.mul(o).div(yA(2,s).mul(vA(1,s))),o.sub(yA(.5,s)).div(vA(1,s)),vA(1,vA(1,o).mul(vA(1,o)).div(yA(2,s).mul(vA(1,s)))));return Qj(o.lessThan(s.oneMinus()).select(o.lessThan(s).select(c.x,c.y),c.z),1e-6,1)}).setLayout({name:`getAlphaHashThreshold`,type:`float`,inputs:[{name:`position`,type:`vec3`}]}),ER=class extends EN{static get type(){return`VertexColorNode`}constructor(e){super(null,`vec4`),this.isVertexColorNode=!0,this.index=e}getAttributeName(){let e=this.index;return`color`+(e>0?e:``)}generate(e){let t=this.getAttributeName(e),n=e.hasGeometryAttribute(t),r;return r=n===!0?super.generate(e):e.generateConst(this.nodeType,new Hn(1,1,1,1)),r}serialize(e){super.serialize(e),e.index=this.index}deserialize(e){super.deserialize(e),this.index=e.index}},DR=(e=0)=>new ER(e),OR=class extends Mi{static get type(){return`NodeMaterial`}get type(){return this.constructor.type}set type(e){}constructor(){super(),this.isNodeMaterial=!0,this.fog=!0,this.lights=!1,this.lightsNode=null,this.envNode=null,this.aoNode=null,this.colorNode=null,this.normalNode=null,this.opacityNode=null,this.backdropNode=null,this.backdropAlphaNode=null,this.alphaTestNode=null,this.maskNode=null,this.maskShadowNode=null,this.positionNode=null,this.geometryNode=null,this.depthNode=null,this.receivedShadowPositionNode=null,this.castShadowPositionNode=null,this.receivedShadowNode=null,this.castShadowNode=null,this.outputNode=null,this.mrtNode=null,this.fragmentNode=null,this.vertexNode=null,this.contextNode=null}_getNodeChildren(){let e=[];for(let t of Object.getOwnPropertyNames(this)){if(t.startsWith(`_`)===!0)continue;let n=this[t];n&&n.isNode===!0&&e.push({property:t,childNode:n})}return e}customProgramCacheKey(){let e=[];for(let{property:t,childNode:n}of this._getNodeChildren())e.push(TD(t.slice(0,-4)),n.getCacheKey());return this.type+ED(e)}build(e){this.setup(e)}setupObserver(e){return new bD(e)}setup(e){e.context.setupNormal=()=>CM(this.setupNormal(e),`NORMAL`,`vec3`),e.context.setupPositionView=()=>this.setupPositionView(e),e.context.setupModelViewProjection=()=>this.setupModelViewProjection(e);let t=e.renderer,n=t.getRenderTarget();e.addStack();let r=this.setupVertex(e),i=CM(this.vertexNode||r,`VERTEX`);e.context.clipSpace=i,e.stack.outputNode=i,this.setupHardwareClipping(e),this.geometryNode!==null&&(e.stack.outputNode=e.stack.outputNode.bypass(this.geometryNode)),e.addFlow(`vertex`,e.removeStack()),e.addStack();let a,o=this.setupClipping(e);if((this.depthWrite===!0||this.depthTest===!0)&&(n===null?t.depth===!0&&this.setupDepth(e):n.depthBuffer===!0&&this.setupDepth(e)),this.fragmentNode===null){this.setupDiffuseColor(e),this.setupAmbientOcclusion(e),this.setupVariants(e);let r=this.setupLighting(e);o!==null&&e.stack.addToStack(o);let i=dk(r,Tk.a).max(0);a=this.setupOutput(e,i),Gk.assign(a);let s=this.outputNode!==null;if(s&&(a=this.outputNode),e.context.getOutput&&(a=e.context.getOutput(a,e)),n!==null){let e=t.getMRT(),n=this.mrtNode;e===null?n!==null&&(a=n):(s&&Gk.assign(a),a=e,n!==null&&(a=e.merge(n)))}}else{let t=this.fragmentNode;t.isOutputStructNode!==!0&&(t=t.convert(e.getOutputType())),a=this.setupOutput(e,t)}e.stack.outputNode=a,e.addFlow(`fragment`,e.removeStack()),e.observer=this.setupObserver(e)}setupClipping(e){if(e.clippingContext===null)return null;let{unionPlanes:t,intersectionPlanes:n}=e.clippingContext,r=null;if(t.length>0||n.length>0){let t=e.renderer.currentSamples;this.alphaToCoverage&&t>1?r=bR():e.stack.addToStack(yR())}return r}setupHardwareClipping(e){if(e.hardwareClipping=!1,e.clippingContext===null)return;let t=e.clippingContext.unionPlanes.length;t>0&&t<=8&&e.isAvailable(`clipDistance`)&&(e.stack.addToStack(xR()),e.hardwareClipping=!0)}setupDepth(e){let{renderer:t,camera:n}=e,r=this.depthNode;if(r===null){let e=t.getMRT();e&&e.has(`depth`)?r=e.get(`depth`):t.logarithmicDepthBuffer===!0&&(r=n.isPerspectiveCamera?fR(nF.z,bP,xP):oR(nF.z,bP,xP))}r!==null&&hR.assign(r).toStack()}setupPositionView(){return KP.mul(QP).xyz}setupModelViewProjection(){return SP.mul(nF)}setupVertex(e){return e.addStack(),this.setupPosition(e),e.context.position=e.removeStack(),oL}setupPosition(e){let{object:t,geometry:n}=e;if((n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color)&&KL(t),t.isSkinnedMesh===!0&&FL(t),this.displacementMap){let e=RF(`displacementMap`,`texture`),t=RF(`displacementScale`,`float`),n=RF(`displacementBias`,`float`);QP.addAssign(lF.normalize().mul(e.x.mul(t).add(n)))}return t.isBatchedMesh&&kL(t),t.isInstancedMesh&&t.instanceMatrix&&t.instanceMatrix.isInstancedBufferAttribute===!0&&TL(t),this.positionNode!==null&&QP.assign(CM(this.positionNode,`POSITION`,`vec3`)),QP}setupDiffuseColor(e){let{object:t,geometry:n}=e;this.maskNode!==null&&rk(this.maskNode).not().discard();let r=this.colorNode?dk(this.colorNode):CI;this.vertexColors===!0&&n.hasAttribute(`color`)&&(r=r.mul(DR())),t.instanceColor&&(r=CL.mul(r)),t.isBatchedMesh&&t._colorsTexture&&(r=OL.mul(r)),Tk.assign(r);let i=this.opacityNode?G(this.opacityNode):EI;Tk.a.assign(Tk.a.mul(i));let a=null;(this.alphaTestNode!==null||this.alphaTest>0)&&(a=this.alphaTestNode===null?SI:G(this.alphaTestNode),this.alphaToCoverage===!0?(Tk.a=tM(a,a.add(Aj(Tk.a)),Tk.a),Tk.a.lessThanEqual(0).discard()):Tk.a.lessThanEqual(a).discard()),this.alphaHash===!0&&Tk.a.lessThan(TR(QP)).discard(),e.isOpaque()&&Tk.a.assign(1)}setupVariants(){}setupOutgoingLight(){return this.lights===!0?J(0):Tk.rgb}setupNormal(){return this.normalNode?J(this.normalNode):PI}setupEnvironment(){let e=null;return this.envNode?e=this.envNode:this.envMap&&(e=this.envMap.isCubeTexture?RF(`envMap`,`cubeTexture`):RF(`envMap`,`texture`)),e}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new XL(rL)),t}setupMaterialLightings(e){let t=[];if(e.renderer.lighting.enabled===!1)return t;let n=this.setupEnvironment(e);n&&n.isLightingNode&&t.push(n);let r=this.setupLightMap(e);return r&&r.isLightingNode&&t.push(r),e.context.ambientOcclusion&&t.push(new JL(e.context.ambientOcclusion)),t}setupAmbientOcclusion(e){let t=this.aoNode;t===null&&e.material.aoMap&&(t=iL),e.context.getAO&&(t=e.context.getAO(t,e)),t!==null&&(tA.assign(t),e.context.ambientOcclusion=tA)}setupLightingModel(){}setupLighting(e){let{material:t}=e,{backdropNode:n,backdropAlphaNode:r,emissiveNode:i}=this,a=this.lights===!0||this.lightsNode!==null,o=this.lights===!0?this.setupMaterialLightings(e):[],s=a?this.lightsNode||e.lightsNode:null,c=this.setupOutgoingLight(e);return s&&(o.length>0||s.getScope().hasLights)?c=YL(s,this.setupLightingModel(e)||null,o,n,r):n!==null&&(c=J(r===null?n:Zj(c,n,r))),(i&&i.isNode===!0||t.emissive&&t.emissive.isColor===!0)&&(Dk.assign(J(i||TI)),c=c.add(Dk)),c}setupFog(e,t){let n=e.fogNode;return n&&(Gk.assign(t),t=dk(n.toVar())),t}setupPremultipliedAlpha(e,t){return gN(t)}setupOutput(e,t){return this.fog===!0&&(t=this.setupFog(e,t)),this.premultipliedAlpha===!0&&(t=this.setupPremultipliedAlpha(e,t)),t}setDefaultValues(e){for(let t in e){let n=e[t];this[t]===void 0&&(this[t]=n,n&&n.clone&&(this[t]=n.clone()))}let t=Object.getOwnPropertyDescriptors(e.constructor.prototype);for(let e in t)Object.getOwnPropertyDescriptor(this.constructor.prototype,e)===void 0&&t[e].get!==void 0&&Object.defineProperty(this.constructor.prototype,e,t[e])}toJSON(e){let t=e===void 0||typeof e==`string`;t&&(e={textures:{},images:{},nodes:{}});let n=Mi.prototype.toJSON.call(this,e);n.inputNodes={};for(let{property:t,childNode:r}of this._getNodeChildren())n.inputNodes[t]=r.toJSON(e).uuid;function r(e){let t=[];for(let n in e){let r=e[n];delete r.metadata,t.push(r)}return t}if(t){let t=r(e.textures),i=r(e.images),a=r(e.nodes);t.length>0&&(n.textures=t),i.length>0&&(n.images=i),a.length>0&&(n.nodes=a)}return n}copy(e){let t=Object.getOwnPropertyDescriptors(this.constructor.prototype);for(let n in t)if(t[n].set!==void 0&&e[n]!==void 0){let t=e[n];this[n]&&this[n].copy!==void 0?this[n].copy(t):this[n]=t}for(let t in this)if(!/^(?:is[A-Z]|_)|^(?:id|uuid|version|type|userData|clippingPlanes)$/.test(t)&&this[t]!==void 0&&e[t]!==void 0){let n=e[t];this[t]&&this[t].copy!==void 0?this[t].copy(n):this[t]=n}return this.clippingPlanes=e.clippingPlanes?e.clippingPlanes.map(e=>e.clone()):null,this.userData=JSON.parse(JSON.stringify(e.userData)),this}},kR=new ha,AR=class extends OR{static get type(){return`LineBasicNodeMaterial`}constructor(e){super(),this.isLineBasicNodeMaterial=!0,this.setDefaultValues(kR),this.setValues(e)}},jR=new Ms,MR=class extends OR{static get type(){return`LineDashedNodeMaterial`}constructor(e){super(),this.isLineDashedNodeMaterial=!0,this.setDefaultValues(jR),this.dashOffset=0,this.offsetNode=null,this.dashScaleNode=null,this.dashSizeNode=null,this.gapSizeNode=null,this.setValues(e)}setupVariants(){let e=this.offsetNode?G(this.offsetNode):eL,t=this.dashScaleNode?G(this.dashScaleNode):XI,n=this.dashSizeNode?G(this.dashSizeNode):ZI,r=this.gapSizeNode?G(this.gapSizeNode):QI;Kk.assign(n),qk.assign(r);let i=wM(DN(`lineDistance`).mul(t));(e?i.add(e):i).mod(Kk.add(qk)).greaterThan(Kk).discard()}},NR=wk(`vec3`,`worldStart`),PR=wk(`vec3`,`worldEnd`),FR=wk(`float`,`lineDistance`),IR=wk(`vec4`,`worldPos`),LR=W(({start:e,end:t})=>{let n=SP.element(2).element(2),r=SP.element(3).element(2);return n.greaterThan(0).select(r.negate().div(n.add(1)),r.mul(-.5).div(n)).sub(e.z).div(t.z.sub(e.z))},{start:`vec4`,end:`vec4`,return:`float`}),RR=W(({p1:e,p2:t,p3:n,p4:r})=>{let i=e.sub(n),a=r.sub(n),o=t.sub(e),s=i.dot(a),c=a.dot(o),l=i.dot(o),u=a.dot(a),d=o.dot(o).mul(u).sub(c.mul(c)),f=s.mul(c).sub(l.mul(u)).div(d).clamp();return ik(f,s.add(c.mul(f)).div(u).clamp())},{p1:`vec3`,p2:`vec3`,p3:`vec3`,p4:`vec3`,return:`vec2`});W(({material:e})=>{let t=e._useDash,n=e._useWorldUnits,r=DN(`instanceStart`),i=DN(`instanceEnd`),a=dk(KP.mul(dk(r,1))).toVar(`start`),o=dk(KP.mul(dk(i,1))).toVar(`end`),s,c;t&&(s=G(DN(`instanceDistanceStart`)).toVar(`distanceStart`),c=G(DN(`instanceDistanceEnd`)).toVar(`distanceEnd`)),n&&(NR.assign(a.xyz),PR.assign(o.xyz));let l=eP.z.div(eP.w);if($O(SP.element(2).element(3).equal(-1),()=>{$O(a.z.lessThan(0).and(o.z.greaterThan(0)),()=>{let e=LR({start:a,end:o});o.assign(dk(Zj(a.xyz,o.xyz,e),o.w)),t&&c.assign(Zj(s,c,e))}).ElseIf(o.z.lessThan(0).and(a.z.greaterThanEqual(0)),()=>{let e=LR({start:o,end:a});a.assign(dk(Zj(o.xyz,a.xyz,e),a.w)),t&&s.assign(Zj(c,s,e))})}),t){let t=e.dashScaleNode?G(e.dashScaleNode):XI,n=e.offsetNode?G(e.offsetNode):eL,r=ZP.y.lessThan(.5).select(t.mul(s),t.mul(c));r=r.add(n),FR.assign(r)}let u=SP.mul(a),d=SP.mul(o),f=u.xyz.div(u.w),p=d.xyz.div(d.w),m=p.xy.sub(f.xy).toVar();m.x.assign(m.x.mul(l)),m.assign(m.normalize());let h=dk().toVar();if(n){let e=o.xyz.sub(a.xyz).normalize(),n=Zj(a.xyz,o.xyz,.5).normalize(),r=e.cross(n).normalize(),i=e.cross(r);IR.assign(ZP.y.lessThan(.5).select(a,o));let s=$I.mul(.5);IR.addAssign(dk(ZP.x.lessThan(0).select(r.mul(s),r.mul(s).negate()),0)),t||(IR.addAssign(dk(ZP.y.lessThan(.5).select(e.mul(s).negate(),e.mul(s)),0)),IR.addAssign(dk(i.mul(s),0)),$O(ZP.y.greaterThan(1).or(ZP.y.lessThan(0)),()=>{IR.subAssign(dk(i.mul(2).mul(s),0))})),h.assign(SP.mul(IR));let c=J().toVar();c.assign(ZP.y.lessThan(.5).select(f,p)),h.z.assign(c.z.mul(h.w))}else{let e=ik(m.y,m.x.negate()).toVar(`offset`);m.x.assign(m.x.div(l)),e.x.assign(e.x.div(l)),e.assign(ZP.x.lessThan(0).select(e.negate(),e)),$O(ZP.y.lessThan(0),()=>{e.assign(e.sub(m))}).ElseIf(ZP.y.greaterThan(1),()=>{e.assign(e.add(m))}),e.assign(e.mul($I)),e.assign(e.div(eP.w.div(XN))),h.assign(ZP.y.lessThan(.5).select(u,d)),e.assign(e.mul(h.w)),h.assign(h.add(dk(e,0,0)))}return h})(),W(({material:e,renderer:t})=>{let n=e._useAlphaToCoverage,r=e._useDash,i=e._useWorldUnits,a=ON();if(r){let t=e.dashSizeNode?G(e.dashSizeNode):ZI,n=e.gapSizeNode?G(e.gapSizeNode):QI;Kk.assign(t),qk.assign(n),a.y.lessThan(-1).or(a.y.greaterThan(1)).discard(),FR.mod(Kk.add(qk)).greaterThan(Kk).discard()}let o=G(1).toVar(`alpha`);if(i){let e=IR.xyz.normalize().mul(1e5),i=PR.sub(NR),a=RR({p1:NR,p2:PR,p3:J(0,0,0),p4:e}),s=NR.add(i.mul(a.x)),c=e.mul(a.y),l=s.sub(c).length().div($I);if(!r)if(n&&t.currentSamples>0){let e=l.fwidth();o.assign(tM(e.negate().add(.5),e.add(.5),l).oneMinus())}else l.greaterThan(.5).discard()}else if(n&&t.currentSamples>0){let e=a.x,t=a.y.greaterThan(0).select(a.y.sub(1),a.y.add(1)),n=e.mul(e).add(t.mul(t)),r=G(n.fwidth()).toVar(`dlen`);$O(a.y.abs().greaterThan(1),()=>{o.assign(tM(r.oneMinus(),r.add(1),n).oneMinus())})}else $O(a.y.abs().greaterThan(1),()=>{let e=a.x,t=a.y.greaterThan(0).select(a.y.sub(1),a.y.add(1));e.mul(e).add(t.mul(t)).greaterThan(1).discard()});return o})();var zR=new Ds,BR=class extends OR{static get type(){return`MeshNormalNodeMaterial`}constructor(e){super(),this.isMeshNormalNodeMaterial=!0,this.setDefaultValues(zR),this.setValues(e)}setupDiffuseColor(){let e=this.opacityNode?G(this.opacityNode):EI;Tk.assign(MM(dk(fI(pF),e),yt))}},VR=W(([e=tF])=>ik(e.z.atan(e.x).mul(1/(Math.PI*2)).add(.5),e.y.clamp(-1,1).asin().mul(1/Math.PI).add(.5))),HR=W(([e=ON()])=>{let t=e.x.sub(.5).mul(Math.PI*2),n=e.y.sub(.5).mul(Math.PI),r=n.cos();return J(r.mul(t.cos()),n.sin(),r.mul(t.sin()))}),UR=class extends Un{constructor(e=1,t={}){super(e,e,t),this.isCubeRenderTarget=!0;let n={width:e,height:e,depth:1};this.texture=new Ia([n,n,n,n,n,n]),this._setTextureOptions(t),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,t){let n=t.minFilter,r=t.generateMipmaps;t.generateMipmaps=!0,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 i=new Ba(5,5,5),a=VR(tF),o=new OR;o.colorNode=FN(t,a,0),o.side=1,o.blending=0;let s=new ea(i,o),c=new Or;c.add(s),t.minFilter===1008&&(t.minFilter=ne);let l=new Oc(1,10,this),u=e.getMRT();return e.setMRT(null),l.update(e,c),e.setMRT(u),t.minFilter=n,t.generateMipmaps=r,s.geometry.dispose(),s.material.dispose(),this}clear(e,t=!0,n=!0,r=!0){let i=e.getRenderTarget();for(let i=0;i<6;i++)e.setRenderTarget(this,i),e.clear(t,n,r);e.setRenderTarget(i)}},WR=new WeakMap,GR=class extends $D{static get type(){return`CubeMapNode`}constructor(e){super(`vec3`),this.envNode=e,this._cubeTexture=null,this._cubeTextureNode=jF(null);let t=new Ia;t.isRenderTargetTexture=!0,this._defaultTexture=t,this.updateBeforeType=VD.RENDER}updateBefore(e){let{renderer:t,material:n}=e,r=this.envNode;if(r.isTextureNode||r.isMaterialReferenceNode){let e=r.isTextureNode?r.value:n[r.property];if(e&&e.isTexture){let n=e.mapping;if(n===303||n===304){if(WR.has(e)){let t=WR.get(e);JR(t,e.mapping),this._cubeTexture=t}else{let n=e.image;if(KR(n)){let r=new UR(n.height);r.fromEquirectangularTexture(t,e),JR(r.texture,e.mapping),this._cubeTexture=r.texture,WR.set(e,r.texture),e.addEventListener(`dispose`,qR)}else this._cubeTexture=this._defaultTexture}this._cubeTextureNode.value=this._cubeTexture}else this._cubeTextureNode=this.envNode}}}setup(e){return this.updateBefore(e),this._cubeTextureNode}};function KR(e){return e==null?!1:e.height>0}function qR(e){let t=e.target;t.removeEventListener(`dispose`,qR);let n=WR.get(t);n!==void 0&&(WR.delete(t),n.dispose())}function JR(e,t){t===303?e.mapping=301:t===304&&(e.mapping=302)}var YR=qO(GR).setParameterLength(1),XR=class extends qL{static get type(){return`BasicEnvironmentNode`}constructor(e=null){super(),this.envNode=e}setup(e){e.context.environment=YR(this.envNode)}},ZR=class extends qL{static get type(){return`BasicLightMapNode`}constructor(e=null){super(),this.lightMapNode=e}setup(e){let t=G(1/Math.PI);e.context.irradianceLightMap=this.lightMapNode.mul(t)}},QR=class{start(e){e.lightsNode.setupLights(e,e.lightsNode.getLightNodes(e)),this.indirect(e)}finish(){}direct(){}directRectArea(){}indirect(){}ambientOcclusion(){}},$R=class extends QR{constructor(){super()}indirect({context:e}){let t=e.ambientOcclusion,n=e.reflectedLight,r=e.irradianceLightMap;n.indirectDiffuse.assign(dk(0)),r?n.indirectDiffuse.addAssign(r):n.indirectDiffuse.addAssign(dk(1,1,1,0)),n.indirectDiffuse.mulAssign(t),n.indirectDiffuse.mulAssign(Tk.rgb)}finish(e){let{material:t,context:n}=e,r=n.outgoingLight,i=e.context.environment;if(i)switch(t.combine){case 0:r.rgb.assign(Zj(r.rgb,r.rgb.mul(i.rgb),AI.mul(jI)));break;case 1:r.rgb.assign(Zj(r.rgb,i.rgb,AI.mul(jI)));break;case 2:r.rgb.addAssign(i.rgb.mul(AI.mul(jI)));break;default:F(`BasicLightingModel: Unsupported .combine value:`,t.combine);break}}},ez=new Hi,tz=class extends OR{static get type(){return`MeshBasicNodeMaterial`}constructor(e){super(),this.isMeshBasicNodeMaterial=!0,this.lights=!0,this.setDefaultValues(ez),this.setValues(e)}setupNormal(){return oF(dF)}setupEnvironment(e){let t=super.setupEnvironment(e);return t?new XR(t):null}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new ZR(rL)),t}setupOutgoingLight(){return Tk.rgb}setupLightingModel(){return new $R}},nz=W(({f0:e,f90:t,dotVH:n})=>{let r=n.mul(-5.55473).sub(6.98316).mul(n).exp2();return e.mul(r.oneMinus()).add(t.mul(r))}),rz=W(e=>e.diffuseColor.mul(1/Math.PI)),iz=()=>G(.25),az=W(({dotNH:e})=>Wk.mul(G(.5)).add(1).mul(G(1/Math.PI)).mul(e.pow(Wk))),oz=W(({lightDirection:e})=>{let t=e.add(rF).normalize(),n=pF.dot(t).clamp(),r=nz({f0:Vk,f90:1,dotVH:rF.dot(t).clamp()}),i=iz(),a=az({dotNH:n});return r.mul(i).mul(a)}),sz=class extends $R{constructor(e=!0){super(),this.specular=e}direct({lightDirection:e,lightColor:t,reflectedLight:n}){let r=pF.dot(e).clamp().mul(t);n.directDiffuse.addAssign(r.mul(rz({diffuseColor:Tk.rgb}))),this.specular===!0&&n.directSpecular.addAssign(r.mul(oz({lightDirection:e})).mul(AI))}indirect(e){let{ambientOcclusion:t,irradiance:n,reflectedLight:r}=e.context;r.indirectDiffuse.addAssign(n.mul(rz({diffuseColor:Tk}))),r.indirectDiffuse.mulAssign(t)}},cz=new Os,lz=class extends OR{static get type(){return`MeshLambertNodeMaterial`}constructor(e){super(),this.isMeshLambertNodeMaterial=!0,this.lights=!0,this.setDefaultValues(cz),this.setValues(e)}setupEnvironment(e){let t=super.setupEnvironment(e);return t?new XR(t):null}setupLightingModel(){return new sz(!1)}},uz=new Ts,dz=class extends OR{static get type(){return`MeshPhongNodeMaterial`}constructor(e){super(),this.isMeshPhongNodeMaterial=!0,this.lights=!0,this.shininessNode=null,this.specularNode=null,this.setDefaultValues(uz),this.setValues(e)}setupEnvironment(e){let t=super.setupEnvironment(e);return t?new XR(t):null}setupLightingModel(){return new sz}setupVariants(){let e=(this.shininessNode?G(this.shininessNode):wI).max(1e-4);Wk.assign(e);let t=this.specularNode||DI;Vk.assign(t)}},fz=W(e=>{if(e.geometry.hasAttribute(`normal`)===!1)return G(0);let t=dF.dFdx().abs().max(dF.dFdy().abs());return t.x.max(t.y).max(t.z)}),pz=W(e=>{let{roughness:t}=e,n=fz(),r=t.max(.0525);return r=r.add(n),r=r.min(1),r}),mz=W(({alpha:e,dotNL:t,dotNV:n})=>{let r=e.pow2(),i=t.mul(r.add(r.oneMinus().mul(n.pow2())).sqrt()),a=n.mul(r.add(r.oneMinus().mul(t.pow2())).sqrt());return bA(.5,i.add(a).max(HA))}).setLayout({name:`V_GGX_SmithCorrelated`,type:`float`,inputs:[{name:`alpha`,type:`float`},{name:`dotNL`,type:`float`},{name:`dotNV`,type:`float`}]}),hz=W(({alphaT:e,alphaB:t,dotTV:n,dotBV:r,dotTL:i,dotBL:a,dotNV:o,dotNL:s})=>{let c=s.mul(J(e.mul(n),t.mul(r),o).length()),l=o.mul(J(e.mul(i),t.mul(a),s).length());return bA(.5,c.add(l).max(HA))}).setLayout({name:`V_GGX_SmithCorrelated_Anisotropic`,type:`float`,inputs:[{name:`alphaT`,type:`float`,qualifier:`in`},{name:`alphaB`,type:`float`,qualifier:`in`},{name:`dotTV`,type:`float`,qualifier:`in`},{name:`dotBV`,type:`float`,qualifier:`in`},{name:`dotTL`,type:`float`,qualifier:`in`},{name:`dotBL`,type:`float`,qualifier:`in`},{name:`dotNV`,type:`float`,qualifier:`in`},{name:`dotNL`,type:`float`,qualifier:`in`}]}),gz=W(({alpha:e,dotNH:t})=>{let n=e.pow2(),r=t.pow2().mul(n.oneMinus()).oneMinus();return n.div(r.pow2()).mul(1/Math.PI)}).setLayout({name:`D_GGX`,type:`float`,inputs:[{name:`alpha`,type:`float`},{name:`dotNH`,type:`float`}]}),_z=G(1/Math.PI),vz=W(({alphaT:e,alphaB:t,dotNH:n,dotTH:r,dotBH:i})=>{let a=e.mul(t),o=J(t.mul(r),e.mul(i),a.mul(n)),s=o.dot(o),c=a.div(s);return _z.mul(a.mul(c.pow2()))}).setLayout({name:`D_GGX_Anisotropic`,type:`float`,inputs:[{name:`alphaT`,type:`float`,qualifier:`in`},{name:`alphaB`,type:`float`,qualifier:`in`},{name:`dotNH`,type:`float`,qualifier:`in`},{name:`dotTH`,type:`float`,qualifier:`in`},{name:`dotBH`,type:`float`,qualifier:`in`}]}),yz=W(({lightDirection:e,f0:t,f90:n,roughness:r,f:i,normalView:a=pF,USE_IRIDESCENCE:o,USE_ANISOTROPY:s})=>{let c=r.pow2(),l=e.add(rF).normalize(),u=a.dot(e).clamp(),d=a.dot(rF).clamp(),f=a.dot(l).clamp(),p=nz({f0:t,f90:n,dotVH:rF.dot(l).clamp()}),m,h;if(BO(o)&&(p=Pk.mix(p,i)),BO(s)){let t=zk.dot(e),n=zk.dot(rF),r=zk.dot(l),i=Bk.dot(e),a=Bk.dot(rF),o=Bk.dot(l);m=hz({alphaT:Lk,alphaB:c,dotTV:n,dotBV:a,dotTL:t,dotBL:i,dotNV:d,dotNL:u}),h=vz({alphaT:Lk,alphaB:c,dotNH:f,dotTH:r,dotBH:o})}else m=mz({alpha:c,dotNL:u,dotNV:d}),h=gz({alpha:c,dotNH:f});return p.mul(m).mul(h)}),bz=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]),xz=null,Sz=W(({roughness:e,dotNV:t})=>{xz===null&&(xz=new ra(bz,16,16,Ee,pe),xz.name=`DFG_LUT`,xz.minFilter=ne,xz.magFilter=ne,xz.wrapS=j,xz.wrapT=j,xz.generateMipmaps=!1,xz.needsUpdate=!0);let n=ik(e,t);return FN(xz,n).rg}),Cz=W(({lightDirection:e,f0:t,f90:n,roughness:r,f:i,USE_IRIDESCENCE:a,USE_ANISOTROPY:o})=>{let s=yz({lightDirection:e,f0:t,f90:n,roughness:r,f:i,USE_IRIDESCENCE:a,USE_ANISOTROPY:o}),c=pF.dot(e).clamp(),l=Sz({roughness:r,dotNV:pF.dot(rF).clamp()}),u=Sz({roughness:r,dotNV:c}),d=t.mul(l.x).add(n.mul(l.y)),f=t.mul(u.x).add(n.mul(u.y)),p=l.x.add(l.y),m=u.x.add(u.y),h=G(1).sub(p),g=G(1).sub(m),_=t.add(t.oneMinus().mul(.047619)),v=d.mul(f).mul(_).div(G(1).sub(h.mul(g).mul(_).mul(_)).add(HA)),y=h.mul(g),b=v.mul(y);return s.add(b)}),wz=W(e=>{let{dotNV:t,specularColor:n,specularF90:r,roughness:i}=e,a=Sz({dotNV:t,roughness:i});return n.mul(a.x).add(r.mul(a.y))}),Tz=W(({f:e,f90:t,dotVH:n})=>{let r=n.oneMinus().saturate(),i=r.mul(r),a=r.mul(i,i).clamp(0,.9999);return e.sub(J(t).mul(a)).div(a.oneMinus())}).setLayout({name:`Schlick_to_F0`,type:`vec3`,inputs:[{name:`f`,type:`vec3`},{name:`f90`,type:`float`},{name:`dotVH`,type:`float`}]}),Ez=W(({roughness:e,dotNH:t})=>{let n=e.pow2(),r=G(1).div(n),i=t.pow2().oneMinus().max(.0078125);return G(2).add(r).mul(i.pow(r.mul(.5))).div(2*Math.PI)}).setLayout({name:`D_Charlie`,type:`float`,inputs:[{name:`roughness`,type:`float`},{name:`dotNH`,type:`float`}]}),Dz=W(({dotNV:e,dotNL:t})=>G(1).div(G(4).mul(t.add(e).sub(t.mul(e))))).setLayout({name:`V_Neubelt`,type:`float`,inputs:[{name:`dotNV`,type:`float`},{name:`dotNL`,type:`float`}]}),Oz=W(({lightDirection:e})=>{let t=e.add(rF).normalize(),n=pF.dot(e).clamp(),r=pF.dot(rF).clamp(),i=Ez({roughness:Nk,dotNH:pF.dot(t).clamp()}),a=Dz({dotNV:r,dotNL:n});return Mk.mul(i).mul(a)}),kz=W(({N:e,V:t,roughness:n})=>{let r=ik(n,e.dot(t).saturate().oneMinus().sqrt());return r.assign(r.mul(.984375).add(.0078125)),r}).setLayout({name:`LTC_Uv`,type:`vec2`,inputs:[{name:`N`,type:`vec3`},{name:`V`,type:`vec3`},{name:`roughness`,type:`float`}]}),Az=W(({f:e})=>{let t=e.length();return Fj(t.mul(t).add(e.z).div(t.add(1)),0)}).setLayout({name:`LTC_ClippedSphereFormFactor`,type:`float`,inputs:[{name:`f`,type:`vec3`}]}),jz=W(({v1:e,v2:t})=>{let n=e.dot(t),r=n.abs().toVar(),i=r.mul(.0145206).add(.4965155).mul(r).add(.8543985).toVar(),a=r.add(4.1616724).mul(r).add(3.417594).toVar(),o=i.div(a),s=n.greaterThan(0).select(o,Fj(n.mul(n).oneMinus(),1e-7).inverseSqrt().mul(.5).sub(o));return e.cross(t).mul(s)}).setLayout({name:`LTC_EdgeVectorFormFactor`,type:`vec3`,inputs:[{name:`v1`,type:`vec3`},{name:`v2`,type:`vec3`}]}),Mz=W(({N:e,V:t,P:n,mInv:r,p0:i,p1:a,p2:o,p3:s})=>{let c=a.sub(i).toVar(),l=s.sub(i).toVar(),u=c.cross(l),d=J().toVar();return $O(u.dot(n.sub(i)).greaterThanEqual(0),()=>{let c=t.sub(e.mul(t.dot(e))).normalize(),l=e.cross(c).negate(),u=r.mul(gk(c,l,e).transpose()).toVar(),f=u.mul(i.sub(n)).normalize().toVar(),p=u.mul(a.sub(n)).normalize().toVar(),m=u.mul(o.sub(n)).normalize().toVar(),h=u.mul(s.sub(n)).normalize().toVar(),g=J(0).toVar();g.addAssign(jz({v1:f,v2:p})),g.addAssign(jz({v1:p,v2:m})),g.addAssign(jz({v1:m,v2:h})),g.addAssign(jz({v1:h,v2:f})),d.assign(J(Az({f:g})))}),d}).setLayout({name:`LTC_Evaluate`,type:`vec3`,inputs:[{name:`N`,type:`vec3`},{name:`V`,type:`vec3`},{name:`P`,type:`vec3`},{name:`mInv`,type:`mat3`},{name:`p0`,type:`vec3`},{name:`p1`,type:`vec3`},{name:`p2`,type:`vec3`},{name:`p3`,type:`vec3`}]}),Nz=1/6,Pz=e=>yA(Nz,yA(e,yA(e,e.negate().add(3)).sub(3)).add(1)),Fz=e=>yA(Nz,yA(e,yA(e,yA(3,e).sub(6))).add(4)),Iz=e=>yA(Nz,yA(e,yA(e,yA(-3,e).add(3)).add(3)).add(1)),Lz=e=>yA(Nz,Hj(e,3)),Rz=e=>Pz(e).add(Fz(e)),zz=e=>Iz(e).add(Lz(e)),Bz=e=>_A(-1,Fz(e).div(Pz(e).add(Fz(e)))),Vz=e=>_A(1,Lz(e).div(Iz(e).add(Lz(e)))),Hz=(e,t,n)=>{let r=e.uvNode,i=yA(r,t.zw).add(.5),a=ij(i),o=sj(i),s=Rz(o.x),c=zz(o.x),l=Bz(o.x),u=Vz(o.x),d=Bz(o.y),f=Vz(o.y),p=ik(a.x.add(l),a.y.add(d)).sub(.5).mul(t.xy),m=ik(a.x.add(u),a.y.add(d)).sub(.5).mul(t.xy),h=ik(a.x.add(l),a.y.add(f)).sub(.5).mul(t.xy),g=ik(a.x.add(u),a.y.add(f)).sub(.5).mul(t.xy),_=Rz(o.y).mul(_A(s.mul(e.sample(p).level(n)),c.mul(e.sample(m).level(n)))),v=zz(o.y).mul(_A(s.mul(e.sample(h).level(n)),c.mul(e.sample(g).level(n))));return _.add(v)},Uz=W(([e,t])=>{let n=ik(e.size(K(t))),r=ik(e.size(K(t.add(1)))),i=bA(1,n),a=bA(1,r),o=Hz(e,dk(i,n),ij(t)),s=Hz(e,dk(a,r),aj(t));return sj(t).mix(o,s)}),Wz=W(([e,t])=>Uz(e,t.mul(AN(e)))),Gz=W(([e,t,n,r,i])=>{let a=J(eM(t.negate(),oj(e),bA(1,r))),o=J(Sj(i[0].xyz),Sj(i[1].xyz),Sj(i[2].xyz));return oj(a).mul(n.mul(o))}).setLayout({name:`getVolumeTransmissionRay`,type:`vec3`,inputs:[{name:`n`,type:`vec3`},{name:`v`,type:`vec3`},{name:`thickness`,type:`float`},{name:`ior`,type:`float`},{name:`modelMatrix`,type:`mat4`}]}),Kz=W(([e,t])=>e.mul(Qj(t.mul(2).sub(2),0,1))).setLayout({name:`applyIorToRoughness`,type:`float`,inputs:[{name:`roughness`,type:`float`},{name:`ior`,type:`float`}]}),qz=eR(),Jz=nR(),Yz=W(([e,t,n],{material:r})=>Uz((r.side===1?qz:Jz).sample(e),tj(QN.x).mul(Kz(t,n)))),Xz=W(([e,t,n])=>($O(n.notEqual(0),()=>QA(ej(t).negate().div(n).negate().mul(e))),J(1))).setLayout({name:`volumeAttenuation`,type:`vec3`,inputs:[{name:`transmissionDistance`,type:`float`},{name:`attenuationColor`,type:`vec3`},{name:`attenuationDistance`,type:`float`}]}),Zz=W(([e,t,n,r,i,a,o,s,c,l,u,d,f,p,m])=>{let h,g;if(m){h=dk().toVar(),g=J().toVar();let i=u.sub(1).mul(m.mul(.025)),a=J(u.sub(i),u,u.add(i));RL({start:0,end:3},({i})=>{let u=a.element(i),m=Gz(e,t,d,u,s),_=o.add(m),v=l.mul(c.mul(dk(_,1))),y=ik(v.xy.div(v.w)).toVar();y.addAssign(1),y.divAssign(2),y.assign(ik(y.x,y.y.oneMinus()));let b=Yz(y,n,u);h.element(i).assign(b.element(i)),h.a.addAssign(b.a),g.element(i).assign(r.element(i).mul(Xz(Sj(m),f,p).element(i)))}),h.a.divAssign(3)}else{let i=Gz(e,t,d,u,s),a=o.add(i),m=l.mul(c.mul(dk(a,1))),_=ik(m.xy.div(m.w)).toVar();_.addAssign(1),_.divAssign(2),_.assign(ik(_.x,_.y.oneMinus())),h=Yz(_,n,u),g=r.mul(Xz(Sj(i),f,p))}let _=g.rgb.mul(h.rgb),v=J(wz({dotNV:e.dot(t).clamp(),specularColor:i,specularF90:a,roughness:n})),y=g.r.add(g.g,g.b).div(3);return dk(v.oneMinus().mul(_),h.a.oneMinus().mul(y).oneMinus())}),Qz=gk(3.2404542,-.969266,.0556434,-1.5371385,1.8760108,-.2040259,-.4985314,.041556,1.0572252),$z=e=>{let t=e.sqrt();return J(1).add(t).div(J(1).sub(t))},eB=(e,t)=>e.sub(t).div(e.add(t)).pow2(),tB=(e,t)=>{let n=e.mul(2*Math.PI*1e-9),r=J(54856e-17,44201e-17,52481e-17),i=J(1681e3,1795300,2208400),a=J(43278e5,93046e5,66121e5),o=G(9747e-17*Math.sqrt(2*Math.PI*45282e5)).mul(n.mul(2239900).add(t.x).cos()).mul(n.pow2().mul(-45282e5).exp()),s=r.mul(a.mul(2*Math.PI).sqrt()).mul(i.mul(n).add(t).cos()).mul(n.pow2().negate().mul(a).exp());return s=J(s.x.add(o),s.y,s.z).div(1.0685e-7),Qz.mul(s)},nB=W(({outsideIOR:e,eta2:t,cosTheta1:n,thinFilmThickness:r,baseF0:i})=>{let a=Zj(e,t,tM(0,.03,r)),o=e.div(a).pow2().mul(n.pow2().oneMinus()).oneMinus();$O(o.lessThan(0),()=>J(1));let s=o.sqrt(),c=nz({f0:eB(a,e),f90:1,dotVH:n}),l=c.oneMinus(),u=a.lessThan(e).select(Math.PI,0),d=G(Math.PI).sub(u),f=$z(i.clamp(0,.9999)),p=nz({f0:eB(f,a.toVec3()),f90:1,dotVH:s}),m=J(f.x.lessThan(a).select(Math.PI,0),f.y.lessThan(a).select(Math.PI,0),f.z.lessThan(a).select(Math.PI,0)),h=a.mul(r,s,2),g=J(d).add(m),_=c.mul(p).clamp(1e-5,.9999),v=_.sqrt(),y=l.pow2().mul(p).div(J(1).sub(_)),b=c.add(y).toVar(),x=y.sub(l).toVar();return RL({start:1,end:2,condition:`<=`,name:`m`},({m:e})=>{x.mulAssign(v);let t=tB(G(e).mul(h),G(e).mul(g)).mul(2);b.addAssign(x.mul(t))}),b.max(J(0))}).setLayout({name:`evalIridescence`,type:`vec3`,inputs:[{name:`outsideIOR`,type:`float`},{name:`eta2`,type:`float`},{name:`cosTheta1`,type:`float`},{name:`thinFilmThickness`,type:`float`},{name:`baseF0`,type:`vec3`}]}),rB=W(({normal:e,viewDir:t,roughness:n})=>{let r=e.dot(t).saturate(),i=n.mul(n),a=n.add(.1).reciprocal(),o=G(-1.9362).add(n.mul(1.0678)).add(i.mul(.4573)).sub(a.mul(.8469)),s=G(-.6014).add(n.mul(.5538)).sub(i.mul(.467)).sub(a.mul(.1255));return o.mul(r).add(s).exp().saturate()}),iB=J(.04),aB=G(1),oB=class extends QR{constructor(e=!1,t=!1,n=!1,r=!1,i=!1,a=!1){super(),this.clearcoat=e,this.sheen=t,this.iridescence=n,this.anisotropy=r,this.transmission=i,this.dispersion=a,this.clearcoatRadiance=null,this.clearcoatSpecularDirect=null,this.clearcoatSpecularIndirect=null,this.sheenSpecularDirect=null,this.sheenSpecularIndirect=null,this.iridescenceFresnel=null,this.iridescenceF0=null,this.iridescenceF0Dielectric=null,this.iridescenceF0Metallic=null}start(e){if(this.clearcoat===!0&&(this.clearcoatRadiance=J().toVar(`clearcoatRadiance`),this.clearcoatSpecularDirect=J().toVar(`clearcoatSpecularDirect`),this.clearcoatSpecularIndirect=J().toVar(`clearcoatSpecularIndirect`)),this.sheen===!0&&(this.sheenSpecularDirect=J().toVar(`sheenSpecularDirect`),this.sheenSpecularIndirect=J().toVar(`sheenSpecularIndirect`)),this.iridescence===!0){let e=pF.dot(rF).clamp(),t=nB({outsideIOR:G(1),eta2:Fk,cosTheta1:e,thinFilmThickness:Ik,baseF0:Vk}),n=nB({outsideIOR:G(1),eta2:Fk,cosTheta1:e,thinFilmThickness:Ik,baseF0:Tk.rgb});this.iridescenceFresnel=Zj(t,n,kk),this.iridescenceF0Dielectric=Tz({f:t,f90:1,dotVH:e}),this.iridescenceF0Metallic=Tz({f:n,f90:1,dotVH:e}),this.iridescenceF0=Zj(this.iridescenceF0Dielectric,this.iridescenceF0Metallic,kk)}if(this.transmission===!0){let t=eF,n=DP.sub(eF).normalize(),r=mF,i=e.context;i.backdrop=Zz(r,n,Ok,Ek,Hk,Uk,t,zP,wP,SP,Yk,Zk,$k,Qk,this.dispersion?eA:null),i.backdropAlpha=Xk,Tk.a.mulAssign(Zj(1,i.backdrop.a,Xk))}super.start(e)}computeMultiscattering(e,t,n,r,i=null){let a=Sz({roughness:Ok,dotNV:pF.dot(rF).clamp()}),o=i?Pk.mix(r,i):r,s=o.mul(a.x).add(n.mul(a.y)),c=a.x.add(a.y).oneMinus(),l=o.add(o.oneMinus().mul(.047619)),u=s.mul(l).div(c.mul(l).oneMinus());e.addAssign(s),t.addAssign(u.mul(c))}direct({lightDirection:e,lightColor:t,reflectedLight:n}){let r=pF.dot(e).clamp().mul(t).toVar();if(this.sheen===!0){this.sheenSpecularDirect.addAssign(r.mul(Oz({lightDirection:e})));let t=rB({normal:pF,viewDir:rF,roughness:Nk}),n=rB({normal:pF,viewDir:e,roughness:Nk}),i=Mk.r.max(Mk.g).max(Mk.b).mul(t.max(n)).oneMinus();r.mulAssign(i)}if(this.clearcoat===!0){let n=hF.dot(e).clamp().mul(t);this.clearcoatSpecularDirect.addAssign(n.mul(yz({lightDirection:e,f0:iB,f90:aB,roughness:jk,normalView:hF})))}n.directDiffuse.addAssign(r.mul(rz({diffuseColor:Ek}))),n.directSpecular.addAssign(r.mul(Cz({lightDirection:e,f0:Hk,f90:1,roughness:Ok,f:this.iridescenceFresnel,USE_IRIDESCENCE:this.iridescence,USE_ANISOTROPY:this.anisotropy})))}directRectArea({lightColor:e,lightPosition:t,halfWidth:n,halfHeight:r,reflectedLight:i,ltc_1:a,ltc_2:o}){let s=t.add(n).sub(r),c=t.sub(n).sub(r),l=t.sub(n).add(r),u=t.add(n).add(r),d=pF,f=rF,p=nF.toVar(),m=kz({N:d,V:f,roughness:Ok}),h=a.sample(m).toVar(),g=o.sample(m).toVar(),_=gk(J(h.x,0,h.y),J(0,1,0),J(h.z,0,h.w)).toVar(),v=Hk.mul(g.x).add(Uk.sub(Hk).mul(g.y)).toVar();if(i.directSpecular.addAssign(e.mul(v).mul(Mz({N:d,V:f,P:p,mInv:_,p0:s,p1:c,p2:l,p3:u}))),i.directDiffuse.addAssign(e.mul(Ek).mul(Mz({N:d,V:f,P:p,mInv:gk(1,0,0,0,1,0,0,0,1),p0:s,p1:c,p2:l,p3:u}))),this.clearcoat===!0){let t=hF,n=kz({N:t,V:f,roughness:jk}),r=a.sample(n),i=o.sample(n),d=gk(J(r.x,0,r.y),J(0,1,0),J(r.z,0,r.w)),m=iB.mul(i.x).add(aB.sub(iB).mul(i.y));this.clearcoatSpecularDirect.addAssign(e.mul(m).mul(Mz({N:t,V:f,P:p,mInv:d,p0:s,p1:c,p2:l,p3:u})))}}indirect(e){this.indirectDiffuse(e),this.indirectSpecular(e),this.ambientOcclusion(e)}indirectDiffuse(e){let{irradiance:t,reflectedLight:n}=e.context,r=t.mul(rz({diffuseColor:Ek})).toVar();if(this.sheen===!0){let e=rB({normal:pF,viewDir:rF,roughness:Nk}),t=Mk.r.max(Mk.g).max(Mk.b).mul(e).oneMinus();r.mulAssign(t)}n.indirectDiffuse.addAssign(r)}indirectSpecular(e){let{radiance:t,iblIrradiance:n,reflectedLight:r}=e.context;if(this.sheen===!0&&this.sheenSpecularIndirect.addAssign(n.mul(Mk,rB({normal:pF,viewDir:rF,roughness:Nk}))),this.clearcoat===!0){let e=wz({dotNV:hF.dot(rF).clamp(),specularColor:iB,specularF90:aB,roughness:jk});this.clearcoatSpecularIndirect.addAssign(this.clearcoatRadiance.mul(e))}let i=J().toVar(`singleScatteringDielectric`),a=J().toVar(`multiScatteringDielectric`),o=J().toVar(`singleScatteringMetallic`),s=J().toVar(`multiScatteringMetallic`);this.computeMultiscattering(i,a,Uk,Vk,this.iridescenceF0Dielectric),this.computeMultiscattering(o,s,Uk,Tk.rgb,this.iridescenceF0Metallic);let c=Zj(i,o,kk),l=Zj(a,s,kk),u=i.add(a),d=Ek.mul(u.oneMinus()),f=n.mul(1/Math.PI),p=t.mul(c).add(l.mul(f)).toVar(),m=d.mul(f).toVar();if(this.sheen===!0){let e=rB({normal:pF,viewDir:rF,roughness:Nk}),t=Mk.r.max(Mk.g).max(Mk.b).mul(e).oneMinus();p.mulAssign(t),m.mulAssign(t)}r.indirectSpecular.addAssign(p),r.indirectDiffuse.addAssign(m)}ambientOcclusion(e){let{ambientOcclusion:t,reflectedLight:n}=e.context,r=pF.dot(rF).clamp().add(t),i=Ok.mul(-16).oneMinus().negate().exp2(),a=t.sub(r.pow(i).oneMinus()).clamp();this.clearcoat===!0&&this.clearcoatSpecularIndirect.mulAssign(t),this.sheen===!0&&this.sheenSpecularIndirect.mulAssign(t),n.indirectDiffuse.mulAssign(t),n.indirectSpecular.mulAssign(a)}finish({context:e}){let{outgoingLight:t}=e;if(this.clearcoat===!0){let e=nz({dotVH:hF.dot(rF).clamp(),f0:iB,f90:aB}),n=t.mul(Ak.mul(e).oneMinus()).add(this.clearcoatSpecularDirect.add(this.clearcoatSpecularIndirect).mul(Ak));t.assign(n)}if(this.sheen===!0){let e=t.add(this.sheenSpecularDirect,this.sheenSpecularIndirect.mul(1/Math.PI));t.assign(e)}}},sB=G(1),cB=G(-2),lB=G(.8),uB=G(-1),dB=G(.4),fB=G(2),pB=G(.305),mB=G(3),hB=G(.21),gB=G(4),_B=G(4),vB=G(16),yB=W(([e])=>{let t=J(bj(e)).toVar(),n=G(-1).toVar();return $O(t.x.greaterThan(t.z),()=>{$O(t.x.greaterThan(t.y),()=>{n.assign(lM(e.x.greaterThan(0),0,3))}).Else(()=>{n.assign(lM(e.y.greaterThan(0),1,4))})}).Else(()=>{$O(t.z.greaterThan(t.y),()=>{n.assign(lM(e.z.greaterThan(0),2,5))}).Else(()=>{n.assign(lM(e.y.greaterThan(0),1,4))})}),n}).setLayout({name:`getFace`,type:`float`,inputs:[{name:`direction`,type:`vec3`}]}),bB=W(([e,t])=>{let n=ik().toVar();return $O(t.equal(0),()=>{n.assign(ik(e.z,e.y).div(bj(e.x)))}).ElseIf(t.equal(1),()=>{n.assign(ik(e.x.negate(),e.z.negate()).div(bj(e.y)))}).ElseIf(t.equal(2),()=>{n.assign(ik(e.x.negate(),e.y).div(bj(e.z)))}).ElseIf(t.equal(3),()=>{n.assign(ik(e.z.negate(),e.y).div(bj(e.x)))}).ElseIf(t.equal(4),()=>{n.assign(ik(e.x.negate(),e.z).div(bj(e.y)))}).Else(()=>{n.assign(ik(e.x,e.y).div(bj(e.z)))}),yA(.5,n.add(1))}).setLayout({name:`getUV`,type:`vec2`,inputs:[{name:`direction`,type:`vec3`},{name:`face`,type:`float`}]}),xB=W(([e])=>{let t=G(0).toVar();return $O(e.greaterThanEqual(lB),()=>{t.assign(sB.sub(e).mul(uB.sub(cB)).div(sB.sub(lB)).add(cB))}).ElseIf(e.greaterThanEqual(dB),()=>{t.assign(lB.sub(e).mul(fB.sub(uB)).div(lB.sub(dB)).add(uB))}).ElseIf(e.greaterThanEqual(pB),()=>{t.assign(dB.sub(e).mul(mB.sub(fB)).div(dB.sub(pB)).add(fB))}).ElseIf(e.greaterThanEqual(hB),()=>{t.assign(pB.sub(e).mul(gB.sub(mB)).div(pB.sub(hB)).add(mB))}).Else(()=>{t.assign(G(-2).mul(tj(yA(1.16,e))))}),t}).setLayout({name:`roughnessToMip`,type:`float`,inputs:[{name:`roughness`,type:`float`}]}),SB=W(([e,t])=>{let n=e.toVar();n.assign(yA(2,n).sub(1));let r=J(n,1).toVar();return $O(t.equal(0),()=>{r.assign(r.zyx)}).ElseIf(t.equal(1),()=>{r.assign(r.xzy),r.xz.mulAssign(-1)}).ElseIf(t.equal(2),()=>{r.x.mulAssign(-1)}).ElseIf(t.equal(3),()=>{r.assign(r.zyx),r.xz.mulAssign(-1)}).ElseIf(t.equal(4),()=>{r.assign(r.xzy),r.xy.mulAssign(-1)}).ElseIf(t.equal(5),()=>{r.z.mulAssign(-1)}),r}).setLayout({name:`getDirection`,type:`vec3`,inputs:[{name:`uv`,type:`vec2`},{name:`face`,type:`float`}]}),CB=W(([e,t,n,r,i,a])=>{let o=G(n),s=J(t),c=Qj(xB(o),cB,a),l=sj(c),u=ij(c),d=J(wB(e,s,u,r,i,a)).toVar();return $O(l.notEqual(0),()=>{let t=J(wB(e,s,u.add(1),r,i,a)).toVar();d.assign(Zj(d,t,l))}),d}),wB=W(([e,t,n,r,i,a])=>{let o=G(n).toVar(),s=J(t),c=G(yB(s)).toVar(),l=G(Fj(_B.sub(o),0)).toVar();o.assign(Fj(o,_B));let u=G($A(o)).toVar(),d=ik(bB(s,c).mul(u.sub(2)).add(1)).toVar();return $O(c.greaterThan(2),()=>{d.y.addAssign(u),c.subAssign(3)}),d.x.addAssign(c.mul(u)),d.x.addAssign(l.mul(yA(3,vB))),d.y.addAssign(yA(4,$A(a).sub(u))),d.x.mulAssign(r),d.y.mulAssign(i),e.sample(d).grad(ik(),ik())}),TB=W(({envMap:e,mipInt:t,outputDirection:n,theta:r,axis:i,CUBEUV_TEXEL_WIDTH:a,CUBEUV_TEXEL_HEIGHT:o,CUBEUV_MAX_MIP:s})=>{let c=uj(r);return wB(e,n.mul(c).add(i.cross(n).mul(cj(r))).add(i.mul(i.dot(n).mul(c.oneMinus()))),t,a,o,s)}),EB=W(({n:e,latitudinal:t,poleAxis:n,outputDirection:r,weights:i,samples:a,dTheta:o,mipInt:s,envMap:c,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:d})=>{let f=J(lM(t,n,Vj(n,r))).toVar();$O(f.equal(J(0)),()=>{f.assign(J(r.z,0,r.x.negate()))}),f.assign(oj(f));let p=J().toVar();return p.addAssign(i.element(0).mul(TB({theta:0,axis:f,outputDirection:r,mipInt:s,envMap:c,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:d}))),RL({start:K(1),end:e},({i:e})=>{$O(e.greaterThanEqual(a),()=>{BL()});let t=G(o.mul(G(e))).toVar();p.addAssign(i.element(e).mul(TB({theta:t.mul(-1),axis:f,outputDirection:r,mipInt:s,envMap:c,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:d}))),p.addAssign(i.element(e).mul(TB({theta:t,axis:f,outputDirection:r,mipInt:s,envMap:c,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:d})))}),dk(p,1)}),DB=W(([e])=>{let t=q(e).toVar();return t.assign(t.shiftLeft(q(16)).bitOr(t.shiftRight(q(16)))),t.assign(t.bitAnd(q(1431655765)).shiftLeft(q(1)).bitOr(t.bitAnd(q(2863311530)).shiftRight(q(1)))),t.assign(t.bitAnd(q(858993459)).shiftLeft(q(2)).bitOr(t.bitAnd(q(3435973836)).shiftRight(q(2)))),t.assign(t.bitAnd(q(252645135)).shiftLeft(q(4)).bitOr(t.bitAnd(q(4042322160)).shiftRight(q(4)))),t.assign(t.bitAnd(q(16711935)).shiftLeft(q(8)).bitOr(t.bitAnd(q(4278255360)).shiftRight(q(8)))),G(t).mul(23283064365386963e-26)}),OB=W(([e,t])=>ik(G(e).div(G(t)),DB(e))),kB=W(([e,t,n])=>{let r=n.mul(n).toConst(),i=J(1,0,0).toConst(),a=Vj(t,i).toConst(),o=nj(e.x).toConst(),s=yA(2,3.14159265359).mul(e.y).toConst(),c=o.mul(uj(s)).toConst(),l=o.mul(cj(s)).toVar(),u=yA(.5,t.z.add(1)).toConst();l.assign(u.oneMinus().mul(nj(c.mul(c).oneMinus())).add(u.mul(l)));let d=i.mul(c).add(a.mul(l)).add(t.mul(nj(Fj(0,c.mul(c).add(l.mul(l)).oneMinus()))));return oj(J(r.mul(d.x),r.mul(d.y),Fj(0,d.z)))}),AB=W(({roughness:e,mipInt:t,envMap:n,N_immutable:r,GGX_SAMPLES:i,CUBEUV_TEXEL_WIDTH:a,CUBEUV_TEXEL_HEIGHT:o,CUBEUV_MAX_MIP:s})=>{let c=J(r).toVar(),l=J(0).toVar(),u=G(0).toVar();return $O(e.lessThan(.001),()=>{l.assign(wB(n,c,t,a,o,s))}).Else(()=>{let r=oj(Vj(lM(bj(c.z).lessThan(.999),J(0,0,1),J(1,0,0)),c)).toVar(),d=Vj(c,r).toVar();RL({start:q(0),end:i},({i:f})=>{let p=kB(OB(f,i),J(0,0,1),e),m=oj(r.mul(p.x).add(d.mul(p.y)).add(c.mul(p.z))),h=oj(m.mul(Bj(c,m).mul(2)).sub(c)),g=Fj(Bj(c,h),0);$O(g.greaterThan(0),()=>{let e=wB(n,h,t,a,o,s);l.addAssign(e.mul(g)),u.addAssign(g)})}),$O(u.greaterThan(0),()=>{l.assign(l.div(u))})}),dk(l,1)}),jB=4,MB=[.125,.215,.35,.446,.526,.582],NB=20,PB=512,FB=new vc(-1,1,1,-1,0,1),IB=new pc(90,1),LB=new Er,RB=null,zB=0,BB=0,VB=new R,HB=new WeakMap,UB=[3,1,5,0,4,2],WB=SB(ON(),DN(`faceIndex`)).normalize(),GB=J(WB.x,WB.y,WB.z),KB=class{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._blurMaterial=null,this._ggxMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._backgroundBox=null}get _hasInitialized(){return this._renderer.hasInitialized()}fromScene(e,t=0,n=.1,r=100,i={}){let{size:a=256,position:o=VB,renderTarget:s=null}=i;if(this._setSize(a),this._hasInitialized===!1)throw Error(`THREE.PMREMGenerator: .fromScene() called before the backend is initialized. Use "await renderer.init();" before using this method.`);RB=this._renderer.getRenderTarget(),zB=this._renderer.getActiveCubeFace(),BB=this._renderer.getActiveMipmapLevel();let c=s||this._allocateTarget(!0);return this._init(c),this._sceneToCubeUV(e,n,r,c,o),t>0&&this._blur(c,0,0,t),this._applyPMREM(c),this._cleanup(c),c}async fromSceneAsync(e,t=0,n=.1,r=100,i={}){return Wt(`PMREMGenerator: ".fromSceneAsync()" is deprecated. Use "await renderer.init()" instead.`),await this._renderer.init(),this.fromScene(e,t,n,r,i)}fromEquirectangular(e,t=null){if(this._hasInitialized===!1)throw Error(`THREE.PMREMGenerator: .fromEquirectangular() called before the backend is initialized. Use "await renderer.init();" before using this method.`);return this._fromTexture(e,t)}async fromEquirectangularAsync(e,t=null){return Wt(`PMREMGenerator: ".fromEquirectangularAsync()" is deprecated. Use "await renderer.init()" instead.`),await this._renderer.init(),this._fromTexture(e,t)}fromCubemap(e,t=null){if(this._hasInitialized===!1)throw Error(`THREE.PMREMGenerator: .fromCubemap() called before the backend is initialized. Use "await renderer.init();" before using this method.`);return this._fromTexture(e,t)}async fromCubemapAsync(e,t=null){return Wt(`PMREMGenerator: ".fromCubemapAsync()" is deprecated. Use "await renderer.init()" instead.`),await this._renderer.init(),this._fromTexture(e,t)}async compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=QB(),await this._compileMaterial(this._cubemapMaterial))}async compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=$B(),await this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSizeFromTexture(e){e.mapping===301||e.mapping===302?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4)}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=2**this._lodMax}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._ggxMaterial!==null&&this._ggxMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e2?l:0,l,l),c.render(e,a)}c.autoClear=l,e.background=p}_textureToCubeUV(e,t){let n=this._renderer,r=e.mapping===301||e.mapping===302;r?this._cubemapMaterial===null&&(this._cubemapMaterial=QB(e)):this._equirectMaterial===null&&(this._equirectMaterial=$B(e));let i=r?this._cubemapMaterial:this._equirectMaterial;i.fragmentNode.value=e;let a=this._lodMeshes[0];a.material=i;let o=this._cubeSize;this._setViewport(t,0,0,3*o,2*o),n.setRenderTarget(t),n.render(a,FB)}_applyPMREM(e){let t=this._renderer,n=t.autoClear;t.autoClear=!1;let r=this._lodMeshes.length;for(let t=1;td-jB?n-d+jB:0),m=4*(this._cubeSize-f);e.texture.frame=(e.texture.frame||0)+1,s.envMap.value=e.texture,s.roughness.value=u,s.mipInt.value=d-t,this._setViewport(i,p,m,3*f,2*f),r.setRenderTarget(i),r.render(o,FB),i.texture.frame=(i.texture.frame||0)+1,s.envMap.value=i.texture,s.roughness.value=0,s.mipInt.value=d-n,this._setViewport(e,p,m,3*f,2*f),r.setRenderTarget(e),r.render(o,FB)}_blur(e,t,n,r,i){let a=this._pingPongRenderTarget;this._halfBlur(e,a,t,n,r,`latitudinal`,i),this._halfBlur(a,e,n,n,r,`longitudinal`,i)}_halfBlur(e,t,n,r,i,a,o){let s=this._renderer,c=this._blurMaterial;a!==`latitudinal`&&a!==`longitudinal`&&I(`blur direction must be either latitudinal or longitudinal!`);let l=this._lodMeshes[r];l.material=c;let u=HB.get(c),d=this._sizeLods[n]-1,f=isFinite(i)?Math.PI/(2*d):2*Math.PI/(2*NB-1),p=i/f,m=isFinite(i)?1+Math.floor(3*p):NB;m>NB&&F(`sigmaRadians, ${i}, is too large and will clip, as it requested ${m} samples when the maximum is set to ${NB}`);let h=[],g=0;for(let e=0;e_-jB?r-_+jB:0),b=4*(this._cubeSize-v);this._setViewport(t,y,b,3*v,2*v),s.setRenderTarget(t),s.render(l,FB)}_setViewport(e,t,n,r,i){this._renderer.isWebGLRenderer?(e.viewport.set(t,e.height-i-n,r,i),e.scissor.set(t,e.height-i-n,r,i)):(e.viewport.set(t,n,r,i),e.scissor.set(t,n,r,i))}};function qB(e){let t=[],n=[],r=[],i=e,a=e-jB+1+MB.length;for(let o=0;oe-jB?s=MB[o-e+jB-1]:o===0&&(s=0),n.push(s);let c=1/(a-2),l=-c,u=1+c,d=[l,l,u,l,u,u,l,l,u,u,l,u],f=new Float32Array(108),p=new Float32Array(72),m=new Float32Array(36);for(let e=0;e<6;e++){let t=e%3*2/3-1,n=e>2?0:-1,r=[t,n,0,t+2/3,n,0,t+2/3,n+1,0,t,n,0,t+2/3,n+1,0,t,n+1,0],i=UB[e];f.set(r,18*i),p.set(d,12*i);let a=[i,i,i,i,i,i];m.set(a,6*i)}let h=new Di;h.setAttribute(`position`,new di(f,3)),h.setAttribute(`uv`,new di(p,2)),h.setAttribute(`faceIndex`,new di(m,1)),r.push(new ea(h,null)),i>jB&&i--}return{lodMeshes:r,sizeLods:t,sigmas:n}}function JB(e,t,n){let r=new Un(e,t,{magFilter:ne,minFilter:ne,generateMipmaps:!1,type:pe,format:xe,colorSpace:bt,depthBuffer:n});return r.texture.mapping=306,r.texture.name=`PMREM.cubeUv`,r.texture.isPMREMTexture=!0,r.scissorTest=!0,r}function YB(e){let t=new OR;return t.depthTest=!1,t.depthWrite=!1,t.blending=0,t.name=`PMREM_${e}`,t}function XB(e,t,n){let r=GN(Array(NB).fill(0)),i=lA(new R(0,1,0)),a=lA(0),o=G(NB),s=lA(0),c={n:o,latitudinal:s,weights:r,poleAxis:i,outputDirection:GB,dTheta:a,samples:lA(1),envMap:FN(),mipInt:lA(0),CUBEUV_TEXEL_WIDTH:G(1/t),CUBEUV_TEXEL_HEIGHT:G(1/n),CUBEUV_MAX_MIP:G(e)},l=YB(`blur`);return l.fragmentNode=EB({...c,latitudinal:s.equal(1)}),HB.set(l,c),l}function ZB(e,t,n){let r={envMap:FN(),roughness:lA(0),mipInt:lA(0),CUBEUV_TEXEL_WIDTH:G(1/t),CUBEUV_TEXEL_HEIGHT:G(1/n),CUBEUV_MAX_MIP:G(e)},i=YB(`ggx`);return i.fragmentNode=AB({...r,N_immutable:GB,GGX_SAMPLES:q(PB)}),HB.set(i,r),i}function QB(e){let t=YB(`cubemap`);return t.fragmentNode=jF(e,GB),t}function $B(e){let t=YB(`equirect`);return t.fragmentNode=FN(e,VR(GB),0),t}var eV=new WeakMap;function tV(e){let t=Math.log2(e)-2,n=1/e;return{texelWidth:1/(3*Math.max(2**t,112)),texelHeight:n,maxMip:t}}function nV(e,t,n){let r=rV(t),i=r.get(e);if((i===void 0?-1:i.pmremVersion)!==e.pmremVersion){let t=e.image;if(e.isCubeTexture)if(aV(t))i=n.fromCubemap(e,i);else return null;else if(oV(t))i=n.fromEquirectangular(e,i);else return null;if(i.pmremVersion=e.pmremVersion,r.has(e)===!1){let t=()=>{e.removeEventListener(`dispose`,t);let n=r.get(e);n!==void 0&&(n.dispose(),r.delete(e))};e.addEventListener(`dispose`,t)}r.set(e,i)}return i.texture}function rV(e){let t=eV.get(e);return t===void 0&&(t=new WeakMap,eV.set(e,t)),t}var iV=class extends $D{static get type(){return`PMREMNode`}constructor(e,t=null,n=null){super(`vec3`),this._value=e,this._pmrem=null,this.uvNode=t,this.levelNode=n,this._generator=null;let r=new Vn;r.isRenderTargetTexture=!0,this._texture=FN(r),this._width=lA(0),this._height=lA(0),this._maxMip=lA(0),this.updateBeforeType=VD.RENDER}set value(e){this._value=e,this._pmrem=null}get value(){return this._value}updateFromTexture(e){let t=tV(e.image.height);this._texture.value=e,this._width.value=t.texelWidth,this._height.value=t.texelHeight,this._maxMip.value=t.maxMip}updateBefore(e){let t=this._pmrem,n=t?t.pmremVersion:-1,r=this._value;n!==r.pmremVersion&&(t=r.isPMREMTexture===!0||r.mapping===306?r:nV(r,e.renderer,this._generator),t!==null&&(this._pmrem=t,this.updateFromTexture(t)))}setup(e){this._generator===null&&(this._generator=new KB(e.renderer)),this.updateBefore(e);let t=this.uvNode;t===null&&e.context.getUV&&(t=e.context.getUV(this,e)),t=this._pmrem.isRenderTargetTexture?wF.mul(J(t.x,t.y.negate(),t.z)):wF.mul(t);let n=this.levelNode;return n===null&&e.context.getTextureLevel&&(n=e.context.getTextureLevel(this)),CB(this._texture,t,n,this._width,this._height,this._maxMip)}dispose(){super.dispose(),this._generator!==null&&this._generator.dispose()}};function aV(e){if(e==null)return!1;let t=0;for(let n=0;n<6;n++)e[n]!==void 0&&t++;return t===6}function oV(e){return e==null?!1:e.height>0}var sV=qO(iV).setParameterLength(1,3),cV=new WeakMap,lV=class extends qL{static get type(){return`EnvironmentNode`}constructor(e=null){super(),this.envNode=e}setup(e){let{material:t}=e,n=this.envNode;if(n.isTextureNode||n.isMaterialReferenceNode){let r=n.isTextureNode?n.value:t[n.property],i=this._getPMREMNodeCache(e.renderer),a=i.get(r);a===void 0&&(a=sV(r),i.set(r,a)),n=a}let r=t.useAnisotropy===!0||t.anisotropy>0?dI:pF,i=n.context(uV(Ok,r)).mul(CF),a=n.context(dV(mF)).mul(Math.PI).mul(CF),o=sN(i),s=sN(a);e.context.radiance.addAssign(o),e.context.iblIrradiance.addAssign(s);let c=e.context.lightingModel.clearcoatRadiance;if(c){let e=sN(n.context(uV(jk,hF)).mul(CF));c.addAssign(e)}}_getPMREMNodeCache(e){let t=cV.get(e);return t===void 0&&(t=new WeakMap,cV.set(e,t)),t}},uV=(e,t)=>{let n=null;return{getUV:()=>(n===null&&(n=rF.negate().reflect(t),n=Gj(e).mix(n,t).normalize(),n=n.transformDirection(TP)),n),getTextureLevel:()=>e}},dV=e=>({getUV:()=>e,getTextureLevel:()=>G(1)}),fV=new Cs,pV=class extends OR{static get type(){return`MeshStandardNodeMaterial`}constructor(e){super(),this.isMeshStandardNodeMaterial=!0,this.lights=!0,this.emissiveNode=null,this.metalnessNode=null,this.roughnessNode=null,this.setDefaultValues(fV),this.setValues(e)}setupEnvironment(e){let t=super.setupEnvironment(e);return t===null&&e.environmentNode&&(t=e.environmentNode),t?new lV(t):null}setupLightingModel(){return new oB}setupSpecular(){let e=Zj(J(.04),Tk.rgb,kk);Vk.assign(J(.04)),Hk.assign(e),Uk.assign(1)}setupVariants(){let e=this.metalnessNode?G(this.metalnessNode):NI;kk.assign(e);let t=this.roughnessNode?G(this.roughnessNode):MI;t=pz({roughness:t}),Ok.assign(t),this.setupSpecular(),Ek.assign(Tk.rgb.mul(e.oneMinus()))}},mV=new ws,hV=class extends pV{static get type(){return`MeshPhysicalNodeMaterial`}constructor(e){super(),this.isMeshPhysicalNodeMaterial=!0,this.clearcoatNode=null,this.clearcoatRoughnessNode=null,this.clearcoatNormalNode=null,this.sheenNode=null,this.sheenRoughnessNode=null,this.iridescenceNode=null,this.iridescenceIORNode=null,this.iridescenceThicknessNode=null,this.specularIntensityNode=null,this.specularColorNode=null,this.iorNode=null,this.transmissionNode=null,this.thicknessNode=null,this.attenuationDistanceNode=null,this.attenuationColorNode=null,this.dispersionNode=null,this.anisotropyNode=null,this.setDefaultValues(mV),this.setValues(e)}get useClearcoat(){return this.clearcoat>0||this.clearcoatNode!==null}get useIridescence(){return this.iridescence>0||this.iridescenceNode!==null}get useSheen(){return this.sheen>0||this.sheenNode!==null}get useAnisotropy(){return this.anisotropy>0||this.anisotropyNode!==null}get useTransmission(){return this.transmission>0||this.transmissionNode!==null}get useDispersion(){return this.dispersion>0||this.dispersionNode!==null}setupSpecular(){let e=this.iorNode?G(this.iorNode):qI;Yk.assign(e),Vk.assign(Pj(Uj(Yk.sub(1).div(Yk.add(1))).mul(kI),J(1)).mul(OI)),Hk.assign(Zj(Vk,Tk.rgb,kk)),Uk.assign(Zj(OI,1,kk))}setupLightingModel(){return new oB(this.useClearcoat,this.useSheen,this.useIridescence,this.useAnisotropy,this.useTransmission,this.useDispersion)}setupVariants(e){if(super.setupVariants(e),this.useClearcoat){let e=this.clearcoatNode?G(this.clearcoatNode):FI,t=this.clearcoatRoughnessNode?G(this.clearcoatRoughnessNode):II;Ak.assign(e),jk.assign(pz({roughness:t}))}if(this.useSheen){let e=this.sheenNode?J(this.sheenNode):zI,t=this.sheenRoughnessNode?G(this.sheenRoughnessNode):BI;Mk.assign(e),Nk.assign(t)}if(this.useIridescence){let e=this.iridescenceNode?G(this.iridescenceNode):HI,t=this.iridescenceIORNode?G(this.iridescenceIORNode):UI,n=this.iridescenceThicknessNode?G(this.iridescenceThicknessNode):WI;Pk.assign(e),Fk.assign(t),Ik.assign(n)}if(this.useAnisotropy){let e=(this.anisotropyNode?ik(this.anisotropyNode):VI).toVar();Rk.assign(e.length()),$O(Rk.equal(0),()=>{e.assign(ik(1,0))}).Else(()=>{e.divAssign(ik(Rk)),Rk.assign(Rk.saturate())}),Lk.assign(Rk.pow2().mix(Ok.pow2(),1)),zk.assign(cI[0].mul(e.x).add(cI[1].mul(e.y))),Bk.assign(cI[1].mul(e.x).sub(cI[0].mul(e.y)))}if(this.useTransmission){let e=this.transmissionNode?G(this.transmissionNode):GI,t=this.thicknessNode?G(this.thicknessNode):KI,n=this.attenuationDistanceNode?G(this.attenuationDistanceNode):JI,r=this.attenuationColorNode?J(this.attenuationColorNode):YI;if(Xk.assign(e),Zk.assign(t),Qk.assign(n),$k.assign(r),this.useDispersion){let e=this.dispersionNode?G(this.dispersionNode):nL;eA.assign(e)}}}setupClearcoatNormal(){return this.clearcoatNormalNode?J(this.clearcoatNormalNode):LI}setup(e){e.context.setupClearcoatNormal=()=>CM(this.setupClearcoatNormal(e),`NORMAL`,`vec3`),super.setup(e)}},gV=W(({normal:e,lightDirection:t,builder:n})=>{let r=ik(e.dot(t).mul(.5).add(.5),0);if(n.material.gradientMap)return J(RF(`gradientMap`,`texture`).context({getUV:()=>r}).r);{let e=r.fwidth().mul(.5);return Zj(J(.7),J(1),tM(G(.7).sub(e.x),G(.7).add(e.x),r.x))}}),_V=class extends QR{direct({lightDirection:e,lightColor:t,reflectedLight:n},r){let i=gV({normal:cF,lightDirection:e,builder:r}).mul(t);n.directDiffuse.addAssign(i.mul(rz({diffuseColor:Tk.rgb})))}indirect(e){let{ambientOcclusion:t,irradiance:n,reflectedLight:r}=e.context;r.indirectDiffuse.addAssign(n.mul(rz({diffuseColor:Tk}))),r.indirectDiffuse.mulAssign(t)}},vV=new Es,yV=class extends OR{static get type(){return`MeshToonNodeMaterial`}constructor(e){super(),this.isMeshToonNodeMaterial=!0,this.lights=!0,this.setDefaultValues(vV),this.setValues(e)}setupLightingModel(){return new _V}},bV=W(()=>{let e=J(rF.z,0,rF.x.negate()).normalize(),t=rF.cross(e);return ik(e.dot(pF),t.dot(pF)).mul(.495).add(.5)}).once([`NORMAL`,`VERTEX`])().toVar(`matcapUV`),xV=new js,SV=class extends OR{static get type(){return`MeshMatcapNodeMaterial`}constructor(e){super(),this.isMeshMatcapNodeMaterial=!0,this.setDefaultValues(xV),this.setValues(e)}setupVariants(e){let t=bV,n;n=e.material.matcap?RF(`matcap`,`texture`).context({getUV:()=>t}):J(Zj(.2,.8,t.y)),Tk.rgb.mulAssign(n.rgb)}},CV=qO(class extends $D{static get type(){return`RotateNode`}constructor(e,t){super(),this.positionNode=e,this.rotationNode=t}generateNodeType(e){return this.positionNode.getNodeType(e)}setup(e){let{rotationNode:t,positionNode:n}=this;if(this.getNodeType(e)===`vec2`){let e=t.cos(),r=t.sin();return hk(e,r,r.negate(),e).mul(n)}else{let e=t,r=_k(dk(1,0,0,0),dk(0,uj(e.x),cj(e.x).negate(),0),dk(0,cj(e.x),uj(e.x),0),dk(0,0,0,1)),i=_k(dk(uj(e.y),0,cj(e.y),0),dk(0,1,0,0),dk(cj(e.y).negate(),0,uj(e.y),0),dk(0,0,0,1)),a=_k(dk(uj(e.z),cj(e.z).negate(),0,0),dk(cj(e.z),uj(e.z),0,0),dk(0,0,1,0),dk(0,0,0,1));return r.mul(i).mul(a).mul(dk(n,1)).xyz}}}).setParameterLength(2),wV=new Ni,TV=class extends OR{static get type(){return`SpriteNodeMaterial`}constructor(e){super(),this.isSpriteNodeMaterial=!0,this._useSizeAttenuation=!0,this.positionNode=null,this.rotationNode=null,this.scaleNode=null,this.transparent=!0,this.setDefaultValues(wV),this.setValues(e)}setupPositionView(e){let{object:t,camera:n}=e,{positionNode:r,rotationNode:i,scaleNode:a,sizeAttenuation:o}=this,s=KP.mul(J(r||0)),c=ik(zP[0].xyz.length(),zP[1].xyz.length());a!==null&&(c=c.mul(ik(a))),n.isPerspectiveCamera&&o===!1&&(c=c.mul(s.z.negate()));let l=ZP.xy;if(t.center&&t.center.isVector2===!0){let e=IM(`center`,`vec2`,t);l=l.sub(e.sub(.5))}l=l.mul(c);let u=G(i||RI),d=CV(l,u);return dk(s.xy.add(d),s.zw)}get sizeAttenuation(){return this._useSizeAttenuation}set sizeAttenuation(e){this._useSizeAttenuation!==e&&(this._useSizeAttenuation=e,this.needsUpdate=!0)}},EV=new Oa,DV=new L,OV=class extends TV{static get type(){return`PointsNodeMaterial`}constructor(e){super(),this.sizeNode=null,this.isPointsNodeMaterial=!0,this.setDefaultValues(EV),this.setValues(e)}setupPositionView(){let{positionNode:e}=this;return KP.mul(J(e||QP)).xyz}setupVertexSprite(e){let{material:t,camera:n}=e,{rotationNode:r,scaleNode:i,sizeNode:a,sizeAttenuation:o}=this,s=super.setupVertex(e);if(t.isNodeMaterial!==!0)return s;let c=a===null?tL:ik(a);c=c.mul(XN),n.isPerspectiveCamera&&o===!0&&(c=c.mul(kV.div(nF.z.negate()))),i&&i.isNode&&(c=c.mul(ik(i)));let l=ZP.xy;if(r&&r.isNode){let e=G(r);l=CV(l,e)}return l=l.mul(c),l=l.div(tP.div(2)),l=l.mul(s.w),s=s.add(dk(l,0,0)),s}setupVertex(e){return e.object.isPoints?super.setupVertex(e):this.setupVertexSprite(e)}get alphaToCoverage(){return this._useAlphaToCoverage}set alphaToCoverage(e){this._useAlphaToCoverage!==e&&(this._useAlphaToCoverage=e,this.needsUpdate=!0)}},kV=lA(1).onFrameUpdate(function({renderer:e}){this.value=.5*e.getSize(DV).y}),AV=class extends QR{constructor(){super(),this.shadowNode=G(1).toVar(`shadowMask`)}direct({lightNode:e}){e.shadowNode!==null&&this.shadowNode.mulAssign(e.shadowNode)}finish({context:e}){Tk.a.mulAssign(this.shadowNode.oneMinus()),e.outgoingLight.rgb.assign(Tk.rgb)}},jV=new fs,MV=class extends OR{static get type(){return`ShadowNodeMaterial`}constructor(e){super(),this.isShadowNodeMaterial=!0,this.lights=!0,this.transparent=!0,this.setDefaultValues(jV),this.setValues(e)}setupLightingModel(){return new AV}};Ck(`vec3`),Ck(`vec3`),Ck(`vec3`);var NV=class{constructor(e,t,n){this.renderer=e,this.nodes=t,this.info=n,this._context=typeof self<`u`?self:null,this._animationLoop=null,this._requestId=null}start(){let e=(t,n)=>{this._requestId=this._context.requestAnimationFrame(e),this.info.autoReset===!0&&this.info.reset(),this.nodes.nodeFrame.update(),this.info.frame=this.nodes.nodeFrame.frameId,this.renderer._inspector.begin(),this._animationLoop!==null&&this._animationLoop(t,n),this.renderer._inspector.finish()};e()}stop(){this._context!==null&&this._context.cancelAnimationFrame(this._requestId),this._requestId=null}getAnimationLoop(){return this._animationLoop}setAnimationLoop(e){this._animationLoop=e}getContext(){return this._context}setContext(e){this._context=e}dispose(){this.stop()}},PV=class{constructor(){this.weakMaps={}}_getWeakMap(e){let t=e.length,n=this.weakMaps[t];return n===void 0&&(n=new WeakMap,this.weakMaps[t]=n),n}get(e){let t=this._getWeakMap(e);for(let n=0;n{this.dispose()},this.onGeometryDispose=()=>{this.attributes=null,this.attributesId=null},this.material.addEventListener(`dispose`,this.onMaterialDispose),this.geometry.addEventListener(`dispose`,this.onGeometryDispose),this._sourceMaterial!==null&&this._sourceMaterial.addEventListener(`dispose`,this.onMaterialDispose)}updateClipping(e){this.clippingContext=e}get clippingNeedsUpdate(){return this.clippingContext===null||this.clippingContext.cacheKey===this.clippingContextCacheKey?!1:(this.clippingContextCacheKey=this.clippingContext.cacheKey,!0)}get hardwareClippingPlanes(){return this.getNodeBuilderState().hardwareClipping===!0?this.clippingContext.unionClippingCount:0}getNodeBuilderState(){return this._nodeBuilderState||=this._nodes.getForRender(this)}getMonitor(){return this._monitor||=this.getNodeBuilderState().observer}getBindings(){return this._bindings||=this.getNodeBuilderState().createBindings()}getBindingGroup(e){for(let t of this.getBindings())if(t.name===e)return t}getIndex(){return this._geometries.getIndex(this)}getIndirect(){return this._geometries.getIndirect(this)}getIndirectOffset(){return this._geometries.getIndirectOffset(this)}getChainArray(){return[this.object,this.material,this.context,this.lightsNode]}setGeometry(e){this.geometry=e,this.attributes=null,this.attributesId=null}getAttributes(){if(this.attributes!==null)return this.attributes;let e=this.getNodeBuilderState().nodeAttributes,t=this.geometry,n=[],r=new Set,i={};for(let a of e){let e;if(a.node&&a.node.attribute?e=a.node.attribute:(e=t.getAttribute(a.name),e!==void 0&&(e.isInterleavedBufferAttribute?i[a.name]=e.data.uuid:i[a.name]=e.id)),e===void 0)continue;n.push(e);let o=e.isInterleavedBufferAttribute?e.data:e;r.add(o)}return this.attributes=n,this.attributesId=i,this.vertexBuffers=Array.from(r.values()),n}getVertexBuffers(){return this.vertexBuffers===null&&this.getAttributes(),this.vertexBuffers}getDrawParameters(){let{object:e,material:t,geometry:n,group:r,drawRange:i}=this,a=this.drawParams||={vertexCount:0,firstVertex:0,instanceCount:0,firstInstance:0},o=this.getIndex(),s=o!==null,c=1;if(n.isInstancedBufferGeometry===!0?c=n.instanceCount:e.count!==void 0&&(c=Math.max(0,e.count)),c===0)return null;if(a.instanceCount=c,e.isBatchedMesh===!0)return a;let l=1;t.wireframe===!0&&!e.isPoints&&!e.isLineSegments&&!e.isLine&&!e.isLineLoop&&(l=2);let u=i.start*l,d=(i.start+i.count)*l;r!==null&&(u=Math.max(u,r.start*l),d=Math.min(d,(r.start+r.count)*l));let f=n.attributes.position,p=1/0;s?p=o.count:f!=null&&(p=f.count),u=Math.max(u,0),d=Math.min(d,p);let m=d-u;return m<0||m===1/0?null:(a.vertexCount=m,a.firstVertex=u,a)}getGeometryCacheKey(){let{geometry:e}=this,t=``;for(let n of Object.keys(e.attributes).sort()){let r=e.attributes[n];t+=n+`,`,r.data&&(t+=r.data.stride+`,`),r.offset&&(t+=r.offset+`,`),r.itemSize&&(t+=r.itemSize+`,`),r.normalized&&(t+=`n,`)}for(let n of Object.keys(e.morphAttributes).sort()){let r=e.morphAttributes[n];t+=`morph-`+n+`,`;for(let e=0,n=r.length;e1)&&(r+=e.uuid+`,`),r+=this.context.id+`,`,r+=e.receiveShadow+`,`,TD(r)}get needsGeometryUpdate(){if(this.geometry.id!==this.object.geometry.id)return!0;if(this.attributes!==null){let e=this.attributesId;for(let t in e){let n=this.geometry.getAttribute(t);if(n===void 0)return!0;let r=n.isInterleavedBufferAttribute?n.data.uuid:n.id;if(e[t]!==r)return!0}}return!1}get needsUpdate(){return this.initialNodesCacheKey!==this.getDynamicCacheKey()||this.clippingNeedsUpdate}getDynamicCacheKey(){let e=0;return this.material.isShadowPassMaterial!==!0&&(e=this._nodes.getCacheKey(this.scene,this.lightsNode)),this.camera.isArrayCamera&&(e=DD(e,this.camera.cameras.length)),this.object.receiveShadow&&(e=DD(e,1)),e=DD(e,this.renderer.contextNode.id,this.renderer.contextNode.version),e}getCacheKey(){return this.getMaterialCacheKey()+this.getDynamicCacheKey()}dispose(){this.material.removeEventListener(`dispose`,this.onMaterialDispose),this.geometry.removeEventListener(`dispose`,this.onGeometryDispose),this._sourceMaterial!==null&&this._sourceMaterial.removeEventListener(`dispose`,this.onMaterialDispose),this.onDispose()}},zV=[],BV=class{constructor(e,t,n,r,i,a){this.renderer=e,this.nodes=t,this.geometries=n,this.pipelines=r,this.bindings=i,this.info=a,this.chainMaps={}}get(e,t,n,r,i,a,o,s){let c=this.getChainMap(s);zV[0]=e,zV[1]=t,zV[2]=a,zV[3]=i;let l=c.get(zV);return l===void 0?(l=this.createRenderObject(this.nodes,this.geometries,this.renderer,e,t,n,r,i,a,o,s),c.set(zV,l)):(l.camera=r,l.updateClipping(o),l.needsGeometryUpdate&&l.setGeometry(e.geometry),(l.version!==t.version||l.needsUpdate)&&(l.initialCacheKey===l.getCacheKey()?l.version=t.version:(l.dispose(),l=this.get(e,t,n,r,i,a,o,s)))),zV[0]=null,zV[1]=null,zV[2]=null,zV[3]=null,l}getChainMap(e=`default`){return this.chainMaps[e]||(this.chainMaps[e]=new PV)}dispose(){this.chainMaps={}}createRenderObject(e,t,n,r,i,a,o,s,c,l,u){let d=this.getChainMap(u),f=new RV(e,t,n,r,i,a,o,s,c,l);return f.onDispose=()=>{this.pipelines.delete(f),this.bindings.deleteForRender(f),this.nodes.delete(f),d.delete(f.getChainArray())},f}},VV=class{constructor(){this.data=new WeakMap}get(e){let t=this.data.get(e);return t===void 0&&(t={},this.data.set(e,t)),t}delete(e){let t=null;return this.data.has(e)&&(t=this.data.get(e),this.data.delete(e)),t}has(e){return this.data.has(e)}dispose(){this.data=new WeakMap}},HV={VERTEX:1,INDEX:2,STORAGE:3,INDIRECT:4},UV=16,WV=211,GV=212,KV=class extends VV{constructor(e,t){super(),this.backend=e,this.info=t}delete(e){let t=super.delete(e);return t!==null&&(this.backend.destroyAttribute(e),this.info.destroyAttribute(e)),t}update(e,t){let n=this.get(e);if(n.version===void 0)t===HV.VERTEX?(this.backend.createAttribute(e),this.info.createAttribute(e)):t===HV.INDEX?(this.backend.createIndexAttribute(e),this.info.createIndexAttribute(e)):t===HV.STORAGE?(this.backend.createStorageAttribute(e),this.info.createStorageAttribute(e)):t===HV.INDIRECT&&(this.backend.createIndirectStorageAttribute(e),this.info.createIndirectStorageAttribute(e)),n.version=this._getBufferAttribute(e).version;else{let t=this._getBufferAttribute(e);(n.version=65535?pi:fi)(t,1);return i.version=qV(e),i.__id=JV(e),i}var XV=class extends VV{constructor(e,t){super(),this.attributes=e,this.info=t,this.wireframes=new WeakMap,this.attributeCall=new WeakMap,this._geometryDisposeListeners=new Map}has(e){let t=e.geometry;return super.has(t)&&this.get(t).initialized===!0}updateForRender(e){this.has(e)===!1&&this.initGeometry(e),this.updateAttributes(e)}initGeometry(e){let t=e.geometry,n=this.get(t);n.initialized=!0,this.info.memory.geometries++;let r=()=>{this.info.memory.geometries--;let n=t.index,i=e.getAttributes();n!==null&&this.attributes.delete(n);for(let e of i)this.attributes.delete(e);let a=this.wireframes.get(t);a!==void 0&&this.attributes.delete(a),t.removeEventListener(`dispose`,r),this._geometryDisposeListeners.delete(t)};t.addEventListener(`dispose`,r),this._geometryDisposeListeners.set(t,r)}updateAttributes(e){let t=e.getAttributes();for(let e of t)e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute?this.updateAttribute(e,HV.STORAGE):this.updateAttribute(e,HV.VERTEX);let n=this.getIndex(e);n!==null&&this.updateAttribute(n,HV.INDEX);let r=e.geometry.indirect;r!==null&&this.updateAttribute(r,HV.INDIRECT)}updateAttribute(e,t){let n=this.info.render.calls;e.isInterleavedBufferAttribute?this.attributeCall.get(e)===void 0?(this.attributes.update(e,t),this.attributeCall.set(e,n)):this.attributeCall.get(e.data)!==n&&(this.attributes.update(e,t),this.attributeCall.set(e.data,n),this.attributeCall.set(e,n)):this.attributeCall.get(e)!==n&&(this.attributes.update(e,t),this.attributeCall.set(e,n))}getIndirect(e){return e.geometry.indirect}getIndirectOffset(e){return e.geometry.indirectOffset}getIndex(e){let{geometry:t,material:n}=e,r=t.index;if(n.wireframe===!0){let e=this.wireframes,n=e.get(t);n===void 0?(n=YV(t),e.set(t,n)):(n.version!==qV(t)||n.__id!==JV(t))&&(this.attributes.delete(n),n=YV(t),e.set(t,n)),r=n}return r}dispose(){for(let[e,t]of this._geometryDisposeListeners.entries())e.removeEventListener(`dispose`,t);this._geometryDisposeListeners.clear()}},ZV=class{constructor(){this.autoReset=!0,this.frame=0,this.calls=0,this.render={calls:0,frameCalls:0,drawCalls:0,triangles:0,points:0,lines:0,timestamp:0},this.compute={calls:0,frameCalls:0,timestamp:0},this.memory={attributes:0,attributesSize:0,geometries:0,indexAttributes:0,indexAttributesSize:0,indirectStorageAttributes:0,indirectStorageAttributesSize:0,programs:0,programsSize:0,readbackBuffers:0,readbackBuffersSize:0,renderTargets:0,storageAttributes:0,storageAttributesSize:0,textures:0,texturesSize:0,uniformBuffers:0,uniformBuffersSize:0,total:0},this.memoryMap=new Map}update(e,t,n){this.render.drawCalls++,e.isMesh||e.isSprite?this.render.triangles+=n*(t/3):e.isPoints?this.render.points+=n*t:e.isLineSegments?this.render.lines+=n*(t/2):e.isLine?this.render.lines+=n*(t-1):I(`WebGPUInfo: Unknown object type.`)}reset(){this.render.drawCalls=0,this.render.frameCalls=0,this.compute.frameCalls=0,this.render.triangles=0,this.render.points=0,this.render.lines=0}dispose(){for(let e in this.reset(),this.calls=0,this.render.calls=0,this.compute.calls=0,this.render.timestamp=0,this.compute.timestamp=0,this.memory)this.memory[e]=0;this.memoryMap.clear()}createTexture(e){let t=this._getTextureMemorySize(e);this.memoryMap.set(e,t),this.memory.textures++,this.memory.total+=t,this.memory.texturesSize+=t}destroyTexture(e){let t=this.memoryMap.get(e)||0;this.memoryMap.delete(e),this.memory.textures--,this.memory.total-=t,this.memory.texturesSize-=t}_createAttribute(e,t){let n=this._getAttributeMemorySize(e);this.memoryMap.set(e,{size:n,type:t}),this.memory[t]++,this.memory.total+=n,this.memory[t+`Size`]+=n}createAttribute(e){this._createAttribute(e,`attributes`)}createIndexAttribute(e){this._createAttribute(e,`indexAttributes`)}createStorageAttribute(e){this._createAttribute(e,`storageAttributes`)}createIndirectStorageAttribute(e){this._createAttribute(e,`indirectStorageAttributes`)}destroyAttribute(e){let t=this.memoryMap.get(e);t&&(this.memoryMap.delete(e),this.memory[t.type]--,this.memory.total-=t.size,this.memory[t.type+`Size`]-=t.size)}createReadbackBuffer(e){let t=e.maxByteLength;this.memoryMap.set(e,{size:t,type:`readbackBuffers`}),this.memory.readbackBuffers++,this.memory.total+=t,this.memory.readbackBuffersSize+=t}destroyReadbackBuffer(e){let{size:t}=this.memoryMap.get(e);this.memoryMap.delete(e),this.memory.readbackBuffers--,this.memory.total-=t,this.memory.readbackBuffersSize-=t}createUniformBuffer(e){let t=e.byteLength;this.memoryMap.set(e,{size:t,type:`uniformBuffers`}),this.memory.uniformBuffers++,this.memory.total+=t,this.memory.uniformBuffersSize+=t}destroyUniformBuffer(e){let t=this.memoryMap.get(e);t&&(this.memoryMap.delete(e),this.memory.uniformBuffers--,this.memory.total-=t.size,this.memory.uniformBuffersSize-=t.size)}createProgram(e){let t=e.code.length;this.memoryMap.set(e,t),this.memory.programs++,this.memory.total+=t,this.memory.programsSize+=t}destroyProgram(e){let t=this.memoryMap.get(e)||0;this.memoryMap.delete(e),this.memory.programs--,this.memory.total-=t,this.memory.programsSize-=t}_getTextureMemorySize(e){if(e.isCompressedTexture)return 1;let t=1;e.type===1010||e.type===1009?t=1:e.type===1011||e.type===1012||e.type===1016?t=2:(e.type===1013||e.type===1014||e.type===1015)&&(t=4);let n=4;e.format===1021||e.format===1028||e.format===1029||e.format===1026||e.format===1027?n=1:e.format===1030||e.format===1031?n=2:(e.format===1022||e.format===1032)&&(n=3);let r=t*n;e.type===1017||e.type===1018?r=2:(e.type===1020||e.type===35902||e.type===35899)&&(r=4);let i=e.width||1,a=e.height||1,o=e.isCubeTexture?6:e.depth||1,s=i*a*o*r,c=e.mipmaps;if(c&&c.length>0){let e=0;for(let t=0;t>t),c=n.height||Math.max(1,a>>t);e+=s*c*o*r}}s+=e}else e.generateMipmaps&&(s*=1.333);return Math.round(s)}_getAttributeMemorySize(e){return e.isInterleavedBufferAttribute&&(e=e.data),e.array?e.array.byteLength:e.count&&e.itemSize?e.count*e.itemSize*4:0}},QV=class{constructor(e){this.cacheKey=e,this.usedTimes=0}},$V=class extends QV{constructor(e,t,n){super(e),this.vertexProgram=t,this.fragmentProgram=n}},eH=class extends QV{constructor(e,t){super(e),this.computeProgram=t,this.isComputePipeline=!0}},tH=0,nH=class{constructor(e,t,n,r=null,i=null){this.id=tH++,this.code=e,this.stage=t,this.name=n,this.transforms=r,this.attributes=i,this.usedTimes=0}},rH=class extends VV{constructor(e,t,n){super(),this.backend=e,this.nodes=t,this.info=n,this.bindings=null,this.caches=new Map,this.programs={vertex:new Map,fragment:new Map,compute:new Map}}getForCompute(e,t){let{backend:n}=this,r=this.get(e);if(this._needsComputeUpdate(e)){let i=r.pipeline;i&&(i.usedTimes--,i.computeProgram.usedTimes--);let a=this.nodes.getForCompute(e),o=this.programs.compute.get(a.computeShader);o===void 0&&(i&&i.computeProgram.usedTimes===0&&this._releaseProgram(i.computeProgram),o=new nH(a.computeShader,`compute`,e.name,a.transforms,a.nodeAttributes),this.programs.compute.set(a.computeShader,o),n.createProgram(o),this.info.createProgram(o));let s=this._getComputeCacheKey(e,o),c=this.caches.get(s);c===void 0&&(i&&i.usedTimes===0&&this._releasePipeline(i),c=this._getComputePipeline(e,o,s,t)),c.usedTimes++,o.usedTimes++,r.version=e.version,r.pipeline=c}return r.pipeline}getForRender(e,t=null){let{backend:n}=this,r=this.get(e);if(this._needsRenderUpdate(e)){let i=r.pipeline;i&&(i.usedTimes--,i.vertexProgram.usedTimes--,i.fragmentProgram.usedTimes--);let a=e.getNodeBuilderState(),o=e.material?e.material.name:``,s=this.programs.vertex.get(a.vertexShader);s===void 0&&(i&&i.vertexProgram.usedTimes===0&&this._releaseProgram(i.vertexProgram),s=new nH(a.vertexShader,`vertex`,o),this.programs.vertex.set(a.vertexShader,s),n.createProgram(s),this.info.createProgram(s));let c=this.programs.fragment.get(a.fragmentShader);c===void 0&&(i&&i.fragmentProgram.usedTimes===0&&this._releaseProgram(i.fragmentProgram),c=new nH(a.fragmentShader,`fragment`,o),this.programs.fragment.set(a.fragmentShader,c),n.createProgram(c),this.info.createProgram(c));let l=this._getRenderCacheKey(e,s,c),u=this.caches.get(l);u===void 0?(i&&i.usedTimes===0&&this._releasePipeline(i),u=this._getRenderPipeline(e,s,c,l,t)):e.pipeline=u,u.usedTimes++,s.usedTimes++,c.usedTimes++,r.pipeline=u}return r.pipeline}isReady(e){let t=this.get(e).pipeline;if(t===void 0)return!1;let n=this.backend.get(t);return n.pipeline!==void 0&&n.pipeline!==null}delete(e){let t=this.get(e).pipeline;return t&&(t.usedTimes--,t.usedTimes===0&&this._releasePipeline(t),t.isComputePipeline?(t.computeProgram.usedTimes--,t.computeProgram.usedTimes===0&&this._releaseProgram(t.computeProgram)):(t.fragmentProgram.usedTimes--,t.vertexProgram.usedTimes--,t.vertexProgram.usedTimes===0&&this._releaseProgram(t.vertexProgram),t.fragmentProgram.usedTimes===0&&this._releaseProgram(t.fragmentProgram))),super.delete(e)}dispose(){super.dispose(),this.caches=new Map,this.programs={vertex:new Map,fragment:new Map,compute:new Map}}updateForRender(e){this.getForRender(e)}_getComputePipeline(e,t,n,r){n||=this._getComputeCacheKey(e,t);let i=this.caches.get(n);return i===void 0&&(i=new eH(n,t),this.caches.set(n,i),this.backend.createComputePipeline(i,r)),i}_getRenderPipeline(e,t,n,r,i){r||=this._getRenderCacheKey(e,t,n);let a=this.caches.get(r);return a===void 0&&(a=new $V(r,t,n),this.caches.set(r,a),e.pipeline=a,this.backend.createRenderPipeline(e,i)),a}_getComputeCacheKey(e,t){return e.id+`,`+t.id}_getRenderCacheKey(e,t,n){return t.id+`,`+n.id+`,`+this.backend.getRenderCacheKey(e)}_releasePipeline(e){this.caches.delete(e.cacheKey)}_releaseProgram(e){let t=e.code,n=e.stage;this.programs[n].delete(t),this.info.destroyProgram(e)}_needsComputeUpdate(e){let t=this.get(e);return t.pipeline===void 0||t.version!==e.version}_needsRenderUpdate(e){return this.get(e).pipeline===void 0||this.backend.needsRenderUpdate(e)}},iH=class extends VV{constructor(e,t,n,r,i,a){super(),this.backend=e,this.textures=n,this.pipelines=i,this.attributes=r,this.nodes=t,this.info=a,this.pipelines.bindings=this}getForRender(e){let t=e.getBindings(),n=this.get(e);return n.initialized!==!0&&(this._createBindings(t),n.initialized=!0),t}getForCompute(e){let t=this.nodes.getForCompute(e).bindings,n=this.get(e);return(n.initialized!==!0||n.bindings!==t)&&(n.bindings!==void 0&&this._destroyBindings(n.bindings),this._createBindings(t),n.initialized=!0,n.bindings=t),t}updateForCompute(e){this._updateBindings(this.getForCompute(e))}updateForRender(e){this._updateBindings(this.getForRender(e))}deleteForCompute(e){let t=this.get(e).bindings||this.nodes.getForCompute(e).bindings;this._destroyBindings(t),this.delete(e)}deleteForRender(e){let t=e.getBindings();this._destroyBindings(t),this.delete(e)}_createBindings(e){for(let t of e){let n=this.get(t);if(n.bindGroup===void 0){for(let e of t.bindings)if(e.isUniformBuffer)this.backend.createUniformBuffer(e),this.info.createUniformBuffer(e);else if(e.isSampledTexture)this.textures.updateTexture(e.texture);else if(e.isSampler)this.textures.updateSampler(e);else if(e.isStorageBuffer){let t=e.attribute,n=t.isIndirectStorageBufferAttribute?HV.INDIRECT:HV.STORAGE;this.attributes.update(t,n)}this.backend.createBindings(t,e,0),n.bindGroup=t,n.usedTimes=1}else n.usedTimes++}}_destroyBindings(e){for(let t of e){let e=this.get(t);if(e.usedTimes--,e.usedTimes===0){for(let e of t.bindings)e.isUniformBuffer?(this.backend.destroyUniformBuffer(e),this.info.destroyUniformBuffer(e),e.release()):e.isSampler&&(e.isSampledTexture!==!0&&this.backend.destroySampler(e),e.release());this.backend.deleteBindGroupData(t),this.delete(t)}}}_updateBindings(e){for(let t of e)this._update(t,e)}_update(e,t){let{backend:n}=this,r=!1,i=!0,a=0,o=0;for(let t of e.bindings)if(this.nodes.updateGroup(t)!==!1){if(t.isStorageBuffer){let e=t.attribute,i=e.isIndirectStorageBufferAttribute?HV.INDIRECT:HV.STORAGE,a=n.get(t);this.attributes.update(e,i),a.attribute!==e&&(a.attribute=e,r=!0)}if(t.isUniformBuffer)t.update()&&n.updateBinding(t);else if(t.isSampledTexture){let s=t.update(),c=t.texture,l=this.textures.get(c);if(s&&(this.textures.updateTexture(c),t.generation!==l.generation&&(t.generation=l.generation,r=!0),l.bindGroups.add(e)),n.get(c).externalTexture!==void 0||l.isDefaultTexture?i=!1:(a=a*10+c.id,o+=c.version),c.isStorageTexture===!0&&c.mipmapsAutoUpdate===!0){let e=this.get(c);t.store===!0?e.needsMipmap=!0:this.textures.needsMipmaps(c)&&e.needsMipmap===!0&&(this.backend.generateMipmaps(c),e.needsMipmap=!1)}}else if(t.isSampler&&t.update()){let e=this.textures.updateSampler(t);t.samplerKey!==e&&(t.samplerKey=e,r=!0)}t.isBuffer&&t.updateRanges.length>0&&t.clearUpdateRanges()}r===!0&&this.backend.updateBindings(e,t,i?a:0,o)}},aH=Object.freeze([]);function oH(e,t){return e.groupOrder===t.groupOrder?e.renderOrder===t.renderOrder?e.z===t.z?e.id-t.id:e.z-t.z:e.renderOrder-t.renderOrder:e.groupOrder-t.groupOrder}function sH(e,t){return e.groupOrder===t.groupOrder?e.renderOrder===t.renderOrder?e.z===t.z?e.id-t.id:t.z-e.z:e.renderOrder-t.renderOrder:e.groupOrder-t.groupOrder}function cH(e){return(e.transmission>0||e.transmissionNode&&e.transmissionNode.isNode)&&e.side===2&&e.forceSinglePass===!1}var lH=class{constructor(e,t,n){this.renderItems=[],this.renderItemsIndex=0,this.opaque=[],this.transparentDoublePass=[],this.transparent=[],this.bundles=[],this.lighting=e,this.lightsNode=e.getNode(t),this.lightsArray=[],this.scene=t,this.camera=n,this.occlusionQueryCount=0,this._lastOcclusionObject=null}begin(){return this.renderItemsIndex=0,this.opaque.length=0,this.transparentDoublePass.length=0,this.transparent.length=0,this.bundles.length=0,this.lightsArray.length=0,this.occlusionQueryCount=0,this}getNextRenderItem(e,t,n,r,i,a,o){let s=this.renderItems[this.renderItemsIndex];return s===void 0?(s={id:e.id,object:e,geometry:t,material:n,groupOrder:r,renderOrder:e.renderOrder,z:i,group:a,clippingContext:o},this.renderItems[this.renderItemsIndex]=s):(s.id=e.id,s.object=e,s.geometry=t,s.material=n,s.groupOrder=r,s.renderOrder=e.renderOrder,s.z=i,s.group=a,s.clippingContext=o),this.renderItemsIndex++,s}push(e,t,n,r,i,a,o){let s=this.getNextRenderItem(e,t,n,r,i,a,o);e.occlusionTest===!0&&this._lastOcclusionObject!==e&&(this.occlusionQueryCount++,this._lastOcclusionObject=e),n.transparent===!0||n.transmission>0||n.transmissionNode&&n.transmissionNode.isNode||n.backdropNode&&n.backdropNode.isNode?(cH(n)&&this.transparentDoublePass.push(s),this.transparent.push(s)):this.opaque.push(s)}unshift(e,t,n,r,i,a,o){let s=this.getNextRenderItem(e,t,n,r,i,a,o);n.transparent===!0||n.transmission>0||n.transmissionNode&&n.transmissionNode.isNode||n.backdropNode&&n.backdropNode.isNode?(cH(n)&&this.transparentDoublePass.unshift(s),this.transparent.unshift(s)):this.opaque.unshift(s)}pushBundle(e){this.bundles.push(e)}pushLight(e){this.lightsArray.push(e)}sort(e,t,n){this.opaque.length>1&&this.opaque.sort(e||oH),this.transparentDoublePass.length>1&&this.transparentDoublePass.sort(t||sH),this.transparent.length>1&&this.transparent.sort(t||sH),n&&(this.opaque.reverse(),this.transparentDoublePass.reverse(),this.transparent.reverse())}finish(){this.lightsNode.setLights(this.lighting.enabled?this.lightsArray:aH);for(let e=this.renderItemsIndex,t=this.renderItems.length;e>t,c=o.height>>t,l=e.depthTexture||i[t],u=e.depthBuffer===!0||e.stencilBuffer===!0,d=!1,f=l!==void 0&&l.image!==void 0&&l.image.depth>1,p=o.depth>1&&(e.useArrayDepthTexture||e.multiview||f);l===void 0&&u&&(l=new La,l.format=e.stencilBuffer?Ce:Se,l.type=e.stencilBuffer?ge:de,l.image.width=s,l.image.height=c,l.image.depth=o.depth,l.renderTarget=e,i[t]=l),l&&(l.isArrayTexture=p),(n.width!==o.width||o.height!==n.height)&&(d=!0,l&&(l.needsUpdate=!0,l.image.width=s,l.image.height=c,l.image.depth=p?o.depth:1)),n.width=o.width,n.height=o.height,n.textures=a,n.depthTexture=l||null,n.depth=e.depthBuffer,n.stencil=e.stencilBuffer,n.renderTarget=e,n.sampleCount!==r&&(d=!0,l&&(l.needsUpdate=!0),n.sampleCount=r);let m={sampleCount:r};if(e.isXRRenderTarget!==!0){for(let e=0;e{this._destroyRenderTarget(e)},e.addEventListener(`dispose`,n.onDispose))}updateTexture(e,t={}){let n=this.get(e);if(n.initialized===!0&&n.version===e.version)return;let r=e.isRenderTargetTexture||e.isDepthTexture||e.isFramebufferTexture,i=this.backend;if(r&&n.initialized===!0&&i.destroyTexture(e),e.isFramebufferTexture){let t=this.renderer.getRenderTarget();t?e.type=t.texture.type:e.type=oe}if(e.isHTMLTexture&&e.image){let t=this.renderer.domElement;if(`requestPaint`in t){if(t.hasAttribute(`layoutsubtree`)||t.setAttribute(`layoutsubtree`,`true`),e.image.parentNode!==t&&t.appendChild(e.image),this._htmlTextures.size===0){let e=this._htmlTextures;t.onpaint=t=>{let n=t&&t.changedElements;for(let t of e)(!n||n.includes(t.image))&&(t.needsUpdate=!0)}}this._htmlTextures.add(e)}}let{width:a,height:o,depth:s}=this.getSize(e);if(t.width=a,t.height=o,t.depth=s,t.needsMipmaps=this.needsMipmaps(e),t.levels=t.needsMipmaps?this.getMipLevels(e,a,o):1,e.isCubeTexture&&e.mipmaps.length>0&&t.levels++,r||e.isStorageTexture===!0||e.isExternalTexture===!0)i.createTexture(e,t),n.generation=e.version;else if(e.version>0){let r=e.image;if(r===void 0)F(`Renderer: Texture marked for update but image is undefined.`);else if(r.complete===!1)F(`Renderer: Texture marked for update but image is incomplete.`);else{if(e.images){let n=[];for(let t of e.images)n.push(t);t.images=n}else t.image=r;(n.isDefaultTexture===void 0||n.isDefaultTexture===!0)&&(i.createTexture(e,t),n.isDefaultTexture=!1,n.generation=e.version),e.source.dataReady===!0&&i.updateTexture(e,t);let a=e.isStorageTexture===!0&&e.mipmapsAutoUpdate===!1;t.needsMipmaps&&e.mipmaps.length===0&&!a&&i.generateMipmaps(e),e.onUpdate&&e.onUpdate(e)}}else i.createDefaultTexture(e),n.isDefaultTexture=!0,n.generation=e.version;n.initialized!==!0&&(n.initialized=!0,n.generation=e.version,n.bindGroups=new Set,this.info.createTexture(e),e.isVideoTexture&&jn.enabled===!0&&jn.getTransfer(e.colorSpace)!==`srgb`&&F(`WebGPURenderer: Video textures must use a color space with a sRGB transfer function, e.g. SRGBColorSpace.`),n.onDispose=()=>{this._destroyTexture(e)},e.addEventListener(`dispose`,n.onDispose)),n.version=e.version}updateSampler(e){return this.backend.updateSampler(e)}getSize(e,t=gH){let n=e.images?e.images[0]:e.image;return n?(n.image!==void 0&&(n=n.image),e.isHTMLTexture?(t.width=n.offsetWidth||1,t.height=n.offsetHeight||1,t.depth=1):typeof HTMLVideoElement<`u`&&n instanceof HTMLVideoElement?(t.width=n.videoWidth||1,t.height=n.videoHeight||1,t.depth=1):typeof VideoFrame<`u`&&n instanceof VideoFrame?(t.width=n.displayWidth||1,t.height=n.displayHeight||1,t.depth=1):(t.width=n.width||1,t.height=n.height||1,t.depth=e.isCubeTexture?6:n.depth||1)):t.width=t.height=t.depth=1,t}getMipLevels(e,t,n){let r;return r=e.mipmaps.length>0?e.mipmaps.length:e.isCompressedTexture===!0?1:Math.floor(Math.log2(Math.max(t,n)))+1,r}needsMipmaps(e){return e.generateMipmaps===!0||e.mipmaps.length>0}_destroyRenderTarget(e){if(this.has(e)===!0){let t=this.get(e),n=t.textures,r=t.depthTexture;e.removeEventListener(`dispose`,t.onDispose);for(let e=0;e{t.isOverrideContextNode===!0&&e.push(t.value.overrideNodes)});let t=new Map(e.flatMap(e=>Array.from(e.entries()))),n=super.getFlowContextData();return n.overrideNodes=t,n}};function bH(e,t=null,n=null){if(t&&t.isNode){let e=t;t=()=>e}return new yH(new Map([[e,t]]),n)}H(`overrideNode`,(e,t,n)=>bH(t,n,e));function xH(e,t=null){let n=new Map;for(let[t,r]of e){let e=r===null?null:typeof r==`function`?r:()=>r;n.set(t,e)}return new yH(n,t)}H(`overrideNodes`,(e,t)=>xH(t,e));var SH=class extends Sk{static get type(){return`ParameterNode`}constructor(e,t=null){super(e,t),this.isParameterNode=!0}getMemberType(e,t){let n=this.getNodeType(e),r=e.getStructTypeNode(n),i;return r===null?(I(`TSL: Member "${t}" not found in struct "${n}".`,new CD),i=`float`):i=r.getMemberType(e,t),i}getHash(){return String(this.id)}generate(){return this.name}},CH=(e,t)=>new SH(e,t),wH=qO(class extends XD{static get type(){return`StackNode`}constructor(e=null){super(),this.nodes=[],this.outputNode=null,this.parent=e,this._currentCond=null,this._expressionNode=null,this._currentNode=null,this._nodeDataLibrary=new Map,this.isStackNode=!0}getElementType(e){return this.outputNode?this.outputNode.getElementType(e):`void`}generateNodeType(e){return this.outputNode?this.outputNode.getNodeType(e):`void`}getMemberType(e,t){return this.outputNode?this.outputNode.getMemberType(e,t):`void`}addToStack(e,t=-1){if(e.isNode!==!0)return I(`TSL: Invalid node added to stack.`,new CD),this;if(t===-1)if(this._currentNode){let e=this._nodeDataLibrary.get(this._currentNode);e===void 0&&(e={delta:0},this._nodeDataLibrary.set(this._currentNode,e)),e.delta++,t=this.nodes.indexOf(this._currentNode)+e.delta}else t=this.nodes.length;return this.nodes.splice(t,0,e),this}addToStackBefore(e){let t=this._currentNode?this.nodes.indexOf(this._currentNode):0;return this.addToStack(e,t)}If(e,t){return this._currentCond=lM(e,new HO(t)),this.addToStack(this._currentCond)}ElseIf(e,t){let n=lM(e,new HO(t));return this._currentCond.elseNode=n,this._currentCond=n,this}Else(e){return this._currentCond.elseNode=new HO(e),this}Switch(e){return this._expressionNode=UO(e),this}Case(...e){let t=[];if(e.length>=2)for(let n=0;ntypeof t==`string`?{name:e,type:t,atomic:!1}:{name:e,type:t.type,atomic:t.atomic||!1})}var EH=class extends XD{static get type(){return`StructTypeNode`}constructor(e,t=null){super(`struct`),this.membersLayout=TH(e),this.name=t,this.isStructTypeNode=!0}getLength(){let e=1,t=0;for(let n of this.membersLayout){let r=n.type,i=ND(r),a=PD(r);e=Math.max(e,a);let o=t%e%a;o!==0&&(t+=a-o),t+=i}return Math.ceil(t/e)*e}getMemberType(e,t){let n=this.membersLayout.find(e=>e.name===t);return n?n.type:`void`}generateNodeType(e){return e.getStructTypeFromNode(this,this.membersLayout,this.name).name}setup(e){e.getStructTypeFromNode(this,this.membersLayout,this.name),e.addInclude(this)}generate(e){return this.getNodeType(e)}},DH=class extends XD{static get type(){return`StructNode`}constructor(e,t){super(`vec3`),this.structTypeNode=e,this.values=t,this.isStructNode=!0}generateNodeType(e){return this.structTypeNode.getNodeType(e)}getMemberType(e,t){return this.structTypeNode.getMemberType(e,t)}_getChildren(){let e=super._getChildren(),t=e.find(e=>e.childNode===this.structTypeNode);return e.splice(e.indexOf(t),1),e.push(t),e}generate(e){let t=e.getVarFromNode(this),n=t.type,r=e.getPropertyName(t);return e.addLineFlowCode(`${r} = ${e.generateStruct(n,this.structTypeNode.membersLayout,this.values)}`,this),t.name}},OH=(e,t=null)=>{let n=new EH(e,t);return YO((...t)=>{let r=null;if(t.length>0)if(t[0].isNode){r={};let n=Object.keys(e);for(let e=0;enew IH(e,`int`,`float`),zH=e=>new IH(e,`uint`,`float`),BH=e=>new IH(e,`float`,`int`),VH=e=>new IH(e,`float`,`uint`),HH={},UH=class e extends Y{static get type(){return`BitcountNode`}constructor(e,t){super(e,t),this.isBitcountNode=!0}_resolveElementType(e,t,n){n===`int`?t.assign(LH(e,`uint`)):t.assign(e)}_returnDataNode(e){switch(e){case`uint`:return q;case`int`:return K;case`uvec2`:return ok;case`uvec3`:return lk;case`uvec4`:return pk;case`ivec2`:return ak;case`ivec3`:return ck;case`ivec4`:return fk}}_createTrailingZerosBaseLayout(e,t){let n=this._returnDataNode(t);return W(([e])=>{let r=q(0);return this._resolveElementType(e,r,t),n(zH(G(r.bitAnd(Cj(r)))).shiftRight(23).sub(127))}).setLayout({name:e,type:t,inputs:[{name:`value`,type:t}]})}_createLeadingZerosBaseLayout(e,t){let n=this._returnDataNode(t);return W(([e])=>{$O(e.equal(q(0)),()=>q(32));let r=q(0),i=q(0);return this._resolveElementType(e,r,t),$O(r.shiftRight(16).equal(0),()=>{i.addAssign(16),r.shiftLeftAssign(16)}),$O(r.shiftRight(24).equal(0),()=>{i.addAssign(8),r.shiftLeftAssign(8)}),$O(r.shiftRight(28).equal(0),()=>{i.addAssign(4),r.shiftLeftAssign(4)}),$O(r.shiftRight(30).equal(0),()=>{i.addAssign(2),r.shiftLeftAssign(2)}),$O(r.shiftRight(31).equal(0),()=>{i.addAssign(1)}),n(i)}).setLayout({name:e,type:t,inputs:[{name:`value`,type:t}]})}_createOneBitsBaseLayout(e,t){let n=this._returnDataNode(t);return W(([e])=>{let r=q(0);return this._resolveElementType(e,r,t),r.assign(r.sub(r.shiftRight(q(1)).bitAnd(q(1431655765)))),r.assign(r.bitAnd(q(858993459)).add(r.shiftRight(q(2)).bitAnd(q(858993459)))),n(r.add(r.shiftRight(q(4))).bitAnd(q(252645135)).mul(q(16843009)).shiftRight(q(24)))}).setLayout({name:e,type:t,inputs:[{name:`value`,type:t}]})}_createMainLayout(e,t,n,r){let i=this._returnDataNode(t);return W(([e])=>{if(n===1)return i(r(e));{let t=i(0),a=[`x`,`y`,`z`,`w`];for(let i=0;id(r))()}};UH.COUNT_TRAILING_ZEROS=`countTrailingZeros`,UH.COUNT_LEADING_ZEROS=`countLeadingZeros`,UH.COUNT_ONE_BITS=`countOneBits`;var WH=U(UH,UH.COUNT_TRAILING_ZEROS).setParameterLength(1),GH=U(UH,UH.COUNT_LEADING_ZEROS).setParameterLength(1),KH=U(UH,UH.COUNT_ONE_BITS).setParameterLength(1),qH=W(([e])=>{let t=e.toUint().mul(747796405).add(2891336453),n=t.shiftRight(t.shiftRight(28).add(4)).bitXor(t).mul(277803737);return n.shiftRight(22).bitXor(n).toFloat().mul(1/2**32)}),JH=(e,t)=>Hj(yA(4,e.mul(vA(1,e))),t),YH=(e,t)=>e.lessThan(.5)?JH(e.mul(2),t).div(2):vA(1,JH(yA(vA(1,e),2),t).div(2)),XH=(e,t,n)=>Hj(bA(Hj(e,t),_A(Hj(e,t),Hj(vA(1,e),n))),1/t),ZH=(e,t)=>cj(WA.mul(t.mul(e).sub(1))).div(WA.mul(t.mul(e).sub(1))),QH=class extends $D{static get type(){return`PackFloatNode`}constructor(e,t){super(),this.vectorNode=t,this.encoding=e,this.isPackFloatNode=!0}generateNodeType(){return`uint`}generate(e){let t=this.vectorNode.getNodeType(e);return`${e.getFloatPackingMethod(this.encoding)}(${this.vectorNode.build(e,t)})`}},$H=U(QH,`snorm`).setParameterLength(1),eU=U(QH,`unorm`).setParameterLength(1),tU=U(QH,`float16`).setParameterLength(1),nU=class extends $D{static get type(){return`UnpackFloatNode`}constructor(e,t){super(),this.uintNode=t,this.encoding=e,this.isUnpackFloatNode=!0}generateNodeType(){return`vec2`}generate(e){let t=this.uintNode.getNodeType(e);return`${e.getFloatUnpackingMethod(this.encoding)}(${this.uintNode.build(e,t)})`}},rU=U(nU,`snorm`).setParameterLength(1),iU=U(nU,`unorm`).setParameterLength(1),aU=U(nU,`float16`).setParameterLength(1),oU=W(([e])=>e.fract().sub(.5).abs()).setLayout({name:`tri`,type:`float`,inputs:[{name:`x`,type:`float`}]}),sU=W(([e])=>J(oU(e.z.add(oU(e.y.mul(1)))),oU(e.z.add(oU(e.x.mul(1)))),oU(e.y.add(oU(e.x.mul(1)))))).setLayout({name:`tri3`,type:`vec3`,inputs:[{name:`p`,type:`vec3`}]}),cU=W(([e,t,n])=>{let r=J(e).toVar(),i=G(1.4).toVar(),a=G(0).toVar(),o=J(r).toVar();return RL({start:G(0),end:G(3),type:`float`,condition:`<=`},()=>{let e=J(sU(o.mul(2))).toVar();r.addAssign(e.add(n.mul(G(.1).mul(t)))),o.mulAssign(1.8),i.mulAssign(1.5),r.mulAssign(1.2);let s=G(oU(r.z.add(oU(r.x.add(oU(r.y)))))).toVar();a.addAssign(s.div(i)),o.addAssign(.14)}),a}).setLayout({name:`triNoise3D`,type:`float`,inputs:[{name:`position`,type:`vec3`},{name:`speed`,type:`float`},{name:`time`,type:`float`}]}),lU=qO(class extends XD{static get type(){return`FunctionOverloadingNode`}constructor(e=[],...t){super(),this.functionNodes=e,this.parametersNodes=t,this._candidateFn=null,this.global=!0}generateNodeType(e){return this.getCandidateFn(e).shaderNode.layout.type}getCandidateFn(e){let t=this.parametersNodes,n=this._candidateFn;if(n===null){let r=null,i=-1;for(let n of this.functionNodes){let a=n.shaderNode.layout;if(a===null)throw Error(`THREE.FunctionOverloadingNode: FunctionNode must be a layout.`);let o=a.inputs;if(t.length===o.length){let a=0;for(let n=0;ni&&(r=n,i=a)}}this._candidateFn=n=r}return n}setup(e){return this.getCandidateFn(e)(...this.parametersNodes)}}),uU=e=>(...t)=>lU(e,...t),dU=lA(0).setGroup(oA).onRenderUpdate(e=>e.time),fU=lA(0).setGroup(oA).onRenderUpdate(e=>e.deltaTime),pU=lA(0,`uint`).setGroup(oA).onRenderUpdate(e=>e.frameId),mU=(e=dU)=>e.add(.75).mul(Math.PI*2).sin().mul(.5).add(.5),hU=(e=dU)=>e.fract().round(),gU=(e=dU)=>e.add(.5).fract().mul(2).sub(1).abs(),_U=(e=dU)=>e.fract();function vU(e,t=null){return dM(t,{getUV:typeof e==`function`?e:()=>e})}var yU=W(([e,t,n=ik(.5)])=>CV(e.sub(n),t).add(n)),bU=W(([e,t,n=ik(.5)])=>{let r=e.sub(n),i=r.dot(r),a=i.mul(i).mul(t);return e.add(r.mul(a))}),xU=W(({position:e=null,horizontal:t=!0,vertical:n=!1})=>{let r;e===null?r=zP:(r=zP.toVar(),r[3][0]=e.x,r[3][1]=e.y,r[3][2]=e.z);let i=wP.mul(r);return BO(t)&&(i[0][0]=zP[0].length(),i[0][1]=0,i[0][2]=0),BO(n)&&(i[1][0]=0,i[1][1]=zP[1].length(),i[1][2]=0),i[2][0]=0,i[2][1]=0,i[2][2]=1,SP.mul(i).mul(QP)}),SU=W(([e=null])=>{let t=gR();return gR(iR(e)).sub(t).lessThan(0).select(ZN,e)}),CU=W(([e,t=ON(),n=G(0)])=>{let r=e.x,i=e.y,a=n.mod(r.mul(i)).floor(),o=a.mod(r),s=i.sub(a.add(1).div(r).ceil()),c=e.reciprocal(),l=ik(o,s);return t.add(l).mul(c)}),wU=W(([e,t=null,n=null,r=G(1),i=QP,a=lF])=>{let o=a.abs().normalize();o=o.div(o.dot(J(1)));let s=i.yz.mul(r),c=i.zx.mul(r),l=i.xy.mul(r),u=e.value,d=t===null?u:t.value,f=n===null?u:n.value;return _A(FN(u,s).mul(o.x),FN(d,c).mul(o.y),FN(f,l).mul(o.z))}),TU=(...e)=>wU(...e),EU=new ca,DU=new R,OU=new R,kU=new R,AU=new qn,jU=new R(0,0,-1),MU=new Hn,NU=new R,PU=new R,FU=new Hn,IU=new L,LU=new Un,RU=ZN.flipX();LU.depthTexture=new La(1,1);var zU=!1,BU=class e extends NN{static get type(){return`ReflectorNode`}constructor(e={}){super(e.defaultTexture||LU.texture,RU),this._reflectorBaseNode=e.reflector||new VU(this,e),this._depthNode=null,this.setUpdateMatrix(!1)}get reflector(){return this._reflectorBaseNode}get target(){return this._reflectorBaseNode.target}getDepthNode(){if(this._depthNode===null){if(this._reflectorBaseNode.depth!==!0)throw Error(`THREE.ReflectorNode: Depth node can only be requested when the reflector is created with { depth: true }. `);this._depthNode=new e({defaultTexture:LU.depthTexture,reflector:this._reflectorBaseNode})}return this._depthNode}setup(e){return e.object.isQuadMesh||this._reflectorBaseNode.build(e),super.setup(e)}clone(){let e=new this.constructor(this.reflectorNode);return e.uvNode=this.uvNode,e.levelNode=this.levelNode,e.biasNode=this.biasNode,e.sampler=this.sampler,e.depthNode=this.depthNode,e.compareNode=this.compareNode,e.gradNode=this.gradNode,e.gatherNode=this.gatherNode,e.offsetNode=this.offsetNode,e._reflectorBaseNode=this._reflectorBaseNode,e}dispose(){super.dispose(),this._reflectorBaseNode.dispose()}},VU=class extends XD{static get type(){return`ReflectorBaseNode`}constructor(e,t={}){super();let{target:n=new z,resolutionScale:r=1,generateMipmaps:i=!1,bounces:a=!0,depth:o=!1,samples:s=0}=t;this.textureNode=e,this.target=n,this.resolutionScale=r,t.resolution!==void 0&&(Wt(`ReflectorNode: The "resolution" parameter has been renamed to "resolutionScale".`),this.resolutionScale=t.resolution),this.generateMipmaps=i,this.bounces=a,this.depth=o,this.samples=s,this.updateBeforeType=a?VD.RENDER:VD.FRAME,this.virtualCameras=new WeakMap,this.renderTargets=new Map,this.forceUpdate=!1,this.hasOutput=!1}_updateResolution(e,t){let n=this.resolutionScale;t.getDrawingBufferSize(IU),e.setSize(Math.round(IU.width*n),Math.round(IU.height*n))}setup(e){return this._updateResolution(LU,e.renderer),super.setup(e)}dispose(){super.dispose();for(let e of this.renderTargets.values())e.dispose()}getVirtualCamera(e){let t=this.virtualCameras.get(e);return t===void 0&&(t=e.clone(),this.virtualCameras.set(e,t)),t}getRenderTarget(e){let t=this.renderTargets.get(e);return t===void 0&&(t=new Un(0,0,{type:pe,samples:this.samples}),this.generateMipmaps===!0&&(t.texture.minFilter=ae,t.texture.generateMipmaps=!0),this.depth===!0&&(t.depthTexture=new La),this.renderTargets.set(e,t)),t}updateBefore(e){if(this.bounces===!1&&zU)return!1;zU=!0;let{scene:t,camera:n,renderer:r,material:i}=e,{target:a}=this,o=this.getVirtualCamera(n),s=this.getRenderTarget(o);r.getDrawingBufferSize(IU),this._updateResolution(s,r),OU.setFromMatrixPosition(a.matrixWorld),kU.setFromMatrixPosition(n.matrixWorld),AU.extractRotation(a.matrixWorld),DU.set(0,0,1),DU.applyMatrix4(AU),NU.subVectors(OU,kU);let c=NU.dot(DU)>0,l=!1;if(c===!0&&this.forceUpdate===!1){if(this.hasOutput===!1){zU=!1;return}l=!0}NU.reflect(DU).negate(),NU.add(OU),AU.extractRotation(n.matrixWorld),jU.set(0,0,-1),jU.applyMatrix4(AU),jU.add(kU),PU.subVectors(OU,jU),PU.reflect(DU).negate(),PU.add(OU),o.coordinateSystem=n.coordinateSystem,o.position.copy(NU),o.up.set(0,1,0),o.up.applyMatrix4(AU),o.up.reflect(DU),o.lookAt(PU),o.near=n.near,o.far=n.far,o.updateMatrixWorld(),o.projectionMatrix.copy(n.projectionMatrix),EU.setFromNormalAndCoplanarPoint(DU,OU),EU.applyMatrix4(o.matrixWorldInverse),MU.set(EU.normal.x,EU.normal.y,EU.normal.z,EU.constant);let u=o.projectionMatrix;FU.x=(Math.sign(MU.x)+u.elements[8])/u.elements[0],FU.y=(Math.sign(MU.y)+u.elements[9])/u.elements[5],FU.z=-1,FU.w=(1+u.elements[10])/u.elements[14],MU.multiplyScalar(1/MU.dot(FU)),u.elements[2]=MU.x,u.elements[6]=MU.y,u.elements[10]=r.coordinateSystem===2001?MU.z-0:MU.z+1-0,u.elements[14]=MU.w,this.textureNode.value=s.texture,this.depth===!0&&(this.textureNode.getDepthNode().value=s.depthTexture),i.visible=!1;let d=r.getRenderTarget(),f=r.getMRT(),p=r.autoClear;r.setMRT(null),r.setRenderTarget(s),r.autoClear=!0;let m=t.name;t.name=(t.name||`Scene`)+` [ Reflector ]`,l?(r.clear(),this.hasOutput=!1):(r.render(t,o),this.hasOutput=!0),t.name=m,r.setMRT(f),r.setRenderTarget(d),r.autoClear=p,i.visible=!0,zU=!1,this.forceUpdate=!1}get resolution(){return Wt(`ReflectorNode: The "resolution" property has been renamed to "resolutionScale".`),this.resolutionScale}set resolution(e){Wt(`ReflectorNode: The "resolution" property has been renamed to "resolutionScale".`),this.resolutionScale=e}},HU=e=>new BU(e),UU=new vc(-1,1,1,-1,0,1),WU=new class extends Di{constructor(e=!1){super();let t=e===!1?[0,-1,0,1,2,1]:[0,2,0,0,2,0];this.setAttribute(`position`,new hi([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute(`uv`,new hi(t,2))}},GU=class extends ea{constructor(e=null){super(WU,e),this.camera=UU,this.isQuadMesh=!0}async renderAsync(e){Wt(`QuadMesh: "renderAsync()" has been deprecated. Use "render()" and "await renderer.init();" when creating the renderer.`),await e.init(),e.render(this,UU)}render(e){e.render(this,UU)}},KU=new L,qU=class extends NN{static get type(){return`RTTNode`}constructor(e,t=null,n=null,r={type:pe}){let i=new Un(t,n,r);super(i.texture,ON()),this.isRTTNode=!0,this.node=e,this.width=t,this.height=n,this.renderTarget=i,this.textureNeedsUpdate=!0,this.autoUpdate=!0,this._resolutionScale=1,this._rttNode=null,this._quadMesh=new GU(new OR),this.updateBeforeType=VD.RENDER}get autoResize(){return this.width===null}setup(e){return this._rttNode=this.node.context(e.getSharedContext()),this._quadMesh.material.name=`RTT`,this._quadMesh.material.needsUpdate=!0,super.setup(e)}setSize(e,t){let n=Math.floor(e*this._resolutionScale),r=Math.floor(t*this._resolutionScale);this.renderTarget.setSize(n,r),this.textureNeedsUpdate=!0}setResolutionScale(e){return this._resolutionScale=e,this.autoResize===!1&&this.setSize(this.width,this.height),this}getResolutionScale(){return this._resolutionScale}updateBefore({renderer:e}){if(this.textureNeedsUpdate===!1&&this.autoUpdate===!1)return;this.textureNeedsUpdate=!1;let t=e.getRenderTarget();if(this.autoResize===!0){let t=e.getDrawingBufferSize(KU),n=Math.floor(t.width*this._resolutionScale),r=Math.floor(t.height*this._resolutionScale);(n!==this.renderTarget.width||r!==this.renderTarget.height)&&(this.renderTarget.setSize(n,r),this.textureNeedsUpdate=!0)}let n=`RTT`;this.node.name&&(n=this.node.name+` [ `+n+` ]`),this._quadMesh.material.fragmentNode=this._rttNode,this._quadMesh.name=n,e.setRenderTarget(this.renderTarget),this._quadMesh.render(e),e.setRenderTarget(t)}clone(){let e=new NN(this.value,this.uvNode,this.levelNode);return e.sampler=this.sampler,e.referenceNode=this,e}},JU=(e,...t)=>new qU(UO(e),...t),YU=(e,...t)=>e.isSampleNode||e.isTextureNode?e:e.isPassNode?e.getTextureNode():JU(e,...t),XU=W(([e,t,n],r)=>{let i;r.renderer.coordinateSystem===2001?(e=ik(e.x,e.y.oneMinus()).mul(2).sub(1),i=dk(J(e,t),1)):i=dk(J(e.x,e.y.oneMinus(),t).mul(2).sub(1),1);let a=dk(n.mul(i));return a.xyz.div(a.w)}),ZU=W(([e,t])=>{let n=t.mul(dk(e,1)),r=n.xy.div(n.w).mul(.5).add(.5).toVar();return ik(r.x,r.y.oneMinus())}),QU=W(([e,t,n])=>{let r=kN(LN(t)),i=ak(e.mul(r)).toVar(),a=LN(t,i).toVar(),o=LN(t,i.sub(ak(2,0))).toVar(),s=LN(t,i.sub(ak(1,0))).toVar(),c=LN(t,i.add(ak(1,0))).toVar(),l=LN(t,i.add(ak(2,0))).toVar(),u=LN(t,i.add(ak(0,2))).toVar(),d=LN(t,i.add(ak(0,1))).toVar(),f=LN(t,i.sub(ak(0,1))).toVar(),p=LN(t,i.sub(ak(0,2))).toVar(),m=bj(vA(G(2).mul(s).sub(o),a)).toVar(),h=bj(vA(G(2).mul(c).sub(l),a)).toVar(),g=bj(vA(G(2).mul(d).sub(u),a)).toVar(),_=bj(vA(G(2).mul(f).sub(p),a)).toVar(),v=XU(e,a,n).toVar();return oj(Vj(m.lessThan(h).select(v.sub(XU(e.sub(ik(G(1).div(r.x),0)),s,n)),v.negate().add(XU(e.add(ik(G(1).div(r.x),0)),c,n))),g.lessThan(_).select(v.sub(XU(e.add(ik(0,G(1).div(r.y))),d,n)),v.negate().add(XU(e.sub(ik(0,G(1).div(r.y))),f,n)))))}),$U=W(([e])=>sj(G(52.9829189).mul(sj(Bj(e,ik(.06711056,.00583715)))))).setLayout({name:`interleavedGradientNoise`,type:`float`,inputs:[{name:`position`,type:`vec2`}]}),eW=W(([e,t,n])=>{let r=G(2.399963229728653),i=nj(G(e).add(.5).div(G(t))),a=G(e).mul(r).add(n);return ik(uj(a),cj(a)).mul(i)}).setLayout({name:`vogelDiskSample`,type:`vec2`,inputs:[{name:`sampleIndex`,type:`int`},{name:`samplesCount`,type:`int`},{name:`phi`,type:`float`}]}),tW=class extends XD{static get type(){return`SampleNode`}constructor(e,t=null){super(),this.callback=e,this.uvNode=t,this.isSampleNode=!0}setup(){return this.sample(ON())}sample(e){return this.callback(e)}},nW=(e,t=null)=>new tW(e,UO(t)),rW=class extends ia{constructor(e,t,n=Float32Array){let r=ArrayBuffer.isView(e)?e:new n(e*t);super(r,t),this.isStorageInstancedBufferAttribute=!0}},iW=class extends di{constructor(e,t,n=Float32Array){let r=ArrayBuffer.isView(e)?e:new n(e*t);super(r,t),this.isStorageBufferAttribute=!0}},aW=(e,t=`float`)=>{let n,r;return t.isStructTypeNode===!0?(n=t.getLength(),r=jD(`float`)):(n=MD(t),r=jD(t)),_L(new iW(e,n,r),t,e)},oW=(e,t=`float`)=>{let n,r;t.isStructTypeNode===!0?(n=t.getLength(),r=jD(`float`)):(n=MD(t),r=jD(t));let i=new rW(e,n,r);return _L(i,t,i.count)},sW=JO(class extends XD{static get type(){return`PointUVNode`}constructor(){super(`vec2`),this.isPointUVNode=!0}generate(){return`vec2( gl_PointCoord.x, 1.0 - gl_PointCoord.y )`}}),cW=new qn,lW=lA(0).setGroup(oA).onRenderUpdate(({scene:e})=>e.backgroundBlurriness),uW=lA(1).setGroup(oA).onRenderUpdate(({scene:e})=>e.backgroundIntensity),dW=lA(new qn).setGroup(oA).onRenderUpdate(({scene:e})=>{let t=e.background;return t!==null&&t.isTexture&&t.mapping!==300||e.backgroundNode&&e.backgroundNode.isNode?cW.makeRotationFromEuler(e.backgroundRotation).transpose():cW.identity(),cW}),fW=class extends NN{static get type(){return`StorageTextureNode`}constructor(e,t,n=null){super(e,t),this.storeNode=n,this.mipLevel=0,this.isStorageTextureNode=!0,this.access=UD.WRITE_ONLY}getInputType(){return`storageTexture`}getTransformedUV(e){return e}setup(e){super.setup(e);let t=e.getNodeProperties(this);return t.storeNode=this.storeNode,t}setAccess(e){return this.access=e,this}setMipLevel(e){return this.mipLevel=e,this}generate(e,t){return this.storeNode===null?super.generate(e,t):(this.generateStore(e),``)}generateSnippet(e,t,n,r,i,a,o,s,c){let l=this.value;return e.generateStorageTextureLoad(l,t,n,r,a,c)}toReadWrite(){return this.setAccess(UD.READ_WRITE)}toReadOnly(){return this.setAccess(UD.READ_ONLY)}toWriteOnly(){return this.setAccess(UD.WRITE_ONLY)}store(e,t){let n=this.clone();return n.referenceNode=this.getBase(),n.uvNode=e,n.storeNode=t,t!==null&&n.toStack(),n}generateStore(e){let{uvNode:t,storeNode:n,depthNode:r}=e.getNodeProperties(this),i=super.generate(e,`property`),a=t.build(e,this.value.is3DTexture===!0?`uvec3`:`uvec2`),o=n.build(e,`vec4`),s=r?r.build(e,`int`):null,c=e.generateTextureStore(this.value,i,a,s,o);e.addLineFlowCode(c,this)}clone(){let e=super.clone();return e.storeNode=this.storeNode,e.mipLevel=this.mipLevel,e.access=this.access,e}},pW=qO(fW).setParameterLength(1,3),mW=(e,t,n)=>{let r;return e.isStorageTextureNode===!0?r=e.store(t,n):(r=pW(e,t,n),n!==null&&r.toStack()),r},hW=qO(class extends fW{static get type(){return`StorageTexture3DNode`}constructor(e,t,n=null){super(e,t,n),this.isStorageTexture3DNode=!0}getDefaultUV(){return J(.5,.5,.5)}setUpdateMatrix(){}generateUV(e,t){return t.build(e,this.sampler===!0?`vec3`:`ivec3`)}generateOffset(e,t){return t.build(e,`ivec3`)}}).setParameterLength(1,3),gW=W(({texture:e,uv:t})=>{let n=1e-4,r=J().toVar();return $O(t.x.lessThan(n),()=>{r.assign(J(1,0,0))}).ElseIf(t.y.lessThan(n),()=>{r.assign(J(0,1,0))}).ElseIf(t.z.lessThan(n),()=>{r.assign(J(0,0,1))}).ElseIf(t.x.greaterThan(1-n),()=>{r.assign(J(-1,0,0))}).ElseIf(t.y.greaterThan(1-n),()=>{r.assign(J(0,-1,0))}).ElseIf(t.z.greaterThan(1-n),()=>{r.assign(J(0,0,-1))}).Else(()=>{let n=.01,i=e.sample(t.add(J(-n,0,0))).r.sub(e.sample(t.add(J(n,0,0))).r),a=e.sample(t.add(J(0,-n,0))).r.sub(e.sample(t.add(J(0,n,0))).r),o=e.sample(t.add(J(0,0,-n))).r.sub(e.sample(t.add(J(0,0,n))).r);r.assign(J(i,a,o))}),r.normalize()}),_W=qO(class extends NN{static get type(){return`Texture3DNode`}constructor(e,t=null,n=null){super(e,t,n),this.isTexture3DNode=!0}getInputType(){return`texture3D`}getDefaultUV(){return J(.5,.5,.5)}setUpdateMatrix(){}generateUV(e,t){return t.build(e,this.sampler===!0?`vec3`:`ivec3`)}generateOffset(e,t){return t.build(e,`ivec3`)}normal(e){return gW({texture:this,uv:e})}}).setParameterLength(1,3),vW=(...e)=>_W(...e).setSampler(!1),yW=(e,t,n)=>_W(e,t).level(n),bW=class extends PF{static get type(){return`UserDataNode`}constructor(e,t,n=null){super(e,t,n),this.userData=n}updateReference(e){return this.reference=this.userData===null?e.object.userData:this.userData,this.reference}},xW=(e,t,n)=>new bW(e,t,n),SW=new WeakMap,CW=class extends $D{static get type(){return`VelocityNode`}constructor(){super(`vec2`),this.projectionMatrix=null,this.updateType=VD.OBJECT,this.updateAfterType=VD.OBJECT,this.previousModelWorldMatrix=lA(new qn),this.previousProjectionMatrix=lA(new qn).setGroup(oA),this.previousCameraViewMatrix=lA(new qn)}setProjectionMatrix(e){this.projectionMatrix=e}update({frameId:e,camera:t,object:n}){let r=TW(n);this.previousModelWorldMatrix.value.copy(r);let i=wW(t);i.frameId!==e&&(i.frameId=e,i.previousProjectionMatrix===void 0?(i.previousProjectionMatrix=new qn,i.previousCameraViewMatrix=new qn,i.currentProjectionMatrix=new qn,i.currentCameraViewMatrix=new qn,i.previousProjectionMatrix.copy(this.projectionMatrix||t.projectionMatrix),i.previousCameraViewMatrix.copy(t.matrixWorldInverse)):(i.previousProjectionMatrix.copy(i.currentProjectionMatrix),i.previousCameraViewMatrix.copy(i.currentCameraViewMatrix)),i.currentProjectionMatrix.copy(this.projectionMatrix||t.projectionMatrix),i.currentCameraViewMatrix.copy(t.matrixWorldInverse),this.previousProjectionMatrix.value.copy(i.previousProjectionMatrix),this.previousCameraViewMatrix.value.copy(i.previousCameraViewMatrix))}updateAfter({object:e}){TW(e).copy(e.matrixWorld)}setup(){let e=this.projectionMatrix===null?SP:lA(this.projectionMatrix),t=this.previousCameraViewMatrix.mul(this.previousModelWorldMatrix),n=e.mul(KP).mul(QP),r=this.previousProjectionMatrix.mul(t).mul($P);return vA(n.xy.div(n.w),r.xy.div(r.w))}};function wW(e){let t=SW.get(e);return t===void 0&&(t={},SW.set(e,t)),t}function TW(e,t=0){let n=wW(e),r=n[t];return r===void 0&&(n[t]=r=new qn,n[t].copy(e.matrixWorld)),r}var EW=JO(CW),DW=W(([e,t])=>Pj(1,e.oneMinus().div(t)).oneMinus()).setLayout({name:`blendBurn`,type:`vec3`,inputs:[{name:`base`,type:`vec3`},{name:`blend`,type:`vec3`}]}),OW=W(([e,t])=>Pj(e.div(t.oneMinus()),1)).setLayout({name:`blendDodge`,type:`vec3`,inputs:[{name:`base`,type:`vec3`},{name:`blend`,type:`vec3`}]}),kW=W(([e,t])=>e.oneMinus().mul(t.oneMinus()).oneMinus()).setLayout({name:`blendScreen`,type:`vec3`,inputs:[{name:`base`,type:`vec3`},{name:`blend`,type:`vec3`}]}),AW=W(([e,t])=>Zj(e.mul(2).mul(t),e.oneMinus().mul(2).mul(t.oneMinus()).oneMinus(),Ij(.5,e))).setLayout({name:`blendOverlay`,type:`vec3`,inputs:[{name:`base`,type:`vec3`},{name:`blend`,type:`vec3`}]}),jW=W(([e,t])=>{let n=t.a.add(e.a.mul(t.a.oneMinus()));return dk(t.rgb.mul(t.a).add(e.rgb.mul(e.a).mul(t.a.oneMinus())).div(n),n)}).setLayout({name:`blendColor`,type:`vec4`,inputs:[{name:`base`,type:`vec4`},{name:`blend`,type:`vec4`}]}),MW=W(([e])=>IW(e.rgb)),NW=W(([e,t=G(1)])=>t.mix(IW(e.rgb),e.rgb).max(0)),PW=W(([e,t=G(0)])=>{let n=_A(e.r,e.g,e.b).div(3),r=e.r.max(e.g.max(e.b)),i=r.sub(n).mul(t).mul(-3);return Zj(e.rgb,r,i).max(0)}),FW=W(([e,t=G(1)])=>{let n=J(.57735,.57735,.57735),r=t.cos();return J(e.rgb.mul(r).add(n.cross(e.rgb).mul(t.sin()).add(n.mul(Bj(n,e.rgb).mul(r.oneMinus()))))).max(0)}),IW=(e,t=J(jn.getLuminanceCoefficients(new R)))=>Bj(e,t),LW=W(([e,t=J(1),n=J(0),r=J(1),i=G(1),a=J(jn.getLuminanceCoefficients(new R,bt))])=>{let o=e.rgb.dot(J(a)),s=Fj(e.rgb.mul(t).add(n),0),c=s.pow(r);return $O(s.r.greaterThan(0),()=>{s.r.assign(c.r)}),$O(s.g.greaterThan(0),()=>{s.g.assign(c.g)}),$O(s.b.greaterThan(0),()=>{s.b.assign(c.b)}),s.assign(o.add(s.sub(o).mul(i)).max(0)),dk(s.rgb,e.a)}),RW=W(([e,t])=>e.mul(t).floor().div(t)),zW=null,BW=qO(class extends QL{static get type(){return`ViewportSharedTextureNode`}constructor(e=ZN,t=null){zW===null&&(zW=new Fa),super(e,t,zW)}getTextureForReference(){return zW}updateReference(){return this}}).setParameterLength(0,2),VW=new L,HW=class extends NN{static get type(){return`PassTextureNode`}constructor(e,t){super(t),this.passNode=e,this.isPassTextureNode=!0,this.setUpdateMatrix(!1)}setup(e){let t=e.getNodeProperties(this);return t.passNode=this.passNode,super.setup(e)}clone(){return new this.constructor(this.passNode,this.value)}},UW=class extends HW{static get type(){return`PassMultipleTextureNode`}constructor(e,t,n=!1){super(e,null),this.textureName=t,this.previousTexture=n,this.isPassMultipleTextureNode=!0}updateTexture(){this.value=this.previousTexture?this.passNode.getPreviousTexture(this.textureName):this.passNode.getTexture(this.textureName)}setup(e){return this.updateTexture(),super.setup(e)}clone(){let e=new this.constructor(this.passNode,this.textureName,this.previousTexture);return e.uvNode=this.uvNode,e.levelNode=this.levelNode,e.biasNode=this.biasNode,e.sampler=this.sampler,e.depthNode=this.depthNode,e.compareNode=this.compareNode,e.gradNode=this.gradNode,e.gatherNode=this.gatherNode,e.offsetNode=this.offsetNode,e}},WW=class e extends $D{static get type(){return`PassNode`}constructor(t,n,r,i={}){super(`vec4`),this.scope=t,this.scene=n,this.camera=r,this.options=i,this._width=1,this._height=1;let a=new Un(this._width,this._height,{type:pe,...i});a.texture.name=`output`;let o=null;(this.scope===e.DEPTH||i.depthBuffer!==!1)&&(o=new La,o.isRenderTargetTexture=!0,o.name=`depth`,a.depthTexture=o),this.renderTarget=a,this.overrideMaterial=null,this.transparent=!0,this.opaque=!0,this.contextNode=null,this._contextNodeCache=null,this._textures={output:a.texture},o!==null&&(this._textures.depth=o),this._textureNodes={},this._linearDepthNodes={},this._viewZNodes={},this._previousTextures={},this._previousTextureNodes={},this._cameraNear=lA(0),this._cameraFar=lA(0),this._mrt=null,this._layers=null,this._resolutionScale=1,this._viewport=null,this._scissor=null,this.isPassNode=!0,this.updateBeforeType=VD.FRAME,this.global=!0}setResolutionScale(e){return this._resolutionScale=e,this}getResolutionScale(){return this._resolutionScale}setResolution(e){return F(`PassNode: .setResolution() is deprecated. Use .setResolutionScale() instead.`),this.setResolutionScale(e)}getResolution(){return F(`PassNode: .getResolution() is deprecated. Use .getResolutionScale() instead.`),this.getResolutionScale()}setLayers(e){return this._layers=e,this}getLayers(){return this._layers}setMRT(e){return this._mrt=e,this}getMRT(){return this._mrt}getTexture(e){let t=this._textures[e];if(t===void 0){if(e===`depth`)throw Error(`THREE.PassNode: Depth texture is not available for this pass.`);t=this.renderTarget.texture.clone(),t.name=e,this._textures[e]=t,this.renderTarget.textures.push(t)}return t}getPreviousTexture(e){let t=this._previousTextures[e];return t===void 0&&(t=this.getTexture(e).clone(),this._previousTextures[e]=t),t}toggleTexture(e){let t=this._previousTextures[e];if(t!==void 0){let n=this._textures[e],r=this.renderTarget.textures.indexOf(n);this.renderTarget.textures[r]=t,this._textures[e]=t,this._previousTextures[e]=n,this._textureNodes[e].updateTexture(),this._previousTextureNodes[e].updateTexture()}}getTextureNode(e=`output`){let t=this._textureNodes[e];return t===void 0&&(t=new UW(this,e),t.updateTexture(),this._textureNodes[e]=t),t}getPreviousTextureNode(e=`output`){let t=this._previousTextureNodes[e];return t===void 0&&(this._textureNodes[e]===void 0&&this.getTextureNode(e),t=new UW(this,e,!0),t.updateTexture(),this._previousTextureNodes[e]=t),t}getViewZNode(e=`depth`){let t=this._viewZNodes[e];if(t===void 0){let n=this._cameraNear,r=this._cameraFar;this._viewZNodes[e]=t=dR(this.getTextureNode(e),n,r)}return t}getLinearDepthNode(e=`depth`){let t=this._linearDepthNodes[e];if(t===void 0){let n=this._cameraNear,r=this._cameraFar,i=this.getViewZNode(e);this._linearDepthNodes[e]=t=oR(i,n,r)}return t}async compileAsync(e){let t=e.getRenderTarget(),n=e.getMRT();e.setRenderTarget(this.renderTarget),e.setMRT(this._mrt),await e.compileAsync(this.scene,this.camera),e.setRenderTarget(t),e.setMRT(n)}setup({renderer:t}){return this.renderTarget.samples=this.options.samples===void 0?t.samples:this.options.samples,this.renderTarget.texture.type=t.getOutputBufferType(),t.reversedDepthBuffer===!0&&this.renderTarget.depthTexture!==null&&(this.renderTarget.depthTexture.type=fe),this.scope===e.COLOR?this.getTextureNode():this.getLinearDepthNode()}updateBefore(e){let{renderer:t}=e,{scene:n}=this,r,i=t.getOutputRenderTarget();i&&i.isXRRenderTarget===!0?(r=t.xr.getCamera(),t.xr.updateCamera(r),VW.set(i.width,i.height)):(r=this.camera,t.getDrawingBufferSize(VW)),this.setSize(VW.width,VW.height);let a=t.getRenderTarget(),o=t.getMRT(),s=t.autoClear,c=t.transparent,l=t.opaque,u=r.layers.mask,d=t.contextNode,f=n.overrideMaterial;for(let e in this._cameraNear.value=r.near,this._cameraFar.value=r.far,this._layers!==null&&(r.layers.mask=this._layers.mask),this._previousTextures)this.toggleTexture(e);this.overrideMaterial!==null&&(n.overrideMaterial=this.overrideMaterial),t.setRenderTarget(this.renderTarget),t.setMRT(this._mrt),t.autoClear=!0,t.transparent=this.transparent,t.opaque=this.opaque,this.contextNode!==null&&((this._contextNodeCache===null||this._contextNodeCache.version!==this.version)&&(this._contextNodeCache={version:this.version,context:dM({...t.contextNode.getFlowContextData(),...this.contextNode.getFlowContextData()})}),t.contextNode=this._contextNodeCache.context);let p=n.name;n.name=this.name?this.name:n.name,t.render(n,r),n.name=p,n.overrideMaterial=f,t.setRenderTarget(a),t.setMRT(o),t.autoClear=s,t.transparent=c,t.opaque=l,t.contextNode=d,r.layers.mask=u}setSize(e,t){this._width=e,this._height=t;let n=Math.floor(this._width*this._resolutionScale),r=Math.floor(this._height*this._resolutionScale);this.renderTarget.setSize(n,r),this._scissor===null?this.renderTarget.scissorTest=!1:(this.renderTarget.scissor.copy(this._scissor).multiplyScalar(this._resolutionScale).floor(),this.renderTarget.scissorTest=!0),this._viewport!==null&&this.renderTarget.viewport.copy(this._viewport).multiplyScalar(this._resolutionScale).floor()}setScissor(e,t,n,r){e===null?this._scissor=null:(this._scissor===null&&(this._scissor=new Hn),e.isVector4?this._scissor.copy(e):this._scissor.set(e,t,n,r))}setViewport(e,t,n,r){e===null?this._viewport=null:(this._viewport===null&&(this._viewport=new Hn),e.isVector4?this._viewport.copy(e):this._viewport.set(e,t,n,r))}dispose(){this.renderTarget.dispose()}};WW.COLOR=`color`,WW.DEPTH=`depth`;var GW=(e,t,n)=>new WW(WW.COLOR,e,t,n),KW=(e,t)=>new HW(e,t),qW=(e,t,n)=>new WW(WW.DEPTH,e,t,n),JW=class extends WW{static get type(){return`ToonOutlinePassNode`}constructor(e,t,n,r,i){super(WW.COLOR,e,t),this.colorNode=n,this.thicknessNode=r,this.alphaNode=i,this._materialCache=new WeakMap,this.name=`Outline Pass`}updateBefore(e){let{renderer:t}=e,n=t.getRenderObjectFunction();t.setRenderObjectFunction((e,n,r,i,a,o,s,c)=>{if((a.isMeshToonMaterial||a.isMeshToonNodeMaterial)&&a.wireframe===!1){let l=this._getOutlineMaterial(a);t.renderObject(e,n,r,i,l,o,s,c)}t.renderObject(e,n,r,i,a,o,s,c)}),super.updateBefore(e),t.setRenderObjectFunction(n)}_createMaterial(){let e=new OR;e.isMeshToonOutlineMaterial=!0,e.name=`Toon_Outline`,e.side=1;let t=lF.negate(),n=SP.mul(KP),r=G(1),i=n.mul(dk(QP,1)),a=n.mul(dk(QP.add(t),1)),o=oj(i.sub(a));return e.vertexNode=i.add(o.mul(this.thicknessNode).mul(i.w).mul(r)),e.colorNode=dk(this.colorNode,this.alphaNode),e}_getOutlineMaterial(e){let t=this._materialCache.get(e);return t===void 0&&(t=this._createMaterial(),this._materialCache.set(e,t)),t}},YW=(e,t,n=new Er(0,0,0),r=.003,i=1)=>new JW(e,t,UO(n),UO(r),UO(i)),XW=W(([e,t])=>e.mul(t).clamp()).setLayout({name:`linearToneMapping`,type:`vec3`,inputs:[{name:`color`,type:`vec3`},{name:`exposure`,type:`float`}]}),ZW=W(([e,t])=>(e=e.mul(t),e.div(e.add(1)).clamp())).setLayout({name:`reinhardToneMapping`,type:`vec3`,inputs:[{name:`color`,type:`vec3`},{name:`exposure`,type:`float`}]}),QW=W(([e,t])=>{e=e.mul(t),e=e.sub(.004).max(0);let n=e.mul(e.mul(6.2).add(.5)),r=e.mul(e.mul(6.2).add(1.7)).add(.06);return n.div(r).pow(2.2)}).setLayout({name:`cineonToneMapping`,type:`vec3`,inputs:[{name:`color`,type:`vec3`},{name:`exposure`,type:`float`}]}),$W=W(([e])=>{let t=e.mul(e.add(.0245786)).sub(90537e-9),n=e.mul(e.add(.432951).mul(.983729)).add(.238081);return t.div(n)}),eG=W(([e,t])=>{let n=gk(.59719,.35458,.04823,.076,.90834,.01566,.0284,.13383,.83777),r=gk(1.60475,-.53108,-.07367,-.10208,1.10813,-.00605,-.00327,-.07276,1.07602);return e=e.mul(t).div(.6),e=n.mul(e),e=$W(e),e=r.mul(e),e.clamp()}).setLayout({name:`acesFilmicToneMapping`,type:`vec3`,inputs:[{name:`color`,type:`vec3`},{name:`exposure`,type:`float`}]}),tG=gk(J(1.6605,-.1246,-.0182),J(-.5876,1.1329,-.1006),J(-.0728,-.0083,1.1187)),nG=gk(J(.6274,.0691,.0164),J(.3293,.9195,.088),J(.0433,.0113,.8956)),rG=W(([e])=>{let t=J(e).toVar(),n=J(t.mul(t)).toVar(),r=J(n.mul(n)).toVar();return G(15.5).mul(r.mul(n)).sub(yA(40.14,r.mul(t))).add(yA(31.96,r).sub(yA(6.868,n.mul(t))).add(yA(.4298,n).add(yA(.1191,t).sub(.00232))))}),iG=W(([e,t])=>{let n=J(e).toVar(),r=gk(J(.856627153315983,.137318972929847,.11189821299995),J(.0951212405381588,.761241990602591,.0767994186031903),J(.0482516061458583,.101439036467562,.811302368396859)),i=gk(J(1.1271005818144368,-.1413297634984383,-.14132976349843826),J(-.11060664309660323,1.157823702216272,-.11060664309660294),J(-.016493938717834573,-.016493938717834257,1.2519364065950405)),a=G(-12.47393),o=G(4.026069);return n.mulAssign(t),n.assign(nG.mul(n)),n.assign(r.mul(n)),n.assign(Fj(n,1e-10)),n.assign(tj(n)),n.assign(n.sub(a).div(o.sub(a))),n.assign(Qj(n,0,1)),n.assign(rG(n)),n.assign(i.mul(n)),n.assign(Hj(Fj(J(0),n),J(2.2))),n.assign(tG.mul(n)),n.assign(Qj(n,0,1)),n}).setLayout({name:`agxToneMapping`,type:`vec3`,inputs:[{name:`color`,type:`vec3`},{name:`exposure`,type:`float`}]}),aG=W(([e,t])=>{let n=G(.76),r=G(.15);e=e.mul(t);let i=Pj(e.r,Pj(e.g,e.b)),a=lM(i.lessThan(.08),i.sub(yA(6.25,i.mul(i))),.04);e.subAssign(a);let o=Fj(e.r,Fj(e.g,e.b));$O(o.lessThan(n),()=>e);let s=vA(1,n),c=vA(1,s.mul(s).div(o.add(s.sub(n))));e.mulAssign(c.div(o));let l=vA(1,bA(1,r.mul(o.sub(c)).add(1)));return Zj(e,J(c),l)}).setLayout({name:`neutralToneMapping`,type:`vec3`,inputs:[{name:`color`,type:`vec3`},{name:`exposure`,type:`float`}]}),oG=class extends XD{static get type(){return`CodeNode`}constructor(e=``,t=[],n=``){super(`code`),this.isCodeNode=!0,this.global=!0,this.code=e,this.includes=t,this.language=n}setIncludes(e){return this.includes=e,this}getIncludes(){return this.includes}generate(e){let t=this.getIncludes(e);for(let n of t)n.build(e);let n=e.getCodeFromNode(this,this.getNodeType(e));return n.code=this.code,n.code}serialize(e){super.serialize(e),e.code=this.code,e.language=this.language}deserialize(e){super.deserialize(e),this.code=e.code,this.language=e.language}},sG=qO(oG).setParameterLength(1,3),cG=(e,t)=>sG(e,t,`js`),lG=(e,t)=>sG(e,t,`wgsl`),uG=(e,t)=>sG(e,t,`glsl`),dG=class extends oG{static get type(){return`FunctionNode`}constructor(e=``,t=[],n=``){super(e,t,n)}generateNodeType(e){return this.getNodeFunction(e).type}getMemberType(e,t){let n=this.getNodeType(e);return e.getStructTypeNode(n).getMemberType(e,t)}getInputs(e){return this.getNodeFunction(e).inputs}getNodeFunction(e){let t=e.getDataFromNode(this),n=t.nodeFunction;return n===void 0&&(n=e.parser.parseFunction(this.code),t.nodeFunction=n),n}generate(e,t){super.generate(e);let n=this.getNodeFunction(e),r=n.name,i=n.type,a=e.getCodeFromNode(this,i);r!==``&&(a.name=r);let o=e.getPropertyName(a);return a.code=this.getNodeFunction(e).getCode(o)+` `,t===`property`?o:e.format(`${o}()`,i,t)}},fG=(e,t=[],n=``)=>{let r=new dG(e,t,n);return YO((...e)=>r.call(...e),r)},pG=(e,t)=>fG(e,t,`glsl`),mG=(e,t)=>fG(e,t,`wgsl`);function hG(e){let t,n=e.context.getViewZ;return n!==void 0&&(t=n(this)),(t||nF.z).negate()}var gG=W(([e,t],n)=>tM(e,t,hG(n))),_G=W(([e],t)=>{let n=hG(t);return e.mul(e,n,n).negate().exp().oneMinus()}),vG=W(([e,t],n)=>{let r=hG(n),i=t.sub(eF.y).max(0).toConst().mul(r).toConst();return e.mul(e,i,i).negate().exp().oneMinus()}),yG=W(([e,t])=>dk(t.toFloat().mix(Gk.rgb,e.toVec3()),Gk.a)),bG=null,xG=null,SG=qO(class extends XD{static get type(){return`RangeNode`}constructor(e=G(),t=G()){super(),this.minNode=e,this.maxNode=t}getVectorLength(e){let t=this.getConstNode(this.minNode),n=this.getConstNode(this.maxNode),r=e.getTypeLength(FD(t.value)),i=e.getTypeLength(FD(n.value));return r>i?r:i}generateNodeType(e){return e.object.count>1?e.getTypeFromLength(this.getVectorLength(e)):`float`}getConstNode(e){let t=null;if(e.traverse(e=>{e.isConstNode===!0&&(t=e)}),t===null)throw new jN(`THREE.TSL: No "ConstNode" found in node graph.`,this.stackTrace);return t}setup(e){let t=e.object,n=null;if(t.count>1){let r=this.getConstNode(this.minNode),i=this.getConstNode(this.maxNode),a=r.value,o=i.value,s=e.getTypeLength(FD(a)),c=e.getTypeLength(FD(o));bG||=new Hn,xG||=new Hn,bG.setScalar(0),xG.setScalar(0),s===1?bG.setScalar(a):a.isColor?bG.set(a.r,a.g,a.b,1):bG.set(a.x,a.y,a.z||0,a.w||0),c===1?xG.setScalar(o):o.isColor?xG.set(o.r,o.g,o.b,1):xG.set(o.x,o.y,o.z||0,o.w||0);let l=4*t.count,u=new Float32Array(l);for(let e=0;enew CG(e,t),TG=wG(`numWorkgroups`,`uvec3`),EG=wG(`workgroupId`,`uvec3`),DG=wG(`globalId`,`uvec3`),OG=wG(`localId`,`uvec3`),kG=wG(`subgroupSize`,`uint`),AG=qO(class extends XD{constructor(e){super(),this.scope=e,this.isBarrierNode=!0}setup(e){e.allowEarlyReturns=!1,e.allowGlobalVariables=!1}generate(e){let{scope:t}=this,{renderer:n}=e;n.backend.isWebGLBackend===!0?e.addFlowCode(`\t// ${t}Barrier \n`):e.addLineFlowCode(`${t}Barrier()`,this)}}),jG=()=>AG(`workgroup`).toStack(),MG=()=>AG(`storage`).toStack(),NG=()=>AG(`texture`).toStack(),PG=class extends ZD{constructor(e,t){super(e,t),this.isWorkgroupInfoElementNode=!0}generate(e,t){let n,r=e.isContextAssign();if(n=super.generate(e),r!==!0){let r=this.getNodeType(e);n=e.format(n,r,t)}return n}},FG=class extends XD{constructor(e,t,n=0){super(t),this.bufferType=t,this.bufferCount=n,this.isWorkgroupInfoNode=!0,this.elementType=t,this.scope=e,this.name=``}setName(e){return this.name=e,this}label(e){return F(`TSL: "label()" has been deprecated. Use "setName()" instead.`,new CD),this.setName(e)}setScope(e){return this.scope=e,this}getElementType(){return this.elementType}getInputType(){return`${this.scope}Array`}element(e){return new PG(this,e)}generate(e){let t=this.name===``?`${this.scope}Array_${this.id}`:this.name;return e.getScopedArray(t,this.scope.toLowerCase(),this.bufferType,this.bufferCount)}},IG=(e,t)=>new FG(`Workgroup`,e,t),LG=class extends XD{static get type(){return`AtomicFunctionNode`}constructor(e,t,n){super(`uint`),this.method=e,this.pointerNode=t,this.valueNode=n,this.parents=!0}getInputType(e){return this.pointerNode.getNodeType(e)}generateNodeType(e){return this.getInputType(e)}generate(e){let t=e.getNodeProperties(this),n=t.parents,r=this.method,i=this.getNodeType(e),a=this.getInputType(e),o=this.pointerNode,s=this.valueNode,c=[];c.push(`&${o.build(e,a)}`),s!==null&&c.push(s.build(e,a));let l=`${e.getMethod(r,i)}( ${c.join(`, `)} )`;if(n&&n.length===1&&n[0].isStackNode===!0)e.addLineFlowCode(l,this);else return t.constNode===void 0&&(t.constNode=pN(l,i).toConst()),t.constNode.build(e)}};LG.ATOMIC_LOAD=`atomicLoad`,LG.ATOMIC_STORE=`atomicStore`,LG.ATOMIC_ADD=`atomicAdd`,LG.ATOMIC_SUB=`atomicSub`,LG.ATOMIC_MAX=`atomicMax`,LG.ATOMIC_MIN=`atomicMin`,LG.ATOMIC_AND=`atomicAnd`,LG.ATOMIC_OR=`atomicOr`,LG.ATOMIC_XOR=`atomicXor`;var RG=qO(LG),zG=(e,t,n)=>RG(e,t,n).toStack(),BG=e=>zG(LG.ATOMIC_LOAD,e,null),VG=(e,t)=>zG(LG.ATOMIC_STORE,e,t),HG=(e,t)=>zG(LG.ATOMIC_ADD,e,t),UG=(e,t)=>zG(LG.ATOMIC_SUB,e,t),WG=(e,t)=>zG(LG.ATOMIC_MAX,e,t),GG=(e,t)=>zG(LG.ATOMIC_MIN,e,t),KG=(e,t)=>zG(LG.ATOMIC_AND,e,t),qG=(e,t)=>zG(LG.ATOMIC_OR,e,t),JG=(e,t)=>zG(LG.ATOMIC_XOR,e,t),YG=class e extends $D{static get type(){return`SubgroupFunctionNode`}constructor(e,t=null,n=null){super(),this.method=e,this.aNode=t,this.bNode=n}getInputType(e){let t=this.aNode?this.aNode.getNodeType(e):null,n=this.bNode?this.bNode.getNodeType(e):null;return(e.isMatrix(t)?0:e.getTypeLength(t))>(e.isMatrix(n)?0:e.getTypeLength(n))?t:n}generateNodeType(t){let n=this.method;return n===e.SUBGROUP_ELECT?`bool`:n===e.SUBGROUP_BALLOT?`uvec4`:this.getInputType(t)}generate(t,n){let r=this.method,i=this.getNodeType(t),a=this.getInputType(t),o=this.aNode,s=this.bNode,c=[];if(r===e.SUBGROUP_BROADCAST||r===e.SUBGROUP_SHUFFLE||r===e.QUAD_BROADCAST){let e=s.getNodeType(t);c.push(o.build(t,i),s.build(t,e===`float`?`int`:i))}else r===e.SUBGROUP_SHUFFLE_XOR||r===e.SUBGROUP_SHUFFLE_DOWN||r===e.SUBGROUP_SHUFFLE_UP?c.push(o.build(t,i),s.build(t,`uint`)):(o!==null&&c.push(o.build(t,a)),s!==null&&c.push(s.build(t,a)));let l=c.length===0?`()`:`( ${c.join(`, `)} )`;return t.format(`${t.getMethod(r,i)}${l}`,i,n)}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}};YG.SUBGROUP_ELECT=`subgroupElect`,YG.SUBGROUP_BALLOT=`subgroupBallot`,YG.SUBGROUP_ADD=`subgroupAdd`,YG.SUBGROUP_INCLUSIVE_ADD=`subgroupInclusiveAdd`,YG.SUBGROUP_EXCLUSIVE_AND=`subgroupExclusiveAdd`,YG.SUBGROUP_MUL=`subgroupMul`,YG.SUBGROUP_INCLUSIVE_MUL=`subgroupInclusiveMul`,YG.SUBGROUP_EXCLUSIVE_MUL=`subgroupExclusiveMul`,YG.SUBGROUP_AND=`subgroupAnd`,YG.SUBGROUP_OR=`subgroupOr`,YG.SUBGROUP_XOR=`subgroupXor`,YG.SUBGROUP_MIN=`subgroupMin`,YG.SUBGROUP_MAX=`subgroupMax`,YG.SUBGROUP_ALL=`subgroupAll`,YG.SUBGROUP_ANY=`subgroupAny`,YG.SUBGROUP_BROADCAST_FIRST=`subgroupBroadcastFirst`,YG.QUAD_SWAP_X=`quadSwapX`,YG.QUAD_SWAP_Y=`quadSwapY`,YG.QUAD_SWAP_DIAGONAL=`quadSwapDiagonal`,YG.SUBGROUP_BROADCAST=`subgroupBroadcast`,YG.SUBGROUP_SHUFFLE=`subgroupShuffle`,YG.SUBGROUP_SHUFFLE_XOR=`subgroupShuffleXor`,YG.SUBGROUP_SHUFFLE_UP=`subgroupShuffleUp`,YG.SUBGROUP_SHUFFLE_DOWN=`subgroupShuffleDown`,YG.QUAD_BROADCAST=`quadBroadcast`;var XG=U(YG,YG.SUBGROUP_ELECT).setParameterLength(0),ZG=U(YG,YG.SUBGROUP_BALLOT).setParameterLength(1),QG=U(YG,YG.SUBGROUP_ADD).setParameterLength(1),$G=U(YG,YG.SUBGROUP_INCLUSIVE_ADD).setParameterLength(1),eK=U(YG,YG.SUBGROUP_EXCLUSIVE_AND).setParameterLength(1),tK=U(YG,YG.SUBGROUP_MUL).setParameterLength(1),nK=U(YG,YG.SUBGROUP_INCLUSIVE_MUL).setParameterLength(1),rK=U(YG,YG.SUBGROUP_EXCLUSIVE_MUL).setParameterLength(1),iK=U(YG,YG.SUBGROUP_AND).setParameterLength(1),aK=U(YG,YG.SUBGROUP_OR).setParameterLength(1),oK=U(YG,YG.SUBGROUP_XOR).setParameterLength(1),sK=U(YG,YG.SUBGROUP_MIN).setParameterLength(1),cK=U(YG,YG.SUBGROUP_MAX).setParameterLength(1),lK=U(YG,YG.SUBGROUP_ALL).setParameterLength(0),uK=U(YG,YG.SUBGROUP_ANY).setParameterLength(0),dK=U(YG,YG.SUBGROUP_BROADCAST_FIRST).setParameterLength(2),fK=U(YG,YG.QUAD_SWAP_X).setParameterLength(1),pK=U(YG,YG.QUAD_SWAP_Y).setParameterLength(1),mK=U(YG,YG.QUAD_SWAP_DIAGONAL).setParameterLength(1),hK=U(YG,YG.SUBGROUP_BROADCAST).setParameterLength(2),gK=U(YG,YG.SUBGROUP_SHUFFLE).setParameterLength(2),_K=U(YG,YG.SUBGROUP_SHUFFLE_XOR).setParameterLength(2),vK=U(YG,YG.SUBGROUP_SHUFFLE_UP).setParameterLength(2),yK=U(YG,YG.SUBGROUP_SHUFFLE_DOWN).setParameterLength(2),bK=U(YG,YG.QUAD_BROADCAST).setParameterLength(1),xK;function SK(e){xK||=new WeakMap;let t=xK.get(e);return t===void 0&&xK.set(e,t={}),t}function CK(e){let t=SK(e);return t.shadowMatrix||=lA(`mat4`).setGroup(oA).onRenderUpdate(t=>((e.castShadow!==!0||t.renderer.shadowMap.enabled===!1)&&(e.shadow.camera.coordinateSystem!==t.camera.coordinateSystem&&(e.shadow.camera.coordinateSystem=t.camera.coordinateSystem,e.shadow.camera.updateProjectionMatrix()),e.shadow.updateMatrices(e)),e.shadow.matrix))}function wK(e,t=eF){let n=CK(e).mul(t);return n.xyz.div(n.w)}function TK(e){let t=SK(e);return t.position||=lA(new R).setGroup(oA).onRenderUpdate((t,n)=>n.value.setFromMatrixPosition(e.matrixWorld))}function EK(e){let t=SK(e);return t.targetPosition||=lA(new R).setGroup(oA).onRenderUpdate((t,n)=>n.value.setFromMatrixPosition(e.target.matrixWorld))}function DK(e){let t=SK(e);return t.viewPosition||=lA(new R).setGroup(oA).onRenderUpdate(({camera:t},n)=>{n.value=n.value||new R,n.value.setFromMatrixPosition(e.matrixWorld),n.value.applyMatrix4(t.matrixWorldInverse)})}var OK=e=>wP.transformDirection(TK(e).sub(EK(e))),kK=Ck(`vec3`,`totalDiffuse`),AK=Ck(`vec3`,`totalSpecular`),jK=Ck(`vec3`,`outgoingLight`),MK=e=>e.sort((e,t)=>e.id-t.id),NK=(e,t)=>{for(let n of t)if(n.isAnalyticLightNode&&n.light.id===e)return n;return null},PK=new WeakMap,FK=[],IK=class extends XD{static get type(){return`LightsNode`}constructor(){super(`vec3`),this.totalDiffuseNode=kK,this.totalSpecularNode=AK,this.outgoingLightNode=jK,this._lights=[],this.global=!0}customCacheKey(){let e=this._lights;for(let t=0;t0}},LK=(e=[])=>new IK().setLights(e),RK=class extends XD{static get type(){return`ShadowBaseNode`}constructor(e){super(),this.light=e,this.updateBeforeType=VD.RENDER,this.isShadowBaseNode=!0}setupShadowPosition({context:e,material:t}){zK.assign(t.receivedShadowPositionNode||e.shadowPositionWorld||eF)}},zK=Ck(`vec3`,`shadowPositionWorld`);function BK(e,t={}){return t.toneMapping=e.toneMapping,t.toneMappingExposure=e.toneMappingExposure,t.outputColorSpace=e.outputColorSpace,t.renderTarget=e.getRenderTarget(),t.activeCubeFace=e.getActiveCubeFace(),t.activeMipmapLevel=e.getActiveMipmapLevel(),t.renderObjectFunction=e.getRenderObjectFunction(),t.pixelRatio=e.getPixelRatio(),t.mrt=e.getMRT(),t.clearColor=e.getClearColor(t.clearColor||new Er),t.clearAlpha=e.getClearAlpha(),t.autoClear=e.autoClear,t.scissorTest=e.getScissorTest(),t}function VK(e,t){return t=BK(e,t),e.setMRT(null),e.setRenderObjectFunction(null),e.setClearColor(0,1),e.autoClear=!0,t}function HK(e,t){e.toneMapping=t.toneMapping,e.toneMappingExposure=t.toneMappingExposure,e.outputColorSpace=t.outputColorSpace,e.setRenderTarget(t.renderTarget,t.activeCubeFace,t.activeMipmapLevel),e.setRenderObjectFunction(t.renderObjectFunction),e.setPixelRatio(t.pixelRatio),e.setMRT(t.mrt),e.setClearColor(t.clearColor,t.clearAlpha),e.autoClear=t.autoClear,e.setScissorTest(t.scissorTest)}function UK(e,t={}){return t.background=e.background,t.backgroundNode=e.backgroundNode,t.overrideMaterial=e.overrideMaterial,t}function WK(e,t){return t=UK(e,t),e.background=null,e.backgroundNode=null,e.overrideMaterial=null,t}function GK(e,t){e.background=t.background,e.backgroundNode=t.backgroundNode,e.overrideMaterial=t.overrideMaterial}function KK(e,t,n){return n=VK(e,n),n=WK(t,n),n}function qK(e,t,n){HK(e,n),GK(t,n)}var JK=new WeakMap,YK=W(({depthTexture:e,shadowCoord:t,depthLayer:n})=>{let r=FN(e,t.xy).setName(`t_basic`);return e.isArrayTexture&&(r=r.depth(n)),r.compare(t.z)}),XK=W(({depthTexture:e,shadowCoord:t,shadow:n,depthLayer:r})=>{let i=(t,n)=>{let i=FN(e,t);return e.isArrayTexture&&(i=i.depth(r)),i.compare(n)},a=FF(`mapSize`,`vec2`,n).setGroup(oA),o=FF(`radius`,`float`,n).setGroup(oA),s=ik(1).div(a),c=o.mul(s.x),l=$U($N.xy).mul(6.28318530718);return _A(i(t.xy.add(eW(0,5,l).mul(c)),t.z),i(t.xy.add(eW(1,5,l).mul(c)),t.z),i(t.xy.add(eW(2,5,l).mul(c)),t.z),i(t.xy.add(eW(3,5,l).mul(c)),t.z),i(t.xy.add(eW(4,5,l).mul(c)),t.z)).mul(1/5)}),ZK=W(({depthTexture:e,shadowCoord:t,shadow:n,depthLayer:r})=>{let i=FF(`mapSize`,`vec2`,n).setGroup(oA),a=ik(1).div(i),o=t.xy,s=sj(o.mul(i).add(.5)).toConst();o.subAssign(s.sub(.5).mul(a));let c=n=>{let i=FN(e,o).offset(n).gather();return e.isArrayTexture&&(i=i.depth(r)),i.compare(t.z)},l=c(ak(-1,1)).toConst(),u=c(ak(1,1)).toConst(),d=c(ak(-1,-1)).toConst(),f=c(ak(1,-1)).toConst();return _A(Zj(l.x,u.y,s.x).add(l.y).add(u.x).mul(s.y),Zj(l.w,u.z,s.x).add(l.z).add(u.w),Zj(d.x,f.y,s.x).add(d.y).add(f.x),Zj(d.w,f.z,s.x).add(d.z).add(f.w).mul(s.y.oneMinus())).mul(1/9)}),QK=W(({depthTexture:e,shadowCoord:t,depthLayer:n},r)=>{let i=FN(e).sample(t.xy);e.isArrayTexture&&(i=i.depth(n)),i=i.rg;let a=i.x,o=Fj(1e-7,i.y.mul(i.y)),s=r.renderer.reversedDepthBuffer?Ij(a,t.z):Ij(t.z,a),c=G(1).toVar();return $O(s.notEqual(1),()=>{let e=t.z.sub(a),n=o.div(o.add(e.mul(e)));n=Qj(vA(n,.3).div(.65)),c.assign(Fj(s,n))}),c}),$K=e=>{let t=JK.get(e);return t===void 0&&(t=new OR,t.colorNode=dk(0,0,0,1),t.isShadowPassMaterial=!0,t.name=`ShadowMaterial`,t.blending=0,t.fog=!1,JK.set(e,t)),t},eq=e=>{let t=JK.get(e);t!==void 0&&(t.dispose(),JK.delete(e))},tq=new PV,nq=[],rq=(e,t,n,r)=>{nq[0]=e,nq[1]=t;let i=tq.get(nq);return(i===void 0||i.shadowType!==n||i.useVelocity!==r)&&(i=(i,a,o,s,c,l,u,d,f)=>{(i.castShadow===!0||i.receiveShadow&&n===3)&&(r&&(LD(i).useVelocity=!0),i.onBeforeShadow(e,i,o,t.camera,s,a.overrideMaterial,l),e.renderObject(i,a,o,s,c,l,u,d,f),i.onAfterShadow(e,i,o,t.camera,s,a.overrideMaterial,l))},i.shadowType=n,i.useVelocity=r,tq.set(nq,i)),nq[0]=null,nq[1]=null,i},iq=W(({samples:e,radius:t,size:n,shadowPass:r,depthLayer:i})=>{let a=G(0).toVar(`meanVertical`),o=G(0).toVar(`squareMeanVertical`),s=e.lessThanEqual(G(1)).select(G(0),G(2).div(e.sub(1))),c=e.lessThanEqual(G(1)).select(G(0),G(-1));return RL({start:K(0),end:K(e),type:`int`,condition:`<`},({i:e})=>{let l=c.add(G(e).mul(s)),u=r.sample(_A($N.xy,ik(0,l).mul(t)).div(n));r.value.isArrayTexture&&(u=u.depth(i)),u=u.x,a.addAssign(u),o.addAssign(u.mul(u))}),a.divAssign(e),o.divAssign(e),ik(a,nj(o.sub(a.mul(a)).max(0)))}),aq=W(({samples:e,radius:t,size:n,shadowPass:r,depthLayer:i})=>{let a=G(0).toVar(`meanHorizontal`),o=G(0).toVar(`squareMeanHorizontal`),s=e.lessThanEqual(G(1)).select(G(0),G(2).div(e.sub(1))),c=e.lessThanEqual(G(1)).select(G(0),G(-1));return RL({start:K(0),end:K(e),type:`int`,condition:`<`},({i:e})=>{let l=c.add(G(e).mul(s)),u=r.sample(_A($N.xy,ik(l,0).mul(t)).div(n));r.value.isArrayTexture&&(u=u.depth(i)),a.addAssign(u.x),o.addAssign(_A(u.y.mul(u.y),u.x.mul(u.x)))}),a.divAssign(e),o.divAssign(e),ik(a,nj(o.sub(a.mul(a)).max(0)))}),oq=[YK,XK,ZK,QK],sq,cq=new GU,lq=class extends RK{static get type(){return`ShadowNode`}constructor(e,t=null){super(e),this.shadow=t||e.shadow,this.shadowMap=null,this.vsmShadowMapVertical=null,this.vsmShadowMapHorizontal=null,this.vsmMaterialVertical=null,this.vsmMaterialHorizontal=null,this._node=null,this._currentShadowType=null,this._cameraFrameId=new WeakMap,this.isShadowNode=!0,this.depthLayer=0}setupShadowFilter(e,{filterFn:t,depthTexture:n,shadowCoord:r,shadow:i,depthLayer:a}){let o=r.x.greaterThanEqual(0).and(r.x.lessThanEqual(1)).and(r.y.greaterThanEqual(0)).and(r.y.lessThanEqual(1)).and(r.z.lessThanEqual(1)),s=t({depthTexture:n,shadowCoord:r,shadow:i,depthLayer:a});return o.select(s,G(1))}setupShadowCoord(e,t){let{shadow:n}=this,{renderer:r}=e,i=n.biasNode||FF(`bias`,`float`,n).setGroup(oA),a=t,o;if(n.camera.isOrthographicCamera||r.logarithmicDepthBuffer!==!0)a=a.xyz.div(a.w),o=a.z;else{let e=a.w;a=a.xy.div(e);let t=FF(`near`,`float`,n.camera).setGroup(oA),r=FF(`far`,`float`,n.camera).setGroup(oA);o=fR(e.negate(),t,r)}return a=J(a.x,a.y.oneMinus(),r.reversedDepthBuffer?o.sub(i):o.add(i)),a}getShadowFilterFn(e){return oq[e]}setupRenderTarget(e,t){let n=new La(e.mapSize.width,e.mapSize.height);n.name=`ShadowDepthTexture`,n.compareFunction=t.renderer.reversedDepthBuffer?518:515;let r=t.createRenderTarget(e.mapSize.width,e.mapSize.height);return r.texture.name=`ShadowMap`,r.texture.type=e.mapType,r.depthTexture=n,{shadowMap:r,depthTexture:n}}setupShadow(e){let{renderer:t,camera:n}=e,{light:r,shadow:i}=this,{depthTexture:a,shadowMap:o}=this.setupRenderTarget(i,e),s=t.shadowMap.type,c=t.hasCompatibility(Ft.TEXTURE_COMPARE);if((s===1||s===2)&&c?(a.minFilter=ne,a.magFilter=ne):(a.minFilter=N,a.magFilter=N),i.camera.coordinateSystem=n.coordinateSystem,i.camera.updateProjectionMatrix(),s===3&&i.isPointLightShadow!==!0){a.compareFunction=null,o.depth>1?(o._vsmShadowMapVertical||(o._vsmShadowMapVertical=e.createRenderTarget(i.mapSize.width,i.mapSize.height,{format:Ee,type:pe,depth:o.depth,depthBuffer:!1}),o._vsmShadowMapVertical.texture.name=`VSMVertical`),this.vsmShadowMapVertical=o._vsmShadowMapVertical,o._vsmShadowMapHorizontal||(o._vsmShadowMapHorizontal=e.createRenderTarget(i.mapSize.width,i.mapSize.height,{format:Ee,type:pe,depth:o.depth,depthBuffer:!1}),o._vsmShadowMapHorizontal.texture.name=`VSMHorizontal`),this.vsmShadowMapHorizontal=o._vsmShadowMapHorizontal):(this.vsmShadowMapVertical=e.createRenderTarget(i.mapSize.width,i.mapSize.height,{format:Ee,type:pe,depthBuffer:!1}),this.vsmShadowMapHorizontal=e.createRenderTarget(i.mapSize.width,i.mapSize.height,{format:Ee,type:pe,depthBuffer:!1}));let t=FN(a);a.isArrayTexture&&(t=t.depth(this.depthLayer));let n=FN(this.vsmShadowMapVertical.texture);a.isArrayTexture&&(n=n.depth(this.depthLayer));let r=FF(`blurSamples`,`float`,i).setGroup(oA),s=FF(`radius`,`float`,i).setGroup(oA),c=FF(`mapSize`,`vec2`,i).setGroup(oA),l=this.vsmMaterialVertical||=new OR;l.fragmentNode=iq({samples:r,radius:s,size:c,shadowPass:t,depthLayer:this.depthLayer}).context(e.getSharedContext()),l.name=`VSMVertical`,l=this.vsmMaterialHorizontal||=new OR,l.fragmentNode=aq({samples:r,radius:s,size:c,shadowPass:n,depthLayer:this.depthLayer}).context(e.getSharedContext()),l.name=`VSMHorizontal`}let l=FF(`intensity`,`float`,i).setGroup(oA),u=FF(`normalBias`,`float`,i).setGroup(oA),d=CK(r),f=mF.mul(u),p;p=!t.highPrecision||e.material.receivedShadowPositionNode||e.context.shadowPositionWorld?d.mul(zK.add(f)):lA(`mat4`).onObjectUpdate(({object:e},t)=>t.value.multiplyMatrices(d.value,e.matrixWorld)).mul(QP).add(d.mul(dk(f,0)));let m=this.setupShadowCoord(e,p),h=i.filterNode||this.getShadowFilterFn(t.shadowMap.type)||null;if(h===null)throw Error(`THREE.WebGPURenderer: Shadow map type not supported yet.`);let g=s===3&&i.isPointLightShadow!==!0?this.vsmShadowMapHorizontal.texture:a,_=this.setupShadowFilter(e,{filterFn:h,shadowTexture:o.texture,depthTexture:g,shadowCoord:m,shadow:i,depthLayer:this.depthLayer}),v;t.shadowMap.transmitted===!0&&(o.texture.isCubeTexture?v=jF(o.texture,m.xyz):(v=FN(o.texture,m),a.isArrayTexture&&(v=v.depth(this.depthLayer))));let y;y=v?Zj(1,_.rgb.mix(v,1),l.mul(v.a)).toVar():Zj(1,_,l).toVar(),this.shadowMap=o,this.shadow.map=o;let b=`${this.light.type} Shadow [ ${this.light.name||`ID: `+this.light.id} ]`;return v&&y.toInspector(`${b} / Color`,()=>this.shadowMap.texture.isCubeTexture?jF(this.shadowMap.texture,HR()):FN(this.shadowMap.texture)),y.toInspector(`${b} / Depth`,()=>{let e=FF(`near`,`float`,this.shadow.camera),t=FF(`far`,`float`,this.shadow.camera),n;n=this.shadowMap.texture.isCubeTexture?jF(this.shadowMap.depthTexture,HR()).r:FN(this.shadowMap.depthTexture).r;let r;return r=this.shadow.camera.isPerspectiveCamera?dR(n,e,t):cR(n,e,t),r=oR(r,e,t),r.oneMinus()})}setup(e){if(e.renderer.shadowMap.enabled!==!1)return W(()=>{let t=e.renderer.shadowMap.type;this._currentShadowType!==t&&(this._reset(),this._node=null);let n=this._node;return this.setupShadowPosition(e),n===null&&(this._node=n=this.setupShadow(e),this._currentShadowType=t),e.material.receivedShadowNode&&(n=e.material.receivedShadowNode(n)),n})()}renderShadow(e){let{shadow:t,shadowMap:n,light:r}=this,{renderer:i,scene:a}=e;t.updateMatrices(r),n.setSize(t.mapSize.width,t.mapSize.height,n.depth);let o=a.name;a.name=`Shadow Map [ ${r.name||`ID: `+r.id} ]`,i.render(a,t.camera),a.name=o}updateShadow(e){let{shadowMap:t,light:n,shadow:r}=this,{renderer:i,scene:a,camera:o}=e,s=i.shadowMap.type;this._depthVersionCached=t.depthTexture.version;let c=r.camera.layers.mask;r.camera.layers.mask&4294967294||(r.camera.layers.mask=o.layers.mask);let l=i.getRenderObjectFunction(),u=i.getMRT(),d=u?u.has(`velocity`):!1;sq=KK(i,a,sq),a.overrideMaterial=$K(n),i.setRenderObjectFunction(rq(i,r,s,d)),i.setClearColor(0,0),i.setRenderTarget(t),this.renderShadow(e),i.setRenderObjectFunction(l),s===3&&r.isPointLightShadow!==!0&&this.vsmPass(i),r.camera.layers.mask=c,qK(i,a,sq)}vsmPass(e){let{shadow:t}=this,n=this.shadowMap.depth;this.vsmShadowMapVertical.setSize(t.mapSize.width,t.mapSize.height,n),this.vsmShadowMapHorizontal.setSize(t.mapSize.width,t.mapSize.height,n),e.setRenderTarget(this.vsmShadowMapVertical),cq.material=this.vsmMaterialVertical,cq.render(e),e.setRenderTarget(this.vsmShadowMapHorizontal),cq.material=this.vsmMaterialHorizontal,cq.render(e)}dispose(){this._reset(),super.dispose()}_reset(){this._currentShadowType=null,eq(this.light),this.shadowMap&&=(this.shadowMap.dispose(),null),this.vsmShadowMapVertical!==null&&(this.vsmShadowMapVertical.dispose(),this.vsmShadowMapVertical=null,this.vsmMaterialVertical.dispose(),this.vsmMaterialVertical=null),this.vsmShadowMapHorizontal!==null&&(this.vsmShadowMapHorizontal.dispose(),this.vsmShadowMapHorizontal=null,this.vsmMaterialHorizontal.dispose(),this.vsmMaterialHorizontal=null)}updateBefore(e){let{shadow:t}=this,n=t.needsUpdate||t.autoUpdate;n&&(this._cameraFrameId[e.camera]===e.frameId&&(n=!1),this._cameraFrameId[e.camera]=e.frameId),n&&(this.updateShadow(e),this.shadowMap.depthTexture.version===this._depthVersionCached&&(t.needsUpdate=!1))}},uq=(e,t)=>new lq(e,t),dq=new Er,fq=new qn,pq=new R,mq=new R,hq=[new R(1,0,0),new R(-1,0,0),new R(0,-1,0),new R(0,1,0),new R(0,0,1),new R(0,0,-1)],gq=[new R(0,-1,0),new R(0,-1,0),new R(0,0,-1),new R(0,0,1),new R(0,-1,0),new R(0,-1,0)],_q=[new R(1,0,0),new R(-1,0,0),new R(0,1,0),new R(0,-1,0),new R(0,0,1),new R(0,0,-1)],vq=[new R(0,-1,0),new R(0,-1,0),new R(0,0,1),new R(0,0,-1),new R(0,-1,0),new R(0,-1,0)],yq=W(({depthTexture:e,bd3D:t,dp:n})=>jF(e,t).compare(n)),bq=W(({depthTexture:e,bd3D:t,dp:n,shadow:r})=>{let i=FF(`radius`,`float`,r).setGroup(oA),a=FF(`mapSize`,`vec2`,r).setGroup(oA),o=i.div(a.x),s=bj(t),c=oj(Vj(t,s.x.greaterThan(s.z).select(J(0,1,0),J(1,0,0)))),l=Vj(t,c),u=$U($N.xy).mul(6.28318530718),d=eW(0,5,u),f=eW(1,5,u),p=eW(2,5,u),m=eW(3,5,u),h=eW(4,5,u);return jF(e,t.add(c.mul(d.x).add(l.mul(d.y)).mul(o))).compare(n).add(jF(e,t.add(c.mul(f.x).add(l.mul(f.y)).mul(o))).compare(n)).add(jF(e,t.add(c.mul(p.x).add(l.mul(p.y)).mul(o))).compare(n)).add(jF(e,t.add(c.mul(m.x).add(l.mul(m.y)).mul(o))).compare(n)).add(jF(e,t.add(c.mul(h.x).add(l.mul(h.y)).mul(o))).compare(n)).mul(1/5)}),xq=W(({filterFn:e,depthTexture:t,shadowCoord:n,shadow:r},i)=>{let a=n.xyz.toConst(),o=a.abs().toConst(),s=o.x.max(o.y).max(o.z),c=lA(`float`).setGroup(oA).onRenderUpdate(()=>r.camera.near),l=lA(`float`).setGroup(oA).onRenderUpdate(()=>r.camera.far),u=FF(`bias`,`float`,r).setGroup(oA),d=G(1).toVar();return $O(s.sub(l).lessThanEqual(0).and(s.sub(c).greaterThanEqual(0)),()=>{let n;i.renderer.reversedDepthBuffer?(n=uR(s.negate(),c,l),n.subAssign(u)):i.renderer.logarithmicDepthBuffer?(n=fR(s.negate(),c,l),n.addAssign(u)):(n=lR(s.negate(),c,l),n.addAssign(u));let o=a.normalize();d.assign(e({depthTexture:t,bd3D:o,dp:n,shadow:r}))}),d}),Sq=class extends lq{static get type(){return`PointShadowNode`}constructor(e,t=null){super(e,t)}getShadowFilterFn(e){return e===0?yq:bq}setupShadowCoord(e,t){return t}setupShadowFilter(e,{filterFn:t,depthTexture:n,shadowCoord:r,shadow:i}){return xq({filterFn:t,depthTexture:n,shadowCoord:r,shadow:i})}setupRenderTarget(e,t){let n=new Ra(e.mapSize.width);n.name=`PointShadowDepthTexture`,n.compareFunction=t.renderer.reversedDepthBuffer?518:515;let r=t.createCubeRenderTarget(e.mapSize.width);return r.texture.name=`PointShadowMap`,r.depthTexture=n,{shadowMap:r,depthTexture:n}}renderShadow(e){let{shadow:t,shadowMap:n,light:r}=this,{renderer:i,scene:a}=e,o=t.camera,s=t.matrix,c=i.coordinateSystem===Nt,l=c?hq:_q,u=c?gq:vq;n.setSize(t.mapSize.width,t.mapSize.width);let d=i.autoClear,f=i.getClearColor(dq),p=i.getClearAlpha();i.autoClear=!1,i.setClearColor(t.clearColor,t.clearAlpha);for(let e=0;e<6;e++){i.setRenderTarget(n,e),i.clear();let c=r.distance||o.far;c!==o.far&&(o.far=c,o.updateProjectionMatrix()),pq.setFromMatrixPosition(r.matrixWorld),o.position.copy(pq),mq.copy(o.position),mq.add(l[e]),o.up.copy(u[e]),o.lookAt(mq),o.updateMatrixWorld(),s.makeTranslation(-pq.x,-pq.y,-pq.z),fq.multiplyMatrices(o.projectionMatrix,o.matrixWorldInverse),t._frustum.setFromProjectionMatrix(fq,o.coordinateSystem,o.reversedDepth);let d=a.name;a.name=`Point Light Shadow [ ${r.name||`ID: `+r.id} ] - Face ${e+1}`,i.render(a,o),a.name=d}i.autoClear=d,i.setClearColor(f,p)}},Cq=(e,t)=>new Sq(e,t),wq=class extends qL{static get type(){return`AnalyticLightNode`}constructor(e=null){super(),this.light=e,this.color=new Er,this.colorNode=e&&e.colorNode||lA(this.color).setGroup(oA),this.baseColorNode=null,this.shadowNode=null,this.shadowColorNode=null,this.isAnalyticLightNode=!0,this.updateType=VD.FRAME,e&&e.shadow&&(this._shadowDisposeListener=()=>{this.disposeShadow()},e.addEventListener(`dispose`,this._shadowDisposeListener))}dispose(){this._shadowDisposeListener&&this.light.removeEventListener(`dispose`,this._shadowDisposeListener),super.dispose()}disposeShadow(){this.shadowNode!==null&&(this.shadowNode.dispose(),this.shadowNode=null),this.shadowColorNode=null,this.baseColorNode!==null&&(this.colorNode=this.baseColorNode,this.baseColorNode=null)}getHash(){return this.light.uuid}getLightVector(e){return DK(this.light).sub(e.context.positionView||nF)}setupDirect(){}setupDirectRectArea(){}setupShadowNode(){return uq(this.light)}setupShadow(e){let{renderer:t}=e;if(t.shadowMap.enabled===!1)return;let n=this.shadowColorNode;if(n===null){let e=this.light.shadow.shadowNode,t;t=e===void 0?this.setupShadowNode():UO(e),this.shadowNode=t,this.shadowColorNode=n=this.colorNode.mul(t),this.baseColorNode=this.colorNode}e.context.getShadow&&(n=e.context.getShadow(this,e)),this.colorNode=n}setup(e){this.colorNode=this.baseColorNode||this.colorNode,this.light.castShadow?e.object.receiveShadow&&this.setupShadow(e):this.shadowNode!==null&&(this.shadowNode.dispose(),this.shadowNode=null,this.shadowColorNode=null);let t=this.setupDirect(e),n=this.setupDirectRectArea(e);t&&e.lightsNode.setupDirectLight(e,this,t),n&&e.lightsNode.setupDirectRectAreaLight(e,this,n)}update(){let{light:e}=this;this.color.copy(e.color).multiplyScalar(e.intensity)}},Tq=W(({lightDistance:e,cutoffDistance:t,decayExponent:n})=>{let r=e.pow(n).max(.01).reciprocal();return t.greaterThan(0).select(r.mul(e.div(t).pow4().oneMinus().clamp().pow2()),r)}),Eq=({color:e,lightVector:t,cutoffDistance:n,decayExponent:r})=>{let i=t.normalize(),a=Tq({lightDistance:t.length(),cutoffDistance:n,decayExponent:r});return{lightDirection:i,lightColor:e.mul(a)}},Dq=class extends wq{static get type(){return`PointLightNode`}constructor(e=null){super(e),this.cutoffDistanceNode=lA(0).setGroup(oA),this.decayExponentNode=lA(2).setGroup(oA)}update(e){let{light:t}=this;super.update(e),this.cutoffDistanceNode.value=t.distance,this.decayExponentNode.value=t.decay}setupShadowNode(){return Cq(this.light)}setupDirect(e){return Eq({color:this.colorNode,lightVector:this.getLightVector(e),cutoffDistance:this.cutoffDistanceNode,decayExponent:this.decayExponentNode})}},Oq=W(([e=ON()])=>{let t=e.mul(2),n=t.x.floor(),r=t.y.floor();return n.add(r).mod(2).sign()}),kq=W(([e=ON()],{renderer:t,material:n})=>{let r=Xj(e.mul(2).sub(1)),i;if(n.alphaToCoverage&&t.currentSamples>0){let e=G(r.fwidth()).toVar();i=tM(e.oneMinus(),e.add(1),r).oneMinus()}else i=lM(r.greaterThan(1),0,1);return i}),Aq=W(([e,t,n])=>{let r=G(n).toVar(),i=G(t).toVar();return lM(rk(e).toVar(),i,r).uniformFlow()}).setLayout({name:`mx_select`,type:`float`,inputs:[{name:`b`,type:`bool`},{name:`t`,type:`float`},{name:`f`,type:`float`}]}),jq=W(([e,t])=>{let n=rk(t).toVar(),r=G(e).toVar();return lM(n,r.negate(),r).uniformFlow()}).setLayout({name:`mx_negate_if`,type:`float`,inputs:[{name:`val`,type:`float`},{name:`b`,type:`bool`}]}),Mq=W(([e])=>K(ij(G(e).toVar()))).setLayout({name:`mx_floor`,type:`int`,inputs:[{name:`x`,type:`float`}]}),Nq=W(([e,t])=>{let n=G(e).toVar();return t.assign(Mq(n)),n.sub(G(t))}),Pq=uU([W(([e,t,n,r,i,a])=>{let o=G(a).toVar(),s=G(i).toVar(),c=G(r).toVar(),l=G(n).toVar(),u=G(t).toVar(),d=G(e).toVar(),f=G(vA(1,s)).toVar();return vA(1,o).mul(d.mul(f).add(u.mul(s))).add(o.mul(l.mul(f).add(c.mul(s))))}).setLayout({name:`mx_bilerp_0`,type:`float`,inputs:[{name:`v0`,type:`float`},{name:`v1`,type:`float`},{name:`v2`,type:`float`},{name:`v3`,type:`float`},{name:`s`,type:`float`},{name:`t`,type:`float`}]}),W(([e,t,n,r,i,a])=>{let o=G(a).toVar(),s=G(i).toVar(),c=J(r).toVar(),l=J(n).toVar(),u=J(t).toVar(),d=J(e).toVar(),f=G(vA(1,s)).toVar();return vA(1,o).mul(d.mul(f).add(u.mul(s))).add(o.mul(l.mul(f).add(c.mul(s))))}).setLayout({name:`mx_bilerp_1`,type:`vec3`,inputs:[{name:`v0`,type:`vec3`},{name:`v1`,type:`vec3`},{name:`v2`,type:`vec3`},{name:`v3`,type:`vec3`},{name:`s`,type:`float`},{name:`t`,type:`float`}]})]),Fq=uU([W(([e,t,n,r,i,a,o,s,c,l,u])=>{let d=G(u).toVar(),f=G(l).toVar(),p=G(c).toVar(),m=G(s).toVar(),h=G(o).toVar(),g=G(a).toVar(),_=G(i).toVar(),v=G(r).toVar(),y=G(n).toVar(),b=G(t).toVar(),x=G(e).toVar(),S=G(vA(1,p)).toVar(),C=G(vA(1,f)).toVar();return G(vA(1,d)).toVar().mul(C.mul(x.mul(S).add(b.mul(p))).add(f.mul(y.mul(S).add(v.mul(p))))).add(d.mul(C.mul(_.mul(S).add(g.mul(p))).add(f.mul(h.mul(S).add(m.mul(p))))))}).setLayout({name:`mx_trilerp_0`,type:`float`,inputs:[{name:`v0`,type:`float`},{name:`v1`,type:`float`},{name:`v2`,type:`float`},{name:`v3`,type:`float`},{name:`v4`,type:`float`},{name:`v5`,type:`float`},{name:`v6`,type:`float`},{name:`v7`,type:`float`},{name:`s`,type:`float`},{name:`t`,type:`float`},{name:`r`,type:`float`}]}),W(([e,t,n,r,i,a,o,s,c,l,u])=>{let d=G(u).toVar(),f=G(l).toVar(),p=G(c).toVar(),m=J(s).toVar(),h=J(o).toVar(),g=J(a).toVar(),_=J(i).toVar(),v=J(r).toVar(),y=J(n).toVar(),b=J(t).toVar(),x=J(e).toVar(),S=G(vA(1,p)).toVar(),C=G(vA(1,f)).toVar();return G(vA(1,d)).toVar().mul(C.mul(x.mul(S).add(b.mul(p))).add(f.mul(y.mul(S).add(v.mul(p))))).add(d.mul(C.mul(_.mul(S).add(g.mul(p))).add(f.mul(h.mul(S).add(m.mul(p))))))}).setLayout({name:`mx_trilerp_1`,type:`vec3`,inputs:[{name:`v0`,type:`vec3`},{name:`v1`,type:`vec3`},{name:`v2`,type:`vec3`},{name:`v3`,type:`vec3`},{name:`v4`,type:`vec3`},{name:`v5`,type:`vec3`},{name:`v6`,type:`vec3`},{name:`v7`,type:`vec3`},{name:`s`,type:`float`},{name:`t`,type:`float`},{name:`r`,type:`float`}]})]),Iq=uU([W(([e,t,n])=>{let r=G(n).toVar(),i=G(t).toVar(),a=q(q(e).toVar().bitAnd(q(7))).toVar(),o=G(Aq(a.lessThan(q(4)),i,r)).toVar(),s=G(yA(2,Aq(a.lessThan(q(4)),r,i))).toVar();return jq(o,rk(a.bitAnd(q(1)))).add(jq(s,rk(a.bitAnd(q(2)))))}).setLayout({name:`mx_gradient_float_0`,type:`float`,inputs:[{name:`hash`,type:`uint`},{name:`x`,type:`float`},{name:`y`,type:`float`}]}),W(([e,t,n,r])=>{let i=G(r).toVar(),a=G(n).toVar(),o=G(t).toVar(),s=q(q(e).toVar().bitAnd(q(15))).toVar(),c=G(Aq(s.lessThan(q(8)),o,a)).toVar(),l=G(Aq(s.lessThan(q(4)),a,Aq(s.equal(q(12)).or(s.equal(q(14))),o,i))).toVar();return jq(c,rk(s.bitAnd(q(1)))).add(jq(l,rk(s.bitAnd(q(2)))))}).setLayout({name:`mx_gradient_float_1`,type:`float`,inputs:[{name:`hash`,type:`uint`},{name:`x`,type:`float`},{name:`y`,type:`float`},{name:`z`,type:`float`}]})]),Lq=uU([W(([e,t,n])=>{let r=G(n).toVar(),i=G(t).toVar(),a=lk(e).toVar();return J(Iq(a.x,i,r),Iq(a.y,i,r),Iq(a.z,i,r))}).setLayout({name:`mx_gradient_vec3_0`,type:`vec3`,inputs:[{name:`hash`,type:`uvec3`},{name:`x`,type:`float`},{name:`y`,type:`float`}]}),W(([e,t,n,r])=>{let i=G(r).toVar(),a=G(n).toVar(),o=G(t).toVar(),s=lk(e).toVar();return J(Iq(s.x,o,a,i),Iq(s.y,o,a,i),Iq(s.z,o,a,i))}).setLayout({name:`mx_gradient_vec3_1`,type:`vec3`,inputs:[{name:`hash`,type:`uvec3`},{name:`x`,type:`float`},{name:`y`,type:`float`},{name:`z`,type:`float`}]})]),Rq=W(([e])=>yA(.6616,G(e).toVar())).setLayout({name:`mx_gradient_scale2d_0`,type:`float`,inputs:[{name:`v`,type:`float`}]}),zq=W(([e])=>yA(.982,G(e).toVar())).setLayout({name:`mx_gradient_scale3d_0`,type:`float`,inputs:[{name:`v`,type:`float`}]}),Bq=uU([Rq,W(([e])=>yA(.6616,J(e).toVar())).setLayout({name:`mx_gradient_scale2d_1`,type:`vec3`,inputs:[{name:`v`,type:`vec3`}]})]),Vq=uU([zq,W(([e])=>yA(.982,J(e).toVar())).setLayout({name:`mx_gradient_scale3d_1`,type:`vec3`,inputs:[{name:`v`,type:`vec3`}]})]),Hq=W(([e,t])=>{let n=K(t).toVar(),r=q(e).toVar();return r.shiftLeft(n).bitOr(r.shiftRight(K(32).sub(n)))}).setLayout({name:`mx_rotl32`,type:`uint`,inputs:[{name:`x`,type:`uint`},{name:`k`,type:`int`}]}),Uq=W(([e,t,n])=>{e.subAssign(n),e.bitXorAssign(Hq(n,K(4))),n.addAssign(t),t.subAssign(e),t.bitXorAssign(Hq(e,K(6))),e.addAssign(n),n.subAssign(t),n.bitXorAssign(Hq(t,K(8))),t.addAssign(e),e.subAssign(n),e.bitXorAssign(Hq(n,K(16))),n.addAssign(t),t.subAssign(e),t.bitXorAssign(Hq(e,K(19))),e.addAssign(n),n.subAssign(t),n.bitXorAssign(Hq(t,K(4))),t.addAssign(e)}),Wq=W(([e,t,n])=>{let r=q(n).toVar(),i=q(t).toVar(),a=q(e).toVar();return r.bitXorAssign(i),r.subAssign(Hq(i,K(14))),a.bitXorAssign(r),a.subAssign(Hq(r,K(11))),i.bitXorAssign(a),i.subAssign(Hq(a,K(25))),r.bitXorAssign(i),r.subAssign(Hq(i,K(16))),a.bitXorAssign(r),a.subAssign(Hq(r,K(4))),i.bitXorAssign(a),i.subAssign(Hq(a,K(14))),r.bitXorAssign(i),r.subAssign(Hq(i,K(24))),r}).setLayout({name:`mx_bjfinal`,type:`uint`,inputs:[{name:`a`,type:`uint`},{name:`b`,type:`uint`},{name:`c`,type:`uint`}]}),Gq=W(([e])=>G(q(e).toVar()).div(G(q(K(4294967295))))).setLayout({name:`mx_bits_to_01`,type:`float`,inputs:[{name:`bits`,type:`uint`}]}),Kq=W(([e])=>{let t=G(e).toVar();return t.mul(t).mul(t).mul(t.mul(t.mul(6).sub(15)).add(10))}).setLayout({name:`mx_fade`,type:`float`,inputs:[{name:`t`,type:`float`}]}),qq=uU([W(([e])=>{let t=K(e).toVar(),n=q(q(1)).toVar(),r=q(q(K(3735928559)).add(n.shiftLeft(q(2))).add(q(13))).toVar();return Wq(r.add(q(t)),r,r)}).setLayout({name:`mx_hash_int_0`,type:`uint`,inputs:[{name:`x`,type:`int`}]}),W(([e,t])=>{let n=K(t).toVar(),r=K(e).toVar(),i=q(q(2)).toVar(),a=q().toVar(),o=q().toVar(),s=q().toVar();return a.assign(o.assign(s.assign(q(K(3735928559)).add(i.shiftLeft(q(2))).add(q(13))))),a.addAssign(q(r)),o.addAssign(q(n)),Wq(a,o,s)}).setLayout({name:`mx_hash_int_1`,type:`uint`,inputs:[{name:`x`,type:`int`},{name:`y`,type:`int`}]}),W(([e,t,n])=>{let r=K(n).toVar(),i=K(t).toVar(),a=K(e).toVar(),o=q(q(3)).toVar(),s=q().toVar(),c=q().toVar(),l=q().toVar();return s.assign(c.assign(l.assign(q(K(3735928559)).add(o.shiftLeft(q(2))).add(q(13))))),s.addAssign(q(a)),c.addAssign(q(i)),l.addAssign(q(r)),Wq(s,c,l)}).setLayout({name:`mx_hash_int_2`,type:`uint`,inputs:[{name:`x`,type:`int`},{name:`y`,type:`int`},{name:`z`,type:`int`}]}),W(([e,t,n,r])=>{let i=K(r).toVar(),a=K(n).toVar(),o=K(t).toVar(),s=K(e).toVar(),c=q(q(4)).toVar(),l=q().toVar(),u=q().toVar(),d=q().toVar();return l.assign(u.assign(d.assign(q(K(3735928559)).add(c.shiftLeft(q(2))).add(q(13))))),l.addAssign(q(s)),u.addAssign(q(o)),d.addAssign(q(a)),Uq(l,u,d),l.addAssign(q(i)),Wq(l,u,d)}).setLayout({name:`mx_hash_int_3`,type:`uint`,inputs:[{name:`x`,type:`int`},{name:`y`,type:`int`},{name:`z`,type:`int`},{name:`xx`,type:`int`}]}),W(([e,t,n,r,i])=>{let a=K(i).toVar(),o=K(r).toVar(),s=K(n).toVar(),c=K(t).toVar(),l=K(e).toVar(),u=q(q(5)).toVar(),d=q().toVar(),f=q().toVar(),p=q().toVar();return d.assign(f.assign(p.assign(q(K(3735928559)).add(u.shiftLeft(q(2))).add(q(13))))),d.addAssign(q(l)),f.addAssign(q(c)),p.addAssign(q(s)),Uq(d,f,p),d.addAssign(q(o)),f.addAssign(q(a)),Wq(d,f,p)}).setLayout({name:`mx_hash_int_4`,type:`uint`,inputs:[{name:`x`,type:`int`},{name:`y`,type:`int`},{name:`z`,type:`int`},{name:`xx`,type:`int`},{name:`yy`,type:`int`}]})]),Jq=uU([W(([e,t])=>{let n=K(t).toVar(),r=q(qq(K(e).toVar(),n)).toVar(),i=lk().toVar();return i.x.assign(r.bitAnd(K(255))),i.y.assign(r.shiftRight(K(8)).bitAnd(K(255))),i.z.assign(r.shiftRight(K(16)).bitAnd(K(255))),i}).setLayout({name:`mx_hash_vec3_0`,type:`uvec3`,inputs:[{name:`x`,type:`int`},{name:`y`,type:`int`}]}),W(([e,t,n])=>{let r=K(n).toVar(),i=K(t).toVar(),a=q(qq(K(e).toVar(),i,r)).toVar(),o=lk().toVar();return o.x.assign(a.bitAnd(K(255))),o.y.assign(a.shiftRight(K(8)).bitAnd(K(255))),o.z.assign(a.shiftRight(K(16)).bitAnd(K(255))),o}).setLayout({name:`mx_hash_vec3_1`,type:`uvec3`,inputs:[{name:`x`,type:`int`},{name:`y`,type:`int`},{name:`z`,type:`int`}]})]),Yq=uU([W(([e])=>{let t=ik(e).toVar(),n=K().toVar(),r=K().toVar(),i=G(Nq(t.x,n)).toVar(),a=G(Nq(t.y,r)).toVar(),o=G(Kq(i)).toVar(),s=G(Kq(a)).toVar();return Bq(G(Pq(Iq(qq(n,r),i,a),Iq(qq(n.add(K(1)),r),i.sub(1),a),Iq(qq(n,r.add(K(1))),i,a.sub(1)),Iq(qq(n.add(K(1)),r.add(K(1))),i.sub(1),a.sub(1)),o,s)).toVar())}).setLayout({name:`mx_perlin_noise_float_0`,type:`float`,inputs:[{name:`p`,type:`vec2`}]}),W(([e])=>{let t=J(e).toVar(),n=K().toVar(),r=K().toVar(),i=K().toVar(),a=G(Nq(t.x,n)).toVar(),o=G(Nq(t.y,r)).toVar(),s=G(Nq(t.z,i)).toVar(),c=G(Kq(a)).toVar(),l=G(Kq(o)).toVar(),u=G(Kq(s)).toVar();return Vq(G(Fq(Iq(qq(n,r,i),a,o,s),Iq(qq(n.add(K(1)),r,i),a.sub(1),o,s),Iq(qq(n,r.add(K(1)),i),a,o.sub(1),s),Iq(qq(n.add(K(1)),r.add(K(1)),i),a.sub(1),o.sub(1),s),Iq(qq(n,r,i.add(K(1))),a,o,s.sub(1)),Iq(qq(n.add(K(1)),r,i.add(K(1))),a.sub(1),o,s.sub(1)),Iq(qq(n,r.add(K(1)),i.add(K(1))),a,o.sub(1),s.sub(1)),Iq(qq(n.add(K(1)),r.add(K(1)),i.add(K(1))),a.sub(1),o.sub(1),s.sub(1)),c,l,u)).toVar())}).setLayout({name:`mx_perlin_noise_float_1`,type:`float`,inputs:[{name:`p`,type:`vec3`}]})]),Xq=uU([W(([e])=>{let t=ik(e).toVar(),n=K().toVar(),r=K().toVar(),i=G(Nq(t.x,n)).toVar(),a=G(Nq(t.y,r)).toVar(),o=G(Kq(i)).toVar(),s=G(Kq(a)).toVar();return Bq(J(Pq(Lq(Jq(n,r),i,a),Lq(Jq(n.add(K(1)),r),i.sub(1),a),Lq(Jq(n,r.add(K(1))),i,a.sub(1)),Lq(Jq(n.add(K(1)),r.add(K(1))),i.sub(1),a.sub(1)),o,s)).toVar())}).setLayout({name:`mx_perlin_noise_vec3_0`,type:`vec3`,inputs:[{name:`p`,type:`vec2`}]}),W(([e])=>{let t=J(e).toVar(),n=K().toVar(),r=K().toVar(),i=K().toVar(),a=G(Nq(t.x,n)).toVar(),o=G(Nq(t.y,r)).toVar(),s=G(Nq(t.z,i)).toVar(),c=G(Kq(a)).toVar(),l=G(Kq(o)).toVar(),u=G(Kq(s)).toVar();return Vq(J(Fq(Lq(Jq(n,r,i),a,o,s),Lq(Jq(n.add(K(1)),r,i),a.sub(1),o,s),Lq(Jq(n,r.add(K(1)),i),a,o.sub(1),s),Lq(Jq(n.add(K(1)),r.add(K(1)),i),a.sub(1),o.sub(1),s),Lq(Jq(n,r,i.add(K(1))),a,o,s.sub(1)),Lq(Jq(n.add(K(1)),r,i.add(K(1))),a.sub(1),o,s.sub(1)),Lq(Jq(n,r.add(K(1)),i.add(K(1))),a,o.sub(1),s.sub(1)),Lq(Jq(n.add(K(1)),r.add(K(1)),i.add(K(1))),a.sub(1),o.sub(1),s.sub(1)),c,l,u)).toVar())}).setLayout({name:`mx_perlin_noise_vec3_1`,type:`vec3`,inputs:[{name:`p`,type:`vec3`}]})]),Zq=uU([W(([e])=>Gq(qq(K(Mq(G(e).toVar())).toVar()))).setLayout({name:`mx_cell_noise_float_0`,type:`float`,inputs:[{name:`p`,type:`float`}]}),W(([e])=>{let t=ik(e).toVar();return Gq(qq(K(Mq(t.x)).toVar(),K(Mq(t.y)).toVar()))}).setLayout({name:`mx_cell_noise_float_1`,type:`float`,inputs:[{name:`p`,type:`vec2`}]}),W(([e])=>{let t=J(e).toVar();return Gq(qq(K(Mq(t.x)).toVar(),K(Mq(t.y)).toVar(),K(Mq(t.z)).toVar()))}).setLayout({name:`mx_cell_noise_float_2`,type:`float`,inputs:[{name:`p`,type:`vec3`}]}),W(([e])=>{let t=dk(e).toVar();return Gq(qq(K(Mq(t.x)).toVar(),K(Mq(t.y)).toVar(),K(Mq(t.z)).toVar(),K(Mq(t.w)).toVar()))}).setLayout({name:`mx_cell_noise_float_3`,type:`float`,inputs:[{name:`p`,type:`vec4`}]})]),Qq=uU([W(([e])=>{let t=K(Mq(G(e).toVar())).toVar();return J(Gq(qq(t,K(0))),Gq(qq(t,K(1))),Gq(qq(t,K(2))))}).setLayout({name:`mx_cell_noise_vec3_0`,type:`vec3`,inputs:[{name:`p`,type:`float`}]}),W(([e])=>{let t=ik(e).toVar(),n=K(Mq(t.x)).toVar(),r=K(Mq(t.y)).toVar();return J(Gq(qq(n,r,K(0))),Gq(qq(n,r,K(1))),Gq(qq(n,r,K(2))))}).setLayout({name:`mx_cell_noise_vec3_1`,type:`vec3`,inputs:[{name:`p`,type:`vec2`}]}),W(([e])=>{let t=J(e).toVar(),n=K(Mq(t.x)).toVar(),r=K(Mq(t.y)).toVar(),i=K(Mq(t.z)).toVar();return J(Gq(qq(n,r,i,K(0))),Gq(qq(n,r,i,K(1))),Gq(qq(n,r,i,K(2))))}).setLayout({name:`mx_cell_noise_vec3_2`,type:`vec3`,inputs:[{name:`p`,type:`vec3`}]}),W(([e])=>{let t=dk(e).toVar(),n=K(Mq(t.x)).toVar(),r=K(Mq(t.y)).toVar(),i=K(Mq(t.z)).toVar(),a=K(Mq(t.w)).toVar();return J(Gq(qq(n,r,i,a,K(0))),Gq(qq(n,r,i,a,K(1))),Gq(qq(n,r,i,a,K(2))))}).setLayout({name:`mx_cell_noise_vec3_3`,type:`vec3`,inputs:[{name:`p`,type:`vec4`}]})]),$q=W(([e,t,n,r])=>{let i=G(r).toVar(),a=G(n).toVar(),o=K(t).toVar(),s=J(e).toVar(),c=G(0).toVar(),l=G(1).toVar();return RL(o,()=>{c.addAssign(l.mul(Yq(s))),l.mulAssign(i),s.mulAssign(a)}),c}).setLayout({name:`mx_fractal_noise_float`,type:`float`,inputs:[{name:`p`,type:`vec3`},{name:`octaves`,type:`int`},{name:`lacunarity`,type:`float`},{name:`diminish`,type:`float`}]}),eJ=W(([e,t,n,r])=>{let i=G(r).toVar(),a=G(n).toVar(),o=K(t).toVar(),s=J(e).toVar(),c=J(0).toVar(),l=G(1).toVar();return RL(o,()=>{c.addAssign(l.mul(Xq(s))),l.mulAssign(i),s.mulAssign(a)}),c}).setLayout({name:`mx_fractal_noise_vec3`,type:`vec3`,inputs:[{name:`p`,type:`vec3`},{name:`octaves`,type:`int`},{name:`lacunarity`,type:`float`},{name:`diminish`,type:`float`}]}),tJ=W(([e,t,n,r])=>{let i=G(r).toVar(),a=G(n).toVar(),o=K(t).toVar(),s=J(e).toVar();return ik($q(s,o,a,i),$q(s.add(J(K(19),K(193),K(17))),o,a,i))}).setLayout({name:`mx_fractal_noise_vec2`,type:`vec2`,inputs:[{name:`p`,type:`vec3`},{name:`octaves`,type:`int`},{name:`lacunarity`,type:`float`},{name:`diminish`,type:`float`}]}),nJ=W(([e,t,n,r])=>{let i=G(r).toVar(),a=G(n).toVar(),o=K(t).toVar(),s=J(e).toVar();return dk(J(eJ(s,o,a,i)).toVar(),G($q(s.add(J(K(19),K(193),K(17))),o,a,i)).toVar())}).setLayout({name:`mx_fractal_noise_vec4`,type:`vec4`,inputs:[{name:`p`,type:`vec3`},{name:`octaves`,type:`int`},{name:`lacunarity`,type:`float`},{name:`diminish`,type:`float`}]}),rJ=uU([W(([e,t,n,r,i,a,o])=>{let s=K(o).toVar(),c=G(a).toVar(),l=K(i).toVar(),u=K(r).toVar(),d=K(n).toVar(),f=K(t).toVar(),p=ik(e).toVar(),m=J(Qq(ik(f.add(u),d.add(l)))).toVar(),h=ik(m.x,m.y).toVar();h.subAssign(.5),h.mulAssign(c),h.addAssign(.5);let g=ik(ik(ik(G(f),G(d)).add(h)).toVar().sub(p)).toVar();return $O(s.equal(K(2)),()=>bj(g.x).add(bj(g.y))),$O(s.equal(K(3)),()=>Fj(bj(g.x),bj(g.y))),Bj(g,g)}).setLayout({name:`mx_worley_distance_0`,type:`float`,inputs:[{name:`p`,type:`vec2`},{name:`x`,type:`int`},{name:`y`,type:`int`},{name:`xoff`,type:`int`},{name:`yoff`,type:`int`},{name:`jitter`,type:`float`},{name:`metric`,type:`int`}]}),W(([e,t,n,r,i,a,o,s,c])=>{let l=K(c).toVar(),u=G(s).toVar(),d=K(o).toVar(),f=K(a).toVar(),p=K(i).toVar(),m=K(r).toVar(),h=K(n).toVar(),g=K(t).toVar(),_=J(e).toVar(),v=J(Qq(J(g.add(p),h.add(f),m.add(d)))).toVar();v.subAssign(.5),v.mulAssign(u),v.addAssign(.5);let y=J(J(J(G(g),G(h),G(m)).add(v)).toVar().sub(_)).toVar();return $O(l.equal(K(2)),()=>bj(y.x).add(bj(y.y)).add(bj(y.z))),$O(l.equal(K(3)),()=>Fj(bj(y.x),bj(y.y),bj(y.z))),Bj(y,y)}).setLayout({name:`mx_worley_distance_1`,type:`float`,inputs:[{name:`p`,type:`vec3`},{name:`x`,type:`int`},{name:`y`,type:`int`},{name:`z`,type:`int`},{name:`xoff`,type:`int`},{name:`yoff`,type:`int`},{name:`zoff`,type:`int`},{name:`jitter`,type:`float`},{name:`metric`,type:`int`}]})]),iJ=W(([e,t,n])=>{let r=K(n).toVar(),i=G(t).toVar(),a=ik(e).toVar(),o=K().toVar(),s=K().toVar(),c=ik(Nq(a.x,o),Nq(a.y,s)).toVar(),l=G(1e6).toVar();return RL({start:-1,end:K(1),name:`x`,condition:`<=`},({x:e})=>{RL({start:-1,end:K(1),name:`y`,condition:`<=`},({y:t})=>{let n=G(rJ(c,e,t,o,s,i,r)).toVar();l.assign(Pj(l,n))})}),$O(r.equal(K(0)),()=>{l.assign(nj(l))}),l}).setLayout({name:`mx_worley_noise_float_0`,type:`float`,inputs:[{name:`p`,type:`vec2`},{name:`jitter`,type:`float`},{name:`metric`,type:`int`}]}),aJ=W(([e,t,n])=>{let r=K(n).toVar(),i=G(t).toVar(),a=ik(e).toVar(),o=K().toVar(),s=K().toVar(),c=ik(Nq(a.x,o),Nq(a.y,s)).toVar(),l=ik(1e6,1e6).toVar();return RL({start:-1,end:K(1),name:`x`,condition:`<=`},({x:e})=>{RL({start:-1,end:K(1),name:`y`,condition:`<=`},({y:t})=>{let n=G(rJ(c,e,t,o,s,i,r)).toVar();$O(n.lessThan(l.x),()=>{l.y.assign(l.x),l.x.assign(n)}).ElseIf(n.lessThan(l.y),()=>{l.y.assign(n)})})}),$O(r.equal(K(0)),()=>{l.assign(nj(l))}),l}).setLayout({name:`mx_worley_noise_vec2_0`,type:`vec2`,inputs:[{name:`p`,type:`vec2`},{name:`jitter`,type:`float`},{name:`metric`,type:`int`}]}),oJ=W(([e,t,n])=>{let r=K(n).toVar(),i=G(t).toVar(),a=ik(e).toVar(),o=K().toVar(),s=K().toVar(),c=ik(Nq(a.x,o),Nq(a.y,s)).toVar(),l=J(1e6,1e6,1e6).toVar();return RL({start:-1,end:K(1),name:`x`,condition:`<=`},({x:e})=>{RL({start:-1,end:K(1),name:`y`,condition:`<=`},({y:t})=>{let n=G(rJ(c,e,t,o,s,i,r)).toVar();$O(n.lessThan(l.x),()=>{l.z.assign(l.y),l.y.assign(l.x),l.x.assign(n)}).ElseIf(n.lessThan(l.y),()=>{l.z.assign(l.y),l.y.assign(n)}).ElseIf(n.lessThan(l.z),()=>{l.z.assign(n)})})}),$O(r.equal(K(0)),()=>{l.assign(nj(l))}),l}).setLayout({name:`mx_worley_noise_vec3_0`,type:`vec3`,inputs:[{name:`p`,type:`vec2`},{name:`jitter`,type:`float`},{name:`metric`,type:`int`}]}),sJ=uU([iJ,W(([e,t,n])=>{let r=K(n).toVar(),i=G(t).toVar(),a=J(e).toVar(),o=K().toVar(),s=K().toVar(),c=K().toVar(),l=J(Nq(a.x,o),Nq(a.y,s),Nq(a.z,c)).toVar(),u=G(1e6).toVar();return RL({start:-1,end:K(1),name:`x`,condition:`<=`},({x:e})=>{RL({start:-1,end:K(1),name:`y`,condition:`<=`},({y:t})=>{RL({start:-1,end:K(1),name:`z`,condition:`<=`},({z:n})=>{let a=G(rJ(l,e,t,n,o,s,c,i,r)).toVar();u.assign(Pj(u,a))})})}),$O(r.equal(K(0)),()=>{u.assign(nj(u))}),u}).setLayout({name:`mx_worley_noise_float_1`,type:`float`,inputs:[{name:`p`,type:`vec3`},{name:`jitter`,type:`float`},{name:`metric`,type:`int`}]})]),cJ=uU([aJ,W(([e,t,n])=>{let r=K(n).toVar(),i=G(t).toVar(),a=J(e).toVar(),o=K().toVar(),s=K().toVar(),c=K().toVar(),l=J(Nq(a.x,o),Nq(a.y,s),Nq(a.z,c)).toVar(),u=ik(1e6,1e6).toVar();return RL({start:-1,end:K(1),name:`x`,condition:`<=`},({x:e})=>{RL({start:-1,end:K(1),name:`y`,condition:`<=`},({y:t})=>{RL({start:-1,end:K(1),name:`z`,condition:`<=`},({z:n})=>{let a=G(rJ(l,e,t,n,o,s,c,i,r)).toVar();$O(a.lessThan(u.x),()=>{u.y.assign(u.x),u.x.assign(a)}).ElseIf(a.lessThan(u.y),()=>{u.y.assign(a)})})})}),$O(r.equal(K(0)),()=>{u.assign(nj(u))}),u}).setLayout({name:`mx_worley_noise_vec2_1`,type:`vec2`,inputs:[{name:`p`,type:`vec3`},{name:`jitter`,type:`float`},{name:`metric`,type:`int`}]})]),lJ=uU([oJ,W(([e,t,n])=>{let r=K(n).toVar(),i=G(t).toVar(),a=J(e).toVar(),o=K().toVar(),s=K().toVar(),c=K().toVar(),l=J(Nq(a.x,o),Nq(a.y,s),Nq(a.z,c)).toVar(),u=J(1e6,1e6,1e6).toVar();return RL({start:-1,end:K(1),name:`x`,condition:`<=`},({x:e})=>{RL({start:-1,end:K(1),name:`y`,condition:`<=`},({y:t})=>{RL({start:-1,end:K(1),name:`z`,condition:`<=`},({z:n})=>{let a=G(rJ(l,e,t,n,o,s,c,i,r)).toVar();$O(a.lessThan(u.x),()=>{u.z.assign(u.y),u.y.assign(u.x),u.x.assign(a)}).ElseIf(a.lessThan(u.y),()=>{u.z.assign(u.y),u.y.assign(a)}).ElseIf(a.lessThan(u.z),()=>{u.z.assign(a)})})})}),$O(r.equal(K(0)),()=>{u.assign(nj(u))}),u}).setLayout({name:`mx_worley_noise_vec3_1`,type:`vec3`,inputs:[{name:`p`,type:`vec3`},{name:`jitter`,type:`float`},{name:`metric`,type:`int`}]})]),uJ=W(([e,t,n,r,i,a,o,s,c,l,u])=>{let d=K(e).toVar(),f=ik(t).toVar(),p=ik(n).toVar(),m=ik(r).toVar(),h=G(i).toVar(),g=G(a).toVar(),_=G(o).toVar(),v=rk(s).toVar(),y=K(c).toVar(),b=G(l).toVar(),x=G(u).toVar(),S=f.mul(p).add(m),C=G(0).toVar();return $O(d.equal(K(0)),()=>{C.assign(Xq(S))}),$O(d.equal(K(1)),()=>{C.assign(Qq(S))}),$O(d.equal(K(2)),()=>{C.assign(lJ(S,h,K(0)))}),$O(d.equal(K(3)),()=>{C.assign(eJ(J(S,0),y,b,x))}),C.assign(C.mul(_.sub(g)).add(g)),$O(v,()=>{C.assign(Qj(C,g,_))}),C}).setLayout({name:`mx_unifiednoise2d`,type:`float`,inputs:[{name:`noiseType`,type:`int`},{name:`texcoord`,type:`vec2`},{name:`freq`,type:`vec2`},{name:`offset`,type:`vec2`},{name:`jitter`,type:`float`},{name:`outmin`,type:`float`},{name:`outmax`,type:`float`},{name:`clampoutput`,type:`bool`},{name:`octaves`,type:`int`},{name:`lacunarity`,type:`float`},{name:`diminish`,type:`float`}]}),dJ=W(([e,t,n,r,i,a,o,s,c,l,u])=>{let d=K(e).toVar(),f=J(t).toVar(),p=J(n).toVar(),m=J(r).toVar(),h=G(i).toVar(),g=G(a).toVar(),_=G(o).toVar(),v=rk(s).toVar(),y=K(c).toVar(),b=G(l).toVar(),x=G(u).toVar(),S=f.mul(p).add(m),C=G(0).toVar();return $O(d.equal(K(0)),()=>{C.assign(Xq(S))}),$O(d.equal(K(1)),()=>{C.assign(Qq(S))}),$O(d.equal(K(2)),()=>{C.assign(lJ(S,h,K(0)))}),$O(d.equal(K(3)),()=>{C.assign(eJ(S,y,b,x))}),C.assign(C.mul(_.sub(g)).add(g)),$O(v,()=>{C.assign(Qj(C,g,_))}),C}).setLayout({name:`mx_unifiednoise3d`,type:`float`,inputs:[{name:`noiseType`,type:`int`},{name:`position`,type:`vec3`},{name:`freq`,type:`vec3`},{name:`offset`,type:`vec3`},{name:`jitter`,type:`float`},{name:`outmin`,type:`float`},{name:`outmax`,type:`float`},{name:`clampoutput`,type:`bool`},{name:`octaves`,type:`int`},{name:`lacunarity`,type:`float`},{name:`diminish`,type:`float`}]}),fJ=W(([e])=>{let t=e.y,n=e.z,r=J().toVar();return $O(t.lessThan(1e-4),()=>{r.assign(J(n,n,n))}).Else(()=>{let i=e.x;i=i.sub(ij(i)).mul(6).toVar();let a=K(kj(i)),o=i.sub(G(a)),s=n.mul(t.oneMinus()),c=n.mul(t.mul(o).oneMinus()),l=n.mul(t.mul(o.oneMinus()).oneMinus());$O(a.equal(K(0)),()=>{r.assign(J(n,l,s))}).ElseIf(a.equal(K(1)),()=>{r.assign(J(c,n,s))}).ElseIf(a.equal(K(2)),()=>{r.assign(J(s,n,l))}).ElseIf(a.equal(K(3)),()=>{r.assign(J(s,c,n))}).ElseIf(a.equal(K(4)),()=>{r.assign(J(l,s,n))}).Else(()=>{r.assign(J(n,s,c))})}),r}).setLayout({name:`mx_hsvtorgb`,type:`vec3`,inputs:[{name:`hsv`,type:`vec3`}]}),pJ=W(([e])=>{let t=J(e).toVar(),n=G(t.x).toVar(),r=G(t.y).toVar(),i=G(t.z).toVar(),a=G(Pj(n,Pj(r,i))).toVar(),o=G(Fj(n,Fj(r,i))).toVar(),s=G(o.sub(a)).toVar(),c=G().toVar(),l=G().toVar(),u=G().toVar();return u.assign(o),$O(o.greaterThan(0),()=>{l.assign(s.div(o))}).Else(()=>{l.assign(0)}),$O(l.lessThanEqual(0),()=>{c.assign(0)}).Else(()=>{$O(n.greaterThanEqual(o),()=>{c.assign(r.sub(i).div(s))}).ElseIf(r.greaterThanEqual(o),()=>{c.assign(_A(2,i.sub(n).div(s)))}).Else(()=>{c.assign(_A(4,n.sub(r).div(s)))}),c.mulAssign(1/6),$O(c.lessThan(0),()=>{c.addAssign(1)})}),J(c,l,u)}).setLayout({name:`mx_rgbtohsv`,type:`vec3`,inputs:[{name:`c`,type:`vec3`}]}),mJ=W(([e])=>{let t=J(e).toVar(),n=uk(TA(t,J(.04045))).toVar();return Zj(J(t.div(12.92)).toVar(),J(Hj(Fj(t.add(J(.055)),J(0)).div(1.055),J(2.4))).toVar(),n)}).setLayout({name:`mx_srgb_texture_to_lin_rec709`,type:`vec3`,inputs:[{name:`color`,type:`vec3`}]}),hJ=(e,t)=>{e=G(e),t=G(t);let n=ik(t.dFdx(),t.dFdy()).length().mul(.7071067811865476);return tM(e.sub(n),e.add(n),t)},gJ=(e,t,n,r)=>Zj(e,t,n[r].clamp()),_J=(e,t,n=ON())=>gJ(e,t,n,`x`),vJ=(e,t,n=ON())=>gJ(e,t,n,`y`),yJ=(e,t,n,r,i=ON())=>{let a=i.x.clamp(),o=i.y.clamp();return Zj(Zj(e,t,a),Zj(n,r,a),o)},bJ=(e,t,n,r,i)=>Zj(e,t,hJ(n,r[i])),xJ=(e,t,n,r=ON())=>bJ(e,t,n,r,`x`),SJ=(e,t,n,r=ON())=>bJ(e,t,n,r,`y`),CJ=(e=1,t=0,n=ON())=>n.mul(e).add(t),wJ=(e,t=1)=>(e=G(e),e.abs().pow(t).mul(e.sign())),TJ=(e,t=1,n=.5)=>G(e).sub(n).mul(t).add(n),EJ=(e=ON(),t=1,n=0)=>Yq(e.convert(`vec2|vec3`)).mul(t).add(n),DJ=(e=ON(),t=1,n=0)=>Xq(e.convert(`vec2|vec3`)).mul(t).add(n),OJ=(e=ON(),t=1,n=0)=>(e=e.convert(`vec2|vec3`),dk(Xq(e),Yq(e.add(ik(19,73)))).mul(t).add(n)),kJ=(e,t=ON(),n=ik(1,1),r=ik(0,0),i=1,a=0,o=1,s=!1,c=1,l=2,u=.5)=>uJ(e,t.convert(`vec2|vec3`),n,r,i,a,o,s,c,l,u),AJ=(e,t=ON(),n=ik(1,1),r=ik(0,0),i=1,a=0,o=1,s=!1,c=1,l=2,u=.5)=>dJ(e,t.convert(`vec2|vec3`),n,r,i,a,o,s,c,l,u),jJ=(e=ON(),t=1)=>sJ(e.convert(`vec2|vec3`),t,K(1)),MJ=(e=ON(),t=1)=>cJ(e.convert(`vec2|vec3`),t,K(1)),NJ=(e=ON(),t=1)=>lJ(e.convert(`vec2|vec3`),t,K(1)),PJ=(e=ON())=>Zq(e.convert(`vec2|vec3`)),FJ=(e=ON(),t=3,n=2,r=.5,i=1)=>$q(e,K(t),n,r).mul(i),IJ=(e=ON(),t=3,n=2,r=.5,i=1)=>tJ(e,K(t),n,r).mul(i),LJ=(e=ON(),t=3,n=2,r=.5,i=1)=>eJ(e,K(t),n,r).mul(i),RJ=(e=ON(),t=3,n=2,r=.5,i=1)=>nJ(e,K(t),n,r).mul(i),zJ=(e,t=G(0))=>_A(e,t),BJ=(e,t=G(0))=>vA(e,t),VJ=(e,t=G(1))=>yA(e,t),HJ=(e,t=G(1))=>bA(e,t),UJ=(e,t=G(1))=>xA(e,t),WJ=(e,t=G(1))=>Hj(e,t),GJ=(e=G(0),t=G(1))=>vj(e,t),KJ=()=>dU,qJ=()=>pU,JJ=(e,t=G(1))=>vA(t,e),YJ=(e,t,n,r)=>e.greaterThan(t).mix(n,r),XJ=(e,t,n,r)=>e.greaterThanEqual(t).mix(n,r),ZJ=(e,t,n,r)=>e.equal(t).mix(n,r),QJ=(e,t=null)=>{if(typeof t==`string`){let n={x:0,r:0,y:1,g:1,z:2,b:2,w:3,a:3},r=t.replace(/^out/,``).toLowerCase();if(n[r]!==void 0)return e.element(n[r])}if(typeof t==`number`)return e.element(t);if(typeof t==`string`&&t.length===1){let n={x:0,r:0,y:1,g:1,z:2,b:2,w:3,a:3};if(n[t]!==void 0)return e.element(n[t])}return e},$J=(e,t=ik(.5,.5),n=ik(1,1),r=G(0),i=ik(0,0))=>{let a=e;if(t&&(a=a.sub(t)),n&&(a=a.mul(n)),r){let e=r.mul(Math.PI/180),t=e.cos(),n=e.sin();a=ik(a.x.mul(t).sub(a.y.mul(n)),a.x.mul(n).add(a.y.mul(t)))}return t&&(a=a.add(t)),i&&(a=a.add(i)),a},eY=(e,t)=>{e=ik(e),t=G(t);let n=t.mul(Math.PI/180);return CV(e,n)},tY=(e,t,n)=>{e=J(e),t=G(t),n=J(n);let r=t.mul(Math.PI/180),i=n.normalize(),a=r.cos(),o=r.sin(),s=G(1).sub(a);return e.mul(a).add(i.cross(e).mul(o)).add(i.mul(i.dot(e)).mul(s))},nY=(e,t)=>(e=J(e),t=G(t),bI(e,t)),rY=W(([e,t,n])=>{let r=oj(e).toVar(),i=vA(G(.5).mul(t.sub(n)),eF).div(r).toVar(),a=vA(G(-.5).mul(t.sub(n)),eF).div(r).toVar(),o=J().toVar();o.x=r.x.greaterThan(G(0)).select(i.x,a.x),o.y=r.y.greaterThan(G(0)).select(i.y,a.y),o.z=r.z.greaterThan(G(0)).select(i.z,a.z);let s=Pj(o.x,o.y,o.z).toVar();return eF.add(r.mul(s)).toVar().sub(n)}),iY=W(([e,t])=>{let n=e.x,r=e.y,i=e.z,a=t.element(0).mul(.886227);return a=a.add(t.element(1).mul(2*.511664).mul(r)),a=a.add(t.element(2).mul(2*.511664).mul(i)),a=a.add(t.element(3).mul(2*.511664).mul(n)),a=a.add(t.element(4).mul(2*.429043).mul(n).mul(r)),a=a.add(t.element(5).mul(2*.429043).mul(r).mul(i)),a=a.add(t.element(6).mul(i.mul(i).mul(.743125).sub(.247708))),a=a.add(t.element(7).mul(2*.429043).mul(n).mul(i)),a=a.add(t.element(8).mul(.429043).mul(yA(n,n).sub(yA(r,r)))),a}),Z=Object.freeze({__proto__:null,BRDF_GGX:yz,BRDF_Lambert:rz,BasicPointShadowFilter:yq,BasicShadowFilter:YK,Break:BL,Const:bM,Continue:zL,DFGLUT:Sz,D_GGX:gz,Discard:mN,EPSILON:HA,F_Schlick:nz,Fn:W,HALF_PI:qA,INFINITY:UA,If:$O,Loop:RL,NodeAccess:UD,NodeShaderStage:BD,NodeType:HD,NodeUpdateType:VD,OnBeforeFrameUpdate:mL,OnBeforeMaterialUpdate:pL,OnBeforeObjectUpdate:fL,OnFrameUpdate:dL,OnMaterialUpdate:uL,OnObjectUpdate:lL,PCFShadowFilter:XK,PCFSoftShadowFilter:ZK,PI:WA,PI2:GA,PointShadowFilter:bq,Return:hN,Schlick_to_F0:Tz,ShaderNode:HO,Stack:tk,Switch:ek,TBNViewMatrix:cI,TWO_PI:KA,VSMShadowFilter:QK,V_GGX_SmithCorrelated:mz,Var:yM,VarIntent:xM,abs:bj,acesFilmicToneMapping:eG,acos:gj,acosh:_j,add:_A,addMethodChaining:H,addNodeElement:TN,agxToneMapping:iG,all:JA,alphaT:Lk,ambientOcclusion:tA,and:OA,anisotropy:Rk,anisotropyB:Bk,anisotropyT:zk,any:YA,append:xk,array:dA,asin:mj,asinh:hj,assign:fA,atan:vj,atanh:yj,atomicAdd:HG,atomicAnd:KG,atomicFunc:zG,atomicLoad:BG,atomicMax:WG,atomicMin:GG,atomicOr:qG,atomicStore:VG,atomicSub:UG,atomicXor:JG,attenuationColor:$k,attenuationDistance:Qk,attribute:DN,attributeArray:aW,backgroundBlurriness:lW,backgroundIntensity:uW,backgroundRotation:dW,batch:kL,batchColor:OL,bentNormalView:dI,billboarding:xU,bitAnd:MA,bitNot:NA,bitOr:PA,bitXor:FA,bitangentGeometry:iI,bitangentLocal:aI,bitangentView:oI,bitangentWorld:sI,bitcast:LH,blendBurn:DW,blendColor:jW,blendDodge:OW,blendOverlay:AW,blendScreen:kW,blur:EB,bool:rk,buffer:HN,bufferAttribute:KM,builtin:KN,builtinAOContext:hM,builtinShadowContext:mM,bumpMap:bI,bvec2:sk,bvec3:uk,bvec4:mk,bypass:lN,cache:cN,call:mA,cameraFar:xP,cameraIndex:yP,cameraNear:bP,cameraNormalMatrix:EP,cameraPosition:DP,cameraProjectionMatrix:SP,cameraProjectionMatrixInverse:CP,cameraViewMatrix:wP,cameraViewport:OP,cameraWorldMatrix:TP,cbrt:Yj,cdl:LW,ceil:aj,checker:Oq,cineonToneMapping:QW,clamp:Qj,clearcoat:Ak,clearcoatNormalView:hF,clearcoatRoughness:jk,clipSpace:XP,code:sG,color:nk,colorSpaceToWorking:MM,colorToDirection:gI,compute:aN,computeKernel:iN,computeSkinning:IL,context:dM,convert:yk,convertColorSpace:NM,convertToTexture:YU,cos:uj,cosh:dj,countLeadingZeros:GH,countOneBits:KH,countTrailingZeros:WH,cross:Vj,cubeTexture:jF,cubeTextureBase:AF,dFdx:Tj,dFdy:Ej,dashSize:Kk,debug:xN,decrement:VA,decrementBefore:zA,defaultBuildStages:GD,defaultShaderStages:WD,defined:BO,degrees:ZA,deltaTime:fU,densityFogFactor:_G,depth:hR,depthPass:qW,determinant:Mj,difference:zj,diffuseColor:Tk,diffuseContribution:Ek,directPointLight:Eq,directionToColor:hI,directionToFaceDirection:sF,dispersion:eA,disposeShadowMaterial:eq,distance:Rj,div:bA,dot:Bj,drawIndex:nN,dynamicBufferAttribute:qM,element:vk,emissive:Dk,equal:SA,equirectDirection:HR,equirectUV:VR,exp:QA,exp2:$A,exponentialHeightFogFactor:vG,expression:pN,faceDirection:aF,faceForward:nM,faceforward:sM,float:G,floatBitsToInt:RH,floatBitsToUint:zH,floor:ij,fog:yG,fract:sj,frameGroup:aA,frameId:pU,frontFacing:iF,fwidth:Aj,gain:YH,gapSize:qk,getConstNodeType:VO,getCurrentStack:QO,getDirection:SB,getDistanceAttenuation:Tq,getGeometryRoughness:fz,getNormalFromDepth:QU,getParallaxCorrectNormal:rY,getRoughness:pz,getScreenPosition:ZU,getShIrradianceAt:iY,getShadowMaterial:$K,getShadowRenderObjectFunction:rq,getTextureIndex:PH,getViewPosition:XU,ggxConvolution:AB,globalId:DG,glsl:uG,glslFn:pG,grayscale:MW,greaterThan:TA,greaterThanEqual:DA,hash:qH,highpModelNormalViewMatrix:YP,highpModelViewMatrix:JP,hue:FW,increment:BA,incrementBefore:RA,inspector:wN,instance:wL,instanceColor:CL,instanceIndex:QM,instancedArray:oW,instancedBufferAttribute:JM,instancedDynamicBufferAttribute:YM,instancedMesh:TL,int:K,intBitsToFloat:BH,interleavedGradientNoise:$U,inverse:Nj,inverseSqrt:rj,inversesqrt:cM,invocationLocalIndex:tN,invocationSubgroupIndex:eN,ior:Yk,iridescence:Pk,iridescenceIOR:Fk,iridescenceThickness:Ik,isolate:sN,ivec2:ak,ivec3:ck,ivec4:fk,js:cG,label:gM,length:Sj,lengthSq:Xj,lessThan:wA,lessThanEqual:EA,lightPosition:TK,lightProjectionUV:wK,lightShadowMatrix:CK,lightTargetDirection:OK,lightTargetPosition:EK,lightViewPosition:DK,lightingContext:YL,lights:LK,linearDepth:gR,linearToneMapping:XW,localId:OG,log:ej,log2:tj,logarithmicDepthToViewZ:pR,luminance:IW,mat2:hk,mat3:gk,mat4:_k,matcapUV:bV,materialAO:iL,materialAlphaTest:SI,materialAnisotropy:VI,materialAnisotropyVector:aL,materialAttenuationColor:YI,materialAttenuationDistance:JI,materialClearcoat:FI,materialClearcoatNormal:LI,materialClearcoatRoughness:II,materialColor:CI,materialDispersion:nL,materialEmissive:TI,materialEnvIntensity:CF,materialEnvRotation:wF,materialIOR:qI,materialIridescence:HI,materialIridescenceIOR:UI,materialIridescenceThickness:WI,materialLightMap:rL,materialLineDashOffset:eL,materialLineDashSize:ZI,materialLineGapSize:QI,materialLineScale:XI,materialLineWidth:$I,materialMetalness:NI,materialNormal:PI,materialOpacity:EI,materialPointSize:tL,materialReference:RF,materialReflectivity:jI,materialRefractionRatio:SF,materialRotation:RI,materialRoughness:MI,materialSheen:zI,materialSheenRoughness:BI,materialShininess:wI,materialSpecular:DI,materialSpecularColor:kI,materialSpecularIntensity:OI,materialSpecularStrength:AI,materialThickness:KI,materialTransmission:GI,max:Fj,maxMipLevel:AN,mediumpModelViewMatrix:qP,metalness:kk,min:Pj,mix:Zj,mixElement:iM,mod:xA,modelDirection:RP,modelNormalMatrix:WP,modelPosition:BP,modelRadius:UP,modelScale:VP,modelViewMatrix:KP,modelViewPosition:HP,modelViewProjection:oL,modelWorldMatrix:zP,modelWorldMatrixInverse:GP,morphReference:KL,mrt:FH,mul:yA,mx_aastep:hJ,mx_add:zJ,mx_atan2:GJ,mx_cell_noise_float:PJ,mx_contrast:TJ,mx_divide:HJ,mx_fractal_noise_float:FJ,mx_fractal_noise_vec2:IJ,mx_fractal_noise_vec3:LJ,mx_fractal_noise_vec4:RJ,mx_frame:qJ,mx_heighttonormal:nY,mx_hsvtorgb:fJ,mx_ifequal:ZJ,mx_ifgreater:YJ,mx_ifgreatereq:XJ,mx_invert:JJ,mx_modulo:UJ,mx_multiply:VJ,mx_noise_float:EJ,mx_noise_vec3:DJ,mx_noise_vec4:OJ,mx_place2d:$J,mx_power:WJ,mx_ramp4:yJ,mx_ramplr:_J,mx_ramptb:vJ,mx_rgbtohsv:pJ,mx_rotate2d:eY,mx_rotate3d:tY,mx_safepower:wJ,mx_separate:QJ,mx_splitlr:xJ,mx_splittb:SJ,mx_srgb_texture_to_lin_rec709:mJ,mx_subtract:BJ,mx_timer:KJ,mx_transform_uv:CJ,mx_unifiednoise2d:kJ,mx_unifiednoise3d:AJ,mx_worley_noise_float:jJ,mx_worley_noise_vec2:MJ,mx_worley_noise_vec3:NJ,negate:Cj,negateOnBackSide:oF,neutralToneMapping:aG,nodeArray:KO,nodeImmutable:JO,nodeObject:UO,nodeObjectIntent:WO,nodeObjects:GO,nodeProxy:qO,nodeProxyConstructor:YO,nodeProxyIntent:U,normalFlat:uF,normalGeometry:cF,normalLocal:lF,normalMap:_I,normalView:pF,normalViewGeometry:dF,normalWorld:mF,normalWorldGeometry:fF,normalize:oj,not:AA,notEqual:CA,numWorkgroups:TG,objectDirection:jP,objectGroup:sA,objectPosition:NP,objectRadius:IP,objectScale:PP,objectViewPosition:FP,objectWorldMatrix:MP,oneMinus:wj,or:kA,orthographicDepthToViewZ:cR,oscSawtooth:_U,oscSine:mU,oscSquare:hU,oscTriangle:gU,output:Gk,outputStruct:AH,overloadingFn:uU,overrideNode:bH,overrideNodes:xH,packHalf2x16:tU,packNormalToRGB:fI,packSnorm2x16:$H,packUnorm2x16:eU,parabola:JH,parallaxDirection:lI,parallaxUV:uI,parameter:CH,pass:GW,passTexture:KW,pcurve:XH,perspectiveDepthToViewZ:dR,pmremTexture:sV,pointShadow:Cq,pointUV:sW,pointWidth:Jk,positionGeometry:ZP,positionLocal:QP,positionPrevious:$P,positionView:nF,positionViewDirection:rF,positionWorld:eF,positionWorldDirection:tF,posterize:RW,pow:Hj,pow2:Uj,pow3:Wj,pow4:Gj,premultiplyAlpha:gN,property:Ck,quadBroadcast:bK,quadSwapDiagonal:mK,quadSwapX:fK,quadSwapY:pK,radians:XA,rand:rM,range:SG,rangeFogFactor:gG,reciprocal:Oj,reference:FF,referenceBuffer:IF,reflect:Lj,reflectVector:DF,reflectView:TF,reflector:HU,refract:eM,refractVector:OF,refractView:EF,reinhardToneMapping:ZW,remap:uN,remapClamp:dN,renderGroup:oA,renderOutput:yN,rendererReference:RM,replaceDefaultUV:vU,rotate:CV,rotateUV:yU,roughness:Ok,round:Dj,rtt:JU,sRGBTransferEOTF:EM,sRGBTransferOETF:DM,sample:nW,sampler:zN,samplerComparison:BN,saturate:$j,saturation:NW,screenCoordinate:$N,screenDPR:XN,screenSize:QN,screenUV:ZN,select:lM,setCurrentStack:ZO,setName:pM,shaderStages:KD,shadow:uq,shadowPositionWorld:zK,shapeCircle:kq,sharedUniformGroup:iA,sheen:Mk,sheenRoughness:Nk,shiftLeft:IA,shiftRight:LA,shininess:Wk,sign:xj,sin:cj,sinc:ZH,sinh:lj,skinning:FL,smoothstep:tM,smoothstepElement:aM,specularColor:Vk,specularColorBlended:Hk,specularF90:Uk,spherizeUV:bU,split:bk,spritesheetUV:CU,sqrt:nj,stack:wH,step:Ij,stepElement:oM,storage:_L,storageBarrier:MG,storageTexture:pW,storageTexture3D:hW,struct:OH,sub:vA,subBuild:CM,subgroupAdd:QG,subgroupAll:lK,subgroupAnd:iK,subgroupAny:uK,subgroupBallot:ZG,subgroupBroadcast:hK,subgroupBroadcastFirst:dK,subgroupElect:XG,subgroupExclusiveAdd:eK,subgroupExclusiveMul:rK,subgroupInclusiveAdd:$G,subgroupInclusiveMul:nK,subgroupIndex:$M,subgroupMax:cK,subgroupMin:sK,subgroupMul:tK,subgroupOr:aK,subgroupShuffle:gK,subgroupShuffleDown:yK,subgroupShuffleUp:vK,subgroupShuffleXor:_K,subgroupSize:kG,subgroupXor:oK,tan:fj,tangentGeometry:$F,tangentLocal:eI,tangentView:tI,tangentWorld:nI,tanh:pj,texture:FN,texture3D:_W,texture3DLevel:yW,texture3DLoad:vW,textureBarrier:NG,textureBicubic:Wz,textureBicubicLevel:Uz,textureCubeUV:CB,textureLevel:RN,textureLoad:LN,textureSize:kN,textureStore:mW,thickness:Zk,time:dU,toneMapping:BM,toneMappingExposure:VM,toonOutlinePass:YW,transformDirection:Kj,transformNormal:gF,transformNormalByInverseViewMatrix:Jj,transformNormalByViewMatrix:qj,transformNormalToView:_F,transformedClearcoatNormalView:bF,transformedNormalView:vF,transformedNormalWorld:yF,transmission:Xk,transpose:jj,triNoise3D:cU,triplanarTexture:TU,triplanarTextures:wU,trunc:kj,uint:q,uintBitsToFloat:VH,uniform:lA,uniformArray:GN,uniformCubeTexture:MF,uniformFlow:fM,uniformGroup:rA,uniformTexture:IN,unpackHalf2x16:aU,unpackNormal:mI,unpackRGBToNormal:pI,unpackSnorm2x16:rU,unpackUnorm2x16:iU,unpremultiplyAlpha:_N,userData:xW,uv:ON,uvec2:ok,uvec3:lk,uvec4:pk,varying:wM,varyingProperty:wk,vec2:ik,vec3:J,vec4:dk,vectorComponents:qD,velocity:EW,vertexColor:DR,vertexIndex:ZM,vertexStage:TM,vibrance:PW,viewZToLogarithmicDepth:fR,viewZToOrthographicDepth:oR,viewZToPerspectiveDepth:lR,viewZToReversedOrthographicDepth:sR,viewZToReversedPerspectiveDepth:uR,viewport:eP,viewportCoordinate:nP,viewportDepthTexture:iR,viewportLinearDepth:_R,viewportMipTexture:eR,viewportOpaqueMipTexture:nR,viewportResolution:iP,viewportSafeUV:SU,viewportSharedTexture:BW,viewportSize:tP,viewportTexture:$L,viewportUV:rP,vogelDiskSample:eW,wgsl:lG,wgslFn:mG,workgroupArray:IG,workgroupBarrier:jG,workgroupId:EG,workingToColorSpace:jM,xor:jA}),aY=new vH,oY=class extends VV{constructor(e,t){super(),this.renderer=e,this.nodes=t}update(e,t,n){let r=this.renderer,i=this.nodes.getBackgroundNode(e)||e.background,a=!1;if(i===null)r._clearColor.getRGB(aY),aY.a=r._clearColor.a;else if(i.isColor===!0)i.getRGB(aY),aY.a=1,a=!0;else if(i.isNode===!0){let n=this.get(e),a=i;aY.copy(r._clearColor);let o=n.backgroundMesh;if(o===void 0){let e=dk(a).mul(uW).context({getUV:()=>dW.mul(fF),getTextureLevel:()=>lW}),t=SP.element(3).element(3).equal(1),r=bA(1,SP.element(1).element(1)).mul(3),s=t.select(QP.mul(r),QP),c=KP.mul(dk(s,0)),l=SP.mul(dk(c.xyz,1));l=l.setZ(l.w);let u=new OR;u.name=`Background.material`,u.side=1,u.depthTest=!1,u.depthWrite=!1,u.allowOverride=!1,u.fog=!1,u.lights=!1,u.vertexNode=l,u.colorNode=e,n.backgroundMeshNode=e,n.backgroundMesh=o=new ea(new cs(1,32,32),u),o.frustumCulled=!1,o.name=`Background.mesh`;function d(){i.removeEventListener(`dispose`,d),o.material.dispose(),o.geometry.dispose()}i.addEventListener(`dispose`,d)}let s=a.getCacheKey();n.backgroundCacheKey!==s&&(n.backgroundMeshNode.node=dk(a).mul(uW),n.backgroundMeshNode.needsUpdate=!0,o.material.needsUpdate=!0,n.backgroundCacheKey=s),t.unshift(o,o.geometry,o.material,0,0,null,null)}else I(`Renderer: Unsupported background configuration.`,i);let o=r.xr.getEnvironmentBlendMode();if(o===`additive`?aY.set(0,0,0,1):o===`alpha-blend`&&aY.set(0,0,0,0),r.autoClear===!0||a===!0){let e=n.clearColorValue;e.r=aY.r,e.g=aY.g,e.b=aY.b,e.a=aY.a,(r.backend.isWebGLBackend===!0||r.alpha===!0)&&(e.r*=e.a,e.g*=e.a,e.b*=e.a),n.depthClearValue=r.getClearDepth(),n.stencilClearValue=r.getClearStencil(),n.clearColor=r.autoClearColor===!0,n.clearDepth=r.autoClearDepth===!0,n.clearStencil=r.autoClearStencil===!0}else n.clearColor=!1,n.clearDepth=!1,n.clearStencil=!1}},sY=0,cY=class{constructor(e=``,t=[]){this.name=e,this.bindings=t,this.id=sY++}},lY=class{constructor(e,t,n,r,i,a,o,s,c,l,u=[]){this.vertexShader=e,this.fragmentShader=t,this.computeShader=n,this.transforms=u,this.nodeAttributes=r,this.bindings=i,this.updateNodes=a,this.updateBeforeNodes=o,this.updateAfterNodes=s,this.observer=c,this.hardwareClipping=l,this.usedTimes=0}createBindings(){let e=[];for(let t of this.bindings)if(t.bindings[0].groupNode.shared!==!0){let n=new cY(t.name,[]);e.push(n);for(let e of t.bindings)n.bindings.push(e.clone())}else e.push(t);return e}},uY=class{constructor(e,t,n=null){this.isNodeAttribute=!0,this.name=e,this.type=t,this.node=n}},dY=class{constructor(e,t,n){this.isNodeUniform=!0,this.name=e,this.type=t,this.node=n}get value(){return this.node.value}set value(e){this.node.value=e}get id(){return this.node.id}get groupNode(){return this.node.groupNode}},fY=class{constructor(e,t,n=!1,r=null){this.isNodeVar=!0,this.name=e,this.type=t,this.readOnly=n,this.count=r}},pY=class extends fY{constructor(e,t,n=null,r=null){super(e,t),this.needsInterpolation=!1,this.isNodeVarying=!0,this.interpolationType=n,this.interpolationSampling=r}},mY=class{constructor(e,t,n=``){this.name=e,this.type=t,this.code=n,Object.defineProperty(this,`isNodeCode`,{value:!0})}},hY=0,gY=class{constructor(e=null){this.id=hY++,this.nodesData=new WeakMap,this.parent=e}getData(e){let t=this.nodesData.get(e);return t===void 0&&this.parent!==null&&(t=this.parent.getData(e)),t}setData(e,t){this.nodesData.set(e,t)}},_Y=class{constructor(e,t){this.name=e,this.members=t,this.output=!1}},vY=class{constructor(e,t){this.name=e,this.value=t,this.boundary=0,this.itemSize=0,this.offset=0,this.index=-1}setValue(e){this.value=e}getValue(){return this.value}},yY=class extends vY{constructor(e,t=0){super(e,t),this.isNumberUniform=!0,this.boundary=4,this.itemSize=1}},bY=class extends vY{constructor(e,t=new L){super(e,t),this.isVector2Uniform=!0,this.boundary=8,this.itemSize=2}},xY=class extends vY{constructor(e,t=new R){super(e,t),this.isVector3Uniform=!0,this.boundary=16,this.itemSize=3}},SY=class extends vY{constructor(e,t=new Hn){super(e,t),this.isVector4Uniform=!0,this.boundary=16,this.itemSize=4}},CY=class extends vY{constructor(e,t=new Er){super(e,t),this.isColorUniform=!0,this.boundary=16,this.itemSize=3}},wY=class extends vY{constructor(e,t=new Xc){super(e,t),this.isMatrix2Uniform=!0,this.boundary=8,this.itemSize=4}},TY=class extends vY{constructor(e,t=new En){super(e,t),this.isMatrix3Uniform=!0,this.boundary=48,this.itemSize=12}},EY=class extends vY{constructor(e,t=new qn){super(e,t),this.isMatrix4Uniform=!0,this.boundary=64,this.itemSize=16}},DY=class extends yY{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}},OY=class extends bY{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}},kY=class extends xY{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}},AY=class extends SY{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}},jY=class extends CY{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}},MY=class extends wY{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}},NY=class extends TY{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}},PY=class extends EY{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}},FY=0,IY=new WeakMap,LY=new WeakMap,RY=new WeakMap,zY=new Map([[Int8Array,`int`],[Int16Array,`int`],[Int32Array,`int`],[Uint8Array,`uint`],[Uint16Array,`uint`],[Uint32Array,`uint`],[Float32Array,`float`]]),BY=e=>/e/g.test(e)?String(e).replace(/\+/g,``):(e=Number(e),e+(e%1?``:`.0`)),VY=e=>{if(e.writeUsageCount>0)return!0;if(e.subBuildsCache!==void 0){for(let t in e.subBuildsCache)if(VY(e.subBuildsCache[t]))return!0}return!1},HY=class{constructor(e,t,n){this.object=e,this.material=e&&e.material||null,this.geometry=e&&e.geometry||null,this.renderer=t,this.parser=n,this.scene=null,this.camera=null,this.nodes=new Set,this.sequentialNodes=new Set,this.updateNodes=[],this.updateBeforeNodes=[],this.updateAfterNodes=[],this.hashNodes={},this.observer=null,this.lightsNode=null,this.environmentNode=null,this.fogNode=null,this.clippingContext=null,this.hardwareClipping=!1,this.vertexShader=null,this.fragmentShader=null,this.computeShader=null,this.flowNodes={vertex:[],fragment:[],compute:[]},this.flowCode={vertex:``,fragment:``,compute:``},this.uniforms={vertex:[],fragment:[],compute:[],index:0},this.structs={vertex:[],fragment:[],compute:[],index:0},this.types={vertex:[],fragment:[],compute:[],index:0},this.bindings={vertex:{},fragment:{},compute:{}},this.bindingsIndexes={},this.bindGroups=null,this.attributes=[],this.bufferAttributes=[],this.varyings=[],this.codes={},this.vars={},this.declarations={},this.flow={code:``},this.chaining=[],this.stack=wH(),this.stacks=[],this.tab=` `,this.currentFunctionNode=null,this.context={material:this.material},this.cache=new gY,this.globalCache=this.cache,this.flowsData=new WeakMap,this.shaderStage=null,this.buildStage=null,this.subBuildLayers=[],this.activeStacks=[],this.subBuildFn=null,this.fnCall=null,Object.defineProperty(this,`id`,{value:FY++})}isFlatShading(){return this.material.flatShading===!0||this.geometry.hasAttribute(`normal`)===!1}isOpaque(){let e=this.material;return e.transparent===!1&&e.blending===1&&e.alphaToCoverage===!1}createRenderTarget(e,t,n){return new Un(e,t,n)}createCubeRenderTarget(e,t){return new UR(e,t)}includes(e){return this.nodes.has(e)}getOutputType(e=0){let t=`vec4`,n=this.renderer.getRenderTarget();if(n!==null){let r=n.textures[e].type,i=n.textures[e].format,a=`vec`;r===1013?a=`ivec`:r===1014&&(a=`uvec`),t=i===1028||i===1029?r===1013?`int`:r===1014?`uint`:`float`:i===1030||i===1031?`${a}2`:i===1022||i===1032?`${a}3`:`${a}4`}return t}getOutputStructName(){}_getBindGroup(e,t){let n=t[0].groupNode,r=n.shared;if(r)for(let e=1;ee.nodeUniform.node.id-t.nodeUniform.node.id);for(let t of e.uniforms)n+=t.nodeUniform.node.id}else n+=e.nodeUniform.id;let r=this.renderer._currentRenderContext||this.renderer,a=IY.get(r);a===void 0&&(a=new Map,IY.set(r,a));let o=TD(n);i=a.get(o),i===void 0&&(i=new cY(e,t),a.set(o,i))}else i=new cY(e,t);return i}getBindGroupArray(e,t){let n=this.bindings[t],r=n[e];return r===void 0&&(this.bindingsIndexes[e]===void 0&&(this.bindingsIndexes[e]={binding:0,group:Object.keys(this.bindingsIndexes).length}),n[e]=r=[]),r}getBindings(){let e=this.bindGroups;if(e===null){let t={},n=this.bindings;for(let e of KD)for(let r in n[e]){let i=n[e][r],a=t[r]||(t[r]=[]);for(let e of i)a.includes(e)===!1&&a.push(e)}for(let n in e=[],t){let r=t[n],i=this._getBindGroup(n,r);e.push(i)}this.bindGroups=e}return e}sortBindingGroups(){let e=this.getBindings();e.sort((e,t)=>e.bindings[0].groupNode.order-t.bindings[0].groupNode.order);for(let t=0;t=0?`${Math.round(t)}u`:`0u`;if(e===`bool`)return t?`true`:`false`;if(e===`color`)return`${this.getType(`vec3`)}( ${BY(t.r)}, ${BY(t.g)}, ${BY(t.b)} )`;let n=this.getTypeLength(e),r=this.getComponentType(e),i=e=>this.generateConst(r,e);if(n===2)return`${this.getType(e)}( ${i(t.x)}, ${i(t.y)} )`;if(n===3)return`${this.getType(e)}( ${i(t.x)}, ${i(t.y)}, ${i(t.z)} )`;if(n===4&&e!==`mat2`)return`${this.getType(e)}( ${i(t.x)}, ${i(t.y)}, ${i(t.z)}, ${i(t.w)} )`;if(n>=4&&t&&(t.isMatrix2||t.isMatrix3||t.isMatrix4))return`${this.getType(e)}( ${t.elements.map(i).join(`, `)} )`;if(n>4)return`${this.getType(e)}()`;throw Error(`THREE.NodeBuilder: Type '${e}' not found in generate constant attempt.`)}getType(e){return e===`color`?`vec3`:e}hasGeometryAttribute(e){return this.geometry&&this.geometry.getAttribute(e)!==void 0}getAttribute(e,t){let n=this.attributes;for(let t of n)if(t.name===e)return t;let r=new uY(e,t);return this.registerDeclaration(r),n.push(r),r}getPropertyName(e){return e.name}isVector(e){return/vec\d/.test(e)}isMatrix(e){return/mat\d/.test(e)}isReference(e){return e===`void`||e===`property`||e===`sampler`||e===`samplerComparison`||e===`texture`||e===`cubeTexture`||e===`storageTexture`||e===`depthTexture`||e===`texture3D`}needsToWorkingColorSpace(){return!1}getComponentTypeFromTexture(e){let t=e.type;return e.isDepthTexture===!0?`float`:t===1013?`int`:t===1014?`uint`:`float`}getElementType(e){return e===`mat2`?`vec2`:e===`mat3`?`vec3`:e===`mat4`?`vec4`:this.getComponentType(e)}getComponentType(e){if(e=this.getVectorType(e),e===`float`||e===`bool`||e===`int`||e===`uint`)return e;let t=/(b|i|u|)(vec|mat)([2-4])/.exec(e);return t===null?null:t[1]===`b`?`bool`:t[1]===`i`?`int`:t[1]===`u`?`uint`:`float`}getVectorType(e){return e===`color`?`vec3`:e===`texture`||e===`cubeTexture`||e===`storageTexture`||e===`texture3D`?`vec4`:e}getTypeFromLength(e,t=`float`){if(e===1)return t;let n=AD(e),r=t===`float`?``:t[0];return/mat2/.test(t)===!0&&(n=n.replace(`vec`,`mat`)),r+n}getTypeFromArray(e){return zY.get(e.constructor)}isInteger(e){return/int|uint|(i|u)vec/.test(e)}getTypeFromAttribute(e){let t=e;e.isInterleavedBufferAttribute&&(t=e.data);let n=t.array,r=e.itemSize,i=e.normalized,a;return!(e instanceof mi)&&i!==!0&&(a=this.getTypeFromArray(n)),this.getTypeFromLength(r,a)}getTypeLength(e){let t=this.getVectorType(e),n=/vec([2-4])/.exec(t);return n===null?t===`float`||t===`bool`||t===`int`||t===`uint`?1:/mat2/.test(e)===!0?4:/mat3/.test(e)===!0?9:/mat4/.test(e)===!0?16:0:Number(n[1])}getVectorFromMatrix(e){return e.replace(`mat`,`vec`)}changeComponentType(e,t){return this.getTypeFromLength(this.getTypeLength(e),t)}getIntegerType(e){let t=this.getComponentType(e);return t===`int`||t===`uint`?e:this.changeComponentType(e,`int`)}setActiveStack(e){this.activeStacks.push(e)}removeActiveStack(e){if(this.activeStacks[this.activeStacks.length-1]===e)this.activeStacks.pop();else throw Error(`THREE.NodeBuilder: Invalid active stack removal.`)}getActiveStack(){return this.activeStacks[this.activeStacks.length-1]}getBaseStack(){return this.activeStacks[0]}addStack(){this.stack=wH(this.stack);let e=QO();return this.stacks.push(e),ZO(this.stack),this.stack}removeStack(){let e=this.stack;for(let t of e.nodes){let n=this.getDataFromNode(t);n.stack=e}return this.stack=e.parent,ZO(this.stacks.pop()),e}getDataFromNode(e,t=this.shaderStage,n=null){n=n===null?e.isGlobal(this)?this.globalCache:this.cache:n;let r=n.getData(e);r===void 0&&(r={},n.setData(e,r)),r[t]===void 0&&(r[t]={});let i=r[t];if(this.subBuildLayers.length===0)return i;let a=r.any?r.any.subBuilds:null,o=this.getClosestSubBuild(a);return o&&(i.subBuildsCache===void 0&&(i.subBuildsCache={}),i=i.subBuildsCache[o]||(i.subBuildsCache[o]={}),i.subBuilds=a),i}getNodeProperties(e,t=`any`){let n=this.getDataFromNode(e,t);return n.properties||={outputNode:null}}getBufferAttributeFromNode(e,t,n=null){let r=this.getDataFromNode(e,`vertex`),i=r.bufferAttribute;if(i===void 0){let a=this.uniforms.index++;n===null&&(n=`nodeAttribute`+a),i=new uY(n,t,e),this.bufferAttributes.push(i),r.bufferAttribute=i}return i}getStructTypeNode(e,t=this.shaderStage){return this.types[t][e]||null}getStructTypeFromNode(e,t,n=null,r=this.shaderStage){let i=this.getDataFromNode(e,r,this.globalCache),a=i.structType;if(a===void 0){let o=this.structs.index++;n===null&&(n=`StructType`+o),a=new _Y(n,t),this.structs[r].push(a),this.types[r][n]=e,i.structType=a}return a}getOutputStructTypeFromNode(e,t){let n=this.getStructTypeFromNode(e,t,`OutputType`,`fragment`);return n.output=!0,n}getUniformFromNode(e,t,n=this.shaderStage,r=null){let i=this.getDataFromNode(e,n,this.globalCache),a=i.uniform;if(a===void 0){let o=this.uniforms.index++;a=new dY(r||`nodeUniform`+o,t,e),this.uniforms[n].push(a),this.registerDeclaration(a),i.uniform=a}return a}getVarFromNode(e,t=null,n=e.getNodeType(this),r=this.shaderStage,i=!1){let a=this.getDataFromNode(e,r),o=this.getSubBuildProperty(`variable`,a.subBuilds),s=a[o];if(s===void 0){let c=i?`_const`:`_var`,l=this.vars[r]||(this.vars[r]=[]),u=this.vars[c]||(this.vars[c]=0);t===null&&(t=(i?`nodeConst`:`nodeVar`)+u,this.vars[c]++),o!==`variable`&&(t=this.getSubBuildProperty(t,a.subBuilds));let d=e.getArrayCount(this);s=new fY(t,n,i,d),i||l.push(s),this.registerDeclaration(s),a[o]=s}return s}isDeterministic(e){if(e.isMathNode)return this.isDeterministic(e.aNode)&&(e.bNode?this.isDeterministic(e.bNode):!0)&&(e.cNode?this.isDeterministic(e.cNode):!0);if(e.isOperatorNode)return this.isDeterministic(e.aNode)&&(e.bNode?this.isDeterministic(e.bNode):!0);if(e.isArrayNode){if(e.values!==null){for(let t of e.values)if(!this.isDeterministic(t))return!1}return!0}else if(e.isConstNode)return!0;return!1}getVaryingFromNode(e,t=null,n=e.getNodeType(this),r=null,i=null){let a=this.getDataFromNode(e,`any`),o=this.getSubBuildProperty(`varying`,a.subBuilds),s=a[o];if(s===void 0){let e=this.varyings,c=e.length;t===null&&(t=`nodeVarying`+c),o!==`varying`&&(t=this.getSubBuildProperty(t,a.subBuilds)),s=new pY(t,n,r,i),e.push(s),this.registerDeclaration(s),a[o]=s}return s}registerDeclaration(e){let t=this.shaderStage,n=this.declarations[t]||(this.declarations[t]={}),r=e.name,i=r,a=this.getPropertyName(e),o=1;for(;n[a]!==void 0;)i=r+`_`+ o++,e.name=i,a=this.getPropertyName(e);i!==r&&F(`TSL: Declaration name '${r}' of '${e.type}' already in use. Renamed to '${i}'.`),n[a]=e}getCodeFromNode(e,t,n=this.shaderStage){let r=this.getDataFromNode(e),i=r.code;if(i===void 0){let e=this.codes[n]||(this.codes[n]=[]),a=e.length;i=new mY(`nodeCode`+a,t),e.push(i),r.code=i}return i}addFlowCodeHierarchy(e,t){let{flowCodes:n,flowCodeBlock:r}=this.getDataFromNode(e),i=!0,a=t;for(;a;){if(r.get(a)===!0){i=!1;break}a=this.getDataFromNode(a).parentNodeBlock}if(i)for(let e of n)this.addLineFlowCode(e)}addLineFlowCodeBlock(e,t,n){let r=this.getDataFromNode(e),i=r.flowCodes||=[],a=r.flowCodeBlock||=new WeakMap;i.push(t),a.set(n,!0)}addLineFlowCode(e,t=null){return e===``?this:(t!==null&&this.context.nodeBlock&&this.addLineFlowCodeBlock(t,e,this.context.nodeBlock),e=this.tab+e,/;\s*$/.test(e)||(e+=`; `),this.flow.code+=e,this)}addFlowCode(e){return this.flow.code+=e,this}addFlowTab(){return this.tab+=` `,this}removeFlowTab(){return this.tab=this.tab.slice(0,-1),this}getFlowData(e){return this.flowsData.get(e)}flowNode(e){let t=e.getNodeType(this),n=this.flowChildNode(e,t);return this.flowsData.set(e,n),n}addInclude(e){this.currentFunctionNode!==null&&this.currentFunctionNode.includes.push(e)}buildFunctionNode(e){let t=this.renderer.backend,n=LY.get(t);n===void 0&&(n=new WeakMap,LY.set(t,n));let r=n.get(e);if(r===void 0){r=new dG;let t=this.currentFunctionNode;this.currentFunctionNode=r,r.code=this.buildFunctionCode(e),this.currentFunctionNode=t,n.set(e,r)}return r}flowShaderNode(e){let t=e.layout,n={[Symbol.iterator](){let e=0,t=Object.values(this);return{next:()=>({value:t[e],done:e++>=t.length})}}};for(let e of t.inputs)n[e.name]=new SH(e.type,e.name);e.layout=null;let r=e.call(n),i=this.flowStagesNode(r,t.type);return e.layout=t,i}flowBuildStage(e,t,n=null){let r=this.getBuildStage();this.setBuildStage(t);let i=e.build(this,n);return this.setBuildStage(r),i}flowStagesNode(e,t=null){let n=this.flow,r=this.vars,i=this.declarations,a=this.cache,o=this.buildStage,s=this.stack,c={code:``};this.flow=c,this.vars={},this.declarations={},this.cache=new gY,this.stack=wH();for(let n of GD)this.setBuildStage(n),c.result=e.build(this,t);return c.vars=this.getVars(this.shaderStage),this.flow=n,this.vars=r,this.declarations=i,this.cache=a,this.stack=s,this.setBuildStage(o),c}getFunctionOperator(){return null}buildFunctionCode(){F(`Abstract function.`)}flowChildNode(e,t=null){let n=this.flow,r={code:``};return this.flow=r,r.result=e.build(this,t),this.flow=n,r}flowNodeFromShaderStage(e,t,n=null,r=null){let i=this.tab,a=this.cache,o=this.shaderStage,s=this.context;this.setShaderStage(e);let c={...this.context};delete c.nodeBlock,this.cache=this.globalCache,this.tab=` `,this.context=c;let l=null;if(this.buildStage===`generate`){let i=this.flowChildNode(t,n);r!==null&&(i.code+=`${this.tab+r} = ${i.result};\n`),this.flowCode[e]=this.flowCode[e]+i.code,l=i}else l=t.build(this);return this.setShaderStage(o),this.cache=a,this.tab=i,this.context=s,l}getAttributesArray(){return this.attributes.concat(this.bufferAttributes)}getAttributes(){F(`Abstract function.`)}getVaryings(){F(`Abstract function.`)}getVar(e,t,n=null){return`${n===null?this.getType(e):this.generateArrayDeclaration(e,n)} ${t}`}getVars(e,t=!1){let n=[],r=this.vars[e];if(r!==void 0)for(let e of r)n.push(`${this.getVar(e.type,e.name,e.count)};`);return n.join(t?` `:` `)}getUniforms(){F(`Abstract function.`)}getCodes(e){let t=this.codes[e],n=``;if(t!==void 0)for(let e of t)n+=e.code+` `;return n}getHash(){return this.vertexShader+this.fragmentShader+this.computeShader}setShaderStage(e){this.shaderStage=e}getShaderStage(){return this.shaderStage}setBuildStage(e){this.buildStage=e}getBuildStage(){return this.buildStage}buildCode(){F(`Abstract function.`)}get subBuild(){return this.subBuildLayers[this.subBuildLayers.length-1]||null}addSubBuild(e){this.subBuildLayers.push(e)}removeSubBuild(){return this.subBuildLayers.pop()}getClosestSubBuild(e){let t;if(t=e&&e.isNode?e.isShaderCallNodeInternal?e.shaderNode.subBuilds:e.isStackNode?[e.subBuild]:this.getDataFromNode(e,`any`).subBuilds:e instanceof Set?[...e]:e,!t)return null;let n=this.subBuildLayers;for(let e=t.length-1;e>=0;e--){let r=t[e];if(n.includes(r))return r}return null}getSubBuildOutput(e){return this.getSubBuildProperty(`outputNode`,e)}getSubBuildProperty(e=``,t=null){let n;n=t===null?this.subBuildFn:this.getClosestSubBuild(t);let r;return r=n?e?n+`_`+e:n:e,r}prebuild(){let{object:e,renderer:t,material:n}=this;if(t.contextNode.isContextNode===!0?this.context={...this.context,...t.contextNode.getFlowContextData()}:I('NodeBuilder: "renderer.contextNode" must be an instance of `context()`.'),n&&n.contextNode&&(n.contextNode.isContextNode===!0?this.context={...this.context,...n.contextNode.getFlowContextData()}:I('NodeBuilder: "material.contextNode" must be an instance of `context()`.')),n!==null){let e=t.library.fromMaterial(n);e===null&&(I(`NodeBuilder: Material "${n.type}" is not compatible.`),e=new OR),e.build(this)}else this.addFlow(`compute`,e)}build(){this.prebuild();for(let e of GD){this.setBuildStage(e),this.context.position&&this.context.position.isNode&&this.flowNodeFromShaderStage(`vertex`,this.context.position);for(let t of KD){this.setShaderStage(t);let n=this.flowNodes[t];for(let t of n)e===`generate`?this.flowNode(t):t.build(this)}}return this.setBuildStage(null),this.setShaderStage(null),this.buildCode(),this.buildUpdateNodes(),this}async buildAsync(){this.prebuild();for(let e of GD){this.setBuildStage(e),this.context.position&&this.context.position.isNode&&this.flowNodeFromShaderStage(`vertex`,this.context.position);for(let t of KD){this.setShaderStage(t);let n=this.flowNodes[t];for(let t of n)e===`generate`?this.flowNode(t):t.build(this);await Gt()}}return this.setBuildStage(null),this.setShaderStage(null),this.buildCode(),this.buildUpdateNodes(),this}getSharedDataFromNode(e){let t=RY.get(e);return t===void 0&&(t={}),t}getNodeUniform(e,t){let n=this.getSharedDataFromNode(e),r=n.cache;if(r===void 0){if(t===`float`||t===`int`||t===`uint`)r=new DY(e);else if(t===`vec2`||t===`ivec2`||t===`uvec2`)r=new OY(e);else if(t===`vec3`||t===`ivec3`||t===`uvec3`)r=new kY(e);else if(t===`vec4`||t===`ivec4`||t===`uvec4`)r=new AY(e);else if(t===`color`)r=new jY(e);else if(t===`mat2`)r=new MY(e);else if(t===`mat3`)r=new NY(e);else if(t===`mat4`)r=new PY(e);else throw Error(`THREE.NodeBuilder: Uniform "${t}" not implemented.`);n.cache=r}return r}format(e,t,n){if(t=this.getVectorType(t),n=this.getVectorType(n),t===n||n===null||this.isReference(n))return e;let r=this.getTypeLength(t),i=this.getTypeLength(n);return r===16&&i===9?`${this.getType(n)}( ${e}[ 0 ].xyz, ${e}[ 1 ].xyz, ${e}[ 2 ].xyz )`:r===9&&i===4?`${this.getType(n)}( ${e}[ 0 ].xy, ${e}[ 1 ].xy )`:r>4||i>4||i===0?e:r===i?`${this.getType(n)}( ${e} )`:r>i?(e=n===`bool`?`all( ${e} )`:`${e}.${`xyz`.slice(0,i)}`,this.format(e,this.getTypeFromLength(i,this.getComponentType(t)),n)):i===4&&r>1?`${this.getType(n)}( ${this.format(e,t,`vec3`)}, 1.0 )`:r===2?`${this.getType(n)}( ${this.format(e,t,`vec2`)}, 0.0 )`:(r===1&&i>1&&t!==this.getComponentType(n)&&(e=`${this.getType(this.getComponentType(n))}( ${e} )`),`${this.getType(n)}( ${e} )`)}getSignature(){return`// Three.js r185 - Node System `}needsPreviousData(){let e=this.renderer.getMRT();return e&&e.has(`velocity`)||LD(this.object).useVelocity===!0}},UY=class{constructor(){this.time=0,this.deltaTime=0,this.frameId=0,this.renderId=0,this.updateMap=new WeakMap,this.updateBeforeMap=new WeakMap,this.updateAfterMap=new WeakMap,this.renderer=null,this.material=null,this.camera=null,this.object=null,this.scene=null}_getMaps(e,t){let n=e.get(t);return n===void 0&&(n={renderId:0,frameId:0},e.set(t,n)),n}updateBeforeNode(e){let t=e.getUpdateBeforeType(),n=e.updateReference(this);if(t===VD.FRAME){let t=this._getMaps(this.updateBeforeMap,n);if(t.frameId!==this.frameId){let n=t.frameId;t.frameId=this.frameId,e.updateBefore(this)===!1&&(t.frameId=n)}}else if(t===VD.RENDER){let t=this._getMaps(this.updateBeforeMap,n);if(t.renderId!==this.renderId){let n=t.renderId;t.renderId=this.renderId,e.updateBefore(this)===!1&&(t.renderId=n)}}else t===VD.OBJECT&&e.updateBefore(this)}updateAfterNode(e){let t=e.getUpdateAfterType(),n=e.updateReference(this);if(t===VD.FRAME){let t=this._getMaps(this.updateAfterMap,n);t.frameId!==this.frameId&&e.updateAfter(this)!==!1&&(t.frameId=this.frameId)}else if(t===VD.RENDER){let t=this._getMaps(this.updateAfterMap,n);t.renderId!==this.renderId&&e.updateAfter(this)!==!1&&(t.renderId=this.renderId)}else t===VD.OBJECT&&e.updateAfter(this)}updateNode(e){let t=e.getUpdateType(),n=e.updateReference(this);if(t===VD.FRAME){let t=this._getMaps(this.updateMap,n);t.frameId!==this.frameId&&e.update(this)!==!1&&(t.frameId=this.frameId)}else if(t===VD.RENDER){let t=this._getMaps(this.updateMap,n);t.renderId!==this.renderId&&e.update(this)!==!1&&(t.renderId=this.renderId)}else t===VD.OBJECT&&e.update(this)}update(){this.frameId++,this.lastTime===void 0&&(this.lastTime=performance.now()),this.deltaTime=(performance.now()-this.lastTime)/1e3,this.lastTime=performance.now(),this.time+=this.deltaTime}},WY=class{constructor(e,t,n=null,r=``,i=!1){this.type=e,this.name=t,this.count=n,this.qualifier=r,this.isConst=i}};WY.isNodeFunctionInput=!0;var GY=class extends wq{static get type(){return`AmbientLightNode`}constructor(e=null){super(e)}setup({context:e}){e.irradiance.addAssign(this.colorNode)}},KY=class extends wq{static get type(){return`DirectionalLightNode`}constructor(e=null){super(e)}setupDirect(){let e=this.colorNode;return{lightDirection:OK(this.light),lightColor:e}}},qY=class extends wq{static get type(){return`HemisphereLightNode`}constructor(e=null){super(e),this.lightPositionNode=TK(e),this.lightDirectionNode=this.lightPositionNode.normalize(),this.groundColorNode=lA(new Er).setGroup(oA)}update(e){let{light:t}=this;super.update(e),this.lightPositionNode.object3d=t,this.groundColorNode.value.copy(t.groundColor).multiplyScalar(t.intensity)}setup(e){let{colorNode:t,groundColorNode:n,lightDirectionNode:r}=this,i=Zj(n,t,mF.dot(r).mul(.5).add(.5));e.context.irradiance.addAssign(i)}},JY=class extends wq{static get type(){return`SpotLightNode`}constructor(e=null){super(e),this.coneCosNode=lA(0).setGroup(oA),this.penumbraCosNode=lA(0).setGroup(oA),this.cutoffDistanceNode=lA(0).setGroup(oA),this.decayExponentNode=lA(0).setGroup(oA),this.colorNode=lA(this.color).setGroup(oA)}update(e){super.update(e);let{light:t}=this;this.coneCosNode.value=Math.cos(t.angle),this.penumbraCosNode.value=Math.cos(t.angle*(1-t.penumbra)),this.cutoffDistanceNode.value=t.distance,this.decayExponentNode.value=t.decay}getSpotAttenuation(e,t){let{coneCosNode:n,penumbraCosNode:r}=this;return tM(n,r,t)}getLightCoord(e){let t=e.getNodeProperties(this),n=t.projectionUV;return n===void 0&&(n=wK(this.light,e.context.positionWorld),t.projectionUV=n),n}setupDirect(e){let{colorNode:t,cutoffDistanceNode:n,decayExponentNode:r,light:i}=this,a=this.getLightVector(e),o=a.normalize(),s=o.dot(OK(i)),c=this.getSpotAttenuation(e,s),l=Tq({lightDistance:a.length(),cutoffDistance:n,decayExponent:r}),u=t.mul(c).mul(l),d,f;return i.colorNode?(f=this.getLightCoord(e),d=i.colorNode(f)):i.map&&(f=this.getLightCoord(e),d=FN(i.map,f.xy).onRenderUpdate(()=>i.map)),d&&(u=f.mul(2).sub(1).abs().lessThan(1).all().select(u.mul(d),u)),{lightColor:u,lightDirection:o}}},YY=class extends JY{static get type(){return`IESSpotLightNode`}constructor(e=null){super(e),this._iesTextureNode=null}getSpotAttenuation(e,t){let n=this.light.iesMap,r=null;return n&&n.isTexture===!0?(this._iesTextureNode=FN(n,ik(t.acos().mul(1/Math.PI),0),0),r=this._iesTextureNode.r):r=super.getSpotAttenuation(e,t),r}update(e){super.update(e),this._iesTextureNode!==null&&this.light.iesMap&&(this._iesTextureNode.value=this.light.iesMap)}},XY=class extends wq{static get type(){return`LightProbeNode`}constructor(e=null){super(e);let t=[];for(let e=0;e<9;e++)t.push(new R);this.lightProbe=GN(t)}update(e){let{light:t}=this;super.update(e);for(let e=0;e<9;e++)this.lightProbe.array[e].copy(t.sh.coefficients[e]).multiplyScalar(t.intensity)}setup(e){let t=iY(mF,this.lightProbe);e.context.irradiance.addAssign(t)}},ZY=W(([e,t])=>{let n=e.abs().sub(t);return Sj(Fj(n,0)).add(Pj(Fj(n.x,n.y),0))}),QY=class extends JY{static get type(){return`ProjectorLightNode`}update(e){super.update(e);let t=this.light;if(this.penumbraCosNode.value=Math.min(Math.cos(t.angle*(1-t.penumbra)),.99999),t.aspect===null){let e=1;t.map!==null&&(e=t.map.width/t.map.height),t.shadow.aspect=e}else t.shadow.aspect=t.aspect}getSpotAttenuation(e){let t=G(0),n=this.penumbraCosNode,r=CK(this.light).mul(e.context.positionWorld||eF);return $O(r.w.greaterThan(0),()=>{let e=ZY(r.xyz.div(r.w).xy.sub(ik(.5)),ik(.5)),i=bA(-1,vA(1,gj(n)).sub(1));t.assign($j(e.mul(-2).mul(i)))}),t}},$Y=new qn,eX=new qn,tX=null,nX=class extends wq{static get type(){return`RectAreaLightNode`}constructor(e=null){super(e),this.halfHeight=lA(new R).setGroup(oA),this.halfWidth=lA(new R).setGroup(oA),this.updateType=VD.RENDER}update(e){super.update(e);let{light:t}=this,n=e.camera.matrixWorldInverse;eX.identity(),$Y.copy(t.matrixWorld),$Y.premultiply(n),eX.extractRotation($Y),this.halfWidth.value.set(t.width*.5,0,0),this.halfHeight.value.set(0,t.height*.5,0),this.halfWidth.value.applyMatrix4(eX),this.halfHeight.value.applyMatrix4(eX)}setupDirectRectArea(e){let t,n;e.isAvailable(`float32Filterable`)?(t=FN(tX.LTC_FLOAT_1),n=FN(tX.LTC_FLOAT_2)):(t=FN(tX.LTC_HALF_1),n=FN(tX.LTC_HALF_2));let{colorNode:r,light:i}=this;return{lightColor:r,lightPosition:DK(i),halfWidth:this.halfWidth,halfHeight:this.halfHeight,ltc_1:t,ltc_2:n}}static setLTC(e){tX=e}},rX=class{parseFunction(){F(`Abstract function.`)}},iX=class{constructor(e,t,n=``,r=``){this.type=e,this.inputs=t,this.name=n,this.precision=r}getCode(){F(`Abstract function.`)}};iX.isNodeFunction=!0;var aX=/^\s*(highp|mediump|lowp)?\s*([a-z_0-9]+)\s*([a-z_0-9]+)?\s*\(([\s\S]*?)\)/i,oX=/[a-z_0-9]+/gi,sX=`#pragma main`,cX=e=>{e=e.trim();let t=e.indexOf(sX),n=t===-1?e:e.slice(t+12),r=n.match(aX);if(r!==null&&r.length===5){let i=r[4],a=[],o=null;for(;(o=oX.exec(i))!==null;)a.push(o);let s=[],c=0;for(;c{let n=this._createNodeBuilder(e,e.material);try{t?await n.buildAsync():n.build()}catch(r){n=this._createNodeBuilder(e,new OR),t?await n.buildAsync():n.build(),I(`TSL: `+r)}return n};if(t)return o().then(e=>(r=this._createNodeBuilderState(e),i.set(a,r),r.usedTimes++,n.nodeBuilderState=r,r));{let t=this._createNodeBuilder(e,e.material);try{t.build()}catch(n){t=this._createNodeBuilder(e,new OR),t.build();let r=n.stackTrace;!r&&n.stack&&(r=new CD(n.stack)),I(`TSL: `+n,r)}r=this._createNodeBuilderState(t),i.set(a,r)}}r.usedTimes++,n.nodeBuilderState=r}return r}getForRenderAsync(e){let t=this.getForRender(e,!0);return t.then?t:Promise.resolve(t)}getForRenderDeferred(e){let t=this.get(e);if(t.nodeBuilderState!==void 0)return t.nodeBuilderState;let n=this.getForRenderCacheKey(e),r=this.nodeBuilderCache.get(n);return r===void 0?(t.pendingBuild!==!0&&(t.pendingBuild=!0,this._buildQueue.push(()=>this.getForRenderAsync(e).then(()=>{t.pendingBuild=!1})),this._processBuildQueue()),null):(r.usedTimes++,t.nodeBuilderState=r,r)}_processBuildQueue(){this._buildInProgress||this._buildQueue.length===0||(this._buildInProgress=!0,this._buildQueue.shift()().then(()=>{this._buildInProgress=!1,this._processBuildQueue()}))}delete(e){if(e.isRenderObject){let t=this.get(e).nodeBuilderState;t!==void 0&&(t.usedTimes--,t.usedTimes===0&&this.nodeBuilderCache.delete(this.getForRenderCacheKey(e)))}return super.delete(e)}getForCompute(e){let t=this.get(e),n=t.nodeBuilderState;if(n===void 0||t.version!==e.version){let r=this.backend.createNodeBuilder(e,this.renderer);r.build(),n=this._createNodeBuilderState(r),t.nodeBuilderState=n,t.version=e.version}return n}_createNodeBuilderState(e){return new lY(e.vertexShader,e.fragmentShader,e.computeShader,e.getAttributesArray(),e.getBindings(),e.updateNodes,e.updateBeforeNodes,e.updateAfterNodes,e.observer,e.hardwareClipping,e.transforms)}getEnvironmentNode(e){if(this.renderer.lighting.enabled===!1)return null;this.updateEnvironment(e);let t=null;if(e.environmentNode&&e.environmentNode.isNode)t=e.environmentNode;else{let n=this.get(e);n.environmentNode&&(t=n.environmentNode)}return t}getBackgroundNode(e){this.updateBackground(e);let t=null;if(e.backgroundNode&&e.backgroundNode.isNode)t=e.backgroundNode;else{let n=this.get(e);n.backgroundNode&&(t=n.backgroundNode)}return t}getFogNode(e){return this.updateFog(e),e.fogNode||this.get(e).fogNode||null}getCacheKey(e,t){dX[0]=e,dX[1]=t;let n=this.renderer.info.calls,r=this.callHashCache.get(dX)||{};if(r.callId!==n){if(fX.push(this.renderer.getOutputRenderTarget()&&this.renderer.getOutputRenderTarget().multiview?1:0),fX.push(this.renderer.lighting.enabled?1:0),this.renderer.lighting.enabled){fX.push(t.getCacheKey(!0)),fX.push(this.renderer.shadowMap.enabled?1:0),fX.push(this.renderer.shadowMap.type);let n=this.getEnvironmentNode(e);n&&fX.push(n.getCacheKey())}let i=this.getFogNode(e);i&&fX.push(i.getCacheKey()),r.callId=n,r.cacheKey=ED(fX),this.callHashCache.set(dX,r),fX.length=0}return dX[0]=null,dX[1]=null,r.cacheKey}get isToneMappingState(){return!this.renderer.getRenderTarget()}updateBackground(e){let t=this.get(e),n=e.background;if(n){let r=e.backgroundBlurriness===0&&t.backgroundBlurriness>0||e.backgroundBlurriness>0&&t.backgroundBlurriness===0;(t.background!==n||r)&&(t.backgroundNode=this.getCacheNode(`background`,n,()=>{if(n.isCubeTexture===!0||n.mapping===303||n.mapping===304||n.mapping===306){if(e.backgroundBlurriness>0||n.mapping===306)return sV(n);{let e;return e=n.isCubeTexture===!0?jF(n):FN(n),YR(e)}}else if(n.isTexture===!0)return FN(n,ZN.flipY()).setUpdateMatrix(!0);else n.isColor!==!0&&I(`WebGPUNodes: Unsupported background configuration.`,n)},r),t.background=n,t.backgroundBlurriness=e.backgroundBlurriness)}else t.backgroundNode&&(delete t.backgroundNode,delete t.background)}getCacheNode(e,t,n,r=!1){let i=this.cacheLib[e]||(this.cacheLib[e]=new WeakMap),a=i.get(t);return(a===void 0||r)&&(a=n(),i.set(t,a)),a}updateFog(e){let t=this.get(e),n=e.fog;n?t.fog!==n&&(t.fogNode=this.getCacheNode(`fog`,n,()=>{if(n.isFogExp2)return yG(FF(`color`,`color`,n).setGroup(oA),_G(FF(`density`,`float`,n).setGroup(oA)));if(n.isFog)return yG(FF(`color`,`color`,n).setGroup(oA),gG(FF(`near`,`float`,n).setGroup(oA),FF(`far`,`float`,n).setGroup(oA)));I(`Renderer: Unsupported fog configuration.`,n)}),t.fog=n):(delete t.fogNode,delete t.fog)}updateEnvironment(e){let t=this.get(e),n=e.environment;n?t.environment!==n&&(t.environmentNode=this.getCacheNode(`environment`,n,()=>{if(n.isCubeTexture===!0)return jF(n);if(n.isTexture===!0)return FN(n);I(`Nodes: Unsupported environment configuration.`,n)}),t.environment=n):t.environmentNode&&(delete t.environmentNode,delete t.environment)}getNodeFrame(e=this.renderer,t=null,n=null,r=null,i=null){let a=this.nodeFrame;return a.renderer=e,a.scene=t,a.object=n,a.camera=r,a.material=i,a}getNodeFrameForRender(e){return this.getNodeFrame(e.renderer,e.scene,e.object,e.camera,e.material)}getOutputCacheKey(){let e=this.renderer;return e.toneMapping+`,`+e.currentColorSpace+`,`+e.xr.isPresenting}getOutputNode(e){let t=this.renderer,n;return n=e.isArrayTexture?this.backend.isWebGLBackend?FN(e,ZN).depth(KN(`gl_ViewID_OVR`)).renderOutput(t.toneMapping,t.currentColorSpace):FN(e,ZN).depth(pX).renderOutput(t.toneMapping,t.currentColorSpace):FN(e,ZN).renderOutput(t.toneMapping,t.currentColorSpace),n}setOutputLayerIndex(e){pX.value=e}updateBefore(e){let t=e.getNodeBuilderState();for(let n of t.updateBeforeNodes)this.getNodeFrameForRender(e).updateBeforeNode(n)}updateAfter(e){let t=e.getNodeBuilderState();for(let n of t.updateAfterNodes)this.getNodeFrameForRender(e).updateAfterNode(n)}updateForCompute(e){let t=this.getNodeFrame(),n=this.getForCompute(e);for(let e of n.updateNodes)t.updateNode(e)}updateForRender(e){let t=this.getNodeFrameForRender(e),n=e.getNodeBuilderState();for(let e of n.updateNodes)t.updateNode(e)}needsRefresh(e){let t=this.getNodeFrameForRender(e);return e.getMonitor().needsRefresh(e,t)}dispose(){super.dispose(),this.nodeFrame=new UY,this.nodeBuilderCache=new Map,this.cacheLib={}}},hX=new ca,gX=class e{constructor(e=null){this.version=0,this.clipIntersection=null,this.cacheKey=``,this.shadowPass=!1,this.viewMatrix=new qn,this.viewNormalMatrix=new En,this.clippingGroupContexts=new WeakMap,this.intersectionPlanes=[],this.unionPlanes=[],this.parentVersion=null,e!==null&&(this.viewMatrix=e.viewMatrix,this.viewNormalMatrix=e.viewNormalMatrix,this.clippingGroupContexts=e.clippingGroupContexts,this.shadowPass=e.shadowPass)}projectPlanes(e,t,n){let r=e.length;for(let i=0;i0&&(Wt(`THREE.XRManager: WebGPU XR does not support MSAA yet. Disabling MSAA for this XR session.`),this._currentSamples===null&&(this._currentSamples=e.samples),e._samples=0)}}async _initWebGPUSession(e){let t=this.getWebGPUBinding(),n=t.createProjectionLayer({colorFormat:t.getPreferredColorFormat(),depthStencilFormat:`depth24plus`});this._glProjLayer=n,e.updateRenderState({layers:[n]}),this._referenceSpace=await e.requestReferenceSpace(this.getReferenceSpaceType()),this._xrRenderTarget=new Un(n.textureWidth,n.textureHeight,{depth:2,minFilter:ne,magFilter:ne,depthBuffer:!0,multiview:!1,useArrayDepthTexture:!0,samples:0}),this._xrRenderTarget.texture.isArrayTexture=!0,this._useMultiviewIfPossible===!0&&Wt(`THREE.XRManager: WebGPU XR does not support multiview yet. Disabling multiview for this XR session.`),this._useMultiview=!1}_disposeWebGPUSession(){let e=this._renderer,t=this._xrRenderTarget;if(t===null||e.backend.isWebGPUBackend!==!0)return;let n=e.backend,r=e._textures,i=n.get?n.get(t):null;i&&(i.descriptors=void 0);let a=e=>{e!=null&&(n.delete&&n.delete(e),r.delete&&r.delete(e))};for(let e=0;eyN(e,n.toneMapping,n.outputColorSpace)}),DX.set(i,a))}else a=i;n.contextNode=a,n.setRenderTarget(r.renderTarget),r.rendercall(),n.contextNode=i}n.setRenderTarget(a),n._setXRLayerSize(i.x,i.y),this.isPresenting=r}getSession(){return this._session}async setSession(e){let t=this._renderer;t.initialized===!1&&await t.init(),this._gl=t.getContext();let n=this._gl;if(this._session=e,e!==null){if(e.addEventListener(`select`,this._onSessionEvent),e.addEventListener(`selectstart`,this._onSessionEvent),e.addEventListener(`selectend`,this._onSessionEvent),e.addEventListener(`squeeze`,this._onSessionEvent),e.addEventListener(`squeezestart`,this._onSessionEvent),e.addEventListener(`squeezeend`,this._onSessionEvent),e.addEventListener(`end`,this._onSessionEnd),e.addEventListener(`inputsourceschange`,this._onInputSourcesChange),this._validateWebGPUSession(),this._currentPixelRatio=t.getPixelRatio(),t.getSize(this._currentSize),this._currentAnimationContext=t._animation.getContext(),this._currentAnimationLoop=t._animation.getAnimationLoop(),t._animation.stop(),this._isWebGPUSession())await this._initWebGPUSession(e);else if(this._supportsLayers===!0){let r=null,i=null,a=null,o=n.getContextAttributes();await t.backend.makeXRCompatible(),this.setFoveation(this.getFoveation()),t.depth&&(a=t.stencil?n.DEPTH24_STENCIL8:n.DEPTH_COMPONENT24,r=t.stencil?Ce:Se,i=t.stencil?ge:de);let s={colorFormat:n.RGBA8,depthFormat:a,scaleFactor:this._framebufferScaleFactor,clearOnAccess:!1};this._useMultiviewIfPossible&&t.hasFeature(`OVR_multiview2`)&&(s.textureType=`texture-array`,this._useMultiview=!0),this._glBinding=this.getBinding();let c=this._glBinding.createProjectionLayer(s),l=[c];this._glProjLayer=c,t.setPixelRatio(1),t._setXRLayerSize(c.textureWidth,c.textureHeight);let u=this._useMultiview?2:1,d=new La(c.textureWidth,c.textureHeight,i,void 0,void 0,void 0,void 0,void 0,void 0,r,u);if(this._xrRenderTarget=new wX(c.textureWidth,c.textureHeight,{format:xe,type:oe,colorSpace:t.outputColorSpace,depthTexture:d,stencilBuffer:t.stencil,samples:o.antialias?4:0,resolveDepthBuffer:c.ignoreDepthValues===!1,resolveStencilBuffer:c.ignoreDepthValues===!1,depth:this._useMultiview?2:1,multiview:this._useMultiview}),this._xrRenderTarget._hasExternalTextures=!0,this._xrRenderTarget.depth=this._useMultiview?2:1,this._sessionUsesLayers=e.enabledFeatures.includes(`layers`),this._referenceSpace=await e.requestReferenceSpace(this.getReferenceSpaceType()),this._sessionUsesLayers)for(let e of this._layers)e.plane.material=new Hi({color:16777215,side:e.type===`cylinder`?1:0}),e.plane.material.blending=5,e.plane.material.blendEquation=100,e.plane.material.blendSrc=200,e.plane.material.blendDst=200,e.xrlayer=this._createXRLayer(e),l.unshift(e.xrlayer);e.updateRenderState({layers:l})}else{await t.backend.makeXRCompatible(),this.setFoveation(this.getFoveation());let r={antialias:t.currentSamples>0,alpha:!0,depth:t.depth,stencil:t.stencil,framebufferScaleFactor:this.getFramebufferScaleFactor()},i=new XRWebGLLayer(e,n,r);this._glBaseLayer=i,e.updateRenderState({baseLayer:i}),t.setPixelRatio(1),t._setXRLayerSize(i.framebufferWidth,i.framebufferHeight),this._xrRenderTarget=new wX(i.framebufferWidth,i.framebufferHeight,{format:xe,type:oe,colorSpace:t.outputColorSpace,stencilBuffer:t.stencil,resolveDepthBuffer:i.ignoreDepthValues===!1,resolveStencilBuffer:i.ignoreDepthValues===!1}),this._xrRenderTarget._isOpaqueFramebuffer=!0,this._referenceSpace=await e.requestReferenceSpace(this.getReferenceSpaceType())}t._animation.setAnimationLoop(this._onAnimationFrame),t._animation.setContext(e),t._animation.start(),this.isPresenting=!0,this.dispatchEvent({type:`sessionstart`})}}updateCamera(e){let t=this._session;if(t===null)return;let n=e.near,r=e.far,i=this._cameraXR,a=this._cameraL,o=this._cameraR;i.near=o.near=a.near=n,i.far=o.far=a.far=r,i.isMultiViewCamera=this._useMultiview,(this._currentDepthNear!==i.near||this._currentDepthFar!==i.far)&&(t.updateRenderState({depthNear:i.near,depthFar:i.far}),this._currentDepthNear=i.near,this._currentDepthFar=i.far),i.layers.mask=e.layers.mask|6,a.layers.mask=i.layers.mask&-5,o.layers.mask=i.layers.mask&-3;let s=e.parent,c=i.cameras;AX(i,s);for(let e=0;e=0&&(n[a]=null,t[a].disconnect(i))}for(let r=0;r=n.length){n.push(i),a=e;break}else if(n[e]===null){n[e]=i,a=e;break}if(a===-1)break}let o=t[a];o&&o.connect(i)}}function FX(e){return e.type===`quad`?this._glBinding.createQuadLayer({transform:new XRRigidTransform(e.translation,e.quaternion),width:e.width/2,height:e.height/2,space:this._referenceSpace,viewPixelWidth:e.pixelwidth,viewPixelHeight:e.pixelheight,clearOnAccess:!1}):this._glBinding.createCylinderLayer({transform:new XRRigidTransform(e.translation,e.quaternion),radius:e.radius,centralAngle:e.centralAngle,aspectRatio:e.aspectRatio,space:this._referenceSpace,viewPixelWidth:e.pixelwidth,viewPixelHeight:e.pixelheight,clearOnAccess:!1})}function IX(e,t){if(t===void 0)return;let n=this._cameraXR,r=this._renderer,i=r.backend,a=this._glBaseLayer,o=this.getReferenceSpace(),s=t.getViewerPose(o);if(this._xrFrame=t,s!==null){let e=s.views,t=this._isWebGPUSession()?this._getWebGPUViewData(e):null;this._glBaseLayer!==null&&t===null&&i.setXRTarget(a.framebuffer);let o=!1;e.length!==n.cameras.length&&(n.cameras.length=0,o=!0);for(let r=0;r{await this.compileAsync(n,t,e);let r=this.needsFrameBufferTarget&&this._renderTarget===null?this._getFrameBufferTarget():this._renderTarget||this._outputRenderTarget,i=this._renderLists.get(e,t),a=this._renderContexts.get(r,this._mrt),o=e.overrideMaterial||n.material,{fragmentShader:s,vertexShader:c}=this._objects.get(n,o,e,t,i.lightsNode,a,a.clippingContext).getNodeBuilderState();return{fragmentShader:s,vertexShader:c}}}}async init(){return this._initPromise===null&&(this._initPromise=new Promise(async(e,t)=>{let n=this.backend;try{await n.init(this)}catch(e){if(this._getFallback!==null)try{this.backend=n=this._getFallback(e),await n.init(this)}catch(e){t(e);return}else{t(e);return}}this._nodes=new mX(this,n),this._animation=new NV(this,this._nodes,this.info),this._attributes=new KV(n,this.info),this._background=new oY(this,this._nodes),this._geometries=new XV(this._attributes,this.info),this._textures=new _H(this,n,this.info),this._pipelines=new rH(n,this._nodes,this.info),this._bindings=new iH(n,this._nodes,this._textures,this._attributes,this._pipelines,this.info),this._objects=new BV(this,this._nodes,this._geometries,this._pipelines,this._bindings,this.info),this._renderLists=new dH(this.lighting),this._bundles=new yX,this._renderContexts=new hH(this),this._animation.start(),this._initialized=!0,this._inspector.init(),e(this)})),this._initPromise}get domElement(){return this._canvasTarget.domElement}get coordinateSystem(){return this.backend.coordinateSystem}async compileAsync(e,t,n=null){if(this._isDeviceLost===!0)return;this._initialized===!1&&await this.init();let r=this._nodes.nodeFrame,i=r.renderId,a=this._currentRenderContext,o=this._currentRenderObjectFunction,s=this._handleObjectFunction,c=this._compilationPromises;n===null&&(n=e);let l=e.isScene===!0?e:n.isScene===!0?n:RX,u=this.needsFrameBufferTarget&&this._renderTarget===null?this._getFrameBufferTarget():this._renderTarget||this._outputRenderTarget,d=this._renderContexts.get(u,this._mrt),f=this._activeMipmapLevel,p=[];this._currentRenderContext=d,this._currentRenderObjectFunction=this.renderObject,this._handleObjectFunction=this._createObjectPipeline,this._compilationPromises=p,r.renderId++,r.update(),d.depth=this.depth,d.stencil=this.stencil,d.clippingContext||=new gX,d.clippingContext.updateGlobal(l,t),e.matrixWorldAutoUpdate===!0&&e.updateMatrixWorld(),t=this._updateCamera(t),l.onBeforeRender(this,e,t,u);let m=t.isArrayCamera?HX:VX;t.isArrayCamera?m.setFromArrayCamera(t):(UX.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),m.setFromProjectionMatrix(UX,t.coordinateSystem,t.reversedDepth));let h=this._renderLists.get(l,t);if(h.begin(),this._projectObject(e,t,0,h,d.clippingContext),n!==e&&n.traverseVisible(function(e){e.isLight&&e.layers.test(t.layers)&&h.pushLight(e)}),h.finish(),u!==null){this._textures.updateRenderTarget(u,f);let e=this._textures.get(u);d.textures=e.textures,d.depthTexture=e.depthTexture}else d.textures=null,d.depthTexture=null;n===e?this._background.update(l,h,d):this._background.update(n,h,d);let g=h.opaque,_=h.transparent,v=h.transparentDoublePass,y=h.lightsNode;this.opaque===!0&&g.length>0&&this._renderObjects(g,t,l,y),this.transparent===!0&&_.length>0&&this._renderTransparents(_,v,t,l,y),r.renderId=i,this._currentRenderContext=a,this._currentRenderObjectFunction=o,this._handleObjectFunction=s,this._compilationPromises=c;for(let e of p){let t=this._objects.get(e.object,e.material,e.scene,e.camera,e.lightsNode,e.renderContext,e.clippingContext,e.passId);t.drawRange=e.object.geometry.drawRange,t.group=e.group,await this._nodes.getForRenderAsync(t),this._nodes.updateBefore(t),this._geometries.updateForRender(t),this._nodes.updateForRender(t),this._bindings.updateForRender(t);let n=[];this._pipelines.getForRender(t,n),n.length>0&&await Promise.all(n),this._nodes.updateAfter(t),await Gt()}}async renderAsync(e,t){Wt(`Renderer: "renderAsync()" has been deprecated. Use "render()" and "await renderer.init();" when creating the renderer.`),await this.init(),this.render(e,t)}async waitForGPU(){I(`Renderer: waitForGPU() has been removed. Read https://github.com/mrdoob/three.js/issues/32012 for more information.`)}set inspector(e){this._inspector!==null&&this._inspector.setRenderer(null),this._inspector=e,this._inspector.setRenderer(this)}get inspector(){return this._inspector}set highPrecision(e){let t=this.contextNode.value;e===!0?(t.modelViewMatrix=JP,t.modelNormalViewMatrix=YP):this.highPrecision&&(delete t.modelViewMatrix,delete t.modelNormalViewMatrix)}get highPrecision(){let e=this.contextNode.value;return e.modelViewMatrix===JP&&e.modelNormalViewMatrix===YP}setMRT(e){return this._mrt=e,this}getMRT(){return this._mrt}getOutputBufferType(){return this._outputBufferType}getColorBufferType(){return Wt(`Renderer: ".getColorBufferType()" has been renamed to ".getOutputBufferType()".`),this.getOutputBufferType()}_onDeviceLost(e){let t=`THREE.WebGPURenderer: ${e.api} Device Lost:\n\nMessage: ${e.message}`;e.reason&&(t+=`\nReason: ${e.reason}`),I(t),this._isDeviceLost=!0}_onError(e){let t=`WebGPURenderer: Uncaptured ${e.api} ${e.type}`;e.message&&(t+=`: ${e.message}`),I(t)}_bundleNeedsUpdate(e,t){return t.bundleGPU===void 0||e.version!==t.version}_renderBundle(e,t,n){let{bundleGroup:r,camera:i,renderList:a}=e,o=this._currentRenderContext,s=this._bundles.get(r,i,o),c=this.backend.get(s);if(this._bundleNeedsUpdate(r,c)){this.backend.beginBundle(o),this._currentRenderBundle=s;let{transparentDoublePass:e,transparent:l,opaque:u}=a;this.opaque===!0&&u.length>0&&this._renderObjects(u,i,t,n),this.transparent===!0&&l.length>0&&this._renderTransparents(l,e,i,t,n),this._currentRenderBundle=null,this.backend.finishBundle(o,s),c.version=r.version}else{let{renderObjects:e}=c;for(let t=0,n=e.length;t{c.removeEventListener(`dispose`,e),l.dispose(),this._frameBufferTargets.delete(c)};c.addEventListener(`dispose`,e),this._frameBufferTargets.set(c,l)}let u=this.getOutputRenderTarget();l.depthBuffer=o,l.stencilBuffer=s,u===null?l.setSize(i,a,1):l.setSize(u.width,u.height,u.depth);let d=this._outputRenderTarget?this._outputRenderTarget.viewport:c._viewport,f=this._outputRenderTarget?this._outputRenderTarget.scissor:c._scissor,p=this._outputRenderTarget?1:c._pixelRatio,m=this._outputRenderTarget?this._outputRenderTarget.scissorTest:c._scissorTest;return l.viewport.copy(d),l.scissor.copy(f),l.viewport.multiplyScalar(p),l.scissor.multiplyScalar(p),l.scissorTest=m,l.multiview=u===null?!1:u.multiview,l.useArrayDepthTexture=u===null?!1:u.useArrayDepthTexture,l.resolveDepthBuffer=u===null?!0:u.resolveDepthBuffer,l._autoAllocateDepthBuffer=u===null?!1:u._autoAllocateDepthBuffer,l}_renderScene(e,t,n=!0){if(this._isDeviceLost===!0)return;let r=n?this._getFrameBufferTarget():null,i=this._nodes.nodeFrame,a=i.renderId,o=this._currentRenderContext,s=this._currentRenderObjectFunction,c=this._handleObjectFunction;this.lighting.beginRender(e),this._callDepth++;let l=e.isScene===!0?e:RX,u=this._renderTarget||this._outputRenderTarget,d=this._activeCubeFace,f=this._activeMipmapLevel,p;if(r===null?p=u:(p=r,this.setRenderTarget(p)),p!==null&&p.depthBuffer===!0){let e=this._textures.get(p);e.depthInitialized!==!0&&((this.autoClear===!1||this.autoClear===!0&&this.autoClearDepth===!1)&&this.clearDepth(),e.depthInitialized=!0)}let m=this._renderContexts.get(p,this._mrt,this._callDepth);this._currentRenderContext=m,this._currentRenderObjectFunction=this._renderObjectFunction||this.renderObject,this._handleObjectFunction=this._renderObjectDirect,this.info.calls++,this.info.render.calls++,this.info.render.frameCalls++,i.renderId=this.info.calls,this.backend.updateTimeStampUID(m),this.inspector.beginRender(this.backend.getTimestampUID(m),e,t,p),e.matrixWorldAutoUpdate===!0&&e.updateMatrixWorld(),t=this._updateCamera(t);let h=this._canvasTarget,g=h._viewport,_=h._scissor,v=h._pixelRatio;p!==null&&(g=p.viewport,_=p.scissor,v=1),this.getDrawingBufferSize(zX),BX.set(0,0,zX.width,zX.height);let y=g.minDepth===void 0?0:g.minDepth,b=g.maxDepth===void 0?1:g.maxDepth;m.viewportValue.copy(g).multiplyScalar(v).floor(),m.viewportValue.width>>=f,m.viewportValue.height>>=f,m.viewportValue.minDepth=y,m.viewportValue.maxDepth=b,m.viewport=m.viewportValue.equals(BX)===!1,m.scissorValue.copy(_).multiplyScalar(v).floor(),m.scissor=h._scissorTest&&m.scissorValue.equals(BX)===!1,m.scissorValue.width>>=f,m.scissorValue.height>>=f,m.clippingContext||=new gX,m.clippingContext.updateGlobal(l,t),l.onBeforeRender(this,e,t,p);let x=t.isArrayCamera?HX:VX;t.isArrayCamera?x.setFromArrayCamera(t):(UX.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),x.setFromProjectionMatrix(UX,t.coordinateSystem,t.reversedDepth));let S=this._renderLists.get(e,t);if(S.begin(),this._projectObject(e,t,0,S,m.clippingContext),S.finish(),this.sortObjects===!0&&S.sort(this._opaqueSort,this._transparentSort,t.reversedDepth),p!==null){this._textures.updateRenderTarget(p,f);let e=this._textures.get(p);m.textures=e.textures,m.depthTexture=e.depthTexture,m.width=e.width,m.height=e.height,m.renderTarget=p,m.depth=p.depthBuffer,m.stencil=p.stencilBuffer}else m.textures=null,m.depthTexture=null,m.width=zX.width,m.height=zX.height,m.depth=this.depth,m.stencil=this.stencil;m.width>>=f,m.height>>=f,m.activeCubeFace=d,m.activeMipmapLevel=f,m.occlusionQueryCount=S.occlusionQueryCount,m.scissorValue.max(WX.set(0,0,0,0)),m.scissorValue.x+m.scissorValue.width>m.width&&(m.scissorValue.width=Math.max(m.width-m.scissorValue.x,0)),m.scissorValue.y+m.scissorValue.height>m.height&&(m.scissorValue.height=Math.max(m.height-m.scissorValue.y,0)),this._background.update(l,S,m),m.camera=t,this.backend.beginRender(m);let{bundles:C,lightsNode:w,transparentDoublePass:T,transparent:E,opaque:D}=S;return C.length>0&&this._renderBundles(C,l,w),this.opaque===!0&&D.length>0&&this._renderObjects(D,t,l,w),this.transparent===!0&&E.length>0&&this._renderTransparents(E,T,t,l,w),this.backend.finishRender(m),i.renderId=a,this._currentRenderContext=o,this._currentRenderObjectFunction=s,this._handleObjectFunction=c,this.lighting.finishRender(e),this._callDepth--,r!==null&&(this.setRenderTarget(u,d,f),this._renderOutput(p)),l.onAfterRender(this,e,t,p),this.inspector.finishRender(this.backend.getTimestampUID(m)),m}_setXRLayerSize(e,t){this._canvasTarget._width=e,this._canvasTarget._height=t,this.setViewport(0,0,e,t)}_renderOutput(e){let t=this._nodes.getOutputCacheKey(),n=this._quadCache.get(e.texture),r;if(n===void 0){r=new GU(new OR),r.name=`Output Color Transform`,r.material.name=`outputColorTransform`,r.material.fragmentNode=this._nodes.getOutputNode(e.texture),n={quad:r,cacheKey:t},this._quadCache.set(e.texture,n);let i=()=>{r.material.dispose(),this._quadCache.delete(e.texture),e.texture.removeEventListener(`dispose`,i)};e.texture.addEventListener(`dispose`,i)}else r=n.quad,n.cacheKey!==t&&(r.material.fragmentNode=this._nodes.getOutputNode(e.texture),r.material.needsUpdate=!0,n.cacheKey=t);let i=this.autoClear,a=this.xr.enabled;this.autoClear=!1,this.xr.enabled=!1,this._renderOutputLayers(r,e),this.autoClear=i,this.xr.enabled=a}getMaxAnisotropy(){return this.backend.capabilities.getMaxAnisotropy()}getActiveCubeFace(){return this._activeCubeFace}getActiveMipmapLevel(){return this._activeMipmapLevel}async setAnimationLoop(e){this._initialized===!1&&await this.init(),this._animation.setAnimationLoop(e)}getAnimationLoop(){return this._animation.getAnimationLoop()}async getArrayBufferAsync(e,t=null,n=0,r=-1){if(t!==null&&t.isReadbackBuffer&&this.info.memoryMap.has(t)===!1){this.info.createReadbackBuffer(t);let e=()=>{t.removeEventListener(`dispose`,e),this.info.destroyReadbackBuffer(t)};t.addEventListener(`dispose`,e)}if(n%4!=0||r>0&&r%4!=0)throw Error(`THREE.Renderer: "getArrayBufferAsync()" offset and count must be a multiple of 4.`);return await this.backend.getArrayBufferAsync(e,t,n,r)}getContext(){return this.backend.getContext()}getPixelRatio(){return this._canvasTarget.getPixelRatio()}getDrawingBufferSize(e){return this._canvasTarget.getDrawingBufferSize(e)}getSize(e){return this._canvasTarget.getSize(e)}setPixelRatio(e=1){this._canvasTarget.setPixelRatio(e)}setDrawingBufferSize(e,t,n){this.xr&&this.xr.isPresenting||this._canvasTarget.setDrawingBufferSize(e,t,n)}setSize(e,t,n=!0){this.xr&&this.xr.isPresenting||this._canvasTarget.setSize(e,t,n)}setOpaqueSort(e){this._opaqueSort=e}setTransparentSort(e){this._transparentSort=e}getScissor(e){return this._canvasTarget.getScissor(e)}setScissor(e,t,n,r){this._canvasTarget.setScissor(e,t,n,r)}getScissorTest(){return this._canvasTarget.getScissorTest()}setScissorTest(e){this._canvasTarget.setScissorTest(e),this.backend.setScissorTest(e)}getViewport(e){return this._canvasTarget.getViewport(e)}setViewport(e,t,n,r,i=0,a=1){this._canvasTarget.setViewport(e,t,n,r,i,a)}getClearColor(e){return e.copy(this._clearColor)}setClearColor(e,t=1){this._clearColor.set(e),this._clearColor.a=t}getClearAlpha(){return this._clearColor.a}setClearAlpha(e){this._clearColor.a=e}getClearDepth(){return this.reversedDepthBuffer===!0?1-this._clearDepth:this._clearDepth}setClearDepth(e){this._clearDepth=e}getClearStencil(){return this._clearStencil}setClearStencil(e){this._clearStencil=e}isOccluded(e){let t=this._currentRenderContext;return t&&this.backend.isOccluded(t,e)}clear(e=!0,t=!0,n=!0){if(this._initialized===!1)throw Error(`THREE.Renderer: .clear() called before the backend is initialized. Use "await renderer.init();" before using this method.`);let r=this._renderTarget||this._getFrameBufferTarget(),i=null;if(r!==null){this._textures.updateRenderTarget(r);let e=this._textures.get(r);i=this._renderContexts.get(r,null,-1),i.textures=e.textures,i.depthTexture=e.depthTexture,i.width=e.width,i.height=e.height,i.renderTarget=r,i.depth=r.depthBuffer,i.stencil=r.stencilBuffer;let t=this.backend.getClearColor();i.clearColorValue.r=t.r,i.clearColorValue.g=t.g,i.clearColorValue.b=t.b,i.clearColorValue.a=t.a,i.clearDepthValue=this.getClearDepth(),i.clearStencilValue=this.getClearStencil(),i.activeCubeFace=this.getActiveCubeFace(),i.activeMipmapLevel=this.getActiveMipmapLevel(),r.depthBuffer===!0&&(e.depthInitialized=!0)}this.backend.clear(e,t,n,i),r!==null&&this._renderTarget===null&&this._renderOutput(r)}clearColor(){this.clear(!0,!1,!1)}clearDepth(){this.clear(!1,!0,!1)}clearStencil(){this.clear(!1,!1,!0)}async clearAsync(e=!0,t=!0,n=!0){Wt(`Renderer: "clearAsync()" has been deprecated. Use "clear()" and "await renderer.init();" when creating the renderer.`),await this.init(),this.clear(e,t,n)}async clearColorAsync(){Wt(`Renderer: "clearColorAsync()" has been deprecated. Use "clearColor()" and "await renderer.init();" when creating the renderer.`),this.clear(!0,!1,!1)}async clearDepthAsync(){Wt(`Renderer: "clearDepthAsync()" has been deprecated. Use "clearDepth()" and "await renderer.init();" when creating the renderer.`),this.clear(!1,!0,!1)}async clearStencilAsync(){Wt(`Renderer: "clearStencilAsync()" has been deprecated. Use "clearStencil()" and "await renderer.init();" when creating the renderer.`),this.clear(!1,!1,!0)}get needsFrameBufferTarget(){let e=this.currentToneMapping!==0,t=this.currentColorSpace!==jn.workingColorSpace;return e||t}get samples(){return this._samples}get currentSamples(){let e=this._samples;return this._renderTarget===null?this.needsFrameBufferTarget&&(e=0):e=this._renderTarget.samples,e}get currentToneMapping(){return this.isOutputTarget?this.toneMapping:0}get currentColorSpace(){return this.isOutputTarget?this.outputColorSpace:jn.workingColorSpace}get isOutputTarget(){return this._renderTarget===this._outputRenderTarget||this._renderTarget===null}dispose(){if(this._initialized===!0){this.info.dispose(),this.backend.dispose(),this._animation.dispose(),this._objects.dispose(),this._geometries.dispose(),this._pipelines.dispose(),this._nodes.dispose(),this._bindings.dispose(),this._renderLists.dispose(),this._renderContexts.dispose(),this._textures.dispose();for(let e of this._frameBufferTargets.keys())e.dispose();Object.values(this.backend.timestampQueryPool).forEach(e=>{e!==null&&e.dispose()})}this.setRenderTarget(null),this.setAnimationLoop(null)}setRenderTarget(e,t=0,n=0){this._renderTarget=e,this._activeCubeFace=t,this._activeMipmapLevel=n}getRenderTarget(){return this._renderTarget}setOutputRenderTarget(e){this._outputRenderTarget=e}getOutputRenderTarget(){return this._outputRenderTarget}setCanvasTarget(e){this._canvasTarget.removeEventListener(`resize`,this._onCanvasTargetResize),this._canvasTarget=e,this._canvasTarget.addEventListener(`resize`,this._onCanvasTargetResize)}getCanvasTarget(){return this._canvasTarget}_resetXRState(){this.backend.setXRTarget(null),this.setOutputRenderTarget(null),this.setRenderTarget(null);for(let e of this._frameBufferTargets.keys())e.dispose()}setRenderObjectFunction(e){this._renderObjectFunction=e}getRenderObjectFunction(){return this._renderObjectFunction}compute(e,t=null){if(this._isDeviceLost===!0)return;if(this._initialized===!1)return F(`Renderer: .compute() called before the backend is initialized. Try using .computeAsync() instead.`),this.computeAsync(e,t);let n=this._nodes.nodeFrame,r=n.renderId;this.info.calls++,this.info.compute.calls++,this.info.compute.frameCalls++,n.renderId=this.info.calls,this.backend.updateTimeStampUID(e),this.inspector.beginCompute(this.backend.getTimestampUID(e),e);let i=this.backend,a=this._pipelines,o=this._bindings,s=this._nodes,c=Array.isArray(e)?e:[e];if(c[0]===void 0||c[0].isComputeNode!==!0)throw Error(`THREE.Renderer: .compute() expects a ComputeNode.`);i.beginCompute(e);for(let n of c){if(a.has(n)===!1){let e=()=>{n.removeEventListener(`dispose`,e),a.delete(n),o.deleteForCompute(n),s.delete(n)};n.addEventListener(`dispose`,e);let t=n.onInitFunction;t!==null&&t.call(n,{renderer:this})}s.updateForCompute(n),o.updateForCompute(n);let r=o.getForCompute(n),c=a.getForCompute(n,r);i.compute(e,n,r,c,t)}i.finishCompute(e),n.renderId=r,this.inspector.finishCompute(this.backend.getTimestampUID(e))}async computeAsync(e,t=null){this._initialized===!1&&await this.init(),this.compute(e,t)}async hasFeatureAsync(e){return Wt(`Renderer: "hasFeatureAsync()" has been deprecated. Use "hasFeature()" and "await renderer.init();" when creating the renderer.`),await this.init(),this.hasFeature(e)}async resolveTimestampsAsync(e=`render`){return this._initialized===!1&&await this.init(),this.backend.resolveTimestampsAsync(e)}hasFeature(e){if(this._initialized===!1)throw Error(`THREE.Renderer: .hasFeature() called before the backend is initialized. Use "await renderer.init();" before using this method.`);return this.backend.hasFeature(e)}hasInitialized(){return this._initialized}async initTextureAsync(e){Wt(`Renderer: "initTextureAsync()" has been deprecated. Use "initTexture()" and "await renderer.init();" when creating the renderer.`),await this.init(),this.initTexture(e)}initTexture(e){if(this._initialized===!1)throw Error(`THREE.Renderer: .initTexture() called before the backend is initialized. Use "await renderer.init();" before using this method.`);this._textures.updateTexture(e)}initRenderTarget(e){if(this._initialized===!1)throw Error(`THREE.Renderer: .initRenderTarget() called before the backend is initialized. Use "await renderer.init();" before using this method.`);this._textures.updateRenderTarget(e);let t=this._textures.get(e),n=this._renderContexts.get(e);n.textures=t.textures,n.depthTexture=t.depthTexture,n.width=t.width,n.height=t.height,n.renderTarget=e,n.depth=e.depthBuffer,n.stencil=e.stencilBuffer,this.backend.initRenderTarget(n)}copyFramebufferToTexture(e,t=null){if(t!==null)if(t.isVector2)t=WX.set(t.x,t.y,e.image.width,e.image.height).floor();else if(t.isVector4)t=WX.copy(t).floor();else{I(`Renderer.copyFramebufferToTexture: Invalid rectangle.`);return}else t=WX.set(0,0,e.image.width,e.image.height);let n=this._currentRenderContext,r;n===null?(r=this._renderTarget||this._getFrameBufferTarget(),r!==null&&(this._textures.updateRenderTarget(r),n=this._textures.get(r))):r=n.renderTarget,this._textures.updateTexture(e,{renderTarget:r}),this.backend.copyFramebufferToTexture(e,n,t),this._inspector.copyFramebufferToTexture(e)}copyTextureToTexture(e,t,n=null,r=null,i=0,a=0){this._textures.updateTexture(e),this._textures.updateTexture(t),this.backend.copyTextureToTexture(e,t,n,r,i,a),this._inspector.copyTextureToTexture(e,t)}async readRenderTargetPixelsAsync(e,t,n,r,i,a=0,o=0){return this.backend.copyTextureToBuffer(e.textures[a],t,n,r,i,o)}_projectObject(e,t,n,r,i){if(e.visible===!1)return;if(e.layers.test(t.layers)){if(e.isGroup)n=e.renderOrder,e.isClippingGroup&&e.enabled&&(i=i.getGroupContext(e));else if(e.isLOD)e.autoUpdate===!0&&e.update(t);else if(e.isLight)r.pushLight(e);else if(e.isSprite){let a=t.isArrayCamera?HX:VX;if(!e.frustumCulled||a.intersectsSprite(e)){this.sortObjects===!0&&WX.setFromMatrixPosition(e.matrixWorld).applyMatrix4(UX);let{geometry:t,material:a}=e;a.visible&&r.push(e,t,a,n,WX.z,null,i)}}else if(e.isLineLoop)I(`Renderer: Objects of type THREE.LineLoop are not supported. Please use THREE.Line or THREE.LineSegments.`);else if(e.isMesh||e.isLine||e.isPoints){let a=t.isArrayCamera?HX:VX;if(!e.frustumCulled||a.intersectsObject(e)){let{geometry:t,material:a}=e;if(this.sortObjects===!0&&(t.boundingSphere===null&&t.computeBoundingSphere(),WX.copy(t.boundingSphere.center).applyMatrix4(e.matrixWorld).applyMatrix4(UX)),Array.isArray(a)){let o=t.groups;for(let s=0,c=o.length;s0){for(let{material:e}of t)e.side=1;this._renderObjects(t,n,r,i,`backSide`);for(let{material:e}of t)e.side=0;this._renderObjects(e,n,r,i);for(let{material:e}of t)e.side=2}else this._renderObjects(e,n,r,i)}_renderObjects(e,t,n,r,i=null){for(let a=0,o=e.length;a(t.not().discard(),e))(c)}}e.depthNode&&e.depthNode.isNode&&(l=e.depthNode),e.castShadowPositionNode&&e.castShadowPositionNode.isNode?s=e.castShadowPositionNode:e.positionNode&&e.positionNode.isNode&&(s=e.positionNode),n={version:t,colorNode:c,depthNode:l,positionNode:s},this._cacheShadowNodes.set(e,n)}return n}_updateCamera(e){let t=this.xr;if(t.isPresenting===!1){let t=!1;if(this.reversedDepthBuffer===!0&&e.reversedDepth!==!0){if(e._reversedDepth=!0,e.isArrayCamera)for(let t of e.cameras)t._reversedDepth=!0;t=!0}let n=this.coordinateSystem;if(e.coordinateSystem!==n){if(e.coordinateSystem=n,e.isArrayCamera)for(let t of e.cameras)t.coordinateSystem=n;t=!0}if(t===!0&&(e.updateProjectionMatrix(),e.isArrayCamera))for(let t of e.cameras)t.updateProjectionMatrix()}return e.parent===null&&e.matrixWorldAutoUpdate===!0&&e.updateMatrixWorld(),t.enabled===!0&&t.isPresenting===!0&&(t.cameraAutoUpdate===!0&&t.updateCamera(e),e=t.getCamera()),e}renderObject(e,t,n,r,i,a,o,s=null,c=null){let l=!1,u,d,f,p,m,h,g,_=this._currentSourceMaterial;if(e.onBeforeRender(this,t,n,r,i,a),i.allowOverride===!0&&t.overrideMaterial!==null){this._currentSourceMaterial=i;let e=t.overrideMaterial;if(l=!0,u=e.isNodeMaterial?e.colorNode:null,d=e.isNodeMaterial?e.depthNode:null,f=e.isNodeMaterial?e.positionNode:null,p=t.overrideMaterial.side,m=e.displacementMap,h=e.displacementScale,g=e.displacementBias,i.positionNode&&i.positionNode.isNode&&(e.positionNode=i.positionNode),e.alphaTest=i.alphaTest,e.alphaMap=i.alphaMap,e.displacementMap=i.displacementMap,e.displacementScale=i.displacementScale,e.displacementBias=i.displacementBias,e.transparent=i.transparent||i.transmission>0||i.transmissionNode&&i.transmissionNode.isNode||i.backdropNode&&i.backdropNode.isNode,e.isShadowPassMaterial){let{colorNode:t,depthNode:n,positionNode:r}=this._getShadowNodes(i);this.shadowMap.type===3?e.side=i.shadowSide===null?i.side:i.shadowSide:e.side=i.shadowSide===null?GX[i.side]:i.shadowSide,t!==null&&(e.colorNode=t),n!==null&&(e.depthNode=n),r!==null&&(e.positionNode=r)}i=e}i.transparent===!0&&i.side===2&&i.forceSinglePass===!1?(i.side=1,this._handleObjectFunction(e,i,t,n,o,a,s,`backSide`),i.side=0,this._handleObjectFunction(e,i,t,n,o,a,s,c),i.side=2):this._handleObjectFunction(e,i,t,n,o,a,s,c),l&&(t.overrideMaterial.colorNode=u,t.overrideMaterial.depthNode=d,t.overrideMaterial.positionNode=f,t.overrideMaterial.side=p,t.overrideMaterial.displacementMap=m,t.overrideMaterial.displacementScale=h,t.overrideMaterial.displacementBias=g),this._currentSourceMaterial=_,e.onAfterRender(this,t,n,r,i,a)}hasCompatibility(e){if(this._initialized===!1)throw Error(`THREE.Renderer: .hasCompatibility() called before the backend is initialized. Use "await renderer.init();" before using this method.`);return this.backend.hasCompatibility(e)}_renderObjectDirect(e,t,n,r,i,a,o,s){let c=this._objects.get(e,t,n,r,i,this._currentRenderContext,o,s);c.drawRange=e.geometry.drawRange,c.group=a,this._currentRenderBundle!==null&&(this.backend.get(this._currentRenderBundle).renderObjects.push(c),c.bundle=this._currentRenderBundle.bundleGroup);let l=this._nodes.needsRefresh(c);l&&(this._nodes.updateBefore(c),this._geometries.updateForRender(c),this._nodes.updateForRender(c),this._bindings.updateForRender(c)),this._pipelines.updateForRender(c),this._pipelines.isReady(c)&&(this.backend.draw(c,this.info),l&&this._nodes.updateAfter(c))}_createObjectPipeline(e,t,n,r,i,a,o,s){if(this._compilationPromises!==null){this._compilationPromises.push({object:e,material:t,scene:n,camera:r,lightsNode:i,group:a,clippingContext:o,passId:s,renderContext:this._currentRenderContext});return}let c=this._objects.get(e,t,n,r,i,this._currentRenderContext,o,s);c.drawRange=e.geometry.drawRange,c.group=a,this._nodes.updateBefore(c),this._geometries.updateForRender(c),this._nodes.updateForRender(c),this._bindings.updateForRender(c),this._pipelines.getForRender(c,this._compilationPromises),this._nodes.updateAfter(c)}_onCanvasTargetResize(){this._initialized&&this.backend.updateSize()}get compile(){return this.compileAsync}},qX=class{constructor(e=``){this.name=e,this.visibility=0}setVisibility(e){this.visibility|=e}getVisibility(){return this.visibility}clone(){return Object.assign(new this.constructor,this)}};function JX(e){return e+(UV-e%UV)%UV}var YX=class extends qX{constructor(e,t=null){super(e),this.isBuffer=!0,this.bytesPerElement=Float32Array.BYTES_PER_ELEMENT,this._buffer=t,this._updateRanges=[]}get updateRanges(){return this._updateRanges}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}get byteLength(){return JX(this._buffer.byteLength)}get buffer(){return this._buffer}update(){return!0}release(){this._buffer=null}},XX=class extends YX{constructor(e,t=null){super(e,t),this.isUniformBuffer=!0}},ZX=0,QX=class extends XX{constructor(e,t){super(`UniformBuffer_`+ ZX++,e?e.value:null),this.nodeUniform=e,this.groupNode=t,this.isNodeUniformBuffer=!0}set updateRanges(e){this.nodeUniform.updateRanges=e}get updateRanges(){return this.nodeUniform.updateRanges}addUpdateRange(e,t){this.nodeUniform.addUpdateRange(e,t)}clearUpdateRanges(){this.nodeUniform.clearUpdateRanges()}get byteLength(){return JX(this.buffer.byteLength)}get buffer(){return this.nodeUniform.value}},$X=class extends XX{constructor(e){super(e),this.isUniformsGroup=!0,this._values=null,this.uniforms=[],this._updateRangeCache=new Map,this._addedIndices=new Set}addUniformUpdateRange(e){let t=e.index;if(this._addedIndices.has(t))return;let n=this._updateRangeCache.get(t);n===void 0&&(n={start:0,count:0},this._updateRangeCache.set(t,n)),n.start=e.offset,n.count=e.itemSize,this._addedIndices.add(t),this.updateRanges.push(n)}clearUpdateRanges(){this._addedIndices.clear(),super.clearUpdateRanges()}addUniform(e){return this.uniforms.push(e),this}removeUniform(e){let t=this.uniforms.indexOf(e);return t!==-1&&this.uniforms.splice(t,1),this}get values(){return this._values===null&&(this._values=Array.from(this.buffer)),this._values}get buffer(){let e=this._buffer;if(e===null){let t=this.byteLength;e=new Float32Array(new ArrayBuffer(t)),this._buffer=e}return e}get byteLength(){let e=this.bytesPerElement,t=0;for(let n=0,r=this.uniforms.length;n0?i:``;t=`${n.name} {\n\t${r} ${e.name}[${a}];\n};\n`}else{let t=e.groupNode.name;if(r[t]===void 0){let e=this.uniformGroups[t];if(e!==void 0){let n=[];for(let t of e.uniforms){let e=t.getType(),r=this.getVectorType(e),i=t.nodeUniform.node.precision,a=`${r} ${t.name};`;i!==null&&(a=fZ[i]+` `+a),n.push(` `+a)}r[t]=n}}i=!0}if(!i){let r=e.node.precision;r!==null&&(t=fZ[r]+` `+t),t=`uniform `+t,n.push(t)}}let i=``;for(let e in r){let t=r[e];i+=this._getGLSLUniformStruct(e,t.join(` `))+` `}return i+=n.join(` `),i}getTypeFromAttribute(e){let t=super.getTypeFromAttribute(e);if(/^[iu]/.test(t)&&e.gpuType!==1013){let n=e;e.isInterleavedBufferAttribute&&(n=e.data);let r=n.array;r instanceof Uint32Array||r instanceof Int32Array||(t=t.slice(1))}return t}getAttributes(e){let t=``;if(e===`vertex`||e===`compute`){let e=this.getAttributesArray(),n=0;for(let r of e)t+=`layout( location = ${n++} ) in ${r.type} ${r.name};\n`}return t}getStructMembers(e){let t=[];for(let n of e.members)t.push(`\t${n.type} ${n.name};`);return t.join(` `)}getStructs(e){let t=[],n=this.structs[e],r=[];for(let e of n)if(e.output)for(let t of e.members)r.push(`layout( location = ${t.index} ) out ${t.type} ${t.name};`);else{let n=`struct `+e.name+` { `;n+=this.getStructMembers(e),n+=` }; `,t.push(n)}return e===`fragment`&&r.length===0&&r.push(`layout( location = 0 ) out ${this.getOutputType()} fragColor;`),` `+r.join(` `)+` `+t.join(` `)}getVaryings(e){let t=``,n=this.varyings;if(e===`vertex`||e===`compute`)for(let r of n){e===`compute`&&(r.needsInterpolation=!0);let n=this.getType(r.type);if(r.needsInterpolation)if(r.interpolationType){let e=mZ[r.interpolationType]||r.interpolationType,i=hZ[r.interpolationSampling]||``;t+=`${e} ${i} out ${n} ${r.name};\n`}else{let e=n.includes(`int`)||n.includes(`uv`)||n.includes(`iv`)?`flat `:``;t+=`${e}out ${n} ${r.name};\n`}else t+=`${n} ${r.name};\n`}else if(e===`fragment`){for(let e of n)if(e.needsInterpolation){let n=this.getType(e.type);if(e.interpolationType){let r=mZ[e.interpolationType]||e.interpolationType,i=hZ[e.interpolationSampling]||``;t+=`${r} ${i} in ${n} ${e.name};\n`}else{let r=n.includes(`int`)||n.includes(`uv`)||n.includes(`iv`)?`flat `:``;t+=`${r}in ${n} ${e.name};\n`}}}for(let n of this.builtins[e])t+=`${n};\n`;return t}getVertexIndex(){return`uint( gl_VertexID )`}getInstanceIndex(){return`uint( gl_InstanceID )`}getInvocationLocalIndex(){return`uint( gl_InstanceID ) % ${this.object.workgroupSize.reduce((e,t)=>e*t,1)}u`}getSubgroupSize(){I(`GLSLNodeBuilder: WebGLBackend does not support the subgroupSize node`)}getInvocationSubgroupIndex(){I(`GLSLNodeBuilder: WebGLBackend does not support the invocationSubgroupIndex node`)}getSubgroupIndex(){I(`GLSLNodeBuilder: WebGLBackend does not support the subgroupIndex node`)}getDrawIndex(){return this.renderer.backend.extensions.has(`WEBGL_multi_draw`)?`uint( gl_DrawID )`:`nodeUniformDrawId`}getFrontFacing(){return`gl_FrontFacing`}getFragCoord(){return`gl_FragCoord.xy`}getFragDepth(){return`gl_FragDepth`}enableExtension(e,t,n=this.shaderStage){let r=this.extensions[n]||(this.extensions[n]=new Map);r.has(e)===!1&&r.set(e,{name:e,behavior:t})}getExtensions(e){let t=[];if(e===`vertex`){let t=this.renderer.backend.extensions;this.object.isBatchedMesh&&t.has(`WEBGL_multi_draw`)&&this.enableExtension(`GL_ANGLE_multi_draw`,`require`,e)}let n=this.extensions[e];if(n!==void 0)for(let{name:e,behavior:r}of n.values())t.push(`#extension ${e} : ${r}`);return t.join(` `)}getClipDistance(){return`gl_ClipDistance`}isAvailable(e){let t=pZ[e];if(t===void 0){let n;switch(t=!1,e){case`float32Filterable`:n=`OES_texture_float_linear`;break;case`clipDistance`:n=`WEBGL_clip_cull_distance`;break}if(n!==void 0){let e=this.renderer.backend.extensions;e.has(n)&&(e.get(n),t=!0)}pZ[e]=t}return t}isFlipY(){return!0}enableHardwareClipping(e){this.enableExtension(`GL_ANGLE_clip_cull_distance`,`require`),this.builtins.vertex.push(`out float gl_ClipDistance[ ${e} ]`)}enableMultiview(){this.enableExtension(`GL_OVR_multiview2`,`require`,`fragment`),this.enableExtension(`GL_OVR_multiview2`,`require`,`vertex`),this.builtins.vertex.push(`layout(num_views = 2) in`)}registerTransform(e,t){this.transforms.push({varyingName:e,attributeNode:t})}getTransforms(){let e=this.transforms,t=``;for(let n=0;n0&&(n+=` `),n+=`\t// flow -> ${a}\n\t`),n+=`${r.code}\n\t`,e===i&&t!==`compute`&&(n+=`// result `,t===`vertex`?(n+=`gl_Position = `,n+=`${this.format(r.result,i.getNodeType(this),`vec4`)};`):t===`fragment`&&(e.outputNode.isOutputStructNode||(n+=`fragColor = `,n+=`${this.format(r.result,i.getNodeType(this),this.getOutputType())};`)))}let a=e[t];if(a.extensions=this.getExtensions(t),a.uniforms=this.getUniforms(t),a.attributes=this.getAttributes(t),a.varyings=this.getVaryings(t),a.vars=this.getVars(t,!0),a.structs=this.getStructs(t),a.codes=this.getCodes(t),a.transforms=this.getTransforms(t),a.flow=n,t===`vertex`){let e=this.renderer.backend.extensions;this.object.isBatchedMesh&&e.has(`WEBGL_multi_draw`)===!1&&(a.uniforms+=` uniform uint nodeUniformDrawId; `)}}this.material===null?this.computeShader=this._getGLSLVertexCode(e.compute):(this.vertexShader=this._getGLSLVertexCode(e.vertex),this.fragmentShader=this._getGLSLFragmentCode(e.fragment))}getUniformFromNode(e,t,n,r=null){let i=super.getUniformFromNode(e,t,n,r),a=this.getDataFromNode(e,n,this.globalCache),o=a.uniformGPU;if(o===void 0){let r=e.groupNode,s=r.name,c=this.getBindGroupArray(s,n);if(t===`texture`)o=new sZ(i.name,i.node,r),c.push(o);else if(t===`cubeTexture`||t===`cubeDepthTexture`)o=new cZ(i.name,i.node,r),c.push(o);else if(t===`texture3D`)o=new lZ(i.name,i.node,r),c.push(o);else if(t===`buffer`){i.name=`buffer${e.id}`;let t=this.getSharedDataFromNode(e),n=t.buffer;n===void 0&&(e.name=`NodeBuffer_${e.id}`,n=new QX(e,r),n.name=e.name,t.buffer=n),c.push(n),o=n}else{let e=this.uniformGroups[s];e===void 0?(e=new rZ(s,r),this.uniformGroups[s]=e,c.push(e)):c.indexOf(e)===-1&&c.push(e),o=this.getNodeUniform(i,t);let n=o.name;e.uniforms.some(e=>e.name===n)||e.addUniform(o)}a.uniformGPU=o}return i}},vZ=null,yZ=null,bZ=class{constructor(e={}){this.parameters=Object.assign({},e),this.data=new WeakMap,this.renderer=null,this.domElement=null,this.timestampQueryPool={[Pt.RENDER]:null,[Pt.COMPUTE]:null},this.trackTimestamp=e.trackTimestamp===!0}async init(e){this.renderer=e}get coordinateSystem(){}beginRender(){}finishRender(){}setXRTarget(){}beginCompute(){}finishCompute(){}draw(){}compute(){}createProgram(){}destroyProgram(){}createBindings(){}updateBindings(){}updateBinding(){}createRenderPipeline(){}createComputePipeline(){}needsRenderUpdate(){}getRenderCacheKey(){}createNodeBuilder(){}updateSampler(){}destroySampler(){}createDefaultTexture(){}createTexture(){}updateTexture(){}generateMipmaps(){}destroyTexture(){}async copyTextureToBuffer(){}copyTextureToTexture(){}copyFramebufferToTexture(){}createAttribute(){}createIndexAttribute(){}createStorageAttribute(){}createUniformBuffer(){}destroyUniformBuffer(){}updateAttribute(){}destroyAttribute(){}getContext(){}updateSize(){}updateViewport(){}updateTimeStampUID(e){let t=this.get(e),n=this.renderer.info.frame,r;r=e.isComputeNode===!0?`c:`+this.renderer.info.compute.frameCalls:`r:`+this.renderer.info.render.frameCalls,t.timestampUID=r+`:`+e.id+`:f`+n}getTimestampUID(e){return this.get(e).timestampUID}getTimestampFrames(e){let t=this.timestampQueryPool[e];return t?t.getTimestampFrames():[]}_getQueryPool(e){let t=e.startsWith(`c:`)?Pt.COMPUTE:Pt.RENDER;return this.timestampQueryPool[t]}getTimestamp(e){return this._getQueryPool(e).getTimestamp(e)}get hasTimestamp(){return!1}hasTimestampQuery(e){return this._getQueryPool(e).hasTimestampQuery(e)}isOccluded(){}async resolveTimestampsAsync(e=`render`){if(!this.trackTimestamp){Wt(`WebGPURenderer: Timestamp tracking is disabled.`);return}let t=this.timestampQueryPool[e];if(!t)return;let n=await t.resolveQueriesAsync();return this.renderer.info[e].timestamp=n,n}async getArrayBufferAsync(){}async hasFeatureAsync(){}hasFeature(){}getDrawingBufferSize(){return vZ||=new L,this.renderer.getDrawingBufferSize(vZ)}setScissorTest(){}getClearColor(){let e=this.renderer;return yZ||=new vH,e.getClearColor(yZ),yZ.getRGB(yZ),yZ}getDomElement(){let e=this.domElement;return e===null&&(e=this.parameters.canvas===void 0?zt():this.parameters.canvas,`setAttribute`in e&&e.setAttribute(`data-engine`,`three.js r185 webgpu`),this.domElement=e),e}hasCompatibility(){return!1}initRenderTarget(){}set(e,t){this.data.set(e,t)}get(e){let t=this.data.get(e);return t===void 0&&(t={},this.data.set(e,t)),t}has(e){return this.data.has(e)}delete(e){this.data.delete(e)}deleteBindGroupData(){}dispose(){}},xZ=0,SZ=class{constructor(e,t){this.buffers=[e.bufferGPU,t],this.type=e.type,this.bufferType=e.bufferType,this.pbo=e.pbo,this.byteLength=e.byteLength,this.bytesPerElement=e.BYTES_PER_ELEMENT,this.version=e.version,this.isInteger=e.isInteger,this.activeBufferIndex=0,this.baseId=e.id}get id(){return`${this.baseId}|${this.activeBufferIndex}`}get bufferGPU(){return this.buffers[this.activeBufferIndex]}get transformBuffer(){return this.buffers[this.activeBufferIndex^1]}switchBuffers(){this.activeBufferIndex^=1}},CZ=class{constructor(e){this.backend=e}createAttribute(e,t){let n=this.backend,{gl:r}=n,i=e.array,a=e.usage||r.STATIC_DRAW,o=e.isInterleavedBufferAttribute?e.data:e,s=n.get(o),c=s.bufferGPU;c===void 0&&(c=this._createBuffer(r,t,i,a),s.bufferGPU=c,s.bufferType=t,s.version=o.version);let l;if(i instanceof Float32Array)l=r.FLOAT;else if(typeof Float16Array<`u`&&i instanceof Float16Array)l=r.HALF_FLOAT;else if(i instanceof Uint16Array)l=e.isFloat16BufferAttribute?r.HALF_FLOAT:r.UNSIGNED_SHORT;else if(i instanceof Int16Array)l=r.SHORT;else if(i instanceof Uint32Array)l=r.UNSIGNED_INT;else if(i instanceof Int32Array)l=r.INT;else if(i instanceof Int8Array)l=r.BYTE;else if(i instanceof Uint8Array)l=r.UNSIGNED_BYTE;else if(i instanceof Uint8ClampedArray)l=r.UNSIGNED_BYTE;else throw Error(`THREE.WebGLBackend: Unsupported buffer data format: `+i);let u={bufferGPU:c,bufferType:t,type:l,byteLength:i.byteLength,bytesPerElement:i.BYTES_PER_ELEMENT,version:e.version,pbo:e.pbo,isInteger:l===r.INT||l===r.UNSIGNED_INT||e.gpuType===1013,id:xZ++};if(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute){let e=this._createBuffer(r,t,i,a);u=new SZ(u,e)}n.set(e,u)}updateAttribute(e){let t=this.backend,{gl:n}=t,r=e.array,i=e.isInterleavedBufferAttribute?e.data:e,a=t.get(i),o=a.bufferType,s=e.isInterleavedBufferAttribute?e.data.updateRanges:e.updateRanges;if(n.bindBuffer(o,a.bufferGPU),s.length===0)n.bufferSubData(o,0,r);else{for(let e=0,t=s.length;e{t.buffer=null,t._mapped=!1,t.removeEventListener(`release`,e),t.removeEventListener(`dispose`,e)};t.addEventListener(`release`,e),t.addEventListener(`dispose`,e),u=new Uint8Array(new ArrayBuffer(l)),t.buffer=u.buffer}else u=new Uint8Array(t);return a.bindBuffer(a.COPY_READ_BUFFER,c),a.getBufferSubData(a.COPY_READ_BUFFER,n,u),a.bindBuffer(a.COPY_READ_BUFFER,null),a.bindBuffer(a.COPY_WRITE_BUFFER,null),t&&t.isReadbackBuffer?t:u.buffer}_createBuffer(e,t,n,r){let i=e.createBuffer();return e.bindBuffer(t,i),e.bufferData(t,n,r),e.bindBuffer(t,null),i}},wZ,TZ,EZ=class{constructor(e){this.backend=e,this.gl=this.backend.gl,this.enabled={},this.parameters={},this.currentFlipSided=null,this.currentCullFace=null,this.currentProgram=null,this.currentBlendingEnabled=!1,this.currentBlending=null,this.currentBlendSrc=null,this.currentBlendDst=null,this.currentBlendSrcAlpha=null,this.currentBlendDstAlpha=null,this.currentPremultipledAlpha=null,this.currentPolygonOffsetFactor=null,this.currentPolygonOffsetUnits=null,this.currentColorMask=null,this.currentDepthReversed=!1,this.currentDepthFunc=null,this.currentDepthMask=null,this.currentStencilFunc=null,this.currentStencilRef=null,this.currentStencilFuncMask=null,this.currentStencilFail=null,this.currentStencilZFail=null,this.currentStencilZPass=null,this.currentStencilMask=null,this.currentLineWidth=null,this.currentClippingPlanes=0,this.currentVAO=null,this.currentIndex=null,this.currentBoundFramebuffers={},this.currentDrawbuffers=new WeakMap,this.maxTextures=this.gl.getParameter(this.gl.MAX_TEXTURE_IMAGE_UNITS),this.currentTextureSlot=null,this.currentBoundTextures={},this.currentBoundBufferBases={},this._init()}_init(){let e=this.gl;wZ={100:e.FUNC_ADD,101:e.FUNC_SUBTRACT,102:e.FUNC_REVERSE_SUBTRACT},TZ={200:e.ZERO,201:e.ONE,202:e.SRC_COLOR,204:e.SRC_ALPHA,210:e.SRC_ALPHA_SATURATE,208:e.DST_COLOR,206:e.DST_ALPHA,203:e.ONE_MINUS_SRC_COLOR,205:e.ONE_MINUS_SRC_ALPHA,209:e.ONE_MINUS_DST_COLOR,207:e.ONE_MINUS_DST_ALPHA};let t=e.getParameter(e.SCISSOR_BOX),n=e.getParameter(e.VIEWPORT);this.currentScissor=new Hn().fromArray(t),this.currentViewport=new Hn().fromArray(n),this._tempVec4=new Hn}enable(e){let{enabled:t}=this;t[e]!==!0&&(this.gl.enable(e),t[e]=!0)}disable(e){let{enabled:t}=this;t[e]!==!1&&(this.gl.disable(e),t[e]=!1)}setFlipSided(e){if(this.currentFlipSided!==e){let{gl:t}=this;e?t.frontFace(t.CW):t.frontFace(t.CCW),this.currentFlipSided=e}}setCullFace(e){let{gl:t}=this;e===0?this.disable(t.CULL_FACE):(this.enable(t.CULL_FACE),e!==this.currentCullFace&&(e===1?t.cullFace(t.BACK):e===2?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))),this.currentCullFace=e}setLineWidth(e){let{currentLineWidth:t,gl:n}=this;e!==t&&(n.lineWidth(e),this.currentLineWidth=e)}setMRTBlending(e,t,n){let r=this.gl,i=this.backend.drawBuffersIndexedExt;if(!i){Wt(`WebGPURenderer: Multiple Render Targets (MRT) blending configuration is not fully supported in compatibility mode. The material blending will be used for all render targets.`);return}for(let a=0;a0?this.enable(r.SAMPLE_ALPHA_TO_COVERAGE):this.disable(r.SAMPLE_ALPHA_TO_COVERAGE),n>0&&this.currentClippingPlanes!==n){let e=12288;for(let t=0;t<8;t++)t{function i(){let a=e.clientWaitSync(t,e.SYNC_FLUSH_COMMANDS_BIT,0);if(a===e.WAIT_FAILED){e.deleteSync(t),r();return}if(a===e.TIMEOUT_EXPIRED){requestAnimationFrame(i);return}e.deleteSync(t),n()}i()})}},OZ=!1,kZ,AZ,jZ,MZ=class{constructor(e){this.backend=e,this.gl=e.gl,this.extensions=e.extensions,this.defaultTextures={},this._srcFramebuffer=null,this._dstFramebuffer=null,OZ===!1&&(this._init(),OZ=!0)}_init(){let e=this.gl;kZ={[A]:e.REPEAT,[j]:e.CLAMP_TO_EDGE,[M]:e.MIRRORED_REPEAT},AZ={[N]:e.NEAREST,[ee]:e.NEAREST_MIPMAP_NEAREST,[te]:e.NEAREST_MIPMAP_LINEAR,[ne]:e.LINEAR,[re]:e.LINEAR_MIPMAP_NEAREST,[ie]:e.LINEAR_MIPMAP_LINEAR},jZ={512:e.NEVER,519:e.ALWAYS,513:e.LESS,515:e.LEQUAL,514:e.EQUAL,518:e.GEQUAL,516:e.GREATER,517:e.NOTEQUAL}}getGLTextureType(e){let{gl:t}=this,n;return n=e.isCubeTexture===!0?t.TEXTURE_CUBE_MAP:e.isArrayTexture===!0||e.isDataArrayTexture===!0||e.isCompressedArrayTexture===!0?t.TEXTURE_2D_ARRAY:e.isData3DTexture===!0?t.TEXTURE_3D:t.TEXTURE_2D,n}getInternalFormat(e,t,n,r,i,a=!1){let{gl:o,extensions:s}=this;if(e!==null){if(o[e]!==void 0)return o[e];F(`WebGLBackend: Attempt to use non-existing WebGL internal format '`+e+`'`)}let c=null;r&&(c=s.get(`EXT_texture_norm16`),c||F(`WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension`));let l=t;if(t===o.RED&&(n===o.FLOAT&&(l=o.R32F),n===o.HALF_FLOAT&&(l=o.R16F),n===o.UNSIGNED_BYTE&&(l=o.R8),n===o.BYTE&&(l=o.R8_SNORM),n===o.UNSIGNED_SHORT&&c&&(l=c.R16_EXT),n===o.SHORT&&c&&(l=c.R16_SNORM_EXT)),t===o.RED_INTEGER&&(n===o.UNSIGNED_BYTE&&(l=o.R8UI),n===o.UNSIGNED_SHORT&&(l=o.R16UI),n===o.UNSIGNED_INT&&(l=o.R32UI),n===o.BYTE&&(l=o.R8I),n===o.SHORT&&(l=o.R16I),n===o.INT&&(l=o.R32I)),t===o.RG&&(n===o.FLOAT&&(l=o.RG32F),n===o.HALF_FLOAT&&(l=o.RG16F),n===o.UNSIGNED_BYTE&&(l=o.RG8),n===o.BYTE&&(l=o.RG8_SNORM),n===o.UNSIGNED_SHORT&&c&&(l=c.RG16_EXT),n===o.SHORT&&c&&(l=c.RG16_SNORM_EXT)),t===o.RG_INTEGER&&(n===o.UNSIGNED_BYTE&&(l=o.RG8UI),n===o.UNSIGNED_SHORT&&(l=o.RG16UI),n===o.UNSIGNED_INT&&(l=o.RG32UI),n===o.BYTE&&(l=o.RG8I),n===o.SHORT&&(l=o.RG16I),n===o.INT&&(l=o.RG32I)),t===o.RGB){let e=a?xt:jn.getTransfer(i);n===o.FLOAT&&(l=o.RGB32F),n===o.HALF_FLOAT&&(l=o.RGB16F),n===o.UNSIGNED_BYTE&&(l=e===`srgb`?o.SRGB8:o.RGB8),n===o.BYTE&&(l=o.RGB8_SNORM),n===o.UNSIGNED_SHORT&&c&&(l=c.RGB16_EXT),n===o.SHORT&&c&&(l=c.RGB16_SNORM_EXT),n===o.UNSIGNED_SHORT_5_6_5&&(l=o.RGB565),n===o.UNSIGNED_SHORT_5_5_5_1&&(l=o.RGB5_A1),n===o.UNSIGNED_SHORT_4_4_4_4&&(l=o.RGB4),n===o.UNSIGNED_INT_5_9_9_9_REV&&(l=o.RGB9_E5),n===o.UNSIGNED_INT_10F_11F_11F_REV&&(l=o.R11F_G11F_B10F)}if(t===o.RGB_INTEGER&&(n===o.UNSIGNED_BYTE&&(l=o.RGB8UI),n===o.UNSIGNED_SHORT&&(l=o.RGB16UI),n===o.UNSIGNED_INT&&(l=o.RGB32UI),n===o.BYTE&&(l=o.RGB8I),n===o.SHORT&&(l=o.RGB16I),n===o.INT&&(l=o.RGB32I)),t===o.RGBA){let e=a?xt:jn.getTransfer(i);n===o.FLOAT&&(l=o.RGBA32F),n===o.HALF_FLOAT&&(l=o.RGBA16F),n===o.UNSIGNED_BYTE&&(l=e===`srgb`?o.SRGB8_ALPHA8:o.RGBA8),n===o.BYTE&&(l=o.RGBA8_SNORM),n===o.UNSIGNED_SHORT&&c&&(l=c.RGBA16_EXT),n===o.SHORT&&c&&(l=c.RGBA16_SNORM_EXT),n===o.UNSIGNED_SHORT_4_4_4_4&&(l=o.RGBA4),n===o.UNSIGNED_SHORT_5_5_5_1&&(l=o.RGB5_A1)}return t===o.RGBA_INTEGER&&(n===o.UNSIGNED_BYTE&&(l=o.RGBA8UI),n===o.UNSIGNED_SHORT&&(l=o.RGBA16UI),n===o.UNSIGNED_INT&&(l=o.RGBA32UI),n===o.BYTE&&(l=o.RGBA8I),n===o.SHORT&&(l=o.RGBA16I),n===o.INT&&(l=o.RGBA32I)),t===o.DEPTH_COMPONENT&&(n===o.UNSIGNED_SHORT&&(l=o.DEPTH_COMPONENT16),n===o.UNSIGNED_INT&&(l=o.DEPTH_COMPONENT24),n===o.FLOAT&&(l=o.DEPTH_COMPONENT32F)),t===o.DEPTH_STENCIL&&n===o.UNSIGNED_INT_24_8&&(l=o.DEPTH24_STENCIL8),(l===o.R16F||l===o.R32F||l===o.RG16F||l===o.RG32F||l===o.RGBA16F||l===o.RGBA32F)&&s.get(`EXT_color_buffer_float`),l}setTextureParameters(e,t){let{gl:n,extensions:r,backend:i}=this,{state:a}=this.backend,o=jn.getPrimaries(jn.workingColorSpace),s=t.colorSpace===``?null:jn.getPrimaries(t.colorSpace),c=t.colorSpace===``||o===s?n.NONE:n.BROWSER_DEFAULT_WEBGL;a.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,t.flipY),a.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),a.pixelStorei(n.UNPACK_ALIGNMENT,t.unpackAlignment),a.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,c),n.texParameteri(e,n.TEXTURE_WRAP_S,kZ[t.wrapS]),n.texParameteri(e,n.TEXTURE_WRAP_T,kZ[t.wrapT]),(e===n.TEXTURE_3D||e===n.TEXTURE_2D_ARRAY)&&(t.isArrayTexture||n.texParameteri(e,n.TEXTURE_WRAP_R,kZ[t.wrapR])),n.texParameteri(e,n.TEXTURE_MAG_FILTER,AZ[t.magFilter]);let l=t.mipmaps!==void 0&&t.mipmaps.length>0,u=t.minFilter===1006&&l?ie:t.minFilter;if(n.texParameteri(e,n.TEXTURE_MIN_FILTER,AZ[u]),t.compareFunction&&(n.texParameteri(e,n.TEXTURE_COMPARE_MODE,n.COMPARE_REF_TO_TEXTURE),n.texParameteri(e,n.TEXTURE_COMPARE_FUNC,jZ[t.compareFunction])),r.has(`EXT_texture_filter_anisotropic`)===!0){if(t.magFilter===1003||t.minFilter!==1005&&t.minFilter!==1008||t.type===1015&&r.has(`OES_texture_float_linear`)===!1)return;if(t.anisotropy>1){let a=r.get(`EXT_texture_filter_anisotropic`);n.texParameterf(e,a.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(t.anisotropy,i.capabilities.getMaxAnisotropy()))}}}createDefaultTexture(e){let{gl:t,backend:n,defaultTextures:r}=this,i=this.getGLTextureType(e),a=r[i];a===void 0&&(a=t.createTexture(),n.state.bindTexture(i,a),t.texParameteri(i,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(i,t.TEXTURE_MAG_FILTER,t.NEAREST),r[i]=a),n.set(e,{textureGPU:a,glTextureType:i})}createTexture(e,t){let{gl:n,backend:r}=this,i,a,o,s,c;if(e.isExternalTexture===!0)i=e.sourceTexture,a=this.getGLTextureType(e);else{let{levels:l,width:u,height:d,depth:f}=t;o=r.utils.convert(e.format,e.colorSpace),s=r.utils.convert(e.type),c=this.getInternalFormat(e.internalFormat,o,s,e.normalized,e.colorSpace,e.isVideoTexture),i=n.createTexture(),a=this.getGLTextureType(e),r.state.bindTexture(a,i),this.setTextureParameters(a,e),e.isArrayTexture||e.isDataArrayTexture||e.isCompressedArrayTexture?n.texStorage3D(n.TEXTURE_2D_ARRAY,l,c,u,d,f):e.isData3DTexture?n.texStorage3D(n.TEXTURE_3D,l,c,u,d,f):e.isVideoTexture||n.texStorage2D(a,l,c,u,d)}r.set(e,{textureGPU:i,glTextureType:a,glFormat:o,glType:s,glInternalFormat:c})}copyBufferToTexture(e,t){let{gl:n,backend:r}=this,{state:i}=r,{textureGPU:a,glTextureType:o,glFormat:s,glType:c}=r.get(t),{width:l,height:u}=t.source.data;n.bindBuffer(n.PIXEL_UNPACK_BUFFER,e),r.state.bindTexture(o,a),i.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,!1),i.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),n.texSubImage2D(o,0,0,0,l,u,s,c,0),n.bindBuffer(n.PIXEL_UNPACK_BUFFER,null),r.state.unbindTexture()}updateTexture(e,t){let{gl:n}=this,{width:r,height:i}=t,{textureGPU:a,glTextureType:o,glFormat:s,glType:c,glInternalFormat:l}=this.backend.get(e);if(!(e.isRenderTargetTexture||a===void 0))if(this.backend.state.bindTexture(o,a),this.setTextureParameters(o,e),e.isCompressedTexture){let r=e.mipmaps,i=t.image;for(let t=0;t0){let t=ll(r.width,r.height,e.format,e.type);for(let i of e.layerUpdates){let e=r.data.subarray(i*t/r.data.BYTES_PER_ELEMENT,(i+1)*t/r.data.BYTES_PER_ELEMENT);n.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,i,r.width,r.height,1,s,c,e)}e.clearLayerUpdates()}else n.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,0,r.width,r.height,r.depth,s,c,r.data)}else if(e.isData3DTexture){let e=t.image;n.texSubImage3D(n.TEXTURE_3D,0,0,0,0,e.width,e.height,e.depth,s,c,e.data)}else if(e.isVideoTexture)e.update(),n.texImage2D(o,0,l,s,c,t.image);else if(e.isHTMLTexture)typeof n.texElementImage2D==`function`&&(n.texElementImage2D.length===3?n.texElementImage2D(n.TEXTURE_2D,n.RGBA8,t.image):n.texElementImage2D(n.TEXTURE_2D,0,n.RGBA,n.RGBA,n.UNSIGNED_BYTE,t.image));else{let a=e.mipmaps;if(a.length>0)for(let e=0,t=a.length;e0,d=t.renderTarget?t.renderTarget.height:this.backend.getDrawingBufferSize().y;if(u){let n=o!==0||s!==0,u,f;if(e.isDepthTexture===!0?(u=r.DEPTH_BUFFER_BIT,f=r.DEPTH_ATTACHMENT,t.stencil&&(u|=r.STENCIL_BUFFER_BIT)):(u=r.COLOR_BUFFER_BIT,f=r.COLOR_ATTACHMENT0),n){let e=this.backend.get(t.renderTarget),n=e.framebuffers[t.getCacheKey()],f=e.msaaFrameBuffer;i.bindFramebuffer(r.DRAW_FRAMEBUFFER,n),i.bindFramebuffer(r.READ_FRAMEBUFFER,f);let p=d-s-l;r.blitFramebuffer(o,p,o+c,p+l,o,p,o+c,p+l,u,r.NEAREST),i.bindFramebuffer(r.READ_FRAMEBUFFER,n),i.bindTexture(r.TEXTURE_2D,a),r.copyTexSubImage2D(r.TEXTURE_2D,0,0,0,o,p,c,l),i.unbindTexture()}else{let e=r.createFramebuffer();i.bindFramebuffer(r.DRAW_FRAMEBUFFER,e),r.framebufferTexture2D(r.DRAW_FRAMEBUFFER,f,r.TEXTURE_2D,a,0),r.blitFramebuffer(0,0,c,l,0,0,c,l,u,r.NEAREST),r.deleteFramebuffer(e)}}else i.bindTexture(r.TEXTURE_2D,a),r.copyTexSubImage2D(r.TEXTURE_2D,0,0,0,o,d-l-s,c,l),i.unbindTexture();e.generateMipmaps&&this.generateMipmaps(e),this.backend._setFramebuffer(t)}setupRenderBufferStorage(e,t,n,r=!1){let{gl:i}=this,a=t.renderTarget,{depthTexture:o,depthBuffer:s,stencilBuffer:c,width:l,height:u}=a;if(i.bindRenderbuffer(i.RENDERBUFFER,e),s&&!c){let t=i.DEPTH_COMPONENT24;r===!0?this.extensions.get(`WEBGL_multisampled_render_to_texture`).renderbufferStorageMultisampleEXT(i.RENDERBUFFER,a.samples,t,l,u):n>0?(o&&o.isDepthTexture&&o.type===i.FLOAT&&(t=i.DEPTH_COMPONENT32F),i.renderbufferStorageMultisample(i.RENDERBUFFER,n,t,l,u)):i.renderbufferStorage(i.RENDERBUFFER,t,l,u),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.RENDERBUFFER,e)}else s&&c&&(n>0?i.renderbufferStorageMultisample(i.RENDERBUFFER,n,i.DEPTH24_STENCIL8,l,u):i.renderbufferStorage(i.RENDERBUFFER,i.DEPTH_STENCIL,l,u),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.RENDERBUFFER,e));i.bindRenderbuffer(i.RENDERBUFFER,null)}async copyTextureToBuffer(e,t,n,r,i,a){let{backend:o,gl:s}=this,{textureGPU:c,glFormat:l,glType:u}=this.backend.get(e),d=s.createFramebuffer();o.state.bindFramebuffer(s.READ_FRAMEBUFFER,d);let f=e.isCubeTexture?s.TEXTURE_CUBE_MAP_POSITIVE_X+a:s.TEXTURE_2D;s.framebufferTexture2D(s.READ_FRAMEBUFFER,s.COLOR_ATTACHMENT0,f,c,0);let p=this._getTypedArrayType(u),m=this._getBytesPerTexel(u,l),h=r*i*m,g=s.createBuffer();s.bindBuffer(s.PIXEL_PACK_BUFFER,g),s.bufferData(s.PIXEL_PACK_BUFFER,h,s.STREAM_READ),s.readPixels(t,n,r,i,l,u,0),s.bindBuffer(s.PIXEL_PACK_BUFFER,null),await o.utils._clientWaitAsync();let _=new p(h/p.BYTES_PER_ELEMENT);return s.bindBuffer(s.PIXEL_PACK_BUFFER,g),s.getBufferSubData(s.PIXEL_PACK_BUFFER,0,_),s.bindBuffer(s.PIXEL_PACK_BUFFER,null),o.state.bindFramebuffer(s.READ_FRAMEBUFFER,null),s.deleteFramebuffer(d),_}_getTypedArrayType(e){let{gl:t}=this;if(e===t.UNSIGNED_BYTE)return Uint8Array;if(e===t.UNSIGNED_SHORT_4_4_4_4||e===t.UNSIGNED_SHORT_5_5_5_1||e===t.UNSIGNED_SHORT_5_6_5||e===t.UNSIGNED_SHORT)return Uint16Array;if(e===t.UNSIGNED_INT)return Uint32Array;if(e===t.HALF_FLOAT)return Uint16Array;if(e===t.FLOAT)return Float32Array;throw Error(`THREE.WebGLTextureUtils: Unsupported WebGL type: ${e}`)}_getBytesPerTexel(e,t){let{gl:n}=this,r=0;if(e===n.UNSIGNED_BYTE&&(r=1),(e===n.UNSIGNED_SHORT_4_4_4_4||e===n.UNSIGNED_SHORT_5_5_5_1||e===n.UNSIGNED_SHORT_5_6_5||e===n.UNSIGNED_SHORT||e===n.HALF_FLOAT)&&(r=2),(e===n.UNSIGNED_INT||e===n.FLOAT)&&(r=4),t===n.RGBA)return r*4;if(t===n.RGB)return r*3;if(t===n.ALPHA)return r}dispose(){let{gl:e}=this;this._srcFramebuffer!==null&&e.deleteFramebuffer(this._srcFramebuffer),this._dstFramebuffer!==null&&e.deleteFramebuffer(this._dstFramebuffer)}};function NZ(e){return e.isDataTexture?e.image.data:typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement||typeof ImageBitmap<`u`&&e instanceof ImageBitmap||typeof OffscreenCanvas<`u`&&e instanceof OffscreenCanvas?e:e.data}var PZ=class{constructor(e){this.backend=e,this.gl=this.backend.gl,this.availableExtensions=this.gl.getSupportedExtensions(),this.extensions={}}get(e){let t=this.extensions[e];return t===void 0&&(t=this.gl.getExtension(e),this.extensions[e]=t),t}has(e){return this.availableExtensions.includes(e)}},FZ=class{constructor(e){this.backend=e,this.maxAnisotropy=null,this.maxUniformBlockSize=null}getMaxAnisotropy(){if(this.maxAnisotropy!==null)return this.maxAnisotropy;let e=this.backend.gl,t=this.backend.extensions;if(t.has(`EXT_texture_filter_anisotropic`)===!0){let n=t.get(`EXT_texture_filter_anisotropic`);this.maxAnisotropy=e.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else this.maxAnisotropy=0;return this.maxAnisotropy}getUniformBufferLimit(){if(this.maxUniformBlockSize!==null)return this.maxUniformBlockSize;let e=this.backend.gl;return this.maxUniformBlockSize=e.getParameter(e.MAX_UNIFORM_BLOCK_SIZE),this.maxUniformBlockSize}},IZ={WEBGL_multi_draw:`WEBGL_multi_draw`,WEBGL_compressed_texture_astc:`texture-compression-astc`,WEBGL_compressed_texture_etc:`texture-compression-etc2`,WEBGL_compressed_texture_etc1:`texture-compression-etc1`,WEBGL_compressed_texture_pvrtc:`texture-compression-pvrtc`,WEBGL_compressed_texture_s3tc:`texture-compression-s3tc`,EXT_texture_compression_bptc:`texture-compression-bc`,EXT_disjoint_timer_query_webgl2:`timestamp-query`,OVR_multiview2:`OVR_multiview2`},LZ=class{constructor(e){this.gl=e.gl,this.extensions=e.extensions,this.info=e.renderer.info,this.mode=null,this.index=0,this.type=null,this.object=null}render(e,t){let{gl:n,mode:r,object:i,type:a,info:o,index:s}=this;s===0?n.drawArrays(r,e,t):n.drawElements(r,t,a,e),o.update(i,t,1)}renderInstances(e,t,n){let{gl:r,mode:i,type:a,index:o,object:s,info:c}=this;n!==0&&(o===0?r.drawArraysInstanced(i,e,t,n):r.drawElementsInstanced(i,t,a,e,n),c.update(s,t,n))}renderMultiDraw(e,t,n){let{extensions:r,mode:i,object:a,info:o}=this;if(n===0)return;let s=r.get(`WEBGL_multi_draw`);if(s===null)for(let r=0;rthis.maxQueries)return Wt(`WebGLTimestampQueryPool [${this.type}]: Maximum number of queries exceeded, when using trackTimestamp it is necessary to resolves the queries via renderer.resolveTimestampsAsync( THREE.TimestampQuery.${this.type.toUpperCase()} ).`),null;let t=this.currentQueryIndex;return this.currentQueryIndex+=2,this.queryStates.set(t,`inactive`),this.queryOffsets.set(e,t),t}beginQuery(e){if(!this.trackTimestamp||this.isDisposed)return;let t=this.queryOffsets.get(e);if(t==null||this.activeQuery!==null)return;let n=this.queries[t];if(n)try{this.queryStates.get(t)===`inactive`&&(this.gl.beginQuery(this.ext.TIME_ELAPSED_EXT,n),this.activeQuery=t,this.queryStates.set(t,`started`))}catch(e){I(`Error in beginQuery:`,e),this.activeQuery=null,this.queryStates.set(t,`inactive`)}}endQuery(e){if(!this.trackTimestamp||this.isDisposed)return;let t=this.queryOffsets.get(e);if(t!=null&&this.activeQuery===t)try{this.gl.endQuery(this.ext.TIME_ELAPSED_EXT),this.queryStates.set(t,`ended`),this.activeQuery=null}catch(e){I(`Error in endQuery:`,e),this.queryStates.set(t,`inactive`),this.activeQuery=null}}async resolveQueriesAsync(){if(!this.trackTimestamp||this.pendingResolve)return this.lastValue;this.pendingResolve=!0;try{let e=new Map;for(let[t,n]of this.queryOffsets)if(this.queryStates.get(n)===`ended`){let r=this.queries[n];e.set(t,this.resolveQuery(r))}if(e.size===0)return this.lastValue;let t={},n=[];for(let[r,i]of e){let e=r.match(/^(.*):f(\d+)$/),a=parseInt(e[2]);n.includes(a)===!1&&n.push(a),t[a]===void 0&&(t[a]=0);let o=await i;this.timestamps.set(r,o),t[a]+=o}let r=t[n[n.length-1]];return this.lastValue=r,this.frames=n,this.currentQueryIndex=0,this.queryOffsets.clear(),this.queryStates.clear(),this.activeQuery=null,r}catch(e){return I(`Error resolving queries:`,e),this.lastValue}finally{this.pendingResolve=!1}}async resolveQuery(e){return new Promise(t=>{if(this.isDisposed){t(this.lastValue);return}let n,r=!1,i=()=>{n&&=(clearTimeout(n),null)},a=e=>{r||(r=!0,i(),t(e))},o=()=>{if(this.isDisposed){a(this.lastValue);return}try{if(this.gl.getParameter(this.ext.GPU_DISJOINT_EXT)){a(this.lastValue);return}if(!this.gl.getQueryParameter(e,this.gl.QUERY_RESULT_AVAILABLE)){n=setTimeout(o,1);return}let r=this.gl.getQueryParameter(e,this.gl.QUERY_RESULT);t(Number(r)/1e6)}catch(e){I(`Error checking query:`,e),t(this.lastValue)}};o()})}dispose(){if(!this.isDisposed&&(this.isDisposed=!0,this.trackTimestamp)){for(let e of this.queries)this.gl.deleteQuery(e);this.queries=[],this.queryStates.clear(),this.queryOffsets.clear(),this.lastValue=0,this.activeQuery=null}}},BZ=class extends bZ{constructor(e={}){super(e),this.isWebGLBackend=!0,this.attributeUtils=null,this.extensions=null,this.capabilities=null,this.textureUtils=null,this.bufferRenderer=null,this.gl=null,this.state=null,this.utils=null,this.vaoCache={},this.transformFeedbackCache={},this.discard=!1,this.disjoint=null,this.parallel=null,this._currentContext=null,this._knownBindings=new WeakSet,this._supportsInvalidateFramebuffer=typeof navigator>`u`?!1:/OculusBrowser/g.test(navigator.userAgent),this._xrFramebuffer=null}init(e){super.init(e);let t=this.parameters,n={antialias:e.currentSamples>0,alpha:!0,depth:e.depth,stencil:e.stencil},r=t.context===void 0?e.domElement.getContext(`webgl2`,n):t.context;function i(t){t.preventDefault();let n={api:`WebGL`,message:t.statusMessage||`Unknown reason`,reason:null,originalEvent:t};e.onDeviceLost(n)}this._onContextLost=i,e.domElement.addEventListener(`webglcontextlost`,i,!1),this.gl=r,this.extensions=new PZ(this),this.capabilities=new FZ(this),this.attributeUtils=new CZ(this),this.textureUtils=new MZ(this),this.bufferRenderer=new LZ(this),this.state=new EZ(this),this.utils=new DZ(this),this.extensions.get(`EXT_color_buffer_float`),this.extensions.get(`WEBGL_clip_cull_distance`),this.extensions.get(`OES_texture_float_linear`),this.extensions.get(`EXT_color_buffer_half_float`),this.extensions.get(`WEBGL_multisampled_render_to_texture`),this.extensions.get(`WEBGL_render_shared_exponent`),this.extensions.get(`WEBGL_multi_draw`),this.extensions.get(`OVR_multiview2`),this.extensions.get(`EXT_clip_control`),this.disjoint=this.extensions.get(`EXT_disjoint_timer_query_webgl2`),this.parallel=this.extensions.get(`KHR_parallel_shader_compile`),this.drawBuffersIndexedExt=this.extensions.get(`OES_draw_buffers_indexed`),t.reversedDepthBuffer&&(this.extensions.has(`EXT_clip_control`)?e.reversedDepthBuffer=!0:(F(`WebGPURenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.`),e.reversedDepthBuffer=!1)),e.reversedDepthBuffer&&this.state.setReversedDepth(!0)}get coordinateSystem(){return Mt}get hasTimestamp(){return this.disjoint!==null}async getArrayBufferAsync(e,t=null,n=0,r=-1){return await this.attributeUtils.getArrayBufferAsync(e,t,n,r)}async makeXRCompatible(){this.gl.getContextAttributes().xrCompatible!==!0&&await this.gl.makeXRCompatible()}setXRTarget(e){this._xrFramebuffer=e}setXRRenderTargetTextures(e,t,n=null){let r=this.gl;if(this.set(e.texture,{textureGPU:t,glInternalFormat:r.RGBA8}),n!==null){let t=e.stencilBuffer?r.DEPTH24_STENCIL8:r.DEPTH_COMPONENT24;this.set(e.depthTexture,{textureGPU:n,glInternalFormat:t}),this.extensions.has(`WEBGL_multisampled_render_to_texture`)===!0&&e._autoAllocateDepthBuffer===!0&&e.multiview===!1&&F(`WebGLBackend: Render-to-texture extension was disabled because an external texture was provided`),e._autoAllocateDepthBuffer=!1}}initTimestampQuery(e,t){if(!this.disjoint||!this.trackTimestamp)return;this.timestampQueryPool[e]||(this.timestampQueryPool[e]=new zZ(this.gl,e,2048));let n=this.timestampQueryPool[e];n.allocateQueriesForContext(t)!==null&&n.beginQuery(t)}prepareTimestampBuffer(e,t){!this.disjoint||!this.trackTimestamp||this.timestampQueryPool[e].endQuery(t)}getContext(){return this.gl}beginRender(e){let{state:t}=this,n=this.get(e);if(e.viewport)this.updateViewport(e);else{let{width:e,height:n}=this.getDrawingBufferSize();t.viewport(0,0,e,n)}if(e.scissor)this.updateScissor(e);else{let{width:e,height:n}=this.getDrawingBufferSize();t.scissor(0,0,e,n)}this.initTimestampQuery(Pt.RENDER,this.getTimestampUID(e)),n.previousContext=this._currentContext,this._currentContext=e,this._setFramebuffer(e),this.clear(e.clearColor,e.clearDepth,e.clearStencil,e,!1);let r=e.occlusionQueryCount;r>0&&(n.currentOcclusionQueries=n.occlusionQueries,n.currentOcclusionQueryObjects=n.occlusionQueryObjects,n.lastOcclusionObject=null,n.occlusionQueries=Array(r),n.occlusionQueryObjects=Array(r),n.occlusionQueryIndex=0)}finishRender(e){let{gl:t,state:n}=this,r=this.get(e),i=r.previousContext;n.resetVertexState();let a=e.occlusionQueryCount;a>0&&(a>r.occlusionQueryIndex&&t.endQuery(t.ANY_SAMPLES_PASSED),this.resolveOccludedAsync(e));let o=e.textures;if(o!==null)for(let e=0;e{let o=0;for(let t=0;t1?t.renderInstances(n,r,i):t.render(n,r)}draw(e){let{object:t,pipeline:n,material:r,context:i,hardwareClippingPlanes:a}=e,{programGPU:o}=this.get(n),{gl:s,state:c}=this,l=this.get(i),u=e.getDrawParameters();if(u===null)return;this._bindUniforms(e.getBindings());let d=t.isMesh&&t.matrixWorld.determinantAffine()<0;c.setMaterial(r,d,a),i.mrt!==null&&i.textures!==null&&c.setMRTBlending(i.textures,i.mrt,r),c.useProgram(o);let f=e.getAttributes(),p=this.get(f),m=p.vaoGPU;if(m===void 0){let e=this._getVaoKey(f);m=this.vaoCache[e],m===void 0&&(m=this._createVao(f),this.vaoCache[e]=m,p.vaoGPU=m)}let h=e.getIndex(),g=h===null?null:this.get(h).bufferGPU;c.setVertexState(m,g);let _=l.lastOcclusionObject;if(_!==t&&_!==void 0){if(_!==null&&_.occlusionTest===!0&&(s.endQuery(s.ANY_SAMPLES_PASSED),l.occlusionQueryIndex++),t.occlusionTest===!0){let e=s.createQuery();s.beginQuery(s.ANY_SAMPLES_PASSED,e),l.occlusionQueries[l.occlusionQueryIndex]=e,l.occlusionQueryObjects[l.occlusionQueryIndex]=t}l.lastOcclusionObject=t}let v=this.bufferRenderer;t.isPoints?v.mode=s.POINTS:t.isLineSegments?v.mode=s.LINES:t.isLine?v.mode=s.LINE_STRIP:t.isLineLoop?v.mode=s.LINE_LOOP:r.wireframe===!0?(c.setLineWidth(r.wireframeLinewidth*this.renderer.getPixelRatio()),v.mode=s.LINES):v.mode=s.TRIANGLES;let{vertexCount:y,instanceCount:b}=u,{firstVertex:x}=u;if(v.object=t,h!==null){x*=h.array.BYTES_PER_ELEMENT;let e=this.get(h);v.index=h.count,v.type=e.type}else v.index=0;if(e.camera.isArrayCamera===!0&&e.camera.cameras.length>0&&e.camera.isMultiViewCamera===!1){let n=this.get(e.camera),r=e.camera.cameras,i=e.getBindingGroup(`cameraIndex`).bindings[0];if(n.indexesGPU===void 0||n.indexesGPU.length!==r.length){let e=new Uint32Array([0,0,0,0]),t=[];for(let n=0,i=r.length;n{let i=this.parallel,a=()=>{n.getProgramParameter(o,i.COMPLETION_STATUS_KHR)?(this._completeCompile(e,r),t()):requestAnimationFrame(a)};a()});t.push(i);return}this._completeCompile(e,r)}_handleSource(e,t){let n=e.split(` `),r=[],i=Math.max(t-6,0),a=Math.min(t+6,n.length);for(let e=i;e`:` `} ${i}: ${n[e]}`)}return r.join(` `)}_getShaderErrors(e,t,n){let r=e.getShaderParameter(t,e.COMPILE_STATUS),i=(e.getShaderInfoLog(t)||``).trim();if(r&&i===``)return``;let a=/ERROR: 0:(\d+)/.exec(i);if(a){let r=parseInt(a[1]);return n.toUpperCase()+` `+i+` `+this._handleSource(e.getShaderSource(t),r)}else return i}_logProgramError(e,t,n){if(this.renderer.debug.checkShaderErrors){let r=this.gl,i=(r.getProgramInfoLog(e)||``).trim();if(r.getProgramParameter(e,r.LINK_STATUS)===!1)if(typeof this.renderer.debug.onShaderError==`function`)this.renderer.debug.onShaderError(r,e,n,t);else{let a=this._getShaderErrors(r,n,`vertex`),o=this._getShaderErrors(r,t,`fragment`);I(`WebGLProgram: Shader Error `+r.getError()+` - VALIDATE_STATUS `+r.getProgramParameter(e,r.VALIDATE_STATUS)+` Program Info Log: `+i+` `+a+` `+o)}else i!==``&&F(`WebGLProgram: Program Info Log:`,i)}}_completeCompile(e,t){let{state:n,gl:r}=this,{programGPU:i,fragmentShader:a,vertexShader:o}=this.get(t);r.getProgramParameter(i,r.LINK_STATUS)===!1&&this._logProgramError(i,a,o),n.useProgram(i);let s=e.getBindings();this._setupBindings(s,i),this.set(t,{programGPU:i,pipeline:i})}createComputePipeline(e,t){let{state:n,gl:r}=this,i={stage:`fragment`,code:`#version 300 es precision highp float; void main() {}`};this.createProgram(i);let{computeProgram:a}=e,o=r.createProgram(),s=this.get(i).shaderGPU,c=this.get(a).shaderGPU,l=a.transforms,u=[],d=[];for(let e=0;eIZ[t]===e),n=this.extensions;for(let e=0;e1,f=i.isXRRenderTarget===!0,p=f===!0&&i._hasExternalTextures===!0,m=a.msaaFrameBuffer,h=a.depthRenderbuffer,g=this.extensions.get(`WEBGL_multisampled_render_to_texture`),_=this.extensions.get(`OVR_multiview2`),v=this._useMultisampledExtension(i),y=mH(e),b;if(l?(a.cubeFramebuffers||={},b=a.cubeFramebuffers[y]):f&&p===!1?b=this._xrFramebuffer:(a.framebuffers||={},b=a.framebuffers[y]),b===void 0){b=t.createFramebuffer(),n.bindFramebuffer(t.FRAMEBUFFER,b);let r=e.textures,s=[];if(l){a.cubeFramebuffers[y]=b;let{textureGPU:e}=this.get(r[0]),n=this.renderer._activeCubeFace,i=this.renderer._activeMipmapLevel;t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+n,e,i)}else{a.framebuffers[y]=b;for(let n=0;n0&&v===!1&&!i.multiview){if(m===void 0){let r=[];m=t.createFramebuffer(),n.bindFramebuffer(t.FRAMEBUFFER,m);let i=[],l=e.textures;for(let n=0;n0&&this._useMultisampledExtension(r)===!1){let a=i.framebuffers[e.getCacheKey()],o=t.COLOR_BUFFER_BIT;r.resolveDepthBuffer&&(r.depthBuffer&&(o|=t.DEPTH_BUFFER_BIT),r.stencilBuffer&&r.resolveStencilBuffer&&(o|=t.STENCIL_BUFFER_BIT));let s=i.msaaFrameBuffer,c=i.msaaRenderbuffers,l=e.textures,u=l.length>1;if(n.bindFramebuffer(t.READ_FRAMEBUFFER,s),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,a),u)for(let e=0;e0&&this.extensions.has(`WEBGL_multisampled_render_to_texture`)===!0&&e._autoAllocateDepthBuffer!==!1}dispose(){this.textureUtils!==null&&this.textureUtils.dispose();let e=this.extensions.get(`WEBGL_lose_context`);e&&e.loseContext(),this.renderer.domElement.removeEventListener(`webglcontextlost`,this._onContextLost)}},VZ={PointList:`point-list`,LineList:`line-list`,LineStrip:`line-strip`,TriangleList:`triangle-list`},HZ=typeof self<`u`&&self.GPUShaderStage?self.GPUShaderStage:{VERTEX:1,FRAGMENT:2,COMPUTE:4},UZ={Never:`never`,Less:`less`,Equal:`equal`,LessEqual:`less-equal`,Greater:`greater`,NotEqual:`not-equal`,GreaterEqual:`greater-equal`,Always:`always`},WZ={Store:`store`},GZ={Load:`load`,Clear:`clear`},KZ={CCW:`ccw`,CW:`cw`},qZ={None:`none`,Back:`back`},JZ={Uint16:`uint16`,Uint32:`uint32`},Q={R8Unorm:`r8unorm`,R8Snorm:`r8snorm`,R8Uint:`r8uint`,R8Sint:`r8sint`,R16Uint:`r16uint`,R16Sint:`r16sint`,R16Float:`r16float`,RG8Unorm:`rg8unorm`,RG8Snorm:`rg8snorm`,RG8Uint:`rg8uint`,RG8Sint:`rg8sint`,R16Unorm:`r16unorm`,R16Snorm:`r16snorm`,R32Uint:`r32uint`,R32Sint:`r32sint`,R32Float:`r32float`,RG16Uint:`rg16uint`,RG16Sint:`rg16sint`,RG16Float:`rg16float`,RGBA8Unorm:`rgba8unorm`,RGBA8UnormSRGB:`rgba8unorm-srgb`,RGBA8Snorm:`rgba8snorm`,RGBA8Uint:`rgba8uint`,RGBA8Sint:`rgba8sint`,BGRA8Unorm:`bgra8unorm`,BGRA8UnormSRGB:`bgra8unorm-srgb`,RG16Unorm:`rg16unorm`,RG16Snorm:`rg16snorm`,RGB9E5UFloat:`rgb9e5ufloat`,RGB10A2Unorm:`rgb10a2unorm`,RG11B10UFloat:`rg11b10ufloat`,RG32Uint:`rg32uint`,RG32Sint:`rg32sint`,RG32Float:`rg32float`,RGBA16Uint:`rgba16uint`,RGBA16Sint:`rgba16sint`,RGBA16Float:`rgba16float`,RGBA16Unorm:`rgba16unorm`,RGBA16Snorm:`rgba16snorm`,RGBA32Uint:`rgba32uint`,RGBA32Sint:`rgba32sint`,RGBA32Float:`rgba32float`,Depth16Unorm:`depth16unorm`,Depth24Plus:`depth24plus`,Depth24PlusStencil8:`depth24plus-stencil8`,Depth32Float:`depth32float`,Depth32FloatStencil8:`depth32float-stencil8`,BC1RGBAUnorm:`bc1-rgba-unorm`,BC1RGBAUnormSRGB:`bc1-rgba-unorm-srgb`,BC2RGBAUnorm:`bc2-rgba-unorm`,BC2RGBAUnormSRGB:`bc2-rgba-unorm-srgb`,BC3RGBAUnorm:`bc3-rgba-unorm`,BC3RGBAUnormSRGB:`bc3-rgba-unorm-srgb`,BC4RUnorm:`bc4-r-unorm`,BC4RSnorm:`bc4-r-snorm`,BC5RGUnorm:`bc5-rg-unorm`,BC5RGSnorm:`bc5-rg-snorm`,BC6HRGBUFloat:`bc6h-rgb-ufloat`,BC6HRGBFloat:`bc6h-rgb-float`,BC7RGBAUnorm:`bc7-rgba-unorm`,BC7RGBAUnormSRGB:`bc7-rgba-unorm-srgb`,ETC2RGB8Unorm:`etc2-rgb8unorm`,ETC2RGB8UnormSRGB:`etc2-rgb8unorm-srgb`,ETC2RGB8A1Unorm:`etc2-rgb8a1unorm`,ETC2RGB8A1UnormSRGB:`etc2-rgb8a1unorm-srgb`,ETC2RGBA8Unorm:`etc2-rgba8unorm`,ETC2RGBA8UnormSRGB:`etc2-rgba8unorm-srgb`,EACR11Unorm:`eac-r11unorm`,EACR11Snorm:`eac-r11snorm`,EACRG11Unorm:`eac-rg11unorm`,EACRG11Snorm:`eac-rg11snorm`,ASTC4x4Unorm:`astc-4x4-unorm`,ASTC4x4UnormSRGB:`astc-4x4-unorm-srgb`,ASTC5x4Unorm:`astc-5x4-unorm`,ASTC5x4UnormSRGB:`astc-5x4-unorm-srgb`,ASTC5x5Unorm:`astc-5x5-unorm`,ASTC5x5UnormSRGB:`astc-5x5-unorm-srgb`,ASTC6x5Unorm:`astc-6x5-unorm`,ASTC6x5UnormSRGB:`astc-6x5-unorm-srgb`,ASTC6x6Unorm:`astc-6x6-unorm`,ASTC6x6UnormSRGB:`astc-6x6-unorm-srgb`,ASTC8x5Unorm:`astc-8x5-unorm`,ASTC8x5UnormSRGB:`astc-8x5-unorm-srgb`,ASTC8x6Unorm:`astc-8x6-unorm`,ASTC8x6UnormSRGB:`astc-8x6-unorm-srgb`,ASTC8x8Unorm:`astc-8x8-unorm`,ASTC8x8UnormSRGB:`astc-8x8-unorm-srgb`,ASTC10x5Unorm:`astc-10x5-unorm`,ASTC10x5UnormSRGB:`astc-10x5-unorm-srgb`,ASTC10x6Unorm:`astc-10x6-unorm`,ASTC10x6UnormSRGB:`astc-10x6-unorm-srgb`,ASTC10x8Unorm:`astc-10x8-unorm`,ASTC10x8UnormSRGB:`astc-10x8-unorm-srgb`,ASTC10x10Unorm:`astc-10x10-unorm`,ASTC10x10UnormSRGB:`astc-10x10-unorm-srgb`,ASTC12x10Unorm:`astc-12x10-unorm`,ASTC12x10UnormSRGB:`astc-12x10-unorm-srgb`,ASTC12x12Unorm:`astc-12x12-unorm`,ASTC12x12UnormSRGB:`astc-12x12-unorm-srgb`},YZ={ClampToEdge:`clamp-to-edge`,Repeat:`repeat`,MirrorRepeat:`mirror-repeat`},XZ={Linear:`linear`,Nearest:`nearest`},ZZ={Zero:`zero`,One:`one`,Src:`src`,OneMinusSrc:`one-minus-src`,SrcAlpha:`src-alpha`,OneMinusSrcAlpha:`one-minus-src-alpha`,Dst:`dst`,OneMinusDst:`one-minus-dst`,DstAlpha:`dst-alpha`,OneMinusDstAlpha:`one-minus-dst-alpha`,SrcAlphaSaturated:`src-alpha-saturated`,Constant:`constant`,OneMinusConstant:`one-minus-constant`},QZ={Add:`add`,Subtract:`subtract`,ReverseSubtract:`reverse-subtract`,Min:`min`,Max:`max`},$Z={None:0,All:15},eQ={Keep:`keep`,Zero:`zero`,Replace:`replace`,Invert:`invert`,IncrementClamp:`increment-clamp`,DecrementClamp:`decrement-clamp`,IncrementWrap:`increment-wrap`,DecrementWrap:`decrement-wrap`},tQ={Storage:`storage`,ReadOnlyStorage:`read-only-storage`},nQ={WriteOnly:`write-only`,ReadOnly:`read-only`,ReadWrite:`read-write`},rQ={NonFiltering:`non-filtering`,Comparison:`comparison`},iQ={Float:`float`,UnfilterableFloat:`unfilterable-float`,Depth:`depth`,SInt:`sint`,UInt:`uint`},aQ={TwoD:`2d`,ThreeD:`3d`},oQ={TwoD:`2d`,TwoDArray:`2d-array`,Cube:`cube`,ThreeD:`3d`},sQ={All:`all`},cQ={Vertex:`vertex`,Instance:`instance`},lQ={CoreFeaturesAndLimits:`core-features-and-limits`,DepthClipControl:`depth-clip-control`,Depth32FloatStencil8:`depth32float-stencil8`,TextureCompressionBC:`texture-compression-bc`,TextureCompressionBCSliced3D:`texture-compression-bc-sliced-3d`,TextureCompressionETC2:`texture-compression-etc2`,TextureCompressionASTC:`texture-compression-astc`,TextureCompressionASTCSliced3D:`texture-compression-astc-sliced-3d`,TimestampQuery:`timestamp-query`,IndirectFirstInstance:`indirect-first-instance`,ShaderF16:`shader-f16`,RG11B10UFloat:`rg11b10ufloat-renderable`,BGRA8UNormStorage:`bgra8unorm-storage`,Float32Filterable:`float32-filterable`,Float32Blendable:`float32-blendable`,ClipDistances:`clip-distances`,DualSourceBlending:`dual-source-blending`,Subgroups:`subgroups`,TextureFormatsTier1:`texture-formats-tier1`,TextureFormatsTier2:`texture-formats-tier2`},uQ={"texture-compression-s3tc":`texture-compression-bc`,"texture-compression-etc1":`texture-compression-etc2`},dQ=class extends iZ{constructor(e,t,n){super(e,t?t.value:null),this.textureNode=t,this.groupNode=n}update(){let{textureNode:e}=this;return this.texture===e.value?super.update():(this.texture=e.value,!0)}},fQ=class extends YX{constructor(e,t){super(e,t?t.array:null),this._attribute=t,this.isStorageBuffer=!0}get attribute(){return this._attribute}},pQ=0,mQ=class extends fQ{constructor(e,t){super(`StorageBuffer_`+ pQ++,e?e.value:null),this.nodeUniform=e,this.access=e?e.access:UD.READ_WRITE,this.groupNode=t}get attribute(){return this.nodeUniform.value}get buffer(){return this.nodeUniform.value.array}},hQ=[null],gQ=class{constructor(e){this.backend=e,this._preferredCanvasFormat=null}getCurrentDepthStencilFormat(e){let t;return e.depth&&(t=e.depthTexture===null?e.stencil?this.backend.renderer.reversedDepthBuffer===!0?Q.Depth32FloatStencil8:Q.Depth24PlusStencil8:this.backend.renderer.reversedDepthBuffer===!0?Q.Depth32Float:Q.Depth24Plus:this.getTextureFormatGPU(e.depthTexture)),t}getTextureFormatGPU(e){return this.backend.get(e).format}getTextureSampleData(e){let t;if(e.isFramebufferTexture)t=1;else if(e.isDepthTexture&&!e.renderTarget){let e=this.backend.renderer,n=e.getRenderTarget();t=n?n.samples:e.currentSamples}else e.renderTarget&&(t=e.renderTarget.samples);t=this.getSampleCount(t||1);let n=t>1&&e.renderTarget!==null&&e.isDepthTexture!==!0&&e.isFramebufferTexture!==!0;return{samples:t,primarySamples:n?1:t,isMSAA:n}}getCurrentColorFormat(e){let t;return t=e.textures===null?this.getPreferredCanvasFormat():this.getTextureFormatGPU(e.textures[0]),t}getCurrentColorFormats(e){return e.textures===null?[this.getPreferredCanvasFormat()]:e.textures.map(e=>this.getTextureFormatGPU(e))}getCurrentColorSpace(e){return e.textures===null?this.backend.renderer.outputColorSpace:e.textures[0].colorSpace}getPrimitiveTopology(e,t){if(e.isPoints)return VZ.PointList;if(e.isLineSegments||e.isMesh&&t.wireframe===!0)return VZ.LineList;if(e.isLine)return VZ.LineStrip;if(e.isMesh)return VZ.TriangleList}getSampleCount(e){return e>=4?4:1}getSampleCountRenderContext(e){return e.textures===null?this.getSampleCount(this.backend.renderer.currentSamples):this.getSampleCount(e.sampleCount)}getPreferredCanvasFormat(){let e=this.backend.parameters.outputType;if(e===void 0)return this._preferredCanvasFormat===null&&(this._preferredCanvasFormat=navigator.gpu.getPreferredCanvasFormat()),this._preferredCanvasFormat;if(e===1009)return Q.BGRA8Unorm;if(e===1016)return Q.RGBA16Float;throw Error(`THREE.WebGPUUtils: Unsupported output buffer type.`)}};function _Q(e,t){hQ[0]=t,e.queue.submit(hQ),hQ[0]=null}var vQ=class{constructor(){this.label=``,this.layout=null,this.entries=[]}reset(){this.label=``,this.layout=null,this.entries.length=0}},yQ=class{constructor(){this.label=``,this.size=0,this.usage=0,this.mappedAtCreation=!1}reset(){this.label=``,this.size=0,this.usage=0,this.mappedAtCreation=!1}},bQ=class{constructor(){this.label=``}reset(){this.label=``}},xQ=class{constructor(){this.label=``,this.colorFormats=null,this.depthStencilFormat=void 0,this.sampleCount=1,this.depthReadOnly=!1,this.stencilReadOnly=!1}reset(){this.label=``,this.colorFormats=null,this.depthStencilFormat=void 0,this.sampleCount=1,this.depthReadOnly=!1,this.stencilReadOnly=!1}},SQ=class{constructor(){this.view=null,this.depthSlice=void 0,this.resolveTarget=void 0,this.clearValue=void 0,this.loadOp=void 0,this.storeOp=void 0}reset(){this.view=null,this.depthSlice=void 0,this.resolveTarget=void 0,this.clearValue=void 0,this.loadOp=void 0,this.storeOp=void 0}},CQ=class{constructor(){this.label=``,this.colorAttachments=[],this.depthStencilAttachment=void 0,this.occlusionQuerySet=void 0,this.timestampWrites=void 0,this.maxDrawCount=5e7}reset(){this.label=``,this.colorAttachments.length=0,this.depthStencilAttachment=void 0,this.occlusionQuerySet=void 0,this.timestampWrites=void 0,this.maxDrawCount=5e7}},wQ=class{constructor(){this.label=``,this.layout=null,this.vertex=null,this.primitive={},this.depthStencil=void 0,this.multisample=new TQ,this.fragment=null}reset(){this.label=``,this.layout=null,this.vertex=null,this.primitive={},this.depthStencil=void 0,this.multisample.reset(),this.fragment=null}},TQ=class{constructor(){this.count=1,this.mask=4294967295,this.alphaToCoverageEnabled=!1}reset(){this.count=1,this.mask=4294967295,this.alphaToCoverageEnabled=!1}},EQ=class{constructor(){this.label=``,this.code=``,this.compilationHints=[]}reset(){this.label=``,this.code=``,this.compilationHints.length=0}},DQ=class{constructor(){this.label=``,this.size={width:0,height:1,depthOrArrayLayers:1},this.mipLevelCount=1,this.sampleCount=1,this.dimension=`2d`,this.format=void 0,this.usage=void 0,this.viewFormats=[],this.textureBindingViewDimension=void 0}reset(){this.label=``,this.size.width=0,this.size.height=1,this.size.depthOrArrayLayers=1,this.mipLevelCount=1,this.sampleCount=1,this.dimension=`2d`,this.format=void 0,this.usage=void 0,this.viewFormats.length=0,this.textureBindingViewDimension=void 0}},OQ=class{constructor(){this.label=``,this.format=void 0,this.dimension=void 0,this.usage=0,this.aspect=`all`,this.baseMipLevel=0,this.mipLevelCount=void 0,this.baseArrayLayer=0,this.arrayLayerCount=void 0,this.swizzle=`rgba`}reset(){this.label=``,this.format=void 0,this.dimension=void 0,this.usage=0,this.aspect=`all`,this.baseMipLevel=0,this.mipLevelCount=void 0,this.baseArrayLayer=0,this.arrayLayerCount=void 0,this.swizzle=`rgba`}},kQ=new vQ,AQ=new yQ,jQ=new bQ,MQ=new xQ,NQ=new CQ,PQ=new wQ,FQ=new SQ,IQ=new EQ,LQ=new DQ,RQ=new OQ,zQ=class extends VV{constructor(e){super(),this.device=e,this.mipmapSampler=e.createSampler({minFilter:XZ.Linear}),this.flipYSampler=e.createSampler({minFilter:XZ.Nearest}),AQ.size=4,AQ.usage=GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST,this.flipUniformBuffer=e.createBuffer(AQ),AQ.reset(),e.queue.writeBuffer(this.flipUniformBuffer,0,new Uint32Array([1])),AQ.size=4,AQ.usage=GPUBufferUsage.UNIFORM,this.noFlipUniformBuffer=e.createBuffer(AQ),AQ.reset(),this.transferPipelines={},IQ.label=`mipmap`,IQ.code=` struct VarysStruct { @builtin( position ) Position: vec4f, @location( 0 ) vTex : vec2f, @location( 1 ) @interpolate(flat, either) vBaseArrayLayer: u32, }; @group( 0 ) @binding ( 2 ) var flipY: u32; @vertex fn mainVS( @builtin( vertex_index ) vertexIndex : u32, @builtin( instance_index ) instanceIndex : u32 ) -> VarysStruct { var Varys : VarysStruct; var pos = array( vec2f( -1, -1 ), vec2f( -1, 3 ), vec2f( 3, -1 ), ); let p = pos[ vertexIndex ]; let mult = select( vec2f( 0.5, -0.5 ), vec2f( 0.5, 0.5 ), flipY != 0 ); Varys.vTex = p * mult + vec2f( 0.5 ); Varys.Position = vec4f( p, 0, 1 ); Varys.vBaseArrayLayer = instanceIndex; return Varys; } @group( 0 ) @binding( 0 ) var imgSampler : sampler; @group( 0 ) @binding( 1 ) var img2d : texture_2d; @fragment fn main_2d( Varys: VarysStruct ) -> @location( 0 ) vec4 { return textureSample( img2d, imgSampler, Varys.vTex ); } @group( 0 ) @binding( 1 ) var img2dArray : texture_2d_array; @fragment fn main_2d_array( Varys: VarysStruct ) -> @location( 0 ) vec4 { return textureSample( img2dArray, imgSampler, Varys.vTex, Varys.vBaseArrayLayer ); } const faceMat = array( mat3x3f( 0, 0, -2, 0, -2, 0, 1, 1, 1 ), // pos-x mat3x3f( 0, 0, 2, 0, -2, 0, -1, 1, -1 ), // neg-x mat3x3f( 2, 0, 0, 0, 0, 2, -1, 1, -1 ), // pos-y mat3x3f( 2, 0, 0, 0, 0, -2, -1, -1, 1 ), // neg-y mat3x3f( 2, 0, 0, 0, -2, 0, -1, 1, 1 ), // pos-z mat3x3f( -2, 0, 0, 0, -2, 0, 1, 1, -1 ), // neg-z ); @group( 0 ) @binding( 1 ) var imgCube : texture_cube; @fragment fn main_cube( Varys: VarysStruct ) -> @location( 0 ) vec4 { return textureSample( imgCube, imgSampler, faceMat[ Varys.vBaseArrayLayer ] * vec3f( fract( Varys.vTex ), 1 ) ); } `,this.mipmapShaderModule=e.createShaderModule(IQ),IQ.reset()}getTransferPipeline(e,t){t||=`2d-array`;let n=`${e}-${t}`,r=this.transferPipelines[n];return r===void 0&&(PQ.label=`mipmap-${e}-${t}`,PQ.vertex={module:this.mipmapShaderModule},PQ.fragment={module:this.mipmapShaderModule,entryPoint:`main_${t.replace(`-`,`_`)}`,targets:[{format:e}]},PQ.layout=`auto`,r=this.device.createRenderPipeline(PQ),PQ.reset(),this.transferPipelines[n]=r),r}flipY(e,t,n=0){let r=t.format,{width:i,height:a}=t.size;LQ.size.width=i,LQ.size.height=a,LQ.format=r,LQ.usage=GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.TEXTURE_BINDING;let o=this.device.createTexture(LQ);LQ.reset();let s=this.getTransferPipeline(r,e.textureBindingViewDimension),c=this.getTransferPipeline(r,o.textureBindingViewDimension),l=this.device.createCommandEncoder(jQ),u=(e,t,n,r,i,a)=>{let o=e.getBindGroupLayout(0);RQ.dimension=t.textureBindingViewDimension||`2d-array`,RQ.mipLevelCount=1;let s=t.createView(RQ);RQ.reset(),kQ.layout=o,kQ.entries.push({binding:0,resource:this.flipYSampler},{binding:1,resource:s},{binding:2,resource:{buffer:a?this.flipUniformBuffer:this.noFlipUniformBuffer}});let c=this.device.createBindGroup(kQ);kQ.reset(),RQ.dimension=`2d`,RQ.mipLevelCount=1,RQ.baseArrayLayer=i,RQ.arrayLayerCount=1;let u=r.createView(RQ);RQ.reset(),FQ.view=u,FQ.loadOp=GZ.Clear,FQ.storeOp=WZ.Store,NQ.colorAttachments.push(FQ);let d=l.beginRenderPass(NQ);NQ.reset(),FQ.reset(),d.setPipeline(e),d.setBindGroup(0,c),d.draw(3,1,0,n),d.end()};u(s,e,n,o,0,!1),u(c,o,0,e,n,!0),_Q(this.device,l.finish()),o.destroy()}generateMipmaps(e,t=null){let n=this.get(e),r=n.layers||this._mipmapCreateBundles(e),i=t;i===null&&(jQ.label=`mipmapEncoder`,i=this.device.createCommandEncoder(jQ),jQ.reset()),this._mipmapRunBundles(i,r),t===null&&_Q(this.device,i.finish()),n.layers=r}_mipmapCreateBundles(e){let t=e.textureBindingViewDimension||`2d-array`,n=this.getTransferPipeline(e.format,t),r=n.getBindGroupLayout(0),i=[];for(let a=1;a0)for(let t=0,a=r.length;t0){for(let r of e.layerUpdates)this._copyBufferToTexture(t.image,n.texture,i,r,e.flipY,r);e.clearLayerUpdates()}else for(let r=0;r0?(this._copyCompressedBufferToTexture(e.mipmaps,n.texture,i,e.layerUpdates),e.clearLayerUpdates()):this._copyCompressedBufferToTexture(e.mipmaps,n.texture,i);else if(e.isCubeTexture)this._copyCubeMapToTexture(e,n.texture,i);else if(e.isHTMLTexture){let t=this.backend.device,r=this.backend.renderer.domElement,a=e.image;if(typeof t.queue.copyElementImageToTexture!=`function`)return;if(!n.hasPaintCallback){n.hasPaintCallback=!0,r.requestPaint();return}let o=i.size.width,s=i.size.height;t.queue.copyElementImageToTexture.length===2?t.queue.copyElementImageToTexture({source:a},{destination:{texture:n.texture},width:o,height:s}):t.queue.copyElementImageToTexture(a,o,s,{texture:n.texture}),e.flipY&&this._flipY(n.texture,i)}else if(r.length>0)for(let t=0,a=r.length;t0?e.width:n.size.width,l=o>0?e.height:n.size.height;$Q.source=e,$Q.flipY=i,e$.texture=t,e$.mipLevel=o,e$.origin.z=r,e$.premultipliedAlpha=a,n$.width=c,n$.height=l;try{s.queue.copyExternalImageToTexture($Q,e$,n$)}catch{}finally{$Q.reset(),e$.reset(),n$.reset()}}_getPassUtils(){let e=this._passUtils;return e===null&&(this._passUtils=e=new zQ(this.backend.device)),e}_generateMipmaps(e,t=null){this._getPassUtils().generateMipmaps(e,t)}_flipY(e,t,n=0){this._getPassUtils().flipY(e,t,n)}_copyBufferToTexture(e,t,n,r,i,a=0,o=0){let s=this.backend.device,c=e.data,l=this._getBytesPerTexel(n.format),u=e.width*l;XQ.texture=t,XQ.mipLevel=o,XQ.origin.z=r,QQ.offset=e.width*e.height*l*a,QQ.bytesPerRow=u,n$.width=e.width,n$.height=e.height,s.queue.writeTexture(XQ,c,QQ,n$),XQ.reset(),QQ.reset(),n$.reset(),i===!0&&this._flipY(t,n,r)}_copyCompressedBufferToTexture(e,t,n,r=null){let i=this.backend.device,a=this._getBlockData(n.format),o=n.size.depthOrArrayLayers>1,s=r&&r.size>0?r:null;for(let r=0;r]*\s*([a-z_0-9]+(?:<[\s\S]+?>)?)/i,l$=/([a-z_0-9]+)\s*:\s*([a-z_0-9]+(?:<[\s\S]+?>)?)/gi,u$={f32:`float`,i32:`int`,u32:`uint`,bool:`bool`,"vec2":`vec2`,"vec2":`ivec2`,"vec2":`uvec2`,"vec2":`bvec2`,vec2f:`vec2`,vec2i:`ivec2`,vec2u:`uvec2`,vec2b:`bvec2`,"vec3":`vec3`,"vec3":`ivec3`,"vec3":`uvec3`,"vec3":`bvec3`,vec3f:`vec3`,vec3i:`ivec3`,vec3u:`uvec3`,vec3b:`bvec3`,"vec4":`vec4`,"vec4":`ivec4`,"vec4":`uvec4`,"vec4":`bvec4`,vec4f:`vec4`,vec4i:`ivec4`,vec4u:`uvec4`,vec4b:`bvec4`,"mat2x2":`mat2`,mat2x2f:`mat2`,"mat3x3":`mat3`,mat3x3f:`mat3`,"mat4x4":`mat4`,mat4x4f:`mat4`,sampler:`sampler`,texture_1d:`texture`,texture_2d:`texture`,texture_2d_array:`texture`,texture_multisampled_2d:`cubeTexture`,texture_depth_2d:`depthTexture`,texture_depth_2d_array:`depthTexture`,texture_depth_multisampled_2d:`depthTexture`,texture_depth_cube:`depthTexture`,texture_depth_cube_array:`depthTexture`,texture_3d:`texture3D`,texture_cube:`cubeTexture`,texture_cube_array:`cubeTexture`,texture_storage_1d:`storageTexture`,texture_storage_2d:`storageTexture`,texture_storage_2d_array:`storageTexture`,texture_storage_3d:`storageTexture`},d$=e=>{e=e.trim();let t=e.match(c$);if(t!==null&&t.length===4){let n=t[2],r=[],i=null;for(;(i=l$.exec(n))!==null;)r.push({name:i[1],type:i[2]});let a=[];for(let e=0;e `+this.outputType;return`fn ${e} ( ${this.inputsCode.trim()} ) ${t}`+this.blockCode}},p$=class extends rX{parseFunction(e){return new f$(e)}},m$={[UD.READ_ONLY]:`read`,[UD.WRITE_ONLY]:`write`,[UD.READ_WRITE]:`read_write`},h$={[A]:`repeat`,[j]:`clamp`,[M]:`mirror`},g$={vertex:HZ.VERTEX,fragment:HZ.FRAGMENT,compute:HZ.COMPUTE},_$={instance:!0,swizzleAssign:!1,storageBuffer:!0},v$={"^^":`tsl_xor`},y$={float:`f32`,int:`i32`,uint:`u32`,bool:`bool`,color:`vec3`,vec2:`vec2`,ivec2:`vec2`,uvec2:`vec2`,bvec2:`vec2`,vec3:`vec3`,ivec3:`vec3`,uvec3:`vec3`,bvec3:`vec3`,vec4:`vec4`,ivec4:`vec4`,uvec4:`vec4`,bvec4:`vec4`,mat2:`mat2x2`,mat3:`mat3x3`,mat4:`mat4x4`},b$={},x$={tsl_xor:new oG(`fn tsl_xor( a : bool, b : bool ) -> bool { return ( a || b ) && !( a && b ); }`),mod_float:new oG(`fn tsl_mod_float( x : f32, y : f32 ) -> f32 { return x - y * floor( x / y ); }`),mod_vec2:new oG(`fn tsl_mod_vec2( x : vec2f, y : vec2f ) -> vec2f { return x - y * floor( x / y ); }`),mod_vec3:new oG(`fn tsl_mod_vec3( x : vec3f, y : vec3f ) -> vec3f { return x - y * floor( x / y ); }`),mod_vec4:new oG(`fn tsl_mod_vec4( x : vec4f, y : vec4f ) -> vec4f { return x - y * floor( x / y ); }`),equals_bool:new oG(`fn tsl_equals_bool( a : bool, b : bool ) -> bool { return a == b; }`),equals_bvec2:new oG(`fn tsl_equals_bvec2( a : vec2f, b : vec2f ) -> vec2 { return vec2( a.x == b.x, a.y == b.y ); }`),equals_bvec3:new oG(`fn tsl_equals_bvec3( a : vec3f, b : vec3f ) -> vec3 { return vec3( a.x == b.x, a.y == b.y, a.z == b.z ); }`),equals_bvec4:new oG(`fn tsl_equals_bvec4( a : vec4f, b : vec4f ) -> vec4 { return vec4( a.x == b.x, a.y == b.y, a.z == b.z, a.w == b.w ); }`),repeatWrapping_float:new oG(`fn tsl_repeatWrapping_float( coord: f32 ) -> f32 { return fract( coord ); }`),mirrorWrapping_float:new oG(`fn tsl_mirrorWrapping_float( coord: f32 ) -> f32 { let mirrored = fract( coord * 0.5 ) * 2.0; return 1.0 - abs( 1.0 - mirrored ); }`),clampWrapping_float:new oG(`fn tsl_clampWrapping_float( coord: f32 ) -> f32 { return clamp( coord, 0.0, 1.0 ); }`),inverse_mat2:new oG(` fn tsl_inverse_mat2( m : mat2x2 ) -> mat2x2 { let det = m[ 0 ][ 0 ] * m[ 1 ][ 1 ] - m[ 0 ][ 1 ] * m[ 1 ][ 0 ]; return mat2x2( m[ 1 ][ 1 ], - m[ 0 ][ 1 ], - m[ 1 ][ 0 ], m[ 0 ][ 0 ] ) * ( 1.0 / det ); } `),inverse_mat3:new oG(` fn tsl_inverse_mat3( m : mat3x3 ) -> mat3x3 { let a00 = m[ 0 ][ 0 ]; let a01 = m[ 0 ][ 1 ]; let a02 = m[ 0 ][ 2 ]; let a10 = m[ 1 ][ 0 ]; let a11 = m[ 1 ][ 1 ]; let a12 = m[ 1 ][ 2 ]; let a20 = m[ 2 ][ 0 ]; let a21 = m[ 2 ][ 1 ]; let a22 = m[ 2 ][ 2 ]; let b01 = a22 * a11 - a12 * a21; let b11 = - a22 * a10 + a12 * a20; let b21 = a21 * a10 - a11 * a20; let det = a00 * b01 + a01 * b11 + a02 * b21; return mat3x3( b01, ( - a22 * a01 + a02 * a21 ), ( a12 * a01 - a02 * a11 ), b11, ( a22 * a00 - a02 * a20 ), ( - a12 * a00 + a02 * a10 ), b21, ( - a21 * a00 + a01 * a20 ), ( a11 * a00 - a01 * a10 ) ) * ( 1.0 / det ); } `),inverse_mat4:new oG(` fn tsl_inverse_mat4( m : mat4x4 ) -> mat4x4 { let a00 = m[ 0 ][ 0 ]; let a01 = m[ 0 ][ 1 ]; let a02 = m[ 0 ][ 2 ]; let a03 = m[ 0 ][ 3 ]; let a10 = m[ 1 ][ 0 ]; let a11 = m[ 1 ][ 1 ]; let a12 = m[ 1 ][ 2 ]; let a13 = m[ 1 ][ 3 ]; let a20 = m[ 2 ][ 0 ]; let a21 = m[ 2 ][ 1 ]; let a22 = m[ 2 ][ 2 ]; let a23 = m[ 2 ][ 3 ]; let a30 = m[ 3 ][ 0 ]; let a31 = m[ 3 ][ 1 ]; let a32 = m[ 3 ][ 2 ]; let a33 = m[ 3 ][ 3 ]; let b00 = a00 * a11 - a01 * a10; let b01 = a00 * a12 - a02 * a10; let b02 = a00 * a13 - a03 * a10; let b03 = a01 * a12 - a02 * a11; let b04 = a01 * a13 - a03 * a11; let b05 = a02 * a13 - a03 * a12; let b06 = a20 * a31 - a21 * a30; let b07 = a20 * a32 - a22 * a30; let b08 = a20 * a33 - a23 * a30; let b09 = a21 * a32 - a22 * a31; let b10 = a21 * a33 - a23 * a31; let b11 = a22 * a33 - a23 * a32; let det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06; return mat4x4( a11 * b11 - a12 * b10 + a13 * b09, a02 * b10 - a01 * b11 - a03 * b09, a31 * b05 - a32 * b04 + a33 * b03, a22 * b04 - a21 * b05 - a23 * b03, a12 * b08 - a10 * b11 - a13 * b07, a00 * b11 - a02 * b08 + a03 * b07, a32 * b02 - a30 * b05 - a33 * b01, a20 * b05 - a22 * b02 + a23 * b01, a10 * b10 - a11 * b08 + a13 * b06, a01 * b08 - a00 * b10 - a03 * b06, a30 * b04 - a31 * b02 + a33 * b00, a21 * b02 - a20 * b04 - a23 * b00, a11 * b07 - a10 * b09 - a12 * b06, a00 * b09 - a01 * b07 + a02 * b06, a31 * b01 - a30 * b03 - a32 * b00, a20 * b03 - a21 * b01 + a22 * b00 ) * ( 1.0 / det ); } `),biquadraticTexture:new oG(` fn tsl_biquadraticTexture( map : texture_2d, coord : vec2f, iRes : vec2u, level : u32 ) -> vec4f { let res = vec2f( iRes ); let uvScaled = coord * res; let uvWrapping = ( ( uvScaled % res ) + res ) % res; // https://www.shadertoy.com/view/WtyXRy let uv = uvWrapping - 0.5; let iuv = floor( uv ); let f = fract( uv ); let rg1 = textureLoad( map, vec2u( iuv + vec2( 0.5, 0.5 ) ) % iRes, level ); let rg2 = textureLoad( map, vec2u( iuv + vec2( 1.5, 0.5 ) ) % iRes, level ); let rg3 = textureLoad( map, vec2u( iuv + vec2( 0.5, 1.5 ) ) % iRes, level ); let rg4 = textureLoad( map, vec2u( iuv + vec2( 1.5, 1.5 ) ) % iRes, level ); return mix( mix( rg1, rg2, f.x ), mix( rg3, rg4, f.x ), f.y ); } `),biquadraticTextureArray:new oG(` fn tsl_biquadraticTexture_array( map : texture_2d_array, coord : vec2f, iRes : vec2u, layer : u32, level : u32 ) -> vec4f { let res = vec2f( iRes ); let uvScaled = coord * res; let uvWrapping = ( ( uvScaled % res ) + res ) % res; // https://www.shadertoy.com/view/WtyXRy let uv = uvWrapping - 0.5; let iuv = floor( uv ); let f = fract( uv ); let rg1 = textureLoad( map, vec2u( iuv + vec2( 0.5, 0.5 ) ) % iRes, layer, level ); let rg2 = textureLoad( map, vec2u( iuv + vec2( 1.5, 0.5 ) ) % iRes, layer, level ); let rg3 = textureLoad( map, vec2u( iuv + vec2( 0.5, 1.5 ) ) % iRes, layer, level ); let rg4 = textureLoad( map, vec2u( iuv + vec2( 1.5, 1.5 ) ) % iRes, layer, level ); return mix( mix( rg1, rg2, f.x ), mix( rg3, rg4, f.x ), f.y ); } `)},S$={dFdx:`dpdx`,dFdy:`- dpdy`,mod_float:`tsl_mod_float`,mod_vec2:`tsl_mod_vec2`,mod_vec3:`tsl_mod_vec3`,mod_vec4:`tsl_mod_vec4`,equals_bool:`tsl_equals_bool`,equals_bvec2:`tsl_equals_bvec2`,equals_bvec3:`tsl_equals_bvec3`,equals_bvec4:`tsl_equals_bvec4`,inverse_mat2:`tsl_inverse_mat2`,inverse_mat3:`tsl_inverse_mat3`,inverse_mat4:`tsl_inverse_mat4`,inversesqrt:`inverseSqrt`,bitcast:`bitcast`,floatpack_snorm_2x16:`pack2x16snorm`,floatpack_unorm_2x16:`pack2x16unorm`,floatpack_float16_2x16:`pack2x16float`,floatunpack_snorm_2x16:`unpack2x16snorm`,floatunpack_unorm_2x16:`unpack2x16unorm`,floatunpack_float16_2x16:`unpack2x16float`},C$=``;(typeof navigator<`u`&&/Firefox|Deno/g.test(navigator.userAgent))!==!0&&(C$+=`diagnostic( off, derivative_uniformity ); `);var w$=class extends HY{constructor(e,t){super(e,t,new p$),this.uniformGroups={},this.uniformGroupsBindings={},this.builtins={},this.directives={},this.scopedArrays=new Map,this.allowEarlyReturns=!0,this.allowGlobalVariables=!0}_generateTextureSample(e,t,n,r,i,a=this.shaderStage){return a===`fragment`?r?i?`textureSample( ${t}, ${t}_sampler, ${n}, ${r}, ${i} )`:`textureSample( ${t}, ${t}_sampler, ${n}, ${r} )`:i?`textureSample( ${t}, ${t}_sampler, ${n}, ${i} )`:`textureSample( ${t}, ${t}_sampler, ${n} )`:this.generateTextureSampleLevel(e,t,n,`0`,r)}generateTextureSampleLevel(e,t,n,r,i,a){return this.isUnfilterable(e)===!1?i?a?`textureSampleLevel( ${t}, ${t}_sampler, ${n}, ${i}, ${r}, ${a} )`:`textureSampleLevel( ${t}, ${t}_sampler, ${n}, ${i}, ${r} )`:a?`textureSampleLevel( ${t}, ${t}_sampler, ${n}, ${r}, ${a} )`:`textureSampleLevel( ${t}, ${t}_sampler, ${n}, ${r} )`:this.isFilteredTexture(e)?this.generateFilteredTexture(e,t,n,a,r,i):this.generateTextureLod(e,t,n,i,a,r)}generateWrapFunction(e){let t=`tsl_coord_${h$[e.wrapS]}S_${h$[e.wrapT]}T_${e.is3DTexture||e.isData3DTexture?`3d`:`2d`}`,n=b$[t];if(n===void 0){let r=[],i=e.is3DTexture||e.isData3DTexture?`vec3f`:`vec2f`,a=`fn ${t}( coord : ${i} ) -> ${i} {\n\n\treturn ${i}(\n`,o=(e,t)=>{e===1e3?(r.push(x$.repeatWrapping_float),a+=`\t\ttsl_repeatWrapping_float( coord.${t} )`):e===1001?(r.push(x$.clampWrapping_float),a+=`\t\ttsl_clampWrapping_float( coord.${t} )`):e===1002?(r.push(x$.mirrorWrapping_float),a+=`\t\ttsl_mirrorWrapping_float( coord.${t} )`):(a+=`\t\tcoord.${t}`,F(`WebGPURenderer: Unsupported texture wrap type "${e}" for vertex shader.`))};o(e.wrapS,`x`),a+=`, `,o(e.wrapT,`y`),(e.is3DTexture||e.isData3DTexture)&&(a+=`, `,o(e.wrapR,`z`)),a+=` ); } `,b$[t]=n=new oG(a,r)}return n.build(this),t}generateArrayDeclaration(e,t){return`array< ${this.getType(e)}, ${t} >`}generateTextureDimension(e,t,n){let r=this.getDataFromNode(e,this.shaderStage,this.cache);r.dimensionsSnippet===void 0&&(r.dimensionsSnippet={});let i=r.dimensionsSnippet[n];if(r.dimensionsSnippet[n]===void 0){let a,o,{primarySamples:s}=this.renderer.backend.utils.getTextureSampleData(e),c=s>1;o=e.is3DTexture||e.isData3DTexture?`vec3`:`vec2`,a=c||e.isStorageTexture?t:`${t}${n?`, u32( ${n} )`:``}`,i=new _M(new fN(`textureDimensions( ${a} )`,o)),r.dimensionsSnippet[n]=i,(e.isArrayTexture||e.isDataArrayTexture||e.is3DTexture||e.isData3DTexture)&&(r.arrayLayerCount=new _M(new fN(`textureNumLayers(${t})`,`u32`))),e.isTextureCube&&(r.cubeFaceCount=new _M(new fN(`6u`,`u32`)))}return i.build(this)}generateFilteredTexture(e,t,n,r,i=`0u`,a){let o=this.generateWrapFunction(e),s=this.generateTextureDimension(e,t,i);return r&&(n=`${n} + vec2(${r}) / ${s}`),a?(this._include(`biquadraticTextureArray`),`tsl_biquadraticTexture_array( ${t}, ${o}( ${n} ), ${s}, u32( ${a} ), u32( ${i} ) )`):(this._include(`biquadraticTexture`),`tsl_biquadraticTexture( ${t}, ${o}( ${n} ), ${s}, u32( ${i} ) )`)}generateTextureLod(e,t,n,r,i,a=`0u`){if(e.isCubeTexture===!0){i&&(n=`${n} + vec3(${i})`);let r=e.isDepthTexture?`u32`:`f32`;return`textureSampleLevel( ${t}, ${t}_sampler, ${n}, ${r}( ${a} ) )`}let o=this.generateWrapFunction(e),s=this.generateTextureDimension(e,t,a),c=e.is3DTexture||e.isData3DTexture?`vec3`:`vec2`,l=c===`vec3`?`vec3( 1, 1, 1 )`:`vec2( 1, 1 )`;i&&(n=`${n} + ${c}(${i}) / ${c}( ${s} )`);let u=`${c}( 0 )`,d=`${c}( ${s} - ${l} )`;return n=`${c}( clamp( floor( ${o}( ${n} ) * ${c}( ${s} ) ), ${u}, ${d} ) )`,this.generateTextureLoad(e,t,n,a,r,null)}generateStorageTextureLoad(e,t,n,r,i,a){a&&(n=`${n} + ${a}`);let o;return o=i?`textureLoad( ${t}, ${n}, ${i} )`:`textureLoad( ${t}, ${n} )`,o}generateTextureLoad(e,t,n,r,i,a){r===null&&(r=`0u`),a&&(n=`${n} + ${a}`);let o;return i?o=`textureLoad( ${t}, ${n}, ${i}, u32( ${r} ) )`:(o=`textureLoad( ${t}, ${n}, u32( ${r} ) )`,this.renderer.backend.compatibilityMode&&e.isDepthTexture&&(o+=`.x`)),o}generateTextureStore(e,t,n,r,i){let a;return a=r?`textureStore( ${t}, ${n}, ${r}, ${i} )`:`textureStore( ${t}, ${n}, ${i} )`,a}isSampleCompare(e){return e.isDepthTexture===!0&&e.compareFunction!==null&&this.renderer.hasCompatibility(Ft.TEXTURE_COMPARE)}isUnfilterable(e){return this.getComponentTypeFromTexture(e)!==`float`||!this.isAvailable(`float32Filterable`)&&e.type===1015||this.isSampleCompare(e)===!1&&e.minFilter===1003&&e.magFilter===1003||this.renderer.backend.utils.getTextureSampleData(e).primarySamples>1}generateTexture(e,t,n,r,i,a=this.shaderStage){let o=null;return o=this.isUnfilterable(e)?this.generateTextureLod(e,t,n,r,i,`0`,a):this._generateTextureSample(e,t,n,r,i,a),o}generateTextureGrad(e,t,n,r,i,a,o=this.shaderStage){if(o===`fragment`)return i?a?`textureSampleGrad( ${t}, ${t}_sampler, ${n}, ${i}, ${r[0]}, ${r[1]}, ${a} )`:`textureSampleGrad( ${t}, ${t}_sampler, ${n}, ${i}, ${r[0]}, ${r[1]} )`:a?`textureSampleGrad( ${t}, ${t}_sampler, ${n}, ${r[0]}, ${r[1]}, ${a} )`:`textureSampleGrad( ${t}, ${t}_sampler, ${n}, ${r[0]}, ${r[1]} )`;I(`WebGPURenderer: THREE.TextureNode.gradient() does not support ${o} shader.`)}generateTextureCompare(e,t,n,r,i,a,o=this.shaderStage){if(o===`fragment`)return e.isDepthTexture===!0&&e.isArrayTexture===!0?a?`textureSampleCompare( ${t}, ${t}_sampler, ${n}, ${i}, ${r}, ${a} )`:`textureSampleCompare( ${t}, ${t}_sampler, ${n}, ${i}, ${r} )`:a?`textureSampleCompare( ${t}, ${t}_sampler, ${n}, ${r}, ${a} )`:`textureSampleCompare( ${t}, ${t}_sampler, ${n}, ${r} )`;I(`WebGPURenderer: THREE.DepthTexture.compareFunction() does not support ${o} shader.`)}generateTextureGather(e,t,n,r,i,a){let o=e.isDepthTexture===!0?``:`${r}, `;return i?a?`textureGather( ${o}${t}, ${t}_sampler, ${n}, ${i}, ${a} )`:`textureGather( ${o}${t}, ${t}_sampler, ${n}, ${i} )`:a?`textureGather( ${o}${t}, ${t}_sampler, ${n}, ${a} )`:`textureGather( ${o}${t}, ${t}_sampler, ${n})`}generateTextureGatherCompare(e,t,n,r,i,a){return i?a?`textureGatherCompare( ${t}, ${t}_sampler, ${n}, ${i}, ${r}, ${a} )`:`textureGatherCompare( ${t}, ${t}_sampler, ${n}, ${i}, ${r})`:a?`textureGatherCompare( ${t}, ${t}_sampler, ${n}, ${r}, ${a} )`:`textureGatherCompare( ${t}, ${t}_sampler, ${n}, ${r})`}generateTextureLevel(e,t,n,r,i,a){return this.isUnfilterable(e)===!1?i?a?`textureSampleLevel( ${t}, ${t}_sampler, ${n}, ${i}, ${r}, ${a} )`:`textureSampleLevel( ${t}, ${t}_sampler, ${n}, ${i}, ${r} )`:a?`textureSampleLevel( ${t}, ${t}_sampler, ${n}, ${r}, ${a} )`:`textureSampleLevel( ${t}, ${t}_sampler, ${n}, ${r} )`:this.isFilteredTexture(e)?this.generateFilteredTexture(e,t,n,a,r,i):this.generateTextureLod(e,t,n,i,a,r)}generateTextureBias(e,t,n,r,i,a,o=this.shaderStage){if(o===`fragment`)return i?a?`textureSampleBias( ${t}, ${t}_sampler, ${n}, ${i}, ${r}, ${a} )`:`textureSampleBias( ${t}, ${t}_sampler, ${n}, ${i}, ${r} )`:a?`textureSampleBias( ${t}, ${t}_sampler, ${n}, ${r}, ${a} )`:`textureSampleBias( ${t}, ${t}_sampler, ${n}, ${r} )`;I(`WebGPURenderer: THREE.TextureNode.biasNode does not support ${o} shader.`)}getPropertyName(e,t=this.shaderStage){if(e.isNodeVarying===!0&&e.needsInterpolation===!0){if(t===`vertex`)return`varyings.${e.name}`}else if(e.isNodeUniform===!0){let t=e.name,n=e.type;return n===`texture`||n===`cubeTexture`||n===`cubeDepthTexture`||n===`storageTexture`||n===`texture3D`?t:n===`buffer`||n===`storageBuffer`||n===`indirectStorageBuffer`?this.isCustomStruct(e)?t:t+`.value`:e.groupNode.name+`.`+t}return super.getPropertyName(e)}getOutputStructName(){return`output`}getFunctionOperator(e){let t=v$[e];return t===void 0?null:(this._include(t),t)}getNodeAccess(e,t){return t===`compute`?e.access:e.isAtomic===!0?(F(`WebGPURenderer: Atomic operations are only supported in compute shaders.`),UD.READ_WRITE):UD.READ_ONLY}getStorageAccess(e,t){return m$[this.getNodeAccess(e,t)]}getUniformFromNode(e,t,n,r=null){let i=super.getUniformFromNode(e,t,n,r),a=this.getDataFromNode(e,n,this.globalCache);if(a.uniformGPU===void 0){let o,s=e.groupNode,c=s.name,l=this.getBindGroupArray(c,n);if(t===`texture`||t===`cubeTexture`||t===`cubeDepthTexture`||t===`storageTexture`||t===`texture3D`){let r=null,a=this.getNodeAccess(e,n);if(t===`texture`||t===`storageTexture`?r=e.value.is3DTexture===!0?new lZ(i.name,i.node,s,a):new sZ(i.name,i.node,s,a):t===`cubeTexture`||t===`cubeDepthTexture`?r=new cZ(i.name,i.node,s,a):t===`texture3D`&&(r=new lZ(i.name,i.node,s,a)),r.store=e.isStorageTextureNode===!0,r.mipLevel=r.store?e.mipLevel:0,r.setVisibility(g$[n]),e.value.isCubeTexture===!0||this.isUnfilterable(e.value)===!1&&r.store===!1||e.gatherNode!==null){let e=new dQ(`${i.name}_sampler`,i.node,s);e.setVisibility(g$[n]),l.push(e,r),o=[e,r]}else l.push(r),o=[r]}else if(t===`buffer`||t===`storageBuffer`||t===`indirectStorageBuffer`){let a=this.getSharedDataFromNode(e),c=a.buffer;c===void 0&&(c=new(t===`buffer`?QX:mQ)(e,s),a.buffer=c),c.setVisibility(c.getVisibility()|g$[n]),l.push(c),o=c,i.name=r||`NodeBuffer_`+i.id}else{let e=this.uniformGroups[c];e===void 0&&(e=new rZ(c,s),e.setVisibility(HZ.VERTEX|HZ.FRAGMENT|HZ.COMPUTE),this.uniformGroups[c]=e),l.indexOf(e)===-1&&l.push(e),o=this.getNodeUniform(i,t);let n=o.name;e.uniforms.some(e=>e.name===n)||e.addUniform(o)}a.uniformGPU=o}return i}getBuiltin(e,t,n,r=this.shaderStage){let i=this.builtins[r]||(this.builtins[r]=new Map);return i.has(e)===!1&&i.set(e,{name:e,property:t,type:n}),t}hasBuiltin(e,t=this.shaderStage){return this.builtins[t]!==void 0&&this.builtins[t].has(e)}getVertexIndex(){return this.shaderStage===`vertex`?this.getBuiltin(`vertex_index`,`vertexIndex`,`u32`,`attribute`):`vertexIndex`}buildFunctionCode(e){let t=e.layout,n=this.flowShaderNode(e),r=[];for(let e of t.inputs)r.push(e.name+` : `+this.getType(e.type));let i=`fn ${t.name}( ${r.join(`, `)} ) -> ${this.getType(t.type)} { ${n.vars} ${n.code} `;return n.result&&(i+=`\treturn ${n.result};\n`),i+=` } `,i}getInstanceIndex(){return this.shaderStage===`vertex`?this.getBuiltin(`instance_index`,`instanceIndex`,`u32`,`attribute`):`instanceIndex`}getInvocationLocalIndex(){return this.getBuiltin(`local_invocation_index`,`invocationLocalIndex`,`u32`,`attribute`)}getSubgroupSize(){return this.enableSubGroups(),this.getBuiltin(`subgroup_size`,`subgroupSize`,`u32`,`attribute`)}getInvocationSubgroupIndex(){return this.enableSubGroups(),this.getBuiltin(`subgroup_invocation_id`,`invocationSubgroupIndex`,`u32`,`attribute`)}getSubgroupIndex(){return this.enableSubGroups(),this.getBuiltin(`subgroup_id`,`subgroupIndex`,`u32`,`attribute`)}getDrawIndex(){return null}getFrontFacing(){return this.getBuiltin(`front_facing`,`isFront`,`bool`)}getFragCoord(){return this.getBuiltin(`position`,`fragCoord`,`vec4`)+`.xy`}getFragDepth(){return`output.`+this.getBuiltin(`frag_depth`,`depth`,`f32`,`output`)}getClipDistance(){return`varyings.hw_clip_distances`}isFlipY(){return!1}enableDirective(e,t=this.shaderStage){(this.directives[t]||(this.directives[t]=new Set)).add(e)}getDirectives(e){let t=[],n=this.directives[e];if(n!==void 0)for(let e of n)t.push(`enable ${e};`);return t.join(` `)}enableSubGroups(){this.enableDirective(`subgroups`)}enableSubgroupsF16(){this.enableDirective(`subgroups-f16`)}enableClipDistances(){this.enableDirective(`clip_distances`)}enableShaderF16(){this.enableDirective(`f16`)}enableDualSourceBlending(){this.enableDirective(`dual_source_blending`)}enableHardwareClipping(e){this.enableClipDistances(),this.getBuiltin(`clip_distances`,`hw_clip_distances`,`array`,`vertex`)}getBuiltins(e){let t=[],n=this.builtins[e];if(n!==void 0)for(let{name:e,property:r,type:i}of n.values())t.push(`@builtin( ${e} ) ${r} : ${i}`);return t.join(`, `)}getScopedArray(e,t,n,r){return this.scopedArrays.has(e)===!1&&this.scopedArrays.set(e,{name:e,scope:t,bufferType:n,bufferCount:r}),e}getScopedArrays(e){if(e!==`compute`)return;let t=[];for(let{name:e,scope:n,bufferType:r,bufferCount:i}of this.scopedArrays.values()){let a=this.getType(r);t.push(`var<${n}> ${e}: array< ${a}, ${i} >;`)}return t.join(` `)}getAttributes(e){let t=[];if(e===`compute`&&(this.getBuiltin(`global_invocation_id`,`globalId`,`vec3`,`attribute`),this.getBuiltin(`workgroup_id`,`workgroupId`,`vec3`,`attribute`),this.getBuiltin(`local_invocation_id`,`localId`,`vec3`,`attribute`),this.getBuiltin(`num_workgroups`,`numWorkgroups`,`vec3`,`attribute`),this.renderer.hasFeature(`subgroups`)&&(this.enableDirective(`subgroups`,e),this.getBuiltin(`subgroup_size`,`subgroupSize`,`u32`,`attribute`))),e===`vertex`||e===`compute`){let e=this.getBuiltins(`attribute`);e&&t.push(e);let n=this.getAttributesArray();for(let e=0,r=n.length;e`),t.push(`\t${r+n.name} : ${i}`)}return e.output&&t.push(`\t${this.getBuiltins(`output`)}`),t.join(`, `)}getStructs(e){let t=``,n=this.structs[e];if(n.length>0){let e=[];for(let t of n){let n=`struct ${t.name} {\n`;n+=this.getStructMembers(t),n+=` };`,e.push(n)}t=` `+e.join(` `)+` `}return t}getVar(e,t,n=null,r=``){let i=`var${r} ${t} : `;return n===null?i+=this.getType(e):i+=this.generateArrayDeclaration(e,n),i}getVars(e,t=!1){let n=``;t&&(n=``);let r=[],i=this.vars[e];if(i!==void 0)for(let e of i)r.push(`${this.getVar(e.type,e.name,e.count,n)};`);return t?r.join(` `):`\n\t${r.join(` `)}\n`}getVaryings(e){let t=[];if(e===`vertex`&&this.getBuiltin(`position`,`builtinClipSpace`,`vec4`,`vertex`),e===`vertex`||e===`fragment`){let n=this.varyings,r=this.vars[e],i=0;for(let a=0;an.value.itemSize;return r&&!i}getUniforms(e){let t=this.renderer.backend,n=this.uniforms[e],r=[],i=[],a=[],o={};for(let a of n){let n=a.groupNode.name,s=this.bindingsIndexes[n];if(a.type===`texture`||a.type===`cubeTexture`||a.type===`cubeDepthTexture`||a.type===`storageTexture`||a.type===`texture3D`){let n=a.node,i=n.value;(i.isCubeTexture===!0||this.isUnfilterable(i)===!1&&n.isStorageTextureNode!==!0||n.gatherNode!==null)&&(this.isSampleCompare(i)&&n.compareNode!==null?r.push(`@binding( ${s.binding++} ) @group( ${s.group} ) var ${a.name}_sampler : sampler_comparison;`):r.push(`@binding( ${s.binding++} ) @group( ${s.group} ) var ${a.name}_sampler : sampler;`));let o,c=``,{primarySamples:l}=t.utils.getTextureSampleData(i);if(l>1&&(c=`_multisampled`),i.isCubeTexture===!0&&i.isDepthTexture===!0)o=`texture_depth_cube`;else if(i.isCubeTexture===!0)o=`texture_cube`;else if(i.isDepthTexture===!0)o=t.compatibilityMode&&i.compareFunction===null?`texture${c}_2d`:`texture_depth${c}_2d${i.isArrayTexture===!0?`_array`:``}`;else if(a.node.isStorageTextureNode===!0){let n=s$(i,t.device),r=this.getStorageAccess(a.node,e),s=a.node.value.is3DTexture,c=a.node.value.isArrayTexture;o=`texture_storage_${s?`3d`:`2d${c?`_array`:``}`}<${n}, ${r}>`}else if(i.isArrayTexture===!0||i.isDataArrayTexture===!0||i.isCompressedArrayTexture===!0)o=`texture_2d_array`;else if(i.is3DTexture===!0||i.isData3DTexture===!0)o=`texture_3d`;else{let e=this.getComponentTypeFromTexture(i).charAt(0);o=`texture${c}_2d<${e}32>`}r.push(`@binding( ${s.binding++} ) @group( ${s.group} ) var ${a.name} : ${o};`)}else if(a.type===`buffer`||a.type===`storageBuffer`||a.type===`indirectStorageBuffer`){let t=a.node,n=this.getType(t.getNodeType(this)),r=t.bufferCount,o=r>0&&a.type===`buffer`?`, `+r:``,c=t.isStorageBufferNode?`storage, ${this.getStorageAccess(t,e)}`:`uniform`;if(this.isCustomStruct(a))i.push(`@binding( ${s.binding++} ) @group( ${s.group} ) var<${c}> ${a.name} : ${n};`);else{let e=`\tvalue : array< ${t.isAtomic?`atomic<${n}>`:`${n}`}${o} >`;i.push(this._getWGSLStructBinding(a.name,e,c,s.binding++,s.group))}}else{let e=a.groupNode.name;if(o[e]===void 0){let t=this.uniformGroups[e];if(t!==void 0){let n=[];for(let e of t.uniforms){let t=e.getType(),r=this.getType(this.getVectorType(t));n.push(`\t${e.name} : ${r}`)}let r=this.uniformGroupsBindings[e];r===void 0&&(r={index:s.binding++,id:s.group},this.uniformGroupsBindings[e]=r),o[e]={index:r.index,id:r.id,snippets:n}}}}}for(let e in o){let t=o[e];a.push(this._getWGSLStructBinding(e,t.snippets.join(`, `),`uniform`,t.index,t.id))}return[...r,...i,...a].join(` `)}buildCode(){let e=this.material===null?{compute:{}}:{fragment:{},vertex:{}};for(let t in this.sortBindingGroups(),e){this.shaderStage=t;let n=this.allowGlobalVariables,r=e[t];r.uniforms=this.getUniforms(t),r.attributes=this.getAttributes(t),r.varyings=this.getVaryings(t),r.structs=this.getStructs(t),r.vars=this.getVars(t,n),r.codes=this.getCodes(t),r.directives=this.getDirectives(t),r.scopedArrays=this.getScopedArrays(t);let i=`// code `;i+=this.flowCode[t];let a=this.flowNodes[t],o=a[a.length-1],s=o.outputNode,c=s!==void 0&&s.isOutputStructNode===!0;for(let e of a){let n=this.getFlowData(e),a=e.name;if(a&&(i.length>0&&(i+=` `),i+=`\t// flow -> ${a}\n`),i+=`${n.code}\n\t`,e===o&&t!==`compute`){if(i+=`// result `,t===`vertex`)i+=`varyings.builtinClipSpace = ${n.result};`;else if(t===`fragment`)if(c)r.returnType=s.getNodeType(this),r.structs+=`var output : `+r.returnType+`;`,i+=`return ${n.result};`;else{let e=`\t@location( 0 ) color: ${this.getType(this.getOutputType())}`,t=this.getBuiltins(`output`);t&&(e+=`, `+t),r.returnType=`OutputStruct`,r.structs+=this._getWGSLStruct(`OutputStruct`,e),r.structs+=` var output : OutputStruct;`,i+=`output.color = ${this.format(n.result,o.getNodeType(this),this.getOutputType())};\n\n\treturn output;`}}}r.flow=i}if(this.shaderStage=null,this.material!==null)this.vertexShader=this._getWGSLVertexCode(e.vertex),this.fragmentShader=this._getWGSLFragmentCode(e.fragment);else{let t=this.object.workgroupSize;this.computeShader=this._getWGSLComputeCode(e.compute,t)}}getMethod(e,t=null){let n;return t!==null&&(n=this._getWGSLMethod(e+`_`+t)),n===void 0&&(n=this._getWGSLMethod(e)),n||e}getBitcastMethod(e){return`bitcast<${this.getType(e)}>`}getFloatPackingMethod(e){return this.getMethod(`floatpack_${e}_2x16`)}getFloatUnpackingMethod(e){return this.getMethod(`floatunpack_${e}_2x16`)}getTernary(e,t,n){return`select( ${n}, ${t}, ${e} )`}getType(e){return y$[e]||e}isAvailable(e){let t=_$[e];return t===void 0&&(e===`float32Filterable`?t=this.renderer.hasFeature(`float32-filterable`):e===`clipDistance`&&(t=this.renderer.hasFeature(`clip-distances`)),_$[e]=t),t}_getWGSLMethod(e){return x$[e]!==void 0&&this._include(e),S$[e]}_include(e){let t=x$[e];return t.build(this),this.addInclude(t),t}_getWGSLVertexCode(e){return`${this.getSignature()} // directives ${e.directives} // structs ${e.structs} // uniforms ${e.uniforms} // varyings ${e.varyings} var varyings : VaryingsStruct; // vars ${e.vars} // codes ${e.codes} @vertex fn main( ${e.attributes} ) -> VaryingsStruct { // flow ${e.flow} return varyings; } `}_getWGSLFragmentCode(e){return`${this.getSignature()} // global ${C$} // structs ${e.structs} // uniforms ${e.uniforms} // vars ${e.vars} // codes ${e.codes} @fragment fn main( ${e.varyings} ) -> ${e.returnType} { // flow ${e.flow} } `}_getWGSLComputeCode(e,t){let[n,r,i]=t;return`${this.getSignature()} // directives ${e.directives} // system var instanceIndex : u32; // locals ${e.scopedArrays} // structs ${e.structs} // uniforms ${e.uniforms} // vars ${this.allowGlobalVariables?e.vars:``} // codes ${e.codes} @compute @workgroup_size( ${n}, ${r}, ${i} ) fn main( ${e.attributes} ) { // local vars ${this.allowGlobalVariables?``:e.vars} // system instanceIndex = globalId.x + globalId.y * ( ${n} * numWorkgroups.x ) + globalId.z * ( ${n} * numWorkgroups.x ) * ( ${r} * numWorkgroups.y ); // flow ${e.flow} } `}_getWGSLStruct(e,t){return` struct ${e} { ${t} };`}_getWGSLStructBinding(e,t,n,r=0,i=0){let a=e+`Struct`;return`${this._getWGSLStruct(a,t)} @binding( ${r} ) @group( ${i} ) var<${n}> ${e} : ${a};`}},T$=new yQ,E$=new bQ,D$=new Map([[Int8Array,[`sint8`,`snorm8`]],[Uint8Array,[`uint8`,`unorm8`]],[Int16Array,[`sint16`,`snorm16`]],[Uint16Array,[`uint16`,`unorm16`]],[Int32Array,[`sint32`,`snorm32`]],[Uint32Array,[`uint32`,`unorm32`]],[Float32Array,[`float32`]]]);typeof Float16Array<`u`&&D$.set(Float16Array,[`float16`]);var O$=new Map([[mi,[`float16`]]]),k$=new Map([[Int32Array,`sint32`],[Int16Array,`sint32`],[Uint32Array,`uint32`],[Uint16Array,`uint32`],[Float32Array,`float32`]]),A$=class{constructor(e){this.backend=e}createAttribute(e,t){let n=this._getBufferAttribute(e),r=this.backend,i=r.get(n),a=i.buffer;if(a===void 0){let o=r.device,s=n.array;if(e.normalized===!1){if(s.constructor===Int16Array||s.constructor===Int8Array)s=new Int32Array(s);else if((s.constructor===Uint16Array||s.constructor===Uint8Array)&&(s=new Uint32Array(s),t&GPUBufferUsage.INDEX))for(let e=0;e1&&n.itemSize*s.BYTES_PER_ELEMENT%4!=0){let e=n.itemSize*s.BYTES_PER_ELEMENT;c=Math.floor((e+3)/4)*4/s.BYTES_PER_ELEMENT}if(c!==void 0){let e=n.itemSize,t=new s.constructor(n.count*c);for(let r=0;r1&&e%4!=0&&(e=Math.floor((e+3)/4)*4)),r.normalized===!1&&(r.array.constructor===Int16Array||r.array.constructor===Uint16Array)&&(e=4),o={arrayStride:e,attributes:[],stepMode:t},n.set(a,o)}let s=this._getVertexFormat(r),c=r.isInterleavedBufferAttribute===!0?r.offset*i:0;o.attributes.push({shaderLocation:e,offset:c,format:s})}return Array.from(n.values())}destroyAttribute(e){let t=this.backend;t.get(this._getBufferAttribute(e)).buffer.destroy(),t.delete(e)}async getArrayBufferAsync(e,t=null,n=0,r=-1){let i=this.backend,a=i.device,o=i.get(this._getBufferAttribute(e)).buffer,s=r===-1?o.size-n:r,c;if(t!==null&&t.isReadbackBuffer){let e=i.get(t);if(t._mapped===!0)throw Error(`THREE.WebGPUAttributeUtils: ReadbackBuffer must be released before being used again.`);if(t._mapped=!0,e.readBufferGPU===void 0){T$.label=`${t.name}_readback`,T$.size=t.maxByteLength,T$.usage=GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ,c=a.createBuffer(T$),T$.reset();let n=()=>{t.buffer=null,t._mapped=!1,c.unmap()},r=()=>{t.buffer=null,t._mapped=!1,c.destroy(),i.delete(t),t.removeEventListener(`release`,n),t.removeEventListener(`dispose`,r)};t.addEventListener(`release`,n),t.addEventListener(`dispose`,r),e.readBufferGPU=c}else c=e.readBufferGPU}else T$.label=`${e.name}_readback`,T$.size=s,T$.usage=GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ,c=a.createBuffer(T$),T$.reset();E$.label=`readback_encoder_${e.name}`;let l=a.createCommandEncoder(E$);if(E$.reset(),l.copyBufferToBuffer(o,n,c,0,s),_Q(a,l.finish()),await c.mapAsync(GPUMapMode.READ,0,s),t===null){let e=c.getMappedRange(0,s).slice();return c.destroy(),e}else if(t.isReadbackBuffer)return t.buffer=c.getMappedRange(0,s),t;else{let e=c.getMappedRange(0,s);return new Uint8Array(t).set(new Uint8Array(e)),c.destroy(),t}}_getVertexFormat(e){let{itemSize:t,normalized:n}=e,r=e.array.constructor,i=e.constructor,a;if(t===1)a=k$.get(r);else{let e=(O$.get(i)||D$.get(r))[n?1:0];if(e){let n=r.BYTES_PER_ELEMENT*t,i=Math.floor((n+3)/4)*4/r.BYTES_PER_ELEMENT;if(i%1)throw Error(`THREE.WebGPUAttributeUtils: Bad vertex format item size.`);a=`${e}x${i}`}}return a||I(`WebGPUAttributeUtils: Vertex format not supported yet.`),a}_getBufferAttribute(e){return e.isInterleavedBufferAttribute&&(e=e.data),e}},j$=new vQ,M$=new yQ,N$=new OQ,P$=class{constructor(e){this.layoutGPU=e,this.usedTimes=0}},F$=class{constructor(e){this.backend=e,this._bindGroupLayoutCache=new Map}createBindingsLayout(e){let t=this.backend,n=t.device,r=t.get(e);if(r.layout)return r.layout.layoutGPU;let i=this._createLayoutEntries(e),a=TD(JSON.stringify(i)),o=this._bindGroupLayoutCache.get(a);return o===void 0&&(o=new P$(n.createBindGroupLayout({entries:i})),this._bindGroupLayoutCache.set(a,o)),o.usedTimes++,r.layout=o,r.layoutKey=a,o.layoutGPU}createBindings(e,t,n,r=0){let{backend:i}=this,a=i.get(e),o=this.createBindingsLayout(e),s;n>0&&(a.groups===void 0&&(a.groups=[],a.versions=[]),a.versions[n]===r&&(s=a.groups[n])),s===void 0&&(s=this.createBindGroup(e,o),n>0&&(a.groups[n]=s,a.versions[n]=r)),a.group=s}updateBinding(e){let t=this.backend,n=t.device,r=e.buffer,i=t.get(e).buffer,a=e.updateRanges;if(a.length===0)n.queue.writeBuffer(i,0,r,0);else{let e=Lt(r),t=e?1:r.BYTES_PER_ELEMENT,o=a[0].start;for(let s=0,c=a.length;s1&&(i+=`-${e.texture.depthOrArrayLayers}`),i+=`-${n}-${r}`,a=e[i],a===void 0){let o=sQ.All,s;s=t.isSampledCubeTexture?oQ.Cube:t.texture.isArrayTexture||t.texture.isDataArrayTexture||t.texture.isCompressedArrayTexture?oQ.TwoDArray:t.isSampledTexture3D?oQ.ThreeD:oQ.TwoD,N$.aspect=o,N$.dimension=s,N$.mipLevelCount=n,N$.baseMipLevel=r,a=e[i]=e.texture.createView(N$),N$.reset()}}j$.entries.push({binding:i,resource:a})}else if(t.isSampler){let e=n.get(t);j$.entries.push({binding:i,resource:e.sampler})}i++}let a=r.createBindGroup(j$);return j$.reset(),a}_createLayoutEntries(e){let t=[],n=0;for(let r of e.bindings){let e=this.backend,i={binding:n,visibility:r.visibility};if(r.isUniformBuffer||r.isStorageBuffer){let e={};r.isStorageBuffer&&(r.visibility&HZ.COMPUTE&&(r.access===UD.READ_WRITE||r.access===UD.WRITE_ONLY)?e.type=tQ.Storage:e.type=tQ.ReadOnlyStorage),i.buffer=e}else if(r.isSampledTexture&&r.store){let e={};e.format=this.backend.get(r.texture).texture.format;let t=r.access;t===UD.READ_WRITE?e.access=nQ.ReadWrite:t===UD.WRITE_ONLY?e.access=nQ.WriteOnly:e.access=nQ.ReadOnly,r.texture.isArrayTexture?e.viewDimension=oQ.TwoDArray:r.texture.is3DTexture&&(e.viewDimension=oQ.ThreeD),i.storageTexture=e}else if(r.isSampledTexture){let t={},{primarySamples:n}=e.utils.getTextureSampleData(r.texture);if(n>1&&(t.multisampled=!0,r.texture.isDepthTexture||(t.sampleType=iQ.UnfilterableFloat)),r.texture.isDepthTexture)e.compatibilityMode&&r.texture.compareFunction===null?t.sampleType=iQ.UnfilterableFloat:t.sampleType=iQ.Depth;else{let e=r.texture.type;e===1013?t.sampleType=iQ.SInt:e===1014?t.sampleType=iQ.UInt:e===1015&&(this.backend.hasFeature(`float32-filterable`)?t.sampleType=iQ.Float:t.sampleType=iQ.UnfilterableFloat)}r.isSampledCubeTexture?t.viewDimension=oQ.Cube:r.texture.isArrayTexture||r.texture.isDataArrayTexture||r.texture.isCompressedArrayTexture?t.viewDimension=oQ.TwoDArray:r.isSampledTexture3D&&(t.viewDimension=oQ.ThreeD),i.texture=t}else if(r.isSampler){let t={};r.texture.isDepthTexture&&(r.texture.compareFunction!==null&&r.textureNode.compareNode!==null&&e.hasCompatibility(Ft.TEXTURE_COMPARE)?t.type=rQ.Comparison:t.type=rQ.NonFiltering),i.sampler=t}else I(`WebGPUBindingUtils: Unsupported binding "${r}".`);t.push(i),n++}return t}deleteBindGroupData(e){let{backend:t}=this,n=t.get(e);n.layout&&(n.layout.usedTimes--,n.layout.usedTimes===0&&this._bindGroupLayoutCache.delete(n.layoutKey),n.layout=void 0,n.layoutKey=void 0)}dispose(){this._bindGroupLayoutCache.clear()}},I$=class{constructor(e){this.backend=e}getMaxAnisotropy(){return 16}getUniformBufferLimit(){return this.backend.device.limits.maxUniformBufferBindingSize}},L$=class{constructor(){this.label=``,this.layout=null,this.compute=null}reset(){this.label=``,this.layout=null,this.compute=null}},R$=class{constructor(){this.label=``,this.bindGroupLayouts=null}reset(){this.label=``,this.bindGroupLayouts=null}},z$=new L$,B$=new R$,V$=new xQ,H$=new wQ,U$=class{constructor(e){this.backend=e}_getSampleCount(e){return this.backend.utils.getSampleCountRenderContext(e)}createRenderPipeline(e,t){let{object:n,material:r,geometry:i,pipeline:a}=e,{vertexProgram:o,fragmentProgram:s}=a,c=this.backend,l=c.device,u=c.utils,d=c.get(a),f=[];for(let t of e.getBindings()){let{layoutGPU:e}=c.get(t).layout;f.push(e)}let p=c.attributeUtils.createShaderVertexBuffers(e),m;r.blending!==0&&(r.blending!==1||r.transparent!==!1)&&(m=this._getBlending(r));let h={};r.stencilWrite===!0&&(h={compare:this._getStencilCompare(r),failOp:this._getStencilOperation(r.stencilFail),depthFailOp:this._getStencilOperation(r.stencilZFail),passOp:this._getStencilOperation(r.stencilZPass)});let g=this._getColorWriteMask(r),_=[];if(e.context.textures!==null){let t=e.context.textures,n=e.context.mrt;for(let e=0;e1,H$.layout=w;let T={},E=e.context.depth,D=e.context.stencil;(E===!0||D===!0)&&(E===!0&&(T.format=S,T.depthWriteEnabled=r.depthWrite,T.depthCompare=x),D===!0&&(T.stencilFront=h,T.stencilBack=h,T.stencilReadMask=r.stencilFuncMask,T.stencilWriteMask=r.stencilWriteMask),r.polygonOffset===!0&&b.topology===VZ.TriangleList&&(T.depthBias=r.polygonOffsetUnits,T.depthBiasSlopeScale=r.polygonOffsetFactor,T.depthBiasClamp=0),H$.depthStencil=T),l.pushErrorScope(`validation`);let O=[{program:o,module:v.module},{program:s,module:y.module}],k=H$.label;if(t===null)d.pipeline=l.createRenderPipeline(H$),H$.reset(),l.popErrorScope().then(e=>{e!==null&&(d.error=!0,I(`WebGPURenderer: Render pipeline creation failed (${k}): ${e.message}`),this._reportShaderDiagnostics(O,k))});else{let e=new Promise(async e=>{try{let e=null,t=null;try{t=l.createRenderPipelineAsync(H$)}catch(t){e=t}if(H$.reset(),t!==null)try{d.pipeline=await t}catch(t){e=t}let n=await l.popErrorScope();(n!==null||e!==null)&&(d.error=!0,I(`WebGPURenderer: Async render pipeline creation failed (${k}): ${n&&n.message||e&&e.message||`unknown`}`),await this._reportShaderDiagnostics(O,k))}finally{e()}});t.push(e)}}createBundleEncoder(e,t=`renderBundleEncoder`){let{utils:n,device:r}=this.backend,i=n.getCurrentDepthStencilFormat(e),a=n.getCurrentColorFormats(e),o=this._getSampleCount(e);V$.label=t,V$.colorFormats=a,V$.depthStencilFormat=i,V$.sampleCount=o;let s=r.createRenderBundleEncoder(V$);return V$.reset(),s}createComputePipeline(e,t){let n=this.backend,r=n.device,i=n.get(e.computeProgram).module,a=n.get(e),o=[];for(let e of t){let{layoutGPU:t}=n.get(e).layout;o.push(t)}let s=e.computeProgram,c=`computePipeline_${s.stage}${s.name?`_${s.name}`:``}`;r.pushErrorScope(`validation`),B$.bindGroupLayouts=o;let l=r.createPipelineLayout(B$);B$.reset(),z$.label=c,z$.compute=i,z$.layout=l,a.pipeline=r.createComputePipeline(z$),z$.reset(),r.popErrorScope().then(e=>{e!==null&&(a.error=!0,I(`WebGPURenderer: Compute pipeline creation failed (${c}): ${e.message}`),this._reportShaderDiagnostics([{program:s,module:i.module}],c))})}async _reportShaderDiagnostics(e,t){for(let{program:n,module:r}of e){let e=await r.getCompilationInfo();if(e.messages.length===0)continue;let i=n.code.split(` `);for(let r of e.messages){let e=r.lineNum>0?` at line ${r.lineNum}${r.linePos>0?`:${r.linePos}`:``}`:``,a=`WebGPURenderer [${t} / ${n.stage} ${r.type}]${e}: ${r.message}`,o=``;r.lineNum>0&&r.lineNum<=i.length&&(o=`\n ${i[r.lineNum-1]}`,r.linePos>0&&(o+=`\n ${` `.repeat(r.linePos-1)}^`)),(r.type===`error`?I:F)(a+o)}}}_getBlending(e){let t,n,r=e.blending,i=e.blendSrc,a=e.blendDst,o=e.blendEquation;if(r===5){let r=e.blendSrcAlpha===null?i:e.blendSrcAlpha,s=e.blendDstAlpha===null?a:e.blendDstAlpha,c=e.blendEquationAlpha===null?o:e.blendEquationAlpha;t={srcFactor:this._getBlendFactor(i),dstFactor:this._getBlendFactor(a),operation:this._getBlendOperation(o)},n={srcFactor:this._getBlendFactor(r),dstFactor:this._getBlendFactor(s),operation:this._getBlendOperation(c)}}else{let i=e.premultipliedAlpha,a=(e,r,i,a)=>{t={srcFactor:e,dstFactor:r,operation:QZ.Add},n={srcFactor:i,dstFactor:a,operation:QZ.Add}};if(i)switch(r){case 1:a(ZZ.One,ZZ.OneMinusSrcAlpha,ZZ.One,ZZ.OneMinusSrcAlpha);break;case 2:a(ZZ.One,ZZ.One,ZZ.One,ZZ.One);break;case 3:a(ZZ.Zero,ZZ.OneMinusSrc,ZZ.Zero,ZZ.One);break;case 4:a(ZZ.Dst,ZZ.OneMinusSrcAlpha,ZZ.Zero,ZZ.One);break}else switch(r){case 1:a(ZZ.SrcAlpha,ZZ.OneMinusSrcAlpha,ZZ.One,ZZ.OneMinusSrcAlpha);break;case 2:a(ZZ.SrcAlpha,ZZ.One,ZZ.One,ZZ.One);break;case 3:I(`WebGPURenderer: "SubtractiveBlending" requires "${e.isMaterial?`material`:`blendMode`}.premultipliedAlpha = true".`);break;case 4:I(`WebGPURenderer: "MultiplyBlending" requires "${e.isMaterial?`material`:`blendMode`}.premultipliedAlpha = true".`);break}}if(t!==void 0&&n!==void 0)return{color:t,alpha:n};I(`WebGPURenderer: Invalid blending: `,r)}_getBlendFactor(e){let t;switch(e){case 200:t=ZZ.Zero;break;case 201:t=ZZ.One;break;case 202:t=ZZ.Src;break;case 203:t=ZZ.OneMinusSrc;break;case 204:t=ZZ.SrcAlpha;break;case 205:t=ZZ.OneMinusSrcAlpha;break;case 208:t=ZZ.Dst;break;case 209:t=ZZ.OneMinusDst;break;case 206:t=ZZ.DstAlpha;break;case 207:t=ZZ.OneMinusDstAlpha;break;case 210:t=ZZ.SrcAlphaSaturated;break;case WV:t=ZZ.Constant;break;case GV:t=ZZ.OneMinusConstant;break;default:I(`WebGPURenderer: Blend factor not supported.`,e)}return t}_getStencilCompare(e){let t,n=e.stencilFunc;switch(n){case 512:t=UZ.Never;break;case 519:t=UZ.Always;break;case 513:t=UZ.Less;break;case 515:t=UZ.LessEqual;break;case 514:t=UZ.Equal;break;case 518:t=UZ.GreaterEqual;break;case 516:t=UZ.Greater;break;case 517:t=UZ.NotEqual;break;default:I(`WebGPURenderer: Invalid stencil function.`,n)}return t}_getStencilOperation(e){let t;switch(e){case Ct:t=eQ.Keep;break;case 0:t=eQ.Zero;break;case wt:t=eQ.Replace;break;case kt:t=eQ.Invert;break;case Tt:t=eQ.IncrementClamp;break;case Et:t=eQ.DecrementClamp;break;case Dt:t=eQ.IncrementWrap;break;case Ot:t=eQ.DecrementWrap;break;default:I(`WebGPURenderer: Invalid stencil operation.`,t)}return t}_getBlendOperation(e){let t;switch(e){case 100:t=QZ.Add;break;case 101:t=QZ.Subtract;break;case 102:t=QZ.ReverseSubtract;break;case 103:t=QZ.Min;break;case 104:t=QZ.Max;break;default:I(`WebGPUPipelineUtils: Blend equation not supported.`,e)}return t}_getPrimitiveState(e,t,n){let r={};r.topology=this.backend.utils.getPrimitiveTopology(e,n),t.index!==null&&e.isLine===!0&&e.isLineSegments!==!0&&(r.stripIndexFormat=t.index.array instanceof Uint16Array?JZ.Uint16:JZ.Uint32);let i=n.side===1;return e.isMesh&&e.matrixWorld.determinantAffine()<0&&(i=!i),r.frontFace=i===!0?KZ.CW:KZ.CCW,r.cullMode=n.side===2?qZ.None:qZ.Back,r}_getColorWriteMask(e){return e.colorWrite===!0?$Z.All:$Z.None}_getDepthCompare(e){let t;if(e.depthTest===!1)t=UZ.Always;else{let n=this.backend.parameters.reversedDepthBuffer?qt[e.depthFunc]:e.depthFunc;switch(n){case 0:t=UZ.Never;break;case 1:t=UZ.Always;break;case 2:t=UZ.Less;break;case 3:t=UZ.LessEqual;break;case 4:t=UZ.Equal;break;case 5:t=UZ.GreaterEqual;break;case 6:t=UZ.Greater;break;case 7:t=UZ.NotEqual;break;default:I(`WebGPUPipelineUtils: Invalid depth function.`,n)}}return t}},W$=class{constructor(){this.label=``,this.type=void 0,this.count=0}reset(){this.label=``,this.type=void 0,this.count=0}},G$=new yQ,K$=new bQ,q$=new W$,J$=class extends RZ{constructor(e,t,n=2048){super(n),this.device=e,this.type=t,q$.label=`queryset_global_timestamp_${t}`,q$.type=`timestamp`,q$.count=this.maxQueries,this.querySet=this.device.createQuerySet(q$),q$.reset();let r=this.maxQueries*8;G$.label=`buffer_timestamp_resolve_${t}`,G$.size=r,G$.usage=GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC,this.resolveBuffer=this.device.createBuffer(G$),G$.reset(),G$.label=`buffer_timestamp_result_${t}`,G$.size=r,G$.usage=GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ,this.resultBuffer=this.device.createBuffer(G$),G$.reset()}allocateQueriesForContext(e){if(!this.trackTimestamp||this.isDisposed)return null;if(this.currentQueryIndex+2>this.maxQueries)return Wt(`WebGPUTimestampQueryPool [${this.type}]: Maximum number of queries exceeded, when using trackTimestamp it is necessary to resolves the queries via renderer.resolveTimestampsAsync( THREE.TimestampQuery.${this.type.toUpperCase()} ).`),null;let t=this.currentQueryIndex;return this.currentQueryIndex+=2,this.queryOffsets.set(e,t),t}async resolveQueriesAsync(){if(!this.trackTimestamp||this.currentQueryIndex===0||this.isDisposed)return this.lastValue;if(this.pendingResolve)return this.pendingResolve;this.pendingResolve=this._resolveQueries();try{return await this.pendingResolve}finally{this.pendingResolve=null}}async _resolveQueries(){if(this.isDisposed)return this.lastValue;try{if(this.resultBuffer.mapState!==`unmapped`)return this.lastValue;let e=new Map(this.queryOffsets),t=this.currentQueryIndex,n=t*8;this.currentQueryIndex=0,this.queryOffsets.clear();let r=this.device.createCommandEncoder(K$);r.resolveQuerySet(this.querySet,0,t,this.resolveBuffer,0),r.copyBufferToBuffer(this.resolveBuffer,0,this.resultBuffer,0,n);let i=r.finish();if(_Q(this.device,i),this.resultBuffer.mapState!==`unmapped`)return this.lastValue;if(await this.resultBuffer.mapAsync(GPUMapMode.READ,0,n),this.isDisposed)return this.resultBuffer.mapState===`mapped`&&this.resultBuffer.unmap(),this.lastValue;let a=new BigUint64Array(this.resultBuffer.getMappedRange(0,n)),o={},s=[];for(let[t,n]of e){let e=t.match(/^(.*):f(\d+)$/),r=parseInt(e[2]);s.includes(r)===!1&&s.push(r),o[r]===void 0&&(o[r]=0);let i=a[n],c=a[n+1],l=Number(c-i)/1e6;this.timestamps.set(t,l),o[r]+=l}let c=o[s[s.length-1]];return this.resultBuffer.unmap(),this.lastValue=c,this.frames=s,c}catch(e){return I(`Error resolving queries:`,e),this.resultBuffer.mapState===`mapped`&&this.resultBuffer.unmap(),this.lastValue}}async dispose(){if(!this.isDisposed){if(this.isDisposed=!0,this.pendingResolve)try{await this.pendingResolve}catch(e){I(`Error waiting for pending resolve:`,e)}if(this.resultBuffer&&this.resultBuffer.mapState===`mapped`)try{this.resultBuffer.unmap()}catch(e){I(`Error unmapping buffer:`,e)}this.querySet&&=(this.querySet.destroy(),null),this.resolveBuffer&&=(this.resolveBuffer.destroy(),null),this.resultBuffer&&=(this.resultBuffer.destroy(),null),this.queryOffsets.clear(),this.pendingResolve=null}}},Y$=class{constructor(){this.label=``,this.timestampWrites=void 0}reset(){this.label=``,this.timestampWrites=void 0}},X$=class{constructor(){this.view=null,this.depthLoadOp=void 0,this.depthStoreOp=void 0,this.depthClearValue=void 0,this.depthReadOnly=!1,this.stencilLoadOp=void 0,this.stencilStoreOp=void 0,this.stencilClearValue=0,this.stencilReadOnly=!1}reset(){this.view=null,this.depthLoadOp=void 0,this.depthStoreOp=void 0,this.depthClearValue=void 0,this.depthReadOnly=!1,this.stencilLoadOp=void 0,this.stencilStoreOp=void 0,this.stencilClearValue=0,this.stencilReadOnly=!1}},Z$=class{constructor(){this.querySet=null,this.beginningOfPassWriteIndex=void 0,this.endOfPassWriteIndex=void 0}reset(){this.querySet=null,this.beginningOfPassWriteIndex=void 0,this.endOfPassWriteIndex=void 0}},Q$={r:0,g:0,b:0,a:1},$$=new yQ,e1=new bQ,t1=new Y$,n1=new W$,r1=new EQ,i1=new Z$,a1=new VQ,o1=new VQ,s1=new OQ,c1=new KQ,l1=class extends bZ{constructor(e={}){super(e),this.isWebGPUBackend=!0,this.parameters.alpha=e.alpha===void 0?!0:e.alpha,this.parameters.requiredLimits=e.requiredLimits===void 0?{}:e.requiredLimits,this.compatibilityMode=null,this.device=null,this.defaultRenderPassdescriptor=null,this.utils=new gQ(this),this.attributeUtils=new A$(this),this.bindingUtils=new F$(this),this.capabilities=new I$(this),this.pipelineUtils=new U$(this),this.textureUtils=new o$(this),this.occludedResolveCache=new Map;let t=typeof navigator>`u`?!0:/Android/.test(navigator.userAgent)===!1;this._compatibility={[Ft.TEXTURE_COMPARE]:t}}async init(e){await super.init(e);let t=this.parameters,n;if(t.device===void 0){let r={powerPreference:t.powerPreference,featureLevel:`compatibility`,xrCompatible:e.xr.enabled},i=typeof navigator<`u`?await navigator.gpu.requestAdapter(r):null;if(i===null)throw Error(`THREE.WebGPUBackend: Unable to create WebGPU adapter.`);let a=Object.values(lQ),o=[];for(let e of a)i.features.has(e)&&o.push(e);let s={requiredFeatures:o,requiredLimits:t.requiredLimits};n=await i.requestDevice(s)}else n=t.device;this.compatibilityMode=!n.features.has(`core-features-and-limits`),this.compatibilityMode&&(e._samples=0),n.lost.then(t=>{if(t.reason===`destroyed`)return;let n={api:`WebGPU`,message:t.message||`Unknown reason`,reason:t.reason||null,originalEvent:t};e.onDeviceLost(n)}),n.onuncapturederror=t=>{let n=t.error,r=n&&n.constructor?n.constructor.name:`GPUError`,i=n&&n.message||`Unknown uncaptured GPU error`;e.onError({api:`WebGPU`,type:r,message:i,originalEvent:t})},this.device=n,this.trackTimestamp=this.trackTimestamp&&this.hasFeature(lQ.TimestampQuery),this.updateSize()}setXRRenderTargetTextures(e,t,n=null){this.set(e.texture,{texture:t,format:t.format,externalTexture:!0,xrViewDescriptors:n,initialized:!0})}get context(){let e=this.renderer.getCanvasTarget(),t=this.get(e),n=t.context;if(n===void 0){let r=this.parameters;n=e.isDefaultCanvasTarget===!0&&r.context!==void 0?r.context:e.domElement.getContext(`webgpu`),`setAttribute`in e.domElement&&e.domElement.setAttribute(`data-engine`,`three.js r185 webgpu`);let i=r.alpha?`premultiplied`:`opaque`,a=r.outputType===1016?`extended`:`standard`;n.configure({device:this.device,format:this.utils.getPreferredCanvasFormat(),usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC,alphaMode:i,toneMapping:{mode:a}}),t.context=n}return n}get coordinateSystem(){return Nt}get hasTimestamp(){return!0}async getArrayBufferAsync(e,t=null,n=0,r=-1){return await this.attributeUtils.getArrayBufferAsync(e,t,n,r)}getContext(){return this.context}_getDefaultRenderPassDescriptor(){let e=this.renderer,t=e.getCanvasTarget(),n=this.get(t),r=e.currentSamples,i=n.descriptor;if(i===void 0||n.samples!==r){if(i=new CQ,i.colorAttachments.push(new SQ),e.depth===!0||e.stencil===!0){let t=new X$;t.view=this.textureUtils.getDepthBuffer(e.depth,e.stencil).createView(),i.depthStencilAttachment=t}let t=i.colorAttachments[0];r>0?t.view=this.textureUtils.getColorBuffer().createView():t.resolveTarget=void 0,n.descriptor=i,n.samples=r}let a=i.colorAttachments[0];return r>0?a.resolveTarget=this.context.getCurrentTexture().createView():a.view=this.context.getCurrentTexture().createView(),i}_isRenderCameraDepthArray(e){let t=e.camera;return e.depthTexture&&e.depthTexture.isArrayTexture===!0&&t!==null&&t.isArrayCamera===!0}_hasExternalTexture(e){let t=e.textures;if(t===null)return!1;for(let e=0;e1)if(l===!0){let t=e.camera.cameras;for(let e=0;e0&&(t.currentOcclusionQuerySet&&t.currentOcclusionQuerySet.destroy(),t.currentOcclusionQueryBuffer&&t.currentOcclusionQueryBuffer.destroy(),t.currentOcclusionQuerySet=t.occlusionQuerySet,t.currentOcclusionQueryBuffer=t.occlusionQueryBuffer,t.currentOcclusionQueryObjects=t.occlusionQueryObjects,n1.label=`occlusionQuerySet_${e.id}`,n1.type=`occlusion`,n1.count=r,i=n.createQuerySet(n1),n1.reset(),t.occlusionQuerySet=i,t.occlusionQueryIndex=0,t.occlusionQueryObjects=Array(r),t.lastOcclusionObject=null);let a;a=e.textures===null?this._getDefaultRenderPassDescriptor():this._getRenderPassDescriptor(e,{loadOp:GZ.Load}),this.initTimestampQuery(Pt.RENDER,this.getTimestampUID(e),a),a.occlusionQuerySet=i;let o=a.depthStencilAttachment;if(e.textures!==null){let t=a.colorAttachments;for(let n=0;n0&&t.currentPass.executeBundles(t.renderBundles),n>t.occlusionQueryIndex&&t.currentPass.endOcclusionQuery();let r=t.encoder;if(this._isRenderCameraDepthArray(e)===!0){let n=[];for(let e=0;e0){let r=n*8,i=this.occludedResolveCache.get(r);i===void 0&&($$.size=r,$$.usage=GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC,i=this.device.createBuffer($$),$$.reset(),this.occludedResolveCache.set(r,i)),$$.size=r,$$.usage=GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ;let a=this.device.createBuffer($$);$$.reset(),t.encoder.resolveQuerySet(t.occlusionQuerySet,0,n,i,0),t.encoder.copyBufferToBuffer(i,0,a,0,r),t.occlusionQueryBuffer=a,this.resolveOccludedAsync(e)}if(_Q(this.device,t.encoder.finish()),e.textures!==null){let t=e.textures;for(let e=0;es&&(i[0]=Math.min(o,s),i[1]=Math.ceil(o/s)),a.dispatchSize=i}i=a.dispatchSize}s.dispatchWorkgroups(i[0],i[1]||1,i[2]||1)}finishCompute(e){let t=this.get(e);t.passEncoderGPU.end(),_Q(this.device,t.cmdEncoderGPU.finish())}_draw(e,t,n,r,i,a,o,s,c){let{object:l,material:u,context:d}=e,f=e.getIndex(),p=f!==null;c.pipeline!==r&&(s.setPipeline(r),c.pipeline=r);let m=c.bindingGroups;for(let e=0,t=i.length;e65535?4:2);for(let a=0;a0){let i=this.get(e.camera),o=e.camera.cameras,d=e.getBindingGroup(`cameraIndex`);if(i.indexesGPU===void 0||i.indexesGPU.length!==o.length){let e=this.get(d),t=[],n=new Uint32Array([0,0,0,0]);for(let r=0,i=o.length;r(F(`WebGPURenderer: WebGPU is not available, running under WebGL2 backend.`),new BZ(e)));let n=new t(e);super(n,e),this.library=new f1,this.isWebGPURenderer=!0,typeof __THREE_DEVTOOLS__<`u`&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent(`observe`,{detail:this}))}};Z.BRDF_GGX,Z.BRDF_Lambert,Z.BasicPointShadowFilter,Z.BasicShadowFilter,Z.Break,Z.Const,Z.Continue,Z.DFGLUT,Z.D_GGX,Z.Discard,Z.EPSILON,Z.F_Schlick;var m1=Z.Fn;Z.INFINITY;var h1=Z.If,g1=Z.Loop;Z.NodeAccess,Z.NodeShaderStage,Z.NodeType,Z.NodeUpdateType,Z.PCFShadowFilter,Z.PCFSoftShadowFilter,Z.PI,Z.PI2,Z.TWO_PI,Z.HALF_PI,Z.PointShadowFilter,Z.Return,Z.Schlick_to_F0,Z.ShaderNode,Z.Stack,Z.Switch,Z.TBNViewMatrix,Z.VSMShadowFilter,Z.V_GGX_SmithCorrelated,Z.Var,Z.VarIntent,Z.abs,Z.acesFilmicToneMapping,Z.acos,Z.acosh,Z.add,Z.addMethodChaining,Z.addNodeElement,Z.agxToneMapping,Z.all,Z.alphaT,Z.ambientOcclusion,Z.and,Z.anisotropy,Z.anisotropyB,Z.anisotropyT,Z.any,Z.append,Z.array;var _1=Z.asin;Z.asinh,Z.assign,Z.atan,Z.atanh,Z.atomicAdd,Z.atomicAnd,Z.atomicFunc,Z.atomicLoad,Z.atomicMax,Z.atomicMin,Z.atomicOr,Z.atomicStore,Z.atomicSub,Z.atomicXor,Z.attenuationColor,Z.attenuationDistance,Z.attribute,Z.attributeArray,Z.backgroundBlurriness,Z.backgroundIntensity,Z.backgroundRotation,Z.batch,Z.bentNormalView,Z.billboarding,Z.bitAnd,Z.bitNot,Z.bitOr,Z.bitXor,Z.bitangentGeometry,Z.bitangentLocal,Z.bitangentView,Z.bitangentWorld,Z.bitcast,Z.blendBurn,Z.blendColor,Z.blendDodge,Z.blendOverlay,Z.blendScreen,Z.blur,Z.bool,Z.buffer,Z.bufferAttribute,Z.bumpMap,Z.builtin,Z.builtinAOContext,Z.builtinShadowContext,Z.bvec2,Z.bvec3,Z.bvec4,Z.bypass,Z.cache,Z.call,Z.cameraFar,Z.cameraIndex,Z.cameraNear,Z.cameraNormalMatrix,Z.cameraPosition,Z.cameraProjectionMatrix,Z.cameraProjectionMatrixInverse,Z.cameraViewMatrix,Z.cameraViewport,Z.cameraWorldMatrix,Z.cbrt,Z.cdl,Z.ceil,Z.checker,Z.cineonToneMapping,Z.clamp,Z.clearcoat,Z.clearcoatNormalView,Z.clearcoatRoughness,Z.clipSpace,Z.code,Z.color,Z.colorSpaceToWorking,Z.colorToDirection,Z.compute,Z.computeKernel,Z.computeSkinning,Z.context,Z.convert,Z.convertColorSpace,Z.convertToTexture,Z.countLeadingZeros,Z.countOneBits,Z.countTrailingZeros;var v1=Z.cos;Z.cosh,Z.cross,Z.cubeTexture,Z.cubeTextureBase,Z.dFdx,Z.dFdy,Z.dashSize,Z.debug,Z.decrement,Z.decrementBefore,Z.defaultBuildStages,Z.defaultShaderStages,Z.defined,Z.degrees,Z.deltaTime,Z.densityFog,Z.densityFogFactor,Z.depth,Z.depthPass,Z.determinant,Z.difference,Z.diffuseColor,Z.directPointLight,Z.directionToColor,Z.directionToFaceDirection,Z.dispersion,Z.distance,Z.div,Z.dot,Z.drawIndex,Z.dynamicBufferAttribute,Z.element,Z.emissive,Z.equal,Z.equirectDirection,Z.equirectUV;var y1=Z.exp;Z.exp2,Z.exponentialHeightFogFactor,Z.expression,Z.faceDirection,Z.faceForward,Z.faceforward;var b1=Z.float;Z.floatBitsToInt,Z.floatBitsToUint,Z.floor,Z.fog,Z.fract,Z.frameGroup,Z.frameId,Z.frontFacing,Z.fwidth,Z.gain,Z.gapSize,Z.getConstNodeType,Z.getCurrentStack,Z.getDirection,Z.getDistanceAttenuation,Z.getGeometryRoughness,Z.getNormalFromDepth,Z.interleavedGradientNoise,Z.vogelDiskSample,Z.getParallaxCorrectNormal,Z.getRoughness,Z.getScreenPosition,Z.getShIrradianceAt,Z.getShadowMaterial,Z.getShadowRenderObjectFunction,Z.getTextureIndex,Z.getViewPosition,Z.globalId,Z.glsl,Z.glslFn,Z.grayscale,Z.greaterThan,Z.greaterThanEqual,Z.hash,Z.highpModelNormalViewMatrix,Z.highpModelViewMatrix,Z.hue,Z.increment,Z.incrementBefore,Z.instance;var x1=Z.instanceIndex;Z.instancedArray,Z.instancedBufferAttribute,Z.instancedDynamicBufferAttribute,Z.instancedMesh,Z.int,Z.intBitsToFloat,Z.inverse,Z.inverseSqrt,Z.inversesqrt,Z.invocationLocalIndex,Z.invocationSubgroupIndex,Z.ior,Z.iridescence,Z.iridescenceIOR,Z.iridescenceThickness,Z.ivec2,Z.ivec3,Z.ivec4,Z.js,Z.label,Z.length,Z.lengthSq,Z.lessThan,Z.lessThanEqual,Z.lightPosition,Z.lightProjectionUV,Z.lightShadowMatrix,Z.lightTargetDirection,Z.lightTargetPosition,Z.lightViewPosition,Z.lightingContext,Z.lights,Z.linearDepth,Z.linearToneMapping,Z.localId,Z.log,Z.log2,Z.logarithmicDepthToViewZ,Z.luminance,Z.mat2,Z.mat3,Z.mat4,Z.matcapUV,Z.materialAO,Z.materialAlphaTest,Z.materialAnisotropy,Z.materialAnisotropyVector,Z.materialAttenuationColor,Z.materialAttenuationDistance,Z.materialClearcoat,Z.materialClearcoatNormal,Z.materialClearcoatRoughness,Z.materialColor,Z.materialDispersion,Z.materialEmissive,Z.materialEnvIntensity,Z.materialEnvRotation,Z.materialIOR,Z.materialIridescence,Z.materialIridescenceIOR,Z.materialIridescenceThickness,Z.materialLightMap,Z.materialLineDashOffset,Z.materialLineDashSize,Z.materialLineGapSize,Z.materialLineScale,Z.materialLineWidth,Z.materialMetalness,Z.materialNormal,Z.materialOpacity,Z.materialPointSize,Z.materialReference,Z.materialReflectivity,Z.materialRefractionRatio,Z.materialRotation,Z.materialRoughness,Z.materialSheen,Z.materialSheenRoughness,Z.materialShininess,Z.materialSpecular,Z.materialSpecularColor,Z.materialSpecularIntensity,Z.materialSpecularStrength,Z.materialThickness,Z.materialTransmission,Z.max,Z.maxMipLevel,Z.mediumpModelViewMatrix,Z.metalness,Z.min,Z.mix,Z.mixElement,Z.mod,Z.modelDirection,Z.modelNormalMatrix,Z.modelPosition,Z.modelRadius,Z.modelScale,Z.modelViewMatrix,Z.modelViewPosition,Z.modelViewProjection,Z.modelWorldMatrix,Z.modelWorldMatrixInverse,Z.morphReference,Z.mrt,Z.mul,Z.mx_aastep,Z.mx_add,Z.mx_atan2,Z.mx_cell_noise_float,Z.mx_contrast,Z.mx_divide,Z.mx_fractal_noise_float,Z.mx_fractal_noise_vec2,Z.mx_fractal_noise_vec3,Z.mx_fractal_noise_vec4,Z.mx_frame,Z.mx_heighttonormal,Z.mx_hsvtorgb,Z.mx_ifequal,Z.mx_ifgreater,Z.mx_ifgreatereq,Z.mx_invert,Z.mx_modulo,Z.mx_multiply,Z.mx_noise_float,Z.mx_noise_vec3,Z.mx_noise_vec4,Z.mx_place2d,Z.mx_power,Z.mx_ramp4,Z.mx_ramplr,Z.mx_ramptb,Z.mx_rgbtohsv,Z.mx_rotate2d,Z.mx_rotate3d,Z.mx_safepower,Z.mx_separate,Z.mx_splitlr,Z.mx_splittb,Z.mx_srgb_texture_to_lin_rec709,Z.mx_subtract,Z.mx_timer,Z.mx_transform_uv,Z.mx_unifiednoise2d,Z.mx_unifiednoise3d,Z.mx_worley_noise_float,Z.mx_worley_noise_vec2,Z.mx_worley_noise_vec3;var S1=Z.negate;Z.negateOnBackSide,Z.neutralToneMapping,Z.nodeArray,Z.nodeImmutable,Z.nodeObject,Z.nodeObjectIntent,Z.nodeObjects,Z.nodeProxy,Z.nodeProxyIntent,Z.normalFlat,Z.normalGeometry,Z.normalLocal,Z.normalMap,Z.normalView,Z.normalViewGeometry,Z.normalWorld,Z.normalWorldGeometry,Z.normalize,Z.not,Z.notEqual,Z.numWorkgroups,Z.objectDirection,Z.objectGroup,Z.objectPosition,Z.objectRadius,Z.objectScale,Z.objectViewPosition,Z.objectWorldMatrix,Z.OnBeforeObjectUpdate,Z.OnBeforeMaterialUpdate,Z.OnObjectUpdate,Z.OnMaterialUpdate,Z.oneMinus,Z.or,Z.orthographicDepthToViewZ,Z.oscSawtooth,Z.oscSine,Z.oscSquare,Z.oscTriangle,Z.output,Z.outputStruct,Z.overloadingFn,Z.overrideNode,Z.overrideNodes,Z.packHalf2x16,Z.packSnorm2x16,Z.packUnorm2x16,Z.packNormalToRGB,Z.parabola,Z.parallaxDirection,Z.parallaxUV,Z.parameter,Z.pass,Z.passTexture,Z.pcurve,Z.perspectiveDepthToViewZ,Z.pmremTexture,Z.pointShadow,Z.pointUV,Z.pointWidth,Z.positionGeometry,Z.positionLocal,Z.positionPrevious,Z.positionView,Z.positionViewDirection,Z.positionWorld,Z.positionWorldDirection,Z.posterize,Z.pow,Z.pow2,Z.pow3,Z.pow4,Z.premultiplyAlpha,Z.property,Z.radians,Z.rand,Z.range,Z.rangeFog,Z.rangeFogFactor,Z.reciprocal,Z.reference,Z.referenceBuffer,Z.reflect,Z.reflectVector,Z.reflectView,Z.reflector,Z.refract,Z.refractVector,Z.refractView,Z.reinhardToneMapping,Z.remap,Z.remapClamp,Z.renderGroup,Z.renderOutput,Z.rendererReference,Z.replaceDefaultUV,Z.rotate,Z.rotateUV,Z.roughness,Z.round,Z.rtt,Z.sRGBTransferEOTF,Z.sRGBTransferOETF,Z.sample,Z.sampler,Z.samplerComparison,Z.saturate,Z.saturation,Z.screen,Z.screenCoordinate,Z.screenDPR,Z.screenSize,Z.screenUV,Z.select,Z.setCurrentStack,Z.setName,Z.shaderStages,Z.shadow,Z.shadowPositionWorld,Z.shapeCircle,Z.sharedUniformGroup,Z.sheen,Z.sheenRoughness,Z.shiftLeft,Z.shiftRight,Z.shininess,Z.sign;var C1=Z.sin;Z.sinh,Z.sinc,Z.skinning,Z.smoothstep,Z.smoothstepElement,Z.specularColor,Z.specularF90,Z.spherizeUV,Z.split,Z.spritesheetUV;var w1=Z.sqrt;Z.stack,Z.step,Z.stepElement;var T1=Z.storage;Z.storageBarrier,Z.storageTexture,Z.storageTexture3D,Z.struct,Z.sub,Z.subgroupAdd,Z.subgroupAll,Z.subgroupAnd,Z.subgroupAny,Z.subgroupBallot,Z.subgroupBroadcast,Z.subgroupBroadcastFirst,Z.subBuild,Z.subgroupElect,Z.subgroupExclusiveAdd,Z.subgroupExclusiveMul,Z.subgroupInclusiveAdd,Z.subgroupInclusiveMul,Z.subgroupIndex,Z.subgroupMax,Z.subgroupMin,Z.subgroupMul,Z.subgroupOr,Z.subgroupShuffle,Z.subgroupShuffleDown,Z.subgroupShuffleUp,Z.subgroupShuffleXor,Z.subgroupSize,Z.subgroupXor,Z.tan,Z.tanh,Z.tangentGeometry,Z.tangentLocal,Z.tangentView,Z.tangentWorld,Z.texture,Z.texture3D,Z.textureBarrier,Z.textureBicubic,Z.textureBicubicLevel,Z.textureCubeUV,Z.textureLoad,Z.textureSize,Z.textureLevel,Z.textureStore,Z.thickness,Z.time,Z.toneMapping,Z.toneMappingExposure,Z.toonOutlinePass,Z.transformDirection,Z.transformNormal,Z.transformNormalByInverseViewMatrix,Z.transformNormalByViewMatrix,Z.transformNormalToView,Z.transformedClearcoatNormalView,Z.transformedNormalView,Z.transformedNormalWorld,Z.transmission,Z.transpose,Z.triNoise3D,Z.triplanarTexture,Z.triplanarTextures,Z.trunc,Z.uint,Z.uintBitsToFloat;var E1=Z.uniform;Z.uniformArray,Z.uniformCubeTexture,Z.uniformGroup,Z.uniformFlow,Z.uniformTexture,Z.unpackHalf2x16,Z.unpackSnorm2x16,Z.unpackUnorm2x16,Z.unpackRGBToNormal,Z.unpremultiplyAlpha,Z.userData,Z.uv,Z.uvec2,Z.uvec3,Z.uvec4,Z.varying,Z.varyingProperty,Z.vec2,Z.vec3,Z.vec4,Z.vectorComponents,Z.velocity,Z.vertexColor,Z.vertexIndex,Z.vertexStage,Z.vibrance,Z.viewZToLogarithmicDepth,Z.viewZToOrthographicDepth,Z.viewZToPerspectiveDepth,Z.viewZToReversedOrthographicDepth,Z.viewZToReversedPerspectiveDepth,Z.viewport,Z.viewportCoordinate,Z.viewportDepthTexture,Z.viewportLinearDepth,Z.viewportMipTexture,Z.viewportOpaqueMipTexture,Z.viewportResolution,Z.viewportSafeUV,Z.viewportSharedTexture,Z.viewportSize,Z.viewportTexture,Z.viewportUV,Z.wgsl,Z.wgslFn,Z.workgroupArray,Z.workgroupBarrier,Z.workgroupId,Z.workingToColorSpace,Z.xor;var D1=new Ur,O1=new R,k1=class extends Tc{constructor(){super(),this.isLineSegmentsGeometry=!0,this.type=`LineSegmentsGeometry`,this.setIndex([0,2,1,2,3,1,2,4,3,4,5,3,4,6,5,6,7,5]),this.setAttribute(`position`,new hi([-1,2,0,1,2,0,-1,1,0,1,1,0,-1,0,0,1,0,0,-1,-1,0,1,-1,0],3)),this.setAttribute(`uv`,new hi([-1,2,1,2,-1,1,1,1,-1,-1,1,-1,-1,-2,1,-2],2))}applyMatrix4(e){let t=this.attributes.instanceStart,n=this.attributes.instanceEnd;return t!==void 0&&(t.applyMatrix4(e),n.applyMatrix4(e),t.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}setPositions(e){let t;e instanceof Float32Array?t=e:Array.isArray(e)&&(t=new Float32Array(e));let n=new Wc(t,6,1);return this.setAttribute(`instanceStart`,new Ai(n,3,0)),this.setAttribute(`instanceEnd`,new Ai(n,3,3)),this.instanceCount=this.attributes.instanceStart.count,this.computeBoundingBox(),this.computeBoundingSphere(),this}setColors(e){let t;e instanceof Float32Array?t=e:Array.isArray(e)&&(t=new Float32Array(e));let n=new Wc(t,6,1);return this.setAttribute(`instanceColorStart`,new Ai(n,3,0)),this.setAttribute(`instanceColorEnd`,new Ai(n,3,3)),this}fromWireframeGeometry(e){return this.setPositions(e.attributes.position.array),this}fromEdgesGeometry(e){return this.setPositions(e.attributes.position.array),this}fromMesh(e){return this.fromWireframeGeometry(new us(e.geometry)),this}fromLineSegments(e){let t=e.geometry;return this.setPositions(t.attributes.position.array),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Ur);let e=this.attributes.instanceStart,t=this.attributes.instanceEnd;e!==void 0&&t!==void 0&&(this.boundingBox.setFromBufferAttribute(e),D1.setFromBufferAttribute(t),this.boundingBox.union(D1))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new yi),this.boundingBox===null&&this.computeBoundingBox();let e=this.attributes.instanceStart,t=this.attributes.instanceEnd;if(e!==void 0&&t!==void 0){let n=this.boundingSphere.center;this.boundingBox.getCenter(n);let r=0;for(let i=0,a=e.count;i #include #include #include #include uniform float linewidth; uniform vec2 resolution; attribute vec3 instanceStart; attribute vec3 instanceEnd; attribute vec3 instanceColorStart; attribute vec3 instanceColorEnd; #ifdef WORLD_UNITS varying vec4 worldPos; varying vec3 worldStart; varying vec3 worldEnd; #ifdef USE_DASH varying vec2 vUv; #endif #else varying vec2 vUv; #endif #ifdef USE_DASH uniform float dashScale; attribute float instanceDistanceStart; attribute float instanceDistanceEnd; varying float vLineDistance; #endif float trimSegmentAlpha( const in vec4 start, const in vec4 end ) { // compute the interpolation factor needed to trim the segment so it terminates // between the camera plane and the near plane // conservative estimate of the near plane float a = projectionMatrix[ 2 ][ 2 ]; // 3nd entry in 3th column float b = projectionMatrix[ 3 ][ 2 ]; // 3nd entry in 4th column // we need different nearEstimate formula for reversed and default depth buffer // a is positive with a reversed depth buffer so it can be used for controlling the code flow float nearEstimate = ( a > 0.0 ) ? ( - b / ( a + 1.0 ) ) : ( - 0.5 * b / a ); return ( nearEstimate - start.z ) / ( end.z - start.z ); } void main() { #ifdef USE_COLOR vColor.xyz = ( position.y < 0.5 ) ? instanceColorStart : instanceColorEnd; #endif float aspect = resolution.x / resolution.y; // camera space vec4 start = modelViewMatrix * vec4( instanceStart, 1.0 ); vec4 end = modelViewMatrix * vec4( instanceEnd, 1.0 ); #ifdef USE_DASH float lineDistanceStart = dashScale * instanceDistanceStart; float lineDistanceEnd = dashScale * instanceDistanceEnd; #endif #ifdef WORLD_UNITS worldStart = start.xyz; worldEnd = end.xyz; #else vUv = uv; #endif // special case for perspective projection, and segments that terminate either in, or behind, the camera plane // clearly the gpu firmware has a way of addressing this issue when projecting into ndc space // but we need to perform ndc-space calculations in the shader, so we must address this issue directly // perhaps there is a more elegant solution -- WestLangley bool perspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 ); // 4th entry in the 3rd column if ( perspective ) { if ( start.z < 0.0 && end.z >= 0.0 ) { float alpha = trimSegmentAlpha( start, end ); end.xyz = mix( start.xyz, end.xyz, alpha ); #ifdef USE_DASH lineDistanceEnd = mix( lineDistanceStart, lineDistanceEnd, alpha ); #endif } else if ( end.z < 0.0 && start.z >= 0.0 ) { float alpha = trimSegmentAlpha( end, start ); start.xyz = mix( end.xyz, start.xyz, alpha ); #ifdef USE_DASH lineDistanceStart = mix( lineDistanceEnd, lineDistanceStart, alpha ); #endif } } #ifdef USE_DASH vLineDistance = ( position.y < 0.5 ) ? lineDistanceStart : lineDistanceEnd; vUv = uv; #endif // clip space vec4 clipStart = projectionMatrix * start; vec4 clipEnd = projectionMatrix * end; // ndc space vec3 ndcStart = clipStart.xyz / clipStart.w; vec3 ndcEnd = clipEnd.xyz / clipEnd.w; // direction vec2 dir = ndcEnd.xy - ndcStart.xy; // account for clip-space aspect ratio dir.x *= aspect; dir = normalize( dir ); #ifdef WORLD_UNITS vec3 worldDir = normalize( end.xyz - start.xyz ); vec3 tmpFwd = normalize( mix( start.xyz, end.xyz, 0.5 ) ); vec3 worldUp = normalize( cross( worldDir, tmpFwd ) ); vec3 worldFwd = cross( worldDir, worldUp ); worldPos = position.y < 0.5 ? start: end; // height offset float hw = linewidth * 0.5; worldPos.xyz += position.x < 0.0 ? hw * worldUp : - hw * worldUp; // don't extend the line if we're rendering dashes because we // won't be rendering the endcaps #ifndef USE_DASH // cap extension worldPos.xyz += position.y < 0.5 ? - hw * worldDir : hw * worldDir; // add width to the box worldPos.xyz += worldFwd * hw; // endcaps if ( position.y > 1.0 || position.y < 0.0 ) { worldPos.xyz -= worldFwd * 2.0 * hw; } #endif // project the worldpos vec4 clip = projectionMatrix * worldPos; // shift the depth of the projected points so the line // segments overlap neatly vec3 clipPose = ( position.y < 0.5 ) ? ndcStart : ndcEnd; clip.z = clipPose.z * clip.w; #else vec2 offset = vec2( dir.y, - dir.x ); // undo aspect ratio adjustment dir.x /= aspect; offset.x /= aspect; // sign flip if ( position.x < 0.0 ) offset *= - 1.0; // endcaps if ( position.y < 0.0 ) { offset += - dir; } else if ( position.y > 1.0 ) { offset += dir; } // adjust for linewidth offset *= linewidth; // adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ... offset /= resolution.y; // select end vec4 clip = ( position.y < 0.5 ) ? clipStart : clipEnd; // back to clip space offset *= clip.w; clip.xy += offset; #endif gl_Position = clip; vec4 mvPosition = ( position.y < 0.5 ) ? start : end; // this is an approximation #include #include #include } `,fragmentShader:` uniform vec3 diffuse; uniform float opacity; uniform float linewidth; #ifdef USE_DASH uniform float dashOffset; uniform float dashSize; uniform float gapSize; #endif varying float vLineDistance; #ifdef WORLD_UNITS varying vec4 worldPos; varying vec3 worldStart; varying vec3 worldEnd; #ifdef USE_DASH varying vec2 vUv; #endif #else varying vec2 vUv; #endif #include #include #include #include #include vec2 closestLineToLine(vec3 p1, vec3 p2, vec3 p3, vec3 p4) { float mua; float mub; vec3 p13 = p1 - p3; vec3 p43 = p4 - p3; vec3 p21 = p2 - p1; float d1343 = dot( p13, p43 ); float d4321 = dot( p43, p21 ); float d1321 = dot( p13, p21 ); float d4343 = dot( p43, p43 ); float d2121 = dot( p21, p21 ); float denom = d2121 * d4343 - d4321 * d4321; float numer = d1343 * d4321 - d1321 * d4343; mua = numer / denom; mua = clamp( mua, 0.0, 1.0 ); mub = ( d1343 + d4321 * ( mua ) ) / d4343; mub = clamp( mub, 0.0, 1.0 ); return vec2( mua, mub ); } void main() { float alpha = opacity; vec4 diffuseColor = vec4( diffuse, alpha ); #include #ifdef USE_DASH if ( vUv.y < - 1.0 || vUv.y > 1.0 ) discard; // discard endcaps if ( mod( vLineDistance + dashOffset, dashSize + gapSize ) > dashSize ) discard; // todo - FIX #endif #ifdef WORLD_UNITS // Find the closest points on the view ray and the line segment vec3 rayEnd = normalize( worldPos.xyz ) * 1e5; vec3 lineDir = worldEnd - worldStart; vec2 params = closestLineToLine( worldStart, worldEnd, vec3( 0.0, 0.0, 0.0 ), rayEnd ); vec3 p1 = worldStart + lineDir * params.x; vec3 p2 = rayEnd * params.y; vec3 delta = p1 - p2; float len = length( delta ); float norm = len / linewidth; #ifndef USE_DASH #ifdef USE_ALPHA_TO_COVERAGE float dnorm = fwidth( norm ); alpha = 1.0 - smoothstep( 0.5 - dnorm, 0.5 + dnorm, norm ); #else if ( norm > 0.5 ) { discard; } #endif #endif #else #ifdef USE_ALPHA_TO_COVERAGE // artifacts appear on some hardware if a derivative is taken within a conditional float a = vUv.x; float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0; float len2 = a * a + b * b; float dlen = fwidth( len2 ); if ( abs( vUv.y ) > 1.0 ) { alpha = 1.0 - smoothstep( 1.0 - dlen, 1.0 + dlen, len2 ); } #else if ( abs( vUv.y ) > 1.0 ) { float a = vUv.x; float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0; float len2 = a * a + b * b; if ( len2 > 1.0 ) discard; } #endif #endif #include #include gl_FragColor = vec4( diffuseColor.rgb, alpha ); #include #include #include #include } `};var A1=class extends xs{constructor(e){super({type:`LineMaterial`,uniforms:vs.clone(hl.line.uniforms),vertexShader:hl.line.vertexShader,fragmentShader:hl.line.fragmentShader,clipping:!0}),this.isLineMaterial=!0,this.setValues(e)}get color(){return this.uniforms.diffuse.value}set color(e){this.uniforms.diffuse.value=e}get worldUnits(){return`WORLD_UNITS`in this.defines}set worldUnits(e){e===!0!==this.worldUnits&&(this.needsUpdate=!0),e===!0?this.defines.WORLD_UNITS=``:delete this.defines.WORLD_UNITS}get linewidth(){return this.uniforms.linewidth.value}set linewidth(e){this.uniforms.linewidth&&(this.uniforms.linewidth.value=e)}get dashed(){return`USE_DASH`in this.defines}set dashed(e){e===!0!==this.dashed&&(this.needsUpdate=!0),e===!0?this.defines.USE_DASH=``:delete this.defines.USE_DASH}get dashScale(){return this.uniforms.dashScale.value}set dashScale(e){this.uniforms.dashScale.value=e}get dashSize(){return this.uniforms.dashSize.value}set dashSize(e){this.uniforms.dashSize.value=e}get dashOffset(){return this.uniforms.dashOffset.value}set dashOffset(e){this.uniforms.dashOffset.value=e}get gapSize(){return this.uniforms.gapSize.value}set gapSize(e){this.uniforms.gapSize.value=e}get opacity(){return this.uniforms.opacity.value}set opacity(e){this.uniforms&&(this.uniforms.opacity.value=e)}get resolution(){return this.uniforms.resolution.value}set resolution(e){this.uniforms.resolution.value.copy(e)}get alphaToCoverage(){return`USE_ALPHA_TO_COVERAGE`in this.defines}set alphaToCoverage(e){this.defines&&(e===!0!==this.alphaToCoverage&&(this.needsUpdate=!0),e===!0?this.defines.USE_ALPHA_TO_COVERAGE=``:delete this.defines.USE_ALPHA_TO_COVERAGE)}},j1=new Hn,M1=new R,N1=new R,P1=new Hn,F1=new Hn,I1=new Hn,L1=new R,R1=new qn,z1=new ol,B1=new R,V1=new Ur,H1=new yi,U1=new Hn,W1,G1;function K1(e,t,n){return U1.set(0,0,-t,1).applyMatrix4(e.projectionMatrix),U1.multiplyScalar(1/U1.w),U1.x=G1/n.width,U1.y=G1/n.height,U1.applyMatrix4(e.projectionMatrixInverse),U1.multiplyScalar(1/U1.w),Math.abs(Math.max(U1.x,U1.y))}function q1(e,t){let n=e.matrixWorld,r=e.geometry,i=r.attributes.instanceStart,a=r.attributes.instanceEnd,o=Math.min(r.instanceCount,i.count);for(let r=0,s=o;ru&&F1.z>u)continue;if(P1.z>u){let e=P1.z-F1.z,t=(P1.z-u)/e;P1.lerp(F1,t)}else if(F1.z>u){let e=F1.z-P1.z,t=(F1.z-u)/e;F1.lerp(P1,t)}P1.applyMatrix4(r),F1.applyMatrix4(r),P1.multiplyScalar(1/P1.w),F1.multiplyScalar(1/F1.w),P1.x*=i.x/2,P1.y*=i.y/2,F1.x*=i.x/2,F1.y*=i.y/2,z1.start.copy(P1),z1.start.z=0,z1.end.copy(F1),z1.end.z=0;let o=z1.closestPointToPointParameter(L1,!0);z1.at(o,B1);let l=Sn.lerp(P1.z,F1.z,o),d=l>=-1&&l<=1,f=L1.distanceTo(B1)e.length)&&(t=e.length);for(var n=0,r=Array(t);n3?(i=m===r)&&(c=a[(s=a[4])?5:(s=3,3)],a[4]=a[5]=e):a[0]<=p&&((i=n<2&&pr||r>m)&&(a[4]=n,a[5]=r,f.n=m,s=0))}if(i||n>1)return o;throw d=!0,r}return function(i,u,m){if(l>1)throw TypeError(`Generator is already running`);for(d&&u===1&&p(u,m),s=u,c=m;(t=s<2?e:c)||!d;){a||(s?s<3?(s>1&&(f.n=-1),p(s,c)):f.n=c:f.v=c);try{if(l=2,a){if(s||(i=`next`),t=a[i]){if(!(t=t.call(a,c)))throw TypeError(`iterator result is not an object`);if(!t.done)return t;c=t.value,s<2&&(s=0)}else s===1&&(t=a.return)&&t.call(a),s<2&&(c=TypeError(`The iterator does not provide a '`+i+`' method`),s=1);a=e}else if((t=(d=f.n<0)?c:n.call(r,f))!==o)break}catch(t){a=e,s=1,c=t}finally{l=1}}return{value:t,done:d}}}(n,i,a),!0),l}var o={};function s(){}function c(){}function l(){}t=Object.getPrototypeOf;var u=[][r]?t(t([][r]())):(N0(t={},r,function(){return this}),t),d=l.prototype=s.prototype=Object.create(u);function f(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,l):(e.__proto__=l,N0(e,i,`GeneratorFunction`)),e.prototype=Object.create(d),e}return c.prototype=l,N0(d,`constructor`,l),N0(l,`constructor`,c),c.displayName=`GeneratorFunction`,N0(l,i,`GeneratorFunction`),N0(d),N0(d,i,`Generator`),N0(d,r,function(){return this}),N0(d,`toString`,function(){return`[object Generator]`}),(M0=function(){return{w:a,m:f}})()}function N0(e,t,n,r){var i=Object.defineProperty;try{i({},``,{})}catch{i=0}N0=function(e,t,n,r){function a(t,n){N0(e,t,function(e){return this._invoke(t,n,e)})}t?i?i(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(a(`next`,0),a(`throw`,1),a(`return`,2))},N0(e,t,n,r)}function P0(e,t){return P0=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},P0(e,t)}function F0(e,t){return r0(e)||w0(e,t)||V0(e,t)||T0()}function I0(e,t){for(;!{}.hasOwnProperty.call(e,t)&&(e=b0(e))!==null;);return e}function L0(e,t,n,r){var i=y0(b0(e.prototype),t,n);return typeof i==`function`?function(e){return i.apply(n,e)}:i}function R0(e){return i0(e)||C0(e)||V0(e)||E0()}function z0(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function B0(e){var t=z0(e,`string`);return typeof t==`symbol`?t:t+``}function V0(e,t){if(e){if(typeof e==`string`)return n0(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?n0(e,t):void 0}}var H0=function(e){e instanceof Array?e.forEach(H0):(e.map&&e.map.dispose(),e.dispose())},U0=function(e){e.geometry&&e.geometry.dispose(),e.material&&H0(e.material),e.texture&&e.texture.dispose(),e.children&&e.children.forEach(U0)},W0=function(e){if(e&&e.children)for(;e.children.length;){var t=e.children[0];e.remove(t),U0(t)}};function G0(e,t){var n=new t;return{linkProp:function(t){return{default:n[t](),onChange:function(n,r){r[e][t](n)},triggerUpdate:!1}},linkMethod:function(t){return function(n){var r=n[e],i=[...arguments].slice(1),a=r[t].apply(r,i);return a===r?this:a}}}}var K0=100;function q0(){return K0}function J0(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,r=(90-e)*Math.PI/180,i=(90-t)*Math.PI/180,a=K0*(1+n),o=Math.sin(r);return{x:a*o*Math.cos(i),y:a*Math.cos(r),z:a*o*Math.sin(i)}}function Y0(e){var t=e.x,n=e.y,r=e.z,i=Math.sqrt(t*t+n*n+r*r),a=Math.acos(n/i),o=Math.atan2(r,t);return{lat:90-a*180/Math.PI,lng:90-o*180/Math.PI-(o<-Math.PI/2?360:0),altitude:i/K0-1}}function X0(e){return e*Math.PI/180}var Z0=window.THREE?window.THREE:{BackSide:1,BufferAttribute:di,Color:Er,Mesh:ea,ShaderMaterial:xs},Q0=` uniform float hollowRadius; varying vec3 vVertexWorldPosition; varying vec3 vVertexNormal; varying float vCameraDistanceToObjCenter; varying float vVertexAngularDistanceToHollowRadius; void main() { vVertexNormal = normalize(normalMatrix * normal); vVertexWorldPosition = (modelMatrix * vec4(position, 1.0)).xyz; vec4 objCenterViewPosition = modelViewMatrix * vec4(0.0, 0.0, 0.0, 1.0); vCameraDistanceToObjCenter = length(objCenterViewPosition); float edgeAngle = atan(hollowRadius / vCameraDistanceToObjCenter); float vertexAngle = acos(dot(normalize(modelViewMatrix * vec4(position, 1.0)), normalize(objCenterViewPosition))); vVertexAngularDistanceToHollowRadius = vertexAngle - edgeAngle; gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0); }`,$0=` uniform vec3 color; uniform float coefficient; uniform float power; uniform float hollowRadius; varying vec3 vVertexNormal; varying vec3 vVertexWorldPosition; varying float vCameraDistanceToObjCenter; varying float vVertexAngularDistanceToHollowRadius; void main() { if (vCameraDistanceToObjCenter < hollowRadius) discard; // inside the hollowRadius if (vVertexAngularDistanceToHollowRadius < 0.0) discard; // frag position is within the hollow radius vec3 worldCameraToVertex = vVertexWorldPosition - cameraPosition; vec3 viewCameraToVertex = (viewMatrix * vec4(worldCameraToVertex, 0.0)).xyz; viewCameraToVertex = normalize(viewCameraToVertex); float intensity = pow( coefficient + dot(vVertexNormal, viewCameraToVertex), power ); gl_FragColor = vec4(color, intensity); }`;function e2(e,t,n,r){return new Z0.ShaderMaterial({depthWrite:!1,transparent:!0,vertexShader:Q0,fragmentShader:$0,uniforms:{coefficient:{value:e},color:{value:new Z0.Color(t)},power:{value:n},hollowRadius:{value:r}}})}function t2(e,t){for(var n=e.clone(),r=new Float32Array(e.attributes.position.count*3),i=0,a=r.length;i1&&arguments[1]!==void 0?arguments[1]:{},i=r.color,a=i===void 0?`gold`:i,o=r.size,s=o===void 0?2:o,c=r.coefficient,l=c===void 0?.5:c,u=r.power,d=u===void 0?1:u,f=r.hollowRadius,p=f===void 0?0:f,m=r.backside,h=m===void 0?!0:m;d0(this,t),n=l0(this,t);var g=t2(e,s),_=e2(l,a,d,p);return h&&(_.side=Z0.BackSide),n.geometry=g,n.material=_,n}return x0(t,e),_0(t)}(Z0.Mesh),r2=window.THREE?window.THREE:{Color:Er,Group:B,LineBasicMaterial:ha,LineSegments:Da,Mesh:ea,MeshPhongMaterial:Ts,SphereGeometry:cs,SRGBColorSpace:yt,TextureLoader:$s},i2=wp({props:{globeImageUrl:{},bumpImageUrl:{},showGlobe:{default:!0,onChange:function(e,t){t.globeGroup.visible=!!e},triggerUpdate:!1},showGraticules:{default:!1,onChange:function(e,t){t.graticulesObj.visible=!!e},triggerUpdate:!1},showAtmosphere:{default:!0,onChange:function(e,t){t.atmosphereObj&&(t.atmosphereObj.visible=!!e)},triggerUpdate:!1},atmosphereColor:{default:`lightskyblue`},atmosphereAltitude:{default:.15},globeCurvatureResolution:{default:4},globeTileEngineUrl:{onChange:function(e,t){t.tileEngine.tileUrl=e}},globeTileEngineMaxLevel:{default:17,onChange:function(e,t){t.tileEngine.maxLevel=e},triggerUpdate:!1},updatePov:{onChange:function(e,t){t.tileEngine.updatePov(e)},triggerUpdate:!1},onReady:{default:function(){},triggerUpdate:!1}},methods:{globeMaterial:function(e,t){return t===void 0?e.globeObj.material:(e.globeObj.material=t||e.defaultGlobeMaterial,this)},globeTileEngineClearCache:function(e){e.tileEngine.clearTiles()},_destructor:function(e){U0(e.globeObj),U0(e.tileEngine),U0(e.graticulesObj)}},stateInit:function(){var e=new r2.MeshPhongMaterial({color:0}),t=new r2.Mesh(void 0,e);t.rotation.y=-Math.PI/2;var n=new zb(K0),r=new r2.Group;return r.__globeObjType=`globe`,r.add(t),r.add(n),{globeGroup:r,globeObj:t,graticulesObj:new r2.LineSegments(new cS(ly(),K0,2),new r2.LineBasicMaterial({color:`lightgrey`,transparent:!0,opacity:.1})),defaultGlobeMaterial:e,tileEngine:n}},init:function(e,t){W0(e),t.scene=e,t.scene.add(t.globeGroup),t.scene.add(t.graticulesObj),t.ready=!1},update:function(e,t){var n=e.globeObj.material;if(e.tileEngine.visible=!(e.globeObj.visible=!e.globeTileEngineUrl),t.hasOwnProperty(`globeCurvatureResolution`)){var r;(r=e.globeObj.geometry)==null||r.dispose();var i=Math.max(4,Math.round(360/e.globeCurvatureResolution));e.globeObj.geometry=new r2.SphereGeometry(K0,i,i/2),e.tileEngine.curvatureResolution=e.globeCurvatureResolution}if(t.hasOwnProperty(`globeImageUrl`)&&(e.globeImageUrl?new r2.TextureLoader().load(e.globeImageUrl,function(t){var r;t.colorSpace=r2.SRGBColorSpace,(r=n.map)==null||r.dispose(),n.map=t,n.color=null,n.needsUpdate=!0,!e.ready&&(e.ready=!0)&&setTimeout(e.onReady)}):!n.color&&(n.color=new r2.Color(0))),t.hasOwnProperty(`bumpImageUrl`)&&(e.bumpImageUrl?e.bumpImageUrl&&new r2.TextureLoader().load(e.bumpImageUrl,function(e){var t;(t=n.bumpMap)==null||t.dispose(),n.bumpMap=e,n.needsUpdate=!0}):(n.bumpMap=null,n.needsUpdate=!0)),(t.hasOwnProperty(`atmosphereColor`)||t.hasOwnProperty(`atmosphereAltitude`))&&(e.atmosphereObj&&(e.scene.remove(e.atmosphereObj),U0(e.atmosphereObj)),e.atmosphereColor&&e.atmosphereAltitude)){var a=e.atmosphereObj=new n2(e.globeObj.geometry,{color:e.atmosphereColor,size:K0*e.atmosphereAltitude,hollowRadius:K0,coefficient:.1,power:3.5});a.visible=!!e.showAtmosphere,a.__globeObjType=`atmosphere`,e.scene.add(a)}!e.ready&&(!e.globeImageUrl||e.globeTileEngineUrl)&&(e.ready=!0,e.onReady())}}),a2=function(e){return isNaN(e)?parseInt(kS(e).toHex(),16):e},o2=function(e){return e&&isNaN(e)?Ym(e).opacity:1},s2=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,r,i=1,a=/^rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*([\d.eE+-]+)\s*\)$/.exec(e.trim().toLowerCase());if(a){var o=F0(a.slice(1),4),s=o[0],c=o[1],l=o[2],u=o[3];r=new Er(`rgb(${+s},${+c},${+l})`),i=Math.min(+u,1)}else r=new Er(e);n&&r.convertLinearToSRGB();var d=r.toArray();return t?[].concat(R0(d),[i]):d};function c2(e,t,n){return e.opacity=t,e.transparent=t<1,e.depthWrite=t>=1,e}var l2=window.THREE?window.THREE:{BufferAttribute:di};function u2(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Float32Array;if(t===1)return new l2.BufferAttribute(new n(e),t);for(var r=new l2.BufferAttribute(new n(e.length*t),t),i=0,a=e.length;i1&&arguments[1]!==void 0?arguments[1]:{},i=r.dataBindAttr,a=i===void 0?`__data`:i,o=r.objBindAttr,s=o===void 0?`__threeObj`:o,c=r.removeDelay,l=c===void 0?0:c;return d0(this,t),n=l0(this,t),v0(n,`scene`,void 0),p0(n,f2,void 0),p0(n,p2,void 0),p0(n,m2,void 0),n.scene=e,m0(f2,n,a),m0(p2,n,s),m0(m2,n,l),n.onRemoveObj(function(){}),n}return x0(t,e),_0(t,[{key:`onCreateObj`,value:function(e){var n=this;return L0(t,`onCreateObj`,this)([function(t){var r=e(t);return t[f0(p2,n)]=r,r[f0(f2,n)]=t,n.scene.add(r),r}]),this}},{key:`onRemoveObj`,value:function(e){var n=this;return L0(t,`onRemoveObj`,this)([function(r,i){var a=L0(t,`getData`,n)([r]);e(r,i);var o=function(){n.scene.remove(r),U0(r),delete a[f0(p2,n)]};f0(m2,n)?setTimeout(o,f0(m2,n)):o()}]),this}}])}(BC),g2=window.THREE?window.THREE:{BufferGeometry:Di,CylinderGeometry:Ha,Matrix4:qn,Mesh:ea,MeshLambertMaterial:Os,Object3D:z,Vector3:R},_2=Object.assign({},fS),v2=_2.BufferGeometryUtils||_2,y2=wp({props:{pointsData:{default:[]},pointLat:{default:`lat`},pointLng:{default:`lng`},pointColor:{default:function(){return`#ffffaa`}},pointAltitude:{default:.1},pointRadius:{default:.25},pointResolution:{default:12,triggerUpdate:!1},pointsMerge:{default:!1},pointsTransitionDuration:{default:1e3,triggerUpdate:!1}},init:function(e,t,n){var r=n.tweenGroup;W0(e),t.scene=e,t.tweenGroup=r,t.dataMapper=new h2(e,{objBindAttr:`__threeObjPoint`})},update:function(e,t){var n=V(e.pointLat),r=V(e.pointLng),i=V(e.pointAltitude),a=V(e.pointRadius),o=V(e.pointColor),s=new g2.CylinderGeometry(1,1,1,e.pointResolution);s.applyMatrix4(new g2.Matrix4().makeRotationX(Math.PI/2)),s.applyMatrix4(new g2.Matrix4().makeTranslation(0,0,-.5));var c=2*Math.PI*K0/360,l={};if(!e.pointsMerge&&t.hasOwnProperty(`pointsMerge`)&&W0(e.scene),e.dataMapper.scene=e.pointsMerge?new g2.Object3D:e.scene,e.dataMapper.onCreateObj(f).onUpdateObj(p).digest(e.pointsData),e.pointsMerge){var u=e.pointsData.length?(v2.mergeGeometries||v2.mergeBufferGeometries)(e.pointsData.map(function(t){var n=e.dataMapper.getObj(t),r=n.geometry.clone();n.updateMatrix(),r.applyMatrix4(n.matrix);var i=s2(o(t));return r.setAttribute(`color`,u2(Array(r.getAttribute(`position`).count).fill(i),4)),r})):new g2.BufferGeometry,d=new g2.Mesh(u,new g2.MeshLambertMaterial({color:16777215,transparent:!0,vertexColors:!0}));d.__globeObjType=`points`,d.__data=e.pointsData,e.dataMapper.clear(),W0(e.scene),e.scene.add(d)}function f(){var e=new g2.Mesh(s);return e.__globeObjType=`point`,e}function p(t,s){var u=function(n){var r=t.__currentTargetD=n,i=r.r,a=r.alt,o=r.lat,s=r.lng;Object.assign(t.position,J0(o,s));var l=e.pointsMerge?new g2.Vector3(0,0,0):e.scene.localToWorld(new g2.Vector3(0,0,0));t.lookAt(l),t.scale.x=t.scale.y=Math.min(30,i)*c,t.scale.z=Math.max(a*K0,.1)},d={alt:+i(s),r:+a(s),lat:+n(s),lng:+r(s)},f=t.__currentTargetD||Object.assign({},d,{alt:-.001});if(Object.keys(d).some(function(e){return f[e]!==d[e]})&&(e.pointsMerge||!e.pointsTransitionDuration||e.pointsTransitionDuration<0?u(d):e.tweenGroup.add(new jp(f).to(d,e.pointsTransitionDuration).easing(Tp.Quadratic.InOut).onUpdate(u).onComplete(function(){e.tweenGroup.remove(this)}).start())),!e.pointsMerge){var p=o(s),m=p?o2(p):0,h=!!m;t.visible=h,h&&(l.hasOwnProperty(p)||(l[p]=new g2.MeshLambertMaterial({color:a2(p),transparent:m<1,opacity:m})),t.material=l[p])}}}}),b2=function(){return{uniforms:{dashOffset:{value:0},dashSize:{value:1},gapSize:{value:0},dashTranslate:{value:0}},vertexShader:` ${pl.common} ${pl.logdepthbuf_pars_vertex} uniform float dashTranslate; attribute vec4 color; varying vec4 vColor; attribute float relDistance; varying float vRelDistance; void main() { // pass through colors and distances vColor = color; vRelDistance = relDistance + dashTranslate; gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0); ${pl.logdepthbuf_vertex} } `,fragmentShader:` ${pl.logdepthbuf_pars_fragment} uniform float dashOffset; uniform float dashSize; uniform float gapSize; varying vec4 vColor; varying float vRelDistance; void main() { // ignore pixels in the gap if (vRelDistance < dashOffset) discard; if (mod(vRelDistance - dashOffset, dashSize + gapSize) > dashSize) discard; // set px color: [r, g, b, a], interpolated between vertices gl_FragColor = vColor; ${pl.logdepthbuf_fragment} } `}},x2=function(e){return e.uniforms.uSurfaceRadius={type:`float`,value:0},e.vertexShader=(`attribute float surfaceRadius; varying float vSurfaceRadius; varying vec3 vPos; `+e.vertexShader).replace(`void main() {`,[`void main() {`,`vSurfaceRadius = surfaceRadius;`,`vPos = position;`].join(` `)),e.fragmentShader=(`uniform float uSurfaceRadius; varying float vSurfaceRadius; varying vec3 vPos; `+e.fragmentShader).replace(`void main() {`,[`void main() {`,`if (length(vPos) < max(uSurfaceRadius, vSurfaceRadius)) discard;`].join(` `)),e},S2=function(e){return e.vertexShader=` attribute float r; const float PI = 3.1415926535897932384626433832795; float toRad(in float a) { return a * PI / 180.0; } vec3 Polar2Cartesian(in vec3 c) { // [lat, lng, r] float phi = toRad(90.0 - c.x); float theta = toRad(90.0 - c.y); float r = c.z; return vec3( // x,y,z r * sin(phi) * cos(theta), r * cos(phi), r * sin(phi) * sin(theta) ); } vec2 Cartesian2Polar(in vec3 p) { float r = sqrt(p.x * p.x + p.y * p.y + p.z * p.z); float phi = acos(p.y / r); float theta = atan(p.z, p.x); return vec2( // lat,lng 90.0 - phi * 180.0 / PI, 90.0 - theta * 180.0 / PI - (theta < -PI / 2.0 ? 360.0 : 0.0) ); } ${e.vertexShader.replace(`}`,` vec3 pos = Polar2Cartesian(vec3(Cartesian2Polar(position), r)); gl_Position = projectionMatrix * modelViewMatrix * vec4(pos, 1.0); } `)} `,e},C2=function(e,t){return e.onBeforeCompile=function(n){e.userData.shader=t(n)},e},w2=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:function(e){return e};if(e.userData.shader)t(e.userData.shader.uniforms);else{var n=e.onBeforeCompile;e.onBeforeCompile=function(e){n(e),t(e.uniforms)}}},T2=[`stroke`],E2=window.THREE?window.THREE:{BufferGeometry:Di,CubicBezierCurve3:uo,Curve:Ua,Group:B,Line:Ca,Mesh:ea,NormalBlending:1,ShaderMaterial:xs,TubeGeometry:ls,Vector3:R},D2=VC.default.default||VC.default,O2=wp({props:{arcsData:{default:[]},arcStartLat:{default:`startLat`},arcStartLng:{default:`startLng`},arcStartAltitude:{default:0},arcEndLat:{default:`endLat`},arcEndLng:{default:`endLng`},arcEndAltitude:{default:0},arcColor:{default:function(){return`#ffffaa`}},arcAltitude:{},arcAltitudeAutoScale:{default:.5},arcStroke:{},arcCurveResolution:{default:64,triggerUpdate:!1},arcCircularResolution:{default:6,triggerUpdate:!1},arcDashLength:{default:1},arcDashGap:{default:0},arcDashInitialGap:{default:0},arcDashAnimateTime:{default:0},arcsTransitionDuration:{default:1e3,triggerUpdate:!1}},methods:{pauseAnimation:function(e){var t;(t=e.ticker)==null||t.pause()},resumeAnimation:function(e){var t;(t=e.ticker)==null||t.resume()},_destructor:function(e){var t;e.sharedMaterial.dispose(),(t=e.ticker)==null||t.dispose()}},stateInit:function(e){return{tweenGroup:e.tweenGroup,ticker:new D2,sharedMaterial:new E2.ShaderMaterial(O0(O0({},b2()),{},{transparent:!0,blending:E2.NormalBlending}))}},init:function(e,t){W0(e),t.scene=e,t.dataMapper=new h2(e,{objBindAttr:`__threeObjArc`}).onCreateObj(function(){var e=new E2.Group;return e.__globeObjType=`arc`,e}),t.ticker.onTick.add(function(e,n){t.dataMapper.entries().map(function(e){return F0(e,2)[1]}).filter(function(e){return e.children.length&&e.children[0].material&&e.children[0].__dashAnimateStep}).forEach(function(e){var t=e.children[0],r=t.__dashAnimateStep*n,i=t.material.uniforms.dashTranslate.value%1e9;t.material.uniforms.dashTranslate.value=i+r})})},update:function(e){var t=V(e.arcStartLat),n=V(e.arcStartLng),r=V(e.arcStartAltitude),i=V(e.arcEndLat),a=V(e.arcEndLng),o=V(e.arcEndAltitude),s=V(e.arcAltitude),c=V(e.arcAltitudeAutoScale),l=V(e.arcStroke),u=V(e.arcColor),d=V(e.arcDashLength),f=V(e.arcDashGap),p=V(e.arcDashInitialGap),m=V(e.arcDashAnimateTime);e.dataMapper.onUpdateObj(function(v,y){var b=l(y),x=b!=null;if(!v.children.length||x!==(v.children[0].type===`Mesh`)){W0(v);var S=x?new E2.Mesh:new E2.Line(new E2.BufferGeometry);S.material=e.sharedMaterial.clone(),v.add(S)}var C=v.children[0];Object.assign(C.material.uniforms,{dashSize:{value:d(y)},gapSize:{value:f(y)},dashOffset:{value:p(y)}});var w=m(y);C.__dashAnimateStep=w>0?1e3/w:0;var T=g(u(y),e.arcCurveResolution,x?e.arcCircularResolution+1:1),E=_(e.arcCurveResolution,x?e.arcCircularResolution+1:1,!0);C.geometry.setAttribute(`color`,T),C.geometry.setAttribute(`relDistance`,E);var D=function(t){var n=v.__currentTargetD=t,r=n.stroke,i=h(k0(n,T2));x?(C.geometry&&C.geometry.dispose(),C.geometry=new E2.TubeGeometry(i,e.arcCurveResolution,r/2,e.arcCircularResolution),C.geometry.setAttribute(`color`,T),C.geometry.setAttribute(`relDistance`,E)):C.geometry.setFromPoints(i.getPoints(e.arcCurveResolution))},O={stroke:b,alt:s(y),altAutoScale:+c(y),startLat:+t(y),startLng:+n(y),startAlt:+r(y),endLat:+i(y),endLng:+a(y),endAlt:+o(y)},k=v.__currentTargetD||Object.assign({},O,{altAutoScale:-.001});Object.keys(O).some(function(e){return k[e]!==O[e]})&&(!e.arcsTransitionDuration||e.arcsTransitionDuration<0?D(O):e.tweenGroup.add(new jp(k).to(O,e.arcsTransitionDuration).easing(Tp.Quadratic.InOut).onUpdate(D).onComplete(function(){e.tweenGroup.remove(this)}).start()))}).digest(e.arcsData);function h(e){var t=e.alt,n=e.altAutoScale,r=e.startLat,i=e.startLng,a=e.startAlt,o=e.endLat,s=e.endLng,c=e.endAlt,l=function(e){var t=F0(e,3),n=t[0],r=t[1],i=t[2],a=J0(r,n,i),o=a.x,s=a.y,c=a.z;return new E2.Vector3(o,s,c)},u=[i,r],d=[s,o],f=t;if(f??=Xv(u,d)/2*n+Math.max(a,c),f||a||c){var p=uy(u,d),m=function(e,t){return t+(t-e)*(e2&&arguments[2]!==void 0?arguments[2]:1,r=t+1,i;if(e instanceof Array||e instanceof Function){var a=e instanceof Array?_g().domain(e.map(function(t,n){return n/(e.length-1)})).range(e):e;i=function(e){return s2(a(e),!0,!0)}}else{var o=s2(e,!0,!0);i=function(){return o}}for(var s=[],c=0,l=r;c1&&arguments[1]!==void 0?arguments[1]:1,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,r=e+1,i=[],a=0,o=r;a=l?i:a}),4)),r})):new k2.BufferGeometry,p=new k2.MeshLambertMaterial({color:16777215,transparent:!0,vertexColors:!0,side:k2.DoubleSide});p.onBeforeCompile=function(e){p.userData.shader=x2(e)};var m=new k2.Mesh(f,p);m.__globeObjType=`hexBinPoints`,m.__data=u,e.dataMapper.clear(),W0(e.scene),e.scene.add(m)}function h(e){var t=new k2.Mesh;t.__hexCenter=uD(e.h3Idx),t.__hexGeoJson=dD(e.h3Idx,!0).reverse();var n=t.__hexCenter[1];return t.__hexGeoJson.forEach(function(e){var t=e[0];Math.abs(n-t)>170&&(e[0]+=n>t?360:-360)}),t.__globeObjType=`hexbin`,t}function g(t,n){var r=function(e,t,n){return e-(e-t)*n},i=Math.max(0,Math.min(1,+c(n))),l=F0(t.__hexCenter,2),u=l[0],f=l[1],p=i===0?t.__hexGeoJson:t.__hexGeoJson.map(function(e){var t=F0(e,2),n=t[0],a=t[1];return[[n,f],[a,u]].map(function(e){var t=F0(e,2),n=t[0],a=t[1];return r(n,a,i)})}),m=e.hexTopCurvatureResolution;t.geometry&&t.geometry.dispose(),t.geometry=new MT([p],0,K0,!1,!0,!0,m);var h={alt:+a(n)},g=function(e){var n=(t.__currentTargetD=e).alt;t.scale.x=t.scale.y=t.scale.z=1+n;var r=K0/(n+1);t.geometry.setAttribute(`surfaceRadius`,u2(Array(t.geometry.getAttribute(`position`).count).fill(r),1))},_=t.__currentTargetD||Object.assign({},h,{alt:-.001});if(Object.keys(h).some(function(e){return _[e]!==h[e]})&&(e.hexBinMerge||!e.hexTransitionDuration||e.hexTransitionDuration<0?g(h):e.tweenGroup.add(new jp(_).to(h,e.hexTransitionDuration).easing(Tp.Quadratic.InOut).onUpdate(g).onComplete(function(){e.tweenGroup.remove(this)}).start())),!e.hexBinMerge){var v=s(n),y=o(n);[v,y].forEach(function(e){if(!d.hasOwnProperty(e)){var t=o2(e);d[e]=C2(new k2.MeshLambertMaterial({color:a2(e),transparent:t<1,opacity:t,side:k2.DoubleSide}),x2)}}),t.material=[v,y].map(function(e){return d[e]})}}}}),N2=function(e){return e*e},P2=function(e){return e*Math.PI/180};function F2(e,t){var n=Math.sqrt,r=Math.cos,i=function(e){return N2(Math.sin(e/2))},a=P2(e[1]),o=P2(t[1]),s=P2(e[0]),c=P2(t[0]);return 2*Math.asin(n(i(o-a)+r(a)*r(o)*i(c-s)))}var I2=Math.sqrt(2*Math.PI);function L2(e,t){return Math.exp(-N2(e/t)/2)/(t*I2)}var R2=function(e){var t=F0(e,2),n=t[0],r=t[1],i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},o=a.lngAccessor,s=o===void 0?function(e){return e[0]}:o,c=a.latAccessor,l=c===void 0?function(e){return e[1]}:c,u=a.weightAccessor,d=u===void 0?function(){return 1}:u,f=a.bandwidth,p=[n,r],m=f*Math.PI/180;return Dm(i.map(function(e){var t=d(e);return t?L2(F2(p,[s(e),l(e)]),m)*t:0}))},z2=function(){var e=c0(M0().m(function e(t){var n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T,E,D,O,k,A,j,M,N,ee,te,ne,re,ie,ae,oe,se,ce=arguments,le,ue,de;return M0().w(function(e){for(;;)switch(e.n){case 0:if(r=ce.length>1&&ce[1]!==void 0?ce[1]:[],i=ce.length>2&&ce[2]!==void 0?ce[2]:{},a=i.lngAccessor,o=a===void 0?function(e){return e[0]}:a,s=i.latAccessor,c=s===void 0?function(e){return e[1]}:s,l=i.weightAccessor,u=l===void 0?function(){return 1}:l,d=i.bandwidth,(n=navigator)!=null&&n.gpu){e.n=1;break}return console.warn(`WebGPU not enabled in browser. Please consider enabling it to improve performance.`),e.a(2,t.map(function(e){return R2(e,r,{lngAccessor:o,latAccessor:c,weightAccessor:u,bandwidth:d})}));case 1:return f=4,p=m1,m=h1,h=E1,g=T1,_=b1,v=x1,y=g1,b=w1,x=C1,S=v1,C=_1,w=y1,T=S1,E=g(new rW(new Float32Array(t.flat().map(P2)),2),`vec2`,t.length),D=g(new rW(new Float32Array(r.map(function(e){return[P2(o(e)),P2(c(e)),u(e)]}).flat()),3),`vec3`,r.length),O=new rW(t.length,1),k=g(O,`float`,t.length),A=_(Math.PI),j=b(A.mul(2)),M=function(e){return e.mul(e)},N=function(e){return M(x(e.div(2)))},ee=function(e,t){var n=_(e[1]),r=_(t[1]),i=_(e[0]),a=_(t[0]);return _(2).mul(C(b(N(r.sub(n)).add(S(n).mul(S(r)).mul(N(a.sub(i)))))))},te=function(e,t){return w(T(M(e.div(t)).div(2))).div(t.mul(j))},ne=h(P2(d)),re=h(P2(d*f)),ie=h(r.length),ae=p(function(){var e=E.element(v),t=k.element(v);t.assign(0),y(ie,function(n){var r=n.i,i=D.element(r),a=i.z;m(a,function(){var n=ee(i.xy,e.xy);m(n&&n.lessThan(re),function(){t.addAssign(te(n,ne).mul(a))})})})}),oe=ae().compute(t.length),se=new p1,e.n=2,se.computeAsync(oe);case 2:return le=Array,ue=Float32Array,e.n=3,se.getArrayBufferAsync(O);case 3:return de=e.v,e.a(2,le.from.call(le,new ue(de)))}},e)}));return function(t){return e.apply(this,arguments)}}(),B2=window.THREE?window.THREE:{Mesh:ea,MeshLambertMaterial:Os,SphereGeometry:cs},V2=3.5,H2=.1,U2=100,W2=function(e){var t=Ym(hD(e));return t.opacity=Math.cbrt(e),t.formatRgb()},G2=wp({props:{heatmapsData:{default:[]},heatmapPoints:{default:function(e){return e}},heatmapPointLat:{default:function(e){return e[0]}},heatmapPointLng:{default:function(e){return e[1]}},heatmapPointWeight:{default:1},heatmapBandwidth:{default:2.5},heatmapColorFn:{default:function(){return W2}},heatmapColorSaturation:{default:1.5},heatmapBaseAltitude:{default:.01},heatmapTopAltitude:{},heatmapsTransitionDuration:{default:0,triggerUpdate:!1}},init:function(e,t,n){var r=n.tweenGroup;W0(e),t.scene=e,t.tweenGroup=r,t.dataMapper=new h2(e,{objBindAttr:`__threeObjHeatmap`}).onCreateObj(function(){var e=new B2.Mesh(new B2.SphereGeometry(K0),C2(new B2.MeshLambertMaterial({vertexColors:!0,transparent:!0}),S2));return e.__globeObjType=`heatmap`,e})},update:function(e){var t=V(e.heatmapPoints),n=V(e.heatmapPointLat),r=V(e.heatmapPointLng),i=V(e.heatmapPointWeight),a=V(e.heatmapBandwidth),o=V(e.heatmapColorFn),s=V(e.heatmapColorSaturation),c=V(e.heatmapBaseAltitude),l=V(e.heatmapTopAltitude);e.dataMapper.onUpdateObj(function(u,d){var f=a(d),p=o(d),m=s(d),h=c(d),g=l(d),_=t(d).map(function(e){var t=n(e),a=r(e),o=J0(t,a);return{x:o.x,y:o.y,z:o.z,lat:t,lng:a,weight:i(e)}}),v=Math.max(H2,f/V2),y=Math.ceil(360/(v||-1));u.geometry.parameters.widthSegments!==y&&(u.geometry.dispose(),u.geometry=new B2.SphereGeometry(K0,y,y/2)),z2(d2(u.geometry.getAttribute(`position`)).map(function(e){var t=F0(e,3),n=t[0],r=t[1],i=t[2],a=Y0({x:n,y:r,z:i});return[a.lng,a.lat]}),_,{latAccessor:function(e){return e.lat},lngAccessor:function(e){return e.lng},weightAccessor:function(e){return e.weight},bandwidth:f}).then(function(t){var n=R0(Array(U2)).map(function(e,t){return s2(p(t/(U2-1)))}),r=function(e){var t=u.__currentTargetD=e,r=t.kdeVals,i=t.topAlt,a=t.saturation,o=Sm(r.map(Math.abs))||1e-15,s=vg([0,o/a],n);u.geometry.setAttribute(`color`,u2(r.map(function(e){return s(Math.abs(e))}),4));var c=_g([0,o],[K0*(1+h),K0*(1+(i||h))]);u.geometry.setAttribute(`r`,u2(r.map(c)))},i={kdeVals:t,topAlt:g,saturation:m},a=u.__currentTargetD||Object.assign({},i,{kdeVals:t.map(function(){return 0}),topAlt:g&&h,saturation:.5});a.kdeVals.length!==t.length&&(a.kdeVals=t.slice()),Object.keys(i).some(function(e){return a[e]!==i[e]})&&(!e.heatmapsTransitionDuration||e.heatmapsTransitionDuration<0?r(i):e.tweenGroup.add(new jp(a).to(i,e.heatmapsTransitionDuration).easing(Tp.Quadratic.InOut).onUpdate(r).onComplete(function(){e.tweenGroup.remove(this)}).start()))})}).digest(e.heatmapsData)}}),K2=window.THREE?window.THREE:{DoubleSide:2,Group:B,LineBasicMaterial:ha,LineSegments:Da,Mesh:ea,MeshBasicMaterial:Hi},q2=wp({props:{polygonsData:{default:[]},polygonGeoJsonGeometry:{default:`geometry`},polygonSideColor:{default:function(){return`#ffffaa`}},polygonSideMaterial:{},polygonCapColor:{default:function(){return`#ffffaa`}},polygonCapMaterial:{},polygonStrokeColor:{},polygonAltitude:{default:.01},polygonCapCurvatureResolution:{default:5},polygonsTransitionDuration:{default:1e3,triggerUpdate:!1}},init:function(e,t,n){var r=n.tweenGroup;W0(e),t.scene=e,t.tweenGroup=r,t.dataMapper=new h2(e,{objBindAttr:`__threeObjPolygon`}).id(function(e){return e.id}).onCreateObj(function(){var e=new K2.Group;return e.__defaultSideMaterial=C2(new K2.MeshBasicMaterial({side:K2.DoubleSide,depthWrite:!0}),x2),e.__defaultCapMaterial=new K2.MeshBasicMaterial({side:K2.DoubleSide,depthWrite:!0}),e.add(new K2.Mesh(void 0,[e.__defaultSideMaterial,e.__defaultCapMaterial])),e.add(new K2.LineSegments(void 0,new K2.LineBasicMaterial)),e.__globeObjType=`polygon`,e})},update:function(e){var t=V(e.polygonGeoJsonGeometry),n=V(e.polygonAltitude),r=V(e.polygonCapCurvatureResolution),i=V(e.polygonCapColor),a=V(e.polygonCapMaterial),o=V(e.polygonSideColor),s=V(e.polygonSideMaterial),c=V(e.polygonStrokeColor),l=[];e.polygonsData.forEach(function(e){var u={data:e,capColor:i(e),capMaterial:a(e),sideColor:o(e),sideMaterial:s(e),strokeColor:c(e),altitude:+n(e),capCurvatureResolution:+r(e)},d=t(e),f=e.__id||`${Math.round(Math.random()*1e9)}`;e.__id=f,d.type===`Polygon`?l.push(O0({id:`${f}_0`,coords:d.coordinates},u)):d.type===`MultiPolygon`?l.push.apply(l,R0(d.coordinates.map(function(e,t){return O0({id:`${f}_${t}`,coords:e},u)}))):console.warn(`Unsupported GeoJson geometry type: ${d.type}. Skipping geometry...`)}),e.dataMapper.onUpdateObj(function(t,n){var r=n.coords,i=n.capColor,a=n.capMaterial,o=n.sideColor,s=n.sideMaterial,c=n.strokeColor,l=n.altitude,u=n.capCurvatureResolution,d=F0(t.children,2),f=d[0],p=d[1],m=!!c;p.visible=m;var h=!!(i||a),g=!!(o||s);J2(f.geometry.parameters||{},{polygonGeoJson:r,curvatureResolution:u,closedTop:h,includeSides:g})||(f.geometry&&f.geometry.dispose(),f.geometry=new MT(r,0,K0,!1,h,g,u)),m&&(!p.geometry.parameters||p.geometry.parameters.geoJson.coordinates!==r||p.geometry.parameters.resolution!==u)&&(p.geometry&&p.geometry.dispose(),p.geometry=new cS({type:`Polygon`,coordinates:r},K0,u));var _=g?0:-1,v=h?g?1:0:-1;if(_>=0&&(f.material[_]=s||t.__defaultSideMaterial),v>=0&&(f.material[v]=a||t.__defaultCapMaterial),[[!s&&o,_],[!a&&i,v]].forEach(function(e){var t=F0(e,2),n=t[0],r=t[1];if(!(!n||r<0)){var i=f.material[r],a=o2(n);i.color.set(a2(n)),i.transparent=a<1,i.opacity=a}}),m){var y=p.material,b=o2(c);y.color.set(a2(c)),y.transparent=b<1,y.opacity=b}var x={alt:l},S=function(e){var n=(t.__currentTargetD=e).alt;f.scale.x=f.scale.y=f.scale.z=1+n,m&&(p.scale.x=p.scale.y=p.scale.z=1+n+1e-4),w2(t.__defaultSideMaterial,function(e){return e.uSurfaceRadius.value=K0/(n+1)})},C=t.__currentTargetD||Object.assign({},x,{alt:-.001});Object.keys(x).some(function(e){return C[e]!==x[e]})&&(!e.polygonsTransitionDuration||e.polygonsTransitionDuration<0||C.alt===x.alt?S(x):e.tweenGroup.add(new jp(C).to(x,e.polygonsTransitionDuration).easing(Tp.Quadratic.InOut).onUpdate(S).onComplete(function(){e.tweenGroup.remove(this)}).start()))}).digest(l)}});function J2(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:function(){return function(e,t){return e===t}};return Object.entries(t).every(function(t){var r=F0(t,2),i=r[0],a=r[1];return e.hasOwnProperty(i)&&n(i)(e[i],a)})}var Y2=window.THREE?window.THREE:{BufferGeometry:Di,DoubleSide:2,Mesh:ea,MeshLambertMaterial:Os,Vector3:R},X2=Object.assign({},fS),Z2=X2.BufferGeometryUtils||X2,Q2=wp({props:{hexPolygonsData:{default:[]},hexPolygonGeoJsonGeometry:{default:`geometry`},hexPolygonColor:{default:function(){return`#ffffaa`}},hexPolygonAltitude:{default:.001},hexPolygonResolution:{default:3},hexPolygonMargin:{default:.2},hexPolygonUseDots:{default:!1},hexPolygonCurvatureResolution:{default:5},hexPolygonDotResolution:{default:12},hexPolygonsTransitionDuration:{default:0,triggerUpdate:!1}},init:function(e,t,n){var r=n.tweenGroup;W0(e),t.scene=e,t.tweenGroup=r,t.dataMapper=new h2(e,{objBindAttr:`__threeObjHexPolygon`}).onCreateObj(function(){var e=new Y2.Mesh(void 0,new Y2.MeshLambertMaterial({side:Y2.DoubleSide}));return e.__globeObjType=`hexPolygon`,e})},update:function(e){var t=V(e.hexPolygonGeoJsonGeometry),n=V(e.hexPolygonColor),r=V(e.hexPolygonAltitude),i=V(e.hexPolygonResolution),a=V(e.hexPolygonMargin),o=V(e.hexPolygonUseDots),s=V(e.hexPolygonCurvatureResolution),c=V(e.hexPolygonDotResolution);e.dataMapper.onUpdateObj(function(l,u){var d=t(u),f=i(u),p=r(u),m=Math.max(0,Math.min(1,+a(u))),h=o(u),g=s(u),_=c(u),v=n(u),y=o2(v);l.material.color.set(a2(v)),l.material.transparent=y<1,l.material.opacity=y;var b={alt:p,margin:m,curvatureResolution:g},x={geoJson:d,h3Res:f},S=l.__currentTargetD||Object.assign({},b,{alt:-.001}),C=l.__currentMemD||x;if(Object.keys(b).some(function(e){return S[e]!==b[e]})||Object.keys(x).some(function(e){return C[e]!==x[e]})){l.__currentMemD=x;var w=[];d.type===`Polygon`?fD(d.coordinates,f,!0).forEach(function(e){return w.push(e)}):d.type===`MultiPolygon`?d.coordinates.forEach(function(e){return fD(e,f,!0).forEach(function(e){return w.push(e)})}):console.warn(`Unsupported GeoJson geometry type: ${d.type}. Skipping geometry...`);var T=w.map(function(e){var t=uD(e),n=dD(e,!0).reverse(),r=t[1];return n.forEach(function(e){var t=e[0];Math.abs(r-t)>170&&(e[0]+=r>t?360:-360)}),{h3Idx:e,hexCenter:t,hexGeoJson:n}}),E=function(e){var t=l.__currentTargetD=e,n=t.alt,r=t.margin,i=t.curvatureResolution;l.geometry&&l.geometry.dispose(),l.geometry=T.length?(Z2.mergeGeometries||Z2.mergeBufferGeometries)(T.map(function(e){var t=F0(e.hexCenter,2),a=t[0],o=t[1];if(h){var s=J0(a,o,n),c=J0(e.hexGeoJson[0][1],e.hexGeoJson[0][0],n),l=new Va(.85*(1-r)*new Y2.Vector3(s.x,s.y,s.z).distanceTo(new Y2.Vector3(c.x,c.y,c.z)),_);return l.rotateX(X0(-a)),l.rotateY(X0(o)),l.translate(s.x,s.y,s.z),l}else{var u=function(e,t,n){return e-(e-t)*n};return new MT([r===0?e.hexGeoJson:e.hexGeoJson.map(function(e){var t=F0(e,2),n=t[0],i=t[1];return[[n,o],[i,a]].map(function(e){var t=F0(e,2),n=t[0],i=t[1];return u(n,i,r)})})],K0,K0*(1+n),!1,!0,!1,i)}})):new Y2.BufferGeometry};!e.hexPolygonsTransitionDuration||e.hexPolygonsTransitionDuration<0?E(b):e.tweenGroup.add(new jp(S).to(b,e.hexPolygonsTransitionDuration).easing(Tp.Quadratic.InOut).onUpdate(E).onComplete(function(){e.tweenGroup.remove(this)}).start())}}).digest(e.hexPolygonsData)}}),$2=window.THREE?window.THREE:{Vector3:R};function e4(e,t){var n=function(e,t){var n=e[e.length-1];return[].concat(R0(e),R0(Array(t-e.length).fill(n)))},r=Math.max(e.length,t.length),i=Sh.apply(void 0,R0([e,t].map(function(e){return e.map(function(e){return[e.x,e.y,e.z]})}).map(function(e){return n(e,r)})));return function(n){return n===0?e:n===1?t:i(n).map(function(e){var t=F0(e,3),n=t[0],r=t[1],i=t[2];return new $2.Vector3(n,r,i)})}}var t4=window.THREE?window.THREE:{BufferGeometry:Di,Color:Er,Group:B,Line:Ca,NormalBlending:1,ShaderMaterial:xs,Vector3:R},n4=VC.default.default||VC.default,r4=wp({props:{pathsData:{default:[]},pathPoints:{default:function(e){return e}},pathPointLat:{default:function(e){return e[0]}},pathPointLng:{default:function(e){return e[1]}},pathPointAlt:{default:.001},pathResolution:{default:2},pathColor:{default:function(){return`#ffffaa`}},pathStroke:{},pathDashLength:{default:1},pathDashGap:{default:0},pathDashInitialGap:{default:0},pathDashAnimateTime:{default:0},pathTransitionDuration:{default:1e3,triggerUpdate:!1},rendererSize:{}},methods:{pauseAnimation:function(e){var t;(t=e.ticker)==null||t.pause()},resumeAnimation:function(e){var t;(t=e.ticker)==null||t.resume()},_destructor:function(e){var t;(t=e.ticker)==null||t.dispose()}},stateInit:function(e){return{tweenGroup:e.tweenGroup,ticker:new n4,sharedMaterial:new t4.ShaderMaterial(O0(O0({},b2()),{},{transparent:!0,blending:t4.NormalBlending}))}},init:function(e,t){W0(e),t.scene=e,t.dataMapper=new h2(e,{objBindAttr:`__threeObjPath`}).onCreateObj(function(){var e=new t4.Group;return e.__globeObjType=`path`,e}),t.ticker.onTick.add(function(e,n){t.dataMapper.entries().map(function(e){return F0(e,2)[1]}).filter(function(e){return e.children.length&&e.children[0].material&&e.children[0].__dashAnimateStep}).forEach(function(e){var t=e.children[0],r=t.__dashAnimateStep*n;if(t.type===`Line`){var i=t.material.uniforms.dashTranslate.value%1e9;t.material.uniforms.dashTranslate.value=i+r}else if(t.type===`Line2`){for(var a=t.material.dashOffset-r,o=t.material.dashSize+t.material.gapSize;a<=-o;)a+=o;t.material.dashOffset=a}})})},update:function(e){var t=V(e.pathPoints),n=V(e.pathPointLat),r=V(e.pathPointLng),i=V(e.pathPointAlt),a=V(e.pathStroke),o=V(e.pathColor),s=V(e.pathDashLength),c=V(e.pathDashGap),l=V(e.pathDashInitialGap),u=V(e.pathDashAnimateTime);e.dataMapper.onUpdateObj(function(h,g){var _=a(g),v=_!=null;if(!h.children.length||v===(h.children[0].type===`Line`)){W0(h);var y=v?new Z1(new X1,new A1):new t4.Line(new t4.BufferGeometry,e.sharedMaterial.clone());h.add(y)}var b=h.children[0],x=f(t(g),n,r,i,e.pathResolution),S=u(g);if(b.__dashAnimateStep=S>0?1e3/S:0,v){b.material.resolution=e.rendererSize;var C=s(g),w=c(g),T=l(g);b.material.dashed=w>0,b.material.dashed?b.material.defines.USE_DASH=``:delete b.material.defines.USE_DASH,b.material.dashed&&(b.material.dashScale=1/d(x),b.material.dashSize=C,b.material.gapSize=w,b.material.dashOffset=-T);var E=o(g);if(E instanceof Array){var D=p(o(g),x.length-1,1,!1);b.geometry.setColors(D.array),b.material.vertexColors=!0}else{var O=E,k=o2(O);b.material.color=new t4.Color(a2(O)),b.material.transparent=k<1,b.material.opacity=k,b.material.vertexColors=!1}b.material.needsUpdate=!0}else{Object.assign(b.material.uniforms,{dashSize:{value:s(g)},gapSize:{value:c(g)},dashOffset:{value:l(g)}});var A=p(o(g),x.length),j=m(x.length,1,!0);b.geometry.setAttribute(`color`,A),b.geometry.setAttribute(`relDistance`,j)}var M=e4(h.__currentTargetD&&h.__currentTargetD.points||[x[0]],x),N=function(e){var t=h.__currentTargetD=e,n=t.stroke,r=t.interpolK,i=h.__currentTargetD.points=M(r);if(v){var a;b.geometry.setPositions((a=[]).concat.apply(a,R0(i.map(function(e){return[e.x,e.y,e.z]})))),b.material.linewidth=n,b.material.dashed&&b.computeLineDistances()}else b.geometry.setFromPoints(i),b.geometry.computeBoundingSphere()},ee={stroke:_,interpolK:1},te=Object.assign({},h.__currentTargetD||ee,{interpolK:0});Object.keys(ee).some(function(e){return te[e]!==ee[e]})&&(!e.pathTransitionDuration||e.pathTransitionDuration<0?N(ee):e.tweenGroup.add(new jp(te).to(ee,e.pathTransitionDuration).easing(Tp.Quadratic.InOut).onUpdate(N).onComplete(function(){e.tweenGroup.remove(this)}).start()))}).digest(e.pathsData);function d(e){var t=0,n;return e.forEach(function(e){n&&(t+=n.distanceTo(e)),n=e}),t}function f(e,t,n,r,i){var a=function(e,t,n){for(var r=[],i=1;i<=n;i++)r.push(e+(t-e)*i/(n+1));return r};return function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,n=[],r=null;return e.forEach(function(e){if(r){for(;Math.abs(r[1]-e[1])>180;)r[1]+=360*(r[1]t)for(var o=Math.floor(i/t),s=a(r[0],e[0],o),c=a(r[1],e[1],o),l=a(r[2],e[2],o),u=0,d=s.length;u2&&arguments[2]!==void 0?arguments[2]:1,r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!0,i=t+1,a;if(e instanceof Array||e instanceof Function){var o=e instanceof Array?_g().domain(e.map(function(t,n){return n/(e.length-1)})).range(e):e;a=function(e){return s2(o(e),r,!0)}}else{var s=s2(e,r,!0);a=function(){return s}}for(var c=[],l=0,u=i;l1&&arguments[1]!==void 0?arguments[1]:1,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,r=e+1,i=[],a=0,o=r;a0&&arguments[0]!==void 0?arguments[0]:1,r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:32;d0(this,t),e=l0(this,t),e.type=`CircleLineGeometry`,e.parameters={radius:n,segmentCount:r};for(var i=[],a=0;a<=r;a++){var o=(a/r-.25)*Math.PI*2;i.push({x:Math.cos(o)*n,y:Math.sin(o)*n,z:0})}return e.setFromPoints(i),e}return x0(t,e),_0(t)}((window.THREE?window.THREE:{BufferGeometry:Di}).BufferGeometry),u4=window.THREE?window.THREE:{Color:Er,Group:B,Line:Ca,LineBasicMaterial:ha,Vector3:R},d4=VC.default.default||VC.default,f4=wp({props:{ringsData:{default:[]},ringLat:{default:`lat`},ringLng:{default:`lng`},ringAltitude:{default:.0015},ringColor:{default:function(){return`#ffffaa`},triggerUpdate:!1},ringResolution:{default:64,triggerUpdate:!1},ringMaxRadius:{default:2,triggerUpdate:!1},ringPropagationSpeed:{default:1,triggerUpdate:!1},ringRepeatPeriod:{default:700,triggerUpdate:!1}},methods:{pauseAnimation:function(e){var t;(t=e.ticker)==null||t.pause()},resumeAnimation:function(e){var t;(t=e.ticker)==null||t.resume()},_destructor:function(e){var t;(t=e.ticker)==null||t.dispose()}},init:function(e,t,n){var r=n.tweenGroup;W0(e),t.scene=e,t.tweenGroup=r,t.dataMapper=new h2(e,{objBindAttr:`__threeObjRing`,removeDelay:3e4}).onCreateObj(function(){var e=new u4.Group;return e.__globeObjType=`ring`,e}),t.ticker=new d4,t.ticker.onTick.add(function(e){if(t.ringsData.length){var n=V(t.ringColor),r=V(t.ringAltitude),i=V(t.ringMaxRadius),a=V(t.ringPropagationSpeed),o=V(t.ringRepeatPeriod);t.dataMapper.entries().filter(function(e){return F0(e,2)[1]}).forEach(function(s){var c=F0(s,2),l=c[0],u=c[1];if((u.__nextRingTime||0)<=e){var d=o(l)/1e3;u.__nextRingTime=e+(d<=0?1/0:d);var f=new u4.Line(new l4(1,t.ringResolution),new u4.LineBasicMaterial),p=n(l),m=p instanceof Array||p instanceof Function,h;m?p instanceof Array?(h=_g().domain(p.map(function(e,t){return t/(p.length-1)})).range(p),f.material.transparent=p.some(function(e){return o2(e)<1})):(h=p,f.material.transparent=!0):(f.material.color=new u4.Color(a2(p)),c2(f.material,o2(p)));var g=K0*(1+r(l)),_=i(l),v=_*Math.PI/180,y=a(l),b=y<=0,x=function(e){var t=e.t,n=(b?1-t:t)*v;if(f.scale.x=f.scale.y=g*Math.sin(n),f.position.z=g*(1-Math.cos(n)),m){var r=h(t);f.material.color=new u4.Color(a2(r)),f.material.transparent&&(f.material.opacity=o2(r))}};if(y===0)x({t:0}),u.add(f);else{var S=Math.abs(_/y)*1e3;t.tweenGroup.add(new jp({t:0}).to({t:1},S).onUpdate(x).onStart(function(){return u.add(f)}).onComplete(function(){t.tweenGroup.remove(this),u.remove(f),U0(f)}).start())}}})}})},update:function(e){var t=V(e.ringLat),n=V(e.ringLng),r=V(e.ringAltitude),i=e.scene.localToWorld(new u4.Vector3(0,0,0));e.dataMapper.onUpdateObj(function(e,a){var o=t(a),s=n(a),c=r(a);Object.assign(e.position,J0(o,s,c)),e.lookAt(i)}).digest(e.ringsData)}}),p4={glyphs:{0:{x_min:73,x_max:715,ha:792,o:`m 394 -29 q 153 129 242 -29 q 73 479 73 272 q 152 829 73 687 q 394 989 241 989 q 634 829 545 989 q 715 479 715 684 q 635 129 715 270 q 394 -29 546 -29 m 394 89 q 546 211 489 89 q 598 479 598 322 q 548 748 598 640 q 394 871 491 871 q 241 748 298 871 q 190 479 190 637 q 239 211 190 319 q 394 89 296 89 `},1:{x_min:215.671875,x_max:574,ha:792,o:`m 574 0 l 442 0 l 442 697 l 215 697 l 215 796 q 386 833 330 796 q 475 986 447 875 l 574 986 l 574 0 `},2:{x_min:59,x_max:731,ha:792,o:`m 731 0 l 59 0 q 197 314 59 188 q 457 487 199 315 q 598 691 598 580 q 543 819 598 772 q 411 867 488 867 q 272 811 328 867 q 209 630 209 747 l 81 630 q 182 901 81 805 q 408 986 271 986 q 629 909 536 986 q 731 694 731 826 q 613 449 731 541 q 378 316 495 383 q 201 122 235 234 l 731 122 l 731 0 `},3:{x_min:54,x_max:737,ha:792,o:`m 737 284 q 635 55 737 141 q 399 -25 541 -25 q 156 52 248 -25 q 54 308 54 140 l 185 308 q 245 147 185 202 q 395 96 302 96 q 539 140 484 96 q 602 280 602 190 q 510 429 602 390 q 324 454 451 454 l 324 565 q 487 584 441 565 q 565 719 565 617 q 515 835 565 791 q 395 879 466 879 q 255 824 307 879 q 203 661 203 769 l 78 661 q 166 909 78 822 q 387 992 250 992 q 603 921 513 992 q 701 723 701 844 q 669 607 701 656 q 578 524 637 558 q 696 434 655 499 q 737 284 737 369 `},4:{x_min:48,x_max:742.453125,ha:792,o:`m 742 243 l 602 243 l 602 0 l 476 0 l 476 243 l 48 243 l 48 368 l 476 958 l 602 958 l 602 354 l 742 354 l 742 243 m 476 354 l 476 792 l 162 354 l 476 354 `},5:{x_min:54.171875,x_max:738,ha:792,o:`m 738 314 q 626 60 738 153 q 382 -23 526 -23 q 155 47 248 -23 q 54 256 54 125 l 183 256 q 259 132 204 174 q 382 91 314 91 q 533 149 471 91 q 602 314 602 213 q 538 469 602 411 q 386 528 475 528 q 284 506 332 528 q 197 439 237 484 l 81 439 l 159 958 l 684 958 l 684 840 l 254 840 l 214 579 q 306 627 258 612 q 407 643 354 643 q 636 552 540 643 q 738 314 738 457 `},6:{x_min:53,x_max:739,ha:792,o:`m 739 312 q 633 62 739 162 q 400 -31 534 -31 q 162 78 257 -31 q 53 439 53 206 q 178 859 53 712 q 441 986 284 986 q 643 912 559 986 q 732 713 732 833 l 601 713 q 544 830 594 786 q 426 875 494 875 q 268 793 331 875 q 193 517 193 697 q 301 597 240 570 q 427 624 362 624 q 643 540 552 624 q 739 312 739 451 m 603 298 q 540 461 603 400 q 404 516 484 516 q 268 461 323 516 q 207 300 207 401 q 269 137 207 198 q 405 83 325 83 q 541 137 486 83 q 603 298 603 197 `},7:{x_min:58.71875,x_max:730.953125,ha:792,o:`m 730 839 q 469 448 560 641 q 335 0 378 255 l 192 0 q 328 441 235 252 q 593 830 421 630 l 58 830 l 58 958 l 730 958 l 730 839 `},8:{x_min:55,x_max:736,ha:792,o:`m 571 527 q 694 424 652 491 q 736 280 736 358 q 648 71 736 158 q 395 -26 551 -26 q 142 69 238 -26 q 55 279 55 157 q 96 425 55 359 q 220 527 138 491 q 120 615 153 562 q 88 726 88 668 q 171 904 88 827 q 395 986 261 986 q 618 905 529 986 q 702 727 702 830 q 670 616 702 667 q 571 527 638 565 m 394 565 q 519 610 475 565 q 563 717 563 655 q 521 823 563 781 q 392 872 474 872 q 265 824 312 872 q 224 720 224 783 q 265 613 224 656 q 394 565 312 565 m 395 91 q 545 150 488 91 q 597 280 597 204 q 546 408 597 355 q 395 465 492 465 q 244 408 299 465 q 194 280 194 356 q 244 150 194 203 q 395 91 299 91 `},9:{x_min:53,x_max:739,ha:792,o:`m 739 524 q 619 94 739 241 q 362 -32 516 -32 q 150 47 242 -32 q 59 244 59 126 l 191 244 q 246 129 191 176 q 373 82 301 82 q 526 161 466 82 q 597 440 597 255 q 363 334 501 334 q 130 432 216 334 q 53 650 53 521 q 134 880 53 786 q 383 986 226 986 q 659 841 566 986 q 739 524 739 719 m 388 449 q 535 514 480 449 q 585 658 585 573 q 535 805 585 744 q 388 873 480 873 q 242 809 294 873 q 191 658 191 745 q 239 514 191 572 q 388 449 292 449 `},ο:{x_min:0,x_max:712,ha:815,o:`m 356 -25 q 96 88 192 -25 q 0 368 0 201 q 92 642 0 533 q 356 761 192 761 q 617 644 517 761 q 712 368 712 533 q 619 91 712 201 q 356 -25 520 -25 m 356 85 q 527 175 465 85 q 583 369 583 255 q 528 562 583 484 q 356 651 466 651 q 189 560 250 651 q 135 369 135 481 q 187 177 135 257 q 356 85 250 85 `},S:{x_min:0,x_max:788,ha:890,o:`m 788 291 q 662 54 788 144 q 397 -26 550 -26 q 116 68 226 -26 q 0 337 0 168 l 131 337 q 200 152 131 220 q 384 85 269 85 q 557 129 479 85 q 650 270 650 183 q 490 429 650 379 q 194 513 341 470 q 33 739 33 584 q 142 964 33 881 q 388 1041 242 1041 q 644 957 543 1041 q 756 716 756 867 l 625 716 q 561 874 625 816 q 395 933 497 933 q 243 891 309 933 q 164 759 164 841 q 325 609 164 656 q 625 526 475 568 q 788 291 788 454 `},"¦":{x_min:343,x_max:449,ha:792,o:`m 449 462 l 343 462 l 343 986 l 449 986 l 449 462 m 449 -242 l 343 -242 l 343 280 l 449 280 l 449 -242 `},"/":{x_min:183.25,x_max:608.328125,ha:792,o:`m 608 1041 l 266 -129 l 183 -129 l 520 1041 l 608 1041 `},Τ:{x_min:-.4375,x_max:777.453125,ha:839,o:`m 777 893 l 458 893 l 458 0 l 319 0 l 319 892 l 0 892 l 0 1013 l 777 1013 l 777 893 `},y:{x_min:0,x_max:684.78125,ha:771,o:`m 684 738 l 388 -83 q 311 -216 356 -167 q 173 -279 252 -279 q 97 -266 133 -279 l 97 -149 q 132 -155 109 -151 q 168 -160 155 -160 q 240 -114 213 -160 q 274 -26 248 -98 l 0 738 l 137 737 l 341 139 l 548 737 l 684 738 `},Π:{x_min:0,x_max:803,ha:917,o:`m 803 0 l 667 0 l 667 886 l 140 886 l 140 0 l 0 0 l 0 1012 l 803 1012 l 803 0 `},ΐ:{x_min:-111,x_max:339,ha:361,o:`m 339 800 l 229 800 l 229 925 l 339 925 l 339 800 m -1 800 l -111 800 l -111 925 l -1 925 l -1 800 m 284 3 q 233 -10 258 -5 q 182 -15 207 -15 q 85 26 119 -15 q 42 200 42 79 l 42 737 l 167 737 l 168 215 q 172 141 168 157 q 226 101 183 101 q 248 103 239 101 q 284 112 257 104 l 284 3 m 302 1040 l 113 819 l 30 819 l 165 1040 l 302 1040 `},g:{x_min:0,x_max:686,ha:838,o:`m 686 34 q 586 -213 686 -121 q 331 -306 487 -306 q 131 -252 216 -306 q 31 -84 31 -190 l 155 -84 q 228 -174 166 -138 q 345 -207 284 -207 q 514 -109 454 -207 q 564 89 564 -27 q 461 6 521 36 q 335 -23 401 -23 q 88 100 184 -23 q 0 370 0 215 q 87 634 0 522 q 330 758 183 758 q 457 728 398 758 q 564 644 515 699 l 564 737 l 686 737 l 686 34 m 582 367 q 529 560 582 481 q 358 652 468 652 q 189 561 250 652 q 135 369 135 482 q 189 176 135 255 q 361 85 251 85 q 529 176 468 85 q 582 367 582 255 `},"²":{x_min:0,x_max:442,ha:539,o:`m 442 383 l 0 383 q 91 566 0 492 q 260 668 176 617 q 354 798 354 727 q 315 875 354 845 q 227 905 277 905 q 136 869 173 905 q 99 761 99 833 l 14 761 q 82 922 14 864 q 232 974 141 974 q 379 926 316 974 q 442 797 442 878 q 351 635 442 704 q 183 539 321 611 q 92 455 92 491 l 442 455 l 442 383 `},"–":{x_min:0,x_max:705.5625,ha:803,o:`m 705 334 l 0 334 l 0 410 l 705 410 l 705 334 `},Κ:{x_min:0,x_max:819.5625,ha:893,o:`m 819 0 l 650 0 l 294 509 l 139 356 l 139 0 l 0 0 l 0 1013 l 139 1013 l 139 526 l 626 1013 l 809 1013 l 395 600 l 819 0 `},ƒ:{x_min:-46.265625,x_max:392,ha:513,o:`m 392 651 l 259 651 l 79 -279 l -46 -278 l 134 651 l 14 651 l 14 751 l 135 751 q 151 948 135 900 q 304 1041 185 1041 q 334 1040 319 1041 q 392 1034 348 1039 l 392 922 q 337 931 360 931 q 271 883 287 931 q 260 793 260 853 l 260 751 l 392 751 l 392 651 `},e:{x_min:0,x_max:714,ha:813,o:`m 714 326 l 140 326 q 200 157 140 227 q 359 87 260 87 q 488 130 431 87 q 561 245 545 174 l 697 245 q 577 48 670 123 q 358 -26 484 -26 q 97 85 195 -26 q 0 363 0 197 q 94 642 0 529 q 358 765 195 765 q 626 627 529 765 q 714 326 714 503 m 576 429 q 507 583 564 522 q 355 650 445 650 q 206 583 266 650 q 140 429 152 522 l 576 429 `},ό:{x_min:0,x_max:712,ha:815,o:`m 356 -25 q 94 91 194 -25 q 0 368 0 202 q 92 642 0 533 q 356 761 192 761 q 617 644 517 761 q 712 368 712 533 q 619 91 712 201 q 356 -25 520 -25 m 356 85 q 527 175 465 85 q 583 369 583 255 q 528 562 583 484 q 356 651 466 651 q 189 560 250 651 q 135 369 135 481 q 187 177 135 257 q 356 85 250 85 m 576 1040 l 387 819 l 303 819 l 438 1040 l 576 1040 `},J:{x_min:0,x_max:588,ha:699,o:`m 588 279 q 287 -26 588 -26 q 58 73 126 -26 q 0 327 0 158 l 133 327 q 160 172 133 227 q 288 96 198 96 q 426 171 391 96 q 449 336 449 219 l 449 1013 l 588 1013 l 588 279 `},"»":{x_min:-1,x_max:503,ha:601,o:`m 503 302 l 280 136 l 281 256 l 429 373 l 281 486 l 280 608 l 503 440 l 503 302 m 221 302 l 0 136 l 0 255 l 145 372 l 0 486 l -1 608 l 221 440 l 221 302 `},"©":{x_min:-3,x_max:1008,ha:1106,o:`m 502 -7 q 123 151 263 -7 q -3 501 -3 294 q 123 851 -3 706 q 502 1011 263 1011 q 881 851 739 1011 q 1008 501 1008 708 q 883 151 1008 292 q 502 -7 744 -7 m 502 60 q 830 197 709 60 q 940 501 940 322 q 831 805 940 681 q 502 944 709 944 q 174 805 296 944 q 65 501 65 680 q 173 197 65 320 q 502 60 294 60 m 741 394 q 661 246 731 302 q 496 190 591 190 q 294 285 369 190 q 228 497 228 370 q 295 714 228 625 q 499 813 370 813 q 656 762 588 813 q 733 625 724 711 l 634 625 q 589 704 629 673 q 498 735 550 735 q 377 666 421 735 q 334 504 334 597 q 374 340 334 408 q 490 272 415 272 q 589 304 549 272 q 638 394 628 337 l 741 394 `},ώ:{x_min:0,x_max:922,ha:1030,o:`m 687 1040 l 498 819 l 415 819 l 549 1040 l 687 1040 m 922 339 q 856 97 922 203 q 650 -26 780 -26 q 538 9 587 -26 q 461 103 489 44 q 387 12 436 46 q 277 -22 339 -22 q 69 97 147 -22 q 0 338 0 202 q 45 551 0 444 q 161 737 84 643 l 302 737 q 175 552 219 647 q 124 336 124 446 q 155 179 124 248 q 275 88 197 88 q 375 163 341 88 q 400 294 400 219 l 400 572 l 524 572 l 524 294 q 561 135 524 192 q 643 88 591 88 q 762 182 719 88 q 797 341 797 257 q 745 555 797 450 q 619 737 705 637 l 760 737 q 874 551 835 640 q 922 339 922 444 `},"^":{x_min:193.0625,x_max:598.609375,ha:792,o:`m 598 772 l 515 772 l 395 931 l 277 772 l 193 772 l 326 1013 l 462 1013 l 598 772 `},"«":{x_min:0,x_max:507.203125,ha:604,o:`m 506 136 l 284 302 l 284 440 l 506 608 l 507 485 l 360 371 l 506 255 l 506 136 m 222 136 l 0 302 l 0 440 l 222 608 l 221 486 l 73 373 l 222 256 l 222 136 `},D:{x_min:0,x_max:828,ha:935,o:`m 389 1013 q 714 867 593 1013 q 828 521 828 729 q 712 161 828 309 q 382 0 587 0 l 0 0 l 0 1013 l 389 1013 m 376 124 q 607 247 523 124 q 681 510 681 355 q 607 771 681 662 q 376 896 522 896 l 139 896 l 139 124 l 376 124 `},"∙":{x_min:0,x_max:142,ha:239,o:`m 142 585 l 0 585 l 0 738 l 142 738 l 142 585 `},ÿ:{x_min:0,x_max:47,ha:125,o:`m 47 3 q 37 -7 47 -7 q 28 0 30 -7 q 39 -4 32 -4 q 45 3 45 -1 l 37 0 q 28 9 28 0 q 39 19 28 19 l 47 16 l 47 19 l 47 3 m 37 1 q 44 8 44 1 q 37 16 44 16 q 30 8 30 16 q 37 1 30 1 m 26 1 l 23 22 l 14 0 l 3 22 l 3 3 l 0 25 l 13 1 l 22 25 l 26 1 `},w:{x_min:0,x_max:1009.71875,ha:1100,o:`m 1009 738 l 783 0 l 658 0 l 501 567 l 345 0 l 222 0 l 0 738 l 130 738 l 284 174 l 432 737 l 576 738 l 721 173 l 881 737 l 1009 738 `},$:{x_min:0,x_max:700,ha:793,o:`m 664 717 l 542 717 q 490 825 531 785 q 381 872 450 865 l 381 551 q 620 446 540 522 q 700 241 700 370 q 618 45 700 116 q 381 -25 536 -25 l 381 -152 l 307 -152 l 307 -25 q 81 62 162 -25 q 0 297 0 149 l 124 297 q 169 146 124 204 q 307 81 215 89 l 307 441 q 80 536 148 469 q 13 725 13 603 q 96 910 13 839 q 307 982 180 982 l 307 1077 l 381 1077 l 381 982 q 574 917 494 982 q 664 717 664 845 m 307 565 l 307 872 q 187 831 233 872 q 142 724 142 791 q 180 618 142 656 q 307 565 218 580 m 381 76 q 562 237 562 96 q 517 361 562 313 q 381 423 472 409 l 381 76 `},"\\":{x_min:-.015625,x_max:425.0625,ha:522,o:`m 425 -129 l 337 -129 l 0 1041 l 83 1041 l 425 -129 `},µ:{x_min:0,x_max:697.21875,ha:747,o:`m 697 -4 q 629 -14 658 -14 q 498 97 513 -14 q 422 9 470 41 q 313 -23 374 -23 q 207 4 258 -23 q 119 81 156 32 l 119 -278 l 0 -278 l 0 738 l 124 738 l 124 343 q 165 173 124 246 q 308 83 216 83 q 452 178 402 83 q 493 359 493 255 l 493 738 l 617 738 l 617 214 q 623 136 617 160 q 673 92 637 92 q 697 96 684 92 l 697 -4 `},Ι:{x_min:42,x_max:181,ha:297,o:`m 181 0 l 42 0 l 42 1013 l 181 1013 l 181 0 `},Ύ:{x_min:0,x_max:1144.5,ha:1214,o:`m 1144 1012 l 807 416 l 807 0 l 667 0 l 667 416 l 325 1012 l 465 1012 l 736 533 l 1004 1012 l 1144 1012 m 277 1040 l 83 799 l 0 799 l 140 1040 l 277 1040 `},"’":{x_min:0,x_max:139,ha:236,o:`m 139 851 q 102 737 139 784 q 0 669 65 690 l 0 734 q 59 787 42 741 q 72 873 72 821 l 0 873 l 0 1013 l 139 1013 l 139 851 `},Ν:{x_min:0,x_max:801,ha:915,o:`m 801 0 l 651 0 l 131 822 l 131 0 l 0 0 l 0 1013 l 151 1013 l 670 191 l 670 1013 l 801 1013 l 801 0 `},"-":{x_min:8.71875,x_max:350.390625,ha:478,o:`m 350 317 l 8 317 l 8 428 l 350 428 l 350 317 `},Q:{x_min:0,x_max:968,ha:1072,o:`m 954 5 l 887 -79 l 744 35 q 622 -11 687 2 q 483 -26 556 -26 q 127 130 262 -26 q 0 504 0 279 q 127 880 0 728 q 484 1041 262 1041 q 841 884 708 1041 q 968 507 968 735 q 933 293 968 398 q 832 104 899 188 l 954 5 m 723 191 q 802 330 777 248 q 828 499 828 412 q 744 790 828 673 q 483 922 650 922 q 228 791 322 922 q 142 505 142 673 q 227 221 142 337 q 487 91 323 91 q 632 123 566 91 l 520 215 l 587 301 l 723 191 `},ς:{x_min:1,x_max:676.28125,ha:740,o:`m 676 460 l 551 460 q 498 595 542 546 q 365 651 448 651 q 199 578 263 651 q 136 401 136 505 q 266 178 136 241 q 508 106 387 142 q 640 -50 640 62 q 625 -158 640 -105 q 583 -278 611 -211 l 465 -278 q 498 -182 490 -211 q 515 -80 515 -126 q 381 12 515 -15 q 134 91 197 51 q 1 388 1 179 q 100 651 1 542 q 354 761 199 761 q 587 680 498 761 q 676 460 676 599 `},M:{x_min:0,x_max:954,ha:1067,o:`m 954 0 l 819 0 l 819 869 l 537 0 l 405 0 l 128 866 l 128 0 l 0 0 l 0 1013 l 200 1013 l 472 160 l 757 1013 l 954 1013 l 954 0 `},Ψ:{x_min:0,x_max:1006,ha:1094,o:`m 1006 678 q 914 319 1006 429 q 571 200 814 200 l 571 0 l 433 0 l 433 200 q 92 319 194 200 q 0 678 0 429 l 0 1013 l 139 1013 l 139 679 q 191 417 139 492 q 433 326 255 326 l 433 1013 l 571 1013 l 571 326 l 580 326 q 813 423 747 326 q 868 679 868 502 l 868 1013 l 1006 1013 l 1006 678 `},C:{x_min:0,x_max:886,ha:944,o:`m 886 379 q 760 87 886 201 q 455 -26 634 -26 q 112 136 236 -26 q 0 509 0 283 q 118 882 0 737 q 469 1041 245 1041 q 748 955 630 1041 q 879 708 879 859 l 745 708 q 649 862 724 805 q 473 920 573 920 q 219 791 312 920 q 136 509 136 675 q 217 229 136 344 q 470 99 311 99 q 672 179 591 99 q 753 379 753 259 l 886 379 `},"!":{x_min:0,x_max:138,ha:236,o:`m 138 684 q 116 409 138 629 q 105 244 105 299 l 33 244 q 16 465 33 313 q 0 684 0 616 l 0 1013 l 138 1013 l 138 684 m 138 0 l 0 0 l 0 151 l 138 151 l 138 0 `},"{":{x_min:0,x_max:480.5625,ha:578,o:`m 480 -286 q 237 -213 303 -286 q 187 -45 187 -159 q 194 48 187 -15 q 201 141 201 112 q 164 264 201 225 q 0 314 118 314 l 0 417 q 164 471 119 417 q 201 605 201 514 q 199 665 201 644 q 193 772 193 769 q 241 941 193 887 q 480 1015 308 1015 l 480 915 q 336 866 375 915 q 306 742 306 828 q 310 662 306 717 q 314 577 314 606 q 288 452 314 500 q 176 365 256 391 q 289 275 257 337 q 314 143 314 226 q 313 84 314 107 q 310 -11 310 -5 q 339 -131 310 -94 q 480 -182 377 -182 l 480 -286 `},X:{x_min:-.015625,x_max:854.15625,ha:940,o:`m 854 0 l 683 0 l 423 409 l 166 0 l 0 0 l 347 519 l 18 1013 l 186 1013 l 428 637 l 675 1013 l 836 1013 l 504 520 l 854 0 `},"#":{x_min:0,x_max:963.890625,ha:1061,o:`m 963 690 l 927 590 l 719 590 l 655 410 l 876 410 l 840 310 l 618 310 l 508 -3 l 393 -2 l 506 309 l 329 310 l 215 -2 l 102 -3 l 212 310 l 0 310 l 36 410 l 248 409 l 312 590 l 86 590 l 120 690 l 347 690 l 459 1006 l 573 1006 l 462 690 l 640 690 l 751 1006 l 865 1006 l 754 690 l 963 690 m 606 590 l 425 590 l 362 410 l 543 410 l 606 590 `},ι:{x_min:42,x_max:284,ha:361,o:`m 284 3 q 233 -10 258 -5 q 182 -15 207 -15 q 85 26 119 -15 q 42 200 42 79 l 42 738 l 167 738 l 168 215 q 172 141 168 157 q 226 101 183 101 q 248 103 239 101 q 284 112 257 104 l 284 3 `},Ά:{x_min:0,x_max:906.953125,ha:982,o:`m 283 1040 l 88 799 l 5 799 l 145 1040 l 283 1040 m 906 0 l 756 0 l 650 303 l 251 303 l 143 0 l 0 0 l 376 1012 l 529 1012 l 906 0 m 609 421 l 452 866 l 293 421 l 609 421 `},")":{x_min:0,x_max:318,ha:415,o:`m 318 365 q 257 25 318 191 q 87 -290 197 -141 l 0 -290 q 140 21 93 -128 q 193 360 193 189 q 141 704 193 537 q 0 1024 97 850 l 87 1024 q 257 706 197 871 q 318 365 318 542 `},ε:{x_min:0,x_max:634.71875,ha:714,o:`m 634 234 q 527 38 634 110 q 300 -25 433 -25 q 98 29 183 -25 q 0 204 0 93 q 37 314 0 265 q 128 390 67 353 q 56 460 82 419 q 26 555 26 505 q 114 712 26 654 q 295 763 191 763 q 499 700 416 763 q 589 515 589 631 l 478 515 q 419 618 464 580 q 307 657 374 657 q 207 630 253 657 q 151 547 151 598 q 238 445 151 469 q 389 434 280 434 l 389 331 l 349 331 q 206 315 255 331 q 125 210 125 287 q 183 107 125 145 q 302 76 233 76 q 436 117 379 76 q 509 234 493 159 l 634 234 `},Δ:{x_min:0,x_max:952.78125,ha:1028,o:`m 952 0 l 0 0 l 400 1013 l 551 1013 l 952 0 m 762 124 l 476 867 l 187 124 l 762 124 `},"}":{x_min:0,x_max:481,ha:578,o:`m 481 314 q 318 262 364 314 q 282 136 282 222 q 284 65 282 97 q 293 -58 293 -48 q 241 -217 293 -166 q 0 -286 174 -286 l 0 -182 q 143 -130 105 -182 q 171 -2 171 -93 q 168 81 171 22 q 165 144 165 140 q 188 275 165 229 q 306 365 220 339 q 191 455 224 391 q 165 588 165 505 q 168 681 165 624 q 171 742 171 737 q 141 865 171 827 q 0 915 102 915 l 0 1015 q 243 942 176 1015 q 293 773 293 888 q 287 675 293 741 q 282 590 282 608 q 318 466 282 505 q 481 417 364 417 l 481 314 `},"‰":{x_min:-3,x_max:1672,ha:1821,o:`m 846 0 q 664 76 732 0 q 603 244 603 145 q 662 412 603 344 q 846 489 729 489 q 1027 412 959 489 q 1089 244 1089 343 q 1029 76 1089 144 q 846 0 962 0 m 845 103 q 945 143 910 103 q 981 243 981 184 q 947 340 981 301 q 845 385 910 385 q 745 342 782 385 q 709 243 709 300 q 742 147 709 186 q 845 103 781 103 m 888 986 l 284 -25 l 199 -25 l 803 986 l 888 986 m 241 468 q 58 545 126 468 q -3 715 -3 615 q 56 881 -3 813 q 238 958 124 958 q 421 881 353 958 q 483 712 483 813 q 423 544 483 612 q 241 468 356 468 m 241 855 q 137 811 175 855 q 100 710 100 768 q 136 612 100 653 q 240 572 172 572 q 344 614 306 572 q 382 713 382 656 q 347 810 382 771 q 241 855 308 855 m 1428 0 q 1246 76 1314 0 q 1185 244 1185 145 q 1244 412 1185 344 q 1428 489 1311 489 q 1610 412 1542 489 q 1672 244 1672 343 q 1612 76 1672 144 q 1428 0 1545 0 m 1427 103 q 1528 143 1492 103 q 1564 243 1564 184 q 1530 340 1564 301 q 1427 385 1492 385 q 1327 342 1364 385 q 1291 243 1291 300 q 1324 147 1291 186 q 1427 103 1363 103 `},a:{x_min:0,x_max:698.609375,ha:794,o:`m 698 0 q 661 -12 679 -7 q 615 -17 643 -17 q 536 12 564 -17 q 500 96 508 41 q 384 6 456 37 q 236 -25 312 -25 q 65 31 130 -25 q 0 194 0 88 q 118 390 0 334 q 328 435 180 420 q 488 483 476 451 q 495 523 495 504 q 442 619 495 584 q 325 654 389 654 q 209 617 257 654 q 152 513 161 580 l 33 513 q 123 705 33 633 q 332 772 207 772 q 528 712 448 772 q 617 531 617 645 l 617 163 q 624 108 617 126 q 664 90 632 90 l 698 94 l 698 0 m 491 262 l 491 372 q 272 329 350 347 q 128 201 128 294 q 166 113 128 144 q 264 83 205 83 q 414 130 346 83 q 491 262 491 183 `},"—":{x_min:0,x_max:941.671875,ha:1039,o:`m 941 334 l 0 334 l 0 410 l 941 410 l 941 334 `},"=":{x_min:8.71875,x_max:780.953125,ha:792,o:`m 780 510 l 8 510 l 8 606 l 780 606 l 780 510 m 780 235 l 8 235 l 8 332 l 780 332 l 780 235 `},N:{x_min:0,x_max:801,ha:914,o:`m 801 0 l 651 0 l 131 823 l 131 0 l 0 0 l 0 1013 l 151 1013 l 670 193 l 670 1013 l 801 1013 l 801 0 `},ρ:{x_min:0,x_max:712,ha:797,o:`m 712 369 q 620 94 712 207 q 362 -26 521 -26 q 230 2 292 -26 q 119 83 167 30 l 119 -278 l 0 -278 l 0 362 q 91 643 0 531 q 355 764 190 764 q 617 647 517 764 q 712 369 712 536 m 583 366 q 530 559 583 480 q 359 651 469 651 q 190 562 252 651 q 135 370 135 483 q 189 176 135 257 q 359 85 250 85 q 528 175 466 85 q 583 366 583 254 `},"¯":{x_min:0,x_max:941.671875,ha:938,o:`m 941 1033 l 0 1033 l 0 1109 l 941 1109 l 941 1033 `},Z:{x_min:0,x_max:779,ha:849,o:`m 779 0 l 0 0 l 0 113 l 621 896 l 40 896 l 40 1013 l 779 1013 l 778 887 l 171 124 l 779 124 l 779 0 `},u:{x_min:0,x_max:617,ha:729,o:`m 617 0 l 499 0 l 499 110 q 391 10 460 45 q 246 -25 322 -25 q 61 58 127 -25 q 0 258 0 136 l 0 738 l 125 738 l 125 284 q 156 148 125 202 q 273 82 197 82 q 433 165 369 82 q 493 340 493 243 l 493 738 l 617 738 l 617 0 `},k:{x_min:0,x_max:612.484375,ha:697,o:`m 612 738 l 338 465 l 608 0 l 469 0 l 251 382 l 121 251 l 121 0 l 0 0 l 0 1013 l 121 1013 l 121 402 l 456 738 l 612 738 `},Η:{x_min:0,x_max:803,ha:917,o:`m 803 0 l 667 0 l 667 475 l 140 475 l 140 0 l 0 0 l 0 1013 l 140 1013 l 140 599 l 667 599 l 667 1013 l 803 1013 l 803 0 `},Α:{x_min:0,x_max:906.953125,ha:985,o:`m 906 0 l 756 0 l 650 303 l 251 303 l 143 0 l 0 0 l 376 1013 l 529 1013 l 906 0 m 609 421 l 452 866 l 293 421 l 609 421 `},s:{x_min:0,x_max:604,ha:697,o:`m 604 217 q 501 36 604 104 q 292 -23 411 -23 q 86 43 166 -23 q 0 238 0 114 l 121 237 q 175 122 121 164 q 300 85 223 85 q 415 112 363 85 q 479 207 479 147 q 361 309 479 276 q 140 372 141 370 q 21 544 21 426 q 111 708 21 647 q 298 761 190 761 q 492 705 413 761 q 583 531 583 643 l 462 531 q 412 625 462 594 q 298 657 363 657 q 199 636 242 657 q 143 558 143 608 q 262 454 143 486 q 484 394 479 397 q 604 217 604 341 `},B:{x_min:0,x_max:778,ha:876,o:`m 580 546 q 724 469 670 535 q 778 311 778 403 q 673 83 778 171 q 432 0 575 0 l 0 0 l 0 1013 l 411 1013 q 629 957 541 1013 q 732 768 732 892 q 691 633 732 693 q 580 546 650 572 m 393 899 l 139 899 l 139 588 l 379 588 q 521 624 462 588 q 592 744 592 667 q 531 859 592 819 q 393 899 471 899 m 419 124 q 566 169 504 124 q 635 303 635 219 q 559 436 635 389 q 402 477 494 477 l 139 477 l 139 124 l 419 124 `},"…":{x_min:0,x_max:614,ha:708,o:`m 142 0 l 0 0 l 0 151 l 142 151 l 142 0 m 378 0 l 236 0 l 236 151 l 378 151 l 378 0 m 614 0 l 472 0 l 472 151 l 614 151 l 614 0 `},"?":{x_min:0,x_max:607,ha:704,o:`m 607 777 q 543 599 607 674 q 422 474 482 537 q 357 272 357 391 l 236 272 q 297 487 236 395 q 411 619 298 490 q 474 762 474 691 q 422 885 474 838 q 301 933 371 933 q 179 880 228 933 q 124 706 124 819 l 0 706 q 94 963 0 872 q 302 1044 177 1044 q 511 973 423 1044 q 607 777 607 895 m 370 0 l 230 0 l 230 151 l 370 151 l 370 0 `},H:{x_min:0,x_max:803,ha:915,o:`m 803 0 l 667 0 l 667 475 l 140 475 l 140 0 l 0 0 l 0 1013 l 140 1013 l 140 599 l 667 599 l 667 1013 l 803 1013 l 803 0 `},ν:{x_min:0,x_max:675,ha:761,o:`m 675 738 l 404 0 l 272 0 l 0 738 l 133 738 l 340 147 l 541 738 l 675 738 `},c:{x_min:1,x_max:701.390625,ha:775,o:`m 701 264 q 584 53 681 133 q 353 -26 487 -26 q 91 91 188 -26 q 1 370 1 201 q 92 645 1 537 q 353 761 190 761 q 572 688 479 761 q 690 493 666 615 l 556 493 q 487 606 545 562 q 356 650 428 650 q 186 563 246 650 q 134 372 134 487 q 188 179 134 258 q 359 88 250 88 q 492 136 437 88 q 566 264 548 185 l 701 264 `},"¶":{x_min:0,x_max:566.671875,ha:678,o:`m 21 892 l 52 892 l 98 761 l 145 892 l 176 892 l 178 741 l 157 741 l 157 867 l 108 741 l 88 741 l 40 871 l 40 741 l 21 741 l 21 892 m 308 854 l 308 731 q 252 691 308 691 q 227 691 240 691 q 207 696 213 695 l 207 712 l 253 706 q 288 733 288 706 l 288 763 q 244 741 279 741 q 193 797 193 741 q 261 860 193 860 q 287 860 273 860 q 308 854 302 855 m 288 842 l 263 843 q 213 796 213 843 q 248 756 213 756 q 288 796 288 756 l 288 842 m 566 988 l 502 988 l 502 -1 l 439 -1 l 439 988 l 317 988 l 317 -1 l 252 -1 l 252 602 q 81 653 155 602 q 0 805 0 711 q 101 989 0 918 q 309 1053 194 1053 l 566 1053 l 566 988 `},β:{x_min:0,x_max:660,ha:745,o:`m 471 550 q 610 450 561 522 q 660 280 660 378 q 578 64 660 151 q 367 -22 497 -22 q 239 5 299 -22 q 126 82 178 32 l 126 -278 l 0 -278 l 0 593 q 54 903 0 801 q 318 1042 127 1042 q 519 964 436 1042 q 603 771 603 887 q 567 644 603 701 q 471 550 532 586 m 337 79 q 476 138 418 79 q 535 279 535 198 q 427 437 535 386 q 226 477 344 477 l 226 583 q 398 620 329 583 q 486 762 486 668 q 435 884 486 833 q 312 935 384 935 q 169 861 219 935 q 126 698 126 797 l 126 362 q 170 169 126 242 q 337 79 224 79 `},Μ:{x_min:0,x_max:954,ha:1068,o:`m 954 0 l 819 0 l 819 868 l 537 0 l 405 0 l 128 865 l 128 0 l 0 0 l 0 1013 l 199 1013 l 472 158 l 758 1013 l 954 1013 l 954 0 `},Ό:{x_min:.109375,x_max:1120,ha:1217,o:`m 1120 505 q 994 132 1120 282 q 642 -29 861 -29 q 290 130 422 -29 q 167 505 167 280 q 294 883 167 730 q 650 1046 430 1046 q 999 882 868 1046 q 1120 505 1120 730 m 977 504 q 896 784 977 669 q 644 915 804 915 q 391 785 484 915 q 307 504 307 669 q 391 224 307 339 q 644 95 486 95 q 894 224 803 95 q 977 504 977 339 m 277 1040 l 83 799 l 0 799 l 140 1040 l 277 1040 `},Ή:{x_min:0,x_max:1158,ha:1275,o:`m 1158 0 l 1022 0 l 1022 475 l 496 475 l 496 0 l 356 0 l 356 1012 l 496 1012 l 496 599 l 1022 599 l 1022 1012 l 1158 1012 l 1158 0 m 277 1040 l 83 799 l 0 799 l 140 1040 l 277 1040 `},"•":{x_min:0,x_max:663.890625,ha:775,o:`m 663 529 q 566 293 663 391 q 331 196 469 196 q 97 294 194 196 q 0 529 0 393 q 96 763 0 665 q 331 861 193 861 q 566 763 469 861 q 663 529 663 665 `},"¥":{x_min:.1875,x_max:819.546875,ha:886,o:`m 563 561 l 697 561 l 696 487 l 520 487 l 482 416 l 482 380 l 697 380 l 695 308 l 482 308 l 482 0 l 342 0 l 342 308 l 125 308 l 125 380 l 342 380 l 342 417 l 303 487 l 125 487 l 125 561 l 258 561 l 0 1013 l 140 1013 l 411 533 l 679 1013 l 819 1013 l 563 561 `},"(":{x_min:0,x_max:318.0625,ha:415,o:`m 318 -290 l 230 -290 q 61 23 122 -142 q 0 365 0 190 q 62 712 0 540 q 230 1024 119 869 l 318 1024 q 175 705 219 853 q 125 360 125 542 q 176 22 125 187 q 318 -290 223 -127 `},U:{x_min:0,x_max:796,ha:904,o:`m 796 393 q 681 93 796 212 q 386 -25 566 -25 q 101 95 208 -25 q 0 393 0 211 l 0 1013 l 138 1013 l 138 391 q 204 191 138 270 q 394 107 276 107 q 586 191 512 107 q 656 391 656 270 l 656 1013 l 796 1013 l 796 393 `},γ:{x_min:.5,x_max:744.953125,ha:822,o:`m 744 737 l 463 54 l 463 -278 l 338 -278 l 338 54 l 154 495 q 104 597 124 569 q 13 651 67 651 l 0 651 l 0 751 l 39 753 q 168 711 121 753 q 242 594 207 676 l 403 208 l 617 737 l 744 737 `},α:{x_min:0,x_max:765.5625,ha:809,o:`m 765 -4 q 698 -14 726 -14 q 564 97 586 -14 q 466 7 525 40 q 337 -26 407 -26 q 88 98 186 -26 q 0 369 0 212 q 88 637 0 525 q 337 760 184 760 q 465 728 407 760 q 563 637 524 696 l 563 739 l 685 739 l 685 222 q 693 141 685 168 q 748 94 708 94 q 765 96 760 94 l 765 -4 m 584 371 q 531 562 584 485 q 360 653 470 653 q 192 566 254 653 q 135 379 135 489 q 186 181 135 261 q 358 84 247 84 q 528 176 465 84 q 584 371 584 260 `},F:{x_min:0,x_max:683.328125,ha:717,o:`m 683 888 l 140 888 l 140 583 l 613 583 l 613 458 l 140 458 l 140 0 l 0 0 l 0 1013 l 683 1013 l 683 888 `},"­":{x_min:0,x_max:705.5625,ha:803,o:`m 705 334 l 0 334 l 0 410 l 705 410 l 705 334 `},":":{x_min:0,x_max:142,ha:239,o:`m 142 585 l 0 585 l 0 738 l 142 738 l 142 585 m 142 0 l 0 0 l 0 151 l 142 151 l 142 0 `},Χ:{x_min:0,x_max:854.171875,ha:935,o:`m 854 0 l 683 0 l 423 409 l 166 0 l 0 0 l 347 519 l 18 1013 l 186 1013 l 427 637 l 675 1013 l 836 1013 l 504 521 l 854 0 `},"*":{x_min:116,x_max:674,ha:792,o:`m 674 768 l 475 713 l 610 544 l 517 477 l 394 652 l 272 478 l 178 544 l 314 713 l 116 766 l 153 876 l 341 812 l 342 1013 l 446 1013 l 446 811 l 635 874 l 674 768 `},"†":{x_min:0,x_max:777,ha:835,o:`m 458 804 l 777 804 l 777 683 l 458 683 l 458 0 l 319 0 l 319 681 l 0 683 l 0 804 l 319 804 l 319 1015 l 458 1013 l 458 804 `},"°":{x_min:0,x_max:347,ha:444,o:`m 173 802 q 43 856 91 802 q 0 977 0 905 q 45 1101 0 1049 q 173 1153 90 1153 q 303 1098 255 1153 q 347 977 347 1049 q 303 856 347 905 q 173 802 256 802 m 173 884 q 238 910 214 884 q 262 973 262 937 q 239 1038 262 1012 q 173 1064 217 1064 q 108 1037 132 1064 q 85 973 85 1010 q 108 910 85 937 q 173 884 132 884 `},V:{x_min:0,x_max:862.71875,ha:940,o:`m 862 1013 l 505 0 l 361 0 l 0 1013 l 143 1013 l 434 165 l 718 1012 l 862 1013 `},Ξ:{x_min:0,x_max:734.71875,ha:763,o:`m 723 889 l 9 889 l 9 1013 l 723 1013 l 723 889 m 673 463 l 61 463 l 61 589 l 673 589 l 673 463 m 734 0 l 0 0 l 0 124 l 734 124 l 734 0 `},"\xA0":{x_min:0,x_max:0,ha:853},Ϋ:{x_min:.328125,x_max:819.515625,ha:889,o:`m 588 1046 l 460 1046 l 460 1189 l 588 1189 l 588 1046 m 360 1046 l 232 1046 l 232 1189 l 360 1189 l 360 1046 m 819 1012 l 482 416 l 482 0 l 342 0 l 342 416 l 0 1012 l 140 1012 l 411 533 l 679 1012 l 819 1012 `},"”":{x_min:0,x_max:347,ha:454,o:`m 139 851 q 102 737 139 784 q 0 669 65 690 l 0 734 q 59 787 42 741 q 72 873 72 821 l 0 873 l 0 1013 l 139 1013 l 139 851 m 347 851 q 310 737 347 784 q 208 669 273 690 l 208 734 q 267 787 250 741 q 280 873 280 821 l 208 873 l 208 1013 l 347 1013 l 347 851 `},"@":{x_min:0,x_max:1260,ha:1357,o:`m 1098 -45 q 877 -160 1001 -117 q 633 -203 752 -203 q 155 -29 327 -203 q 0 360 0 127 q 176 802 0 616 q 687 1008 372 1008 q 1123 854 969 1008 q 1260 517 1260 718 q 1155 216 1260 341 q 868 82 1044 82 q 772 106 801 82 q 737 202 737 135 q 647 113 700 144 q 527 82 594 82 q 367 147 420 82 q 314 312 314 212 q 401 565 314 452 q 639 690 498 690 q 810 588 760 690 l 849 668 l 938 668 q 877 441 900 532 q 833 226 833 268 q 853 182 833 198 q 902 167 873 167 q 1088 272 1012 167 q 1159 512 1159 372 q 1051 793 1159 681 q 687 925 925 925 q 248 747 415 925 q 97 361 97 586 q 226 26 97 159 q 627 -122 370 -122 q 856 -87 737 -122 q 1061 8 976 -53 l 1098 -45 m 786 488 q 738 580 777 545 q 643 615 700 615 q 483 517 548 615 q 425 322 425 430 q 457 203 425 250 q 552 156 490 156 q 722 273 665 156 q 786 488 738 309 `},Ί:{x_min:0,x_max:499,ha:613,o:`m 277 1040 l 83 799 l 0 799 l 140 1040 l 277 1040 m 499 0 l 360 0 l 360 1012 l 499 1012 l 499 0 `},i:{x_min:14,x_max:136,ha:275,o:`m 136 873 l 14 873 l 14 1013 l 136 1013 l 136 873 m 136 0 l 14 0 l 14 737 l 136 737 l 136 0 `},Β:{x_min:0,x_max:778,ha:877,o:`m 580 545 q 724 468 671 534 q 778 310 778 402 q 673 83 778 170 q 432 0 575 0 l 0 0 l 0 1013 l 411 1013 q 629 957 541 1013 q 732 768 732 891 q 691 632 732 692 q 580 545 650 571 m 393 899 l 139 899 l 139 587 l 379 587 q 521 623 462 587 q 592 744 592 666 q 531 859 592 819 q 393 899 471 899 m 419 124 q 566 169 504 124 q 635 302 635 219 q 559 435 635 388 q 402 476 494 476 l 139 476 l 139 124 l 419 124 `},υ:{x_min:0,x_max:617,ha:725,o:`m 617 352 q 540 94 617 199 q 308 -24 455 -24 q 76 94 161 -24 q 0 352 0 199 l 0 739 l 126 739 l 126 355 q 169 185 126 257 q 312 98 220 98 q 451 185 402 98 q 492 355 492 257 l 492 739 l 617 739 l 617 352 `},"]":{x_min:0,x_max:275,ha:372,o:`m 275 -281 l 0 -281 l 0 -187 l 151 -187 l 151 920 l 0 920 l 0 1013 l 275 1013 l 275 -281 `},m:{x_min:0,x_max:1019,ha:1128,o:`m 1019 0 l 897 0 l 897 454 q 860 591 897 536 q 739 660 816 660 q 613 586 659 660 q 573 436 573 522 l 573 0 l 447 0 l 447 455 q 412 591 447 535 q 294 657 372 657 q 165 586 213 657 q 122 437 122 521 l 122 0 l 0 0 l 0 738 l 117 738 l 117 640 q 202 730 150 697 q 316 763 254 763 q 437 730 381 763 q 525 642 494 697 q 621 731 559 700 q 753 763 682 763 q 943 694 867 763 q 1019 512 1019 625 l 1019 0 `},χ:{x_min:8.328125,x_max:780.5625,ha:815,o:`m 780 -278 q 715 -294 747 -294 q 616 -257 663 -294 q 548 -175 576 -227 l 379 133 l 143 -277 l 9 -277 l 313 254 l 163 522 q 127 586 131 580 q 36 640 91 640 q 8 637 27 640 l 8 752 l 52 757 q 162 719 113 757 q 236 627 200 690 l 383 372 l 594 737 l 726 737 l 448 250 l 625 -69 q 670 -153 647 -110 q 743 -188 695 -188 q 780 -184 759 -188 l 780 -278 `},ί:{x_min:42,x_max:326.71875,ha:361,o:`m 284 3 q 233 -10 258 -5 q 182 -15 207 -15 q 85 26 119 -15 q 42 200 42 79 l 42 737 l 167 737 l 168 215 q 172 141 168 157 q 226 101 183 101 q 248 102 239 101 q 284 112 257 104 l 284 3 m 326 1040 l 137 819 l 54 819 l 189 1040 l 326 1040 `},Ζ:{x_min:0,x_max:779.171875,ha:850,o:`m 779 0 l 0 0 l 0 113 l 620 896 l 40 896 l 40 1013 l 779 1013 l 779 887 l 170 124 l 779 124 l 779 0 `},R:{x_min:0,x_max:781.953125,ha:907,o:`m 781 0 l 623 0 q 587 242 590 52 q 407 433 585 433 l 138 433 l 138 0 l 0 0 l 0 1013 l 396 1013 q 636 946 539 1013 q 749 731 749 868 q 711 597 749 659 q 608 502 674 534 q 718 370 696 474 q 729 207 722 352 q 781 26 736 62 l 781 0 m 373 551 q 533 594 465 551 q 614 731 614 645 q 532 859 614 815 q 373 896 465 896 l 138 896 l 138 551 l 373 551 `},o:{x_min:0,x_max:713,ha:821,o:`m 357 -25 q 94 91 194 -25 q 0 368 0 202 q 93 642 0 533 q 357 761 193 761 q 618 644 518 761 q 713 368 713 533 q 619 91 713 201 q 357 -25 521 -25 m 357 85 q 528 175 465 85 q 584 369 584 255 q 529 562 584 484 q 357 651 467 651 q 189 560 250 651 q 135 369 135 481 q 187 177 135 257 q 357 85 250 85 `},K:{x_min:0,x_max:819.46875,ha:906,o:`m 819 0 l 649 0 l 294 509 l 139 355 l 139 0 l 0 0 l 0 1013 l 139 1013 l 139 526 l 626 1013 l 809 1013 l 395 600 l 819 0 `},",":{x_min:0,x_max:142,ha:239,o:`m 142 -12 q 105 -132 142 -82 q 0 -205 68 -182 l 0 -138 q 57 -82 40 -124 q 70 0 70 -51 l 0 0 l 0 151 l 142 151 l 142 -12 `},d:{x_min:0,x_max:683,ha:796,o:`m 683 0 l 564 0 l 564 93 q 456 6 516 38 q 327 -25 395 -25 q 87 100 181 -25 q 0 365 0 215 q 90 639 0 525 q 343 763 187 763 q 564 647 486 763 l 564 1013 l 683 1013 l 683 0 m 582 373 q 529 562 582 484 q 361 653 468 653 q 190 561 253 653 q 135 365 135 479 q 189 175 135 254 q 358 85 251 85 q 529 178 468 85 q 582 373 582 258 `},"¨":{x_min:-109,x_max:247,ha:232,o:`m 247 1046 l 119 1046 l 119 1189 l 247 1189 l 247 1046 m 19 1046 l -109 1046 l -109 1189 l 19 1189 l 19 1046 `},E:{x_min:0,x_max:736.109375,ha:789,o:`m 736 0 l 0 0 l 0 1013 l 725 1013 l 725 889 l 139 889 l 139 585 l 677 585 l 677 467 l 139 467 l 139 125 l 736 125 l 736 0 `},Y:{x_min:0,x_max:820,ha:886,o:`m 820 1013 l 482 416 l 482 0 l 342 0 l 342 416 l 0 1013 l 140 1013 l 411 534 l 679 1012 l 820 1013 `},'"':{x_min:0,x_max:299,ha:396,o:`m 299 606 l 203 606 l 203 988 l 299 988 l 299 606 m 96 606 l 0 606 l 0 988 l 96 988 l 96 606 `},"‹":{x_min:17.984375,x_max:773.609375,ha:792,o:`m 773 40 l 18 376 l 17 465 l 773 799 l 773 692 l 159 420 l 773 149 l 773 40 `},"„":{x_min:0,x_max:364,ha:467,o:`m 141 -12 q 104 -132 141 -82 q 0 -205 67 -182 l 0 -138 q 56 -82 40 -124 q 69 0 69 -51 l 0 0 l 0 151 l 141 151 l 141 -12 m 364 -12 q 327 -132 364 -82 q 222 -205 290 -182 l 222 -138 q 279 -82 262 -124 q 292 0 292 -51 l 222 0 l 222 151 l 364 151 l 364 -12 `},δ:{x_min:1,x_max:710,ha:810,o:`m 710 360 q 616 87 710 196 q 356 -28 518 -28 q 99 82 197 -28 q 1 356 1 192 q 100 606 1 509 q 355 703 199 703 q 180 829 288 754 q 70 903 124 866 l 70 1012 l 643 1012 l 643 901 l 258 901 q 462 763 422 794 q 636 592 577 677 q 710 360 710 485 m 584 365 q 552 501 584 447 q 451 602 521 555 q 372 611 411 611 q 197 541 258 611 q 136 355 136 472 q 190 171 136 245 q 358 85 252 85 q 528 173 465 85 q 584 365 584 252 `},έ:{x_min:0,x_max:634.71875,ha:714,o:`m 634 234 q 527 38 634 110 q 300 -25 433 -25 q 98 29 183 -25 q 0 204 0 93 q 37 313 0 265 q 128 390 67 352 q 56 459 82 419 q 26 555 26 505 q 114 712 26 654 q 295 763 191 763 q 499 700 416 763 q 589 515 589 631 l 478 515 q 419 618 464 580 q 307 657 374 657 q 207 630 253 657 q 151 547 151 598 q 238 445 151 469 q 389 434 280 434 l 389 331 l 349 331 q 206 315 255 331 q 125 210 125 287 q 183 107 125 145 q 302 76 233 76 q 436 117 379 76 q 509 234 493 159 l 634 234 m 520 1040 l 331 819 l 248 819 l 383 1040 l 520 1040 `},ω:{x_min:0,x_max:922,ha:1031,o:`m 922 339 q 856 97 922 203 q 650 -26 780 -26 q 538 9 587 -26 q 461 103 489 44 q 387 12 436 46 q 277 -22 339 -22 q 69 97 147 -22 q 0 339 0 203 q 45 551 0 444 q 161 738 84 643 l 302 738 q 175 553 219 647 q 124 336 124 446 q 155 179 124 249 q 275 88 197 88 q 375 163 341 88 q 400 294 400 219 l 400 572 l 524 572 l 524 294 q 561 135 524 192 q 643 88 591 88 q 762 182 719 88 q 797 342 797 257 q 745 556 797 450 q 619 738 705 638 l 760 738 q 874 551 835 640 q 922 339 922 444 `},"´":{x_min:0,x_max:96,ha:251,o:`m 96 606 l 0 606 l 0 988 l 96 988 l 96 606 `},"±":{x_min:11,x_max:781,ha:792,o:`m 781 490 l 446 490 l 446 255 l 349 255 l 349 490 l 11 490 l 11 586 l 349 586 l 349 819 l 446 819 l 446 586 l 781 586 l 781 490 m 781 21 l 11 21 l 11 115 l 781 115 l 781 21 `},"|":{x_min:343,x_max:449,ha:792,o:`m 449 462 l 343 462 l 343 986 l 449 986 l 449 462 m 449 -242 l 343 -242 l 343 280 l 449 280 l 449 -242 `},ϋ:{x_min:0,x_max:617,ha:725,o:`m 482 800 l 372 800 l 372 925 l 482 925 l 482 800 m 239 800 l 129 800 l 129 925 l 239 925 l 239 800 m 617 352 q 540 93 617 199 q 308 -24 455 -24 q 76 93 161 -24 q 0 352 0 199 l 0 738 l 126 738 l 126 354 q 169 185 126 257 q 312 98 220 98 q 451 185 402 98 q 492 354 492 257 l 492 738 l 617 738 l 617 352 `},"§":{x_min:0,x_max:593,ha:690,o:`m 593 425 q 554 312 593 369 q 467 233 516 254 q 537 83 537 172 q 459 -74 537 -12 q 288 -133 387 -133 q 115 -69 184 -133 q 47 96 47 -6 l 166 96 q 199 7 166 40 q 288 -26 232 -26 q 371 -5 332 -26 q 420 60 420 21 q 311 201 420 139 q 108 309 210 255 q 0 490 0 383 q 33 602 0 551 q 124 687 66 654 q 75 743 93 712 q 58 812 58 773 q 133 984 58 920 q 300 1043 201 1043 q 458 987 394 1043 q 529 814 529 925 l 411 814 q 370 908 404 877 q 289 939 336 939 q 213 911 246 939 q 180 841 180 883 q 286 720 180 779 q 484 612 480 615 q 593 425 593 534 m 467 409 q 355 544 467 473 q 196 630 228 612 q 146 587 162 609 q 124 525 124 558 q 239 387 124 462 q 398 298 369 315 q 448 345 429 316 q 467 409 467 375 `},b:{x_min:0,x_max:685,ha:783,o:`m 685 372 q 597 99 685 213 q 347 -25 501 -25 q 219 5 277 -25 q 121 93 161 36 l 121 0 l 0 0 l 0 1013 l 121 1013 l 121 634 q 214 723 157 692 q 341 754 272 754 q 591 637 493 754 q 685 372 685 526 m 554 356 q 499 550 554 470 q 328 644 437 644 q 162 556 223 644 q 108 369 108 478 q 160 176 108 256 q 330 83 221 83 q 498 169 435 83 q 554 356 554 245 `},q:{x_min:0,x_max:683,ha:876,o:`m 683 -278 l 564 -278 l 564 97 q 474 8 533 39 q 345 -23 415 -23 q 91 93 188 -23 q 0 364 0 203 q 87 635 0 522 q 337 760 184 760 q 466 727 408 760 q 564 637 523 695 l 564 737 l 683 737 l 683 -278 m 582 375 q 527 564 582 488 q 358 652 466 652 q 190 565 253 652 q 135 377 135 488 q 189 179 135 261 q 361 84 251 84 q 530 179 469 84 q 582 375 582 260 `},Ω:{x_min:-.171875,x_max:969.5625,ha:1068,o:`m 969 0 l 555 0 l 555 123 q 744 308 675 194 q 814 558 814 423 q 726 812 814 709 q 484 922 633 922 q 244 820 334 922 q 154 567 154 719 q 223 316 154 433 q 412 123 292 199 l 412 0 l 0 0 l 0 124 l 217 124 q 68 327 122 210 q 15 572 15 444 q 144 911 15 781 q 484 1041 274 1041 q 822 909 691 1041 q 953 569 953 777 q 899 326 953 443 q 750 124 846 210 l 969 124 l 969 0 `},ύ:{x_min:0,x_max:617,ha:725,o:`m 617 352 q 540 93 617 199 q 308 -24 455 -24 q 76 93 161 -24 q 0 352 0 199 l 0 738 l 126 738 l 126 354 q 169 185 126 257 q 312 98 220 98 q 451 185 402 98 q 492 354 492 257 l 492 738 l 617 738 l 617 352 m 535 1040 l 346 819 l 262 819 l 397 1040 l 535 1040 `},z:{x_min:-.015625,x_max:613.890625,ha:697,o:`m 613 0 l 0 0 l 0 100 l 433 630 l 20 630 l 20 738 l 594 738 l 593 636 l 163 110 l 613 110 l 613 0 `},"™":{x_min:0,x_max:894,ha:1e3,o:`m 389 951 l 229 951 l 229 503 l 160 503 l 160 951 l 0 951 l 0 1011 l 389 1011 l 389 951 m 894 503 l 827 503 l 827 939 l 685 503 l 620 503 l 481 937 l 481 503 l 417 503 l 417 1011 l 517 1011 l 653 580 l 796 1010 l 894 1011 l 894 503 `},ή:{x_min:.78125,x_max:697,ha:810,o:`m 697 -278 l 572 -278 l 572 454 q 540 587 572 536 q 425 650 501 650 q 271 579 337 650 q 206 420 206 509 l 206 0 l 81 0 l 81 489 q 73 588 81 562 q 0 644 56 644 l 0 741 q 68 755 38 755 q 158 721 124 755 q 200 630 193 687 q 297 726 234 692 q 434 761 359 761 q 620 692 544 761 q 697 516 697 624 l 697 -278 m 479 1040 l 290 819 l 207 819 l 341 1040 l 479 1040 `},Θ:{x_min:0,x_max:960,ha:1056,o:`m 960 507 q 833 129 960 280 q 476 -32 698 -32 q 123 129 255 -32 q 0 507 0 280 q 123 883 0 732 q 476 1045 255 1045 q 832 883 696 1045 q 960 507 960 732 m 817 500 q 733 789 817 669 q 476 924 639 924 q 223 792 317 924 q 142 507 142 675 q 222 222 142 339 q 476 89 315 89 q 730 218 636 89 q 817 500 817 334 m 716 449 l 243 449 l 243 571 l 716 571 l 716 449 `},"®":{x_min:-3,x_max:1008,ha:1106,o:`m 503 532 q 614 562 566 532 q 672 658 672 598 q 614 747 672 716 q 503 772 569 772 l 338 772 l 338 532 l 503 532 m 502 -7 q 123 151 263 -7 q -3 501 -3 294 q 123 851 -3 706 q 502 1011 263 1011 q 881 851 739 1011 q 1008 501 1008 708 q 883 151 1008 292 q 502 -7 744 -7 m 502 60 q 830 197 709 60 q 940 501 940 322 q 831 805 940 681 q 502 944 709 944 q 174 805 296 944 q 65 501 65 680 q 173 197 65 320 q 502 60 294 60 m 788 146 l 678 146 q 653 316 655 183 q 527 449 652 449 l 338 449 l 338 146 l 241 146 l 241 854 l 518 854 q 688 808 621 854 q 766 658 766 755 q 739 563 766 607 q 668 497 713 519 q 751 331 747 472 q 788 164 756 190 l 788 146 `},"~":{x_min:0,x_max:833,ha:931,o:`m 833 958 q 778 753 833 831 q 594 665 716 665 q 402 761 502 665 q 240 857 302 857 q 131 795 166 857 q 104 665 104 745 l 0 665 q 54 867 0 789 q 237 958 116 958 q 429 861 331 958 q 594 765 527 765 q 704 827 670 765 q 729 958 729 874 l 833 958 `},Ε:{x_min:0,x_max:736.21875,ha:778,o:`m 736 0 l 0 0 l 0 1013 l 725 1013 l 725 889 l 139 889 l 139 585 l 677 585 l 677 467 l 139 467 l 139 125 l 736 125 l 736 0 `},"³":{x_min:0,x_max:450,ha:547,o:`m 450 552 q 379 413 450 464 q 220 366 313 366 q 69 414 130 366 q 0 567 0 470 l 85 567 q 126 470 85 504 q 225 437 168 437 q 320 467 280 437 q 360 552 360 498 q 318 632 360 608 q 213 657 276 657 q 195 657 203 657 q 176 657 181 657 l 176 722 q 279 733 249 722 q 334 815 334 752 q 300 881 334 856 q 220 907 267 907 q 133 875 169 907 q 97 781 97 844 l 15 781 q 78 926 15 875 q 220 972 135 972 q 364 930 303 972 q 426 817 426 888 q 344 697 426 733 q 421 642 392 681 q 450 552 450 603 `},"[":{x_min:0,x_max:273.609375,ha:371,o:`m 273 -281 l 0 -281 l 0 1013 l 273 1013 l 273 920 l 124 920 l 124 -187 l 273 -187 l 273 -281 `},L:{x_min:0,x_max:645.828125,ha:696,o:`m 645 0 l 0 0 l 0 1013 l 140 1013 l 140 126 l 645 126 l 645 0 `},σ:{x_min:0,x_max:803.390625,ha:894,o:`m 803 628 l 633 628 q 713 368 713 512 q 618 93 713 204 q 357 -25 518 -25 q 94 91 194 -25 q 0 368 0 201 q 94 644 0 533 q 356 761 194 761 q 481 750 398 761 q 608 739 564 739 l 803 739 l 803 628 m 360 85 q 529 180 467 85 q 584 374 584 262 q 527 566 584 490 q 352 651 463 651 q 187 559 247 651 q 135 368 135 478 q 189 175 135 254 q 360 85 251 85 `},ζ:{x_min:0,x_max:573,ha:642,o:`m 573 -40 q 553 -162 573 -97 q 510 -278 543 -193 l 400 -278 q 441 -187 428 -219 q 462 -90 462 -132 q 378 -14 462 -14 q 108 45 197 -14 q 0 290 0 117 q 108 631 0 462 q 353 901 194 767 l 55 901 l 55 1012 l 561 1012 l 561 924 q 261 669 382 831 q 128 301 128 489 q 243 117 128 149 q 458 98 350 108 q 573 -40 573 80 `},θ:{x_min:0,x_max:674,ha:778,o:`m 674 496 q 601 160 674 304 q 336 -26 508 -26 q 73 153 165 -26 q 0 485 0 296 q 72 840 0 683 q 343 1045 166 1045 q 605 844 516 1045 q 674 496 674 692 m 546 579 q 498 798 546 691 q 336 935 437 935 q 178 798 237 935 q 126 579 137 701 l 546 579 m 546 475 l 126 475 q 170 233 126 348 q 338 80 230 80 q 504 233 447 80 q 546 475 546 346 `},Ο:{x_min:0,x_max:958,ha:1054,o:`m 485 1042 q 834 883 703 1042 q 958 511 958 735 q 834 136 958 287 q 481 -26 701 -26 q 126 130 261 -26 q 0 504 0 279 q 127 880 0 729 q 485 1042 263 1042 m 480 98 q 731 225 638 98 q 815 504 815 340 q 733 783 815 670 q 480 913 640 913 q 226 785 321 913 q 142 504 142 671 q 226 224 142 339 q 480 98 319 98 `},Γ:{x_min:0,x_max:705.28125,ha:749,o:`m 705 886 l 140 886 l 140 0 l 0 0 l 0 1012 l 705 1012 l 705 886 `}," ":{x_min:0,x_max:0,ha:375},"%":{x_min:-3,x_max:1089,ha:1186,o:`m 845 0 q 663 76 731 0 q 602 244 602 145 q 661 412 602 344 q 845 489 728 489 q 1027 412 959 489 q 1089 244 1089 343 q 1029 76 1089 144 q 845 0 962 0 m 844 103 q 945 143 909 103 q 981 243 981 184 q 947 340 981 301 q 844 385 909 385 q 744 342 781 385 q 708 243 708 300 q 741 147 708 186 q 844 103 780 103 m 888 986 l 284 -25 l 199 -25 l 803 986 l 888 986 m 241 468 q 58 545 126 468 q -3 715 -3 615 q 56 881 -3 813 q 238 958 124 958 q 421 881 353 958 q 483 712 483 813 q 423 544 483 612 q 241 468 356 468 m 241 855 q 137 811 175 855 q 100 710 100 768 q 136 612 100 653 q 240 572 172 572 q 344 614 306 572 q 382 713 382 656 q 347 810 382 771 q 241 855 308 855 `},P:{x_min:0,x_max:726,ha:806,o:`m 424 1013 q 640 931 555 1013 q 726 719 726 850 q 637 506 726 587 q 413 426 548 426 l 140 426 l 140 0 l 0 0 l 0 1013 l 424 1013 m 379 889 l 140 889 l 140 548 l 372 548 q 522 589 459 548 q 593 720 593 637 q 528 845 593 801 q 379 889 463 889 `},Έ:{x_min:0,x_max:1078.21875,ha:1118,o:`m 1078 0 l 342 0 l 342 1013 l 1067 1013 l 1067 889 l 481 889 l 481 585 l 1019 585 l 1019 467 l 481 467 l 481 125 l 1078 125 l 1078 0 m 277 1040 l 83 799 l 0 799 l 140 1040 l 277 1040 `},Ώ:{x_min:.125,x_max:1136.546875,ha:1235,o:`m 1136 0 l 722 0 l 722 123 q 911 309 842 194 q 981 558 981 423 q 893 813 981 710 q 651 923 800 923 q 411 821 501 923 q 321 568 321 720 q 390 316 321 433 q 579 123 459 200 l 579 0 l 166 0 l 166 124 l 384 124 q 235 327 289 210 q 182 572 182 444 q 311 912 182 782 q 651 1042 441 1042 q 989 910 858 1042 q 1120 569 1120 778 q 1066 326 1120 443 q 917 124 1013 210 l 1136 124 l 1136 0 m 277 1040 l 83 800 l 0 800 l 140 1041 l 277 1040 `},_:{x_min:0,x_max:705.5625,ha:803,o:`m 705 -334 l 0 -334 l 0 -234 l 705 -234 l 705 -334 `},Ϊ:{x_min:-110,x_max:246,ha:275,o:`m 246 1046 l 118 1046 l 118 1189 l 246 1189 l 246 1046 m 18 1046 l -110 1046 l -110 1189 l 18 1189 l 18 1046 m 136 0 l 0 0 l 0 1012 l 136 1012 l 136 0 `},"+":{x_min:23,x_max:768,ha:792,o:`m 768 372 l 444 372 l 444 0 l 347 0 l 347 372 l 23 372 l 23 468 l 347 468 l 347 840 l 444 840 l 444 468 l 768 468 l 768 372 `},"½":{x_min:0,x_max:1050,ha:1149,o:`m 1050 0 l 625 0 q 712 178 625 108 q 878 277 722 187 q 967 385 967 328 q 932 456 967 429 q 850 484 897 484 q 759 450 798 484 q 721 352 721 416 l 640 352 q 706 502 640 448 q 851 551 766 551 q 987 509 931 551 q 1050 385 1050 462 q 976 251 1050 301 q 829 179 902 215 q 717 68 740 133 l 1050 68 l 1050 0 m 834 985 l 215 -28 l 130 -28 l 750 984 l 834 985 m 224 422 l 142 422 l 142 811 l 0 811 l 0 867 q 104 889 62 867 q 164 973 157 916 l 224 973 l 224 422 `},Ρ:{x_min:0,x_max:720,ha:783,o:`m 424 1013 q 637 933 554 1013 q 720 723 720 853 q 633 508 720 591 q 413 426 546 426 l 140 426 l 140 0 l 0 0 l 0 1013 l 424 1013 m 378 889 l 140 889 l 140 548 l 371 548 q 521 589 458 548 q 592 720 592 637 q 527 845 592 801 q 378 889 463 889 `},"'":{x_min:0,x_max:139,ha:236,o:`m 139 851 q 102 737 139 784 q 0 669 65 690 l 0 734 q 59 787 42 741 q 72 873 72 821 l 0 873 l 0 1013 l 139 1013 l 139 851 `},ª:{x_min:0,x_max:350,ha:397,o:`m 350 625 q 307 616 328 616 q 266 631 281 616 q 247 673 251 645 q 190 628 225 644 q 116 613 156 613 q 32 641 64 613 q 0 722 0 669 q 72 826 0 800 q 247 866 159 846 l 247 887 q 220 934 247 916 q 162 953 194 953 q 104 934 129 953 q 76 882 80 915 l 16 882 q 60 976 16 941 q 166 1011 104 1011 q 266 979 224 1011 q 308 891 308 948 l 308 706 q 311 679 308 688 q 331 670 315 670 l 350 672 l 350 625 m 247 757 l 247 811 q 136 790 175 798 q 64 726 64 773 q 83 682 64 697 q 132 667 103 667 q 207 690 174 667 q 247 757 247 718 `},"΅":{x_min:0,x_max:450,ha:553,o:`m 450 800 l 340 800 l 340 925 l 450 925 l 450 800 m 406 1040 l 212 800 l 129 800 l 269 1040 l 406 1040 m 110 800 l 0 800 l 0 925 l 110 925 l 110 800 `},T:{x_min:0,x_max:777,ha:835,o:`m 777 894 l 458 894 l 458 0 l 319 0 l 319 894 l 0 894 l 0 1013 l 777 1013 l 777 894 `},Φ:{x_min:0,x_max:915,ha:997,o:`m 527 0 l 389 0 l 389 122 q 110 231 220 122 q 0 509 0 340 q 110 785 0 677 q 389 893 220 893 l 389 1013 l 527 1013 l 527 893 q 804 786 693 893 q 915 509 915 679 q 805 231 915 341 q 527 122 696 122 l 527 0 m 527 226 q 712 310 641 226 q 779 507 779 389 q 712 705 779 627 q 527 787 641 787 l 527 226 m 389 226 l 389 787 q 205 698 275 775 q 136 505 136 620 q 206 308 136 391 q 389 226 276 226 `},"⁋":{x_min:0,x_max:0,ha:694},j:{x_min:-77.78125,x_max:167,ha:349,o:`m 167 871 l 42 871 l 42 1013 l 167 1013 l 167 871 m 167 -80 q 121 -231 167 -184 q -26 -278 76 -278 l -77 -278 l -77 -164 l -41 -164 q 26 -143 11 -164 q 42 -65 42 -122 l 42 737 l 167 737 l 167 -80 `},Σ:{x_min:0,x_max:756.953125,ha:819,o:`m 756 0 l 0 0 l 0 107 l 395 523 l 22 904 l 22 1013 l 745 1013 l 745 889 l 209 889 l 566 523 l 187 125 l 756 125 l 756 0 `},"›":{x_min:18.0625,x_max:774,ha:792,o:`m 774 376 l 18 40 l 18 149 l 631 421 l 18 692 l 18 799 l 774 465 l 774 376 `},"<":{x_min:17.984375,x_max:773.609375,ha:792,o:`m 773 40 l 18 376 l 17 465 l 773 799 l 773 692 l 159 420 l 773 149 l 773 40 `},"£":{x_min:0,x_max:704.484375,ha:801,o:`m 704 41 q 623 -10 664 5 q 543 -26 583 -26 q 359 15 501 -26 q 243 36 288 36 q 158 23 197 36 q 73 -21 119 10 l 6 76 q 125 195 90 150 q 175 331 175 262 q 147 443 175 383 l 0 443 l 0 512 l 108 512 q 43 734 43 623 q 120 929 43 854 q 358 1010 204 1010 q 579 936 487 1010 q 678 729 678 857 l 678 684 l 552 684 q 504 838 552 780 q 362 896 457 896 q 216 852 263 896 q 176 747 176 815 q 199 627 176 697 q 248 512 217 574 l 468 512 l 468 443 l 279 443 q 297 356 297 398 q 230 194 297 279 q 153 107 211 170 q 227 133 190 125 q 293 142 264 142 q 410 119 339 142 q 516 96 482 96 q 579 105 550 96 q 648 142 608 115 l 704 41 `},t:{x_min:0,x_max:367,ha:458,o:`m 367 0 q 312 -5 339 -2 q 262 -8 284 -8 q 145 28 183 -8 q 108 143 108 64 l 108 638 l 0 638 l 0 738 l 108 738 l 108 944 l 232 944 l 232 738 l 367 738 l 367 638 l 232 638 l 232 185 q 248 121 232 140 q 307 102 264 102 q 345 104 330 102 q 367 107 360 107 l 367 0 `},"¬":{x_min:0,x_max:706,ha:803,o:`m 706 411 l 706 158 l 630 158 l 630 335 l 0 335 l 0 411 l 706 411 `},λ:{x_min:0,x_max:750,ha:803,o:`m 750 -7 q 679 -15 716 -15 q 538 59 591 -15 q 466 214 512 97 l 336 551 l 126 0 l 0 0 l 270 705 q 223 837 247 770 q 116 899 190 899 q 90 898 100 899 l 90 1004 q 152 1011 125 1011 q 298 938 244 1011 q 373 783 326 901 l 605 192 q 649 115 629 136 q 716 95 669 95 l 736 95 q 750 97 745 97 l 750 -7 `},W:{x_min:0,x_max:1263.890625,ha:1351,o:`m 1263 1013 l 995 0 l 859 0 l 627 837 l 405 0 l 265 0 l 0 1013 l 136 1013 l 342 202 l 556 1013 l 701 1013 l 921 207 l 1133 1012 l 1263 1013 `},">":{x_min:18.0625,x_max:774,ha:792,o:`m 774 376 l 18 40 l 18 149 l 631 421 l 18 692 l 18 799 l 774 465 l 774 376 `},v:{x_min:0,x_max:675.15625,ha:761,o:`m 675 738 l 404 0 l 272 0 l 0 738 l 133 737 l 340 147 l 541 737 l 675 738 `},τ:{x_min:.28125,x_max:644.5,ha:703,o:`m 644 628 l 382 628 l 382 179 q 388 120 382 137 q 436 91 401 91 q 474 94 447 91 q 504 97 501 97 l 504 0 q 454 -9 482 -5 q 401 -14 426 -14 q 278 67 308 -14 q 260 233 260 118 l 260 628 l 0 628 l 0 739 l 644 739 l 644 628 `},ξ:{x_min:0,x_max:624.9375,ha:699,o:`m 624 -37 q 608 -153 624 -96 q 563 -278 593 -211 l 454 -278 q 491 -183 486 -200 q 511 -83 511 -126 q 484 -23 511 -44 q 370 1 452 1 q 323 0 354 1 q 283 -1 293 -1 q 84 76 169 -1 q 0 266 0 154 q 56 431 0 358 q 197 538 108 498 q 94 613 134 562 q 54 730 54 665 q 77 823 54 780 q 143 901 101 867 l 27 901 l 27 1012 l 576 1012 l 576 901 l 380 901 q 244 863 303 901 q 178 745 178 820 q 312 600 178 636 q 532 582 380 582 l 532 479 q 276 455 361 479 q 118 281 118 410 q 165 173 118 217 q 274 120 208 133 q 494 101 384 110 q 624 -37 624 76 `},"&":{x_min:-3,x_max:894.25,ha:992,o:`m 894 0 l 725 0 l 624 123 q 471 0 553 40 q 306 -41 390 -41 q 168 -7 231 -41 q 62 92 105 26 q 14 187 31 139 q -3 276 -3 235 q 55 433 -3 358 q 248 581 114 508 q 170 689 196 640 q 137 817 137 751 q 214 985 137 922 q 384 1041 284 1041 q 548 988 483 1041 q 622 824 622 928 q 563 666 622 739 q 431 556 516 608 l 621 326 q 649 407 639 361 q 663 493 653 426 l 781 493 q 703 229 781 352 l 894 0 m 504 818 q 468 908 504 877 q 384 940 433 940 q 293 907 331 940 q 255 818 255 875 q 289 714 255 767 q 363 628 313 678 q 477 729 446 682 q 504 818 504 771 m 556 209 l 314 499 q 179 395 223 449 q 135 283 135 341 q 146 222 135 253 q 183 158 158 192 q 333 80 241 80 q 556 209 448 80 `},Λ:{x_min:0,x_max:862.5,ha:942,o:`m 862 0 l 719 0 l 426 847 l 143 0 l 0 0 l 356 1013 l 501 1013 l 862 0 `},I:{x_min:41,x_max:180,ha:293,o:`m 180 0 l 41 0 l 41 1013 l 180 1013 l 180 0 `},G:{x_min:0,x_max:921,ha:1011,o:`m 921 0 l 832 0 l 801 136 q 655 15 741 58 q 470 -28 568 -28 q 126 133 259 -28 q 0 499 0 284 q 125 881 0 731 q 486 1043 259 1043 q 763 957 647 1043 q 905 709 890 864 l 772 709 q 668 866 747 807 q 486 926 589 926 q 228 795 322 926 q 142 507 142 677 q 228 224 142 342 q 483 94 323 94 q 712 195 625 94 q 796 435 796 291 l 477 435 l 477 549 l 921 549 l 921 0 `},ΰ:{x_min:0,x_max:617,ha:725,o:`m 524 800 l 414 800 l 414 925 l 524 925 l 524 800 m 183 800 l 73 800 l 73 925 l 183 925 l 183 800 m 617 352 q 540 93 617 199 q 308 -24 455 -24 q 76 93 161 -24 q 0 352 0 199 l 0 738 l 126 738 l 126 354 q 169 185 126 257 q 312 98 220 98 q 451 185 402 98 q 492 354 492 257 l 492 738 l 617 738 l 617 352 m 489 1040 l 300 819 l 216 819 l 351 1040 l 489 1040 `},"`":{x_min:0,x_max:138.890625,ha:236,o:`m 138 699 l 0 699 l 0 861 q 36 974 0 929 q 138 1041 72 1020 l 138 977 q 82 931 95 969 q 69 839 69 893 l 138 839 l 138 699 `},"·":{x_min:0,x_max:142,ha:239,o:`m 142 585 l 0 585 l 0 738 l 142 738 l 142 585 `},Υ:{x_min:.328125,x_max:819.515625,ha:889,o:`m 819 1013 l 482 416 l 482 0 l 342 0 l 342 416 l 0 1013 l 140 1013 l 411 533 l 679 1013 l 819 1013 `},r:{x_min:0,x_max:355.5625,ha:432,o:`m 355 621 l 343 621 q 179 569 236 621 q 122 411 122 518 l 122 0 l 0 0 l 0 737 l 117 737 l 117 604 q 204 719 146 686 q 355 753 262 753 l 355 621 `},x:{x_min:0,x_max:675,ha:764,o:`m 675 0 l 525 0 l 331 286 l 144 0 l 0 0 l 256 379 l 12 738 l 157 737 l 336 473 l 516 738 l 661 738 l 412 380 l 675 0 `},μ:{x_min:0,x_max:696.609375,ha:747,o:`m 696 -4 q 628 -14 657 -14 q 498 97 513 -14 q 422 8 470 41 q 313 -24 374 -24 q 207 3 258 -24 q 120 80 157 31 l 120 -278 l 0 -278 l 0 738 l 124 738 l 124 343 q 165 172 124 246 q 308 82 216 82 q 451 177 402 82 q 492 358 492 254 l 492 738 l 616 738 l 616 214 q 623 136 616 160 q 673 92 636 92 q 696 95 684 92 l 696 -4 `},h:{x_min:0,x_max:615,ha:724,o:`m 615 472 l 615 0 l 490 0 l 490 454 q 456 590 490 535 q 338 654 416 654 q 186 588 251 654 q 122 436 122 522 l 122 0 l 0 0 l 0 1013 l 122 1013 l 122 633 q 218 727 149 694 q 362 760 287 760 q 552 676 484 760 q 615 472 615 600 `},".":{x_min:0,x_max:142,ha:239,o:`m 142 0 l 0 0 l 0 151 l 142 151 l 142 0 `},φ:{x_min:-2,x_max:878,ha:974,o:`m 496 -279 l 378 -279 l 378 -17 q 101 88 204 -17 q -2 367 -2 194 q 68 626 -2 510 q 283 758 151 758 l 283 646 q 167 537 209 626 q 133 373 133 462 q 192 177 133 254 q 378 93 259 93 l 378 758 q 445 764 426 763 q 476 765 464 765 q 765 659 653 765 q 878 377 878 553 q 771 96 878 209 q 496 -17 665 -17 l 496 -279 m 496 93 l 514 93 q 687 183 623 93 q 746 380 746 265 q 691 569 746 491 q 522 658 629 658 l 496 656 l 496 93 `},";":{x_min:0,x_max:142,ha:239,o:`m 142 585 l 0 585 l 0 738 l 142 738 l 142 585 m 142 -12 q 105 -132 142 -82 q 0 -206 68 -182 l 0 -138 q 58 -82 43 -123 q 68 0 68 -56 l 0 0 l 0 151 l 142 151 l 142 -12 `},f:{x_min:0,x_max:378,ha:472,o:`m 378 638 l 246 638 l 246 0 l 121 0 l 121 638 l 0 638 l 0 738 l 121 738 q 137 935 121 887 q 290 1028 171 1028 q 320 1027 305 1028 q 378 1021 334 1026 l 378 908 q 323 918 346 918 q 257 870 273 918 q 246 780 246 840 l 246 738 l 378 738 l 378 638 `},"“":{x_min:1,x_max:348.21875,ha:454,o:`m 140 670 l 1 670 l 1 830 q 37 943 1 897 q 140 1011 74 990 l 140 947 q 82 900 97 940 q 68 810 68 861 l 140 810 l 140 670 m 348 670 l 209 670 l 209 830 q 245 943 209 897 q 348 1011 282 990 l 348 947 q 290 900 305 940 q 276 810 276 861 l 348 810 l 348 670 `},A:{x_min:.03125,x_max:906.953125,ha:1008,o:`m 906 0 l 756 0 l 648 303 l 251 303 l 142 0 l 0 0 l 376 1013 l 529 1013 l 906 0 m 610 421 l 452 867 l 293 421 l 610 421 `},"‘":{x_min:1,x_max:139.890625,ha:236,o:`m 139 670 l 1 670 l 1 830 q 37 943 1 897 q 139 1011 74 990 l 139 947 q 82 900 97 940 q 68 810 68 861 l 139 810 l 139 670 `},ϊ:{x_min:-70,x_max:283,ha:361,o:`m 283 800 l 173 800 l 173 925 l 283 925 l 283 800 m 40 800 l -70 800 l -70 925 l 40 925 l 40 800 m 283 3 q 232 -10 257 -5 q 181 -15 206 -15 q 84 26 118 -15 q 41 200 41 79 l 41 737 l 166 737 l 167 215 q 171 141 167 157 q 225 101 182 101 q 247 103 238 101 q 283 112 256 104 l 283 3 `},π:{x_min:-.21875,x_max:773.21875,ha:857,o:`m 773 -7 l 707 -11 q 575 40 607 -11 q 552 174 552 77 l 552 226 l 552 626 l 222 626 l 222 0 l 97 0 l 97 626 l 0 626 l 0 737 l 773 737 l 773 626 l 676 626 l 676 171 q 695 103 676 117 q 773 90 714 90 l 773 -7 `},ά:{x_min:0,x_max:765.5625,ha:809,o:`m 765 -4 q 698 -14 726 -14 q 564 97 586 -14 q 466 7 525 40 q 337 -26 407 -26 q 88 98 186 -26 q 0 369 0 212 q 88 637 0 525 q 337 760 184 760 q 465 727 407 760 q 563 637 524 695 l 563 738 l 685 738 l 685 222 q 693 141 685 168 q 748 94 708 94 q 765 95 760 94 l 765 -4 m 584 371 q 531 562 584 485 q 360 653 470 653 q 192 566 254 653 q 135 379 135 489 q 186 181 135 261 q 358 84 247 84 q 528 176 465 84 q 584 371 584 260 m 604 1040 l 415 819 l 332 819 l 466 1040 l 604 1040 `},O:{x_min:0,x_max:958,ha:1057,o:`m 485 1041 q 834 882 702 1041 q 958 512 958 734 q 834 136 958 287 q 481 -26 702 -26 q 126 130 261 -26 q 0 504 0 279 q 127 880 0 728 q 485 1041 263 1041 m 480 98 q 731 225 638 98 q 815 504 815 340 q 733 783 815 669 q 480 912 640 912 q 226 784 321 912 q 142 504 142 670 q 226 224 142 339 q 480 98 319 98 `},n:{x_min:0,x_max:615,ha:724,o:`m 615 463 l 615 0 l 490 0 l 490 454 q 453 592 490 537 q 331 656 410 656 q 178 585 240 656 q 117 421 117 514 l 117 0 l 0 0 l 0 738 l 117 738 l 117 630 q 218 728 150 693 q 359 764 286 764 q 552 675 484 764 q 615 463 615 593 `},l:{x_min:41,x_max:166,ha:279,o:`m 166 0 l 41 0 l 41 1013 l 166 1013 l 166 0 `},"¤":{x_min:40.09375,x_max:728.796875,ha:825,o:`m 728 304 l 649 224 l 512 363 q 383 331 458 331 q 256 363 310 331 l 119 224 l 40 304 l 177 441 q 150 553 150 493 q 184 673 150 621 l 40 818 l 119 898 l 267 749 q 321 766 291 759 q 384 773 351 773 q 447 766 417 773 q 501 749 477 759 l 649 898 l 728 818 l 585 675 q 612 618 604 648 q 621 553 621 587 q 591 441 621 491 l 728 304 m 384 682 q 280 643 318 682 q 243 551 243 604 q 279 461 243 499 q 383 423 316 423 q 487 461 449 423 q 525 553 525 500 q 490 641 525 605 q 384 682 451 682 `},κ:{x_min:0,x_max:632.328125,ha:679,o:`m 632 0 l 482 0 l 225 384 l 124 288 l 124 0 l 0 0 l 0 738 l 124 738 l 124 446 l 433 738 l 596 738 l 312 466 l 632 0 `},p:{x_min:0,x_max:685,ha:786,o:`m 685 364 q 598 96 685 205 q 350 -23 504 -23 q 121 89 205 -23 l 121 -278 l 0 -278 l 0 738 l 121 738 l 121 633 q 220 726 159 691 q 351 761 280 761 q 598 636 504 761 q 685 364 685 522 m 557 371 q 501 560 557 481 q 330 651 437 651 q 162 559 223 651 q 108 366 108 479 q 162 177 108 254 q 333 87 224 87 q 502 178 441 87 q 557 371 557 258 `},"‡":{x_min:0,x_max:777,ha:835,o:`m 458 238 l 458 0 l 319 0 l 319 238 l 0 238 l 0 360 l 319 360 l 319 681 l 0 683 l 0 804 l 319 804 l 319 1015 l 458 1013 l 458 804 l 777 804 l 777 683 l 458 683 l 458 360 l 777 360 l 777 238 l 458 238 `},ψ:{x_min:0,x_max:808,ha:907,o:`m 465 -278 l 341 -278 l 341 -15 q 87 102 180 -15 q 0 378 0 210 l 0 739 l 133 739 l 133 379 q 182 195 133 275 q 341 98 242 98 l 341 922 l 465 922 l 465 98 q 623 195 563 98 q 675 382 675 278 l 675 742 l 808 742 l 808 381 q 720 104 808 213 q 466 -13 627 -13 l 465 -278 `},η:{x_min:.78125,x_max:697,ha:810,o:`m 697 -278 l 572 -278 l 572 454 q 540 587 572 536 q 425 650 501 650 q 271 579 337 650 q 206 420 206 509 l 206 0 l 81 0 l 81 489 q 73 588 81 562 q 0 644 56 644 l 0 741 q 68 755 38 755 q 158 720 124 755 q 200 630 193 686 q 297 726 234 692 q 434 761 359 761 q 620 692 544 761 q 697 516 697 624 l 697 -278 `}},cssFontWeight:`normal`,ascender:1189,underlinePosition:-100,cssFontStyle:`normal`,boundingBox:{yMin:-334,xMin:-111,yMax:1189,xMax:1672},resolution:1e3,original_font_information:{postscript_name:`Helvetiker-Regular`,version_string:`Version 1.00 2004 initial release`,vendor_url:`http://www.magenta.gr/`,full_font_name:`Helvetiker`,font_family_name:`Helvetiker`,copyright:`Copyright (c) Μagenta ltd, 2004`,description:``,trademark:``,designer:``,designer_url:``,unique_font_identifier:`Μagenta ltd:Helvetiker:22-10-104`,license_url:`http://www.ellak.gr/fonts/MgOpen/license.html`,license_description:`Copyright (c) 2004 by MAGENTA Ltd. All Rights Reserved.\r \r Permission is hereby granted, free of charge, to any person obtaining a copy of the fonts accompanying this license ("Fonts") and associated documentation files (the "Font Software"), to reproduce and distribute the Font Software, including without limitation the rights to use, copy, merge, publish, distribute, and/or sell copies of the Font Software, and to permit persons to whom the Font Software is furnished to do so, subject to the following conditions: \r \r The above copyright and this permission notice shall be included in all copies of one or more of the Font Software typefaces.\r \r The Font Software may be modified, altered, or added to, and in particular the designs of glyphs or characters in the Fonts may be modified and additional glyphs or characters may be added to the Fonts, only if the fonts are renamed to names not containing the word "MgOpen", or if the modifications are accepted for inclusion in the Font Software itself by the each appointed Administrator.\r \r This License becomes null and void to the extent applicable to Fonts or Font Software that has been modified and is distributed under the "MgOpen" name.\r \r The Font Software may be sold as part of a larger software package but no copy of one or more of the Font Software typefaces may be sold by itself. \r \r THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL MAGENTA OR PERSONS OR BODIES IN CHARGE OF ADMINISTRATION AND MAINTENANCE OF THE FONT SOFTWARE BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE FONT SOFTWARE.`,manufacturer_name:`Μagenta ltd`,font_sub_family_name:`Regular`},descender:-334,familyName:`Helvetiker`,lineHeight:1522,underlineThickness:50},m4=O0(O0({},window.THREE?window.THREE:{BoxGeometry:Ba,CircleGeometry:Va,DoubleSide:2,Group:B,Mesh:ea,MeshLambertMaterial:Os,TextGeometry:t0,Vector3:R}),{},{Font:Q1,TextGeometry:t0}),h4=wp({props:{labelsData:{default:[]},labelLat:{default:`lat`},labelLng:{default:`lng`},labelAltitude:{default:.002},labelText:{default:`text`},labelSize:{default:.5},labelTypeFace:{default:p4,onChange:function(e,t){t.font=new m4.Font(e)}},labelColor:{default:function(){return`lightgrey`}},labelRotation:{default:0},labelResolution:{default:3},labelIncludeDot:{default:!0},labelDotRadius:{default:.1},labelDotOrientation:{default:function(){return`bottom`}},labelsTransitionDuration:{default:1e3,triggerUpdate:!1}},init:function(e,t,n){var r=n.tweenGroup;W0(e),t.scene=e,t.tweenGroup=r;var i=new m4.CircleGeometry(1,32);t.dataMapper=new h2(e,{objBindAttr:`__threeObjLabel`}).onCreateObj(function(){var e=new m4.MeshLambertMaterial;e.side=2;var t=new m4.Group;t.add(new m4.Mesh(i,e));var n=new m4.Mesh(void 0,e);t.add(n);var r=new m4.Mesh;return r.visible=!1,n.add(r),t.__globeObjType=`label`,t})},update:function(e){var t=V(e.labelLat),n=V(e.labelLng),r=V(e.labelAltitude),i=V(e.labelText),a=V(e.labelSize),o=V(e.labelRotation),s=V(e.labelColor),c=V(e.labelIncludeDot),l=V(e.labelDotRadius),u=V(e.labelDotOrientation),d=new Set([`right`,`top`,`bottom`]),f=2*Math.PI*K0/360;e.dataMapper.onUpdateObj(function(p,m){var h=F0(p.children,2),g=h[0],_=h[1],v=F0(_.children,1)[0],y=s(m),b=o2(y);_.material.color.set(a2(y)),_.material.transparent=b<1,_.material.opacity=b;var x=c(m),S=u(m);!x||!d.has(S)&&(S=`bottom`);var C=x?+l(m)*f:1e-12;g.scale.x=g.scale.y=C;var w=+a(m)*f;if(_.geometry&&_.geometry.dispose(),_.geometry=new m4.TextGeometry(i(m),{font:e.font,size:w,depth:0,bevelEnabled:!0,bevelThickness:0,bevelSize:0,curveSegments:e.labelResolution}),v.geometry&&v.geometry.dispose(),_.geometry.computeBoundingBox(),v.geometry=h0(m4.BoxGeometry,R0(new m4.Vector3().subVectors(_.geometry.boundingBox.max,_.geometry.boundingBox.min).clampScalar(0,1/0).toArray())),S!==`right`&&_.geometry.center(),x){var T=C+w/2;S===`right`&&(_.position.x=T),_.position.y={right:-w/2,top:T+w/2,bottom:-T-w/2}[S]}var E=function(t){var n=p.__currentTargetD=t,r=n.lat,i=n.lng,a=n.alt,o=n.rot,s=n.scale;Object.assign(p.position,J0(r,i,a)),p.lookAt(e.scene.localToWorld(new m4.Vector3(0,0,0))),p.rotateY(Math.PI),p.rotateZ(-o*Math.PI/180),p.scale.x=p.scale.y=p.scale.z=s},D={lat:+t(m),lng:+n(m),alt:+r(m),rot:+o(m),scale:1},O=p.__currentTargetD||Object.assign({},D,{scale:1e-12});Object.keys(D).some(function(e){return O[e]!==D[e]})&&(!e.labelsTransitionDuration||e.labelsTransitionDuration<0?E(D):e.tweenGroup.add(new jp(O).to(D,e.labelsTransitionDuration).easing(Tp.Quadratic.InOut).onUpdate(E).onComplete(function(){e.tweenGroup.remove(this)}).start()))}).digest(e.labelsData)}}),g4=O0(O0({},window.THREE?window.THREE:{}),{},{CSS2DObject:vf}),_4=wp({props:{htmlElementsData:{default:[]},htmlLat:{default:`lat`},htmlLng:{default:`lng`},htmlAltitude:{default:0},htmlElement:{},htmlElementVisibilityModifier:{triggerUpdate:!1},htmlTransitionDuration:{default:1e3,triggerUpdate:!1},isBehindGlobe:{onChange:function(){this.updateObjVisibility()},triggerUpdate:!1}},methods:{updateObjVisibility:function(e,t){e.dataMapper&&(t?[t]:e.dataMapper.entries().map(function(e){return F0(e,2)[1]}).filter(function(e){return e})).forEach(function(t){var n=!e.isBehindGlobe||!e.isBehindGlobe(t.position);e.htmlElementVisibilityModifier?(t.visible=!0,e.htmlElementVisibilityModifier(t.element,n)):t.visible=n})}},init:function(e,t,n){var r=n.tweenGroup;W0(e),t.scene=e,t.tweenGroup=r,t.dataMapper=new h2(e,{objBindAttr:`__threeObjHtml`}).onCreateObj(function(e){var n=V(t.htmlElement)(e),r=new g4.CSS2DObject(n);return r.__globeObjType=`html`,r})},update:function(e,t){var n=this,r=V(e.htmlLat),i=V(e.htmlLng),a=V(e.htmlAltitude);t.hasOwnProperty(`htmlElement`)&&e.dataMapper.clear(),e.dataMapper.onUpdateObj(function(t,o){var s=function(e){var r=t.__currentTargetD=e,i=r.alt,a=r.lat,o=r.lng;Object.assign(t.position,J0(a,o,i)),n.updateObjVisibility(t)},c={lat:+r(o),lng:+i(o),alt:+a(o)};!e.htmlTransitionDuration||e.htmlTransitionDuration<0||!t.__currentTargetD?s(c):e.tweenGroup.add(new jp(t.__currentTargetD).to(c,e.htmlTransitionDuration).easing(Tp.Quadratic.InOut).onUpdate(s).onComplete(function(){e.tweenGroup.remove(this)}).start())}).digest(e.htmlElementsData)}}),v4=window.THREE?window.THREE:{Group:B,Mesh:ea,MeshLambertMaterial:Os,SphereGeometry:cs},y4=wp({props:{objectsData:{default:[]},objectLat:{default:`lat`},objectLng:{default:`lng`},objectAltitude:{default:.01},objectFacesSurface:{default:!0},objectRotation:{},objectThreeObject:{default:new v4.Mesh(new v4.SphereGeometry(1,16,8),new v4.MeshLambertMaterial({color:`#ffffaa`,transparent:!0,opacity:.7}))}},init:function(e,t){W0(e),t.scene=e,t.dataMapper=new h2(e,{objBindAttr:`__threeObjObject`}).onCreateObj(function(e){var n=V(t.objectThreeObject)(e);t.objectThreeObject===n&&(n=n.clone());var r=new v4.Group;return r.add(n),r.__globeObjType=`object`,r})},update:function(e,t){var n=V(e.objectLat),r=V(e.objectLng),i=V(e.objectAltitude),a=V(e.objectFacesSurface),o=V(e.objectRotation);t.hasOwnProperty(`objectThreeObject`)&&e.dataMapper.clear(),e.dataMapper.onUpdateObj(function(e,t){var s=+n(t),c=+r(t),l=+i(t);Object.assign(e.position,J0(s,c,l)),a(t)?e.setRotationFromEuler(new rr(X0(-s),X0(c),0,`YXZ`)):e.rotation.set(0,0,0);var u=e.children[0],d=o(t);d&&u.setRotationFromEuler(new rr(X0(d.x||0),X0(d.y||0),X0(d.z||0)))}).digest(e.objectsData)}}),b4=wp({props:{customLayerData:{default:[]},customThreeObject:{},customThreeObjectUpdate:{triggerUpdate:!1}},init:function(e,t){W0(e),t.scene=e,t.dataMapper=new h2(e,{objBindAttr:`__threeObjCustom`}).onCreateObj(function(e){var n=V(t.customThreeObject)(e,K0);return n&&(t.customThreeObject===n&&(n=n.clone()),n.__globeObjType=`custom`),n})},update:function(e,t){e.customThreeObjectUpdate||W0(e.scene);var n=V(e.customThreeObjectUpdate);t.hasOwnProperty(`customThreeObject`)&&e.dataMapper.clear(),e.dataMapper.onUpdateObj(function(e,t){return n(e,t,K0)}).digest(e.customLayerData)}}),x4=window.THREE?window.THREE:{Camera:lc,Group:B,Vector2:L,Vector3:R},S4=[`globeLayer`,`pointsLayer`,`arcsLayer`,`hexBinLayer`,`heatmapsLayer`,`polygonsLayer`,`hexedPolygonsLayer`,`pathsLayer`,`tilesLayer`,`particlesLayer`,`ringsLayer`,`labelsLayer`,`htmlElementsLayer`,`objectsLayer`,`customLayer`],C4=G0(`globeLayer`,i2),w4=Object.assign.apply(Object,R0([`globeImageUrl`,`bumpImageUrl`,`globeCurvatureResolution`,`globeTileEngineUrl`,`globeTileEngineMaxLevel`,`showGlobe`,`showGraticules`,`showAtmosphere`,`atmosphereColor`,`atmosphereAltitude`].map(function(e){return v0({},e,C4.linkProp(e))}))),T4=Object.assign.apply(Object,R0([`globeMaterial`,`globeTileEngineClearCache`].map(function(e){return v0({},e,C4.linkMethod(e))}))),E4=G0(`pointsLayer`,y2),D4=Object.assign.apply(Object,R0([`pointsData`,`pointLat`,`pointLng`,`pointColor`,`pointAltitude`,`pointRadius`,`pointResolution`,`pointsMerge`,`pointsTransitionDuration`].map(function(e){return v0({},e,E4.linkProp(e))}))),O4=G0(`arcsLayer`,O2),k4=Object.assign.apply(Object,R0([`arcsData`,`arcStartLat`,`arcStartLng`,`arcStartAltitude`,`arcEndLat`,`arcEndLng`,`arcEndAltitude`,`arcColor`,`arcAltitude`,`arcAltitudeAutoScale`,`arcStroke`,`arcCurveResolution`,`arcCircularResolution`,`arcDashLength`,`arcDashGap`,`arcDashInitialGap`,`arcDashAnimateTime`,`arcsTransitionDuration`].map(function(e){return v0({},e,O4.linkProp(e))}))),A4=G0(`hexBinLayer`,M2),j4=Object.assign.apply(Object,R0([`hexBinPointsData`,`hexBinPointLat`,`hexBinPointLng`,`hexBinPointWeight`,`hexBinResolution`,`hexMargin`,`hexTopCurvatureResolution`,`hexTopColor`,`hexSideColor`,`hexAltitude`,`hexBinMerge`,`hexTransitionDuration`].map(function(e){return v0({},e,A4.linkProp(e))}))),M4=G0(`heatmapsLayer`,G2),N4=Object.assign.apply(Object,R0([`heatmapsData`,`heatmapPoints`,`heatmapPointLat`,`heatmapPointLng`,`heatmapPointWeight`,`heatmapBandwidth`,`heatmapColorFn`,`heatmapColorSaturation`,`heatmapBaseAltitude`,`heatmapTopAltitude`,`heatmapsTransitionDuration`].map(function(e){return v0({},e,M4.linkProp(e))}))),P4=G0(`hexedPolygonsLayer`,Q2),F4=Object.assign.apply(Object,R0([`hexPolygonsData`,`hexPolygonGeoJsonGeometry`,`hexPolygonColor`,`hexPolygonAltitude`,`hexPolygonResolution`,`hexPolygonMargin`,`hexPolygonUseDots`,`hexPolygonCurvatureResolution`,`hexPolygonDotResolution`,`hexPolygonsTransitionDuration`].map(function(e){return v0({},e,P4.linkProp(e))}))),I4=G0(`polygonsLayer`,q2),L4=Object.assign.apply(Object,R0([`polygonsData`,`polygonGeoJsonGeometry`,`polygonCapColor`,`polygonCapMaterial`,`polygonSideColor`,`polygonSideMaterial`,`polygonStrokeColor`,`polygonAltitude`,`polygonCapCurvatureResolution`,`polygonsTransitionDuration`].map(function(e){return v0({},e,I4.linkProp(e))}))),R4=G0(`pathsLayer`,r4),z4=Object.assign.apply(Object,R0([`pathsData`,`pathPoints`,`pathPointLat`,`pathPointLng`,`pathPointAlt`,`pathResolution`,`pathColor`,`pathStroke`,`pathDashLength`,`pathDashGap`,`pathDashInitialGap`,`pathDashAnimateTime`,`pathTransitionDuration`].map(function(e){return v0({},e,R4.linkProp(e))}))),B4=G0(`tilesLayer`,a4),V4=Object.assign.apply(Object,R0([`tilesData`,`tileLat`,`tileLng`,`tileAltitude`,`tileWidth`,`tileHeight`,`tileUseGlobeProjection`,`tileMaterial`,`tileCurvatureResolution`,`tilesTransitionDuration`].map(function(e){return v0({},e,B4.linkProp(e))}))),H4=G0(`particlesLayer`,c4),U4=Object.assign.apply(Object,R0([`particlesData`,`particlesList`,`particleLat`,`particleLng`,`particleAltitude`,`particlesSize`,`particlesSizeAttenuation`,`particlesColor`,`particlesTexture`].map(function(e){return v0({},e,H4.linkProp(e))}))),W4=G0(`ringsLayer`,f4),G4=Object.assign.apply(Object,R0([`ringsData`,`ringLat`,`ringLng`,`ringAltitude`,`ringColor`,`ringResolution`,`ringMaxRadius`,`ringPropagationSpeed`,`ringRepeatPeriod`].map(function(e){return v0({},e,W4.linkProp(e))}))),K4=G0(`labelsLayer`,h4),q4=Object.assign.apply(Object,R0([`labelsData`,`labelLat`,`labelLng`,`labelAltitude`,`labelRotation`,`labelText`,`labelSize`,`labelTypeFace`,`labelColor`,`labelResolution`,`labelIncludeDot`,`labelDotRadius`,`labelDotOrientation`,`labelsTransitionDuration`].map(function(e){return v0({},e,K4.linkProp(e))}))),J4=G0(`htmlElementsLayer`,_4),Y4=Object.assign.apply(Object,R0([`htmlElementsData`,`htmlLat`,`htmlLng`,`htmlAltitude`,`htmlElement`,`htmlElementVisibilityModifier`,`htmlTransitionDuration`].map(function(e){return v0({},e,J4.linkProp(e))}))),X4=G0(`objectsLayer`,y4),Z4=Object.assign.apply(Object,R0([`objectsData`,`objectLat`,`objectLng`,`objectAltitude`,`objectRotation`,`objectFacesSurface`,`objectThreeObject`].map(function(e){return v0({},e,X4.linkProp(e))}))),Q4=G0(`customLayer`,b4),$4=Object.assign.apply(Object,R0([`customLayerData`,`customThreeObject`,`customThreeObjectUpdate`].map(function(e){return v0({},e,Q4.linkProp(e))}))),e3=wp({props:O0(O0(O0(O0(O0(O0(O0(O0(O0(O0(O0(O0(O0(O0(O0({onGlobeReady:{triggerUpdate:!1},rendererSize:{default:new x4.Vector2(window.innerWidth,window.innerHeight),onChange:function(e,t){t.pathsLayer.rendererSize(e)},triggerUpdate:!1}},w4),D4),k4),j4),N4),L4),F4),z4),V4),U4),G4),q4),Y4),Z4),$4),methods:O0({getGlobeRadius:q0,getCoords:function(e){var t=[...arguments].slice(1);return J0.apply(void 0,t)},toGeoCoords:function(e){var t=[...arguments].slice(1);return Y0.apply(void 0,t)},setPointOfView:function(e,t){var n=t instanceof x4.Camera?t.position:t,r=q0(),i=void 0;if(e.scene&&n){var a,o,s,c;i=function(t){a===void 0&&(a=n.clone().applyMatrix4(e.scene.matrixWorld.clone().invert())),o===void 0&&(o=a.length()),s===void 0&&(s=Math.sqrt(o**2-r**2)),c===void 0&&(c=Math.acos(s/o));var i=a.distanceTo(t);if(i1&&arguments[1]!==void 0?arguments[1]:Object,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,r=function(t){function r(){var t;d0(this,r);var i=[...arguments];return t=l0(this,r,[].concat(i)),t.__kapsuleInstance=h0(e,[].concat(R0(n?[t]:[]),i)),t}return x0(r,t),_0(r)}(t);return Object.keys(e()).forEach(function(e){return r.prototype[e]=function(){var t,n=(t=this.__kapsuleInstance)[e].apply(t,arguments);return n===this.__kapsuleInstance?this:n}}),r}var n3=t3(e3,(window.THREE?window.THREE:{Group:B}).Group,!0),r3={type:`change`},i3={type:`start`},a3={type:`end`},o3=1e-6,s3={NONE:-1,ROTATE:0,ZOOM:1,PAN:2,TOUCH_ROTATE:3,TOUCH_ZOOM_PAN:4},c3=new L,l3=new L,u3=new R,d3=new R,f3=new R,p3=new Cn,m3=new R,h3=new R,g3=new R,_3=new R,v3=class extends cl{constructor(e,t=null){super(e,t),this.screen={left:0,top:0,width:0,height:0},this.rotateSpeed=1,this.zoomSpeed=1.2,this.panSpeed=.3,this.noRotate=!1,this.noZoom=!1,this.noPan=!1,this.staticMoving=!1,this.dynamicDampingFactor=.2,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.keys=[`KeyA`,`KeyS`,`KeyD`],this.mouseButtons={LEFT:O.ROTATE,MIDDLE:O.DOLLY,RIGHT:O.PAN},this.target=new R,this.state=s3.NONE,this.keyState=s3.NONE,this._lastPosition=new R,this._lastZoom=1,this._touchZoomDistanceStart=0,this._touchZoomDistanceEnd=0,this._lastAngle=0,this._eye=new R,this._movePrev=new L,this._moveCurr=new L,this._lastAxis=new R,this._zoomStart=new L,this._zoomEnd=new L,this._panStart=new L,this._panEnd=new L,this._pointers=[],this._pointerPositions={},this._onPointerMove=b3.bind(this),this._onPointerDown=y3.bind(this),this._onPointerUp=x3.bind(this),this._onPointerCancel=S3.bind(this),this._onContextMenu=k3.bind(this),this._onMouseWheel=O3.bind(this),this._onKeyDown=w3.bind(this),this._onKeyUp=C3.bind(this),this._onTouchStart=A3.bind(this),this._onTouchMove=j3.bind(this),this._onTouchEnd=M3.bind(this),this._onMouseDown=T3.bind(this),this._onMouseMove=E3.bind(this),this._onMouseUp=D3.bind(this),this._target0=this.target.clone(),this._position0=this.object.position.clone(),this._up0=this.object.up.clone(),this._zoom0=this.object.zoom,t!==null&&(this.connect(t),this.handleResize()),this.update()}connect(e){super.connect(e),window.addEventListener(`keydown`,this._onKeyDown),window.addEventListener(`keyup`,this._onKeyUp),this.domElement.addEventListener(`pointerdown`,this._onPointerDown),this.domElement.addEventListener(`pointercancel`,this._onPointerCancel),this.domElement.addEventListener(`wheel`,this._onMouseWheel,{passive:!1}),this.domElement.addEventListener(`contextmenu`,this._onContextMenu),this.domElement.style.touchAction=`none`}disconnect(){window.removeEventListener(`keydown`,this._onKeyDown),window.removeEventListener(`keyup`,this._onKeyUp),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._onPointerCancel),this.domElement.removeEventListener(`wheel`,this._onMouseWheel),this.domElement.removeEventListener(`contextmenu`,this._onContextMenu),this.domElement.style.touchAction=``}dispose(){this.disconnect()}handleResize(){let e=this.domElement.getBoundingClientRect(),t=this.domElement.ownerDocument.documentElement;this.screen.left=e.left+window.pageXOffset-t.clientLeft,this.screen.top=e.top+window.pageYOffset-t.clientTop,this.screen.width=e.width,this.screen.height=e.height}update(){this._eye.subVectors(this.object.position,this.target),this.noRotate||this._rotateCamera(),this.noZoom||this._zoomCamera(),this.noPan||this._panCamera(),this.object.position.addVectors(this.target,this._eye),this.object.isPerspectiveCamera?(this._checkDistances(),this.object.lookAt(this.target),this._lastPosition.distanceToSquared(this.object.position)>o3&&(this.dispatchEvent(r3),this._lastPosition.copy(this.object.position))):this.object.isOrthographicCamera?(this.object.lookAt(this.target),(this._lastPosition.distanceToSquared(this.object.position)>o3||this._lastZoom!==this.object.zoom)&&(this.dispatchEvent(r3),this._lastPosition.copy(this.object.position),this._lastZoom=this.object.zoom)):console.warn(`THREE.TrackballControls: Unsupported camera type.`)}reset(){this.state=s3.NONE,this.keyState=s3.NONE,this.target.copy(this._target0),this.object.position.copy(this._position0),this.object.up.copy(this._up0),this.object.zoom=this._zoom0,this.object.updateProjectionMatrix(),this._eye.subVectors(this.object.position,this.target),this.object.lookAt(this.target),this.dispatchEvent(r3),this._lastPosition.copy(this.object.position),this._lastZoom=this.object.zoom}_panCamera(){if(l3.copy(this._panEnd).sub(this._panStart),l3.lengthSq()){if(this.object.isOrthographicCamera){let e=(this.object.right-this.object.left)/this.object.zoom/this.domElement.clientWidth,t=(this.object.top-this.object.bottom)/this.object.zoom/this.domElement.clientWidth;l3.x*=e,l3.y*=t}l3.multiplyScalar(this._eye.length()*this.panSpeed),d3.copy(this._eye).cross(this.object.up).setLength(l3.x),d3.add(u3.copy(this.object.up).setLength(l3.y)),this.object.position.add(d3),this.target.add(d3),this.staticMoving?this._panStart.copy(this._panEnd):this._panStart.add(l3.subVectors(this._panEnd,this._panStart).multiplyScalar(this.dynamicDampingFactor))}}_rotateCamera(){_3.set(this._moveCurr.x-this._movePrev.x,this._moveCurr.y-this._movePrev.y,0);let e=_3.length();e?(this._eye.copy(this.object.position).sub(this.target),m3.copy(this._eye).normalize(),h3.copy(this.object.up).normalize(),g3.crossVectors(h3,m3).normalize(),h3.setLength(this._moveCurr.y-this._movePrev.y),g3.setLength(this._moveCurr.x-this._movePrev.x),_3.copy(h3.add(g3)),f3.crossVectors(_3,this._eye).normalize(),e*=this.rotateSpeed,p3.setFromAxisAngle(f3,e),this._eye.applyQuaternion(p3),this.object.up.applyQuaternion(p3),this._lastAxis.copy(f3),this._lastAngle=e):!this.staticMoving&&this._lastAngle&&(this._lastAngle*=Math.sqrt(1-this.dynamicDampingFactor),this._eye.copy(this.object.position).sub(this.target),p3.setFromAxisAngle(this._lastAxis,this._lastAngle),this._eye.applyQuaternion(p3),this.object.up.applyQuaternion(p3)),this._movePrev.copy(this._moveCurr)}_zoomCamera(){let e;this.state===s3.TOUCH_ZOOM_PAN?(e=this._touchZoomDistanceStart/this._touchZoomDistanceEnd,this._touchZoomDistanceStart=this._touchZoomDistanceEnd,this.object.isPerspectiveCamera?this._eye.multiplyScalar(e):this.object.isOrthographicCamera?(this.object.zoom=Sn.clamp(this.object.zoom/e,this.minZoom,this.maxZoom),this._lastZoom!==this.object.zoom&&this.object.updateProjectionMatrix()):console.warn(`THREE.TrackballControls: Unsupported camera type`)):(e=1+(this._zoomEnd.y-this._zoomStart.y)*this.zoomSpeed,e!==1&&e>0&&(this.object.isPerspectiveCamera?this._eye.multiplyScalar(e):this.object.isOrthographicCamera?(this.object.zoom=Sn.clamp(this.object.zoom/e,this.minZoom,this.maxZoom),this._lastZoom!==this.object.zoom&&this.object.updateProjectionMatrix()):console.warn(`THREE.TrackballControls: Unsupported camera type`)),this.staticMoving?this._zoomStart.copy(this._zoomEnd):this._zoomStart.y+=(this._zoomEnd.y-this._zoomStart.y)*this.dynamicDampingFactor)}_getMouseOnScreen(e,t){return c3.set((e-this.screen.left)/this.screen.width,(t-this.screen.top)/this.screen.height),c3}_getMouseOnCircle(e,t){return c3.set((e-this.screen.width*.5-this.screen.left)/(this.screen.width*.5),(this.screen.height+2*(this.screen.top-t))/this.screen.width),c3}_addPointer(e){this._pointers.push(e)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;tthis.maxDistance*this.maxDistance&&(this.object.position.addVectors(this.target,this._eye.setLength(this.maxDistance)),this._zoomStart.copy(this._zoomEnd)),this._eye.lengthSq()Math.PI&&(n-=B3),r<-Math.PI?r+=B3:r>Math.PI&&(r-=B3),n<=r?this._spherical.theta=Math.max(n,Math.min(r,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(n+r)/2?Math.max(n,this._spherical.theta):Math.min(r,this._spherical.theta)),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):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let i=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{let e=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),i=e!=this._spherical.radius}if(z3.setFromSpherical(this._spherical),z3.applyQuaternion(this._quatInverse),t.copy(this.target).add(z3),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)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let e=null;if(this.object.isPerspectiveCamera){let t=z3.length();e=this._clampDistance(t*this._scale);let n=t-e;this.object.position.addScaledVector(this._dollyDirection,n),this.object.updateMatrixWorld(),i=!!n}else if(this.object.isOrthographicCamera){let t=new R(this._mouse.x,this._mouse.y,0);t.unproject(this.object);let n=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),i=n!==this.object.zoom;let r=new R(this._mouse.x,this._mouse.y,0);r.unproject(this.object),this.object.position.sub(r).add(t),this.object.updateMatrixWorld(),e=z3.length()}else console.warn(`WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled.`),this.zoomToCursor=!1;e!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(e).add(this.object.position):(I3.origin.copy(this.object.position),I3.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(I3.direction))H3||8*(1-this._lastQuaternion.dot(this.object.quaternion))>H3||this._lastTargetPosition.distanceToSquared(this.target)>H3?(this.dispatchEvent(N3),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e===null?B3/60/60*this.autoRotateSpeed:B3/60*this.autoRotateSpeed*e}_getZoomScale(e){let t=Math.abs(e*.01);return .95**(this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){z3.setFromMatrixColumn(t,0),z3.multiplyScalar(-e),this._panOffset.add(z3)}_panUp(e,t){this.screenSpacePanning===!0?z3.setFromMatrixColumn(t,1):(z3.setFromMatrixColumn(t,0),z3.crossVectors(this.object.up,z3)),z3.multiplyScalar(e),this._panOffset.add(z3)}_pan(e,t){let n=this.domElement;if(this.object.isPerspectiveCamera){let r=this.object.position;z3.copy(r).sub(this.target);let i=z3.length();i*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*i/n.clientHeight,this.object.matrix),this._panUp(2*t*i/n.clientHeight,this.object.matrix)}else 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)):(console.warn(`WARNING: OrbitControls.js encountered an unknown camera type - pan disabled.`),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn(`WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled.`),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(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(),r=e-n.left,i=t-n.top,a=n.width,o=n.height;this._mouse.x=r/a*2-1,this._mouse.y=-(i/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(B3*this._rotateDelta.x/t.clientHeight),this._rotateUp(B3*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){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)):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){this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0?this._dollyIn(this._getZoomScale(e.deltaY)):e.deltaY>0&&this._dollyOut(this._getZoomScale(e.deltaY)),this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(B3*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),t=!0;break;case this.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(-B3*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),t=!0;break;case this.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(B3*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),t=!0;break;case this.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(-B3*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),t=!0;break}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=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._rotateStart.set(n,r)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._panStart.set(n,r)}}_handleTouchStartDolly(e){let t=this._getSecondPointerPosition(e),n=e.pageX-t.x,r=e.pageY-t.y,i=Math.sqrt(n*n+r*r);this._dollyStart.set(0,i)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._rotateEnd.set(n,r)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);let t=this.domElement;this._rotateLeft(B3*this._rotateDelta.x/t.clientHeight),this._rotateUp(B3*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=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._panEnd.set(n,r)}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,r=e.pageY-t.y,i=Math.sqrt(n*n+r*r);this._dollyEnd.set(0,i),this._dollyDelta.set(0,(this._dollyEnd.y/this._dollyStart.y)**+this.zoomSpeed),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);let a=(e.pageX+t.x)*.5,o=(e.pageY+t.y)*.5;this._updateZoomParameters(a,o)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;tr6||8*(1-this._lastQuaternion.dot(t.quaternion))>r6)&&(this.dispatchEvent(n6),this._lastQuaternion.copy(t.quaternion),this._lastPosition.copy(t.position))}_updateMovementVector(){let e=this._moveState.forward||this.autoForward&&!this._moveState.back?1:0;this._moveVector.x=-this._moveState.left+this._moveState.right,this._moveVector.y=-this._moveState.down+this._moveState.up,this._moveVector.z=-e+this._moveState.back}_updateRotationVector(){this._rotationVector.x=-this._moveState.pitchDown+this._moveState.pitchUp,this._rotationVector.y=-this._moveState.yawRight+this._moveState.yawLeft,this._rotationVector.z=-this._moveState.rollRight+this._moveState.rollLeft}_getContainerDimensions(){return this.domElement==document?{size:[window.innerWidth,window.innerHeight],offset:[0,0]}:{size:[this.domElement.offsetWidth,this.domElement.offsetHeight],offset:[this.domElement.offsetLeft,this.domElement.offsetTop]}}};function o6(e){if(!(e.altKey||this.enabled===!1)){switch(e.code){case`ShiftLeft`:case`ShiftRight`:this.movementSpeedMultiplier=.1;break;case`KeyW`:this._moveState.forward=1;break;case`KeyS`:this._moveState.back=1;break;case`KeyA`:this._moveState.left=1;break;case`KeyD`:this._moveState.right=1;break;case`KeyR`:this._moveState.up=1;break;case`KeyF`:this._moveState.down=1;break;case`ArrowUp`:this._moveState.pitchUp=1;break;case`ArrowDown`:this._moveState.pitchDown=1;break;case`ArrowLeft`:this._moveState.yawLeft=1;break;case`ArrowRight`:this._moveState.yawRight=1;break;case`KeyQ`:this._moveState.rollLeft=1;break;case`KeyE`:this._moveState.rollRight=1;break}this._updateMovementVector(),this._updateRotationVector()}}function s6(e){if(this.enabled!==!1){switch(e.code){case`ShiftLeft`:case`ShiftRight`:this.movementSpeedMultiplier=1;break;case`KeyW`:this._moveState.forward=0;break;case`KeyS`:this._moveState.back=0;break;case`KeyA`:this._moveState.left=0;break;case`KeyD`:this._moveState.right=0;break;case`KeyR`:this._moveState.up=0;break;case`KeyF`:this._moveState.down=0;break;case`ArrowUp`:this._moveState.pitchUp=0;break;case`ArrowDown`:this._moveState.pitchDown=0;break;case`ArrowLeft`:this._moveState.yawLeft=0;break;case`ArrowRight`:this._moveState.yawRight=0;break;case`KeyQ`:this._moveState.rollLeft=0;break;case`KeyE`:this._moveState.rollRight=0;break}this._updateMovementVector(),this._updateRotationVector()}}function c6(e){if(this.enabled!==!1)if(this.dragToLook)this._status++;else{switch(e.button){case 0:this._moveState.forward=1;break;case 2:this._moveState.back=1;break}this._updateMovementVector()}}function l6(e){if(this.enabled!==!1&&(!this.dragToLook||this._status>0)){let t=this._getContainerDimensions(),n=t.size[0]/2,r=t.size[1]/2;this._moveState.yawLeft=-(e.pageX-t.offset[0]-n)/n,this._moveState.pitchDown=(e.pageY-t.offset[1]-r)/r,this._updateRotationVector()}}function u6(e){if(this.enabled!==!1){if(this.dragToLook)this._status--,this._moveState.yawLeft=this._moveState.pitchDown=0;else{switch(e.button){case 0:this._moveState.forward=0;break;case 2:this._moveState.back=0;break}this._updateMovementVector()}this._updateRotationVector()}}function d6(){this.enabled!==!1&&(this.dragToLook?(this._status=0,this._moveState.yawLeft=this._moveState.pitchDown=0):(this._moveState.forward=0,this._moveState.back=0,this._updateMovementVector()),this._updateRotationVector())}function f6(e){this.enabled!==!1&&e.preventDefault()}var p6={name:`CopyShader`,uniforms:{tDiffuse:{value:null},opacity:{value:1}},vertexShader:` varying vec2 vUv; void main() { vUv = uv; gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); }`,fragmentShader:` uniform float opacity; uniform sampler2D tDiffuse; varying vec2 vUv; void main() { vec4 texel = texture2D( tDiffuse, vUv ); gl_FragColor = opacity * texel; }`},m6=class{constructor(){this.isPass=!0,this.enabled=!0,this.needsSwap=!0,this.clear=!1,this.renderToScreen=!1}setSize(){}render(){console.error(`THREE.Pass: .render() must be implemented in derived pass.`)}dispose(){}},h6=new vc(-1,1,1,-1,0,1),g6=new class extends Di{constructor(){super(),this.setAttribute(`position`,new hi([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute(`uv`,new hi([0,2,0,0,2,0],2))}},_6=class{constructor(e){this._mesh=new ea(g6,e)}dispose(){this._mesh.geometry.dispose()}render(e){e.render(this._mesh,h6)}get material(){return this._mesh.material}set material(e){this._mesh.material=e}},v6=class extends m6{constructor(e,t=`tDiffuse`){super(),this.textureID=t,this.uniforms=null,this.material=null,e instanceof xs?(this.uniforms=e.uniforms,this.material=e):e&&(this.uniforms=vs.clone(e.uniforms),this.material=new xs({name:e.name===void 0?`unspecified`:e.name,defines:Object.assign({},e.defines),uniforms:this.uniforms,vertexShader:e.vertexShader,fragmentShader:e.fragmentShader})),this._fsQuad=new _6(this.material)}render(e,t,n){this.uniforms[this.textureID]&&(this.uniforms[this.textureID].value=n.texture),this._fsQuad.material=this.material,this.renderToScreen?(e.setRenderTarget(null),this._fsQuad.render(e)):(e.setRenderTarget(t),this.clear&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),this._fsQuad.render(e))}dispose(){this.material.dispose(),this._fsQuad.dispose()}},y6=class extends m6{constructor(e,t){super(),this.scene=e,this.camera=t,this.clear=!0,this.needsSwap=!1,this.inverse=!1}render(e,t,n){let r=e.getContext(),i=e.state;i.buffers.color.setMask(!1),i.buffers.depth.setMask(!1),i.buffers.color.setLocked(!0),i.buffers.depth.setLocked(!0);let a,o;this.inverse?(a=0,o=1):(a=1,o=0),i.buffers.stencil.setTest(!0),i.buffers.stencil.setOp(r.REPLACE,r.REPLACE,r.REPLACE),i.buffers.stencil.setFunc(r.ALWAYS,a,4294967295),i.buffers.stencil.setClear(o),i.buffers.stencil.setLocked(!0),e.setRenderTarget(n),this.clear&&e.clear(),e.render(this.scene,this.camera),e.setRenderTarget(t),this.clear&&e.clear(),e.render(this.scene,this.camera),i.buffers.color.setLocked(!1),i.buffers.depth.setLocked(!1),i.buffers.color.setMask(!0),i.buffers.depth.setMask(!0),i.buffers.stencil.setLocked(!1),i.buffers.stencil.setFunc(r.EQUAL,1,4294967295),i.buffers.stencil.setOp(r.KEEP,r.KEEP,r.KEEP),i.buffers.stencil.setLocked(!0)}},b6=class extends m6{constructor(){super(),this.needsSwap=!1}render(e){e.state.buffers.stencil.setLocked(!1),e.state.buffers.stencil.setTest(!1)}},x6=class{constructor(e,t){if(this.renderer=e,this._pixelRatio=e.getPixelRatio(),t===void 0){let n=e.getSize(new L);this._width=n.width,this._height=n.height,t=new Wn(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:pe}),t.texture.name=`EffectComposer.rt1`}else this._width=t.width,this._height=t.height;this.renderTarget1=t,this.renderTarget2=t.clone(),this.renderTarget2.texture.name=`EffectComposer.rt2`,this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2,this.renderToScreen=!0,this.passes=[],this.copyPass=new v6(p6),this.copyPass.material.blending=0,this.timer=new Ac}swapBuffers(){let e=this.readBuffer;this.readBuffer=this.writeBuffer,this.writeBuffer=e}addPass(e){this.passes.push(e),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}insertPass(e,t){this.passes.splice(t,0,e),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}removePass(e){let t=this.passes.indexOf(e);t!==-1&&this.passes.splice(t,1)}isLastEnabledPass(e){for(let t=e+1;t=0&&i<1?(s=a,c=o):i>=1&&i<2?(s=o,c=a):i>=2&&i<3?(c=a,l=o):i>=3&&i<4?(c=o,l=a):i>=4&&i<5?(s=o,l=a):i>=5&&i<6&&(s=a,l=o);var u=n-a/2,d=s+u,f=c+u,p=l+u;return r(d,f,p)}var M6={aliceblue:`f0f8ff`,antiquewhite:`faebd7`,aqua:`00ffff`,aquamarine:`7fffd4`,azure:`f0ffff`,beige:`f5f5dc`,bisque:`ffe4c4`,black:`000`,blanchedalmond:`ffebcd`,blue:`0000ff`,blueviolet:`8a2be2`,brown:`a52a2a`,burlywood:`deb887`,cadetblue:`5f9ea0`,chartreuse:`7fff00`,chocolate:`d2691e`,coral:`ff7f50`,cornflowerblue:`6495ed`,cornsilk:`fff8dc`,crimson:`dc143c`,cyan:`00ffff`,darkblue:`00008b`,darkcyan:`008b8b`,darkgoldenrod:`b8860b`,darkgray:`a9a9a9`,darkgreen:`006400`,darkgrey:`a9a9a9`,darkkhaki:`bdb76b`,darkmagenta:`8b008b`,darkolivegreen:`556b2f`,darkorange:`ff8c00`,darkorchid:`9932cc`,darkred:`8b0000`,darksalmon:`e9967a`,darkseagreen:`8fbc8f`,darkslateblue:`483d8b`,darkslategray:`2f4f4f`,darkslategrey:`2f4f4f`,darkturquoise:`00ced1`,darkviolet:`9400d3`,deeppink:`ff1493`,deepskyblue:`00bfff`,dimgray:`696969`,dimgrey:`696969`,dodgerblue:`1e90ff`,firebrick:`b22222`,floralwhite:`fffaf0`,forestgreen:`228b22`,fuchsia:`ff00ff`,gainsboro:`dcdcdc`,ghostwhite:`f8f8ff`,gold:`ffd700`,goldenrod:`daa520`,gray:`808080`,green:`008000`,greenyellow:`adff2f`,grey:`808080`,honeydew:`f0fff0`,hotpink:`ff69b4`,indianred:`cd5c5c`,indigo:`4b0082`,ivory:`fffff0`,khaki:`f0e68c`,lavender:`e6e6fa`,lavenderblush:`fff0f5`,lawngreen:`7cfc00`,lemonchiffon:`fffacd`,lightblue:`add8e6`,lightcoral:`f08080`,lightcyan:`e0ffff`,lightgoldenrodyellow:`fafad2`,lightgray:`d3d3d3`,lightgreen:`90ee90`,lightgrey:`d3d3d3`,lightpink:`ffb6c1`,lightsalmon:`ffa07a`,lightseagreen:`20b2aa`,lightskyblue:`87cefa`,lightslategray:`789`,lightslategrey:`789`,lightsteelblue:`b0c4de`,lightyellow:`ffffe0`,lime:`0f0`,limegreen:`32cd32`,linen:`faf0e6`,magenta:`f0f`,maroon:`800000`,mediumaquamarine:`66cdaa`,mediumblue:`0000cd`,mediumorchid:`ba55d3`,mediumpurple:`9370db`,mediumseagreen:`3cb371`,mediumslateblue:`7b68ee`,mediumspringgreen:`00fa9a`,mediumturquoise:`48d1cc`,mediumvioletred:`c71585`,midnightblue:`191970`,mintcream:`f5fffa`,mistyrose:`ffe4e1`,moccasin:`ffe4b5`,navajowhite:`ffdead`,navy:`000080`,oldlace:`fdf5e6`,olive:`808000`,olivedrab:`6b8e23`,orange:`ffa500`,orangered:`ff4500`,orchid:`da70d6`,palegoldenrod:`eee8aa`,palegreen:`98fb98`,paleturquoise:`afeeee`,palevioletred:`db7093`,papayawhip:`ffefd5`,peachpuff:`ffdab9`,peru:`cd853f`,pink:`ffc0cb`,plum:`dda0dd`,powderblue:`b0e0e6`,purple:`800080`,rebeccapurple:`639`,red:`f00`,rosybrown:`bc8f8f`,royalblue:`4169e1`,saddlebrown:`8b4513`,salmon:`fa8072`,sandybrown:`f4a460`,seagreen:`2e8b57`,seashell:`fff5ee`,sienna:`a0522d`,silver:`c0c0c0`,skyblue:`87ceeb`,slateblue:`6a5acd`,slategray:`708090`,slategrey:`708090`,snow:`fffafa`,springgreen:`00ff7f`,steelblue:`4682b4`,tan:`d2b48c`,teal:`008080`,thistle:`d8bfd8`,tomato:`ff6347`,turquoise:`40e0d0`,violet:`ee82ee`,wheat:`f5deb3`,white:`fff`,whitesmoke:`f5f5f5`,yellow:`ff0`,yellowgreen:`9acd32`};function N6(e){if(typeof e!=`string`)return e;var t=e.toLowerCase();return M6[t]?`#`+M6[t]:e}var P6=/^#[a-fA-F0-9]{6}$/,F6=/^#[a-fA-F0-9]{8}$/,I6=/^#[a-fA-F0-9]{3}$/,L6=/^#[a-fA-F0-9]{4}$/,R6=/^rgb\(\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*\)$/i,z6=/^rgb(?:a)?\(\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,|\/)\s*([-+]?\d*[.]?\d+[%]?)\s*\)$/i,B6=/^hsl\(\s*(\d{0,3}[.]?[0-9]+(?:deg)?)\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*\)$/i,V6=/^hsl(?:a)?\(\s*(\d{0,3}[.]?[0-9]+(?:deg)?)\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,|\/)\s*([-+]?\d*[.]?\d+[%]?)\s*\)$/i;function H6(e){if(typeof e!=`string`)throw new O6(3);var t=N6(e);if(t.match(P6))return{red:parseInt(``+t[1]+t[2],16),green:parseInt(``+t[3]+t[4],16),blue:parseInt(``+t[5]+t[6],16)};if(t.match(F6)){var n=parseFloat((parseInt(``+t[7]+t[8],16)/255).toFixed(2));return{red:parseInt(``+t[1]+t[2],16),green:parseInt(``+t[3]+t[4],16),blue:parseInt(``+t[5]+t[6],16),alpha:n}}if(t.match(I6))return{red:parseInt(``+t[1]+t[1],16),green:parseInt(``+t[2]+t[2],16),blue:parseInt(``+t[3]+t[3],16)};if(t.match(L6)){var r=parseFloat((parseInt(``+t[4]+t[4],16)/255).toFixed(2));return{red:parseInt(``+t[1]+t[1],16),green:parseInt(``+t[2]+t[2],16),blue:parseInt(``+t[3]+t[3],16),alpha:r}}var i=R6.exec(t);if(i)return{red:parseInt(``+i[1],10),green:parseInt(``+i[2],10),blue:parseInt(``+i[3],10)};var a=z6.exec(t.substring(0,50));if(a)return{red:parseInt(``+a[1],10),green:parseInt(``+a[2],10),blue:parseInt(``+a[3],10),alpha:parseFloat(``+a[4])>1?parseFloat(``+a[4])/100:parseFloat(``+a[4])};var o=B6.exec(t);if(o){var s=`rgb(`+j6(parseInt(``+o[1],10),parseInt(``+o[2],10)/100,parseInt(``+o[3],10)/100)+`)`,c=R6.exec(s);if(!c)throw new O6(4,t,s);return{red:parseInt(``+c[1],10),green:parseInt(``+c[2],10),blue:parseInt(``+c[3],10)}}var l=V6.exec(t.substring(0,50));if(l){var u=`rgb(`+j6(parseInt(``+l[1],10),parseInt(``+l[2],10)/100,parseInt(``+l[3],10)/100)+`)`,d=R6.exec(u);if(!d)throw new O6(4,t,u);return{red:parseInt(``+d[1],10),green:parseInt(``+d[2],10),blue:parseInt(``+d[3],10),alpha:parseFloat(``+l[4])>1?parseFloat(``+l[4])/100:parseFloat(``+l[4])}}throw new O6(5)}function U6(e){var t=e.red/255,n=e.green/255,r=e.blue/255,i=Math.max(t,n,r),a=Math.min(t,n,r),o=(i+a)/2;if(i===a)return e.alpha===void 0?{hue:0,saturation:0,lightness:o}:{hue:0,saturation:0,lightness:o,alpha:e.alpha};var s,c=i-a,l=o>.5?c/(2-i-a):c/(i+a);switch(i){case t:s=(n-r)/c+(n=1?Y6(e,t,n):`rgba(`+j6(e,t,n)+`,`+r+`)`;if(typeof e==`object`&&t===void 0&&n===void 0&&r===void 0)return e.alpha>=1?Y6(e.hue,e.saturation,e.lightness):`rgba(`+j6(e.hue,e.saturation,e.lightness)+`,`+e.alpha+`)`;throw new O6(2)}function Q6(e,t,n){if(typeof e==`number`&&typeof t==`number`&&typeof n==`number`)return G6(`#`+K6(e)+K6(t)+K6(n));if(typeof e==`object`&&t===void 0&&n===void 0)return G6(`#`+K6(e.red)+K6(e.green)+K6(e.blue));throw new O6(6)}function $6(e,t,n,r){if(typeof e==`string`&&typeof t==`number`){var i=H6(e);return`rgba(`+i.red+`,`+i.green+`,`+i.blue+`,`+t+`)`}else if(typeof e==`number`&&typeof t==`number`&&typeof n==`number`&&typeof r==`number`)return r>=1?Q6(e,t,n):`rgba(`+e+`,`+t+`,`+n+`,`+r+`)`;else if(typeof e==`object`&&t===void 0&&n===void 0&&r===void 0)return e.alpha>=1?Q6(e.red,e.green,e.blue):`rgba(`+e.red+`,`+e.green+`,`+e.blue+`,`+e.alpha+`)`;throw new O6(7)}var e8=function(e){return typeof e.red==`number`&&typeof e.green==`number`&&typeof e.blue==`number`&&(typeof e.alpha!=`number`||e.alpha===void 0)},t8=function(e){return typeof e.red==`number`&&typeof e.green==`number`&&typeof e.blue==`number`&&typeof e.alpha==`number`},n8=function(e){return typeof e.hue==`number`&&typeof e.saturation==`number`&&typeof e.lightness==`number`&&(typeof e.alpha!=`number`||e.alpha===void 0)},r8=function(e){return typeof e.hue==`number`&&typeof e.saturation==`number`&&typeof e.lightness==`number`&&typeof e.alpha==`number`};function i8(e){if(typeof e!=`object`)throw new O6(8);if(t8(e))return $6(e);if(e8(e))return Q6(e);if(r8(e))return Z6(e);if(n8(e))return X6(e);throw new O6(8)}function a8(e,t,n){return function(){var r=n.concat(Array.prototype.slice.call(arguments));return r.length>=t?e.apply(this,r):a8(e,t,r)}}function o8(e){return a8(e,e.length,[])}function s8(e,t){if(t===`transparent`)return t;var n=W6(t);return i8(r({},n,{hue:n.hue+parseFloat(e)}))}o8(s8);function c8(e,t,n){return Math.max(e,Math.min(t,n))}function l8(e,t){if(t===`transparent`)return t;var n=W6(t);return i8(r({},n,{lightness:c8(0,1,n.lightness-parseFloat(e))}))}o8(l8);function u8(e,t){if(t===`transparent`)return t;var n=W6(t);return i8(r({},n,{saturation:c8(0,1,n.saturation-parseFloat(e))}))}o8(u8);function d8(e,t){if(t===`transparent`)return t;var n=W6(t);return i8(r({},n,{lightness:c8(0,1,n.lightness+parseFloat(e))}))}o8(d8);function f8(e,t,n){if(t===`transparent`)return n;if(n===`transparent`)return t;if(e===0)return n;var i=H6(t),a=r({},i,{alpha:typeof i.alpha==`number`?i.alpha:1}),o=H6(n),s=r({},o,{alpha:typeof o.alpha==`number`?o.alpha:1}),c=a.alpha-s.alpha,l=parseFloat(e)*2-1,u=((l*c===-1?l:l+c)/(1+l*c)+1)/2,d=1-u;return $6({red:Math.floor(a.red*u+s.red*d),green:Math.floor(a.green*u+s.green*d),blue:Math.floor(a.blue*u+s.blue*d),alpha:a.alpha*parseFloat(e)+s.alpha*(1-parseFloat(e))})}var p8=o8(f8);function m8(e,t){if(t===`transparent`)return t;var n=H6(t);return $6(r({},n,{alpha:c8(0,1,((typeof n.alpha==`number`?n.alpha:1)*100+parseFloat(e)*100)/100)}))}var h8=o8(m8);function g8(e,t){if(t===`transparent`)return t;var n=W6(t);return i8(r({},n,{saturation:c8(0,1,n.saturation+parseFloat(e))}))}o8(g8);function _8(e,t){return t===`transparent`?t:i8(r({},W6(t),{hue:parseFloat(e)}))}o8(_8);function v8(e,t){return t===`transparent`?t:i8(r({},W6(t),{lightness:parseFloat(e)}))}o8(v8);function y8(e,t){return t===`transparent`?t:i8(r({},W6(t),{saturation:parseFloat(e)}))}o8(y8);function b8(e,t){return t===`transparent`?t:p8(parseFloat(e),`rgb(0, 0, 0)`,t)}o8(b8);function x8(e,t){return t===`transparent`?t:p8(parseFloat(e),`rgb(255, 255, 255)`,t)}o8(x8);function S8(e,t){if(t===`transparent`)return t;var n=H6(t);return $6(r({},n,{alpha:c8(0,1,((typeof n.alpha==`number`?n.alpha:1)*100-parseFloat(e)*100).toFixed(2)/100)}))}o8(S8);var C8={svg:`http://www.w3.org/2000/svg`,xhtml:`http://www.w3.org/1999/xhtml`,xlink:`http://www.w3.org/1999/xlink`,xml:`http://www.w3.org/XML/1998/namespace`,xmlns:`http://www.w3.org/2000/xmlns/`};function w8(e){var t=e+=``,n=t.indexOf(`:`);return n>=0&&(t=e.slice(0,n))!==`xmlns`&&(e=e.slice(n+1)),C8.hasOwnProperty(t)?{space:C8[t],local:e}:e}function T8(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===`http://www.w3.org/1999/xhtml`&&t.documentElement.namespaceURI===`http://www.w3.org/1999/xhtml`?t.createElement(e):t.createElementNS(n,e)}}function E8(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function D8(e){var t=w8(e);return(t.local?E8:T8)(t)}function O8(){}function k8(e){return e==null?O8:function(){return this.querySelector(e)}}function A8(e){typeof e!=`function`&&(e=k8(e));for(var t=this._groups,n=t.length,r=Array(n),i=0;i=v&&(v=_+1);!(b=g[v])&&++v=0;)(o=r[i])&&(a&&o.compareDocumentPosition(a)^4&&a.parentNode.insertBefore(o,a),a=o);return this}function o5(e){e||=s5;function t(t,n){return t&&n?e(t.__data__,n.__data__):!t-!n}for(var n=this._groups,r=n.length,i=Array(r),a=0;at?1:e>=t?0:NaN}function c5(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function l5(){return Array.from(this)}function u5(){for(var e=this._groups,t=0,n=e.length;t1?this.each((t==null?S5:typeof t==`function`?w5:C5)(e,t,n??``)):E5(this.node(),e)}function E5(e,t){return e.style.getPropertyValue(t)||x5(e).getComputedStyle(e,null).getPropertyValue(t)}function D5(e){return function(){delete this[e]}}function O5(e,t){return function(){this[e]=t}}function k5(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function A5(e,t){return arguments.length>1?this.each((t==null?D5:typeof t==`function`?k5:O5)(e,t)):this.node()[e]}function j5(e){return e.trim().split(/^|\s+/)}function M5(e){return e.classList||new N5(e)}function N5(e){this._node=e,this._names=j5(e.getAttribute(`class`)||``)}N5.prototype={add:function(e){this._names.indexOf(e)<0&&(this._names.push(e),this._node.setAttribute(`class`,this._names.join(` `)))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute(`class`,this._names.join(` `)))},contains:function(e){return this._names.indexOf(e)>=0}};function P5(e,t){for(var n=M5(e),r=-1,i=t.length;++r=0&&(t=e.slice(n+1),e=e.slice(0,n)),{type:e,name:t}})}function l7(e){return function(){var t=this.__on;if(t){for(var n=0,r=-1,i=t.length,a;n2&&(o.children=arguments.length>3?w7.call(arguments,2):n),typeof e==`function`&&e.defaultProps!=null)for(a in e.defaultProps)o[a]===void 0&&(o[a]=e.defaultProps[a]);return K7(e,o,r,i,null)}function K7(e,t,n,r,i){var a={type:e,props:t,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:i??++E7,__i:-1,__u:0};return i==null&&T7.vnode!=null&&T7.vnode(a),a}function q7(e){return e.children}function J7(e,t){this.props=e,this.context=t}function Y7(e,t){if(t==null)return e.__?Y7(e.__,e.__i+1):null;for(var n;tt&&O7.sort(j7),e=O7.shift(),t=O7.length,X7(e)}finally{O7.length=$7.__r=0}}function e9(e,t,n,r,i,a,o,s,c,l,u){var d,f,p,m,h,g,_,v=r&&r.__k||B7,y=t.length;for(c=t9(n,t,v,c,y),d=0;d0?o=e.__k[a]=K7(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):e.__k[a]=o,c=a+f,o.__=e,o.__b=e.__b+1,s=null,(l=o.__i=r9(o,n,c,d))!=-1&&(d--,(s=n[l])&&(s.__u|=2)),s==null||s.__v==null?(l==-1&&(i>u?f--:ic?f--:f++,o.__u|=4))):e.__k[a]=null;if(d)for(a=0;a(u?1:0)){for(i=n-1,a=n+1;i>=0||a=0?i--:a++])!=null&&!(2&l.__u)&&s==l.key&&c==l.type)return o}return-1}function i9(e,t,n){t[0]==`-`?e.setProperty(t,n??``):e[t]=n==null?``:typeof n!=`number`||V7.test(t)?n:n+`px`}function a9(e,t,n,r,i){var a,o;n:if(t==`style`)if(typeof n==`string`)e.style.cssText=n;else{if(typeof r==`string`&&(e.style.cssText=r=``),r)for(t in r)n&&t in n||i9(e.style,t,``);if(n)for(t in n)r&&n[t]==r[t]||i9(e.style,t,n[t])}else if(t[0]==`o`&&t[1]==`n`)a=t!=(t=t.replace(F7,`$1`)),o=t.toLowerCase(),t=o in e||t==`onFocusOut`||t==`onFocusIn`?o.slice(2):t.slice(2),e.l||={},e.l[t+a]=n,n?r?n[P7]=r[P7]:(n[P7]=I7,e.addEventListener(t,a?R7:L7,a)):e.removeEventListener(t,a?R7:L7,a);else{if(i==`http://www.w3.org/2000/svg`)t=t.replace(/xlink(H|:h)/,`h`).replace(/sName$/,`s`);else if(t!=`width`&&t!=`height`&&t!=`href`&&t!=`list`&&t!=`form`&&t!=`tabIndex`&&t!=`download`&&t!=`rowSpan`&&t!=`colSpan`&&t!=`role`&&t!=`popover`&&t in e)try{e[t]=n??``;break n}catch{}typeof n==`function`||(n==null||!1===n&&t[4]!=`-`?e.removeAttribute(t):e.setAttribute(t,t==`popover`&&n==1?``:n))}}function o9(e){return function(t){if(this.l){var n=this.l[t.type+e];if(t[N7]==null)t[N7]=I7++;else if(t[N7]0?e:H7(e)?e.map(u9):e.constructor===void 0?U7({},e):null}function d9(e,t,n,r,i,a,o,s,c){var l,u,d,f,p,m,h,g=n.props||z7,_=t.props,v=t.type;if(v==`svg`?i=`http://www.w3.org/2000/svg`:v==`math`?i=`http://www.w3.org/1998/Math/MathML`:i||=`http://www.w3.org/1999/xhtml`,a!=null){for(l=0;l2&&(s.children=arguments.length>3?w7.call(arguments,2):n),K7(e.type,s,r||e.key,i||e.ref,null)}w7=B7.slice,T7={__e:function(e,t,n,r){for(var i,a,o;t=t.__;)if((i=t.__c)&&!i.__)try{if((a=i.constructor)&&a.getDerivedStateFromError!=null&&(i.setState(a.getDerivedStateFromError(e)),o=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(e,r||{}),o=i.__d),o)return i.__E=i}catch(t){e=t}throw e}},E7=0,D7=function(e){return e!=null&&e.constructor===void 0},J7.prototype.setState=function(e,t){var n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=U7({},this.state);typeof e==`function`&&(e=e(U7({},n),this.props)),e&&U7(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),Q7(this))},J7.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),Q7(this))},J7.prototype.render=q7,O7=[],A7=typeof Promise==`function`?Promise.prototype.then.bind(Promise.resolve()):setTimeout,j7=function(e,t){return e.__v.__b-t.__v.__b},$7.__r=0,M7=Math.random().toString(8),N7=`__d`+M7,P7=`__a`+M7,F7=/(PointerCapture)$|Capture$/i,I7=0,L7=o9(!1),R7=o9(!0);function _9(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n`u`)){var r=document.head||document.getElementsByTagName(`head`)[0],i=document.createElement(`style`);i.type=`text/css`,n===`top`&&r.firstChild?r.insertBefore(i,r.firstChild):r.appendChild(i),i.styleSheet?i.styleSheet.cssText=e:i.appendChild(document.createTextNode(e))}}M9(`.float-tooltip-kap { position: absolute; width: max-content; /* prevent shrinking near right edge */ max-width: max(50%, 150px); padding: 3px 5px; border-radius: 3px; font: 12px sans-serif; color: #eee; background: rgba(0,0,0,0.6); pointer-events: none; } `);var N9=wp({props:{content:{default:!1},offsetX:{triggerUpdate:!1},offsetY:{triggerUpdate:!1}},init:function(e,t){var n=(arguments.length>2&&arguments[2]!==void 0?arguments[2]:{}).style,r=n===void 0?{}:n,i=x7(e&&D9(e)===`object`&&e.node&&typeof e.node==`function`?e.node():e);i.style(`position`)===`static`&&i.style(`position`,`relative`),t.tooltipEl=i.append(`div`).attr(`class`,`float-tooltip-kap`),Object.entries(r).forEach(function(e){var n=w9(e,2),r=n[0],i=n[1];return t.tooltipEl.style(r,i)}),t.tooltipEl.style(`left`,`-10000px`).style(`display`,`none`);var a=`tooltip-${Math.round(Math.random()*0xe8d4a51000)}`;t.mouseInside=!1,i.on(`mousemove.${a}`,function(e){t.mouseInside=!0;var n=C7(e),r=i.node(),a=r.offsetWidth,o=r.offsetHeight,s=[t.offsetX===null||t.offsetX===void 0?`-${n[0]/a*100}%`:typeof t.offsetX==`number`?`calc(-50% + ${t.offsetX}px)`:t.offsetX,t.offsetY===null||t.offsetY===void 0?o>130&&o-n[1]<100?`calc(-100% - 6px)`:`21px`:typeof t.offsetY==`number`?t.offsetY<0?`calc(-100% - ${Math.abs(t.offsetY)}px)`:`${t.offsetY}px`:t.offsetY];t.tooltipEl.style(`left`,n[0]+`px`).style(`top`,n[1]+`px`).style(`transform`,`translate(${s.join(`,`)})`),t.content&&t.tooltipEl.style(`display`,`inline`)}),i.on(`mouseover.${a}`,function(){t.mouseInside=!0,t.content&&t.tooltipEl.style(`display`,`inline`)}),i.on(`mouseout.${a}`,function(){t.mouseInside=!1,t.tooltipEl.style(`display`,`none`)})},update:function(e){e.tooltipEl.style(`display`,e.content&&e.mouseInside?`inline`:`none`),e.content?e.content instanceof HTMLElement?(e.tooltipEl.text(``),e.tooltipEl.append(function(){return e.content})):typeof e.content==`string`?e.tooltipEl.html(e.content):A9(e.content)?(e.tooltipEl.text(``),j9(e.content,e.tooltipEl.node())):(e.tooltipEl.style(`display`,`none`),console.warn(`Tooltip content is invalid, skipping.`,e.content,e.content.toString())):e.tooltipEl.text(``)}});function P9(e,t){t===void 0&&(t={});var n=t.insertAt;if(!(typeof document>`u`)){var r=document.head||document.getElementsByTagName(`head`)[0],i=document.createElement(`style`);i.type=`text/css`,n===`top`&&r.firstChild?r.insertBefore(i,r.firstChild):r.appendChild(i),i.styleSheet?i.styleSheet.cssText=e:i.appendChild(document.createTextNode(e))}}P9(`.scene-nav-info { position: absolute; bottom: 5px; width: 100%; text-align: center; color: slategrey; opacity: 0.7; font-size: 10px; font-family: sans-serif; pointer-events: none; user-select: none; } .scene-container canvas:focus { outline: none; }`);function F9(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n=e.pointerRaycasterThrottleMs){e.lastRaycasterCheck=t;var n=null;if(e.hoverDuringDrag||!e.isPointerDragging){var r=this.intersectingObjects(e.pointerPos.x,e.pointerPos.y);e.hoverOrderComparator&&r.sort(function(t,n){return e.hoverOrderComparator(t.object,n.object)});var i=r.find(function(t){return e.hoverFilter(t.object)})||null;n=i?i.object:null,e.intersection=i||null}n!==e.hoverObj&&(e.onHover(n,e.hoverObj,e.intersection),e.tooltip.content(n&&V(e.tooltipContent)(n,e.intersection)||null),e.hoverObj=n)}e.tweenGroup.update()}return this},getPointerPos:function(e){var t=e.pointerPos;return{x:t.x,y:t.y}},cameraPosition:function(e,t,n,r){var i=e.camera;if(t&&e.initialised){var a,o,s=t,c=n||{x:0,y:0,z:0};if((a=e.povPosTween)==null||a.end(),(o=e.povTgtTween)==null||o.end(),!r)d(s),f(c);else{var l=Object.assign({},i.position),u=p();e.tweenGroup.add(e.povPosTween=new jp(l).to(s,r).easing(Tp.Quadratic.Out).onUpdate(d).onComplete(function(){e.povPosTween=void 0,e.tweenGroup.remove(this)}).start()),e.tweenGroup.add(e.povTgtTween=new jp(u).to(c,r/3).easing(Tp.Quadratic.Out).onUpdate(f).onComplete(function(){e.povTgtTween=void 0,e.tweenGroup.remove(this)}).start())}return this}return Object.assign({},i.position,{lookAt:p()});function d(e){var t=e.x,n=e.y,r=e.z;t!==void 0&&(i.position.x=t),n!==void 0&&(i.position.y=n),r!==void 0&&(i.position.z=r)}function f(t){var n=new B9.Vector3(t.x,t.y,t.z);e.controls.enabled&&e.controls.target?e.controls.target=n:i.lookAt(n)}function p(){return Object.assign(new B9.Vector3(0,0,-1e3).applyQuaternion(i.quaternion).add(i.position))}},zoomToFit:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:10,r=[...arguments].slice(3);return this.fitToBbox(this.getBbox.apply(this,r),t,n)},fitToBbox:function(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:10,i=e.camera;if(t){var a=new B9.Vector3(0,0,0),o=Math.max.apply(Math,I9(Object.entries(t).map(function(e){var t=Dee(e,2),n=t[0],r=t[1];return Math.max.apply(Math,I9(r.map(function(e){return Math.abs(a[n]-e)})))})))*2,s=(1-r*2/e.height)*i.fov,c=o/Math.atan(s*Math.PI/180),l=c/i.aspect,u=Math.max(c,l);if(u>0){var d=a.clone().sub(i.position).normalize().multiplyScalar(-u);this.cameraPosition(d,a,n)}}return this},getBbox:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:function(){return!0},n=new B9.Box3(new B9.Vector3(0,0,0),new B9.Vector3(0,0,0)),r=e.objects.filter(t);return r.length?(r.forEach(function(e){return n.expandByObject(e)}),Object.assign.apply(Object,I9([`x`,`y`,`z`].map(function(e){return See({},e,[n.min[e],n.max[e]])})))):null},getScreenCoords:function(e,t,n,r){var i=new B9.Vector3(t,n,r);return i.project(this.camera()),{x:(i.x+1)*e.width/2,y:-(i.y-1)*e.height/2}},getSceneCoords:function(e,t,n){var r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0,i=new B9.Vector2(t/e.width*2-1,-(n/e.height)*2+1),a=new B9.Raycaster;return a.setFromCamera(i,e.camera),Object.assign({},a.ray.at(r,new B9.Vector3))},intersectingObjects:function(e,t,n){var r=new B9.Vector2(t/e.width*2-1,-(n/e.height)*2+1),i=new B9.Raycaster;return i.params.Line.threshold=e.lineHoverPrecision,i.params.Points.threshold=e.pointsHoverPrecision,i.setFromCamera(r,e.camera),i.intersectObjects(e.objects,!0)},renderer:function(e){return e.renderer},scene:function(e){return e.scene},camera:function(e){return e.camera},postProcessingComposer:function(e){return e.postProcessingComposer},controls:function(e){return e.controls},tbControls:function(e){return e.controls},_destructor:function(e){var t,n,r;Aee(e.scene),(t=e.controls)==null||t.dispose(),(n=e.renderer)==null||n.dispose(),(r=e.postProcessingComposer)==null||r.dispose()}},stateInit:function(){return{scene:new B9.Scene,camera:new B9.PerspectiveCamera,timer:new B9.Timer,tweenGroup:new Dp,lastRaycasterCheck:0}},init:function(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},r=n.controlType,i=r===void 0?`trackball`:r,a=n.useWebGPU,o=a===void 0?!1:a,s=n.rendererConfig,c=s===void 0?{}:s,l=n.extraRenderers,u=l===void 0?[]:l,d=n.waitForLoadComplete,f=d===void 0?!0:d;e.innerHTML=``,e.appendChild(t.container=document.createElement(`div`)),t.container.className=`scene-container`,t.container.style.position=`relative`,t.container.appendChild(t.navInfo=document.createElement(`div`)),t.navInfo.className=`scene-nav-info`,t.navInfo.textContent={orbit:`Left-click: rotate, Mouse-wheel/middle-click: zoom, Right-click: pan`,trackball:`Left-click: rotate, Mouse-wheel/middle-click: zoom, Right-click: pan`,fly:`WASD: move, R|F: up | down, Q|E: roll, up|down: pitch, left|right: yaw`}[i]||``,t.navInfo.style.display=t.showNavInfo?null:`none`,t.tooltip=new N9(t.container),t.pointerPos=new B9.Vector2,t.pointerPos.x=-2,t.pointerPos.y=-2,[`pointermove`,`pointerdown`].forEach(function(e){return t.container.addEventListener(e,function(n){if(e===`pointerdown`&&(t.isPointerPressed=!0),!t.isPointerDragging&&n.type===`pointermove`&&(n.pressure>0||t.isPointerPressed)&&(n.pointerType===`mouse`||n.movementX===void 0||[n.movementX,n.movementY].some(function(e){return Math.abs(e)>1}))&&(t.isPointerDragging=!0),t.enablePointerInteraction){var r=i(t.container);t.pointerPos.x=n.pageX-r.left,t.pointerPos.y=n.pageY-r.top}function i(e){var t=e.getBoundingClientRect(),n=window.pageXOffset||document.documentElement.scrollLeft,r=window.pageYOffset||document.documentElement.scrollTop;return{top:t.top+r,left:t.left+n}}},{passive:!0})}),t.container.addEventListener(`pointerup`,function(e){t.isPointerPressed&&(t.isPointerPressed=!1,!(t.isPointerDragging&&(t.isPointerDragging=!1,!t.clickAfterDrag))&&requestAnimationFrame(function(){e.button===0&&t.onClick(t.hoverObj||null,e,t.intersection),e.button===2&&t.onRightClick&&t.onRightClick(t.hoverObj||null,e,t.intersection)}))},{passive:!0,capture:!0}),t.container.addEventListener(`contextmenu`,function(e){t.onRightClick&&e.preventDefault()}),t.renderer=new(o?p1:B9.WebGLRenderer)(Object.assign({antialias:!0,alpha:!0},c)),t.renderer.setPixelRatio(Math.min(2,window.devicePixelRatio)),t.container.appendChild(t.renderer.domElement),t.extraRenderers=u,t.extraRenderers.forEach(function(e){e.domElement.style.position=`absolute`,e.domElement.style.top=`0px`,e.domElement.style.pointerEvents=`none`,t.container.appendChild(e.domElement)}),t.postProcessingComposer=new x6(t.renderer),t.postProcessingComposer.addPass(new S6(t.scene,t.camera)),t.controls=new{trackball:v3,orbit:U3,fly:a6}[i](t.camera,t.renderer.domElement),i===`fly`&&(t.controls.movementSpeed=300,t.controls.rollSpeed=Math.PI/6,t.controls.dragToLook=!0),(i===`trackball`||i===`orbit`)&&(t.controls.minDistance=.1,t.controls.maxDistance=t.skyRadius,t.controls.addEventListener(`start`,function(){t.controlsEngaged=!0}),t.controls.addEventListener(`change`,function(){t.controlsEngaged&&(t.controlsDragging=!0)}),t.controls.addEventListener(`end`,function(){t.controlsEngaged=!1,t.controlsDragging=!1})),[t.renderer,t.postProcessingComposer].concat(I9(t.extraRenderers)).forEach(function(e){return e.setSize(t.width,t.height)}),t.camera.aspect=t.width/t.height,t.camera.updateProjectionMatrix(),t.camera.position.z=1e3,t.scene.add(t.skysphere=new B9.Mesh),t.skysphere.visible=!1,t.loadComplete=t.scene.visible=!f,window.scene=t.scene},update:function(e,t){if(e.width&&e.height&&(t.hasOwnProperty(`width`)||t.hasOwnProperty(`height`))){var n,r=e.width,i=e.height;e.container.style.width=`${r}px`,e.container.style.height=`${i}px`,[e.renderer,e.postProcessingComposer].concat(I9(e.extraRenderers)).forEach(function(e){return e.setSize(r,i)}),e.camera.aspect=r/i;var a=e.viewOffset.slice(0,2);a.some(function(e){return e})&&(n=e.camera).setViewOffset.apply(n,[r,i].concat(I9(a),[r,i])),e.camera.updateProjectionMatrix()}if(t.hasOwnProperty(`viewOffset`)){var o,s=e.width,c=e.height,l=e.viewOffset.slice(0,2);l.some(function(e){return e})?(o=e.camera).setViewOffset.apply(o,[s,c].concat(I9(l),[s,c])):e.camera.clearViewOffset()}if(t.hasOwnProperty(`skyRadius`)&&e.skyRadius&&(e.controls.hasOwnProperty(`maxDistance`)&&t.skyRadius&&(e.controls.maxDistance=Math.min(e.controls.maxDistance,e.skyRadius)),e.camera.far=e.skyRadius*2.5,e.camera.updateProjectionMatrix(),e.skysphere.geometry=new B9.SphereGeometry(e.skyRadius)),t.hasOwnProperty(`backgroundColor`)){var u=H6(e.backgroundColor).alpha;u===void 0&&(u=1),e.renderer.setClearColor(new B9.Color(h8(1,e.backgroundColor)),u)}t.hasOwnProperty(`backgroundImageUrl`)&&(e.backgroundImageUrl?new B9.TextureLoader().load(e.backgroundImageUrl,function(t){t.colorSpace=B9.SRGBColorSpace,e.skysphere.material=new B9.MeshBasicMaterial({map:t,side:B9.BackSide}),e.skysphere.visible=!0,e.onBackgroundImageLoaded&&setTimeout(e.onBackgroundImageLoaded),!e.loadComplete&&d()}):(e.skysphere.visible=!1,e.skysphere.material.map=null,!e.loadComplete&&d())),t.hasOwnProperty(`showNavInfo`)&&(e.navInfo.style.display=e.showNavInfo?null:`none`),t.hasOwnProperty(`lights`)&&((t.lights||[]).forEach(function(t){return e.scene.remove(t)}),e.lights.forEach(function(t){return e.scene.add(t)})),t.hasOwnProperty(`objects`)&&((t.objects||[]).forEach(function(t){return e.scene.remove(t)}),e.objects.forEach(function(t){return e.scene.add(t)}));function d(){e.loadComplete=e.scene.visible=!0}}});function jee(e,t){t===void 0&&(t={});var n=t.insertAt;if(!(typeof document>`u`)){var r=document.head||document.getElementsByTagName(`head`)[0],i=document.createElement(`style`);i.type=`text/css`,n===`top`&&r.firstChild?r.insertBefore(i,r.firstChild):r.appendChild(i),i.styleSheet?i.styleSheet.cssText=e:i.appendChild(document.createTextNode(e))}}jee(`.scene-container .clickable { cursor: pointer; }`);function H9(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n1&&arguments[1]!==void 0?arguments[1]:{},n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,r=o();if(t.lat===void 0&&t.lng===void 0&&t.altitude===void 0)return r;var i,a=Object.assign({},r,t);if([`lat`,`lng`,`altitude`].forEach(function(e){return a[e]=+a[e]}),(i=e.povTween)==null||i.end(),!n)s(a);else{for(;r.lng-a.lng>180;)r.lng-=360;for(;r.lng-a.lng<-180;)r.lng+=360;e.tweenGroup.add(e.povTween=new jp(r).to(a,n).easing(Tp.Cubic.InOut).onUpdate(s).onComplete(function(){e.povTween=void 0,e.tweenGroup.remove(this)}).start())}return this;function o(){return e.globe.toGeoCoords(e.renderObjs.cameraPosition())}function s(t){var n=t.lat,r=t.lng,i=t.altitude;e.renderObjs.cameraPosition(e.globe.getCoords(n,r,i)),e.globe.setPointOfView(e.renderObjs.camera())}},getScreenCoords:function(e){var t,n=[...arguments].slice(1),r=(t=e.globe).getCoords.apply(t,n);return e.renderObjs.getScreenCoords(r.x,r.y,r.z)},toGlobeCoords:function(e,t,n){var r=e.renderObjs.intersectingObjects(t,n).find(function(e){return(e.object.__globeObjType||e.object.parent.__globeObjType)===`globe`});if(!r)return null;var i=e.globe.toGeoCoords(r.point);return{lat:i.lat,lng:i.lng}},scene:function(e){return e.renderObjs.scene()},camera:function(e){return e.renderObjs.camera()},renderer:function(e){return e.renderObjs.renderer()},controls:function(e){return e.renderObjs.controls()},_destructor:function(e){this.pauseAnimation(),this.pointsData([]),this.arcsData([]),this.polygonsData([]),this.pathsData([]),this.heatmapsData([]),this.hexBinPointsData([]),this.hexPolygonsData([]),this.tilesData([]),this.particlesData([]),this.labelsData([]),this.htmlElementsData([]),this.objectsData([]),this.customLayerData([]),e.globe._destructor(),e.renderObjs._destructor()}},Hee),Wee),stateInit:function(e){var t=e.rendererConfig,n=e.waitForGlobeReady,r=n===void 0?!0:n,i=Fee(e,Bee),a=new n3(G9({waitForGlobeReady:r},i));return{globe:a,renderObjs:V9({controlType:`orbit`,rendererConfig:t,waitForLoadComplete:r,extraRenderers:[new J9.CSS2DRenderer]}).skyRadius(a.getGlobeRadius()*500).showNavInfo(!1).objects([a]).lights([new J9.AmbientLight(13421772,Math.PI),new J9.DirectionalLight(16777215,.6*Math.PI)]),tweenGroup:new Dp}},init:function(e,t){var n=this;e.innerHTML=``,e.appendChild(t.container=document.createElement(`div`)),t.container.style.position=`relative`;var r=document.createElement(`div`);t.container.appendChild(r),t.renderObjs(r),t.globe.rendererSize(t.renderObjs.renderer().getSize(new J9.Vector2)),this.pointOfView({altitude:2.5});var i=t.globe.getGlobeRadius(),a=t.renderObjs.controls();t.renderObjs.camera().near=.05,a.minDistance=i+Math.max(.001,t.renderObjs.camera().near*1.1),a.maxDistance=i*100,a.enablePan=!1,a.enableDamping=!0,a.dampingFactor=.1,a.rotateSpeed=.3,a.zoomSpeed=.3,a.zoomToCursor=!0,a.addEventListener(`change`,function(){a.target.setScalar(0);var e=n.pointOfView();a.rotateSpeed=e.altitude*.3,a.zoomSpeed=Math.sqrt(e.altitude)*.5,t.globe.setPointOfView(t.renderObjs.camera()),t.onZoom&&t.onZoom(e)});var o=function(e){for(var t=e;t&&!t.hasOwnProperty(`__globeObjType`);)t=t.parent;return t},s={point:function(e){return e},arc:function(e){return e},polygon:function(e){return e.data},path:function(e){return e},heatmap:function(e){return e},hexbin:function(e){return e},hexPolygon:function(e){return e},tile:function(e){return e},particles:function(e,t){return!t||!t.hasOwnProperty(`index`)||e.length<=t.index?e:e[t.index]},label:function(e){return e},object:function(e){return e},custom:function(e){return e}};J9.REVISION<155&&(t.renderObjs.renderer().useLegacyLights=!1),t.renderObjs.hoverFilter(function(e){var n=o(e);if(!n)return!1;var r=n.__globeObjType;if(r!==`globe`&&!s.hasOwnProperty(r))return!1;var i=s.hasOwnProperty(r)&&n.__data?s[r](n.__data):null;return[`points`,`hexBinPoints`].some(function(e){return e===r})&&Array.isArray(i)?!1:t.pointerEventsFilter(n,i)}).tooltipContent(function(e,n){var r={point:t.pointLabel,arc:t.arcLabel,polygon:t.polygonLabel,path:t.pathLabel,hexbin:t.hexLabel,hexPolygon:t.hexPolygonLabel,tile:t.tileLabel,particles:t.particleLabel,label:t.labelLabel,object:t.objectLabel,custom:t.customLayerLabel},i=o(e),a=i&&i.__globeObjType;return i&&a&&r.hasOwnProperty(a)&&s.hasOwnProperty(a)&&V(r[a])(s[a](i.__data,n))||``}).onHover(function(e,n,r){var i={point:t.onPointHover,arc:t.onArcHover,polygon:t.onPolygonHover,path:t.onPathHover,heatmap:t.onHeatmapHover,hexbin:t.onHexHover,hexPolygon:t.onHexPolygonHover,tile:t.onTileHover,particles:t.onParticleHover,label:t.onLabelHover,object:t.onObjectHover,custom:t.onCustomLayerHover},a={globe:t.onGlobeClick,point:t.onPointClick,arc:t.onArcClick,polygon:t.onPolygonClick,path:t.onPathClick,heatmap:t.onHeatmapClick,hexbin:t.onHexClick,hexPolygon:t.onHexPolygonClick,tile:t.onTileClick,particles:t.onParticleClick,label:t.onLabelClick,object:t.onObjectClick,custom:t.onCustomLayerClick},c=o(e);if(c&&!i.hasOwnProperty(c.__globeObjType)&&(c=null),c!==t.hoverObj){var l,u=t.hoverObj?t.hoverObj.__globeObjType:null,d=t.hoverData,f=c?c.__globeObjType:null,p=(l=c)!=null&&l.__data?s[f](c.__data,r):null;u&&u!==f&&i[u]&&i[u](null,d||null),f&&i[f]&&i[f](p,u===f?d:null),t.renderObjs.renderer().domElement.classList[f&&a[f]&&V(t.showPointerCursor)(f,p)?`add`:`remove`](`clickable`),t.hoverObj=c,t.hoverData=p}}).onClick(function(e,r,i){if(e){var a={globe:t.onGlobeClick,point:t.onPointClick,arc:t.onArcClick,polygon:t.onPolygonClick,path:t.onPathClick,heatmap:t.onHeatmapClick,hexbin:t.onHexClick,hexPolygon:t.onHexPolygonClick,tile:t.onTileClick,particles:t.onParticleClick,label:t.onLabelClick,object:t.onObjectClick,custom:t.onCustomLayerClick},c=o(e),l=c.__globeObjType;if(c&&a.hasOwnProperty(l)&&a[l]){var u=[r],d=i!=null&&i.isVector3?i:i?.point;if(l===`globe`){var f=n.toGeoCoords(d),p=f.lat,m=f.lng;u.unshift({lat:p,lng:m})}else u.push(n.toGeoCoords(d));s.hasOwnProperty(l)&&u.unshift(s[l](c.__data,i)),a[l].apply(a,u)}}}).onRightClick(function(e,r,i){if(e){var a={globe:t.onGlobeRightClick,point:t.onPointRightClick,arc:t.onArcRightClick,polygon:t.onPolygonRightClick,path:t.onPathRightClick,heatmap:t.onHeatmapRightClick,hexbin:t.onHexRightClick,hexPolygon:t.onHexPolygonRightClick,tile:t.onTileRightClick,particles:t.onParticleRightClick,label:t.onLabelRightClick,object:t.onObjectRightClick,custom:t.onCustomLayerRightClick},c=o(e),l=c.__globeObjType;if(c&&a.hasOwnProperty(l)&&a[l]){var u=[r],d=i!=null&&i.isVector3?i:i?.point;if(l===`globe`){var f=n.toGeoCoords(d),p=f.lat,m=f.lng;u.unshift({lat:p,lng:m})}else u.push(n.toGeoCoords(d));s.hasOwnProperty(l)&&u.unshift(s[l](c.__data,i)),a[l].apply(a,u)}}}),this._animationCycle()}}),$=o(c(),1),Kee={width:$.default.number,height:$.default.number,globeOffset:$.default.arrayOf($.default.number),backgroundColor:$.default.string,backgroundImageUrl:$.default.string,globeImageUrl:$.default.string,bumpImageUrl:$.default.string,globeTileEngineUrl:$.default.func,showGlobe:$.default.bool,showGraticules:$.default.bool,showAtmosphere:$.default.bool,atmosphereColor:$.default.string,atmosphereAltitude:$.default.number,globeMaterial:$.default.object,onGlobeReady:$.default.func,onGlobeClick:$.default.func,onGlobeRightClick:$.default.func,pointsData:$.default.arrayOf($.default.object),pointLat:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),pointLng:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),pointColor:$.default.oneOfType([$.default.string,$.default.func]),pointAltitude:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),pointRadius:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),pointResolution:$.default.number,pointsMerge:$.default.bool,pointsTransitionDuration:$.default.number,pointLabel:$.default.oneOfType([$.default.string,$.default.func]),onPointClick:$.default.func,onPointRightClick:$.default.func,onPointHover:$.default.func,arcsData:$.default.arrayOf($.default.object),arcStartLat:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),arcStartLng:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),arcEndLat:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),arcEndLng:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),arcColor:$.default.oneOfType([$.default.string,$.default.arrayOf($.default.string),$.default.func]),arcAltitude:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),arcAltitudeAutoScale:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),arcStroke:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),arcCurveResolution:$.default.number,arcCircularResolution:$.default.number,arcDashLength:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),arcDashGap:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),arcDashInitialGap:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),arcDashAnimateTime:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),arcsTransitionDuration:$.default.number,arcLabel:$.default.oneOfType([$.default.string,$.default.func]),onArcClick:$.default.func,onArcRightClick:$.default.func,onArcHover:$.default.func,polygonsData:$.default.arrayOf($.default.object),polygonGeoJsonGeometry:$.default.oneOfType([$.default.string,$.default.func]),polygonCapColor:$.default.oneOfType([$.default.string,$.default.func]),polygonCapMaterial:$.default.oneOfType([$.default.object,$.default.string,$.default.func]),polygonSideColor:$.default.oneOfType([$.default.string,$.default.func]),polygonSideMaterial:$.default.oneOfType([$.default.object,$.default.string,$.default.func]),polygonStrokeColor:$.default.oneOfType([$.default.string,$.default.func]),polygonAltitude:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),polygonCapCurvatureResolution:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),polygonsTransitionDuration:$.default.number,polygonLabel:$.default.oneOfType([$.default.string,$.default.func]),onPolygonClick:$.default.func,onPolygonRightClick:$.default.func,onPolygonHover:$.default.func,pathsData:$.default.array,pathPoints:$.default.oneOfType([$.default.array,$.default.string,$.default.func]),pathPointLat:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),pathPointLng:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),pathPointAlt:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),pathResolution:$.default.number,pathColor:$.default.oneOfType([$.default.string,$.default.arrayOf($.default.string),$.default.func]),pathStroke:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),pathDashLength:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),pathDashGap:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),pathDashInitialGap:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),pathDashAnimateTime:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),pathTransitionDuration:$.default.number,pathLabel:$.default.oneOfType([$.default.string,$.default.func]),onPathClick:$.default.func,onPathRightClick:$.default.func,onPathHover:$.default.func,heatmapsData:$.default.array,heatmapPoints:$.default.oneOfType([$.default.array,$.default.string,$.default.func]),heatmapPointLat:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),heatmapPointLng:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),heatmapPointWeight:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),heatmapBandwidth:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),heatmapColorFn:$.default.oneOfType([$.default.string,$.default.func]),heatmapColorSaturation:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),heatmapBaseAltitude:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),heatmapTopAltitude:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),heatmapsTransitionDuration:$.default.number,onHeatmapClick:$.default.func,onHeatmapRightClick:$.default.func,onHeatmapHover:$.default.func,hexBinPointsData:$.default.arrayOf($.default.object),hexBinPointLat:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),hexBinPointLng:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),hexBinPointWeight:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),hexBinResolution:$.default.number,hexMargin:$.default.oneOfType([$.default.number,$.default.func]),hexTopColor:$.default.func,hexSideColor:$.default.func,hexAltitude:$.default.oneOfType([$.default.number,$.default.func]),hexTopCurvatureResolution:$.default.number,hexBinMerge:$.default.bool,hexTransitionDuration:$.default.number,hexLabel:$.default.oneOfType([$.default.string,$.default.func]),onHexClick:$.default.func,onHexRightClick:$.default.func,onHexHover:$.default.func,hexPolygonsData:$.default.arrayOf($.default.object),hexPolygonGeoJsonGeometry:$.default.oneOfType([$.default.string,$.default.func]),hexPolygonColor:$.default.oneOfType([$.default.string,$.default.func]),hexPolygonAltitude:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),hexPolygonResolution:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),hexPolygonMargin:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),hexPolygonUseDots:$.default.oneOfType([$.default.bool,$.default.string,$.default.func]),hexPolygonCurvatureResolution:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),hexPolygonDotResolution:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),hexPolygonsTransitionDuration:$.default.number,hexPolygonLabel:$.default.oneOfType([$.default.string,$.default.func]),onHexPolygonClick:$.default.func,onHexPolygonRightClick:$.default.func,onHexPolygonHover:$.default.func,tilesData:$.default.arrayOf($.default.object),tileLat:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),tileLng:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),tileAltitude:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),tileWidth:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),tileHeight:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),tileUseGlobeProjection:$.default.oneOfType([$.default.bool,$.default.string,$.default.func]),tileMaterial:$.default.oneOfType([$.default.object,$.default.string,$.default.func]),tileCurvatureResolution:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),tilesTransitionDuration:$.default.number,tileLabel:$.default.oneOfType([$.default.string,$.default.func]),onTileClick:$.default.func,onTileRightClick:$.default.func,onTileHover:$.default.func,particlesData:$.default.arrayOf($.default.object),particlesList:$.default.oneOfType([$.default.string,$.default.func]),particleLat:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),particleLng:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),particleAltitude:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),particlesSize:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),particlesSizeAttenuation:$.default.oneOfType([$.default.bool,$.default.string,$.default.func]),particlesColor:$.default.oneOfType([$.default.string,$.default.func]),particlesTexture:$.default.oneOfType([$.default.string,$.default.func]),particleLabel:$.default.oneOfType([$.default.string,$.default.func]),onParticleClick:$.default.func,onParticleRightClick:$.default.func,onParticleHover:$.default.func,ringsData:$.default.arrayOf($.default.object),ringLat:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),ringLng:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),ringAltitude:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),ringColor:$.default.oneOfType([$.default.string,$.default.arrayOf($.default.string),$.default.func]),ringResolution:$.default.number,ringMaxRadius:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),ringPropagationSpeed:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),ringRepeatPeriod:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),labelsData:$.default.arrayOf($.default.object),labelLat:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),labelLng:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),labelAltitude:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),labelRotation:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),labelText:$.default.oneOfType([$.default.string,$.default.func]),labelSize:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),labelTypeFace:$.default.object,labelColor:$.default.oneOfType([$.default.string,$.default.func]),labelResolution:$.default.number,labelIncludeDot:$.default.oneOfType([$.default.bool,$.default.string,$.default.func]),labelDotRadius:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),labelDotOrientation:$.default.oneOfType([$.default.string,$.default.func]),labelsTransitionDuration:$.default.number,labelLabel:$.default.oneOfType([$.default.string,$.default.func]),onLabelClick:$.default.func,onLabelRightClick:$.default.func,onLabelHover:$.default.func,htmlElementsData:$.default.arrayOf($.default.object),htmlLat:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),htmlLng:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),htmlAltitude:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),htmlElement:$.default.oneOfType([$.default.string,$.default.func]),htmlElementVisibilityModifier:$.default.func,htmlTransitionDuration:$.default.number,objectsData:$.default.arrayOf($.default.object),objectLat:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),objectLng:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),objectAltitude:$.default.oneOfType([$.default.number,$.default.string,$.default.func]),objectRotation:$.default.oneOfType([$.default.shape({x:$.default.number,y:$.default.number,z:$.default.number}),$.default.string,$.default.func]),objectFacesSurface:$.default.oneOfType([$.default.bool,$.default.string,$.default.func]),objectThreeObject:$.default.oneOfType([$.default.object,$.default.string,$.default.func]),objectLabel:$.default.oneOfType([$.default.string,$.default.func]),onObjectClick:$.default.func,onObjectRightClick:$.default.func,onObjectHover:$.default.func,customLayerData:$.default.arrayOf($.default.object),customThreeObject:$.default.oneOfType([$.default.object,$.default.string,$.default.func]),customThreeObjectUpdate:$.default.oneOfType([$.default.string,$.default.func]),customLayerLabel:$.default.oneOfType([$.default.string,$.default.func]),onCustomLayerClick:$.default.func,onCustomLayerRightClick:$.default.func,onCustomLayerHover:$.default.func,enablePointerInteraction:$.default.bool,pointerEventsFilter:$.default.func,lineHoverPrecision:$.default.number,showPointerCursor:$.default.oneOfType([$.default.bool,$.default.func]),onZoom:$.default.func},Z9=E(Gee,{methodNames:[`pauseAnimation`,`resumeAnimation`,`pointOfView`,`lights`,`scene`,`camera`,`renderer`,`postProcessingComposer`,`controls`,`getGlobeRadius`,`getCoords`,`getScreenCoords`,`toGeoCoords`,`toGlobeCoords`,`globeTileEngineClearCache`],initPropNames:[`animateIn`,`waitForGlobeReady`,`rendererConfig`]});Z9.displayName=`Globe`,Z9.propTypes=Kee;var Q9=s(),$9=n.globe;function qee(e){let t=e.address??{},n=[t.street,t.additional,[t.postalCode,t.city,t.region].filter(Boolean).join(` `),t.country].filter(Boolean),r=e.contact?.phone??``;return`

`}function Jee({locations:e,mapText:t}){let n=(0,d.useRef)(null),r=(0,d.useRef)(null),[i,a]=(0,d.useState)(!1),o=(0,d.useRef)(null),[s,c]=(0,d.useState)({features:[]}),[l,u]=(0,d.useState)({size:900,left:-320,top:-140}),f=(0,d.useMemo)(()=>new Ts({color:$9.surface_color,transparent:!0,opacity:$9.surface_opacity,shininess:$9.surface_shininess}),[]),p=(0,d.useRef)($9.auto_rotate_speed);(0,d.useEffect)(()=>{let e=n.current;if(!e)return;let t=e.controls();t.autoRotate=!0,t.autoRotateSpeed=$9.auto_rotate_speed,t.enableZoom=!1,p.current=$9.auto_rotate_speed;let a=()=>{let e=i?0:$9.auto_rotate_speed,n=p.current,o=e-n;if(Math.abs(o)>5e-4){let e=n+o*.06;p.current=e,t.autoRotateSpeed=e,r.current=requestAnimationFrame(a)}else p.current=e,t.autoRotateSpeed=e,r.current=null};return r.current=requestAnimationFrame(a),()=>{r.current&&=(cancelAnimationFrame(r.current),null)}},[i]),(0,d.useEffect)(()=>{fetch($9.geojson_url).then(e=>{if(!e.ok)throw Error(`GeoJSON konnte nicht geladen werden: ${e.status}`);return e.json()}).then(e=>{c(e)}).catch(()=>{})},[]),(0,d.useEffect)(()=>{let e=o.current;if(!e)return;let t=new ResizeObserver(e=>{for(let t of e){let e=t.contentRect.width,n=t.contentRect.height;if(e<10||n<10)continue;let r=Math.round(Math.max(e,n)*$9.size_factor),i=e*$9.centre_x,a=n*$9.centre_y;u({size:r,left:Math.round(i-r/2),top:Math.round(a-r/2)})}});return t.observe(e),()=>{t.disconnect()}},[]),(0,d.useEffect)(()=>()=>{f.dispose()},[f]);let m=(0,d.useMemo)(()=>e.filter(e=>e.coordinates?.latitude!==void 0&&e.coordinates?.longitude!==void 0).map(e=>({lat:e.coordinates?.latitude??0,lng:e.coordinates?.longitude??0,color:$9.marker_color,loc:e})),[e]),h=(0,d.useCallback)(e=>qee(e.loc),[]),g=(0,d.useCallback)(e=>{let t=e.loc.links?.contact??`/contact`;window.location.href=t},[]);return(0,Q9.jsxs)(`div`,{className:`vitec_locationmap`,children:[(0,Q9.jsx)(`div`,{className:`vitec_locationmap__globe-col`,ref:o,onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),children:(0,Q9.jsx)(`div`,{className:`vitec_locationmap__globe-canvas`,style:{width:l.size,height:l.size,left:l.left,top:l.top},children:(0,Q9.jsx)(Z9,{ref:n,width:l.size,height:l.size,backgroundColor:`rgba(0, 0, 0, 0)`,globeMaterial:f,showGlobe:!0,showAtmosphere:!0,atmosphereColor:$9.atmosphere_color,atmosphereAltitude:$9.atmosphere_altitude,hexPolygonsData:s.features,hexPolygonResolution:$9.hex_resolution,hexPolygonMargin:$9.hex_margin,hexPolygonColor:()=>$9.hex_color,pointsData:m,pointLat:`lat`,pointLng:`lng`,pointColor:`color`,pointRadius:$9.marker_radius,pointAltitude:$9.marker_altitude,pointLabel:h,onPointClick:g})})}),t&&(0,Q9.jsx)(`div`,{className:`vitec_locationmap__text-col`,dangerouslySetInnerHTML:{__html:t}})]})}export{Jee as VitecGlobeMap};