var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(e&&(t=e(e=0)),t),s=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),c=(e,n)=>{let r={};for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n||t(r,Symbol.toStringTag,{value:`Module`}),r},l=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;li[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},u=(n,r,a)=>(a=n==null?{}:e(i(n)),l(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n)),d=e=>a.call(e,`module.exports`)?e[`module.exports`]:l(t({},`__esModule`,{value:!0}),e);(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var f=s((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.portal`),r=Symbol.for(`react.fragment`),i=Symbol.for(`react.strict_mode`),a=Symbol.for(`react.profiler`),o=Symbol.for(`react.consumer`),s=Symbol.for(`react.context`),c=Symbol.for(`react.forward_ref`),l=Symbol.for(`react.suspense`),u=Symbol.for(`react.memo`),d=Symbol.for(`react.lazy`),f=Symbol.for(`react.activity`),p=Symbol.iterator;function m(e){return typeof e!=`object`||!e?null:(e=p&&e[p]||e[`@@iterator`],typeof e==`function`?e:null)}var h={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},g=Object.assign,_={};function v(e,t,n){this.props=e,this.context=t,this.refs=_,this.updater=n||h}v.prototype.isReactComponent={},v.prototype.setState=function(e,t){if(typeof e!=`object`&&typeof e!=`function`&&e!=null)throw Error(`takes an object of state variables to update or a function which returns an object of state variables.`);this.updater.enqueueSetState(this,e,t,`setState`)},v.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,`forceUpdate`)};function y(){}y.prototype=v.prototype;function b(e,t,n){this.props=e,this.context=t,this.refs=_,this.updater=n||h}var x=b.prototype=new y;x.constructor=b,g(x,v.prototype),x.isPureReactComponent=!0;var S=Array.isArray;function C(){}var w={H:null,A:null,T:null,S:null},T=Object.prototype.hasOwnProperty;function E(e,n,r){var i=r.ref;return{$$typeof:t,type:e,key:n,ref:i===void 0?null:i,props:r}}function D(e,t){return E(e.type,t,e.props)}function O(e){return typeof e==`object`&&!!e&&e.$$typeof===t}function k(e){var t={"=":`=0`,":":`=2`};return`$`+e.replace(/[=:]/g,function(e){return t[e]})}var A=/\/+/g;function j(e,t){return typeof e==`object`&&e&&e.key!=null?k(``+e.key):t.toString(36)}function ee(e){switch(e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason;default:switch(typeof e.status==`string`?e.then(C,C):(e.status=`pending`,e.then(function(t){e.status===`pending`&&(e.status=`fulfilled`,e.value=t)},function(t){e.status===`pending`&&(e.status=`rejected`,e.reason=t)})),e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason}}throw e}function te(e,r,i,a,o){var s=typeof e;(s===`undefined`||s===`boolean`)&&(e=null);var c=!1;if(e===null)c=!0;else switch(s){case`bigint`:case`string`:case`number`:c=!0;break;case`object`:switch(e.$$typeof){case t:case n:c=!0;break;case d:return c=e._init,te(c(e._payload),r,i,a,o)}}if(c)return o=o(e),c=a===``?`.`+j(e,0):a,S(o)?(i=``,c!=null&&(i=c.replace(A,`$&/`)+`/`),te(o,r,i,``,function(e){return e})):o!=null&&(O(o)&&(o=D(o,i+(o.key==null||e&&e.key===o.key?``:(``+o.key).replace(A,`$&/`)+`/`)+c)),r.push(o)),1;c=0;var l=a===``?`.`:a+`:`;if(S(e))for(var u=0;u{t.exports=f()})),m=s((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0>>1,a=e[r];if(0>>1;ri(c,n))li(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(li(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m)if(n(c)!==null)m=!0,S||(S=!0,O());else{var t=n(l);t!==null&&j(x,t.startTime-e)}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-Tt&&E());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&j(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?O():S=!1}}}var O;if(typeof y==`function`)O=function(){y(D)};else if(typeof MessageChannel<`u`){var k=new MessageChannel,A=k.port2;k.port1.onmessage=D,O=function(){A.postMessage(null)}}else O=function(){_(D,0)};function j(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,j(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,O()))),r},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),h=s(((e,t)=>{t.exports=m()})),g=s((e=>{var t=p();function n(e){var t=`https://react.dev/errors/`+e;if(1{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=g()})),v=s((e=>{var t=h(),n=p(),r=_();function i(e){var t=`https://react.dev/errors/`+e;if(1ie||(e.current=re[ie],re[ie]=null,ie--)}function L(e,t){ie++,re[ie]=e.current,e.current=t}var oe=I(null),se=I(null),ce=I(null),le=I(null);function ue(e,t){switch(L(ce,t),L(se,e),L(oe,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Kd(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Kd(t),e=qd(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}ae(oe),L(oe,e)}function de(){ae(oe),ae(se),ae(ce)}function fe(e){e.memoizedState!==null&&L(le,e);var t=oe.current,n=qd(t,e.type);t!==n&&(L(se,e),L(oe,n))}function pe(e){se.current===e&&(ae(oe),ae(se)),le.current===e&&(ae(le),Y._currentValue=ne)}var me,he;function ge(e){if(me===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);me=t&&t[1]||``,he=-1)`:-1i||c[r]!==l[i]){var u=` `+c[r].replace(` at new `,` at `);return e.displayName&&u.includes(``)&&(u=u.replace(``,e.displayName)),u}while(1<=r&&0<=i);break}}}finally{_e=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:``)?ge(n):``}function ye(e,t){switch(e.tag){case 26:case 27:case 5:return ge(e.type);case 16:return ge(`Lazy`);case 13:return e.child!==t&&t!==null?ge(`Suspense Fallback`):ge(`Suspense`);case 19:return ge(`SuspenseList`);case 0:case 15:return ve(e.type,!1);case 11:return ve(e.type.render,!1);case 1:return ve(e.type,!0);case 31:return ge(`Activity`);default:return``}}function be(e){try{var t=``,n=null;do t+=ye(e,n),n=e,e=e.return;while(e);return t}catch(e){return` Error generating stack: `+e.message+` `+e.stack}}var xe=Object.prototype.hasOwnProperty,Se=t.unstable_scheduleCallback,Ce=t.unstable_cancelCallback,R=t.unstable_shouldYield,we=t.unstable_requestPaint,Te=t.unstable_now,Ee=t.unstable_getCurrentPriorityLevel,z=t.unstable_ImmediatePriority,De=t.unstable_UserBlockingPriority,Oe=t.unstable_NormalPriority,ke=t.unstable_LowPriority,B=t.unstable_IdlePriority,Ae=t.log,je=t.unstable_setDisableYieldValue,Me=null,Ne=null;function Pe(e){if(typeof Ae==`function`&&je(e),Ne&&typeof Ne.setStrictMode==`function`)try{Ne.setStrictMode(Me,e)}catch{}}var Fe=Math.clz32?Math.clz32:Re,Ie=Math.log,Le=Math.LN2;function Re(e){return e>>>=0,e===0?32:31-(Ie(e)/Le|0)|0}var ze=256,Be=262144,Ve=4194304;function He(e){var t=e&42;if(t!==0)return t;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return e&261888;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function Ue(e,t,n){var r=e.pendingLanes;if(r===0)return 0;var i=0,a=e.suspendedLanes,o=e.pingedLanes;e=e.warmLanes;var s=r&134217727;return s===0?(s=r&~a,s===0?o===0?n||(n=r&~e,n!==0&&(i=He(n))):i=He(o):i=He(s)):(r=s&~a,r===0?(o&=s,o===0?n||(n=s&~e,n!==0&&(i=He(n))):i=He(o)):i=He(r)),i===0?0:t!==0&&t!==i&&(t&a)===0&&(a=i&-i,n=t&-t,a>=n||a===32&&n&4194048)?t:i}function We(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function Ge(e,t){switch(e){case 1:case 2:case 4:case 8:case 64:return t+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Ke(){var e=Ve;return Ve<<=1,!(Ve&62914560)&&(Ve=4194304),e}function qe(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function Je(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function Ye(e,t,n,r,i,a){var o=e.pendingLanes;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=n,e.entangledLanes&=n,e.errorRecoveryDisabledLanes&=n,e.shellSuspendCounter=0;var s=e.entanglements,c=e.expirationTimes,l=e.hiddenUpdates;for(n=o&~n;0`u`||window.document===void 0||window.document.createElement===void 0),on=!1;if(H)try{var sn={};Object.defineProperty(sn,"passive",{get:function(){on=!0}}),window.addEventListener(`test`,sn,sn),window.removeEventListener(`test`,sn,sn)}catch{on=!1}var cn=null,ln=null,un=null;function dn(){if(un)return un;var e,t=ln,n=t.length,r,i=`value`in cn?cn.value:cn.textContent,a=i.length;for(e=0;e=Bn),Un=` `,Wn=!1;function Gn(e,t){switch(e){case`keyup`:return Rn.indexOf(t.keyCode)!==-1;case`keydown`:return t.keyCode!==229;case`keypress`:case`mousedown`:case`focusout`:return!0;default:return!1}}function Kn(e){return e=e.detail,typeof e==`object`&&`data`in e?e.data:null}var qn=!1;function Jn(e,t){switch(e){case`compositionend`:return Kn(t);case`keypress`:return t.which===32?(Wn=!0,Un):null;case`textInput`:return e=t.data,e===Un&&Wn?null:e;default:return null}}function Yn(e,t){if(qn)return e===`compositionend`||!zn&&Gn(e,t)?(e=dn(),un=ln=cn=null,qn=!1,e):null;switch(e){case`paste`:return null;case`keypress`:if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1=t)return{node:n,offset:t-e};e=r}a:{for(;n;){if(n.nextSibling){n=n.nextSibling;break a}n=n.parentNode}n=void 0}n=_r(n)}}function yr(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?yr(e,t.parentNode):`contains`in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function br(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=Pt(e.document);t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href==`string`}catch{n=!1}if(n)e=t.contentWindow;else break;t=Pt(e.document)}return t}function xr(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t===`input`&&(e.type===`text`||e.type===`search`||e.type===`tel`||e.type===`url`||e.type===`password`)||t===`textarea`||e.contentEditable===`true`)}var Sr=H&&`documentMode`in document&&11>=document.documentMode,Cr=null,wr=null,Tr=null,Er=!1;function Dr(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Er||Cr==null||Cr!==Pt(r)||(r=Cr,`selectionStart`in r&&xr(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),Tr&&gr(Tr,r)||(Tr=r,r=jd(wr,`onSelect`),0>=o,i-=o,vi=1<<32-Fe(t)+i|n<h?(g=d,d=null):g=d.sibling;var _=p(i,d,s[h],c);if(_===null){d===null&&(d=g);break}e&&d&&_.alternate===null&&t(i,d),a=o(_,a,h),u===null?l=_:u.sibling=_,u=_,d=g}if(h===s.length)return n(i,d),Di&&bi(i,h),l;if(d===null){for(;hg?(_=h,h=null):_=h.sibling;var y=p(a,h,v.value,l);if(y===null){h===null&&(h=_);break}e&&h&&y.alternate===null&&t(a,h),s=o(y,s,g),d===null?u=y:d.sibling=y,d=y,h=_}if(v.done)return n(a,h),Di&&bi(a,g),u;if(h===null){for(;!v.done;g++,v=c.next())v=f(a,v.value,l),v!==null&&(s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return Di&&bi(a,g),u}for(h=r(h);!v.done;g++,v=c.next())v=m(h,a,g,v.value,l),v!==null&&(e&&v.alternate!==null&&h.delete(v.key===null?g:v.key),s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return e&&h.forEach(function(e){return t(a,e)}),Di&&bi(a,g),u}function b(e,r,o,c){if(typeof o==`object`&&o&&o.type===y&&o.key===null&&(o=o.props.children),typeof o==`object`&&o){switch(o.$$typeof){case g:a:{for(var l=o.key;r!==null;){if(r.key===l){if(l=o.type,l===y){if(r.tag===7){n(e,r.sibling),c=a(r,o.props.children),c.return=e,e=c;break a}}else if(r.elementType===l||typeof l==`object`&&l&&l.$$typeof===O&&ba(l)===r.type){n(e,r.sibling),c=a(r,o.props),Da(c,o),c.return=e,e=c;break a}n(e,r);break}else t(e,r);r=r.sibling}o.type===y?(c=ai(o.props.children,e.mode,c,o.key),c.return=e,e=c):(c=ii(o.type,o.key,o.props,null,e.mode,c),Da(c,o),c.return=e,e=c)}return s(e);case v:a:{for(l=o.key;r!==null;){if(r.key===l)if(r.tag===4&&r.stateNode.containerInfo===o.containerInfo&&r.stateNode.implementation===o.implementation){n(e,r.sibling),c=a(r,o.children||[]),c.return=e,e=c;break a}else{n(e,r);break}else t(e,r);r=r.sibling}c=ci(o,e.mode,c),c.return=e,e=c}return s(e);case O:return o=ba(o),b(e,r,o,c)}if(N(o))return h(e,r,o,c);if(ee(o)){if(l=ee(o),typeof l!=`function`)throw Error(i(150));return o=l.call(o),_(e,r,o,c)}if(typeof o.then==`function`)return b(e,r,Ea(o),c);if(o.$$typeof===C)return b(e,r,Ji(e,o),c);Oa(e,o)}return typeof o==`string`&&o!==``||typeof o==`number`||typeof o==`bigint`?(o=``+o,r!==null&&r.tag===6?(n(e,r.sibling),c=a(r,o),c.return=e,e=c):(n(e,r),c=oi(o,e.mode,c),c.return=e,e=c),s(e)):n(e,r)}return function(e,t,n,r){try{Ta=0;var i=b(e,t,n,r);return wa=null,i}catch(t){if(t===ma||t===ga)throw t;var a=ei(29,t,null,e.mode);return a.lanes=r,a.return=e,a}}}var Aa=ka(!0),ja=ka(!1),Ma=!1;function Na(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Pa(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function Fa(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function Ia(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,Ll&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,t=Zr(e),Xr(e,null,n),t}return qr(e,r,t,n),Zr(e)}function La(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,n&4194048)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Ze(e,n)}}function Ra(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,a=null;if(n=n.firstBaseUpdate,n!==null){do{var o={lane:n.lane,tag:n.tag,payload:n.payload,callback:null,next:null};a===null?i=a=o:a=a.next=o,n=n.next}while(n!==null);a===null?i=a=t:a=a.next=t}else i=a=t;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:a,shared:r.shared,callbacks:r.callbacks},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}var za=!1;function Ba(){if(za){var e=aa;if(e!==null)throw e}}function Va(e,t,n,r){za=!1;var i=e.updateQueue;Ma=!1;var a=i.firstBaseUpdate,o=i.lastBaseUpdate,s=i.shared.pending;if(s!==null){i.shared.pending=null;var c=s,l=c.next;c.next=null,o===null?a=l:o.next=l,o=c;var u=e.alternate;u!==null&&(u=u.updateQueue,s=u.lastBaseUpdate,s!==o&&(s===null?u.firstBaseUpdate=l:s.next=l,u.lastBaseUpdate=c))}if(a!==null){var d=i.baseState;o=0,u=l=c=null,s=a;do{var p=s.lane&-536870913,m=p!==s.lane;if(m?(Bl&p)===p:(r&p)===p){p!==0&&p===ia&&(za=!0),u!==null&&(u=u.next={lane:0,tag:s.tag,payload:s.payload,callback:null,next:null});a:{var h=e,g=s;p=t;var _=n;switch(g.tag){case 1:if(h=g.payload,typeof h==`function`){d=h.call(_,d,p);break a}d=h;break a;case 3:h.flags=h.flags&-65537|128;case 0:if(h=g.payload,p=typeof h==`function`?h.call(_,d,p):h,p==null)break a;d=f({},d,p);break a;case 2:Ma=!0}}p=s.callback,p!==null&&(e.flags|=64,m&&(e.flags|=8192),m=i.callbacks,m===null?i.callbacks=[p]:m.push(p))}else m={lane:p,tag:s.tag,payload:s.payload,callback:s.callback,next:null},u===null?(l=u=m,c=d):u=u.next=m,o|=p;if(s=s.next,s===null){if(s=i.shared.pending,s===null)break;m=s,s=m.next,m.next=null,i.lastBaseUpdate=m,i.shared.pending=null}}while(1);u===null&&(c=d),i.baseState=c,i.firstBaseUpdate=l,i.lastBaseUpdate=u,a===null&&(i.shared.lanes=0),Jl|=o,e.lanes=o,e.memoizedState=d}}function Ha(e,t){if(typeof e!=`function`)throw Error(i(191,e));e.call(t)}function Ua(e,t){var n=e.callbacks;if(n!==null)for(e.callbacks=null,e=0;ea?a:8;var o=P.T,s={};P.T=s,As(e,!1,t,n);try{var c=i(),l=P.S;l!==null&&l(s,c),typeof c==`object`&&c&&typeof c.then==`function`?ks(e,t,ca(c,r),gu(e)):ks(e,t,r,gu(e))}catch(n){ks(e,t,{then:function(){},status:`rejected`,reason:n},gu())}finally{F.p=a,o!==null&&s.types!==null&&(o.types=s.types),P.T=o}}function ys(){}function bs(e,t,n,r){if(e.tag!==5)throw Error(i(476));var a=xs(e).queue;vs(e,a,t,ne,n===null?ys:function(){return Ss(e),n(r)})}function xs(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:ne,baseState:ne,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:jo,lastRenderedState:ne},next:null};var n={};return t.next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:jo,lastRenderedState:n},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function Ss(e){var t=xs(e);t.next===null&&(t=e.alternate.memoizedState),ks(e,t.next.queue,{},gu())}function Cs(){return qi(Y)}function ws(){return Eo().memoizedState}function Ts(){return Eo().memoizedState}function Es(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var n=gu();e=Fa(n);var r=Ia(t,e,n);r!==null&&(vu(r,t,n),La(r,t,n)),t={cache:ea()},e.payload=t;return}t=t.return}}function Ds(e,t,n){var r=gu();n={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},js(e)?Ms(t,n):(n=Jr(e,t,n,r),n!==null&&(vu(n,e,r),Ns(n,t,r)))}function Os(e,t,n){ks(e,t,n,gu())}function ks(e,t,n,r){var i={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(js(e))Ms(t,i);else{var a=e.alternate;if(e.lanes===0&&(a===null||a.lanes===0)&&(a=t.lastRenderedReducer,a!==null))try{var o=t.lastRenderedState,s=a(o,n);if(i.hasEagerState=!0,i.eagerState=s,hr(s,o))return qr(e,t,i,0),Rl===null&&Kr(),!1}catch{}if(n=Jr(e,t,i,r),n!==null)return vu(n,e,r),Ns(n,t,r),!0}return!1}function As(e,t,n,r){if(r={lane:2,revertLane:hd(),gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null},js(e)){if(t)throw Error(i(479))}else t=Jr(e,n,r,2),t!==null&&vu(t,e,2)}function js(e){var t=e.alternate;return e===ao||t!==null&&t===ao}function Ms(e,t){lo=co=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function Ns(e,t,n){if(n&4194048){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Ze(e,n)}}var Ps={readContext:qi,use:ko,useCallback:go,useContext:go,useEffect:go,useImperativeHandle:go,useLayoutEffect:go,useInsertionEffect:go,useMemo:go,useReducer:go,useRef:go,useState:go,useDebugValue:go,useDeferredValue:go,useTransition:go,useSyncExternalStore:go,useId:go,useHostTransitionStatus:go,useFormState:go,useActionState:go,useOptimistic:go,useMemoCache:go,useCacheRefresh:go};Ps.useEffectEvent=go;var Fs={readContext:qi,use:ko,useCallback:function(e,t){return To().memoizedState=[e,t===void 0?null:t],e},useContext:qi,useEffect:as,useImperativeHandle:function(e,t,n){n=n==null?null:n.concat([e]),rs(4194308,4,ds.bind(null,t,e),n)},useLayoutEffect:function(e,t){return rs(4194308,4,e,t)},useInsertionEffect:function(e,t){rs(4,2,e,t)},useMemo:function(e,t){var n=To();t=t===void 0?null:t;var r=e();if(uo){Pe(!0);try{e()}finally{Pe(!1)}}return n.memoizedState=[r,t],r},useReducer:function(e,t,n){var r=To();if(n!==void 0){var i=n(t);if(uo){Pe(!0);try{n(t)}finally{Pe(!1)}}}else i=t;return r.memoizedState=r.baseState=i,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:i},r.queue=e,e=e.dispatch=Ds.bind(null,ao,e),[r.memoizedState,e]},useRef:function(e){var t=To();return e={current:e},t.memoizedState=e},useState:function(e){e=Vo(e);var t=e.queue,n=Os.bind(null,ao,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:ps,useDeferredValue:function(e,t){return gs(To(),e,t)},useTransition:function(){var e=Vo(!1);return e=vs.bind(null,ao,e.queue,!0,!1),To().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var r=ao,a=To();if(Di){if(n===void 0)throw Error(i(407));n=n()}else{if(n=t(),Rl===null)throw Error(i(349));Bl&127||Io(r,t,n)}a.memoizedState=n;var o={value:n,getSnapshot:t};return a.queue=o,as(Ro.bind(null,r,o,e),[e]),r.flags|=2048,ts(9,{destroy:void 0},Lo.bind(null,r,o,n,t),null),n},useId:function(){var e=To(),t=Rl.identifierPrefix;if(Di){var n=yi,r=vi;n=(r&~(1<<32-Fe(r)-1)).toString(32)+n,t=`_`+t+`R_`+n,n=fo++,0<\/script>`,o=o.removeChild(o.firstChild);break;case`select`:o=typeof r.is==`string`?s.createElement(`select`,{is:r.is}):s.createElement(`select`),r.multiple?o.multiple=!0:r.size&&(o.size=r.size);break;default:o=typeof r.is==`string`?s.createElement(a,{is:r.is}):s.createElement(a)}}o[it]=t,o[at]=r;a:for(s=t.child;s!==null;){if(s.tag===5||s.tag===6)o.appendChild(s.stateNode);else if(s.tag!==4&&s.tag!==27&&s.child!==null){s.child.return=s,s=s.child;continue}if(s===t)break a;for(;s.sibling===null;){if(s.return===null||s.return===t)break a;s=s.return}s.sibling.return=s.return,s=s.sibling}t.stateNode=o;a:switch(Bd(o,a,r),a){case`button`:case`input`:case`select`:case`textarea`:r=!!r.autoFocus;break a;case`img`:r=!0;break a;default:r=!1}r&&kc(t)}}return Pc(t),Ac(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==r&&kc(t);else{if(typeof r!=`string`&&t.stateNode===null)throw Error(i(166));if(e=ce.current,Pi(t)){if(e=t.stateNode,n=t.memoizedProps,r=null,a=Ti,a!==null)switch(a.tag){case 27:case 5:r=a.memoizedProps}e[it]=t,e=!!(e.nodeValue===n||r!==null&&!0===r.suppressHydrationWarning||Ld(e.nodeValue,n)),e||ji(t,!0)}else e=Gd(e).createTextNode(r),e[it]=t,t.stateNode=e}return Pc(t),null;case 31:if(n=t.memoizedState,e===null||e.memoizedState!==null){if(r=Pi(t),n!==null){if(e===null){if(!r)throw Error(i(318));if(e=t.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(557));e[it]=t}else Fi(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Pc(t),e=!1}else n=Ii(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=n),e=!0;if(!e)return t.flags&256?(to(t),t):(to(t),null);if(t.flags&128)throw Error(i(558))}return Pc(t),null;case 13:if(r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(a=Pi(t),r!==null&&r.dehydrated!==null){if(e===null){if(!a)throw Error(i(318));if(a=t.memoizedState,a=a===null?null:a.dehydrated,!a)throw Error(i(317));a[it]=t}else Fi(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Pc(t),a=!1}else a=Ii(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=a),a=!0;if(!a)return t.flags&256?(to(t),t):(to(t),null)}return to(t),t.flags&128?(t.lanes=n,t):(n=r!==null,e=e!==null&&e.memoizedState!==null,n&&(r=t.child,a=null,r.alternate!==null&&r.alternate.memoizedState!==null&&r.alternate.memoizedState.cachePool!==null&&(a=r.alternate.memoizedState.cachePool.pool),o=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(o=r.memoizedState.cachePool.pool),o!==a&&(r.flags|=2048)),n!==e&&n&&(t.child.flags|=8192),Mc(t,t.updateQueue),Pc(t),null);case 4:return de(),e===null&&Dd(t.stateNode.containerInfo),Pc(t),null;case 10:return Vi(t.type),Pc(t),null;case 19:if(ae(no),r=t.memoizedState,r===null)return Pc(t),null;if(a=(t.flags&128)!=0,o=r.rendering,o===null)if(a)Nc(r,!1);else{if(ql!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(o=ro(e),o!==null){for(t.flags|=128,Nc(r,!1),e=o.updateQueue,t.updateQueue=e,Mc(t,e),t.subtreeFlags=0,e=n,n=t.child;n!==null;)ri(n,e),n=n.sibling;return L(no,no.current&1|2),Di&&bi(t,r.treeForkCount),t.child}e=e.sibling}r.tail!==null&&Te()>iu&&(t.flags|=128,a=!0,Nc(r,!1),t.lanes=4194304)}else{if(!a)if(e=ro(o),e!==null){if(t.flags|=128,a=!0,e=e.updateQueue,t.updateQueue=e,Mc(t,e),Nc(r,!0),r.tail===null&&r.tailMode===`hidden`&&!o.alternate&&!Di)return Pc(t),null}else 2*Te()-r.renderingStartTime>iu&&n!==536870912&&(t.flags|=128,a=!0,Nc(r,!1),t.lanes=4194304);r.isBackwards?(o.sibling=t.child,t.child=o):(e=r.last,e===null?t.child=o:e.sibling=o,r.last=o)}return r.tail===null?(Pc(t),null):(e=r.tail,r.rendering=e,r.tail=e.sibling,r.renderingStartTime=Te(),e.sibling=null,n=no.current,L(no,a?n&1|2:n&1),Di&&bi(t,r.treeForkCount),e);case 22:case 23:return to(t),Ja(),r=t.memoizedState!==null,e===null?r&&(t.flags|=8192):e.memoizedState!==null!==r&&(t.flags|=8192),r?n&536870912&&!(t.flags&128)&&(Pc(t),t.subtreeFlags&6&&(t.flags|=8192)):Pc(t),n=t.updateQueue,n!==null&&Mc(t,n.retryQueue),n=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),r=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(r=t.memoizedState.cachePool.pool),r!==n&&(t.flags|=2048),e!==null&&ae(ua),null;case 24:return n=null,e!==null&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),Vi($i),Pc(t),null;case 25:return null;case 30:return null}throw Error(i(156,t.tag))}function Ic(e,t){switch(Ci(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Vi($i),de(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return pe(t),null;case 31:if(t.memoizedState!==null){if(to(t),t.alternate===null)throw Error(i(340));Fi()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(to(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(i(340));Fi()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return ae(no),null;case 4:return de(),null;case 10:return Vi(t.type),null;case 22:case 23:return to(t),Ja(),e!==null&&ae(ua),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return Vi($i),null;case 25:return null;default:return null}}function Lc(e,t){switch(Ci(t),t.tag){case 3:Vi($i),de();break;case 26:case 27:case 5:pe(t);break;case 4:de();break;case 31:t.memoizedState!==null&&to(t);break;case 13:to(t);break;case 19:ae(no);break;case 10:Vi(t.type);break;case 22:case 23:to(t),Ja(),e!==null&&ae(ua);break;case 24:Vi($i)}}function Rc(e,t){try{var n=t.updateQueue,r=n===null?null:n.lastEffect;if(r!==null){var i=r.next;n=i;do{if((n.tag&e)===e){r=void 0;var a=n.create,o=n.inst;r=a(),o.destroy=r}n=n.next}while(n!==i)}}catch(e){Ju(t,t.return,e)}}function zc(e,t,n){try{var r=t.updateQueue,i=r===null?null:r.lastEffect;if(i!==null){var a=i.next;r=a;do{if((r.tag&e)===e){var o=r.inst,s=o.destroy;if(s!==void 0){o.destroy=void 0,i=t;var c=n,l=s;try{l()}catch(e){Ju(i,c,e)}}}r=r.next}while(r!==a)}}catch(e){Ju(t,t.return,e)}}function Bc(e){var t=e.updateQueue;if(t!==null){var n=e.stateNode;try{Ua(t,n)}catch(t){Ju(e,e.return,t)}}}function Vc(e,t,n){n.props=Hs(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(n){Ju(e,t,n)}}function Hc(e,t){try{var n=e.ref;if(n!==null){switch(e.tag){case 26:case 27:case 5:var r=e.stateNode;break;case 30:r=e.stateNode;break;default:r=e.stateNode}typeof n==`function`?e.refCleanup=n(r):n.current=r}}catch(n){Ju(e,t,n)}}function Uc(e,t){var n=e.ref,r=e.refCleanup;if(n!==null)if(typeof r==`function`)try{r()}catch(n){Ju(e,t,n)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof n==`function`)try{n(null)}catch(n){Ju(e,t,n)}else n.current=null}function Wc(e){var t=e.type,n=e.memoizedProps,r=e.stateNode;try{a:switch(t){case`button`:case`input`:case`select`:case`textarea`:n.autoFocus&&r.focus();break a;case`img`:n.src?r.src=n.src:n.srcSet&&(r.srcset=n.srcSet)}}catch(t){Ju(e,e.return,t)}}function Gc(e,t,n){try{var r=e.stateNode;Vd(r,e.type,n,t),r[at]=t}catch(t){Ju(e,e.return,t)}}function Kc(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&nf(e.type)||e.tag===4}function qc(e){a:for(;;){for(;e.sibling===null;){if(e.return===null||Kc(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.tag===27&&nf(e.type)||e.flags&2||e.child===null||e.tag===4)continue a;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Jc(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?(n.nodeType===9?n.body:n.nodeName===`HTML`?n.ownerDocument.body:n).insertBefore(e,t):(t=n.nodeType===9?n.body:n.nodeName===`HTML`?n.ownerDocument.body:n,t.appendChild(e),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=Zt));else if(r!==4&&(r===27&&nf(e.type)&&(n=e.stateNode,t=null),e=e.child,e!==null))for(Jc(e,t,n),e=e.sibling;e!==null;)Jc(e,t,n),e=e.sibling}function Yc(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(r===27&&nf(e.type)&&(n=e.stateNode),e=e.child,e!==null))for(Yc(e,t,n),e=e.sibling;e!==null;)Yc(e,t,n),e=e.sibling}function Xc(e){var t=e.stateNode,n=e.memoizedProps;try{for(var r=e.type,i=t.attributes;i.length;)t.removeAttributeNode(i[0]);Bd(t,r,n),t[it]=e,t[at]=n}catch(t){Ju(e,e.return,t)}}var Zc=!1,Qc=!1,$c=!1,el=typeof WeakSet==`function`?WeakSet:Set,tl=null;function nl(e,t){if(e=e.containerInfo,Wd=dp,e=br(e),xr(e)){if(`selectionStart`in e)var n={start:e.selectionStart,end:e.selectionEnd};else a:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var a=r.anchorOffset,o=r.focusNode;r=r.focusOffset;try{n.nodeType,o.nodeType}catch{n=null;break a}var s=0,c=-1,l=-1,u=0,d=0,f=e,p=null;b:for(;;){for(var m;f!==n||a!==0&&f.nodeType!==3||(c=s+a),f!==o||r!==0&&f.nodeType!==3||(l=s+r),f.nodeType===3&&(s+=f.nodeValue.length),(m=f.firstChild)!==null;)p=f,f=m;for(;;){if(f===e)break b;if(p===n&&++u===a&&(c=s),p===o&&++d===r&&(l=s),(m=f.nextSibling)!==null)break;f=p,p=f.parentNode}f=m}n=c===-1||l===-1?null:{start:c,end:l}}else n=null}n||={start:0,end:0}}else n=null;for(J={focusedElem:e,selectionRange:n},dp=!1,tl=t;tl!==null;)if(t=tl,e=t.child,t.subtreeFlags&1028&&e!==null)e.return=t,tl=e;else for(;tl!==null;){switch(t=tl,o=t.alternate,e=t.flags,t.tag){case 0:if(e&4&&(e=t.updateQueue,e=e===null?null:e.events,e!==null))for(n=0;n title`))),Bd(o,r,n),o[it]=e,_t(o),r=o;break a;case`link`:var s=Kf(`link`,`href`,a).get(r+(n.href||``));if(s){for(var c=0;cg&&(o=g,g=h,h=o);var _=vr(s,h),v=vr(s,g);if(_&&v&&(p.rangeCount!==1||p.anchorNode!==_.node||p.anchorOffset!==_.offset||p.focusNode!==v.node||p.focusOffset!==v.offset)){var y=d.createRange();y.setStart(_.node,_.offset),p.removeAllRanges(),h>g?(p.addRange(y),p.extend(v.node,v.offset)):(y.setEnd(v.node,v.offset),p.addRange(y))}}}}for(d=[],p=s;p=p.parentNode;)p.nodeType===1&&d.push({element:p,left:p.scrollLeft,top:p.scrollTop});for(typeof s.focus==`function`&&s.focus(),s=0;sn?32:n,P.T=null,n=fu,fu=null;var o=cu,s=uu;if(su=0,lu=cu=null,uu=0,Ll&6)throw Error(i(331));var c=Ll;if(Ll|=4,Ml(o.current),wl(o,o.current,s,n),Ll=c,cd(0,!1),Ne&&typeof Ne.onPostCommitFiberRoot==`function`)try{Ne.onPostCommitFiberRoot(Me,o)}catch{}return!0}finally{F.p=a,P.T=r,Wu(e,t)}}function qu(e,t,n){t=ui(n,t),t=Js(e.stateNode,t,2),e=Ia(e,t,2),e!==null&&(Je(e,2),sd(e))}function Ju(e,t,n){if(e.tag===3)qu(e,e,n);else for(;t!==null;){if(t.tag===3){qu(t,e,n);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError==`function`||typeof r.componentDidCatch==`function`&&(ou===null||!ou.has(r))){e=ui(n,e),n=Ys(2),r=Ia(t,n,2),r!==null&&(Xs(n,r,t,e),Je(r,2),sd(r));break}}t=t.return}}function Yu(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new Il;var i=new Set;r.set(t,i)}else i=r.get(t),i===void 0&&(i=new Set,r.set(t,i));i.has(n)||(Gl=!0,i.add(n),e=Xu.bind(null,e,t,n),t.then(e,e))}function Xu(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,Rl===e&&(Bl&n)===n&&(ql===4||ql===3&&(Bl&62914560)===Bl&&300>Te()-nu?!(Ll&2)&&Tu(e,0):Xl|=n,Ql===Bl&&(Ql=0)),sd(e)}function Zu(e,t){t===0&&(t=Ke()),e=Yr(e,t),e!==null&&(Je(e,t),sd(e))}function Qu(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),Zu(e,n)}function $u(e,t){var n=0;switch(e.tag){case 31:case 13:var r=e.stateNode,a=e.memoizedState;a!==null&&(n=a.retryLane);break;case 19:r=e.stateNode;break;case 22:r=e.stateNode._retryCache;break;default:throw Error(i(314))}r!==null&&r.delete(t),Zu(e,n)}function ed(e,t){return Se(e,t)}var td=null,nd=null,rd=!1,id=!1,ad=!1,od=0;function sd(e){e!==nd&&e.next===null&&(nd===null?td=nd=e:nd=nd.next=e),id=!0,rd||(rd=!0,md())}function cd(e,t){if(!ad&&id){ad=!0;do for(var n=!1,r=td;r!==null;){if(!t)if(e!==0){var i=r.pendingLanes;if(i===0)var a=0;else{var o=r.suspendedLanes,s=r.pingedLanes;a=(1<<31-Fe(42|e)+1)-1,a&=i&~(o&~s),a=a&201326741?a&201326741|1:a?a|2:0}a!==0&&(n=!0,pd(r,a))}else a=Bl,a=Ue(r,r===Rl?a:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),!(a&3)||We(r,a)||(n=!0,pd(r,a));r=r.next}while(n);ad=!1}}function ld(){ud()}function ud(){id=rd=!1;var e=0;od!==0&&Xd()&&(e=od);for(var t=Te(),n=null,r=td;r!==null;){var i=r.next,a=dd(r,t);a===0?(r.next=null,n===null?td=i:n.next=i,i===null&&(nd=n)):(n=r,(e!==0||a&3)&&(id=!0)),r=i}su!==0&&su!==5||cd(e,!1),od!==0&&(od=0)}function dd(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,i=e.expirationTimes,a=e.pendingLanes&-62914561;0s)break;var u=c.transferSize,d=c.initiatorType;u&&Hd(d)&&(c=c.responseEnd,o+=u*(c`u`?null:document;function Ef(e,t,n){var r=Tf;if(r&&typeof t==`string`&&t){var i=It(t);i=`link[rel="`+e+`"][href="`+i+`"]`,typeof n==`string`&&(i+=`[crossorigin="`+n+`"]`),bf.has(i)||(bf.add(i),e={rel:e,crossOrigin:n,href:t},r.querySelector(i)===null&&(t=r.createElement(`link`),Bd(t,`link`,e),_t(t),r.head.appendChild(t)))}}function Df(e){Sf.D(e),Ef(`dns-prefetch`,e,null)}function Of(e,t){Sf.C(e,t),Ef(`preconnect`,e,t)}function kf(e,t,n){Sf.L(e,t,n);var r=Tf;if(r&&e&&t){var i=`link[rel="preload"][as="`+It(t)+`"]`;t===`image`&&n&&n.imageSrcSet?(i+=`[imagesrcset="`+It(n.imageSrcSet)+`"]`,typeof n.imageSizes==`string`&&(i+=`[imagesizes="`+It(n.imageSizes)+`"]`)):i+=`[href="`+It(e)+`"]`;var a=i;switch(t){case`style`:a=Ff(e);break;case`script`:a=zf(e)}yf.has(a)||(e=f({rel:`preload`,href:t===`image`&&n&&n.imageSrcSet?void 0:e,as:t},n),yf.set(a,e),r.querySelector(i)!==null||t===`style`&&r.querySelector(If(a))||t===`script`&&r.querySelector(Bf(a))||(t=r.createElement(`link`),Bd(t,`link`,e),_t(t),r.head.appendChild(t)))}}function Af(e,t){Sf.m(e,t);var n=Tf;if(n&&e){var r=t&&typeof t.as==`string`?t.as:`script`,i=`link[rel="modulepreload"][as="`+It(r)+`"][href="`+It(e)+`"]`,a=i;switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:a=zf(e)}if(!yf.has(a)&&(e=f({rel:`modulepreload`,href:e},t),yf.set(a,e),n.querySelector(i)===null)){switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:if(n.querySelector(Bf(a)))return}r=n.createElement(`link`),Bd(r,`link`,e),_t(r),n.head.appendChild(r)}}}function jf(e,t,n){Sf.S(e,t,n);var r=Tf;if(r&&e){var i=gt(r).hoistableStyles,a=Ff(e);t||=`default`;var o=i.get(a);if(!o){var s={loading:0,preload:null};if(o=r.querySelector(If(a)))s.loading=5;else{e=f({rel:`stylesheet`,href:e,"data-precedence":t},n),(n=yf.get(a))&&Uf(e,n);var c=o=r.createElement(`link`);_t(c),Bd(c,`link`,e),c._p=new Promise(function(e,t){c.onload=e,c.onerror=t}),c.addEventListener(`load`,function(){s.loading|=1}),c.addEventListener(`error`,function(){s.loading|=2}),s.loading|=4,Hf(o,t,r)}o={type:`stylesheet`,instance:o,count:1,state:s},i.set(a,o)}}}function Mf(e,t){Sf.X(e,t);var n=Tf;if(n&&e){var r=gt(n).hoistableScripts,i=zf(e),a=r.get(i);a||(a=n.querySelector(Bf(i)),a||(e=f({src:e,async:!0},t),(t=yf.get(i))&&Wf(e,t),a=n.createElement(`script`),_t(a),Bd(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Nf(e,t){Sf.M(e,t);var n=Tf;if(n&&e){var r=gt(n).hoistableScripts,i=zf(e),a=r.get(i);a||(a=n.querySelector(Bf(i)),a||(e=f({src:e,async:!0,type:`module`},t),(t=yf.get(i))&&Wf(e,t),a=n.createElement(`script`),_t(a),Bd(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Pf(e,t,n,r){var a=(a=ce.current)?xf(a):null;if(!a)throw Error(i(446));switch(e){case`meta`:case`title`:return null;case`style`:return typeof n.precedence==`string`&&typeof n.href==`string`?(t=Ff(n.href),n=gt(a).hoistableStyles,r=n.get(t),r||(r={type:`style`,instance:null,count:0,state:null},n.set(t,r)),r):{type:`void`,instance:null,count:0,state:null};case`link`:if(n.rel===`stylesheet`&&typeof n.href==`string`&&typeof n.precedence==`string`){e=Ff(n.href);var o=gt(a).hoistableStyles,s=o.get(e);if(s||(a=a.ownerDocument||a,s={type:`stylesheet`,instance:null,count:0,state:{loading:0,preload:null}},o.set(e,s),(o=a.querySelector(If(e)))&&!o._p&&(s.instance=o,s.state.loading=5),yf.has(e)||(n={rel:`preload`,as:`style`,href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},yf.set(e,n),o||Rf(a,e,n,s.state))),t&&r===null)throw Error(i(528,``));return s}if(t&&r!==null)throw Error(i(529,``));return null;case`script`:return t=n.async,n=n.src,typeof n==`string`&&t&&typeof t!=`function`&&typeof t!=`symbol`?(t=zf(n),n=gt(a).hoistableScripts,r=n.get(t),r||(r={type:`script`,instance:null,count:0,state:null},n.set(t,r)),r):{type:`void`,instance:null,count:0,state:null};default:throw Error(i(444,e))}}function Ff(e){return`href="`+It(e)+`"`}function If(e){return`link[rel="stylesheet"][`+e+`]`}function Lf(e){return f({},e,{"data-precedence":e.precedence,precedence:null})}function Rf(e,t,n,r){e.querySelector(`link[rel="preload"][as="style"][`+t+`]`)?r.loading=1:(t=e.createElement(`link`),r.preload=t,t.addEventListener(`load`,function(){return r.loading|=1}),t.addEventListener(`error`,function(){return r.loading|=2}),Bd(t,`link`,n),_t(t),e.head.appendChild(t))}function zf(e){return`[src="`+It(e)+`"]`}function Bf(e){return`script[async]`+e}function Vf(e,t,n){if(t.count++,t.instance===null)switch(t.type){case`style`:var r=e.querySelector(`style[data-href~="`+It(n.href)+`"]`);if(r)return t.instance=r,_t(r),r;var a=f({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return r=(e.ownerDocument||e).createElement(`style`),_t(r),Bd(r,`style`,a),Hf(r,n.precedence,e),t.instance=r;case`stylesheet`:a=Ff(n.href);var o=e.querySelector(If(a));if(o)return t.state.loading|=4,t.instance=o,_t(o),o;r=Lf(n),(a=yf.get(a))&&Uf(r,a),o=(e.ownerDocument||e).createElement(`link`),_t(o);var s=o;return s._p=new Promise(function(e,t){s.onload=e,s.onerror=t}),Bd(o,`link`,r),t.state.loading|=4,Hf(o,n.precedence,e),t.instance=o;case`script`:return o=zf(n.src),(a=e.querySelector(Bf(o)))?(t.instance=a,_t(a),a):(r=n,(a=yf.get(o))&&(r=f({},n),Wf(r,a)),e=e.ownerDocument||e,a=e.createElement(`script`),_t(a),Bd(a,`link`,r),e.head.appendChild(a),t.instance=a);case`void`:return null;default:throw Error(i(443,t.type))}else t.type===`stylesheet`&&!(t.state.loading&4)&&(r=t.instance,t.state.loading|=4,Hf(r,n.precedence,e));return t.instance}function Hf(e,t,n){for(var r=n.querySelectorAll(`link[rel="stylesheet"][data-precedence],style[data-precedence]`),i=r.length?r[r.length-1]:null,a=i,o=0;o title`):null)}function Jf(e,t,n){if(n===1||t.itemProp!=null)return!1;switch(e){case`meta`:case`title`:return!0;case`style`:if(typeof t.precedence!=`string`||typeof t.href!=`string`||t.href===``)break;return!0;case`link`:if(typeof t.rel!=`string`||typeof t.href!=`string`||t.href===``||t.onLoad||t.onError)break;switch(t.rel){case`stylesheet`:return e=t.disabled,typeof t.precedence==`string`&&e==null;default:return!0}case`script`:if(t.async&&typeof t.async!=`function`&&typeof t.async!=`symbol`&&!t.onLoad&&!t.onError&&t.src&&typeof t.src==`string`)return!0}return!1}function Yf(e){return!(e.type===`stylesheet`&&!(e.state.loading&3))}function Xf(e,t,n,r){if(n.type===`stylesheet`&&(typeof r.media!=`string`||!1!==matchMedia(r.media).matches)&&!(n.state.loading&4)){if(n.instance===null){var i=Ff(r.href),a=t.querySelector(If(i));if(a){t=a._p,typeof t==`object`&&t&&typeof t.then==`function`&&(e.count++,e=$f.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=a,_t(a);return}a=t.ownerDocument||t,r=Lf(r),(i=yf.get(i))&&Uf(r,i),a=a.createElement(`link`),_t(a);var o=a;o._p=new Promise(function(e,t){o.onload=e,o.onerror=t}),Bd(a,`link`,r),n.instance=a}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(n,t),(t=n.state.preload)&&!(n.state.loading&3)&&(e.count++,n=$f.bind(e),t.addEventListener(`load`,n),t.addEventListener(`error`,n))}}var Zf=0;function Qf(e,t){return e.stylesheets&&e.count===0&&tp(e,e.stylesheets),0Zf?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(r),clearTimeout(i)}}:null}function $f(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)tp(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var ep=null;function tp(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,ep=new Map,t.forEach(np,e),ep=null,$f.call(e))}function np(e,t){if(!(t.state.loading&4)){var n=ep.get(e);if(n)var r=n.get(null);else{n=new Map,ep.set(e,n);for(var i=e.querySelectorAll(`link[data-precedence],style[data-precedence]`),a=0;a{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=v()})),b=u(p(),1),x=u(y(),1),S={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},C={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},w=`attached`,T=`detached`,E=1e3,D=1001,O=1002,k=1003,A=1004,j=1004,ee=1005,te=1005,M=1006,N=1007,P=1007,F=1008,ne=1008,re=1009,ie=1010,I=1011,ae=1012,L=1013,oe=1014,se=1015,ce=1016,le=1017,ue=1018,de=1020,fe=35902,pe=35899,me=1021,he=1022,ge=1023,_e=1026,ve=1027,ye=1028,be=1029,xe=1030,Se=1031,Ce=1032,R=1033,we=33776,Te=33777,Ee=33778,z=33779,De=35840,Oe=35841,ke=35842,B=35843,Ae=36196,je=37492,Me=37496,Ne=37488,Pe=37489,Fe=37490,Ie=37491,Le=37808,Re=37809,ze=37810,Be=37811,Ve=37812,He=37813,Ue=37814,We=37815,Ge=37816,Ke=37817,qe=37818,Je=37819,Ye=37820,Xe=37821,Ze=36492,Qe=36494,$e=36495,et=36283,tt=36284,nt=36285,rt=36286,it=2200,at=2201,ot=2202,st=2300,ct=2301,lt=2302,ut=2303,dt=2400,ft=2401,pt=2402,mt=2500,ht=2501,gt=3200,_t=3201,vt=3202,yt=3203,bt=`srgb`,xt=`srgb-linear`,St=`linear`,Ct=`srgb`,wt=7680,Tt=7681,Et=7682,Dt=7683,Ot=34055,kt=34056,At=5386,jt=35044,Mt=35048,Nt=35040,Pt=35045,Ft=35049,It=35041,Lt=35046,Rt=35050,zt=35042,Bt=`300 es`,Vt=2e3,Ht=2001,Ut={COMPUTE:`compute`,RENDER:`render`},Wt={PERSPECTIVE:`perspective`,LINEAR:`linear`,FLAT:`flat`},Gt={NORMAL:`normal`,CENTROID:`centroid`,SAMPLE:`sample`,FIRST:`first`,EITHER:`either`},Kt={TEXTURE_COMPARE:`depthTextureCompare`};function qt(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}var Jt={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function Yt(e,t){return new Jt[e](t)}function Xt(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function Zt(e){return document.createElementNS(`http://www.w3.org/1999/xhtml`,e)}function Qt(){let e=Zt(`canvas`);return e.style.display=`block`,e}var $t={},en=null;function tn(e){en=e}function nn(){return en}function rn(...e){let t=`THREE.`+e.shift();en?en(`log`,t,...e):console.log(t,...e)}function an(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 V(...e){e=an(e);let t=`THREE.`+e.shift();if(en)en(`warn`,t,...e);else{let n=e[0];n&&n.isStackTrace?console.warn(n.getError(t)):console.warn(t,...e)}}function H(...e){e=an(e);let t=`THREE.`+e.shift();if(en)en(`error`,t,...e);else{let n=e[0];n&&n.isStackTrace?console.error(n.getError(t)):console.error(t,...e)}}function on(...e){let t=e.join(` `);t in $t||($t[t]=!0,V(...e))}function sn(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 cn={0:1,2:6,4:7,3:5,1:0,6:2,7:4,5:3},ln=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]+un[e>>16&255]+un[e>>24&255]+`-`+un[t&255]+un[t>>8&255]+`-`+un[t>>16&15|64]+un[t>>24&255]+`-`+un[n&63|128]+un[n>>8&255]+`-`+un[n>>16&255]+un[n>>24&255]+un[r&255]+un[r>>8&255]+un[r>>16&255]+un[r>>24&255]).toLowerCase()}function U(e,t,n){return Math.max(t,Math.min(n,e))}function hn(e,t){return(e%t+t)%t}function gn(e,t,n,r,i){return r+(e-t)*(i-r)/(n-t)}function _n(e,t,n){return e===t?0:(n-e)/(t-e)}function vn(e,t,n){return(1-n)*e+n*t}function yn(e,t,n,r){return vn(e,t,1-Math.exp(-n*r))}function bn(e,t=1){return t-Math.abs(hn(e,t*2)-t)}function xn(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t),e*e*(3-2*e))}function Sn(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t),e*e*e*(e*(e*6-15)+10))}function Cn(e,t){return e+Math.floor(Math.random()*(t-e+1))}function wn(e,t){return e+Math.random()*(t-e)}function Tn(e){return e*(.5-Math.random())}function En(e){e!==void 0&&(dn=e);let t=dn+=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 Dn(e){return e*fn}function On(e){return e*pn}function kn(e){return(e&e-1)==0&&e!==0}function An(e){return 2**Math.ceil(Math.log(e)/Math.LN2)}function jn(e){return 2**Math.floor(Math.log(e)/Math.LN2)}function Mn(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:V(`MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: `+i)}}function Nn(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(`Invalid component type.`)}}function Pn(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(`Invalid component type.`)}}var Fn={DEG2RAD:fn,RAD2DEG:pn,generateUUID:mn,clamp:U,euclideanModulo:hn,mapLinear:gn,inverseLerp:_n,lerp:vn,damp:yn,pingpong:bn,smoothstep:xn,smootherstep:Sn,randInt:Cn,randFloat:wn,randFloatSpread:Tn,seededRandom:En,degToRad:Dn,radToDeg:On,isPowerOfTwo:kn,ceilPowerOfTwo:An,floorPowerOfTwo:jn,setQuaternionFromProperEuler:Mn,normalize:Pn,denormalize:Nn},W=class e{static{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(`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(`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=U(this.x,e.x,t.x),this.y=U(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=U(this.x,e,t),this.y=U(this.y,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(U(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(U(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}},In=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:V(`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(U(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}},G=class e{static{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(`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(`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(Rn.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Rn.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=U(this.x,e.x,t.x),this.y=U(this.y,e.y,t.y),this.z=U(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=U(this.x,e,t),this.y=U(this.y,e,t),this.z=U(this.z,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(U(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 Ln.copy(this).projectOnVector(e),this.sub(Ln)}reflect(e){return this.sub(Ln.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(U(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}},Ln=new G,Rn=new In,zn=class e{static{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 this.premultiply(Bn.makeScale(e,t)),this}rotate(e){return this.premultiply(Bn.makeRotation(-e)),this}translate(e,t){return this.premultiply(Bn.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)}},Bn=new zn,Vn=new zn().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),Hn=new zn().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function Un(){let e={enabled:!0,workingColorSpace:xt,spaces:{},convert:function(e,t,n){return this.enabled===!1||t===n||!t||!n?e:(this.spaces[t].transfer===`srgb`&&(e.r=Gn(e.r),e.g=Gn(e.g),e.b=Gn(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=Kn(e.r),e.g=Kn(e.g),e.b=Kn(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===``?St: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 on(`ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace().`),e.workingToColorSpace(t,n)},toWorkingColorSpace:function(t,n){return on(`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({[xt]:{primaries:t,whitePoint:r,transfer:St,toXYZ:Vn,fromXYZ:Hn,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:bt},outputColorSpaceConfig:{drawingBufferColorSpace:bt}},[bt]:{primaries:t,whitePoint:r,transfer:Ct,toXYZ:Vn,fromXYZ:Hn,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:bt}}}),e}var Wn=Un();function Gn(e){return e<.04045?e*.0773993808:(e*.9478672986+.0521327014)**2.4}function Kn(e){return e<.0031308?e*12.92:1.055*e**.41666-.055}var qn,Jn=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{qn===void 0&&(qn=Zt(`canvas`)),qn.width=e.width,qn.height=e.height;let t=qn.getContext(`2d`);e instanceof ImageData?t.putImageData(e,0,0):t.drawImage(e,0,0,e.width,e.height),n=qn}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=Zt(`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($n).x}get height(){return this.source.getSize($n).y}get depth(){return this.source.getSize($n).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){V(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}let r=this[t];if(r===void 0){V(`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 E:e.x-=Math.floor(e.x);break;case D:e.x=e.x<0?0:1;break;case O: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 E:e.y-=Math.floor(e.y);break;case D:e.y=e.y<0?0:1;break;case O: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++}};er.DEFAULT_IMAGE=null,er.DEFAULT_MAPPING=300,er.DEFAULT_ANISOTROPY=1;var tr=class e{static{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(`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(`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;t.025?(c.inputState.pinching=!1,this.dispatchEvent({type:`pinchend`,handedness:e.handedness,target:this})):!c.inputState.pinching&&o<=.015&&(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(Lr)))}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 Ir;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}},zr={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},Br={h:0,s:0,l:0},Vr={h:0,s:0,l:0};function Hr(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 K=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=bt){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Wn.colorSpaceToWorking(this,t),this}setRGB(e,t,n,r=Wn.workingColorSpace){return this.r=e,this.g=t,this.b=n,Wn.colorSpaceToWorking(this,r),this}setHSL(e,t,n,r=Wn.workingColorSpace){if(e=hn(e,1),t=U(t,0,1),n=U(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=Hr(i,r,e+1/3),this.g=Hr(i,r,e),this.b=Hr(i,r,e-1/3)}return Wn.colorSpaceToWorking(this,r),this}setStyle(e,t=bt){function n(t){t!==void 0&&parseFloat(t)<1&&V(`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:V(`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);V(`Color: Invalid hex color `+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=bt){let n=zr[e.toLowerCase()];return n===void 0?V(`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=Gn(e.r),this.g=Gn(e.g),this.b=Gn(e.b),this}copyLinearToSRGB(e){return this.r=Kn(e.r),this.g=Kn(e.g),this.b=Kn(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=bt){return Wn.workingToColorSpace(Ur.copy(this),e),Math.round(U(Ur.r*255,0,255))*65536+Math.round(U(Ur.g*255,0,255))*256+Math.round(U(Ur.b*255,0,255))}getHexString(e=bt){return(`000000`+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Wn.workingColorSpace){Wn.workingToColorSpace(Ur.copy(this),t);let n=Ur.r,r=Ur.g,i=Ur.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}},qr=new G,Jr=new G,Yr=new G,Xr=new G,Zr=new G,Qr=new G,$r=new G,ei=new G,ti=new G,ni=new G,ri=new tr,ii=new tr,ai=new tr,oi=class e{constructor(e=new G,t=new G,n=new G){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,r){r.subVectors(n,t),qr.subVectors(e,t),r.cross(qr);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){qr.subVectors(r,t),Jr.subVectors(n,t),Yr.subVectors(e,t);let a=qr.dot(qr),o=qr.dot(Jr),s=qr.dot(Yr),c=Jr.dot(Jr),l=Jr.dot(Yr),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,Xr)===null?!1:Xr.x>=0&&Xr.y>=0&&Xr.x+Xr.y<=1}static getInterpolation(e,t,n,r,i,a,o,s){return this.getBarycoord(e,t,n,r,Xr)===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,Xr.x),s.addScaledVector(a,Xr.y),s.addScaledVector(o,Xr.z),s)}static getInterpolatedAttribute(e,t,n,r,i,a){return ri.setScalar(0),ii.setScalar(0),ai.setScalar(0),ri.fromBufferAttribute(e,t),ii.fromBufferAttribute(e,n),ai.fromBufferAttribute(e,r),a.setScalar(0),a.addScaledVector(ri,i.x),a.addScaledVector(ii,i.y),a.addScaledVector(ai,i.z),a}static isFrontFacing(e,t,n,r){return qr.subVectors(n,t),Jr.subVectors(e,t),qr.cross(Jr).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 qr.subVectors(this.c,this.b),Jr.subVectors(this.a,this.b),qr.cross(Jr).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;Zr.subVectors(r,n),Qr.subVectors(i,n),ei.subVectors(e,n);let s=Zr.dot(ei),c=Qr.dot(ei);if(s<=0&&c<=0)return t.copy(n);ti.subVectors(e,r);let l=Zr.dot(ti),u=Qr.dot(ti);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(Zr,a);ni.subVectors(e,i);let f=Zr.dot(ni),p=Qr.dot(ni);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(Qr,o);let h=l*p-f*u;if(h<=0&&u-l>=0&&f-p>=0)return $r.subVectors(i,r),o=(u-l)/(u-l+(f-p)),t.copy(r).addScaledVector($r,o);let g=1/(h+m+d);return a=m*g,o=d*g,t.copy(n).addScaledVector(Zr,a).addScaledVector(Qr,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}},si=class{constructor(e=new G(1/0,1/0,1/0),t=new G(-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,li),li.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(_i),vi.subVectors(this.max,_i),di.subVectors(e.a,_i),fi.subVectors(e.b,_i),pi.subVectors(e.c,_i),mi.subVectors(fi,di),hi.subVectors(pi,fi),gi.subVectors(di,pi);let t=[0,-mi.z,mi.y,0,-hi.z,hi.y,0,-gi.z,gi.y,mi.z,0,-mi.x,hi.z,0,-hi.x,gi.z,0,-gi.x,-mi.y,mi.x,0,-hi.y,hi.x,0,-gi.y,gi.x,0];return!xi(t,di,fi,pi,vi)||(t=[1,0,0,0,1,0,0,0,1],!xi(t,di,fi,pi,vi))?!1:(yi.crossVectors(mi,hi),t=[yi.x,yi.y,yi.z],xi(t,di,fi,pi,vi))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,li).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(li).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:(ci[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),ci[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),ci[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),ci[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),ci[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),ci[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),ci[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),ci[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(ci),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}},ci=[new G,new G,new G,new G,new G,new G,new G,new G],li=new G,ui=new si,di=new G,fi=new G,pi=new G,mi=new G,hi=new G,gi=new G,_i=new G,vi=new G,yi=new G,bi=new G;function xi(e,t,n,r,i){for(let a=0,o=e.length-3;a<=o;a+=3){bi.fromArray(e,a);let o=i.x*Math.abs(bi.x)+i.y*Math.abs(bi.y)+i.z*Math.abs(bi.z),s=t.dot(bi),c=n.dot(bi),l=r.dot(bi);if(Math.max(-Math.max(s,c,l),Math.min(s,c,l))>o)return!1}return!0}var Si=Ci();function Ci(){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 wi(e){Math.abs(e)>65504&&V(`DataUtils.toHalfFloat(): Value out of range.`),e=U(e,-65504,65504),Si.floatView[0]=e;let t=Si.uint32View[0],n=t>>23&511;return Si.baseTable[n]+((t&8388607)>>Si.shiftTable[n])}function Ti(e){let t=e>>10;return Si.uint32View[0]=Si.mantissaTable[Si.offsetTable[t]+(e&1023)]+Si.exponentTable[t],Si.floatView[0]}var Ei=class{static toHalfFloat(e){return wi(e)}static fromHalfFloat(e){return Ti(e)}},Di=new G,Oi=new W,ki=0,Ai=class extends ln{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:ki++}),this.name=``,this.array=e,this.itemSize=t,this.count=e===void 0?0:e.length/t,this.normalized=n,this.usage=jt,this.updateRanges=[],this.gpuType=se,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;Bi.subVectors(e,this.center);let t=Bi.lengthSq();if(t>this.radius*this.radius){let e=Math.sqrt(t),n=(e-this.radius)*.5;this.center.addScaledVector(Bi,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(Bi.copy(e.center).add(Vi)),this.expandByPoint(Bi.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}},Ui=0,Wi=new cr,Gi=new Fr,Ki=new G,qi=new si,Ji=new si,Yi=new G,Xi=class e extends ln{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Ui++}),this.uuid=mn(),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={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(qt(e)?Li: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 zn().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}applyQuaternion(e){return Wi.makeRotationFromQuaternion(e),this.applyMatrix4(Wi),this}rotateX(e){return Wi.makeRotationX(e),this.applyMatrix4(Wi),this}rotateY(e){return Wi.makeRotationY(e),this.applyMatrix4(Wi),this}rotateZ(e){return Wi.makeRotationZ(e),this.applyMatrix4(Wi),this}translate(e,t,n){return Wi.makeTranslation(e,t,n),this.applyMatrix4(Wi),this}scale(e,t,n){return Wi.makeScale(e,t,n),this.applyMatrix4(Wi),this}lookAt(e){return Gi.lookAt(e),Gi.updateMatrix(),this.applyMatrix4(Gi.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Ki).negate(),this.translate(Ki.x,Ki.y,Ki.z),this}setFromPoints(e){let t=this.getAttribute(`position`);if(t===void 0){let t=[];for(let n=0,r=e.length;nt.count&&V(`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 si);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){H(`BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.`,this),this.boundingBox.set(new G(-1/0,-1/0,-1/0),new G(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){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){V(`Material: parameter '${t}' has value of undefined.`);continue}let r=this[t];if(r===void 0){V(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}r&&r.isColor?r.set(n):r&&r.isVector3&&n&&n.isVector3?r.copy(n):this[t]=n}}toJSON(e){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}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++}},na=class extends ta{constructor(e){super(),this.isSpriteMaterial=!0,this.type=`SpriteMaterial`,this.color=new K(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}},ra,ia=new G,aa=new G,oa=new G,sa=new W,ca=new W,la=new cr,ua=new G,da=new G,fa=new G,pa=new W,ma=new W,ha=new W,ga=class extends Fr{constructor(e=new na){if(super(),this.isSprite=!0,this.type=`Sprite`,ra===void 0){ra=new Xi;let e=new Zi(new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),5);ra.setIndex([0,1,2,0,2,3]),ra.setAttribute(`position`,new $i(e,3,0,!1)),ra.setAttribute(`uv`,new $i(e,2,3,!1))}this.geometry=ra,this.material=e,this.center=new W(.5,.5),this.count=1}raycast(e,t){e.camera===null&&H(`Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.`),aa.setFromMatrixScale(this.matrixWorld),la.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),oa.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&aa.multiplyScalar(-oa.z);let n=this.material.rotation,r,i;n!==0&&(i=Math.cos(n),r=Math.sin(n));let a=this.center;_a(ua.set(-.5,-.5,0),oa,a,aa,r,i),_a(da.set(.5,-.5,0),oa,a,aa,r,i),_a(fa.set(.5,.5,0),oa,a,aa,r,i),pa.set(0,0),ma.set(1,0),ha.set(1,1);let o=e.ray.intersectTriangle(ua,da,fa,!1,ia);if(o===null&&(_a(da.set(-.5,.5,0),oa,a,aa,r,i),ma.set(0,1),o=e.ray.intersectTriangle(ua,fa,da,!1,ia),o===null))return;let s=e.ray.origin.distanceTo(ia);se.far||t.push({distance:s,point:ia.clone(),uv:oi.getInterpolation(ia,ua,da,fa,pa,ma,ha,new W),face:null,object:this})}copy(e,t){return super.copy(e,t),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}};function _a(e,t,n,r,i,a){sa.subVectors(e,n).addScalar(.5).multiply(r),i===void 0?ca.copy(sa):(ca.x=a*sa.x-i*sa.y,ca.y=i*sa.x+a*sa.y),e.copy(t),e.x+=ca.x,e.y+=ca.y,e.applyMatrix4(la)}var va=new G,ya=new G,ba=class extends Fr{constructor(){super(),this.isLOD=!0,this._currentLevel=0,this.type=`LOD`,Object.defineProperties(this,{levels:{enumerable:!0,value:[]}}),this.autoUpdate=!0}copy(e){super.copy(e,!1);let t=e.levels;for(let e=0,n=t.length;e0){let n,r;for(n=1,r=t.length;n0){va.setFromMatrixPosition(this.matrixWorld);let n=e.ray.origin.distanceTo(va);this.getObjectForDistance(n).raycast(e,t)}}update(e){let t=this.levels;if(t.length>1){va.setFromMatrixPosition(e.matrixWorld),ya.setFromMatrixPosition(this.matrixWorld);let n=va.distanceTo(ya)/e.zoom;t[0].object.visible=!0;let r,i;for(r=1,i=t.length;r=e)t[r-1].object.visible=!1,t[r].object.visible=!0;else break}for(this._currentLevel=r-1;r0)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(Sa).addScaledVector(Ca,d),f}intersectSphere(e,t){xa.subVectors(e.center,this.origin);let n=xa.dot(this.direction),r=xa.dot(xa)-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,xa)!==null}intersectTriangle(e,t,n,r,i){Ta.subVectors(t,e),Ea.subVectors(n,e),Da.crossVectors(Ta,Ea);let a=this.direction.dot(Da),o;if(a>0){if(r)return null;o=1}else if(a<0)o=-1,a=-a;else return null;wa.subVectors(this.origin,e);let s=o*this.direction.dot(Ea.crossVectors(wa,Ea));if(s<0)return null;let c=o*this.direction.dot(Ta.cross(wa));if(c<0||s+c>a)return null;let l=-o*wa.dot(Da);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)}},ka=class extends ta{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type=`MeshBasicMaterial`,this.color=new K(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 vr,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}},Aa=new cr,ja=new Oa,Ma=new Hi,Na=new G,Pa=new G,Fa=new G,Ia=new G,La=new G,Ra=new G,za=new G,Ba=new G,Va=class extends Fr{constructor(e=new Xi,t=new ka){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))&&(Aa.copy(i).invert(),ja.copy(e.ray).applyMatrix4(Aa),!(n.boundingBox!==null&&ja.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,ja)))}_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:Ba.clone(),object:e}}function Ua(e,t,n,r,i,a,o,s,c,l){e.getVertexPosition(s,Pa),e.getVertexPosition(c,Fa),e.getVertexPosition(l,Ia);let u=Ha(e,t,n,r,Pa,Fa,Ia,za);if(u){let e=new G;oi.getBarycoord(za,Pa,Fa,Ia,e),i&&(u.uv=oi.getInterpolatedAttribute(i,s,c,l,e,new W)),a&&(u.uv1=oi.getInterpolatedAttribute(a,s,c,l,e,new W)),o&&(u.normal=oi.getInterpolatedAttribute(o,s,c,l,e,new G),u.normal.dot(r.direction)>0&&u.normal.multiplyScalar(-1));let t={a:s,b:c,c:l,normal:new G,materialIndex:0};oi.getNormal(Pa,Fa,Ia,t.normal),u.face=t,u.barycoord=e}return u}var Wa=new tr,Ga=new tr,Ka=new tr,qa=new tr,Ja=new cr,Ya=new G,Xa=new Hi,Za=new cr,Qa=new Oa,$a=class extends Va{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type=`SkinnedMesh`,this.bindMode=w,this.bindMatrix=new cr,this.bindMatrixInverse=new cr,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){let e=this.geometry;this.boundingBox===null&&(this.boundingBox=new si),this.boundingBox.makeEmpty();let t=e.getAttribute(`position`);for(let e=0;e1)?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||_o.getNormalMatrix(e),r=this.coplanarPoint(ho).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)}},yo=new Hi,bo=new W(.5,.5),xo=new G,So=class{constructor(e=new vo,t=new vo,n=new vo,r=new vo,i=new vo,a=new vo){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=Vt,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(),yo.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{let t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),yo.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(yo)}intersectsSprite(e){return yo.center.set(0,0,0),yo.radius=.7071067811865476+bo.distanceTo(e.center),yo.applyMatrix4(e.matrixWorld),this.intersectsSphere(yo)}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,xo.y=r.normal.y>0?e.max.y:e.min.y,xo.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(xo)<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)}},Co=new cr,wo=new So,To=class e{constructor(){this.coordinateSystem=Vt}intersectsObject(e,t){if(!t.isArrayCamera||t.cameras.length===0)return!1;for(let n=0;n=i.length&&i.push({start:-1,count:-1,z:-1,index:-1});let o=i[this.index];a.push(o),this.index++,o.start=e,o.count=t,o.z=n,o.index=r}reset(){this.list.length=0,this.index=0}},Ao=new cr,jo=new K(1,1,1),Mo=new So,No=new To,Po=new si,Fo=new Hi,Io=new G,Lo=new G,Ro=new G,zo=new ko,Bo=new Va,Vo=[];function Ho(e,t,n=0){let r=t.itemSize;if(e.isInterleavedBufferAttribute||e.array.constructor!==t.array.constructor){let i=e.count;for(let a=0;a65535?new Uint32Array(r):new Uint16Array(r);t.setIndex(new Ai(e,1))}this._geometryInitialized=!0}}_validateGeometry(e){let t=this.geometry;if(!!e.getIndex()!=!!t.getIndex())throw Error(`THREE.BatchedMesh: All geometries must consistently have "index".`);for(let n in t.attributes){if(!e.hasAttribute(n))throw Error(`THREE.BatchedMesh: Added geometry missing "${n}". All geometries must have consistent attributes.`);let r=e.getAttribute(n),i=t.getAttribute(n);if(r.itemSize!==i.itemSize||r.normalized!==i.normalized)throw Error(`THREE.BatchedMesh: All attributes must have a consistent itemSize and normalized value.`)}}validateInstanceId(e){let t=this._instanceInfo;if(e<0||e>=t.length||t[e].active===!1)throw Error(`THREE.BatchedMesh: Invalid instanceId ${e}. Instance is either out of range or has been deleted.`)}validateGeometryId(e){let t=this._geometryInfo;if(e<0||e>=t.length||t[e].active===!1)throw Error(`THREE.BatchedMesh: Invalid geometryId ${e}. Geometry is either out of range or has been deleted.`)}setCustomSort(e){return this.customSort=e,this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new si);let e=this.boundingBox,t=this._instanceInfo;e.makeEmpty();for(let n=0,r=t.length;n=this.maxInstanceCount&&this._availableInstanceIds.length===0)throw Error(`THREE.BatchedMesh: Maximum item count reached.`);let t={visible:!0,active:!0,geometryIndex:e},n=null;this._availableInstanceIds.length>0?(this._availableInstanceIds.sort(Eo),n=this._availableInstanceIds.shift(),this._instanceInfo[n]=t):(n=this._instanceInfo.length,this._instanceInfo.push(t));let r=this._matricesTexture;Ao.identity().toArray(r.image.data,n*16),r.needsUpdate=!0;let i=this._colorsTexture;return i&&(jo.toArray(i.image.data,n*4),i.needsUpdate=!0),this._visibilityChanged=!0,n}addGeometry(e,t=-1,n=-1){this._initializeGeometry(e),this._validateGeometry(e);let r={vertexStart:-1,vertexCount:-1,reservedVertexCount:-1,indexStart:-1,indexCount:-1,reservedIndexCount:-1,start:-1,count:-1,boundingBox:null,boundingSphere:null,active:!0},i=this._geometryInfo;r.vertexStart=this._nextVertexStart,r.reservedVertexCount=t===-1?e.getAttribute(`position`).count:t;let a=e.getIndex();if(a!==null&&(r.indexStart=this._nextIndexStart,r.reservedIndexCount=n===-1?a.count:n),r.indexStart!==-1&&r.indexStart+r.reservedIndexCount>this._maxIndexCount||r.vertexStart+r.reservedVertexCount>this._maxVertexCount)throw Error(`THREE.BatchedMesh: Reserved space request exceeds the maximum buffer size.`);let o;return this._availableGeometryIds.length>0?(this._availableGeometryIds.sort(Eo),o=this._availableGeometryIds.shift(),i[o]=r):(o=this._geometryCount,this._geometryCount++,i.push(r)),this.setGeometryAt(o,e),this._nextIndexStart=r.indexStart+r.reservedIndexCount,this._nextVertexStart=r.vertexStart+r.reservedVertexCount,o}setGeometryAt(e,t){if(e>=this._geometryCount)throw Error(`THREE.BatchedMesh: Maximum geometry count reached.`);this._validateGeometry(t);let n=this.geometry,r=n.getIndex()!==null,i=n.getIndex(),a=t.getIndex(),o=this._geometryInfo[e];if(r&&a.count>o.reservedIndexCount||t.attributes.position.count>o.reservedVertexCount)throw Error(`THREE.BatchedMesh: Reserved space not large enough for provided geometry.`);let s=o.vertexStart,c=o.reservedVertexCount;o.vertexCount=t.getAttribute(`position`).count;for(let e in n.attributes){let r=t.getAttribute(e),i=n.getAttribute(e);Ho(r,i,s);let a=r.itemSize;for(let e=r.count,t=c;e=t.length||t[e].active===!1)return this;let n=this._instanceInfo;for(let t=0,r=n.length;tt).sort((e,t)=>n[e].vertexStart-n[t].vertexStart),i=this.geometry;for(let a=0,o=n.length;a=this._geometryCount)return null;let n=this.geometry,r=this._geometryInfo[e];if(r.boundingBox===null){let e=new si,t=n.index,i=n.attributes.position;for(let n=r.start,a=r.start+r.count;n=this._geometryCount)return null;let n=this.geometry,r=this._geometryInfo[e];if(r.boundingSphere===null){let t=new Hi;this.getBoundingBoxAt(e,Po),Po.getCenter(t.center);let i=n.index,a=n.attributes.position,o=0;for(let e=r.start,n=r.start+r.count;ee.active);if(Math.max(...n.map(e=>e.vertexStart+e.reservedVertexCount))>e)throw Error(`BatchedMesh: Geometry vertex values are being used outside the range ${t}. Cannot shrink further.`);if(this.geometry.index&&Math.max(...n.map(e=>e.indexStart+e.reservedIndexCount))>t)throw Error(`BatchedMesh: Geometry index values are being used outside the range ${t}. Cannot shrink further.`);let r=this.geometry;r.dispose(),this._maxVertexCount=e,this._maxIndexCount=t,this._geometryInitialized&&(this._geometryInitialized=!1,this.geometry=new Xi,this._initializeGeometry(r));let i=this.geometry;r.index&&Uo(r.index.array,i.index.array);for(let e in r.attributes)Uo(r.attributes[e].array,i.attributes[e].array)}raycast(e,t){let n=this._instanceInfo,r=this._geometryInfo,i=this.matrixWorld,a=this.geometry;Bo.material=this.material,Bo.geometry.index=a.index,Bo.geometry.attributes=a.attributes,Bo.geometry.boundingBox===null&&(Bo.geometry.boundingBox=new si),Bo.geometry.boundingSphere===null&&(Bo.geometry.boundingSphere=new Hi);for(let a=0,o=n.length;a({...e,boundingBox:e.boundingBox===null?null:e.boundingBox.clone(),boundingSphere:e.boundingSphere===null?null:e.boundingSphere.clone()})),this._instanceInfo=e._instanceInfo.map(e=>({...e})),this._availableInstanceIds=e._availableInstanceIds.slice(),this._availableGeometryIds=e._availableGeometryIds.slice(),this._nextIndexStart=e._nextIndexStart,this._nextVertexStart=e._nextVertexStart,this._geometryCount=e._geometryCount,this._maxInstanceCount=e._maxInstanceCount,this._maxVertexCount=e._maxVertexCount,this._maxIndexCount=e._maxIndexCount,this._geometryInitialized=e._geometryInitialized,this._multiDrawCounts=e._multiDrawCounts.slice(),this._multiDrawStarts=e._multiDrawStarts.slice(),this._indirectTexture=e._indirectTexture.clone(),this._indirectTexture.image.data=this._indirectTexture.image.data.slice(),this._matricesTexture=e._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.data.slice(),this._colorsTexture!==null&&(this._colorsTexture=e._colorsTexture.clone(),this._colorsTexture.image.data=this._colorsTexture.image.data.slice()),this}dispose(){this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this._indirectTexture.dispose(),this._indirectTexture=null,this._colorsTexture!==null&&(this._colorsTexture.dispose(),this._colorsTexture=null)}onBeforeRender(e,t,n,r,i){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;let a=r.getIndex(),o=a===null?1:a.array.BYTES_PER_ELEMENT,s=1;i.wireframe&&(s=2,o=r.attributes.position.count>65535?4:2);let c=this._instanceInfo,l=this._multiDrawStarts,u=this._multiDrawCounts,d=this._geometryInfo,f=this.perObjectFrustumCulled,p=this._indirectTexture,m=p.image.data,h=n.isArrayCamera?No:Mo;f&&!n.isArrayCamera&&(Ao.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse).multiply(this.matrixWorld),Mo.setFromProjectionMatrix(Ao,n.coordinateSystem,n.reversedDepth));let g=0;if(this.sortObjects){Ao.copy(this.matrixWorld).invert(),Io.setFromMatrixPosition(n.matrixWorld).applyMatrix4(Ao),Lo.set(0,0,-1).transformDirection(n.matrixWorld).transformDirection(Ao);for(let e=0,t=c.length;e0){let n=e[t[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;er)return;Zo.applyMatrix4(e.matrixWorld);let c=t.ray.origin.distanceTo(Zo);if(!(ct.far))return{distance:c,point:Qo.clone().applyMatrix4(e.matrixWorld),index:o,face:null,faceIndex:null,barycoord:null,object:e}}var ts=new G,ns=new G,rs=class extends $o{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 fs=class extends er{constructor(e,t,n,r,i=M,a=M,o,s,c){super(e,t,n,r,i,a,o,s,c),this.isVideoTexture=!0,this.generateMipmaps=!1,this._requestVideoFrameCallbackId=0;let l=this;function u(){l.needsUpdate=!0,l._requestVideoFrameCallbackId=e.requestVideoFrameCallback(u)}`requestVideoFrameCallback`in e&&(this._requestVideoFrameCallbackId=e.requestVideoFrameCallback(u))}clone(){return new this.constructor(this.image).copy(this)}update(){let e=this.image;!(`requestVideoFrameCallback`in e)&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}dispose(){this._requestVideoFrameCallbackId!==0&&(this.source.data.cancelVideoFrameCallback(this._requestVideoFrameCallbackId),this._requestVideoFrameCallbackId=0),super.dispose()}},ps=class extends fs{constructor(e,t,n,r,i,a,o,s){super({},e,t,n,r,i,a,o,s),this.isVideoFrameTexture=!0}update(){}clone(){return new this.constructor().copy(this)}setFrame(e){this.image=e,this.needsUpdate=!0}},ms=class extends er{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=k,this.minFilter=k,this.generateMipmaps=!1,this.needsUpdate=!0}},hs=class extends er{constructor(e,t,n,r,i,a,o,s,c,l,u,d){super(null,a,o,s,c,l,r,i,u,d),this.isCompressedTexture=!0,this.image={width:t,height:n},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}},gs=class extends hs{constructor(e,t,n,r,i,a){super(e,t,n,i,a),this.isCompressedArrayTexture=!0,this.image.depth=r,this.wrapR=D,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}},_s=class extends hs{constructor(e,t,n){super(void 0,e[0].width,e[0].height,t,n,301),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=e}},vs=class extends er{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}},ys=class extends er{constructor(e,t,n,r,i,a,o,s,c){super(e,t,n,r,i,a,o,s,c),this.isCanvasTexture=!0,this.needsUpdate=!0}},bs=class extends er{constructor(e,t,n,r,i,a,o,s,c){super(e,t,n,r,i,a,o,s,c),this.isHTMLTexture=!0,this.generateMipmaps=!1,this.needsUpdate=!0;let l=e?e.parentNode:null;l!==null&&`requestPaint`in l&&(l.onpaint=()=>{this.needsUpdate=!0},l.requestPaint())}dispose(){let e=this.image?this.image.parentNode:null;e!==null&&`onpaint`in e&&(e.onpaint=null),super.dispose()}},xs=class extends er{constructor(e,t,n=oe,r,i,a,o=k,s=k,c,l=_e,u=1){if(l!==1026&&l!==1027)throw Error(`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 Xn(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}},Ss=class extends xs{constructor(e,t=oe,n=301,r,i,a=k,o=k,s,c=_e){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}},Cs=class extends er{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}},ws=class e extends Xi{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 q(c,3)),this.setAttribute(`normal`,new q(l,3)),this.setAttribute(`uv`,new q(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 G;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){let e=(_-1)*m;for(let t=0;t0&&v(!0),t>0&&v(!1)),this.setIndex(l),this.setAttribute(`position`,new q(u,3)),this.setAttribute(`normal`,new q(d,3)),this.setAttribute(`uv`,new q(f,2));function _(){let a=new G,_=new G,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 W,m=new G,_=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;e.9&&Math.min(t,n,r)<.1&&(t<.2&&(a[e+0]+=1),n<.2&&(a[e+2]+=1),r<.2&&(a[e+4]+=1))}}function d(e){i.push(e.x,e.y,e.z)}function f(t,n){let r=t*3;n.x=e[r+0],n.y=e[r+1],n.z=e[r+2]}function p(){let e=new G,t=new G,n=new G,r=new G,o=new W,s=new W,c=new W;for(let l=0,u=0;l0)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 W:new G);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 G,r=[],i=[],a=[],o=new G,s=new cr;for(let t=0;t<=e;t++){let n=t/e;r[t]=this.getTangentAt(n,new G)}i[0]=new G,a[0]=new G;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(U(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(U(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}},Ls=class extends Is{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 W){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}},Rs=class extends Ls{constructor(e,t,n,r,i,a){super(e,t,n,n,r,i,a),this.isArcCurve=!0,this.type=`ArcCurve`}};function zs(){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 Bs=new G,Vs=new G,Hs=new zs,Us=new zs,Ws=new zs,Gs=class extends Is{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 G){let n=t,r=this.points,i=r.length,a=(i-+!this.closed)*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]:(Vs.subVectors(r[0],r[1]).add(r[0]),c=Vs);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(Ks(o,s.x,c.x,l.x,u.x),Ks(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}},fc=class extends dc{constructor(e){super(e),this.uuid=mn(),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 gc(a,o,n,s,c,l,0),o}function mc(e,t,n,r,i){let a;if(i===Gc(e,t,n,r)>0)for(let i=t;i=t;i-=r)a=Hc(i/r|0,e[i],e[i+1],a);return a&&Pc(a,a.next)&&(Uc(a),a=a.next),a}function hc(e,t){if(!e)return e;t||=e;let n=e,r;do if(r=!1,!n.steiner&&(Pc(n,n.next)||Nc(n.prev,n,n.next)===0)){if(Uc(n),n=t=n.prev,n===n.next)break;r=!0}else n=n.next;while(r||n!==t);return t}function gc(e,t,n,r,i,a,o){if(!e)return;!o&&a&&Ec(e,r,i,a);let s=e;for(;e.prev!==e.next;){let c=e.prev,l=e.next;if(a?vc(e,r,i,a):_c(e)){t.push(c.i,e.i,l.i),Uc(e),e=l.next,s=l.next;continue}if(e=l,e===s){o?o===1?(e=yc(hc(e),t),gc(e,t,n,r,i,a,2)):o===2&&bc(e,t,n,r,i,a):gc(hc(e),t,n,r,i,a,1);break}}}function _c(e){let t=e.prev,n=e,r=e.next;if(Nc(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&&jc(i,s,a,c,o,l,m.x,m.y)&&Nc(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function vc(e,t,n,r){let i=e.prev,a=e,o=e.next;if(Nc(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),_=Oc(p,m,t,n,r),v=Oc(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&&jc(s,u,c,d,l,f,y.x,y.y)&&Nc(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&&jc(s,u,c,d,l,f,b.x,b.y)&&Nc(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&&jc(s,u,c,d,l,f,y.x,y.y)&&Nc(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&&jc(s,u,c,d,l,f,b.x,b.y)&&Nc(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function yc(e,t){let n=e;do{let r=n.prev,i=n.next.next;!Pc(r,i)&&Fc(r,n,n.next,i)&&zc(r,i)&&zc(i,r)&&(t.push(r.i,n.i,i.i),Uc(n),Uc(n.next),n=e=i),n=n.next}while(n!==e);return hc(n)}function bc(e,t,n,r,i,a){let o=e;do{let e=o.next.next;for(;e!==o.prev;){if(o.i!==e.i&&Mc(o,e)){let s=Vc(o,e);o=hc(o,o.next),s=hc(s,s.next),gc(o,t,n,r,i,a,0),gc(s,t,n,r,i,a,0);return}e=e.next}o=o.next}while(o!==e)}function xc(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&&Ac(io.x||n.x===o.x&&Tc(o,n)))&&(o=n,u=t)}n=n.next}while(n!==s);return o}function Tc(e,t){return Nc(e.prev,e,t.prev)<0&&Nc(t.next,e,e.next)<0}function Ec(e,t,n,r){let i=e;do i.z===0&&(i.z=Oc(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,Dc(i)}function Dc(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 Oc(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 kc(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 jc(e,t,n,r,i,a,o,s){return!(e===o&&t===s)&&Ac(e,t,n,r,i,a,o,s)}function Mc(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!Rc(e,t)&&(zc(e,t)&&zc(t,e)&&Bc(e,t)&&(Nc(e.prev,e,t.prev)||Nc(e,t.prev,t))||Pc(e,t)&&Nc(e.prev,e,e.next)>0&&Nc(t.prev,t,t.next)>0)}function Nc(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function Pc(e,t){return e.x===t.x&&e.y===t.y}function Fc(e,t,n,r){let i=Lc(Nc(e,t,n)),a=Lc(Nc(e,t,r)),o=Lc(Nc(n,r,e)),s=Lc(Nc(n,r,t));return!!(i!==a&&o!==s||i===0&&Ic(e,n,t)||a===0&&Ic(e,r,t)||o===0&&Ic(n,e,r)||s===0&&Ic(n,t,r))}function Ic(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 Lc(e){return e>0?1:e<0?-1:0}function Rc(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&&Fc(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}function zc(e,t){return Nc(e.prev,e,e.next)<0?Nc(e,t,e.next)>=0&&Nc(e,e.prev,t)>=0:Nc(e,t,e.prev)<0||Nc(e,e.next,t)<0}function Bc(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 Vc(e,t){let n=Wc(e.i,e.x,e.y),r=Wc(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 Hc(e,t,n,r){let i=Wc(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 Uc(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 Wc(e,t,n){return{i:e,x:t,y:n,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function Gc(e,t,n,r){let i=0;for(let a=t,o=n-r;a2&&e[t-1].equals(e[0])&&e.pop()}function Yc(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 W(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 W(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}},wl=class extends Cl{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type=`RawShaderMaterial`}},Tl=class extends ta{constructor(e){super(),this.isMeshStandardMaterial=!0,this.type=`MeshStandardMaterial`,this.defines={STANDARD:``},this.color=new K(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 K(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new W(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 vr,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}},El=class extends Tl{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 W(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return U(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 K(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 K(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new K(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}},Dl=class extends ta{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type=`MeshPhongMaterial`,this.color=new K(16777215),this.specular=new K(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new K(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new W(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new vr,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}},Ol=class extends ta{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:``},this.type=`MeshToonMaterial`,this.color=new K(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new K(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new W(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}},kl=class extends ta{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type=`MeshNormalMaterial`,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new W(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}},Al=class extends ta{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type=`MeshLambertMaterial`,this.color=new K(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new K(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new W(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new vr,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}},jl=class extends ta{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type=`MeshDepthMaterial`,this.depthPacking=gt,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}},Ml=class extends ta{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}},Nl=class extends ta{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:``},this.type=`MeshMatcapMaterial`,this.color=new K(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new W(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}},Pl=class extends Go{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 Fl(e,t){return!e||e.constructor===t?e:typeof t.BYTES_PER_ELEMENT==`number`?new t(e):Array.prototype.slice.call(e)}function Il(e){function t(t,n){return e[t]-e[n]}let n=e.length,r=Array(n);for(let e=0;e!==n;++e)r[e]=e;return r.sort(t),r}function Ll(e,t,n){let r=e.length,i=new e.constructor(r);for(let a=0,o=0;o!==r;++a){let r=n[a]*t;for(let n=0;n!==t;++n)i[o++]=e[r+n]}return i}function Rl(e,t,n,r){let i=1,a=e[0];for(;a!==void 0&&a[r]===void 0;)a=e[i++];if(a===void 0)return;let o=a[r];if(o!==void 0)if(Array.isArray(o))do o=a[r],o!==void 0&&(t.push(a.time),n.push(...o)),a=e[i++];while(a!==void 0);else if(o.toArray!==void 0)do o=a[r],o!==void 0&&(t.push(a.time),o.toArray(n,n.length)),a=e[i++];while(a!==void 0);else do o=a[r],o!==void 0&&(t.push(a.time),n.push(o)),a=e[i++];while(a!==void 0)}function zl(e,t,n,r,i=30){let a=e.clone();a.name=t;let o=[];for(let e=0;e=r)){c.push(t.times[e]);for(let n=0;na.tracks[e].times[0]&&(s=a.tracks[e].times[0]);for(let e=0;e=r.times[d]){let e=d*c+s,t=e+c-s;f=r.values.slice(e,t)}else{let e=r.createInterpolant(),t=s,n=c-s;e.evaluate(a),f=e.resultBuffer.slice(t,n)}i===`quaternion`&&new In().fromArray(f).normalize().conjugate().toArray(f);let p=o.times.length;for(let e=0;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&&(H(`KeyframeTrack: Invalid value size in track.`,this),e=!1);let n=this.times,r=this.values,i=n.length;i===0&&(H(`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)){H(`KeyframeTrack: Time is not a valid number.`,this,t,r),e=!1;break}if(a!==null&&a>r){H(`KeyframeTrack: Out of order keys.`,this,t,r,a),e=!1;break}a=r}if(r!==void 0&&Xt(r))for(let t=0,n=r.length;t!==n;++t){let n=r[t];if(isNaN(n)){H(`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()===lt,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}};ql.prototype.ValueTypeName=``,ql.prototype.TimeBufferType=Float32Array,ql.prototype.ValueBufferType=Float32Array,ql.prototype.DefaultInterpolation=ct;var Jl=class extends ql{constructor(e,t,n){super(e,t,n)}};Jl.prototype.ValueTypeName=`bool`,Jl.prototype.ValueBufferType=Array,Jl.prototype.DefaultInterpolation=st,Jl.prototype.InterpolantFactoryMethodLinear=void 0,Jl.prototype.InterpolantFactoryMethodSmooth=void 0;var Yl=class extends ql{constructor(e,t,n,r){super(e,t,n,r)}};Yl.prototype.ValueTypeName=`color`;var Xl=class extends ql{constructor(e,t,n,r){super(e,t,n,r)}};Xl.prototype.ValueTypeName=`number`;var Zl=class extends Hl{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)In.slerpFlat(i,0,a,c-o,a,c,s);return i}},Ql=class extends ql{constructor(e,t,n,r){super(e,t,n,r)}InterpolantFactoryMethodLinear(e){return new Zl(this.times,this.values,this.getValueSize(),e)}};Ql.prototype.ValueTypeName=`quaternion`,Ql.prototype.InterpolantFactoryMethodSmooth=void 0;var $l=class extends ql{constructor(e,t,n){super(e,t,n)}};$l.prototype.ValueTypeName=`string`,$l.prototype.ValueBufferType=Array,$l.prototype.DefaultInterpolation=st,$l.prototype.InterpolantFactoryMethodLinear=void 0,$l.prototype.InterpolantFactoryMethodSmooth=void 0;var eu=class extends ql{constructor(e,t,n,r){super(e,t,n,r)}};eu.prototype.ValueTypeName=`vector`;var tu=class{constructor(e=``,t=-1,n=[],r=mt){this.name=e,this.tracks=n,this.duration=t,this.blendMode=r,this.uuid=mn(),this.userData={},this.duration<0&&this.resetDuration()}static parse(e){let t=[],n=e.tracks,r=1/(e.fps||1);for(let e=0,i=n.length;e!==i;++e)t.push(ru(n[e]).scale(r));let i=new this(e.name,e.duration,t,e.blendMode);return i.uuid=e.uuid,i.userData=JSON.parse(e.userData||`{}`),i}static toJSON(e){let t=[],n=e.tracks,r={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode,userData:JSON.stringify(e.userData)};for(let e=0,r=n.length;e!==r;++e)t.push(ql.toJSON(n[e]));return r}static CreateFromMorphTargetSequence(e,t,n,r){let i=t.length,a=[];for(let e=0;e1){let e=a[1],t=r[e];t||(r[e]=t=[]),t.push(n)}}let a=[];for(let e in r)a.push(this.CreateFromMorphTargetSequence(e,r[e],t,n));return a}static parseAnimation(e,t){if(V(`AnimationClip: parseAnimation() is deprecated and will be removed with r185`),!e)return H(`AnimationClip: No animation in JSONLoader data.`),null;let n=function(e,t,n,r,i){if(n.length!==0){let a=[],o=[];Rl(n,a,o,r),a.length!==0&&i.push(new e(t,a,o))}},r=[],i=e.name||`default`,a=e.fps||30,o=e.blendMode,s=e.length||-1,c=e.hierarchy||[];for(let e=0;e{t&&t(i),this.manager.itemEnd(e)},0);return}if(lu[e]!==void 0){lu[e].push({onLoad:t,onProgress:n,onError:r});return}lu[e]=[],lu[e].push({onLoad:t,onProgress:n,onError:r});let a=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?`include`:`same-origin`,signal:typeof AbortSignal.any==`function`?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal}),o=this.mimeType,s=this.responseType;fetch(a).then(t=>{if(t.status===200||t.status===0){if(t.status===0&&V(`FileLoader: HTTP Status 0 received.`),typeof ReadableStream>`u`||t.body===void 0||t.body.getReader===void 0)return t;let n=lu[e],r=t.body.getReader(),i=t.headers.get(`X-File-Size`)||t.headers.get(`Content-Length`),a=i?parseInt(i):0,o=a!==0,s=0,c=new ReadableStream({start(e){t();function t(){r.read().then(({done:r,value:i})=>{if(r)e.close();else{s+=i.byteLength;let r=new ProgressEvent(`progress`,{lengthComputable:o,loaded:s,total:a});for(let e=0,t=n.length;e{e.error(t)})}}});return new Response(c)}else throw new uu(`fetch for "${t.url}" responded with ${t.status}: ${t.statusText}`,t)}).then(e=>{switch(s){case`arraybuffer`:return e.arrayBuffer();case`blob`:return e.blob();case`document`:return e.text().then(e=>new DOMParser().parseFromString(e,o));case`json`:return e.json();default:if(o===``)return e.text();{let t=/charset="?([^;"\s]*)"?/i.exec(o),n=t&&t[1]?t[1].toLowerCase():void 0,r=new TextDecoder(n);return e.arrayBuffer().then(e=>r.decode(e))}}}).then(t=>{iu.add(`file:${e}`,t);let n=lu[e];delete lu[e];for(let e=0,r=n.length;e{let n=lu[e];if(n===void 0)throw this.manager.itemError(e),t;delete lu[e];for(let e=0,r=n.length;e{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}},fu=class extends cu{constructor(e){super(e)}load(e,t,n,r){let i=this,a=new du(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(n){try{t(i.parse(JSON.parse(n)))}catch(t){r?r(t):H(t),i.manager.itemError(e)}},n,r)}parse(e){let t=[];for(let n=0;n0:r.vertexColors=e.vertexColors),e.uniforms!==void 0)for(let t in e.uniforms){let i=e.uniforms[t];switch(r.uniforms[t]={},i.type){case`t`:r.uniforms[t].value=n(i.value);break;case`c`:r.uniforms[t].value=new K().setHex(i.value);break;case`v2`:r.uniforms[t].value=new W().fromArray(i.value);break;case`v3`:r.uniforms[t].value=new G().fromArray(i.value);break;case`v4`:r.uniforms[t].value=new tr().fromArray(i.value);break;case`m3`:r.uniforms[t].value=new zn().fromArray(i.value);break;case`m4`:r.uniforms[t].value=new cr().fromArray(i.value);break;default:r.uniforms[t].value=i.value}}if(e.defines!==void 0&&(r.defines=e.defines),e.vertexShader!==void 0&&(r.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(r.fragmentShader=e.fragmentShader),e.glslVersion!==void 0&&(r.glslVersion=e.glslVersion),e.extensions!==void 0)for(let t in e.extensions)r.extensions[t]=e.extensions[t];if(e.lights!==void 0&&(r.lights=e.lights),e.clipping!==void 0&&(r.clipping=e.clipping),e.size!==void 0&&(r.size=e.size),e.sizeAttenuation!==void 0&&(r.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(r.map=n(e.map)),e.matcap!==void 0&&(r.matcap=n(e.matcap)),e.alphaMap!==void 0&&(r.alphaMap=n(e.alphaMap)),e.bumpMap!==void 0&&(r.bumpMap=n(e.bumpMap)),e.bumpScale!==void 0&&(r.bumpScale=e.bumpScale),e.normalMap!==void 0&&(r.normalMap=n(e.normalMap)),e.normalMapType!==void 0&&(r.normalMapType=e.normalMapType),e.normalScale!==void 0){let t=e.normalScale;Array.isArray(t)===!1&&(t=[t,t]),r.normalScale=new W().fromArray(t)}return e.displacementMap!==void 0&&(r.displacementMap=n(e.displacementMap)),e.displacementScale!==void 0&&(r.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(r.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(r.roughnessMap=n(e.roughnessMap)),e.metalnessMap!==void 0&&(r.metalnessMap=n(e.metalnessMap)),e.emissiveMap!==void 0&&(r.emissiveMap=n(e.emissiveMap)),e.emissiveIntensity!==void 0&&(r.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(r.specularMap=n(e.specularMap)),e.specularIntensityMap!==void 0&&(r.specularIntensityMap=n(e.specularIntensityMap)),e.specularColorMap!==void 0&&(r.specularColorMap=n(e.specularColorMap)),e.envMap!==void 0&&(r.envMap=n(e.envMap)),e.envMapRotation!==void 0&&r.envMapRotation.fromArray(e.envMapRotation),e.envMapIntensity!==void 0&&(r.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(r.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(r.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(r.lightMap=n(e.lightMap)),e.lightMapIntensity!==void 0&&(r.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(r.aoMap=n(e.aoMap)),e.aoMapIntensity!==void 0&&(r.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(r.gradientMap=n(e.gradientMap)),e.clearcoatMap!==void 0&&(r.clearcoatMap=n(e.clearcoatMap)),e.clearcoatRoughnessMap!==void 0&&(r.clearcoatRoughnessMap=n(e.clearcoatRoughnessMap)),e.clearcoatNormalMap!==void 0&&(r.clearcoatNormalMap=n(e.clearcoatNormalMap)),e.clearcoatNormalScale!==void 0&&(r.clearcoatNormalScale=new W().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(r.iridescenceMap=n(e.iridescenceMap)),e.iridescenceThicknessMap!==void 0&&(r.iridescenceThicknessMap=n(e.iridescenceThicknessMap)),e.transmissionMap!==void 0&&(r.transmissionMap=n(e.transmissionMap)),e.thicknessMap!==void 0&&(r.thicknessMap=n(e.thicknessMap)),e.anisotropyMap!==void 0&&(r.anisotropyMap=n(e.anisotropyMap)),e.sheenColorMap!==void 0&&(r.sheenColorMap=n(e.sheenColorMap)),e.sheenRoughnessMap!==void 0&&(r.sheenRoughnessMap=n(e.sheenRoughnessMap)),r}setTextures(e){return this.textures=e,this}createMaterialFromType(t){return e.createMaterialFromType(t)}static createMaterialFromType(e){return new{ShadowMaterial:ml,SpriteMaterial:na,RawShaderMaterial:wl,ShaderMaterial:Cl,PointsMaterial:as,MeshPhysicalMaterial:El,MeshStandardMaterial:Tl,MeshPhongMaterial:Dl,MeshToonMaterial:Ol,MeshNormalMaterial:kl,MeshLambertMaterial:Al,MeshDepthMaterial:jl,MeshDistanceMaterial:Ml,MeshBasicMaterial:ka,MeshMatcapMaterial:Nl,LineDashedMaterial:Pl,LineBasicMaterial:Go,Material:ta}[e]}},Gu=class{static extractUrlBase(e){let t=e.lastIndexOf(`/`);return t===-1?`./`:e.slice(0,t+1)}static resolveURL(e,t){return typeof e!=`string`||e===``?``:(/^https?:\/\//i.test(t)&&/^\//.test(e)&&(t=t.replace(/(^https?:\/\/[^\/]+).*/i,`$1`)),/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e)?e:t+e)}},Ku=class extends Xi{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type=`InstancedBufferGeometry`,this.instanceCount=1/0}copy(e){return super.copy(e),this.instanceCount=e.instanceCount,this}toJSON(){let e=super.toJSON();return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}},qu=class extends cu{constructor(e){super(e)}load(e,t,n,r){let i=this,a=new du(i.manager);a.setPath(i.path),a.setRequestHeader(i.requestHeader),a.setWithCredentials(i.withCredentials),a.load(e,function(n){try{t(i.parse(JSON.parse(n)))}catch(t){r?r(t):H(t),i.manager.itemError(e)}},n,r)}parse(e){let t={},n={};function r(e,n){if(t[n]!==void 0)return t[n];let r=e.interleavedBuffers[n],a=i(e,r.buffer),o=new Zi(Yt(r.type,a),r.stride);return o.uuid=r.uuid,t[n]=o,o}function i(e,t){if(n[t]!==void 0)return n[t];let r=e.arrayBuffers[t],i=new Uint32Array(r).buffer;return n[t]=i,i}let a=e.isInstancedBufferGeometry?new Ku:new Xi,o=e.data.index;if(o!==void 0){let e=Yt(o.type,o.array);a.setIndex(new Ai(e,1))}let s=e.data.attributes;for(let t in s){let n=s[t],i;if(n.isInterleavedBufferAttribute)i=new $i(r(e.data,n.data),n.itemSize,n.offset,n.normalized);else{let e=Yt(n.type,n.array);i=new(n.isInstancedBufferAttribute?ao:Ai)(e,n.itemSize,n.normalized)}n.name!==void 0&&(i.name=n.name),n.usage!==void 0&&i.setUsage(n.usage),a.setAttribute(t,i)}let c=e.data.morphAttributes;if(c)for(let t in c){let n=c[t],i=[];for(let t=0,a=n.length;t0){i=new hu(new ou(t)),i.setCrossOrigin(this.crossOrigin);for(let t=0,n=e.length;t0){r=new hu(this.manager),r.setCrossOrigin(this.crossOrigin);for(let t=0,r=e.length;t{let t=null,n=null;return e.boundingBox!==void 0&&(t=new si().fromJSON(e.boundingBox)),e.boundingSphere!==void 0&&(n=new Hi().fromJSON(e.boundingSphere)),{...e,boundingBox:t,boundingSphere:n}}),a._instanceInfo=e.instanceInfo,a._availableInstanceIds=e._availableInstanceIds,a._availableGeometryIds=e._availableGeometryIds,a._nextIndexStart=e.nextIndexStart,a._nextVertexStart=e.nextVertexStart,a._geometryCount=e.geometryCount,a._maxInstanceCount=e.maxInstanceCount,a._maxVertexCount=e.maxVertexCount,a._maxIndexCount=e.maxIndexCount,a._geometryInitialized=e.geometryInitialized,a._matricesTexture=c(e.matricesTexture.uuid),a._indirectTexture=c(e.indirectTexture.uuid),e.colorsTexture!==void 0&&(a._colorsTexture=c(e.colorsTexture.uuid)),e.boundingSphere!==void 0&&(a.boundingSphere=new Hi().fromJSON(e.boundingSphere)),e.boundingBox!==void 0&&(a.boundingBox=new si().fromJSON(e.boundingBox));break;case`LOD`:a=new ba;break;case`Line`:a=new $o(o(e.geometry),s(e.material));break;case`LineLoop`:a=new is(o(e.geometry),s(e.material));break;case`LineSegments`:a=new rs(o(e.geometry),s(e.material));break;case`PointCloud`:case`Points`:a=new us(o(e.geometry),s(e.material));break;case`Sprite`:a=new ga(s(e.material));break;case`Group`:a=new Ir;break;case`Bone`:a=new eo;break;default:a=new Fr}if(a.uuid=e.uuid,e.name!==void 0&&(a.name=e.name),e.matrix===void 0?(e.position!==void 0&&a.position.fromArray(e.position),e.rotation!==void 0&&a.rotation.fromArray(e.rotation),e.quaternion!==void 0&&a.quaternion.fromArray(e.quaternion),e.scale!==void 0&&a.scale.fromArray(e.scale)):(a.matrix.fromArray(e.matrix),e.matrixAutoUpdate!==void 0&&(a.matrixAutoUpdate=e.matrixAutoUpdate),a.matrixAutoUpdate&&a.matrix.decompose(a.position,a.quaternion,a.scale)),e.up!==void 0&&a.up.fromArray(e.up),e.pivot!==void 0&&(a.pivot=new G().fromArray(e.pivot)),e.morphTargetDictionary!==void 0&&(a.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),e.morphTargetInfluences!==void 0&&(a.morphTargetInfluences=e.morphTargetInfluences.slice()),e.castShadow!==void 0&&(a.castShadow=e.castShadow),e.receiveShadow!==void 0&&(a.receiveShadow=e.receiveShadow),e.shadow&&(e.shadow.intensity!==void 0&&(a.shadow.intensity=e.shadow.intensity),e.shadow.bias!==void 0&&(a.shadow.bias=e.shadow.bias),e.shadow.normalBias!==void 0&&(a.shadow.normalBias=e.shadow.normalBias),e.shadow.radius!==void 0&&(a.shadow.radius=e.shadow.radius),e.shadow.mapSize!==void 0&&a.shadow.mapSize.fromArray(e.shadow.mapSize),e.shadow.camera!==void 0&&(a.shadow.camera=this.parseObject(e.shadow.camera))),e.visible!==void 0&&(a.visible=e.visible),e.frustumCulled!==void 0&&(a.frustumCulled=e.frustumCulled),e.renderOrder!==void 0&&(a.renderOrder=e.renderOrder),e.static!==void 0&&(a.static=e.static),e.userData!==void 0&&(a.userData=e.userData),e.layers!==void 0&&(a.layers.mask=e.layers),e.children!==void 0){let o=e.children;for(let e=0;e`u`&&V(`ImageBitmapLoader: createImageBitmap() not supported.`),typeof fetch>`u`&&V(`ImageBitmapLoader: fetch() not supported.`),this.options={premultiplyAlpha:`none`},this._abortController=new AbortController}setOptions(e){return this.options=e,this}load(e,t,n,r){e===void 0&&(e=``),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let i=this,a=iu.get(`image-bitmap:${e}`);if(a!==void 0){if(i.manager.itemStart(e),a.then){a.then(n=>{$u.has(a)===!0?(r&&r($u.get(a)),i.manager.itemError(e),i.manager.itemEnd(e)):(t&&t(n),i.manager.itemEnd(e))});return}setTimeout(function(){t&&t(a),i.manager.itemEnd(e)},0);return}let o={};o.credentials=this.crossOrigin===`anonymous`?`same-origin`:`include`,o.headers=this.requestHeader,o.signal=typeof AbortSignal.any==`function`?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal;let s=fetch(e,o).then(function(e){return e.blob()}).then(function(e){return createImageBitmap(e,Object.assign(i.options,{colorSpaceConversion:`none`}))}).then(function(n){iu.add(`image-bitmap:${e}`,n),t&&t(n),i.manager.itemEnd(e)}).catch(function(t){r&&r(t),$u.set(s,t),iu.remove(`image-bitmap:${e}`),i.manager.itemError(e),i.manager.itemEnd(e)});iu.add(`image-bitmap:${e}`,s),i.manager.itemStart(e)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}},td,nd=class{static getContext(){return td===void 0&&(td=new(window.AudioContext||window.webkitAudioContext)),td}static setContext(e){td=e}},rd=class extends cu{constructor(e){super(e)}load(e,t,n,r){let i=this,a=new du(this.manager);a.setResponseType(`arraybuffer`),a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(n){try{let r=n.slice(0),a=nd.getContext(),s=e+`#decode`;i.manager.itemStart(s),a.decodeAudioData(r,function(e){t(e),i.manager.itemEnd(s)}).catch(function(e){o(e),i.manager.itemEnd(s)})}catch(e){o(e)}},n,r);function o(t){r?r(t):H(t),i.manager.itemError(e)}}},id=new cr,ad=new cr,od=new cr,sd=class{constructor(){this.type=`StereoCamera`,this.aspect=1,this.eyeSep=.064,this.cameraL=new Mu,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new Mu,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}update(e){let t=this._cache;if(t.focus!==e.focus||t.fov!==e.fov||t.aspect!==e.aspect*this.aspect||t.near!==e.near||t.far!==e.far||t.zoom!==e.zoom||t.eyeSep!==this.eyeSep){t.focus=e.focus,t.fov=e.fov,t.aspect=e.aspect*this.aspect,t.near=e.near,t.far=e.far,t.zoom=e.zoom,t.eyeSep=this.eyeSep,od.copy(e.projectionMatrix);let n=t.eyeSep/2,r=n*t.near/t.focus,i=t.near*Math.tan(fn*t.fov*.5)/t.zoom,a,o;ad.elements[12]=-n,id.elements[12]=n,a=-i*t.aspect+r,o=i*t.aspect+r,od.elements[0]=2*t.near/(o-a),od.elements[8]=(o+a)/(o-a),this.cameraL.projectionMatrix.copy(od),a=-i*t.aspect-r,o=i*t.aspect-r,od.elements[0]=2*t.near/(o-a),od.elements[8]=(o+a)/(o-a),this.cameraR.projectionMatrix.copy(od)}this.cameraL.matrixWorld.copy(e.matrixWorld).multiply(ad),this.cameraR.matrixWorld.copy(e.matrixWorld).multiply(id)}},cd=-90,ld=1,ud=class extends Fr{constructor(e,t,n){super(),this.type=`CubeCamera`,this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;let r=new Mu(cd,ld,e,t);r.layers=this.layers,this.add(r);let i=new Mu(cd,ld,e,t);i.layers=this.layers,this.add(i);let a=new Mu(cd,ld,e,t);a.layers=this.layers,this.add(a);let o=new Mu(cd,ld,e,t);o.layers=this.layers,this.add(o);let s=new Mu(cd,ld,e,t);s.layers=this.layers,this.add(s);let c=new Mu(cd,ld,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){let e=this.coordinateSystem,t=this.children.concat(),[n,r,i,a,o,s]=t;for(let e of t)this.remove(e);if(e===2e3)n.up.set(0,1,0),n.lookAt(1,0,0),r.up.set(0,1,0),r.lookAt(-1,0,0),i.up.set(0,0,-1),i.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),s.up.set(0,1,0),s.lookAt(0,0,-1);else if(e===2001)n.up.set(0,-1,0),n.lookAt(-1,0,0),r.up.set(0,-1,0),r.lookAt(1,0,0),i.up.set(0,0,1),i.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),s.up.set(0,-1,0),s.lookAt(0,0,-1);else throw Error(`THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: `+e);for(let e of t)this.add(e),e.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();let{renderTarget:n,activeMipmapLevel:r}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());let[i,a,o,s,c,l]=this.children,u=e.getRenderTarget(),d=e.getActiveCubeFace(),f=e.getActiveMipmapLevel(),p=e.xr.enabled;e.xr.enabled=!1;let m=n.texture.generateMipmaps;n.texture.generateMipmaps=!1;let h=!1;h=e.isWebGLRenderer===!0?e.state.buffers.depth.getReversed():e.reversedDepthBuffer,e.setRenderTarget(n,0,r),h&&e.autoClear===!1&&e.clearDepth(),e.render(t,i),e.setRenderTarget(n,1,r),h&&e.autoClear===!1&&e.clearDepth(),e.render(t,a),e.setRenderTarget(n,2,r),h&&e.autoClear===!1&&e.clearDepth(),e.render(t,o),e.setRenderTarget(n,3,r),h&&e.autoClear===!1&&e.clearDepth(),e.render(t,s),e.setRenderTarget(n,4,r),h&&e.autoClear===!1&&e.clearDepth(),e.render(t,c),n.texture.generateMipmaps=m,e.setRenderTarget(n,5,r),h&&e.autoClear===!1&&e.clearDepth(),e.render(t,l),e.setRenderTarget(u,d,f),e.xr.enabled=p,n.texture.needsPMREMUpdate=!0}},dd=class extends Mu{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}},fd=class{constructor(){this._previousTime=0,this._currentTime=0,this._startTime=performance.now(),this._delta=0,this._elapsed=0,this._timescale=1,this._document=null,this._pageVisibilityHandler=null}connect(e){this._document=e,e.hidden!==void 0&&(this._pageVisibilityHandler=pd.bind(this),e.addEventListener(`visibilitychange`,this._pageVisibilityHandler,!1))}disconnect(){this._pageVisibilityHandler!==null&&(this._document.removeEventListener(`visibilitychange`,this._pageVisibilityHandler),this._pageVisibilityHandler=null),this._document=null}getDelta(){return this._delta/1e3}getElapsed(){return this._elapsed/1e3}getTimescale(){return this._timescale}setTimescale(e){return this._timescale=e,this}reset(){return this._currentTime=performance.now()-this._startTime,this}dispose(){this.disconnect()}update(e){return this._pageVisibilityHandler!==null&&this._document.hidden===!0?this._delta=0:(this._previousTime=this._currentTime,this._currentTime=(e===void 0?performance.now():e)-this._startTime,this._delta=(this._currentTime-this._previousTime)*this._timescale,this._elapsed+=this._delta),this}};function pd(){this._document.hidden===!1&&this.reset()}var md=new G,hd=new In,gd=new G,_d=new G,vd=new G,yd=class extends Fr{constructor(){super(),this.type=`AudioListener`,this.context=nd.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._timer=new fd}getInput(){return this.gain}removeFilter(){return this.filter!==null&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this}getFilter(){return this.filter}setFilter(e){return this.filter===null?this.gain.disconnect(this.context.destination):(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)),this.filter=e,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}updateMatrixWorld(e){super.updateMatrixWorld(e),this._timer.update();let t=this.context.listener;if(this.timeDelta=this._timer.getDelta(),this.matrixWorld.decompose(md,hd,gd),_d.set(0,0,-1).applyQuaternion(hd),vd.set(0,1,0).applyQuaternion(hd),t.positionX){let e=this.context.currentTime+this.timeDelta;t.positionX.linearRampToValueAtTime(md.x,e),t.positionY.linearRampToValueAtTime(md.y,e),t.positionZ.linearRampToValueAtTime(md.z,e),t.forwardX.linearRampToValueAtTime(_d.x,e),t.forwardY.linearRampToValueAtTime(_d.y,e),t.forwardZ.linearRampToValueAtTime(_d.z,e),t.upX.linearRampToValueAtTime(vd.x,e),t.upY.linearRampToValueAtTime(vd.y,e),t.upZ.linearRampToValueAtTime(vd.z,e)}else t.setPosition(md.x,md.y,md.z),t.setOrientation(_d.x,_d.y,_d.z,vd.x,vd.y,vd.z)}},bd=class extends Fr{constructor(e){super(),this.type=`Audio`,this.listener=e,this.context=e.context,this.gain=this.context.createGain(),this.gain.connect(e.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.source=null,this.sourceType=`empty`,this._startedAt=0,this._progress=0,this._connected=!1,this.filters=[]}getOutput(){return this.gain}setNodeSource(e){return this.hasPlaybackControl=!1,this.sourceType=`audioNode`,this.source=e,this.connect(),this}setMediaElementSource(e){return this.hasPlaybackControl=!1,this.sourceType=`mediaNode`,this.source=this.context.createMediaElementSource(e),this.connect(),this}setMediaStreamSource(e){return this.hasPlaybackControl=!1,this.sourceType=`mediaStreamNode`,this.source=this.context.createMediaStreamSource(e),this.connect(),this}setBuffer(e){return this.buffer=e,this.sourceType=`buffer`,this.autoplay&&this.play(),this}play(e=0){if(this.isPlaying===!0){V(`Audio: Audio is already playing.`);return}if(this.hasPlaybackControl===!1){V(`Audio: this Audio has no playback control.`);return}this._startedAt=this.context.currentTime+e;let t=this.context.createBufferSource();return t.buffer=this.buffer,t.loop=this.loop,t.loopStart=this.loopStart,t.loopEnd=this.loopEnd,t.onended=this.onEnded.bind(this),t.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=t,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){if(this.hasPlaybackControl===!1){V(`Audio: this Audio has no playback control.`);return}return this.isPlaying===!0&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,this.loop===!0&&(this._progress%=this.duration||this.buffer.duration),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this}stop(e=0){if(this.hasPlaybackControl===!1){V(`Audio: this Audio has no playback control.`);return}return this._progress=0,this.source!==null&&(this.source.stop(this.context.currentTime+e),this.source.onended=null),this.isPlaying=!1,this}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let e=1,t=this.filters.length;e0){this.source.disconnect(this.filters[0]);for(let e=1,t=this.filters.length;e0&&this._mixBufferRegionAdditive(n,r,this._addIndex*t,1,t);for(let e=t,i=t+t;e!==i;++e)if(n[e]!==n[e+t]){o.setValue(n,r);break}}saveOriginalState(){let e=this.binding,t=this.buffer,n=this.valueSize,r=n*this._origIndex;e.getValue(t,r);for(let e=n,i=r;e!==i;++e)t[e]=t[r+e%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){let e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){let e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let n=e;n=.5)for(let r=0;r!==i;++r)e[t+r]=e[n+r]}_slerp(e,t,n,r){In.slerpFlat(e,t,e,t,e,n,r)}_slerpAdditive(e,t,n,r,i){let a=this._workIndex*i;In.multiplyQuaternionsFlat(e,a,e,t,e,n),In.slerpFlat(e,t,e,t,e,a,r)}_lerp(e,t,n,r,i){let a=1-r;for(let o=0;o!==i;++o){let i=t+o;e[i]=e[i]*a+e[n+o]*r}}_lerpAdditive(e,t,n,r,i){for(let a=0;a!==i;++a){let i=t+a;e[i]=e[i]+e[n+a]*r}}},Od=`\\[\\]\\.:\\/`,kd=RegExp(`[\\[\\]\\.:\\/]`,`g`),Ad=`[^\\[\\]\\.:\\/]`,jd=`[^`+Od.replace(`\\.`,``)+`]`,Md=`((?:WC+[\\/:])*)`.replace(`WC`,Ad),Nd=`(WCOD+)?`.replace(`WCOD`,jd),Pd=`(?:\\.(WC+)(?:\\[(.+)\\])?)?`.replace(`WC`,Ad),Fd=`\\.(WC+)(?:\\[(.+)\\])?`.replace(`WC`,Ad),Id=RegExp(`^`+Md+Nd+Pd+Fd+`$`),Ld=[`material`,`materials`,`bones`,`map`],Rd=class{constructor(e,t,n){let r=n||zd.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,r)}getValue(e,t){this.bind();let n=this._targetGroup.nCachedObjects_,r=this._bindings[n];r!==void 0&&r.getValue(e,t)}setValue(e,t){let n=this._bindings;for(let r=this._targetGroup.nCachedObjects_,i=n.length;r!==i;++r)n[r].setValue(e,t)}bind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}},zd=class e{constructor(t,n,r){this.path=n,this.parsedPath=r||e.parseTrackName(n),this.node=e.findNode(t,this.parsedPath.nodeName),this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,n,r){return t&&t.isAnimationObjectGroup?new e.Composite(t,n,r):new e(t,n,r)}static sanitizeNodeName(e){return e.replace(/\s/g,`_`).replace(kd,``)}static parseTrackName(e){let t=Id.exec(e);if(t===null)throw Error(`PropertyBinding: Cannot parse trackName: `+e);let n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},r=n.nodeName&&n.nodeName.lastIndexOf(`.`);if(r!==void 0&&r!==-1){let e=n.nodeName.substring(r+1);Ld.indexOf(e)!==-1&&(n.nodeName=n.nodeName.substring(0,r),n.objectName=e)}if(n.propertyName===null||n.propertyName.length===0)throw Error(`PropertyBinding: can not parse propertyName from trackName: `+e);return n}static findNode(e,t){if(t===void 0||t===``||t===`.`||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){let n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){let n=function(e){for(let r=0;r=i){let a=i++,l=e[a];t[l.uuid]=c,e[c]=l,t[s]=a,e[a]=o;for(let e=0,t=r;e!==t;++e){let t=n[e],r=t[a],i=t[c];t[c]=r,t[a]=i}}}this.nCachedObjects_=i}uncache(){let e=this._objects,t=this._indicesByUUID,n=this._bindings,r=n.length,i=this.nCachedObjects_,a=e.length;for(let o=0,s=arguments.length;o!==s;++o){let s=arguments[o].uuid,c=t[s];if(c!==void 0)if(delete t[s],c0&&(t[o.uuid]=c),e[c]=o,e.pop();for(let e=0,t=r;e!==t;++e){let t=n[e];t[c]=t[i],t.pop()}}}this.nCachedObjects_=i}subscribe_(e,t){let n=this._bindingsIndicesByPath,r=n[e],i=this._bindings;if(r!==void 0)return i[r];let a=this._paths,o=this._parsedPaths,s=this._objects,c=s.length,l=this.nCachedObjects_,u=Array(c);r=i.length,n[e]=r,a.push(e),o.push(t),i.push(u);for(let n=l,r=s.length;n!==r;++n){let r=s[n];u[n]=new zd(r,e,t)}return u}unsubscribe_(e){let t=this._bindingsIndicesByPath,n=t[e];if(n!==void 0){let r=this._paths,i=this._parsedPaths,a=this._bindings,o=a.length-1,s=a[o],c=e[o];t[c]=n,a[n]=s,a.pop(),i[n]=i[o],i.pop(),r[n]=r[o],r.pop()}}},Vd=class{constructor(e,t,n=null,r=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=n,this.blendMode=r;let i=t.tracks,a=i.length,o=Array(a),s={endingStart:dt,endingEnd:dt};for(let e=0;e!==a;++e){let t=i[e].createInterpolant(null);o[e]=t,t.settings&&Object.assign(s,t.settings),t.settings=s}this._interpolantSettings=s,this._interpolants=o,this._propertyBindings=Array(a),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=at,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,n=!1){if(e.fadeOut(t),this.fadeIn(t),n===!0){let n=this._clip.duration,r=e._clip.duration,i=r/n,a=n/r;e.warp(1,i,t),this.warp(a,1,t)}return this}crossFadeTo(e,t,n=!1){return e.crossFadeFrom(this,t,n)}stopFading(){let e=this._weightInterpolant;return e!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,n){let r=this._mixer,i=r.time,a=this.timeScale,o=this._timeScaleInterpolant;o===null&&(o=r._lendControlInterpolant(),this._timeScaleInterpolant=o);let s=o.parameterPositions,c=o.sampleValues;return s[0]=i,s[1]=i+n,c[0]=e/a,c[1]=t/a,this}stopWarping(){let e=this._timeScaleInterpolant;return e!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,n,r){if(!this.enabled){this._updateWeight(e);return}let i=this._startTime;if(i!==null){let r=(e-i)*n;r<0||n===0?t=0:(this._startTime=null,t=n*r)}t*=this._updateTimeScale(e);let a=this._updateTime(t),o=this._updateWeight(e);if(o>0){let e=this._interpolants,t=this._propertyBindings;switch(this.blendMode){case ht:for(let n=0,r=e.length;n!==r;++n)e[n].evaluate(a),t[n].accumulateAdditive(o);break;case mt:default:for(let n=0,i=e.length;n!==i;++n)e[n].evaluate(a),t[n].accumulate(r,o)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;let n=this._weightInterpolant;if(n!==null){let r=n.evaluate(e)[0];t*=r,e>n.parameterPositions[1]&&(this.stopFading(),r===0&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;let n=this._timeScaleInterpolant;if(n!==null){let r=n.evaluate(e)[0];t*=r,e>n.parameterPositions[1]&&(this.stopWarping(),t===0?this.paused=!0:this.timeScale=t)}}return this._effectiveTimeScale=t,t}_updateTime(e){let t=this._clip.duration,n=this.loop,r=this.time+e,i=this._loopCount,a=n===ot;if(e===0)return i===-1?r:a&&(i&1)==1?t-r:r;if(n===2200){i===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));handle_stop:{if(r>=t)r=t;else if(r<0)r=0;else{this.time=r;break handle_stop}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=r,this._mixer.dispatchEvent({type:`finished`,action:this,direction:e<0?-1:1})}}else{if(i===-1&&(e>=0?(i=0,this._setEndings(!0,this.repetitions===0,a)):this._setEndings(this.repetitions===0,!0,a)),r>=t||r<0){let n=Math.floor(r/t);r-=t*n,i+=Math.abs(n);let o=this.repetitions-i;if(o<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,r=e>0?t:0,this.time=r,this._mixer.dispatchEvent({type:`finished`,action:this,direction:e>0?1:-1});else{if(o===1){let t=e<0;this._setEndings(t,!t,a)}else this._setEndings(!1,!1,a);this._loopCount=i,this.time=r,this._mixer.dispatchEvent({type:`loop`,action:this,loopDelta:n})}}else this._loopCount=i,this.time=r;if(a&&(i&1)==1)return t-r}return r}_setEndings(e,t,n){let r=this._interpolantSettings;n?(r.endingStart=ft,r.endingEnd=ft):(e?r.endingStart=this.zeroSlopeAtStart?ft:dt:r.endingStart=pt,t?r.endingEnd=this.zeroSlopeAtEnd?ft:dt:r.endingEnd=pt)}_scheduleFading(e,t,n){let r=this._mixer,i=r.time,a=this._weightInterpolant;a===null&&(a=r._lendControlInterpolant(),this._weightInterpolant=a);let o=a.parameterPositions,s=a.sampleValues;return o[0]=i,s[0]=t,o[1]=i+e,s[1]=n,this}},Hd=new Float32Array(1),Ud=class extends ln{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1,typeof __THREE_DEVTOOLS__<`u`&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent(`observe`,{detail:this}))}_bindAction(e,t){let n=e._localRoot||this._root,r=e._clip.tracks,i=r.length,a=e._propertyBindings,o=e._interpolants,s=n.uuid,c=this._bindingsByRootAndName,l=c[s];l===void 0&&(l={},c[s]=l);for(let e=0;e!==i;++e){let i=r[e],c=i.name,u=l[c];if(u!==void 0)++u.referenceCount,a[e]=u;else{if(u=a[e],u!==void 0){u._cacheIndex===null&&(++u.referenceCount,this._addInactiveBinding(u,s,c));continue}let r=t&&t._propertyBindings[e].binding.parsedPath;u=new Dd(zd.create(n,c,r),i.ValueTypeName,i.getValueSize()),++u.referenceCount,this._addInactiveBinding(u,s,c),a[e]=u}o[e].resultBuffer=u.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){let t=(e._localRoot||this._root).uuid,n=e._clip.uuid,r=this._actionsByClip[n];this._bindAction(e,r&&r.knownActions[0]),this._addInactiveAction(e,n,t)}let t=e._propertyBindings;for(let e=0,n=t.length;e!==n;++e){let n=t[e];n.useCount++===0&&(this._lendBinding(n),n.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){let t=e._propertyBindings;for(let e=0,n=t.length;e!==n;++e){let n=t[e];--n.useCount===0&&(n.restoreOriginalState(),this._takeBackBinding(n))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;let e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){let t=e._cacheIndex;return t!==null&&t=0;--n)e[n].stop();return this}update(e){e*=this.timeScale;let t=this._actions,n=this._nActiveActions,r=this.time+=e,i=Math.sign(e),a=this._accuIndex^=1;for(let o=0;o!==n;++o)t[o]._update(r,e,i,a);let o=this._bindings,s=this._nActiveBindings;for(let e=0;e!==s;++e)o[e].apply(a);return this}setTime(e){this.time=0;for(let e=0;e=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,rf).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)}},of=new G,sf=new G,cf=new G,lf=new G,uf=new G,df=new G,ff=new G,pf=class{constructor(e=new G,t=new G){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){of.subVectors(e,this.start),sf.subVectors(this.end,this.start);let n=sf.dot(sf);if(n===0)return 0;let r=sf.dot(of)/n;return t&&(r=U(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=df,n=ff){let r=1e-8*1e-8,i,a,o=this.start,s=e.start,c=this.end,l=e.end;cf.subVectors(c,o),lf.subVectors(l,s),uf.subVectors(o,s);let u=cf.dot(cf),d=lf.dot(lf),f=lf.dot(uf);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=U(a,0,1);else{let e=cf.dot(uf);if(d<=r)a=0,i=U(-e/u,0,1);else{let t=cf.dot(lf),n=u*d-t*t;i=n===0?0:U((t*f-e*d)/n,0,1),a=(t*i+f)/d,a<0?(a=0,i=U(-e/u,0,1)):a>1&&(a=1,i=U((t-e)/u,0,1))}}return t.copy(o).addScaledVector(cf,i),n.copy(s).addScaledVector(lf,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)}},mf=new G,hf=class extends Fr{constructor(e,t){super(),this.light=e,this.matrixAutoUpdate=!1,this.color=t,this.type=`SpotLightHelper`;let n=new Xi,r=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let e=0,t=1;e<32;e++,t++){let n=e/32*Math.PI*2,i=t/32*Math.PI*2;r.push(Math.cos(n),Math.sin(n),1,Math.cos(i),Math.sin(i),1)}n.setAttribute(`position`,new q(r,3));let i=new Go({fog:!1,toneMapped:!1});this.cone=new rs(n,i),this.add(this.cone),this.update()}dispose(){this.cone.geometry.dispose(),this.cone.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),this.parent?(this.parent.updateWorldMatrix(!0),this.matrix.copy(this.parent.matrixWorld).invert().multiply(this.light.matrixWorld)):this.matrix.copy(this.light.matrixWorld),this.matrixWorld.copy(this.light.matrixWorld);let e=this.light.distance?this.light.distance:1e3,t=e*Math.tan(this.light.angle);this.cone.scale.set(t,t,e),mf.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(mf),this.color===void 0?this.cone.material.color.copy(this.light.color):this.cone.material.color.set(this.color)}},gf=new G,_f=new cr,vf=new cr,yf=class extends rs{constructor(e){let t=bf(e),n=new Xi,r=[],i=[];for(let e=0;e1)for(let n=0;n.99999)this.quaternion.set(0,0,0,1);else if(e.y<-.99999)this.quaternion.set(1,0,0,0);else{Bf.set(e.z,0,-e.x).normalize();let t=Math.acos(e.y);this.quaternion.setFromAxisAngle(Bf,t)}}setLength(e,t=e*.2,n=t*.2){this.line.scale.set(1,Math.max(1e-4,e-t),1),this.line.updateMatrix(),this.cone.scale.set(n,t,n),this.cone.position.y=e,this.cone.updateMatrix()}setColor(e){this.line.material.color.set(e),this.cone.material.color.set(e)}copy(e){return super.copy(e,!1),this.line.copy(e.line),this.cone.copy(e.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}},Wf=class extends rs{constructor(e=1){let t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],n=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],r=new Xi;r.setAttribute(`position`,new q(t,3)),r.setAttribute(`color`,new q(n,3));let i=new Go({vertexColors:!0,toneMapped:!1});super(r,i),this.type=`AxesHelper`}setColors(e,t,n){let r=new K,i=this.geometry.attributes.color.array;return r.set(e),r.toArray(i,0),r.toArray(i,3),r.set(t),r.toArray(i,6),r.toArray(i,9),r.set(n),r.toArray(i,12),r.toArray(i,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}},Gf=class{constructor(){this.type=`ShapePath`,this.color=new K,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new dc,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(e){function t(e){let t=[];for(let n=0,r=e.length;n2**-52){if(c<0&&(n=t[a],s=-s,o=t[i],c=-c),e.yo.y)continue;if(e.y===n.y){if(e.x===n.x)return!0}else{let t=c*(e.x-n.x)-s*(e.y-n.y);if(t===0)return!0;if(t<0)continue;r=!r}}else{if(e.y!==n.y)continue;if(o.x<=e.x&&e.x<=n.x||n.x<=e.x&&e.x<=o.x)return!0}}return r}let r=qc.isClockWise,i=this.subPaths;if(i.length===0)return[];let a,o,s,c=[];if(i.length===1)return o=i[0],s=new fc,s.curves=o.curves,c.push(s),c;let l=!r(i[0].getPoints());l=e?!l:l;let u=[],d=[],f=[],p=0,m;d[p]=void 0,f[p]=[];for(let t=0,n=i.length;t1){let e=!1,t=0;for(let e=0,t=d.length;e0&&e===!1&&(f=u)}let h;for(let e=0,t=d.length;et?(e.repeat.x=1,e.repeat.y=n/t,e.offset.x=0,e.offset.y=(1-e.repeat.y)/2):(e.repeat.x=t/n,e.repeat.y=1,e.offset.x=(1-e.repeat.x)/2,e.offset.y=0),e}function Jf(e,t){let n=e.image&&e.image.width?e.image.width/e.image.height:1;return n>t?(e.repeat.x=t/n,e.repeat.y=1,e.offset.x=(1-e.repeat.x)/2,e.offset.y=0):(e.repeat.x=1,e.repeat.y=n/t,e.offset.x=0,e.offset.y=(1-e.repeat.y)/2),e}function Yf(e){return e.repeat.x=1,e.repeat.y=1,e.offset.x=0,e.offset.y=0,e}function Xf(e,t,n,r){let i=Zf(r);switch(n){case me:return e*t;case ye:return e*t/i.components*i.byteLength;case be:return e*t/i.components*i.byteLength;case xe:return e*t*2/i.components*i.byteLength;case Se:return e*t*2/i.components*i.byteLength;case he:return e*t*3/i.components*i.byteLength;case ge:return e*t*4/i.components*i.byteLength;case R:return e*t*4/i.components*i.byteLength;case we:case Te:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*8;case Ee:case z:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*16;case Oe:case B:return Math.max(e,16)*Math.max(t,8)/4;case De:case ke:return Math.max(e,8)*Math.max(t,8)/2;case Ae:case je:case Ne:case Pe:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*8;case Me:case Fe:case Ie:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*16;case Le:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*16;case Re:return Math.floor((e+4)/5)*Math.floor((t+3)/4)*16;case ze:return Math.floor((e+4)/5)*Math.floor((t+4)/5)*16;case Be:return Math.floor((e+5)/6)*Math.floor((t+4)/5)*16;case Ve:return Math.floor((e+5)/6)*Math.floor((t+5)/6)*16;case He:return Math.floor((e+7)/8)*Math.floor((t+4)/5)*16;case Ue:return Math.floor((e+7)/8)*Math.floor((t+5)/6)*16;case We:return Math.floor((e+7)/8)*Math.floor((t+7)/8)*16;case Ge:return Math.floor((e+9)/10)*Math.floor((t+4)/5)*16;case Ke:return Math.floor((e+9)/10)*Math.floor((t+5)/6)*16;case qe:return Math.floor((e+9)/10)*Math.floor((t+7)/8)*16;case Je:return Math.floor((e+9)/10)*Math.floor((t+9)/10)*16;case Ye:return Math.floor((e+11)/12)*Math.floor((t+9)/10)*16;case Xe:return Math.floor((e+11)/12)*Math.floor((t+11)/12)*16;case Ze:case Qe:case $e:return Math.ceil(e/4)*Math.ceil(t/4)*16;case et:case tt:return Math.ceil(e/4)*Math.ceil(t/4)*8;case nt:case rt:return Math.ceil(e/4)*Math.ceil(t/4)*16}throw Error(`Unable to determine texture byte length for ${n} format.`)}function Zf(e){switch(e){case re:case ie:return{byteLength:1,components:1};case ae:case I:case ce:return{byteLength:2,components:1};case le:case ue:return{byteLength:2,components:4};case oe:case L:case se:return{byteLength:4,components:1};case fe:case pe:return{byteLength:4,components:3}}throw Error(`Unknown texture type ${e}.`)}var Qf=class{static contain(e,t){return qf(e,t)}static cover(e,t){return Jf(e,t)}static fill(e){return Yf(e)}static getByteLength(e,t,n,r){return Xf(e,t,n,r)}};typeof __THREE_DEVTOOLS__<`u`&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent(`register`,{detail:{revision:`184`}})),typeof window<`u`&&(window.__THREE__?V(`WARNING: Multiple instances of Three.js being imported.`):window.__THREE__=`184`);var $f=c({ACESFilmicToneMapping:()=>4,AddEquation:()=>100,AddOperation:()=>2,AdditiveAnimationBlendMode:()=>ht,AdditiveBlending:()=>2,AgXToneMapping:()=>6,AlphaFormat:()=>me,AlwaysCompare:()=>519,AlwaysDepth:()=>1,AlwaysStencilFunc:()=>519,AmbientLight:()=>Bu,AnimationAction:()=>Vd,AnimationClip:()=>tu,AnimationLoader:()=>fu,AnimationMixer:()=>Ud,AnimationObjectGroup:()=>Bd,AnimationUtils:()=>Vl,ArcCurve:()=>Rs,ArrayCamera:()=>dd,ArrowHelper:()=>Uf,AttachedBindMode:()=>w,Audio:()=>bd,AudioAnalyser:()=>Ed,AudioContext:()=>nd,AudioListener:()=>yd,AudioLoader:()=>rd,AxesHelper:()=>Wf,BackSide:()=>1,BasicDepthPacking:()=>gt,BasicShadowMap:()=>0,BatchedMesh:()=>Wo,BezierInterpolant:()=>Kl,Bone:()=>eo,BooleanKeyframeTrack:()=>Jl,Box2:()=>af,Box3:()=>si,Box3Helper:()=>Rf,BoxGeometry:()=>ws,BoxHelper:()=>Lf,BufferAttribute:()=>Ai,BufferGeometry:()=>Xi,BufferGeometryLoader:()=>qu,ByteType:()=>ie,Cache:()=>iu,Camera:()=>Ou,CameraHelper:()=>Pf,CanvasTexture:()=>ys,CapsuleGeometry:()=>Ts,CatmullRomCurve3:()=>Gs,CineonToneMapping:()=>3,CircleGeometry:()=>Es,ClampToEdgeWrapping:()=>D,Clock:()=>$d,Color:()=>K,ColorKeyframeTrack:()=>Yl,ColorManagement:()=>Wn,Compatibility:()=>Kt,CompressedArrayTexture:()=>gs,CompressedCubeTexture:()=>_s,CompressedTexture:()=>hs,CompressedTextureLoader:()=>pu,ConeGeometry:()=>Os,ConstantAlphaFactor:()=>213,ConstantColorFactor:()=>211,Controls:()=>Kf,CubeCamera:()=>ud,CubeDepthTexture:()=>Ss,CubeReflectionMapping:()=>301,CubeRefractionMapping:()=>302,CubeTexture:()=>vs,CubeTextureLoader:()=>gu,CubeUVReflectionMapping:()=>306,CubicBezierCurve:()=>nc,CubicBezierCurve3:()=>rc,CubicInterpolant:()=>Ul,CullFaceBack:()=>1,CullFaceFront:()=>2,CullFaceFrontBack:()=>3,CullFaceNone:()=>0,Curve:()=>Is,CurvePath:()=>uc,CustomBlending:()=>5,CustomToneMapping:()=>5,CylinderGeometry:()=>Ds,Cylindrical:()=>tf,Data3DTexture:()=>or,DataArrayTexture:()=>ir,DataTexture:()=>to,DataTextureLoader:()=>_u,DataUtils:()=>Ei,DecrementStencilOp:()=>Dt,DecrementWrapStencilOp:()=>kt,DefaultLoadingManager:()=>su,DepthFormat:()=>_e,DepthStencilFormat:()=>ve,DepthTexture:()=>xs,DetachedBindMode:()=>T,DirectionalLight:()=>zu,DirectionalLightHelper:()=>jf,DiscreteInterpolant:()=>Gl,DodecahedronGeometry:()=>As,DoubleSide:()=>2,DstAlphaFactor:()=>206,DstColorFactor:()=>208,DynamicCopyUsage:()=>Rt,DynamicDrawUsage:()=>Mt,DynamicReadUsage:()=>Ft,EdgesGeometry:()=>Fs,EllipseCurve:()=>Ls,EqualCompare:()=>514,EqualDepth:()=>4,EqualStencilFunc:()=>514,EquirectangularReflectionMapping:()=>303,EquirectangularRefractionMapping:()=>304,Euler:()=>vr,EventDispatcher:()=>ln,ExternalTexture:()=>Cs,ExtrudeGeometry:()=>Xc,FileLoader:()=>du,Float16BufferAttribute:()=>Ri,Float32BufferAttribute:()=>q,FloatType:()=>se,Fog:()=>Gr,FogExp2:()=>Wr,FramebufferTexture:()=>ms,FrontSide:()=>0,Frustum:()=>So,FrustumArray:()=>To,GLBufferAttribute:()=>Jd,GLSL1:()=>`100`,GLSL3:()=>Bt,GreaterCompare:()=>516,GreaterDepth:()=>6,GreaterEqualCompare:()=>518,GreaterEqualDepth:()=>5,GreaterEqualStencilFunc:()=>518,GreaterStencilFunc:()=>516,GridHelper:()=>Ef,Group:()=>Ir,HTMLTexture:()=>bs,HalfFloatType:()=>ce,HemisphereLight:()=>bu,HemisphereLightHelper:()=>Tf,IcosahedronGeometry:()=>$c,ImageBitmapLoader:()=>ed,ImageLoader:()=>hu,ImageUtils:()=>Jn,IncrementStencilOp:()=>Et,IncrementWrapStencilOp:()=>Ot,InstancedBufferAttribute:()=>ao,InstancedBufferGeometry:()=>Ku,InstancedInterleavedBuffer:()=>qd,InstancedMesh:()=>mo,Int16BufferAttribute:()=>Pi,Int32BufferAttribute:()=>Ii,Int8BufferAttribute:()=>ji,IntType:()=>L,InterleavedBuffer:()=>Zi,InterleavedBufferAttribute:()=>$i,Interpolant:()=>Hl,InterpolateBezier:()=>ut,InterpolateDiscrete:()=>st,InterpolateLinear:()=>ct,InterpolateSmooth:()=>lt,InterpolationSamplingMode:()=>Gt,InterpolationSamplingType:()=>Wt,InvertStencilOp:()=>At,KeepStencilOp:()=>wt,KeyframeTrack:()=>ql,LOD:()=>ba,LatheGeometry:()=>el,Layers:()=>yr,LessCompare:()=>513,LessDepth:()=>2,LessEqualCompare:()=>515,LessEqualDepth:()=>3,LessEqualStencilFunc:()=>515,LessStencilFunc:()=>513,Light:()=>yu,LightProbe:()=>Uu,Line:()=>$o,Line3:()=>pf,LineBasicMaterial:()=>Go,LineCurve:()=>ic,LineCurve3:()=>ac,LineDashedMaterial:()=>Pl,LineLoop:()=>is,LineSegments:()=>rs,LinearFilter:()=>M,LinearInterpolant:()=>Wl,LinearMipMapLinearFilter:()=>ne,LinearMipMapNearestFilter:()=>P,LinearMipmapLinearFilter:()=>F,LinearMipmapNearestFilter:()=>N,LinearSRGBColorSpace:()=>xt,LinearToneMapping:()=>1,LinearTransfer:()=>St,Loader:()=>cu,LoaderUtils:()=>Gu,LoadingManager:()=>ou,LoopOnce:()=>it,LoopPingPong:()=>ot,LoopRepeat:()=>at,MOUSE:()=>S,Material:()=>ta,MaterialBlending:()=>6,MaterialLoader:()=>Wu,MathUtils:()=>Fn,Matrix2:()=>nf,Matrix3:()=>zn,Matrix4:()=>cr,MaxEquation:()=>104,Mesh:()=>Va,MeshBasicMaterial:()=>ka,MeshDepthMaterial:()=>jl,MeshDistanceMaterial:()=>Ml,MeshLambertMaterial:()=>Al,MeshMatcapMaterial:()=>Nl,MeshNormalMaterial:()=>kl,MeshPhongMaterial:()=>Dl,MeshPhysicalMaterial:()=>El,MeshStandardMaterial:()=>Tl,MeshToonMaterial:()=>Ol,MinEquation:()=>103,MirroredRepeatWrapping:()=>O,MixOperation:()=>1,MultiplyBlending:()=>4,MultiplyOperation:()=>0,NearestFilter:()=>k,NearestMipMapLinearFilter:()=>te,NearestMipMapNearestFilter:()=>j,NearestMipmapLinearFilter:()=>ee,NearestMipmapNearestFilter:()=>A,NeutralToneMapping:()=>7,NeverCompare:()=>512,NeverDepth:()=>0,NeverStencilFunc:()=>512,NoBlending:()=>0,NoColorSpace:()=>``,NoNormalPacking:()=>``,NoToneMapping:()=>0,NormalAnimationBlendMode:()=>mt,NormalBlending:()=>1,NormalGAPacking:()=>`ga`,NormalRGPacking:()=>`rg`,NotEqualCompare:()=>517,NotEqualDepth:()=>7,NotEqualStencilFunc:()=>517,NumberKeyframeTrack:()=>Xl,Object3D:()=>Fr,ObjectLoader:()=>Yu,ObjectSpaceNormalMap:()=>1,OctahedronGeometry:()=>tl,OneFactor:()=>201,OneMinusConstantAlphaFactor:()=>214,OneMinusConstantColorFactor:()=>212,OneMinusDstAlphaFactor:()=>207,OneMinusDstColorFactor:()=>209,OneMinusSrcAlphaFactor:()=>205,OneMinusSrcColorFactor:()=>203,OrthographicCamera:()=>Lu,PCFShadowMap:()=>1,PCFSoftShadowMap:()=>2,PMREMGenerator:()=>Cp,Path:()=>dc,PerspectiveCamera:()=>Mu,Plane:()=>vo,PlaneGeometry:()=>nl,PlaneHelper:()=>zf,PointLight:()=>Iu,PointLightHelper:()=>xf,Points:()=>us,PointsMaterial:()=>as,PolarGridHelper:()=>Df,PolyhedronGeometry:()=>ks,PositionalAudio:()=>Td,PropertyBinding:()=>zd,PropertyMixer:()=>Dd,QuadraticBezierCurve:()=>oc,QuadraticBezierCurve3:()=>sc,Quaternion:()=>In,QuaternionKeyframeTrack:()=>Ql,QuaternionLinearInterpolant:()=>Zl,R11_EAC_Format:()=>Ne,RED_GREEN_RGTC2_Format:()=>nt,RED_RGTC1_Format:()=>et,REVISION:()=>`184`,RG11_EAC_Format:()=>Fe,RGBADepthPacking:()=>_t,RGBAFormat:()=>ge,RGBAIntegerFormat:()=>R,RGBA_ASTC_10x10_Format:()=>Je,RGBA_ASTC_10x5_Format:()=>Ge,RGBA_ASTC_10x6_Format:()=>Ke,RGBA_ASTC_10x8_Format:()=>qe,RGBA_ASTC_12x10_Format:()=>Ye,RGBA_ASTC_12x12_Format:()=>Xe,RGBA_ASTC_4x4_Format:()=>Le,RGBA_ASTC_5x4_Format:()=>Re,RGBA_ASTC_5x5_Format:()=>ze,RGBA_ASTC_6x5_Format:()=>Be,RGBA_ASTC_6x6_Format:()=>Ve,RGBA_ASTC_8x5_Format:()=>He,RGBA_ASTC_8x6_Format:()=>Ue,RGBA_ASTC_8x8_Format:()=>We,RGBA_BPTC_Format:()=>Ze,RGBA_ETC2_EAC_Format:()=>Me,RGBA_PVRTC_2BPPV1_Format:()=>B,RGBA_PVRTC_4BPPV1_Format:()=>ke,RGBA_S3TC_DXT1_Format:()=>Te,RGBA_S3TC_DXT3_Format:()=>Ee,RGBA_S3TC_DXT5_Format:()=>z,RGBDepthPacking:()=>vt,RGBFormat:()=>he,RGBIntegerFormat:()=>Ce,RGB_BPTC_SIGNED_Format:()=>Qe,RGB_BPTC_UNSIGNED_Format:()=>$e,RGB_ETC1_Format:()=>Ae,RGB_ETC2_Format:()=>je,RGB_PVRTC_2BPPV1_Format:()=>Oe,RGB_PVRTC_4BPPV1_Format:()=>De,RGB_S3TC_DXT1_Format:()=>we,RGDepthPacking:()=>yt,RGFormat:()=>xe,RGIntegerFormat:()=>Se,RawShaderMaterial:()=>wl,Ray:()=>Oa,Raycaster:()=>Xd,RectAreaLight:()=>Vu,RedFormat:()=>ye,RedIntegerFormat:()=>be,ReinhardToneMapping:()=>2,RenderTarget:()=>nr,RenderTarget3D:()=>Wd,RepeatWrapping:()=>E,ReplaceStencilOp:()=>Tt,ReverseSubtractEquation:()=>102,RingGeometry:()=>rl,SIGNED_R11_EAC_Format:()=>Pe,SIGNED_RED_GREEN_RGTC2_Format:()=>rt,SIGNED_RED_RGTC1_Format:()=>tt,SIGNED_RG11_EAC_Format:()=>Ie,SRGBColorSpace:()=>bt,SRGBTransfer:()=>Ct,Scene:()=>Kr,ShaderChunk:()=>np,ShaderLib:()=>rp,ShaderMaterial:()=>Cl,ShadowMaterial:()=>ml,Shape:()=>fc,ShapeGeometry:()=>il,ShapePath:()=>Gf,ShapeUtils:()=>qc,ShortType:()=>I,Skeleton:()=>io,SkeletonHelper:()=>yf,SkinnedMesh:()=>$a,Source:()=>Xn,Sphere:()=>Hi,SphereGeometry:()=>ol,Spherical:()=>ef,SphericalHarmonics3:()=>Hu,SplineCurve:()=>cc,SpotLight:()=>Pu,SpotLightHelper:()=>hf,Sprite:()=>ga,SpriteMaterial:()=>na,SrcAlphaFactor:()=>204,SrcAlphaSaturateFactor:()=>210,SrcColorFactor:()=>202,StaticCopyUsage:()=>Lt,StaticDrawUsage:()=>jt,StaticReadUsage:()=>Pt,StereoCamera:()=>sd,StreamCopyUsage:()=>zt,StreamDrawUsage:()=>Nt,StreamReadUsage:()=>It,StringKeyframeTrack:()=>$l,SubtractEquation:()=>101,SubtractiveBlending:()=>3,TOUCH:()=>C,TangentSpaceNormalMap:()=>0,TetrahedronGeometry:()=>sl,Texture:()=>er,TextureLoader:()=>vu,TextureUtils:()=>Qf,Timer:()=>fd,TimestampQuery:()=>Ut,TorusGeometry:()=>cl,TorusKnotGeometry:()=>ll,Triangle:()=>oi,TriangleFanDrawMode:()=>2,TriangleStripDrawMode:()=>1,TrianglesDrawMode:()=>0,TubeGeometry:()=>ul,UVMapping:()=>300,Uint16BufferAttribute:()=>Fi,Uint32BufferAttribute:()=>Li,Uint8BufferAttribute:()=>Mi,Uint8ClampedBufferAttribute:()=>Ni,Uniform:()=>J,UniformsGroup:()=>Kd,UniformsLib:()=>Y,UniformsUtils:()=>bl,UnsignedByteType:()=>re,UnsignedInt101111Type:()=>pe,UnsignedInt248Type:()=>de,UnsignedInt5999Type:()=>fe,UnsignedIntType:()=>oe,UnsignedShort4444Type:()=>le,UnsignedShort5551Type:()=>ue,UnsignedShortType:()=>ae,VSMShadowMap:()=>3,Vector2:()=>W,Vector3:()=>G,Vector4:()=>tr,VectorKeyframeTrack:()=>eu,VideoFrameTexture:()=>ps,VideoTexture:()=>fs,WebGL3DRenderTarget:()=>sr,WebGLArrayRenderTarget:()=>ar,WebGLCoordinateSystem:()=>Vt,WebGLCubeRenderTarget:()=>Mp,WebGLRenderTarget:()=>rr,WebGLRenderer:()=>gg,WebGLUtils:()=>ig,WebGPUCoordinateSystem:()=>Ht,WebXRController:()=>Rr,WireframeGeometry:()=>dl,WrapAroundEnding:()=>pt,ZeroCurvatureEnding:()=>dt,ZeroFactor:()=>200,ZeroSlopeEnding:()=>ft,ZeroStencilOp:()=>0,createCanvasElement:()=>Qt,error:()=>H,getConsoleFunction:()=>nn,log:()=>rn,setConsoleFunction:()=>tn,warn:()=>V,warnOnce:()=>on});function ep(){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 tp(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 ); } vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) { return normalize( ( vec4( dir, 0.0 ) * matrix ).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; #ifdef FLIP_SIDED transformedTangent = - transformedTangent; #endif #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 = inverseTransformDirection( normal, viewMatrix ); #ifdef ENVMAP_MODE_REFLECTION vec3 reflectVec = reflect( cameraToFrag, worldNormal ); #else vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio ); #endif #else vec3 reflectVec = vReflect; #endif #ifdef ENVMAP_TYPE_CUBE vec4 envColor = textureCube( envMap, 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 = inverseTransformDirection( 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 = inverseTransformDirection( 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 = inverseTransformDirection( 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 = inverseTransformDirection( normal, viewMatrix ); vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe ); return irradiance; } vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) { vec3 irradiance = ambientLightColor; return irradiance; } float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) { 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 = inverseTransformDirection( 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 #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED ) tbn[0] *= faceDirection; tbn[1] *= faceDirection; #endif #endif #ifdef USE_CLEARCOAT_NORMALMAP #ifdef USE_TANGENT mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal ); #else mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv ); #endif #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED ) tbn2[0] *= faceDirection; tbn2[1] *= faceDirection; #endif #endif vec3 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 ); #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 = inverseTransformDirection( 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 = inverseTransformDirection( 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 }`},Y={common:{diffuse:{value:new K(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new zn},alphaMap:{value:null},alphaMapTransform:{value:new zn},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new zn}},envmap:{envMap:{value:null},envMapRotation:{value:new zn},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new zn}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new zn}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new zn},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new zn},normalScale:{value:new W(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new zn},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new zn}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new zn}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new zn}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new K(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 G},probesMax:{value:new G},probesResolution:{value:new G}},points:{diffuse:{value:new K(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new zn},alphaTest:{value:0},uvTransform:{value:new zn}},sprite:{diffuse:{value:new K(16777215)},opacity:{value:1},center:{value:new W(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new zn},alphaMap:{value:null},alphaMapTransform:{value:new zn},alphaTest:{value:0}}},rp={basic:{uniforms:gl([Y.common,Y.specularmap,Y.envmap,Y.aomap,Y.lightmap,Y.fog]),vertexShader:np.meshbasic_vert,fragmentShader:np.meshbasic_frag},lambert:{uniforms:gl([Y.common,Y.specularmap,Y.envmap,Y.aomap,Y.lightmap,Y.emissivemap,Y.bumpmap,Y.normalmap,Y.displacementmap,Y.fog,Y.lights,{emissive:{value:new K(0)},envMapIntensity:{value:1}}]),vertexShader:np.meshlambert_vert,fragmentShader:np.meshlambert_frag},phong:{uniforms:gl([Y.common,Y.specularmap,Y.envmap,Y.aomap,Y.lightmap,Y.emissivemap,Y.bumpmap,Y.normalmap,Y.displacementmap,Y.fog,Y.lights,{emissive:{value:new K(0)},specular:{value:new K(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:np.meshphong_vert,fragmentShader:np.meshphong_frag},standard:{uniforms:gl([Y.common,Y.envmap,Y.aomap,Y.lightmap,Y.emissivemap,Y.bumpmap,Y.normalmap,Y.displacementmap,Y.roughnessmap,Y.metalnessmap,Y.fog,Y.lights,{emissive:{value:new K(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:np.meshphysical_vert,fragmentShader:np.meshphysical_frag},toon:{uniforms:gl([Y.common,Y.aomap,Y.lightmap,Y.emissivemap,Y.bumpmap,Y.normalmap,Y.displacementmap,Y.gradientmap,Y.fog,Y.lights,{emissive:{value:new K(0)}}]),vertexShader:np.meshtoon_vert,fragmentShader:np.meshtoon_frag},matcap:{uniforms:gl([Y.common,Y.bumpmap,Y.normalmap,Y.displacementmap,Y.fog,{matcap:{value:null}}]),vertexShader:np.meshmatcap_vert,fragmentShader:np.meshmatcap_frag},points:{uniforms:gl([Y.points,Y.fog]),vertexShader:np.points_vert,fragmentShader:np.points_frag},dashed:{uniforms:gl([Y.common,Y.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:np.linedashed_vert,fragmentShader:np.linedashed_frag},depth:{uniforms:gl([Y.common,Y.displacementmap]),vertexShader:np.depth_vert,fragmentShader:np.depth_frag},normal:{uniforms:gl([Y.common,Y.bumpmap,Y.normalmap,Y.displacementmap,{opacity:{value:1}}]),vertexShader:np.meshnormal_vert,fragmentShader:np.meshnormal_frag},sprite:{uniforms:gl([Y.sprite,Y.fog]),vertexShader:np.sprite_vert,fragmentShader:np.sprite_frag},background:{uniforms:{uvTransform:{value:new zn},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:np.background_vert,fragmentShader:np.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new zn}},vertexShader:np.backgroundCube_vert,fragmentShader:np.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:np.cube_vert,fragmentShader:np.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:np.equirect_vert,fragmentShader:np.equirect_frag},distance:{uniforms:gl([Y.common,Y.displacementmap,{referencePosition:{value:new G},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:np.distance_vert,fragmentShader:np.distance_frag},shadow:{uniforms:gl([Y.lights,Y.fog,{color:{value:new K(0)},opacity:{value:1}}]),vertexShader:np.shadow_vert,fragmentShader:np.shadow_frag}};rp.physical={uniforms:gl([rp.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new zn},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new zn},clearcoatNormalScale:{value:new W(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new zn},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new zn},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new zn},sheen:{value:0},sheenColor:{value:new K(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new zn},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new zn},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new zn},transmissionSamplerSize:{value:new W},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new zn},attenuationDistance:{value:0},attenuationColor:{value:new K(0)},specularColor:{value:new K(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new zn},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new zn},anisotropyVector:{value:new W},anisotropyMap:{value:null},anisotropyMapTransform:{value:new zn}}]),vertexShader:np.meshphysical_vert,fragmentShader:np.meshphysical_frag};var ip={r:0,b:0,g:0},ap=new cr,op=new zn;op.set(-1,0,0,0,1,0,0,0,1);function sp(e,t,n,r,i,a){let o=new K(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 Va(new ws(1,1,1),new Cl({name:`BackgroundCubeMaterial`,uniforms:hl(rp.backgroundCube.uniforms),vertexShader:rp.backgroundCube.vertexShader,fragmentShader:rp.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(ap.makeRotationFromEuler(n.backgroundRotation)).transpose(),i.isCubeTexture&&i.isRenderTargetTexture===!1&&l.material.uniforms.backgroundRotation.value.premultiply(op),l.material.toneMapped=Wn.getTransfer(i.colorSpace)!==Ct,(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 Va(new nl(2,2),new Cl({name:`BackgroundMaterial`,uniforms:hl(rp.background.uniforms),vertexShader:rp.background.vertexShader,fragmentShader:rp.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=Wn.getTransfer(i.colorSpace)!==Ct,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(ip,yl(e)),n.buffers.color.setClear(ip.r,ip.g,ip.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 cp(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&&(V(`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&&V(`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 dp(e){let t=this,n=null,r=0,i=!1,a=!1,o=new vo,s=new zn,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=Ap(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=kp(),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=Ap()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=kp());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;Ep(t,0,0,3*s,2*s),n.setRenderTarget(t),n.render(a,gp)}_applyPMREM(e){let t=this._renderer,n=t.autoClear;t.autoClear=!1;let r=this._lodMeshes.length;for(let t=1;td-fp?n-d+fp:0),m=4*(this._cubeSize-f);s.envMap.value=e.texture,s.roughness.value=u,s.mipInt.value=d-t,Ep(i,p,m,3*f,2*f),r.setRenderTarget(i),r.render(o,gp),s.envMap.value=i.texture,s.roughness.value=0,s.mipInt.value=d-n,Ep(e,p,m,3*f,2*f),r.setRenderTarget(e),r.render(o,gp)}_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`&&H(`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*mp-1),p=i/f,m=isFinite(i)?1+Math.floor(3*p):mp;m>mp&&V(`sigmaRadians, ${i}, is too large and will clip, as it requested ${m} samples when the maximum is set to ${mp}`);let h=[],g=0;for(let e=0;e_-fp?r-_+fp:0),4*(this._cubeSize-v),3*v,2*v),s.setRenderTarget(t),s.render(l,gp)}};function wp(e){let t=[],n=[],r=[],i=e,a=e-fp+1+pp.length;for(let o=0;oe-fp?s=pp[o-e+fp-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 Xi;h.setAttribute(`position`,new Ai(f,3)),h.setAttribute(`uv`,new Ai(p,2)),h.setAttribute(`faceIndex`,new Ai(m,1)),r.push(new Va(h,null)),i>fp&&i--}return{lodMeshes:r,sizeLods:t,sigmas:n}}function Tp(e,t,n){let r=new rr(e,t,n);return r.texture.mapping=306,r.texture.name=`PMREM.cubeUv`,r.scissorTest=!0,r}function Ep(e,t,n,r,i){e.viewport.set(t,n,r,i),e.scissor.set(t,n,r,i)}function Dp(e,t,n){return new Cl({name:`PMREMGGXConvolution`,defines:{GGX_SAMPLES:hp,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:jp(),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 Op(e,t,n){let r=new Float32Array(mp),i=new G(0,1,0);return new Cl({name:`SphericalGaussianBlur`,defines:{n:mp,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:jp(),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 kp(){return new Cl({name:`EquirectangularToCubeUV`,uniforms:{envMap:{value:null}},vertexShader:jp(),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 Ap(){return new Cl({name:`CubemapToCubeUV`,uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:jp(),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 jp(){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 Mp=class extends rr{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;let n={width:e,height:e,depth:1},r=[n,n,n,n,n,n];this.texture=new vs(r),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 ws(5,5,5),i=new Cl({name:`CubemapFromEquirect`,uniforms:hl(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:1,blending:0});i.uniforms.tEquirect.value=t;let a=new Va(r,i),o=t.minFilter;return t.minFilter===1008&&(t.minFilter=M),new ud(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 Np(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 Mp(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 Cp(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 Cp(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 Pp(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&&on(`WebGLRenderer: `+e+` extension not supported.`),t}}}function Fp(e,t,n,r){let i={},a=new WeakMap;function o(e){let s=e.target;s.index!==null&&t.remove(s.index);for(let e in 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?Li: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 ir(h,p,m,u);g.type=se,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}),l=new Va(s,c),u=new Lu(-1,1,1,-1,0,1),d=null,f=null,p=!1,m,h=null,g=[],_=!1;this.setSize=function(e,t){a.setSize(e,t),o.setSize(e,t);for(let n=0;n0&&g[0].isRenderPass===!0;let t=a.width,n=a.height;for(let e=0;e0)return e;let i=t*n,a=qp[i];if(a===void 0&&(a=new Float32Array(i),qp[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 $p(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 Ym(e,t,n){let r=e.createShader(t);return e.shaderSource(r,n),e.compileShader(r),r}var Xm=37297,Zm=0;function Qm(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 $m=new zn;function eh(e){Wn._getMatrix($m,Wn.workingColorSpace,e);let t=`mat3( ${$m.elements.map(e=>e.toFixed(4))} )`;switch(Wn.getTransfer(e)){case St:return[t,`LinearTransferOETF`];case Ct:return[t,`sRGBTransferOETF`];default:return V(`WebGLProgram: Unsupported color space: `,e),[t,`LinearTransferOETF`]}}function th(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+` `+Qm(e.getShaderSource(t),r)}else return i}function nh(e,t){let n=eh(t);return[`vec4 ${e}( vec4 value ) {`,` return ${n[1]}( vec4( value.rgb * ${n[0]}, value.a ) );`,`}`].join(` `)}var rh={1:`Linear`,2:`Reinhard`,3:`Cineon`,4:`ACESFilmic`,6:`AgX`,7:`Neutral`,5:`Custom`};function ih(e,t){let n=rh[t];return n===void 0?(V(`WebGLProgram: Unsupported toneMapping:`,t),`vec3 `+e+`( vec3 color ) { return LinearToneMapping( color ); }`):`vec3 `+e+`( vec3 color ) { return `+n+`ToneMapping( color ); }`}var ah=new G;function oh(){return Wn.getLuminanceCoefficients(ah),[`float luminance( const in vec3 rgb ) {`,` const vec3 weights = vec3( ${ah.x.toFixed(4)}, ${ah.y.toFixed(4)}, ${ah.z.toFixed(4)} );`,` return dot( weights, rgb );`,`}`].join(` `)}function sh(e){return[e.extensionClipCullDistance?`#extension GL_ANGLE_clip_cull_distance : require`:``,e.extensionMultiDraw?`#extension GL_ANGLE_multi_draw : require`:``].filter(uh).join(` `)}function ch(e){let t=[];for(let n in e){let r=e[n];r!==!1&&t.push(`#define `+n+` `+r)}return t.join(` `)}function lh(e,t){let n={},r=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES);for(let i=0;i/gm;function mh(e){return e.replace(ph,gh)}var hh=new Map;function gh(e,t){let n=np[t];if(n===void 0){let e=hh.get(t);if(e!==void 0)n=np[e],V(`WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.`,t,e);else throw Error(`Can not resolve #include <`+t+`>`)}return mh(n)}var _h=/#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 vh(e){return e.replace(_h,yh)}function yh(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(uh).join(` `),_.length>0&&(_+=` `)):(g=[bh(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(uh).join(` `),_=[bh(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?``:np.tonemapping_pars_fragment,n.toneMapping===0?``:ih(`toneMapping`,n.toneMapping),n.dithering?`#define DITHERING`:``,n.opaque?`#define OPAQUE`:``,np.colorspace_pars_fragment,nh(`linearToOutputTexel`,n.outputColorSpace),oh(),n.useDepthPacking?`#define DEPTH_PACKING `+n.depthPacking:``,` `].filter(uh).join(` `)),o=mh(o),o=dh(o,n),o=fh(o,n),s=mh(s),s=dh(s,n),s=fh(s,n),o=vh(o),s=vh(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=Ym(i,i.VERTEX_SHADER,y),S=Ym(i,i.FRAGMENT_SHADER,b);i.attachShader(h,x),i.attachShader(h,S),n.index0AttributeName===void 0?n.morphTargets===!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=th(i,x,`vertex`),n=th(i,S,`fragment`);H(`THREE.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):V(`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 Jm(i,h),T=lh(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,Xm)),E},this.destroy=function(){r.releaseStatesOfProgram(this),i.deleteProgram(h),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=Zm++,this.cacheKey=t,this.usedTimes=1,this.program=h,this.vertexShader=x,this.fragmentShader=S,this}var jh=0,Mh=class{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){let t=e.vertexShader,n=e.fragmentShader,r=this._getShaderStage(t),i=this._getShaderStage(n),a=this._getShaderCacheForMaterial(e);return a.has(r)===!1&&(a.add(r),r.usedTimes++),a.has(i)===!1&&(a.add(i),i.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}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){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 Nh(e),t.set(e,n)),n}},Nh=class{constructor(e){this.id=jh++,this.code=e,this.usedTimes=0}};function Ph(e){return e===1030||e===37490||e===36285}function Fh(e,t,n,r,i,a){let o=new yr,s=new Mh,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&&V(`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=rp[C];D=e.vertexShader,O=e.fragmentShader}else D=i.vertexShader,O=i.fragmentShader,s.update(i),k=s.getVertexShaderID(i),A=s.getFragmentShaderID(i);let j=e.getRenderTarget(),ee=e.state.buffers.depth.getReversed(),te=h.isInstancedMesh===!0,M=h.isBatchedMesh===!0,N=!!i.map,P=!!i.matcap,F=!!x,ne=!!i.aoMap,re=!!i.lightMap,ie=!!i.bumpMap,I=!!i.normalMap,ae=!!i.displacementMap,L=!!i.emissiveMap,oe=!!i.metalnessMap,se=!!i.roughnessMap,ce=i.anisotropy>0,le=i.clearcoat>0,ue=i.dispersion>0,de=i.iridescence>0,fe=i.sheen>0,pe=i.transmission>0,me=ce&&!!i.anisotropyMap,he=le&&!!i.clearcoatMap,ge=le&&!!i.clearcoatNormalMap,_e=le&&!!i.clearcoatRoughnessMap,ve=de&&!!i.iridescenceMap,ye=de&&!!i.iridescenceThicknessMap,be=fe&&!!i.sheenColorMap,xe=fe&&!!i.sheenRoughnessMap,Se=!!i.specularMap,Ce=!!i.specularColorMap,R=!!i.specularIntensityMap,we=pe&&!!i.transmissionMap,Te=pe&&!!i.thicknessMap,Ee=!!i.gradientMap,z=!!i.alphaMap,De=i.alphaTest>0,Oe=!!i.alphaHash,ke=!!i.extensions,B=0;i.toneMapped&&(j===null||j.isXRRenderTarget===!0)&&(B=e.toneMapping);let Ae={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:M,batchingColor:M&&h._colorsTexture!==null,instancing:te,instancingColor:te&&h.instanceColor!==null,instancingMorph:te&&h.morphTexture!==null,outputColorSpace:j===null?e.outputColorSpace:j.isXRRenderTarget===!0?j.texture.colorSpace:Wn.workingColorSpace,alphaToCoverage:!!i.alphaToCoverage,map:N,matcap:P,envMap:F,envMapMode:F&&x.mapping,envMapCubeUVHeight:S,aoMap:ne,lightMap:re,bumpMap:ie,normalMap:I,displacementMap:ae,emissiveMap:L,normalMapObjectSpace:I&&i.normalMapType===1,normalMapTangentSpace:I&&i.normalMapType===0,packedNormalMap:I&&i.normalMapType===0&&Ph(i.normalMap.format),metalnessMap:oe,roughnessMap:se,anisotropy:ce,anisotropyMap:me,clearcoat:le,clearcoatMap:he,clearcoatNormalMap:ge,clearcoatRoughnessMap:_e,dispersion:ue,iridescence:de,iridescenceMap:ve,iridescenceThicknessMap:ye,sheen:fe,sheenColorMap:be,sheenRoughnessMap:xe,specularMap:Se,specularColorMap:Ce,specularIntensityMap:R,transmission:pe,transmissionMap:we,thicknessMap:Te,gradientMap:Ee,opaque:i.transparent===!1&&i.blending===1&&i.alphaToCoverage===!1,alphaMap:z,alphaTest:De,alphaHash:Oe,combine:i.combine,mapUv:N&&m(i.map.channel),aoMapUv:ne&&m(i.aoMap.channel),lightMapUv:re&&m(i.lightMap.channel),bumpMapUv:ie&&m(i.bumpMap.channel),normalMapUv:I&&m(i.normalMap.channel),displacementMapUv:ae&&m(i.displacementMap.channel),emissiveMapUv:L&&m(i.emissiveMap.channel),metalnessMapUv:oe&&m(i.metalnessMap.channel),roughnessMapUv:se&&m(i.roughnessMap.channel),anisotropyMapUv:me&&m(i.anisotropyMap.channel),clearcoatMapUv:he&&m(i.clearcoatMap.channel),clearcoatNormalMapUv:ge&&m(i.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:_e&&m(i.clearcoatRoughnessMap.channel),iridescenceMapUv:ve&&m(i.iridescenceMap.channel),iridescenceThicknessMapUv:ye&&m(i.iridescenceThicknessMap.channel),sheenColorMapUv:be&&m(i.sheenColorMap.channel),sheenRoughnessMapUv:xe&&m(i.sheenRoughnessMap.channel),specularMapUv:Se&&m(i.specularMap.channel),specularColorMapUv:Ce&&m(i.specularColorMap.channel),specularIntensityMapUv:R&&m(i.specularIntensityMap.channel),transmissionMapUv:we&&m(i.transmissionMap.channel),thicknessMapUv:Te&&m(i.thicknessMap.channel),alphaMapUv:z&&m(i.alphaMap.channel),vertexTangents:!!v.attributes.tangent&&(I||ce),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&&(N||z),fog:!!_,useFog:i.fog===!0,fogExp2:!!_&&_.isFogExp2,flatShading:i.wireframe===!1&&(i.flatShading===!0||v.attributes.normal===void 0&&I===!1&&(i.isMeshLambertMaterial||i.isMeshPhongMaterial||i.isMeshStandardMaterial||i.isMeshPhysicalMaterial)),sizeAttenuation:i.sizeAttenuation===!0,logarithmicDepthBuffer:d,reversedDepthBuffer:ee,skinning:h.isSkinnedMesh===!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:B,decodeVideoTexture:N&&i.map.isVideoTexture===!0&&Wn.getTransfer(i.map.colorSpace)===`srgb`,decodeVideoTextureEmissive:L&&i.emissiveMap.isVideoTexture===!0&&Wn.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:ke&&i.extensions.clipCullDistance===!0&&n.has(`WEBGL_clip_cull_distance`),extensionMultiDraw:(ke&&i.extensions.multiDraw===!0||M)&&n.has(`WEBGL_multi_draw`),rendererExtensionParallelShaderCompile:n.has(`KHR_parallel_shader_compile`),customProgramCacheKey:i.customProgramCacheKey()};return Ae.vertexUv1s=c.has(1),Ae.vertexUv2s=c.has(2),Ae.vertexUv3s=c.has(3),c.clear(),Ae}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),e.push(o.mask)}function y(e){let t=p[e.type],n;if(t){let e=rp[t];n=bl.clone(e.uniforms)}else n=e.uniforms;return n}function b(t,n){let r=u.get(n);return r===void 0?(r=new Ah(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 Ih(){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 Lh(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 Rh(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 zh(){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){n.length>1&&n.sort(e||Lh),r.length>1&&r.sort(t||Rh),i.length>1&&i.sort(t||Rh)}function d(){for(let n=t,r=e.length;n=r.length?(i=new zh,r.push(i)):i=r[n],i}function n(){e=new WeakMap}return{get:t,dispose:n}}function Vh(){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 G,color:new K};break;case`SpotLight`:n={position:new G,direction:new G,color:new K,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case`PointLight`:n={position:new G,color:new K,distance:0,decay:0};break;case`HemisphereLight`:n={direction:new G,skyColor:new K,groundColor:new K};break;case`RectAreaLight`:n={color:new K,position:new G,halfWidth:new G,halfHeight:new G};break}return e[t.id]=n,n}}}function Hh(){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 W};break;case`SpotLight`:n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new W};break;case`PointLight`:n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new W,shadowCameraNear:1,shadowCameraFar:1e3};break}return e[t.id]=n,n}}}var Uh=0;function Wh(e,t){return(t.castShadow?2:0)-(e.castShadow?2:0)+ +!!t.map-!!e.map}function Gh(e){let t=new Vh,n=Hh(),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 G);let i=new G,a=new cr,o=new cr;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(Wh);for(let e=0,y=i.length;e0&&(e.has(`OES_texture_float_linear`)===!0?(r.rectAreaLTC1=Y.LTC_FLOAT_1,r.rectAreaLTC2=Y.LTC_FLOAT_2):(r.rectAreaLTC1=Y.LTC_HALF_1,r.rectAreaLTC2=Y.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=Uh++)}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 Kh(e),i.push(a)):a=i[r],a}function r(){t=new WeakMap}return{get:n,dispose:r}}var Jh=`void main() { gl_Position = vec4( position, 1.0 ); }`,Yh=`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 ); }`,Xh=[new G(1,0,0),new G(-1,0,0),new G(0,1,0),new G(0,-1,0),new G(0,0,1),new G(0,0,-1)],Zh=[new G(0,-1,0),new G(0,-1,0),new G(0,0,1),new G(0,0,-1),new G(0,-1,0),new G(0,-1,0)],Qh=new cr,$h=new G,eg=new G;function tg(e,t,n){let r=new So,i=new W,a=new W,o=new tr,s=new jl,c=new Ml,l={},u=n.maxTextureSize,d={0:1,1:0,2:2},f=new Cl({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new W},radius:{value:4}},vertexShader:Jh,fragmentShader:Yh}),p=f.clone();p.defines.HORIZONTAL_PASS=1;let m=new Xi;m.setAttribute(`position`,new Ai(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let h=new Va(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&&(V(`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){V(`WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.`);continue}d.map=new rr(i.x,i.y,{format:xe,type:ce,minFilter:M,magFilter:M,generateMipmaps:!1}),d.map.texture.name=l.name+`.shadowMap`,d.map.depthTexture=new xs(i.x,i.y,se),d.map.depthTexture.name=l.name+`.shadowMapDepth`,d.map.depthTexture.format=_e,d.map.depthTexture.compareFunction=null,d.map.depthTexture.minFilter=k,d.map.depthTexture.magFilter=k}else l.isPointLight?(d.map=new Mp(i.x),d.map.depthTexture=new Ss(i.x,oe)):(d.map=new rr(i.x,i.y),d.map.depthTexture=new xs(i.x,i.y,oe)),d.map.depthTexture.name=l.name+`.shadowMap`,d.map.depthTexture.format=_e,this.type===1?(d.map.depthTexture.compareFunction=h?518:515,d.map.depthTexture.minFilter=M,d.map.depthTexture.magFilter=M):(d.map.depthTexture.compareFunction=null,d.map.depthTexture.minFilter=k,d.map.depthTexture.magFilter=k);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):(M=parseFloat(/^WebGL (\d)/.exec(N)[1]),te=M>=1);let P=null,F={},ne=e.getParameter(e.SCISSOR_BOX),re=e.getParameter(e.VIEWPORT),ie=new tr().fromArray(ne),I=new tr().fromArray(re);function ae(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 W,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):Zt(`canvas`)}function g(e,t,n){let r=1,i=Ae(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),V(`WebGLRenderer: Texture has been resized from (`+i.width+`x`+i.height+`) to (`+n+`x`+a+`).`),o}else return`data`in e&&V(`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];V(`WebGLRenderer: Attempt to use non-existing WebGL internal format '`+n+`'`)}let c;a&&(c=t.get(`EXT_texture_norm16`),c||V(`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?St:Wn.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,V(`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),te(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&&j(e),Object.keys(i).length===0&&p.delete(n)}r.remove(e)}function j(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 te(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&&V(`WebGLTextures: Trying to use `+e+` texture units while this GPU supports only `+i.maxTextures),P+=1,e}function ae(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 L(t,i){let a=r.get(t);if(t.isVideoTexture&&ke(t),t.isRenderTargetTexture===!1&&t.isExternalTexture!==!0&&t.version>0&&a.__version!==t.version){let e=t.image;if(e===null)V(`WebGLRenderer: Texture marked for update but no image data found.`);else if(e.complete===!1)V(`WebGLRenderer: Texture marked for update but image is incomplete`);else{ge(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 oe(t,i){let a=r.get(t);if(t.isRenderTargetTexture===!1&&t.version>0&&a.__version!==t.version){ge(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 se(t,i){let a=r.get(t);if(t.isRenderTargetTexture===!1&&t.version>0&&a.__version!==t.version){ge(a,t,i);return}n.bindTexture(e.TEXTURE_3D,a.__webglTexture,e.TEXTURE0+i)}function ce(t,i){let a=r.get(t);if(t.isCubeDepthTexture!==!0&&t.version>0&&a.__version!==t.version){_e(a,t,i);return}n.bindTexture(e.TEXTURE_CUBE_MAP,a.__webglTexture,e.TEXTURE0+i)}let le={[E]:e.REPEAT,[D]:e.CLAMP_TO_EDGE,[O]:e.MIRRORED_REPEAT},ue={[k]:e.NEAREST,[A]:e.NEAREST_MIPMAP_NEAREST,[ee]:e.NEAREST_MIPMAP_LINEAR,[M]:e.LINEAR,[N]:e.LINEAR_MIPMAP_NEAREST,[F]:e.LINEAR_MIPMAP_LINEAR},de={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 fe(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)&&V(`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,le[a.wrapS]),e.texParameteri(n,e.TEXTURE_WRAP_T,le[a.wrapT]),(n===e.TEXTURE_3D||n===e.TEXTURE_2D_ARRAY)&&e.texParameteri(n,e.TEXTURE_WRAP_R,le[a.wrapR]),e.texParameteri(n,e.TEXTURE_MAG_FILTER,ue[a.magFilter]),e.texParameteri(n,e.TEXTURE_MIN_FILTER,ue[a.minFilter]),a.compareFunction&&(e.texParameteri(n,e.TEXTURE_COMPARE_MODE,e.COMPARE_REF_TO_TEXTURE),e.texParameteri(n,e.TEXTURE_COMPARE_FUNC,de[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 pe(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=ae(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&&j(n)),t.__cacheKey=s,t.__webglTexture=a[s].texture}return r}function me(e,t,n){return Math.floor(Math.floor(e/n)/t)}function he(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=Xf(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 V(`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=Xf(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}let r=e.RGBA,i=e.RGBA,a=e.UNSIGNED_BYTE;e.texElementImage2D(e.TEXTURE_2D,0,r,i,a,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=Ae(y[0]);n.texStorage2D(e.TEXTURE_2D,E,m,t.width,t.height)}for(let t=0,i=y.length;t0&&D++;let t=Ae(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),Oe(i)?s.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,c,l,h.__webglTexture,0,De(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 be(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;Oe(n)?s.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,De(n),o,n.width,n.height):r?e.renderbufferStorageMultisample(e.RENDERBUFFER,De(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++)xe(i.__webglFramebuffer[e],t,e);else{let e=t.texture.mipmaps;e&&e.length>0?xe(i.__webglFramebuffer[0],t,0):xe(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(),be(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(),be(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 Ce(t,n,i){let a=r.get(t);n!==void 0&&ye(a.__webglFramebuffer,t,t.texture,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,0),i!==void 0&&Se(t)}function R(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&&Oe(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(Oe(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 ke(e){let t=o.render.frame;u.get(e)!==t&&(u.set(e,t),e.update())}function B(e,t){let n=e.colorSpace,r=e.format,i=e.type;return e.isCompressedTexture===!0||e.isVideoTexture===!0||n!==`srgb-linear`&&n!==``&&(Wn.getTransfer(n)===`srgb`?(r!==1023||i!==1009)&&V(`WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType.`):H(`WebGLTextures: Unsupported texture color space:`,n)),t}function Ae(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=I,this.resetTextureUnits=ne,this.getTextureUnits=re,this.setTextureUnits=ie,this.setTexture2D=L,this.setTexture2DArray=oe,this.setTexture3D=se,this.setTextureCube=ce,this.rebindTextures=Ce,this.setupRenderTarget=R,this.updateRenderTargetMipmap=we,this.updateMultisampleRenderTarget=z,this.setupDepthRenderbuffer=Se,this.setupFrameBufferTexture=ye,this.useMultisampledRTT=Oe,this.isReversedDepthBuffer=function(){return n.buffers.depth.getReversed()}}function ig(e,t){function n(n,r=``){let i,a=Wn.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 ag=` void main() { gl_Position = vec4( position, 1.0 ); }`,og=` 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; } }`,sg=class{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){let n=new Cs(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 Cl({vertexShader:ag,fragmentShader:og,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new Va(new nl(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}},cg=class extends ln{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 sg,g={},_=t.getContextAttributes(),v=null,y=null,b=[],x=[],S=new W,C=null,w=new Mu;w.viewport=new tr;let T=new Mu;T.viewport=new tr;let E=[w,T],D=new dd,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 Rr,b[e]=t),t.getTargetRaySpace()},this.getControllerGrip=function(e){let t=b[e];return t===void 0&&(t=new Rr,b[e]=t),t.getGripSpace()},this.getHand=function(e){let t=b[e];return t===void 0&&(t=new Rr,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`,ee);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 te=new G,M=new G;function N(e,t,n){te.setFromMatrixPosition(t.matrixWorld),M.setFromMatrixPosition(n.matrixWorld);let r=te.distanceTo(M),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 P(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;P(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(lg.makeRotationFromEuler(o)).transpose(),a.isCubeTexture&&a.isRenderTargetTexture===!1&&e.envMapRotation.value.premultiply(ug),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 fg(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&&(m(e),o=u(e),i[e.id]=o,e.addEventListener(`dispose`,g));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 h(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?V(`WebGLRenderer: Texture samplers can not be part of an uniforms group.`):ArrayBuffer.isView(e)?(t.boundary=16,t.storage=e.byteLength):V(`WebGLRenderer: Unsupported uniform value type.`,e),t}function g(t){let n=t.target;n.removeEventListener(`dispose`,g);let r=o.indexOf(n.__bindingPointIndex);o.splice(r,1),e.deleteBuffer(i[n.id]),delete i[n.id],delete a[n.id]}function _(){for(let t in i)e.deleteBuffer(i[t]);o=[],i={},a={}}return{bind:c,update:l,dispose:_}}var pg=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]),mg=null;function hg(){return mg===null&&(mg=new to(pg,16,16,xe,ce),mg.name=`DFG_LUT`,mg.minFilter=M,mg.magFilter=M,mg.wrapS=D,mg.wrapT=D,mg.generateMipmaps=!1,mg.needsUpdate=!0),mg}var gg=class{constructor(e={}){let{canvas:t=Qt(),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=re}=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([R,Se,be]),g=new Set([re,oe,ae,de,le,ue]),_=new Uint32Array(4),v=new Int32Array(4),y=new G,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;this._outputColorSpace=bt;let O=0,k=0,A=null,j=-1,ee=null,te=new tr,M=new tr,N=null,P=new K(0),ne=0,ie=t.width,I=t.height,L=1,se=null,fe=null,pe=new tr(0,0,ie,I),me=new tr(0,0,ie,I),he=!1,ge=new So,_e=!1,ve=!1,ye=new cr,xe=new G,Ce=new tr,we={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},Te=!1;function Ee(){return A===null?L:1}let z=n;function De(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 r184`),t.addEventListener(`webglcontextlost`,Qe,!1),t.addEventListener(`webglcontextrestored`,$e,!1),t.addEventListener(`webglcontextcreationerror`,et,!1),z===null){let t=`webgl2`;if(z=De(t,e),z===null)throw De(t)?Error(`Error creating WebGL context with your selected attributes.`):Error(`Error creating WebGL context.`)}}catch(e){throw H(`WebGLRenderer: `+e.message),e}let Oe,ke,B,Ae,je,Me,Ne,Pe,Fe,Ie,Le,Re,ze,Be,Ve,He,Ue,We,Ge,Ke,qe,Je,Ye;function Xe(){Oe=new Pp(z),Oe.init(),qe=new ig(z,Oe),ke=new up(z,Oe,e,qe),B=new ng(z,Oe),ke.reversedDepthBuffer&&d&&B.buffers.depth.setReversed(!0),Ae=new Lp(z),je=new Ih,Me=new rg(z,Oe,B,je,ke,qe,Ae),Ne=new Np(T),Pe=new tp(z),Je=new cp(z,Pe),Fe=new Fp(z,Pe,Ae,Je),Ie=new zp(z,Fe,Pe,Je,Ae),We=new Rp(z,ke,Me),Ve=new dp(je),Le=new Fh(T,Ne,Oe,ke,Je,Ve),Re=new dg(T,je),ze=new Bh,Be=new qh(Oe),Ue=new sp(T,Ne,B,Ie,p,s),He=new tg(T,Ie,ke),Ye=new fg(z,Ae,ke,B),Ge=new lp(z,Oe,Ae),Ke=new Ip(z,Oe,Ae),Ae.programs=Le.programs,T.capabilities=ke,T.extensions=Oe,T.properties=je,T.renderLists=ze,T.shadowMap=He,T.state=B,T.info=Ae}Xe(),m!==1009&&(w=new Vp(m,t.width,t.height,r,i));let Ze=new cg(T,z);this.xr=Ze,this.getContext=function(){return z},this.getContextAttributes=function(){return z.getContextAttributes()},this.forceContextLoss=function(){let e=Oe.get(`WEBGL_lose_context`);e&&e.loseContext()},this.forceContextRestore=function(){let e=Oe.get(`WEBGL_lose_context`);e&&e.restoreContext()},this.getPixelRatio=function(){return L},this.setPixelRatio=function(e){e!==void 0&&(L=e,this.setSize(ie,I,!1))},this.getSize=function(e){return e.set(ie,I)},this.setSize=function(e,n,r=!0){if(Ze.isPresenting){V(`WebGLRenderer: Can't change size while VR device is presenting.`);return}ie=e,I=n,t.width=Math.floor(e*L),t.height=Math.floor(n*L),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(ie*L,I*L).floor()},this.setDrawingBufferSize=function(e,n,r){ie=e,I=n,L=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){H(`THREE.WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.`);return}if(e){for(let t=0;t{function n(){if(r.forEach(function(e){je.get(e).currentProgram.isReady()&&r.delete(e)}),r.size===0){t(e);return}setTimeout(n,10)}Oe.get(`KHR_parallel_shader_compile`)===null?setTimeout(n,10):n()})};let at=null;function ot(e){at&&at(e)}function st(){lt.stop()}function ct(){lt.start()}let lt=new ep;lt.setAnimationLoop(ot),typeof self<`u`&<.setContext(self),this.setAnimationLoop=function(e){at=e,Ze.setAnimationLoop(e),e===null?lt.stop():lt.start()},Ze.addEventListener(`sessionstart`,st),Ze.addEventListener(`sessionend`,ct),this.render=function(e,t){if(t!==void 0&&t.isCamera!==!0){H(`WebGLRenderer.render: camera is not an instance of THREE.Camera.`);return}if(E===!0)return;D!==null&&D.renderStart(e,t);let n=Ze.enabled===!0&&Ze.isPresenting===!0,r=w!==null&&(A===null||n)&&w.begin(T,A);if(e.matrixWorldAutoUpdate===!0&&e.updateMatrixWorld(),t.parent===null&&t.matrixWorldAutoUpdate===!0&&t.updateMatrixWorld(),Ze.enabled===!0&&Ze.isPresenting===!0&&(w===null||w.isCompositing()===!1)&&(Ze.cameraAutoUpdate===!0&&Ze.updateCamera(t),t=Ze.getCamera()),e.isScene===!0&&e.onBeforeRender(T,e,t,A),x=Be.get(e,C.length),x.init(t),x.state.textureUnits=Me.getTextureUnits(),C.push(x),ye.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),ge.setFromProjectionMatrix(ye,Vt,t.reversedDepth),ve=this.localClippingEnabled,_e=Ve.init(this.clippingPlanes,ve),b=ze.get(e,S.length),b.init(),S.push(b),Ze.enabled===!0&&Ze.isPresenting===!0){let e=T.xr.getDepthSensingMesh();e!==null&&ut(e,t,-1/0,T.sortObjects)}ut(e,t,0,T.sortObjects),b.finish(),T.sortObjects===!0&&b.sort(se,fe),Te=Ze.enabled===!1||Ze.isPresenting===!1||Ze.hasDepthSensing()===!1,Te&&Ue.addToRenderList(b,e),this.info.render.frame++,_e===!0&&Ve.beginShadows();let i=x.state.shadowsArray;if(He.render(i,e,t),_e===!0&&Ve.endShadows(),this.info.autoReset===!0&&this.info.reset(),(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&&ft(n,r,e,t),Te&&Ue.render(e),dt(b,e,t)}A!==null&&k===0&&(Me.updateMultisampleRenderTarget(A),Me.updateRenderTargetMipmap(A)),r&&w.end(T),e.isScene===!0&&e.onAfterRender(T,e,t),Je.resetDefaultState(),j=-1,ee=null,C.pop(),C.length>0?(x=C[C.length-1],Me.setTextureUnits(x.state.textureUnits),_e===!0&&Ve.setGlobalState(T.clippingPlanes,x.state.camera)):x=null,S.pop(),b=S.length>0?S[S.length-1]:null,D!==null&&D.renderEnd()};function ut(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||ge.intersectsSprite(e)){r&&Ce.setFromMatrixPosition(e.matrixWorld).applyMatrix4(ye);let t=Ie.update(e),i=e.material;i.visible&&b.push(e,t,i,n,Ce.z,null)}}else if((e.isMesh||e.isLine||e.isPoints)&&(!e.frustumCulled||ge.intersectsObject(e))){let t=Ie.update(e),i=e.material;if(r&&(e.boundingSphere===void 0?(t.boundingSphere===null&&t.computeBoundingSphere(),Ce.copy(t.boundingSphere.center)):(e.boundingSphere===null&&e.computeBoundingSphere(),Ce.copy(e.boundingSphere.center)),Ce.applyMatrix4(e.matrixWorld).applyMatrix4(ye)),Array.isArray(i)){let r=t.groups;for(let a=0,o=r.length;a0&&pt(i,t,n),a.length>0&&pt(a,t,n),o.length>0&&pt(o,t,n),B.buffers.depth.setTest(!0),B.buffers.depth.setMask(!0),B.buffers.color.setMask(!0),B.setPolygonOffset(!1)}function ft(e,t,n,r){if((n.isScene===!0?n.overrideMaterial:null)!==null)return;if(x.state.transmissionRenderTarget[r.id]===void 0){let e=Oe.has(`EXT_color_buffer_half_float`)||Oe.has(`EXT_color_buffer_float`);x.state.transmissionRenderTarget[r.id]=new rr(1,1,{generateMipmaps:!0,type:e?ce:re,minFilter:F,samples:Math.max(4,ke.samples),stencilBuffer:i,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Wn.workingColorSpace})}let a=x.state.transmissionRenderTarget[r.id],o=r.viewport||te;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(P),ne=T.getClearAlpha(),ne<1&&T.setClearColor(16777215,.5),T.clear(),Te&&Ue.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),_e===!0&&Ve.setGlobalState(T.clippingPlanes,r),pt(e,n,r),Me.updateMultisampleRenderTarget(a),Me.updateRenderTargetMipmap(a),Oe.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 gt(e){if(e.uniformsList===null){let t=e.currentProgram.getUniforms();e.uniformsList=Jm.seqWithValue(t.seq,e.uniforms)}return e.uniformsList}function _t(e,t){let n=je.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 vt(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&&(A===null||A.isXRRenderTarget===!0)&&(h=T.toneMapping);let g=n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color,_=g===void 0?0:g.length,v=je.get(r),y=x.state.lights;if(_e===!0&&(ve===!0||e!==ee)){let t=e===ee&&r.id===j;Ve.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!==Ve.numPlanes||v.numIntersection!==Ve.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=ht(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(B.useProgram(S.program)&&(C=!0,w=!0,E=!0),r.id!==j&&(j=r.id,w=!0),v.needsLights){let e=vt(x.state.lightProbeGridArray,i);v.lightProbeGrid!==e&&(v.lightProbeGrid=e,w=!0)}if(C||ee!==e){B.buffers.depth.getReversed()&&e.reversedDepth!==!0&&(e._reversedDepth=!0,e.updateProjectionMatrix()),O.setValue(z,`projectionMatrix`,e.projectionMatrix),O.setValue(z,`viewMatrix`,e.matrixWorldInverse);let t=O.map.cameraPosition;t!==void 0&&t.setValue(z,xe.setFromMatrixPosition(e.matrixWorld)),ke.logarithmicDepthBuffer&&O.setValue(z,`logDepthBufFC`,2/(Math.log(e.far+1)/Math.LN2)),(r.isMeshPhongMaterial||r.isMeshToonMaterial||r.isMeshLambertMaterial||r.isMeshBasicMaterial||r.isMeshStandardMaterial||r.isShaderMaterial)&&O.setValue(z,`isOrthographic`,e.isOrthographicCamera===!0),ee!==e&&(ee=e,w=!0,E=!0)}if(v.needsLights&&(y.state.directionalShadowMap.length>0&&O.setValue(z,`directionalShadowMap`,y.state.directionalShadowMap,Me),y.state.spotShadowMap.length>0&&O.setValue(z,`spotShadowMap`,y.state.spotShadowMap,Me),y.state.pointShadowMap.length>0&&O.setValue(z,`pointShadowMap`,y.state.pointShadowMap,Me)),i.isSkinnedMesh){O.setOptional(z,i,`bindMatrix`),O.setOptional(z,i,`bindMatrixInverse`);let e=i.skeleton;e&&(e.boneTexture===null&&e.computeBoneTexture(),O.setValue(z,`boneTexture`,e.boneTexture,Me))}i.isBatchedMesh&&(O.setOptional(z,i,`batchingTexture`),O.setValue(z,`batchingTexture`,i._matricesTexture,Me),O.setOptional(z,i,`batchingIdTexture`),O.setValue(z,`batchingIdTexture`,i._indirectTexture,Me),O.setOptional(z,i,`batchingColorTexture`),i._colorsTexture!==null&&O.setValue(z,`batchingColorTexture`,i._colorsTexture,Me));let te=n.morphAttributes;if((te.position!==void 0||te.normal!==void 0||te.color!==void 0)&&We.update(i,n,S),(w||v.receiveShadow!==i.receiveShadow)&&(v.receiveShadow=i.receiveShadow,O.setValue(z,`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=hg()),w){if(O.setValue(z,`toneMappingExposure`,T.toneMappingExposure),v.needsLights&&xt(k,E),a&&r.fog===!0&&Re.refreshFogUniforms(k,a),Re.refreshMaterialUniforms(k,r,L,I,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)}Jm.upload(z,gt(v),k,Me)}if(r.isShaderMaterial&&r.uniformsNeedUpdate===!0&&(Jm.upload(z,gt(v),k,Me),r.uniformsNeedUpdate=!1),r.isSpriteMaterial&&O.setValue(z,`center`,i.center),O.setValue(z,`modelViewMatrix`,i.modelViewMatrix),O.setValue(z,`normalMatrix`,i.normalMatrix),O.setValue(z,`modelMatrix`,i.matrixWorld),r.uniformsGroups!==void 0){let e=r.uniformsGroups;for(let t=0,n=e.length;t0&&Me.useMultisampledRTT(e)===!1?je.get(e).__webglMultisampledFramebuffer:Array.isArray(c)?c[n]:c,te.copy(e.viewport),M.copy(e.scissor),N=e.scissorTest}else te.copy(pe).multiplyScalar(L).floor(),M.copy(me).multiplyScalar(L).floor(),N=he;if(n!==0&&(r=Ct),B.bindFramebuffer(z.FRAMEBUFFER,r)&&B.drawBuffers(e,r),B.viewport(te),B.scissor(M),B.setScissorTest(N),i){let r=je.get(e.texture);z.framebufferTexture2D(z.FRAMEBUFFER,z.COLOR_ATTACHMENT0,z.TEXTURE_CUBE_MAP_POSITIVE_X+t,r.__webglTexture,n)}else if(a){let r=t;for(let t=0;t1&&z.readBuffer(z.COLOR_ATTACHMENT0+s),!ke.textureFormatReadable(c)){H(`WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.`);return}if(!ke.textureTypeReadable(l)){H(`WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.`);return}t>=0&&t<=e.width-r&&n>=0&&n<=e.height-i&&z.readPixels(t,n,r,i,qe.convert(c),qe.convert(l),a)}finally{let e=A===null?null:je.get(A).__webglFramebuffer;B.bindFramebuffer(z.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=je.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){B.bindFramebuffer(z.FRAMEBUFFER,c);let o=e.textures[s],l=o.format,u=o.type;if(e.textures.length>1&&z.readBuffer(z.COLOR_ATTACHMENT0+s),!ke.textureFormatReadable(l))throw Error(`THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.`);if(!ke.textureTypeReadable(u))throw Error(`THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.`);let d=z.createBuffer();z.bindBuffer(z.PIXEL_PACK_BUFFER,d),z.bufferData(z.PIXEL_PACK_BUFFER,a.byteLength,z.STREAM_READ),z.readPixels(t,n,r,i,qe.convert(l),qe.convert(u),0);let f=A===null?null:je.get(A).__webglFramebuffer;B.bindFramebuffer(z.FRAMEBUFFER,f);let p=z.fenceSync(z.SYNC_GPU_COMMANDS_COMPLETE,0);return z.flush(),await sn(z,p,4),z.bindBuffer(z.PIXEL_PACK_BUFFER,d),z.getBufferSubData(z.PIXEL_PACK_BUFFER,0,a),z.deleteBuffer(d),z.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;Me.setTexture2D(e,0),z.copyTexSubImage2D(z.TEXTURE_2D,n,0,0,o,s,i,a),B.unbindTexture()};let wt=z.createFramebuffer(),Tt=z.createFramebuffer();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=qe.convert(t.format),_=qe.convert(t.type),v;t.isData3DTexture?(Me.setTexture3D(t,0),v=z.TEXTURE_3D):t.isDataArrayTexture||t.isCompressedArrayTexture?(Me.setTexture2DArray(t,0),v=z.TEXTURE_2D_ARRAY):(Me.setTexture2D(t,0),v=z.TEXTURE_2D),B.activeTexture(z.TEXTURE0),B.pixelStorei(z.UNPACK_FLIP_Y_WEBGL,t.flipY),B.pixelStorei(z.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),B.pixelStorei(z.UNPACK_ALIGNMENT,t.unpackAlignment);let y=B.getParameter(z.UNPACK_ROW_LENGTH),b=B.getParameter(z.UNPACK_IMAGE_HEIGHT),x=B.getParameter(z.UNPACK_SKIP_PIXELS),S=B.getParameter(z.UNPACK_SKIP_ROWS),C=B.getParameter(z.UNPACK_SKIP_IMAGES);B.pixelStorei(z.UNPACK_ROW_LENGTH,h.width),B.pixelStorei(z.UNPACK_IMAGE_HEIGHT,h.height),B.pixelStorei(z.UNPACK_SKIP_PIXELS,l),B.pixelStorei(z.UNPACK_SKIP_ROWS,u),B.pixelStorei(z.UNPACK_SKIP_IMAGES,d);let w=e.isDataArrayTexture||e.isData3DTexture,T=t.isDataArrayTexture||t.isData3DTexture;if(e.isDepthTexture){let n=je.get(e),r=je.get(t),h=je.get(n.__renderTarget),g=je.get(r.__renderTarget);B.bindFramebuffer(z.READ_FRAMEBUFFER,h.__webglFramebuffer),B.bindFramebuffer(z.DRAW_FRAMEBUFFER,g.__webglFramebuffer);for(let n=0;n{var t=p();function n(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var r=typeof Object.is==`function`?Object.is:n,i=t.useState,a=t.useEffect,o=t.useLayoutEffect,s=t.useDebugValue;function c(e,t){var n=t(),r=i({inst:{value:n,getSnapshot:t}}),c=r[0].inst,u=r[1];return o(function(){c.value=n,c.getSnapshot=t,l(c)&&u({inst:c})},[e,n,t]),a(function(){return l(c)&&u({inst:c}),e(function(){l(c)&&u({inst:c})})},[e]),s(n),n}function l(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!r(e,n)}catch{return!0}}function u(e,t){return t()}var d=typeof window>`u`||window.document===void 0||window.document.createElement===void 0?u:c;e.useSyncExternalStore=t.useSyncExternalStore===void 0?d:t.useSyncExternalStore})),vg=s(((e,t)=>{t.exports=_g()})),yg=s((e=>{var t=p(),n=vg();function r(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var i=typeof Object.is==`function`?Object.is:r,a=n.useSyncExternalStore,o=t.useRef,s=t.useEffect,c=t.useMemo,l=t.useDebugValue;e.useSyncExternalStoreWithSelector=function(e,t,n,r,u){var d=o(null);if(d.current===null){var f={hasValue:!1,value:null};d.current=f}else f=d.current;d=c(function(){function e(e){if(!a){if(a=!0,o=e,e=r(e),u!==void 0&&f.hasValue){var t=f.value;if(u(t,e))return s=t}return s=e}if(t=s,i(o,e))return t;var n=r(e);return u!==void 0&&u(t,n)?(o=e,t):(o=e,s=n)}var a=!1,o,s,c=n===void 0?null:n;return[function(){return e(t())},c===null?void 0:function(){return e(c())}]},[t,n,r,u]);var p=a(e,d[0],d[1]);return s(function(){f.hasValue=!0,f.value=p},[p]),l(p),p}})),bg=u(s(((e,t)=>{t.exports=yg()}))(),1),xg=e=>{let t,n=new Set,r=(e,r)=>{let i=typeof e==`function`?e(t):e;if(!Object.is(i,t)){let e=t;t=r??(typeof i!=`object`||!i)?i:Object.assign({},t,i),n.forEach(n=>n(t,e))}},i=()=>t,a={setState:r,getState:i,getInitialState:()=>o,subscribe:e=>(n.add(e),()=>n.delete(e))},o=t=e(r,i,a);return a},Sg=(e=>e?xg(e):xg),{useSyncExternalStoreWithSelector:Cg}=bg.default,wg=e=>e;function Tg(e,t=wg,n){let r=Cg(e.subscribe,e.getState,e.getInitialState,t,n);return b.useDebugValue(r),r}var Eg=(e,t)=>{let n=Sg(e),r=(e,r=t)=>Tg(n,e,r);return Object.assign(r,n),r},Dg=((e,t)=>e?Eg(e,t):Eg),Og=e=>typeof e==`object`&&typeof e.then==`function`,kg=[];function Ag(e,t,n=(e,t)=>e===t){if(e===t)return!0;if(!e||!t)return!1;let r=e.length;if(t.length!==r)return!1;for(let i=0;i0&&(e.timeout&&clearTimeout(e.timeout),e.timeout=setTimeout(e.remove,r.lifespan)),e.response;if(!n)throw e.promise}let i={keys:t,equal:r.equal,remove:()=>{let e=kg.indexOf(i);e!==-1&&kg.splice(e,1)},promise:(Og(e)?e:e(...t)).then(e=>{i.response=e,r.lifespan&&r.lifespan>0&&(i.timeout=setTimeout(i.remove,r.lifespan))}).catch(e=>i.error=e)};if(kg.push(i),!n)throw i.promise}var Mg=(e,t,n)=>jg(e,t,!1,n),Ng=(e,t,n)=>void jg(e,t,!0,n),Pg=e=>{if(e===void 0||e.length===0)kg.splice(0,kg.length);else{let t=kg.find(t=>Ag(e,t.keys,t.equal));t&&t.remove()}},Fg=s((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),Ig=s(((e,t)=>{t.exports=Fg()})),Lg=u(h()),X=Ig();typeof window<`u`&&(window.document?.createElement||window.navigator?.product===`ReactNative`)?b.useLayoutEffect:b.useEffect;function Rg(e,t,n){if(!e)return;if(n(e)===!0)return e;let r=t?e.return:e.child;for(;r;){let e=Rg(r,t,n);if(e)return e;r=t?null:r.sibling}}function zg(e){try{return Object.defineProperties(e,{_currentRenderer:{get(){return null},set(){}},_currentRenderer2:{get(){return null},set(){}}})}catch{return e}}var Bg=zg(b.createContext(null)),Vg=class extends b.Component{render(){return b.createElement(Bg.Provider,{value:this._reactInternals},this.props.children)}};function Hg(){let e=b.useContext(Bg);if(e===null)throw Error(`its-fine: useFiber must be called within a !`);let t=b.useId();return b.useMemo(()=>{for(let n of[e,e?.alternate]){if(!n)continue;let e=Rg(n,!1,e=>{let n=e.memoizedState;for(;n;){if(n.memoizedState===t)return!0;n=n.next}});if(e)return e}},[e,t])}var Ug=Symbol.for(`react.context`),Wg=e=>typeof e==`object`&&!!e&&`$$typeof`in e&&e.$$typeof===Ug;function Gg(){let e=Hg(),[t]=b.useState(()=>new Map);t.clear();let n=e;for(;n;){let e=n.type;Wg(e)&&e!==Bg&&!t.has(e)&&t.set(e,b.use(zg(e))),n=n.return}return t}function Kg(){let e=Gg();return b.useMemo(()=>Array.from(e.keys()).reduce((t,n)=>r=>b.createElement(t,null,b.createElement(n.Provider,{...r,value:e.get(n)})),e=>b.createElement(Vg,{...e})),[e])}function qg(e){let t=e.root;for(;t.getState().previousRoot;)t=t.getState().previousRoot;return t}var Jg=e=>e&&e.isOrthographicCamera,Yg=e=>e&&e.hasOwnProperty(`current`),Xg=e=>e!=null&&(typeof e==`string`||typeof e==`number`||e.isColor),Zg=((e,t)=>typeof window<`u`&&((e=window.document)?.createElement||(t=window.navigator)?.product===`ReactNative`))()?b.useLayoutEffect:b.useEffect;function Qg(e){let t=b.useRef(e);return Zg(()=>void(t.current=e),[e]),t}function $g(){let e=Hg(),t=Kg();return b.useMemo(()=>({children:n})=>(0,X.jsx)(Rg(e,!0,e=>e.type===b.StrictMode)?b.StrictMode:b.Fragment,{children:(0,X.jsx)(t,{children:n})}),[e,t])}function e_({set:e}){return Zg(()=>(e(new Promise(()=>null)),()=>e(!1)),[e]),null}var t_=(e=>(e=class extends b.Component{constructor(...e){super(...e),this.state={error:!1}}componentDidCatch(e){this.props.set(e)}render(){return this.state.error?null:this.props.children}},e.getDerivedStateFromError=()=>({error:!0}),e))();function n_(e){let t=typeof window<`u`?window.devicePixelRatio??2:1;return Array.isArray(e)?Math.min(Math.max(e[0],t),e[1]):e}function r_(e){return e.__r3f?.root.getState()}var i_={obj:e=>e===Object(e)&&!i_.arr(e)&&typeof e!=`function`,fun:e=>typeof e==`function`,str:e=>typeof e==`string`,num:e=>typeof e==`number`,boo:e=>typeof e==`boolean`,und:e=>e===void 0,nul:e=>e===null,arr:e=>Array.isArray(e),equ(e,t,{arrays:n=`shallow`,objects:r=`reference`,strict:i=!0}={}){if(typeof e!=typeof t||!!e!=!!t)return!1;if(i_.str(e)||i_.num(e)||i_.boo(e))return e===t;let a=i_.obj(e);if(a&&r===`reference`)return e===t;let o=i_.arr(e);if(o&&n===`reference`)return e===t;if((o||a)&&e===t)return!0;let s;for(s in e)if(!(s in t))return!1;if(a&&n===`shallow`&&r===`shallow`){for(s in i?t:e)if(!i_.equ(e[s],t[s],{strict:i,objects:`reference`}))return!1}else for(s in i?t:e)if(e[s]!==t[s])return!1;if(i_.und(s)){if(o&&e.length===0&&t.length===0||a&&Object.keys(e).length===0&&Object.keys(t).length===0)return!0;if(e!==t)return!1}return!0}};function a_(e){let t={nodes:{},materials:{},meshes:{}};return e&&e.traverse(e=>{e.name&&(t.nodes[e.name]=e),e.material&&!t.materials[e.material.name]&&(t.materials[e.material.name]=e.material),e.isMesh&&!t.meshes[e.name]&&(t.meshes[e.name]=e)}),t}function o_(e){e.type!==`Scene`&&(e.dispose==null||e.dispose());for(let t in e){let n=e[t];n?.type!==`Scene`&&(n==null||n.dispose==null||n.dispose())}}var s_=[`children`,`key`,`ref`];function c_(e){let t={};for(let n in e)s_.includes(n)||(t[n]=e[n]);return t}function l_(e,t,n,r){let i=e,a=i?.__r3f;return a||(a={root:t,type:n,parent:null,children:[],props:c_(r),object:i,eventCount:0,handlers:{},isHidden:!1},i&&(i.__r3f=a)),a}function u_(e,t){if(!t.includes(`-`)||t in e)return{root:e,key:t,target:e[t]};let n=e,r=t.split(`-`);for(let i of r){if(typeof n!=`object`||!n){if(n!==void 0){let e=r.slice(r.indexOf(i)).join(`-`);return{root:n,key:e,target:void 0}}return{root:e,key:t,target:void 0}}t=i,e=n,n=n[t]}return{root:e,key:t,target:n}}var d_=/-\d+$/;function f_(e,t){if(i_.str(t.props.attach)){if(d_.test(t.props.attach)){let n=t.props.attach.replace(d_,``),{root:r,key:i}=u_(e.object,n);Array.isArray(r[i])||(r[i]=[])}let{root:n,key:r}=u_(e.object,t.props.attach);t.previousAttach=n[r],n[r]=t.object}else i_.fun(t.props.attach)&&(t.previousAttach=t.props.attach(e.object,t.object))}function p_(e,t){if(i_.str(t.props.attach)){let{root:n,key:r}=u_(e.object,t.props.attach),i=t.previousAttach;i===void 0?delete n[r]:n[r]=i}else t.previousAttach==null||t.previousAttach(e.object,t.object);delete t.previousAttach}var m_=[...s_,`args`,`dispose`,`attach`,`object`,`onUpdate`,`dispose`],h_=new Map;function g_(e){let t=h_.get(e.constructor);try{t||(t=new e.constructor,h_.set(e.constructor,t))}catch{}return t}function __(e,t){let n={};for(let r in t)if(!m_.includes(r)&&!i_.equ(t[r],e.props[r])){n[r]=t[r];for(let e in t)e.startsWith(`${r}-`)&&(n[e]=t[e])}for(let r in e.props){if(m_.includes(r)||t.hasOwnProperty(r))continue;let{root:i,key:a}=u_(e.object,r);if(i.constructor&&i.constructor.length===0){let e=g_(i);i_.und(e)||(n[a]=e[a])}else n[a]=0}return n}var v_=[`map`,`emissiveMap`,`sheenColorMap`,`specularColorMap`,`envMap`],y_=/^on(Pointer|Click|DoubleClick|ContextMenu|Wheel)/;function b_(e,t){var n;let r=e.__r3f,i=r&&qg(r).getState(),a=r?.eventCount;for(let n in t){let a=t[n];if(m_.includes(n))continue;if(r&&y_.test(n)){typeof a==`function`?r.handlers[n]=a:delete r.handlers[n],r.eventCount=Object.keys(r.handlers).length;continue}if(a===void 0)continue;let{root:s,key:c,target:l}=u_(e,n);if(l===void 0&&(typeof s!=`object`||!s))throw Error(`R3F: Cannot set "${n}". Ensure it is an object before setting "${c}".`);if(l instanceof yr&&a instanceof yr)l.mask=a.mask;else if(l instanceof K&&Xg(a))l.set(a);else if(typeof l==`object`&&l&&typeof l.set==`function`&&typeof l.copy==`function`&&a!=null&&a.constructor&&l.constructor===a.constructor)l.copy(a);else if(typeof l==`object`&&l&&typeof l.set==`function`&&Array.isArray(a))typeof l.fromArray==`function`?l.fromArray(a):l.set(...a);else if(typeof l==`object`&&l&&typeof l.set==`function`&&typeof a==`number`)typeof l.setScalar==`function`?l.setScalar(a):l.set(a);else if(s instanceof Cl&&c===`uniforms`&&i_.obj(a)){i_.obj(s.uniforms)||(s.uniforms={});let e=s.uniforms,t=a;for(let n in t){let r=t[n],i=e[n];i?Object.assign(i,r):e[n]={...r}}}else{var o;s[c]=a,i&&!i.linear&&v_.includes(c)&&(o=s[c])!=null&&o.isTexture&&s[c].format===1023&&s[c].type===1009&&(s[c].colorSpace=bt)}}if(r!=null&&r.parent&&i!=null&&i.internal&&(n=r.object)!=null&&n.isObject3D&&a!==r.eventCount){let e=r.object,t=i.internal.interaction.indexOf(e);t>-1&&i.internal.interaction.splice(t,1),r.eventCount&&e.raycast!==null&&i.internal.interaction.push(e)}return r&&r.props.attach===void 0&&(r.object.isBufferGeometry?r.props.attach=`geometry`:r.object.isMaterial&&(r.props.attach=`material`)),r&&x_(r),e}function x_(e){var t;if(!e.parent)return;e.props.onUpdate==null||e.props.onUpdate(e.object);let n=(t=e.root)==null||t.getState==null?void 0:t.getState();n&&n.internal.frames===0&&n.invalidate()}function S_(e,t){e.manual||(Jg(e)?(e.left=t.width/-2,e.right=t.width/2,e.top=t.height/2,e.bottom=t.height/-2):e.aspect=t.width/t.height,e.updateProjectionMatrix())}var C_=e=>e?.isObject3D;function w_(e){return(e.eventObject||e.object).uuid+`/`+e.index+e.instanceId}function T_(e,t,n,r){let i=n.get(t);i&&(n.delete(t),n.size===0&&(e.delete(r),i.target.releasePointerCapture(r)))}function E_(e,t,n){let{internal:r}=e.getState();for(let e=0;e{if(e.eventObject===t||e.object===t){r.hovered.delete(i);let a={...e,eventObject:e.eventObject===t?n:e.eventObject,object:e.object===t?n:e.object};r.hovered.set(w_(a),a)}}),r.capturedMap.forEach(e=>{let r=e.get(t);r&&(e.delete(t),e.set(n,r))})}function D_(e,t){let{internal:n}=e.getState();n.interaction=n.interaction.filter(e=>e!==t),n.initialHits=n.initialHits.filter(e=>e!==t),n.hovered.forEach((e,r)=>{(e.eventObject===t||e.object===t)&&n.hovered.delete(r)}),n.capturedMap.forEach((e,r)=>{T_(n.capturedMap,t,e,r)})}function O_(e){function t(t){let{internal:n}=e.getState(),r=t.offsetX-n.initialClick[0],i=t.offsetY-n.initialClick[1];return Math.round(Math.sqrt(r*r+i*i))}function n(e){return e.filter(e=>[`Move`,`Over`,`Enter`,`Out`,`Leave`].some(t=>e.__r3f?.handlers[`onPointer`+t]))}function r(t,n){let r=e.getState(),i=new Set,a=[],o=n?n(r.internal.interaction):r.internal.interaction;for(let e=0;e{let n=r_(e.object),r=r_(t.object);return!n||!r?e.distance-t.distance:r.events.priority-n.events.priority||e.distance-t.distance}).filter(e=>{let t=w_(e);return i.has(t)?!1:(i.add(t),!0)});r.events.filter&&(c=r.events.filter(c,r));for(let e of c){let t=e.object;for(;t;){var l;(l=t.__r3f)!=null&&l.eventCount&&a.push({...e,eventObject:t}),t=t.parent}}if(`pointerId`in t&&r.internal.capturedMap.has(t.pointerId))for(let e of r.internal.capturedMap.get(t.pointerId).values())i.has(w_(e.intersection))||a.push(e.intersection);return a}function i(e,t,n,r){if(e.length){let i={stopped:!1};for(let o of e){let s=r_(o.object);if(s||o.object.traverseAncestors(e=>{let t=r_(e);if(t)return s=t,!1}),s){let{raycaster:c,pointer:l,camera:u,internal:d}=s,f=new G(l.x,l.y,0).unproject(u),p=e=>d.capturedMap.get(e)?.has(o.eventObject)??!1,m=e=>{let n={intersection:o,target:t.target};d.capturedMap.has(e)?d.capturedMap.get(e).set(o.eventObject,n):d.capturedMap.set(e,new Map([[o.eventObject,n]])),t.target.setPointerCapture(e)},h=e=>{let t=d.capturedMap.get(e);t&&T_(d.capturedMap,o.eventObject,t,e)},g={};for(let e in t){let n=t[e];typeof n!=`function`&&(g[e]=n)}let _={...o,...g,pointer:l,intersections:e,stopped:i.stopped,delta:n,unprojectedPoint:f,ray:c.ray,camera:u,stopPropagation(){let n=`pointerId`in t&&d.capturedMap.get(t.pointerId);(!n||n.has(o.eventObject))&&(_.stopped=i.stopped=!0,d.hovered.size&&Array.from(d.hovered.values()).find(e=>e.eventObject===o.eventObject)&&a([...e.slice(0,e.indexOf(o)),o]))},target:{hasPointerCapture:p,setPointerCapture:m,releasePointerCapture:h},currentTarget:{hasPointerCapture:p,setPointerCapture:m,releasePointerCapture:h},nativeEvent:t};if(r(_),i.stopped===!0)break}}}return e}function a(t){let{internal:n}=e.getState();for(let e of n.hovered.values())if(!t.length||!t.find(t=>t.object===e.object&&t.index===e.index&&t.instanceId===e.instanceId)){let r=e.eventObject.__r3f;if(n.hovered.delete(w_(e)),r!=null&&r.eventCount){let n=r.handlers,i={...e,intersections:t};n.onPointerOut==null||n.onPointerOut(i),n.onPointerLeave==null||n.onPointerLeave(i)}}}function o(e,t){for(let n=0;na([]);case`onLostPointerCapture`:return t=>{let{internal:n}=e.getState();`pointerId`in t&&n.capturedMap.has(t.pointerId)&&requestAnimationFrame(()=>{n.capturedMap.has(t.pointerId)&&(n.capturedMap.delete(t.pointerId),a([]))})}}return function(c){let{onPointerMissed:l,internal:u}=e.getState();u.lastEvent.current=c;let d=s===`onPointerMove`,f=s===`onClick`||s===`onContextMenu`||s===`onDoubleClick`,p=r(c,d?n:void 0),m=f?t(c):0;s===`onPointerDown`&&(u.initialClick=[c.offsetX,c.offsetY],u.initialHits=p.map(e=>e.eventObject)),f&&!p.length&&m<=2&&(o(c,u.interaction),l&&l(c)),d&&a(p);function h(e){let t=e.eventObject,n=t.__r3f;if(!(n!=null&&n.eventCount))return;let r=n.handlers;if(d){if(r.onPointerOver||r.onPointerEnter||r.onPointerOut||r.onPointerLeave){let t=w_(e),n=u.hovered.get(t);n?n.stopped&&e.stopPropagation():(u.hovered.set(t,e),r.onPointerOver==null||r.onPointerOver(e),r.onPointerEnter==null||r.onPointerEnter(e))}r.onPointerMove==null||r.onPointerMove(e)}else{let n=r[s];n?(!f||u.initialHits.includes(t))&&(o(c,u.interaction.filter(e=>!u.initialHits.includes(e))),n(e)):f&&u.initialHits.includes(t)&&o(c,u.interaction.filter(e=>!u.initialHits.includes(e)))}}i(p,c,m,h)}}return{handlePointer:s}}var k_=e=>!!(e!=null&&e.render),A_=b.createContext(null),j_=(e,t)=>{let n=Dg((n,r)=>{let i=new G,a=new G,o=new G;function s(e=r().camera,t=a,n=r().size){let{width:s,height:c,top:l,left:u}=n,d=s/c;t.isVector3?o.copy(t):o.set(...t);let f=e.getWorldPosition(i).distanceTo(o);if(Jg(e))return{width:s/e.zoom,height:c/e.zoom,top:l,left:u,factor:1,distance:f,aspect:d};{let t=e.fov*Math.PI/180,n=2*Math.tan(t/2)*f,r=s/c*n;return{width:r,height:n,top:l,left:u,factor:s/r,distance:f,aspect:d}}}let c,l=e=>n(t=>({performance:{...t.performance,current:e}})),u=new W;return{set:n,get:r,gl:null,camera:null,raycaster:null,events:{priority:1,enabled:!0,connected:!1},scene:null,xr:null,invalidate:(t=1)=>e(r(),t),advance:(e,n)=>t(e,n,r()),legacy:!1,linear:!1,flat:!1,controls:null,clock:new $d,pointer:u,mouse:u,frameloop:`always`,onPointerMissed:void 0,performance:{current:1,min:.5,max:1,debounce:200,regress:()=>{let e=r();c&&clearTimeout(c),e.performance.current!==e.performance.min&&l(e.performance.min),c=setTimeout(()=>l(r().performance.max),e.performance.debounce)}},size:{width:0,height:0,top:0,left:0},viewport:{initialDpr:0,dpr:0,width:0,height:0,top:0,left:0,aspect:0,distance:0,factor:0,getCurrentViewport:s},setEvents:e=>n(t=>({...t,events:{...t.events,...e}})),setSize:(e,t,i=0,o=0)=>{let c=r().camera,l={width:e,height:t,top:i,left:o};n(e=>({size:l,viewport:{...e.viewport,...s(c,a,l)}}))},setDpr:e=>n(t=>{let n=n_(e);return{viewport:{...t.viewport,dpr:n,initialDpr:t.viewport.initialDpr||n}}}),setFrameloop:(e=`always`)=>{let t=r().clock;t.stop(),t.elapsedTime=0,e!==`never`&&(t.start(),t.elapsedTime=0),n(()=>({frameloop:e}))},previousRoot:void 0,internal:{interaction:[],hovered:new Map,subscribers:[],initialClick:[0,0],initialHits:[],capturedMap:new Map,lastEvent:b.createRef(),active:!1,frames:0,priority:0,subscribe:(e,t,n)=>{let i=r().internal;return i.priority+=+(t>0),i.subscribers.push({ref:e,priority:t,store:n}),i.subscribers=i.subscribers.sort((e,t)=>e.priority-t.priority),()=>{let n=r().internal;n!=null&&n.subscribers&&(n.priority-=+(t>0),n.subscribers=n.subscribers.filter(t=>t.ref!==e))}}}}}),r=n.getState(),i=r.size,a=r.viewport.dpr,o=r.camera;return n.subscribe(()=>{let{camera:e,size:t,viewport:r,gl:s,set:c}=n.getState();if(t.width!==i.width||t.height!==i.height||r.dpr!==a){i=t,a=r.dpr,S_(e,t),r.dpr>0&&s.setPixelRatio(r.dpr);let n=typeof HTMLCanvasElement<`u`&&s.domElement instanceof HTMLCanvasElement;s.setSize(t.width,t.height,n)}e!==o&&(o=e,c(t=>({viewport:{...t.viewport,...t.viewport.getCurrentViewport(e)}})))}),n.subscribe(t=>e(t)),n};function M_(){let e=b.useContext(A_);if(!e)throw Error(`R3F: Hooks can only be used within the Canvas component!`);return e}function N_(e=e=>e,t){return M_()(e,t)}function P_(e,t=0){let n=M_(),r=n.getState().internal.subscribe,i=Qg(e);return Zg(()=>r(i,t,n),[t,r,n]),null}var F_=new WeakMap,I_=e=>typeof e==`function`&&e?.prototype?.constructor===e;function L_(e,t){return function(n,...r){let i;return I_(n)?(i=F_.get(n),i||(i=new n,F_.set(n,i))):i=n,e&&e(i),Promise.all(r.map(e=>new Promise((n,r)=>i.load(e,e=>{C_(e?.scene)&&Object.assign(e,a_(e.scene)),n(e)},t,t=>r(Error(`Could not load ${e}: ${t?.message}`))))))}}function R_(e,t,n,r){let i=Array.isArray(t)?t:[t],a=Mg(L_(n,r),[e,...i],{equal:i_.equ});return Array.isArray(t)?a:a[0]}R_.preload=function(e,t,n){let r=Array.isArray(t)?t:[t];return Ng(L_(n),[e,...r])},R_.clear=function(e,t){return Pg([e,...Array.isArray(t)?t:[t]])};var z_=1,B_=8,V_=32,H_=2,U_={name:`@react-three/fiber`,version:`9.6.1`,description:`A React renderer for Threejs`,keywords:[`react`,`renderer`,`fiber`,`three`,`threejs`],author:`Paul Henschel (https://github.com/drcmda)`,license:`MIT`,maintainers:[`Josh Ellis (https://github.com/joshuaellis)`,`Cody Bennett (https://github.com/codyjasonbennett)`,`Kris Baumgarter (https://github.com/krispya)`],bugs:{url:`https://github.com/pmndrs/react-three-fiber/issues`},homepage:`https://github.com/pmndrs/react-three-fiber#readme`,repository:{type:`git`,url:`git+https://github.com/pmndrs/react-three-fiber.git`},collective:{type:`opencollective`,url:`https://opencollective.com/react-three-fiber`},main:`dist/react-three-fiber.cjs.js`,module:`dist/react-three-fiber.esm.js`,types:`dist/react-three-fiber.cjs.d.ts`,"react-native":`native/dist/react-three-fiber-native.cjs.js`,sideEffects:!1,preconstruct:{entrypoints:[`index.tsx`,`native.tsx`]},scripts:{prebuild:`cp ../../readme.md readme.md`},devDependencies:{"@types/react-reconciler":`^0.32.3`,"react-reconciler":`^0.33.0`},dependencies:{"@babel/runtime":`^7.17.8`,"@types/webxr":`*`,"base64-js":`^1.5.1`,buffer:`^6.0.3`,"its-fine":`^2.0.0`,"react-use-measure":`^2.1.7`,scheduler:`^0.27.0`,"suspend-react":`^0.1.3`,"use-sync-external-store":`^1.4.0`,zustand:`^5.0.3`},peerDependencies:{expo:`>=43.0`,"expo-asset":`>=8.4`,"expo-file-system":`>=11.0`,"expo-gl":`>=11.0`,react:`>=19 <19.3`,"react-dom":`>=19 <19.3`,"react-native":`>=0.78`,three:`>=0.156`},peerDependenciesMeta:{"react-dom":{optional:!0},"react-native":{optional:!0},expo:{optional:!0},"expo-asset":{optional:!0},"expo-file-system":{optional:!0},"expo-gl":{optional:!0}}};function W_(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,`default`)?e.default:e}var G_={exports:{}},K_={exports:{}};K_.exports;var q_;function J_(){return q_||(q_=1,function(e){e.exports=function(e){function t(e,t,n,r){return new sa(e,t,n,r)}function n(){}function r(e){var t=`https://react.dev/errors/`+e;if(1dc||(e.current=uc[dc],uc[dc]=null,dc--)}function p(e,t){dc++,uc[dc]=e.current,e.current=t}function m(e){return e>>>=0,e===0?32:31-(mc(e)/hc|0)|0}function h(e){var t=e&42;if(t!==0)return t;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return e&261888;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function g(e,t,n){var r=e.pendingLanes;if(r===0)return 0;var i=0,a=e.suspendedLanes,o=e.pingedLanes;e=e.warmLanes;var s=r&134217727;return s===0?(s=r&~a,s===0?o===0?n||(n=r&~e,n!==0&&(i=h(n))):i=h(o):i=h(s)):(r=s&~a,r===0?(o&=s,o===0?n||(n=s&~e,n!==0&&(i=h(n))):i=h(o)):i=h(r)),i===0?0:t!==0&&t!==i&&(t&a)===0&&(a=i&-i,n=t&-t,a>=n||a===32&&n&4194048)?t:i}function _(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function v(e,t){switch(e){case 1:case 2:case 4:case 8:case 64:return t+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function y(){var e=vc;return vc<<=1,!(vc&62914560)&&(vc=4194304),e}function x(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function S(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function C(e,t,n,r,i,a){var o=e.pendingLanes;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=n,e.entangledLanes&=n,e.errorRecoveryDisabledLanes&=n,e.shellSuspendCounter=0;var s=e.entanglements,c=e.expirationTimes,l=e.hiddenUpdates;for(n=o&~n;0)`:-1i||c[r]!==l[i]){var u=` `+c[r].replace(` at new `,` at `);return e.displayName&&u.includes(``)&&(u=u.replace(``,e.displayName)),u}while(1<=r&&0<=i);break}}}finally{Lc=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:``)?j(n):``}function te(e,t){switch(e.tag){case 26:case 27:case 5:return j(e.type);case 16:return j(`Lazy`);case 13:return e.child!==t&&t!==null?j(`Suspense Fallback`):j(`Suspense`);case 19:return j(`SuspenseList`);case 0:case 15:return ee(e.type,!1);case 11:return ee(e.type.render,!1);case 1:return ee(e.type,!0);case 31:return j(`Activity`);default:return``}}function M(e){try{var t=``,n=null;do t+=te(e,n),n=e,e=e.return;while(e);return t}catch(e){return` Error generating stack: `+e.message+` `+e.stack}}function N(e,t){if(typeof e==`object`&&e){var n=Rc.get(e);return n===void 0?(t={value:e,source:t,stack:M(t)},Rc.set(e,t),t):n}return{value:e,source:t,stack:M(t)}}function P(e,t){zc[Bc++]=Hc,zc[Bc++]=Vc,Vc=e,Hc=t}function F(e,t,n){Uc[Wc++]=Kc,Uc[Wc++]=qc,Uc[Wc++]=Gc,Gc=e;var r=Kc;e=qc;var i=32-pc(r)-1;r&=~(1<>=o,i-=o,Kc=1<<32-pc(t)+i|n<f?(p=d,d=null):p=d.sibling;var _=h(t,d,o[f],c);if(_===null){d===null&&(d=p);break}e&&d&&_.alternate===null&&n(t,d),r=s(_,r,f),u===null?l=_:u.sibling=_,u=_,d=p}if(f===o.length)return i(t,d),el&&P(t,f),l;if(d===null){for(;fp?(_=f,f=null):_=f.sibling;var y=h(t,f,v.value,l);if(y===null){f===null&&(f=_);break}e&&f&&y.alternate===null&&n(t,f),o=s(y,o,p),d===null?u=y:d.sibling=y,d=y,f=_}if(v.done)return i(t,f),el&&P(t,p),u;if(f===null){for(;!v.done;p++,v=c.next())v=m(t,v.value,l),v!==null&&(o=s(v,o,p),d===null?u=v:d.sibling=v,d=v);return el&&P(t,p),u}for(f=a(f);!v.done;p++,v=c.next())v=g(f,t,p,v.value,l),v!==null&&(e&&v.alternate!==null&&f.delete(v.key===null?p:v.key),o=s(v,o,p),d===null?u=v:d.sibling=v,d=v);return e&&f.forEach(function(e){return n(t,e)}),el&&P(t,p),u}function y(e,t,a,s){if(typeof a==`object`&&a&&a.type===Aa&&a.key===null&&(a=a.props.children),typeof a==`object`&&a){switch(a.$$typeof){case Oa:e:{for(var u=a.key;t!==null;){if(t.key===u){if(u=a.type,u===Aa){if(t.tag===7){i(e,t.sibling),s=o(t,a.props.children),s.return=e,e=s;break e}}else if(t.elementType===u||typeof u==`object`&&u&&u.$$typeof===za&&He(u)===t.type){i(e,t.sibling),s=o(t,a.props),Ke(s,a),s.return=e,e=s;break e}i(e,t);break}else n(e,t);t=t.sibling}a.type===Aa?(s=fa(a.props.children,e.mode,s,a.key),s.return=e,e=s):(s=da(a.type,a.key,a.props,null,e.mode,s),Ke(s,a),s.return=e,e=s)}return c(e);case ka:e:{for(u=a.key;t!==null;){if(t.key===u)if(t.tag===4&&t.stateNode.containerInfo===a.containerInfo&&t.stateNode.implementation===a.implementation){i(e,t.sibling),s=o(t,a.children||[]),s.return=e,e=s;break e}else{i(e,t);break}else n(e,t);t=t.sibling}s=ha(a,e.mode,s),s.return=e,e=s}return c(e);case za:return a=He(a),y(e,t,a,s)}if(Wa(a))return _(e,t,a,s);if(l(a)){if(u=l(a),typeof u!=`function`)throw Error(r(150));return a=u.call(a),v(e,t,a,s)}if(typeof a.then==`function`)return y(e,t,Ge(a),s);if(a.$$typeof===Pa)return y(e,t,Se(e,a),s);qe(e,a)}return typeof a==`string`&&a!==``||typeof a==`number`||typeof a==`bigint`?(a=``+a,t!==null&&t.tag===6?(i(e,t.sibling),s=o(t,a),s.return=e,e=s):(i(e,t),s=pa(a,e.mode,s),s.return=e,e=s),c(e)):i(e,t)}return function(e,n,r,i){try{kl=0;var a=y(e,n,r,i);return Ol=null,a}catch(n){if(n===Cl||n===Tl)throw n;var o=t(29,n,null,e.mode);return o.lanes=i,o.return=e,o}}}function Ye(){for(var e=Nl,t=Pl=Nl=0;ta?a:8);var o=Ga.T,s={};Ga.T=s,kn(e,!1,t,n);try{var c=i(),l=Ga.S;l!==null&&l(s,c),typeof c==`object`&&c&&typeof c.then==`function`?On(e,t,Fe(c,r),Ci(e)):On(e,t,r,Ci(e))}catch(n){On(e,t,{then:function(){},status:`rejected`,reason:n},Ci())}finally{ho(a),o!==null&&s.types!==null&&(o.types=s.types),Ga.T=o}}function xn(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:Do,baseState:Do,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ft,lastRenderedState:Do},next:null};var n={};return t.next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ft,lastRenderedState:n},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function Sn(){return xe(Oo)}function Cn(){return At().memoizedState}function wn(){return At().memoizedState}function Tn(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var n=Ci();e=rt(n);var r=it(t,e,n);r!==null&&(Ti(r,t,n),at(r,t,n)),t={cache:R()},e.payload=t;return}t=t.return}}function En(e,t,n){var r=Ci();n={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},An(e)?jn(t,n):(n=Ze(e,t,n,r),n!==null&&(Ti(n,e,r),Mn(n,t,r)))}function Dn(e,t,n){On(e,t,n,Ci())}function On(e,t,n,r){var i={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(An(e))jn(t,i);else{var a=e.alternate;if(e.lanes===0&&(a===null||a.lanes===0)&&(a=t.lastRenderedReducer,a!==null))try{var o=t.lastRenderedState,s=a(o,n);if(i.hasEagerState=!0,i.eagerState=s,Mc(s,o))return Xe(e,t,i,0),Tu===null&&Ye(),!1}catch{}if(n=Ze(e,t,i,r),n!==null)return Ti(n,e,r),Mn(n,t,r),!0}return!1}function kn(e,t,n,i){if(i={lane:2,revertLane:Me(),gesture:null,action:i,hasEagerState:!1,eagerState:null,next:null},An(e)){if(t)throw Error(r(479))}else t=Ze(e,n,i,2),t!==null&&Ti(t,e,2)}function An(e){var t=e.alternate;return e===Ul||t!==null&&t===Ul}function jn(e,t){ql=Kl=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function Mn(e,t,n){if(n&4194048){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,T(e,n)}}function Nn(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:Ea({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}function Pn(e,t,n,r,i,a,o){return e=e.stateNode,typeof e.shouldComponentUpdate==`function`?e.shouldComponentUpdate(r,a,o):t.prototype&&t.prototype.isPureReactComponent?!ze(n,r)||!ze(i,a):!0}function Fn(e,t,n,r){e=t.state,typeof t.componentWillReceiveProps==`function`&&t.componentWillReceiveProps(n,r),typeof t.UNSAFE_componentWillReceiveProps==`function`&&t.UNSAFE_componentWillReceiveProps(n,r),t.state!==e&&ru.enqueueReplaceState(t,t.state,null)}function W(e,t){var n=t;if(`ref`in t)for(var r in n={},t)r!==`ref`&&(n[r]=t[r]);if(e=e.defaultProps)for(var i in n===t&&(n=Ea({},n)),e)n[i]===void 0&&(n[i]=e[i]);return n}function In(e,t){try{var n=e.onUncaughtError;n(t.value,{componentStack:t.stack})}catch(e){setTimeout(function(){throw e})}}function G(e,t,n){try{var r=e.onCaughtError;r(n.value,{componentStack:n.stack,errorBoundary:t.tag===1?t.stateNode:null})}catch(e){setTimeout(function(){throw e})}}function Ln(e,t,n){return n=rt(n),n.tag=3,n.payload={element:null},n.callback=function(){In(e,t)},n}function Rn(e){return e=rt(e),e.tag=3,e}function zn(e,t,n,r){var i=n.type.getDerivedStateFromError;if(typeof i==`function`){var a=r.value;e.payload=function(){return i(a)},e.callback=function(){G(t,n,r)}}var o=n.stateNode;o!==null&&typeof o.componentDidCatch==`function`&&(e.callback=function(){G(t,n,r),typeof i!=`function`&&(qu===null?qu=new Set([this]):qu.add(this));var e=r.stack;this.componentDidCatch(r.value,{componentStack:e===null?``:e})})}function Bn(e,t,n,i,a){if(n.flags|=32768,typeof i==`object`&&i&&typeof i.then==`function`){if(t=n.alternate,t!==null&&ve(t,n,a,!0),n=zl.current,n!==null){switch(n.tag){case 31:case 13:return Bl===null?Li():n.alternate===null&&Pu===0&&(Pu=3),n.flags&=-257,n.flags|=65536,n.lanes=a,i===El?n.flags|=16384:(t=n.updateQueue,t===null?n.updateQueue=new Set([i]):t.add(i),ta(e,i,a)),!1;case 22:return n.flags|=65536,i===El?n.flags|=16384:(t=n.updateQueue,t===null?(t={transitions:null,markerInstances:null,retryQueue:new Set([i])},n.updateQueue=t):(n=t.retryQueue,n===null?t.retryQueue=new Set([i]):n.add(i)),ta(e,i,a)),!1}throw Error(r(435,n.tag))}return ta(e,i,a),Li(),!1}if(el)return t=zl.current,t===null?(i!==rl&&(t=Error(r(423),{cause:i}),pe(N(t,n))),e=e.current.alternate,e.flags|=65536,a&=-a,e.lanes|=a,i=N(i,n),a=Ln(e.stateNode,i,a),ot(e,a),Pu!==4&&(Pu=2)):(!(t.flags&65536)&&(t.flags|=256),t.flags|=65536,t.lanes=a,i!==rl&&(e=Error(r(422),{cause:i}),pe(N(e,n)))),!1;var o=Error(r(520),{cause:i});if(o=N(o,n),Bu===null?Bu=[o]:Bu.push(o),Pu!==4&&(Pu=2),t===null)return!0;i=N(i,n),n=t;do{switch(n.tag){case 3:return n.flags|=65536,e=a&-a,n.lanes|=e,e=Ln(n.stateNode,i,e),ot(n,e),!1;case 1:if(t=n.type,o=n.stateNode,!(n.flags&128)&&(typeof t.getDerivedStateFromError==`function`||o!==null&&typeof o.componentDidCatch==`function`&&(qu===null||!qu.has(o))))return n.flags|=65536,a&=-a,n.lanes|=a,a=Rn(a),zn(a,e,n,i),ot(n,a),!1}n=n.return}while(n!==null);return!1}function Vn(e,t,n,r){t.child=e===null?jl(t,null,n,r):Al(t,e.child,n,r)}function Hn(e,t,n,r,i){n=n.render;var a=t.ref;if(`ref`in r){var o={};for(var s in r)s!==`ref`&&(o[s]=r[s])}else o=r;return be(t),r=St(e,t,n,o,a,i),s=Et(),e!==null&&!au?(Dt(e,t,i),dr(e,t,i)):(el&&s&&ne(t),t.flags|=1,Vn(e,t,r,i),t.child)}function Un(e,t,n,r,i){if(e===null){var a=n.type;return typeof a==`function`&&!ca(a)&&a.defaultProps===void 0&&n.compare===null?(t.tag=15,t.type=a,Wn(e,t,a,r,i)):(e=da(n.type,null,r,t,t.mode,i),e.ref=t.ref,e.return=t,t.child=e)}if(a=e.child,!fr(e,i)){var o=a.memoizedProps;if(n=n.compare,n=n===null?ze:n,n(o,r)&&e.ref===t.ref)return dr(e,t,i)}return t.flags|=1,e=la(a,r),e.ref=t.ref,e.return=t,t.child=e}function Wn(e,t,n,r,i){if(e!==null){var a=e.memoizedProps;if(ze(a,r)&&e.ref===t.ref)if(au=!1,t.pendingProps=r=a,fr(e,i))e.flags&131072&&(au=!0);else return t.lanes=e.lanes,dr(e,t,i)}return Qn(e,t,n,r,i)}function Gn(e,t,n,r){var i=r.children,a=e===null?null:e.memoizedState;if(e===null&&t.stateNode===null&&(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),r.mode===`hidden`){if(t.flags&128){if(a=a===null?n:a.baseLanes|n,e!==null){for(r=t.child=e.child,i=0;r!==null;)i=i|r.lanes|r.childLanes,r=r.sibling;r=i&~a}else r=0,t.child=null;return qn(e,t,a,n,r)}if(n&536870912)t.memoizedState={baseLanes:0,cachePool:null},e!==null&&Le(t,a===null?null:a.cachePool),a===null?ft():dt(t,a),gt(t);else return r=t.lanes=536870912,qn(e,t,a===null?n:a.baseLanes|n,n,r)}else a===null?(e!==null&&Le(t,null),ft(),_t()):(Le(t,a.cachePool),dt(t,a),_t(),t.memoizedState=null);return Vn(e,t,i,n),t.child}function Kn(e,t){return e!==null&&e.tag===22||t.stateNode!==null||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function qn(e,t,n,r,i){var a=Ie();return a=a===null?null:{parent:co?ul._currentValue:ul._currentValue2,pool:a},t.memoizedState={baseLanes:n,cachePool:a},e!==null&&Le(t,null),ft(),gt(t),e!==null&&ve(e,t,r,!0),t.childLanes=i,null}function Jn(e,t){return t=or({mode:t.mode,children:t.children},e.mode),t.ref=e.ref,e.child=t,t.return=e,t}function Yn(e,t,n){return Al(t,e.child,null,n),e=Jn(t,t.pendingProps),e.flags|=2,vt(t),t.memoizedState=null,e}function Xn(e,t,n){var i=t.pendingProps,a=(t.flags&128)!=0;if(t.flags&=-129,e===null){if(el){if(i.mode===`hidden`)return e=Jn(t,i),t.lanes=536870912,Kn(null,e);if(ht(t),(e=$c)?(e=Cs(e,nl),e!==null&&(t.memoizedState={dehydrated:e,treeContext:Gc===null?null:{id:Kc,overflow:qc},retryLane:536870912,hydrationErrors:null},n=ma(e),n.return=t,t.child=n,Qc=t,$c=null)):e=null,e===null)throw se(t);return t.lanes=536870912,null}return Jn(t,i)}var o=e.memoizedState;if(o!==null){var s=o.dehydrated;if(ht(t),a)if(t.flags&256)t.flags&=-257,t=Yn(e,t,n);else if(t.memoizedState!==null)t.child=e.child,t.flags|=128,t=null;else throw Error(r(558));else if(au||ve(e,t,n,!1),a=(n&e.childLanes)!==0,au||a){if(i=Tu,i!==null&&(s=E(i,n),s!==0&&s!==o.retryLane))throw o.retryLane=s,Qe(e,s),Ti(i,e,s),iu;Li(),t=Yn(e,t,n)}else e=o.treeContext,fo&&($c=vs(s),Qc=t,el=!0,tl=null,nl=!1,e!==null&&ie(t,e)),t=Jn(t,i),t.flags|=4096;return t}return e=la(e.child,{mode:i.mode,children:i.children}),e.ref=t.ref,t.child=e,e.return=t,e}function Zn(e,t){var n=t.ref;if(n===null)e!==null&&e.ref!==null&&(t.flags|=4194816);else{if(typeof n!=`function`&&typeof n!=`object`)throw Error(r(284));(e===null||e.ref!==n)&&(t.flags|=4194816)}}function Qn(e,t,n,r,i){return be(t),n=St(e,t,n,r,void 0,i),r=Et(),e!==null&&!au?(Dt(e,t,i),dr(e,t,i)):(el&&r&&ne(t),t.flags|=1,Vn(e,t,n,i),t.child)}function $n(e,t,n,r,i,a){return be(t),t.updateQueue=null,n=wt(t,r,n,i),Ct(e),r=Et(),e!==null&&!au?(Dt(e,t,a),dr(e,t,a)):(el&&r&&ne(t),t.flags|=1,Vn(e,t,n,a),t.child)}function er(e,t,n,r,i){if(be(t),t.stateNode===null){var a=fc,o=n.contextType;typeof o==`object`&&o&&(a=xe(o)),a=new n(r,a),t.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,a.updater=ru,t.stateNode=a,a._reactInternals=t,a=t.stateNode,a.props=r,a.state=t.memoizedState,a.refs={},tt(t),o=n.contextType,a.context=typeof o==`object`&&o?xe(o):fc,a.state=t.memoizedState,o=n.getDerivedStateFromProps,typeof o==`function`&&(Nn(t,n,o,r),a.state=t.memoizedState),typeof n.getDerivedStateFromProps==`function`||typeof a.getSnapshotBeforeUpdate==`function`||typeof a.UNSAFE_componentWillMount!=`function`&&typeof a.componentWillMount!=`function`||(o=a.state,typeof a.componentWillMount==`function`&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount==`function`&&a.UNSAFE_componentWillMount(),o!==a.state&&ru.enqueueReplaceState(a,a.state,null),ct(t,r,a,i),st(),a.state=t.memoizedState),typeof a.componentDidMount==`function`&&(t.flags|=4194308),r=!0}else if(e===null){a=t.stateNode;var s=t.memoizedProps,c=W(n,s);a.props=c;var l=a.context,u=n.contextType;o=fc,typeof u==`object`&&u&&(o=xe(u));var d=n.getDerivedStateFromProps;u=typeof d==`function`||typeof a.getSnapshotBeforeUpdate==`function`,s=t.pendingProps!==s,u||typeof a.UNSAFE_componentWillReceiveProps!=`function`&&typeof a.componentWillReceiveProps!=`function`||(s||l!==o)&&Fn(t,a,r,o),Fl=!1;var f=t.memoizedState;a.state=f,ct(t,r,a,i),st(),l=t.memoizedState,s||f!==l||Fl?(typeof d==`function`&&(Nn(t,n,d,r),l=t.memoizedState),(c=Fl||Pn(t,n,c,r,f,l,o))?(u||typeof a.UNSAFE_componentWillMount!=`function`&&typeof a.componentWillMount!=`function`||(typeof a.componentWillMount==`function`&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount==`function`&&a.UNSAFE_componentWillMount()),typeof a.componentDidMount==`function`&&(t.flags|=4194308)):(typeof a.componentDidMount==`function`&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=l),a.props=r,a.state=l,a.context=o,r=c):(typeof a.componentDidMount==`function`&&(t.flags|=4194308),r=!1)}else{a=t.stateNode,nt(e,t),o=t.memoizedProps,u=W(n,o),a.props=u,d=t.pendingProps,f=a.context,l=n.contextType,c=fc,typeof l==`object`&&l&&(c=xe(l)),s=n.getDerivedStateFromProps,(l=typeof s==`function`||typeof a.getSnapshotBeforeUpdate==`function`)||typeof a.UNSAFE_componentWillReceiveProps!=`function`&&typeof a.componentWillReceiveProps!=`function`||(o!==d||f!==c)&&Fn(t,a,r,c),Fl=!1,f=t.memoizedState,a.state=f,ct(t,r,a,i),st();var p=t.memoizedState;o!==d||f!==p||Fl||e!==null&&e.dependencies!==null&&ye(e.dependencies)?(typeof s==`function`&&(Nn(t,n,s,r),p=t.memoizedState),(u=Fl||Pn(t,n,u,r,f,p,c)||e!==null&&e.dependencies!==null&&ye(e.dependencies))?(l||typeof a.UNSAFE_componentWillUpdate!=`function`&&typeof a.componentWillUpdate!=`function`||(typeof a.componentWillUpdate==`function`&&a.componentWillUpdate(r,p,c),typeof a.UNSAFE_componentWillUpdate==`function`&&a.UNSAFE_componentWillUpdate(r,p,c)),typeof a.componentDidUpdate==`function`&&(t.flags|=4),typeof a.getSnapshotBeforeUpdate==`function`&&(t.flags|=1024)):(typeof a.componentDidUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=p),a.props=r,a.state=p,a.context=c,r=u):(typeof a.componentDidUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),r=!1)}return a=r,Zn(e,t),r=(t.flags&128)!=0,a||r?(a=t.stateNode,n=r&&typeof n.getDerivedStateFromError!=`function`?null:a.render(),t.flags|=1,e!==null&&r?(t.child=Al(t,e.child,null,i),t.child=Al(t,null,n,i)):Vn(e,t,n,i),t.memoizedState=a.state,e=t.child):e=dr(e,t,i),e}function tr(e,t,n,r){return de(),t.flags|=256,Vn(e,t,n,r),t.child}function nr(e){return{baseLanes:e,cachePool:Re()}}function rr(e,t,n){return e=e===null?0:e.childLanes&~n,t&&(e|=Ru),e}function ir(e,t,n){var i=t.pendingProps,a=!1,o=(t.flags&128)!=0,s;if((s=o)||(s=e!==null&&e.memoizedState===null?!1:(Vl.current&2)!=0),s&&(a=!0,t.flags&=-129),s=(t.flags&32)!=0,t.flags&=-33,e===null){if(el){if(a?mt(t):_t(),(e=$c)?(e=ws(e,nl),e!==null&&(t.memoizedState={dehydrated:e,treeContext:Gc===null?null:{id:Kc,overflow:qc},retryLane:536870912,hydrationErrors:null},n=ma(e),n.return=t,t.child=n,Qc=t,$c=null)):e=null,e===null)throw se(t);return ls(e)?t.lanes=32:t.lanes=536870912,null}var c=i.children;return i=i.fallback,a?(_t(),a=t.mode,c=or({mode:`hidden`,children:c},a),i=fa(i,a,n,null),c.return=t,i.return=t,c.sibling=i,t.child=c,i=t.child,i.memoizedState=nr(n),i.childLanes=rr(e,s,n),t.memoizedState=ou,Kn(null,i)):(mt(t),ar(t,c))}var l=e.memoizedState;if(l!==null&&(c=l.dehydrated,c!==null)){if(o)t.flags&256?(mt(t),t.flags&=-257,t=sr(e,t,n)):t.memoizedState===null?(_t(),c=i.fallback,a=t.mode,i=or({mode:`visible`,children:i.children},a),c=fa(c,a,n,null),c.flags|=2,i.return=t,c.return=t,i.sibling=c,t.child=i,Al(t,e.child,null,n),i=t.child,i.memoizedState=nr(n),i.childLanes=rr(e,s,n),t.memoizedState=ou,t=Kn(null,i)):(_t(),t.child=e.child,t.flags|=128,t=null);else if(mt(t),ls(c))s=us(c).digest,i=Error(r(419)),i.stack=``,i.digest=s,pe({value:i,source:null,stack:null}),t=sr(e,t,n);else if(au||ve(e,t,n,!1),s=(n&e.childLanes)!==0,au||s){if(s=Tu,s!==null&&(i=E(s,n),i!==0&&i!==l.retryLane))throw l.retryLane=i,Qe(e,i),Ti(s,e,i),iu;cs(c)||Li(),t=sr(e,t,n)}else cs(c)?(t.flags|=192,t.child=e.child,t=null):(e=l.treeContext,fo&&($c=ys(c),Qc=t,el=!0,tl=null,nl=!1,e!==null&&ie(t,e)),t=ar(t,i.children),t.flags|=4096);return t}return a?(_t(),c=i.fallback,a=t.mode,l=e.child,o=l.sibling,i=la(l,{mode:`hidden`,children:i.children}),i.subtreeFlags=l.subtreeFlags&65011712,o===null?(c=fa(c,a,n,null),c.flags|=2):c=la(o,c),c.return=t,i.return=t,i.sibling=c,t.child=i,Kn(null,i),i=t.child,c=e.child.memoizedState,c===null?c=nr(n):(a=c.cachePool,a===null?a=Re():(l=co?ul._currentValue:ul._currentValue2,a=a.parent===l?a:{parent:l,pool:l}),c={baseLanes:c.baseLanes|n,cachePool:a}),i.memoizedState=c,i.childLanes=rr(e,s,n),t.memoizedState=ou,Kn(e.child,i)):(mt(t),n=e.child,e=n.sibling,n=la(n,{mode:`visible`,children:i.children}),n.return=t,n.sibling=null,e!==null&&(s=t.deletions,s===null?(t.deletions=[e],t.flags|=16):s.push(e)),t.child=n,t.memoizedState=null,n)}function ar(e,t){return t=or({mode:`visible`,children:t},e.mode),t.return=e,e.child=t}function or(e,n){return e=t(22,e,null,n),e.lanes=0,e}function sr(e,t,n){return Al(t,e.child,null,n),e=ar(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function cr(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),ge(e.return,t,n)}function lr(e,t,n,r,i,a){var o=e.memoizedState;o===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:i,treeForkCount:a}:(o.isBackwards=t,o.rendering=null,o.renderingStartTime=0,o.last=r,o.tail=n,o.tailMode=i,o.treeForkCount=a)}function ur(e,t,n){var r=t.pendingProps,i=r.revealOrder,a=r.tail;r=r.children;var o=Vl.current,s=(o&2)!=0;if(s?(o=o&1|2,t.flags|=128):o&=1,p(Vl,o),Vn(e,t,r,n),r=el?Hc:0,!s&&e!==null&&e.flags&128)e:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&cr(e,n,t);else if(e.tag===19)cr(e,n,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;e.sibling===null;){if(e.return===null||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}switch(i){case`forwards`:for(n=t.child,i=null;n!==null;)e=n.alternate,e!==null&&yt(e)===null&&(i=n),n=n.sibling;n=i,n===null?(i=t.child,t.child=null):(i=n.sibling,n.sibling=null),lr(t,!1,i,n,a,r);break;case`backwards`:case`unstable_legacy-backwards`:for(n=null,i=t.child,t.child=null;i!==null;){if(e=i.alternate,e!==null&&yt(e)===null){t.child=i;break}e=i.sibling,i.sibling=n,n=i,i=e}lr(t,!0,n,null,a,r);break;case`together`:lr(t,!1,null,null,void 0,r);break;default:t.memoizedState=null}return t.child}function dr(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),Fu|=t.lanes,(n&t.childLanes)===0)if(e!==null){if(ve(e,t,n,!1),(n&t.childLanes)===0)return null}else return null;if(e!==null&&t.child!==e.child)throw Error(r(153));if(t.child!==null){for(e=t.child,n=la(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=la(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function fr(e,t){return(e.lanes&t)===0?(e=e.dependencies,!!(e!==null&&ye(e))):!0}function pr(e,t,n){switch(t.tag){case 3:I(t,t.stateNode.containerInfo),me(t,ul,e.memoizedState.cache),de();break;case 27:case 5:L(t);break;case 4:I(t,t.stateNode.containerInfo);break;case 10:me(t,t.type,t.memoizedProps.value);break;case 31:if(t.memoizedState!==null)return t.flags|=128,ht(t),null;break;case 13:var r=t.memoizedState;if(r!==null)return r.dehydrated===null?(n&t.child.childLanes)===0?(mt(t),e=dr(e,t,n),e===null?null:e.sibling):ir(e,t,n):(mt(t),t.flags|=128,null);mt(t);break;case 19:var i=(e.flags&128)!=0;if(r=(n&t.childLanes)!==0,r||=(ve(e,t,n,!1),(n&t.childLanes)!==0),i){if(r)return ur(e,t,n);t.flags|=128}if(i=t.memoizedState,i!==null&&(i.rendering=null,i.tail=null,i.lastEffect=null),p(Vl,Vl.current),r)break;return null;case 22:return t.lanes=0,Gn(e,t,n,t.pendingProps);case 24:me(t,ul,e.memoizedState.cache)}return dr(e,t,n)}function mr(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps)au=!0;else{if(!fr(e,n)&&!(t.flags&128))return au=!1,pr(e,t,n);au=(e.flags&131072)!=0}else au=!1,el&&t.flags&1048576&&F(t,Hc,t.index);switch(t.lanes=0,t.tag){case 16:e:{var i=t.pendingProps;if(e=He(t.elementType),t.type=e,typeof e==`function`)ca(e)?(i=W(e,i),t.tag=1,t=er(null,t,e,i,n)):(t.tag=0,t=Qn(null,t,e,i,n));else{if(e!=null){var a=e.$$typeof;if(a===Fa){t.tag=11,t=Hn(null,t,e,i,n);break e}else if(a===Ra){t.tag=14,t=Un(null,t,e,i,n);break e}}throw t=u(e)||e,Error(r(306,t,``))}}return t;case 0:return Qn(e,t,t.type,t.pendingProps,n);case 1:return i=t.type,a=W(i,t.pendingProps),er(e,t,i,a,n);case 3:e:{if(I(t,t.stateNode.containerInfo),e===null)throw Error(r(387));var o=t.pendingProps;a=t.memoizedState,i=a.element,nt(e,t),ct(t,o,null,n);var s=t.memoizedState;if(o=s.cache,me(t,ul,o),o!==a.cache&&_e(t,[ul],n,!0),st(),o=s.element,fo&&a.isDehydrated)if(a={element:o,isDehydrated:!1,cache:s.cache},t.updateQueue.baseState=a,t.memoizedState=a,t.flags&256){t=tr(e,t,o,n);break e}else if(o!==i){i=N(Error(r(424)),t),pe(i),t=tr(e,t,o,n);break e}else for(fo&&($c=_s(t.stateNode.containerInfo),Qc=t,el=!0,tl=null,nl=!0),n=jl(t,null,o,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(de(),o===i){t=dr(e,t,n);break e}Vn(e,t,o,n)}t=t.child}return t;case 26:if(Ws)return Zn(e,t),e===null?(n=qs(t.type,null,t.pendingProps,null))?t.memoizedState=n:el||(t.stateNode=$s(t.type,t.pendingProps,Xc.current,t)):t.memoizedState=qs(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:if(ic)return L(t),e===null&&ic&&el&&(i=t.stateNode=ac(t.type,t.pendingProps,Xc.current,Jc.current,!1),Qc=t,nl=!0,$c=bs(t.type,i,$c)),Vn(e,t,t.pendingProps.children,n),Zn(e,t),e===null&&(t.flags|=4194304),t.child;case 5:return e===null&&el&&(Hs(t.type,t.pendingProps,Jc.current),(a=i=$c)&&(i=xs(i,t.type,t.pendingProps,nl),i===null?a=!1:(t.stateNode=i,Qc=t,$c=gs(i),nl=!1,a=!0)),a||se(t)),L(t),a=t.type,o=t.pendingProps,s=e===null?null:e.memoizedProps,i=o.children,ro(a,o)?i=null:s!==null&&ro(a,s)&&(t.flags|=32),t.memoizedState!==null&&(a=St(e,t,Tt,null,null,n),co?Oo._currentValue=a:Oo._currentValue2=a),Zn(e,t),Vn(e,t,i,n),t.child;case 6:return e===null&&el&&(Us(t.pendingProps,Jc.current),(e=n=$c)&&(n=Ss(n,t.pendingProps,nl),n===null?e=!1:(t.stateNode=n,Qc=t,$c=null,e=!0)),e||se(t)),null;case 13:return ir(e,t,n);case 4:return I(t,t.stateNode.containerInfo),i=t.pendingProps,e===null?t.child=Al(t,null,i,n):Vn(e,t,i,n),t.child;case 11:return Hn(e,t,t.type,t.pendingProps,n);case 7:return Vn(e,t,t.pendingProps,n),t.child;case 8:return Vn(e,t,t.pendingProps.children,n),t.child;case 12:return Vn(e,t,t.pendingProps.children,n),t.child;case 10:return i=t.pendingProps,me(t,t.type,i.value),Vn(e,t,i.children,n),t.child;case 9:return a=t.type._context,i=t.pendingProps.children,be(t),a=xe(a),i=i(a),t.flags|=1,Vn(e,t,i,n),t.child;case 14:return Un(e,t,t.type,t.pendingProps,n);case 15:return Wn(e,t,t.type,t.pendingProps,n);case 19:return ur(e,t,n);case 31:return Xn(e,t,n);case 22:return Gn(e,t,n,t.pendingProps);case 24:return be(t),i=xe(ul),e===null?(a=Ie(),a===null&&(a=Tu,o=R(),a.pooledCache=o,o.refCount++,o!==null&&(a.pooledCacheLanes|=n),a=o),t.memoizedState={parent:i,cache:a},tt(t),me(t,ul,a)):((e.lanes&n)!==0&&(nt(e,t),ct(t,null,null,n),st()),a=e.memoizedState,o=t.memoizedState,a.parent===i?(i=o.cache,me(t,ul,i),i!==a.cache&&_e(t,[ul],n,!0)):(a={parent:i,cache:i},t.memoizedState=a,t.lanes===0&&(t.memoizedState=t.updateQueue.baseState=a),me(t,ul,i))),Vn(e,t,t.pendingProps.children,n),t.child;case 29:throw t.pendingProps}throw Error(r(156,t.tag))}function hr(e){e.flags|=4}function gr(e){uo&&(e.flags|=8)}function _r(e,t){if(e!==null&&e.child===t.child)return!1;if(t.flags&16)return!0;for(e=t.child;e!==null;){if(e.flags&8218||e.subtreeFlags&8218)return!0;e=e.sibling}return!1}function vr(e,t,n,r){if(lo)for(n=t.child;n!==null;){if(n.tag===5||n.tag===6)to(e,n.stateNode);else if(!(n.tag===4||ic&&n.tag===27)&&n.child!==null){n.child.return=n,n=n.child;continue}if(n===t)break;for(;n.sibling===null;){if(n.return===null||n.return===t)return;n=n.return}n.sibling.return=n.return,n=n.sibling}else if(uo)for(var i=t.child;i!==null;){if(i.tag===5){var a=i.stateNode;n&&r&&(a=os(a,i.type,i.memoizedProps)),to(e,a)}else if(i.tag===6)a=i.stateNode,n&&r&&(a=ss(a,i.memoizedProps)),to(e,a);else if(i.tag!==4){if(i.tag===22&&i.memoizedState!==null)a=i.child,a!==null&&(a.return=i),vr(e,i,!0,!0);else if(i.child!==null){i.child.return=i,i=i.child;continue}}if(i===t)break;for(;i.sibling===null;){if(i.return===null||i.return===t)return;i=i.return}i.sibling.return=i.return,i=i.sibling}}function yr(e,t,n,r){var i=!1;if(uo)for(var a=t.child;a!==null;){if(a.tag===5){var o=a.stateNode;n&&r&&(o=os(o,a.type,a.memoizedProps)),rs(e,o)}else if(a.tag===6)o=a.stateNode,n&&r&&(o=ss(o,a.memoizedProps)),rs(e,o);else if(a.tag!==4){if(a.tag===22&&a.memoizedState!==null)i=a.child,i!==null&&(i.return=a),yr(e,a,!0,!0),i=!0;else if(a.child!==null){a.child.return=a,a=a.child;continue}}if(a===t)break;for(;a.sibling===null;){if(a.return===null||a.return===t)return i;a=a.return}a.sibling.return=a.return,a=a.sibling}return i}function br(e,t){if(uo&&_r(e,t)){e=t.stateNode;var n=e.containerInfo,r=ns();yr(r,t,!1,!1),e.pendingChildren=r,hr(t),is(n,r)}}function xr(e,t,n,r){if(lo)e.memoizedProps!==r&&hr(t);else if(uo){var i=e.stateNode,a=e.memoizedProps;if((e=_r(e,t))||a!==r){var o=Jc.current;a=ts(i,n,a,r,!e,null),a===i?t.stateNode=i:(gr(t),no(a,n,r,o)&&hr(t),t.stateNode=a,e&&vr(a,t,!1,!1))}else t.stateNode=i}}function Sr(e,t,n,r,i){if(e.mode&32&&(n===null?bo(t,r):xo(t,n,r))){if(e.flags|=16777216,(i&335544128)===i||So(t,r))if(Co(e.stateNode,t,r))e.flags|=8192;else if(Pi())e.flags|=8192;else throw Dl=El,wl}else e.flags&=-16777217}function Cr(e,t){if(tc(t)){if(e.flags|=16777216,!nc(t))if(Pi())e.flags|=8192;else throw Dl=El,wl}else e.flags&=-16777217}function wr(e,t){t!==null&&(e.flags|=4),e.flags&16384&&(t=e.tag===22?536870912:y(),e.lanes|=t,zu|=t)}function Tr(e,t){if(!el)switch(e.tailMode){case`hidden`:t=e.tail;for(var n=null;t!==null;)t.alternate!==null&&(n=t),t=t.sibling;n===null?e.tail=null:n.sibling=null;break;case`collapsed`:n=e.tail;for(var r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:r.sibling=null}}function Er(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,r=0;if(t)for(var i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags&65011712,r|=i.flags&65011712,i.return=e,i=i.sibling;else for(i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags,r|=i.flags,i.return=e,i=i.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function Dr(e,t,n){var i=t.pendingProps;switch(re(t),t.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Er(t),null;case 1:return Er(t),null;case 3:return n=t.stateNode,i=null,e!==null&&(i=e.memoizedState.cache),t.memoizedState.cache!==i&&(t.flags|=2048),he(ul),ae(),n.pendingContext&&(n.context=n.pendingContext,n.pendingContext=null),(e===null||e.child===null)&&(ue(t)?hr(t):e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,fe())),br(e,t),Er(t),null;case 26:if(Ws){var a=t.type,o=t.memoizedState;return e===null?(hr(t),o===null?(Er(t),Sr(t,a,null,i,n)):(Er(t),Cr(t,o))):o?o===e.memoizedState?(Er(t),t.flags&=-16777217):(hr(t),Er(t),Cr(t,o)):(o=e.memoizedProps,lo?o!==i&&hr(t):xr(e,t,a,i),Er(t),Sr(t,a,o,i,n)),null}case 27:if(ic){if(oe(t),n=Xc.current,a=t.type,e!==null&&t.stateNode!=null)lo?e.memoizedProps!==i&&hr(t):xr(e,t,a,i);else{if(!i){if(t.stateNode===null)throw Error(r(166));return Er(t),null}e=Jc.current,ue(t)?ce(t,e):(e=ac(a,i,n,e,!0),t.stateNode=e,hr(t))}return Er(t),null}case 5:if(oe(t),a=t.type,e!==null&&t.stateNode!=null)xr(e,t,a,i);else{if(!i){if(t.stateNode===null)throw Error(r(166));return Er(t),null}if(o=Jc.current,ue(t))ce(t,o),Fs(t.stateNode,a,i,o)&&(t.flags|=64);else{var s=eo(a,i,Xc.current,o,t);gr(t),vr(s,t,!1,!1),t.stateNode=s,no(s,a,i,o)&&hr(t)}}return Er(t),Sr(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&t.stateNode!=null)n=e.memoizedProps,lo?n!==i&&hr(t):uo&&(n===i?t.stateNode=e.stateNode:(e=Xc.current,n=Jc.current,gr(t),t.stateNode=io(i,e,n,t)));else{if(typeof i!=`string`&&t.stateNode===null)throw Error(r(166));if(e=Xc.current,n=Jc.current,ue(t)){if(!fo)throw Error(r(176));if(e=t.stateNode,n=t.memoizedProps,i=null,a=Qc,a!==null)switch(a.tag){case 27:case 5:i=a.memoizedProps}Es(e,n,t,i)||se(t,!0)}else gr(t),t.stateNode=io(i,e,n,t)}return Er(t),null;case 31:if(n=t.memoizedState,e===null||e.memoizedState!==null){if(i=ue(t),n!==null){if(e===null){if(!i)throw Error(r(318));if(!fo)throw Error(r(556));if(e=t.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(r(557));Ds(e,t)}else de(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Er(t),e=!1}else n=fe(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=n),e=!0;if(!e)return t.flags&256?(vt(t),t):(vt(t),null);if(t.flags&128)throw Error(r(558))}return Er(t),null;case 13:if(i=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(a=ue(t),i!==null&&i.dehydrated!==null){if(e===null){if(!a)throw Error(r(318));if(!fo)throw Error(r(344));if(a=t.memoizedState,a=a===null?null:a.dehydrated,!a)throw Error(r(317));Os(a,t)}else de(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Er(t),a=!1}else a=fe(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=a),a=!0;if(!a)return t.flags&256?(vt(t),t):(vt(t),null)}return vt(t),t.flags&128?(t.lanes=n,t):(n=i!==null,e=e!==null&&e.memoizedState!==null,n&&(i=t.child,a=null,i.alternate!==null&&i.alternate.memoizedState!==null&&i.alternate.memoizedState.cachePool!==null&&(a=i.alternate.memoizedState.cachePool.pool),o=null,i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(o=i.memoizedState.cachePool.pool),o!==a&&(i.flags|=2048)),n!==e&&n&&(t.child.flags|=8192),wr(t,t.updateQueue),Er(t),null);case 4:return ae(),br(e,t),e===null&&mo(t.stateNode.containerInfo),Er(t),null;case 10:return he(t.type),Er(t),null;case 19:if(f(Vl),i=t.memoizedState,i===null)return Er(t),null;if(a=(t.flags&128)!=0,o=i.rendering,o===null)if(a)Tr(i,!1);else{if(Pu!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(o=yt(e),o!==null){for(t.flags|=128,Tr(i,!1),e=o.updateQueue,t.updateQueue=e,wr(t,e),t.subtreeFlags=0,e=n,n=t.child;n!==null;)ua(n,e),n=n.sibling;return p(Vl,Vl.current&1|2),el&&P(t,i.treeForkCount),t.child}e=e.sibling}i.tail!==null&&Cc()>Gu&&(t.flags|=128,a=!0,Tr(i,!1),t.lanes=4194304)}else{if(!a)if(e=yt(o),e!==null){if(t.flags|=128,a=!0,e=e.updateQueue,t.updateQueue=e,wr(t,e),Tr(i,!0),i.tail===null&&i.tailMode===`hidden`&&!o.alternate&&!el)return Er(t),null}else 2*Cc()-i.renderingStartTime>Gu&&n!==536870912&&(t.flags|=128,a=!0,Tr(i,!1),t.lanes=4194304);i.isBackwards?(o.sibling=t.child,t.child=o):(e=i.last,e===null?t.child=o:e.sibling=o,i.last=o)}return i.tail===null?(Er(t),null):(e=i.tail,i.rendering=e,i.tail=e.sibling,i.renderingStartTime=Cc(),e.sibling=null,n=Vl.current,p(Vl,a?n&1|2:n&1),el&&P(t,i.treeForkCount),e);case 22:case 23:return vt(t),pt(),i=t.memoizedState!==null,e===null?i&&(t.flags|=8192):e.memoizedState!==null!==i&&(t.flags|=8192),i?n&536870912&&!(t.flags&128)&&(Er(t),t.subtreeFlags&6&&(t.flags|=8192)):Er(t),n=t.updateQueue,n!==null&&wr(t,n.retryQueue),n=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),i=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(i=t.memoizedState.cachePool.pool),i!==n&&(t.flags|=2048),e!==null&&f(Sl),null;case 24:return n=null,e!==null&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),he(ul),Er(t),null;case 25:return null;case 30:return null}throw Error(r(156,t.tag))}function Or(e,t){switch(re(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return he(ul),ae(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return oe(t),null;case 31:if(t.memoizedState!==null){if(vt(t),t.alternate===null)throw Error(r(340));de()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(vt(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(r(340));de()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return f(Vl),null;case 4:return ae(),null;case 10:return he(t.type),null;case 22:case 23:return vt(t),pt(),e!==null&&f(Sl),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return he(ul),null;case 25:return null;default:return null}}function kr(e,t){switch(re(t),t.tag){case 3:he(ul),ae();break;case 26:case 27:case 5:oe(t);break;case 4:ae();break;case 31:t.memoizedState!==null&&vt(t);break;case 13:vt(t);break;case 19:f(Vl);break;case 10:he(t.type);break;case 22:case 23:vt(t),pt(),e!==null&&f(Sl);break;case 24:he(ul)}}function Ar(e,t){try{var n=t.updateQueue,r=n===null?null:n.lastEffect;if(r!==null){var i=r.next;n=i;do{if((n.tag&e)===e){r=void 0;var a=n.create,o=n.inst;r=a(),o.destroy=r}n=n.next}while(n!==i)}}catch(e){ea(t,t.return,e)}}function jr(e,t,n){try{var r=t.updateQueue,i=r===null?null:r.lastEffect;if(i!==null){var a=i.next;r=a;do{if((r.tag&e)===e){var o=r.inst,s=o.destroy;if(s!==void 0){o.destroy=void 0,i=t;var c=n,l=s;try{l()}catch(e){ea(i,c,e)}}}r=r.next}while(r!==a)}}catch(e){ea(t,t.return,e)}}function Mr(e){var t=e.updateQueue;if(t!==null){var n=e.stateNode;try{ut(t,n)}catch(t){ea(e,e.return,t)}}}function Nr(e,t,n){n.props=W(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(n){ea(e,t,n)}}function Pr(e,t){try{var n=e.ref;if(n!==null){switch(e.tag){case 26:case 27:case 5:var r=Ya(e.stateNode);break;case 30:r=e.stateNode;break;default:r=e.stateNode}typeof n==`function`?e.refCleanup=n(r):n.current=r}}catch(n){ea(e,t,n)}}function Fr(e,t){var n=e.ref,r=e.refCleanup;if(n!==null)if(typeof r==`function`)try{r()}catch(n){ea(e,t,n)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof n==`function`)try{n(null)}catch(n){ea(e,t,n)}else n.current=null}function Ir(e){var t=e.type,n=e.memoizedProps,r=e.stateNode;try{Uo(r,t,n,e)}catch(t){ea(e,e.return,t)}}function Lr(e,t,n){try{Wo(e.stateNode,e.type,n,t,e)}catch(t){ea(e,e.return,t)}}function Rr(e){return e.tag===5||e.tag===3||(Ws?e.tag===26:!1)||(ic?e.tag===27&&lc(e.type):!1)||e.tag===4}function zr(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Rr(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(ic&&e.tag===27&&lc(e.type)||e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Br(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?Ko(n,e,t):Vo(n,e);else if(r!==4&&(ic&&r===27&&lc(e.type)&&(n=e.stateNode,t=null),e=e.child,e!==null))for(Br(e,t,n),e=e.sibling;e!==null;)Br(e,t,n),e=e.sibling}function Vr(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?Go(n,e,t):Bo(n,e);else if(r!==4&&(ic&&r===27&&lc(e.type)&&(n=e.stateNode),e=e.child,e!==null))for(Vr(e,t,n),e=e.sibling;e!==null;)Vr(e,t,n),e=e.sibling}function Hr(e,t,n){e=e.containerInfo;try{as(e,n)}catch(e){ea(t,t.return,e)}}function K(e){var t=e.stateNode,n=e.memoizedProps;try{oc(e.type,n,t,e)}catch(t){ea(e,e.return,t)}}function Ur(e,t){for(Qa(e.containerInfo),du=t;du!==null;)if(e=du,t=e.child,e.subtreeFlags&1028&&t!==null)t.return=e,du=t;else for(;du!==null;){e=du;var n=e.alternate;switch(t=e.flags,e.tag){case 0:if(t&4&&(t=e.updateQueue,t=t===null?null:t.events,t!==null))for(var i=0;i`;case vu:return`:has(`+(bi(e)||``)+`)`;case yu:return`[role="`+e.value+`"]`;case xu:return`"`+e.value+`"`;case bu:return`[data-testname="`+e.value+`"]`;default:throw Error(r(365))}}function xi(e,t){var n=[];e=[e,0];for(var r=0;rn?32:n;n=Ga.T;var a=go();try{ho(i),Ga.T=null,i=$u,$u=null;var o=Yu,s=Zu;if(Ju=0,Xu=Yu=null,Zu=0,wu&6)throw Error(r(331));var c=wu;if(wu|=4,hi(o.current),ci(o,o.current,s,i),wu=c,z(0,!1),jc&&typeof jc.onPostCommitFiberRoot==`function`)try{jc.onPostCommitFiberRoot(Ac,o)}catch{}return!0}finally{ho(a),Ga.T=n,Xi(e,t)}}function $i(e,t,n){t=N(n,t),t=Ln(e.stateNode,t,2),e=it(e,t,2),e!==null&&(S(e,2),Ee(e))}function ea(e,t,n){if(e.tag===3)$i(e,e,n);else for(;t!==null;){if(t.tag===3){$i(t,e,n);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError==`function`||typeof r.componentDidCatch==`function`&&(qu===null||!qu.has(r))){e=N(n,e),n=Rn(2),r=it(t,n,2),r!==null&&(zn(n,r,t,e),S(r,2),Ee(r));break}}t=t.return}}function ta(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new Cu;var i=new Set;r.set(t,i)}else i=r.get(t),i===void 0&&(i=new Set,r.set(t,i));i.has(n)||(Mu=!0,i.add(n),e=na.bind(null,e,t,n),t.then(e,e))}function na(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,Tu===e&&(Du&n)===n&&(Pu===4||Pu===3&&(Du&62914560)===Du&&300>Cc()-Uu?!(wu&2)&&Mi(e,0):Lu|=n,zu===Du&&(zu=0)),Ee(e)}function ra(e,t){t===0&&(t=y()),e=Qe(e,t),e!==null&&(S(e,t),Ee(e))}function ia(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),ra(e,n)}function aa(e,t){var n=0;switch(e.tag){case 31:case 13:var i=e.stateNode,a=e.memoizedState;a!==null&&(n=a.retryLane);break;case 19:i=e.stateNode;break;case 22:i=e.stateNode._retryCache;break;default:throw Error(r(314))}i!==null&&i.delete(t),ra(e,n)}function oa(e,t){return yc(e,t)}function sa(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function ca(e){return e=e.prototype,!(!e||!e.isReactComponent)}function la(e,n){var r=e.alternate;return r===null?(r=t(e.tag,n,e.key,e.mode),r.elementType=e.elementType,r.type=e.type,r.stateNode=e.stateNode,r.alternate=e,e.alternate=r):(r.pendingProps=n,r.type=e.type,r.flags=0,r.subtreeFlags=0,r.deletions=null),r.flags=e.flags&65011712,r.childLanes=e.childLanes,r.lanes=e.lanes,r.child=e.child,r.memoizedProps=e.memoizedProps,r.memoizedState=e.memoizedState,r.updateQueue=e.updateQueue,n=e.dependencies,r.dependencies=n===null?null:{lanes:n.lanes,firstContext:n.firstContext},r.sibling=e.sibling,r.index=e.index,r.ref=e.ref,r.refCleanup=e.refCleanup,r}function ua(e,t){e.flags&=65011714;var n=e.alternate;return n===null?(e.childLanes=0,e.lanes=t,e.child=null,e.subtreeFlags=0,e.memoizedProps=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.stateNode=null):(e.childLanes=n.childLanes,e.lanes=n.lanes,e.child=n.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=n.memoizedProps,e.memoizedState=n.memoizedState,e.updateQueue=n.updateQueue,e.type=n.type,t=n.dependencies,e.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),e}function da(e,n,i,a,o,s){var c=0;if(a=e,typeof e==`function`)ca(e)&&(c=1);else if(typeof e==`string`)c=Ws&&ic?Gs(e,i,Jc.current)?26:cc(e)?27:5:Ws?Gs(e,i,Jc.current)?26:5:ic&&cc(e)?27:5;else e:switch(e){case Ba:return e=t(31,i,n,o),e.elementType=Ba,e.lanes=s,e;case Aa:return fa(i.children,o,s,n);case ja:c=8,o|=24;break;case Ma:return e=t(12,i,n,o|2),e.elementType=Ma,e.lanes=s,e;case Ia:return e=t(13,i,n,o),e.elementType=Ia,e.lanes=s,e;case La:return e=t(19,i,n,o),e.elementType=La,e.lanes=s,e;default:if(typeof e==`object`&&e)switch(e.$$typeof){case Pa:c=10;break e;case Na:c=9;break e;case Fa:c=11;break e;case Ra:c=14;break e;case za:c=16,a=null;break e}c=29,i=Error(r(130,e===null?`null`:typeof e,``)),a=null}return n=t(c,i,n,o),n.elementType=e,n.type=a,n.lanes=s,n}function fa(e,n,r,i){return e=t(7,e,i,n),e.lanes=r,e}function pa(e,n,r){return e=t(6,e,null,n),e.lanes=r,e}function ma(e){var n=t(18,null,null,0);return n.stateNode=e,n}function ha(e,n,r){return n=t(4,e.children===null?[]:e.children,e.key,n),n.lanes=r,n.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},n}function ga(e,t,n,r,i,a,o,s,c){this.tag=1,this.containerInfo=e,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=so,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=x(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=x(0),this.hiddenUpdates=x(null),this.identifierPrefix=r,this.onUncaughtError=i,this.onCaughtError=a,this.onRecoverableError=o,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=c,this.incompleteTransitions=new Map}function _a(e,n,r,i,a,o,s,c,l,u,d,f){return e=new ga(e,n,r,s,l,u,d,f,c),n=1,o===!0&&(n|=24),o=t(3,null,null,n),e.current=o,o.stateNode=e,n=R(),n.refCount++,e.pooledCache=n,n.refCount++,o.memoizedState={element:i,isDehydrated:r,cache:n},tt(o),e}function va(e){return e?(e=fc,e):fc}function ya(e){var t=e._reactInternals;if(t===void 0)throw typeof e.render==`function`?Error(r(188)):(e=Object.keys(e).join(`,`),Error(r(268,e)));return e=o(t),e=e===null?null:s(e),e===null?null:Ya(e.stateNode)}function ba(e,t,n,r,i,a){i=va(i),r.context===null?r.context=i:r.pendingContext=i,r=rt(t),r.payload={element:n},a=a===void 0?null:a,a!==null&&(r.callback=a),n=it(e,r,t),n!==null&&(Ti(n,e,t),at(n,e,t))}function xa(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n=u&&o>=f&&a<=d&&s<=p){e.splice(t,1);break}else if(i!==u||n.width!==l.width||ps){if(!(o!==f||n.height!==l.height||da)){u>i&&(l.width+=u-i,l.x=i),do&&(l.height+=f-o,l.y=o),pn&&(n=c)),c `)+` No matching component was found for: `)+e.join(` > `)}return null},Ca.getPublicRootInstance=function(e){if(e=e.current,!e.child)return null;switch(e.child.tag){case 27:case 5:return Ya(e.child.stateNode);default:return e.child.stateNode}},Ca.injectIntoDevTools=function(){var e={bundleType:0,version:Ka,rendererPackageName:qa,currentDispatcherRef:Ga,reconcilerVersion:`19.2.0`};if(Ja!==null&&(e.rendererConfig=Ja),typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`)e=!1;else{var t=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(t.isDisabled||!t.supportsFiber)e=!0;else{try{Ac=t.inject(e),jc=t}catch{}e=!!t.checkDCE}}return e},Ca.isAlreadyRendering=function(){return(wu&6)!=0},Ca.observeVisibleRects=function(e,t,n,i){if(!Mo)throw Error(r(363));e=Si(e,t);var a=zo(e,n,i).disconnect;return{disconnect:function(){a()}}},Ca.shouldError=function(){return null},Ca.shouldSuspend=function(){return!1},Ca.startHostTransition=function(e,t,i,a){if(e.tag!==5)throw Error(r(476));var o=xn(e).queue;bn(e,o,t,Do,i===null?n:function(){var t=xn(e);return t.next===null&&(t=e.alternate.memoizedState),On(e,t.next.queue,{},Ci()),i(a)})},Ca.updateContainer=function(e,t,n,r){var i=t.current,a=Ci();return ba(i,a,e,t,n,r),a},Ca.updateContainerSync=function(e,t,n,r){return ba(t.current,2,e,t,n,r),2},Ca},e.exports.default=e.exports,Object.defineProperty(e.exports,"__esModule",{value:!0})}(K_)),K_.exports}({exports:{}}).exports;var Y_;function X_(){return Y_||(Y_=1,G_.exports=J_()),G_.exports}var Z_=W_(X_());function Q_(e){let t=Z_(e);return t.injectIntoDevTools(),t}var $_=0,ev={},tv=/^three(?=[A-Z])/,nv=e=>`${e[0].toUpperCase()}${e.slice(1)}`,rv=0,iv=e=>typeof e==`function`;function av(e){if(iv(e)){let t=`${rv++}`;return ev[t]=e,t}else Object.assign(ev,e)}function ov(e,t){let n=nv(e),r=ev[n];if(e!==`primitive`&&!r)throw Error(`R3F: ${n} is not part of the THREE namespace! Did you forget to extend? See: https://docs.pmnd.rs/react-three-fiber/api/objects#using-3rd-party-objects-declaratively`);if(e===`primitive`&&!t.object)throw Error(`R3F: Primitives without 'object' are invalid!`);if(t.args!==void 0&&!Array.isArray(t.args))throw Error(`R3F: The args prop must be an array!`)}function sv(e,t,n){var r;return e=nv(e)in ev?e:e.replace(tv,``),ov(e,t),e===`primitive`&&(r=t.object)!=null&&r.__r3f&&delete t.object.__r3f,l_(t.object,n,e,t)}function cv(e){if(!e.isHidden){var t;e.props.attach&&(t=e.parent)!=null&&t.object?p_(e.parent,e):C_(e.object)&&(e.object.visible=!1),e.isHidden=!0,x_(e)}}function lv(e){if(e.isHidden){var t;e.props.attach&&(t=e.parent)!=null&&t.object?f_(e.parent,e):C_(e.object)&&e.props.visible!==!1&&(e.object.visible=!0),e.isHidden=!1,x_(e)}}function uv(e,t,n){let r=t.root.getState();if(!(!e.parent&&e.object!==r.scene)){if(!t.object){let e=ev[nv(t.type)];t.object=t.props.object??new e(...t.props.args??[]),t.object.__r3f=t}if(b_(t.object,t.props),t.props.attach)f_(e,t);else if(C_(t.object)&&C_(e.object)){let r=e.object.children.indexOf(n?.object);if(n&&r!==-1){let n=e.object.children.indexOf(t.object);if(n!==-1){e.object.children.splice(n,1);let i=n{try{e.dispose()}catch{}};typeof IS_REACT_ACT_ENVIRONMENT<`u`?t():(0,Lg.unstable_scheduleCallback)(Lg.unstable_IdlePriority,t)}}function mv(e,t,n){if(!t)return;t.parent=null;let r=e.children.indexOf(t);r!==-1&&e.children.splice(r,1),t.props.attach?p_(e,t):C_(t.object)&&C_(e.object)&&(e.object.remove(t.object),D_(qg(t),t.object));let i=t.props.dispose!==null&&n!==!1;for(let e=t.children.length-1;e>=0;e--){let n=t.children[e];mv(t,n,i)}t.children.length=0,delete t.object.__r3f,i&&t.type!==`primitive`&&t.object.type!==`Scene`&&pv(t.object),n===void 0&&x_(t)}function hv(e,t){for(let n of[e,e.alternate])if(n!==null)if(typeof n.ref==`function`){n.refCleanup==null||n.refCleanup();let e=n.ref(t);typeof e==`function`&&(n.refCleanup=e)}else n.ref&&(n.ref.current=t)}var gv=[];function _v(){for(let[e]of gv){let t=e.parent;if(t){e.props.attach?p_(t,e):C_(e.object)&&C_(t.object)&&t.object.remove(e.object);for(let t of e.children)t.props.attach?p_(e,t):C_(t.object)&&C_(e.object)&&e.object.remove(t.object)}e.isHidden&&lv(e),e.object.__r3f&&delete e.object.__r3f,e.type!==`primitive`&&pv(e.object)}for(let[e,t,n]of gv){e.props=t;let r=e.parent;if(r){let t=ev[nv(e.type)],i=e.object;e.object=e.props.object??new t(...e.props.args??[]),e.object.__r3f=e,hv(n,e.object),E_(qg(e),i,e.object),b_(e.object,e.props),e.props.attach?f_(r,e):C_(e.object)&&C_(r.object)&&r.object.add(e.object);for(let t of e.children)t.props.attach?f_(e,t):C_(t.object)&&C_(e.object)&&e.object.add(t.object);x_(e)}}gv.length=0}var vv=()=>{},yv={},bv=$_,xv=0,Sv=4,Cv=Q_({isPrimaryRenderer:!1,warnsIfNotActing:!1,supportsMutation:!0,supportsPersistence:!1,supportsHydration:!1,createInstance:sv,removeChild:mv,appendChild:dv,appendInitialChild:dv,insertBefore:fv,appendChildToContainer(e,t){let n=e.getState().scene.__r3f;!t||!n||dv(n,t)},removeChildFromContainer(e,t){let n=e.getState().scene.__r3f;!t||!n||mv(n,t)},insertInContainerBefore(e,t,n){let r=e.getState().scene.__r3f;!t||!n||!r||fv(r,t,n)},getRootHostContext:()=>yv,getChildHostContext:()=>yv,commitUpdate(e,t,n,r,i){var a;ov(t,r);let o=!1;if(e.type===`primitive`&&n.object!==r.object?o=!0:r.args?.length===n.args?.length?(a=r.args)!=null&&a.some((e,t)=>e!==n.args?.[t])&&(o=!0):o=!0,o)gv.push([e,{...r},i]);else{let t=__(e,r);Object.keys(t).length&&(Object.assign(e.props,t),b_(e.object,t))}(i.sibling===null||(i.flags&Sv)===xv)&&_v()},finalizeInitialChildren:()=>!1,commitMount(){},getPublicInstance:e=>e?.object,prepareForCommit:()=>null,preparePortalMount:e=>l_(e.getState().scene,e,``,{}),resetAfterCommit:()=>{},shouldSetTextContent:()=>!1,clearContainer:()=>!1,hideInstance:cv,unhideInstance:lv,createTextInstance:vv,hideTextInstance:vv,unhideTextInstance:vv,scheduleTimeout:typeof setTimeout==`function`?setTimeout:void 0,cancelTimeout:typeof clearTimeout==`function`?clearTimeout:void 0,noTimeout:-1,getInstanceFromNode:()=>null,beforeActiveInstanceBlur(){},afterActiveInstanceBlur(){},detachDeletedInstance(){},prepareScopeUpdate(){},getInstanceFromScope:()=>null,shouldAttemptEagerTransition:()=>!1,trackSchedulerEvent:()=>{},resolveEventType:()=>null,resolveEventTimeStamp:()=>-1.1,requestPostPaintCallback(){},maySuspendCommit:()=>!1,preloadInstance:()=>!0,suspendInstance(){},waitForCommitToBeReady:()=>null,NotPendingTransition:null,HostTransitionContext:b.createContext(null),setCurrentUpdatePriority(e){bv=e},getCurrentUpdatePriority(){return bv},resolveUpdatePriority(){if(bv!==$_)return bv;switch(typeof window<`u`&&window.event?.type){case`click`:case`contextmenu`:case`dblclick`:case`pointercancel`:case`pointerdown`:case`pointerup`:return H_;case`pointermove`:case`pointerout`:case`pointerover`:case`pointerenter`:case`pointerleave`:case`wheel`:return B_;default:return V_}},resetFormInstance(){},rendererPackageName:`@react-three/fiber`,rendererVersion:U_.version,applyViewTransitionName(e,t,n){},restoreViewTransitionName(e,t){},cancelViewTransitionName(e,t,n){},cancelRootViewTransitionName(e){},restoreRootViewTransitionName(e){},InstanceMeasurement:null,measureInstance:e=>null,wasInstanceInViewport:e=>!0,hasInstanceChanged:(e,t)=>!1,hasInstanceAffectedParent:(e,t)=>!1,suspendOnActiveViewTransition(e,t){},startGestureTransition:()=>null,startViewTransition:()=>null,stopViewTransition(e){},createViewTransitionInstance:e=>null,getCurrentGestureOffset(e){throw Error(`startGestureTransition is not yet supported in react-three-fiber.`)},cloneMutableInstance(e,t){return e},cloneMutableTextInstance(e){return e},cloneRootViewTransitionContainer(e){throw Error(`Not implemented.`)},removeRootViewTransitionClone(e,t){throw Error(`Not implemented.`)},createFragmentInstance:e=>null,updateFragmentInstanceFiber(e,t){},commitNewChildToFragmentInstance(e,t){},deleteChildFromFragmentInstance(e,t){},measureClonedInstance:e=>null,maySuspendCommitOnUpdate:(e,t,n)=>!1,maySuspendCommitInSyncRender:(e,t)=>!1,startSuspendingCommit:()=>null,getSuspendedCommitReason:(e,t)=>null}),wv=new Map,Tv={objects:`shallow`,strict:!1};function Ev(e,t){if(!t&&typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement&&e.parentElement){let{width:t,height:n,top:r,left:i}=e.parentElement.getBoundingClientRect();return{width:t,height:n,top:r,left:i}}else if(!t&&typeof OffscreenCanvas<`u`&&e instanceof OffscreenCanvas)return{width:e.width,height:e.height,top:0,left:0};return{width:0,height:0,top:0,left:0,...t}}function Dv(e){let t=wv.get(e),n=t?.fiber,r=t?.store;t&&console.warn(`R3F.createRoot should only be called once!`);let i=typeof reportError==`function`?reportError:console.error,a=r||j_(Kv,qv),o=n||Cv.createContainer(a,z_,null,!1,null,``,i,i,i,null);t||wv.set(e,{fiber:o,store:a});let s,c,l=!1,u=null;return{async configure(t={}){let n;u=new Promise(e=>n=e);let{gl:r,size:i,scene:o,events:d,onCreated:f,shadows:p=!1,linear:m=!1,flat:h=!1,legacy:g=!1,orthographic:_=!1,frameloop:v=`always`,dpr:y=[1,2],performance:b,raycaster:x,camera:S,onPointerMissed:C}=t,w=a.getState(),T=w.gl;if(!w.gl){let t={canvas:e,powerPreference:`high-performance`,antialias:!0,alpha:!0},n=typeof r==`function`?await r(t):r;T=k_(n)?n:new gg({...t,...r}),w.set({gl:T})}let E=w.raycaster;E||w.set({raycaster:E=new Xd});let{params:D,...O}=x||{};if(i_.equ(O,E,Tv)||b_(E,{...O}),i_.equ(D,E.params,Tv)||b_(E,{params:{...E.params,...D}}),!w.camera||w.camera===c&&!i_.equ(c,S,Tv)){c=S;let e=S?.isCamera,t=e?S:_?new Lu(0,0,0,0,.1,1e3):new Mu(75,0,.1,1e3);e||(t.position.z=5,S&&(b_(t,S),t.manual||(`aspect`in S||`left`in S||`right`in S||`bottom`in S||`top`in S)&&(t.manual=!0,t.updateProjectionMatrix())),!w.camera&&!(S!=null&&S.rotation)&&t.lookAt(0,0,0)),w.set({camera:t}),E.camera=t}if(!w.scene){let e;o!=null&&o.isScene?(e=o,l_(e,a,``,{})):(e=new Kr,l_(e,a,``,{}),o&&b_(e,o)),w.set({scene:e})}d&&!w.events.handlers&&w.set({events:d(a)});let k=Ev(e,i);if(i_.equ(k,w.size,Tv)||w.setSize(k.width,k.height,k.top,k.left),y&&w.viewport.dpr!==n_(y)&&w.setDpr(y),w.frameloop!==v&&w.setFrameloop(v),w.onPointerMissed||w.set({onPointerMissed:C}),b&&!i_.equ(b,w.performance,Tv)&&w.set(e=>({performance:{...e.performance,...b}})),!w.xr){let e=(e,t)=>{let n=a.getState();n.frameloop!==`never`&&qv(e,!0,n,t)},t=()=>{let t=a.getState();t.gl.xr.enabled=t.gl.xr.isPresenting,t.gl.xr.setAnimationLoop(t.gl.xr.isPresenting?e:null),t.gl.xr.isPresenting||Kv(t)},n={connect(){let e=a.getState().gl;e.xr.addEventListener(`sessionstart`,t),e.xr.addEventListener(`sessionend`,t)},disconnect(){let e=a.getState().gl;e.xr.removeEventListener(`sessionstart`,t),e.xr.removeEventListener(`sessionend`,t)}};typeof T.xr?.addEventListener==`function`&&n.connect(),w.set({xr:n})}if(T.shadowMap){let e=T.shadowMap.enabled,t=T.shadowMap.type;if(T.shadowMap.enabled=!!p,i_.boo(p))T.shadowMap.type=2;else if(i_.str(p)){let e={basic:0,percentage:1,soft:2,variance:3};T.shadowMap.type=e[p]??2}else i_.obj(p)&&Object.assign(T.shadowMap,p);(e!==T.shadowMap.enabled||t!==T.shadowMap.type)&&(T.shadowMap.needsUpdate=!0)}return Wn.enabled=!g,l||(T.outputColorSpace=m?xt:bt,T.toneMapping=h?0:4),w.legacy!==g&&w.set(()=>({legacy:g})),w.linear!==m&&w.set(()=>({linear:m})),w.flat!==h&&w.set(()=>({flat:h})),r&&!i_.fun(r)&&!k_(r)&&!i_.equ(r,T,Tv)&&b_(T,r),s=f,l=!0,n(),this},render(t){return!l&&!u&&this.configure(),u.then(()=>{Cv.updateContainer((0,X.jsx)(Ov,{store:a,children:t,onCreated:s,rootElement:e}),o,null,()=>void 0)}),a},unmount(){kv(e)}}}function Ov({store:e,children:t,onCreated:n,rootElement:r}){return Zg(()=>{let t=e.getState();t.set(e=>({internal:{...e.internal,active:!0}})),n&&n(t),e.getState().events.connected||t.events.connect==null||t.events.connect(r)},[]),(0,X.jsx)(A_.Provider,{value:e,children:t})}function kv(e,t){let n=wv.get(e),r=n?.fiber;if(r){let i=n?.store.getState();i&&(i.internal.active=!1),Cv.updateContainer(null,r,null,()=>{i&&setTimeout(()=>{try{var n,r,a,o;i.events.disconnect==null||i.events.disconnect(),(n=i.gl)==null||(r=n.renderLists)==null||r.dispose==null||r.dispose(),(a=i.gl)==null||a.forceContextLoss==null||a.forceContextLoss(),(o=i.gl)!=null&&o.xr&&i.xr.disconnect(),o_(i.scene),wv.delete(e),t&&t(e)}catch{}},500)})}}function Av(e,t,n){return(0,X.jsx)(jv,{children:e,container:t,state:n})}function jv({state:e={},children:t,container:n}){let{events:r,size:i,...a}=e,o=M_(),[s]=b.useState(()=>new Xd),[c]=b.useState(()=>new W),l=Qg((e,t)=>{let a;if(t.camera&&i){let n=t.camera;a=e.viewport.getCurrentViewport(n,new G,i),n!==e.camera&&S_(n,i)}return{...e,...t,scene:n,raycaster:s,pointer:c,mouse:c,previousRoot:o,events:{...e.events,...t.events,...r},size:{...e.size,...i},viewport:{...e.viewport,...a},setEvents:e=>t.set(t=>({...t,events:{...t.events,...e}}))}}),u=b.useMemo(()=>{let e=Dg((e,t)=>({...a,set:e,get:t})),t=t=>e.setState(e=>l.current(t,e));return t(o.getState()),o.subscribe(t),e},[o,n]);return(0,X.jsx)(X.Fragment,{children:Cv.createPortal((0,X.jsx)(A_.Provider,{value:u,children:t}),u,null)})}var Mv=new Set,Nv=new Set,Pv=new Set;function Fv(e,t){if(e.size)for(let{callback:n}of e.values())n(t)}function Iv(e,t){switch(e){case`before`:return Fv(Mv,t);case`after`:return Fv(Nv,t);case`tail`:return Fv(Pv,t)}}var Lv,Rv;function zv(e,t,n){let r=t.clock.getDelta();t.frameloop===`never`&&typeof e==`number`&&(r=e-t.clock.elapsedTime,t.clock.oldTime=t.clock.elapsedTime,t.clock.elapsedTime=e),Lv=t.internal.subscribers;for(let e=0;e0)&&!((t=Wv.gl.xr)!=null&&t.isPresenting)&&(Hv+=zv(e,Wv))}if(Vv=!1,Iv(`after`,e),Hv===0)return Iv(`tail`,e),Bv=!1,cancelAnimationFrame(Uv)}function Kv(e,t=1){var n;if(!e)return wv.forEach(e=>Kv(e.store.getState(),t));(n=e.gl.xr)!=null&&n.isPresenting||!e.internal.active||e.frameloop===`never`||(t>1?e.internal.frames=Math.min(60,e.internal.frames+t):Vv?e.internal.frames=2:e.internal.frames=1,Bv||(Bv=!0,requestAnimationFrame(Gv)))}function qv(e,t=!0,n,r){if(t&&Iv(`before`,e),n)zv(e,n,r);else for(let t of wv.values())zv(e,t.store.getState());t&&Iv(`after`,e)}var Jv={onClick:[`click`,!1],onContextMenu:[`contextmenu`,!1],onDoubleClick:[`dblclick`,!1],onWheel:[`wheel`,!0],onPointerDown:[`pointerdown`,!0],onPointerUp:[`pointerup`,!0],onPointerLeave:[`pointerleave`,!0],onPointerMove:[`pointermove`,!0],onPointerCancel:[`pointercancel`,!0],onLostPointerCapture:[`lostpointercapture`,!0]};function Yv(e){let{handlePointer:t}=O_(e);return{priority:1,enabled:!0,compute(e,t,n){t.pointer.set(e.offsetX/t.size.width*2-1,-(e.offsetY/t.size.height)*2+1),t.raycaster.setFromCamera(t.pointer,t.camera)},connected:void 0,handlers:Object.keys(Jv).reduce((e,n)=>({...e,[n]:t(n)}),{}),update:()=>{var t;let{events:n,internal:r}=e.getState();(t=r.lastEvent)!=null&&t.current&&n.handlers&&n.handlers.onPointerMove(r.lastEvent.current)},connect:t=>{let{set:n,events:r}=e.getState();if(r.disconnect==null||r.disconnect(),n(e=>({events:{...e.events,connected:t}})),r.handlers)for(let e in r.handlers){let n=r.handlers[e],[i,a]=Jv[e];t.addEventListener(i,n,{passive:a})}},disconnect:()=>{let{set:t,events:n}=e.getState();if(n.connected){if(n.handlers)for(let e in n.handlers){let t=n.handlers[e],[r]=Jv[e];n.connected.removeEventListener(r,t)}t(e=>({events:{...e.events,connected:void 0}}))}}}}function Xv(e,t){let n;return(...r)=>{window.clearTimeout(n),n=window.setTimeout(()=>e(...r),t)}}function Zv({debounce:e,scroll:t,polyfill:n,offsetSize:r}={debounce:0,scroll:!1,offsetSize:!1}){let i=n||(typeof window>`u`?class{}:window.ResizeObserver);if(!i)throw Error(`This browser does not support ResizeObserver out of the box. See: https://github.com/react-spring/react-use-measure/#resize-observer-polyfills`);let[a,o]=(0,b.useState)({left:0,top:0,width:0,height:0,bottom:0,right:0,x:0,y:0}),s=(0,b.useRef)({element:null,scrollContainers:null,resizeObserver:null,lastBounds:a,orientationHandler:null}),c=e?typeof e==`number`?e:e.scroll:null,l=e?typeof e==`number`?e:e.resize:null,u=(0,b.useRef)(!1);(0,b.useEffect)(()=>(u.current=!0,()=>void(u.current=!1)));let[d,f,p]=(0,b.useMemo)(()=>{let e=()=>{if(!s.current.element)return;let{left:e,top:t,width:n,height:i,bottom:a,right:c,x:l,y:d}=s.current.element.getBoundingClientRect(),f={left:e,top:t,width:n,height:i,bottom:a,right:c,x:l,y:d};s.current.element instanceof HTMLElement&&r&&(f.height=s.current.element.offsetHeight,f.width=s.current.element.offsetWidth),Object.freeze(f),u.current&&!ny(s.current.lastBounds,f)&&o(s.current.lastBounds=f)};return[e,l?Xv(e,l):e,c?Xv(e,c):e]},[o,r,c,l]);function m(){s.current.scrollContainers&&(s.current.scrollContainers.forEach(e=>e.removeEventListener(`scroll`,p,!0)),s.current.scrollContainers=null),s.current.resizeObserver&&(s.current.resizeObserver.disconnect(),s.current.resizeObserver=null),s.current.orientationHandler&&(`orientation`in screen&&`removeEventListener`in screen.orientation?screen.orientation.removeEventListener(`change`,s.current.orientationHandler):`onorientationchange`in window&&window.removeEventListener(`orientationchange`,s.current.orientationHandler))}function h(){s.current.element&&(s.current.resizeObserver=new i(p),s.current.resizeObserver.observe(s.current.element),t&&s.current.scrollContainers&&s.current.scrollContainers.forEach(e=>e.addEventListener(`scroll`,p,{capture:!0,passive:!0})),s.current.orientationHandler=()=>{p()},`orientation`in screen&&`addEventListener`in screen.orientation?screen.orientation.addEventListener(`change`,s.current.orientationHandler):`onorientationchange`in window&&window.addEventListener(`orientationchange`,s.current.orientationHandler))}return $v(p,!!t),Qv(f),(0,b.useEffect)(()=>{m(),h()},[t,p,f]),(0,b.useEffect)(()=>m,[]),[e=>{!e||e===s.current.element||(m(),s.current.element=e,s.current.scrollContainers=ey(e),h())},a,d]}function Qv(e){(0,b.useEffect)(()=>{let t=e;return window.addEventListener(`resize`,t),()=>void window.removeEventListener(`resize`,t)},[e])}function $v(e,t){(0,b.useEffect)(()=>{if(t){let t=e;return window.addEventListener(`scroll`,t,{capture:!0,passive:!0}),()=>void window.removeEventListener(`scroll`,t,!0)}},[e,t])}function ey(e){let t=[];if(!e||e===document.body)return t;let{overflow:n,overflowX:r,overflowY:i}=window.getComputedStyle(e);return[n,r,i].some(e=>e===`auto`||e===`scroll`)&&t.push(e),[...t,...ey(e.parentElement)]}var ty=[`x`,`y`,`top`,`bottom`,`left`,`right`,`width`,`height`],ny=(e,t)=>ty.every(n=>e[n]===t[n]);function ry({ref:e,children:t,fallback:n,resize:r,style:i,gl:a,events:o=Yv,eventSource:s,eventPrefix:c,shadows:l,linear:u,flat:d,legacy:f,orthographic:p,frameloop:m,dpr:h,performance:g,raycaster:_,camera:v,scene:y,onPointerMissed:x,onCreated:S,...C}){b.useMemo(()=>av($f),[]);let w=$g(),[T,E]=Zv({scroll:!0,debounce:{scroll:50,resize:0},...r}),D=b.useRef(null),O=b.useRef(null);b.useImperativeHandle(e,()=>D.current);let k=Qg(x),[A,j]=b.useState(!1),[ee,te]=b.useState(!1);if(A)throw A;if(ee)throw ee;let M=b.useRef(null);return Zg(()=>{let e=D.current;if(E.width>0&&E.height>0&&e){M.current||=Dv(e);async function n(){await M.current.configure({gl:a,scene:y,events:o,shadows:l,linear:u,flat:d,legacy:f,orthographic:p,frameloop:m,dpr:h,performance:g,raycaster:_,camera:v,size:E,onPointerMissed:(...e)=>k.current==null?void 0:k.current(...e),onCreated:e=>{e.events.connect==null||e.events.connect(s?Yg(s)?s.current:s:O.current),c&&e.setEvents({compute:(e,t)=>{let n=e[c+`X`],r=e[c+`Y`];t.pointer.set(n/t.size.width*2-1,-(r/t.size.height)*2+1),t.raycaster.setFromCamera(t.pointer,t.camera)}}),S?.(e)}}),M.current.render((0,X.jsx)(w,{children:(0,X.jsx)(t_,{set:te,children:(0,X.jsx)(b.Suspense,{fallback:(0,X.jsx)(e_,{set:j}),children:t??null})})}))}n()}}),b.useEffect(()=>{let e=D.current;if(e)return()=>kv(e)},[]),(0,X.jsx)(`div`,{ref:O,style:{position:`relative`,width:`100%`,height:`100%`,overflow:`hidden`,pointerEvents:s?`none`:`auto`,...i},...C,children:(0,X.jsx)(`div`,{ref:T,style:{width:`100%`,height:`100%`},children:(0,X.jsx)(`canvas`,{ref:D,style:{display:`block`},children:n})})})}function iy(e){return(0,X.jsx)(Vg,{children:(0,X.jsx)(ry,{...e})})}var ay=(0,b.createContext)({});function oy(e){let t=(0,b.useRef)(null);return t.current===null&&(t.current=e()),t.current}var sy=typeof window<`u`?b.useLayoutEffect:b.useEffect,cy=(0,b.createContext)(null);function ly(e,t){e.indexOf(t)===-1&&e.push(t)}function uy(e,t){let n=e.indexOf(t);n>-1&&e.splice(n,1)}var dy=(e,t,n)=>n>t?t:n/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(e),my=e=>typeof e==`object`&&!!e,hy=e=>/^0[^.\s]+$/u.test(e);function gy(e){let t;return()=>(t===void 0&&(t=e()),t)}var _y=e=>e,vy=(...e)=>e.reduce((e,t)=>n=>t(e(n))),yy=(e,t,n)=>{let r=t-e;return r?(n-e)/r:1},by=class{constructor(){this.subscriptions=[]}add(e){return ly(this.subscriptions,e),()=>uy(this.subscriptions,e)}notify(e,t,n){let r=this.subscriptions.length;if(r)if(r===1)this.subscriptions[0](e,t,n);else for(let i=0;ie*1e3,Sy=e=>e/1e3,Cy=(e,t)=>t?1e3/t*e:0,wy=(e,t,n)=>(((1-3*n+3*t)*e+(3*n-6*t))*e+3*t)*e,Ty=1e-7,Ey=12;function Dy(e,t,n,r,i){let a,o,s=0;do o=t+(n-t)/2,a=wy(o,r,i)-e,a>0?n=o:t=o;while(Math.abs(a)>Ty&&++sDy(t,0,1,e,n);return e=>e===0||e===1?e:wy(i(e),t,r)}var ky=e=>t=>t<=.5?e(2*t)/2:(2-e(2*(1-t)))/2,Ay=e=>t=>1-e(1-t),jy=Oy(.33,1.53,.69,.99),My=Ay(jy),Ny=ky(My),Py=e=>e>=1?1:(e*=2)<1?.5*My(e):.5*(2-2**(-10*(e-1))),Fy=e=>1-Math.sin(Math.acos(e)),Iy=Ay(Fy),Ly=ky(Fy),Ry=Oy(.42,0,1,1),zy=Oy(0,0,.58,1),By=Oy(.42,0,.58,1),Vy=e=>Array.isArray(e)&&typeof e[0]!=`number`,Hy=e=>Array.isArray(e)&&typeof e[0]==`number`,Uy={linear:_y,easeIn:Ry,easeInOut:By,easeOut:zy,circIn:Fy,circInOut:Ly,circOut:Iy,backIn:My,backInOut:Ny,backOut:jy,anticipate:Py},Wy=e=>typeof e==`string`,Gy=e=>{if(Hy(e)){e.length;let[t,n,r,i]=e;return Oy(t,n,r,i)}else if(Wy(e))return Uy[e],`${e}`,Uy[e];return e},Ky=[`setup`,`read`,`resolveKeyframes`,`preUpdate`,`update`,`preRender`,`render`,`postRender`],qy={value:null,addProjectionMetrics:null};function Jy(e,t){let n=new Set,r=new Set,i=!1,a=!1,o=new WeakSet,s={delta:0,timestamp:0,isProcessing:!1},c=0;function l(t){o.has(t)&&(u.schedule(t),e()),c++,t(s)}let u={schedule:(e,t=!1,a=!1)=>{let s=a&&i?n:r;return t&&o.add(e),s.add(e),e},cancel:e=>{r.delete(e),o.delete(e)},process:e=>{if(s=e,i){a=!0;return}i=!0;let o=n;n=r,r=o,n.forEach(l),t&&qy.value&&qy.value.frameloop[t].push(c),c=0,n.clear(),i=!1,a&&(a=!1,u.process(e))}};return u}var Yy=40;function Xy(e,t){let n=!1,r=!0,i={delta:0,timestamp:0,isProcessing:!1},a=()=>n=!0,o=Ky.reduce((e,n)=>(e[n]=Jy(a,t?n:void 0),e),{}),{setup:s,read:c,resolveKeyframes:l,preUpdate:u,update:d,preRender:f,render:p,postRender:m}=o,h=()=>{let a=fy.useManualTiming,o=a?i.timestamp:performance.now();n=!1,a||(i.delta=r?1e3/60:Math.max(Math.min(o-i.timestamp,Yy),1)),i.timestamp=o,i.isProcessing=!0,s.process(i),c.process(i),l.process(i),u.process(i),d.process(i),f.process(i),p.process(i),m.process(i),i.isProcessing=!1,n&&t&&(r=!1,e(h))},g=()=>{n=!0,r=!0,i.isProcessing||e(h)};return{schedule:Ky.reduce((e,t)=>{let r=o[t];return e[t]=(e,t=!1,i=!1)=>(n||g(),r.schedule(e,t,i)),e},{}),cancel:e=>{for(let t=0;t(tb===void 0&&rb.set($y.isProcessing||fy.useManualTiming?$y.timestamp:performance.now()),tb),set:e=>{tb=e,queueMicrotask(nb)}},ib={layout:0,mainThread:0,waapi:0},ab=e=>t=>typeof t==`string`&&t.startsWith(e),ob=ab(`--`),sb=ab(`var(--`),cb=e=>sb(e)?lb.test(e.split(`/*`)[0].trim()):!1,lb=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;function ub(e){return typeof e==`string`?e.split(`/*`)[0].includes(`var(--`):!1}var db={test:e=>typeof e==`number`,parse:parseFloat,transform:e=>e},fb={...db,transform:e=>dy(0,1,e)},pb={...db,default:1},mb=e=>Math.round(e*1e5)/1e5,hb=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function gb(e){return e==null}var _b=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,vb=(e,t)=>n=>!!(typeof n==`string`&&_b.test(n)&&n.startsWith(e)||t&&!gb(n)&&Object.prototype.hasOwnProperty.call(n,t)),yb=(e,t,n)=>r=>{if(typeof r!=`string`)return r;let[i,a,o,s]=r.match(hb);return{[e]:parseFloat(i),[t]:parseFloat(a),[n]:parseFloat(o),alpha:s===void 0?1:parseFloat(s)}},bb=e=>dy(0,255,e),xb={...db,transform:e=>Math.round(bb(e))},Sb={test:vb(`rgb`,`red`),parse:yb(`red`,`green`,`blue`),transform:({red:e,green:t,blue:n,alpha:r=1})=>`rgba(`+xb.transform(e)+`, `+xb.transform(t)+`, `+xb.transform(n)+`, `+mb(fb.transform(r))+`)`};function Cb(e){let t=``,n=``,r=``,i=``;return e.length>5?(t=e.substring(1,3),n=e.substring(3,5),r=e.substring(5,7),i=e.substring(7,9)):(t=e.substring(1,2),n=e.substring(2,3),r=e.substring(3,4),i=e.substring(4,5),t+=t,n+=n,r+=r,i+=i),{red:parseInt(t,16),green:parseInt(n,16),blue:parseInt(r,16),alpha:i?parseInt(i,16)/255:1}}var wb={test:vb(`#`),parse:Cb,transform:Sb.transform},Tb=e=>({test:t=>typeof t==`string`&&t.endsWith(e)&&t.split(` `).length===1,parse:parseFloat,transform:t=>`${t}${e}`}),Eb=Tb(`deg`),Db=Tb(`%`),Z=Tb(`px`),Ob=Tb(`vh`),kb=Tb(`vw`),Ab={...Db,parse:e=>Db.parse(e)/100,transform:e=>Db.transform(e*100)},jb={test:vb(`hsl`,`hue`),parse:yb(`hue`,`saturation`,`lightness`),transform:({hue:e,saturation:t,lightness:n,alpha:r=1})=>`hsla(`+Math.round(e)+`, `+Db.transform(mb(t))+`, `+Db.transform(mb(n))+`, `+mb(fb.transform(r))+`)`},Mb={test:e=>Sb.test(e)||wb.test(e)||jb.test(e),parse:e=>Sb.test(e)?Sb.parse(e):jb.test(e)?jb.parse(e):wb.parse(e),transform:e=>typeof e==`string`?e:e.hasOwnProperty(`red`)?Sb.transform(e):jb.transform(e),getAnimatableNone:e=>{let t=Mb.parse(e);return t.alpha=0,Mb.transform(t)}},Nb=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function Pb(e){return isNaN(e)&&typeof e==`string`&&(e.match(hb)?.length||0)+(e.match(Nb)?.length||0)>0}var Fb=`number`,Ib=`color`,Lb=`var`,Rb=`var(`,zb="${}",Bb=/var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)/giu;function Vb(e){let t=e.toString(),n=[],r={color:[],number:[],var:[]},i=[],a=0;return{values:n,split:t.replace(Bb,e=>(Mb.test(e)?(r.color.push(a),i.push(Ib),n.push(Mb.parse(e))):e.startsWith(Rb)?(r.var.push(a),i.push(Lb),n.push(e)):(r.number.push(a),i.push(Fb),n.push(parseFloat(e))),++a,zb)).split(zb),indexes:r,types:i}}function Hb(e){return Vb(e).values}function Ub({split:e,types:t}){let n=e.length;return r=>{let i=``;for(let a=0;atypeof e==`number`?0:Mb.test(e)?Mb.getAnimatableNone(e):e,Kb=(e,t)=>typeof e==`number`?t?.trim().endsWith(`/`)?e:0:Gb(e);function qb(e){let t=Vb(e);return Ub(t)(t.values.map((e,n)=>Kb(e,t.split[n])))}var Jb={test:Pb,parse:Hb,createTransformer:Wb,getAnimatableNone:qb};function Yb(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)*(2/3-n)*6:e}function Xb({hue:e,saturation:t,lightness:n,alpha:r}){e/=360,t/=100,n/=100;let i=0,a=0,o=0;if(!t)i=a=o=n;else{let r=n<.5?n*(1+t):n+t-n*t,s=2*n-r;i=Yb(s,r,e+1/3),a=Yb(s,r,e),o=Yb(s,r,e-1/3)}return{red:Math.round(i*255),green:Math.round(a*255),blue:Math.round(o*255),alpha:r}}function Zb(e,t){return n=>n>0?t:e}var Qb=(e,t,n)=>e+(t-e)*n,$b=(e,t,n)=>{let r=e*e,i=n*(t*t-r)+r;return i<0?0:Math.sqrt(i)},ex=[wb,Sb,jb],tx=e=>ex.find(t=>t.test(e));function nx(e){let t=tx(e);if(`${e}`,!t)return!1;let n=t.parse(e);return t===jb&&(n=Xb(n)),n}var rx=(e,t)=>{let n=nx(e),r=nx(t);if(!n||!r)return Zb(e,t);let i={...n};return e=>(i.red=$b(n.red,r.red,e),i.green=$b(n.green,r.green,e),i.blue=$b(n.blue,r.blue,e),i.alpha=Qb(n.alpha,r.alpha,e),Sb.transform(i))},ix=new Set([`none`,`hidden`]);function ax(e,t){return ix.has(e)?n=>n<=0?e:t:n=>n>=1?t:e}function ox(e,t){return n=>Qb(e,t,n)}function sx(e){return typeof e==`number`?ox:typeof e==`string`?cb(e)?Zb:Mb.test(e)?rx:dx:Array.isArray(e)?cx:typeof e==`object`?Mb.test(e)?rx:lx:Zb}function cx(e,t){let n=[...e],r=n.length,i=e.map((e,n)=>sx(e)(e,t[n]));return e=>{for(let t=0;t{for(let t in r)n[t]=r[t](e);return n}}function ux(e,t){let n=[],r={color:0,var:0,number:0};for(let i=0;i{let n=Jb.createTransformer(t),r=Vb(e),i=Vb(t);return r.indexes.var.length===i.indexes.var.length&&r.indexes.color.length===i.indexes.color.length&&r.indexes.number.length>=i.indexes.number.length?ix.has(e)&&!i.values.length||ix.has(t)&&!r.values.length?ax(e,t):vy(cx(ux(r,i),i.values),n):(`${e}${t}`,Zb(e,t))};function fx(e,t,n){return typeof e==`number`&&typeof t==`number`&&typeof n==`number`?Qb(e,t,n):sx(e)(e,t)}var px=e=>{let t=({timestamp:t})=>e(t);return{start:(e=!0)=>Zy.update(t,e),stop:()=>Qy(t),now:()=>$y.isProcessing?$y.timestamp:rb.now()}},mx=(e,t,n=10)=>{let r=``,i=Math.max(Math.round(t/n),2);for(let t=0;t=2e4?1/0:t}function _x(e,t=100,n){let r=n({...e,keyframes:[0,t]}),i=Math.min(gx(r),hx);return{type:`keyframes`,ease:e=>r.next(i*e).value/t,duration:Sy(i)}}var vx={stiffness:100,damping:10,mass:1,velocity:0,duration:800,bounce:.3,visualDuration:.3,restSpeed:{granular:.01,default:2},restDelta:{granular:.005,default:.5},minDuration:.01,maxDuration:10,minDamping:.05,maxDamping:1};function yx(e,t){return e*Math.sqrt(1-t*t)}var bx=12;function xx(e,t,n){let r=n;for(let n=1;n{let r=t*o,i=r*e,a=r-n,s=yx(t,o),c=Math.exp(-i);return Sx-a/s*c},a=t=>{let r=t*o*e,a=r*n+n,s=o**2*t**2*e,c=Math.exp(-r),l=yx(t**2,o);return(-i(t)+Sx>0?-1:1)*((a-s)*c)/l}):(i=t=>-.001+Math.exp(-t*e)*((t-n)*e+1),a=t=>Math.exp(-t*e)*((n-t)*(e*e)));let s=5/e,c=xx(i,a,s);if(e=xy(e),isNaN(c))return{stiffness:vx.stiffness,damping:vx.damping,duration:e};{let t=c**2*r;return{stiffness:t,damping:o*2*Math.sqrt(r*t),duration:e}}}var wx=[`duration`,`bounce`],Tx=[`stiffness`,`damping`,`mass`];function Ex(e,t){return t.some(t=>e[t]!==void 0)}function Dx(e){let t={velocity:vx.velocity,stiffness:vx.stiffness,damping:vx.damping,mass:vx.mass,isResolvedFromDuration:!1,...e};if(!Ex(e,Tx)&&Ex(e,wx))if(t.velocity=0,e.visualDuration){let n=e.visualDuration,r=2*Math.PI/(n*1.2),i=r*r,a=2*dy(.05,1,1-(e.bounce||0))*Math.sqrt(i);t={...t,mass:vx.mass,stiffness:i,damping:a}}else{let n=Cx({...e,velocity:0});t={...t,...n,mass:vx.mass},t.isResolvedFromDuration=!0}return t}function Ox(e=vx.visualDuration,t=vx.bounce){let n=typeof e==`object`?e:{visualDuration:e,keyframes:[0,1],bounce:t},{restSpeed:r,restDelta:i}=n,a=n.keyframes[0],o=n.keyframes[n.keyframes.length-1],s={done:!1,value:a},{stiffness:c,damping:l,mass:u,duration:d,velocity:f,isResolvedFromDuration:p}=Dx({...n,velocity:-Sy(n.velocity||0)}),m=f||0,h=l/(2*Math.sqrt(c*u)),g=o-a,_=Sy(Math.sqrt(c/u)),v=Math.abs(g)<5;r||=v?vx.restSpeed.granular:vx.restSpeed.default,i||=v?vx.restDelta.granular:vx.restDelta.default;let y,b,x,S,C,w;if(h<1)x=yx(_,h),S=(m+h*_*g)/x,y=e=>o-Math.exp(-h*_*e)*(S*Math.sin(x*e)+g*Math.cos(x*e)),C=h*_*S+g*x,w=h*_*g-S*x,b=e=>Math.exp(-h*_*e)*(C*Math.sin(x*e)+w*Math.cos(x*e));else if(h===1){y=e=>o-Math.exp(-_*e)*(g+(m+_*g)*e);let e=m+_*g;b=t=>Math.exp(-_*t)*(_*e*t-m)}else{let e=_*Math.sqrt(h*h-1);y=t=>{let n=Math.exp(-h*_*t),r=Math.min(e*t,300);return o-n*((m+h*_*g)*Math.sinh(r)+e*g*Math.cosh(r))/e};let t=(m+h*_*g)/e,n=h*_*t-g*e,r=h*_*g-t*e;b=t=>{let i=Math.exp(-h*_*t),a=Math.min(e*t,300);return i*(n*Math.sinh(a)+r*Math.cosh(a))}}let T={calculatedDuration:p&&d||null,velocity:e=>xy(b(e)),next:e=>{if(!p&&h<1){let t=Math.exp(-h*_*e),n=Math.sin(x*e),a=Math.cos(x*e),c=o-t*(S*n+g*a),l=xy(t*(C*n+w*a));return s.done=Math.abs(l)<=r&&Math.abs(o-c)<=i,s.value=s.done?o:c,s}let t=y(e);if(p)s.done=e>=d;else{let n=xy(b(e));s.done=Math.abs(n)<=r&&Math.abs(o-t)<=i}return s.value=s.done?o:t,s},toString:()=>{let e=Math.min(gx(T),hx),t=mx(t=>T.next(e*t).value,e,30);return e+`ms `+t},toTransition:()=>{}};return T}Ox.applyToOptions=e=>{let t=_x(e,100,Ox);return e.ease=t.ease,e.duration=xy(t.duration),e.type=`keyframes`,e};var kx=5;function Ax(e,t,n){let r=Math.max(t-kx,0);return Cy(n-e(r),t-r)}function jx({keyframes:e,velocity:t=0,power:n=.8,timeConstant:r=325,bounceDamping:i=10,bounceStiffness:a=500,modifyTarget:o,min:s,max:c,restDelta:l=.5,restSpeed:u}){let d=e[0],f={done:!1,value:d},p=e=>s!==void 0&&ec,m=e=>s===void 0?c:c===void 0||Math.abs(s-e)-h*Math.exp(-e/r),y=e=>_+v(e),b=e=>{let t=v(e),n=y(e);f.done=Math.abs(t)<=l,f.value=f.done?_:n},x,S,C=e=>{p(f.value)&&(x=e,S=Ox({keyframes:[f.value,m(f.value)],velocity:Ax(y,e,f.value),damping:i,stiffness:a,restDelta:l,restSpeed:u}))};return C(0),{calculatedDuration:null,next:e=>{let t=!1;return!S&&x===void 0&&(t=!0,b(e),C(e)),x!==void 0&&e>=x?S.next(e-x):(!t&&b(e),f)}}}function Mx(e,t,n){let r=[],i=n||fy.mix||fx,a=e.length-1;for(let n=0;nt[0];if(a===2&&t[0]===t[1])return()=>t[1];let o=e[0]===e[1];e[0]>e[a-1]&&(e=[...e].reverse(),t=[...t].reverse());let s=Mx(t,r,i),c=s.length,l=n=>{if(o&&n1)for(;rl(dy(e[0],e[a-1],t)):l}function Px(e,t){let n=e[e.length-1];for(let r=1;r<=t;r++){let i=yy(0,t,r);e.push(Qb(n,1,i))}}function Fx(e){let t=[0];return Px(t,e.length-1),t}function Ix(e,t){return e.map(e=>e*t)}function Lx(e,t){return e.map(()=>t||By).splice(0,e.length-1)}function Rx({duration:e=300,keyframes:t,times:n,ease:r=`easeInOut`}){let i=Vy(r)?r.map(Gy):Gy(r),a={done:!1,value:t[0]},o=Nx(Ix(n&&n.length===t.length?n:Fx(t),e),t,{ease:Array.isArray(i)?i:Lx(t,i)});return{calculatedDuration:e,next:t=>(a.value=o(t),a.done=t>=e,a)}}var zx=e=>e!==null;function Bx(e,{repeat:t,repeatType:n=`loop`},r,i=1){let a=e.filter(zx),o=i<0||t&&n!==`loop`&&t%2==1?0:a.length-1;return!o||r===void 0?a[o]:r}var Vx={decay:jx,inertia:jx,tween:Rx,keyframes:Rx,spring:Ox};function Hx(e){typeof e.type==`string`&&(e.type=Vx[e.type])}var Ux=class{constructor(){this.updateFinished()}get finished(){return this._finished}updateFinished(){this._finished=new Promise(e=>{this.resolve=e})}notifyFinished(){this.resolve()}then(e,t){return this.finished.then(e,t)}},Wx=e=>e/100,Gx=class extends Ux{constructor(e){super(),this.state=`idle`,this.startTime=null,this.isStopped=!1,this.currentTime=0,this.holdTime=null,this.playbackSpeed=1,this.delayState={done:!1,value:void 0},this.stop=()=>{let{motionValue:e}=this.options;e&&e.updatedAt!==rb.now()&&this.tick(rb.now()),this.isStopped=!0,this.state!==`idle`&&(this.teardown(),this.options.onStop?.())},ib.mainThread++,this.options=e,this.initAnimation(),this.play(),e.autoplay===!1&&this.pause()}initAnimation(){let{options:e}=this;Hx(e);let{type:t=Rx,repeat:n=0,repeatDelay:r=0,repeatType:i,velocity:a=0}=e,{keyframes:o}=e,s=t||Rx;s!==Rx&&typeof o[0]!=`number`&&(this.mixKeyframes=vy(Wx,fx(o[0],o[1])),o=[0,100]);let c=s({...e,keyframes:o});i===`mirror`&&(this.mirroredGenerator=s({...e,keyframes:[...o].reverse(),velocity:-a})),c.calculatedDuration===null&&(c.calculatedDuration=gx(c));let{calculatedDuration:l}=c;this.calculatedDuration=l,this.resolvedDuration=l+r,this.totalDuration=this.resolvedDuration*(n+1)-r,this.generator=c}updateTime(e){let t=Math.round(e-this.startTime)*this.playbackSpeed;this.holdTime===null?this.currentTime=t:this.currentTime=this.holdTime}tick(e,t=!1){let{generator:n,totalDuration:r,mixKeyframes:i,mirroredGenerator:a,resolvedDuration:o,calculatedDuration:s}=this;if(this.startTime===null)return n.next(0);let{delay:c=0,keyframes:l,repeat:u,repeatType:d,repeatDelay:f,type:p,onUpdate:m,finalKeyframe:h}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,e):this.speed<0&&(this.startTime=Math.min(e-r/this.speed,this.startTime)),t?this.currentTime=e:this.updateTime(e);let g=this.currentTime-c*(this.playbackSpeed>=0?1:-1),_=this.playbackSpeed>=0?g<0:g>r;this.currentTime=Math.max(g,0),this.state===`finished`&&this.holdTime===null&&(this.currentTime=r);let v=this.currentTime,y=n;if(u){let e=Math.min(this.currentTime,r)/o,t=Math.floor(e),n=e%1;!n&&e>=1&&(n=1),n===1&&t--,t=Math.min(t,u+1),t%2&&(d===`reverse`?(n=1-n,f&&(n-=f/o)):d===`mirror`&&(y=a)),v=dy(0,1,n)*o}let b;_?(this.delayState.value=l[0],b=this.delayState):b=y.next(v),i&&!_&&(b.value=i(b.value));let{done:x}=b;!_&&s!==null&&(x=this.playbackSpeed>=0?this.currentTime>=r:this.currentTime<=0);let S=this.holdTime===null&&(this.state===`finished`||this.state===`running`&&x);return S&&p!==jx&&(b.value=Bx(l,this.options,h,this.speed)),m&&m(b.value),S&&this.finish(),b}then(e,t){return this.finished.then(e,t)}get duration(){return Sy(this.calculatedDuration)}get iterationDuration(){let{delay:e=0}=this.options||{};return this.duration+Sy(e)}get time(){return Sy(this.currentTime)}set time(e){e=xy(e),this.currentTime=e,this.startTime===null||this.holdTime!==null||this.playbackSpeed===0?this.holdTime=e:this.driver&&(this.startTime=this.driver.now()-e/this.playbackSpeed),this.driver?this.driver.start(!1):(this.startTime=0,this.state=`paused`,this.holdTime=e,this.tick(e))}getGeneratorVelocity(){let e=this.currentTime;if(e<=0)return this.options.velocity||0;if(this.generator.velocity)return this.generator.velocity(e);let t=this.generator.next(e).value;return Ax(e=>this.generator.next(e).value,e,t)}get speed(){return this.playbackSpeed}set speed(e){let t=this.playbackSpeed!==e;t&&this.driver&&this.updateTime(rb.now()),this.playbackSpeed=e,t&&this.driver&&(this.time=Sy(this.currentTime))}play(){if(this.isStopped)return;let{driver:e=px,startTime:t}=this.options;this.driver||=e(e=>this.tick(e)),this.options.onPlay?.();let n=this.driver.now();this.state===`finished`?(this.updateFinished(),this.startTime=n):this.holdTime===null?this.startTime||=t??n:this.startTime=n-this.holdTime,this.state===`finished`&&this.speed<0&&(this.startTime+=this.calculatedDuration),this.holdTime=null,this.state=`running`,this.driver.start()}pause(){this.state=`paused`,this.updateTime(rb.now()),this.holdTime=this.currentTime}complete(){this.state!==`running`&&this.play(),this.state=`finished`,this.holdTime=null}finish(){this.notifyFinished(),this.teardown(),this.state=`finished`,this.options.onComplete?.()}cancel(){this.holdTime=null,this.startTime=0,this.tick(0),this.teardown(),this.options.onCancel?.()}teardown(){this.state=`idle`,this.stopDriver(),this.startTime=this.holdTime=null,ib.mainThread--}stopDriver(){this.driver&&=(this.driver.stop(),void 0)}sample(e){return this.startTime=0,this.tick(e,!0)}attachTimeline(e){return this.options.allowFlatten&&(this.options.type=`keyframes`,this.options.ease=`linear`,this.initAnimation()),this.driver?.stop(),e.observe(this)}};function Kx(e){for(let t=1;te*180/Math.PI,Jx=e=>Xx(qx(Math.atan2(e[1],e[0]))),Yx={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:e=>(Math.abs(e[0])+Math.abs(e[3]))/2,rotate:Jx,rotateZ:Jx,skewX:e=>qx(Math.atan(e[1])),skewY:e=>qx(Math.atan(e[2])),skew:e=>(Math.abs(e[1])+Math.abs(e[2]))/2},Xx=e=>(e%=360,e<0&&(e+=360),e),Zx=Jx,Qx=e=>Math.sqrt(e[0]*e[0]+e[1]*e[1]),$x=e=>Math.sqrt(e[4]*e[4]+e[5]*e[5]),eS={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:Qx,scaleY:$x,scale:e=>(Qx(e)+$x(e))/2,rotateX:e=>Xx(qx(Math.atan2(e[6],e[5]))),rotateY:e=>Xx(qx(Math.atan2(-e[2],e[0]))),rotateZ:Zx,rotate:Zx,skewX:e=>qx(Math.atan(e[4])),skewY:e=>qx(Math.atan(e[1])),skew:e=>(Math.abs(e[1])+Math.abs(e[4]))/2};function tS(e){return+!!e.includes(`scale`)}function nS(e,t){if(!e||e===`none`)return tS(t);let n=e.match(/^matrix3d\(([-\d.e\s,]+)\)$/u),r,i;if(n)r=eS,i=n;else{let t=e.match(/^matrix\(([-\d.e\s,]+)\)$/u);r=Yx,i=t}if(!i)return tS(t);let a=r[t],o=i[1].split(`,`).map(iS);return typeof a==`function`?a(o):o[a]}var rS=(e,t)=>{let{transform:n=`none`}=getComputedStyle(e);return nS(n,t)};function iS(e){return parseFloat(e.trim())}var aS=[`transformPerspective`,`x`,`y`,`z`,`translateX`,`translateY`,`translateZ`,`scale`,`scaleX`,`scaleY`,`rotate`,`rotateX`,`rotateY`,`rotateZ`,`skew`,`skewX`,`skewY`],oS=new Set([...aS,`pathRotation`]),sS=e=>e===db||e===Z,cS=new Set([`x`,`y`,`z`]),lS=aS.filter(e=>!cS.has(e));function uS(e){let t=[];return lS.forEach(n=>{let r=e.getValue(n);r!==void 0&&(t.push([n,r.get()]),r.set(+!!n.startsWith(`scale`)))}),t}var dS={width:({x:e},{paddingLeft:t=`0`,paddingRight:n=`0`,boxSizing:r})=>{let i=e.max-e.min;return r===`border-box`?i:i-parseFloat(t)-parseFloat(n)},height:({y:e},{paddingTop:t=`0`,paddingBottom:n=`0`,boxSizing:r})=>{let i=e.max-e.min;return r===`border-box`?i:i-parseFloat(t)-parseFloat(n)},top:(e,{top:t})=>parseFloat(t),left:(e,{left:t})=>parseFloat(t),bottom:({y:e},{top:t})=>parseFloat(t)+(e.max-e.min),right:({x:e},{left:t})=>parseFloat(t)+(e.max-e.min),x:(e,{transform:t})=>nS(t,`x`),y:(e,{transform:t})=>nS(t,`y`)};dS.translateX=dS.x,dS.translateY=dS.y;var fS=new Set,pS=!1,mS=!1,hS=!1;function gS(){if(mS){let e=Array.from(fS).filter(e=>e.needsMeasurement),t=new Set(e.map(e=>e.element)),n=new Map;t.forEach(e=>{let t=uS(e);t.length&&(n.set(e,t),e.render())}),e.forEach(e=>e.measureInitialState()),t.forEach(e=>{e.render();let t=n.get(e);t&&t.forEach(([t,n])=>{e.getValue(t)?.set(n)})}),e.forEach(e=>e.measureEndState()),e.forEach(e=>{e.suspendedScrollY!==void 0&&window.scrollTo(0,e.suspendedScrollY)})}mS=!1,pS=!1,fS.forEach(e=>e.complete(hS)),fS.clear()}function _S(){fS.forEach(e=>{e.readKeyframes(),e.needsMeasurement&&(mS=!0)})}function vS(){hS=!0,_S(),gS(),hS=!1}var yS=class{constructor(e,t,n,r,i,a=!1){this.state=`pending`,this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...e],this.onComplete=t,this.name=n,this.motionValue=r,this.element=i,this.isAsync=a}scheduleResolve(){this.state=`scheduled`,this.isAsync?(fS.add(this),pS||(pS=!0,Zy.read(_S),Zy.resolveKeyframes(gS))):(this.readKeyframes(),this.complete())}readKeyframes(){let{unresolvedKeyframes:e,name:t,element:n,motionValue:r}=this;if(e[0]===null){let i=r?.get(),a=e[e.length-1];if(i!==void 0)e[0]=i;else if(n&&t){let r=n.readValue(t,a);r!=null&&(e[0]=r)}e[0]===void 0&&(e[0]=a),r&&i===void 0&&r.set(e[0])}Kx(e)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(e=!1){this.state=`complete`,this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,e),fS.delete(this)}cancel(){this.state===`scheduled`&&(fS.delete(this),this.state=`pending`)}resume(){this.state===`pending`&&this.scheduleResolve()}},bS=e=>e.startsWith(`--`);function xS(e,t,n){bS(t)?e.style.setProperty(t,n):e.style[t]=n}var SS={};function CS(e,t){let n=gy(e);return()=>SS[t]??n()}var wS=CS(()=>window.ScrollTimeline!==void 0,`scrollTimeline`),TS=CS(()=>{try{document.createElement(`div`).animate({opacity:0},{easing:`linear(0, 1)`})}catch{return!1}return!0},`linearEasing`),ES=([e,t,n,r])=>`cubic-bezier(${e}, ${t}, ${n}, ${r})`,DS={linear:`linear`,ease:`ease`,easeIn:`ease-in`,easeOut:`ease-out`,easeInOut:`ease-in-out`,circIn:ES([0,.65,.55,1]),circOut:ES([.55,0,1,.45]),backIn:ES([.31,.01,.66,-.59]),backOut:ES([.33,1.53,.69,.99])};function OS(e,t){if(e)return typeof e==`function`?TS()?mx(e,t):`ease-out`:Hy(e)?ES(e):Array.isArray(e)?e.map(e=>OS(e,t)||DS.easeOut):DS[e]}function kS(e,t,n,{delay:r=0,duration:i=300,repeat:a=0,repeatType:o=`loop`,ease:s=`easeOut`,times:c}={},l=void 0){let u={[t]:n};c&&(u.offset=c);let d=OS(s,i);Array.isArray(d)&&(u.easing=d),qy.value&&ib.waapi++;let f={delay:r,duration:i,easing:Array.isArray(d)?`linear`:d,fill:`both`,iterations:a+1,direction:o===`reverse`?`alternate`:`normal`};l&&(f.pseudoElement=l);let p=e.animate(u,f);return qy.value&&p.finished.finally(()=>{ib.waapi--}),p}function AS(e){return typeof e==`function`&&`applyToOptions`in e}function jS({type:e,...t}){return AS(e)&&TS()?e.applyToOptions(t):(t.duration??=300,t.ease??=`easeOut`,t)}var MS=class extends Ux{constructor(e){if(super(),this.finishedTime=null,this.isStopped=!1,this.manualStartTime=null,!e)return;let{element:t,name:n,keyframes:r,pseudoElement:i,allowFlatten:a=!1,finalKeyframe:o,onComplete:s}=e;this.isPseudoElement=!!i,this.allowFlatten=a,this.options=e,e.type;let c=jS(e);this.animation=kS(t,n,r,c,i),c.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!i){let e=Bx(r,this.options,o,this.speed);this.updateMotionValue&&this.updateMotionValue(e),xS(t,n,e),this.animation.cancel()}s?.(),this.notifyFinished()}}play(){this.isStopped||(this.manualStartTime=null,this.animation.play(),this.state===`finished`&&this.updateFinished())}pause(){this.animation.pause()}complete(){this.animation.finish?.()}cancel(){try{this.animation.cancel()}catch{}}stop(){if(this.isStopped)return;this.isStopped=!0;let{state:e}=this;e===`idle`||e===`finished`||(this.updateMotionValue?this.updateMotionValue():this.commitStyles(),this.isPseudoElement||this.cancel())}commitStyles(){let e=this.options?.element;!this.isPseudoElement&&e?.isConnected&&this.animation.commitStyles?.()}get duration(){let e=this.animation.effect?.getComputedTiming?.().duration||0;return Sy(Number(e))}get iterationDuration(){let{delay:e=0}=this.options||{};return this.duration+Sy(e)}get time(){return Sy(Number(this.animation.currentTime)||0)}set time(e){let t=this.finishedTime!==null;this.manualStartTime=null,this.finishedTime=null,this.animation.currentTime=xy(e),t&&this.animation.pause()}get speed(){return this.animation.playbackRate}set speed(e){e<0&&(this.finishedTime=null),this.animation.playbackRate=e}get state(){return this.finishedTime===null?this.animation.playState:`finished`}get startTime(){return this.manualStartTime??Number(this.animation.startTime)}set startTime(e){this.manualStartTime=this.animation.startTime=e}attachTimeline({timeline:e,rangeStart:t,rangeEnd:n,observe:r}){return this.allowFlatten&&this.animation.effect?.updateTiming({easing:`linear`}),this.animation.onfinish=null,e&&wS()?(this.animation.timeline=e,t&&(this.animation.rangeStart=t),n&&(this.animation.rangeEnd=n),_y):r(this)}},NS={anticipate:Py,backInOut:Ny,circInOut:Ly};function PS(e){return e in NS}function FS(e){typeof e.ease==`string`&&PS(e.ease)&&(e.ease=NS[e.ease])}var IS=10,LS=class extends MS{constructor(e){FS(e),Hx(e),super(e),e.startTime!==void 0&&e.autoplay!==!1&&(this.startTime=e.startTime),this.options=e}updateMotionValue(e){let{motionValue:t,onUpdate:n,onComplete:r,element:i,...a}=this.options;if(!t)return;if(e!==void 0){t.set(e);return}let o=new Gx({...a,autoplay:!1}),s=Math.max(IS,rb.now()-this.startTime),c=dy(0,IS,s-IS),l=o.sample(s).value,{name:u}=this.options;i&&u&&xS(i,u,l),t.setWithVelocity(o.sample(Math.max(0,s-c)).value,l,c),o.stop()}},RS=(e,t)=>t===`zIndex`?!1:!!(typeof e==`number`||Array.isArray(e)||typeof e==`string`&&(Jb.test(e)||e===`0`)&&!e.startsWith(`url(`));function zS(e){let t=e[0];if(e.length===1)return!0;for(let n=0;nObject.hasOwnProperty.call(Element.prototype,`animate`));function qS(e){let{motionValue:t,name:n,repeatDelay:r,repeatType:i,damping:a,type:o,keyframes:s}=e;if(!(t?.owner?.current instanceof HTMLElement))return!1;let{onUpdate:c,transformTemplate:l}=t.owner.getProps();return KS()&&n&&(HS.has(n)||GS.has(n)&&WS(s))&&(n!==`transform`||!l)&&!c&&!r&&i!==`mirror`&&a!==0&&o!==`inertia`}var JS=40,YS=class extends Ux{constructor({autoplay:e=!0,delay:t=0,type:n=`keyframes`,repeat:r=0,repeatDelay:i=0,repeatType:a=`loop`,keyframes:o,name:s,motionValue:c,element:l,...u}){super(),this.stop=()=>{this._animation&&(this._animation.stop(),this.stopTimeline?.()),this.keyframeResolver?.cancel()},this.createdAt=rb.now();let d={autoplay:e,delay:t,type:n,repeat:r,repeatDelay:i,repeatType:a,name:s,motionValue:c,element:l,...u},f=l?.KeyframeResolver||yS;this.keyframeResolver=new f(o,(e,t,n)=>this.onKeyframesResolved(e,t,d,!n),s,c,l),this.keyframeResolver?.scheduleResolve()}onKeyframesResolved(e,t,n,r){this.keyframeResolver=void 0;let{name:i,type:a,velocity:o,delay:s,isHandoff:c,onUpdate:l}=n;this.resolvedAt=rb.now();let u=!0;BS(e,i,a,o)||(u=!1,(fy.instantAnimations||!s)&&l?.(Bx(e,n,t)),e[0]=e[e.length-1],VS(n),n.repeat=0);let d={startTime:r?this.resolvedAt&&this.resolvedAt-this.createdAt>JS?this.resolvedAt:this.createdAt:void 0,finalKeyframe:t,...n,keyframes:e},f=u&&!c&&qS(d),p=d.motionValue?.owner?.current,m;if(f)try{m=new LS({...d,element:p})}catch{m=new Gx(d)}else m=new Gx(d);m.finished.then(()=>{this.notifyFinished()}).catch(_y),this.pendingTimeline&&=(this.stopTimeline=m.attachTimeline(this.pendingTimeline),void 0),this._animation=m}get finished(){return this._animation?this.animation.finished:this._finished}then(e,t){return this.finished.finally(e).then(()=>{})}get animation(){return this._animation||(this.keyframeResolver?.resume(),vS()),this._animation}get duration(){return this.animation.duration}get iterationDuration(){return this.animation.iterationDuration}get time(){return this.animation.time}set time(e){this.animation.time=e}get speed(){return this.animation.speed}get state(){return this.animation.state}set speed(e){this.animation.speed=e}get startTime(){return this.animation.startTime}attachTimeline(e){return this._animation?this.stopTimeline=this.animation.attachTimeline(e):this.pendingTimeline=e,()=>this.stop()}play(){this.animation.play()}pause(){this.animation.pause()}complete(){this.animation.complete()}cancel(){this._animation&&this.animation.cancel(),this.keyframeResolver?.cancel()}};function XS(e,t,n,r=0,i=1){let a=Array.from(e).sort((e,t)=>e.sortNodePosition(t)).indexOf(t),o=e.size,s=(o-1)*r;return typeof n==`function`?n(a,o):i===1?a*r:s-a*r}var ZS=30,QS=e=>!isNaN(parseFloat(e)),$S={current:void 0},eC=class{constructor(e,t={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=e=>{let t=rb.now();if(this.updatedAt!==t&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(e),this.current!==this.prev&&(this.events.change?.notify(this.current),this.dependents))for(let e of this.dependents)e.dirty()},this.hasAnimated=!1,this.setCurrent(e),this.owner=t.owner}setCurrent(e){this.current=e,this.updatedAt=rb.now(),this.canTrackVelocity===null&&e!==void 0&&(this.canTrackVelocity=QS(this.current))}setPrevFrameValue(e=this.current){this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt}onChange(e){return this.on(`change`,e)}on(e,t){this.events[e]||(this.events[e]=new by);let n=this.events[e].add(t);return e===`change`?()=>{n(),Zy.read(()=>{this.events.change.getSize()||this.stop()})}:n}clearListeners(){for(let e in this.events)this.events[e].clear()}attach(e,t){this.passiveEffect=e,this.stopPassiveEffect=t}set(e){this.passiveEffect?this.passiveEffect(e,this.updateAndNotify):this.updateAndNotify(e)}setWithVelocity(e,t,n){this.set(t),this.prev=void 0,this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt-n}jump(e,t=!0){this.updateAndNotify(e),this.prev=e,this.prevUpdatedAt=this.prevFrameValue=void 0,t&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}dirty(){this.events.change?.notify(this.current)}addDependent(e){this.dependents||=new Set,this.dependents.add(e)}removeDependent(e){this.dependents&&this.dependents.delete(e)}get(){return $S.current&&$S.current.push(this),this.current}getPrevious(){return this.prev}getVelocity(){let e=rb.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||e-this.updatedAt>ZS)return 0;let t=Math.min(this.updatedAt-this.prevUpdatedAt,ZS);return Cy(parseFloat(this.current)-parseFloat(this.prevFrameValue),t)}start(e){return this.stop(),new Promise(t=>{this.hasAnimated=!0,this.animation=e(t),this.events.animationStart&&this.events.animationStart.notify()}).then(()=>{this.events.animationComplete&&this.events.animationComplete.notify(),this.clearAnimation()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){delete this.animation}destroy(){this.dependents?.clear(),this.events.destroy?.notify(),this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}};function tC(e,t){return new eC(e,t)}function nC(e,t){if(e?.inherit&&t){let{inherit:n,...r}=e;return{...t,...r}}return e}function rC(e,t){let n=e?.[t]??e?.default??e;return n===e?n:nC(n,e)}var iC={type:`spring`,stiffness:500,damping:25,restSpeed:10},aC=e=>({type:`spring`,stiffness:550,damping:e===0?2*Math.sqrt(550):30,restSpeed:10}),oC={type:`keyframes`,duration:.8},sC={type:`keyframes`,ease:[.25,.1,.35,1],duration:.3},cC=(e,{keyframes:t})=>t.length>2?oC:oS.has(e)?e.startsWith(`scale`)?aC(t[1]):iC:sC,lC=new Set([`when`,`delay`,`delayChildren`,`staggerChildren`,`staggerDirection`,`repeat`,`repeatType`,`repeatDelay`,`from`,`elapsed`]);function uC(e){for(let t in e)if(!lC.has(t))return!0;return!1}var dC=(e,t,n,r={},i,a)=>o=>{let s=rC(r,e)||{},c=s.delay||r.delay||0,{elapsed:l=0}=r;l-=xy(c);let u={keyframes:Array.isArray(n)?n:[null,n],ease:`easeOut`,velocity:t.getVelocity(),...s,delay:-l,onUpdate:e=>{t.set(e),s.onUpdate&&s.onUpdate(e)},onComplete:()=>{o(),s.onComplete&&s.onComplete()},name:e,motionValue:t,element:a?void 0:i};uC(s)||Object.assign(u,cC(e,u)),u.duration&&=xy(u.duration),u.repeatDelay&&=xy(u.repeatDelay),u.from!==void 0&&(u.keyframes[0]=u.from);let d=!1;if((u.type===!1||u.duration===0&&!u.repeatDelay)&&(VS(u),u.delay===0&&(d=!0)),(fy.instantAnimations||fy.skipAnimations||i?.shouldSkipAnimations||s.skipAnimations)&&(d=!0,VS(u),u.delay=0),u.allowFlatten=!s.type&&!s.ease,d&&!a&&t.get()!==void 0){let e=Bx(u.keyframes,s);if(e!==void 0){Zy.update(()=>{u.onUpdate(e),u.onComplete()});return}}return s.isSync?new Gx(u):new YS(u)},fC=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function pC(e){let t=fC.exec(e);if(!t)return[,];let[,n,r,i]=t;return[`--${n??r}`,i]}function mC(e,t,n=1){`${e}`;let[r,i]=pC(e);if(!r)return;let a=window.getComputedStyle(t).getPropertyValue(r);if(a){let e=a.trim();return py(e)?parseFloat(e):e}return cb(i)?mC(i,t,n+1):i}function hC(e){let t=[{},{}];return e?.values.forEach((e,n)=>{t[0][n]=e.get(),t[1][n]=e.getVelocity()}),t}function gC(e,t,n,r){if(typeof t==`function`){let[i,a]=hC(r);t=t(n===void 0?e.custom:n,i,a)}if(typeof t==`string`&&(t=e.variants&&e.variants[t]),typeof t==`function`){let[i,a]=hC(r);t=t(n===void 0?e.custom:n,i,a)}return t}function _C(e,t,n){let r=e.getProps();return gC(r,t,n===void 0?r.custom:n,e)}var vC=new Set([`width`,`height`,`top`,`left`,`right`,`bottom`,...aS]),yC=e=>Array.isArray(e);function bC(e,t,n){e.hasValue(t)?e.getValue(t).set(n):e.addValue(t,tC(n))}function xC(e){return yC(e)?e[e.length-1]||0:e}function SC(e,t){let{transitionEnd:n={},transition:r={},...i}=_C(e,t)||{};i={...i,...n};for(let t in i)bC(e,t,xC(i[t]))}var CC=e=>!!(e&&e.getVelocity);function wC(e){return!!(CC(e)&&e.add)}function TC(e,t){let n=e.getValue(`willChange`);if(wC(n))return n.add(t);if(!n&&fy.WillChange){let n=new fy.WillChange(`auto`);e.addValue(`willChange`,n),n.add(t)}}function EC(e){return e.replace(/([A-Z])/g,e=>`-${e.toLowerCase()}`)}var DC=`data-`+EC(`framerAppearId`);function OC(e){return e.props[DC]}function kC({protectedKeys:e,needsAnimating:t},n){let r=e.hasOwnProperty(n)&&t[n]!==!0;return t[n]=!1,r}function AC(e,t,{delay:n=0,transitionOverride:r,type:i}={}){let{transition:a,transitionEnd:o,...s}=t,c=e.getDefaultTransition();a=a?nC(a,c):c;let l=a?.reduceMotion,u=a?.skipAnimations;r&&(a=r);let d=[],f=i&&e.animationState&&e.animationState.getState()[i],p=a?.path;p&&p.animateVisualElement(e,s,a,n,d);for(let t in s){let r=e.getValue(t,e.latestValues[t]??null),i=s[t];if(i===void 0||f&&kC(f,t))continue;let o={delay:n,...rC(a||{},t)};u&&(o.skipAnimations=!0);let c=r.get();if(c!==void 0&&!r.isAnimating()&&!Array.isArray(i)&&i===c&&!o.velocity){Zy.update(()=>r.set(i));continue}let p=!1;if(window.MotionHandoffAnimation){let n=OC(e);if(n){let e=window.MotionHandoffAnimation(n,t,Zy);e!==null&&(o.startTime=e,p=!0)}}TC(e,t);let m=l??e.shouldReduceMotion;r.start(dC(t,r,i,m&&vC.has(t)?{type:!1}:o,e,p));let h=r.animation;h&&d.push(h)}if(o){let t=()=>Zy.update(()=>{o&&SC(e,o)});d.length?Promise.all(d).then(t):t()}return d}function jC(e,t,n={}){let r=_C(e,t,n.type===`exit`?e.presenceContext?.custom:void 0),{transition:i=e.getDefaultTransition()||{}}=r||{};n.transitionOverride&&(i=n.transitionOverride);let a=r?()=>Promise.all(AC(e,r,n)):()=>Promise.resolve(),o=e.variantChildren&&e.variantChildren.size?(r=0)=>{let{delayChildren:a=0,staggerChildren:o,staggerDirection:s}=i;return MC(e,t,r,a,o,s,n)}:()=>Promise.resolve(),{when:s}=i;if(s){let[e,t]=s===`beforeChildren`?[a,o]:[o,a];return e().then(()=>t())}else return Promise.all([a(),o(n.delay)])}function MC(e,t,n=0,r=0,i=0,a=1,o){let s=[];for(let c of e.variantChildren)c.notify(`AnimationStart`,t),s.push(jC(c,t,{...o,delay:n+(typeof r==`function`?0:r)+XS(e.variantChildren,c,r,i,a)}).then(()=>c.notify(`AnimationComplete`,t)));return Promise.all(s)}function NC(e,t,n={}){e.notify(`AnimationStart`,t);let r;if(Array.isArray(t)){let i=t.map(t=>jC(e,t,n));r=Promise.all(i)}else if(typeof t==`string`)r=jC(e,t,n);else{let i=typeof t==`function`?_C(e,t,n.custom):t;r=Promise.all(AC(e,i,n))}return r.then(()=>{e.notify(`AnimationComplete`,t)})}var PC={test:e=>e===`auto`,parse:e=>e},FC=e=>t=>t.test(e),IC=[db,Z,Db,Eb,kb,Ob,PC],LC=e=>IC.find(FC(e));function RC(e){return typeof e==`number`?e===0:e===null?!0:e===`none`||e===`0`||hy(e)}var zC=new Set([`brightness`,`contrast`,`saturate`,`opacity`]);function BC(e){let[t,n]=e.slice(0,-1).split(`(`);if(t===`drop-shadow`)return e;let[r]=n.match(hb)||[];if(!r)return e;let i=n.replace(r,``),a=+!!zC.has(t);return r!==n&&(a*=100),t+`(`+a+i+`)`}var VC=/\b([a-z-]*)\(.*?\)/gu,HC={...Jb,getAnimatableNone:e=>{let t=e.match(VC);return t?t.map(BC).join(` `):e}},UC={...Jb,getAnimatableNone:e=>{let t=Jb.parse(e);return Jb.createTransformer(e)(t.map(e=>typeof e==`number`?0:typeof e==`object`?{...e,alpha:1}:e))}},WC={...db,transform:Math.round},GC={borderWidth:Z,borderTopWidth:Z,borderRightWidth:Z,borderBottomWidth:Z,borderLeftWidth:Z,borderRadius:Z,borderTopLeftRadius:Z,borderTopRightRadius:Z,borderBottomRightRadius:Z,borderBottomLeftRadius:Z,width:Z,maxWidth:Z,height:Z,maxHeight:Z,top:Z,right:Z,bottom:Z,left:Z,inset:Z,insetBlock:Z,insetBlockStart:Z,insetBlockEnd:Z,insetInline:Z,insetInlineStart:Z,insetInlineEnd:Z,padding:Z,paddingTop:Z,paddingRight:Z,paddingBottom:Z,paddingLeft:Z,paddingBlock:Z,paddingBlockStart:Z,paddingBlockEnd:Z,paddingInline:Z,paddingInlineStart:Z,paddingInlineEnd:Z,margin:Z,marginTop:Z,marginRight:Z,marginBottom:Z,marginLeft:Z,marginBlock:Z,marginBlockStart:Z,marginBlockEnd:Z,marginInline:Z,marginInlineStart:Z,marginInlineEnd:Z,fontSize:Z,backgroundPositionX:Z,backgroundPositionY:Z,rotate:Eb,pathRotation:Eb,rotateX:Eb,rotateY:Eb,rotateZ:Eb,scale:pb,scaleX:pb,scaleY:pb,scaleZ:pb,skew:Eb,skewX:Eb,skewY:Eb,distance:Z,translateX:Z,translateY:Z,translateZ:Z,x:Z,y:Z,z:Z,perspective:Z,transformPerspective:Z,opacity:fb,originX:Ab,originY:Ab,originZ:Z,zIndex:WC,fillOpacity:fb,strokeOpacity:fb,numOctaves:WC},KC={...GC,color:Mb,backgroundColor:Mb,outlineColor:Mb,fill:Mb,stroke:Mb,borderColor:Mb,borderTopColor:Mb,borderRightColor:Mb,borderBottomColor:Mb,borderLeftColor:Mb,filter:HC,WebkitFilter:HC,mask:UC,WebkitMask:UC},qC=e=>KC[e],JC=new Set([HC,UC]);function YC(e,t){let n=qC(e);return JC.has(n)||(n=Jb),n.getAnimatableNone?n.getAnimatableNone(t):void 0}var XC=new Set([`auto`,`none`,`0`]);function ZC(e,t,n){let r=0,i;for(;r{e.getValue(t).set(n)}),this.resolveNoneKeyframes()}};function $C(e,t,n){if(e==null)return[];if(e instanceof EventTarget)return[e];if(typeof e==`string`){let r=document;t&&(r=t.current);let i=n?.[e]??r.querySelectorAll(e);return i?Array.from(i):[]}return Array.from(e).filter(e=>e!=null)}var ew=(e,t)=>t&&typeof e==`number`?t.transform(e):e;function tw(e){return my(e)&&`offsetHeight`in e&&!(`ownerSVGElement`in e)}var{schedule:nw,cancel:rw}=Xy(queueMicrotask,!1),iw={x:!1,y:!1};function aw(){return iw.x||iw.y}function ow(e){return e===`x`||e===`y`?iw[e]?null:(iw[e]=!0,()=>{iw[e]=!1}):iw.x||iw.y?null:(iw.x=iw.y=!0,()=>{iw.x=iw.y=!1})}function sw(e,t){let n=$C(e),r=new AbortController;return[n,{passive:!0,...t,signal:r.signal},()=>r.abort()]}function cw(e){return!(e.pointerType===`touch`||aw())}function lw(e,t,n={}){let[r,i,a]=sw(e,n);return r.forEach(e=>{let n=!1,r=!1,a,o=()=>{e.removeEventListener(`pointerleave`,u)},s=e=>{a&&=(a(e),void 0),o()},c=e=>{n=!1,window.removeEventListener(`pointerup`,c),window.removeEventListener(`pointercancel`,c),r&&(r=!1,s(e))},l=()=>{n=!0,window.addEventListener(`pointerup`,c,i),window.addEventListener(`pointercancel`,c,i)},u=e=>{if(e.pointerType!==`touch`){if(n){r=!0;return}s(e)}};e.addEventListener(`pointerenter`,n=>{if(!cw(n))return;r=!1;let o=t(e,n);typeof o==`function`&&(a=o,e.addEventListener(`pointerleave`,u,i))},i),e.addEventListener(`pointerdown`,l,i)}),a}var uw=(e,t)=>t?e===t?!0:uw(e,t.parentElement):!1,dw=e=>e.pointerType===`mouse`?typeof e.button!=`number`||e.button<=0:e.isPrimary!==!1,fw=new Set([`BUTTON`,`INPUT`,`SELECT`,`TEXTAREA`,`A`]);function pw(e){return fw.has(e.tagName)||e.isContentEditable===!0}var mw=new Set([`INPUT`,`SELECT`,`TEXTAREA`]);function hw(e){return mw.has(e.tagName)||e.isContentEditable===!0}var gw=new WeakSet;function _w(e){return t=>{t.key===`Enter`&&e(t)}}function vw(e,t){e.dispatchEvent(new PointerEvent(`pointer`+t,{isPrimary:!0,bubbles:!0}))}var yw=(e,t)=>{let n=e.currentTarget;if(!n)return;let r=_w(()=>{if(gw.has(n))return;vw(n,`down`);let e=_w(()=>{vw(n,`up`)});n.addEventListener(`keyup`,e,t),n.addEventListener(`blur`,()=>vw(n,`cancel`),t)});n.addEventListener(`keydown`,r,t),n.addEventListener(`blur`,()=>n.removeEventListener(`keydown`,r),t)};function bw(e){return dw(e)&&!aw()}var xw=new WeakSet;function Sw(e,t,n={}){let[r,i,a]=sw(e,n),o=e=>{let r=e.currentTarget;if(!bw(e)||xw.has(e))return;gw.add(r),n.stopPropagation&&xw.add(e);let a=t(r,e),o=(e,t)=>{window.removeEventListener(`pointerup`,s),window.removeEventListener(`pointercancel`,c),gw.has(r)&&gw.delete(r),bw(e)&&typeof a==`function`&&a(e,{success:t})},s=e=>{o(e,r===window||r===document||n.useGlobalTarget||uw(r,e.target))},c=e=>{o(e,!1)};window.addEventListener(`pointerup`,s,i),window.addEventListener(`pointercancel`,c,i)};return r.forEach(e=>{(n.useGlobalTarget?window:e).addEventListener(`pointerdown`,o,i),tw(e)&&(e.addEventListener(`focus`,e=>yw(e,i)),!pw(e)&&!e.hasAttribute(`tabindex`)&&(e.tabIndex=0))}),a}function Cw(e){return my(e)&&`ownerSVGElement`in e}var ww=new WeakMap,Tw,Ew=(e,t,n)=>(r,i)=>i&&i[0]?i[0][e+`Size`]:Cw(r)&&`getBBox`in r?r.getBBox()[t]:r[n],Dw=Ew(`inline`,`width`,`offsetWidth`),Ow=Ew(`block`,`height`,`offsetHeight`);function kw({target:e,borderBoxSize:t}){ww.get(e)?.forEach(n=>{n(e,{get width(){return Dw(e,t)},get height(){return Ow(e,t)}})})}function Aw(e){e.forEach(kw)}function jw(){typeof ResizeObserver>`u`||(Tw=new ResizeObserver(Aw))}function Mw(e,t){Tw||jw();let n=$C(e);return n.forEach(e=>{let n=ww.get(e);n||(n=new Set,ww.set(e,n)),n.add(t),Tw?.observe(e)}),()=>{n.forEach(e=>{let n=ww.get(e);n?.delete(t),n?.size||Tw?.unobserve(e)})}}var Nw=new Set,Pw;function Fw(){Pw=()=>{let e={get width(){return window.innerWidth},get height(){return window.innerHeight}};Nw.forEach(t=>t(e))},window.addEventListener(`resize`,Pw)}function Iw(e){return Nw.add(e),Pw||Fw(),()=>{Nw.delete(e),!Nw.size&&typeof Pw==`function`&&(window.removeEventListener(`resize`,Pw),Pw=void 0)}}function Lw(e,t){return typeof e==`function`?Iw(e):Mw(e,t)}function Rw(e){return Cw(e)&&e.tagName===`svg`}var zw=[...IC,Mb,Jb],Bw=e=>zw.find(FC(e)),Vw=()=>({translate:0,scale:1,origin:0,originPoint:0}),Hw=()=>({x:Vw(),y:Vw()}),Uw=()=>({min:0,max:0}),Ww=()=>({x:Uw(),y:Uw()}),Gw=new WeakMap;function Kw(e){return typeof e==`object`&&!!e&&typeof e.start==`function`}function qw(e){return typeof e==`string`||Array.isArray(e)}var Jw=[`animate`,`whileInView`,`whileFocus`,`whileHover`,`whileTap`,`whileDrag`,`exit`],Yw=[`initial`,...Jw];function Xw(e){return Kw(e.animate)||Yw.some(t=>qw(e[t]))}function Zw(e){return!!(Xw(e)||e.variants)}function Qw(e,t,n){for(let r in t){let i=t[r],a=n[r];if(CC(i))e.addValue(r,i);else if(CC(a))e.addValue(r,tC(i,{owner:e}));else if(a!==i)if(e.hasValue(r)){let t=e.getValue(r);t.liveStyle===!0?t.jump(i):t.hasAnimated||t.set(i)}else{let t=e.getStaticValue(r);e.addValue(r,tC(t===void 0?i:t,{owner:e}))}}for(let r in n)t[r]===void 0&&e.removeValue(r);return t}var $w={current:null},eT={current:!1},tT=typeof window<`u`;function nT(){if(eT.current=!0,tT)if(window.matchMedia){let e=window.matchMedia(`(prefers-reduced-motion)`),t=()=>$w.current=e.matches;e.addEventListener(`change`,t),t()}else $w.current=!1}var rT=[`AnimationStart`,`AnimationComplete`,`Update`,`BeforeLayoutMeasure`,`LayoutMeasure`,`LayoutAnimationStart`,`LayoutAnimationComplete`],iT={};function aT(e){iT=e}function oT(){return iT}var sT=class{scrapeMotionValuesFromProps(e,t,n){return{}}constructor({parent:e,props:t,presenceContext:n,reducedMotionConfig:r,skipAnimations:i,blockInitialAnimation:a,visualState:o},s={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.shouldSkipAnimations=!1,this.values=new Map,this.KeyframeResolver=yS,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},this.hasBeenMounted=!1,this.events={},this.propEventSubscriptions={},this.notifyUpdate=()=>this.notify(`Update`,this.latestValues),this.render=()=>{this.current&&(this.triggerBuild(),this.renderInstance(this.current,this.renderState,this.props.style,this.projection))},this.renderScheduledAt=0,this.scheduleRender=()=>{let e=rb.now();this.renderScheduledAtthis.bindToMotionValue(t,e)),this.reducedMotionConfig===`never`?this.shouldReduceMotion=!1:this.reducedMotionConfig===`always`?this.shouldReduceMotion=!0:(eT.current||nT(),this.shouldReduceMotion=$w.current),this.shouldSkipAnimations=this.skipAnimationsConfig??!1,this.parent?.addChild(this),this.update(this.props,this.presenceContext),this.hasBeenMounted=!0}unmount(){this.projection&&this.projection.unmount(),Qy(this.notifyUpdate),Qy(this.render),this.valueSubscriptions.forEach(e=>e()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),this.parent?.removeChild(this);for(let e in this.events)this.events[e].clear();for(let e in this.features){let t=this.features[e];t&&(t.unmount(),t.isMounted=!1)}this.current=null}addChild(e){this.children.add(e),this.enteringChildren??=new Set,this.enteringChildren.add(e)}removeChild(e){this.children.delete(e),this.enteringChildren&&this.enteringChildren.delete(e)}bindToMotionValue(e,t){if(this.valueSubscriptions.has(e)&&this.valueSubscriptions.get(e)(),t.accelerate&&HS.has(e)&&this.current instanceof HTMLElement){let{factory:n,keyframes:r,times:i,ease:a,duration:o}=t.accelerate,s=new MS({element:this.current,name:e,keyframes:r,times:i,ease:a,duration:xy(o)}),c=n(s);this.valueSubscriptions.set(e,()=>{c(),s.cancel()});return}let n=oS.has(e);n&&this.onBindTransform&&this.onBindTransform();let r=t.on(`change`,t=>{this.latestValues[e]=t,this.props.onUpdate&&Zy.preRender(this.notifyUpdate),n&&this.projection&&(this.projection.isTransformDirty=!0),this.scheduleRender()}),i;typeof window<`u`&&window.MotionCheckAppearSync&&(i=window.MotionCheckAppearSync(this,e,t)),this.valueSubscriptions.set(e,()=>{r(),i&&i()})}sortNodePosition(e){return!this.current||!this.sortInstanceNodePosition||this.type!==e.type?0:this.sortInstanceNodePosition(this.current,e.current)}updateFeatures(){let e=`animation`;for(e in iT){let t=iT[e];if(!t)continue;let{isEnabled:n,Feature:r}=t;if(!this.features[e]&&r&&n(this.props)&&(this.features[e]=new r(this)),this.features[e]){let t=this.features[e];t.isMounted?t.update():(t.mount(),t.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):Ww()}getStaticValue(e){return this.latestValues[e]}setStaticValue(e,t){this.latestValues[e]=t}update(e,t){(e.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=e,this.prevPresenceContext=this.presenceContext,this.presenceContext=t;for(let t=0;tt.variantChildren.delete(e)}addValue(e,t){let n=this.values.get(e);t!==n&&(n&&this.removeValue(e),this.bindToMotionValue(e,t),this.values.set(e,t),this.latestValues[e]=t.get())}removeValue(e){this.values.delete(e);let t=this.valueSubscriptions.get(e);t&&(t(),this.valueSubscriptions.delete(e)),delete this.latestValues[e],this.removeValueFromRenderState(e,this.renderState)}hasValue(e){return this.values.has(e)}getValue(e,t){if(this.props.values&&this.props.values[e])return this.props.values[e];let n=this.values.get(e);return n===void 0&&t!==void 0&&(n=tC(t===null?void 0:t,{owner:this}),this.addValue(e,n)),n}readValue(e,t){let n=this.latestValues[e]!==void 0||!this.current?this.latestValues[e]:this.getBaseTargetFromProps(this.props,e)??this.readValueFromInstance(this.current,e,this.options);return n!=null&&(typeof n==`string`&&(py(n)||hy(n))?n=parseFloat(n):!Bw(n)&&Jb.test(t)&&(n=YC(e,t)),this.setBaseTarget(e,CC(n)?n.get():n)),CC(n)?n.get():n}setBaseTarget(e,t){this.baseTarget[e]=t}getBaseTarget(e){let{initial:t}=this.props,n;if(typeof t==`string`||typeof t==`object`){let r=gC(this.props,t,this.presenceContext?.custom);r&&(n=r[e])}if(t&&n!==void 0)return n;let r=this.getBaseTargetFromProps(this.props,e);return r!==void 0&&!CC(r)?r:this.initialValues[e]!==void 0&&n===void 0?void 0:this.baseTarget[e]}on(e,t){return this.events[e]||(this.events[e]=new by),this.events[e].add(t)}notify(e,...t){this.events[e]&&this.events[e].notify(...t)}scheduleRenderMicrotask(){nw.render(this.render)}},cT=class extends sT{constructor(){super(...arguments),this.KeyframeResolver=QC}sortInstanceNodePosition(e,t){return e.compareDocumentPosition(t)&2?1:-1}getBaseTargetFromProps(e,t){let n=e.style;return n?n[t]:void 0}removeValueFromRenderState(e,{vars:t,style:n}){delete t[e],delete n[e]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);let{children:e}=this.props;CC(e)&&(this.childSubscription=e.on(`change`,e=>{this.current&&(this.current.textContent=`${e}`)}))}},lT=class{constructor(e){this.isMounted=!1,this.node=e}update(){}};function uT({top:e,left:t,right:n,bottom:r}){return{x:{min:t,max:n},y:{min:e,max:r}}}function dT({x:e,y:t}){return{top:t.min,right:e.max,bottom:t.max,left:e.min}}function fT(e,t){if(!t)return e;let n=t({x:e.left,y:e.top}),r=t({x:e.right,y:e.bottom});return{top:n.y,left:n.x,bottom:r.y,right:r.x}}function pT(e){return e===void 0||e===1}function mT({scale:e,scaleX:t,scaleY:n}){return!pT(e)||!pT(t)||!pT(n)}function hT(e){return mT(e)||gT(e)||e.z||e.rotate||e.rotateX||e.rotateY||e.skewX||e.skewY}function gT(e){return _T(e.x)||_T(e.y)}function _T(e){return e&&e!==`0%`}function vT(e,t,n){return n+t*(e-n)}function yT(e,t,n,r,i){return i!==void 0&&(e=vT(e,i,r)),vT(e,n,r)+t}function bT(e,t=0,n=1,r,i){e.min=yT(e.min,t,n,r,i),e.max=yT(e.max,t,n,r,i)}function xT(e,{x:t,y:n}){bT(e.x,t.translate,t.scale,t.originPoint),bT(e.y,n.translate,n.scale,n.originPoint)}var ST=.999999999999,CT=1.0000000000001;function wT(e,t,n,r=!1){let i=n.length;if(!i)return;t.x=t.y=1;let a,o;for(let s=0;sST&&(t.x=1),t.yST&&(t.y=1)}function TT(e,t){e.min+=t,e.max+=t}function ET(e,t,n,r,i=.5){bT(e,t,n,Qb(e.min,e.max,i),r)}function DT(e,t){return typeof e==`string`?parseFloat(e)/100*(t.max-t.min):e}function OT(e,t,n){let r=n??e;ET(e.x,DT(t.x,r.x),t.scaleX,t.scale,t.originX),ET(e.y,DT(t.y,r.y),t.scaleY,t.scale,t.originY)}function kT(e,t){return uT(fT(e.getBoundingClientRect(),t))}function AT(e,t,n){let r=kT(e,n),{scroll:i}=t;return i&&(TT(r.x,i.offset.x),TT(r.y,i.offset.y)),r}var jT={x:`translateX`,y:`translateY`,z:`translateZ`,transformPerspective:`perspective`},MT=aS.length;function NT(e,t,n){let r=``,i=!0;for(let a=0;a{if(!t.target)return e;if(typeof e==`string`)if(Z.test(e))e=parseFloat(e);else return e;return`${IT(e,t.target.x)}% ${IT(e,t.target.y)}%`}},RT={correct:(e,{treeScale:t,projectionDelta:n})=>{let r=e,i=Jb.parse(e);if(i.length>5)return r;let a=Jb.createTransformer(e),o=typeof i[0]==`number`?0:1,s=n.x.scale*t.x,c=n.y.scale*t.y;i[0+o]/=s,i[1+o]/=c;let l=Qb(s,c,.5);return typeof i[2+o]==`number`&&(i[2+o]/=l),typeof i[3+o]==`number`&&(i[3+o]/=l),a(i)}},zT={borderRadius:{...LT,applyTo:[`borderTopLeftRadius`,`borderTopRightRadius`,`borderBottomLeftRadius`,`borderBottomRightRadius`]},borderTopLeftRadius:LT,borderTopRightRadius:LT,borderBottomLeftRadius:LT,borderBottomRightRadius:LT,boxShadow:RT};function BT(e,{layout:t,layoutId:n}){return oS.has(e)||e.startsWith(`origin`)||(t||n!==void 0)&&(!!zT[e]||e===`opacity`)}function VT(e,t,n){let r=e.style,i=t?.style,a={};if(!r)return a;for(let t in r)(CC(r[t])||i&&CC(i[t])||BT(t,e)||n?.getValue(t)?.liveStyle!==void 0)&&(a[t]=r[t]);return a}function HT(e){return window.getComputedStyle(e)}var UT=class extends cT{constructor(){super(...arguments),this.type=`html`,this.renderInstance=FT}readValueFromInstance(e,t){if(oS.has(t))return this.projection?.isProjecting?tS(t):rS(e,t);{let n=HT(e),r=(ob(t)?n.getPropertyValue(t):n[t])||0;return typeof r==`string`?r.trim():r}}measureInstanceViewportBox(e,{transformPagePoint:t}){return kT(e,t)}build(e,t,n){PT(e,t,n.transformTemplate)}scrapeMotionValuesFromProps(e,t,n){return VT(e,t,n)}},WT={offset:`stroke-dashoffset`,array:`stroke-dasharray`},GT={offset:`strokeDashoffset`,array:`strokeDasharray`};function KT(e,t,n=1,r=0,i=!0){e.pathLength=1;let a=i?WT:GT;e[a.offset]=`${-r}`,e[a.array]=`${t} ${n}`}var qT=[`offsetDistance`,`offsetPath`,`offsetRotate`,`offsetAnchor`];function JT(e,{attrX:t,attrY:n,attrScale:r,pathLength:i,pathSpacing:a=1,pathOffset:o=0,...s},c,l,u){if(PT(e,s,l),c){e.style.viewBox&&(e.attrs.viewBox=e.style.viewBox);return}e.attrs=e.style,e.style={};let{attrs:d,style:f}=e;d.transform&&(f.transform=d.transform,delete d.transform),(f.transform||d.transformOrigin)&&(f.transformOrigin=d.transformOrigin??`50% 50%`,delete d.transformOrigin),f.transform&&(f.transformBox=u?.transformBox??`fill-box`,delete d.transformBox);for(let e of qT)d[e]!==void 0&&(f[e]=d[e],delete d[e]);t!==void 0&&(d.x=t),n!==void 0&&(d.y=n),r!==void 0&&(d.scale=r),i!==void 0&&KT(d,i,a,o,!1)}var YT=new Set([`baseFrequency`,`diffuseConstant`,`kernelMatrix`,`kernelUnitLength`,`keySplines`,`keyTimes`,`limitingConeAngle`,`markerHeight`,`markerWidth`,`numOctaves`,`targetX`,`targetY`,`surfaceScale`,`specularConstant`,`specularExponent`,`stdDeviation`,`tableValues`,`viewBox`,`gradientTransform`,`pathLength`,`startOffset`,`textLength`,`lengthAdjust`]),XT=e=>typeof e==`string`&&e.toLowerCase()===`svg`;function ZT(e,t,n,r){FT(e,t,void 0,r);for(let n in t.attrs)e.setAttribute(YT.has(n)?n:EC(n),t.attrs[n])}function QT(e,t,n){let r=VT(e,t,n);for(let n in e)if(CC(e[n])||CC(t[n])){let t=aS.indexOf(n)===-1?n:`attr`+n.charAt(0).toUpperCase()+n.substring(1);r[t]=e[n]}return r}var $T=class extends cT{constructor(){super(...arguments),this.type=`svg`,this.isSVGTag=!1,this.measureInstanceViewportBox=Ww}getBaseTargetFromProps(e,t){return e[t]}readValueFromInstance(e,t){if(oS.has(t)){let e=qC(t);return e&&e.default||0}return t=YT.has(t)?t:EC(t),e.getAttribute(t)}scrapeMotionValuesFromProps(e,t,n){return QT(e,t,n)}build(e,t,n){JT(e,t,this.isSVGTag,n.transformTemplate,n.style)}renderInstance(e,t,n,r){ZT(e,t,n,r)}mount(e){this.isSVGTag=XT(e.tagName),super.mount(e)}},eE=Yw.length;function tE(e){if(!e)return;if(!e.isControllingVariants){let t=e.parent&&tE(e.parent)||{};return e.props.initial!==void 0&&(t.initial=e.props.initial),t}let t={};for(let n=0;nPromise.all(t.map(({animation:t,options:n})=>NC(e,t,n)))}function oE(e){let t=aE(e),n=lE(),r=!0,i=!1,a=t=>(n,r)=>{let i=_C(e,r,t===`exit`?e.presenceContext?.custom:void 0);if(i){let{transition:e,transitionEnd:t,...r}=i;n={...n,...r,...t}}return n};function o(n){t=n(e)}function s(o){let{props:s}=e,c=tE(e.parent)||{},l=[],u=new Set,d={},f=1/0;for(let t=0;tf&&g,x=!1,S=Array.isArray(h)?h:[h],C=S.reduce(a(p),{});_===!1&&(C={});let{prevResolvedValues:w={}}=m,T={...w,...C},E=t=>{b=!0,u.has(t)&&(x=!0,u.delete(t)),m.needsAnimating[t]=!0;let n=e.getValue(t);n&&(n.liveStyle=!1)};for(let e in T){let t=C[e],n=w[e];if(d.hasOwnProperty(e))continue;let r=!1;r=yC(t)&&yC(n)?!nE(t,n)||y:t!==n,r?t==null?u.add(e):E(e):t!==void 0&&u.has(e)?E(e):m.protectedKeys[e]=!0}m.prevProp=h,m.prevResolvedValues=C,m.isActive&&(d={...d,...C}),(r||i)&&e.blockInitialAnimation&&(b=!1);let D=v&&y;b&&(!D||x)&&l.push(...S.map(t=>{let n={type:p};if(typeof t==`string`&&(r||i)&&!D&&e.manuallyAnimateOnMount&&e.parent){let{parent:r}=e,i=_C(r,t);if(r.enteringChildren&&i){let{delayChildren:t}=i.transition||{};n.delay=XS(r.enteringChildren,e,t)}}return{animation:t,options:n}}))}if(u.size){let t={};if(typeof s.initial!=`boolean`){let n=_C(e,Array.isArray(s.initial)?s.initial[0]:s.initial);n&&n.transition&&(t.transition=n.transition)}u.forEach(n=>{let r=e.getBaseTarget(n),i=e.getValue(n);i&&(i.liveStyle=!0),t[n]=r??null}),l.push({animation:t})}let p=!!l.length;return r&&(s.initial===!1||s.initial===s.animate)&&!e.manuallyAnimateOnMount&&(p=!1),r=!1,i=!1,p?t(l):Promise.resolve()}function c(t,r){if(n[t].isActive===r)return Promise.resolve();e.variantChildren?.forEach(e=>e.animationState?.setActive(t,r)),n[t].isActive=r;let i=s(t);for(let e in n)n[e].protectedKeys={};return i}return{animateChanges:s,setActive:c,setAnimateFunction:o,getState:()=>n,reset:()=>{n=lE(),i=!0}}}function sE(e,t){return typeof t==`string`?t!==e:Array.isArray(t)?!nE(t,e):!1}function cE(e=!1){return{isActive:e,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function lE(){return{animate:cE(!0),whileInView:cE(),whileHover:cE(),whileTap:cE(),whileDrag:cE(),whileFocus:cE(),exit:cE()}}function uE(e,t){e.min=t.min,e.max=t.max}function dE(e,t){uE(e.x,t.x),uE(e.y,t.y)}function fE(e,t){e.translate=t.translate,e.scale=t.scale,e.originPoint=t.originPoint,e.origin=t.origin}var pE=.9999,mE=1.0001,hE=-.01,gE=.01;function _E(e){return e.max-e.min}function vE(e,t,n){return Math.abs(e-t)<=n}function yE(e,t,n,r=.5){e.origin=r,e.originPoint=Qb(t.min,t.max,e.origin),e.scale=_E(n)/_E(t),e.translate=Qb(n.min,n.max,e.origin)-e.originPoint,(e.scale>=pE&&e.scale<=mE||isNaN(e.scale))&&(e.scale=1),(e.translate>=hE&&e.translate<=gE||isNaN(e.translate))&&(e.translate=0)}function bE(e,t,n,r){yE(e.x,t.x,n.x,r?r.originX:void 0),yE(e.y,t.y,n.y,r?r.originY:void 0)}function xE(e,t,n,r=0){e.min=(r?Qb(n.min,n.max,r):n.min)+t.min,e.max=e.min+_E(t)}function SE(e,t,n,r){xE(e.x,t.x,n.x,r?.x),xE(e.y,t.y,n.y,r?.y)}function CE(e,t,n,r=0){let i=r?Qb(n.min,n.max,r):n.min;e.min=t.min-i,e.max=e.min+_E(t)}function wE(e,t,n,r){CE(e.x,t.x,n.x,r?.x),CE(e.y,t.y,n.y,r?.y)}function TE(e,t,n,r,i){return e-=t,e=vT(e,1/n,r),i!==void 0&&(e=vT(e,1/i,r)),e}function EE(e,t=0,n=1,r=.5,i,a=e,o=e){if(Db.test(t)&&(t=parseFloat(t),t=Qb(o.min,o.max,t/100)-o.min),typeof t!=`number`)return;let s=Qb(a.min,a.max,r);e===a&&(s-=t),e.min=TE(e.min,t,n,s,i),e.max=TE(e.max,t,n,s,i)}function DE(e,t,[n,r,i],a,o){EE(e,t[n],t[r],t[i],t.scale,a,o)}var OE=[`x`,`scaleX`,`originX`],kE=[`y`,`scaleY`,`originY`];function AE(e,t,n,r){DE(e.x,t,OE,n?n.x:void 0,r?r.x:void 0),DE(e.y,t,kE,n?n.y:void 0,r?r.y:void 0)}function jE(e){return e.translate===0&&e.scale===1}function ME(e){return jE(e.x)&&jE(e.y)}function NE(e,t){return e.min===t.min&&e.max===t.max}function PE(e,t){return NE(e.x,t.x)&&NE(e.y,t.y)}function FE(e,t){return Math.round(e.min)===Math.round(t.min)&&Math.round(e.max)===Math.round(t.max)}function IE(e,t){return FE(e.x,t.x)&&FE(e.y,t.y)}function LE(e){return _E(e.x)/_E(e.y)}function RE(e,t){return e.translate===t.translate&&e.scale===t.scale&&e.originPoint===t.originPoint}function zE(e){return[e(`x`),e(`y`)]}function BE(e,t,n){let r=``,i=e.x.translate/t.x,a=e.y.translate/t.y,o=n?.z||0;if((i||a||o)&&(r=`translate3d(${i}px, ${a}px, ${o}px) `),(t.x!==1||t.y!==1)&&(r+=`scale(${1/t.x}, ${1/t.y}) `),n){let{transformPerspective:e,rotate:t,pathRotation:i,rotateX:a,rotateY:o,skewX:s,skewY:c}=n;e&&(r=`perspective(${e}px) ${r}`),t&&(r+=`rotate(${t}deg) `),i&&(r+=`rotate(${i}deg) `),a&&(r+=`rotateX(${a}deg) `),o&&(r+=`rotateY(${o}deg) `),s&&(r+=`skewX(${s}deg) `),c&&(r+=`skewY(${c}deg) `)}let s=e.x.scale*t.x,c=e.y.scale*t.y;return(s!==1||c!==1)&&(r+=`scale(${s}, ${c})`),r||`none`}var VE=[`borderTopLeftRadius`,`borderTopRightRadius`,`borderBottomLeftRadius`,`borderBottomRightRadius`],HE=VE.length,UE=e=>typeof e==`string`?parseFloat(e):e,WE=e=>typeof e==`number`||Z.test(e);function GE(e,t,n,r,i,a){i?(e.opacity=Qb(0,n.opacity??1,qE(r)),e.opacityExit=Qb(t.opacity??1,0,JE(r))):a&&(e.opacity=Qb(t.opacity??1,n.opacity??1,r));for(let i=0;irt?1:n(yy(e,t,r))}function XE(e,t,n){let r=CC(e)?e:tC(e);return r.start(dC(``,r,t,n)),r.animation}function ZE(e,t,n,r={passive:!0}){return e.addEventListener(t,n,r),()=>e.removeEventListener(t,n)}var QE=(e,t)=>e.depth-t.depth,$E=class{constructor(){this.children=[],this.isDirty=!1}add(e){ly(this.children,e),this.isDirty=!0}remove(e){uy(this.children,e),this.isDirty=!0}forEach(e){this.isDirty&&this.children.sort(QE),this.isDirty=!1,this.children.forEach(e)}};function eD(e,t){let n=rb.now(),r=({timestamp:i})=>{let a=i-n;a>=t&&(Qy(r),e(a-t))};return Zy.setup(r,!0),()=>Qy(r)}function tD(e){return CC(e)?e.get():e}var nD=class{constructor(){this.members=[]}add(e){ly(this.members,e);for(let t=this.members.length-1;t>=0;t--){let n=this.members[t];if(n===e||n===this.lead||n===this.prevLead)continue;let r=n.instance;(!r||r.isConnected===!1)&&!n.snapshot&&(uy(this.members,n),n.unmount())}e.scheduleRender()}remove(e){if(uy(this.members,e),e===this.prevLead&&(this.prevLead=void 0),e===this.lead){let e=this.members[this.members.length-1];e&&this.promote(e)}}relegate(e){for(let t=this.members.indexOf(e)-1;t>=0;t--){let e=this.members[t];if(e.isPresent!==!1&&e.instance?.isConnected!==!1)return this.promote(e),!0}return!1}promote(e,t){let n=this.lead;if(e!==n&&(this.prevLead=n,this.lead=e,e.show(),n)){n.updateSnapshot(),e.scheduleRender();let{layoutDependency:r}=n.options,{layoutDependency:i}=e.options;(r===void 0||r!==i)&&(e.resumeFrom=n,t&&(n.preserveOpacity=!0),n.snapshot&&(e.snapshot=n.snapshot,e.snapshot.latestValues=n.animationValues||n.latestValues),e.root?.isUpdating&&(e.isLayoutDirty=!0)),e.options.crossfade===!1&&n.hide()}}exitAnimationComplete(){this.members.forEach(e=>{e.options.onExitComplete?.(),e.resumingFrom?.options.onExitComplete?.()})}scheduleRender(){this.members.forEach(e=>e.instance&&e.scheduleRender(!1))}removeLeadSnapshot(){this.lead?.snapshot&&(this.lead.snapshot=void 0)}},rD={hasAnimatedSinceResize:!0,hasEverUpdated:!1},iD={nodes:0,calculatedTargetDeltas:0,calculatedProjections:0},aD=[``,`X`,`Y`,`Z`],oD=1e3,sD=0;function cD(e,t,n,r){let{latestValues:i}=t;i[e]&&(n[e]=i[e],t.setStaticValue(e,0),r&&(r[e]=0))}function lD(e){if(e.hasCheckedOptimisedAppear=!0,e.root===e)return;let{visualElement:t}=e.options;if(!t)return;let n=OC(t);if(window.MotionHasOptimisedAnimation(n,`transform`)){let{layout:t,layoutId:r}=e.options;window.MotionCancelOptimisedAnimation(n,`transform`,Zy,!(t||r))}let{parent:r}=e;r&&!r.hasCheckedOptimisedAppear&&lD(r)}function uD({attachResizeListener:e,defaultParent:t,measureScroll:n,checkIsScrollRoot:r,resetTransform:i}){return class{constructor(e={},n=t?.()){this.id=sD++,this.animationId=0,this.animationCommitId=0,this.children=new Set,this.options={},this.isTreeAnimating=!1,this.isAnimationBlocked=!1,this.isLayoutDirty=!1,this.isProjectionDirty=!1,this.isSharedProjectionDirty=!1,this.isTransformDirty=!1,this.updateManuallyBlocked=!1,this.updateBlockedByResize=!1,this.isUpdating=!1,this.isSVG=!1,this.needsReset=!1,this.shouldResetTransform=!1,this.hasCheckedOptimisedAppear=!1,this.treeScale={x:1,y:1},this.eventHandlers=new Map,this.hasTreeAnimated=!1,this.layoutVersion=0,this.updateScheduled=!1,this.scheduleUpdate=()=>this.update(),this.projectionUpdateScheduled=!1,this.checkUpdateFailed=()=>{this.isUpdating&&(this.isUpdating=!1,this.clearAllSnapshots())},this.updateProjection=()=>{this.projectionUpdateScheduled=!1,qy.value&&(iD.nodes=iD.calculatedTargetDeltas=iD.calculatedProjections=0),this.nodes.forEach(pD),this.nodes.forEach(SD),this.nodes.forEach(CD),this.nodes.forEach(mD),qy.addProjectionMetrics&&qy.addProjectionMetrics(iD)},this.resolvedRelativeTargetAt=0,this.linkedParentVersion=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=e,this.root=n?n.root||n:this,this.path=n?[...n.path,n]:[],this.parent=n,this.depth=n?n.depth+1:0;for(let e=0;ethis.root.updateBlockedByResize=!1;Zy.read(()=>{r=window.innerWidth}),e(t,()=>{let e=window.innerWidth;e!==r&&(r=e,this.root.updateBlockedByResize=!0,n&&n(),n=eD(i,250),rD.hasAnimatedSinceResize&&(rD.hasAnimatedSinceResize=!1,this.nodes.forEach(xD)))})}n&&this.root.registerSharedNode(n,this),this.options.animate!==!1&&i&&(n||r)&&this.addEventListener(`didUpdate`,({delta:e,hasLayoutChanged:t,hasRelativeLayoutChanged:n,layout:r})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}let a=this.options.transition||i.getDefaultTransition()||AD,{onLayoutAnimationStart:o,onLayoutAnimationComplete:s}=i.getProps(),c=!this.targetLayout||!IE(this.targetLayout,r),l=!t&&n;if(this.options.layoutRoot||this.resumeFrom||l||t&&(c||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);let t={...rC(a,`layout`),onPlay:o,onComplete:s};(i.shouldReduceMotion||this.options.layoutRoot)&&(t.delay=0,t.type=!1),this.startAnimation(t),this.setAnimationOrigin(e,l,t.path)}else t||xD(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=r})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);let e=this.getStack();e&&e.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),Qy(this.updateProjection)}blockUpdate(){this.updateManuallyBlocked=!0}unblockUpdate(){this.updateManuallyBlocked=!1}isUpdateBlocked(){return this.updateManuallyBlocked||this.updateBlockedByResize}isTreeAnimationBlocked(){return this.isAnimationBlocked||this.parent&&this.parent.isTreeAnimationBlocked()||!1}startUpdate(){this.isUpdateBlocked()||(this.isUpdating=!0,this.nodes&&this.nodes.forEach(wD),this.animationId++)}getTransformTemplate(){let{visualElement:e}=this.options;return e&&e.getProps().transformTemplate}willUpdate(e=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&lD(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let e=0;e{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!_E(this.snapshot.measuredBox.x)&&!_E(this.snapshot.measuredBox.y)&&(this.snapshot=void 0))}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let e=0;e{let n=t/1e3,r=p?.(n);r?(o.x.translate=r.x,o.x.scale=Qb(e.x.scale,1,n),o.x.origin=e.x.origin,o.x.originPoint=e.x.originPoint,o.y.translate=r.y,o.y.scale=Qb(e.y.scale,1,n),o.y.origin=e.y.origin,o.y.originPoint=e.y.originPoint):(ED(o.x,e.x,n),ED(o.y,e.y,n)),this.setTargetDelta(o),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(wE(s,this.layout.layoutBox,this.relativeParent.layout.layoutBox,this.options.layoutAnchor||void 0),OD(this.relativeTarget,this.relativeTargetOrigin,s,n),f&&PE(this.relativeTarget,f)&&(this.isProjectionDirty=!1),f||=Ww(),dE(f,this.relativeTarget)),c&&(this.animationValues=a,GE(a,i,this.latestValues,n,d,u)),r&&r.rotate!==void 0&&(this.animationValues||=a,this.animationValues.pathRotation=r.rotate),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=n},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(e){this.notifyListeners(`animationStart`),this.currentAnimation?.stop(),this.resumingFrom?.currentAnimation?.stop(),this.pendingAnimation&&=(Qy(this.pendingAnimation),void 0),this.pendingAnimation=Zy.update(()=>{rD.hasAnimatedSinceResize=!0,ib.layout++,this.motionValue||=tC(0),this.motionValue.jump(0,!1),this.currentAnimation=XE(this.motionValue,[0,1e3],{...e,velocity:0,isSync:!0,onUpdate:t=>{this.mixTargetDelta(t),e.onUpdate&&e.onUpdate(t)},onStop:()=>{ib.layout--},onComplete:()=>{ib.layout--,e.onComplete&&e.onComplete(),this.completeAnimation()}}),this.resumingFrom&&(this.resumingFrom.currentAnimation=this.currentAnimation),this.pendingAnimation=void 0})}completeAnimation(){this.resumingFrom&&(this.resumingFrom.currentAnimation=void 0,this.resumingFrom.preserveOpacity=void 0);let e=this.getStack();e&&e.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners(`animationComplete`)}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(oD),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){let e=this.getLead(),{targetWithTransforms:t,target:n,layout:r,latestValues:i}=e;if(!(!t||!n||!r)){if(this!==e&&this.layout&&r&&FD(this.options.animationType,this.layout.layoutBox,r.layoutBox)){n=this.target||Ww();let t=_E(this.layout.layoutBox.x);n.x.min=e.target.x.min,n.x.max=n.x.min+t;let r=_E(this.layout.layoutBox.y);n.y.min=e.target.y.min,n.y.max=n.y.min+r}dE(t,n),OT(t,i),bE(this.projectionDeltaWithTransform,this.layoutCorrected,t,i)}}registerSharedNode(e,t){this.sharedNodes.has(e)||this.sharedNodes.set(e,new nD),this.sharedNodes.get(e).add(t);let n=t.options.initialPromotionConfig;t.promote({transition:n?n.transition:void 0,preserveFollowOpacity:n&&n.shouldPreserveFollowOpacity?n.shouldPreserveFollowOpacity(t):void 0})}isLead(){let e=this.getStack();return e?e.lead===this:!0}getLead(){let{layoutId:e}=this.options;return e&&this.getStack()?.lead||this}getPrevLead(){let{layoutId:e}=this.options;return e?this.getStack()?.prevLead:void 0}getStack(){let{layoutId:e}=this.options;if(e)return this.root.sharedNodes.get(e)}promote({needsReset:e,transition:t,preserveFollowOpacity:n}={}){let r=this.getStack();r&&r.promote(this,n),e&&(this.projectionDelta=void 0,this.needsReset=!0),t&&this.setOptions({transition:t})}relegate(){let e=this.getStack();return e?e.relegate(this):!1}resetSkewAndRotation(){let{visualElement:e}=this.options;if(!e)return;let t=!1,{latestValues:n}=e;if((n.z||n.rotate||n.rotateX||n.rotateY||n.rotateZ||n.skewX||n.skewY)&&(t=!0),!t)return;let r={};n.z&&cD(`z`,e,r,this.animationValues);for(let t=0;te.currentAnimation?.stop()),this.root.nodes.forEach(gD),this.root.sharedNodes.clear()}}}function dD(e){e.updateLayout()}function fD(e){let t=e.resumeFrom?.snapshot||e.snapshot;if(e.isLead()&&e.layout&&t&&e.hasListeners(`didUpdate`)){let{layoutBox:n,measuredBox:r}=e.layout,{animationType:i}=e.options,a=t.source!==e.layout.source;if(i===`size`)zE(e=>{let r=a?t.measuredBox[e]:t.layoutBox[e],i=_E(r);r.min=n[e].min,r.max=r.min+i});else if(i===`x`||i===`y`){let e=i===`x`?`y`:`x`;uE(a?t.measuredBox[e]:t.layoutBox[e],n[e])}else FD(i,t.layoutBox,n)&&zE(r=>{let i=a?t.measuredBox[r]:t.layoutBox[r],o=_E(n[r]);i.max=i.min+o,e.relativeTarget&&!e.currentAnimation&&(e.isProjectionDirty=!0,e.relativeTarget[r].max=e.relativeTarget[r].min+o)});let o=Hw();bE(o,n,t.layoutBox);let s=Hw();a?bE(s,e.applyTransform(r,!0),t.measuredBox):bE(s,n,t.layoutBox);let c=!ME(o),l=!1;if(!e.resumeFrom){let r=e.getClosestProjectingParent();if(r&&!r.resumeFrom){let{snapshot:i,layout:a}=r;if(i&&a){let o=e.options.layoutAnchor||void 0,s=Ww();wE(s,t.layoutBox,i.layoutBox,o);let c=Ww();wE(c,n,a.layoutBox,o),IE(s,c)||(l=!0),r.options.layoutRoot&&(e.relativeTarget=c,e.relativeTargetOrigin=s,e.relativeParent=r)}}}e.notifyListeners(`didUpdate`,{layout:n,snapshot:t,delta:s,layoutDelta:o,hasLayoutChanged:c,hasRelativeLayoutChanged:l})}else if(e.isLead()){let{onExitComplete:t}=e.options;t&&t()}e.options.transition=void 0}function pD(e){qy.value&&iD.nodes++,e.parent&&(e.isProjecting()||(e.isProjectionDirty=e.parent.isProjectionDirty),e.isSharedProjectionDirty||=!!(e.isProjectionDirty||e.parent.isProjectionDirty||e.parent.isSharedProjectionDirty),e.isTransformDirty||=e.parent.isTransformDirty)}function mD(e){e.isProjectionDirty=e.isSharedProjectionDirty=e.isTransformDirty=!1}function hD(e){e.clearSnapshot()}function gD(e){e.clearMeasurements()}function _D(e){e.isLayoutDirty=!0,e.updateLayout()}function vD(e){e.isLayoutDirty=!1}function yD(e){e.isAnimationBlocked&&e.layout&&!e.isLayoutDirty&&(e.snapshot=e.layout,e.isLayoutDirty=!0)}function bD(e){let{visualElement:t}=e.options;t&&t.getProps().onBeforeLayoutMeasure&&t.notify(`BeforeLayoutMeasure`),e.resetTransform()}function xD(e){e.finishAnimation(),e.targetDelta=e.relativeTarget=e.target=void 0,e.isProjectionDirty=!0}function SD(e){e.resolveTargetDelta()}function CD(e){e.calcProjection()}function wD(e){e.resetSkewAndRotation()}function TD(e){e.removeLeadSnapshot()}function ED(e,t,n){e.translate=Qb(t.translate,0,n),e.scale=Qb(t.scale,1,n),e.origin=t.origin,e.originPoint=t.originPoint}function DD(e,t,n,r){e.min=Qb(t.min,n.min,r),e.max=Qb(t.max,n.max,r)}function OD(e,t,n,r){DD(e.x,t.x,n.x,r),DD(e.y,t.y,n.y,r)}function kD(e){return e.animationValues&&e.animationValues.opacityExit!==void 0}var AD={duration:.45,ease:[.4,0,.1,1]},jD=e=>typeof navigator<`u`&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(e),MD=jD(`applewebkit/`)&&!jD(`chrome/`)?Math.round:_y;function ND(e){e.min=MD(e.min),e.max=MD(e.max)}function PD(e){ND(e.x),ND(e.y)}function FD(e,t,n){return e===`position`||e===`preserve-aspect`&&!vE(LE(t),LE(n),.2)}function ID(e){return e!==e.root&&e.scroll?.wasRoot}var LD=uD({attachResizeListener:(e,t)=>ZE(e,`resize`,t),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body?.scrollLeft||0,y:document.documentElement.scrollTop||document.body?.scrollTop||0}),checkIsScrollRoot:()=>!0}),RD={current:void 0},zD=uD({measureScroll:e=>({x:e.scrollLeft,y:e.scrollTop}),defaultParent:()=>{if(!RD.current){let e=new LD({});e.mount(window),e.setOptions({layoutScroll:!0}),RD.current=e}return RD.current},resetTransform:(e,t)=>{e.style.transform=t===void 0?`none`:t},checkIsScrollRoot:e=>window.getComputedStyle(e).position===`fixed`}),BD=(0,b.createContext)({transformPagePoint:e=>e,isStatic:!1,reducedMotion:`never`});function VD(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}function HD(...e){return t=>{let n=!1,r=e.map(e=>{let r=VD(e,t);return!n&&typeof r==`function`&&(n=!0),r});if(n)return()=>{for(let t=0;t{let{width:e,height:u,top:d,left:f,right:p,bottom:m,direction:h}=c.current;if(t||a===!1||!s.current||!e||!u)return;let g=h===`rtl`,_=n===`left`?g?`right: ${p}`:`left: ${f}`:g?`left: ${f}`:`right: ${p}`,v=r===`bottom`?`bottom: ${m}`:`top: ${d}`;s.current.dataset.motionPopId=o;let y=document.createElement(`style`);l&&(y.nonce=l);let b=i??document.head;return b.appendChild(y),y.sheet&&y.sheet.insertRule(` [data-motion-pop-id="${o}"] { position: absolute !important; width: ${e}px !important; height: ${u}px !important; ${_}px !important; ${v}px !important; } `),()=>{s.current?.removeAttribute(`data-motion-pop-id`),b.contains(y)&&b.removeChild(y)}},[t]),(0,X.jsx)(WD,{isPresent:t,childRef:s,sizeRef:c,pop:a,children:a===!1?e:b.cloneElement(e,{ref:u})})}var KD=({children:e,initial:t,isPresent:n,onExitComplete:r,custom:i,presenceAffectsLayout:a,mode:o,anchorX:s,anchorY:c,root:l})=>{let u=oy(qD),d=(0,b.useId)(),f=!0,p=(0,b.useMemo)(()=>(f=!1,{id:d,initial:t,isPresent:n,custom:i,onExitComplete:e=>{u.set(e,!0);for(let e of u.values())if(!e)return;r&&r()},register:e=>(u.set(e,!1),()=>u.delete(e))}),[n,u,r]);return a&&f&&(p={...p}),(0,b.useMemo)(()=>{u.forEach((e,t)=>u.set(t,!1))},[n]),b.useEffect(()=>{!n&&!u.size&&r&&r()},[n]),e=(0,X.jsx)(GD,{pop:o===`popLayout`,isPresent:n,anchorX:s,anchorY:c,root:l,children:e}),(0,X.jsx)(cy.Provider,{value:p,children:e})};function qD(){return new Map}function JD(e=!0){let t=(0,b.useContext)(cy);if(t===null)return[!0,null];let{isPresent:n,onExitComplete:r,register:i}=t,a=(0,b.useId)();(0,b.useEffect)(()=>{if(e)return i(a)},[e]);let o=(0,b.useCallback)(()=>e&&r&&r(a),[a,r,e]);return!n&&r?[!1,o]:[!0]}var YD=e=>e.key||``;function XD(e){let t=[];return b.Children.forEach(e,e=>{(0,b.isValidElement)(e)&&t.push(e)}),t}var ZD=({children:e,custom:t,initial:n=!0,onExitComplete:r,presenceAffectsLayout:i=!0,mode:a=`sync`,propagate:o=!1,anchorX:s=`left`,anchorY:c=`top`,root:l})=>{let[u,d]=JD(o),f=(0,b.useMemo)(()=>XD(e),[e]),p=o&&!u?[]:f.map(YD),m=(0,b.useRef)(!0),h=(0,b.useRef)(f),g=oy(()=>new Map),_=(0,b.useRef)(new Set),[v,y]=(0,b.useState)(f),[x,S]=(0,b.useState)(f);sy(()=>{m.current=!1,h.current=f;for(let e=0;e{let v=YD(e),y=o&&!u?!1:f===x||p.includes(v);return(0,X.jsx)(KD,{isPresent:y,initial:!m.current||n?void 0:!1,custom:t,presenceAffectsLayout:i,mode:a,root:l,onExitComplete:y?void 0:()=>{if(_.current.has(v))return;if(g.has(v))_.current.add(v),g.set(v,!0);else return;let e=!0;g.forEach(t=>{t||(e=!1)}),e&&(w?.(),S(h.current),o&&d?.(),r&&r())},anchorX:s,anchorY:c,children:e},v)})})},QD=(0,b.createContext)({strict:!1}),$D={animation:[`animate`,`variants`,`whileHover`,`whileTap`,`exit`,`whileInView`,`whileFocus`,`whileDrag`],exit:[`exit`],drag:[`drag`,`dragControls`],focus:[`whileFocus`],hover:[`whileHover`,`onHoverStart`,`onHoverEnd`],tap:[`whileTap`,`onTap`,`onTapStart`,`onTapCancel`],pan:[`onPan`,`onPanStart`,`onPanSessionStart`,`onPanEnd`],inView:[`whileInView`,`onViewportEnter`,`onViewportLeave`],layout:[`layout`,`layoutId`]},eO=!1;function tO(){if(eO)return;let e={};for(let t in $D)e[t]={isEnabled:e=>$D[t].some(t=>!!e[t])};aT(e),eO=!0}function nO(){return tO(),oT()}function rO(e){let t=nO();for(let n in e)t[n]={...t[n],...e[n]};aT(t)}var iO=new Set(`animate.exit.variants.initial.style.values.variants.transition.transformTemplate.custom.inherit.onBeforeLayoutMeasure.onAnimationStart.onAnimationComplete.onUpdate.onDragStart.onDrag.onDragEnd.onMeasureDragConstraints.onDirectionLock.onDragTransitionEnd._dragX._dragY.onHoverStart.onHoverEnd.onViewportEnter.onViewportLeave.globalTapTarget.propagate.ignoreStrict.viewport`.split(`.`));function aO(e){return e.startsWith(`while`)||e.startsWith(`drag`)&&e!==`draggable`||e.startsWith(`layout`)||e.startsWith(`onTap`)||e.startsWith(`onPan`)||e.startsWith(`onLayout`)||iO.has(e)}var oO=c({default:()=>sO}),sO,cO=o((()=>{throw sO={},Error(`Could not resolve "@emotion/is-prop-valid" imported by "framer-motion". Is it installed?`)})),lO=e=>!aO(e);function uO(e){typeof e==`function`&&(lO=t=>t.startsWith(`on`)?!aO(t):e(t))}try{uO((cO(),d(oO)).default)}catch{}function dO(e,t,n){let r={};for(let i in e)i===`values`&&typeof e.values==`object`||CC(e[i])||(lO(i)||n===!0&&aO(i)||!t&&!aO(i)||e.draggable&&i.startsWith(`onDrag`))&&(r[i]=e[i]);return r}var fO=(0,b.createContext)({});function pO(e,t){if(Xw(e)){let{initial:t,animate:n}=e;return{initial:t===!1||qw(t)?t:void 0,animate:qw(n)?n:void 0}}return e.inherit===!1?{}:t}function mO(e){let{initial:t,animate:n}=pO(e,(0,b.useContext)(fO));return(0,b.useMemo)(()=>({initial:t,animate:n}),[hO(t),hO(n)])}function hO(e){return Array.isArray(e)?e.join(` `):e}var gO=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function _O(e,t,n){for(let r in t)!CC(t[r])&&!BT(r,n)&&(e[r]=t[r])}function vO({transformTemplate:e},t){return(0,b.useMemo)(()=>{let n=gO();return PT(n,t,e),Object.assign({},n.vars,n.style)},[t])}function yO(e,t){let n=e.style||{},r={};return _O(r,n,e),Object.assign(r,vO(e,t)),r}function bO(e,t){let n={},r=yO(e,t);return e.drag&&e.dragListener!==!1&&(n.draggable=!1,r.userSelect=r.WebkitUserSelect=r.WebkitTouchCallout=`none`,r.touchAction=e.drag===!0?`none`:`pan-${e.drag===`x`?`y`:`x`}`),e.tabIndex===void 0&&(e.onTap||e.onTapStart||e.whileTap)&&(n.tabIndex=0),n.style=r,n}var xO=()=>({...gO(),attrs:{}});function SO(e,t,n,r){let i=(0,b.useMemo)(()=>{let n=xO();return JT(n,t,XT(r),e.transformTemplate,e.style),{...n.attrs,style:{...n.style}}},[t]);if(e.style){let t={};_O(t,e.style,e),i.style={...t,...i.style}}return i}var CO=[`animate`,`circle`,`defs`,`desc`,`ellipse`,`g`,`image`,`line`,`filter`,`marker`,`mask`,`metadata`,`path`,`pattern`,`polygon`,`polyline`,`rect`,`stop`,`switch`,`symbol`,`svg`,`text`,`tspan`,`use`,`view`];function wO(e){return typeof e!=`string`||e.includes(`-`)?!1:!!(CO.indexOf(e)>-1||/[A-Z]/u.test(e))}function TO(e,t,n,{latestValues:r},i,a=!1,o){let s=(o??wO(e)?SO:bO)(t,r,i,e),c=dO(t,typeof e==`string`,a),l=e===b.Fragment?{}:{...c,...s,ref:n},{children:u}=t,d=(0,b.useMemo)(()=>CC(u)?u.get():u,[u]);return(0,b.createElement)(e,{...l,children:d})}function EO({scrapeMotionValuesFromProps:e,createRenderState:t},n,r,i){return{latestValues:DO(n,r,i,e),renderState:t()}}function DO(e,t,n,r){let i={},a=r(e,{});for(let e in a)i[e]=tD(a[e]);let{initial:o,animate:s}=e,c=Xw(e),l=Zw(e);t&&l&&!c&&e.inherit!==!1&&(o===void 0&&(o=t.initial),s===void 0&&(s=t.animate));let u=n?n.initial===!1:!1;u||=o===!1;let d=u?s:o;if(d&&typeof d!=`boolean`&&!Kw(d)){let t=Array.isArray(d)?d:[d];for(let n=0;n(t,n)=>{let r=(0,b.useContext)(fO),i=(0,b.useContext)(cy),a=()=>EO(e,t,r,i);return n?a():oy(a)},kO=OO({scrapeMotionValuesFromProps:VT,createRenderState:gO}),AO=OO({scrapeMotionValuesFromProps:QT,createRenderState:xO}),jO=Symbol.for(`motionComponentSymbol`);function MO(e,t,n){let r=(0,b.useRef)(n);(0,b.useInsertionEffect)(()=>{r.current=n});let i=(0,b.useRef)(null);return(0,b.useCallback)(n=>{n&&e.onMount?.(n),t&&(n?t.mount(n):t.unmount());let a=r.current;if(typeof a==`function`)if(n){let e=a(n);typeof e==`function`&&(i.current=e)}else i.current?(i.current(),i.current=null):a(n);else a&&(a.current=n)},[t])}var NO=(0,b.createContext)({});function PO(e){return e&&typeof e==`object`&&Object.prototype.hasOwnProperty.call(e,`current`)}function FO(e,t,n,r,i,a){let{visualElement:o}=(0,b.useContext)(fO),s=(0,b.useContext)(QD),c=(0,b.useContext)(cy),l=(0,b.useContext)(BD),u=l.reducedMotion,d=l.skipAnimations,f=(0,b.useRef)(null),p=(0,b.useRef)(!1);r||=s.renderer,!f.current&&r&&(f.current=r(e,{visualState:t,parent:o,props:n,presenceContext:c,blockInitialAnimation:c?c.initial===!1:!1,reducedMotionConfig:u,skipAnimations:d,isSVG:a}),p.current&&f.current&&(f.current.manuallyAnimateOnMount=!0));let m=f.current,h=(0,b.useContext)(NO);m&&!m.projection&&i&&(m.type===`html`||m.type===`svg`)&&IO(f.current,n,i,h);let g=(0,b.useRef)(!1);(0,b.useInsertionEffect)(()=>{m&&g.current&&m.update(n,c)});let _=n[DC],v=(0,b.useRef)(!!_&&typeof window<`u`&&!window.MotionHandoffIsComplete?.(_)&&window.MotionHasOptimisedAnimation?.(_));return sy(()=>{p.current=!0,m&&(g.current=!0,window.MotionIsMounted=!0,m.updateFeatures(),m.scheduleRenderMicrotask(),v.current&&m.animationState&&m.animationState.animateChanges())}),(0,b.useEffect)(()=>{m&&(!v.current&&m.animationState&&m.animationState.animateChanges(),v.current&&=(queueMicrotask(()=>{window.MotionHandoffMarkAsComplete?.(_)}),!1),m.enteringChildren=void 0)}),m}function IO(e,t,n,r){let{layoutId:i,layout:a,drag:o,dragConstraints:s,layoutScroll:c,layoutRoot:l,layoutAnchor:u,layoutCrossfade:d}=t;e.projection=new n(e.latestValues,t[`data-framer-portal-id`]?void 0:LO(e.parent)),e.projection.setOptions({layoutId:i,layout:a,alwaysMeasureLayout:!!o||s&&PO(s),visualElement:e,animationType:typeof a==`string`?a:`both`,initialPromotionConfig:r,crossfade:d,layoutScroll:c,layoutRoot:l,layoutAnchor:u})}function LO(e){if(e)return e.options.allowProjection===!1?LO(e.parent):e.projection}function RO(e,{forwardMotionProps:t=!1,type:n}={},r,i){r&&rO(r);let a=n?n===`svg`:wO(e),o=a?AO:kO;function s(n,s){let c,l={...(0,b.useContext)(BD),...n,layoutId:zO(n)},{isStatic:u}=l,d=mO(n),f=o(n,u);if(!u&&typeof window<`u`){BO(l,r);let t=VO(l);c=t.MeasureLayout,d.visualElement=FO(e,f,l,i,t.ProjectionNode,a)}return(0,X.jsxs)(fO.Provider,{value:d,children:[c&&d.visualElement?(0,X.jsx)(c,{visualElement:d.visualElement,...l}):null,TO(e,n,MO(f,d.visualElement,s),f,u,t,a)]})}s.displayName=`motion.${typeof e==`string`?e:`create(${e.displayName??e.name??``})`}`;let c=(0,b.forwardRef)(s);return c[jO]=e,c}function zO({layoutId:e}){let t=(0,b.useContext)(ay).id;return t&&e!==void 0?t+`-`+e:e}function BO(e,t){(0,b.useContext)(QD).strict}function VO(e){let{drag:t,layout:n}=nO();if(!t&&!n)return{};let r={...t,...n};return{MeasureLayout:t?.isEnabled(e)||n?.isEnabled(e)?r.MeasureLayout:void 0,ProjectionNode:r.ProjectionNode}}function HO(e,t){if(typeof Proxy>`u`)return RO;let n=new Map,r=(n,r)=>RO(n,r,e,t);return new Proxy((e,t)=>r(e,t),{get:(i,a)=>a===`create`?r:(n.has(a)||n.set(a,RO(a,void 0,e,t)),n.get(a))})}var UO=(e,t)=>t.isSVG??wO(e)?new $T(t):new UT(t,{allowProjection:e!==b.Fragment}),WO=class extends lT{constructor(e){super(e),e.animationState||=oE(e)}updateAnimationControlsSubscription(){let{animate:e}=this.node.getProps();Kw(e)&&(this.unmountControls=e.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){let{animate:e}=this.node.getProps(),{animate:t}=this.node.prevProps||{};e!==t&&this.updateAnimationControlsSubscription()}unmount(){this.node.animationState.reset(),this.unmountControls?.()}},GO=0,KO={animation:{Feature:WO},exit:{Feature:class extends lT{constructor(){super(...arguments),this.id=GO++,this.isExitComplete=!1}update(){if(!this.node.presenceContext)return;let{isPresent:e,onExitComplete:t}=this.node.presenceContext,{isPresent:n}=this.node.prevPresenceContext||{};if(!this.node.animationState||e===n)return;if(e&&n===!1){if(this.isExitComplete){let{initial:e,custom:t}=this.node.getProps();if(typeof e==`string`||typeof e==`object`&&e&&!Array.isArray(e)){let n=_C(this.node,e,t);if(n){let{transition:e,transitionEnd:t,...r}=n;for(let e in r)this.node.getValue(e)?.jump(r[e])}}this.node.animationState.reset(),this.node.animationState.animateChanges()}else this.node.animationState.setActive(`exit`,!1);this.isExitComplete=!1;return}let r=this.node.animationState.setActive(`exit`,!e);t&&!e&&r.then(()=>{this.isExitComplete=!0,t(this.id)})}mount(){let{register:e,onExitComplete:t}=this.node.presenceContext||{};t&&t(this.id),e&&(this.unmount=e(this.id))}unmount(){}}}};function qO(e){return{point:{x:e.pageX,y:e.pageY}}}var JO=e=>t=>dw(t)&&e(t,qO(t));function YO(e,t,n,r){return ZE(e,t,JO(n),r)}var XO=({current:e})=>e?e.ownerDocument.defaultView:null,ZO=(e,t)=>Math.abs(e-t);function QO(e,t){let n=ZO(e.x,t.x),r=ZO(e.y,t.y);return Math.sqrt(n**2+r**2)}var $O=new Set([`auto`,`scroll`]),ek=class{constructor(e,t,{transformPagePoint:n,contextWindow:r=window,dragSnapToOrigin:i=!1,distanceThreshold:a=3,element:o}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.lastRawMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.scrollPositions=new Map,this.removeScrollListeners=null,this.onElementScroll=e=>{this.handleScroll(e.target)},this.onWindowScroll=()=>{this.handleScroll(window)},this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;this.lastRawMoveEventInfo&&(this.lastMoveEventInfo=tk(this.lastRawMoveEventInfo,this.transformPagePoint));let e=rk(this.lastMoveEventInfo,this.history),t=this.startEvent!==null,n=QO(e.offset,{x:0,y:0})>=this.distanceThreshold;if(!t&&!n)return;let{point:r}=e,{timestamp:i}=$y;this.history.push({...r,timestamp:i});let{onStart:a,onMove:o}=this.handlers;t||(a&&a(this.lastMoveEvent,e),this.startEvent=this.lastMoveEvent),o&&o(this.lastMoveEvent,e)},this.handlePointerMove=(e,t)=>{this.lastMoveEvent=e,this.lastRawMoveEventInfo=t,this.lastMoveEventInfo=tk(t,this.transformPagePoint),Zy.update(this.updatePoint,!0)},this.handlePointerUp=(e,t)=>{this.end();let{onEnd:n,onSessionEnd:r,resumeAnimation:i}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&i&&i(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;let a=rk(e.type===`pointercancel`?this.lastMoveEventInfo:tk(t,this.transformPagePoint),this.history);this.startEvent&&n&&n(e,a),r&&r(e,a)},!dw(e))return;this.dragSnapToOrigin=i,this.handlers=t,this.transformPagePoint=n,this.distanceThreshold=a,this.contextWindow=r||window;let s=tk(qO(e),this.transformPagePoint),{point:c}=s,{timestamp:l}=$y;this.history=[{...c,timestamp:l}];let{onSessionStart:u}=t;u&&u(e,rk(s,this.history)),this.removeListeners=vy(YO(this.contextWindow,`pointermove`,this.handlePointerMove),YO(this.contextWindow,`pointerup`,this.handlePointerUp),YO(this.contextWindow,`pointercancel`,this.handlePointerUp)),o&&this.startScrollTracking(o)}startScrollTracking(e){let t=e.parentElement;for(;t;){let e=getComputedStyle(t);($O.has(e.overflowX)||$O.has(e.overflowY))&&this.scrollPositions.set(t,{x:t.scrollLeft,y:t.scrollTop}),t=t.parentElement}this.scrollPositions.set(window,{x:window.scrollX,y:window.scrollY}),window.addEventListener(`scroll`,this.onElementScroll,{capture:!0}),window.addEventListener(`scroll`,this.onWindowScroll),this.removeScrollListeners=()=>{window.removeEventListener(`scroll`,this.onElementScroll,{capture:!0}),window.removeEventListener(`scroll`,this.onWindowScroll)}}handleScroll(e){let t=this.scrollPositions.get(e);if(!t)return;let n=e===window,r=n?{x:window.scrollX,y:window.scrollY}:{x:e.scrollLeft,y:e.scrollTop},i={x:r.x-t.x,y:r.y-t.y};i.x===0&&i.y===0||(n?this.lastMoveEventInfo&&(this.lastMoveEventInfo.point.x+=i.x,this.lastMoveEventInfo.point.y+=i.y):this.history.length>0&&(this.history[0].x-=i.x,this.history[0].y-=i.y),this.scrollPositions.set(e,r),Zy.update(this.updatePoint,!0))}updateHandlers(e){this.handlers=e}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),Qy(this.updatePoint)}};function tk(e,t){return t?{point:t(e.point)}:e}function nk(e,t){return{x:e.x-t.x,y:e.y-t.y}}function rk({point:e},t){return{point:e,delta:nk(e,ak(t)),offset:nk(e,ik(t)),velocity:ok(t,.1)}}function ik(e){return e[0]}function ak(e){return e[e.length-1]}function ok(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,r=null,i=ak(e);for(;n>=0&&(r=e[n],!(i.timestamp-r.timestamp>xy(t)));)n--;if(!r)return{x:0,y:0};r===e[0]&&e.length>2&&i.timestamp-r.timestamp>xy(t)*2&&(r=e[1]);let a=Sy(i.timestamp-r.timestamp);if(a===0)return{x:0,y:0};let o={x:(i.x-r.x)/a,y:(i.y-r.y)/a};return o.x===1/0&&(o.x=0),o.y===1/0&&(o.y=0),o}function sk(e,{min:t,max:n},r){return t!==void 0&&en&&(e=r?Qb(n,e,r.max):Math.min(e,n)),e}function ck(e,t,n){return{min:t===void 0?void 0:e.min+t,max:n===void 0?void 0:e.max+n-(e.max-e.min)}}function lk(e,{top:t,left:n,bottom:r,right:i}){return{x:ck(e.x,n,i),y:ck(e.y,t,r)}}function uk(e,t){let n=t.min-e.min,r=t.max-e.max;return t.max-t.minr?n=yy(t.min,t.max-r,e.min):r>i&&(n=yy(e.min,e.max-i,t.min)),dy(0,1,n)}function pk(e,t){let n={};return t.min!==void 0&&(n.min=t.min-e.min),t.max!==void 0&&(n.max=t.max-e.min),n}var mk=.35;function hk(e=mk){return e===!1?e=0:e===!0&&(e=mk),{x:gk(e,`left`,`right`),y:gk(e,`top`,`bottom`)}}function gk(e,t,n){return{min:_k(e,t),max:_k(e,n)}}function _k(e,t){return typeof e==`number`?e:e[t]||0}var vk=new WeakMap,yk=class{constructor(e){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=Ww(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=e}start(e,{snapToCursor:t=!1,distanceThreshold:n}={}){let{presenceContext:r}=this.visualElement;if(r&&r.isPresent===!1)return;let i=e=>{t&&this.snapToCursor(qO(e).point),this.stopAnimation()},a=(e,t)=>{let{drag:n,dragPropagation:r,onDragStart:i}=this.getProps();if(n&&!r&&(this.openDragLock&&this.openDragLock(),this.openDragLock=ow(n),!this.openDragLock))return;this.latestPointerEvent=e,this.latestPanInfo=t,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),zE(e=>{let t=this.getAxisMotionValue(e).get()||0;if(Db.test(t)){let{projection:n}=this.visualElement;if(n&&n.layout){let r=n.layout.layoutBox[e];r&&(t=_E(r)*(parseFloat(t)/100))}}this.originPoint[e]=t}),i&&Zy.update(()=>i(e,t),!1,!0),TC(this.visualElement,`transform`);let{animationState:a}=this.visualElement;a&&a.setActive(`whileDrag`,!0)},o=(e,t)=>{this.latestPointerEvent=e,this.latestPanInfo=t;let{dragPropagation:n,dragDirectionLock:r,onDirectionLock:i,onDrag:a}=this.getProps();if(!n&&!this.openDragLock)return;let{offset:o}=t;if(r&&this.currentDirection===null){this.currentDirection=Ck(o),this.currentDirection!==null&&i&&i(this.currentDirection);return}this.updateAxis(`x`,t.point,o),this.updateAxis(`y`,t.point,o),this.visualElement.render(),a&&Zy.update(()=>a(e,t),!1,!0)},s=(e,t)=>{this.latestPointerEvent=e,this.latestPanInfo=t,this.stop(e,t),this.latestPointerEvent=null,this.latestPanInfo=null},c=()=>{let{dragSnapToOrigin:e}=this.getProps();(e||this.constraints)&&this.startAnimation({x:0,y:0})},{dragSnapToOrigin:l}=this.getProps();this.panSession=new ek(e,{onSessionStart:i,onStart:a,onMove:o,onSessionEnd:s,resumeAnimation:c},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:l,distanceThreshold:n,contextWindow:XO(this.visualElement),element:this.visualElement.current})}stop(e,t){let n=e||this.latestPointerEvent,r=t||this.latestPanInfo,i=this.isDragging;if(this.cancel(),!i||!r||!n)return;let{velocity:a}=r;this.startAnimation(a);let{onDragEnd:o}=this.getProps();o&&Zy.postRender(()=>o(n,r))}cancel(){this.isDragging=!1;let{projection:e,animationState:t}=this.visualElement;e&&(e.isAnimationBlocked=!1),this.endPanSession();let{dragPropagation:n}=this.getProps();!n&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),t&&t.setActive(`whileDrag`,!1)}endPanSession(){this.panSession&&this.panSession.end(),this.panSession=void 0}updateAxis(e,t,n){let{drag:r}=this.getProps();if(!n||!Sk(e,r,this.currentDirection))return;let i=this.getAxisMotionValue(e),a=this.originPoint[e]+n[e];this.constraints&&this.constraints[e]&&(a=sk(a,this.constraints[e],this.elastic[e])),i.set(a)}resolveConstraints(){let{dragConstraints:e,dragElastic:t}=this.getProps(),n=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):this.visualElement.projection?.layout,r=this.constraints;e&&PO(e)?this.constraints||=this.resolveRefConstraints():e&&n?this.constraints=lk(n.layoutBox,e):this.constraints=!1,this.elastic=hk(t),r!==this.constraints&&!PO(e)&&n&&this.constraints&&!this.hasMutatedConstraints&&zE(e=>{this.constraints!==!1&&this.getAxisMotionValue(e)&&(this.constraints[e]=pk(n.layoutBox[e],this.constraints[e]))})}resolveRefConstraints(){let{dragConstraints:e,onMeasureDragConstraints:t}=this.getProps();if(!e||!PO(e))return!1;let n=e.current,{projection:r}=this.visualElement;if(!r||!r.layout)return!1;r.root&&(r.root.scroll=void 0,r.root.updateScroll());let i=AT(n,r.root,this.visualElement.getTransformPagePoint()),a=dk(r.layout.layoutBox,i);if(t){let e=t(dT(a));this.hasMutatedConstraints=!!e,e&&(a=uT(e))}return a}startAnimation(e){let{drag:t,dragMomentum:n,dragElastic:r,dragTransition:i,dragSnapToOrigin:a,onDragTransitionEnd:o}=this.getProps(),s=this.constraints||{},c=zE(o=>{if(!Sk(o,t,this.currentDirection))return;let c=s&&s[o]||{};(a===!0||a===o)&&(c={min:0,max:0});let l=r?200:1e6,u=r?40:1e7,d={type:`inertia`,velocity:n?e[o]:0,bounceStiffness:l,bounceDamping:u,timeConstant:750,restDelta:1,restSpeed:10,...i,...c};return this.startAxisValueAnimation(o,d)});return Promise.all(c).then(o)}startAxisValueAnimation(e,t){let n=this.getAxisMotionValue(e);return TC(this.visualElement,e),n.start(dC(e,n,0,t,this.visualElement,!1))}stopAnimation(){zE(e=>this.getAxisMotionValue(e).stop())}getAxisMotionValue(e){let t=`_drag${e.toUpperCase()}`;return this.visualElement.getProps()[t]||this.visualElement.getValue(e,this.visualElement.latestValues[e]??0)}snapToCursor(e){zE(t=>{let{drag:n}=this.getProps();if(!Sk(t,n,this.currentDirection))return;let{projection:r}=this.visualElement,i=this.getAxisMotionValue(t);if(r&&r.layout){let{min:n,max:a}=r.layout.layoutBox[t],o=i.get()||0;i.set(e[t]-Qb(n,a,.5)+o)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;let{drag:e,dragConstraints:t}=this.getProps(),{projection:n}=this.visualElement;if(!PO(t)||!n||!this.constraints)return;this.stopAnimation();let r={x:0,y:0};zE(e=>{let t=this.getAxisMotionValue(e);if(t&&this.constraints!==!1){let n=t.get();r[e]=fk({min:n,max:n},this.constraints[e])}});let{transformTemplate:i}=this.visualElement.getProps();this.visualElement.current.style.transform=i?i({},``):`none`,n.root&&n.root.updateScroll(),n.updateLayout(),this.constraints=!1,this.resolveConstraints(),zE(t=>{if(!Sk(t,e,null))return;let n=this.getAxisMotionValue(t),{min:i,max:a}=this.constraints[t];n.set(Qb(i,a,r[t]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;vk.set(this.visualElement,this);let e=this.visualElement.current,t=YO(e,`pointerdown`,t=>{let{drag:n,dragListener:r=!0}=this.getProps(),i=t.target,a=i!==e&&hw(i);n&&r&&!a&&this.start(t)}),n,r=()=>{let{dragConstraints:t}=this.getProps();PO(t)&&t.current&&(this.constraints=this.resolveRefConstraints(),n||=xk(e,t.current,()=>this.scalePositionWithinConstraints()))},{projection:i}=this.visualElement,a=i.addEventListener(`measure`,r);i&&!i.layout&&(i.root&&i.root.updateScroll(),i.updateLayout()),Zy.read(r);let o=ZE(window,`resize`,()=>this.scalePositionWithinConstraints()),s=i.addEventListener(`didUpdate`,(({delta:e,hasLayoutChanged:t})=>{this.isDragging&&t&&(zE(t=>{let n=this.getAxisMotionValue(t);n&&(this.originPoint[t]+=e[t].translate,n.set(n.get()+e[t].translate))}),this.visualElement.render())}));return()=>{o(),t(),a(),s&&s(),n&&n()}}getProps(){let e=this.visualElement.getProps(),{drag:t=!1,dragDirectionLock:n=!1,dragPropagation:r=!1,dragConstraints:i=!1,dragElastic:a=mk,dragMomentum:o=!0}=e;return{...e,drag:t,dragDirectionLock:n,dragPropagation:r,dragConstraints:i,dragElastic:a,dragMomentum:o}}};function bk(e){let t=!0;return()=>{if(t){t=!1;return}e()}}function xk(e,t,n){let r=Lw(e,bk(n)),i=Lw(t,bk(n));return()=>{r(),i()}}function Sk(e,t,n){return(t===!0||t===e)&&(n===null||n===e)}function Ck(e,t=10){let n=null;return Math.abs(e.y)>t?n=`y`:Math.abs(e.x)>t&&(n=`x`),n}var wk=class extends lT{constructor(e){super(e),this.removeGroupControls=_y,this.removeListeners=_y,this.controls=new yk(e)}mount(){let{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||_y}update(){let{dragControls:e}=this.node.getProps(),{dragControls:t}=this.node.prevProps||{};e!==t&&(this.removeGroupControls(),e&&(this.removeGroupControls=e.subscribe(this.controls)))}unmount(){this.removeGroupControls(),this.removeListeners(),this.controls.isDragging||this.controls.endPanSession()}},Tk=e=>(t,n)=>{e&&Zy.update(()=>e(t,n),!1,!0)},Ek=class extends lT{constructor(){super(...arguments),this.removePointerDownListener=_y}onPointerDown(e){this.session=new ek(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:XO(this.node)})}createPanHandlers(){let{onPanSessionStart:e,onPanStart:t,onPan:n,onPanEnd:r}=this.node.getProps();return{onSessionStart:Tk(e),onStart:Tk(t),onMove:Tk(n),onEnd:(e,t)=>{delete this.session,r&&Zy.postRender(()=>r(e,t))}}}mount(){this.removePointerDownListener=YO(this.node.current,`pointerdown`,e=>this.onPointerDown(e))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}},Dk=!1,Ok=class extends b.Component{componentDidMount(){let{visualElement:e,layoutGroup:t,switchLayoutGroup:n,layoutId:r}=this.props,{projection:i}=e;i&&(t.group&&t.group.add(i),n&&n.register&&r&&n.register(i),Dk&&i.root.didUpdate(),i.addEventListener(`animationComplete`,()=>{this.safeToRemove()}),i.setOptions({...i.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),rD.hasEverUpdated=!0}getSnapshotBeforeUpdate(e){let{layoutDependency:t,visualElement:n,drag:r,isPresent:i}=this.props,{projection:a}=n;return a?(a.isPresent=i,e.layoutDependency!==t&&a.setOptions({...a.options,layoutDependency:t}),Dk=!0,r||e.layoutDependency!==t||t===void 0||e.isPresent!==i?a.willUpdate():this.safeToRemove(),e.isPresent!==i&&(i?a.promote():a.relegate()||Zy.postRender(()=>{let e=a.getStack();(!e||!e.members.length)&&this.safeToRemove()})),null):null}componentDidUpdate(){let{visualElement:e,layoutAnchor:t}=this.props,{projection:n}=e;n&&(n.options.layoutAnchor=t,n.root.didUpdate(),nw.postRender(()=>{!n.currentAnimation&&n.isLead()&&this.safeToRemove()}))}componentWillUnmount(){let{visualElement:e,layoutGroup:t,switchLayoutGroup:n}=this.props,{projection:r}=e;Dk=!0,r&&(r.scheduleCheckAfterUnmount(),t&&t.group&&t.group.remove(r),n&&n.deregister&&n.deregister(r))}safeToRemove(){let{safeToRemove:e}=this.props;e&&e()}render(){return null}};function kk(e){let[t,n]=JD(),r=(0,b.useContext)(ay);return(0,X.jsx)(Ok,{...e,layoutGroup:r,switchLayoutGroup:(0,b.useContext)(NO),isPresent:t,safeToRemove:n})}var Ak={pan:{Feature:Ek},drag:{Feature:wk,ProjectionNode:zD,MeasureLayout:kk}};function jk(e,t,n){let{props:r}=e;e.animationState&&r.whileHover&&e.animationState.setActive(`whileHover`,n===`Start`);let i=r[`onHover`+n];i&&Zy.postRender(()=>i(t,qO(t)))}var Mk=class extends lT{mount(){let{current:e}=this.node;e&&(this.unmount=lw(e,(e,t)=>(jk(this.node,t,`Start`),e=>jk(this.node,e,`End`))))}unmount(){}},Nk=class extends lT{constructor(){super(...arguments),this.isActive=!1}onFocus(){let e=!1;try{e=this.node.current.matches(`:focus-visible`)}catch{e=!0}!e||!this.node.animationState||(this.node.animationState.setActive(`whileFocus`,!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive(`whileFocus`,!1),this.isActive=!1)}mount(){this.unmount=vy(ZE(this.node.current,`focus`,()=>this.onFocus()),ZE(this.node.current,`blur`,()=>this.onBlur()))}unmount(){}};function Pk(e,t,n){let{props:r}=e;if(e.current instanceof HTMLButtonElement&&e.current.disabled)return;e.animationState&&r.whileTap&&e.animationState.setActive(`whileTap`,n===`Start`);let i=r[`onTap`+(n===`End`?``:n)];i&&Zy.postRender(()=>i(t,qO(t)))}var Fk=class extends lT{mount(){let{current:e}=this.node;if(!e)return;let{globalTapTarget:t,propagate:n}=this.node.props;this.unmount=Sw(e,(e,t)=>(Pk(this.node,t,`Start`),(e,{success:t})=>Pk(this.node,e,t?`End`:`Cancel`)),{useGlobalTarget:t,stopPropagation:n?.tap===!1})}unmount(){}},Ik=new WeakMap,Lk=new WeakMap,Rk=e=>{let t=Ik.get(e.target);t&&t(e)},zk=e=>{e.forEach(Rk)};function Bk({root:e,...t}){let n=e||document;Lk.has(n)||Lk.set(n,{});let r=Lk.get(n),i=JSON.stringify(t);return r[i]||(r[i]=new IntersectionObserver(zk,{root:e,...t})),r[i]}function Vk(e,t,n){let r=Bk(t);return Ik.set(e,n),r.observe(e),()=>{Ik.delete(e),r.unobserve(e)}}var Hk={some:0,all:1},Uk=class extends lT{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.stopObserver?.();let{viewport:e={}}=this.node.getProps(),{root:t,margin:n,amount:r=`some`,once:i}=e,a={root:t?t.current:void 0,rootMargin:n,threshold:typeof r==`number`?r:Hk[r]},o=e=>{let{isIntersecting:t}=e;if(this.isInView===t||(this.isInView=t,i&&!t&&this.hasEnteredView))return;t&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive(`whileInView`,t);let{onViewportEnter:n,onViewportLeave:r}=this.node.getProps(),a=t?n:r;a&&a(e)};this.stopObserver=Vk(this.node.current,a,o)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>`u`)return;let{props:e,prevProps:t}=this.node;[`amount`,`margin`,`root`].some(Wk(e,t))&&this.startObserver()}unmount(){this.stopObserver?.(),this.hasEnteredView=!1,this.isInView=!1}};function Wk({viewport:e={}},{viewport:t={}}={}){return n=>e[n]!==t[n]}var Gk={inView:{Feature:Uk},tap:{Feature:Fk},focus:{Feature:Nk},hover:{Feature:Mk}},Kk={layout:{ProjectionNode:zD,MeasureLayout:kk}},Q=HO({...KO,...Gk,...Ak,...Kk},UO);function qk(){return qk=Object.assign?Object.assign.bind():function(e){for(var t=1;t>>1|(lA&21845)<<1;uA=(uA&52428)>>>2|(uA&13107)<<2,uA=(uA&61680)>>>4|(uA&3855)<<4,cA[lA]=((uA&65280)>>>8|(uA&255)<<8)>>>1}for(var dA=(function(e,t,n){for(var r=e.length,i=0,a=new Zk(t);i>>c]=l}else for(s=new Zk(r),i=0;i>>15-e[i]);return s}),fA=new Xk(288),lA=0;lA<144;++lA)fA[lA]=8;for(var lA=144;lA<256;++lA)fA[lA]=9;for(var lA=256;lA<280;++lA)fA[lA]=7;for(var lA=280;lA<288;++lA)fA[lA]=8;for(var pA=new Xk(32),lA=0;lA<32;++lA)pA[lA]=5;var mA=dA(fA,9,1),hA=dA(pA,5,1),gA=function(e){for(var t=e[0],n=1;nt&&(t=e[n]);return t},_A=function(e,t,n){var r=t/8|0;return(e[r]|e[r+1]<<8)>>(t&7)&n},vA=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(t&7)},yA=function(e){return(e/8|0)+(e&7&&1)},bA=function(e,t,n){(t==null||t<0)&&(t=0),(n==null||n>e.length)&&(n=e.length);var r=new(e instanceof Zk?Zk:e instanceof Qk?Qk:Xk)(n-t);return r.set(e.subarray(t,n)),r},xA=function(e,t,n){var r=e.length;if(!r||n&&!n.l&&r<5)return t||new Xk(0);var i=!t||n,a=!n||n.i;n||={},t||=new Xk(r*3);var o=function(e){var n=t.length;if(e>n){var r=new Xk(Math.max(n*2,e));r.set(t),t=r}},s=n.f||0,c=n.p||0,l=n.b||0,u=n.l,d=n.d,f=n.m,p=n.n,m=r*8;do{if(!u){n.f=s=_A(e,c,1);var h=_A(e,c+1,3);if(c+=3,!h){var g=yA(c)+4,_=e[g-4]|e[g-3]<<8,v=g+_;if(v>r){if(a)throw`unexpected EOF`;break}i&&o(l+_),t.set(e.subarray(g,v),l),n.b=l+=_,n.p=c=v*8;continue}else if(h==1)u=mA,d=hA,f=9,p=5;else if(h==2){var y=_A(e,c,31)+257,b=_A(e,c+10,15)+4,x=y+_A(e,c+5,31)+1;c+=14;for(var S=new Xk(x),C=new Xk(19),w=0;w>>4;if(g<16)S[w++]=g;else{var k=0,A=0;for(g==16?(A=3+_A(e,c,3),c+=2,k=S[w-1]):g==17?(A=3+_A(e,c,7),c+=3):g==18&&(A=11+_A(e,c,127),c+=7);A--;)S[w++]=k}}var j=S.subarray(0,y),ee=S.subarray(y);f=gA(j),p=gA(ee),u=dA(j,f,1),d=dA(ee,p,1)}else throw`invalid block type`;if(c>m){if(a)throw`unexpected EOF`;break}}i&&o(l+131072);for(var te=(1<>>4;if(c+=k&15,c>m){if(a)throw`unexpected EOF`;break}if(!k)throw`invalid length/literal`;if(P<256)t[l++]=P;else if(P==256){N=c,u=null;break}else{var F=P-254;if(P>264){var w=P-257,ne=$k[w];F=_A(e,c,(1<>>4;if(!re)throw`invalid distance`;c+=re&15;var ee=sA[ie];if(ie>3){var ne=eA[ie];ee+=vA(e,c)&(1<m){if(a)throw`unexpected EOF`;break}i&&o(l+131072);for(var I=l+F;l>>4>7||(e[0]<<8|e[1])%31)throw`invalid zlib data`;if(e[1]&32)throw`invalid zlib data: preset dictionaries not supported`};function wA(e,t){return xA((CA(e),e.subarray(2,-4)),t)}var TA=typeof TextDecoder<`u`&&new TextDecoder;try{TA.decode(SA,{stream:!0})}catch{}var EA=e=>e&&e.isCubeTexture,DA=class extends Va{constructor(e,t){let n=EA(e),r=((n?e.image[0]?.width:e.image.width)??1024)/4,i=Math.floor(Math.log2(r)),a=2**i,o=3*Math.max(a,112),s=4*a,c=[n?`#define ENVMAP_TYPE_CUBE`:``,`#define CUBEUV_TEXEL_WIDTH ${1/o}`,`#define CUBEUV_TEXEL_HEIGHT ${1/s}`,`#define CUBEUV_MAX_MIP ${i}.0`].join(` `)+` #define ENVMAP_TYPE_CUBE_UV varying vec3 vWorldPosition; uniform float radius; uniform float height; uniform float angle; #ifdef ENVMAP_TYPE_CUBE uniform samplerCube map; #else uniform sampler2D map; #endif // From: https://www.shadertoy.com/view/4tsBD7 float diskIntersectWithBackFaceCulling( vec3 ro, vec3 rd, vec3 c, vec3 n, float r ) { float d = dot ( rd, n ); if( d > 0.0 ) { return 1e6; } vec3 o = ro - c; float t = - dot( n, o ) / d; vec3 q = o + rd * t; return ( dot( q, q ) < r * r ) ? t : 1e6; } // From: https://www.iquilezles.org/www/articles/intersectors/intersectors.htm float sphereIntersect( vec3 ro, vec3 rd, vec3 ce, float ra ) { vec3 oc = ro - ce; float b = dot( oc, rd ); float c = dot( oc, oc ) - ra * ra; float h = b * b - c; if( h < 0.0 ) { return -1.0; } h = sqrt( h ); return - b + h; } vec3 project() { vec3 p = normalize( vWorldPosition ); vec3 camPos = cameraPosition; camPos.y -= height; float intersection = sphereIntersect( camPos, p, vec3( 0.0 ), radius ); if( intersection > 0.0 ) { vec3 h = vec3( 0.0, - height, 0.0 ); float intersection2 = diskIntersectWithBackFaceCulling( camPos, p, h, vec3( 0.0, 1.0, 0.0 ), radius ); p = ( camPos + min( intersection, intersection2 ) * p ) / radius; } else { p = vec3( 0.0, 1.0, 0.0 ); } return p; } #include #include void main() { vec3 projectedWorldPosition = project(); #ifdef ENVMAP_TYPE_CUBE vec3 outcolor = textureCube( map, projectedWorldPosition ).rgb; #else vec3 direction = normalize( projectedWorldPosition ); vec2 uv = equirectUv( direction ); vec3 outcolor = texture2D( map, uv ).rgb; #endif gl_FragColor = vec4( outcolor, 1.0 ); #include #include <${Jk>=154?`colorspace_fragment`:`encodings_fragment`}> } `,l={map:{value:e},height:{value:t?.height||15},radius:{value:t?.radius||100}},u=new $c(1,16),d=new Cl({uniforms:l,fragmentShader:c,vertexShader:` varying vec3 vWorldPosition; void main() { vec4 worldPosition = ( modelMatrix * vec4( position, 1.0 ) ); vWorldPosition = worldPosition.xyz; gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); } `,side:2});super(u,d)}set radius(e){this.material.uniforms.radius.value=e}get radius(){return this.material.uniforms.radius.value}set height(e){this.material.uniforms.height.value=e}get height(){return this.material.uniforms.height.value}};function OA(e){if(typeof TextDecoder<`u`)return new TextDecoder().decode(e);let t=``;for(let n=0,r=e.length;n=2.0 are supported.`));return}let s=new kj(i,{path:t||this.resourcePath||``,crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});s.fileLoader.setRequestHeader(this.requestHeader);for(let e=0;e=0&&o[t]===void 0&&console.warn(`THREE.GLTFLoader: Unknown extension "`+t+`".`)}}s.setExtensions(a),s.setPlugins(o),s.parse(n,r)}parseAsync(e,t){let n=this;return new Promise(function(r,i){n.parse(e,t,r,i)})}};function PA(){let e={};return{get:function(t){return e[t]},add:function(t,n){e[t]=n},remove:function(t){delete e[t]},removeAll:function(){e={}}}}var FA={KHR_BINARY_GLTF:`KHR_binary_glTF`,KHR_DRACO_MESH_COMPRESSION:`KHR_draco_mesh_compression`,KHR_LIGHTS_PUNCTUAL:`KHR_lights_punctual`,KHR_MATERIALS_CLEARCOAT:`KHR_materials_clearcoat`,KHR_MATERIALS_DISPERSION:`KHR_materials_dispersion`,KHR_MATERIALS_IOR:`KHR_materials_ior`,KHR_MATERIALS_SHEEN:`KHR_materials_sheen`,KHR_MATERIALS_SPECULAR:`KHR_materials_specular`,KHR_MATERIALS_TRANSMISSION:`KHR_materials_transmission`,KHR_MATERIALS_IRIDESCENCE:`KHR_materials_iridescence`,KHR_MATERIALS_ANISOTROPY:`KHR_materials_anisotropy`,KHR_MATERIALS_UNLIT:`KHR_materials_unlit`,KHR_MATERIALS_VOLUME:`KHR_materials_volume`,KHR_TEXTURE_BASISU:`KHR_texture_basisu`,KHR_TEXTURE_TRANSFORM:`KHR_texture_transform`,KHR_MESH_QUANTIZATION:`KHR_mesh_quantization`,KHR_MATERIALS_EMISSIVE_STRENGTH:`KHR_materials_emissive_strength`,EXT_MATERIALS_BUMP:`EXT_materials_bump`,EXT_TEXTURE_WEBP:`EXT_texture_webp`,EXT_TEXTURE_AVIF:`EXT_texture_avif`,EXT_MESHOPT_COMPRESSION:`EXT_meshopt_compression`,EXT_MESH_GPU_INSTANCING:`EXT_mesh_gpu_instancing`},IA=class{constructor(e){this.parser=e,this.name=FA.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){let e=this.parser,t=this.parser.json.nodes||[];for(let n=0,r=t.length;n=0)throw Error(`THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures`);return null}return t.loadTextureImage(e,i.source,a)}},XA=class{constructor(e){this.parser=e,this.name=FA.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){let t=this.name,n=this.parser,r=n.json,i=r.textures[e];if(!i.extensions||!i.extensions[t])return null;let a=i.extensions[t],o=r.images[a.source],s=n.textureLoader;if(o.uri){let e=n.options.manager.getHandler(o.uri);e!==null&&(s=e)}return this.detectSupport().then(function(i){if(i)return n.loadTextureImage(e,a.source,s);if(r.extensionsRequired&&r.extensionsRequired.indexOf(t)>=0)throw Error(`THREE.GLTFLoader: WebP required by asset but unsupported.`);return n.loadTexture(e)})}detectSupport(){return this.isSupported||=new Promise(function(e){let t=new Image;t.src=`data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA`,t.onload=t.onerror=function(){e(t.height===1)}}),this.isSupported}},ZA=class{constructor(e){this.parser=e,this.name=FA.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){let t=this.name,n=this.parser,r=n.json,i=r.textures[e];if(!i.extensions||!i.extensions[t])return null;let a=i.extensions[t],o=r.images[a.source],s=n.textureLoader;if(o.uri){let e=n.options.manager.getHandler(o.uri);e!==null&&(s=e)}return this.detectSupport().then(function(i){if(i)return n.loadTextureImage(e,a.source,s);if(r.extensionsRequired&&r.extensionsRequired.indexOf(t)>=0)throw Error(`THREE.GLTFLoader: AVIF required by asset but unsupported.`);return n.loadTexture(e)})}detectSupport(){return this.isSupported||=new Promise(function(e){let t=new Image;t.src=`data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=`,t.onload=t.onerror=function(){e(t.height===1)}}),this.isSupported}},QA=class{constructor(e){this.name=FA.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){let t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){let e=n.extensions[this.name],r=this.parser.getDependency(`buffer`,e.buffer),i=this.parser.options.meshoptDecoder;if(!i||!i.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw Error(`THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files`);return null}return r.then(function(t){let n=e.byteOffset||0,r=e.byteLength||0,a=e.count,o=e.byteStride,s=new Uint8Array(t,n,r);return i.decodeGltfBufferAsync?i.decodeGltfBufferAsync(a,o,s,e.mode,e.filter).then(function(e){return e.buffer}):i.ready.then(function(){let t=new ArrayBuffer(a*o);return i.decodeGltfBuffer(new Uint8Array(t),a,o,s,e.mode,e.filter),t})})}else return null}},$A=class{constructor(e){this.name=FA.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){let t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||n.mesh===void 0)return null;let r=t.meshes[n.mesh];for(let e of r.primitives)if(e.mode!==uj.TRIANGLES&&e.mode!==uj.TRIANGLE_STRIP&&e.mode!==uj.TRIANGLE_FAN&&e.mode!==void 0)return null;let i=n.extensions[this.name].attributes,a=[],o={};for(let e in i)a.push(this.parser.getDependency(`accessor`,i[e]).then(t=>(o[e]=t,o[e])));return a.length<1?null:(a.push(this.parser.createNodeMesh(e)),Promise.all(a).then(e=>{let t=e.pop(),n=t.isGroup?t.children:[t],r=e[0].count,i=[];for(let e of n){let t=new cr,n=new G,a=new In,s=new G(1,1,1),c=new mo(e.geometry,e.material,r);for(let e=0;e=152?{TEXCOORD_0:`uv`,TEXCOORD_1:`uv1`,TEXCOORD_2:`uv2`,TEXCOORD_3:`uv3`}:{TEXCOORD_0:`uv`,TEXCOORD_1:`uv2`},COLOR_0:`color`,WEIGHTS_0:`skinWeight`,JOINTS_0:`skinIndex`},gj={scale:`scale`,translation:`position`,rotation:`quaternion`,weights:`morphTargetInfluences`},_j={CUBICSPLINE:void 0,LINEAR:ct,STEP:st},vj={OPAQUE:`OPAQUE`,MASK:`MASK`,BLEND:`BLEND`};function yj(e){return e.DefaultMaterial===void 0&&(e.DefaultMaterial=new Tl({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:0})),e.DefaultMaterial}function bj(e,t,n){for(let r in n.extensions)e[r]===void 0&&(t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[r]=n.extensions[r])}function xj(e,t){t.extras!==void 0&&(typeof t.extras==`object`?Object.assign(e.userData,t.extras):console.warn(`THREE.GLTFLoader: Ignoring primitive type .extras, `+t.extras))}function Sj(e,t,n){let r=!1,i=!1,a=!1;for(let e=0,n=t.length;e0||e.search(/^data\:image\/jpeg/)===0?`image/jpeg`:e.search(/\.webp($|\?)/i)>0||e.search(/^data\:image\/webp/)===0?`image/webp`:`image/png`}var Oj=new cr,kj=class{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new PA,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let n=!1,r=!1,i=-1;typeof navigator<`u`&&navigator.userAgent!==void 0&&(n=/^((?!chrome|android).)*safari/i.test(navigator.userAgent)===!0,r=navigator.userAgent.indexOf(`Firefox`)>-1,i=r?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1),typeof createImageBitmap>`u`||n||r&&i<98?this.textureLoader=new vu(this.options.manager):this.textureLoader=new ed(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new du(this.options.manager),this.fileLoader.setResponseType(`arraybuffer`),this.options.crossOrigin===`use-credentials`&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){let n=this,r=this.json,i=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(e){return e._markDefs&&e._markDefs()}),Promise.all(this._invokeAll(function(e){return e.beforeRoot&&e.beforeRoot()})).then(function(){return Promise.all([n.getDependencies(`scene`),n.getDependencies(`animation`),n.getDependencies(`camera`)])}).then(function(t){let a={scene:t[0][r.scene||0],scenes:t[0],animations:t[1],cameras:t[2],asset:r.asset,parser:n,userData:{}};return bj(i,a,r),xj(a,r),Promise.all(n._invokeAll(function(e){return e.afterRoot&&e.afterRoot(a)})).then(function(){for(let e of a.scenes)e.updateMatrixWorld();e(a)})}).catch(t)}_markDefs(){let e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let n=0,r=t.length;n{let n=this.associations.get(e);n!=null&&this.associations.set(t,n);for(let[n,r]of e.children.entries())i(r,t.children[n])};return i(n,r),r.name+=`_instance_`+ e.uses[t]++,r}_invokeOne(e){let t=Object.values(this.plugins);t.push(this);for(let n=0;n=2&&p.setY(t,u[e*a+1]),a>=3&&p.setZ(t,u[e*a+2]),a>=4&&p.setW(t,u[e*a+3]),a>=5)throw Error(`THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.`)}}return p})}loadTexture(e){let t=this.json,n=this.options,r=t.textures[e].source,i=t.images[r],a=this.textureLoader;if(i.uri){let e=n.manager.getHandler(i.uri);e!==null&&(a=e)}return this.loadTextureImage(e,r,a)}loadTextureImage(e,t,n){let r=this,i=this.json,a=i.textures[e],o=i.images[t],s=(o.uri||o.bufferView)+`:`+a.sampler;if(this.textureCache[s])return this.textureCache[s];let c=this.loadImageSource(t,n).then(function(t){t.flipY=!1,t.name=a.name||o.name||``,t.name===``&&typeof o.uri==`string`&&o.uri.startsWith(`data:image/`)===!1&&(t.name=o.uri);let n=(i.samplers||{})[a.sampler]||{};return t.magFilter=fj[n.magFilter]||1006,t.minFilter=fj[n.minFilter]||1008,t.wrapS=pj[n.wrapS]||1e3,t.wrapT=pj[n.wrapT]||1e3,r.associations.set(t,{textures:e}),t}).catch(function(){return null});return this.textureCache[s]=c,c}loadImageSource(e,t){let n=this,r=this.json,i=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(e=>e.clone());let a=r.images[e],o=self.URL||self.webkitURL,s=a.uri||``,c=!1;if(a.bufferView!==void 0)s=n.getDependency(`bufferView`,a.bufferView).then(function(e){c=!0;let t=new Blob([e],{type:a.mimeType});return s=o.createObjectURL(t),s});else if(a.uri===void 0)throw Error(`THREE.GLTFLoader: Image `+e+` is missing URI and bufferView`);let l=Promise.resolve(s).then(function(e){return new Promise(function(n,r){let a=n;t.isImageBitmapLoader===!0&&(a=function(e){let t=new er(e);t.needsUpdate=!0,n(t)}),t.load(Gu.resolveURL(e,i.path),a,void 0,r)})}).then(function(e){return c===!0&&o.revokeObjectURL(s),xj(e,a),e.userData.mimeType=a.mimeType||Dj(a.uri),e}).catch(function(e){throw console.error(`THREE.GLTFLoader: Couldn't load texture`,s),e});return this.sourceCache[e]=l,l}assignTexture(e,t,n,r){let i=this;return this.getDependency(`texture`,n.index).then(function(a){if(!a)return null;if(n.texCoord!==void 0&&n.texCoord>0&&(a=a.clone(),a.channel=n.texCoord),i.extensions[FA.KHR_TEXTURE_TRANSFORM]){let e=n.extensions===void 0?void 0:n.extensions[FA.KHR_TEXTURE_TRANSFORM];if(e){let t=i.associations.get(a);a=i.extensions[FA.KHR_TEXTURE_TRANSFORM].extendTexture(a,e),i.associations.set(a,t)}}return r!==void 0&&(typeof r==`number`&&(r=r===jA?kA:AA),`colorSpace`in a?a.colorSpace=r:a.encoding=r===kA?jA:MA),e[t]=a,a})}assignFinalMaterial(e){let t=e.geometry,n=e.material,r=t.attributes.tangent===void 0,i=t.attributes.color!==void 0,a=t.attributes.normal===void 0;if(e.isPoints){let e=`PointsMaterial:`+n.uuid,t=this.cache.get(e);t||(t=new as,ta.prototype.copy.call(t,n),t.color.copy(n.color),t.map=n.map,t.sizeAttenuation=!1,this.cache.add(e,t)),n=t}else if(e.isLine){let e=`LineBasicMaterial:`+n.uuid,t=this.cache.get(e);t||(t=new Go,ta.prototype.copy.call(t,n),t.color.copy(n.color),t.map=n.map,this.cache.add(e,t)),n=t}if(r||i||a){let e=`ClonedMaterial:`+n.uuid+`:`;r&&(e+=`derivative-tangents:`),i&&(e+=`vertex-colors:`),a&&(e+=`flat-shading:`);let t=this.cache.get(e);t||(t=n.clone(),i&&(t.vertexColors=!0),a&&(t.flatShading=!0),r&&(t.normalScale&&(t.normalScale.y*=-1),t.clearcoatNormalScale&&(t.clearcoatNormalScale.y*=-1)),this.cache.add(e,t),this.associations.set(t,this.associations.get(n))),n=t}e.material=n}getMaterialType(){return Tl}loadMaterial(e){let t=this,n=this.json,r=this.extensions,i=n.materials[e],a,o={},s=i.extensions||{},c=[];if(s[FA.KHR_MATERIALS_UNLIT]){let e=r[FA.KHR_MATERIALS_UNLIT];a=e.getMaterialType(),c.push(e.extendParams(o,i,t))}else{let n=i.pbrMetallicRoughness||{};if(o.color=new K(1,1,1),o.opacity=1,Array.isArray(n.baseColorFactor)){let e=n.baseColorFactor;o.color.setRGB(e[0],e[1],e[2],AA),o.opacity=e[3]}n.baseColorTexture!==void 0&&c.push(t.assignTexture(o,`map`,n.baseColorTexture,kA)),o.metalness=n.metallicFactor===void 0?1:n.metallicFactor,o.roughness=n.roughnessFactor===void 0?1:n.roughnessFactor,n.metallicRoughnessTexture!==void 0&&(c.push(t.assignTexture(o,`metalnessMap`,n.metallicRoughnessTexture)),c.push(t.assignTexture(o,`roughnessMap`,n.metallicRoughnessTexture))),a=this._invokeOne(function(t){return t.getMaterialType&&t.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(t){return t.extendMaterialParams&&t.extendMaterialParams(e,o)})))}i.doubleSided===!0&&(o.side=2);let l=i.alphaMode||vj.OPAQUE;if(l===vj.BLEND?(o.transparent=!0,o.depthWrite=!1):(o.transparent=!1,l===vj.MASK&&(o.alphaTest=i.alphaCutoff===void 0?.5:i.alphaCutoff)),i.normalTexture!==void 0&&a!==ka&&(c.push(t.assignTexture(o,`normalMap`,i.normalTexture)),o.normalScale=new W(1,1),i.normalTexture.scale!==void 0)){let e=i.normalTexture.scale;o.normalScale.set(e,e)}if(i.occlusionTexture!==void 0&&a!==ka&&(c.push(t.assignTexture(o,`aoMap`,i.occlusionTexture)),i.occlusionTexture.strength!==void 0&&(o.aoMapIntensity=i.occlusionTexture.strength)),i.emissiveFactor!==void 0&&a!==ka){let e=i.emissiveFactor;o.emissive=new K().setRGB(e[0],e[1],e[2],AA)}return i.emissiveTexture!==void 0&&a!==ka&&c.push(t.assignTexture(o,`emissiveMap`,i.emissiveTexture,kA)),Promise.all(c).then(function(){let n=new a(o);return i.name&&(n.name=i.name),xj(n,i),t.associations.set(n,{materials:e}),i.extensions&&bj(r,n,i),n})}createUniqueName(e){let t=zd.sanitizeNodeName(e||``);return t in this.nodeNamesUsed?t+`_`+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){let t=this,n=this.extensions,r=this.primitiveCache;function i(e){return n[FA.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e,t).then(function(n){return jj(n,e,t)})}let a=[];for(let n=0,o=e.length;n0&&Cj(d,i),d.name=t.createUniqueName(i.name||`mesh_`+e),xj(d,i),u.extensions&&bj(r,d,u),t.assignFinalMaterial(d),c.push(d)}for(let n=0,r=c.length;n1?new Ir:t.length===1?t[0]:new Fr,o!==t[0])for(let e=0,n=t.length;e{let t=new Map;for(let[e,n]of r.associations)(e instanceof ta||e instanceof er)&&t.set(e,n);return e.traverse(e=>{let n=r.associations.get(e);n!=null&&t.set(e,n)}),t})(i),i})}_createAnimationTracks(e,t,n,r,i){let a=[],o=e.name?e.name:e.uuid,s=[];gj[i.path]===gj.weights?e.traverse(function(e){e.morphTargetInfluences&&s.push(e.name?e.name:e.uuid)}):s.push(o);let c;switch(gj[i.path]){case gj.weights:c=Xl;break;case gj.rotation:c=Ql;break;case gj.position:case gj.scale:c=eu;break;default:switch(n.itemSize){case 1:c=Xl;break;default:c=eu;break}break}let l=r.interpolation===void 0?ct:_j[r.interpolation],u=this._getArrayFromAccessor(n);for(let e=0,n=s.length;e(i=s.indexOf(` `))&&a=e.byteLength||!(l=n(e)))&&t(1,`no header found`),(u=l.match(r))||t(3,`bad initial token`),c.valid|=1,c.programtype=u[1],c.string+=l+` `;l=n(e),!1!==l;){if(c.string+=l+` `,l.charAt(0)===`#`){c.comments+=l+` `;continue}if((u=l.match(i))&&(c.gamma=parseFloat(u[1])),(u=l.match(a))&&(c.exposure=parseFloat(u[1])),(u=l.match(o))&&(c.valid|=2,c.format=u[1]),(u=l.match(s))&&(c.valid|=4,c.height=parseInt(u[1],10),c.width=parseInt(u[2],10)),c.valid&2&&c.valid&4)break}return c.valid&2||t(3,`missing format specifier`),c.valid&4||t(3,`missing image size specifier`),c},i=function(e,n,r){let i=n;if(i<8||i>32767||e[0]!==2||e[1]!==2||e[2]&128)return new Uint8Array(e);i!==(e[2]<<8|e[3])&&t(3,`wrong scanline width`);let a=new Uint8Array(4*n*r);a.length||t(4,`unable to allocate buffer space`);let o=0,s=0,c=4*i,l=new Uint8Array(4),u=new Uint8Array(c),d=r;for(;d>0&&se.byteLength&&t(1),l[0]=e[s++],l[1]=e[s++],l[2]=e[s++],l[3]=e[s++],(l[0]!=2||l[1]!=2||(l[2]<<8|l[3])!=i)&&t(3,`bad rgbe scanline format`);let n=0,r;for(;n128;if(i&&(r-=128),(r===0||n+r>c)&&t(3,`bad scanline data`),i){let t=e[s++];for(let e=0;e=152,Ij=class extends _u{constructor(e){super(e),this.type=ce}parse(e){let t=65536,n=8192,r=65537,i=16384,a=i-1,o=65535,s=2.7182818**2.2;function c(e,n){for(var r=0,i=0;i>3]&1<<(i&7))&&(n[r++]=i);for(var a=r-1;r>n&(1<0;--t){var i=n+f[t]>>1;f[t]=n,n=i}for(var t=0;t0&&(e[t]=a|f[a]++<<6)}}function m(e,t,n,r,i,a,o){for(var s=n,c=0,l=0;i<=a;i++){if(s.value-n.value>r)return!1;d(6,c,l,e,s);var f=u.l;if(c=u.c,l=u.lc,o[i]=f,f==63){if(s.value-n.value>r)throw`Something wrong with hufUnpackEncTable`;d(8,c,l,e,s);var m=u.l+6;if(c=u.c,l=u.lc,i+m>a+1)throw`Something wrong with hufUnpackEncTable`;for(;m--;)o[i++]=0;i--}else if(f>=59){var m=f-59+2;if(i+m>a+1)throw`Something wrong with hufUnpackEncTable`;for(;m--;)o[i++]=0;i--}}p(o)}function h(e){return e&63}function g(e){return e>>6}function _(e,t,n,r){for(;t<=n;t++){var i=g(e[t]),a=h(e[t]);if(i>>a)throw`Invalid table entry`;if(a>14){var o=r[i>>a-14];if(o.len)throw`Invalid table entry`;if(o.lit++,o.p){var s=o.p;o.p=Array(o.lit);for(var c=0;c0;c--){var o=r[(i<<14-a)+l];if(o.len||o.p)throw`Invalid table entry`;o.len=a,o.lit=t,l++}}return!0}let v={c:0,lc:0};function y(e,t,n,r){e=e<<8|ve(n,r),t+=8,v.c=e,v.lc=t}let b={c:0,lc:0};function x(e,t,n,r,i,a,o,s,c,l){if(e==t){r<8&&(y(n,r,i,o),n=v.c,r=v.lc),r-=8;var u=n>>r,u=new Uint8Array([u])[0];if(c.value+u>l)return!1;for(var d=s[c.value-1];u-- >0;)s[c.value++]=d}else if(c.value32767?t-65536:t}let w={a:0,b:0};function T(e,t){var n=C(e),r=C(t),i=n+(r&1)+(r>>1),a=i,o=i-r;w.a=a,w.b=o}function E(e,t){var n=S(e),r=S(t),i=n-(r>>1)&o;w.a=r+i-32768&o,w.b=i}function D(e,t,n,r,i,a,o){for(var s=o<16384,c=n>i?i:n,l=1,u;l<=c;)l<<=1;for(l>>=1,u=l,l>>=1;l>=1;){for(var d=0,f=d+a*(i-u),p=a*l,m=a*u,h=r*l,g=r*u,_,v,y,b;d<=f;d+=m){for(var x=d,S=d+r*(n-u);x<=S;x+=g){var C=x+h,D=x+p,O=D+h;s?(T(e[x+t],e[D+t]),_=w.a,y=w.b,T(e[C+t],e[O+t]),v=w.a,b=w.b,T(_,v),e[x+t]=w.a,e[C+t]=w.b,T(y,b),e[D+t]=w.a,e[O+t]=w.b):(E(e[x+t],e[D+t]),_=w.a,y=w.b,E(e[C+t],e[O+t]),v=w.a,b=w.b,E(_,v),e[x+t]=w.a,e[C+t]=w.b,E(y,b),e[D+t]=w.a,e[O+t]=w.b)}if(n&l){var D=x+p;s?T(e[x+t],e[D+t]):E(e[x+t],e[D+t]),_=w.a,e[D+t]=w.b,e[x+t]=_}}if(i&l)for(var x=d,S=d+r*(n-u);x<=S;x+=g){var C=x+h;s?T(e[x+t],e[C+t]):E(e[x+t],e[C+t]),_=w.a,e[C+t]=w.b,e[x+t]=_}u=l,l>>=1}return d}function O(e,t,n,r,i,o,s,c,l,u){for(var d=0,f=0,p=c,m=Math.trunc(i.value+(o+7)/8);i.value=14;){var _=t[d>>f-14&a];if(_.len)f-=_.len,x(_.lit,s,d,f,n,r,i,l,u,p),d=b.c,f=b.lc;else{if(!_.p)throw`hufDecode issues`;var S;for(S=0;S<_.lit;S++){for(var C=h(e[_.p[S]]);f=C&&g(e[_.p[S]])==(d>>f-C&(1<>=w,f-=w;f>0;){var _=t[d<<14-f&a];if(_.len)f-=_.len,x(_.lit,s,d,f,n,r,i,l,u,p),d=b.c,f=b.lc;else throw`hufDecode issues`}return!0}function k(e,t,n,a,o,s){var c={value:0},u=n.value,d=_e(t,n),f=_e(t,n);n.value+=4;var p=_e(t,n);if(n.value+=4,d<0||d>=r||f<0||f>=r)throw`Something wrong with HUF_ENCSIZE`;var h=Array(r),g=Array(i);if(l(g),m(e,t,n,a-(n.value-u),d,f,h),p>8*(a-(n.value-u)))throw`Something wrong with hufUncompress`;_(h,d,f,g),O(h,g,e,t,n,p,f,s,o,c)}function A(e,t,n){for(var r=0;ra||(t[i++]=e[n++],i>a));)t[i++]=e[r++]}function te(e){for(var t=e.byteLength,n=[],r=0,i=new DataView(e);t>0;){var a=i.getInt8(r++);if(a<0){var o=-a;t-=o+1;for(var s=0;s>8==255?i+=r&255:(n[i]=r,i++),e.value++}function P(e,t){t[0]=R(e[0]),t[1]=R(e[1]),t[2]=R(e[5]),t[3]=R(e[6]),t[4]=R(e[14]),t[5]=R(e[15]),t[6]=R(e[27]),t[7]=R(e[28]),t[8]=R(e[2]),t[9]=R(e[4]),t[10]=R(e[7]),t[11]=R(e[13]),t[12]=R(e[16]),t[13]=R(e[26]),t[14]=R(e[29]),t[15]=R(e[42]),t[16]=R(e[3]),t[17]=R(e[8]),t[18]=R(e[12]),t[19]=R(e[17]),t[20]=R(e[25]),t[21]=R(e[30]),t[22]=R(e[41]),t[23]=R(e[43]),t[24]=R(e[9]),t[25]=R(e[11]),t[26]=R(e[18]),t[27]=R(e[24]),t[28]=R(e[31]),t[29]=R(e[40]),t[30]=R(e[44]),t[31]=R(e[53]),t[32]=R(e[10]),t[33]=R(e[19]),t[34]=R(e[23]),t[35]=R(e[32]),t[36]=R(e[39]),t[37]=R(e[45]),t[38]=R(e[52]),t[39]=R(e[54]),t[40]=R(e[20]),t[41]=R(e[22]),t[42]=R(e[33]),t[43]=R(e[38]),t[44]=R(e[46]),t[45]=R(e[51]),t[46]=R(e[55]),t[47]=R(e[60]),t[48]=R(e[21]),t[49]=R(e[34]),t[50]=R(e[37]),t[51]=R(e[47]),t[52]=R(e[50]),t[53]=R(e[56]),t[54]=R(e[59]),t[55]=R(e[61]),t[56]=R(e[35]),t[57]=R(e[36]),t[58]=R(e[48]),t[59]=R(e[49]),t[60]=R(e[57]),t[61]=R(e[58]),t[62]=R(e[62]),t[63]=R(e[63])}function F(e){let t=.5*Math.cos(3.14159/4),n=.5*Math.cos(3.14159/16),r=.5*Math.cos(3.14159/8),i=.5*Math.cos(3*3.14159/16),a=.5*Math.cos(5*3.14159/16),o=.5*Math.cos(3*3.14159/8),s=.5*Math.cos(7*3.14159/16);for(var c=[,,,,],l=[,,,,],u=[,,,,],d=[,,,,],f=0;f<8;++f){var p=f*8;c[0]=r*e[p+2],c[1]=o*e[p+2],c[2]=r*e[p+6],c[3]=o*e[p+6],l[0]=n*e[p+1]+i*e[p+3]+a*e[p+5]+s*e[p+7],l[1]=i*e[p+1]-s*e[p+3]-n*e[p+5]-a*e[p+7],l[2]=a*e[p+1]-n*e[p+3]+s*e[p+5]+i*e[p+7],l[3]=s*e[p+1]-a*e[p+3]+i*e[p+5]-n*e[p+7],u[0]=t*(e[p+0]+e[p+4]),u[3]=t*(e[p+0]-e[p+4]),u[1]=c[0]+c[3],u[2]=c[1]-c[2],d[0]=u[0]+u[1],d[1]=u[3]+u[2],d[2]=u[3]-u[2],d[3]=u[0]-u[1],e[p+0]=d[0]+l[0],e[p+1]=d[1]+l[1],e[p+2]=d[2]+l[2],e[p+3]=d[3]+l[3],e[p+4]=d[3]-l[3],e[p+5]=d[2]-l[2],e[p+6]=d[1]-l[1],e[p+7]=d[0]-l[0]}for(var m=0;m<8;++m)c[0]=r*e[16+m],c[1]=o*e[16+m],c[2]=r*e[48+m],c[3]=o*e[48+m],l[0]=n*e[8+m]+i*e[24+m]+a*e[40+m]+s*e[56+m],l[1]=i*e[8+m]-s*e[24+m]-n*e[40+m]-a*e[56+m],l[2]=a*e[8+m]-n*e[24+m]+s*e[40+m]+i*e[56+m],l[3]=s*e[8+m]-a*e[24+m]+i*e[40+m]-n*e[56+m],u[0]=t*(e[m]+e[32+m]),u[3]=t*(e[m]-e[32+m]),u[1]=c[0]+c[3],u[2]=c[1]-c[2],d[0]=u[0]+u[1],d[1]=u[3]+u[2],d[2]=u[3]-u[2],d[3]=u[0]-u[1],e[0+m]=d[0]+l[0],e[8+m]=d[1]+l[1],e[16+m]=d[2]+l[2],e[24+m]=d[3]+l[3],e[32+m]=d[3]-l[3],e[40+m]=d[2]-l[2],e[48+m]=d[1]-l[1],e[56+m]=d[0]-l[0]}function ne(e){for(var t=0;t<64;++t){var n=e[0][t],r=e[1][t],i=e[2][t];e[0][t]=n+1.5747*i,e[1][t]=n-.1873*r-.4682*i,e[2][t]=n+1.8556*r}}function re(e,t,n){for(var r=0;r<64;++r)t[n+r]=Ei.toHalfFloat(ie(e[r]))}function ie(e){return e<=1?Math.sign(e)*Math.abs(e)**2.2:Math.sign(e)*s**(Math.abs(e)-1)}function I(e){return new DataView(e.array.buffer,e.offset.value,e.size)}function ae(e){var t=e.viewer.buffer.slice(e.offset.value,e.offset.value+e.size),n=new Uint8Array(te(t)),r=new Uint8Array(n.length);return j(n),ee(n,r),new DataView(r.buffer)}function L(e){var t=wA(e.array.slice(e.offset.value,e.offset.value+e.size)),n=new Uint8Array(t.length);return j(t),ee(t,n),new DataView(n.buffer)}function oe(e){for(var r=e.viewer,i={value:e.offset.value},a=new Uint16Array(e.width*e.scanlineBlockSize*(e.channels*e.type)),o=new Uint8Array(n),s=0,l=Array(e.channels),u=0;u=n)throw`Something is wrong with PIZ_COMPRESSION BITMAP_SIZE`;if(d<=f)for(var u=0;u0;){var s=de(t.buffer,n),c=be(t,n),l=c>>2&3,u=(c>>4)-1,d=new Int8Array([u])[0],f=be(t,n);a.push({name:s,index:d,type:f,compression:l}),o-=s.length+3}for(var p=Le.channels,m=Array(e.channels),h=0;h=0&&(v.idx[b.index]=y),g.offset=y)}if(i.acCompressedSize>0)switch(i.acCompression){case 0:var x=new Uint16Array(i.totalAcUncompressedCount);k(e.array,t,n,i.acCompressedSize,x,i.totalAcUncompressedCount);break;case 1:var S=e.array.slice(n.value,n.value+i.totalAcUncompressedCount),C=wA(S),x=new Uint16Array(C.buffer);n.value+=i.totalAcUncompressedCount;break}if(i.dcCompressedSize>0){var w={array:e.array,offset:n,size:i.dcCompressedSize},T=new Uint16Array(L(w).buffer);n.value+=i.dcCompressedSize}if(i.rleRawSize>0){var S=e.array.slice(n.value,n.value+i.rleCompressedSize),C=wA(S),E=te(C.buffer);n.value+=i.rleCompressedSize}for(var D=0,O=Array(m.length),h=0;h>10,n=e&1023;return(e>>15?-1:1)*(t?t===31?n?NaN:1/0:2**(t-15)*(1+n/1024):n/1024*6103515625e-14)}function we(e,t){var n=e.getUint16(t.value,!0);return t.value+=2,n}function Te(e,t){return R(we(e,t))}function Ee(e,t,n,r){for(var i=n.value,a=[];n.valueRe.height?Re.height-t:Re.scanlineBlockSize;let n=Re.size=Re.height)break;for(let e=0;e{let n={attributeIDs:this.defaultAttributeIDs,attributeTypes:this.defaultAttributeTypes,useUniqueIDs:!1};this.decodeGeometry(e,n).then(t).catch(r)},n,r)}decodeDracoFile(e,t,n,r){let i={attributeIDs:n||this.defaultAttributeIDs,attributeTypes:r||this.defaultAttributeTypes,useUniqueIDs:!!n};this.decodeGeometry(e,i).then(t)}decodeGeometry(e,t){for(let e in t.attributeTypes){let n=t.attributeTypes[e];n.BYTES_PER_ELEMENT!==void 0&&(t.attributeTypes[e]=n.name)}let n=JSON.stringify(t);if(Lj.has(e)){let t=Lj.get(e);if(t.key===n)return t.promise;if(e.byteLength===0)throw Error(`THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.`)}let r,i=this.workerNextTaskID++,a=e.byteLength,o=this._getWorker(i,a).then(n=>(r=n,new Promise((n,a)=>{r._callbacks[i]={resolve:n,reject:a},r.postMessage({type:`decode`,id:i,taskConfig:t,buffer:e},[e])}))).then(e=>this._createGeometry(e.geometry));return o.catch(()=>!0).then(()=>{r&&i&&this._releaseTask(r,i)}),Lj.set(e,{key:n,promise:o}),o}_createGeometry(e){let t=new Xi;e.index&&t.setIndex(new Ai(e.index.array,1));for(let n=0;n{n.load(e,t,void 0,r)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;let e=typeof WebAssembly!=`object`||this.decoderConfig.type===`js`,t=[];return e?t.push(this._loadLibrary(`draco_decoder.js`,`text`)):(t.push(this._loadLibrary(`draco_wasm_wrapper.js`,`text`)),t.push(this._loadLibrary(`draco_decoder.wasm`,`arraybuffer`))),this.decoderPending=Promise.all(t).then(t=>{let n=t[0];e||(this.decoderConfig.wasmBinary=t[1]);let r=zj.toString(),i=[`/* draco decoder */`,n,``,`/* worker */`,r.substring(r.indexOf(`{`)+1,r.lastIndexOf(`}`))].join(` `);this.workerSourceURL=URL.createObjectURL(new Blob([i]))}),this.decoderPending}_getWorker(e,t){return this._initDecoder().then(()=>{if(this.workerPool.lengtht._taskLoad?-1:1});let n=this.workerPool[this.workerPool.length-1];return n._taskCosts[e]=t,n._taskLoad+=t,n})}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){console.log(`Task load: `,this.workerPool.map(e=>e._taskLoad))}dispose(){for(let e=0;e{let t=e.draco,o=new t.Decoder,s=new t.DecoderBuffer;s.Init(new Int8Array(r),r.byteLength);try{let e=n(t,o,s,a),r=e.attributes.map(e=>e.array.buffer);e.index&&r.push(e.index.array.buffer),self.postMessage({type:`decode`,id:i.id,geometry:e},r)}catch(e){console.error(e),self.postMessage({type:`error`,id:i.id,error:e.message})}finally{t.destroy(s),t.destroy(o)}});break}};function n(e,t,n,a){let o=a.attributeIDs,s=a.attributeTypes,c,l,u=t.GetEncodedGeometryType(n);if(u===e.TRIANGULAR_MESH)c=new e.Mesh,l=t.DecodeBufferToMesh(n,c);else if(u===e.POINT_CLOUD)c=new e.PointCloud,l=t.DecodeBufferToPointCloud(n,c);else throw Error(`THREE.DRACOLoader: Unexpected geometry type.`);if(!l.ok()||c.ptr===0)throw Error(`THREE.DRACOLoader: Decoding failed: `+l.error_msg());let d={index:null,attributes:[]};for(let n in o){let r=self[s[n]],l,u;if(a.useUniqueIDs)u=o[n],l=t.GetAttributeByUniqueId(c,u);else{if(u=t.GetAttributeId(c,e[o[n]]),u===-1)continue;l=t.GetAttribute(c,u)}d.attributes.push(i(e,t,c,n,r,l))}return u===e.TRIANGULAR_MESH&&(d.index=r(e,t,c)),e.destroy(c),d}function r(e,t,n){let r=n.num_faces()*3,i=r*4,a=e._malloc(i);t.GetTrianglesUInt32Array(n,i,a);let o=new Uint32Array(e.HEAPF32.buffer,a,r).slice();return e._free(a),{array:o,itemSize:1}}function i(e,t,n,r,i,o){let s=o.num_components(),c=n.num_points()*s,l=c*i.BYTES_PER_ELEMENT,u=a(e,i),d=e._malloc(l);t.GetAttributeDataArrayForAllPoints(n,o,u,l,d);let f=new i(e.HEAPF32.buffer,d,c).slice();return e._free(d),{name:r,array:f,itemSize:s}}function a(e,t){switch(t){case Float32Array:return e.DT_FLOAT32;case Int8Array:return e.DT_INT8;case Int16Array:return e.DT_INT16;case Int32Array:return e.DT_INT32;case Uint8Array:return e.DT_UINT8;case Uint16Array:return e.DT_UINT16;case Uint32Array:return e.DT_UINT32}}}var Bj,Vj=()=>{if(Bj)return Bj;let e=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,3,2,0,0,5,3,1,0,1,12,1,0,10,22,2,12,0,65,0,65,0,65,0,252,10,0,0,11,7,0,65,0,253,15,26,11]),t=new Uint8Array([32,0,65,253,3,1,2,34,4,106,6,5,11,8,7,20,13,33,12,16,128,9,116,64,19,113,127,15,10,21,22,14,255,66,24,54,136,107,18,23,192,26,114,118,132,17,77,101,130,144,27,87,131,44,45,74,156,154,70,167]);if(typeof WebAssembly!=`object`)return{supported:!1};let n=`B9h9z9tFBBBF8fL9gBB9gLaaaaaFa9gEaaaB9gFaFa9gEaaaFaEMcBFFFGGGEIIILF9wFFFLEFBFKNFaFCx/IFMO/LFVK9tv9t9vq95GBt9f9f939h9z9t9f9j9h9s9s9f9jW9vq9zBBp9tv9z9o9v9wW9f9kv9j9v9kv9WvqWv94h919m9mvqBF8Z9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv94h919m9mvqBGy9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv949TvZ91v9u9jvBEn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9P9jWBIi9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9R919hWBLn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9F949wBKI9z9iqlBOc+x8ycGBM/qQFTa8jUUUUBCU/EBlHL8kUUUUBC9+RKGXAGCFJAI9LQBCaRKAE2BBC+gF9HQBALAEAIJHOAGlAGTkUUUBRNCUoBAG9uC/wgBZHKCUGAKCUG9JyRVAECFJRICBRcGXEXAcAF9PQFAVAFAclAcAVJAF9JyRMGXGXAG9FQBAMCbJHKC9wZRSAKCIrCEJCGrRQANCUGJRfCBRbAIRTEXGXAOATlAQ9PQBCBRISEMATAQJRIGXAS9FQBCBRtCBREEXGXAOAIlCi9PQBCBRISLMANCU/CBJAEJRKGXGXGXGXGXATAECKrJ2BBAtCKZrCEZfIBFGEBMAKhB83EBAKCNJhB83EBSEMAKAI2BIAI2BBHmCKrHYAYCE6HYy86BBAKCFJAICIJAYJHY2BBAmCIrCEZHPAPCE6HPy86BBAKCGJAYAPJHY2BBAmCGrCEZHPAPCE6HPy86BBAKCEJAYAPJHY2BBAmCEZHmAmCE6Hmy86BBAKCIJAYAmJHY2BBAI2BFHmCKrHPAPCE6HPy86BBAKCLJAYAPJHY2BBAmCIrCEZHPAPCE6HPy86BBAKCKJAYAPJHY2BBAmCGrCEZHPAPCE6HPy86BBAKCOJAYAPJHY2BBAmCEZHmAmCE6Hmy86BBAKCNJAYAmJHY2BBAI2BGHmCKrHPAPCE6HPy86BBAKCVJAYAPJHY2BBAmCIrCEZHPAPCE6HPy86BBAKCcJAYAPJHY2BBAmCGrCEZHPAPCE6HPy86BBAKCMJAYAPJHY2BBAmCEZHmAmCE6Hmy86BBAKCSJAYAmJHm2BBAI2BEHICKrHYAYCE6HYy86BBAKCQJAmAYJHm2BBAICIrCEZHYAYCE6HYy86BBAKCfJAmAYJHm2BBAICGrCEZHYAYCE6HYy86BBAKCbJAmAYJHK2BBAICEZHIAICE6HIy86BBAKAIJRISGMAKAI2BNAI2BBHmCIrHYAYCb6HYy86BBAKCFJAICNJAYJHY2BBAmCbZHmAmCb6Hmy86BBAKCGJAYAmJHm2BBAI2BFHYCIrHPAPCb6HPy86BBAKCEJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCIJAmAYJHm2BBAI2BGHYCIrHPAPCb6HPy86BBAKCLJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCKJAmAYJHm2BBAI2BEHYCIrHPAPCb6HPy86BBAKCOJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCNJAmAYJHm2BBAI2BIHYCIrHPAPCb6HPy86BBAKCVJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCcJAmAYJHm2BBAI2BLHYCIrHPAPCb6HPy86BBAKCMJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCSJAmAYJHm2BBAI2BKHYCIrHPAPCb6HPy86BBAKCQJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCfJAmAYJHm2BBAI2BOHICIrHYAYCb6HYy86BBAKCbJAmAYJHK2BBAICbZHIAICb6HIy86BBAKAIJRISFMAKAI8pBB83BBAKCNJAICNJ8pBB83BBAICTJRIMAtCGJRtAECTJHEAS9JQBMMGXAIQBCBRISEMGXAM9FQBANAbJ2BBRtCBRKAfREEXAEANCU/CBJAKJ2BBHTCFrCBATCFZl9zAtJHt86BBAEAGJREAKCFJHKAM9HQBMMAfCFJRfAIRTAbCFJHbAG9HQBMMABAcAG9sJANCUGJAMAG9sTkUUUBpANANCUGJAMCaJAG9sJAGTkUUUBpMAMCBAIyAcJRcAIQBMC9+RKSFMCBC99AOAIlAGCAAGCA9Ly6yRKMALCU/EBJ8kUUUUBAKM+OmFTa8jUUUUBCoFlHL8kUUUUBC9+RKGXAFCE9uHOCtJAI9LQBCaRKAE2BBHNC/wFZC/gF9HQBANCbZHVCF9LQBALCoBJCgFCUFT+JUUUBpALC84Jha83EBALC8wJha83EBALC8oJha83EBALCAJha83EBALCiJha83EBALCTJha83EBALha83ENALha83EBAEAIJC9wJRcAECFJHNAOJRMGXAF9FQBCQCbAVCF6yRSABRECBRVCBRQCBRfCBRICBRKEXGXAMAcuQBC9+RKSEMGXGXAN2BBHOC/vF9LQBALCoBJAOCIrCa9zAKJCbZCEWJHb8oGIRTAb8oGBRtGXAOCbZHbAS9PQBALAOCa9zAIJCbZCGWJ8oGBAVAbyROAb9FRbGXGXAGCG9HQBABAt87FBABCIJAO87FBABCGJAT87FBSFMAEAtjGBAECNJAOjGBAECIJATjGBMAVAbJRVALCoBJAKCEWJHmAOjGBAmATjGIALAICGWJAOjGBALCoBJAKCFJCbZHKCEWJHTAtjGBATAOjGIAIAbJRIAKCFJRKSGMGXGXAbCb6QBAQAbJAbC989zJCFJRQSFMAM1BBHbCgFZROGXGXAbCa9MQBAMCFJRMSFMAM1BFHbCgBZCOWAOCgBZqROGXAbCa9MQBAMCGJRMSFMAM1BGHbCgBZCfWAOqROGXAbCa9MQBAMCEJRMSFMAM1BEHbCgBZCdWAOqROGXAbCa9MQBAMCIJRMSFMAM2BIC8cWAOqROAMCLJRMMAOCFrCBAOCFZl9zAQJRQMGXGXAGCG9HQBABAt87FBABCIJAQ87FBABCGJAT87FBSFMAEAtjGBAECNJAQjGBAECIJATjGBMALCoBJAKCEWJHOAQjGBAOATjGIALAICGWJAQjGBALCoBJAKCFJCbZHKCEWJHOAtjGBAOAQjGIAICFJRIAKCFJRKSFMGXAOCDF9LQBALAIAcAOCbZJ2BBHbCIrHTlCbZCGWJ8oGBAVCFJHtATyROALAIAblCbZCGWJ8oGBAtAT9FHmJHtAbCbZHTyRbAT9FRTGXGXAGCG9HQBABAV87FBABCIJAb87FBABCGJAO87FBSFMAEAVjGBAECNJAbjGBAECIJAOjGBMALAICGWJAVjGBALCoBJAKCEWJHYAOjGBAYAVjGIALAICFJHICbZCGWJAOjGBALCoBJAKCFJCbZCEWJHYAbjGBAYAOjGIALAIAmJCbZHICGWJAbjGBALCoBJAKCGJCbZHKCEWJHOAVjGBAOAbjGIAKCFJRKAIATJRIAtATJRVSFMAVCBAM2BBHYyHTAOC/+F6HPJROAYCbZRtGXGXAYCIrHmQBAOCFJRbSFMAORbALAIAmlCbZCGWJ8oGBROMGXGXAtQBAbCFJRVSFMAbRVALAIAYlCbZCGWJ8oGBRbMGXGXAP9FQBAMCFJRYSFMAM1BFHYCgFZRTGXGXAYCa9MQBAMCGJRYSFMAM1BGHYCgBZCOWATCgBZqRTGXAYCa9MQBAMCEJRYSFMAM1BEHYCgBZCfWATqRTGXAYCa9MQBAMCIJRYSFMAM1BIHYCgBZCdWATqRTGXAYCa9MQBAMCLJRYSFMAMCKJRYAM2BLC8cWATqRTMATCFrCBATCFZl9zAQJHQRTMGXGXAmCb6QBAYRPSFMAY1BBHMCgFZROGXGXAMCa9MQBAYCFJRPSFMAY1BFHMCgBZCOWAOCgBZqROGXAMCa9MQBAYCGJRPSFMAY1BGHMCgBZCfWAOqROGXAMCa9MQBAYCEJRPSFMAY1BEHMCgBZCdWAOqROGXAMCa9MQBAYCIJRPSFMAYCLJRPAY2BIC8cWAOqROMAOCFrCBAOCFZl9zAQJHQROMGXGXAtCb6QBAPRMSFMAP1BBHMCgFZRbGXGXAMCa9MQBAPCFJRMSFMAP1BFHMCgBZCOWAbCgBZqRbGXAMCa9MQBAPCGJRMSFMAP1BGHMCgBZCfWAbqRbGXAMCa9MQBAPCEJRMSFMAP1BEHMCgBZCdWAbqRbGXAMCa9MQBAPCIJRMSFMAPCLJRMAP2BIC8cWAbqRbMAbCFrCBAbCFZl9zAQJHQRbMGXGXAGCG9HQBABAT87FBABCIJAb87FBABCGJAO87FBSFMAEATjGBAECNJAbjGBAECIJAOjGBMALCoBJAKCEWJHYAOjGBAYATjGIALAICGWJATjGBALCoBJAKCFJCbZCEWJHYAbjGBAYAOjGIALAICFJHICbZCGWJAOjGBALCoBJAKCGJCbZCEWJHOATjGBAOAbjGIALAIAm9FAmCb6qJHICbZCGWJAbjGBAIAt9FAtCb6qJRIAKCEJRKMANCFJRNABCKJRBAECSJREAKCbZRKAICbZRIAfCEJHfAF9JQBMMCBC99AMAc6yRKMALCoFJ8kUUUUBAKM/tIFGa8jUUUUBCTlRLC9+RKGXAFCLJAI9LQBCaRKAE2BBC/+FZC/QF9HQBALhB83ENAECFJRKAEAIJC98JREGXAF9FQBGXAGCG6QBEXGXAKAE9JQBC9+bMAK1BBHGCgFZRIGXGXAGCa9MQBAKCFJRKSFMAK1BFHGCgBZCOWAICgBZqRIGXAGCa9MQBAKCGJRKSFMAK1BGHGCgBZCfWAIqRIGXAGCa9MQBAKCEJRKSFMAK1BEHGCgBZCdWAIqRIGXAGCa9MQBAKCIJRKSFMAK2BIC8cWAIqRIAKCLJRKMALCNJAICFZCGWqHGAICGrCBAICFrCFZl9zAG8oGBJHIjGBABAIjGBABCIJRBAFCaJHFQBSGMMEXGXAKAE9JQBC9+bMAK1BBHGCgFZRIGXGXAGCa9MQBAKCFJRKSFMAK1BFHGCgBZCOWAICgBZqRIGXAGCa9MQBAKCGJRKSFMAK1BGHGCgBZCfWAIqRIGXAGCa9MQBAKCEJRKSFMAK1BEHGCgBZCdWAIqRIGXAGCa9MQBAKCIJRKSFMAK2BIC8cWAIqRIAKCLJRKMABAICGrCBAICFrCFZl9zALCNJAICFZCGWqHI8oGBJHG87FBAIAGjGBABCGJRBAFCaJHFQBMMCBC99AKAE6yRKMAKM+lLKFaF99GaG99FaG99GXGXAGCI9HQBAF9FQFEXGXGX9DBBB8/9DBBB+/ABCGJHG1BB+yAB1BBHE+yHI+L+TABCFJHL1BBHK+yHO+L+THN9DBBBB9gHVyAN9DBB/+hANAN+U9DBBBBANAVyHcAc+MHMAECa3yAI+SHIAI+UAcAMAKCa3yAO+SHcAc+U+S+S+R+VHO+U+SHN+L9DBBB9P9d9FQBAN+oRESFMCUUUU94REMAGAE86BBGXGX9DBBB8/9DBBB+/Ac9DBBBB9gyAcAO+U+SHN+L9DBBB9P9d9FQBAN+oRGSFMCUUUU94RGMALAG86BBGXGX9DBBB8/9DBBB+/AI9DBBBB9gyAIAO+U+SHN+L9DBBB9P9d9FQBAN+oRGSFMCUUUU94RGMABAG86BBABCIJRBAFCaJHFQBSGMMAF9FQBEXGXGX9DBBB8/9DBBB+/ABCIJHG8uFB+yAB8uFBHE+yHI+L+TABCGJHL8uFBHK+yHO+L+THN9DBBBB9gHVyAN9DB/+g6ANAN+U9DBBBBANAVyHcAc+MHMAECa3yAI+SHIAI+UAcAMAKCa3yAO+SHcAc+U+S+S+R+VHO+U+SHN+L9DBBB9P9d9FQBAN+oRESFMCUUUU94REMAGAE87FBGXGX9DBBB8/9DBBB+/Ac9DBBBB9gyAcAO+U+SHN+L9DBBB9P9d9FQBAN+oRGSFMCUUUU94RGMALAG87FBGXGX9DBBB8/9DBBB+/AI9DBBBB9gyAIAO+U+SHN+L9DBBB9P9d9FQBAN+oRGSFMCUUUU94RGMABAG87FBABCNJRBAFCaJHFQBMMM/SEIEaE99EaF99GXAF9FQBCBREABRIEXGXGX9D/zI818/AICKJ8uFBHLCEq+y+VHKAI8uFB+y+UHO9DB/+g6+U9DBBB8/9DBBB+/AO9DBBBB9gy+SHN+L9DBBB9P9d9FQBAN+oRVSFMCUUUU94RVMAICIJ8uFBRcAICGJ8uFBRMABALCFJCEZAEqCFWJAV87FBGXGXAKAM+y+UHN9DB/+g6+U9DBBB8/9DBBB+/AN9DBBBB9gy+SHS+L9DBBB9P9d9FQBAS+oRMSFMCUUUU94RMMABALCGJCEZAEqCFWJAM87FBGXGXAKAc+y+UHK9DB/+g6+U9DBBB8/9DBBB+/AK9DBBBB9gy+SHS+L9DBBB9P9d9FQBAS+oRcSFMCUUUU94RcMABALCaJCEZAEqCFWJAc87FBGXGX9DBBU8/AOAO+U+TANAN+U+TAKAK+U+THO9DBBBBAO9DBBBB9gy+R9DB/+g6+U9DBBB8/+SHO+L9DBBB9P9d9FQBAO+oRcSFMCUUUU94RcMABALCEZAEqCFWJAc87FBAICNJRIAECIJREAFCaJHFQBMMM9JBGXAGCGrAF9sHF9FQBEXABAB8oGBHGCNWCN91+yAGCi91CnWCUUU/8EJ+++U84GBABCIJRBAFCaJHFQBMMM9TFEaCBCB8oGUkUUBHFABCEJC98ZJHBjGUkUUBGXGXAB8/BCTWHGuQBCaREABAGlCggEJCTrXBCa6QFMAFREMAEM/lFFFaGXGXAFABqCEZ9FQBABRESFMGXGXAGCT9PQBABRESFMABREEXAEAF8oGBjGBAECIJAFCIJ8oGBjGBAECNJAFCNJ8oGBjGBAECSJAFCSJ8oGBjGBAECTJREAFCTJRFAGC9wJHGCb9LQBMMAGCI9JQBEXAEAF8oGBjGBAFCIJRFAECIJREAGC98JHGCE9LQBMMGXAG9FQBEXAEAF2BB86BBAECFJREAFCFJRFAGCaJHGQBMMABMoFFGaGXGXABCEZ9FQBABRESFMAFCgFZC+BwsN9sRIGXGXAGCT9PQBABRESFMABREEXAEAIjGBAECSJAIjGBAECNJAIjGBAECIJAIjGBAECTJREAGC9wJHGCb9LQBMMAGCI9JQBEXAEAIjGBAECIJREAGC98JHGCE9LQBMMGXAG9FQBEXAEAF86BBAECFJREAGCaJHGQBMMABMMMFBCUNMIT9kBB`;WebAssembly.validate(e)&&(n=`B9h9z9tFBBBFiI9gBB9gLaaaaaFa9gEaaaB9gFaFaEMcBBFBFFGGGEILF9wFFFLEFBFKNFaFCx/aFMO/LFVK9tv9t9vq95GBt9f9f939h9z9t9f9j9h9s9s9f9jW9vq9zBBp9tv9z9o9v9wW9f9kv9j9v9kv9WvqWv94h919m9mvqBG8Z9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv94h919m9mvqBIy9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv949TvZ91v9u9jvBLn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9P9jWBKi9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9R919hWBOn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9F949wBNI9z9iqlBVc+N9IcIBTEM9+FLa8jUUUUBCTlRBCBRFEXCBRGCBREEXABCNJAGJAECUaAFAGrCFZHIy86BBAEAIJREAGCFJHGCN9HQBMAFCx+YUUBJAE86BBAFCEWCxkUUBJAB8pEN83EBAFCFJHFCUG9HQBMMk8lLbaE97F9+FaL978jUUUUBCU/KBlHL8kUUUUBC9+RKGXAGCFJAI9LQBCaRKAE2BBC+gF9HQBALAEAIJHOAGlAG/8cBBCUoBAG9uC/wgBZHKCUGAKCUG9JyRNAECFJRKCBRVGXEXAVAF9PQFANAFAVlAVANJAF9JyRcGXGXAG9FQBAcCbJHIC9wZHMCE9sRSAMCFWRQAICIrCEJCGrRfCBRbEXAKRTCBRtGXEXGXAOATlAf9PQBCBRKSLMALCU/CBJAtAM9sJRmATAfJRKCBREGXAMCoB9JQBAOAKlC/gB9JQBCBRIEXAmAIJREGXGXGXGXGXATAICKrJ2BBHYCEZfIBFGEBMAECBDtDMIBSEMAEAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPAPDQBFGENVcMILKOSQfbHeD8dBh+BsxoxoUwN0AeD8dFhxoUwkwk+gUa0sHnhTkAnsHnhNkAnsHn7CgFZHiCEWCxkUUBJDBEBAiCx+YUUBJDBBBHeAeDQBBBBBBBBBBBBBBBBAnhAk7CgFZHiCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIBAKCIJAeDeBJAiCx+YUUBJ2BBJRKSGMAEAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPAPDQBFGENVcMILKOSQfbHeD8dBh+BsxoxoUwN0AeD8dFhxoUwkwk+gUa0sHnhTkAnsHnhNkAnsHn7CgFZHiCEWCxkUUBJDBEBAiCx+YUUBJDBBBHeAeDQBBBBBBBBBBBBBBBBAnhAk7CgFZHiCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIBAKCNJAeDeBJAiCx+YUUBJ2BBJRKSFMAEAKDBBBDMIBAKCTJRKMGXGXGXGXGXAYCGrCEZfIBFGEBMAECBDtDMITSEMAEAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPAPDQBFGENVcMILKOSQfbHeD8dBh+BsxoxoUwN0AeD8dFhxoUwkwk+gUa0sHnhTkAnsHnhNkAnsHn7CgFZHiCEWCxkUUBJDBEBAiCx+YUUBJDBBBHeAeDQBBBBBBBBBBBBBBBBAnhAk7CgFZHiCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMITAKCIJAeDeBJAiCx+YUUBJ2BBJRKSGMAEAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPAPDQBFGENVcMILKOSQfbHeD8dBh+BsxoxoUwN0AeD8dFhxoUwkwk+gUa0sHnhTkAnsHnhNkAnsHn7CgFZHiCEWCxkUUBJDBEBAiCx+YUUBJDBBBHeAeDQBBBBBBBBBBBBBBBBAnhAk7CgFZHiCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMITAKCNJAeDeBJAiCx+YUUBJ2BBJRKSFMAEAKDBBBDMITAKCTJRKMGXGXGXGXGXAYCIrCEZfIBFGEBMAECBDtDMIASEMAEAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPAPDQBFGENVcMILKOSQfbHeD8dBh+BsxoxoUwN0AeD8dFhxoUwkwk+gUa0sHnhTkAnsHnhNkAnsHn7CgFZHiCEWCxkUUBJDBEBAiCx+YUUBJDBBBHeAeDQBBBBBBBBBBBBBBBBAnhAk7CgFZHiCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIAAKCIJAeDeBJAiCx+YUUBJ2BBJRKSGMAEAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPAPDQBFGENVcMILKOSQfbHeD8dBh+BsxoxoUwN0AeD8dFhxoUwkwk+gUa0sHnhTkAnsHnhNkAnsHn7CgFZHiCEWCxkUUBJDBEBAiCx+YUUBJDBBBHeAeDQBBBBBBBBBBBBBBBBAnhAk7CgFZHiCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIAAKCNJAeDeBJAiCx+YUUBJ2BBJRKSFMAEAKDBBBDMIAAKCTJRKMGXGXGXGXGXAYCKrfIBFGEBMAECBDtDMI8wSEMAEAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPAPDQBFGENVcMILKOSQfbHeD8dBh+BsxoxoUwN0AeD8dFhxoUwkwk+gUa0sHnhTkAnsHnhNkAnsHn7CgFZHYCEWCxkUUBJDBEBAYCx+YUUBJDBBBHeAeDQBBBBBBBBBBBBBBBBAnhAk7CgFZHYCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMI8wAKCIJAeDeBJAYCx+YUUBJ2BBJRKSGMAEAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPAPDQBFGENVcMILKOSQfbHeD8dBh+BsxoxoUwN0AeD8dFhxoUwkwk+gUa0sHnhTkAnsHnhNkAnsHn7CgFZHYCEWCxkUUBJDBEBAYCx+YUUBJDBBBHeAeDQBBBBBBBBBBBBBBBBAnhAk7CgFZHYCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMI8wAKCNJAeDeBJAYCx+YUUBJ2BBJRKSFMAEAKDBBBDMI8wAKCTJRKMAICoBJREAICUFJAM9LQFAERIAOAKlC/fB9LQBMMGXAEAM9PQBAECErRIEXGXAOAKlCi9PQBCBRKSOMAmAEJRYGXGXGXGXGXATAECKrJ2BBAICKZrCEZfIBFGEBMAYCBDtDMIBSEMAYAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPAPDQBFGENVcMILKOSQfbHeD8dBh+BsxoxoUwN0AeD8dFhxoUwkwk+gUa0sHnhTkAnsHnhNkAnsHn7CgFZHiCEWCxkUUBJDBEBAiCx+YUUBJDBBBHeAeDQBBBBBBBBBBBBBBBBAnhAk7CgFZHiCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIBAKCIJAeDeBJAiCx+YUUBJ2BBJRKSGMAYAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPAPDQBFGENVcMILKOSQfbHeD8dBh+BsxoxoUwN0AeD8dFhxoUwkwk+gUa0sHnhTkAnsHnhNkAnsHn7CgFZHiCEWCxkUUBJDBEBAiCx+YUUBJDBBBHeAeDQBBBBBBBBBBBBBBBBAnhAk7CgFZHiCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIBAKCNJAeDeBJAiCx+YUUBJ2BBJRKSFMAYAKDBBBDMIBAKCTJRKMAICGJRIAECTJHEAM9JQBMMGXAK9FQBAKRTAtCFJHtCI6QGSFMMCBRKSEMGXAM9FQBALCUGJAbJREALAbJDBGBReCBRYEXAEALCU/CBJAYJHIDBIBHdCFD9tAdCFDbHPD9OD9hD9RHdAIAMJDBIBH8ZCFD9tA8ZAPD9OD9hD9RH8ZDQBTFtGmEYIPLdKeOnHpAIAQJDBIBHyCFD9tAyAPD9OD9hD9RHyAIASJDBIBH8cCFD9tA8cAPD9OD9hD9RH8cDQBTFtGmEYIPLdKeOnH8dDQBFTtGEmYILPdKOenHPAPDQBFGEBFGEBFGEBFGEAeD9uHeDyBjGBAEAGJHIAeAPAPDQILKOILKOILKOILKOD9uHeDyBjGBAIAGJHIAeAPAPDQNVcMNVcMNVcMNVcMD9uHeDyBjGBAIAGJHIAeAPAPDQSQfbSQfbSQfbSQfbD9uHeDyBjGBAIAGJHIAeApA8dDQNVi8ZcMpySQ8c8dfb8e8fHPAPDQBFGEBFGEBFGEBFGED9uHeDyBjGBAIAGJHIAeAPAPDQILKOILKOILKOILKOD9uHeDyBjGBAIAGJHIAeAPAPDQNVcMNVcMNVcMNVcMD9uHeDyBjGBAIAGJHIAeAPAPDQSQfbSQfbSQfbSQfbD9uHeDyBjGBAIAGJHIAeAdA8ZDQNiV8ZcpMyS8cQ8df8eb8fHdAyA8cDQNiV8ZcpMyS8cQ8df8eb8fH8ZDQBFTtGEmYILPdKOenHPAPDQBFGEBFGEBFGEBFGED9uHeDyBjGBAIAGJHIAeAPAPDQILKOILKOILKOILKOD9uHeDyBjGBAIAGJHIAeAPAPDQNVcMNVcMNVcMNVcMD9uHeDyBjGBAIAGJHIAeAPAPDQSQfbSQfbSQfbSQfbD9uHeDyBjGBAIAGJHIAeAdA8ZDQNVi8ZcMpySQ8c8dfb8e8fHPAPDQBFGEBFGEBFGEBFGED9uHeDyBjGBAIAGJHIAeAPAPDQILKOILKOILKOILKOD9uHeDyBjGBAIAGJHIAeAPAPDQNVcMNVcMNVcMNVcMD9uHeDyBjGBAIAGJHIAeAPAPDQSQfbSQfbSQfbSQfbD9uHeDyBjGBAIAGJREAYCTJHYAM9JQBMMAbCIJHbAG9JQBMMABAVAG9sJALCUGJAcAG9s/8cBBALALCUGJAcCaJAG9sJAG/8cBBMAcCBAKyAVJRVAKQBMC9+RKSFMCBC99AOAKlAGCAAGCA9Ly6yRKMALCU/KBJ8kUUUUBAKMNBT+BUUUBM+KmFTa8jUUUUBCoFlHL8kUUUUBC9+RKGXAFCE9uHOCtJAI9LQBCaRKAE2BBHNC/wFZC/gF9HQBANCbZHVCF9LQBALCoBJCgFCUF/8MBALC84Jha83EBALC8wJha83EBALC8oJha83EBALCAJha83EBALCiJha83EBALCTJha83EBALha83ENALha83EBAEAIJC9wJRcAECFJHNAOJRMGXAF9FQBCQCbAVCF6yRSABRECBRVCBRQCBRfCBRICBRKEXGXAMAcuQBC9+RKSEMGXGXAN2BBHOC/vF9LQBALCoBJAOCIrCa9zAKJCbZCEWJHb8oGIRTAb8oGBRtGXAOCbZHbAS9PQBALAOCa9zAIJCbZCGWJ8oGBAVAbyROAb9FRbGXGXAGCG9HQBABAt87FBABCIJAO87FBABCGJAT87FBSFMAEAtjGBAECNJAOjGBAECIJATjGBMAVAbJRVALCoBJAKCEWJHmAOjGBAmATjGIALAICGWJAOjGBALCoBJAKCFJCbZHKCEWJHTAtjGBATAOjGIAIAbJRIAKCFJRKSGMGXGXAbCb6QBAQAbJAbC989zJCFJRQSFMAM1BBHbCgFZROGXGXAbCa9MQBAMCFJRMSFMAM1BFHbCgBZCOWAOCgBZqROGXAbCa9MQBAMCGJRMSFMAM1BGHbCgBZCfWAOqROGXAbCa9MQBAMCEJRMSFMAM1BEHbCgBZCdWAOqROGXAbCa9MQBAMCIJRMSFMAM2BIC8cWAOqROAMCLJRMMAOCFrCBAOCFZl9zAQJRQMGXGXAGCG9HQBABAt87FBABCIJAQ87FBABCGJAT87FBSFMAEAtjGBAECNJAQjGBAECIJATjGBMALCoBJAKCEWJHOAQjGBAOATjGIALAICGWJAQjGBALCoBJAKCFJCbZHKCEWJHOAtjGBAOAQjGIAICFJRIAKCFJRKSFMGXAOCDF9LQBALAIAcAOCbZJ2BBHbCIrHTlCbZCGWJ8oGBAVCFJHtATyROALAIAblCbZCGWJ8oGBAtAT9FHmJHtAbCbZHTyRbAT9FRTGXGXAGCG9HQBABAV87FBABCIJAb87FBABCGJAO87FBSFMAEAVjGBAECNJAbjGBAECIJAOjGBMALAICGWJAVjGBALCoBJAKCEWJHYAOjGBAYAVjGIALAICFJHICbZCGWJAOjGBALCoBJAKCFJCbZCEWJHYAbjGBAYAOjGIALAIAmJCbZHICGWJAbjGBALCoBJAKCGJCbZHKCEWJHOAVjGBAOAbjGIAKCFJRKAIATJRIAtATJRVSFMAVCBAM2BBHYyHTAOC/+F6HPJROAYCbZRtGXGXAYCIrHmQBAOCFJRbSFMAORbALAIAmlCbZCGWJ8oGBROMGXGXAtQBAbCFJRVSFMAbRVALAIAYlCbZCGWJ8oGBRbMGXGXAP9FQBAMCFJRYSFMAM1BFHYCgFZRTGXGXAYCa9MQBAMCGJRYSFMAM1BGHYCgBZCOWATCgBZqRTGXAYCa9MQBAMCEJRYSFMAM1BEHYCgBZCfWATqRTGXAYCa9MQBAMCIJRYSFMAM1BIHYCgBZCdWATqRTGXAYCa9MQBAMCLJRYSFMAMCKJRYAM2BLC8cWATqRTMATCFrCBATCFZl9zAQJHQRTMGXGXAmCb6QBAYRPSFMAY1BBHMCgFZROGXGXAMCa9MQBAYCFJRPSFMAY1BFHMCgBZCOWAOCgBZqROGXAMCa9MQBAYCGJRPSFMAY1BGHMCgBZCfWAOqROGXAMCa9MQBAYCEJRPSFMAY1BEHMCgBZCdWAOqROGXAMCa9MQBAYCIJRPSFMAYCLJRPAY2BIC8cWAOqROMAOCFrCBAOCFZl9zAQJHQROMGXGXAtCb6QBAPRMSFMAP1BBHMCgFZRbGXGXAMCa9MQBAPCFJRMSFMAP1BFHMCgBZCOWAbCgBZqRbGXAMCa9MQBAPCGJRMSFMAP1BGHMCgBZCfWAbqRbGXAMCa9MQBAPCEJRMSFMAP1BEHMCgBZCdWAbqRbGXAMCa9MQBAPCIJRMSFMAPCLJRMAP2BIC8cWAbqRbMAbCFrCBAbCFZl9zAQJHQRbMGXGXAGCG9HQBABAT87FBABCIJAb87FBABCGJAO87FBSFMAEATjGBAECNJAbjGBAECIJAOjGBMALCoBJAKCEWJHYAOjGBAYATjGIALAICGWJATjGBALCoBJAKCFJCbZCEWJHYAbjGBAYAOjGIALAICFJHICbZCGWJAOjGBALCoBJAKCGJCbZCEWJHOATjGBAOAbjGIALAIAm9FAmCb6qJHICbZCGWJAbjGBAIAt9FAtCb6qJRIAKCEJRKMANCFJRNABCKJRBAECSJREAKCbZRKAICbZRIAfCEJHfAF9JQBMMCBC99AMAc6yRKMALCoFJ8kUUUUBAKM/tIFGa8jUUUUBCTlRLC9+RKGXAFCLJAI9LQBCaRKAE2BBC/+FZC/QF9HQBALhB83ENAECFJRKAEAIJC98JREGXAF9FQBGXAGCG6QBEXGXAKAE9JQBC9+bMAK1BBHGCgFZRIGXGXAGCa9MQBAKCFJRKSFMAK1BFHGCgBZCOWAICgBZqRIGXAGCa9MQBAKCGJRKSFMAK1BGHGCgBZCfWAIqRIGXAGCa9MQBAKCEJRKSFMAK1BEHGCgBZCdWAIqRIGXAGCa9MQBAKCIJRKSFMAK2BIC8cWAIqRIAKCLJRKMALCNJAICFZCGWqHGAICGrCBAICFrCFZl9zAG8oGBJHIjGBABAIjGBABCIJRBAFCaJHFQBSGMMEXGXAKAE9JQBC9+bMAK1BBHGCgFZRIGXGXAGCa9MQBAKCFJRKSFMAK1BFHGCgBZCOWAICgBZqRIGXAGCa9MQBAKCGJRKSFMAK1BGHGCgBZCfWAIqRIGXAGCa9MQBAKCEJRKSFMAK1BEHGCgBZCdWAIqRIGXAGCa9MQBAKCIJRKSFMAK2BIC8cWAIqRIAKCLJRKMABAICGrCBAICFrCFZl9zALCNJAICFZCGWqHI8oGBJHG87FBAIAGjGBABCGJRBAFCaJHFQBMMCBC99AKAE6yRKMAKM/dLEK97FaF97GXGXAGCI9HQBAF9FQFCBRGEXABABDBBBHECiD+rFCiD+sFD/6FHIAECND+rFCiD+sFD/6FAID/gFAECTD+rFCiD+sFD/6FHLD/gFD/kFD/lFHKCBDtD+2FHOAICUUUU94DtHND9OD9RD/kFHI9DBB/+hDYAIAID/mFAKAKD/mFALAOALAND9OD9RD/kFHIAID/mFD/kFD/kFD/jFD/nFHLD/mF9DBBX9LDYHOD/kFCgFDtD9OAECUUU94DtD9OD9QAIALD/mFAOD/kFCND+rFCU/+EDtD9OD9QAKALD/mFAOD/kFCTD+rFCUU/8ODtD9OD9QDMBBABCTJRBAGCIJHGAF9JQBSGMMAF9FQBCBRGEXABCTJHVAVDBBBHECBDtHOCUU98D8cFCUU98D8cEHND9OABDBBBHKAEDQILKOSQfbPden8c8d8e8fCggFDtD9OD/6FAKAEDQBFGENVcMTtmYi8ZpyHECTD+sFD/6FHID/gFAECTD+rFCTD+sFD/6FHLD/gFD/kFD/lFHE9DB/+g6DYALAEAOD+2FHOALCUUUU94DtHcD9OD9RD/kFHLALD/mFAEAED/mFAIAOAIAcD9OD9RD/kFHEAED/mFD/kFD/kFD/jFD/nFHID/mF9DBBX9LDYHOD/kFCTD+rFALAID/mFAOD/kFCggEDtD9OD9QHLAEAID/mFAOD/kFCaDbCBDnGCBDnECBDnKCBDnOCBDncCBDnMCBDnfCBDnbD9OHEDQNVi8ZcMpySQ8c8dfb8e8fD9QDMBBABAKAND9OALAEDQBFTtGEmYILPdKOenD9QDMBBABCAJRBAGCIJHGAF9JQBMMM/hEIGaF97FaL978jUUUUBCTlREGXAF9FQBCBRIEXAEABDBBBHLABCTJHKDBBBHODQILKOSQfbPden8c8d8e8fHNCTD+sFHVCID+rFDMIBAB9DBBU8/DY9D/zI818/DYAVCEDtD9QD/6FD/nFHVALAODQBFGENVcMTtmYi8ZpyHLCTD+rFCTD+sFD/6FD/mFHOAOD/mFAVALCTD+sFD/6FD/mFHcAcD/mFAVANCTD+rFCTD+sFD/6FD/mFHNAND/mFD/kFD/kFD/lFCBDtD+4FD/jF9DB/+g6DYHVD/mF9DBBX9LDYHLD/kFCggEDtHMD9OAcAVD/mFALD/kFCTD+rFD9QHcANAVD/mFALD/kFCTD+rFAOAVD/mFALD/kFAMD9OD9QHVDQBFTtGEmYILPdKOenHLD8dBAEDBIBDyB+t+J83EBABCNJALD8dFAEDBIBDyF+t+J83EBAKAcAVDQNVi8ZcMpySQ8c8dfb8e8fHVD8dBAEDBIBDyG+t+J83EBABCiJAVD8dFAEDBIBDyE+t+J83EBABCAJRBAICIJHIAF9JQBMMM9jFF97GXAGCGrAF9sHG9FQBCBRFEXABABDBBBHECND+rFCND+sFD/6FAECiD+sFCnD+rFCUUU/8EDtD+uFD/mFDMBBABCTJRBAFCIJHFAG9JQBMMM9TFEaCBCB8oGUkUUBHFABCEJC98ZJHBjGUkUUBGXGXAB8/BCTWHGuQBCaREABAGlCggEJCTrXBCa6QFMAFREMAEMMMFBCUNMIT9tBB`);let r,i=WebAssembly.instantiate(a(n),{}).then(e=>{r=e.instance,r.exports.__wasm_call_ctors()});function a(e){let n=new Uint8Array(e.length);for(let t=0;t96?r-71:r>64?r-65:r>47?r+4:r>46?63:62}let r=0;for(let i=0;i{n&&n(r),e&&(Uj||=new Rj,Uj.setDecoderPath(typeof e==`string`?e:Wj),r.setDRACOLoader(Uj)),t&&r.setMeshoptDecoder(typeof Vj==`function`?Vj():Vj)}}var Kj=(e,t,n,r)=>R_(NA,e,Gj(t,n,r));Kj.preload=(e,t,n,r)=>R_.preload(NA,e,Gj(t,n,r)),Kj.clear=e=>R_.clear(NA,e),Kj.setDecoderPath=e=>{Wj=e};var qj=class extends Cl{constructor(e=new W){super({uniforms:{inputBuffer:new J(null),depthBuffer:new J(null),resolution:new J(new W),texelSize:new J(new W),halfTexelSize:new J(new W),kernel:new J(0),scale:new J(1),cameraNear:new J(0),cameraFar:new J(1),minDepthThreshold:new J(0),maxDepthThreshold:new J(1),depthScale:new J(0),depthToBlurRatioBias:new J(.25)},fragmentShader:`#include #include uniform sampler2D inputBuffer; uniform sampler2D depthBuffer; uniform float cameraNear; uniform float cameraFar; uniform float minDepthThreshold; uniform float maxDepthThreshold; uniform float depthScale; uniform float depthToBlurRatioBias; varying vec2 vUv; varying vec2 vUv0; varying vec2 vUv1; varying vec2 vUv2; varying vec2 vUv3; void main() { float depthFactor = 0.0; #ifdef USE_DEPTH vec4 depth = texture2D(depthBuffer, vUv); depthFactor = smoothstep(minDepthThreshold, maxDepthThreshold, 1.0-(depth.r * depth.a)); depthFactor *= depthScale; depthFactor = max(0.0, min(1.0, depthFactor + 0.25)); #endif vec4 sum = texture2D(inputBuffer, mix(vUv0, vUv, depthFactor)); sum += texture2D(inputBuffer, mix(vUv1, vUv, depthFactor)); sum += texture2D(inputBuffer, mix(vUv2, vUv, depthFactor)); sum += texture2D(inputBuffer, mix(vUv3, vUv, depthFactor)); gl_FragColor = sum * 0.25 ; #include #include #include <${Hj>=154?`colorspace_fragment`:`encodings_fragment`}> }`,vertexShader:`uniform vec2 texelSize; uniform vec2 halfTexelSize; uniform float kernel; uniform float scale; varying vec2 vUv; varying vec2 vUv0; varying vec2 vUv1; varying vec2 vUv2; varying vec2 vUv3; void main() { vec2 uv = position.xy * 0.5 + 0.5; vUv = uv; vec2 dUv = (texelSize * vec2(kernel) + halfTexelSize) * scale; vUv0 = vec2(uv.x - dUv.x, uv.y + dUv.y); vUv1 = vec2(uv.x + dUv.x, uv.y + dUv.y); vUv2 = vec2(uv.x + dUv.x, uv.y - dUv.y); vUv3 = vec2(uv.x - dUv.x, uv.y - dUv.y); gl_Position = vec4(position.xy, 1.0, 1.0); }`,blending:0,depthWrite:!1,depthTest:!1}),this.toneMapped=!1,this.setTexelSize(e.x,e.y),this.kernel=new Float32Array([0,1,2,2,3])}setTexelSize(e,t){this.uniforms.texelSize.value.set(e,t),this.uniforms.halfTexelSize.value.set(e,t).multiplyScalar(.5)}setResolution(e){this.uniforms.resolution.value.copy(e)}},Jj=class{constructor({gl:e,resolution:t,width:n=500,height:r=500,minDepthThreshold:i=0,maxDepthThreshold:a=1,depthScale:o=0,depthToBlurRatioBias:s=.25}){this.renderToScreen=!1,this.renderTargetA=new rr(t,t,{minFilter:M,magFilter:M,stencilBuffer:!1,depthBuffer:!1,type:ce}),this.renderTargetB=this.renderTargetA.clone(),this.convolutionMaterial=new qj,this.convolutionMaterial.setTexelSize(1/n,1/r),this.convolutionMaterial.setResolution(new W(n,r)),this.scene=new Kr,this.camera=new Ou,this.convolutionMaterial.uniforms.minDepthThreshold.value=i,this.convolutionMaterial.uniforms.maxDepthThreshold.value=a,this.convolutionMaterial.uniforms.depthScale.value=o,this.convolutionMaterial.uniforms.depthToBlurRatioBias.value=s,this.convolutionMaterial.defines.USE_DEPTH=o>0;let c=new Float32Array([-1,-1,0,3,-1,0,-1,3,0]),l=new Float32Array([0,0,2,0,0,2]),u=new Xi;u.setAttribute(`position`,new Ai(c,3)),u.setAttribute(`uv`,new Ai(l,2)),this.screen=new Va(u,this.convolutionMaterial),this.screen.frustumCulled=!1,this.scene.add(this.screen)}render(e,t,n){let r=this.scene,i=this.camera,a=this.renderTargetA,o=this.renderTargetB,s=this.convolutionMaterial,c=s.uniforms;c.depthBuffer.value=t.depthTexture;let l=s.kernel,u=t,d,f,p;for(f=0,p=l.length-1;f`,`#include my_vUv = textureMatrix * vec4( position, 1.0 ); gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );`),e.fragmentShader=` uniform sampler2D tDiffuse; uniform sampler2D tDiffuseBlur; uniform sampler2D tDepth; uniform sampler2D distortionMap; uniform float distortion; uniform float cameraNear; uniform float cameraFar; uniform bool hasBlur; uniform float mixBlur; uniform float mirror; uniform float mixStrength; uniform float minDepthThreshold; uniform float maxDepthThreshold; uniform float mixContrast; uniform float depthScale; uniform float depthToBlurRatioBias; varying vec4 my_vUv; ${e.fragmentShader}`,e.fragmentShader=e.fragmentShader.replace(`#include `,`#include float distortionFactor = 0.0; #ifdef USE_DISTORTION distortionFactor = texture2D(distortionMap, vUv).r * distortion; #endif vec4 new_vUv = my_vUv; new_vUv.x += distortionFactor; new_vUv.y += distortionFactor; vec4 base = texture2DProj(tDiffuse, new_vUv); vec4 blur = texture2DProj(tDiffuseBlur, new_vUv); vec4 merge = base; #ifdef USE_NORMALMAP vec2 normal_uv = vec2(0.0); vec4 normalColor = texture2D(normalMap, vUv * normalScale); vec3 my_normal = normalize( vec3( normalColor.r * 2.0 - 1.0, normalColor.b, normalColor.g * 2.0 - 1.0 ) ); vec3 coord = new_vUv.xyz / new_vUv.w; normal_uv = coord.xy + coord.z * my_normal.xz * 0.05; vec4 base_normal = texture2D(tDiffuse, normal_uv); vec4 blur_normal = texture2D(tDiffuseBlur, normal_uv); merge = base_normal; blur = blur_normal; #endif float depthFactor = 0.0001; float blurFactor = 0.0; #ifdef USE_DEPTH vec4 depth = texture2DProj(tDepth, new_vUv); depthFactor = smoothstep(minDepthThreshold, maxDepthThreshold, 1.0-(depth.r * depth.a)); depthFactor *= depthScale; depthFactor = max(0.0001, min(1.0, depthFactor)); #ifdef USE_BLUR blur = blur * min(1.0, depthFactor + depthToBlurRatioBias); merge = merge * min(1.0, depthFactor + 0.5); #else merge = merge * depthFactor; #endif #endif float reflectorRoughnessFactor = roughness; #ifdef USE_ROUGHNESSMAP vec4 reflectorTexelRoughness = texture2D( roughnessMap, vUv ); reflectorRoughnessFactor *= reflectorTexelRoughness.g; #endif #ifdef USE_BLUR blurFactor = min(1.0, mixBlur * reflectorRoughnessFactor); merge = mix(merge, blur, blurFactor); #endif vec4 newMerge = vec4(0.0, 0.0, 0.0, 1.0); newMerge.r = (merge.r - 0.5) * mixContrast + 0.5; newMerge.g = (merge.g - 0.5) * mixContrast + 0.5; newMerge.b = (merge.b - 0.5) * mixContrast + 0.5; diffuseColor.rgb = diffuseColor.rgb * ((1.0 - min(1.0, mirror)) + newMerge.rgb * mixStrength); `)}get tDiffuse(){return this._tDiffuse.value}set tDiffuse(e){this._tDiffuse.value=e}get tDepth(){return this._tDepth.value}set tDepth(e){this._tDepth.value=e}get distortionMap(){return this._distortionMap.value}set distortionMap(e){this._distortionMap.value=e}get tDiffuseBlur(){return this._tDiffuseBlur.value}set tDiffuseBlur(e){this._tDiffuseBlur.value=e}get textureMatrix(){return this._textureMatrix.value}set textureMatrix(e){this._textureMatrix.value=e}get hasBlur(){return this._hasBlur.value}set hasBlur(e){this._hasBlur.value=e}get mirror(){return this._mirror.value}set mirror(e){this._mirror.value=e}get mixBlur(){return this._mixBlur.value}set mixBlur(e){this._mixBlur.value=e}get mixStrength(){return this._blurStrength.value}set mixStrength(e){this._blurStrength.value=e}get minDepthThreshold(){return this._minDepthThreshold.value}set minDepthThreshold(e){this._minDepthThreshold.value=e}get maxDepthThreshold(){return this._maxDepthThreshold.value}set maxDepthThreshold(e){this._maxDepthThreshold.value=e}get depthScale(){return this._depthScale.value}set depthScale(e){this._depthScale.value=e}get depthToBlurRatioBias(){return this._depthToBlurRatioBias.value}set depthToBlurRatioBias(e){this._depthToBlurRatioBias.value=e}get distortion(){return this._distortion.value}set distortion(e){this._distortion.value=e}get mixContrast(){return this._mixContrast.value}set mixContrast(e){this._mixContrast.value=e}},Xj=b.forwardRef(({mixBlur:e=0,mixStrength:t=1,resolution:n=256,blur:r=[0,0],minDepthThreshold:i=.9,maxDepthThreshold:a=1,depthScale:o=0,depthToBlurRatioBias:s=.25,mirror:c=0,distortion:l=1,mixContrast:u=1,distortionMap:d,reflectorOffset:f=0,...p},m)=>{av({MeshReflectorMaterialImpl:Yj});let h=N_(({gl:e})=>e),g=N_(({camera:e})=>e),_=N_(({scene:e})=>e);r=Array.isArray(r)?r:[r,r];let v=r[0]+r[1]>0,y=r[0],x=r[1],S=b.useRef(null);b.useImperativeHandle(m,()=>S.current,[]);let[C]=b.useState(()=>new vo),[w]=b.useState(()=>new G),[T]=b.useState(()=>new G),[E]=b.useState(()=>new G),[D]=b.useState(()=>new cr),[O]=b.useState(()=>new G(0,0,-1)),[k]=b.useState(()=>new tr),[A]=b.useState(()=>new G),[j]=b.useState(()=>new G),[ee]=b.useState(()=>new tr),[te]=b.useState(()=>new cr),[N]=b.useState(()=>new Mu),P=b.useCallback(()=>{var e;let t=S.current.parent||((e=S.current)==null||(e=e.__r3f.parent)==null?void 0:e.object);if(!t||(T.setFromMatrixPosition(t.matrixWorld),E.setFromMatrixPosition(g.matrixWorld),D.extractRotation(t.matrixWorld),w.set(0,0,1),w.applyMatrix4(D),T.addScaledVector(w,f),A.subVectors(T,E),A.dot(w)>0))return;A.reflect(w).negate(),A.add(T),D.extractRotation(g.matrixWorld),O.set(0,0,-1),O.applyMatrix4(D),O.add(E),j.subVectors(T,O),j.reflect(w).negate(),j.add(T),N.position.copy(A),N.up.set(0,1,0),N.up.applyMatrix4(D),N.up.reflect(w),N.lookAt(j),N.far=g.far,N.updateMatrixWorld(),N.projectionMatrix.copy(g.projectionMatrix),te.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),te.multiply(N.projectionMatrix),te.multiply(N.matrixWorldInverse),te.multiply(t.matrixWorld),C.setFromNormalAndCoplanarPoint(w,T),C.applyMatrix4(N.matrixWorldInverse),k.set(C.normal.x,C.normal.y,C.normal.z,C.constant);let n=N.projectionMatrix;ee.x=(Math.sign(k.x)+n.elements[8])/n.elements[0],ee.y=(Math.sign(k.y)+n.elements[9])/n.elements[5],ee.z=-1,ee.w=(1+n.elements[10])/n.elements[14],k.multiplyScalar(2/k.dot(ee)),n.elements[2]=k.x,n.elements[6]=k.y,n.elements[10]=k.z+1,n.elements[14]=k.w},[g,f]),[F,ne,re,ie]=b.useMemo(()=>{let r={minFilter:M,magFilter:M,type:ce},f=new rr(n,n,r);f.depthBuffer=!0,f.depthTexture=new xs(n,n),f.depthTexture.format=_e,f.depthTexture.type=ae;let p=new rr(n,n,r);return[f,p,new Jj({gl:h,resolution:n,width:y,height:x,minDepthThreshold:i,maxDepthThreshold:a,depthScale:o,depthToBlurRatioBias:s}),{mirror:c,textureMatrix:te,mixBlur:e,tDiffuse:f.texture,tDepth:f.depthTexture,tDiffuseBlur:p.texture,hasBlur:v,mixStrength:t,minDepthThreshold:i,maxDepthThreshold:a,depthScale:o,depthToBlurRatioBias:s,distortion:l,distortionMap:d,mixContrast:u,"defines-USE_BLUR":v?``:void 0,"defines-USE_DEPTH":o>0?``:void 0,"defines-USE_DISTORTION":d?``:void 0}]},[h,y,x,te,n,c,v,e,t,i,a,o,s,l,d,u]);return P_(()=>{var e;let t=S.current.parent||((e=S.current)==null||(e=e.__r3f.parent)==null?void 0:e.object);if(!t)return;t.visible=!1;let n=h.xr.enabled,r=h.shadowMap.autoUpdate;P(),h.xr.enabled=!1,h.shadowMap.autoUpdate=!1,h.setRenderTarget(F),h.state.buffers.depth.setMask(!0),h.autoClear||h.clear(),h.render(_,N),v&&re.render(h,F,ne),h.xr.enabled=n,h.shadowMap.autoUpdate=r,t.visible=!0,h.setRenderTarget(null)}),b.createElement(`meshReflectorMaterialImpl`,qk({attach:`material`,key:`key`+ie[`defines-USE_BLUR`]+ie[`defines-USE_DEPTH`]+ie[`defines-USE_DISTORTION`],ref:S},ie,p))}),Zj=(e,t,n)=>{let r;switch(e){case re:r=new Uint8ClampedArray(t*n*4);break;case ce:r=new Uint16Array(t*n*4);break;case oe:r=new Uint32Array(t*n*4);break;case ie:r=new Int8Array(t*n*4);break;case I:r=new Int16Array(t*n*4);break;case L:r=new Int32Array(t*n*4);break;case se:r=new Float32Array(t*n*4);break;default:throw Error(`Unsupported data type`)}return r},Qj,$j=(e,t,n,r)=>{if(Qj!==void 0)return Qj;let i=new rr(1,1,r);t.setRenderTarget(i);let a=new Va(new nl,new ka({color:16777215}));t.render(a,n),t.setRenderTarget(null);let o=Zj(e,i.width,i.height);return t.readRenderTargetPixels(i,0,0,i.width,i.height,o),i.dispose(),a.geometry.dispose(),a.material.dispose(),Qj=o[0]!==0,Qj},eM=class e{_renderer;_rendererIsDisposable=!1;_material;_scene;_camera;_quad;_renderTarget;_width;_height;_type;_colorSpace;_supportsReadPixels=!0;constructor(t){this._width=t.width,this._height=t.height,this._type=t.type,this._colorSpace=t.colorSpace;let n={format:ge,depthBuffer:!1,stencilBuffer:!1,type:this._type,colorSpace:this._colorSpace,anisotropy:t.renderTargetOptions?.anisotropy===void 0?1:t.renderTargetOptions?.anisotropy,generateMipmaps:t.renderTargetOptions?.generateMipmaps===void 0?!1:t.renderTargetOptions?.generateMipmaps,magFilter:t.renderTargetOptions?.magFilter===void 0?M:t.renderTargetOptions?.magFilter,minFilter:t.renderTargetOptions?.minFilter===void 0?M:t.renderTargetOptions?.minFilter,samples:t.renderTargetOptions?.samples===void 0?void 0:t.renderTargetOptions?.samples,wrapS:t.renderTargetOptions?.wrapS===void 0?D:t.renderTargetOptions?.wrapS,wrapT:t.renderTargetOptions?.wrapT===void 0?D:t.renderTargetOptions?.wrapT};if(this._material=t.material,t.renderer?this._renderer=t.renderer:(this._renderer=e.instantiateRenderer(),this._rendererIsDisposable=!0),this._scene=new Kr,this._camera=new Lu,this._camera.position.set(0,0,10),this._camera.left=-.5,this._camera.right=.5,this._camera.top=.5,this._camera.bottom=-.5,this._camera.updateProjectionMatrix(),!$j(this._type,this._renderer,this._camera,n)){let e;switch(this._type){case ce:e=this._renderer.extensions.has(`EXT_color_buffer_float`)?se:void 0;break}e===void 0?(this._supportsReadPixels=!1,console.warn(`This browser dos not support toArray or toDataTexture, calls to those methods will result in an error thrown`)):(console.warn(`This browser does not support reading pixels from ${this._type} RenderTargets, switching to ${se}`),this._type=e)}this._quad=new Va(new nl,this._material),this._quad.geometry.computeBoundingBox(),this._scene.add(this._quad),this._renderTarget=new rr(this.width,this.height,n),this._renderTarget.texture.mapping=t.renderTargetOptions?.mapping===void 0?300:t.renderTargetOptions?.mapping}static instantiateRenderer(){let e=new gg;return e.setSize(128,128),e}render=()=>{this._renderer.setRenderTarget(this._renderTarget);try{this._renderer.render(this._scene,this._camera)}catch(e){throw this._renderer.setRenderTarget(null),e}this._renderer.setRenderTarget(null)};toArray(){if(!this._supportsReadPixels)throw Error(`Can't read pixels in this browser`);let e=Zj(this._type,this._width,this._height);return this._renderer.readRenderTargetPixels(this._renderTarget,0,0,this._width,this._height,e),e}toDataTexture(e){let t=new to(this.toArray(),this.width,this.height,ge,this._type,e?.mapping||300,e?.wrapS||1001,e?.wrapT||1001,e?.magFilter||1006,e?.minFilter||1006,e?.anisotropy||1,xt);return t.generateMipmaps=e?.generateMipmaps===void 0?!1:e?.generateMipmaps,t}disposeOnDemandRenderer(){this._renderer.setRenderTarget(null),this._rendererIsDisposable&&(this._renderer.dispose(),this._renderer.forceContextLoss())}dispose(e){this.disposeOnDemandRenderer(),e&&this.renderTarget.dispose(),this.material instanceof Cl&&Object.values(this.material.uniforms).forEach(e=>{e.value instanceof er&&e.value.dispose()}),Object.values(this.material).forEach(e=>{e instanceof er&&e.dispose()}),this.material.dispose(),this._quad.geometry.dispose()}get width(){return this._width}set width(e){this._width=e,this._renderTarget.setSize(this._width,this._height)}get height(){return this._height}set height(e){this._height=e,this._renderTarget.setSize(this._width,this._height)}get renderer(){return this._renderer}get renderTarget(){return this._renderTarget}set renderTarget(e){this._renderTarget=e,this._width=e.width,this._height=e.height}get material(){return this._material}get type(){return this._type}get colorSpace(){return this._colorSpace}},tM=class extends Error{},nM=class extends Error{},rM=(e,t,n)=>{let r=RegExp(`${t}="([^"]*)"`,`i`).exec(e);if(r)return r[1];let i=RegExp(`<${t}[^>]*>([\\s\\S]*?)`,`i`).exec(e);if(i){let e=i[1].match(/([^<]*)<\/rdf:li>/g);return e&&e.length===3?e.map(e=>e.replace(/<\/?rdf:li>/g,``)):i[1].trim()}if(n!==void 0)return n;throw Error(`Can't find ${t} in gainmap metadata`)},iM=e=>{let t;t=typeof TextDecoder<`u`?new TextDecoder().decode(e):e.toString();let n=t.indexOf(``,n),r=t.slice(n,e+10);try{let e=rM(r,`hdrgm:GainMapMin`,`0`),t=rM(r,`hdrgm:GainMapMax`),n=rM(r,`hdrgm:Gamma`,`1`),i=rM(r,`hdrgm:OffsetSDR`,`0.015625`),a=rM(r,`hdrgm:OffsetHDR`,`0.015625`),o=/hdrgm:HDRCapacityMin="([^"]*)"/.exec(r),s=o?o[1]:`0`,c=/hdrgm:HDRCapacityMax="([^"]*)"/.exec(r);if(!c)throw Error(`Incomplete gainmap metadata`);let l=c[1];return{gainMapMin:Array.isArray(e)?e.map(e=>parseFloat(e)):[parseFloat(e),parseFloat(e),parseFloat(e)],gainMapMax:Array.isArray(t)?t.map(e=>parseFloat(e)):[parseFloat(t),parseFloat(t),parseFloat(t)],gamma:Array.isArray(n)?n.map(e=>parseFloat(e)):[parseFloat(n),parseFloat(n),parseFloat(n)],offsetSdr:Array.isArray(i)?i.map(e=>parseFloat(e)):[parseFloat(i),parseFloat(i),parseFloat(i)],offsetHdr:Array.isArray(a)?a.map(e=>parseFloat(e)):[parseFloat(a),parseFloat(a),parseFloat(a)],hdrCapacityMin:parseFloat(s),hdrCapacityMax:parseFloat(l)}}catch{}n=t.indexOf(`{let r=this.options.debug,i=new DataView(e.buffer);if(i.getUint16(0)!==65496){n(Error(`Not a valid jpeg`));return}let a=i.byteLength,o=2,s=0,c;for(;o250){n(Error(`Found no marker after ${s} loops 😵`));return}if(i.getUint8(o)!==255){n(Error(`Not a valid marker at offset 0x${o.toString(16)}, found: 0x${i.getUint8(o).toString(16)}`));return}if(c=i.getUint8(o+1),r&&console.log(`Marker: ${c.toString(16)}`),c===226){r&&console.log(`Found APP2 marker (0xffe2)`);let e=o+4;if(i.getUint32(e)===1297106432){let r=e+4,a;if(i.getUint16(r)===18761)a=!1;else if(i.getUint16(r)===19789)a=!0;else{n(Error(`No valid endianness marker found in TIFF header`));return}if(i.getUint16(r+2,!a)!==42){n(Error(`Not valid TIFF data! (no 0x002A marker)`));return}let o=i.getUint32(r+4,!a);if(o<8){n(Error(`Not valid TIFF data! (First offset less than 8)`));return}let s=r+o,c=i.getUint16(s,!a),l=s+2,u=0;for(let e=l;e{let t=iM(e);if(!t)throw new nM(`Gain map XMP metadata not found`);let n=await new aM({extractFII:!0,extractNonFII:!0}).extract(e);if(n.length!==2)throw new tM(`Gain map recovery image not found`);return{sdr:new Uint8Array(await n[0].arrayBuffer()),gainMap:new Uint8Array(await n[1].arrayBuffer()),metadata:t}},sM=e=>new Promise((t,n)=>{let r=document.createElement(`img`);r.onload=()=>{t(r)},r.onerror=e=>{n(e)},r.src=URL.createObjectURL(e)}),cM=class extends cu{_renderer;_renderTargetOptions;_internalLoadingManager;_config;constructor(e,t){super(t),this._config=e,e.renderer&&(this._renderer=e.renderer),this._internalLoadingManager=new ou}setRenderer(e){return this._renderer=e,this}setRenderTargetOptions(e){return this._renderTargetOptions=e,this}prepareQuadRenderer(){this._renderer||console.warn(`WARNING: A Renderer was not passed to this Loader constructor or in setRenderer, the result of this Loader will need to be converted to a Data Texture with toDataTexture() before you can use it in your renderer.`);let e=this._config.createMaterial({gainMapMax:[1,1,1],gainMapMin:[0,0,0],gamma:[1,1,1],offsetHdr:[1,1,1],offsetSdr:[1,1,1],hdrCapacityMax:1,hdrCapacityMin:0,maxDisplayBoost:1,gainMap:new er,sdr:new er});return this._config.createQuadRenderer({width:16,height:16,type:ce,colorSpace:xt,material:e,renderer:this._renderer,renderTargetOptions:this._renderTargetOptions})}async processImages(e,t,n){let r=t?new Blob([t],{type:`image/jpeg`}):void 0,i=new Blob([e],{type:`image/jpeg`}),a,o,s=!1;if(typeof createImageBitmap>`u`){let e=await Promise.all([r?sM(r):Promise.resolve(void 0),sM(i)]);o=e[0],a=e[1],s=n===`flipY`}else{let e=await Promise.all([r?createImageBitmap(r,{imageOrientation:n||`flipY`}):Promise.resolve(void 0),createImageBitmap(i,{imageOrientation:n||`flipY`})]);o=e[0],a=e[1]}return{sdrImage:a,gainMapImage:o,needsFlip:s}}createTextures(e,t,n){let r=new er(t||new ImageData(2,2),300,D,D,M,ne,ge,re,1,xt);r.flipY=n,r.needsUpdate=!0;let i=new er(e,300,D,D,M,ne,ge,re,1,bt);return i.flipY=n,i.needsUpdate=!0,{gainMap:r,sdr:i}}updateQuadRenderer(e,t,n,r,i){e.width=t.width,e.height=t.height,e.material.gainMap=n,e.material.sdr=r,e.material.gainMapMin=i.gainMapMin,e.material.gainMapMax=i.gainMapMax,e.material.offsetHdr=i.offsetHdr,e.material.offsetSdr=i.offsetSdr,e.material.gamma=i.gamma,e.material.hdrCapacityMin=i.hdrCapacityMin,e.material.hdrCapacityMax=i.hdrCapacityMax,e.material.maxDisplayBoost=2**i.hdrCapacityMax,e.material.needsUpdate=!0}},lM=` varying vec2 vUv; void main() { vUv = uv; gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0); } `,uM=` // min half float value #define HALF_FLOAT_MIN vec3( -65504, -65504, -65504 ) // max half float value #define HALF_FLOAT_MAX vec3( 65504, 65504, 65504 ) uniform sampler2D sdr; uniform sampler2D gainMap; uniform vec3 gamma; uniform vec3 offsetHdr; uniform vec3 offsetSdr; uniform vec3 gainMapMin; uniform vec3 gainMapMax; uniform float weightFactor; varying vec2 vUv; void main() { vec3 rgb = texture2D( sdr, vUv ).rgb; vec3 recovery = texture2D( gainMap, vUv ).rgb; vec3 logRecovery = pow( recovery, gamma ); vec3 logBoost = gainMapMin * ( 1.0 - logRecovery ) + gainMapMax * logRecovery; vec3 hdrColor = (rgb + offsetSdr) * exp2( logBoost * weightFactor ) - offsetHdr; vec3 clampedHdrColor = max( HALF_FLOAT_MIN, min( HALF_FLOAT_MAX, hdrColor )); gl_FragColor = vec4( clampedHdrColor , 1.0 ); } `,dM=class extends Cl{_maxDisplayBoost;_hdrCapacityMin;_hdrCapacityMax;constructor({gamma:e,offsetHdr:t,offsetSdr:n,gainMapMin:r,gainMapMax:i,maxDisplayBoost:a,hdrCapacityMin:o,hdrCapacityMax:s,sdr:c,gainMap:l}){super({name:`GainMapDecoderMaterial`,vertexShader:lM,fragmentShader:uM,uniforms:{sdr:{value:c},gainMap:{value:l},gamma:{value:new G(1/e[0],1/e[1],1/e[2])},offsetHdr:{value:new G().fromArray(t)},offsetSdr:{value:new G().fromArray(n)},gainMapMin:{value:new G().fromArray(r)},gainMapMax:{value:new G().fromArray(i)},weightFactor:{value:(Math.log2(a)-o)/(s-o)}},blending:0,depthTest:!1,depthWrite:!1}),this._maxDisplayBoost=a,this._hdrCapacityMin=o,this._hdrCapacityMax=s,this.needsUpdate=!0,this.uniformsNeedUpdate=!0}get sdr(){return this.uniforms.sdr.value}set sdr(e){this.uniforms.sdr.value=e}get gainMap(){return this.uniforms.gainMap.value}set gainMap(e){this.uniforms.gainMap.value=e}get offsetHdr(){return this.uniforms.offsetHdr.value.toArray()}set offsetHdr(e){this.uniforms.offsetHdr.value.fromArray(e)}get offsetSdr(){return this.uniforms.offsetSdr.value.toArray()}set offsetSdr(e){this.uniforms.offsetSdr.value.fromArray(e)}get gainMapMin(){return this.uniforms.gainMapMin.value.toArray()}set gainMapMin(e){this.uniforms.gainMapMin.value.fromArray(e)}get gainMapMax(){return this.uniforms.gainMapMax.value.toArray()}set gainMapMax(e){this.uniforms.gainMapMax.value.fromArray(e)}get gamma(){let e=this.uniforms.gamma.value;return[1/e.x,1/e.y,1/e.z]}set gamma(e){let t=this.uniforms.gamma.value;t.x=1/e[0],t.y=1/e[1],t.z=1/e[2]}get hdrCapacityMin(){return this._hdrCapacityMin}set hdrCapacityMin(e){this._hdrCapacityMin=e,this.calculateWeight()}get hdrCapacityMax(){return this._hdrCapacityMax}set hdrCapacityMax(e){this._hdrCapacityMax=e,this.calculateWeight()}get maxDisplayBoost(){return this._maxDisplayBoost}set maxDisplayBoost(e){this._maxDisplayBoost=Math.max(1,Math.min(65504,e)),this.calculateWeight()}calculateWeight(){let e=(Math.log2(this._maxDisplayBoost)-this._hdrCapacityMin)/(this._hdrCapacityMax-this._hdrCapacityMin);this.uniforms.weightFactor.value=Math.max(0,Math.min(1,e))}},fM=class extends cM{constructor(e,t){super({renderer:e,createMaterial:e=>new dM(e),createQuadRenderer:e=>new eM(e)},t)}async render(e,t,n,r){let{sdrImage:i,gainMapImage:a,needsFlip:o}=await this.processImages(n,r,`flipY`),{gainMap:s,sdr:c}=this.createTextures(i,a,o);this.updateQuadRenderer(e,i,s,c,t),e.render()}},pM=class extends fM{load([e,t,n],r,i,a){let o=this.prepareQuadRenderer(),s,c,l,u=async()=>{if(s&&c&&l){try{await this.render(o,l,s,c)}catch(r){this.manager.itemError(e),this.manager.itemError(t),this.manager.itemError(n),typeof a==`function`&&a(r),o.disposeOnDemandRenderer();return}typeof r==`function`&&r(o),this.manager.itemEnd(e),this.manager.itemEnd(t),this.manager.itemEnd(n),o.disposeOnDemandRenderer()}},d=!0,f=0,p=0,m=!0,h=0,g=0,_=!0,v=0,y=0,b=()=>{if(typeof i==`function`){let e=f+h+v,t=p+g+y;i(new ProgressEvent(`progress`,{lengthComputable:d&&m&&_,loaded:t,total:e}))}};this.manager.itemStart(e),this.manager.itemStart(t),this.manager.itemStart(n);let x=new du(this._internalLoadingManager);x.setResponseType(`arraybuffer`),x.setRequestHeader(this.requestHeader),x.setPath(this.path),x.setWithCredentials(this.withCredentials),x.load(e,async e=>{if(typeof e==`string`)throw Error(`Invalid sdr buffer`);s=e,await u()},e=>{d=e.lengthComputable,p=e.loaded,f=e.total,b()},t=>{this.manager.itemError(e),typeof a==`function`&&a(t)});let S=new du(this._internalLoadingManager);S.setResponseType(`arraybuffer`),S.setRequestHeader(this.requestHeader),S.setPath(this.path),S.setWithCredentials(this.withCredentials),S.load(t,async e=>{if(typeof e==`string`)throw Error(`Invalid gainmap buffer`);c=e,await u()},e=>{m=e.lengthComputable,g=e.loaded,h=e.total,b()},e=>{this.manager.itemError(t),typeof a==`function`&&a(e)});let C=new du(this._internalLoadingManager);return C.setRequestHeader(this.requestHeader),C.setPath(this.path),C.setWithCredentials(this.withCredentials),C.load(n,async e=>{if(typeof e!=`string`)throw Error(`Invalid metadata string`);l=JSON.parse(e),await u()},e=>{_=e.lengthComputable,y=e.loaded,v=e.total,b()},e=>{this.manager.itemError(n),typeof a==`function`&&a(e)}),o}},mM=class extends fM{load(e,t,n,r){let i=this.prepareQuadRenderer(),a=new du(this._internalLoadingManager);return a.setResponseType(`arraybuffer`),a.setRequestHeader(this.requestHeader),a.setPath(this.path),a.setWithCredentials(this.withCredentials),this.manager.itemStart(e),a.load(e,async n=>{if(typeof n==`string`)throw Error(`Invalid buffer, received [string], was expecting [ArrayBuffer]`);let a=new Uint8Array(n),o,s,c;try{let e=await oM(a);o=e.sdr,s=e.gainMap,c=e.metadata}catch(t){if(t instanceof nM||t instanceof tM)console.warn(`Failure to reconstruct an HDR image from ${e}: Gain map metadata not found in the file, HDRJPGLoader will render the SDR jpeg`),c={gainMapMin:[0,0,0],gainMapMax:[1,1,1],gamma:[1,1,1],hdrCapacityMin:0,hdrCapacityMax:1,offsetHdr:[0,0,0],offsetSdr:[0,0,0]},o=a;else throw t}try{await this.render(i,c,o.buffer,s?.buffer)}catch(t){this.manager.itemError(e),typeof r==`function`&&r(t),i.disposeOnDemandRenderer();return}typeof t==`function`&&t(i),this.manager.itemEnd(e),i.disposeOnDemandRenderer()},n,t=>{this.manager.itemError(e),typeof r==`function`&&r(t)}),i}},hM={apartment:`lebombo_1k.hdr`,city:`potsdamer_platz_1k.hdr`,dawn:`kiara_1_dawn_1k.hdr`,forest:`forest_slope_1k.hdr`,lobby:`st_fagans_interior_1k.hdr`,night:`dikhololo_night_1k.hdr`,park:`rooitou_park_1k.hdr`,studio:`studio_small_03_1k.hdr`,sunset:`venice_sunset_1k.hdr`,warehouse:`empty_warehouse_01_1k.hdr`},gM=`https://raw.githack.com/pmndrs/drei-assets/456060a26bbeb8fdf79326f224b6d99b8bcce736/hdri/`,_M=e=>Array.isArray(e),vM=[`/px.png`,`/nx.png`,`/py.png`,`/ny.png`,`/pz.png`,`/nz.png`];function yM({files:e=vM,path:t=``,preset:n=void 0,colorSpace:r=void 0,extensions:i}={}){n&&(SM(n),e=hM[n],t=gM);let a=_M(e),{extension:o,isCubemap:s}=CM(e),c=wM(o);if(!c)throw Error(`useEnvironment: Unrecognized file extension: `+e);let l=N_(e=>e.gl);(0,b.useLayoutEffect)(()=>{if(o!==`webp`&&o!==`jpg`&&o!==`jpeg`)return;function t(){R_.clear(c,a?[e]:e)}l.domElement.addEventListener(`webglcontextlost`,t,{once:!0})},[e,l.domElement]);let u=R_(c,a?[e]:e,e=>{(o===`webp`||o===`jpg`||o===`jpeg`)&&e.setRenderer(l),e.setPath==null||e.setPath(t),i&&i(e)}),d=a?u[0]:u;return(o===`jpg`||o===`jpeg`||o===`webp`)&&(d=d.renderTarget?.texture),d.mapping=s?301:303,d.colorSpace=r??(s?`srgb`:`srgb-linear`),d}var bM={files:vM,path:``,preset:void 0,extensions:void 0};yM.preload=e=>{let t={...bM,...e},{files:n,path:r=``}=t,{preset:i,extensions:a}=t;i&&(SM(i),n=hM[i],r=gM);let{extension:o}=CM(n);if(o===`webp`||o===`jpg`||o===`jpeg`)throw Error(`useEnvironment: Preloading gainmaps is not supported`);let s=wM(o);if(!s)throw Error(`useEnvironment: Unrecognized file extension: `+n);R_.preload(s,_M(n)?[n]:n,e=>{e.setPath==null||e.setPath(r),a&&a(e)})};var xM={files:vM,preset:void 0};yM.clear=e=>{let t={...xM,...e},{files:n}=t,{preset:r}=t;r&&(SM(r),n=hM[r]);let{extension:i}=CM(n),a=wM(i);if(!a)throw Error(`useEnvironment: Unrecognized file extension: `+n);R_.clear(a,_M(n)?[n]:n)};function SM(e){if(!(e in hM))throw Error(`Preset must be one of: `+Object.keys(hM).join(`, `))}function CM(e){var t;let n=_M(e)&&e.length===6,r=_M(e)&&e.length===3&&e.some(e=>e.endsWith(`json`)),i=_M(e)?e[0]:e;return{extension:n?`cube`:r?`webp`:i.startsWith(`data:application/exr`)?`exr`:i.startsWith(`data:application/hdr`)?`hdr`:i.startsWith(`data:image/jpeg`)?`jpg`:(t=i.split(`.`).pop())==null||(t=t.split(`?`))==null||(t=t.shift())==null?void 0:t.toLowerCase(),isCubemap:n,isGainmap:r}}function wM(e){return e===`cube`?gu:e===`hdr`?Pj:e===`exr`?Ij:e===`jpg`||e===`jpeg`?mM:e===`webp`?pM:null}var TM=e=>e.current&&e.current.isScene,EM=e=>TM(e)?e.current:e;function DM(e,t,n,r,i={}){var a,o;i={backgroundBlurriness:0,backgroundIntensity:1,backgroundRotation:[0,0,0],environmentIntensity:1,environmentRotation:[0,0,0],...i};let s=EM(t||n),c=s.background,l=s.environment,u={backgroundBlurriness:s.backgroundBlurriness,backgroundIntensity:s.backgroundIntensity,backgroundRotation:((a=s.backgroundRotation)==null||a.clone==null?void 0:a.clone())??[0,0,0],environmentIntensity:s.environmentIntensity,environmentRotation:((o=s.environmentRotation)==null||o.clone==null?void 0:o.clone())??[0,0,0]};return e!==`only`&&(s.environment=r),e&&(s.background=r),b_(s,i),()=>{e!==`only`&&(s.environment=l),e&&(s.background=c),b_(s,u)}}function OM({scene:e,background:t=!1,map:n,...r}){let i=N_(e=>e.scene);return b.useLayoutEffect(()=>{if(n)return DM(t,e,i,n,r)}),null}function kM({background:e=!1,scene:t,blur:n,backgroundBlurriness:r,backgroundIntensity:i,backgroundRotation:a,environmentIntensity:o,environmentRotation:s,...c}){let l=yM(c),u=N_(e=>e.scene);return b.useLayoutEffect(()=>DM(e,t,u,l,{backgroundBlurriness:n??r,backgroundIntensity:i,backgroundRotation:a,environmentIntensity:o,environmentRotation:s})),b.useEffect(()=>()=>{l.dispose()},[l]),null}function AM({children:e,near:t=.1,far:n=1e3,resolution:r=256,frames:i=1,map:a,background:o=!1,blur:s,backgroundBlurriness:c,backgroundIntensity:l,backgroundRotation:u,environmentIntensity:d,environmentRotation:f,scene:p,files:m,path:h,preset:g=void 0,extensions:_}){let v=N_(e=>e.gl),y=N_(e=>e.scene),x=b.useRef(null),[S]=b.useState(()=>new Kr),C=b.useMemo(()=>{let e=new Mp(r);return e.texture.type=ce,e},[r]);b.useEffect(()=>()=>{C.dispose()},[C]),b.useLayoutEffect(()=>{if(i===1){let e=v.autoClear;v.autoClear=!0,x.current.update(v,S),v.autoClear=e}return DM(o,p,y,C.texture,{backgroundBlurriness:s??c,backgroundIntensity:l,backgroundRotation:u,environmentIntensity:d,environmentRotation:f})},[e,S,C.texture,p,y,o,i,v]);let w=1;return P_(()=>{if(i===1/0||wav({GroundProjectedEnvImpl:DA}),[]),b.useEffect(()=>()=>{t.dispose()},[t]);let r=b.useMemo(()=>[n],[n]),i=e.ground?.height,a=e.ground?.radius,o=e.ground?.scale??1e3;return b.createElement(b.Fragment,null,b.createElement(OM,qk({},e,{map:n})),b.createElement(`groundProjectedEnvImpl`,{args:r,scale:o,height:i,radius:a}))}function MM(e){return e.ground?b.createElement(jM,e):e.map?b.createElement(OM,e):e.children?b.createElement(AM,e):b.createElement(kM,e)}var NM=b.forwardRef(({scale:e=10,frames:t=1/0,opacity:n=1,width:r=1,height:i=1,blur:a=1,near:o=0,far:s=10,resolution:c=512,smooth:l=!0,color:u=`#000000`,depthWrite:d=!1,renderOrder:f,...p},m)=>{let h=b.useRef(null),g=N_(e=>e.scene),_=N_(e=>e.gl),v=b.useRef(null);r*=Array.isArray(e)?e[0]:e||1,i*=Array.isArray(e)?e[1]:e||1;let[y,x,S,C,w,T,E]=b.useMemo(()=>{let e=new rr(c,c),t=new rr(c,c);t.texture.generateMipmaps=e.texture.generateMipmaps=!1;let n=new nl(r,i).rotateX(Math.PI/2),a=new Va(n),o=new jl;o.depthTest=o.depthWrite=!1,o.onBeforeCompile=e=>{e.uniforms={...e.uniforms,ucolor:{value:new K(u)}},e.fragmentShader=e.fragmentShader.replace(`void main() {`,`uniform vec3 ucolor; void main() { `),e.fragmentShader=e.fragmentShader.replace(`vec4( vec3( 1.0 - fragCoordZ ), opacity );`,`vec4( ucolor * fragCoordZ * 2.0, ( 1.0 - fragCoordZ ) * 1.0 );`)};let s=new Cl(Mj),l=new Cl(Nj);return l.depthTest=s.depthTest=!1,[e,n,o,a,s,l,t]},[c,r,i,e,u]),D=e=>{C.visible=!0,C.material=w,w.uniforms.tDiffuse.value=y.texture,w.uniforms.h.value=e*1/256,_.setRenderTarget(E),_.render(C,v.current),C.material=T,T.uniforms.tDiffuse.value=E.texture,T.uniforms.v.value=e*1/256,_.setRenderTarget(y),_.render(C,v.current),C.visible=!1},O=0,k,A;return P_(()=>{v.current&&(t===1/0||Oh.current,[]),b.createElement(`group`,qk({"rotation-x":Math.PI/2},p,{ref:h}),b.createElement(`mesh`,{renderOrder:f,geometry:x,scale:[1,-1,1],rotation:[-Math.PI/2,0,0]},b.createElement(`meshBasicMaterial`,{transparent:!0,map:y.texture,opacity:n,depthWrite:d})),b.createElement(`orthographicCamera`,{ref:v,args:[-r/2,r/2,i/2,-i/2,o,s]}))});function PM({pixelated:e}){let t=N_(e=>e.gl),n=N_(e=>e.internal.active),r=N_(e=>e.performance.current),i=N_(e=>e.viewport.initialDpr),a=N_(e=>e.setDpr);return b.useEffect(()=>{let r=t.domElement;return()=>{n&&a(i),e&&r&&(r.style.imageRendering=`auto`)}},[]),b.useEffect(()=>{a(r*i),e&&t.domElement&&(t.domElement.style.imageRendering=r===1?`auto`:`pixelated`)},[r]),null}var FM=Object.freeze([`jab`,`cross`,`low_kick`,`roundhouse`,`uppercut`]),IM=Object.freeze([`jab`,`cross`,`low_kick`,`roundhouse`,`uppercut`,`parry`,`backstep`,`clinch`,`throw`]),LM=Object.freeze(new Set([`roundhouse`,`uppercut`]));Object.freeze(new Set([`jab`,`cross`,`low_kick`]));var RM=Object.freeze(new Set([`clinch`,`throw`])),zM=Object.freeze(new Set([`parry`,`backstep`])),BM=Object.freeze({jab:{damage:6,staminaCost:8,range:3,minRange:1.9,optimalRange:2.4,maxRange:3,startup:.09,active:.06,recovery:.25,cancelWindow:.35,hitReaction:`flinch`,knockback:.2,attackerPushback:.02,hitstop:.03,blockedHitstop:.025,shake:.18,blockedShake:.06,anticipationWeight:.15,tags:[`punch`,`fast`]},cross:{damage:10,staminaCost:12,range:3.3,minRange:2,optimalRange:2.7,maxRange:3.3,startup:.12,active:.08,recovery:.3,cancelWindow:.32,hitReaction:`stumble`,knockback:.45,attackerPushback:.05,hitstop:.045,blockedHitstop:.03,shake:.26,blockedShake:.1,anticipationWeight:.3,tags:[`punch`]},low_kick:{damage:8,staminaCost:10,range:3.4,minRange:2.1,optimalRange:2.8,maxRange:3.4,startup:.14,active:.1,recovery:.28,cancelWindow:.32,hitReaction:`flinch`,knockback:.3,attackerPushback:.04,hitstop:.04,blockedHitstop:.028,shake:.22,blockedShake:.08,anticipationWeight:.3,tags:[`kick`,`low`]},roundhouse:{damage:14,staminaCost:22,range:3.8,minRange:2.3,optimalRange:3.1,maxRange:3.8,startup:.24,active:.12,recovery:.44,cancelWindow:.22,hitReaction:`knockdown`,knockback:1.1,attackerPushback:.12,hitstop:.09,blockedHitstop:.05,shake:.42,blockedShake:.18,anticipationWeight:.55,tags:[`kick`,`heavy`]},uppercut:{damage:16,staminaCost:24,range:2.6,minRange:1.5,optimalRange:2,maxRange:2.6,startup:.2,active:.1,recovery:.5,cancelWindow:.18,hitReaction:`knockdown`,knockback:.85,attackerPushback:.1,hitstop:.08,blockedHitstop:.045,shake:.4,blockedShake:.16,anticipationWeight:.45,tags:[`punch`,`heavy`]},parry:{damage:0,staminaCost:14,range:1.5,minRange:0,optimalRange:1.5,maxRange:2.5,startup:.05,active:.2,recovery:.2,cancelWindow:.35,hitReaction:`none`,knockback:0,attackerPushback:0,hitstop:.02,blockedHitstop:.02,shake:0,blockedShake:0,anticipationWeight:.1,tags:[`defensive`,`counter`]},walk:{damage:0,staminaCost:0,range:0,minRange:0,optimalRange:0,maxRange:0,startup:.2,active:.2,recovery:.2,cancelWindow:1,hitReaction:`none`,knockback:0,attackerPushback:0,hitstop:0,blockedHitstop:0,shake:0,blockedShake:0,anticipationWeight:0,tags:[`locomotion`]},backstep:{damage:0,staminaCost:10,range:0,minRange:0,optimalRange:0,maxRange:0,startup:.05,active:.18,recovery:.12,cancelWindow:1,hitReaction:`none`,knockback:0,attackerPushback:0,hitstop:0,blockedHitstop:0,shake:0,blockedShake:0,anticipationWeight:.1,tags:[`defensive`,`evasive`]},clinch:{damage:4,staminaCost:12,range:1.6,minRange:.5,optimalRange:1,maxRange:1.6,startup:.1,active:.1,recovery:.3,cancelWindow:.4,hitReaction:`clinched`,knockback:0,attackerPushback:0,hitstop:.06,blockedHitstop:.04,shake:.15,blockedShake:.1,anticipationWeight:.2,tags:[`grapple`]},throw:{damage:22,staminaCost:20,range:1.8,minRange:.6,optimalRange:1.1,maxRange:1.8,startup:.1,active:.1,recovery:.4,cancelWindow:.3,hitReaction:`fall`,knockback:1.4,attackerPushback:.05,hitstop:.12,blockedHitstop:.04,shake:.55,blockedShake:.12,anticipationWeight:.3,tags:[`grapple`,`heavy`]}});function VM(e){let t=BM[e];return t?t.startup+t.active+t.recovery:.5}function HM(e){return IM.includes(e)}function UM(e){return LM.has(e)}var WM=Object.freeze({maxStamina:100,baseRegenRate:18,blockRegenMultiplier:.35,actionRegenMultiplier:0,fatigueThreshold:20,fatigueExtraCost:3,grappledCostPenalty:5});function GM(e,t={}){let n=BM[e];if(!n)return 0;let r=n.staminaCost;return t.isFatigued&&r>0&&(r+=WM.fatigueExtraCost),t.isGrappled&&r>0&&(r+=WM.grappledCostPenalty),Math.max(0,r)}function KM(e,t,n={}){let{isBlocking:r,isAttacking:i,isHit:a,isGrappled:o}=n,s=WM.baseRegenRate;return i||a||o?s*=WM.actionRegenMultiplier:r&&(s*=WM.blockRegenMultiplier),JM(e+s*t)}function qM(e,t,n={}){return t>=GM(e,n)}function JM(e){return Math.max(0,Math.min(WM.maxStamina,e))}function YM(e,t,n={}){return JM(e-GM(t,n))}var XM=Object.freeze({maxComboScaleHits:6,minComboScale:.35,counterHitMultiplier:1.35,blockChipFraction:.08,blockStaminaFraction:.35,blockStaminaDamageFraction:.25,parryStaminaReward:12,grappledDamageMultiplier:1.15}),ZM=Object.freeze({NONE:`none`,FLINCH:`flinch`,STUMBLE:`stumble`,KNOCKDOWN:`knockdown`,FALL:`fall`,CLINCHED:`clinched`});function QM(e,t,n){return Math.max(t,Math.min(n,e))}function $M(e){let t=Math.max(0,e);return t===0?1:QM(1-t/XM.maxComboScaleHits,XM.minComboScale,1)}function eN(e,t){if(!e||!e.isAttacking)return!1;let n=BM[t];if(!n)return!1;let r=e.animProgress||0,i=n.startup+n.active+n.recovery;if(i<=0)return!1;let a=r*i;return an.startup+n.active+n.recovery*.4}function tN(e,t,n){let r=BM[e];if(!r)return ZM.FLINCH;if(r.hitReaction){if(r.hitReaction===ZM.CLINCHED)return ZM.CLINCHED;if(r.hitReaction===ZM.NONE)return ZM.NONE}return n<=0?ZM.FALL:UM(e)&&t>=12?ZM.KNOCKDOWN:t>=10?ZM.STUMBLE:ZM.FLINCH}function nN(e,t,n,r,i={}){let a=BM[e.move];if(!a)return{hit:!1,reason:`unknown_move`};let o=a.minRange==null?a.range*.3:a.minRange,s=a.maxRange==null?a.range:a.maxRange;if(ns)return{hit:!1,reason:`out_of_range`};if(e.position&&t.position&&e.facing!=null){let n=t.position[0]-e.position[0];if(n!==0&&Math.sign(n)!==Math.sign(e.facing))return{hit:!1,reason:`wrong_facing`}}let c=1;a.optimalRange!=null&&Math.abs(n-a.optimalRange)>.4&&(c=.8);let l=a.startup+a.active+a.recovery,u=(e.animProgress||0)*l;if(!(u>=a.startup&&u<=a.startup+a.active))return{hit:!1,reason:`not_active`};if(t.isBlocking)return rN(e,t);if(t.anim===`parry`)return iN(e,t);if(t.anim===`backstep`)return{hit:!1,reason:`evaded`};let d=a.damage*c,f=eN(t,t.anim);f&&(d*=XM.counterHitMultiplier);let p=i.comboCount||0;d*=$M(p),i.defenderIsGrappled&&(d*=XM.grappledDamageMultiplier),d=Math.round(d);let m=Math.max(0,(t.hp||0)-d),h=tN(e.move,d,m);return{hit:!0,damage:d,hpLeft:m,reaction:h,knockback:a.knockback,counterHit:f,rangeScale:c,reason:`hit`}}function rN(e,t){let n=BM[e.move];if(!n)return{hit:!1,reason:`unknown_move`};let r=n.damage,i=Math.max(1,Math.floor(r*XM.blockChipFraction)),a=Math.floor(GM(e.move)*XM.blockStaminaFraction),o=Math.floor(r*XM.blockStaminaDamageFraction);return{hit:!1,blocked:!0,chip:i,staminaCost:a,staminaDamage:o,hpLeft:Math.max(0,(t.hp||0)-i),staminaLeft:Math.max(0,(t.stamina||0)-a-o),reaction:ZM.NONE,knockback:n.knockback*.25,reason:`blocked`}}function iN(e,t){let n=BM.parry,r=n.startup+n.active+n.recovery,i=(t.animProgress||0)*r;if(!(i>=n.startup&&i<=n.startup+n.active)){let n=BM[e.move],r=n&&n.optimalRange!=null?n.optimalRange:2;return nN(e,{...t,anim:`idle`,isBlocking:!1},r,0)}return{hit:!1,parried:!0,staminaReward:XM.parryStaminaReward,reaction:ZM.NONE,counterWindow:n.active*.8,reason:`parried`}}function aN(e,t,n){let r=BM.clinch,i=n??0,a=r.minRange==null?0:r.minRange,o=r.maxRange==null?r.range:r.maxRange;if(io)return{success:!1,reason:`out_of_range`};if(e&&t&&e.position&&t.position&&e.facing!=null){let n=t.position[0]-e.position[0];if(n!==0&&Math.sign(n)!==Math.sign(e.facing))return{success:!1,reason:`wrong_facing`}}if(RM.has(t.anim))return{success:!1,reason:`defender_occupied`};if(zM.has(t.anim))return{success:!1,reason:`defended`};let s=r.damage;return{success:!0,damage:s,hpLeft:Math.max(0,(t.hp||0)-s),reaction:ZM.CLINCHED,grappled:!0,duration:1.2,reason:`clinched`}}function oN(e,t,n){let r=BM.throw,i=n??0,a=r.minRange==null?0:r.minRange,o=r.maxRange==null?r.range:r.maxRange;if(io)return{success:!1,reason:`out_of_range`};if(e&&t&&e.position&&t.position&&e.facing!=null){let n=t.position[0]-e.position[0];if(n!==0&&Math.sign(n)!==Math.sign(e.facing))return{success:!1,reason:`wrong_facing`}}if(t.anim===`backstep`)return{success:!1,reason:`evaded`};let s=r.damage;t.anim===`clinch`&&(s*=XM.grappledDamageMultiplier),s=Math.round(s);let c=Math.max(0,(t.hp||0)-s);return{success:!0,damage:s,hpLeft:c,reaction:ZM.FALL,knockback:r.knockback,grappled:!1,duration:1.4,reason:`thrown`}}function sN(e,t=!1){switch(e){case ZM.FLINCH:return .3;case ZM.STUMBLE:return .55;case ZM.KNOCKDOWN:return t?1.2:.8;case ZM.FALL:return 1.6;case ZM.CLINCHED:return 1.4;default:return 0}}var cN=Object.freeze({balanced:Object.freeze({id:`balanced`,rangePreference:`mid`,aggression:.6,patience:.55,parryAffinity:.55,evadeAffinity:.45,blockAffinity:.55,grappleAffinity:.3,feintAffinity:.3,comboAffinity:.5,reactionDelayBase:.18,riskTolerance:.5,movementStyle:`circling`,signatureMoves:[`cross`,`low_kick`,`roundhouse`]}),heavy:Object.freeze({id:`heavy`,rangePreference:`mid`,aggression:.8,patience:.35,parryAffinity:.3,evadeAffinity:.2,blockAffinity:.75,grappleAffinity:.45,feintAffinity:.2,comboAffinity:.35,reactionDelayBase:.24,riskTolerance:.7,movementStyle:`direct`,signatureMoves:[`uppercut`,`roundhouse`,`cross`]}),fast:Object.freeze({id:`fast`,rangePreference:`close`,aggression:.85,patience:.3,parryAffinity:.45,evadeAffinity:.55,blockAffinity:.3,grappleAffinity:.2,feintAffinity:.5,comboAffinity:.7,reactionDelayBase:.14,riskTolerance:.6,movementStyle:`jittery`,signatureMoves:[`jab`,`cross`,`low_kick`]}),agile:Object.freeze({id:`agile`,rangePreference:`mid`,aggression:.65,patience:.6,parryAffinity:.5,evadeAffinity:.85,blockAffinity:.25,grappleAffinity:.15,feintAffinity:.55,comboAffinity:.65,reactionDelayBase:.12,riskTolerance:.55,movementStyle:`circling`,signatureMoves:[`jab`,`low_kick`,`cross`]}),grappler:Object.freeze({id:`grappler`,rangePreference:`close`,aggression:.7,patience:.5,parryAffinity:.4,evadeAffinity:.3,blockAffinity:.7,grappleAffinity:.9,feintAffinity:.25,comboAffinity:.55,reactionDelayBase:.2,riskTolerance:.65,movementStyle:`direct`,signatureMoves:[`clinch`,`throw`,`uppercut`]})}),lN=Object.freeze({ronin:`balanced`,monk:`grappler`,assassin:`agile`,champion:`heavy`});function uN(e){return cN[lN[e]||`balanced`]||cN.balanced}function dN(e){return e&&typeof e==`object`&&e.id?e:typeof e==`string`&&cN[e]?cN[e]:cN.balanced}function fN(e,t,n){return Math.max(t,Math.min(n,e))}function pN(e,t,n){return e+(t-e)*n}function mN(e,t=1){let n=dN(e),r=Math.max(1,Math.min(8,Math.round(t)||1)),i=Math.min(1,(r-1)/4),a=pN(.2,.08,i),o=pN(.2,.55,i),s=pN(.3,.1,i),c=pN(.18,.5,i),l=pN(.55,.85,i),u=pN(.62,.92,i),d=pN(.1,.4,i),f=pN(.05,.3,i),p=pN(.3,.7,i),m=pN(.2,.65,i),h=fN(a+(n.reactionDelayBase-.18),.05,.4),g=fN(o*(.5+n.parryAffinity),.05,.78),_=fN(s*(.5+n.blockAffinity),.05,.6),v=fN(c*(.5+n.evadeAffinity),.05,.75),y=fN(l*(.7+n.aggression*.5),.3,.98),b=fN(d*(.4+n.grappleAffinity*1.5),.02,.65),x=fN(f*(.5+n.feintAffinity*1.5),0,.55);return{aggression:y,reactionTime:h,parryChance:g,counterChance:fN(p*(.6+n.aggression*.8),.2,.9),blockChance:_,evadeChance:v,grappleChance:b,feintChance:x,comboChance:fN(m*(.5+n.comboAffinity),.1,.85),accuracy:fN(u,.5,.96),patience:n.patience,riskTolerance:n.riskTolerance,archetype:n,round:r}}function hN(e,t){let n=BM[t];if(!n)return null;let r=VM(t),i=(e.animProgress||0)*r;return{data:n,total:r,localTime:i,inStartup:i=n.startup&&i=n.startup&&i<=n.startup+n.active,inLateActive:i>=n.startup+n.active*.5&&i<=n.startup+n.active}}function gN(e,t,n,r,i){if(!qM(`parry`,i))return 0;let{data:a,inStartup:o,inEarlyActive:s}=e;if(!o&&!s)return 0;let c=a.tags||[];if(c.includes(`low`)||c.includes(`grapple`)||t>a.range*1.3+.4)return 0;let l=.25+(a.anticipationWeight||0)*1.4;return l*=.4+n.parryAffinity*1.1,l*=.5+r.parryChance*1.6,UM(e.move)&&(l+=.15),Math.max(0,l)}function _N(e,t,n,r,i,a){if(!qM(`backstep`,i))return 0;let{data:o,inStartup:s,inEarlyActive:c,inLateActive:l}=e;if(!s&&!c&&!l||t>o.range*1.2)return 0;let u=UM(e.move),d=.3+(o.anticipationWeight||0)*.6;return d*=.4+n.evadeAffinity*1.2,d*=.5+r.evadeChance*1.5,u&&(d+=.2),a&&(d+=.1),Math.max(0,d)}function vN(e,t,n,r){let{data:i}=e,a=i.tags||[],o=.44999999999999996;return o*=.5+t.blockAffinity*1.1,o*=.4+n.blockChance*1.4,a.includes(`low`)&&(o*=1.15),UM(e.move)&&(i.anticipationWeight||0)>.4&&(o*=.55),r>0&&(o*=Math.max(.25,1-r*.3)),Math.max(0,o)}function yN(e,t,n,r,i,a){if(a>0||!qM(`throw`,i)||t>2.3)return 0;let{inStartup:o,inEarlyActive:s}=e;if(!o&&!s||!UM(e.move))return 0;let c=.4;return c*=.3+n.grappleAffinity*1.5,c*=.5+r.grappleChance*1.2,c*=.7+n.riskTolerance*.6,Math.max(0,c)}function bN(e,t,n,r,i,a,o={}){if(!e||!e.isAttacking)return null;let s=hN(e,t);if(!s)return null;s.move=t;let c=o.consecutiveBlocks||0,l=o.parryCooldown||0,u=o.grappleCooldown||0,d=c>=1,f=gN(s,n,i,a,r);l>0&&(f*=.2);let p=_N(s,n,i,a,r,d),m=vN(s,i,a,c),h=yN(s,n,i,a,r,u),g=[{move:`parry`,score:f,delay:a.reactionTime*.6},{move:`backstep`,score:p,delay:a.reactionTime*.55},{move:`block`,score:m,delay:a.reactionTime*.8},{move:`throw`,score:h,delay:a.reactionTime*.45}];g.sort((e,t)=>t.score-e.score);let _=g[0],v=.35+(1-(a.accuracy||.65))*.3;return!_||_.scoree===t).length;return Math.min(.85,r*SN)}function wN(e){return{clinch:e?.clinchRange??2.4,close:e?.closeRange??4,kick:e?.kickRange??4.6}}var TN=.45;function EN(e,t,n,r,i,a){let o=FM.filter(e=>qM(e,t));if(o.length===0)return null;let s=TN*2,c=o.filter(t=>{let n=BM[t];return n?e<=(n.maxRange??n.range)+s:!1});if(c.length===0)return null;let l=c,u=wN(a),d=l.map(t=>{let a=BM[t],o=0;e<=u.clinch?o+=UM(t)?.18:.65:e<=u.close?o+=[`jab`,`cross`,`uppercut`].includes(t)?1:.5:e<=u.kick?o+=[`low_kick`,`roundhouse`].includes(t)?1:.4:o+=a.range>=e?.25:0,o+=a.damage/20*n.aggression*.6;let s=GM(t);return o+=(1-s/100)*.18,UM(t)&&(o-=(1-n.accuracy)*.35),r?.signatureMoves?.includes(t)&&(o+=.3),r?.rangePreference===`close`&&e<=u.close&&(o+=.1),r?.rangePreference===`far`&&e>u.close&&(o+=.1),o*=1-CN(i,t),{move:t,score:o}});d.sort((e,t)=>t.score-e.score);let f=d.slice(0,2),p=f[Math.floor(Math.random()*f.length)];return p?p.move:null}var DN=Object.freeze({jab:[`cross`,`low_kick`,`uppercut`],cross:[`low_kick`,`uppercut`,`roundhouse`],low_kick:[`cross`,`roundhouse`,`uppercut`],roundhouse:[`cross`,`jab`],uppercut:[`low_kick`,`cross`],clinch:[`throw`,`uppercut`]});function ON(e,t,n,r={}){if(!e)return[];let i=t?.comboAffinity??.4,a=r.aggression??t?.aggression??.5,o=Math.max(1,Math.round(1+i*2+a*.5)),s=Math.min(3,o),c=DN[e]||[`jab`,`cross`],l=[],u=n;for(let e=0;e5.5||n<1.6)return!1;let r=(e.feintAffinity||0)*.55;return Math.random()e===`roundhouse`||e===`uppercut`);if(t<=2.5){if((r?.grappleAffinity||0)>.55&&qM(`clinch`,n))return`clinch`;if(qM(`uppercut`,n)&&Math.random()<.45)return`uppercut`;if(qM(`jab`,n))return`jab`}if(t<=4)return a===`roundhouse`&&qM(`cross`,n)?`cross`:a===`uppercut`&&qM(`low_kick`,n)?`low_kick`:a===`low_kick`&&qM(`jab`,n)?`jab`:a===`cross`&&qM(`cross`,n)?`cross`:o&&qM(`jab`,n)?`jab`:qM(`cross`,n)?`cross`:qM(`jab`,n)?`jab`:null;if(t<=4.8){if(qM(`low_kick`,n))return`low_kick`;if(qM(`roundhouse`,n))return`roundhouse`}return qM(`low_kick`,n)?`low_kick`:qM(`jab`,n)?`jab`:null}var jN=2,MN=3.4,NN=4.4,PN=6;function FN(e){let t=e?.rangePreference||`mid`;return t===`close`?{tooCloseRange:1.6,closeRange:2.9,idealRange:3.6,farRange:5.4}:t===`far`?{tooCloseRange:2.4,closeRange:3.8,idealRange:4.8,farRange:6.2}:{tooCloseRange:jN,closeRange:MN,idealRange:NN,farRange:PN}}function IN(e,t){let n=FN(t),r=e=n.farRange,distance:e,boundaries:n}}function LN(e,t,n,r){let i=e?.movementStyle||`direct`;return n?`escapeCorner`:r?t.tooClose||t.close&&(e?.evadeAffinity||0)>.5?`retreat`:`hold`:t.far?`approach`:t.tooClose?i===`circling`?`circle`:(e?.grappleAffinity||0)>.6?`hold`:`retreat`:t.ideal?i===`jittery`?`microMove`:i===`circling`?`circle`:`hold`:i===`jittery`?`microMove`:`hold`}function RN(e,t,n={}){let r=n.arenaHalfWidth??15,i=n.cornerThreshold??3.5,a=e?.[0]||0,o=t?.[0]||0,s=a===0?1:-Math.sign(a),c=s>0?o>a:o=0?1:-1)*.5),[s*u,0,d]}function zN(e,t,n,r,i,a={}){let o=a.approachSpeedFactor??.72,s=a.retreatSpeedFactor??.65,c=r>.001?r:.001,l=t/c,u=n/c;switch(e){case`approach`:{let e=o*(.85+(i?.aggression||.5)*.4);return[l*e,0,u*e]}case`retreat`:{let e=s*(.85+(i?.evadeAffinity||.4)*.35);return[-l*e,0,-u*e]}case`circle`:{let e=(i?.id?.charCodeAt(0)||0)%2==0?1:-1,t=s*.65;return[-u*t*e,0,l*t*e]}case`microMove`:{let e=s*.3,t=Date.now()%800/800,n=Math.sin(t*Math.PI*2);return[-l*e*n,0,-u*e*n]}default:return[0,0,0]}}var BN=Object.freeze({IDLE:`idle`,APPROACH:`approach`,RETREAT:`retreat`,ATTACKING:`attacking`,BLOCKING:`block`,PARRYING:`parry`,BACKSTEPPING:`backstep`,CLINCHING:`clinch`,THROWING:`throw`,RECOVER:`recover`,CORNERED:`cornered`,FEINTING:`feinting`,WAITING:`waiting`}),VN=Object.freeze({arenaHalfWidth:15,arenaHalfDepth:10,clinchRange:2.4,closeRange:4,kickRange:4.6,tooCloseRange:2,cornerThreshold:3.5,baseDecisionCooldown:.85,blockDuration:.55,parryDuration:.32,backstepDuration:.28,backstepDistance:2.2,approachSpeedFactor:.72,retreatSpeedFactor:.65,staleWindowSize:4,parryCooldownAfterUse:.65,grappleCooldownAfterUse:1.2,feintCooldown:1.4}),HN=.32;function UN(e,t){let n=(e[0]||0)-(t[0]||0),r=(e[2]||0)-(t[2]||0);return Math.sqrt(n*n+r*r)}function WN(e,t,n=VN.staleWindowSize){if(!Array.isArray(e))return[t];for(e.push(t);e.length>n;)e.shift();return e}function GN(e,t){if(!Array.isArray(e)||e.length===0)return 0;let n=e.slice(-VN.staleWindowSize).filter(e=>e===t).length;return Math.min(.85,n*HN)}function KN(e){return e?e.isAttacking?!0:[BN.PARRYING,BN.BACKSTEPPING,BN.CLINCHING,BN.THROWING].includes(e.state):!1}function qN(e,t){return{history:Array.isArray(e.history)?e.history.slice():[],cooldown:Math.max(0,(e.cooldown||0)-t),reactionTimer:Math.max(0,(e.reactionTimer||0)-t),parryCooldown:Math.max(0,(e.parryCooldown||0)-t),grappleCooldown:Math.max(0,(e.grappleCooldown||0)-t),feintCooldown:Math.max(0,(e.feintCooldown||0)-t),consecutiveBlocks:e.consecutiveBlocks||0,prevPlayerAttacking:!!e.prevPlayerAttacking,comboPlan:Array.isArray(e.comboPlan)?e.comboPlan.slice():[],lastChosen:e.lastChosen||null}}function JN(e,t,n,r,i,a,o){switch(e){case`approach`:return{state:BN.APPROACH,anim:`walk`,velocity:zN(`approach`,t,n,r,i,o)};case`retreat`:return{state:BN.RETREAT,anim:`walk`,velocity:zN(`retreat`,t,n,r,i,o)};case`circle`:return{state:BN.APPROACH,anim:`walk`,velocity:zN(`circle`,t,n,r,i,o)};case`microMove`:return{state:BN.IDLE,anim:`idle`,velocity:zN(`microMove`,t,n,r,i,o)};case`escapeCorner`:return{state:BN.CORNERED,anim:`walk`,velocity:RN(a.position,[a.position[0]+t,0,(a.position[2]||0)+n],o)};default:return{state:BN.IDLE,anim:`idle`,velocity:[0,0,0]}}}function YN(e){if(e?.archetype)return dN(e.archetype);let t=e?.npcCharacterId||e?.game?.npcCharacterId;return t?uN(t):cN.balanced}function XN(e,t){for(;e.comboPlan.length>0;){let n=e.comboPlan.shift();if(qM(n,t)&&GN(e.history,n)<.6)return n}return null}function ZN(e,t=VN){let n={...VN,...t},{game:r,player:i,npc:a,pendingGemmaMove:o,dt:s}=e,c=YN(e),l=mN(c,r?.round||1),u=Array.isArray(e.playerHistory)?e.playerHistory:[],d=UN(i.position,a.position),f=(i.position[0]||0)-(a.position[0]||0),p=(i.position[2]||0)-(a.position[2]||0),m=f>0?1:-1,h=qN(e.ai||{},s),g=!!(i&&i.isAttacking);if(g&&!h.prevPlayerAttacking){let e=u.slice(-4).filter(e=>e===i.anim).length,t=Math.min(.6,Math.max(0,e-1)*.2),n=(l.reactionTime||.2)*(1-t);h.reactionTimer=Math.max(0,n-s*.5)}if(g||(h.consecutiveBlocks=0),h.prevPlayerAttacking=g,KN(a))return{state:a.state,anim:a.anim,move:a.anim,facing:m,ai:h};if(g&&h.cooldown<=0&&h.reactionTimer<=0){let e=bN(i,i.anim,d,a.stamina,c,l,h);if(e&&e.move&&e.move!==`none`)return h.cooldown=n.baseDecisionCooldown,e.move===`parry`?(h.parryCooldown=n.parryCooldownAfterUse,h.consecutiveBlocks=0,WN(h.history,`parry`),{state:BN.PARRYING,anim:`parry`,move:`parry`,facing:m,duration:n.parryDuration,ai:h}):e.move===`backstep`?(h.consecutiveBlocks=0,WN(h.history,`backstep`),{state:BN.BACKSTEPPING,anim:`backstep`,move:`backstep`,facing:m,duration:n.backstepDuration,velocity:[-Math.sign(f||1)*n.backstepDistance/n.backstepDuration,0,-p*.3],ai:h}):e.move===`throw`?(h.grappleCooldown=n.grappleCooldownAfterUse,h.consecutiveBlocks=0,WN(h.history,`throw`),{state:BN.THROWING,anim:`throw`,move:`throw`,facing:m,ai:h}):(h.consecutiveBlocks+=1,{state:BN.BLOCKING,anim:`block`,move:null,facing:m,duration:n.blockDuration,ai:h})}if(g&&h.reactionTimer>0)return{state:BN.WAITING,anim:a.anim===`walk`?`walk`:`idle`,move:null,facing:m,velocity:[0,0,0],ai:h};if(h.cooldown<=0){let e=XN(h,a.stamina);if(e)return h.cooldown=n.baseDecisionCooldown*.55,h.lastChosen=e,WN(h.history,e),{state:BN.ATTACKING,anim:e,move:e,facing:m,ai:h};if(d<=n.clinchRange&&h.grappleCooldown<=0&&Math.random()=n.arenaHalfWidth-n.cornerThreshold,b=JN(LN(c,_,v||y,g),f,p,d,c,a,n);return{state:b.state,anim:b.anim,move:null,facing:m,velocity:b.velocity,ai:h}}function QN(e,t=VN){let n=t.arenaHalfWidth??VN.arenaHalfWidth,r=t.arenaHalfDepth??VN.arenaHalfDepth;return[Math.max(-n,Math.min(n,e[0]||0)),e[1]||0,Math.max(-r,Math.min(r,e[2]||0))]}function $N(){return{history:[],cooldown:0,reactionTimer:0,parryCooldown:0,grappleCooldown:0,feintCooldown:0,consecutiveBlocks:0,prevPlayerAttacking:!1,comboPlan:[],lastChosen:null}}var eP={ronin:{id:`ronin`,name:`Ronin`,style:`balanced`,difficulty:`normal`,stats:{speed:3,power:3,range:3},accentColor:`#00d4ff`,bodyColor:`#07070a`,description:`A disciplined wanderer with no master, equally comfortable striking from any distance.`,torsoScale:1,headScale:1,limbScale:1,handScale:1,bodyScale:1,stanceOffset:1,stance:`balanced`,physics:{weight:1}},brute:{id:`brute`,name:`Brute`,style:`heavy`,difficulty:`easy`,stats:{speed:1,power:5,range:2},accentColor:`#ff7b00`,bodyColor:`#08070a`,description:`A hulking mountain of muscle whose haymakers end fights in a single clean blow.`,torsoScale:1.25,headScale:.9,limbScale:1.1,handScale:1.2,bodyScale:1.1,stanceOffset:.92,stance:`hunched`,physics:{weight:1.4}},monk:{id:`monk`,name:`Monk`,style:`fast`,difficulty:`hard`,stats:{speed:5,power:2,range:3},accentColor:`#f9d76c`,bodyColor:`#08070a`,description:`A lightning-fast ascetic who turns every block into a blur of counter-strikes.`,torsoScale:.85,headScale:.95,limbScale:1.15,handScale:.9,bodyScale:.95,stanceOffset:1.05,stance:`low`,physics:{weight:.8}},assassin:{id:`assassin`,name:`Assassin`,style:`agile`,difficulty:`expert`,stats:{speed:4,power:2,range:4},accentColor:`#9d4edd`,bodyColor:`#08070a`,description:`A shadow with knives for feet, darting in and out before opponents can react.`,torsoScale:.8,headScale:.9,limbScale:1.05,handScale:.85,bodyScale:1,stanceOffset:1,stance:`sideways`,physics:{weight:.7}}};Object.values(eP);var tP=`cd_online_uid_v1`,nP=(()=>{try{return globalThis.localStorage}catch{return null}})();function rP(){if(typeof globalThis.crypto?.randomUUID==`function`)return globalThis.crypto.randomUUID();let e=new Uint8Array(16);if(typeof globalThis.crypto?.getRandomValues==`function`)globalThis.crypto.getRandomValues(e);else for(let t=0;t<16;t++)e[t]=Math.floor(Math.random()*256);e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t=[...e].map(e=>e.toString(16).padStart(2,`0`)).join(``);return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}function iP(){if(!nP)return rP();let e=nP.getItem(tP);return(!e||e.length<8||e.length>64)&&(e=rP(),nP.setItem(tP,e)),e}function aP(){nP&&nP.removeItem(tP)}function oP(e){let t=eP[e]||eP.ronin;return{name:t.id,speed:t.stats.speed,power:t.stats.power,range:t.stats.range,weight:t.physics?.weight??1,stance:t.stance||`neutral`,stamina:100,hp:100}}function sP(e){return e==null||e<2?`close`:e<4?`mid`:`far`}function cP({sequence:e,playerCharacterId:t,npcCharacterId:n,round:r,distance:i,playerPrevMove:a,playerId:o,playerStamina:s,npcStamina:c}){return{sequence:e,player:oP(t),npc:oP(n),round:r||1,distance:sP(i),playerId:o||void 0,playerPrevMove:a||void 0}}var lP=new Set,uP={playerId:``,roundsLogged:0,nextRetrainIn:25,cooldownLeftSec:0,adapterScope:`global`,onlineRlEnabled:!1};function dP(){return uP}function fP(e){return lP.add(e),()=>lP.delete(e)}function pP(){for(let e of lP)try{e(uP)}catch(e){console.error(`adversary listener`,e)}}function mP(e){uP={...uP,...e},pP()}var hP=null,gP=null;function _P(e){if(!e||(mP({playerId:e}),hP))return;let t=async()=>{try{let t=await fetch(`/me?playerId=${encodeURIComponent(e)}`);if(!t.ok)return;let n=await t.json();mP({roundsLogged:n.rounds_logged??0,nextRetrainIn:n.next_retrain_in??0,cooldownLeftSec:n.cooldown_left_sec??0,adapterScope:n.adapter_scope??`global`,onlineRlEnabled:!!n.online_rl_enabled})}catch{}};t(),hP=setInterval(t,15e3),gP=setInterval(()=>{uP.cooldownLeftSec>0&&mP({cooldownLeftSec:Math.max(0,uP.cooldownLeftSec-1)})},1e3)}function vP(){hP&&=(clearInterval(hP),null),gP&&=(clearInterval(gP),null)}async function yP(e){if(!e)return!1;try{return(await fetch(`/forget`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({playerId:e})})).ok}catch(e){return console.error(`forget failed`,e),!1}}var bP=Object.freeze({MOVE_LEFT:`moveLeft`,MOVE_RIGHT:`moveRight`,MOVE_UP:`moveUp`,MOVE_DOWN:`moveDown`,JAB:`jab`,CROSS:`cross`,LOW_KICK:`lowKick`,ROUNDHOUSE:`roundhouse`,UPPERCUT:`uppercut`,BLOCK:`block`,BACKSTEP:`backstep`,PAUSE:`pause`});Object.freeze([bP.JAB,bP.CROSS,bP.LOW_KICK,bP.ROUNDHOUSE,bP.UPPERCUT]);var xP=Object.freeze({a:bP.MOVE_LEFT,arrowleft:bP.MOVE_LEFT,d:bP.MOVE_RIGHT,arrowright:bP.MOVE_RIGHT,w:bP.MOVE_UP,arrowup:bP.MOVE_UP,s:bP.MOVE_DOWN,arrowdown:bP.MOVE_DOWN,j:bP.JAB,l:bP.CROSS,k:bP.LOW_KICK,u:bP.UPPERCUT,i:bP.ROUNDHOUSE," ":bP.BLOCK,shift:bP.BLOCK,q:bP.BACKSTEP,escape:bP.PAUSE}),SP=Object.freeze(new Set([`w`,`a`,`s`,`d`,`arrowup`,`arrowdown`,`arrowleft`,`arrowright`,`j`,`k`,`l`,`u`,`i`,` `,`shift`,`q`,`escape`]));function CP(e){return(e||``).toLowerCase()}function wP(e,t=xP){return t[CP(e)]||null}function TP(e){return SP.has(CP(e))}function EP(){return{moveLeft:!1,moveRight:!1,moveUp:!1,moveDown:!1,jab:!1,cross:!1,lowKick:!1,roundhouse:!1,uppercut:!1,block:!1,backstep:!1,pause:!1}}function DP(e,t,n){let r=wP(t);return r&&(e[r]=n),e}function OP(e){let t=0,n=0;e.moveLeft&&--t,e.moveRight&&(t+=1),e.moveUp&&--n,e.moveDown&&(n+=1);let r=Math.sqrt(t*t+n*n);return r===0?{x:0,z:0}:{x:t/r,z:n/r}}function kP(e,t){return e.jab&&!t.jab?`jab`:e.cross&&!t.cross?`cross`:e.lowKick&&!t.lowKick?`low_kick`:e.roundhouse&&!t.roundhouse?`roundhouse`:e.uppercut&&!t.uppercut?`uppercut`:null}function AP(e,t){return!e.block&&t.block}function jP(e,t){return e.backstep&&!t.backstep}function MP(e,t){return e.pause&&!t.pause}function NP(e){let t=new Map,n=new Map,r=e.clone();return PP(e,r,function(e,r){t.set(r,e),n.set(e,r)}),r.traverse(function(e){if(!e.isSkinnedMesh)return;let r=e,i=t.get(e),a=i.skeleton.bones;r.skeleton=i.skeleton.clone(),r.bindMatrix.copy(i.bindMatrix),r.skeleton.bones=a.map(function(e){return n.get(e)}),r.bind(r.skeleton,r.bindMatrix)}),r}function PP(e,t,n){n(e,t);for(let r=0;re&&[e[0],-e[1],-e[2]];return{hipY:e.hipY,torso:t(e.torso),head:t(e.head),armL:t(e.armR),foreL:t(e.foreR),armR:t(e.armL),foreR:t(e.foreL),legL:t(e.legR),calfL:t(e.calfR),legR:t(e.legL),calfR:t(e.calfL),footL:t(e.footR),footR:t(e.footL)}}var zP={linear:e=>e,inQuad:e=>e*e,outQuad:e=>1-(1-e)*(1-e),inOutQuad:e=>e<.5?2*e*e:1-(-2*e+2)**2/2,inCubic:e=>e*e*e,outCubic:e=>1-(1-e)**3,inOutCubic:e=>e<.5?4*e*e*e:1-(-2*e+2)**3/2,outBack:e=>1+2.70158*(e-1)**3+1.70158*(e-1)**2,strike:e=>e<.4?Math.sin(e/.4*(Math.PI/2)):1-(e-.4)/.6*.25,recovery:e=>1-e**1.5,hold:()=>1},BP=LP(0);function VP(e){return Array.isArray(e)?[0,0,0]:0}function HP(e){let t={};for(let n of Object.keys(BP))e[n]===void 0?t[n]=VP(BP[n]):t[n]=Array.isArray(BP[n])?[e[n][0]-BP[n][0],e[n][1]-BP[n][1],e[n][2]-BP[n][2]]:e[n]-BP[n];return t}function UP(e,t,n,r={}){return{start:e,end:t,pose:HP(n),rootOffset:r.rootOffset||[0,0,0],ease:r.ease||`linear`}}function $(e){return e}var WP={idle:[UP(0,1,{hipY:1,torso:$([0,0,0]),head:$([0,0,0]),armL:$([.5,0,.4]),foreL:$([-1.2,0,0]),armR:$([.5,0,-.4]),foreR:$([-1.2,0,0]),legL:$([-.15,0,.08]),calfL:$([.15,0,0]),legR:$([.15,0,-.08]),calfR:$([.1,0,0]),footL:$([.04,0,.02]),footR:$([.04,0,-.02])})],walk:[UP(0,.5,{hipY:1.04,torso:$([0,0,.06]),head:$([0,0,0]),legL:$([-.7,0,.05]),calfL:$([.55,0,0]),legR:$([.7,0,-.05]),calfR:$([.1,0,0]),footL:$([.18,0,.03]),footR:$([-.16,0,-.04]),armL:$([.7,0,.4]),foreL:$([-1.2,0,0]),armR:$([.3,0,-.4]),foreR:$([-1.2,0,0])}),UP(.5,1,{hipY:1.04,torso:$([0,0,-.06]),head:$([0,0,0]),legL:$([.7,0,.05]),calfL:$([.1,0,0]),legR:$([-.7,0,-.05]),calfR:$([.55,0,0]),footL:$([-.16,0,.04]),footR:$([.18,0,-.03]),armL:$([.3,0,.4]),foreL:$([-1.2,0,0]),armR:$([.7,0,-.4]),foreR:$([-1.2,0,0])})],jab:[UP(0,.15,{hipY:1,torso:$([0,-.1,0]),armL:$([.6,0,.45]),foreL:$([-1.3,0,0])},{ease:`inQuad`}),UP(.15,.35,{hipY:1,torso:$([0,-.35,0]),armL:$([-1.5,0,.05]),foreL:$([-.1,0,0]),legL:$([-.3,0,.08])},{rootOffset:[.1,0,0],ease:`strike`}),UP(.35,.55,{hipY:1,torso:$([0,-.35,0]),armL:$([-1.5,0,.05]),foreL:$([-.1,0,0]),legL:$([-.3,0,.08])},{rootOffset:[.1,0,0],ease:`hold`}),UP(.55,1,{hipY:1,torso:$([0,0,0]),armL:$([.5,0,.4]),foreL:$([-1.2,0,0]),legL:$([-.15,0,.08])},{ease:`recovery`})],cross:[UP(0,.15,{hipY:1,torso:$([0,-.2,.02]),armR:$([.6,0,-.45]),foreR:$([-1.3,0,0])},{ease:`inQuad`}),UP(.15,.35,{hipY:1,torso:$([0,-.9,.1]),armR:$([-1.6,0,-.05]),foreR:$([-.1,0,0]),legR:$([.25,0,-.08])},{rootOffset:[.15,0,0],ease:`strike`}),UP(.35,.55,{hipY:1,torso:$([0,-.9,.1]),armR:$([-1.6,0,-.05]),foreR:$([-.1,0,0]),legR:$([.25,0,-.08])},{rootOffset:[.15,0,0],ease:`hold`}),UP(.55,1,{hipY:1,torso:$([0,0,0]),armR:$([.5,0,-.4]),foreR:$([-1.2,0,0]),legR:$([.15,0,-.08])},{ease:`recovery`})],low_kick:[UP(0,.2,{hipY:.95,torso:$([-.05,-.1,0]),legR:$([.15,0,-.08]),calfR:$([.1,0,0])},{ease:`inQuad`}),UP(.2,.45,{hipY:.98,torso:$([-.25,-.2,0]),legR:$([-1.4,0,.4]),calfR:$([.3,0,0]),footR:$([.48,0,.16])},{rootOffset:[.15,0,0],ease:`strike`}),UP(.45,.65,{hipY:.98,torso:$([-.25,-.2,0]),legR:$([-1.4,0,.4]),calfR:$([.3,0,0]),footR:$([.48,0,.16])},{rootOffset:[.15,0,0],ease:`hold`}),UP(.65,1,{hipY:1,torso:$([0,0,0]),legR:$([.15,0,-.08]),calfR:$([.1,0,0])},{ease:`recovery`})],roundhouse:[UP(0,.2,{hipY:1.05,torso:$([0,-.2,0]),legL:$([-.5,0,.3]),calfL:$([.4,0,0]),armL:$([.7,0,.6]),armR:$([.7,0,-.6])},{ease:`inCubic`}),UP(.2,.45,{hipY:1.25,torso:$([-.3,-1.8,0]),legL:$([-1.4,-.6,-1.2]),calfL:$([0,0,0]),footL:$([.28,-.25,-.35]),armL:$([.8,0,.8]),armR:$([.8,0,-.8])},{rootOffset:[.05,0,0],ease:`strike`}),UP(.45,.7,{hipY:1.25,torso:$([-.3,-1.8,0]),legL:$([-1.4,-.6,-1.2]),calfL:$([0,0,0]),footL:$([.28,-.25,-.35]),armL:$([.8,0,.8]),armR:$([.8,0,-.8])},{rootOffset:[.05,0,0],ease:`hold`}),UP(.7,1,{hipY:1,torso:$([0,0,0]),legL:$([-.15,0,.08]),calfL:$([.15,0,0]),armL:$([.5,0,.4]),armR:$([.5,0,-.4])},{ease:`recovery`})],uppercut:[UP(0,.2,{hipY:.95,torso:$([-.05,0,0]),armR:$([.8,0,-.4]),foreR:$([-1.4,0,0]),legL:$([-.25,0,.08]),calfL:$([.25,0,0])},{ease:`inQuad`}),UP(.2,.45,{hipY:1.35,torso:$([-.25,0,0]),armR:$([-2.6,0,0]),foreR:$([-.6,0,0]),legL:$([-.5,0,.08]),calfL:$([.5,0,0]),legR:$([-.4,0,-.08]),calfR:$([.4,0,0])},{rootOffset:[.1,0,0],ease:`strike`}),UP(.45,.7,{hipY:1.35,torso:$([-.25,0,0]),armR:$([-2.6,0,0]),foreR:$([-.6,0,0]),legL:$([-.5,0,.08]),calfL:$([.5,0,0]),legR:$([-.4,0,-.08]),calfR:$([.4,0,0])},{rootOffset:[.1,0,0],ease:`hold`}),UP(.7,1,{hipY:1,torso:$([0,0,0]),armR:$([.5,0,-.4]),foreR:$([-1.2,0,0]),legL:$([-.15,0,.08]),calfL:$([.15,0,0]),legR:$([.15,0,-.08]),calfR:$([.1,0,0])},{ease:`recovery`})],block:[UP(0,.2,{hipY:.95,torso:$([.05,0,0])},{ease:`inQuad`}),UP(.2,.8,{hipY:.95,torso:$([.1,0,0]),armL:$([-.3,0,.8]),foreL:$([-1.8,0,0]),armR:$([-.3,0,-.8]),foreR:$([-1.8,0,0])},{ease:`outQuad`}),UP(.8,1,{hipY:1,torso:$([0,0,0]),armL:$([.5,0,.4]),foreL:$([-1.2,0,0]),armR:$([.5,0,-.4]),foreR:$([-1.2,0,0])},{ease:`recovery`})],parry:[UP(0,.15,{hipY:.95,torso:$([.05,.2,0]),armL:$([-.5,0,.9]),foreL:$([-1.9,0,0]),armR:$([-.5,0,-.9]),foreR:$([-1.9,0,0])},{rootOffset:[-.1,0,0],ease:`inCubic`}),UP(.15,.35,{hipY:.95,torso:$([.05,-.3,0]),armL:$([-.2,0,.7]),foreL:$([-1.6,0,0]),armR:$([-.2,0,-.7]),foreR:$([-1.6,0,0])},{rootOffset:[.05,0,0],ease:`strike`}),UP(.35,1,{hipY:1,torso:$([0,0,0]),armL:$([.5,0,.4]),foreL:$([-1.2,0,0]),armR:$([.5,0,-.4]),foreR:$([-1.2,0,0])},{ease:`recovery`})],backstep:[UP(0,.3,{hipY:.95,torso:$([.05,0,0]),armL:$([.7,0,.5]),foreL:$([-1.2,0,0]),armR:$([.7,0,-.5]),foreR:$([-1.2,0,0]),legL:$([-.35,0,.08]),legR:$([.35,0,-.08])},{rootOffset:[-.25,0,0],ease:`outQuad`}),UP(.3,.7,{hipY:.95,torso:$([.05,0,0]),armL:$([.7,0,.5]),foreL:$([-1.2,0,0]),armR:$([.7,0,-.5]),foreR:$([-1.2,0,0]),legL:$([-.35,0,.08]),legR:$([.35,0,-.08])},{rootOffset:[-.45,0,0],ease:`linear`}),UP(.7,1,{hipY:1,torso:$([0,0,0]),armL:$([.5,0,.4]),foreL:$([-1.2,0,0]),armR:$([.5,0,-.4]),foreR:$([-1.2,0,0]),legL:$([-.15,0,.08]),legR:$([.15,0,-.08])},{rootOffset:[-.1,0,0],ease:`recovery`})],clinch:[UP(0,.3,{hipY:1,torso:$([.05,.2,0]),armL:$([.3,0,.6]),foreL:$([-1,0,0]),armR:$([.3,0,-.6]),foreR:$([-1,0,0])},{rootOffset:[.1,0,0],ease:`inOutQuad`}),UP(.3,.7,{hipY:.95,torso:$([.1,.3,0]),armL:$([-.2,0,.7]),foreL:$([-.8,0,0]),armR:$([-.2,0,-.7]),foreR:$([-.8,0,0])},{rootOffset:[.25,0,0],ease:`hold`}),UP(.7,1,{hipY:1,torso:$([0,0,0]),armL:$([.5,0,.4]),foreL:$([-1.2,0,0]),armR:$([.5,0,-.4]),foreR:$([-1.2,0,0])},{ease:`recovery`})],clinched:[UP(0,.25,{hipY:.96,torso:$([.12,.18,.04]),head:$([.12,0,.02]),armL:$([.05,0,.64]),foreL:$([-.75,0,0]),armR:$([.05,0,-.64]),foreR:$([-.75,0,0]),legL:$([-.22,0,.08]),calfL:$([.28,0,0]),legR:$([.22,0,-.08]),calfR:$([.28,0,0])},{rootOffset:[-.08,0,0],ease:`outQuad`}),UP(.25,.85,{hipY:.92,torso:$([.16,.28,.06]),head:$([.16,.05,.02]),armL:$([-.18,0,.72]),foreL:$([-.62,0,0]),armR:$([-.18,0,-.72]),foreR:$([-.62,0,0]),legL:$([-.28,0,.08]),calfL:$([.34,0,0]),legR:$([.28,0,-.08]),calfR:$([.34,0,0])},{rootOffset:[-.12,0,0],ease:`hold`}),UP(.85,1,{hipY:.96,torso:$([.08,.12,.03]),head:$([.1,0,0]),armL:$([.16,0,.58]),foreL:$([-.85,0,0]),armR:$([.16,0,-.58]),foreR:$([-.85,0,0])},{ease:`recovery`})],throw:[UP(0,.25,{hipY:1,torso:$([0,-.2,0]),armL:$([.6,0,.5]),foreL:$([-1.1,0,0]),armR:$([.6,0,-.5]),foreR:$([-1.1,0,0])},{rootOffset:[.1,0,0],ease:`inQuad`}),UP(.25,.5,{hipY:1.1,torso:$([0,-.6,0]),armL:$([-.8,0,.6]),foreL:$([-.4,0,0]),armR:$([-.8,0,-.6]),foreR:$([-.4,0,0])},{rootOffset:[.35,0,0],ease:`strike`}),UP(.5,.75,{hipY:1.1,torso:$([0,-.6,0]),armL:$([-.8,0,.6]),foreL:$([-.4,0,0]),armR:$([-.8,0,-.6]),foreR:$([-.4,0,0])},{rootOffset:[.35,0,0],ease:`hold`}),UP(.75,1,{hipY:1,torso:$([0,0,0]),armL:$([.5,0,.4]),foreL:$([-1.2,0,0]),armR:$([.5,0,-.4]),foreR:$([-1.2,0,0])},{ease:`recovery`})],thrown:[UP(0,.3,{hipY:1,torso:$([.2,.2,.1]),armL:$([.8,0,.7]),foreL:$([-.5,0,0]),armR:$([.8,0,-.7]),foreR:$([-.5,0,0])},{rootOffset:[-.1,0,0],ease:`outQuad`}),UP(.3,.8,{hipY:.35,torso:$([-.3,.4,-.2]),head:$([.4,0,.2]),armL:$([1,0,.8]),foreL:$([-.2,0,0]),armR:$([1,0,-.8]),foreR:$([-.2,0,0]),legL:$([-.6,0,.08]),calfL:$([.6,0,0]),legR:$([.6,0,-.08]),calfR:$([.6,0,0])},{rootOffset:[-.6,0,0],ease:`outCubic`}),UP(.8,1,{hipY:.35,torso:$([-.3,.4,-.2]),head:$([.4,0,.2]),armL:$([1,0,.8]),foreL:$([-.2,0,0]),armR:$([1,0,-.8]),foreR:$([-.2,0,0]),legL:$([-.6,0,.08]),calfL:$([.6,0,0]),legR:$([.6,0,-.08]),calfR:$([.6,0,0])},{rootOffset:[-.6,0,0],ease:`hold`})],flinch:[UP(0,.15,{hipY:.95,torso:$([.15,0,-.05]),head:$([.2,0,.1]),armL:$([.7,0,.6]),foreL:$([-.6,0,0]),armR:$([.7,0,-.6]),foreR:$([-.6,0,0])},{rootOffset:[-.05,0,0],ease:`strike`}),UP(.15,.5,{hipY:.95,torso:$([.3,0,-.15]),head:$([.4,0,.2]),armL:$([.8,0,.7]),foreL:$([-.5,0,0]),armR:$([.8,0,-.7]),foreR:$([-.5,0,0])},{rootOffset:[-.1,0,0],ease:`hold`}),UP(.5,1,{hipY:1,torso:$([0,0,0]),head:$([0,0,0]),armL:$([.5,0,.4]),foreL:$([-1.2,0,0]),armR:$([.5,0,-.4]),foreR:$([-1.2,0,0])},{ease:`recovery`})],stumble:[UP(0,.25,{hipY:.9,torso:$([.2,.2,-.15]),head:$([.3,0,.2]),armL:$([.9,0,.7]),foreL:$([-.4,0,0]),armR:$([.9,0,-.7]),foreR:$([-.4,0,0]),legL:$([-.35,0,.08]),legR:$([.35,0,-.08])},{rootOffset:[-.25,0,0],ease:`outQuad`}),UP(.25,.7,{hipY:.85,torso:$([.25,.4,-.2]),head:$([.4,0,.25]),armL:$([1,0,.8]),foreL:$([-.2,0,0]),armR:$([1,0,-.8]),foreR:$([-.2,0,0]),legL:$([-.5,0,.08]),calfL:$([.3,0,0]),legR:$([.5,0,-.08]),calfR:$([.3,0,0])},{rootOffset:[-.45,0,0],ease:`hold`}),UP(.7,1,{hipY:1,torso:$([0,0,0]),head:$([0,0,0]),armL:$([.5,0,.4]),foreL:$([-1.2,0,0]),armR:$([.5,0,-.4]),foreR:$([-1.2,0,0]),legL:$([-.15,0,.08]),calfL:$([.15,0,0]),legR:$([.15,0,-.08]),calfR:$([.1,0,0])},{rootOffset:[-.05,0,0],ease:`recovery`})],knockdown:[UP(0,.25,{hipY:.9,torso:$([.2,.3,-.2]),head:$([.4,0,.2]),armL:$([1,0,.8]),foreL:$([-.3,0,0]),armR:$([1,0,-.8]),foreR:$([-.3,0,0])},{rootOffset:[-.2,0,0],ease:`outQuad`}),UP(.25,.6,{hipY:.25,torso:$([-.4,.5,-.3]),head:$([.5,0,.3]),armL:$([1.2,0,.9]),foreL:$([0,0,0]),armR:$([1.2,0,-.9]),foreR:$([0,0,0]),legL:$([-.7,0,.08]),calfL:$([.7,0,0]),legR:$([.7,0,-.08]),calfR:$([.7,0,0])},{rootOffset:[-.7,0,0],ease:`outCubic`}),UP(.6,1,{hipY:.2,torso:$([-.4,.5,-.3]),head:$([.5,0,.3]),armL:$([1.2,0,.9]),foreL:$([0,0,0]),armR:$([1.2,0,-.9]),foreR:$([0,0,0]),legL:$([-.7,0,.08]),calfL:$([.7,0,0]),legR:$([.7,0,-.08]),calfR:$([.7,0,0])},{rootOffset:[-.7,0,0],ease:`hold`})],fall:[UP(0,.18,{hipY:.88,torso:$([.35,.16,-.14]),head:$([.35,0,.18]),armL:$([.95,0,.78]),foreL:$([-.38,0,0]),armR:$([.95,0,-.78]),foreR:$([-.38,0,0]),legL:$([-.4,0,.08]),calfL:$([.45,0,0]),legR:$([.38,0,-.08]),calfR:$([.45,0,0])},{rootOffset:[-.15,0,0],ease:`outQuad`}),UP(.18,.65,{hipY:.14,torso:$([1.5,.28,-.28]),head:$([.45,0,.24]),armL:$([1.18,0,.95]),foreL:$([-.08,0,0]),armR:$([1.18,0,-.95]),foreR:$([-.08,0,0]),legL:$([-.62,0,.08]),calfL:$([.72,0,0]),legR:$([.58,0,-.08]),calfR:$([.72,0,0]),footL:$([-.22,0,.12]),footR:$([-.22,0,-.12])},{rootOffset:[-.82,0,0],ease:`outCubic`}),UP(.65,1,{hipY:.12,torso:$([1.45,.22,-.24]),head:$([.36,0,.18]),armL:$([1.08,0,.86]),foreL:$([-.12,0,0]),armR:$([1.08,0,-.86]),foreR:$([-.12,0,0]),legL:$([-.52,0,.08]),calfL:$([.62,0,0]),legR:$([.5,0,-.08]),calfR:$([.62,0,0]),footL:$([-.18,0,.1]),footR:$([-.18,0,-.1])},{rootOffset:[-.82,0,0],ease:`hold`})],getup:[UP(0,.3,{hipY:.25,torso:$([-.4,.5,-.3]),head:$([.5,0,.3]),armL:$([1.2,0,.9]),foreL:$([0,0,0]),armR:$([1.2,0,-.9]),foreR:$([0,0,0]),legL:$([-.7,0,.08]),calfL:$([.7,0,0]),legR:$([.7,0,-.08]),calfR:$([.7,0,0])},{rootOffset:[-.7,0,0],ease:`linear`}),UP(.3,.6,{hipY:.7,torso:$([-.2,.2,-.1]),head:$([.2,0,.1]),armL:$([.9,0,.6]),foreL:$([-.5,0,0]),armR:$([.9,0,-.6]),foreR:$([-.5,0,0]),legL:$([-.5,0,.08]),calfL:$([.5,0,0]),legR:$([.5,0,-.08]),calfR:$([.5,0,0])},{rootOffset:[-.3,0,0],ease:`inOutCubic`}),UP(.6,1,{hipY:1,torso:$([0,0,0]),head:$([0,0,0]),armL:$([.5,0,.4]),foreL:$([-1.2,0,0]),armR:$([.5,0,-.4]),foreR:$([-1.2,0,0]),legL:$([-.15,0,.08]),calfL:$([.15,0,0]),legR:$([.15,0,-.08]),calfR:$([.1,0,0])},{ease:`recovery`})]};function GP(e,t){let n=WP[e]||WP.idle,r=FP(t),i=n[0],a=n[n.length-1];for(let e=0;e=n[e].start&&r=n[n.length-1].start&&(i=n[n.length-1],a=n[n.length-1]);let o=a.start-i.start||1,s=o<=0?0:FP((r-i.start)/o),c=(zP[i.ease]||zP.linear)(s),l={};for(let e of Object.keys(BP)){let t=i.pose[e],n=a.pose[e];Array.isArray(t)?l[e]=[t[0]+(n[0]-t[0])*c,t[1]+(n[1]-t[1])*c,t[2]+(n[2]-t[2])*c]:l[e]=t+(n-t)*c}let u=i.rootOffset,d=a.rootOffset;return{pose:l,rootOffset:[u[0]+(d[0]-u[0])*c,u[1]+(d[1]-u[1])*c,u[2]+(d[2]-u[2])*c],phase:i}}var KP=new Map;function qP(e,t){let n=document.createElement(`canvas`);n.width=e,n.height=e,t(n.getContext(`2d`),e);let r=new ys(n);return r.colorSpace=bt,r.minFilter=M,r.magFilter=M,r.generateMipmaps=!1,r}function JP(e,t,n){if(KP.has(e))return KP.get(e);let r=qP(t,(e,t)=>{let r=e.createRadialGradient(t/2,t/2,0,t/2,t/2,t/2);n.forEach(([e,t])=>r.addColorStop(e,t)),e.fillStyle=r,e.fillRect(0,0,t,t)});return KP.set(e,r),r}function YP(e,t){if(KP.has(e))return KP.get(e);let n=qP(t,(e,t)=>{e.save(),e.translate(t/2,t/2),e.rotate(Math.PI/5);let n=e.createLinearGradient(-t*.45,0,t*.45,0);n.addColorStop(0,`rgba(255,255,255,0)`),n.addColorStop(.25,`rgba(255,255,255,0.9)`),n.addColorStop(.55,`rgba(255,255,255,0.95)`),n.addColorStop(.85,`rgba(255,255,255,0.4)`),n.addColorStop(1,`rgba(255,255,255,0)`),e.fillStyle=n,e.beginPath(),e.ellipse(0,0,t*.42,t*.18,0,0,Math.PI*2),e.fill(),e.fillStyle=`rgba(255,255,255,0.7)`,e.fillRect(-t*.4,-.5,t*.8,1),e.restore()});return KP.set(e,n),n}function XP(e,t){if(KP.has(e))return KP.get(e);let n=qP(t,(e,t)=>{let n=t/2,r=t/2;e.strokeStyle=`rgba(255,255,255,1)`,e.lineWidth=1.4;for(let i=0;i<6;i++){let a=i/6*Math.PI;e.beginPath(),e.moveTo(n,r),e.lineTo(n+Math.cos(a)*t*.42,r+Math.sin(a)*t*.42),e.stroke()}});return KP.set(e,n),n}function ZP(){return JP(`softCircle`,64,[[0,`rgba(255,255,255,1)`],[.45,`rgba(255,255,255,0.5)`],[1,`rgba(255,255,255,0)`]])}function QP(){return JP(`glow`,64,[[0,`rgba(255,255,255,1)`],[.3,`rgba(255,255,255,0.75)`],[1,`rgba(255,255,255,0)`]])}function $P(){return YP(`leaf`,64)}function eF(){return XP(`flake`,64)}var tF=2,nF=[{active:!1,x:0,y:0,z:0},{active:!1,x:0,y:0,z:0}];function rF(e,t,n,r){if(e<0||e>=tF)return;let i=nF[e];i.active=!0,i.x=t,i.y=n,i.z=r}function iF(e){if(!e||!e.current)return null;let t=e.current;return Array.isArray(t.position)?{x:t.position[0]||0,y:t.position[1]||0,z:t.position[2]||0}:t.position&&typeof t.position.x==`number`?{x:t.position.x,y:t.position.y,z:t.position.z}:null}function aF({playerRef:e=null,npcRef:t=null,count:n=80,bounds:r=[30,8,18],origin:i=[0,2,-4],color:a=`#ffae3b`,size:o=.14,opacity:s=.7,drift:c=.25,repelRadius:l=1.8,repelStrength:u=6,damping:d=1.6,texture:f=null,sizePulseRef:p=null}){let m=(0,b.useRef)(),h=(0,b.useRef)(),[g,_,v]=r,[y,x,S]=i,C=(0,b.useMemo)(()=>f||QP(),[f]),[w]=(0,b.useState)(()=>{let e=new Float32Array(n*3),t=new Float32Array(n*3),r=new Float32Array(n),i=new Float32Array(n);for(let a=0;a1e-4?1/l:0;return P_((r,i)=>{let a=m.current;if(!a)return;let f=Math.min(i||.016,.05),g=r.clock.elapsedTime,_=iF(e)||(nF[0].active?nF[0]:null),v=iF(t)||(nF[1].active?nF[1]:null),b=a.geometry.attributes.position.array,C=w.velocities,k=w.phases,A=w.driftScales,j=Math.exp(-d*f);for(let e=0;e1e-4){let r=1-c*O,i=u*r*r/c;s+=e*i,d+=t*i,p+=n*i}}if(v){let e=i-v.x,t=a-(v.y+1),n=o-v.z,r=e*e+t*t*.4+n*n,c=Math.sqrt(r);if(c1e-4){let r=1-c*O,i=u*r*r/c;s+=e*i,d+=t*i,p+=n*i}}let m=k[e],h=c*A[e],w=Math.sin(g*.7+m)*h,ee=Math.cos(g*.5+m*1.3)*h*.4,te=Math.sin(g*.6+m*.7)*h,M=C[t]*j+s*f,N=C[n]*j+d*f,P=C[r]*j+p*f;i+=(M+w)*f,a+=(N+ee)*f,o+=(P+te)*f;let F=i-y,ne=a-x,re=o-S;F>T?(i=y-T,M=0):F<-T&&(i=y+T,M=0),ne>E?(a=x-E,N=0):ne<-E&&(a=x+E,N=0),re>D?(o=S-D,P=0):re<-D&&(o=S+D,P=0),b[t]=i,b[n]=a,b[r]=o,C[t]=M,C[n]=N,C[r]=P}if(a.geometry.attributes.position.needsUpdate=!0,h.current){let e=p&&typeof p.current==`number`?p.current:0;h.current.size=o*(1+e),h.current.opacity=s*(1+e*.6)}}),(0,X.jsxs)(`points`,{ref:m,frustumCulled:!1,children:[(0,X.jsx)(`bufferGeometry`,{children:(0,X.jsx)(`bufferAttribute`,{attach:`attributes-position`,array:w.positions,count:n,itemSize:3})}),(0,X.jsx)(`pointsMaterial`,{ref:h,size:o,color:a,map:C,alphaMap:C,transparent:!0,opacity:s,sizeAttenuation:!0,blending:2,depthWrite:!1})]})}var oF=Object.freeze({torso:{bone:`mixamorigSpine2`,type:`rotation`},head:{bone:`mixamorigHead`,type:`rotation`},armL:{bone:`mixamorigLeftArm`,type:`rotation`},foreL:{bone:`mixamorigLeftForeArm`,type:`rotation`},armR:{bone:`mixamorigRightArm`,type:`rotation`},foreR:{bone:`mixamorigRightForeArm`,type:`rotation`},legL:{bone:`mixamorigLeftUpLeg`,type:`rotation`},calfL:{bone:`mixamorigLeftLeg`,type:`rotation`},footL:{bone:`mixamorigLeftFoot`,type:`rotation`},legR:{bone:`mixamorigRightUpLeg`,type:`rotation`},calfR:{bone:`mixamorigRightLeg`,type:`rotation`},footR:{bone:`mixamorigRightFoot`,type:`rotation`}}),sF=Object.freeze({mixamorigHips:{rotation:[0,0,0]},mixamorigSpine:{rotation:[0,0,0]},mixamorigSpine1:{rotation:[0,0,0]},mixamorigSpine2:{rotation:[0,0,0]},mixamorigNeck:{rotation:[0,0,0]},mixamorigHead:{rotation:[0,0,0]},mixamorigLeftArm:{rotation:[0,0,Math.PI/2]},mixamorigLeftForeArm:{rotation:[0,0,0]},mixamorigLeftHand:{rotation:[0,0,0]},mixamorigRightArm:{rotation:[0,0,-Math.PI/2]},mixamorigRightForeArm:{rotation:[0,0,0]},mixamorigRightHand:{rotation:[0,0,0]},mixamorigLeftUpLeg:{rotation:[0,0,0]},mixamorigLeftLeg:{rotation:[0,0,0]},mixamorigLeftFoot:{rotation:[0,0,0]},mixamorigRightUpLeg:{rotation:[0,0,0]},mixamorigRightLeg:{rotation:[0,0,0]},mixamorigRightFoot:{rotation:[0,0,0]}}),cF=Object.freeze({torso:{bone:`Torso_1`,type:`rotation`},head:{bone:`Head`,type:`rotation`},armL:{bone:`UpperArmL`,type:`rotation`},foreL:{bone:`LowerArmL`,type:`rotation`},armR:{bone:`UpperArmR`,type:`rotation`},foreR:{bone:`LowerArmR`,type:`rotation`},legL:{bone:`UpperLegL`,type:`rotation`},calfL:{bone:`LowerLegL`,type:`rotation`},footL:{bone:`FootL`,type:`rotation`},legR:{bone:`UpperLegR`,type:`rotation`},calfR:{bone:`LowerLegR`,type:`rotation`},footR:{bone:`FootR`,type:`rotation`}}),lF=Object.freeze({ronin:{spineScale:[1,1,1],armScale:[1,1,1],legScale:[1,1,1],headScale:[1,1,1]},brute:{spineScale:[1.25,1.05,1.15],armScale:[1.15,1.1,1.1],legScale:[1.1,1,1.1],headScale:[.95,.95,.95]},monk:{spineScale:[.9,1,.9],armScale:[1.1,1.05,1.05],legScale:[1.15,1,1.05],headScale:[1,1,1]},assassin:{spineScale:[.85,1.05,.85],armScale:[1.05,1.1,1],legScale:[1.1,1.15,1],headScale:[.95,1,.95]}});function uF(e,t,n,r){return e+(t-e)*(1-Math.exp(-n*r))}function dF(e,t,n){return Math.max(t,Math.min(n,e))}var fF=.35,pF=.05,mF=.12,hF=new Set([`idle`,`walk`]),gF=new Set([`fall`,`knockdown`,`thrown`]),_F=new Set([`uppercut`,`roundhouse`,`getup`]),vF={idle:[`idle`,`Idle`,`Standing`],walk:[`walk`,`Walk`,`Walking`,`run`,`Running`]},yF={jab:.42,cross:.62,low_kick:.5,roundhouse:.9,uppercut:.86,parry:.28,clinch:.45,throw:.78};function bF(e){let t=e?.stats||{},n=t.strength??t.power??60,r=t.speed??60,i=t.defense??55,a=e?.physics?.weight||dF(.72+n/180+i/260-r/420,.7,1.45);return{mass:a,response:dF(15/a,8,22),lean:dF(1.35/a,.82,1.55),followThrough:dF(.74+n/180,.82,1.32),footWidth:dF((e?.bodyScale||1)*.18,.14,.24)}}function xF(e,t){return e.find(e=>t.some(t=>e.name===t))}function SF(e){if(!e)return null;let t=e.tracks.map(e=>{if(!(e.ValueTypeName===`vector`&&e.name.endsWith(`.position`)&&/(mixamorigHips|Hips|Bone|Body)\.position$/.test(e.name)))return e;let t=e.values.slice();for(let e=0;e0?0:Math.PI))*.08*c,m=dF(d*.012,0,.12);return wF(n,`torso`,[o+r+s*.16+f,a+s*.18,i]),wF(n,`head`,[-r*.35-o*.22,p-a*.18,-i*.35]),wF(n,`armL`,[s*.04,0,m-i*.22]),wF(n,`armR`,[s*.04,0,-m-i*.22]),wF(n,`foreL`,[-s*.035,0,0]),wF(n,`foreR`,[-s*.035,0,0]),wF(n,`legL`,[Math.max(0,-r)*.12,0,i*.12]),wF(n,`legR`,[Math.max(0,-r)*.12,0,i*.12]),wF(n,`footL`,[-r*.12,0,i*.08]),wF(n,`footR`,[-r*.12,0,i*.08]),n}function kF(e,t){return t?{url:`/models/characters/xbot.glb`,boneMap:oF,restCorrection:sF}:{url:`/models/characters/robot_expressive.glb`,boneMap:cF,restCorrection:null}}function AF(e,t){if(!e)return;let n=lF[t]||lF.ronin;e.userData||={},e.userData.fighterScales=n;for(let[t,r]of Object.entries({spineScale:[`mixamorigSpine`,`mixamorigSpine1`,`mixamorigSpine2`,`Body`,`Abdomen`,`Torso_1`],armScale:[`mixamorigLeftArm`,`mixamorigLeftForeArm`,`mixamorigRightArm`,`mixamorigRightForeArm`,`UpperArmL`,`LowerArmL`,`UpperArmR`,`LowerArmR`],legScale:[`mixamorigLeftUpLeg`,`mixamorigLeftLeg`,`mixamorigRightUpLeg`,`mixamorigRightLeg`,`UpperLegL`,`LowerLegL`,`UpperLegR`,`LowerLegR`],headScale:[`mixamorigHead`,`Head`]})){let i=n[t];if(i)for(let t of r){let n=e.getObjectByName(t);n&&n.scale.set(i[0],i[1],i[2])}}}function jF({stateRef:e,character:t,isPlayer:n=!0,onFootstep:r,onBackstepLanding:i}){let a=(0,b.useRef)(),o=(0,b.useRef)(),s=(0,b.useRef)({}),c=(0,b.useRef)(null),l=(0,b.useRef)(0),u=(0,b.useRef)(0),d=(0,b.useRef)(0),f=(0,b.useRef)(0),p=(0,b.useRef)(0),m=(0,b.useRef)(new G),h=(0,b.useRef)(0),g=(0,b.useRef)(0),_=(0,b.useRef)(0),v=(0,b.useRef)(0),y=(0,b.useRef)(null),x=(0,b.useRef)({}),S=(0,b.useRef)({}),C=(0,b.useMemo)(()=>kF(t,n),[t,n]),w=Kj(C.url),T=(0,b.useMemo)(()=>bF(t),[t]),E=(0,b.useMemo)(()=>NP(w.scene),[w]);return(0,b.useEffect)(()=>{if(!E||!w.animations?.length)return;let e=new Ud(E),t={},n={};for(let[r,i]of Object.entries(vF)){let a=xF(w.animations,i);if(!a)continue;let o=SF(a),s=e.clipAction(o);s.setLoop(at,1/0),s.enabled=!0,s.clampWhenFinished=!1,s.play(),s.setEffectiveWeight(+(r===`idle`)),t[r]=s,n[r]=+(r===`idle`)}return y.current=e,x.current=t,S.current=n,()=>{e.stopAllAction(),e.uncacheRoot(E),y.current=null,x.current={},S.current={}}},[E,w.animations]),(0,b.useEffect)(()=>{if(!E)return;let e=null;E.traverse(t=>{t.isBone&&!e&&(e=t)}),e||E.traverse(t=>{!e&&(t.isObject3D||t.isBone)&&t.parent&&t.parent.isBone&&(e=t)}),c.current=e;let r={};E.traverse(e=>{(e.isBone||e.name)&&(r[e.name]=e)}),s.current=r,C.restCorrection&&E.traverse(e=>{let t=C.restCorrection[e.name];t&&e.isBone&&(e.rotation.set(t.rotation[0],t.rotation[1],t.rotation[2]),e.updateMatrix(),e.matrixAutoUpdate=!0)});let i=t?.fighterId||(t?.id===`champion`?`brute`:t?.id)||`ronin`;AF(e,i);let a=t&&t.accentColor?new K(t.accentColor):new K(4473924);E.traverse(e=>{if(!e.isMesh)return;e.castShadow=!0,e.receiveShadow=!0;let t=(Array.isArray(e.material)?e.material:[e.material]).map(e=>{if(!e)return e;let t=new Tl({color:16777215,map:e.map||null,normalMap:e.normalMap||null,roughnessMap:e.roughnessMap||null,metalnessMap:e.metalnessMap||null,roughness:.62,metalness:.08,emissive:a,emissiveIntensity:.08,envMapIntensity:1});return(e.transparent||e.alphaMap!==void 0&&e.alphaMap)&&(t.transparent=!0,t.alphaTest=e.alphaTest||0,t.alphaMap=e.alphaMap||null),t});e.material=t.length===1?t[0]:t}),n||NF(E)},[E,t,n,C]),P_((b,w)=>{try{let b=e.current;if(!b||!a.current||!o.current)return;let D=Math.min(w||.016,.05),O=b.position?.[0]||0,k=b.position?.[1]||0,A=b.position?.[2]||0;a.current.position.set(O,k,A);let j=m.current,ee=D>0?(O-j.x)/D:0,te=D>0?(A-j.z)/D:0,M=Number.isFinite(b.velX)?b.velX:ee,N=Number.isFinite(b.velZ)?b.velZ:te,P=Math.sqrt(M*M+N*N);j.set(O,k,A);let F=b.facing>0?1:-1,ne=t&&t.bodyScale||1,re=dF(P*.012+(b.isHit?.08:0),0,.14);v.current=uF(v.current,re,12,D),o.current.scale.x=uF(o.current.scale.x,F*ne*(1+v.current*.1),14,D),o.current.scale.y=uF(o.current.scale.y,ne*(1-v.current*.08),9,D),o.current.scale.z=uF(o.current.scale.z,ne*(1+v.current*.06),9,D);let ie=b.anim||`idle`,I=b.animProgress||0,ae=x.current,L=S.current,oe=ie===`walk`&&ae.walk?`walk`:`idle`,se=hF.has(ie)?1:.12;for(let[e,t]of Object.entries(ae)){let n=e===oe?se:0,r=uF(L[e]??0,n,9,D);L[e]=r,t.enabled=r>.001,t.setEffectiveWeight(r),e===`walk`&&(t.timeScale=dF(.75+P*.16,.75,1.65)),e===`idle`&&(t.timeScale=dF(.88+(T.mass-1)*.1,.82,1.08))}y.current&&y.current.update(D);let ce=M*(b.facing||1),le=dF(-ce*.045*T.lean,-.28,.24),ue=dF(-N*.04,-.18,.18),de=dF(ce*.025+TF(ie,I)*.16,-.28,.32);h.current=uF(h.current,le,T.response,D),g.current=uF(g.current,ue,T.response*.8,D),_.current=uF(_.current,de,T.response*.75,D),b.attackerPushbackTilt>0&&(b.attackerPushbackTilt=Math.max(0,b.attackerPushbackTilt-.2*D/.15)),b.knockbackTilt>0&&(b.knockbackTilt=Math.max(0,b.knockbackTilt-.25*D/.15));let fe=(b.attackerPushbackTilt||0)-(b.knockbackTilt||0);o.current.rotation.x=uF(o.current.rotation.x,fe*.3+h.current*.22,12,D),o.current.rotation.z=uF(o.current.rotation.z,g.current*.18,10,D);let pe=b.isHit?1.6:.08;E.traverse(e=>{e.isMesh&&(Array.isArray(e.material)?e.material:[e.material]).forEach(e=>{!e||!e.emissive||(e.emissiveIntensity=uF(e.emissiveIntensity??.08,pe,18,D))})});let me=performance.now()/1e3,he=GP(ie,I),ge=LP(me),_e={};for(let e of Object.keys(ge))e===`hipY`?_e[e]=ge[e]+(he.pose[e]||0):_e[e]=IP(ge[e],he.pose[e]);let ve=OF(F>0?_e:RP(_e),{lean:h.current,sway:g.current,twist:_.current,impactTilt:fe,strike:TF(ie,I)*T.followThrough,idleWeight:+(ie===`idle`),time:me,facing:F,speed:P});MF(ve,C.boneMap,s.current,c.current,D,EF(ie));let ye=he.rootOffset||[0,0,0],be=(F>0?ye[0]:-ye[0])*.62,xe=DF(ie,ve.hipY)+(ye[1]||0)*.35,Se=(ye[2]||0)*.62;if(o.current.position.x=uF(o.current.position.x,be,13,D),o.current.position.y=uF(o.current.position.y,xe,10,D),o.current.position.z=uF(o.current.position.z,Se,13,D),ie===`walk`){let e=Math.sin((I||0)*Math.PI*2),t=u.current;t>0&&e<=0?r?.([O-T.footWidth*F,.05,A],{intensity:1,type:`walk`}):t<0&&e>=0&&r?.([O+T.footWidth*F,.05,A],{intensity:1,type:`walk`}),u.current=e}else u.current=0;ie===`backstep`&&b.stateTimer>0&&b.stateTimer=.06&&(d.current=0,r?.([O,.05,A],{intensity:.6,type:`slide`}))):d.current=0,ie===`backstep`&&f.current>=mF&&(b.stateTimer||0)=.65&&r?.([O,.05,A],{intensity:1.4,type:`landing`}),p.current=I):p.current=0,l.current=I,rF(+!n,O,k,A)}catch{}}),(0,X.jsx)(`group`,{ref:a,children:(0,X.jsx)(`group`,{ref:o,children:(0,X.jsx)(`primitive`,{object:E})})})}function MF(e,t,n,r,i,a=1){for(let[r,o]of Object.entries(t)){let t=n[o.bone];if(!t)continue;let s=e[r];if(o.type===`positionY`){let e=s,n=t.position.y+(e-t.position.y)*a;t.position.y=uF(t.position.y,n,10,i)}else if(o.type===`rotation`){if(!Array.isArray(s))continue;let e=s[0]||0,n=s[1]||0,r=s[2]||0,o=t.rotation.x+(e-t.rotation.x)*a,c=t.rotation.y+(n-t.rotation.y)*a,l=t.rotation.z+(r-t.rotation.z)*a;t.rotation.x=uF(t.rotation.x,o,18,i),t.rotation.y=uF(t.rotation.y,c,18,i),t.rotation.z=uF(t.rotation.z,l,18,i)}}}function NF(e){let t=new K(1312009),n=new K(12845082);e.traverse(e=>{if(!e.isMesh)return;let r=(Array.isArray(e.material)?e.material:[e.material]).map(e=>{if(!e)return e;let r=new Tl({color:t,emissive:n,emissiveIntensity:.35,roughness:.35,metalness:.55,flatShading:!1});return e.map&&(r.map=e.map),e.normalMap&&(r.normalMap=e.normalMap),r});e.material=r.length===1?r[0]:r,e.castShadow=!0});let r=e.getObjectByName(`Bone_Head`)||e.getObjectByName(`mixamorigHead`)||e.getObjectByName(`Head`)||null,i=new Os(.05,.18,6),a=new Tl({color:655876,emissive:9043984,emissiveIntensity:.6,roughness:.4,metalness:.7}),o=new Va(i,a);o.position.set(-.08,.12,0),o.rotation.z=.3;let s=new Va(i,a);if(s.position.set(.08,.12,0),s.rotation.z=-.3,r)r.add(o),r.add(s);else{let t=new Fr;t.position.set(0,1.6,0),t.add(o),t.add(s),e.add(t)}let c=new Iu(16721216,.7,2.5,2);if(c.position.set(0,.05,.05),r)r.add(c);else{let t=new Fr;t.position.set(0,1.6,0),t.add(c),e.add(t)}}function PF({playerRef:e,npcRef:t,gameRef:n}){let r=(0,b.useRef)(),i=(0,b.useRef)(null),a=(0,b.useRef)(3.2),{width:o,height:s}=N_(e=>e.size),c=(0,b.useMemo)(()=>{let e=7*(s>0?o/s:1);return[-e/2,e/2,7/2,-7/2,.1,100]},[o,s]);return P_(o=>{let s=r.current;if(!s)return;let c=e.current.position,l=t.current.position,u=n.current,d=(c[0]+l[0])/2,f=Math.abs(c[0]-l[0]);i.current===null&&(i.current=d),i.current+=(d-i.current)*.08;let p=i.current,m=e.current.anim,h=t.current.anim,g=new Set([`clinch`,`getup`,`knockdown`]),_=new Set([`uppercut`]),v=new Set([`knockdown`,`fall`]),y=3.2;(g.has(m)||g.has(h))&&(y-=.3),(_.has(m)||_.has(h))&&(y+=.3),(v.has(m)||v.has(h))&&(y-=.5);let b=o.clock.elapsedTime;m===`knockdown`||m===`fall`||h===`knockdown`||h===`fall`||(y+=Math.sin(b*.5)*.02),a.current+=(y-a.current)*.06;let x=a.current,S=Math.min(c[0],l[0])<=-13,C=Math.max(c[0],l[0])>=13,w=S||C,T=Fn.clamp(5/(f+3),.35,1.1);w&&(T*=1.08),s.zoom+=(T-s.zoom)*.05,u.camZoomPulse&&(u.camZoomPulse*=.88,u.camZoomPulse<.001&&(u.camZoomPulse=0),s.zoom*=1-u.camZoomPulse),u.camRecoil||={x:0,y:0,intensity:0};let E=u.camRecoil,D=.12;E.x+=(0-E.x)*D,E.y+=(0-E.y)*D,E.intensity+=(0-E.intensity)*D;let O=0,k=0,A=0;if(u.screenShake>0){let e=u.screenShake*(1+Math.random()*.5);O=(Math.random()-.5)*e,k=(Math.random()-.5)*e*.5,A=(Math.random()-.5)*e*.3,u.screenShake*=.82,u.screenShake<.02&&(u.screenShake=0)}let j=E.x*E.intensity,ee=E.y*E.intensity;u.camRoll===void 0&&(u.camRoll=0),s.rotation.z+=(u.camRoll-s.rotation.z)*.1,u.camRoll*=.92,Math.abs(u.camRoll)<.001&&(u.camRoll=0),s.position.set(p+O+j,x+k+ee,12+A),s.lookAt(p,1.4,0),s.updateProjectionMatrix()}),(0,X.jsx)(`orthographicCamera`,{ref:r,makeDefault:!0,position:[0,3.2,12],args:c,zoom:.7})}var FF=(()=>{let e=new Float32Array([-1,-1,0,3,-1,0,-1,3,0]),t=new Float32Array([0,0,2,0,0,2]),n=new Xi;return n.setAttribute(`position`,new Ai(e,3)),n.setAttribute(`uv`,new Ai(t,2)),n})(),IF=class e{static get fullscreenGeometry(){return FF}constructor(e=`Pass`,t=new Kr,n=new Lu){this.name=e,this.renderer=null,this.scene=t,this.camera=n,this.screen=null,this.rtt=!0,this.needsSwap=!0,this.needsDepthBlit=!1,this.needsDepthTexture=!1,this.enabled=!0}get renderToScreen(){return!this.rtt}set renderToScreen(e){if(this.rtt===e){let t=this.fullscreenMaterial;t!==null&&(t.needsUpdate=!0),this.rtt=!e}}set mainScene(e){}set mainCamera(e){}setRenderer(e){this.renderer=e}isEnabled(){return this.enabled}setEnabled(e){this.enabled=e}get fullscreenMaterial(){return this.screen===null?null:this.screen.material}set fullscreenMaterial(t){let n=this.screen;n===null?(n=new Va(e.fullscreenGeometry,t),n.frustumCulled=!1,this.scene===null&&(this.scene=new Kr),this.scene.add(n),this.screen=n):n.material=t}getFullscreenMaterial(){return this.fullscreenMaterial}setFullscreenMaterial(e){this.fullscreenMaterial=e}getDepthTexture(){return null}setDepthTexture(e,t=gt){}render(e,t,n,r,i){throw Error(`Render method not implemented!`)}setSize(e,t){}initialize(e,t,n){}dispose(){for(let t of Object.keys(this)){let n=this[t];(n instanceof rr||n instanceof ta||n instanceof er||n instanceof e)&&this[t].dispose()}this.fullscreenMaterial!==null&&this.fullscreenMaterial.dispose()}},LF=class extends IF{constructor(){super(`ClearMaskPass`,null,null),this.needsSwap=!1}render(e,t,n,r,i){let a=e.state.buffers.stencil;a.setLocked(!1),a.setTest(!1)}},RF=`#ifdef COLOR_WRITE #include #include #ifdef FRAMEBUFFER_PRECISION_HIGH uniform mediump sampler2D inputBuffer; #else uniform lowp sampler2D inputBuffer; #endif #endif #ifdef DEPTH_WRITE #include #ifdef GL_FRAGMENT_PRECISION_HIGH uniform highp sampler2D depthBuffer; #else uniform mediump sampler2D depthBuffer; #endif float readDepth(const in vec2 uv){ #if DEPTH_PACKING == 3201 return unpackRGBAToDepth(texture2D(depthBuffer,uv)); #else return texture2D(depthBuffer,uv).r; #endif } #endif #ifdef USE_WEIGHTS uniform vec4 channelWeights; #endif uniform float opacity;varying vec2 vUv;void main(){ #ifdef COLOR_WRITE vec4 texel=texture2D(inputBuffer,vUv); #ifdef USE_WEIGHTS texel*=channelWeights; #endif gl_FragColor=opacity*texel; #ifdef COLOR_SPACE_CONVERSION #include #endif #include #else gl_FragColor=vec4(0.0); #endif #ifdef DEPTH_WRITE gl_FragDepth=readDepth(vUv); #endif }`,zF=`varying vec2 vUv;void main(){vUv=position.xy*0.5+0.5;gl_Position=vec4(position.xy,1.0,1.0);}`,BF=class extends Cl{constructor(){super({name:`CopyMaterial`,defines:{COLOR_SPACE_CONVERSION:`1`,DEPTH_PACKING:`0`,COLOR_WRITE:`1`},uniforms:{inputBuffer:new J(null),depthBuffer:new J(null),channelWeights:new J(null),opacity:new J(1)},blending:0,toneMapped:!1,depthWrite:!1,depthTest:!1,fragmentShader:RF,vertexShader:zF}),this.depthFunc=1}get inputBuffer(){return this.uniforms.inputBuffer.value}set inputBuffer(e){let t=e!==null;this.colorWrite!==t&&(t?this.defines.COLOR_WRITE=!0:delete this.defines.COLOR_WRITE,this.colorWrite=t,this.needsUpdate=!0),this.uniforms.inputBuffer.value=e}get depthBuffer(){return this.uniforms.depthBuffer.value}set depthBuffer(e){let t=e!==null;this.depthWrite!==t&&(t?this.defines.DEPTH_WRITE=!0:delete this.defines.DEPTH_WRITE,this.depthTest=t,this.depthWrite=t,this.needsUpdate=!0),this.uniforms.depthBuffer.value=e}set depthPacking(e){this.defines.DEPTH_PACKING=e.toFixed(0),this.needsUpdate=!0}get colorSpaceConversion(){return this.defines.COLOR_SPACE_CONVERSION!==void 0}set colorSpaceConversion(e){this.colorSpaceConversion!==e&&(e?this.defines.COLOR_SPACE_CONVERSION=!0:delete this.defines.COLOR_SPACE_CONVERSION,this.needsUpdate=!0)}get channelWeights(){return this.uniforms.channelWeights.value}set channelWeights(e){e===null?delete this.defines.USE_WEIGHTS:(this.defines.USE_WEIGHTS=`1`,this.uniforms.channelWeights.value=e),this.needsUpdate=!0}setInputBuffer(e){this.uniforms.inputBuffer.value=e}getOpacity(e){return this.uniforms.opacity.value}setOpacity(e){this.uniforms.opacity.value=e}},VF=class extends IF{constructor(e,t=!0){super(`CopyPass`),this.fullscreenMaterial=new BF,this.needsSwap=!1,this.renderTarget=e,e===void 0&&(this.renderTarget=new rr(1,1,{minFilter:M,magFilter:M,stencilBuffer:!1,depthBuffer:!1}),this.renderTarget.texture.name=`CopyPass.Target`),this.autoResize=t}get resize(){return this.autoResize}set resize(e){this.autoResize=e}get texture(){return this.renderTarget.texture}getTexture(){return this.renderTarget.texture}setAutoResizeEnabled(e){this.autoResize=e}render(e,t,n,r,i){this.fullscreenMaterial.inputBuffer=t.texture,e.setRenderTarget(this.renderToScreen?null:this.renderTarget),e.render(this.scene,this.camera)}setSize(e,t){this.autoResize&&this.renderTarget.setSize(e,t)}initialize(e,t,n){n!==void 0&&(this.renderTarget.texture.type=n,n===1009?e!==null&&e.outputColorSpace===`srgb`&&(this.renderTarget.texture.colorSpace=bt):this.fullscreenMaterial.defines.FRAMEBUFFER_PRECISION_HIGH=`1`)}},HF=new K,UF=class extends IF{constructor(e=!0,t=!0,n=!1){super(`ClearPass`,null,null),this.needsSwap=!1,this.color=e,this.depth=t,this.stencil=n,this.overrideClearColor=null,this.overrideClearAlpha=-1}setClearFlags(e,t,n){this.color=e,this.depth=t,this.stencil=n}getOverrideClearColor(){return this.overrideClearColor}setOverrideClearColor(e){this.overrideClearColor=e}getOverrideClearAlpha(){return this.overrideClearAlpha}setOverrideClearAlpha(e){this.overrideClearAlpha=e}render(e,t,n,r,i){let a=this.overrideClearColor,o=this.overrideClearAlpha,s=e.getClearAlpha(),c=a!==null,l=o>=0;c?(e.getClearColor(HF),e.setClearColor(a,l?o:s)):l&&e.setClearAlpha(o),e.setRenderTarget(this.renderToScreen?null:t),e.clear(this.color,this.depth,this.stencil),c?e.setClearColor(HF,s):l&&e.setClearAlpha(s)}},WF=class extends IF{constructor(e,t){super(`MaskPass`,e,t),this.needsSwap=!1,this.clearPass=new UF(!1,!1,!0),this.inverse=!1}set mainScene(e){this.scene=e}set mainCamera(e){this.camera=e}get inverted(){return this.inverse}set inverted(e){this.inverse=e}get clear(){return this.clearPass.enabled}set clear(e){this.clearPass.enabled=e}getClearPass(){return this.clearPass}isInverted(){return this.inverted}setInverted(e){this.inverted=e}render(e,t,n,r,i){let a=e.getContext(),o=e.state.buffers,s=this.scene,c=this.camera,l=this.clearPass,u=+!this.inverted,d=1-u;o.color.setMask(!1),o.depth.setMask(!1),o.color.setLocked(!0),o.depth.setLocked(!0),o.stencil.setTest(!0),o.stencil.setOp(a.REPLACE,a.REPLACE,a.REPLACE),o.stencil.setFunc(a.ALWAYS,u,4294967295),o.stencil.setClear(d),o.stencil.setLocked(!0),this.clearPass.enabled&&(this.renderToScreen?l.render(e,null):(l.render(e,t),l.render(e,n))),this.renderToScreen?(e.setRenderTarget(null),e.render(s,c)):(e.setRenderTarget(t),e.render(s,c),e.setRenderTarget(n),e.render(s,c)),o.color.setLocked(!1),o.depth.setLocked(!1),o.stencil.setLocked(!1),o.stencil.setFunc(a.EQUAL,1,4294967295),o.stencil.setOp(a.KEEP,a.KEEP,a.KEEP),o.stencil.setLocked(!0)}},GF=1/1e3,KF=1e3,qF=class{constructor(){this.startTime=performance.now(),this.previousTime=0,this.currentTime=0,this._delta=0,this._elapsed=0,this._fixedDelta=1e3/60,this.timescale=1,this.useFixedDelta=!1,this._autoReset=!1}get autoReset(){return this._autoReset}set autoReset(e){typeof document<`u`&&document.hidden!==void 0&&(e?document.addEventListener(`visibilitychange`,this):document.removeEventListener(`visibilitychange`,this),this._autoReset=e)}get delta(){return this._delta*GF}get fixedDelta(){return this._fixedDelta*GF}set fixedDelta(e){this._fixedDelta=e*KF}get elapsed(){return this._elapsed*GF}update(e){this.useFixedDelta?this._delta=this.fixedDelta:(this.previousTime=this.currentTime,this.currentTime=(e===void 0?performance.now():e)-this.startTime,this._delta=this.currentTime-this.previousTime),this._delta*=this.timescale,this._elapsed+=this._delta}reset(){this._delta=0,this._elapsed=0,this.currentTime=performance.now()-this.startTime}getDelta(){return this.delta}getElapsed(){return this.elapsed}handleEvent(e){document.hidden||(this.currentTime=performance.now()-this.startTime)}dispose(){this.autoReset=!1}},JF=class{constructor(e=null,{depthBuffer:t=!0,stencilBuffer:n=!1,multisampling:r=0,frameBufferType:i}={}){this.renderer=null,this.inputBuffer=this.createBuffer(t,n,i,r),this.outputBuffer=this.inputBuffer.clone(),this.copyPass=new VF,this.depthTexture=null,this.depthRenderTarget=null,this.passes=[],this.timer=new qF,this.autoRenderToScreen=!0,this.setRenderer(e)}get multisampling(){return this.inputBuffer.samples}set multisampling(e){let t=this.inputBuffer,n=this.multisampling;n>0&&e>0?(this.inputBuffer.samples=e,this.outputBuffer.samples=e,this.inputBuffer.dispose(),this.outputBuffer.dispose()):n!==e&&(this.inputBuffer.dispose(),this.outputBuffer.dispose(),this.inputBuffer=this.createBuffer(t.depthBuffer,t.stencilBuffer,t.texture.type,e),this.outputBuffer=this.inputBuffer.clone())}getTimer(){return this.timer}getRenderer(){return this.renderer}setRenderer(e){if(this.renderer=e,e!==null){let t=e.getSize(new W),n=e.getContext().getContextAttributes().alpha,r=this.inputBuffer.texture.type;r===1009&&e.outputColorSpace===`srgb`&&(this.inputBuffer.texture.colorSpace=bt,this.outputBuffer.texture.colorSpace=bt,this.inputBuffer.dispose(),this.outputBuffer.dispose()),e.autoClear=!1,this.setSize(t.width,t.height);for(let t of this.passes)t.initialize(e,n,r)}}replaceRenderer(e,t=!0){let n=this.renderer,r=n.domElement.parentNode;return this.setRenderer(e),t&&r!==null&&(r.removeChild(n.domElement),r.appendChild(e.domElement)),n}createDepthTexture(){let e=this.inputBuffer,t=new xs;this.depthTexture=t,e.stencilBuffer?(t.format=ve,t.type=de):t.type=se;let n=t.clone();return n.name=`EffectComposer.StableDepth`,this.depthRenderTarget=new rr(e.width,e.height,{depthBuffer:!0,stencilBuffer:e.stencilBuffer,depthTexture:n}),n}blitDepthBuffer(e){let t=this.renderer,n=this.depthRenderTarget,r=t.properties,i=t.getContext();t.setRenderTarget(n);let a=r.get(e).__webglFramebuffer,o=r.get(n).__webglFramebuffer,s=e.stencilBuffer?i.DEPTH_BUFFER_BIT|i.STENCIL_BUFFER_BIT:i.DEPTH_BUFFER_BIT;i.bindFramebuffer(i.READ_FRAMEBUFFER,a),i.bindFramebuffer(i.DRAW_FRAMEBUFFER,o),i.blitFramebuffer(0,0,e.width,e.height,0,0,n.width,n.height,s,i.NEAREST),i.bindFramebuffer(i.READ_FRAMEBUFFER,null),i.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),t.setRenderTarget(null)}deleteDepthTexture(){if(this.depthTexture!==null){this.depthTexture.dispose(),this.depthTexture=null,this.depthRenderTarget.dispose(),this.depthRenderTarget=null,this.inputBuffer.depthTexture=null,this.outputBuffer.depthTexture=null;for(let e of this.passes)e.setDepthTexture(null)}}createBuffer(e,t,n,r){let i=this.renderer,a=i===null?new W:i.getDrawingBufferSize(new W),o={minFilter:M,magFilter:M,stencilBuffer:t,depthBuffer:e,type:n},s=new rr(a.width,a.height,o);return r>0&&(s.samples=r),n===1009&&i!==null&&i.outputColorSpace===`srgb`&&(s.texture.colorSpace=bt),s.texture.name=`EffectComposer.Buffer`,s.texture.generateMipmaps=!1,s}setMainScene(e){for(let t of this.passes)t.mainScene=e}setMainCamera(e){for(let t of this.passes)t.mainCamera=e}addPass(e,t){let n=this.passes,r=this.renderer,i=r.getDrawingBufferSize(new W),a=r.getContext().getContextAttributes().alpha,o=this.inputBuffer.texture.type;if(e.renderer=r,e.setSize(i.width,i.height),e.initialize(r,a,o),this.autoRenderToScreen&&(n.length>0&&(n[n.length-1].renderToScreen=!1),e.renderToScreen&&(this.autoRenderToScreen=!1)),t===void 0?n.push(e):n.splice(t,0,e),this.autoRenderToScreen&&(n[n.length-1].renderToScreen=!0),e.needsDepthTexture||this.depthTexture!==null)if(this.depthTexture===null){let t=this.createDepthTexture();for(e of n)e.setDepthTexture(t)}else{let t=this.depthRenderTarget.depthTexture;e.setDepthTexture(t)}}removePass(e){let t=this.passes,n=t.indexOf(e);if(n!==-1&&t.splice(n,1).length>0){if(this.depthTexture!==null&&!t.reduce((e,t)=>e||t.needsDepthTexture,!1)){let t=this.depthRenderTarget.depthTexture;e.getDepthTexture()===t&&e.setDepthTexture(null),this.deleteDepthTexture()}this.autoRenderToScreen&&n===t.length&&(e.renderToScreen=!1,t.length>0&&(t[t.length-1].renderToScreen=!0))}}removeAllPasses(){let e=this.passes;this.deleteDepthTexture(),e.length>0&&(this.autoRenderToScreen&&(e[e.length-1].renderToScreen=!1),this.passes=[])}render(e){let t=this.renderer,n=this.copyPass,r=this.inputBuffer,i=this.outputBuffer,a,o=!1;e===void 0&&(this.timer.update(),e=this.timer.getDelta());for(let s of this.passes)if(s.enabled){if(r.depthTexture=this.depthTexture,i.depthTexture=null,s.render(t,r,i,e,o),s.needsDepthBlit&&this.depthRenderTarget!==null&&this.blitDepthBuffer(r),s.needsSwap){if(o){n.renderToScreen=s.renderToScreen;let a=t.getContext(),c=t.state.buffers.stencil;c.setFunc(a.NOTEQUAL,1,4294967295),n.render(t,r,i,e,o),c.setFunc(a.EQUAL,1,4294967295)}a=r,r=i,i=a}s instanceof WF?o=!0:s instanceof LF&&(o=!1)}}setSize(e,t,n){let r=this.renderer,i=r.getSize(new W);(e===void 0||t===void 0)&&(e=i.width,t=i.height),(i.width!==e||i.height!==t)&&r.setSize(e,t,n);let a=r.getDrawingBufferSize(new W);this.inputBuffer.setSize(a.width,a.height),this.outputBuffer.setSize(a.width,a.height),this.depthRenderTarget!==null&&this.depthRenderTarget.setSize(a.width,a.height);for(let e of this.passes)e.setSize(a.width,a.height)}reset(){this.dispose(),this.autoRenderToScreen=!0}dispose(){for(let e of this.passes)e.dispose();this.passes=[],this.inputBuffer!==null&&this.inputBuffer.dispose(),this.outputBuffer!==null&&this.outputBuffer.dispose(),this.deleteDepthTexture(),this.copyPass.dispose(),this.timer.dispose(),IF.fullscreenGeometry.dispose()}},YF={NONE:0,DEPTH:1,CONVOLUTION:2},XF={FRAGMENT_HEAD:`FRAGMENT_HEAD`,FRAGMENT_MAIN_UV:`FRAGMENT_MAIN_UV`,FRAGMENT_MAIN_IMAGE:`FRAGMENT_MAIN_IMAGE`,VERTEX_HEAD:`VERTEX_HEAD`,VERTEX_MAIN_SUPPORT:`VERTEX_MAIN_SUPPORT`},ZF=class{constructor(){this.shaderParts=new Map([[XF.FRAGMENT_HEAD,null],[XF.FRAGMENT_MAIN_UV,null],[XF.FRAGMENT_MAIN_IMAGE,null],[XF.VERTEX_HEAD,null],[XF.VERTEX_MAIN_SUPPORT,null]]),this.defines=new Map,this.uniforms=new Map,this.blendModes=new Map,this.extensions=new Set,this.attributes=YF.NONE,this.varyings=new Set,this.uvTransformation=!1,this.readDepth=!1,this.colorSpace=xt}},QF=!1,$F=class{constructor(e=null){this.originalMaterials=new Map,this.material=null,this.materials=null,this.materialsBackSide=null,this.materialsDoubleSide=null,this.materialsFlatShaded=null,this.materialsFlatShadedBackSide=null,this.materialsFlatShadedDoubleSide=null,this.setMaterial(e),this.meshCount=0,this.replaceMaterial=e=>{if(e.isMesh){let t;if(e.material.flatShading)switch(e.material.side){case 2:t=this.materialsFlatShadedDoubleSide;break;case 1:t=this.materialsFlatShadedBackSide;break;default:t=this.materialsFlatShaded;break}else switch(e.material.side){case 2:t=this.materialsDoubleSide;break;case 1:t=this.materialsBackSide;break;default:t=this.materials;break}this.originalMaterials.set(e,e.material),e.isSkinnedMesh?e.material=t[2]:e.isInstancedMesh?e.material=t[1]:e.material=t[0],++this.meshCount}}}cloneMaterial(e){if(!(e instanceof Cl))return e.clone();let t=e.uniforms,n=new Map;for(let e in t){let r=t[e].value;r.isRenderTargetTexture&&(t[e].value=null,n.set(e,r))}let r=e.clone();for(let e of n)t[e[0]].value=e[1],r.uniforms[e[0]].value=e[1];return r}setMaterial(e){if(this.disposeMaterials(),this.material=e,e!==null){let t=this.materials=[this.cloneMaterial(e),this.cloneMaterial(e),this.cloneMaterial(e)];for(let n of t)n.uniforms=Object.assign({},e.uniforms),n.side=0;t[2].skinning=!0,this.materialsBackSide=t.map(t=>{let n=this.cloneMaterial(t);return n.uniforms=Object.assign({},e.uniforms),n.side=1,n}),this.materialsDoubleSide=t.map(t=>{let n=this.cloneMaterial(t);return n.uniforms=Object.assign({},e.uniforms),n.side=2,n}),this.materialsFlatShaded=t.map(t=>{let n=this.cloneMaterial(t);return n.uniforms=Object.assign({},e.uniforms),n.flatShading=!0,n}),this.materialsFlatShadedBackSide=t.map(t=>{let n=this.cloneMaterial(t);return n.uniforms=Object.assign({},e.uniforms),n.flatShading=!0,n.side=1,n}),this.materialsFlatShadedDoubleSide=t.map(t=>{let n=this.cloneMaterial(t);return n.uniforms=Object.assign({},e.uniforms),n.flatShading=!0,n.side=2,n})}}render(e,t,n){let r=e.shadowMap.enabled;if(e.shadowMap.enabled=!1,QF){let r=this.originalMaterials;this.meshCount=0,t.traverse(this.replaceMaterial),e.render(t,n);for(let e of r)e[0].material=e[1];this.meshCount!==r.size&&r.clear()}else{let r=t.overrideMaterial;t.overrideMaterial=this.material,e.render(t,n),t.overrideMaterial=r}e.shadowMap.enabled=r}disposeMaterials(){if(this.material!==null){let e=this.materials.concat(this.materialsBackSide).concat(this.materialsDoubleSide).concat(this.materialsFlatShaded).concat(this.materialsFlatShadedBackSide).concat(this.materialsFlatShadedDoubleSide);for(let t of e)t.dispose()}}dispose(){this.originalMaterials.clear(),this.disposeMaterials()}static get workaroundEnabled(){return QF}static set workaroundEnabled(e){QF=e}},eI=-1,tI=class extends ln{constructor(e=null,t=eI,n=eI,r=1){super(),e!==null&&this.addEventListener(`change`,()=>e.setSize(this.baseSize.width,this.baseSize.height)),this.baseSize=new W(1,1),this.preferredSize=new W(t,n),this.target=this.preferredSize,this.s=r,this.effectiveSize=new W,this.addEventListener(`change`,()=>this.updateEffectiveSize()),this.updateEffectiveSize()}updateEffectiveSize(){let e=this.baseSize,t=this.preferredSize,n=this.effectiveSize,r=this.scale;t.width===eI?t.height===eI?n.width=Math.round(e.width*r):n.width=Math.round(t.height*(e.width/Math.max(e.height,1))):n.width=t.width,t.height===eI?t.width===eI?n.height=Math.round(e.height*r):n.height=Math.round(t.width/Math.max(e.width/Math.max(e.height,1),1)):n.height=t.height}get width(){return this.effectiveSize.width}set width(e){this.preferredWidth=e}get height(){return this.effectiveSize.height}set height(e){this.preferredHeight=e}getWidth(){return this.width}getHeight(){return this.height}get scale(){return this.s}set scale(e){this.s!==e&&(this.s=e,this.preferredSize.setScalar(eI),this.dispatchEvent({type:`change`}))}getScale(){return this.scale}setScale(e){this.scale=e}get baseWidth(){return this.baseSize.width}set baseWidth(e){this.baseSize.width!==e&&(this.baseSize.width=e,this.dispatchEvent({type:`change`}))}getBaseWidth(){return this.baseWidth}setBaseWidth(e){this.baseWidth=e}get baseHeight(){return this.baseSize.height}set baseHeight(e){this.baseSize.height!==e&&(this.baseSize.height=e,this.dispatchEvent({type:`change`}))}getBaseHeight(){return this.baseHeight}setBaseHeight(e){this.baseHeight=e}setBaseSize(e,t){(this.baseSize.width!==e||this.baseSize.height!==t)&&(this.baseSize.set(e,t),this.dispatchEvent({type:`change`}))}get preferredWidth(){return this.preferredSize.width}set preferredWidth(e){this.preferredSize.width!==e&&(this.preferredSize.width=e,this.dispatchEvent({type:`change`}))}getPreferredWidth(){return this.preferredWidth}setPreferredWidth(e){this.preferredWidth=e}get preferredHeight(){return this.preferredSize.height}set preferredHeight(e){this.preferredSize.height!==e&&(this.preferredSize.height=e,this.dispatchEvent({type:`change`}))}getPreferredHeight(){return this.preferredHeight}setPreferredHeight(e){this.preferredHeight=e}setPreferredSize(e,t){(this.preferredSize.width!==e||this.preferredSize.height!==t)&&(this.preferredSize.set(e,t),this.dispatchEvent({type:`change`}))}copy(e){this.s=e.scale,this.baseSize.set(e.baseWidth,e.baseHeight),this.preferredSize.set(e.preferredWidth,e.preferredHeight),this.dispatchEvent({type:`change`})}static get AUTO_SIZE(){return eI}},nI={SKIP:9,SET:30,ADD:0,ALPHA:1,AVERAGE:2,COLOR:3,COLOR_BURN:4,COLOR_DODGE:5,DARKEN:6,DIFFERENCE:7,DIVIDE:8,DST:9,EXCLUSION:10,HARD_LIGHT:11,HARD_MIX:12,HUE:13,INVERT:14,INVERT_RGB:15,LIGHTEN:16,LINEAR_BURN:17,LINEAR_DODGE:18,LINEAR_LIGHT:19,LUMINOSITY:20,MULTIPLY:21,NEGATION:22,NORMAL:23,OVERLAY:24,PIN_LIGHT:25,REFLECT:26,SATURATION:27,SCREEN:28,SOFT_LIGHT:29,SRC:30,SUBTRACT:31,VIVID_LIGHT:32},rI=new Map([[nI.ADD,`vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 c=dst.rgb+src.rgb;return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}`],[nI.ALPHA,`vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){return mix(dst,src,src.a*opacity);}`],[nI.AVERAGE,`vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 c=(dst.rgb+src.rgb)*0.5;return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}`],[nI.COLOR,`vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 a=RGBToHSL(dst.rgb);vec3 b=RGBToHSL(src.rgb);vec3 c=HSLToRGB(vec3(b.xy,a.z));return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}`],[nI.COLOR_BURN,`vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 a=dst.rgb,b=src.rgb;vec3 c=mix(step(0.0,b)*(1.0-min(vec3(1.0),(1.0-a)/max(b,1e-9))),vec3(1.0),step(1.0,a));return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}`],[nI.COLOR_DODGE,`vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 a=dst.rgb,b=src.rgb;vec3 c=step(0.0,a)*mix(min(vec3(1.0),a/max(1.0-b,1e-9)),vec3(1.0),step(1.0,b));return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}`],[nI.DARKEN,`vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 c=min(dst.rgb,src.rgb);return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}`],[nI.DIFFERENCE,`vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 c=abs(dst.rgb-src.rgb);return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}`],[nI.DIVIDE,`vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 c=dst.rgb/max(src.rgb,1e-9);return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}`],[nI.DST,null],[nI.EXCLUSION,`vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 c=dst.rgb+src.rgb-2.0*dst.rgb*src.rgb;return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}`],[nI.HARD_LIGHT,`vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 a=min(dst.rgb,1.0);vec3 b=min(src.rgb,1.0);vec3 c=mix(2.0*a*b,1.0-2.0*(1.0-a)*(1.0-b),step(0.5,b));return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}`],[nI.HARD_MIX,`vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 c=step(1.0,dst.rgb+src.rgb);return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}`],[nI.HUE,`vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 a=RGBToHSL(dst.rgb);vec3 b=RGBToHSL(src.rgb);vec3 c=HSLToRGB(vec3(b.x,a.yz));return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}`],[nI.INVERT,`vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 c=max(1.0-src.rgb,0.0);return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}`],[nI.INVERT_RGB,`vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 c=src.rgb*max(1.0-dst.rgb,0.0);return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}`],[nI.LIGHTEN,`vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 c=max(dst.rgb,src.rgb);return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}`],[nI.LINEAR_BURN,`vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 c=clamp(src.rgb+dst.rgb-1.0,0.0,1.0);return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}`],[nI.LINEAR_DODGE,`vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 c=min(dst.rgb+src.rgb,1.0);return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}`],[nI.LINEAR_LIGHT,`vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 c=clamp(2.0*src.rgb+dst.rgb-1.0,0.0,1.0);return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}`],[nI.LUMINOSITY,`vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 a=RGBToHSL(dst.rgb);vec3 b=RGBToHSL(src.rgb);vec3 c=HSLToRGB(vec3(a.xy,b.z));return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}`],[nI.MULTIPLY,`vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 c=dst.rgb*src.rgb;return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}`],[nI.NEGATION,`vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 c=max(1.0-abs(1.0-dst.rgb-src.rgb),0.0);return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}`],[nI.NORMAL,`vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){return mix(dst,src,opacity);}`],[nI.OVERLAY,`vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 a=2.0*src.rgb*dst.rgb;vec3 b=1.0-2.0*(1.0-src.rgb)*(1.0-dst.rgb);vec3 c=mix(a,b,step(0.5,dst.rgb));return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}`],[nI.PIN_LIGHT,`vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 src2=2.0*src.rgb;vec3 c=mix(mix(src2,dst.rgb,step(0.5*dst.rgb,src.rgb)),max(src2-1.0,vec3(0.0)),step(dst.rgb,src2-1.0));return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}`],[nI.REFLECT,`vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 a=min(dst.rgb*dst.rgb/max(1.0-src.rgb,1e-9),1.0);vec3 c=mix(a,src.rgb,step(1.0,src.rgb));return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}`],[nI.SATURATION,`vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 a=RGBToHSL(dst.rgb);vec3 b=RGBToHSL(src.rgb);vec3 c=HSLToRGB(vec3(a.x,b.y,a.z));return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}`],[nI.SCREEN,`vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 c=dst.rgb+src.rgb-min(dst.rgb*src.rgb,1.0);return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}`],[nI.SOFT_LIGHT,`vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 src2=2.0*src.rgb;vec3 d=dst.rgb+(src2-1.0);vec3 w=step(0.5,src.rgb);vec3 a=dst.rgb-(1.0-src2)*dst.rgb*(1.0-dst.rgb);vec3 b=mix(d*(sqrt(dst.rgb)-dst.rgb),d*dst.rgb*((16.0*dst.rgb-12.0)*dst.rgb+3.0),w*(1.0-step(0.25,dst.rgb)));vec3 c=mix(a,b,w);return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}`],[nI.SRC,`vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){return src;}`],[nI.SUBTRACT,`vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 c=max(dst.rgb-src.rgb,0.0);return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}`],[nI.VIVID_LIGHT,`vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 c=mix(max(1.0-min((1.0-dst.rgb)/(2.0*src.rgb),1.0),0.0),min(dst.rgb/(2.0*(1.0-src.rgb)),1.0),step(0.5,src.rgb));return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}`]]),iI=class extends ln{constructor(e,t=1){super(),this._blendFunction=e,this.opacity=new J(t)}getOpacity(){return this.opacity.value}setOpacity(e){this.opacity.value=e}get blendFunction(){return this._blendFunction}set blendFunction(e){this._blendFunction=e,this.dispatchEvent({type:`change`})}getBlendFunction(){return this.blendFunction}setBlendFunction(e){this.blendFunction=e}getShaderCode(){return rI.get(this.blendFunction)}},aI=class extends ln{constructor(e,t,{attributes:n=YF.NONE,blendFunction:r=nI.NORMAL,defines:i=new Map,uniforms:a=new Map,extensions:o=null,vertexShader:s=null}={}){super(),this.name=e,this.renderer=null,this.attributes=n,this.fragmentShader=t,this.vertexShader=s,this.defines=i,this.uniforms=a,this.extensions=o,this.blendMode=new iI(r),this.blendMode.addEventListener(`change`,e=>this.setChanged()),this._inputColorSpace=xt,this._outputColorSpace=``}get inputColorSpace(){return this._inputColorSpace}set inputColorSpace(e){this._inputColorSpace=e,this.setChanged()}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e,this.setChanged()}set mainScene(e){}set mainCamera(e){}getName(){return this.name}setRenderer(e){this.renderer=e}getDefines(){return this.defines}getUniforms(){return this.uniforms}getExtensions(){return this.extensions}getBlendMode(){return this.blendMode}getAttributes(){return this.attributes}setAttributes(e){this.attributes=e,this.setChanged()}getFragmentShader(){return this.fragmentShader}setFragmentShader(e){this.fragmentShader=e,this.setChanged()}getVertexShader(){return this.vertexShader}setVertexShader(e){this.vertexShader=e,this.setChanged()}setChanged(){this.dispatchEvent({type:`change`})}setDepthTexture(e,t=gt){}update(e,t,n){}setSize(e,t){}initialize(e,t,n){}dispose(){for(let e of Object.keys(this)){let t=this[e];(t instanceof rr||t instanceof ta||t instanceof er||t instanceof IF)&&this[e].dispose()}}},oI={VERY_SMALL:0,SMALL:1,MEDIUM:2,LARGE:3,VERY_LARGE:4,HUGE:5},sI=`#ifdef FRAMEBUFFER_PRECISION_HIGH uniform mediump sampler2D inputBuffer; #else uniform lowp sampler2D inputBuffer; #endif varying vec2 vUv0;varying vec2 vUv1;varying vec2 vUv2;varying vec2 vUv3;void main(){vec4 sum=texture2D(inputBuffer,vUv0);sum+=texture2D(inputBuffer,vUv1);sum+=texture2D(inputBuffer,vUv2);sum+=texture2D(inputBuffer,vUv3);gl_FragColor=sum*0.25; #include }`,cI=`uniform vec4 texelSize;uniform float kernel;uniform float scale;varying vec2 vUv0;varying vec2 vUv1;varying vec2 vUv2;varying vec2 vUv3;void main(){vec2 uv=position.xy*0.5+0.5;vec2 dUv=(texelSize.xy*vec2(kernel)+texelSize.zw)*scale;vUv0=vec2(uv.x-dUv.x,uv.y+dUv.y);vUv1=vec2(uv.x+dUv.x,uv.y+dUv.y);vUv2=vec2(uv.x+dUv.x,uv.y-dUv.y);vUv3=vec2(uv.x-dUv.x,uv.y-dUv.y);gl_Position=vec4(position.xy,1.0,1.0);}`,lI=[new Float32Array([0,0]),new Float32Array([0,1,1]),new Float32Array([0,1,1,2]),new Float32Array([0,1,2,2,3]),new Float32Array([0,1,2,3,4,4,5]),new Float32Array([0,1,2,3,4,5,7,8,9,10])],uI=class extends Cl{constructor(e=new tr){super({name:`KawaseBlurMaterial`,uniforms:{inputBuffer:new J(null),texelSize:new J(new tr),scale:new J(1),kernel:new J(0)},blending:0,toneMapped:!1,depthWrite:!1,depthTest:!1,fragmentShader:sI,vertexShader:cI}),this.setTexelSize(e.x,e.y),this.kernelSize=oI.MEDIUM}set inputBuffer(e){this.uniforms.inputBuffer.value=e}setInputBuffer(e){this.inputBuffer=e}get kernelSequence(){return lI[this.kernelSize]}get scale(){return this.uniforms.scale.value}set scale(e){this.uniforms.scale.value=e}getScale(){return this.uniforms.scale.value}setScale(e){this.uniforms.scale.value=e}getKernel(){return null}get kernel(){return this.uniforms.kernel.value}set kernel(e){this.uniforms.kernel.value=e}setKernel(e){this.kernel=e}setTexelSize(e,t){this.uniforms.texelSize.value.set(e,t,e*.5,t*.5)}setSize(e,t){let n=1/e,r=1/t;this.uniforms.texelSize.value.set(n,r,n*.5,r*.5)}},dI=class extends IF{constructor({kernelSize:e=oI.MEDIUM,resolutionScale:t=.5,width:n=tI.AUTO_SIZE,height:r=tI.AUTO_SIZE,resolutionX:i=n,resolutionY:a=r}={}){super(`KawaseBlurPass`),this.renderTargetA=new rr(1,1,{depthBuffer:!1}),this.renderTargetA.texture.name=`Blur.Target.A`,this.renderTargetB=this.renderTargetA.clone(),this.renderTargetB.texture.name=`Blur.Target.B`;let o=this.resolution=new tI(this,i,a,t);o.addEventListener(`change`,e=>this.setSize(o.baseWidth,o.baseHeight)),this._blurMaterial=new uI,this._blurMaterial.kernelSize=e,this.copyMaterial=new BF}getResolution(){return this.resolution}get blurMaterial(){return this._blurMaterial}set blurMaterial(e){this._blurMaterial=e}get dithering(){return this.copyMaterial.dithering}set dithering(e){this.copyMaterial.dithering=e}get kernelSize(){return this.blurMaterial.kernelSize}set kernelSize(e){this.blurMaterial.kernelSize=e}get width(){return this.resolution.width}set width(e){this.resolution.preferredWidth=e}get height(){return this.resolution.height}set height(e){this.resolution.preferredHeight=e}get scale(){return this.blurMaterial.scale}set scale(e){this.blurMaterial.scale=e}getScale(){return this.blurMaterial.scale}setScale(e){this.blurMaterial.scale=e}getKernelSize(){return this.kernelSize}setKernelSize(e){this.kernelSize=e}getResolutionScale(){return this.resolution.scale}setResolutionScale(e){this.resolution.scale=e}render(e,t,n,r,i){let a=this.scene,o=this.camera,s=this.renderTargetA,c=this.renderTargetB,l=this.blurMaterial,u=l.kernelSequence,d=t;this.fullscreenMaterial=l;for(let t=0,n=u.length;t #ifdef FRAMEBUFFER_PRECISION_HIGH uniform mediump sampler2D inputBuffer; #else uniform lowp sampler2D inputBuffer; #endif #ifdef RANGE uniform vec2 range; #elif defined(THRESHOLD) uniform float threshold;uniform float smoothing; #endif varying vec2 vUv;void main(){vec4 texel=texture2D(inputBuffer,vUv);float l=luminance(texel.rgb);float mask=1.0; #ifdef RANGE float low=step(range.x,l);float high=step(l,range.y);mask=low*high; #elif defined(THRESHOLD) mask=smoothstep(threshold,threshold+smoothing,l); #endif #ifdef COLOR gl_FragColor=texel*mask; #else gl_FragColor=vec4(l*mask); #endif }`,pI=class extends Cl{constructor(e=!1,t=null){super({name:`LuminanceMaterial`,defines:{THREE_REVISION:`184`.replace(/\D+/g,``)},uniforms:{inputBuffer:new J(null),threshold:new J(0),smoothing:new J(1),range:new J(null)},blending:0,toneMapped:!1,depthWrite:!1,depthTest:!1,fragmentShader:fI,vertexShader:zF}),this.colorOutput=e,this.luminanceRange=t}set inputBuffer(e){this.uniforms.inputBuffer.value=e}setInputBuffer(e){this.uniforms.inputBuffer.value=e}get threshold(){return this.uniforms.threshold.value}set threshold(e){this.smoothing>0||e>0?this.defines.THRESHOLD=`1`:delete this.defines.THRESHOLD,this.uniforms.threshold.value=e}getThreshold(){return this.threshold}setThreshold(e){this.threshold=e}get smoothing(){return this.uniforms.smoothing.value}set smoothing(e){this.threshold>0||e>0?this.defines.THRESHOLD=`1`:delete this.defines.THRESHOLD,this.uniforms.smoothing.value=e}getSmoothingFactor(){return this.smoothing}setSmoothingFactor(e){this.smoothing=e}get useThreshold(){return this.threshold>0||this.smoothing>0}set useThreshold(e){}get colorOutput(){return this.defines.COLOR!==void 0}set colorOutput(e){e?this.defines.COLOR=`1`:delete this.defines.COLOR,this.needsUpdate=!0}isColorOutputEnabled(e){return this.colorOutput}setColorOutputEnabled(e){this.colorOutput=e}get useRange(){return this.luminanceRange!==null}set useRange(e){this.luminanceRange=null}get luminanceRange(){return this.uniforms.range.value}set luminanceRange(e){e===null?delete this.defines.RANGE:this.defines.RANGE=`1`,this.uniforms.range.value=e,this.needsUpdate=!0}getLuminanceRange(){return this.luminanceRange}setLuminanceRange(e){this.luminanceRange=e}},mI=class extends IF{constructor({renderTarget:e,luminanceRange:t,colorOutput:n,resolutionScale:r=1,width:i=tI.AUTO_SIZE,height:a=tI.AUTO_SIZE,resolutionX:o=i,resolutionY:s=a}={}){super(`LuminancePass`),this.fullscreenMaterial=new pI(n,t),this.needsSwap=!1,this.renderTarget=e,this.renderTarget===void 0&&(this.renderTarget=new rr(1,1,{depthBuffer:!1}),this.renderTarget.texture.name=`LuminancePass.Target`);let c=this.resolution=new tI(this,o,s,r);c.addEventListener(`change`,e=>this.setSize(c.baseWidth,c.baseHeight))}get texture(){return this.renderTarget.texture}getTexture(){return this.renderTarget.texture}getResolution(){return this.resolution}render(e,t,n,r,i){let a=this.fullscreenMaterial;a.inputBuffer=t.texture,e.setRenderTarget(this.renderToScreen?null:this.renderTarget),e.render(this.scene,this.camera)}setSize(e,t){let n=this.resolution;n.setBaseSize(e,t),this.renderTarget.setSize(n.width,n.height)}initialize(e,t,n){n!==void 0&&n!==1009&&(this.renderTarget.texture.type=n,this.fullscreenMaterial.defines.FRAMEBUFFER_PRECISION_HIGH=`1`)}},hI=`#ifdef FRAMEBUFFER_PRECISION_HIGH uniform mediump sampler2D inputBuffer; #else uniform lowp sampler2D inputBuffer; #endif #define WEIGHT_INNER 0.125 #define WEIGHT_OUTER 0.05556 varying vec2 vUv;varying vec2 vUv00;varying vec2 vUv01;varying vec2 vUv02;varying vec2 vUv03;varying vec2 vUv04;varying vec2 vUv05;varying vec2 vUv06;varying vec2 vUv07;varying vec2 vUv08;varying vec2 vUv09;varying vec2 vUv10;varying vec2 vUv11;float clampToBorder(const in vec2 uv){return float(uv.s>=0.0&&uv.s<=1.0&&uv.t>=0.0&&uv.t<=1.0);}void main(){vec4 c=vec4(0.0);vec4 w=WEIGHT_INNER*vec4(clampToBorder(vUv00),clampToBorder(vUv01),clampToBorder(vUv02),clampToBorder(vUv03));c+=w.x*texture2D(inputBuffer,vUv00);c+=w.y*texture2D(inputBuffer,vUv01);c+=w.z*texture2D(inputBuffer,vUv02);c+=w.w*texture2D(inputBuffer,vUv03);w=WEIGHT_OUTER*vec4(clampToBorder(vUv04),clampToBorder(vUv05),clampToBorder(vUv06),clampToBorder(vUv07));c+=w.x*texture2D(inputBuffer,vUv04);c+=w.y*texture2D(inputBuffer,vUv05);c+=w.z*texture2D(inputBuffer,vUv06);c+=w.w*texture2D(inputBuffer,vUv07);w=WEIGHT_OUTER*vec4(clampToBorder(vUv08),clampToBorder(vUv09),clampToBorder(vUv10),clampToBorder(vUv11));c+=w.x*texture2D(inputBuffer,vUv08);c+=w.y*texture2D(inputBuffer,vUv09);c+=w.z*texture2D(inputBuffer,vUv10);c+=w.w*texture2D(inputBuffer,vUv11);c+=WEIGHT_OUTER*texture2D(inputBuffer,vUv);gl_FragColor=c; #include }`,gI=`uniform vec2 texelSize;varying vec2 vUv;varying vec2 vUv00;varying vec2 vUv01;varying vec2 vUv02;varying vec2 vUv03;varying vec2 vUv04;varying vec2 vUv05;varying vec2 vUv06;varying vec2 vUv07;varying vec2 vUv08;varying vec2 vUv09;varying vec2 vUv10;varying vec2 vUv11;void main(){vUv=position.xy*0.5+0.5;vUv00=vUv+texelSize*vec2(-1.0,1.0);vUv01=vUv+texelSize*vec2(1.0,1.0);vUv02=vUv+texelSize*vec2(-1.0,-1.0);vUv03=vUv+texelSize*vec2(1.0,-1.0);vUv04=vUv+texelSize*vec2(-2.0,2.0);vUv05=vUv+texelSize*vec2(0.0,2.0);vUv06=vUv+texelSize*vec2(2.0,2.0);vUv07=vUv+texelSize*vec2(-2.0,0.0);vUv08=vUv+texelSize*vec2(2.0,0.0);vUv09=vUv+texelSize*vec2(-2.0,-2.0);vUv10=vUv+texelSize*vec2(0.0,-2.0);vUv11=vUv+texelSize*vec2(2.0,-2.0);gl_Position=vec4(position.xy,1.0,1.0);}`,_I=class extends Cl{constructor(){super({name:`DownsamplingMaterial`,uniforms:{inputBuffer:new J(null),texelSize:new J(new W)},blending:0,toneMapped:!1,depthWrite:!1,depthTest:!1,fragmentShader:hI,vertexShader:gI})}set inputBuffer(e){this.uniforms.inputBuffer.value=e}setSize(e,t){this.uniforms.texelSize.value.set(1/e,1/t)}},vI=`#ifdef FRAMEBUFFER_PRECISION_HIGH uniform mediump sampler2D inputBuffer;uniform mediump sampler2D supportBuffer; #else uniform lowp sampler2D inputBuffer;uniform lowp sampler2D supportBuffer; #endif uniform float radius;varying vec2 vUv;varying vec2 vUv0;varying vec2 vUv1;varying vec2 vUv2;varying vec2 vUv3;varying vec2 vUv4;varying vec2 vUv5;varying vec2 vUv6;varying vec2 vUv7;void main(){vec4 c=vec4(0.0);c+=texture2D(inputBuffer,vUv0)*0.0625;c+=texture2D(inputBuffer,vUv1)*0.125;c+=texture2D(inputBuffer,vUv2)*0.0625;c+=texture2D(inputBuffer,vUv3)*0.125;c+=texture2D(inputBuffer,vUv)*0.25;c+=texture2D(inputBuffer,vUv4)*0.125;c+=texture2D(inputBuffer,vUv5)*0.0625;c+=texture2D(inputBuffer,vUv6)*0.125;c+=texture2D(inputBuffer,vUv7)*0.0625;vec4 baseColor=texture2D(supportBuffer,vUv);gl_FragColor=mix(baseColor,c,radius); #include }`,yI=`uniform vec2 texelSize;varying vec2 vUv;varying vec2 vUv0;varying vec2 vUv1;varying vec2 vUv2;varying vec2 vUv3;varying vec2 vUv4;varying vec2 vUv5;varying vec2 vUv6;varying vec2 vUv7;void main(){vUv=position.xy*0.5+0.5;vUv0=vUv+texelSize*vec2(-1.0,1.0);vUv1=vUv+texelSize*vec2(0.0,1.0);vUv2=vUv+texelSize*vec2(1.0,1.0);vUv3=vUv+texelSize*vec2(-1.0,0.0);vUv4=vUv+texelSize*vec2(1.0,0.0);vUv5=vUv+texelSize*vec2(-1.0,-1.0);vUv6=vUv+texelSize*vec2(0.0,-1.0);vUv7=vUv+texelSize*vec2(1.0,-1.0);gl_Position=vec4(position.xy,1.0,1.0);}`,bI=class extends Cl{constructor(){super({name:`UpsamplingMaterial`,uniforms:{inputBuffer:new J(null),supportBuffer:new J(null),texelSize:new J(new W),radius:new J(.85)},blending:0,toneMapped:!1,depthWrite:!1,depthTest:!1,fragmentShader:vI,vertexShader:yI})}set inputBuffer(e){this.uniforms.inputBuffer.value=e}set supportBuffer(e){this.uniforms.supportBuffer.value=e}get radius(){return this.uniforms.radius.value}set radius(e){this.uniforms.radius.value=e}setSize(e,t){this.uniforms.texelSize.value.set(1/e,1/t)}},xI=class extends IF{constructor(){super(`MipmapBlurPass`),this.needsSwap=!1,this.renderTarget=new rr(1,1,{depthBuffer:!1}),this.renderTarget.texture.name=`Upsampling.Mipmap0`,this.downsamplingMipmaps=[],this.upsamplingMipmaps=[],this.downsamplingMaterial=new _I,this.upsamplingMaterial=new bI,this.resolution=new W}get texture(){return this.renderTarget.texture}get levels(){return this.downsamplingMipmaps.length}set levels(e){if(this.levels!==e){let t=this.renderTarget;this.dispose(),this.downsamplingMipmaps=[],this.upsamplingMipmaps=[];for(let n=0;n=0;--t){let n=u[t];c.setSize(d.width,d.height),c.inputBuffer=d.texture,c.supportBuffer=l[t].texture,e.setRenderTarget(n),e.render(a,o),d=n}}setSize(e,t){let n=this.resolution;n.set(e,t);let r=n.width,i=n.height;for(let e=0,t=this.downsamplingMipmaps.length;ethis.setSize(p.baseWidth,p.baseHeight))}get texture(){return this.mipmapBlurPass.enabled?this.mipmapBlurPass.texture:this.renderTarget.texture}getTexture(){return this.texture}getResolution(){return this.resolution}getBlurPass(){return this.blurPass}getLuminancePass(){return this.luminancePass}get luminanceMaterial(){return this.luminancePass.fullscreenMaterial}getLuminanceMaterial(){return this.luminancePass.fullscreenMaterial}get width(){return this.resolution.width}set width(e){this.resolution.preferredWidth=e}get height(){return this.resolution.height}set height(e){this.resolution.preferredHeight=e}get dithering(){return this.blurPass.dithering}set dithering(e){this.blurPass.dithering=e}get kernelSize(){return this.blurPass.kernelSize}set kernelSize(e){this.blurPass.kernelSize=e}get distinction(){return console.warn(this.name,`distinction was removed`),1}set distinction(e){console.warn(this.name,`distinction was removed`)}get intensity(){return this.uniforms.get(`intensity`).value}set intensity(e){this.uniforms.get(`intensity`).value=e}getIntensity(){return this.intensity}setIntensity(e){this.intensity=e}getResolutionScale(){return this.resolution.scale}setResolutionScale(e){this.resolution.scale=e}update(e,t,n){let r=this.renderTarget,i=this.luminancePass;i.enabled?(i.render(e,t),this.mipmapBlurPass.enabled?this.mipmapBlurPass.render(e,i.renderTarget):this.blurPass.render(e,i.renderTarget,r)):this.mipmapBlurPass.enabled?this.mipmapBlurPass.render(e,t):this.blurPass.render(e,t,r)}setSize(e,t){let n=this.resolution;n.setBaseSize(e,t),this.renderTarget.setSize(n.width,n.height),this.blurPass.resolution.copy(n),this.luminancePass.setSize(e,t),this.mipmapBlurPass.setSize(e,t)}initialize(e,t,n){this.blurPass.initialize(e,t,n),this.luminancePass.initialize(e,t,n),this.mipmapBlurPass.initialize(e,t,n),n!==void 0&&(this.renderTarget.texture.type=n,e!==null&&e.outputColorSpace===`srgb`&&(this.renderTarget.texture.colorSpace=bt))}},wI=`uniform float brightness;uniform float contrast;void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){vec3 color=inputColor.rgb+vec3(brightness-0.5);if(contrast>0.0){color/=vec3(1.0-contrast);}else{color*=vec3(1.0+contrast);}outputColor=vec4(color+vec3(0.5),inputColor.a);}`,TI=class extends aI{constructor({blendFunction:e=nI.SRC,brightness:t=0,contrast:n=0}={}){super(`BrightnessContrastEffect`,wI,{blendFunction:e,uniforms:new Map([[`brightness`,new J(t)],[`contrast`,new J(n)]])}),this.inputColorSpace=bt}get brightness(){return this.uniforms.get(`brightness`).value}set brightness(e){this.uniforms.get(`brightness`).value=e}getBrightness(){return this.brightness}setBrightness(e){this.brightness=e}get contrast(){return this.uniforms.get(`contrast`).value}set contrast(e){this.uniforms.get(`contrast`).value=e}getContrast(){return this.contrast}setContrast(e){this.contrast=e}},EI=`#ifdef RADIAL_MODULATION uniform float modulationOffset; #endif varying float vActive;varying vec2 vUvR;varying vec2 vUvB;void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){vec2 ra=inputColor.ra;vec2 ba=inputColor.ba; #ifdef RADIAL_MODULATION const vec2 center=vec2(0.5);float d=distance(uv,center)*2.0;d=max(d-modulationOffset,0.0);if(vActive>0.0&&d>0.0){ra=texture2D(inputBuffer,mix(uv,vUvR,d)).ra;ba=texture2D(inputBuffer,mix(uv,vUvB,d)).ba;} #else if(vActive>0.0){ra=texture2D(inputBuffer,vUvR).ra;ba=texture2D(inputBuffer,vUvB).ba;} #endif outputColor=vec4(ra.x,inputColor.g,ba.x,max(max(ra.y,ba.y),inputColor.a));}`,DI=`uniform vec2 offset;varying float vActive;varying vec2 vUvR;varying vec2 vUvB;void mainSupport(const in vec2 uv){vec2 shift=offset*vec2(1.0,aspect);vActive=(shift.x!=0.0||shift.y!=0.0)?1.0:0.0;vUvR=uv+shift;vUvB=uv-shift;}`,OI=class extends aI{constructor({offset:e=new W(.001,5e-4),radialModulation:t=!1,modulationOffset:n=.15}={}){super(`ChromaticAberrationEffect`,EI,{vertexShader:DI,attributes:YF.CONVOLUTION,uniforms:new Map([[`offset`,new J(e)],[`modulationOffset`,new J(n)]])}),this.radialModulation=t}get offset(){return this.uniforms.get(`offset`).value}set offset(e){this.uniforms.get(`offset`).value=e}get radialModulation(){return this.defines.has(`RADIAL_MODULATION`)}set radialModulation(e){e?this.defines.set(`RADIAL_MODULATION`,`1`):this.defines.delete(`RADIAL_MODULATION`),this.setChanged()}get modulationOffset(){return this.uniforms.get(`modulationOffset`).value}set modulationOffset(e){this.uniforms.get(`modulationOffset`).value=e}getOffset(){return this.offset}setOffset(e){this.offset=e}},kI={RED:0,GREEN:1,BLUE:2,ALPHA:3},AI={DISCARD:0,MULTIPLY:1,MULTIPLY_RGB_SET_ALPHA:2,MULTIPLY_RGB:3},jI=`#ifdef FRAMEBUFFER_PRECISION_HIGH uniform mediump sampler2D inputBuffer; #else uniform lowp sampler2D inputBuffer; #endif #if PASS == 1 uniform vec4 kernel64[32]; #else uniform vec4 kernel16[8]; #endif uniform lowp sampler2D cocBuffer;uniform vec2 texelSize;uniform float scale;varying vec2 vUv;void main(){ #ifdef FOREGROUND vec2 cocNearFar=texture2D(cocBuffer,vUv).rg*scale;float coc=cocNearFar.x; #else float coc=texture2D(cocBuffer,vUv).g*scale; #endif if(coc==0.0){gl_FragColor=texture2D(inputBuffer,vUv);}else{ #ifdef FOREGROUND vec2 step=texelSize*max(cocNearFar.x,cocNearFar.y); #else vec2 step=texelSize*coc; #endif #if PASS == 1 vec4 acc=vec4(0.0);for(int i=0;i<32;++i){vec4 kernel=kernel64[i];vec2 uv=step*kernel.xy+vUv;acc+=texture2D(inputBuffer,uv);uv=step*kernel.zw+vUv;acc+=texture2D(inputBuffer,uv);}gl_FragColor=acc/64.0; #else vec4 maxValue=texture2D(inputBuffer,vUv);for(int i=0;i<8;++i){vec4 kernel=kernel16[i];vec2 uv=step*kernel.xy+vUv;maxValue=max(texture2D(inputBuffer,uv),maxValue);uv=step*kernel.zw+vUv;maxValue=max(texture2D(inputBuffer,uv),maxValue);}gl_FragColor=maxValue; #endif }}`,MI=class extends Cl{constructor(e=!1,t=!1){super({name:`BokehMaterial`,defines:{PASS:e?`2`:`1`},uniforms:{inputBuffer:new J(null),cocBuffer:new J(null),texelSize:new J(new W),kernel64:new J(null),kernel16:new J(null),scale:new J(1)},blending:0,toneMapped:!1,depthWrite:!1,depthTest:!1,fragmentShader:jI,vertexShader:zF}),t&&(this.defines.FOREGROUND=`1`),this.generateKernel()}set inputBuffer(e){this.uniforms.inputBuffer.value=e}setInputBuffer(e){this.uniforms.inputBuffer.value=e}set cocBuffer(e){this.uniforms.cocBuffer.value=e}setCoCBuffer(e){this.uniforms.cocBuffer.value=e}get scale(){return this.uniforms.scale.value}set scale(e){this.uniforms.scale.value=e}getScale(e){return this.scale}setScale(e){this.scale=e}generateKernel(){let e=new Float64Array(128),t=new Float64Array(32),n=0,r=0;for(let i=0,a=Math.sqrt(80);i<80;++i){let o=i*2.39996323,s=Math.sqrt(i)/a,c=s*Math.cos(o),l=s*Math.sin(o);i%5==0?(t[r++]=c,t[r++]=l):(e[n++]=c,e[n++]=l)}this.uniforms.kernel64.value=e,this.uniforms.kernel16.value=t}setTexelSize(e,t){this.uniforms.texelSize.value.set(e,t)}setSize(e,t){this.uniforms.texelSize.value.set(1/e,1/t)}},NI=`#include #include #ifdef GL_FRAGMENT_PRECISION_HIGH uniform highp sampler2D depthBuffer; #else uniform mediump sampler2D depthBuffer; #endif uniform mat4 projectionMatrix;uniform mat4 projectionMatrixInverse;uniform float cameraNear;uniform float cameraFar;uniform float focusDistance;uniform float focusRange;varying vec2 vUv;float readDepth(const in vec2 uv){ #if DEPTH_PACKING == 3201 float depth=unpackRGBAToDepth(texture2D(depthBuffer,uv)); #else float depth=texture2D(depthBuffer,uv).r; #endif #if defined(USE_LOGARITHMIC_DEPTH_BUFFER) || defined(LOG_DEPTH) float d=pow(2.0,depth*log2(cameraFar+1.0))-1.0;float a=cameraFar/(cameraFar-cameraNear);float b=cameraFar*cameraNear/(cameraNear-cameraFar);depth=a+b/d; #elif defined(USE_REVERSED_DEPTH_BUFFER) depth=1.0-depth; #endif return depth;} #ifdef PERSPECTIVE_CAMERA #define getViewZ(depth) perspectiveDepthToViewZ(depth, cameraNear, cameraFar) #else #define getViewZ(depth) orthographicDepthToViewZ(depth, cameraNear, cameraFar) #endif vec3 getViewPosition(const in vec2 screenPosition,const in float depth,const in float viewZ){vec4 clipPosition=vec4(vec3(screenPosition,depth)*2.0-1.0,1.0);float clipW=projectionMatrix[2][3]*viewZ+projectionMatrix[3][3];clipPosition*=clipW;return(projectionMatrixInverse*clipPosition).xyz;}vec3 getViewPosition(const in vec2 screenPosition,const in float depth){return getViewPosition(screenPosition,depth,getViewZ(depth));} #define getDistance(viewPosition) length(viewPosition) void main(){float depth=readDepth(vUv);vec3 viewPosition=getViewPosition(vUv,depth);float distance=getDistance(viewPosition);float signedDistance=distance-focusDistance;float magnitude=smoothstep(0.0,focusRange,abs(signedDistance));gl_FragColor.rg=magnitude*vec2(step(signedDistance,0.0),step(0.0,signedDistance));}`,PI=class extends Cl{constructor(e=null){super({name:`CircleOfConfusionMaterial`,defines:{DEPTH_PACKING:`0`},uniforms:{depthBuffer:new J(null),projectionMatrix:new J(null),projectionMatrixInverse:new J(null),cameraNear:new J(.3),cameraFar:new J(1e3),focusDistance:new J(0),focusRange:new J(0)},blending:0,toneMapped:!1,depthWrite:!1,depthTest:!1,fragmentShader:NI,vertexShader:zF}),this.uniforms.focalLength=this.uniforms.focusRange,e!==null&&this.copyCameraSettings(e)}set depthBuffer(e){this.uniforms.depthBuffer.value=e}set depthPacking(e){this.defines.DEPTH_PACKING=e.toFixed(0),this.needsUpdate=!0}setDepthBuffer(e,t=gt){this.depthBuffer=e,this.depthPacking=t}get focusDistance(){return this.uniforms.focusDistance.value}set focusDistance(e){this.uniforms.focusDistance.value=e}get worldFocusDistance(){return this.focusDistance}set worldFocusDistance(e){this.focusDistance=e}getFocusDistance(e){this.uniforms.focusDistance.value=e}setFocusDistance(e){this.uniforms.focusDistance.value=e}get focalLength(){return this.focusRange}set focalLength(e){this.focusRange=e}get focusRange(){return this.uniforms.focusRange.value}set focusRange(e){this.uniforms.focusRange.value=e}get worldFocusRange(){return this.focusRange}set worldFocusRange(e){this.focusRange=e}getFocalLength(e){return this.focusRange}setFocalLength(e){this.focusRange=e}adoptCameraSettings(e){this.copyCameraSettings(e)}copyCameraSettings(e){this.uniforms.projectionMatrix.value=e.projectionMatrix,this.uniforms.projectionMatrixInverse.value=e.projectionMatrixInverse,this.uniforms.cameraNear.value=e.near,this.uniforms.cameraFar.value=e.far;let t=this.defines.PERSPECTIVE_CAMERA!==void 0;e instanceof Mu?t||(this.defines.PERSPECTIVE_CAMERA=!0,this.needsUpdate=!0):t&&(delete this.defines.PERSPECTIVE_CAMERA,this.needsUpdate=!0)}},FI=`#ifdef FRAMEBUFFER_PRECISION_HIGH uniform mediump sampler2D inputBuffer; #else uniform lowp sampler2D inputBuffer; #endif #ifdef MASK_PRECISION_HIGH uniform mediump sampler2D maskTexture; #else uniform lowp sampler2D maskTexture; #endif #if MASK_FUNCTION != 0 uniform float strength; #endif varying vec2 vUv;void main(){ #if COLOR_CHANNEL == 0 float mask=texture2D(maskTexture,vUv).r; #elif COLOR_CHANNEL == 1 float mask=texture2D(maskTexture,vUv).g; #elif COLOR_CHANNEL == 2 float mask=texture2D(maskTexture,vUv).b; #else float mask=texture2D(maskTexture,vUv).a; #endif #if MASK_FUNCTION == 0 #ifdef INVERTED mask=(mask>0.0)?0.0:1.0; #else mask=(mask>0.0)?1.0:0.0; #endif #else mask=clamp(mask*strength,0.0,1.0); #ifdef INVERTED mask=1.0-mask; #endif #endif #if MASK_FUNCTION == 3 vec4 texel=texture2D(inputBuffer,vUv);gl_FragColor=vec4(mask*texel.rgb,texel.a); #elif MASK_FUNCTION == 2 gl_FragColor=vec4(mask*texture2D(inputBuffer,vUv).rgb,mask); #else gl_FragColor=mask*texture2D(inputBuffer,vUv); #endif }`,II=class extends Cl{constructor(e=null){super({name:`MaskMaterial`,uniforms:{maskTexture:new J(e),inputBuffer:new J(null),strength:new J(1)},blending:0,toneMapped:!1,depthWrite:!1,depthTest:!1,fragmentShader:FI,vertexShader:zF}),this.colorChannel=kI.RED,this.maskFunction=AI.DISCARD}set inputBuffer(e){this.uniforms.inputBuffer.value=e}setInputBuffer(e){this.uniforms.inputBuffer.value=e}set maskTexture(e){this.uniforms.maskTexture.value=e,delete this.defines.MASK_PRECISION_HIGH,e.type!==1009&&(this.defines.MASK_PRECISION_HIGH=`1`),this.needsUpdate=!0}setMaskTexture(e){this.maskTexture=e}set colorChannel(e){this.defines.COLOR_CHANNEL=e.toFixed(0),this.needsUpdate=!0}setColorChannel(e){this.colorChannel=e}set maskFunction(e){this.defines.MASK_FUNCTION=e.toFixed(0),this.needsUpdate=!0}setMaskFunction(e){this.maskFunction=e}get inverted(){return this.defines.INVERTED!==void 0}set inverted(e){this.inverted&&!e?delete this.defines.INVERTED:e&&(this.defines.INVERTED=`1`),this.needsUpdate=!0}isInverted(){return this.inverted}setInverted(e){this.inverted=e}get strength(){return this.uniforms.strength.value}set strength(e){this.uniforms.strength.value=e}getStrength(){return this.strength}setStrength(e){this.strength=e}},LI=class extends IF{constructor(e,t=`inputBuffer`){super(`ShaderPass`),this.fullscreenMaterial=e,this.input=t}setInput(e){this.input=e}render(e,t,n,r,i){let a=this.fullscreenMaterial.uniforms;t!==null&&a!==void 0&&a[this.input]!==void 0&&(a[this.input].value=t.texture),e.setRenderTarget(this.renderToScreen?null:n),e.render(this.scene,this.camera)}initialize(e,t,n){n!==void 0&&n!==1009&&(this.fullscreenMaterial.defines.FRAMEBUFFER_PRECISION_HIGH=`1`)}},RI=`#ifdef FRAMEBUFFER_PRECISION_HIGH uniform mediump sampler2D nearColorBuffer;uniform mediump sampler2D farColorBuffer; #else uniform lowp sampler2D nearColorBuffer;uniform lowp sampler2D farColorBuffer; #endif #if MASK_FUNCTION != 1 && MASK_FUNCTION != 2 uniform lowp sampler2D farCoCBuffer; #endif uniform lowp sampler2D nearCoCBuffer;uniform float scale;void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){vec4 colorNear=texture2D(nearColorBuffer,uv);vec4 colorFar=texture2D(farColorBuffer,uv); #if MASK_FUNCTION == 1 || MASK_FUNCTION == 2 vec2 cocNearFar=vec2(texture2D(nearCoCBuffer,uv).r,colorFar.a);cocNearFar.x=min(cocNearFar.x*scale,1.0); #else vec2 cocNearFar=vec2(texture2D(nearCoCBuffer,uv).r,texture2D(farCoCBuffer,uv).g);cocNearFar=min(cocNearFar*scale,1.0);colorFar.a*=cocNearFar.y; #endif vec4 result=inputColor*(1.0-cocNearFar.y)+colorFar;result=mix(result,colorNear,cocNearFar.x);outputColor=result;}`,zI=new G,BI=class extends aI{constructor(e,{blendFunction:t,worldFocusDistance:n,worldFocusRange:r,focalLength:i,focusDistance:a=n||3,focusRange:o=r||i||2,bokehScale:s=1,resolutionScale:c=.5,width:l,height:u,resolutionX:d=l||tI.AUTO_SIZE,resolutionY:f=u||tI.AUTO_SIZE}={}){super(`DepthOfFieldEffect`,RI,{blendFunction:t,attributes:YF.DEPTH,uniforms:new Map([[`nearColorBuffer`,new J(null)],[`farColorBuffer`,new J(null)],[`nearCoCBuffer`,new J(null)],[`farCoCBuffer`,new J(null)],[`scale`,new J(1)]])}),this.camera=e,this.renderTarget=new rr(1,1,{depthBuffer:!1}),this.renderTarget.texture.name=`DoF.Intermediate`,this.renderTargetMasked=this.renderTarget.clone(),this.renderTargetMasked.texture.name=`DoF.Masked.Far`,this.renderTargetNear=this.renderTarget.clone(),this.renderTargetNear.texture.name=`DoF.Bokeh.Near`,this.uniforms.get(`nearColorBuffer`).value=this.renderTargetNear.texture,this.renderTargetFar=this.renderTarget.clone(),this.renderTargetFar.texture.name=`DoF.Bokeh.Far`,this.uniforms.get(`farColorBuffer`).value=this.renderTargetFar.texture,this.renderTargetCoC=this.renderTarget.clone(),this.renderTargetCoC.texture.name=`DoF.CoC`,this.uniforms.get(`farCoCBuffer`).value=this.renderTargetCoC.texture,this.renderTargetCoCBlurred=this.renderTargetCoC.clone(),this.renderTargetCoCBlurred.texture.name=`DoF.CoC.Blurred`,this.uniforms.get(`nearCoCBuffer`).value=this.renderTargetCoCBlurred.texture,this.cocPass=new LI(new PI(e));let p=this.cocMaterial;p.focusDistance=a,p.focusRange=o,this.blurPass=new dI({resolutionScale:c,resolutionX:d,resolutionY:f,kernelSize:oI.MEDIUM}),this.maskPass=new LI(new II(this.renderTargetCoC.texture));let m=this.maskPass.fullscreenMaterial;m.colorChannel=kI.GREEN,this.maskFunction=AI.MULTIPLY_RGB,this.bokehNearBasePass=new LI(new MI(!1,!0)),this.bokehNearBasePass.fullscreenMaterial.cocBuffer=this.renderTargetCoCBlurred.texture,this.bokehNearFillPass=new LI(new MI(!0,!0)),this.bokehNearFillPass.fullscreenMaterial.cocBuffer=this.renderTargetCoCBlurred.texture,this.bokehFarBasePass=new LI(new MI(!1,!1)),this.bokehFarBasePass.fullscreenMaterial.cocBuffer=this.renderTargetCoC.texture,this.bokehFarFillPass=new LI(new MI(!0,!1)),this.bokehFarFillPass.fullscreenMaterial.cocBuffer=this.renderTargetCoC.texture,this.target=null;let h=this.resolution=new tI(this,d,f,c);h.addEventListener(`change`,e=>this.setSize(h.baseWidth,h.baseHeight)),this.bokehScale=s}set mainCamera(e){this.camera=e,this.cocMaterial.copyCameraSettings(e)}get cocTexture(){return this.renderTargetCoC.texture}get maskFunction(){return this.maskPass.fullscreenMaterial.maskFunction}set maskFunction(e){this.maskFunction!==e&&(this.defines.set(`MASK_FUNCTION`,e.toFixed(0)),this.maskPass.fullscreenMaterial.maskFunction=e,this.setChanged())}get cocMaterial(){return this.cocPass.fullscreenMaterial}get circleOfConfusionMaterial(){return this.cocMaterial}getCircleOfConfusionMaterial(){return this.cocMaterial}getBlurPass(){return this.blurPass}getResolution(){return this.resolution}get bokehScale(){return this.uniforms.get(`scale`).value}set bokehScale(e){this.bokehNearBasePass.fullscreenMaterial.scale=e,this.bokehNearFillPass.fullscreenMaterial.scale=e,this.bokehFarBasePass.fullscreenMaterial.scale=e,this.bokehFarFillPass.fullscreenMaterial.scale=e,this.maskPass.fullscreenMaterial.strength=e,this.uniforms.get(`scale`).value=e}getBokehScale(){return this.bokehScale}setBokehScale(e){this.bokehScale=e}getTarget(){return this.target}setTarget(e){this.target=e}calculateFocusDistance(e){return this.camera.getWorldPosition(zI).distanceTo(e)}setDepthTexture(e,t=gt){this.cocMaterial.depthBuffer=e,this.cocMaterial.depthPacking=t}update(e,t,n){let r=this.renderTarget,i=this.renderTargetCoC,a=this.renderTargetCoCBlurred,o=this.renderTargetMasked;if(this.target!==null){let e=this.calculateFocusDistance(this.target);this.cocMaterial.focusDistance=e}this.cocPass.render(e,null,i),this.blurPass.render(e,i,a),this.maskPass.render(e,t,o),this.bokehFarBasePass.render(e,o,r),this.bokehFarFillPass.render(e,r,this.renderTargetFar),this.bokehNearBasePass.render(e,t,r),this.bokehNearFillPass.render(e,r,this.renderTargetNear)}setSize(e,t){let n=this.resolution;n.setBaseSize(e,t);let r=n.width,i=n.height;this.cocPass.setSize(e,t),this.blurPass.setSize(e,t),this.maskPass.setSize(e,t),this.renderTargetFar.setSize(e,t),this.renderTargetCoC.setSize(e,t),this.renderTargetMasked.setSize(e,t),this.renderTarget.setSize(r,i),this.renderTargetNear.setSize(r,i),this.renderTargetCoCBlurred.setSize(r,i),this.bokehNearBasePass.fullscreenMaterial.setSize(e,t),this.bokehNearFillPass.fullscreenMaterial.setSize(e,t),this.bokehFarBasePass.fullscreenMaterial.setSize(e,t),this.bokehFarFillPass.fullscreenMaterial.setSize(e,t)}initialize(e,t,n){this.cocPass.initialize(e,t,n),this.maskPass.initialize(e,t,n),this.bokehNearBasePass.initialize(e,t,n),this.bokehNearFillPass.initialize(e,t,n),this.bokehFarBasePass.initialize(e,t,n),this.bokehFarFillPass.initialize(e,t,n),this.blurPass.initialize(e,t,re),e.capabilities.logarithmicDepthBuffer&&(this.cocPass.fullscreenMaterial.defines.LOG_DEPTH=`1`),n!==void 0&&(this.renderTarget.texture.type=n,this.renderTargetNear.texture.type=n,this.renderTargetFar.texture.type=n,this.renderTargetMasked.texture.type=n,e!==null&&e.outputColorSpace===`srgb`&&(this.renderTarget.texture.colorSpace=bt,this.renderTargetNear.texture.colorSpace=bt,this.renderTargetFar.texture.colorSpace=bt,this.renderTargetMasked.texture.colorSpace=bt))}},VI=class extends IF{constructor(e,t,n=null){super(`RenderPass`,e,t),this.needsSwap=!1,this.needsDepthBlit=!0,this.clearPass=new UF,this.overrideMaterialManager=n===null?null:new $F(n),this.ignoreBackground=!1,this.skipShadowMapUpdate=!1,this.selection=null}set mainScene(e){this.scene=e}set mainCamera(e){this.camera=e}get renderToScreen(){return super.renderToScreen}set renderToScreen(e){super.renderToScreen=e,this.clearPass.renderToScreen=e}get overrideMaterial(){let e=this.overrideMaterialManager;return e===null?null:e.material}set overrideMaterial(e){let t=this.overrideMaterialManager;e===null?t!==null&&(t.dispose(),this.overrideMaterialManager=null):t===null?this.overrideMaterialManager=new $F(e):t.setMaterial(e)}getOverrideMaterial(){return this.overrideMaterial}setOverrideMaterial(e){this.overrideMaterial=e}get clear(){return this.clearPass.enabled}set clear(e){this.clearPass.enabled=e}getSelection(){return this.selection}setSelection(e){this.selection=e}isBackgroundDisabled(){return this.ignoreBackground}setBackgroundDisabled(e){this.ignoreBackground=e}isShadowMapDisabled(){return this.skipShadowMapUpdate}setShadowMapDisabled(e){this.skipShadowMapUpdate=e}getClearPass(){return this.clearPass}render(e,t,n,r,i){let a=this.scene,o=this.camera,s=this.selection,c=o.layers.mask,l=a.background,u=e.shadowMap.autoUpdate,d=this.renderToScreen?null:t;s!==null&&o.layers.set(s.getLayer()),this.skipShadowMapUpdate&&(e.shadowMap.autoUpdate=!1),(this.ignoreBackground||this.clearPass.overrideClearColor!==null)&&(a.background=null),this.clearPass.enabled&&this.clearPass.render(e,t),e.setRenderTarget(d),this.overrideMaterialManager===null?e.render(a,o):this.overrideMaterialManager.render(e,a,o),o.layers.mask=c,a.background=l,e.shadowMap.autoUpdate=u}},HI=`uniform vec3 hue;uniform float saturation;void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){vec3 color=vec3(dot(inputColor.rgb,hue.xyz),dot(inputColor.rgb,hue.zxy),dot(inputColor.rgb,hue.yzx));float average=(color.r+color.g+color.b)/3.0;vec3 diff=average-color;if(saturation>0.0){color+=diff*(1.0-1.0/(1.001-saturation));}else{color+=diff*-saturation;}outputColor=vec4(min(color,1.0),inputColor.a);}`,UI=class extends aI{constructor({blendFunction:e=nI.SRC,hue:t=0,saturation:n=0}={}){super(`HueSaturationEffect`,HI,{blendFunction:e,uniforms:new Map([[`hue`,new J(new G)],[`saturation`,new J(n)]])}),this.hue=t}get saturation(){return this.uniforms.get(`saturation`).value}set saturation(e){this.uniforms.get(`saturation`).value=e}getSaturation(){return this.saturation}setSaturation(e){this.saturation=e}get hue(){let e=this.uniforms.get(`hue`).value;return Math.acos((e.x*3-1)/2)}set hue(e){let t=Math.sin(e),n=Math.cos(e);this.uniforms.get(`hue`).value.set((2*n+1)/3,(-Math.sqrt(3)*t-n+1)/3,(Math.sqrt(3)*t-n+1)/3)}getHue(){return this.hue}setHue(e){this.hue=e}},WI={DEFAULT:0,ESKIL:1},GI=`void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){vec3 noise=vec3(rand(uv*(1.0+time))); #ifdef PREMULTIPLY outputColor=vec4(min(inputColor.rgb*noise,vec3(1.0)),inputColor.a); #else outputColor=vec4(noise,inputColor.a); #endif }`,KI=class extends aI{constructor({blendFunction:e=nI.SCREEN,premultiply:t=!1}={}){super(`NoiseEffect`,GI,{blendFunction:e}),this.premultiply=t}get premultiply(){return this.defines.has(`PREMULTIPLY`)}set premultiply(e){this.premultiply!==e&&(e?this.defines.set(`PREMULTIPLY`,`1`):this.defines.delete(`PREMULTIPLY`),this.setChanged())}isPremultiplied(){return this.premultiply}setPremultiplied(e){this.premultiply=e}};Math.PI*.5;var qI=`#include #ifdef GL_FRAGMENT_PRECISION_HIGH uniform highp sampler2D depthBuffer; #else uniform mediump sampler2D depthBuffer; #endif #ifdef DOWNSAMPLE_NORMALS uniform lowp sampler2D normalBuffer; #endif varying vec2 vUv0;varying vec2 vUv1;varying vec2 vUv2;varying vec2 vUv3;float readDepth(const in vec2 uv){ #if DEPTH_PACKING == 3201 return unpackRGBAToDepth(texture2D(depthBuffer,uv)); #else return texture2D(depthBuffer,uv).r; #endif }int findBestDepth(const in float samples[4]){float c=(samples[0]+samples[1]+samples[2]+samples[3])*0.25;float distances[4];distances[0]=abs(c-samples[0]);distances[1]=abs(c-samples[1]);distances[2]=abs(c-samples[2]);distances[3]=abs(c-samples[3]);float maxDistance=max(max(distances[0],distances[1]),max(distances[2],distances[3]));int remaining[3];int rejected[3];int i,j,k;for(i=0,j=0,k=0;i<4;++i){if(distances[i]this.setSize(s.baseWidth,s.baseHeight))}get texture(){return this.renderTarget.texture}getTexture(){return this.renderTarget.texture}getResolution(){return this.resolution}setDepthTexture(e,t=gt){this.fullscreenMaterial.depthBuffer=e,this.fullscreenMaterial.depthPacking=t}render(e,t,n,r,i){e.setRenderTarget(this.renderToScreen?null:this.renderTarget),e.render(this.scene,this.camera)}setSize(e,t){let n=this.resolution;n.setBaseSize(e,t),this.renderTarget.setSize(n.width,n.height),this.fullscreenMaterial.setSize(e,t)}initialize(e,t,n){let r=e.getContext();if(!(r.getExtension(`EXT_color_buffer_float`)||r.getExtension(`EXT_color_buffer_half_float`)))throw Error(`Rendering to float texture is not supported.`)}},ZI=`uniform float offset;uniform float darkness;void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){const vec2 center=vec2(0.5);vec3 color=inputColor.rgb; #if VIGNETTE_TECHNIQUE == 0 float d=distance(uv,center);color*=smoothstep(0.8,offset*0.799,d*(darkness+offset)); #else vec2 coord=(uv-center)*vec2(offset);color=mix(color,vec3(1.0-darkness),dot(coord,coord)); #endif outputColor=vec4(color,inputColor.a);}`,QI=class extends aI{constructor({blendFunction:e,eskil:t=!1,technique:n=t?WI.ESKIL:WI.DEFAULT,offset:r=.5,darkness:i=.5}={}){super(`VignetteEffect`,ZI,{blendFunction:e,defines:new Map([[`VIGNETTE_TECHNIQUE`,n.toFixed(0)]]),uniforms:new Map([[`offset`,new J(r)],[`darkness`,new J(i)]])})}get technique(){return Number(this.defines.get(`VIGNETTE_TECHNIQUE`))}set technique(e){this.technique!==e&&(this.defines.set(`VIGNETTE_TECHNIQUE`,e.toFixed(0)),this.setChanged())}get eskil(){return this.technique===WI.ESKIL}set eskil(e){this.technique=e?WI.ESKIL:WI.DEFAULT}getTechnique(){return this.technique}setTechnique(e){this.technique=e}get offset(){return this.uniforms.get(`offset`).value}set offset(e){this.uniforms.get(`offset`).value=e}getOffset(){return this.offset}setOffset(e){this.offset=e}get darkness(){return this.uniforms.get(`darkness`).value}set darkness(e){this.uniforms.get(`darkness`).value=e}getDarkness(){return this.darkness}setDarkness(e){this.darkness=e}},$I=`#include #include #include #define packFloatToRGBA(v) packDepthToRGBA(v) #define unpackRGBAToFloat(v) unpackRGBAToDepth(v) #ifdef FRAMEBUFFER_PRECISION_HIGH uniform mediump sampler2D inputBuffer; #else uniform lowp sampler2D inputBuffer; #endif #if DEPTH_PACKING == 3201 uniform lowp sampler2D depthBuffer; #elif defined(GL_FRAGMENT_PRECISION_HIGH) uniform highp sampler2D depthBuffer; #else uniform mediump sampler2D depthBuffer; #endif uniform vec2 resolution;uniform vec2 texelSize;uniform float cameraNear;uniform float cameraFar;uniform float aspect;uniform float time;varying vec2 vUv;vec4 sRGBToLinear(const 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);}float readDepth(const in vec2 uv){ #if DEPTH_PACKING == 3201 float depth=unpackRGBAToDepth(texture2D(depthBuffer,uv)); #else float depth=texture2D(depthBuffer,uv).r; #endif #if defined(USE_LOGARITHMIC_DEPTH_BUFFER) || defined(LOG_DEPTH) float d=pow(2.0,depth*log2(cameraFar+1.0))-1.0;float a=cameraFar/(cameraFar-cameraNear);float b=cameraFar*cameraNear/(cameraNear-cameraFar);depth=a+b/d; #elif defined(USE_REVERSED_DEPTH_BUFFER) depth=1.0-depth; #endif return depth;}float getViewZ(const in float depth){ #ifdef PERSPECTIVE_CAMERA return perspectiveDepthToViewZ(depth,cameraNear,cameraFar); #else return orthographicDepthToViewZ(depth,cameraNear,cameraFar); #endif }vec3 RGBToHCV(const in vec3 RGB){vec4 P=mix(vec4(RGB.bg,-1.0,2.0/3.0),vec4(RGB.gb,0.0,-1.0/3.0),step(RGB.b,RGB.g));vec4 Q=mix(vec4(P.xyw,RGB.r),vec4(RGB.r,P.yzx),step(P.x,RGB.r));float C=Q.x-min(Q.w,Q.y);float H=abs((Q.w-Q.y)/(6.0*C+EPSILON)+Q.z);return vec3(H,C,Q.x);}vec3 RGBToHSL(const in vec3 RGB){vec3 HCV=RGBToHCV(RGB);float L=HCV.z-HCV.y*0.5;float S=HCV.y/(1.0-abs(L*2.0-1.0)+EPSILON);return vec3(HCV.x,S,L);}vec3 HueToRGB(const in float H){float R=abs(H*6.0-3.0)-1.0;float G=2.0-abs(H*6.0-2.0);float B=2.0-abs(H*6.0-4.0);return clamp(vec3(R,G,B),0.0,1.0);}vec3 HSLToRGB(const in vec3 HSL){vec3 RGB=HueToRGB(HSL.x);float C=(1.0-abs(2.0*HSL.z-1.0))*HSL.y;return(RGB-0.5)*C+HSL.z;}FRAGMENT_HEAD void main(){FRAGMENT_MAIN_UV vec4 color0=texture2D(inputBuffer,UV);vec4 color1=vec4(0.0);FRAGMENT_MAIN_IMAGE color0.a=clamp(color0.a,0.0,1.0);gl_FragColor=color0; #ifdef ENCODE_OUTPUT #include #endif #include }`,eL=`uniform vec2 resolution;uniform vec2 texelSize;uniform float cameraNear;uniform float cameraFar;uniform float aspect;uniform float time;varying vec2 vUv;VERTEX_HEAD void main(){vUv=position.xy*0.5+0.5;VERTEX_MAIN_SUPPORT gl_Position=vec4(position.xy,1.0,1.0);}`,tL=class extends Cl{constructor(e,t,n,r,i=!1){super({name:`EffectMaterial`,defines:{THREE_REVISION:`184`.replace(/\D+/g,``),DEPTH_PACKING:`0`,ENCODE_OUTPUT:`1`},uniforms:{inputBuffer:new J(null),depthBuffer:new J(null),resolution:new J(new W),texelSize:new J(new W),cameraNear:new J(.3),cameraFar:new J(1e3),aspect:new J(1),time:new J(0)},blending:0,toneMapped:!1,depthWrite:!1,depthTest:!1,dithering:i}),e&&this.setShaderParts(e),t&&this.setDefines(t),n&&this.setUniforms(n),this.copyCameraSettings(r)}set inputBuffer(e){this.uniforms.inputBuffer.value=e}setInputBuffer(e){this.uniforms.inputBuffer.value=e}get depthBuffer(){return this.uniforms.depthBuffer.value}set depthBuffer(e){this.uniforms.depthBuffer.value=e}get depthPacking(){return Number(this.defines.DEPTH_PACKING)}set depthPacking(e){this.defines.DEPTH_PACKING=e.toFixed(0),this.needsUpdate=!0}setDepthBuffer(e,t=gt){this.depthBuffer=e,this.depthPacking=t}setShaderData(e){this.setShaderParts(e.shaderParts),this.setDefines(e.defines),this.setUniforms(e.uniforms),this.setExtensions(e.extensions)}setShaderParts(e){return this.fragmentShader=$I.replace(XF.FRAGMENT_HEAD,e.get(XF.FRAGMENT_HEAD)||``).replace(XF.FRAGMENT_MAIN_UV,e.get(XF.FRAGMENT_MAIN_UV)||``).replace(XF.FRAGMENT_MAIN_IMAGE,e.get(XF.FRAGMENT_MAIN_IMAGE)||``),this.vertexShader=eL.replace(XF.VERTEX_HEAD,e.get(XF.VERTEX_HEAD)||``).replace(XF.VERTEX_MAIN_SUPPORT,e.get(XF.VERTEX_MAIN_SUPPORT)||``),this.needsUpdate=!0,this}setDefines(e){for(let t of e.entries())this.defines[t[0]]=t[1];return this.needsUpdate=!0,this}setUniforms(e){for(let t of e.entries())this.uniforms[t[0]]=t[1];return this}setExtensions(e){this.extensions={};for(let t of e)this.extensions[t]=!0;return this}get encodeOutput(){return this.defines.ENCODE_OUTPUT!==void 0}set encodeOutput(e){this.encodeOutput!==e&&(e?this.defines.ENCODE_OUTPUT=`1`:delete this.defines.ENCODE_OUTPUT,this.needsUpdate=!0)}isOutputEncodingEnabled(e){return this.encodeOutput}setOutputEncodingEnabled(e){this.encodeOutput=e}get time(){return this.uniforms.time.value}set time(e){this.uniforms.time.value=e}setDeltaTime(e){this.uniforms.time.value+=e}adoptCameraSettings(e){this.copyCameraSettings(e)}copyCameraSettings(e){e&&(this.uniforms.cameraNear.value=e.near,this.uniforms.cameraFar.value=e.far,e instanceof Mu?this.defines.PERSPECTIVE_CAMERA=`1`:delete this.defines.PERSPECTIVE_CAMERA,this.needsUpdate=!0)}setSize(e,t){let n=this.uniforms;n.resolution.value.set(e,t),n.texelSize.value.set(1/e,1/t),n.aspect.value=e/t}static get Section(){return XF}};Number(`184`.replace(/\D+/g,``));var nL=255/256;new Float32Array([nL/256**3,nL/256**2,nL/256,nL]),new Float32Array([nL,nL/256,nL/256**2,1/256**3]);function rL(e,t,n){for(let r of t){let t=`$1`+e+r.charAt(0).toUpperCase()+r.slice(1),i=RegExp(`([^\\.])(\\b`+r+`\\b)`,`g`);for(let e of n.entries())e[1]!==null&&n.set(e[0],e[1].replace(i,t))}}function iL(e,t,n){let r=t.getFragmentShader(),i=t.getVertexShader(),a=r!==void 0&&/mainImage/.test(r),o=r!==void 0&&/mainUv/.test(r);if(n.attributes|=t.getAttributes(),r===void 0)throw Error(`Missing fragment shader (${t.name})`);if(o&&(n.attributes&YF.CONVOLUTION)!==0)throw Error(`Effects that transform UVs are incompatible with convolution effects (${t.name})`);if(!a&&!o)throw Error(`Could not find mainImage or mainUv function (${t.name})`);{let s=/\w+\s+(\w+)\([\w\s,]*\)\s*{/g,c=n.shaderParts,l=c.get(XF.FRAGMENT_HEAD)||``,u=c.get(XF.FRAGMENT_MAIN_UV)||``,d=c.get(XF.FRAGMENT_MAIN_IMAGE)||``,f=c.get(XF.VERTEX_HEAD)||``,p=c.get(XF.VERTEX_MAIN_SUPPORT)||``,m=new Set,h=new Set;if(o&&(u+=` ${e}MainUv(UV); `,n.uvTransformation=!0),i!==null&&/mainSupport/.test(i)){let t=/mainSupport *\([\w\s]*?uv\s*?\)/.test(i);p+=` ${e}MainSupport(`,p+=t?`vUv); `:`); `;for(let e of i.matchAll(/(?:varying\s+\w+\s+([\S\s]*?);)/g))for(let t of e[1].split(/\s*,\s*/))n.varyings.add(t),m.add(t),h.add(t);for(let e of i.matchAll(s))h.add(e[1])}for(let e of r.matchAll(s))h.add(e[1]);for(let e of t.defines.keys())h.add(e.replace(/\([\w\s,]*\)/g,``));for(let e of t.uniforms.keys())h.add(e);h.delete(`while`),h.delete(`for`),h.delete(`if`),t.uniforms.forEach((t,r)=>n.uniforms.set(e+r.charAt(0).toUpperCase()+r.slice(1),t)),t.defines.forEach((t,r)=>n.defines.set(e+r.charAt(0).toUpperCase()+r.slice(1),t));let g=new Map([[`fragment`,r],[`vertex`,i]]);rL(e,h,n.defines),rL(e,h,g),r=g.get(`fragment`),i=g.get(`vertex`);let _=t.blendMode;if(n.blendModes.set(_.blendFunction,_),a){t.inputColorSpace!==null&&t.inputColorSpace!==n.colorSpace&&(d+=t.inputColorSpace===`srgb`?`color0 = sRGBTransferOETF(color0); `:`color0 = sRGBToLinear(color0); `),t.outputColorSpace===``?t.inputColorSpace!==null&&(n.colorSpace=t.inputColorSpace):n.colorSpace=t.outputColorSpace,d+=`${e}MainImage(color0, UV, `,(n.attributes&YF.DEPTH)!==0&&/MainImage *\([\w\s,]*?depth[\w\s,]*?\)/.test(r)&&(d+=`depth, `,n.readDepth=!0),d+=`color1); `;let i=e+`BlendOpacity`;n.uniforms.set(i,_.opacity),d+=`color0 = blend${_.blendFunction}(color0, color1, ${i}); `,l+=`uniform float ${i}; `}if(l+=r+` `,i!==null&&(f+=i+` `),c.set(XF.FRAGMENT_HEAD,l),c.set(XF.FRAGMENT_MAIN_UV,u),c.set(XF.FRAGMENT_MAIN_IMAGE,d),c.set(XF.VERTEX_HEAD,f),c.set(XF.VERTEX_MAIN_SUPPORT,p),t.extensions!==null)for(let e of t.extensions)n.extensions.add(e)}}var aL=class extends IF{constructor(e,...t){super(`EffectPass`),this.fullscreenMaterial=new tL(null,null,null,e),this.listener=e=>this.handleEvent(e),this.effects=[],this.setEffects(t),this.skipRendering=!1,this.minTime=1,this.maxTime=1/0,this.timeScale=1}set mainScene(e){for(let t of this.effects)t.mainScene=e}set mainCamera(e){this.fullscreenMaterial.copyCameraSettings(e);for(let t of this.effects)t.mainCamera=e}get encodeOutput(){return this.fullscreenMaterial.encodeOutput}set encodeOutput(e){this.fullscreenMaterial.encodeOutput=e}get dithering(){return this.fullscreenMaterial.dithering}set dithering(e){let t=this.fullscreenMaterial;t.dithering=e,t.needsUpdate=!0}setEffects(e){for(let e of this.effects)e.removeEventListener(`change`,this.listener);this.effects=e.sort((e,t)=>t.attributes-e.attributes);for(let e of this.effects)e.addEventListener(`change`,this.listener)}updateMaterial(){let e=new ZF,t=0;for(let n of this.effects)if(n.blendMode.blendFunction===nI.DST)e.attributes|=n.getAttributes()&YF.DEPTH;else if((e.attributes&n.getAttributes()&YF.CONVOLUTION)!==0)throw Error(`Convolution effects cannot be merged (${n.name})`);else iL(`e`+ t++,n,e);let n=e.shaderParts.get(XF.FRAGMENT_HEAD),r=e.shaderParts.get(XF.FRAGMENT_MAIN_IMAGE),i=e.shaderParts.get(XF.FRAGMENT_MAIN_UV),a=/\bblend\b/g;for(let t of e.blendModes.values())n+=t.getShaderCode().replace(a,`blend${t.blendFunction}`)+` `;(e.attributes&YF.DEPTH)===0?this.needsDepthTexture=!1:(e.readDepth&&(r=`float depth = readDepth(UV); `+r),this.needsDepthTexture=this.getDepthTexture()===null),e.colorSpace===`srgb`&&(r+=`color0 = sRGBToLinear(color0); `),e.uvTransformation?(i=`vec2 transformedUv = vUv; `+i,e.defines.set(`UV`,`transformedUv`)):e.defines.set(`UV`,`vUv`),e.shaderParts.set(XF.FRAGMENT_HEAD,n),e.shaderParts.set(XF.FRAGMENT_MAIN_IMAGE,r),e.shaderParts.set(XF.FRAGMENT_MAIN_UV,i);for(let[t,n]of e.shaderParts)n!==null&&e.shaderParts.set(t,n.trim().replace(/^#/,` #`));this.skipRendering=t===0,this.needsSwap=!this.skipRendering,this.fullscreenMaterial.setShaderData(e)}recompile(){this.updateMaterial()}getDepthTexture(){return this.fullscreenMaterial.depthBuffer}setDepthTexture(e,t=gt){this.fullscreenMaterial.depthBuffer=e,this.fullscreenMaterial.depthPacking=t;for(let n of this.effects)n.setDepthTexture(e,t)}render(e,t,n,r,i){for(let n of this.effects)n.update(e,t,r);if(!this.skipRendering||this.renderToScreen){let i=this.fullscreenMaterial;i.inputBuffer=t.texture,i.time+=r*this.timeScale,e.setRenderTarget(this.renderToScreen?null:n),e.render(this.scene,this.camera)}}setSize(e,t){this.fullscreenMaterial.setSize(e,t);for(let n of this.effects)n.setSize(e,t)}initialize(e,t,n){this.renderer=e;for(let r of this.effects)r.initialize(e,t,n);this.updateMaterial(),n!==void 0&&n!==1009&&(this.fullscreenMaterial.defines.FRAMEBUFFER_PRECISION_HIGH=`1`)}dispose(){super.dispose();for(let e of this.effects)e.removeEventListener(`change`,this.listener),e.dispose()}handleEvent(e){switch(e.type){case`change`:this.recompile();break}}},oL=class extends IF{constructor(e,t,{renderTarget:n,resolutionScale:r=1,width:i=tI.AUTO_SIZE,height:a=tI.AUTO_SIZE,resolutionX:o=i,resolutionY:s=a}={}){super(`NormalPass`),this.needsSwap=!1,this.renderPass=new VI(e,t,new kl);let c=this.renderPass;c.ignoreBackground=!0,c.skipShadowMapUpdate=!0;let l=c.getClearPass();l.overrideClearColor=new K(7829503),l.overrideClearAlpha=1,this.renderTarget=n,this.renderTarget===void 0&&(this.renderTarget=new rr(1,1,{minFilter:k,magFilter:k}),this.renderTarget.texture.name=`NormalPass.Target`);let u=this.resolution=new tI(this,o,s,r);u.addEventListener(`change`,e=>this.setSize(u.baseWidth,u.baseHeight))}set mainScene(e){this.renderPass.mainScene=e}set mainCamera(e){this.renderPass.mainCamera=e}get texture(){return this.renderTarget.texture}getTexture(){return this.renderTarget.texture}getResolution(){return this.resolution}getResolutionScale(){return this.resolution.scale}setResolutionScale(e){this.resolution.scale=e}render(e,t,n,r,i){let a=this.renderToScreen?null:this.renderTarget;this.renderPass.render(e,a,a)}setSize(e,t){let n=this.resolution;n.setBaseSize(e,t),this.renderTarget.setSize(n.width,n.height)}};new Float32Array([0,0,0]),new Float32Array([1,0,0]),new Float32Array([1,1,0]),new Float32Array([1,1,1]),new Float32Array([0,0,0]),new Float32Array([1,0,0]),new Float32Array([1,0,1]),new Float32Array([1,1,1]),new Float32Array([0,0,0]),new Float32Array([0,0,1]),new Float32Array([1,0,1]),new Float32Array([1,1,1]),new Float32Array([0,0,0]),new Float32Array([0,1,0]),new Float32Array([1,1,0]),new Float32Array([1,1,1]),new Float32Array([0,0,0]),new Float32Array([0,1,0]),new Float32Array([0,1,1]),new Float32Array([1,1,1]),new Float32Array([0,0,0]),new Float32Array([0,0,1]),new Float32Array([0,1,1]),new Float32Array([1,1,1]),new Float32Array([0,-.25,.25,-.125,.125,-.375,.375]),new Float32Array([0,0]),new Float32Array([.25,-.25]),new Float32Array([-.25,.25]),new Float32Array([.125,-.125]),new Float32Array([-.125,.125]),new Uint8Array([0,0]),new Uint8Array([3,0]),new Uint8Array([0,3]),new Uint8Array([3,3]),new Uint8Array([1,0]),new Uint8Array([4,0]),new Uint8Array([1,3]),new Uint8Array([4,3]),new Uint8Array([0,1]),new Uint8Array([3,1]),new Uint8Array([0,4]),new Uint8Array([3,4]),new Uint8Array([1,1]),new Uint8Array([4,1]),new Uint8Array([1,4]),new Uint8Array([4,4]),new Uint8Array([0,0]),new Uint8Array([1,0]),new Uint8Array([0,2]),new Uint8Array([1,2]),new Uint8Array([2,0]),new Uint8Array([3,0]),new Uint8Array([2,2]),new Uint8Array([3,2]),new Uint8Array([0,1]),new Uint8Array([1,1]),new Uint8Array([0,3]),new Uint8Array([1,3]),new Uint8Array([2,1]),new Uint8Array([3,1]),new Uint8Array([2,3]),new Uint8Array([3,3]),cL(0,0,0,0),new Float32Array([0,0,0,0]),cL(0,0,0,1),new Float32Array([0,0,0,1]),cL(0,0,1,0),new Float32Array([0,0,1,0]),cL(0,0,1,1),new Float32Array([0,0,1,1]),cL(0,1,0,0),new Float32Array([0,1,0,0]),cL(0,1,0,1),new Float32Array([0,1,0,1]),cL(0,1,1,0),new Float32Array([0,1,1,0]),cL(0,1,1,1),new Float32Array([0,1,1,1]),cL(1,0,0,0),new Float32Array([1,0,0,0]),cL(1,0,0,1),new Float32Array([1,0,0,1]),cL(1,0,1,0),new Float32Array([1,0,1,0]),cL(1,0,1,1),new Float32Array([1,0,1,1]),cL(1,1,0,0),new Float32Array([1,1,0,0]),cL(1,1,0,1),new Float32Array([1,1,0,1]),cL(1,1,1,0),new Float32Array([1,1,1,0]),cL(1,1,1,1),new Float32Array([1,1,1,1]);function sL(e,t,n){return e+(t-e)*n}function cL(e,t,n,r){return sL(sL(e,t,.75),sL(n,r,.75),.875)}function lL(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}new W,new W;function uL(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}var dL=function e(t,n,r){var i=this;uL(this,e),lL(this,`dot2`,function(e,t){return i.x*e+i.y*t}),lL(this,`dot3`,function(e,t,n){return i.x*e+i.y*t+i.z*n}),this.x=t,this.y=n,this.z=r},fL=[new dL(1,1,0),new dL(-1,1,0),new dL(1,-1,0),new dL(-1,-1,0),new dL(1,0,1),new dL(-1,0,1),new dL(1,0,-1),new dL(-1,0,-1),new dL(0,1,1),new dL(0,-1,1),new dL(0,1,-1),new dL(0,-1,-1)],pL=[151,160,137,91,90,15,131,13,201,95,96,53,194,233,7,225,140,36,103,30,69,142,8,99,37,240,21,10,23,190,6,148,247,120,234,75,0,26,197,62,94,252,219,203,117,35,11,32,57,177,33,88,237,149,56,87,174,20,125,136,171,168,68,175,74,165,71,134,139,48,27,166,77,146,158,231,83,111,229,122,60,211,133,230,220,105,92,41,55,46,245,40,244,102,143,54,65,25,63,161,1,216,80,73,209,76,132,187,208,89,18,169,200,196,135,130,116,188,159,86,164,100,109,198,173,186,3,64,52,217,226,250,124,123,5,202,38,147,118,126,255,82,85,212,207,206,59,227,47,16,58,17,182,189,28,42,223,183,170,213,119,248,152,2,44,154,163,70,221,153,101,155,167,43,172,9,129,22,39,253,19,98,108,110,79,113,224,232,178,185,112,104,218,246,97,228,251,34,242,193,238,210,144,12,191,179,162,241,81,51,145,235,249,14,239,107,49,192,214,31,181,199,106,157,184,84,204,176,115,121,50,45,127,4,150,254,138,236,205,93,222,114,67,29,24,72,243,141,128,195,78,66,215,61,156,180],mL=Array(512),hL=Array(512);(function(e){e>0&&e<1&&(e*=65536),e=Math.floor(e),e<256&&(e|=e<<8);for(var t=0;t<256;t++){var n=t&1?pL[t]^e&255:pL[t]^e>>8&255;mL[t]=mL[t+256]=n,hL[t]=hL[t+256]=fL[n%12]}})(0),.5*(Math.sqrt(3)-1),(3-Math.sqrt(3))/6,Math.PI*2;function gL(e){if(typeof e==`number`)e=Math.abs(e);else if(typeof e==`string`){var t=e;e=0;for(var n=0;n(e.getAttributes()&2)==2,bL=(0,b.memo)((0,b.forwardRef)(({children:e,camera:t,scene:n,resolutionScale:r,enabled:i=!0,renderPriority:a=1,autoClear:o=!0,depthBuffer:s,enableNormalPass:c,stencilBuffer:l,multisampling:u=8,frameBufferType:d=ce},f)=>{let{gl:p,scene:m,camera:h,size:g}=N_(),_=n||m,v=t||h,[y,x,S]=(0,b.useMemo)(()=>{let e=new JF(p,{depthBuffer:s,stencilBuffer:l,multisampling:u,frameBufferType:d});e.addPass(new VI(_,v));let t=null,n=null;return c&&(n=new oL(_,v),n.enabled=!1,e.addPass(n),r!==void 0&&(t=new XI({normalBuffer:n.texture,resolutionScale:r}),t.enabled=!1,e.addPass(t))),[e,n,t]},[v,p,s,l,u,d,_,c,r]);(0,b.useEffect)(()=>y?.setSize(g.width,g.height),[y,g]),P_((e,t)=>{if(i){let e=p.autoClear;p.autoClear=o,l&&!o&&p.clearStencil(),y.render(t),p.autoClear=e}},i?a:0);let C=(0,b.useRef)(null);(0,b.useLayoutEffect)(()=>{let e=[],t=C.current.__r3f;if(t&&y){let n=t.children;for(let t=0;t{for(let t of e)y?.removePass(t);x&&(x.enabled=!1),S&&(S.enabled=!1)}},[y,e,v,x,S]),(0,b.useEffect)(()=>{let e=p.toneMapping;return p.toneMapping=0,()=>{p.toneMapping=e}},[p]);let w=(0,b.useMemo)(()=>({composer:y,normalPass:x,downSamplingPass:S,resolutionScale:r,camera:v,scene:_}),[y,x,S,r,v,_]);return(0,b.useImperativeHandle)(f,()=>y,[y]),(0,X.jsx)(vL.Provider,{value:w,children:(0,X.jsx)(`group`,{ref:C,children:e})})})),xL=0,SL=new WeakMap,CL=(e,t)=>function({blendFunction:n=t?.blendFunction,opacity:r=t?.opacity,...i}){let a=SL.get(e);if(!a){let t=`@react-three/postprocessing/${e.name}-${xL++}`;av({[t]:e}),SL.set(e,a=t)}let o=N_(e=>e.camera),s=b.useMemo(()=>[...t?.args??[],...i.args??[{...t,...i}]],[JSON.stringify(i)]);return(0,X.jsx)(a,{camera:o,"blendMode-blendFunction":n,"blendMode-opacity-value":r,...i,args:s})},wL=(0,b.forwardRef)(function({blendFunction:e,worldFocusDistance:t,worldFocusRange:n,focusDistance:r,focusRange:i,focalLength:a,bokehScale:o,resolutionScale:s,resolutionX:c,resolutionY:l,width:u,height:d,target:f,depthTexture:p,...m},h){let{camera:g}=(0,b.useContext)(vL),_=f!=null,v=(0,b.useMemo)(()=>{let f=new BI(g,{blendFunction:e,worldFocusDistance:t,worldFocusRange:n,focusDistance:r,focusRange:i,focalLength:a,bokehScale:o,resolutionScale:s,resolutionX:c,resolutionY:l,width:u,height:d});_&&(f.target=new G),p&&f.setDepthTexture(p.texture,p.packing);let m=f.maskPass;return m.maskFunction=AI.MULTIPLY_RGB_SET_ALPHA,f},[g,e,t,n,r,i,a,o,s,c,l,u,d,_,p]);return(0,b.useEffect)(()=>()=>{v.dispose()},[v]),(0,X.jsx)(`primitive`,{...m,ref:h,object:v,target:f})}),TL=CL(CI,{blendFunction:0}),EL=CL(TI),DL=CL(OI),OL=CL(UI),kL=CL(KI,{blendFunction:5}),AL=CL(QI),jL=.008,ML=.005,NL=.012,PL=.9,FL=.86;function IL({postFx:e,gameRef:t}){let n=(0,b.useRef)(null),r=(0,b.useRef)(null),i=(0,b.useRef)(null),a=(0,b.useRef)(null),o=(0,b.useRef)(0),s=t?.current?.qualityPreset||(typeof e?.quality==`string`?e.quality:`medium`),[c,l]=(0,b.useState)(s),u=e?.chromaticAberration?.offset??[5e-4,5e-4],d=Array.isArray(u)?new W(u[0]??0,u[1]??0):new W(5e-4,5e-4),f=e?.bloom||{},p=e?.vignette||{},m=e?.brightnessContrast||{},h=e?.saturation||{},g=e?.chromaticAberration||{},_=e?.noise||{},v=e?.depthOfField||{},y=p.darkness??.7,x=h.saturation??0,S=h.hue??0,C=m.brightness??0,w=m.contrast??0;P_((e,u)=>{let f=t?.current;if(!f)return;let p=f.qualityPreset||s;p!==c&&l(p),typeof f.vignettePulse!=`number`&&(f.vignettePulse=0),typeof f.critPulse!=`number`&&(f.critPulse=0),f.vignettePulse=Math.max(0,f.vignettePulse*PL),f.critPulse=Math.max(0,f.critPulse*FL);let m=n.current;if(m&&m.offset){let e=Math.max(0,f.screenShake||0)*ML,t=f.critPulse*NL,n=Math.min(jL,e+t);m.offset.set(d.x+n,d.y+n)}let h=Math.max(0,Math.min(1,f.lowHpFactor||0)),g=Math.min(1,u*4);o.current+=(h-o.current)*g;let _=o.current,v=i.current;v&&(v.saturation=x-_*.5,v.hue=S-_*.08);let b=a.current;b&&(b.brightness=C-_*.06,b.contrast=w+_*.06);let T=r.current;T&&(T.darkness=Math.min(1.2,y+f.vignettePulse+_*.18))});let T=v.enabled!==!1&&c!==`low`,E=(0,b.useMemo)(()=>{if(!e)return null;let t=[(0,X.jsx)(TL,{intensity:f.intensity??1.3,luminanceThreshold:f.luminanceThreshold??.35,luminanceSmoothing:f.luminanceSmoothing??.25,mipmapBlur:f.mipmapBlur??!0,radius:f.radius??.7,levels:f.levels??7},`bloom`),(0,X.jsx)(DL,{ref:n,offset:d,radialModulation:g.radialModulation??!1},`chroma`),(0,X.jsx)(OL,{ref:i,saturation:x,hue:S},`huesat`),(0,X.jsx)(EL,{ref:a,brightness:C,contrast:w},`brightcont`),(0,X.jsx)(kL,{opacity:_.opacity??.05,premultiply:_.premultiply??!0},`noise`),(0,X.jsx)(AL,{ref:r,eskil:p.eskil??!1,offset:p.offset??.3,darkness:y},`vignette`)];return T&&t.splice(1,0,(0,X.jsx)(wL,{focusDistance:v.focusDistance??.02,focalLength:v.focalLength??.05,bokehScale:v.bokehScale??1.5},`dof`)),t},[c,T,e]);return!e||!E?null:(0,X.jsx)(bL,{multisampling:0,children:E})}var LL=(0,b.createContext)(null);function RL(){let e=(0,b.useContext)(LL);if(!e)throw Error(`useVfx must be used within a VfxProvider`);return e}function zL(){let{particlesRef:e}=RL(),t=(0,b.useRef)(),n=(0,b.useRef)(new Float32Array(600)),r=(0,b.useRef)(new Float32Array(600)),i=(0,b.useRef)(new Float32Array(200)),a=(0,b.useRef)(new K);return P_((o,s)=>{if(!t.current)return;let c=e.current,l=Math.min(s,.05);for(let e=c.length-1;e>=0;e--){let t=c[e];t.x+=t.vx*l,t.y+=t.vy*l,t.z+=t.vz*l,t.type===`spark`?(t.vy-=9.8*l,t.life-=l*2.2):(t.vy*=.96,t.vx*=.96,t.vz*=.96,t.life-=l*1.4),t.life<=0&&c.splice(e,1)}let u=n.current,d=r.current,f=i.current;for(let e=0;e<200;e++)if(enew K,[]);return P_((r,i)=>{if(!t.current)return;let a=Math.min(i,.05),o=e.current;for(let e=o.length-1;e>=0;e--){let t=o[e];t.radius+=(t.maxRadius-t.radius)*4*a,t.life-=a*2.5,t.life<=0&&o.splice(e,1)}let s=t.current.children;for(let e=0;eArray.from({length:8}).map((e,t)=>(0,X.jsxs)(`mesh`,{rotation:[-Math.PI/2,0,0],visible:!1,children:[(0,X.jsx)(`ringGeometry`,{args:[.85,1,64]}),(0,X.jsx)(`meshBasicMaterial`,{transparent:!0,opacity:0,blending:2,depthWrite:!1,side:2})]},t)),[])})}function VL(){let{splattersRef:e}=RL(),t=(0,b.useRef)(),{camera:n}=N_(),r=(0,b.useMemo)(()=>new K,[]),i=(0,b.useMemo)(()=>new In,[]);return P_((a,o)=>{if(!t.current)return;let s=Math.min(o,.05),c=e.current;for(let e=c.length-1;e>=0;e--){let t=c[e];t.life-=s,t.life<=0&&c.splice(e,1)}let l=t.current.children;for(let e=0;eArray.from({length:8}).map((e,t)=>(0,X.jsxs)(`mesh`,{visible:!1,children:[(0,X.jsx)(`planeGeometry`,{args:[1,1]}),(0,X.jsx)(`meshBasicMaterial`,{transparent:!0,opacity:0,blending:2,depthWrite:!1,side:2})]},t)),[])})}var HL=.15,UL=1.5,WL=4,GL=25,KL=(0,b.forwardRef)((e,t)=>{let n=(0,b.useRef)([]),r=(0,b.useRef)(0),[,i]=(0,b.useState)(0),a=(0,b.useCallback)(()=>i(e=>e+1|0),[]);return(0,b.useImperativeHandle)(t,()=>({spawn:(e,t)=>{r.current+=1,n.current.push({id:r.current,position:[e[0],e[1]??1.2,e[2]??0],color:t||`#ff3344`,life:HL,maxLife:HL,intensity:UL}),a()},clear:()=>{n.current.length=0,a()}}),[a]),P_((e,t)=>{let r=n.current;if(r.length===0)return;let i=Math.min(t,.05),o=!1;for(let e=r.length-1;e>=0;e--){let t=r[e].life-i;t<=0?(r.splice(e,1),o=!0):t!==r[e].life&&(r[e].life=t,o=!0)}o&&a()}),(0,X.jsx)(X.Fragment,{children:n.current.map(e=>{let t=e.maxLife-e.life,n=e.intensity*Math.exp(-t*GL);return(0,X.jsx)(`pointLight`,{position:e.position,color:e.color,intensity:n,distance:WL,decay:2},e.id)})})});KL.displayName=`ImpactLights`;var qL=15,JL=10,YL=3.8,XL=9,ZL=100,QL=1.8,$L=1.2,eR=4,tR=.05,nR=.35,rR=2,iR=.7,aR=.7,oR=14;function sR(e){return[Math.max(-15,Math.min(qL,e[0]||0)),e[1]||0,Math.max(-10,Math.min(JL,e[2]||0))]}function cR(e,t){let n=(e[0]||0)-(t[0]||0),r=(e[2]||0)-(t[2]||0);return Math.sqrt(n*n+r*r)}var lR=.55;function uR(e,t,n,r){let i=cR(e,t),a=n??lR,o=r??lR;return Math.max(0,i-a-o)}function dR(e,t,n){return{position:[n,0,0],facing:t?1:-1,anim:`idle`,animProgress:0,isAttacking:!1,attackStartX:null,isBlocking:!1,isHit:!1,isPlayer:t,hp:ZL,stamina:WM.maxStamina,stateTimer:0,hitstun:0,hitstunDuration:0,comboCount:0,comboTimer:0,hitConnected:!1,velX:0,velZ:0,attackerPushbackTilt:0,knockbackTilt:0,config:e}}function fR(){return{round:1,playerScore:0,npcScore:0,time:0,roundOver:!1,gameOver:!1,winner:null,roundOverTimer:0,screenShake:0,freezeFrames:0,matchWinner:null,camRoll:0,camZoomPulse:0}}function pR({arena:e,playerCharacter:t,npcCharacter:n,onGameOver:r,onRoundEnd:i,onPause:a,paused:o=!1,modelReadyRef:s=null},c){let l=(0,b.useRef)(dR(t,!0,-5)),u=(0,b.useRef)(dR(n,!1,5)),d=(0,b.useRef)(fR()),f=(0,b.useRef)(EP()),p=(0,b.useRef)(EP()),m=(0,b.useRef)($N()),h=(0,b.useRef)(null),g=(0,b.useRef)(!1),_=(0,b.useRef)([]),v=(0,b.useRef)(`intro`),y=(0,b.useRef)(1.2),x=(0,b.useRef)(null),S=(0,b.useMemo)(()=>uN(n?.id),[n]),{spawnImpact:C,spawnShockwave:w,spawnSplatter:T,spawnFootstep:E}=RL(),D=(0,b.useCallback)((e,t)=>{E&&E(e);let n=t&&t.type;(n===`slide`||n===`landing`||n===`walk`)&&window.dispatchEvent(new CustomEvent(`game-vfx`,{detail:{type:n,position:e}}))},[E]),O=(0,b.useCallback)(e=>{E&&E(e),window.dispatchEvent(new CustomEvent(`game-vfx`,{detail:{type:`landing`,position:e}}))},[E]),k=(0,b.useMemo)(()=>e?e.component:null,[e]);(0,b.useImperativeHandle)(c,()=>({playerRef:l,npcRef:u,gameRef:d})),(0,b.useEffect)(()=>{let e=e=>{let t=e.detail?.counterMove||e.detail?.move;t&&(h.current=t)};return window.addEventListener(`ai-response`,e),()=>window.removeEventListener(`ai-response`,e)},[]),(0,b.useEffect)(()=>{let e=e=>{TP(e.key)&&e.preventDefault(),DP(f.current,e.key,!0)},t=e=>{DP(f.current,e.key,!1)};return window.addEventListener(`keydown`,e),window.addEventListener(`keyup`,t),()=>{window.removeEventListener(`keydown`,e),window.removeEventListener(`keyup`,t)}},[]);function A(){if(g.current)return;let e=_.current,r=e.slice(-5);r.length===0&&r.push(l.current.anim);let i=r.join(`,`),a=e.length>1?e[e.length-1]:``;if(!(s?.current===!0&&typeof window.sendAIRequest==`function`)){let t=l.current,n=u.current,r=uR(t.position,n.position),i=AN({anim:t.anim,animProgress:t.animProgress,isAttacking:t.isAttacking},r,n.stamina,S,e);i&&(h.current=i);return}g.current=!0;let o=l.current,c=u.current,f=uR(o.position,c.position),p=cP({sequence:i,playerCharacterId:t?.id,npcCharacterId:n?.id,round:d.current.round,distance:f,playerPrevMove:a,playerStamina:o.stamina,npcStamina:c.stamina});window.sendAIRequest(p).finally(()=>{g.current=!1})}function j(e,t){e.anim=t,e.animProgress=0,e.hitConnected=!1}function ee(e){let t=l.current;if(t.hitstun>0||t.isAttacking||t.hp<=0)return;let n={isGrappled:t.anim===`clinched`,isFatigued:t.stamina<20};if(!qM(e,t.stamina,n))return;t.stamina=YM(t.stamina,e,n),t.isAttacking=!0,t.isBlocking=!1,t.attackStartX=t.position[0],t.velX=0,j(t,e);let r=_.current;for(r.push(e);r.length>8;)r.shift();Math.random()<.7&&A()}function te(e){let t=u.current;if(t.hitstun>0||t.isAttacking||t.hp<=0)return;let n={isGrappled:t.anim===`clinched`,isFatigued:t.stamina<20};qM(e,t.stamina,n)&&(t.stamina=YM(t.stamina,e,n),t.isAttacking=!0,t.isBlocking=!1,t.attackStartX=t.position[0],t.velX=0,j(t,e))}function M(e,t,n,r){if(!(n.anim===`backstep`&&(n.stateTimer||0)>nR-tR))if(e.hit){n.hp=e.hpLeft,n.isHit=!0,setTimeout(()=>{n.isHit=!1},80);let i=e.reaction,a=BM[t.anim],o=!!a?.tags?.includes(`heavy`),s=e.counterHit||i===ZM.KNOCKDOWN||i===ZM.FALL,c=sN(i,o);n.hitstun=Math.max(n.hitstun,c),n.hitstunDuration=Math.max(n.hitstunDuration||0,n.hitstun),j(n,i===ZM.FALL?`fall`:i);let l=n.position[0]>t.position[0]?1:-1,u=e.knockback;if(u){let e=n.position[0]<=-13.5,t=n.position[0]>=qL-1.5,r=e||t;r&&(u*=.5),n.position[0]+=l*u,r&&(d.current.screenShake=Math.max(d.current.screenShake,.15),d.current.freezeFrames=Math.max(d.current.freezeFrames,.03))}a?.attackerPushback&&(t.position[0]-=l*a.attackerPushback);let f=s?.32:o?.26:.2;t.attackerPushbackTilt=Math.max(t.attackerPushbackTilt||0,f),n.knockbackTilt=Math.max(n.knockbackTilt||0,f+.05),t.comboCount+=1,t.comboTimer=$L;let p=[(t.position[0]+n.position[0])/2,1.2,(t.position[2]+n.position[2])/2];s&&(t.stamina=Math.min(WM.maxStamina,t.stamina+eR)),C(p,{count:s?34:o?22:14,isCrit:s,isPlayer:r,move:t.anim}),T(p,{isCrit:s,isPlayer:r,move:t.anim}),x.current&&x.current.spawn(p,t.config?.accentColor||`#ff3344`),(s||o)&&w(p,{isPlayer:r,maxRadius:s?3.8:2.4});let m=a?.shake??(s?.45:.22),h=a?.hitstop??(s?.08:.04),g=i===ZM.KNOCKDOWN||i===ZM.FALL?.04:0,_=s?.03:0;if(d.current.screenShake=Math.max(d.current.screenShake,m),d.current.freezeFrames=Math.max(d.current.freezeFrames,h+g+_),d.current.camRecoil||(d.current.camRecoil={x:0,y:0,intensity:0}),d.current.camRecoil.x=-l*(s?.3:.18)*(1+(o?.4:0)),d.current.camRecoil.y=s||o?.1:.05,d.current.camRecoil.intensity=1,i===ZM.KNOCKDOWN||i===ZM.FALL||t.anim===`roundhouse`||t.anim===`uppercut`||t.anim===`throw`){let e=s||o?.08:.05;d.current.camRoll=-l*e}s&&(d.current.camZoomPulse=.08),window.dispatchEvent(new CustomEvent(`game-vfx`,{detail:{type:`hit`,color:s?`#ffd700`:r?`#2ec4b6`:`#e71d36`,crit:s,heavy:o,position:p,groundSplatter:o}})),s&&window.dispatchEvent(new CustomEvent(`game-vfx`,{detail:{type:`screenFlash`,color:`#ffd700`,crit:!0,heavy:o}})),(i===ZM.KNOCKDOWN||i===ZM.FALL||t.anim===`throw`)&&window.dispatchEvent(new CustomEvent(`game-vfx`,{detail:{type:`heavyImpact`,position:p,color:s?`#ffd700`:`#ff3344`,crit:s,heavy:o}}))}else if(e.blocked){n.hp=e.hpLeft,n.stamina=e.staminaLeft;let i=BM[t.anim],a=i?.blockedShake??.1;d.current.screenShake=Math.max(d.current.screenShake,a),d.current.freezeFrames=Math.max(d.current.freezeFrames,i?.blockedHitstop??.03);let o=[(t.position[0]+n.position[0])/2,1.1,(t.position[2]+n.position[2])/2];if(C(o,{count:10,isPlayer:r,move:t.anim,isBlock:!0}),e.knockback){let r=n.position[0]>t.position[0]?1:-1;n.position[0]+=r*e.knockback,i?.attackerPushback&&(t.position[0]-=r*i.attackerPushback*.4)}window.dispatchEvent(new CustomEvent(`game-vfx`,{detail:{type:`blocked`,color:r?`#2ec4b6`:`#e71d36`,crit:!1,heavy:!1,position:o}}))}else e.parried&&(n.stamina=Math.min(WM.maxStamina,n.stamina+e.staminaReward),d.current.screenShake=Math.max(d.current.screenShake,.18),w(n.position,{isPlayer:!r,maxRadius:2.2}),window.dispatchEvent(new CustomEvent(`game-vfx`,{detail:{type:`parried`,color:r?`#e71d36`:`#2ec4b6`,crit:!1,heavy:!1,position:n.position}})))}function N(e,t,n){let r=BM[e.anim];if(!r||e.hitConnected)return;let i=VM(e.anim),a=e.animProgress*i;if(!(a>=r.startup&&a<=r.startup+r.active))return;let o=uR(e.position,t.position),s={comboCount:e.comboCount,defenderIsGrappled:t.anim===`clinched`};if(e.anim===`clinch`){let r=aN(e,t,o);r.success&&(e.hitConnected=!0,M(r,e,t,n));return}if(e.anim===`throw`){let r=oN(e,t,o);r.success&&(e.hitConnected=!0,M(r,e,t,n));return}let c=nN({move:e.anim,animProgress:e.animProgress,position:e.position,facing:e.facing,isAttacking:e.isAttacking},t,o,0,s);c.hit||c.blocked||c.parried?(e.hitConnected=!0,M(c,e,t,n)):c.reason}function P(e,t){if(e.hitstun>0){let n=e.hitstunDuration||.3;e.animProgress=n>0?Math.max(0,Math.min(1,1-e.hitstun/n)):0,e.hitstun-=t,e.hitstun<=0&&(e.hitstun=0,e.isAttacking=!1,e.isBlocking=!1,j(e,`idle`));return}if(e.anim===`block`&&e.isBlocking){e.animProgress=0;return}let n=VM(e.anim);n>0&&(e.animProgress+=t/n),e.animProgress>=1&&(e.anim===`walk`?e.animProgress%=1:(e.animProgress=0,e.isAttacking=!1,e.isBlocking=!1,e.anim=`idle`,e.hitConnected=!1))}function F(e){let a=d.current;if(e===`player`?a.playerScore+=1:e===`npc`&&(a.npcScore+=1),a.playerScore>=2||a.npcScore>=2){a.gameOver=!0,a.matchWinner=a.playerScore>=2?`player`:`npc`,r&&r(a.matchWinner);return}a.round+=1,a.roundOver=!1,a.roundOverTimer=0,a.winner=null,a.time=0,v.current=`intro`,y.current=1.2,l.current=dR(t,!0,-5),u.current=dR(n,!1,5),m.current=$N(),_.current=[],h.current=null,i&&i(a)}function ne(){let e=d.current;if(e.roundOver){e.roundOverTimer+=.016,e.roundOverTimer>=QL&&F(e.winner);return}l.current.hp<=0&&!e.roundOver?(e.roundOver=!0,e.winner=`npc`,j(l.current,`fall`),l.current.hitstun=1.5,l.current.hitstunDuration=1.5):u.current.hp<=0&&!e.roundOver&&(e.roundOver=!0,e.winner=`player`,j(u.current,`fall`),u.current.hitstun=1.5,u.current.hitstunDuration=1.5)}return P_((e,t)=>{if(o||d.current.gameOver)return;let r=Math.min(t,.05);if(d.current.freezeFrames>0){d.current.freezeFrames-=r;return}let i=r;if(v.current===`intro`){y.current-=i,y.current<=0&&(v.current=`fighting`);return}let s=l.current,c=u.current,g=d.current;g.time+=i;let b={...p.current};Object.assign(p.current,{...f.current});let x=f.current;if(MP(x,b)){a&&a();return}let C=kP(x,b);if(C&&!s.isAttacking&&s.hitstun<=0&&s.hp>0&&ee(C),s.hitstun<=0&&s.hp>0&&!s.isAttacking&&(x.block?(s.isBlocking=!0,s.anim=`block`,s.animProgress=0):s.isBlocking&&AP(x,b)&&(s.isBlocking=!1,j(s,`idle`))),jP(x,b)&&!s.isAttacking&&s.hitstun<=0&&s.hp>0){let e={isGrappled:c.anim===`clinch`,isFatigued:s.stamina<20};qM(`backstep`,s.stamina,e)&&(s.stamina=YM(s.stamina,`backstep`,e),j(s,`backstep`),s.stateTimer=nR,s.velX=0,s.velZ=0,s.isAttacking=!1)}if(s.hitstun<=0&&s.hp>0&&!s.isAttacking&&!s.isBlocking){let e=OP(x),t=e.x!==0||e.z!==0,n=0,r=0;if(t){let t=e.x>0&&s.facing<0||e.x<0&&s.facing>0,i=t?aR:1;qL-Math.abs(s.position[0]).01&&(s.facing=e.x>0?1:-1)):s.anim===`walk`&&Math.abs(s.velX)<.1&&Math.abs(s.velZ)<.1&&(s.anim=`idle`,s.animProgress=0)}else s.velX+=(0-s.velX)*oR*i,s.velZ+=(0-s.velZ)*oR*i;if(s.anim===`backstep`&&s.stateTimer>0){s.stateTimer-=i;let e=nR-s.stateTimer;e>=tR&&e<.22999999999999998&&(s.position[0]+=-s.facing*XL*i),s.stateTimer<=0&&j(s,`idle`)}if(s.stamina=KM(s.stamina,i,{isBlocking:s.isBlocking,isAttacking:s.isAttacking,isHit:s.isHit,isGrappled:s.anim===`clinched`}),c.stamina=KM(c.stamina,i,{isBlocking:c.isBlocking,isAttacking:c.isAttacking,isHit:c.isHit,isGrappled:c.anim===`clinched`}),c.hp>0&&c.hitstun<=0){let e=ZN({game:g,archetype:S,npcCharacterId:n?.id,playerHistory:_.current.slice(-5),player:{position:s.position,facing:s.facing,anim:s.anim,animProgress:s.animProgress,isAttacking:s.isAttacking,hp:s.hp,stamina:s.stamina},npc:{position:c.position,facing:c.facing,anim:c.anim,animProgress:c.animProgress,isAttacking:c.isAttacking,hp:c.hp,stamina:c.stamina,state:c.state,stateTimer:c.stateTimer},pendingGemmaMove:h.current,ai:m.current,dt:i},{arenaHalfWidth:qL,arenaHalfDepth:JL});if(m.current=e.ai||m.current,h.current=null,c.facing=e.facing??c.facing,c.state=e.state||c.state,e.move&&e.state===BN.ATTACKING?c.isAttacking||te(e.move):e.move===`parry`?!c.isAttacking&&c.anim!==`parry`&&(c.stamina=YM(c.stamina,`parry`),j(c,`parry`),c.stateTimer=e.duration||.32):e.move===`backstep`?c.anim!==`backstep`&&(c.stamina=YM(c.stamina,`backstep`),j(c,`backstep`),c.stateTimer=e.duration||nR):e.move===`clinch`?c.isAttacking||te(`clinch`):e.move===`throw`?c.isAttacking||te(`throw`):e.state===BN.BLOCKING?(c.isBlocking=!0,c.anim=`block`,c.animProgress=0,c.stateTimer=e.duration||.55):e.velocity?(c.velX=e.velocity[0]*YL,c.velZ=e.velocity[2]*YL,c.position[0]+=c.velX*i,c.position[2]+=c.velZ*i,e.anim&&(c.anim=e.anim)):(c.velX+=(0-c.velX)*oR*i,c.velZ+=(0-c.velZ)*oR*i),c.isAttacking&&c.attackStartX!=null){let e=BM[c.anim];if(e){let t=e.startup+e.active+e.recovery;(c.animProgress||0)*t<=e.startup+e.active?(c.position[0]=c.attackStartX,c.velX=0):c.attackStartX=null}}}if(c.stateTimer>0&&(c.stateTimer-=i,c.stateTimer<=0&&(c.isBlocking=!1,j(c,`idle`))),c.anim===`backstep`&&c.stateTimer>0){let e=nR-c.stateTimer;e>=tR&&e<.22999999999999998&&(c.position[0]+=-c.facing*XL*i)}s.position=sR(s.position),c.position=QN(c.position,{arenaHalfWidth:qL,arenaHalfDepth:JL}),s.hp>0&&(s.facing=s.position[0]0&&(c.facing=c.position[0]0&&(s.comboTimer-=i,s.comboTimer<=0&&(s.comboCount=0)),c.comboTimer>0&&(c.comboTimer-=i,c.comboTimer<=0&&(c.comboCount=0)),ne()}),(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(PM,{pixelated:!0}),(0,X.jsx)(`color`,{attach:`background`,args:[e?.fog?.color||`#05040a`]}),e?.fog&&(0,X.jsx)(`fog`,{attach:`fog`,args:[e.fog.color,e.fog.near,e.fog.far]}),(0,X.jsx)(PF,{playerRef:l,npcRef:u,gameRef:d}),k&&(0,X.jsx)(k,{arena:e}),(0,X.jsx)(jF,{stateRef:l,character:t,isPlayer:!0,onFootstep:D,onBackstepLanding:O}),(0,X.jsx)(jF,{stateRef:u,character:n,isPlayer:!1,onFootstep:D,onBackstepLanding:O}),(0,X.jsx)(zL,{}),(0,X.jsx)(BL,{}),(0,X.jsx)(VL,{}),(0,X.jsx)(KL,{ref:x}),(0,X.jsx)(IL,{postFx:e?.postFx,gameRef:d})]})}var mR=(0,b.forwardRef)(pR),hR=`DUEL OF ALBION`,gR=`A Fable of Blade and Shadow`,_R=[{label:`DUEL`,active:!0,hint:`Begin a new battle`,badge:null,variant:`primary`},{label:`FORGE`,active:!0,hint:`Preview your warrior`,badge:`Preview`,variant:`muted`},{label:`CODEX`,active:!0,hint:`Bestiary of shadows`,badge:`Bestiary`,variant:`muted`},{label:`SETTINGS`,active:!0,hint:`Tweak the duel`,badge:`Quick`,variant:`muted`}],vR=Array.from({length:38}).map((e,t)=>({id:t,left:Math.random()*100,size:1.2+Math.random()*2.4,duration:8+Math.random()*9,delay:Math.random()*8,drift:-40+Math.random()*80,opacity:.4+Math.random()*.5,isAsh:Math.random()>.55})),yR={hidden:{opacity:0},visible:{opacity:1,transition:{staggerChildren:.05,delayChildren:.3}}},bR={hidden:{opacity:0,clipPath:`inset(0 100% 0 0)`},visible:{opacity:1,clipPath:`inset(0 0% 0 0)`,transition:{duration:.7,ease:[.22,1,.36,1]}}},xR=({className:e,style:t})=>(0,X.jsxs)(`svg`,{className:e,width:`140`,height:`140`,viewBox:`0 0 140 140`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,style:t,children:[(0,X.jsx)(`path`,{d:`M10 130 C30 90, 10 70, 50 50 C90 30, 110 50, 130 10`,stroke:`currentColor`,strokeWidth:`1.5`,fill:`none`}),(0,X.jsx)(`path`,{d:`M20 130 C35 100, 25 85, 55 70 C80 55, 100 70, 120 35`,stroke:`currentColor`,strokeWidth:`1`,fill:`none`,opacity:`0.6`}),(0,X.jsx)(`circle`,{cx:`130`,cy:`10`,r:`3`,fill:`currentColor`}),(0,X.jsx)(`circle`,{cx:`10`,cy:`130`,r:`3`,fill:`currentColor`})]}),SR=()=>(0,X.jsxs)(`svg`,{className:`pointer-events-none absolute inset-0 h-full w-full opacity-[0.08]`,children:[(0,X.jsxs)(`filter`,{id:`grain`,children:[(0,X.jsx)(`feTurbulence`,{type:`fractalNoise`,baseFrequency:`0.8`,numOctaves:`4`,stitchTiles:`stitch`}),(0,X.jsx)(`feColorMatrix`,{type:`saturate`,values:`0`})]}),(0,X.jsx)(`rect`,{width:`100%`,height:`100%`,filter:`url(#grain)`})]}),CR=()=>(0,X.jsx)(`div`,{className:`ember-layer`,children:vR.map(e=>(0,X.jsx)(`span`,{className:`ember ${e.isAsh?`ember-ash`:``}`,style:{left:`${e.left}%`,width:`${e.size}px`,height:`${e.size}px`,animationDuration:`${e.duration}s`,animationDelay:`${e.delay}s`,opacity:e.opacity,"--drift":`${e.drift}px`}},e.id))}),wR=({label:e,active:t,onClick:n,delay:r,hint:i,badge:a,variant:o=`primary`})=>(0,X.jsxs)(Q.button,{initial:{opacity:0,y:24},animate:{opacity:1,y:0},transition:{delay:r,duration:.6,ease:[.22,1,.36,1]},disabled:!t,onClick:n,className:` group relative w-80 px-8 py-4 text-center font-title tracking-[0.28em] transition-all duration-300 ease-out ${t?o===`primary`?`cursor-pointer text-gold-bright hover:-translate-y-1`:`cursor-pointer text-parchment-dim hover:-translate-y-0.5 hover:text-parchment`:`cursor-not-allowed text-parchment-dark/35`} `,style:{fontSize:t?`1.4rem`:`0.95rem`,letterSpacing:t?`0.32em`:`0.28em`},children:[t?o===`primary`?(0,X.jsx)(`span`,{className:`absolute inset-0 rounded-sm border border-gold/50 bg-gradient-to-b from-ink-800/70 to-ink-900/80 transition-all duration-300 group-hover:border-gold group-hover:from-ink-700/80 group-hover:to-ink-800/80 group-hover:shadow-[0_0_24px_2px_rgba(212,175,55,0.35)]`}):(0,X.jsx)(`span`,{className:`absolute inset-0 rounded-sm border border-parchment-dark/35 bg-gradient-to-b from-ink-800/40 to-ink-900/60 transition-all duration-300 group-hover:border-parchment-dim/70 group-hover:from-ink-700/60 group-hover:to-ink-800/60 group-hover:shadow-[0_0_16px_2px_rgba(184,168,138,0.18)]`}):(0,X.jsx)(`span`,{className:`absolute inset-0 rounded-sm border border-gold/10 bg-ink-900/30`}),t&&o===`primary`&&(0,X.jsx)(`span`,{className:`absolute inset-0 -translate-x-full bg-gradient-to-r from-transparent via-gold/15 to-transparent transition-transform duration-1000 group-hover:translate-x-full`}),t&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`absolute inset-x-0 bottom-0 h-[1px] scale-x-0 bg-gradient-to-r from-transparent via-gold to-transparent transition-transform duration-500 group-hover:scale-x-100`}),(0,X.jsx)(`span`,{className:`absolute inset-x-0 top-0 h-[1px] scale-x-0 bg-gradient-to-r from-transparent ${o===`primary`?`via-gold/60`:`via-parchment-dark/50`} to-transparent transition-transform duration-700 group-hover:scale-x-100`})]}),(0,X.jsx)(`span`,{className:`relative drop-shadow-md transition-all duration-300 ${t?o===`primary`?`group-hover:[text-shadow:0_0_14px_rgba(212,175,55,0.9),0_0_28px_rgba(212,175,55,0.5)]`:`group-hover:[text-shadow:0_0_8px_rgba(184,168,138,0.45)]`:``}`,children:e}),a&&t&&(0,X.jsx)(`span`,{className:`pointer-events-none absolute -bottom-3 left-1/2 -translate-x-1/2 rounded-sm border px-2 py-0.5 text-[9px] font-bold uppercase tracking-[0.3em] shadow-[0_0_8px_rgba(212,175,55,0.25)] ${o===`primary`?`border-gold/45 bg-ink-900/85 text-gold-bright`:`border-parchment-dark/40 bg-ink-900/85 text-parchment-dim`}`,style:{fontFamily:`var(--font-fantasy)`},children:a}),t&&o===`primary`&&(0,X.jsx)(`span`,{className:`pointer-events-none absolute -right-12 top-1/2 -translate-y-1/2 text-xs font-body italic text-gold/60 opacity-0 transition-opacity duration-300 group-hover:opacity-100`,children:i}),t&&o===`muted`&&(0,X.jsx)(`span`,{className:`pointer-events-none absolute -bottom-7 left-1/2 -translate-x-1/2 whitespace-nowrap text-[10px] font-body italic tracking-[0.25em] text-parchment-dark/70`,children:i})]});function TR({onStart:e,onOpenForge:t,onOpenCodex:n,onOpenSettings:r}){let i=(0,b.useRef)(null),[a,o]=(0,b.useState)({x:0,y:0}),s={DUEL:e,FORGE:t,CODEX:n,SETTINGS:r};return(0,b.useEffect)(()=>{let e=e=>{if(!i.current)return;let t=i.current.getBoundingClientRect();o({x:(e.clientX-t.left)/t.width-.5,y:(e.clientY-t.top)/t.height-.5})};return window.addEventListener(`mousemove`,e),()=>window.removeEventListener(`mousemove`,e)},[]),(0,X.jsxs)(`div`,{ref:i,className:`fixed inset-0 z-[100] flex items-center justify-center overflow-hidden bg-ink-900 font-body`,children:[(0,X.jsx)(`div`,{className:`pointer-events-none absolute inset-0 z-[1]`,style:{background:`radial-gradient(circle at 50% 40%, transparent 0%, rgba(5,4,10,0.4) 50%, rgba(5,4,10,0.92) 100%)`}}),(0,X.jsx)(SR,{}),(0,X.jsx)(CR,{}),(0,X.jsx)(xR,{className:`filigree-corner absolute left-6 top-6 z-[2] text-gold/60`,style:{transform:`translate(${a.x*-10}px, ${a.y*-10}px)`}}),(0,X.jsx)(xR,{className:`filigree-corner absolute right-6 top-6 z-[2] rotate-90 text-gold/60`,style:{transform:`rotate(90deg) translate(${a.x*-10}px, ${a.y*-10}px)`}}),(0,X.jsx)(xR,{className:`filigree-corner absolute bottom-6 left-6 z-[2] -rotate-90 text-gold/60`,style:{transform:`rotate(-90deg) translate(${a.x*10}px, ${a.y*10}px)`}}),(0,X.jsx)(xR,{className:`filigree-corner absolute bottom-6 right-6 z-[2] rotate-180 text-gold/60`,style:{transform:`rotate(180deg) translate(${a.x*10}px, ${a.y*10}px)`}}),(0,X.jsxs)(`div`,{className:`relative z-10 flex flex-col items-center text-center`,children:[(0,X.jsxs)(Q.div,{initial:{opacity:0,y:-8},animate:{opacity:1,y:0},transition:{delay:.2,duration:.6},className:`mb-3 flex items-center gap-3 font-body text-xs uppercase tracking-[0.5em] text-parchment-dark`,children:[(0,X.jsx)(`span`,{className:`h-[1px] w-10 bg-gold/40`}),`Chapter I`,(0,X.jsx)(`span`,{className:`h-[1px] w-10 bg-gold/40`})]}),(0,X.jsx)(Q.h1,{variants:yR,initial:`hidden`,animate:`visible`,className:`mb-4 flex flex-wrap justify-center font-title text-6xl tracking-[0.12em] sm:text-7xl md:text-8xl`,children:hR.split(``).map((e,t)=>(0,X.jsx)(Q.span,{variants:bR,className:`text-glow-gold-sheen inline-block`,children:e===` `?`\xA0`:e},t))}),(0,X.jsx)(Q.p,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{delay:1.1,duration:.8},className:`mb-3 font-body text-xl italic tracking-wide text-parchment-dim sm:text-2xl`,children:gR}),(0,X.jsx)(Q.p,{initial:{opacity:0},animate:{opacity:.6},transition:{delay:1.4,duration:.8},className:`mb-10 font-brush text-2xl text-gold-dim`,style:{fontFamily:`var(--font-brush)`},children:`~ choose thy fate ~`}),(0,X.jsx)(Q.div,{initial:{scaleX:0},animate:{scaleX:1},transition:{delay:1.3,duration:.8,ease:[.22,1,.36,1]},className:`mb-10 h-[1px] w-72 bg-gradient-to-r from-transparent via-gold/70 to-transparent`}),(0,X.jsx)(`nav`,{className:`flex flex-col items-center gap-7`,children:_R.map((e,t)=>(0,X.jsx)(wR,{label:e.label,active:e.active,hint:e.hint,badge:e.badge,variant:e.variant,onClick:e.active?s[e.label]:void 0,delay:1.5+t*.1},e.label))}),(0,X.jsx)(Q.div,{initial:{opacity:0},animate:{opacity:1},transition:{delay:2.2,duration:1},className:`mt-14`,children:(0,X.jsxs)(Q.p,{animate:{opacity:[.45,1,.45]},transition:{duration:2.2,repeat:1/0,ease:`easeInOut`},className:`flex items-center gap-3 font-body text-sm tracking-[0.3em] text-parchment-dark`,children:[(0,X.jsx)(`span`,{className:`h-[1px] w-8 bg-gold/40`}),`CLICK TO DUEL`,(0,X.jsx)(`span`,{className:`h-[1px] w-8 bg-gold/40`})]})})]})]})}var ER=[{anim:`idle`,duration:1.1},{anim:`walk`,duration:1},{anim:`jab`,duration:.55},{anim:`cross`,duration:.62},{anim:`backstep`,duration:.44},{anim:`roundhouse`,duration:.9},{anim:`idle`,duration:.8}],DR=ER.reduce((e,t)=>e+t.duration,0);function OR({stateRef:e,characterId:t}){let n=(0,b.useRef)(0);return(0,b.useEffect)(()=>{n.current=performance.now()/1e3},[t]),P_(t=>{let r=((t.clock.elapsedTime-n.current)%DR+DR)%DR,i=0,a=ER[0];for(let e of ER){if(r>=i&&r{e.toneMapping=4,e.toneMappingExposure=1.05,e.shadowMap.type=2},children:[(0,X.jsx)(`color`,{attach:`background`,args:[{temple:`#05040a`,bamboo:`#0d1f17`,coliseum:`#2a1c4a`,shrine:`#0a1424`}[t]||`#05040a`]}),(0,X.jsx)(MM,{preset:`warehouse`,environmentIntensity:.55}),(0,X.jsx)(`ambientLight`,{intensity:.18,color:`#f0e6d2`}),(0,X.jsx)(`directionalLight`,{position:[2.5,5.2,3.4],intensity:2.1,color:`#f0e6d2`,castShadow:!0,"shadow-mapSize-width":1024,"shadow-mapSize-height":1024}),(0,X.jsx)(`pointLight`,{position:[-2.4,2.2,2.2],intensity:1.4,color:e?.glowColor||`#d4af37`,distance:8,decay:2}),(0,X.jsx)(`pointLight`,{position:[1.6,.8,-1.4],intensity:.5,color:`#6ecfff`,distance:5,decay:2}),(0,X.jsx)(OR,{stateRef:n,characterId:e?.id}),(0,X.jsxs)(`mesh`,{rotation:[-Math.PI/2,0,0],position:[0,-.03,0],receiveShadow:!0,children:[(0,X.jsx)(`circleGeometry`,{args:[1.7,64]}),(0,X.jsx)(`meshStandardMaterial`,{color:`#17111d`,roughness:.86,metalness:.12,emissive:e?.glowColor||`#d4af37`,emissiveIntensity:.05})]}),(0,X.jsx)(NM,{position:[0,.01,0],opacity:.48,scale:3.7,blur:2.4,far:2.4,color:`#020106`}),(0,X.jsx)(jF,{stateRef:n,character:e,isPlayer:!0})]})})}var AR={primary:`btn-primary`,secondary:`btn-secondary`,danger:`btn-danger`,ghost:`btn-ghost`},jR={sm:`btn-size-sm`,md:`btn-size-md`,lg:`btn-size-lg`},MR={sm:void 0,md:160,lg:220},NR=(0,b.forwardRef)(function({variant:e=`primary`,size:t=`md`,icon:n,iconRight:r,children:i,onClick:a,disabled:o=!1,type:s=`button`,className:c=``,style:l,withSheen:u=!0,ariaLabel:d,...f},p){let m=AR[e]??AR.primary,h=jR[t]??jR.md,g=MR[t],_=e===`primary`?`via-gold/30`:e===`danger`?`via-[rgba(231,29,54,0.18)]`:`via-parchment/10`,v={fontFamily:`var(--font-title)`,...g?{minWidth:`${g}px`}:{},...l};return(0,X.jsxs)(`button`,{ref:p,type:s,onClick:a,disabled:o,"aria-label":d,className:`btn-base ${m} ${h} group ${c}`,style:v,...f,children:[u&&(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`btn-sheen bg-gradient-to-r from-transparent ${_} to-transparent`}),n&&(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`relative inline-flex shrink-0`,children:n}),(0,X.jsx)(`span`,{className:`relative inline-flex items-center`,children:i}),r&&(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`relative inline-flex shrink-0`,children:r})]})}),PR={hidden:{opacity:0},visible:{opacity:1,transition:{duration:.5,staggerChildren:.08}},exit:{opacity:0,transition:{duration:.3}}},FR={hidden:{opacity:0,y:30,scale:.96},visible:{opacity:1,y:0,scale:1,transition:{duration:.55,ease:[.22,1,.36,1]}}},IR={hidden:{opacity:0,y:-20,filter:`blur(8px)`},visible:{opacity:1,y:0,filter:`blur(0px)`,transition:{duration:.8,ease:[.22,1,.36,1]}}},LR=({stats:e,color:t,size:n=160})=>{let r=[`STR`,`SPD`,`DEF`,`SHD`],i=[Math.max(10,Math.min(100,e?.strength??50)),Math.max(10,Math.min(100,e?.speed??50)),Math.max(10,Math.min(100,e?.defense??50)),Math.max(10,Math.min(100,e?.shadow??50))],a=n/2,o=n/2,s=n/2-18,c=[.25,.5,.75,1],l=(e,t)=>{let n=Math.PI*2*e/4-Math.PI/2;return{x:a+Math.cos(n)*s*t,y:o+Math.sin(n)*s*t}},u=i.map((e,t)=>{let n=l(t,e/100);return`${n.x},${n.y}`}).join(` `);return(0,X.jsxs)(`svg`,{width:n,height:n,viewBox:`0 0 ${n} ${n}`,className:`overflow-visible`,children:[c.map((e,t)=>(0,X.jsx)(`polygon`,{points:[0,1,2,3].map(t=>{let n=l(t,e);return`${n.x},${n.y}`}).join(` `),fill:`none`,stroke:`rgba(212,175,55,0.25)`,strokeWidth:`0.8`},t)),[0,1,2,3].map(e=>{let t=l(e,1);return(0,X.jsx)(`line`,{x1:a,y1:o,x2:t.x,y2:t.y,stroke:`rgba(212,175,55,0.18)`,strokeWidth:`0.6`},e)}),(0,X.jsx)(`polygon`,{points:u,fill:t,fillOpacity:`0.18`,stroke:t,strokeWidth:`1.5`,style:{filter:`drop-shadow(0 0 6px ${t}66)`}}),i.map((e,n)=>{let r=l(n,e/100);return(0,X.jsx)(`circle`,{cx:r.x,cy:r.y,r:`2`,fill:t},n)}),[0,1,2,3].map(e=>{let t=l(e,1.18);return(0,X.jsx)(`text`,{x:t.x,y:t.y,textAnchor:`middle`,dominantBaseline:`middle`,fontSize:`9`,fontFamily:`var(--font-fantasy)`,fontWeight:`700`,fill:`rgba(240,230,210,0.75)`,letterSpacing:`0.1em`,children:r[e]},e)})]})},RR=({kind:e,color:t})=>{let n={width:16,height:16,viewBox:`0 0 24 24`,fill:`none`,stroke:t,strokeWidth:1.6,strokeLinecap:`round`,strokeLinejoin:`round`};switch(e){case`strength`:return(0,X.jsxs)(`svg`,{...n,children:[(0,X.jsx)(`path`,{d:`M14.5 17.5 3 6V3h3l11.5 11.5`}),(0,X.jsx)(`path`,{d:`M13 19l6-6`})]});case`speed`:return(0,X.jsxs)(`svg`,{...n,children:[(0,X.jsx)(`path`,{d:`M3 12c5-7 13-7 18 0`}),(0,X.jsx)(`path`,{d:`M3 12c5 7 13 7 18 0`}),(0,X.jsx)(`path`,{d:`M12 4v16`})]});case`defense`:return(0,X.jsx)(`svg`,{...n,children:(0,X.jsx)(`path`,{d:`M12 2l8 4v6c0 5-3.5 8.5-8 10-4.5-1.5-8-5-8-10V6l8-4z`})});case`shadow`:return(0,X.jsxs)(`svg`,{...n,children:[(0,X.jsx)(`path`,{d:`M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7S2 12 2 12z`}),(0,X.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`})]});default:return null}};function zR({characters:e=[],selectedId:t,onSelect:n,onConfirm:r,onBack:i}){let a=e.find(e=>e.id===t)||e[0],[o,s]=(0,b.useState)(null);return(0,X.jsxs)(Q.div,{variants:PR,initial:`hidden`,animate:`visible`,exit:`exit`,className:`fixed inset-0 z-[100] flex items-center justify-center overflow-hidden bg-ink-900/95 font-body backdrop-blur-sm`,children:[(0,X.jsx)(`div`,{className:`pointer-events-none absolute inset-0 z-[1]`,style:{background:`radial-gradient(circle at 50% 40%, transparent 0%, rgba(5,4,10,0.4) 50%, rgba(5,4,10,0.92) 100%)`}}),(0,X.jsx)(`div`,{className:`pointer-events-none absolute top-0 left-0 z-[2] h-1 w-full bg-gradient-to-r from-transparent via-gold/60 to-transparent`}),(0,X.jsxs)(`div`,{className:`relative z-10 flex h-full w-full max-w-7xl flex-col px-6 py-6 md:px-10`,children:[(0,X.jsxs)(`div`,{className:`mb-4 flex flex-col items-center text-center`,children:[(0,X.jsx)(Q.h1,{variants:IR,className:`font-title text-4xl tracking-[0.18em] text-gold sm:text-5xl md:text-6xl`,style:{textShadow:`0 2px 24px rgba(0,0,0,0.9), 0 0 30px rgba(212,175,55,0.35)`,fontFamily:`var(--font-title)`},children:`Choose Your Shadow`}),(0,X.jsx)(Q.div,{initial:{scaleX:0},animate:{scaleX:1},transition:{delay:.5,duration:.8},className:`mt-3 h-[1px] w-56 bg-gradient-to-r from-transparent via-gold/70 to-transparent`}),(0,X.jsx)(Q.p,{initial:{opacity:0},animate:{opacity:.6},transition:{delay:.8,duration:.6},className:`mt-2 text-xs uppercase tracking-[0.4em] text-parchment-dark`,style:{fontFamily:`var(--font-fantasy)`},children:`four souls · one blade`})]}),(0,X.jsxs)(`div`,{className:`flex flex-1 flex-col gap-5 overflow-hidden md:flex-row`,children:[(0,X.jsx)(Q.div,{variants:PR,className:`flex flex-1 flex-wrap content-start gap-3 overflow-y-auto pr-1 md:grid md:grid-cols-2`,children:e.map(e=>{let r=e.id===t,i=e.id===o;return(0,X.jsxs)(Q.button,{variants:FR,onClick:()=>n(e.id),onMouseEnter:()=>s(e.id),onMouseLeave:()=>s(null),className:` group relative flex flex-col items-start gap-2 rounded-sm border p-3 text-left transition-all duration-300 ${r?`border-gold/80 bg-gradient-to-br from-ink-700/95 to-ink-800/95`:`border-gold/20 bg-ink-800/60 hover:border-gold/50 hover:bg-ink-700/70`} ${r?`float-up -translate-y-1`:``} `,style:{minWidth:200,boxShadow:r?`0 0 24px 2px ${e.glowColor}55, 0 0 32px rgba(212,175,55,0.25), inset 0 0 0 1px rgba(212,175,55,0.4)`:i?`0 0 14px 1px ${e.glowColor}33`:void 0,transform:i&&!r?`scale(1.02)`:r?`translateY(-4px) scale(1.02)`:void 0,transition:`all 0.3s cubic-bezier(0.22, 1, 0.36, 1)`},children:[(0,X.jsx)(`span`,{className:`absolute -left-px -top-px h-5 w-5 border-l-2 border-t-2 border-gold transition-opacity duration-300`,style:{opacity:r||i?1:.4}}),(0,X.jsx)(`span`,{className:`absolute -bottom-px -right-px h-5 w-5 border-b-2 border-r-2 border-gold transition-opacity duration-300`,style:{opacity:r||i?1:.4}}),(0,X.jsx)(`span`,{className:`absolute -right-px -top-px h-3 w-3 border-r-2 border-t-2 border-gold/60 transition-opacity duration-300`,style:{opacity:+!!r}}),(0,X.jsx)(`span`,{className:`absolute -bottom-px -left-px h-3 w-3 border-b-2 border-l-2 border-gold/60 transition-opacity duration-300`,style:{opacity:+!!r}}),(0,X.jsxs)(`div`,{className:`flex w-full items-center justify-between`,children:[(0,X.jsx)(`h3`,{className:`font-title text-lg tracking-widest transition-all duration-300`,style:{fontFamily:`var(--font-title)`,color:r||i?`#f9d76c`:`var(--color-parchment)`,textShadow:i||r?`0 0 12px ${e.glowColor}, 0 0 20px rgba(212,175,55,0.4), 0 2px 8px rgba(0,0,0,0.8)`:`0 2px 8px rgba(0,0,0,0.8)`},children:e.name}),(0,X.jsx)(`span`,{className:`h-3 w-3 rounded-full`,style:{backgroundColor:e.glowColor,boxShadow:r?`0 0 12px ${e.glowColor}, 0 0 24px ${e.glowColor}`:`0 0 8px ${e.glowColor}`}})]}),(0,X.jsx)(`p`,{className:`text-xs italic text-parchment-dim`,style:{fontFamily:`var(--font-body)`},children:e.style}),(0,X.jsx)(`div`,{className:`mt-1 flex w-full items-center justify-center`,children:(0,X.jsx)(LR,{stats:e.stats,color:e.glowColor,size:120})})]},e.id)})}),(0,X.jsxs)(Q.div,{initial:{opacity:0,x:40},animate:{opacity:1,x:0},transition:{delay:.4,duration:.7},className:`flex h-[460px] w-full flex-col gap-4 md:h-auto md:w-[460px] lg:w-[500px]`,children:[(0,X.jsxs)(`div`,{className:`relative flex-[1.6] overflow-hidden rounded-sm border bg-ink-800/40 p-1 shadow-[0_12px_50px_rgba(0,0,0,0.55)]`,style:{borderColor:a?.glowColor?`${a.glowColor}80`:`rgba(212,175,55,0.4)`,boxShadow:`0 12px 50px rgba(0,0,0,0.55), 0 0 30px ${a?.glowColor||`#d4af37`}33`,minHeight:340},children:[(0,X.jsx)(`span`,{className:`pointer-events-none absolute left-1 top-1 z-[2] h-4 w-4 border-l-2 border-t-2 border-gold/70`}),(0,X.jsx)(`span`,{className:`pointer-events-none absolute right-1 top-1 z-[2] h-4 w-4 border-r-2 border-t-2 border-gold/70`}),(0,X.jsx)(`span`,{className:`pointer-events-none absolute bottom-1 left-1 z-[2] h-4 w-4 border-b-2 border-l-2 border-gold/70`}),(0,X.jsx)(`span`,{className:`pointer-events-none absolute bottom-1 right-1 z-[2] h-4 w-4 border-b-2 border-r-2 border-gold/70`}),(0,X.jsx)(kR,{character:a})]}),(0,X.jsxs)(`div`,{className:`relative flex-shrink-0 rounded-sm border border-[rgba(138,110,32,0.4)] p-4`,style:{background:`linear-gradient(135deg, rgba(240,230,210,0.95), rgba(209,191,160,0.92))`,boxShadow:`0 8px 24px rgba(0,0,0,0.55), inset 0 1px 0 rgba(255,255,255,0.25)`,color:`#05040a`},children:[(0,X.jsx)(`span`,{className:`pointer-events-none absolute left-1 top-1 h-3 w-3 border-l-2 border-t-2 border-[#8a6e20]`}),(0,X.jsx)(`span`,{className:`pointer-events-none absolute right-1 top-1 h-3 w-3 border-r-2 border-t-2 border-[#8a6e20]`}),(0,X.jsx)(`span`,{className:`pointer-events-none absolute bottom-1 left-1 h-3 w-3 border-b-2 border-l-2 border-[#8a6e20]`}),(0,X.jsx)(`span`,{className:`pointer-events-none absolute bottom-1 right-1 h-3 w-3 border-b-2 border-r-2 border-[#8a6e20]`}),(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(`span`,{className:`h-2 w-2 rounded-full`,style:{backgroundColor:a?.glowColor,boxShadow:`0 0 8px ${a?.glowColor}`}}),(0,X.jsx)(`h4`,{className:`font-title text-base tracking-[0.18em] text-[#05040a]`,style:{fontFamily:`var(--font-title)`},children:a?.name})]}),(0,X.jsx)(`p`,{className:`mt-1 text-[11px] uppercase tracking-[0.3em] text-[#8a6e20]`,style:{fontFamily:`var(--font-fantasy)`},children:a?.style}),(0,X.jsx)(`p`,{className:`mt-2 line-clamp-2 text-sm italic leading-snug text-[#3a2e1a]`,style:{fontFamily:`var(--font-body)`},children:a?.description||`A shadow waiting to be shaped by your will.`}),(0,X.jsx)(`div`,{className:`mt-3 flex items-center justify-between border-t border-[rgba(138,110,32,0.3)] pt-2`,children:[{key:`strength`,label:`STR`},{key:`speed`,label:`SPD`},{key:`defense`,label:`DEF`},{key:`shadow`,label:`SHD`}].map((e,t,n)=>(0,X.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,X.jsx)(RR,{kind:e.key,color:a?.glowColor||`#d4af37`}),(0,X.jsx)(`span`,{className:`text-[10px] font-bold tracking-widest text-[#05040a]`,style:{fontFamily:`var(--font-fantasy)`},children:e.label}),(0,X.jsx)(`span`,{className:`text-[10px] font-bold text-[#8a6e20]`,style:{fontFamily:`var(--font-fantasy)`},children:a?.stats?.[e.key]??50}),te===`embers`?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`absolute inset-0 opacity-30`,style:{backgroundImage:`radial-gradient(circle at 20% 80%, rgba(231,29,54,0.6) 0px, transparent 2px), radial-gradient(circle at 70% 30%, rgba(249,215,108,0.6) 0px, transparent 1.5px)`,backgroundSize:`60px 60px, 80px 80px`}}),(0,X.jsx)(`div`,{className:`absolute inset-0 opacity-25`,style:{backgroundImage:`linear-gradient(115deg, transparent 0%, transparent 40%, rgba(255,255,255,0.1) 50%, transparent 60%, transparent 100%)`}})]}):e===`stalks`?(0,X.jsxs)(X.Fragment,{children:[[...Array(8)].map((e,t)=>(0,X.jsx)(`div`,{className:`absolute bottom-0 w-[3px] bg-gradient-to-t from-transparent via-[rgba(173,255,47,0.35)] to-transparent`,style:{left:`${(t+.5)*12}%`,height:`${60+t%3*15}%`}},t)),(0,X.jsx)(`div`,{className:`absolute inset-0 opacity-30`,style:{backgroundImage:`radial-gradient(circle at 50% 0%, rgba(173,255,47,0.4) 0%, transparent 50%)`}})]}):e===`stone`?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`absolute inset-0 opacity-30`,style:{backgroundImage:`repeating-linear-gradient(90deg, transparent 0px, transparent 18px, rgba(255,255,255,0.06) 18px, rgba(255,255,255,0.06) 20px)`,backgroundPositionY:`top`}}),(0,X.jsx)(`div`,{className:`absolute inset-0 opacity-25`,style:{backgroundImage:`repeating-linear-gradient(0deg, transparent 0px, transparent 22px, rgba(180,90,43,0.18) 22px, rgba(180,90,43,0.18) 24px)`}}),(0,X.jsx)(`div`,{className:`absolute inset-0 opacity-50`,style:{backgroundImage:`radial-gradient(circle at 50% 100%, rgba(255,157,62,0.35) 0%, transparent 55%)`}})]}):e===`lanterns`?(0,X.jsxs)(X.Fragment,{children:[[...[,,,,,,]].map((e,t)=>(0,X.jsx)(`div`,{className:`absolute h-2 w-2 rounded-full`,style:{left:`${10+t*15}%`,top:`${20+t%2*30}%`,background:`radial-gradient(circle, #f9d76c 0%, #6ecfff 50%, transparent 80%)`,boxShadow:`0 0 12px #f9d76c, 0 0 24px #6ecfff`}},t)),(0,X.jsx)(`div`,{className:`absolute inset-0 opacity-40`,style:{backgroundImage:`linear-gradient(180deg, rgba(7,13,22,0.0) 0%, rgba(7,13,22,0.7) 100%)`}})]}):null;function GR({arenas:e=[],selectedId:t,onSelect:n,onConfirm:r,onBack:i}){let a=e.find(e=>e.id===t)||e[0],[o,s]=(0,b.useState)(null),[c,l]=(0,b.useState)(!1),u=()=>{a&&(l(!0),setTimeout(()=>r?.(),800))};(0,b.useEffect)(()=>{if(c){let e=setTimeout(()=>l(!1),1e3);return()=>clearTimeout(e)}},[c]);let d=a?.id&&UR[a.id]?.accent||`#d4af37`;return(0,X.jsxs)(Q.div,{variants:BR,initial:`hidden`,animate:`visible`,exit:`exit`,className:`fixed inset-0 z-[100] flex items-center justify-center overflow-hidden bg-ink-900/95 font-body backdrop-blur-sm`,children:[(0,X.jsx)(`div`,{className:`pointer-events-none absolute inset-0 z-[1]`,style:{background:`radial-gradient(circle at 50% 40%, transparent 0%, rgba(5,4,10,0.4) 50%, rgba(5,4,10,0.92) 100%)`}}),(0,X.jsx)(`div`,{className:`pointer-events-none absolute inset-0 z-[2] transition-[background] duration-700`,style:{animation:`ambient-breath 6s ease-in-out infinite`,background:a?.id?`radial-gradient(circle at 50% 60%, ${d}55 0%, transparent 65%)`:`none`}}),(0,X.jsx)(ZD,{children:c&&(0,X.jsx)(`div`,{className:`arena-confirm-overlay`,style:{"--arena-accent":d}},`confirm-fade`)}),(0,X.jsxs)(`div`,{className:`relative z-10 flex w-full max-w-6xl flex-col items-center px-6 py-6`,children:[(0,X.jsxs)(`div`,{className:`mb-6 text-center`,children:[(0,X.jsx)(Q.h1,{variants:HR,className:`font-title text-4xl tracking-[0.18em] text-gold sm:text-5xl md:text-6xl`,style:{textShadow:`0 2px 24px rgba(0,0,0,0.9), 0 0 30px rgba(212,175,55,0.35)`,fontFamily:`var(--font-title)`},children:`Choose the Battleground`}),(0,X.jsx)(Q.div,{initial:{scaleX:0},animate:{scaleX:1},transition:{delay:.5,duration:.8},className:`mx-auto mt-3 h-[1px] w-56 bg-gradient-to-r from-transparent via-gold/70 to-transparent`}),(0,X.jsx)(Q.p,{initial:{opacity:0},animate:{opacity:.6},transition:{delay:.8,duration:.6},className:`mt-2 text-xs uppercase tracking-[0.4em] text-parchment-dark`,style:{fontFamily:`var(--font-fantasy)`},children:`four grounds · one fate`})]}),(0,X.jsx)(Q.div,{variants:BR,className:`grid w-full grid-cols-1 gap-5 sm:grid-cols-2 lg:grid-cols-4`,children:e.map(e=>{let r=e.id===t,i=e.id===o,a=UR[e.id]||UR.temple;return(0,X.jsxs)(Q.button,{variants:VR,onClick:()=>n(e.id),onMouseEnter:()=>s(e.id),onMouseLeave:()=>s(null),className:` group card-tilt relative flex flex-col overflow-hidden rounded-sm border text-left ${r?`border-gold/80`:`border-gold/20 hover:border-gold/50`} `,style:{background:`linear-gradient(180deg, rgba(20,16,28,0.6) 0%, rgba(8,6,14,0.92) 100%)`,minHeight:360,boxShadow:r?`0 0 30px 2px ${a.accent}55, 0 12px 32px rgba(0,0,0,0.6)`:i?`0 0 18px 1px ${a.accent}33`:void 0},children:[(0,X.jsxs)(`div`,{className:`relative h-44 w-full ${a.cardClass}`,children:[(0,X.jsx)(WR,{kind:a.pattern}),(0,X.jsx)(`div`,{className:`absolute inset-0 transition-all duration-500`,style:{background:i?`linear-gradient(180deg, rgba(255,255,255,0.08) 0%, transparent 40%)`:`linear-gradient(180deg, rgba(0,0,0,0.0) 0%, rgba(0,0,0,0.35) 100%)`,mixBlendMode:i?`screen`:`normal`}}),(0,X.jsx)(`span`,{className:` absolute right-3 top-3 rounded-sm border border-gold/40 bg-ink-900/70 px-2 py-0.5 font-title text-[10px] uppercase tracking-[0.25em] text-parchment transition-all duration-300 ${i?`opacity-100 translate-y-0`:`translate-y-1 opacity-60`} `,style:{fontFamily:`var(--font-fantasy)`,color:a.accent,textShadow:`0 0 8px ${a.accent}88`},children:a.atmos})]}),(0,X.jsxs)(`div`,{className:`flex flex-1 flex-col p-4`,children:[(0,X.jsxs)(`div`,{className:`mb-2 flex items-center justify-between`,children:[(0,X.jsx)(`h3`,{className:`font-title text-lg tracking-widest transition-all duration-300`,style:{fontFamily:`var(--font-title)`,color:r||i?`#f9d76c`:`var(--color-parchment)`,textShadow:i||r?`0 0 12px ${a.accent}, 0 2px 8px rgba(0,0,0,0.8)`:`0 2px 8px rgba(0,0,0,0.8)`},children:e.name}),(0,X.jsx)(`span`,{className:`h-3 w-3 rounded-full`,style:{backgroundColor:a.accent,boxShadow:r?`0 0 14px ${a.accent}, 0 0 24px ${a.accent}`:`0 0 10px ${a.accent}`}})]}),(0,X.jsx)(`p`,{className:`flex-1 text-sm leading-relaxed text-parchment-dim`,style:{fontFamily:`var(--font-body)`},children:e.description}),(0,X.jsxs)(`div`,{className:`mt-3 flex items-center justify-between border-t border-gold/15 pt-3`,children:[(0,X.jsx)(`span`,{className:` text-xs uppercase tracking-[0.2em] transition-colors ${r?`text-gold`:`text-parchment-dark`} `,style:{fontFamily:`var(--font-fantasy)`,textShadow:r?`0 0 8px rgba(212,175,55,0.6)`:void 0},children:r?`✦ Selected`:`Select`}),r&&(0,X.jsx)(Q.span,{layoutId:`arena-selected`,className:`text-gold`,style:{textShadow:`0 0 10px rgba(212,175,55,0.8)`,fontFamily:`var(--font-title)`},children:`⚔`})]})]}),(0,X.jsx)(`span`,{className:` absolute left-2 top-2 z-[2] h-6 w-6 border-l-2 border-t-2 border-gold transition-opacity duration-300 ${r||i?`opacity-100`:`opacity-30`} `}),(0,X.jsx)(`span`,{className:` absolute bottom-2 right-2 z-[2] h-6 w-6 border-b-2 border-r-2 border-gold transition-opacity duration-300 ${r||i?`opacity-100`:`opacity-30`} `}),(0,X.jsx)(`span`,{className:` absolute right-2 top-2 z-[3] h-4 w-4 border-r-2 border-t-2 border-gold/60 transition-opacity duration-300 ${r?`opacity-100`:`opacity-30`} `}),(0,X.jsx)(`span`,{className:` absolute bottom-2 left-2 z-[3] h-4 w-4 border-b-2 border-l-2 border-gold/60 transition-opacity duration-300 ${r?`opacity-100`:`opacity-30`} `})]},e.id)})}),(0,X.jsxs)(Q.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{duration:.4},className:`mt-6 text-center`,children:[(0,X.jsx)(`p`,{className:`text-sm uppercase tracking-[0.3em] text-parchment-dark`,style:{fontFamily:`var(--font-fantasy)`},children:`The duel shall take place in`}),(0,X.jsx)(`p`,{className:`mt-1 text-2xl text-gold`,style:{fontFamily:`var(--font-title)`,textShadow:`0 2px 12px rgba(0,0,0,0.8), 0 0 16px rgba(212,175,55,0.35)`},children:a?.name})]},a?.id),(0,X.jsxs)(Q.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.8,duration:.5},className:`mt-6 flex items-center justify-center gap-4`,children:[(0,X.jsx)(NR,{variant:`secondary`,size:`md`,onClick:i,children:`Back`}),(0,X.jsx)(NR,{variant:`primary`,size:`lg`,onClick:u,disabled:c,children:c?`Entering...`:`Enter Arena`})]})]})]})}var KR=[`I`,`II`,`III`],qR=`ᚠᚢᚦᚨᚱᚲᚷᚹᚺᚾ`.split(``);function JR(e,t=0,n=100){return Math.min(n,Math.max(t,e))}function YR({value:e,colorVar:t,deepColorVar:n,side:r}){let i=JR(e),a=r===`right`,o=i<25,s=i<15,c=`M 18 8 L 222 8 L 210 30 L 130 56 L 110 56 L 30 30 Z`,l=`lfill-${r}`,u=`lframe-${r}`,d=`ltick-${r}`,f=i/100*48,p=52-f;return(0,X.jsxs)(`div`,{className:`relative flex items-center`,style:{width:240,height:60,transform:a?`scaleX(-1)`:`none`},children:[(0,X.jsxs)(`svg`,{viewBox:`0 0 240 60`,className:`absolute inset-0 ${o?`lantern-pulse`:``}`,style:{overflow:`visible`},children:[(0,X.jsxs)(`defs`,{children:[(0,X.jsxs)(`linearGradient`,{id:u,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,X.jsx)(`stop`,{offset:`0%`,stopColor:`#f9d76c`}),(0,X.jsx)(`stop`,{offset:`50%`,stopColor:`#8a6e20`}),(0,X.jsx)(`stop`,{offset:`100%`,stopColor:`#d4af37`})]}),(0,X.jsxs)(`linearGradient`,{id:l,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,X.jsx)(`stop`,{offset:`0%`,stopColor:t,stopOpacity:`0.95`}),(0,X.jsx)(`stop`,{offset:`100%`,stopColor:n,stopOpacity:`1`})]}),(0,X.jsxs)(`linearGradient`,{id:d,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,X.jsx)(`stop`,{offset:`0%`,stopColor:`rgba(212,175,55,0.0)`}),(0,X.jsx)(`stop`,{offset:`50%`,stopColor:`rgba(212,175,55,0.85)`}),(0,X.jsx)(`stop`,{offset:`100%`,stopColor:`rgba(212,175,55,0.0)`})]}),(0,X.jsx)(`clipPath`,{id:`lclip-${r}`,children:(0,X.jsx)(`path`,{d:`M 22 11 L 218 11 L 207 30 L 129 52 L 111 52 L 33 30 Z`})})]}),(0,X.jsx)(`path`,{d:c,fill:`rgba(10,8,6,0.62)`,stroke:`url(#${u})`,strokeWidth:`3.2`,className:`lantern-frame`,strokeLinejoin:`round`}),(0,X.jsxs)(`g`,{clipPath:`url(#lclip-${r})`,children:[(0,X.jsx)(Q.rect,{x:`0`,width:240,height:f,fill:`url(#${l})`,initial:!1,animate:{y:p,height:f},transition:{duration:.18,ease:`easeOut`}}),(0,X.jsx)(Q.path,{d:`M 30 11 L 210 11 L 198 16 L 42 16 Z`,fill:`rgba(255,255,255,0.18)`,initial:!1,animate:{y:p-2},transition:{duration:.18,ease:`easeOut`}})]}),[25,50,75].map(e=>{let t=22+e/100*196;return(0,X.jsxs)(`g`,{children:[(0,X.jsx)(`line`,{x1:t,y1:12,x2:t,y2:50,stroke:`url(#${d})`,strokeWidth:`1.2`,strokeDasharray:`3 2`}),(0,X.jsx)(`line`,{x1:t-3,y1:30,x2:t+3,y2:30,stroke:`rgba(212,175,55,0.65)`,strokeWidth:`1.2`})]},e)}),(0,X.jsx)(`path`,{d:c,fill:`none`,stroke:`url(#${u})`,strokeWidth:`3.2`,className:`lantern-frame`,strokeLinejoin:`round`}),(0,X.jsx)(`circle`,{cx:`14`,cy:`30`,r:`9`,fill:`rgba(10,8,6,0.7)`,stroke:`#d4af37`,strokeWidth:`2`}),(0,X.jsx)(`circle`,{cx:`14`,cy:`30`,r:`3`,fill:`#d4af37`}),(0,X.jsx)(`circle`,{cx:`226`,cy:`30`,r:`7`,fill:`rgba(10,8,6,0.7)`,stroke:`#d4af37`,strokeWidth:`2`}),(0,X.jsx)(`circle`,{cx:`226`,cy:`30`,r:`2.4`,fill:`#d4af37`}),(0,X.jsx)(`path`,{d:`M 120 56 L 116 60 L 124 60 Z`,fill:`#d4af37`,stroke:`#8a6e20`,strokeWidth:`1`})]}),(0,X.jsx)(ZD,{children:s&&(0,X.jsxs)(Q.svg,{viewBox:`0 0 240 60`,className:`absolute inset-0 pointer-events-none`,initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},children:[(0,X.jsx)(`path`,{d:`M 60 14 L 72 26 L 66 40 M 120 12 L 114 24 L 128 32 L 122 44 M 90 14 L 96 26 L 88 36 M 150 16 L 158 26 L 152 36`,stroke:`rgba(255,255,255,0.7)`,strokeWidth:`1.6`,fill:`none`}),(0,X.jsx)(`path`,{d:`M 60 14 L 72 26 L 66 40 M 120 12 L 114 24 L 128 32 L 122 44 M 90 14 L 96 26 L 88 36`,stroke:`rgba(0,0,0,0.5)`,strokeWidth:`0.8`,fill:`none`}),[0,.25,.5,.75,1].map((e,t)=>(0,X.jsx)(Q.circle,{cx:240*.5+(t-2)*18,cy:60*.5,r:`1.8`,fill:`#ffd700`,initial:{opacity:1,x:0,y:0},animate:{opacity:0,x:(t-2)*14,y:-20-t*6},transition:{duration:.7,repeat:1/0,delay:e*.4}},t))]})}),(0,X.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center pointer-events-none`,style:{transform:a?`scaleX(-1)`:`none`},children:(0,X.jsx)(`span`,{className:`text-[2.1rem] font-black leading-none`,style:{fontFamily:`var(--font-title)`,color:i<30?`var(--color-crit)`:`var(--color-parchment)`,textShadow:`0 2px 4px rgba(0,0,0,0.95), 0 0 14px rgba(0,0,0,0.85), 0 0 2px rgba(255,255,255,0.4)`,letterSpacing:`0.05em`},children:Math.round(i)})})]})}function XR({score:e,side:t=`left`}){return(0,X.jsx)(`div`,{className:`relative flex items-center`,style:{width:84,height:38},children:(0,X.jsxs)(`svg`,{viewBox:`0 0 84 38`,className:`absolute inset-0 overflow-visible`,children:[(0,X.jsxs)(`defs`,{children:[(0,X.jsxs)(`linearGradient`,{id:`blade-${t}`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,X.jsx)(`stop`,{offset:`0%`,stopColor:`#f0f0f0`}),(0,X.jsx)(`stop`,{offset:`50%`,stopColor:`#b0b0b0`}),(0,X.jsx)(`stop`,{offset:`100%`,stopColor:`#5a5a5a`})]}),(0,X.jsxs)(`linearGradient`,{id:`hilt-${t}`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,X.jsx)(`stop`,{offset:`0%`,stopColor:`#d4af37`}),(0,X.jsx)(`stop`,{offset:`100%`,stopColor:`#6a4a18`})]})]}),(0,X.jsxs)(`g`,{transform:`translate(${t===`left`?22:62} 4) rotate(${t===`left`?32:-32})`,children:[(0,X.jsx)(`rect`,{x:`-1.6`,y:`0`,width:`3.2`,height:`24`,fill:`url(#blade-${t})`}),(0,X.jsx)(`polygon`,{points:`0,0 -1.6,3 1.6,3`,fill:`#d0d0d0`}),(0,X.jsx)(`rect`,{x:`-6`,y:`22`,width:`12`,height:`2`,fill:`url(#hilt-${t})`}),(0,X.jsx)(`rect`,{x:`-2.5`,y:`24`,width:`5`,height:`5`,fill:`#5c3a1a`}),(0,X.jsx)(`circle`,{cx:`0`,cy:`26.5`,r:`1.6`,fill:`#d4af37`})]}),Array.from({length:3}).map((t,n)=>{let r=n{let i=t=5,r=e>=8;return(0,X.jsxs)(`div`,{className:`flex flex-col items-center`,children:[(0,X.jsx)(ZD,{children:n&&(0,X.jsxs)(Q.div,{initial:{opacity:0,scale:.6,y:16},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:1.1,y:-8},transition:{duration:.25,ease:`easeOut`},className:`mb-2 px-5 py-1 text-lg font-bold tracking-[0.25em] text-glow-gold`,style:{fontFamily:`var(--font-title)`,color:`var(--color-crit)`,borderTop:`2px solid rgba(212,175,55,0.7)`,borderBottom:`2px solid rgba(212,175,55,0.7)`,background:`rgba(20,10,0,0.4)`,position:`relative`},children:[r&&(0,X.jsx)(Q.span,{"aria-hidden":`true`,className:`absolute inset-0 -z-10 flex items-center justify-center pointer-events-none`,initial:{opacity:0,scale:.5},animate:{opacity:[0,.9,0],scale:[.5,1.4,1.8]},transition:{duration:.7,repeat:1/0,ease:`easeOut`},children:(0,X.jsx)(`span`,{style:{width:220,height:60,background:`radial-gradient(ellipse at 50% 50%, rgba(255,215,0,0.55) 0%, transparent 70%)`,filter:`blur(4px)`}})}),`SHADOW RAGE`]})}),(0,X.jsxs)(`div`,{className:`flex items-center gap-2 relative`,children:[r&&(0,X.jsx)(Q.div,{"aria-hidden":`true`,className:`absolute inset-0 flex items-center justify-center pointer-events-none`,initial:{opacity:0,scale:.4},animate:{opacity:[0,.85,0],scale:[.4,1.25,1.6]},transition:{duration:.9,repeat:1/0,ease:`easeOut`},children:(0,X.jsx)(`span`,{style:{width:280,height:80,background:`radial-gradient(ellipse at 50% 50%, rgba(255,215,0,0.65) 0%, rgba(212,175,55,0.25) 35%, transparent 70%)`,filter:`blur(6px)`}})}),(0,X.jsxs)(`span`,{className:`text-[2.5rem] font-black leading-none text-glow-gold relative`,style:{fontFamily:`var(--font-title)`,color:`var(--color-crit)`},children:[`x`,e]}),(0,X.jsx)(`div`,{className:`flex items-center relative`,children:Array.from({length:t}).map((e,t)=>(0,X.jsx)(Q.span,{initial:{opacity:0,scale:0,rotate:-90},animate:{opacity:1,scale:1,rotate:0},transition:{delay:t*.04,duration:.2},className:`text-[1.5rem]`,style:{fontFamily:`var(--font-fantasy)`,color:n?`var(--color-crit)`:`var(--color-mana)`,textShadow:n?`0 0 12px rgba(255,215,0,0.95), 0 0 24px rgba(255,200,50,0.6)`:`0 0 10px rgba(123,104,238,0.85)`,marginLeft:t>0?-6:0},children:qR[t%qR.length]},t))})]})]})}function ez(){return(0,X.jsx)(`div`,{className:`flex items-center gap-3 px-5 py-2 rounded-full pointer-events-auto`,style:{background:`rgba(10,8,6,0.65)`,backdropFilter:`blur(8px)`,border:`1px solid rgba(212,175,55,0.25)`,boxShadow:`0 8px 32px rgba(0,0,0,0.5)`},children:[{keys:[`W`,`A`,`S`,`D`],label:`Move`},{keys:[`J`],label:`Jab`},{keys:[`K`],label:`Low Kick`},{keys:[`L`],label:`Cross`},{keys:[`U`],label:`Uppercut`},{keys:[`I`],label:`Roundhouse`}].map(({keys:e,label:t})=>(0,X.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,X.jsx)(`div`,{className:`flex gap-0.5`,children:e.map(e=>(0,X.jsx)(`kbd`,{className:`inline-flex items-center justify-center min-w-[1.6rem] h-6 px-1 text-xs font-bold rounded text-[var(--color-parchment)] select-none`,style:{fontFamily:`var(--font-fantasy)`,background:`linear-gradient(180deg, #5c5040 0%, #3a3126 100%)`,border:`1px solid #8a7b63`,borderBottomWidth:`3px`,boxShadow:`inset 0 1px 0 rgba(255,255,255,0.12), 0 2px 4px rgba(0,0,0,0.5)`,textShadow:`0 1px 2px rgba(0,0,0,0.9)`},children:e},e))}),(0,X.jsx)(`span`,{className:`text-[0.7rem] text-[var(--color-parchment-dim)] uppercase tracking-wider`,style:{fontFamily:`var(--font-body)`},children:t})]},t))})}function tz({text:e,color:t,crit:n=!1,heavy:r=!1}){return(0,X.jsx)(ZD,{children:e&&(0,X.jsxs)(Q.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.05},children:[(0,X.jsx)(`div`,{className:`hit-splash-ink`,style:{width:n?420:320,height:n?200:140},children:(0,X.jsxs)(`svg`,{viewBox:`0 0 400 180`,preserveAspectRatio:`none`,style:{width:`100%`,height:`100%`},children:[(0,X.jsx)(`defs`,{children:(0,X.jsxs)(`radialGradient`,{id:`splashInkGrad`,children:[(0,X.jsx)(`stop`,{offset:`0%`,stopColor:n?`#ffd700`:t,stopOpacity:`0.55`}),(0,X.jsx)(`stop`,{offset:`60%`,stopColor:n?`#ffd700`:t,stopOpacity:`0.25`}),(0,X.jsx)(`stop`,{offset:`100%`,stopColor:n?`#ffd700`:t,stopOpacity:`0`})]})}),(0,X.jsx)(`ellipse`,{cx:`200`,cy:`90`,rx:n?180:140,ry:n?70:50,fill:`url(#splashInkGrad)`}),(0,X.jsx)(`path`,{d:`M 80 60 C 110 50 160 55 200 70 C 240 55 290 50 320 65 C 340 80 320 100 290 110 C 240 130 200 120 160 130 C 120 140 80 120 70 100 C 60 80 60 70 80 60 Z`,fill:n?`#1a0d00`:t,opacity:`0.55`}),(0,X.jsx)(`path`,{d:`M 90 70 C 130 60 180 65 200 80 M 220 75 C 260 65 300 70 320 85 M 110 110 C 150 100 200 105 250 110 M 140 130 C 180 122 220 125 260 130`,stroke:n?`#ffd700`:t,strokeWidth:`2`,fill:`none`,opacity:`0.6`}),n&&Array.from({length:12}).map((e,t)=>{let n=t/12*Math.PI*2,r=60+t%3*22,i=90+t%3*18;return(0,X.jsx)(`line`,{x1:200+Math.cos(n)*r,y1:90+Math.sin(n)*r,x2:200+Math.cos(n)*i,y2:90+Math.sin(n)*i,stroke:`#ffd700`,strokeWidth:`1.4`,opacity:`0.55`},t)})]})}),(0,X.jsxs)(`div`,{className:`hit-splash`,style:{color:n?`var(--color-crit)`:t},children:[n&&(0,X.jsx)(`span`,{className:`crit-star`,children:`✦`}),n&&(0,X.jsx)(`span`,{className:`crit-star`,children:`✦`}),e]})]},e)})}function nz({flash:e}){if(!e)return null;let t=e.crit;return(0,X.jsxs)(`div`,{className:`pointer-events-none absolute inset-0 z-[24]`,"aria-hidden":`true`,children:[t&&(0,X.jsx)(`div`,{className:`absolute inset-0 crit-flash-base`,style:{background:`#ffffff`,mixBlendMode:`screen`}}),(0,X.jsx)(`div`,{className:`absolute inset-0 crit-flash-radial`,style:{background:`radial-gradient(circle at 50% 50%, ${e.color} 0%, transparent 60%)`,mixBlendMode:`screen`,transformOrigin:`50% 50%`}}),t&&(0,X.jsx)(`div`,{className:`absolute inset-0 crit-flash-vignette`})]},e.key)}function rz({playerHP:e,npcHP:t,round:n,playerScore:r,npcScore:i,combo:a,stamina:o}){let[s,c]=(0,b.useState)(null),[l,u]=(0,b.useState)(null);(0,b.useEffect)(()=>{let e=e=>{let t=e.detail||{};if(t.type!==`screenFlash`)return;let n=Date.now()+Math.random();c({color:t.color,crit:!!t.crit,heavy:!!t.heavy,key:n}),setTimeout(()=>{c(e=>e&&e.key===n?null:e)},520),window.dispatchEvent(new CustomEvent(`hud-vfx-flash`,{detail:{color:t.color,crit:!!t.crit,key:n}}));let r=t.crit?`shake-crit`:t.heavy?`shake-heavy`:`shake-light`;document.body.classList.add(r),setTimeout(()=>document.body.classList.remove(r),t.crit?600:t.heavy?550:400);let i=t.crit?`CRITICAL`:t.heavy?`HEAVY`:`HIT`,a=t.crit?`#ffd700`:t.color||`#ff3344`,o=Date.now()+Math.random();u({text:i,color:a,crit:!!t.crit,heavy:!!t.heavy,key:o}),setTimeout(()=>{u(e=>e&&e.key===o?null:e)},560)};return window.addEventListener(`game-vfx`,e),()=>window.removeEventListener(`game-vfx`,e)},[]);let d=e<25;return(0,X.jsxs)(`div`,{className:`absolute inset-0 pointer-events-none z-10 overflow-hidden`,children:[(0,X.jsx)(nz,{flash:s}),d&&(0,X.jsx)(`div`,{className:`player-low-hp-vignette vignette-pulse`}),(0,X.jsx)(tz,{text:l?.text,color:l?.color,crit:l?.crit,heavy:l?.heavy}),(0,X.jsxs)(`div`,{className:`absolute top-5 left-5 flex flex-col gap-1`,children:[(0,X.jsxs)(`div`,{className:`flex items-baseline gap-3`,children:[(0,X.jsx)(`h2`,{className:`text-2xl font-black tracking-widest text-glow-player`,style:{fontFamily:`var(--font-title)`,color:`var(--color-player)`},children:`HERO`}),d&&(0,X.jsx)(Q.span,{initial:{opacity:0},animate:{opacity:[.5,1,.5]},transition:{duration:.6,repeat:1/0},className:`text-[0.65rem] tracking-[0.35em] uppercase`,style:{fontFamily:`var(--font-title)`,color:`var(--color-crit)`,textShadow:`0 0 8px rgba(255,215,0,0.85)`},children:`DANGER`})]}),(0,X.jsx)(YR,{value:e,colorVar:`var(--color-player)`,deepColorVar:`var(--color-player-deep)`,side:`left`})]}),(0,X.jsxs)(`div`,{className:`absolute top-5 right-5 flex flex-col items-end gap-1`,children:[(0,X.jsx)(`div`,{className:`flex items-baseline gap-3`,children:(0,X.jsx)(`h2`,{className:`text-2xl font-black tracking-widest text-glow-enemy`,style:{fontFamily:`var(--font-title)`,color:`var(--color-enemy)`},children:`BALVERINE`})}),(0,X.jsx)(YR,{value:t,colorVar:`var(--color-enemy)`,deepColorVar:`var(--color-enemy-deep)`,side:`right`})]}),(0,X.jsxs)(`div`,{className:`absolute top-0 left-1/2 -translate-x-1/2 flex flex-col items-center gap-1`,style:{marginTop:-8},children:[(0,X.jsx)(ZR,{round:n,playerScore:r,npcScore:i}),(0,X.jsx)(`div`,{style:{marginTop:112},children:(0,X.jsx)(QR,{value:o})})]}),(0,X.jsx)(`div`,{className:`absolute bottom-20 left-1/2 -translate-x-1/2`,children:(0,X.jsx)($R,{combo:a})}),(0,X.jsx)(`div`,{className:`absolute bottom-3 left-1/2 -translate-x-1/2`,children:(0,X.jsx)(ez,{})})]})}function iz(){let[e,t]=(0,b.useState)(dP()),[n,r]=(0,b.useState)(!1);if((0,b.useEffect)(()=>fP(t),[]),!e.playerId)return null;let i=e.roundsLogged?Math.min(1,e.roundsLogged/Math.max(1,e.roundsLogged+e.nextRetrainIn)):0,a=e.cooldownLeftSec>0,o=e.adapterScope||`global`,s=a?`Training… ${Math.ceil(e.cooldownLeftSec/60)} min left`:e.roundsLogged===0?`No data yet`:e.nextRetrainIn===0?`Awaiting next retrain`:`${e.roundsLogged} / ${e.roundsLogged+e.nextRetrainIn} rounds`,c=async()=>{window.confirm(`Forget my learned model? The opponent will revert to the default AI for your next matches.`)&&(await yP(e.playerId),aP(),window.location.reload())};return(0,X.jsxs)(`div`,{style:{position:`absolute`,top:12,right:12,zIndex:30,fontFamily:`system-ui, sans-serif`,fontSize:11,color:`#e7e7e7`,background:`rgba(8, 8, 12, 0.72)`,border:`1px solid rgba(255,255,255,0.08)`,borderRadius:6,padding:`6px 10px`,minWidth:180,backdropFilter:`blur(4px)`,userSelect:`none`},onClick:()=>r(e=>!e),title:`Click for options`,children:[(0,X.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:6},children:[(0,X.jsx)(`span`,{style:{display:`inline-block`,width:8,height:8,borderRadius:`50%`,background:o===`user`?`#ff6b6b`:`#5dd5ff`,boxShadow:o===`user`?`0 0 6px #ff6b6b`:`0 0 6px #5dd5ff`}}),(0,X.jsx)(`span`,{style:{fontWeight:600},children:`Adversary IQ`}),(0,X.jsx)(`span`,{style:{marginLeft:`auto`,opacity:.7},children:o===`user`?`Personalized`:`Global`})]}),(0,X.jsx)(`div`,{style:{marginTop:4,height:4,background:`rgba(255,255,255,0.08)`,borderRadius:2,overflow:`hidden`},children:(0,X.jsx)(`div`,{style:{width:`${Math.round(i*100)}%`,height:`100%`,background:a?`linear-gradient(90deg, #f0c75e, #ff6b6b)`:`linear-gradient(90deg, #5dd5ff, #ff6b6b)`,transition:`width 0.4s`}})}),(0,X.jsx)(`div`,{style:{marginTop:4,opacity:.85},children:s}),n&&(0,X.jsx)(`button`,{onClick:e=>{e.stopPropagation(),c()},style:{marginTop:6,background:`rgba(255,107,107,0.15)`,border:`1px solid rgba(255,107,107,0.4)`,color:`#ff9b9b`,borderRadius:4,padding:`4px 6px`,fontSize:10,cursor:`pointer`,width:`100%`},children:`Forget my learned model`})]})}var az=[`M 60 10 C 75 5 95 8 105 22 C 115 38 100 55 82 56 C 65 58 52 48 48 36 C 44 22 50 14 60 10 Z M 30 60 C 38 55 50 60 52 70 C 54 80 44 86 36 82 C 28 78 24 66 30 60 Z M 100 70 C 112 68 120 76 118 86 C 116 96 104 100 96 92 C 88 84 90 72 100 70 Z`,`M 50 5 C 70 0 95 10 100 30 C 105 50 88 60 70 58 C 52 56 40 45 42 30 C 44 15 42 8 50 5 Z M 20 50 C 30 45 40 55 38 68 C 36 78 22 80 16 70 C 12 60 14 54 20 50 Z M 90 80 C 100 78 110 88 105 100 C 100 110 84 110 80 98 C 76 90 80 82 90 80 Z`,`M 55 8 C 80 4 100 16 102 38 C 104 56 86 64 68 60 C 50 56 44 42 46 28 C 48 18 50 12 55 8 Z M 22 55 C 32 52 42 62 40 72 C 38 82 24 86 18 78 C 12 70 14 60 22 55 Z`];function oz({numbers:e=[]}){return(0,X.jsx)(`div`,{className:`pointer-events-none absolute inset-0 z-[35] overflow-hidden`,children:(0,X.jsx)(ZD,{children:e.map(({id:e,text:t,color:n,x:r,y:i,crit:a=!1,heavy:o=!1,side:s=1})=>{let c=s===-1?-1:1,l=az[e%az.length],u=a?5:3.4,d=a?4.2:2.9;return(0,X.jsxs)(Q.div,{initial:{opacity:0,scale:a?.3:.5,x:0,y:a?0:8},animate:{opacity:[0,1,1,0],scale:a?[.3,u*.32,u*.28,u*.22]:[.5,1.15,1,.85],x:[0,c*(a?24:12),c*(a?42:22)],y:a?[-20,-90,-140]:[8,-40,-80],rotate:a?[-8,4,0]:[-4,3,0]},exit:{opacity:0},transition:{duration:a?1.1:.85,ease:`easeOut`},style:{position:`absolute`,left:`${r}%`,top:`${i}%`,fontFamily:`var(--font-brush)`,color:a?`#000`:n,textShadow:a?`0 0 8px #ffd700, 0 0 18px #ffd700, 0 0 32px #ffd700, 0 4px 12px rgba(0,0,0,0.9)`:`0 0 6px ${n}, 0 0 18px ${n}, 0 3px 10px rgba(0,0,0,0.9)`,WebkitTextStroke:a?`2px #ffd700`:`0.5px rgba(0,0,0,0.5)`,fontSize:`${d}rem`,fontWeight:900,lineHeight:1,whiteSpace:`nowrap`,zIndex:35,transform:`translate(-50%, -50%)`},children:[(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`pointer-events-none absolute inset-0 flex items-center justify-center`,style:{filter:`drop-shadow(0 0 12px ${a?`rgba(255,215,0,0.9)`:n})`,transform:`translate(-50%, -50%)`,left:`50%`,top:`50%`},children:(0,X.jsxs)(`svg`,{width:a?220:170,height:a?220:170,viewBox:`0 0 120 120`,className:`absolute`,style:{transform:`translate(-50%, -50%)`,left:`50%`,top:`50%`},children:[(0,X.jsx)(`path`,{d:l,fill:a?`#1a0d00`:n,opacity:a?.85:.75}),a&&(0,X.jsx)(`path`,{d:l,fill:`none`,stroke:`#ffd700`,strokeWidth:`2`,opacity:`0.7`})]})}),a&&(0,X.jsxs)(`span`,{"aria-hidden":`true`,className:`pointer-events-none absolute inset-0 -z-10 flex items-center justify-center`,children:[(0,X.jsx)(`svg`,{width:`140`,height:`140`,viewBox:`0 0 120 120`,className:`absolute`,style:{filter:`drop-shadow(0 0 10px rgba(255, 215, 0, 0.95))`,transform:`translate(-50%, -50%)`,left:`50%`,top:`50%`},children:(0,X.jsx)(`polygon`,{points:`60,0 70,45 120,40 78,65 100,110 60,80 20,110 42,65 0,40 50,45`,fill:`#ffd700`,opacity:`0.95`})}),(0,X.jsx)(`svg`,{width:`180`,height:`180`,viewBox:`0 0 160 160`,className:`absolute`,style:{filter:`drop-shadow(0 0 6px rgba(0, 0, 0, 0.9))`,transform:`translate(-50%, -50%) rotate(18deg)`,left:`50%`,top:`50%`},children:(0,X.jsx)(`polygon`,{points:`80,10 92,58 150,52 102,80 130,140 80,105 30,140 58,80 10,52 68,58`,fill:`none`,stroke:`#000`,strokeWidth:`3`,opacity:`0.95`})})]}),o&&!a&&(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`pointer-events-none absolute inset-0 -z-10 flex items-center justify-center`,children:(0,X.jsx)(`svg`,{width:`160`,height:`160`,viewBox:`0 0 160 160`,className:`absolute`,style:{filter:`drop-shadow(0 0 14px `+n+`)`,transform:`translate(-50%, -50%)`,left:`50%`,top:`50%`},children:(0,X.jsx)(`path`,{d:`M 80 5 L 95 60 L 155 55 L 105 88 L 130 150 L 80 110 L 30 150 L 55 88 L 5 55 L 65 60 Z`,fill:`none`,stroke:n,strokeWidth:`3.5`,opacity:`0.85`})})}),(0,X.jsx)(`span`,{style:{position:`relative`,zIndex:2},children:t})]},e)})})})}var sz=e=>e?.trim().toUpperCase()===`ROUND WON`,cz={hidden:{opacity:0,scale:.6,rotate:-45},visible:e=>({opacity:1,scale:1,rotate:e===`left`?-12:12,transition:{duration:.5,ease:[.22,1,.36,1],delay:.1}})},lz={hidden:{opacity:0,scale:2.5,y:60},visible:{opacity:1,scale:1,y:0,transition:{duration:.55,ease:[.22,1,.36,1],delay:.25}}},uz={hidden:{pathLength:0,opacity:0},visible:{pathLength:1,opacity:1,transition:{duration:.7,ease:`easeOut`,delay:.35}}};function dz({result:e}){let t=sz(e),n=t?`VICTORY`:`DEFEAT`,r=t?`The crowd roars thy name...`:`The tale continues, bruised but unbroken...`,i=t?`text-[#d4af37]`:`text-[#e71d36]`,a=t?`drop-shadow-[0_0_18px_rgba(212,175,55,0.7)]`:`drop-shadow-[0_0_18px_rgba(231,29,54,0.7)]`;return(0,X.jsxs)(`div`,{className:`pointer-events-none absolute inset-0 z-[90] flex items-center justify-center overflow-hidden`,style:{background:`radial-gradient(circle at center, rgba(5,4,10,0.2) 0%, rgba(5,4,10,0.75) 60%, rgba(5,4,10,0.95) 100%)`},children:[(0,X.jsxs)(`svg`,{className:`absolute inset-0 h-full w-full`,viewBox:`0 0 1920 1080`,preserveAspectRatio:`xMidYMid slice`,xmlns:`http://www.w3.org/2000/svg`,children:[(0,X.jsxs)(`defs`,{children:[(0,X.jsxs)(`linearGradient`,{id:`bladeWin`,x1:`0`,y1:`0`,x2:`1`,y2:`1`,children:[(0,X.jsx)(`stop`,{offset:`0%`,stopColor:`#f9d76c`,stopOpacity:`0.9`}),(0,X.jsx)(`stop`,{offset:`100%`,stopColor:`#8a6e20`,stopOpacity:`0.4`})]}),(0,X.jsxs)(`linearGradient`,{id:`bladeLoss`,x1:`0`,y1:`0`,x2:`1`,y2:`1`,children:[(0,X.jsx)(`stop`,{offset:`0%`,stopColor:`#e71d36`,stopOpacity:`0.85`}),(0,X.jsx)(`stop`,{offset:`100%`,stopColor:`#590d22`,stopOpacity:`0.35`})]})]}),(0,X.jsx)(Q.g,{custom:`left`,variants:cz,initial:`hidden`,animate:`visible`,style:{originX:.5,originY:.5},children:(0,X.jsx)(`path`,{d:`M 720 540 L 960 540 L 980 535 L 960 540 L 980 545 L 960 540 Z`,fill:t?`url(#bladeWin)`:`url(#bladeLoss)`,opacity:`0.35`})}),(0,X.jsx)(Q.g,{custom:`right`,variants:cz,initial:`hidden`,animate:`visible`,style:{originX:.5,originY:.5},children:(0,X.jsx)(`path`,{d:`M 1200 540 L 960 540 L 940 535 L 960 540 L 940 545 L 960 540 Z`,fill:t?`url(#bladeWin)`:`url(#bladeLoss)`,opacity:`0.35`})}),!t&&(0,X.jsx)(Q.path,{d:`M 860 420 L 880 470 L 870 520 L 900 580 M 1020 400 L 1000 460 L 1015 510 L 990 570 M 940 620 L 955 670`,fill:`none`,stroke:`#e71d36`,strokeWidth:`2`,strokeLinecap:`round`,opacity:`0.45`,variants:uz,initial:`hidden`,animate:`visible`})]}),(0,X.jsxs)(`div`,{className:`relative z-10 text-center`,children:[(0,X.jsx)(Q.h1,{variants:lz,initial:`hidden`,animate:`visible`,className:`text-[clamp(3rem,12vw,10rem)] font-bold uppercase leading-none tracking-widest ${i} ${a}`,style:{fontFamily:`var(--font-title)`},children:n}),(0,X.jsx)(Q.p,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.6,delay:.65},className:`mt-4 text-[clamp(1rem,2.5vw,1.5rem)] text-[#b8a88a]`,style:{fontFamily:`var(--font-body)`,textShadow:`0 2px 12px rgba(0,0,0,0.9)`},children:r})]})]})}var fz=({className:e})=>(0,X.jsxs)(`svg`,{className:e,width:`28`,height:`36`,viewBox:`0 0 28 36`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:[(0,X.jsx)(`path`,{d:`M14 2C14 2 4 12 4 22C4 28 8 34 14 34C20 34 24 28 24 22C24 12 14 2 14 2Z`,fill:`currentColor`,fillOpacity:`0.15`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,X.jsx)(`path`,{d:`M14 10C14 10 9 16 9 22C9 26 11 29 14 29C17 29 19 26 19 22C19 16 14 10 14 10Z`,fill:`currentColor`,fillOpacity:`0.55`})]}),pz=({side:e})=>(0,X.jsx)(`svg`,{width:`180`,height:`320`,viewBox:`0 0 180 320`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,className:`text-gold`,style:{filter:`drop-shadow(0 0 14px rgba(212,175,55,0.45))`},children:(0,X.jsxs)(`g`,{transform:e===`left`?``:`translate(180,0) scale(-1,1)`,children:[(0,X.jsx)(`path`,{d:`M40 300 C20 250, 20 200, 30 150 C40 100, 60 60, 90 30`,stroke:`currentColor`,strokeWidth:`2`,fill:`none`}),[...Array(11)].map((e,t)=>{let n=t/10;return(0,X.jsxs)(`g`,{transform:`translate(${30+60*n+Math.sin(n*3)*6}, ${300-270*n-Math.cos(n*2)*4}) rotate(${-25+n*60})`,children:[(0,X.jsx)(`path`,{d:`M0 0 Q10 -8 20 0 Q10 8 0 0 Z`,fill:`currentColor`,fillOpacity:`0.9`,stroke:`currentColor`,strokeWidth:`1`}),(0,X.jsx)(`path`,{d:`M4 -3 Q10 -6 16 -2`,stroke:`currentColor`,strokeWidth:`0.8`,fill:`none`,opacity:`0.7`})]},t)})]})}),mz=Array.from({length:60}).map((e,t)=>({id:t,left:Math.random()*100,size:2+Math.random()*4,duration:4+Math.random()*4,delay:Math.random()*4,drift:-60+Math.random()*120,opacity:.6+Math.random()*.4})),hz=Array.from({length:30}).map((e,t)=>({id:t,left:Math.random()*100,size:1.5+Math.random()*2.5,duration:6+Math.random()*6,delay:Math.random()*6,drift:-30+Math.random()*60,opacity:.4+Math.random()*.5})),gz=()=>(0,X.jsx)(`div`,{className:`ember-layer`,children:mz.map(e=>(0,X.jsx)(`span`,{className:`ember ember-victory`,style:{left:`${e.left}%`,width:`${e.size}px`,height:`${e.size}px`,top:0,bottom:`auto`,animation:`gold-shower ${e.duration}s linear ${e.delay}s infinite`,opacity:e.opacity,"--drift":`${e.drift}px`}},e.id))}),_z=()=>(0,X.jsx)(`div`,{className:`ember-layer`,children:hz.map(e=>(0,X.jsx)(`span`,{className:`ember ember-defeat`,style:{left:`${e.left}%`,width:`${e.size}px`,height:`${e.size}px`,animationDuration:`${e.duration}s`,animationDelay:`${e.delay}s`,opacity:e.opacity,"--drift":`${e.drift}px`}},e.id))}),vz={hidden:{opacity:0,scale:.92,y:40},visible:{opacity:1,scale:1,y:0,transition:{duration:.8,ease:[.22,1,.36,1]}}},yz={hidden:{opacity:0,y:30,filter:`blur(12px)`},visible:{opacity:1,y:0,filter:`blur(0px)`,transition:{duration:1,ease:[.22,1,.36,1]}}},bz={hidden:{opacity:0,x:-20},visible:e=>({opacity:1,x:0,transition:{delay:.6+e*.15,duration:.6}})},xz={hidden:{opacity:0,y:20},visible:e=>({opacity:1,y:0,transition:{delay:1+e*.15,duration:.6}})},Sz=()=>(0,X.jsxs)(`svg`,{className:`mx-auto h-6 w-48 text-gold/60`,viewBox:`0 0 200 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:[(0,X.jsx)(`path`,{d:`M0 12H80`,stroke:`currentColor`,strokeWidth:`1`}),(0,X.jsx)(`path`,{d:`M120 12H200`,stroke:`currentColor`,strokeWidth:`1`}),(0,X.jsx)(`circle`,{cx:`100`,cy:`12`,r:`4`,stroke:`currentColor`,strokeWidth:`1`}),(0,X.jsx)(`path`,{d:`M100 2C105 8, 105 16, 100 22C95 16, 95 8, 100 2Z`,stroke:`currentColor`,strokeWidth:`1`,fill:`none`})]}),Cz=()=>(0,X.jsxs)(`svg`,{className:`pointer-events-none absolute left-1/2 top-1/2 z-0 h-[520px] w-[520px] -translate-x-1/2 -translate-y-1/2 text-gold/30`,viewBox:`0 0 200 200`,fill:`none`,style:{animation:`spin-slow 60s linear infinite`},children:[(0,X.jsxs)(`g`,{stroke:`currentColor`,strokeWidth:`0.5`,fill:`none`,children:[(0,X.jsx)(`circle`,{cx:`100`,cy:`100`,r:`90`,strokeDasharray:`2 4`}),(0,X.jsx)(`circle`,{cx:`100`,cy:`100`,r:`70`,strokeDasharray:`1 6`}),(0,X.jsx)(`circle`,{cx:`100`,cy:`100`,r:`50`,strokeDasharray:`3 3`})]}),[...Array(12)].map((e,t)=>{let n=t*Math.PI*2/12;return(0,X.jsx)(`line`,{x1:100+Math.cos(n)*60,y1:100+Math.sin(n)*60,x2:100+Math.cos(n)*88,y2:100+Math.sin(n)*88},t)})]});function wz({victory:e,playerScore:t,npcScore:n,onRestart:r,onMenu:i}){let a=e?`VICTORY`:`DEFEAT`,o=e?`text-glow-gold-sheen`:`text-parchment-dark`;return(0,X.jsxs)(`div`,{className:`fixed inset-0 z-[120] flex items-center justify-center overflow-hidden bg-ink-900/95 font-body backdrop-blur-sm ${e?``:`palette-desaturate`}`,children:[(0,X.jsx)(`div`,{className:`pointer-events-none absolute inset-0 z-[1]`,style:{background:e?`radial-gradient(circle at 50% 35%, rgba(212,175,55,0.18) 0%, transparent 55%, rgba(5,4,10,0.9) 100%)`:`radial-gradient(circle at 50% 35%, rgba(80,75,70,0.15) 0%, transparent 55%, rgba(5,4,10,0.95) 100%)`}}),e?(0,X.jsx)(gz,{}):(0,X.jsx)(_z,{}),e&&(0,X.jsx)(Cz,{}),(0,X.jsxs)(Q.div,{variants:vz,initial:`hidden`,animate:`visible`,className:`relative z-10 w-full max-w-2xl rounded-sm border-2 p-10 text-center shadow-2xl shadow-black/70 ${e?`border-gold/40 bg-gradient-to-b from-aged-paper/95 to-parchment/90 parchment-cracked`:`border-gold/20 bg-gradient-to-b from-aged-paper/90 to-parchment-dark/30 parchment-cracked`}`,children:[(0,X.jsx)(`span`,{className:`absolute -left-[2px] -top-[2px] z-[2] h-8 w-8 border-l-2 border-t-2 border-gold/70`}),(0,X.jsx)(`span`,{className:`absolute -right-[2px] -top-[2px] z-[2] h-8 w-8 border-r-2 border-t-2 border-gold/70`}),(0,X.jsx)(`span`,{className:`absolute -bottom-[2px] -left-[2px] z-[2] h-8 w-8 border-b-2 border-l-2 border-gold/70`}),(0,X.jsx)(`span`,{className:`absolute -bottom-[2px] -right-[2px] z-[2] h-8 w-8 border-b-2 border-r-2 border-gold/70`}),e&&(0,X.jsx)(`div`,{className:`pointer-events-none absolute left-1/2 top-1/2 z-[1] -translate-x-1/2 -translate-y-1/2 opacity-70`,style:{animation:`rise-laurel 1.6s ease-out forwards`},children:(0,X.jsxs)(`div`,{className:`flex`,style:{width:460,height:320,position:`relative`},children:[(0,X.jsx)(pz,{side:`left`}),(0,X.jsx)(pz,{side:`right`})]})}),(0,X.jsxs)(`div`,{className:`relative z-[2]`,children:[(0,X.jsx)(Sz,{}),(0,X.jsx)(Q.h1,{variants:yz,initial:`hidden`,animate:`visible`,className:`my-6 font-title text-7xl tracking-[0.15em] sm:text-8xl ${o}`,style:e?void 0:{textShadow:`0 0 10px rgba(80,75,70,0.8), 0 4px 24px rgba(0,0,0,0.9)`},children:a}),(0,X.jsx)(Q.p,{initial:{opacity:0},animate:{opacity:1},transition:{delay:.8,duration:.8},className:`mb-8 font-body text-lg italic text-ink-700`,style:{fontFamily:`var(--font-body)`},children:e?`The realm shall sing of your blade this night.`:`Your shadow fades into the mists of Albion.`}),(0,X.jsxs)(Q.div,{initial:`hidden`,animate:`visible`,className:`mb-10 flex items-center justify-center gap-8 sm:gap-14`,children:[(0,X.jsxs)(Q.div,{custom:0,variants:bz,className:`flex flex-col items-center`,children:[(0,X.jsx)(`span`,{className:`mb-2 font-title text-sm tracking-widest text-ink-700`,style:{fontFamily:`var(--font-title)`},children:`PLAYER`}),(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(fz,{className:`text-gold animate-flame`}),(0,X.jsx)(`span`,{className:`font-title text-5xl text-ink-900`,style:{fontFamily:`var(--font-title)`},children:t})]})]}),(0,X.jsx)(`div`,{className:`h-16 w-[1px] bg-ink-600/40`}),(0,X.jsxs)(Q.div,{custom:1,variants:bz,className:`flex flex-col items-center`,children:[(0,X.jsx)(`span`,{className:`mb-2 font-title text-sm tracking-widest text-ink-700`,style:{fontFamily:`var(--font-title)`},children:`FOE`}),(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(`span`,{className:`font-title text-5xl text-ink-900`,style:{fontFamily:`var(--font-title)`},children:n}),(0,X.jsx)(fz,{className:`text-enemy animate-flame`})]})]})]}),(0,X.jsx)(Sz,{}),(0,X.jsxs)(`div`,{className:`mt-10 flex flex-col items-center justify-center gap-5 sm:flex-row`,children:[(0,X.jsxs)(Q.button,{custom:0,variants:xz,initial:`hidden`,animate:`visible`,onClick:r,className:`btn-base btn-primary btn-size-lg glow-border-gold`,children:[(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`btn-sheen bg-gradient-to-r from-transparent via-gold/30 to-transparent`}),(0,X.jsx)(`span`,{className:`relative`,children:`Rise Again`})]}),(0,X.jsxs)(Q.button,{custom:1,variants:xz,initial:`hidden`,animate:`visible`,onClick:i,className:`btn-base btn-danger btn-size-lg`,children:[(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`btn-sheen bg-gradient-to-r from-transparent via-[rgba(231,29,54,0.18)] to-transparent`}),(0,X.jsx)(`span`,{className:`relative`,children:`Flee to Tavern`})]})]})]})]})]})}var Tz=[{key:`Controls`,icon:`sword`,badge:`7`},{key:`Audio`,icon:`lute`,badge:`♪`},{key:`Video`,icon:`eye`,badge:`◐`},{key:`Gameplay`,icon:`scales`,badge:`⚖`}],Ez={hidden:{opacity:0,rotateY:-75,scale:.92},visible:{opacity:1,rotateY:0,scale:1,transition:{duration:.55,ease:[.22,1,.36,1]}},exit:{opacity:0,rotateY:45,scale:.96,transition:{duration:.35}}},Dz={hidden:{opacity:0},visible:{opacity:1,transition:{duration:.35}}},Oz=[{keys:`W A S D`,action:`Move`},{keys:`J`,action:`Jab`},{keys:`K`,action:`Low Kick`},{keys:`L`,action:`Cross`},{keys:`U`,action:`Uppercut`},{keys:`I`,action:`Roundhouse`},{keys:`ESC`,action:`Pause`}],kz=({name:e,className:t=``})=>{let n={width:18,height:18,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:1.6,strokeLinecap:`round`,strokeLinejoin:`round`,className:t};switch(e){case`sword`:return(0,X.jsxs)(`svg`,{...n,children:[(0,X.jsx)(`path`,{d:`M14.5 17.5 3 6V3h3l11.5 11.5`}),(0,X.jsx)(`path`,{d:`M13 19l6-6`}),(0,X.jsx)(`path`,{d:`M16 16l4 4`}),(0,X.jsx)(`path`,{d:`M19 21l2-2`})]});case`lute`:return(0,X.jsxs)(`svg`,{...n,children:[(0,X.jsx)(`path`,{d:`M12 3v6`}),(0,X.jsx)(`path`,{d:`M9 6h6`}),(0,X.jsx)(`path`,{d:`M8 9c-2 1-3 3-3 5a4 4 0 0 0 8 0c0-2-1-4-3-5`}),(0,X.jsx)(`path`,{d:`M5 21l4-4`}),(0,X.jsx)(`path`,{d:`M15 21l4-4`})]});case`eye`:return(0,X.jsxs)(`svg`,{...n,children:[(0,X.jsx)(`path`,{d:`M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7S2 12 2 12z`}),(0,X.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`})]});case`scales`:return(0,X.jsxs)(`svg`,{...n,children:[(0,X.jsx)(`path`,{d:`M12 3v18`}),(0,X.jsx)(`path`,{d:`M5 21h14`}),(0,X.jsx)(`path`,{d:`M5 7h14`}),(0,X.jsx)(`path`,{d:`M5 7l-3 6h6l-3-6z`}),(0,X.jsx)(`path`,{d:`M19 7l-3 6h6l-3-6z`})]});default:return null}};function Az({children:e}){return(0,X.jsx)(`h4`,{className:`mb-2 border-b border-[rgba(138,110,32,0.3)] pb-1 text-xs font-bold uppercase tracking-[0.25em] text-[#8a6e20]`,style:{fontFamily:`var(--font-fantasy)`},children:e})}function jz({label:e,value:t,onChange:n,onReset:r,hint:i,disabled:a=!1}){let[o,s]=(0,b.useState)(!1),c=(0,b.useRef)(null),l=(0,b.useCallback)(e=>{let t=c.current?.getBoundingClientRect();if(!t)return;let r=Math.max(0,Math.min(t.width,e-t.left));n(Math.round(r/t.width*100))},[n]);return(0,b.useEffect)(()=>{if(!o)return;let e=e=>l(e.clientX),t=()=>s(!1);return window.addEventListener(`mousemove`,e),window.addEventListener(`mouseup`,t),()=>{window.removeEventListener(`mousemove`,e),window.removeEventListener(`mouseup`,t)}},[o,l]),(0,X.jsxs)(`div`,{className:a?`pointer-events-none opacity-50`:``,children:[(0,X.jsxs)(`div`,{className:`mb-1 flex items-center justify-between`,children:[(0,X.jsx)(`span`,{className:`text-sm font-bold text-[#05040a]`,style:{fontFamily:`var(--font-fantasy)`},children:e}),(0,X.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,X.jsx)(`span`,{className:`min-w-[2ch] text-right text-sm font-bold tabular-nums text-[#8a6e20]`,style:{fontFamily:`var(--font-body)`},children:t}),r&&(0,X.jsx)(`button`,{type:`button`,onClick:r,className:`text-[10px] uppercase tracking-widest text-[#8a7b63] transition-colors hover:text-[#590d22]`,style:{fontFamily:`var(--font-fantasy)`},children:`reset`})]})]}),(0,X.jsxs)(`div`,{ref:c,onMouseDown:e=>{a||(s(!0),l(e.clientX))},className:`relative h-3 cursor-pointer select-none rounded-sm border border-[rgba(138,110,32,0.6)] bg-[rgba(240,230,210,0.65)] shadow-[inset_0_1px_2px_rgba(0,0,0,0.25)]`,children:[(0,X.jsx)(`div`,{className:`h-full rounded-l-sm bg-[linear-gradient(90deg,#8a6e20,#d4af37,#f1c232)] shadow-[0_0_8px_rgba(212,175,55,0.55)]`,style:{width:`${t}%`}}),(0,X.jsx)(`div`,{className:`absolute top-1/2 h-5 w-5 -translate-x-1/2 -translate-y-1/2 rounded-full border-2 border-[#8a6e20] bg-[linear-gradient(135deg,#fff8e1,#d4af37)] shadow-[0_0_6px_rgba(0,0,0,0.45)] transition-[left] duration-75`,style:{left:`${t}%`}})]}),i&&(0,X.jsx)(`p`,{className:`mt-1 text-[11px] italic text-[#8a7b63]`,style:{fontFamily:`var(--font-body)`},children:i})]})}function Mz({options:e,value:t,onChange:n}){return(0,X.jsx)(`div`,{className:`grid grid-cols-3 gap-2`,children:e.map(e=>{let r=t===e.value;return(0,X.jsxs)(`button`,{type:`button`,onClick:()=>n(e.value),"aria-pressed":r,className:`flex flex-col items-center gap-1 rounded-sm border-2 px-3 py-3 text-center transition-all active:scale-[0.97] ${r?`border-[#d4af37] bg-[rgba(240,230,210,0.95)] shadow-[0_0_12px_rgba(212,175,55,0.55)]`:`border-[rgba(138,110,32,0.45)] bg-[rgba(240,230,210,0.55)] hover:border-[rgba(138,110,32,0.75)] hover:bg-[rgba(240,230,210,0.8)]`}`,children:[e.glyph&&(0,X.jsx)(`span`,{className:`text-lg leading-none ${r?`text-[#8a6e20]`:`text-[#a89878]`}`,style:{fontFamily:`var(--font-title)`},children:e.glyph}),(0,X.jsx)(`span`,{className:`text-[12px] font-bold uppercase tracking-wider ${r?`text-[#05040a]`:`text-[#5c4d3c]`}`,style:{fontFamily:`var(--font-fantasy)`},children:e.label}),e.hint&&(0,X.jsx)(`span`,{className:`text-[10px] leading-tight text-[#8a7b63]`,style:{fontFamily:`var(--font-body)`},children:e.hint})]},e.value)})})}function Nz({label:e,value:t,onChange:n,hint:r}){return(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3 py-1`,children:[(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsx)(`div`,{className:`text-sm font-bold text-[#05040a]`,style:{fontFamily:`var(--font-fantasy)`},children:e}),r&&(0,X.jsx)(`div`,{className:`mt-0.5 text-[11px] italic text-[#8a7b63]`,style:{fontFamily:`var(--font-body)`},children:r})]}),(0,X.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":t,onClick:()=>n(!t),className:`relative h-6 w-12 shrink-0 rounded-full border-2 transition-all ${t?`border-[#d4af37] bg-[linear-gradient(90deg,#b8860b,#d4af37)] shadow-[0_0_8px_rgba(212,175,55,0.5)]`:`border-[rgba(138,110,32,0.55)] bg-[rgba(209,191,160,0.6)]`}`,children:(0,X.jsx)(`span`,{className:`absolute top-1/2 h-4 w-4 -translate-y-1/2 rounded-full border border-[#8a6e20] bg-[linear-gradient(135deg,#fff8e1,#f1c232)] shadow transition-all ${t?`left-[1.35rem]`:`left-[2px]`}`})})]})}function Pz({onResume:e,onRestart:t,onQuit:n,audioSettings:r,setAudioSettings:i,videoSettings:a,setVideoSettings:o,gameplaySettings:s,setGameplaySettings:c}){let[l,u]=(0,b.useState)(`Controls`);return(0,X.jsxs)(Q.div,{className:`absolute inset-0 z-[110] flex items-center justify-center`,style:{perspective:`1200px`},variants:Dz,initial:`hidden`,animate:`visible`,exit:`hidden`,children:[(0,X.jsx)(`div`,{className:`absolute inset-0 bg-[rgba(5,4,10,0.55)] backdrop-blur-md`,onClick:e}),(0,X.jsx)(ZD,{children:(0,X.jsxs)(Q.div,{variants:Ez,initial:`hidden`,animate:`visible`,exit:`exit`,className:`relative z-10 flex h-[min(85vh,720px)] w-[min(92vw,1100px)] overflow-hidden rounded-sm border-2 border-[rgba(138,110,32,0.45)] bg-[linear-gradient(135deg,rgba(240,230,210,0.97),rgba(209,191,160,0.94))] text-[#05040a] shadow-[0_24px_80px_rgba(0,0,0,0.7),inset_0_1px_0_rgba(255,255,255,0.25)]`,style:{fontFamily:`var(--font-body)`,boxShadow:`0 24px 80px rgba(0,0,0,0.7), inset 0 1px 0 rgba(255,255,255,0.25), 0 0 0 2px rgba(212,175,55,0.25)`},children:[(0,X.jsx)(`span`,{className:`ink-stain`,style:{top:`12%`,left:`8%`,width:90,height:70}}),(0,X.jsx)(`span`,{className:`ink-stain`,style:{top:`60%`,left:`30%`,width:60,height:50,opacity:.5}}),(0,X.jsx)(`span`,{className:`ink-stain`,style:{top:`20%`,right:`6%`,width:110,height:80}}),(0,X.jsx)(`span`,{className:`ink-stain`,style:{bottom:`10%`,right:`12%`,width:70,height:60,opacity:.5}}),(0,X.jsx)(`div`,{className:`torn-edge-top`}),(0,X.jsx)(`div`,{className:`torn-edge-bottom`}),(0,X.jsx)(`svg`,{className:`pointer-events-none absolute top-0 left-0 z-[1] w-full`,viewBox:`0 0 1200 24`,preserveAspectRatio:`none`,height:`24`,children:(0,X.jsx)(`path`,{d:`M0,0 L0,12 Q30,20 60,10 T120,14 T180,6 T240,16 T300,8 T360,18 T420,10 T480,14 T540,6 T600,16 T660,8 T720,18 T780,10 T840,14 T900,6 T960,16 T1020,8 T1080,18 T1140,10 T1200,14 L1200,0 Z`,fill:`rgba(209,191,160,0.94)`})}),(0,X.jsx)(`svg`,{className:`pointer-events-none absolute bottom-0 left-0 z-[1] w-full`,viewBox:`0 0 1200 24`,preserveAspectRatio:`none`,height:`24`,children:(0,X.jsx)(`path`,{d:`M0,24 L0,12 Q30,4 60,14 T120,10 T180,18 T240,8 T300,16 T360,6 T420,14 T480,10 T540,18 T600,8 T660,16 T720,6 T780,14 T840,10 T900,18 T960,8 T1020,16 T1080,6 T1140,14 T1200,10 L1200,24 Z`,fill:`rgba(209,191,160,0.94)`})}),(0,X.jsx)(`div`,{className:`pointer-events-none absolute top-3 left-3 z-[2] h-10 w-10 border-t-2 border-l-2 border-[rgba(212,175,55,0.75)]`}),(0,X.jsx)(`div`,{className:`pointer-events-none absolute top-3 right-3 z-[2] h-10 w-10 border-t-2 border-r-2 border-[rgba(212,175,55,0.75)]`}),(0,X.jsx)(`div`,{className:`pointer-events-none absolute bottom-3 left-3 z-[2] h-10 w-10 border-b-2 border-l-2 border-[rgba(212,175,55,0.75)]`}),(0,X.jsx)(`div`,{className:`pointer-events-none absolute bottom-3 right-3 z-[2] h-10 w-10 border-b-2 border-r-2 border-[rgba(212,175,55,0.75)]`}),(0,X.jsxs)(`aside`,{className:`relative z-[3] flex w-56 flex-col border-r border-[rgba(138,110,32,0.35)] bg-[rgba(209,191,160,0.5)] py-8 pr-0`,children:[(0,X.jsx)(`h2`,{className:`px-5 text-xl font-bold tracking-wide text-[#8a6e20]`,style:{fontFamily:`var(--font-title)`},children:`Tome of Options`}),(0,X.jsx)(`div`,{className:`mt-2 px-5 text-[10px] uppercase tracking-[0.3em] text-[#8a7b63]`,children:`~ Select a scroll ~`}),(0,X.jsx)(`nav`,{className:`mt-6 flex flex-col gap-1`,children:Tz.map(e=>{let t=l===e.key;return(0,X.jsxs)(`button`,{onClick:()=>u(e.key),className:`group relative flex items-center gap-3 px-5 py-3 text-left text-sm font-semibold uppercase tracking-wider transition-colors ${t?`text-[#05040a]`:`text-[#8a7b63] hover:text-[#05040a]`}`,style:{fontFamily:`var(--font-fantasy)`},children:[t&&(0,X.jsx)(Q.span,{layoutId:`pause-tab`,className:`absolute inset-0 bg-[rgba(240,230,210,0.85)]`,style:{borderLeft:`3px solid #d4af37`},transition:{duration:.25}}),(0,X.jsx)(`span`,{className:`relative z-10 transition-colors ${t?`text-[#8a6e20]`:`text-[#8a7b63]`}`,children:(0,X.jsx)(kz,{name:e.icon})}),(0,X.jsx)(`span`,{className:`relative z-10 flex-1`,children:e.key}),(0,X.jsx)(`span`,{className:`relative z-10 inline-flex h-5 min-w-[1.4rem] items-center justify-center rounded-full border px-1.5 text-[10px] font-bold tracking-normal transition-colors ${t?`border-[#8a6e20]/60 bg-[rgba(212,175,55,0.18)] text-[#8a6e20]`:`border-[#8a7b63]/40 bg-[rgba(138,110,32,0.1)] text-[#8a7b63] group-hover:border-[#8a7b63]/70 group-hover:text-[#5c4d3c]`}`,children:e.badge})]},e.key)})})]}),(0,X.jsxs)(`main`,{className:`relative z-[3] flex flex-1 flex-col p-8`,children:[(0,X.jsxs)(`div`,{className:`flex-1 overflow-y-auto`,children:[l===`Controls`&&(0,X.jsxs)(Q.div,{initial:{opacity:0,x:20},animate:{opacity:1,x:0},transition:{duration:.3},children:[(0,X.jsxs)(`h3`,{className:`mb-2 flex items-center gap-3 text-2xl font-bold text-[#05040a]`,style:{fontFamily:`var(--font-title)`},children:[(0,X.jsx)(kz,{name:`sword`,className:`text-[#8a6e20]`}),`Blade & Boot Bindings`]}),(0,X.jsx)(`p`,{className:`mb-6 text-sm italic text-[#8a7b63]`,style:{fontFamily:`var(--font-body)`},children:`"Strike true, parry true, live to duel again."`}),(0,X.jsx)(`ul`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2`,children:Oz.map(e=>(0,X.jsxs)(`li`,{className:`flex items-center justify-between rounded border border-[rgba(138,110,32,0.25)] bg-[rgba(240,230,210,0.6)] px-4 py-3`,children:[(0,X.jsx)(`span`,{className:`text-[#5c4d3c]`,style:{fontFamily:`var(--font-body)`},children:e.action}),(0,X.jsx)(`span`,{className:`rounded border border-[rgba(138,110,32,0.45)] bg-[rgba(209,191,160,0.8)] px-2 py-1 text-xs font-bold tracking-widest text-[#05040a] shadow-sm`,style:{fontFamily:`var(--font-fantasy)`},children:e.keys})]},e.action))})]}),l===`Audio`&&(0,X.jsxs)(Q.div,{initial:{opacity:0,x:20},animate:{opacity:1,x:0},transition:{duration:.3},children:[(0,X.jsxs)(`h3`,{className:`mb-2 flex items-center gap-3 text-2xl font-bold text-[#05040a]`,style:{fontFamily:`var(--font-title)`},children:[(0,X.jsx)(kz,{name:`lute`,className:`text-[#8a6e20]`}),`Sounds of the Realm`]}),(0,X.jsx)(`p`,{className:`mb-5 text-sm italic text-[#8a7b63]`,style:{fontFamily:`var(--font-body)`},children:`"Tune the wind and the clash of steel to your liking."`}),(0,X.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 sm:grid-cols-[1fr,1fr]`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,X.jsx)(Az,{children:`Mixer`}),(0,X.jsx)(jz,{label:`Master Volume`,value:r.muted?0:r.master,onChange:e=>i(t=>({...t,master:e,muted:!1})),onReset:()=>i(e=>({...e,master:80,muted:!1})),hint:`All sound, in one dial.`,disabled:r.muted}),(0,X.jsx)(jz,{label:`SFX Volume`,value:r.muted?0:r.sfx,onChange:e=>i(t=>({...t,sfx:e})),onReset:()=>i(e=>({...e,sfx:100})),hint:`Hits, blocks, footsteps.`,disabled:r.muted}),(0,X.jsx)(jz,{label:`Music Volume`,value:r.muted?0:r.music,onChange:e=>i(t=>({...t,music:e})),onReset:()=>i(e=>({...e,music:60})),hint:`Ambient lute and drum.`,disabled:r.muted})]}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-4 sm:items-end`,children:[(0,X.jsx)(Az,{children:`Quick`}),(0,X.jsxs)(`button`,{type:`button`,onClick:()=>i(e=>({...e,muted:!e.muted})),"aria-pressed":r.muted,className:`flex w-full items-center justify-center gap-2 rounded-sm border-2 px-5 py-3 text-sm font-bold uppercase tracking-widest transition-all active:scale-95 ${r.muted?`border-[#d4af37] bg-[linear-gradient(135deg,#fff8e1,#d4af37)] text-[#05040a] shadow-[0_0_14px_rgba(212,175,55,0.6)]`:`border-[rgba(138,110,32,0.55)] bg-[rgba(209,191,160,0.7)] text-[#5c4d3c] hover:border-[rgba(138,110,32,0.85)] hover:bg-[rgba(240,230,210,0.9)]`}`,style:{fontFamily:`var(--font-fantasy)`},children:[(0,X.jsxs)(`svg`,{width:`18`,height:`18`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,X.jsx)(`polygon`,{points:`11 5 6 9 2 9 2 15 6 15 11 19 11 5`}),r.muted?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`line`,{x1:`23`,y1:`9`,x2:`17`,y2:`15`}),(0,X.jsx)(`line`,{x1:`17`,y1:`9`,x2:`23`,y2:`15`})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`path`,{d:`M15.54 8.46a5 5 0 0 1 0 7.07`}),(0,X.jsx)(`path`,{d:`M19.07 4.93a10 10 0 0 1 0 14.14`})]})]}),r.muted?`Unmute All`:`Mute All`]}),(0,X.jsx)(`p`,{className:`w-full text-[11px] italic text-[#8a7b63]`,style:{fontFamily:`var(--font-body)`},children:`The bards shall heed your command.`})]})]})]},`audio`),l===`Video`&&(0,X.jsxs)(Q.div,{initial:{opacity:0,x:20},animate:{opacity:1,x:0},transition:{duration:.3},children:[(0,X.jsxs)(`h3`,{className:`mb-2 flex items-center gap-3 text-2xl font-bold text-[#05040a]`,style:{fontFamily:`var(--font-title)`},children:[(0,X.jsx)(kz,{name:`eye`,className:`text-[#8a6e20]`}),`View of the Arena`]}),(0,X.jsx)(`p`,{className:`mb-5 text-sm italic text-[#8a7b63]`,style:{fontFamily:`var(--font-body)`},children:`"The world can be painted in broad strokes or fine detail."`}),(0,X.jsx)(Az,{children:`Quality`}),(0,X.jsx)(Mz,{value:a.quality,onChange:e=>o(t=>({...t,quality:e})),options:[{value:`low`,label:`Low`,glyph:`I`,hint:`No bloom · dpr 1`},{value:`medium`,label:`Medium`,glyph:`II`,hint:`Bloom · dpr 1.5`},{value:`high`,label:`High`,glyph:`III`,hint:`Full effects · dpr 2`}]}),(0,X.jsx)(Az,{children:`Effects`}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,X.jsx)(Nz,{label:`Hit Spark Particles`,hint:`Bursts of light on every landed blow.`,value:a.hitSparks,onChange:e=>o(t=>({...t,hitSparks:e}))}),(0,X.jsx)(Nz,{label:`Damage Numbers`,hint:`Floating numerals on each hit.`,value:a.damageNumbers,onChange:e=>o(t=>({...t,damageNumbers:e}))})]}),(0,X.jsx)(`div`,{className:`mt-4`,children:(0,X.jsx)(jz,{label:`Screen Shake Intensity`,value:a.screenShake,onChange:e=>o(t=>({...t,screenShake:e})),onReset:()=>o(e=>({...e,screenShake:50})),hint:`How hard the world trembles on a heavy hit.`})})]},`video`),l===`Gameplay`&&(0,X.jsxs)(Q.div,{initial:{opacity:0,x:20},animate:{opacity:1,x:0},transition:{duration:.3},children:[(0,X.jsxs)(`h3`,{className:`mb-2 flex items-center gap-3 text-2xl font-bold text-[#05040a]`,style:{fontFamily:`var(--font-title)`},children:[(0,X.jsx)(kz,{name:`scales`,className:`text-[#8a6e20]`}),`Rules of Engagement`]}),(0,X.jsx)(`p`,{className:`mb-5 text-sm italic text-[#8a7b63]`,style:{fontFamily:`var(--font-body)`},children:`"Set the terms of your duel."`}),(0,X.jsx)(Az,{children:`Difficulty`}),(0,X.jsx)(Mz,{value:s.difficulty,onChange:e=>c(t=>({...t,difficulty:e})),options:[{value:`apprentice`,label:`Apprentice`,glyph:`I`,hint:`Rounds 1–2`},{value:`champion`,label:`Champion`,glyph:`II`,hint:`Rounds 1–3`},{value:`legend`,label:`Legend`,glyph:`III`,hint:`Rounds 1–5`}]}),(0,X.jsx)(Az,{children:`Match Format`}),(0,X.jsx)(Mz,{value:s.matchFormat,onChange:e=>c(t=>({...t,matchFormat:e})),options:[{value:`single`,label:`Single Bout`,glyph:`I`,hint:`1 round`},{value:`bestOf3`,label:`Best of Three`,glyph:`III`,hint:`First to 2`},{value:`bestOf5`,label:`Best of Five`,glyph:`V`,hint:`First to 3`}]}),(0,X.jsx)(Az,{children:`HUD & Focus`}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,X.jsx)(Nz,{label:`Show Control Hints in HUD`,hint:`Small key reminders on the action bar.`,value:s.showControlHints,onChange:e=>c(t=>({...t,showControlHints:e}))}),(0,X.jsx)(Nz,{label:`Auto-Pause When Tab Loses Focus`,hint:`Freezes the duel if you look away.`,value:s.autoPauseOnBlur,onChange:e=>c(t=>({...t,autoPauseOnBlur:e}))})]})]},`gameplay`)]}),(0,X.jsxs)(`div`,{className:`mt-6 flex flex-wrap items-center justify-between gap-3 border-t border-[rgba(138,110,32,0.3)] pt-5`,children:[(0,X.jsxs)(`span`,{className:`flex items-center gap-2 text-[11px] uppercase tracking-[0.25em] text-[#8a7b63]`,style:{fontFamily:`var(--font-fantasy)`},children:[(0,X.jsx)(`kbd`,{className:`rounded border border-[rgba(138,110,32,0.45)] bg-[rgba(240,230,210,0.7)] px-1.5 py-0.5 text-[10px] font-bold text-[#05040a]`,style:{fontFamily:`var(--font-fantasy)`},children:`ESC`}),`Press ESC to resume`]}),(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,X.jsx)(NR,{variant:`secondary`,size:`sm`,onClick:e,children:`Resume`}),(0,X.jsx)(NR,{variant:`secondary`,size:`sm`,onClick:t,children:`Restart Duel`}),(0,X.jsx)(NR,{variant:`danger`,size:`sm`,onClick:n,children:`Flee to Tavern`})]})]})]})]},`pause-panel`)})]})}function Fz({color:e=`#ff3344`}){let t=e===`#ffd700`;return(0,X.jsx)(ZD,{children:(0,X.jsxs)(Q.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.16,ease:`easeOut`},className:`pointer-events-none absolute inset-0 z-[25]`,children:[t&&(0,X.jsx)(`div`,{className:`absolute inset-0 crit-flash-base`,style:{background:`#ffffff`,mixBlendMode:`screen`}}),(0,X.jsx)(`div`,{className:`absolute inset-0 crit-flash-radial`,style:{background:`radial-gradient(circle at 50% 50%, ${e} 0%, rgba(0,0,0,0) 55%)`,mixBlendMode:`screen`,transformOrigin:`50% 50%`}}),t&&(0,X.jsx)(`div`,{className:`absolute inset-0 crit-flash-vignette`}),t&&(0,X.jsx)(`div`,{className:`absolute inset-0 crit-ember-burst`,style:{background:`conic-gradient(from 0deg at 50% 50%, rgba(255,215,0,0) 0deg, rgba(255,215,0,0.35) 20deg, rgba(255,215,0,0) 40deg, rgba(255,215,0,0.35) 80deg, rgba(255,215,0,0) 120deg, rgba(255,215,0,0.35) 160deg, rgba(255,215,0,0) 200deg, rgba(255,215,0,0.35) 240deg, rgba(255,215,0,0) 280deg, rgba(255,215,0,0.35) 320deg, rgba(255,215,0,0) 360deg)`,mixBlendMode:`screen`,transformOrigin:`50% 50%`}})]},e)})}var Iz=[{id:`ronin`,name:`The Ronin`,style:`Balanced Striker`,description:`A wandering duelist with no master. Fast hands, steady feet, and a blade that lives only in memory.`,glowColor:`#e71d36`,bodyColor:`#0a0a0a`,accentColor:`#e71d36`,bodyScale:1,torsoScale:1,headScale:1,limbScale:1,handScale:1,stanceOffset:1,silhouette:{build:`balanced`,shoulderWidth:1,waistNarrow:.4,hipWidth:1,headShape:`round`,hasTopknot:!0,hasHood:!1,hasMohawk:!1,isBald:!1,armLength:1.05,armThickness:.95,hasWrappedHands:!1,hasGauntlets:!1,legStyle:`hakama`,legThickness:.95,hasBoots:!1,hasKatanaSheath:!0,hasSash:!1,hasScarf:!1,hasShoulderPads:!1,hasHeadband:!0,hasPauldron:!1,hasPrayerBeads:!1,hasTwinDaggers:!1,proportions:{torsoW:1,torsoH:1,armW:1,armH:1,legW:1,legH:1,headW:1,headH:1,headD:1},stanceModifier:{torsoTilt:.04,armForward:0,armSpread:.4,legSpread:.08,kneeBend:0,headTilt:0},idleAnim:{breathAmp:.045,breathRate:1.9,torsoSwayAmp:.0525,torsoSwayRate:1.7,torsoRollAmp:.033,torsoRollRate:2.1,headSwayAmp:.0375,headSwayRate:2,headScanAmp:0,headScanRate:0,weightShiftAmp:.03,weightShiftRate:3.2,chestExpand:.01}},stats:{strength:60,speed:60,defense:55,shadow:50}},{id:`monk`,name:`The Iron Monk`,style:`Resilient Grappler`,description:`Trained in the high temples where breath is armour. Excels at clinches, throws, and outlasting foes.`,glowColor:`#adff2f`,bodyColor:`#0a0a0a`,accentColor:`#adff2f`,bodyScale:1.05,torsoScale:1.08,headScale:.98,limbScale:1.02,handScale:1.05,stanceOffset:.98,silhouette:{build:`stocky`,shoulderWidth:1.2,waistNarrow:.2,hipWidth:1.1,headShape:`round`,hasTopknot:!1,hasHood:!1,hasMohawk:!1,isBald:!0,armLength:.95,armThickness:1.15,hasWrappedHands:!0,hasGauntlets:!1,legStyle:`baggy`,legThickness:1.1,hasBoots:!1,hasKatanaSheath:!1,hasSash:!0,hasScarf:!1,hasShoulderPads:!1,hasHeadband:!1,hasPauldron:!1,hasPrayerBeads:!0,hasTwinDaggers:!1,proportions:{torsoW:1.3,torsoH:.95,armW:1.2,armH:.9,legW:1.15,legH:.85,headW:1.1,headH:1.05,headD:1.05},stanceModifier:{torsoTilt:.12,armForward:.45,armSpread:.65,legSpread:.2,kneeBend:.15,headTilt:0},idleAnim:{breathAmp:.06,breathRate:1.2,torsoSwayAmp:.03,torsoSwayRate:1.3,torsoRollAmp:.02,torsoRollRate:1.5,headSwayAmp:.02,headSwayRate:1,headScanAmp:0,headScanRate:0,weightShiftAmp:.02,weightShiftRate:4,chestExpand:.02}},stats:{strength:70,speed:45,defense:70,shadow:40}},{id:`assassin`,name:`The Velvet Assassin`,style:`Speed Striker`,description:`Strikes like a thought. Fragile, but blindingly fast; a single opening is all she needs.`,glowColor:`#6ecfff`,bodyColor:`#0a0a0a`,accentColor:`#6ecfff`,bodyScale:.96,torsoScale:.95,headScale:.96,limbScale:.98,handScale:.95,stanceOffset:1.02,silhouette:{build:`slim`,shoulderWidth:.85,waistNarrow:.6,hipWidth:.9,headShape:`angular`,hasTopknot:!1,hasHood:!0,hasMohawk:!1,isBald:!1,armLength:1.1,armThickness:.85,hasWrappedHands:!1,hasGauntlets:!1,legStyle:`straight`,legThickness:.85,hasBoots:!1,hasKatanaSheath:!1,hasSash:!1,hasScarf:!0,hasShoulderPads:!1,hasHeadband:!1,hasPauldron:!1,hasPrayerBeads:!1,hasTwinDaggers:!0,proportions:{torsoW:.75,torsoH:1.2,armW:.7,armH:1.3,legW:.75,legH:1.2,headW:.85,headH:.95,headD:.95},stanceModifier:{torsoTilt:-.02,armForward:.1,armSpread:.2,legSpread:.04,kneeBend:0,headTilt:.12},idleAnim:{breathAmp:.04,breathRate:2.5,torsoSwayAmp:.06,torsoSwayRate:2.2,torsoRollAmp:.04,torsoRollRate:2.5,headSwayAmp:0,headSwayRate:0,headScanAmp:.06,headScanRate:1.5,weightShiftAmp:.025,weightShiftRate:2.5,chestExpand:.01}},stats:{strength:50,speed:85,defense:35,shadow:70}},{id:`champion`,name:`The Pit Champion`,style:`Heavy Hitter`,description:`Built from scar tissue and grudges. Each blow lands like a verdict; each step shakes the ground.`,glowColor:`#ff9d3e`,bodyColor:`#0a0a0a`,accentColor:`#ff9d3e`,bodyScale:1.12,torsoScale:1.12,headScale:1.05,limbScale:1.08,handScale:1.1,stanceOffset:.95,silhouette:{build:`stocky`,shoulderWidth:1.35,waistNarrow:.1,hipWidth:1.2,headShape:`square`,hasTopknot:!1,hasHood:!1,hasMohawk:!0,isBald:!1,armLength:.95,armThickness:1.25,hasWrappedHands:!1,hasGauntlets:!0,legStyle:`armored`,legThickness:1.2,hasBoots:!0,hasKatanaSheath:!1,hasSash:!1,hasScarf:!1,hasShoulderPads:!0,hasHeadband:!1,hasPauldron:!0,hasPrayerBeads:!1,hasTwinDaggers:!1,proportions:{torsoW:1.5,torsoH:1.1,armW:1.4,armH:1,legW:1.4,legH:1,headW:1.2,headH:1.1,headD:1.2},stanceModifier:{torsoTilt:.1,armForward:.25,armSpread:.55,legSpread:.18,kneeBend:.18,headTilt:0},idleAnim:{breathAmp:.05,breathRate:1.5,torsoSwayAmp:.04,torsoSwayRate:1.5,torsoRollAmp:.05,torsoRollRate:1.8,headSwayAmp:.025,headSwayRate:1.7,headScanAmp:0,headScanRate:0,weightShiftAmp:.04,weightShiftRate:2.8,chestExpand:.025}},stats:{strength:90,speed:35,defense:60,shadow:30}}],Lz=Iz[0],Rz=[{keys:`W A S D`,action:`Move`},{keys:`J`,action:`Jab`},{keys:`K`,action:`Low Kick`},{keys:`L`,action:`Cross`},{keys:`U`,action:`Uppercut`},{keys:`I`,action:`Roundhouse`},{keys:`ESC`,action:`Pause`}],zz={hidden:{opacity:0},visible:{opacity:1,transition:{duration:.3}}},Bz={hidden:{opacity:0,y:24,scale:.96},visible:{opacity:1,y:0,scale:1,transition:{duration:.45,ease:[.22,1,.36,1]}},exit:{opacity:0,y:16,scale:.97,transition:{duration:.3}}},Vz=({className:e=``})=>(0,X.jsxs)(`svg`,{className:e,width:`20`,height:`20`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,X.jsx)(`path`,{d:`M6 6l12 12`}),(0,X.jsx)(`path`,{d:`M18 6L6 18`})]}),Hz=()=>(0,X.jsx)(`div`,{className:`parchment-grain pointer-events-none`}),Uz=({className:e})=>(0,X.jsxs)(`svg`,{className:`pointer-events-none absolute h-16 w-16 text-gold/55 ${e||``}`,viewBox:`0 0 140 140`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,"aria-hidden":`true`,children:[(0,X.jsx)(`path`,{d:`M10 130 C30 90, 10 70, 50 50 C90 30, 110 50, 130 10`,stroke:`currentColor`,strokeWidth:`1.5`,fill:`none`}),(0,X.jsx)(`path`,{d:`M20 130 C35 100, 25 85, 55 70 C80 55, 100 70, 120 35`,stroke:`currentColor`,strokeWidth:`1`,fill:`none`,opacity:`0.6`}),(0,X.jsx)(`circle`,{cx:`130`,cy:`10`,r:`3`,fill:`currentColor`}),(0,X.jsx)(`circle`,{cx:`10`,cy:`130`,r:`3`,fill:`currentColor`})]}),Wz=({title:e,subtitle:t,onClose:n,children:r,maxWidth:i=`1100px`})=>((0,b.useEffect)(()=>{let e=e=>{e.key===`Escape`&&n()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[n]),(0,X.jsx)(Q.div,{variants:zz,initial:`hidden`,animate:`visible`,exit:`hidden`,onClick:n,className:`fixed inset-0 z-[150] flex items-center justify-center overflow-y-auto bg-ink-900/85 px-4 py-8 backdrop-blur-md`,children:(0,X.jsxs)(Q.div,{variants:Bz,initial:`hidden`,animate:`visible`,exit:`exit`,onClick:e=>e.stopPropagation(),className:`relative my-auto w-full overflow-hidden rounded-sm border-2 border-gold/45 bg-gradient-to-b from-ink-800/95 to-ink-900/95 shadow-[0_24px_80px_rgba(0,0,0,0.75)]`,style:{maxWidth:i,fontFamily:`var(--font-body)`,boxShadow:`0 24px 80px rgba(0,0,0,0.75), inset 0 1px 0 rgba(255,255,255,0.04), 0 0 0 1px rgba(212,175,55,0.18)`},children:[(0,X.jsx)(Uz,{className:`left-2 top-2`}),(0,X.jsx)(Uz,{className:`right-2 top-2 -scale-x-100`}),(0,X.jsx)(Uz,{className:`bottom-2 left-2 -scale-y-100`}),(0,X.jsx)(Uz,{className:`bottom-2 right-2 -scale-100`}),(0,X.jsx)(Hz,{}),(0,X.jsx)(`button`,{onClick:n,"aria-label":`Close overlay`,className:`absolute right-3 top-3 z-30 flex h-10 w-10 items-center justify-center rounded-sm border border-gold/40 bg-ink-900/70 text-gold-bright transition-all hover:border-gold hover:text-gold-bright hover:shadow-[0_0_12px_rgba(212,175,55,0.45)] active:scale-95`,style:{fontFamily:`var(--font-fantasy)`},children:(0,X.jsx)(Vz,{})}),(0,X.jsxs)(`div`,{className:`relative z-10 px-6 pb-8 pt-10 sm:px-10 sm:pb-10 sm:pt-12`,children:[(e||t)&&(0,X.jsxs)(`div`,{className:`mb-6 flex flex-col items-center text-center`,children:[e&&(0,X.jsx)(Q.h2,{initial:{opacity:0,y:-8},animate:{opacity:1,y:0},transition:{delay:.05,duration:.5},className:`font-title text-3xl tracking-[0.18em] text-gold-bright sm:text-4xl md:text-5xl`,style:{fontFamily:`var(--font-title)`,textShadow:`0 2px 16px rgba(0,0,0,0.9), 0 0 24px rgba(212,175,55,0.35)`},children:e}),(0,X.jsx)(Q.div,{initial:{scaleX:0},animate:{scaleX:1},transition:{delay:.2,duration:.7},className:`my-3 h-[1px] w-40 bg-gradient-to-r from-transparent via-gold/70 to-transparent sm:w-56`}),t&&(0,X.jsx)(Q.p,{initial:{opacity:0},animate:{opacity:1},transition:{delay:.3,duration:.5},className:`font-body text-base italic tracking-wide text-parchment-dim sm:text-lg`,style:{fontFamily:`var(--font-body)`},children:t})]}),r]})]},`overlay-panel`)},`overlay-backdrop`)),Gz=({label:e,value:t,color:n})=>{let r=Math.max(0,Math.min(100,t??0));return(0,X.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,X.jsx)(`span`,{className:`w-12 text-[10px] font-bold uppercase tracking-[0.25em] text-parchment-dark`,style:{fontFamily:`var(--font-fantasy)`},children:e}),(0,X.jsx)(`div`,{className:`h-1.5 flex-1 overflow-hidden rounded-full border border-gold/15 bg-ink-900/80`,children:(0,X.jsx)(Q.div,{initial:{width:0},animate:{width:`${r}%`},transition:{duration:.8,ease:[.22,1,.36,1]},className:`h-full rounded-full`,style:{backgroundColor:n,boxShadow:`0 0 8px ${n}88`}})}),(0,X.jsx)(`span`,{className:`w-8 text-right text-xs font-bold text-parchment-dim`,style:{fontFamily:`var(--font-fantasy)`},children:r})]})},Kz=({character:e,onSelect:t})=>{let n=e.glowColor||`#d4af37`;return(0,X.jsxs)(Q.button,{onClick:()=>t(e.id),whileHover:{y:-3},transition:{duration:.25},className:`group relative flex h-full flex-col items-stretch overflow-hidden rounded-sm border border-gold/25 bg-ink-900/70 p-3 text-left transition-all hover:border-gold/70 hover:shadow-[0_0_20px_2px_rgba(212,175,55,0.25)]`,children:[(0,X.jsx)(`span`,{className:`absolute -left-px -top-px h-4 w-4 border-l-2 border-t-2 border-gold/60 transition-opacity duration-300 group-hover:border-gold group-hover:opacity-100`}),(0,X.jsx)(`span`,{className:`absolute -bottom-px -right-px h-4 w-4 border-b-2 border-r-2 border-gold/60 transition-opacity duration-300 group-hover:border-gold group-hover:opacity-100`}),(0,X.jsx)(`div`,{className:`mb-3 h-32 overflow-hidden rounded-sm border border-gold/15 bg-ink-900`,children:(0,X.jsx)(kR,{character:e})}),(0,X.jsx)(`h3`,{className:`font-title text-lg tracking-widest text-gold-bright transition-all group-hover:[text-shadow:0_0_10px_rgba(212,175,55,0.7)]`,style:{fontFamily:`var(--font-title)`,color:n,textShadow:`0 0 10px ${n}55, 0 2px 6px rgba(0,0,0,0.9)`},children:e.name}),(0,X.jsx)(`p`,{className:`mt-0.5 text-xs italic text-parchment-dim`,style:{fontFamily:`var(--font-body)`},children:e.style}),(0,X.jsx)(`p`,{className:`mt-2 text-xs leading-relaxed text-parchment/80`,style:{fontFamily:`var(--font-body)`},children:e.description}),(0,X.jsxs)(`div`,{className:`mt-3 space-y-1.5`,children:[(0,X.jsx)(Gz,{label:`STR`,value:e.stats?.strength,color:n}),(0,X.jsx)(Gz,{label:`SPD`,value:e.stats?.speed,color:n}),(0,X.jsx)(Gz,{label:`DEF`,value:e.stats?.defense,color:n}),(0,X.jsx)(Gz,{label:`SHD`,value:e.stats?.shadow,color:n})]}),(0,X.jsx)(`span`,{className:`mt-3 text-[10px] uppercase tracking-[0.3em] text-parchment-dark transition-colors group-hover:text-gold-bright`,style:{fontFamily:`var(--font-fantasy)`},children:`~ read more ~`})]})},qz=({character:e,onBack:t})=>{let n=e.glowColor||`#d4af37`;return(0,X.jsxs)(Q.div,{initial:{opacity:0,y:16},animate:{opacity:1,y:0},exit:{opacity:0,y:-12},transition:{duration:.4,ease:[.22,1,.36,1]},className:`flex flex-col gap-6 md:flex-row`,children:[(0,X.jsx)(`div`,{className:`md:w-1/2`,children:(0,X.jsx)(`div`,{className:`h-72 overflow-hidden rounded-sm border border-gold/30 bg-ink-900 shadow-[0_0_24px_rgba(0,0,0,0.6)] md:h-[420px]`,children:(0,X.jsx)(kR,{character:e})})}),(0,X.jsxs)(`div`,{className:`flex flex-1 flex-col md:w-1/2`,children:[(0,X.jsx)(`button`,{onClick:t,className:`mb-3 self-start text-[10px] uppercase tracking-[0.3em] text-parchment-dim transition-colors hover:text-gold-bright`,style:{fontFamily:`var(--font-fantasy)`},children:`← back to the codex`}),(0,X.jsx)(`h3`,{className:`font-title text-3xl tracking-widest sm:text-4xl`,style:{fontFamily:`var(--font-title)`,color:n,textShadow:`0 0 14px ${n}66, 0 2px 8px rgba(0,0,0,0.9)`},children:e.name}),(0,X.jsx)(`p`,{className:`mt-1 text-sm italic text-parchment-dim sm:text-base`,style:{fontFamily:`var(--font-body)`},children:e.style}),(0,X.jsx)(`div`,{className:`my-3 h-[1px] w-full bg-gradient-to-r from-gold/40 via-gold/15 to-transparent`}),(0,X.jsx)(`p`,{className:`text-sm leading-relaxed text-parchment/90 sm:text-base`,style:{fontFamily:`var(--font-body)`},children:e.description}),(0,X.jsx)(`h4`,{className:`mt-6 text-[10px] font-bold uppercase tracking-[0.3em] text-gold-dim`,style:{fontFamily:`var(--font-fantasy)`},children:`~ combat ledger ~`}),(0,X.jsxs)(`div`,{className:`mt-3 space-y-2.5`,children:[(0,X.jsx)(Gz,{label:`STR`,value:e.stats?.strength,color:n}),(0,X.jsx)(Gz,{label:`SPD`,value:e.stats?.speed,color:n}),(0,X.jsx)(Gz,{label:`DEF`,value:e.stats?.defense,color:n}),(0,X.jsx)(Gz,{label:`SHD`,value:e.stats?.shadow,color:n})]})]})]},`detail-${e.id}`)};function Jz({onClose:e}){let[t,n]=(0,b.useState)(null),r=t==null?null:Iz.find(e=>e.id===t);return(0,X.jsx)(Wz,{title:`The Codex of Albion`,subtitle:`A record of every shadow that has walked these lands`,onClose:e,maxWidth:`1200px`,children:(0,X.jsx)(ZD,{mode:`wait`,children:r?(0,X.jsx)(qz,{character:r,onBack:()=>n(null)},`detail`):(0,X.jsx)(Q.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.25},className:`grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4`,children:Iz.map(e=>(0,X.jsx)(Kz,{character:e,onSelect:n},e.id))},`grid`)})})}var Yz=[{id:`head`,label:`Head`,hint:`Hoods, helms, circlets`},{id:`body`,label:`Body`,hint:`Armor, sashes, scarves`},{id:`legs`,label:`Legs`,hint:`Boots, greaves, wraps`}],Xz=({label:e,hint:t})=>(0,X.jsxs)(`div`,{className:`relative flex h-44 flex-col items-center justify-center overflow-hidden rounded-sm border-2 border-dashed border-gold/40 bg-ink-900/70 sm:h-52`,children:[(0,X.jsx)(`span`,{className:`pointer-events-none absolute inset-1 rounded-sm border border-gold/15`}),(0,X.jsx)(`span`,{className:`mb-2 text-[10px] font-bold uppercase tracking-[0.3em] text-gold-dim`,style:{fontFamily:`var(--font-fantasy)`},children:e}),(0,X.jsx)(`span`,{className:`text-xs italic text-parchment-dark`,style:{fontFamily:`var(--font-body)`},children:t}),(0,X.jsx)(Q.div,{initial:{rotate:-8,scale:.9,opacity:0},animate:{rotate:-8,scale:1,opacity:1},transition:{delay:.3,duration:.4},className:`pointer-events-none absolute right-2 top-2 rounded-sm border-2 border-[#8c1a1a] bg-[#3a0a0a]/70 px-2 py-0.5 text-[10px] font-extrabold uppercase tracking-[0.2em] text-[#d9a3a3] shadow-[0_0_10px_rgba(140,26,26,0.6)]`,style:{fontFamily:`var(--font-fantasy)`},children:`Locked`}),(0,X.jsxs)(`svg`,{className:`pointer-events-none absolute bottom-2 right-2 h-5 w-5 text-gold/35`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.4`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,X.jsx)(`rect`,{x:`5`,y:`11`,width:`14`,height:`9`,rx:`1`}),(0,X.jsx)(`path`,{d:`M8 11V7a4 4 0 0 1 8 0v4`})]})]});function Zz({onClose:e}){return(0,X.jsxs)(Wz,{title:`The Forge`,subtitle:`Where warriors are made`,onClose:e,maxWidth:`1200px`,children:[(0,X.jsx)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-4 sm:gap-4`,children:Iz.map((e,t)=>(0,X.jsxs)(Q.div,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{delay:.1+t*.05,duration:.45},className:`flex flex-col items-stretch`,children:[(0,X.jsx)(`div`,{className:`mb-2 h-44 overflow-hidden rounded-sm border border-gold/25 bg-ink-900 sm:h-56`,children:(0,X.jsx)(kR,{character:e})}),(0,X.jsx)(`h4`,{className:`text-center font-title text-sm tracking-widest`,style:{fontFamily:`var(--font-title)`,color:e.glowColor||`#d4af37`,textShadow:`0 0 8px ${e.glowColor||`#d4af37`}55, 0 1px 4px rgba(0,0,0,0.9)`},children:e.name})]},e.id))}),(0,X.jsxs)(`div`,{className:`mt-8`,children:[(0,X.jsx)(`h3`,{className:`mb-4 text-center text-[10px] font-bold uppercase tracking-[0.3em] text-gold-dim`,style:{fontFamily:`var(--font-fantasy)`},children:`~ customization slots ~`}),(0,X.jsx)(`div`,{className:`grid grid-cols-1 gap-4 sm:grid-cols-3`,children:Yz.map(e=>(0,X.jsx)(Xz,{label:e.label,hint:e.hint},e.id))})]}),(0,X.jsx)(`p`,{className:`mt-8 text-center text-xs italic text-parchment-dim sm:text-sm`,style:{fontFamily:`var(--font-body)`},children:`The smiths are still tempering these blades. Return soon.`})]})}var Qz=({on:e,onToggle:t,label:n})=>(0,X.jsx)(`button`,{role:`switch`,"aria-checked":e,"aria-label":n,onClick:t,className:`relative inline-flex h-6 w-11 items-center rounded-full border transition-all ${e?`border-gold/70 bg-gold/30`:`border-gold/25 bg-ink-900/70`}`,style:{fontFamily:`var(--font-fantasy)`},children:(0,X.jsx)(Q.span,{layout:!0,transition:{type:`spring`,stiffness:500,damping:30},className:`block h-4 w-4 rounded-full ${e?`ml-6 bg-gold-bright`:`ml-1 bg-parchment-dim/70`}`,style:{boxShadow:e?`0 0 8px rgba(212,175,55,0.7)`:`0 0 4px rgba(0,0,0,0.4)`}})});function $z({onClose:e,gpuActive:t=!1}){let[n,r]=(0,b.useState)(!0),[i,a]=(0,b.useState)(!1);return(0,X.jsx)(Wz,{title:`Quick Settings`,subtitle:`Tweak thy duel before the bell rings`,onClose:e,maxWidth:`780px`,children:(0,X.jsxs)(`div`,{className:`space-y-6`,children:[(0,X.jsxs)(`section`,{children:[(0,X.jsxs)(`h3`,{className:`mb-3 flex items-center gap-2 border-b border-gold/20 pb-2 text-xs font-bold uppercase tracking-[0.3em] text-gold-dim`,style:{fontFamily:`var(--font-fantasy)`},children:[(0,X.jsx)(`span`,{className:`h-[1px] w-5 bg-gold/40`}),`Blade & Boot Bindings`,(0,X.jsx)(`span`,{className:`h-[1px] flex-1 bg-gold/20`})]}),(0,X.jsx)(`ul`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-2`,children:Rz.map(e=>(0,X.jsxs)(`li`,{className:`flex items-center justify-between rounded-sm border border-gold/20 bg-ink-900/60 px-3 py-2`,children:[(0,X.jsx)(`span`,{className:`text-sm text-parchment/90`,style:{fontFamily:`var(--font-body)`},children:e.action}),(0,X.jsx)(`span`,{className:`rounded-sm border border-gold/45 bg-ink-800/80 px-2 py-0.5 text-[11px] font-bold tracking-widest text-gold-bright shadow-sm`,style:{fontFamily:`var(--font-fantasy)`},children:e.keys})]},e.action))})]}),(0,X.jsxs)(`section`,{children:[(0,X.jsxs)(`h3`,{className:`mb-3 flex items-center gap-2 border-b border-gold/20 pb-2 text-xs font-bold uppercase tracking-[0.3em] text-gold-dim`,style:{fontFamily:`var(--font-fantasy)`},children:[(0,X.jsx)(`span`,{className:`h-[1px] w-5 bg-gold/40`}),`Display`,(0,X.jsx)(`span`,{className:`h-[1px] flex-1 bg-gold/20`})]}),(0,X.jsxs)(`div`,{className:`space-y-3 rounded-sm border border-gold/20 bg-ink-900/60 p-4`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`p`,{className:`text-sm font-bold text-parchment`,style:{fontFamily:`var(--font-fantasy)`},children:`Show on-screen controls`}),(0,X.jsx)(`p`,{className:`text-xs italic text-parchment-dark`,style:{fontFamily:`var(--font-body)`},children:`Overlay touch buttons on mobile`})]}),(0,X.jsx)(Qz,{on:n,onToggle:()=>r(e=>!e),label:`Show on-screen controls`})]}),(0,X.jsxs)(`div`,{className:`flex items-center justify-between border-t border-gold/10 pt-3`,children:[(0,X.jsx)(`p`,{className:`text-sm font-bold text-parchment`,style:{fontFamily:`var(--font-fantasy)`},children:`GPU Status`}),(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-2 rounded-full border px-3 py-1 text-[10px] font-bold uppercase tracking-[0.25em] ${t?`border-crit/60 bg-crit/10 text-crit`:`border-[#6c8e6a]/60 bg-[#6c8e6a]/10 text-[#6c8e6a]`}`,style:{fontFamily:`var(--font-fantasy)`},children:[(0,X.jsx)(`span`,{className:`h-2 w-2 rounded-full ${t?`bg-crit animate-pulse-glow`:`bg-[#6c8e6a]`}`}),t?`Active`:`Idle`]})]})]})]}),(0,X.jsx)(`section`,{className:`pt-2`,children:(0,X.jsxs)(`div`,{className:`flex flex-col items-center gap-3`,children:[(0,X.jsx)(`button`,{onClick:()=>a(!0),className:`min-w-[260px] rounded-sm border border-gold/55 bg-gradient-to-b from-gold/20 to-gold/5 px-8 py-3 font-title text-sm tracking-[0.2em] text-parchment transition-all hover:-translate-y-0.5 hover:border-gold hover:text-gold-bright hover:shadow-[0_0_20px_2px_rgba(212,175,55,0.35)] active:scale-95`,style:{fontFamily:`var(--font-title)`},children:`Open Full Settings`}),(0,X.jsx)(ZD,{children:i&&(0,X.jsxs)(Q.p,{initial:{opacity:0,y:-4},animate:{opacity:1,y:0},exit:{opacity:0},transition:{duration:.3},className:`text-center text-xs italic text-parchment-dim`,style:{fontFamily:`var(--font-body)`},children:[`Full settings (audio, video, gameplay) are available in-game — press `,(0,X.jsx)(`span`,{className:`font-bold text-gold-bright`,children:`ESC`}),` `,`during a duel.`]})})]})})]})})}function eB(e){return typeof document>`u`?`#ffffff`:getComputedStyle(document.documentElement).getPropertyValue(e).trim()||`#ffffff`}function tB(e){let t=e.replace(`#`,``);return parseInt(t,16)}function nB({children:e}){let t=(0,b.useRef)([]),n=(0,b.useRef)([]),r=(0,b.useRef)([]),i=(0,b.useRef)(0),a=(0,b.useCallback)(()=>tB(eB(`--color-player`)),[]),o=(0,b.useCallback)(()=>tB(eB(`--color-enemy`)),[]),s=(0,b.useCallback)(()=>tB(eB(`--color-crit`)),[]),c=(0,b.useCallback)(()=>tB(eB(`--color-parchment-dim`)),[]),l=(0,b.useCallback)((e,n={})=>{let{count:r=18,isCrit:c=!1,isPlayer:l=!1}=n,u=c?s():l?a():o(),d=[];for(let t=0;t200&&t.current.splice(0,t.current.length-200)},[s,a,o]),u=(0,b.useCallback)(e=>{let n=c(),r=[];for(let t=0;t<8;t++)r.push({id:i.current++,type:`dust`,x:e[0]+(Math.random()-.5)*.4,y:.05,z:(e[2]||0)+(Math.random()-.5)*.4,vx:(Math.random()-.5)*1.2,vy:.3+Math.random()*.5,vz:(Math.random()-.5)*1.2,life:1,maxLife:1,color:n,size:.06+Math.random()*.08});t.current.push(...r),t.current.length>200&&t.current.splice(0,t.current.length-200)},[c]),d=(0,b.useCallback)((e,t={})=>{let{color:r,isPlayer:s=!1}=t;n.current.push({id:i.current++,x:e[0],y:e[1]||.02,z:e[2]||0,radius:.1,maxRadius:t.maxRadius||2.5,life:1,color:r||(s?a():o())})},[a,o]),f=(0,b.useCallback)((e,t={})=>{let{isCrit:n=!1,isPlayer:c=!1}=t;r.current.push({id:i.current++,x:e[0],y:e[1]||1.3,z:e[2]||0,life:1,maxLife:.35,scale:n?1.4:1,color:n?s():c?a():o()})},[s,a,o]),p=(0,b.useMemo)(()=>({particlesRef:t,shockwavesRef:n,splattersRef:r,spawnImpact:l,spawnFootstep:u,spawnShockwave:d,spawnSplatter:f}),[l,u,d,f]);return(0,X.jsx)(LL.Provider,{value:p,children:e})}var rB=3;function iB({lighting:e}){let{ambient:t,key:n,rim:r,environment:i}=e||{},a=(0,b.useRef)(),o=(0,b.useRef)(),s=(0,b.useRef)(null),c=(0,b.useRef)(null),l=(0,b.useRef)(new K),u=(0,b.useRef)(new K);return P_(t=>{if(!e)return;let i=t.clock.elapsedTime;if(a.current&&n){s.current||=new K().copy(a.current.color);let e=Number.isFinite(n.flickerSeed)?n.flickerSeed:0,t=Math.sin(i*8+e)*.1+.95;a.current.intensity=n.intensity*rB*t;let r=s.current,o=Math.sin(i*5+e)*.02;l.current.setRGB(Math.max(0,Math.min(1,r.r+o*.3)),Math.max(0,Math.min(1,r.g+o*.1)),Math.max(0,Math.min(1,r.b-o*.1))),a.current.color.copy(l.current)}if(o.current&&r){c.current||=new K().copy(o.current.color);let e=Number.isFinite(r.flickerSeed)?r.flickerSeed:1.7,t=Math.sin(i*7+e)*.08+.96;o.current.intensity=r.intensity*rB*t;let n=c.current,a=Math.sin(i*4.5+e)*.015;u.current.setRGB(Math.max(0,Math.min(1,n.r+a*.25)),Math.max(0,Math.min(1,n.g+a*.05)),Math.max(0,Math.min(1,n.b-a*.05))),o.current.color.copy(u.current)}}),e?(0,X.jsxs)(X.Fragment,{children:[i&&i.preset&&(0,X.jsx)(MM,{preset:i.preset,environmentIntensity:i.intensity??.35,background:!!i.background}),t&&(0,X.jsx)(`ambientLight`,{intensity:t.intensity,color:t.color}),n&&(0,X.jsx)(`directionalLight`,{ref:a,position:n.position,intensity:n.intensity,color:n.color,castShadow:!!n.castShadow,"shadow-mapSize-width":n.castShadow?2048:void 0,"shadow-mapSize-height":n.castShadow?2048:void 0,"shadow-bias":-5e-4,"shadow-normalBias":.02,"shadow-camera-left":-20,"shadow-camera-right":20,"shadow-camera-top":20,"shadow-camera-bottom":-20,"shadow-camera-near":.5,"shadow-camera-far":60}),r&&(0,X.jsx)(`directionalLight`,{ref:o,position:r.position,intensity:r.intensity,color:r.color})]}):null}var aB=null;function oB(){if(aB)return aB;let e=document.createElement(`canvas`);e.width=32,e.height=256;let t=e.getContext(`2d`),n=t.createLinearGradient(0,0,0,256);n.addColorStop(0,`rgba(255,255,255,1)`),n.addColorStop(.25,`rgba(255,255,255,0.55)`),n.addColorStop(.6,`rgba(255,255,255,0.18)`),n.addColorStop(1,`rgba(255,255,255,0)`),t.fillStyle=n,t.fillRect(0,0,32,256);let r=new ys(e);return r.colorSpace=bt,r.minFilter=M,r.magFilter=M,r.generateMipmaps=!1,aB=r,r}function sB({position:e=[0,12,0],targetY:t=0,color:n=`#fff5d8`,width:r=2.5,intensity:i=.6,animated:a=!0}){let o=(0,b.useRef)(),s=(0,b.useRef)(),c=(0,b.useMemo)(()=>oB(),[]),l=e[1],u=Math.max(.1,l-t),d=(l+t)/2,f=Math.max(0,Math.min(1,i))*.25,p=e[0]*.3+e[2]*.7;return P_(e=>{if(!a){o.current&&(o.current.opacity=f),s.current&&(s.current.opacity=f*.7);return}let t=e.clock.elapsedTime,n=1+Math.sin(t*1.4+p)*.1;o.current&&(o.current.opacity=f*n),s.current&&(s.current.opacity=f*.7*n)}),(0,X.jsxs)(`group`,{position:[e[0],d,e[2]],children:[(0,X.jsxs)(`mesh`,{children:[(0,X.jsx)(`planeGeometry`,{args:[r,u]}),(0,X.jsx)(`meshBasicMaterial`,{ref:o,color:n,map:c,alphaMap:c,transparent:!0,opacity:f,blending:2,depthWrite:!1,side:2,toneMapped:!1})]}),(0,X.jsxs)(`mesh`,{rotation:[0,Math.PI/2,0],children:[(0,X.jsx)(`planeGeometry`,{args:[r,u]}),(0,X.jsx)(`meshBasicMaterial`,{ref:s,color:n,map:c,alphaMap:c,transparent:!0,opacity:f*.7,blending:2,depthWrite:!1,side:2,toneMapped:!1})]})]})}var cB=` float pfHash21(vec2 p) { p = fract(p * vec2(123.34, 456.21)); p += dot(p, p + 45.32); return fract(p.x * p.y); } vec2 pfHash22(vec2 p) { return vec2(pfHash21(p), pfHash21(p + 17.17)); } // Each pattern returns vec4(color, intensity). intensity in [0,1] is the // amount of pattern modification at this pixel (0 = pure base color, 1 = // full crack/accent). The fragment shader uses it to mix the overlay // alpha between uBaseAlpha (base areas) and 1.0 (crack/accent areas). // Cracked obsidian-style stone: brick-like tiles with thin dark cracks and // a sparse glowing accent (lava seams, runic glow). vec4 patternCrackedStone(vec2 wp, vec3 base, vec3 crack, vec3 accent) { vec2 cell = floor(wp * 0.45); vec2 jitter = (pfHash22(cell) - 0.5) * 0.6; vec2 local = fract(wp * 0.45) - 0.5 + jitter * 0.3; float brick = max( smoothstep(0.48, 0.5, abs(local.x)), smoothstep(0.46, 0.48, abs(local.y)) ); // Sparse sub-cracks float subSeed = pfHash21(floor(wp * 1.6)); float subCrack = step(0.965, subSeed) * 0.5; // Accent glow in occasional tiles float accentMask = step(0.78, pfHash21(cell + 9.0)) * 0.45; vec3 col = base; col = mix(col, crack, brick); col = mix(col, crack, subCrack); col = mix(col, accent, accentMask); float intensity = clamp(brick + subCrack + accentMask, 0.0, 1.0); return vec4(col, intensity); } // Wet dirt / moss path: irregular puddles, lighter moss patches and faint // reflective streaks. Used by the bamboo grove floor. vec4 patternWetPath(vec2 wp, vec3 base, vec3 crack, vec3 accent) { float n1 = pfHash21(floor(wp * 0.9)); float n2 = pfHash21(floor(wp * 0.9) + 3.0); vec2 cell = floor(wp * 0.9) + 0.5; float r = length(wp * 0.9 - cell); float puddle = (1.0 - smoothstep(0.18, 0.45, r)) * step(0.45, n1); // Subtle moss tufts float moss = step(0.7, pfHash21(floor(wp * 2.4) + 11.0)) * 0.35; // Streaky reflections inside puddles float streak = sin(wp.x * 1.7 + n2 * 6.28) * 0.5 + 0.5; streak = smoothstep(0.5, 0.95, streak); vec3 col = base; col = mix(col, crack, moss); col = mix(col, accent, puddle * 0.55); col = mix(col, accent * 1.2, puddle * streak * 0.35); float intensity = clamp(moss + puddle * 0.55 + puddle * streak * 0.35, 0.0, 1.0); return vec4(col, intensity); } // Cracked marble: warm sandy stone with veining, big dark cracks, gold flecks. vec4 patternCrackedMarble(vec2 wp, vec3 base, vec3 crack, vec3 accent) { float vein = sin(wp.x * 0.25 + sin(wp.y * 0.18) * 3.0) * 0.5 + 0.5; float vein2 = sin(wp.y * 0.4 + cos(wp.x * 0.22) * 2.0) * 0.5 + 0.5; float veins = smoothstep(0.55, 0.7, vein) * 0.4 + smoothstep(0.6, 0.85, vein2) * 0.25; // Big cracks vec2 g = abs(fract(wp * 0.18 + 0.5) - 0.5); float crackDist = min(g.x, g.y); float bigCrack = 1.0 - smoothstep(0.0, 0.025, crackDist); // Gold flecks float fleck = step(0.985, pfHash21(floor(wp * 3.0) + 5.0)); vec3 col = base; col = mix(col, crack, clamp(veins, 0.0, 1.0) * 0.35); col = mix(col, crack, bigCrack * 0.6); col = mix(col, accent, fleck * 0.5); float intensity = clamp(veins * 0.35 + bigCrack * 0.6 + fleck * 0.5, 0.0, 1.0); return vec4(col, intensity); } // Black ice: smooth glassy surface with hex-ish crack lattice. Intensity // is 0 across the smooth body (so the reflection dominates) and 1 on // the crack lines / sub-cracks. vec4 patternBlackIce(vec2 wp, vec3 base, vec3 crack, vec3 accent) { // Hex-ish crack lattice. vec2 hp = wp * 0.55; vec2 s = vec2(1.0, 1.732); vec2 a = mod(hp, s) - s * 0.5; vec2 b = mod(hp - s * 0.5, s) - s * 0.5; float da = min(min(abs(a.x), abs(a.y)), length(a) * 0.7); float db = min(min(abs(b.x), abs(b.y)), length(b) * 0.7); float crackMask = 1.0 - smoothstep(0.0, 0.03, min(da, db)); // Sub cracks float sub = step(0.97, pfHash21(floor(wp * 1.4) + 2.0)) * 0.5; crackMask = max(crackMask, sub); // Slow shimmer band float shimmer = sin(wp.x * 0.6 + wp.y * 0.35) * 0.5 + 0.5; vec3 col = base + accent * 0.18 * shimmer; col = mix(col, crack, clamp(crackMask, 0.0, 1.0)); float intensity = clamp(crackMask, 0.0, 1.0); return vec4(col, intensity); } `,lB={crackedStone:0,wetPath:1,crackedMarble:2,blackIce:3},uB={blur:[100,100],resolution:256,mixBlur:1,mixStrength:.6,mirror:.5,depthScale:.5,minDepthThreshold:.4,maxDepthThreshold:1.4,baseAlpha:.4};function dB({floor:e}){let{size:t=[60,60],baseColor:n=`#222222`,crackColor:r=`#000000`,accentColor:i=`#ffffff`,pattern:a=`crackedStone`,roughness:o=.9,metalness:s=0,reflection:c}=e||{},l=(0,b.useMemo)(()=>({...uB,...c||{}}),[c]),u=(0,b.useMemo)(()=>{let e=new Tl({color:16777215,roughness:o,metalness:s,transparent:!0,depthWrite:!1});return e.onBeforeCompile=s=>{s.uniforms.uBaseColor={value:new K(n)},s.uniforms.uCrackColor={value:new K(r)},s.uniforms.uAccentColor={value:new K(i)},s.uniforms.uPattern={value:lB[a]??0},s.uniforms.uRoughness={value:o},s.uniforms.uBaseAlpha={value:l.baseAlpha},s.uniforms.uFloorSize={value:new W(t[0],t[1])},s.vertexShader=s.vertexShader.replace(`#include `,`#include varying vec2 vFloorPos;`),s.vertexShader=s.vertexShader.replace(`#include `,`#include vec4 _floorWP = modelMatrix * vec4(position, 1.0); vFloorPos = _floorWP.xz;`),s.fragmentShader=s.fragmentShader.replace(`#include `,`#include varying vec2 vFloorPos; uniform vec3 uBaseColor; uniform vec3 uCrackColor; uniform vec3 uAccentColor; uniform float uPattern; uniform float uRoughness; uniform float uBaseAlpha; ${cB}`),s.fragmentShader=s.fragmentShader.replace(`#include `,`#include vec4 _floorCol; if (uPattern < 0.5) { _floorCol = patternCrackedStone(vFloorPos, uBaseColor, uCrackColor, uAccentColor); } else if (uPattern < 1.5) { _floorCol = patternWetPath(vFloorPos, uBaseColor, uCrackColor, uAccentColor); } else if (uPattern < 2.5) { _floorCol = patternCrackedMarble(vFloorPos, uBaseColor, uCrackColor, uAccentColor); } else { _floorCol = patternBlackIce(vFloorPos, uBaseColor, uCrackColor, uAccentColor); } diffuseColor.rgb = _floorCol.rgb; // Pixels that are pure base show the reflection through; cracks/accents // are fully opaque. diffuseColor.a = mix(uBaseAlpha, 1.0, clamp(_floorCol.a, 0.0, 1.0));`),s.fragmentShader=s.fragmentShader.replace(`#include `,`#include roughnessFactor = uRoughness;`),e.userData.shader=s},e.customProgramCacheKey=()=>`procedural-floor-${a}-${n}-${r}-${i}-${o}-${s}-${l.baseAlpha}`,e},[n,r,i,a,o,s,t,l.baseAlpha]);return(0,X.jsxs)(`group`,{children:[(0,X.jsxs)(`mesh`,{rotation:[-Math.PI/2,0,0],position:[0,0,0],children:[(0,X.jsx)(`planeGeometry`,{args:t}),(0,X.jsx)(Xj,{color:n,resolution:l.resolution,blur:l.blur,mixBlur:l.mixBlur,mixStrength:l.mixStrength,mirror:l.mirror,depthScale:l.depthScale,minDepthThreshold:l.minDepthThreshold,maxDepthThreshold:l.maxDepthThreshold,roughness:o,metalness:s})]}),(0,X.jsx)(`mesh`,{rotation:[-Math.PI/2,0,0],receiveShadow:!0,position:[0,.01,0],material:u,children:(0,X.jsx)(`planeGeometry`,{args:t})})]})}function fB({depth:e=.5,strength:t=1,color:n=`#000000`,y:r=0,z:i=-20,kind:a=`plane`,size:o=[40,20],shapes:s=[],opacity:c=1}){let{camera:l}=N_(),u=(0,b.useRef)();P_(()=>{if(!u.current)return;let n=l.position?.x??0;u.current.position.x=n*(1-e)*t});let d={color:n,depthWrite:!1,transparent:c<1,opacity:c};return(0,X.jsxs)(`group`,{ref:u,position:[0,r,i],children:[a===`plane`&&(0,X.jsxs)(`mesh`,{children:[(0,X.jsx)(`planeGeometry`,{args:o}),(0,X.jsx)(`meshBasicMaterial`,{...d})]}),a===`silhouette`&&s.map((e,t)=>{if(e.type===`box`)return(0,X.jsxs)(`mesh`,{position:e.position||[0,0,0],children:[(0,X.jsx)(`boxGeometry`,{args:e.size||[1,1,1]}),(0,X.jsx)(`meshBasicMaterial`,{...d})]},t);if(e.type===`arch`){let{width:n,height:r,thickness:i}=e;return(0,X.jsxs)(`group`,{position:e.position||[0,0,0],children:[(0,X.jsxs)(`mesh`,{position:[-n/2,r/2,0],children:[(0,X.jsx)(`boxGeometry`,{args:[i,r,.1]}),(0,X.jsx)(`meshBasicMaterial`,{...d})]}),(0,X.jsxs)(`mesh`,{position:[n/2,r/2,0],children:[(0,X.jsx)(`boxGeometry`,{args:[i,r,.1]}),(0,X.jsx)(`meshBasicMaterial`,{...d})]}),(0,X.jsxs)(`mesh`,{position:[0,r+i/2,0],children:[(0,X.jsx)(`boxGeometry`,{args:[n+i,i,.1]}),(0,X.jsx)(`meshBasicMaterial`,{...d})]})]},t)}return null})]})}function pB({count:e=40,color:t=`#cbd5e0`,size:n=1.2,opacity:r=.18,spread:i=[40,.5,25],origin:a=[0,.2,-4]}){let o=(0,b.useRef)(),s=(0,b.useMemo)(()=>ZP(),[]),c=(0,b.useMemo)(()=>new Float32Array(e*3),[e]),l=(0,b.useMemo)(()=>new Float32Array(e),[e]),u=(0,b.useMemo)(()=>new Float32Array(e),[e]);return(0,b.useEffect)(()=>{let[t,,n]=i,[r,,s]=a;for(let i=0;i{if(!o.current)return;let n=t.clock.elapsedTime,[r,,s]=i,[d,f,p]=a;for(let t=0;t{let t=new Float32Array(e*3),n=new Float32Array(e),r=new Float32Array(e),i=new Float32Array(e),a=new Float32Array(e);for(let o=0;oQP(),[]);return P_((t,n)=>{let r=c.current;if(!r)return;let i=r.geometry.attributes.position.array,a=t.clock.elapsedTime;for(let t=0;tp+u&&(i[t*3+1]=p,i[t*3]=f+Math.random()*l-l*.5,i[t*3+2]=m+Math.random()*d-d*.5);r.geometry.attributes.position.needsUpdate=!0}),(0,X.jsxs)(`points`,{ref:c,children:[(0,X.jsx)(`bufferGeometry`,{children:(0,X.jsx)(`bufferAttribute`,{attach:`attributes-position`,array:h.positions,count:e,itemSize:3})}),(0,X.jsx)(`pointsMaterial`,{size:i,color:r,map:g,alphaMap:g,transparent:!0,opacity:a,sizeAttenuation:!0,blending:2,depthWrite:!1})]})}function hB({position:e,color:t}){let n=(0,b.useRef)(),r=(0,b.useRef)();return P_(t=>{let i=t.clock.elapsedTime;n.current&&(n.current.material.opacity=.5+Math.sin(i*3+e[0])*.15),r.current&&(r.current.intensity=1.2+Math.sin(i*3+e[0])*.3)}),(0,X.jsxs)(`group`,{position:e,children:[(0,X.jsxs)(`mesh`,{castShadow:!0,position:[0,4,0],children:[(0,X.jsx)(`cylinderGeometry`,{args:[.35,.45,8,12]}),(0,X.jsx)(`meshStandardMaterial`,{color:`#151219`,roughness:.95,metalness:.2})]}),(0,X.jsxs)(`mesh`,{position:[0,8.4,0],ref:n,children:[(0,X.jsx)(`sphereGeometry`,{args:[.35,16,16]}),(0,X.jsx)(`meshBasicMaterial`,{color:t,transparent:!0,opacity:.6})]}),(0,X.jsx)(`pointLight`,{ref:r,position:[0,8.4,0],intensity:1.2,color:t,distance:20,decay:2})]})}function gB({arena:e}){let t=(0,b.useRef)(),n=e?.atmosphere,r=(0,b.useRef)(0),i=(0,b.useRef)(0),{shockwavesRef:a}=RL();P_((e,n)=>{t.current&&(t.current.material.opacity=.4+Math.sin(e.clock.elapsedTime*2)*.1);let o=a?.current;if(o){let e=o.length;e>i.current&&(r.current=Math.min(.6,r.current+.4)),i.current=e}r.current*=Math.exp(-1.8*Math.min(n||.016,.05)),r.current<.001&&(r.current=0)});let o=(0,b.useMemo)(()=>[{x:-12,color:`#2ec4b6`},{x:-7,color:`#d4af37`},{x:7,color:`#d4af37`},{x:12,color:`#e71d36`}],[]);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`color`,{attach:`background`,args:[`#05040a`]}),(0,X.jsx)(`fog`,{attach:`fog`,args:[`#05040a`,14,50]}),(0,X.jsx)(iB,{lighting:n.lighting}),(0,X.jsx)(`pointLight`,{position:[-4,6,3],intensity:1.8,color:`#2ec4b6`,distance:22,decay:2}),(0,X.jsx)(`pointLight`,{position:[4,6,3],intensity:1.8,color:`#e71d36`,distance:22,decay:2}),(0,X.jsx)(`pointLight`,{position:[0,4,-8],intensity:.9,color:`#d4af37`,distance:18,decay:2}),(0,X.jsx)(`spotLight`,{position:[0,16,8],intensity:1,angle:.55,penumbra:.85,color:`#f0e6d2`,castShadow:!0,"shadow-mapSize-width":1024,"shadow-mapSize-height":1024,"shadow-bias":-.001}),(0,X.jsx)(dB,{floor:n.floor}),(0,X.jsxs)(`mesh`,{position:[0,.01,0],rotation:[-Math.PI/2,0,0],ref:t,children:[(0,X.jsx)(`ringGeometry`,{args:[4,4.25,64]}),(0,X.jsx)(`meshBasicMaterial`,{color:`#2a2010`,transparent:!0,opacity:.6})]}),n.parallax.map((e,t)=>(0,X.jsx)(fB,{...e},t)),(n.beams||[]).map((e,t)=>(0,X.jsx)(sB,{...e},`beam-${t}`)),n.floorFog&&(0,X.jsx)(pB,{...n.floorFog}),o.map((e,t)=>(0,X.jsx)(hB,{position:[e.x,0,-12],color:e.color},t)),n.particles.map((e,t)=>e.kind===`ember`?(0,X.jsx)(mB,{...e},`p-${t}`):null),(0,X.jsx)(aF,{count:80,bounds:[24,6,14],origin:[0,2.5,-3],color:`#ffb45a`,size:.22,opacity:.55,drift:.35,repelRadius:2,repelStrength:7.5,damping:1.4,sizePulseRef:r})]})}var _B=` attribute float aAngle; attribute float aSpin; uniform float uTime; uniform float uPixelRatio; varying float vAngle; void main() { vAngle = aAngle + aSpin * uTime; vec4 mvPosition = modelViewMatrix * vec4(position, 1.0); gl_Position = projectionMatrix * mvPosition; gl_PointSize = 60.0 * uPixelRatio / max(0.1, -mvPosition.z); } `,vB=` uniform sampler2D uMap; uniform vec3 uColor; uniform float uOpacity; varying float vAngle; void main() { vec2 c = gl_PointCoord - 0.5; float s = sin(vAngle); float co = cos(vAngle); vec2 r = vec2(c.x * co - c.y * s, c.x * s + c.y * co); vec2 uv = r + 0.5; if (uv.x < 0.0 || uv.x > 1.0 || uv.y < 0.0 || uv.y > 1.0) discard; vec4 t = texture2D(uMap, uv); if (t.a < 0.04) discard; gl_FragColor = vec4(uColor, t.a * uOpacity); } `;function yB({count:e=90,bounds:t=[45,7,30],origin:n=[0,3,-6],color:r=`#adff2f`,opacity:i=.9,speed:a=.5,drift:o=.35,spin:s=1.4}){let c=(0,b.useRef)(),[l,u,d]=t,[f,p,m]=n,[h]=(0,b.useState)(()=>{let t=new Float32Array(e*3),n=new Float32Array(e),r=new Float32Array(e),i=new Float32Array(e),a=new Float32Array(e);for(let o=0;o({uMap:{value:$P()},uColor:{value:new K(r)},uOpacity:{value:i},uTime:{value:0},uPixelRatio:{value:Math.min(typeof window<`u`&&window.devicePixelRatio||1,2)}}),[r,i]);return P_((t,n)=>{let r=c.current;if(!r)return;g.uTime.value=t.clock.elapsedTime;let i=r.geometry.attributes.position.array,s=t.clock.elapsedTime;for(let t=0;t{let t=new Float32Array(e*3),n=new Float32Array(e),r=new Float32Array(e);for(let i=0;iZP(),[]);return P_((t,n)=>{let r=c.current;if(!r)return;let i=r.geometry.attributes.position.array,a=t.clock.elapsedTime;for(let t=0;tp+u*.5&&(i[t*3+1]=p-u*.5,i[t*3]=f+Math.random()*l-l*.5,i[t*3+2]=m+Math.random()*d-d*.5);r.geometry.attributes.position.needsUpdate=!0}),(0,X.jsxs)(`points`,{ref:c,children:[(0,X.jsx)(`bufferGeometry`,{children:(0,X.jsx)(`bufferAttribute`,{attach:`attributes-position`,array:h.positions,count:e,itemSize:3})}),(0,X.jsx)(`pointsMaterial`,{size:i,color:r,map:g,alphaMap:g,transparent:!0,opacity:a,sizeAttenuation:!0,depthWrite:!1,blending:1})]})}var xB=` varying vec2 vUv; varying vec3 vWorldPosition; void main() { vUv = uv; vec4 worldPosition = modelMatrix * vec4(position, 1.0); vWorldPosition = worldPosition.xyz; gl_Position = projectionMatrix * viewMatrix * worldPosition; } `,SB=` uniform vec3 topColor; uniform vec3 bottomColor; uniform float intensity; varying vec2 vUv; varying vec3 vWorldPosition; void main() { float h = smoothstep(-0.2, 1.2, vUv.y); vec3 color = mix(bottomColor, topColor, h); gl_FragColor = vec4(color * intensity, 1.0); } `,CB=` uniform vec3 topColor; uniform vec3 bottomColor; uniform vec3 noiseColor; uniform float intensity; uniform float time; varying vec2 vUv; varying vec3 vWorldPosition; // Simplex-ish 2D noise vec3 mod289(vec3 x) { return x - floor(x * (1.0 / 289.0)) * 289.0; } vec2 mod289(vec2 x) { return x - floor(x * (1.0 / 289.0)) * 289.0; } vec3 permute(vec3 x) { return mod289(((x*34.0)+1.0)*x); } float snoise(vec2 v) { const vec4 C = vec4(0.211324865405187, 0.366025403784439, -0.577350269189626, 0.024390243902439); vec2 i = floor(v + dot(v, C.yy)); vec2 x0 = v - i + dot(i, C.xx); vec2 i1 = (x0.x > x0.y) ? vec2(1.0, 0.0) : vec2(0.0, 1.0); vec4 x12 = x0.xyxy + C.xxzz; x12.xy -= i1; i = mod289(i); vec3 p = permute(permute(i.y + vec3(0.0, i1.y, 1.0)) + i.x + vec3(0.0, i1.x, 1.0)); vec3 m = max(0.5 - vec3(dot(x0,x0), dot(x12.xy,x12.xy), dot(x12.zw,x12.zw)), 0.0); m = m*m; m = m*m; vec3 x = 2.0 * fract(p * C.www) - 1.0; vec3 h = abs(x) - 0.5; vec3 ox = floor(x + 0.5); vec3 a0 = x - ox; m *= 1.79284291400159 - 0.85373472095314 * (a0*a0 + h*h); vec3 g; g.x = a0.x * x0.x + h.x * x0.y; g.yz = a0.yz * x12.xz + h.yz * x12.yw; return 130.0 * dot(m, g); } void main() { float h = smoothstep(-0.2, 1.2, vUv.y); vec3 base = mix(bottomColor, topColor, h); float n1 = snoise(vUv * 4.0 + time * 0.03); float n2 = snoise(vUv * 10.0 - time * 0.05); float mist = smoothstep(-0.2, 0.6, n1 * 0.5 + n2 * 0.25); vec3 color = mix(base, noiseColor, mist * 0.35); gl_FragColor = vec4(color * intensity, 1.0); } `,wB=` uniform vec3 topColor; uniform vec3 midColor; uniform vec3 bottomColor; uniform float intensity; uniform float time; varying vec2 vUv; float hash(vec2 p) { return fract(sin(dot(p, vec2(12.9898, 78.233))) * 43758.5453); } void main() { float h = vUv.y; vec3 horizon = mix(bottomColor, midColor, smoothstep(0.0, 0.45, h)); vec3 color = mix(horizon, topColor, smoothstep(0.45, 1.0, h)); // Subtle banding / clouds float bands = sin(h * 20.0 + time * 0.04) * 0.5 + 0.5; color += (midColor - color) * bands * 0.08 * (1.0 - h); gl_FragColor = vec4(color * intensity, 1.0); } `;function TB(e){return function(){let t=e+=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 EB({count:e=80}){let t=(0,b.useRef)(),n=(0,b.useMemo)(()=>new Fr,[]),r=(0,b.useMemo)(()=>{let t=TB(11839232),n=[];for(let r=0;r{if(!t.current)return;let i=e.clock.elapsedTime,a=Math.sin(Math.PI/5*i),o=.55+.45*(.5+.5*Math.sin(i*.6));r.forEach((e,r)=>{let s=Math.sin(i*1.2*e.windFreq+e.phase)*.04+(a+e.windBias)*e.windResponse*.08*o;n.position.set(e.x,e.height/2,e.z),n.scale.set(e.scale,e.height,e.scale),n.rotation.set(e.lean,0,s),n.updateMatrix(),t.current.setMatrixAt(r,n.matrix)}),t.current.instanceMatrix.needsUpdate=!0}),(0,X.jsxs)(`instancedMesh`,{ref:t,args:[null,null,e],receiveShadow:!0,castShadow:!0,children:[(0,X.jsx)(`cylinderGeometry`,{args:[.06,.08,1,8]}),(0,X.jsx)(`meshStandardMaterial`,{color:`#2d4a32`,roughness:.85,metalness:.05})]})}function DB({y:e,opacity:t,color:n}){let r=(0,b.useRef)();return P_(n=>{if(!r.current)return;let i=n.clock.elapsedTime;r.current.position.x=Math.sin(i*.15)*2,r.current.material.opacity=t+Math.sin(i+e)*.03}),(0,X.jsxs)(`mesh`,{position:[0,e,-15],rotation:[-Math.PI/2,0,0],ref:r,children:[(0,X.jsx)(`planeGeometry`,{args:[70,40,1,1]}),(0,X.jsx)(`meshBasicMaterial`,{color:n,transparent:!0,opacity:t,depthWrite:!1})]})}function OB({arena:e}){let{atmosphere:t}=e||{},n=(0,b.useMemo)(()=>({topColor:{value:new K(`#0d1f17`)},bottomColor:{value:new K(`#3a5f40`)},noiseColor:{value:new K(`#8fbc8f`)},intensity:{value:1.1},time:{value:0}}),[]);return P_(e=>{n.time.value=e.clock.elapsedTime}),(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`color`,{attach:`background`,args:[`#0d1f17`]}),(0,X.jsx)(`fog`,{attach:`fog`,args:[`#1a3322`,12,46]}),(0,X.jsxs)(`mesh`,{scale:[-120,120,120],children:[(0,X.jsx)(`sphereGeometry`,{args:[1,32,32]}),(0,X.jsx)(`shaderMaterial`,{vertexShader:xB,fragmentShader:CB,uniforms:n,side:1,depthWrite:!1})]}),(0,X.jsx)(iB,{lighting:t.lighting}),(0,X.jsx)(`pointLight`,{position:[0,5,-5],intensity:.8,color:`#90ee90`,distance:24,decay:2}),(0,X.jsx)(dB,{floor:t.floor}),(0,X.jsx)(EB,{count:90}),t.parallax.map((e,t)=>(0,X.jsx)(fB,{...e},t)),(t.beams||[]).map((e,t)=>(0,X.jsx)(sB,{...e},`beam-${t}`)),t.floorFog&&(0,X.jsx)(pB,{...t.floorFog}),(0,X.jsx)(DB,{y:.3,opacity:.18,color:`#a8c6a8`}),(0,X.jsx)(DB,{y:1.2,opacity:.12,color:`#d4e8d4`}),t.particles.map((e,t)=>e.kind===`leaf`?(0,X.jsx)(yB,{...e},`p-${t}`):e.kind===`dust`?(0,X.jsx)(bB,{...e},`p-${t}`):null),(0,X.jsx)(aF,{count:70,bounds:[28,5,16],origin:[0,1.8,-3],color:`#b8ff96`,size:.16,opacity:.6,drift:.3,repelRadius:1.8,repelStrength:6,damping:1.5})]})}function kB(e){return function(){let t=e+=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 AB({position:e,height:t,lean:n,color:r=`#6e5a45`}){return(0,X.jsxs)(`group`,{position:e,rotation:[n[0],n[1],n[2]],children:[(0,X.jsxs)(`mesh`,{castShadow:!0,receiveShadow:!0,position:[0,t/2,0],children:[(0,X.jsx)(`cylinderGeometry`,{args:[.55,.65,t,14]}),(0,X.jsx)(`meshStandardMaterial`,{color:r,roughness:.95,metalness:.1})]}),(0,X.jsxs)(`mesh`,{castShadow:!0,position:[0,t+.15,0],rotation:[.4,0,.2],children:[(0,X.jsx)(`cylinderGeometry`,{args:[.45,.55,.3,12]}),(0,X.jsx)(`meshStandardMaterial`,{color:r,roughness:.95})]}),[0,1,2,3,4,5].map(e=>(0,X.jsxs)(`mesh`,{position:[Math.cos(e/6*Math.PI*2)*.55,t/2,Math.sin(e/6*Math.PI*2)*.55],children:[(0,X.jsx)(`boxGeometry`,{args:[.08,t*.9,.04]}),(0,X.jsx)(`meshStandardMaterial`,{color:`#5c4a38`,roughness:.95})]},e))]})}function jB({position:e}){let t=(0,b.useRef)(),n=(0,b.useRef)();return P_(r=>{let i=r.clock.elapsedTime;t.current&&(t.current.intensity=1.4+Math.sin(i*8+e[0])*.3),n.current&&(n.current.scale.setScalar(1+Math.sin(i*10+e[2])*.08),n.current.rotation.z=Math.sin(i*6)*.1)}),(0,X.jsxs)(`group`,{position:e,children:[(0,X.jsxs)(`mesh`,{position:[0,.8,0],children:[(0,X.jsx)(`cylinderGeometry`,{args:[.08,.1,1.6,8]}),(0,X.jsx)(`meshStandardMaterial`,{color:`#3d3024`,roughness:.9})]}),(0,X.jsxs)(`mesh`,{ref:n,position:[0,1.75,0],children:[(0,X.jsx)(`coneGeometry`,{args:[.12,.35,8]}),(0,X.jsx)(`meshBasicMaterial`,{color:`#ff9d3e`,transparent:!0,opacity:.85})]}),(0,X.jsx)(`pointLight`,{ref:t,position:[0,1.8,0],intensity:1.4,color:`#ff7b2e`,distance:14,decay:2})]})}function MB({arena:e}){let{atmosphere:t}=e||{},n=(0,b.useMemo)(()=>({topColor:{value:new K(`#2a1c4a`)},midColor:{value:new K(`#b45a2b`)},bottomColor:{value:new K(`#e8a64d`)},intensity:{value:1.05},time:{value:0}}),[]);P_(e=>{n.time.value=e.clock.elapsedTime});let r=(0,b.useMemo)(()=>[{position:[-14,0,-10],height:5.5,lean:[.1,0,.05]},{position:[-10,0,-14],height:7,lean:[-.05,0,.08]},{position:[10,0,-13],height:4.2,lean:[.06,0,-.1]},{position:[15,0,-9],height:6.3,lean:[0,0,-.06]},{position:[-17,0,-4],height:3.5,lean:[.12,0,0]},{position:[17,0,-5],height:4,lean:[-.08,0,.04]}],[]);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`color`,{attach:`background`,args:[`#2a1c4a`]}),(0,X.jsx)(`fog`,{attach:`fog`,args:[`#5c3a1e`,14,52]}),(0,X.jsxs)(`mesh`,{scale:[-120,120,120],children:[(0,X.jsx)(`sphereGeometry`,{args:[1,32,32]}),(0,X.jsx)(`shaderMaterial`,{vertexShader:xB,fragmentShader:wB,uniforms:n,side:1,depthWrite:!1})]}),(0,X.jsx)(iB,{lighting:t.lighting}),(0,X.jsx)(`pointLight`,{position:[0,6,-8],intensity:.8,color:`#d4af37`,distance:28,decay:2}),(0,X.jsx)(dB,{floor:t.floor}),t.parallax.map((e,t)=>(0,X.jsx)(fB,{...e},t)),r.map((e,t)=>(0,X.jsx)(AB,{...e},t)),(t.beams||[]).map((e,t)=>(0,X.jsx)(sB,{...e},`beam-${t}`)),t.floorFog&&(0,X.jsx)(pB,{...t.floorFog}),(0,b.useMemo)(()=>{let e=kB(12587358);return[[-6,.12,-6],[7,.1,-7],[-4,.08,3],[5,.1,4]].map((t,n)=>({position:t,rotation:[e()*.4,e()*Math.PI,e()*.4],size:[.5+e()*.4,.2+e()*.2,.5+e()*.4],key:n}))},[]).map(({position:e,rotation:t,size:n,key:r})=>(0,X.jsxs)(`mesh`,{position:e,rotation:t,castShadow:!0,receiveShadow:!0,children:[(0,X.jsx)(`boxGeometry`,{args:n}),(0,X.jsx)(`meshStandardMaterial`,{color:`#6e5a45`,roughness:.95})]},r)),(0,X.jsx)(jB,{position:[-11,0,4]}),(0,X.jsx)(jB,{position:[11,0,4]}),(0,X.jsx)(jB,{position:[0,0,-9]}),t.particles.map((e,t)=>e.kind===`dust`?(0,X.jsx)(bB,{...e},`p-${t}`):e.kind===`ember`?(0,X.jsx)(mB,{...e},`p-${t}`):null)]})}function NB({count:e=220,bounds:t=[55,14,40],origin:n=[0,6,-6],color:r=`#e8f4ff`,opacity:i=.85,speed:a=.35,drift:o=.18}){let s=(0,b.useRef)(),c=(0,b.useRef)(),[l,u,d]=t,[f,p,m]=n,h=Math.max(1,Math.floor(e*.7)),g=Math.max(1,e-h),[_]=(0,b.useState)(()=>{let e=new Float32Array(h*3),t=new Float32Array(h),n=new Float32Array(h);for(let r=0;r{let e=new Float32Array(g*3),t=new Float32Array(g),n=new Float32Array(g);for(let r=0;rZP(),[]),x=(0,b.useMemo)(()=>eF(),[]);return P_((e,t)=>{let n=s.current,r=c.current,i=e.clock.elapsedTime;if(n){let e=n.geometry.attributes.position.array;for(let n=0;n>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}}function FB({position:e}){let t=(0,b.useRef)();return P_(e=>{t.current&&(t.current.material.opacity=.35+Math.sin(e.clock.elapsedTime*2)*.1)}),(0,X.jsxs)(`group`,{position:e,children:[(0,X.jsxs)(`mesh`,{castShadow:!0,position:[-2.5,3.5,0],children:[(0,X.jsx)(`boxGeometry`,{args:[.8,7,.8]}),(0,X.jsx)(`meshStandardMaterial`,{color:`#2a3d52`,roughness:.7,metalness:.2})]}),(0,X.jsxs)(`mesh`,{castShadow:!0,position:[2.5,3.5,0],children:[(0,X.jsx)(`boxGeometry`,{args:[.8,7,.8]}),(0,X.jsx)(`meshStandardMaterial`,{color:`#2a3d52`,roughness:.7,metalness:.2})]}),(0,X.jsxs)(`mesh`,{castShadow:!0,position:[0,7.2,0],children:[(0,X.jsx)(`boxGeometry`,{args:[6.2,.6,.9]}),(0,X.jsx)(`meshStandardMaterial`,{color:`#2a3d52`,roughness:.7,metalness:.2})]}),(0,X.jsxs)(`mesh`,{position:[0,7.6,0],children:[(0,X.jsx)(`boxGeometry`,{args:[6.6,.25,1.1]}),(0,X.jsx)(`meshStandardMaterial`,{color:`#e8f0f7`,roughness:.9})]}),(0,X.jsxs)(`mesh`,{ref:t,position:[0,4.5,.1],children:[(0,X.jsx)(`torusGeometry`,{args:[.55,.06,8,32]}),(0,X.jsx)(`meshBasicMaterial`,{color:`#6ecfff`,transparent:!0,opacity:.4})]}),(0,X.jsx)(`pointLight`,{position:[0,4.5,.5],intensity:1.2,color:`#6ecfff`,distance:16,decay:2})]})}var IB=` varying vec2 vUv; void main() { vUv = uv; gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0); } `,LB=` uniform float uTime; uniform vec3 uColorA; uniform vec3 uColorB; uniform vec3 uColorC; uniform float uOpacity; varying vec2 vUv; // Soft 1D wave: a sin centered on c with width w, returns 0..1. float band(float x, float c, float w) { float d = (x - c) / w; return exp(-d * d); } void main() { // Curtain altitude bias: aurora is brightest in the upper half of the // plane and fades to nothing toward the floor. float vertical = smoothstep(0.05, 0.55, vUv.y) * (1.0 - smoothstep(0.75, 1.05, vUv.y)); // Three bands drifting at different rates and widths. float a = band(vUv.x, 0.5 + 0.35 * sin(uTime * 0.07), 0.18); float b = band(vUv.x, 0.5 + 0.30 * sin(uTime * 0.11 + 2.1), 0.14); float c = band(vUv.x, 0.5 + 0.40 * sin(uTime * 0.05 + 4.2), 0.22); // Slow hue cycle so the bands gently breathe in and out. float pa = 0.5 + 0.5 * sin(uTime * 0.13); float pb = 0.5 + 0.5 * sin(uTime * 0.17 + 1.7); float pc = 0.5 + 0.5 * sin(uTime * 0.09 + 3.4); vec3 color = uColorA * (a * pa) + uColorB * (b * pb) + uColorC * (c * pc); float alpha = (a * pa + b * pb + c * pc) * vertical * uOpacity; gl_FragColor = vec4(color, alpha); } `;function RB(){let e=(0,b.useRef)(),t=(0,b.useMemo)(()=>({uTime:{value:0},uColorA:{value:new K(`#5af0d6`)},uColorB:{value:new K(`#9b7cff`)},uColorC:{value:new K(`#6effa2`)},uOpacity:{value:.18}}),[]);return P_(t=>{e.current&&(e.current.uniforms.uTime.value=t.clock.elapsedTime)}),(0,X.jsxs)(`mesh`,{position:[0,14,-50],renderOrder:-1,children:[(0,X.jsx)(`planeGeometry`,{args:[140,32,1,1]}),(0,X.jsx)(`shaderMaterial`,{ref:e,vertexShader:IB,fragmentShader:LB,uniforms:t,transparent:!0,blending:2,depthWrite:!1,depthTest:!1})]})}function zB({arena:e}){let{atmosphere:t}=e||{},n=(0,b.useRef)(),r=(0,b.useMemo)(()=>({topColor:{value:new K(`#0a1424`)},bottomColor:{value:new K(`#3a6b8c`)},intensity:{value:.95}}),[]);return P_(e=>{n.current&&(n.current.material.opacity=.55+Math.sin(e.clock.elapsedTime*1.5)*.05)}),(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`color`,{attach:`background`,args:[`#0a1424`]}),(0,X.jsx)(`fog`,{attach:`fog`,args:[`#1a2e42`,14,54]}),(0,X.jsxs)(`mesh`,{scale:[-120,120,120],children:[(0,X.jsx)(`sphereGeometry`,{args:[1,32,32]}),(0,X.jsx)(`shaderMaterial`,{vertexShader:xB,fragmentShader:SB,uniforms:r,side:1,depthWrite:!1})]}),(0,X.jsx)(RB,{}),(0,X.jsx)(iB,{lighting:t.lighting}),(0,X.jsx)(`pointLight`,{position:[0,5,-6],intensity:1,color:`#6ecfff`,distance:22,decay:2}),(0,X.jsx)(dB,{floor:t.floor}),(0,X.jsxs)(`mesh`,{rotation:[-Math.PI/2,0,0],position:[0,.005,0],ref:n,children:[(0,X.jsx)(`planeGeometry`,{args:[22,22]}),(0,X.jsx)(`meshBasicMaterial`,{color:`#6ecfff`,transparent:!0,opacity:.55,depthWrite:!1})]}),t.parallax.map((e,t)=>(0,X.jsx)(fB,{...e},t)),(0,X.jsx)(FB,{position:[0,0,-16]}),(t.beams||[]).map((e,t)=>(0,X.jsx)(sB,{...e},`beam-${t}`)),t.floorFog&&(0,X.jsx)(pB,{...t.floorFog}),(0,b.useMemo)(()=>{let e=PB(991319);return[[-10,.3,-8],[11,.25,-9],[-7,.2,5],[8,.25,4]].map((t,n)=>({position:t,radius:1.2+e()*.5,key:n}))},[]).map(({position:e,radius:t,key:n})=>(0,X.jsxs)(`mesh`,{position:e,receiveShadow:!0,children:[(0,X.jsx)(`sphereGeometry`,{args:[t,12,12]}),(0,X.jsx)(`meshStandardMaterial`,{color:`#dce8f2`,roughness:.95})]},n)),t.particles.map((e,t)=>e.kind===`snow`?(0,X.jsx)(NB,{...e},`p-${t}`):e.kind===`dust`?(0,X.jsx)(bB,{...e},`p-${t}`):null),(0,X.jsx)(aF,{count:70,bounds:[24,4,12],origin:[0,2,-3],color:`#dcefff`,size:.18,opacity:.55,drift:.22,repelRadius:1.9,repelStrength:5.5,damping:1.7})]})}var BB={temple:gB,bamboo:OB,coliseum:MB,shrine:zB},VB=[{id:`temple`,name:`Temple of Cinder`,description:`Cracked obsidian floors and floating embers. The old gods still watch from the ash.`,component:BB.temple,swatch:{from:`#2a2010`,to:`#d4af37`,accent:`#e71d36`},camera:{distance:9,height:3.2,lookAtY:1.4},fog:{color:`#140f0a`,near:8,far:28},postFx:{bloom:{intensity:1.5,luminanceThreshold:.3,luminanceSmoothing:.25,mipmapBlur:!0,radius:.8,levels:7},vignette:{offset:.28,darkness:.78,eskil:!1},saturation:{saturation:.08,hue:0},brightnessContrast:{brightness:-.03,contrast:.08},chromaticAberration:{offset:[8e-4,8e-4],radialModulation:!1},noise:{opacity:.06,premultiply:!0},depthOfField:{enabled:!0,focusDistance:.02,focalLength:.05,bokehScale:1.5}},atmosphere:{lighting:{ambient:{intensity:.16,color:`#2a1a0c`},key:{position:[2,12,6],intensity:.45,color:`#d4af37`,castShadow:!0,flickerSeed:0},rim:{position:[-6,6,-8],intensity:.6,color:`#e71d36`,flickerSeed:1.7},environment:{preset:`warehouse`,intensity:.35,background:!1}},beams:[{position:[-4,14,2],targetY:0,color:`#ffae3b`,width:2,intensity:.7,animated:!0},{position:[5,14,-3],targetY:0,color:`#d4af37`,width:1.6,intensity:.55,animated:!0}],floorFog:{color:`#3a2410`,size:1.4,opacity:.16,count:42,spread:[42,.5,24],origin:[0,.2,-3]},floor:{size:[60,60],baseColor:`#0a090e`,crackColor:`#3a0a0a`,accentColor:`#e71d36`,pattern:`crackedStone`,roughness:.92,metalness:.1,reflection:{blur:[300,100],resolution:256,mixBlur:1,mixStrength:.5,mirror:.3,depthScale:.3,minDepthThreshold:.4,maxDepthThreshold:1.4,baseAlpha:.4}},parallax:[{kind:`silhouette`,depth:.85,strength:.5,color:`#0c0608`,y:4,z:-32,shapes:[{type:`box`,position:[-18,2,0],size:[4,12,.5]},{type:`box`,position:[-10,1.5,0],size:[3,9,.5]},{type:`box`,position:[-2,3,0],size:[5,16,.5]},{type:`box`,position:[7,2,0],size:[3.5,11,.5]},{type:`box`,position:[15,1,0],size:[3,8,.5]},{type:`box`,position:[22,2.5,0],size:[4,13,.5]},{type:`arch`,position:[-12,0,0],width:4,height:7,thickness:.6},{type:`arch`,position:[4,0,0],width:5,height:9,thickness:.7},{type:`arch`,position:[18,0,0],width:4,height:6,thickness:.6}]},{kind:`plane`,depth:.7,strength:.7,color:`#0a0608`,y:8,z:-26,size:[60,16],opacity:.85}],particles:[{kind:`ember`,count:140,bounds:[40,9,28],origin:[0,0,-4],color:`#ffae3b`,size:.18,opacity:.7,speed:.55,drift:.35},{kind:`ember`,count:60,bounds:[30,7,18],origin:[0,0,-6],color:`#e71d36`,size:.14,opacity:.55,speed:.45,drift:.25}]}},{id:`bamboo`,name:`Whispering Bamboo Grove`,description:`Moonlight cuts through silver stalks. Every rustle could be footwork or wind.`,component:BB.bamboo,swatch:{from:`#0d1f17`,to:`#3a5f40`,accent:`#adff2f`},camera:{distance:9.5,height:3,lookAtY:1.3},fog:{color:`#0a1812`,near:9,far:30},postFx:{bloom:{intensity:.9,luminanceThreshold:.5,luminanceSmoothing:.22,mipmapBlur:!0,radius:.65,levels:6},vignette:{offset:.32,darkness:.7,eskil:!1},saturation:{saturation:.05,hue:0},brightnessContrast:{brightness:-.02,contrast:.06},chromaticAberration:{offset:[4e-4,4e-4],radialModulation:!1},noise:{opacity:.045,premultiply:!0},depthOfField:{enabled:!0,focusDistance:.025,focalLength:.05,bokehScale:1.4}},atmosphere:{lighting:{ambient:{intensity:.22,color:`#8fbc8f`},key:{position:[-6,12,8],intensity:.55,color:`#d4e8c5`,castShadow:!0,flickerSeed:1},rim:{position:[8,6,-10],intensity:.45,color:`#adff2f`,flickerSeed:2.4},environment:{preset:`forest`,intensity:.4,background:!1}},beams:[{position:[0,13,-3],targetY:0,color:`#d4e8c5`,width:2.4,intensity:.55,animated:!0}],floorFog:{color:`#a8c6a8`,size:1.5,opacity:.18,count:46,spread:[46,.5,26],origin:[0,.2,-4]},floor:{size:[70,70],baseColor:`#14261a`,crackColor:`#1f3a25`,accentColor:`#6a8a5a`,pattern:`wetPath`,roughness:.95,metalness:.05,reflection:{blur:[400,200],resolution:128,mixBlur:1,mixStrength:.4,mirror:.4,depthScale:.5,minDepthThreshold:.4,maxDepthThreshold:1.4,baseAlpha:.35}},parallax:[{kind:`silhouette`,depth:.9,strength:.4,color:`#070d0a`,y:4,z:-38,shapes:[{type:`box`,position:[-22,4,0],size:[.6,14,.3]},{type:`box`,position:[-16,3.5,0],size:[.5,12,.3]},{type:`box`,position:[-9,4.5,0],size:[.6,15,.3]},{type:`box`,position:[-3,3,0],size:[.5,11,.3]},{type:`box`,position:[3,4,0],size:[.6,13,.3]},{type:`box`,position:[10,3.5,0],size:[.5,12,.3]},{type:`box`,position:[17,4.2,0],size:[.6,14,.3]},{type:`box`,position:[24,3,0],size:[.5,11,.3]}]},{kind:`plane`,depth:.7,strength:.6,color:`#0a1610`,y:10,z:-28,size:[80,18],opacity:.7}],particles:[{kind:`leaf`,count:90,bounds:[45,9,30],origin:[0,4,-6],color:`#c8e6a0`,size:.28,opacity:.85,speed:.5,drift:.35,spin:1.4},{kind:`dust`,count:90,bounds:[45,3,30],origin:[0,1.2,-4],color:`#adff2f`,size:.07,opacity:.55,speed:.25,drift:.3}]}},{id:`coliseum`,name:`Shattered Coliseum`,description:`Broken marble under a bruised sky. The crowd is dust, but the arena remembers.`,component:BB.coliseum,swatch:{from:`#2a1c4a`,to:`#b45a2b`,accent:`#ff9d3e`},camera:{distance:10,height:3.4,lookAtY:1.5},fog:{color:`#120c20`,near:10,far:32},postFx:{bloom:{intensity:1,luminanceThreshold:.4,luminanceSmoothing:.25,mipmapBlur:!0,radius:.72,levels:7},vignette:{offset:.3,darkness:.72,eskil:!1},saturation:{saturation:.06,hue:0},brightnessContrast:{brightness:-.02,contrast:.07},chromaticAberration:{offset:[6e-4,6e-4],radialModulation:!1},noise:{opacity:.05,premultiply:!0},depthOfField:{enabled:!0,focusDistance:.022,focalLength:.05,bokehScale:1.5}},atmosphere:{lighting:{ambient:{intensity:.2,color:`#b45a2b`},key:{position:[-8,12,12],intensity:.7,color:`#ffdb9a`,castShadow:!0,flickerSeed:2},rim:{position:[10,6,-10],intensity:.45,color:`#ff7b2e`,flickerSeed:3.3},environment:{preset:`sunset`,intensity:.45,background:!1}},beams:[{position:[0,14,-1],targetY:0,color:`#ff9d3e`,width:3,intensity:.75,animated:!0}],floorFog:{color:`#e8c98f`,size:1.6,opacity:.17,count:44,spread:[50,.5,28],origin:[0,.2,-5]},floor:{size:[70,70],baseColor:`#8c7655`,crackColor:`#2a1f15`,accentColor:`#d4af37`,pattern:`crackedMarble`,roughness:.98,metalness:.02,reflection:{blur:[200,200],resolution:128,mixBlur:1,mixStrength:.3,mirror:.2,depthScale:.4,minDepthThreshold:.4,maxDepthThreshold:1.4,baseAlpha:.4}},parallax:[{kind:`silhouette`,depth:.85,strength:.5,color:`#1a0e1f`,y:4,z:-34,shapes:[{type:`box`,position:[-22,3,0],size:[5,14,.5]},{type:`box`,position:[-14,4,0],size:[6,18,.5]},{type:`box`,position:[-5,3.5,0],size:[5,15,.5]},{type:`box`,position:[5,3.2,0],size:[5,14,.5]},{type:`box`,position:[14,3.8,0],size:[6,17,.5]},{type:`box`,position:[22,3,0],size:[5,14,.5]},{type:`arch`,position:[-10,0,0],width:5,height:8,thickness:.7},{type:`arch`,position:[0,0,0],width:4,height:6,thickness:.6},{type:`arch`,position:[10,0,0],width:5,height:8,thickness:.7}]},{kind:`plane`,depth:.7,strength:.65,color:`#1a0e1f`,y:9,z:-28,size:[80,18],opacity:.85}],particles:[{kind:`dust`,count:180,bounds:[55,8,40],origin:[0,.5,-6],color:`#e8c98f`,size:.11,opacity:.5,speed:.18,drift:.18},{kind:`ember`,count:60,bounds:[40,8,24],origin:[0,0,-8],color:`#ff9d3e`,size:.12,opacity:.6,speed:.4,drift:.2}]}},{id:`shrine`,name:`Frozen Shrine`,description:`Lanterns flicker on black ice. Honour the duel, or join the statues in the snow.`,component:BB.shrine,swatch:{from:`#0a1424`,to:`#3a6b8c`,accent:`#6ecfff`},camera:{distance:9.2,height:3.1,lookAtY:1.35},fog:{color:`#070d16`,near:9,far:30},postFx:{bloom:{intensity:1.3,luminanceThreshold:.35,luminanceSmoothing:.25,mipmapBlur:!0,radius:.78,levels:7},vignette:{offset:.3,darkness:.74,eskil:!1},saturation:{saturation:.04,hue:.02},brightnessContrast:{brightness:-.02,contrast:.08},chromaticAberration:{offset:[7e-4,7e-4],radialModulation:!1},noise:{opacity:.04,premultiply:!0},depthOfField:{enabled:!0,focusDistance:.024,focalLength:.05,bokehScale:1.5}},atmosphere:{lighting:{ambient:{intensity:.18,color:`#4a7a9a`},key:{position:[6,12,8],intensity:.5,color:`#b8dfff`,castShadow:!0,flickerSeed:3},rim:{position:[-8,6,-10],intensity:.5,color:`#6ecfff`,flickerSeed:4.1},environment:{preset:`night`,intensity:.3,background:!1}},beams:[{position:[0,12,-16],targetY:0,color:`#6ecfff`,width:2.2,intensity:.55,animated:!0}],floorFog:{color:`#b8dfff`,size:1.3,opacity:.18,count:40,spread:[44,.5,26],origin:[0,.2,-4]},floor:{size:[70,70],baseColor:`#1c3048`,crackColor:`#6ecfff`,accentColor:`#b8dfff`,pattern:`blackIce`,roughness:.35,metalness:.4,reflection:{blur:[100,100],resolution:256,mixBlur:1,mixStrength:.7,mirror:.85,depthScale:.2,minDepthThreshold:.4,maxDepthThreshold:1.4,baseAlpha:.25}},parallax:[{kind:`silhouette`,depth:.88,strength:.45,color:`#050a14`,y:4,z:-36,shapes:[{type:`box`,position:[-20,3,0],size:[3,12,.5]},{type:`box`,position:[-10,2,0],size:[2.5,9,.5]},{type:`box`,position:[-3,3.5,0],size:[3,14,.5]},{type:`box`,position:[5,2.5,0],size:[2.5,10,.5]},{type:`box`,position:[13,3.2,0],size:[3,13,.5]},{type:`box`,position:[22,2.8,0],size:[3,11,.5]},{type:`arch`,position:[-14,0,0],width:4,height:7,thickness:.6},{type:`arch`,position:[8,0,0],width:5,height:8,thickness:.7}]},{kind:`plane`,depth:.7,strength:.6,color:`#060c18`,y:10,z:-28,size:[80,18],opacity:.8}],particles:[{kind:`snow`,count:220,bounds:[55,14,40],origin:[0,6,-6],color:`#e8f4ff`,opacity:.85,speed:.35,drift:.18},{kind:`dust`,count:60,bounds:[40,3,30],origin:[0,.5,-4],color:`#b8dfff`,size:.06,opacity:.4,speed:.1,drift:.18}]}}],HB=VB[0];function UB(){let[e,t]=(0,b.useState)(`start`),[n,r]=(0,b.useState)(!1),[i,a]=(0,b.useState)(Lz.id),[o,s]=(0,b.useState)(HB.id),[c,l]=(0,b.useState)(0),[u,d]=(0,b.useState)(null),[f,p]=(0,b.useState)({master:80,sfx:100,music:60,muted:!1}),[m,h]=(0,b.useState)({quality:`medium`,hitSparks:!0,damageNumbers:!0,screenShake:50}),[g,_]=(0,b.useState)({difficulty:`champion`,matchFormat:`bestOf3`,showControlHints:!0,autoPauseOnBlur:!0}),[v,y]=(0,b.useState)(100),[x,S]=(0,b.useState)(100),[C,w]=(0,b.useState)(100),[T,E]=(0,b.useState)(100),[D,O]=(0,b.useState)(1),[k,A]=(0,b.useState)(0),[j,ee]=(0,b.useState)(0),[te,M]=(0,b.useState)(0),[N,P]=(0,b.useState)(null),[F,ne]=(0,b.useState)(null),[re,ie]=(0,b.useState)(null),[I,ae]=(0,b.useState)([]),[L,oe]=(0,b.useState)(null),[se,ce]=(0,b.useState)(``),le=(0,b.useRef)(null),ue=(0,b.useRef)(100),de=(0,b.useRef)(100),fe=(0,b.useRef)(0),pe=(0,b.useRef)(!1),me=(0,b.useMemo)(()=>Iz[3],[]),he=(0,b.useMemo)(()=>Iz.find(e=>e.id===i)||Lz,[i]),ge=(0,b.useMemo)(()=>VB.find(e=>e.id===o)||HB,[o]),_e=(0,b.useCallback)((e,t,n,r)=>{let i=fe.current++,a=50+(n?-1:1)*(15+Math.random()*12),o=35+Math.random()*25;ae(n=>[...n,{id:i,text:e,color:t,x:a,y:o,crit:r}]),setTimeout(()=>{ae(e=>e.filter(e=>e.id!==i))},760)},[]),ve=(0,b.useCallback)(e=>{oe({color:e,key:Date.now()}),setTimeout(()=>oe(null),180)},[]),ye=(0,b.useCallback)(e=>{ce(e?`shake-heavy`:`shake-light`),setTimeout(()=>ce(``),400)},[]);(0,b.useEffect)(()=>{if(e!==`playing`&&e!==`roundEnd`)return;let t=setInterval(()=>{let e=le.current;if(!e)return;let t=e.playerRef.current,n=e.npcRef.current,r=e.gameRef.current;if(!t||!n||!r)return;y(t.hp),S(n.hp),w(t.stamina),E(n.stamina),O(r.round),A(r.playerScore),ee(r.npcScore),M(Math.max(t.comboCount,n.comboCount)),r.qualityPreset=m.quality,r.playerHpRatio=Math.max(0,Math.min(1,t.hp/100)),r.lowHpFactor=Math.max(0,Math.min(1,(30-t.hp)/30));let i=ue.current-t.hp,a=de.current-n.hp;if(i>0){let e=i>=12||r.screenShake>.35,t=e?`#ffd700`:`#ff3344`;_e(`-${Math.round(i)}`,t,!0,e),ve(t),ye(e||i>=10),ie({text:n.anim.toUpperCase(),color:t,key:Date.now(),crit:e}),setTimeout(()=>ie(null),500),r.vignettePulse=Math.max(r.vignettePulse||0,e?.42:.3),r.critPulse=Math.max(r.critPulse||0,e?.7:.25)}if(a>0){let e=a>=12||r.screenShake>.35,n=e?`#ffd700`:`#00d4ff`;_e(`-${Math.round(a)}`,n,!1,e),ve(n),ye(e||a>=10),ie({text:t.anim.toUpperCase(),color:n,key:Date.now(),crit:e}),setTimeout(()=>ie(null),500),r.vignettePulse=Math.max(r.vignettePulse||0,e?.42:.3),r.critPulse=Math.max(r.critPulse||0,e?.7:.25)}ue.current=t.hp,de.current=n.hp},80);return()=>clearInterval(t)},[e,_e,ve,ye,m.quality]);let be=(0,b.useRef)(``);(0,b.useEffect)(()=>(be.current=iP(),_P(be.current),()=>vP()),[!1]),(0,b.useEffect)(()=>{let e=be.current;return window.sendAIRequest=async t=>{let n;n=typeof t==`string`?{sequence:t,playerId:e}:{...t||{},playerId:e};try{let e=await fetch(`/predict`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(n)});if(!e.ok)throw Error(`HTTP ${e.status}`);let t=await e.json();t&&t.adapterScope&&mP({adapterScope:t.adapterScope}),window.dispatchEvent(new CustomEvent(`ai-response`,{detail:t}))}catch(e){console.error(`AI request failed:`,e),pe.current=!1,window.dispatchEvent(new CustomEvent(`ai-response`,{detail:{reasoning:e.message,counterMove:null,sequence:n.sequence||``}}))}},()=>{window.sendAIRequest=void 0}},[!1]),(0,b.useEffect)(()=>{let e=!1;return(async()=>{try{let t=await fetch(`/health`,{method:`GET`});if(!t.ok)throw Error(`HTTP ${t.status}`);let n=await t.json();e||(pe.current=!!(n&&n.ready))}catch{e||(pe.current=!1)}})(),()=>{e=!0}},[!1]),(0,b.useEffect)(()=>{let t=t=>{t.key===`Escape`&&(e===`playing`||e===`roundEnd`)&&r(e=>!e)};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e]);let xe=()=>t(`characterSelect`),Se=()=>t(`arenaSelect`),Ce=()=>t(`playing`),R=()=>{l(e=>e+1),t(`playing`),y(100),S(100),w(100),E(100),O(1),A(0),ee(0),ne(null),P(null),M(0),ue.current=100,de.current=100},we=(0,b.useCallback)(e=>{P(e.winner===`player`?`ROUND WON`:`ROUND LOST`),setTimeout(()=>{P(null)},2800)},[]),Te=(0,b.useCallback)(e=>{ne(e===`player`),t(`gameOver`)},[]),Ee=(e===`playing`||e===`roundEnd`)&&!n,z=(e===`playing`||e===`roundEnd`)&&n,De=`game-container ${se} ${Ee?``:`gpu-idle`}`,Oe=Ee?`GPU ACTIVE`:`GPU IDLE`,ke=`mqfxdvh9`.slice(-6);return(0,X.jsx)(nB,{children:(0,X.jsxs)(`div`,{className:De,"data-gpu":Ee?`active`:`idle`,children:[(0,X.jsxs)(`div`,{className:`gpu-status ${Ee?`is-active`:`is-idle`}`,"aria-hidden":`true`,children:[(0,X.jsx)(`span`,{className:`dot`}),(0,X.jsx)(`span`,{children:Oe}),ke&&(0,X.jsxs)(`span`,{style:{opacity:.55,marginLeft:6},children:[`v`,ke]})]}),Ee&&(0,X.jsx)(b.Suspense,{fallback:(0,X.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center bg-ink-900/80 text-amber-200 font-cinzel text-sm tracking-widest`,children:`Loading fighters...`}),children:(0,X.jsx)(iy,{shadows:!0,camera:{position:[0,4,12],fov:50},gl:{antialias:!0,alpha:!1,powerPreference:`high-performance`,preserveDrawingBuffer:!0},dpr:[1,2],frameloop:`always`,onCreated:({gl:e})=>{e.toneMapping=4,e.toneMappingExposure=1.1,e.shadowMap.type=2},children:(0,X.jsx)(mR,{ref:le,arena:ge,playerCharacter:he,npcCharacter:me,onGameOver:Te,onRoundEnd:we,onPause:()=>r(!0),paused:!1,modelReadyRef:pe})},c)}),z&&(0,X.jsx)(WB,{arena:ge,characters:[he,me]},c),(e===`playing`||e===`roundEnd`)&&!n&&(0,X.jsx)(rz,{playerHP:v,npcHP:x,round:D,playerScore:k,npcScore:j,combo:te,energy:C,stamina:C,npcStamina:T}),(e===`playing`||e===`roundEnd`)&&!n&&(0,X.jsx)(iz,{}),(0,X.jsx)(oz,{numbers:I}),L&&(0,X.jsx)(Fz,{color:L.color},L.key),re&&(0,X.jsxs)(`div`,{className:`hit-splash`,style:{color:re.color},children:[re.crit&&(0,X.jsx)(`span`,{className:`crit-star`,children:`✦`}),re.text]},re.key),N&&(0,X.jsx)(dz,{result:N}),n&&e!==`gameOver`&&e!==`start`&&(0,X.jsx)(Pz,{onResume:()=>r(!1),onRestart:R,onQuit:()=>{r(!1),t(`start`)},audioSettings:f,setAudioSettings:p,videoSettings:m,setVideoSettings:h,gameplaySettings:g,setGameplaySettings:_}),e===`start`&&(0,X.jsx)(TR,{onStart:xe,onOpenCodex:()=>d(`codex`),onOpenForge:()=>d(`forge`),onOpenSettings:()=>d(`settings`)}),(0,X.jsxs)(ZD,{children:[e===`start`&&u===`codex`&&(0,X.jsx)(Jz,{onClose:()=>d(null)}),e===`start`&&u===`forge`&&(0,X.jsx)(Zz,{onClose:()=>d(null)}),e===`start`&&u===`settings`&&(0,X.jsx)($z,{onClose:()=>d(null),gpuActive:Ee})]}),e===`characterSelect`&&(0,X.jsx)(zR,{characters:Iz,selectedId:i,onSelect:a,onConfirm:Se,onBack:()=>t(`start`)}),e===`arenaSelect`&&(0,X.jsx)(GR,{arenas:VB,selectedId:o,onSelect:s,onConfirm:Ce,onBack:()=>t(`characterSelect`)}),e===`gameOver`&&(0,X.jsx)(wz,{victory:F,playerScore:k,npcScore:j,onRestart:R,onMenu:()=>t(`start`)})]})})}function WB({arena:e,characters:t}){return(0,X.jsx)(b.Suspense,{fallback:(0,X.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center bg-ink-900/80 text-amber-200 font-cinzel text-sm tracking-widest`,children:`Loading fighters...`}),children:(0,X.jsx)(iy,{shadows:!1,camera:{position:[0,4,12],fov:50},gl:{antialias:!0,alpha:!1,powerPreference:`low-power`,preserveDrawingBuffer:!0},dpr:1,frameloop:`never`,children:(0,X.jsx)(mR,{arena:e,playerCharacter:t[0],npcCharacter:t[1],paused:!0})})})}var GB=class extends b.Component{constructor(e){super(e),this.state={error:null}}static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){console.error(`App crashed:`,e,t)}render(){return this.state.error?(0,X.jsxs)(`div`,{style:{position:`fixed`,inset:0,display:`flex`,flexDirection:`column`,alignItems:`center`,justifyContent:`center`,padding:24,background:`#05040a`,color:`#f0e6d2`,fontFamily:`Cinzel, Georgia, serif`,textAlign:`center`,zIndex:99999},children:[(0,X.jsx)(`h1`,{style:{color:`#e71d36`,fontSize:28,marginBottom:12},children:`Something went wrong`}),(0,X.jsx)(`pre`,{style:{maxWidth:800,whiteSpace:`pre-wrap`,wordBreak:`break-word`,background:`rgba(255,255,255,0.04)`,padding:16,borderRadius:8,border:`1px solid rgba(212,175,55,0.3)`,fontSize:13,lineHeight:1.5,color:`#b8a88a`},children:String(this.state.error?.message||this.state.error)}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>window.location.reload(),style:{marginTop:20,padding:`10px 24px`,background:`rgba(212,175,55,0.15)`,border:`1px solid #d4af37`,color:`#d4af37`,fontFamily:`inherit`,fontSize:14,letterSpacing:`0.2em`,textTransform:`uppercase`,cursor:`pointer`,borderRadius:4},children:`Reload`})]}):this.props.children}};function KB(e,t){try{let n=document.getElementById(`__fatal_overlay__`);n||(n=document.createElement(`div`),n.id=`__fatal_overlay__`,n.style.cssText=`position:fixed;inset:0;display:flex;flex-direction:column;align-items:center;justify-content:center;padding:24px;background:#05040a;color:#f0e6d2;font-family:Cinzel,Georgia,serif;text-align:center;z-index:99999;overflow:auto;`,document.body.appendChild(n)),n.innerHTML=`

`+e+`

`+t+`
`}catch(e){console.error(`showFatalError failed`,e)}}window.addEventListener(`error`,e=>{KB(`Something went wrong`,String(e.error&&(e.error.stack||e.error.message)||e.message||`Unknown error`))}),window.addEventListener(`unhandledrejection`,e=>{KB(`Unhandled promise rejection`,String(e.reason&&(e.reason.stack||e.reason.message)||e.reason||`Unknown`))});try{(0,x.createRoot)(document.getElementById(`root`)).render((0,X.jsx)(GB,{children:(0,X.jsx)(UB,{})}))}catch(e){KB(`Failed to mount app`,String(e&&(e.stack||e.message)||e))}