1
0
Files
card/public/planet/static/js/main.85974979.js
syui 980e9c1259 Convert public directory from submodule to normal directory
- Remove public from git submodule tracking
- Add all public directory contents as regular files
- Fixes GitHub Actions error: "No url found for submodule path 'public' in .gitmodules"

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-18 13:04:46 +09:00

2 lines
1.3 MiB

/*! For license information please see main.85974979.js.LICENSE.txt */
(()=>{var e={356:e=>{function t(e,t,n){var r,i,s,a,o;function l(){var u=Date.now()-a;u<t&&u>=0?r=setTimeout(l,t-u):(r=null,n||(o=e.apply(s,i),s=i=null))}null==t&&(t=100);var u=function(){s=this,i=arguments,a=Date.now();var u=n&&!r;return r||(r=setTimeout(l,t)),u&&(o=e.apply(s,i),s=i=null),o};return u.clear=function(){r&&(clearTimeout(r),r=null)},u.flush=function(){r&&(o=e.apply(s,i),s=i=null,clearTimeout(r),r=null)},u}t.debounce=t,e.exports=t},345:(e,t,n)=>{"use strict";var r=n(950),i=n(204);function s(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n<arguments.length;n++)t+="&args[]="+encodeURIComponent(arguments[n]);return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var a=new Set,o={};function l(e,t){u(e,t),u(e+"Capture",t)}function u(e,t){for(o[e]=t,e=0;e<t.length;e++)a.add(t[e])}var c=!("undefined"===typeof window||"undefined"===typeof window.document||"undefined"===typeof window.document.createElement),h=Object.prototype.hasOwnProperty,d=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,p={},f={};function m(e,t,n,r,i,s,a){this.acceptsBooleans=2===t||3===t||4===t,this.attributeName=r,this.attributeNamespace=i,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=s,this.removeEmptyString=a}var g={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach((function(e){g[e]=new m(e,0,!1,e,null,!1,!1)})),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach((function(e){var t=e[0];g[t]=new m(t,1,!1,e[1],null,!1,!1)})),["contentEditable","draggable","spellCheck","value"].forEach((function(e){g[e]=new m(e,2,!1,e.toLowerCase(),null,!1,!1)})),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach((function(e){g[e]=new m(e,2,!1,e,null,!1,!1)})),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach((function(e){g[e]=new m(e,3,!1,e.toLowerCase(),null,!1,!1)})),["checked","multiple","muted","selected"].forEach((function(e){g[e]=new m(e,3,!0,e,null,!1,!1)})),["capture","download"].forEach((function(e){g[e]=new m(e,4,!1,e,null,!1,!1)})),["cols","rows","size","span"].forEach((function(e){g[e]=new m(e,6,!1,e,null,!1,!1)})),["rowSpan","start"].forEach((function(e){g[e]=new m(e,5,!1,e.toLowerCase(),null,!1,!1)}));var v=/[\-:]([a-z])/g;function y(e){return e[1].toUpperCase()}function _(e,t,n,r){var i=g.hasOwnProperty(t)?g[t]:null;(null!==i?0!==i.type:r||!(2<t.length)||"o"!==t[0]&&"O"!==t[0]||"n"!==t[1]&&"N"!==t[1])&&(function(e,t,n,r){if(null===t||"undefined"===typeof t||function(e,t,n,r){if(null!==n&&0===n.type)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return!r&&(null!==n?!n.acceptsBooleans:"data-"!==(e=e.toLowerCase().slice(0,5))&&"aria-"!==e);default:return!1}}(e,t,n,r))return!0;if(r)return!1;if(null!==n)switch(n.type){case 3:return!t;case 4:return!1===t;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}(t,n,i,r)&&(n=null),r||null===i?function(e){return!!h.call(f,e)||!h.call(p,e)&&(d.test(e)?f[e]=!0:(p[e]=!0,!1))}(t)&&(null===n?e.removeAttribute(t):e.setAttribute(t,""+n)):i.mustUseProperty?e[i.propertyName]=null===n?3!==i.type&&"":n:(t=i.attributeName,r=i.attributeNamespace,null===n?e.removeAttribute(t):(n=3===(i=i.type)||4===i&&!0===n?"":""+n,r?e.setAttributeNS(r,t,n):e.setAttribute(t,n))))}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach((function(e){var t=e.replace(v,y);g[t]=new m(t,1,!1,e,null,!1,!1)})),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach((function(e){var t=e.replace(v,y);g[t]=new m(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)})),["xml:base","xml:lang","xml:space"].forEach((function(e){var t=e.replace(v,y);g[t]=new m(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)})),["tabIndex","crossOrigin"].forEach((function(e){g[e]=new m(e,1,!1,e.toLowerCase(),null,!1,!1)})),g.xlinkHref=new m("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach((function(e){g[e]=new m(e,1,!1,e.toLowerCase(),null,!0,!0)}));var x=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,A=Symbol.for("react.element"),M=Symbol.for("react.portal"),b=Symbol.for("react.fragment"),S=Symbol.for("react.strict_mode"),w=Symbol.for("react.profiler"),E=Symbol.for("react.provider"),T=Symbol.for("react.context"),C=Symbol.for("react.forward_ref"),R=Symbol.for("react.suspense"),P=Symbol.for("react.suspense_list"),I=Symbol.for("react.memo"),B=Symbol.for("react.lazy");Symbol.for("react.scope"),Symbol.for("react.debug_trace_mode");var L=Symbol.for("react.offscreen");Symbol.for("react.legacy_hidden"),Symbol.for("react.cache"),Symbol.for("react.tracing_marker");var D=Symbol.iterator;function U(e){return null===e||"object"!==typeof e?null:"function"===typeof(e=D&&e[D]||e["@@iterator"])?e:null}var N,F=Object.assign;function O(e){if(void 0===N)try{throw Error()}catch(n){var t=n.stack.trim().match(/\n( *(at )?)/);N=t&&t[1]||""}return"\n"+N+e}var k=!1;function H(e,t){if(!e||k)return"";k=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(t)if(t=function(){throw Error()},Object.defineProperty(t.prototype,"props",{set:function(){throw Error()}}),"object"===typeof Reflect&&Reflect.construct){try{Reflect.construct(t,[])}catch(u){var r=u}Reflect.construct(e,[],t)}else{try{t.call()}catch(u){r=u}e.call(t.prototype)}else{try{throw Error()}catch(u){r=u}e()}}catch(u){if(u&&r&&"string"===typeof u.stack){for(var i=u.stack.split("\n"),s=r.stack.split("\n"),a=i.length-1,o=s.length-1;1<=a&&0<=o&&i[a]!==s[o];)o--;for(;1<=a&&0<=o;a--,o--)if(i[a]!==s[o]){if(1!==a||1!==o)do{if(a--,0>--o||i[a]!==s[o]){var l="\n"+i[a].replace(" at new "," at ");return e.displayName&&l.includes("<anonymous>")&&(l=l.replace("<anonymous>",e.displayName)),l}}while(1<=a&&0<=o);break}}}finally{k=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?O(e):""}function z(e){switch(e.tag){case 5:return O(e.type);case 16:return O("Lazy");case 13:return O("Suspense");case 19:return O("SuspenseList");case 0:case 2:case 15:return e=H(e.type,!1);case 11:return e=H(e.type.render,!1);case 1:return e=H(e.type,!0);default:return""}}function G(e){if(null==e)return null;if("function"===typeof e)return e.displayName||e.name||null;if("string"===typeof e)return e;switch(e){case b:return"Fragment";case M:return"Portal";case w:return"Profiler";case S:return"StrictMode";case R:return"Suspense";case P:return"SuspenseList"}if("object"===typeof e)switch(e.$$typeof){case T:return(e.displayName||"Context")+".Consumer";case E:return(e._context.displayName||"Context")+".Provider";case C:var t=e.render;return(e=e.displayName)||(e=""!==(e=t.displayName||t.name||"")?"ForwardRef("+e+")":"ForwardRef"),e;case I:return null!==(t=e.displayName||null)?t:G(e.type)||"Memo";case B:t=e._payload,e=e._init;try{return G(e(t))}catch(n){}}return null}function V(e){var t=e.type;switch(e.tag){case 24:return"Cache";case 9:return(t.displayName||"Context")+".Consumer";case 10:return(t._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=(e=t.render).displayName||e.name||"",t.displayName||(""!==e?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return G(t);case 8:return t===S?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if("function"===typeof t)return t.displayName||t.name||null;if("string"===typeof t)return t}return null}function W(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":case"object":return e;default:return""}}function j(e){var t=e.type;return(e=e.nodeName)&&"input"===e.toLowerCase()&&("checkbox"===t||"radio"===t)}function X(e){e._valueTracker||(e._valueTracker=function(e){var t=j(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&"undefined"!==typeof n&&"function"===typeof n.get&&"function"===typeof n.set){var i=n.get,s=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return i.call(this)},set:function(e){r=""+e,s.call(this,e)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(e){r=""+e},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}(e))}function J(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=j(e)?e.checked?"true":"false":e.value),(e=r)!==n&&(t.setValue(e),!0)}function Y(e){if("undefined"===typeof(e=e||("undefined"!==typeof document?document:void 0)))return null;try{return e.activeElement||e.body}catch(t){return e.body}}function K(e,t){var n=t.checked;return F({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:null!=n?n:e._wrapperState.initialChecked})}function q(e,t){var n=null==t.defaultValue?"":t.defaultValue,r=null!=t.checked?t.checked:t.defaultChecked;n=W(null!=t.value?t.value:n),e._wrapperState={initialChecked:r,initialValue:n,controlled:"checkbox"===t.type||"radio"===t.type?null!=t.checked:null!=t.value}}function Q(e,t){null!=(t=t.checked)&&_(e,"checked",t,!1)}function Z(e,t){Q(e,t);var n=W(t.value),r=t.type;if(null!=n)"number"===r?(0===n&&""===e.value||e.value!=n)&&(e.value=""+n):e.value!==""+n&&(e.value=""+n);else if("submit"===r||"reset"===r)return void e.removeAttribute("value");t.hasOwnProperty("value")?ee(e,t.type,n):t.hasOwnProperty("defaultValue")&&ee(e,t.type,W(t.defaultValue)),null==t.checked&&null!=t.defaultChecked&&(e.defaultChecked=!!t.defaultChecked)}function $(e,t,n){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var r=t.type;if(!("submit"!==r&&"reset"!==r||void 0!==t.value&&null!==t.value))return;t=""+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}""!==(n=e.name)&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,""!==n&&(e.name=n)}function ee(e,t,n){"number"===t&&Y(e.ownerDocument)===e||(null==n?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var te=Array.isArray;function ne(e,t,n,r){if(e=e.options,t){t={};for(var i=0;i<n.length;i++)t["$"+n[i]]=!0;for(n=0;n<e.length;n++)i=t.hasOwnProperty("$"+e[n].value),e[n].selected!==i&&(e[n].selected=i),i&&r&&(e[n].defaultSelected=!0)}else{for(n=""+W(n),t=null,i=0;i<e.length;i++){if(e[i].value===n)return e[i].selected=!0,void(r&&(e[i].defaultSelected=!0));null!==t||e[i].disabled||(t=e[i])}null!==t&&(t.selected=!0)}}function re(e,t){if(null!=t.dangerouslySetInnerHTML)throw Error(s(91));return F({},t,{value:void 0,defaultValue:void 0,children:""+e._wrapperState.initialValue})}function ie(e,t){var n=t.value;if(null==n){if(n=t.children,t=t.defaultValue,null!=n){if(null!=t)throw Error(s(92));if(te(n)){if(1<n.length)throw Error(s(93));n=n[0]}t=n}null==t&&(t=""),n=t}e._wrapperState={initialValue:W(n)}}function se(e,t){var n=W(t.value),r=W(t.defaultValue);null!=n&&((n=""+n)!==e.value&&(e.value=n),null==t.defaultValue&&e.defaultValue!==n&&(e.defaultValue=n)),null!=r&&(e.defaultValue=""+r)}function ae(e){var t=e.textContent;t===e._wrapperState.initialValue&&""!==t&&null!==t&&(e.value=t)}function oe(e){switch(e){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function le(e,t){return null==e||"http://www.w3.org/1999/xhtml"===e?oe(t):"http://www.w3.org/2000/svg"===e&&"foreignObject"===t?"http://www.w3.org/1999/xhtml":e}var ue,ce,he=(ce=function(e,t){if("http://www.w3.org/2000/svg"!==e.namespaceURI||"innerHTML"in e)e.innerHTML=t;else{for((ue=ue||document.createElement("div")).innerHTML="<svg>"+t.valueOf().toString()+"</svg>",t=ue.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}},"undefined"!==typeof MSApp&&MSApp.execUnsafeLocalFunction?function(e,t,n,r){MSApp.execUnsafeLocalFunction((function(){return ce(e,t)}))}:ce);function de(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&3===n.nodeType)return void(n.nodeValue=t)}e.textContent=t}var pe={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},fe=["Webkit","ms","Moz","O"];function me(e,t,n){return null==t||"boolean"===typeof t||""===t?"":n||"number"!==typeof t||0===t||pe.hasOwnProperty(e)&&pe[e]?(""+t).trim():t+"px"}function ge(e,t){for(var n in e=e.style,t)if(t.hasOwnProperty(n)){var r=0===n.indexOf("--"),i=me(n,t[n],r);"float"===n&&(n="cssFloat"),r?e.setProperty(n,i):e[n]=i}}Object.keys(pe).forEach((function(e){fe.forEach((function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),pe[t]=pe[e]}))}));var ve=F({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function ye(e,t){if(t){if(ve[e]&&(null!=t.children||null!=t.dangerouslySetInnerHTML))throw Error(s(137,e));if(null!=t.dangerouslySetInnerHTML){if(null!=t.children)throw Error(s(60));if("object"!==typeof t.dangerouslySetInnerHTML||!("__html"in t.dangerouslySetInnerHTML))throw Error(s(61))}if(null!=t.style&&"object"!==typeof t.style)throw Error(s(62))}}function _e(e,t){if(-1===e.indexOf("-"))return"string"===typeof t.is;switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var xe=null;function Ae(e){return(e=e.target||e.srcElement||window).correspondingUseElement&&(e=e.correspondingUseElement),3===e.nodeType?e.parentNode:e}var Me=null,be=null,Se=null;function we(e){if(e=_i(e)){if("function"!==typeof Me)throw Error(s(280));var t=e.stateNode;t&&(t=Ai(t),Me(e.stateNode,e.type,t))}}function Ee(e){be?Se?Se.push(e):Se=[e]:be=e}function Te(){if(be){var e=be,t=Se;if(Se=be=null,we(e),t)for(e=0;e<t.length;e++)we(t[e])}}function Ce(e,t){return e(t)}function Re(){}var Pe=!1;function Ie(e,t,n){if(Pe)return e(t,n);Pe=!0;try{return Ce(e,t,n)}finally{Pe=!1,(null!==be||null!==Se)&&(Re(),Te())}}function Be(e,t){var n=e.stateNode;if(null===n)return null;var r=Ai(n);if(null===r)return null;n=r[t];e:switch(t){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(r=!r.disabled)||(r=!("button"===(e=e.type)||"input"===e||"select"===e||"textarea"===e)),e=!r;break e;default:e=!1}if(e)return null;if(n&&"function"!==typeof n)throw Error(s(231,t,typeof n));return n}var Le=!1;if(c)try{var De={};Object.defineProperty(De,"passive",{get:function(){Le=!0}}),window.addEventListener("test",De,De),window.removeEventListener("test",De,De)}catch(ce){Le=!1}function Ue(e,t,n,r,i,s,a,o,l){var u=Array.prototype.slice.call(arguments,3);try{t.apply(n,u)}catch(c){this.onError(c)}}var Ne=!1,Fe=null,Oe=!1,ke=null,He={onError:function(e){Ne=!0,Fe=e}};function ze(e,t,n,r,i,s,a,o,l){Ne=!1,Fe=null,Ue.apply(He,arguments)}function Ge(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do{0!==(4098&(t=e).flags)&&(n=t.return),e=t.return}while(e)}return 3===t.tag?n:null}function Ve(e){if(13===e.tag){var t=e.memoizedState;if(null===t&&(null!==(e=e.alternate)&&(t=e.memoizedState)),null!==t)return t.dehydrated}return null}function We(e){if(Ge(e)!==e)throw Error(s(188))}function je(e){return null!==(e=function(e){var t=e.alternate;if(!t){if(null===(t=Ge(e)))throw Error(s(188));return t!==e?null:e}for(var n=e,r=t;;){var i=n.return;if(null===i)break;var a=i.alternate;if(null===a){if(null!==(r=i.return)){n=r;continue}break}if(i.child===a.child){for(a=i.child;a;){if(a===n)return We(i),e;if(a===r)return We(i),t;a=a.sibling}throw Error(s(188))}if(n.return!==r.return)n=i,r=a;else{for(var o=!1,l=i.child;l;){if(l===n){o=!0,n=i,r=a;break}if(l===r){o=!0,r=i,n=a;break}l=l.sibling}if(!o){for(l=a.child;l;){if(l===n){o=!0,n=a,r=i;break}if(l===r){o=!0,r=a,n=i;break}l=l.sibling}if(!o)throw Error(s(189))}}if(n.alternate!==r)throw Error(s(190))}if(3!==n.tag)throw Error(s(188));return n.stateNode.current===n?e:t}(e))?Xe(e):null}function Xe(e){if(5===e.tag||6===e.tag)return e;for(e=e.child;null!==e;){var t=Xe(e);if(null!==t)return t;e=e.sibling}return null}var Je=i.unstable_scheduleCallback,Ye=i.unstable_cancelCallback,Ke=i.unstable_shouldYield,qe=i.unstable_requestPaint,Qe=i.unstable_now,Ze=i.unstable_getCurrentPriorityLevel,$e=i.unstable_ImmediatePriority,et=i.unstable_UserBlockingPriority,tt=i.unstable_NormalPriority,nt=i.unstable_LowPriority,rt=i.unstable_IdlePriority,it=null,st=null;var at=Math.clz32?Math.clz32:function(e){return e>>>=0,0===e?32:31-(ot(e)/lt|0)|0},ot=Math.log,lt=Math.LN2;var ut=64,ct=4194304;function ht(e){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: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 4194240&e;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return 130023424&e;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function dt(e,t){var n=e.pendingLanes;if(0===n)return 0;var r=0,i=e.suspendedLanes,s=e.pingedLanes,a=268435455&n;if(0!==a){var o=a&~i;0!==o?r=ht(o):0!==(s&=a)&&(r=ht(s))}else 0!==(a=n&~i)?r=ht(a):0!==s&&(r=ht(s));if(0===r)return 0;if(0!==t&&t!==r&&0===(t&i)&&((i=r&-r)>=(s=t&-t)||16===i&&0!==(4194240&s)))return t;if(0!==(4&r)&&(r|=16&n),0!==(t=e.entangledLanes))for(e=e.entanglements,t&=r;0<t;)i=1<<(n=31-at(t)),r|=e[n],t&=~i;return r}function pt(e,t){switch(e){case 1:case 2:case 4:return t+250;case 8:case 16:case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;default:return-1}}function ft(e){return 0!==(e=-1073741825&e.pendingLanes)?e:1073741824&e?1073741824:0}function mt(){var e=ut;return 0===(4194240&(ut<<=1))&&(ut=64),e}function gt(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function vt(e,t,n){e.pendingLanes|=t,536870912!==t&&(e.suspendedLanes=0,e.pingedLanes=0),(e=e.eventTimes)[t=31-at(t)]=n}function yt(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-at(n),i=1<<r;i&t|e[r]&t&&(e[r]|=t),n&=~i}}var _t=0;function xt(e){return 1<(e&=-e)?4<e?0!==(268435455&e)?16:536870912:4:1}var At,Mt,bt,St,wt,Et=!1,Tt=[],Ct=null,Rt=null,Pt=null,It=new Map,Bt=new Map,Lt=[],Dt="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset submit".split(" ");function Ut(e,t){switch(e){case"focusin":case"focusout":Ct=null;break;case"dragenter":case"dragleave":Rt=null;break;case"mouseover":case"mouseout":Pt=null;break;case"pointerover":case"pointerout":It.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":Bt.delete(t.pointerId)}}function Nt(e,t,n,r,i,s){return null===e||e.nativeEvent!==s?(e={blockedOn:t,domEventName:n,eventSystemFlags:r,nativeEvent:s,targetContainers:[i]},null!==t&&(null!==(t=_i(t))&&Mt(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,null!==i&&-1===t.indexOf(i)&&t.push(i),e)}function Ft(e){var t=yi(e.target);if(null!==t){var n=Ge(t);if(null!==n)if(13===(t=n.tag)){if(null!==(t=Ve(n)))return e.blockedOn=t,void wt(e.priority,(function(){bt(n)}))}else if(3===t&&n.stateNode.current.memoizedState.isDehydrated)return void(e.blockedOn=3===n.tag?n.stateNode.containerInfo:null)}e.blockedOn=null}function Ot(e){if(null!==e.blockedOn)return!1;for(var t=e.targetContainers;0<t.length;){var n=Kt(e.domEventName,e.eventSystemFlags,t[0],e.nativeEvent);if(null!==n)return null!==(t=_i(n))&&Mt(t),e.blockedOn=n,!1;var r=new(n=e.nativeEvent).constructor(n.type,n);xe=r,n.target.dispatchEvent(r),xe=null,t.shift()}return!0}function kt(e,t,n){Ot(e)&&n.delete(t)}function Ht(){Et=!1,null!==Ct&&Ot(Ct)&&(Ct=null),null!==Rt&&Ot(Rt)&&(Rt=null),null!==Pt&&Ot(Pt)&&(Pt=null),It.forEach(kt),Bt.forEach(kt)}function zt(e,t){e.blockedOn===t&&(e.blockedOn=null,Et||(Et=!0,i.unstable_scheduleCallback(i.unstable_NormalPriority,Ht)))}function Gt(e){function t(t){return zt(t,e)}if(0<Tt.length){zt(Tt[0],e);for(var n=1;n<Tt.length;n++){var r=Tt[n];r.blockedOn===e&&(r.blockedOn=null)}}for(null!==Ct&&zt(Ct,e),null!==Rt&&zt(Rt,e),null!==Pt&&zt(Pt,e),It.forEach(t),Bt.forEach(t),n=0;n<Lt.length;n++)(r=Lt[n]).blockedOn===e&&(r.blockedOn=null);for(;0<Lt.length&&null===(n=Lt[0]).blockedOn;)Ft(n),null===n.blockedOn&&Lt.shift()}var Vt=x.ReactCurrentBatchConfig,Wt=!0;function jt(e,t,n,r){var i=_t,s=Vt.transition;Vt.transition=null;try{_t=1,Jt(e,t,n,r)}finally{_t=i,Vt.transition=s}}function Xt(e,t,n,r){var i=_t,s=Vt.transition;Vt.transition=null;try{_t=4,Jt(e,t,n,r)}finally{_t=i,Vt.transition=s}}function Jt(e,t,n,r){if(Wt){var i=Kt(e,t,n,r);if(null===i)Wr(e,t,r,Yt,n),Ut(e,r);else if(function(e,t,n,r,i){switch(t){case"focusin":return Ct=Nt(Ct,e,t,n,r,i),!0;case"dragenter":return Rt=Nt(Rt,e,t,n,r,i),!0;case"mouseover":return Pt=Nt(Pt,e,t,n,r,i),!0;case"pointerover":var s=i.pointerId;return It.set(s,Nt(It.get(s)||null,e,t,n,r,i)),!0;case"gotpointercapture":return s=i.pointerId,Bt.set(s,Nt(Bt.get(s)||null,e,t,n,r,i)),!0}return!1}(i,e,t,n,r))r.stopPropagation();else if(Ut(e,r),4&t&&-1<Dt.indexOf(e)){for(;null!==i;){var s=_i(i);if(null!==s&&At(s),null===(s=Kt(e,t,n,r))&&Wr(e,t,r,Yt,n),s===i)break;i=s}null!==i&&r.stopPropagation()}else Wr(e,t,r,null,n)}}var Yt=null;function Kt(e,t,n,r){if(Yt=null,null!==(e=yi(e=Ae(r))))if(null===(t=Ge(e)))e=null;else if(13===(n=t.tag)){if(null!==(e=Ve(t)))return e;e=null}else if(3===n){if(t.stateNode.current.memoizedState.isDehydrated)return 3===t.tag?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null);return Yt=e,null}function qt(e){switch(e){case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 1;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch(Ze()){case $e:return 1;case et:return 4;case tt:case nt:return 16;case rt:return 536870912;default:return 16}default:return 16}}var Qt=null,Zt=null,$t=null;function en(){if($t)return $t;var e,t,n=Zt,r=n.length,i="value"in Qt?Qt.value:Qt.textContent,s=i.length;for(e=0;e<r&&n[e]===i[e];e++);var a=r-e;for(t=1;t<=a&&n[r-t]===i[s-t];t++);return $t=i.slice(e,1<t?1-t:void 0)}function tn(e){var t=e.keyCode;return"charCode"in e?0===(e=e.charCode)&&13===t&&(e=13):e=t,10===e&&(e=13),32<=e||13===e?e:0}function nn(){return!0}function rn(){return!1}function sn(e){function t(t,n,r,i,s){for(var a in this._reactName=t,this._targetInst=r,this.type=n,this.nativeEvent=i,this.target=s,this.currentTarget=null,e)e.hasOwnProperty(a)&&(t=e[a],this[a]=t?t(i):i[a]);return this.isDefaultPrevented=(null!=i.defaultPrevented?i.defaultPrevented:!1===i.returnValue)?nn:rn,this.isPropagationStopped=rn,this}return F(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var e=this.nativeEvent;e&&(e.preventDefault?e.preventDefault():"unknown"!==typeof e.returnValue&&(e.returnValue=!1),this.isDefaultPrevented=nn)},stopPropagation:function(){var e=this.nativeEvent;e&&(e.stopPropagation?e.stopPropagation():"unknown"!==typeof e.cancelBubble&&(e.cancelBubble=!0),this.isPropagationStopped=nn)},persist:function(){},isPersistent:nn}),t}var an,on,ln,un={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},cn=sn(un),hn=F({},un,{view:0,detail:0}),dn=sn(hn),pn=F({},hn,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:wn,button:0,buttons:0,relatedTarget:function(e){return void 0===e.relatedTarget?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return"movementX"in e?e.movementX:(e!==ln&&(ln&&"mousemove"===e.type?(an=e.screenX-ln.screenX,on=e.screenY-ln.screenY):on=an=0,ln=e),an)},movementY:function(e){return"movementY"in e?e.movementY:on}}),fn=sn(pn),mn=sn(F({},pn,{dataTransfer:0})),gn=sn(F({},hn,{relatedTarget:0})),vn=sn(F({},un,{animationName:0,elapsedTime:0,pseudoElement:0})),yn=F({},un,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),_n=sn(yn),xn=sn(F({},un,{data:0})),An={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Mn={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},bn={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Sn(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):!!(e=bn[e])&&!!t[e]}function wn(){return Sn}var En=F({},hn,{key:function(e){if(e.key){var t=An[e.key]||e.key;if("Unidentified"!==t)return t}return"keypress"===e.type?13===(e=tn(e))?"Enter":String.fromCharCode(e):"keydown"===e.type||"keyup"===e.type?Mn[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:wn,charCode:function(e){return"keypress"===e.type?tn(e):0},keyCode:function(e){return"keydown"===e.type||"keyup"===e.type?e.keyCode:0},which:function(e){return"keypress"===e.type?tn(e):"keydown"===e.type||"keyup"===e.type?e.keyCode:0}}),Tn=sn(En),Cn=sn(F({},pn,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0})),Rn=sn(F({},hn,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:wn})),Pn=sn(F({},un,{propertyName:0,elapsedTime:0,pseudoElement:0})),In=F({},pn,{deltaX:function(e){return"deltaX"in e?e.deltaX:"wheelDeltaX"in e?-e.wheelDeltaX:0},deltaY:function(e){return"deltaY"in e?e.deltaY:"wheelDeltaY"in e?-e.wheelDeltaY:"wheelDelta"in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0}),Bn=sn(In),Ln=[9,13,27,32],Dn=c&&"CompositionEvent"in window,Un=null;c&&"documentMode"in document&&(Un=document.documentMode);var Nn=c&&"TextEvent"in window&&!Un,Fn=c&&(!Dn||Un&&8<Un&&11>=Un),On=String.fromCharCode(32),kn=!1;function Hn(e,t){switch(e){case"keyup":return-1!==Ln.indexOf(t.keyCode);case"keydown":return 229!==t.keyCode;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function zn(e){return"object"===typeof(e=e.detail)&&"data"in e?e.data:null}var Gn=!1;var Vn={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function Wn(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return"input"===t?!!Vn[e.type]:"textarea"===t}function jn(e,t,n,r){Ee(r),0<(t=Xr(t,"onChange")).length&&(n=new cn("onChange","change",null,n,r),e.push({event:n,listeners:t}))}var Xn=null,Jn=null;function Yn(e){Or(e,0)}function Kn(e){if(J(xi(e)))return e}function qn(e,t){if("change"===e)return t}var Qn=!1;if(c){var Zn;if(c){var $n="oninput"in document;if(!$n){var er=document.createElement("div");er.setAttribute("oninput","return;"),$n="function"===typeof er.oninput}Zn=$n}else Zn=!1;Qn=Zn&&(!document.documentMode||9<document.documentMode)}function tr(){Xn&&(Xn.detachEvent("onpropertychange",nr),Jn=Xn=null)}function nr(e){if("value"===e.propertyName&&Kn(Jn)){var t=[];jn(t,Jn,e,Ae(e)),Ie(Yn,t)}}function rr(e,t,n){"focusin"===e?(tr(),Jn=n,(Xn=t).attachEvent("onpropertychange",nr)):"focusout"===e&&tr()}function ir(e){if("selectionchange"===e||"keyup"===e||"keydown"===e)return Kn(Jn)}function sr(e,t){if("click"===e)return Kn(t)}function ar(e,t){if("input"===e||"change"===e)return Kn(t)}var or="function"===typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e===1/t)||e!==e&&t!==t};function lr(e,t){if(or(e,t))return!0;if("object"!==typeof e||null===e||"object"!==typeof t||null===t)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(r=0;r<n.length;r++){var i=n[r];if(!h.call(t,i)||!or(e[i],t[i]))return!1}return!0}function ur(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function cr(e,t){var n,r=ur(e);for(e=0;r;){if(3===r.nodeType){if(n=e+r.textContent.length,e<=t&&n>=t)return{node:r,offset:t-e};e=n}e:{for(;r;){if(r.nextSibling){r=r.nextSibling;break e}r=r.parentNode}r=void 0}r=ur(r)}}function hr(e,t){return!(!e||!t)&&(e===t||(!e||3!==e.nodeType)&&(t&&3===t.nodeType?hr(e,t.parentNode):"contains"in e?e.contains(t):!!e.compareDocumentPosition&&!!(16&e.compareDocumentPosition(t))))}function dr(){for(var e=window,t=Y();t instanceof e.HTMLIFrameElement;){try{var n="string"===typeof t.contentWindow.location.href}catch(r){n=!1}if(!n)break;t=Y((e=t.contentWindow).document)}return t}function pr(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&("input"===t&&("text"===e.type||"search"===e.type||"tel"===e.type||"url"===e.type||"password"===e.type)||"textarea"===t||"true"===e.contentEditable)}function fr(e){var t=dr(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&hr(n.ownerDocument.documentElement,n)){if(null!==r&&pr(n))if(t=r.start,void 0===(e=r.end)&&(e=t),"selectionStart"in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if((e=(t=n.ownerDocument||document)&&t.defaultView||window).getSelection){e=e.getSelection();var i=n.textContent.length,s=Math.min(r.start,i);r=void 0===r.end?s:Math.min(r.end,i),!e.extend&&s>r&&(i=r,r=s,s=i),i=cr(n,s);var a=cr(n,r);i&&a&&(1!==e.rangeCount||e.anchorNode!==i.node||e.anchorOffset!==i.offset||e.focusNode!==a.node||e.focusOffset!==a.offset)&&((t=t.createRange()).setStart(i.node,i.offset),e.removeAllRanges(),s>r?(e.addRange(t),e.extend(a.node,a.offset)):(t.setEnd(a.node,a.offset),e.addRange(t)))}for(t=[],e=n;e=e.parentNode;)1===e.nodeType&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for("function"===typeof n.focus&&n.focus(),n=0;n<t.length;n++)(e=t[n]).element.scrollLeft=e.left,e.element.scrollTop=e.top}}var mr=c&&"documentMode"in document&&11>=document.documentMode,gr=null,vr=null,yr=null,_r=!1;function xr(e,t,n){var r=n.window===n?n.document:9===n.nodeType?n:n.ownerDocument;_r||null==gr||gr!==Y(r)||("selectionStart"in(r=gr)&&pr(r)?r={start:r.selectionStart,end:r.selectionEnd}:r={anchorNode:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection()).anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset},yr&&lr(yr,r)||(yr=r,0<(r=Xr(vr,"onSelect")).length&&(t=new cn("onSelect","select",null,t,n),e.push({event:t,listeners:r}),t.target=gr)))}function Ar(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit"+e]="webkit"+t,n["Moz"+e]="moz"+t,n}var Mr={animationend:Ar("Animation","AnimationEnd"),animationiteration:Ar("Animation","AnimationIteration"),animationstart:Ar("Animation","AnimationStart"),transitionend:Ar("Transition","TransitionEnd")},br={},Sr={};function wr(e){if(br[e])return br[e];if(!Mr[e])return e;var t,n=Mr[e];for(t in n)if(n.hasOwnProperty(t)&&t in Sr)return br[e]=n[t];return e}c&&(Sr=document.createElement("div").style,"AnimationEvent"in window||(delete Mr.animationend.animation,delete Mr.animationiteration.animation,delete Mr.animationstart.animation),"TransitionEvent"in window||delete Mr.transitionend.transition);var Er=wr("animationend"),Tr=wr("animationiteration"),Cr=wr("animationstart"),Rr=wr("transitionend"),Pr=new Map,Ir="abort auxClick cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");function Br(e,t){Pr.set(e,t),l(t,[e])}for(var Lr=0;Lr<Ir.length;Lr++){var Dr=Ir[Lr];Br(Dr.toLowerCase(),"on"+(Dr[0].toUpperCase()+Dr.slice(1)))}Br(Er,"onAnimationEnd"),Br(Tr,"onAnimationIteration"),Br(Cr,"onAnimationStart"),Br("dblclick","onDoubleClick"),Br("focusin","onFocus"),Br("focusout","onBlur"),Br(Rr,"onTransitionEnd"),u("onMouseEnter",["mouseout","mouseover"]),u("onMouseLeave",["mouseout","mouseover"]),u("onPointerEnter",["pointerout","pointerover"]),u("onPointerLeave",["pointerout","pointerover"]),l("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),l("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),l("onBeforeInput",["compositionend","keypress","textInput","paste"]),l("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),l("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),l("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Ur="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),Nr=new Set("cancel close invalid load scroll toggle".split(" ").concat(Ur));function Fr(e,t,n){var r=e.type||"unknown-event";e.currentTarget=n,function(e,t,n,r,i,a,o,l,u){if(ze.apply(this,arguments),Ne){if(!Ne)throw Error(s(198));var c=Fe;Ne=!1,Fe=null,Oe||(Oe=!0,ke=c)}}(r,t,void 0,e),e.currentTarget=null}function Or(e,t){t=0!==(4&t);for(var n=0;n<e.length;n++){var r=e[n],i=r.event;r=r.listeners;e:{var s=void 0;if(t)for(var a=r.length-1;0<=a;a--){var o=r[a],l=o.instance,u=o.currentTarget;if(o=o.listener,l!==s&&i.isPropagationStopped())break e;Fr(i,o,u),s=l}else for(a=0;a<r.length;a++){if(l=(o=r[a]).instance,u=o.currentTarget,o=o.listener,l!==s&&i.isPropagationStopped())break e;Fr(i,o,u),s=l}}}if(Oe)throw e=ke,Oe=!1,ke=null,e}function kr(e,t){var n=t[mi];void 0===n&&(n=t[mi]=new Set);var r=e+"__bubble";n.has(r)||(Vr(t,e,2,!1),n.add(r))}function Hr(e,t,n){var r=0;t&&(r|=4),Vr(n,e,r,t)}var zr="_reactListening"+Math.random().toString(36).slice(2);function Gr(e){if(!e[zr]){e[zr]=!0,a.forEach((function(t){"selectionchange"!==t&&(Nr.has(t)||Hr(t,!1,e),Hr(t,!0,e))}));var t=9===e.nodeType?e:e.ownerDocument;null===t||t[zr]||(t[zr]=!0,Hr("selectionchange",!1,t))}}function Vr(e,t,n,r){switch(qt(t)){case 1:var i=jt;break;case 4:i=Xt;break;default:i=Jt}n=i.bind(null,t,n,e),i=void 0,!Le||"touchstart"!==t&&"touchmove"!==t&&"wheel"!==t||(i=!0),r?void 0!==i?e.addEventListener(t,n,{capture:!0,passive:i}):e.addEventListener(t,n,!0):void 0!==i?e.addEventListener(t,n,{passive:i}):e.addEventListener(t,n,!1)}function Wr(e,t,n,r,i){var s=r;if(0===(1&t)&&0===(2&t)&&null!==r)e:for(;;){if(null===r)return;var a=r.tag;if(3===a||4===a){var o=r.stateNode.containerInfo;if(o===i||8===o.nodeType&&o.parentNode===i)break;if(4===a)for(a=r.return;null!==a;){var l=a.tag;if((3===l||4===l)&&((l=a.stateNode.containerInfo)===i||8===l.nodeType&&l.parentNode===i))return;a=a.return}for(;null!==o;){if(null===(a=yi(o)))return;if(5===(l=a.tag)||6===l){r=s=a;continue e}o=o.parentNode}}r=r.return}Ie((function(){var r=s,i=Ae(n),a=[];e:{var o=Pr.get(e);if(void 0!==o){var l=cn,u=e;switch(e){case"keypress":if(0===tn(n))break e;case"keydown":case"keyup":l=Tn;break;case"focusin":u="focus",l=gn;break;case"focusout":u="blur",l=gn;break;case"beforeblur":case"afterblur":l=gn;break;case"click":if(2===n.button)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":l=fn;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":l=mn;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":l=Rn;break;case Er:case Tr:case Cr:l=vn;break;case Rr:l=Pn;break;case"scroll":l=dn;break;case"wheel":l=Bn;break;case"copy":case"cut":case"paste":l=_n;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":l=Cn}var c=0!==(4&t),h=!c&&"scroll"===e,d=c?null!==o?o+"Capture":null:o;c=[];for(var p,f=r;null!==f;){var m=(p=f).stateNode;if(5===p.tag&&null!==m&&(p=m,null!==d&&(null!=(m=Be(f,d))&&c.push(jr(f,m,p)))),h)break;f=f.return}0<c.length&&(o=new l(o,u,null,n,i),a.push({event:o,listeners:c}))}}if(0===(7&t)){if(l="mouseout"===e||"pointerout"===e,(!(o="mouseover"===e||"pointerover"===e)||n===xe||!(u=n.relatedTarget||n.fromElement)||!yi(u)&&!u[fi])&&(l||o)&&(o=i.window===i?i:(o=i.ownerDocument)?o.defaultView||o.parentWindow:window,l?(l=r,null!==(u=(u=n.relatedTarget||n.toElement)?yi(u):null)&&(u!==(h=Ge(u))||5!==u.tag&&6!==u.tag)&&(u=null)):(l=null,u=r),l!==u)){if(c=fn,m="onMouseLeave",d="onMouseEnter",f="mouse","pointerout"!==e&&"pointerover"!==e||(c=Cn,m="onPointerLeave",d="onPointerEnter",f="pointer"),h=null==l?o:xi(l),p=null==u?o:xi(u),(o=new c(m,f+"leave",l,n,i)).target=h,o.relatedTarget=p,m=null,yi(i)===r&&((c=new c(d,f+"enter",u,n,i)).target=p,c.relatedTarget=h,m=c),h=m,l&&u)e:{for(d=u,f=0,p=c=l;p;p=Jr(p))f++;for(p=0,m=d;m;m=Jr(m))p++;for(;0<f-p;)c=Jr(c),f--;for(;0<p-f;)d=Jr(d),p--;for(;f--;){if(c===d||null!==d&&c===d.alternate)break e;c=Jr(c),d=Jr(d)}c=null}else c=null;null!==l&&Yr(a,o,l,c,!1),null!==u&&null!==h&&Yr(a,h,u,c,!0)}if("select"===(l=(o=r?xi(r):window).nodeName&&o.nodeName.toLowerCase())||"input"===l&&"file"===o.type)var g=qn;else if(Wn(o))if(Qn)g=ar;else{g=ir;var v=rr}else(l=o.nodeName)&&"input"===l.toLowerCase()&&("checkbox"===o.type||"radio"===o.type)&&(g=sr);switch(g&&(g=g(e,r))?jn(a,g,n,i):(v&&v(e,o,r),"focusout"===e&&(v=o._wrapperState)&&v.controlled&&"number"===o.type&&ee(o,"number",o.value)),v=r?xi(r):window,e){case"focusin":(Wn(v)||"true"===v.contentEditable)&&(gr=v,vr=r,yr=null);break;case"focusout":yr=vr=gr=null;break;case"mousedown":_r=!0;break;case"contextmenu":case"mouseup":case"dragend":_r=!1,xr(a,n,i);break;case"selectionchange":if(mr)break;case"keydown":case"keyup":xr(a,n,i)}var y;if(Dn)e:{switch(e){case"compositionstart":var _="onCompositionStart";break e;case"compositionend":_="onCompositionEnd";break e;case"compositionupdate":_="onCompositionUpdate";break e}_=void 0}else Gn?Hn(e,n)&&(_="onCompositionEnd"):"keydown"===e&&229===n.keyCode&&(_="onCompositionStart");_&&(Fn&&"ko"!==n.locale&&(Gn||"onCompositionStart"!==_?"onCompositionEnd"===_&&Gn&&(y=en()):(Zt="value"in(Qt=i)?Qt.value:Qt.textContent,Gn=!0)),0<(v=Xr(r,_)).length&&(_=new xn(_,e,null,n,i),a.push({event:_,listeners:v}),y?_.data=y:null!==(y=zn(n))&&(_.data=y))),(y=Nn?function(e,t){switch(e){case"compositionend":return zn(t);case"keypress":return 32!==t.which?null:(kn=!0,On);case"textInput":return(e=t.data)===On&&kn?null:e;default:return null}}(e,n):function(e,t){if(Gn)return"compositionend"===e||!Dn&&Hn(e,t)?(e=en(),$t=Zt=Qt=null,Gn=!1,e):null;switch(e){case"paste":default:return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case"compositionend":return Fn&&"ko"!==t.locale?null:t.data}}(e,n))&&(0<(r=Xr(r,"onBeforeInput")).length&&(i=new xn("onBeforeInput","beforeinput",null,n,i),a.push({event:i,listeners:r}),i.data=y))}Or(a,t)}))}function jr(e,t,n){return{instance:e,listener:t,currentTarget:n}}function Xr(e,t){for(var n=t+"Capture",r=[];null!==e;){var i=e,s=i.stateNode;5===i.tag&&null!==s&&(i=s,null!=(s=Be(e,n))&&r.unshift(jr(e,s,i)),null!=(s=Be(e,t))&&r.push(jr(e,s,i))),e=e.return}return r}function Jr(e){if(null===e)return null;do{e=e.return}while(e&&5!==e.tag);return e||null}function Yr(e,t,n,r,i){for(var s=t._reactName,a=[];null!==n&&n!==r;){var o=n,l=o.alternate,u=o.stateNode;if(null!==l&&l===r)break;5===o.tag&&null!==u&&(o=u,i?null!=(l=Be(n,s))&&a.unshift(jr(n,l,o)):i||null!=(l=Be(n,s))&&a.push(jr(n,l,o))),n=n.return}0!==a.length&&e.push({event:t,listeners:a})}var Kr=/\r\n?/g,qr=/\u0000|\uFFFD/g;function Qr(e){return("string"===typeof e?e:""+e).replace(Kr,"\n").replace(qr,"")}function Zr(e,t,n){if(t=Qr(t),Qr(e)!==t&&n)throw Error(s(425))}function $r(){}var ei=null,ti=null;function ni(e,t){return"textarea"===e||"noscript"===e||"string"===typeof t.children||"number"===typeof t.children||"object"===typeof t.dangerouslySetInnerHTML&&null!==t.dangerouslySetInnerHTML&&null!=t.dangerouslySetInnerHTML.__html}var ri="function"===typeof setTimeout?setTimeout:void 0,ii="function"===typeof clearTimeout?clearTimeout:void 0,si="function"===typeof Promise?Promise:void 0,ai="function"===typeof queueMicrotask?queueMicrotask:"undefined"!==typeof si?function(e){return si.resolve(null).then(e).catch(oi)}:ri;function oi(e){setTimeout((function(){throw e}))}function li(e,t){var n=t,r=0;do{var i=n.nextSibling;if(e.removeChild(n),i&&8===i.nodeType)if("/$"===(n=i.data)){if(0===r)return e.removeChild(i),void Gt(t);r--}else"$"!==n&&"$?"!==n&&"$!"!==n||r++;n=i}while(n);Gt(t)}function ui(e){for(;null!=e;e=e.nextSibling){var t=e.nodeType;if(1===t||3===t)break;if(8===t){if("$"===(t=e.data)||"$!"===t||"$?"===t)break;if("/$"===t)return null}}return e}function ci(e){e=e.previousSibling;for(var t=0;e;){if(8===e.nodeType){var n=e.data;if("$"===n||"$!"===n||"$?"===n){if(0===t)return e;t--}else"/$"===n&&t++}e=e.previousSibling}return null}var hi=Math.random().toString(36).slice(2),di="__reactFiber$"+hi,pi="__reactProps$"+hi,fi="__reactContainer$"+hi,mi="__reactEvents$"+hi,gi="__reactListeners$"+hi,vi="__reactHandles$"+hi;function yi(e){var t=e[di];if(t)return t;for(var n=e.parentNode;n;){if(t=n[fi]||n[di]){if(n=t.alternate,null!==t.child||null!==n&&null!==n.child)for(e=ci(e);null!==e;){if(n=e[di])return n;e=ci(e)}return t}n=(e=n).parentNode}return null}function _i(e){return!(e=e[di]||e[fi])||5!==e.tag&&6!==e.tag&&13!==e.tag&&3!==e.tag?null:e}function xi(e){if(5===e.tag||6===e.tag)return e.stateNode;throw Error(s(33))}function Ai(e){return e[pi]||null}var Mi=[],bi=-1;function Si(e){return{current:e}}function wi(e){0>bi||(e.current=Mi[bi],Mi[bi]=null,bi--)}function Ei(e,t){bi++,Mi[bi]=e.current,e.current=t}var Ti={},Ci=Si(Ti),Ri=Si(!1),Pi=Ti;function Ii(e,t){var n=e.type.contextTypes;if(!n)return Ti;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var i,s={};for(i in n)s[i]=t[i];return r&&((e=e.stateNode).__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=s),s}function Bi(e){return null!==(e=e.childContextTypes)&&void 0!==e}function Li(){wi(Ri),wi(Ci)}function Di(e,t,n){if(Ci.current!==Ti)throw Error(s(168));Ei(Ci,t),Ei(Ri,n)}function Ui(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,"function"!==typeof r.getChildContext)return n;for(var i in r=r.getChildContext())if(!(i in t))throw Error(s(108,V(e)||"Unknown",i));return F({},n,r)}function Ni(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Ti,Pi=Ci.current,Ei(Ci,e),Ei(Ri,Ri.current),!0}function Fi(e,t,n){var r=e.stateNode;if(!r)throw Error(s(169));n?(e=Ui(e,t,Pi),r.__reactInternalMemoizedMergedChildContext=e,wi(Ri),wi(Ci),Ei(Ci,e)):wi(Ri),Ei(Ri,n)}var Oi=null,ki=!1,Hi=!1;function zi(e){null===Oi?Oi=[e]:Oi.push(e)}function Gi(){if(!Hi&&null!==Oi){Hi=!0;var e=0,t=_t;try{var n=Oi;for(_t=1;e<n.length;e++){var r=n[e];do{r=r(!0)}while(null!==r)}Oi=null,ki=!1}catch(i){throw null!==Oi&&(Oi=Oi.slice(e+1)),Je($e,Gi),i}finally{_t=t,Hi=!1}}return null}var Vi=[],Wi=0,ji=null,Xi=0,Ji=[],Yi=0,Ki=null,qi=1,Qi="";function Zi(e,t){Vi[Wi++]=Xi,Vi[Wi++]=ji,ji=e,Xi=t}function $i(e,t,n){Ji[Yi++]=qi,Ji[Yi++]=Qi,Ji[Yi++]=Ki,Ki=e;var r=qi;e=Qi;var i=32-at(r)-1;r&=~(1<<i),n+=1;var s=32-at(t)+i;if(30<s){var a=i-i%5;s=(r&(1<<a)-1).toString(32),r>>=a,i-=a,qi=1<<32-at(t)+i|n<<i|r,Qi=s+e}else qi=1<<s|n<<i|r,Qi=e}function es(e){null!==e.return&&(Zi(e,1),$i(e,1,0))}function ts(e){for(;e===ji;)ji=Vi[--Wi],Vi[Wi]=null,Xi=Vi[--Wi],Vi[Wi]=null;for(;e===Ki;)Ki=Ji[--Yi],Ji[Yi]=null,Qi=Ji[--Yi],Ji[Yi]=null,qi=Ji[--Yi],Ji[Yi]=null}var ns=null,rs=null,is=!1,ss=null;function as(e,t){var n=Iu(5,null,null,0);n.elementType="DELETED",n.stateNode=t,n.return=e,null===(t=e.deletions)?(e.deletions=[n],e.flags|=16):t.push(n)}function os(e,t){switch(e.tag){case 5:var n=e.type;return null!==(t=1!==t.nodeType||n.toLowerCase()!==t.nodeName.toLowerCase()?null:t)&&(e.stateNode=t,ns=e,rs=ui(t.firstChild),!0);case 6:return null!==(t=""===e.pendingProps||3!==t.nodeType?null:t)&&(e.stateNode=t,ns=e,rs=null,!0);case 13:return null!==(t=8!==t.nodeType?null:t)&&(n=null!==Ki?{id:qi,overflow:Qi}:null,e.memoizedState={dehydrated:t,treeContext:n,retryLane:1073741824},(n=Iu(18,null,null,0)).stateNode=t,n.return=e,e.child=n,ns=e,rs=null,!0);default:return!1}}function ls(e){return 0!==(1&e.mode)&&0===(128&e.flags)}function us(e){if(is){var t=rs;if(t){var n=t;if(!os(e,t)){if(ls(e))throw Error(s(418));t=ui(n.nextSibling);var r=ns;t&&os(e,t)?as(r,n):(e.flags=-4097&e.flags|2,is=!1,ns=e)}}else{if(ls(e))throw Error(s(418));e.flags=-4097&e.flags|2,is=!1,ns=e}}}function cs(e){for(e=e.return;null!==e&&5!==e.tag&&3!==e.tag&&13!==e.tag;)e=e.return;ns=e}function hs(e){if(e!==ns)return!1;if(!is)return cs(e),is=!0,!1;var t;if((t=3!==e.tag)&&!(t=5!==e.tag)&&(t="head"!==(t=e.type)&&"body"!==t&&!ni(e.type,e.memoizedProps)),t&&(t=rs)){if(ls(e))throw ds(),Error(s(418));for(;t;)as(e,t),t=ui(t.nextSibling)}if(cs(e),13===e.tag){if(!(e=null!==(e=e.memoizedState)?e.dehydrated:null))throw Error(s(317));e:{for(e=e.nextSibling,t=0;e;){if(8===e.nodeType){var n=e.data;if("/$"===n){if(0===t){rs=ui(e.nextSibling);break e}t--}else"$"!==n&&"$!"!==n&&"$?"!==n||t++}e=e.nextSibling}rs=null}}else rs=ns?ui(e.stateNode.nextSibling):null;return!0}function ds(){for(var e=rs;e;)e=ui(e.nextSibling)}function ps(){rs=ns=null,is=!1}function fs(e){null===ss?ss=[e]:ss.push(e)}var ms=x.ReactCurrentBatchConfig;function gs(e,t,n){if(null!==(e=n.ref)&&"function"!==typeof e&&"object"!==typeof e){if(n._owner){if(n=n._owner){if(1!==n.tag)throw Error(s(309));var r=n.stateNode}if(!r)throw Error(s(147,e));var i=r,a=""+e;return null!==t&&null!==t.ref&&"function"===typeof t.ref&&t.ref._stringRef===a?t.ref:(t=function(e){var t=i.refs;null===e?delete t[a]:t[a]=e},t._stringRef=a,t)}if("string"!==typeof e)throw Error(s(284));if(!n._owner)throw Error(s(290,e))}return e}function vs(e,t){throw e=Object.prototype.toString.call(t),Error(s(31,"[object Object]"===e?"object with keys {"+Object.keys(t).join(", ")+"}":e))}function ys(e){return(0,e._init)(e._payload)}function _s(e){function t(t,n){if(e){var r=t.deletions;null===r?(t.deletions=[n],t.flags|=16):r.push(n)}}function n(n,r){if(!e)return null;for(;null!==r;)t(n,r),r=r.sibling;return null}function r(e,t){for(e=new Map;null!==t;)null!==t.key?e.set(t.key,t):e.set(t.index,t),t=t.sibling;return e}function i(e,t){return(e=Lu(e,t)).index=0,e.sibling=null,e}function a(t,n,r){return t.index=r,e?null!==(r=t.alternate)?(r=r.index)<n?(t.flags|=2,n):r:(t.flags|=2,n):(t.flags|=1048576,n)}function o(t){return e&&null===t.alternate&&(t.flags|=2),t}function l(e,t,n,r){return null===t||6!==t.tag?((t=Fu(n,e.mode,r)).return=e,t):((t=i(t,n)).return=e,t)}function u(e,t,n,r){var s=n.type;return s===b?h(e,t,n.props.children,r,n.key):null!==t&&(t.elementType===s||"object"===typeof s&&null!==s&&s.$$typeof===B&&ys(s)===t.type)?((r=i(t,n.props)).ref=gs(e,t,n),r.return=e,r):((r=Du(n.type,n.key,n.props,null,e.mode,r)).ref=gs(e,t,n),r.return=e,r)}function c(e,t,n,r){return null===t||4!==t.tag||t.stateNode.containerInfo!==n.containerInfo||t.stateNode.implementation!==n.implementation?((t=Ou(n,e.mode,r)).return=e,t):((t=i(t,n.children||[])).return=e,t)}function h(e,t,n,r,s){return null===t||7!==t.tag?((t=Uu(n,e.mode,r,s)).return=e,t):((t=i(t,n)).return=e,t)}function d(e,t,n){if("string"===typeof t&&""!==t||"number"===typeof t)return(t=Fu(""+t,e.mode,n)).return=e,t;if("object"===typeof t&&null!==t){switch(t.$$typeof){case A:return(n=Du(t.type,t.key,t.props,null,e.mode,n)).ref=gs(e,null,t),n.return=e,n;case M:return(t=Ou(t,e.mode,n)).return=e,t;case B:return d(e,(0,t._init)(t._payload),n)}if(te(t)||U(t))return(t=Uu(t,e.mode,n,null)).return=e,t;vs(e,t)}return null}function p(e,t,n,r){var i=null!==t?t.key:null;if("string"===typeof n&&""!==n||"number"===typeof n)return null!==i?null:l(e,t,""+n,r);if("object"===typeof n&&null!==n){switch(n.$$typeof){case A:return n.key===i?u(e,t,n,r):null;case M:return n.key===i?c(e,t,n,r):null;case B:return p(e,t,(i=n._init)(n._payload),r)}if(te(n)||U(n))return null!==i?null:h(e,t,n,r,null);vs(e,n)}return null}function f(e,t,n,r,i){if("string"===typeof r&&""!==r||"number"===typeof r)return l(t,e=e.get(n)||null,""+r,i);if("object"===typeof r&&null!==r){switch(r.$$typeof){case A:return u(t,e=e.get(null===r.key?n:r.key)||null,r,i);case M:return c(t,e=e.get(null===r.key?n:r.key)||null,r,i);case B:return f(e,t,n,(0,r._init)(r._payload),i)}if(te(r)||U(r))return h(t,e=e.get(n)||null,r,i,null);vs(t,r)}return null}function m(i,s,o,l){for(var u=null,c=null,h=s,m=s=0,g=null;null!==h&&m<o.length;m++){h.index>m?(g=h,h=null):g=h.sibling;var v=p(i,h,o[m],l);if(null===v){null===h&&(h=g);break}e&&h&&null===v.alternate&&t(i,h),s=a(v,s,m),null===c?u=v:c.sibling=v,c=v,h=g}if(m===o.length)return n(i,h),is&&Zi(i,m),u;if(null===h){for(;m<o.length;m++)null!==(h=d(i,o[m],l))&&(s=a(h,s,m),null===c?u=h:c.sibling=h,c=h);return is&&Zi(i,m),u}for(h=r(i,h);m<o.length;m++)null!==(g=f(h,i,m,o[m],l))&&(e&&null!==g.alternate&&h.delete(null===g.key?m:g.key),s=a(g,s,m),null===c?u=g:c.sibling=g,c=g);return e&&h.forEach((function(e){return t(i,e)})),is&&Zi(i,m),u}function g(i,o,l,u){var c=U(l);if("function"!==typeof c)throw Error(s(150));if(null==(l=c.call(l)))throw Error(s(151));for(var h=c=null,m=o,g=o=0,v=null,y=l.next();null!==m&&!y.done;g++,y=l.next()){m.index>g?(v=m,m=null):v=m.sibling;var _=p(i,m,y.value,u);if(null===_){null===m&&(m=v);break}e&&m&&null===_.alternate&&t(i,m),o=a(_,o,g),null===h?c=_:h.sibling=_,h=_,m=v}if(y.done)return n(i,m),is&&Zi(i,g),c;if(null===m){for(;!y.done;g++,y=l.next())null!==(y=d(i,y.value,u))&&(o=a(y,o,g),null===h?c=y:h.sibling=y,h=y);return is&&Zi(i,g),c}for(m=r(i,m);!y.done;g++,y=l.next())null!==(y=f(m,i,g,y.value,u))&&(e&&null!==y.alternate&&m.delete(null===y.key?g:y.key),o=a(y,o,g),null===h?c=y:h.sibling=y,h=y);return e&&m.forEach((function(e){return t(i,e)})),is&&Zi(i,g),c}return function e(r,s,a,l){if("object"===typeof a&&null!==a&&a.type===b&&null===a.key&&(a=a.props.children),"object"===typeof a&&null!==a){switch(a.$$typeof){case A:e:{for(var u=a.key,c=s;null!==c;){if(c.key===u){if((u=a.type)===b){if(7===c.tag){n(r,c.sibling),(s=i(c,a.props.children)).return=r,r=s;break e}}else if(c.elementType===u||"object"===typeof u&&null!==u&&u.$$typeof===B&&ys(u)===c.type){n(r,c.sibling),(s=i(c,a.props)).ref=gs(r,c,a),s.return=r,r=s;break e}n(r,c);break}t(r,c),c=c.sibling}a.type===b?((s=Uu(a.props.children,r.mode,l,a.key)).return=r,r=s):((l=Du(a.type,a.key,a.props,null,r.mode,l)).ref=gs(r,s,a),l.return=r,r=l)}return o(r);case M:e:{for(c=a.key;null!==s;){if(s.key===c){if(4===s.tag&&s.stateNode.containerInfo===a.containerInfo&&s.stateNode.implementation===a.implementation){n(r,s.sibling),(s=i(s,a.children||[])).return=r,r=s;break e}n(r,s);break}t(r,s),s=s.sibling}(s=Ou(a,r.mode,l)).return=r,r=s}return o(r);case B:return e(r,s,(c=a._init)(a._payload),l)}if(te(a))return m(r,s,a,l);if(U(a))return g(r,s,a,l);vs(r,a)}return"string"===typeof a&&""!==a||"number"===typeof a?(a=""+a,null!==s&&6===s.tag?(n(r,s.sibling),(s=i(s,a)).return=r,r=s):(n(r,s),(s=Fu(a,r.mode,l)).return=r,r=s),o(r)):n(r,s)}}var xs=_s(!0),As=_s(!1),Ms=Si(null),bs=null,Ss=null,ws=null;function Es(){ws=Ss=bs=null}function Ts(e){var t=Ms.current;wi(Ms),e._currentValue=t}function Cs(e,t,n){for(;null!==e;){var r=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,null!==r&&(r.childLanes|=t)):null!==r&&(r.childLanes&t)!==t&&(r.childLanes|=t),e===n)break;e=e.return}}function Rs(e,t){bs=e,ws=Ss=null,null!==(e=e.dependencies)&&null!==e.firstContext&&(0!==(e.lanes&t)&&(_o=!0),e.firstContext=null)}function Ps(e){var t=e._currentValue;if(ws!==e)if(e={context:e,memoizedValue:t,next:null},null===Ss){if(null===bs)throw Error(s(308));Ss=e,bs.dependencies={lanes:0,firstContext:e}}else Ss=Ss.next=e;return t}var Is=null;function Bs(e){null===Is?Is=[e]:Is.push(e)}function Ls(e,t,n,r){var i=t.interleaved;return null===i?(n.next=n,Bs(t)):(n.next=i.next,i.next=n),t.interleaved=n,Ds(e,r)}function Ds(e,t){e.lanes|=t;var n=e.alternate;for(null!==n&&(n.lanes|=t),n=e,e=e.return;null!==e;)e.childLanes|=t,null!==(n=e.alternate)&&(n.childLanes|=t),n=e,e=e.return;return 3===n.tag?n.stateNode:null}var Us=!1;function Ns(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Fs(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function Os(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function ks(e,t,n){var r=e.updateQueue;if(null===r)return null;if(r=r.shared,0!==(2&Cl)){var i=r.pending;return null===i?t.next=t:(t.next=i.next,i.next=t),r.pending=t,Ds(e,n)}return null===(i=r.interleaved)?(t.next=t,Bs(r)):(t.next=i.next,i.next=t),r.interleaved=t,Ds(e,n)}function Hs(e,t,n){if(null!==(t=t.updateQueue)&&(t=t.shared,0!==(4194240&n))){var r=t.lanes;n|=r&=e.pendingLanes,t.lanes=n,yt(e,n)}}function zs(e,t){var n=e.updateQueue,r=e.alternate;if(null!==r&&n===(r=r.updateQueue)){var i=null,s=null;if(null!==(n=n.firstBaseUpdate)){do{var a={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};null===s?i=s=a:s=s.next=a,n=n.next}while(null!==n);null===s?i=s=t:s=s.next=t}else i=s=t;return n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:s,shared:r.shared,effects:r.effects},void(e.updateQueue=n)}null===(e=n.lastBaseUpdate)?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function Gs(e,t,n,r){var i=e.updateQueue;Us=!1;var s=i.firstBaseUpdate,a=i.lastBaseUpdate,o=i.shared.pending;if(null!==o){i.shared.pending=null;var l=o,u=l.next;l.next=null,null===a?s=u:a.next=u,a=l;var c=e.alternate;null!==c&&((o=(c=c.updateQueue).lastBaseUpdate)!==a&&(null===o?c.firstBaseUpdate=u:o.next=u,c.lastBaseUpdate=l))}if(null!==s){var h=i.baseState;for(a=0,c=u=l=null,o=s;;){var d=o.lane,p=o.eventTime;if((r&d)===d){null!==c&&(c=c.next={eventTime:p,lane:0,tag:o.tag,payload:o.payload,callback:o.callback,next:null});e:{var f=e,m=o;switch(d=t,p=n,m.tag){case 1:if("function"===typeof(f=m.payload)){h=f.call(p,h,d);break e}h=f;break e;case 3:f.flags=-65537&f.flags|128;case 0:if(null===(d="function"===typeof(f=m.payload)?f.call(p,h,d):f)||void 0===d)break e;h=F({},h,d);break e;case 2:Us=!0}}null!==o.callback&&0!==o.lane&&(e.flags|=64,null===(d=i.effects)?i.effects=[o]:d.push(o))}else p={eventTime:p,lane:d,tag:o.tag,payload:o.payload,callback:o.callback,next:null},null===c?(u=c=p,l=h):c=c.next=p,a|=d;if(null===(o=o.next)){if(null===(o=i.shared.pending))break;o=(d=o).next,d.next=null,i.lastBaseUpdate=d,i.shared.pending=null}}if(null===c&&(l=h),i.baseState=l,i.firstBaseUpdate=u,i.lastBaseUpdate=c,null!==(t=i.shared.interleaved)){i=t;do{a|=i.lane,i=i.next}while(i!==t)}else null===s&&(i.shared.lanes=0);Nl|=a,e.lanes=a,e.memoizedState=h}}function Vs(e,t,n){if(e=t.effects,t.effects=null,null!==e)for(t=0;t<e.length;t++){var r=e[t],i=r.callback;if(null!==i){if(r.callback=null,r=n,"function"!==typeof i)throw Error(s(191,i));i.call(r)}}}var Ws={},js=Si(Ws),Xs=Si(Ws),Js=Si(Ws);function Ys(e){if(e===Ws)throw Error(s(174));return e}function Ks(e,t){switch(Ei(Js,t),Ei(Xs,e),Ei(js,Ws),e=t.nodeType){case 9:case 11:t=(t=t.documentElement)?t.namespaceURI:le(null,"");break;default:t=le(t=(e=8===e?t.parentNode:t).namespaceURI||null,e=e.tagName)}wi(js),Ei(js,t)}function qs(){wi(js),wi(Xs),wi(Js)}function Qs(e){Ys(Js.current);var t=Ys(js.current),n=le(t,e.type);t!==n&&(Ei(Xs,e),Ei(js,n))}function Zs(e){Xs.current===e&&(wi(js),wi(Xs))}var $s=Si(0);function ea(e){for(var t=e;null!==t;){if(13===t.tag){var n=t.memoizedState;if(null!==n&&(null===(n=n.dehydrated)||"$?"===n.data||"$!"===n.data))return t}else if(19===t.tag&&void 0!==t.memoizedProps.revealOrder){if(0!==(128&t.flags))return t}else if(null!==t.child){t.child.return=t,t=t.child;continue}if(t===e)break;for(;null===t.sibling;){if(null===t.return||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var ta=[];function na(){for(var e=0;e<ta.length;e++)ta[e]._workInProgressVersionPrimary=null;ta.length=0}var ra=x.ReactCurrentDispatcher,ia=x.ReactCurrentBatchConfig,sa=0,aa=null,oa=null,la=null,ua=!1,ca=!1,ha=0,da=0;function pa(){throw Error(s(321))}function fa(e,t){if(null===t)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!or(e[n],t[n]))return!1;return!0}function ma(e,t,n,r,i,a){if(sa=a,aa=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,ra.current=null===e||null===e.memoizedState?Za:$a,e=n(r,i),ca){a=0;do{if(ca=!1,ha=0,25<=a)throw Error(s(301));a+=1,la=oa=null,t.updateQueue=null,ra.current=eo,e=n(r,i)}while(ca)}if(ra.current=Qa,t=null!==oa&&null!==oa.next,sa=0,la=oa=aa=null,ua=!1,t)throw Error(s(300));return e}function ga(){var e=0!==ha;return ha=0,e}function va(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return null===la?aa.memoizedState=la=e:la=la.next=e,la}function ya(){if(null===oa){var e=aa.alternate;e=null!==e?e.memoizedState:null}else e=oa.next;var t=null===la?aa.memoizedState:la.next;if(null!==t)la=t,oa=e;else{if(null===e)throw Error(s(310));e={memoizedState:(oa=e).memoizedState,baseState:oa.baseState,baseQueue:oa.baseQueue,queue:oa.queue,next:null},null===la?aa.memoizedState=la=e:la=la.next=e}return la}function _a(e,t){return"function"===typeof t?t(e):t}function xa(e){var t=ya(),n=t.queue;if(null===n)throw Error(s(311));n.lastRenderedReducer=e;var r=oa,i=r.baseQueue,a=n.pending;if(null!==a){if(null!==i){var o=i.next;i.next=a.next,a.next=o}r.baseQueue=i=a,n.pending=null}if(null!==i){a=i.next,r=r.baseState;var l=o=null,u=null,c=a;do{var h=c.lane;if((sa&h)===h)null!==u&&(u=u.next={lane:0,action:c.action,hasEagerState:c.hasEagerState,eagerState:c.eagerState,next:null}),r=c.hasEagerState?c.eagerState:e(r,c.action);else{var d={lane:h,action:c.action,hasEagerState:c.hasEagerState,eagerState:c.eagerState,next:null};null===u?(l=u=d,o=r):u=u.next=d,aa.lanes|=h,Nl|=h}c=c.next}while(null!==c&&c!==a);null===u?o=r:u.next=l,or(r,t.memoizedState)||(_o=!0),t.memoizedState=r,t.baseState=o,t.baseQueue=u,n.lastRenderedState=r}if(null!==(e=n.interleaved)){i=e;do{a=i.lane,aa.lanes|=a,Nl|=a,i=i.next}while(i!==e)}else null===i&&(n.lanes=0);return[t.memoizedState,n.dispatch]}function Aa(e){var t=ya(),n=t.queue;if(null===n)throw Error(s(311));n.lastRenderedReducer=e;var r=n.dispatch,i=n.pending,a=t.memoizedState;if(null!==i){n.pending=null;var o=i=i.next;do{a=e(a,o.action),o=o.next}while(o!==i);or(a,t.memoizedState)||(_o=!0),t.memoizedState=a,null===t.baseQueue&&(t.baseState=a),n.lastRenderedState=a}return[a,r]}function Ma(){}function ba(e,t){var n=aa,r=ya(),i=t(),a=!or(r.memoizedState,i);if(a&&(r.memoizedState=i,_o=!0),r=r.queue,Ua(Ea.bind(null,n,r,e),[e]),r.getSnapshot!==t||a||null!==la&&1&la.memoizedState.tag){if(n.flags|=2048,Pa(9,wa.bind(null,n,r,i,t),void 0,null),null===Rl)throw Error(s(349));0!==(30&sa)||Sa(n,t,i)}return i}function Sa(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},null===(t=aa.updateQueue)?(t={lastEffect:null,stores:null},aa.updateQueue=t,t.stores=[e]):null===(n=t.stores)?t.stores=[e]:n.push(e)}function wa(e,t,n,r){t.value=n,t.getSnapshot=r,Ta(t)&&Ca(e)}function Ea(e,t,n){return n((function(){Ta(t)&&Ca(e)}))}function Ta(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!or(e,n)}catch(r){return!0}}function Ca(e){var t=Ds(e,1);null!==t&&nu(t,e,1,-1)}function Ra(e){var t=va();return"function"===typeof e&&(e=e()),t.memoizedState=t.baseState=e,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:_a,lastRenderedState:e},t.queue=e,e=e.dispatch=Ja.bind(null,aa,e),[t.memoizedState,e]}function Pa(e,t,n,r){return e={tag:e,create:t,destroy:n,deps:r,next:null},null===(t=aa.updateQueue)?(t={lastEffect:null,stores:null},aa.updateQueue=t,t.lastEffect=e.next=e):null===(n=t.lastEffect)?t.lastEffect=e.next=e:(r=n.next,n.next=e,e.next=r,t.lastEffect=e),e}function Ia(){return ya().memoizedState}function Ba(e,t,n,r){var i=va();aa.flags|=e,i.memoizedState=Pa(1|t,n,void 0,void 0===r?null:r)}function La(e,t,n,r){var i=ya();r=void 0===r?null:r;var s=void 0;if(null!==oa){var a=oa.memoizedState;if(s=a.destroy,null!==r&&fa(r,a.deps))return void(i.memoizedState=Pa(t,n,s,r))}aa.flags|=e,i.memoizedState=Pa(1|t,n,s,r)}function Da(e,t){return Ba(8390656,8,e,t)}function Ua(e,t){return La(2048,8,e,t)}function Na(e,t){return La(4,2,e,t)}function Fa(e,t){return La(4,4,e,t)}function Oa(e,t){return"function"===typeof t?(e=e(),t(e),function(){t(null)}):null!==t&&void 0!==t?(e=e(),t.current=e,function(){t.current=null}):void 0}function ka(e,t,n){return n=null!==n&&void 0!==n?n.concat([e]):null,La(4,4,Oa.bind(null,t,e),n)}function Ha(){}function za(e,t){var n=ya();t=void 0===t?null:t;var r=n.memoizedState;return null!==r&&null!==t&&fa(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function Ga(e,t){var n=ya();t=void 0===t?null:t;var r=n.memoizedState;return null!==r&&null!==t&&fa(t,r[1])?r[0]:(e=e(),n.memoizedState=[e,t],e)}function Va(e,t,n){return 0===(21&sa)?(e.baseState&&(e.baseState=!1,_o=!0),e.memoizedState=n):(or(n,t)||(n=mt(),aa.lanes|=n,Nl|=n,e.baseState=!0),t)}function Wa(e,t){var n=_t;_t=0!==n&&4>n?n:4,e(!0);var r=ia.transition;ia.transition={};try{e(!1),t()}finally{_t=n,ia.transition=r}}function ja(){return ya().memoizedState}function Xa(e,t,n){var r=tu(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},Ya(e))Ka(t,n);else if(null!==(n=Ls(e,t,n,r))){nu(n,e,r,eu()),qa(n,t,r)}}function Ja(e,t,n){var r=tu(e),i={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(Ya(e))Ka(t,i);else{var s=e.alternate;if(0===e.lanes&&(null===s||0===s.lanes)&&null!==(s=t.lastRenderedReducer))try{var a=t.lastRenderedState,o=s(a,n);if(i.hasEagerState=!0,i.eagerState=o,or(o,a)){var l=t.interleaved;return null===l?(i.next=i,Bs(t)):(i.next=l.next,l.next=i),void(t.interleaved=i)}}catch(u){}null!==(n=Ls(e,t,i,r))&&(nu(n,e,r,i=eu()),qa(n,t,r))}}function Ya(e){var t=e.alternate;return e===aa||null!==t&&t===aa}function Ka(e,t){ca=ua=!0;var n=e.pending;null===n?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function qa(e,t,n){if(0!==(4194240&n)){var r=t.lanes;n|=r&=e.pendingLanes,t.lanes=n,yt(e,n)}}var Qa={readContext:Ps,useCallback:pa,useContext:pa,useEffect:pa,useImperativeHandle:pa,useInsertionEffect:pa,useLayoutEffect:pa,useMemo:pa,useReducer:pa,useRef:pa,useState:pa,useDebugValue:pa,useDeferredValue:pa,useTransition:pa,useMutableSource:pa,useSyncExternalStore:pa,useId:pa,unstable_isNewReconciler:!1},Za={readContext:Ps,useCallback:function(e,t){return va().memoizedState=[e,void 0===t?null:t],e},useContext:Ps,useEffect:Da,useImperativeHandle:function(e,t,n){return n=null!==n&&void 0!==n?n.concat([e]):null,Ba(4194308,4,Oa.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Ba(4194308,4,e,t)},useInsertionEffect:function(e,t){return Ba(4,2,e,t)},useMemo:function(e,t){var n=va();return t=void 0===t?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=va();return t=void 0!==n?n(t):t,r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=Xa.bind(null,aa,e),[r.memoizedState,e]},useRef:function(e){return e={current:e},va().memoizedState=e},useState:Ra,useDebugValue:Ha,useDeferredValue:function(e){return va().memoizedState=e},useTransition:function(){var e=Ra(!1),t=e[0];return e=Wa.bind(null,e[1]),va().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=aa,i=va();if(is){if(void 0===n)throw Error(s(407));n=n()}else{if(n=t(),null===Rl)throw Error(s(349));0!==(30&sa)||Sa(r,t,n)}i.memoizedState=n;var a={value:n,getSnapshot:t};return i.queue=a,Da(Ea.bind(null,r,a,e),[e]),r.flags|=2048,Pa(9,wa.bind(null,r,a,n,t),void 0,null),n},useId:function(){var e=va(),t=Rl.identifierPrefix;if(is){var n=Qi;t=":"+t+"R"+(n=(qi&~(1<<32-at(qi)-1)).toString(32)+n),0<(n=ha++)&&(t+="H"+n.toString(32)),t+=":"}else t=":"+t+"r"+(n=da++).toString(32)+":";return e.memoizedState=t},unstable_isNewReconciler:!1},$a={readContext:Ps,useCallback:za,useContext:Ps,useEffect:Ua,useImperativeHandle:ka,useInsertionEffect:Na,useLayoutEffect:Fa,useMemo:Ga,useReducer:xa,useRef:Ia,useState:function(){return xa(_a)},useDebugValue:Ha,useDeferredValue:function(e){return Va(ya(),oa.memoizedState,e)},useTransition:function(){return[xa(_a)[0],ya().memoizedState]},useMutableSource:Ma,useSyncExternalStore:ba,useId:ja,unstable_isNewReconciler:!1},eo={readContext:Ps,useCallback:za,useContext:Ps,useEffect:Ua,useImperativeHandle:ka,useInsertionEffect:Na,useLayoutEffect:Fa,useMemo:Ga,useReducer:Aa,useRef:Ia,useState:function(){return Aa(_a)},useDebugValue:Ha,useDeferredValue:function(e){var t=ya();return null===oa?t.memoizedState=e:Va(t,oa.memoizedState,e)},useTransition:function(){return[Aa(_a)[0],ya().memoizedState]},useMutableSource:Ma,useSyncExternalStore:ba,useId:ja,unstable_isNewReconciler:!1};function to(e,t){if(e&&e.defaultProps){for(var n in t=F({},t),e=e.defaultProps)void 0===t[n]&&(t[n]=e[n]);return t}return t}function no(e,t,n,r){n=null===(n=n(r,t=e.memoizedState))||void 0===n?t:F({},t,n),e.memoizedState=n,0===e.lanes&&(e.updateQueue.baseState=n)}var ro={isMounted:function(e){return!!(e=e._reactInternals)&&Ge(e)===e},enqueueSetState:function(e,t,n){e=e._reactInternals;var r=eu(),i=tu(e),s=Os(r,i);s.payload=t,void 0!==n&&null!==n&&(s.callback=n),null!==(t=ks(e,s,i))&&(nu(t,e,i,r),Hs(t,e,i))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=eu(),i=tu(e),s=Os(r,i);s.tag=1,s.payload=t,void 0!==n&&null!==n&&(s.callback=n),null!==(t=ks(e,s,i))&&(nu(t,e,i,r),Hs(t,e,i))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=eu(),r=tu(e),i=Os(n,r);i.tag=2,void 0!==t&&null!==t&&(i.callback=t),null!==(t=ks(e,i,r))&&(nu(t,e,r,n),Hs(t,e,r))}};function io(e,t,n,r,i,s,a){return"function"===typeof(e=e.stateNode).shouldComponentUpdate?e.shouldComponentUpdate(r,s,a):!t.prototype||!t.prototype.isPureReactComponent||(!lr(n,r)||!lr(i,s))}function so(e,t,n){var r=!1,i=Ti,s=t.contextType;return"object"===typeof s&&null!==s?s=Ps(s):(i=Bi(t)?Pi:Ci.current,s=(r=null!==(r=t.contextTypes)&&void 0!==r)?Ii(e,i):Ti),t=new t(n,s),e.memoizedState=null!==t.state&&void 0!==t.state?t.state:null,t.updater=ro,e.stateNode=t,t._reactInternals=e,r&&((e=e.stateNode).__reactInternalMemoizedUnmaskedChildContext=i,e.__reactInternalMemoizedMaskedChildContext=s),t}function ao(e,t,n,r){e=t.state,"function"===typeof t.componentWillReceiveProps&&t.componentWillReceiveProps(n,r),"function"===typeof t.UNSAFE_componentWillReceiveProps&&t.UNSAFE_componentWillReceiveProps(n,r),t.state!==e&&ro.enqueueReplaceState(t,t.state,null)}function oo(e,t,n,r){var i=e.stateNode;i.props=n,i.state=e.memoizedState,i.refs={},Ns(e);var s=t.contextType;"object"===typeof s&&null!==s?i.context=Ps(s):(s=Bi(t)?Pi:Ci.current,i.context=Ii(e,s)),i.state=e.memoizedState,"function"===typeof(s=t.getDerivedStateFromProps)&&(no(e,t,s,n),i.state=e.memoizedState),"function"===typeof t.getDerivedStateFromProps||"function"===typeof i.getSnapshotBeforeUpdate||"function"!==typeof i.UNSAFE_componentWillMount&&"function"!==typeof i.componentWillMount||(t=i.state,"function"===typeof i.componentWillMount&&i.componentWillMount(),"function"===typeof i.UNSAFE_componentWillMount&&i.UNSAFE_componentWillMount(),t!==i.state&&ro.enqueueReplaceState(i,i.state,null),Gs(e,n,i,r),i.state=e.memoizedState),"function"===typeof i.componentDidMount&&(e.flags|=4194308)}function lo(e,t){try{var n="",r=t;do{n+=z(r),r=r.return}while(r);var i=n}catch(s){i="\nError generating stack: "+s.message+"\n"+s.stack}return{value:e,source:t,stack:i,digest:null}}function uo(e,t,n){return{value:e,source:null,stack:null!=n?n:null,digest:null!=t?t:null}}function co(e,t){try{console.error(t.value)}catch(n){setTimeout((function(){throw n}))}}var ho="function"===typeof WeakMap?WeakMap:Map;function po(e,t,n){(n=Os(-1,n)).tag=3,n.payload={element:null};var r=t.value;return n.callback=function(){Wl||(Wl=!0,jl=r),co(0,t)},n}function fo(e,t,n){(n=Os(-1,n)).tag=3;var r=e.type.getDerivedStateFromError;if("function"===typeof r){var i=t.value;n.payload=function(){return r(i)},n.callback=function(){co(0,t)}}var s=e.stateNode;return null!==s&&"function"===typeof s.componentDidCatch&&(n.callback=function(){co(0,t),"function"!==typeof r&&(null===Xl?Xl=new Set([this]):Xl.add(this));var e=t.stack;this.componentDidCatch(t.value,{componentStack:null!==e?e:""})}),n}function mo(e,t,n){var r=e.pingCache;if(null===r){r=e.pingCache=new ho;var i=new Set;r.set(t,i)}else void 0===(i=r.get(t))&&(i=new Set,r.set(t,i));i.has(n)||(i.add(n),e=wu.bind(null,e,t,n),t.then(e,e))}function go(e){do{var t;if((t=13===e.tag)&&(t=null===(t=e.memoizedState)||null!==t.dehydrated),t)return e;e=e.return}while(null!==e);return null}function vo(e,t,n,r,i){return 0===(1&e.mode)?(e===t?e.flags|=65536:(e.flags|=128,n.flags|=131072,n.flags&=-52805,1===n.tag&&(null===n.alternate?n.tag=17:((t=Os(-1,1)).tag=2,ks(n,t,1))),n.lanes|=1),e):(e.flags|=65536,e.lanes=i,e)}var yo=x.ReactCurrentOwner,_o=!1;function xo(e,t,n,r){t.child=null===e?As(t,null,n,r):xs(t,e.child,n,r)}function Ao(e,t,n,r,i){n=n.render;var s=t.ref;return Rs(t,i),r=ma(e,t,n,r,s,i),n=ga(),null===e||_o?(is&&n&&es(t),t.flags|=1,xo(e,t,r,i),t.child):(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~i,Wo(e,t,i))}function Mo(e,t,n,r,i){if(null===e){var s=n.type;return"function"!==typeof s||Bu(s)||void 0!==s.defaultProps||null!==n.compare||void 0!==n.defaultProps?((e=Du(n.type,null,r,t,t.mode,i)).ref=t.ref,e.return=t,t.child=e):(t.tag=15,t.type=s,bo(e,t,s,r,i))}if(s=e.child,0===(e.lanes&i)){var a=s.memoizedProps;if((n=null!==(n=n.compare)?n:lr)(a,r)&&e.ref===t.ref)return Wo(e,t,i)}return t.flags|=1,(e=Lu(s,r)).ref=t.ref,e.return=t,t.child=e}function bo(e,t,n,r,i){if(null!==e){var s=e.memoizedProps;if(lr(s,r)&&e.ref===t.ref){if(_o=!1,t.pendingProps=r=s,0===(e.lanes&i))return t.lanes=e.lanes,Wo(e,t,i);0!==(131072&e.flags)&&(_o=!0)}}return Eo(e,t,n,r,i)}function So(e,t,n){var r=t.pendingProps,i=r.children,s=null!==e?e.memoizedState:null;if("hidden"===r.mode)if(0===(1&t.mode))t.memoizedState={baseLanes:0,cachePool:null,transitions:null},Ei(Ll,Bl),Bl|=n;else{if(0===(1073741824&n))return e=null!==s?s.baseLanes|n:n,t.lanes=t.childLanes=1073741824,t.memoizedState={baseLanes:e,cachePool:null,transitions:null},t.updateQueue=null,Ei(Ll,Bl),Bl|=e,null;t.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=null!==s?s.baseLanes:n,Ei(Ll,Bl),Bl|=r}else null!==s?(r=s.baseLanes|n,t.memoizedState=null):r=n,Ei(Ll,Bl),Bl|=r;return xo(e,t,i,n),t.child}function wo(e,t){var n=t.ref;(null===e&&null!==n||null!==e&&e.ref!==n)&&(t.flags|=512,t.flags|=2097152)}function Eo(e,t,n,r,i){var s=Bi(n)?Pi:Ci.current;return s=Ii(t,s),Rs(t,i),n=ma(e,t,n,r,s,i),r=ga(),null===e||_o?(is&&r&&es(t),t.flags|=1,xo(e,t,n,i),t.child):(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~i,Wo(e,t,i))}function To(e,t,n,r,i){if(Bi(n)){var s=!0;Ni(t)}else s=!1;if(Rs(t,i),null===t.stateNode)Vo(e,t),so(t,n,r),oo(t,n,r,i),r=!0;else if(null===e){var a=t.stateNode,o=t.memoizedProps;a.props=o;var l=a.context,u=n.contextType;"object"===typeof u&&null!==u?u=Ps(u):u=Ii(t,u=Bi(n)?Pi:Ci.current);var c=n.getDerivedStateFromProps,h="function"===typeof c||"function"===typeof a.getSnapshotBeforeUpdate;h||"function"!==typeof a.UNSAFE_componentWillReceiveProps&&"function"!==typeof a.componentWillReceiveProps||(o!==r||l!==u)&&ao(t,a,r,u),Us=!1;var d=t.memoizedState;a.state=d,Gs(t,r,a,i),l=t.memoizedState,o!==r||d!==l||Ri.current||Us?("function"===typeof c&&(no(t,n,c,r),l=t.memoizedState),(o=Us||io(t,n,o,r,d,l,u))?(h||"function"!==typeof a.UNSAFE_componentWillMount&&"function"!==typeof a.componentWillMount||("function"===typeof a.componentWillMount&&a.componentWillMount(),"function"===typeof a.UNSAFE_componentWillMount&&a.UNSAFE_componentWillMount()),"function"===typeof a.componentDidMount&&(t.flags|=4194308)):("function"===typeof a.componentDidMount&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=l),a.props=r,a.state=l,a.context=u,r=o):("function"===typeof a.componentDidMount&&(t.flags|=4194308),r=!1)}else{a=t.stateNode,Fs(e,t),o=t.memoizedProps,u=t.type===t.elementType?o:to(t.type,o),a.props=u,h=t.pendingProps,d=a.context,"object"===typeof(l=n.contextType)&&null!==l?l=Ps(l):l=Ii(t,l=Bi(n)?Pi:Ci.current);var p=n.getDerivedStateFromProps;(c="function"===typeof p||"function"===typeof a.getSnapshotBeforeUpdate)||"function"!==typeof a.UNSAFE_componentWillReceiveProps&&"function"!==typeof a.componentWillReceiveProps||(o!==h||d!==l)&&ao(t,a,r,l),Us=!1,d=t.memoizedState,a.state=d,Gs(t,r,a,i);var f=t.memoizedState;o!==h||d!==f||Ri.current||Us?("function"===typeof p&&(no(t,n,p,r),f=t.memoizedState),(u=Us||io(t,n,u,r,d,f,l)||!1)?(c||"function"!==typeof a.UNSAFE_componentWillUpdate&&"function"!==typeof a.componentWillUpdate||("function"===typeof a.componentWillUpdate&&a.componentWillUpdate(r,f,l),"function"===typeof a.UNSAFE_componentWillUpdate&&a.UNSAFE_componentWillUpdate(r,f,l)),"function"===typeof a.componentDidUpdate&&(t.flags|=4),"function"===typeof a.getSnapshotBeforeUpdate&&(t.flags|=1024)):("function"!==typeof a.componentDidUpdate||o===e.memoizedProps&&d===e.memoizedState||(t.flags|=4),"function"!==typeof a.getSnapshotBeforeUpdate||o===e.memoizedProps&&d===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=f),a.props=r,a.state=f,a.context=l,r=u):("function"!==typeof a.componentDidUpdate||o===e.memoizedProps&&d===e.memoizedState||(t.flags|=4),"function"!==typeof a.getSnapshotBeforeUpdate||o===e.memoizedProps&&d===e.memoizedState||(t.flags|=1024),r=!1)}return Co(e,t,n,r,s,i)}function Co(e,t,n,r,i,s){wo(e,t);var a=0!==(128&t.flags);if(!r&&!a)return i&&Fi(t,n,!1),Wo(e,t,s);r=t.stateNode,yo.current=t;var o=a&&"function"!==typeof n.getDerivedStateFromError?null:r.render();return t.flags|=1,null!==e&&a?(t.child=xs(t,e.child,null,s),t.child=xs(t,null,o,s)):xo(e,t,o,s),t.memoizedState=r.state,i&&Fi(t,n,!0),t.child}function Ro(e){var t=e.stateNode;t.pendingContext?Di(0,t.pendingContext,t.pendingContext!==t.context):t.context&&Di(0,t.context,!1),Ks(e,t.containerInfo)}function Po(e,t,n,r,i){return ps(),fs(i),t.flags|=256,xo(e,t,n,r),t.child}var Io,Bo,Lo,Do,Uo={dehydrated:null,treeContext:null,retryLane:0};function No(e){return{baseLanes:e,cachePool:null,transitions:null}}function Fo(e,t,n){var r,i=t.pendingProps,a=$s.current,o=!1,l=0!==(128&t.flags);if((r=l)||(r=(null===e||null!==e.memoizedState)&&0!==(2&a)),r?(o=!0,t.flags&=-129):null!==e&&null===e.memoizedState||(a|=1),Ei($s,1&a),null===e)return us(t),null!==(e=t.memoizedState)&&null!==(e=e.dehydrated)?(0===(1&t.mode)?t.lanes=1:"$!"===e.data?t.lanes=8:t.lanes=1073741824,null):(l=i.children,e=i.fallback,o?(i=t.mode,o=t.child,l={mode:"hidden",children:l},0===(1&i)&&null!==o?(o.childLanes=0,o.pendingProps=l):o=Nu(l,i,0,null),e=Uu(e,i,n,null),o.return=t,e.return=t,o.sibling=e,t.child=o,t.child.memoizedState=No(n),t.memoizedState=Uo,e):Oo(t,l));if(null!==(a=e.memoizedState)&&null!==(r=a.dehydrated))return function(e,t,n,r,i,a,o){if(n)return 256&t.flags?(t.flags&=-257,ko(e,t,o,r=uo(Error(s(422))))):null!==t.memoizedState?(t.child=e.child,t.flags|=128,null):(a=r.fallback,i=t.mode,r=Nu({mode:"visible",children:r.children},i,0,null),(a=Uu(a,i,o,null)).flags|=2,r.return=t,a.return=t,r.sibling=a,t.child=r,0!==(1&t.mode)&&xs(t,e.child,null,o),t.child.memoizedState=No(o),t.memoizedState=Uo,a);if(0===(1&t.mode))return ko(e,t,o,null);if("$!"===i.data){if(r=i.nextSibling&&i.nextSibling.dataset)var l=r.dgst;return r=l,ko(e,t,o,r=uo(a=Error(s(419)),r,void 0))}if(l=0!==(o&e.childLanes),_o||l){if(null!==(r=Rl)){switch(o&-o){case 4:i=2;break;case 16:i=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:i=32;break;case 536870912:i=268435456;break;default:i=0}0!==(i=0!==(i&(r.suspendedLanes|o))?0:i)&&i!==a.retryLane&&(a.retryLane=i,Ds(e,i),nu(r,e,i,-1))}return mu(),ko(e,t,o,r=uo(Error(s(421))))}return"$?"===i.data?(t.flags|=128,t.child=e.child,t=Tu.bind(null,e),i._reactRetry=t,null):(e=a.treeContext,rs=ui(i.nextSibling),ns=t,is=!0,ss=null,null!==e&&(Ji[Yi++]=qi,Ji[Yi++]=Qi,Ji[Yi++]=Ki,qi=e.id,Qi=e.overflow,Ki=t),t=Oo(t,r.children),t.flags|=4096,t)}(e,t,l,i,r,a,n);if(o){o=i.fallback,l=t.mode,r=(a=e.child).sibling;var u={mode:"hidden",children:i.children};return 0===(1&l)&&t.child!==a?((i=t.child).childLanes=0,i.pendingProps=u,t.deletions=null):(i=Lu(a,u)).subtreeFlags=14680064&a.subtreeFlags,null!==r?o=Lu(r,o):(o=Uu(o,l,n,null)).flags|=2,o.return=t,i.return=t,i.sibling=o,t.child=i,i=o,o=t.child,l=null===(l=e.child.memoizedState)?No(n):{baseLanes:l.baseLanes|n,cachePool:null,transitions:l.transitions},o.memoizedState=l,o.childLanes=e.childLanes&~n,t.memoizedState=Uo,i}return e=(o=e.child).sibling,i=Lu(o,{mode:"visible",children:i.children}),0===(1&t.mode)&&(i.lanes=n),i.return=t,i.sibling=null,null!==e&&(null===(n=t.deletions)?(t.deletions=[e],t.flags|=16):n.push(e)),t.child=i,t.memoizedState=null,i}function Oo(e,t){return(t=Nu({mode:"visible",children:t},e.mode,0,null)).return=e,e.child=t}function ko(e,t,n,r){return null!==r&&fs(r),xs(t,e.child,null,n),(e=Oo(t,t.pendingProps.children)).flags|=2,t.memoizedState=null,e}function Ho(e,t,n){e.lanes|=t;var r=e.alternate;null!==r&&(r.lanes|=t),Cs(e.return,t,n)}function zo(e,t,n,r,i){var s=e.memoizedState;null===s?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:i}:(s.isBackwards=t,s.rendering=null,s.renderingStartTime=0,s.last=r,s.tail=n,s.tailMode=i)}function Go(e,t,n){var r=t.pendingProps,i=r.revealOrder,s=r.tail;if(xo(e,t,r.children,n),0!==(2&(r=$s.current)))r=1&r|2,t.flags|=128;else{if(null!==e&&0!==(128&e.flags))e:for(e=t.child;null!==e;){if(13===e.tag)null!==e.memoizedState&&Ho(e,n,t);else if(19===e.tag)Ho(e,n,t);else if(null!==e.child){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;null===e.sibling;){if(null===e.return||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}r&=1}if(Ei($s,r),0===(1&t.mode))t.memoizedState=null;else switch(i){case"forwards":for(n=t.child,i=null;null!==n;)null!==(e=n.alternate)&&null===ea(e)&&(i=n),n=n.sibling;null===(n=i)?(i=t.child,t.child=null):(i=n.sibling,n.sibling=null),zo(t,!1,i,n,s);break;case"backwards":for(n=null,i=t.child,t.child=null;null!==i;){if(null!==(e=i.alternate)&&null===ea(e)){t.child=i;break}e=i.sibling,i.sibling=n,n=i,i=e}zo(t,!0,n,null,s);break;case"together":zo(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function Vo(e,t){0===(1&t.mode)&&null!==e&&(e.alternate=null,t.alternate=null,t.flags|=2)}function Wo(e,t,n){if(null!==e&&(t.dependencies=e.dependencies),Nl|=t.lanes,0===(n&t.childLanes))return null;if(null!==e&&t.child!==e.child)throw Error(s(153));if(null!==t.child){for(n=Lu(e=t.child,e.pendingProps),t.child=n,n.return=t;null!==e.sibling;)e=e.sibling,(n=n.sibling=Lu(e,e.pendingProps)).return=t;n.sibling=null}return t.child}function jo(e,t){if(!is)switch(e.tailMode){case"hidden":t=e.tail;for(var n=null;null!==t;)null!==t.alternate&&(n=t),t=t.sibling;null===n?e.tail=null:n.sibling=null;break;case"collapsed":n=e.tail;for(var r=null;null!==n;)null!==n.alternate&&(r=n),n=n.sibling;null===r?t||null===e.tail?e.tail=null:e.tail.sibling=null:r.sibling=null}}function Xo(e){var t=null!==e.alternate&&e.alternate.child===e.child,n=0,r=0;if(t)for(var i=e.child;null!==i;)n|=i.lanes|i.childLanes,r|=14680064&i.subtreeFlags,r|=14680064&i.flags,i.return=e,i=i.sibling;else for(i=e.child;null!==i;)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 Jo(e,t,n){var r=t.pendingProps;switch(ts(t),t.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Xo(t),null;case 1:case 17:return Bi(t.type)&&Li(),Xo(t),null;case 3:return r=t.stateNode,qs(),wi(Ri),wi(Ci),na(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),null!==e&&null!==e.child||(hs(t)?t.flags|=4:null===e||e.memoizedState.isDehydrated&&0===(256&t.flags)||(t.flags|=1024,null!==ss&&(au(ss),ss=null))),Bo(e,t),Xo(t),null;case 5:Zs(t);var i=Ys(Js.current);if(n=t.type,null!==e&&null!=t.stateNode)Lo(e,t,n,r,i),e.ref!==t.ref&&(t.flags|=512,t.flags|=2097152);else{if(!r){if(null===t.stateNode)throw Error(s(166));return Xo(t),null}if(e=Ys(js.current),hs(t)){r=t.stateNode,n=t.type;var a=t.memoizedProps;switch(r[di]=t,r[pi]=a,e=0!==(1&t.mode),n){case"dialog":kr("cancel",r),kr("close",r);break;case"iframe":case"object":case"embed":kr("load",r);break;case"video":case"audio":for(i=0;i<Ur.length;i++)kr(Ur[i],r);break;case"source":kr("error",r);break;case"img":case"image":case"link":kr("error",r),kr("load",r);break;case"details":kr("toggle",r);break;case"input":q(r,a),kr("invalid",r);break;case"select":r._wrapperState={wasMultiple:!!a.multiple},kr("invalid",r);break;case"textarea":ie(r,a),kr("invalid",r)}for(var l in ye(n,a),i=null,a)if(a.hasOwnProperty(l)){var u=a[l];"children"===l?"string"===typeof u?r.textContent!==u&&(!0!==a.suppressHydrationWarning&&Zr(r.textContent,u,e),i=["children",u]):"number"===typeof u&&r.textContent!==""+u&&(!0!==a.suppressHydrationWarning&&Zr(r.textContent,u,e),i=["children",""+u]):o.hasOwnProperty(l)&&null!=u&&"onScroll"===l&&kr("scroll",r)}switch(n){case"input":X(r),$(r,a,!0);break;case"textarea":X(r),ae(r);break;case"select":case"option":break;default:"function"===typeof a.onClick&&(r.onclick=$r)}r=i,t.updateQueue=r,null!==r&&(t.flags|=4)}else{l=9===i.nodeType?i:i.ownerDocument,"http://www.w3.org/1999/xhtml"===e&&(e=oe(n)),"http://www.w3.org/1999/xhtml"===e?"script"===n?((e=l.createElement("div")).innerHTML="<script><\/script>",e=e.removeChild(e.firstChild)):"string"===typeof r.is?e=l.createElement(n,{is:r.is}):(e=l.createElement(n),"select"===n&&(l=e,r.multiple?l.multiple=!0:r.size&&(l.size=r.size))):e=l.createElementNS(e,n),e[di]=t,e[pi]=r,Io(e,t,!1,!1),t.stateNode=e;e:{switch(l=_e(n,r),n){case"dialog":kr("cancel",e),kr("close",e),i=r;break;case"iframe":case"object":case"embed":kr("load",e),i=r;break;case"video":case"audio":for(i=0;i<Ur.length;i++)kr(Ur[i],e);i=r;break;case"source":kr("error",e),i=r;break;case"img":case"image":case"link":kr("error",e),kr("load",e),i=r;break;case"details":kr("toggle",e),i=r;break;case"input":q(e,r),i=K(e,r),kr("invalid",e);break;case"option":default:i=r;break;case"select":e._wrapperState={wasMultiple:!!r.multiple},i=F({},r,{value:void 0}),kr("invalid",e);break;case"textarea":ie(e,r),i=re(e,r),kr("invalid",e)}for(a in ye(n,i),u=i)if(u.hasOwnProperty(a)){var c=u[a];"style"===a?ge(e,c):"dangerouslySetInnerHTML"===a?null!=(c=c?c.__html:void 0)&&he(e,c):"children"===a?"string"===typeof c?("textarea"!==n||""!==c)&&de(e,c):"number"===typeof c&&de(e,""+c):"suppressContentEditableWarning"!==a&&"suppressHydrationWarning"!==a&&"autoFocus"!==a&&(o.hasOwnProperty(a)?null!=c&&"onScroll"===a&&kr("scroll",e):null!=c&&_(e,a,c,l))}switch(n){case"input":X(e),$(e,r,!1);break;case"textarea":X(e),ae(e);break;case"option":null!=r.value&&e.setAttribute("value",""+W(r.value));break;case"select":e.multiple=!!r.multiple,null!=(a=r.value)?ne(e,!!r.multiple,a,!1):null!=r.defaultValue&&ne(e,!!r.multiple,r.defaultValue,!0);break;default:"function"===typeof i.onClick&&(e.onclick=$r)}switch(n){case"button":case"input":case"select":case"textarea":r=!!r.autoFocus;break e;case"img":r=!0;break e;default:r=!1}}r&&(t.flags|=4)}null!==t.ref&&(t.flags|=512,t.flags|=2097152)}return Xo(t),null;case 6:if(e&&null!=t.stateNode)Do(e,t,e.memoizedProps,r);else{if("string"!==typeof r&&null===t.stateNode)throw Error(s(166));if(n=Ys(Js.current),Ys(js.current),hs(t)){if(r=t.stateNode,n=t.memoizedProps,r[di]=t,(a=r.nodeValue!==n)&&null!==(e=ns))switch(e.tag){case 3:Zr(r.nodeValue,n,0!==(1&e.mode));break;case 5:!0!==e.memoizedProps.suppressHydrationWarning&&Zr(r.nodeValue,n,0!==(1&e.mode))}a&&(t.flags|=4)}else(r=(9===n.nodeType?n:n.ownerDocument).createTextNode(r))[di]=t,t.stateNode=r}return Xo(t),null;case 13:if(wi($s),r=t.memoizedState,null===e||null!==e.memoizedState&&null!==e.memoizedState.dehydrated){if(is&&null!==rs&&0!==(1&t.mode)&&0===(128&t.flags))ds(),ps(),t.flags|=98560,a=!1;else if(a=hs(t),null!==r&&null!==r.dehydrated){if(null===e){if(!a)throw Error(s(318));if(!(a=null!==(a=t.memoizedState)?a.dehydrated:null))throw Error(s(317));a[di]=t}else ps(),0===(128&t.flags)&&(t.memoizedState=null),t.flags|=4;Xo(t),a=!1}else null!==ss&&(au(ss),ss=null),a=!0;if(!a)return 65536&t.flags?t:null}return 0!==(128&t.flags)?(t.lanes=n,t):((r=null!==r)!==(null!==e&&null!==e.memoizedState)&&r&&(t.child.flags|=8192,0!==(1&t.mode)&&(null===e||0!==(1&$s.current)?0===Dl&&(Dl=3):mu())),null!==t.updateQueue&&(t.flags|=4),Xo(t),null);case 4:return qs(),Bo(e,t),null===e&&Gr(t.stateNode.containerInfo),Xo(t),null;case 10:return Ts(t.type._context),Xo(t),null;case 19:if(wi($s),null===(a=t.memoizedState))return Xo(t),null;if(r=0!==(128&t.flags),null===(l=a.rendering))if(r)jo(a,!1);else{if(0!==Dl||null!==e&&0!==(128&e.flags))for(e=t.child;null!==e;){if(null!==(l=ea(e))){for(t.flags|=128,jo(a,!1),null!==(r=l.updateQueue)&&(t.updateQueue=r,t.flags|=4),t.subtreeFlags=0,r=n,n=t.child;null!==n;)e=r,(a=n).flags&=14680066,null===(l=a.alternate)?(a.childLanes=0,a.lanes=e,a.child=null,a.subtreeFlags=0,a.memoizedProps=null,a.memoizedState=null,a.updateQueue=null,a.dependencies=null,a.stateNode=null):(a.childLanes=l.childLanes,a.lanes=l.lanes,a.child=l.child,a.subtreeFlags=0,a.deletions=null,a.memoizedProps=l.memoizedProps,a.memoizedState=l.memoizedState,a.updateQueue=l.updateQueue,a.type=l.type,e=l.dependencies,a.dependencies=null===e?null:{lanes:e.lanes,firstContext:e.firstContext}),n=n.sibling;return Ei($s,1&$s.current|2),t.child}e=e.sibling}null!==a.tail&&Qe()>Gl&&(t.flags|=128,r=!0,jo(a,!1),t.lanes=4194304)}else{if(!r)if(null!==(e=ea(l))){if(t.flags|=128,r=!0,null!==(n=e.updateQueue)&&(t.updateQueue=n,t.flags|=4),jo(a,!0),null===a.tail&&"hidden"===a.tailMode&&!l.alternate&&!is)return Xo(t),null}else 2*Qe()-a.renderingStartTime>Gl&&1073741824!==n&&(t.flags|=128,r=!0,jo(a,!1),t.lanes=4194304);a.isBackwards?(l.sibling=t.child,t.child=l):(null!==(n=a.last)?n.sibling=l:t.child=l,a.last=l)}return null!==a.tail?(t=a.tail,a.rendering=t,a.tail=t.sibling,a.renderingStartTime=Qe(),t.sibling=null,n=$s.current,Ei($s,r?1&n|2:1&n),t):(Xo(t),null);case 22:case 23:return hu(),r=null!==t.memoizedState,null!==e&&null!==e.memoizedState!==r&&(t.flags|=8192),r&&0!==(1&t.mode)?0!==(1073741824&Bl)&&(Xo(t),6&t.subtreeFlags&&(t.flags|=8192)):Xo(t),null;case 24:case 25:return null}throw Error(s(156,t.tag))}function Yo(e,t){switch(ts(t),t.tag){case 1:return Bi(t.type)&&Li(),65536&(e=t.flags)?(t.flags=-65537&e|128,t):null;case 3:return qs(),wi(Ri),wi(Ci),na(),0!==(65536&(e=t.flags))&&0===(128&e)?(t.flags=-65537&e|128,t):null;case 5:return Zs(t),null;case 13:if(wi($s),null!==(e=t.memoizedState)&&null!==e.dehydrated){if(null===t.alternate)throw Error(s(340));ps()}return 65536&(e=t.flags)?(t.flags=-65537&e|128,t):null;case 19:return wi($s),null;case 4:return qs(),null;case 10:return Ts(t.type._context),null;case 22:case 23:return hu(),null;default:return null}}Io=function(e,t){for(var n=t.child;null!==n;){if(5===n.tag||6===n.tag)e.appendChild(n.stateNode);else if(4!==n.tag&&null!==n.child){n.child.return=n,n=n.child;continue}if(n===t)break;for(;null===n.sibling;){if(null===n.return||n.return===t)return;n=n.return}n.sibling.return=n.return,n=n.sibling}},Bo=function(){},Lo=function(e,t,n,r){var i=e.memoizedProps;if(i!==r){e=t.stateNode,Ys(js.current);var s,a=null;switch(n){case"input":i=K(e,i),r=K(e,r),a=[];break;case"select":i=F({},i,{value:void 0}),r=F({},r,{value:void 0}),a=[];break;case"textarea":i=re(e,i),r=re(e,r),a=[];break;default:"function"!==typeof i.onClick&&"function"===typeof r.onClick&&(e.onclick=$r)}for(c in ye(n,r),n=null,i)if(!r.hasOwnProperty(c)&&i.hasOwnProperty(c)&&null!=i[c])if("style"===c){var l=i[c];for(s in l)l.hasOwnProperty(s)&&(n||(n={}),n[s]="")}else"dangerouslySetInnerHTML"!==c&&"children"!==c&&"suppressContentEditableWarning"!==c&&"suppressHydrationWarning"!==c&&"autoFocus"!==c&&(o.hasOwnProperty(c)?a||(a=[]):(a=a||[]).push(c,null));for(c in r){var u=r[c];if(l=null!=i?i[c]:void 0,r.hasOwnProperty(c)&&u!==l&&(null!=u||null!=l))if("style"===c)if(l){for(s in l)!l.hasOwnProperty(s)||u&&u.hasOwnProperty(s)||(n||(n={}),n[s]="");for(s in u)u.hasOwnProperty(s)&&l[s]!==u[s]&&(n||(n={}),n[s]=u[s])}else n||(a||(a=[]),a.push(c,n)),n=u;else"dangerouslySetInnerHTML"===c?(u=u?u.__html:void 0,l=l?l.__html:void 0,null!=u&&l!==u&&(a=a||[]).push(c,u)):"children"===c?"string"!==typeof u&&"number"!==typeof u||(a=a||[]).push(c,""+u):"suppressContentEditableWarning"!==c&&"suppressHydrationWarning"!==c&&(o.hasOwnProperty(c)?(null!=u&&"onScroll"===c&&kr("scroll",e),a||l===u||(a=[])):(a=a||[]).push(c,u))}n&&(a=a||[]).push("style",n);var c=a;(t.updateQueue=c)&&(t.flags|=4)}},Do=function(e,t,n,r){n!==r&&(t.flags|=4)};var Ko=!1,qo=!1,Qo="function"===typeof WeakSet?WeakSet:Set,Zo=null;function $o(e,t){var n=e.ref;if(null!==n)if("function"===typeof n)try{n(null)}catch(r){Su(e,t,r)}else n.current=null}function el(e,t,n){try{n()}catch(r){Su(e,t,r)}}var tl=!1;function nl(e,t,n){var r=t.updateQueue;if(null!==(r=null!==r?r.lastEffect:null)){var i=r=r.next;do{if((i.tag&e)===e){var s=i.destroy;i.destroy=void 0,void 0!==s&&el(t,n,s)}i=i.next}while(i!==r)}}function rl(e,t){if(null!==(t=null!==(t=t.updateQueue)?t.lastEffect:null)){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function il(e){var t=e.ref;if(null!==t){var n=e.stateNode;e.tag,e=n,"function"===typeof t?t(e):t.current=e}}function sl(e){var t=e.alternate;null!==t&&(e.alternate=null,sl(t)),e.child=null,e.deletions=null,e.sibling=null,5===e.tag&&(null!==(t=e.stateNode)&&(delete t[di],delete t[pi],delete t[mi],delete t[gi],delete t[vi])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function al(e){return 5===e.tag||3===e.tag||4===e.tag}function ol(e){e:for(;;){for(;null===e.sibling;){if(null===e.return||al(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;5!==e.tag&&6!==e.tag&&18!==e.tag;){if(2&e.flags)continue e;if(null===e.child||4===e.tag)continue e;e.child.return=e,e=e.child}if(!(2&e.flags))return e.stateNode}}function ll(e,t,n){var r=e.tag;if(5===r||6===r)e=e.stateNode,t?8===n.nodeType?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(8===n.nodeType?(t=n.parentNode).insertBefore(e,n):(t=n).appendChild(e),null!==(n=n._reactRootContainer)&&void 0!==n||null!==t.onclick||(t.onclick=$r));else if(4!==r&&null!==(e=e.child))for(ll(e,t,n),e=e.sibling;null!==e;)ll(e,t,n),e=e.sibling}function ul(e,t,n){var r=e.tag;if(5===r||6===r)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(4!==r&&null!==(e=e.child))for(ul(e,t,n),e=e.sibling;null!==e;)ul(e,t,n),e=e.sibling}var cl=null,hl=!1;function dl(e,t,n){for(n=n.child;null!==n;)pl(e,t,n),n=n.sibling}function pl(e,t,n){if(st&&"function"===typeof st.onCommitFiberUnmount)try{st.onCommitFiberUnmount(it,n)}catch(o){}switch(n.tag){case 5:qo||$o(n,t);case 6:var r=cl,i=hl;cl=null,dl(e,t,n),hl=i,null!==(cl=r)&&(hl?(e=cl,n=n.stateNode,8===e.nodeType?e.parentNode.removeChild(n):e.removeChild(n)):cl.removeChild(n.stateNode));break;case 18:null!==cl&&(hl?(e=cl,n=n.stateNode,8===e.nodeType?li(e.parentNode,n):1===e.nodeType&&li(e,n),Gt(e)):li(cl,n.stateNode));break;case 4:r=cl,i=hl,cl=n.stateNode.containerInfo,hl=!0,dl(e,t,n),cl=r,hl=i;break;case 0:case 11:case 14:case 15:if(!qo&&(null!==(r=n.updateQueue)&&null!==(r=r.lastEffect))){i=r=r.next;do{var s=i,a=s.destroy;s=s.tag,void 0!==a&&(0!==(2&s)||0!==(4&s))&&el(n,t,a),i=i.next}while(i!==r)}dl(e,t,n);break;case 1:if(!qo&&($o(n,t),"function"===typeof(r=n.stateNode).componentWillUnmount))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(o){Su(n,t,o)}dl(e,t,n);break;case 21:dl(e,t,n);break;case 22:1&n.mode?(qo=(r=qo)||null!==n.memoizedState,dl(e,t,n),qo=r):dl(e,t,n);break;default:dl(e,t,n)}}function fl(e){var t=e.updateQueue;if(null!==t){e.updateQueue=null;var n=e.stateNode;null===n&&(n=e.stateNode=new Qo),t.forEach((function(t){var r=Cu.bind(null,e,t);n.has(t)||(n.add(t),t.then(r,r))}))}}function ml(e,t){var n=t.deletions;if(null!==n)for(var r=0;r<n.length;r++){var i=n[r];try{var a=e,o=t,l=o;e:for(;null!==l;){switch(l.tag){case 5:cl=l.stateNode,hl=!1;break e;case 3:case 4:cl=l.stateNode.containerInfo,hl=!0;break e}l=l.return}if(null===cl)throw Error(s(160));pl(a,o,i),cl=null,hl=!1;var u=i.alternate;null!==u&&(u.return=null),i.return=null}catch(c){Su(i,t,c)}}if(12854&t.subtreeFlags)for(t=t.child;null!==t;)gl(t,e),t=t.sibling}function gl(e,t){var n=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(ml(t,e),vl(e),4&r){try{nl(3,e,e.return),rl(3,e)}catch(g){Su(e,e.return,g)}try{nl(5,e,e.return)}catch(g){Su(e,e.return,g)}}break;case 1:ml(t,e),vl(e),512&r&&null!==n&&$o(n,n.return);break;case 5:if(ml(t,e),vl(e),512&r&&null!==n&&$o(n,n.return),32&e.flags){var i=e.stateNode;try{de(i,"")}catch(g){Su(e,e.return,g)}}if(4&r&&null!=(i=e.stateNode)){var a=e.memoizedProps,o=null!==n?n.memoizedProps:a,l=e.type,u=e.updateQueue;if(e.updateQueue=null,null!==u)try{"input"===l&&"radio"===a.type&&null!=a.name&&Q(i,a),_e(l,o);var c=_e(l,a);for(o=0;o<u.length;o+=2){var h=u[o],d=u[o+1];"style"===h?ge(i,d):"dangerouslySetInnerHTML"===h?he(i,d):"children"===h?de(i,d):_(i,h,d,c)}switch(l){case"input":Z(i,a);break;case"textarea":se(i,a);break;case"select":var p=i._wrapperState.wasMultiple;i._wrapperState.wasMultiple=!!a.multiple;var f=a.value;null!=f?ne(i,!!a.multiple,f,!1):p!==!!a.multiple&&(null!=a.defaultValue?ne(i,!!a.multiple,a.defaultValue,!0):ne(i,!!a.multiple,a.multiple?[]:"",!1))}i[pi]=a}catch(g){Su(e,e.return,g)}}break;case 6:if(ml(t,e),vl(e),4&r){if(null===e.stateNode)throw Error(s(162));i=e.stateNode,a=e.memoizedProps;try{i.nodeValue=a}catch(g){Su(e,e.return,g)}}break;case 3:if(ml(t,e),vl(e),4&r&&null!==n&&n.memoizedState.isDehydrated)try{Gt(t.containerInfo)}catch(g){Su(e,e.return,g)}break;case 4:default:ml(t,e),vl(e);break;case 13:ml(t,e),vl(e),8192&(i=e.child).flags&&(a=null!==i.memoizedState,i.stateNode.isHidden=a,!a||null!==i.alternate&&null!==i.alternate.memoizedState||(zl=Qe())),4&r&&fl(e);break;case 22:if(h=null!==n&&null!==n.memoizedState,1&e.mode?(qo=(c=qo)||h,ml(t,e),qo=c):ml(t,e),vl(e),8192&r){if(c=null!==e.memoizedState,(e.stateNode.isHidden=c)&&!h&&0!==(1&e.mode))for(Zo=e,h=e.child;null!==h;){for(d=Zo=h;null!==Zo;){switch(f=(p=Zo).child,p.tag){case 0:case 11:case 14:case 15:nl(4,p,p.return);break;case 1:$o(p,p.return);var m=p.stateNode;if("function"===typeof m.componentWillUnmount){r=p,n=p.return;try{t=r,m.props=t.memoizedProps,m.state=t.memoizedState,m.componentWillUnmount()}catch(g){Su(r,n,g)}}break;case 5:$o(p,p.return);break;case 22:if(null!==p.memoizedState){Al(d);continue}}null!==f?(f.return=p,Zo=f):Al(d)}h=h.sibling}e:for(h=null,d=e;;){if(5===d.tag){if(null===h){h=d;try{i=d.stateNode,c?"function"===typeof(a=i.style).setProperty?a.setProperty("display","none","important"):a.display="none":(l=d.stateNode,o=void 0!==(u=d.memoizedProps.style)&&null!==u&&u.hasOwnProperty("display")?u.display:null,l.style.display=me("display",o))}catch(g){Su(e,e.return,g)}}}else if(6===d.tag){if(null===h)try{d.stateNode.nodeValue=c?"":d.memoizedProps}catch(g){Su(e,e.return,g)}}else if((22!==d.tag&&23!==d.tag||null===d.memoizedState||d===e)&&null!==d.child){d.child.return=d,d=d.child;continue}if(d===e)break e;for(;null===d.sibling;){if(null===d.return||d.return===e)break e;h===d&&(h=null),d=d.return}h===d&&(h=null),d.sibling.return=d.return,d=d.sibling}}break;case 19:ml(t,e),vl(e),4&r&&fl(e);case 21:}}function vl(e){var t=e.flags;if(2&t){try{e:{for(var n=e.return;null!==n;){if(al(n)){var r=n;break e}n=n.return}throw Error(s(160))}switch(r.tag){case 5:var i=r.stateNode;32&r.flags&&(de(i,""),r.flags&=-33),ul(e,ol(e),i);break;case 3:case 4:var a=r.stateNode.containerInfo;ll(e,ol(e),a);break;default:throw Error(s(161))}}catch(o){Su(e,e.return,o)}e.flags&=-3}4096&t&&(e.flags&=-4097)}function yl(e,t,n){Zo=e,_l(e,t,n)}function _l(e,t,n){for(var r=0!==(1&e.mode);null!==Zo;){var i=Zo,s=i.child;if(22===i.tag&&r){var a=null!==i.memoizedState||Ko;if(!a){var o=i.alternate,l=null!==o&&null!==o.memoizedState||qo;o=Ko;var u=qo;if(Ko=a,(qo=l)&&!u)for(Zo=i;null!==Zo;)l=(a=Zo).child,22===a.tag&&null!==a.memoizedState?Ml(i):null!==l?(l.return=a,Zo=l):Ml(i);for(;null!==s;)Zo=s,_l(s,t,n),s=s.sibling;Zo=i,Ko=o,qo=u}xl(e)}else 0!==(8772&i.subtreeFlags)&&null!==s?(s.return=i,Zo=s):xl(e)}}function xl(e){for(;null!==Zo;){var t=Zo;if(0!==(8772&t.flags)){var n=t.alternate;try{if(0!==(8772&t.flags))switch(t.tag){case 0:case 11:case 15:qo||rl(5,t);break;case 1:var r=t.stateNode;if(4&t.flags&&!qo)if(null===n)r.componentDidMount();else{var i=t.elementType===t.type?n.memoizedProps:to(t.type,n.memoizedProps);r.componentDidUpdate(i,n.memoizedState,r.__reactInternalSnapshotBeforeUpdate)}var a=t.updateQueue;null!==a&&Vs(t,a,r);break;case 3:var o=t.updateQueue;if(null!==o){if(n=null,null!==t.child)switch(t.child.tag){case 5:case 1:n=t.child.stateNode}Vs(t,o,n)}break;case 5:var l=t.stateNode;if(null===n&&4&t.flags){n=l;var u=t.memoizedProps;switch(t.type){case"button":case"input":case"select":case"textarea":u.autoFocus&&n.focus();break;case"img":u.src&&(n.src=u.src)}}break;case 6:case 4:case 12:case 19:case 17:case 21:case 22:case 23:case 25:break;case 13:if(null===t.memoizedState){var c=t.alternate;if(null!==c){var h=c.memoizedState;if(null!==h){var d=h.dehydrated;null!==d&&Gt(d)}}}break;default:throw Error(s(163))}qo||512&t.flags&&il(t)}catch(p){Su(t,t.return,p)}}if(t===e){Zo=null;break}if(null!==(n=t.sibling)){n.return=t.return,Zo=n;break}Zo=t.return}}function Al(e){for(;null!==Zo;){var t=Zo;if(t===e){Zo=null;break}var n=t.sibling;if(null!==n){n.return=t.return,Zo=n;break}Zo=t.return}}function Ml(e){for(;null!==Zo;){var t=Zo;try{switch(t.tag){case 0:case 11:case 15:var n=t.return;try{rl(4,t)}catch(l){Su(t,n,l)}break;case 1:var r=t.stateNode;if("function"===typeof r.componentDidMount){var i=t.return;try{r.componentDidMount()}catch(l){Su(t,i,l)}}var s=t.return;try{il(t)}catch(l){Su(t,s,l)}break;case 5:var a=t.return;try{il(t)}catch(l){Su(t,a,l)}}}catch(l){Su(t,t.return,l)}if(t===e){Zo=null;break}var o=t.sibling;if(null!==o){o.return=t.return,Zo=o;break}Zo=t.return}}var bl,Sl=Math.ceil,wl=x.ReactCurrentDispatcher,El=x.ReactCurrentOwner,Tl=x.ReactCurrentBatchConfig,Cl=0,Rl=null,Pl=null,Il=0,Bl=0,Ll=Si(0),Dl=0,Ul=null,Nl=0,Fl=0,Ol=0,kl=null,Hl=null,zl=0,Gl=1/0,Vl=null,Wl=!1,jl=null,Xl=null,Jl=!1,Yl=null,Kl=0,ql=0,Ql=null,Zl=-1,$l=0;function eu(){return 0!==(6&Cl)?Qe():-1!==Zl?Zl:Zl=Qe()}function tu(e){return 0===(1&e.mode)?1:0!==(2&Cl)&&0!==Il?Il&-Il:null!==ms.transition?(0===$l&&($l=mt()),$l):0!==(e=_t)?e:e=void 0===(e=window.event)?16:qt(e.type)}function nu(e,t,n,r){if(50<ql)throw ql=0,Ql=null,Error(s(185));vt(e,n,r),0!==(2&Cl)&&e===Rl||(e===Rl&&(0===(2&Cl)&&(Fl|=n),4===Dl&&ou(e,Il)),ru(e,r),1===n&&0===Cl&&0===(1&t.mode)&&(Gl=Qe()+500,ki&&Gi()))}function ru(e,t){var n=e.callbackNode;!function(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,i=e.expirationTimes,s=e.pendingLanes;0<s;){var a=31-at(s),o=1<<a,l=i[a];-1===l?0!==(o&n)&&0===(o&r)||(i[a]=pt(o,t)):l<=t&&(e.expiredLanes|=o),s&=~o}}(e,t);var r=dt(e,e===Rl?Il:0);if(0===r)null!==n&&Ye(n),e.callbackNode=null,e.callbackPriority=0;else if(t=r&-r,e.callbackPriority!==t){if(null!=n&&Ye(n),1===t)0===e.tag?function(e){ki=!0,zi(e)}(lu.bind(null,e)):zi(lu.bind(null,e)),ai((function(){0===(6&Cl)&&Gi()})),n=null;else{switch(xt(r)){case 1:n=$e;break;case 4:n=et;break;case 16:default:n=tt;break;case 536870912:n=rt}n=Ru(n,iu.bind(null,e))}e.callbackPriority=t,e.callbackNode=n}}function iu(e,t){if(Zl=-1,$l=0,0!==(6&Cl))throw Error(s(327));var n=e.callbackNode;if(Mu()&&e.callbackNode!==n)return null;var r=dt(e,e===Rl?Il:0);if(0===r)return null;if(0!==(30&r)||0!==(r&e.expiredLanes)||t)t=gu(e,r);else{t=r;var i=Cl;Cl|=2;var a=fu();for(Rl===e&&Il===t||(Vl=null,Gl=Qe()+500,du(e,t));;)try{yu();break}catch(l){pu(e,l)}Es(),wl.current=a,Cl=i,null!==Pl?t=0:(Rl=null,Il=0,t=Dl)}if(0!==t){if(2===t&&(0!==(i=ft(e))&&(r=i,t=su(e,i))),1===t)throw n=Ul,du(e,0),ou(e,r),ru(e,Qe()),n;if(6===t)ou(e,r);else{if(i=e.current.alternate,0===(30&r)&&!function(e){for(var t=e;;){if(16384&t.flags){var n=t.updateQueue;if(null!==n&&null!==(n=n.stores))for(var r=0;r<n.length;r++){var i=n[r],s=i.getSnapshot;i=i.value;try{if(!or(s(),i))return!1}catch(o){return!1}}}if(n=t.child,16384&t.subtreeFlags&&null!==n)n.return=t,t=n;else{if(t===e)break;for(;null===t.sibling;){if(null===t.return||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}(i)&&(2===(t=gu(e,r))&&(0!==(a=ft(e))&&(r=a,t=su(e,a))),1===t))throw n=Ul,du(e,0),ou(e,r),ru(e,Qe()),n;switch(e.finishedWork=i,e.finishedLanes=r,t){case 0:case 1:throw Error(s(345));case 2:case 5:Au(e,Hl,Vl);break;case 3:if(ou(e,r),(130023424&r)===r&&10<(t=zl+500-Qe())){if(0!==dt(e,0))break;if(((i=e.suspendedLanes)&r)!==r){eu(),e.pingedLanes|=e.suspendedLanes&i;break}e.timeoutHandle=ri(Au.bind(null,e,Hl,Vl),t);break}Au(e,Hl,Vl);break;case 4:if(ou(e,r),(4194240&r)===r)break;for(t=e.eventTimes,i=-1;0<r;){var o=31-at(r);a=1<<o,(o=t[o])>i&&(i=o),r&=~a}if(r=i,10<(r=(120>(r=Qe()-r)?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*Sl(r/1960))-r)){e.timeoutHandle=ri(Au.bind(null,e,Hl,Vl),r);break}Au(e,Hl,Vl);break;default:throw Error(s(329))}}}return ru(e,Qe()),e.callbackNode===n?iu.bind(null,e):null}function su(e,t){var n=kl;return e.current.memoizedState.isDehydrated&&(du(e,t).flags|=256),2!==(e=gu(e,t))&&(t=Hl,Hl=n,null!==t&&au(t)),e}function au(e){null===Hl?Hl=e:Hl.push.apply(Hl,e)}function ou(e,t){for(t&=~Ol,t&=~Fl,e.suspendedLanes|=t,e.pingedLanes&=~t,e=e.expirationTimes;0<t;){var n=31-at(t),r=1<<n;e[n]=-1,t&=~r}}function lu(e){if(0!==(6&Cl))throw Error(s(327));Mu();var t=dt(e,0);if(0===(1&t))return ru(e,Qe()),null;var n=gu(e,t);if(0!==e.tag&&2===n){var r=ft(e);0!==r&&(t=r,n=su(e,r))}if(1===n)throw n=Ul,du(e,0),ou(e,t),ru(e,Qe()),n;if(6===n)throw Error(s(345));return e.finishedWork=e.current.alternate,e.finishedLanes=t,Au(e,Hl,Vl),ru(e,Qe()),null}function uu(e,t){var n=Cl;Cl|=1;try{return e(t)}finally{0===(Cl=n)&&(Gl=Qe()+500,ki&&Gi())}}function cu(e){null!==Yl&&0===Yl.tag&&0===(6&Cl)&&Mu();var t=Cl;Cl|=1;var n=Tl.transition,r=_t;try{if(Tl.transition=null,_t=1,e)return e()}finally{_t=r,Tl.transition=n,0===(6&(Cl=t))&&Gi()}}function hu(){Bl=Ll.current,wi(Ll)}function du(e,t){e.finishedWork=null,e.finishedLanes=0;var n=e.timeoutHandle;if(-1!==n&&(e.timeoutHandle=-1,ii(n)),null!==Pl)for(n=Pl.return;null!==n;){var r=n;switch(ts(r),r.tag){case 1:null!==(r=r.type.childContextTypes)&&void 0!==r&&Li();break;case 3:qs(),wi(Ri),wi(Ci),na();break;case 5:Zs(r);break;case 4:qs();break;case 13:case 19:wi($s);break;case 10:Ts(r.type._context);break;case 22:case 23:hu()}n=n.return}if(Rl=e,Pl=e=Lu(e.current,null),Il=Bl=t,Dl=0,Ul=null,Ol=Fl=Nl=0,Hl=kl=null,null!==Is){for(t=0;t<Is.length;t++)if(null!==(r=(n=Is[t]).interleaved)){n.interleaved=null;var i=r.next,s=n.pending;if(null!==s){var a=s.next;s.next=i,r.next=a}n.pending=r}Is=null}return e}function pu(e,t){for(;;){var n=Pl;try{if(Es(),ra.current=Qa,ua){for(var r=aa.memoizedState;null!==r;){var i=r.queue;null!==i&&(i.pending=null),r=r.next}ua=!1}if(sa=0,la=oa=aa=null,ca=!1,ha=0,El.current=null,null===n||null===n.return){Dl=1,Ul=t,Pl=null;break}e:{var a=e,o=n.return,l=n,u=t;if(t=Il,l.flags|=32768,null!==u&&"object"===typeof u&&"function"===typeof u.then){var c=u,h=l,d=h.tag;if(0===(1&h.mode)&&(0===d||11===d||15===d)){var p=h.alternate;p?(h.updateQueue=p.updateQueue,h.memoizedState=p.memoizedState,h.lanes=p.lanes):(h.updateQueue=null,h.memoizedState=null)}var f=go(o);if(null!==f){f.flags&=-257,vo(f,o,l,0,t),1&f.mode&&mo(a,c,t),u=c;var m=(t=f).updateQueue;if(null===m){var g=new Set;g.add(u),t.updateQueue=g}else m.add(u);break e}if(0===(1&t)){mo(a,c,t),mu();break e}u=Error(s(426))}else if(is&&1&l.mode){var v=go(o);if(null!==v){0===(65536&v.flags)&&(v.flags|=256),vo(v,o,l,0,t),fs(lo(u,l));break e}}a=u=lo(u,l),4!==Dl&&(Dl=2),null===kl?kl=[a]:kl.push(a),a=o;do{switch(a.tag){case 3:a.flags|=65536,t&=-t,a.lanes|=t,zs(a,po(0,u,t));break e;case 1:l=u;var y=a.type,_=a.stateNode;if(0===(128&a.flags)&&("function"===typeof y.getDerivedStateFromError||null!==_&&"function"===typeof _.componentDidCatch&&(null===Xl||!Xl.has(_)))){a.flags|=65536,t&=-t,a.lanes|=t,zs(a,fo(a,l,t));break e}}a=a.return}while(null!==a)}xu(n)}catch(x){t=x,Pl===n&&null!==n&&(Pl=n=n.return);continue}break}}function fu(){var e=wl.current;return wl.current=Qa,null===e?Qa:e}function mu(){0!==Dl&&3!==Dl&&2!==Dl||(Dl=4),null===Rl||0===(268435455&Nl)&&0===(268435455&Fl)||ou(Rl,Il)}function gu(e,t){var n=Cl;Cl|=2;var r=fu();for(Rl===e&&Il===t||(Vl=null,du(e,t));;)try{vu();break}catch(i){pu(e,i)}if(Es(),Cl=n,wl.current=r,null!==Pl)throw Error(s(261));return Rl=null,Il=0,Dl}function vu(){for(;null!==Pl;)_u(Pl)}function yu(){for(;null!==Pl&&!Ke();)_u(Pl)}function _u(e){var t=bl(e.alternate,e,Bl);e.memoizedProps=e.pendingProps,null===t?xu(e):Pl=t,El.current=null}function xu(e){var t=e;do{var n=t.alternate;if(e=t.return,0===(32768&t.flags)){if(null!==(n=Jo(n,t,Bl)))return void(Pl=n)}else{if(null!==(n=Yo(n,t)))return n.flags&=32767,void(Pl=n);if(null===e)return Dl=6,void(Pl=null);e.flags|=32768,e.subtreeFlags=0,e.deletions=null}if(null!==(t=t.sibling))return void(Pl=t);Pl=t=e}while(null!==t);0===Dl&&(Dl=5)}function Au(e,t,n){var r=_t,i=Tl.transition;try{Tl.transition=null,_t=1,function(e,t,n,r){do{Mu()}while(null!==Yl);if(0!==(6&Cl))throw Error(s(327));n=e.finishedWork;var i=e.finishedLanes;if(null===n)return null;if(e.finishedWork=null,e.finishedLanes=0,n===e.current)throw Error(s(177));e.callbackNode=null,e.callbackPriority=0;var a=n.lanes|n.childLanes;if(function(e,t){var n=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0<n;){var i=31-at(n),s=1<<i;t[i]=0,r[i]=-1,e[i]=-1,n&=~s}}(e,a),e===Rl&&(Pl=Rl=null,Il=0),0===(2064&n.subtreeFlags)&&0===(2064&n.flags)||Jl||(Jl=!0,Ru(tt,(function(){return Mu(),null}))),a=0!==(15990&n.flags),0!==(15990&n.subtreeFlags)||a){a=Tl.transition,Tl.transition=null;var o=_t;_t=1;var l=Cl;Cl|=4,El.current=null,function(e,t){if(ei=Wt,pr(e=dr())){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{var r=(n=(n=e.ownerDocument)&&n.defaultView||window).getSelection&&n.getSelection();if(r&&0!==r.rangeCount){n=r.anchorNode;var i=r.anchorOffset,a=r.focusNode;r=r.focusOffset;try{n.nodeType,a.nodeType}catch(A){n=null;break e}var o=0,l=-1,u=-1,c=0,h=0,d=e,p=null;t:for(;;){for(var f;d!==n||0!==i&&3!==d.nodeType||(l=o+i),d!==a||0!==r&&3!==d.nodeType||(u=o+r),3===d.nodeType&&(o+=d.nodeValue.length),null!==(f=d.firstChild);)p=d,d=f;for(;;){if(d===e)break t;if(p===n&&++c===i&&(l=o),p===a&&++h===r&&(u=o),null!==(f=d.nextSibling))break;p=(d=p).parentNode}d=f}n=-1===l||-1===u?null:{start:l,end:u}}else n=null}n=n||{start:0,end:0}}else n=null;for(ti={focusedElem:e,selectionRange:n},Wt=!1,Zo=t;null!==Zo;)if(e=(t=Zo).child,0!==(1028&t.subtreeFlags)&&null!==e)e.return=t,Zo=e;else for(;null!==Zo;){t=Zo;try{var m=t.alternate;if(0!==(1024&t.flags))switch(t.tag){case 0:case 11:case 15:case 5:case 6:case 4:case 17:break;case 1:if(null!==m){var g=m.memoizedProps,v=m.memoizedState,y=t.stateNode,_=y.getSnapshotBeforeUpdate(t.elementType===t.type?g:to(t.type,g),v);y.__reactInternalSnapshotBeforeUpdate=_}break;case 3:var x=t.stateNode.containerInfo;1===x.nodeType?x.textContent="":9===x.nodeType&&x.documentElement&&x.removeChild(x.documentElement);break;default:throw Error(s(163))}}catch(A){Su(t,t.return,A)}if(null!==(e=t.sibling)){e.return=t.return,Zo=e;break}Zo=t.return}m=tl,tl=!1}(e,n),gl(n,e),fr(ti),Wt=!!ei,ti=ei=null,e.current=n,yl(n,e,i),qe(),Cl=l,_t=o,Tl.transition=a}else e.current=n;if(Jl&&(Jl=!1,Yl=e,Kl=i),a=e.pendingLanes,0===a&&(Xl=null),function(e){if(st&&"function"===typeof st.onCommitFiberRoot)try{st.onCommitFiberRoot(it,e,void 0,128===(128&e.current.flags))}catch(t){}}(n.stateNode),ru(e,Qe()),null!==t)for(r=e.onRecoverableError,n=0;n<t.length;n++)i=t[n],r(i.value,{componentStack:i.stack,digest:i.digest});if(Wl)throw Wl=!1,e=jl,jl=null,e;0!==(1&Kl)&&0!==e.tag&&Mu(),a=e.pendingLanes,0!==(1&a)?e===Ql?ql++:(ql=0,Ql=e):ql=0,Gi()}(e,t,n,r)}finally{Tl.transition=i,_t=r}return null}function Mu(){if(null!==Yl){var e=xt(Kl),t=Tl.transition,n=_t;try{if(Tl.transition=null,_t=16>e?16:e,null===Yl)var r=!1;else{if(e=Yl,Yl=null,Kl=0,0!==(6&Cl))throw Error(s(331));var i=Cl;for(Cl|=4,Zo=e.current;null!==Zo;){var a=Zo,o=a.child;if(0!==(16&Zo.flags)){var l=a.deletions;if(null!==l){for(var u=0;u<l.length;u++){var c=l[u];for(Zo=c;null!==Zo;){var h=Zo;switch(h.tag){case 0:case 11:case 15:nl(8,h,a)}var d=h.child;if(null!==d)d.return=h,Zo=d;else for(;null!==Zo;){var p=(h=Zo).sibling,f=h.return;if(sl(h),h===c){Zo=null;break}if(null!==p){p.return=f,Zo=p;break}Zo=f}}}var m=a.alternate;if(null!==m){var g=m.child;if(null!==g){m.child=null;do{var v=g.sibling;g.sibling=null,g=v}while(null!==g)}}Zo=a}}if(0!==(2064&a.subtreeFlags)&&null!==o)o.return=a,Zo=o;else e:for(;null!==Zo;){if(0!==(2048&(a=Zo).flags))switch(a.tag){case 0:case 11:case 15:nl(9,a,a.return)}var y=a.sibling;if(null!==y){y.return=a.return,Zo=y;break e}Zo=a.return}}var _=e.current;for(Zo=_;null!==Zo;){var x=(o=Zo).child;if(0!==(2064&o.subtreeFlags)&&null!==x)x.return=o,Zo=x;else e:for(o=_;null!==Zo;){if(0!==(2048&(l=Zo).flags))try{switch(l.tag){case 0:case 11:case 15:rl(9,l)}}catch(M){Su(l,l.return,M)}if(l===o){Zo=null;break e}var A=l.sibling;if(null!==A){A.return=l.return,Zo=A;break e}Zo=l.return}}if(Cl=i,Gi(),st&&"function"===typeof st.onPostCommitFiberRoot)try{st.onPostCommitFiberRoot(it,e)}catch(M){}r=!0}return r}finally{_t=n,Tl.transition=t}}return!1}function bu(e,t,n){e=ks(e,t=po(0,t=lo(n,t),1),1),t=eu(),null!==e&&(vt(e,1,t),ru(e,t))}function Su(e,t,n){if(3===e.tag)bu(e,e,n);else for(;null!==t;){if(3===t.tag){bu(t,e,n);break}if(1===t.tag){var r=t.stateNode;if("function"===typeof t.type.getDerivedStateFromError||"function"===typeof r.componentDidCatch&&(null===Xl||!Xl.has(r))){t=ks(t,e=fo(t,e=lo(n,e),1),1),e=eu(),null!==t&&(vt(t,1,e),ru(t,e));break}}t=t.return}}function wu(e,t,n){var r=e.pingCache;null!==r&&r.delete(t),t=eu(),e.pingedLanes|=e.suspendedLanes&n,Rl===e&&(Il&n)===n&&(4===Dl||3===Dl&&(130023424&Il)===Il&&500>Qe()-zl?du(e,0):Ol|=n),ru(e,t)}function Eu(e,t){0===t&&(0===(1&e.mode)?t=1:(t=ct,0===(130023424&(ct<<=1))&&(ct=4194304)));var n=eu();null!==(e=Ds(e,t))&&(vt(e,t,n),ru(e,n))}function Tu(e){var t=e.memoizedState,n=0;null!==t&&(n=t.retryLane),Eu(e,n)}function Cu(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,i=e.memoizedState;null!==i&&(n=i.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(s(314))}null!==r&&r.delete(t),Eu(e,n)}function Ru(e,t){return Je(e,t)}function Pu(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.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 Iu(e,t,n,r){return new Pu(e,t,n,r)}function Bu(e){return!(!(e=e.prototype)||!e.isReactComponent)}function Lu(e,t){var n=e.alternate;return null===n?((n=Iu(e.tag,t,e.key,e.mode)).elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=14680064&e.flags,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=null===t?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function Du(e,t,n,r,i,a){var o=2;if(r=e,"function"===typeof e)Bu(e)&&(o=1);else if("string"===typeof e)o=5;else e:switch(e){case b:return Uu(n.children,i,a,t);case S:o=8,i|=8;break;case w:return(e=Iu(12,n,t,2|i)).elementType=w,e.lanes=a,e;case R:return(e=Iu(13,n,t,i)).elementType=R,e.lanes=a,e;case P:return(e=Iu(19,n,t,i)).elementType=P,e.lanes=a,e;case L:return Nu(n,i,a,t);default:if("object"===typeof e&&null!==e)switch(e.$$typeof){case E:o=10;break e;case T:o=9;break e;case C:o=11;break e;case I:o=14;break e;case B:o=16,r=null;break e}throw Error(s(130,null==e?e:typeof e,""))}return(t=Iu(o,n,t,i)).elementType=e,t.type=r,t.lanes=a,t}function Uu(e,t,n,r){return(e=Iu(7,e,r,t)).lanes=n,e}function Nu(e,t,n,r){return(e=Iu(22,e,r,t)).elementType=L,e.lanes=n,e.stateNode={isHidden:!1},e}function Fu(e,t,n){return(e=Iu(6,e,null,t)).lanes=n,e}function Ou(e,t,n){return(t=Iu(4,null!==e.children?e.children:[],e.key,t)).lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function ku(e,t,n,r,i){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=gt(0),this.expirationTimes=gt(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=gt(0),this.identifierPrefix=r,this.onRecoverableError=i,this.mutableSourceEagerHydrationData=null}function Hu(e,t,n,r,i,s,a,o,l){return e=new ku(e,t,n,o,l),1===t?(t=1,!0===s&&(t|=8)):t=0,s=Iu(3,null,null,t),e.current=s,s.stateNode=e,s.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},Ns(s),e}function zu(e){if(!e)return Ti;e:{if(Ge(e=e._reactInternals)!==e||1!==e.tag)throw Error(s(170));var t=e;do{switch(t.tag){case 3:t=t.stateNode.context;break e;case 1:if(Bi(t.type)){t=t.stateNode.__reactInternalMemoizedMergedChildContext;break e}}t=t.return}while(null!==t);throw Error(s(171))}if(1===e.tag){var n=e.type;if(Bi(n))return Ui(e,n,t)}return t}function Gu(e,t,n,r,i,s,a,o,l){return(e=Hu(n,r,!0,e,0,s,0,o,l)).context=zu(null),n=e.current,(s=Os(r=eu(),i=tu(n))).callback=void 0!==t&&null!==t?t:null,ks(n,s,i),e.current.lanes=i,vt(e,i,r),ru(e,r),e}function Vu(e,t,n,r){var i=t.current,s=eu(),a=tu(i);return n=zu(n),null===t.context?t.context=n:t.pendingContext=n,(t=Os(s,a)).payload={element:e},null!==(r=void 0===r?null:r)&&(t.callback=r),null!==(e=ks(i,t,a))&&(nu(e,i,a,s),Hs(e,i,a)),a}function Wu(e){return(e=e.current).child?(e.child.tag,e.child.stateNode):null}function ju(e,t){if(null!==(e=e.memoizedState)&&null!==e.dehydrated){var n=e.retryLane;e.retryLane=0!==n&&n<t?n:t}}function Xu(e,t){ju(e,t),(e=e.alternate)&&ju(e,t)}bl=function(e,t,n){if(null!==e)if(e.memoizedProps!==t.pendingProps||Ri.current)_o=!0;else{if(0===(e.lanes&n)&&0===(128&t.flags))return _o=!1,function(e,t,n){switch(t.tag){case 3:Ro(t),ps();break;case 5:Qs(t);break;case 1:Bi(t.type)&&Ni(t);break;case 4:Ks(t,t.stateNode.containerInfo);break;case 10:var r=t.type._context,i=t.memoizedProps.value;Ei(Ms,r._currentValue),r._currentValue=i;break;case 13:if(null!==(r=t.memoizedState))return null!==r.dehydrated?(Ei($s,1&$s.current),t.flags|=128,null):0!==(n&t.child.childLanes)?Fo(e,t,n):(Ei($s,1&$s.current),null!==(e=Wo(e,t,n))?e.sibling:null);Ei($s,1&$s.current);break;case 19:if(r=0!==(n&t.childLanes),0!==(128&e.flags)){if(r)return Go(e,t,n);t.flags|=128}if(null!==(i=t.memoizedState)&&(i.rendering=null,i.tail=null,i.lastEffect=null),Ei($s,$s.current),r)break;return null;case 22:case 23:return t.lanes=0,So(e,t,n)}return Wo(e,t,n)}(e,t,n);_o=0!==(131072&e.flags)}else _o=!1,is&&0!==(1048576&t.flags)&&$i(t,Xi,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;Vo(e,t),e=t.pendingProps;var i=Ii(t,Ci.current);Rs(t,n),i=ma(null,t,r,e,i,n);var a=ga();return t.flags|=1,"object"===typeof i&&null!==i&&"function"===typeof i.render&&void 0===i.$$typeof?(t.tag=1,t.memoizedState=null,t.updateQueue=null,Bi(r)?(a=!0,Ni(t)):a=!1,t.memoizedState=null!==i.state&&void 0!==i.state?i.state:null,Ns(t),i.updater=ro,t.stateNode=i,i._reactInternals=t,oo(t,r,e,n),t=Co(null,t,r,!0,a,n)):(t.tag=0,is&&a&&es(t),xo(null,t,i,n),t=t.child),t;case 16:r=t.elementType;e:{switch(Vo(e,t),e=t.pendingProps,r=(i=r._init)(r._payload),t.type=r,i=t.tag=function(e){if("function"===typeof e)return Bu(e)?1:0;if(void 0!==e&&null!==e){if((e=e.$$typeof)===C)return 11;if(e===I)return 14}return 2}(r),e=to(r,e),i){case 0:t=Eo(null,t,r,e,n);break e;case 1:t=To(null,t,r,e,n);break e;case 11:t=Ao(null,t,r,e,n);break e;case 14:t=Mo(null,t,r,to(r.type,e),n);break e}throw Error(s(306,r,""))}return t;case 0:return r=t.type,i=t.pendingProps,Eo(e,t,r,i=t.elementType===r?i:to(r,i),n);case 1:return r=t.type,i=t.pendingProps,To(e,t,r,i=t.elementType===r?i:to(r,i),n);case 3:e:{if(Ro(t),null===e)throw Error(s(387));r=t.pendingProps,i=(a=t.memoizedState).element,Fs(e,t),Gs(t,r,null,n);var o=t.memoizedState;if(r=o.element,a.isDehydrated){if(a={element:r,isDehydrated:!1,cache:o.cache,pendingSuspenseBoundaries:o.pendingSuspenseBoundaries,transitions:o.transitions},t.updateQueue.baseState=a,t.memoizedState=a,256&t.flags){t=Po(e,t,r,n,i=lo(Error(s(423)),t));break e}if(r!==i){t=Po(e,t,r,n,i=lo(Error(s(424)),t));break e}for(rs=ui(t.stateNode.containerInfo.firstChild),ns=t,is=!0,ss=null,n=As(t,null,r,n),t.child=n;n;)n.flags=-3&n.flags|4096,n=n.sibling}else{if(ps(),r===i){t=Wo(e,t,n);break e}xo(e,t,r,n)}t=t.child}return t;case 5:return Qs(t),null===e&&us(t),r=t.type,i=t.pendingProps,a=null!==e?e.memoizedProps:null,o=i.children,ni(r,i)?o=null:null!==a&&ni(r,a)&&(t.flags|=32),wo(e,t),xo(e,t,o,n),t.child;case 6:return null===e&&us(t),null;case 13:return Fo(e,t,n);case 4:return Ks(t,t.stateNode.containerInfo),r=t.pendingProps,null===e?t.child=xs(t,null,r,n):xo(e,t,r,n),t.child;case 11:return r=t.type,i=t.pendingProps,Ao(e,t,r,i=t.elementType===r?i:to(r,i),n);case 7:return xo(e,t,t.pendingProps,n),t.child;case 8:case 12:return xo(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,i=t.pendingProps,a=t.memoizedProps,o=i.value,Ei(Ms,r._currentValue),r._currentValue=o,null!==a)if(or(a.value,o)){if(a.children===i.children&&!Ri.current){t=Wo(e,t,n);break e}}else for(null!==(a=t.child)&&(a.return=t);null!==a;){var l=a.dependencies;if(null!==l){o=a.child;for(var u=l.firstContext;null!==u;){if(u.context===r){if(1===a.tag){(u=Os(-1,n&-n)).tag=2;var c=a.updateQueue;if(null!==c){var h=(c=c.shared).pending;null===h?u.next=u:(u.next=h.next,h.next=u),c.pending=u}}a.lanes|=n,null!==(u=a.alternate)&&(u.lanes|=n),Cs(a.return,n,t),l.lanes|=n;break}u=u.next}}else if(10===a.tag)o=a.type===t.type?null:a.child;else if(18===a.tag){if(null===(o=a.return))throw Error(s(341));o.lanes|=n,null!==(l=o.alternate)&&(l.lanes|=n),Cs(o,n,t),o=a.sibling}else o=a.child;if(null!==o)o.return=a;else for(o=a;null!==o;){if(o===t){o=null;break}if(null!==(a=o.sibling)){a.return=o.return,o=a;break}o=o.return}a=o}xo(e,t,i.children,n),t=t.child}return t;case 9:return i=t.type,r=t.pendingProps.children,Rs(t,n),r=r(i=Ps(i)),t.flags|=1,xo(e,t,r,n),t.child;case 14:return i=to(r=t.type,t.pendingProps),Mo(e,t,r,i=to(r.type,i),n);case 15:return bo(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,i=t.pendingProps,i=t.elementType===r?i:to(r,i),Vo(e,t),t.tag=1,Bi(r)?(e=!0,Ni(t)):e=!1,Rs(t,n),so(t,r,i),oo(t,r,i,n),Co(null,t,r,!0,e,n);case 19:return Go(e,t,n);case 22:return So(e,t,n)}throw Error(s(156,t.tag))};var Ju="function"===typeof reportError?reportError:function(e){console.error(e)};function Yu(e){this._internalRoot=e}function Ku(e){this._internalRoot=e}function qu(e){return!(!e||1!==e.nodeType&&9!==e.nodeType&&11!==e.nodeType)}function Qu(e){return!(!e||1!==e.nodeType&&9!==e.nodeType&&11!==e.nodeType&&(8!==e.nodeType||" react-mount-point-unstable "!==e.nodeValue))}function Zu(){}function $u(e,t,n,r,i){var s=n._reactRootContainer;if(s){var a=s;if("function"===typeof i){var o=i;i=function(){var e=Wu(a);o.call(e)}}Vu(t,a,e,i)}else a=function(e,t,n,r,i){if(i){if("function"===typeof r){var s=r;r=function(){var e=Wu(a);s.call(e)}}var a=Gu(t,r,e,0,null,!1,0,"",Zu);return e._reactRootContainer=a,e[fi]=a.current,Gr(8===e.nodeType?e.parentNode:e),cu(),a}for(;i=e.lastChild;)e.removeChild(i);if("function"===typeof r){var o=r;r=function(){var e=Wu(l);o.call(e)}}var l=Hu(e,0,!1,null,0,!1,0,"",Zu);return e._reactRootContainer=l,e[fi]=l.current,Gr(8===e.nodeType?e.parentNode:e),cu((function(){Vu(t,l,n,r)})),l}(n,t,e,i,r);return Wu(a)}Ku.prototype.render=Yu.prototype.render=function(e){var t=this._internalRoot;if(null===t)throw Error(s(409));Vu(e,t,null,null)},Ku.prototype.unmount=Yu.prototype.unmount=function(){var e=this._internalRoot;if(null!==e){this._internalRoot=null;var t=e.containerInfo;cu((function(){Vu(null,e,null,null)})),t[fi]=null}},Ku.prototype.unstable_scheduleHydration=function(e){if(e){var t=St();e={blockedOn:null,target:e,priority:t};for(var n=0;n<Lt.length&&0!==t&&t<Lt[n].priority;n++);Lt.splice(n,0,e),0===n&&Ft(e)}},At=function(e){switch(e.tag){case 3:var t=e.stateNode;if(t.current.memoizedState.isDehydrated){var n=ht(t.pendingLanes);0!==n&&(yt(t,1|n),ru(t,Qe()),0===(6&Cl)&&(Gl=Qe()+500,Gi()))}break;case 13:cu((function(){var t=Ds(e,1);if(null!==t){var n=eu();nu(t,e,1,n)}})),Xu(e,1)}},Mt=function(e){if(13===e.tag){var t=Ds(e,134217728);if(null!==t)nu(t,e,134217728,eu());Xu(e,134217728)}},bt=function(e){if(13===e.tag){var t=tu(e),n=Ds(e,t);if(null!==n)nu(n,e,t,eu());Xu(e,t)}},St=function(){return _t},wt=function(e,t){var n=_t;try{return _t=e,t()}finally{_t=n}},Me=function(e,t,n){switch(t){case"input":if(Z(e,n),t=n.name,"radio"===n.type&&null!=t){for(n=e;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll("input[name="+JSON.stringify(""+t)+'][type="radio"]'),t=0;t<n.length;t++){var r=n[t];if(r!==e&&r.form===e.form){var i=Ai(r);if(!i)throw Error(s(90));J(r),Z(r,i)}}}break;case"textarea":se(e,n);break;case"select":null!=(t=n.value)&&ne(e,!!n.multiple,t,!1)}},Ce=uu,Re=cu;var ec={usingClientEntryPoint:!1,Events:[_i,xi,Ai,Ee,Te,uu]},tc={findFiberByHostInstance:yi,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},nc={bundleType:tc.bundleType,version:tc.version,rendererPackageName:tc.rendererPackageName,rendererConfig:tc.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:x.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return null===(e=je(e))?null:e.stateNode},findFiberByHostInstance:tc.findFiberByHostInstance||function(){return null},findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.3.1-next-f1338f8080-20240426"};if("undefined"!==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__){var rc=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!rc.isDisabled&&rc.supportsFiber)try{it=rc.inject(nc),st=rc}catch(ce){}}t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=ec,t.createPortal=function(e,t){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null;if(!qu(t))throw Error(s(200));return function(e,t,n){var r=3<arguments.length&&void 0!==arguments[3]?arguments[3]:null;return{$$typeof:M,key:null==r?null:""+r,children:e,containerInfo:t,implementation:n}}(e,t,null,n)},t.createRoot=function(e,t){if(!qu(e))throw Error(s(299));var n=!1,r="",i=Ju;return null!==t&&void 0!==t&&(!0===t.unstable_strictMode&&(n=!0),void 0!==t.identifierPrefix&&(r=t.identifierPrefix),void 0!==t.onRecoverableError&&(i=t.onRecoverableError)),t=Hu(e,1,!1,null,0,n,0,r,i),e[fi]=t.current,Gr(8===e.nodeType?e.parentNode:e),new Yu(t)},t.findDOMNode=function(e){if(null==e)return null;if(1===e.nodeType)return e;var t=e._reactInternals;if(void 0===t){if("function"===typeof e.render)throw Error(s(188));throw e=Object.keys(e).join(","),Error(s(268,e))}return e=null===(e=je(t))?null:e.stateNode},t.flushSync=function(e){return cu(e)},t.hydrate=function(e,t,n){if(!Qu(t))throw Error(s(200));return $u(null,e,t,!0,n)},t.hydrateRoot=function(e,t,n){if(!qu(e))throw Error(s(405));var r=null!=n&&n.hydratedSources||null,i=!1,a="",o=Ju;if(null!==n&&void 0!==n&&(!0===n.unstable_strictMode&&(i=!0),void 0!==n.identifierPrefix&&(a=n.identifierPrefix),void 0!==n.onRecoverableError&&(o=n.onRecoverableError)),t=Gu(t,null,e,1,null!=n?n:null,i,0,a,o),e[fi]=t.current,Gr(e),r)for(e=0;e<r.length;e++)i=(i=(n=r[e])._getVersion)(n._source),null==t.mutableSourceEagerHydrationData?t.mutableSourceEagerHydrationData=[n,i]:t.mutableSourceEagerHydrationData.push(n,i);return new Ku(t)},t.render=function(e,t,n){if(!Qu(t))throw Error(s(200));return $u(null,e,t,!1,n)},t.unmountComponentAtNode=function(e){if(!Qu(e))throw Error(s(40));return!!e._reactRootContainer&&(cu((function(){$u(null,null,e,!1,(function(){e._reactRootContainer=null,e[fi]=null}))})),!0)},t.unstable_batchedUpdates=uu,t.unstable_renderSubtreeIntoContainer=function(e,t,n,r){if(!Qu(n))throw Error(s(200));if(null==e||void 0===e._reactInternals)throw Error(s(38));return $u(e,t,n,!1,r)},t.version="18.3.1-next-f1338f8080-20240426"},352:(e,t,n)=>{"use strict";var r=n(119);t.createRoot=r.createRoot,t.hydrateRoot=r.hydrateRoot},119:(e,t,n)=>{"use strict";!function e(){if("undefined"!==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"===typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}(),e.exports=n(345)},969:(e,t)=>{"use strict";function n(e,t){var n=e.length;e.push(t);e:for(;0<n;){var r=n-1>>>1,i=e[r];if(!(0<s(i,t)))break e;e[r]=t,e[n]=i,n=r}}function r(e){return 0===e.length?null:e[0]}function i(e){if(0===e.length)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;e:for(var r=0,i=e.length,a=i>>>1;r<a;){var o=2*(r+1)-1,l=e[o],u=o+1,c=e[u];if(0>s(l,n))u<i&&0>s(c,l)?(e[r]=c,e[u]=n,r=u):(e[r]=l,e[o]=n,r=o);else{if(!(u<i&&0>s(c,n)))break e;e[r]=c,e[u]=n,r=u}}}return t}function s(e,t){var n=e.sortIndex-t.sortIndex;return 0!==n?n:e.id-t.id}if("object"===typeof performance&&"function"===typeof performance.now){var a=performance;t.unstable_now=function(){return a.now()}}else{var o=Date,l=o.now();t.unstable_now=function(){return o.now()-l}}var u=[],c=[],h=1,d=null,p=3,f=!1,m=!1,g=!1,v="function"===typeof setTimeout?setTimeout:null,y="function"===typeof clearTimeout?clearTimeout:null,_="undefined"!==typeof setImmediate?setImmediate:null;function x(e){for(var t=r(c);null!==t;){if(null===t.callback)i(c);else{if(!(t.startTime<=e))break;i(c),t.sortIndex=t.expirationTime,n(u,t)}t=r(c)}}function A(e){if(g=!1,x(e),!m)if(null!==r(u))m=!0,L(M);else{var t=r(c);null!==t&&D(A,t.startTime-e)}}function M(e,n){m=!1,g&&(g=!1,y(E),E=-1),f=!0;var s=p;try{for(x(n),d=r(u);null!==d&&(!(d.expirationTime>n)||e&&!R());){var a=d.callback;if("function"===typeof a){d.callback=null,p=d.priorityLevel;var o=a(d.expirationTime<=n);n=t.unstable_now(),"function"===typeof o?d.callback=o:d===r(u)&&i(u),x(n)}else i(u);d=r(u)}if(null!==d)var l=!0;else{var h=r(c);null!==h&&D(A,h.startTime-n),l=!1}return l}finally{d=null,p=s,f=!1}}"undefined"!==typeof navigator&&void 0!==navigator.scheduling&&void 0!==navigator.scheduling.isInputPending&&navigator.scheduling.isInputPending.bind(navigator.scheduling);var b,S=!1,w=null,E=-1,T=5,C=-1;function R(){return!(t.unstable_now()-C<T)}function P(){if(null!==w){var e=t.unstable_now();C=e;var n=!0;try{n=w(!0,e)}finally{n?b():(S=!1,w=null)}}else S=!1}if("function"===typeof _)b=function(){_(P)};else if("undefined"!==typeof MessageChannel){var I=new MessageChannel,B=I.port2;I.port1.onmessage=P,b=function(){B.postMessage(null)}}else b=function(){v(P,0)};function L(e){w=e,S||(S=!0,b())}function D(e,n){E=v((function(){e(t.unstable_now())}),n)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(e){e.callback=null},t.unstable_continueExecution=function(){m||f||(m=!0,L(M))},t.unstable_forceFrameRate=function(e){0>e||125<e?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):T=0<e?Math.floor(1e3/e):5},t.unstable_getCurrentPriorityLevel=function(){return p},t.unstable_getFirstCallbackNode=function(){return r(u)},t.unstable_next=function(e){switch(p){case 1:case 2:case 3:var t=3;break;default:t=p}var n=p;p=t;try{return e()}finally{p=n}},t.unstable_pauseExecution=function(){},t.unstable_requestPaint=function(){},t.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=p;p=e;try{return t()}finally{p=n}},t.unstable_scheduleCallback=function(e,i,s){var a=t.unstable_now();switch("object"===typeof s&&null!==s?s="number"===typeof(s=s.delay)&&0<s?a+s:a:s=a,e){case 1:var o=-1;break;case 2:o=250;break;case 5:o=1073741823;break;case 4:o=1e4;break;default:o=5e3}return e={id:h++,callback:i,priorityLevel:e,startTime:s,expirationTime:o=s+o,sortIndex:-1},s>a?(e.sortIndex=s,n(c,e),null===r(u)&&e===r(c)&&(g?(y(E),E=-1):g=!0,D(A,s-a))):(e.sortIndex=o,n(u,e),m||f||(m=!0,L(M))),e},t.unstable_shouldYield=R,t.unstable_wrapCallback=function(e){var t=p;return function(){var n=p;p=t;try{return e.apply(this,arguments)}finally{p=n}}}},204:(e,t,n)=>{"use strict";e.exports=n(969)},153:(e,t)=>{"use strict";t.ConcurrentRoot=1,t.ContinuousEventPriority=4,t.DefaultEventPriority=16,t.DiscreteEventPriority=1},473:(e,t,n)=>{e.exports=function(e){var t={},r=n(950),i=n(340),s=Object.assign;function a(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n<arguments.length;n++)t+="&args[]="+encodeURIComponent(arguments[n]);return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var o=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,l=Symbol.for("react.element"),u=Symbol.for("react.portal"),c=Symbol.for("react.fragment"),h=Symbol.for("react.strict_mode"),d=Symbol.for("react.profiler"),p=Symbol.for("react.provider"),f=Symbol.for("react.context"),m=Symbol.for("react.forward_ref"),g=Symbol.for("react.suspense"),v=Symbol.for("react.suspense_list"),y=Symbol.for("react.memo"),_=Symbol.for("react.lazy");Symbol.for("react.scope"),Symbol.for("react.debug_trace_mode");var x=Symbol.for("react.offscreen");Symbol.for("react.legacy_hidden"),Symbol.for("react.cache"),Symbol.for("react.tracing_marker");var A=Symbol.iterator;function M(e){return null===e||"object"!==typeof e?null:"function"===typeof(e=A&&e[A]||e["@@iterator"])?e:null}function b(e){if(null==e)return null;if("function"===typeof e)return e.displayName||e.name||null;if("string"===typeof e)return e;switch(e){case c:return"Fragment";case u:return"Portal";case d:return"Profiler";case h:return"StrictMode";case g:return"Suspense";case v:return"SuspenseList"}if("object"===typeof e)switch(e.$$typeof){case f:return(e.displayName||"Context")+".Consumer";case p:return(e._context.displayName||"Context")+".Provider";case m:var t=e.render;return(e=e.displayName)||(e=""!==(e=t.displayName||t.name||"")?"ForwardRef("+e+")":"ForwardRef"),e;case y:return null!==(t=e.displayName||null)?t:b(e.type)||"Memo";case _:t=e._payload,e=e._init;try{return b(e(t))}catch(n){}}return null}function S(e){var t=e.type;switch(e.tag){case 24:return"Cache";case 9:return(t.displayName||"Context")+".Consumer";case 10:return(t._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=(e=t.render).displayName||e.name||"",t.displayName||(""!==e?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return b(t);case 8:return t===h?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if("function"===typeof t)return t.displayName||t.name||null;if("string"===typeof t)return t}return null}function w(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do{0!==(4098&(t=e).flags)&&(n=t.return),e=t.return}while(e)}return 3===t.tag?n:null}function E(e){if(w(e)!==e)throw Error(a(188))}function T(e){var t=e.alternate;if(!t){if(null===(t=w(e)))throw Error(a(188));return t!==e?null:e}for(var n=e,r=t;;){var i=n.return;if(null===i)break;var s=i.alternate;if(null===s){if(null!==(r=i.return)){n=r;continue}break}if(i.child===s.child){for(s=i.child;s;){if(s===n)return E(i),e;if(s===r)return E(i),t;s=s.sibling}throw Error(a(188))}if(n.return!==r.return)n=i,r=s;else{for(var o=!1,l=i.child;l;){if(l===n){o=!0,n=i,r=s;break}if(l===r){o=!0,r=i,n=s;break}l=l.sibling}if(!o){for(l=s.child;l;){if(l===n){o=!0,n=s,r=i;break}if(l===r){o=!0,r=s,n=i;break}l=l.sibling}if(!o)throw Error(a(189))}}if(n.alternate!==r)throw Error(a(190))}if(3!==n.tag)throw Error(a(188));return n.stateNode.current===n?e:t}function C(e){return null!==(e=T(e))?R(e):null}function R(e){if(5===e.tag||6===e.tag)return e;for(e=e.child;null!==e;){var t=R(e);if(null!==t)return t;e=e.sibling}return null}function P(e){if(5===e.tag||6===e.tag)return e;for(e=e.child;null!==e;){if(4!==e.tag){var t=P(e);if(null!==t)return t}e=e.sibling}return null}var I,B=Array.isArray,L=e.getPublicInstance,D=e.getRootHostContext,U=e.getChildHostContext,N=e.prepareForCommit,F=e.resetAfterCommit,O=e.createInstance,k=e.appendInitialChild,H=e.finalizeInitialChildren,z=e.prepareUpdate,G=e.shouldSetTextContent,V=e.createTextInstance,W=e.scheduleTimeout,j=e.cancelTimeout,X=e.noTimeout,J=e.isPrimaryRenderer,Y=e.supportsMutation,K=e.supportsPersistence,q=e.supportsHydration,Q=e.getInstanceFromNode,Z=e.preparePortalMount,$=e.getCurrentEventPriority,ee=e.detachDeletedInstance,te=e.supportsMicrotasks,ne=e.scheduleMicrotask,re=e.supportsTestSelectors,ie=e.findFiberRoot,se=e.getBoundingRect,ae=e.getTextContent,oe=e.isHiddenSubtree,le=e.matchAccessibilityRole,ue=e.setFocusIfFocusable,ce=e.setupIntersectionObserver,he=e.appendChild,de=e.appendChildToContainer,pe=e.commitTextUpdate,fe=e.commitMount,me=e.commitUpdate,ge=e.insertBefore,ve=e.insertInContainerBefore,ye=e.removeChild,_e=e.removeChildFromContainer,xe=e.resetTextContent,Ae=e.hideInstance,Me=e.hideTextInstance,be=e.unhideInstance,Se=e.unhideTextInstance,we=e.clearContainer,Ee=e.cloneInstance,Te=e.createContainerChildSet,Ce=e.appendChildToContainerChildSet,Re=e.finalizeContainerChildren,Pe=e.replaceContainerChildren,Ie=e.cloneHiddenInstance,Be=e.cloneHiddenTextInstance,Le=e.canHydrateInstance,De=e.canHydrateTextInstance,Ue=e.canHydrateSuspenseInstance,Ne=e.isSuspenseInstancePending,Fe=e.isSuspenseInstanceFallback,Oe=e.registerSuspenseInstanceRetry,ke=e.getNextHydratableSibling,He=e.getFirstHydratableChild,ze=e.getFirstHydratableChildWithinContainer,Ge=e.getFirstHydratableChildWithinSuspenseInstance,Ve=e.hydrateInstance,We=e.hydrateTextInstance,je=e.hydrateSuspenseInstance,Xe=e.getNextHydratableInstanceAfterSuspenseInstance,Je=e.commitHydratedContainer,Ye=e.commitHydratedSuspenseInstance,Ke=e.clearSuspenseBoundary,qe=e.clearSuspenseBoundaryFromContainer,Qe=e.shouldDeleteUnhydratedTailInstances,Ze=e.didNotMatchHydratedContainerTextInstance,$e=e.didNotMatchHydratedTextInstance;function et(e){if(void 0===I)try{throw Error()}catch(n){var t=n.stack.trim().match(/\n( *(at )?)/);I=t&&t[1]||""}return"\n"+I+e}var tt=!1;function nt(e,t){if(!e||tt)return"";tt=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(t)if(t=function(){throw Error()},Object.defineProperty(t.prototype,"props",{set:function(){throw Error()}}),"object"===typeof Reflect&&Reflect.construct){try{Reflect.construct(t,[])}catch(u){var r=u}Reflect.construct(e,[],t)}else{try{t.call()}catch(u){r=u}e.call(t.prototype)}else{try{throw Error()}catch(u){r=u}e()}}catch(u){if(u&&r&&"string"===typeof u.stack){for(var i=u.stack.split("\n"),s=r.stack.split("\n"),a=i.length-1,o=s.length-1;1<=a&&0<=o&&i[a]!==s[o];)o--;for(;1<=a&&0<=o;a--,o--)if(i[a]!==s[o]){if(1!==a||1!==o)do{if(a--,0>--o||i[a]!==s[o]){var l="\n"+i[a].replace(" at new "," at ");return e.displayName&&l.includes("<anonymous>")&&(l=l.replace("<anonymous>",e.displayName)),l}}while(1<=a&&0<=o);break}}}finally{tt=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?et(e):""}var rt=Object.prototype.hasOwnProperty,it=[],st=-1;function at(e){return{current:e}}function ot(e){0>st||(e.current=it[st],it[st]=null,st--)}function lt(e,t){st++,it[st]=e.current,e.current=t}var ut={},ct=at(ut),ht=at(!1),dt=ut;function pt(e,t){var n=e.type.contextTypes;if(!n)return ut;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var i,s={};for(i in n)s[i]=t[i];return r&&((e=e.stateNode).__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=s),s}function ft(e){return null!==(e=e.childContextTypes)&&void 0!==e}function mt(){ot(ht),ot(ct)}function gt(e,t,n){if(ct.current!==ut)throw Error(a(168));lt(ct,t),lt(ht,n)}function vt(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,"function"!==typeof r.getChildContext)return n;for(var i in r=r.getChildContext())if(!(i in t))throw Error(a(108,S(e)||"Unknown",i));return s({},n,r)}function yt(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||ut,dt=ct.current,lt(ct,e),lt(ht,ht.current),!0}function _t(e,t,n){var r=e.stateNode;if(!r)throw Error(a(169));n?(e=vt(e,t,dt),r.__reactInternalMemoizedMergedChildContext=e,ot(ht),ot(ct),lt(ct,e)):ot(ht),lt(ht,n)}var xt=Math.clz32?Math.clz32:function(e){return 0===(e>>>=0)?32:31-(At(e)/Mt|0)|0},At=Math.log,Mt=Math.LN2;var bt=64,St=4194304;function wt(e){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: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 4194240&e;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return 130023424&e;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function Et(e,t){var n=e.pendingLanes;if(0===n)return 0;var r=0,i=e.suspendedLanes,s=e.pingedLanes,a=268435455&n;if(0!==a){var o=a&~i;0!==o?r=wt(o):0!==(s&=a)&&(r=wt(s))}else 0!==(a=n&~i)?r=wt(a):0!==s&&(r=wt(s));if(0===r)return 0;if(0!==t&&t!==r&&0===(t&i)&&((i=r&-r)>=(s=t&-t)||16===i&&0!==(4194240&s)))return t;if(0!==(4&r)&&(r|=16&n),0!==(t=e.entangledLanes))for(e=e.entanglements,t&=r;0<t;)i=1<<(n=31-xt(t)),r|=e[n],t&=~i;return r}function Tt(e,t){switch(e){case 1:case 2:case 4:return t+250;case 8:case 16:case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;default:return-1}}function Ct(e){return 0!==(e=-1073741825&e.pendingLanes)?e:1073741824&e?1073741824:0}function Rt(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function Pt(e,t,n){e.pendingLanes|=t,536870912!==t&&(e.suspendedLanes=0,e.pingedLanes=0),(e=e.eventTimes)[t=31-xt(t)]=n}function It(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-xt(n),i=1<<r;i&t|e[r]&t&&(e[r]|=t),n&=~i}}var Bt=0;function Lt(e){return 1<(e&=-e)?4<e?0!==(268435455&e)?16:536870912:4:1}var Dt=i.unstable_scheduleCallback,Ut=i.unstable_cancelCallback,Nt=i.unstable_shouldYield,Ft=i.unstable_requestPaint,Ot=i.unstable_now,kt=i.unstable_ImmediatePriority,Ht=i.unstable_UserBlockingPriority,zt=i.unstable_NormalPriority,Gt=i.unstable_IdlePriority,Vt=null,Wt=null;var jt="function"===typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e===1/t)||e!==e&&t!==t},Xt=null,Jt=!1,Yt=!1;function Kt(e){null===Xt?Xt=[e]:Xt.push(e)}function qt(){if(!Yt&&null!==Xt){Yt=!0;var e=0,t=Bt;try{var n=Xt;for(Bt=1;e<n.length;e++){var r=n[e];do{r=r(!0)}while(null!==r)}Xt=null,Jt=!1}catch(i){throw null!==Xt&&(Xt=Xt.slice(e+1)),Dt(kt,qt),i}finally{Bt=t,Yt=!1}}return null}var Qt=o.ReactCurrentBatchConfig;function Zt(e,t){if(jt(e,t))return!0;if("object"!==typeof e||null===e||"object"!==typeof t||null===t)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(r=0;r<n.length;r++){var i=n[r];if(!rt.call(t,i)||!jt(e[i],t[i]))return!1}return!0}function $t(e){switch(e.tag){case 5:return et(e.type);case 16:return et("Lazy");case 13:return et("Suspense");case 19:return et("SuspenseList");case 0:case 2:case 15:return e=nt(e.type,!1);case 11:return e=nt(e.type.render,!1);case 1:return e=nt(e.type,!0);default:return""}}function en(e,t){if(e&&e.defaultProps){for(var n in t=s({},t),e=e.defaultProps)void 0===t[n]&&(t[n]=e[n]);return t}return t}var tn=at(null),nn=null,rn=null,sn=null;function an(){sn=rn=nn=null}function on(e,t,n){J?(lt(tn,t._currentValue),t._currentValue=n):(lt(tn,t._currentValue2),t._currentValue2=n)}function ln(e){var t=tn.current;ot(tn),J?e._currentValue=t:e._currentValue2=t}function un(e,t,n){for(;null!==e;){var r=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,null!==r&&(r.childLanes|=t)):null!==r&&(r.childLanes&t)!==t&&(r.childLanes|=t),e===n)break;e=e.return}}function cn(e,t){nn=e,sn=rn=null,null!==(e=e.dependencies)&&null!==e.firstContext&&(0!==(e.lanes&t)&&(Ni=!0),e.firstContext=null)}function hn(e){var t=J?e._currentValue:e._currentValue2;if(sn!==e)if(e={context:e,memoizedValue:t,next:null},null===rn){if(null===nn)throw Error(a(308));rn=e,nn.dependencies={lanes:0,firstContext:e}}else rn=rn.next=e;return t}var dn=null,pn=!1;function fn(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function mn(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function gn(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function vn(e,t){var n=e.updateQueue;null!==n&&(n=n.shared,null!==Ys&&0!==(1&e.mode)&&0===(2&Js)?(null===(e=n.interleaved)?(t.next=t,null===dn?dn=[n]:dn.push(n)):(t.next=e.next,e.next=t),n.interleaved=t):(null===(e=n.pending)?t.next=t:(t.next=e.next,e.next=t),n.pending=t))}function yn(e,t,n){if(null!==(t=t.updateQueue)&&(t=t.shared,0!==(4194240&n))){var r=t.lanes;n|=r&=e.pendingLanes,t.lanes=n,It(e,n)}}function _n(e,t){var n=e.updateQueue,r=e.alternate;if(null!==r&&n===(r=r.updateQueue)){var i=null,s=null;if(null!==(n=n.firstBaseUpdate)){do{var a={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};null===s?i=s=a:s=s.next=a,n=n.next}while(null!==n);null===s?i=s=t:s=s.next=t}else i=s=t;return n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:s,shared:r.shared,effects:r.effects},void(e.updateQueue=n)}null===(e=n.lastBaseUpdate)?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function xn(e,t,n,r){var i=e.updateQueue;pn=!1;var a=i.firstBaseUpdate,o=i.lastBaseUpdate,l=i.shared.pending;if(null!==l){i.shared.pending=null;var u=l,c=u.next;u.next=null,null===o?a=c:o.next=c,o=u;var h=e.alternate;null!==h&&((l=(h=h.updateQueue).lastBaseUpdate)!==o&&(null===l?h.firstBaseUpdate=c:l.next=c,h.lastBaseUpdate=u))}if(null!==a){var d=i.baseState;for(o=0,h=c=u=null,l=a;;){var p=l.lane,f=l.eventTime;if((r&p)===p){null!==h&&(h=h.next={eventTime:f,lane:0,tag:l.tag,payload:l.payload,callback:l.callback,next:null});e:{var m=e,g=l;switch(p=t,f=n,g.tag){case 1:if("function"===typeof(m=g.payload)){d=m.call(f,d,p);break e}d=m;break e;case 3:m.flags=-65537&m.flags|128;case 0:if(null===(p="function"===typeof(m=g.payload)?m.call(f,d,p):m)||void 0===p)break e;d=s({},d,p);break e;case 2:pn=!0}}null!==l.callback&&0!==l.lane&&(e.flags|=64,null===(p=i.effects)?i.effects=[l]:p.push(l))}else f={eventTime:f,lane:p,tag:l.tag,payload:l.payload,callback:l.callback,next:null},null===h?(c=h=f,u=d):h=h.next=f,o|=p;if(null===(l=l.next)){if(null===(l=i.shared.pending))break;l=(p=l).next,p.next=null,i.lastBaseUpdate=p,i.shared.pending=null}}if(null===h&&(u=d),i.baseState=u,i.firstBaseUpdate=c,i.lastBaseUpdate=h,null!==(t=i.shared.interleaved)){i=t;do{o|=i.lane,i=i.next}while(i!==t)}else null===a&&(i.shared.lanes=0);ta|=o,e.lanes=o,e.memoizedState=d}}function An(e,t,n){if(e=t.effects,t.effects=null,null!==e)for(t=0;t<e.length;t++){var r=e[t],i=r.callback;if(null!==i){if(r.callback=null,r=n,"function"!==typeof i)throw Error(a(191,i));i.call(r)}}}var Mn=(new r.Component).refs;function bn(e,t,n,r){n=null===(n=n(r,t=e.memoizedState))||void 0===n?t:s({},t,n),e.memoizedState=n,0===e.lanes&&(e.updateQueue.baseState=n)}var Sn={isMounted:function(e){return!!(e=e._reactInternals)&&w(e)===e},enqueueSetState:function(e,t,n){e=e._reactInternals;var r=xa(),i=Aa(e),s=gn(r,i);s.payload=t,void 0!==n&&null!==n&&(s.callback=n),vn(e,s),null!==(t=Ma(e,i,r))&&yn(t,e,i)},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=xa(),i=Aa(e),s=gn(r,i);s.tag=1,s.payload=t,void 0!==n&&null!==n&&(s.callback=n),vn(e,s),null!==(t=Ma(e,i,r))&&yn(t,e,i)},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=xa(),r=Aa(e),i=gn(n,r);i.tag=2,void 0!==t&&null!==t&&(i.callback=t),vn(e,i),null!==(t=Ma(e,r,n))&&yn(t,e,r)}};function wn(e,t,n,r,i,s,a){return"function"===typeof(e=e.stateNode).shouldComponentUpdate?e.shouldComponentUpdate(r,s,a):!t.prototype||!t.prototype.isPureReactComponent||(!Zt(n,r)||!Zt(i,s))}function En(e,t,n){var r=!1,i=ut,s=t.contextType;return"object"===typeof s&&null!==s?s=hn(s):(i=ft(t)?dt:ct.current,s=(r=null!==(r=t.contextTypes)&&void 0!==r)?pt(e,i):ut),t=new t(n,s),e.memoizedState=null!==t.state&&void 0!==t.state?t.state:null,t.updater=Sn,e.stateNode=t,t._reactInternals=e,r&&((e=e.stateNode).__reactInternalMemoizedUnmaskedChildContext=i,e.__reactInternalMemoizedMaskedChildContext=s),t}function Tn(e,t,n,r){e=t.state,"function"===typeof t.componentWillReceiveProps&&t.componentWillReceiveProps(n,r),"function"===typeof t.UNSAFE_componentWillReceiveProps&&t.UNSAFE_componentWillReceiveProps(n,r),t.state!==e&&Sn.enqueueReplaceState(t,t.state,null)}function Cn(e,t,n,r){var i=e.stateNode;i.props=n,i.state=e.memoizedState,i.refs=Mn,fn(e);var s=t.contextType;"object"===typeof s&&null!==s?i.context=hn(s):(s=ft(t)?dt:ct.current,i.context=pt(e,s)),i.state=e.memoizedState,"function"===typeof(s=t.getDerivedStateFromProps)&&(bn(e,t,s,n),i.state=e.memoizedState),"function"===typeof t.getDerivedStateFromProps||"function"===typeof i.getSnapshotBeforeUpdate||"function"!==typeof i.UNSAFE_componentWillMount&&"function"!==typeof i.componentWillMount||(t=i.state,"function"===typeof i.componentWillMount&&i.componentWillMount(),"function"===typeof i.UNSAFE_componentWillMount&&i.UNSAFE_componentWillMount(),t!==i.state&&Sn.enqueueReplaceState(i,i.state,null),xn(e,n,i,r),i.state=e.memoizedState),"function"===typeof i.componentDidMount&&(e.flags|=4194308)}var Rn=[],Pn=0,In=null,Bn=0,Ln=[],Dn=0,Un=null,Nn=1,Fn="";function On(e,t){Rn[Pn++]=Bn,Rn[Pn++]=In,In=e,Bn=t}function kn(e,t,n){Ln[Dn++]=Nn,Ln[Dn++]=Fn,Ln[Dn++]=Un,Un=e;var r=Nn;e=Fn;var i=32-xt(r)-1;r&=~(1<<i),n+=1;var s=32-xt(t)+i;if(30<s){var a=i-i%5;s=(r&(1<<a)-1).toString(32),r>>=a,i-=a,Nn=1<<32-xt(t)+i|n<<i|r,Fn=s+e}else Nn=1<<s|n<<i|r,Fn=e}function Hn(e){null!==e.return&&(On(e,1),kn(e,1,0))}function zn(e){for(;e===In;)In=Rn[--Pn],Rn[Pn]=null,Bn=Rn[--Pn],Rn[Pn]=null;for(;e===Un;)Un=Ln[--Dn],Ln[Dn]=null,Fn=Ln[--Dn],Ln[Dn]=null,Nn=Ln[--Dn],Ln[Dn]=null}var Gn=null,Vn=null,Wn=!1,jn=!1,Xn=null;function Jn(e,t){var n=Qa(5,null,null,0);n.elementType="DELETED",n.stateNode=t,n.return=e,null===(t=e.deletions)?(e.deletions=[n],e.flags|=16):t.push(n)}function Yn(e,t){switch(e.tag){case 5:return null!==(t=Le(t,e.type,e.pendingProps))&&(e.stateNode=t,Gn=e,Vn=He(t),!0);case 6:return null!==(t=De(t,e.pendingProps))&&(e.stateNode=t,Gn=e,Vn=null,!0);case 13:if(null!==(t=Ue(t))){var n=null!==Un?{id:Nn,overflow:Fn}:null;return e.memoizedState={dehydrated:t,treeContext:n,retryLane:1073741824},(n=Qa(18,null,null,0)).stateNode=t,n.return=e,e.child=n,Gn=e,Vn=null,!0}return!1;default:return!1}}function Kn(e){return 0!==(1&e.mode)&&0===(128&e.flags)}function qn(e){if(Wn){var t=Vn;if(t){var n=t;if(!Yn(e,t)){if(Kn(e))throw Error(a(418));t=ke(n);var r=Gn;t&&Yn(e,t)?Jn(r,n):(e.flags=-4097&e.flags|2,Wn=!1,Gn=e)}}else{if(Kn(e))throw Error(a(418));e.flags=-4097&e.flags|2,Wn=!1,Gn=e}}}function Qn(e){for(e=e.return;null!==e&&5!==e.tag&&3!==e.tag&&13!==e.tag;)e=e.return;Gn=e}function Zn(e){if(!q||e!==Gn)return!1;if(!Wn)return Qn(e),Wn=!0,!1;if(3!==e.tag&&(5!==e.tag||Qe(e.type)&&!G(e.type,e.memoizedProps))){var t=Vn;if(t){if(Kn(e)){for(e=Vn;e;)e=ke(e);throw Error(a(418))}for(;t;)Jn(e,t),t=ke(t)}}if(Qn(e),13===e.tag){if(!q)throw Error(a(316));if(!(e=null!==(e=e.memoizedState)?e.dehydrated:null))throw Error(a(317));Vn=Xe(e)}else Vn=Gn?ke(e.stateNode):null;return!0}function $n(){q&&(Vn=Gn=null,jn=Wn=!1)}function er(e){null===Xn?Xn=[e]:Xn.push(e)}function tr(e,t,n){if(null!==(e=n.ref)&&"function"!==typeof e&&"object"!==typeof e){if(n._owner){if(n=n._owner){if(1!==n.tag)throw Error(a(309));var r=n.stateNode}if(!r)throw Error(a(147,e));var i=r,s=""+e;return null!==t&&null!==t.ref&&"function"===typeof t.ref&&t.ref._stringRef===s?t.ref:(t=function(e){var t=i.refs;t===Mn&&(t=i.refs={}),null===e?delete t[s]:t[s]=e},t._stringRef=s,t)}if("string"!==typeof e)throw Error(a(284));if(!n._owner)throw Error(a(290,e))}return e}function nr(e,t){throw e=Object.prototype.toString.call(t),Error(a(31,"[object Object]"===e?"object with keys {"+Object.keys(t).join(", ")+"}":e))}function rr(e){return(0,e._init)(e._payload)}function ir(e){function t(t,n){if(e){var r=t.deletions;null===r?(t.deletions=[n],t.flags|=16):r.push(n)}}function n(n,r){if(!e)return null;for(;null!==r;)t(n,r),r=r.sibling;return null}function r(e,t){for(e=new Map;null!==t;)null!==t.key?e.set(t.key,t):e.set(t.index,t),t=t.sibling;return e}function i(e,t){return(e=$a(e,t)).index=0,e.sibling=null,e}function s(t,n,r){return t.index=r,e?null!==(r=t.alternate)?(r=r.index)<n?(t.flags|=2,n):r:(t.flags|=2,n):(t.flags|=1048576,n)}function o(t){return e&&null===t.alternate&&(t.flags|=2),t}function h(e,t,n,r){return null===t||6!==t.tag?((t=ro(n,e.mode,r)).return=e,t):((t=i(t,n)).return=e,t)}function d(e,t,n,r){var s=n.type;return s===c?f(e,t,n.props.children,r,n.key):null!==t&&(t.elementType===s||"object"===typeof s&&null!==s&&s.$$typeof===_&&rr(s)===t.type)?((r=i(t,n.props)).ref=tr(e,t,n),r.return=e,r):((r=eo(n.type,n.key,n.props,null,e.mode,r)).ref=tr(e,t,n),r.return=e,r)}function p(e,t,n,r){return null===t||4!==t.tag||t.stateNode.containerInfo!==n.containerInfo||t.stateNode.implementation!==n.implementation?((t=io(n,e.mode,r)).return=e,t):((t=i(t,n.children||[])).return=e,t)}function f(e,t,n,r,s){return null===t||7!==t.tag?((t=to(n,e.mode,r,s)).return=e,t):((t=i(t,n)).return=e,t)}function m(e,t,n){if("string"===typeof t&&""!==t||"number"===typeof t)return(t=ro(""+t,e.mode,n)).return=e,t;if("object"===typeof t&&null!==t){switch(t.$$typeof){case l:return(n=eo(t.type,t.key,t.props,null,e.mode,n)).ref=tr(e,null,t),n.return=e,n;case u:return(t=io(t,e.mode,n)).return=e,t;case _:return m(e,(0,t._init)(t._payload),n)}if(B(t)||M(t))return(t=to(t,e.mode,n,null)).return=e,t;nr(e,t)}return null}function g(e,t,n,r){var i=null!==t?t.key:null;if("string"===typeof n&&""!==n||"number"===typeof n)return null!==i?null:h(e,t,""+n,r);if("object"===typeof n&&null!==n){switch(n.$$typeof){case l:return n.key===i?d(e,t,n,r):null;case u:return n.key===i?p(e,t,n,r):null;case _:return g(e,t,(i=n._init)(n._payload),r)}if(B(n)||M(n))return null!==i?null:f(e,t,n,r,null);nr(e,n)}return null}function v(e,t,n,r,i){if("string"===typeof r&&""!==r||"number"===typeof r)return h(t,e=e.get(n)||null,""+r,i);if("object"===typeof r&&null!==r){switch(r.$$typeof){case l:return d(t,e=e.get(null===r.key?n:r.key)||null,r,i);case u:return p(t,e=e.get(null===r.key?n:r.key)||null,r,i);case _:return v(e,t,n,(0,r._init)(r._payload),i)}if(B(r)||M(r))return f(t,e=e.get(n)||null,r,i,null);nr(t,r)}return null}function y(i,a,o,l){for(var u=null,c=null,h=a,d=a=0,p=null;null!==h&&d<o.length;d++){h.index>d?(p=h,h=null):p=h.sibling;var f=g(i,h,o[d],l);if(null===f){null===h&&(h=p);break}e&&h&&null===f.alternate&&t(i,h),a=s(f,a,d),null===c?u=f:c.sibling=f,c=f,h=p}if(d===o.length)return n(i,h),Wn&&On(i,d),u;if(null===h){for(;d<o.length;d++)null!==(h=m(i,o[d],l))&&(a=s(h,a,d),null===c?u=h:c.sibling=h,c=h);return Wn&&On(i,d),u}for(h=r(i,h);d<o.length;d++)null!==(p=v(h,i,d,o[d],l))&&(e&&null!==p.alternate&&h.delete(null===p.key?d:p.key),a=s(p,a,d),null===c?u=p:c.sibling=p,c=p);return e&&h.forEach((function(e){return t(i,e)})),Wn&&On(i,d),u}function x(i,o,l,u){var c=M(l);if("function"!==typeof c)throw Error(a(150));if(null==(l=c.call(l)))throw Error(a(151));for(var h=c=null,d=o,p=o=0,f=null,y=l.next();null!==d&&!y.done;p++,y=l.next()){d.index>p?(f=d,d=null):f=d.sibling;var _=g(i,d,y.value,u);if(null===_){null===d&&(d=f);break}e&&d&&null===_.alternate&&t(i,d),o=s(_,o,p),null===h?c=_:h.sibling=_,h=_,d=f}if(y.done)return n(i,d),Wn&&On(i,p),c;if(null===d){for(;!y.done;p++,y=l.next())null!==(y=m(i,y.value,u))&&(o=s(y,o,p),null===h?c=y:h.sibling=y,h=y);return Wn&&On(i,p),c}for(d=r(i,d);!y.done;p++,y=l.next())null!==(y=v(d,i,p,y.value,u))&&(e&&null!==y.alternate&&d.delete(null===y.key?p:y.key),o=s(y,o,p),null===h?c=y:h.sibling=y,h=y);return e&&d.forEach((function(e){return t(i,e)})),Wn&&On(i,p),c}return function e(r,s,a,h){if("object"===typeof a&&null!==a&&a.type===c&&null===a.key&&(a=a.props.children),"object"===typeof a&&null!==a){switch(a.$$typeof){case l:e:{for(var d=a.key,p=s;null!==p;){if(p.key===d){if((d=a.type)===c){if(7===p.tag){n(r,p.sibling),(s=i(p,a.props.children)).return=r,r=s;break e}}else if(p.elementType===d||"object"===typeof d&&null!==d&&d.$$typeof===_&&rr(d)===p.type){n(r,p.sibling),(s=i(p,a.props)).ref=tr(r,p,a),s.return=r,r=s;break e}n(r,p);break}t(r,p),p=p.sibling}a.type===c?((s=to(a.props.children,r.mode,h,a.key)).return=r,r=s):((h=eo(a.type,a.key,a.props,null,r.mode,h)).ref=tr(r,s,a),h.return=r,r=h)}return o(r);case u:e:{for(p=a.key;null!==s;){if(s.key===p){if(4===s.tag&&s.stateNode.containerInfo===a.containerInfo&&s.stateNode.implementation===a.implementation){n(r,s.sibling),(s=i(s,a.children||[])).return=r,r=s;break e}n(r,s);break}t(r,s),s=s.sibling}(s=io(a,r.mode,h)).return=r,r=s}return o(r);case _:return e(r,s,(p=a._init)(a._payload),h)}if(B(a))return y(r,s,a,h);if(M(a))return x(r,s,a,h);nr(r,a)}return"string"===typeof a&&""!==a||"number"===typeof a?(a=""+a,null!==s&&6===s.tag?(n(r,s.sibling),(s=i(s,a)).return=r,r=s):(n(r,s),(s=ro(a,r.mode,h)).return=r,r=s),o(r)):n(r,s)}}var sr=ir(!0),ar=ir(!1),or={},lr=at(or),ur=at(or),cr=at(or);function hr(e){if(e===or)throw Error(a(174));return e}function dr(e,t){lt(cr,t),lt(ur,e),lt(lr,or),e=D(t),ot(lr),lt(lr,e)}function pr(){ot(lr),ot(ur),ot(cr)}function fr(e){var t=hr(cr.current),n=hr(lr.current);n!==(t=U(n,e.type,t))&&(lt(ur,e),lt(lr,t))}function mr(e){ur.current===e&&(ot(lr),ot(ur))}var gr=at(0);function vr(e){for(var t=e;null!==t;){if(13===t.tag){var n=t.memoizedState;if(null!==n&&(null===(n=n.dehydrated)||Ne(n)||Fe(n)))return t}else if(19===t.tag&&void 0!==t.memoizedProps.revealOrder){if(0!==(128&t.flags))return t}else if(null!==t.child){t.child.return=t,t=t.child;continue}if(t===e)break;for(;null===t.sibling;){if(null===t.return||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var yr=[];function _r(){for(var e=0;e<yr.length;e++){var t=yr[e];J?t._workInProgressVersionPrimary=null:t._workInProgressVersionSecondary=null}yr.length=0}var xr=o.ReactCurrentDispatcher,Ar=o.ReactCurrentBatchConfig,Mr=0,br=null,Sr=null,wr=null,Er=!1,Tr=!1,Cr=0,Rr=0;function Pr(){throw Error(a(321))}function Ir(e,t){if(null===t)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!jt(e[n],t[n]))return!1;return!0}function Br(e,t,n,r,i,s){if(Mr=s,br=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,xr.current=null===e||null===e.memoizedState?fi:mi,e=n(r,i),Tr){s=0;do{if(Tr=!1,Cr=0,25<=s)throw Error(a(301));s+=1,wr=Sr=null,t.updateQueue=null,xr.current=gi,e=n(r,i)}while(Tr)}if(xr.current=pi,t=null!==Sr&&null!==Sr.next,Mr=0,wr=Sr=br=null,Er=!1,t)throw Error(a(300));return e}function Lr(){var e=0!==Cr;return Cr=0,e}function Dr(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return null===wr?br.memoizedState=wr=e:wr=wr.next=e,wr}function Ur(){if(null===Sr){var e=br.alternate;e=null!==e?e.memoizedState:null}else e=Sr.next;var t=null===wr?br.memoizedState:wr.next;if(null!==t)wr=t,Sr=e;else{if(null===e)throw Error(a(310));e={memoizedState:(Sr=e).memoizedState,baseState:Sr.baseState,baseQueue:Sr.baseQueue,queue:Sr.queue,next:null},null===wr?br.memoizedState=wr=e:wr=wr.next=e}return wr}function Nr(e,t){return"function"===typeof t?t(e):t}function Fr(e){var t=Ur(),n=t.queue;if(null===n)throw Error(a(311));n.lastRenderedReducer=e;var r=Sr,i=r.baseQueue,s=n.pending;if(null!==s){if(null!==i){var o=i.next;i.next=s.next,s.next=o}r.baseQueue=i=s,n.pending=null}if(null!==i){s=i.next,r=r.baseState;var l=o=null,u=null,c=s;do{var h=c.lane;if((Mr&h)===h)null!==u&&(u=u.next={lane:0,action:c.action,hasEagerState:c.hasEagerState,eagerState:c.eagerState,next:null}),r=c.hasEagerState?c.eagerState:e(r,c.action);else{var d={lane:h,action:c.action,hasEagerState:c.hasEagerState,eagerState:c.eagerState,next:null};null===u?(l=u=d,o=r):u=u.next=d,br.lanes|=h,ta|=h}c=c.next}while(null!==c&&c!==s);null===u?o=r:u.next=l,jt(r,t.memoizedState)||(Ni=!0),t.memoizedState=r,t.baseState=o,t.baseQueue=u,n.lastRenderedState=r}if(null!==(e=n.interleaved)){i=e;do{s=i.lane,br.lanes|=s,ta|=s,i=i.next}while(i!==e)}else null===i&&(n.lanes=0);return[t.memoizedState,n.dispatch]}function Or(e){var t=Ur(),n=t.queue;if(null===n)throw Error(a(311));n.lastRenderedReducer=e;var r=n.dispatch,i=n.pending,s=t.memoizedState;if(null!==i){n.pending=null;var o=i=i.next;do{s=e(s,o.action),o=o.next}while(o!==i);jt(s,t.memoizedState)||(Ni=!0),t.memoizedState=s,null===t.baseQueue&&(t.baseState=s),n.lastRenderedState=s}return[s,r]}function kr(){}function Hr(e,t){var n=br,r=Ur(),i=t(),s=!jt(r.memoizedState,i);if(s&&(r.memoizedState=i,Ni=!0),r=r.queue,Qr(Vr.bind(null,n,r,e),[e]),r.getSnapshot!==t||s||null!==wr&&1&wr.memoizedState.tag){if(n.flags|=2048,Xr(9,Gr.bind(null,n,r,i,t),void 0,null),null===Ys)throw Error(a(349));0!==(30&Mr)||zr(n,t,i)}return i}function zr(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},null===(t=br.updateQueue)?(t={lastEffect:null,stores:null},br.updateQueue=t,t.stores=[e]):null===(n=t.stores)?t.stores=[e]:n.push(e)}function Gr(e,t,n,r){t.value=n,t.getSnapshot=r,Wr(t)&&Ma(e,1,-1)}function Vr(e,t,n){return n((function(){Wr(t)&&Ma(e,1,-1)}))}function Wr(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!jt(e,n)}catch(r){return!0}}function jr(e){var t=Dr();return"function"===typeof e&&(e=e()),t.memoizedState=t.baseState=e,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Nr,lastRenderedState:e},t.queue=e,e=e.dispatch=li.bind(null,br,e),[t.memoizedState,e]}function Xr(e,t,n,r){return e={tag:e,create:t,destroy:n,deps:r,next:null},null===(t=br.updateQueue)?(t={lastEffect:null,stores:null},br.updateQueue=t,t.lastEffect=e.next=e):null===(n=t.lastEffect)?t.lastEffect=e.next=e:(r=n.next,n.next=e,e.next=r,t.lastEffect=e),e}function Jr(){return Ur().memoizedState}function Yr(e,t,n,r){var i=Dr();br.flags|=e,i.memoizedState=Xr(1|t,n,void 0,void 0===r?null:r)}function Kr(e,t,n,r){var i=Ur();r=void 0===r?null:r;var s=void 0;if(null!==Sr){var a=Sr.memoizedState;if(s=a.destroy,null!==r&&Ir(r,a.deps))return void(i.memoizedState=Xr(t,n,s,r))}br.flags|=e,i.memoizedState=Xr(1|t,n,s,r)}function qr(e,t){return Yr(8390656,8,e,t)}function Qr(e,t){return Kr(2048,8,e,t)}function Zr(e,t){return Kr(4,2,e,t)}function $r(e,t){return Kr(4,4,e,t)}function ei(e,t){return"function"===typeof t?(e=e(),t(e),function(){t(null)}):null!==t&&void 0!==t?(e=e(),t.current=e,function(){t.current=null}):void 0}function ti(e,t,n){return n=null!==n&&void 0!==n?n.concat([e]):null,Kr(4,4,ei.bind(null,t,e),n)}function ni(){}function ri(e,t){var n=Ur();t=void 0===t?null:t;var r=n.memoizedState;return null!==r&&null!==t&&Ir(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function ii(e,t){var n=Ur();t=void 0===t?null:t;var r=n.memoizedState;return null!==r&&null!==t&&Ir(t,r[1])?r[0]:(e=e(),n.memoizedState=[e,t],e)}function si(e,t){var n=Bt;Bt=0!==n&&4>n?n:4,e(!0);var r=Ar.transition;Ar.transition={};try{e(!1),t()}finally{Bt=n,Ar.transition=r}}function ai(){return Ur().memoizedState}function oi(e,t,n){var r=Aa(e);n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},ui(e)?ci(t,n):(hi(e,t,n),null!==(e=Ma(e,r,n=xa()))&&di(e,t,r))}function li(e,t,n){var r=Aa(e),i={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(ui(e))ci(t,i);else{hi(e,t,i);var s=e.alternate;if(0===e.lanes&&(null===s||0===s.lanes)&&null!==(s=t.lastRenderedReducer))try{var a=t.lastRenderedState,o=s(a,n);if(i.hasEagerState=!0,i.eagerState=o,jt(o,a))return}catch(l){}null!==(e=Ma(e,r,n=xa()))&&di(e,t,r)}}function ui(e){var t=e.alternate;return e===br||null!==t&&t===br}function ci(e,t){Tr=Er=!0;var n=e.pending;null===n?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function hi(e,t,n){null!==Ys&&0!==(1&e.mode)&&0===(2&Js)?(null===(e=t.interleaved)?(n.next=n,null===dn?dn=[t]:dn.push(t)):(n.next=e.next,e.next=n),t.interleaved=n):(null===(e=t.pending)?n.next=n:(n.next=e.next,e.next=n),t.pending=n)}function di(e,t,n){if(0!==(4194240&n)){var r=t.lanes;n|=r&=e.pendingLanes,t.lanes=n,It(e,n)}}var pi={readContext:hn,useCallback:Pr,useContext:Pr,useEffect:Pr,useImperativeHandle:Pr,useInsertionEffect:Pr,useLayoutEffect:Pr,useMemo:Pr,useReducer:Pr,useRef:Pr,useState:Pr,useDebugValue:Pr,useDeferredValue:Pr,useTransition:Pr,useMutableSource:Pr,useSyncExternalStore:Pr,useId:Pr,unstable_isNewReconciler:!1},fi={readContext:hn,useCallback:function(e,t){return Dr().memoizedState=[e,void 0===t?null:t],e},useContext:hn,useEffect:qr,useImperativeHandle:function(e,t,n){return n=null!==n&&void 0!==n?n.concat([e]):null,Yr(4194308,4,ei.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Yr(4194308,4,e,t)},useInsertionEffect:function(e,t){return Yr(4,2,e,t)},useMemo:function(e,t){var n=Dr();return t=void 0===t?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=Dr();return t=void 0!==n?n(t):t,r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=oi.bind(null,br,e),[r.memoizedState,e]},useRef:function(e){return e={current:e},Dr().memoizedState=e},useState:jr,useDebugValue:ni,useDeferredValue:function(e){var t=jr(e),n=t[0],r=t[1];return qr((function(){var t=Ar.transition;Ar.transition={};try{r(e)}finally{Ar.transition=t}}),[e]),n},useTransition:function(){var e=jr(!1),t=e[0];return e=si.bind(null,e[1]),Dr().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=br,i=Dr();if(Wn){if(void 0===n)throw Error(a(407));n=n()}else{if(n=t(),null===Ys)throw Error(a(349));0!==(30&Mr)||zr(r,t,n)}i.memoizedState=n;var s={value:n,getSnapshot:t};return i.queue=s,qr(Vr.bind(null,r,s,e),[e]),r.flags|=2048,Xr(9,Gr.bind(null,r,s,n,t),void 0,null),n},useId:function(){var e=Dr(),t=Ys.identifierPrefix;if(Wn){var n=Fn;t=":"+t+"R"+(n=(Nn&~(1<<32-xt(Nn)-1)).toString(32)+n),0<(n=Cr++)&&(t+="H"+n.toString(32)),t+=":"}else t=":"+t+"r"+(n=Rr++).toString(32)+":";return e.memoizedState=t},unstable_isNewReconciler:!1},mi={readContext:hn,useCallback:ri,useContext:hn,useEffect:Qr,useImperativeHandle:ti,useInsertionEffect:Zr,useLayoutEffect:$r,useMemo:ii,useReducer:Fr,useRef:Jr,useState:function(){return Fr(Nr)},useDebugValue:ni,useDeferredValue:function(e){var t=Fr(Nr),n=t[0],r=t[1];return Qr((function(){var t=Ar.transition;Ar.transition={};try{r(e)}finally{Ar.transition=t}}),[e]),n},useTransition:function(){return[Fr(Nr)[0],Ur().memoizedState]},useMutableSource:kr,useSyncExternalStore:Hr,useId:ai,unstable_isNewReconciler:!1},gi={readContext:hn,useCallback:ri,useContext:hn,useEffect:Qr,useImperativeHandle:ti,useInsertionEffect:Zr,useLayoutEffect:$r,useMemo:ii,useReducer:Or,useRef:Jr,useState:function(){return Or(Nr)},useDebugValue:ni,useDeferredValue:function(e){var t=Or(Nr),n=t[0],r=t[1];return Qr((function(){var t=Ar.transition;Ar.transition={};try{r(e)}finally{Ar.transition=t}}),[e]),n},useTransition:function(){return[Or(Nr)[0],Ur().memoizedState]},useMutableSource:kr,useSyncExternalStore:Hr,useId:ai,unstable_isNewReconciler:!1};function vi(e,t){try{var n="",r=t;do{n+=$t(r),r=r.return}while(r);var i=n}catch(s){i="\nError generating stack: "+s.message+"\n"+s.stack}return{value:e,source:t,stack:i}}function yi(e,t){try{console.error(t.value)}catch(n){setTimeout((function(){throw n}))}}var _i,xi,Ai,Mi,bi="function"===typeof WeakMap?WeakMap:Map;function Si(e,t,n){(n=gn(-1,n)).tag=3,n.payload={element:null};var r=t.value;return n.callback=function(){ca||(ca=!0,ha=r),yi(0,t)},n}function wi(e,t,n){(n=gn(-1,n)).tag=3;var r=e.type.getDerivedStateFromError;if("function"===typeof r){var i=t.value;n.payload=function(){return r(i)},n.callback=function(){yi(0,t)}}var s=e.stateNode;return null!==s&&"function"===typeof s.componentDidCatch&&(n.callback=function(){yi(0,t),"function"!==typeof r&&(null===da?da=new Set([this]):da.add(this));var e=t.stack;this.componentDidCatch(t.value,{componentStack:null!==e?e:""})}),n}function Ei(e,t,n){var r=e.pingCache;if(null===r){r=e.pingCache=new bi;var i=new Set;r.set(t,i)}else void 0===(i=r.get(t))&&(i=new Set,r.set(t,i));i.has(n)||(i.add(n),e=ja.bind(null,e,t,n),t.then(e,e))}function Ti(e){do{var t;if((t=13===e.tag)&&(t=null===(t=e.memoizedState)||null!==t.dehydrated),t)return e;e=e.return}while(null!==e);return null}function Ci(e,t,n,r,i){return 0===(1&e.mode)?(e===t?e.flags|=65536:(e.flags|=128,n.flags|=131072,n.flags&=-52805,1===n.tag&&(null===n.alternate?n.tag=17:((t=gn(-1,1)).tag=2,vn(n,t))),n.lanes|=1),e):(e.flags|=65536,e.lanes=i,e)}function Ri(e){e.flags|=4}function Pi(e,t){if(null!==e&&e.child===t.child)return!0;if(0!==(16&t.flags))return!1;for(e=t.child;null!==e;){if(0!==(12854&e.flags)||0!==(12854&e.subtreeFlags))return!1;e=e.sibling}return!0}if(Y)_i=function(e,t){for(var n=t.child;null!==n;){if(5===n.tag||6===n.tag)k(e,n.stateNode);else if(4!==n.tag&&null!==n.child){n.child.return=n,n=n.child;continue}if(n===t)break;for(;null===n.sibling;){if(null===n.return||n.return===t)return;n=n.return}n.sibling.return=n.return,n=n.sibling}},xi=function(){},Ai=function(e,t,n,r,i){if((e=e.memoizedProps)!==r){var s=t.stateNode,a=hr(lr.current);n=z(s,n,e,r,i,a),(t.updateQueue=n)&&Ri(t)}},Mi=function(e,t,n,r){n!==r&&Ri(t)};else if(K){_i=function(e,t,n,r){for(var i=t.child;null!==i;){if(5===i.tag){var s=i.stateNode;n&&r&&(s=Ie(s,i.type,i.memoizedProps,i)),k(e,s)}else if(6===i.tag)s=i.stateNode,n&&r&&(s=Be(s,i.memoizedProps,i)),k(e,s);else if(4!==i.tag)if(22===i.tag&&null!==i.memoizedState)null!==(s=i.child)&&(s.return=i),_i(e,i,!0,!0);else if(null!==i.child){i.child.return=i,i=i.child;continue}if(i===t)break;for(;null===i.sibling;){if(null===i.return||i.return===t)return;i=i.return}i.sibling.return=i.return,i=i.sibling}};var Ii=function(e,t,n,r){for(var i=t.child;null!==i;){if(5===i.tag){var s=i.stateNode;n&&r&&(s=Ie(s,i.type,i.memoizedProps,i)),Ce(e,s)}else if(6===i.tag)s=i.stateNode,n&&r&&(s=Be(s,i.memoizedProps,i)),Ce(e,s);else if(4!==i.tag)if(22===i.tag&&null!==i.memoizedState)null!==(s=i.child)&&(s.return=i),Ii(e,i,!0,!0);else if(null!==i.child){i.child.return=i,i=i.child;continue}if(i===t)break;for(;null===i.sibling;){if(null===i.return||i.return===t)return;i=i.return}i.sibling.return=i.return,i=i.sibling}};xi=function(e,t){var n=t.stateNode;if(!Pi(e,t)){e=n.containerInfo;var r=Te(e);Ii(r,t,!1,!1),n.pendingChildren=r,Ri(t),Re(e,r)}},Ai=function(e,t,n,r,i){var s=e.stateNode,a=e.memoizedProps;if((e=Pi(e,t))&&a===r)t.stateNode=s;else{var o=t.stateNode,l=hr(lr.current),u=null;a!==r&&(u=z(o,n,a,r,i,l)),e&&null===u?t.stateNode=s:(s=Ee(s,u,n,a,r,t,e,o),H(s,n,r,i,l)&&Ri(t),t.stateNode=s,e?Ri(t):_i(s,t,!1,!1))}},Mi=function(e,t,n,r){n!==r?(e=hr(cr.current),n=hr(lr.current),t.stateNode=V(r,e,n,t),Ri(t)):t.stateNode=e.stateNode}}else xi=function(){},Ai=function(){},Mi=function(){};function Bi(e,t){if(!Wn)switch(e.tailMode){case"hidden":t=e.tail;for(var n=null;null!==t;)null!==t.alternate&&(n=t),t=t.sibling;null===n?e.tail=null:n.sibling=null;break;case"collapsed":n=e.tail;for(var r=null;null!==n;)null!==n.alternate&&(r=n),n=n.sibling;null===r?t||null===e.tail?e.tail=null:e.tail.sibling=null:r.sibling=null}}function Li(e){var t=null!==e.alternate&&e.alternate.child===e.child,n=0,r=0;if(t)for(var i=e.child;null!==i;)n|=i.lanes|i.childLanes,r|=14680064&i.subtreeFlags,r|=14680064&i.flags,i.return=e,i=i.sibling;else for(i=e.child;null!==i;)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 Di(e,t,n){var r=t.pendingProps;switch(zn(t),t.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Li(t),null;case 1:case 17:return ft(t.type)&&mt(),Li(t),null;case 3:return r=t.stateNode,pr(),ot(ht),ot(ct),_r(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),null!==e&&null!==e.child||(Zn(t)?Ri(t):null===e||e.memoizedState.isDehydrated&&0===(256&t.flags)||(t.flags|=1024,null!==Xn&&(Ta(Xn),Xn=null))),xi(e,t),Li(t),null;case 5:mr(t),n=hr(cr.current);var i=t.type;if(null!==e&&null!=t.stateNode)Ai(e,t,i,r,n),e.ref!==t.ref&&(t.flags|=512,t.flags|=2097152);else{if(!r){if(null===t.stateNode)throw Error(a(166));return Li(t),null}if(e=hr(lr.current),Zn(t)){if(!q)throw Error(a(175));e=Ve(t.stateNode,t.type,t.memoizedProps,n,e,t,!jn),t.updateQueue=e,null!==e&&Ri(t)}else{var s=O(i,r,n,e,t);_i(s,t,!1,!1),t.stateNode=s,H(s,i,r,n,e)&&Ri(t)}null!==t.ref&&(t.flags|=512,t.flags|=2097152)}return Li(t),null;case 6:if(e&&null!=t.stateNode)Mi(e,t,e.memoizedProps,r);else{if("string"!==typeof r&&null===t.stateNode)throw Error(a(166));if(e=hr(cr.current),n=hr(lr.current),Zn(t)){if(!q)throw Error(a(176));if(e=t.stateNode,r=t.memoizedProps,(n=We(e,r,t,!jn))&&null!==(i=Gn))switch(s=0!==(1&i.mode),i.tag){case 3:Ze(i.stateNode.containerInfo,e,r,s);break;case 5:$e(i.type,i.memoizedProps,i.stateNode,e,r,s)}n&&Ri(t)}else t.stateNode=V(r,e,n,t)}return Li(t),null;case 13:if(ot(gr),r=t.memoizedState,Wn&&null!==Vn&&0!==(1&t.mode)&&0===(128&t.flags)){for(e=Vn;e;)e=ke(e);return $n(),t.flags|=98560,t}if(null!==r&&null!==r.dehydrated){if(r=Zn(t),null===e){if(!r)throw Error(a(318));if(!q)throw Error(a(344));if(!(e=null!==(e=t.memoizedState)?e.dehydrated:null))throw Error(a(317));je(e,t)}else $n(),0===(128&t.flags)&&(t.memoizedState=null),t.flags|=4;return Li(t),null}return null!==Xn&&(Ta(Xn),Xn=null),0!==(128&t.flags)?(t.lanes=n,t):(r=null!==r,n=!1,null===e?Zn(t):n=null!==e.memoizedState,r&&!n&&(t.child.flags|=8192,0!==(1&t.mode)&&(null===e||0!==(1&gr.current)?0===$s&&($s=3):Ua())),null!==t.updateQueue&&(t.flags|=4),Li(t),null);case 4:return pr(),xi(e,t),null===e&&Z(t.stateNode.containerInfo),Li(t),null;case 10:return ln(t.type._context),Li(t),null;case 19:if(ot(gr),null===(i=t.memoizedState))return Li(t),null;if(r=0!==(128&t.flags),null===(s=i.rendering))if(r)Bi(i,!1);else{if(0!==$s||null!==e&&0!==(128&e.flags))for(e=t.child;null!==e;){if(null!==(s=vr(e))){for(t.flags|=128,Bi(i,!1),null!==(e=s.updateQueue)&&(t.updateQueue=e,t.flags|=4),t.subtreeFlags=0,e=n,r=t.child;null!==r;)i=e,(n=r).flags&=14680066,null===(s=n.alternate)?(n.childLanes=0,n.lanes=i,n.child=null,n.subtreeFlags=0,n.memoizedProps=null,n.memoizedState=null,n.updateQueue=null,n.dependencies=null,n.stateNode=null):(n.childLanes=s.childLanes,n.lanes=s.lanes,n.child=s.child,n.subtreeFlags=0,n.deletions=null,n.memoizedProps=s.memoizedProps,n.memoizedState=s.memoizedState,n.updateQueue=s.updateQueue,n.type=s.type,i=s.dependencies,n.dependencies=null===i?null:{lanes:i.lanes,firstContext:i.firstContext}),r=r.sibling;return lt(gr,1&gr.current|2),t.child}e=e.sibling}null!==i.tail&&Ot()>oa&&(t.flags|=128,r=!0,Bi(i,!1),t.lanes=4194304)}else{if(!r)if(null!==(e=vr(s))){if(t.flags|=128,r=!0,null!==(e=e.updateQueue)&&(t.updateQueue=e,t.flags|=4),Bi(i,!0),null===i.tail&&"hidden"===i.tailMode&&!s.alternate&&!Wn)return Li(t),null}else 2*Ot()-i.renderingStartTime>oa&&1073741824!==n&&(t.flags|=128,r=!0,Bi(i,!1),t.lanes=4194304);i.isBackwards?(s.sibling=t.child,t.child=s):(null!==(e=i.last)?e.sibling=s:t.child=s,i.last=s)}return null!==i.tail?(t=i.tail,i.rendering=t,i.tail=t.sibling,i.renderingStartTime=Ot(),t.sibling=null,e=gr.current,lt(gr,r?1&e|2:1&e),t):(Li(t),null);case 22:case 23:return Ia(),r=null!==t.memoizedState,null!==e&&null!==e.memoizedState!==r&&(t.flags|=8192),r&&0!==(1&t.mode)?0!==(1073741824&Qs)&&(Li(t),Y&&6&t.subtreeFlags&&(t.flags|=8192)):Li(t),null;case 24:case 25:return null}throw Error(a(156,t.tag))}var Ui=o.ReactCurrentOwner,Ni=!1;function Fi(e,t,n,r){t.child=null===e?ar(t,null,n,r):sr(t,e.child,n,r)}function Oi(e,t,n,r,i){n=n.render;var s=t.ref;return cn(t,i),r=Br(e,t,n,r,s,i),n=Lr(),null===e||Ni?(Wn&&n&&Hn(t),t.flags|=1,Fi(e,t,r,i),t.child):(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~i,is(e,t,i))}function ki(e,t,n,r,i){if(null===e){var s=n.type;return"function"!==typeof s||Za(s)||void 0!==s.defaultProps||null!==n.compare||void 0!==n.defaultProps?((e=eo(n.type,null,r,t,t.mode,i)).ref=t.ref,e.return=t,t.child=e):(t.tag=15,t.type=s,Hi(e,t,s,r,i))}if(s=e.child,0===(e.lanes&i)){var a=s.memoizedProps;if((n=null!==(n=n.compare)?n:Zt)(a,r)&&e.ref===t.ref)return is(e,t,i)}return t.flags|=1,(e=$a(s,r)).ref=t.ref,e.return=t,t.child=e}function Hi(e,t,n,r,i){if(null!==e&&Zt(e.memoizedProps,r)&&e.ref===t.ref){if(Ni=!1,0===(e.lanes&i))return t.lanes=e.lanes,is(e,t,i);0!==(131072&e.flags)&&(Ni=!0)}return Vi(e,t,n,r,i)}function zi(e,t,n){var r=t.pendingProps,i=r.children,s=null!==e?e.memoizedState:null;if("hidden"===r.mode)if(0===(1&t.mode))t.memoizedState={baseLanes:0,cachePool:null},lt(Zs,Qs),Qs|=n;else{if(0===(1073741824&n))return e=null!==s?s.baseLanes|n:n,t.lanes=t.childLanes=1073741824,t.memoizedState={baseLanes:e,cachePool:null},t.updateQueue=null,lt(Zs,Qs),Qs|=e,null;t.memoizedState={baseLanes:0,cachePool:null},r=null!==s?s.baseLanes:n,lt(Zs,Qs),Qs|=r}else null!==s?(r=s.baseLanes|n,t.memoizedState=null):r=n,lt(Zs,Qs),Qs|=r;return Fi(e,t,i,n),t.child}function Gi(e,t){var n=t.ref;(null===e&&null!==n||null!==e&&e.ref!==n)&&(t.flags|=512,t.flags|=2097152)}function Vi(e,t,n,r,i){var s=ft(n)?dt:ct.current;return s=pt(t,s),cn(t,i),n=Br(e,t,n,r,s,i),r=Lr(),null===e||Ni?(Wn&&r&&Hn(t),t.flags|=1,Fi(e,t,n,i),t.child):(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~i,is(e,t,i))}function Wi(e,t,n,r,i){if(ft(n)){var s=!0;yt(t)}else s=!1;if(cn(t,i),null===t.stateNode)null!==e&&(e.alternate=null,t.alternate=null,t.flags|=2),En(t,n,r),Cn(t,n,r,i),r=!0;else if(null===e){var a=t.stateNode,o=t.memoizedProps;a.props=o;var l=a.context,u=n.contextType;"object"===typeof u&&null!==u?u=hn(u):u=pt(t,u=ft(n)?dt:ct.current);var c=n.getDerivedStateFromProps,h="function"===typeof c||"function"===typeof a.getSnapshotBeforeUpdate;h||"function"!==typeof a.UNSAFE_componentWillReceiveProps&&"function"!==typeof a.componentWillReceiveProps||(o!==r||l!==u)&&Tn(t,a,r,u),pn=!1;var d=t.memoizedState;a.state=d,xn(t,r,a,i),l=t.memoizedState,o!==r||d!==l||ht.current||pn?("function"===typeof c&&(bn(t,n,c,r),l=t.memoizedState),(o=pn||wn(t,n,o,r,d,l,u))?(h||"function"!==typeof a.UNSAFE_componentWillMount&&"function"!==typeof a.componentWillMount||("function"===typeof a.componentWillMount&&a.componentWillMount(),"function"===typeof a.UNSAFE_componentWillMount&&a.UNSAFE_componentWillMount()),"function"===typeof a.componentDidMount&&(t.flags|=4194308)):("function"===typeof a.componentDidMount&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=l),a.props=r,a.state=l,a.context=u,r=o):("function"===typeof a.componentDidMount&&(t.flags|=4194308),r=!1)}else{a=t.stateNode,mn(e,t),o=t.memoizedProps,u=t.type===t.elementType?o:en(t.type,o),a.props=u,h=t.pendingProps,d=a.context,"object"===typeof(l=n.contextType)&&null!==l?l=hn(l):l=pt(t,l=ft(n)?dt:ct.current);var p=n.getDerivedStateFromProps;(c="function"===typeof p||"function"===typeof a.getSnapshotBeforeUpdate)||"function"!==typeof a.UNSAFE_componentWillReceiveProps&&"function"!==typeof a.componentWillReceiveProps||(o!==h||d!==l)&&Tn(t,a,r,l),pn=!1,d=t.memoizedState,a.state=d,xn(t,r,a,i);var f=t.memoizedState;o!==h||d!==f||ht.current||pn?("function"===typeof p&&(bn(t,n,p,r),f=t.memoizedState),(u=pn||wn(t,n,u,r,d,f,l)||!1)?(c||"function"!==typeof a.UNSAFE_componentWillUpdate&&"function"!==typeof a.componentWillUpdate||("function"===typeof a.componentWillUpdate&&a.componentWillUpdate(r,f,l),"function"===typeof a.UNSAFE_componentWillUpdate&&a.UNSAFE_componentWillUpdate(r,f,l)),"function"===typeof a.componentDidUpdate&&(t.flags|=4),"function"===typeof a.getSnapshotBeforeUpdate&&(t.flags|=1024)):("function"!==typeof a.componentDidUpdate||o===e.memoizedProps&&d===e.memoizedState||(t.flags|=4),"function"!==typeof a.getSnapshotBeforeUpdate||o===e.memoizedProps&&d===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=f),a.props=r,a.state=f,a.context=l,r=u):("function"!==typeof a.componentDidUpdate||o===e.memoizedProps&&d===e.memoizedState||(t.flags|=4),"function"!==typeof a.getSnapshotBeforeUpdate||o===e.memoizedProps&&d===e.memoizedState||(t.flags|=1024),r=!1)}return ji(e,t,n,r,s,i)}function ji(e,t,n,r,i,s){Gi(e,t);var a=0!==(128&t.flags);if(!r&&!a)return i&&_t(t,n,!1),is(e,t,s);r=t.stateNode,Ui.current=t;var o=a&&"function"!==typeof n.getDerivedStateFromError?null:r.render();return t.flags|=1,null!==e&&a?(t.child=sr(t,e.child,null,s),t.child=sr(t,null,o,s)):Fi(e,t,o,s),t.memoizedState=r.state,i&&_t(t,n,!0),t.child}function Xi(e){var t=e.stateNode;t.pendingContext?gt(0,t.pendingContext,t.pendingContext!==t.context):t.context&&gt(0,t.context,!1),dr(e,t.containerInfo)}function Ji(e,t,n,r,i){return $n(),er(i),t.flags|=256,Fi(e,t,n,r),t.child}var Yi={dehydrated:null,treeContext:null,retryLane:0};function Ki(e){return{baseLanes:e,cachePool:null}}function qi(e,t,n){var r,i=t.pendingProps,s=gr.current,o=!1,l=0!==(128&t.flags);if((r=l)||(r=(null===e||null!==e.memoizedState)&&0!==(2&s)),r?(o=!0,t.flags&=-129):null!==e&&null===e.memoizedState||(s|=1),lt(gr,1&s),null===e)return qn(t),null!==(e=t.memoizedState)&&null!==(e=e.dehydrated)?(0===(1&t.mode)?t.lanes=1:Fe(e)?t.lanes=8:t.lanes=1073741824,null):(s=i.children,e=i.fallback,o?(i=t.mode,o=t.child,s={mode:"hidden",children:s},0===(1&i)&&null!==o?(o.childLanes=0,o.pendingProps=s):o=no(s,i,0,null),e=to(e,i,n,null),o.return=t,e.return=t,o.sibling=e,t.child=o,t.child.memoizedState=Ki(n),t.memoizedState=Yi,e):Qi(t,s));if(null!==(s=e.memoizedState)){if(null!==(r=s.dehydrated)){if(l)return 256&t.flags?(t.flags&=-257,es(e,t,n,Error(a(422)))):null!==t.memoizedState?(t.child=e.child,t.flags|=128,null):(o=i.fallback,s=t.mode,i=no({mode:"visible",children:i.children},s,0,null),(o=to(o,s,n,null)).flags|=2,i.return=t,o.return=t,i.sibling=o,t.child=i,0!==(1&t.mode)&&sr(t,e.child,null,n),t.child.memoizedState=Ki(n),t.memoizedState=Yi,o);if(0===(1&t.mode))t=es(e,t,n,null);else if(Fe(r))t=es(e,t,n,Error(a(419)));else if(i=0!==(n&e.childLanes),Ni||i){if(null!==(i=Ys)){switch(n&-n){case 4:o=2;break;case 16:o=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:o=32;break;case 536870912:o=268435456;break;default:o=0}0!==(i=0!==(o&(i.suspendedLanes|n))?0:o)&&i!==s.retryLane&&(s.retryLane=i,Ma(e,i,-1))}Ua(),t=es(e,t,n,Error(a(421)))}else Ne(r)?(t.flags|=128,t.child=e.child,t=Ja.bind(null,e),Oe(r,t),t=null):(n=s.treeContext,q&&(Vn=Ge(r),Gn=t,Wn=!0,Xn=null,jn=!1,null!==n&&(Ln[Dn++]=Nn,Ln[Dn++]=Fn,Ln[Dn++]=Un,Nn=n.id,Fn=n.overflow,Un=t)),(t=Qi(t,t.pendingProps.children)).flags|=4096);return t}return o?(i=$i(e,t,i.children,i.fallback,n),o=t.child,s=e.child.memoizedState,o.memoizedState=null===s?Ki(n):{baseLanes:s.baseLanes|n,cachePool:null},o.childLanes=e.childLanes&~n,t.memoizedState=Yi,i):(n=Zi(e,t,i.children,n),t.memoizedState=null,n)}return o?(i=$i(e,t,i.children,i.fallback,n),o=t.child,s=e.child.memoizedState,o.memoizedState=null===s?Ki(n):{baseLanes:s.baseLanes|n,cachePool:null},o.childLanes=e.childLanes&~n,t.memoizedState=Yi,i):(n=Zi(e,t,i.children,n),t.memoizedState=null,n)}function Qi(e,t){return(t=no({mode:"visible",children:t},e.mode,0,null)).return=e,e.child=t}function Zi(e,t,n,r){var i=e.child;return e=i.sibling,n=$a(i,{mode:"visible",children:n}),0===(1&t.mode)&&(n.lanes=r),n.return=t,n.sibling=null,null!==e&&(null===(r=t.deletions)?(t.deletions=[e],t.flags|=16):r.push(e)),t.child=n}function $i(e,t,n,r,i){var s=t.mode,a=(e=e.child).sibling,o={mode:"hidden",children:n};return 0===(1&s)&&t.child!==e?((n=t.child).childLanes=0,n.pendingProps=o,t.deletions=null):(n=$a(e,o)).subtreeFlags=14680064&e.subtreeFlags,null!==a?r=$a(a,r):(r=to(r,s,i,null)).flags|=2,r.return=t,n.return=t,n.sibling=r,t.child=n,r}function es(e,t,n,r){return null!==r&&er(r),sr(t,e.child,null,n),(e=Qi(t,t.pendingProps.children)).flags|=2,t.memoizedState=null,e}function ts(e,t,n){e.lanes|=t;var r=e.alternate;null!==r&&(r.lanes|=t),un(e.return,t,n)}function ns(e,t,n,r,i){var s=e.memoizedState;null===s?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:i}:(s.isBackwards=t,s.rendering=null,s.renderingStartTime=0,s.last=r,s.tail=n,s.tailMode=i)}function rs(e,t,n){var r=t.pendingProps,i=r.revealOrder,s=r.tail;if(Fi(e,t,r.children,n),0!==(2&(r=gr.current)))r=1&r|2,t.flags|=128;else{if(null!==e&&0!==(128&e.flags))e:for(e=t.child;null!==e;){if(13===e.tag)null!==e.memoizedState&&ts(e,n,t);else if(19===e.tag)ts(e,n,t);else if(null!==e.child){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;null===e.sibling;){if(null===e.return||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}r&=1}if(lt(gr,r),0===(1&t.mode))t.memoizedState=null;else switch(i){case"forwards":for(n=t.child,i=null;null!==n;)null!==(e=n.alternate)&&null===vr(e)&&(i=n),n=n.sibling;null===(n=i)?(i=t.child,t.child=null):(i=n.sibling,n.sibling=null),ns(t,!1,i,n,s);break;case"backwards":for(n=null,i=t.child,t.child=null;null!==i;){if(null!==(e=i.alternate)&&null===vr(e)){t.child=i;break}e=i.sibling,i.sibling=n,n=i,i=e}ns(t,!0,n,null,s);break;case"together":ns(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function is(e,t,n){if(null!==e&&(t.dependencies=e.dependencies),ta|=t.lanes,0===(n&t.childLanes))return null;if(null!==e&&t.child!==e.child)throw Error(a(153));if(null!==t.child){for(n=$a(e=t.child,e.pendingProps),t.child=n,n.return=t;null!==e.sibling;)e=e.sibling,(n=n.sibling=$a(e,e.pendingProps)).return=t;n.sibling=null}return t.child}function ss(e,t){switch(zn(t),t.tag){case 1:return ft(t.type)&&mt(),65536&(e=t.flags)?(t.flags=-65537&e|128,t):null;case 3:return pr(),ot(ht),ot(ct),_r(),0!==(65536&(e=t.flags))&&0===(128&e)?(t.flags=-65537&e|128,t):null;case 5:return mr(t),null;case 13:if(ot(gr),null!==(e=t.memoizedState)&&null!==e.dehydrated){if(null===t.alternate)throw Error(a(340));$n()}return 65536&(e=t.flags)?(t.flags=-65537&e|128,t):null;case 19:return ot(gr),null;case 4:return pr(),null;case 10:return ln(t.type._context),null;case 22:case 23:return Ia(),null;default:return null}}var as=!1,os=!1,ls="function"===typeof WeakSet?WeakSet:Set,us=null;function cs(e,t){var n=e.ref;if(null!==n)if("function"===typeof n)try{n(null)}catch(r){Wa(e,t,r)}else n.current=null}function hs(e,t,n){try{n()}catch(r){Wa(e,t,r)}}var ds=!1;function ps(e,t,n){var r=t.updateQueue;if(null!==(r=null!==r?r.lastEffect:null)){var i=r=r.next;do{if((i.tag&e)===e){var s=i.destroy;i.destroy=void 0,void 0!==s&&hs(t,n,s)}i=i.next}while(i!==r)}}function fs(e,t){if(null!==(t=null!==(t=t.updateQueue)?t.lastEffect:null)){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function ms(e){var t=e.ref;if(null!==t){var n=e.stateNode;if(5===e.tag)e=L(n);else e=n;"function"===typeof t?t(e):t.current=e}}function gs(e,t,n){if(Wt&&"function"===typeof Wt.onCommitFiberUnmount)try{Wt.onCommitFiberUnmount(Vt,t)}catch(a){}switch(t.tag){case 0:case 11:case 14:case 15:if(null!==(e=t.updateQueue)&&null!==(e=e.lastEffect)){var r=e=e.next;do{var i=r,s=i.destroy;i=i.tag,void 0!==s&&(0!==(2&i)||0!==(4&i))&&hs(t,n,s),r=r.next}while(r!==e)}break;case 1:if(cs(t,n),"function"===typeof(e=t.stateNode).componentWillUnmount)try{e.props=t.memoizedProps,e.state=t.memoizedState,e.componentWillUnmount()}catch(a){Wa(t,n,a)}break;case 5:cs(t,n);break;case 4:Y?Ss(e,t,n):K&&K&&(t=t.stateNode.containerInfo,n=Te(t),Pe(t,n))}}function vs(e,t,n){for(var r=t;;)if(gs(e,r,n),null===r.child||Y&&4===r.tag){if(r===t)break;for(;null===r.sibling;){if(null===r.return||r.return===t)return;r=r.return}r.sibling.return=r.return,r=r.sibling}else r.child.return=r,r=r.child}function ys(e){var t=e.alternate;null!==t&&(e.alternate=null,ys(t)),e.child=null,e.deletions=null,e.sibling=null,5===e.tag&&(null!==(t=e.stateNode)&&ee(t)),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function _s(e){return 5===e.tag||3===e.tag||4===e.tag}function xs(e){e:for(;;){for(;null===e.sibling;){if(null===e.return||_s(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;5!==e.tag&&6!==e.tag&&18!==e.tag;){if(2&e.flags)continue e;if(null===e.child||4===e.tag)continue e;e.child.return=e,e=e.child}if(!(2&e.flags))return e.stateNode}}function As(e){if(Y){e:{for(var t=e.return;null!==t;){if(_s(t))break e;t=t.return}throw Error(a(160))}var n=t;switch(n.tag){case 5:t=n.stateNode,32&n.flags&&(xe(t),n.flags&=-33),bs(e,n=xs(e),t);break;case 3:case 4:t=n.stateNode.containerInfo,Ms(e,n=xs(e),t);break;default:throw Error(a(161))}}}function Ms(e,t,n){var r=e.tag;if(5===r||6===r)e=e.stateNode,t?ve(n,e,t):de(n,e);else if(4!==r&&null!==(e=e.child))for(Ms(e,t,n),e=e.sibling;null!==e;)Ms(e,t,n),e=e.sibling}function bs(e,t,n){var r=e.tag;if(5===r||6===r)e=e.stateNode,t?ge(n,e,t):he(n,e);else if(4!==r&&null!==(e=e.child))for(bs(e,t,n),e=e.sibling;null!==e;)bs(e,t,n),e=e.sibling}function Ss(e,t,n){for(var r,i,s=t,o=!1;;){if(!o){o=s.return;e:for(;;){if(null===o)throw Error(a(160));switch(r=o.stateNode,o.tag){case 5:i=!1;break e;case 3:case 4:r=r.containerInfo,i=!0;break e}o=o.return}o=!0}if(5===s.tag||6===s.tag)vs(e,s,n),i?_e(r,s.stateNode):ye(r,s.stateNode);else if(18===s.tag)i?qe(r,s.stateNode):Ke(r,s.stateNode);else if(4===s.tag){if(null!==s.child){r=s.stateNode.containerInfo,i=!0,s.child.return=s,s=s.child;continue}}else if(gs(e,s,n),null!==s.child){s.child.return=s,s=s.child;continue}if(s===t)break;for(;null===s.sibling;){if(null===s.return||s.return===t)return;4===(s=s.return).tag&&(o=!1)}s.sibling.return=s.return,s=s.sibling}}function ws(e,t){if(Y){switch(t.tag){case 0:case 11:case 14:case 15:return ps(3,t,t.return),fs(3,t),void ps(5,t,t.return);case 1:case 12:case 17:return;case 5:var n=t.stateNode;if(null!=n){var r=t.memoizedProps;e=null!==e?e.memoizedProps:r;var i=t.type,s=t.updateQueue;t.updateQueue=null,null!==s&&me(n,s,i,e,r,t)}return;case 6:if(null===t.stateNode)throw Error(a(162));return n=t.memoizedProps,void pe(t.stateNode,null!==e?e.memoizedProps:n,n);case 3:return void(q&&null!==e&&e.memoizedState.isDehydrated&&Je(t.stateNode.containerInfo));case 13:case 19:return void Es(t)}throw Error(a(163))}switch(t.tag){case 0:case 11:case 14:case 15:return ps(3,t,t.return),fs(3,t),void ps(5,t,t.return);case 12:case 22:case 23:return;case 13:case 19:return void Es(t);case 3:q&&null!==e&&e.memoizedState.isDehydrated&&Je(t.stateNode.containerInfo)}e:if(K){switch(t.tag){case 1:case 5:case 6:break e;case 3:case 4:t=t.stateNode,Pe(t.containerInfo,t.pendingChildren);break e}throw Error(a(163))}}function Es(e){var t=e.updateQueue;if(null!==t){e.updateQueue=null;var n=e.stateNode;null===n&&(n=e.stateNode=new ls),t.forEach((function(t){var r=Ya.bind(null,e,t);n.has(t)||(n.add(t),t.then(r,r))}))}}function Ts(e,t,n){us=e,Cs(e,t,n)}function Cs(e,t,n){for(var r=0!==(1&e.mode);null!==us;){var i=us,s=i.child;if(22===i.tag&&r){var a=null!==i.memoizedState||as;if(!a){var o=i.alternate,l=null!==o&&null!==o.memoizedState||os;o=as;var u=os;if(as=a,(os=l)&&!u)for(us=i;null!==us;)l=(a=us).child,22===a.tag&&null!==a.memoizedState?Is(i):null!==l?(l.return=a,us=l):Is(i);for(;null!==s;)us=s,Cs(s,t,n),s=s.sibling;us=i,as=o,os=u}Rs(e)}else 0!==(8772&i.subtreeFlags)&&null!==s?(s.return=i,us=s):Rs(e)}}function Rs(e){for(;null!==us;){var t=us;if(0!==(8772&t.flags)){var n=t.alternate;try{if(0!==(8772&t.flags))switch(t.tag){case 0:case 11:case 15:os||fs(5,t);break;case 1:var r=t.stateNode;if(4&t.flags&&!os)if(null===n)r.componentDidMount();else{var i=t.elementType===t.type?n.memoizedProps:en(t.type,n.memoizedProps);r.componentDidUpdate(i,n.memoizedState,r.__reactInternalSnapshotBeforeUpdate)}var s=t.updateQueue;null!==s&&An(t,s,r);break;case 3:var o=t.updateQueue;if(null!==o){if(n=null,null!==t.child)switch(t.child.tag){case 5:n=L(t.child.stateNode);break;case 1:n=t.child.stateNode}An(t,o,n)}break;case 5:var l=t.stateNode;null===n&&4&t.flags&&fe(l,t.type,t.memoizedProps,t);break;case 6:case 4:case 12:case 19:case 17:case 21:case 22:case 23:break;case 13:if(q&&null===t.memoizedState){var u=t.alternate;if(null!==u){var c=u.memoizedState;if(null!==c){var h=c.dehydrated;null!==h&&Ye(h)}}}break;default:throw Error(a(163))}os||512&t.flags&&ms(t)}catch(d){Wa(t,t.return,d)}}if(t===e){us=null;break}if(null!==(n=t.sibling)){n.return=t.return,us=n;break}us=t.return}}function Ps(e){for(;null!==us;){var t=us;if(t===e){us=null;break}var n=t.sibling;if(null!==n){n.return=t.return,us=n;break}us=t.return}}function Is(e){for(;null!==us;){var t=us;try{switch(t.tag){case 0:case 11:case 15:var n=t.return;try{fs(4,t)}catch(l){Wa(t,n,l)}break;case 1:var r=t.stateNode;if("function"===typeof r.componentDidMount){var i=t.return;try{r.componentDidMount()}catch(l){Wa(t,i,l)}}var s=t.return;try{ms(t)}catch(l){Wa(t,s,l)}break;case 5:var a=t.return;try{ms(t)}catch(l){Wa(t,a,l)}}}catch(l){Wa(t,t.return,l)}if(t===e){us=null;break}var o=t.sibling;if(null!==o){o.return=t.return,us=o;break}us=t.return}}var Bs=0,Ls=1,Ds=2,Us=3,Ns=4;if("function"===typeof Symbol&&Symbol.for){var Fs=Symbol.for;Bs=Fs("selector.component"),Ls=Fs("selector.has_pseudo_class"),Ds=Fs("selector.role"),Us=Fs("selector.test_id"),Ns=Fs("selector.text")}function Os(e){var t=Q(e);if(null!=t){if("string"!==typeof t.memoizedProps["data-testname"])throw Error(a(364));return t}if(null===(e=ie(e)))throw Error(a(362));return e.stateNode.current}function ks(e,t){switch(t.$$typeof){case Bs:if(e.type===t.value)return!0;break;case Ls:e:{t=t.value,e=[e,0];for(var n=0;n<e.length;){var r=e[n++],i=e[n++],s=t[i];if(5!==r.tag||!oe(r)){for(;null!=s&&ks(r,s);)s=t[++i];if(i===t.length){t=!0;break e}for(r=r.child;null!==r;)e.push(r,i),r=r.sibling}}t=!1}return t;case Ds:if(5===e.tag&&le(e.stateNode,t.value))return!0;break;case Ns:if((5===e.tag||6===e.tag)&&(null!==(e=ae(e))&&0<=e.indexOf(t.value)))return!0;break;case Us:if(5===e.tag&&("string"===typeof(e=e.memoizedProps["data-testname"])&&e.toLowerCase()===t.value.toLowerCase()))return!0;break;default:throw Error(a(365))}return!1}function Hs(e){switch(e.$$typeof){case Bs:return"<"+(b(e.value)||"Unknown")+">";case Ls:return":has("+(Hs(e)||"")+")";case Ds:return'[role="'+e.value+'"]';case Ns:return'"'+e.value+'"';case Us:return'[data-testname="'+e.value+'"]';default:throw Error(a(365))}}function zs(e,t){var n=[];e=[e,0];for(var r=0;r<e.length;){var i=e[r++],s=e[r++],a=t[s];if(5!==i.tag||!oe(i)){for(;null!=a&&ks(i,a);)a=t[++s];if(s===t.length)n.push(i);else for(i=i.child;null!==i;)e.push(i,s),i=i.sibling}}return n}function Gs(e,t){if(!re)throw Error(a(363));e=zs(e=Os(e),t),t=[],e=Array.from(e);for(var n=0;n<e.length;){var r=e[n++];if(5===r.tag)oe(r)||t.push(r.stateNode);else for(r=r.child;null!==r;)e.push(r),r=r.sibling}return t}var Vs=Math.ceil,Ws=o.ReactCurrentDispatcher,js=o.ReactCurrentOwner,Xs=o.ReactCurrentBatchConfig,Js=0,Ys=null,Ks=null,qs=0,Qs=0,Zs=at(0),$s=0,ea=null,ta=0,na=0,ra=0,ia=null,sa=null,aa=0,oa=1/0;function la(){oa=Ot()+500}var ua,ca=!1,ha=null,da=null,pa=!1,fa=null,ma=0,ga=0,va=null,ya=-1,_a=0;function xa(){return 0!==(6&Js)?Ot():-1!==ya?ya:ya=Ot()}function Aa(e){return 0===(1&e.mode)?1:0!==(2&Js)&&0!==qs?qs&-qs:null!==Qt.transition?(0===_a&&(e=bt,0===(4194240&(bt<<=1))&&(bt=64),_a=e),_a):0!==(e=Bt)?e:$()}function Ma(e,t,n){if(50<ga)throw ga=0,va=null,Error(a(185));var r=ba(e,t);return null===r?null:(Pt(r,t,n),0!==(2&Js)&&r===Ys||(r===Ys&&(0===(2&Js)&&(na|=t),4===$s&&Ca(r,qs)),Sa(r,n),1===t&&0===Js&&0===(1&e.mode)&&(la(),Jt&&qt())),r)}function ba(e,t){e.lanes|=t;var n=e.alternate;for(null!==n&&(n.lanes|=t),n=e,e=e.return;null!==e;)e.childLanes|=t,null!==(n=e.alternate)&&(n.childLanes|=t),n=e,e=e.return;return 3===n.tag?n.stateNode:null}function Sa(e,t){var n=e.callbackNode;!function(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,i=e.expirationTimes,s=e.pendingLanes;0<s;){var a=31-xt(s),o=1<<a,l=i[a];-1===l?0!==(o&n)&&0===(o&r)||(i[a]=Tt(o,t)):l<=t&&(e.expiredLanes|=o),s&=~o}}(e,t);var r=Et(e,e===Ys?qs:0);if(0===r)null!==n&&Ut(n),e.callbackNode=null,e.callbackPriority=0;else if(t=r&-r,e.callbackPriority!==t){if(null!=n&&Ut(n),1===t)0===e.tag?function(e){Jt=!0,Kt(e)}(Ra.bind(null,e)):Kt(Ra.bind(null,e)),te?ne((function(){0===Js&&qt()})):Dt(kt,qt),n=null;else{switch(Lt(r)){case 1:n=kt;break;case 4:n=Ht;break;case 16:default:n=zt;break;case 536870912:n=Gt}n=Ka(n,wa.bind(null,e))}e.callbackPriority=t,e.callbackNode=n}}function wa(e,t){if(ya=-1,_a=0,0!==(6&Js))throw Error(a(327));var n=e.callbackNode;if(Ga()&&e.callbackNode!==n)return null;var r=Et(e,e===Ys?qs:0);if(0===r)return null;if(0!==(30&r)||0!==(r&e.expiredLanes)||t)t=Na(e,r);else{t=r;var i=Js;Js|=2;var s=Da();for(Ys===e&&qs===t||(la(),Ba(e,t));;)try{Oa();break}catch(l){La(e,l)}an(),Ws.current=s,Js=i,null!==Ks?t=0:(Ys=null,qs=0,t=$s)}if(0!==t){if(2===t&&(0!==(i=Ct(e))&&(r=i,t=Ea(e,i))),1===t)throw n=ea,Ba(e,0),Ca(e,r),Sa(e,Ot()),n;if(6===t)Ca(e,r);else{if(i=e.current.alternate,0===(30&r)&&!function(e){for(var t=e;;){if(16384&t.flags){var n=t.updateQueue;if(null!==n&&null!==(n=n.stores))for(var r=0;r<n.length;r++){var i=n[r],s=i.getSnapshot;i=i.value;try{if(!jt(s(),i))return!1}catch(o){return!1}}}if(n=t.child,16384&t.subtreeFlags&&null!==n)n.return=t,t=n;else{if(t===e)break;for(;null===t.sibling;){if(null===t.return||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}(i)&&(2===(t=Na(e,r))&&(0!==(s=Ct(e))&&(r=s,t=Ea(e,s))),1===t))throw n=ea,Ba(e,0),Ca(e,r),Sa(e,Ot()),n;switch(e.finishedWork=i,e.finishedLanes=r,t){case 0:case 1:throw Error(a(345));case 2:case 5:za(e,sa);break;case 3:if(Ca(e,r),(130023424&r)===r&&10<(t=aa+500-Ot())){if(0!==Et(e,0))break;if(((i=e.suspendedLanes)&r)!==r){xa(),e.pingedLanes|=e.suspendedLanes&i;break}e.timeoutHandle=W(za.bind(null,e,sa),t);break}za(e,sa);break;case 4:if(Ca(e,r),(4194240&r)===r)break;for(t=e.eventTimes,i=-1;0<r;){var o=31-xt(r);s=1<<o,(o=t[o])>i&&(i=o),r&=~s}if(r=i,10<(r=(120>(r=Ot()-r)?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*Vs(r/1960))-r)){e.timeoutHandle=W(za.bind(null,e,sa),r);break}za(e,sa);break;default:throw Error(a(329))}}}return Sa(e,Ot()),e.callbackNode===n?wa.bind(null,e):null}function Ea(e,t){var n=ia;return e.current.memoizedState.isDehydrated&&(Ba(e,t).flags|=256),2!==(e=Na(e,t))&&(t=sa,sa=n,null!==t&&Ta(t)),e}function Ta(e){null===sa?sa=e:sa.push.apply(sa,e)}function Ca(e,t){for(t&=~ra,t&=~na,e.suspendedLanes|=t,e.pingedLanes&=~t,e=e.expirationTimes;0<t;){var n=31-xt(t),r=1<<n;e[n]=-1,t&=~r}}function Ra(e){if(0!==(6&Js))throw Error(a(327));Ga();var t=Et(e,0);if(0===(1&t))return Sa(e,Ot()),null;var n=Na(e,t);if(0!==e.tag&&2===n){var r=Ct(e);0!==r&&(t=r,n=Ea(e,r))}if(1===n)throw n=ea,Ba(e,0),Ca(e,t),Sa(e,Ot()),n;if(6===n)throw Error(a(345));return e.finishedWork=e.current.alternate,e.finishedLanes=t,za(e,sa),Sa(e,Ot()),null}function Pa(e){null!==fa&&0===fa.tag&&0===(6&Js)&&Ga();var t=Js;Js|=1;var n=Xs.transition,r=Bt;try{if(Xs.transition=null,Bt=1,e)return e()}finally{Bt=r,Xs.transition=n,0===(6&(Js=t))&&qt()}}function Ia(){Qs=Zs.current,ot(Zs)}function Ba(e,t){e.finishedWork=null,e.finishedLanes=0;var n=e.timeoutHandle;if(n!==X&&(e.timeoutHandle=X,j(n)),null!==Ks)for(n=Ks.return;null!==n;){var r=n;switch(zn(r),r.tag){case 1:null!==(r=r.type.childContextTypes)&&void 0!==r&&mt();break;case 3:pr(),ot(ht),ot(ct),_r();break;case 5:mr(r);break;case 4:pr();break;case 13:case 19:ot(gr);break;case 10:ln(r.type._context);break;case 22:case 23:Ia()}n=n.return}if(Ys=e,Ks=e=$a(e.current,null),qs=Qs=t,$s=0,ea=null,ra=na=ta=0,sa=ia=null,null!==dn){for(t=0;t<dn.length;t++)if(null!==(r=(n=dn[t]).interleaved)){n.interleaved=null;var i=r.next,s=n.pending;if(null!==s){var a=s.next;s.next=i,r.next=a}n.pending=r}dn=null}return e}function La(e,t){for(;;){var n=Ks;try{if(an(),xr.current=pi,Er){for(var r=br.memoizedState;null!==r;){var i=r.queue;null!==i&&(i.pending=null),r=r.next}Er=!1}if(Mr=0,wr=Sr=br=null,Tr=!1,Cr=0,js.current=null,null===n||null===n.return){$s=1,ea=t,Ks=null;break}e:{var s=e,o=n.return,l=n,u=t;if(t=qs,l.flags|=32768,null!==u&&"object"===typeof u&&"function"===typeof u.then){var c=u,h=l,d=h.tag;if(0===(1&h.mode)&&(0===d||11===d||15===d)){var p=h.alternate;p?(h.updateQueue=p.updateQueue,h.memoizedState=p.memoizedState,h.lanes=p.lanes):(h.updateQueue=null,h.memoizedState=null)}var f=Ti(o);if(null!==f){f.flags&=-257,Ci(f,o,l,0,t),1&f.mode&&Ei(s,c,t),u=c;var m=(t=f).updateQueue;if(null===m){var g=new Set;g.add(u),t.updateQueue=g}else m.add(u);break e}if(0===(1&t)){Ei(s,c,t),Ua();break e}u=Error(a(426))}else if(Wn&&1&l.mode){var v=Ti(o);if(null!==v){0===(65536&v.flags)&&(v.flags|=256),Ci(v,o,l,0,t),er(u);break e}}s=u,4!==$s&&($s=2),null===ia?ia=[s]:ia.push(s),u=vi(u,l),l=o;do{switch(l.tag){case 3:l.flags|=65536,t&=-t,l.lanes|=t,_n(l,Si(0,u,t));break e;case 1:s=u;var y=l.type,_=l.stateNode;if(0===(128&l.flags)&&("function"===typeof y.getDerivedStateFromError||null!==_&&"function"===typeof _.componentDidCatch&&(null===da||!da.has(_)))){l.flags|=65536,t&=-t,l.lanes|=t,_n(l,wi(l,s,t));break e}}l=l.return}while(null!==l)}Ha(n)}catch(x){t=x,Ks===n&&null!==n&&(Ks=n=n.return);continue}break}}function Da(){var e=Ws.current;return Ws.current=pi,null===e?pi:e}function Ua(){0!==$s&&3!==$s&&2!==$s||($s=4),null===Ys||0===(268435455&ta)&&0===(268435455&na)||Ca(Ys,qs)}function Na(e,t){var n=Js;Js|=2;var r=Da();for(Ys===e&&qs===t||Ba(e,t);;)try{Fa();break}catch(i){La(e,i)}if(an(),Js=n,Ws.current=r,null!==Ks)throw Error(a(261));return Ys=null,qs=0,$s}function Fa(){for(;null!==Ks;)ka(Ks)}function Oa(){for(;null!==Ks&&!Nt();)ka(Ks)}function ka(e){var t=ua(e.alternate,e,Qs);e.memoizedProps=e.pendingProps,null===t?Ha(e):Ks=t,js.current=null}function Ha(e){var t=e;do{var n=t.alternate;if(e=t.return,0===(32768&t.flags)){if(null!==(n=Di(n,t,Qs)))return void(Ks=n)}else{if(null!==(n=ss(n,t)))return n.flags&=32767,void(Ks=n);if(null===e)return $s=6,void(Ks=null);e.flags|=32768,e.subtreeFlags=0,e.deletions=null}if(null!==(t=t.sibling))return void(Ks=t);Ks=t=e}while(null!==t);0===$s&&($s=5)}function za(e,t){var n=Bt,r=Xs.transition;try{Xs.transition=null,Bt=1,function(e,t,n){do{Ga()}while(null!==fa);if(0!==(6&Js))throw Error(a(327));var r=e.finishedWork,i=e.finishedLanes;if(null===r)return null;if(e.finishedWork=null,e.finishedLanes=0,r===e.current)throw Error(a(177));e.callbackNode=null,e.callbackPriority=0;var s=r.lanes|r.childLanes;if(function(e,t){var n=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0<n;){var i=31-xt(n),s=1<<i;t[i]=0,r[i]=-1,e[i]=-1,n&=~s}}(e,s),e===Ys&&(Ks=Ys=null,qs=0),0===(2064&r.subtreeFlags)&&0===(2064&r.flags)||pa||(pa=!0,Ka(zt,(function(){return Ga(),null}))),s=0!==(15990&r.flags),0!==(15990&r.subtreeFlags)||s){s=Xs.transition,Xs.transition=null;var o=Bt;Bt=1;var l=Js;Js|=4,js.current=null,function(e,t){for(N(e.containerInfo),us=t;null!==us;)if(t=(e=us).child,0!==(1028&e.subtreeFlags)&&null!==t)t.return=e,us=t;else for(;null!==us;){e=us;try{var n=e.alternate;if(0!==(1024&e.flags))switch(e.tag){case 0:case 11:case 15:case 5:case 6:case 4:case 17:break;case 1:if(null!==n){var r=n.memoizedProps,i=n.memoizedState,s=e.stateNode,o=s.getSnapshotBeforeUpdate(e.elementType===e.type?r:en(e.type,r),i);s.__reactInternalSnapshotBeforeUpdate=o}break;case 3:Y&&we(e.stateNode.containerInfo);break;default:throw Error(a(163))}}catch(l){Wa(e,e.return,l)}if(null!==(t=e.sibling)){t.return=e.return,us=t;break}us=e.return}n=ds,ds=!1}(e,r),function(e,t){for(us=t;null!==us;){var n=(t=us).deletions;if(null!==n)for(var r=0;r<n.length;r++){var i=n[r];try{var s=e;Y?Ss(s,i,t):vs(s,i,t);var a=i.alternate;null!==a&&(a.return=null),i.return=null}catch(A){Wa(i,t,A)}}if(n=t.child,0!==(12854&t.subtreeFlags)&&null!==n)n.return=t,us=n;else for(;null!==us;){t=us;try{var o=t.flags;if(32&o&&Y&&xe(t.stateNode),512&o){var l=t.alternate;if(null!==l){var u=l.ref;null!==u&&("function"===typeof u?u(null):u.current=null)}}if(8192&o)switch(t.tag){case 13:if(null!==t.memoizedState){var c=t.alternate;null!==c&&null!==c.memoizedState||(aa=Ot())}break;case 22:var h=null!==t.memoizedState,d=t.alternate,p=null!==d&&null!==d.memoizedState;if(n=t,Y)e:if(r=n,i=h,s=null,Y)for(var f=r;;){if(5===f.tag){if(null===s){s=f;var m=f.stateNode;i?Ae(m):be(f.stateNode,f.memoizedProps)}}else if(6===f.tag){if(null===s){var g=f.stateNode;i?Me(g):Se(g,f.memoizedProps)}}else if((22!==f.tag&&23!==f.tag||null===f.memoizedState||f===r)&&null!==f.child){f.child.return=f,f=f.child;continue}if(f===r)break;for(;null===f.sibling;){if(null===f.return||f.return===r)break e;s===f&&(s=null),f=f.return}s===f&&(s=null),f.sibling.return=f.return,f=f.sibling}if(h&&!p&&0!==(1&n.mode)){us=n;for(var v=n.child;null!==v;){for(n=us=v;null!==us;){var y=(r=us).child;switch(r.tag){case 0:case 11:case 14:case 15:ps(4,r,r.return);break;case 1:cs(r,r.return);var _=r.stateNode;if("function"===typeof _.componentWillUnmount){var x=r.return;try{_.props=r.memoizedProps,_.state=r.memoizedState,_.componentWillUnmount()}catch(A){Wa(r,x,A)}}break;case 5:cs(r,r.return);break;case 22:if(null!==r.memoizedState){Ps(n);continue}}null!==y?(y.return=r,us=y):Ps(n)}v=v.sibling}}}switch(4102&o){case 2:As(t),t.flags&=-3;break;case 6:As(t),t.flags&=-3,ws(t.alternate,t);break;case 4096:t.flags&=-4097;break;case 4100:t.flags&=-4097,ws(t.alternate,t);break;case 4:ws(t.alternate,t)}}catch(A){Wa(t,t.return,A)}if(null!==(n=t.sibling)){n.return=t.return,us=n;break}us=t.return}}}(e,r),F(e.containerInfo),e.current=r,Ts(r,e,i),Ft(),Js=l,Bt=o,Xs.transition=s}else e.current=r;if(pa&&(pa=!1,fa=e,ma=i),s=e.pendingLanes,0===s&&(da=null),function(e){if(Wt&&"function"===typeof Wt.onCommitFiberRoot)try{Wt.onCommitFiberRoot(Vt,e,void 0,128===(128&e.current.flags))}catch(t){}}(r.stateNode),Sa(e,Ot()),null!==t)for(n=e.onRecoverableError,r=0;r<t.length;r++)n(t[r]);if(ca)throw ca=!1,e=ha,ha=null,e;0!==(1&ma)&&0!==e.tag&&Ga(),s=e.pendingLanes,0!==(1&s)?e===va?ga++:(ga=0,va=e):ga=0,qt()}(e,t,n)}finally{Xs.transition=r,Bt=n}return null}function Ga(){if(null!==fa){var e=Lt(ma),t=Xs.transition,n=Bt;try{if(Xs.transition=null,Bt=16>e?16:e,null===fa)var r=!1;else{if(e=fa,fa=null,ma=0,0!==(6&Js))throw Error(a(331));var i=Js;for(Js|=4,us=e.current;null!==us;){var s=us,o=s.child;if(0!==(16&us.flags)){var l=s.deletions;if(null!==l){for(var u=0;u<l.length;u++){var c=l[u];for(us=c;null!==us;){var h=us;switch(h.tag){case 0:case 11:case 15:ps(8,h,s)}var d=h.child;if(null!==d)d.return=h,us=d;else for(;null!==us;){var p=(h=us).sibling,f=h.return;if(ys(h),h===c){us=null;break}if(null!==p){p.return=f,us=p;break}us=f}}}var m=s.alternate;if(null!==m){var g=m.child;if(null!==g){m.child=null;do{var v=g.sibling;g.sibling=null,g=v}while(null!==g)}}us=s}}if(0!==(2064&s.subtreeFlags)&&null!==o)o.return=s,us=o;else e:for(;null!==us;){if(0!==(2048&(s=us).flags))switch(s.tag){case 0:case 11:case 15:ps(9,s,s.return)}var y=s.sibling;if(null!==y){y.return=s.return,us=y;break e}us=s.return}}var _=e.current;for(us=_;null!==us;){var x=(o=us).child;if(0!==(2064&o.subtreeFlags)&&null!==x)x.return=o,us=x;else e:for(o=_;null!==us;){if(0!==(2048&(l=us).flags))try{switch(l.tag){case 0:case 11:case 15:fs(9,l)}}catch(M){Wa(l,l.return,M)}if(l===o){us=null;break e}var A=l.sibling;if(null!==A){A.return=l.return,us=A;break e}us=l.return}}if(Js=i,qt(),Wt&&"function"===typeof Wt.onPostCommitFiberRoot)try{Wt.onPostCommitFiberRoot(Vt,e)}catch(M){}r=!0}return r}finally{Bt=n,Xs.transition=t}}return!1}function Va(e,t,n){vn(e,t=Si(0,t=vi(n,t),1)),t=xa(),null!==(e=ba(e,1))&&(Pt(e,1,t),Sa(e,t))}function Wa(e,t,n){if(3===e.tag)Va(e,e,n);else for(;null!==t;){if(3===t.tag){Va(t,e,n);break}if(1===t.tag){var r=t.stateNode;if("function"===typeof t.type.getDerivedStateFromError||"function"===typeof r.componentDidCatch&&(null===da||!da.has(r))){vn(t,e=wi(t,e=vi(n,e),1)),e=xa(),null!==(t=ba(t,1))&&(Pt(t,1,e),Sa(t,e));break}}t=t.return}}function ja(e,t,n){var r=e.pingCache;null!==r&&r.delete(t),t=xa(),e.pingedLanes|=e.suspendedLanes&n,Ys===e&&(qs&n)===n&&(4===$s||3===$s&&(130023424&qs)===qs&&500>Ot()-aa?Ba(e,0):ra|=n),Sa(e,t)}function Xa(e,t){0===t&&(0===(1&e.mode)?t=1:(t=St,0===(130023424&(St<<=1))&&(St=4194304)));var n=xa();null!==(e=ba(e,t))&&(Pt(e,t,n),Sa(e,n))}function Ja(e){var t=e.memoizedState,n=0;null!==t&&(n=t.retryLane),Xa(e,n)}function Ya(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,i=e.memoizedState;null!==i&&(n=i.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(a(314))}null!==r&&r.delete(t),Xa(e,n)}function Ka(e,t){return Dt(e,t)}function qa(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.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 Qa(e,t,n,r){return new qa(e,t,n,r)}function Za(e){return!(!(e=e.prototype)||!e.isReactComponent)}function $a(e,t){var n=e.alternate;return null===n?((n=Qa(e.tag,t,e.key,e.mode)).elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=14680064&e.flags,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=null===t?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function eo(e,t,n,r,i,s){var o=2;if(r=e,"function"===typeof e)Za(e)&&(o=1);else if("string"===typeof e)o=5;else e:switch(e){case c:return to(n.children,i,s,t);case h:o=8,i|=8;break;case d:return(e=Qa(12,n,t,2|i)).elementType=d,e.lanes=s,e;case g:return(e=Qa(13,n,t,i)).elementType=g,e.lanes=s,e;case v:return(e=Qa(19,n,t,i)).elementType=v,e.lanes=s,e;case x:return no(n,i,s,t);default:if("object"===typeof e&&null!==e)switch(e.$$typeof){case p:o=10;break e;case f:o=9;break e;case m:o=11;break e;case y:o=14;break e;case _:o=16,r=null;break e}throw Error(a(130,null==e?e:typeof e,""))}return(t=Qa(o,n,t,i)).elementType=e,t.type=r,t.lanes=s,t}function to(e,t,n,r){return(e=Qa(7,e,r,t)).lanes=n,e}function no(e,t,n,r){return(e=Qa(22,e,r,t)).elementType=x,e.lanes=n,e.stateNode={},e}function ro(e,t,n){return(e=Qa(6,e,null,t)).lanes=n,e}function io(e,t,n){return(t=Qa(4,null!==e.children?e.children:[],e.key,t)).lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function so(e,t,n,r,i){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=X,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Rt(0),this.expirationTimes=Rt(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Rt(0),this.identifierPrefix=r,this.onRecoverableError=i,q&&(this.mutableSourceEagerHydrationData=null)}function ao(e,t,n,r,i,s,a,o,l){return e=new so(e,t,n,o,l),1===t?(t=1,!0===s&&(t|=8)):t=0,s=Qa(3,null,null,t),e.current=s,s.stateNode=e,s.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null},fn(s),e}function oo(e){if(!e)return ut;e:{if(w(e=e._reactInternals)!==e||1!==e.tag)throw Error(a(170));var t=e;do{switch(t.tag){case 3:t=t.stateNode.context;break e;case 1:if(ft(t.type)){t=t.stateNode.__reactInternalMemoizedMergedChildContext;break e}}t=t.return}while(null!==t);throw Error(a(171))}if(1===e.tag){var n=e.type;if(ft(n))return vt(e,n,t)}return t}function lo(e){var t=e._reactInternals;if(void 0===t){if("function"===typeof e.render)throw Error(a(188));throw e=Object.keys(e).join(","),Error(a(268,e))}return null===(e=C(t))?null:e.stateNode}function uo(e,t){if(null!==(e=e.memoizedState)&&null!==e.dehydrated){var n=e.retryLane;e.retryLane=0!==n&&n<t?n:t}}function co(e,t){uo(e,t),(e=e.alternate)&&uo(e,t)}function ho(e){return null===(e=C(e))?null:e.stateNode}function po(){return null}return ua=function(e,t,n){if(null!==e)if(e.memoizedProps!==t.pendingProps||ht.current)Ni=!0;else{if(0===(e.lanes&n)&&0===(128&t.flags))return Ni=!1,function(e,t,n){switch(t.tag){case 3:Xi(t),$n();break;case 5:fr(t);break;case 1:ft(t.type)&&yt(t);break;case 4:dr(t,t.stateNode.containerInfo);break;case 10:on(0,t.type._context,t.memoizedProps.value);break;case 13:var r=t.memoizedState;if(null!==r)return null!==r.dehydrated?(lt(gr,1&gr.current),t.flags|=128,null):0!==(n&t.child.childLanes)?qi(e,t,n):(lt(gr,1&gr.current),null!==(e=is(e,t,n))?e.sibling:null);lt(gr,1&gr.current);break;case 19:if(r=0!==(n&t.childLanes),0!==(128&e.flags)){if(r)return rs(e,t,n);t.flags|=128}var i=t.memoizedState;if(null!==i&&(i.rendering=null,i.tail=null,i.lastEffect=null),lt(gr,gr.current),r)break;return null;case 22:case 23:return t.lanes=0,zi(e,t,n)}return is(e,t,n)}(e,t,n);Ni=0!==(131072&e.flags)}else Ni=!1,Wn&&0!==(1048576&t.flags)&&kn(t,Bn,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;null!==e&&(e.alternate=null,t.alternate=null,t.flags|=2),e=t.pendingProps;var i=pt(t,ct.current);cn(t,n),i=Br(null,t,r,e,i,n);var s=Lr();return t.flags|=1,"object"===typeof i&&null!==i&&"function"===typeof i.render&&void 0===i.$$typeof?(t.tag=1,t.memoizedState=null,t.updateQueue=null,ft(r)?(s=!0,yt(t)):s=!1,t.memoizedState=null!==i.state&&void 0!==i.state?i.state:null,fn(t),i.updater=Sn,t.stateNode=i,i._reactInternals=t,Cn(t,r,e,n),t=ji(null,t,r,!0,s,n)):(t.tag=0,Wn&&s&&Hn(t),Fi(null,t,i,n),t=t.child),t;case 16:r=t.elementType;e:{switch(null!==e&&(e.alternate=null,t.alternate=null,t.flags|=2),e=t.pendingProps,r=(i=r._init)(r._payload),t.type=r,i=t.tag=function(e){if("function"===typeof e)return Za(e)?1:0;if(void 0!==e&&null!==e){if((e=e.$$typeof)===m)return 11;if(e===y)return 14}return 2}(r),e=en(r,e),i){case 0:t=Vi(null,t,r,e,n);break e;case 1:t=Wi(null,t,r,e,n);break e;case 11:t=Oi(null,t,r,e,n);break e;case 14:t=ki(null,t,r,en(r.type,e),n);break e}throw Error(a(306,r,""))}return t;case 0:return r=t.type,i=t.pendingProps,Vi(e,t,r,i=t.elementType===r?i:en(r,i),n);case 1:return r=t.type,i=t.pendingProps,Wi(e,t,r,i=t.elementType===r?i:en(r,i),n);case 3:e:{if(Xi(t),null===e)throw Error(a(387));r=t.pendingProps,i=(s=t.memoizedState).element,mn(e,t),xn(t,r,null,n);var o=t.memoizedState;if(r=o.element,q&&s.isDehydrated){if(s={element:r,isDehydrated:!1,cache:o.cache,transitions:o.transitions},t.updateQueue.baseState=s,t.memoizedState=s,256&t.flags){t=Ji(e,t,r,n,i=Error(a(423)));break e}if(r!==i){t=Ji(e,t,r,n,i=Error(a(424)));break e}for(q&&(Vn=ze(t.stateNode.containerInfo),Gn=t,Wn=!0,Xn=null,jn=!1),n=ar(t,null,r,n),t.child=n;n;)n.flags=-3&n.flags|4096,n=n.sibling}else{if($n(),r===i){t=is(e,t,n);break e}Fi(e,t,r,n)}t=t.child}return t;case 5:return fr(t),null===e&&qn(t),r=t.type,i=t.pendingProps,s=null!==e?e.memoizedProps:null,o=i.children,G(r,i)?o=null:null!==s&&G(r,s)&&(t.flags|=32),Gi(e,t),Fi(e,t,o,n),t.child;case 6:return null===e&&qn(t),null;case 13:return qi(e,t,n);case 4:return dr(t,t.stateNode.containerInfo),r=t.pendingProps,null===e?t.child=sr(t,null,r,n):Fi(e,t,r,n),t.child;case 11:return r=t.type,i=t.pendingProps,Oi(e,t,r,i=t.elementType===r?i:en(r,i),n);case 7:return Fi(e,t,t.pendingProps,n),t.child;case 8:case 12:return Fi(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,i=t.pendingProps,s=t.memoizedProps,on(0,r,o=i.value),null!==s)if(jt(s.value,o)){if(s.children===i.children&&!ht.current){t=is(e,t,n);break e}}else for(null!==(s=t.child)&&(s.return=t);null!==s;){var l=s.dependencies;if(null!==l){o=s.child;for(var u=l.firstContext;null!==u;){if(u.context===r){if(1===s.tag){(u=gn(-1,n&-n)).tag=2;var c=s.updateQueue;if(null!==c){var h=(c=c.shared).pending;null===h?u.next=u:(u.next=h.next,h.next=u),c.pending=u}}s.lanes|=n,null!==(u=s.alternate)&&(u.lanes|=n),un(s.return,n,t),l.lanes|=n;break}u=u.next}}else if(10===s.tag)o=s.type===t.type?null:s.child;else if(18===s.tag){if(null===(o=s.return))throw Error(a(341));o.lanes|=n,null!==(l=o.alternate)&&(l.lanes|=n),un(o,n,t),o=s.sibling}else o=s.child;if(null!==o)o.return=s;else for(o=s;null!==o;){if(o===t){o=null;break}if(null!==(s=o.sibling)){s.return=o.return,o=s;break}o=o.return}s=o}Fi(e,t,i.children,n),t=t.child}return t;case 9:return i=t.type,r=t.pendingProps.children,cn(t,n),r=r(i=hn(i)),t.flags|=1,Fi(e,t,r,n),t.child;case 14:return i=en(r=t.type,t.pendingProps),ki(e,t,r,i=en(r.type,i),n);case 15:return Hi(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,i=t.pendingProps,i=t.elementType===r?i:en(r,i),null!==e&&(e.alternate=null,t.alternate=null,t.flags|=2),t.tag=1,ft(r)?(e=!0,yt(t)):e=!1,cn(t,n),En(t,r,i),Cn(t,r,i,n),ji(null,t,r,!0,e,n);case 19:return rs(e,t,n);case 22:return zi(e,t,n)}throw Error(a(156,t.tag))},t.attemptContinuousHydration=function(e){13===e.tag&&(Ma(e,134217728,xa()),co(e,134217728))},t.attemptHydrationAtCurrentPriority=function(e){if(13===e.tag){var t=xa(),n=Aa(e);Ma(e,n,t),co(e,n)}},t.attemptSynchronousHydration=function(e){switch(e.tag){case 3:var t=e.stateNode;if(t.current.memoizedState.isDehydrated){var n=wt(t.pendingLanes);0!==n&&(It(t,1|n),Sa(t,Ot()),0===(6&Js)&&(la(),qt()))}break;case 13:var r=xa();Pa((function(){return Ma(e,1,r)})),co(e,1)}},t.batchedUpdates=function(e,t){var n=Js;Js|=1;try{return e(t)}finally{0===(Js=n)&&(la(),Jt&&qt())}},t.createComponentSelector=function(e){return{$$typeof:Bs,value:e}},t.createContainer=function(e,t,n,r,i,s,a){return ao(e,t,!1,null,0,r,0,s,a)},t.createHasPseudoClassSelector=function(e){return{$$typeof:Ls,value:e}},t.createHydrationContainer=function(e,t,n,r,i,s,a,o,l){return(e=ao(n,r,!0,e,0,s,0,o,l)).context=oo(null),n=e.current,(s=gn(r=xa(),i=Aa(n))).callback=void 0!==t&&null!==t?t:null,vn(n,s),e.current.lanes=i,Pt(e,i,r),Sa(e,r),e},t.createPortal=function(e,t,n){var r=3<arguments.length&&void 0!==arguments[3]?arguments[3]:null;return{$$typeof:u,key:null==r?null:""+r,children:e,containerInfo:t,implementation:n}},t.createRoleSelector=function(e){return{$$typeof:Ds,value:e}},t.createTestNameSelector=function(e){return{$$typeof:Us,value:e}},t.createTextSelector=function(e){return{$$typeof:Ns,value:e}},t.deferredUpdates=function(e){var t=Bt,n=Xs.transition;try{return Xs.transition=null,Bt=16,e()}finally{Bt=t,Xs.transition=n}},t.discreteUpdates=function(e,t,n,r,i){var s=Bt,a=Xs.transition;try{return Xs.transition=null,Bt=1,e(t,n,r,i)}finally{Bt=s,Xs.transition=a,0===Js&&la()}},t.findAllNodes=Gs,t.findBoundingRects=function(e,t){if(!re)throw Error(a(363));t=Gs(e,t),e=[];for(var n=0;n<t.length;n++)e.push(se(t[n]));for(t=e.length-1;0<t;t--)for(var r=(n=e[t]).x,i=r+n.width,s=n.y,o=s+n.height,l=t-1;0<=l;l--)if(t!==l){var u=e[l],c=u.x,h=c+u.width,d=u.y,p=d+u.height;if(r>=c&&s>=d&&i<=h&&o<=p){e.splice(t,1);break}if(!(r!==c||n.width!==u.width||p<s||d>o)){d>s&&(u.height+=d-s,u.y=s),p<o&&(u.height=o-d),e.splice(t,1);break}if(!(s!==d||n.height!==u.height||h<r||c>i)){c>r&&(u.width+=c-r,u.x=r),h<i&&(u.width=i-c),e.splice(t,1);break}}return e},t.findHostInstance=lo,t.findHostInstanceWithNoPortals=function(e){return null===(e=null!==(e=T(e))?P(e):null)?null:e.stateNode},t.findHostInstanceWithWarning=function(e){return lo(e)},t.flushControlled=function(e){var t=Js;Js|=1;var n=Xs.transition,r=Bt;try{Xs.transition=null,Bt=1,e()}finally{Bt=r,Xs.transition=n,0===(Js=t)&&(la(),qt())}},t.flushPassiveEffects=Ga,t.flushSync=Pa,t.focusWithin=function(e,t){if(!re)throw Error(a(363));for(t=zs(e=Os(e),t),t=Array.from(t),e=0;e<t.length;){var n=t[e++];if(!oe(n)){if(5===n.tag&&ue(n.stateNode))return!0;for(n=n.child;null!==n;)t.push(n),n=n.sibling}}return!1},t.getCurrentUpdatePriority=function(){return Bt},t.getFindAllNodesFailureDescription=function(e,t){if(!re)throw Error(a(363));var n=0,r=[];e=[Os(e),0];for(var i=0;i<e.length;){var s=e[i++],o=e[i++],l=t[o];if((5!==s.tag||!oe(s))&&(ks(s,l)&&(r.push(Hs(l)),++o>n&&(n=o)),o<t.length))for(s=s.child;null!==s;)e.push(s,o),s=s.sibling}if(n<t.length){for(e=[];n<t.length;n++)e.push(Hs(t[n]));return"findAllNodes was able to match part of the selector:\n "+r.join(" > ")+"\n\nNo matching component was found for:\n "+e.join(" > ")}return null},t.getPublicRootInstance=function(e){return(e=e.current).child?5===e.child.tag?L(e.child.stateNode):e.child.stateNode:null},t.injectIntoDevTools=function(e){if(e={bundleType:e.bundleType,version:e.version,rendererPackageName:e.rendererPackageName,rendererConfig:e.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:o.ReactCurrentDispatcher,findHostInstanceByFiber:ho,findFiberByHostInstance:e.findFiberByHostInstance||po,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.0.0-fc46dba67-20220329"},"undefined"===typeof __REACT_DEVTOOLS_GLOBAL_HOOK__)e=!1;else{var t=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(t.isDisabled||!t.supportsFiber)e=!0;else{try{Vt=t.inject(e),Wt=t}catch(n){}e=!!t.checkDCE}}return e},t.isAlreadyRendering=function(){return!1},t.observeVisibleRects=function(e,t,n,r){if(!re)throw Error(a(363));e=Gs(e,t);var i=ce(e,n,r).disconnect;return{disconnect:function(){i()}}},t.registerMutableSourceForHydration=function(e,t){var n=t._getVersion;n=n(t._source),null==e.mutableSourceEagerHydrationData?e.mutableSourceEagerHydrationData=[t,n]:e.mutableSourceEagerHydrationData.push(t,n)},t.runWithPriority=function(e,t){var n=Bt;try{return Bt=e,t()}finally{Bt=n}},t.shouldError=function(){return null},t.shouldSuspend=function(){return!1},t.updateContainer=function(e,t,n,r){var i=t.current,s=xa(),a=Aa(i);return n=oo(n),null===t.context?t.context=n:t.pendingContext=n,(t=gn(s,a)).payload={element:e},null!==(r=void 0===r?null:r)&&(t.callback=r),vn(i,t),null!==(e=Ma(i,a,s))&&yn(e,i,a),a},t}},878:(e,t,n)=>{"use strict";e.exports=n(153)},235:(e,t,n)=>{"use strict";e.exports=n(473)},654:(e,t,n)=>{"use strict";var r=n(950),i=Symbol.for("react.element"),s=Symbol.for("react.fragment"),a=Object.prototype.hasOwnProperty,o=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,l={key:!0,ref:!0,__self:!0,__source:!0};function u(e,t,n){var r,s={},u=null,c=null;for(r in void 0!==n&&(u=""+n),void 0!==t.key&&(u=""+t.key),void 0!==t.ref&&(c=t.ref),t)a.call(t,r)&&!l.hasOwnProperty(r)&&(s[r]=t[r]);if(e&&e.defaultProps)for(r in t=e.defaultProps)void 0===s[r]&&(s[r]=t[r]);return{$$typeof:i,type:e,key:u,ref:c,props:s,_owner:o.current}}t.jsx=u,t.jsxs=u},49:(e,t)=>{"use strict";var n=Symbol.for("react.element"),r=Symbol.for("react.portal"),i=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),o=Symbol.for("react.provider"),l=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),c=Symbol.for("react.suspense"),h=Symbol.for("react.memo"),d=Symbol.for("react.lazy"),p=Symbol.iterator;var f={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},m=Object.assign,g={};function v(e,t,n){this.props=e,this.context=t,this.refs=g,this.updater=n||f}function y(){}function _(e,t,n){this.props=e,this.context=t,this.refs=g,this.updater=n||f}v.prototype.isReactComponent={},v.prototype.setState=function(e,t){if("object"!==typeof e&&"function"!==typeof e&&null!=e)throw Error("setState(...): 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")},y.prototype=v.prototype;var x=_.prototype=new y;x.constructor=_,m(x,v.prototype),x.isPureReactComponent=!0;var A=Array.isArray,M=Object.prototype.hasOwnProperty,b={current:null},S={key:!0,ref:!0,__self:!0,__source:!0};function w(e,t,r){var i,s={},a=null,o=null;if(null!=t)for(i in void 0!==t.ref&&(o=t.ref),void 0!==t.key&&(a=""+t.key),t)M.call(t,i)&&!S.hasOwnProperty(i)&&(s[i]=t[i]);var l=arguments.length-2;if(1===l)s.children=r;else if(1<l){for(var u=Array(l),c=0;c<l;c++)u[c]=arguments[c+2];s.children=u}if(e&&e.defaultProps)for(i in l=e.defaultProps)void 0===s[i]&&(s[i]=l[i]);return{$$typeof:n,type:e,key:a,ref:o,props:s,_owner:b.current}}function E(e){return"object"===typeof e&&null!==e&&e.$$typeof===n}var T=/\/+/g;function C(e,t){return"object"===typeof e&&null!==e&&null!=e.key?function(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,(function(e){return t[e]}))}(""+e.key):t.toString(36)}function R(e,t,i,s,a){var o=typeof e;"undefined"!==o&&"boolean"!==o||(e=null);var l=!1;if(null===e)l=!0;else switch(o){case"string":case"number":l=!0;break;case"object":switch(e.$$typeof){case n:case r:l=!0}}if(l)return a=a(l=e),e=""===s?"."+C(l,0):s,A(a)?(i="",null!=e&&(i=e.replace(T,"$&/")+"/"),R(a,t,i,"",(function(e){return e}))):null!=a&&(E(a)&&(a=function(e,t){return{$$typeof:n,type:e.type,key:t,ref:e.ref,props:e.props,_owner:e._owner}}(a,i+(!a.key||l&&l.key===a.key?"":(""+a.key).replace(T,"$&/")+"/")+e)),t.push(a)),1;if(l=0,s=""===s?".":s+":",A(e))for(var u=0;u<e.length;u++){var c=s+C(o=e[u],u);l+=R(o,t,i,c,a)}else if(c=function(e){return null===e||"object"!==typeof e?null:"function"===typeof(e=p&&e[p]||e["@@iterator"])?e:null}(e),"function"===typeof c)for(e=c.call(e),u=0;!(o=e.next()).done;)l+=R(o=o.value,t,i,c=s+C(o,u++),a);else if("object"===o)throw t=String(e),Error("Objects are not valid as a React child (found: "+("[object Object]"===t?"object with keys {"+Object.keys(e).join(", ")+"}":t)+"). If you meant to render a collection of children, use an array instead.");return l}function P(e,t,n){if(null==e)return e;var r=[],i=0;return R(e,r,"","",(function(e){return t.call(n,e,i++)})),r}function I(e){if(-1===e._status){var t=e._result;(t=t()).then((function(t){0!==e._status&&-1!==e._status||(e._status=1,e._result=t)}),(function(t){0!==e._status&&-1!==e._status||(e._status=2,e._result=t)})),-1===e._status&&(e._status=0,e._result=t)}if(1===e._status)return e._result.default;throw e._result}var B={current:null},L={transition:null},D={ReactCurrentDispatcher:B,ReactCurrentBatchConfig:L,ReactCurrentOwner:b};function U(){throw Error("act(...) is not supported in production builds of React.")}t.Children={map:P,forEach:function(e,t,n){P(e,(function(){t.apply(this,arguments)}),n)},count:function(e){var t=0;return P(e,(function(){t++})),t},toArray:function(e){return P(e,(function(e){return e}))||[]},only:function(e){if(!E(e))throw Error("React.Children.only expected to receive a single React element child.");return e}},t.Component=v,t.Fragment=i,t.Profiler=a,t.PureComponent=_,t.StrictMode=s,t.Suspense=c,t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=D,t.act=U,t.cloneElement=function(e,t,r){if(null===e||void 0===e)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+e+".");var i=m({},e.props),s=e.key,a=e.ref,o=e._owner;if(null!=t){if(void 0!==t.ref&&(a=t.ref,o=b.current),void 0!==t.key&&(s=""+t.key),e.type&&e.type.defaultProps)var l=e.type.defaultProps;for(u in t)M.call(t,u)&&!S.hasOwnProperty(u)&&(i[u]=void 0===t[u]&&void 0!==l?l[u]:t[u])}var u=arguments.length-2;if(1===u)i.children=r;else if(1<u){l=Array(u);for(var c=0;c<u;c++)l[c]=arguments[c+2];i.children=l}return{$$typeof:n,type:e.type,key:s,ref:a,props:i,_owner:o}},t.createContext=function(e){return(e={$$typeof:l,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null}).Provider={$$typeof:o,_context:e},e.Consumer=e},t.createElement=w,t.createFactory=function(e){var t=w.bind(null,e);return t.type=e,t},t.createRef=function(){return{current:null}},t.forwardRef=function(e){return{$$typeof:u,render:e}},t.isValidElement=E,t.lazy=function(e){return{$$typeof:d,_payload:{_status:-1,_result:e},_init:I}},t.memo=function(e,t){return{$$typeof:h,type:e,compare:void 0===t?null:t}},t.startTransition=function(e){var t=L.transition;L.transition={};try{e()}finally{L.transition=t}},t.unstable_act=U,t.useCallback=function(e,t){return B.current.useCallback(e,t)},t.useContext=function(e){return B.current.useContext(e)},t.useDebugValue=function(){},t.useDeferredValue=function(e){return B.current.useDeferredValue(e)},t.useEffect=function(e,t){return B.current.useEffect(e,t)},t.useId=function(){return B.current.useId()},t.useImperativeHandle=function(e,t,n){return B.current.useImperativeHandle(e,t,n)},t.useInsertionEffect=function(e,t){return B.current.useInsertionEffect(e,t)},t.useLayoutEffect=function(e,t){return B.current.useLayoutEffect(e,t)},t.useMemo=function(e,t){return B.current.useMemo(e,t)},t.useReducer=function(e,t,n){return B.current.useReducer(e,t,n)},t.useRef=function(e){return B.current.useRef(e)},t.useState=function(e){return B.current.useState(e)},t.useSyncExternalStore=function(e,t,n){return B.current.useSyncExternalStore(e,t,n)},t.useTransition=function(){return B.current.useTransition()},t.version="18.3.1"},950:(e,t,n)=>{"use strict";e.exports=n(49)},414:(e,t,n)=>{"use strict";e.exports=n(654)},761:(e,t)=>{"use strict";function n(e,t){var n=e.length;e.push(t);e:for(;0<n;){var r=n-1>>>1,i=e[r];if(!(0<s(i,t)))break e;e[r]=t,e[n]=i,n=r}}function r(e){return 0===e.length?null:e[0]}function i(e){if(0===e.length)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;e:for(var r=0,i=e.length,a=i>>>1;r<a;){var o=2*(r+1)-1,l=e[o],u=o+1,c=e[u];if(0>s(l,n))u<i&&0>s(c,l)?(e[r]=c,e[u]=n,r=u):(e[r]=l,e[o]=n,r=o);else{if(!(u<i&&0>s(c,n)))break e;e[r]=c,e[u]=n,r=u}}}return t}function s(e,t){var n=e.sortIndex-t.sortIndex;return 0!==n?n:e.id-t.id}if("object"===typeof performance&&"function"===typeof performance.now){var a=performance;t.unstable_now=function(){return a.now()}}else{var o=Date,l=o.now();t.unstable_now=function(){return o.now()-l}}var u=[],c=[],h=1,d=null,p=3,f=!1,m=!1,g=!1,v="function"===typeof setTimeout?setTimeout:null,y="function"===typeof clearTimeout?clearTimeout:null,_="undefined"!==typeof setImmediate?setImmediate:null;function x(e){for(var t=r(c);null!==t;){if(null===t.callback)i(c);else{if(!(t.startTime<=e))break;i(c),t.sortIndex=t.expirationTime,n(u,t)}t=r(c)}}function A(e){if(g=!1,x(e),!m)if(null!==r(u))m=!0,L(M);else{var t=r(c);null!==t&&D(A,t.startTime-e)}}function M(e,n){m=!1,g&&(g=!1,y(E),E=-1),f=!0;var s=p;try{for(x(n),d=r(u);null!==d&&(!(d.expirationTime>n)||e&&!R());){var a=d.callback;if("function"===typeof a){d.callback=null,p=d.priorityLevel;var o=a(d.expirationTime<=n);n=t.unstable_now(),"function"===typeof o?d.callback=o:d===r(u)&&i(u),x(n)}else i(u);d=r(u)}if(null!==d)var l=!0;else{var h=r(c);null!==h&&D(A,h.startTime-n),l=!1}return l}finally{d=null,p=s,f=!1}}"undefined"!==typeof navigator&&void 0!==navigator.scheduling&&void 0!==navigator.scheduling.isInputPending&&navigator.scheduling.isInputPending.bind(navigator.scheduling);var b,S=!1,w=null,E=-1,T=5,C=-1;function R(){return!(t.unstable_now()-C<T)}function P(){if(null!==w){var e=t.unstable_now();C=e;var n=!0;try{n=w(!0,e)}finally{n?b():(S=!1,w=null)}}else S=!1}if("function"===typeof _)b=function(){_(P)};else if("undefined"!==typeof MessageChannel){var I=new MessageChannel,B=I.port2;I.port1.onmessage=P,b=function(){B.postMessage(null)}}else b=function(){v(P,0)};function L(e){w=e,S||(S=!0,b())}function D(e,n){E=v((function(){e(t.unstable_now())}),n)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(e){e.callback=null},t.unstable_continueExecution=function(){m||f||(m=!0,L(M))},t.unstable_forceFrameRate=function(e){0>e||125<e?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):T=0<e?Math.floor(1e3/e):5},t.unstable_getCurrentPriorityLevel=function(){return p},t.unstable_getFirstCallbackNode=function(){return r(u)},t.unstable_next=function(e){switch(p){case 1:case 2:case 3:var t=3;break;default:t=p}var n=p;p=t;try{return e()}finally{p=n}},t.unstable_pauseExecution=function(){},t.unstable_requestPaint=function(){},t.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=p;p=e;try{return t()}finally{p=n}},t.unstable_scheduleCallback=function(e,i,s){var a=t.unstable_now();switch("object"===typeof s&&null!==s?s="number"===typeof(s=s.delay)&&0<s?a+s:a:s=a,e){case 1:var o=-1;break;case 2:o=250;break;case 5:o=1073741823;break;case 4:o=1e4;break;default:o=5e3}return e={id:h++,callback:i,priorityLevel:e,startTime:s,expirationTime:o=s+o,sortIndex:-1},s>a?(e.sortIndex=s,n(c,e),null===r(u)&&e===r(c)&&(g?(y(E),E=-1):g=!0,D(A,s-a))):(e.sortIndex=o,n(u,e),m||f||(m=!0,L(M))),e},t.unstable_shouldYield=R,t.unstable_wrapCallback=function(e){var t=p;return function(){var n=p;p=t;try{return e.apply(this,arguments)}finally{p=n}}}},340:(e,t,n)=>{"use strict";e.exports=n(761)}},t={};function n(r){var i=t[r];if(void 0!==i)return i.exports;var s=t[r]={exports:{}};return e[r](s,s.exports,n),s.exports}n.m=e,n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.f={},n.e=e=>Promise.all(Object.keys(n.f).reduce(((t,r)=>(n.f[r](e,t),t)),[])),n.u=e=>"static/js/"+e+".650ab1fe.chunk.js",n.miniCssF=e=>{},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{var e={},t="vrm2:";n.l=(r,i,s,a)=>{if(e[r])e[r].push(i);else{var o,l;if(void 0!==s)for(var u=document.getElementsByTagName("script"),c=0;c<u.length;c++){var h=u[c];if(h.getAttribute("src")==r||h.getAttribute("data-webpack")==t+s){o=h;break}}o||(l=!0,(o=document.createElement("script")).charset="utf-8",o.timeout=120,n.nc&&o.setAttribute("nonce",n.nc),o.setAttribute("data-webpack",t+s),o.src=r),e[r]=[i];var d=(t,n)=>{o.onerror=o.onload=null,clearTimeout(p);var i=e[r];if(delete e[r],o.parentNode&&o.parentNode.removeChild(o),i&&i.forEach((e=>e(n))),t)return t(n)},p=setTimeout(d.bind(null,void 0,{type:"timeout",target:o}),12e4);o.onerror=d.bind(null,o.onerror),o.onload=d.bind(null,o.onload),l&&document.head.appendChild(o)}}})(),n.r=e=>{"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.p="/",(()=>{var e={792:0};n.f.j=(t,r)=>{var i=n.o(e,t)?e[t]:void 0;if(0!==i)if(i)r.push(i[2]);else{var s=new Promise(((n,r)=>i=e[t]=[n,r]));r.push(i[2]=s);var a=n.p+n.u(t),o=new Error;n.l(a,(r=>{if(n.o(e,t)&&(0!==(i=e[t])&&(e[t]=void 0),i)){var s=r&&("load"===r.type?"missing":r.type),a=r&&r.target&&r.target.src;o.message="Loading chunk "+t+" failed.\n("+s+": "+a+")",o.name="ChunkLoadError",o.type=s,o.request=a,i[1](o)}}),"chunk-"+t,t)}};var t=(t,r)=>{var i,s,a=r[0],o=r[1],l=r[2],u=0;if(a.some((t=>0!==e[t]))){for(i in o)n.o(o,i)&&(n.m[i]=o[i]);if(l)l(n)}for(t&&t(r);u<a.length;u++)s=a[u],n.o(e,s)&&e[s]&&e[s][0](),e[s]=0},r=self.webpackChunkvrm2=self.webpackChunkvrm2||[];r.forEach(t.bind(null,0)),r.push=t.bind(null,r.push.bind(r))})(),(()=>{"use strict";var e={};n.r(e),n.d(e,{ACESFilmicToneMapping:()=>se,AddEquation:()=>S,AddOperation:()=>ee,AdditiveAnimationBlendMode:()=>Vt,AdditiveBlending:()=>x,AgXToneMapping:()=>oe,AlphaFormat:()=>Ge,AlwaysCompare:()=>Bn,AlwaysDepth:()=>j,AlwaysStencilFunc:()=>Sn,AmbientLight:()=>wp,AnimationAction:()=>mf,AnimationClip:()=>Kd,AnimationLoader:()=>ip,AnimationMixer:()=>vf,AnimationObjectGroup:()=>ff,AnimationUtils:()=>Nd,ArcCurve:()=>eh,ArrayCamera:()=>eu,ArrowHelper:()=>cm,AttachedBindMode:()=>ue,Audio:()=>Zp,AudioAnalyser:()=>sf,AudioContext:()=>kp,AudioListener:()=>Qp,AudioLoader:()=>Hp,AxesHelper:()=>hm,BackSide:()=>g,BasicDepthPacking:()=>Jt,BasicShadowMap:()=>h,BatchedMesh:()=>Sc,Bone:()=>Xu,BooleanKeyframeTrack:()=>Gd,Box2:()=>If,Box3:()=>kr,Box3Helper:()=>sm,BoxGeometry:()=>qs,BoxHelper:()=>im,BufferAttribute:()=>ps,BufferGeometry:()=>Ps,BufferGeometryLoader:()=>Bp,ByteType:()=>Ie,Cache:()=>Qd,Camera:()=>na,CameraHelper:()=>tm,CanvasTexture:()=>Qc,CapsuleGeometry:()=>Ah,CatmullRomCurve3:()=>ah,CineonToneMapping:()=>ie,CircleGeometry:()=>Mh,ClampToEdgeWrapping:()=>ye,Clock:()=>jp,Color:()=>ts,ColorKeyframeTrack:()=>Vd,ColorManagement:()=>yr,CompressedArrayTexture:()=>Kc,CompressedCubeTexture:()=>qc,CompressedTexture:()=>Yc,CompressedTextureLoader:()=>sp,ConeGeometry:()=>Sh,ConstantAlphaFactor:()=>G,ConstantColorFactor:()=>H,CubeCamera:()=>la,CubeReflectionMapping:()=>de,CubeRefractionMapping:()=>pe,CubeTexture:()=>ua,CubeTextureLoader:()=>op,CubeUVReflectionMapping:()=>ge,CubicBezierCurve:()=>ch,CubicBezierCurve3:()=>hh,CubicInterpolant:()=>Od,CullFaceBack:()=>l,CullFaceFront:()=>u,CullFaceFrontBack:()=>c,CullFaceNone:()=>o,Curve:()=>Zc,CurvePath:()=>yh,CustomBlending:()=>b,CustomToneMapping:()=>ae,CylinderGeometry:()=>bh,Cylindrical:()=>Cf,Data3DTexture:()=>Lr,DataArrayTexture:()=>Ir,DataTexture:()=>Ju,DataTextureLoader:()=>lp,DataUtils:()=>cs,DecrementStencilOp:()=>pn,DecrementWrapStencilOp:()=>mn,DefaultLoadingManager:()=>$d,DepthFormat:()=>Je,DepthStencilFormat:()=>Ye,DepthTexture:()=>io,DetachedBindMode:()=>ce,DirectionalLight:()=>Sp,DirectionalLightHelper:()=>Zf,DiscreteInterpolant:()=>Hd,DisplayP3ColorSpace:()=>nn,DodecahedronGeometry:()=>Eh,DoubleSide:()=>v,DstAlphaFactor:()=>U,DstColorFactor:()=>F,DynamicCopyUsage:()=>Hn,DynamicDrawUsage:()=>Dn,DynamicReadUsage:()=>Fn,EdgesGeometry:()=>Ih,EllipseCurve:()=>$c,EqualCompare:()=>Tn,EqualDepth:()=>Y,EqualStencilFunc:()=>_n,EquirectangularReflectionMapping:()=>fe,EquirectangularRefractionMapping:()=>me,Euler:()=>Mi,EventDispatcher:()=>Xn,ExtrudeGeometry:()=>od,FileLoader:()=>rp,Float16BufferAttribute:()=>As,Float32BufferAttribute:()=>Ms,FloatType:()=>Ne,Fog:()=>du,FogExp2:()=>hu,FramebufferTexture:()=>Jc,FrontSide:()=>m,Frustum:()=>va,GLBufferAttribute:()=>Mf,GLSL1:()=>Gn,GLSL3:()=>Vn,GreaterCompare:()=>Rn,GreaterDepth:()=>q,GreaterEqualCompare:()=>In,GreaterEqualDepth:()=>K,GreaterEqualStencilFunc:()=>bn,GreaterStencilFunc:()=>An,GridHelper:()=>Jf,Group:()=>tu,HalfFloatType:()=>Fe,HemisphereLight:()=>hp,HemisphereLightHelper:()=>Xf,IcosahedronGeometry:()=>ud,ImageBitmapLoader:()=>Fp,ImageLoader:()=>ap,ImageUtils:()=>Mr,IncrementStencilOp:()=>dn,IncrementWrapStencilOp:()=>fn,InstancedBufferAttribute:()=>Qu,InstancedBufferGeometry:()=>Ip,InstancedInterleavedBuffer:()=>Af,InstancedMesh:()=>sc,Int16BufferAttribute:()=>vs,Int32BufferAttribute:()=>_s,Int8BufferAttribute:()=>fs,IntType:()=>De,InterleavedBuffer:()=>fu,InterleavedBufferAttribute:()=>gu,Interpolant:()=>Fd,InterpolateDiscrete:()=>Nt,InterpolateLinear:()=>Ft,InterpolateSmooth:()=>Ot,InvertStencilOp:()=>gn,KeepStencilOp:()=>cn,KeyframeTrack:()=>zd,LOD:()=>Uu,LatheGeometry:()=>xh,Layers:()=>bi,LessCompare:()=>En,LessDepth:()=>X,LessEqualCompare:()=>Cn,LessEqualDepth:()=>J,LessEqualStencilFunc:()=>xn,LessStencilFunc:()=>yn,Light:()=>cp,LightProbe:()=>Cp,Line:()=>Lc,Line3:()=>Df,LineBasicMaterial:()=>wc,LineCurve:()=>dh,LineCurve3:()=>ph,LineDashedMaterial:()=>Pd,LineLoop:()=>Oc,LineSegments:()=>Fc,LinearDisplayP3ColorSpace:()=>rn,LinearFilter:()=>we,LinearInterpolant:()=>kd,LinearMipMapLinearFilter:()=>Re,LinearMipMapNearestFilter:()=>Te,LinearMipmapLinearFilter:()=>Ce,LinearMipmapNearestFilter:()=>Ee,LinearSRGBColorSpace:()=>tn,LinearToneMapping:()=>ne,LinearTransfer:()=>sn,Loader:()=>ep,LoaderUtils:()=>Pp,LoadingManager:()=>Zd,LoopOnce:()=>Lt,LoopPingPong:()=>Ut,LoopRepeat:()=>Dt,LuminanceAlphaFormat:()=>Xe,LuminanceFormat:()=>je,MOUSE:()=>s,Material:()=>is,MaterialLoader:()=>Rp,MathUtils:()=>rr,Matrix2:()=>Rf,Matrix3:()=>sr,Matrix4:()=>di,MaxEquation:()=>C,Mesh:()=>Ys,MeshBasicMaterial:()=>ss,MeshDepthMaterial:()=>Xl,MeshDistanceMaterial:()=>Jl,MeshLambertMaterial:()=>Cd,MeshMatcapMaterial:()=>Rd,MeshNormalMaterial:()=>Td,MeshPhongMaterial:()=>wd,MeshPhysicalMaterial:()=>Sd,MeshStandardMaterial:()=>bd,MeshToonMaterial:()=>Ed,MinEquation:()=>T,MirroredRepeatWrapping:()=>_e,MixOperation:()=>$,MultiplyBlending:()=>M,MultiplyOperation:()=>Z,NearestFilter:()=>xe,NearestMipMapLinearFilter:()=>Se,NearestMipMapNearestFilter:()=>Me,NearestMipmapLinearFilter:()=>be,NearestMipmapNearestFilter:()=>Ae,NeutralToneMapping:()=>le,NeverCompare:()=>wn,NeverDepth:()=>W,NeverStencilFunc:()=>vn,NoBlending:()=>y,NoColorSpace:()=>$t,NoToneMapping:()=>te,NormalAnimationBlendMode:()=>Gt,NormalBlending:()=>_,NotEqualCompare:()=>Pn,NotEqualDepth:()=>Q,NotEqualStencilFunc:()=>Mn,NumberKeyframeTrack:()=>Wd,Object3D:()=>ki,ObjectLoader:()=>Lp,ObjectSpaceNormalMap:()=>Zt,OctahedronGeometry:()=>cd,OneFactor:()=>P,OneMinusConstantAlphaFactor:()=>V,OneMinusConstantColorFactor:()=>z,OneMinusDstAlphaFactor:()=>N,OneMinusDstColorFactor:()=>O,OneMinusSrcAlphaFactor:()=>D,OneMinusSrcColorFactor:()=>B,OrthographicCamera:()=>La,P3Primaries:()=>ln,PCFShadowMap:()=>d,PCFSoftShadowMap:()=>p,PMREMGenerator:()=>ja,Path:()=>_h,PerspectiveCamera:()=>aa,Plane:()=>fa,PlaneGeometry:()=>xa,PlaneHelper:()=>am,PointLight:()=>Mp,PointLightHelper:()=>Gf,Points:()=>Wc,PointsMaterial:()=>kc,PolarGridHelper:()=>Yf,PolyhedronGeometry:()=>wh,PositionalAudio:()=>rf,PropertyBinding:()=>pf,PropertyMixer:()=>af,QuadraticBezierCurve:()=>fh,QuadraticBezierCurve3:()=>mh,Quaternion:()=>Ur,QuaternionKeyframeTrack:()=>Xd,QuaternionLinearInterpolant:()=>jd,RED_GREEN_RGTC2_Format:()=>It,RED_RGTC1_Format:()=>Rt,REVISION:()=>i,RGBADepthPacking:()=>Yt,RGBAFormat:()=>We,RGBAIntegerFormat:()=>et,RGBA_ASTC_10x10_Format:()=>bt,RGBA_ASTC_10x5_Format:()=>xt,RGBA_ASTC_10x6_Format:()=>At,RGBA_ASTC_10x8_Format:()=>Mt,RGBA_ASTC_12x10_Format:()=>St,RGBA_ASTC_12x12_Format:()=>wt,RGBA_ASTC_4x4_Format:()=>dt,RGBA_ASTC_5x4_Format:()=>pt,RGBA_ASTC_5x5_Format:()=>ft,RGBA_ASTC_6x5_Format:()=>mt,RGBA_ASTC_6x6_Format:()=>gt,RGBA_ASTC_8x5_Format:()=>vt,RGBA_ASTC_8x6_Format:()=>yt,RGBA_ASTC_8x8_Format:()=>_t,RGBA_BPTC_Format:()=>Et,RGBA_ETC2_EAC_Format:()=>ht,RGBA_PVRTC_2BPPV1_Format:()=>lt,RGBA_PVRTC_4BPPV1_Format:()=>ot,RGBA_S3TC_DXT1_Format:()=>nt,RGBA_S3TC_DXT3_Format:()=>rt,RGBA_S3TC_DXT5_Format:()=>it,RGBDepthPacking:()=>Kt,RGBFormat:()=>Ve,RGBIntegerFormat:()=>$e,RGB_BPTC_SIGNED_Format:()=>Tt,RGB_BPTC_UNSIGNED_Format:()=>Ct,RGB_ETC1_Format:()=>ut,RGB_ETC2_Format:()=>ct,RGB_PVRTC_2BPPV1_Format:()=>at,RGB_PVRTC_4BPPV1_Format:()=>st,RGB_S3TC_DXT1_Format:()=>tt,RGDepthPacking:()=>qt,RGFormat:()=>Qe,RGIntegerFormat:()=>Ze,RawShaderMaterial:()=>Md,Ray:()=>hi,Raycaster:()=>Sf,Rec709Primaries:()=>on,RectAreaLight:()=>Ep,RedFormat:()=>Ke,RedIntegerFormat:()=>qe,ReinhardToneMapping:()=>re,RenderTarget:()=>Rr,RepeatWrapping:()=>ve,ReplaceStencilOp:()=>hn,ReverseSubtractEquation:()=>E,RingGeometry:()=>hd,SIGNED_RED_GREEN_RGTC2_Format:()=>Bt,SIGNED_RED_RGTC1_Format:()=>Pt,SRGBColorSpace:()=>en,SRGBTransfer:()=>an,Scene:()=>pu,ShaderChunk:()=>Aa,ShaderLib:()=>ba,ShaderMaterial:()=>ta,ShadowMaterial:()=>Ad,Shape:()=>Bh,ShapeGeometry:()=>dd,ShapePath:()=>dm,ShapeUtils:()=>id,ShortType:()=>Be,Skeleton:()=>qu,SkeletonHelper:()=>Hf,SkinnedMesh:()=>ju,Source:()=>Sr,Sphere:()=>ri,SphereGeometry:()=>pd,Spherical:()=>Tf,SphericalHarmonics3:()=>Tp,SplineCurve:()=>gh,SpotLight:()=>vp,SpotLightHelper:()=>Nf,Sprite:()=>Iu,SpriteMaterial:()=>vu,SrcAlphaFactor:()=>L,SrcAlphaSaturateFactor:()=>k,SrcColorFactor:()=>I,StaticCopyUsage:()=>kn,StaticDrawUsage:()=>Ln,StaticReadUsage:()=>Nn,StereoCamera:()=>Wp,StreamCopyUsage:()=>zn,StreamDrawUsage:()=>Un,StreamReadUsage:()=>On,StringKeyframeTrack:()=>Jd,SubtractEquation:()=>w,SubtractiveBlending:()=>A,TOUCH:()=>a,TangentSpaceNormalMap:()=>Qt,TetrahedronGeometry:()=>fd,Texture:()=>Tr,TextureLoader:()=>up,TextureUtils:()=>Ql,TorusGeometry:()=>md,TorusKnotGeometry:()=>gd,Triangle:()=>qi,TriangleFanDrawMode:()=>Xt,TriangleStripDrawMode:()=>jt,TrianglesDrawMode:()=>Wt,TubeGeometry:()=>vd,UVMapping:()=>he,Uint16BufferAttribute:()=>ys,Uint32BufferAttribute:()=>xs,Uint8BufferAttribute:()=>ms,Uint8ClampedBufferAttribute:()=>gs,Uniform:()=>yf,UniformsGroup:()=>xf,UniformsLib:()=>Ma,UniformsUtils:()=>ea,UnsignedByteType:()=>Pe,UnsignedInt248Type:()=>He,UnsignedInt5999Type:()=>ze,UnsignedIntType:()=>Ue,UnsignedShort4444Type:()=>Oe,UnsignedShort5551Type:()=>ke,UnsignedShortType:()=>Le,VSMShadowMap:()=>f,Vector2:()=>ir,Vector3:()=>Nr,Vector4:()=>Cr,VectorKeyframeTrack:()=>Yd,VideoTexture:()=>Xc,WebGL3DRenderTarget:()=>Dr,WebGLArrayRenderTarget:()=>Br,WebGLCoordinateSystem:()=>Wn,WebGLCubeRenderTarget:()=>ca,WebGLMultipleRenderTargets:()=>pm,WebGLRenderTarget:()=>Pr,WebGLRenderer:()=>cu,WebGLUtils:()=>$l,WebGPUCoordinateSystem:()=>jn,WireframeGeometry:()=>yd,WrapAroundEnding:()=>zt,ZeroCurvatureEnding:()=>kt,ZeroFactor:()=>R,ZeroSlopeEnding:()=>Ht,ZeroStencilOp:()=>un,createCanvasElement:()=>hr});var t=n(950),r=n(352);const i="167",s={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},a={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},o=0,l=1,u=2,c=3,h=0,d=1,p=2,f=3,m=0,g=1,v=2,y=0,_=1,x=2,A=3,M=4,b=5,S=100,w=101,E=102,T=103,C=104,R=200,P=201,I=202,B=203,L=204,D=205,U=206,N=207,F=208,O=209,k=210,H=211,z=212,G=213,V=214,W=0,j=1,X=2,J=3,Y=4,K=5,q=6,Q=7,Z=0,$=1,ee=2,te=0,ne=1,re=2,ie=3,se=4,ae=5,oe=6,le=7,ue="attached",ce="detached",he=300,de=301,pe=302,fe=303,me=304,ge=306,ve=1e3,ye=1001,_e=1002,xe=1003,Ae=1004,Me=1004,be=1005,Se=1005,we=1006,Ee=1007,Te=1007,Ce=1008,Re=1008,Pe=1009,Ie=1010,Be=1011,Le=1012,De=1013,Ue=1014,Ne=1015,Fe=1016,Oe=1017,ke=1018,He=1020,ze=35902,Ge=1021,Ve=1022,We=1023,je=1024,Xe=1025,Je=1026,Ye=1027,Ke=1028,qe=1029,Qe=1030,Ze=1031,$e=1032,et=1033,tt=33776,nt=33777,rt=33778,it=33779,st=35840,at=35841,ot=35842,lt=35843,ut=36196,ct=37492,ht=37496,dt=37808,pt=37809,ft=37810,mt=37811,gt=37812,vt=37813,yt=37814,_t=37815,xt=37816,At=37817,Mt=37818,bt=37819,St=37820,wt=37821,Et=36492,Tt=36494,Ct=36495,Rt=36283,Pt=36284,It=36285,Bt=36286,Lt=2200,Dt=2201,Ut=2202,Nt=2300,Ft=2301,Ot=2302,kt=2400,Ht=2401,zt=2402,Gt=2500,Vt=2501,Wt=0,jt=1,Xt=2,Jt=3200,Yt=3201,Kt=3202,qt=3203,Qt=0,Zt=1,$t="",en="srgb",tn="srgb-linear",nn="display-p3",rn="display-p3-linear",sn="linear",an="srgb",on="rec709",ln="p3",un=0,cn=7680,hn=7681,dn=7682,pn=7683,fn=34055,mn=34056,gn=5386,vn=512,yn=513,_n=514,xn=515,An=516,Mn=517,bn=518,Sn=519,wn=512,En=513,Tn=514,Cn=515,Rn=516,Pn=517,In=518,Bn=519,Ln=35044,Dn=35048,Un=35040,Nn=35045,Fn=35049,On=35041,kn=35046,Hn=35050,zn=35042,Gn="100",Vn="300 es",Wn=2e3,jn=2001;class Xn{addEventListener(e,t){void 0===this._listeners&&(this._listeners={});const n=this._listeners;void 0===n[e]&&(n[e]=[]),-1===n[e].indexOf(t)&&n[e].push(t)}hasEventListener(e,t){if(void 0===this._listeners)return!1;const n=this._listeners;return void 0!==n[e]&&-1!==n[e].indexOf(t)}removeEventListener(e,t){if(void 0===this._listeners)return;const n=this._listeners[e];if(void 0!==n){const e=n.indexOf(t);-1!==e&&n.splice(e,1)}}dispatchEvent(e){if(void 0===this._listeners)return;const t=this._listeners[e.type];if(void 0!==t){e.target=this;const n=t.slice(0);for(let t=0,r=n.length;t<r;t++)n[t].call(this,e);e.target=null}}}const Jn=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let Yn=1234567;const Kn=Math.PI/180,qn=180/Math.PI;function Qn(){const e=4294967295*Math.random()|0,t=4294967295*Math.random()|0,n=4294967295*Math.random()|0,r=4294967295*Math.random()|0;return(Jn[255&e]+Jn[e>>8&255]+Jn[e>>16&255]+Jn[e>>24&255]+"-"+Jn[255&t]+Jn[t>>8&255]+"-"+Jn[t>>16&15|64]+Jn[t>>24&255]+"-"+Jn[63&n|128]+Jn[n>>8&255]+"-"+Jn[n>>16&255]+Jn[n>>24&255]+Jn[255&r]+Jn[r>>8&255]+Jn[r>>16&255]+Jn[r>>24&255]).toLowerCase()}function Zn(e,t,n){return Math.max(t,Math.min(n,e))}function $n(e,t){return(e%t+t)%t}function er(e,t,n){return(1-n)*e+n*t}function tr(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 new Error("Invalid component type.")}}function nr(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return Math.round(4294967295*e);case Uint16Array:return Math.round(65535*e);case Uint8Array:return Math.round(255*e);case Int32Array:return Math.round(2147483647*e);case Int16Array:return Math.round(32767*e);case Int8Array:return Math.round(127*e);default:throw new Error("Invalid component type.")}}const rr={DEG2RAD:Kn,RAD2DEG:qn,generateUUID:Qn,clamp:Zn,euclideanModulo:$n,mapLinear:function(e,t,n,r,i){return r+(e-t)*(i-r)/(n-t)},inverseLerp:function(e,t,n){return e!==t?(n-e)/(t-e):0},lerp:er,damp:function(e,t,n,r){return er(e,t,1-Math.exp(-n*r))},pingpong:function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return t-Math.abs($n(e,2*t)-t)},smoothstep:function(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t))*e*(3-2*e)},smootherstep:function(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t))*e*e*(e*(6*e-15)+10)},randInt:function(e,t){return e+Math.floor(Math.random()*(t-e+1))},randFloat:function(e,t){return e+Math.random()*(t-e)},randFloatSpread:function(e){return e*(.5-Math.random())},seededRandom:function(e){void 0!==e&&(Yn=e);let t=Yn+=1831565813;return t=Math.imul(t^t>>>15,1|t),t^=t+Math.imul(t^t>>>7,61|t),((t^t>>>14)>>>0)/4294967296},degToRad:function(e){return e*Kn},radToDeg:function(e){return e*qn},isPowerOfTwo:function(e){return 0===(e&e-1)&&0!==e},ceilPowerOfTwo:function(e){return Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))},floorPowerOfTwo:function(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))},setQuaternionFromProperEuler:function(e,t,n,r,i){const s=Math.cos,a=Math.sin,o=s(n/2),l=a(n/2),u=s((t+r)/2),c=a((t+r)/2),h=s((t-r)/2),d=a((t-r)/2),p=s((r-t)/2),f=a((r-t)/2);switch(i){case"XYX":e.set(o*c,l*h,l*d,o*u);break;case"YZY":e.set(l*d,o*c,l*h,o*u);break;case"ZXZ":e.set(l*h,l*d,o*c,o*u);break;case"XZX":e.set(o*c,l*f,l*p,o*u);break;case"YXY":e.set(l*p,o*c,l*f,o*u);break;case"ZYZ":e.set(l*f,l*p,o*c,o*u);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}},normalize:nr,denormalize:tr};class ir{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;ir.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,n=this.y,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6],this.y=r[1]*t+r[4]*n+r[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(0===t)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(Zn(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return this.x=e[t],this.y=e[t+1],this}toArray(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const n=Math.cos(t),r=Math.sin(t),i=this.x-e.x,s=this.y-e.y;return this.x=i*n-s*r+e.x,this.y=i*r+s*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class sr{constructor(e,t,n,r,i,s,a,o,l){sr.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],void 0!==e&&this.set(e,t,n,r,i,s,a,o,l)}set(e,t,n,r,i,s,a,o,l){const u=this.elements;return u[0]=e,u[1]=r,u[2]=a,u[3]=t,u[4]=i,u[5]=o,u[6]=n,u[7]=s,u[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,r=t.elements,i=this.elements,s=n[0],a=n[3],o=n[6],l=n[1],u=n[4],c=n[7],h=n[2],d=n[5],p=n[8],f=r[0],m=r[3],g=r[6],v=r[1],y=r[4],_=r[7],x=r[2],A=r[5],M=r[8];return i[0]=s*f+a*v+o*x,i[3]=s*m+a*y+o*A,i[6]=s*g+a*_+o*M,i[1]=l*f+u*v+c*x,i[4]=l*m+u*y+c*A,i[7]=l*g+u*_+c*M,i[2]=h*f+d*v+p*x,i[5]=h*m+d*y+p*A,i[8]=h*g+d*_+p*M,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],s=e[4],a=e[5],o=e[6],l=e[7],u=e[8];return t*s*u-t*a*l-n*i*u+n*a*o+r*i*l-r*s*o}invert(){const e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],s=e[4],a=e[5],o=e[6],l=e[7],u=e[8],c=u*s-a*l,h=a*o-u*i,d=l*i-s*o,p=t*c+n*h+r*d;if(0===p)return this.set(0,0,0,0,0,0,0,0,0);const f=1/p;return e[0]=c*f,e[1]=(r*l-u*n)*f,e[2]=(a*n-r*s)*f,e[3]=h*f,e[4]=(u*t-r*o)*f,e[5]=(r*i-a*t)*f,e[6]=d*f,e[7]=(n*o-l*t)*f,e[8]=(s*t-n*i)*f,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,r,i,s,a){const o=Math.cos(i),l=Math.sin(i);return this.set(n*o,n*l,-n*(o*s+l*a)+s+e,-r*l,r*o,-r*(-l*s+o*a)+a+t,0,0,1),this}scale(e,t){return this.premultiply(ar.makeScale(e,t)),this}rotate(e){return this.premultiply(ar.makeRotation(-e)),this}translate(e,t){return this.premultiply(ar.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,n=e.elements;for(let r=0;r<9;r++)if(t[r]!==n[r])return!1;return!0}fromArray(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return(new this.constructor).fromArray(this.elements)}}const ar=new sr;function or(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}const lr={Int8Array:Int8Array,Uint8Array:Uint8Array,Uint8ClampedArray:Uint8ClampedArray,Int16Array:Int16Array,Uint16Array:Uint16Array,Int32Array:Int32Array,Uint32Array:Uint32Array,Float32Array:Float32Array,Float64Array:Float64Array};function ur(e,t){return new lr[e](t)}function cr(e){return document.createElementNS("http://www.w3.org/1999/xhtml",e)}function hr(){const e=cr("canvas");return e.style.display="block",e}const dr={};function pr(e){e in dr||(dr[e]=!0,console.warn(e))}const fr=(new sr).set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),mr=(new sr).set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),gr={[tn]:{transfer:sn,primaries:on,luminanceCoefficients:[.2126,.7152,.0722],toReference:e=>e,fromReference:e=>e},[en]:{transfer:an,primaries:on,luminanceCoefficients:[.2126,.7152,.0722],toReference:e=>e.convertSRGBToLinear(),fromReference:e=>e.convertLinearToSRGB()},[rn]:{transfer:sn,primaries:ln,luminanceCoefficients:[.2289,.6917,.0793],toReference:e=>e.applyMatrix3(mr),fromReference:e=>e.applyMatrix3(fr)},[nn]:{transfer:an,primaries:ln,luminanceCoefficients:[.2289,.6917,.0793],toReference:e=>e.convertSRGBToLinear().applyMatrix3(mr),fromReference:e=>e.applyMatrix3(fr).convertLinearToSRGB()}},vr=new Set([tn,rn]),yr={enabled:!0,_workingColorSpace:tn,get workingColorSpace(){return this._workingColorSpace},set workingColorSpace(e){if(!vr.has(e))throw new Error(`Unsupported working color space, "${e}".`);this._workingColorSpace=e},convert:function(e,t,n){if(!1===this.enabled||t===n||!t||!n)return e;const r=gr[t].toReference;return(0,gr[n].fromReference)(r(e))},fromWorkingColorSpace:function(e,t){return this.convert(e,this._workingColorSpace,t)},toWorkingColorSpace:function(e,t){return this.convert(e,t,this._workingColorSpace)},getPrimaries:function(e){return gr[e].primaries},getTransfer:function(e){return e===$t?sn:gr[e].transfer},getLuminanceCoefficients:function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this._workingColorSpace;return e.fromArray(gr[t].luminanceCoefficients)}};function _r(e){return e<.04045?.0773993808*e:Math.pow(.9478672986*e+.0521327014,2.4)}function xr(e){return e<.0031308?12.92*e:1.055*Math.pow(e,.41666)-.055}let Ar;class Mr{static getDataURL(e){if(/^data:/i.test(e.src))return e.src;if("undefined"===typeof HTMLCanvasElement)return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{void 0===Ar&&(Ar=cr("canvas")),Ar.width=e.width,Ar.height=e.height;const n=Ar.getContext("2d");e instanceof ImageData?n.putImageData(e,0,0):n.drawImage(e,0,0,e.width,e.height),t=Ar}return t.width>2048||t.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",e),t.toDataURL("image/jpeg",.6)):t.toDataURL("image/png")}static sRGBToLinear(e){if("undefined"!==typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!==typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!==typeof ImageBitmap&&e instanceof ImageBitmap){const t=cr("canvas");t.width=e.width,t.height=e.height;const n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);const r=n.getImageData(0,0,e.width,e.height),i=r.data;for(let e=0;e<i.length;e++)i[e]=255*_r(i[e]/255);return n.putImageData(r,0,0),t}if(e.data){const t=e.data.slice(0);for(let e=0;e<t.length;e++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[e]=Math.floor(255*_r(t[e]/255)):t[e]=_r(t[e]);return{data:t,width:e.width,height:e.height}}return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let br=0;class Sr{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;this.isSource=!0,Object.defineProperty(this,"id",{value:br++}),this.uuid=Qn(),this.data=e,this.dataReady=!0,this.version=0}set needsUpdate(e){!0===e&&this.version++}toJSON(e){const t=void 0===e||"string"===typeof e;if(!t&&void 0!==e.images[this.uuid])return e.images[this.uuid];const n={uuid:this.uuid,url:""},r=this.data;if(null!==r){let e;if(Array.isArray(r)){e=[];for(let t=0,n=r.length;t<n;t++)r[t].isDataTexture?e.push(wr(r[t].image)):e.push(wr(r[t]))}else e=wr(r);n.url=e}return t||(e.images[this.uuid]=n),n}}function wr(e){return"undefined"!==typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!==typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!==typeof ImageBitmap&&e instanceof ImageBitmap?Mr.getDataURL(e):e.data?{data:Array.from(e.data),width:e.width,height:e.height,type:e.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}let Er=0;class Tr extends Xn{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Tr.DEFAULT_IMAGE,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Tr.DEFAULT_MAPPING,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:ye,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:ye,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:we,s=arguments.length>5&&void 0!==arguments[5]?arguments[5]:Ce,a=arguments.length>6&&void 0!==arguments[6]?arguments[6]:We,o=arguments.length>7&&void 0!==arguments[7]?arguments[7]:Pe,l=arguments.length>8&&void 0!==arguments[8]?arguments[8]:Tr.DEFAULT_ANISOTROPY,u=arguments.length>9&&void 0!==arguments[9]?arguments[9]:$t;super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Er++}),this.uuid=Qn(),this.name="",this.source=new Sr(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=n,this.wrapT=r,this.magFilter=i,this.minFilter=s,this.anisotropy=l,this.format=a,this.internalFormat=null,this.type=o,this.offset=new ir(0,0),this.repeat=new ir(1,1),this.center=new ir(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new sr,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=u,this.userData={},this.version=0,this.onUpdate=null,this.isRenderTargetTexture=!1,this.pmremVersion=0}get image(){return this.source.data}set image(e){void 0===e&&(e=null),this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}clone(){return(new this.constructor).copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}toJSON(e){const t=void 0===e||"string"===typeof e;if(!t&&void 0!==e.textures[this.uuid])return e.textures[this.uuid];const n={metadata:{version:4.6,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==he)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case ve:e.x=e.x-Math.floor(e.x);break;case ye:e.x=e.x<0?0:1;break;case _e:1===Math.abs(Math.floor(e.x)%2)?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x)}if(e.y<0||e.y>1)switch(this.wrapT){case ve:e.y=e.y-Math.floor(e.y);break;case ye:e.y=e.y<0?0:1;break;case _e:1===Math.abs(Math.floor(e.y)%2)?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y)}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){!0===e&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){!0===e&&this.pmremVersion++}}Tr.DEFAULT_IMAGE=null,Tr.DEFAULT_MAPPING=he,Tr.DEFAULT_ANISOTROPY=1;class Cr{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1;Cr.prototype.isVector4=!0,this.x=e,this.y=t,this.z=n,this.w=r}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,r){return this.x=e,this.y=t,this.z=n,this.w=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=void 0!==e.w?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,n=this.y,r=this.z,i=this.w,s=e.elements;return this.x=s[0]*t+s[4]*n+s[8]*r+s[12]*i,this.y=s[1]*t+s[5]*n+s[9]*r+s[13]*i,this.z=s[2]*t+s[6]*n+s[10]*r+s[14]*i,this.w=s[3]*t+s[7]*n+s[11]*r+s[15]*i,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,r,i;const s=.01,a=.1,o=e.elements,l=o[0],u=o[4],c=o[8],h=o[1],d=o[5],p=o[9],f=o[2],m=o[6],g=o[10];if(Math.abs(u-h)<s&&Math.abs(c-f)<s&&Math.abs(p-m)<s){if(Math.abs(u+h)<a&&Math.abs(c+f)<a&&Math.abs(p+m)<a&&Math.abs(l+d+g-3)<a)return this.set(1,0,0,0),this;t=Math.PI;const e=(l+1)/2,o=(d+1)/2,v=(g+1)/2,y=(u+h)/4,_=(c+f)/4,x=(p+m)/4;return e>o&&e>v?e<s?(n=0,r=.707106781,i=.707106781):(n=Math.sqrt(e),r=y/n,i=_/n):o>v?o<s?(n=.707106781,r=0,i=.707106781):(r=Math.sqrt(o),n=y/r,i=x/r):v<s?(n=.707106781,r=.707106781,i=0):(i=Math.sqrt(v),n=_/i,r=x/i),this.set(n,r,i,t),this}let v=Math.sqrt((m-p)*(m-p)+(c-f)*(c-f)+(h-u)*(h-u));return Math.abs(v)<.001&&(v=1),this.x=(m-p)/v,this.y=(c-f)/v,this.z=(h-u)/v,this.w=Math.acos((l+d+g-1)/2),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this.w=Math.max(e.w,Math.min(t.w,this.w)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this.w=Math.max(e,Math.min(t,this.w)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class Rr extends Xn{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};super(),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=1,this.scissor=new Cr(0,0,e,t),this.scissorTest=!1,this.viewport=new Cr(0,0,e,t);const r={width:e,height:t,depth:1};n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:we,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1},n);const i=new Tr(r,n.mapping,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.colorSpace);i.flipY=!1,i.generateMipmaps=n.generateMipmaps,i.internalFormat=n.internalFormat,this.textures=[];const s=n.count;for(let a=0;a<s;a++)this.textures[a]=i.clone(),this.textures[a].isRenderTargetTexture=!0;this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this.depthTexture=n.depthTexture,this.samples=n.samples}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}setSize(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;if(this.width!==e||this.height!==t||this.depth!==n){this.width=e,this.height=t,this.depth=n;for(let r=0,i=this.textures.length;r<i;r++)this.textures[r].image.width=e,this.textures[r].image.height=t,this.textures[r].image.depth=n;this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return(new this.constructor).copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let n=0,r=e.textures.length;n<r;n++)this.textures[n]=e.textures[n].clone(),this.textures[n].isRenderTargetTexture=!0;const t=Object.assign({},e.texture.image);return this.texture.source=new Sr(t),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,null!==e.depthTexture&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class Pr extends Rr{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,arguments.length>2&&void 0!==arguments[2]?arguments[2]:{}),this.isWebGLRenderTarget=!0}}class Ir extends Tr{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1;super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:r},this.magFilter=xe,this.minFilter=xe,this.wrapR=ye,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class Br extends Pr{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;super(e,t,arguments.length>3&&void 0!==arguments[3]?arguments[3]:{}),this.isWebGLArrayRenderTarget=!0,this.depth=n,this.texture=new Ir(null,e,t,n),this.texture.isRenderTargetTexture=!0}}class Lr extends Tr{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1;super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:r},this.magFilter=xe,this.minFilter=xe,this.wrapR=ye,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Dr extends Pr{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;super(e,t,arguments.length>3&&void 0!==arguments[3]?arguments[3]:{}),this.isWebGL3DRenderTarget=!0,this.depth=n,this.texture=new Lr(null,e,t,n),this.texture.isRenderTargetTexture=!0}}class Ur{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1;this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=r}static slerpFlat(e,t,n,r,i,s,a){let o=n[r+0],l=n[r+1],u=n[r+2],c=n[r+3];const h=i[s+0],d=i[s+1],p=i[s+2],f=i[s+3];if(0===a)return e[t+0]=o,e[t+1]=l,e[t+2]=u,void(e[t+3]=c);if(1===a)return e[t+0]=h,e[t+1]=d,e[t+2]=p,void(e[t+3]=f);if(c!==f||o!==h||l!==d||u!==p){let e=1-a;const t=o*h+l*d+u*p+c*f,n=t>=0?1:-1,r=1-t*t;if(r>Number.EPSILON){const i=Math.sqrt(r),s=Math.atan2(i,t*n);e=Math.sin(e*s)/i,a=Math.sin(a*s)/i}const i=a*n;if(o=o*e+h*i,l=l*e+d*i,u=u*e+p*i,c=c*e+f*i,e===1-a){const e=1/Math.sqrt(o*o+l*l+u*u+c*c);o*=e,l*=e,u*=e,c*=e}}e[t]=o,e[t+1]=l,e[t+2]=u,e[t+3]=c}static multiplyQuaternionsFlat(e,t,n,r,i,s){const a=n[r],o=n[r+1],l=n[r+2],u=n[r+3],c=i[s],h=i[s+1],d=i[s+2],p=i[s+3];return e[t]=a*p+u*c+o*d-l*h,e[t+1]=o*p+u*h+l*c-a*d,e[t+2]=l*p+u*d+a*h-o*c,e[t+3]=u*p-a*c-o*h-l*d,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){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];const n=e._x,r=e._y,i=e._z,s=e._order,a=Math.cos,o=Math.sin,l=a(n/2),u=a(r/2),c=a(i/2),h=o(n/2),d=o(r/2),p=o(i/2);switch(s){case"XYZ":this._x=h*u*c+l*d*p,this._y=l*d*c-h*u*p,this._z=l*u*p+h*d*c,this._w=l*u*c-h*d*p;break;case"YXZ":this._x=h*u*c+l*d*p,this._y=l*d*c-h*u*p,this._z=l*u*p-h*d*c,this._w=l*u*c+h*d*p;break;case"ZXY":this._x=h*u*c-l*d*p,this._y=l*d*c+h*u*p,this._z=l*u*p+h*d*c,this._w=l*u*c-h*d*p;break;case"ZYX":this._x=h*u*c-l*d*p,this._y=l*d*c+h*u*p,this._z=l*u*p-h*d*c,this._w=l*u*c+h*d*p;break;case"YZX":this._x=h*u*c+l*d*p,this._y=l*d*c+h*u*p,this._z=l*u*p-h*d*c,this._w=l*u*c-h*d*p;break;case"XZY":this._x=h*u*c-l*d*p,this._y=l*d*c-h*u*p,this._z=l*u*p+h*d*c,this._w=l*u*c+h*d*p;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+s)}return!0===t&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const n=t/2,r=Math.sin(n);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,n=t[0],r=t[4],i=t[8],s=t[1],a=t[5],o=t[9],l=t[2],u=t[6],c=t[10],h=n+a+c;if(h>0){const e=.5/Math.sqrt(h+1);this._w=.25/e,this._x=(u-o)*e,this._y=(i-l)*e,this._z=(s-r)*e}else if(n>a&&n>c){const e=2*Math.sqrt(1+n-a-c);this._w=(u-o)/e,this._x=.25*e,this._y=(r+s)/e,this._z=(i+l)/e}else if(a>c){const e=2*Math.sqrt(1+a-n-c);this._w=(i-l)/e,this._x=(r+s)/e,this._y=.25*e,this._z=(o+u)/e}else{const e=2*Math.sqrt(1+c-n-a);this._w=(s-r)/e,this._x=(i+l)/e,this._y=(o+u)/e,this._z=.25*e}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<Number.EPSILON?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Zn(this.dot(e),-1,1)))}rotateTowards(e,t){const n=this.angleTo(e);if(0===n)return this;const r=Math.min(1,t/n);return this.slerp(e,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return 0===e?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const n=e._x,r=e._y,i=e._z,s=e._w,a=t._x,o=t._y,l=t._z,u=t._w;return this._x=n*u+s*a+r*l-i*o,this._y=r*u+s*o+i*a-n*l,this._z=i*u+s*l+n*o-r*a,this._w=s*u-n*a-r*o-i*l,this._onChangeCallback(),this}slerp(e,t){if(0===t)return this;if(1===t)return this.copy(e);const n=this._x,r=this._y,i=this._z,s=this._w;let a=s*e._w+n*e._x+r*e._y+i*e._z;if(a<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,a=-a):this.copy(e),a>=1)return this._w=s,this._x=n,this._y=r,this._z=i,this;const o=1-a*a;if(o<=Number.EPSILON){const e=1-t;return this._w=e*s+t*this._w,this._x=e*n+t*this._x,this._y=e*r+t*this._y,this._z=e*i+t*this._z,this.normalize(),this}const l=Math.sqrt(o),u=Math.atan2(l,a),c=Math.sin((1-t)*u)/l,h=Math.sin(t*u)/l;return this._w=s*c+this._w*h,this._x=n*c+this._x*h,this._y=r*c+this._y*h,this._z=i*c+this._z*h,this._onChangeCallback(),this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),r=Math.sqrt(1-n),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){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]: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(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class Nr{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;Nr.prototype.isVector3=!0,this.x=e,this.y=t,this.z=n}set(e,t,n){return void 0===n&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(Or.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Or.setFromAxisAngle(e,t))}applyMatrix3(e){const 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){const t=this.x,n=this.y,r=this.z,i=e.elements,s=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])*s,this.y=(i[1]*t+i[5]*n+i[9]*r+i[13])*s,this.z=(i[2]*t+i[6]*n+i[10]*r+i[14])*s,this}applyQuaternion(e){const t=this.x,n=this.y,r=this.z,i=e.x,s=e.y,a=e.z,o=e.w,l=2*(s*r-a*n),u=2*(a*t-i*r),c=2*(i*n-s*t);return this.x=t+o*l+s*c-a*u,this.y=n+o*u+a*l-i*c,this.z=r+o*c+i*u-s*l,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,n=this.y,r=this.z,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=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const n=e.x,r=e.y,i=e.z,s=t.x,a=t.y,o=t.z;return this.x=r*o-i*a,this.y=i*s-n*o,this.z=n*a-r*s,this}projectOnVector(e){const t=e.lengthSq();if(0===t)return this.set(0,0,0);const n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return Fr.copy(this).projectOnVector(e),this.sub(Fr)}reflect(e){return this.sub(Fr.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(0===t)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(Zn(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y,r=this.z-e.z;return t*t+n*n+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){const r=Math.sin(t)*e;return this.x=r*Math.sin(n),this.y=Math.cos(t)*e,this.z=r*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=r,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,4*t)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,3*t)}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){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,t=2*Math.random()-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const Fr=new Nr,Or=new Ur;class kr{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new Nr(1/0,1/0,1/0),t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new Nr(-1/0,-1/0,-1/0);this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t+=3)this.expandByPoint(zr.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(zr.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const n=zr.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}setFromObject(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return this.makeEmpty(),this.expandByObject(e,t)}clone(){return(new this.constructor).copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];e.updateWorldMatrix(!1,!1);const n=e.geometry;if(void 0!==n){const r=n.getAttribute("position");if(!0===t&&void 0!==r&&!0!==e.isInstancedMesh)for(let t=0,n=r.count;t<n;t++)!0===e.isMesh?e.getVertexPosition(t,zr):zr.fromBufferAttribute(r,t),zr.applyMatrix4(e.matrixWorld),this.expandByPoint(zr);else void 0!==e.boundingBox?(null===e.boundingBox&&e.computeBoundingBox(),Gr.copy(e.boundingBox)):(null===n.boundingBox&&n.computeBoundingBox(),Gr.copy(n.boundingBox)),Gr.applyMatrix4(e.matrixWorld),this.union(Gr)}const r=e.children;for(let i=0,s=r.length;i<s;i++)this.expandByObject(r[i],t);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,zr),zr.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(Kr),qr.subVectors(this.max,Kr),Vr.subVectors(e.a,Kr),Wr.subVectors(e.b,Kr),jr.subVectors(e.c,Kr),Xr.subVectors(Wr,Vr),Jr.subVectors(jr,Wr),Yr.subVectors(Vr,jr);let t=[0,-Xr.z,Xr.y,0,-Jr.z,Jr.y,0,-Yr.z,Yr.y,Xr.z,0,-Xr.x,Jr.z,0,-Jr.x,Yr.z,0,-Yr.x,-Xr.y,Xr.x,0,-Jr.y,Jr.x,0,-Yr.y,Yr.x,0];return!!$r(t,Vr,Wr,jr,qr)&&(t=[1,0,0,0,1,0,0,0,1],!!$r(t,Vr,Wr,jr,qr)&&(Qr.crossVectors(Xr,Jr),t=[Qr.x,Qr.y,Qr.z],$r(t,Vr,Wr,jr,qr)))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,zr).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=.5*this.getSize(zr).length()),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()||(Hr[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Hr[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Hr[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Hr[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Hr[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Hr[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Hr[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Hr[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Hr)),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}const Hr=[new Nr,new Nr,new Nr,new Nr,new Nr,new Nr,new Nr,new Nr],zr=new Nr,Gr=new kr,Vr=new Nr,Wr=new Nr,jr=new Nr,Xr=new Nr,Jr=new Nr,Yr=new Nr,Kr=new Nr,qr=new Nr,Qr=new Nr,Zr=new Nr;function $r(e,t,n,r,i){for(let s=0,a=e.length-3;s<=a;s+=3){Zr.fromArray(e,s);const a=i.x*Math.abs(Zr.x)+i.y*Math.abs(Zr.y)+i.z*Math.abs(Zr.z),o=t.dot(Zr),l=n.dot(Zr),u=r.dot(Zr);if(Math.max(-Math.max(o,l,u),Math.min(o,l,u))>a)return!1}return!0}const ei=new kr,ti=new Nr,ni=new Nr;class ri{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new Nr,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:-1;this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const n=this.center;void 0!==t?n.copy(t):ei.setFromPoints(e).getCenter(n);let r=0;for(let i=0,s=e.length;i<s;i++)r=Math.max(r,n.distanceToSquared(e[i]));return this.radius=Math.sqrt(r),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){const t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){const n=this.center.distanceToSquared(e);return t.copy(e),n>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;ti.subVectors(e,this.center);const t=ti.lengthSq();if(t>this.radius*this.radius){const e=Math.sqrt(t),n=.5*(e-this.radius);this.center.addScaledVector(ti,n/e),this.radius+=n}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(!0===this.center.equals(e.center)?this.radius=Math.max(this.radius,e.radius):(ni.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(ti.copy(e.center).add(ni)),this.expandByPoint(ti.copy(e.center).sub(ni))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return(new this.constructor).copy(this)}}const ii=new Nr,si=new Nr,ai=new Nr,oi=new Nr,li=new Nr,ui=new Nr,ci=new Nr;class hi{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new Nr,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new Nr(0,0,-1);this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,ii)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=ii.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(ii.copy(this.origin).addScaledVector(this.direction,t),ii.distanceToSquared(e))}distanceSqToSegment(e,t,n,r){si.copy(e).add(t).multiplyScalar(.5),ai.copy(t).sub(e).normalize(),oi.copy(this.origin).sub(si);const i=.5*e.distanceTo(t),s=-this.direction.dot(ai),a=oi.dot(this.direction),o=-oi.dot(ai),l=oi.lengthSq(),u=Math.abs(1-s*s);let c,h,d,p;if(u>0)if(c=s*o-a,h=s*a-o,p=i*u,c>=0)if(h>=-p)if(h<=p){const e=1/u;c*=e,h*=e,d=c*(c+s*h+2*a)+h*(s*c+h+2*o)+l}else h=i,c=Math.max(0,-(s*h+a)),d=-c*c+h*(h+2*o)+l;else h=-i,c=Math.max(0,-(s*h+a)),d=-c*c+h*(h+2*o)+l;else h<=-p?(c=Math.max(0,-(-s*i+a)),h=c>0?-i:Math.min(Math.max(-i,-o),i),d=-c*c+h*(h+2*o)+l):h<=p?(c=0,h=Math.min(Math.max(-i,-o),i),d=h*(h+2*o)+l):(c=Math.max(0,-(s*i+a)),h=c>0?i:Math.min(Math.max(-i,-o),i),d=-c*c+h*(h+2*o)+l);else h=s>0?-i:i,c=Math.max(0,-(s*h+a)),d=-c*c+h*(h+2*o)+l;return n&&n.copy(this.origin).addScaledVector(this.direction,c),r&&r.copy(si).addScaledVector(ai,h),d}intersectSphere(e,t){ii.subVectors(e.center,this.origin);const n=ii.dot(this.direction),r=ii.dot(ii)-n*n,i=e.radius*e.radius;if(r>i)return null;const s=Math.sqrt(i-r),a=n-s,o=n+s;return o<0?null:a<0?this.at(o,t):this.at(a,t)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(0===t)return 0===e.distanceToPoint(this.origin)?0:null;const n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){const n=this.distanceToPlane(e);return null===n?null:this.at(n,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);if(0===t)return!0;return e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,r,i,s,a,o;const l=1/this.direction.x,u=1/this.direction.y,c=1/this.direction.z,h=this.origin;return l>=0?(n=(e.min.x-h.x)*l,r=(e.max.x-h.x)*l):(n=(e.max.x-h.x)*l,r=(e.min.x-h.x)*l),u>=0?(i=(e.min.y-h.y)*u,s=(e.max.y-h.y)*u):(i=(e.max.y-h.y)*u,s=(e.min.y-h.y)*u),n>s||i>r?null:((i>n||isNaN(n))&&(n=i),(s<r||isNaN(r))&&(r=s),c>=0?(a=(e.min.z-h.z)*c,o=(e.max.z-h.z)*c):(a=(e.max.z-h.z)*c,o=(e.min.z-h.z)*c),n>o||a>r?null:((a>n||n!==n)&&(n=a),(o<r||r!==r)&&(r=o),r<0?null:this.at(n>=0?n:r,t)))}intersectsBox(e){return null!==this.intersectBox(e,ii)}intersectTriangle(e,t,n,r,i){li.subVectors(t,e),ui.subVectors(n,e),ci.crossVectors(li,ui);let s,a=this.direction.dot(ci);if(a>0){if(r)return null;s=1}else{if(!(a<0))return null;s=-1,a=-a}oi.subVectors(this.origin,e);const o=s*this.direction.dot(ui.crossVectors(oi,ui));if(o<0)return null;const l=s*this.direction.dot(li.cross(oi));if(l<0)return null;if(o+l>a)return null;const u=-s*oi.dot(ci);return u<0?null:this.at(u/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)}}class di{constructor(e,t,n,r,i,s,a,o,l,u,c,h,d,p,f,m){di.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],void 0!==e&&this.set(e,t,n,r,i,s,a,o,l,u,c,h,d,p,f,m)}set(e,t,n,r,i,s,a,o,l,u,c,h,d,p,f,m){const g=this.elements;return g[0]=e,g[4]=t,g[8]=n,g[12]=r,g[1]=i,g[5]=s,g[9]=a,g[13]=o,g[2]=l,g[6]=u,g[10]=c,g[14]=h,g[3]=d,g[7]=p,g[11]=f,g[15]=m,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return(new di).fromArray(this.elements)}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){const t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){const t=this.elements,n=e.elements,r=1/pi.setFromMatrixColumn(e,0).length(),i=1/pi.setFromMatrixColumn(e,1).length(),s=1/pi.setFromMatrixColumn(e,2).length();return t[0]=n[0]*r,t[1]=n[1]*r,t[2]=n[2]*r,t[3]=0,t[4]=n[4]*i,t[5]=n[5]*i,t[6]=n[6]*i,t[7]=0,t[8]=n[8]*s,t[9]=n[9]*s,t[10]=n[10]*s,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,n=e.x,r=e.y,i=e.z,s=Math.cos(n),a=Math.sin(n),o=Math.cos(r),l=Math.sin(r),u=Math.cos(i),c=Math.sin(i);if("XYZ"===e.order){const e=s*u,n=s*c,r=a*u,i=a*c;t[0]=o*u,t[4]=-o*c,t[8]=l,t[1]=n+r*l,t[5]=e-i*l,t[9]=-a*o,t[2]=i-e*l,t[6]=r+n*l,t[10]=s*o}else if("YXZ"===e.order){const e=o*u,n=o*c,r=l*u,i=l*c;t[0]=e+i*a,t[4]=r*a-n,t[8]=s*l,t[1]=s*c,t[5]=s*u,t[9]=-a,t[2]=n*a-r,t[6]=i+e*a,t[10]=s*o}else if("ZXY"===e.order){const e=o*u,n=o*c,r=l*u,i=l*c;t[0]=e-i*a,t[4]=-s*c,t[8]=r+n*a,t[1]=n+r*a,t[5]=s*u,t[9]=i-e*a,t[2]=-s*l,t[6]=a,t[10]=s*o}else if("ZYX"===e.order){const e=s*u,n=s*c,r=a*u,i=a*c;t[0]=o*u,t[4]=r*l-n,t[8]=e*l+i,t[1]=o*c,t[5]=i*l+e,t[9]=n*l-r,t[2]=-l,t[6]=a*o,t[10]=s*o}else if("YZX"===e.order){const e=s*o,n=s*l,r=a*o,i=a*l;t[0]=o*u,t[4]=i-e*c,t[8]=r*c+n,t[1]=c,t[5]=s*u,t[9]=-a*u,t[2]=-l*u,t[6]=n*c+r,t[10]=e-i*c}else if("XZY"===e.order){const e=s*o,n=s*l,r=a*o,i=a*l;t[0]=o*u,t[4]=-c,t[8]=l*u,t[1]=e*c+i,t[5]=s*u,t[9]=n*c-r,t[2]=r*c-n,t[6]=a*u,t[10]=i*c+e}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(mi,e,gi)}lookAt(e,t,n){const r=this.elements;return _i.subVectors(e,t),0===_i.lengthSq()&&(_i.z=1),_i.normalize(),vi.crossVectors(n,_i),0===vi.lengthSq()&&(1===Math.abs(n.z)?_i.x+=1e-4:_i.z+=1e-4,_i.normalize(),vi.crossVectors(n,_i)),vi.normalize(),yi.crossVectors(_i,vi),r[0]=vi.x,r[4]=yi.x,r[8]=_i.x,r[1]=vi.y,r[5]=yi.y,r[9]=_i.y,r[2]=vi.z,r[6]=yi.z,r[10]=_i.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,r=t.elements,i=this.elements,s=n[0],a=n[4],o=n[8],l=n[12],u=n[1],c=n[5],h=n[9],d=n[13],p=n[2],f=n[6],m=n[10],g=n[14],v=n[3],y=n[7],_=n[11],x=n[15],A=r[0],M=r[4],b=r[8],S=r[12],w=r[1],E=r[5],T=r[9],C=r[13],R=r[2],P=r[6],I=r[10],B=r[14],L=r[3],D=r[7],U=r[11],N=r[15];return i[0]=s*A+a*w+o*R+l*L,i[4]=s*M+a*E+o*P+l*D,i[8]=s*b+a*T+o*I+l*U,i[12]=s*S+a*C+o*B+l*N,i[1]=u*A+c*w+h*R+d*L,i[5]=u*M+c*E+h*P+d*D,i[9]=u*b+c*T+h*I+d*U,i[13]=u*S+c*C+h*B+d*N,i[2]=p*A+f*w+m*R+g*L,i[6]=p*M+f*E+m*P+g*D,i[10]=p*b+f*T+m*I+g*U,i[14]=p*S+f*C+m*B+g*N,i[3]=v*A+y*w+_*R+x*L,i[7]=v*M+y*E+_*P+x*D,i[11]=v*b+y*T+_*I+x*U,i[15]=v*S+y*C+_*B+x*N,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[4],r=e[8],i=e[12],s=e[1],a=e[5],o=e[9],l=e[13],u=e[2],c=e[6],h=e[10],d=e[14];return e[3]*(+i*o*c-r*l*c-i*a*h+n*l*h+r*a*d-n*o*d)+e[7]*(+t*o*d-t*l*h+i*s*h-r*s*d+r*l*u-i*o*u)+e[11]*(+t*l*c-t*a*d-i*s*c+n*s*d+i*a*u-n*l*u)+e[15]*(-r*a*u-t*o*c+t*a*h+r*s*c-n*s*h+n*o*u)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){const r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=t,r[14]=n),this}invert(){const e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],s=e[4],a=e[5],o=e[6],l=e[7],u=e[8],c=e[9],h=e[10],d=e[11],p=e[12],f=e[13],m=e[14],g=e[15],v=c*m*l-f*h*l+f*o*d-a*m*d-c*o*g+a*h*g,y=p*h*l-u*m*l-p*o*d+s*m*d+u*o*g-s*h*g,_=u*f*l-p*c*l+p*a*d-s*f*d-u*a*g+s*c*g,x=p*c*o-u*f*o-p*a*h+s*f*h+u*a*m-s*c*m,A=t*v+n*y+r*_+i*x;if(0===A)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const M=1/A;return e[0]=v*M,e[1]=(f*h*i-c*m*i-f*r*d+n*m*d+c*r*g-n*h*g)*M,e[2]=(a*m*i-f*o*i+f*r*l-n*m*l-a*r*g+n*o*g)*M,e[3]=(c*o*i-a*h*i-c*r*l+n*h*l+a*r*d-n*o*d)*M,e[4]=y*M,e[5]=(u*m*i-p*h*i+p*r*d-t*m*d-u*r*g+t*h*g)*M,e[6]=(p*o*i-s*m*i-p*r*l+t*m*l+s*r*g-t*o*g)*M,e[7]=(s*h*i-u*o*i+u*r*l-t*h*l-s*r*d+t*o*d)*M,e[8]=_*M,e[9]=(p*c*i-u*f*i-p*n*d+t*f*d+u*n*g-t*c*g)*M,e[10]=(s*f*i-p*a*i+p*n*l-t*f*l-s*n*g+t*a*g)*M,e[11]=(u*a*i-s*c*i-u*n*l+t*c*l+s*n*d-t*a*d)*M,e[12]=x*M,e[13]=(u*f*r-p*c*r+p*n*h-t*f*h-u*n*m+t*c*m)*M,e[14]=(p*a*r-s*f*r-p*n*o+t*f*o+s*n*m-t*a*m)*M,e[15]=(s*c*r-u*a*r+u*n*o-t*c*o-s*n*h+t*a*h)*M,this}scale(e){const t=this.elements,n=e.x,r=e.y,i=e.z;return t[0]*=n,t[4]*=r,t[8]*=i,t[1]*=n,t[5]*=r,t[9]*=i,t[2]*=n,t[6]*=r,t[10]*=i,t[3]*=n,t[7]*=r,t[11]*=i,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,r))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const n=Math.cos(t),r=Math.sin(t),i=1-n,s=e.x,a=e.y,o=e.z,l=i*s,u=i*a;return this.set(l*s+n,l*a-r*o,l*o+r*a,0,l*a+r*o,u*a+n,u*o-r*s,0,l*o-r*a,u*o+r*s,i*o*o+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,r,i,s){return this.set(1,n,i,0,e,1,s,0,t,r,1,0,0,0,0,1),this}compose(e,t,n){const r=this.elements,i=t._x,s=t._y,a=t._z,o=t._w,l=i+i,u=s+s,c=a+a,h=i*l,d=i*u,p=i*c,f=s*u,m=s*c,g=a*c,v=o*l,y=o*u,_=o*c,x=n.x,A=n.y,M=n.z;return r[0]=(1-(f+g))*x,r[1]=(d+_)*x,r[2]=(p-y)*x,r[3]=0,r[4]=(d-_)*A,r[5]=(1-(h+g))*A,r[6]=(m+v)*A,r[7]=0,r[8]=(p+y)*M,r[9]=(m-v)*M,r[10]=(1-(h+f))*M,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,n){const r=this.elements;let i=pi.set(r[0],r[1],r[2]).length();const s=pi.set(r[4],r[5],r[6]).length(),a=pi.set(r[8],r[9],r[10]).length();this.determinant()<0&&(i=-i),e.x=r[12],e.y=r[13],e.z=r[14],fi.copy(this);const o=1/i,l=1/s,u=1/a;return fi.elements[0]*=o,fi.elements[1]*=o,fi.elements[2]*=o,fi.elements[4]*=l,fi.elements[5]*=l,fi.elements[6]*=l,fi.elements[8]*=u,fi.elements[9]*=u,fi.elements[10]*=u,t.setFromRotationMatrix(fi),n.x=i,n.y=s,n.z=a,this}makePerspective(e,t,n,r,i,s){let a=arguments.length>6&&void 0!==arguments[6]?arguments[6]:Wn;const o=this.elements,l=2*i/(t-e),u=2*i/(n-r),c=(t+e)/(t-e),h=(n+r)/(n-r);let d,p;if(a===Wn)d=-(s+i)/(s-i),p=-2*s*i/(s-i);else{if(a!==jn)throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);d=-s/(s-i),p=-s*i/(s-i)}return o[0]=l,o[4]=0,o[8]=c,o[12]=0,o[1]=0,o[5]=u,o[9]=h,o[13]=0,o[2]=0,o[6]=0,o[10]=d,o[14]=p,o[3]=0,o[7]=0,o[11]=-1,o[15]=0,this}makeOrthographic(e,t,n,r,i,s){let a=arguments.length>6&&void 0!==arguments[6]?arguments[6]:Wn;const o=this.elements,l=1/(t-e),u=1/(n-r),c=1/(s-i),h=(t+e)*l,d=(n+r)*u;let p,f;if(a===Wn)p=(s+i)*c,f=-2*c;else{if(a!==jn)throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);p=i*c,f=-1*c}return o[0]=2*l,o[4]=0,o[8]=0,o[12]=-h,o[1]=0,o[5]=2*u,o[9]=0,o[13]=-d,o[2]=0,o[6]=0,o[10]=f,o[14]=-p,o[3]=0,o[7]=0,o[11]=0,o[15]=1,this}equals(e){const t=this.elements,n=e.elements;for(let r=0;r<16;r++)if(t[r]!==n[r])return!1;return!0}fromArray(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}}const pi=new Nr,fi=new di,mi=new Nr(0,0,0),gi=new Nr(1,1,1),vi=new Nr,yi=new Nr,_i=new Nr,xi=new di,Ai=new Ur;class Mi{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:Mi.DEFAULT_ORDER;this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=r}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n){let r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:this._order;return this._x=e,this._y=t,this._z=n,this._order=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this._order,n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];const r=e.elements,i=r[0],s=r[4],a=r[8],o=r[1],l=r[5],u=r[9],c=r[2],h=r[6],d=r[10];switch(t){case"XYZ":this._y=Math.asin(Zn(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-u,d),this._z=Math.atan2(-s,i)):(this._x=Math.atan2(h,l),this._z=0);break;case"YXZ":this._x=Math.asin(-Zn(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(a,d),this._z=Math.atan2(o,l)):(this._y=Math.atan2(-c,i),this._z=0);break;case"ZXY":this._x=Math.asin(Zn(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(-c,d),this._z=Math.atan2(-s,l)):(this._y=0,this._z=Math.atan2(o,i));break;case"ZYX":this._y=Math.asin(-Zn(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(h,d),this._z=Math.atan2(o,i)):(this._x=0,this._z=Math.atan2(-s,l));break;case"YZX":this._z=Math.asin(Zn(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-u,l),this._y=Math.atan2(-c,i)):(this._x=0,this._y=Math.atan2(a,d));break;case"XZY":this._z=Math.asin(-Zn(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(h,l),this._y=Math.atan2(a,i)):(this._x=Math.atan2(-u,d),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,!0===n&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return xi.makeRotationFromQuaternion(e),this.setFromRotationMatrix(xi,t,n)}setFromVector3(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this._order;return this.set(e.x,e.y,e.z,t)}reorder(e){return Ai.setFromEuler(this),this.setFromQuaternion(Ai,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],void 0!==e[3]&&(this._order=e[3]),this._onChangeCallback(),this}toArray(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}Mi.DEFAULT_ORDER="XYZ";class bi{constructor(){this.mask=1}set(e){this.mask=1<<e>>>0}enable(e){this.mask|=1<<e}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e}disable(e){this.mask&=~(1<<e)}disableAll(){this.mask=0}test(e){return 0!==(this.mask&e.mask)}isEnabled(e){return 0!==(this.mask&1<<e)}}let Si=0;const wi=new Nr,Ei=new Ur,Ti=new di,Ci=new Nr,Ri=new Nr,Pi=new Nr,Ii=new Ur,Bi=new Nr(1,0,0),Li=new Nr(0,1,0),Di=new Nr(0,0,1),Ui={type:"added"},Ni={type:"removed"},Fi={type:"childadded",child:null},Oi={type:"childremoved",child:null};class ki extends Xn{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Si++}),this.uuid=Qn(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=ki.DEFAULT_UP.clone();const e=new Nr,t=new Mi,n=new Ur,r=new Nr(1,1,1);t._onChange((function(){n.setFromEuler(t,!1)})),n._onChange((function(){t.setFromQuaternion(n,void 0,!1)})),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:r},modelViewMatrix:{value:new di},normalMatrix:{value:new sr}}),this.matrix=new di,this.matrixWorld=new di,this.matrixAutoUpdate=ki.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=ki.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new bi,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={}}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return Ei.setFromAxisAngle(e,t),this.quaternion.multiply(Ei),this}rotateOnWorldAxis(e,t){return Ei.setFromAxisAngle(e,t),this.quaternion.premultiply(Ei),this}rotateX(e){return this.rotateOnAxis(Bi,e)}rotateY(e){return this.rotateOnAxis(Li,e)}rotateZ(e){return this.rotateOnAxis(Di,e)}translateOnAxis(e,t){return wi.copy(e).applyQuaternion(this.quaternion),this.position.add(wi.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(Bi,e)}translateY(e){return this.translateOnAxis(Li,e)}translateZ(e){return this.translateOnAxis(Di,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Ti.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?Ci.copy(e):Ci.set(e,t,n);const r=this.parent;this.updateWorldMatrix(!0,!1),Ri.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Ti.lookAt(Ri,Ci,this.up):Ti.lookAt(Ci,Ri,this.up),this.quaternion.setFromRotationMatrix(Ti),r&&(Ti.extractRotation(r.matrixWorld),Ei.setFromRotationMatrix(Ti),this.quaternion.premultiply(Ei.invert()))}add(e){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return e===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(Ui),Fi.child=e,this.dispatchEvent(Fi),Fi.child=null):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.remove(arguments[e]);return this}const t=this.children.indexOf(e);return-1!==t&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(Ni),Oi.child=e,this.dispatchEvent(Oi),Oi.child=null),this}removeFromParent(){const e=this.parent;return null!==e&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),Ti.copy(this.matrixWorld).invert(),null!==e.parent&&(e.parent.updateWorldMatrix(!0,!1),Ti.multiply(e.parent.matrixWorld)),e.applyMatrix4(Ti),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(Ui),Fi.child=e,this.dispatchEvent(Fi),Fi.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let n=0,r=this.children.length;n<r;n++){const r=this.children[n].getObjectByProperty(e,t);if(void 0!==r)return r}}getObjectsByProperty(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[];this[e]===t&&n.push(this);const r=this.children;for(let i=0,s=r.length;i<s;i++)r[i].getObjectsByProperty(e,t,n);return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Ri,e,Pi),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Ri,Ii,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);const t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].traverse(e)}traverseVisible(e){if(!1===this.visible)return;e(this);const t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].traverseVisible(e)}traverseAncestors(e){const t=this.parent;null!==t&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(!0===this.matrixWorldAutoUpdate&&(null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);const t=this.children;for(let n=0,r=t.length;n<r;n++){t[n].updateMatrixWorld(e)}}updateWorldMatrix(e,t){const n=this.parent;if(!0===e&&null!==n&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),!0===this.matrixWorldAutoUpdate&&(null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),!0===t){const e=this.children;for(let t=0,n=e.length;t<n;t++){e[t].updateWorldMatrix(!1,!0)}}}toJSON(e){const t=void 0===e||"string"===typeof e,n={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.6,type:"Object",generator:"Object3D.toJSON"});const r={};function i(t,n){return void 0===t[n.uuid]&&(t[n.uuid]=n.toJSON(e)),n.uuid}if(r.uuid=this.uuid,r.type=this.type,""!==this.name&&(r.name=this.name),!0===this.castShadow&&(r.castShadow=!0),!0===this.receiveShadow&&(r.receiveShadow=!0),!1===this.visible&&(r.visible=!1),!1===this.frustumCulled&&(r.frustumCulled=!1),0!==this.renderOrder&&(r.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),r.up=this.up.toArray(),!1===this.matrixAutoUpdate&&(r.matrixAutoUpdate=!1),this.isInstancedMesh&&(r.type="InstancedMesh",r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),null!==this.instanceColor&&(r.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(r.type="BatchedMesh",r.perObjectFrustumCulled=this.perObjectFrustumCulled,r.sortObjects=this.sortObjects,r.drawRanges=this._drawRanges,r.reservedRanges=this._reservedRanges,r.visibility=this._visibility,r.active=this._active,r.bounds=this._bounds.map((e=>({boxInitialized:e.boxInitialized,boxMin:e.box.min.toArray(),boxMax:e.box.max.toArray(),sphereInitialized:e.sphereInitialized,sphereRadius:e.sphere.radius,sphereCenter:e.sphere.center.toArray()}))),r.maxInstanceCount=this._maxInstanceCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.geometryCount=this._geometryCount,r.matricesTexture=this._matricesTexture.toJSON(e),null!==this._colorsTexture&&(r.colorsTexture=this._colorsTexture.toJSON(e)),null!==this.boundingSphere&&(r.boundingSphere={center:r.boundingSphere.center.toArray(),radius:r.boundingSphere.radius}),null!==this.boundingBox&&(r.boundingBox={min:r.boundingBox.min.toArray(),max:r.boundingBox.max.toArray()})),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&&!0!==this.environment.isRenderTargetTexture&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=i(e.geometries,this.geometry);const t=this.geometry.parameters;if(void 0!==t&&void 0!==t.shapes){const n=t.shapes;if(Array.isArray(n))for(let t=0,r=n.length;t<r;t++){const r=n[t];i(e.shapes,r)}else i(e.shapes,n)}}if(this.isSkinnedMesh&&(r.bindMode=this.bindMode,r.bindMatrix=this.bindMatrix.toArray(),void 0!==this.skeleton&&(i(e.skeletons,this.skeleton),r.skeleton=this.skeleton.uuid)),void 0!==this.material)if(Array.isArray(this.material)){const t=[];for(let n=0,r=this.material.length;n<r;n++)t.push(i(e.materials,this.material[n]));r.material=t}else r.material=i(e.materials,this.material);if(this.children.length>0){r.children=[];for(let t=0;t<this.children.length;t++)r.children.push(this.children[t].toJSON(e).object)}if(this.animations.length>0){r.animations=[];for(let t=0;t<this.animations.length;t++){const n=this.animations[t];r.animations.push(i(e.animations,n))}}if(t){const t=s(e.geometries),r=s(e.materials),i=s(e.textures),a=s(e.images),o=s(e.shapes),l=s(e.skeletons),u=s(e.animations),c=s(e.nodes);t.length>0&&(n.geometries=t),r.length>0&&(n.materials=r),i.length>0&&(n.textures=i),a.length>0&&(n.images=a),o.length>0&&(n.shapes=o),l.length>0&&(n.skeletons=l),u.length>0&&(n.animations=u),c.length>0&&(n.nodes=c)}return n.object=r,n;function s(e){const t=[];for(const n in e){const r=e[n];delete r.metadata,t.push(r)}return t}}clone(e){return(new this.constructor).copy(this,e)}copy(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),!0===t)for(let n=0;n<e.children.length;n++){const t=e.children[n];this.add(t.clone())}return this}}ki.DEFAULT_UP=new Nr(0,1,0),ki.DEFAULT_MATRIX_AUTO_UPDATE=!0,ki.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const Hi=new Nr,zi=new Nr,Gi=new Nr,Vi=new Nr,Wi=new Nr,ji=new Nr,Xi=new Nr,Ji=new Nr,Yi=new Nr,Ki=new Nr;class qi{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new Nr,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new Nr,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new Nr;this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,r){r.subVectors(n,t),Hi.subVectors(e,t),r.cross(Hi);const i=r.lengthSq();return i>0?r.multiplyScalar(1/Math.sqrt(i)):r.set(0,0,0)}static getBarycoord(e,t,n,r,i){Hi.subVectors(r,t),zi.subVectors(n,t),Gi.subVectors(e,t);const s=Hi.dot(Hi),a=Hi.dot(zi),o=Hi.dot(Gi),l=zi.dot(zi),u=zi.dot(Gi),c=s*l-a*a;if(0===c)return i.set(0,0,0),null;const h=1/c,d=(l*o-a*u)*h,p=(s*u-a*o)*h;return i.set(1-d-p,p,d)}static containsPoint(e,t,n,r){return null!==this.getBarycoord(e,t,n,r,Vi)&&(Vi.x>=0&&Vi.y>=0&&Vi.x+Vi.y<=1)}static getInterpolation(e,t,n,r,i,s,a,o){return null===this.getBarycoord(e,t,n,r,Vi)?(o.x=0,o.y=0,"z"in o&&(o.z=0),"w"in o&&(o.w=0),null):(o.setScalar(0),o.addScaledVector(i,Vi.x),o.addScaledVector(s,Vi.y),o.addScaledVector(a,Vi.z),o)}static isFrontFacing(e,t,n,r){return Hi.subVectors(n,t),zi.subVectors(e,t),Hi.cross(zi).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 Hi.subVectors(this.c,this.b),zi.subVectors(this.a,this.b),.5*Hi.cross(zi).length()}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return qi.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return qi.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,r,i){return qi.getInterpolation(e,this.a,this.b,this.c,t,n,r,i)}containsPoint(e){return qi.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return qi.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const n=this.a,r=this.b,i=this.c;let s,a;Wi.subVectors(r,n),ji.subVectors(i,n),Ji.subVectors(e,n);const o=Wi.dot(Ji),l=ji.dot(Ji);if(o<=0&&l<=0)return t.copy(n);Yi.subVectors(e,r);const u=Wi.dot(Yi),c=ji.dot(Yi);if(u>=0&&c<=u)return t.copy(r);const h=o*c-u*l;if(h<=0&&o>=0&&u<=0)return s=o/(o-u),t.copy(n).addScaledVector(Wi,s);Ki.subVectors(e,i);const d=Wi.dot(Ki),p=ji.dot(Ki);if(p>=0&&d<=p)return t.copy(i);const f=d*l-o*p;if(f<=0&&l>=0&&p<=0)return a=l/(l-p),t.copy(n).addScaledVector(ji,a);const m=u*p-d*c;if(m<=0&&c-u>=0&&d-p>=0)return Xi.subVectors(i,r),a=(c-u)/(c-u+(d-p)),t.copy(r).addScaledVector(Xi,a);const g=1/(m+f+h);return s=f*g,a=h*g,t.copy(n).addScaledVector(Wi,s).addScaledVector(ji,a)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const Qi={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},Zi={h:0,s:0,l:0},$i={h:0,s:0,l:0};function es(e,t,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?e+6*(t-e)*n:n<.5?t:n<2/3?e+6*(t-e)*(2/3-n):e}class ts{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(void 0===t&&void 0===n){const t=e;t&&t.isColor?this.copy(t):"number"===typeof t?this.setHex(t):"string"===typeof t&&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){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:en;return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(255&e)/255,yr.toWorkingColorSpace(this,t),this}setRGB(e,t,n){let r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:yr.workingColorSpace;return this.r=e,this.g=t,this.b=n,yr.toWorkingColorSpace(this,r),this}setHSL(e,t,n){let r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:yr.workingColorSpace;if(e=$n(e,1),t=Zn(t,0,1),n=Zn(n,0,1),0===t)this.r=this.g=this.b=n;else{const r=n<=.5?n*(1+t):n+t-n*t,i=2*n-r;this.r=es(i,r,e+1/3),this.g=es(i,r,e),this.b=es(i,r,e-1/3)}return yr.toWorkingColorSpace(this,r),this}setStyle(e){let t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:en;function r(t){void 0!==t&&parseFloat(t)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}if(t=/^(\w+)\(([^\)]*)\)/.exec(e)){let i;const s=t[1],a=t[2];switch(s){case"rgb":case"rgba":if(i=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return r(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,n);if(i=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return r(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,n);break;case"hsl":case"hsla":if(i=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return r(i[4]),this.setHSL(parseFloat(i[1])/360,parseFloat(i[2])/100,parseFloat(i[3])/100,n);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(t=/^\#([A-Fa-f\d]+)$/.exec(e)){const r=t[1],i=r.length;if(3===i)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,n);if(6===i)return this.setHex(parseInt(r,16),n);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,n);return this}setColorName(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:en;const n=Qi[e.toLowerCase()];return void 0!==n?this.setHex(n,t):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=_r(e.r),this.g=_r(e.g),this.b=_r(e.b),this}copyLinearToSRGB(e){return this.r=xr(e.r),this.g=xr(e.g),this.b=xr(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:en;return yr.fromWorkingColorSpace(ns.copy(this),e),65536*Math.round(Zn(255*ns.r,0,255))+256*Math.round(Zn(255*ns.g,0,255))+Math.round(Zn(255*ns.b,0,255))}getHexString(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:en;return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:yr.workingColorSpace;yr.fromWorkingColorSpace(ns.copy(this),t);const n=ns.r,r=ns.g,i=ns.b,s=Math.max(n,r,i),a=Math.min(n,r,i);let o,l;const u=(a+s)/2;if(a===s)o=0,l=0;else{const e=s-a;switch(l=u<=.5?e/(s+a):e/(2-s-a),s){case n:o=(r-i)/e+(r<i?6:0);break;case r:o=(i-n)/e+2;break;case i:o=(n-r)/e+4}o/=6}return e.h=o,e.s=l,e.l=u,e}getRGB(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:yr.workingColorSpace;return yr.fromWorkingColorSpace(ns.copy(this),t),e.r=ns.r,e.g=ns.g,e.b=ns.b,e}getStyle(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:en;yr.fromWorkingColorSpace(ns.copy(this),e);const t=ns.r,n=ns.g,r=ns.b;return e!==en?`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${r.toFixed(3)})`:`rgb(${Math.round(255*t)},${Math.round(255*n)},${Math.round(255*r)})`}offsetHSL(e,t,n){return this.getHSL(Zi),this.setHSL(Zi.h+e,Zi.s+t,Zi.l+n)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(Zi),e.getHSL($i);const n=er(Zi.h,$i.h,t),r=er(Zi.s,$i.s,t),i=er(Zi.l,$i.l,t);return this.setHSL(n,r,i),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const t=this.r,n=this.g,r=this.b,i=e.elements;return this.r=i[0]*t+i[3]*n+i[6]*r,this.g=i[1]*t+i[4]*n+i[7]*r,this.b=i[2]*t+i[5]*n+i[8]*r,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const ns=new ts;ts.NAMES=Qi;let rs=0;class is extends Xn{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:rs++}),this.uuid=Qn(),this.name="",this.type="Material",this.blending=_,this.side=m,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=L,this.blendDst=D,this.blendEquation=S,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new ts(0,0,0),this.blendAlpha=0,this.depthFunc=J,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=Sn,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=cn,this.stencilZFail=cn,this.stencilZPass=cn,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!==e>0&&this.version++,this._alphaTest=e}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(void 0!==e)for(const t in e){const n=e[t];if(void 0===n){console.warn(`THREE.Material: parameter '${t}' has value of undefined.`);continue}const r=this[t];void 0!==r?r&&r.isColor?r.set(n):r&&r.isVector3&&n&&n.isVector3?r.copy(n):this[t]=n:console.warn(`THREE.Material: '${t}' is not a property of THREE.${this.type}.`)}}toJSON(e){const t=void 0===e||"string"===typeof e;t&&(e={textures:{},images:{}});const n={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};function r(e){const t=[];for(const n in e){const r=e[n];delete r.metadata,t.push(r)}return t}if(n.uuid=this.uuid,n.type=this.type,""!==this.name&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),void 0!==this.roughness&&(n.roughness=this.roughness),void 0!==this.metalness&&(n.metalness=this.metalness),void 0!==this.sheen&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),void 0!==this.sheenRoughness&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),void 0!==this.emissiveIntensity&&1!==this.emissiveIntensity&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),void 0!==this.specularIntensity&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),void 0!==this.shininess&&(n.shininess=this.shininess),void 0!==this.clearcoat&&(n.clearcoat=this.clearcoat),void 0!==this.clearcoatRoughness&&(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()),void 0!==this.dispersion&&(n.dispersion=this.dispersion),void 0!==this.iridescence&&(n.iridescence=this.iridescence),void 0!==this.iridescenceIOR&&(n.iridescenceIOR=this.iridescenceIOR),void 0!==this.iridescenceThicknessRange&&(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),void 0!==this.anisotropy&&(n.anisotropy=this.anisotropy),void 0!==this.anisotropyRotation&&(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,void 0!==this.combine&&(n.combine=this.combine)),void 0!==this.envMapRotation&&(n.envMapRotation=this.envMapRotation.toArray()),void 0!==this.envMapIntensity&&(n.envMapIntensity=this.envMapIntensity),void 0!==this.reflectivity&&(n.reflectivity=this.reflectivity),void 0!==this.refractionRatio&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),void 0!==this.transmission&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),void 0!==this.thickness&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),void 0!==this.attenuationDistance&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),void 0!==this.attenuationColor&&(n.attenuationColor=this.attenuationColor.getHex()),void 0!==this.size&&(n.size=this.size),null!==this.shadowSide&&(n.shadowSide=this.shadowSide),void 0!==this.sizeAttenuation&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==_&&(n.blending=this.blending),this.side!==m&&(n.side=this.side),!0===this.vertexColors&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),!0===this.transparent&&(n.transparent=!0),this.blendSrc!==L&&(n.blendSrc=this.blendSrc),this.blendDst!==D&&(n.blendDst=this.blendDst),this.blendEquation!==S&&(n.blendEquation=this.blendEquation),null!==this.blendSrcAlpha&&(n.blendSrcAlpha=this.blendSrcAlpha),null!==this.blendDstAlpha&&(n.blendDstAlpha=this.blendDstAlpha),null!==this.blendEquationAlpha&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),0!==this.blendAlpha&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==J&&(n.depthFunc=this.depthFunc),!1===this.depthTest&&(n.depthTest=this.depthTest),!1===this.depthWrite&&(n.depthWrite=this.depthWrite),!1===this.colorWrite&&(n.colorWrite=this.colorWrite),255!==this.stencilWriteMask&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==Sn&&(n.stencilFunc=this.stencilFunc),0!==this.stencilRef&&(n.stencilRef=this.stencilRef),255!==this.stencilFuncMask&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==cn&&(n.stencilFail=this.stencilFail),this.stencilZFail!==cn&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==cn&&(n.stencilZPass=this.stencilZPass),!0===this.stencilWrite&&(n.stencilWrite=this.stencilWrite),void 0!==this.rotation&&0!==this.rotation&&(n.rotation=this.rotation),!0===this.polygonOffset&&(n.polygonOffset=!0),0!==this.polygonOffsetFactor&&(n.polygonOffsetFactor=this.polygonOffsetFactor),0!==this.polygonOffsetUnits&&(n.polygonOffsetUnits=this.polygonOffsetUnits),void 0!==this.linewidth&&1!==this.linewidth&&(n.linewidth=this.linewidth),void 0!==this.dashSize&&(n.dashSize=this.dashSize),void 0!==this.gapSize&&(n.gapSize=this.gapSize),void 0!==this.scale&&(n.scale=this.scale),!0===this.dithering&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),!0===this.alphaHash&&(n.alphaHash=!0),!0===this.alphaToCoverage&&(n.alphaToCoverage=!0),!0===this.premultipliedAlpha&&(n.premultipliedAlpha=!0),!0===this.forceSinglePass&&(n.forceSinglePass=!0),!0===this.wireframe&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(n.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(n.wireframeLinejoin=this.wireframeLinejoin),!0===this.flatShading&&(n.flatShading=!0),!1===this.visible&&(n.visible=!1),!1===this.toneMapped&&(n.toneMapped=!1),!1===this.fog&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData),t){const 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;const t=e.clippingPlanes;let n=null;if(null!==t){const e=t.length;n=new 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.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){!0===e&&this.version++}onBuild(){console.warn("Material: onBuild() has been removed.")}onBeforeRender(){console.warn("Material: onBeforeRender() has been removed.")}}class ss extends is{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new ts(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 Mi,this.combine=Z,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const as=os();function os(){const e=new ArrayBuffer(4),t=new Float32Array(e),n=new Uint32Array(e),r=new Uint32Array(512),i=new Uint32Array(512);for(let l=0;l<256;++l){const e=l-127;e<-27?(r[l]=0,r[256|l]=32768,i[l]=24,i[256|l]=24):e<-14?(r[l]=1024>>-e-14,r[256|l]=1024>>-e-14|32768,i[l]=-e-1,i[256|l]=-e-1):e<=15?(r[l]=e+15<<10,r[256|l]=e+15<<10|32768,i[l]=13,i[256|l]=13):e<128?(r[l]=31744,r[256|l]=64512,i[l]=24,i[256|l]=24):(r[l]=31744,r[256|l]=64512,i[l]=13,i[256|l]=13)}const s=new Uint32Array(2048),a=new Uint32Array(64),o=new Uint32Array(64);for(let l=1;l<1024;++l){let e=l<<13,t=0;for(;0===(8388608&e);)e<<=1,t-=8388608;e&=-8388609,t+=947912704,s[l]=e|t}for(let l=1024;l<2048;++l)s[l]=939524096+(l-1024<<13);for(let l=1;l<31;++l)a[l]=l<<23;a[31]=1199570944,a[32]=2147483648;for(let l=33;l<63;++l)a[l]=2147483648+(l-32<<23);a[63]=3347054592;for(let l=1;l<64;++l)32!==l&&(o[l]=1024);return{floatView:t,uint32View:n,baseTable:r,shiftTable:i,mantissaTable:s,exponentTable:a,offsetTable:o}}function ls(e){Math.abs(e)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),e=Zn(e,-65504,65504),as.floatView[0]=e;const t=as.uint32View[0],n=t>>23&511;return as.baseTable[n]+((8388607&t)>>as.shiftTable[n])}function us(e){const t=e>>10;return as.uint32View[0]=as.mantissaTable[as.offsetTable[t]+(1023&e)]+as.exponentTable[t],as.floatView[0]}const cs={toHalfFloat:ls,fromHalfFloat:us},hs=new Nr,ds=new ir;class ps{constructor(e,t){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=e,this.itemSize=t,this.count=void 0!==e?e.length/t:0,this.normalized=n,this.usage=Ln,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.gpuType=Ne,this.version=0}onUploadCallback(){}set needsUpdate(e){!0===e&&this.version++}get updateRange(){return pr("THREE.BufferAttribute: updateRange() is deprecated and will be removed in r169. Use addUpdateRange() instead."),this._updateRange}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let r=0,i=this.itemSize;r<i;r++)this.array[e+r]=t.array[n+r];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(2===this.itemSize)for(let t=0,n=this.count;t<n;t++)ds.fromBufferAttribute(this,t),ds.applyMatrix3(e),this.setXY(t,ds.x,ds.y);else if(3===this.itemSize)for(let t=0,n=this.count;t<n;t++)hs.fromBufferAttribute(this,t),hs.applyMatrix3(e),this.setXYZ(t,hs.x,hs.y,hs.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)hs.fromBufferAttribute(this,t),hs.applyMatrix4(e),this.setXYZ(t,hs.x,hs.y,hs.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)hs.fromBufferAttribute(this,t),hs.applyNormalMatrix(e),this.setXYZ(t,hs.x,hs.y,hs.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)hs.fromBufferAttribute(this,t),hs.transformDirection(e),this.setXYZ(t,hs.x,hs.y,hs.z);return this}set(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return this.array.set(e,t),this}getComponent(e,t){let n=this.array[e*this.itemSize+t];return this.normalized&&(n=tr(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=nr(n,this.array)),this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=tr(t,this.array)),t}setX(e,t){return this.normalized&&(t=nr(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=tr(t,this.array)),t}setY(e,t){return this.normalized&&(t=nr(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=tr(t,this.array)),t}setZ(e,t){return this.normalized&&(t=nr(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=tr(t,this.array)),t}setW(e,t){return this.normalized&&(t=nr(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=nr(t,this.array),n=nr(n,this.array)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,r){return e*=this.itemSize,this.normalized&&(t=nr(t,this.array),n=nr(n,this.array),r=nr(r,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this}setXYZW(e,t,n,r,i){return e*=this.itemSize,this.normalized&&(t=nr(t,this.array),n=nr(n,this.array),r=nr(r,this.array),i=nr(i,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this.array[e+3]=i,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return""!==this.name&&(e.name=this.name),this.usage!==Ln&&(e.usage=this.usage),e}}class fs extends ps{constructor(e,t,n){super(new Int8Array(e),t,n)}}class ms extends ps{constructor(e,t,n){super(new Uint8Array(e),t,n)}}class gs extends ps{constructor(e,t,n){super(new Uint8ClampedArray(e),t,n)}}class vs extends ps{constructor(e,t,n){super(new Int16Array(e),t,n)}}class ys extends ps{constructor(e,t,n){super(new Uint16Array(e),t,n)}}class _s extends ps{constructor(e,t,n){super(new Int32Array(e),t,n)}}class xs extends ps{constructor(e,t,n){super(new Uint32Array(e),t,n)}}class As extends ps{constructor(e,t,n){super(new Uint16Array(e),t,n),this.isFloat16BufferAttribute=!0}getX(e){let t=us(this.array[e*this.itemSize]);return this.normalized&&(t=tr(t,this.array)),t}setX(e,t){return this.normalized&&(t=nr(t,this.array)),this.array[e*this.itemSize]=ls(t),this}getY(e){let t=us(this.array[e*this.itemSize+1]);return this.normalized&&(t=tr(t,this.array)),t}setY(e,t){return this.normalized&&(t=nr(t,this.array)),this.array[e*this.itemSize+1]=ls(t),this}getZ(e){let t=us(this.array[e*this.itemSize+2]);return this.normalized&&(t=tr(t,this.array)),t}setZ(e,t){return this.normalized&&(t=nr(t,this.array)),this.array[e*this.itemSize+2]=ls(t),this}getW(e){let t=us(this.array[e*this.itemSize+3]);return this.normalized&&(t=tr(t,this.array)),t}setW(e,t){return this.normalized&&(t=nr(t,this.array)),this.array[e*this.itemSize+3]=ls(t),this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=nr(t,this.array),n=nr(n,this.array)),this.array[e+0]=ls(t),this.array[e+1]=ls(n),this}setXYZ(e,t,n,r){return e*=this.itemSize,this.normalized&&(t=nr(t,this.array),n=nr(n,this.array),r=nr(r,this.array)),this.array[e+0]=ls(t),this.array[e+1]=ls(n),this.array[e+2]=ls(r),this}setXYZW(e,t,n,r,i){return e*=this.itemSize,this.normalized&&(t=nr(t,this.array),n=nr(n,this.array),r=nr(r,this.array),i=nr(i,this.array)),this.array[e+0]=ls(t),this.array[e+1]=ls(n),this.array[e+2]=ls(r),this.array[e+3]=ls(i),this}}class Ms extends ps{constructor(e,t,n){super(new Float32Array(e),t,n)}}let bs=0;const Ss=new di,ws=new ki,Es=new Nr,Ts=new kr,Cs=new kr,Rs=new Nr;class Ps extends Xn{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:bs++}),this.uuid=Qn(),this.name="",this.type="BufferGeometry",this.index=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(or(e)?xs:ys)(e,1):this.index=e,this}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return void 0!==this.attributes[e]}addGroup(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){const t=this.attributes.position;void 0!==t&&(t.applyMatrix4(e),t.needsUpdate=!0);const n=this.attributes.normal;if(void 0!==n){const t=(new sr).getNormalMatrix(e);n.applyNormalMatrix(t),n.needsUpdate=!0}const r=this.attributes.tangent;return void 0!==r&&(r.transformDirection(e),r.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this}applyQuaternion(e){return Ss.makeRotationFromQuaternion(e),this.applyMatrix4(Ss),this}rotateX(e){return Ss.makeRotationX(e),this.applyMatrix4(Ss),this}rotateY(e){return Ss.makeRotationY(e),this.applyMatrix4(Ss),this}rotateZ(e){return Ss.makeRotationZ(e),this.applyMatrix4(Ss),this}translate(e,t,n){return Ss.makeTranslation(e,t,n),this.applyMatrix4(Ss),this}scale(e,t,n){return Ss.makeScale(e,t,n),this.applyMatrix4(Ss),this}lookAt(e){return ws.lookAt(e),ws.updateMatrix(),this.applyMatrix4(ws.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Es).negate(),this.translate(Es.x,Es.y,Es.z),this}setFromPoints(e){const t=[];for(let n=0,r=e.length;n<r;n++){const r=e[n];t.push(r.x,r.y,r.z||0)}return this.setAttribute("position",new Ms(t,3)),this}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new kr);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute)return console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),void this.boundingBox.set(new Nr(-1/0,-1/0,-1/0),new Nr(1/0,1/0,1/0));if(void 0!==e){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,r=t.length;n<r;n++){const e=t[n];Ts.setFromBufferAttribute(e),this.morphTargetsRelative?(Rs.addVectors(this.boundingBox.min,Ts.min),this.boundingBox.expandByPoint(Rs),Rs.addVectors(this.boundingBox.max,Ts.max),this.boundingBox.expandByPoint(Rs)):(this.boundingBox.expandByPoint(Ts.min),this.boundingBox.expandByPoint(Ts.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){null===this.boundingSphere&&(this.boundingSphere=new ri);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute)return console.error("THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),void this.boundingSphere.set(new Nr,1/0);if(e){const n=this.boundingSphere.center;if(Ts.setFromBufferAttribute(e),t)for(let e=0,i=t.length;e<i;e++){const n=t[e];Cs.setFromBufferAttribute(n),this.morphTargetsRelative?(Rs.addVectors(Ts.min,Cs.min),Ts.expandByPoint(Rs),Rs.addVectors(Ts.max,Cs.max),Ts.expandByPoint(Rs)):(Ts.expandByPoint(Cs.min),Ts.expandByPoint(Cs.max))}Ts.getCenter(n);let r=0;for(let t=0,i=e.count;t<i;t++)Rs.fromBufferAttribute(e,t),r=Math.max(r,n.distanceToSquared(Rs));if(t)for(let i=0,s=t.length;i<s;i++){const s=t[i],a=this.morphTargetsRelative;for(let t=0,i=s.count;t<i;t++)Rs.fromBufferAttribute(s,t),a&&(Es.fromBufferAttribute(e,t),Rs.add(Es)),r=Math.max(r,n.distanceToSquared(Rs))}this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,t=this.attributes;if(null===e||void 0===t.position||void 0===t.normal||void 0===t.uv)return void console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");const n=t.position,r=t.normal,i=t.uv;!1===this.hasAttribute("tangent")&&this.setAttribute("tangent",new ps(new Float32Array(4*n.count),4));const s=this.getAttribute("tangent"),a=[],o=[];for(let b=0;b<n.count;b++)a[b]=new Nr,o[b]=new Nr;const l=new Nr,u=new Nr,c=new Nr,h=new ir,d=new ir,p=new ir,f=new Nr,m=new Nr;function g(e,t,r){l.fromBufferAttribute(n,e),u.fromBufferAttribute(n,t),c.fromBufferAttribute(n,r),h.fromBufferAttribute(i,e),d.fromBufferAttribute(i,t),p.fromBufferAttribute(i,r),u.sub(l),c.sub(l),d.sub(h),p.sub(h);const s=1/(d.x*p.y-p.x*d.y);isFinite(s)&&(f.copy(u).multiplyScalar(p.y).addScaledVector(c,-d.y).multiplyScalar(s),m.copy(c).multiplyScalar(d.x).addScaledVector(u,-p.x).multiplyScalar(s),a[e].add(f),a[t].add(f),a[r].add(f),o[e].add(m),o[t].add(m),o[r].add(m))}let v=this.groups;0===v.length&&(v=[{start:0,count:e.count}]);for(let b=0,S=v.length;b<S;++b){const t=v[b],n=t.start;for(let r=n,i=n+t.count;r<i;r+=3)g(e.getX(r+0),e.getX(r+1),e.getX(r+2))}const y=new Nr,_=new Nr,x=new Nr,A=new Nr;function M(e){x.fromBufferAttribute(r,e),A.copy(x);const t=a[e];y.copy(t),y.sub(x.multiplyScalar(x.dot(t))).normalize(),_.crossVectors(A,t);const n=_.dot(o[e])<0?-1:1;s.setXYZW(e,y.x,y.y,y.z,n)}for(let b=0,S=v.length;b<S;++b){const t=v[b],n=t.start;for(let r=n,i=n+t.count;r<i;r+=3)M(e.getX(r+0)),M(e.getX(r+1)),M(e.getX(r+2))}}computeVertexNormals(){const e=this.index,t=this.getAttribute("position");if(void 0!==t){let n=this.getAttribute("normal");if(void 0===n)n=new ps(new Float32Array(3*t.count),3),this.setAttribute("normal",n);else for(let e=0,t=n.count;e<t;e++)n.setXYZ(e,0,0,0);const r=new Nr,i=new Nr,s=new Nr,a=new Nr,o=new Nr,l=new Nr,u=new Nr,c=new Nr;if(e)for(let h=0,d=e.count;h<d;h+=3){const d=e.getX(h+0),p=e.getX(h+1),f=e.getX(h+2);r.fromBufferAttribute(t,d),i.fromBufferAttribute(t,p),s.fromBufferAttribute(t,f),u.subVectors(s,i),c.subVectors(r,i),u.cross(c),a.fromBufferAttribute(n,d),o.fromBufferAttribute(n,p),l.fromBufferAttribute(n,f),a.add(u),o.add(u),l.add(u),n.setXYZ(d,a.x,a.y,a.z),n.setXYZ(p,o.x,o.y,o.z),n.setXYZ(f,l.x,l.y,l.z)}else for(let e=0,h=t.count;e<h;e+=3)r.fromBufferAttribute(t,e+0),i.fromBufferAttribute(t,e+1),s.fromBufferAttribute(t,e+2),u.subVectors(s,i),c.subVectors(r,i),u.cross(c),n.setXYZ(e+0,u.x,u.y,u.z),n.setXYZ(e+1,u.x,u.y,u.z),n.setXYZ(e+2,u.x,u.y,u.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)Rs.fromBufferAttribute(e,t),Rs.normalize(),e.setXYZ(t,Rs.x,Rs.y,Rs.z)}toNonIndexed(){function e(e,t){const n=e.array,r=e.itemSize,i=e.normalized,s=new n.constructor(t.length*r);let a=0,o=0;for(let l=0,u=t.length;l<u;l++){a=e.isInterleavedBufferAttribute?t[l]*e.data.stride+e.offset:t[l]*r;for(let e=0;e<r;e++)s[o++]=n[a++]}return new ps(s,r,i)}if(null===this.index)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new Ps,n=this.index.array,r=this.attributes;for(const a in r){const i=e(r[a],n);t.setAttribute(a,i)}const i=this.morphAttributes;for(const a in i){const r=[],s=i[a];for(let t=0,i=s.length;t<i;t++){const i=e(s[t],n);r.push(i)}t.morphAttributes[a]=r}t.morphTargetsRelative=this.morphTargetsRelative;const s=this.groups;for(let a=0,o=s.length;a<o;a++){const e=s[a];t.addGroup(e.start,e.count,e.materialIndex)}return t}toJSON(){const e={metadata:{version:4.6,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,""!==this.name&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),void 0!==this.parameters){const t=this.parameters;for(const n in t)void 0!==t[n]&&(e[n]=t[n]);return e}e.data={attributes:{}};const t=this.index;null!==t&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const n=this.attributes;for(const o in n){const t=n[o];e.data.attributes[o]=t.toJSON(e.data)}const r={};let i=!1;for(const o in this.morphAttributes){const t=this.morphAttributes[o],n=[];for(let r=0,i=t.length;r<i;r++){const i=t[r];n.push(i.toJSON(e.data))}n.length>0&&(r[o]=n,i=!0)}i&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);const s=this.groups;s.length>0&&(e.data.groups=JSON.parse(JSON.stringify(s)));const a=this.boundingSphere;return null!==a&&(e.data.boundingSphere={center:a.center.toArray(),radius:a.radius}),e}clone(){return(new this.constructor).copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const n=e.index;null!==n&&this.setIndex(n.clone(t));const r=e.attributes;for(const l in r){const e=r[l];this.setAttribute(l,e.clone(t))}const i=e.morphAttributes;for(const l in i){const e=[],n=i[l];for(let r=0,i=n.length;r<i;r++)e.push(n[r].clone(t));this.morphAttributes[l]=e}this.morphTargetsRelative=e.morphTargetsRelative;const s=e.groups;for(let l=0,u=s.length;l<u;l++){const e=s[l];this.addGroup(e.start,e.count,e.materialIndex)}const a=e.boundingBox;null!==a&&(this.boundingBox=a.clone());const o=e.boundingSphere;return null!==o&&(this.boundingSphere=o.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const Is=new di,Bs=new hi,Ls=new ri,Ds=new Nr,Us=new Nr,Ns=new Nr,Fs=new Nr,Os=new Nr,ks=new Nr,Hs=new ir,zs=new ir,Gs=new ir,Vs=new Nr,Ws=new Nr,js=new Nr,Xs=new Nr,Js=new Nr;class Ys extends ki{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new Ps,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new ss;super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),void 0!==e.morphTargetInfluences&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),void 0!==e.morphTargetDictionary&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){const n=e[t[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e<t;e++){const t=n[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[t]=e}}}}getVertexPosition(e,t){const n=this.geometry,r=n.attributes.position,i=n.morphAttributes.position,s=n.morphTargetsRelative;t.fromBufferAttribute(r,e);const a=this.morphTargetInfluences;if(i&&a){ks.set(0,0,0);for(let n=0,r=i.length;n<r;n++){const r=a[n],o=i[n];0!==r&&(Os.fromBufferAttribute(o,e),s?ks.addScaledVector(Os,r):ks.addScaledVector(Os.sub(t),r))}t.add(ks)}return t}raycast(e,t){const n=this.geometry,r=this.material,i=this.matrixWorld;if(void 0!==r){if(null===n.boundingSphere&&n.computeBoundingSphere(),Ls.copy(n.boundingSphere),Ls.applyMatrix4(i),Bs.copy(e.ray).recast(e.near),!1===Ls.containsPoint(Bs.origin)){if(null===Bs.intersectSphere(Ls,Ds))return;if(Bs.origin.distanceToSquared(Ds)>(e.far-e.near)**2)return}Is.copy(i).invert(),Bs.copy(e.ray).applyMatrix4(Is),null!==n.boundingBox&&!1===Bs.intersectsBox(n.boundingBox)||this._computeIntersections(e,t,Bs)}}_computeIntersections(e,t,n){let r;const i=this.geometry,s=this.material,a=i.index,o=i.attributes.position,l=i.attributes.uv,u=i.attributes.uv1,c=i.attributes.normal,h=i.groups,d=i.drawRange;if(null!==a)if(Array.isArray(s))for(let p=0,f=h.length;p<f;p++){const i=h[p],o=s[i.materialIndex];for(let s=Math.max(i.start,d.start),h=Math.min(a.count,Math.min(i.start+i.count,d.start+d.count));s<h;s+=3){r=Ks(this,o,e,n,l,u,c,a.getX(s),a.getX(s+1),a.getX(s+2)),r&&(r.faceIndex=Math.floor(s/3),r.face.materialIndex=i.materialIndex,t.push(r))}}else{for(let i=Math.max(0,d.start),o=Math.min(a.count,d.start+d.count);i<o;i+=3){r=Ks(this,s,e,n,l,u,c,a.getX(i),a.getX(i+1),a.getX(i+2)),r&&(r.faceIndex=Math.floor(i/3),t.push(r))}}else if(void 0!==o)if(Array.isArray(s))for(let p=0,f=h.length;p<f;p++){const i=h[p],a=s[i.materialIndex];for(let s=Math.max(i.start,d.start),h=Math.min(o.count,Math.min(i.start+i.count,d.start+d.count));s<h;s+=3){r=Ks(this,a,e,n,l,u,c,s,s+1,s+2),r&&(r.faceIndex=Math.floor(s/3),r.face.materialIndex=i.materialIndex,t.push(r))}}else{for(let i=Math.max(0,d.start),a=Math.min(o.count,d.start+d.count);i<a;i+=3){r=Ks(this,s,e,n,l,u,c,i,i+1,i+2),r&&(r.faceIndex=Math.floor(i/3),t.push(r))}}}}function Ks(e,t,n,r,i,s,a,o,l,u){e.getVertexPosition(o,Us),e.getVertexPosition(l,Ns),e.getVertexPosition(u,Fs);const c=function(e,t,n,r,i,s,a,o){let l;if(l=t.side===g?r.intersectTriangle(a,s,i,!0,o):r.intersectTriangle(i,s,a,t.side===m,o),null===l)return null;Js.copy(o),Js.applyMatrix4(e.matrixWorld);const u=n.ray.origin.distanceTo(Js);return u<n.near||u>n.far?null:{distance:u,point:Js.clone(),object:e}}(e,t,n,r,Us,Ns,Fs,Xs);if(c){i&&(Hs.fromBufferAttribute(i,o),zs.fromBufferAttribute(i,l),Gs.fromBufferAttribute(i,u),c.uv=qi.getInterpolation(Xs,Us,Ns,Fs,Hs,zs,Gs,new ir)),s&&(Hs.fromBufferAttribute(s,o),zs.fromBufferAttribute(s,l),Gs.fromBufferAttribute(s,u),c.uv1=qi.getInterpolation(Xs,Us,Ns,Fs,Hs,zs,Gs,new ir)),a&&(Vs.fromBufferAttribute(a,o),Ws.fromBufferAttribute(a,l),js.fromBufferAttribute(a,u),c.normal=qi.getInterpolation(Xs,Us,Ns,Fs,Vs,Ws,js,new Nr),c.normal.dot(r.direction)>0&&c.normal.multiplyScalar(-1));const e={a:o,b:l,c:u,normal:new Nr,materialIndex:0};qi.getNormal(Us,Ns,Fs,e.normal),c.face=e}return c}class qs extends Ps{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:1,s=arguments.length>5&&void 0!==arguments[5]?arguments[5]:1;super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:r,heightSegments:i,depthSegments:s};const a=this;r=Math.floor(r),i=Math.floor(i),s=Math.floor(s);const o=[],l=[],u=[],c=[];let h=0,d=0;function p(e,t,n,r,i,s,p,f,m,g,v){const y=s/m,_=p/g,x=s/2,A=p/2,M=f/2,b=m+1,S=g+1;let w=0,E=0;const T=new Nr;for(let a=0;a<S;a++){const s=a*_-A;for(let o=0;o<b;o++){const h=o*y-x;T[e]=h*r,T[t]=s*i,T[n]=M,l.push(T.x,T.y,T.z),T[e]=0,T[t]=0,T[n]=f>0?1:-1,u.push(T.x,T.y,T.z),c.push(o/m),c.push(1-a/g),w+=1}}for(let a=0;a<g;a++)for(let e=0;e<m;e++){const t=h+e+b*a,n=h+e+b*(a+1),r=h+(e+1)+b*(a+1),i=h+(e+1)+b*a;o.push(t,n,i),o.push(n,r,i),E+=6}a.addGroup(d,E,v),d+=E,h+=w}p("z","y","x",-1,-1,n,t,e,s,i,0),p("z","y","x",1,-1,n,t,-e,s,i,1),p("x","z","y",1,1,e,n,t,r,s,2),p("x","z","y",1,-1,e,n,-t,r,s,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(o),this.setAttribute("position",new Ms(l,3)),this.setAttribute("normal",new Ms(u,3)),this.setAttribute("uv",new Ms(c,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new qs(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function Qs(e){const t={};for(const n in e){t[n]={};for(const r in e[n]){const i=e[n][r];i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)?i.isRenderTargetTexture?(console.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),t[n][r]=null):t[n][r]=i.clone():Array.isArray(i)?t[n][r]=i.slice():t[n][r]=i}}return t}function Zs(e){const t={};for(let n=0;n<e.length;n++){const r=Qs(e[n]);for(const e in r)t[e]=r[e]}return t}function $s(e){const t=e.getRenderTarget();return null===t?e.outputColorSpace:!0===t.isXRRenderTarget?t.texture.colorSpace:yr.workingColorSpace}const ea={clone:Qs,merge:Zs};class ta extends is{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader="void main() {\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",this.fragmentShader="void main() {\n\tgl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );\n}",this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={clipCullDistance:!1,multiDraw:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,void 0!==e&&this.setValues(e)}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=Qs(e.uniforms),this.uniformsGroups=function(e){const t=[];for(let n=0;n<e.length;n++)t.push(e[n].clone());return t}(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this}toJSON(e){const t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(const r in this.uniforms){const n=this.uniforms[r].value;n&&n.isTexture?t.uniforms[r]={type:"t",value:n.toJSON(e).uuid}:n&&n.isColor?t.uniforms[r]={type:"c",value:n.getHex()}:n&&n.isVector2?t.uniforms[r]={type:"v2",value:n.toArray()}:n&&n.isVector3?t.uniforms[r]={type:"v3",value:n.toArray()}:n&&n.isVector4?t.uniforms[r]={type:"v4",value:n.toArray()}:n&&n.isMatrix3?t.uniforms[r]={type:"m3",value:n.toArray()}:n&&n.isMatrix4?t.uniforms[r]={type:"m4",value:n.toArray()}:t.uniforms[r]={value:n}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;const n={};for(const r in this.extensions)!0===this.extensions[r]&&(n[r]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}}class na extends ki{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new di,this.projectionMatrix=new di,this.projectionMatrixInverse=new di,this.coordinateSystem=Wn}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return(new this.constructor).copy(this)}}const ra=new Nr,ia=new ir,sa=new ir;class aa extends na{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:50,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:.1,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:2e3;super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=r,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=null===e.view?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const t=.5*this.getFilmHeight()/e;this.fov=2*qn*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(.5*Kn*this.fov);return.5*this.getFilmHeight()/e}getEffectiveFOV(){return 2*qn*Math.atan(Math.tan(.5*Kn*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,n){ra.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(ra.x,ra.y).multiplyScalar(-e/ra.z),ra.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(ra.x,ra.y).multiplyScalar(-e/ra.z)}getViewSize(e,t){return this.getViewBounds(e,ia,sa),t.subVectors(sa,ia)}setViewOffset(e,t,n,r,i,s){this.aspect=e/t,null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=r,this.view.width=i,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(.5*Kn*this.fov)/this.zoom,n=2*t,r=this.aspect*n,i=-.5*r;const s=this.view;if(null!==this.view&&this.view.enabled){const e=s.fullWidth,a=s.fullHeight;i+=s.offsetX*r/e,t-=s.offsetY*n/a,r*=s.width/e,n*=s.height/a}const a=this.filmOffset;0!==a&&(i+=e*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(i,i+r,t,t-n,e,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,null!==this.view&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}const oa=-90;class la extends ki{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const r=new aa(oa,1,e,t);r.layers=this.layers,this.add(r);const i=new aa(oa,1,e,t);i.layers=this.layers,this.add(i);const s=new aa(oa,1,e,t);s.layers=this.layers,this.add(s);const a=new aa(oa,1,e,t);a.layers=this.layers,this.add(a);const o=new aa(oa,1,e,t);o.layers=this.layers,this.add(o);const l=new aa(oa,1,e,t);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[n,r,i,s,a,o]=t;for(const l of t)this.remove(l);if(e===Wn)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),s.up.set(0,0,1),s.lookAt(0,-1,0),a.up.set(0,1,0),a.lookAt(0,0,1),o.up.set(0,1,0),o.lookAt(0,0,-1);else{if(e!==jn)throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);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),s.up.set(0,0,-1),s.lookAt(0,-1,0),a.up.set(0,-1,0),a.lookAt(0,0,1),o.up.set(0,-1,0),o.lookAt(0,0,-1)}for(const l of t)this.add(l),l.updateMatrixWorld()}update(e,t){null===this.parent&&this.updateMatrixWorld();const{renderTarget:n,activeMipmapLevel:r}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[i,s,a,o,l,u]=this.children,c=e.getRenderTarget(),h=e.getActiveCubeFace(),d=e.getActiveMipmapLevel(),p=e.xr.enabled;e.xr.enabled=!1;const f=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,e.setRenderTarget(n,0,r),e.render(t,i),e.setRenderTarget(n,1,r),e.render(t,s),e.setRenderTarget(n,2,r),e.render(t,a),e.setRenderTarget(n,3,r),e.render(t,o),e.setRenderTarget(n,4,r),e.render(t,l),n.texture.generateMipmaps=f,e.setRenderTarget(n,5,r),e.render(t,u),e.setRenderTarget(c,h,d),e.xr.enabled=p,n.texture.needsPMREMUpdate=!0}}class ua extends Tr{constructor(e,t,n,r,i,s,a,o,l,u){super(e=void 0!==e?e:[],t=void 0!==t?t:de,n,r,i,s,a,o,l,u),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class ca extends Pr{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(e,e,t),this.isWebGLCubeRenderTarget=!0;const n={width:e,height:e,depth:1},r=[n,n,n,n,n,n];this.texture=new ua(r,t.mapping,t.wrapS,t.wrapT,t.magFilter,t.minFilter,t.format,t.type,t.anisotropy,t.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=void 0!==t.generateMipmaps&&t.generateMipmaps,this.texture.minFilter=void 0!==t.minFilter?t.minFilter:we}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const n={uniforms:{tEquirect:{value:null}},vertexShader:"\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\tvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\n\t\t\t\t\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n\n\t\t\t\t}\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvWorldDirection = transformDirection( position, modelMatrix );\n\n\t\t\t\t\t#include <begin_vertex>\n\t\t\t\t\t#include <project_vertex>\n\n\t\t\t\t}\n\t\t\t",fragmentShader:"\n\n\t\t\t\tuniform sampler2D tEquirect;\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\t#include <common>\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvec3 direction = normalize( vWorldDirection );\n\n\t\t\t\t\tvec2 sampleUV = equirectUv( direction );\n\n\t\t\t\t\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\n\t\t\t\t}\n\t\t\t"},r=new qs(5,5,5),i=new ta({name:"CubemapFromEquirect",uniforms:Qs(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:g,blending:y});i.uniforms.tEquirect.value=t;const s=new Ys(r,i),a=t.minFilter;t.minFilter===Ce&&(t.minFilter=we);return new la(1,10,this).update(e,s),t.minFilter=a,s.geometry.dispose(),s.material.dispose(),this}clear(e,t,n,r){const i=e.getRenderTarget();for(let s=0;s<6;s++)e.setRenderTarget(this,s),e.clear(t,n,r);e.setRenderTarget(i)}}const ha=new Nr,da=new Nr,pa=new sr;class fa{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new Nr(1,0,0),t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,r){return this.normal.set(e,t,n),this.constant=r,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){const r=ha.subVectors(n,t).cross(da.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(r,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t){const n=e.delta(ha),r=this.normal.dot(n);if(0===r)return 0===this.distanceToPoint(e.start)?t.copy(e.start):null;const i=-(e.start.dot(this.normal)+this.constant)/r;return i<0||i>1?null:t.copy(e.start).addScaledVector(n,i)}intersectsLine(e){const t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const n=t||pa.getNormalMatrix(e),r=this.coplanarPoint(ha).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)}}const ma=new ri,ga=new Nr;class va{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new fa,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new fa,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new fa,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:new fa,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:new fa,s=arguments.length>5&&void 0!==arguments[5]?arguments[5]:new fa;this.planes=[e,t,n,r,i,s]}set(e,t,n,r,i,s){const a=this.planes;return a[0].copy(e),a[1].copy(t),a[2].copy(n),a[3].copy(r),a[4].copy(i),a[5].copy(s),this}copy(e){const t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Wn;const n=this.planes,r=e.elements,i=r[0],s=r[1],a=r[2],o=r[3],l=r[4],u=r[5],c=r[6],h=r[7],d=r[8],p=r[9],f=r[10],m=r[11],g=r[12],v=r[13],y=r[14],_=r[15];if(n[0].setComponents(o-i,h-l,m-d,_-g).normalize(),n[1].setComponents(o+i,h+l,m+d,_+g).normalize(),n[2].setComponents(o+s,h+u,m+p,_+v).normalize(),n[3].setComponents(o-s,h-u,m-p,_-v).normalize(),n[4].setComponents(o-a,h-c,m-f,_-y).normalize(),t===Wn)n[5].setComponents(o+a,h+c,m+f,_+y).normalize();else{if(t!==jn)throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);n[5].setComponents(a,c,f,y).normalize()}return this}intersectsObject(e){if(void 0!==e.boundingSphere)null===e.boundingSphere&&e.computeBoundingSphere(),ma.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;null===t.boundingSphere&&t.computeBoundingSphere(),ma.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(ma)}intersectsSprite(e){return ma.center.set(0,0,0),ma.radius=.7071067811865476,ma.applyMatrix4(e.matrixWorld),this.intersectsSphere(ma)}intersectsSphere(e){const t=this.planes,n=e.center,r=-e.radius;for(let i=0;i<6;i++){if(t[i].distanceToPoint(n)<r)return!1}return!0}intersectsBox(e){const t=this.planes;for(let n=0;n<6;n++){const r=t[n];if(ga.x=r.normal.x>0?e.max.x:e.min.x,ga.y=r.normal.y>0?e.max.y:e.min.y,ga.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(ga)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return(new this.constructor).copy(this)}}function ya(){let e=null,t=!1,n=null,r=null;function i(t,s){n(t,s),r=e.requestAnimationFrame(i)}return{start:function(){!0!==t&&null!==n&&(r=e.requestAnimationFrame(i),t=!0)},stop:function(){e.cancelAnimationFrame(r),t=!1},setAnimationLoop:function(e){n=e},setContext:function(t){e=t}}}function _a(e){const t=new WeakMap;return{get:function(e){return e.isInterleavedBufferAttribute&&(e=e.data),t.get(e)},remove:function(n){n.isInterleavedBufferAttribute&&(n=n.data);const r=t.get(n);r&&(e.deleteBuffer(r.buffer),t.delete(n))},update:function(n,r){if(n.isInterleavedBufferAttribute&&(n=n.data),n.isGLBufferAttribute){const e=t.get(n);return void((!e||e.version<n.version)&&t.set(n,{buffer:n.buffer,type:n.type,bytesPerElement:n.elementSize,version:n.version}))}const i=t.get(n);if(void 0===i)t.set(n,function(t,n){const r=t.array,i=t.usage,s=r.byteLength,a=e.createBuffer();let o;if(e.bindBuffer(n,a),e.bufferData(n,r,i),t.onUploadCallback(),r instanceof Float32Array)o=e.FLOAT;else if(r instanceof Uint16Array)o=t.isFloat16BufferAttribute?e.HALF_FLOAT:e.UNSIGNED_SHORT;else if(r instanceof Int16Array)o=e.SHORT;else if(r instanceof Uint32Array)o=e.UNSIGNED_INT;else if(r instanceof Int32Array)o=e.INT;else if(r instanceof Int8Array)o=e.BYTE;else if(r instanceof Uint8Array)o=e.UNSIGNED_BYTE;else{if(!(r instanceof Uint8ClampedArray))throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+r);o=e.UNSIGNED_BYTE}return{buffer:a,type:o,bytesPerElement:r.BYTES_PER_ELEMENT,version:t.version,size:s}}(n,r));else if(i.version<n.version){if(i.size!==n.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");!function(t,n,r){const i=n.array,s=n._updateRange,a=n.updateRanges;if(e.bindBuffer(r,t),-1===s.count&&0===a.length&&e.bufferSubData(r,0,i),0!==a.length){for(let t=0,n=a.length;t<n;t++){const n=a[t];e.bufferSubData(r,n.start*i.BYTES_PER_ELEMENT,i,n.start,n.count)}n.clearUpdateRanges()}-1!==s.count&&(e.bufferSubData(r,s.offset*i.BYTES_PER_ELEMENT,i,s.offset,s.count),s.count=-1),n.onUploadCallback()}(i.buffer,n,r),i.version=n.version}}}}class xa extends Ps{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1;super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:r};const i=e/2,s=t/2,a=Math.floor(n),o=Math.floor(r),l=a+1,u=o+1,c=e/a,h=t/o,d=[],p=[],f=[],m=[];for(let g=0;g<u;g++){const e=g*h-s;for(let t=0;t<l;t++){const n=t*c-i;p.push(n,-e,0),f.push(0,0,1),m.push(t/a),m.push(1-g/o)}}for(let g=0;g<o;g++)for(let e=0;e<a;e++){const t=e+l*g,n=e+l*(g+1),r=e+1+l*(g+1),i=e+1+l*g;d.push(t,n,i),d.push(n,r,i)}this.setIndex(d),this.setAttribute("position",new Ms(p,3)),this.setAttribute("normal",new Ms(f,3)),this.setAttribute("uv",new Ms(m,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new xa(e.width,e.height,e.widthSegments,e.heightSegments)}}const Aa={alphahash_fragment:"#ifdef USE_ALPHAHASH\n\tif ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;\n#endif",alphahash_pars_fragment:"#ifdef USE_ALPHAHASH\n\tconst float ALPHA_HASH_SCALE = 0.05;\n\tfloat hash2D( vec2 value ) {\n\t\treturn fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );\n\t}\n\tfloat hash3D( vec3 value ) {\n\t\treturn hash2D( vec2( hash2D( value.xy ), value.z ) );\n\t}\n\tfloat getAlphaHashThreshold( vec3 position ) {\n\t\tfloat maxDeriv = max(\n\t\t\tlength( dFdx( position.xyz ) ),\n\t\t\tlength( dFdy( position.xyz ) )\n\t\t);\n\t\tfloat pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );\n\t\tvec2 pixScales = vec2(\n\t\t\texp2( floor( log2( pixScale ) ) ),\n\t\t\texp2( ceil( log2( pixScale ) ) )\n\t\t);\n\t\tvec2 alpha = vec2(\n\t\t\thash3D( floor( pixScales.x * position.xyz ) ),\n\t\t\thash3D( floor( pixScales.y * position.xyz ) )\n\t\t);\n\t\tfloat lerpFactor = fract( log2( pixScale ) );\n\t\tfloat x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;\n\t\tfloat a = min( lerpFactor, 1.0 - lerpFactor );\n\t\tvec3 cases = vec3(\n\t\t\tx * x / ( 2.0 * a * ( 1.0 - a ) ),\n\t\t\t( x - 0.5 * a ) / ( 1.0 - a ),\n\t\t\t1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )\n\t\t);\n\t\tfloat threshold = ( x < ( 1.0 - a ) )\n\t\t\t? ( ( x < a ) ? cases.x : cases.y )\n\t\t\t: cases.z;\n\t\treturn clamp( threshold , 1.0e-6, 1.0 );\n\t}\n#endif",alphamap_fragment:"#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;\n#endif",alphamap_pars_fragment:"#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",alphatest_fragment:"#ifdef USE_ALPHATEST\n\t#ifdef ALPHA_TO_COVERAGE\n\tdiffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );\n\tif ( diffuseColor.a == 0.0 ) discard;\n\t#else\n\tif ( diffuseColor.a < alphaTest ) discard;\n\t#endif\n#endif",alphatest_pars_fragment:"#ifdef USE_ALPHATEST\n\tuniform float alphaTest;\n#endif",aomap_fragment:"#ifdef USE_AOMAP\n\tfloat ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;\n\treflectedLight.indirectDiffuse *= ambientOcclusion;\n\t#if defined( USE_CLEARCOAT ) \n\t\tclearcoatSpecularIndirect *= ambientOcclusion;\n\t#endif\n\t#if defined( USE_SHEEN ) \n\t\tsheenSpecularIndirect *= ambientOcclusion;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD )\n\t\tfloat dotNV = saturate( dot( geometryNormal, geometryViewDir ) );\n\t\treflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );\n\t#endif\n#endif",aomap_pars_fragment:"#ifdef USE_AOMAP\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n#endif",batching_pars_vertex:"#ifdef USE_BATCHING\n\t#if ! defined( GL_ANGLE_multi_draw )\n\t#define gl_DrawID _gl_DrawID\n\tuniform int _gl_DrawID;\n\t#endif\n\tuniform highp sampler2D batchingTexture;\n\tuniform highp usampler2D batchingIdTexture;\n\tmat4 getBatchingMatrix( const in float i ) {\n\t\tint size = textureSize( batchingTexture, 0 ).x;\n\t\tint j = int( i ) * 4;\n\t\tint x = j % size;\n\t\tint y = j / size;\n\t\tvec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );\n\t\tvec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );\n\t\tvec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );\n\t\tvec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );\n\t\treturn mat4( v1, v2, v3, v4 );\n\t}\n\tfloat getIndirectIndex( const in int i ) {\n\t\tint size = textureSize( batchingIdTexture, 0 ).x;\n\t\tint x = i % size;\n\t\tint y = i / size;\n\t\treturn float( texelFetch( batchingIdTexture, ivec2( x, y ), 0 ).r );\n\t}\n#endif\n#ifdef USE_BATCHING_COLOR\n\tuniform sampler2D batchingColorTexture;\n\tvec3 getBatchingColor( const in float i ) {\n\t\tint size = textureSize( batchingColorTexture, 0 ).x;\n\t\tint j = int( i );\n\t\tint x = j % size;\n\t\tint y = j / size;\n\t\treturn texelFetch( batchingColorTexture, ivec2( x, y ), 0 ).rgb;\n\t}\n#endif",batching_vertex:"#ifdef USE_BATCHING\n\tmat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );\n#endif",begin_vertex:"vec3 transformed = vec3( position );\n#ifdef USE_ALPHAHASH\n\tvPosition = vec3( position );\n#endif",beginnormal_vertex:"vec3 objectNormal = vec3( normal );\n#ifdef USE_TANGENT\n\tvec3 objectTangent = vec3( tangent.xyz );\n#endif",bsdfs:"float G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, 1.0, dotVH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n} // validated",iridescence_fragment:"#ifdef USE_IRIDESCENCE\n\tconst mat3 XYZ_TO_REC709 = mat3(\n\t\t 3.2404542, -0.9692660, 0.0556434,\n\t\t-1.5371385, 1.8760108, -0.2040259,\n\t\t-0.4985314, 0.0415560, 1.0572252\n\t);\n\tvec3 Fresnel0ToIor( vec3 fresnel0 ) {\n\t\tvec3 sqrtF0 = sqrt( fresnel0 );\n\t\treturn ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );\n\t}\n\tvec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {\n\t\treturn pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );\n\t}\n\tfloat IorToFresnel0( float transmittedIor, float incidentIor ) {\n\t\treturn pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));\n\t}\n\tvec3 evalSensitivity( float OPD, vec3 shift ) {\n\t\tfloat phase = 2.0 * PI * OPD * 1.0e-9;\n\t\tvec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );\n\t\tvec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );\n\t\tvec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );\n\t\tvec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );\n\t\txyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );\n\t\txyz /= 1.0685e-7;\n\t\tvec3 rgb = XYZ_TO_REC709 * xyz;\n\t\treturn rgb;\n\t}\n\tvec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {\n\t\tvec3 I;\n\t\tfloat iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );\n\t\tfloat sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );\n\t\tfloat cosTheta2Sq = 1.0 - sinTheta2Sq;\n\t\tif ( cosTheta2Sq < 0.0 ) {\n\t\t\treturn vec3( 1.0 );\n\t\t}\n\t\tfloat cosTheta2 = sqrt( cosTheta2Sq );\n\t\tfloat R0 = IorToFresnel0( iridescenceIOR, outsideIOR );\n\t\tfloat R12 = F_Schlick( R0, 1.0, cosTheta1 );\n\t\tfloat T121 = 1.0 - R12;\n\t\tfloat phi12 = 0.0;\n\t\tif ( iridescenceIOR < outsideIOR ) phi12 = PI;\n\t\tfloat phi21 = PI - phi12;\n\t\tvec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) );\t\tvec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );\n\t\tvec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );\n\t\tvec3 phi23 = vec3( 0.0 );\n\t\tif ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;\n\t\tif ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;\n\t\tif ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;\n\t\tfloat OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;\n\t\tvec3 phi = vec3( phi21 ) + phi23;\n\t\tvec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );\n\t\tvec3 r123 = sqrt( R123 );\n\t\tvec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );\n\t\tvec3 C0 = R12 + Rs;\n\t\tI = C0;\n\t\tvec3 Cm = Rs - T121;\n\t\tfor ( int m = 1; m <= 2; ++ m ) {\n\t\t\tCm *= r123;\n\t\t\tvec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );\n\t\t\tI += Cm * Sm;\n\t\t}\n\t\treturn max( I, vec3( 0.0 ) );\n\t}\n#endif",bumpmap_pars_fragment:"#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vBumpMapUv );\n\t\tvec2 dSTdy = dFdy( vBumpMapUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {\n\t\tvec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );\n\t\tvec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );\n\t\tvec3 vN = surf_norm;\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\t\tfloat fDet = dot( vSigmaX, R1 ) * faceDirection;\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif",clipping_planes_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvec4 plane;\n\t#ifdef ALPHA_TO_COVERAGE\n\t\tfloat distanceToPlane, distanceGradient;\n\t\tfloat clipOpacity = 1.0;\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tdistanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;\n\t\t\tdistanceGradient = fwidth( distanceToPlane ) / 2.0;\n\t\t\tclipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane );\n\t\t\tif ( clipOpacity == 0.0 ) discard;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\t\tfloat unionClipOpacity = 1.0;\n\t\t\t#pragma unroll_loop_start\n\t\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\t\tplane = clippingPlanes[ i ];\n\t\t\t\tdistanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;\n\t\t\t\tdistanceGradient = fwidth( distanceToPlane ) / 2.0;\n\t\t\t\tunionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane );\n\t\t\t}\n\t\t\t#pragma unroll_loop_end\n\t\t\tclipOpacity *= 1.0 - unionClipOpacity;\n\t\t#endif\n\t\tdiffuseColor.a *= clipOpacity;\n\t\tif ( diffuseColor.a == 0.0 ) discard;\n\t#else\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tif ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\t\tbool clipped = true;\n\t\t\t#pragma unroll_loop_start\n\t\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\t\tplane = clippingPlanes[ i ];\n\t\t\t\tclipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t\t}\n\t\t\t#pragma unroll_loop_end\n\t\t\tif ( clipped ) discard;\n\t\t#endif\n\t#endif\n#endif",clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n#endif",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvClipPosition = - mvPosition.xyz;\n#endif",color_fragment:"#if defined( USE_COLOR_ALPHA )\n\tdiffuseColor *= vColor;\n#elif defined( USE_COLOR )\n\tdiffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR )\n\tvarying vec3 vColor;\n#endif",color_pars_vertex:"#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )\n\tvarying vec3 vColor;\n#endif",color_vertex:"#if defined( USE_COLOR_ALPHA )\n\tvColor = vec4( 1.0 );\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )\n\tvColor = vec3( 1.0 );\n#endif\n#ifdef USE_COLOR\n\tvColor *= color;\n#endif\n#ifdef USE_INSTANCING_COLOR\n\tvColor.xyz *= instanceColor.xyz;\n#endif\n#ifdef USE_BATCHING_COLOR\n\tvec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) );\n\tvColor.xyz *= batchingColor.xyz;\n#endif",common:"#define PI 3.141592653589793\n#define PI2 6.283185307179586\n#define PI_HALF 1.5707963267948966\n#define RECIPROCAL_PI 0.3183098861837907\n#define RECIPROCAL_PI2 0.15915494309189535\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement( a ) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nvec3 pow2( const in vec3 x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }\nfloat average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract( sin( sn ) * c );\n}\n#ifdef HIGH_PRECISION\n\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n\tfloat precisionSafeLength( vec3 v ) {\n\t\tfloat maxComponent = max3( abs( v ) );\n\t\treturn length( v / maxComponent ) * maxComponent;\n\t}\n#endif\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\n#ifdef USE_ALPHAHASH\n\tvarying vec3 vPosition;\n#endif\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nbool isPerspectiveMatrix( mat4 m ) {\n\treturn m[ 2 ][ 3 ] == - 1.0;\n}\nvec2 equirectUv( in vec3 dir ) {\n\tfloat u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;\n\tfloat v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\treturn vec2( u, v );\n}\nvec3 BRDF_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n}\nfloat F_Schlick( const in float f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n} // validated",cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n\t#define cubeUV_minMipLevel 4.0\n\t#define cubeUV_minTileSize 16.0\n\tfloat getFace( vec3 direction ) {\n\t\tvec3 absDirection = abs( direction );\n\t\tfloat face = - 1.0;\n\t\tif ( absDirection.x > absDirection.z ) {\n\t\t\tif ( absDirection.x > absDirection.y )\n\t\t\t\tface = direction.x > 0.0 ? 0.0 : 3.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t} else {\n\t\t\tif ( absDirection.z > absDirection.y )\n\t\t\t\tface = direction.z > 0.0 ? 2.0 : 5.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t}\n\t\treturn face;\n\t}\n\tvec2 getUV( vec3 direction, float face ) {\n\t\tvec2 uv;\n\t\tif ( face == 0.0 ) {\n\t\t\tuv = vec2( direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 1.0 ) {\n\t\t\tuv = vec2( - direction.x, - direction.z ) / abs( direction.y );\n\t\t} else if ( face == 2.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.y ) / abs( direction.z );\n\t\t} else if ( face == 3.0 ) {\n\t\t\tuv = vec2( - direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 4.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.z ) / abs( direction.y );\n\t\t} else {\n\t\t\tuv = vec2( direction.x, direction.y ) / abs( direction.z );\n\t\t}\n\t\treturn 0.5 * ( uv + 1.0 );\n\t}\n\tvec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {\n\t\tfloat face = getFace( direction );\n\t\tfloat filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );\n\t\tmipInt = max( mipInt, cubeUV_minMipLevel );\n\t\tfloat faceSize = exp2( mipInt );\n\t\thighp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;\n\t\tif ( face > 2.0 ) {\n\t\t\tuv.y += faceSize;\n\t\t\tface -= 3.0;\n\t\t}\n\t\tuv.x += face * faceSize;\n\t\tuv.x += filterInt * 3.0 * cubeUV_minTileSize;\n\t\tuv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );\n\t\tuv.x *= CUBEUV_TEXEL_WIDTH;\n\t\tuv.y *= CUBEUV_TEXEL_HEIGHT;\n\t\t#ifdef texture2DGradEXT\n\t\t\treturn texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;\n\t\t#else\n\t\t\treturn texture2D( envMap, uv ).rgb;\n\t\t#endif\n\t}\n\t#define cubeUV_r0 1.0\n\t#define cubeUV_m0 - 2.0\n\t#define cubeUV_r1 0.8\n\t#define cubeUV_m1 - 1.0\n\t#define cubeUV_r4 0.4\n\t#define cubeUV_m4 2.0\n\t#define cubeUV_r5 0.305\n\t#define cubeUV_m5 3.0\n\t#define cubeUV_r6 0.21\n\t#define cubeUV_m6 4.0\n\tfloat roughnessToMip( float roughness ) {\n\t\tfloat mip = 0.0;\n\t\tif ( roughness >= cubeUV_r1 ) {\n\t\t\tmip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;\n\t\t} else if ( roughness >= cubeUV_r4 ) {\n\t\t\tmip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;\n\t\t} else if ( roughness >= cubeUV_r5 ) {\n\t\t\tmip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;\n\t\t} else if ( roughness >= cubeUV_r6 ) {\n\t\t\tmip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;\n\t\t} else {\n\t\t\tmip = - 2.0 * log2( 1.16 * roughness );\t\t}\n\t\treturn mip;\n\t}\n\tvec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {\n\t\tfloat mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );\n\t\tfloat mipF = fract( mip );\n\t\tfloat mipInt = floor( mip );\n\t\tvec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );\n\t\tif ( mipF == 0.0 ) {\n\t\t\treturn vec4( color0, 1.0 );\n\t\t} else {\n\t\t\tvec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );\n\t\t\treturn vec4( mix( color0, color1, mipF ), 1.0 );\n\t\t}\n\t}\n#endif",defaultnormal_vertex:"vec3 transformedNormal = objectNormal;\n#ifdef USE_TANGENT\n\tvec3 transformedTangent = objectTangent;\n#endif\n#ifdef USE_BATCHING\n\tmat3 bm = mat3( batchingMatrix );\n\ttransformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );\n\ttransformedNormal = bm * transformedNormal;\n\t#ifdef USE_TANGENT\n\t\ttransformedTangent = bm * transformedTangent;\n\t#endif\n#endif\n#ifdef USE_INSTANCING\n\tmat3 im = mat3( instanceMatrix );\n\ttransformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );\n\ttransformedNormal = im * transformedNormal;\n\t#ifdef USE_TANGENT\n\t\ttransformedTangent = im * transformedTangent;\n\t#endif\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n\ttransformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;\n\t#ifdef FLIP_SIDED\n\t\ttransformedTangent = - transformedTangent;\n\t#endif\n#endif",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );\n#endif",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif",colorspace_fragment:"gl_FragColor = linearToOutputTexel( gl_FragColor );",colorspace_pars_fragment:"\nconst mat3 LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 = mat3(\n\tvec3( 0.8224621, 0.177538, 0.0 ),\n\tvec3( 0.0331941, 0.9668058, 0.0 ),\n\tvec3( 0.0170827, 0.0723974, 0.9105199 )\n);\nconst mat3 LINEAR_DISPLAY_P3_TO_LINEAR_SRGB = mat3(\n\tvec3( 1.2249401, - 0.2249404, 0.0 ),\n\tvec3( - 0.0420569, 1.0420571, 0.0 ),\n\tvec3( - 0.0196376, - 0.0786361, 1.0982735 )\n);\nvec4 LinearSRGBToLinearDisplayP3( in vec4 value ) {\n\treturn vec4( value.rgb * LINEAR_SRGB_TO_LINEAR_DISPLAY_P3, value.a );\n}\nvec4 LinearDisplayP3ToLinearSRGB( in vec4 value ) {\n\treturn vec4( value.rgb * LINEAR_DISPLAY_P3_TO_LINEAR_SRGB, value.a );\n}\nvec4 LinearTransferOETF( in vec4 value ) {\n\treturn value;\n}\nvec4 sRGBTransferOETF( in vec4 value ) {\n\treturn 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 );\n}",envmap_fragment:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvec3 cameraToFrag;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToFrag, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif",envmap_common_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float envMapIntensity;\n\tuniform float flipEnvMap;\n\tuniform mat3 envMapRotation;\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\t\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float reflectivity;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\tvarying vec3 vWorldPosition;\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\t\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif",envmap_physical_pars_fragment:"#ifdef USE_ENVMAP\n\tvec3 getIBLIrradiance( const in vec3 normal ) {\n\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );\n\t\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\tvec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {\n\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\tvec3 reflectVec = reflect( - viewDir, normal );\n\t\t\treflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );\n\t\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );\n\t\t\treturn envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\t#ifdef USE_ANISOTROPY\n\t\tvec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {\n\t\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\t\tvec3 bentNormal = cross( bitangent, viewDir );\n\t\t\t\tbentNormal = normalize( cross( bentNormal, bitangent ) );\n\t\t\t\tbentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );\n\t\t\t\treturn getIBLRadiance( viewDir, bentNormal, roughness );\n\t\t\t#else\n\t\t\t\treturn vec3( 0.0 );\n\t\t\t#endif\n\t\t}\n\t#endif\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif",fog_vertex:"#ifdef USE_FOG\n\tvFogDepth = - mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\n\tvarying float vFogDepth;\n#endif",fog_fragment:"#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, vFogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif",fog_pars_fragment:"#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float vFogDepth;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif",gradientmap_pars_fragment:"#ifdef USE_GRADIENTMAP\n\tuniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\tfloat dotNL = dot( normal, lightDirection );\n\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t#ifdef USE_GRADIENTMAP\n\t\treturn vec3( texture2D( gradientMap, coord ).r );\n\t#else\n\t\tvec2 fw = fwidth( coord ) * 0.5;\n\t\treturn mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );\n\t#endif\n}",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif",lights_lambert_fragment:"LambertMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularStrength = specularStrength;",lights_lambert_pars_fragment:"varying vec3 vViewPosition;\nstruct LambertMaterial {\n\tvec3 diffuseColor;\n\tfloat specularStrength;\n};\nvoid 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 ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid 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 ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Lambert\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Lambert",lights_pars_begin:"uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\n#if defined( USE_LIGHT_PROBES )\n\tuniform vec3 lightProbe[ 9 ];\n#endif\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\treturn result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {\n\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\treturn irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\treturn irradiance;\n}\nfloat getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\tif ( cutoffDistance > 0.0 ) {\n\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t}\n\treturn distanceFalloff;\n}\nfloat getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {\n\treturn smoothstep( coneCosine, penumbraCosine, angleCosine );\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {\n\t\tlight.color = directionalLight.color;\n\t\tlight.direction = directionalLight.direction;\n\t\tlight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {\n\t\tvec3 lVector = pointLight.position - geometryPosition;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tlight.color = pointLight.color;\n\t\tlight.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );\n\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {\n\t\tvec3 lVector = spotLight.position - geometryPosition;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat angleCos = dot( light.direction, spotLight.direction );\n\t\tfloat spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\tif ( spotAttenuation > 0.0 ) {\n\t\t\tfloat lightDistance = length( lVector );\n\t\t\tlight.color = spotLight.color * spotAttenuation;\n\t\t\tlight.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t\t} else {\n\t\t\tlight.color = vec3( 0.0 );\n\t\t\tlight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltc_1;\tuniform sampler2D ltc_2;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {\n\t\tfloat dotNL = dot( normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\treturn irradiance;\n\t}\n#endif",lights_toon_fragment:"ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;",lights_toon_pars_fragment:"varying vec3 vViewPosition;\nstruct ToonMaterial {\n\tvec3 diffuseColor;\n};\nvoid 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 ) {\n\tvec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid 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 ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Toon\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Toon",lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;",lights_phong_pars_fragment:"varying vec3 vViewPosition;\nstruct BlinnPhongMaterial {\n\tvec3 diffuseColor;\n\tvec3 specularColor;\n\tfloat specularShininess;\n\tfloat specularStrength;\n};\nvoid 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 ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid 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 ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong",lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nvec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;\nmaterial.roughness = min( material.roughness, 1.0 );\n#ifdef IOR\n\tmaterial.ior = ior;\n\t#ifdef USE_SPECULAR\n\t\tfloat specularIntensityFactor = specularIntensity;\n\t\tvec3 specularColorFactor = specularColor;\n\t\t#ifdef USE_SPECULAR_COLORMAP\n\t\t\tspecularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;\n\t\t#endif\n\t\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\t\tspecularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;\n\t\t#endif\n\t\tmaterial.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );\n\t#else\n\t\tfloat specularIntensityFactor = 1.0;\n\t\tvec3 specularColorFactor = vec3( 1.0 );\n\t\tmaterial.specularF90 = 1.0;\n\t#endif\n\tmaterial.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );\n\tmaterial.specularF90 = 1.0;\n#endif\n#ifdef USE_CLEARCOAT\n\tmaterial.clearcoat = clearcoat;\n\tmaterial.clearcoatRoughness = clearcoatRoughness;\n\tmaterial.clearcoatF0 = vec3( 0.04 );\n\tmaterial.clearcoatF90 = 1.0;\n\t#ifdef USE_CLEARCOATMAP\n\t\tmaterial.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;\n\t#endif\n\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\t\tmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;\n\t#endif\n\tmaterial.clearcoat = saturate( material.clearcoat );\tmaterial.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n\tmaterial.clearcoatRoughness += geometryRoughness;\n\tmaterial.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_DISPERSION\n\tmaterial.dispersion = dispersion;\n#endif\n#ifdef USE_IRIDESCENCE\n\tmaterial.iridescence = iridescence;\n\tmaterial.iridescenceIOR = iridescenceIOR;\n\t#ifdef USE_IRIDESCENCEMAP\n\t\tmaterial.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;\n\t#endif\n\t#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\t\tmaterial.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;\n\t#else\n\t\tmaterial.iridescenceThickness = iridescenceThicknessMaximum;\n\t#endif\n#endif\n#ifdef USE_SHEEN\n\tmaterial.sheenColor = sheenColor;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tmaterial.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;\n\t#endif\n\tmaterial.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tmaterial.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;\n\t#endif\n#endif\n#ifdef USE_ANISOTROPY\n\t#ifdef USE_ANISOTROPYMAP\n\t\tmat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );\n\t\tvec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;\n\t\tvec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;\n\t#else\n\t\tvec2 anisotropyV = anisotropyVector;\n\t#endif\n\tmaterial.anisotropy = length( anisotropyV );\n\tif( material.anisotropy == 0.0 ) {\n\t\tanisotropyV = vec2( 1.0, 0.0 );\n\t} else {\n\t\tanisotropyV /= material.anisotropy;\n\t\tmaterial.anisotropy = saturate( material.anisotropy );\n\t}\n\tmaterial.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );\n\tmaterial.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;\n\tmaterial.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;\n#endif",lights_physical_pars_fragment:"struct PhysicalMaterial {\n\tvec3 diffuseColor;\n\tfloat roughness;\n\tvec3 specularColor;\n\tfloat specularF90;\n\tfloat dispersion;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat clearcoat;\n\t\tfloat clearcoatRoughness;\n\t\tvec3 clearcoatF0;\n\t\tfloat clearcoatF90;\n\t#endif\n\t#ifdef USE_IRIDESCENCE\n\t\tfloat iridescence;\n\t\tfloat iridescenceIOR;\n\t\tfloat iridescenceThickness;\n\t\tvec3 iridescenceFresnel;\n\t\tvec3 iridescenceF0;\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tvec3 sheenColor;\n\t\tfloat sheenRoughness;\n\t#endif\n\t#ifdef IOR\n\t\tfloat ior;\n\t#endif\n\t#ifdef USE_TRANSMISSION\n\t\tfloat transmission;\n\t\tfloat transmissionAlpha;\n\t\tfloat thickness;\n\t\tfloat attenuationDistance;\n\t\tvec3 attenuationColor;\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat anisotropy;\n\t\tfloat alphaT;\n\t\tvec3 anisotropyT;\n\t\tvec3 anisotropyB;\n\t#endif\n};\nvec3 clearcoatSpecularDirect = vec3( 0.0 );\nvec3 clearcoatSpecularIndirect = vec3( 0.0 );\nvec3 sheenSpecularDirect = vec3( 0.0 );\nvec3 sheenSpecularIndirect = vec3(0.0 );\nvec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {\n float x = clamp( 1.0 - dotVH, 0.0, 1.0 );\n float x2 = x * x;\n float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );\n return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );\n}\nfloat V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\n#ifdef USE_ANISOTROPY\n\tfloat 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 ) {\n\t\tfloat gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );\n\t\tfloat gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );\n\t\tfloat v = 0.5 / ( gv + gl );\n\t\treturn saturate(v);\n\t}\n\tfloat D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {\n\t\tfloat a2 = alphaT * alphaB;\n\t\thighp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );\n\t\thighp float v2 = dot( v, v );\n\t\tfloat w2 = a2 / v2;\n\t\treturn RECIPROCAL_PI * a2 * pow2 ( w2 );\n\t}\n#endif\n#ifdef USE_CLEARCOAT\n\tvec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {\n\t\tvec3 f0 = material.clearcoatF0;\n\t\tfloat f90 = material.clearcoatF90;\n\t\tfloat roughness = material.clearcoatRoughness;\n\t\tfloat alpha = pow2( roughness );\n\t\tvec3 halfDir = normalize( lightDir + viewDir );\n\t\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\t\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\t\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\t\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\t\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t\treturn F * ( V * D );\n\t}\n#endif\nvec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n\tvec3 f0 = material.specularColor;\n\tfloat f90 = material.specularF90;\n\tfloat roughness = material.roughness;\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t#ifdef USE_IRIDESCENCE\n\t\tF = mix( F, material.iridescenceFresnel, material.iridescence );\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat dotTL = dot( material.anisotropyT, lightDir );\n\t\tfloat dotTV = dot( material.anisotropyT, viewDir );\n\t\tfloat dotTH = dot( material.anisotropyT, halfDir );\n\t\tfloat dotBL = dot( material.anisotropyB, lightDir );\n\t\tfloat dotBV = dot( material.anisotropyB, viewDir );\n\t\tfloat dotBH = dot( material.anisotropyB, halfDir );\n\t\tfloat V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );\n\t\tfloat D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );\n\t#else\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t#endif\n\treturn F * ( V * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie( float roughness, float dotNH ) {\n\tfloat alpha = pow2( roughness );\n\tfloat invAlpha = 1.0 / alpha;\n\tfloat cos2h = dotNH * dotNH;\n\tfloat sin2h = max( 1.0 - cos2h, 0.0078125 );\n\treturn ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );\n}\nfloat V_Neubelt( float dotNV, float dotNL ) {\n\treturn saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );\n}\nvec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat D = D_Charlie( sheenRoughness, dotNH );\n\tfloat V = V_Neubelt( dotNV, dotNL );\n\treturn sheenColor * ( D * V );\n}\n#endif\nfloat IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat r2 = roughness * roughness;\n\tfloat a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;\n\tfloat b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;\n\tfloat DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );\n\treturn saturate( DG * RECIPROCAL_PI );\n}\nvec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\tvec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;\n\treturn fab;\n}\nvec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\treturn specularColor * fab.x + specularF90 * fab.y;\n}\n#ifdef USE_IRIDESCENCE\nvoid 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 ) {\n#else\nvoid 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 ) {\n#endif\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\t#ifdef USE_IRIDESCENCE\n\t\tvec3 Fr = mix( specularColor, iridescenceF0, iridescence );\n\t#else\n\t\tvec3 Fr = specularColor;\n\t#endif\n\tvec3 FssEss = Fr * fab.x + specularF90 * fab.y;\n\tfloat Ess = fab.x + fab.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid 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 ) {\n\t\tvec3 normal = geometryNormal;\n\t\tvec3 viewDir = geometryViewDir;\n\t\tvec3 position = geometryPosition;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.roughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 0, 1, 0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t}\n#endif\nvoid 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 ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = dotNLcc * directLight.color;\n\t\tclearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );\n\t#endif\n\treflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material );\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid 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 ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid 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) {\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n\t#endif\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\t#ifdef USE_IRIDESCENCE\n\t\tcomputeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );\n\t#else\n\t\tcomputeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );\n\t#endif\n\tvec3 totalScattering = singleScattering + multiScattering;\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );\n\treflectedLight.indirectSpecular += radiance * singleScattering;\n\treflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}",lights_fragment_begin:"\nvec3 geometryPosition = - vViewPosition;\nvec3 geometryNormal = normal;\nvec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\nvec3 geometryClearcoatNormal = vec3( 0.0 );\n#ifdef USE_CLEARCOAT\n\tgeometryClearcoatNormal = clearcoatNormal;\n#endif\n#ifdef USE_IRIDESCENCE\n\tfloat dotNVi = saturate( dot( normal, geometryViewDir ) );\n\tif ( material.iridescenceThickness == 0.0 ) {\n\t\tmaterial.iridescence = 0.0;\n\t} else {\n\t\tmaterial.iridescence = saturate( material.iridescence );\n\t}\n\tif ( material.iridescence > 0.0 ) {\n\t\tmaterial.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );\n\t\tmaterial.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );\n\t}\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointLightInfo( pointLight, geometryPosition, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\tvec4 spotColor;\n\tvec3 spotLightCoord;\n\tbool inSpotLightMap;\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotLightInfo( spotLight, geometryPosition, directLight );\n\t\t#if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX\n\t\t#elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t#define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS\n\t\t#else\n\t\t#define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#endif\n\t\t#if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )\n\t\t\tspotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;\n\t\t\tinSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );\n\t\t\tspotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );\n\t\t\tdirectLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;\n\t\t#endif\n\t\t#undef SPOT_LIGHT_MAP_INDEX\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tspotLightShadow = spotLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalLightInfo( directionalLight, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 iblIrradiance = vec3( 0.0 );\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\t#if defined( USE_LIGHT_PROBES )\n\t\tirradiance += getLightProbeIrradiance( lightProbe, geometryNormal );\n\t#endif\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n#endif",lights_fragment_maps:"#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\t\tvec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tiblIrradiance += getIBLIrradiance( geometryNormal );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\t#ifdef USE_ANISOTROPY\n\t\tradiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );\n\t#else\n\t\tradiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );\n\t#endif\n#endif",lights_fragment_end:"#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif",logdepthbuf_fragment:"#if defined( USE_LOGDEPTHBUF )\n\tgl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#if defined( USE_LOGDEPTHBUF )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_pars_vertex:"#ifdef USE_LOGDEPTHBUF\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGDEPTHBUF\n\tvFragDepth = 1.0 + gl_Position.w;\n\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n#endif",map_fragment:"#ifdef USE_MAP\n\tvec4 sampledDiffuseColor = texture2D( map, vMapUv );\n\t#ifdef DECODE_VIDEO_TEXTURE\n\t\tsampledDiffuseColor = vec4( mix( pow( sampledDiffuseColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), sampledDiffuseColor.rgb * 0.0773993808, vec3( lessThanEqual( sampledDiffuseColor.rgb, vec3( 0.04045 ) ) ) ), sampledDiffuseColor.w );\n\t\n\t#endif\n\tdiffuseColor *= sampledDiffuseColor;\n#endif",map_pars_fragment:"#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif",map_particle_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\t#if defined( USE_POINTS_UV )\n\t\tvec2 uv = vUv;\n\t#else\n\t\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n\t#endif\n#endif\n#ifdef USE_MAP\n\tdiffuseColor *= texture2D( map, uv );\n#endif\n#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, uv ).g;\n#endif",map_particle_pars_fragment:"#if defined( USE_POINTS_UV )\n\tvarying vec2 vUv;\n#else\n\t#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\t\tuniform mat3 uvTransform;\n\t#endif\n#endif\n#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif",metalnessmap_pars_fragment:"#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif",morphinstance_vertex:"#ifdef USE_INSTANCING_MORPH\n\tfloat morphTargetInfluences[ MORPHTARGETS_COUNT ];\n\tfloat morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\tmorphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;\n\t}\n#endif",morphcolor_vertex:"#if defined( USE_MORPHCOLORS )\n\tvColor *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t#if defined( USE_COLOR_ALPHA )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];\n\t\t#elif defined( USE_COLOR )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];\n\t\t#endif\n\t}\n#endif",morphnormal_vertex:"#ifdef USE_MORPHNORMALS\n\tobjectNormal *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\tif ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];\n\t}\n#endif",morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\n\t#ifndef USE_INSTANCING_MORPH\n\t\tuniform float morphTargetBaseInfluence;\n\t\tuniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];\n\t#endif\n\tuniform sampler2DArray morphTargetsTexture;\n\tuniform ivec2 morphTargetsTextureSize;\n\tvec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {\n\t\tint texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;\n\t\tint y = texelIndex / morphTargetsTextureSize.x;\n\t\tint x = texelIndex - y * morphTargetsTextureSize.x;\n\t\tivec3 morphUV = ivec3( x, y, morphTargetIndex );\n\t\treturn texelFetch( morphTargetsTexture, morphUV, 0 );\n\t}\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\n\ttransformed *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\tif ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];\n\t}\n#endif",normal_fragment_begin:"float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;\n#ifdef FLAT_SHADED\n\tvec3 fdx = dFdx( vViewPosition );\n\tvec3 fdy = dFdy( vViewPosition );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal *= faceDirection;\n\t#endif\n#endif\n#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )\n\t#ifdef USE_TANGENT\n\t\tmat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\t#else\n\t\tmat3 tbn = getTangentFrame( - vViewPosition, normal,\n\t\t#if defined( USE_NORMALMAP )\n\t\t\tvNormalMapUv\n\t\t#elif defined( USE_CLEARCOAT_NORMALMAP )\n\t\t\tvClearcoatNormalMapUv\n\t\t#else\n\t\t\tvUv\n\t\t#endif\n\t\t);\n\t#endif\n\t#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n\t\ttbn[0] *= faceDirection;\n\t\ttbn[1] *= faceDirection;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\t#ifdef USE_TANGENT\n\t\tmat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\t#else\n\t\tmat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );\n\t#endif\n\t#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n\t\ttbn2[0] *= faceDirection;\n\t\ttbn2[1] *= faceDirection;\n\t#endif\n#endif\nvec3 nonPerturbedNormal = normal;",normal_fragment_maps:"#ifdef USE_NORMALMAP_OBJECTSPACE\n\tnormal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n\t#ifdef FLIP_SIDED\n\t\tnormal = - normal;\n\t#endif\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * faceDirection;\n\t#endif\n\tnormal = normalize( normalMatrix * normal );\n#elif defined( USE_NORMALMAP_TANGENTSPACE )\n\tvec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n\tmapN.xy *= normalScale;\n\tnormal = normalize( tbn * mapN );\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );\n#endif",normal_pars_fragment:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_pars_vertex:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_vertex:"#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif",normalmap_pars_fragment:"#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n#endif\n#ifdef USE_NORMALMAP_OBJECTSPACE\n\tuniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )\n\tmat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {\n\t\tvec3 q0 = dFdx( eye_pos.xyz );\n\t\tvec3 q1 = dFdy( eye_pos.xyz );\n\t\tvec2 st0 = dFdx( uv.st );\n\t\tvec2 st1 = dFdy( uv.st );\n\t\tvec3 N = surf_norm;\n\t\tvec3 q1perp = cross( q1, N );\n\t\tvec3 q0perp = cross( N, q0 );\n\t\tvec3 T = q1perp * st0.x + q0perp * st1.x;\n\t\tvec3 B = q1perp * st0.y + q0perp * st1.y;\n\t\tfloat det = max( dot( T, T ), dot( B, B ) );\n\t\tfloat scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );\n\t\treturn mat3( T * scale, B * scale, N );\n\t}\n#endif",clearcoat_normal_fragment_begin:"#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal = nonPerturbedNormal;\n#endif",clearcoat_normal_fragment_maps:"#ifdef USE_CLEARCOAT_NORMALMAP\n\tvec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;\n\tclearcoatMapN.xy *= clearcoatNormalScale;\n\tclearcoatNormal = normalize( tbn2 * clearcoatMapN );\n#endif",clearcoat_pars_fragment:"#ifdef USE_CLEARCOATMAP\n\tuniform sampler2D clearcoatMap;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform sampler2D clearcoatNormalMap;\n\tuniform vec2 clearcoatNormalScale;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform sampler2D clearcoatRoughnessMap;\n#endif",iridescence_pars_fragment:"#ifdef USE_IRIDESCENCEMAP\n\tuniform sampler2D iridescenceMap;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tuniform sampler2D iridescenceThicknessMap;\n#endif",opaque_fragment:"#ifdef OPAQUE\ndiffuseColor.a = 1.0;\n#endif\n#ifdef USE_TRANSMISSION\ndiffuseColor.a *= material.transmissionAlpha;\n#endif\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );",packing:"vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.;\nconst float Inv255 = 1. / 255.;\nconst vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 );\nconst vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g );\nconst vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b );\nconst vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a );\nvec4 packDepthToRGBA( const in float v ) {\n\tif( v <= 0.0 )\n\t\treturn vec4( 0., 0., 0., 0. );\n\tif( v >= 1.0 )\n\t\treturn vec4( 1., 1., 1., 1. );\n\tfloat vuf;\n\tfloat af = modf( v * PackFactors.a, vuf );\n\tfloat bf = modf( vuf * ShiftRight8, vuf );\n\tfloat gf = modf( vuf * ShiftRight8, vuf );\n\treturn vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af );\n}\nvec3 packDepthToRGB( const in float v ) {\n\tif( v <= 0.0 )\n\t\treturn vec3( 0., 0., 0. );\n\tif( v >= 1.0 )\n\t\treturn vec3( 1., 1., 1. );\n\tfloat vuf;\n\tfloat bf = modf( v * PackFactors.b, vuf );\n\tfloat gf = modf( vuf * ShiftRight8, vuf );\n\treturn vec3( vuf * Inv255, gf * PackUpscale, bf );\n}\nvec2 packDepthToRG( const in float v ) {\n\tif( v <= 0.0 )\n\t\treturn vec2( 0., 0. );\n\tif( v >= 1.0 )\n\t\treturn vec2( 1., 1. );\n\tfloat vuf;\n\tfloat gf = modf( v * 256., vuf );\n\treturn vec2( vuf * Inv255, gf );\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors4 );\n}\nfloat unpackRGBToDepth( const in vec3 v ) {\n\treturn dot( v, UnpackFactors3 );\n}\nfloat unpackRGToDepth( const in vec2 v ) {\n\treturn v.r * UnpackFactors2.r + v.g * UnpackFactors2.g;\n}\nvec4 pack2HalfToRGBA( const in vec2 v ) {\n\tvec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );\n\treturn vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );\n}\nvec2 unpackRGBATo2Half( const in vec4 v ) {\n\treturn vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {\n\treturn depth * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * depth - far );\n}",premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif",project_vertex:"vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_BATCHING\n\tmvPosition = batchingMatrix * mvPosition;\n#endif\n#ifdef USE_INSTANCING\n\tmvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;",dithering_fragment:"#ifdef DITHERING\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif",dithering_pars_fragment:"#ifdef DITHERING\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif",roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );\n\troughnessFactor *= texelRoughness.g;\n#endif",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"#if NUM_SPOT_LIGHT_COORDS > 0\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#if NUM_SPOT_LIGHT_MAPS > 0\n\tuniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tvec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n\t\treturn unpackRGBATo2Half( texture2D( shadow, uv ) );\n\t}\n\tfloat VSMShadow (sampler2D shadow, vec2 uv, float compare ){\n\t\tfloat occlusion = 1.0;\n\t\tvec2 distribution = texture2DDistribution( shadow, uv );\n\t\tfloat hard_shadow = step( compare , distribution.x );\n\t\tif (hard_shadow != 1.0 ) {\n\t\t\tfloat distance = compare - distribution.x ;\n\t\t\tfloat variance = max( 0.00000, distribution.y * distribution.y );\n\t\t\tfloat softness_probability = variance / (variance + distance * distance );\t\t\tsoftness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );\t\t\tocclusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n\t\t}\n\t\treturn occlusion;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n\t\tbool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tfloat dx2 = dx0 / 2.0;\n\t\t\tfloat dy2 = dy0 / 2.0;\n\t\t\tfloat dx3 = dx1 / 2.0;\n\t\t\tfloat dy3 = dy1 / 2.0;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 17.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx = texelSize.x;\n\t\t\tfloat dy = texelSize.y;\n\t\t\tvec2 uv = shadowCoord.xy;\n\t\t\tvec2 f = fract( uv * shadowMapSize + 0.5 );\n\t\t\tuv -= f * texelSize;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, uv, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t f.y )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_VSM )\n\t\t\tshadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tfloat shadow = 1.0;\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\t\n\t\tfloat lightToPositionLength = length( lightToPosition );\n\t\tif ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) {\n\t\t\tfloat dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\t\tdp += shadowBias;\n\t\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )\n\t\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\t\tshadow = (\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t\t) * ( 1.0 / 9.0 );\n\t\t\t#else\n\t\t\t\tshadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t\t#endif\n\t\t}\n\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t}\n#endif",shadowmap_pars_vertex:"#if NUM_SPOT_LIGHT_COORDS > 0\n\tuniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n#endif",shadowmap_vertex:"#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )\n\tvec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\tvec4 shadowWorldPosition;\n#endif\n#if defined( USE_SHADOWMAP )\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );\n\t\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );\n\t\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if NUM_SPOT_LIGHT_COORDS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition;\n\t\t#if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t\tshadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;\n\t\t#endif\n\t\tvSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n#endif",shadowmask_pars_fragment:"float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tdirectionalLight = directionalLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tspotLight = spotLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tpointLight = pointLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#endif\n\treturn shadow;\n}",skinbase_vertex:"#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\tuniform highp sampler2D boneTexture;\n\tmat4 getBoneMatrix( const in float i ) {\n\t\tint size = textureSize( boneTexture, 0 ).x;\n\t\tint j = int( i ) * 4;\n\t\tint x = j % size;\n\t\tint y = j / size;\n\t\tvec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );\n\t\tvec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );\n\t\tvec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );\n\t\tvec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );\n\t\treturn mat4( v1, v2, v3, v4 );\n\t}\n#endif",skinning_vertex:"#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\ttransformed = ( bindMatrixInverse * skinned ).xyz;\n#endif",skinnormal_vertex:"#ifdef USE_SKINNING\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n\t#ifdef USE_TANGENT\n\t\tobjectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#endif\n#endif",specularmap_fragment:"float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif",specularmap_pars_fragment:"#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif",tonemapping_fragment:"#if defined( TONE_MAPPING )\n\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif",tonemapping_pars_fragment:"#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn saturate( toneMappingExposure * color );\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 RRTAndODTFit( vec3 v ) {\n\tvec3 a = v * ( v + 0.0245786 ) - 0.000090537;\n\tvec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;\n\treturn a / b;\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\tconst mat3 ACESInputMat = mat3(\n\t\tvec3( 0.59719, 0.07600, 0.02840 ),\t\tvec3( 0.35458, 0.90834, 0.13383 ),\n\t\tvec3( 0.04823, 0.01566, 0.83777 )\n\t);\n\tconst mat3 ACESOutputMat = mat3(\n\t\tvec3( 1.60475, -0.10208, -0.00327 ),\t\tvec3( -0.53108, 1.10813, -0.07276 ),\n\t\tvec3( -0.07367, -0.00605, 1.07602 )\n\t);\n\tcolor *= toneMappingExposure / 0.6;\n\tcolor = ACESInputMat * color;\n\tcolor = RRTAndODTFit( color );\n\tcolor = ACESOutputMat * color;\n\treturn saturate( color );\n}\nconst mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(\n\tvec3( 1.6605, - 0.1246, - 0.0182 ),\n\tvec3( - 0.5876, 1.1329, - 0.1006 ),\n\tvec3( - 0.0728, - 0.0083, 1.1187 )\n);\nconst mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(\n\tvec3( 0.6274, 0.0691, 0.0164 ),\n\tvec3( 0.3293, 0.9195, 0.0880 ),\n\tvec3( 0.0433, 0.0113, 0.8956 )\n);\nvec3 agxDefaultContrastApprox( vec3 x ) {\n\tvec3 x2 = x * x;\n\tvec3 x4 = x2 * x2;\n\treturn + 15.5 * x4 * x2\n\t\t- 40.14 * x4 * x\n\t\t+ 31.96 * x4\n\t\t- 6.868 * x2 * x\n\t\t+ 0.4298 * x2\n\t\t+ 0.1191 * x\n\t\t- 0.00232;\n}\nvec3 AgXToneMapping( vec3 color ) {\n\tconst mat3 AgXInsetMatrix = mat3(\n\t\tvec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),\n\t\tvec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),\n\t\tvec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )\n\t);\n\tconst mat3 AgXOutsetMatrix = mat3(\n\t\tvec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),\n\t\tvec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),\n\t\tvec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )\n\t);\n\tconst float AgxMinEv = - 12.47393;\tconst float AgxMaxEv = 4.026069;\n\tcolor *= toneMappingExposure;\n\tcolor = LINEAR_SRGB_TO_LINEAR_REC2020 * color;\n\tcolor = AgXInsetMatrix * color;\n\tcolor = max( color, 1e-10 );\tcolor = log2( color );\n\tcolor = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );\n\tcolor = clamp( color, 0.0, 1.0 );\n\tcolor = agxDefaultContrastApprox( color );\n\tcolor = AgXOutsetMatrix * color;\n\tcolor = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );\n\tcolor = LINEAR_REC2020_TO_LINEAR_SRGB * color;\n\tcolor = clamp( color, 0.0, 1.0 );\n\treturn color;\n}\nvec3 NeutralToneMapping( vec3 color ) {\n\tconst float StartCompression = 0.8 - 0.04;\n\tconst float Desaturation = 0.15;\n\tcolor *= toneMappingExposure;\n\tfloat x = min( color.r, min( color.g, color.b ) );\n\tfloat offset = x < 0.08 ? x - 6.25 * x * x : 0.04;\n\tcolor -= offset;\n\tfloat peak = max( color.r, max( color.g, color.b ) );\n\tif ( peak < StartCompression ) return color;\n\tfloat d = 1. - StartCompression;\n\tfloat newPeak = 1. - d * d / ( peak + d - StartCompression );\n\tcolor *= newPeak / peak;\n\tfloat g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );\n\treturn mix( color, vec3( newPeak ), g );\n}\nvec3 CustomToneMapping( vec3 color ) { return color; }",transmission_fragment:"#ifdef USE_TRANSMISSION\n\tmaterial.transmission = transmission;\n\tmaterial.transmissionAlpha = 1.0;\n\tmaterial.thickness = thickness;\n\tmaterial.attenuationDistance = attenuationDistance;\n\tmaterial.attenuationColor = attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tmaterial.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tmaterial.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;\n\t#endif\n\tvec3 pos = vWorldPosition;\n\tvec3 v = normalize( cameraPosition - pos );\n\tvec3 n = inverseTransformDirection( normal, viewMatrix );\n\tvec4 transmitted = getIBLVolumeRefraction(\n\t\tn, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,\n\t\tpos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,\n\t\tmaterial.attenuationColor, material.attenuationDistance );\n\tmaterial.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );\n\ttotalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );\n#endif",transmission_pars_fragment:"#ifdef USE_TRANSMISSION\n\tuniform float transmission;\n\tuniform float thickness;\n\tuniform float attenuationDistance;\n\tuniform vec3 attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tuniform sampler2D transmissionMap;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tuniform sampler2D thicknessMap;\n\t#endif\n\tuniform vec2 transmissionSamplerSize;\n\tuniform sampler2D transmissionSamplerMap;\n\tuniform mat4 modelMatrix;\n\tuniform mat4 projectionMatrix;\n\tvarying vec3 vWorldPosition;\n\tfloat w0( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );\n\t}\n\tfloat w1( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );\n\t}\n\tfloat w2( float a ){\n\t\treturn ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );\n\t}\n\tfloat w3( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * a * a );\n\t}\n\tfloat g0( float a ) {\n\t\treturn w0( a ) + w1( a );\n\t}\n\tfloat g1( float a ) {\n\t\treturn w2( a ) + w3( a );\n\t}\n\tfloat h0( float a ) {\n\t\treturn - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );\n\t}\n\tfloat h1( float a ) {\n\t\treturn 1.0 + w3( a ) / ( w2( a ) + w3( a ) );\n\t}\n\tvec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {\n\t\tuv = uv * texelSize.zw + 0.5;\n\t\tvec2 iuv = floor( uv );\n\t\tvec2 fuv = fract( uv );\n\t\tfloat g0x = g0( fuv.x );\n\t\tfloat g1x = g1( fuv.x );\n\t\tfloat h0x = h0( fuv.x );\n\t\tfloat h1x = h1( fuv.x );\n\t\tfloat h0y = h0( fuv.y );\n\t\tfloat h1y = h1( fuv.y );\n\t\tvec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n\t\treturn g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +\n\t\t\tg1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );\n\t}\n\tvec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {\n\t\tvec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );\n\t\tvec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );\n\t\tvec2 fLodSizeInv = 1.0 / fLodSize;\n\t\tvec2 cLodSizeInv = 1.0 / cLodSize;\n\t\tvec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );\n\t\tvec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );\n\t\treturn mix( fSample, cSample, fract( lod ) );\n\t}\n\tvec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {\n\t\tvec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );\n\t\tvec3 modelScale;\n\t\tmodelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );\n\t\tmodelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );\n\t\tmodelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );\n\t\treturn normalize( refractionVector ) * thickness * modelScale;\n\t}\n\tfloat applyIorToRoughness( const in float roughness, const in float ior ) {\n\t\treturn roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );\n\t}\n\tvec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {\n\t\tfloat lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );\n\t\treturn textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );\n\t}\n\tvec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tif ( isinf( attenuationDistance ) ) {\n\t\t\treturn vec3( 1.0 );\n\t\t} else {\n\t\t\tvec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;\n\t\t\tvec3 transmittance = exp( - attenuationCoefficient * transmissionDistance );\t\t\treturn transmittance;\n\t\t}\n\t}\n\tvec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,\n\t\tconst in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,\n\t\tconst in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness,\n\t\tconst in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tvec4 transmittedLight;\n\t\tvec3 transmittance;\n\t\t#ifdef USE_DISPERSION\n\t\t\tfloat halfSpread = ( ior - 1.0 ) * 0.025 * dispersion;\n\t\t\tvec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread );\n\t\t\tfor ( int i = 0; i < 3; i ++ ) {\n\t\t\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix );\n\t\t\t\tvec3 refractedRayExit = position + transmissionRay;\n\t\t\n\t\t\t\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n\t\t\t\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\n\t\t\t\trefractionCoords += 1.0;\n\t\t\t\trefractionCoords /= 2.0;\n\t\t\n\t\t\t\tvec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] );\n\t\t\t\ttransmittedLight[ i ] = transmissionSample[ i ];\n\t\t\t\ttransmittedLight.a += transmissionSample.a;\n\t\t\t\ttransmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ];\n\t\t\t}\n\t\t\ttransmittedLight.a /= 3.0;\n\t\t\n\t\t#else\n\t\t\n\t\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );\n\t\t\tvec3 refractedRayExit = position + transmissionRay;\n\t\t\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n\t\t\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\n\t\t\trefractionCoords += 1.0;\n\t\t\trefractionCoords /= 2.0;\n\t\t\ttransmittedLight = getTransmissionSample( refractionCoords, roughness, ior );\n\t\t\ttransmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );\n\t\t\n\t\t#endif\n\t\tvec3 attenuatedColor = transmittance * transmittedLight.rgb;\n\t\tvec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );\n\t\tfloat transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;\n\t\treturn vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );\n\t}\n#endif",uv_pars_fragment:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvarying vec2 vUv;\n#endif\n#ifdef USE_MAP\n\tvarying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n\tvarying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n\tvarying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n\tvarying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n\tvarying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n\tvarying vec2 vNormalMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tvarying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n\tvarying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tvarying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tvarying vec2 vAnisotropyMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tvarying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tvarying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tvarying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tvarying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tvarying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tvarying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tvarying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n\tvarying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tvarying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tvarying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tuniform mat3 transmissionMapTransform;\n\tvarying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n\tuniform mat3 thicknessMapTransform;\n\tvarying vec2 vThicknessMapUv;\n#endif",uv_pars_vertex:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvarying vec2 vUv;\n#endif\n#ifdef USE_MAP\n\tuniform mat3 mapTransform;\n\tvarying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform mat3 alphaMapTransform;\n\tvarying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n\tuniform mat3 lightMapTransform;\n\tvarying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n\tuniform mat3 aoMapTransform;\n\tvarying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n\tuniform mat3 bumpMapTransform;\n\tvarying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n\tuniform mat3 normalMapTransform;\n\tvarying vec2 vNormalMapUv;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n\tuniform mat3 displacementMapTransform;\n\tvarying vec2 vDisplacementMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tuniform mat3 emissiveMapTransform;\n\tvarying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n\tuniform mat3 metalnessMapTransform;\n\tvarying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tuniform mat3 roughnessMapTransform;\n\tvarying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tuniform mat3 anisotropyMapTransform;\n\tvarying vec2 vAnisotropyMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tuniform mat3 clearcoatMapTransform;\n\tvarying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform mat3 clearcoatNormalMapTransform;\n\tvarying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform mat3 clearcoatRoughnessMapTransform;\n\tvarying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tuniform mat3 sheenColorMapTransform;\n\tvarying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tuniform mat3 sheenRoughnessMapTransform;\n\tvarying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tuniform mat3 iridescenceMapTransform;\n\tvarying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tuniform mat3 iridescenceThicknessMapTransform;\n\tvarying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n\tuniform mat3 specularMapTransform;\n\tvarying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tuniform mat3 specularColorMapTransform;\n\tvarying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tuniform mat3 specularIntensityMapTransform;\n\tvarying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tuniform mat3 transmissionMapTransform;\n\tvarying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n\tuniform mat3 thicknessMapTransform;\n\tvarying vec2 vThicknessMapUv;\n#endif",uv_vertex:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvUv = vec3( uv, 1 ).xy;\n#endif\n#ifdef USE_MAP\n\tvMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ALPHAMAP\n\tvAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_LIGHTMAP\n\tvLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_AOMAP\n\tvAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_BUMPMAP\n\tvBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_NORMALMAP\n\tvNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n\tvDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tvEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_METALNESSMAP\n\tvMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tvRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tvAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tvClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tvClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tvClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tvIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tvIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tvSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tvSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULARMAP\n\tvSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tvSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tvSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tvTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_THICKNESSMAP\n\tvThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;\n#endif",worldpos_vertex:"#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0\n\tvec4 worldPosition = vec4( transformed, 1.0 );\n\t#ifdef USE_BATCHING\n\t\tworldPosition = batchingMatrix * worldPosition;\n\t#endif\n\t#ifdef USE_INSTANCING\n\t\tworldPosition = instanceMatrix * worldPosition;\n\t#endif\n\tworldPosition = modelMatrix * worldPosition;\n#endif",background_vert:"varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\tgl_Position = vec4( position.xy, 1.0, 1.0 );\n}",background_frag:"uniform sampler2D t2D;\nuniform float backgroundIntensity;\nvarying vec2 vUv;\nvoid main() {\n\tvec4 texColor = texture2D( t2D, vUv );\n\t#ifdef DECODE_VIDEO_TEXTURE\n\t\ttexColor = 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 );\n\t#endif\n\ttexColor.rgb *= backgroundIntensity;\n\tgl_FragColor = texColor;\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}",backgroundCube_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\tgl_Position.z = gl_Position.w;\n}",backgroundCube_frag:"#ifdef ENVMAP_TYPE_CUBE\n\tuniform samplerCube envMap;\n#elif defined( ENVMAP_TYPE_CUBE_UV )\n\tuniform sampler2D envMap;\n#endif\nuniform float flipEnvMap;\nuniform float backgroundBlurriness;\nuniform float backgroundIntensity;\nuniform mat3 backgroundRotation;\nvarying vec3 vWorldDirection;\n#include <cube_uv_reflection_fragment>\nvoid main() {\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );\n\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\tvec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );\n\t#else\n\t\tvec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t#endif\n\ttexColor.rgb *= backgroundIntensity;\n\tgl_FragColor = texColor;\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}",cube_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\tgl_Position.z = gl_Position.w;\n}",cube_frag:"uniform samplerCube tCube;\nuniform float tFlip;\nuniform float opacity;\nvarying vec3 vWorldDirection;\nvoid main() {\n\tvec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );\n\tgl_FragColor = texColor;\n\tgl_FragColor.a *= opacity;\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}",depth_vert:"#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include <uv_vertex>\n\t#include <batching_vertex>\n\t#include <skinbase_vertex>\n\t#include <morphinstance_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvHighPrecisionZW = gl_Position.zw;\n}",depth_frag:"#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include <clipping_planes_fragment>\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <logdepthbuf_fragment>\n\tfloat fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;\n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( fragCoordZ );\n\t#elif DEPTH_PACKING == 3202\n\t\tgl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 );\n\t#elif DEPTH_PACKING == 3203\n\t\tgl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );\n\t#endif\n}",distanceRGBA_vert:"#define DISTANCE\nvarying vec3 vWorldPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <batching_vertex>\n\t#include <skinbase_vertex>\n\t#include <morphinstance_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <worldpos_vertex>\n\t#include <clipping_planes_vertex>\n\tvWorldPosition = worldPosition.xyz;\n}",distanceRGBA_frag:"#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main () {\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include <clipping_planes_fragment>\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = packDepthToRGBA( dist );\n}",equirect_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n}",equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvec3 direction = normalize( vWorldDirection );\n\tvec2 sampleUV = equirectUv( direction );\n\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}",linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include <common>\n#include <uv_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\tvLineDistance = scale * lineDistance;\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}",linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include <common>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}",meshbasic_vert:"#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinbase_vertex>\n\t\t#include <skinnormal_vertex>\n\t\t#include <defaultnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <fog_vertex>\n}",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <specularmap_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\t\treflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include <aomap_fragment>\n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include <envmap_fragment>\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshlambert_vert:"#define LAMBERT\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshlambert_frag:"#define LAMBERT\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_lambert_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_lambert_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshmatcap_vert:"#define MATCAP\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <color_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n\tvViewPosition = - mvPosition.xyz;\n}",meshmatcap_frag:"#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <normal_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\tvec3 viewDir = normalize( vViewPosition );\n\tvec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n\tvec3 y = cross( viewDir, x );\n\tvec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;\n\t#ifdef USE_MATCAP\n\t\tvec4 matcapColor = texture2D( matcap, uv );\n\t#else\n\t\tvec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );\n\t#endif\n\tvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshnormal_vert:"#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvarying vec3 vViewPosition;\n#endif\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}",meshnormal_frag:"#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvarying vec3 vViewPosition;\n#endif\n#include <packing>\n#include <uv_pars_fragment>\n#include <normal_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );\n\t#include <clipping_planes_fragment>\n\t#include <logdepthbuf_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\tgl_FragColor = vec4( packNormalToRGB( normal ), diffuseColor.a );\n\t#ifdef OPAQUE\n\t\tgl_FragColor.a = 1.0;\n\t#endif\n}",meshphong_vert:"#define PHONG\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_phong_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_phong_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshphysical_vert:"#define STANDARD\nvarying vec3 vViewPosition;\n#ifdef USE_TRANSMISSION\n\tvarying vec3 vWorldPosition;\n#endif\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n#ifdef USE_TRANSMISSION\n\tvWorldPosition = worldPosition.xyz;\n#endif\n}",meshphysical_frag:"#define STANDARD\n#ifdef PHYSICAL\n\t#define IOR\n\t#define USE_SPECULAR\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef IOR\n\tuniform float ior;\n#endif\n#ifdef USE_SPECULAR\n\tuniform float specularIntensity;\n\tuniform vec3 specularColor;\n\t#ifdef USE_SPECULAR_COLORMAP\n\t\tuniform sampler2D specularColorMap;\n\t#endif\n\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\tuniform sampler2D specularIntensityMap;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n#ifdef USE_DISPERSION\n\tuniform float dispersion;\n#endif\n#ifdef USE_IRIDESCENCE\n\tuniform float iridescence;\n\tuniform float iridescenceIOR;\n\tuniform float iridescenceThicknessMinimum;\n\tuniform float iridescenceThicknessMaximum;\n#endif\n#ifdef USE_SHEEN\n\tuniform vec3 sheenColor;\n\tuniform float sheenRoughness;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tuniform sampler2D sheenColorMap;\n\t#endif\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tuniform sampler2D sheenRoughnessMap;\n\t#endif\n#endif\n#ifdef USE_ANISOTROPY\n\tuniform vec2 anisotropyVector;\n\t#ifdef USE_ANISOTROPYMAP\n\t\tuniform sampler2D anisotropyMap;\n\t#endif\n#endif\nvarying vec3 vViewPosition;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <iridescence_fragment>\n#include <cube_uv_reflection_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_physical_pars_fragment>\n#include <fog_pars_fragment>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_physical_pars_fragment>\n#include <transmission_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <clearcoat_pars_fragment>\n#include <iridescence_pars_fragment>\n#include <roughnessmap_pars_fragment>\n#include <metalnessmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <roughnessmap_fragment>\n\t#include <metalnessmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <clearcoat_normal_fragment_begin>\n\t#include <clearcoat_normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_physical_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\n\tvec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n\t#include <transmission_fragment>\n\tvec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;\n\t#ifdef USE_SHEEN\n\t\tfloat sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );\n\t\toutgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );\n\t\tvec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );\n\t\toutgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;\n\t#endif\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshtoon_vert:"#define TOON\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshtoon_frag:"#define TOON\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <gradientmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_toon_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_toon_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",points_vert:"uniform float size;\nuniform float scale;\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\n#ifdef USE_POINTS_UV\n\tvarying vec2 vUv;\n\tuniform mat3 uvTransform;\n#endif\nvoid main() {\n\t#ifdef USE_POINTS_UV\n\t\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\t#endif\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\tgl_PointSize = size;\n\t#ifdef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n\t#endif\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <fog_vertex>\n}",points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <color_pars_fragment>\n#include <map_particle_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\t#include <logdepthbuf_fragment>\n\t#include <map_particle_fragment>\n\t#include <color_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}",shadow_vert:"#include <common>\n#include <batching_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <shadowmap_pars_vertex>\nvoid main() {\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",shadow_frag:"uniform vec3 color;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <logdepthbuf_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <shadowmask_pars_fragment>\nvoid main() {\n\t#include <logdepthbuf_fragment>\n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n}",sprite_vert:"uniform float rotation;\nuniform vec2 center;\n#include <common>\n#include <uv_pars_vertex>\n#include <fog_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\tvec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\n\tvec2 scale;\n\tscale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );\n\tscale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );\n\t#ifndef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) scale *= - mvPosition.z;\n\t#endif\n\tvec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n\tvec2 rotatedPosition;\n\trotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n\trotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n\tmvPosition.xy += rotatedPosition;\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}",sprite_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n}"},Ma={common:{diffuse:{value:new ts(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new sr},alphaMap:{value:null},alphaMapTransform:{value:new sr},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new sr}},envmap:{envMap:{value:null},envMapRotation:{value:new sr},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new sr}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new sr}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new sr},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new sr},normalScale:{value:new ir(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new sr},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new sr}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new sr}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new sr}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new ts(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new ts(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new sr},alphaTest:{value:0},uvTransform:{value:new sr}},sprite:{diffuse:{value:new ts(16777215)},opacity:{value:1},center:{value:new ir(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new sr},alphaMap:{value:null},alphaMapTransform:{value:new sr},alphaTest:{value:0}}},ba={basic:{uniforms:Zs([Ma.common,Ma.specularmap,Ma.envmap,Ma.aomap,Ma.lightmap,Ma.fog]),vertexShader:Aa.meshbasic_vert,fragmentShader:Aa.meshbasic_frag},lambert:{uniforms:Zs([Ma.common,Ma.specularmap,Ma.envmap,Ma.aomap,Ma.lightmap,Ma.emissivemap,Ma.bumpmap,Ma.normalmap,Ma.displacementmap,Ma.fog,Ma.lights,{emissive:{value:new ts(0)}}]),vertexShader:Aa.meshlambert_vert,fragmentShader:Aa.meshlambert_frag},phong:{uniforms:Zs([Ma.common,Ma.specularmap,Ma.envmap,Ma.aomap,Ma.lightmap,Ma.emissivemap,Ma.bumpmap,Ma.normalmap,Ma.displacementmap,Ma.fog,Ma.lights,{emissive:{value:new ts(0)},specular:{value:new ts(1118481)},shininess:{value:30}}]),vertexShader:Aa.meshphong_vert,fragmentShader:Aa.meshphong_frag},standard:{uniforms:Zs([Ma.common,Ma.envmap,Ma.aomap,Ma.lightmap,Ma.emissivemap,Ma.bumpmap,Ma.normalmap,Ma.displacementmap,Ma.roughnessmap,Ma.metalnessmap,Ma.fog,Ma.lights,{emissive:{value:new ts(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Aa.meshphysical_vert,fragmentShader:Aa.meshphysical_frag},toon:{uniforms:Zs([Ma.common,Ma.aomap,Ma.lightmap,Ma.emissivemap,Ma.bumpmap,Ma.normalmap,Ma.displacementmap,Ma.gradientmap,Ma.fog,Ma.lights,{emissive:{value:new ts(0)}}]),vertexShader:Aa.meshtoon_vert,fragmentShader:Aa.meshtoon_frag},matcap:{uniforms:Zs([Ma.common,Ma.bumpmap,Ma.normalmap,Ma.displacementmap,Ma.fog,{matcap:{value:null}}]),vertexShader:Aa.meshmatcap_vert,fragmentShader:Aa.meshmatcap_frag},points:{uniforms:Zs([Ma.points,Ma.fog]),vertexShader:Aa.points_vert,fragmentShader:Aa.points_frag},dashed:{uniforms:Zs([Ma.common,Ma.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Aa.linedashed_vert,fragmentShader:Aa.linedashed_frag},depth:{uniforms:Zs([Ma.common,Ma.displacementmap]),vertexShader:Aa.depth_vert,fragmentShader:Aa.depth_frag},normal:{uniforms:Zs([Ma.common,Ma.bumpmap,Ma.normalmap,Ma.displacementmap,{opacity:{value:1}}]),vertexShader:Aa.meshnormal_vert,fragmentShader:Aa.meshnormal_frag},sprite:{uniforms:Zs([Ma.sprite,Ma.fog]),vertexShader:Aa.sprite_vert,fragmentShader:Aa.sprite_frag},background:{uniforms:{uvTransform:{value:new sr},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Aa.background_vert,fragmentShader:Aa.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new sr}},vertexShader:Aa.backgroundCube_vert,fragmentShader:Aa.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Aa.cube_vert,fragmentShader:Aa.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Aa.equirect_vert,fragmentShader:Aa.equirect_frag},distanceRGBA:{uniforms:Zs([Ma.common,Ma.displacementmap,{referencePosition:{value:new Nr},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Aa.distanceRGBA_vert,fragmentShader:Aa.distanceRGBA_frag},shadow:{uniforms:Zs([Ma.lights,Ma.fog,{color:{value:new ts(0)},opacity:{value:1}}]),vertexShader:Aa.shadow_vert,fragmentShader:Aa.shadow_frag}};ba.physical={uniforms:Zs([ba.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new sr},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new sr},clearcoatNormalScale:{value:new ir(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new sr},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new sr},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new sr},sheen:{value:0},sheenColor:{value:new ts(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new sr},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new sr},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new sr},transmissionSamplerSize:{value:new ir},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new sr},attenuationDistance:{value:0},attenuationColor:{value:new ts(0)},specularColor:{value:new ts(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new sr},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new sr},anisotropyVector:{value:new ir},anisotropyMap:{value:null},anisotropyMapTransform:{value:new sr}}]),vertexShader:Aa.meshphysical_vert,fragmentShader:Aa.meshphysical_frag};const Sa={r:0,b:0,g:0},wa=new Mi,Ea=new di;function Ta(e,t,n,r,i,s,a){const o=new ts(0);let l,u,c=!0===s?0:1,h=null,d=0,p=null;function f(e){let r=!0===e.isScene?e.background:null;if(r&&r.isTexture){r=(e.backgroundBlurriness>0?n:t).get(r)}return r}function v(t,n){t.getRGB(Sa,$s(e)),r.buffers.color.setClear(Sa.r,Sa.g,Sa.b,n,a)}return{getClearColor:function(){return o},setClearColor:function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;o.set(e),c=t,v(o,c)},getClearAlpha:function(){return c},setClearAlpha:function(e){c=e,v(o,c)},render:function(t){let n=!1;const i=f(t);null===i?v(o,c):i&&i.isColor&&(v(i,1),n=!0);const s=e.xr.getEnvironmentBlendMode();"additive"===s?r.buffers.color.setClear(0,0,0,1,a):"alpha-blend"===s&&r.buffers.color.setClear(0,0,0,0,a),(e.autoClear||n)&&(r.buffers.depth.setTest(!0),r.buffers.depth.setMask(!0),r.buffers.color.setMask(!0),e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil))},addToRenderList:function(t,n){const r=f(n);r&&(r.isCubeTexture||r.mapping===ge)?(void 0===u&&(u=new Ys(new qs(1,1,1),new ta({name:"BackgroundCubeMaterial",uniforms:Qs(ba.backgroundCube.uniforms),vertexShader:ba.backgroundCube.vertexShader,fragmentShader:ba.backgroundCube.fragmentShader,side:g,depthTest:!1,depthWrite:!1,fog:!1})),u.geometry.deleteAttribute("normal"),u.geometry.deleteAttribute("uv"),u.onBeforeRender=function(e,t,n){this.matrixWorld.copyPosition(n.matrixWorld)},Object.defineProperty(u.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(u)),wa.copy(n.backgroundRotation),wa.x*=-1,wa.y*=-1,wa.z*=-1,r.isCubeTexture&&!1===r.isRenderTargetTexture&&(wa.y*=-1,wa.z*=-1),u.material.uniforms.envMap.value=r,u.material.uniforms.flipEnvMap.value=r.isCubeTexture&&!1===r.isRenderTargetTexture?-1:1,u.material.uniforms.backgroundBlurriness.value=n.backgroundBlurriness,u.material.uniforms.backgroundIntensity.value=n.backgroundIntensity,u.material.uniforms.backgroundRotation.value.setFromMatrix4(Ea.makeRotationFromEuler(wa)),u.material.toneMapped=yr.getTransfer(r.colorSpace)!==an,h===r&&d===r.version&&p===e.toneMapping||(u.material.needsUpdate=!0,h=r,d=r.version,p=e.toneMapping),u.layers.enableAll(),t.unshift(u,u.geometry,u.material,0,0,null)):r&&r.isTexture&&(void 0===l&&(l=new Ys(new xa(2,2),new ta({name:"BackgroundMaterial",uniforms:Qs(ba.background.uniforms),vertexShader:ba.background.vertexShader,fragmentShader:ba.background.fragmentShader,side:m,depthTest:!1,depthWrite:!1,fog:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(l)),l.material.uniforms.t2D.value=r,l.material.uniforms.backgroundIntensity.value=n.backgroundIntensity,l.material.toneMapped=yr.getTransfer(r.colorSpace)!==an,!0===r.matrixAutoUpdate&&r.updateMatrix(),l.material.uniforms.uvTransform.value.copy(r.matrix),h===r&&d===r.version&&p===e.toneMapping||(l.material.needsUpdate=!0,h=r,d=r.version,p=e.toneMapping),l.layers.enableAll(),t.unshift(l,l.geometry,l.material,0,0,null))}}}function Ca(e,t){const n=e.getParameter(e.MAX_VERTEX_ATTRIBS),r={},i=u(null);let s=i,a=!1;function o(t){return e.bindVertexArray(t)}function l(t){return e.deleteVertexArray(t)}function u(e){const t=[],r=[],i=[];for(let s=0;s<n;s++)t[s]=0,r[s]=0,i[s]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:t,enabledAttributes:r,attributeDivisors:i,object:e,attributes:{},index:null}}function c(){const e=s.newAttributes;for(let t=0,n=e.length;t<n;t++)e[t]=0}function h(e){d(e,0)}function d(t,n){const r=s.newAttributes,i=s.enabledAttributes,a=s.attributeDivisors;r[t]=1,0===i[t]&&(e.enableVertexAttribArray(t),i[t]=1),a[t]!==n&&(e.vertexAttribDivisor(t,n),a[t]=n)}function p(){const t=s.newAttributes,n=s.enabledAttributes;for(let r=0,i=n.length;r<i;r++)n[r]!==t[r]&&(e.disableVertexAttribArray(r),n[r]=0)}function f(t,n,r,i,s,a,o){!0===o?e.vertexAttribIPointer(t,n,r,s,a):e.vertexAttribPointer(t,n,r,i,s,a)}function m(){g(),a=!0,s!==i&&(s=i,o(s.object))}function g(){i.geometry=null,i.program=null,i.wireframe=!1}return{setup:function(n,i,l,m,g){let v=!1;const y=function(t,n,i){const s=!0===i.wireframe;let a=r[t.id];void 0===a&&(a={},r[t.id]=a);let o=a[n.id];void 0===o&&(o={},a[n.id]=o);let l=o[s];void 0===l&&(l=u(e.createVertexArray()),o[s]=l);return l}(m,l,i);s!==y&&(s=y,o(s.object)),v=function(e,t,n,r){const i=s.attributes,a=t.attributes;let o=0;const l=n.getAttributes();for(const s in l){if(l[s].location>=0){const t=i[s];let n=a[s];if(void 0===n&&("instanceMatrix"===s&&e.instanceMatrix&&(n=e.instanceMatrix),"instanceColor"===s&&e.instanceColor&&(n=e.instanceColor)),void 0===t)return!0;if(t.attribute!==n)return!0;if(n&&t.data!==n.data)return!0;o++}}return s.attributesNum!==o||s.index!==r}(n,m,l,g),v&&function(e,t,n,r){const i={},a=t.attributes;let o=0;const l=n.getAttributes();for(const s in l){if(l[s].location>=0){let t=a[s];void 0===t&&("instanceMatrix"===s&&e.instanceMatrix&&(t=e.instanceMatrix),"instanceColor"===s&&e.instanceColor&&(t=e.instanceColor));const n={};n.attribute=t,t&&t.data&&(n.data=t.data),i[s]=n,o++}}s.attributes=i,s.attributesNum=o,s.index=r}(n,m,l,g),null!==g&&t.update(g,e.ELEMENT_ARRAY_BUFFER),(v||a)&&(a=!1,function(n,r,i,s){c();const a=s.attributes,o=i.getAttributes(),l=r.defaultAttributeValues;for(const u in o){const r=o[u];if(r.location>=0){let i=a[u];if(void 0===i&&("instanceMatrix"===u&&n.instanceMatrix&&(i=n.instanceMatrix),"instanceColor"===u&&n.instanceColor&&(i=n.instanceColor)),void 0!==i){const a=i.normalized,o=i.itemSize,l=t.get(i);if(void 0===l)continue;const u=l.buffer,c=l.type,p=l.bytesPerElement,m=c===e.INT||c===e.UNSIGNED_INT||i.gpuType===De;if(i.isInterleavedBufferAttribute){const t=i.data,l=t.stride,g=i.offset;if(t.isInstancedInterleavedBuffer){for(let e=0;e<r.locationSize;e++)d(r.location+e,t.meshPerAttribute);!0!==n.isInstancedMesh&&void 0===s._maxInstanceCount&&(s._maxInstanceCount=t.meshPerAttribute*t.count)}else for(let e=0;e<r.locationSize;e++)h(r.location+e);e.bindBuffer(e.ARRAY_BUFFER,u);for(let e=0;e<r.locationSize;e++)f(r.location+e,o/r.locationSize,c,a,l*p,(g+o/r.locationSize*e)*p,m)}else{if(i.isInstancedBufferAttribute){for(let e=0;e<r.locationSize;e++)d(r.location+e,i.meshPerAttribute);!0!==n.isInstancedMesh&&void 0===s._maxInstanceCount&&(s._maxInstanceCount=i.meshPerAttribute*i.count)}else for(let e=0;e<r.locationSize;e++)h(r.location+e);e.bindBuffer(e.ARRAY_BUFFER,u);for(let e=0;e<r.locationSize;e++)f(r.location+e,o/r.locationSize,c,a,o*p,o/r.locationSize*e*p,m)}}else if(void 0!==l){const t=l[u];if(void 0!==t)switch(t.length){case 2:e.vertexAttrib2fv(r.location,t);break;case 3:e.vertexAttrib3fv(r.location,t);break;case 4:e.vertexAttrib4fv(r.location,t);break;default:e.vertexAttrib1fv(r.location,t)}}}}p()}(n,i,l,m),null!==g&&e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,t.get(g).buffer))},reset:m,resetDefaultState:g,dispose:function(){m();for(const e in r){const t=r[e];for(const e in t){const n=t[e];for(const e in n)l(n[e].object),delete n[e];delete t[e]}delete r[e]}},releaseStatesOfGeometry:function(e){if(void 0===r[e.id])return;const t=r[e.id];for(const n in t){const e=t[n];for(const t in e)l(e[t].object),delete e[t];delete t[n]}delete r[e.id]},releaseStatesOfProgram:function(e){for(const t in r){const n=r[t];if(void 0===n[e.id])continue;const i=n[e.id];for(const e in i)l(i[e].object),delete i[e];delete n[e.id]}},initAttributes:c,enableAttribute:h,disableUnusedAttributes:p}}function Ra(e,t,n){let r;function i(t,i,s){0!==s&&(e.drawArraysInstanced(r,t,i,s),n.update(i,r,s))}this.setMode=function(e){r=e},this.render=function(t,i){e.drawArrays(r,t,i),n.update(i,r,1)},this.renderInstances=i,this.renderMultiDraw=function(e,i,s){if(0===s)return;t.get("WEBGL_multi_draw").multiDrawArraysWEBGL(r,e,0,i,0,s);let a=0;for(let t=0;t<s;t++)a+=i[t];n.update(a,r,1)},this.renderMultiDrawInstances=function(e,s,a,o){if(0===a)return;const l=t.get("WEBGL_multi_draw");if(null===l)for(let t=0;t<e.length;t++)i(e[t],s[t],o[t]);else{l.multiDrawArraysInstancedWEBGL(r,e,0,s,0,o,0,a);let t=0;for(let e=0;e<a;e++)t+=s[e];for(let e=0;e<o.length;e++)n.update(t,r,o[e])}}}function Pa(e,t,n,r){let i;function s(t){if("highp"===t){if(e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.HIGH_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT).precision>0)return"highp";t="mediump"}return"mediump"===t&&e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.MEDIUM_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let a=void 0!==n.precision?n.precision:"highp";const o=s(a);o!==a&&(console.warn("THREE.WebGLRenderer:",a,"not supported, using",o,"instead."),a=o);const l=!0===n.logarithmicDepthBuffer,u=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),c=e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS);return{isWebGL2:!0,getMaxAnisotropy:function(){if(void 0!==i)return i;if(!0===t.has("EXT_texture_filter_anisotropic")){const n=t.get("EXT_texture_filter_anisotropic");i=e.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else i=0;return i},getMaxPrecision:s,textureFormatReadable:function(t){return t===We||r.convert(t)===e.getParameter(e.IMPLEMENTATION_COLOR_READ_FORMAT)},textureTypeReadable:function(n){const i=n===Fe&&(t.has("EXT_color_buffer_half_float")||t.has("EXT_color_buffer_float"));return!(n!==Pe&&r.convert(n)!==e.getParameter(e.IMPLEMENTATION_COLOR_READ_TYPE)&&n!==Ne&&!i)},precision:a,logarithmicDepthBuffer:l,maxTextures:u,maxVertexTextures:c,maxTextureSize:e.getParameter(e.MAX_TEXTURE_SIZE),maxCubemapSize:e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE),maxAttributes:e.getParameter(e.MAX_VERTEX_ATTRIBS),maxVertexUniforms:e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),maxVaryings:e.getParameter(e.MAX_VARYING_VECTORS),maxFragmentUniforms:e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),vertexTextures:c>0,maxSamples:e.getParameter(e.MAX_SAMPLES)}}function Ia(e){const t=this;let n=null,r=0,i=!1,s=!1;const a=new fa,o=new sr,l={value:null,needsUpdate:!1};function u(e,n,r,i){const s=null!==e?e.length:0;let u=null;if(0!==s){if(u=l.value,!0!==i||null===u){const t=r+4*s,i=n.matrixWorldInverse;o.getNormalMatrix(i),(null===u||u.length<t)&&(u=new Float32Array(t));for(let n=0,l=r;n!==s;++n,l+=4)a.copy(e[n]).applyMatrix4(i,o),a.normal.toArray(u,l),u[l+3]=a.constant}l.value=u,l.needsUpdate=!0}return t.numPlanes=s,t.numIntersection=0,u}this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(e,t){const n=0!==e.length||t||0!==r||i;return i=t,r=e.length,n},this.beginShadows=function(){s=!0,u(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(e,t){n=u(e,t,0)},this.setState=function(a,o,c){const h=a.clippingPlanes,d=a.clipIntersection,p=a.clipShadows,f=e.get(a);if(!i||null===h||0===h.length||s&&!p)s?u(null):function(){l.value!==n&&(l.value=n,l.needsUpdate=r>0);t.numPlanes=r,t.numIntersection=0}();else{const e=s?0:r,t=4*e;let i=f.clippingState||null;l.value=i,i=u(h,o,t,c);for(let r=0;r!==t;++r)i[r]=n[r];f.clippingState=i,this.numIntersection=d?this.numPlanes:0,this.numPlanes+=e}}}function Ba(e){let t=new WeakMap;function n(e,t){return t===fe?e.mapping=de:t===me&&(e.mapping=pe),e}function r(e){const n=e.target;n.removeEventListener("dispose",r);const i=t.get(n);void 0!==i&&(t.delete(n),i.dispose())}return{get:function(i){if(i&&i.isTexture){const s=i.mapping;if(s===fe||s===me){if(t.has(i)){return n(t.get(i).texture,i.mapping)}{const s=i.image;if(s&&s.height>0){const a=new ca(s.height);return a.fromEquirectangularTexture(e,i),t.set(i,a),i.addEventListener("dispose",r),n(a.texture,i.mapping)}return null}}}return i},dispose:function(){t=new WeakMap}}}class La extends na{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:-1,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:-1,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:.1,s=arguments.length>5&&void 0!==arguments[5]?arguments[5]:2e3;super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=r,this.near=i,this.far=s,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=null===e.view?null:Object.assign({},e.view),this}setViewOffset(e,t,n,r,i,s){null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=r,this.view.width=i,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,r=(this.top+this.bottom)/2;let i=n-e,s=n+e,a=r+t,o=r-t;if(null!==this.view&&this.view.enabled){const e=(this.right-this.left)/this.view.fullWidth/this.zoom,t=(this.top-this.bottom)/this.view.fullHeight/this.zoom;i+=e*this.view.offsetX,s=i+e*this.view.width,a-=t*this.view.offsetY,o=a-t*this.view.height}this.projectionMatrix.makeOrthographic(i,s,a,o,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,null!==this.view&&(t.object.view=Object.assign({},this.view)),t}}const Da=[.125,.215,.35,.446,.526,.582],Ua=20,Na=new La,Fa=new ts;let Oa=null,ka=0,Ha=0,za=!1;const Ga=(1+Math.sqrt(5))/2,Va=1/Ga,Wa=[new Nr(-Ga,Va,0),new Nr(Ga,Va,0),new Nr(-Va,0,Ga),new Nr(Va,0,Ga),new Nr(0,Ga,-Va),new Nr(0,Ga,Va),new Nr(-1,1,-1),new Nr(1,1,-1),new Nr(-1,1,1),new Nr(1,1,1)];class ja{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:.1,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:100;Oa=this._renderer.getRenderTarget(),ka=this._renderer.getActiveCubeFace(),Ha=this._renderer.getActiveMipmapLevel(),za=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(256);const i=this._allocateTargets();return i.depthBuffer=!0,this._sceneToCubeUV(e,n,r,i),t>0&&this._blur(i,0,0,t),this._applyPMREM(i),this._cleanup(i),i}fromEquirectangular(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return this._fromTexture(e,t)}fromCubemap(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return this._fromTexture(e,t)}compileCubemapShader(){null===this._cubemapMaterial&&(this._cubemapMaterial=Ka(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){null===this._equirectMaterial&&(this._equirectMaterial=Ya(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),null!==this._cubemapMaterial&&this._cubemapMaterial.dispose(),null!==this._equirectMaterial&&this._equirectMaterial.dispose()}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){null!==this._blurMaterial&&this._blurMaterial.dispose(),null!==this._pingPongRenderTarget&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodPlanes.length;e++)this._lodPlanes[e].dispose()}_cleanup(e){this._renderer.setRenderTarget(Oa,ka,Ha),this._renderer.xr.enabled=za,e.scissorTest=!1,Ja(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===de||e.mapping===pe?this._setSize(0===e.image.length?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),Oa=this._renderer.getRenderTarget(),ka=this._renderer.getActiveCubeFace(),Ha=this._renderer.getActiveMipmapLevel(),za=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const n=t||this._allocateTargets();return this._textureToCubeUV(e,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){const e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,n={magFilter:we,minFilter:we,generateMipmaps:!1,type:Fe,format:We,colorSpace:tn,depthBuffer:!1},r=Xa(e,t,n);if(null===this._pingPongRenderTarget||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){null!==this._pingPongRenderTarget&&this._dispose(),this._pingPongRenderTarget=Xa(e,t,n);const{_lodMax:r}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=function(e){const t=[],n=[],r=[];let i=e;const s=e-4+1+Da.length;for(let a=0;a<s;a++){const s=Math.pow(2,i);n.push(s);let o=1/s;a>e-4?o=Da[a-e+4-1]:0===a&&(o=0),r.push(o);const l=1/(s-2),u=-l,c=1+l,h=[u,u,c,u,c,c,u,u,c,c,u,c],d=6,p=6,f=3,m=2,g=1,v=new Float32Array(f*p*d),y=new Float32Array(m*p*d),_=new Float32Array(g*p*d);for(let e=0;e<d;e++){const 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];v.set(r,f*p*e),y.set(h,m*p*e);const i=[e,e,e,e,e,e];_.set(i,g*p*e)}const x=new Ps;x.setAttribute("position",new ps(v,f)),x.setAttribute("uv",new ps(y,m)),x.setAttribute("faceIndex",new ps(_,g)),t.push(x),i>4&&i--}return{lodPlanes:t,sizeLods:n,sigmas:r}}(r)),this._blurMaterial=function(e,t,n){const r=new Float32Array(Ua),i=new Nr(0,1,0),s=new ta({name:"SphericalGaussianBlur",defines:{n:Ua,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:qa(),fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\t\t\tuniform int samples;\n\t\t\tuniform float weights[ n ];\n\t\t\tuniform bool latitudinal;\n\t\t\tuniform float dTheta;\n\t\t\tuniform float mipInt;\n\t\t\tuniform vec3 poleAxis;\n\n\t\t\t#define ENVMAP_TYPE_CUBE_UV\n\t\t\t#include <cube_uv_reflection_fragment>\n\n\t\t\tvec3 getSample( float theta, vec3 axis ) {\n\n\t\t\t\tfloat cosTheta = cos( theta );\n\t\t\t\t// Rodrigues' axis-angle rotation\n\t\t\t\tvec3 sampleDirection = vOutputDirection * cosTheta\n\t\t\t\t\t+ cross( axis, vOutputDirection ) * sin( theta )\n\t\t\t\t\t+ axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );\n\n\t\t\t\treturn bilinearCubeUV( envMap, sampleDirection, mipInt );\n\n\t\t\t}\n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );\n\n\t\t\t\tif ( all( equal( axis, vec3( 0.0 ) ) ) ) {\n\n\t\t\t\t\taxis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );\n\n\t\t\t\t}\n\n\t\t\t\taxis = normalize( axis );\n\n\t\t\t\tgl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t\t\t\tgl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );\n\n\t\t\t\tfor ( int i = 1; i < n; i++ ) {\n\n\t\t\t\t\tif ( i >= samples ) {\n\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t}\n\n\t\t\t\t\tfloat theta = dTheta * float( i );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( theta, axis );\n\n\t\t\t\t}\n\n\t\t\t}\n\t\t",blending:y,depthTest:!1,depthWrite:!1});return s}(r,e,t)}return r}_compileMaterial(e){const t=new Ys(this._lodPlanes[0],e);this._renderer.compile(t,Na)}_sceneToCubeUV(e,t,n,r){const i=new aa(90,1,t,n),s=[1,-1,1,1,1,1],a=[1,1,1,-1,-1,-1],o=this._renderer,l=o.autoClear,u=o.toneMapping;o.getClearColor(Fa),o.toneMapping=te,o.autoClear=!1;const c=new ss({name:"PMREM.Background",side:g,depthWrite:!1,depthTest:!1}),h=new Ys(new qs,c);let d=!1;const p=e.background;p?p.isColor&&(c.color.copy(p),e.background=null,d=!0):(c.color.copy(Fa),d=!0);for(let f=0;f<6;f++){const t=f%3;0===t?(i.up.set(0,s[f],0),i.lookAt(a[f],0,0)):1===t?(i.up.set(0,0,s[f]),i.lookAt(0,a[f],0)):(i.up.set(0,s[f],0),i.lookAt(0,0,a[f]));const n=this._cubeSize;Ja(r,t*n,f>2?n:0,n,n),o.setRenderTarget(r),d&&o.render(h,i),o.render(e,i)}h.geometry.dispose(),h.material.dispose(),o.toneMapping=u,o.autoClear=l,e.background=p}_textureToCubeUV(e,t){const n=this._renderer,r=e.mapping===de||e.mapping===pe;r?(null===this._cubemapMaterial&&(this._cubemapMaterial=Ka()),this._cubemapMaterial.uniforms.flipEnvMap.value=!1===e.isRenderTargetTexture?-1:1):null===this._equirectMaterial&&(this._equirectMaterial=Ya());const i=r?this._cubemapMaterial:this._equirectMaterial,s=new Ys(this._lodPlanes[0],i);i.uniforms.envMap.value=e;const a=this._cubeSize;Ja(t,0,0,3*a,2*a),n.setRenderTarget(t),n.render(s,Na)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;const r=this._lodPlanes.length;for(let i=1;i<r;i++){const t=Math.sqrt(this._sigmas[i]*this._sigmas[i]-this._sigmas[i-1]*this._sigmas[i-1]),n=Wa[(r-i-1)%Wa.length];this._blur(e,i-1,i,t,n)}t.autoClear=n}_blur(e,t,n,r,i){const s=this._pingPongRenderTarget;this._halfBlur(e,s,t,n,r,"latitudinal",i),this._halfBlur(s,e,n,n,r,"longitudinal",i)}_halfBlur(e,t,n,r,i,s,a){const o=this._renderer,l=this._blurMaterial;"latitudinal"!==s&&"longitudinal"!==s&&console.error("blur direction must be either latitudinal or longitudinal!");const u=new Ys(this._lodPlanes[r],l),c=l.uniforms,h=this._sizeLods[n]-1,d=isFinite(i)?Math.PI/(2*h):2*Math.PI/39,p=i/d,f=isFinite(i)?1+Math.floor(3*p):Ua;f>Ua&&console.warn(`sigmaRadians, ${i}, is too large and will clip, as it requested ${f} samples when the maximum is set to 20`);const m=[];let g=0;for(let _=0;_<Ua;++_){const e=_/p,t=Math.exp(-e*e/2);m.push(t),0===_?g+=t:_<f&&(g+=2*t)}for(let _=0;_<m.length;_++)m[_]=m[_]/g;c.envMap.value=e.texture,c.samples.value=f,c.weights.value=m,c.latitudinal.value="latitudinal"===s,a&&(c.poleAxis.value=a);const{_lodMax:v}=this;c.dTheta.value=d,c.mipInt.value=v-n;const y=this._sizeLods[r];Ja(t,3*y*(r>v-4?r-v+4:0),4*(this._cubeSize-y),3*y,2*y),o.setRenderTarget(t),o.render(u,Na)}}function Xa(e,t,n){const r=new Pr(e,t,n);return r.texture.mapping=ge,r.texture.name="PMREM.cubeUv",r.scissorTest=!0,r}function Ja(e,t,n,r,i){e.viewport.set(t,n,r,i),e.scissor.set(t,n,r,i)}function Ya(){return new ta({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:qa(),fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\n\t\t\t#include <common>\n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 outputDirection = normalize( vOutputDirection );\n\t\t\t\tvec2 uv = equirectUv( outputDirection );\n\n\t\t\t\tgl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );\n\n\t\t\t}\n\t\t",blending:y,depthTest:!1,depthWrite:!1})}function Ka(){return new ta({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:qa(),fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tuniform float flipEnvMap;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform samplerCube envMap;\n\n\t\t\tvoid main() {\n\n\t\t\t\tgl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );\n\n\t\t\t}\n\t\t",blending:y,depthTest:!1,depthWrite:!1})}function qa(){return"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t"}function Qa(e){let t=new WeakMap,n=null;function r(e){const n=e.target;n.removeEventListener("dispose",r);const i=t.get(n);void 0!==i&&(t.delete(n),i.dispose())}return{get:function(i){if(i&&i.isTexture){const s=i.mapping,a=s===fe||s===me,o=s===de||s===pe;if(a||o){let s=t.get(i);const l=void 0!==s?s.texture.pmremVersion:0;if(i.isRenderTargetTexture&&i.pmremVersion!==l)return null===n&&(n=new ja(e)),s=a?n.fromEquirectangular(i,s):n.fromCubemap(i,s),s.texture.pmremVersion=i.pmremVersion,t.set(i,s),s.texture;if(void 0!==s)return s.texture;{const l=i.image;return a&&l&&l.height>0||o&&l&&function(e){let t=0;const n=6;for(let r=0;r<n;r++)void 0!==e[r]&&t++;return t===n}(l)?(null===n&&(n=new ja(e)),s=a?n.fromEquirectangular(i):n.fromCubemap(i),s.texture.pmremVersion=i.pmremVersion,t.set(i,s),i.addEventListener("dispose",r),s.texture):null}}}return i},dispose:function(){t=new WeakMap,null!==n&&(n.dispose(),n=null)}}}function Za(e){const t={};function n(n){if(void 0!==t[n])return t[n];let r;switch(n){case"WEBGL_depth_texture":r=e.getExtension("WEBGL_depth_texture")||e.getExtension("MOZ_WEBGL_depth_texture")||e.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":r=e.getExtension("EXT_texture_filter_anisotropic")||e.getExtension("MOZ_EXT_texture_filter_anisotropic")||e.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":r=e.getExtension("WEBGL_compressed_texture_s3tc")||e.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":r=e.getExtension("WEBGL_compressed_texture_pvrtc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:r=e.getExtension(n)}return t[n]=r,r}return{has:function(e){return null!==n(e)},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){const t=n(e);return null===t&&pr("THREE.WebGLRenderer: "+e+" extension not supported."),t}}}function $a(e,t,n,r){const i={},s=new WeakMap;function a(e){const o=e.target;null!==o.index&&t.remove(o.index);for(const n in o.attributes)t.remove(o.attributes[n]);for(const n in o.morphAttributes){const e=o.morphAttributes[n];for(let n=0,r=e.length;n<r;n++)t.remove(e[n])}o.removeEventListener("dispose",a),delete i[o.id];const l=s.get(o);l&&(t.remove(l),s.delete(o)),r.releaseStatesOfGeometry(o),!0===o.isInstancedBufferGeometry&&delete o._maxInstanceCount,n.memory.geometries--}function o(e){const n=[],r=e.index,i=e.attributes.position;let a=0;if(null!==r){const e=r.array;a=r.version;for(let t=0,r=e.length;t<r;t+=3){const r=e[t+0],i=e[t+1],s=e[t+2];n.push(r,i,i,s,s,r)}}else{if(void 0===i)return;{const e=i.array;a=i.version;for(let t=0,r=e.length/3-1;t<r;t+=3){const e=t+0,r=t+1,i=t+2;n.push(e,r,r,i,i,e)}}}const o=new(or(n)?xs:ys)(n,1);o.version=a;const l=s.get(e);l&&t.remove(l),s.set(e,o)}return{get:function(e,t){return!0===i[t.id]||(t.addEventListener("dispose",a),i[t.id]=!0,n.memory.geometries++),t},update:function(n){const r=n.attributes;for(const s in r)t.update(r[s],e.ARRAY_BUFFER);const i=n.morphAttributes;for(const s in i){const n=i[s];for(let r=0,i=n.length;r<i;r++)t.update(n[r],e.ARRAY_BUFFER)}},getWireframeAttribute:function(e){const t=s.get(e);if(t){const n=e.index;null!==n&&t.version<n.version&&o(e)}else o(e);return s.get(e)}}}function eo(e,t,n){let r,i,s;function a(t,a,o){0!==o&&(e.drawElementsInstanced(r,a,i,t*s,o),n.update(a,r,o))}this.setMode=function(e){r=e},this.setIndex=function(e){i=e.type,s=e.bytesPerElement},this.render=function(t,a){e.drawElements(r,a,i,t*s),n.update(a,r,1)},this.renderInstances=a,this.renderMultiDraw=function(e,s,a){if(0===a)return;t.get("WEBGL_multi_draw").multiDrawElementsWEBGL(r,s,0,i,e,0,a);let o=0;for(let t=0;t<a;t++)o+=s[t];n.update(o,r,1)},this.renderMultiDrawInstances=function(e,o,l,u){if(0===l)return;const c=t.get("WEBGL_multi_draw");if(null===c)for(let t=0;t<e.length;t++)a(e[t]/s,o[t],u[t]);else{c.multiDrawElementsInstancedWEBGL(r,o,0,i,e,0,u,0,l);let t=0;for(let e=0;e<l;e++)t+=o[e];for(let e=0;e<u.length;e++)n.update(t,r,u[e])}}}function to(e){const t={frame:0,calls:0,triangles:0,points:0,lines:0};return{memory:{geometries:0,textures:0},render:t,programs:null,autoReset:!0,reset:function(){t.calls=0,t.triangles=0,t.points=0,t.lines=0},update:function(n,r,i){switch(t.calls++,r){case e.TRIANGLES:t.triangles+=i*(n/3);break;case e.LINES:t.lines+=i*(n/2);break;case e.LINE_STRIP:t.lines+=i*(n-1);break;case e.LINE_LOOP:t.lines+=i*n;break;case e.POINTS:t.points+=i*n;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",r)}}}}function no(e,t,n){const r=new WeakMap,i=new Cr;return{update:function(s,a,o){const l=s.morphTargetInfluences,u=a.morphAttributes.position||a.morphAttributes.normal||a.morphAttributes.color,c=void 0!==u?u.length:0;let h=r.get(a);if(void 0===h||h.count!==c){void 0!==h&&h.texture.dispose();const d=void 0!==a.morphAttributes.position,p=void 0!==a.morphAttributes.normal,f=void 0!==a.morphAttributes.color,m=a.morphAttributes.position||[],g=a.morphAttributes.normal||[],v=a.morphAttributes.color||[];let y=0;!0===d&&(y=1),!0===p&&(y=2),!0===f&&(y=3);let _=a.attributes.position.count*y,x=1;_>t.maxTextureSize&&(x=Math.ceil(_/t.maxTextureSize),_=t.maxTextureSize);const A=new Float32Array(_*x*4*c),M=new Ir(A,_,x,c);M.type=Ne,M.needsUpdate=!0;const b=4*y;for(let w=0;w<c;w++){const E=m[w],T=g[w],C=v[w],R=_*x*4*w;for(let P=0;P<E.count;P++){const I=P*b;!0===d&&(i.fromBufferAttribute(E,P),A[R+I+0]=i.x,A[R+I+1]=i.y,A[R+I+2]=i.z,A[R+I+3]=0),!0===p&&(i.fromBufferAttribute(T,P),A[R+I+4]=i.x,A[R+I+5]=i.y,A[R+I+6]=i.z,A[R+I+7]=0),!0===f&&(i.fromBufferAttribute(C,P),A[R+I+8]=i.x,A[R+I+9]=i.y,A[R+I+10]=i.z,A[R+I+11]=4===C.itemSize?i.w:1)}}function S(){M.dispose(),r.delete(a),a.removeEventListener("dispose",S)}h={count:c,texture:M,size:new ir(_,x)},r.set(a,h),a.addEventListener("dispose",S)}if(!0===s.isInstancedMesh&&null!==s.morphTexture)o.getUniforms().setValue(e,"morphTexture",s.morphTexture,n);else{let B=0;for(let D=0;D<l.length;D++)B+=l[D];const L=a.morphTargetsRelative?1:1-B;o.getUniforms().setValue(e,"morphTargetBaseInfluence",L),o.getUniforms().setValue(e,"morphTargetInfluences",l)}o.getUniforms().setValue(e,"morphTargetsTexture",h.texture,n),o.getUniforms().setValue(e,"morphTargetsTextureSize",h.size)}}}function ro(e,t,n,r){let i=new WeakMap;function s(e){const t=e.target;t.removeEventListener("dispose",s),n.remove(t.instanceMatrix),null!==t.instanceColor&&n.remove(t.instanceColor)}return{update:function(a){const o=r.render.frame,l=a.geometry,u=t.get(a,l);if(i.get(u)!==o&&(t.update(u),i.set(u,o)),a.isInstancedMesh&&(!1===a.hasEventListener("dispose",s)&&a.addEventListener("dispose",s),i.get(a)!==o&&(n.update(a.instanceMatrix,e.ARRAY_BUFFER),null!==a.instanceColor&&n.update(a.instanceColor,e.ARRAY_BUFFER),i.set(a,o))),a.isSkinnedMesh){const e=a.skeleton;i.get(e)!==o&&(e.update(),i.set(e,o))}return u},dispose:function(){i=new WeakMap}}}class io extends Tr{constructor(e,t,n,r,i,s,a,o,l){let u=arguments.length>9&&void 0!==arguments[9]?arguments[9]:Je;if(u!==Je&&u!==Ye)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");void 0===n&&u===Je&&(n=Ue),void 0===n&&u===Ye&&(n=He),super(null,r,i,s,a,o,u,n,l),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=void 0!==a?a:xe,this.minFilter=void 0!==o?o:xe,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.compareFunction=e.compareFunction,this}toJSON(e){const t=super.toJSON(e);return null!==this.compareFunction&&(t.compareFunction=this.compareFunction),t}}const so=new Tr,ao=new io(1,1),oo=new Ir,lo=new Lr,uo=new ua,co=[],ho=[],po=new Float32Array(16),fo=new Float32Array(9),mo=new Float32Array(4);function go(e,t,n){const r=e[0];if(r<=0||r>0)return e;const i=t*n;let s=co[i];if(void 0===s&&(s=new Float32Array(i),co[i]=s),0!==t){r.toArray(s,0);for(let r=1,i=0;r!==t;++r)i+=n,e[r].toArray(s,i)}return s}function vo(e,t){if(e.length!==t.length)return!1;for(let n=0,r=e.length;n<r;n++)if(e[n]!==t[n])return!1;return!0}function yo(e,t){for(let n=0,r=t.length;n<r;n++)e[n]=t[n]}function _o(e,t){let n=ho[t];void 0===n&&(n=new Int32Array(t),ho[t]=n);for(let r=0;r!==t;++r)n[r]=e.allocateTextureUnit();return n}function xo(e,t){const n=this.cache;n[0]!==t&&(e.uniform1f(this.addr,t),n[0]=t)}function Ao(e,t){const n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y||(e.uniform2f(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y);else{if(vo(n,t))return;e.uniform2fv(this.addr,t),yo(n,t)}}function Mo(e,t){const n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y&&n[2]===t.z||(e.uniform3f(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z);else if(void 0!==t.r)n[0]===t.r&&n[1]===t.g&&n[2]===t.b||(e.uniform3f(this.addr,t.r,t.g,t.b),n[0]=t.r,n[1]=t.g,n[2]=t.b);else{if(vo(n,t))return;e.uniform3fv(this.addr,t),yo(n,t)}}function bo(e,t){const n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y&&n[2]===t.z&&n[3]===t.w||(e.uniform4f(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w);else{if(vo(n,t))return;e.uniform4fv(this.addr,t),yo(n,t)}}function So(e,t){const n=this.cache,r=t.elements;if(void 0===r){if(vo(n,t))return;e.uniformMatrix2fv(this.addr,!1,t),yo(n,t)}else{if(vo(n,r))return;mo.set(r),e.uniformMatrix2fv(this.addr,!1,mo),yo(n,r)}}function wo(e,t){const n=this.cache,r=t.elements;if(void 0===r){if(vo(n,t))return;e.uniformMatrix3fv(this.addr,!1,t),yo(n,t)}else{if(vo(n,r))return;fo.set(r),e.uniformMatrix3fv(this.addr,!1,fo),yo(n,r)}}function Eo(e,t){const n=this.cache,r=t.elements;if(void 0===r){if(vo(n,t))return;e.uniformMatrix4fv(this.addr,!1,t),yo(n,t)}else{if(vo(n,r))return;po.set(r),e.uniformMatrix4fv(this.addr,!1,po),yo(n,r)}}function To(e,t){const n=this.cache;n[0]!==t&&(e.uniform1i(this.addr,t),n[0]=t)}function Co(e,t){const n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y||(e.uniform2i(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y);else{if(vo(n,t))return;e.uniform2iv(this.addr,t),yo(n,t)}}function Ro(e,t){const n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y&&n[2]===t.z||(e.uniform3i(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z);else{if(vo(n,t))return;e.uniform3iv(this.addr,t),yo(n,t)}}function Po(e,t){const n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y&&n[2]===t.z&&n[3]===t.w||(e.uniform4i(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w);else{if(vo(n,t))return;e.uniform4iv(this.addr,t),yo(n,t)}}function Io(e,t){const n=this.cache;n[0]!==t&&(e.uniform1ui(this.addr,t),n[0]=t)}function Bo(e,t){const n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y||(e.uniform2ui(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y);else{if(vo(n,t))return;e.uniform2uiv(this.addr,t),yo(n,t)}}function Lo(e,t){const n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y&&n[2]===t.z||(e.uniform3ui(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z);else{if(vo(n,t))return;e.uniform3uiv(this.addr,t),yo(n,t)}}function Do(e,t){const n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y&&n[2]===t.z&&n[3]===t.w||(e.uniform4ui(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w);else{if(vo(n,t))return;e.uniform4uiv(this.addr,t),yo(n,t)}}function Uo(e,t,n){const r=this.cache,i=n.allocateTextureUnit();let s;r[0]!==i&&(e.uniform1i(this.addr,i),r[0]=i),this.type===e.SAMPLER_2D_SHADOW?(ao.compareFunction=Cn,s=ao):s=so,n.setTexture2D(t||s,i)}function No(e,t,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(e.uniform1i(this.addr,i),r[0]=i),n.setTexture3D(t||lo,i)}function Fo(e,t,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(e.uniform1i(this.addr,i),r[0]=i),n.setTextureCube(t||uo,i)}function Oo(e,t,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(e.uniform1i(this.addr,i),r[0]=i),n.setTexture2DArray(t||oo,i)}function ko(e,t){e.uniform1fv(this.addr,t)}function Ho(e,t){const n=go(t,this.size,2);e.uniform2fv(this.addr,n)}function zo(e,t){const n=go(t,this.size,3);e.uniform3fv(this.addr,n)}function Go(e,t){const n=go(t,this.size,4);e.uniform4fv(this.addr,n)}function Vo(e,t){const n=go(t,this.size,4);e.uniformMatrix2fv(this.addr,!1,n)}function Wo(e,t){const n=go(t,this.size,9);e.uniformMatrix3fv(this.addr,!1,n)}function jo(e,t){const n=go(t,this.size,16);e.uniformMatrix4fv(this.addr,!1,n)}function Xo(e,t){e.uniform1iv(this.addr,t)}function Jo(e,t){e.uniform2iv(this.addr,t)}function Yo(e,t){e.uniform3iv(this.addr,t)}function Ko(e,t){e.uniform4iv(this.addr,t)}function qo(e,t){e.uniform1uiv(this.addr,t)}function Qo(e,t){e.uniform2uiv(this.addr,t)}function Zo(e,t){e.uniform3uiv(this.addr,t)}function $o(e,t){e.uniform4uiv(this.addr,t)}function el(e,t,n){const r=this.cache,i=t.length,s=_o(n,i);vo(r,s)||(e.uniform1iv(this.addr,s),yo(r,s));for(let a=0;a!==i;++a)n.setTexture2D(t[a]||so,s[a])}function tl(e,t,n){const r=this.cache,i=t.length,s=_o(n,i);vo(r,s)||(e.uniform1iv(this.addr,s),yo(r,s));for(let a=0;a!==i;++a)n.setTexture3D(t[a]||lo,s[a])}function nl(e,t,n){const r=this.cache,i=t.length,s=_o(n,i);vo(r,s)||(e.uniform1iv(this.addr,s),yo(r,s));for(let a=0;a!==i;++a)n.setTextureCube(t[a]||uo,s[a])}function rl(e,t,n){const r=this.cache,i=t.length,s=_o(n,i);vo(r,s)||(e.uniform1iv(this.addr,s),yo(r,s));for(let a=0;a!==i;++a)n.setTexture2DArray(t[a]||oo,s[a])}class il{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.setValue=function(e){switch(e){case 5126:return xo;case 35664:return Ao;case 35665:return Mo;case 35666:return bo;case 35674:return So;case 35675:return wo;case 35676:return Eo;case 5124:case 35670:return To;case 35667:case 35671:return Co;case 35668:case 35672:return Ro;case 35669:case 35673:return Po;case 5125:return Io;case 36294:return Bo;case 36295:return Lo;case 36296:return Do;case 35678:case 36198:case 36298:case 36306:case 35682:return Uo;case 35679:case 36299:case 36307:return No;case 35680:case 36300:case 36308:case 36293:return Fo;case 36289:case 36303:case 36311:case 36292:return Oo}}(t.type)}}class sl{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=function(e){switch(e){case 5126:return ko;case 35664:return Ho;case 35665:return zo;case 35666:return Go;case 35674:return Vo;case 35675:return Wo;case 35676:return jo;case 5124:case 35670:return Xo;case 35667:case 35671:return Jo;case 35668:case 35672:return Yo;case 35669:case 35673:return Ko;case 5125:return qo;case 36294:return Qo;case 36295:return Zo;case 36296:return $o;case 35678:case 36198:case 36298:case 36306:case 35682:return el;case 35679:case 36299:case 36307:return tl;case 35680:case 36300:case 36308:case 36293:return nl;case 36289:case 36303:case 36311:case 36292:return rl}}(t.type)}}class al{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,n){const r=this.seq;for(let i=0,s=r.length;i!==s;++i){const s=r[i];s.setValue(e,t[s.id],n)}}}const ol=/(\w+)(\])?(\[|\.)?/g;function ll(e,t){e.seq.push(t),e.map[t.id]=t}function ul(e,t,n){const r=e.name,i=r.length;for(ol.lastIndex=0;;){const s=ol.exec(r),a=ol.lastIndex;let o=s[1];const l="]"===s[2],u=s[3];if(l&&(o|=0),void 0===u||"["===u&&a+2===i){ll(n,void 0===u?new il(o,e,t):new sl(o,e,t));break}{let e=n.map[o];void 0===e&&(e=new al(o),ll(n,e)),n=e}}}class cl{constructor(e,t){this.seq=[],this.map={};const n=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let r=0;r<n;++r){const n=e.getActiveUniform(t,r);ul(n,e.getUniformLocation(t,n.name),this)}}setValue(e,t,n,r){const i=this.map[t];void 0!==i&&i.setValue(e,n,r)}setOptional(e,t,n){const r=t[n];void 0!==r&&this.setValue(e,n,r)}static upload(e,t,n,r){for(let i=0,s=t.length;i!==s;++i){const s=t[i],a=n[s.id];!1!==a.needsUpdate&&s.setValue(e,a.value,r)}}static seqWithValue(e,t){const n=[];for(let r=0,i=e.length;r!==i;++r){const i=e[r];i.id in t&&n.push(i)}return n}}function hl(e,t,n){const r=e.createShader(t);return e.shaderSource(r,n),e.compileShader(r),r}const dl=37297;let pl=0;function fl(e,t,n){const r=e.getShaderParameter(t,e.COMPILE_STATUS),i=e.getShaderInfoLog(t).trim();if(r&&""===i)return"";const s=/ERROR: 0:(\d+)/.exec(i);if(s){const r=parseInt(s[1]);return n.toUpperCase()+"\n\n"+i+"\n\n"+function(e,t){const n=e.split("\n"),r=[],i=Math.max(t-6,0),s=Math.min(t+6,n.length);for(let a=i;a<s;a++){const e=a+1;r.push(`${e===t?">":" "} ${e}: ${n[a]}`)}return r.join("\n")}(e.getShaderSource(t),r)}return i}function ml(e,t){const n=function(e){const t=yr.getPrimaries(yr.workingColorSpace),n=yr.getPrimaries(e);let r;switch(t===n?r="":t===ln&&n===on?r="LinearDisplayP3ToLinearSRGB":t===on&&n===ln&&(r="LinearSRGBToLinearDisplayP3"),e){case tn:case rn:return[r,"LinearTransferOETF"];case en:case nn:return[r,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",e),[r,"LinearTransferOETF"]}}(t);return`vec4 ${e}( vec4 value ) { return ${n[0]}( ${n[1]}( value ) ); }`}function gl(e,t){let n;switch(t){case ne:n="Linear";break;case re:n="Reinhard";break;case ie:n="OptimizedCineon";break;case se:n="ACESFilmic";break;case oe:n="AgX";break;case le:n="Neutral";break;case ae:n="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",t),n="Linear"}return"vec3 "+e+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}const vl=new Nr;function yl(){yr.getLuminanceCoefficients(vl);return["float luminance( const in vec3 rgb ) {",`\tconst vec3 weights = vec3( ${vl.x.toFixed(4)}, ${vl.y.toFixed(4)}, ${vl.z.toFixed(4)} );`,"\treturn dot( weights, rgb );","}"].join("\n")}function _l(e){return""!==e}function xl(e,t){const n=t.numSpotLightShadows+t.numSpotLightMaps-t.numSpotLightShadowsWithMaps;return e.replace(/NUM_DIR_LIGHTS/g,t.numDirLights).replace(/NUM_SPOT_LIGHTS/g,t.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,t.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,n).replace(/NUM_RECT_AREA_LIGHTS/g,t.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,t.numPointLights).replace(/NUM_HEMI_LIGHTS/g,t.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,t.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,t.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,t.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,t.numPointLightShadows)}function Al(e,t){return e.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}const Ml=/^[ \t]*#include +<([\w\d./]+)>/gm;function bl(e){return e.replace(Ml,wl)}const Sl=new Map;function wl(e,t){let n=Aa[t];if(void 0===n){const e=Sl.get(t);if(void 0===e)throw new Error("Can not resolve #include <"+t+">");n=Aa[e],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',t,e)}return bl(n)}const El=/#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 Tl(e){return e.replace(El,Cl)}function Cl(e,t,n,r){let i="";for(let s=parseInt(t);s<parseInt(n);s++)i+=r.replace(/\[\s*i\s*\]/g,"[ "+s+" ]").replace(/UNROLLED_LOOP_INDEX/g,s);return i}function Rl(e){let t=`precision ${e.precision} float;\n\tprecision ${e.precision} int;\n\tprecision ${e.precision} sampler2D;\n\tprecision ${e.precision} samplerCube;\n\tprecision ${e.precision} sampler3D;\n\tprecision ${e.precision} sampler2DArray;\n\tprecision ${e.precision} sampler2DShadow;\n\tprecision ${e.precision} samplerCubeShadow;\n\tprecision ${e.precision} sampler2DArrayShadow;\n\tprecision ${e.precision} isampler2D;\n\tprecision ${e.precision} isampler3D;\n\tprecision ${e.precision} isamplerCube;\n\tprecision ${e.precision} isampler2DArray;\n\tprecision ${e.precision} usampler2D;\n\tprecision ${e.precision} usampler3D;\n\tprecision ${e.precision} usamplerCube;\n\tprecision ${e.precision} usampler2DArray;\n\t`;return"highp"===e.precision?t+="\n#define HIGH_PRECISION":"mediump"===e.precision?t+="\n#define MEDIUM_PRECISION":"lowp"===e.precision&&(t+="\n#define LOW_PRECISION"),t}function Pl(e,t,n,r){const i=e.getContext(),s=n.defines;let a=n.vertexShader,o=n.fragmentShader;const l=function(e){let t="SHADOWMAP_TYPE_BASIC";return e.shadowMapType===d?t="SHADOWMAP_TYPE_PCF":e.shadowMapType===p?t="SHADOWMAP_TYPE_PCF_SOFT":e.shadowMapType===f&&(t="SHADOWMAP_TYPE_VSM"),t}(n),u=function(e){let t="ENVMAP_TYPE_CUBE";if(e.envMap)switch(e.envMapMode){case de:case pe:t="ENVMAP_TYPE_CUBE";break;case ge:t="ENVMAP_TYPE_CUBE_UV"}return t}(n),c=function(e){let t="ENVMAP_MODE_REFLECTION";e.envMap&&e.envMapMode===pe&&(t="ENVMAP_MODE_REFRACTION");return t}(n),h=function(e){let t="ENVMAP_BLENDING_NONE";if(e.envMap)switch(e.combine){case Z:t="ENVMAP_BLENDING_MULTIPLY";break;case $:t="ENVMAP_BLENDING_MIX";break;case ee:t="ENVMAP_BLENDING_ADD"}return t}(n),m=function(e){const t=e.envMapCubeUVHeight;if(null===t)return null;const n=Math.log2(t)-2,r=1/t;return{texelWidth:1/(3*Math.max(Math.pow(2,n),112)),texelHeight:r,maxMip:n}}(n),g=function(e){return[e.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",e.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(_l).join("\n")}(n),v=function(e){const t=[];for(const n in e){const r=e[n];!1!==r&&t.push("#define "+n+" "+r)}return t.join("\n")}(s),y=i.createProgram();let _,x,A=n.glslVersion?"#version "+n.glslVersion+"\n":"";n.isRawShaderMaterial?(_=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,v].filter(_l).join("\n"),_.length>0&&(_+="\n"),x=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,v].filter(_l).join("\n"),x.length>0&&(x+="\n")):(_=[Rl(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,v,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 "+c:"",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&&!1===n.flatShading?"#define USE_TANGENT":"",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&&!1===n.flatShading?"#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 "+l:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING","\tattribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR","\tattribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH","\tuniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1","\tattribute vec2 uv1;","#endif","#ifdef USE_UV2","\tattribute vec2 uv2;","#endif","#ifdef USE_UV3","\tattribute vec2 uv3;","#endif","#ifdef USE_TANGENT","\tattribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )","\tattribute vec4 color;","#elif defined( USE_COLOR )","\tattribute vec3 color;","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif","\n"].filter(_l).join("\n"),x=[Rl(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,v,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 "+u:"",n.envMap?"#define "+c:"",n.envMap?"#define "+h:"",m?"#define CUBEUV_TEXEL_WIDTH "+m.texelWidth:"",m?"#define CUBEUV_TEXEL_HEIGHT "+m.texelHeight:"",m?"#define CUBEUV_MAX_MIP "+m.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.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&&!1===n.flatShading?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor||n.batchingColor?"#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.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 "+l:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",n.toneMapping!==te?"#define TONE_MAPPING":"",n.toneMapping!==te?Aa.tonemapping_pars_fragment:"",n.toneMapping!==te?gl("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",Aa.colorspace_pars_fragment,ml("linearToOutputTexel",n.outputColorSpace),yl(),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"","\n"].filter(_l).join("\n")),a=bl(a),a=xl(a,n),a=Al(a,n),o=bl(o),o=xl(o,n),o=Al(o,n),a=Tl(a),o=Tl(o),!0!==n.isRawShaderMaterial&&(A="#version 300 es\n",_=[g,"#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+_,x=["#define varying in",n.glslVersion===Vn?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===Vn?"":"#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("\n")+"\n"+x);const M=A+_+a,b=A+x+o,S=hl(i,i.VERTEX_SHADER,M),w=hl(i,i.FRAGMENT_SHADER,b);function E(t){if(e.debug.checkShaderErrors){const n=i.getProgramInfoLog(y).trim(),r=i.getShaderInfoLog(S).trim(),s=i.getShaderInfoLog(w).trim();let a=!0,o=!0;if(!1===i.getProgramParameter(y,i.LINK_STATUS))if(a=!1,"function"===typeof e.debug.onShaderError)e.debug.onShaderError(i,y,S,w);else{const e=fl(i,S,"vertex"),r=fl(i,w,"fragment");console.error("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(y,i.VALIDATE_STATUS)+"\n\nMaterial Name: "+t.name+"\nMaterial Type: "+t.type+"\n\nProgram Info Log: "+n+"\n"+e+"\n"+r)}else""!==n?console.warn("THREE.WebGLProgram: Program Info Log:",n):""!==r&&""!==s||(o=!1);o&&(t.diagnostics={runnable:a,programLog:n,vertexShader:{log:r,prefix:_},fragmentShader:{log:s,prefix:x}})}i.deleteShader(S),i.deleteShader(w),T=new cl(i,y),C=function(e,t){const n={},r=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES);for(let i=0;i<r;i++){const r=e.getActiveAttrib(t,i),s=r.name;let a=1;r.type===e.FLOAT_MAT2&&(a=2),r.type===e.FLOAT_MAT3&&(a=3),r.type===e.FLOAT_MAT4&&(a=4),n[s]={type:r.type,location:e.getAttribLocation(t,s),locationSize:a}}return n}(i,y)}let T,C;i.attachShader(y,S),i.attachShader(y,w),void 0!==n.index0AttributeName?i.bindAttribLocation(y,0,n.index0AttributeName):!0===n.morphTargets&&i.bindAttribLocation(y,0,"position"),i.linkProgram(y),this.getUniforms=function(){return void 0===T&&E(this),T},this.getAttributes=function(){return void 0===C&&E(this),C};let R=!1===n.rendererExtensionParallelShaderCompile;return this.isReady=function(){return!1===R&&(R=i.getProgramParameter(y,dl)),R},this.destroy=function(){r.releaseStatesOfProgram(this),i.deleteProgram(y),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=pl++,this.cacheKey=t,this.usedTimes=1,this.program=y,this.vertexShader=S,this.fragmentShader=w,this}let Il=0;class Bl{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const t=e.vertexShader,n=e.fragmentShader,r=this._getShaderStage(t),i=this._getShaderStage(n),s=this._getShaderCacheForMaterial(e);return!1===s.has(r)&&(s.add(r),r.usedTimes++),!1===s.has(i)&&(s.add(i),i.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const n of t)n.usedTimes--,0===n.usedTimes&&this.shaderCache.delete(n.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const t=this.materialCache;let n=t.get(e);return void 0===n&&(n=new Set,t.set(e,n)),n}_getShaderStage(e){const t=this.shaderCache;let n=t.get(e);return void 0===n&&(n=new Ll(e),t.set(e,n)),n}}class Ll{constructor(e){this.id=Il++,this.code=e,this.usedTimes=0}}function Dl(e,t,n,r,i,s,a){const o=new bi,l=new Bl,u=new Set,c=[],h=i.logarithmicDepthBuffer,d=i.vertexTextures;let p=i.precision;const f={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function m(e){return u.add(e),0===e?"uv":`uv${e}`}return{getParameters:function(s,o,c,y,x){const A=y.fog,M=x.geometry,b=s.isMeshStandardMaterial?y.environment:null,S=(s.isMeshStandardMaterial?n:t).get(s.envMap||b),w=S&&S.mapping===ge?S.image.height:null,E=f[s.type];null!==s.precision&&(p=i.getMaxPrecision(s.precision),p!==s.precision&&console.warn("THREE.WebGLProgram.getParameters:",s.precision,"not supported, using",p,"instead."));const T=M.morphAttributes.position||M.morphAttributes.normal||M.morphAttributes.color,C=void 0!==T?T.length:0;let R,P,I,B,L=0;if(void 0!==M.morphAttributes.position&&(L=1),void 0!==M.morphAttributes.normal&&(L=2),void 0!==M.morphAttributes.color&&(L=3),E){const e=ba[E];R=e.vertexShader,P=e.fragmentShader}else R=s.vertexShader,P=s.fragmentShader,l.update(s),I=l.getVertexShaderID(s),B=l.getFragmentShaderID(s);const D=e.getRenderTarget(),U=!0===x.isInstancedMesh,N=!0===x.isBatchedMesh,F=!!s.map,O=!!s.matcap,k=!!S,H=!!s.aoMap,z=!!s.lightMap,G=!!s.bumpMap,V=!!s.normalMap,W=!!s.displacementMap,j=!!s.emissiveMap,X=!!s.metalnessMap,J=!!s.roughnessMap,Y=s.anisotropy>0,K=s.clearcoat>0,q=s.dispersion>0,Q=s.iridescence>0,Z=s.sheen>0,$=s.transmission>0,ee=Y&&!!s.anisotropyMap,ne=K&&!!s.clearcoatMap,re=K&&!!s.clearcoatNormalMap,ie=K&&!!s.clearcoatRoughnessMap,se=Q&&!!s.iridescenceMap,ae=Q&&!!s.iridescenceThicknessMap,oe=Z&&!!s.sheenColorMap,le=Z&&!!s.sheenRoughnessMap,ue=!!s.specularMap,ce=!!s.specularColorMap,he=!!s.specularIntensityMap,de=$&&!!s.transmissionMap,pe=$&&!!s.thicknessMap,fe=!!s.gradientMap,me=!!s.alphaMap,ve=s.alphaTest>0,ye=!!s.alphaHash,_e=!!s.extensions;let xe=te;s.toneMapped&&(null!==D&&!0!==D.isXRRenderTarget||(xe=e.toneMapping));const Ae={shaderID:E,shaderType:s.type,shaderName:s.name,vertexShader:R,fragmentShader:P,defines:s.defines,customVertexShaderID:I,customFragmentShaderID:B,isRawShaderMaterial:!0===s.isRawShaderMaterial,glslVersion:s.glslVersion,precision:p,batching:N,batchingColor:N&&null!==x._colorsTexture,instancing:U,instancingColor:U&&null!==x.instanceColor,instancingMorph:U&&null!==x.morphTexture,supportsVertexTextures:d,outputColorSpace:null===D?e.outputColorSpace:!0===D.isXRRenderTarget?D.texture.colorSpace:tn,alphaToCoverage:!!s.alphaToCoverage,map:F,matcap:O,envMap:k,envMapMode:k&&S.mapping,envMapCubeUVHeight:w,aoMap:H,lightMap:z,bumpMap:G,normalMap:V,displacementMap:d&&W,emissiveMap:j,normalMapObjectSpace:V&&s.normalMapType===Zt,normalMapTangentSpace:V&&s.normalMapType===Qt,metalnessMap:X,roughnessMap:J,anisotropy:Y,anisotropyMap:ee,clearcoat:K,clearcoatMap:ne,clearcoatNormalMap:re,clearcoatRoughnessMap:ie,dispersion:q,iridescence:Q,iridescenceMap:se,iridescenceThicknessMap:ae,sheen:Z,sheenColorMap:oe,sheenRoughnessMap:le,specularMap:ue,specularColorMap:ce,specularIntensityMap:he,transmission:$,transmissionMap:de,thicknessMap:pe,gradientMap:fe,opaque:!1===s.transparent&&s.blending===_&&!1===s.alphaToCoverage,alphaMap:me,alphaTest:ve,alphaHash:ye,combine:s.combine,mapUv:F&&m(s.map.channel),aoMapUv:H&&m(s.aoMap.channel),lightMapUv:z&&m(s.lightMap.channel),bumpMapUv:G&&m(s.bumpMap.channel),normalMapUv:V&&m(s.normalMap.channel),displacementMapUv:W&&m(s.displacementMap.channel),emissiveMapUv:j&&m(s.emissiveMap.channel),metalnessMapUv:X&&m(s.metalnessMap.channel),roughnessMapUv:J&&m(s.roughnessMap.channel),anisotropyMapUv:ee&&m(s.anisotropyMap.channel),clearcoatMapUv:ne&&m(s.clearcoatMap.channel),clearcoatNormalMapUv:re&&m(s.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:ie&&m(s.clearcoatRoughnessMap.channel),iridescenceMapUv:se&&m(s.iridescenceMap.channel),iridescenceThicknessMapUv:ae&&m(s.iridescenceThicknessMap.channel),sheenColorMapUv:oe&&m(s.sheenColorMap.channel),sheenRoughnessMapUv:le&&m(s.sheenRoughnessMap.channel),specularMapUv:ue&&m(s.specularMap.channel),specularColorMapUv:ce&&m(s.specularColorMap.channel),specularIntensityMapUv:he&&m(s.specularIntensityMap.channel),transmissionMapUv:de&&m(s.transmissionMap.channel),thicknessMapUv:pe&&m(s.thicknessMap.channel),alphaMapUv:me&&m(s.alphaMap.channel),vertexTangents:!!M.attributes.tangent&&(V||Y),vertexColors:s.vertexColors,vertexAlphas:!0===s.vertexColors&&!!M.attributes.color&&4===M.attributes.color.itemSize,pointsUvs:!0===x.isPoints&&!!M.attributes.uv&&(F||me),fog:!!A,useFog:!0===s.fog,fogExp2:!!A&&A.isFogExp2,flatShading:!0===s.flatShading,sizeAttenuation:!0===s.sizeAttenuation,logarithmicDepthBuffer:h,skinning:!0===x.isSkinnedMesh,morphTargets:void 0!==M.morphAttributes.position,morphNormals:void 0!==M.morphAttributes.normal,morphColors:void 0!==M.morphAttributes.color,morphTargetsCount:C,morphTextureStride:L,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,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:s.dithering,shadowMapEnabled:e.shadowMap.enabled&&c.length>0,shadowMapType:e.shadowMap.type,toneMapping:xe,decodeVideoTexture:F&&!0===s.map.isVideoTexture&&yr.getTransfer(s.map.colorSpace)===an,premultipliedAlpha:s.premultipliedAlpha,doubleSided:s.side===v,flipSided:s.side===g,useDepthPacking:s.depthPacking>=0,depthPacking:s.depthPacking||0,index0AttributeName:s.index0AttributeName,extensionClipCullDistance:_e&&!0===s.extensions.clipCullDistance&&r.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(_e&&!0===s.extensions.multiDraw||N)&&r.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:r.has("KHR_parallel_shader_compile"),customProgramCacheKey:s.customProgramCacheKey()};return Ae.vertexUv1s=u.has(1),Ae.vertexUv2s=u.has(2),Ae.vertexUv3s=u.has(3),u.clear(),Ae},getProgramCacheKey:function(t){const n=[];if(t.shaderID?n.push(t.shaderID):(n.push(t.customVertexShaderID),n.push(t.customFragmentShaderID)),void 0!==t.defines)for(const e in t.defines)n.push(e),n.push(t.defines[e]);return!1===t.isRawShaderMaterial&&(!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)}(n,t),function(e,t){o.disableAll(),t.supportsVertexTextures&&o.enable(0);t.instancing&&o.enable(1);t.instancingColor&&o.enable(2);t.instancingMorph&&o.enable(3);t.matcap&&o.enable(4);t.envMap&&o.enable(5);t.normalMapObjectSpace&&o.enable(6);t.normalMapTangentSpace&&o.enable(7);t.clearcoat&&o.enable(8);t.iridescence&&o.enable(9);t.alphaTest&&o.enable(10);t.vertexColors&&o.enable(11);t.vertexAlphas&&o.enable(12);t.vertexUv1s&&o.enable(13);t.vertexUv2s&&o.enable(14);t.vertexUv3s&&o.enable(15);t.vertexTangents&&o.enable(16);t.anisotropy&&o.enable(17);t.alphaHash&&o.enable(18);t.batching&&o.enable(19);t.dispersion&&o.enable(20);t.batchingColor&&o.enable(21);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.skinning&&o.enable(4);t.morphTargets&&o.enable(5);t.morphNormals&&o.enable(6);t.morphColors&&o.enable(7);t.premultipliedAlpha&&o.enable(8);t.shadowMapEnabled&&o.enable(9);t.doubleSided&&o.enable(10);t.flipSided&&o.enable(11);t.useDepthPacking&&o.enable(12);t.dithering&&o.enable(13);t.transmission&&o.enable(14);t.sheen&&o.enable(15);t.opaque&&o.enable(16);t.pointsUvs&&o.enable(17);t.decodeVideoTexture&&o.enable(18);t.alphaToCoverage&&o.enable(19);e.push(o.mask)}(n,t),n.push(e.outputColorSpace)),n.push(t.customProgramCacheKey),n.join()},getUniforms:function(e){const t=f[e.type];let n;if(t){const e=ba[t];n=ea.clone(e.uniforms)}else n=e.uniforms;return n},acquireProgram:function(t,n){let r;for(let e=0,i=c.length;e<i;e++){const t=c[e];if(t.cacheKey===n){r=t,++r.usedTimes;break}}return void 0===r&&(r=new Pl(e,n,t,s),c.push(r)),r},releaseProgram:function(e){if(0===--e.usedTimes){const t=c.indexOf(e);c[t]=c[c.length-1],c.pop(),e.destroy()}},releaseShaderCache:function(e){l.remove(e)},programs:c,dispose:function(){l.dispose()}}}function Ul(){let e=new WeakMap;return{get:function(t){let n=e.get(t);return void 0===n&&(n={},e.set(t,n)),n},remove:function(t){e.delete(t)},update:function(t,n,r){e.get(t)[n]=r},dispose:function(){e=new WeakMap}}}function Nl(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.material.id!==t.material.id?e.material.id-t.material.id:e.z!==t.z?e.z-t.z:e.id-t.id}function Fl(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.z!==t.z?t.z-e.z:e.id-t.id}function Ol(){const e=[];let t=0;const n=[],r=[],i=[];function s(n,r,i,s,a,o){let l=e[t];return void 0===l?(l={id:n.id,object:n,geometry:r,material:i,groupOrder:s,renderOrder:n.renderOrder,z:a,group:o},e[t]=l):(l.id=n.id,l.object=n,l.geometry=r,l.material=i,l.groupOrder=s,l.renderOrder=n.renderOrder,l.z=a,l.group=o),t++,l}return{opaque:n,transmissive:r,transparent:i,init:function(){t=0,n.length=0,r.length=0,i.length=0},push:function(e,t,a,o,l,u){const c=s(e,t,a,o,l,u);a.transmission>0?r.push(c):!0===a.transparent?i.push(c):n.push(c)},unshift:function(e,t,a,o,l,u){const c=s(e,t,a,o,l,u);a.transmission>0?r.unshift(c):!0===a.transparent?i.unshift(c):n.unshift(c)},finish:function(){for(let n=t,r=e.length;n<r;n++){const t=e[n];if(null===t.id)break;t.id=null,t.object=null,t.geometry=null,t.material=null,t.group=null}},sort:function(e,t){n.length>1&&n.sort(e||Nl),r.length>1&&r.sort(t||Fl),i.length>1&&i.sort(t||Fl)}}}function kl(){let e=new WeakMap;return{get:function(t,n){const r=e.get(t);let i;return void 0===r?(i=new Ol,e.set(t,[i])):n>=r.length?(i=new Ol,r.push(i)):i=r[n],i},dispose:function(){e=new WeakMap}}}function Hl(){const e={};return{get:function(t){if(void 0!==e[t.id])return e[t.id];let n;switch(t.type){case"DirectionalLight":n={direction:new Nr,color:new ts};break;case"SpotLight":n={position:new Nr,direction:new Nr,color:new ts,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new Nr,color:new ts,distance:0,decay:0};break;case"HemisphereLight":n={direction:new Nr,skyColor:new ts,groundColor:new ts};break;case"RectAreaLight":n={color:new ts,position:new Nr,halfWidth:new Nr,halfHeight:new Nr}}return e[t.id]=n,n}}}let zl=0;function Gl(e,t){return(t.castShadow?2:0)-(e.castShadow?2:0)+(t.map?1:0)-(e.map?1:0)}function Vl(e){const t=new Hl,n=function(){const e={};return{get:function(t){if(void 0!==e[t.id])return e[t.id];let n;switch(t.type){case"DirectionalLight":case"SpotLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new ir};break;case"PointLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new ir,shadowCameraNear:1,shadowCameraFar:1e3}}return e[t.id]=n,n}}}(),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 o=0;o<9;o++)r.probe.push(new Nr);const i=new Nr,s=new di,a=new di;return{setup:function(i){let s=0,a=0,o=0;for(let e=0;e<9;e++)r.probe[e].set(0,0,0);let l=0,u=0,c=0,h=0,d=0,p=0,f=0,m=0,g=0,v=0,y=0;i.sort(Gl);for(let e=0,x=i.length;e<x;e++){const _=i[e],x=_.color,A=_.intensity,M=_.distance,b=_.shadow&&_.shadow.map?_.shadow.map.texture:null;if(_.isAmbientLight)s+=x.r*A,a+=x.g*A,o+=x.b*A;else if(_.isLightProbe){for(let e=0;e<9;e++)r.probe[e].addScaledVector(_.sh.coefficients[e],A);y++}else if(_.isDirectionalLight){const e=t.get(_);if(e.color.copy(_.color).multiplyScalar(_.intensity),_.castShadow){const e=_.shadow,t=n.get(_);t.shadowIntensity=e.intensity,t.shadowBias=e.bias,t.shadowNormalBias=e.normalBias,t.shadowRadius=e.radius,t.shadowMapSize=e.mapSize,r.directionalShadow[l]=t,r.directionalShadowMap[l]=b,r.directionalShadowMatrix[l]=_.shadow.matrix,p++}r.directional[l]=e,l++}else if(_.isSpotLight){const e=t.get(_);e.position.setFromMatrixPosition(_.matrixWorld),e.color.copy(x).multiplyScalar(A),e.distance=M,e.coneCos=Math.cos(_.angle),e.penumbraCos=Math.cos(_.angle*(1-_.penumbra)),e.decay=_.decay,r.spot[c]=e;const i=_.shadow;if(_.map&&(r.spotLightMap[g]=_.map,g++,i.updateMatrices(_),_.castShadow&&v++),r.spotLightMatrix[c]=i.matrix,_.castShadow){const e=n.get(_);e.shadowIntensity=i.intensity,e.shadowBias=i.bias,e.shadowNormalBias=i.normalBias,e.shadowRadius=i.radius,e.shadowMapSize=i.mapSize,r.spotShadow[c]=e,r.spotShadowMap[c]=b,m++}c++}else if(_.isRectAreaLight){const e=t.get(_);e.color.copy(x).multiplyScalar(A),e.halfWidth.set(.5*_.width,0,0),e.halfHeight.set(0,.5*_.height,0),r.rectArea[h]=e,h++}else if(_.isPointLight){const e=t.get(_);if(e.color.copy(_.color).multiplyScalar(_.intensity),e.distance=_.distance,e.decay=_.decay,_.castShadow){const e=_.shadow,t=n.get(_);t.shadowIntensity=e.intensity,t.shadowBias=e.bias,t.shadowNormalBias=e.normalBias,t.shadowRadius=e.radius,t.shadowMapSize=e.mapSize,t.shadowCameraNear=e.camera.near,t.shadowCameraFar=e.camera.far,r.pointShadow[u]=t,r.pointShadowMap[u]=b,r.pointShadowMatrix[u]=_.shadow.matrix,f++}r.point[u]=e,u++}else if(_.isHemisphereLight){const e=t.get(_);e.skyColor.copy(_.color).multiplyScalar(A),e.groundColor.copy(_.groundColor).multiplyScalar(A),r.hemi[d]=e,d++}}h>0&&(!0===e.has("OES_texture_float_linear")?(r.rectAreaLTC1=Ma.LTC_FLOAT_1,r.rectAreaLTC2=Ma.LTC_FLOAT_2):(r.rectAreaLTC1=Ma.LTC_HALF_1,r.rectAreaLTC2=Ma.LTC_HALF_2)),r.ambient[0]=s,r.ambient[1]=a,r.ambient[2]=o;const _=r.hash;_.directionalLength===l&&_.pointLength===u&&_.spotLength===c&&_.rectAreaLength===h&&_.hemiLength===d&&_.numDirectionalShadows===p&&_.numPointShadows===f&&_.numSpotShadows===m&&_.numSpotMaps===g&&_.numLightProbes===y||(r.directional.length=l,r.spot.length=c,r.rectArea.length=h,r.point.length=u,r.hemi.length=d,r.directionalShadow.length=p,r.directionalShadowMap.length=p,r.pointShadow.length=f,r.pointShadowMap.length=f,r.spotShadow.length=m,r.spotShadowMap.length=m,r.directionalShadowMatrix.length=p,r.pointShadowMatrix.length=f,r.spotLightMatrix.length=m+g-v,r.spotLightMap.length=g,r.numSpotLightShadowsWithMaps=v,r.numLightProbes=y,_.directionalLength=l,_.pointLength=u,_.spotLength=c,_.rectAreaLength=h,_.hemiLength=d,_.numDirectionalShadows=p,_.numPointShadows=f,_.numSpotShadows=m,_.numSpotMaps=g,_.numLightProbes=y,r.version=zl++)},setupView:function(e,t){let n=0,o=0,l=0,u=0,c=0;const h=t.matrixWorldInverse;for(let d=0,p=e.length;d<p;d++){const t=e[d];if(t.isDirectionalLight){const e=r.directional[n];e.direction.setFromMatrixPosition(t.matrixWorld),i.setFromMatrixPosition(t.target.matrixWorld),e.direction.sub(i),e.direction.transformDirection(h),n++}else if(t.isSpotLight){const e=r.spot[l];e.position.setFromMatrixPosition(t.matrixWorld),e.position.applyMatrix4(h),e.direction.setFromMatrixPosition(t.matrixWorld),i.setFromMatrixPosition(t.target.matrixWorld),e.direction.sub(i),e.direction.transformDirection(h),l++}else if(t.isRectAreaLight){const e=r.rectArea[u];e.position.setFromMatrixPosition(t.matrixWorld),e.position.applyMatrix4(h),a.identity(),s.copy(t.matrixWorld),s.premultiply(h),a.extractRotation(s),e.halfWidth.set(.5*t.width,0,0),e.halfHeight.set(0,.5*t.height,0),e.halfWidth.applyMatrix4(a),e.halfHeight.applyMatrix4(a),u++}else if(t.isPointLight){const e=r.point[o];e.position.setFromMatrixPosition(t.matrixWorld),e.position.applyMatrix4(h),o++}else if(t.isHemisphereLight){const e=r.hemi[c];e.direction.setFromMatrixPosition(t.matrixWorld),e.direction.transformDirection(h),c++}}},state:r}}function Wl(e){const t=new Vl(e),n=[],r=[];const i={lightsArray:n,shadowsArray:r,camera:null,lights:t,transmissionRenderTarget:{}};return{init:function(e){i.camera=e,n.length=0,r.length=0},state:i,setupLights:function(){t.setup(n)},setupLightsView:function(e){t.setupView(n,e)},pushLight:function(e){n.push(e)},pushShadow:function(e){r.push(e)}}}function jl(e){let t=new WeakMap;return{get:function(n){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;const i=t.get(n);let s;return void 0===i?(s=new Wl(e),t.set(n,[s])):r>=i.length?(s=new Wl(e),i.push(s)):s=i[r],s},dispose:function(){t=new WeakMap}}}class Xl extends is{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=Jt,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class Jl extends is{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}function Yl(e,t,n){let r=new va;const i=new ir,s=new ir,a=new Cr,o=new Xl({depthPacking:Yt}),l=new Jl,u={},c=n.maxTextureSize,h={[m]:g,[g]:m,[v]:v},p=new ta({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new ir},radius:{value:4}},vertexShader:"void main() {\n\tgl_Position = vec4( position, 1.0 );\n}",fragmentShader:"uniform sampler2D shadow_pass;\nuniform vec2 resolution;\nuniform float radius;\n#include <packing>\nvoid main() {\n\tconst float samples = float( VSM_SAMPLES );\n\tfloat mean = 0.0;\n\tfloat squared_mean = 0.0;\n\tfloat uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );\n\tfloat uvStart = samples <= 1.0 ? 0.0 : - 1.0;\n\tfor ( float i = 0.0; i < samples; i ++ ) {\n\t\tfloat uvOffset = uvStart + i * uvStride;\n\t\t#ifdef HORIZONTAL_PASS\n\t\t\tvec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );\n\t\t\tmean += distribution.x;\n\t\t\tsquared_mean += distribution.y * distribution.y + distribution.x * distribution.x;\n\t\t#else\n\t\t\tfloat depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );\n\t\t\tmean += depth;\n\t\t\tsquared_mean += depth * depth;\n\t\t#endif\n\t}\n\tmean = mean / samples;\n\tsquared_mean = squared_mean / samples;\n\tfloat std_dev = sqrt( squared_mean - mean * mean );\n\tgl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );\n}"}),_=p.clone();_.defines.HORIZONTAL_PASS=1;const x=new Ps;x.setAttribute("position",new ps(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const A=new Ys(x,p),M=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=d;let b=this.type;function S(n,r){const s=t.update(A);p.defines.VSM_SAMPLES!==n.blurSamples&&(p.defines.VSM_SAMPLES=n.blurSamples,_.defines.VSM_SAMPLES=n.blurSamples,p.needsUpdate=!0,_.needsUpdate=!0),null===n.mapPass&&(n.mapPass=new Pr(i.x,i.y)),p.uniforms.shadow_pass.value=n.map.texture,p.uniforms.resolution.value=n.mapSize,p.uniforms.radius.value=n.radius,e.setRenderTarget(n.mapPass),e.clear(),e.renderBufferDirect(r,null,s,p,A,null),_.uniforms.shadow_pass.value=n.mapPass.texture,_.uniforms.resolution.value=n.mapSize,_.uniforms.radius.value=n.radius,e.setRenderTarget(n.map),e.clear(),e.renderBufferDirect(r,null,s,_,A,null)}function w(t,n,r,i){let s=null;const a=!0===r.isPointLight?t.customDistanceMaterial:t.customDepthMaterial;if(void 0!==a)s=a;else if(s=!0===r.isPointLight?l:o,e.localClippingEnabled&&!0===n.clipShadows&&Array.isArray(n.clippingPlanes)&&0!==n.clippingPlanes.length||n.displacementMap&&0!==n.displacementScale||n.alphaMap&&n.alphaTest>0||n.map&&n.alphaTest>0){const e=s.uuid,t=n.uuid;let r=u[e];void 0===r&&(r={},u[e]=r);let i=r[t];void 0===i&&(i=s.clone(),r[t]=i,n.addEventListener("dispose",T)),s=i}if(s.visible=n.visible,s.wireframe=n.wireframe,s.side=i===f?null!==n.shadowSide?n.shadowSide:n.side:null!==n.shadowSide?n.shadowSide:h[n.side],s.alphaMap=n.alphaMap,s.alphaTest=n.alphaTest,s.map=n.map,s.clipShadows=n.clipShadows,s.clippingPlanes=n.clippingPlanes,s.clipIntersection=n.clipIntersection,s.displacementMap=n.displacementMap,s.displacementScale=n.displacementScale,s.displacementBias=n.displacementBias,s.wireframeLinewidth=n.wireframeLinewidth,s.linewidth=n.linewidth,!0===r.isPointLight&&!0===s.isMeshDistanceMaterial){e.properties.get(s).light=r}return s}function E(n,i,s,a,o){if(!1===n.visible)return;if(n.layers.test(i.layers)&&(n.isMesh||n.isLine||n.isPoints)&&(n.castShadow||n.receiveShadow&&o===f)&&(!n.frustumCulled||r.intersectsObject(n))){n.modelViewMatrix.multiplyMatrices(s.matrixWorldInverse,n.matrixWorld);const r=t.update(n),l=n.material;if(Array.isArray(l)){const t=r.groups;for(let u=0,c=t.length;u<c;u++){const c=t[u],h=l[c.materialIndex];if(h&&h.visible){const t=w(n,h,a,o);n.onBeforeShadow(e,n,i,s,r,t,c),e.renderBufferDirect(s,null,r,t,n,c),n.onAfterShadow(e,n,i,s,r,t,c)}}}else if(l.visible){const t=w(n,l,a,o);n.onBeforeShadow(e,n,i,s,r,t,null),e.renderBufferDirect(s,null,r,t,n,null),n.onAfterShadow(e,n,i,s,r,t,null)}}const l=n.children;for(let e=0,t=l.length;e<t;e++)E(l[e],i,s,a,o)}function T(e){e.target.removeEventListener("dispose",T);for(const t in u){const n=u[t],r=e.target.uuid;if(r in n){n[r].dispose(),delete n[r]}}}this.render=function(t,n,o){if(!1===M.enabled)return;if(!1===M.autoUpdate&&!1===M.needsUpdate)return;if(0===t.length)return;const l=e.getRenderTarget(),u=e.getActiveCubeFace(),h=e.getActiveMipmapLevel(),d=e.state;d.setBlending(y),d.buffers.color.setClear(1,1,1,1),d.buffers.depth.setTest(!0),d.setScissorTest(!1);const p=b!==f&&this.type===f,m=b===f&&this.type!==f;for(let g=0,v=t.length;g<v;g++){const l=t[g],u=l.shadow;if(void 0===u){console.warn("THREE.WebGLShadowMap:",l,"has no shadow.");continue}if(!1===u.autoUpdate&&!1===u.needsUpdate)continue;i.copy(u.mapSize);const h=u.getFrameExtents();if(i.multiply(h),s.copy(u.mapSize),(i.x>c||i.y>c)&&(i.x>c&&(s.x=Math.floor(c/h.x),i.x=s.x*h.x,u.mapSize.x=s.x),i.y>c&&(s.y=Math.floor(c/h.y),i.y=s.y*h.y,u.mapSize.y=s.y)),null===u.map||!0===p||!0===m){const e=this.type!==f?{minFilter:xe,magFilter:xe}:{};null!==u.map&&u.map.dispose(),u.map=new Pr(i.x,i.y,e),u.map.texture.name=l.name+".shadowMap",u.camera.updateProjectionMatrix()}e.setRenderTarget(u.map),e.clear();const v=u.getViewportCount();for(let e=0;e<v;e++){const t=u.getViewport(e);a.set(s.x*t.x,s.y*t.y,s.x*t.z,s.y*t.w),d.viewport(a),u.updateMatrices(l,e),r=u.getFrustum(),E(n,o,u.camera,l,this.type)}!0!==u.isPointLightShadow&&this.type===f&&S(u,o),u.needsUpdate=!1}b=this.type,M.needsUpdate=!1,e.setRenderTarget(l,u,h)}}function Kl(e){const t=new function(){let t=!1;const n=new Cr;let r=null;const i=new Cr(0,0,0,0);return{setMask:function(n){r===n||t||(e.colorMask(n,n,n,n),r=n)},setLocked:function(e){t=e},setClear:function(t,r,s,a,o){!0===o&&(t*=a,r*=a,s*=a),n.set(t,r,s,a),!1===i.equals(n)&&(e.clearColor(t,r,s,a),i.copy(n))},reset:function(){t=!1,r=null,i.set(-1,0,0,0)}}},n=new function(){let t=!1,n=null,r=null,i=null;return{setTest:function(t){t?Se(e.DEPTH_TEST):we(e.DEPTH_TEST)},setMask:function(r){n===r||t||(e.depthMask(r),n=r)},setFunc:function(t){if(r!==t){switch(t){case W:e.depthFunc(e.NEVER);break;case j:e.depthFunc(e.ALWAYS);break;case X:e.depthFunc(e.LESS);break;case J:e.depthFunc(e.LEQUAL);break;case Y:e.depthFunc(e.EQUAL);break;case K:e.depthFunc(e.GEQUAL);break;case q:e.depthFunc(e.GREATER);break;case Q:e.depthFunc(e.NOTEQUAL);break;default:e.depthFunc(e.LEQUAL)}r=t}},setLocked:function(e){t=e},setClear:function(t){i!==t&&(e.clearDepth(t),i=t)},reset:function(){t=!1,n=null,r=null,i=null}}},r=new function(){let t=!1,n=null,r=null,i=null,s=null,a=null,o=null,l=null,u=null;return{setTest:function(n){t||(n?Se(e.STENCIL_TEST):we(e.STENCIL_TEST))},setMask:function(r){n===r||t||(e.stencilMask(r),n=r)},setFunc:function(t,n,a){r===t&&i===n&&s===a||(e.stencilFunc(t,n,a),r=t,i=n,s=a)},setOp:function(t,n,r){a===t&&o===n&&l===r||(e.stencilOp(t,n,r),a=t,o=n,l=r)},setLocked:function(e){t=e},setClear:function(t){u!==t&&(e.clearStencil(t),u=t)},reset:function(){t=!1,n=null,r=null,i=null,s=null,a=null,o=null,l=null,u=null}}},i=new WeakMap,s=new WeakMap;let a={},c={},h=new WeakMap,d=[],p=null,f=!1,m=null,Z=null,$=null,ee=null,te=null,ne=null,re=null,ie=new ts(0,0,0),se=0,ae=!1,oe=null,le=null,ue=null,ce=null,he=null;const de=e.getParameter(e.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let pe=!1,fe=0;const me=e.getParameter(e.VERSION);-1!==me.indexOf("WebGL")?(fe=parseFloat(/^WebGL (\d)/.exec(me)[1]),pe=fe>=1):-1!==me.indexOf("OpenGL ES")&&(fe=parseFloat(/^OpenGL ES (\d)/.exec(me)[1]),pe=fe>=2);let ge=null,ve={};const ye=e.getParameter(e.SCISSOR_BOX),_e=e.getParameter(e.VIEWPORT),xe=(new Cr).fromArray(ye),Ae=(new Cr).fromArray(_e);function Me(t,n,r,i){const s=new Uint8Array(4),a=e.createTexture();e.bindTexture(t,a),e.texParameteri(t,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(t,e.TEXTURE_MAG_FILTER,e.NEAREST);for(let o=0;o<r;o++)t===e.TEXTURE_3D||t===e.TEXTURE_2D_ARRAY?e.texImage3D(n,0,e.RGBA,1,1,i,0,e.RGBA,e.UNSIGNED_BYTE,s):e.texImage2D(n+o,0,e.RGBA,1,1,0,e.RGBA,e.UNSIGNED_BYTE,s);return a}const be={};function Se(t){!0!==a[t]&&(e.enable(t),a[t]=!0)}function we(t){!1!==a[t]&&(e.disable(t),a[t]=!1)}be[e.TEXTURE_2D]=Me(e.TEXTURE_2D,e.TEXTURE_2D,1),be[e.TEXTURE_CUBE_MAP]=Me(e.TEXTURE_CUBE_MAP,e.TEXTURE_CUBE_MAP_POSITIVE_X,6),be[e.TEXTURE_2D_ARRAY]=Me(e.TEXTURE_2D_ARRAY,e.TEXTURE_2D_ARRAY,1,1),be[e.TEXTURE_3D]=Me(e.TEXTURE_3D,e.TEXTURE_3D,1,1),t.setClear(0,0,0,1),n.setClear(1),r.setClear(0),Se(e.DEPTH_TEST),n.setFunc(J),Re(!1),Pe(l),Se(e.CULL_FACE),Ce(y);const Ee={[S]:e.FUNC_ADD,[w]:e.FUNC_SUBTRACT,[E]:e.FUNC_REVERSE_SUBTRACT};Ee[T]=e.MIN,Ee[C]=e.MAX;const Te={[R]:e.ZERO,[P]:e.ONE,[I]:e.SRC_COLOR,[L]:e.SRC_ALPHA,[k]:e.SRC_ALPHA_SATURATE,[F]:e.DST_COLOR,[U]:e.DST_ALPHA,[B]:e.ONE_MINUS_SRC_COLOR,[D]:e.ONE_MINUS_SRC_ALPHA,[O]:e.ONE_MINUS_DST_COLOR,[N]:e.ONE_MINUS_DST_ALPHA,[H]:e.CONSTANT_COLOR,[z]:e.ONE_MINUS_CONSTANT_COLOR,[G]:e.CONSTANT_ALPHA,[V]:e.ONE_MINUS_CONSTANT_ALPHA};function Ce(t,n,r,i,s,a,o,l,u,c){if(t!==y){if(!1===f&&(Se(e.BLEND),f=!0),t===b)s=s||n,a=a||r,o=o||i,n===Z&&s===te||(e.blendEquationSeparate(Ee[n],Ee[s]),Z=n,te=s),r===$&&i===ee&&a===ne&&o===re||(e.blendFuncSeparate(Te[r],Te[i],Te[a],Te[o]),$=r,ee=i,ne=a,re=o),!1!==l.equals(ie)&&u===se||(e.blendColor(l.r,l.g,l.b,u),ie.copy(l),se=u),m=t,ae=!1;else if(t!==m||c!==ae){if(Z===S&&te===S||(e.blendEquation(e.FUNC_ADD),Z=S,te=S),c)switch(t){case _:e.blendFuncSeparate(e.ONE,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case x:e.blendFunc(e.ONE,e.ONE);break;case A:e.blendFuncSeparate(e.ZERO,e.ONE_MINUS_SRC_COLOR,e.ZERO,e.ONE);break;case M:e.blendFuncSeparate(e.ZERO,e.SRC_COLOR,e.ZERO,e.SRC_ALPHA);break;default:console.error("THREE.WebGLState: Invalid blending: ",t)}else switch(t){case _:e.blendFuncSeparate(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case x:e.blendFunc(e.SRC_ALPHA,e.ONE);break;case A:e.blendFuncSeparate(e.ZERO,e.ONE_MINUS_SRC_COLOR,e.ZERO,e.ONE);break;case M:e.blendFunc(e.ZERO,e.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",t)}$=null,ee=null,ne=null,re=null,ie.set(0,0,0),se=0,m=t,ae=c}}else!0===f&&(we(e.BLEND),f=!1)}function Re(t){oe!==t&&(t?e.frontFace(e.CW):e.frontFace(e.CCW),oe=t)}function Pe(t){t!==o?(Se(e.CULL_FACE),t!==le&&(t===l?e.cullFace(e.BACK):t===u?e.cullFace(e.FRONT):e.cullFace(e.FRONT_AND_BACK))):we(e.CULL_FACE),le=t}function Ie(t,n,r){t?(Se(e.POLYGON_OFFSET_FILL),ce===n&&he===r||(e.polygonOffset(n,r),ce=n,he=r)):we(e.POLYGON_OFFSET_FILL)}return{buffers:{color:t,depth:n,stencil:r},enable:Se,disable:we,bindFramebuffer:function(t,n){return c[t]!==n&&(e.bindFramebuffer(t,n),c[t]=n,t===e.DRAW_FRAMEBUFFER&&(c[e.FRAMEBUFFER]=n),t===e.FRAMEBUFFER&&(c[e.DRAW_FRAMEBUFFER]=n),!0)},drawBuffers:function(t,n){let r=d,i=!1;if(t){r=h.get(n),void 0===r&&(r=[],h.set(n,r));const s=t.textures;if(r.length!==s.length||r[0]!==e.COLOR_ATTACHMENT0){for(let t=0,n=s.length;t<n;t++)r[t]=e.COLOR_ATTACHMENT0+t;r.length=s.length,i=!0}}else r[0]!==e.BACK&&(r[0]=e.BACK,i=!0);i&&e.drawBuffers(r)},useProgram:function(t){return p!==t&&(e.useProgram(t),p=t,!0)},setBlending:Ce,setMaterial:function(i,s){i.side===v?we(e.CULL_FACE):Se(e.CULL_FACE);let a=i.side===g;s&&(a=!a),Re(a),i.blending===_&&!1===i.transparent?Ce(y):Ce(i.blending,i.blendEquation,i.blendSrc,i.blendDst,i.blendEquationAlpha,i.blendSrcAlpha,i.blendDstAlpha,i.blendColor,i.blendAlpha,i.premultipliedAlpha),n.setFunc(i.depthFunc),n.setTest(i.depthTest),n.setMask(i.depthWrite),t.setMask(i.colorWrite);const o=i.stencilWrite;r.setTest(o),o&&(r.setMask(i.stencilWriteMask),r.setFunc(i.stencilFunc,i.stencilRef,i.stencilFuncMask),r.setOp(i.stencilFail,i.stencilZFail,i.stencilZPass)),Ie(i.polygonOffset,i.polygonOffsetFactor,i.polygonOffsetUnits),!0===i.alphaToCoverage?Se(e.SAMPLE_ALPHA_TO_COVERAGE):we(e.SAMPLE_ALPHA_TO_COVERAGE)},setFlipSided:Re,setCullFace:Pe,setLineWidth:function(t){t!==ue&&(pe&&e.lineWidth(t),ue=t)},setPolygonOffset:Ie,setScissorTest:function(t){t?Se(e.SCISSOR_TEST):we(e.SCISSOR_TEST)},activeTexture:function(t){void 0===t&&(t=e.TEXTURE0+de-1),ge!==t&&(e.activeTexture(t),ge=t)},bindTexture:function(t,n,r){void 0===r&&(r=null===ge?e.TEXTURE0+de-1:ge);let i=ve[r];void 0===i&&(i={type:void 0,texture:void 0},ve[r]=i),i.type===t&&i.texture===n||(ge!==r&&(e.activeTexture(r),ge=r),e.bindTexture(t,n||be[t]),i.type=t,i.texture=n)},unbindTexture:function(){const t=ve[ge];void 0!==t&&void 0!==t.type&&(e.bindTexture(t.type,null),t.type=void 0,t.texture=void 0)},compressedTexImage2D:function(){try{e.compressedTexImage2D.apply(e,arguments)}catch(by){console.error("THREE.WebGLState:",by)}},compressedTexImage3D:function(){try{e.compressedTexImage3D.apply(e,arguments)}catch(by){console.error("THREE.WebGLState:",by)}},texImage2D:function(){try{e.texImage2D.apply(e,arguments)}catch(by){console.error("THREE.WebGLState:",by)}},texImage3D:function(){try{e.texImage3D.apply(e,arguments)}catch(by){console.error("THREE.WebGLState:",by)}},updateUBOMapping:function(t,n){let r=s.get(n);void 0===r&&(r=new WeakMap,s.set(n,r));let i=r.get(t);void 0===i&&(i=e.getUniformBlockIndex(n,t.name),r.set(t,i))},uniformBlockBinding:function(t,n){const r=s.get(n).get(t);i.get(n)!==r&&(e.uniformBlockBinding(n,r,t.__bindingPointIndex),i.set(n,r))},texStorage2D:function(){try{e.texStorage2D.apply(e,arguments)}catch(by){console.error("THREE.WebGLState:",by)}},texStorage3D:function(){try{e.texStorage3D.apply(e,arguments)}catch(by){console.error("THREE.WebGLState:",by)}},texSubImage2D:function(){try{e.texSubImage2D.apply(e,arguments)}catch(by){console.error("THREE.WebGLState:",by)}},texSubImage3D:function(){try{e.texSubImage3D.apply(e,arguments)}catch(by){console.error("THREE.WebGLState:",by)}},compressedTexSubImage2D:function(){try{e.compressedTexSubImage2D.apply(e,arguments)}catch(by){console.error("THREE.WebGLState:",by)}},compressedTexSubImage3D:function(){try{e.compressedTexSubImage3D.apply(e,arguments)}catch(by){console.error("THREE.WebGLState:",by)}},scissor:function(t){!1===xe.equals(t)&&(e.scissor(t.x,t.y,t.z,t.w),xe.copy(t))},viewport:function(t){!1===Ae.equals(t)&&(e.viewport(t.x,t.y,t.z,t.w),Ae.copy(t))},reset:function(){e.disable(e.BLEND),e.disable(e.CULL_FACE),e.disable(e.DEPTH_TEST),e.disable(e.POLYGON_OFFSET_FILL),e.disable(e.SCISSOR_TEST),e.disable(e.STENCIL_TEST),e.disable(e.SAMPLE_ALPHA_TO_COVERAGE),e.blendEquation(e.FUNC_ADD),e.blendFunc(e.ONE,e.ZERO),e.blendFuncSeparate(e.ONE,e.ZERO,e.ONE,e.ZERO),e.blendColor(0,0,0,0),e.colorMask(!0,!0,!0,!0),e.clearColor(0,0,0,0),e.depthMask(!0),e.depthFunc(e.LESS),e.clearDepth(1),e.stencilMask(4294967295),e.stencilFunc(e.ALWAYS,0,4294967295),e.stencilOp(e.KEEP,e.KEEP,e.KEEP),e.clearStencil(0),e.cullFace(e.BACK),e.frontFace(e.CCW),e.polygonOffset(0,0),e.activeTexture(e.TEXTURE0),e.bindFramebuffer(e.FRAMEBUFFER,null),e.bindFramebuffer(e.DRAW_FRAMEBUFFER,null),e.bindFramebuffer(e.READ_FRAMEBUFFER,null),e.useProgram(null),e.lineWidth(1),e.scissor(0,0,e.canvas.width,e.canvas.height),e.viewport(0,0,e.canvas.width,e.canvas.height),a={},ge=null,ve={},c={},h=new WeakMap,d=[],p=null,f=!1,m=null,Z=null,$=null,ee=null,te=null,ne=null,re=null,ie=new ts(0,0,0),se=0,ae=!1,oe=null,le=null,ue=null,ce=null,he=null,xe.set(0,0,e.canvas.width,e.canvas.height),Ae.set(0,0,e.canvas.width,e.canvas.height),t.reset(),n.reset(),r.reset()}}}function ql(e,t,n,r){const i=function(e){switch(e){case Pe:case Ie:return{byteLength:1,components:1};case Le:case Be:case Fe:return{byteLength:2,components:1};case Oe:case ke:return{byteLength:2,components:4};case Ue:case De:case Ne:return{byteLength:4,components:1};case ze:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${e}.`)}(r);switch(n){case Ge:case je:return e*t;case Xe:return e*t*2;case Ke:case qe:return e*t/i.components*i.byteLength;case Qe:case Ze:return e*t*2/i.components*i.byteLength;case Ve:return e*t*3/i.components*i.byteLength;case We:case et:return e*t*4/i.components*i.byteLength;case tt:case nt:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*8;case rt:case it:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*16;case at:case lt:return Math.max(e,16)*Math.max(t,8)/4;case st:case ot:return Math.max(e,8)*Math.max(t,8)/2;case ut:case ct:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*8;case ht:case dt:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*16;case pt:return Math.floor((e+4)/5)*Math.floor((t+3)/4)*16;case ft:return Math.floor((e+4)/5)*Math.floor((t+4)/5)*16;case mt:return Math.floor((e+5)/6)*Math.floor((t+4)/5)*16;case gt:return Math.floor((e+5)/6)*Math.floor((t+5)/6)*16;case vt:return Math.floor((e+7)/8)*Math.floor((t+4)/5)*16;case yt:return Math.floor((e+7)/8)*Math.floor((t+5)/6)*16;case _t:return Math.floor((e+7)/8)*Math.floor((t+7)/8)*16;case xt:return Math.floor((e+9)/10)*Math.floor((t+4)/5)*16;case At:return Math.floor((e+9)/10)*Math.floor((t+5)/6)*16;case Mt:return Math.floor((e+9)/10)*Math.floor((t+7)/8)*16;case bt:return Math.floor((e+9)/10)*Math.floor((t+9)/10)*16;case St:return Math.floor((e+11)/12)*Math.floor((t+9)/10)*16;case wt:return Math.floor((e+11)/12)*Math.floor((t+11)/12)*16;case Et:case Tt:case Ct:return Math.ceil(e/4)*Math.ceil(t/4)*16;case Rt:case Pt:return Math.ceil(e/4)*Math.ceil(t/4)*8;case It:case Bt:return Math.ceil(e/4)*Math.ceil(t/4)*16}throw new Error(`Unable to determine texture byte length for ${n} format.`)}const Ql={contain:function(e,t){const n=e.image&&e.image.width?e.image.width/e.image.height:1;return n>t?(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},cover:function(e,t){const 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},fill:function(e){return e.repeat.x=1,e.repeat.y=1,e.offset.x=0,e.offset.y=0,e},getByteLength:ql};function Zl(e,t,n,r,i,s,a){const o=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):null,l="undefined"!==typeof navigator&&/OculusBrowser/g.test(navigator.userAgent),u=new ir,c=new WeakMap;let h;const d=new WeakMap;let p=!1;try{p="undefined"!==typeof OffscreenCanvas&&null!==new OffscreenCanvas(1,1).getContext("2d")}catch(z){}function f(e,t){return p?new OffscreenCanvas(e,t):cr("canvas")}function m(e,t,n){let r=1;const i=H(e);if((i.width>n||i.height>n)&&(r=n/Math.max(i.width,i.height)),r<1){if("undefined"!==typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!==typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!==typeof ImageBitmap&&e instanceof ImageBitmap||"undefined"!==typeof VideoFrame&&e instanceof VideoFrame){const n=Math.floor(r*i.width),s=Math.floor(r*i.height);void 0===h&&(h=f(n,s));const a=t?f(n,s):h;a.width=n,a.height=s;return a.getContext("2d").drawImage(e,0,0,n,s),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+i.width+"x"+i.height+") to ("+n+"x"+s+")."),a}return"data"in e&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+i.width+"x"+i.height+")."),e}return e}function g(e){return e.generateMipmaps&&e.minFilter!==xe&&e.minFilter!==we}function v(t){e.generateMipmap(t)}function y(n,r,i,s){let a=arguments.length>4&&void 0!==arguments[4]&&arguments[4];if(null!==n){if(void 0!==e[n])return e[n];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+n+"'")}let o=r;if(r===e.RED&&(i===e.FLOAT&&(o=e.R32F),i===e.HALF_FLOAT&&(o=e.R16F),i===e.UNSIGNED_BYTE&&(o=e.R8)),r===e.RED_INTEGER&&(i===e.UNSIGNED_BYTE&&(o=e.R8UI),i===e.UNSIGNED_SHORT&&(o=e.R16UI),i===e.UNSIGNED_INT&&(o=e.R32UI),i===e.BYTE&&(o=e.R8I),i===e.SHORT&&(o=e.R16I),i===e.INT&&(o=e.R32I)),r===e.RG&&(i===e.FLOAT&&(o=e.RG32F),i===e.HALF_FLOAT&&(o=e.RG16F),i===e.UNSIGNED_BYTE&&(o=e.RG8)),r===e.RG_INTEGER&&(i===e.UNSIGNED_BYTE&&(o=e.RG8UI),i===e.UNSIGNED_SHORT&&(o=e.RG16UI),i===e.UNSIGNED_INT&&(o=e.RG32UI),i===e.BYTE&&(o=e.RG8I),i===e.SHORT&&(o=e.RG16I),i===e.INT&&(o=e.RG32I)),r===e.RGB&&i===e.UNSIGNED_INT_5_9_9_9_REV&&(o=e.RGB9_E5),r===e.RGBA){const t=a?sn:yr.getTransfer(s);i===e.FLOAT&&(o=e.RGBA32F),i===e.HALF_FLOAT&&(o=e.RGBA16F),i===e.UNSIGNED_BYTE&&(o=t===an?e.SRGB8_ALPHA8:e.RGBA8),i===e.UNSIGNED_SHORT_4_4_4_4&&(o=e.RGBA4),i===e.UNSIGNED_SHORT_5_5_5_1&&(o=e.RGB5_A1)}return o!==e.R16F&&o!==e.R32F&&o!==e.RG16F&&o!==e.RG32F&&o!==e.RGBA16F&&o!==e.RGBA32F||t.get("EXT_color_buffer_float"),o}function _(t,n){let r;return t?null===n||n===Ue||n===He?r=e.DEPTH24_STENCIL8:n===Ne?r=e.DEPTH32F_STENCIL8:n===Le&&(r=e.DEPTH24_STENCIL8,console.warn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):null===n||n===Ue||n===He?r=e.DEPTH_COMPONENT24:n===Ne?r=e.DEPTH_COMPONENT32F:n===Le&&(r=e.DEPTH_COMPONENT16),r}function x(e,t){return!0===g(e)||e.isFramebufferTexture&&e.minFilter!==xe&&e.minFilter!==we?Math.log2(Math.max(t.width,t.height))+1:void 0!==e.mipmaps&&e.mipmaps.length>0?e.mipmaps.length:e.isCompressedTexture&&Array.isArray(e.image)?t.mipmaps.length:1}function A(e){const t=e.target;t.removeEventListener("dispose",A),function(e){const t=r.get(e);if(void 0===t.__webglInit)return;const n=e.source,i=d.get(n);if(i){const r=i[t.__cacheKey];r.usedTimes--,0===r.usedTimes&&b(e),0===Object.keys(i).length&&d.delete(n)}r.remove(e)}(t),t.isVideoTexture&&c.delete(t)}function M(t){const n=t.target;n.removeEventListener("dispose",M),function(t){const n=r.get(t);t.depthTexture&&t.depthTexture.dispose();if(t.isWebGLCubeRenderTarget)for(let r=0;r<6;r++){if(Array.isArray(n.__webglFramebuffer[r]))for(let t=0;t<n.__webglFramebuffer[r].length;t++)e.deleteFramebuffer(n.__webglFramebuffer[r][t]);else e.deleteFramebuffer(n.__webglFramebuffer[r]);n.__webglDepthbuffer&&e.deleteRenderbuffer(n.__webglDepthbuffer[r])}else{if(Array.isArray(n.__webglFramebuffer))for(let t=0;t<n.__webglFramebuffer.length;t++)e.deleteFramebuffer(n.__webglFramebuffer[t]);else e.deleteFramebuffer(n.__webglFramebuffer);if(n.__webglDepthbuffer&&e.deleteRenderbuffer(n.__webglDepthbuffer),n.__webglMultisampledFramebuffer&&e.deleteFramebuffer(n.__webglMultisampledFramebuffer),n.__webglColorRenderbuffer)for(let t=0;t<n.__webglColorRenderbuffer.length;t++)n.__webglColorRenderbuffer[t]&&e.deleteRenderbuffer(n.__webglColorRenderbuffer[t]);n.__webglDepthRenderbuffer&&e.deleteRenderbuffer(n.__webglDepthRenderbuffer)}const i=t.textures;for(let s=0,o=i.length;s<o;s++){const t=r.get(i[s]);t.__webglTexture&&(e.deleteTexture(t.__webglTexture),a.memory.textures--),r.remove(i[s])}r.remove(t)}(n)}function b(t){const n=r.get(t);e.deleteTexture(n.__webglTexture);const i=t.source;delete d.get(i)[n.__cacheKey],a.memory.textures--}let S=0;function w(t,i){const s=r.get(t);if(t.isVideoTexture&&function(e){const t=a.render.frame;c.get(e)!==t&&(c.set(e,t),e.update())}(t),!1===t.isRenderTargetTexture&&t.version>0&&s.__version!==t.version){const e=t.image;if(null===e)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else{if(!1!==e.complete)return void I(s,t,i);console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete")}}n.bindTexture(e.TEXTURE_2D,s.__webglTexture,e.TEXTURE0+i)}const E={[ve]:e.REPEAT,[ye]:e.CLAMP_TO_EDGE,[_e]:e.MIRRORED_REPEAT},T={[xe]:e.NEAREST,[Ae]:e.NEAREST_MIPMAP_NEAREST,[be]:e.NEAREST_MIPMAP_LINEAR,[we]:e.LINEAR,[Ee]:e.LINEAR_MIPMAP_NEAREST,[Ce]:e.LINEAR_MIPMAP_LINEAR},C={[wn]:e.NEVER,[Bn]:e.ALWAYS,[En]:e.LESS,[Cn]:e.LEQUAL,[Tn]:e.EQUAL,[In]:e.GEQUAL,[Rn]:e.GREATER,[Pn]:e.NOTEQUAL};function R(n,s){if(s.type!==Ne||!1!==t.has("OES_texture_float_linear")||s.magFilter!==we&&s.magFilter!==Ee&&s.magFilter!==be&&s.magFilter!==Ce&&s.minFilter!==we&&s.minFilter!==Ee&&s.minFilter!==be&&s.minFilter!==Ce||console.warn("THREE.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,E[s.wrapS]),e.texParameteri(n,e.TEXTURE_WRAP_T,E[s.wrapT]),n!==e.TEXTURE_3D&&n!==e.TEXTURE_2D_ARRAY||e.texParameteri(n,e.TEXTURE_WRAP_R,E[s.wrapR]),e.texParameteri(n,e.TEXTURE_MAG_FILTER,T[s.magFilter]),e.texParameteri(n,e.TEXTURE_MIN_FILTER,T[s.minFilter]),s.compareFunction&&(e.texParameteri(n,e.TEXTURE_COMPARE_MODE,e.COMPARE_REF_TO_TEXTURE),e.texParameteri(n,e.TEXTURE_COMPARE_FUNC,C[s.compareFunction])),!0===t.has("EXT_texture_filter_anisotropic")){if(s.magFilter===xe)return;if(s.minFilter!==be&&s.minFilter!==Ce)return;if(s.type===Ne&&!1===t.has("OES_texture_float_linear"))return;if(s.anisotropy>1||r.get(s).__currentAnisotropy){const a=t.get("EXT_texture_filter_anisotropic");e.texParameterf(n,a.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(s.anisotropy,i.getMaxAnisotropy())),r.get(s).__currentAnisotropy=s.anisotropy}}}function P(t,n){let r=!1;void 0===t.__webglInit&&(t.__webglInit=!0,n.addEventListener("dispose",A));const i=n.source;let s=d.get(i);void 0===s&&(s={},d.set(i,s));const o=function(e){const 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()}(n);if(o!==t.__cacheKey){void 0===s[o]&&(s[o]={texture:e.createTexture(),usedTimes:0},a.memory.textures++,r=!0),s[o].usedTimes++;const i=s[t.__cacheKey];void 0!==i&&(s[t.__cacheKey].usedTimes--,0===i.usedTimes&&b(n)),t.__cacheKey=o,t.__webglTexture=s[o].texture}return r}function I(t,a,o){let l=e.TEXTURE_2D;(a.isDataArrayTexture||a.isCompressedArrayTexture)&&(l=e.TEXTURE_2D_ARRAY),a.isData3DTexture&&(l=e.TEXTURE_3D);const u=P(t,a),c=a.source;n.bindTexture(l,t.__webglTexture,e.TEXTURE0+o);const h=r.get(c);if(c.version!==h.__version||!0===u){n.activeTexture(e.TEXTURE0+o);const t=yr.getPrimaries(yr.workingColorSpace),r=a.colorSpace===$t?null:yr.getPrimaries(a.colorSpace),d=a.colorSpace===$t||t===r?e.NONE:e.BROWSER_DEFAULT_WEBGL;e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,a.flipY),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,a.premultiplyAlpha),e.pixelStorei(e.UNPACK_ALIGNMENT,a.unpackAlignment),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,d);let p=m(a.image,!1,i.maxTextureSize);p=k(a,p);const f=s.convert(a.format,a.colorSpace),A=s.convert(a.type);let M,b=y(a.internalFormat,f,A,a.colorSpace,a.isVideoTexture);R(l,a);const S=a.mipmaps,w=!0!==a.isVideoTexture,E=void 0===h.__version||!0===u,T=c.dataReady,C=x(a,p);if(a.isDepthTexture)b=_(a.format===Ye,a.type),E&&(w?n.texStorage2D(e.TEXTURE_2D,1,b,p.width,p.height):n.texImage2D(e.TEXTURE_2D,0,b,p.width,p.height,0,f,A,null));else if(a.isDataTexture)if(S.length>0){w&&E&&n.texStorage2D(e.TEXTURE_2D,C,b,S[0].width,S[0].height);for(let t=0,r=S.length;t<r;t++)M=S[t],w?T&&n.texSubImage2D(e.TEXTURE_2D,t,0,0,M.width,M.height,f,A,M.data):n.texImage2D(e.TEXTURE_2D,t,b,M.width,M.height,0,f,A,M.data);a.generateMipmaps=!1}else w?(E&&n.texStorage2D(e.TEXTURE_2D,C,b,p.width,p.height),T&&n.texSubImage2D(e.TEXTURE_2D,0,0,0,p.width,p.height,f,A,p.data)):n.texImage2D(e.TEXTURE_2D,0,b,p.width,p.height,0,f,A,p.data);else if(a.isCompressedTexture)if(a.isCompressedArrayTexture){w&&E&&n.texStorage3D(e.TEXTURE_2D_ARRAY,C,b,S[0].width,S[0].height,p.depth);for(let t=0,r=S.length;t<r;t++)if(M=S[t],a.format!==We)if(null!==f)if(w){if(T)if(a.layerUpdates.size>0){const r=ql(M.width,M.height,a.format,a.type);for(const i of a.layerUpdates){const s=M.data.subarray(i*r/M.data.BYTES_PER_ELEMENT,(i+1)*r/M.data.BYTES_PER_ELEMENT);n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,t,0,0,i,M.width,M.height,1,f,s,0,0)}a.clearLayerUpdates()}else n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,t,0,0,0,M.width,M.height,p.depth,f,M.data,0,0)}else n.compressedTexImage3D(e.TEXTURE_2D_ARRAY,t,b,M.width,M.height,p.depth,0,M.data,0,0);else console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else w?T&&n.texSubImage3D(e.TEXTURE_2D_ARRAY,t,0,0,0,M.width,M.height,p.depth,f,A,M.data):n.texImage3D(e.TEXTURE_2D_ARRAY,t,b,M.width,M.height,p.depth,0,f,A,M.data)}else{w&&E&&n.texStorage2D(e.TEXTURE_2D,C,b,S[0].width,S[0].height);for(let t=0,r=S.length;t<r;t++)M=S[t],a.format!==We?null!==f?w?T&&n.compressedTexSubImage2D(e.TEXTURE_2D,t,0,0,M.width,M.height,f,M.data):n.compressedTexImage2D(e.TEXTURE_2D,t,b,M.width,M.height,0,M.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):w?T&&n.texSubImage2D(e.TEXTURE_2D,t,0,0,M.width,M.height,f,A,M.data):n.texImage2D(e.TEXTURE_2D,t,b,M.width,M.height,0,f,A,M.data)}else if(a.isDataArrayTexture)if(w){if(E&&n.texStorage3D(e.TEXTURE_2D_ARRAY,C,b,p.width,p.height,p.depth),T)if(a.layerUpdates.size>0){const t=ql(p.width,p.height,a.format,a.type);for(const r of a.layerUpdates){const i=p.data.subarray(r*t/p.data.BYTES_PER_ELEMENT,(r+1)*t/p.data.BYTES_PER_ELEMENT);n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,r,p.width,p.height,1,f,A,i)}a.clearLayerUpdates()}else n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,0,p.width,p.height,p.depth,f,A,p.data)}else n.texImage3D(e.TEXTURE_2D_ARRAY,0,b,p.width,p.height,p.depth,0,f,A,p.data);else if(a.isData3DTexture)w?(E&&n.texStorage3D(e.TEXTURE_3D,C,b,p.width,p.height,p.depth),T&&n.texSubImage3D(e.TEXTURE_3D,0,0,0,0,p.width,p.height,p.depth,f,A,p.data)):n.texImage3D(e.TEXTURE_3D,0,b,p.width,p.height,p.depth,0,f,A,p.data);else if(a.isFramebufferTexture){if(E)if(w)n.texStorage2D(e.TEXTURE_2D,C,b,p.width,p.height);else{let t=p.width,r=p.height;for(let i=0;i<C;i++)n.texImage2D(e.TEXTURE_2D,i,b,t,r,0,f,A,null),t>>=1,r>>=1}}else if(S.length>0){if(w&&E){const t=H(S[0]);n.texStorage2D(e.TEXTURE_2D,C,b,t.width,t.height)}for(let t=0,r=S.length;t<r;t++)M=S[t],w?T&&n.texSubImage2D(e.TEXTURE_2D,t,0,0,f,A,M):n.texImage2D(e.TEXTURE_2D,t,b,f,A,M);a.generateMipmaps=!1}else if(w){if(E){const t=H(p);n.texStorage2D(e.TEXTURE_2D,C,b,t.width,t.height)}T&&n.texSubImage2D(e.TEXTURE_2D,0,0,0,f,A,p)}else n.texImage2D(e.TEXTURE_2D,0,b,f,A,p);g(a)&&v(l),h.__version=c.version,a.onUpdate&&a.onUpdate(a)}t.__version=a.version}function B(t,i,a,l,u,c){const h=s.convert(a.format,a.colorSpace),d=s.convert(a.type),p=y(a.internalFormat,h,d,a.colorSpace);if(!r.get(i).__hasExternalTextures){const t=Math.max(1,i.width>>c),r=Math.max(1,i.height>>c);u===e.TEXTURE_3D||u===e.TEXTURE_2D_ARRAY?n.texImage3D(u,c,p,t,r,i.depth,0,h,d,null):n.texImage2D(u,c,p,t,r,0,h,d,null)}n.bindFramebuffer(e.FRAMEBUFFER,t),O(i)?o.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,l,u,r.get(a).__webglTexture,0,F(i)):(u===e.TEXTURE_2D||u>=e.TEXTURE_CUBE_MAP_POSITIVE_X&&u<=e.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&e.framebufferTexture2D(e.FRAMEBUFFER,l,u,r.get(a).__webglTexture,c),n.bindFramebuffer(e.FRAMEBUFFER,null)}function L(t,n,r){if(e.bindRenderbuffer(e.RENDERBUFFER,t),n.depthBuffer){const i=n.depthTexture,s=i&&i.isDepthTexture?i.type:null,a=_(n.stencilBuffer,s),l=n.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,u=F(n);O(n)?o.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,u,a,n.width,n.height):r?e.renderbufferStorageMultisample(e.RENDERBUFFER,u,a,n.width,n.height):e.renderbufferStorage(e.RENDERBUFFER,a,n.width,n.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,l,e.RENDERBUFFER,t)}else{const t=n.textures;for(let i=0;i<t.length;i++){const a=t[i],l=s.convert(a.format,a.colorSpace),u=s.convert(a.type),c=y(a.internalFormat,l,u,a.colorSpace),h=F(n);r&&!1===O(n)?e.renderbufferStorageMultisample(e.RENDERBUFFER,h,c,n.width,n.height):O(n)?o.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,h,c,n.width,n.height):e.renderbufferStorage(e.RENDERBUFFER,c,n.width,n.height)}}e.bindRenderbuffer(e.RENDERBUFFER,null)}function D(t){const i=r.get(t),s=!0===t.isWebGLCubeRenderTarget;if(t.depthTexture&&!i.__autoAllocateDepthBuffer){if(s)throw new Error("target.depthTexture not supported in Cube render targets");!function(t,i){if(i&&i.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(n.bindFramebuffer(e.FRAMEBUFFER,t),!i.depthTexture||!i.depthTexture.isDepthTexture)throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");r.get(i.depthTexture).__webglTexture&&i.depthTexture.image.width===i.width&&i.depthTexture.image.height===i.height||(i.depthTexture.image.width=i.width,i.depthTexture.image.height=i.height,i.depthTexture.needsUpdate=!0),w(i.depthTexture,0);const s=r.get(i.depthTexture).__webglTexture,a=F(i);if(i.depthTexture.format===Je)O(i)?o.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.TEXTURE_2D,s,0,a):e.framebufferTexture2D(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.TEXTURE_2D,s,0);else{if(i.depthTexture.format!==Ye)throw new Error("Unknown depthTexture format");O(i)?o.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.TEXTURE_2D,s,0,a):e.framebufferTexture2D(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.TEXTURE_2D,s,0)}}(i.__webglFramebuffer,t)}else if(s){i.__webglDepthbuffer=[];for(let r=0;r<6;r++)n.bindFramebuffer(e.FRAMEBUFFER,i.__webglFramebuffer[r]),i.__webglDepthbuffer[r]=e.createRenderbuffer(),L(i.__webglDepthbuffer[r],t,!1)}else n.bindFramebuffer(e.FRAMEBUFFER,i.__webglFramebuffer),i.__webglDepthbuffer=e.createRenderbuffer(),L(i.__webglDepthbuffer,t,!1);n.bindFramebuffer(e.FRAMEBUFFER,null)}const U=[],N=[];function F(e){return Math.min(i.maxSamples,e.samples)}function O(e){const n=r.get(e);return e.samples>0&&!0===t.has("WEBGL_multisampled_render_to_texture")&&!1!==n.__useRenderToTexture}function k(e,t){const n=e.colorSpace,r=e.format,i=e.type;return!0===e.isCompressedTexture||!0===e.isVideoTexture||n!==tn&&n!==$t&&(yr.getTransfer(n)===an?r===We&&i===Pe||console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",n)),t}function H(e){return"undefined"!==typeof HTMLImageElement&&e instanceof HTMLImageElement?(u.width=e.naturalWidth||e.width,u.height=e.naturalHeight||e.height):"undefined"!==typeof VideoFrame&&e instanceof VideoFrame?(u.width=e.displayWidth,u.height=e.displayHeight):(u.width=e.width,u.height=e.height),u}this.allocateTextureUnit=function(){const e=S;return e>=i.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+e+" texture units while this GPU supports only "+i.maxTextures),S+=1,e},this.resetTextureUnits=function(){S=0},this.setTexture2D=w,this.setTexture2DArray=function(t,i){const s=r.get(t);t.version>0&&s.__version!==t.version?I(s,t,i):n.bindTexture(e.TEXTURE_2D_ARRAY,s.__webglTexture,e.TEXTURE0+i)},this.setTexture3D=function(t,i){const s=r.get(t);t.version>0&&s.__version!==t.version?I(s,t,i):n.bindTexture(e.TEXTURE_3D,s.__webglTexture,e.TEXTURE0+i)},this.setTextureCube=function(t,a){const o=r.get(t);t.version>0&&o.__version!==t.version?function(t,a,o){if(6!==a.image.length)return;const l=P(t,a),u=a.source;n.bindTexture(e.TEXTURE_CUBE_MAP,t.__webglTexture,e.TEXTURE0+o);const c=r.get(u);if(u.version!==c.__version||!0===l){n.activeTexture(e.TEXTURE0+o);const t=yr.getPrimaries(yr.workingColorSpace),r=a.colorSpace===$t?null:yr.getPrimaries(a.colorSpace),h=a.colorSpace===$t||t===r?e.NONE:e.BROWSER_DEFAULT_WEBGL;e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,a.flipY),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,a.premultiplyAlpha),e.pixelStorei(e.UNPACK_ALIGNMENT,a.unpackAlignment),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,h);const d=a.isCompressedTexture||a.image[0].isCompressedTexture,p=a.image[0]&&a.image[0].isDataTexture,f=[];for(let e=0;e<6;e++)f[e]=d||p?p?a.image[e].image:a.image[e]:m(a.image[e],!0,i.maxCubemapSize),f[e]=k(a,f[e]);const _=f[0],A=s.convert(a.format,a.colorSpace),M=s.convert(a.type),b=y(a.internalFormat,A,M,a.colorSpace),S=!0!==a.isVideoTexture,w=void 0===c.__version||!0===l,E=u.dataReady;let T,C=x(a,_);if(R(e.TEXTURE_CUBE_MAP,a),d){S&&w&&n.texStorage2D(e.TEXTURE_CUBE_MAP,C,b,_.width,_.height);for(let t=0;t<6;t++){T=f[t].mipmaps;for(let r=0;r<T.length;r++){const i=T[r];a.format!==We?null!==A?S?E&&n.compressedTexSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,r,0,0,i.width,i.height,A,i.data):n.compressedTexImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,r,b,i.width,i.height,0,i.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):S?E&&n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,r,0,0,i.width,i.height,A,M,i.data):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,r,b,i.width,i.height,0,A,M,i.data)}}}else{if(T=a.mipmaps,S&&w){T.length>0&&C++;const t=H(f[0]);n.texStorage2D(e.TEXTURE_CUBE_MAP,C,b,t.width,t.height)}for(let t=0;t<6;t++)if(p){S?E&&n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,0,0,f[t].width,f[t].height,A,M,f[t].data):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,b,f[t].width,f[t].height,0,A,M,f[t].data);for(let r=0;r<T.length;r++){const i=T[r].image[t].image;S?E&&n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,r+1,0,0,i.width,i.height,A,M,i.data):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,r+1,b,i.width,i.height,0,A,M,i.data)}}else{S?E&&n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,0,0,A,M,f[t]):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,b,A,M,f[t]);for(let r=0;r<T.length;r++){const i=T[r];S?E&&n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,r+1,0,0,A,M,i.image[t]):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,r+1,b,A,M,i.image[t])}}}g(a)&&v(e.TEXTURE_CUBE_MAP),c.__version=u.version,a.onUpdate&&a.onUpdate(a)}t.__version=a.version}(o,t,a):n.bindTexture(e.TEXTURE_CUBE_MAP,o.__webglTexture,e.TEXTURE0+a)},this.rebindTextures=function(t,n,i){const s=r.get(t);void 0!==n&&B(s.__webglFramebuffer,t,t.texture,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,0),void 0!==i&&D(t)},this.setupRenderTarget=function(t){const i=t.texture,o=r.get(t),l=r.get(i);t.addEventListener("dispose",M);const u=t.textures,c=!0===t.isWebGLCubeRenderTarget,h=u.length>1;if(h||(void 0===l.__webglTexture&&(l.__webglTexture=e.createTexture()),l.__version=i.version,a.memory.textures++),c){o.__webglFramebuffer=[];for(let t=0;t<6;t++)if(i.mipmaps&&i.mipmaps.length>0){o.__webglFramebuffer[t]=[];for(let n=0;n<i.mipmaps.length;n++)o.__webglFramebuffer[t][n]=e.createFramebuffer()}else o.__webglFramebuffer[t]=e.createFramebuffer()}else{if(i.mipmaps&&i.mipmaps.length>0){o.__webglFramebuffer=[];for(let t=0;t<i.mipmaps.length;t++)o.__webglFramebuffer[t]=e.createFramebuffer()}else o.__webglFramebuffer=e.createFramebuffer();if(h)for(let t=0,n=u.length;t<n;t++){const n=r.get(u[t]);void 0===n.__webglTexture&&(n.__webglTexture=e.createTexture(),a.memory.textures++)}if(t.samples>0&&!1===O(t)){o.__webglMultisampledFramebuffer=e.createFramebuffer(),o.__webglColorRenderbuffer=[],n.bindFramebuffer(e.FRAMEBUFFER,o.__webglMultisampledFramebuffer);for(let n=0;n<u.length;n++){const r=u[n];o.__webglColorRenderbuffer[n]=e.createRenderbuffer(),e.bindRenderbuffer(e.RENDERBUFFER,o.__webglColorRenderbuffer[n]);const i=s.convert(r.format,r.colorSpace),a=s.convert(r.type),l=y(r.internalFormat,i,a,r.colorSpace,!0===t.isXRRenderTarget),c=F(t);e.renderbufferStorageMultisample(e.RENDERBUFFER,c,l,t.width,t.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+n,e.RENDERBUFFER,o.__webglColorRenderbuffer[n])}e.bindRenderbuffer(e.RENDERBUFFER,null),t.depthBuffer&&(o.__webglDepthRenderbuffer=e.createRenderbuffer(),L(o.__webglDepthRenderbuffer,t,!0)),n.bindFramebuffer(e.FRAMEBUFFER,null)}}if(c){n.bindTexture(e.TEXTURE_CUBE_MAP,l.__webglTexture),R(e.TEXTURE_CUBE_MAP,i);for(let n=0;n<6;n++)if(i.mipmaps&&i.mipmaps.length>0)for(let r=0;r<i.mipmaps.length;r++)B(o.__webglFramebuffer[n][r],t,i,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+n,r);else B(o.__webglFramebuffer[n],t,i,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+n,0);g(i)&&v(e.TEXTURE_CUBE_MAP),n.unbindTexture()}else if(h){for(let i=0,s=u.length;i<s;i++){const s=u[i],a=r.get(s);n.bindTexture(e.TEXTURE_2D,a.__webglTexture),R(e.TEXTURE_2D,s),B(o.__webglFramebuffer,t,s,e.COLOR_ATTACHMENT0+i,e.TEXTURE_2D,0),g(s)&&v(e.TEXTURE_2D)}n.unbindTexture()}else{let r=e.TEXTURE_2D;if((t.isWebGL3DRenderTarget||t.isWebGLArrayRenderTarget)&&(r=t.isWebGL3DRenderTarget?e.TEXTURE_3D:e.TEXTURE_2D_ARRAY),n.bindTexture(r,l.__webglTexture),R(r,i),i.mipmaps&&i.mipmaps.length>0)for(let n=0;n<i.mipmaps.length;n++)B(o.__webglFramebuffer[n],t,i,e.COLOR_ATTACHMENT0,r,n);else B(o.__webglFramebuffer,t,i,e.COLOR_ATTACHMENT0,r,0);g(i)&&v(r),n.unbindTexture()}t.depthBuffer&&D(t)},this.updateRenderTargetMipmap=function(t){const i=t.textures;for(let s=0,a=i.length;s<a;s++){const a=i[s];if(g(a)){const i=t.isWebGLCubeRenderTarget?e.TEXTURE_CUBE_MAP:e.TEXTURE_2D,s=r.get(a).__webglTexture;n.bindTexture(i,s),v(i),n.unbindTexture()}}},this.updateMultisampleRenderTarget=function(t){if(t.samples>0)if(!1===O(t)){const i=t.textures,s=t.width,a=t.height;let o=e.COLOR_BUFFER_BIT;const u=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,c=r.get(t),h=i.length>1;if(h)for(let t=0;t<i.length;t++)n.bindFramebuffer(e.FRAMEBUFFER,c.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+t,e.RENDERBUFFER,null),n.bindFramebuffer(e.FRAMEBUFFER,c.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+t,e.TEXTURE_2D,null,0);n.bindFramebuffer(e.READ_FRAMEBUFFER,c.__webglMultisampledFramebuffer),n.bindFramebuffer(e.DRAW_FRAMEBUFFER,c.__webglFramebuffer);for(let n=0;n<i.length;n++){if(t.resolveDepthBuffer&&(t.depthBuffer&&(o|=e.DEPTH_BUFFER_BIT),t.stencilBuffer&&t.resolveStencilBuffer&&(o|=e.STENCIL_BUFFER_BIT)),h){e.framebufferRenderbuffer(e.READ_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.RENDERBUFFER,c.__webglColorRenderbuffer[n]);const t=r.get(i[n]).__webglTexture;e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,t,0)}e.blitFramebuffer(0,0,s,a,0,0,s,a,o,e.NEAREST),!0===l&&(U.length=0,N.length=0,U.push(e.COLOR_ATTACHMENT0+n),t.depthBuffer&&!1===t.resolveDepthBuffer&&(U.push(u),N.push(u),e.invalidateFramebuffer(e.DRAW_FRAMEBUFFER,N)),e.invalidateFramebuffer(e.READ_FRAMEBUFFER,U))}if(n.bindFramebuffer(e.READ_FRAMEBUFFER,null),n.bindFramebuffer(e.DRAW_FRAMEBUFFER,null),h)for(let t=0;t<i.length;t++){n.bindFramebuffer(e.FRAMEBUFFER,c.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+t,e.RENDERBUFFER,c.__webglColorRenderbuffer[t]);const s=r.get(i[t]).__webglTexture;n.bindFramebuffer(e.FRAMEBUFFER,c.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+t,e.TEXTURE_2D,s,0)}n.bindFramebuffer(e.DRAW_FRAMEBUFFER,c.__webglMultisampledFramebuffer)}else if(t.depthBuffer&&!1===t.resolveDepthBuffer&&l){const n=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;e.invalidateFramebuffer(e.DRAW_FRAMEBUFFER,[n])}},this.setupDepthRenderbuffer=D,this.setupFrameBufferTexture=B,this.useMultisampledRTT=O}function $l(e,t){return{convert:function(n){let r,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:$t;const s=yr.getTransfer(i);if(n===Pe)return e.UNSIGNED_BYTE;if(n===Oe)return e.UNSIGNED_SHORT_4_4_4_4;if(n===ke)return e.UNSIGNED_SHORT_5_5_5_1;if(n===ze)return e.UNSIGNED_INT_5_9_9_9_REV;if(n===Ie)return e.BYTE;if(n===Be)return e.SHORT;if(n===Le)return e.UNSIGNED_SHORT;if(n===De)return e.INT;if(n===Ue)return e.UNSIGNED_INT;if(n===Ne)return e.FLOAT;if(n===Fe)return e.HALF_FLOAT;if(n===Ge)return e.ALPHA;if(n===Ve)return e.RGB;if(n===We)return e.RGBA;if(n===je)return e.LUMINANCE;if(n===Xe)return e.LUMINANCE_ALPHA;if(n===Je)return e.DEPTH_COMPONENT;if(n===Ye)return e.DEPTH_STENCIL;if(n===Ke)return e.RED;if(n===qe)return e.RED_INTEGER;if(n===Qe)return e.RG;if(n===Ze)return e.RG_INTEGER;if(n===et)return e.RGBA_INTEGER;if(n===tt||n===nt||n===rt||n===it)if(s===an){if(r=t.get("WEBGL_compressed_texture_s3tc_srgb"),null===r)return null;if(n===tt)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===nt)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===rt)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===it)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else{if(r=t.get("WEBGL_compressed_texture_s3tc"),null===r)return null;if(n===tt)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===nt)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===rt)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===it)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}if(n===st||n===at||n===ot||n===lt){if(r=t.get("WEBGL_compressed_texture_pvrtc"),null===r)return null;if(n===st)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===at)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===ot)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===lt)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(n===ut||n===ct||n===ht){if(r=t.get("WEBGL_compressed_texture_etc"),null===r)return null;if(n===ut||n===ct)return s===an?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(n===ht)return s===an?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC}if(n===dt||n===pt||n===ft||n===mt||n===gt||n===vt||n===yt||n===_t||n===xt||n===At||n===Mt||n===bt||n===St||n===wt){if(r=t.get("WEBGL_compressed_texture_astc"),null===r)return null;if(n===dt)return s===an?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===pt)return s===an?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===ft)return s===an?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===mt)return s===an?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===gt)return s===an?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===vt)return s===an?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===yt)return s===an?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===_t)return s===an?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===xt)return s===an?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===At)return s===an?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===Mt)return s===an?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===bt)return s===an?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===St)return s===an?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===wt)return s===an?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}if(n===Et||n===Tt||n===Ct){if(r=t.get("EXT_texture_compression_bptc"),null===r)return null;if(n===Et)return s===an?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===Tt)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===Ct)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}if(n===Rt||n===Pt||n===It||n===Bt){if(r=t.get("EXT_texture_compression_rgtc"),null===r)return null;if(n===Et)return r.COMPRESSED_RED_RGTC1_EXT;if(n===Pt)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===It)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===Bt)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}return n===He?e.UNSIGNED_INT_24_8:void 0!==e[n]?e[n]:null}}}class eu extends aa{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];super(),this.isArrayCamera=!0,this.cameras=e}}class tu extends ki{constructor(){super(),this.isGroup=!0,this.type="Group"}}const nu={type:"move"};class ru{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return null===this._hand&&(this._hand=new tu,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return null===this._targetRay&&(this._targetRay=new tu,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new Nr,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new Nr),this._targetRay}getGripSpace(){return null===this._grip&&(this._grip=new tu,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new Nr,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new Nr),this._grip}dispatchEvent(e){return null!==this._targetRay&&this._targetRay.dispatchEvent(e),null!==this._grip&&this._grip.dispatchEvent(e),null!==this._hand&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const t=this._hand;if(t)for(const n of e.hand.values())this._getHandJoint(t,n)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),null!==this._targetRay&&(this._targetRay.visible=!1),null!==this._grip&&(this._grip.visible=!1),null!==this._hand&&(this._hand.visible=!1),this}update(e,t,n){let r=null,i=null,s=null;const a=this._targetRay,o=this._grip,l=this._hand;if(e&&"visible-blurred"!==t.session.visibilityState){if(l&&e.hand){s=!0;for(const s of e.hand.values()){const e=t.getJointPose(s,n),r=this._getHandJoint(l,s);null!==e&&(r.matrix.fromArray(e.transform.matrix),r.matrix.decompose(r.position,r.rotation,r.scale),r.matrixWorldNeedsUpdate=!0,r.jointRadius=e.radius),r.visible=null!==e}const r=l.joints["index-finger-tip"],i=l.joints["thumb-tip"],a=r.position.distanceTo(i.position),o=.02,u=.005;l.inputState.pinching&&a>o+u?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&a<=o-u&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else null!==o&&e.gripSpace&&(i=t.getPose(e.gripSpace,n),null!==i&&(o.matrix.fromArray(i.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,i.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(i.linearVelocity)):o.hasLinearVelocity=!1,i.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(i.angularVelocity)):o.hasAngularVelocity=!1));null!==a&&(r=t.getPose(e.targetRaySpace,n),null===r&&null!==i&&(r=i),null!==r&&(a.matrix.fromArray(r.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,r.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(r.linearVelocity)):a.hasLinearVelocity=!1,r.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(r.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(nu)))}return null!==a&&(a.visible=null!==r),null!==o&&(o.visible=null!==i),null!==l&&(l.visible=null!==s),this}_getHandJoint(e,t){if(void 0===e.joints[t.jointName]){const n=new tu;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}class iu{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t,n){if(null===this.texture){const r=new Tr;e.properties.get(r).__webglTexture=t.texture,t.depthNear==n.depthNear&&t.depthFar==n.depthFar||(this.depthNear=t.depthNear,this.depthFar=t.depthFar),this.texture=r}}getMesh(e){if(null!==this.texture&&null===this.mesh){const t=e.cameras[0].viewport,n=new ta({vertexShader:"\nvoid main() {\n\n\tgl_Position = vec4( position, 1.0 );\n\n}",fragmentShader:"\nuniform sampler2DArray depthColor;\nuniform float depthWidth;\nuniform float depthHeight;\n\nvoid main() {\n\n\tvec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight );\n\n\tif ( coord.x >= 1.0 ) {\n\n\t\tgl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r;\n\n\t} else {\n\n\t\tgl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r;\n\n\t}\n\n}",uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new Ys(new xa(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class su extends Xn{constructor(e,t){super();const n=this;let r=null,i=1,s=null,a="local-floor",o=1,l=null,u=null,c=null,h=null,d=null,p=null;const f=new iu,m=t.getContextAttributes();let g=null,v=null;const y=[],_=[],x=new ir;let A=null;const M=new aa;M.layers.enable(1),M.viewport=new Cr;const b=new aa;b.layers.enable(2),b.viewport=new Cr;const S=[M,b],w=new eu;w.layers.enable(1),w.layers.enable(2);let E=null,T=null;function C(e){const t=_.indexOf(e.inputSource);if(-1===t)return;const n=y[t];void 0!==n&&(n.update(e.inputSource,e.frame,l||s),n.dispatchEvent({type:e.type,data:e.inputSource}))}function R(){r.removeEventListener("select",C),r.removeEventListener("selectstart",C),r.removeEventListener("selectend",C),r.removeEventListener("squeeze",C),r.removeEventListener("squeezestart",C),r.removeEventListener("squeezeend",C),r.removeEventListener("end",R),r.removeEventListener("inputsourceschange",P);for(let e=0;e<y.length;e++){const t=_[e];null!==t&&(_[e]=null,y[e].disconnect(t))}E=null,T=null,f.reset(),e.setRenderTarget(g),d=null,h=null,c=null,r=null,v=null,U.stop(),n.isPresenting=!1,e.setPixelRatio(A),e.setSize(x.width,x.height,!1),n.dispatchEvent({type:"sessionend"})}function P(e){for(let t=0;t<e.removed.length;t++){const n=e.removed[t],r=_.indexOf(n);r>=0&&(_[r]=null,y[r].disconnect(n))}for(let t=0;t<e.added.length;t++){const n=e.added[t];let r=_.indexOf(n);if(-1===r){for(let e=0;e<y.length;e++){if(e>=_.length){_.push(n),r=e;break}if(null===_[e]){_[e]=n,r=e;break}}if(-1===r)break}const i=y[r];i&&i.connect(n)}}this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(e){let t=y[e];return void 0===t&&(t=new ru,y[e]=t),t.getTargetRaySpace()},this.getControllerGrip=function(e){let t=y[e];return void 0===t&&(t=new ru,y[e]=t),t.getGripSpace()},this.getHand=function(e){let t=y[e];return void 0===t&&(t=new ru,y[e]=t),t.getHandSpace()},this.setFramebufferScaleFactor=function(e){i=e,!0===n.isPresenting&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(e){a=e,!0===n.isPresenting&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||s},this.setReferenceSpace=function(e){l=e},this.getBaseLayer=function(){return null!==h?h:d},this.getBinding=function(){return c},this.getFrame=function(){return p},this.getSession=function(){return r},this.setSession=async function(u){if(r=u,null!==r){if(g=e.getRenderTarget(),r.addEventListener("select",C),r.addEventListener("selectstart",C),r.addEventListener("selectend",C),r.addEventListener("squeeze",C),r.addEventListener("squeezestart",C),r.addEventListener("squeezeend",C),r.addEventListener("end",R),r.addEventListener("inputsourceschange",P),!0!==m.xrCompatible&&await t.makeXRCompatible(),A=e.getPixelRatio(),e.getSize(x),void 0===r.renderState.layers){const n={antialias:m.antialias,alpha:!0,depth:m.depth,stencil:m.stencil,framebufferScaleFactor:i};d=new XRWebGLLayer(r,t,n),r.updateRenderState({baseLayer:d}),e.setPixelRatio(1),e.setSize(d.framebufferWidth,d.framebufferHeight,!1),v=new Pr(d.framebufferWidth,d.framebufferHeight,{format:We,type:Pe,colorSpace:e.outputColorSpace,stencilBuffer:m.stencil})}else{let n=null,s=null,a=null;m.depth&&(a=m.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,n=m.stencil?Ye:Je,s=m.stencil?He:Ue);const o={colorFormat:t.RGBA8,depthFormat:a,scaleFactor:i};c=new XRWebGLBinding(r,t),h=c.createProjectionLayer(o),r.updateRenderState({layers:[h]}),e.setPixelRatio(1),e.setSize(h.textureWidth,h.textureHeight,!1),v=new Pr(h.textureWidth,h.textureHeight,{format:We,type:Pe,depthTexture:new io(h.textureWidth,h.textureHeight,s,void 0,void 0,void 0,void 0,void 0,void 0,n),stencilBuffer:m.stencil,colorSpace:e.outputColorSpace,samples:m.antialias?4:0,resolveDepthBuffer:!1===h.ignoreDepthValues})}v.isXRRenderTarget=!0,this.setFoveation(o),l=null,s=await r.requestReferenceSpace(a),U.setContext(r),U.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(null!==r)return r.environmentBlendMode},this.getDepthTexture=function(){return f.getDepthTexture()};const I=new Nr,B=new Nr;function L(e,t){null===t?e.matrixWorld.copy(e.matrix):e.matrixWorld.multiplyMatrices(t.matrixWorld,e.matrix),e.matrixWorldInverse.copy(e.matrixWorld).invert()}this.updateCamera=function(e){if(null===r)return;null!==f.texture&&(e.near=f.depthNear,e.far=f.depthFar),w.near=b.near=M.near=e.near,w.far=b.far=M.far=e.far,E===w.near&&T===w.far||(r.updateRenderState({depthNear:w.near,depthFar:w.far}),E=w.near,T=w.far,M.near=E,M.far=T,b.near=E,b.far=T,M.updateProjectionMatrix(),b.updateProjectionMatrix(),e.updateProjectionMatrix());const t=e.parent,n=w.cameras;L(w,t);for(let r=0;r<n.length;r++)L(n[r],t);2===n.length?function(e,t,n){I.setFromMatrixPosition(t.matrixWorld),B.setFromMatrixPosition(n.matrixWorld);const r=I.distanceTo(B),i=t.projectionMatrix.elements,s=n.projectionMatrix.elements,a=i[14]/(i[10]-1),o=i[14]/(i[10]+1),l=(i[9]+1)/i[5],u=(i[9]-1)/i[5],c=(i[8]-1)/i[0],h=(s[8]+1)/s[0],d=a*c,p=a*h,f=r/(-c+h),m=f*-c;t.matrixWorld.decompose(e.position,e.quaternion,e.scale),e.translateX(m),e.translateZ(f),e.matrixWorld.compose(e.position,e.quaternion,e.scale),e.matrixWorldInverse.copy(e.matrixWorld).invert();const g=a+f,v=o+f,y=d-m,_=p+(r-m),x=l*o/v*g,A=u*o/v*g;e.projectionMatrix.makePerspective(y,_,x,A,g,v),e.projectionMatrixInverse.copy(e.projectionMatrix).invert()}(w,M,b):w.projectionMatrix.copy(M.projectionMatrix),function(e,t,n){null===n?e.matrix.copy(t.matrixWorld):(e.matrix.copy(n.matrixWorld),e.matrix.invert(),e.matrix.multiply(t.matrixWorld));e.matrix.decompose(e.position,e.quaternion,e.scale),e.updateMatrixWorld(!0),e.projectionMatrix.copy(t.projectionMatrix),e.projectionMatrixInverse.copy(t.projectionMatrixInverse),e.isPerspectiveCamera&&(e.fov=2*qn*Math.atan(1/e.projectionMatrix.elements[5]),e.zoom=1)}(e,w,t)},this.getCamera=function(){return w},this.getFoveation=function(){if(null!==h||null!==d)return o},this.setFoveation=function(e){o=e,null!==h&&(h.fixedFoveation=e),null!==d&&void 0!==d.fixedFoveation&&(d.fixedFoveation=e)},this.hasDepthSensing=function(){return null!==f.texture},this.getDepthSensingMesh=function(){return f.getMesh(w)};let D=null;const U=new ya;U.setAnimationLoop((function(t,i){if(u=i.getViewerPose(l||s),p=i,null!==u){const t=u.views;null!==d&&(e.setRenderTargetFramebuffer(v,d.framebuffer),e.setRenderTarget(v));let n=!1;t.length!==w.cameras.length&&(w.cameras.length=0,n=!0);for(let r=0;r<t.length;r++){const i=t[r];let s=null;if(null!==d)s=d.getViewport(i);else{const t=c.getViewSubImage(h,i);s=t.viewport,0===r&&(e.setRenderTargetTextures(v,t.colorTexture,h.ignoreDepthValues?void 0:t.depthStencilTexture),e.setRenderTarget(v))}let a=S[r];void 0===a&&(a=new aa,a.layers.enable(r),a.viewport=new Cr,S[r]=a),a.matrix.fromArray(i.transform.matrix),a.matrix.decompose(a.position,a.quaternion,a.scale),a.projectionMatrix.fromArray(i.projectionMatrix),a.projectionMatrixInverse.copy(a.projectionMatrix).invert(),a.viewport.set(s.x,s.y,s.width,s.height),0===r&&(w.matrix.copy(a.matrix),w.matrix.decompose(w.position,w.quaternion,w.scale)),!0===n&&w.cameras.push(a)}const i=r.enabledFeatures;if(i&&i.includes("depth-sensing")){const n=c.getDepthInformation(t[0]);n&&n.isValid&&n.texture&&f.init(e,n,r.renderState)}}for(let e=0;e<y.length;e++){const t=_[e],n=y[e];null!==t&&void 0!==n&&n.update(t,i,l||s)}D&&D(t,i),i.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:i}),p=null})),this.setAnimationLoop=function(e){D=e},this.dispose=function(){}}}const au=new Mi,ou=new di;function lu(e,t){function n(e,t){!0===e.matrixAutoUpdate&&e.updateMatrix(),t.value.copy(e.matrix)}function r(e,r){e.opacity.value=r.opacity,r.color&&e.diffuse.value.copy(r.color),r.emissive&&e.emissive.value.copy(r.emissive).multiplyScalar(r.emissiveIntensity),r.map&&(e.map.value=r.map,n(r.map,e.mapTransform)),r.alphaMap&&(e.alphaMap.value=r.alphaMap,n(r.alphaMap,e.alphaMapTransform)),r.bumpMap&&(e.bumpMap.value=r.bumpMap,n(r.bumpMap,e.bumpMapTransform),e.bumpScale.value=r.bumpScale,r.side===g&&(e.bumpScale.value*=-1)),r.normalMap&&(e.normalMap.value=r.normalMap,n(r.normalMap,e.normalMapTransform),e.normalScale.value.copy(r.normalScale),r.side===g&&e.normalScale.value.negate()),r.displacementMap&&(e.displacementMap.value=r.displacementMap,n(r.displacementMap,e.displacementMapTransform),e.displacementScale.value=r.displacementScale,e.displacementBias.value=r.displacementBias),r.emissiveMap&&(e.emissiveMap.value=r.emissiveMap,n(r.emissiveMap,e.emissiveMapTransform)),r.specularMap&&(e.specularMap.value=r.specularMap,n(r.specularMap,e.specularMapTransform)),r.alphaTest>0&&(e.alphaTest.value=r.alphaTest);const i=t.get(r),s=i.envMap,a=i.envMapRotation;s&&(e.envMap.value=s,au.copy(a),au.x*=-1,au.y*=-1,au.z*=-1,s.isCubeTexture&&!1===s.isRenderTargetTexture&&(au.y*=-1,au.z*=-1),e.envMapRotation.value.setFromMatrix4(ou.makeRotationFromEuler(au)),e.flipEnvMap.value=s.isCubeTexture&&!1===s.isRenderTargetTexture?-1:1,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))}return{refreshFogUniforms:function(t,n){n.color.getRGB(t.fogColor.value,$s(e)),n.isFog?(t.fogNear.value=n.near,t.fogFar.value=n.far):n.isFogExp2&&(t.fogDensity.value=n.density)},refreshMaterialUniforms:function(e,i,s,a,o){i.isMeshBasicMaterial||i.isMeshLambertMaterial?r(e,i):i.isMeshToonMaterial?(r(e,i),function(e,t){t.gradientMap&&(e.gradientMap.value=t.gradientMap)}(e,i)):i.isMeshPhongMaterial?(r(e,i),function(e,t){e.specular.value.copy(t.specular),e.shininess.value=Math.max(t.shininess,1e-4)}(e,i)):i.isMeshStandardMaterial?(r(e,i),function(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)}(e,i),i.isMeshPhysicalMaterial&&function(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===g&&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))}(e,i,o)):i.isMeshMatcapMaterial?(r(e,i),function(e,t){t.matcap&&(e.matcap.value=t.matcap)}(e,i)):i.isMeshDepthMaterial?r(e,i):i.isMeshDistanceMaterial?(r(e,i),function(e,n){const 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}(e,i)):i.isMeshNormalMaterial?r(e,i):i.isLineBasicMaterial?(function(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))}(e,i),i.isLineDashedMaterial&&function(e,t){e.dashSize.value=t.dashSize,e.totalSize.value=t.dashSize+t.gapSize,e.scale.value=t.scale}(e,i)):i.isPointsMaterial?function(e,t,r,i){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.size.value=t.size*r,e.scale.value=.5*i,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)}(e,i,s,a):i.isSpriteMaterial?function(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)}(e,i):i.isShadowMaterial?(e.color.value.copy(i.color),e.opacity.value=i.opacity):i.isShaderMaterial&&(i.uniformsNeedUpdate=!1)}}}function uu(e,t,n,r){let i={},s={},a=[];const o=e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS);function l(e,t,n,r){const i=e.value,s=t+"_"+n;if(void 0===r[s])return r[s]="number"===typeof i||"boolean"===typeof i?i:i.clone(),!0;{const e=r[s];if("number"===typeof i||"boolean"===typeof i){if(e!==i)return r[s]=i,!0}else if(!1===e.equals(i))return e.copy(i),!0}return!1}function u(e){const t={boundary:0,storage:0};return"number"===typeof e||"boolean"===typeof e?(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?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",e),t}function c(t){const n=t.target;n.removeEventListener("dispose",c);const r=a.indexOf(n.__bindingPointIndex);a.splice(r,1),e.deleteBuffer(i[n.id]),delete i[n.id],delete s[n.id]}return{bind:function(e,t){const n=t.program;r.uniformBlockBinding(e,n)},update:function(n,h){let d=i[n.id];void 0===d&&(!function(e){const t=e.uniforms;let n=0;const r=16;for(let s=0,a=t.length;s<a;s++){const e=Array.isArray(t[s])?t[s]:[t[s]];for(let t=0,i=e.length;t<i;t++){const i=e[t],s=Array.isArray(i.value)?i.value:[i.value];for(let e=0,t=s.length;e<t;e++){const t=u(s[e]),a=n%r,o=a%t.boundary,l=a+o;n+=o,0!==l&&r-l<t.storage&&(n+=r-l),i.__data=new Float32Array(t.storage/Float32Array.BYTES_PER_ELEMENT),i.__offset=n,n+=t.storage}}}const i=n%r;i>0&&(n+=r-i);e.__size=n,e.__cache={}}(n),d=function(t){const n=function(){for(let e=0;e<o;e++)if(-1===a.indexOf(e))return a.push(e),e;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}();t.__bindingPointIndex=n;const r=e.createBuffer(),i=t.__size,s=t.usage;return e.bindBuffer(e.UNIFORM_BUFFER,r),e.bufferData(e.UNIFORM_BUFFER,i,s),e.bindBuffer(e.UNIFORM_BUFFER,null),e.bindBufferBase(e.UNIFORM_BUFFER,n,r),r}(n),i[n.id]=d,n.addEventListener("dispose",c));const p=h.program;r.updateUBOMapping(n,p);const f=t.render.frame;s[n.id]!==f&&(!function(t){const n=i[t.id],r=t.uniforms,s=t.__cache;e.bindBuffer(e.UNIFORM_BUFFER,n);for(let i=0,a=r.length;i<a;i++){const t=Array.isArray(r[i])?r[i]:[r[i]];for(let n=0,r=t.length;n<r;n++){const r=t[n];if(!0===l(r,i,n,s)){const t=r.__offset,n=Array.isArray(r.value)?r.value:[r.value];let i=0;for(let s=0;s<n.length;s++){const a=n[s],o=u(a);"number"===typeof a||"boolean"===typeof a?(r.__data[0]=a,e.bufferSubData(e.UNIFORM_BUFFER,t+i,r.__data)):a.isMatrix3?(r.__data[0]=a.elements[0],r.__data[1]=a.elements[1],r.__data[2]=a.elements[2],r.__data[3]=0,r.__data[4]=a.elements[3],r.__data[5]=a.elements[4],r.__data[6]=a.elements[5],r.__data[7]=0,r.__data[8]=a.elements[6],r.__data[9]=a.elements[7],r.__data[10]=a.elements[8],r.__data[11]=0):(a.toArray(r.__data,i),i+=o.storage/Float32Array.BYTES_PER_ELEMENT)}e.bufferSubData(e.UNIFORM_BUFFER,t,r.__data)}}}e.bindBuffer(e.UNIFORM_BUFFER,null)}(n),s[n.id]=f)},dispose:function(){for(const t in i)e.deleteBuffer(i[t]);a=[],i={},s={}}}}class cu{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{canvas:t=hr(),context:n=null,depth:r=!0,stencil:s=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:u=!1,powerPreference:c="default",failIfMajorPerformanceCaveat:h=!1}=e;let d;if(this.isWebGLRenderer=!0,null!==n){if("undefined"!==typeof WebGLRenderingContext&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");d=n.getContextAttributes().alpha}else d=a;const p=new Uint32Array(4),f=new Int32Array(4);let y=null,_=null;const x=[],A=[];this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this._outputColorSpace=en,this.toneMapping=te,this.toneMappingExposure=1;const M=this;let b=!1,S=0,w=0,E=null,T=-1,C=null;const R=new Cr,P=new Cr;let I=null;const B=new ts(0);let L=0,D=t.width,U=t.height,N=1,F=null,O=null;const k=new Cr(0,0,D,U),H=new Cr(0,0,D,U);let z=!1;const G=new va;let V=!1,W=!1;const j=new di,X=new Nr,J=new Cr,Y={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let K=!1;function q(){return null===E?N:1}let Q,Z,$,ee,ne,re,ie,se,ae,oe,le,ue,ce,he,de,pe,fe,me,ge,ve,ye,_e,xe,Ae,Me=n;function be(e,n){return t.getContext(e,n)}try{const e={alpha:!0,depth:r,stencil:s,antialias:o,premultipliedAlpha:l,preserveDrawingBuffer:u,powerPreference:c,failIfMajorPerformanceCaveat:h};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${i}`),t.addEventListener("webglcontextlost",Ee,!1),t.addEventListener("webglcontextrestored",Te,!1),t.addEventListener("webglcontextcreationerror",Re,!1),null===Me){const t="webgl2";if(Me=be(t,e),null===Me)throw be(t)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(by){throw console.error("THREE.WebGLRenderer: "+by.message),by}function Se(){Q=new Za(Me),Q.init(),_e=new $l(Me,Q),Z=new Pa(Me,Q,e,_e),$=new Kl(Me),ee=new to(Me),ne=new Ul,re=new Zl(Me,Q,$,ne,Z,_e,ee),ie=new Ba(M),se=new Qa(M),ae=new _a(Me),xe=new Ca(Me,ae),oe=new $a(Me,ae,ee,xe),le=new ro(Me,oe,ae,ee),ge=new no(Me,Z,re),pe=new Ia(ne),ue=new Dl(M,ie,se,Q,Z,xe,pe),ce=new lu(M,ne),he=new kl,de=new jl(Q),me=new Ta(M,ie,se,$,le,d,l),fe=new Yl(M,le,Z),Ae=new uu(Me,ee,Z,$),ve=new Ra(Me,Q,ee),ye=new eo(Me,Q,ee),ee.programs=ue.programs,M.capabilities=Z,M.extensions=Q,M.properties=ne,M.renderLists=he,M.shadowMap=fe,M.state=$,M.info=ee}Se();const we=new su(M,Me);function Ee(e){e.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),b=!0}function Te(){console.log("THREE.WebGLRenderer: Context Restored."),b=!1;const e=ee.autoReset,t=fe.enabled,n=fe.autoUpdate,r=fe.needsUpdate,i=fe.type;Se(),ee.autoReset=e,fe.enabled=t,fe.autoUpdate=n,fe.needsUpdate=r,fe.type=i}function Re(e){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",e.statusMessage)}function Ie(e){const t=e.target;t.removeEventListener("dispose",Ie),function(e){(function(e){const t=ne.get(e).programs;void 0!==t&&(t.forEach((function(e){ue.releaseProgram(e)})),e.isShaderMaterial&&ue.releaseShaderCache(e))})(e),ne.remove(e)}(t)}function Be(e,t,n){!0===e.transparent&&e.side===v&&!1===e.forceSinglePass?(e.side=g,e.needsUpdate=!0,Ye(e,t,n),e.side=m,e.needsUpdate=!0,Ye(e,t,n),e.side=v):Ye(e,t,n)}this.xr=we,this.getContext=function(){return Me},this.getContextAttributes=function(){return Me.getContextAttributes()},this.forceContextLoss=function(){const e=Q.get("WEBGL_lose_context");e&&e.loseContext()},this.forceContextRestore=function(){const e=Q.get("WEBGL_lose_context");e&&e.restoreContext()},this.getPixelRatio=function(){return N},this.setPixelRatio=function(e){void 0!==e&&(N=e,this.setSize(D,U,!1))},this.getSize=function(e){return e.set(D,U)},this.setSize=function(e,n){let r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];we.isPresenting?console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting."):(D=e,U=n,t.width=Math.floor(e*N),t.height=Math.floor(n*N),!0===r&&(t.style.width=e+"px",t.style.height=n+"px"),this.setViewport(0,0,e,n))},this.getDrawingBufferSize=function(e){return e.set(D*N,U*N).floor()},this.setDrawingBufferSize=function(e,n,r){D=e,U=n,N=r,t.width=Math.floor(e*r),t.height=Math.floor(n*r),this.setViewport(0,0,e,n)},this.getCurrentViewport=function(e){return e.copy(R)},this.getViewport=function(e){return e.copy(k)},this.setViewport=function(e,t,n,r){e.isVector4?k.set(e.x,e.y,e.z,e.w):k.set(e,t,n,r),$.viewport(R.copy(k).multiplyScalar(N).round())},this.getScissor=function(e){return e.copy(H)},this.setScissor=function(e,t,n,r){e.isVector4?H.set(e.x,e.y,e.z,e.w):H.set(e,t,n,r),$.scissor(P.copy(H).multiplyScalar(N).round())},this.getScissorTest=function(){return z},this.setScissorTest=function(e){$.setScissorTest(z=e)},this.setOpaqueSort=function(e){F=e},this.setTransparentSort=function(e){O=e},this.getClearColor=function(e){return e.copy(me.getClearColor())},this.setClearColor=function(){me.setClearColor.apply(me,arguments)},this.getClearAlpha=function(){return me.getClearAlpha()},this.setClearAlpha=function(){me.setClearAlpha.apply(me,arguments)},this.clear=function(){let e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],t=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],n=0;if(!(arguments.length>0&&void 0!==arguments[0])||arguments[0]){let e=!1;if(null!==E){const t=E.texture.format;e=t===et||t===Ze||t===qe}if(e){const e=E.texture.type,t=e===Pe||e===Ue||e===Le||e===He||e===Oe||e===ke,n=me.getClearColor(),r=me.getClearAlpha(),i=n.r,s=n.g,a=n.b;t?(p[0]=i,p[1]=s,p[2]=a,p[3]=r,Me.clearBufferuiv(Me.COLOR,0,p)):(f[0]=i,f[1]=s,f[2]=a,f[3]=r,Me.clearBufferiv(Me.COLOR,0,f))}else n|=Me.COLOR_BUFFER_BIT}e&&(n|=Me.DEPTH_BUFFER_BIT),t&&(n|=Me.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),Me.clear(n)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){t.removeEventListener("webglcontextlost",Ee,!1),t.removeEventListener("webglcontextrestored",Te,!1),t.removeEventListener("webglcontextcreationerror",Re,!1),he.dispose(),de.dispose(),ne.dispose(),ie.dispose(),se.dispose(),le.dispose(),xe.dispose(),Ae.dispose(),ue.dispose(),we.dispose(),we.removeEventListener("sessionstart",Ne),we.removeEventListener("sessionend",ze),Ge.stop()},this.renderBufferDirect=function(e,t,n,r,i,s){null===t&&(t=Y);const a=i.isMesh&&i.matrixWorld.determinant()<0,o=function(e,t,n,r,i){!0!==t.isScene&&(t=Y);re.resetTextureUnits();const s=t.fog,a=r.isMeshStandardMaterial?t.environment:null,o=null===E?M.outputColorSpace:!0===E.isXRRenderTarget?E.texture.colorSpace:tn,l=(r.isMeshStandardMaterial?se:ie).get(r.envMap||a),u=!0===r.vertexColors&&!!n.attributes.color&&4===n.attributes.color.itemSize,c=!!n.attributes.tangent&&(!!r.normalMap||r.anisotropy>0),h=!!n.morphAttributes.position,d=!!n.morphAttributes.normal,p=!!n.morphAttributes.color;let f=te;r.toneMapped&&(null!==E&&!0!==E.isXRRenderTarget||(f=M.toneMapping));const m=n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color,g=void 0!==m?m.length:0,v=ne.get(r),y=_.state.lights;if(!0===V&&(!0===W||e!==C)){const t=e===C&&r.id===T;pe.setState(r,e,t)}let x=!1;r.version===v.__version?v.needsLights&&v.lightsStateVersion!==y.state.version||v.outputColorSpace!==o||i.isBatchedMesh&&!1===v.batching?x=!0:i.isBatchedMesh||!0!==v.batching?i.isBatchedMesh&&!0===v.batchingColor&&null===i.colorTexture||i.isBatchedMesh&&!1===v.batchingColor&&null!==i.colorTexture||i.isInstancedMesh&&!1===v.instancing?x=!0:i.isInstancedMesh||!0!==v.instancing?i.isSkinnedMesh&&!1===v.skinning?x=!0:i.isSkinnedMesh||!0!==v.skinning?i.isInstancedMesh&&!0===v.instancingColor&&null===i.instanceColor||i.isInstancedMesh&&!1===v.instancingColor&&null!==i.instanceColor||i.isInstancedMesh&&!0===v.instancingMorph&&null===i.morphTexture||i.isInstancedMesh&&!1===v.instancingMorph&&null!==i.morphTexture||v.envMap!==l||!0===r.fog&&v.fog!==s?x=!0:void 0===v.numClippingPlanes||v.numClippingPlanes===pe.numPlanes&&v.numIntersection===pe.numIntersection?(v.vertexAlphas!==u||v.vertexTangents!==c||v.morphTargets!==h||v.morphNormals!==d||v.morphColors!==p||v.toneMapping!==f||v.morphTargetsCount!==g)&&(x=!0):x=!0:x=!0:x=!0:x=!0:(x=!0,v.__version=r.version);let A=v.currentProgram;!0===x&&(A=Ye(r,t,i));let b=!1,S=!1,w=!1;const R=A.getUniforms(),P=v.uniforms;$.useProgram(A.program)&&(b=!0,S=!0,w=!0);r.id!==T&&(T=r.id,S=!0);if(b||C!==e){R.setValue(Me,"projectionMatrix",e.projectionMatrix),R.setValue(Me,"viewMatrix",e.matrixWorldInverse);const t=R.map.cameraPosition;void 0!==t&&t.setValue(Me,X.setFromMatrixPosition(e.matrixWorld)),Z.logarithmicDepthBuffer&&R.setValue(Me,"logDepthBufFC",2/(Math.log(e.far+1)/Math.LN2)),(r.isMeshPhongMaterial||r.isMeshToonMaterial||r.isMeshLambertMaterial||r.isMeshBasicMaterial||r.isMeshStandardMaterial||r.isShaderMaterial)&&R.setValue(Me,"isOrthographic",!0===e.isOrthographicCamera),C!==e&&(C=e,S=!0,w=!0)}if(i.isSkinnedMesh){R.setOptional(Me,i,"bindMatrix"),R.setOptional(Me,i,"bindMatrixInverse");const e=i.skeleton;e&&(null===e.boneTexture&&e.computeBoneTexture(),R.setValue(Me,"boneTexture",e.boneTexture,re))}i.isBatchedMesh&&(R.setOptional(Me,i,"batchingTexture"),R.setValue(Me,"batchingTexture",i._matricesTexture,re),R.setOptional(Me,i,"batchingIdTexture"),R.setValue(Me,"batchingIdTexture",i._indirectTexture,re),R.setOptional(Me,i,"batchingColorTexture"),null!==i._colorsTexture&&R.setValue(Me,"batchingColorTexture",i._colorsTexture,re));const I=n.morphAttributes;void 0===I.position&&void 0===I.normal&&void 0===I.color||ge.update(i,n,A);(S||v.receiveShadow!==i.receiveShadow)&&(v.receiveShadow=i.receiveShadow,R.setValue(Me,"receiveShadow",i.receiveShadow));r.isMeshGouraudMaterial&&null!==r.envMap&&(P.envMap.value=l,P.flipEnvMap.value=l.isCubeTexture&&!1===l.isRenderTargetTexture?-1:1);r.isMeshStandardMaterial&&null===r.envMap&&null!==t.environment&&(P.envMapIntensity.value=t.environmentIntensity);S&&(R.setValue(Me,"toneMappingExposure",M.toneMappingExposure),v.needsLights&&(L=w,(B=P).ambientLightColor.needsUpdate=L,B.lightProbe.needsUpdate=L,B.directionalLights.needsUpdate=L,B.directionalLightShadows.needsUpdate=L,B.pointLights.needsUpdate=L,B.pointLightShadows.needsUpdate=L,B.spotLights.needsUpdate=L,B.spotLightShadows.needsUpdate=L,B.rectAreaLights.needsUpdate=L,B.hemisphereLights.needsUpdate=L),s&&!0===r.fog&&ce.refreshFogUniforms(P,s),ce.refreshMaterialUniforms(P,r,N,U,_.state.transmissionRenderTarget[e.id]),cl.upload(Me,Ke(v),P,re));var B,L;r.isShaderMaterial&&!0===r.uniformsNeedUpdate&&(cl.upload(Me,Ke(v),P,re),r.uniformsNeedUpdate=!1);r.isSpriteMaterial&&R.setValue(Me,"center",i.center);if(R.setValue(Me,"modelViewMatrix",i.modelViewMatrix),R.setValue(Me,"normalMatrix",i.normalMatrix),R.setValue(Me,"modelMatrix",i.matrixWorld),r.isShaderMaterial||r.isRawShaderMaterial){const e=r.uniformsGroups;for(let t=0,n=e.length;t<n;t++){const n=e[t];Ae.update(n,A),Ae.bind(n,A)}}return A}(e,t,n,r,i);$.setMaterial(r,a);let l=n.index,u=1;if(!0===r.wireframe){if(l=oe.getWireframeAttribute(n),void 0===l)return;u=2}const c=n.drawRange,h=n.attributes.position;let d=c.start*u,p=(c.start+c.count)*u;null!==s&&(d=Math.max(d,s.start*u),p=Math.min(p,(s.start+s.count)*u)),null!==l?(d=Math.max(d,0),p=Math.min(p,l.count)):void 0!==h&&null!==h&&(d=Math.max(d,0),p=Math.min(p,h.count));const f=p-d;if(f<0||f===1/0)return;let m;xe.setup(i,r,o,n,l);let g=ve;if(null!==l&&(m=ae.get(l),g=ye,g.setIndex(m)),i.isMesh)!0===r.wireframe?($.setLineWidth(r.wireframeLinewidth*q()),g.setMode(Me.LINES)):g.setMode(Me.TRIANGLES);else if(i.isLine){let e=r.linewidth;void 0===e&&(e=1),$.setLineWidth(e*q()),i.isLineSegments?g.setMode(Me.LINES):i.isLineLoop?g.setMode(Me.LINE_LOOP):g.setMode(Me.LINE_STRIP)}else i.isPoints?g.setMode(Me.POINTS):i.isSprite&&g.setMode(Me.TRIANGLES);if(i.isBatchedMesh)if(null!==i._multiDrawInstances)g.renderMultiDrawInstances(i._multiDrawStarts,i._multiDrawCounts,i._multiDrawCount,i._multiDrawInstances);else if(Q.get("WEBGL_multi_draw"))g.renderMultiDraw(i._multiDrawStarts,i._multiDrawCounts,i._multiDrawCount);else{const e=i._multiDrawStarts,t=i._multiDrawCounts,n=i._multiDrawCount,s=l?ae.get(l).bytesPerElement:1,a=ne.get(r).currentProgram.getUniforms();for(let r=0;r<n;r++)a.setValue(Me,"_gl_DrawID",r),g.render(e[r]/s,t[r])}else if(i.isInstancedMesh)g.renderInstances(d,f,i.count);else if(n.isInstancedBufferGeometry){const e=void 0!==n._maxInstanceCount?n._maxInstanceCount:1/0,t=Math.min(n.instanceCount,e);g.renderInstances(d,f,t)}else g.render(d,f)},this.compile=function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;null===n&&(n=e),_=de.get(n),_.init(t),A.push(_),n.traverseVisible((function(e){e.isLight&&e.layers.test(t.layers)&&(_.pushLight(e),e.castShadow&&_.pushShadow(e))})),e!==n&&e.traverseVisible((function(e){e.isLight&&e.layers.test(t.layers)&&(_.pushLight(e),e.castShadow&&_.pushShadow(e))})),_.setupLights();const r=new Set;return e.traverse((function(e){const t=e.material;if(t)if(Array.isArray(t))for(let i=0;i<t.length;i++){const s=t[i];Be(s,n,e),r.add(s)}else Be(t,n,e),r.add(t)})),A.pop(),_=null,r},this.compileAsync=function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;const r=this.compile(e,t,n);return new Promise((t=>{function n(){r.forEach((function(e){ne.get(e).currentProgram.isReady()&&r.delete(e)})),0!==r.size?setTimeout(n,10):t(e)}null!==Q.get("KHR_parallel_shader_compile")?n():setTimeout(n,10)}))};let De=null;function Ne(){Ge.stop()}function ze(){Ge.start()}const Ge=new ya;function Ve(e,t,n,r){if(!1===e.visible)return;if(e.layers.test(t.layers))if(e.isGroup)n=e.renderOrder;else if(e.isLOD)!0===e.autoUpdate&&e.update(t);else if(e.isLight)_.pushLight(e),e.castShadow&&_.pushShadow(e);else if(e.isSprite){if(!e.frustumCulled||G.intersectsSprite(e)){r&&J.setFromMatrixPosition(e.matrixWorld).applyMatrix4(j);const t=le.update(e),i=e.material;i.visible&&y.push(e,t,i,n,J.z,null)}}else if((e.isMesh||e.isLine||e.isPoints)&&(!e.frustumCulled||G.intersectsObject(e))){const t=le.update(e),i=e.material;if(r&&(void 0!==e.boundingSphere?(null===e.boundingSphere&&e.computeBoundingSphere(),J.copy(e.boundingSphere.center)):(null===t.boundingSphere&&t.computeBoundingSphere(),J.copy(t.boundingSphere.center)),J.applyMatrix4(e.matrixWorld).applyMatrix4(j)),Array.isArray(i)){const r=t.groups;for(let s=0,a=r.length;s<a;s++){const a=r[s],o=i[a.materialIndex];o&&o.visible&&y.push(e,t,o,n,J.z,a)}}else i.visible&&y.push(e,t,i,n,J.z,null)}const i=e.children;for(let s=0,a=i.length;s<a;s++)Ve(i[s],t,n,r)}function We(e,t,n,r){const i=e.opaque,s=e.transmissive,a=e.transparent;_.setupLightsView(n),!0===V&&pe.setGlobalState(M.clippingPlanes,n),r&&$.viewport(R.copy(r)),i.length>0&&Xe(i,t,n),s.length>0&&Xe(s,t,n),a.length>0&&Xe(a,t,n),$.buffers.depth.setTest(!0),$.buffers.depth.setMask(!0),$.buffers.color.setMask(!0),$.setPolygonOffset(!1)}function je(e,t,n,r){if(null!==(!0===n.isScene?n.overrideMaterial:null))return;void 0===_.state.transmissionRenderTarget[r.id]&&(_.state.transmissionRenderTarget[r.id]=new Pr(1,1,{generateMipmaps:!0,type:Q.has("EXT_color_buffer_half_float")||Q.has("EXT_color_buffer_float")?Fe:Pe,minFilter:Ce,samples:4,stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:yr.workingColorSpace}));const i=_.state.transmissionRenderTarget[r.id],a=r.viewport||R;i.setSize(a.z,a.w);const o=M.getRenderTarget();M.setRenderTarget(i),M.getClearColor(B),L=M.getClearAlpha(),L<1&&M.setClearColor(16777215,.5),M.clear(),K&&me.render(n);const l=M.toneMapping;M.toneMapping=te;const u=r.viewport;if(void 0!==r.viewport&&(r.viewport=void 0),_.setupLightsView(r),!0===V&&pe.setGlobalState(M.clippingPlanes,r),Xe(e,n,r),re.updateMultisampleRenderTarget(i),re.updateRenderTargetMipmap(i),!1===Q.has("WEBGL_multisampled_render_to_texture")){let e=!1;for(let i=0,s=t.length;i<s;i++){const s=t[i],a=s.object,o=s.geometry,l=s.material,u=s.group;if(l.side===v&&a.layers.test(r.layers)){const t=l.side;l.side=g,l.needsUpdate=!0,Je(a,n,r,o,l,u),l.side=t,l.needsUpdate=!0,e=!0}}!0===e&&(re.updateMultisampleRenderTarget(i),re.updateRenderTargetMipmap(i))}M.setRenderTarget(o),M.setClearColor(B,L),void 0!==u&&(r.viewport=u),M.toneMapping=l}function Xe(e,t,n){const r=!0===t.isScene?t.overrideMaterial:null;for(let i=0,s=e.length;i<s;i++){const s=e[i],a=s.object,o=s.geometry,l=null===r?s.material:r,u=s.group;a.layers.test(n.layers)&&Je(a,t,n,o,l,u)}}function Je(e,t,n,r,i,s){e.onBeforeRender(M,t,n,r,i,s),e.modelViewMatrix.multiplyMatrices(n.matrixWorldInverse,e.matrixWorld),e.normalMatrix.getNormalMatrix(e.modelViewMatrix),!0===i.transparent&&i.side===v&&!1===i.forceSinglePass?(i.side=g,i.needsUpdate=!0,M.renderBufferDirect(n,t,r,i,e,s),i.side=m,i.needsUpdate=!0,M.renderBufferDirect(n,t,r,i,e,s),i.side=v):M.renderBufferDirect(n,t,r,i,e,s),e.onAfterRender(M,t,n,r,i,s)}function Ye(e,t,n){!0!==t.isScene&&(t=Y);const r=ne.get(e),i=_.state.lights,s=_.state.shadowsArray,a=i.state.version,o=ue.getParameters(e,i.state,s,t,n),l=ue.getProgramCacheKey(o);let u=r.programs;r.environment=e.isMeshStandardMaterial?t.environment:null,r.fog=t.fog,r.envMap=(e.isMeshStandardMaterial?se:ie).get(e.envMap||r.environment),r.envMapRotation=null!==r.environment&&null===e.envMap?t.environmentRotation:e.envMapRotation,void 0===u&&(e.addEventListener("dispose",Ie),u=new Map,r.programs=u);let c=u.get(l);if(void 0!==c){if(r.currentProgram===c&&r.lightsStateVersion===a)return Qe(e,o),c}else o.uniforms=ue.getUniforms(e),e.onBeforeCompile(o,M),c=ue.acquireProgram(o,l),u.set(l,c),r.uniforms=o.uniforms;const h=r.uniforms;return(e.isShaderMaterial||e.isRawShaderMaterial)&&!0!==e.clipping||(h.clippingPlanes=pe.uniform),Qe(e,o),r.needsLights=function(e){return e.isMeshLambertMaterial||e.isMeshToonMaterial||e.isMeshPhongMaterial||e.isMeshStandardMaterial||e.isShadowMaterial||e.isShaderMaterial&&!0===e.lights}(e),r.lightsStateVersion=a,r.needsLights&&(h.ambientLightColor.value=i.state.ambient,h.lightProbe.value=i.state.probe,h.directionalLights.value=i.state.directional,h.directionalLightShadows.value=i.state.directionalShadow,h.spotLights.value=i.state.spot,h.spotLightShadows.value=i.state.spotShadow,h.rectAreaLights.value=i.state.rectArea,h.ltc_1.value=i.state.rectAreaLTC1,h.ltc_2.value=i.state.rectAreaLTC2,h.pointLights.value=i.state.point,h.pointLightShadows.value=i.state.pointShadow,h.hemisphereLights.value=i.state.hemi,h.directionalShadowMap.value=i.state.directionalShadowMap,h.directionalShadowMatrix.value=i.state.directionalShadowMatrix,h.spotShadowMap.value=i.state.spotShadowMap,h.spotLightMatrix.value=i.state.spotLightMatrix,h.spotLightMap.value=i.state.spotLightMap,h.pointShadowMap.value=i.state.pointShadowMap,h.pointShadowMatrix.value=i.state.pointShadowMatrix),r.currentProgram=c,r.uniformsList=null,c}function Ke(e){if(null===e.uniformsList){const t=e.currentProgram.getUniforms();e.uniformsList=cl.seqWithValue(t.seq,e.uniforms)}return e.uniformsList}function Qe(e,t){const n=ne.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}Ge.setAnimationLoop((function(e){De&&De(e)})),"undefined"!==typeof self&&Ge.setContext(self),this.setAnimationLoop=function(e){De=e,we.setAnimationLoop(e),null===e?Ge.stop():Ge.start()},we.addEventListener("sessionstart",Ne),we.addEventListener("sessionend",ze),this.render=function(e,t){if(void 0!==t&&!0!==t.isCamera)return void console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");if(!0===b)return;if(!0===e.matrixWorldAutoUpdate&&e.updateMatrixWorld(),null===t.parent&&!0===t.matrixWorldAutoUpdate&&t.updateMatrixWorld(),!0===we.enabled&&!0===we.isPresenting&&(!0===we.cameraAutoUpdate&&we.updateCamera(t),t=we.getCamera()),!0===e.isScene&&e.onBeforeRender(M,e,t,E),_=de.get(e,A.length),_.init(t),A.push(_),j.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),G.setFromProjectionMatrix(j),W=this.localClippingEnabled,V=pe.init(this.clippingPlanes,W),y=he.get(e,x.length),y.init(),x.push(y),!0===we.enabled&&!0===we.isPresenting){const e=M.xr.getDepthSensingMesh();null!==e&&Ve(e,t,-1/0,M.sortObjects)}Ve(e,t,0,M.sortObjects),y.finish(),!0===M.sortObjects&&y.sort(F,O),K=!1===we.enabled||!1===we.isPresenting||!1===we.hasDepthSensing(),K&&me.addToRenderList(y,e),this.info.render.frame++,!0===V&&pe.beginShadows();const n=_.state.shadowsArray;fe.render(n,e,t),!0===V&&pe.endShadows(),!0===this.info.autoReset&&this.info.reset();const r=y.opaque,i=y.transmissive;if(_.setupLights(),t.isArrayCamera){const n=t.cameras;if(i.length>0)for(let t=0,s=n.length;t<s;t++){je(r,i,e,n[t])}K&&me.render(e);for(let t=0,r=n.length;t<r;t++){const r=n[t];We(y,e,r,r.viewport)}}else i.length>0&&je(r,i,e,t),K&&me.render(e),We(y,e,t);null!==E&&(re.updateMultisampleRenderTarget(E),re.updateRenderTargetMipmap(E)),!0===e.isScene&&e.onAfterRender(M,e,t),xe.resetDefaultState(),T=-1,C=null,A.pop(),A.length>0?(_=A[A.length-1],!0===V&&pe.setGlobalState(M.clippingPlanes,_.state.camera)):_=null,x.pop(),y=x.length>0?x[x.length-1]:null},this.getActiveCubeFace=function(){return S},this.getActiveMipmapLevel=function(){return w},this.getRenderTarget=function(){return E},this.setRenderTargetTextures=function(e,t,n){ne.get(e.texture).__webglTexture=t,ne.get(e.depthTexture).__webglTexture=n;const r=ne.get(e);r.__hasExternalTextures=!0,r.__autoAllocateDepthBuffer=void 0===n,r.__autoAllocateDepthBuffer||!0===Q.has("WEBGL_multisampled_render_to_texture")&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),r.__useRenderToTexture=!1)},this.setRenderTargetFramebuffer=function(e,t){const n=ne.get(e);n.__webglFramebuffer=t,n.__useDefaultFramebuffer=void 0===t},this.setRenderTarget=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;E=e,S=t,w=n;let r=!0,i=null,s=!1,a=!1;if(e){const o=ne.get(e);void 0!==o.__useDefaultFramebuffer?($.bindFramebuffer(Me.FRAMEBUFFER,null),r=!1):void 0===o.__webglFramebuffer?re.setupRenderTarget(e):o.__hasExternalTextures&&re.rebindTextures(e,ne.get(e.texture).__webglTexture,ne.get(e.depthTexture).__webglTexture);const l=e.texture;(l.isData3DTexture||l.isDataArrayTexture||l.isCompressedArrayTexture)&&(a=!0);const u=ne.get(e).__webglFramebuffer;e.isWebGLCubeRenderTarget?(i=Array.isArray(u[t])?u[t][n]:u[t],s=!0):i=e.samples>0&&!1===re.useMultisampledRTT(e)?ne.get(e).__webglMultisampledFramebuffer:Array.isArray(u)?u[n]:u,R.copy(e.viewport),P.copy(e.scissor),I=e.scissorTest}else R.copy(k).multiplyScalar(N).floor(),P.copy(H).multiplyScalar(N).floor(),I=z;if($.bindFramebuffer(Me.FRAMEBUFFER,i)&&r&&$.drawBuffers(e,i),$.viewport(R),$.scissor(P),$.setScissorTest(I),s){const r=ne.get(e.texture);Me.framebufferTexture2D(Me.FRAMEBUFFER,Me.COLOR_ATTACHMENT0,Me.TEXTURE_CUBE_MAP_POSITIVE_X+t,r.__webglTexture,n)}else if(a){const r=ne.get(e.texture),i=t||0;Me.framebufferTextureLayer(Me.FRAMEBUFFER,Me.COLOR_ATTACHMENT0,r.__webglTexture,n||0,i)}T=-1},this.readRenderTargetPixels=function(e,t,n,r,i,s,a){if(!e||!e.isWebGLRenderTarget)return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let o=ne.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&void 0!==a&&(o=o[a]),o){$.bindFramebuffer(Me.FRAMEBUFFER,o);try{const a=e.texture,o=a.format,l=a.type;if(!Z.textureFormatReadable(o))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");if(!Z.textureTypeReadable(l))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");t>=0&&t<=e.width-r&&n>=0&&n<=e.height-i&&Me.readPixels(t,n,r,i,_e.convert(o),_e.convert(l),s)}finally{const e=null!==E?ne.get(E).__webglFramebuffer:null;$.bindFramebuffer(Me.FRAMEBUFFER,e)}}},this.readRenderTargetPixelsAsync=async function(e,t,n,r,i,s,a){if(!e||!e.isWebGLRenderTarget)throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let o=ne.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&void 0!==a&&(o=o[a]),o){$.bindFramebuffer(Me.FRAMEBUFFER,o);try{const a=e.texture,o=a.format,l=a.type;if(!Z.textureFormatReadable(o))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!Z.textureTypeReadable(l))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");if(t>=0&&t<=e.width-r&&n>=0&&n<=e.height-i){const e=Me.createBuffer();Me.bindBuffer(Me.PIXEL_PACK_BUFFER,e),Me.bufferData(Me.PIXEL_PACK_BUFFER,s.byteLength,Me.STREAM_READ),Me.readPixels(t,n,r,i,_e.convert(o),_e.convert(l),0),Me.flush();const a=Me.fenceSync(Me.SYNC_GPU_COMMANDS_COMPLETE,0);await function(e,t,n){return new Promise((function(r,i){setTimeout((function s(){switch(e.clientWaitSync(t,e.SYNC_FLUSH_COMMANDS_BIT,0)){case e.WAIT_FAILED:i();break;case e.TIMEOUT_EXPIRED:setTimeout(s,n);break;default:r()}}),n)}))}(Me,a,4);try{Me.bindBuffer(Me.PIXEL_PACK_BUFFER,e),Me.getBufferSubData(Me.PIXEL_PACK_BUFFER,0,s)}finally{Me.deleteBuffer(e),Me.deleteSync(a)}return s}}finally{const e=null!==E?ne.get(E).__webglFramebuffer:null;$.bindFramebuffer(Me.FRAMEBUFFER,e)}}},this.copyFramebufferToTexture=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;!0!==e.isTexture&&(pr("WebGLRenderer: copyFramebufferToTexture function signature has changed."),t=arguments[0]||null,e=arguments[1]);const r=Math.pow(2,-n),i=Math.floor(e.image.width*r),s=Math.floor(e.image.height*r),a=null!==t?t.x:0,o=null!==t?t.y:0;re.setTexture2D(e,0),Me.copyTexSubImage2D(Me.TEXTURE_2D,n,0,0,a,o,i,s),$.unbindTexture()},this.copyTextureToTexture=function(e,t){let n,r,i,s,a,o,l=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,u=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,c=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0;!0!==e.isTexture&&(pr("WebGLRenderer: copyTextureToTexture function signature has changed."),u=arguments[0]||null,e=arguments[1],t=arguments[2],c=arguments[3]||0,l=null),null!==l?(n=l.max.x-l.min.x,r=l.max.y-l.min.y,i=l.min.x,s=l.min.y):(n=e.image.width,r=e.image.height,i=0,s=0),null!==u?(a=u.x,o=u.y):(a=0,o=0);const h=_e.convert(t.format),d=_e.convert(t.type);re.setTexture2D(t,0),Me.pixelStorei(Me.UNPACK_FLIP_Y_WEBGL,t.flipY),Me.pixelStorei(Me.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),Me.pixelStorei(Me.UNPACK_ALIGNMENT,t.unpackAlignment);const p=Me.getParameter(Me.UNPACK_ROW_LENGTH),f=Me.getParameter(Me.UNPACK_IMAGE_HEIGHT),m=Me.getParameter(Me.UNPACK_SKIP_PIXELS),g=Me.getParameter(Me.UNPACK_SKIP_ROWS),v=Me.getParameter(Me.UNPACK_SKIP_IMAGES),y=e.isCompressedTexture?e.mipmaps[c]:e.image;Me.pixelStorei(Me.UNPACK_ROW_LENGTH,y.width),Me.pixelStorei(Me.UNPACK_IMAGE_HEIGHT,y.height),Me.pixelStorei(Me.UNPACK_SKIP_PIXELS,i),Me.pixelStorei(Me.UNPACK_SKIP_ROWS,s),e.isDataTexture?Me.texSubImage2D(Me.TEXTURE_2D,c,a,o,n,r,h,d,y.data):e.isCompressedTexture?Me.compressedTexSubImage2D(Me.TEXTURE_2D,c,a,o,y.width,y.height,h,y.data):Me.texSubImage2D(Me.TEXTURE_2D,c,a,o,n,r,h,d,y),Me.pixelStorei(Me.UNPACK_ROW_LENGTH,p),Me.pixelStorei(Me.UNPACK_IMAGE_HEIGHT,f),Me.pixelStorei(Me.UNPACK_SKIP_PIXELS,m),Me.pixelStorei(Me.UNPACK_SKIP_ROWS,g),Me.pixelStorei(Me.UNPACK_SKIP_IMAGES,v),0===c&&t.generateMipmaps&&Me.generateMipmap(Me.TEXTURE_2D),$.unbindTexture()},this.copyTextureToTexture3D=function(e,t){let n,r,i,s,a,o,l,u,c,h=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,d=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,p=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0;!0!==e.isTexture&&(pr("WebGLRenderer: copyTextureToTexture3D function signature has changed."),h=arguments[0]||null,d=arguments[1]||null,e=arguments[2],t=arguments[3],p=arguments[4]||0);const f=e.isCompressedTexture?e.mipmaps[p]:e.image;null!==h?(n=h.max.x-h.min.x,r=h.max.y-h.min.y,i=h.max.z-h.min.z,s=h.min.x,a=h.min.y,o=h.min.z):(n=f.width,r=f.height,i=f.depth,s=0,a=0,o=0),null!==d?(l=d.x,u=d.y,c=d.z):(l=0,u=0,c=0);const m=_e.convert(t.format),g=_e.convert(t.type);let v;if(t.isData3DTexture)re.setTexture3D(t,0),v=Me.TEXTURE_3D;else{if(!t.isDataArrayTexture&&!t.isCompressedArrayTexture)return void console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");re.setTexture2DArray(t,0),v=Me.TEXTURE_2D_ARRAY}Me.pixelStorei(Me.UNPACK_FLIP_Y_WEBGL,t.flipY),Me.pixelStorei(Me.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),Me.pixelStorei(Me.UNPACK_ALIGNMENT,t.unpackAlignment);const y=Me.getParameter(Me.UNPACK_ROW_LENGTH),_=Me.getParameter(Me.UNPACK_IMAGE_HEIGHT),x=Me.getParameter(Me.UNPACK_SKIP_PIXELS),A=Me.getParameter(Me.UNPACK_SKIP_ROWS),M=Me.getParameter(Me.UNPACK_SKIP_IMAGES);Me.pixelStorei(Me.UNPACK_ROW_LENGTH,f.width),Me.pixelStorei(Me.UNPACK_IMAGE_HEIGHT,f.height),Me.pixelStorei(Me.UNPACK_SKIP_PIXELS,s),Me.pixelStorei(Me.UNPACK_SKIP_ROWS,a),Me.pixelStorei(Me.UNPACK_SKIP_IMAGES,o),e.isDataTexture||e.isData3DTexture?Me.texSubImage3D(v,p,l,u,c,n,r,i,m,g,f.data):t.isCompressedArrayTexture?Me.compressedTexSubImage3D(v,p,l,u,c,n,r,i,m,f.data):Me.texSubImage3D(v,p,l,u,c,n,r,i,m,g,f),Me.pixelStorei(Me.UNPACK_ROW_LENGTH,y),Me.pixelStorei(Me.UNPACK_IMAGE_HEIGHT,_),Me.pixelStorei(Me.UNPACK_SKIP_PIXELS,x),Me.pixelStorei(Me.UNPACK_SKIP_ROWS,A),Me.pixelStorei(Me.UNPACK_SKIP_IMAGES,M),0===p&&t.generateMipmaps&&Me.generateMipmap(v),$.unbindTexture()},this.initRenderTarget=function(e){void 0===ne.get(e).__webglFramebuffer&&re.setupRenderTarget(e)},this.initTexture=function(e){e.isCubeTexture?re.setTextureCube(e,0):e.isData3DTexture?re.setTexture3D(e,0):e.isDataArrayTexture||e.isCompressedArrayTexture?re.setTexture2DArray(e,0):re.setTexture2D(e,0),$.unbindTexture()},this.resetState=function(){S=0,w=0,E=null,$.reset(),xe.reset()},"undefined"!==typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Wn}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=e===nn?"display-p3":"srgb",t.unpackColorSpace=yr.workingColorSpace===rn?"display-p3":"srgb"}}class hu{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:25e-5;this.isFogExp2=!0,this.name="",this.color=new ts(e),this.density=t}clone(){return new hu(this.color,this.density)}toJSON(){return{type:"FogExp2",name:this.name,color:this.color.getHex(),density:this.density}}}class du{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1e3;this.isFog=!0,this.name="",this.color=new ts(e),this.near=t,this.far=n}clone(){return new du(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class pu extends ki{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new Mi,this.environmentIntensity=1,this.environmentRotation=new Mi,this.overrideMaterial=null,"undefined"!==typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),null!==e.background&&(this.background=e.background.clone()),null!==e.environment&&(this.environment=e.environment.clone()),null!==e.fog&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),null!==e.overrideMaterial&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return null!==this.fog&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),1!==this.backgroundIntensity&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),1!==this.environmentIntensity&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}}class fu{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=void 0!==e?e.length/t:0,this.usage=Ln,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.version=0,this.uuid=Qn()}onUploadCallback(){}set needsUpdate(e){!0===e&&this.version++}get updateRange(){return pr("THREE.InterleavedBuffer: updateRange() is deprecated and will be removed in r169. Use addUpdateRange() instead."),this._updateRange}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let r=0,i=this.stride;r<i;r++)this.array[e+r]=t.array[n+r];return this}set(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return this.array.set(e,t),this}clone(e){void 0===e.arrayBuffers&&(e.arrayBuffers={}),void 0===this.array.buffer._uuid&&(this.array.buffer._uuid=Qn()),void 0===e.arrayBuffers[this.array.buffer._uuid]&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(t,this.stride);return n.setUsage(this.usage),n}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return void 0===e.arrayBuffers&&(e.arrayBuffers={}),void 0===this.array.buffer._uuid&&(this.array.buffer._uuid=Qn()),void 0===e.arrayBuffers[this.array.buffer._uuid]&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}const mu=new Nr;class gu{constructor(e,t,n){let r=arguments.length>3&&void 0!==arguments[3]&&arguments[3];this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=n,this.normalized=r}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,n=this.data.count;t<n;t++)mu.fromBufferAttribute(this,t),mu.applyMatrix4(e),this.setXYZ(t,mu.x,mu.y,mu.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)mu.fromBufferAttribute(this,t),mu.applyNormalMatrix(e),this.setXYZ(t,mu.x,mu.y,mu.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)mu.fromBufferAttribute(this,t),mu.transformDirection(e),this.setXYZ(t,mu.x,mu.y,mu.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(n=tr(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=nr(n,this.array)),this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){return this.normalized&&(t=nr(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=nr(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=nr(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=nr(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=tr(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=tr(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=tr(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=tr(t,this.array)),t}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=nr(t,this.array),n=nr(n,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=nr(t,this.array),n=nr(n,this.array),r=nr(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=r,this}setXYZW(e,t,n,r,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=nr(t,this.array),n=nr(n,this.array),r=nr(r,this.array),i=nr(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=r,this.data.array[e+3]=i,this}clone(e){if(void 0===e){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const e=[];for(let t=0;t<this.count;t++){const n=t*this.data.stride+this.offset;for(let t=0;t<this.itemSize;t++)e.push(this.data.array[n+t])}return new ps(new this.array.constructor(e),this.itemSize,this.normalized)}return void 0===e.interleavedBuffers&&(e.interleavedBuffers={}),void 0===e.interleavedBuffers[this.data.uuid]&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new gu(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(void 0===e){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const e=[];for(let t=0;t<this.count;t++){const n=t*this.data.stride+this.offset;for(let t=0;t<this.itemSize;t++)e.push(this.data.array[n+t])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:e,normalized:this.normalized}}return void 0===e.interleavedBuffers&&(e.interleavedBuffers={}),void 0===e.interleavedBuffers[this.data.uuid]&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}class vu extends is{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new ts(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}let yu;const _u=new Nr,xu=new Nr,Au=new Nr,Mu=new ir,bu=new ir,Su=new di,wu=new Nr,Eu=new Nr,Tu=new Nr,Cu=new ir,Ru=new ir,Pu=new ir;class Iu extends ki{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new vu;if(super(),this.isSprite=!0,this.type="Sprite",void 0===yu){yu=new Ps;const e=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),t=new fu(e,5);yu.setIndex([0,1,2,0,2,3]),yu.setAttribute("position",new gu(t,3,0,!1)),yu.setAttribute("uv",new gu(t,2,3,!1))}this.geometry=yu,this.material=e,this.center=new ir(.5,.5)}raycast(e,t){null===e.camera&&console.error('THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),xu.setFromMatrixScale(this.matrixWorld),Su.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),Au.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&!1===this.material.sizeAttenuation&&xu.multiplyScalar(-Au.z);const n=this.material.rotation;let r,i;0!==n&&(i=Math.cos(n),r=Math.sin(n));const s=this.center;Bu(wu.set(-.5,-.5,0),Au,s,xu,r,i),Bu(Eu.set(.5,-.5,0),Au,s,xu,r,i),Bu(Tu.set(.5,.5,0),Au,s,xu,r,i),Cu.set(0,0),Ru.set(1,0),Pu.set(1,1);let a=e.ray.intersectTriangle(wu,Eu,Tu,!1,_u);if(null===a&&(Bu(Eu.set(-.5,.5,0),Au,s,xu,r,i),Ru.set(0,1),a=e.ray.intersectTriangle(wu,Tu,Eu,!1,_u),null===a))return;const o=e.ray.origin.distanceTo(_u);o<e.near||o>e.far||t.push({distance:o,point:_u.clone(),uv:qi.getInterpolation(_u,wu,Eu,Tu,Cu,Ru,Pu,new ir),face:null,object:this})}copy(e,t){return super.copy(e,t),void 0!==e.center&&this.center.copy(e.center),this.material=e.material,this}}function Bu(e,t,n,r,i,s){Mu.subVectors(e,n).addScalar(.5).multiply(r),void 0!==i?(bu.x=s*Mu.x-i*Mu.y,bu.y=i*Mu.x+s*Mu.y):bu.copy(Mu),e.copy(t),e.x+=bu.x,e.y+=bu.y,e.applyMatrix4(Su)}const Lu=new Nr,Du=new Nr;class Uu extends ki{constructor(){super(),this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]},isLOD:{value:!0}}),this.autoUpdate=!0}copy(e){super.copy(e,!1);const t=e.levels;for(let n=0,r=t.length;n<r;n++){const e=t[n];this.addLevel(e.object.clone(),e.distance,e.hysteresis)}return this.autoUpdate=e.autoUpdate,this}addLevel(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;t=Math.abs(t);const r=this.levels;let i;for(i=0;i<r.length&&!(t<r[i].distance);i++);return r.splice(i,0,{distance:t,hysteresis:n,object:e}),this.add(e),this}getCurrentLevel(){return this._currentLevel}getObjectForDistance(e){const t=this.levels;if(t.length>0){let n,r;for(n=1,r=t.length;n<r;n++){let r=t[n].distance;if(t[n].object.visible&&(r-=r*t[n].hysteresis),e<r)break}return t[n-1].object}return null}raycast(e,t){if(this.levels.length>0){Lu.setFromMatrixPosition(this.matrixWorld);const n=e.ray.origin.distanceTo(Lu);this.getObjectForDistance(n).raycast(e,t)}}update(e){const t=this.levels;if(t.length>1){Lu.setFromMatrixPosition(e.matrixWorld),Du.setFromMatrixPosition(this.matrixWorld);const n=Lu.distanceTo(Du)/e.zoom;let r,i;for(t[0].object.visible=!0,r=1,i=t.length;r<i;r++){let e=t[r].distance;if(t[r].object.visible&&(e-=e*t[r].hysteresis),!(n>=e))break;t[r-1].object.visible=!1,t[r].object.visible=!0}for(this._currentLevel=r-1;r<i;r++)t[r].object.visible=!1}}toJSON(e){const t=super.toJSON(e);!1===this.autoUpdate&&(t.object.autoUpdate=!1),t.object.levels=[];const n=this.levels;for(let r=0,i=n.length;r<i;r++){const e=n[r];t.object.levels.push({object:e.object.uuid,distance:e.distance,hysteresis:e.hysteresis})}return t}}const Nu=new Nr,Fu=new Cr,Ou=new Cr,ku=new Nr,Hu=new di,zu=new Nr,Gu=new ri,Vu=new di,Wu=new hi;class ju extends Ys{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=ue,this.bindMatrix=new di,this.bindMatrixInverse=new di,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const e=this.geometry;null===this.boundingBox&&(this.boundingBox=new kr),this.boundingBox.makeEmpty();const t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,zu),this.boundingBox.expandByPoint(zu)}computeBoundingSphere(){const e=this.geometry;null===this.boundingSphere&&(this.boundingSphere=new ri),this.boundingSphere.makeEmpty();const t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,zu),this.boundingSphere.expandByPoint(zu)}copy(e,t){return super.copy(e,t),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,null!==e.boundingBox&&(this.boundingBox=e.boundingBox.clone()),null!==e.boundingSphere&&(this.boundingSphere=e.boundingSphere.clone()),this}raycast(e,t){const n=this.material,r=this.matrixWorld;void 0!==n&&(null===this.boundingSphere&&this.computeBoundingSphere(),Gu.copy(this.boundingSphere),Gu.applyMatrix4(r),!1!==e.ray.intersectsSphere(Gu)&&(Vu.copy(r).invert(),Wu.copy(e.ray).applyMatrix4(Vu),null!==this.boundingBox&&!1===Wu.intersectsBox(this.boundingBox)||this._computeIntersections(e,t,Wu)))}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){this.skeleton=e,void 0===t&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){const e=new Cr,t=this.geometry.attributes.skinWeight;for(let n=0,r=t.count;n<r;n++){e.fromBufferAttribute(t,n);const r=1/e.manhattanLength();r!==1/0?e.multiplyScalar(r):e.set(1,0,0,0),t.setXYZW(n,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode===ue?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===ce?this.bindMatrixInverse.copy(this.bindMatrix).invert():console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){const n=this.skeleton,r=this.geometry;Fu.fromBufferAttribute(r.attributes.skinIndex,e),Ou.fromBufferAttribute(r.attributes.skinWeight,e),Nu.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let i=0;i<4;i++){const e=Ou.getComponent(i);if(0!==e){const r=Fu.getComponent(i);Hu.multiplyMatrices(n.bones[r].matrixWorld,n.boneInverses[r]),t.addScaledVector(ku.copy(Nu).applyMatrix4(Hu),e)}}return t.applyMatrix4(this.bindMatrixInverse)}}class Xu extends ki{constructor(){super(),this.isBone=!0,this.type="Bone"}}class Ju extends Tr{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;super(null,arguments.length>5?arguments[5]:void 0,arguments.length>6?arguments[6]:void 0,arguments.length>7?arguments[7]:void 0,arguments.length>8&&void 0!==arguments[8]?arguments[8]:xe,arguments.length>9&&void 0!==arguments[9]?arguments[9]:xe,arguments.length>3?arguments[3]:void 0,arguments.length>4?arguments[4]:void 0,arguments.length>10?arguments[10]:void 0,arguments.length>11?arguments[11]:void 0),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const Yu=new di,Ku=new di;class qu{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];this.uuid=Qn(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){const e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(16*e.length),0===t.length)this.calculateInverses();else if(e.length!==t.length){console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let e=0,t=this.bones.length;e<t;e++)this.boneInverses.push(new di)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){const t=new di;this.bones[e]&&t.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(t)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){const t=this.bones[e];t&&t.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){const t=this.bones[e];t&&(t.parent&&t.parent.isBone?(t.matrix.copy(t.parent.matrixWorld).invert(),t.matrix.multiply(t.matrixWorld)):t.matrix.copy(t.matrixWorld),t.matrix.decompose(t.position,t.quaternion,t.scale))}}update(){const e=this.bones,t=this.boneInverses,n=this.boneMatrices,r=this.boneTexture;for(let i=0,s=e.length;i<s;i++){const r=e[i]?e[i].matrixWorld:Ku;Yu.multiplyMatrices(r,t[i]),Yu.toArray(n,16*i)}null!==r&&(r.needsUpdate=!0)}clone(){return new qu(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(4*this.bones.length);e=4*Math.ceil(e/4),e=Math.max(e,4);const t=new Float32Array(e*e*4);t.set(this.boneMatrices);const n=new Ju(t,e,e,We,Ne);return n.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=n,this}getBoneByName(e){for(let t=0,n=this.bones.length;t<n;t++){const n=this.bones[t];if(n.name===e)return n}}dispose(){null!==this.boneTexture&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let n=0,r=e.bones.length;n<r;n++){const r=e.bones[n];let i=t[r];void 0===i&&(console.warn("THREE.Skeleton: No bone found with UUID:",r),i=new Xu),this.bones.push(i),this.boneInverses.push((new di).fromArray(e.boneInverses[n]))}return this.init(),this}toJSON(){const e={metadata:{version:4.6,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;const t=this.bones,n=this.boneInverses;for(let r=0,i=t.length;r<i;r++){const i=t[r];e.bones.push(i.uuid);const s=n[r];e.boneInverses.push(s.toArray())}return e}}class Qu extends ps{constructor(e,t,n){let r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1;super(e,t,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=r}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){const e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}}const Zu=new di,$u=new di,ec=[],tc=new kr,nc=new di,rc=new Ys,ic=new ri;class sc extends Ys{constructor(e,t,n){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new Qu(new Float32Array(16*n),16),this.instanceColor=null,this.morphTexture=null,this.count=n,this.boundingBox=null,this.boundingSphere=null;for(let r=0;r<n;r++)this.setMatrixAt(r,nc)}computeBoundingBox(){const e=this.geometry,t=this.count;null===this.boundingBox&&(this.boundingBox=new kr),null===e.boundingBox&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,Zu),tc.copy(e.boundingBox).applyMatrix4(Zu),this.boundingBox.union(tc)}computeBoundingSphere(){const e=this.geometry,t=this.count;null===this.boundingSphere&&(this.boundingSphere=new ri),null===e.boundingSphere&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,Zu),ic.copy(e.boundingSphere).applyMatrix4(Zu),this.boundingSphere.union(ic)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),null!==e.morphTexture&&(this.morphTexture=e.morphTexture.clone()),null!==e.instanceColor&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,null!==e.boundingBox&&(this.boundingBox=e.boundingBox.clone()),null!==e.boundingSphere&&(this.boundingSphere=e.boundingSphere.clone()),this}getColorAt(e,t){t.fromArray(this.instanceColor.array,3*e)}getMatrixAt(e,t){t.fromArray(this.instanceMatrix.array,16*e)}getMorphAt(e,t){const n=t.morphTargetInfluences,r=this.morphTexture.source.data.data,i=e*(n.length+1)+1;for(let s=0;s<n.length;s++)n[s]=r[i+s]}raycast(e,t){const n=this.matrixWorld,r=this.count;if(rc.geometry=this.geometry,rc.material=this.material,void 0!==rc.material&&(null===this.boundingSphere&&this.computeBoundingSphere(),ic.copy(this.boundingSphere),ic.applyMatrix4(n),!1!==e.ray.intersectsSphere(ic)))for(let i=0;i<r;i++){this.getMatrixAt(i,Zu),$u.multiplyMatrices(n,Zu),rc.matrixWorld=$u,rc.raycast(e,ec);for(let e=0,n=ec.length;e<n;e++){const n=ec[e];n.instanceId=i,n.object=this,t.push(n)}ec.length=0}}setColorAt(e,t){null===this.instanceColor&&(this.instanceColor=new Qu(new Float32Array(3*this.instanceMatrix.count).fill(1),3)),t.toArray(this.instanceColor.array,3*e)}setMatrixAt(e,t){t.toArray(this.instanceMatrix.array,16*e)}setMorphAt(e,t){const n=t.morphTargetInfluences,r=n.length+1;null===this.morphTexture&&(this.morphTexture=new Ju(new Float32Array(r*this.count),r,this.count,Ke,Ne));const i=this.morphTexture.source.data.data;let s=0;for(let l=0;l<n.length;l++)s+=n[l];const a=this.geometry.morphTargetsRelative?1:1-s,o=r*e;i[o]=a,i.set(n,o+1)}updateMorphTargets(){}dispose(){return this.dispatchEvent({type:"dispose"}),null!==this.morphTexture&&(this.morphTexture.dispose(),this.morphTexture=null),this}}function ac(e,t){return e.z-t.z}function oc(e,t){return t.z-e.z}class lc{constructor(){this.index=0,this.pool=[],this.list=[]}push(e,t,n){const r=this.pool,i=this.list;this.index>=r.length&&r.push({start:-1,count:-1,z:-1,index:-1});const s=r[this.index];i.push(s),this.index++,s.start=e.start,s.count=e.count,s.z=t,s.index=n}reset(){this.list.length=0,this.index=0}}const uc=new di,cc=new di,hc=new di,dc=new ts(1,1,1),pc=new di,fc=new va,mc=new kr,gc=new ri,vc=new Nr,yc=new Nr,_c=new Nr,xc=new lc,Ac=new Ys,Mc=[];function bc(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;const r=t.itemSize;if(e.isInterleavedBufferAttribute||e.array.constructor!==t.array.constructor){const i=e.count;for(let s=0;s<i;s++)for(let i=0;i<r;i++)t.setComponent(s+n,i,e.getComponent(s,i))}else t.array.set(e.array,n*r);t.needsUpdate=!0}class Sc extends Ys{get maxInstanceCount(){return this._maxInstanceCount}constructor(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:2*t,r=arguments.length>3?arguments[3]:void 0;super(new Ps,r),this.isBatchedMesh=!0,this.perObjectFrustumCulled=!0,this.sortObjects=!0,this.boundingBox=null,this.boundingSphere=null,this.customSort=null,this._drawInfo=[],this._drawRanges=[],this._reservedRanges=[],this._bounds=[],this._maxInstanceCount=e,this._maxVertexCount=t,this._maxIndexCount=n,this._geometryInitialized=!1,this._geometryCount=0,this._multiDrawCounts=new Int32Array(e),this._multiDrawStarts=new Int32Array(e),this._multiDrawCount=0,this._multiDrawInstances=null,this._visibilityChanged=!0,this._matricesTexture=null,this._indirectTexture=null,this._colorsTexture=null,this._initMatricesTexture(),this._initIndirectTexture()}_initMatricesTexture(){let e=Math.sqrt(4*this._maxInstanceCount);e=4*Math.ceil(e/4),e=Math.max(e,4);const t=new Float32Array(e*e*4),n=new Ju(t,e,e,We,Ne);this._matricesTexture=n}_initIndirectTexture(){let e=Math.sqrt(this._maxInstanceCount);e=Math.ceil(e);const t=new Uint32Array(e*e),n=new Ju(t,e,e,qe,Ue);this._indirectTexture=n}_initColorsTexture(){let e=Math.sqrt(this._maxIndexCount);e=Math.ceil(e);const t=new Float32Array(e*e*4).fill(1),n=new Ju(t,e,e,We,Ne);n.colorSpace=yr.workingColorSpace,this._colorsTexture=n}_initializeGeometry(e){const t=this.geometry,n=this._maxVertexCount,r=this._maxIndexCount;if(!1===this._geometryInitialized){for(const r in e.attributes){const i=e.getAttribute(r),{array:s,itemSize:a,normalized:o}=i,l=new s.constructor(n*a),u=new ps(l,a,o);t.setAttribute(r,u)}if(null!==e.getIndex()){const e=n>65535?new Uint32Array(r):new Uint16Array(r);t.setIndex(new ps(e,1))}this._geometryInitialized=!0}}_validateGeometry(e){const t=this.geometry;if(Boolean(e.getIndex())!==Boolean(t.getIndex()))throw new Error('BatchedMesh: All geometries must consistently have "index".');for(const n in t.attributes){if(!e.hasAttribute(n))throw new Error(`BatchedMesh: Added geometry missing "${n}". All geometries must have consistent attributes.`);const r=e.getAttribute(n),i=t.getAttribute(n);if(r.itemSize!==i.itemSize||r.normalized!==i.normalized)throw new Error("BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}setCustomSort(e){return this.customSort=e,this}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new kr);const e=this._geometryCount,t=this.boundingBox,n=this._drawInfo;t.makeEmpty();for(let r=0;r<e;r++){if(!1===n[r].active)continue;const e=n[r].geometryIndex;this.getMatrixAt(r,uc),this.getBoundingBoxAt(e,mc).applyMatrix4(uc),t.union(mc)}}computeBoundingSphere(){null===this.boundingSphere&&(this.boundingSphere=new ri);const e=this.boundingSphere,t=this._drawInfo;e.makeEmpty();for(let n=0,r=t.length;n<r;n++){if(!1===t[n].active)continue;const r=t[n].geometryIndex;this.getMatrixAt(n,uc),this.getBoundingSphereAt(r,gc).applyMatrix4(uc),e.union(gc)}}addInstance(e){if(this._drawInfo.length>=this._maxInstanceCount)throw new Error("BatchedMesh: Maximum item count reached.");this._drawInfo.push({visible:!0,active:!0,geometryIndex:e});const t=this._drawInfo.length-1,n=this._matricesTexture,r=n.image.data;hc.toArray(r,16*t),n.needsUpdate=!0;const i=this._colorsTexture;return i&&(dc.toArray(i.image.data,4*t),i.needsUpdate=!0),t}addGeometry(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:-1,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:-1;if(this._initializeGeometry(e),this._validateGeometry(e),this._drawInfo.length>=this._maxInstanceCount)throw new Error("BatchedMesh: Maximum item count reached.");const r={vertexStart:-1,vertexCount:-1,indexStart:-1,indexCount:-1};let i=null;const s=this._reservedRanges,a=this._drawRanges,o=this._bounds;0!==this._geometryCount&&(i=s[s.length-1]),r.vertexCount=-1===t?e.getAttribute("position").count:t,r.vertexStart=null===i?0:i.vertexStart+i.vertexCount;const l=e.getIndex(),u=null!==l;if(u&&(r.indexCount=-1===n?l.count:n,r.indexStart=null===i?0:i.indexStart+i.indexCount),-1!==r.indexStart&&r.indexStart+r.indexCount>this._maxIndexCount||r.vertexStart+r.vertexCount>this._maxVertexCount)throw new Error("BatchedMesh: Reserved space request exceeds the maximum buffer size.");const c=this._geometryCount;return this._geometryCount++,s.push(r),a.push({start:u?r.indexStart:r.vertexStart,count:-1}),o.push({boxInitialized:!1,box:new kr,sphereInitialized:!1,sphere:new ri}),this.setGeometryAt(c,e),c}setGeometryAt(e,t){if(e>=this._geometryCount)throw new Error("BatchedMesh: Maximum geometry count reached.");this._validateGeometry(t);const n=this.geometry,r=null!==n.getIndex(),i=n.getIndex(),s=t.getIndex(),a=this._reservedRanges[e];if(r&&s.count>a.indexCount||t.attributes.position.count>a.vertexCount)throw new Error("BatchedMesh: Reserved space not large enough for provided geometry.");const o=a.vertexStart,l=a.vertexCount;for(const d in n.attributes){const e=t.getAttribute(d),r=n.getAttribute(d);bc(e,r,o);const i=e.itemSize;for(let t=e.count,n=l;t<n;t++){const e=o+t;for(let t=0;t<i;t++)r.setComponent(e,t,0)}r.needsUpdate=!0,r.addUpdateRange(o*i,l*i)}if(r){const e=a.indexStart;for(let t=0;t<s.count;t++)i.setX(e+t,o+s.getX(t));for(let t=s.count,n=a.indexCount;t<n;t++)i.setX(e+t,o);i.needsUpdate=!0,i.addUpdateRange(e,a.indexCount)}const u=this._bounds[e];null!==t.boundingBox?(u.box.copy(t.boundingBox),u.boxInitialized=!0):u.boxInitialized=!1,null!==t.boundingSphere?(u.sphere.copy(t.boundingSphere),u.sphereInitialized=!0):u.sphereInitialized=!1;const c=this._drawRanges[e],h=t.getAttribute("position");return c.count=r?s.count:h.count,this._visibilityChanged=!0,e}getBoundingBoxAt(e,t){if(e>=this._geometryCount)return null;const n=this._bounds[e],r=n.box,i=this.geometry;if(!1===n.boxInitialized){r.makeEmpty();const t=i.index,s=i.attributes.position,a=this._drawRanges[e];for(let e=a.start,n=a.start+a.count;e<n;e++){let n=e;t&&(n=t.getX(n)),r.expandByPoint(vc.fromBufferAttribute(s,n))}n.boxInitialized=!0}return t.copy(r),t}getBoundingSphereAt(e,t){if(e>=this._geometryCount)return null;const n=this._bounds[e],r=n.sphere,i=this.geometry;if(!1===n.sphereInitialized){r.makeEmpty(),this.getBoundingBoxAt(e,mc),mc.getCenter(r.center);const t=i.index,s=i.attributes.position,a=this._drawRanges[e];let o=0;for(let e=a.start,n=a.start+a.count;e<n;e++){let n=e;t&&(n=t.getX(n)),vc.fromBufferAttribute(s,n),o=Math.max(o,r.center.distanceToSquared(vc))}r.radius=Math.sqrt(o),n.sphereInitialized=!0}return t.copy(r),t}setMatrixAt(e,t){const n=this._drawInfo,r=this._matricesTexture,i=this._matricesTexture.image.data;return e>=n.length||!1===n[e].active||(t.toArray(i,16*e),r.needsUpdate=!0),this}getMatrixAt(e,t){const n=this._drawInfo,r=this._matricesTexture.image.data;return e>=n.length||!1===n[e].active?null:t.fromArray(r,16*e)}setColorAt(e,t){null===this._colorsTexture&&this._initColorsTexture();const n=this._colorsTexture,r=this._colorsTexture.image.data,i=this._drawInfo;return e>=i.length||!1===i[e].active||(t.toArray(r,4*e),n.needsUpdate=!0),this}getColorAt(e,t){const n=this._colorsTexture.image.data,r=this._drawInfo;return e>=r.length||!1===r[e].active?null:t.fromArray(n,4*e)}setVisibleAt(e,t){const n=this._drawInfo;return e>=n.length||!1===n[e].active||n[e].visible===t||(n[e].visible=t,this._visibilityChanged=!0),this}getVisibleAt(e){const t=this._drawInfo;return!(e>=t.length||!1===t[e].active)&&t[e].visible}raycast(e,t){const n=this._drawInfo,r=this._drawRanges,i=this.matrixWorld,s=this.geometry;Ac.material=this.material,Ac.geometry.index=s.index,Ac.geometry.attributes=s.attributes,null===Ac.geometry.boundingBox&&(Ac.geometry.boundingBox=new kr),null===Ac.geometry.boundingSphere&&(Ac.geometry.boundingSphere=new ri);for(let a=0,o=n.length;a<o;a++){if(!n[a].visible||!n[a].active)continue;const s=n[a].geometryIndex,o=r[s];Ac.geometry.setDrawRange(o.start,o.count),this.getMatrixAt(a,Ac.matrixWorld).premultiply(i),this.getBoundingBoxAt(s,Ac.geometry.boundingBox),this.getBoundingSphereAt(s,Ac.geometry.boundingSphere),Ac.raycast(e,Mc);for(let e=0,n=Mc.length;e<n;e++){const n=Mc[e];n.object=this,n.batchId=a,t.push(n)}Mc.length=0}Ac.material=null,Ac.geometry.index=null,Ac.geometry.attributes={},Ac.geometry.setDrawRange(0,1/0)}copy(e){return super.copy(e),this.geometry=e.geometry.clone(),this.perObjectFrustumCulled=e.perObjectFrustumCulled,this.sortObjects=e.sortObjects,this.boundingBox=null!==e.boundingBox?e.boundingBox.clone():null,this.boundingSphere=null!==e.boundingSphere?e.boundingSphere.clone():null,this._drawRanges=e._drawRanges.map((e=>({...e}))),this._reservedRanges=e._reservedRanges.map((e=>({...e}))),this._drawInfo=e._drawInfo.map((e=>({...e}))),this._bounds=e._bounds.map((e=>({boxInitialized:e.boxInitialized,box:e.box.clone(),sphereInitialized:e.sphereInitialized,sphere:e.sphere.clone()}))),this._maxInstanceCount=e._maxInstanceCount,this._maxVertexCount=e._maxVertexCount,this._maxIndexCount=e._maxIndexCount,this._geometryInitialized=e._geometryInitialized,this._geometryCount=e._geometryCount,this._multiDrawCounts=e._multiDrawCounts.slice(),this._multiDrawStarts=e._multiDrawStarts.slice(),this._matricesTexture=e._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.data.slice(),null!==this._colorsTexture&&(this._colorsTexture=e._colorsTexture.clone(),this._colorsTexture.image.data=this._colorsTexture.image.data.slice()),this}dispose(){return this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this._indirectTexture.dispose(),this._indirectTexture=null,null!==this._colorsTexture&&(this._colorsTexture.dispose(),this._colorsTexture=null),this}onBeforeRender(e,t,n,r,i){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;const s=r.getIndex(),a=null===s?1:s.array.BYTES_PER_ELEMENT,o=this._drawInfo,l=this._multiDrawStarts,u=this._multiDrawCounts,c=this._drawRanges,h=this.perObjectFrustumCulled,d=this._indirectTexture,p=d.image.data;h&&(pc.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse).multiply(this.matrixWorld),fc.setFromProjectionMatrix(pc,e.coordinateSystem));let f=0;if(this.sortObjects){cc.copy(this.matrixWorld).invert(),vc.setFromMatrixPosition(n.matrixWorld).applyMatrix4(cc),yc.set(0,0,-1).transformDirection(n.matrixWorld).transformDirection(cc);for(let n=0,r=o.length;n<r;n++)if(o[n].visible&&o[n].active){const e=o[n].geometryIndex;this.getMatrixAt(n,uc),this.getBoundingSphereAt(e,gc).applyMatrix4(uc);let t=!1;if(h&&(t=!fc.intersectsSphere(gc)),!t){const t=_c.subVectors(gc.center,vc).dot(yc);xc.push(c[e],t,n)}}const e=xc.list,t=this.customSort;null===t?e.sort(i.transparent?oc:ac):t.call(this,e,n);for(let n=0,r=e.length;n<r;n++){const t=e[n];l[f]=t.start*a,u[f]=t.count,p[f]=t.index,f++}xc.reset()}else for(let m=0,g=o.length;m<g;m++)if(o[m].visible&&o[m].active){const e=o[m].geometryIndex;let t=!1;if(h&&(this.getMatrixAt(m,uc),this.getBoundingSphereAt(e,gc).applyMatrix4(uc),t=!fc.intersectsSphere(gc)),!t){const t=c[e];l[f]=t.start*a,u[f]=t.count,p[f]=m,f++}}d.needsUpdate=!0,this._multiDrawCount=f,this._visibilityChanged=!1}onBeforeShadow(e,t,n,r,i,s){this.onBeforeRender(e,null,r,i,s)}}class wc extends is{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new ts(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}const Ec=new Nr,Tc=new Nr,Cc=new di,Rc=new hi,Pc=new ri,Ic=new Nr,Bc=new Nr;class Lc extends ki{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new Ps,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new wc;super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(null===e.index){const t=e.attributes.position,n=[0];for(let e=1,r=t.count;e<r;e++)Ec.fromBufferAttribute(t,e-1),Tc.fromBufferAttribute(t,e),n[e]=n[e-1],n[e]+=Ec.distanceTo(Tc);e.setAttribute("lineDistance",new Ms(n,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){const n=this.geometry,r=this.matrixWorld,i=e.params.Line.threshold,s=n.drawRange;if(null===n.boundingSphere&&n.computeBoundingSphere(),Pc.copy(n.boundingSphere),Pc.applyMatrix4(r),Pc.radius+=i,!1===e.ray.intersectsSphere(Pc))return;Cc.copy(r).invert(),Rc.copy(e.ray).applyMatrix4(Cc);const a=i/((this.scale.x+this.scale.y+this.scale.z)/3),o=a*a,l=this.isLineSegments?2:1,u=n.index,c=n.attributes.position;if(null!==u){const n=Math.max(0,s.start),r=Math.min(u.count,s.start+s.count);for(let i=n,s=r-1;i<s;i+=l){const n=u.getX(i),r=u.getX(i+1),s=Dc(this,e,Rc,o,n,r);s&&t.push(s)}if(this.isLineLoop){const i=u.getX(r-1),s=u.getX(n),a=Dc(this,e,Rc,o,i,s);a&&t.push(a)}}else{const n=Math.max(0,s.start),r=Math.min(c.count,s.start+s.count);for(let i=n,s=r-1;i<s;i+=l){const n=Dc(this,e,Rc,o,i,i+1);n&&t.push(n)}if(this.isLineLoop){const i=Dc(this,e,Rc,o,r-1,n);i&&t.push(i)}}}updateMorphTargets(){const e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){const n=e[t[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e<t;e++){const t=n[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[t]=e}}}}}function Dc(e,t,n,r,i,s){const a=e.geometry.attributes.position;Ec.fromBufferAttribute(a,i),Tc.fromBufferAttribute(a,s);if(n.distanceSqToSegment(Ec,Tc,Ic,Bc)>r)return;Ic.applyMatrix4(e.matrixWorld);const o=t.ray.origin.distanceTo(Ic);return o<t.near||o>t.far?void 0:{distance:o,point:Bc.clone().applyMatrix4(e.matrixWorld),index:i,face:null,faceIndex:null,object:e}}const Uc=new Nr,Nc=new Nr;class Fc extends Lc{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(null===e.index){const t=e.attributes.position,n=[];for(let e=0,r=t.count;e<r;e+=2)Uc.fromBufferAttribute(t,e),Nc.fromBufferAttribute(t,e+1),n[e]=0===e?0:n[e-1],n[e+1]=n[e]+Uc.distanceTo(Nc);e.setAttribute("lineDistance",new Ms(n,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class Oc extends Lc{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}}class kc extends is{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new ts(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}const Hc=new di,zc=new hi,Gc=new ri,Vc=new Nr;class Wc extends ki{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new Ps,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new kc;super(),this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}raycast(e,t){const n=this.geometry,r=this.matrixWorld,i=e.params.Points.threshold,s=n.drawRange;if(null===n.boundingSphere&&n.computeBoundingSphere(),Gc.copy(n.boundingSphere),Gc.applyMatrix4(r),Gc.radius+=i,!1===e.ray.intersectsSphere(Gc))return;Hc.copy(r).invert(),zc.copy(e.ray).applyMatrix4(Hc);const a=i/((this.scale.x+this.scale.y+this.scale.z)/3),o=a*a,l=n.index,u=n.attributes.position;if(null!==l){for(let n=Math.max(0,s.start),i=Math.min(l.count,s.start+s.count);n<i;n++){const i=l.getX(n);Vc.fromBufferAttribute(u,i),jc(Vc,i,o,r,e,t,this)}}else{for(let n=Math.max(0,s.start),i=Math.min(u.count,s.start+s.count);n<i;n++)Vc.fromBufferAttribute(u,n),jc(Vc,n,o,r,e,t,this)}}updateMorphTargets(){const e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){const n=e[t[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e<t;e++){const t=n[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[t]=e}}}}}function jc(e,t,n,r,i,s,a){const o=zc.distanceSqToPoint(e);if(o<n){const n=new Nr;zc.closestPointToPoint(e,n),n.applyMatrix4(r);const l=i.ray.origin.distanceTo(n);if(l<i.near||l>i.far)return;s.push({distance:l,distanceToRay:Math.sqrt(o),point:n,index:t,face:null,object:a})}}class Xc extends Tr{constructor(e,t,n,r,i,s,a,o,l){super(e,t,n,r,i,s,a,o,l),this.isVideoTexture=!0,this.minFilter=void 0!==s?s:we,this.magFilter=void 0!==i?i:we,this.generateMipmaps=!1;const u=this;"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback((function t(){u.needsUpdate=!0,e.requestVideoFrameCallback(t)}))}clone(){return new this.constructor(this.image).copy(this)}update(){const e=this.image;!1==="requestVideoFrameCallback"in e&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}class Jc extends Tr{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=xe,this.minFilter=xe,this.generateMipmaps=!1,this.needsUpdate=!0}}class Yc extends Tr{constructor(e,t,n,r,i,s,a,o,l,u,c,h){super(null,s,a,o,l,u,r,i,c,h),this.isCompressedTexture=!0,this.image={width:t,height:n},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}}class Kc extends Yc{constructor(e,t,n,r,i,s){super(e,t,n,i,s),this.isCompressedArrayTexture=!0,this.image.depth=r,this.wrapR=ye,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class qc extends Yc{constructor(e,t,n){super(void 0,e[0].width,e[0].height,t,n,de),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=e}}class Qc extends Tr{constructor(e,t,n,r,i,s,a,o,l){super(e,t,n,r,i,s,a,o,l),this.isCanvasTexture=!0,this.needsUpdate=!0}}class Zc{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){const n=this.getUtoTmapping(e);return this.getPoint(n,t)}getPoints(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:5;const t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return t}getSpacedPoints(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:5;const t=[];for(let n=0;n<=e;n++)t.push(this.getPointAt(n/e));return t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.arcLengthDivisions;if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const t=[];let n,r=this.getPoint(0),i=0;t.push(0);for(let s=1;s<=e;s++)n=this.getPoint(s/e),i+=n.distanceTo(r),t.push(i),r=n;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){const n=this.getLengths();let r=0;const i=n.length;let s;s=t||e*n[i-1];let a,o=0,l=i-1;for(;o<=l;)if(r=Math.floor(o+(l-o)/2),a=n[r]-s,a<0)o=r+1;else{if(!(a>0)){l=r;break}l=r-1}if(r=l,n[r]===s)return r/(i-1);const u=n[r];return(r+(s-u)/(n[r+1]-u))/(i-1)}getTangent(e,t){const n=1e-4;let r=e-n,i=e+n;r<0&&(r=0),i>1&&(i=1);const s=this.getPoint(r),a=this.getPoint(i),o=t||(s.isVector2?new ir:new Nr);return o.copy(a).sub(s).normalize(),o}getTangentAt(e,t){const n=this.getUtoTmapping(e);return this.getTangent(n,t)}computeFrenetFrames(e,t){const n=new Nr,r=[],i=[],s=[],a=new Nr,o=new di;for(let d=0;d<=e;d++){const t=d/e;r[d]=this.getTangentAt(t,new Nr)}i[0]=new Nr,s[0]=new Nr;let l=Number.MAX_VALUE;const u=Math.abs(r[0].x),c=Math.abs(r[0].y),h=Math.abs(r[0].z);u<=l&&(l=u,n.set(1,0,0)),c<=l&&(l=c,n.set(0,1,0)),h<=l&&n.set(0,0,1),a.crossVectors(r[0],n).normalize(),i[0].crossVectors(r[0],a),s[0].crossVectors(r[0],i[0]);for(let d=1;d<=e;d++){if(i[d]=i[d-1].clone(),s[d]=s[d-1].clone(),a.crossVectors(r[d-1],r[d]),a.length()>Number.EPSILON){a.normalize();const e=Math.acos(Zn(r[d-1].dot(r[d]),-1,1));i[d].applyMatrix4(o.makeRotationAxis(a,e))}s[d].crossVectors(r[d],i[d])}if(!0===t){let t=Math.acos(Zn(i[0].dot(i[e]),-1,1));t/=e,r[0].dot(a.crossVectors(i[0],i[e]))>0&&(t=-t);for(let n=1;n<=e;n++)i[n].applyMatrix4(o.makeRotationAxis(r[n],t*n)),s[n].crossVectors(r[n],i[n])}return{tangents:r,normals:i,binormals:s}}clone(){return(new this.constructor).copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.6,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class $c extends Zc{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,s=arguments.length>5&&void 0!==arguments[5]?arguments[5]:2*Math.PI,a=arguments.length>6&&void 0!==arguments[6]&&arguments[6],o=arguments.length>7&&void 0!==arguments[7]?arguments[7]: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=s,this.aClockwise=a,this.aRotation=o}getPoint(e){const t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new ir,n=2*Math.PI;let r=this.aEndAngle-this.aStartAngle;const i=Math.abs(r)<Number.EPSILON;for(;r<0;)r+=n;for(;r>n;)r-=n;r<Number.EPSILON&&(r=i?0:n),!0!==this.aClockwise||i||(r===n?r=-n:r-=n);const s=this.aStartAngle+e*r;let a=this.aX+this.xRadius*Math.cos(s),o=this.aY+this.yRadius*Math.sin(s);if(0!==this.aRotation){const e=Math.cos(this.aRotation),t=Math.sin(this.aRotation),n=a-this.aX,r=o-this.aY;a=n*e-r*t+this.aX,o=n*t+r*e+this.aY}return t.set(a,o)}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(){const 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}}class eh extends $c{constructor(e,t,n,r,i,s){super(e,t,n,n,r,i,s),this.isArcCurve=!0,this.type="ArcCurve"}}function th(){let e=0,t=0,n=0,r=0;function i(i,s,a,o){e=i,t=a,n=-3*i+3*s-2*a-o,r=2*i-2*s+a+o}return{initCatmullRom:function(e,t,n,r,s){i(t,n,s*(n-e),s*(r-t))},initNonuniformCatmullRom:function(e,t,n,r,s,a,o){let l=(t-e)/s-(n-e)/(s+a)+(n-t)/a,u=(n-t)/a-(r-t)/(a+o)+(r-n)/o;l*=a,u*=a,i(t,n,l,u)},calc:function(i){const s=i*i;return e+t*i+n*s+r*(s*i)}}}const nh=new Nr,rh=new th,ih=new th,sh=new th;class ah extends Zc{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"centripetal",r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:.5;super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=n,this.tension=r}getPoint(e){const t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new Nr,n=this.points,r=n.length,i=(r-(this.closed?0:1))*e;let s,a,o=Math.floor(i),l=i-o;this.closed?o+=o>0?0:(Math.floor(Math.abs(o)/r)+1)*r:0===l&&o===r-1&&(o=r-2,l=1),this.closed||o>0?s=n[(o-1)%r]:(nh.subVectors(n[0],n[1]).add(n[0]),s=nh);const u=n[o%r],c=n[(o+1)%r];if(this.closed||o+2<r?a=n[(o+2)%r]:(nh.subVectors(n[r-1],n[r-2]).add(n[r-1]),a=nh),"centripetal"===this.curveType||"chordal"===this.curveType){const e="chordal"===this.curveType?.5:.25;let t=Math.pow(s.distanceToSquared(u),e),n=Math.pow(u.distanceToSquared(c),e),r=Math.pow(c.distanceToSquared(a),e);n<1e-4&&(n=1),t<1e-4&&(t=n),r<1e-4&&(r=n),rh.initNonuniformCatmullRom(s.x,u.x,c.x,a.x,t,n,r),ih.initNonuniformCatmullRom(s.y,u.y,c.y,a.y,t,n,r),sh.initNonuniformCatmullRom(s.z,u.z,c.z,a.z,t,n,r)}else"catmullrom"===this.curveType&&(rh.initCatmullRom(s.x,u.x,c.x,a.x,this.tension),ih.initCatmullRom(s.y,u.y,c.y,a.y,this.tension),sh.initCatmullRom(s.z,u.z,c.z,a.z,this.tension));return t.set(rh.calc(l),ih.calc(l),sh.calc(l)),t}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const n=e.points[t];this.points.push(n.clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,n=this.points.length;t<n;t++){const n=this.points[t];e.points.push(n.toArray())}return e.closed=this.closed,e.curveType=this.curveType,e.tension=this.tension,e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const n=e.points[t];this.points.push((new Nr).fromArray(n))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}}function oh(e,t,n,r,i){const s=.5*(r-t),a=.5*(i-n),o=e*e;return(2*n-2*r+s+a)*(e*o)+(-3*n+3*r-2*s-a)*o+s*e+n}function lh(e,t,n,r){return function(e,t){const n=1-e;return n*n*t}(e,t)+function(e,t){return 2*(1-e)*e*t}(e,n)+function(e,t){return e*e*t}(e,r)}function uh(e,t,n,r,i){return function(e,t){const n=1-e;return n*n*n*t}(e,t)+function(e,t){const n=1-e;return 3*n*n*e*t}(e,n)+function(e,t){return 3*(1-e)*e*e*t}(e,r)+function(e,t){return e*e*e*t}(e,i)}class ch extends Zc{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new ir,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new ir,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new ir,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:new ir;super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=n,this.v3=r}getPoint(e){const t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new ir,n=this.v0,r=this.v1,i=this.v2,s=this.v3;return t.set(uh(e,n.x,r.x,i.x,s.x),uh(e,n.y,r.y,i.y,s.y)),t}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}}class hh extends Zc{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new Nr,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new Nr,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new Nr,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:new Nr;super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=n,this.v3=r}getPoint(e){const t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new Nr,n=this.v0,r=this.v1,i=this.v2,s=this.v3;return t.set(uh(e,n.x,r.x,i.x,s.x),uh(e,n.y,r.y,i.y,s.y),uh(e,n.z,r.z,i.z,s.z)),t}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}}class dh extends Zc{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new ir,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new ir;super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e){const t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new ir;return 1===e?t.copy(this.v2):(t.copy(this.v2).sub(this.v1),t.multiplyScalar(e).add(this.v1)),t}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e){return(arguments.length>1&&void 0!==arguments[1]?arguments[1]:new ir).subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class ph extends Zc{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new Nr,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new Nr;super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e){const t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new Nr;return 1===e?t.copy(this.v2):(t.copy(this.v2).sub(this.v1),t.multiplyScalar(e).add(this.v1)),t}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e){return(arguments.length>1&&void 0!==arguments[1]?arguments[1]:new Nr).subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class fh extends Zc{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new ir,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new ir,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new ir;super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=n}getPoint(e){const t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new ir,n=this.v0,r=this.v1,i=this.v2;return t.set(lh(e,n.x,r.x,i.x),lh(e,n.y,r.y,i.y)),t}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class mh extends Zc{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new Nr,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new Nr,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new Nr;super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=n}getPoint(e){const t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new Nr,n=this.v0,r=this.v1,i=this.v2;return t.set(lh(e,n.x,r.x,i.x),lh(e,n.y,r.y,i.y),lh(e,n.z,r.z,i.z)),t}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class gh extends Zc{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e){const t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new ir,n=this.points,r=(n.length-1)*e,i=Math.floor(r),s=r-i,a=n[0===i?i:i-1],o=n[i],l=n[i>n.length-2?n.length-1:i+1],u=n[i>n.length-3?n.length-1:i+2];return t.set(oh(s,a.x,o.x,l.x,u.x),oh(s,a.y,o.y,l.y,u.y)),t}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const n=e.points[t];this.points.push(n.clone())}return this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,n=this.points.length;t<n;t++){const n=this.points[t];e.points.push(n.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const n=e.points[t];this.points.push((new ir).fromArray(n))}return this}}var vh=Object.freeze({__proto__:null,ArcCurve:eh,CatmullRomCurve3:ah,CubicBezierCurve:ch,CubicBezierCurve3:hh,EllipseCurve:$c,LineCurve:dh,LineCurve3:ph,QuadraticBezierCurve:fh,QuadraticBezierCurve3:mh,SplineCurve:gh});class yh extends Zc{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(e){this.curves.push(e)}closePath(){const e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);if(!e.equals(t)){const n=!0===e.isVector2?"LineCurve":"LineCurve3";this.curves.push(new vh[n](t,e))}return this}getPoint(e,t){const n=e*this.getLength(),r=this.getCurveLengths();let i=0;for(;i<r.length;){if(r[i]>=n){const e=r[i]-n,s=this.curves[i],a=s.getLength(),o=0===a?0:1-e/a;return s.getPointAt(o,t)}i++}return null}getLength(){const e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const e=[];let t=0;for(let n=0,r=this.curves.length;n<r;n++)t+=this.curves[n].getLength(),e.push(t);return this.cacheLengths=e,e}getSpacedPoints(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:40;const t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return this.autoClose&&t.push(t[0]),t}getPoints(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:12;const t=[];let n;for(let r=0,i=this.curves;r<i.length;r++){const s=i[r],a=s.isEllipseCurve?2*e:s.isLineCurve||s.isLineCurve3?1:s.isSplineCurve?e*s.points.length:e,o=s.getPoints(a);for(let e=0;e<o.length;e++){const r=o[e];n&&n.equals(r)||(t.push(r),n=r)}}return this.autoClose&&t.length>1&&!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;t<n;t++){const n=e.curves[t];this.curves.push(n.clone())}return this.autoClose=e.autoClose,this}toJSON(){const e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let t=0,n=this.curves.length;t<n;t++){const n=this.curves[t];e.curves.push(n.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,n=e.curves.length;t<n;t++){const n=e.curves[t];this.curves.push((new vh[n.type]).fromJSON(n))}return this}}class _h extends yh{constructor(e){super(),this.type="Path",this.currentPoint=new ir,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,n=e.length;t<n;t++)this.lineTo(e[t].x,e[t].y);return this}moveTo(e,t){return this.currentPoint.set(e,t),this}lineTo(e,t){const n=new dh(this.currentPoint.clone(),new ir(e,t));return this.curves.push(n),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,n,r){const i=new fh(this.currentPoint.clone(),new ir(e,t),new ir(n,r));return this.curves.push(i),this.currentPoint.set(n,r),this}bezierCurveTo(e,t,n,r,i,s){const a=new ch(this.currentPoint.clone(),new ir(e,t),new ir(n,r),new ir(i,s));return this.curves.push(a),this.currentPoint.set(i,s),this}splineThru(e){const t=[this.currentPoint.clone()].concat(e),n=new gh(t);return this.curves.push(n),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,n,r,i,s){const a=this.currentPoint.x,o=this.currentPoint.y;return this.absarc(e+a,t+o,n,r,i,s),this}absarc(e,t,n,r,i,s){return this.absellipse(e,t,n,n,r,i,s),this}ellipse(e,t,n,r,i,s,a,o){const l=this.currentPoint.x,u=this.currentPoint.y;return this.absellipse(e+l,t+u,n,r,i,s,a,o),this}absellipse(e,t,n,r,i,s,a,o){const l=new $c(e,t,n,r,i,s,a,o);if(this.curves.length>0){const e=l.getPoint(0);e.equals(this.currentPoint)||this.lineTo(e.x,e.y)}this.curves.push(l);const u=l.getPoint(1);return this.currentPoint.copy(u),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){const e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}}class xh extends Ps{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[new ir(0,-.5),new ir(.5,0),new ir(0,.5)],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:12,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:2*Math.PI;super(),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:n,phiLength:r},t=Math.floor(t),r=Zn(r,0,2*Math.PI);const i=[],s=[],a=[],o=[],l=[],u=1/t,c=new Nr,h=new ir,d=new Nr,p=new Nr,f=new Nr;let m=0,g=0;for(let v=0;v<=e.length-1;v++)switch(v){case 0:m=e[v+1].x-e[v].x,g=e[v+1].y-e[v].y,d.x=1*g,d.y=-m,d.z=0*g,f.copy(d),d.normalize(),o.push(d.x,d.y,d.z);break;case e.length-1:o.push(f.x,f.y,f.z);break;default:m=e[v+1].x-e[v].x,g=e[v+1].y-e[v].y,d.x=1*g,d.y=-m,d.z=0*g,p.copy(d),d.x+=f.x,d.y+=f.y,d.z+=f.z,d.normalize(),o.push(d.x,d.y,d.z),f.copy(p)}for(let v=0;v<=t;v++){const i=n+v*u*r,d=Math.sin(i),p=Math.cos(i);for(let n=0;n<=e.length-1;n++){c.x=e[n].x*d,c.y=e[n].y,c.z=e[n].x*p,s.push(c.x,c.y,c.z),h.x=v/t,h.y=n/(e.length-1),a.push(h.x,h.y);const r=o[3*n+0]*d,i=o[3*n+1],u=o[3*n+0]*p;l.push(r,i,u)}}for(let v=0;v<t;v++)for(let t=0;t<e.length-1;t++){const n=t+v*e.length,r=n,s=n+e.length,a=n+e.length+1,o=n+1;i.push(r,s,o),i.push(a,o,s)}this.setIndex(i),this.setAttribute("position",new Ms(s,3)),this.setAttribute("uv",new Ms(a,2)),this.setAttribute("normal",new Ms(l,3))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new xh(e.points,e.segments,e.phiStart,e.phiLength)}}class Ah extends xh{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:4,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:8;const i=new _h;i.absarc(0,-t/2,e,1.5*Math.PI,0),i.absarc(0,t/2,e,0,.5*Math.PI),super(i.getPoints(n),r),this.type="CapsuleGeometry",this.parameters={radius:e,length:t,capSegments:n,radialSegments:r}}static fromJSON(e){return new Ah(e.radius,e.length,e.capSegments,e.radialSegments)}}class Mh extends Ps{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:32,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:2*Math.PI;super(),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:n,thetaLength:r},t=Math.max(3,t);const i=[],s=[],a=[],o=[],l=new Nr,u=new ir;s.push(0,0,0),a.push(0,0,1),o.push(.5,.5);for(let c=0,h=3;c<=t;c++,h+=3){const i=n+c/t*r;l.x=e*Math.cos(i),l.y=e*Math.sin(i),s.push(l.x,l.y,l.z),a.push(0,0,1),u.x=(s[h]/e+1)/2,u.y=(s[h+1]/e+1)/2,o.push(u.x,u.y)}for(let c=1;c<=t;c++)i.push(c,c+1,0);this.setIndex(i),this.setAttribute("position",new Ms(s,3)),this.setAttribute("normal",new Ms(a,3)),this.setAttribute("uv",new Ms(o,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Mh(e.radius,e.segments,e.thetaStart,e.thetaLength)}}class bh extends Ps{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:32,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:1,s=arguments.length>5&&void 0!==arguments[5]&&arguments[5],a=arguments.length>6&&void 0!==arguments[6]?arguments[6]:0,o=arguments.length>7&&void 0!==arguments[7]?arguments[7]:2*Math.PI;super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:n,radialSegments:r,heightSegments:i,openEnded:s,thetaStart:a,thetaLength:o};const l=this;r=Math.floor(r),i=Math.floor(i);const u=[],c=[],h=[],d=[];let p=0;const f=[],m=n/2;let g=0;function v(n){const i=p,s=new ir,f=new Nr;let v=0;const y=!0===n?e:t,_=!0===n?1:-1;for(let e=1;e<=r;e++)c.push(0,m*_,0),h.push(0,_,0),d.push(.5,.5),p++;const x=p;for(let e=0;e<=r;e++){const t=e/r*o+a,n=Math.cos(t),i=Math.sin(t);f.x=y*i,f.y=m*_,f.z=y*n,c.push(f.x,f.y,f.z),h.push(0,_,0),s.x=.5*n+.5,s.y=.5*i*_+.5,d.push(s.x,s.y),p++}for(let e=0;e<r;e++){const t=i+e,r=x+e;!0===n?u.push(r,r+1,t):u.push(r+1,r,t),v+=3}l.addGroup(g,v,!0===n?1:2),g+=v}!function(){const s=new Nr,v=new Nr;let y=0;const _=(t-e)/n;for(let l=0;l<=i;l++){const u=[],g=l/i,y=g*(t-e)+e;for(let e=0;e<=r;e++){const t=e/r,i=t*o+a,l=Math.sin(i),f=Math.cos(i);v.x=y*l,v.y=-g*n+m,v.z=y*f,c.push(v.x,v.y,v.z),s.set(l,_,f).normalize(),h.push(s.x,s.y,s.z),d.push(t,1-g),u.push(p++)}f.push(u)}for(let e=0;e<r;e++)for(let t=0;t<i;t++){const n=f[t][e],r=f[t+1][e],i=f[t+1][e+1],s=f[t][e+1];u.push(n,r,s),u.push(r,i,s),y+=6}l.addGroup(g,y,0),g+=y}(),!1===s&&(e>0&&v(!0),t>0&&v(!1)),this.setIndex(u),this.setAttribute("position",new Ms(c,3)),this.setAttribute("normal",new Ms(h,3)),this.setAttribute("uv",new Ms(d,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new bh(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class Sh extends bh{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:32,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1,i=arguments.length>4&&void 0!==arguments[4]&&arguments[4],s=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0,a=arguments.length>6&&void 0!==arguments[6]?arguments[6]:2*Math.PI;super(0,e,t,n,r,i,s,a),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:n,heightSegments:r,openEnded:i,thetaStart:s,thetaLength:a}}static fromJSON(e){return new Sh(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class wh extends Ps{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:n,detail:r};const i=[],s=[];function a(e,t,n,r){const i=r+1,s=[];for(let a=0;a<=i;a++){s[a]=[];const r=e.clone().lerp(n,a/i),o=t.clone().lerp(n,a/i),l=i-a;for(let e=0;e<=l;e++)s[a][e]=0===e&&a===i?r:r.clone().lerp(o,e/l)}for(let a=0;a<i;a++)for(let e=0;e<2*(i-a)-1;e++){const t=Math.floor(e/2);e%2===0?(o(s[a][t+1]),o(s[a+1][t]),o(s[a][t])):(o(s[a][t+1]),o(s[a+1][t+1]),o(s[a+1][t]))}}function o(e){i.push(e.x,e.y,e.z)}function l(t,n){const r=3*t;n.x=e[r+0],n.y=e[r+1],n.z=e[r+2]}function u(e,t,n,r){r<0&&1===e.x&&(s[t]=e.x-1),0===n.x&&0===n.z&&(s[t]=r/2/Math.PI+.5)}function c(e){return Math.atan2(e.z,-e.x)}!function(e){const n=new Nr,r=new Nr,i=new Nr;for(let s=0;s<t.length;s+=3)l(t[s+0],n),l(t[s+1],r),l(t[s+2],i),a(n,r,i,e)}(r),function(e){const t=new Nr;for(let n=0;n<i.length;n+=3)t.x=i[n+0],t.y=i[n+1],t.z=i[n+2],t.normalize().multiplyScalar(e),i[n+0]=t.x,i[n+1]=t.y,i[n+2]=t.z}(n),function(){const e=new Nr;for(let n=0;n<i.length;n+=3){e.x=i[n+0],e.y=i[n+1],e.z=i[n+2];const r=c(e)/2/Math.PI+.5,a=(t=e,Math.atan2(-t.y,Math.sqrt(t.x*t.x+t.z*t.z))/Math.PI+.5);s.push(r,1-a)}var t;(function(){const e=new Nr,t=new Nr,n=new Nr,r=new Nr,a=new ir,o=new ir,l=new ir;for(let h=0,d=0;h<i.length;h+=9,d+=6){e.set(i[h+0],i[h+1],i[h+2]),t.set(i[h+3],i[h+4],i[h+5]),n.set(i[h+6],i[h+7],i[h+8]),a.set(s[d+0],s[d+1]),o.set(s[d+2],s[d+3]),l.set(s[d+4],s[d+5]),r.copy(e).add(t).add(n).divideScalar(3);const p=c(r);u(a,d+0,e,p),u(o,d+2,t,p),u(l,d+4,n,p)}})(),function(){for(let e=0;e<s.length;e+=6){const t=s[e+0],n=s[e+2],r=s[e+4],i=Math.max(t,n,r),a=Math.min(t,n,r);i>.9&&a<.1&&(t<.2&&(s[e+0]+=1),n<.2&&(s[e+2]+=1),r<.2&&(s[e+4]+=1))}}()}(),this.setAttribute("position",new Ms(i,3)),this.setAttribute("normal",new Ms(i.slice(),3)),this.setAttribute("uv",new Ms(s,2)),0===r?this.computeVertexNormals():this.normalizeNormals()}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new wh(e.vertices,e.indices,e.radius,e.details)}}class Eh extends wh{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;const n=(1+Math.sqrt(5))/2,r=1/n;super([-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-r,-n,0,-r,n,0,r,-n,0,r,n,-r,-n,0,-r,n,0,r,-n,0,r,n,0,-n,0,-r,n,0,-r,-n,0,r,n,0,r],[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],e,t),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new Eh(e.radius,e.detail)}}const Th=new Nr,Ch=new Nr,Rh=new Nr,Ph=new qi;class Ih extends Ps{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;if(super(),this.type="EdgesGeometry",this.parameters={geometry:e,thresholdAngle:t},null!==e){const n=4,r=Math.pow(10,n),i=Math.cos(Kn*t),s=e.getIndex(),a=e.getAttribute("position"),o=s?s.count:a.count,l=[0,0,0],u=["a","b","c"],c=new Array(3),h={},d=[];for(let e=0;e<o;e+=3){s?(l[0]=s.getX(e),l[1]=s.getX(e+1),l[2]=s.getX(e+2)):(l[0]=e,l[1]=e+1,l[2]=e+2);const{a:t,b:n,c:o}=Ph;if(t.fromBufferAttribute(a,l[0]),n.fromBufferAttribute(a,l[1]),o.fromBufferAttribute(a,l[2]),Ph.getNormal(Rh),c[0]=`${Math.round(t.x*r)},${Math.round(t.y*r)},${Math.round(t.z*r)}`,c[1]=`${Math.round(n.x*r)},${Math.round(n.y*r)},${Math.round(n.z*r)}`,c[2]=`${Math.round(o.x*r)},${Math.round(o.y*r)},${Math.round(o.z*r)}`,c[0]!==c[1]&&c[1]!==c[2]&&c[2]!==c[0])for(let e=0;e<3;e++){const t=(e+1)%3,n=c[e],r=c[t],s=Ph[u[e]],a=Ph[u[t]],o=`${n}_${r}`,p=`${r}_${n}`;p in h&&h[p]?(Rh.dot(h[p].normal)<=i&&(d.push(s.x,s.y,s.z),d.push(a.x,a.y,a.z)),h[p]=null):o in h||(h[o]={index0:l[e],index1:l[t],normal:Rh.clone()})}}for(const e in h)if(h[e]){const{index0:t,index1:n}=h[e];Th.fromBufferAttribute(a,t),Ch.fromBufferAttribute(a,n),d.push(Th.x,Th.y,Th.z),d.push(Ch.x,Ch.y,Ch.z)}this.setAttribute("position",new Ms(d,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}class Bh extends _h{constructor(e){super(e),this.uuid=Qn(),this.type="Shape",this.holes=[]}getPointsHoles(e){const t=[];for(let n=0,r=this.holes.length;n<r;n++)t[n]=this.holes[n].getPoints(e);return t}extractPoints(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}}copy(e){super.copy(e),this.holes=[];for(let t=0,n=e.holes.length;t<n;t++){const n=e.holes[t];this.holes.push(n.clone())}return this}toJSON(){const e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let t=0,n=this.holes.length;t<n;t++){const n=this.holes[t];e.holes.push(n.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.uuid=e.uuid,this.holes=[];for(let t=0,n=e.holes.length;t<n;t++){const n=e.holes[t];this.holes.push((new _h).fromJSON(n))}return this}}const Lh=function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:2;const r=t&&t.length,i=r?t[0]*n:e.length;let s=Dh(e,0,i,n,!0);const a=[];if(!s||s.next===s.prev)return a;let o,l,u,c,h,d,p;if(r&&(s=function(e,t,n,r){const i=[];let s,a,o,l,u;for(s=0,a=t.length;s<a;s++)o=t[s]*r,l=s<a-1?t[s+1]*r:e.length,u=Dh(e,o,l,r,!1),u===u.next&&(u.steiner=!0),i.push(jh(u));for(i.sort(zh),s=0;s<i.length;s++)n=Gh(i[s],n);return n}(e,t,s,n)),e.length>80*n){o=u=e[0],l=c=e[1];for(let t=n;t<i;t+=n)h=e[t],d=e[t+1],h<o&&(o=h),d<l&&(l=d),h>u&&(u=h),d>c&&(c=d);p=Math.max(u-o,c-l),p=0!==p?32767/p:0}return Nh(s,a,n,o,l,p,0),a};function Dh(e,t,n,r,i){let s,a;if(i===function(e,t,n,r){let i=0;for(let s=t,a=n-r;s<n;s+=r)i+=(e[a]-e[s])*(e[s+1]+e[a+1]),a=s;return i}(e,t,n,r)>0)for(s=t;s<n;s+=r)a=td(s,e[s],e[s+1],a);else for(s=n-r;s>=t;s-=r)a=td(s,e[s],e[s+1],a);return a&&Kh(a,a.next)&&(nd(a),a=a.next),a}function Uh(e,t){if(!e)return e;t||(t=e);let n,r=e;do{if(n=!1,r.steiner||!Kh(r,r.next)&&0!==Yh(r.prev,r,r.next))r=r.next;else{if(nd(r),r=t=r.prev,r===r.next)break;n=!0}}while(n||r!==t);return t}function Nh(e,t,n,r,i,s,a){if(!e)return;!a&&s&&function(e,t,n,r){let i=e;do{0===i.z&&(i.z=Wh(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,function(e){let t,n,r,i,s,a,o,l,u=1;do{for(n=e,e=null,s=null,a=0;n;){for(a++,r=n,o=0,t=0;t<u&&(o++,r=r.nextZ,r);t++);for(l=u;o>0||l>0&&r;)0!==o&&(0===l||!r||n.z<=r.z)?(i=n,n=n.nextZ,o--):(i=r,r=r.nextZ,l--),s?s.nextZ=i:e=i,i.prevZ=s,s=i;n=r}s.nextZ=null,u*=2}while(a>1)}(i)}(e,r,i,s);let o,l,u=e;for(;e.prev!==e.next;)if(o=e.prev,l=e.next,s?Oh(e,r,i,s):Fh(e))t.push(o.i/n|0),t.push(e.i/n|0),t.push(l.i/n|0),nd(e),e=l.next,u=l.next;else if((e=l)===u){a?1===a?Nh(e=kh(Uh(e),t,n),t,n,r,i,s,2):2===a&&Hh(e,t,n,r,i,s):Nh(Uh(e),t,n,r,i,s,1);break}}function Fh(e){const t=e.prev,n=e,r=e.next;if(Yh(t,n,r)>=0)return!1;const i=t.x,s=n.x,a=r.x,o=t.y,l=n.y,u=r.y,c=i<s?i<a?i:a:s<a?s:a,h=o<l?o<u?o:u:l<u?l:u,d=i>s?i>a?i:a:s>a?s:a,p=o>l?o>u?o:u:l>u?l:u;let f=r.next;for(;f!==t;){if(f.x>=c&&f.x<=d&&f.y>=h&&f.y<=p&&Xh(i,o,s,l,a,u,f.x,f.y)&&Yh(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function Oh(e,t,n,r){const i=e.prev,s=e,a=e.next;if(Yh(i,s,a)>=0)return!1;const o=i.x,l=s.x,u=a.x,c=i.y,h=s.y,d=a.y,p=o<l?o<u?o:u:l<u?l:u,f=c<h?c<d?c:d:h<d?h:d,m=o>l?o>u?o:u:l>u?l:u,g=c>h?c>d?c:d:h>d?h:d,v=Wh(p,f,t,n,r),y=Wh(m,g,t,n,r);let _=e.prevZ,x=e.nextZ;for(;_&&_.z>=v&&x&&x.z<=y;){if(_.x>=p&&_.x<=m&&_.y>=f&&_.y<=g&&_!==i&&_!==a&&Xh(o,c,l,h,u,d,_.x,_.y)&&Yh(_.prev,_,_.next)>=0)return!1;if(_=_.prevZ,x.x>=p&&x.x<=m&&x.y>=f&&x.y<=g&&x!==i&&x!==a&&Xh(o,c,l,h,u,d,x.x,x.y)&&Yh(x.prev,x,x.next)>=0)return!1;x=x.nextZ}for(;_&&_.z>=v;){if(_.x>=p&&_.x<=m&&_.y>=f&&_.y<=g&&_!==i&&_!==a&&Xh(o,c,l,h,u,d,_.x,_.y)&&Yh(_.prev,_,_.next)>=0)return!1;_=_.prevZ}for(;x&&x.z<=y;){if(x.x>=p&&x.x<=m&&x.y>=f&&x.y<=g&&x!==i&&x!==a&&Xh(o,c,l,h,u,d,x.x,x.y)&&Yh(x.prev,x,x.next)>=0)return!1;x=x.nextZ}return!0}function kh(e,t,n){let r=e;do{const i=r.prev,s=r.next.next;!Kh(i,s)&&qh(i,r,r.next,s)&&$h(i,s)&&$h(s,i)&&(t.push(i.i/n|0),t.push(r.i/n|0),t.push(s.i/n|0),nd(r),nd(r.next),r=e=s),r=r.next}while(r!==e);return Uh(r)}function Hh(e,t,n,r,i,s){let a=e;do{let e=a.next.next;for(;e!==a.prev;){if(a.i!==e.i&&Jh(a,e)){let o=ed(a,e);return a=Uh(a,a.next),o=Uh(o,o.next),Nh(a,t,n,r,i,s,0),void Nh(o,t,n,r,i,s,0)}e=e.next}a=a.next}while(a!==e)}function zh(e,t){return e.x-t.x}function Gh(e,t){const n=function(e,t){let n,r=t,i=-1/0;const s=e.x,a=e.y;do{if(a<=r.y&&a>=r.next.y&&r.next.y!==r.y){const e=r.x+(a-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(e<=s&&e>i&&(i=e,n=r.x<r.next.x?r:r.next,e===s))return n}r=r.next}while(r!==t);if(!n)return null;const o=n,l=n.x,u=n.y;let c,h=1/0;r=n;do{s>=r.x&&r.x>=l&&s!==r.x&&Xh(a<u?s:i,a,l,u,a<u?i:s,a,r.x,r.y)&&(c=Math.abs(a-r.y)/(s-r.x),$h(r,e)&&(c<h||c===h&&(r.x>n.x||r.x===n.x&&Vh(n,r)))&&(n=r,h=c)),r=r.next}while(r!==o);return n}(e,t);if(!n)return t;const r=ed(n,e);return Uh(r,r.next),Uh(n,n.next)}function Vh(e,t){return Yh(e.prev,e,t.prev)<0&&Yh(t.next,e,e.next)<0}function Wh(e,t,n,r,i){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-n)*i|0)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-r)*i|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function jh(e){let t=e,n=e;do{(t.x<n.x||t.x===n.x&&t.y<n.y)&&(n=t),t=t.next}while(t!==e);return n}function Xh(e,t,n,r,i,s,a,o){return(i-a)*(t-o)>=(e-a)*(s-o)&&(e-a)*(r-o)>=(n-a)*(t-o)&&(n-a)*(s-o)>=(i-a)*(r-o)}function Jh(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(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&&qh(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}(e,t)&&($h(e,t)&&$h(t,e)&&function(e,t){let n=e,r=!1;const i=(e.x+t.x)/2,s=(e.y+t.y)/2;do{n.y>s!==n.next.y>s&&n.next.y!==n.y&&i<(n.next.x-n.x)*(s-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next}while(n!==e);return r}(e,t)&&(Yh(e.prev,e,t.prev)||Yh(e,t.prev,t))||Kh(e,t)&&Yh(e.prev,e,e.next)>0&&Yh(t.prev,t,t.next)>0)}function Yh(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function Kh(e,t){return e.x===t.x&&e.y===t.y}function qh(e,t,n,r){const i=Zh(Yh(e,t,n)),s=Zh(Yh(e,t,r)),a=Zh(Yh(n,r,e)),o=Zh(Yh(n,r,t));return i!==s&&a!==o||(!(0!==i||!Qh(e,n,t))||(!(0!==s||!Qh(e,r,t))||(!(0!==a||!Qh(n,e,r))||!(0!==o||!Qh(n,t,r)))))}function Qh(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 Zh(e){return e>0?1:e<0?-1:0}function $h(e,t){return Yh(e.prev,e,e.next)<0?Yh(e,t,e.next)>=0&&Yh(e,e.prev,t)>=0:Yh(e,t,e.prev)<0||Yh(e,e.next,t)<0}function ed(e,t){const n=new rd(e.i,e.x,e.y),r=new rd(t.i,t.x,t.y),i=e.next,s=t.prev;return e.next=t,t.prev=e,n.next=i,i.prev=n,r.next=n,n.prev=r,s.next=r,r.prev=s,r}function td(e,t,n,r){const i=new rd(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 nd(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 rd(e,t,n){this.i=e,this.x=t,this.y=n,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}class id{static area(e){const t=e.length;let n=0;for(let r=t-1,i=0;i<t;r=i++)n+=e[r].x*e[i].y-e[i].x*e[r].y;return.5*n}static isClockWise(e){return id.area(e)<0}static triangulateShape(e,t){const n=[],r=[],i=[];sd(e),ad(n,e);let s=e.length;t.forEach(sd);for(let o=0;o<t.length;o++)r.push(s),s+=t[o].length,ad(n,t[o]);const a=Lh(n,r);for(let o=0;o<a.length;o+=3)i.push(a.slice(o,o+3));return i}}function sd(e){const t=e.length;t>2&&e[t-1].equals(e[0])&&e.pop()}function ad(e,t){for(let n=0;n<t.length;n++)e.push(t[n].x),e.push(t[n].y)}class od extends Ps{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new Bh([new ir(.5,.5),new ir(-.5,.5),new ir(-.5,-.5),new ir(.5,-.5)]),t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(),this.type="ExtrudeGeometry",this.parameters={shapes:e,options:t},e=Array.isArray(e)?e:[e];const n=this,r=[],i=[];for(let a=0,o=e.length;a<o;a++){s(e[a])}function s(e){const s=[],a=void 0!==t.curveSegments?t.curveSegments:12,o=void 0!==t.steps?t.steps:1,l=void 0!==t.depth?t.depth:1;let u=void 0===t.bevelEnabled||t.bevelEnabled,c=void 0!==t.bevelThickness?t.bevelThickness:.2,h=void 0!==t.bevelSize?t.bevelSize:c-.1,d=void 0!==t.bevelOffset?t.bevelOffset:0,p=void 0!==t.bevelSegments?t.bevelSegments:3;const f=t.extrudePath,m=void 0!==t.UVGenerator?t.UVGenerator:ld;let g,v,y,_,x,A=!1;f&&(g=f.getSpacedPoints(o),A=!0,u=!1,v=f.computeFrenetFrames(o,!1),y=new Nr,_=new Nr,x=new Nr),u||(p=0,c=0,h=0,d=0);const M=e.extractPoints(a);let b=M.shape;const S=M.holes;if(!id.isClockWise(b)){b=b.reverse();for(let e=0,t=S.length;e<t;e++){const t=S[e];id.isClockWise(t)&&(S[e]=t.reverse())}}const w=id.triangulateShape(b,S),E=b;for(let t=0,n=S.length;t<n;t++){const e=S[t];b=b.concat(e)}function T(e,t,n){return t||console.error("THREE.ExtrudeGeometry: vec does not exist"),e.clone().addScaledVector(t,n)}const C=b.length,R=w.length;function P(e,t,n){let r,i,s;const a=e.x-t.x,o=e.y-t.y,l=n.x-e.x,u=n.y-e.y,c=a*a+o*o,h=a*u-o*l;if(Math.abs(h)>Number.EPSILON){const h=Math.sqrt(c),d=Math.sqrt(l*l+u*u),p=t.x-o/h,f=t.y+a/h,m=((n.x-u/d-p)*u-(n.y+l/d-f)*l)/(a*u-o*l);r=p+a*m-e.x,i=f+o*m-e.y;const g=r*r+i*i;if(g<=2)return new ir(r,i);s=Math.sqrt(g/2)}else{let e=!1;a>Number.EPSILON?l>Number.EPSILON&&(e=!0):a<-Number.EPSILON?l<-Number.EPSILON&&(e=!0):Math.sign(o)===Math.sign(u)&&(e=!0),e?(r=-o,i=a,s=Math.sqrt(c)):(r=a,i=o,s=Math.sqrt(c/2))}return new ir(r/s,i/s)}const I=[];for(let t=0,n=E.length,r=n-1,i=t+1;t<n;t++,r++,i++)r===n&&(r=0),i===n&&(i=0),I[t]=P(E[t],E[r],E[i]);const B=[];let L,D=I.concat();for(let t=0,n=S.length;t<n;t++){const e=S[t];L=[];for(let t=0,n=e.length,r=n-1,i=t+1;t<n;t++,r++,i++)r===n&&(r=0),i===n&&(i=0),L[t]=P(e[t],e[r],e[i]);B.push(L),D=D.concat(L)}for(let t=0;t<p;t++){const e=t/p,n=c*Math.cos(e*Math.PI/2),r=h*Math.sin(e*Math.PI/2)+d;for(let t=0,i=E.length;t<i;t++){const e=T(E[t],I[t],r);F(e.x,e.y,-n)}for(let t=0,i=S.length;t<i;t++){const e=S[t];L=B[t];for(let t=0,i=e.length;t<i;t++){const i=T(e[t],L[t],r);F(i.x,i.y,-n)}}}const U=h+d;for(let t=0;t<C;t++){const e=u?T(b[t],D[t],U):b[t];A?(_.copy(v.normals[0]).multiplyScalar(e.x),y.copy(v.binormals[0]).multiplyScalar(e.y),x.copy(g[0]).add(_).add(y),F(x.x,x.y,x.z)):F(e.x,e.y,0)}for(let t=1;t<=o;t++)for(let e=0;e<C;e++){const n=u?T(b[e],D[e],U):b[e];A?(_.copy(v.normals[t]).multiplyScalar(n.x),y.copy(v.binormals[t]).multiplyScalar(n.y),x.copy(g[t]).add(_).add(y),F(x.x,x.y,x.z)):F(n.x,n.y,l/o*t)}for(let t=p-1;t>=0;t--){const e=t/p,n=c*Math.cos(e*Math.PI/2),r=h*Math.sin(e*Math.PI/2)+d;for(let t=0,i=E.length;t<i;t++){const e=T(E[t],I[t],r);F(e.x,e.y,l+n)}for(let t=0,i=S.length;t<i;t++){const e=S[t];L=B[t];for(let t=0,i=e.length;t<i;t++){const i=T(e[t],L[t],r);A?F(i.x,i.y+g[o-1].y,g[o-1].x+n):F(i.x,i.y,l+n)}}}function N(e,t){let n=e.length;for(;--n>=0;){const r=n;let i=n-1;i<0&&(i=e.length-1);for(let e=0,n=o+2*p;e<n;e++){const n=C*e,s=C*(e+1);k(t+r+n,t+i+n,t+i+s,t+r+s)}}}function F(e,t,n){s.push(e),s.push(t),s.push(n)}function O(e,t,i){H(e),H(t),H(i);const s=r.length/3,a=m.generateTopUV(n,r,s-3,s-2,s-1);z(a[0]),z(a[1]),z(a[2])}function k(e,t,i,s){H(e),H(t),H(s),H(t),H(i),H(s);const a=r.length/3,o=m.generateSideWallUV(n,r,a-6,a-3,a-2,a-1);z(o[0]),z(o[1]),z(o[3]),z(o[1]),z(o[2]),z(o[3])}function H(e){r.push(s[3*e+0]),r.push(s[3*e+1]),r.push(s[3*e+2])}function z(e){i.push(e.x),i.push(e.y)}!function(){const e=r.length/3;if(u){let e=0,t=C*e;for(let n=0;n<R;n++){const e=w[n];O(e[2]+t,e[1]+t,e[0]+t)}e=o+2*p,t=C*e;for(let n=0;n<R;n++){const e=w[n];O(e[0]+t,e[1]+t,e[2]+t)}}else{for(let e=0;e<R;e++){const t=w[e];O(t[2],t[1],t[0])}for(let e=0;e<R;e++){const t=w[e];O(t[0]+C*o,t[1]+C*o,t[2]+C*o)}}n.addGroup(e,r.length/3-e,0)}(),function(){const e=r.length/3;let t=0;N(E,t),t+=E.length;for(let n=0,r=S.length;n<r;n++){const e=S[n];N(e,t),t+=e.length}n.addGroup(e,r.length/3-e,1)}()}this.setAttribute("position",new Ms(r,3)),this.setAttribute("uv",new Ms(i,2)),this.computeVertexNormals()}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON();return function(e,t,n){if(n.shapes=[],Array.isArray(e))for(let r=0,i=e.length;r<i;r++){const t=e[r];n.shapes.push(t.uuid)}else n.shapes.push(e.uuid);n.options=Object.assign({},t),void 0!==t.extrudePath&&(n.options.extrudePath=t.extrudePath.toJSON());return n}(this.parameters.shapes,this.parameters.options,e)}static fromJSON(e,t){const n=[];for(let i=0,s=e.shapes.length;i<s;i++){const r=t[e.shapes[i]];n.push(r)}const r=e.options.extrudePath;return void 0!==r&&(e.options.extrudePath=(new vh[r.type]).fromJSON(r)),new od(n,e.options)}}const ld={generateTopUV:function(e,t,n,r,i){const s=t[3*n],a=t[3*n+1],o=t[3*r],l=t[3*r+1],u=t[3*i],c=t[3*i+1];return[new ir(s,a),new ir(o,l),new ir(u,c)]},generateSideWallUV:function(e,t,n,r,i,s){const a=t[3*n],o=t[3*n+1],l=t[3*n+2],u=t[3*r],c=t[3*r+1],h=t[3*r+2],d=t[3*i],p=t[3*i+1],f=t[3*i+2],m=t[3*s],g=t[3*s+1],v=t[3*s+2];return Math.abs(o-c)<Math.abs(a-u)?[new ir(a,1-l),new ir(u,1-h),new ir(d,1-f),new ir(m,1-v)]:[new ir(o,1-l),new ir(c,1-h),new ir(p,1-f),new ir(g,1-v)]}};class ud extends wh{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;const n=(1+Math.sqrt(5))/2;super([-1,n,0,1,n,0,-1,-n,0,1,-n,0,0,-1,n,0,1,n,0,-1,-n,0,1,-n,n,0,-1,n,0,1,-n,0,-1,-n,0,1],[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],e,t),this.type="IcosahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new ud(e.radius,e.detail)}}class cd extends wh{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;super([1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2],e,t),this.type="OctahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new cd(e.radius,e.detail)}}class hd extends Ps{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:.5,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:32,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,s=arguments.length>5&&void 0!==arguments[5]?arguments[5]:2*Math.PI;super(),this.type="RingGeometry",this.parameters={innerRadius:e,outerRadius:t,thetaSegments:n,phiSegments:r,thetaStart:i,thetaLength:s},n=Math.max(3,n),r=Math.max(1,r);const a=[],o=[],l=[],u=[];let c=e;const h=(t-e)/r,d=new Nr,p=new ir;for(let f=0;f<=r;f++){for(let e=0;e<=n;e++){const r=i+e/n*s;d.x=c*Math.cos(r),d.y=c*Math.sin(r),o.push(d.x,d.y,d.z),l.push(0,0,1),p.x=(d.x/t+1)/2,p.y=(d.y/t+1)/2,u.push(p.x,p.y)}c+=h}for(let f=0;f<r;f++){const e=f*(n+1);for(let t=0;t<n;t++){const r=t+e,i=r,s=r+n+1,o=r+n+2,l=r+1;a.push(i,s,l),a.push(s,o,l)}}this.setIndex(a),this.setAttribute("position",new Ms(o,3)),this.setAttribute("normal",new Ms(l,3)),this.setAttribute("uv",new Ms(u,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new hd(e.innerRadius,e.outerRadius,e.thetaSegments,e.phiSegments,e.thetaStart,e.thetaLength)}}class dd extends Ps{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new Bh([new ir(0,.5),new ir(-.5,-.5),new ir(.5,-.5)]),t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:12;super(),this.type="ShapeGeometry",this.parameters={shapes:e,curveSegments:t};const n=[],r=[],i=[],s=[];let a=0,o=0;if(!1===Array.isArray(e))l(e);else for(let u=0;u<e.length;u++)l(e[u]),this.addGroup(a,o,u),a+=o,o=0;function l(e){const a=r.length/3,l=e.extractPoints(t);let u=l.shape;const c=l.holes;!1===id.isClockWise(u)&&(u=u.reverse());for(let t=0,n=c.length;t<n;t++){const e=c[t];!0===id.isClockWise(e)&&(c[t]=e.reverse())}const h=id.triangulateShape(u,c);for(let t=0,n=c.length;t<n;t++){const e=c[t];u=u.concat(e)}for(let t=0,n=u.length;t<n;t++){const e=u[t];r.push(e.x,e.y,0),i.push(0,0,1),s.push(e.x,e.y)}for(let t=0,r=h.length;t<r;t++){const e=h[t],r=e[0]+a,i=e[1]+a,s=e[2]+a;n.push(r,i,s),o+=3}}this.setIndex(n),this.setAttribute("position",new Ms(r,3)),this.setAttribute("normal",new Ms(i,3)),this.setAttribute("uv",new Ms(s,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON();return function(e,t){if(t.shapes=[],Array.isArray(e))for(let n=0,r=e.length;n<r;n++){const r=e[n];t.shapes.push(r.uuid)}else t.shapes.push(e.uuid);return t}(this.parameters.shapes,e)}static fromJSON(e,t){const n=[];for(let r=0,i=e.shapes.length;r<i;r++){const i=t[e.shapes[r]];n.push(i)}return new dd(n,e.curveSegments)}}class pd extends Ps{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:32,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:16,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:2*Math.PI,s=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0,a=arguments.length>6&&void 0!==arguments[6]?arguments[6]:Math.PI;super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:n,phiStart:r,phiLength:i,thetaStart:s,thetaLength:a},t=Math.max(3,Math.floor(t)),n=Math.max(2,Math.floor(n));const o=Math.min(s+a,Math.PI);let l=0;const u=[],c=new Nr,h=new Nr,d=[],p=[],f=[],m=[];for(let g=0;g<=n;g++){const d=[],v=g/n;let y=0;0===g&&0===s?y=.5/t:g===n&&o===Math.PI&&(y=-.5/t);for(let n=0;n<=t;n++){const o=n/t;c.x=-e*Math.cos(r+o*i)*Math.sin(s+v*a),c.y=e*Math.cos(s+v*a),c.z=e*Math.sin(r+o*i)*Math.sin(s+v*a),p.push(c.x,c.y,c.z),h.copy(c).normalize(),f.push(h.x,h.y,h.z),m.push(o+y,1-v),d.push(l++)}u.push(d)}for(let g=0;g<n;g++)for(let e=0;e<t;e++){const t=u[g][e+1],r=u[g][e],i=u[g+1][e],a=u[g+1][e+1];(0!==g||s>0)&&d.push(t,r,a),(g!==n-1||o<Math.PI)&&d.push(r,i,a)}this.setIndex(d),this.setAttribute("position",new Ms(p,3)),this.setAttribute("normal",new Ms(f,3)),this.setAttribute("uv",new Ms(m,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new pd(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}class fd extends wh{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;super([1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],[2,1,0,0,3,2,1,3,0,2,3,1],e,t),this.type="TetrahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new fd(e.radius,e.detail)}}class md extends Ps{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:.4,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:12,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:48,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:2*Math.PI;super(),this.type="TorusGeometry",this.parameters={radius:e,tube:t,radialSegments:n,tubularSegments:r,arc:i},n=Math.floor(n),r=Math.floor(r);const s=[],a=[],o=[],l=[],u=new Nr,c=new Nr,h=new Nr;for(let d=0;d<=n;d++)for(let s=0;s<=r;s++){const p=s/r*i,f=d/n*Math.PI*2;c.x=(e+t*Math.cos(f))*Math.cos(p),c.y=(e+t*Math.cos(f))*Math.sin(p),c.z=t*Math.sin(f),a.push(c.x,c.y,c.z),u.x=e*Math.cos(p),u.y=e*Math.sin(p),h.subVectors(c,u).normalize(),o.push(h.x,h.y,h.z),l.push(s/r),l.push(d/n)}for(let d=1;d<=n;d++)for(let e=1;e<=r;e++){const t=(r+1)*d+e-1,n=(r+1)*(d-1)+e-1,i=(r+1)*(d-1)+e,a=(r+1)*d+e;s.push(t,n,a),s.push(n,i,a)}this.setIndex(s),this.setAttribute("position",new Ms(a,3)),this.setAttribute("normal",new Ms(o,3)),this.setAttribute("uv",new Ms(l,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new md(e.radius,e.tube,e.radialSegments,e.tubularSegments,e.arc)}}class gd extends Ps{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:.4,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:64,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:8,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:2,s=arguments.length>5&&void 0!==arguments[5]?arguments[5]:3;super(),this.type="TorusKnotGeometry",this.parameters={radius:e,tube:t,tubularSegments:n,radialSegments:r,p:i,q:s},n=Math.floor(n),r=Math.floor(r);const a=[],o=[],l=[],u=[],c=new Nr,h=new Nr,d=new Nr,p=new Nr,f=new Nr,m=new Nr,g=new Nr;for(let y=0;y<=n;++y){const a=y/n*i*Math.PI*2;v(a,i,s,e,d),v(a+.01,i,s,e,p),m.subVectors(p,d),g.addVectors(p,d),f.crossVectors(m,g),g.crossVectors(f,m),f.normalize(),g.normalize();for(let e=0;e<=r;++e){const i=e/r*Math.PI*2,s=-t*Math.cos(i),a=t*Math.sin(i);c.x=d.x+(s*g.x+a*f.x),c.y=d.y+(s*g.y+a*f.y),c.z=d.z+(s*g.z+a*f.z),o.push(c.x,c.y,c.z),h.subVectors(c,d).normalize(),l.push(h.x,h.y,h.z),u.push(y/n),u.push(e/r)}}for(let y=1;y<=n;y++)for(let e=1;e<=r;e++){const t=(r+1)*(y-1)+(e-1),n=(r+1)*y+(e-1),i=(r+1)*y+e,s=(r+1)*(y-1)+e;a.push(t,n,s),a.push(n,i,s)}function v(e,t,n,r,i){const s=Math.cos(e),a=Math.sin(e),o=n/t*e,l=Math.cos(o);i.x=r*(2+l)*.5*s,i.y=r*(2+l)*a*.5,i.z=r*Math.sin(o)*.5}this.setIndex(a),this.setAttribute("position",new Ms(o,3)),this.setAttribute("normal",new Ms(l,3)),this.setAttribute("uv",new Ms(u,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new gd(e.radius,e.tube,e.tubularSegments,e.radialSegments,e.p,e.q)}}class vd extends Ps{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new mh(new Nr(-1,-1,0),new Nr(-1,1,0),new Nr(1,1,0)),t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:64,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:8,i=arguments.length>4&&void 0!==arguments[4]&&arguments[4];super(),this.type="TubeGeometry",this.parameters={path:e,tubularSegments:t,radius:n,radialSegments:r,closed:i};const s=e.computeFrenetFrames(t,i);this.tangents=s.tangents,this.normals=s.normals,this.binormals=s.binormals;const a=new Nr,o=new Nr,l=new ir;let u=new Nr;const c=[],h=[],d=[],p=[];function f(i){u=e.getPointAt(i/t,u);const l=s.normals[i],d=s.binormals[i];for(let e=0;e<=r;e++){const t=e/r*Math.PI*2,i=Math.sin(t),s=-Math.cos(t);o.x=s*l.x+i*d.x,o.y=s*l.y+i*d.y,o.z=s*l.z+i*d.z,o.normalize(),h.push(o.x,o.y,o.z),a.x=u.x+n*o.x,a.y=u.y+n*o.y,a.z=u.z+n*o.z,c.push(a.x,a.y,a.z)}}!function(){for(let e=0;e<t;e++)f(e);f(!1===i?t:0),function(){for(let e=0;e<=t;e++)for(let n=0;n<=r;n++)l.x=e/t,l.y=n/r,d.push(l.x,l.y)}(),function(){for(let e=1;e<=t;e++)for(let t=1;t<=r;t++){const n=(r+1)*(e-1)+(t-1),i=(r+1)*e+(t-1),s=(r+1)*e+t,a=(r+1)*(e-1)+t;p.push(n,i,a),p.push(i,s,a)}}()}(),this.setIndex(p),this.setAttribute("position",new Ms(c,3)),this.setAttribute("normal",new Ms(h,3)),this.setAttribute("uv",new Ms(d,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON();return e.path=this.parameters.path.toJSON(),e}static fromJSON(e){return new vd((new vh[e.path.type]).fromJSON(e.path),e.tubularSegments,e.radius,e.radialSegments,e.closed)}}class yd extends Ps{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;if(super(),this.type="WireframeGeometry",this.parameters={geometry:e},null!==e){const t=[],n=new Set,r=new Nr,i=new Nr;if(null!==e.index){const s=e.attributes.position,a=e.index;let o=e.groups;0===o.length&&(o=[{start:0,count:a.count,materialIndex:0}]);for(let e=0,l=o.length;e<l;++e){const l=o[e],u=l.start;for(let e=u,o=u+l.count;e<o;e+=3)for(let l=0;l<3;l++){const o=a.getX(e+l),u=a.getX(e+(l+1)%3);r.fromBufferAttribute(s,o),i.fromBufferAttribute(s,u),!0===_d(r,i,n)&&(t.push(r.x,r.y,r.z),t.push(i.x,i.y,i.z))}}}else{const s=e.attributes.position;for(let e=0,a=s.count/3;e<a;e++)for(let o=0;o<3;o++){const a=3*e+o,l=3*e+(o+1)%3;r.fromBufferAttribute(s,a),i.fromBufferAttribute(s,l),!0===_d(r,i,n)&&(t.push(r.x,r.y,r.z),t.push(i.x,i.y,i.z))}}this.setAttribute("position",new Ms(t,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}function _d(e,t,n){const r=`${e.x},${e.y},${e.z}-${t.x},${t.y},${t.z}`,i=`${t.x},${t.y},${t.z}-${e.x},${e.y},${e.z}`;return!0!==n.has(r)&&!0!==n.has(i)&&(n.add(r),n.add(i),!0)}var xd=Object.freeze({__proto__:null,BoxGeometry:qs,CapsuleGeometry:Ah,CircleGeometry:Mh,ConeGeometry:Sh,CylinderGeometry:bh,DodecahedronGeometry:Eh,EdgesGeometry:Ih,ExtrudeGeometry:od,IcosahedronGeometry:ud,LatheGeometry:xh,OctahedronGeometry:cd,PlaneGeometry:xa,PolyhedronGeometry:wh,RingGeometry:hd,ShapeGeometry:dd,SphereGeometry:pd,TetrahedronGeometry:fd,TorusGeometry:md,TorusKnotGeometry:gd,TubeGeometry:vd,WireframeGeometry:yd});class Ad extends is{constructor(e){super(),this.isShadowMaterial=!0,this.type="ShadowMaterial",this.color=new ts(0),this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.fog=e.fog,this}}class Md extends ta{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class bd extends is{constructor(e){super(),this.isMeshStandardMaterial=!0,this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new ts(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 ts(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Qt,this.normalScale=new ir(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 Mi,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class Sd extends bd{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 ir(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return Zn(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 ts(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 ts(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new ts(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}}class wd extends is{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new ts(16777215),this.specular=new ts(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ts(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Qt,this.normalScale=new ir(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Mi,this.combine=Z,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.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.flatShading=e.flatShading,this.fog=e.fog,this}}class Ed extends is{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new ts(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ts(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Qt,this.normalScale=new ir(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.gradientMap=e.gradientMap,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}class Td extends is{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Qt,this.normalScale=new ir(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this}}class Cd extends is{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new ts(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ts(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Qt,this.normalScale=new ir(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Mi,this.combine=Z,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.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.flatShading=e.flatShading,this.fog=e.fog,this}}class Rd extends is{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new ts(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Qt,this.normalScale=new ir(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={MATCAP:""},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.flatShading=e.flatShading,this.fog=e.fog,this}}class Pd extends wc{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 Id(e,t,n){return!e||!n&&e.constructor===t?e:"number"===typeof t.BYTES_PER_ELEMENT?new t(e):Array.prototype.slice.call(e)}function Bd(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function Ld(e){const t=e.length,n=new Array(t);for(let r=0;r!==t;++r)n[r]=r;return n.sort((function(t,n){return e[t]-e[n]})),n}function Dd(e,t,n){const r=e.length,i=new e.constructor(r);for(let s=0,a=0;a!==r;++s){const r=n[s]*t;for(let n=0;n!==t;++n)i[a++]=e[r+n]}return i}function Ud(e,t,n,r){let i=1,s=e[0];for(;void 0!==s&&void 0===s[r];)s=e[i++];if(void 0===s)return;let a=s[r];if(void 0!==a)if(Array.isArray(a))do{a=s[r],void 0!==a&&(t.push(s.time),n.push.apply(n,a)),s=e[i++]}while(void 0!==s);else if(void 0!==a.toArray)do{a=s[r],void 0!==a&&(t.push(s.time),a.toArray(n,n.length)),s=e[i++]}while(void 0!==s);else do{a=s[r],void 0!==a&&(t.push(s.time),n.push(a)),s=e[i++]}while(void 0!==s)}const Nd={convertArray:Id,isTypedArray:Bd,getKeyframeOrder:Ld,sortedArray:Dd,flattenJSON:Ud,subclip:function(e,t,n,r){let i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:30;const s=e.clone();s.name=t;const a=[];for(let l=0;l<s.tracks.length;++l){const e=s.tracks[l],t=e.getValueSize(),o=[],u=[];for(let s=0;s<e.times.length;++s){const a=e.times[s]*i;if(!(a<n||a>=r)){o.push(e.times[s]);for(let n=0;n<t;++n)u.push(e.values[s*t+n])}}0!==o.length&&(e.times=Id(o,e.times.constructor),e.values=Id(u,e.values.constructor),a.push(e))}s.tracks=a;let o=1/0;for(let l=0;l<s.tracks.length;++l)o>s.tracks[l].times[0]&&(o=s.tracks[l].times[0]);for(let l=0;l<s.tracks.length;++l)s.tracks[l].shift(-1*o);return s.resetDuration(),s},makeClipAdditive:function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:30;r<=0&&(r=30);const i=n.tracks.length,s=t/r;for(let a=0;a<i;++a){const t=n.tracks[a],r=t.ValueTypeName;if("bool"===r||"string"===r)continue;const i=e.tracks.find((function(e){return e.name===t.name&&e.ValueTypeName===r}));if(void 0===i)continue;let o=0;const l=t.getValueSize();t.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(o=l/3);let u=0;const c=i.getValueSize();i.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(u=c/3);const h=t.times.length-1;let d;if(s<=t.times[0]){const e=o,n=l-o;d=t.values.slice(e,n)}else if(s>=t.times[h]){const e=h*l+o,n=e+l-o;d=t.values.slice(e,n)}else{const e=t.createInterpolant(),n=o,r=l-o;e.evaluate(s),d=e.resultBuffer.slice(n,r)}if("quaternion"===r){(new Ur).fromArray(d).normalize().conjugate().toArray(d)}const p=i.times.length;for(let e=0;e<p;++e){const t=e*c+u;if("quaternion"===r)Ur.multiplyQuaternionsFlat(i.values,t,d,0,i.values,t);else{const e=c-2*u;for(let n=0;n<e;++n)i.values[t+n]-=d[n]}}}return e.blendMode=Vt,e}};class Fd{constructor(e,t,n,r){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=void 0!==r?r:new t.constructor(n),this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){const t=this.parameterPositions;let n=this._cachedIndex,r=t[n],i=t[n-1];e:{t:{let s;n:{r:if(!(e<r)){for(let s=n+2;;){if(void 0===r){if(e<i)break r;return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===s)break;if(i=r,r=t[++n],e<r)break t}s=t.length;break n}if(e>=i)break e;{const a=t[1];e<a&&(n=2,i=a);for(let s=n-2;;){if(void 0===i)return this._cachedIndex=0,this.copySampleValue_(0);if(n===s)break;if(r=i,i=t[--n-1],e>=i)break t}s=n,n=0}}for(;n<s;){const r=n+s>>>1;e<t[r]?s=r:n=r+1}if(r=t[n],i=t[n-1],void 0===i)return this._cachedIndex=0,this.copySampleValue_(0);if(void 0===r)return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,i,r)}return this.interpolate_(n,i,e,r)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,r=this.valueSize,i=e*r;for(let s=0;s!==r;++s)t[s]=n[i+s];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}}class Od extends Fd{constructor(e,t,n,r){super(e,t,n,r),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:kt,endingEnd:kt}}intervalChanged_(e,t,n){const r=this.parameterPositions;let i=e-2,s=e+1,a=r[i],o=r[s];if(void 0===a)switch(this.getSettings_().endingStart){case Ht:i=e,a=2*t-n;break;case zt:i=r.length-2,a=t+r[i]-r[i+1];break;default:i=e,a=n}if(void 0===o)switch(this.getSettings_().endingEnd){case Ht:s=e,o=2*n-t;break;case zt:s=1,o=n+r[1]-r[0];break;default:s=e-1,o=t}const l=.5*(n-t),u=this.valueSize;this._weightPrev=l/(t-a),this._weightNext=l/(o-n),this._offsetPrev=i*u,this._offsetNext=s*u}interpolate_(e,t,n,r){const i=this.resultBuffer,s=this.sampleValues,a=this.valueSize,o=e*a,l=o-a,u=this._offsetPrev,c=this._offsetNext,h=this._weightPrev,d=this._weightNext,p=(n-t)/(r-t),f=p*p,m=f*p,g=-h*m+2*h*f-h*p,v=(1+h)*m+(-1.5-2*h)*f+(-.5+h)*p+1,y=(-1-d)*m+(1.5+d)*f+.5*p,_=d*m-d*f;for(let x=0;x!==a;++x)i[x]=g*s[u+x]+v*s[l+x]+y*s[o+x]+_*s[c+x];return i}}class kd extends Fd{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e,t,n,r){const i=this.resultBuffer,s=this.sampleValues,a=this.valueSize,o=e*a,l=o-a,u=(n-t)/(r-t),c=1-u;for(let h=0;h!==a;++h)i[h]=s[l+h]*c+s[o+h]*u;return i}}class Hd extends Fd{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e){return this.copySampleValue_(e-1)}}class zd{constructor(e,t,n,r){if(void 0===e)throw new Error("THREE.KeyframeTrack: track name is undefined");if(void 0===t||0===t.length)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=Id(t,this.TimeBufferType),this.values=Id(n,this.ValueBufferType),this.setInterpolation(r||this.DefaultInterpolation)}static toJSON(e){const t=e.constructor;let n;if(t.toJSON!==this.toJSON)n=t.toJSON(e);else{n={name:e.name,times:Id(e.times,Array),values:Id(e.values,Array)};const t=e.getInterpolation();t!==e.DefaultInterpolation&&(n.interpolation=t)}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new Hd(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new kd(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new Od(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case Nt:t=this.InterpolantFactoryMethodDiscrete;break;case Ft:t=this.InterpolantFactoryMethodLinear;break;case Ot:t=this.InterpolantFactoryMethodSmooth}if(void 0===t){const t="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(void 0===this.createInterpolant){if(e===this.DefaultInterpolation)throw new Error(t);this.setInterpolation(this.DefaultInterpolation)}return console.warn("THREE.KeyframeTrack:",t),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return Nt;case this.InterpolantFactoryMethodLinear:return Ft;case this.InterpolantFactoryMethodSmooth:return Ot}}getValueSize(){return this.values.length/this.times.length}shift(e){if(0!==e){const t=this.times;for(let n=0,r=t.length;n!==r;++n)t[n]+=e}return this}scale(e){if(1!==e){const t=this.times;for(let n=0,r=t.length;n!==r;++n)t[n]*=e}return this}trim(e,t){const n=this.times,r=n.length;let i=0,s=r-1;for(;i!==r&&n[i]<e;)++i;for(;-1!==s&&n[s]>t;)--s;if(++s,0!==i||s!==r){i>=s&&(s=Math.max(s,1),i=s-1);const e=this.getValueSize();this.times=n.slice(i,s),this.values=this.values.slice(i*e,s*e)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);const n=this.times,r=this.values,i=n.length;0===i&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let s=null;for(let a=0;a!==i;a++){const t=n[a];if("number"===typeof t&&isNaN(t)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,a,t),e=!1;break}if(null!==s&&s>t){console.error("THREE.KeyframeTrack: Out of order keys.",this,a,t,s),e=!1;break}s=t}if(void 0!==r&&Bd(r))for(let a=0,o=r.length;a!==o;++a){const t=r[a];if(isNaN(t)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,a,t),e=!1;break}}return e}optimize(){const e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),r=this.getInterpolation()===Ot,i=e.length-1;let s=1;for(let a=1;a<i;++a){let i=!1;const o=e[a];if(o!==e[a+1]&&(1!==a||o!==e[0]))if(r)i=!0;else{const e=a*n,r=e-n,s=e+n;for(let a=0;a!==n;++a){const n=t[e+a];if(n!==t[r+a]||n!==t[s+a]){i=!0;break}}}if(i){if(a!==s){e[s]=e[a];const r=a*n,i=s*n;for(let e=0;e!==n;++e)t[i+e]=t[r+e]}++s}}if(i>0){e[s]=e[i];for(let e=i*n,r=s*n,a=0;a!==n;++a)t[r+a]=t[e+a];++s}return s!==e.length?(this.times=e.slice(0,s),this.values=t.slice(0,s*n)):(this.times=e,this.values=t),this}clone(){const e=this.times.slice(),t=this.values.slice(),n=new(0,this.constructor)(this.name,e,t);return n.createInterpolant=this.createInterpolant,n}}zd.prototype.TimeBufferType=Float32Array,zd.prototype.ValueBufferType=Float32Array,zd.prototype.DefaultInterpolation=Ft;class Gd extends zd{constructor(e,t,n){super(e,t,n)}}Gd.prototype.ValueTypeName="bool",Gd.prototype.ValueBufferType=Array,Gd.prototype.DefaultInterpolation=Nt,Gd.prototype.InterpolantFactoryMethodLinear=void 0,Gd.prototype.InterpolantFactoryMethodSmooth=void 0;class Vd extends zd{}Vd.prototype.ValueTypeName="color";class Wd extends zd{}Wd.prototype.ValueTypeName="number";class jd extends Fd{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e,t,n,r){const i=this.resultBuffer,s=this.sampleValues,a=this.valueSize,o=(n-t)/(r-t);let l=e*a;for(let u=l+a;l!==u;l+=4)Ur.slerpFlat(i,0,s,l-a,s,l,o);return i}}class Xd extends zd{InterpolantFactoryMethodLinear(e){return new jd(this.times,this.values,this.getValueSize(),e)}}Xd.prototype.ValueTypeName="quaternion",Xd.prototype.InterpolantFactoryMethodSmooth=void 0;class Jd extends zd{constructor(e,t,n){super(e,t,n)}}Jd.prototype.ValueTypeName="string",Jd.prototype.ValueBufferType=Array,Jd.prototype.DefaultInterpolation=Nt,Jd.prototype.InterpolantFactoryMethodLinear=void 0,Jd.prototype.InterpolantFactoryMethodSmooth=void 0;class Yd extends zd{}Yd.prototype.ValueTypeName="vector";class Kd{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:-1,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:Gt;this.name=e,this.tracks=n,this.duration=t,this.blendMode=r,this.uuid=Qn(),this.duration<0&&this.resetDuration()}static parse(e){const t=[],n=e.tracks,r=1/(e.fps||1);for(let s=0,a=n.length;s!==a;++s)t.push(qd(n[s]).scale(r));const i=new this(e.name,e.duration,t,e.blendMode);return i.uuid=e.uuid,i}static toJSON(e){const t=[],n=e.tracks,r={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let i=0,s=n.length;i!==s;++i)t.push(zd.toJSON(n[i]));return r}static CreateFromMorphTargetSequence(e,t,n,r){const i=t.length,s=[];for(let a=0;a<i;a++){let e=[],o=[];e.push((a+i-1)%i,a,(a+1)%i),o.push(0,1,0);const l=Ld(e);e=Dd(e,1,l),o=Dd(o,1,l),r||0!==e[0]||(e.push(i),o.push(o[0])),s.push(new Wd(".morphTargetInfluences["+t[a].name+"]",e,o).scale(1/n))}return new this(e,-1,s)}static findByName(e,t){let n=e;if(!Array.isArray(e)){const t=e;n=t.geometry&&t.geometry.animations||t.animations}for(let r=0;r<n.length;r++)if(n[r].name===t)return n[r];return null}static CreateClipsFromMorphTargetSequences(e,t,n){const r={},i=/^([\w-]*?)([\d]+)$/;for(let a=0,o=e.length;a<o;a++){const t=e[a],n=t.name.match(i);if(n&&n.length>1){const e=n[1];let i=r[e];i||(r[e]=i=[]),i.push(t)}}const s=[];for(const a in r)s.push(this.CreateFromMorphTargetSequence(a,r[a],t,n));return s}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const n=function(e,t,n,r,i){if(0!==n.length){const s=[],a=[];Ud(n,s,a,r),0!==s.length&&i.push(new e(t,s,a))}},r=[],i=e.name||"default",s=e.fps||30,a=e.blendMode;let o=e.length||-1;const l=e.hierarchy||[];for(let u=0;u<l.length;u++){const e=l[u].keys;if(e&&0!==e.length)if(e[0].morphTargets){const t={};let n;for(n=0;n<e.length;n++)if(e[n].morphTargets)for(let r=0;r<e[n].morphTargets.length;r++)t[e[n].morphTargets[r]]=-1;for(const i in t){const t=[],s=[];for(let r=0;r!==e[n].morphTargets.length;++r){const r=e[n];t.push(r.time),s.push(r.morphTarget===i?1:0)}r.push(new Wd(".morphTargetInfluence["+i+"]",t,s))}o=t.length*s}else{const i=".bones["+t[u].name+"]";n(Yd,i+".position",e,"pos",r),n(Xd,i+".quaternion",e,"rot",r),n(Yd,i+".scale",e,"scl",r)}}if(0===r.length)return null;return new this(i,o,r,a)}resetDuration(){let e=0;for(let t=0,n=this.tracks.length;t!==n;++t){const n=this.tracks[t];e=Math.max(e,n.times[n.times.length-1])}return this.duration=e,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){const e=[];for(let t=0;t<this.tracks.length;t++)e.push(this.tracks[t].clone());return new this.constructor(this.name,this.duration,e,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}}function qd(e){if(void 0===e.type)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const t=function(e){switch(e.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return Wd;case"vector":case"vector2":case"vector3":case"vector4":return Yd;case"color":return Vd;case"quaternion":return Xd;case"bool":case"boolean":return Gd;case"string":return Jd}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+e)}(e.type);if(void 0===e.times){const t=[],n=[];Ud(e.keys,t,n,"value"),e.times=t,e.values=n}return void 0!==t.parse?t.parse(e):new t(e.name,e.times,e.values,e.interpolation)}const Qd={enabled:!1,files:{},add:function(e,t){!1!==this.enabled&&(this.files[e]=t)},get:function(e){if(!1!==this.enabled)return this.files[e]},remove:function(e){delete this.files[e]},clear:function(){this.files={}}};class Zd{constructor(e,t,n){const r=this;let i,s=!1,a=0,o=0;const l=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this.itemStart=function(e){o++,!1===s&&void 0!==r.onStart&&r.onStart(e,a,o),s=!0},this.itemEnd=function(e){a++,void 0!==r.onProgress&&r.onProgress(e,a,o),a===o&&(s=!1,void 0!==r.onLoad&&r.onLoad())},this.itemError=function(e){void 0!==r.onError&&r.onError(e)},this.resolveURL=function(e){return i?i(e):e},this.setURLModifier=function(e){return i=e,this},this.addHandler=function(e,t){return l.push(e,t),this},this.removeHandler=function(e){const t=l.indexOf(e);return-1!==t&&l.splice(t,2),this},this.getHandler=function(e){for(let t=0,n=l.length;t<n;t+=2){const n=l[t],r=l[t+1];if(n.global&&(n.lastIndex=0),n.test(e))return r}return null}}}const $d=new Zd;class ep{constructor(e){this.manager=void 0!==e?e:$d,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){const n=this;return new Promise((function(r,i){n.load(e,r,t,i)}))}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}}ep.DEFAULT_MATERIAL_NAME="__DEFAULT";const tp={};class np extends Error{constructor(e,t){super(e),this.response=t}}class rp extends ep{constructor(e){super(e)}load(e,t,n,r){void 0===e&&(e=""),void 0!==this.path&&(e=this.path+e),e=this.manager.resolveURL(e);const i=Qd.get(e);if(void 0!==i)return this.manager.itemStart(e),setTimeout((()=>{t&&t(i),this.manager.itemEnd(e)}),0),i;if(void 0!==tp[e])return void tp[e].push({onLoad:t,onProgress:n,onError:r});tp[e]=[],tp[e].push({onLoad:t,onProgress:n,onError:r});const s=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),a=this.mimeType,o=this.responseType;fetch(s).then((t=>{if(200===t.status||0===t.status){if(0===t.status&&console.warn("THREE.FileLoader: HTTP Status 0 received."),"undefined"===typeof ReadableStream||void 0===t.body||void 0===t.body.getReader)return t;const n=tp[e],r=t.body.getReader(),i=t.headers.get("X-File-Size")||t.headers.get("Content-Length"),s=i?parseInt(i):0,a=0!==s;let o=0;const l=new ReadableStream({start(e){!function t(){r.read().then((r=>{let{done:i,value:l}=r;if(i)e.close();else{o+=l.byteLength;const r=new ProgressEvent("progress",{lengthComputable:a,loaded:o,total:s});for(let e=0,t=n.length;e<t;e++){const t=n[e];t.onProgress&&t.onProgress(r)}e.enqueue(l),t()}}),(t=>{e.error(t)}))}()}});return new Response(l)}throw new np(`fetch for "${t.url}" responded with ${t.status}: ${t.statusText}`,t)})).then((e=>{switch(o){case"arraybuffer":return e.arrayBuffer();case"blob":return e.blob();case"document":return e.text().then((e=>(new DOMParser).parseFromString(e,a)));case"json":return e.json();default:if(void 0===a)return e.text();{const t=/charset="?([^;"\s]*)"?/i.exec(a),n=t&&t[1]?t[1].toLowerCase():void 0,r=new TextDecoder(n);return e.arrayBuffer().then((e=>r.decode(e)))}}})).then((t=>{Qd.add(e,t);const n=tp[e];delete tp[e];for(let e=0,r=n.length;e<r;e++){const r=n[e];r.onLoad&&r.onLoad(t)}})).catch((t=>{const n=tp[e];if(void 0===n)throw this.manager.itemError(e),t;delete tp[e];for(let e=0,r=n.length;e<r;e++){const r=n[e];r.onError&&r.onError(t)}this.manager.itemError(e)})).finally((()=>{this.manager.itemEnd(e)})),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}}class ip extends ep{constructor(e){super(e)}load(e,t,n,r){const i=this,s=new rp(this.manager);s.setPath(this.path),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(e,(function(n){try{t(i.parse(JSON.parse(n)))}catch(s){r?r(s):console.error(s),i.manager.itemError(e)}}),n,r)}parse(e){const t=[];for(let n=0;n<e.length;n++){const r=Kd.parse(e[n]);t.push(r)}return t}}class sp extends ep{constructor(e){super(e)}load(e,t,n,r){const i=this,s=[],a=new Yc,o=new rp(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(i.withCredentials);let l=0;function u(u){o.load(e[u],(function(e){const n=i.parse(e,!0);s[u]={width:n.width,height:n.height,format:n.format,mipmaps:n.mipmaps},l+=1,6===l&&(1===n.mipmapCount&&(a.minFilter=we),a.image=s,a.format=n.format,a.needsUpdate=!0,t&&t(a))}),n,r)}if(Array.isArray(e))for(let c=0,h=e.length;c<h;++c)u(c);else o.load(e,(function(e){const n=i.parse(e,!0);if(n.isCubemap){const e=n.mipmaps.length/n.mipmapCount;for(let t=0;t<e;t++){s[t]={mipmaps:[]};for(let e=0;e<n.mipmapCount;e++)s[t].mipmaps.push(n.mipmaps[t*n.mipmapCount+e]),s[t].format=n.format,s[t].width=n.width,s[t].height=n.height}a.image=s}else a.image.width=n.width,a.image.height=n.height,a.mipmaps=n.mipmaps;1===n.mipmapCount&&(a.minFilter=we),a.format=n.format,a.needsUpdate=!0,t&&t(a)}),n,r);return a}}class ap extends ep{constructor(e){super(e)}load(e,t,n,r){void 0!==this.path&&(e=this.path+e),e=this.manager.resolveURL(e);const i=this,s=Qd.get(e);if(void 0!==s)return i.manager.itemStart(e),setTimeout((function(){t&&t(s),i.manager.itemEnd(e)}),0),s;const a=cr("img");function o(){u(),Qd.add(e,this),t&&t(this),i.manager.itemEnd(e)}function l(t){u(),r&&r(t),i.manager.itemError(e),i.manager.itemEnd(e)}function u(){a.removeEventListener("load",o,!1),a.removeEventListener("error",l,!1)}return a.addEventListener("load",o,!1),a.addEventListener("error",l,!1),"data:"!==e.slice(0,5)&&void 0!==this.crossOrigin&&(a.crossOrigin=this.crossOrigin),i.manager.itemStart(e),a.src=e,a}}class op extends ep{constructor(e){super(e)}load(e,t,n,r){const i=new ua;i.colorSpace=en;const s=new ap(this.manager);s.setCrossOrigin(this.crossOrigin),s.setPath(this.path);let a=0;function o(n){s.load(e[n],(function(e){i.images[n]=e,a++,6===a&&(i.needsUpdate=!0,t&&t(i))}),void 0,r)}for(let l=0;l<e.length;++l)o(l);return i}}class lp extends ep{constructor(e){super(e)}load(e,t,n,r){const i=this,s=new Ju,a=new rp(this.manager);return a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setPath(this.path),a.setWithCredentials(i.withCredentials),a.load(e,(function(e){let n;try{n=i.parse(e)}catch(by){if(void 0===r)return void console.error(by);r(by)}void 0!==n.image?s.image=n.image:void 0!==n.data&&(s.image.width=n.width,s.image.height=n.height,s.image.data=n.data),s.wrapS=void 0!==n.wrapS?n.wrapS:ye,s.wrapT=void 0!==n.wrapT?n.wrapT:ye,s.magFilter=void 0!==n.magFilter?n.magFilter:we,s.minFilter=void 0!==n.minFilter?n.minFilter:we,s.anisotropy=void 0!==n.anisotropy?n.anisotropy:1,void 0!==n.colorSpace&&(s.colorSpace=n.colorSpace),void 0!==n.flipY&&(s.flipY=n.flipY),void 0!==n.format&&(s.format=n.format),void 0!==n.type&&(s.type=n.type),void 0!==n.mipmaps&&(s.mipmaps=n.mipmaps,s.minFilter=Ce),1===n.mipmapCount&&(s.minFilter=we),void 0!==n.generateMipmaps&&(s.generateMipmaps=n.generateMipmaps),s.needsUpdate=!0,t&&t(s,n)}),n,r),s}}class up extends ep{constructor(e){super(e)}load(e,t,n,r){const i=new Tr,s=new ap(this.manager);return s.setCrossOrigin(this.crossOrigin),s.setPath(this.path),s.load(e,(function(e){i.image=e,i.needsUpdate=!0,void 0!==t&&t(i)}),n,r),i}}class cp extends ki{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;super(),this.isLight=!0,this.type="Light",this.color=new ts(e),this.intensity=t}dispose(){}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,void 0!==this.groundColor&&(t.object.groundColor=this.groundColor.getHex()),void 0!==this.distance&&(t.object.distance=this.distance),void 0!==this.angle&&(t.object.angle=this.angle),void 0!==this.decay&&(t.object.decay=this.decay),void 0!==this.penumbra&&(t.object.penumbra=this.penumbra),void 0!==this.shadow&&(t.object.shadow=this.shadow.toJSON()),void 0!==this.target&&(t.object.target=this.target.uuid),t}}class hp extends cp{constructor(e,t,n){super(e,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(ki.DEFAULT_UP),this.updateMatrix(),this.groundColor=new ts(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}}const dp=new di,pp=new Nr,fp=new Nr;class mp{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new ir(512,512),this.map=null,this.mapPass=null,this.matrix=new di,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new va,this._frameExtents=new ir(1,1),this._viewportCount=1,this._viewports=[new Cr(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,n=this.matrix;pp.setFromMatrixPosition(e.matrixWorld),t.position.copy(pp),fp.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(fp),t.updateMatrixWorld(),dp.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(dp),n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(dp)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.intensity=e.intensity,this.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this}clone(){return(new this.constructor).copy(this)}toJSON(){const e={};return 1!==this.intensity&&(e.intensity=this.intensity),0!==this.bias&&(e.bias=this.bias),0!==this.normalBias&&(e.normalBias=this.normalBias),1!==this.radius&&(e.radius=this.radius),512===this.mapSize.x&&512===this.mapSize.y||(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}class gp extends mp{constructor(){super(new aa(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){const t=this.camera,n=2*qn*e.angle*this.focus,r=this.mapSize.width/this.mapSize.height,i=e.distance||t.far;n===t.fov&&r===t.aspect&&i===t.far||(t.fov=n,t.aspect=r,t.far=i,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}class vp extends cp{constructor(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:Math.PI/3,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,s=arguments.length>5&&void 0!==arguments[5]?arguments[5]:2;super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(ki.DEFAULT_UP),this.updateMatrix(),this.target=new ki,this.distance=n,this.angle=r,this.penumbra=i,this.decay=s,this.map=null,this.shadow=new gp}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}const yp=new di,_p=new Nr,xp=new Nr;class Ap extends mp{constructor(){super(new aa(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new ir(4,2),this._viewportCount=6,this._viewports=[new Cr(2,1,1,1),new Cr(0,1,1,1),new Cr(3,1,1,1),new Cr(1,1,1,1),new Cr(3,0,1,1),new Cr(1,0,1,1)],this._cubeDirections=[new Nr(1,0,0),new Nr(-1,0,0),new Nr(0,0,1),new Nr(0,0,-1),new Nr(0,1,0),new Nr(0,-1,0)],this._cubeUps=[new Nr(0,1,0),new Nr(0,1,0),new Nr(0,1,0),new Nr(0,1,0),new Nr(0,0,1),new Nr(0,0,-1)]}updateMatrices(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;const n=this.camera,r=this.matrix,i=e.distance||n.far;i!==n.far&&(n.far=i,n.updateProjectionMatrix()),_p.setFromMatrixPosition(e.matrixWorld),n.position.copy(_p),xp.copy(n.position),xp.add(this._cubeDirections[t]),n.up.copy(this._cubeUps[t]),n.lookAt(xp),n.updateMatrixWorld(),r.makeTranslation(-_p.x,-_p.y,-_p.z),yp.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(yp)}}class Mp extends cp{constructor(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:2;super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=r,this.shadow=new Ap}get power(){return 4*this.intensity*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}}class bp extends mp{constructor(){super(new La(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class Sp extends cp{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(ki.DEFAULT_UP),this.updateMatrix(),this.target=new ki,this.shadow=new bp}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}class wp extends cp{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}}class Ep extends cp{constructor(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:10,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:10;super(e,t),this.isRectAreaLight=!0,this.type="RectAreaLight",this.width=n,this.height=r}get power(){return this.intensity*this.width*this.height*Math.PI}set power(e){this.intensity=e/(this.width*this.height*Math.PI)}copy(e){return super.copy(e),this.width=e.width,this.height=e.height,this}toJSON(e){const t=super.toJSON(e);return t.object.width=this.width,t.object.height=this.height,t}}class Tp{constructor(){this.isSphericalHarmonics3=!0,this.coefficients=[];for(let e=0;e<9;e++)this.coefficients.push(new Nr)}set(e){for(let t=0;t<9;t++)this.coefficients[t].copy(e[t]);return this}zero(){for(let e=0;e<9;e++)this.coefficients[e].set(0,0,0);return this}getAt(e,t){const n=e.x,r=e.y,i=e.z,s=this.coefficients;return t.copy(s[0]).multiplyScalar(.282095),t.addScaledVector(s[1],.488603*r),t.addScaledVector(s[2],.488603*i),t.addScaledVector(s[3],.488603*n),t.addScaledVector(s[4],n*r*1.092548),t.addScaledVector(s[5],r*i*1.092548),t.addScaledVector(s[6],.315392*(3*i*i-1)),t.addScaledVector(s[7],n*i*1.092548),t.addScaledVector(s[8],.546274*(n*n-r*r)),t}getIrradianceAt(e,t){const n=e.x,r=e.y,i=e.z,s=this.coefficients;return t.copy(s[0]).multiplyScalar(.886227),t.addScaledVector(s[1],1.023328*r),t.addScaledVector(s[2],1.023328*i),t.addScaledVector(s[3],1.023328*n),t.addScaledVector(s[4],.858086*n*r),t.addScaledVector(s[5],.858086*r*i),t.addScaledVector(s[6],.743125*i*i-.247708),t.addScaledVector(s[7],.858086*n*i),t.addScaledVector(s[8],.429043*(n*n-r*r)),t}add(e){for(let t=0;t<9;t++)this.coefficients[t].add(e.coefficients[t]);return this}addScaledSH(e,t){for(let n=0;n<9;n++)this.coefficients[n].addScaledVector(e.coefficients[n],t);return this}scale(e){for(let t=0;t<9;t++)this.coefficients[t].multiplyScalar(e);return this}lerp(e,t){for(let n=0;n<9;n++)this.coefficients[n].lerp(e.coefficients[n],t);return this}equals(e){for(let t=0;t<9;t++)if(!this.coefficients[t].equals(e.coefficients[t]))return!1;return!0}copy(e){return this.set(e.coefficients)}clone(){return(new this.constructor).copy(this)}fromArray(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;const n=this.coefficients;for(let r=0;r<9;r++)n[r].fromArray(e,t+3*r);return this}toArray(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;const n=this.coefficients;for(let r=0;r<9;r++)n[r].toArray(e,t+3*r);return e}static getBasisAt(e,t){const n=e.x,r=e.y,i=e.z;t[0]=.282095,t[1]=.488603*r,t[2]=.488603*i,t[3]=.488603*n,t[4]=1.092548*n*r,t[5]=1.092548*r*i,t[6]=.315392*(3*i*i-1),t[7]=1.092548*n*i,t[8]=.546274*(n*n-r*r)}}class Cp extends cp{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new Tp;super(void 0,arguments.length>1&&void 0!==arguments[1]?arguments[1]:1),this.isLightProbe=!0,this.sh=e}copy(e){return super.copy(e),this.sh.copy(e.sh),this}fromJSON(e){return this.intensity=e.intensity,this.sh.fromArray(e.sh),this}toJSON(e){const t=super.toJSON(e);return t.object.sh=this.sh.toArray(),t}}class Rp extends ep{constructor(e){super(e),this.textures={}}load(e,t,n,r){const i=this,s=new rp(i.manager);s.setPath(i.path),s.setRequestHeader(i.requestHeader),s.setWithCredentials(i.withCredentials),s.load(e,(function(n){try{t(i.parse(JSON.parse(n)))}catch(s){r?r(s):console.error(s),i.manager.itemError(e)}}),n,r)}parse(e){const t=this.textures;function n(e){return void 0===t[e]&&console.warn("THREE.MaterialLoader: Undefined texture",e),t[e]}const r=Rp.createMaterialFromType(e.type);if(void 0!==e.uuid&&(r.uuid=e.uuid),void 0!==e.name&&(r.name=e.name),void 0!==e.color&&void 0!==r.color&&r.color.setHex(e.color),void 0!==e.roughness&&(r.roughness=e.roughness),void 0!==e.metalness&&(r.metalness=e.metalness),void 0!==e.sheen&&(r.sheen=e.sheen),void 0!==e.sheenColor&&(r.sheenColor=(new ts).setHex(e.sheenColor)),void 0!==e.sheenRoughness&&(r.sheenRoughness=e.sheenRoughness),void 0!==e.emissive&&void 0!==r.emissive&&r.emissive.setHex(e.emissive),void 0!==e.specular&&void 0!==r.specular&&r.specular.setHex(e.specular),void 0!==e.specularIntensity&&(r.specularIntensity=e.specularIntensity),void 0!==e.specularColor&&void 0!==r.specularColor&&r.specularColor.setHex(e.specularColor),void 0!==e.shininess&&(r.shininess=e.shininess),void 0!==e.clearcoat&&(r.clearcoat=e.clearcoat),void 0!==e.clearcoatRoughness&&(r.clearcoatRoughness=e.clearcoatRoughness),void 0!==e.dispersion&&(r.dispersion=e.dispersion),void 0!==e.iridescence&&(r.iridescence=e.iridescence),void 0!==e.iridescenceIOR&&(r.iridescenceIOR=e.iridescenceIOR),void 0!==e.iridescenceThicknessRange&&(r.iridescenceThicknessRange=e.iridescenceThicknessRange),void 0!==e.transmission&&(r.transmission=e.transmission),void 0!==e.thickness&&(r.thickness=e.thickness),void 0!==e.attenuationDistance&&(r.attenuationDistance=e.attenuationDistance),void 0!==e.attenuationColor&&void 0!==r.attenuationColor&&r.attenuationColor.setHex(e.attenuationColor),void 0!==e.anisotropy&&(r.anisotropy=e.anisotropy),void 0!==e.anisotropyRotation&&(r.anisotropyRotation=e.anisotropyRotation),void 0!==e.fog&&(r.fog=e.fog),void 0!==e.flatShading&&(r.flatShading=e.flatShading),void 0!==e.blending&&(r.blending=e.blending),void 0!==e.combine&&(r.combine=e.combine),void 0!==e.side&&(r.side=e.side),void 0!==e.shadowSide&&(r.shadowSide=e.shadowSide),void 0!==e.opacity&&(r.opacity=e.opacity),void 0!==e.transparent&&(r.transparent=e.transparent),void 0!==e.alphaTest&&(r.alphaTest=e.alphaTest),void 0!==e.alphaHash&&(r.alphaHash=e.alphaHash),void 0!==e.depthFunc&&(r.depthFunc=e.depthFunc),void 0!==e.depthTest&&(r.depthTest=e.depthTest),void 0!==e.depthWrite&&(r.depthWrite=e.depthWrite),void 0!==e.colorWrite&&(r.colorWrite=e.colorWrite),void 0!==e.blendSrc&&(r.blendSrc=e.blendSrc),void 0!==e.blendDst&&(r.blendDst=e.blendDst),void 0!==e.blendEquation&&(r.blendEquation=e.blendEquation),void 0!==e.blendSrcAlpha&&(r.blendSrcAlpha=e.blendSrcAlpha),void 0!==e.blendDstAlpha&&(r.blendDstAlpha=e.blendDstAlpha),void 0!==e.blendEquationAlpha&&(r.blendEquationAlpha=e.blendEquationAlpha),void 0!==e.blendColor&&void 0!==r.blendColor&&r.blendColor.setHex(e.blendColor),void 0!==e.blendAlpha&&(r.blendAlpha=e.blendAlpha),void 0!==e.stencilWriteMask&&(r.stencilWriteMask=e.stencilWriteMask),void 0!==e.stencilFunc&&(r.stencilFunc=e.stencilFunc),void 0!==e.stencilRef&&(r.stencilRef=e.stencilRef),void 0!==e.stencilFuncMask&&(r.stencilFuncMask=e.stencilFuncMask),void 0!==e.stencilFail&&(r.stencilFail=e.stencilFail),void 0!==e.stencilZFail&&(r.stencilZFail=e.stencilZFail),void 0!==e.stencilZPass&&(r.stencilZPass=e.stencilZPass),void 0!==e.stencilWrite&&(r.stencilWrite=e.stencilWrite),void 0!==e.wireframe&&(r.wireframe=e.wireframe),void 0!==e.wireframeLinewidth&&(r.wireframeLinewidth=e.wireframeLinewidth),void 0!==e.wireframeLinecap&&(r.wireframeLinecap=e.wireframeLinecap),void 0!==e.wireframeLinejoin&&(r.wireframeLinejoin=e.wireframeLinejoin),void 0!==e.rotation&&(r.rotation=e.rotation),void 0!==e.linewidth&&(r.linewidth=e.linewidth),void 0!==e.dashSize&&(r.dashSize=e.dashSize),void 0!==e.gapSize&&(r.gapSize=e.gapSize),void 0!==e.scale&&(r.scale=e.scale),void 0!==e.polygonOffset&&(r.polygonOffset=e.polygonOffset),void 0!==e.polygonOffsetFactor&&(r.polygonOffsetFactor=e.polygonOffsetFactor),void 0!==e.polygonOffsetUnits&&(r.polygonOffsetUnits=e.polygonOffsetUnits),void 0!==e.dithering&&(r.dithering=e.dithering),void 0!==e.alphaToCoverage&&(r.alphaToCoverage=e.alphaToCoverage),void 0!==e.premultipliedAlpha&&(r.premultipliedAlpha=e.premultipliedAlpha),void 0!==e.forceSinglePass&&(r.forceSinglePass=e.forceSinglePass),void 0!==e.visible&&(r.visible=e.visible),void 0!==e.toneMapped&&(r.toneMapped=e.toneMapped),void 0!==e.userData&&(r.userData=e.userData),void 0!==e.vertexColors&&("number"===typeof e.vertexColors?r.vertexColors=e.vertexColors>0:r.vertexColors=e.vertexColors),void 0!==e.uniforms)for(const i in e.uniforms){const t=e.uniforms[i];switch(r.uniforms[i]={},t.type){case"t":r.uniforms[i].value=n(t.value);break;case"c":r.uniforms[i].value=(new ts).setHex(t.value);break;case"v2":r.uniforms[i].value=(new ir).fromArray(t.value);break;case"v3":r.uniforms[i].value=(new Nr).fromArray(t.value);break;case"v4":r.uniforms[i].value=(new Cr).fromArray(t.value);break;case"m3":r.uniforms[i].value=(new sr).fromArray(t.value);break;case"m4":r.uniforms[i].value=(new di).fromArray(t.value);break;default:r.uniforms[i].value=t.value}}if(void 0!==e.defines&&(r.defines=e.defines),void 0!==e.vertexShader&&(r.vertexShader=e.vertexShader),void 0!==e.fragmentShader&&(r.fragmentShader=e.fragmentShader),void 0!==e.glslVersion&&(r.glslVersion=e.glslVersion),void 0!==e.extensions)for(const i in e.extensions)r.extensions[i]=e.extensions[i];if(void 0!==e.lights&&(r.lights=e.lights),void 0!==e.clipping&&(r.clipping=e.clipping),void 0!==e.size&&(r.size=e.size),void 0!==e.sizeAttenuation&&(r.sizeAttenuation=e.sizeAttenuation),void 0!==e.map&&(r.map=n(e.map)),void 0!==e.matcap&&(r.matcap=n(e.matcap)),void 0!==e.alphaMap&&(r.alphaMap=n(e.alphaMap)),void 0!==e.bumpMap&&(r.bumpMap=n(e.bumpMap)),void 0!==e.bumpScale&&(r.bumpScale=e.bumpScale),void 0!==e.normalMap&&(r.normalMap=n(e.normalMap)),void 0!==e.normalMapType&&(r.normalMapType=e.normalMapType),void 0!==e.normalScale){let t=e.normalScale;!1===Array.isArray(t)&&(t=[t,t]),r.normalScale=(new ir).fromArray(t)}return void 0!==e.displacementMap&&(r.displacementMap=n(e.displacementMap)),void 0!==e.displacementScale&&(r.displacementScale=e.displacementScale),void 0!==e.displacementBias&&(r.displacementBias=e.displacementBias),void 0!==e.roughnessMap&&(r.roughnessMap=n(e.roughnessMap)),void 0!==e.metalnessMap&&(r.metalnessMap=n(e.metalnessMap)),void 0!==e.emissiveMap&&(r.emissiveMap=n(e.emissiveMap)),void 0!==e.emissiveIntensity&&(r.emissiveIntensity=e.emissiveIntensity),void 0!==e.specularMap&&(r.specularMap=n(e.specularMap)),void 0!==e.specularIntensityMap&&(r.specularIntensityMap=n(e.specularIntensityMap)),void 0!==e.specularColorMap&&(r.specularColorMap=n(e.specularColorMap)),void 0!==e.envMap&&(r.envMap=n(e.envMap)),void 0!==e.envMapRotation&&r.envMapRotation.fromArray(e.envMapRotation),void 0!==e.envMapIntensity&&(r.envMapIntensity=e.envMapIntensity),void 0!==e.reflectivity&&(r.reflectivity=e.reflectivity),void 0!==e.refractionRatio&&(r.refractionRatio=e.refractionRatio),void 0!==e.lightMap&&(r.lightMap=n(e.lightMap)),void 0!==e.lightMapIntensity&&(r.lightMapIntensity=e.lightMapIntensity),void 0!==e.aoMap&&(r.aoMap=n(e.aoMap)),void 0!==e.aoMapIntensity&&(r.aoMapIntensity=e.aoMapIntensity),void 0!==e.gradientMap&&(r.gradientMap=n(e.gradientMap)),void 0!==e.clearcoatMap&&(r.clearcoatMap=n(e.clearcoatMap)),void 0!==e.clearcoatRoughnessMap&&(r.clearcoatRoughnessMap=n(e.clearcoatRoughnessMap)),void 0!==e.clearcoatNormalMap&&(r.clearcoatNormalMap=n(e.clearcoatNormalMap)),void 0!==e.clearcoatNormalScale&&(r.clearcoatNormalScale=(new ir).fromArray(e.clearcoatNormalScale)),void 0!==e.iridescenceMap&&(r.iridescenceMap=n(e.iridescenceMap)),void 0!==e.iridescenceThicknessMap&&(r.iridescenceThicknessMap=n(e.iridescenceThicknessMap)),void 0!==e.transmissionMap&&(r.transmissionMap=n(e.transmissionMap)),void 0!==e.thicknessMap&&(r.thicknessMap=n(e.thicknessMap)),void 0!==e.anisotropyMap&&(r.anisotropyMap=n(e.anisotropyMap)),void 0!==e.sheenColorMap&&(r.sheenColorMap=n(e.sheenColorMap)),void 0!==e.sheenRoughnessMap&&(r.sheenRoughnessMap=n(e.sheenRoughnessMap)),r}setTextures(e){return this.textures=e,this}static createMaterialFromType(e){return new{ShadowMaterial:Ad,SpriteMaterial:vu,RawShaderMaterial:Md,ShaderMaterial:ta,PointsMaterial:kc,MeshPhysicalMaterial:Sd,MeshStandardMaterial:bd,MeshPhongMaterial:wd,MeshToonMaterial:Ed,MeshNormalMaterial:Td,MeshLambertMaterial:Cd,MeshDepthMaterial:Xl,MeshDistanceMaterial:Jl,MeshBasicMaterial:ss,MeshMatcapMaterial:Rd,LineDashedMaterial:Pd,LineBasicMaterial:wc,Material:is}[e]}}class Pp{static decodeText(e){if(console.warn("THREE.LoaderUtils: decodeText() has been deprecated with r165 and will be removed with r175. Use TextDecoder instead."),"undefined"!==typeof TextDecoder)return(new TextDecoder).decode(e);let t="";for(let r=0,i=e.length;r<i;r++)t+=String.fromCharCode(e[r]);try{return decodeURIComponent(escape(t))}catch(n){return t}}static extractUrlBase(e){const t=e.lastIndexOf("/");return-1===t?"./":e.slice(0,t+1)}static resolveURL(e,t){return"string"!==typeof e||""===e?"":(/^https?:\/\//i.test(t)&&/^\//.test(e)&&(t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e)?e:t+e)}}class Ip extends Ps{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(e){return super.copy(e),this.instanceCount=e.instanceCount,this}toJSON(){const e=super.toJSON();return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}}class Bp extends ep{constructor(e){super(e)}load(e,t,n,r){const i=this,s=new rp(i.manager);s.setPath(i.path),s.setRequestHeader(i.requestHeader),s.setWithCredentials(i.withCredentials),s.load(e,(function(n){try{t(i.parse(JSON.parse(n)))}catch(s){r?r(s):console.error(s),i.manager.itemError(e)}}),n,r)}parse(e){const t={},n={};function r(e,r){if(void 0!==t[r])return t[r];const i=e.interleavedBuffers[r],s=function(e,t){if(void 0!==n[t])return n[t];const r=e.arrayBuffers,i=r[t],s=new Uint32Array(i).buffer;return n[t]=s,s}(e,i.buffer),a=ur(i.type,s),o=new fu(a,i.stride);return o.uuid=i.uuid,t[r]=o,o}const i=e.isInstancedBufferGeometry?new Ip:new Ps,s=e.data.index;if(void 0!==s){const e=ur(s.type,s.array);i.setIndex(new ps(e,1))}const a=e.data.attributes;for(const c in a){const t=a[c];let n;if(t.isInterleavedBufferAttribute){const i=r(e.data,t.data);n=new gu(i,t.itemSize,t.offset,t.normalized)}else{const e=ur(t.type,t.array);n=new(t.isInstancedBufferAttribute?Qu:ps)(e,t.itemSize,t.normalized)}void 0!==t.name&&(n.name=t.name),void 0!==t.usage&&n.setUsage(t.usage),i.setAttribute(c,n)}const o=e.data.morphAttributes;if(o)for(const c in o){const t=o[c],n=[];for(let i=0,s=t.length;i<s;i++){const s=t[i];let a;if(s.isInterleavedBufferAttribute){const t=r(e.data,s.data);a=new gu(t,s.itemSize,s.offset,s.normalized)}else{const e=ur(s.type,s.array);a=new ps(e,s.itemSize,s.normalized)}void 0!==s.name&&(a.name=s.name),n.push(a)}i.morphAttributes[c]=n}e.data.morphTargetsRelative&&(i.morphTargetsRelative=!0);const l=e.data.groups||e.data.drawcalls||e.data.offsets;if(void 0!==l)for(let c=0,h=l.length;c!==h;++c){const e=l[c];i.addGroup(e.start,e.count,e.materialIndex)}const u=e.data.boundingSphere;if(void 0!==u){const e=new Nr;void 0!==u.center&&e.fromArray(u.center),i.boundingSphere=new ri(e,u.radius)}return e.name&&(i.name=e.name),e.userData&&(i.userData=e.userData),i}}class Lp extends ep{constructor(e){super(e)}load(e,t,n,r){const i=this,s=""===this.path?Pp.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||s;const a=new rp(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,(function(n){let s=null;try{s=JSON.parse(n)}catch(by){return void 0!==r&&r(by),void console.error("THREE:ObjectLoader: Can't parse "+e+".",by.message)}const a=s.metadata;if(void 0===a||void 0===a.type||"geometry"===a.type.toLowerCase())return void 0!==r&&r(new Error("THREE.ObjectLoader: Can't load "+e)),void console.error("THREE.ObjectLoader: Can't load "+e);i.parse(s,t)}),n,r)}async loadAsync(e,t){const n=""===this.path?Pp.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||n;const r=new rp(this.manager);r.setPath(this.path),r.setRequestHeader(this.requestHeader),r.setWithCredentials(this.withCredentials);const i=await r.loadAsync(e,t),s=JSON.parse(i),a=s.metadata;if(void 0===a||void 0===a.type||"geometry"===a.type.toLowerCase())throw new Error("THREE.ObjectLoader: Can't load "+e);return await this.parseAsync(s)}parse(e,t){const n=this.parseAnimations(e.animations),r=this.parseShapes(e.shapes),i=this.parseGeometries(e.geometries,r),s=this.parseImages(e.images,(function(){void 0!==t&&t(l)})),a=this.parseTextures(e.textures,s),o=this.parseMaterials(e.materials,a),l=this.parseObject(e.object,i,o,a,n),u=this.parseSkeletons(e.skeletons,l);if(this.bindSkeletons(l,u),this.bindLightTargets(l),void 0!==t){let e=!1;for(const t in s)if(s[t].data instanceof HTMLImageElement){e=!0;break}!1===e&&t(l)}return l}async parseAsync(e){const t=this.parseAnimations(e.animations),n=this.parseShapes(e.shapes),r=this.parseGeometries(e.geometries,n),i=await this.parseImagesAsync(e.images),s=this.parseTextures(e.textures,i),a=this.parseMaterials(e.materials,s),o=this.parseObject(e.object,r,a,s,t),l=this.parseSkeletons(e.skeletons,o);return this.bindSkeletons(o,l),this.bindLightTargets(o),o}parseShapes(e){const t={};if(void 0!==e)for(let n=0,r=e.length;n<r;n++){const r=(new Bh).fromJSON(e[n]);t[r.uuid]=r}return t}parseSkeletons(e,t){const n={},r={};if(t.traverse((function(e){e.isBone&&(r[e.uuid]=e)})),void 0!==e)for(let i=0,s=e.length;i<s;i++){const t=(new qu).fromJSON(e[i],r);n[t.uuid]=t}return n}parseGeometries(e,t){const n={};if(void 0!==e){const r=new Bp;for(let i=0,s=e.length;i<s;i++){let s;const a=e[i];switch(a.type){case"BufferGeometry":case"InstancedBufferGeometry":s=r.parse(a);break;default:a.type in xd?s=xd[a.type].fromJSON(a,t):console.warn(`THREE.ObjectLoader: Unsupported geometry type "${a.type}"`)}s.uuid=a.uuid,void 0!==a.name&&(s.name=a.name),void 0!==a.userData&&(s.userData=a.userData),n[a.uuid]=s}}return n}parseMaterials(e,t){const n={},r={};if(void 0!==e){const i=new Rp;i.setTextures(t);for(let t=0,s=e.length;t<s;t++){const s=e[t];void 0===n[s.uuid]&&(n[s.uuid]=i.parse(s)),r[s.uuid]=n[s.uuid]}}return r}parseAnimations(e){const t={};if(void 0!==e)for(let n=0;n<e.length;n++){const r=e[n],i=Kd.parse(r);t[i.uuid]=i}return t}parseImages(e,t){const n=this,r={};let i;function s(e){if("string"===typeof e){const t=e;return function(e){return n.manager.itemStart(e),i.load(e,(function(){n.manager.itemEnd(e)}),void 0,(function(){n.manager.itemError(e),n.manager.itemEnd(e)}))}(/^(\/\/)|([a-z]+:(\/\/)?)/i.test(t)?t:n.resourcePath+t)}return e.data?{data:ur(e.type,e.data),width:e.width,height:e.height}:null}if(void 0!==e&&e.length>0){const n=new Zd(t);i=new ap(n),i.setCrossOrigin(this.crossOrigin);for(let t=0,i=e.length;t<i;t++){const n=e[t],i=n.url;if(Array.isArray(i)){const e=[];for(let t=0,n=i.length;t<n;t++){const n=s(i[t]);null!==n&&(n instanceof HTMLImageElement?e.push(n):e.push(new Ju(n.data,n.width,n.height)))}r[n.uuid]=new Sr(e)}else{const e=s(n.url);r[n.uuid]=new Sr(e)}}}return r}async parseImagesAsync(e){const t=this,n={};let r;async function i(e){if("string"===typeof e){const n=e,i=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(n)?n:t.resourcePath+n;return await r.loadAsync(i)}return e.data?{data:ur(e.type,e.data),width:e.width,height:e.height}:null}if(void 0!==e&&e.length>0){r=new ap(this.manager),r.setCrossOrigin(this.crossOrigin);for(let t=0,r=e.length;t<r;t++){const r=e[t],s=r.url;if(Array.isArray(s)){const e=[];for(let t=0,n=s.length;t<n;t++){const n=s[t],r=await i(n);null!==r&&(r instanceof HTMLImageElement?e.push(r):e.push(new Ju(r.data,r.width,r.height)))}n[r.uuid]=new Sr(e)}else{const e=await i(r.url);n[r.uuid]=new Sr(e)}}}return n}parseTextures(e,t){function n(e,t){return"number"===typeof e?e:(console.warn("THREE.ObjectLoader.parseTexture: Constant should be in numeric form.",e),t[e])}const r={};if(void 0!==e)for(let i=0,s=e.length;i<s;i++){const s=e[i];void 0===s.image&&console.warn('THREE.ObjectLoader: No "image" specified for',s.uuid),void 0===t[s.image]&&console.warn("THREE.ObjectLoader: Undefined image",s.image);const a=t[s.image],o=a.data;let l;Array.isArray(o)?(l=new ua,6===o.length&&(l.needsUpdate=!0)):(l=o&&o.data?new Ju:new Tr,o&&(l.needsUpdate=!0)),l.source=a,l.uuid=s.uuid,void 0!==s.name&&(l.name=s.name),void 0!==s.mapping&&(l.mapping=n(s.mapping,Dp)),void 0!==s.channel&&(l.channel=s.channel),void 0!==s.offset&&l.offset.fromArray(s.offset),void 0!==s.repeat&&l.repeat.fromArray(s.repeat),void 0!==s.center&&l.center.fromArray(s.center),void 0!==s.rotation&&(l.rotation=s.rotation),void 0!==s.wrap&&(l.wrapS=n(s.wrap[0],Up),l.wrapT=n(s.wrap[1],Up)),void 0!==s.format&&(l.format=s.format),void 0!==s.internalFormat&&(l.internalFormat=s.internalFormat),void 0!==s.type&&(l.type=s.type),void 0!==s.colorSpace&&(l.colorSpace=s.colorSpace),void 0!==s.minFilter&&(l.minFilter=n(s.minFilter,Np)),void 0!==s.magFilter&&(l.magFilter=n(s.magFilter,Np)),void 0!==s.anisotropy&&(l.anisotropy=s.anisotropy),void 0!==s.flipY&&(l.flipY=s.flipY),void 0!==s.generateMipmaps&&(l.generateMipmaps=s.generateMipmaps),void 0!==s.premultiplyAlpha&&(l.premultiplyAlpha=s.premultiplyAlpha),void 0!==s.unpackAlignment&&(l.unpackAlignment=s.unpackAlignment),void 0!==s.compareFunction&&(l.compareFunction=s.compareFunction),void 0!==s.userData&&(l.userData=s.userData),r[s.uuid]=l}return r}parseObject(e,t,n,r,i){let s,a,o;function l(e){return void 0===t[e]&&console.warn("THREE.ObjectLoader: Undefined geometry",e),t[e]}function u(e){if(void 0!==e){if(Array.isArray(e)){const t=[];for(let r=0,i=e.length;r<i;r++){const i=e[r];void 0===n[i]&&console.warn("THREE.ObjectLoader: Undefined material",i),t.push(n[i])}return t}return void 0===n[e]&&console.warn("THREE.ObjectLoader: Undefined material",e),n[e]}}function c(e){return void 0===r[e]&&console.warn("THREE.ObjectLoader: Undefined texture",e),r[e]}switch(e.type){case"Scene":s=new pu,void 0!==e.background&&(Number.isInteger(e.background)?s.background=new ts(e.background):s.background=c(e.background)),void 0!==e.environment&&(s.environment=c(e.environment)),void 0!==e.fog&&("Fog"===e.fog.type?s.fog=new du(e.fog.color,e.fog.near,e.fog.far):"FogExp2"===e.fog.type&&(s.fog=new hu(e.fog.color,e.fog.density)),""!==e.fog.name&&(s.fog.name=e.fog.name)),void 0!==e.backgroundBlurriness&&(s.backgroundBlurriness=e.backgroundBlurriness),void 0!==e.backgroundIntensity&&(s.backgroundIntensity=e.backgroundIntensity),void 0!==e.backgroundRotation&&s.backgroundRotation.fromArray(e.backgroundRotation),void 0!==e.environmentIntensity&&(s.environmentIntensity=e.environmentIntensity),void 0!==e.environmentRotation&&s.environmentRotation.fromArray(e.environmentRotation);break;case"PerspectiveCamera":s=new aa(e.fov,e.aspect,e.near,e.far),void 0!==e.focus&&(s.focus=e.focus),void 0!==e.zoom&&(s.zoom=e.zoom),void 0!==e.filmGauge&&(s.filmGauge=e.filmGauge),void 0!==e.filmOffset&&(s.filmOffset=e.filmOffset),void 0!==e.view&&(s.view=Object.assign({},e.view));break;case"OrthographicCamera":s=new La(e.left,e.right,e.top,e.bottom,e.near,e.far),void 0!==e.zoom&&(s.zoom=e.zoom),void 0!==e.view&&(s.view=Object.assign({},e.view));break;case"AmbientLight":s=new wp(e.color,e.intensity);break;case"DirectionalLight":s=new Sp(e.color,e.intensity),s.target=e.target||"";break;case"PointLight":s=new Mp(e.color,e.intensity,e.distance,e.decay);break;case"RectAreaLight":s=new Ep(e.color,e.intensity,e.width,e.height);break;case"SpotLight":s=new vp(e.color,e.intensity,e.distance,e.angle,e.penumbra,e.decay),s.target=e.target||"";break;case"HemisphereLight":s=new hp(e.color,e.groundColor,e.intensity);break;case"LightProbe":s=(new Cp).fromJSON(e);break;case"SkinnedMesh":a=l(e.geometry),o=u(e.material),s=new ju(a,o),void 0!==e.bindMode&&(s.bindMode=e.bindMode),void 0!==e.bindMatrix&&s.bindMatrix.fromArray(e.bindMatrix),void 0!==e.skeleton&&(s.skeleton=e.skeleton);break;case"Mesh":a=l(e.geometry),o=u(e.material),s=new Ys(a,o);break;case"InstancedMesh":a=l(e.geometry),o=u(e.material);const t=e.count,n=e.instanceMatrix,r=e.instanceColor;s=new sc(a,o,t),s.instanceMatrix=new Qu(new Float32Array(n.array),16),void 0!==r&&(s.instanceColor=new Qu(new Float32Array(r.array),r.itemSize));break;case"BatchedMesh":a=l(e.geometry),o=u(e.material),s=new Sc(e.maxInstanceCount,e.maxVertexCount,e.maxIndexCount,o),s.geometry=a,s.perObjectFrustumCulled=e.perObjectFrustumCulled,s.sortObjects=e.sortObjects,s._drawRanges=e.drawRanges,s._reservedRanges=e.reservedRanges,s._visibility=e.visibility,s._active=e.active,s._bounds=e.bounds.map((e=>{const t=new kr;t.min.fromArray(e.boxMin),t.max.fromArray(e.boxMax);const n=new ri;return n.radius=e.sphereRadius,n.center.fromArray(e.sphereCenter),{boxInitialized:e.boxInitialized,box:t,sphereInitialized:e.sphereInitialized,sphere:n}})),s._maxInstanceCount=e.maxInstanceCount,s._maxVertexCount=e.maxVertexCount,s._maxIndexCount=e.maxIndexCount,s._geometryInitialized=e.geometryInitialized,s._geometryCount=e.geometryCount,s._matricesTexture=c(e.matricesTexture.uuid),void 0!==e.colorsTexture&&(s._colorsTexture=c(e.colorsTexture.uuid));break;case"LOD":s=new Uu;break;case"Line":s=new Lc(l(e.geometry),u(e.material));break;case"LineLoop":s=new Oc(l(e.geometry),u(e.material));break;case"LineSegments":s=new Fc(l(e.geometry),u(e.material));break;case"PointCloud":case"Points":s=new Wc(l(e.geometry),u(e.material));break;case"Sprite":s=new Iu(u(e.material));break;case"Group":s=new tu;break;case"Bone":s=new Xu;break;default:s=new ki}if(s.uuid=e.uuid,void 0!==e.name&&(s.name=e.name),void 0!==e.matrix?(s.matrix.fromArray(e.matrix),void 0!==e.matrixAutoUpdate&&(s.matrixAutoUpdate=e.matrixAutoUpdate),s.matrixAutoUpdate&&s.matrix.decompose(s.position,s.quaternion,s.scale)):(void 0!==e.position&&s.position.fromArray(e.position),void 0!==e.rotation&&s.rotation.fromArray(e.rotation),void 0!==e.quaternion&&s.quaternion.fromArray(e.quaternion),void 0!==e.scale&&s.scale.fromArray(e.scale)),void 0!==e.up&&s.up.fromArray(e.up),void 0!==e.castShadow&&(s.castShadow=e.castShadow),void 0!==e.receiveShadow&&(s.receiveShadow=e.receiveShadow),e.shadow&&(void 0!==e.shadow.intensity&&(s.shadow.intensity=e.shadow.intensity),void 0!==e.shadow.bias&&(s.shadow.bias=e.shadow.bias),void 0!==e.shadow.normalBias&&(s.shadow.normalBias=e.shadow.normalBias),void 0!==e.shadow.radius&&(s.shadow.radius=e.shadow.radius),void 0!==e.shadow.mapSize&&s.shadow.mapSize.fromArray(e.shadow.mapSize),void 0!==e.shadow.camera&&(s.shadow.camera=this.parseObject(e.shadow.camera))),void 0!==e.visible&&(s.visible=e.visible),void 0!==e.frustumCulled&&(s.frustumCulled=e.frustumCulled),void 0!==e.renderOrder&&(s.renderOrder=e.renderOrder),void 0!==e.userData&&(s.userData=e.userData),void 0!==e.layers&&(s.layers.mask=e.layers),void 0!==e.children){const a=e.children;for(let e=0;e<a.length;e++)s.add(this.parseObject(a[e],t,n,r,i))}if(void 0!==e.animations){const t=e.animations;for(let e=0;e<t.length;e++){const n=t[e];s.animations.push(i[n])}}if("LOD"===e.type){void 0!==e.autoUpdate&&(s.autoUpdate=e.autoUpdate);const t=e.levels;for(let e=0;e<t.length;e++){const n=t[e],r=s.getObjectByProperty("uuid",n.object);void 0!==r&&s.addLevel(r,n.distance,n.hysteresis)}}return s}bindSkeletons(e,t){0!==Object.keys(t).length&&e.traverse((function(e){if(!0===e.isSkinnedMesh&&void 0!==e.skeleton){const n=t[e.skeleton];void 0===n?console.warn("THREE.ObjectLoader: No skeleton found with UUID:",e.skeleton):e.bind(n,e.bindMatrix)}}))}bindLightTargets(e){e.traverse((function(t){if(t.isDirectionalLight||t.isSpotLight){const n=t.target,r=e.getObjectByProperty("uuid",n);t.target=void 0!==r?r:new ki}}))}}const Dp={UVMapping:he,CubeReflectionMapping:de,CubeRefractionMapping:pe,EquirectangularReflectionMapping:fe,EquirectangularRefractionMapping:me,CubeUVReflectionMapping:ge},Up={RepeatWrapping:ve,ClampToEdgeWrapping:ye,MirroredRepeatWrapping:_e},Np={NearestFilter:xe,NearestMipmapNearestFilter:Ae,NearestMipmapLinearFilter:be,LinearFilter:we,LinearMipmapNearestFilter:Ee,LinearMipmapLinearFilter:Ce};class Fp extends ep{constructor(e){super(e),this.isImageBitmapLoader=!0,"undefined"===typeof createImageBitmap&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),"undefined"===typeof fetch&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(e){return this.options=e,this}load(e,t,n,r){void 0===e&&(e=""),void 0!==this.path&&(e=this.path+e),e=this.manager.resolveURL(e);const i=this,s=Qd.get(e);if(void 0!==s)return i.manager.itemStart(e),s.then?void s.then((n=>{t&&t(n),i.manager.itemEnd(e)})).catch((e=>{r&&r(e)})):(setTimeout((function(){t&&t(s),i.manager.itemEnd(e)}),0),s);const a={};a.credentials="anonymous"===this.crossOrigin?"same-origin":"include",a.headers=this.requestHeader;const o=fetch(e,a).then((function(e){return e.blob()})).then((function(e){return createImageBitmap(e,Object.assign(i.options,{colorSpaceConversion:"none"}))})).then((function(n){return Qd.add(e,n),t&&t(n),i.manager.itemEnd(e),n})).catch((function(t){r&&r(t),Qd.remove(e),i.manager.itemError(e),i.manager.itemEnd(e)}));Qd.add(e,o),i.manager.itemStart(e)}}let Op;class kp{static getContext(){return void 0===Op&&(Op=new(window.AudioContext||window.webkitAudioContext)),Op}static setContext(e){Op=e}}class Hp extends ep{constructor(e){super(e)}load(e,t,n,r){const i=this,s=new rp(this.manager);function a(t){r?r(t):console.error(t),i.manager.itemError(e)}s.setResponseType("arraybuffer"),s.setPath(this.path),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(e,(function(e){try{const n=e.slice(0);kp.getContext().decodeAudioData(n,(function(e){t(e)})).catch(a)}catch(n){a(n)}}),n,r)}}const zp=new di,Gp=new di,Vp=new di;class Wp{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new aa,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new aa,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}update(e){const t=this._cache;if(t.focus!==e.focus||t.fov!==e.fov||t.aspect!==e.aspect*this.aspect||t.near!==e.near||t.far!==e.far||t.zoom!==e.zoom||t.eyeSep!==this.eyeSep){t.focus=e.focus,t.fov=e.fov,t.aspect=e.aspect*this.aspect,t.near=e.near,t.far=e.far,t.zoom=e.zoom,t.eyeSep=this.eyeSep,Vp.copy(e.projectionMatrix);const n=t.eyeSep/2,r=n*t.near/t.focus,i=t.near*Math.tan(Kn*t.fov*.5)/t.zoom;let s,a;Gp.elements[12]=-n,zp.elements[12]=n,s=-i*t.aspect+r,a=i*t.aspect+r,Vp.elements[0]=2*t.near/(a-s),Vp.elements[8]=(a+s)/(a-s),this.cameraL.projectionMatrix.copy(Vp),s=-i*t.aspect-r,a=i*t.aspect-r,Vp.elements[0]=2*t.near/(a-s),Vp.elements[8]=(a+s)/(a-s),this.cameraR.projectionMatrix.copy(Vp)}this.cameraL.matrixWorld.copy(e.matrixWorld).multiply(Gp),this.cameraR.matrixWorld.copy(e.matrixWorld).multiply(zp)}}class jp{constructor(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=Xp(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let e=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){const t=Xp();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}}function Xp(){return("undefined"===typeof performance?Date:performance).now()}const Jp=new Nr,Yp=new Ur,Kp=new Nr,qp=new Nr;class Qp extends ki{constructor(){super(),this.type="AudioListener",this.context=kp.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new jp}getInput(){return this.gain}removeFilter(){return null!==this.filter&&(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 null!==this.filter?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=e,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}updateMatrixWorld(e){super.updateMatrixWorld(e);const t=this.context.listener,n=this.up;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(Jp,Yp,Kp),qp.set(0,0,-1).applyQuaternion(Yp),t.positionX){const e=this.context.currentTime+this.timeDelta;t.positionX.linearRampToValueAtTime(Jp.x,e),t.positionY.linearRampToValueAtTime(Jp.y,e),t.positionZ.linearRampToValueAtTime(Jp.z,e),t.forwardX.linearRampToValueAtTime(qp.x,e),t.forwardY.linearRampToValueAtTime(qp.y,e),t.forwardZ.linearRampToValueAtTime(qp.z,e),t.upX.linearRampToValueAtTime(n.x,e),t.upY.linearRampToValueAtTime(n.y,e),t.upZ.linearRampToValueAtTime(n.z,e)}else t.setPosition(Jp.x,Jp.y,Jp.z),t.setOrientation(qp.x,qp.y,qp.z,n.x,n.y,n.z)}}class Zp extends ki{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(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;if(!0===this.isPlaying)return void console.warn("THREE.Audio: Audio is already playing.");if(!1===this.hasPlaybackControl)return void console.warn("THREE.Audio: this Audio has no playback control.");this._startedAt=this.context.currentTime+e;const t=this.context.createBufferSource();return t.buffer=this.buffer,t.loop=this.loop,t.loopStart=this.loopStart,t.loopEnd=this.loopEnd,t.onended=this.onEnded.bind(this),t.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=t,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){if(!1!==this.hasPlaybackControl)return!0===this.isPlaying&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,!0===this.loop&&(this._progress=this._progress%(this.duration||this.buffer.duration)),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this;console.warn("THREE.Audio: this Audio has no playback control.")}stop(){if(!1!==this.hasPlaybackControl)return this._progress=0,null!==this.source&&(this.source.stop(),this.source.onended=null),this.isPlaying=!1,this;console.warn("THREE.Audio: this Audio has no playback control.")}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let e=1,t=this.filters.length;e<t;e++)this.filters[e-1].connect(this.filters[e]);this.filters[this.filters.length-1].connect(this.getOutput())}else this.source.connect(this.getOutput());return this._connected=!0,this}disconnect(){if(!1!==this._connected){if(this.filters.length>0){this.source.disconnect(this.filters[0]);for(let e=1,t=this.filters.length;e<t;e++)this.filters[e-1].disconnect(this.filters[e]);this.filters[this.filters.length-1].disconnect(this.getOutput())}else this.source.disconnect(this.getOutput());return this._connected=!1,this}}getFilters(){return this.filters}setFilters(e){return e||(e=[]),!0===this._connected?(this.disconnect(),this.filters=e.slice(),this.connect()):this.filters=e.slice(),this}setDetune(e){return this.detune=e,!0===this.isPlaying&&void 0!==this.source.detune&&this.source.detune.setTargetAtTime(this.detune,this.context.currentTime,.01),this}getDetune(){return this.detune}getFilter(){return this.getFilters()[0]}setFilter(e){return this.setFilters(e?[e]:[])}setPlaybackRate(e){if(!1!==this.hasPlaybackControl)return this.playbackRate=e,!0===this.isPlaying&&this.source.playbackRate.setTargetAtTime(this.playbackRate,this.context.currentTime,.01),this;console.warn("THREE.Audio: this Audio has no playback control.")}getPlaybackRate(){return this.playbackRate}onEnded(){this.isPlaying=!1}getLoop(){return!1===this.hasPlaybackControl?(console.warn("THREE.Audio: this Audio has no playback control."),!1):this.loop}setLoop(e){if(!1!==this.hasPlaybackControl)return this.loop=e,!0===this.isPlaying&&(this.source.loop=this.loop),this;console.warn("THREE.Audio: this Audio has no playback control.")}setLoopStart(e){return this.loopStart=e,this}setLoopEnd(e){return this.loopEnd=e,this}getVolume(){return this.gain.gain.value}setVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}}const $p=new Nr,ef=new Ur,tf=new Nr,nf=new Nr;class rf extends Zp{constructor(e){super(e),this.panner=this.context.createPanner(),this.panner.panningModel="HRTF",this.panner.connect(this.gain)}connect(){super.connect(),this.panner.connect(this.gain)}disconnect(){super.disconnect(),this.panner.disconnect(this.gain)}getOutput(){return this.panner}getRefDistance(){return this.panner.refDistance}setRefDistance(e){return this.panner.refDistance=e,this}getRolloffFactor(){return this.panner.rolloffFactor}setRolloffFactor(e){return this.panner.rolloffFactor=e,this}getDistanceModel(){return this.panner.distanceModel}setDistanceModel(e){return this.panner.distanceModel=e,this}getMaxDistance(){return this.panner.maxDistance}setMaxDistance(e){return this.panner.maxDistance=e,this}setDirectionalCone(e,t,n){return this.panner.coneInnerAngle=e,this.panner.coneOuterAngle=t,this.panner.coneOuterGain=n,this}updateMatrixWorld(e){if(super.updateMatrixWorld(e),!0===this.hasPlaybackControl&&!1===this.isPlaying)return;this.matrixWorld.decompose($p,ef,tf),nf.set(0,0,1).applyQuaternion(ef);const t=this.panner;if(t.positionX){const e=this.context.currentTime+this.listener.timeDelta;t.positionX.linearRampToValueAtTime($p.x,e),t.positionY.linearRampToValueAtTime($p.y,e),t.positionZ.linearRampToValueAtTime($p.z,e),t.orientationX.linearRampToValueAtTime(nf.x,e),t.orientationY.linearRampToValueAtTime(nf.y,e),t.orientationZ.linearRampToValueAtTime(nf.z,e)}else t.setPosition($p.x,$p.y,$p.z),t.setOrientation(nf.x,nf.y,nf.z)}}class sf{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2048;this.analyser=e.context.createAnalyser(),this.analyser.fftSize=t,this.data=new Uint8Array(this.analyser.frequencyBinCount),e.getOutput().connect(this.analyser)}getFrequencyData(){return this.analyser.getByteFrequencyData(this.data),this.data}getAverageFrequency(){let e=0;const t=this.getFrequencyData();for(let n=0;n<t.length;n++)e+=t[n];return e/t.length}}class af{constructor(e,t,n){let r,i,s;switch(this.binding=e,this.valueSize=n,t){case"quaternion":r=this._slerp,i=this._slerpAdditive,s=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(6*n),this._workIndex=5;break;case"string":case"bool":r=this._select,i=this._select,s=this._setAdditiveIdentityOther,this.buffer=new Array(5*n);break;default:r=this._lerp,i=this._lerpAdditive,s=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(5*n)}this._mixBufferRegion=r,this._mixBufferRegionAdditive=i,this._setIdentity=s,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(e,t){const n=this.buffer,r=this.valueSize,i=e*r+r;let s=this.cumulativeWeight;if(0===s){for(let e=0;e!==r;++e)n[i+e]=n[e];s=t}else{s+=t;const e=t/s;this._mixBufferRegion(n,i,0,e,r)}this.cumulativeWeight=s}accumulateAdditive(e){const t=this.buffer,n=this.valueSize,r=n*this._addIndex;0===this.cumulativeWeightAdditive&&this._setIdentity(),this._mixBufferRegionAdditive(t,r,0,e,n),this.cumulativeWeightAdditive+=e}apply(e){const t=this.valueSize,n=this.buffer,r=e*t+t,i=this.cumulativeWeight,s=this.cumulativeWeightAdditive,a=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,i<1){const e=t*this._origIndex;this._mixBufferRegion(n,r,e,1-i,t)}s>0&&this._mixBufferRegionAdditive(n,r,this._addIndex*t,1,t);for(let o=t,l=t+t;o!==l;++o)if(n[o]!==n[o+t]){a.setValue(n,r);break}}saveOriginalState(){const e=this.binding,t=this.buffer,n=this.valueSize,r=n*this._origIndex;e.getValue(t,r);for(let i=n,s=r;i!==s;++i)t[i]=t[r+i%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const e=3*this.valueSize;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){const e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let n=e;n<t;n++)this.buffer[n]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){const e=this._origIndex*this.valueSize,t=this._addIndex*this.valueSize;for(let n=0;n<this.valueSize;n++)this.buffer[t+n]=this.buffer[e+n]}_select(e,t,n,r,i){if(r>=.5)for(let s=0;s!==i;++s)e[t+s]=e[n+s]}_slerp(e,t,n,r){Ur.slerpFlat(e,t,e,t,e,n,r)}_slerpAdditive(e,t,n,r,i){const s=this._workIndex*i;Ur.multiplyQuaternionsFlat(e,s,e,t,e,n),Ur.slerpFlat(e,t,e,t,e,s,r)}_lerp(e,t,n,r,i){const s=1-r;for(let a=0;a!==i;++a){const i=t+a;e[i]=e[i]*s+e[n+a]*r}}_lerpAdditive(e,t,n,r,i){for(let s=0;s!==i;++s){const i=t+s;e[i]=e[i]+e[n+s]*r}}}const of="\\[\\]\\.:\\/",lf=new RegExp("["+of+"]","g"),uf="[^"+of+"]",cf="[^"+of.replace("\\.","")+"]",hf=new RegExp("^"+/((?:WC+[\/:])*)/.source.replace("WC",uf)+/(WCOD+)?/.source.replace("WCOD",cf)+/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",uf)+/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",uf)+"$"),df=["material","materials","bones","map"];class pf{constructor(e,t,n){this.path=t,this.parsedPath=n||pf.parseTrackName(t),this.node=pf.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){return e&&e.isAnimationObjectGroup?new pf.Composite(e,t,n):new pf(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(lf,"")}static parseTrackName(e){const t=hf.exec(e);if(null===t)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},r=n.nodeName&&n.nodeName.lastIndexOf(".");if(void 0!==r&&-1!==r){const e=n.nodeName.substring(r+1);-1!==df.indexOf(e)&&(n.nodeName=n.nodeName.substring(0,r),n.objectName=e)}if(null===n.propertyName||0===n.propertyName.length)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return n}static findNode(e,t){if(void 0===t||""===t||"."===t||-1===t||t===e.name||t===e.uuid)return e;if(e.skeleton){const n=e.skeleton.getBoneByName(t);if(void 0!==n)return n}if(e.children){const n=function(e){for(let r=0;r<e.length;r++){const i=e[r];if(i.name===t||i.uuid===t)return i;const s=n(i.children);if(s)return s}return null},r=n(e.children);if(r)return r}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){const n=this.resolvedProperty;for(let r=0,i=n.length;r!==i;++r)e[t++]=n[r]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){const n=this.resolvedProperty;for(let r=0,i=n.length;r!==i;++r)n[r]=e[t++]}_setValue_array_setNeedsUpdate(e,t){const n=this.resolvedProperty;for(let r=0,i=n.length;r!==i;++r)n[r]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){const n=this.resolvedProperty;for(let r=0,i=n.length;r!==i;++r)n[r]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node;const t=this.parsedPath,n=t.objectName,r=t.propertyName;let i=t.propertyIndex;if(e||(e=pf.findNode(this.rootNode,t.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e)return void console.warn("THREE.PropertyBinding: No target node found for track: "+this.path+".");if(n){let r=t.objectIndex;switch(n){case"materials":if(!e.material)return void console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);if(!e.material.materials)return void console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);e=e.material.materials;break;case"bones":if(!e.skeleton)return void console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);e=e.skeleton.bones;for(let t=0;t<e.length;t++)if(e[t].name===r){r=t;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material)return void console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);if(!e.material.map)return void console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);e=e.material.map;break;default:if(void 0===e[n])return void console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);e=e[n]}if(void 0!==r){if(void 0===e[r])return void console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);e=e[r]}}const s=e[r];if(void 0===s){const n=t.nodeName;return void console.error("THREE.PropertyBinding: Trying to update property for track: "+n+"."+r+" but it wasn't found.",e)}let a=this.Versioning.None;this.targetObject=e,void 0!==e.needsUpdate?a=this.Versioning.NeedsUpdate:void 0!==e.matrixWorldNeedsUpdate&&(a=this.Versioning.MatrixWorldNeedsUpdate);let o=this.BindingType.Direct;if(void 0!==i){if("morphTargetInfluences"===r){if(!e.geometry)return void console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);if(!e.geometry.morphAttributes)return void console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);void 0!==e.morphTargetDictionary[i]&&(i=e.morphTargetDictionary[i])}o=this.BindingType.ArrayElement,this.resolvedProperty=s,this.propertyIndex=i}else void 0!==s.fromArray&&void 0!==s.toArray?(o=this.BindingType.HasFromToArray,this.resolvedProperty=s):Array.isArray(s)?(o=this.BindingType.EntireArray,this.resolvedProperty=s):this.propertyName=r;this.getValue=this.GetterByBindingType[o],this.setValue=this.SetterByBindingTypeAndVersioning[o][a]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}pf.Composite=class{constructor(e,t,n){const r=n||pf.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,r)}getValue(e,t){this.bind();const n=this._targetGroup.nCachedObjects_,r=this._bindings[n];void 0!==r&&r.getValue(e,t)}setValue(e,t){const n=this._bindings;for(let r=this._targetGroup.nCachedObjects_,i=n.length;r!==i;++r)n[r].setValue(e,t)}bind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}},pf.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},pf.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},pf.prototype.GetterByBindingType=[pf.prototype._getValue_direct,pf.prototype._getValue_array,pf.prototype._getValue_arrayElement,pf.prototype._getValue_toArray],pf.prototype.SetterByBindingTypeAndVersioning=[[pf.prototype._setValue_direct,pf.prototype._setValue_direct_setNeedsUpdate,pf.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[pf.prototype._setValue_array,pf.prototype._setValue_array_setNeedsUpdate,pf.prototype._setValue_array_setMatrixWorldNeedsUpdate],[pf.prototype._setValue_arrayElement,pf.prototype._setValue_arrayElement_setNeedsUpdate,pf.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[pf.prototype._setValue_fromArray,pf.prototype._setValue_fromArray_setNeedsUpdate,pf.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class ff{constructor(){this.isAnimationObjectGroup=!0,this.uuid=Qn(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;const e={};this._indicesByUUID=e;for(let n=0,r=arguments.length;n!==r;++n)e[arguments[n].uuid]=n;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};const t=this;this.stats={objects:{get total(){return t._objects.length},get inUse(){return this.total-t.nCachedObjects_}},get bindingsPerObject(){return t._bindings.length}}}add(){const e=this._objects,t=this._indicesByUUID,n=this._paths,r=this._parsedPaths,i=this._bindings,s=i.length;let a,o=e.length,l=this.nCachedObjects_;for(let u=0,c=arguments.length;u!==c;++u){const c=arguments[u],h=c.uuid;let d=t[h];if(void 0===d){d=o++,t[h]=d,e.push(c);for(let e=0,t=s;e!==t;++e)i[e].push(new pf(c,n[e],r[e]))}else if(d<l){a=e[d];const o=--l,u=e[o];t[u.uuid]=d,e[d]=u,t[h]=o,e[o]=c;for(let e=0,t=s;e!==t;++e){const t=i[e],s=t[o];let a=t[d];t[d]=s,void 0===a&&(a=new pf(c,n[e],r[e])),t[o]=a}}else e[d]!==a&&console.error("THREE.AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.")}this.nCachedObjects_=l}remove(){const e=this._objects,t=this._indicesByUUID,n=this._bindings,r=n.length;let i=this.nCachedObjects_;for(let s=0,a=arguments.length;s!==a;++s){const a=arguments[s],o=a.uuid,l=t[o];if(void 0!==l&&l>=i){const s=i++,u=e[s];t[u.uuid]=l,e[l]=u,t[o]=s,e[s]=a;for(let e=0,t=r;e!==t;++e){const t=n[e],r=t[s],i=t[l];t[l]=r,t[s]=i}}}this.nCachedObjects_=i}uncache(){const e=this._objects,t=this._indicesByUUID,n=this._bindings,r=n.length;let i=this.nCachedObjects_,s=e.length;for(let a=0,o=arguments.length;a!==o;++a){const o=arguments[a].uuid,l=t[o];if(void 0!==l)if(delete t[o],l<i){const a=--i,o=e[a],u=--s,c=e[u];t[o.uuid]=l,e[l]=o,t[c.uuid]=a,e[a]=c,e.pop();for(let e=0,t=r;e!==t;++e){const t=n[e],r=t[a],i=t[u];t[l]=r,t[a]=i,t.pop()}}else{const i=--s,a=e[i];i>0&&(t[a.uuid]=l),e[l]=a,e.pop();for(let e=0,t=r;e!==t;++e){const t=n[e];t[l]=t[i],t.pop()}}}this.nCachedObjects_=i}subscribe_(e,t){const n=this._bindingsIndicesByPath;let r=n[e];const i=this._bindings;if(void 0!==r)return i[r];const s=this._paths,a=this._parsedPaths,o=this._objects,l=o.length,u=this.nCachedObjects_,c=new Array(l);r=i.length,n[e]=r,s.push(e),a.push(t),i.push(c);for(let h=u,d=o.length;h!==d;++h){const n=o[h];c[h]=new pf(n,e,t)}return c}unsubscribe_(e){const t=this._bindingsIndicesByPath,n=t[e];if(void 0!==n){const r=this._paths,i=this._parsedPaths,s=this._bindings,a=s.length-1,o=s[a];t[e[a]]=n,s[n]=o,s.pop(),i[n]=i[a],i.pop(),r[n]=r[a],r.pop()}}}class mf{constructor(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:t.blendMode;this._mixer=e,this._clip=t,this._localRoot=n,this.blendMode=r;const i=t.tracks,s=i.length,a=new Array(s),o={endingStart:kt,endingEnd:kt};for(let l=0;l!==s;++l){const e=i[l].createInterpolant(null);a[l]=e,e.settings=o}this._interpolantSettings=o,this._interpolants=a,this._propertyBindings=new Array(s),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=Dt,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&&0!==this.timeScale&&null===this._startTime&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,n){if(e.fadeOut(t),this.fadeIn(t),n){const n=this._clip.duration,r=e._clip.duration,i=r/n,s=n/r;e.warp(1,i,t),this.warp(s,1,t)}return this}crossFadeTo(e,t,n){return e.crossFadeFrom(this,t,n)}stopFading(){const e=this._weightInterpolant;return null!==e&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,n){const r=this._mixer,i=r.time,s=this.timeScale;let a=this._timeScaleInterpolant;null===a&&(a=r._lendControlInterpolant(),this._timeScaleInterpolant=a);const o=a.parameterPositions,l=a.sampleValues;return o[0]=i,o[1]=i+n,l[0]=e/s,l[1]=t/s,this}stopWarping(){const e=this._timeScaleInterpolant;return null!==e&&(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)return void this._updateWeight(e);const i=this._startTime;if(null!==i){const r=(e-i)*n;r<0||0===n?t=0:(this._startTime=null,t=n*r)}t*=this._updateTimeScale(e);const s=this._updateTime(t),a=this._updateWeight(e);if(a>0){const e=this._interpolants,t=this._propertyBindings;if(this.blendMode===Vt)for(let n=0,r=e.length;n!==r;++n)e[n].evaluate(s),t[n].accumulateAdditive(a);else for(let n=0,i=e.length;n!==i;++n)e[n].evaluate(s),t[n].accumulate(r,a)}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;const n=this._weightInterpolant;if(null!==n){const r=n.evaluate(e)[0];t*=r,e>n.parameterPositions[1]&&(this.stopFading(),0===r&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;const n=this._timeScaleInterpolant;if(null!==n){t*=n.evaluate(e)[0],e>n.parameterPositions[1]&&(this.stopWarping(),0===t?this.paused=!0:this.timeScale=t)}}return this._effectiveTimeScale=t,t}_updateTime(e){const t=this._clip.duration,n=this.loop;let r=this.time+e,i=this._loopCount;const s=n===Ut;if(0===e)return-1===i?r:s&&1===(1&i)?t-r:r;if(n===Lt){-1===i&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(r>=t)r=t;else{if(!(r<0)){this.time=r;break e}r=0}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(-1===i&&(e>=0?(i=0,this._setEndings(!0,0===this.repetitions,s)):this._setEndings(0===this.repetitions,!0,s)),r>=t||r<0){const n=Math.floor(r/t);r-=t*n,i+=Math.abs(n);const a=this.repetitions-i;if(a<=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(1===a){const t=e<0;this._setEndings(t,!t,s)}else this._setEndings(!1,!1,s);this._loopCount=i,this.time=r,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:n})}}else this.time=r;if(s&&1===(1&i))return t-r}return r}_setEndings(e,t,n){const r=this._interpolantSettings;n?(r.endingStart=Ht,r.endingEnd=Ht):(r.endingStart=e?this.zeroSlopeAtStart?Ht:kt:zt,r.endingEnd=t?this.zeroSlopeAtEnd?Ht:kt:zt)}_scheduleFading(e,t,n){const r=this._mixer,i=r.time;let s=this._weightInterpolant;null===s&&(s=r._lendControlInterpolant(),this._weightInterpolant=s);const a=s.parameterPositions,o=s.sampleValues;return a[0]=i,o[0]=t,a[1]=i+e,o[1]=n,this}}const gf=new Float32Array(1);class vf extends Xn{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){const n=e._localRoot||this._root,r=e._clip.tracks,i=r.length,s=e._propertyBindings,a=e._interpolants,o=n.uuid,l=this._bindingsByRootAndName;let u=l[o];void 0===u&&(u={},l[o]=u);for(let c=0;c!==i;++c){const e=r[c],i=e.name;let l=u[i];if(void 0!==l)++l.referenceCount,s[c]=l;else{if(l=s[c],void 0!==l){null===l._cacheIndex&&(++l.referenceCount,this._addInactiveBinding(l,o,i));continue}const r=t&&t._propertyBindings[c].binding.parsedPath;l=new af(pf.create(n,i,r),e.ValueTypeName,e.getValueSize()),++l.referenceCount,this._addInactiveBinding(l,o,i),s[c]=l}a[c].resultBuffer=l.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(null===e._cacheIndex){const 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)}const t=e._propertyBindings;for(let e=0,n=t.length;e!==n;++e){const n=t[e];0===n.useCount++&&(this._lendBinding(n),n.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){const t=e._propertyBindings;for(let e=0,n=t.length;e!==n;++e){const n=t[e];0===--n.useCount&&(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;const e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){const t=e._cacheIndex;return null!==t&&t<this._nActiveActions}_addInactiveAction(e,t,n){const r=this._actions,i=this._actionsByClip;let s=i[t];if(void 0===s)s={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,i[t]=s;else{const t=s.knownActions;e._byClipCacheIndex=t.length,t.push(e)}e._cacheIndex=r.length,r.push(e),s.actionByRoot[n]=e}_removeInactiveAction(e){const t=this._actions,n=t[t.length-1],r=e._cacheIndex;n._cacheIndex=r,t[r]=n,t.pop(),e._cacheIndex=null;const i=e._clip.uuid,s=this._actionsByClip,a=s[i],o=a.knownActions,l=o[o.length-1],u=e._byClipCacheIndex;l._byClipCacheIndex=u,o[u]=l,o.pop(),e._byClipCacheIndex=null;delete a.actionByRoot[(e._localRoot||this._root).uuid],0===o.length&&delete s[i],this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){const t=e._propertyBindings;for(let n=0,r=t.length;n!==r;++n){const e=t[n];0===--e.referenceCount&&this._removeInactiveBinding(e)}}_lendAction(e){const t=this._actions,n=e._cacheIndex,r=this._nActiveActions++,i=t[r];e._cacheIndex=r,t[r]=e,i._cacheIndex=n,t[n]=i}_takeBackAction(e){const t=this._actions,n=e._cacheIndex,r=--this._nActiveActions,i=t[r];e._cacheIndex=r,t[r]=e,i._cacheIndex=n,t[n]=i}_addInactiveBinding(e,t,n){const r=this._bindingsByRootAndName,i=this._bindings;let s=r[t];void 0===s&&(s={},r[t]=s),s[n]=e,e._cacheIndex=i.length,i.push(e)}_removeInactiveBinding(e){const t=this._bindings,n=e.binding,r=n.rootNode.uuid,i=n.path,s=this._bindingsByRootAndName,a=s[r],o=t[t.length-1],l=e._cacheIndex;o._cacheIndex=l,t[l]=o,t.pop(),delete a[i],0===Object.keys(a).length&&delete s[r]}_lendBinding(e){const t=this._bindings,n=e._cacheIndex,r=this._nActiveBindings++,i=t[r];e._cacheIndex=r,t[r]=e,i._cacheIndex=n,t[n]=i}_takeBackBinding(e){const t=this._bindings,n=e._cacheIndex,r=--this._nActiveBindings,i=t[r];e._cacheIndex=r,t[r]=e,i._cacheIndex=n,t[n]=i}_lendControlInterpolant(){const e=this._controlInterpolants,t=this._nActiveControlInterpolants++;let n=e[t];return void 0===n&&(n=new kd(new Float32Array(2),new Float32Array(2),1,gf),n.__cacheIndex=t,e[t]=n),n}_takeBackControlInterpolant(e){const t=this._controlInterpolants,n=e.__cacheIndex,r=--this._nActiveControlInterpolants,i=t[r];e.__cacheIndex=r,t[r]=e,i.__cacheIndex=n,t[n]=i}clipAction(e,t,n){const r=t||this._root,i=r.uuid;let s="string"===typeof e?Kd.findByName(r,e):e;const a=null!==s?s.uuid:e,o=this._actionsByClip[a];let l=null;if(void 0===n&&(n=null!==s?s.blendMode:Gt),void 0!==o){const e=o.actionByRoot[i];if(void 0!==e&&e.blendMode===n)return e;l=o.knownActions[0],null===s&&(s=l._clip)}if(null===s)return null;const u=new mf(this,s,t,n);return this._bindAction(u,l),this._addInactiveAction(u,a,i),u}existingAction(e,t){const n=t||this._root,r=n.uuid,i="string"===typeof e?Kd.findByName(n,e):e,s=i?i.uuid:e,a=this._actionsByClip[s];return void 0!==a&&a.actionByRoot[r]||null}stopAllAction(){const e=this._actions;for(let t=this._nActiveActions-1;t>=0;--t)e[t].stop();return this}update(e){e*=this.timeScale;const t=this._actions,n=this._nActiveActions,r=this.time+=e,i=Math.sign(e),s=this._accuIndex^=1;for(let l=0;l!==n;++l){t[l]._update(r,e,i,s)}const a=this._bindings,o=this._nActiveBindings;for(let l=0;l!==o;++l)a[l].apply(s);return this}setTime(e){this.time=0;for(let t=0;t<this._actions.length;t++)this._actions[t].time=0;return this.update(e)}getRoot(){return this._root}uncacheClip(e){const t=this._actions,n=e.uuid,r=this._actionsByClip,i=r[n];if(void 0!==i){const e=i.knownActions;for(let n=0,r=e.length;n!==r;++n){const r=e[n];this._deactivateAction(r);const i=r._cacheIndex,s=t[t.length-1];r._cacheIndex=null,r._byClipCacheIndex=null,s._cacheIndex=i,t[i]=s,t.pop(),this._removeInactiveBindingsForAction(r)}delete r[n]}}uncacheRoot(e){const t=e.uuid,n=this._actionsByClip;for(const i in n){const e=n[i].actionByRoot[t];void 0!==e&&(this._deactivateAction(e),this._removeInactiveAction(e))}const r=this._bindingsByRootAndName[t];if(void 0!==r)for(const i in r){const e=r[i];e.restoreOriginalState(),this._removeInactiveBinding(e)}}uncacheAction(e,t){const n=this.existingAction(e,t);null!==n&&(this._deactivateAction(n),this._removeInactiveAction(n))}}class yf{constructor(e){this.value=e}clone(){return new yf(void 0===this.value.clone?this.value:this.value.clone())}}let _f=0;class xf extends Xn{constructor(){super(),this.isUniformsGroup=!0,Object.defineProperty(this,"id",{value:_f++}),this.name="",this.usage=Ln,this.uniforms=[]}add(e){return this.uniforms.push(e),this}remove(e){const t=this.uniforms.indexOf(e);return-1!==t&&this.uniforms.splice(t,1),this}setName(e){return this.name=e,this}setUsage(e){return this.usage=e,this}dispose(){return this.dispatchEvent({type:"dispose"}),this}copy(e){this.name=e.name,this.usage=e.usage;const t=e.uniforms;this.uniforms.length=0;for(let n=0,r=t.length;n<r;n++){const e=Array.isArray(t[n])?t[n]:[t[n]];for(let t=0;t<e.length;t++)this.uniforms.push(e[t].clone())}return this}clone(){return(new this.constructor).copy(this)}}class Af extends fu{constructor(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;super(e,t),this.isInstancedInterleavedBuffer=!0,this.meshPerAttribute=n}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}clone(e){const t=super.clone(e);return t.meshPerAttribute=this.meshPerAttribute,t}toJSON(e){const t=super.toJSON(e);return t.isInstancedInterleavedBuffer=!0,t.meshPerAttribute=this.meshPerAttribute,t}}class Mf{constructor(e,t,n,r,i){this.isGLBufferAttribute=!0,this.name="",this.buffer=e,this.type=t,this.itemSize=n,this.elementSize=r,this.count=i,this.version=0}set needsUpdate(e){!0===e&&this.version++}setBuffer(e){return this.buffer=e,this}setType(e,t){return this.type=e,this.elementSize=t,this}setItemSize(e){return this.itemSize=e,this}setCount(e){return this.count=e,this}}const bf=new di;class Sf{constructor(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1/0;this.ray=new hi(e,t),this.near=n,this.far=r,this.camera=null,this.layers=new bi,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,(t.near+t.far)/(t.near-t.far)).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):console.error("THREE.Raycaster: Unsupported camera type: "+t.type)}setFromXRController(e){return bf.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(bf),this}intersectObject(e){let t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[];return Ef(e,this,t,!(arguments.length>1&&void 0!==arguments[1])||arguments[1]),t.sort(wf),t}intersectObjects(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[];for(let r=0,i=e.length;r<i;r++)Ef(e[r],this,n,t);return n.sort(wf),n}}function wf(e,t){return e.distance-t.distance}function Ef(e,t,n,r){let i=!0;if(e.layers.test(t.layers)){!1===e.raycast(t,n)&&(i=!1)}if(!0===i&&!0===r){const r=e.children;for(let e=0,i=r.length;e<i;e++)Ef(r[e],t,n,!0)}}class Tf{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return this.radius=e,this.phi=t,this.theta=n,this}set(e,t,n){return this.radius=e,this.phi=t,this.theta=n,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){const e=1e-6;return this.phi=Math.max(e,Math.min(Math.PI-e,this.phi)),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,n){return this.radius=Math.sqrt(e*e+t*t+n*n),0===this.radius?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,n),this.phi=Math.acos(Zn(t/this.radius,-1,1))),this}clone(){return(new this.constructor).copy(this)}}class Cf{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return this.radius=e,this.theta=t,this.y=n,this}set(e,t,n){return this.radius=e,this.theta=t,this.y=n,this}copy(e){return this.radius=e.radius,this.theta=e.theta,this.y=e.y,this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,n){return this.radius=Math.sqrt(e*e+n*n),this.theta=Math.atan2(e,n),this.y=t,this}clone(){return(new this.constructor).copy(this)}}class Rf{constructor(e,t,n,r){Rf.prototype.isMatrix2=!0,this.elements=[1,0,0,1],void 0!==e&&this.set(e,t,n,r)}identity(){return this.set(1,0,0,1),this}fromArray(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;for(let n=0;n<4;n++)this.elements[n]=e[n+t];return this}set(e,t,n,r){const i=this.elements;return i[0]=e,i[2]=t,i[1]=n,i[3]=r,this}}const Pf=new ir;class If{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new ir(1/0,1/0),t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new ir(-1/0,-1/0);this.isBox2=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const n=Pf.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}clone(){return(new this.constructor).copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(e){return this.isEmpty()?e.set(0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}containsPoint(e){return e.x>=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,Pf).distanceTo(e)}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}const Bf=new Nr,Lf=new Nr;class Df{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new Nr,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new Nr;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){Bf.subVectors(e,this.start),Lf.subVectors(this.end,this.start);const n=Lf.dot(Lf);let r=Lf.dot(Bf)/n;return t&&(r=Zn(r,0,1)),r}closestPointToPoint(e,t,n){const r=this.closestPointToPointParameter(e,t);return this.delta(n).multiplyScalar(r).add(this.start)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return(new this.constructor).copy(this)}}const Uf=new Nr;class Nf extends ki{constructor(e,t){super(),this.light=e,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";const n=new Ps,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 s=0,a=1,o=32;s<o;s++,a++){const e=s/o*Math.PI*2,t=a/o*Math.PI*2;r.push(Math.cos(e),Math.sin(e),1,Math.cos(t),Math.sin(t),1)}n.setAttribute("position",new Ms(r,3));const i=new wc({fog:!1,toneMapped:!1});this.cone=new Fc(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);const e=this.light.distance?this.light.distance:1e3,t=e*Math.tan(this.light.angle);this.cone.scale.set(t,t,e),Uf.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(Uf),void 0!==this.color?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}}const Ff=new Nr,Of=new di,kf=new di;class Hf extends Fc{constructor(e){const t=zf(e),n=new Ps,r=[],i=[],s=new ts(0,0,1),a=new ts(0,1,0);for(let o=0;o<t.length;o++){const e=t[o];e.parent&&e.parent.isBone&&(r.push(0,0,0),r.push(0,0,0),i.push(s.r,s.g,s.b),i.push(a.r,a.g,a.b))}n.setAttribute("position",new Ms(r,3)),n.setAttribute("color",new Ms(i,3));super(n,new wc({vertexColors:!0,depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0})),this.isSkeletonHelper=!0,this.type="SkeletonHelper",this.root=e,this.bones=t,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1}updateMatrixWorld(e){const t=this.bones,n=this.geometry,r=n.getAttribute("position");kf.copy(this.root.matrixWorld).invert();for(let i=0,s=0;i<t.length;i++){const e=t[i];e.parent&&e.parent.isBone&&(Of.multiplyMatrices(kf,e.matrixWorld),Ff.setFromMatrixPosition(Of),r.setXYZ(s,Ff.x,Ff.y,Ff.z),Of.multiplyMatrices(kf,e.parent.matrixWorld),Ff.setFromMatrixPosition(Of),r.setXYZ(s+1,Ff.x,Ff.y,Ff.z),s+=2)}n.getAttribute("position").needsUpdate=!0,super.updateMatrixWorld(e)}dispose(){this.geometry.dispose(),this.material.dispose()}}function zf(e){const t=[];!0===e.isBone&&t.push(e);for(let n=0;n<e.children.length;n++)t.push.apply(t,zf(e.children[n]));return t}class Gf extends Ys{constructor(e,t,n){super(new pd(t,4,2),new ss({wireframe:!0,fog:!1,toneMapped:!1})),this.light=e,this.color=n,this.type="PointLightHelper",this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}dispose(){this.geometry.dispose(),this.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),void 0!==this.color?this.material.color.set(this.color):this.material.color.copy(this.light.color)}}const Vf=new Nr,Wf=new ts,jf=new ts;class Xf extends ki{constructor(e,t,n){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=n,this.type="HemisphereLightHelper";const r=new cd(t);r.rotateY(.5*Math.PI),this.material=new ss({wireframe:!0,fog:!1,toneMapped:!1}),void 0===this.color&&(this.material.vertexColors=!0);const i=r.getAttribute("position"),s=new Float32Array(3*i.count);r.setAttribute("color",new ps(s,3)),this.add(new Ys(r,this.material)),this.update()}dispose(){this.children[0].geometry.dispose(),this.children[0].material.dispose()}update(){const e=this.children[0];if(void 0!==this.color)this.material.color.set(this.color);else{const t=e.geometry.getAttribute("color");Wf.copy(this.light.color),jf.copy(this.light.groundColor);for(let e=0,n=t.count;e<n;e++){const r=e<n/2?Wf:jf;t.setXYZ(e,r.r,r.g,r.b)}t.needsUpdate=!0}this.light.updateWorldMatrix(!0,!1),e.lookAt(Vf.setFromMatrixPosition(this.light.matrixWorld).negate())}}class Jf extends Fc{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:10,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:10,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:4473924,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:8947848;n=new ts(n),r=new ts(r);const i=t/2,s=e/t,a=e/2,o=[],l=[];for(let c=0,h=0,d=-a;c<=t;c++,d+=s){o.push(-a,0,d,a,0,d),o.push(d,0,-a,d,0,a);const e=c===i?n:r;e.toArray(l,h),h+=3,e.toArray(l,h),h+=3,e.toArray(l,h),h+=3,e.toArray(l,h),h+=3}const u=new Ps;u.setAttribute("position",new Ms(o,3)),u.setAttribute("color",new Ms(l,3));super(u,new wc({vertexColors:!0,toneMapped:!1})),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}class Yf extends Fc{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:10,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:16,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:8,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:64,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:4473924,s=arguments.length>5&&void 0!==arguments[5]?arguments[5]:8947848;i=new ts(i),s=new ts(s);const a=[],o=[];if(t>1)for(let u=0;u<t;u++){const n=u/t*(2*Math.PI),r=Math.sin(n)*e,l=Math.cos(n)*e;a.push(0,0,0),a.push(r,0,l);const c=1&u?i:s;o.push(c.r,c.g,c.b),o.push(c.r,c.g,c.b)}for(let u=0;u<n;u++){const t=1&u?i:s,l=e-e/n*u;for(let e=0;e<r;e++){let n=e/r*(2*Math.PI),i=Math.sin(n)*l,s=Math.cos(n)*l;a.push(i,0,s),o.push(t.r,t.g,t.b),n=(e+1)/r*(2*Math.PI),i=Math.sin(n)*l,s=Math.cos(n)*l,a.push(i,0,s),o.push(t.r,t.g,t.b)}}const l=new Ps;l.setAttribute("position",new Ms(a,3)),l.setAttribute("color",new Ms(o,3));super(l,new wc({vertexColors:!0,toneMapped:!1})),this.type="PolarGridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}const Kf=new Nr,qf=new Nr,Qf=new Nr;class Zf extends ki{constructor(e,t,n){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=n,this.type="DirectionalLightHelper",void 0===t&&(t=1);let r=new Ps;r.setAttribute("position",new Ms([-t,t,0,t,t,0,t,-t,0,-t,-t,0,-t,t,0],3));const i=new wc({fog:!1,toneMapped:!1});this.lightPlane=new Lc(r,i),this.add(this.lightPlane),r=new Ps,r.setAttribute("position",new Ms([0,0,0,0,0,1],3)),this.targetLine=new Lc(r,i),this.add(this.targetLine),this.update()}dispose(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),Kf.setFromMatrixPosition(this.light.matrixWorld),qf.setFromMatrixPosition(this.light.target.matrixWorld),Qf.subVectors(qf,Kf),this.lightPlane.lookAt(qf),void 0!==this.color?(this.lightPlane.material.color.set(this.color),this.targetLine.material.color.set(this.color)):(this.lightPlane.material.color.copy(this.light.color),this.targetLine.material.color.copy(this.light.color)),this.targetLine.lookAt(qf),this.targetLine.scale.z=Qf.length()}}const $f=new Nr,em=new na;class tm extends Fc{constructor(e){const t=new Ps,n=new wc({color:16777215,vertexColors:!0,toneMapped:!1}),r=[],i=[],s={};function a(e,t){o(e),o(t)}function o(e){r.push(0,0,0),i.push(0,0,0),void 0===s[e]&&(s[e]=[]),s[e].push(r.length/3-1)}a("n1","n2"),a("n2","n4"),a("n4","n3"),a("n3","n1"),a("f1","f2"),a("f2","f4"),a("f4","f3"),a("f3","f1"),a("n1","f1"),a("n2","f2"),a("n3","f3"),a("n4","f4"),a("p","n1"),a("p","n2"),a("p","n3"),a("p","n4"),a("u1","u2"),a("u2","u3"),a("u3","u1"),a("c","t"),a("p","c"),a("cn1","cn2"),a("cn3","cn4"),a("cf1","cf2"),a("cf3","cf4"),t.setAttribute("position",new Ms(r,3)),t.setAttribute("color",new Ms(i,3)),super(t,n),this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=s,this.update();const l=new ts(16755200),u=new ts(16711680),c=new ts(43775),h=new ts(16777215),d=new ts(3355443);this.setColors(l,u,c,h,d)}setColors(e,t,n,r,i){const s=this.geometry.getAttribute("color");s.setXYZ(0,e.r,e.g,e.b),s.setXYZ(1,e.r,e.g,e.b),s.setXYZ(2,e.r,e.g,e.b),s.setXYZ(3,e.r,e.g,e.b),s.setXYZ(4,e.r,e.g,e.b),s.setXYZ(5,e.r,e.g,e.b),s.setXYZ(6,e.r,e.g,e.b),s.setXYZ(7,e.r,e.g,e.b),s.setXYZ(8,e.r,e.g,e.b),s.setXYZ(9,e.r,e.g,e.b),s.setXYZ(10,e.r,e.g,e.b),s.setXYZ(11,e.r,e.g,e.b),s.setXYZ(12,e.r,e.g,e.b),s.setXYZ(13,e.r,e.g,e.b),s.setXYZ(14,e.r,e.g,e.b),s.setXYZ(15,e.r,e.g,e.b),s.setXYZ(16,e.r,e.g,e.b),s.setXYZ(17,e.r,e.g,e.b),s.setXYZ(18,e.r,e.g,e.b),s.setXYZ(19,e.r,e.g,e.b),s.setXYZ(20,e.r,e.g,e.b),s.setXYZ(21,e.r,e.g,e.b),s.setXYZ(22,e.r,e.g,e.b),s.setXYZ(23,e.r,e.g,e.b),s.setXYZ(24,t.r,t.g,t.b),s.setXYZ(25,t.r,t.g,t.b),s.setXYZ(26,t.r,t.g,t.b),s.setXYZ(27,t.r,t.g,t.b),s.setXYZ(28,t.r,t.g,t.b),s.setXYZ(29,t.r,t.g,t.b),s.setXYZ(30,t.r,t.g,t.b),s.setXYZ(31,t.r,t.g,t.b),s.setXYZ(32,n.r,n.g,n.b),s.setXYZ(33,n.r,n.g,n.b),s.setXYZ(34,n.r,n.g,n.b),s.setXYZ(35,n.r,n.g,n.b),s.setXYZ(36,n.r,n.g,n.b),s.setXYZ(37,n.r,n.g,n.b),s.setXYZ(38,r.r,r.g,r.b),s.setXYZ(39,r.r,r.g,r.b),s.setXYZ(40,i.r,i.g,i.b),s.setXYZ(41,i.r,i.g,i.b),s.setXYZ(42,i.r,i.g,i.b),s.setXYZ(43,i.r,i.g,i.b),s.setXYZ(44,i.r,i.g,i.b),s.setXYZ(45,i.r,i.g,i.b),s.setXYZ(46,i.r,i.g,i.b),s.setXYZ(47,i.r,i.g,i.b),s.setXYZ(48,i.r,i.g,i.b),s.setXYZ(49,i.r,i.g,i.b),s.needsUpdate=!0}update(){const e=this.geometry,t=this.pointMap;em.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),nm("c",t,e,em,0,0,-1),nm("t",t,e,em,0,0,1),nm("n1",t,e,em,-1,-1,-1),nm("n2",t,e,em,1,-1,-1),nm("n3",t,e,em,-1,1,-1),nm("n4",t,e,em,1,1,-1),nm("f1",t,e,em,-1,-1,1),nm("f2",t,e,em,1,-1,1),nm("f3",t,e,em,-1,1,1),nm("f4",t,e,em,1,1,1),nm("u1",t,e,em,.7,1.1,-1),nm("u2",t,e,em,-.7,1.1,-1),nm("u3",t,e,em,0,2,-1),nm("cf1",t,e,em,-1,0,1),nm("cf2",t,e,em,1,0,1),nm("cf3",t,e,em,0,-1,1),nm("cf4",t,e,em,0,1,1),nm("cn1",t,e,em,-1,0,-1),nm("cn2",t,e,em,1,0,-1),nm("cn3",t,e,em,0,-1,-1),nm("cn4",t,e,em,0,1,-1),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}}function nm(e,t,n,r,i,s,a){$f.set(i,s,a).unproject(r);const o=t[e];if(void 0!==o){const e=n.getAttribute("position");for(let t=0,n=o.length;t<n;t++)e.setXYZ(o[t],$f.x,$f.y,$f.z)}}const rm=new kr;class im extends Fc{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:16776960;const n=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),r=new Float32Array(24),i=new Ps;i.setIndex(new ps(n,1)),i.setAttribute("position",new ps(r,3)),super(i,new wc({color:t,toneMapped:!1})),this.object=e,this.type="BoxHelper",this.matrixAutoUpdate=!1,this.update()}update(e){if(void 0!==e&&console.warn("THREE.BoxHelper: .update() has no longer arguments."),void 0!==this.object&&rm.setFromObject(this.object),rm.isEmpty())return;const t=rm.min,n=rm.max,r=this.geometry.attributes.position,i=r.array;i[0]=n.x,i[1]=n.y,i[2]=n.z,i[3]=t.x,i[4]=n.y,i[5]=n.z,i[6]=t.x,i[7]=t.y,i[8]=n.z,i[9]=n.x,i[10]=t.y,i[11]=n.z,i[12]=n.x,i[13]=n.y,i[14]=t.z,i[15]=t.x,i[16]=n.y,i[17]=t.z,i[18]=t.x,i[19]=t.y,i[20]=t.z,i[21]=n.x,i[22]=t.y,i[23]=t.z,r.needsUpdate=!0,this.geometry.computeBoundingSphere()}setFromObject(e){return this.object=e,this.update(),this}copy(e,t){return super.copy(e,t),this.object=e.object,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class sm extends Fc{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:16776960;const n=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),r=new Ps;r.setIndex(new ps(n,1)),r.setAttribute("position",new Ms([1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],3)),super(r,new wc({color:t,toneMapped:!1})),this.box=e,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(e){const t=this.box;t.isEmpty()||(t.getCenter(this.position),t.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(e))}dispose(){this.geometry.dispose(),this.material.dispose()}}class am extends Lc{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;const n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:16776960,r=new Ps;r.setAttribute("position",new Ms([1,-1,0,-1,1,0,-1,-1,0,1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],3)),r.computeBoundingSphere(),super(r,new wc({color:n,toneMapped:!1})),this.type="PlaneHelper",this.plane=e,this.size=t;const i=new Ps;i.setAttribute("position",new Ms([1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],3)),i.computeBoundingSphere(),this.add(new Ys(i,new ss({color:n,opacity:.2,transparent:!0,depthWrite:!1,toneMapped:!1})))}updateMatrixWorld(e){this.position.set(0,0,0),this.scale.set(.5*this.size,.5*this.size,1),this.lookAt(this.plane.normal),this.translateZ(-this.plane.constant),super.updateMatrixWorld(e)}dispose(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()}}const om=new Nr;let lm,um;class cm extends ki{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new Nr(0,0,1),t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new Nr(0,0,0),n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:16776960,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:.2*n,s=arguments.length>5&&void 0!==arguments[5]?arguments[5]:.2*i;super(),this.type="ArrowHelper",void 0===lm&&(lm=new Ps,lm.setAttribute("position",new Ms([0,0,0,0,1,0],3)),um=new bh(0,.5,1,5,1),um.translate(0,-.5,0)),this.position.copy(t),this.line=new Lc(lm,new wc({color:r,toneMapped:!1})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new Ys(um,new ss({color:r,toneMapped:!1})),this.cone.matrixAutoUpdate=!1,this.add(this.cone),this.setDirection(e),this.setLength(n,i,s)}setDirection(e){if(e.y>.99999)this.quaternion.set(0,0,0,1);else if(e.y<-.99999)this.quaternion.set(1,0,0,0);else{om.set(e.z,0,-e.x).normalize();const t=Math.acos(e.y);this.quaternion.setFromAxisAngle(om,t)}}setLength(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:.2*e,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:.2*t;this.line.scale.set(1,Math.max(1e-4,e-t),1),this.line.updateMatrix(),this.cone.scale.set(n,t,n),this.cone.position.y=e,this.cone.updateMatrix()}setColor(e){this.line.material.color.set(e),this.cone.material.color.set(e)}copy(e){return super.copy(e,!1),this.line.copy(e.line),this.cone.copy(e.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}}class hm extends Fc{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;const t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],n=new Ps;n.setAttribute("position",new Ms(t,3)),n.setAttribute("color",new Ms([1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],3));super(n,new wc({vertexColors:!0,toneMapped:!1})),this.type="AxesHelper"}setColors(e,t,n){const r=new ts,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()}}class dm{constructor(){this.type="ShapePath",this.color=new ts,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new _h,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,s){return this.currentPath.bezierCurveTo(e,t,n,r,i,s),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(e){function t(e,t){const n=t.length;let r=!1;for(let i=n-1,s=0;s<n;i=s++){let n=t[i],a=t[s],o=a.x-n.x,l=a.y-n.y;if(Math.abs(l)>Number.EPSILON){if(l<0&&(n=t[s],o=-o,a=t[i],l=-l),e.y<n.y||e.y>a.y)continue;if(e.y===n.y){if(e.x===n.x)return!0}else{const t=l*(e.x-n.x)-o*(e.y-n.y);if(0===t)return!0;if(t<0)continue;r=!r}}else{if(e.y!==n.y)continue;if(a.x<=e.x&&e.x<=n.x||n.x<=e.x&&e.x<=a.x)return!0}}return r}const n=id.isClockWise,r=this.subPaths;if(0===r.length)return[];let i,s,a;const o=[];if(1===r.length)return s=r[0],a=new Bh,a.curves=s.curves,o.push(a),o;let l=!n(r[0].getPoints());l=e?!l:l;const u=[],c=[];let h,d,p=[],f=0;c[f]=void 0,p[f]=[];for(let m=0,g=r.length;m<g;m++)s=r[m],h=s.getPoints(),i=n(h),i=e?!i:i,i?(!l&&c[f]&&f++,c[f]={s:new Bh,p:h},c[f].s.curves=s.curves,l&&f++,p[f]=[]):p[f].push({h:s,p:h[0]});if(!c[0])return function(e){const t=[];for(let n=0,r=e.length;n<r;n++){const r=e[n],i=new Bh;i.curves=r.curves,t.push(i)}return t}(r);if(c.length>1){let e=!1,n=0;for(let t=0,r=c.length;t<r;t++)u[t]=[];for(let r=0,i=c.length;r<i;r++){const i=p[r];for(let s=0;s<i.length;s++){const a=i[s];let o=!0;for(let i=0;i<c.length;i++)t(a.p,c[i].p)&&(r!==i&&n++,o?(o=!1,u[i].push(a)):e=!0);o&&u[r].push(a)}}n>0&&!1===e&&(p=u)}for(let m=0,g=c.length;m<g;m++){a=c[m].s,o.push(a),d=p[m];for(let e=0,t=d.length;e<t;e++)a.holes.push(d[e].h)}return o}}class pm extends Pr{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};console.warn('THREE.WebGLMultipleRenderTargets has been deprecated and will be removed in r172. Use THREE.WebGLRenderTarget and set the "count" parameter to enable MRT.'),super(e,t,{...r,count:n}),this.isWebGLMultipleRenderTargets=!0}get texture(){return this.textures}}"undefined"!==typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:i}})),"undefined"!==typeof window&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=i);const fm=new WeakMap;class mm extends ep{constructor(e){super(e),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(e){return this.decoderPath=e,this}setDecoderConfig(e){return this.decoderConfig=e,this}setWorkerLimit(e){return this.workerLimit=e,this}load(e,t,n,r){const i=new rp(this.manager);i.setPath(this.path),i.setResponseType("arraybuffer"),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials),i.load(e,(e=>{const n={attributeIDs:this.defaultAttributeIDs,attributeTypes:this.defaultAttributeTypes,useUniqueIDs:!1};this.decodeGeometry(e,n).then(t).catch(r)}),n,r)}decodeDracoFile(e,t,n,r){const i={attributeIDs:n||this.defaultAttributeIDs,attributeTypes:r||this.defaultAttributeTypes,useUniqueIDs:!!n};this.decodeGeometry(e,i).then(t)}decodeGeometry(e,t){for(const o in t.attributeTypes){const e=t.attributeTypes[o];void 0!==e.BYTES_PER_ELEMENT&&(t.attributeTypes[o]=e.name)}const n=JSON.stringify(t);if(fm.has(e)){const t=fm.get(e);if(t.key===n)return t.promise;if(0===e.byteLength)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let r;const i=this.workerNextTaskID++,s=e.byteLength,a=this._getWorker(i,s).then((n=>(r=n,new Promise(((n,s)=>{r._callbacks[i]={resolve:n,reject:s},r.postMessage({type:"decode",id:i,taskConfig:t,buffer:e},[e])}))))).then((e=>this._createGeometry(e.geometry)));return a.catch((()=>!0)).then((()=>{r&&i&&this._releaseTask(r,i)})),fm.set(e,{key:n,promise:a}),a}_createGeometry(e){const t=new Ps;e.index&&t.setIndex(new ps(e.index.array,1));for(let n=0;n<e.attributes.length;n++){const r=e.attributes[n],i=r.name,s=r.array,a=r.itemSize;t.setAttribute(i,new ps(s,a))}return t}_loadLibrary(e,t){const n=new rp(this.manager);return n.setPath(this.decoderPath),n.setResponseType(t),n.setWithCredentials(this.withCredentials),new Promise(((t,r)=>{n.load(e,t,void 0,r)}))}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const e="object"!==typeof WebAssembly||"js"===this.decoderConfig.type,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=>{const n=t[0];e||(this.decoderConfig.wasmBinary=t[1]);const r=gm.toString(),i=["/* draco decoder */",n,"","/* worker */",r.substring(r.indexOf("{")+1,r.lastIndexOf("}"))].join("\n");this.workerSourceURL=URL.createObjectURL(new Blob([i]))})),this.decoderPending}_getWorker(e,t){return this._initDecoder().then((()=>{if(this.workerPool.length<this.workerLimit){const e=new Worker(this.workerSourceURL);e._callbacks={},e._taskCosts={},e._taskLoad=0,e.postMessage({type:"init",decoderConfig:this.decoderConfig}),e.onmessage=function(t){const n=t.data;switch(n.type){case"decode":e._callbacks[n.id].resolve(n);break;case"error":e._callbacks[n.id].reject(n);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+n.type+'"')}},this.workerPool.push(e)}else this.workerPool.sort((function(e,t){return e._taskLoad>t._taskLoad?-1:1}));const 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<this.workerPool.length;++e)this.workerPool[e].terminate();return this.workerPool.length=0,this}}function gm(){let e,t;function n(e,t,n,r,i,s){const a=s.num_components(),o=n.num_points()*a,l=o*i.BYTES_PER_ELEMENT,u=function(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}}(e,i),c=e._malloc(l);t.GetAttributeDataArrayForAllPoints(n,s,u,l,c);const h=new i(e.HEAPF32.buffer,c,o).slice();return e._free(c),{name:r,array:h,itemSize:a}}onmessage=function(r){const i=r.data;switch(i.type){case"init":e=i.decoderConfig,t=new Promise((function(t){e.onModuleLoaded=function(e){t({draco:e})},DracoDecoderModule(e)}));break;case"decode":const r=i.buffer,s=i.taskConfig;t.then((e=>{const t=e.draco,a=new t.Decoder,o=new t.DecoderBuffer;o.Init(new Int8Array(r),r.byteLength);try{const e=function(e,t,r,i){const s=i.attributeIDs,a=i.attributeTypes;let o,l;const u=t.GetEncodedGeometryType(r);if(u===e.TRIANGULAR_MESH)o=new e.Mesh,l=t.DecodeBufferToMesh(r,o);else{if(u!==e.POINT_CLOUD)throw new Error("THREE.DRACOLoader: Unexpected geometry type.");o=new e.PointCloud,l=t.DecodeBufferToPointCloud(r,o)}if(!l.ok()||0===o.ptr)throw new Error("THREE.DRACOLoader: Decoding failed: "+l.error_msg());const c={index:null,attributes:[]};for(const h in s){const r=self[a[h]];let l,u;if(i.useUniqueIDs)u=s[h],l=t.GetAttributeByUniqueId(o,u);else{if(u=t.GetAttributeId(o,e[s[h]]),-1===u)continue;l=t.GetAttribute(o,u)}c.attributes.push(n(e,t,o,h,r,l))}u===e.TRIANGULAR_MESH&&(c.index=function(e,t,n){const r=n.num_faces(),i=3*r,s=4*i,a=e._malloc(s);t.GetTrianglesUInt32Array(n,s,a);const o=new Uint32Array(e.HEAPF32.buffer,a,i).slice();return e._free(a),{array:o,itemSize:1}}(e,t,o));return e.destroy(o),c}(t,a,o,s),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(by){console.error(by),self.postMessage({type:"error",id:i.id,error:by.message})}finally{t.destroy(o),t.destroy(a)}}))}}}let vm;const ym=()=>{if(vm)return vm;const 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("object"!==typeof WebAssembly)return{supported:!1};let n,r="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)&&(r="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");const i=WebAssembly.instantiate(function(e){const n=new Uint8Array(e.length);for(let t=0;t<e.length;++t){const r=e.charCodeAt(t);n[t]=r>96?r-71:r>64?r-65:r>47?r+4:r>46?63:62}let r=0;for(let i=0;i<e.length;++i)n[r++]=n[i]<60?t[n[i]]:64*(n[i]-60)+n[++i];return n.buffer.slice(0,r)}(r),{}).then((e=>{n=e.instance,n.exports.__wasm_call_ctors()}));function s(e,t,r,i,s,a){const o=n.exports.sbrk,l=r+3&-4,u=o(l*i),c=o(s.length),h=new Uint8Array(n.exports.memory.buffer);h.set(s,c);const d=e(u,r,i,c,s.length);if(0===d&&a&&a(u,l,i),t.set(h.subarray(u,u+r*i)),o(u-o(0)),0!==d)throw new Error(`Malformed buffer data: ${d}`)}const a={0:"",1:"meshopt_decodeFilterOct",2:"meshopt_decodeFilterQuat",3:"meshopt_decodeFilterExp",NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},o={0:"meshopt_decodeVertexBuffer",1:"meshopt_decodeIndexBuffer",2:"meshopt_decodeIndexSequence",ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};return vm={ready:i,supported:!0,decodeVertexBuffer(e,t,r,i,o){s(n.exports.meshopt_decodeVertexBuffer,e,t,r,i,n.exports[a[o]])},decodeIndexBuffer(e,t,r,i){s(n.exports.meshopt_decodeIndexBuffer,e,t,r,i)},decodeIndexSequence(e,t,r,i){s(n.exports.meshopt_decodeIndexSequence,e,t,r,i)},decodeGltfBuffer(e,t,r,i,l,u){s(n.exports[o[l]],e,t,r,i,n.exports[a[u]])}},vm};function _m(e,t){if(t===Wt)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),e;if(t===Xt||t===jt){let n=e.getIndex();if(null===n){const t=[],r=e.getAttribute("position");if(void 0===r)return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),e;for(let e=0;e<r.count;e++)t.push(e);e.setIndex(t),n=e.getIndex()}const r=n.count-2,i=[];if(n)if(t===Xt)for(let e=1;e<=r;e++)i.push(n.getX(0)),i.push(n.getX(e)),i.push(n.getX(e+1));else for(let e=0;e<r;e++)e%2===0?(i.push(n.getX(e)),i.push(n.getX(e+1)),i.push(n.getX(e+2))):(i.push(n.getX(e+2)),i.push(n.getX(e+1)),i.push(n.getX(e)));i.length/3!==r&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const s=e.clone();return s.setIndex(i),s.clearGroups(),s}return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",t),e}const xm=parseInt(i.replace(/\D+/g,""));function Am(e){if("undefined"!==typeof TextDecoder)return(new TextDecoder).decode(e);let t="";for(let r=0,i=e.length;r<i;r++)t+=String.fromCharCode(e[r]);try{return decodeURIComponent(escape(t))}catch(n){return t}}const Mm="srgb",bm="srgb-linear";class Sm extends ep{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register((function(e){return new Pm(e)})),this.register((function(e){return new Im(e)})),this.register((function(e){return new Hm(e)})),this.register((function(e){return new zm(e)})),this.register((function(e){return new Gm(e)})),this.register((function(e){return new Lm(e)})),this.register((function(e){return new Dm(e)})),this.register((function(e){return new Um(e)})),this.register((function(e){return new Nm(e)})),this.register((function(e){return new Rm(e)})),this.register((function(e){return new Fm(e)})),this.register((function(e){return new Bm(e)})),this.register((function(e){return new km(e)})),this.register((function(e){return new Om(e)})),this.register((function(e){return new Tm(e)})),this.register((function(e){return new Vm(e)})),this.register((function(e){return new Wm(e)}))}load(e,t,n,r){const i=this;let s;if(""!==this.resourcePath)s=this.resourcePath;else if(""!==this.path){const t=Pp.extractUrlBase(e);s=Pp.resolveURL(t,this.path)}else s=Pp.extractUrlBase(e);this.manager.itemStart(e);const a=function(t){r?r(t):console.error(t),i.manager.itemError(e),i.manager.itemEnd(e)},o=new rp(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,(function(n){try{i.parse(n,s,(function(n){t(n),i.manager.itemEnd(e)}),a)}catch(r){a(r)}}),n,a)}setDRACOLoader(e){return this.dracoLoader=e,this}setDDSLoader(){throw new Error('THREE.GLTFLoader: "MSFT_texture_dds" no longer supported. Please update to "KHR_texture_basisu".')}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return-1===this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.push(e),this}unregister(e){return-1!==this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,n,r){let i;const s={},a={};if("string"===typeof e)i=JSON.parse(e);else if(e instanceof ArrayBuffer){if(Am(new Uint8Array(e.slice(0,4)))===jm){try{s[Em.KHR_BINARY_GLTF]=new Ym(e)}catch(by){return void(r&&r(by))}i=JSON.parse(s[Em.KHR_BINARY_GLTF].content)}else i=JSON.parse(Am(new Uint8Array(e)))}else i=e;if(void 0===i.asset||i.asset.version[0]<2)return void(r&&r(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported.")));const o=new _g(i,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});o.fileLoader.setRequestHeader(this.requestHeader);for(let l=0;l<this.pluginCallbacks.length;l++){const e=this.pluginCallbacks[l](o);e.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),a[e.name]=e,s[e.name]=!0}if(i.extensionsUsed)for(let l=0;l<i.extensionsUsed.length;++l){const e=i.extensionsUsed[l],t=i.extensionsRequired||[];switch(e){case Em.KHR_MATERIALS_UNLIT:s[e]=new Cm;break;case Em.KHR_DRACO_MESH_COMPRESSION:s[e]=new Km(i,this.dracoLoader);break;case Em.KHR_TEXTURE_TRANSFORM:s[e]=new qm;break;case Em.KHR_MESH_QUANTIZATION:s[e]=new Qm;break;default:t.indexOf(e)>=0&&void 0===a[e]&&console.warn('THREE.GLTFLoader: Unknown extension "'+e+'".')}}o.setExtensions(s),o.setPlugins(a),o.parse(n,r)}parseAsync(e,t){const n=this;return new Promise((function(r,i){n.parse(e,t,r,i)}))}}function wm(){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={}}}}const Em={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"};class Tm{constructor(e){this.parser=e,this.name=Em.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let n=0,r=t.length;n<r;n++){const r=t[n];r.extensions&&r.extensions[this.name]&&void 0!==r.extensions[this.name].light&&e._addNodeRef(this.cache,r.extensions[this.name].light)}}_loadLight(e){const t=this.parser,n="light:"+e;let r=t.cache.get(n);if(r)return r;const i=t.json,s=((i.extensions&&i.extensions[this.name]||{}).lights||[])[e];let a;const o=new ts(16777215);void 0!==s.color&&o.setRGB(s.color[0],s.color[1],s.color[2],bm);const l=void 0!==s.range?s.range:0;switch(s.type){case"directional":a=new Sp(o),a.target.position.set(0,0,-1),a.add(a.target);break;case"point":a=new Mp(o),a.distance=l;break;case"spot":a=new vp(o),a.distance=l,s.spot=s.spot||{},s.spot.innerConeAngle=void 0!==s.spot.innerConeAngle?s.spot.innerConeAngle:0,s.spot.outerConeAngle=void 0!==s.spot.outerConeAngle?s.spot.outerConeAngle:Math.PI/4,a.angle=s.spot.outerConeAngle,a.penumbra=1-s.spot.innerConeAngle/s.spot.outerConeAngle,a.target.position.set(0,0,-1),a.add(a.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+s.type)}return a.position.set(0,0,0),a.decay=2,pg(a,s),void 0!==s.intensity&&(a.intensity=s.intensity),a.name=t.createUniqueName(s.name||"light_"+e),r=Promise.resolve(a),t.cache.add(n,r),r}getDependency(e,t){if("light"===e)return this._loadLight(t)}createNodeAttachment(e){const t=this,n=this.parser,r=n.json.nodes[e],i=(r.extensions&&r.extensions[this.name]||{}).light;return void 0===i?null:this._loadLight(i).then((function(e){return n._getNodeRef(t.cache,i,e)}))}}class Cm{constructor(){this.name=Em.KHR_MATERIALS_UNLIT}getMaterialType(){return ss}extendParams(e,t,n){const r=[];e.color=new ts(1,1,1),e.opacity=1;const i=t.pbrMetallicRoughness;if(i){if(Array.isArray(i.baseColorFactor)){const t=i.baseColorFactor;e.color.setRGB(t[0],t[1],t[2],bm),e.opacity=t[3]}void 0!==i.baseColorTexture&&r.push(n.assignTexture(e,"map",i.baseColorTexture,Mm))}return Promise.all(r)}}class Rm{constructor(e){this.parser=e,this.name=Em.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=n.extensions[this.name].emissiveStrength;return void 0!==r&&(t.emissiveIntensity=r),Promise.resolve()}}class Pm{constructor(e){this.parser=e,this.name=Em.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?Sd:null}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const i=[],s=r.extensions[this.name];if(void 0!==s.clearcoatFactor&&(t.clearcoat=s.clearcoatFactor),void 0!==s.clearcoatTexture&&i.push(n.assignTexture(t,"clearcoatMap",s.clearcoatTexture)),void 0!==s.clearcoatRoughnessFactor&&(t.clearcoatRoughness=s.clearcoatRoughnessFactor),void 0!==s.clearcoatRoughnessTexture&&i.push(n.assignTexture(t,"clearcoatRoughnessMap",s.clearcoatRoughnessTexture)),void 0!==s.clearcoatNormalTexture&&(i.push(n.assignTexture(t,"clearcoatNormalMap",s.clearcoatNormalTexture)),void 0!==s.clearcoatNormalTexture.scale)){const e=s.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new ir(e,e)}return Promise.all(i)}}class Im{constructor(e){this.parser=e,this.name=Em.KHR_MATERIALS_DISPERSION}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?Sd:null}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=n.extensions[this.name];return t.dispersion=void 0!==r.dispersion?r.dispersion:0,Promise.resolve()}}class Bm{constructor(e){this.parser=e,this.name=Em.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?Sd:null}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const i=[],s=r.extensions[this.name];return void 0!==s.iridescenceFactor&&(t.iridescence=s.iridescenceFactor),void 0!==s.iridescenceTexture&&i.push(n.assignTexture(t,"iridescenceMap",s.iridescenceTexture)),void 0!==s.iridescenceIor&&(t.iridescenceIOR=s.iridescenceIor),void 0===t.iridescenceThicknessRange&&(t.iridescenceThicknessRange=[100,400]),void 0!==s.iridescenceThicknessMinimum&&(t.iridescenceThicknessRange[0]=s.iridescenceThicknessMinimum),void 0!==s.iridescenceThicknessMaximum&&(t.iridescenceThicknessRange[1]=s.iridescenceThicknessMaximum),void 0!==s.iridescenceThicknessTexture&&i.push(n.assignTexture(t,"iridescenceThicknessMap",s.iridescenceThicknessTexture)),Promise.all(i)}}class Lm{constructor(e){this.parser=e,this.name=Em.KHR_MATERIALS_SHEEN}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?Sd:null}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const i=[];t.sheenColor=new ts(0,0,0),t.sheenRoughness=0,t.sheen=1;const s=r.extensions[this.name];if(void 0!==s.sheenColorFactor){const e=s.sheenColorFactor;t.sheenColor.setRGB(e[0],e[1],e[2],bm)}return void 0!==s.sheenRoughnessFactor&&(t.sheenRoughness=s.sheenRoughnessFactor),void 0!==s.sheenColorTexture&&i.push(n.assignTexture(t,"sheenColorMap",s.sheenColorTexture,Mm)),void 0!==s.sheenRoughnessTexture&&i.push(n.assignTexture(t,"sheenRoughnessMap",s.sheenRoughnessTexture)),Promise.all(i)}}class Dm{constructor(e){this.parser=e,this.name=Em.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?Sd:null}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const i=[],s=r.extensions[this.name];return void 0!==s.transmissionFactor&&(t.transmission=s.transmissionFactor),void 0!==s.transmissionTexture&&i.push(n.assignTexture(t,"transmissionMap",s.transmissionTexture)),Promise.all(i)}}class Um{constructor(e){this.parser=e,this.name=Em.KHR_MATERIALS_VOLUME}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?Sd:null}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const i=[],s=r.extensions[this.name];t.thickness=void 0!==s.thicknessFactor?s.thicknessFactor:0,void 0!==s.thicknessTexture&&i.push(n.assignTexture(t,"thicknessMap",s.thicknessTexture)),t.attenuationDistance=s.attenuationDistance||1/0;const a=s.attenuationColor||[1,1,1];return t.attenuationColor=(new ts).setRGB(a[0],a[1],a[2],bm),Promise.all(i)}}class Nm{constructor(e){this.parser=e,this.name=Em.KHR_MATERIALS_IOR}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?Sd:null}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=n.extensions[this.name];return t.ior=void 0!==r.ior?r.ior:1.5,Promise.resolve()}}class Fm{constructor(e){this.parser=e,this.name=Em.KHR_MATERIALS_SPECULAR}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?Sd:null}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const i=[],s=r.extensions[this.name];t.specularIntensity=void 0!==s.specularFactor?s.specularFactor:1,void 0!==s.specularTexture&&i.push(n.assignTexture(t,"specularIntensityMap",s.specularTexture));const a=s.specularColorFactor||[1,1,1];return t.specularColor=(new ts).setRGB(a[0],a[1],a[2],bm),void 0!==s.specularColorTexture&&i.push(n.assignTexture(t,"specularColorMap",s.specularColorTexture,Mm)),Promise.all(i)}}class Om{constructor(e){this.parser=e,this.name=Em.EXT_MATERIALS_BUMP}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?Sd:null}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const i=[],s=r.extensions[this.name];return t.bumpScale=void 0!==s.bumpFactor?s.bumpFactor:1,void 0!==s.bumpTexture&&i.push(n.assignTexture(t,"bumpMap",s.bumpTexture)),Promise.all(i)}}class km{constructor(e){this.parser=e,this.name=Em.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?Sd:null}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const i=[],s=r.extensions[this.name];return void 0!==s.anisotropyStrength&&(t.anisotropy=s.anisotropyStrength),void 0!==s.anisotropyRotation&&(t.anisotropyRotation=s.anisotropyRotation),void 0!==s.anisotropyTexture&&i.push(n.assignTexture(t,"anisotropyMap",s.anisotropyTexture)),Promise.all(i)}}class Hm{constructor(e){this.parser=e,this.name=Em.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,n=t.json,r=n.textures[e];if(!r.extensions||!r.extensions[this.name])return null;const i=r.extensions[this.name],s=t.options.ktx2Loader;if(!s){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,i.source,s)}}class zm{constructor(e){this.parser=e,this.name=Em.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,n=this.parser,r=n.json,i=r.textures[e];if(!i.extensions||!i.extensions[t])return null;const s=i.extensions[t],a=r.images[s.source];let o=n.textureLoader;if(a.uri){const e=n.options.manager.getHandler(a.uri);null!==e&&(o=e)}return this.detectSupport().then((function(i){if(i)return n.loadTextureImage(e,s.source,o);if(r.extensionsRequired&&r.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return n.loadTexture(e)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(e){const t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(1===t.height)}}))),this.isSupported}}class Gm{constructor(e){this.parser=e,this.name=Em.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){const t=this.name,n=this.parser,r=n.json,i=r.textures[e];if(!i.extensions||!i.extensions[t])return null;const s=i.extensions[t],a=r.images[s.source];let o=n.textureLoader;if(a.uri){const e=n.options.manager.getHandler(a.uri);null!==e&&(o=e)}return this.detectSupport().then((function(i){if(i)return n.loadTextureImage(e,s.source,o);if(r.extensionsRequired&&r.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return n.loadTexture(e)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(e){const t=new Image;t.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",t.onload=t.onerror=function(){e(1===t.height)}}))),this.isSupported}}class Vm{constructor(e){this.name=Em.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){const 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 new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return r.then((function(t){const n=e.byteOffset||0,r=e.byteLength||0,s=e.count,a=e.byteStride,o=new Uint8Array(t,n,r);return i.decodeGltfBufferAsync?i.decodeGltfBufferAsync(s,a,o,e.mode,e.filter).then((function(e){return e.buffer})):i.ready.then((function(){const t=new ArrayBuffer(s*a);return i.decodeGltfBuffer(new Uint8Array(t),s,a,o,e.mode,e.filter),t}))}))}return null}}class Wm{constructor(e){this.name=Em.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||void 0===n.mesh)return null;const r=t.meshes[n.mesh];for(const o of r.primitives)if(o.mode!==tg.TRIANGLES&&o.mode!==tg.TRIANGLE_STRIP&&o.mode!==tg.TRIANGLE_FAN&&void 0!==o.mode)return null;const i=n.extensions[this.name].attributes,s=[],a={};for(const o in i)s.push(this.parser.getDependency("accessor",i[o]).then((e=>(a[o]=e,a[o]))));return s.length<1?null:(s.push(this.parser.createNodeMesh(e)),Promise.all(s).then((e=>{const t=e.pop(),n=t.isGroup?t.children:[t],r=e[0].count,i=[];for(const s of n){const e=new di,t=new Nr,n=new Ur,o=new Nr(1,1,1),l=new sc(s.geometry,s.material,r);for(let i=0;i<r;i++)a.TRANSLATION&&t.fromBufferAttribute(a.TRANSLATION,i),a.ROTATION&&n.fromBufferAttribute(a.ROTATION,i),a.SCALE&&o.fromBufferAttribute(a.SCALE,i),l.setMatrixAt(i,e.compose(t,n,o));for(const r in a)if("_COLOR_0"===r){const e=a[r];l.instanceColor=new Qu(e.array,e.itemSize,e.normalized)}else"TRANSLATION"!==r&&"ROTATION"!==r&&"SCALE"!==r&&s.geometry.setAttribute(r,a[r]);ki.prototype.copy.call(l,s),this.parser.assignFinalMaterial(l),i.push(l)}return t.isGroup?(t.clear(),t.add(...i),t):i[0]})))}}const jm="glTF",Xm=1313821514,Jm=5130562;class Ym{constructor(e){this.name=Em.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,12);if(this.header={magic:Am(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==jm)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const n=this.header.length-12,r=new DataView(e,12);let i=0;for(;i<n;){const t=r.getUint32(i,!0);i+=4;const n=r.getUint32(i,!0);if(i+=4,n===Xm){const n=new Uint8Array(e,12+i,t);this.content=Am(n)}else if(n===Jm){const n=12+i;this.body=e.slice(n,n+t)}i+=t}if(null===this.content)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class Km{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=Em.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const n=this.json,r=this.dracoLoader,i=e.extensions[this.name].bufferView,s=e.extensions[this.name].attributes,a={},o={},l={};for(const u in s){const e=ag[u]||u.toLowerCase();a[e]=s[u]}for(const u in e.attributes){const t=ag[u]||u.toLowerCase();if(void 0!==s[u]){const r=n.accessors[e.attributes[u]],i=ng[r.componentType];l[t]=i.name,o[t]=!0===r.normalized}}return t.getDependency("bufferView",i).then((function(e){return new Promise((function(t,n){r.decodeDracoFile(e,(function(e){for(const t in e.attributes){const n=e.attributes[t],r=o[t];void 0!==r&&(n.normalized=r)}t(e)}),a,l,bm,n)}))}))}}class qm{constructor(){this.name=Em.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return void 0!==t.texCoord&&t.texCoord!==e.channel||void 0!==t.offset||void 0!==t.rotation||void 0!==t.scale?(e=e.clone(),void 0!==t.texCoord&&(e.channel=t.texCoord),void 0!==t.offset&&e.offset.fromArray(t.offset),void 0!==t.rotation&&(e.rotation=t.rotation),void 0!==t.scale&&e.repeat.fromArray(t.scale),e.needsUpdate=!0,e):e}}class Qm{constructor(){this.name=Em.KHR_MESH_QUANTIZATION}}class Zm extends Fd{constructor(e,t,n,r){super(e,t,n,r)}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,r=this.valueSize,i=e*r*3+r;for(let s=0;s!==r;s++)t[s]=n[i+s];return t}interpolate_(e,t,n,r){const i=this.resultBuffer,s=this.sampleValues,a=this.valueSize,o=2*a,l=3*a,u=r-t,c=(n-t)/u,h=c*c,d=h*c,p=e*l,f=p-l,m=-2*d+3*h,g=d-h,v=1-m,y=g-h+c;for(let _=0;_!==a;_++){const e=s[f+_+a],t=s[f+_+o]*u,n=s[p+_+a],r=s[p+_]*u;i[_]=v*e+y*t+m*n+g*r}return i}}const $m=new Ur;class eg extends Zm{interpolate_(e,t,n,r){const i=super.interpolate_(e,t,n,r);return $m.fromArray(i).normalize().toArray(i),i}}const tg={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},ng={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},rg={9728:xe,9729:we,9984:Ae,9985:Ee,9986:be,9987:Ce},ig={33071:ye,33648:_e,10497:ve},sg={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},ag={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",...xm>=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"},og={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},lg={CUBICSPLINE:void 0,LINEAR:Ft,STEP:Nt},ug="OPAQUE",cg="MASK",hg="BLEND";function dg(e,t,n){for(const r in n.extensions)void 0===e[r]&&(t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[r]=n.extensions[r])}function pg(e,t){void 0!==t.extras&&("object"===typeof t.extras?Object.assign(e.userData,t.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+t.extras))}function fg(e,t){if(e.updateMorphTargets(),void 0!==t.weights)for(let n=0,r=t.weights.length;n<r;n++)e.morphTargetInfluences[n]=t.weights[n];if(t.extras&&Array.isArray(t.extras.targetNames)){const n=t.extras.targetNames;if(e.morphTargetInfluences.length===n.length){e.morphTargetDictionary={};for(let t=0,r=n.length;t<r;t++)e.morphTargetDictionary[n[t]]=t}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function mg(e){let t;const n=e.extensions&&e.extensions[Em.KHR_DRACO_MESH_COMPRESSION];if(t=n?"draco:"+n.bufferView+":"+n.indices+":"+gg(n.attributes):e.indices+":"+gg(e.attributes)+":"+e.mode,void 0!==e.targets)for(let r=0,i=e.targets.length;r<i;r++)t+=":"+gg(e.targets[r]);return t}function gg(e){let t="";const n=Object.keys(e).sort();for(let r=0,i=n.length;r<i;r++)t+=n[r]+":"+e[n[r]]+";";return t}function vg(e){switch(e){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}const yg=new di;class _g{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new wm,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;"undefined"!==typeof navigator&&"undefined"!==typeof navigator.userAgent&&(n=!0===/^((?!chrome|android).)*safari/i.test(navigator.userAgent),r=navigator.userAgent.indexOf("Firefox")>-1,i=r?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1),"undefined"===typeof createImageBitmap||n||r&&i<98?this.textureLoader=new up(this.options.manager):this.textureLoader=new Fp(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new rp(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),"use-credentials"===this.options.crossOrigin&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const 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){const s={scene:t[0][r.scene||0],scenes:t[0],animations:t[1],cameras:t[2],asset:r.asset,parser:n,userData:{}};return dg(i,s,r),pg(s,r),Promise.all(n._invokeAll((function(e){return e.afterRoot&&e.afterRoot(s)}))).then((function(){for(const e of s.scenes)e.updateMatrixWorld();e(s)}))})).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let r=0,i=t.length;r<i;r++){const n=t[r].joints;for(let t=0,r=n.length;t<r;t++)e[n[t]].isBone=!0}for(let r=0,i=e.length;r<i;r++){const t=e[r];void 0!==t.mesh&&(this._addNodeRef(this.meshCache,t.mesh),void 0!==t.skin&&(n[t.mesh].isSkinnedMesh=!0)),void 0!==t.camera&&this._addNodeRef(this.cameraCache,t.camera)}}_addNodeRef(e,t){void 0!==t&&(void 0===e.refs[t]&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,n){if(e.refs[t]<=1)return n;const r=n.clone(),i=(e,t)=>{const n=this.associations.get(e);null!=n&&this.associations.set(t,n);for(const[r,s]of e.children.entries())i(s,t.children[r])};return i(n,r),r.name+="_instance_"+e.uses[t]++,r}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){const r=e(t[n]);if(r)return r}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const n=[];for(let r=0;r<t.length;r++){const i=e(t[r]);i&&n.push(i)}return n}getDependency(e,t){const n=e+":"+t;let r=this.cache.get(n);if(!r){switch(e){case"scene":r=this.loadScene(t);break;case"node":r=this._invokeOne((function(e){return e.loadNode&&e.loadNode(t)}));break;case"mesh":r=this._invokeOne((function(e){return e.loadMesh&&e.loadMesh(t)}));break;case"accessor":r=this.loadAccessor(t);break;case"bufferView":r=this._invokeOne((function(e){return e.loadBufferView&&e.loadBufferView(t)}));break;case"buffer":r=this.loadBuffer(t);break;case"material":r=this._invokeOne((function(e){return e.loadMaterial&&e.loadMaterial(t)}));break;case"texture":r=this._invokeOne((function(e){return e.loadTexture&&e.loadTexture(t)}));break;case"skin":r=this.loadSkin(t);break;case"animation":r=this._invokeOne((function(e){return e.loadAnimation&&e.loadAnimation(t)}));break;case"camera":r=this.loadCamera(t);break;default:if(r=this._invokeOne((function(n){return n!=this&&n.getDependency&&n.getDependency(e,t)})),!r)throw new Error("Unknown type: "+e)}this.cache.add(n,r)}return r}getDependencies(e){let t=this.cache.get(e);if(!t){const n=this,r=this.json[e+("mesh"===e?"es":"s")]||[];t=Promise.all(r.map((function(t,r){return n.getDependency(e,r)}))),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],n=this.fileLoader;if(t.type&&"arraybuffer"!==t.type)throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(void 0===t.uri&&0===e)return Promise.resolve(this.extensions[Em.KHR_BINARY_GLTF].body);const r=this.options;return new Promise((function(e,i){n.load(Pp.resolveURL(t.uri,r.path),e,void 0,(function(){i(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))}))}))}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then((function(e){const n=t.byteLength||0,r=t.byteOffset||0;return e.slice(r,r+n)}))}loadAccessor(e){const t=this,n=this.json,r=this.json.accessors[e];if(void 0===r.bufferView&&void 0===r.sparse){const e=sg[r.type],t=ng[r.componentType],n=!0===r.normalized,i=new t(r.count*e);return Promise.resolve(new ps(i,e,n))}const i=[];return void 0!==r.bufferView?i.push(this.getDependency("bufferView",r.bufferView)):i.push(null),void 0!==r.sparse&&(i.push(this.getDependency("bufferView",r.sparse.indices.bufferView)),i.push(this.getDependency("bufferView",r.sparse.values.bufferView))),Promise.all(i).then((function(e){const i=e[0],s=sg[r.type],a=ng[r.componentType],o=a.BYTES_PER_ELEMENT,l=o*s,u=r.byteOffset||0,c=void 0!==r.bufferView?n.bufferViews[r.bufferView].byteStride:void 0,h=!0===r.normalized;let d,p;if(c&&c!==l){const e=Math.floor(u/c),n="InterleavedBuffer:"+r.bufferView+":"+r.componentType+":"+e+":"+r.count;let l=t.cache.get(n);l||(d=new a(i,e*c,r.count*c/o),l=new fu(d,c/o),t.cache.add(n,l)),p=new gu(l,s,u%c/o,h)}else d=null===i?new a(r.count*s):new a(i,u,r.count*s),p=new ps(d,s,h);if(void 0!==r.sparse){const t=sg.SCALAR,n=ng[r.sparse.indices.componentType],o=r.sparse.indices.byteOffset||0,l=r.sparse.values.byteOffset||0,u=new n(e[1],o,r.sparse.count*t),c=new a(e[2],l,r.sparse.count*s);null!==i&&(p=new ps(p.array.slice(),p.itemSize,p.normalized));for(let e=0,r=u.length;e<r;e++){const t=u[e];if(p.setX(t,c[e*s]),s>=2&&p.setY(t,c[e*s+1]),s>=3&&p.setZ(t,c[e*s+2]),s>=4&&p.setW(t,c[e*s+3]),s>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return p}))}loadTexture(e){const t=this.json,n=this.options,r=t.textures[e].source,i=t.images[r];let s=this.textureLoader;if(i.uri){const e=n.manager.getHandler(i.uri);null!==e&&(s=e)}return this.loadTextureImage(e,r,s)}loadTextureImage(e,t,n){const r=this,i=this.json,s=i.textures[e],a=i.images[t],o=(a.uri||a.bufferView)+":"+s.sampler;if(this.textureCache[o])return this.textureCache[o];const l=this.loadImageSource(t,n).then((function(t){t.flipY=!1,t.name=s.name||a.name||"",""===t.name&&"string"===typeof a.uri&&!1===a.uri.startsWith("data:image/")&&(t.name=a.uri);const n=(i.samplers||{})[s.sampler]||{};return t.magFilter=rg[n.magFilter]||we,t.minFilter=rg[n.minFilter]||Ce,t.wrapS=ig[n.wrapS]||ve,t.wrapT=ig[n.wrapT]||ve,r.associations.set(t,{textures:e}),t})).catch((function(){return null}));return this.textureCache[o]=l,l}loadImageSource(e,t){const n=this,r=this.json,i=this.options;if(void 0!==this.sourceCache[e])return this.sourceCache[e].then((e=>e.clone()));const s=r.images[e],a=self.URL||self.webkitURL;let o=s.uri||"",l=!1;if(void 0!==s.bufferView)o=n.getDependency("bufferView",s.bufferView).then((function(e){l=!0;const t=new Blob([e],{type:s.mimeType});return o=a.createObjectURL(t),o}));else if(void 0===s.uri)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const u=Promise.resolve(o).then((function(e){return new Promise((function(n,r){let s=n;!0===t.isImageBitmapLoader&&(s=function(e){const t=new Tr(e);t.needsUpdate=!0,n(t)}),t.load(Pp.resolveURL(e,i.path),s,void 0,r)}))})).then((function(e){var t;return!0===l&&a.revokeObjectURL(o),pg(e,s),e.userData.mimeType=s.mimeType||((t=s.uri).search(/\.jpe?g($|\?)/i)>0||0===t.search(/^data\:image\/jpeg/)?"image/jpeg":t.search(/\.webp($|\?)/i)>0||0===t.search(/^data\:image\/webp/)?"image/webp":"image/png"),e})).catch((function(e){throw console.error("THREE.GLTFLoader: Couldn't load texture",o),e}));return this.sourceCache[e]=u,u}assignTexture(e,t,n,r){const i=this;return this.getDependency("texture",n.index).then((function(s){if(!s)return null;if(void 0!==n.texCoord&&n.texCoord>0&&((s=s.clone()).channel=n.texCoord),i.extensions[Em.KHR_TEXTURE_TRANSFORM]){const e=void 0!==n.extensions?n.extensions[Em.KHR_TEXTURE_TRANSFORM]:void 0;if(e){const t=i.associations.get(s);s=i.extensions[Em.KHR_TEXTURE_TRANSFORM].extendTexture(s,e),i.associations.set(s,t)}}return void 0!==r&&("number"===typeof r&&(r=3001===r?Mm:bm),"colorSpace"in s?s.colorSpace=r:s.encoding=r===Mm?3001:3e3),e[t]=s,s}))}assignFinalMaterial(e){const t=e.geometry;let n=e.material;const r=void 0===t.attributes.tangent,i=void 0!==t.attributes.color,s=void 0===t.attributes.normal;if(e.isPoints){const e="PointsMaterial:"+n.uuid;let t=this.cache.get(e);t||(t=new kc,is.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){const e="LineBasicMaterial:"+n.uuid;let t=this.cache.get(e);t||(t=new wc,is.prototype.copy.call(t,n),t.color.copy(n.color),t.map=n.map,this.cache.add(e,t)),n=t}if(r||i||s){let e="ClonedMaterial:"+n.uuid+":";r&&(e+="derivative-tangents:"),i&&(e+="vertex-colors:"),s&&(e+="flat-shading:");let t=this.cache.get(e);t||(t=n.clone(),i&&(t.vertexColors=!0),s&&(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 bd}loadMaterial(e){const t=this,n=this.json,r=this.extensions,i=n.materials[e];let s;const a={},o=[];if((i.extensions||{})[Em.KHR_MATERIALS_UNLIT]){const e=r[Em.KHR_MATERIALS_UNLIT];s=e.getMaterialType(),o.push(e.extendParams(a,i,t))}else{const n=i.pbrMetallicRoughness||{};if(a.color=new ts(1,1,1),a.opacity=1,Array.isArray(n.baseColorFactor)){const e=n.baseColorFactor;a.color.setRGB(e[0],e[1],e[2],bm),a.opacity=e[3]}void 0!==n.baseColorTexture&&o.push(t.assignTexture(a,"map",n.baseColorTexture,Mm)),a.metalness=void 0!==n.metallicFactor?n.metallicFactor:1,a.roughness=void 0!==n.roughnessFactor?n.roughnessFactor:1,void 0!==n.metallicRoughnessTexture&&(o.push(t.assignTexture(a,"metalnessMap",n.metallicRoughnessTexture)),o.push(t.assignTexture(a,"roughnessMap",n.metallicRoughnessTexture))),s=this._invokeOne((function(t){return t.getMaterialType&&t.getMaterialType(e)})),o.push(Promise.all(this._invokeAll((function(t){return t.extendMaterialParams&&t.extendMaterialParams(e,a)}))))}!0===i.doubleSided&&(a.side=v);const l=i.alphaMode||ug;if(l===hg?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,l===cg&&(a.alphaTest=void 0!==i.alphaCutoff?i.alphaCutoff:.5)),void 0!==i.normalTexture&&s!==ss&&(o.push(t.assignTexture(a,"normalMap",i.normalTexture)),a.normalScale=new ir(1,1),void 0!==i.normalTexture.scale)){const e=i.normalTexture.scale;a.normalScale.set(e,e)}if(void 0!==i.occlusionTexture&&s!==ss&&(o.push(t.assignTexture(a,"aoMap",i.occlusionTexture)),void 0!==i.occlusionTexture.strength&&(a.aoMapIntensity=i.occlusionTexture.strength)),void 0!==i.emissiveFactor&&s!==ss){const e=i.emissiveFactor;a.emissive=(new ts).setRGB(e[0],e[1],e[2],bm)}return void 0!==i.emissiveTexture&&s!==ss&&o.push(t.assignTexture(a,"emissiveMap",i.emissiveTexture,Mm)),Promise.all(o).then((function(){const n=new s(a);return i.name&&(n.name=i.name),pg(n,i),t.associations.set(n,{materials:e}),i.extensions&&dg(r,n,i),n}))}createUniqueName(e){const t=pf.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,n=this.extensions,r=this.primitiveCache;function i(e){return n[Em.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e,t).then((function(n){return xg(n,e,t)}))}const s=[];for(let a=0,o=e.length;a<o;a++){const n=e[a],o=mg(n),l=r[o];if(l)s.push(l.promise);else{let e;e=n.extensions&&n.extensions[Em.KHR_DRACO_MESH_COMPRESSION]?i(n):xg(new Ps,n,t),r[o]={primitive:n,promise:e},s.push(e)}}return Promise.all(s)}loadMesh(e){const t=this,n=this.json,r=this.extensions,i=n.meshes[e],s=i.primitives,a=[];for(let l=0,u=s.length;l<u;l++){const e=void 0===s[l].material?(void 0===(o=this.cache).DefaultMaterial&&(o.DefaultMaterial=new bd({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:m})),o.DefaultMaterial):this.getDependency("material",s[l].material);a.push(e)}var o;return a.push(t.loadGeometries(s)),Promise.all(a).then((function(n){const a=n.slice(0,n.length-1),o=n[n.length-1],l=[];for(let c=0,h=o.length;c<h;c++){const n=o[c],u=s[c];let h;const d=a[c];if(u.mode===tg.TRIANGLES||u.mode===tg.TRIANGLE_STRIP||u.mode===tg.TRIANGLE_FAN||void 0===u.mode)h=!0===i.isSkinnedMesh?new ju(n,d):new Ys(n,d),!0===h.isSkinnedMesh&&h.normalizeSkinWeights(),u.mode===tg.TRIANGLE_STRIP?h.geometry=_m(h.geometry,jt):u.mode===tg.TRIANGLE_FAN&&(h.geometry=_m(h.geometry,Xt));else if(u.mode===tg.LINES)h=new Fc(n,d);else if(u.mode===tg.LINE_STRIP)h=new Lc(n,d);else if(u.mode===tg.LINE_LOOP)h=new Oc(n,d);else{if(u.mode!==tg.POINTS)throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+u.mode);h=new Wc(n,d)}Object.keys(h.geometry.morphAttributes).length>0&&fg(h,i),h.name=t.createUniqueName(i.name||"mesh_"+e),pg(h,i),u.extensions&&dg(r,h,u),t.assignFinalMaterial(h),l.push(h)}for(let r=0,i=l.length;r<i;r++)t.associations.set(l[r],{meshes:e,primitives:r});if(1===l.length)return i.extensions&&dg(r,l[0],i),l[0];const u=new tu;i.extensions&&dg(r,u,i),t.associations.set(u,{meshes:e});for(let e=0,t=l.length;e<t;e++)u.add(l[e]);return u}))}loadCamera(e){let t;const n=this.json.cameras[e],r=n[n.type];if(r)return"perspective"===n.type?t=new aa(rr.radToDeg(r.yfov),r.aspectRatio||1,r.znear||1,r.zfar||2e6):"orthographic"===n.type&&(t=new La(-r.xmag,r.xmag,r.ymag,-r.ymag,r.znear,r.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),pg(t,n),Promise.resolve(t);console.warn("THREE.GLTFLoader: Missing camera parameters.")}loadSkin(e){const t=this.json.skins[e],n=[];for(let r=0,i=t.joints.length;r<i;r++)n.push(this._loadNodeShallow(t.joints[r]));return void 0!==t.inverseBindMatrices?n.push(this.getDependency("accessor",t.inverseBindMatrices)):n.push(null),Promise.all(n).then((function(e){const n=e.pop(),r=e,i=[],s=[];for(let a=0,o=r.length;a<o;a++){const e=r[a];if(e){i.push(e);const t=new di;null!==n&&t.fromArray(n.array,16*a),s.push(t)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[a])}return new qu(i,s)}))}loadAnimation(e){const t=this.json,n=this,r=t.animations[e],i=r.name?r.name:"animation_"+e,s=[],a=[],o=[],l=[],u=[];for(let c=0,h=r.channels.length;c<h;c++){const e=r.channels[c],t=r.samplers[e.sampler],n=e.target,i=n.node,h=void 0!==r.parameters?r.parameters[t.input]:t.input,d=void 0!==r.parameters?r.parameters[t.output]:t.output;void 0!==n.node&&(s.push(this.getDependency("node",i)),a.push(this.getDependency("accessor",h)),o.push(this.getDependency("accessor",d)),l.push(t),u.push(n))}return Promise.all([Promise.all(s),Promise.all(a),Promise.all(o),Promise.all(l),Promise.all(u)]).then((function(e){const t=e[0],r=e[1],s=e[2],a=e[3],o=e[4],l=[];for(let i=0,u=t.length;i<u;i++){const e=t[i],u=r[i],c=s[i],h=a[i],d=o[i];if(void 0===e)continue;e.updateMatrix&&e.updateMatrix();const p=n._createAnimationTracks(e,u,c,h,d);if(p)for(let t=0;t<p.length;t++)l.push(p[t])}return new Kd(i,void 0,l)}))}createNodeMesh(e){const t=this.json,n=this,r=t.nodes[e];return void 0===r.mesh?null:n.getDependency("mesh",r.mesh).then((function(e){const t=n._getNodeRef(n.meshCache,r.mesh,e);return void 0!==r.weights&&t.traverse((function(e){if(e.isMesh)for(let t=0,n=r.weights.length;t<n;t++)e.morphTargetInfluences[t]=r.weights[t]})),t}))}loadNode(e){const t=this,n=this.json.nodes[e],r=t._loadNodeShallow(e),i=[],s=n.children||[];for(let o=0,l=s.length;o<l;o++)i.push(t.getDependency("node",s[o]));const a=void 0===n.skin?Promise.resolve(null):t.getDependency("skin",n.skin);return Promise.all([r,Promise.all(i),a]).then((function(e){const t=e[0],n=e[1],r=e[2];null!==r&&t.traverse((function(e){e.isSkinnedMesh&&e.bind(r,yg)}));for(let i=0,s=n.length;i<s;i++)t.add(n[i]);return t}))}_loadNodeShallow(e){const t=this.json,n=this.extensions,r=this;if(void 0!==this.nodeCache[e])return this.nodeCache[e];const i=t.nodes[e],s=i.name?r.createUniqueName(i.name):"",a=[],o=r._invokeOne((function(t){return t.createNodeMesh&&t.createNodeMesh(e)}));return o&&a.push(o),void 0!==i.camera&&a.push(r.getDependency("camera",i.camera).then((function(e){return r._getNodeRef(r.cameraCache,i.camera,e)}))),r._invokeAll((function(t){return t.createNodeAttachment&&t.createNodeAttachment(e)})).forEach((function(e){a.push(e)})),this.nodeCache[e]=Promise.all(a).then((function(t){let a;if(a=!0===i.isBone?new Xu:t.length>1?new tu:1===t.length?t[0]:new ki,a!==t[0])for(let e=0,n=t.length;e<n;e++)a.add(t[e]);if(i.name&&(a.userData.name=i.name,a.name=s),pg(a,i),i.extensions&&dg(n,a,i),void 0!==i.matrix){const e=new di;e.fromArray(i.matrix),a.applyMatrix4(e)}else void 0!==i.translation&&a.position.fromArray(i.translation),void 0!==i.rotation&&a.quaternion.fromArray(i.rotation),void 0!==i.scale&&a.scale.fromArray(i.scale);return r.associations.has(a)||r.associations.set(a,{}),r.associations.get(a).nodes=e,a})),this.nodeCache[e]}loadScene(e){const t=this.extensions,n=this.json.scenes[e],r=this,i=new tu;n.name&&(i.name=r.createUniqueName(n.name)),pg(i,n),n.extensions&&dg(t,i,n);const s=n.nodes||[],a=[];for(let o=0,l=s.length;o<l;o++)a.push(r.getDependency("node",s[o]));return Promise.all(a).then((function(e){for(let t=0,n=e.length;t<n;t++)i.add(e[t]);return r.associations=(e=>{const t=new Map;for(const[n,i]of r.associations)(n instanceof is||n instanceof Tr)&&t.set(n,i);return e.traverse((e=>{const n=r.associations.get(e);null!=n&&t.set(e,n)})),t})(i),i}))}_createAnimationTracks(e,t,n,r,i){const s=[],a=e.name?e.name:e.uuid,o=[];let l;switch(og[i.path]===og.weights?e.traverse((function(e){e.morphTargetInfluences&&o.push(e.name?e.name:e.uuid)})):o.push(a),og[i.path]){case og.weights:l=Wd;break;case og.rotation:l=Xd;break;case og.position:case og.scale:l=Yd;break;default:if(1===n.itemSize)l=Wd;else l=Yd}const u=void 0!==r.interpolation?lg[r.interpolation]:Ft,c=this._getArrayFromAccessor(n);for(let h=0,d=o.length;h<d;h++){const e=new l(o[h]+"."+og[i.path],t.array,c,u);"CUBICSPLINE"===r.interpolation&&this._createCubicSplineTrackInterpolant(e),s.push(e)}return s}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const e=vg(t.constructor),n=new Float32Array(t.length);for(let r=0,i=t.length;r<i;r++)n[r]=t[r]*e;t=n}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(e){return new(this instanceof Xd?eg:Zm)(this.times,this.values,this.getValueSize()/3,e)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function xg(e,t,n){const r=t.attributes,i=[];function s(t,r){return n.getDependency("accessor",t).then((function(t){e.setAttribute(r,t)}))}for(const a in r){const t=ag[a]||a.toLowerCase();t in e.attributes||i.push(s(r[a],t))}if(void 0!==t.indices&&!e.index){const r=n.getDependency("accessor",t.indices).then((function(t){e.setIndex(t)}));i.push(r)}return pg(e,t),function(e,t,n){const r=t.attributes,i=new kr;if(void 0===r.POSITION)return;{const e=n.json.accessors[r.POSITION],t=e.min,s=e.max;if(void 0===t||void 0===s)return void console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");if(i.set(new Nr(t[0],t[1],t[2]),new Nr(s[0],s[1],s[2])),e.normalized){const t=vg(ng[e.componentType]);i.min.multiplyScalar(t),i.max.multiplyScalar(t)}}const s=t.targets;if(void 0!==s){const e=new Nr,t=new Nr;for(let r=0,i=s.length;r<i;r++){const i=s[r];if(void 0!==i.POSITION){const r=n.json.accessors[i.POSITION],s=r.min,a=r.max;if(void 0!==s&&void 0!==a){if(t.setX(Math.max(Math.abs(s[0]),Math.abs(a[0]))),t.setY(Math.max(Math.abs(s[1]),Math.abs(a[1]))),t.setZ(Math.max(Math.abs(s[2]),Math.abs(a[2]))),r.normalized){const e=vg(ng[r.componentType]);t.multiplyScalar(e)}e.max(t)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}i.expandByVector(e)}e.boundingBox=i;const a=new ri;i.getCenter(a.center),a.radius=i.min.distanceTo(i.max)/2,e.boundingSphere=a}(e,t,n),Promise.all(i).then((function(){return void 0!==t.targets?function(e,t,n){let r=!1,i=!1,s=!1;for(let u=0,c=t.length;u<c;u++){const e=t[u];if(void 0!==e.POSITION&&(r=!0),void 0!==e.NORMAL&&(i=!0),void 0!==e.COLOR_0&&(s=!0),r&&i&&s)break}if(!r&&!i&&!s)return Promise.resolve(e);const a=[],o=[],l=[];for(let u=0,c=t.length;u<c;u++){const c=t[u];if(r){const t=void 0!==c.POSITION?n.getDependency("accessor",c.POSITION):e.attributes.position;a.push(t)}if(i){const t=void 0!==c.NORMAL?n.getDependency("accessor",c.NORMAL):e.attributes.normal;o.push(t)}if(s){const t=void 0!==c.COLOR_0?n.getDependency("accessor",c.COLOR_0):e.attributes.color;l.push(t)}}return Promise.all([Promise.all(a),Promise.all(o),Promise.all(l)]).then((function(t){const n=t[0],a=t[1],o=t[2];return r&&(e.morphAttributes.position=n),i&&(e.morphAttributes.normal=a),s&&(e.morphAttributes.color=o),e.morphTargetsRelative=!0,e}))}(e,t.targets,n):e}))}var Ag=n(878);function Mg(e){let t;const n=new Set,r=(e,r)=>{const i="function"===typeof e?e(t):e;if(i!==t){const e=t;t=r?i:Object.assign({},t,i),n.forEach((n=>n(t,e)))}},i=()=>t,s={setState:r,getState:i,subscribe:(e,r,s)=>r||s?function(e){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:i,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Object.is;console.warn("[DEPRECATED] Please use `subscribeWithSelector` middleware");let a=r(t);function o(){const n=r(t);if(!s(a,n)){const t=a;e(a=n,t)}}return n.add(o),()=>n.delete(o)}(e,r,s):(n.add(e),()=>n.delete(e)),destroy:()=>n.clear()};return t=e(r,i,s),s}const bg="undefined"===typeof window||!window.navigator||/ServerSideRendering|^Deno\//.test(window.navigator.userAgent)?t.useEffect:t.useLayoutEffect;var Sg=n(235),wg=n.n(Sg),Eg=n(340);const Tg=[];function Cg(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:(e,t)=>e===t;if(e===t)return!0;if(!e||!t)return!1;const r=e.length;if(t.length!==r)return!1;for(let i=0;i<r;i++)if(!n(e[i],t[i]))return!1;return!0}function Rg(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};null===t&&(t=[e]);for(const a of Tg)if(Cg(t,a.keys,a.equal)){if(n)return;if(Object.prototype.hasOwnProperty.call(a,"error"))throw a.error;if(Object.prototype.hasOwnProperty.call(a,"response"))return r.lifespan&&r.lifespan>0&&(a.timeout&&clearTimeout(a.timeout),a.timeout=setTimeout(a.remove,r.lifespan)),a.response;if(!n)throw a.promise}const i={keys:t,equal:r.equal,remove:()=>{const e=Tg.indexOf(i);-1!==e&&Tg.splice(e,1)},promise:(s=e,"object"===typeof s&&"function"===typeof s.then?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))};var s;if(Tg.push(i),!n)throw i.promise}const Pg=(e,t,n)=>Rg(e,t,!1,n);var Ig=n(414);const Bg={};var Lg,Dg;const Ug=e=>"colorSpace"in e||"outputColorSpace"in e,Ng=()=>{var e;return null!=(e=Bg.ColorManagement)?e:null},Fg=e=>e&&e.isOrthographicCamera,Og="undefined"!==typeof window&&(null!=(Lg=window.document)&&Lg.createElement||"ReactNative"===(null==(Dg=window.navigator)?void 0:Dg.product))?t.useLayoutEffect:t.useEffect;function kg(e){const n=t.useRef(e);return Og((()=>{n.current=e}),[e]),n}function Hg(e){let{set:t}=e;return Og((()=>(t(new Promise((()=>null))),()=>t(!1))),[t]),null}class zg extends t.Component{constructor(){super(...arguments),this.state={error:!1}}componentDidCatch(e){this.props.set(e)}render(){return this.state.error?null:this.props.children}}zg.getDerivedStateFromError=()=>({error:!0});const Gg="__default",Vg=new Map,Wg=e=>e&&!!e.memoized&&!!e.changes;function jg(e){var t;const n="undefined"!==typeof window?null!=(t=window.devicePixelRatio)?t:2:1;return Array.isArray(e)?Math.min(Math.max(e[0],n),e[1]):e}const Xg=e=>{var t;return null==(t=e.__r3f)?void 0:t.root.getState()};function Jg(e){let t=e.__r3f.root;for(;t.getState().previousRoot;)t=t.getState().previousRoot;return t}const Yg={obj:e=>e===Object(e)&&!Yg.arr(e)&&"function"!==typeof e,fun:e=>"function"===typeof e,str:e=>"string"===typeof e,num:e=>"number"===typeof e,boo:e=>"boolean"===typeof e,und:e=>void 0===e,arr:e=>Array.isArray(e),equ(e,t){let{arrays:n="shallow",objects:r="reference",strict:i=!0}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(typeof e!==typeof t||!!e!==!!t)return!1;if(Yg.str(e)||Yg.num(e)||Yg.boo(e))return e===t;const s=Yg.obj(e);if(s&&"reference"===r)return e===t;const a=Yg.arr(e);if(a&&"reference"===n)return e===t;if((a||s)&&e===t)return!0;let o;for(o in e)if(!(o in t))return!1;if(s&&"shallow"===n&&"shallow"===r){for(o in i?t:e)if(!Yg.equ(e[o],t[o],{strict:i,objects:"reference"}))return!1}else for(o in i?t:e)if(e[o]!==t[o])return!1;if(Yg.und(o)){if(a&&0===e.length&&0===t.length)return!0;if(s&&0===Object.keys(e).length&&0===Object.keys(t).length)return!0;if(e!==t)return!1}return!0}};function Kg(e){const t={nodes:{},materials:{}};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)})),t}function qg(e,t){return e.__r3f={type:"",root:null,previousAttach:null,memoizedProps:{},eventCount:0,handlers:{},objects:[],parent:null,...t},e}function Qg(e,t){let n=e;if(t.includes("-")){const r=t.split("-"),i=r.pop();return n=r.reduce(((e,t)=>e[t]),e),{target:n,key:i}}return{target:n,key:t}}const Zg=/-\d+$/;function $g(e,t,n){if(Yg.str(n)){if(Zg.test(n)){const t=n.replace(Zg,""),{target:r,key:i}=Qg(e,t);Array.isArray(r[i])||(r[i]=[])}const{target:r,key:i}=Qg(e,n);t.__r3f.previousAttach=r[i],r[i]=t}else t.__r3f.previousAttach=n(e,t)}function ev(e,t,n){var r,i;if(Yg.str(n)){const{target:r,key:i}=Qg(e,n),s=t.__r3f.previousAttach;void 0===s?delete r[i]:r[i]=s}else null==(r=t.__r3f)||null==r.previousAttach||r.previousAttach(e,t);null==(i=t.__r3f)||delete i.previousAttach}function tv(e,t){let{children:n,key:r,ref:i,...s}=t,{children:a,key:o,ref:l,...u}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},c=arguments.length>3&&void 0!==arguments[3]&&arguments[3];const h=e.__r3f,d=Object.entries(s),p=[];if(c){const e=Object.keys(u);for(let t=0;t<e.length;t++)s.hasOwnProperty(e[t])||d.unshift([e[t],Gg+"remove"])}d.forEach((t=>{let[n,r]=t;var i;if(null!=(i=e.__r3f)&&i.primitive&&"object"===n)return;if(Yg.equ(r,u[n]))return;if(/^on(Pointer|Click|DoubleClick|ContextMenu|Wheel)/.test(n))return p.push([n,r,!0,[]]);let a=[];n.includes("-")&&(a=n.split("-")),p.push([n,r,!1,a]);for(const e in s){const t=s[e];e.startsWith(`${n}-`)&&p.push([e,t,!1,e.split("-")])}}));const f={...s};return null!=h&&h.memoizedProps&&null!=h&&h.memoizedProps.args&&(f.args=h.memoizedProps.args),null!=h&&h.memoizedProps&&null!=h&&h.memoizedProps.attach&&(f.attach=h.memoizedProps.attach),{memoized:f,changes:p}}const nv="undefined"!==typeof process&&!1;function rv(e,t){var n;const r=e.__r3f,i=null==r?void 0:r.root,s=null==i||null==i.getState?void 0:i.getState(),{memoized:a,changes:o}=Wg(t)?t:tv(e,t),l=null==r?void 0:r.eventCount;e.__r3f&&(e.__r3f.memoizedProps=a);for(let u=0;u<o.length;u++){let[t,n,i,a]=o[u];if(Ug(e)){const e=3001,r="srgb",i="srgb-linear";"encoding"===t?(t="colorSpace",n=n===e?r:i):"outputEncoding"===t&&(t="outputColorSpace",n=n===e?r:i)}let l=e,c=l[t];if(a.length&&(c=a.reduce(((e,t)=>e[t]),e),!c||!c.set)){const[n,...r]=a.reverse();l=r.reverse().reduce(((e,t)=>e[t]),e),t=n}if(n===Gg+"remove")if(l.constructor){let e=Vg.get(l.constructor);e||(e=new l.constructor,Vg.set(l.constructor,e)),n=e[t]}else n=0;if(i&&r)n?r.handlers[t]=n:delete r.handlers[t],r.eventCount=Object.keys(r.handlers).length;else if(c&&c.set&&(c.copy||c instanceof bi)){if(Array.isArray(n))c.fromArray?c.fromArray(n):c.set(...n);else if(c.copy&&n&&n.constructor&&(nv?c.constructor.name===n.constructor.name:c.constructor===n.constructor))c.copy(n);else if(void 0!==n){const e=c instanceof ts;!e&&c.setScalar?c.setScalar(n):c instanceof bi&&n instanceof bi?c.mask=n.mask:c.set(n),!Ng()&&s&&!s.linear&&e&&c.convertSRGBToLinear()}}else if(l[t]=n,l[t]instanceof Tr&&l[t].format===We&&l[t].type===Pe&&s){const e=l[t];Ug(e)&&Ug(s.gl)?e.colorSpace=s.gl.outputColorSpace:e.encoding=s.gl.outputEncoding}iv(e)}if(r&&r.parent&&e.raycast&&l!==r.eventCount){const t=Jg(e).getState().internal,n=t.interaction.indexOf(e);n>-1&&t.interaction.splice(n,1),r.eventCount&&t.interaction.push(e)}return!(1===o.length&&"onUpdate"===o[0][0])&&o.length&&null!=(n=e.__r3f)&&n.parent&&sv(e),e}function iv(e){var t,n;const r=null==(t=e.__r3f)||null==(n=t.root)||null==n.getState?void 0:n.getState();r&&0===r.internal.frames&&r.invalidate()}function sv(e){null==e.onUpdate||e.onUpdate(e)}function av(e,t){e.manual||(Fg(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(),e.updateMatrixWorld())}function ov(e){return(e.eventObject||e.object).uuid+"/"+e.index+e.instanceId}function lv(e,t,n,r){const i=n.get(t);i&&(n.delete(t),0===n.size&&(e.delete(r),i.target.releasePointerCapture(r)))}function uv(e){function t(e){return e.filter((e=>["Move","Over","Enter","Out","Leave"].some((t=>{var n;return null==(n=e.__r3f)?void 0:n.handlers["onPointer"+t]}))))}function n(t){const{internal:n}=e.getState();for(const e of n.hovered.values())if(!t.length||!t.find((t=>t.object===e.object&&t.index===e.index&&t.instanceId===e.instanceId))){const r=e.eventObject.__r3f,i=null==r?void 0:r.handlers;if(n.hovered.delete(ov(e)),null!=r&&r.eventCount){const n={...e,intersections:t};null==i.onPointerOut||i.onPointerOut(n),null==i.onPointerLeave||i.onPointerLeave(n)}}}function r(e,t){for(let n=0;n<t.length;n++){const r=t[n].__r3f;null==r||null==r.handlers.onPointerMissed||r.handlers.onPointerMissed(e)}}return{handlePointer:function(i){switch(i){case"onPointerLeave":case"onPointerCancel":return()=>n([]);case"onLostPointerCapture":return t=>{const{internal:r}=e.getState();"pointerId"in t&&r.capturedMap.has(t.pointerId)&&requestAnimationFrame((()=>{r.capturedMap.has(t.pointerId)&&(r.capturedMap.delete(t.pointerId),n([]))}))}}return function(s){const{onPointerMissed:a,internal:o}=e.getState();o.lastEvent.current=s;const l="onPointerMove"===i,u="onClick"===i||"onContextMenu"===i||"onDoubleClick"===i,c=function(t,n){const r=e.getState(),i=new Set,s=[],a=n?n(r.internal.interaction):r.internal.interaction;for(let e=0;e<a.length;e++){const t=Xg(a[e]);t&&(t.raycaster.camera=void 0)}r.previousRoot||null==r.events.compute||r.events.compute(t,r);let o=a.flatMap((function(e){const n=Xg(e);return n&&n.events.enabled&&null!==n.raycaster.camera?(void 0===n.raycaster.camera&&(null==n.events.compute||n.events.compute(t,n,null==(r=n.previousRoot)?void 0:r.getState()),void 0===n.raycaster.camera&&(n.raycaster.camera=null)),n.raycaster.camera?n.raycaster.intersectObject(e,!0):[]):[];var r})).sort(((e,t)=>{const n=Xg(e.object),r=Xg(t.object);return n&&r&&r.events.priority-n.events.priority||e.distance-t.distance})).filter((e=>{const t=ov(e);return!i.has(t)&&(i.add(t),!0)}));r.events.filter&&(o=r.events.filter(o,r));for(const e of o){let t=e.object;for(;t;){var l;null!=(l=t.__r3f)&&l.eventCount&&s.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(ov(e.intersection))||s.push(e.intersection);return s}(s,l?t:void 0),h=u?function(t){const{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))}(s):0;"onPointerDown"===i&&(o.initialClick=[s.offsetX,s.offsetY],o.initialHits=c.map((e=>e.eventObject))),u&&!c.length&&h<=2&&(r(s,o.interaction),a&&a(s)),l&&n(c),function(t,r,i,s){const a=e.getState();if(t.length){const e={stopped:!1};for(const o of t){const l=Xg(o.object)||a,{raycaster:u,pointer:c,camera:h,internal:d}=l,p=new Nr(c.x,c.y,0).unproject(h),f=e=>{var t,n;return null!=(t=null==(n=d.capturedMap.get(e))?void 0:n.has(o.eventObject))&&t},m=e=>{const t={intersection:o,target:r.target};d.capturedMap.has(e)?d.capturedMap.get(e).set(o.eventObject,t):d.capturedMap.set(e,new Map([[o.eventObject,t]])),r.target.setPointerCapture(e)},g=e=>{const t=d.capturedMap.get(e);t&&lv(d.capturedMap,o.eventObject,t,e)};let v={};for(let e in r){let t=r[e];"function"!==typeof t&&(v[e]=t)}let y={...o,...v,pointer:c,intersections:t,stopped:e.stopped,delta:i,unprojectedPoint:p,ray:u.ray,camera:h,stopPropagation(){const i="pointerId"in r&&d.capturedMap.get(r.pointerId);(!i||i.has(o.eventObject))&&(y.stopped=e.stopped=!0,d.hovered.size&&Array.from(d.hovered.values()).find((e=>e.eventObject===o.eventObject)))&&n([...t.slice(0,t.indexOf(o)),o])},target:{hasPointerCapture:f,setPointerCapture:m,releasePointerCapture:g},currentTarget:{hasPointerCapture:f,setPointerCapture:m,releasePointerCapture:g},nativeEvent:r};if(s(y),!0===e.stopped)break}}}(c,s,h,(function(e){const t=e.eventObject,n=t.__r3f,a=null==n?void 0:n.handlers;if(null!=n&&n.eventCount)if(l){if(a.onPointerOver||a.onPointerEnter||a.onPointerOut||a.onPointerLeave){const t=ov(e),n=o.hovered.get(t);n?n.stopped&&e.stopPropagation():(o.hovered.set(t,e),null==a.onPointerOver||a.onPointerOver(e),null==a.onPointerEnter||a.onPointerEnter(e))}null==a.onPointerMove||a.onPointerMove(e)}else{const n=a[i];n?u&&!o.initialHits.includes(t)||(r(s,o.interaction.filter((e=>!o.initialHits.includes(e)))),n(e)):u&&o.initialHits.includes(t)&&r(s,o.interaction.filter((e=>!o.initialHits.includes(e))))}}))}}}}const cv=e=>!(null==e||!e.render),hv=t.createContext(null),dv=(e,n)=>{const r=function(e){const n="function"===typeof e?Mg(e):e,r=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:n.getState,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Object.is;const[,i]=(0,t.useReducer)((e=>e+1),0),s=n.getState(),a=(0,t.useRef)(s),o=(0,t.useRef)(e),l=(0,t.useRef)(r),u=(0,t.useRef)(!1),c=(0,t.useRef)();let h;void 0===c.current&&(c.current=e(s));let d=!1;(a.current!==s||o.current!==e||l.current!==r||u.current)&&(h=e(s),d=!r(c.current,h)),bg((()=>{d&&(c.current=h),a.current=s,o.current=e,l.current=r,u.current=!1}));const p=(0,t.useRef)(s);bg((()=>{const e=()=>{try{const e=n.getState(),t=o.current(e);l.current(c.current,t)||(a.current=e,c.current=t,i())}catch(by){u.current=!0,i()}},t=n.subscribe(e);return n.getState()!==p.current&&e(),t}),[]);const f=d?h:c.current;return(0,t.useDebugValue)(f),f};return Object.assign(r,n),r[Symbol.iterator]=function(){console.warn("[useStore, api] = create() is deprecated and will be removed in v4");const e=[r,n];return{next(){const t=e.length<=0;return{value:e.shift(),done:t}}}},r}(((r,i)=>{const s=new Nr,a=new Nr,o=new Nr;function l(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:i().camera,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:a,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:i().size;const{width:r,height:l,top:u,left:c}=n,h=r/l;t instanceof Nr?o.copy(t):o.set(...t);const d=e.getWorldPosition(s).distanceTo(o);if(Fg(e))return{width:r/e.zoom,height:l/e.zoom,top:u,left:c,factor:1,distance:d,aspect:h};{const t=e.fov*Math.PI/180,n=2*Math.tan(t/2)*d,i=n*(r/l);return{width:i,height:n,top:u,left:c,factor:r/i,distance:d,aspect:h}}}let u;const c=e=>r((t=>({performance:{...t.performance,current:e}}))),h=new ir,d={set:r,get:i,gl:null,camera:null,raycaster:null,events:{priority:1,enabled:!0,connected:!1},xr:null,scene:null,invalidate:function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;return e(i(),t)},advance:(e,t)=>n(e,t,i()),legacy:!1,linear:!1,flat:!1,controls:null,clock:new jp,pointer:h,mouse:h,frameloop:"always",onPointerMissed:void 0,performance:{current:1,min:.5,max:1,debounce:200,regress:()=>{const e=i();u&&clearTimeout(u),e.performance.current!==e.performance.min&&c(e.performance.min),u=setTimeout((()=>c(i().performance.max)),e.performance.debounce)}},size:{width:0,height:0,top:0,left:0,updateStyle:!1},viewport:{initialDpr:0,dpr:0,width:0,height:0,top:0,left:0,aspect:0,distance:0,factor:0,getCurrentViewport:l},setEvents:e=>r((t=>({...t,events:{...t.events,...e}}))),setSize:(e,t,n,s,o)=>{const u=i().camera,c={width:e,height:t,top:s||0,left:o||0,updateStyle:n};r((e=>({size:c,viewport:{...e.viewport,...l(u,a,c)}})))},setDpr:e=>r((t=>{const n=jg(e);return{viewport:{...t.viewport,dpr:n,initialDpr:t.viewport.initialDpr||n}}})),setFrameloop:function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"always";const t=i().clock;t.stop(),t.elapsedTime=0,"never"!==e&&(t.start(),t.elapsedTime=0),r((()=>({frameloop:e})))},previousRoot:void 0,internal:{active:!1,priority:0,frames:0,lastEvent:t.createRef(),interaction:[],hovered:new Map,subscribers:[],initialClick:[0,0],initialHits:[],capturedMap:new Map,subscribe:(e,t,n)=>{const r=i().internal;return r.priority=r.priority+(t>0?1:0),r.subscribers.push({ref:e,priority:t,store:n}),r.subscribers=r.subscribers.sort(((e,t)=>e.priority-t.priority)),()=>{const n=i().internal;null!=n&&n.subscribers&&(n.priority=n.priority-(t>0?1:0),n.subscribers=n.subscribers.filter((t=>t.ref!==e)))}}}};return d})),i=r.getState();let s=i.size,a=i.viewport.dpr,o=i.camera;return r.subscribe((()=>{const{camera:e,size:t,viewport:n,gl:i,set:l}=r.getState();if(t.width!==s.width||t.height!==s.height||n.dpr!==a){var u;s=t,a=n.dpr,av(e,t),i.setPixelRatio(n.dpr);const r=null!=(u=t.updateStyle)?u:"undefined"!==typeof HTMLCanvasElement&&i.domElement instanceof HTMLCanvasElement;i.setSize(t.width,t.height,r)}e!==o&&(o=e,l((t=>({viewport:{...t.viewport,...t.viewport.getCurrentViewport(e)}}))))})),r.subscribe((t=>e(t))),r};let pv,fv=new Set,mv=new Set,gv=new Set;function vv(e,t){if(e.size)for(const{callback:n}of e.values())n(t)}function yv(e,t){switch(e){case"before":return vv(fv,t);case"after":return vv(mv,t);case"tail":return vv(gv,t)}}let _v,xv;function Av(e,t,n){let r=t.clock.getDelta();for("never"===t.frameloop&&"number"===typeof e&&(r=e-t.clock.elapsedTime,t.clock.oldTime=t.clock.elapsedTime,t.clock.elapsedTime=e),_v=t.internal.subscribers,pv=0;pv<_v.length;pv++)xv=_v[pv],xv.ref.current(xv.store.getState(),r,n);return!t.internal.priority&&t.gl.render&&t.gl.render(t.scene,t.camera),t.internal.frames=Math.max(0,t.internal.frames-1),"always"===t.frameloop?1:t.internal.frames}function Mv(){const e=t.useContext(hv);if(!e)throw new Error("R3F: Hooks can only be used within the Canvas component!");return e}function bv(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:e=>e,t=arguments.length>1?arguments[1]:void 0;return Mv()(e,t)}function Sv(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;const n=Mv(),r=n.getState().internal.subscribe,i=kg(e);return Og((()=>r(i,t,n)),[t,r,n]),null}const wv=new WeakMap;function Ev(e,t){return function(n){let r=wv.get(n);r||(r=new n,wv.set(n,r)),e&&e(r);for(var i=arguments.length,s=new Array(i>1?i-1:0),a=1;a<i;a++)s[a-1]=arguments[a];return Promise.all(s.map((e=>new Promise(((n,i)=>r.load(e,(e=>{e.scene&&Object.assign(e,Kg(e.scene)),n(e)}),t,(t=>i(new Error(`Could not load ${e}: ${null==t?void 0:t.message}`)))))))))}}function Tv(e,t,n,r){const i=Array.isArray(t)?t:[t],s=Pg(Ev(n,r),[e,...i],{equal:Yg.equ});return Array.isArray(t)?s:s[0]}Tv.preload=function(e,t,n){const r=Array.isArray(t)?t:[t];return((e,t,n)=>{Rg(e,t,!0,n)})(Ev(n),[e,...r])},Tv.clear=function(e,t){return(e=>{if(void 0===e||0===e.length)Tg.splice(0,Tg.length);else{const t=Tg.find((t=>Cg(e,t.keys,t.equal)));t&&t.remove()}})([e,...Array.isArray(t)?t:[t]])};const Cv=new Map,{invalidate:Rv,advance:Pv}=function(e){let t,n,r,i=!1,s=!1;function a(o){n=requestAnimationFrame(a),i=!0,t=0,yv("before",o),s=!0;for(const n of e.values()){var l;r=n.store.getState(),!r.internal.active||!("always"===r.frameloop||r.internal.frames>0)||null!=(l=r.gl.xr)&&l.isPresenting||(t+=Av(o,r))}if(s=!1,yv("after",o),0===t)return yv("tail",o),i=!1,cancelAnimationFrame(n)}return{loop:a,invalidate:function t(n){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;var o;if(!n)return e.forEach((e=>t(e.store.getState(),r)));null!=(o=n.gl.xr)&&o.isPresenting||!n.internal.active||"never"===n.frameloop||(n.internal.frames=r>1?Math.min(60,n.internal.frames+r):s?2:1,i||(i=!0,requestAnimationFrame(a)))},advance:function(t){let n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r=arguments.length>2?arguments[2]:void 0,i=arguments.length>3?arguments[3]:void 0;if(n&&yv("before",t),r)Av(t,r,i);else for(const s of e.values())Av(t,s.store.getState());n&&yv("after",t)}}}(Cv),{reconciler:Iv,applyProps:Bv}=function(e,t){function n(e,t,n){let r,{args:i=[],attach:s,...a}=t,o=`${e[0].toUpperCase()}${e.slice(1)}`;if("primitive"===e){if(void 0===a.object)throw new Error("R3F: Primitives without 'object' are invalid!");r=qg(a.object,{type:e,root:n,attach:s,primitive:!0})}else{const t=Bg[o];if(!t)throw new Error(`R3F: ${o} is not part of the THREE namespace! Did you forget to extend? See: https://docs.pmnd.rs/react-three-fiber/api/objects#using-3rd-party-objects-declaratively`);if(!Array.isArray(i))throw new Error("R3F: The args prop must be an array!");r=qg(new t(...i),{type:e,root:n,attach:s,memoizedProps:{args:i}})}return void 0===r.__r3f.attach&&(r instanceof Ps?r.__r3f.attach="geometry":r instanceof is&&(r.__r3f.attach="material")),"inject"!==o&&rv(r,a),r}function r(e,t){let n=!1;var r,i;t&&(null!=(r=t.__r3f)&&r.attach?$g(e,t,t.__r3f.attach):t.isObject3D&&e.isObject3D&&(e.add(t),n=!0),n||null==(i=e.__r3f)||i.objects.push(t),t.__r3f||qg(t,{}),t.__r3f.parent=e,sv(t),iv(t))}function i(e,t,n){let r=!1;if(t){var i,s;if(null!=(i=t.__r3f)&&i.attach)$g(e,t,t.__r3f.attach);else if(t.isObject3D&&e.isObject3D){t.parent=e,t.dispatchEvent({type:"added"}),e.dispatchEvent({type:"childadded",child:t});const i=e.children.filter((e=>e!==t)),s=i.indexOf(n);e.children=[...i.slice(0,s),t,...i.slice(s)],r=!0}r||null==(s=e.__r3f)||s.objects.push(t),t.__r3f||qg(t,{}),t.__r3f.parent=e,sv(t),iv(t)}}function s(e,t){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];e&&[...e].forEach((e=>a(t,e,n)))}function a(e,t,n){if(t){var r,i,a;if(t.__r3f&&(t.__r3f.parent=null),null!=(r=e.__r3f)&&r.objects&&(e.__r3f.objects=e.__r3f.objects.filter((e=>e!==t))),null!=(i=t.__r3f)&&i.attach)ev(e,t,t.__r3f.attach);else if(t.isObject3D&&e.isObject3D){var o;e.remove(t),null!=(o=t.__r3f)&&o.root&&function(e,t){const{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)=>{lv(n.capturedMap,t,e,r)}))}(Jg(t),t)}const u=null==(a=t.__r3f)?void 0:a.primitive,c=!u&&(void 0===n?null!==t.dispose:n);var l;if(!u)s(null==(l=t.__r3f)?void 0:l.objects,t,c),s(t.children,t,c);if(delete t.__r3f,c&&t.dispose&&"Scene"!==t.type){const e=()=>{try{t.dispose()}catch(e){}};"undefined"===typeof IS_REACT_ACT_ENVIRONMENT?(0,Eg.unstable_scheduleCallback)(Eg.unstable_IdlePriority,e):e()}iv(e)}}const o=()=>console.warn("Text is not allowed in the R3F tree! This could be stray whitespace or characters.");return{reconciler:wg()({createInstance:n,removeChild:a,appendChild:r,appendInitialChild:r,insertBefore:i,supportsMutation:!0,isPrimaryRenderer:!1,supportsPersistence:!1,supportsHydration:!1,noTimeout:-1,appendChildToContainer:(e,t)=>{if(!t)return;const n=e.getState().scene;n.__r3f&&(n.__r3f.root=e,r(n,t))},removeChildFromContainer:(e,t)=>{t&&a(e.getState().scene,t)},insertInContainerBefore:(e,t,n)=>{if(!t||!n)return;const r=e.getState().scene;r.__r3f&&i(r,t,n)},getRootHostContext:()=>null,getChildHostContext:e=>e,finalizeInitialChildren(e){var t;const n=null!=(t=null==e?void 0:e.__r3f)?t:{};return Boolean(n.handlers)},prepareUpdate(e,t,n,r){var i;if((null!=(i=null==e?void 0:e.__r3f)?i:{}).primitive&&r.object&&r.object!==e)return[!0];{const{args:t=[],children:i,...s}=r,{args:a=[],children:o,...l}=n;if(!Array.isArray(t))throw new Error("R3F: the args prop must be an array!");if(t.some(((e,t)=>e!==a[t])))return[!0];const u=tv(e,s,l,!0);return u.changes.length?[!1,u]:null}},commitUpdate(e,t,i,s,o,l){let[u,c]=t;u?function(e,t,i,s){var o;const l=null==(o=e.__r3f)?void 0:o.parent;if(!l)return;const u=n(t,i,e.__r3f.root);if(e.children){for(const t of e.children)t.__r3f&&r(u,t);e.children=e.children.filter((e=>!e.__r3f))}e.__r3f.objects.forEach((e=>r(u,e))),e.__r3f.objects=[],e.__r3f.autoRemovedBeforeAppend||a(l,e),u.parent&&(u.__r3f.autoRemovedBeforeAppend=!0),r(l,u),u.raycast&&u.__r3f.eventCount&&Jg(u).getState().internal.interaction.push(u);[s,s.alternate].forEach((e=>{null!==e&&(e.stateNode=u,e.ref&&("function"===typeof e.ref?e.ref(u):e.ref.current=u))}))}(e,i,o,l):rv(e,c)},commitMount(e,t,n,r){var i;const s=null!=(i=e.__r3f)?i:{};e.raycast&&s.handlers&&s.eventCount&&Jg(e).getState().internal.interaction.push(e)},getPublicInstance:e=>e,prepareForCommit:()=>null,preparePortalMount:e=>qg(e.getState().scene),resetAfterCommit:()=>{},shouldSetTextContent:()=>!1,clearContainer:()=>!1,hideInstance(e){var t;const{attach:n,parent:r}=null!=(t=e.__r3f)?t:{};n&&r&&ev(r,e,n),e.isObject3D&&(e.visible=!1),iv(e)},unhideInstance(e,t){var n;const{attach:r,parent:i}=null!=(n=e.__r3f)?n:{};r&&i&&$g(i,e,r),(e.isObject3D&&null==t.visible||t.visible)&&(e.visible=!0),iv(e)},createTextInstance:o,hideTextInstance:o,unhideTextInstance:o,getCurrentEventPriority:()=>t?t():Ag.DefaultEventPriority,beforeActiveInstanceBlur:()=>{},afterActiveInstanceBlur:()=>{},detachDeletedInstance:()=>{},now:"undefined"!==typeof performance&&Yg.fun(performance.now)?performance.now:Yg.fun(Date.now)?Date.now:()=>0,scheduleTimeout:Yg.fun(setTimeout)?setTimeout:void 0,cancelTimeout:Yg.fun(clearTimeout)?clearTimeout:void 0}),applyProps:rv}}(0,(function(){var e;const t="undefined"!==typeof self&&self||"undefined"!==typeof window&&window;if(!t)return Ag.DefaultEventPriority;switch(null==(e=t.event)?void 0:e.type){case"click":case"contextmenu":case"dblclick":case"pointercancel":case"pointerdown":case"pointerup":return Ag.DiscreteEventPriority;case"pointermove":case"pointerout":case"pointerover":case"pointerenter":case"pointerleave":case"wheel":return Ag.ContinuousEventPriority;default:return Ag.DefaultEventPriority}})),Lv={objects:"shallow",strict:!1},Dv=(e,t)=>{const n="function"===typeof e?e(t):e;return cv(n)?n:new cu({powerPreference:"high-performance",canvas:t,antialias:!0,alpha:!0,...e})};function Uv(e){const t=Cv.get(e),n=null==t?void 0:t.fiber,r=null==t?void 0:t.store;t&&console.warn("R3F.createRoot should only be called once!");const i="function"===typeof reportError?reportError:console.error,s=r||dv(Rv,Pv),a=n||Iv.createContainer(s,Ag.ConcurrentRoot,null,!1,null,"",i,null);let o;t||Cv.set(e,{fiber:a,store:s});let l,u=!1;return{configure(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{gl:n,size:r,scene:i,events:a,onCreated:c,shadows:m=!1,linear:g=!1,flat:v=!1,legacy:y=!1,orthographic:_=!1,frameloop:x="always",dpr:A=[1,2],performance:M,raycaster:b,camera:S,onPointerMissed:w}=t,E=s.getState(),T=E.gl;E.gl||E.set({gl:T=Dv(n,e)});let C=E.raycaster;C||E.set({raycaster:C=new Sf});const{params:R,...P}=b||{};if(Yg.equ(P,C,Lv)||Bv(C,{...P}),Yg.equ(R,C.params,Lv)||Bv(C,{params:{...C.params,...R}}),!E.camera||E.camera===l&&!Yg.equ(l,S,Lv)){l=S;const e=S instanceof na,t=e?S:_?new La(0,0,0,0,.1,1e3):new aa(75,0,.1,1e3);e||(t.position.z=5,S&&(Bv(t,S),("aspect"in S||"left"in S||"right"in S||"bottom"in S||"top"in S)&&(t.manual=!0,t.updateProjectionMatrix())),E.camera||null!=S&&S.rotation||t.lookAt(0,0,0)),E.set({camera:t}),C.camera=t}if(!E.scene){let e;i instanceof pu?e=i:(e=new pu,i&&Bv(e,i)),E.set({scene:qg(e)})}if(!E.xr){var I;const e=(e,t)=>{const n=s.getState();"never"!==n.frameloop&&Pv(e,!0,n,t)},t=()=>{const t=s.getState();t.gl.xr.enabled=t.gl.xr.isPresenting,t.gl.xr.setAnimationLoop(t.gl.xr.isPresenting?e:null),t.gl.xr.isPresenting||Rv(t)},n={connect(){const e=s.getState().gl;e.xr.addEventListener("sessionstart",t),e.xr.addEventListener("sessionend",t)},disconnect(){const e=s.getState().gl;e.xr.removeEventListener("sessionstart",t),e.xr.removeEventListener("sessionend",t)}};"function"===typeof(null==(I=T.xr)?void 0:I.addEventListener)&&n.connect(),E.set({xr:n})}if(T.shadowMap){const e=T.shadowMap.enabled,t=T.shadowMap.type;if(T.shadowMap.enabled=!!m,Yg.boo(m))T.shadowMap.type=p;else if(Yg.str(m)){var B;const e={basic:h,percentage:d,soft:p,variance:f};T.shadowMap.type=null!=(B=e[m])?B:p}else Yg.obj(m)&&Object.assign(T.shadowMap,m);e===T.shadowMap.enabled&&t===T.shadowMap.type||(T.shadowMap.needsUpdate=!0)}const L=Ng();if(L&&("enabled"in L?L.enabled=!y:"legacyMode"in L&&(L.legacyMode=y)),!u){Bv(T,{outputEncoding:g?3e3:3001,toneMapping:v?te:se})}E.legacy!==y&&E.set((()=>({legacy:y}))),E.linear!==g&&E.set((()=>({linear:g}))),E.flat!==v&&E.set((()=>({flat:v}))),!n||Yg.fun(n)||cv(n)||Yg.equ(n,T,Lv)||Bv(T,n),a&&!E.events.handlers&&E.set({events:a(s)});const D=function(e,t){const n="undefined"!==typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement;if(t){const{width:e,height:r,top:i,left:s,updateStyle:a=n}=t;return{width:e,height:r,top:i,left:s,updateStyle:a}}if("undefined"!==typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement&&e.parentElement){const{width:t,height:r,top:i,left:s}=e.parentElement.getBoundingClientRect();return{width:t,height:r,top:i,left:s,updateStyle:n}}return"undefined"!==typeof OffscreenCanvas&&e instanceof OffscreenCanvas?{width:e.width,height:e.height,top:0,left:0,updateStyle:n}:{width:0,height:0,top:0,left:0}}(e,r);return Yg.equ(D,E.size,Lv)||E.setSize(D.width,D.height,D.updateStyle,D.top,D.left),A&&E.viewport.dpr!==jg(A)&&E.setDpr(A),E.frameloop!==x&&E.setFrameloop(x),E.onPointerMissed||E.set({onPointerMissed:w}),M&&!Yg.equ(M,E.performance,Lv)&&E.set((e=>({performance:{...e.performance,...M}}))),o=c,u=!0,this},render(t){return u||this.configure(),Iv.updateContainer((0,Ig.jsx)(Nv,{store:s,children:t,onCreated:o,rootElement:e}),a,null,(()=>{})),s},unmount(){Fv(e)}}}function Nv(e){let{store:t,children:n,onCreated:r,rootElement:i}=e;return Og((()=>{const e=t.getState();e.set((e=>({internal:{...e.internal,active:!0}}))),r&&r(e),t.getState().events.connected||null==e.events.connect||e.events.connect(i)}),[]),(0,Ig.jsx)(hv.Provider,{value:t,children:n})}function Fv(e,t){const n=Cv.get(e),r=null==n?void 0:n.fiber;if(r){const i=null==n?void 0:n.store.getState();i&&(i.internal.active=!1),Iv.updateContainer(null,r,null,(()=>{i&&setTimeout((()=>{try{var n,r,s,a;null==i.events.disconnect||i.events.disconnect(),null==(n=i.gl)||null==(r=n.renderLists)||null==r.dispose||r.dispose(),null==(s=i.gl)||null==s.forceContextLoss||s.forceContextLoss(),null!=(a=i.gl)&&a.xr&&i.xr.disconnect(),function(e){e.dispose&&"Scene"!==e.type&&e.dispose();for(const t in e)null==t.dispose||t.dispose(),delete e[t]}(i),Cv.delete(e),t&&t(e)}catch(o){}}),500)}))}}Iv.injectIntoDevTools({bundleType:0,rendererPackageName:"@react-three/fiber",version:t.version});t.unstable_act;let Ov=null,kv="https://www.gstatic.com/draco/versioned/decoders/1.5.5/";function Hv(e,t,n){return r=>{n&&n(r),e&&(Ov||(Ov=new mm),Ov.setDecoderPath("string"===typeof e?e:kv),r.setDRACOLoader(Ov)),t&&r.setMeshoptDecoder("function"===typeof ym?ym():ym)}}function zv(e){return Tv(Sm,e,Hv(!(arguments.length>1&&void 0!==arguments[1])||arguments[1],!(arguments.length>2&&void 0!==arguments[2])||arguments[2],arguments.length>3?arguments[3]:void 0))}zv.preload=function(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],r=arguments.length>3?arguments[3]:void 0;return Tv.preload(Sm,e,Hv(t,n,r))},zv.clear=e=>Tv.clear(Sm,e),zv.setDecoderPath=e=>{kv=e};function Gv(){return Gv=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Gv.apply(null,arguments)}let Vv,Wv;const jv=t.createContext(null),Xv=new di,Jv=new Nr,Yv=t.forwardRef(((e,n)=>{let{children:r,range:i,limit:s=1e3,...a}=e;const o=t.useRef(null);t.useImperativeHandle(n,(()=>o.current),[]);const[l,u]=t.useState([]),[[c,h,d]]=t.useState((()=>[new Float32Array(3*s),Float32Array.from({length:3*s},(()=>1)),Float32Array.from({length:s},(()=>1))]));t.useEffect((()=>{o.current.geometry.attributes.position.needsUpdate=!0})),Sv((()=>{for(o.current.updateMatrix(),o.current.updateMatrixWorld(),Xv.copy(o.current.matrixWorld).invert(),o.current.geometry.drawRange.count=Math.min(s,void 0!==i?i:s,l.length),Vv=0;Vv<l.length;Vv++)Wv=l[Vv].current,Wv.getWorldPosition(Jv).applyMatrix4(Xv),Jv.toArray(c,3*Vv),o.current.geometry.attributes.position.needsUpdate=!0,Wv.matrixWorldNeedsUpdate=!0,Wv.color.toArray(h,3*Vv),o.current.geometry.attributes.color.needsUpdate=!0,d.set([Wv.size],Vv),o.current.geometry.attributes.size.needsUpdate=!0}));const p=t.useMemo((()=>({getParent:()=>o,subscribe:e=>(u((t=>[...t,e])),()=>u((t=>t.filter((t=>t.current!==e.current)))))})),[]);return t.createElement("points",Gv({userData:{instances:l},matrixAutoUpdate:!1,ref:o,raycast:()=>null},a),t.createElement("bufferGeometry",null,t.createElement("bufferAttribute",{attach:"attributes-position",count:c.length/3,array:c,itemSize:3,usage:Dn}),t.createElement("bufferAttribute",{attach:"attributes-color",count:h.length/3,array:h,itemSize:3,usage:Dn}),t.createElement("bufferAttribute",{attach:"attributes-size",count:d.length,array:d,itemSize:1,usage:Dn})),t.createElement(jv.Provider,{value:p},r))})),Kv=t.forwardRef(((e,n)=>{let{children:r,positions:i,colors:s,sizes:a,stride:o=3,...l}=e;const u=t.useRef(null);return t.useImperativeHandle(n,(()=>u.current),[]),Sv((()=>{const e=u.current.geometry.attributes;e.position.needsUpdate=!0,s&&(e.color.needsUpdate=!0),a&&(e.size.needsUpdate=!0)})),t.createElement("points",Gv({ref:u},l),t.createElement("bufferGeometry",null,t.createElement("bufferAttribute",{attach:"attributes-position",count:i.length/o,array:i,itemSize:o,usage:Dn}),s&&t.createElement("bufferAttribute",{attach:"attributes-color",count:s.length/o,array:s,itemSize:3,usage:Dn}),a&&t.createElement("bufferAttribute",{attach:"attributes-size",count:a.length/o,array:a,itemSize:1,usage:Dn})),r)})),qv=t.forwardRef(((e,n)=>e.positions instanceof Float32Array?t.createElement(Kv,Gv({},e,{ref:n})):t.createElement(Yv,Gv({},e,{ref:n}))));var Qv=Object.defineProperty,Zv=(e,t,n)=>(((e,t,n)=>{t in e?Qv(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n})(e,"symbol"!==typeof t?t+"":t,n),n);const $v=new hi,ey=new fa,ty=Math.cos(Math.PI/180*70),ny=(e,t)=>(e%t+t)%t;class ry extends Xn{constructor(e,t){super(),Zv(this,"object"),Zv(this,"domElement"),Zv(this,"enabled",!0),Zv(this,"target",new Nr),Zv(this,"minDistance",0),Zv(this,"maxDistance",1/0),Zv(this,"minZoom",0),Zv(this,"maxZoom",1/0),Zv(this,"minPolarAngle",0),Zv(this,"maxPolarAngle",Math.PI),Zv(this,"minAzimuthAngle",-1/0),Zv(this,"maxAzimuthAngle",1/0),Zv(this,"enableDamping",!1),Zv(this,"dampingFactor",.05),Zv(this,"enableZoom",!0),Zv(this,"zoomSpeed",1),Zv(this,"enableRotate",!0),Zv(this,"rotateSpeed",1),Zv(this,"enablePan",!0),Zv(this,"panSpeed",1),Zv(this,"screenSpacePanning",!0),Zv(this,"keyPanSpeed",7),Zv(this,"zoomToCursor",!1),Zv(this,"autoRotate",!1),Zv(this,"autoRotateSpeed",2),Zv(this,"reverseOrbit",!1),Zv(this,"reverseHorizontalOrbit",!1),Zv(this,"reverseVerticalOrbit",!1),Zv(this,"keys",{LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"}),Zv(this,"mouseButtons",{LEFT:s.ROTATE,MIDDLE:s.DOLLY,RIGHT:s.PAN}),Zv(this,"touches",{ONE:a.ROTATE,TWO:a.DOLLY_PAN}),Zv(this,"target0"),Zv(this,"position0"),Zv(this,"zoom0"),Zv(this,"_domElementKeyEvents",null),Zv(this,"getPolarAngle"),Zv(this,"getAzimuthalAngle"),Zv(this,"setPolarAngle"),Zv(this,"setAzimuthalAngle"),Zv(this,"getDistance"),Zv(this,"listenToKeyEvents"),Zv(this,"stopListenToKeyEvents"),Zv(this,"saveState"),Zv(this,"reset"),Zv(this,"update"),Zv(this,"connect"),Zv(this,"dispose"),this.object=e,this.domElement=t,this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this.getPolarAngle=()=>h.phi,this.getAzimuthalAngle=()=>h.theta,this.setPolarAngle=e=>{let t=ny(e,2*Math.PI),r=h.phi;r<0&&(r+=2*Math.PI),t<0&&(t+=2*Math.PI);let i=Math.abs(t-r);2*Math.PI-i<i&&(t<r?t+=2*Math.PI:r+=2*Math.PI),d.phi=t-r,n.update()},this.setAzimuthalAngle=e=>{let t=ny(e,2*Math.PI),r=h.theta;r<0&&(r+=2*Math.PI),t<0&&(t+=2*Math.PI);let i=Math.abs(t-r);2*Math.PI-i<i&&(t<r?t+=2*Math.PI:r+=2*Math.PI),d.theta=t-r,n.update()},this.getDistance=()=>n.object.position.distanceTo(n.target),this.listenToKeyEvents=e=>{e.addEventListener("keydown",Q),this._domElementKeyEvents=e},this.stopListenToKeyEvents=()=>{this._domElementKeyEvents.removeEventListener("keydown",Q),this._domElementKeyEvents=null},this.saveState=()=>{n.target0.copy(n.target),n.position0.copy(n.object.position),n.zoom0=n.object.zoom},this.reset=()=>{n.target.copy(n.target0),n.object.position.copy(n.position0),n.object.zoom=n.zoom0,n.object.updateProjectionMatrix(),n.dispatchEvent(r),n.update(),u=l.NONE},this.update=(()=>{const t=new Nr,i=new Nr(0,1,0),s=(new Ur).setFromUnitVectors(e.up,i),a=s.clone().invert(),o=new Nr,m=new Ur,g=2*Math.PI;return function(){const v=n.object.position;s.setFromUnitVectors(e.up,i),a.copy(s).invert(),t.copy(v).sub(n.target),t.applyQuaternion(s),h.setFromVector3(t),n.autoRotate&&u===l.NONE&&P(2*Math.PI/60/60*n.autoRotateSpeed),n.enableDamping?(h.theta+=d.theta*n.dampingFactor,h.phi+=d.phi*n.dampingFactor):(h.theta+=d.theta,h.phi+=d.phi);let y=n.minAzimuthAngle,_=n.maxAzimuthAngle;isFinite(y)&&isFinite(_)&&(y<-Math.PI?y+=g:y>Math.PI&&(y-=g),_<-Math.PI?_+=g:_>Math.PI&&(_-=g),h.theta=y<=_?Math.max(y,Math.min(_,h.theta)):h.theta>(y+_)/2?Math.max(y,h.theta):Math.min(_,h.theta)),h.phi=Math.max(n.minPolarAngle,Math.min(n.maxPolarAngle,h.phi)),h.makeSafe(),!0===n.enableDamping?n.target.addScaledVector(f,n.dampingFactor):n.target.add(f),n.zoomToCursor&&E||n.object.isOrthographicCamera?h.radius=O(h.radius):h.radius=O(h.radius*p),t.setFromSpherical(h),t.applyQuaternion(a),v.copy(n.target).add(t),n.object.matrixAutoUpdate||n.object.updateMatrix(),n.object.lookAt(n.target),!0===n.enableDamping?(d.theta*=1-n.dampingFactor,d.phi*=1-n.dampingFactor,f.multiplyScalar(1-n.dampingFactor)):(d.set(0,0,0),f.set(0,0,0));let x=!1;if(n.zoomToCursor&&E){let r=null;if(n.object instanceof aa&&n.object.isPerspectiveCamera){const e=t.length();r=O(e*p);const i=e-r;n.object.position.addScaledVector(S,i),n.object.updateMatrixWorld()}else if(n.object.isOrthographicCamera){const e=new Nr(w.x,w.y,0);e.unproject(n.object),n.object.zoom=Math.max(n.minZoom,Math.min(n.maxZoom,n.object.zoom/p)),n.object.updateProjectionMatrix(),x=!0;const i=new Nr(w.x,w.y,0);i.unproject(n.object),n.object.position.sub(i).add(e),n.object.updateMatrixWorld(),r=t.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),n.zoomToCursor=!1;null!==r&&(n.screenSpacePanning?n.target.set(0,0,-1).transformDirection(n.object.matrix).multiplyScalar(r).add(n.object.position):($v.origin.copy(n.object.position),$v.direction.set(0,0,-1).transformDirection(n.object.matrix),Math.abs(n.object.up.dot($v.direction))<ty?e.lookAt(n.target):(ey.setFromNormalAndCoplanarPoint(n.object.up,n.target),$v.intersectPlane(ey,n.target))))}else n.object instanceof La&&n.object.isOrthographicCamera&&(x=1!==p,x&&(n.object.zoom=Math.max(n.minZoom,Math.min(n.maxZoom,n.object.zoom/p)),n.object.updateProjectionMatrix()));return p=1,E=!1,!!(x||o.distanceToSquared(n.object.position)>c||8*(1-m.dot(n.object.quaternion))>c)&&(n.dispatchEvent(r),o.copy(n.object.position),m.copy(n.object.quaternion),x=!1,!0)}})(),this.connect=e=>{e===document&&console.error('THREE.OrbitControls: "document" should not be used as the target "domElement". Please use "renderer.domElement" instead.'),n.domElement=e,n.domElement.style.touchAction="none",n.domElement.addEventListener("contextmenu",Z),n.domElement.addEventListener("pointerdown",J),n.domElement.addEventListener("pointercancel",K),n.domElement.addEventListener("wheel",q)},this.dispose=()=>{var e,t,r,i,s,a;n.domElement&&(n.domElement.style.touchAction="auto"),null==(e=n.domElement)||e.removeEventListener("contextmenu",Z),null==(t=n.domElement)||t.removeEventListener("pointerdown",J),null==(r=n.domElement)||r.removeEventListener("pointercancel",K),null==(i=n.domElement)||i.removeEventListener("wheel",q),null==(s=n.domElement)||s.ownerDocument.removeEventListener("pointermove",Y),null==(a=n.domElement)||a.ownerDocument.removeEventListener("pointerup",K),null!==n._domElementKeyEvents&&n._domElementKeyEvents.removeEventListener("keydown",Q)};const n=this,r={type:"change"},i={type:"start"},o={type:"end"},l={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6};let u=l.NONE;const c=1e-6,h=new Tf,d=new Tf;let p=1;const f=new Nr,m=new ir,g=new ir,v=new ir,y=new ir,_=new ir,x=new ir,A=new ir,M=new ir,b=new ir,S=new Nr,w=new ir;let E=!1;const T=[],C={};function R(){return Math.pow(.95,n.zoomSpeed)}function P(e){n.reverseOrbit||n.reverseHorizontalOrbit?d.theta+=e:d.theta-=e}function I(e){n.reverseOrbit||n.reverseVerticalOrbit?d.phi+=e:d.phi-=e}const B=(()=>{const e=new Nr;return function(t,n){e.setFromMatrixColumn(n,0),e.multiplyScalar(-t),f.add(e)}})(),L=(()=>{const e=new Nr;return function(t,r){!0===n.screenSpacePanning?e.setFromMatrixColumn(r,1):(e.setFromMatrixColumn(r,0),e.crossVectors(n.object.up,e)),e.multiplyScalar(t),f.add(e)}})(),D=(()=>{const e=new Nr;return function(t,r){const i=n.domElement;if(i&&n.object instanceof aa&&n.object.isPerspectiveCamera){const s=n.object.position;e.copy(s).sub(n.target);let a=e.length();a*=Math.tan(n.object.fov/2*Math.PI/180),B(2*t*a/i.clientHeight,n.object.matrix),L(2*r*a/i.clientHeight,n.object.matrix)}else i&&n.object instanceof La&&n.object.isOrthographicCamera?(B(t*(n.object.right-n.object.left)/n.object.zoom/i.clientWidth,n.object.matrix),L(r*(n.object.top-n.object.bottom)/n.object.zoom/i.clientHeight,n.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),n.enablePan=!1)}})();function U(e){n.object instanceof aa&&n.object.isPerspectiveCamera||n.object instanceof La&&n.object.isOrthographicCamera?p/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),n.enableZoom=!1)}function N(e){n.object instanceof aa&&n.object.isPerspectiveCamera||n.object instanceof La&&n.object.isOrthographicCamera?p*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),n.enableZoom=!1)}function F(e){if(!n.zoomToCursor||!n.domElement)return;E=!0;const t=n.domElement.getBoundingClientRect(),r=e.clientX-t.left,i=e.clientY-t.top,s=t.width,a=t.height;w.x=r/s*2-1,w.y=-i/a*2+1,S.set(w.x,w.y,1).unproject(n.object).sub(n.object.position).normalize()}function O(e){return Math.max(n.minDistance,Math.min(n.maxDistance,e))}function k(e){m.set(e.clientX,e.clientY)}function H(e){y.set(e.clientX,e.clientY)}function z(){if(1==T.length)m.set(T[0].pageX,T[0].pageY);else{const e=.5*(T[0].pageX+T[1].pageX),t=.5*(T[0].pageY+T[1].pageY);m.set(e,t)}}function G(){if(1==T.length)y.set(T[0].pageX,T[0].pageY);else{const e=.5*(T[0].pageX+T[1].pageX),t=.5*(T[0].pageY+T[1].pageY);y.set(e,t)}}function V(){const e=T[0].pageX-T[1].pageX,t=T[0].pageY-T[1].pageY,n=Math.sqrt(e*e+t*t);A.set(0,n)}function W(e){if(1==T.length)g.set(e.pageX,e.pageY);else{const t=ee(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);g.set(n,r)}v.subVectors(g,m).multiplyScalar(n.rotateSpeed);const t=n.domElement;t&&(P(2*Math.PI*v.x/t.clientHeight),I(2*Math.PI*v.y/t.clientHeight)),m.copy(g)}function j(e){if(1==T.length)_.set(e.pageX,e.pageY);else{const t=ee(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);_.set(n,r)}x.subVectors(_,y).multiplyScalar(n.panSpeed),D(x.x,x.y),y.copy(_)}function X(e){const t=ee(e),r=e.pageX-t.x,i=e.pageY-t.y,s=Math.sqrt(r*r+i*i);M.set(0,s),b.set(0,Math.pow(M.y/A.y,n.zoomSpeed)),U(b.y),A.copy(M)}function J(e){var t,r;!1!==n.enabled&&(0===T.length&&(null==(t=n.domElement)||t.ownerDocument.addEventListener("pointermove",Y),null==(r=n.domElement)||r.ownerDocument.addEventListener("pointerup",K)),function(e){T.push(e)}(e),"touch"===e.pointerType?function(e){switch($(e),T.length){case 1:switch(n.touches.ONE){case a.ROTATE:if(!1===n.enableRotate)return;z(),u=l.TOUCH_ROTATE;break;case a.PAN:if(!1===n.enablePan)return;G(),u=l.TOUCH_PAN;break;default:u=l.NONE}break;case 2:switch(n.touches.TWO){case a.DOLLY_PAN:if(!1===n.enableZoom&&!1===n.enablePan)return;n.enableZoom&&V(),n.enablePan&&G(),u=l.TOUCH_DOLLY_PAN;break;case a.DOLLY_ROTATE:if(!1===n.enableZoom&&!1===n.enableRotate)return;n.enableZoom&&V(),n.enableRotate&&z(),u=l.TOUCH_DOLLY_ROTATE;break;default:u=l.NONE}break;default:u=l.NONE}u!==l.NONE&&n.dispatchEvent(i)}(e):function(e){let t;switch(e.button){case 0:t=n.mouseButtons.LEFT;break;case 1:t=n.mouseButtons.MIDDLE;break;case 2:t=n.mouseButtons.RIGHT;break;default:t=-1}switch(t){case s.DOLLY:if(!1===n.enableZoom)return;!function(e){F(e),A.set(e.clientX,e.clientY)}(e),u=l.DOLLY;break;case s.ROTATE:if(e.ctrlKey||e.metaKey||e.shiftKey){if(!1===n.enablePan)return;H(e),u=l.PAN}else{if(!1===n.enableRotate)return;k(e),u=l.ROTATE}break;case s.PAN:if(e.ctrlKey||e.metaKey||e.shiftKey){if(!1===n.enableRotate)return;k(e),u=l.ROTATE}else{if(!1===n.enablePan)return;H(e),u=l.PAN}break;default:u=l.NONE}u!==l.NONE&&n.dispatchEvent(i)}(e))}function Y(e){!1!==n.enabled&&("touch"===e.pointerType?function(e){switch($(e),u){case l.TOUCH_ROTATE:if(!1===n.enableRotate)return;W(e),n.update();break;case l.TOUCH_PAN:if(!1===n.enablePan)return;j(e),n.update();break;case l.TOUCH_DOLLY_PAN:if(!1===n.enableZoom&&!1===n.enablePan)return;!function(e){n.enableZoom&&X(e),n.enablePan&&j(e)}(e),n.update();break;case l.TOUCH_DOLLY_ROTATE:if(!1===n.enableZoom&&!1===n.enableRotate)return;!function(e){n.enableZoom&&X(e),n.enableRotate&&W(e)}(e),n.update();break;default:u=l.NONE}}(e):function(e){if(!1===n.enabled)return;switch(u){case l.ROTATE:if(!1===n.enableRotate)return;!function(e){g.set(e.clientX,e.clientY),v.subVectors(g,m).multiplyScalar(n.rotateSpeed);const t=n.domElement;t&&(P(2*Math.PI*v.x/t.clientHeight),I(2*Math.PI*v.y/t.clientHeight)),m.copy(g),n.update()}(e);break;case l.DOLLY:if(!1===n.enableZoom)return;!function(e){M.set(e.clientX,e.clientY),b.subVectors(M,A),b.y>0?U(R()):b.y<0&&N(R()),A.copy(M),n.update()}(e);break;case l.PAN:if(!1===n.enablePan)return;!function(e){_.set(e.clientX,e.clientY),x.subVectors(_,y).multiplyScalar(n.panSpeed),D(x.x,x.y),y.copy(_),n.update()}(e)}}(e))}function K(e){var t,r,i;!function(e){delete C[e.pointerId];for(let t=0;t<T.length;t++)if(T[t].pointerId==e.pointerId)return void T.splice(t,1)}(e),0===T.length&&(null==(t=n.domElement)||t.releasePointerCapture(e.pointerId),null==(r=n.domElement)||r.ownerDocument.removeEventListener("pointermove",Y),null==(i=n.domElement)||i.ownerDocument.removeEventListener("pointerup",K)),n.dispatchEvent(o),u=l.NONE}function q(e){!1===n.enabled||!1===n.enableZoom||u!==l.NONE&&u!==l.ROTATE||(e.preventDefault(),n.dispatchEvent(i),function(e){F(e),e.deltaY<0?N(R()):e.deltaY>0&&U(R()),n.update()}(e),n.dispatchEvent(o))}function Q(e){!1!==n.enabled&&!1!==n.enablePan&&function(e){let t=!1;switch(e.code){case n.keys.UP:D(0,n.keyPanSpeed),t=!0;break;case n.keys.BOTTOM:D(0,-n.keyPanSpeed),t=!0;break;case n.keys.LEFT:D(n.keyPanSpeed,0),t=!0;break;case n.keys.RIGHT:D(-n.keyPanSpeed,0),t=!0}t&&(e.preventDefault(),n.update())}(e)}function Z(e){!1!==n.enabled&&e.preventDefault()}function $(e){let t=C[e.pointerId];void 0===t&&(t=new ir,C[e.pointerId]=t),t.set(e.pageX,e.pageY)}function ee(e){const t=e.pointerId===T[0].pointerId?T[1]:T[0];return C[t.pointerId]}void 0!==t&&this.connect(t),this.update()}}const iy=t.forwardRef(((e,n)=>{let{makeDefault:r,camera:i,regress:s,domElement:a,enableDamping:o=!0,keyEvents:l=!1,onChange:u,onStart:c,onEnd:h,...d}=e;const p=bv((e=>e.invalidate)),f=bv((e=>e.camera)),m=bv((e=>e.gl)),g=bv((e=>e.events)),v=bv((e=>e.setEvents)),y=bv((e=>e.set)),_=bv((e=>e.get)),x=bv((e=>e.performance)),A=i||f,M=a||g.connected||m.domElement,b=t.useMemo((()=>new ry(A)),[A]);return Sv((()=>{b.enabled&&b.update()}),-1),t.useEffect((()=>(l&&b.connect(!0===l?M:l),b.connect(M),()=>{b.dispose()})),[l,M,s,b,p]),t.useEffect((()=>{const e=e=>{p(),s&&x.regress(),u&&u(e)},t=e=>{c&&c(e)},n=e=>{h&&h(e)};return b.addEventListener("change",e),b.addEventListener("start",t),b.addEventListener("end",n),()=>{b.removeEventListener("start",t),b.removeEventListener("end",n),b.removeEventListener("change",e)}}),[u,c,h,b,p,v]),t.useEffect((()=>{if(r){const e=_().controls;return y({controls:b}),()=>y({controls:e})}}),[r,b]),t.createElement("primitive",Gv({ref:n,object:b,enableDamping:o},d))}));var sy=n(356),ay=n.n(sy);function oy(e){let{debounce:n,scroll:r,polyfill:i,offsetSize:s}=void 0===e?{debounce:0,scroll:!1,offsetSize:!1}:e;const a=i||("undefined"===typeof window?class{}:window.ResizeObserver);if(!a)throw new Error("This browser does not support ResizeObserver out of the box. See: https://github.com/react-spring/react-use-measure/#resize-observer-polyfills");const[o,l]=(0,t.useState)({left:0,top:0,width:0,height:0,bottom:0,right:0,x:0,y:0}),u=(0,t.useRef)({element:null,scrollContainers:null,resizeObserver:null,lastBounds:o}),c=n?"number"===typeof n?n:n.scroll:null,h=n?"number"===typeof n?n:n.resize:null,d=(0,t.useRef)(!1);(0,t.useEffect)((()=>(d.current=!0,()=>{d.current=!1})));const[p,f,m]=(0,t.useMemo)((()=>{const e=()=>{if(!u.current.element)return;const{left:e,top:t,width:n,height:r,bottom:i,right:a,x:o,y:c}=u.current.element.getBoundingClientRect(),h={left:e,top:t,width:n,height:r,bottom:i,right:a,x:o,y:c};u.current.element instanceof HTMLElement&&s&&(h.height=u.current.element.offsetHeight,h.width=u.current.element.offsetWidth),Object.freeze(h),d.current&&!cy(u.current.lastBounds,h)&&l(u.current.lastBounds=h)};return[e,h?ay()(e,h):e,c?ay()(e,c):e]}),[l,s,c,h]);function g(){u.current.scrollContainers&&(u.current.scrollContainers.forEach((e=>e.removeEventListener("scroll",m,!0))),u.current.scrollContainers=null),u.current.resizeObserver&&(u.current.resizeObserver.disconnect(),u.current.resizeObserver=null)}function v(){u.current.element&&(u.current.resizeObserver=new a(m),u.current.resizeObserver.observe(u.current.element),r&&u.current.scrollContainers&&u.current.scrollContainers.forEach((e=>e.addEventListener("scroll",m,{capture:!0,passive:!0}))))}var y,_,x;return y=m,_=Boolean(r),(0,t.useEffect)((()=>{if(_){const e=y;return window.addEventListener("scroll",e,{capture:!0,passive:!0}),()=>{window.removeEventListener("scroll",e,!0)}}}),[y,_]),x=f,(0,t.useEffect)((()=>{const e=x;return window.addEventListener("resize",e),()=>{window.removeEventListener("resize",e)}}),[x]),(0,t.useEffect)((()=>{g(),v()}),[r,m,f]),(0,t.useEffect)((()=>g),[]),[e=>{e&&e!==u.current.element&&(g(),u.current.element=e,u.current.scrollContainers=ly(e),v())},o,p]}function ly(e){const t=[];if(!e||e===document.body)return t;const{overflow:n,overflowX:r,overflowY:i}=window.getComputedStyle(e);return[n,r,i].some((e=>"auto"===e||"scroll"===e))&&t.push(e),[...t,...ly(e.parentElement)]}const uy=["x","y","top","bottom","left","right","width","height"],cy=(e,t)=>uy.every((n=>e[n]===t[n]));var hy,dy,py=Object.defineProperty,fy=Object.defineProperties,my=Object.getOwnPropertyDescriptors,gy=Object.getOwnPropertySymbols,vy=Object.prototype.hasOwnProperty,yy=Object.prototype.propertyIsEnumerable,_y=(e,t,n)=>t in e?py(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,xy=(e,t)=>{for(var n in t||(t={}))vy.call(t,n)&&_y(e,n,t[n]);if(gy)for(var n of gy(t))yy.call(t,n)&&_y(e,n,t[n]);return e};"undefined"===typeof window||!(null==(hy=window.document)?void 0:hy.createElement)&&"ReactNative"!==(null==(dy=window.navigator)?void 0:dy.product)?t.useEffect:t.useLayoutEffect;function Ay(e,t,n){if(!e)return;if(!0===n(e))return e;let r=t?e.return:e.child;for(;r;){const e=Ay(r,t,n);if(e)return e;r=t?null:r.sibling}}function My(e){try{return Object.defineProperties(e,{_currentRenderer:{get:()=>null,set(){}},_currentRenderer2:{get:()=>null,set(){}}})}catch(t){return e}}const by=console.error;console.error=function(){const e=[...arguments].join("");if(!(null==e?void 0:e.startsWith("Warning:"))||!e.includes("useContext"))return by.apply(this,arguments);console.error=by};const Sy=My(t.createContext(null));class wy extends t.Component{render(){return t.createElement(Sy.Provider,{value:this._reactInternals},this.props.children)}}function Ey(){const e=t.useContext(Sy);if(null===e)throw new Error("its-fine: useFiber must be called within a <FiberProvider />!");const n=t.useId();return t.useMemo((()=>{for(const t of[e,null==e?void 0:e.alternate]){if(!t)continue;const e=Ay(t,!1,(e=>{let t=e.memoizedState;for(;t;){if(t.memoizedState===n)return!0;t=t.next}}));if(e)return e}}),[e,n])}function Ty(){const e=function(){const e=Ey(),[n]=t.useState((()=>new Map));n.clear();let r=e;for(;r;){if(r.type&&"object"===typeof r.type){const e=void 0===r.type._context&&r.type.Provider===r.type?r.type:r.type._context;e&&e!==Sy&&!n.has(e)&&n.set(e,t.useContext(My(e)))}r=r.return}return n}();return t.useMemo((()=>Array.from(e.keys()).reduce(((n,r)=>i=>{return t.createElement(n,null,t.createElement(r.Provider,(s=xy({},i),a={value:e.get(r)},fy(s,my(a)))));var s,a}),(e=>t.createElement(wy,xy({},e))))),[e])}const Cy={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 Ry(e){const{handlePointer:t}=uv(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(Cy).reduce(((e,n)=>({...e,[n]:t(n)})),{}),update:()=>{var t;const{events:n,internal:r}=e.getState();null!=(t=r.lastEvent)&&t.current&&n.handlers&&n.handlers.onPointerMove(r.lastEvent.current)},connect:t=>{var n;const{set:r,events:i}=e.getState();null==i.disconnect||i.disconnect(),r((e=>({events:{...e.events,connected:t}}))),Object.entries(null!=(n=i.handlers)?n:[]).forEach((e=>{let[n,r]=e;const[i,s]=Cy[n];t.addEventListener(i,r,{passive:s})}))},disconnect:()=>{const{set:t,events:n}=e.getState();var r;n.connected&&(Object.entries(null!=(r=n.handlers)?r:[]).forEach((e=>{let[t,r]=e;if(n&&n.connected instanceof HTMLElement){const[e]=Cy[t];n.connected.removeEventListener(e,r)}})),t((e=>({events:{...e.events,connected:void 0}}))))}}}const Py=t.forwardRef((function(n,r){let{children:i,fallback:s,resize:a,style:o,gl:l,events:u=Ry,eventSource:c,eventPrefix:h,shadows:d,linear:p,flat:f,legacy:m,orthographic:g,frameloop:v,dpr:y,performance:_,raycaster:x,camera:A,scene:M,onPointerMissed:b,onCreated:S,...w}=n;t.useMemo((()=>{return t=e,void Object.assign(Bg,t);var t}),[]);const E=Ty(),[T,C]=oy({scroll:!0,debounce:{scroll:50,resize:0},...a}),R=t.useRef(null),P=t.useRef(null);t.useImperativeHandle(r,(()=>R.current));const I=kg(b),[B,L]=t.useState(!1),[D,U]=t.useState(!1);if(B)throw B;if(D)throw D;const N=t.useRef(null);Og((()=>{const e=R.current;C.width>0&&C.height>0&&e&&(N.current||(N.current=Uv(e)),N.current.configure({gl:l,events:u,shadows:d,linear:p,flat:f,legacy:m,orthographic:g,frameloop:v,dpr:y,performance:_,raycaster:x,camera:A,scene:M,size:C,onPointerMissed:function(){return null==I.current?void 0:I.current(...arguments)},onCreated:e=>{var t;null==e.events.connect||e.events.connect(c?(t=c)&&t.hasOwnProperty("current")?c.current:c:P.current),h&&e.setEvents({compute:(e,t)=>{const n=e[h+"X"],r=e[h+"Y"];t.pointer.set(n/t.size.width*2-1,-r/t.size.height*2+1),t.raycaster.setFromCamera(t.pointer,t.camera)}}),null==S||S(e)}}),N.current.render((0,Ig.jsx)(E,{children:(0,Ig.jsx)(zg,{set:U,children:(0,Ig.jsx)(t.Suspense,{fallback:(0,Ig.jsx)(Hg,{set:L}),children:i})})})))})),t.useEffect((()=>{const e=R.current;if(e)return()=>Fv(e)}),[]);const F=c?"none":"auto";return(0,Ig.jsx)("div",{ref:P,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden",pointerEvents:F,...o},...w,children:(0,Ig.jsx)("div",{ref:T,style:{width:"100%",height:"100%"},children:(0,Ig.jsx)("canvas",{ref:R,style:{display:"block"},children:s})})})})),Iy=t.forwardRef((function(e,t){return(0,Ig.jsx)(wy,{children:(0,Ig.jsx)(Py,{...e,ref:t})})}));function By(e,t){if(t===Wt)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),e;if(t===Xt||t===jt){let n=e.getIndex();if(null===n){const t=[],r=e.getAttribute("position");if(void 0===r)return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),e;for(let e=0;e<r.count;e++)t.push(e);e.setIndex(t),n=e.getIndex()}const r=n.count-2,i=[];if(t===Xt)for(let e=1;e<=r;e++)i.push(n.getX(0)),i.push(n.getX(e)),i.push(n.getX(e+1));else for(let e=0;e<r;e++)e%2===0?(i.push(n.getX(e)),i.push(n.getX(e+1)),i.push(n.getX(e+2))):(i.push(n.getX(e+2)),i.push(n.getX(e+1)),i.push(n.getX(e)));i.length/3!==r&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const s=e.clone();return s.setIndex(i),s.clearGroups(),s}return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",t),e}class Ly extends ep{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register((function(e){return new ky(e)})),this.register((function(e){return new Hy(e)})),this.register((function(e){return new Ky(e)})),this.register((function(e){return new qy(e)})),this.register((function(e){return new Qy(e)})),this.register((function(e){return new Gy(e)})),this.register((function(e){return new Vy(e)})),this.register((function(e){return new Wy(e)})),this.register((function(e){return new jy(e)})),this.register((function(e){return new Oy(e)})),this.register((function(e){return new Xy(e)})),this.register((function(e){return new zy(e)})),this.register((function(e){return new Yy(e)})),this.register((function(e){return new Jy(e)})),this.register((function(e){return new Ny(e)})),this.register((function(e){return new Zy(e)})),this.register((function(e){return new $y(e)}))}load(e,t,n,r){const i=this;let s;if(""!==this.resourcePath)s=this.resourcePath;else if(""!==this.path){const t=Pp.extractUrlBase(e);s=Pp.resolveURL(t,this.path)}else s=Pp.extractUrlBase(e);this.manager.itemStart(e);const a=function(t){r?r(t):console.error(t),i.manager.itemError(e),i.manager.itemEnd(e)},o=new rp(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,(function(n){try{i.parse(n,s,(function(n){t(n),i.manager.itemEnd(e)}),a)}catch(r){a(r)}}),n,a)}setDRACOLoader(e){return this.dracoLoader=e,this}setDDSLoader(){throw new Error('THREE.GLTFLoader: "MSFT_texture_dds" no longer supported. Please update to "KHR_texture_basisu".')}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return-1===this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.push(e),this}unregister(e){return-1!==this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,n,r){let i;const s={},a={},o=new TextDecoder;if("string"===typeof e)i=JSON.parse(e);else if(e instanceof ArrayBuffer){if(o.decode(new Uint8Array(e,0,4))===e_){try{s[Uy.KHR_BINARY_GLTF]=new r_(e)}catch(by){return void(r&&r(by))}i=JSON.parse(s[Uy.KHR_BINARY_GLTF].content)}else i=JSON.parse(o.decode(e))}else i=e;if(void 0===i.asset||i.asset.version[0]<2)return void(r&&r(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported.")));const l=new C_(i,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});l.fileLoader.setRequestHeader(this.requestHeader);for(let u=0;u<this.pluginCallbacks.length;u++){const e=this.pluginCallbacks[u](l);e.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),a[e.name]=e,s[e.name]=!0}if(i.extensionsUsed)for(let u=0;u<i.extensionsUsed.length;++u){const e=i.extensionsUsed[u],t=i.extensionsRequired||[];switch(e){case Uy.KHR_MATERIALS_UNLIT:s[e]=new Fy;break;case Uy.KHR_DRACO_MESH_COMPRESSION:s[e]=new i_(i,this.dracoLoader);break;case Uy.KHR_TEXTURE_TRANSFORM:s[e]=new s_;break;case Uy.KHR_MESH_QUANTIZATION:s[e]=new a_;break;default:t.indexOf(e)>=0&&void 0===a[e]&&console.warn('THREE.GLTFLoader: Unknown extension "'+e+'".')}}l.setExtensions(s),l.setPlugins(a),l.parse(n,r)}parseAsync(e,t){const n=this;return new Promise((function(r,i){n.parse(e,t,r,i)}))}}function Dy(){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={}}}}const Uy={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"};class Ny{constructor(e){this.parser=e,this.name=Uy.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let n=0,r=t.length;n<r;n++){const r=t[n];r.extensions&&r.extensions[this.name]&&void 0!==r.extensions[this.name].light&&e._addNodeRef(this.cache,r.extensions[this.name].light)}}_loadLight(e){const t=this.parser,n="light:"+e;let r=t.cache.get(n);if(r)return r;const i=t.json,s=((i.extensions&&i.extensions[this.name]||{}).lights||[])[e];let a;const o=new ts(16777215);void 0!==s.color&&o.setRGB(s.color[0],s.color[1],s.color[2],tn);const l=void 0!==s.range?s.range:0;switch(s.type){case"directional":a=new Sp(o),a.target.position.set(0,0,-1),a.add(a.target);break;case"point":a=new Mp(o),a.distance=l;break;case"spot":a=new vp(o),a.distance=l,s.spot=s.spot||{},s.spot.innerConeAngle=void 0!==s.spot.innerConeAngle?s.spot.innerConeAngle:0,s.spot.outerConeAngle=void 0!==s.spot.outerConeAngle?s.spot.outerConeAngle:Math.PI/4,a.angle=s.spot.outerConeAngle,a.penumbra=1-s.spot.innerConeAngle/s.spot.outerConeAngle,a.target.position.set(0,0,-1),a.add(a.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+s.type)}return a.position.set(0,0,0),a.decay=2,M_(a,s),void 0!==s.intensity&&(a.intensity=s.intensity),a.name=t.createUniqueName(s.name||"light_"+e),r=Promise.resolve(a),t.cache.add(n,r),r}getDependency(e,t){if("light"===e)return this._loadLight(t)}createNodeAttachment(e){const t=this,n=this.parser,r=n.json.nodes[e],i=(r.extensions&&r.extensions[this.name]||{}).light;return void 0===i?null:this._loadLight(i).then((function(e){return n._getNodeRef(t.cache,i,e)}))}}class Fy{constructor(){this.name=Uy.KHR_MATERIALS_UNLIT}getMaterialType(){return ss}extendParams(e,t,n){const r=[];e.color=new ts(1,1,1),e.opacity=1;const i=t.pbrMetallicRoughness;if(i){if(Array.isArray(i.baseColorFactor)){const t=i.baseColorFactor;e.color.setRGB(t[0],t[1],t[2],tn),e.opacity=t[3]}void 0!==i.baseColorTexture&&r.push(n.assignTexture(e,"map",i.baseColorTexture,en))}return Promise.all(r)}}class Oy{constructor(e){this.parser=e,this.name=Uy.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=n.extensions[this.name].emissiveStrength;return void 0!==r&&(t.emissiveIntensity=r),Promise.resolve()}}class ky{constructor(e){this.parser=e,this.name=Uy.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?Sd:null}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const i=[],s=r.extensions[this.name];if(void 0!==s.clearcoatFactor&&(t.clearcoat=s.clearcoatFactor),void 0!==s.clearcoatTexture&&i.push(n.assignTexture(t,"clearcoatMap",s.clearcoatTexture)),void 0!==s.clearcoatRoughnessFactor&&(t.clearcoatRoughness=s.clearcoatRoughnessFactor),void 0!==s.clearcoatRoughnessTexture&&i.push(n.assignTexture(t,"clearcoatRoughnessMap",s.clearcoatRoughnessTexture)),void 0!==s.clearcoatNormalTexture&&(i.push(n.assignTexture(t,"clearcoatNormalMap",s.clearcoatNormalTexture)),void 0!==s.clearcoatNormalTexture.scale)){const e=s.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new ir(e,e)}return Promise.all(i)}}class Hy{constructor(e){this.parser=e,this.name=Uy.KHR_MATERIALS_DISPERSION}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?Sd:null}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=n.extensions[this.name];return t.dispersion=void 0!==r.dispersion?r.dispersion:0,Promise.resolve()}}class zy{constructor(e){this.parser=e,this.name=Uy.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?Sd:null}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const i=[],s=r.extensions[this.name];return void 0!==s.iridescenceFactor&&(t.iridescence=s.iridescenceFactor),void 0!==s.iridescenceTexture&&i.push(n.assignTexture(t,"iridescenceMap",s.iridescenceTexture)),void 0!==s.iridescenceIor&&(t.iridescenceIOR=s.iridescenceIor),void 0===t.iridescenceThicknessRange&&(t.iridescenceThicknessRange=[100,400]),void 0!==s.iridescenceThicknessMinimum&&(t.iridescenceThicknessRange[0]=s.iridescenceThicknessMinimum),void 0!==s.iridescenceThicknessMaximum&&(t.iridescenceThicknessRange[1]=s.iridescenceThicknessMaximum),void 0!==s.iridescenceThicknessTexture&&i.push(n.assignTexture(t,"iridescenceThicknessMap",s.iridescenceThicknessTexture)),Promise.all(i)}}class Gy{constructor(e){this.parser=e,this.name=Uy.KHR_MATERIALS_SHEEN}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?Sd:null}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const i=[];t.sheenColor=new ts(0,0,0),t.sheenRoughness=0,t.sheen=1;const s=r.extensions[this.name];if(void 0!==s.sheenColorFactor){const e=s.sheenColorFactor;t.sheenColor.setRGB(e[0],e[1],e[2],tn)}return void 0!==s.sheenRoughnessFactor&&(t.sheenRoughness=s.sheenRoughnessFactor),void 0!==s.sheenColorTexture&&i.push(n.assignTexture(t,"sheenColorMap",s.sheenColorTexture,en)),void 0!==s.sheenRoughnessTexture&&i.push(n.assignTexture(t,"sheenRoughnessMap",s.sheenRoughnessTexture)),Promise.all(i)}}class Vy{constructor(e){this.parser=e,this.name=Uy.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?Sd:null}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const i=[],s=r.extensions[this.name];return void 0!==s.transmissionFactor&&(t.transmission=s.transmissionFactor),void 0!==s.transmissionTexture&&i.push(n.assignTexture(t,"transmissionMap",s.transmissionTexture)),Promise.all(i)}}class Wy{constructor(e){this.parser=e,this.name=Uy.KHR_MATERIALS_VOLUME}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?Sd:null}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const i=[],s=r.extensions[this.name];t.thickness=void 0!==s.thicknessFactor?s.thicknessFactor:0,void 0!==s.thicknessTexture&&i.push(n.assignTexture(t,"thicknessMap",s.thicknessTexture)),t.attenuationDistance=s.attenuationDistance||1/0;const a=s.attenuationColor||[1,1,1];return t.attenuationColor=(new ts).setRGB(a[0],a[1],a[2],tn),Promise.all(i)}}class jy{constructor(e){this.parser=e,this.name=Uy.KHR_MATERIALS_IOR}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?Sd:null}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=n.extensions[this.name];return t.ior=void 0!==r.ior?r.ior:1.5,Promise.resolve()}}class Xy{constructor(e){this.parser=e,this.name=Uy.KHR_MATERIALS_SPECULAR}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?Sd:null}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const i=[],s=r.extensions[this.name];t.specularIntensity=void 0!==s.specularFactor?s.specularFactor:1,void 0!==s.specularTexture&&i.push(n.assignTexture(t,"specularIntensityMap",s.specularTexture));const a=s.specularColorFactor||[1,1,1];return t.specularColor=(new ts).setRGB(a[0],a[1],a[2],tn),void 0!==s.specularColorTexture&&i.push(n.assignTexture(t,"specularColorMap",s.specularColorTexture,en)),Promise.all(i)}}class Jy{constructor(e){this.parser=e,this.name=Uy.EXT_MATERIALS_BUMP}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?Sd:null}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const i=[],s=r.extensions[this.name];return t.bumpScale=void 0!==s.bumpFactor?s.bumpFactor:1,void 0!==s.bumpTexture&&i.push(n.assignTexture(t,"bumpMap",s.bumpTexture)),Promise.all(i)}}class Yy{constructor(e){this.parser=e,this.name=Uy.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?Sd:null}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const i=[],s=r.extensions[this.name];return void 0!==s.anisotropyStrength&&(t.anisotropy=s.anisotropyStrength),void 0!==s.anisotropyRotation&&(t.anisotropyRotation=s.anisotropyRotation),void 0!==s.anisotropyTexture&&i.push(n.assignTexture(t,"anisotropyMap",s.anisotropyTexture)),Promise.all(i)}}class Ky{constructor(e){this.parser=e,this.name=Uy.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,n=t.json,r=n.textures[e];if(!r.extensions||!r.extensions[this.name])return null;const i=r.extensions[this.name],s=t.options.ktx2Loader;if(!s){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,i.source,s)}}class qy{constructor(e){this.parser=e,this.name=Uy.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,n=this.parser,r=n.json,i=r.textures[e];if(!i.extensions||!i.extensions[t])return null;const s=i.extensions[t],a=r.images[s.source];let o=n.textureLoader;if(a.uri){const e=n.options.manager.getHandler(a.uri);null!==e&&(o=e)}return this.detectSupport().then((function(i){if(i)return n.loadTextureImage(e,s.source,o);if(r.extensionsRequired&&r.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return n.loadTexture(e)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(e){const t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(1===t.height)}}))),this.isSupported}}class Qy{constructor(e){this.parser=e,this.name=Uy.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){const t=this.name,n=this.parser,r=n.json,i=r.textures[e];if(!i.extensions||!i.extensions[t])return null;const s=i.extensions[t],a=r.images[s.source];let o=n.textureLoader;if(a.uri){const e=n.options.manager.getHandler(a.uri);null!==e&&(o=e)}return this.detectSupport().then((function(i){if(i)return n.loadTextureImage(e,s.source,o);if(r.extensionsRequired&&r.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return n.loadTexture(e)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(e){const t=new Image;t.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",t.onload=t.onerror=function(){e(1===t.height)}}))),this.isSupported}}class Zy{constructor(e){this.name=Uy.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){const 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 new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return r.then((function(t){const n=e.byteOffset||0,r=e.byteLength||0,s=e.count,a=e.byteStride,o=new Uint8Array(t,n,r);return i.decodeGltfBufferAsync?i.decodeGltfBufferAsync(s,a,o,e.mode,e.filter).then((function(e){return e.buffer})):i.ready.then((function(){const t=new ArrayBuffer(s*a);return i.decodeGltfBuffer(new Uint8Array(t),s,a,o,e.mode,e.filter),t}))}))}return null}}class $y{constructor(e){this.name=Uy.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||void 0===n.mesh)return null;const r=t.meshes[n.mesh];for(const o of r.primitives)if(o.mode!==c_.TRIANGLES&&o.mode!==c_.TRIANGLE_STRIP&&o.mode!==c_.TRIANGLE_FAN&&void 0!==o.mode)return null;const i=n.extensions[this.name].attributes,s=[],a={};for(const o in i)s.push(this.parser.getDependency("accessor",i[o]).then((e=>(a[o]=e,a[o]))));return s.length<1?null:(s.push(this.parser.createNodeMesh(e)),Promise.all(s).then((e=>{const t=e.pop(),n=t.isGroup?t.children:[t],r=e[0].count,i=[];for(const s of n){const e=new di,t=new Nr,n=new Ur,o=new Nr(1,1,1),l=new sc(s.geometry,s.material,r);for(let i=0;i<r;i++)a.TRANSLATION&&t.fromBufferAttribute(a.TRANSLATION,i),a.ROTATION&&n.fromBufferAttribute(a.ROTATION,i),a.SCALE&&o.fromBufferAttribute(a.SCALE,i),l.setMatrixAt(i,e.compose(t,n,o));for(const r in a)if("_COLOR_0"===r){const e=a[r];l.instanceColor=new Qu(e.array,e.itemSize,e.normalized)}else"TRANSLATION"!==r&&"ROTATION"!==r&&"SCALE"!==r&&s.geometry.setAttribute(r,a[r]);ki.prototype.copy.call(l,s),this.parser.assignFinalMaterial(l),i.push(l)}return t.isGroup?(t.clear(),t.add(...i),t):i[0]})))}}const e_="glTF",t_=1313821514,n_=5130562;class r_{constructor(e){this.name=Uy.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,12),n=new TextDecoder;if(this.header={magic:n.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==e_)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const r=this.header.length-12,i=new DataView(e,12);let s=0;for(;s<r;){const t=i.getUint32(s,!0);s+=4;const r=i.getUint32(s,!0);if(s+=4,r===t_){const r=new Uint8Array(e,12+s,t);this.content=n.decode(r)}else if(r===n_){const n=12+s;this.body=e.slice(n,n+t)}s+=t}if(null===this.content)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class i_{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=Uy.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const n=this.json,r=this.dracoLoader,i=e.extensions[this.name].bufferView,s=e.extensions[this.name].attributes,a={},o={},l={};for(const u in s){const e=m_[u]||u.toLowerCase();a[e]=s[u]}for(const u in e.attributes){const t=m_[u]||u.toLowerCase();if(void 0!==s[u]){const r=n.accessors[e.attributes[u]],i=h_[r.componentType];l[t]=i.name,o[t]=!0===r.normalized}}return t.getDependency("bufferView",i).then((function(e){return new Promise((function(t,n){r.decodeDracoFile(e,(function(e){for(const t in e.attributes){const n=e.attributes[t],r=o[t];void 0!==r&&(n.normalized=r)}t(e)}),a,l,tn,n)}))}))}}class s_{constructor(){this.name=Uy.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return void 0!==t.texCoord&&t.texCoord!==e.channel||void 0!==t.offset||void 0!==t.rotation||void 0!==t.scale?(e=e.clone(),void 0!==t.texCoord&&(e.channel=t.texCoord),void 0!==t.offset&&e.offset.fromArray(t.offset),void 0!==t.rotation&&(e.rotation=t.rotation),void 0!==t.scale&&e.repeat.fromArray(t.scale),e.needsUpdate=!0,e):e}}class a_{constructor(){this.name=Uy.KHR_MESH_QUANTIZATION}}class o_ extends Fd{constructor(e,t,n,r){super(e,t,n,r)}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,r=this.valueSize,i=e*r*3+r;for(let s=0;s!==r;s++)t[s]=n[i+s];return t}interpolate_(e,t,n,r){const i=this.resultBuffer,s=this.sampleValues,a=this.valueSize,o=2*a,l=3*a,u=r-t,c=(n-t)/u,h=c*c,d=h*c,p=e*l,f=p-l,m=-2*d+3*h,g=d-h,v=1-m,y=g-h+c;for(let _=0;_!==a;_++){const e=s[f+_+a],t=s[f+_+o]*u,n=s[p+_+a],r=s[p+_]*u;i[_]=v*e+y*t+m*n+g*r}return i}}const l_=new Ur;class u_ extends o_{interpolate_(e,t,n,r){const i=super.interpolate_(e,t,n,r);return l_.fromArray(i).normalize().toArray(i),i}}const c_={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},h_={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},d_={9728:xe,9729:we,9984:Ae,9985:Ee,9986:be,9987:Ce},p_={33071:ye,33648:_e,10497:ve},f_={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},m_={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},g_={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},v_={CUBICSPLINE:void 0,LINEAR:Ft,STEP:Nt},y_="OPAQUE",__="MASK",x_="BLEND";function A_(e,t,n){for(const r in n.extensions)void 0===e[r]&&(t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[r]=n.extensions[r])}function M_(e,t){void 0!==t.extras&&("object"===typeof t.extras?Object.assign(e.userData,t.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+t.extras))}function b_(e,t){if(e.updateMorphTargets(),void 0!==t.weights)for(let n=0,r=t.weights.length;n<r;n++)e.morphTargetInfluences[n]=t.weights[n];if(t.extras&&Array.isArray(t.extras.targetNames)){const n=t.extras.targetNames;if(e.morphTargetInfluences.length===n.length){e.morphTargetDictionary={};for(let t=0,r=n.length;t<r;t++)e.morphTargetDictionary[n[t]]=t}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function S_(e){let t;const n=e.extensions&&e.extensions[Uy.KHR_DRACO_MESH_COMPRESSION];if(t=n?"draco:"+n.bufferView+":"+n.indices+":"+w_(n.attributes):e.indices+":"+w_(e.attributes)+":"+e.mode,void 0!==e.targets)for(let r=0,i=e.targets.length;r<i;r++)t+=":"+w_(e.targets[r]);return t}function w_(e){let t="";const n=Object.keys(e).sort();for(let r=0,i=n.length;r<i;r++)t+=n[r]+":"+e[n[r]]+";";return t}function E_(e){switch(e){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}const T_=new di;class C_{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new Dy,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,s=-1;if("undefined"!==typeof navigator){const e=navigator.userAgent;n=!0===/^((?!chrome|android).)*safari/i.test(e);const t=e.match(/Version\/(\d+)/);r=n&&t?parseInt(t[1],10):-1,i=e.indexOf("Firefox")>-1,s=i?e.match(/Firefox\/([0-9]+)\./)[1]:-1}"undefined"===typeof createImageBitmap||n&&r<17||i&&s<98?this.textureLoader=new up(this.options.manager):this.textureLoader=new Fp(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new rp(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),"use-credentials"===this.options.crossOrigin&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const 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){const s={scene:t[0][r.scene||0],scenes:t[0],animations:t[1],cameras:t[2],asset:r.asset,parser:n,userData:{}};return A_(i,s,r),M_(s,r),Promise.all(n._invokeAll((function(e){return e.afterRoot&&e.afterRoot(s)}))).then((function(){for(const e of s.scenes)e.updateMatrixWorld();e(s)}))})).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let r=0,i=t.length;r<i;r++){const n=t[r].joints;for(let t=0,r=n.length;t<r;t++)e[n[t]].isBone=!0}for(let r=0,i=e.length;r<i;r++){const t=e[r];void 0!==t.mesh&&(this._addNodeRef(this.meshCache,t.mesh),void 0!==t.skin&&(n[t.mesh].isSkinnedMesh=!0)),void 0!==t.camera&&this._addNodeRef(this.cameraCache,t.camera)}}_addNodeRef(e,t){void 0!==t&&(void 0===e.refs[t]&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,n){if(e.refs[t]<=1)return n;const r=n.clone(),i=(e,t)=>{const n=this.associations.get(e);null!=n&&this.associations.set(t,n);for(const[r,s]of e.children.entries())i(s,t.children[r])};return i(n,r),r.name+="_instance_"+e.uses[t]++,r}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){const r=e(t[n]);if(r)return r}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const n=[];for(let r=0;r<t.length;r++){const i=e(t[r]);i&&n.push(i)}return n}getDependency(e,t){const n=e+":"+t;let r=this.cache.get(n);if(!r){switch(e){case"scene":r=this.loadScene(t);break;case"node":r=this._invokeOne((function(e){return e.loadNode&&e.loadNode(t)}));break;case"mesh":r=this._invokeOne((function(e){return e.loadMesh&&e.loadMesh(t)}));break;case"accessor":r=this.loadAccessor(t);break;case"bufferView":r=this._invokeOne((function(e){return e.loadBufferView&&e.loadBufferView(t)}));break;case"buffer":r=this.loadBuffer(t);break;case"material":r=this._invokeOne((function(e){return e.loadMaterial&&e.loadMaterial(t)}));break;case"texture":r=this._invokeOne((function(e){return e.loadTexture&&e.loadTexture(t)}));break;case"skin":r=this.loadSkin(t);break;case"animation":r=this._invokeOne((function(e){return e.loadAnimation&&e.loadAnimation(t)}));break;case"camera":r=this.loadCamera(t);break;default:if(r=this._invokeOne((function(n){return n!=this&&n.getDependency&&n.getDependency(e,t)})),!r)throw new Error("Unknown type: "+e)}this.cache.add(n,r)}return r}getDependencies(e){let t=this.cache.get(e);if(!t){const n=this,r=this.json[e+("mesh"===e?"es":"s")]||[];t=Promise.all(r.map((function(t,r){return n.getDependency(e,r)}))),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],n=this.fileLoader;if(t.type&&"arraybuffer"!==t.type)throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(void 0===t.uri&&0===e)return Promise.resolve(this.extensions[Uy.KHR_BINARY_GLTF].body);const r=this.options;return new Promise((function(e,i){n.load(Pp.resolveURL(t.uri,r.path),e,void 0,(function(){i(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))}))}))}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then((function(e){const n=t.byteLength||0,r=t.byteOffset||0;return e.slice(r,r+n)}))}loadAccessor(e){const t=this,n=this.json,r=this.json.accessors[e];if(void 0===r.bufferView&&void 0===r.sparse){const e=f_[r.type],t=h_[r.componentType],n=!0===r.normalized,i=new t(r.count*e);return Promise.resolve(new ps(i,e,n))}const i=[];return void 0!==r.bufferView?i.push(this.getDependency("bufferView",r.bufferView)):i.push(null),void 0!==r.sparse&&(i.push(this.getDependency("bufferView",r.sparse.indices.bufferView)),i.push(this.getDependency("bufferView",r.sparse.values.bufferView))),Promise.all(i).then((function(e){const i=e[0],s=f_[r.type],a=h_[r.componentType],o=a.BYTES_PER_ELEMENT,l=o*s,u=r.byteOffset||0,c=void 0!==r.bufferView?n.bufferViews[r.bufferView].byteStride:void 0,h=!0===r.normalized;let d,p;if(c&&c!==l){const e=Math.floor(u/c),n="InterleavedBuffer:"+r.bufferView+":"+r.componentType+":"+e+":"+r.count;let l=t.cache.get(n);l||(d=new a(i,e*c,r.count*c/o),l=new fu(d,c/o),t.cache.add(n,l)),p=new gu(l,s,u%c/o,h)}else d=null===i?new a(r.count*s):new a(i,u,r.count*s),p=new ps(d,s,h);if(void 0!==r.sparse){const t=f_.SCALAR,n=h_[r.sparse.indices.componentType],o=r.sparse.indices.byteOffset||0,l=r.sparse.values.byteOffset||0,u=new n(e[1],o,r.sparse.count*t),c=new a(e[2],l,r.sparse.count*s);null!==i&&(p=new ps(p.array.slice(),p.itemSize,p.normalized));for(let e=0,r=u.length;e<r;e++){const t=u[e];if(p.setX(t,c[e*s]),s>=2&&p.setY(t,c[e*s+1]),s>=3&&p.setZ(t,c[e*s+2]),s>=4&&p.setW(t,c[e*s+3]),s>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return p}))}loadTexture(e){const t=this.json,n=this.options,r=t.textures[e].source,i=t.images[r];let s=this.textureLoader;if(i.uri){const e=n.manager.getHandler(i.uri);null!==e&&(s=e)}return this.loadTextureImage(e,r,s)}loadTextureImage(e,t,n){const r=this,i=this.json,s=i.textures[e],a=i.images[t],o=(a.uri||a.bufferView)+":"+s.sampler;if(this.textureCache[o])return this.textureCache[o];const l=this.loadImageSource(t,n).then((function(t){t.flipY=!1,t.name=s.name||a.name||"",""===t.name&&"string"===typeof a.uri&&!1===a.uri.startsWith("data:image/")&&(t.name=a.uri);const n=(i.samplers||{})[s.sampler]||{};return t.magFilter=d_[n.magFilter]||we,t.minFilter=d_[n.minFilter]||Ce,t.wrapS=p_[n.wrapS]||ve,t.wrapT=p_[n.wrapT]||ve,r.associations.set(t,{textures:e}),t})).catch((function(){return null}));return this.textureCache[o]=l,l}loadImageSource(e,t){const n=this,r=this.json,i=this.options;if(void 0!==this.sourceCache[e])return this.sourceCache[e].then((e=>e.clone()));const s=r.images[e],a=self.URL||self.webkitURL;let o=s.uri||"",l=!1;if(void 0!==s.bufferView)o=n.getDependency("bufferView",s.bufferView).then((function(e){l=!0;const t=new Blob([e],{type:s.mimeType});return o=a.createObjectURL(t),o}));else if(void 0===s.uri)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const u=Promise.resolve(o).then((function(e){return new Promise((function(n,r){let s=n;!0===t.isImageBitmapLoader&&(s=function(e){const t=new Tr(e);t.needsUpdate=!0,n(t)}),t.load(Pp.resolveURL(e,i.path),s,void 0,r)}))})).then((function(e){var t;return!0===l&&a.revokeObjectURL(o),M_(e,s),e.userData.mimeType=s.mimeType||((t=s.uri).search(/\.jpe?g($|\?)/i)>0||0===t.search(/^data\:image\/jpeg/)?"image/jpeg":t.search(/\.webp($|\?)/i)>0||0===t.search(/^data\:image\/webp/)?"image/webp":"image/png"),e})).catch((function(e){throw console.error("THREE.GLTFLoader: Couldn't load texture",o),e}));return this.sourceCache[e]=u,u}assignTexture(e,t,n,r){const i=this;return this.getDependency("texture",n.index).then((function(s){if(!s)return null;if(void 0!==n.texCoord&&n.texCoord>0&&((s=s.clone()).channel=n.texCoord),i.extensions[Uy.KHR_TEXTURE_TRANSFORM]){const e=void 0!==n.extensions?n.extensions[Uy.KHR_TEXTURE_TRANSFORM]:void 0;if(e){const t=i.associations.get(s);s=i.extensions[Uy.KHR_TEXTURE_TRANSFORM].extendTexture(s,e),i.associations.set(s,t)}}return void 0!==r&&(s.colorSpace=r),e[t]=s,s}))}assignFinalMaterial(e){const t=e.geometry;let n=e.material;const r=void 0===t.attributes.tangent,i=void 0!==t.attributes.color,s=void 0===t.attributes.normal;if(e.isPoints){const e="PointsMaterial:"+n.uuid;let t=this.cache.get(e);t||(t=new kc,is.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){const e="LineBasicMaterial:"+n.uuid;let t=this.cache.get(e);t||(t=new wc,is.prototype.copy.call(t,n),t.color.copy(n.color),t.map=n.map,this.cache.add(e,t)),n=t}if(r||i||s){let e="ClonedMaterial:"+n.uuid+":";r&&(e+="derivative-tangents:"),i&&(e+="vertex-colors:"),s&&(e+="flat-shading:");let t=this.cache.get(e);t||(t=n.clone(),i&&(t.vertexColors=!0),s&&(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 bd}loadMaterial(e){const t=this,n=this.json,r=this.extensions,i=n.materials[e];let s;const a={},o=[];if((i.extensions||{})[Uy.KHR_MATERIALS_UNLIT]){const e=r[Uy.KHR_MATERIALS_UNLIT];s=e.getMaterialType(),o.push(e.extendParams(a,i,t))}else{const n=i.pbrMetallicRoughness||{};if(a.color=new ts(1,1,1),a.opacity=1,Array.isArray(n.baseColorFactor)){const e=n.baseColorFactor;a.color.setRGB(e[0],e[1],e[2],tn),a.opacity=e[3]}void 0!==n.baseColorTexture&&o.push(t.assignTexture(a,"map",n.baseColorTexture,en)),a.metalness=void 0!==n.metallicFactor?n.metallicFactor:1,a.roughness=void 0!==n.roughnessFactor?n.roughnessFactor:1,void 0!==n.metallicRoughnessTexture&&(o.push(t.assignTexture(a,"metalnessMap",n.metallicRoughnessTexture)),o.push(t.assignTexture(a,"roughnessMap",n.metallicRoughnessTexture))),s=this._invokeOne((function(t){return t.getMaterialType&&t.getMaterialType(e)})),o.push(Promise.all(this._invokeAll((function(t){return t.extendMaterialParams&&t.extendMaterialParams(e,a)}))))}!0===i.doubleSided&&(a.side=v);const l=i.alphaMode||y_;if(l===x_?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,l===__&&(a.alphaTest=void 0!==i.alphaCutoff?i.alphaCutoff:.5)),void 0!==i.normalTexture&&s!==ss&&(o.push(t.assignTexture(a,"normalMap",i.normalTexture)),a.normalScale=new ir(1,1),void 0!==i.normalTexture.scale)){const e=i.normalTexture.scale;a.normalScale.set(e,e)}if(void 0!==i.occlusionTexture&&s!==ss&&(o.push(t.assignTexture(a,"aoMap",i.occlusionTexture)),void 0!==i.occlusionTexture.strength&&(a.aoMapIntensity=i.occlusionTexture.strength)),void 0!==i.emissiveFactor&&s!==ss){const e=i.emissiveFactor;a.emissive=(new ts).setRGB(e[0],e[1],e[2],tn)}return void 0!==i.emissiveTexture&&s!==ss&&o.push(t.assignTexture(a,"emissiveMap",i.emissiveTexture,en)),Promise.all(o).then((function(){const n=new s(a);return i.name&&(n.name=i.name),M_(n,i),t.associations.set(n,{materials:e}),i.extensions&&A_(r,n,i),n}))}createUniqueName(e){const t=pf.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,n=this.extensions,r=this.primitiveCache;function i(e){return n[Uy.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e,t).then((function(n){return R_(n,e,t)}))}const s=[];for(let a=0,o=e.length;a<o;a++){const n=e[a],o=S_(n),l=r[o];if(l)s.push(l.promise);else{let e;e=n.extensions&&n.extensions[Uy.KHR_DRACO_MESH_COMPRESSION]?i(n):R_(new Ps,n,t),r[o]={primitive:n,promise:e},s.push(e)}}return Promise.all(s)}loadMesh(e){const t=this,n=this.json,r=this.extensions,i=n.meshes[e],s=i.primitives,a=[];for(let l=0,u=s.length;l<u;l++){const e=void 0===s[l].material?(void 0===(o=this.cache).DefaultMaterial&&(o.DefaultMaterial=new bd({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:m})),o.DefaultMaterial):this.getDependency("material",s[l].material);a.push(e)}var o;return a.push(t.loadGeometries(s)),Promise.all(a).then((function(n){const a=n.slice(0,n.length-1),o=n[n.length-1],l=[];for(let c=0,h=o.length;c<h;c++){const n=o[c],u=s[c];let h;const d=a[c];if(u.mode===c_.TRIANGLES||u.mode===c_.TRIANGLE_STRIP||u.mode===c_.TRIANGLE_FAN||void 0===u.mode)h=!0===i.isSkinnedMesh?new ju(n,d):new Ys(n,d),!0===h.isSkinnedMesh&&h.normalizeSkinWeights(),u.mode===c_.TRIANGLE_STRIP?h.geometry=By(h.geometry,jt):u.mode===c_.TRIANGLE_FAN&&(h.geometry=By(h.geometry,Xt));else if(u.mode===c_.LINES)h=new Fc(n,d);else if(u.mode===c_.LINE_STRIP)h=new Lc(n,d);else if(u.mode===c_.LINE_LOOP)h=new Oc(n,d);else{if(u.mode!==c_.POINTS)throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+u.mode);h=new Wc(n,d)}Object.keys(h.geometry.morphAttributes).length>0&&b_(h,i),h.name=t.createUniqueName(i.name||"mesh_"+e),M_(h,i),u.extensions&&A_(r,h,u),t.assignFinalMaterial(h),l.push(h)}for(let r=0,i=l.length;r<i;r++)t.associations.set(l[r],{meshes:e,primitives:r});if(1===l.length)return i.extensions&&A_(r,l[0],i),l[0];const u=new tu;i.extensions&&A_(r,u,i),t.associations.set(u,{meshes:e});for(let e=0,t=l.length;e<t;e++)u.add(l[e]);return u}))}loadCamera(e){let t;const n=this.json.cameras[e],r=n[n.type];if(r)return"perspective"===n.type?t=new aa(rr.radToDeg(r.yfov),r.aspectRatio||1,r.znear||1,r.zfar||2e6):"orthographic"===n.type&&(t=new La(-r.xmag,r.xmag,r.ymag,-r.ymag,r.znear,r.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),M_(t,n),Promise.resolve(t);console.warn("THREE.GLTFLoader: Missing camera parameters.")}loadSkin(e){const t=this.json.skins[e],n=[];for(let r=0,i=t.joints.length;r<i;r++)n.push(this._loadNodeShallow(t.joints[r]));return void 0!==t.inverseBindMatrices?n.push(this.getDependency("accessor",t.inverseBindMatrices)):n.push(null),Promise.all(n).then((function(e){const n=e.pop(),r=e,i=[],s=[];for(let a=0,o=r.length;a<o;a++){const e=r[a];if(e){i.push(e);const t=new di;null!==n&&t.fromArray(n.array,16*a),s.push(t)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[a])}return new qu(i,s)}))}loadAnimation(e){const t=this.json,n=this,r=t.animations[e],i=r.name?r.name:"animation_"+e,s=[],a=[],o=[],l=[],u=[];for(let c=0,h=r.channels.length;c<h;c++){const e=r.channels[c],t=r.samplers[e.sampler],n=e.target,i=n.node,h=void 0!==r.parameters?r.parameters[t.input]:t.input,d=void 0!==r.parameters?r.parameters[t.output]:t.output;void 0!==n.node&&(s.push(this.getDependency("node",i)),a.push(this.getDependency("accessor",h)),o.push(this.getDependency("accessor",d)),l.push(t),u.push(n))}return Promise.all([Promise.all(s),Promise.all(a),Promise.all(o),Promise.all(l),Promise.all(u)]).then((function(e){const t=e[0],r=e[1],s=e[2],a=e[3],o=e[4],l=[];for(let i=0,u=t.length;i<u;i++){const e=t[i],u=r[i],c=s[i],h=a[i],d=o[i];if(void 0===e)continue;e.updateMatrix&&e.updateMatrix();const p=n._createAnimationTracks(e,u,c,h,d);if(p)for(let t=0;t<p.length;t++)l.push(p[t])}return new Kd(i,void 0,l)}))}createNodeMesh(e){const t=this.json,n=this,r=t.nodes[e];return void 0===r.mesh?null:n.getDependency("mesh",r.mesh).then((function(e){const t=n._getNodeRef(n.meshCache,r.mesh,e);return void 0!==r.weights&&t.traverse((function(e){if(e.isMesh)for(let t=0,n=r.weights.length;t<n;t++)e.morphTargetInfluences[t]=r.weights[t]})),t}))}loadNode(e){const t=this,n=this.json.nodes[e],r=t._loadNodeShallow(e),i=[],s=n.children||[];for(let o=0,l=s.length;o<l;o++)i.push(t.getDependency("node",s[o]));const a=void 0===n.skin?Promise.resolve(null):t.getDependency("skin",n.skin);return Promise.all([r,Promise.all(i),a]).then((function(e){const t=e[0],n=e[1],r=e[2];null!==r&&t.traverse((function(e){e.isSkinnedMesh&&e.bind(r,T_)}));for(let i=0,s=n.length;i<s;i++)t.add(n[i]);return t}))}_loadNodeShallow(e){const t=this.json,n=this.extensions,r=this;if(void 0!==this.nodeCache[e])return this.nodeCache[e];const i=t.nodes[e],s=i.name?r.createUniqueName(i.name):"",a=[],o=r._invokeOne((function(t){return t.createNodeMesh&&t.createNodeMesh(e)}));return o&&a.push(o),void 0!==i.camera&&a.push(r.getDependency("camera",i.camera).then((function(e){return r._getNodeRef(r.cameraCache,i.camera,e)}))),r._invokeAll((function(t){return t.createNodeAttachment&&t.createNodeAttachment(e)})).forEach((function(e){a.push(e)})),this.nodeCache[e]=Promise.all(a).then((function(t){let a;if(a=!0===i.isBone?new Xu:t.length>1?new tu:1===t.length?t[0]:new ki,a!==t[0])for(let e=0,n=t.length;e<n;e++)a.add(t[e]);if(i.name&&(a.userData.name=i.name,a.name=s),M_(a,i),i.extensions&&A_(n,a,i),void 0!==i.matrix){const e=new di;e.fromArray(i.matrix),a.applyMatrix4(e)}else void 0!==i.translation&&a.position.fromArray(i.translation),void 0!==i.rotation&&a.quaternion.fromArray(i.rotation),void 0!==i.scale&&a.scale.fromArray(i.scale);return r.associations.has(a)||r.associations.set(a,{}),r.associations.get(a).nodes=e,a})),this.nodeCache[e]}loadScene(e){const t=this.extensions,n=this.json.scenes[e],r=this,i=new tu;n.name&&(i.name=r.createUniqueName(n.name)),M_(i,n),n.extensions&&A_(t,i,n);const s=n.nodes||[],a=[];for(let o=0,l=s.length;o<l;o++)a.push(r.getDependency("node",s[o]));return Promise.all(a).then((function(e){for(let t=0,n=e.length;t<n;t++)i.add(e[t]);return r.associations=(e=>{const t=new Map;for(const[n,i]of r.associations)(n instanceof is||n instanceof Tr)&&t.set(n,i);return e.traverse((e=>{const n=r.associations.get(e);null!=n&&t.set(e,n)})),t})(i),i}))}_createAnimationTracks(e,t,n,r,i){const s=[],a=e.name?e.name:e.uuid,o=[];let l;switch(g_[i.path]===g_.weights?e.traverse((function(e){e.morphTargetInfluences&&o.push(e.name?e.name:e.uuid)})):o.push(a),g_[i.path]){case g_.weights:l=Wd;break;case g_.rotation:l=Xd;break;case g_.position:case g_.scale:l=Yd;break;default:if(1===n.itemSize)l=Wd;else l=Yd}const u=void 0!==r.interpolation?v_[r.interpolation]:Ft,c=this._getArrayFromAccessor(n);for(let h=0,d=o.length;h<d;h++){const e=new l(o[h]+"."+g_[i.path],t.array,c,u);"CUBICSPLINE"===r.interpolation&&this._createCubicSplineTrackInterpolant(e),s.push(e)}return s}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const e=E_(t.constructor),n=new Float32Array(t.length);for(let r=0,i=t.length;r<i;r++)n[r]=t[r]*e;t=n}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(e){return new(this instanceof Xd?u_:o_)(this.times,this.values,this.getValueSize()/3,e)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function R_(e,t,n){const r=t.attributes,i=[];function s(t,r){return n.getDependency("accessor",t).then((function(t){e.setAttribute(r,t)}))}for(const a in r){const t=m_[a]||a.toLowerCase();t in e.attributes||i.push(s(r[a],t))}if(void 0!==t.indices&&!e.index){const r=n.getDependency("accessor",t.indices).then((function(t){e.setIndex(t)}));i.push(r)}return yr.workingColorSpace!==tn&&"COLOR_0"in r&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${yr.workingColorSpace}" not supported.`),M_(e,t),function(e,t,n){const r=t.attributes,i=new kr;if(void 0===r.POSITION)return;{const e=n.json.accessors[r.POSITION],t=e.min,s=e.max;if(void 0===t||void 0===s)return void console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");if(i.set(new Nr(t[0],t[1],t[2]),new Nr(s[0],s[1],s[2])),e.normalized){const t=E_(h_[e.componentType]);i.min.multiplyScalar(t),i.max.multiplyScalar(t)}}const s=t.targets;if(void 0!==s){const e=new Nr,t=new Nr;for(let r=0,i=s.length;r<i;r++){const i=s[r];if(void 0!==i.POSITION){const r=n.json.accessors[i.POSITION],s=r.min,a=r.max;if(void 0!==s&&void 0!==a){if(t.setX(Math.max(Math.abs(s[0]),Math.abs(a[0]))),t.setY(Math.max(Math.abs(s[1]),Math.abs(a[1]))),t.setZ(Math.max(Math.abs(s[2]),Math.abs(a[2]))),r.normalized){const e=E_(h_[r.componentType]);t.multiplyScalar(e)}e.max(t)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}i.expandByVector(e)}e.boundingBox=i;const a=new ri;i.getCenter(a.center),a.radius=i.min.distanceTo(i.max)/2,e.boundingSphere=a}(e,t,n),Promise.all(i).then((function(){return void 0!==t.targets?function(e,t,n){let r=!1,i=!1,s=!1;for(let u=0,c=t.length;u<c;u++){const e=t[u];if(void 0!==e.POSITION&&(r=!0),void 0!==e.NORMAL&&(i=!0),void 0!==e.COLOR_0&&(s=!0),r&&i&&s)break}if(!r&&!i&&!s)return Promise.resolve(e);const a=[],o=[],l=[];for(let u=0,c=t.length;u<c;u++){const c=t[u];if(r){const t=void 0!==c.POSITION?n.getDependency("accessor",c.POSITION):e.attributes.position;a.push(t)}if(i){const t=void 0!==c.NORMAL?n.getDependency("accessor",c.NORMAL):e.attributes.normal;o.push(t)}if(s){const t=void 0!==c.COLOR_0?n.getDependency("accessor",c.COLOR_0):e.attributes.color;l.push(t)}}return Promise.all([Promise.all(a),Promise.all(o),Promise.all(l)]).then((function(t){const n=t[0],a=t[1],o=t[2];return r&&(e.morphAttributes.position=n),i&&(e.morphAttributes.normal=a),s&&(e.morphAttributes.color=o),e.morphTargetsRelative=!0,e}))}(e,t.targets,n):e}))}var P_=(e,t,n)=>new Promise(((r,i)=>{var s=e=>{try{o(n.next(e))}catch(t){i(t)}},a=e=>{try{o(n.throw(e))}catch(t){i(t)}},o=e=>e.done?r(e.value):Promise.resolve(e.value).then(s,a);o((n=n.apply(e,t)).next())})),I_=(e,t,n)=>new Promise(((r,i)=>{var s=e=>{try{o(n.next(e))}catch(t){i(t)}},a=e=>{try{o(n.throw(e))}catch(t){i(t)}},o=e=>e.done?r(e.value):Promise.resolve(e.value).then(s,a);o((n=n.apply(e,t)).next())})),B_=class extends ki{constructor(e){super(),this.weight=0,this.isBinary=!1,this.overrideBlink="none",this.overrideLookAt="none",this.overrideMouth="none",this._binds=[],this.name=`VRMExpression_${e}`,this.expressionName=e,this.type="VRMExpression",this.visible=!1}get overrideBlinkAmount(){return"block"===this.overrideBlink?0<this.weight?1:0:"blend"===this.overrideBlink?this.weight:0}get overrideLookAtAmount(){return"block"===this.overrideLookAt?0<this.weight?1:0:"blend"===this.overrideLookAt?this.weight:0}get overrideMouthAmount(){return"block"===this.overrideMouth?0<this.weight?1:0:"blend"===this.overrideMouth?this.weight:0}addBind(e){this._binds.push(e)}applyWeight(e){var t;let n=this.isBinary?this.weight<=.5?0:1:this.weight;n*=null!=(t=null==e?void 0:e.multiplier)?t:1,this._binds.forEach((e=>e.applyWeight(n)))}clearAppliedWeight(){this._binds.forEach((e=>e.clearAppliedWeight()))}};function L_(e,t,n){var r,i;const s=e.parser.json,a=null==(r=s.nodes)?void 0:r[t];if(null==a)return console.warn(`extractPrimitivesInternal: Attempt to use nodes[${t}] of glTF but the node doesn't exist`),null;const o=a.mesh;if(null==o)return null;const l=null==(i=s.meshes)?void 0:i[o];if(null==l)return console.warn(`extractPrimitivesInternal: Attempt to use meshes[${o}] of glTF but the mesh doesn't exist`),null;const u=l.primitives.length,c=[];return n.traverse((e=>{c.length<u&&e.isMesh&&c.push(e)})),c}function D_(e,t){return I_(this,null,(function*(){const n=yield e.parser.getDependency("node",t);return L_(e,t,n)}))}function U_(e){return I_(this,null,(function*(){const t=yield e.parser.getDependencies("node"),n=new Map;return t.forEach(((t,r)=>{const i=L_(e,r,t);null!=i&&n.set(r,i)})),n}))}var N_={Aa:"aa",Ih:"ih",Ou:"ou",Ee:"ee",Oh:"oh",Blink:"blink",Happy:"happy",Angry:"angry",Sad:"sad",Relaxed:"relaxed",LookUp:"lookUp",Surprised:"surprised",LookDown:"lookDown",LookLeft:"lookLeft",LookRight:"lookRight",BlinkLeft:"blinkLeft",BlinkRight:"blinkRight",Neutral:"neutral"};function F_(e){return Math.max(Math.min(e,1),0)}var O_=class e{constructor(){this.blinkExpressionNames=["blink","blinkLeft","blinkRight"],this.lookAtExpressionNames=["lookLeft","lookRight","lookUp","lookDown"],this.mouthExpressionNames=["aa","ee","ih","oh","ou"],this._expressions=[],this._expressionMap={}}get expressions(){return this._expressions.concat()}get expressionMap(){return Object.assign({},this._expressionMap)}get presetExpressionMap(){const e={},t=new Set(Object.values(N_));return Object.entries(this._expressionMap).forEach((n=>{let[r,i]=n;t.has(r)&&(e[r]=i)})),e}get customExpressionMap(){const e={},t=new Set(Object.values(N_));return Object.entries(this._expressionMap).forEach((n=>{let[r,i]=n;t.has(r)||(e[r]=i)})),e}copy(e){return this._expressions.concat().forEach((e=>{this.unregisterExpression(e)})),e._expressions.forEach((e=>{this.registerExpression(e)})),this.blinkExpressionNames=e.blinkExpressionNames.concat(),this.lookAtExpressionNames=e.lookAtExpressionNames.concat(),this.mouthExpressionNames=e.mouthExpressionNames.concat(),this}clone(){return(new e).copy(this)}getExpression(e){var t;return null!=(t=this._expressionMap[e])?t:null}registerExpression(e){this._expressions.push(e),this._expressionMap[e.expressionName]=e}unregisterExpression(e){const t=this._expressions.indexOf(e);-1===t&&console.warn("VRMExpressionManager: The specified expressions is not registered"),this._expressions.splice(t,1),delete this._expressionMap[e.expressionName]}getValue(e){var t;const n=this.getExpression(e);return null!=(t=null==n?void 0:n.weight)?t:null}setValue(e,t){const n=this.getExpression(e);n&&(n.weight=F_(t))}resetValues(){this._expressions.forEach((e=>{e.weight=0}))}getExpressionTrackName(e){const t=this.getExpression(e);return t?`${t.name}.weight`:null}update(){const e=this._calculateWeightMultipliers();this._expressions.forEach((e=>{e.clearAppliedWeight()})),this._expressions.forEach((t=>{let n=1;const r=t.expressionName;-1!==this.blinkExpressionNames.indexOf(r)&&(n*=e.blink),-1!==this.lookAtExpressionNames.indexOf(r)&&(n*=e.lookAt),-1!==this.mouthExpressionNames.indexOf(r)&&(n*=e.mouth),t.applyWeight({multiplier:n})}))}_calculateWeightMultipliers(){let e=1,t=1,n=1;return this._expressions.forEach((r=>{e-=r.overrideBlinkAmount,t-=r.overrideLookAtAmount,n-=r.overrideMouthAmount})),e=Math.max(0,e),t=Math.max(0,t),n=Math.max(0,n),{blink:e,lookAt:t,mouth:n}}},k_={_Color:"color",_EmissionColor:"emissionColor",_ShadeColor:"shadeColor",_RimColor:"rimColor",_OutlineColor:"outlineColor"},H_=new ts,z_=class e{constructor(e){let{material:t,type:n,targetValue:r,targetAlpha:i}=e;this.material=t,this.type=n,this.targetValue=r,this.targetAlpha=null!=i?i:1;const s=this._initColorBindState(),a=this._initAlphaBindState();this._state={color:s,alpha:a}}applyWeight(e){const{color:t,alpha:n}=this._state;if(null!=t){const{propertyName:n,deltaValue:r}=t,i=this.material[n];void 0!=i&&i.add(H_.copy(r).multiplyScalar(e))}if(null!=n){const{propertyName:t,deltaValue:r}=n;void 0!=this.material[t]&&(this.material[t]+=r*e)}}clearAppliedWeight(){const{color:e,alpha:t}=this._state;if(null!=e){const{propertyName:t,initialValue:n}=e,r=this.material[t];void 0!=r&&r.copy(n)}if(null!=t){const{propertyName:e,initialValue:n}=t;void 0!=this.material[e]&&(this.material[e]=n)}}_initColorBindState(){var e,t,n;const{material:r,type:i,targetValue:s}=this,a=this._getPropertyNameMap(),o=null!=(t=null==(e=null==a?void 0:a[i])?void 0:e[0])?t:null;if(null==o)return console.warn(`Tried to add a material color bind to the material ${null!=(n=r.name)?n:"(no name)"}, the type ${i} but the material or the type is not supported.`),null;const l=r[o].clone();return{propertyName:o,initialValue:l,deltaValue:new ts(s.r-l.r,s.g-l.g,s.b-l.b)}}_initAlphaBindState(){var e,t,n;const{material:r,type:i,targetAlpha:s}=this,a=this._getPropertyNameMap(),o=null!=(t=null==(e=null==a?void 0:a[i])?void 0:e[1])?t:null;if(null==o&&1!==s)return console.warn(`Tried to add a material alpha bind to the material ${null!=(n=r.name)?n:"(no name)"}, the type ${i} but the material or the type does not support alpha.`),null;if(null==o)return null;const l=r[o];return{propertyName:o,initialValue:l,deltaValue:s-l}}_getPropertyNameMap(){var t,n;return null!=(n=null==(t=Object.entries(e._propertyNameMapMap).find((e=>{let[t]=e;return!0===this.material[t]})))?void 0:t[1])?n:null}};z_._propertyNameMapMap={isMeshStandardMaterial:{color:["color","opacity"],emissionColor:["emissive",null]},isMeshBasicMaterial:{color:["color","opacity"]},isMToonMaterial:{color:["color","opacity"],emissionColor:["emissive",null],outlineColor:["outlineColorFactor",null],matcapColor:["matcapFactor",null],rimColor:["parametricRimColorFactor",null],shadeColor:["shadeColorFactor",null]}};var G_=z_,V_=class{constructor(e){let{primitives:t,index:n,weight:r}=e;this.primitives=t,this.index=n,this.weight=r}applyWeight(e){this.primitives.forEach((t=>{var n;null!=(null==(n=t.morphTargetInfluences)?void 0:n[this.index])&&(t.morphTargetInfluences[this.index]+=this.weight*e)}))}clearAppliedWeight(){this.primitives.forEach((e=>{var t;null!=(null==(t=e.morphTargetInfluences)?void 0:t[this.index])&&(e.morphTargetInfluences[this.index]=0)}))}},W_=new ir,j_=class e{constructor(t){let{material:n,scale:r,offset:i}=t;var s,a;this.material=n,this.scale=r,this.offset=i;const o=null==(s=Object.entries(e._propertyNamesMap).find((e=>{let[t]=e;return!0===n[t]})))?void 0:s[1];null==o?(console.warn(`Tried to add a texture transform bind to the material ${null!=(a=n.name)?a:"(no name)"} but the material is not supported.`),this._properties=[]):(this._properties=[],o.forEach((e=>{var t;const s=null==(t=n[e])?void 0:t.clone();if(!s)return null;n[e]=s;const a=s.offset.clone(),o=s.repeat.clone(),l=i.clone().sub(a),u=r.clone().sub(o);this._properties.push({name:e,initialOffset:a,deltaOffset:l,initialScale:o,deltaScale:u})})))}applyWeight(e){this._properties.forEach((t=>{const n=this.material[t.name];void 0!==n&&(n.offset.add(W_.copy(t.deltaOffset).multiplyScalar(e)),n.repeat.add(W_.copy(t.deltaScale).multiplyScalar(e)))}))}clearAppliedWeight(){this._properties.forEach((e=>{const t=this.material[e.name];void 0!==t&&(t.offset.copy(e.initialOffset),t.repeat.copy(e.initialScale))}))}};j_._propertyNamesMap={isMeshStandardMaterial:["map","emissiveMap","bumpMap","normalMap","displacementMap","roughnessMap","metalnessMap","alphaMap"],isMeshBasicMaterial:["map","specularMap","alphaMap"],isMToonMaterial:["map","normalMap","emissiveMap","shadeMultiplyTexture","rimMultiplyTexture","outlineWidthMultiplyTexture","uvAnimationMaskTexture"]};var X_=j_,J_=new Set(["1.0","1.0-beta"]),Y_=class e{get name(){return"VRMExpressionLoaderPlugin"}constructor(e){this.parser=e}afterRoot(e){return I_(this,null,(function*(){e.userData.vrmExpressionManager=yield this._import(e)}))}_import(e){return I_(this,null,(function*(){const t=yield this._v1Import(e);if(t)return t;const n=yield this._v0Import(e);return n||null}))}_v1Import(e){return I_(this,null,(function*(){var t,n;const r=this.parser.json;if(!(-1!==(null==(t=r.extensionsUsed)?void 0:t.indexOf("VRMC_vrm"))))return null;const i=null==(n=r.extensions)?void 0:n.VRMC_vrm;if(!i)return null;const s=i.specVersion;if(!J_.has(s))return console.warn(`VRMExpressionLoaderPlugin: Unknown VRMC_vrm specVersion "${s}"`),null;const a=i.expressions;if(!a)return null;const o=new Set(Object.values(N_)),l=new Map;null!=a.preset&&Object.entries(a.preset).forEach((e=>{let[t,n]=e;null!=n&&(o.has(t)?l.set(t,n):console.warn(`VRMExpressionLoaderPlugin: Unknown preset name "${t}" detected. Ignoring the expression`))})),null!=a.custom&&Object.entries(a.custom).forEach((e=>{let[t,n]=e;o.has(t)?console.warn(`VRMExpressionLoaderPlugin: Custom expression cannot have preset name "${t}". Ignoring the expression`):l.set(t,n)}));const u=new O_;return yield Promise.all(Array.from(l.entries()).map((t=>I_(this,[t],(function(t){var n=this;let[r,i]=t;return function*(){var t,s,a,o,l,c,h;const d=new B_(r);if(e.scene.add(d),d.isBinary=null!=(t=i.isBinary)&&t,d.overrideBlink=null!=(s=i.overrideBlink)?s:"none",d.overrideLookAt=null!=(a=i.overrideLookAt)?a:"none",d.overrideMouth=null!=(o=i.overrideMouth)?o:"none",null==(l=i.morphTargetBinds)||l.forEach((t=>I_(n,null,(function*(){var n;if(void 0===t.node||void 0===t.index)return;const r=yield D_(e,t.node),s=t.index;r.every((e=>Array.isArray(e.morphTargetInfluences)&&s<e.morphTargetInfluences.length))?d.addBind(new V_({primitives:r,index:s,weight:null!=(n=t.weight)?n:1})):console.warn(`VRMExpressionLoaderPlugin: ${i.name} attempts to index morph #${s} but not found.`)})))),i.materialColorBinds||i.textureTransformBinds){const t=[];e.scene.traverse((e=>{const n=e.material;n&&t.push(n)})),null==(c=i.materialColorBinds)||c.forEach((e=>I_(n,null,(function*(){t.filter((t=>{var n;const r=null==(n=this.parser.associations.get(t))?void 0:n.materials;return e.material===r})).forEach((t=>{d.addBind(new G_({material:t,type:e.type,targetValue:(new ts).fromArray(e.targetValue),targetAlpha:e.targetValue[3]}))}))})))),null==(h=i.textureTransformBinds)||h.forEach((e=>I_(n,null,(function*(){t.filter((t=>{var n;const r=null==(n=this.parser.associations.get(t))?void 0:n.materials;return e.material===r})).forEach((t=>{var n,r;d.addBind(new X_({material:t,offset:(new ir).fromArray(null!=(n=e.offset)?n:[0,0]),scale:(new ir).fromArray(null!=(r=e.scale)?r:[1,1])}))}))}))))}u.registerExpression(d)}()}))))),u}))}_v0Import(t){return I_(this,null,(function*(){var n;const r=this.parser.json,i=null==(n=r.extensions)?void 0:n.VRM;if(!i)return null;const s=i.blendShapeMaster;if(!s)return null;const a=new O_,o=s.blendShapeGroups;if(!o)return a;const l=new Set;return yield Promise.all(o.map((n=>I_(this,null,(function*(){var i;const s=n.presetName,o=null!=s&&e.v0v1PresetNameMap[s]||null,u=null!=o?o:n.name;if(null==u)return void console.warn("VRMExpressionLoaderPlugin: One of custom expressions has no name. Ignoring the expression");if(l.has(u))return void console.warn(`VRMExpressionLoaderPlugin: An expression preset ${s} has duplicated entries. Ignoring the expression`);l.add(u);const c=new B_(u);t.scene.add(c),c.isBinary=null!=(i=n.isBinary)&&i,n.binds&&n.binds.forEach((e=>I_(this,null,(function*(){var i;if(void 0===e.mesh||void 0===e.index)return;const s=[];null==(i=r.nodes)||i.forEach(((t,n)=>{t.mesh===e.mesh&&s.push(n)}));const a=e.index;yield Promise.all(s.map((r=>I_(this,null,(function*(){var i;const s=yield D_(t,r);s.every((e=>Array.isArray(e.morphTargetInfluences)&&a<e.morphTargetInfluences.length))?c.addBind(new V_({primitives:s,index:a,weight:.01*(null!=(i=e.weight)?i:100)})):console.warn(`VRMExpressionLoaderPlugin: ${n.name} attempts to index ${a}th morph but not found.`)})))))}))));const h=n.materialValues;h&&0!==h.length&&h.forEach((e=>{if(void 0===e.materialName||void 0===e.propertyName||void 0===e.targetValue)return;const n=[];t.scene.traverse((t=>{if(t.material){const r=t.material;Array.isArray(r)?n.push(...r.filter((t=>(t.name===e.materialName||t.name===e.materialName+" (Outline)")&&-1===n.indexOf(t)))):r.name===e.materialName&&-1===n.indexOf(r)&&n.push(r)}}));const r=e.propertyName;n.forEach((t=>{if("_MainTex_ST"===r){const n=new ir(e.targetValue[0],e.targetValue[1]),r=new ir(e.targetValue[2],e.targetValue[3]);return r.y=1-r.y-n.y,void c.addBind(new X_({material:t,scale:n,offset:r}))}const n=k_[r];n?c.addBind(new G_({material:t,type:n,targetValue:(new ts).fromArray(e.targetValue),targetAlpha:e.targetValue[3]})):console.warn(r+" is not supported")}))})),a.registerExpression(c)}))))),a}))}};Y_.v0v1PresetNameMap={a:"aa",e:"ee",i:"ih",o:"oh",u:"ou",blink:"blink",joy:"happy",angry:"angry",sorrow:"sad",fun:"relaxed",lookup:"lookUp",lookdown:"lookDown",lookleft:"lookLeft",lookright:"lookRight",blink_l:"blinkLeft",blink_r:"blinkRight",neutral:"neutral"};var K_=Y_,q_=class e{constructor(t,n){this._firstPersonOnlyLayer=e.DEFAULT_FIRSTPERSON_ONLY_LAYER,this._thirdPersonOnlyLayer=e.DEFAULT_THIRDPERSON_ONLY_LAYER,this._initializedLayers=!1,this.humanoid=t,this.meshAnnotations=n}copy(e){if(this.humanoid!==e.humanoid)throw new Error("VRMFirstPerson: humanoid must be same in order to copy");return this.meshAnnotations=e.meshAnnotations.map((e=>({meshes:e.meshes.concat(),type:e.type}))),this}clone(){return new e(this.humanoid,this.meshAnnotations).copy(this)}get firstPersonOnlyLayer(){return this._firstPersonOnlyLayer}get thirdPersonOnlyLayer(){return this._thirdPersonOnlyLayer}setup(){let{firstPersonOnlyLayer:t=e.DEFAULT_FIRSTPERSON_ONLY_LAYER,thirdPersonOnlyLayer:n=e.DEFAULT_THIRDPERSON_ONLY_LAYER}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this._initializedLayers||(this._firstPersonOnlyLayer=t,this._thirdPersonOnlyLayer=n,this.meshAnnotations.forEach((e=>{e.meshes.forEach((t=>{"firstPersonOnly"===e.type?(t.layers.set(this._firstPersonOnlyLayer),t.traverse((e=>e.layers.set(this._firstPersonOnlyLayer)))):"thirdPersonOnly"===e.type?(t.layers.set(this._thirdPersonOnlyLayer),t.traverse((e=>e.layers.set(this._thirdPersonOnlyLayer)))):"auto"===e.type&&this._createHeadlessModel(t)}))})),this._initializedLayers=!0)}_excludeTriangles(e,t,n,r){let i=0;if(null!=t&&t.length>0)for(let s=0;s<e.length;s+=3){const a=e[s],o=e[s+1],l=e[s+2],u=t[a],c=n[a];if(u[0]>0&&r.includes(c[0]))continue;if(u[1]>0&&r.includes(c[1]))continue;if(u[2]>0&&r.includes(c[2]))continue;if(u[3]>0&&r.includes(c[3]))continue;const h=t[o],d=n[o];if(h[0]>0&&r.includes(d[0]))continue;if(h[1]>0&&r.includes(d[1]))continue;if(h[2]>0&&r.includes(d[2]))continue;if(h[3]>0&&r.includes(d[3]))continue;const p=t[l],f=n[l];p[0]>0&&r.includes(f[0])||(p[1]>0&&r.includes(f[1])||p[2]>0&&r.includes(f[2])||p[3]>0&&r.includes(f[3])||(e[i++]=a,e[i++]=o,e[i++]=l))}return i}_createErasedMesh(e,t){const n=new ju(e.geometry.clone(),e.material);n.name=`${e.name}(erase)`,n.frustumCulled=e.frustumCulled,n.layers.set(this._firstPersonOnlyLayer);const r=n.geometry,i=r.getAttribute("skinIndex"),s=i instanceof Mf?[]:i.array,a=[];for(let f=0;f<s.length;f+=4)a.push([s[f],s[f+1],s[f+2],s[f+3]]);const o=r.getAttribute("skinWeight"),l=o instanceof Mf?[]:o.array,u=[];for(let f=0;f<l.length;f+=4)u.push([l[f],l[f+1],l[f+2],l[f+3]]);const c=r.getIndex();if(!c)throw new Error("The geometry doesn't have an index buffer");const h=Array.from(c.array),d=this._excludeTriangles(h,u,a,t),p=[];for(let f=0;f<d;f++)p[f]=h[f];return r.setIndex(p),e.onBeforeRender&&(n.onBeforeRender=e.onBeforeRender),n.bind(new qu(e.skeleton.bones,e.skeleton.boneInverses),new di),n}_createHeadlessModelForSkinnedMesh(e,t){const n=[];if(t.skeleton.bones.forEach(((e,t)=>{this._isEraseTarget(e)&&n.push(t)})),!n.length)return t.layers.enable(this._thirdPersonOnlyLayer),void t.layers.enable(this._firstPersonOnlyLayer);t.layers.set(this._thirdPersonOnlyLayer);const r=this._createErasedMesh(t,n);e.add(r)}_createHeadlessModel(e){if("Group"===e.type)if(e.layers.set(this._thirdPersonOnlyLayer),this._isEraseTarget(e))e.traverse((e=>e.layers.set(this._thirdPersonOnlyLayer)));else{const t=new tu;t.name=`_headless_${e.name}`,t.layers.set(this._firstPersonOnlyLayer),e.parent.add(t),e.children.filter((e=>"SkinnedMesh"===e.type)).forEach((e=>{const n=e;this._createHeadlessModelForSkinnedMesh(t,n)}))}else if("SkinnedMesh"===e.type){const t=e;this._createHeadlessModelForSkinnedMesh(e.parent,t)}else this._isEraseTarget(e)&&(e.layers.set(this._thirdPersonOnlyLayer),e.traverse((e=>e.layers.set(this._thirdPersonOnlyLayer))))}_isEraseTarget(e){return e===this.humanoid.getRawBoneNode("head")||!!e.parent&&this._isEraseTarget(e.parent)}};q_.DEFAULT_FIRSTPERSON_ONLY_LAYER=9,q_.DEFAULT_THIRDPERSON_ONLY_LAYER=10;var Q_=q_,Z_=new Set(["1.0","1.0-beta"]),$_=class{get name(){return"VRMFirstPersonLoaderPlugin"}constructor(e){this.parser=e}afterRoot(e){return I_(this,null,(function*(){const t=e.userData.vrmHumanoid;if(null!==t){if(void 0===t)throw new Error("VRMFirstPersonLoaderPlugin: vrmHumanoid is undefined. VRMHumanoidLoaderPlugin have to be used first");e.userData.vrmFirstPerson=yield this._import(e,t)}}))}_import(e,t){return I_(this,null,(function*(){if(null==t)return null;const n=yield this._v1Import(e,t);if(n)return n;const r=yield this._v0Import(e,t);return r||null}))}_v1Import(e,t){return I_(this,null,(function*(){var n,r;const i=this.parser.json;if(!(-1!==(null==(n=i.extensionsUsed)?void 0:n.indexOf("VRMC_vrm"))))return null;const s=null==(r=i.extensions)?void 0:r.VRMC_vrm;if(!s)return null;const a=s.specVersion;if(!Z_.has(a))return console.warn(`VRMFirstPersonLoaderPlugin: Unknown VRMC_vrm specVersion "${a}"`),null;const o=s.firstPerson;if(!o)return null;const l=[],u=yield U_(e);return Array.from(u.entries()).forEach((e=>{let[t,n]=e;var r;const i=o.meshAnnotations?o.meshAnnotations.find((e=>e.node===t)):void 0;l.push({meshes:n,type:null!=(r=null==i?void 0:i.type)?r:"both"})})),new Q_(t,l)}))}_v0Import(e,t){return I_(this,null,(function*(){var n;const r=this.parser.json,i=null==(n=r.extensions)?void 0:n.VRM;if(!i)return null;const s=i.firstPerson;if(!s)return null;const a=[],o=yield U_(e);return Array.from(o.entries()).forEach((e=>{let[t,n]=e;const i=r.nodes[t],o=s.meshAnnotations?s.meshAnnotations.find((e=>e.mesh===i.mesh)):void 0;a.push({meshes:n,type:this._convertV0FlagToV1Type(null==o?void 0:o.firstPersonFlag)})})),new Q_(t,a)}))}_convertV0FlagToV1Type(e){return"FirstPersonOnly"===e?"firstPersonOnly":"ThirdPersonOnly"===e?"thirdPersonOnly":"Auto"===e?"auto":"both"}},ex=new Nr,tx=new Nr,nx=new Ur,rx=class extends tu{constructor(e){super(),this.vrmHumanoid=e,this._boneAxesMap=new Map,Object.values(e.humanBones).forEach((e=>{const t=new hm(1);t.matrixAutoUpdate=!1,t.material.depthTest=!1,t.material.depthWrite=!1,this.add(t),this._boneAxesMap.set(e,t)}))}dispose(){Array.from(this._boneAxesMap.values()).forEach((e=>{e.geometry.dispose(),e.material.dispose()}))}updateMatrixWorld(e){Array.from(this._boneAxesMap.entries()).forEach((e=>{let[t,n]=e;t.node.updateWorldMatrix(!0,!1),t.node.matrixWorld.decompose(ex,nx,tx);const r=ex.set(.1,.1,.1).divide(tx);n.matrix.copy(t.node.matrixWorld).scale(r)})),super.updateMatrixWorld(e)}},ix=["hips","spine","chest","upperChest","neck","head","leftEye","rightEye","jaw","leftUpperLeg","leftLowerLeg","leftFoot","leftToes","rightUpperLeg","rightLowerLeg","rightFoot","rightToes","leftShoulder","leftUpperArm","leftLowerArm","leftHand","rightShoulder","rightUpperArm","rightLowerArm","rightHand","leftThumbMetacarpal","leftThumbProximal","leftThumbDistal","leftIndexProximal","leftIndexIntermediate","leftIndexDistal","leftMiddleProximal","leftMiddleIntermediate","leftMiddleDistal","leftRingProximal","leftRingIntermediate","leftRingDistal","leftLittleProximal","leftLittleIntermediate","leftLittleDistal","rightThumbMetacarpal","rightThumbProximal","rightThumbDistal","rightIndexProximal","rightIndexIntermediate","rightIndexDistal","rightMiddleProximal","rightMiddleIntermediate","rightMiddleDistal","rightRingProximal","rightRingIntermediate","rightRingDistal","rightLittleProximal","rightLittleIntermediate","rightLittleDistal"],sx={hips:null,spine:"hips",chest:"spine",upperChest:"chest",neck:"upperChest",head:"neck",leftEye:"head",rightEye:"head",jaw:"head",leftUpperLeg:"hips",leftLowerLeg:"leftUpperLeg",leftFoot:"leftLowerLeg",leftToes:"leftFoot",rightUpperLeg:"hips",rightLowerLeg:"rightUpperLeg",rightFoot:"rightLowerLeg",rightToes:"rightFoot",leftShoulder:"upperChest",leftUpperArm:"leftShoulder",leftLowerArm:"leftUpperArm",leftHand:"leftLowerArm",rightShoulder:"upperChest",rightUpperArm:"rightShoulder",rightLowerArm:"rightUpperArm",rightHand:"rightLowerArm",leftThumbMetacarpal:"leftHand",leftThumbProximal:"leftThumbMetacarpal",leftThumbDistal:"leftThumbProximal",leftIndexProximal:"leftHand",leftIndexIntermediate:"leftIndexProximal",leftIndexDistal:"leftIndexIntermediate",leftMiddleProximal:"leftHand",leftMiddleIntermediate:"leftMiddleProximal",leftMiddleDistal:"leftMiddleIntermediate",leftRingProximal:"leftHand",leftRingIntermediate:"leftRingProximal",leftRingDistal:"leftRingIntermediate",leftLittleProximal:"leftHand",leftLittleIntermediate:"leftLittleProximal",leftLittleDistal:"leftLittleIntermediate",rightThumbMetacarpal:"rightHand",rightThumbProximal:"rightThumbMetacarpal",rightThumbDistal:"rightThumbProximal",rightIndexProximal:"rightHand",rightIndexIntermediate:"rightIndexProximal",rightIndexDistal:"rightIndexIntermediate",rightMiddleProximal:"rightHand",rightMiddleIntermediate:"rightMiddleProximal",rightMiddleDistal:"rightMiddleIntermediate",rightRingProximal:"rightHand",rightRingIntermediate:"rightRingProximal",rightRingDistal:"rightRingIntermediate",rightLittleProximal:"rightHand",rightLittleIntermediate:"rightLittleProximal",rightLittleDistal:"rightLittleIntermediate"};function ax(e){return e.invert?e.invert():e.inverse(),e}var ox=new Nr,lx=new Ur,ux=class{constructor(e){this.humanBones=e,this.restPose=this.getAbsolutePose()}getAbsolutePose(){const e={};return Object.keys(this.humanBones).forEach((t=>{const n=t,r=this.getBoneNode(n);r&&(ox.copy(r.position),lx.copy(r.quaternion),e[n]={position:ox.toArray(),rotation:lx.toArray()})})),e}getPose(){const e={};return Object.keys(this.humanBones).forEach((t=>{const n=t,r=this.getBoneNode(n);if(!r)return;ox.set(0,0,0),lx.identity();const i=this.restPose[n];(null==i?void 0:i.position)&&ox.fromArray(i.position).negate(),(null==i?void 0:i.rotation)&&ax(lx.fromArray(i.rotation)),ox.add(r.position),lx.premultiply(r.quaternion),e[n]={position:ox.toArray(),rotation:lx.toArray()}})),e}setPose(e){Object.entries(e).forEach((e=>{let[t,n]=e;const r=t,i=this.getBoneNode(r);if(!i)return;const s=this.restPose[r];s&&((null==n?void 0:n.position)&&(i.position.fromArray(n.position),s.position&&i.position.add(ox.fromArray(s.position))),(null==n?void 0:n.rotation)&&(i.quaternion.fromArray(n.rotation),s.rotation&&i.quaternion.multiply(lx.fromArray(s.rotation))))}))}resetPose(){Object.entries(this.restPose).forEach((e=>{let[t,n]=e;const r=this.getBoneNode(t);r&&((null==n?void 0:n.position)&&r.position.fromArray(n.position),(null==n?void 0:n.rotation)&&r.quaternion.fromArray(n.rotation))}))}getBone(e){var t;return null!=(t=this.humanBones[e])?t:void 0}getBoneNode(e){var t,n;return null!=(n=null==(t=this.humanBones[e])?void 0:t.node)?n:null}},cx=new Nr,hx=new Ur,dx=new Nr,px=class e extends ux{static _setupTransforms(e){const t=new ki;t.name="VRMHumanoidRig";const n={},r={},i={},s={};ix.forEach((t=>{var a;const o=e.getBoneNode(t);if(o){const e=new Nr,l=new Ur;o.updateWorldMatrix(!0,!1),o.matrixWorld.decompose(e,l,cx),n[t]=e,r[t]=l,i[t]=o.quaternion.clone();const u=new Ur;null==(a=o.parent)||a.matrixWorld.decompose(cx,u,cx),s[t]=u}}));const a={};return ix.forEach((r=>{var i;const s=e.getBoneNode(r);if(s){const e=n[r];let o,l=r;for(;null==o&&(l=sx[l],null!=l);)o=n[l];const u=new ki;u.name="Normalized_"+s.name;(l?null==(i=a[l])?void 0:i.node:t).add(u),u.position.copy(e),o&&u.position.sub(o),a[r]={node:u}}})),{rigBones:a,root:t,parentWorldRotations:s,boneRotations:i}}constructor(t){const{rigBones:n,root:r,parentWorldRotations:i,boneRotations:s}=e._setupTransforms(t);super(n),this.original=t,this.root=r,this._parentWorldRotations=i,this._boneRotations=s}update(){ix.forEach((e=>{const t=this.original.getBoneNode(e);if(null!=t){const n=this.getBoneNode(e),r=this._parentWorldRotations[e],i=hx.copy(r).invert(),s=this._boneRotations[e];if(t.quaternion.copy(n.quaternion).multiply(r).premultiply(i).multiply(s),"hips"===e){const e=n.getWorldPosition(dx);t.parent.updateWorldMatrix(!0,!1);const r=t.parent.matrixWorld,i=e.applyMatrix4(r.invert());t.position.copy(i)}}}))}},fx=class e{get restPose(){return console.warn("VRMHumanoid: restPose is deprecated. Use either rawRestPose or normalizedRestPose instead."),this.rawRestPose}get rawRestPose(){return this._rawHumanBones.restPose}get normalizedRestPose(){return this._normalizedHumanBones.restPose}get humanBones(){return this._rawHumanBones.humanBones}get rawHumanBones(){return this._rawHumanBones.humanBones}get normalizedHumanBones(){return this._normalizedHumanBones.humanBones}get normalizedHumanBonesRoot(){return this._normalizedHumanBones.root}constructor(e,t){var n;this.autoUpdateHumanBones=null==(n=null==t?void 0:t.autoUpdateHumanBones)||n,this._rawHumanBones=new ux(e),this._normalizedHumanBones=new px(this._rawHumanBones)}copy(e){return this.autoUpdateHumanBones=e.autoUpdateHumanBones,this._rawHumanBones=new ux(e.humanBones),this._normalizedHumanBones=new px(this._rawHumanBones),this}clone(){return new e(this.humanBones,{autoUpdateHumanBones:this.autoUpdateHumanBones}).copy(this)}getAbsolutePose(){return console.warn("VRMHumanoid: getAbsolutePose() is deprecated. Use either getRawAbsolutePose() or getNormalizedAbsolutePose() instead."),this.getRawAbsolutePose()}getRawAbsolutePose(){return this._rawHumanBones.getAbsolutePose()}getNormalizedAbsolutePose(){return this._normalizedHumanBones.getAbsolutePose()}getPose(){return console.warn("VRMHumanoid: getPose() is deprecated. Use either getRawPose() or getNormalizedPose() instead."),this.getRawPose()}getRawPose(){return this._rawHumanBones.getPose()}getNormalizedPose(){return this._normalizedHumanBones.getPose()}setPose(e){return console.warn("VRMHumanoid: setPose() is deprecated. Use either setRawPose() or setNormalizedPose() instead."),this.setRawPose(e)}setRawPose(e){return this._rawHumanBones.setPose(e)}setNormalizedPose(e){return this._normalizedHumanBones.setPose(e)}resetPose(){return console.warn("VRMHumanoid: resetPose() is deprecated. Use either resetRawPose() or resetNormalizedPose() instead."),this.resetRawPose()}resetRawPose(){return this._rawHumanBones.resetPose()}resetNormalizedPose(){return this._normalizedHumanBones.resetPose()}getBone(e){return console.warn("VRMHumanoid: getBone() is deprecated. Use either getRawBone() or getNormalizedBone() instead."),this.getRawBone(e)}getRawBone(e){return this._rawHumanBones.getBone(e)}getNormalizedBone(e){return this._normalizedHumanBones.getBone(e)}getBoneNode(e){return console.warn("VRMHumanoid: getBoneNode() is deprecated. Use either getRawBoneNode() or getNormalizedBoneNode() instead."),this.getRawBoneNode(e)}getRawBoneNode(e){return this._rawHumanBones.getBoneNode(e)}getNormalizedBoneNode(e){return this._normalizedHumanBones.getBoneNode(e)}update(){this.autoUpdateHumanBones&&this._normalizedHumanBones.update()}},mx={Hips:"hips",Spine:"spine",Head:"head",LeftUpperLeg:"leftUpperLeg",LeftLowerLeg:"leftLowerLeg",LeftFoot:"leftFoot",RightUpperLeg:"rightUpperLeg",RightLowerLeg:"rightLowerLeg",RightFoot:"rightFoot",LeftUpperArm:"leftUpperArm",LeftLowerArm:"leftLowerArm",LeftHand:"leftHand",RightUpperArm:"rightUpperArm",RightLowerArm:"rightLowerArm",RightHand:"rightHand"},gx=new Set(["1.0","1.0-beta"]),vx={leftThumbProximal:"leftThumbMetacarpal",leftThumbIntermediate:"leftThumbProximal",rightThumbProximal:"rightThumbMetacarpal",rightThumbIntermediate:"rightThumbProximal"},yx=class{get name(){return"VRMHumanoidLoaderPlugin"}constructor(e,t){this.parser=e,this.helperRoot=null==t?void 0:t.helperRoot,this.autoUpdateHumanBones=null==t?void 0:t.autoUpdateHumanBones}afterRoot(e){return I_(this,null,(function*(){e.userData.vrmHumanoid=yield this._import(e)}))}_import(e){return I_(this,null,(function*(){const t=yield this._v1Import(e);if(t)return t;const n=yield this._v0Import(e);return n||null}))}_v1Import(e){return I_(this,null,(function*(){var t,n;const r=this.parser.json;if(!(-1!==(null==(t=r.extensionsUsed)?void 0:t.indexOf("VRMC_vrm"))))return null;const i=null==(n=r.extensions)?void 0:n.VRMC_vrm;if(!i)return null;const s=i.specVersion;if(!gx.has(s))return console.warn(`VRMHumanoidLoaderPlugin: Unknown VRMC_vrm specVersion "${s}"`),null;const a=i.humanoid;if(!a)return null;const o=null!=a.humanBones.leftThumbIntermediate||null!=a.humanBones.rightThumbIntermediate,l={};null!=a.humanBones&&(yield Promise.all(Object.entries(a.humanBones).map((e=>I_(this,[e],(function(e){var t=this;let[n,r]=e;return function*(){let e=n;const i=r.node;if(o){const t=vx[e];null!=t&&(e=t)}const s=yield t.parser.getDependency("node",i);null!=s?l[e]={node:s}:console.warn(`A glTF node bound to the humanoid bone ${e} (index = ${i}) does not exist`)}()}))))));const u=new fx(this._ensureRequiredBonesExist(l),{autoUpdateHumanBones:this.autoUpdateHumanBones});if(e.scene.add(u.normalizedHumanBonesRoot),this.helperRoot){const e=new rx(u);this.helperRoot.add(e),e.renderOrder=this.helperRoot.renderOrder}return u}))}_v0Import(e){return I_(this,null,(function*(){var t;const n=null==(t=this.parser.json.extensions)?void 0:t.VRM;if(!n)return null;const r=n.humanoid;if(!r)return null;const i={};null!=r.humanBones&&(yield Promise.all(r.humanBones.map((e=>I_(this,null,(function*(){const t=e.bone,n=e.node;if(null==t||null==n)return;const r=yield this.parser.getDependency("node",n);if(null==r)return void console.warn(`A glTF node bound to the humanoid bone ${t} (index = ${n}) does not exist`);const s=vx[t],a=null!=s?s:t;null==i[a]?i[a]={node:r}:console.warn(`Multiple bone entries for ${a} detected (index = ${n}), ignoring duplicated entries.`)}))))));const s=new fx(this._ensureRequiredBonesExist(i),{autoUpdateHumanBones:this.autoUpdateHumanBones});if(e.scene.add(s.normalizedHumanBonesRoot),this.helperRoot){const e=new rx(s);this.helperRoot.add(e),e.renderOrder=this.helperRoot.renderOrder}return s}))}_ensureRequiredBonesExist(e){const t=Object.values(mx).filter((t=>null==e[t]));if(t.length>0)throw new Error(`VRMHumanoidLoaderPlugin: These humanoid bones are required but not exist: ${t.join(", ")}`);return e}},_x=class extends Ps{constructor(){super(),this._currentTheta=0,this._currentRadius=0,this.theta=0,this.radius=0,this._currentTheta=0,this._currentRadius=0,this._attrPos=new ps(new Float32Array(195),3),this.setAttribute("position",this._attrPos),this._attrIndex=new ps(new Uint16Array(189),1),this.setIndex(this._attrIndex),this._buildIndex(),this.update()}update(){let e=!1;this._currentTheta!==this.theta&&(this._currentTheta=this.theta,e=!0),this._currentRadius!==this.radius&&(this._currentRadius=this.radius,e=!0),e&&this._buildPosition()}_buildPosition(){this._attrPos.setXYZ(0,0,0,0);for(let e=0;e<64;e++){const t=e/63*this._currentTheta;this._attrPos.setXYZ(e+1,this._currentRadius*Math.sin(t),0,this._currentRadius*Math.cos(t))}this._attrPos.needsUpdate=!0}_buildIndex(){for(let e=0;e<63;e++)this._attrIndex.setXYZ(3*e,0,e+1,e+2);this._attrIndex.needsUpdate=!0}},xx=class extends Ps{constructor(){super(),this.radius=0,this._currentRadius=0,this.tail=new Nr,this._currentTail=new Nr,this._attrPos=new ps(new Float32Array(294),3),this.setAttribute("position",this._attrPos),this._attrIndex=new ps(new Uint16Array(194),1),this.setIndex(this._attrIndex),this._buildIndex(),this.update()}update(){let e=!1;this._currentRadius!==this.radius&&(this._currentRadius=this.radius,e=!0),this._currentTail.equals(this.tail)||(this._currentTail.copy(this.tail),e=!0),e&&this._buildPosition()}_buildPosition(){for(let e=0;e<32;e++){const t=e/16*Math.PI;this._attrPos.setXYZ(e,Math.cos(t),Math.sin(t),0),this._attrPos.setXYZ(32+e,0,Math.cos(t),Math.sin(t)),this._attrPos.setXYZ(64+e,Math.sin(t),0,Math.cos(t))}this.scale(this._currentRadius,this._currentRadius,this._currentRadius),this.translate(this._currentTail.x,this._currentTail.y,this._currentTail.z),this._attrPos.setXYZ(96,0,0,0),this._attrPos.setXYZ(97,this._currentTail.x,this._currentTail.y,this._currentTail.z),this._attrPos.needsUpdate=!0}_buildIndex(){for(let e=0;e<32;e++){const t=(e+1)%32;this._attrIndex.setXY(2*e,e,t),this._attrIndex.setXY(64+2*e,32+e,32+t),this._attrIndex.setXY(128+2*e,64+e,64+t)}this._attrIndex.setXY(192,96,97),this._attrIndex.needsUpdate=!0}},Ax=new Ur,Mx=new Ur,bx=new Nr,Sx=new Nr,wx=Math.sqrt(2)/2,Ex=new Ur(0,0,-wx,wx),Tx=new Nr(0,1,0),Cx=class extends tu{constructor(e){super(),this.matrixAutoUpdate=!1,this.vrmLookAt=e;{const e=new _x;e.radius=.5;const t=new ss({color:65280,transparent:!0,opacity:.5,side:v,depthTest:!1,depthWrite:!1});this._meshPitch=new Ys(e,t),this.add(this._meshPitch)}{const e=new _x;e.radius=.5;const t=new ss({color:16711680,transparent:!0,opacity:.5,side:v,depthTest:!1,depthWrite:!1});this._meshYaw=new Ys(e,t),this.add(this._meshYaw)}{const e=new xx;e.radius=.1;const t=new wc({color:16777215,depthTest:!1,depthWrite:!1});this._lineTarget=new Fc(e,t),this._lineTarget.frustumCulled=!1,this.add(this._lineTarget)}}dispose(){this._meshYaw.geometry.dispose(),this._meshYaw.material.dispose(),this._meshPitch.geometry.dispose(),this._meshPitch.material.dispose(),this._lineTarget.geometry.dispose(),this._lineTarget.material.dispose()}updateMatrixWorld(e){const t=rr.DEG2RAD*this.vrmLookAt.yaw;this._meshYaw.geometry.theta=t,this._meshYaw.geometry.update();const n=rr.DEG2RAD*this.vrmLookAt.pitch;this._meshPitch.geometry.theta=n,this._meshPitch.geometry.update(),this.vrmLookAt.getLookAtWorldPosition(bx),this.vrmLookAt.getLookAtWorldQuaternion(Ax),Ax.multiply(this.vrmLookAt.getFaceFrontQuaternion(Mx)),this._meshYaw.position.copy(bx),this._meshYaw.quaternion.copy(Ax),this._meshPitch.position.copy(bx),this._meshPitch.quaternion.copy(Ax),this._meshPitch.quaternion.multiply(Mx.setFromAxisAngle(Tx,t)),this._meshPitch.quaternion.multiply(Ex);const{target:r,autoUpdate:i}=this.vrmLookAt;null!=r&&i&&(r.getWorldPosition(Sx).sub(bx),this._lineTarget.geometry.tail.copy(Sx),this._lineTarget.geometry.update(),this._lineTarget.position.copy(bx)),super.updateMatrixWorld(e)}},Rx=new Nr,Px=new Nr;function Ix(e,t){return e.matrixWorld.decompose(Rx,t,Px),t}function Bx(e){return[Math.atan2(-e.z,e.x),Math.atan2(e.y,Math.sqrt(e.x*e.x+e.z*e.z))]}function Lx(e){const t=Math.round(e/2/Math.PI);return e-2*Math.PI*t}var Dx=new Nr(0,0,1),Ux=new Nr,Nx=new Nr,Fx=new Nr,Ox=new Ur,kx=new Ur,Hx=new Ur,zx=new Ur,Gx=new Mi,Vx=class e{constructor(e,t){this.offsetFromHeadBone=new Nr,this.autoUpdate=!0,this.faceFront=new Nr(0,0,1),this.humanoid=e,this.applier=t,this._yaw=0,this._pitch=0,this._needsUpdate=!0,this._restHeadWorldQuaternion=this.getLookAtWorldQuaternion(new Ur)}get yaw(){return this._yaw}set yaw(e){this._yaw=e,this._needsUpdate=!0}get pitch(){return this._pitch}set pitch(e){this._pitch=e,this._needsUpdate=!0}get euler(){return console.warn("VRMLookAt: euler is deprecated. use getEuler() instead."),this.getEuler(new Mi)}getEuler(e){return e.set(rr.DEG2RAD*this._pitch,rr.DEG2RAD*this._yaw,0,"YXZ")}copy(e){if(this.humanoid!==e.humanoid)throw new Error("VRMLookAt: humanoid must be same in order to copy");return this.offsetFromHeadBone.copy(e.offsetFromHeadBone),this.applier=e.applier,this.autoUpdate=e.autoUpdate,this.target=e.target,this.faceFront.copy(e.faceFront),this}clone(){return new e(this.humanoid,this.applier).copy(this)}reset(){this._yaw=0,this._pitch=0,this._needsUpdate=!0}getLookAtWorldPosition(e){const t=this.humanoid.getRawBoneNode("head");return e.copy(this.offsetFromHeadBone).applyMatrix4(t.matrixWorld)}getLookAtWorldQuaternion(e){return Ix(this.humanoid.getRawBoneNode("head"),e)}getFaceFrontQuaternion(e){if(this.faceFront.distanceToSquared(Dx)<.01)return e.copy(this._restHeadWorldQuaternion).invert();const[t,n]=Bx(this.faceFront);return Gx.set(0,.5*Math.PI+t,n,"YZX"),e.setFromEuler(Gx).premultiply(zx.copy(this._restHeadWorldQuaternion).invert())}getLookAtWorldDirection(e){return this.getLookAtWorldQuaternion(kx),this.getFaceFrontQuaternion(Hx),e.copy(Dx).applyQuaternion(kx).applyQuaternion(Hx).applyEuler(this.getEuler(Gx))}lookAt(e){const t=Ox.copy(this._restHeadWorldQuaternion).multiply(ax(this.getLookAtWorldQuaternion(kx))),n=this.getLookAtWorldPosition(Nx),r=Fx.copy(e).sub(n).applyQuaternion(t).normalize(),[i,s]=Bx(this.faceFront),[a,o]=Bx(r),l=Lx(a-i),u=Lx(s-o);this._yaw=rr.RAD2DEG*l,this._pitch=rr.RAD2DEG*u,this._needsUpdate=!0}update(e){null!=this.target&&this.autoUpdate&&this.lookAt(this.target.getWorldPosition(Ux)),this._needsUpdate&&(this._needsUpdate=!1,this.applier.applyYawPitch(this._yaw,this._pitch))}};Vx.EULER_ORDER="YXZ";var Wx=Vx,jx=new Nr(0,0,1),Xx=new Ur,Jx=new Ur,Yx=new Mi(0,0,0,"YXZ"),Kx=class{constructor(e,t,n,r,i){this.humanoid=e,this.rangeMapHorizontalInner=t,this.rangeMapHorizontalOuter=n,this.rangeMapVerticalDown=r,this.rangeMapVerticalUp=i,this.faceFront=new Nr(0,0,1),this._restQuatLeftEye=new Ur,this._restQuatRightEye=new Ur,this._restLeftEyeParentWorldQuat=new Ur,this._restRightEyeParentWorldQuat=new Ur;const s=this.humanoid.getRawBoneNode("leftEye"),a=this.humanoid.getRawBoneNode("rightEye");s&&(this._restQuatLeftEye.copy(s.quaternion),Ix(s.parent,this._restLeftEyeParentWorldQuat)),a&&(this._restQuatRightEye.copy(a.quaternion),Ix(a.parent,this._restRightEyeParentWorldQuat))}applyYawPitch(e,t){const n=this.humanoid.getRawBoneNode("leftEye"),r=this.humanoid.getRawBoneNode("rightEye"),i=this.humanoid.getNormalizedBoneNode("leftEye"),s=this.humanoid.getNormalizedBoneNode("rightEye");n&&(Yx.x=t<0?-rr.DEG2RAD*this.rangeMapVerticalDown.map(-t):rr.DEG2RAD*this.rangeMapVerticalUp.map(t),Yx.y=e<0?-rr.DEG2RAD*this.rangeMapHorizontalInner.map(-e):rr.DEG2RAD*this.rangeMapHorizontalOuter.map(e),Xx.setFromEuler(Yx),this._getWorldFaceFrontQuat(Jx),i.quaternion.copy(Jx).multiply(Xx).multiply(Jx.invert()),Xx.copy(this._restLeftEyeParentWorldQuat),n.quaternion.copy(i.quaternion).multiply(Xx).premultiply(Xx.invert()).multiply(this._restQuatLeftEye)),r&&(Yx.x=t<0?-rr.DEG2RAD*this.rangeMapVerticalDown.map(-t):rr.DEG2RAD*this.rangeMapVerticalUp.map(t),Yx.y=e<0?-rr.DEG2RAD*this.rangeMapHorizontalOuter.map(-e):rr.DEG2RAD*this.rangeMapHorizontalInner.map(e),Xx.setFromEuler(Yx),this._getWorldFaceFrontQuat(Jx),s.quaternion.copy(Jx).multiply(Xx).multiply(Jx.invert()),Xx.copy(this._restRightEyeParentWorldQuat),r.quaternion.copy(s.quaternion).multiply(Xx).premultiply(Xx.invert()).multiply(this._restQuatRightEye))}lookAt(e){console.warn("VRMLookAtBoneApplier: lookAt() is deprecated. use apply() instead.");const t=rr.RAD2DEG*e.y,n=rr.RAD2DEG*e.x;this.applyYawPitch(t,n)}_getWorldFaceFrontQuat(e){if(this.faceFront.distanceToSquared(jx)<.01)return e.identity();const[t,n]=Bx(this.faceFront);return Yx.set(0,.5*Math.PI+t,n,"YZX"),e.setFromEuler(Yx)}};Kx.type="bone";var qx=class{constructor(e,t,n,r,i){this.expressions=e,this.rangeMapHorizontalInner=t,this.rangeMapHorizontalOuter=n,this.rangeMapVerticalDown=r,this.rangeMapVerticalUp=i}applyYawPitch(e,t){t<0?(this.expressions.setValue("lookDown",0),this.expressions.setValue("lookUp",this.rangeMapVerticalUp.map(-t))):(this.expressions.setValue("lookUp",0),this.expressions.setValue("lookDown",this.rangeMapVerticalDown.map(t))),e<0?(this.expressions.setValue("lookLeft",0),this.expressions.setValue("lookRight",this.rangeMapHorizontalOuter.map(-e))):(this.expressions.setValue("lookRight",0),this.expressions.setValue("lookLeft",this.rangeMapHorizontalOuter.map(e)))}lookAt(e){console.warn("VRMLookAtBoneApplier: lookAt() is deprecated. use apply() instead.");const t=rr.RAD2DEG*e.y,n=rr.RAD2DEG*e.x;this.applyYawPitch(t,n)}};qx.type="expression";var Qx=class{constructor(e,t){this.inputMaxValue=e,this.outputScale=t}map(e){return this.outputScale*F_(e/this.inputMaxValue)}},Zx=new Set(["1.0","1.0-beta"]),$x=.01,eA=class{get name(){return"VRMLookAtLoaderPlugin"}constructor(e,t){this.parser=e,this.helperRoot=null==t?void 0:t.helperRoot}afterRoot(e){return I_(this,null,(function*(){const t=e.userData.vrmHumanoid;if(null===t)return;if(void 0===t)throw new Error("VRMLookAtLoaderPlugin: vrmHumanoid is undefined. VRMHumanoidLoaderPlugin have to be used first");const n=e.userData.vrmExpressionManager;if(null!==n){if(void 0===n)throw new Error("VRMLookAtLoaderPlugin: vrmExpressionManager is undefined. VRMExpressionLoaderPlugin have to be used first");e.userData.vrmLookAt=yield this._import(e,t,n)}}))}_import(e,t,n){return I_(this,null,(function*(){if(null==t||null==n)return null;const r=yield this._v1Import(e,t,n);if(r)return r;const i=yield this._v0Import(e,t,n);return i||null}))}_v1Import(e,t,n){return I_(this,null,(function*(){var e,r,i;const s=this.parser.json;if(!(-1!==(null==(e=s.extensionsUsed)?void 0:e.indexOf("VRMC_vrm"))))return null;const a=null==(r=s.extensions)?void 0:r.VRMC_vrm;if(!a)return null;const o=a.specVersion;if(!Zx.has(o))return console.warn(`VRMLookAtLoaderPlugin: Unknown VRMC_vrm specVersion "${o}"`),null;const l=a.lookAt;if(!l)return null;const u="expression"===l.type?1:10,c=this._v1ImportRangeMap(l.rangeMapHorizontalInner,u),h=this._v1ImportRangeMap(l.rangeMapHorizontalOuter,u),d=this._v1ImportRangeMap(l.rangeMapVerticalDown,u),p=this._v1ImportRangeMap(l.rangeMapVerticalUp,u);let f;f="expression"===l.type?new qx(n,c,h,d,p):new Kx(t,c,h,d,p);const m=this._importLookAt(t,f);return m.offsetFromHeadBone.fromArray(null!=(i=l.offsetFromHeadBone)?i:[0,.06,0]),m}))}_v1ImportRangeMap(e,t){var n,r;let i=null!=(n=null==e?void 0:e.inputMaxValue)?n:90;const s=null!=(r=null==e?void 0:e.outputScale)?r:t;return i<$x&&(console.warn("VRMLookAtLoaderPlugin: inputMaxValue of a range map is too small. Consider reviewing the range map!"),i=$x),new Qx(i,s)}_v0Import(e,t,n){return I_(this,null,(function*(){var e,r,i,s;const a=null==(e=this.parser.json.extensions)?void 0:e.VRM;if(!a)return null;const o=a.firstPerson;if(!o)return null;const l="BlendShape"===o.lookAtTypeName?1:10,u=this._v0ImportDegreeMap(o.lookAtHorizontalInner,l),c=this._v0ImportDegreeMap(o.lookAtHorizontalOuter,l),h=this._v0ImportDegreeMap(o.lookAtVerticalDown,l),d=this._v0ImportDegreeMap(o.lookAtVerticalUp,l);let p;p="BlendShape"===o.lookAtTypeName?new qx(n,u,c,h,d):new Kx(t,u,c,h,d);const f=this._importLookAt(t,p);return o.firstPersonBoneOffset?f.offsetFromHeadBone.set(null!=(r=o.firstPersonBoneOffset.x)?r:0,null!=(i=o.firstPersonBoneOffset.y)?i:.06,-(null!=(s=o.firstPersonBoneOffset.z)?s:0)):f.offsetFromHeadBone.set(0,.06,0),f.faceFront.set(0,0,-1),p instanceof Kx&&p.faceFront.set(0,0,-1),f}))}_v0ImportDegreeMap(e,t){var n,r;const i=null==e?void 0:e.curve;"[0,0,0,1,1,1,1,0]"!==JSON.stringify(i)&&console.warn("Curves of LookAtDegreeMap defined in VRM 0.0 are not supported");let s=null!=(n=null==e?void 0:e.xRange)?n:90;const a=null!=(r=null==e?void 0:e.yRange)?r:t;return s<$x&&(console.warn("VRMLookAtLoaderPlugin: xRange of a degree map is too small. Consider reviewing the degree map!"),s=$x),new Qx(s,a)}_importLookAt(e,t){const n=new Wx(e,t);if(this.helperRoot){const e=new Cx(n);this.helperRoot.add(e),e.renderOrder=this.helperRoot.renderOrder}return n}};var tA=new Set(["1.0","1.0-beta"]),nA=class{get name(){return"VRMMetaLoaderPlugin"}constructor(e,t){var n,r,i;this.parser=e,this.needThumbnailImage=null!=(n=null==t?void 0:t.needThumbnailImage)&&n,this.acceptLicenseUrls=null!=(r=null==t?void 0:t.acceptLicenseUrls)?r:["https://vrm.dev/licenses/1.0/"],this.acceptV0Meta=null==(i=null==t?void 0:t.acceptV0Meta)||i}afterRoot(e){return I_(this,null,(function*(){e.userData.vrmMeta=yield this._import(e)}))}_import(e){return I_(this,null,(function*(){const t=yield this._v1Import(e);if(null!=t)return t;const n=yield this._v0Import(e);return null!=n?n:null}))}_v1Import(e){return I_(this,null,(function*(){var e,t,n;const r=this.parser.json;if(!(-1!==(null==(e=r.extensionsUsed)?void 0:e.indexOf("VRMC_vrm"))))return null;const i=null==(t=r.extensions)?void 0:t.VRMC_vrm;if(null==i)return null;const s=i.specVersion;if(!tA.has(s))return console.warn(`VRMMetaLoaderPlugin: Unknown VRMC_vrm specVersion "${s}"`),null;const a=i.meta;if(!a)return null;const o=a.licenseUrl;if(!new Set(this.acceptLicenseUrls).has(o))throw new Error(`VRMMetaLoaderPlugin: The license url "${o}" is not accepted`);let l;return this.needThumbnailImage&&null!=a.thumbnailImage&&(l=null!=(n=yield this._extractGLTFImage(a.thumbnailImage))?n:void 0),{metaVersion:"1",name:a.name,version:a.version,authors:a.authors,copyrightInformation:a.copyrightInformation,contactInformation:a.contactInformation,references:a.references,thirdPartyLicenses:a.thirdPartyLicenses,thumbnailImage:l,licenseUrl:a.licenseUrl,avatarPermission:a.avatarPermission,allowExcessivelyViolentUsage:a.allowExcessivelyViolentUsage,allowExcessivelySexualUsage:a.allowExcessivelySexualUsage,commercialUsage:a.commercialUsage,allowPoliticalOrReligiousUsage:a.allowPoliticalOrReligiousUsage,allowAntisocialOrHateUsage:a.allowAntisocialOrHateUsage,creditNotation:a.creditNotation,allowRedistribution:a.allowRedistribution,modification:a.modification,otherLicenseUrl:a.otherLicenseUrl}}))}_v0Import(e){return I_(this,null,(function*(){var e;const t=null==(e=this.parser.json.extensions)?void 0:e.VRM;if(!t)return null;const n=t.meta;if(!n)return null;if(!this.acceptV0Meta)throw new Error("VRMMetaLoaderPlugin: Attempted to load VRM0.0 meta but acceptV0Meta is false");let r;return this.needThumbnailImage&&null!=n.texture&&-1!==n.texture&&(r=yield this.parser.getDependency("texture",n.texture)),{metaVersion:"0",allowedUserName:n.allowedUserName,author:n.author,commercialUssageName:n.commercialUssageName,contactInformation:n.contactInformation,licenseName:n.licenseName,otherLicenseUrl:n.otherLicenseUrl,otherPermissionUrl:n.otherPermissionUrl,reference:n.reference,sexualUssageName:n.sexualUssageName,texture:null!=r?r:void 0,title:n.title,version:n.version,violentUssageName:n.violentUssageName}}))}_extractGLTFImage(e){return I_(this,null,(function*(){var t;const n=null==(t=this.parser.json.images)?void 0:t[e];if(null==n)return console.warn(`VRMMetaLoaderPlugin: Attempt to use images[${e}] of glTF as a thumbnail but the image doesn't exist`),null;let r=n.uri;if(null!=n.bufferView){const e=yield this.parser.getDependency("bufferView",n.bufferView),t=new Blob([e],{type:n.mimeType});r=URL.createObjectURL(t)}if(null==r)return console.warn(`VRMMetaLoaderPlugin: Attempt to use images[${e}] of glTF as a thumbnail but the image couldn't load properly`),null;const i=new ap;return yield i.loadAsync((s=r,a=this.parser.options.path,"string"!==typeof s||""===s?"":(/^https?:\/\//i.test(a)&&/^\//.test(s)&&(a=a.replace(/(^https?:\/\/[^/]+).*/i,"$1")),/^(https?:)?\/\//i.test(s)||/^data:.*,.*$/i.test(s)||/^blob:.*$/i.test(s)?s:a+s))).catch((e=>(console.error(e),console.warn("VRMMetaLoaderPlugin: Failed to load a thumbnail image"),null)));var s,a}))}},rA=class{constructor(e){this.scene=e.scene,this.meta=e.meta,this.humanoid=e.humanoid,this.expressionManager=e.expressionManager,this.firstPerson=e.firstPerson,this.lookAt=e.lookAt}update(e){this.humanoid.update(),this.lookAt&&this.lookAt.update(e),this.expressionManager&&this.expressionManager.update()}},iA=class extends rA{constructor(e){super(e),this.materials=e.materials,this.springBoneManager=e.springBoneManager,this.nodeConstraintManager=e.nodeConstraintManager}update(e){super.update(e),this.nodeConstraintManager&&this.nodeConstraintManager.update(),this.springBoneManager&&this.springBoneManager.update(e),this.materials&&this.materials.forEach((t=>{t.update&&t.update(e)}))}},sA=Object.defineProperty,aA=Object.getOwnPropertySymbols,oA=Object.prototype.hasOwnProperty,lA=Object.prototype.propertyIsEnumerable,uA=(e,t,n)=>t in e?sA(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,cA=(e,t)=>{for(var n in t||(t={}))oA.call(t,n)&&uA(e,n,t[n]);if(aA)for(var n of aA(t))lA.call(t,n)&&uA(e,n,t[n]);return e},hA=(e,t,n)=>new Promise(((r,i)=>{var s=e=>{try{o(n.next(e))}catch(t){i(t)}},a=e=>{try{o(n.throw(e))}catch(t){i(t)}},o=e=>e.done?r(e.value):Promise.resolve(e.value).then(s,a);o((n=n.apply(e,t)).next())})),dA={"":3e3,srgb:3001};var pA=class{get pending(){return Promise.all(this._pendings)}constructor(e,t){this._parser=e,this._materialParams=t,this._pendings=[]}assignPrimitive(e,t){null!=t&&(this._materialParams[e]=t)}assignColor(e,t,n){null!=t&&(this._materialParams[e]=(new ts).fromArray(t),n&&this._materialParams[e].convertSRGBToLinear())}assignTexture(e,t,n){return hA(this,null,(function*(){const r=(()=>hA(this,null,(function*(){null!=t&&(yield this._parser.assignTexture(this._materialParams,e,t),n&&function(e,t){parseInt(i,10)>=152?e.colorSpace=t:e.encoding=dA[t]}(this._materialParams[e],"srgb"))})))();return this._pendings.push(r),r}))}assignTextureByIndex(e,t,n){return hA(this,null,(function*(){return this.assignTexture(e,null!=t?{index:t}:void 0,n)}))}},fA="none",mA="none",gA="worldCoordinates",vA="screenCoordinates",yA={3e3:"",3001:"srgb"};function _A(e){return parseInt(i,10)>=152?e.colorSpace:yA[e.encoding]}var xA=class extends ta{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};var t;super({vertexShader:"// #define PHONG\n\nvarying vec3 vViewPosition;\n\n#ifndef FLAT_SHADED\n varying vec3 vNormal;\n#endif\n\n#include <common>\n\n// #include <uv_pars_vertex>\n#ifdef MTOON_USE_UV\n varying vec2 vUv;\n\n // COMPAT: pre-r151 uses a common uvTransform\n #if THREE_VRM_THREE_REVISION < 151\n uniform mat3 uvTransform;\n #endif\n#endif\n\n// #include <uv2_pars_vertex>\n// COMAPT: pre-r151 uses uv2 for lightMap and aoMap\n#if THREE_VRM_THREE_REVISION < 151\n #if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n attribute vec2 uv2;\n varying vec2 vUv2;\n uniform mat3 uv2Transform;\n #endif\n#endif\n\n// #include <displacementmap_pars_vertex>\n// #include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\n\n#ifdef USE_OUTLINEWIDTHMULTIPLYTEXTURE\n uniform sampler2D outlineWidthMultiplyTexture;\n uniform mat3 outlineWidthMultiplyTextureUvTransform;\n#endif\n\nuniform float outlineWidthFactor;\n\nvoid main() {\n\n // #include <uv_vertex>\n #ifdef MTOON_USE_UV\n // COMPAT: pre-r151 uses a common uvTransform\n #if THREE_VRM_THREE_REVISION >= 151\n vUv = uv;\n #else\n vUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n #endif\n #endif\n\n // #include <uv2_vertex>\n // COMAPT: pre-r151 uses uv2 for lightMap and aoMap\n #if THREE_VRM_THREE_REVISION < 151\n #if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n vUv2 = ( uv2Transform * vec3( uv2, 1 ) ).xy;\n #endif\n #endif\n\n #include <color_vertex>\n\n #include <beginnormal_vertex>\n #include <morphnormal_vertex>\n #include <skinbase_vertex>\n #include <skinnormal_vertex>\n\n // we need this to compute the outline properly\n objectNormal = normalize( objectNormal );\n\n #include <defaultnormal_vertex>\n\n #ifndef FLAT_SHADED // Normal computed with derivatives when FLAT_SHADED\n vNormal = normalize( transformedNormal );\n #endif\n\n #include <begin_vertex>\n\n #include <morphtarget_vertex>\n #include <skinning_vertex>\n // #include <displacementmap_vertex>\n #include <project_vertex>\n #include <logdepthbuf_vertex>\n #include <clipping_planes_vertex>\n\n vViewPosition = - mvPosition.xyz;\n\n float outlineTex = 1.0;\n\n #ifdef OUTLINE\n #ifdef USE_OUTLINEWIDTHMULTIPLYTEXTURE\n vec2 outlineWidthMultiplyTextureUv = ( outlineWidthMultiplyTextureUvTransform * vec3( vUv, 1 ) ).xy;\n outlineTex = texture2D( outlineWidthMultiplyTexture, outlineWidthMultiplyTextureUv ).g;\n #endif\n\n #ifdef OUTLINE_WIDTH_WORLD\n float worldNormalLength = length( transformedNormal );\n vec3 outlineOffset = outlineWidthFactor * outlineTex * worldNormalLength * objectNormal;\n gl_Position = projectionMatrix * modelViewMatrix * vec4( outlineOffset + transformed, 1.0 );\n #endif\n\n #ifdef OUTLINE_WIDTH_SCREEN\n vec3 clipNormal = ( projectionMatrix * modelViewMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n vec2 projectedNormal = normalize( clipNormal.xy );\n projectedNormal.x *= projectionMatrix[ 0 ].x / projectionMatrix[ 1 ].y;\n gl_Position.xy += 2.0 * outlineWidthFactor * outlineTex * projectedNormal.xy;\n #endif\n\n gl_Position.z += 1E-6 * gl_Position.w; // anti-artifact magic\n #endif\n\n #include <worldpos_vertex>\n // #include <envmap_vertex>\n #include <shadowmap_vertex>\n #include <fog_vertex>\n\n}",fragmentShader:"// #define PHONG\n\nuniform vec3 litFactor;\n\nuniform float opacity;\n\nuniform vec3 shadeColorFactor;\n#ifdef USE_SHADEMULTIPLYTEXTURE\n uniform sampler2D shadeMultiplyTexture;\n uniform mat3 shadeMultiplyTextureUvTransform;\n#endif\n\nuniform float shadingShiftFactor;\nuniform float shadingToonyFactor;\n\n#ifdef USE_SHADINGSHIFTTEXTURE\n uniform sampler2D shadingShiftTexture;\n uniform mat3 shadingShiftTextureUvTransform;\n uniform float shadingShiftTextureScale;\n#endif\n\nuniform float giEqualizationFactor;\n\nuniform vec3 parametricRimColorFactor;\n#ifdef USE_RIMMULTIPLYTEXTURE\n uniform sampler2D rimMultiplyTexture;\n uniform mat3 rimMultiplyTextureUvTransform;\n#endif\nuniform float rimLightingMixFactor;\nuniform float parametricRimFresnelPowerFactor;\nuniform float parametricRimLiftFactor;\n\n#ifdef USE_MATCAPTEXTURE\n uniform vec3 matcapFactor;\n uniform sampler2D matcapTexture;\n uniform mat3 matcapTextureUvTransform;\n#endif\n\nuniform vec3 emissive;\nuniform float emissiveIntensity;\n\nuniform vec3 outlineColorFactor;\nuniform float outlineLightingMixFactor;\n\n#ifdef USE_UVANIMATIONMASKTEXTURE\n uniform sampler2D uvAnimationMaskTexture;\n uniform mat3 uvAnimationMaskTextureUvTransform;\n#endif\n\nuniform float uvAnimationScrollXOffset;\nuniform float uvAnimationScrollYOffset;\nuniform float uvAnimationRotationPhase;\n\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n\n// #include <uv_pars_fragment>\n#if ( defined( MTOON_USE_UV ) && !defined( MTOON_UVS_VERTEX_ONLY ) )\n varying vec2 vUv;\n#endif\n\n// #include <uv2_pars_fragment>\n// COMAPT: pre-r151 uses uv2 for lightMap and aoMap\n#if THREE_VRM_THREE_REVISION < 151\n #if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n varying vec2 vUv2;\n #endif\n#endif\n\n#include <map_pars_fragment>\n\n#ifdef USE_MAP\n uniform mat3 mapUvTransform;\n#endif\n\n// #include <alphamap_pars_fragment>\n\n#include <alphatest_pars_fragment>\n\n#include <aomap_pars_fragment>\n// #include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n\n#ifdef USE_EMISSIVEMAP\n uniform mat3 emissiveMapUvTransform;\n#endif\n\n// #include <envmap_common_pars_fragment>\n// #include <envmap_pars_fragment>\n// #include <cube_uv_reflection_fragment>\n#include <fog_pars_fragment>\n\n// #include <bsdfs>\n// COMPAT: pre-r151 doesn't have BRDF_Lambert in <common>\n#if THREE_VRM_THREE_REVISION < 151\n vec3 BRDF_Lambert( const in vec3 diffuseColor ) {\n return RECIPROCAL_PI * diffuseColor;\n }\n#endif\n\n#include <lights_pars_begin>\n\n#include <normal_pars_fragment>\n\n// #include <lights_phong_pars_fragment>\nvarying vec3 vViewPosition;\n\nstruct MToonMaterial {\n vec3 diffuseColor;\n vec3 shadeColor;\n float shadingShift;\n};\n\nfloat linearstep( float a, float b, float t ) {\n return clamp( ( t - a ) / ( b - a ), 0.0, 1.0 );\n}\n\n/**\n * Convert NdotL into toon shading factor using shadingShift and shadingToony\n */\nfloat getShading(\n const in float dotNL,\n const in float shadow,\n const in float shadingShift\n) {\n float shading = dotNL;\n shading = shading + shadingShift;\n shading = linearstep( -1.0 + shadingToonyFactor, 1.0 - shadingToonyFactor, shading );\n shading *= shadow;\n return shading;\n}\n\n/**\n * Mix diffuseColor and shadeColor using shading factor and light color\n */\nvec3 getDiffuse(\n const in MToonMaterial material,\n const in float shading,\n in vec3 lightColor\n) {\n #ifdef DEBUG_LITSHADERATE\n return vec3( BRDF_Lambert( shading * lightColor ) );\n #endif\n\n vec3 col = lightColor * BRDF_Lambert( mix( material.shadeColor, material.diffuseColor, shading ) );\n\n // The \"comment out if you want to PBR absolutely\" line\n #ifdef V0_COMPAT_SHADE\n col = min( col, material.diffuseColor );\n #endif\n\n return col;\n}\n\n// COMPAT: pre-r156 uses a struct GeometricContext\n#if THREE_VRM_THREE_REVISION >= 157\n void RE_Direct_MToon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in MToonMaterial material, const in float shadow, inout ReflectedLight reflectedLight ) {\n float dotNL = clamp( dot( geometryNormal, directLight.direction ), -1.0, 1.0 );\n vec3 irradiance = directLight.color;\n\n // directSpecular will be used for rim lighting, not an actual specular\n reflectedLight.directSpecular += irradiance;\n\n irradiance *= dotNL;\n\n float shading = getShading( dotNL, shadow, material.shadingShift );\n\n // toon shaded diffuse\n reflectedLight.directDiffuse += getDiffuse( material, shading, directLight.color );\n }\n\n void RE_IndirectDiffuse_MToon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in MToonMaterial material, inout ReflectedLight reflectedLight ) {\n // indirect diffuse will use diffuseColor, no shadeColor involved\n reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n\n // directSpecular will be used for rim lighting, not an actual specular\n reflectedLight.directSpecular += irradiance;\n }\n#else\n void RE_Direct_MToon( const in IncidentLight directLight, const in GeometricContext geometry, const in MToonMaterial material, const in float shadow, inout ReflectedLight reflectedLight ) {\n float dotNL = clamp( dot( geometry.normal, directLight.direction ), -1.0, 1.0 );\n vec3 irradiance = directLight.color;\n\n // directSpecular will be used for rim lighting, not an actual specular\n reflectedLight.directSpecular += irradiance;\n\n irradiance *= dotNL;\n\n float shading = getShading( dotNL, shadow, material.shadingShift );\n\n // toon shaded diffuse\n reflectedLight.directDiffuse += getDiffuse( material, shading, directLight.color );\n }\n\n void RE_IndirectDiffuse_MToon( const in vec3 irradiance, const in GeometricContext geometry, const in MToonMaterial material, inout ReflectedLight reflectedLight ) {\n // indirect diffuse will use diffuseColor, no shadeColor involved\n reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n\n // directSpecular will be used for rim lighting, not an actual specular\n reflectedLight.directSpecular += irradiance;\n }\n#endif\n\n#define RE_Direct RE_Direct_MToon\n#define RE_IndirectDiffuse RE_IndirectDiffuse_MToon\n#define Material_LightProbeLOD( material ) (0)\n\n#include <shadowmap_pars_fragment>\n// #include <bumpmap_pars_fragment>\n\n// #include <normalmap_pars_fragment>\n#ifdef USE_NORMALMAP\n\n uniform sampler2D normalMap;\n uniform mat3 normalMapUvTransform;\n uniform vec2 normalScale;\n\n#endif\n\n// COMPAT: pre-r151\n// USE_NORMALMAP_OBJECTSPACE used to be OBJECTSPACE_NORMALMAP in pre-r151\n#if defined( USE_NORMALMAP_OBJECTSPACE ) || defined( OBJECTSPACE_NORMALMAP )\n\n uniform mat3 normalMatrix;\n\n#endif\n\n// COMPAT: pre-r151\n// USE_NORMALMAP_TANGENTSPACE used to be TANGENTSPACE_NORMALMAP in pre-r151\n#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( TANGENTSPACE_NORMALMAP ) )\n\n // Per-Pixel Tangent Space Normal Mapping\n // http://hacksoflife.blogspot.ch/2009/11/per-pixel-tangent-space-normal-mapping.html\n\n // three-vrm specific change: it requires `uv` as an input in order to support uv scrolls\n\n // Temporary compat against shader change @ Three.js r126, r151\n #if THREE_VRM_THREE_REVISION >= 151\n\n mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {\n\n vec3 q0 = dFdx( eye_pos.xyz );\n vec3 q1 = dFdy( eye_pos.xyz );\n vec2 st0 = dFdx( uv.st );\n vec2 st1 = dFdy( uv.st );\n\n vec3 N = surf_norm;\n\n vec3 q1perp = cross( q1, N );\n vec3 q0perp = cross( N, q0 );\n\n vec3 T = q1perp * st0.x + q0perp * st1.x;\n vec3 B = q1perp * st0.y + q0perp * st1.y;\n\n float det = max( dot( T, T ), dot( B, B ) );\n float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );\n\n return mat3( T * scale, B * scale, N );\n\n }\n\n #else\n\n vec3 perturbNormal2Arb( vec2 uv, vec3 eye_pos, vec3 surf_norm, vec3 mapN, float faceDirection ) {\n\n vec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );\n vec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );\n vec2 st0 = dFdx( uv.st );\n vec2 st1 = dFdy( uv.st );\n\n vec3 N = normalize( surf_norm );\n\n vec3 q1perp = cross( q1, N );\n vec3 q0perp = cross( N, q0 );\n\n vec3 T = q1perp * st0.x + q0perp * st1.x;\n vec3 B = q1perp * st0.y + q0perp * st1.y;\n\n // three-vrm specific change: Workaround for the issue that happens when delta of uv = 0.0\n // TODO: Is this still required? Or shall I make a PR about it?\n if ( length( T ) == 0.0 || length( B ) == 0.0 ) {\n return surf_norm;\n }\n\n float det = max( dot( T, T ), dot( B, B ) );\n float scale = ( det == 0.0 ) ? 0.0 : faceDirection * inversesqrt( det );\n\n return normalize( T * ( mapN.x * scale ) + B * ( mapN.y * scale ) + N * mapN.z );\n\n }\n\n #endif\n\n#endif\n\n// #include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\n\n// == post correction ==========================================================\nvoid postCorrection() {\n #include <tonemapping_fragment>\n #include <colorspace_fragment>\n #include <fog_fragment>\n #include <premultiplied_alpha_fragment>\n #include <dithering_fragment>\n}\n\n// == main procedure ===========================================================\nvoid main() {\n #include <clipping_planes_fragment>\n\n vec2 uv = vec2(0.5, 0.5);\n\n #if ( defined( MTOON_USE_UV ) && !defined( MTOON_UVS_VERTEX_ONLY ) )\n uv = vUv;\n\n float uvAnimMask = 1.0;\n #ifdef USE_UVANIMATIONMASKTEXTURE\n vec2 uvAnimationMaskTextureUv = ( uvAnimationMaskTextureUvTransform * vec3( uv, 1 ) ).xy;\n uvAnimMask = texture2D( uvAnimationMaskTexture, uvAnimationMaskTextureUv ).b;\n #endif\n\n float uvRotCos = cos( uvAnimationRotationPhase * uvAnimMask );\n float uvRotSin = sin( uvAnimationRotationPhase * uvAnimMask );\n uv = mat2( uvRotCos, -uvRotSin, uvRotSin, uvRotCos ) * ( uv - 0.5 ) + 0.5;\n uv = uv + vec2( uvAnimationScrollXOffset, uvAnimationScrollYOffset ) * uvAnimMask;\n #endif\n\n #ifdef DEBUG_UV\n gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n #if ( defined( MTOON_USE_UV ) && !defined( MTOON_UVS_VERTEX_ONLY ) )\n gl_FragColor = vec4( uv, 0.0, 1.0 );\n #endif\n return;\n #endif\n\n vec4 diffuseColor = vec4( litFactor, opacity );\n ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n vec3 totalEmissiveRadiance = emissive * emissiveIntensity;\n\n #include <logdepthbuf_fragment>\n\n // #include <map_fragment>\n #ifdef USE_MAP\n vec2 mapUv = ( mapUvTransform * vec3( uv, 1 ) ).xy;\n vec4 sampledDiffuseColor = texture2D( map, mapUv );\n #ifdef DECODE_VIDEO_TEXTURE\n sampledDiffuseColor = vec4( mix( pow( sampledDiffuseColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), sampledDiffuseColor.rgb * 0.0773993808, vec3( lessThanEqual( sampledDiffuseColor.rgb, vec3( 0.04045 ) ) ) ), sampledDiffuseColor.w );\n #endif\n diffuseColor *= sampledDiffuseColor;\n #endif\n\n // #include <color_fragment>\n #if ( defined( USE_COLOR ) && !defined( IGNORE_VERTEX_COLOR ) )\n diffuseColor.rgb *= vColor;\n #endif\n\n // #include <alphamap_fragment>\n\n #include <alphatest_fragment>\n\n // #include <specularmap_fragment>\n\n // #include <normal_fragment_begin>\n float faceDirection = gl_FrontFacing ? 1.0 : -1.0;\n\n #ifdef FLAT_SHADED\n\n vec3 fdx = dFdx( vViewPosition );\n vec3 fdy = dFdy( vViewPosition );\n vec3 normal = normalize( cross( fdx, fdy ) );\n\n #else\n\n vec3 normal = normalize( vNormal );\n\n #ifdef DOUBLE_SIDED\n\n normal *= faceDirection;\n\n #endif\n\n #endif\n\n #ifdef USE_NORMALMAP\n\n vec2 normalMapUv = ( normalMapUvTransform * vec3( uv, 1 ) ).xy;\n\n #endif\n\n #ifdef USE_NORMALMAP_TANGENTSPACE\n\n #ifdef USE_TANGENT\n\n mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\n #else\n\n mat3 tbn = getTangentFrame( - vViewPosition, normal, normalMapUv );\n\n #endif\n\n #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n\n tbn[0] *= faceDirection;\n tbn[1] *= faceDirection;\n\n #endif\n\n #endif\n\n #ifdef USE_CLEARCOAT_NORMALMAP\n\n #ifdef USE_TANGENT\n\n mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\n #else\n\n mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );\n\n #endif\n\n #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n\n tbn2[0] *= faceDirection;\n tbn2[1] *= faceDirection;\n\n #endif\n\n #endif\n\n // non perturbed normal for clearcoat among others\n\n vec3 nonPerturbedNormal = normal;\n\n #ifdef OUTLINE\n normal *= -1.0;\n #endif\n\n // #include <normal_fragment_maps>\n\n // COMPAT: pre-r151\n // USE_NORMALMAP_OBJECTSPACE used to be OBJECTSPACE_NORMALMAP in pre-r151\n #if defined( USE_NORMALMAP_OBJECTSPACE ) || defined( OBJECTSPACE_NORMALMAP )\n\n normal = texture2D( normalMap, normalMapUv ).xyz * 2.0 - 1.0; // overrides both flatShading and attribute normals\n\n #ifdef FLIP_SIDED\n\n normal = - normal;\n\n #endif\n\n #ifdef DOUBLE_SIDED\n\n normal = normal * faceDirection;\n\n #endif\n\n normal = normalize( normalMatrix * normal );\n\n // COMPAT: pre-r151\n // USE_NORMALMAP_TANGENTSPACE used to be TANGENTSPACE_NORMALMAP in pre-r151\n #elif defined( USE_NORMALMAP_TANGENTSPACE ) || defined( TANGENTSPACE_NORMALMAP )\n\n vec3 mapN = texture2D( normalMap, normalMapUv ).xyz * 2.0 - 1.0;\n mapN.xy *= normalScale;\n\n // COMPAT: pre-r151\n #if THREE_VRM_THREE_REVISION >= 151 || defined( USE_TANGENT )\n\n normal = normalize( tbn * mapN );\n\n #else\n\n normal = perturbNormal2Arb( uv, -vViewPosition, normal, mapN, faceDirection );\n\n #endif\n\n #endif\n\n // #include <emissivemap_fragment>\n #ifdef USE_EMISSIVEMAP\n vec2 emissiveMapUv = ( emissiveMapUvTransform * vec3( uv, 1 ) ).xy;\n totalEmissiveRadiance *= texture2D( emissiveMap, emissiveMapUv ).rgb;\n #endif\n\n #ifdef DEBUG_NORMAL\n gl_FragColor = vec4( 0.5 + 0.5 * normal, 1.0 );\n return;\n #endif\n\n // -- MToon: lighting --------------------------------------------------------\n // accumulation\n // #include <lights_phong_fragment>\n MToonMaterial material;\n\n material.diffuseColor = diffuseColor.rgb;\n\n material.shadeColor = shadeColorFactor;\n #ifdef USE_SHADEMULTIPLYTEXTURE\n vec2 shadeMultiplyTextureUv = ( shadeMultiplyTextureUvTransform * vec3( uv, 1 ) ).xy;\n material.shadeColor *= texture2D( shadeMultiplyTexture, shadeMultiplyTextureUv ).rgb;\n #endif\n\n #if ( defined( USE_COLOR ) && !defined( IGNORE_VERTEX_COLOR ) )\n material.shadeColor.rgb *= vColor;\n #endif\n\n material.shadingShift = shadingShiftFactor;\n #ifdef USE_SHADINGSHIFTTEXTURE\n vec2 shadingShiftTextureUv = ( shadingShiftTextureUvTransform * vec3( uv, 1 ) ).xy;\n material.shadingShift += texture2D( shadingShiftTexture, shadingShiftTextureUv ).r * shadingShiftTextureScale;\n #endif\n\n // #include <lights_fragment_begin>\n\n // MToon Specific changes:\n // Since we want to take shadows into account of shading instead of irradiance,\n // we had to modify the codes that multiplies the results of shadowmap into color of direct lights.\n\n // COMPAT: pre-r156 uses a struct GeometricContext\n #if THREE_VRM_THREE_REVISION >= 157\n vec3 geometryPosition = - vViewPosition;\n vec3 geometryNormal = normal;\n vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\n\n vec3 geometryClearcoatNormal;\n\n #ifdef USE_CLEARCOAT\n\n geometryClearcoatNormal = clearcoatNormal;\n\n #endif\n #else\n GeometricContext geometry;\n\n geometry.position = - vViewPosition;\n geometry.normal = normal;\n geometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\n\n #ifdef USE_CLEARCOAT\n\n geometry.clearcoatNormal = clearcoatNormal;\n\n #endif\n #endif\n\n IncidentLight directLight;\n\n // since these variables will be used in unrolled loop, we have to define in prior\n float shadow;\n\n #if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\n PointLight pointLight;\n #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n PointLightShadow pointLightShadow;\n #endif\n\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\n pointLight = pointLights[ i ];\n\n // COMPAT: pre-r156 uses a struct GeometricContext\n #if THREE_VRM_THREE_REVISION >= 157\n getPointLightInfo( pointLight, geometryPosition, directLight );\n #else\n getPointLightInfo( pointLight, geometry, directLight );\n #endif\n\n shadow = 1.0;\n #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n pointLightShadow = pointLightShadows[ i ];\n // COMPAT: pre-r166\n // r166 introduced shadowIntensity\n #if THREE_VRM_THREE_REVISION >= 166\n shadow = all( bvec2( directLight.visible, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n #else\n shadow = all( bvec2( directLight.visible, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n #endif\n #endif\n\n // COMPAT: pre-r156 uses a struct GeometricContext\n #if THREE_VRM_THREE_REVISION >= 157\n RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, shadow, reflectedLight );\n #else\n RE_Direct( directLight, geometry, material, shadow, reflectedLight );\n #endif\n\n }\n #pragma unroll_loop_end\n\n #endif\n\n #if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\n SpotLight spotLight;\n #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n SpotLightShadow spotLightShadow;\n #endif\n\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\n spotLight = spotLights[ i ];\n\n // COMPAT: pre-r156 uses a struct GeometricContext\n #if THREE_VRM_THREE_REVISION >= 157\n getSpotLightInfo( spotLight, geometryPosition, directLight );\n #else\n getSpotLightInfo( spotLight, geometry, directLight );\n #endif\n\n shadow = 1.0;\n #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n spotLightShadow = spotLightShadows[ i ];\n // COMPAT: pre-r166\n // r166 introduced shadowIntensity\n #if THREE_VRM_THREE_REVISION >= 166\n shadow = all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n #else\n shadow = all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n #endif\n #endif\n\n // COMPAT: pre-r156 uses a struct GeometricContext\n #if THREE_VRM_THREE_REVISION >= 157\n RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, shadow, reflectedLight );\n #else\n RE_Direct( directLight, geometry, material, shadow, reflectedLight );\n #endif\n\n }\n #pragma unroll_loop_end\n\n #endif\n\n #if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\n DirectionalLight directionalLight;\n #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n DirectionalLightShadow directionalLightShadow;\n #endif\n\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\n directionalLight = directionalLights[ i ];\n\n // COMPAT: pre-r156 uses a struct GeometricContext\n #if THREE_VRM_THREE_REVISION >= 157\n getDirectionalLightInfo( directionalLight, directLight );\n #else\n getDirectionalLightInfo( directionalLight, geometry, directLight );\n #endif\n\n shadow = 1.0;\n #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n directionalLightShadow = directionalLightShadows[ i ];\n // COMPAT: pre-r166\n // r166 introduced shadowIntensity\n #if THREE_VRM_THREE_REVISION >= 166\n shadow = all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n #else\n shadow = all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n #endif\n #endif\n\n // COMPAT: pre-r156 uses a struct GeometricContext\n #if THREE_VRM_THREE_REVISION >= 157\n RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, shadow, reflectedLight );\n #else\n RE_Direct( directLight, geometry, material, shadow, reflectedLight );\n #endif\n\n }\n #pragma unroll_loop_end\n\n #endif\n\n // #if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\n // RectAreaLight rectAreaLight;\n\n // #pragma unroll_loop_start\n // for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\n // rectAreaLight = rectAreaLights[ i ];\n // RE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );\n\n // }\n // #pragma unroll_loop_end\n\n // #endif\n\n #if defined( RE_IndirectDiffuse )\n\n vec3 iblIrradiance = vec3( 0.0 );\n\n vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\n // COMPAT: pre-r156 uses a struct GeometricContext\n // COMPAT: pre-r156 doesn't have a define USE_LIGHT_PROBES\n #if THREE_VRM_THREE_REVISION >= 157\n #if defined( USE_LIGHT_PROBES )\n irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );\n #endif\n #else\n irradiance += getLightProbeIrradiance( lightProbe, geometry.normal );\n #endif\n\n #if ( NUM_HEMI_LIGHTS > 0 )\n\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\n // COMPAT: pre-r156 uses a struct GeometricContext\n #if THREE_VRM_THREE_REVISION >= 157\n irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );\n #else\n irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry.normal );\n #endif\n\n }\n #pragma unroll_loop_end\n\n #endif\n\n #endif\n\n // #if defined( RE_IndirectSpecular )\n\n // vec3 radiance = vec3( 0.0 );\n // vec3 clearcoatRadiance = vec3( 0.0 );\n\n // #endif\n\n #include <lights_fragment_maps>\n #include <lights_fragment_end>\n\n // modulation\n #include <aomap_fragment>\n\n vec3 col = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\n\n #ifdef DEBUG_LITSHADERATE\n gl_FragColor = vec4( col, diffuseColor.a );\n postCorrection();\n return;\n #endif\n\n // -- MToon: rim lighting -----------------------------------------\n vec3 viewDir = normalize( vViewPosition );\n\n #ifndef PHYSICALLY_CORRECT_LIGHTS\n reflectedLight.directSpecular /= PI;\n #endif\n vec3 rimMix = mix( vec3( 1.0 ), reflectedLight.directSpecular, 1.0 );\n\n vec3 rim = parametricRimColorFactor * pow( saturate( 1.0 - dot( viewDir, normal ) + parametricRimLiftFactor ), parametricRimFresnelPowerFactor );\n\n #ifdef USE_MATCAPTEXTURE\n {\n vec3 x = normalize( vec3( viewDir.z, 0.0, -viewDir.x ) );\n vec3 y = cross( viewDir, x ); // guaranteed to be normalized\n vec2 sphereUv = 0.5 + 0.5 * vec2( dot( x, normal ), -dot( y, normal ) );\n sphereUv = ( matcapTextureUvTransform * vec3( sphereUv, 1 ) ).xy;\n vec3 matcap = texture2D( matcapTexture, sphereUv ).rgb;\n rim += matcapFactor * matcap;\n }\n #endif\n\n #ifdef USE_RIMMULTIPLYTEXTURE\n vec2 rimMultiplyTextureUv = ( rimMultiplyTextureUvTransform * vec3( uv, 1 ) ).xy;\n rim *= texture2D( rimMultiplyTexture, rimMultiplyTextureUv ).rgb;\n #endif\n\n col += rimMix * rim;\n\n // -- MToon: Emission --------------------------------------------------------\n col += totalEmissiveRadiance;\n\n // #include <envmap_fragment>\n\n // -- Almost done! -----------------------------------------------------------\n #if defined( OUTLINE )\n col = outlineColorFactor.rgb * mix( vec3( 1.0 ), col, outlineLightingMixFactor );\n #endif\n\n #ifdef OPAQUE\n diffuseColor.a = 1.0;\n #endif\n\n gl_FragColor = vec4( col, diffuseColor.a );\n postCorrection();\n}\n"}),this.uvAnimationScrollXSpeedFactor=0,this.uvAnimationScrollYSpeedFactor=0,this.uvAnimationRotationSpeedFactor=0,this.fog=!0,this.normalMapType=Qt,this._ignoreVertexColor=!0,this._v0CompatShade=!1,this._debugMode=fA,this._outlineWidthMode=mA,this._isOutline=!1,e.transparentWithZWrite&&(e.depthWrite=!0),delete e.transparentWithZWrite,e.fog=!0,e.lights=!0,e.clipping=!0,this.uniforms=ea.merge([Ma.common,Ma.normalmap,Ma.emissivemap,Ma.fog,Ma.lights,{litFactor:{value:new ts(1,1,1)},mapUvTransform:{value:new sr},colorAlpha:{value:1},normalMapUvTransform:{value:new sr},shadeColorFactor:{value:new ts(0,0,0)},shadeMultiplyTexture:{value:null},shadeMultiplyTextureUvTransform:{value:new sr},shadingShiftFactor:{value:0},shadingShiftTexture:{value:null},shadingShiftTextureUvTransform:{value:new sr},shadingShiftTextureScale:{value:1},shadingToonyFactor:{value:.9},giEqualizationFactor:{value:.9},matcapFactor:{value:new ts(1,1,1)},matcapTexture:{value:null},matcapTextureUvTransform:{value:new sr},parametricRimColorFactor:{value:new ts(0,0,0)},rimMultiplyTexture:{value:null},rimMultiplyTextureUvTransform:{value:new sr},rimLightingMixFactor:{value:1},parametricRimFresnelPowerFactor:{value:5},parametricRimLiftFactor:{value:0},emissive:{value:new ts(0,0,0)},emissiveIntensity:{value:1},emissiveMapUvTransform:{value:new sr},outlineWidthMultiplyTexture:{value:null},outlineWidthMultiplyTextureUvTransform:{value:new sr},outlineWidthFactor:{value:0},outlineColorFactor:{value:new ts(0,0,0)},outlineLightingMixFactor:{value:1},uvAnimationMaskTexture:{value:null},uvAnimationMaskTextureUvTransform:{value:new sr},uvAnimationScrollXOffset:{value:0},uvAnimationScrollYOffset:{value:0},uvAnimationRotationPhase:{value:0}},null!=(t=e.uniforms)?t:{}]),this.setValues(e),this._uploadUniformsWorkaround(),this.customProgramCacheKey=()=>[...Object.entries(this._generateDefines()).map((e=>{let[t,n]=e;return`${t}:${n}`})),this.matcapTexture?`matcapTextureColorSpace:${_A(this.matcapTexture)}`:"",this.shadeMultiplyTexture?`shadeMultiplyTextureColorSpace:${_A(this.shadeMultiplyTexture)}`:"",this.rimMultiplyTexture?`rimMultiplyTextureColorSpace:${_A(this.rimMultiplyTexture)}`:""].join(","),this.onBeforeCompile=e=>{const t=parseInt(i,10),n=Object.entries(cA(cA({},this._generateDefines()),this.defines)).filter((e=>{let[t,n]=e;return!!n})).map((e=>{let[t,n]=e;return`#define ${t} ${n}`})).join("\n")+"\n";e.vertexShader=n+e.vertexShader,e.fragmentShader=n+e.fragmentShader,t<154&&(e.fragmentShader=e.fragmentShader.replace("#include <colorspace_fragment>","#include <encodings_fragment>"))}}get color(){return this.uniforms.litFactor.value}set color(e){this.uniforms.litFactor.value=e}get map(){return this.uniforms.map.value}set map(e){this.uniforms.map.value=e}get normalMap(){return this.uniforms.normalMap.value}set normalMap(e){this.uniforms.normalMap.value=e}get normalScale(){return this.uniforms.normalScale.value}set normalScale(e){this.uniforms.normalScale.value=e}get emissive(){return this.uniforms.emissive.value}set emissive(e){this.uniforms.emissive.value=e}get emissiveIntensity(){return this.uniforms.emissiveIntensity.value}set emissiveIntensity(e){this.uniforms.emissiveIntensity.value=e}get emissiveMap(){return this.uniforms.emissiveMap.value}set emissiveMap(e){this.uniforms.emissiveMap.value=e}get shadeColorFactor(){return this.uniforms.shadeColorFactor.value}set shadeColorFactor(e){this.uniforms.shadeColorFactor.value=e}get shadeMultiplyTexture(){return this.uniforms.shadeMultiplyTexture.value}set shadeMultiplyTexture(e){this.uniforms.shadeMultiplyTexture.value=e}get shadingShiftFactor(){return this.uniforms.shadingShiftFactor.value}set shadingShiftFactor(e){this.uniforms.shadingShiftFactor.value=e}get shadingShiftTexture(){return this.uniforms.shadingShiftTexture.value}set shadingShiftTexture(e){this.uniforms.shadingShiftTexture.value=e}get shadingShiftTextureScale(){return this.uniforms.shadingShiftTextureScale.value}set shadingShiftTextureScale(e){this.uniforms.shadingShiftTextureScale.value=e}get shadingToonyFactor(){return this.uniforms.shadingToonyFactor.value}set shadingToonyFactor(e){this.uniforms.shadingToonyFactor.value=e}get giEqualizationFactor(){return this.uniforms.giEqualizationFactor.value}set giEqualizationFactor(e){this.uniforms.giEqualizationFactor.value=e}get matcapFactor(){return this.uniforms.matcapFactor.value}set matcapFactor(e){this.uniforms.matcapFactor.value=e}get matcapTexture(){return this.uniforms.matcapTexture.value}set matcapTexture(e){this.uniforms.matcapTexture.value=e}get parametricRimColorFactor(){return this.uniforms.parametricRimColorFactor.value}set parametricRimColorFactor(e){this.uniforms.parametricRimColorFactor.value=e}get rimMultiplyTexture(){return this.uniforms.rimMultiplyTexture.value}set rimMultiplyTexture(e){this.uniforms.rimMultiplyTexture.value=e}get rimLightingMixFactor(){return this.uniforms.rimLightingMixFactor.value}set rimLightingMixFactor(e){this.uniforms.rimLightingMixFactor.value=e}get parametricRimFresnelPowerFactor(){return this.uniforms.parametricRimFresnelPowerFactor.value}set parametricRimFresnelPowerFactor(e){this.uniforms.parametricRimFresnelPowerFactor.value=e}get parametricRimLiftFactor(){return this.uniforms.parametricRimLiftFactor.value}set parametricRimLiftFactor(e){this.uniforms.parametricRimLiftFactor.value=e}get outlineWidthMultiplyTexture(){return this.uniforms.outlineWidthMultiplyTexture.value}set outlineWidthMultiplyTexture(e){this.uniforms.outlineWidthMultiplyTexture.value=e}get outlineWidthFactor(){return this.uniforms.outlineWidthFactor.value}set outlineWidthFactor(e){this.uniforms.outlineWidthFactor.value=e}get outlineColorFactor(){return this.uniforms.outlineColorFactor.value}set outlineColorFactor(e){this.uniforms.outlineColorFactor.value=e}get outlineLightingMixFactor(){return this.uniforms.outlineLightingMixFactor.value}set outlineLightingMixFactor(e){this.uniforms.outlineLightingMixFactor.value=e}get uvAnimationMaskTexture(){return this.uniforms.uvAnimationMaskTexture.value}set uvAnimationMaskTexture(e){this.uniforms.uvAnimationMaskTexture.value=e}get uvAnimationScrollXOffset(){return this.uniforms.uvAnimationScrollXOffset.value}set uvAnimationScrollXOffset(e){this.uniforms.uvAnimationScrollXOffset.value=e}get uvAnimationScrollYOffset(){return this.uniforms.uvAnimationScrollYOffset.value}set uvAnimationScrollYOffset(e){this.uniforms.uvAnimationScrollYOffset.value=e}get uvAnimationRotationPhase(){return this.uniforms.uvAnimationRotationPhase.value}set uvAnimationRotationPhase(e){this.uniforms.uvAnimationRotationPhase.value=e}get ignoreVertexColor(){return this._ignoreVertexColor}set ignoreVertexColor(e){this._ignoreVertexColor=e,this.needsUpdate=!0}get v0CompatShade(){return this._v0CompatShade}set v0CompatShade(e){this._v0CompatShade=e,this.needsUpdate=!0}get debugMode(){return this._debugMode}set debugMode(e){this._debugMode=e,this.needsUpdate=!0}get outlineWidthMode(){return this._outlineWidthMode}set outlineWidthMode(e){this._outlineWidthMode=e,this.needsUpdate=!0}get isOutline(){return this._isOutline}set isOutline(e){this._isOutline=e,this.needsUpdate=!0}get isMToonMaterial(){return!0}update(e){this._uploadUniformsWorkaround(),this._updateUVAnimation(e)}copy(e){return super.copy(e),this.map=e.map,this.normalMap=e.normalMap,this.emissiveMap=e.emissiveMap,this.shadeMultiplyTexture=e.shadeMultiplyTexture,this.shadingShiftTexture=e.shadingShiftTexture,this.matcapTexture=e.matcapTexture,this.rimMultiplyTexture=e.rimMultiplyTexture,this.outlineWidthMultiplyTexture=e.outlineWidthMultiplyTexture,this.uvAnimationMaskTexture=e.uvAnimationMaskTexture,this.normalMapType=e.normalMapType,this.uvAnimationScrollXSpeedFactor=e.uvAnimationScrollXSpeedFactor,this.uvAnimationScrollYSpeedFactor=e.uvAnimationScrollYSpeedFactor,this.uvAnimationRotationSpeedFactor=e.uvAnimationRotationSpeedFactor,this.ignoreVertexColor=e.ignoreVertexColor,this.v0CompatShade=e.v0CompatShade,this.debugMode=e.debugMode,this.outlineWidthMode=e.outlineWidthMode,this.isOutline=e.isOutline,this.needsUpdate=!0,this}_updateUVAnimation(e){this.uniforms.uvAnimationScrollXOffset.value+=e*this.uvAnimationScrollXSpeedFactor,this.uniforms.uvAnimationScrollYOffset.value+=e*this.uvAnimationScrollYSpeedFactor,this.uniforms.uvAnimationRotationPhase.value+=e*this.uvAnimationRotationSpeedFactor,this.uniforms.alphaTest.value=this.alphaTest,this.uniformsNeedUpdate=!0}_uploadUniformsWorkaround(){this.uniforms.opacity.value=this.opacity,this._updateTextureMatrix(this.uniforms.map,this.uniforms.mapUvTransform),this._updateTextureMatrix(this.uniforms.normalMap,this.uniforms.normalMapUvTransform),this._updateTextureMatrix(this.uniforms.emissiveMap,this.uniforms.emissiveMapUvTransform),this._updateTextureMatrix(this.uniforms.shadeMultiplyTexture,this.uniforms.shadeMultiplyTextureUvTransform),this._updateTextureMatrix(this.uniforms.shadingShiftTexture,this.uniforms.shadingShiftTextureUvTransform),this._updateTextureMatrix(this.uniforms.matcapTexture,this.uniforms.matcapTextureUvTransform),this._updateTextureMatrix(this.uniforms.rimMultiplyTexture,this.uniforms.rimMultiplyTextureUvTransform),this._updateTextureMatrix(this.uniforms.outlineWidthMultiplyTexture,this.uniforms.outlineWidthMultiplyTextureUvTransform),this._updateTextureMatrix(this.uniforms.uvAnimationMaskTexture,this.uniforms.uvAnimationMaskTextureUvTransform),this.uniformsNeedUpdate=!0}_generateDefines(){const e=parseInt(i,10),t=null!==this.outlineWidthMultiplyTexture,n=null!==this.map||null!==this.normalMap||null!==this.emissiveMap||null!==this.shadeMultiplyTexture||null!==this.shadingShiftTexture||null!==this.rimMultiplyTexture||null!==this.uvAnimationMaskTexture;return{THREE_VRM_THREE_REVISION:e,OUTLINE:this._isOutline,MTOON_USE_UV:t||n,MTOON_UVS_VERTEX_ONLY:t&&!n,V0_COMPAT_SHADE:this._v0CompatShade,USE_SHADEMULTIPLYTEXTURE:null!==this.shadeMultiplyTexture,USE_SHADINGSHIFTTEXTURE:null!==this.shadingShiftTexture,USE_MATCAPTEXTURE:null!==this.matcapTexture,USE_RIMMULTIPLYTEXTURE:null!==this.rimMultiplyTexture,USE_OUTLINEWIDTHMULTIPLYTEXTURE:this._isOutline&&null!==this.outlineWidthMultiplyTexture,USE_UVANIMATIONMASKTEXTURE:null!==this.uvAnimationMaskTexture,IGNORE_VERTEX_COLOR:!0===this._ignoreVertexColor,DEBUG_NORMAL:"normal"===this._debugMode,DEBUG_LITSHADERATE:"litShadeRate"===this._debugMode,DEBUG_UV:"uv"===this._debugMode,OUTLINE_WIDTH_WORLD:this._isOutline&&this._outlineWidthMode===gA,OUTLINE_WIDTH_SCREEN:this._isOutline&&this._outlineWidthMode===vA}}_updateTextureMatrix(e,t){e.value&&(e.value.matrixAutoUpdate&&e.value.updateMatrix(),t.value.copy(e.value.matrix))}},AA=new Set(["1.0","1.0-beta"]),MA=class e{get name(){return e.EXTENSION_NAME}constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};var n,r,i,s;this.parser=e,this.materialType=null!=(n=t.materialType)?n:xA,this.renderOrderOffset=null!=(r=t.renderOrderOffset)?r:0,this.v0CompatShade=null!=(i=t.v0CompatShade)&&i,this.debugMode=null!=(s=t.debugMode)?s:"none",this._mToonMaterialSet=new Set}beforeRoot(){return hA(this,null,(function*(){this._removeUnlitExtensionIfMToonExists()}))}afterRoot(e){return hA(this,null,(function*(){e.userData.vrmMToonMaterials=Array.from(this._mToonMaterialSet)}))}getMaterialType(e){return this._getMToonExtension(e)?this.materialType:null}extendMaterialParams(e,t){const n=this._getMToonExtension(e);return n?this._extendMaterialParams(n,t):null}loadMesh(e){return hA(this,null,(function*(){var t;const n=this.parser,r=null==(t=n.json.meshes)?void 0:t[e];if(null==r)throw new Error(`MToonMaterialLoaderPlugin: Attempt to use meshes[${e}] of glTF but the mesh doesn't exist`);const i=r.primitives,s=yield n.loadMesh(e);if(1===i.length){const e=s,t=i[0].material;null!=t&&this._setupPrimitive(e,t)}else{const e=s;for(let t=0;t<i.length;t++){const n=e.children[t],r=i[t].material;null!=r&&this._setupPrimitive(n,r)}}return s}))}_removeUnlitExtensionIfMToonExists(){const e=this.parser.json.materials;null==e||e.map(((e,t)=>{var n;this._getMToonExtension(t)&&(null==(n=e.extensions)?void 0:n.KHR_materials_unlit)&&delete e.extensions.KHR_materials_unlit}))}_getMToonExtension(t){var n,r;const i=null==(n=this.parser.json.materials)?void 0:n[t];if(null==i)return void console.warn(`MToonMaterialLoaderPlugin: Attempt to use materials[${t}] of glTF but the material doesn't exist`);const s=null==(r=i.extensions)?void 0:r[e.EXTENSION_NAME];if(null==s)return;const a=s.specVersion;if(AA.has(a))return s;console.warn(`MToonMaterialLoaderPlugin: Unknown ${e.EXTENSION_NAME} specVersion "${a}"`)}_extendMaterialParams(e,t){return hA(this,null,(function*(){var n;delete t.metalness,delete t.roughness;const r=new pA(this.parser,t);r.assignPrimitive("transparentWithZWrite",e.transparentWithZWrite),r.assignColor("shadeColorFactor",e.shadeColorFactor),r.assignTexture("shadeMultiplyTexture",e.shadeMultiplyTexture,!0),r.assignPrimitive("shadingShiftFactor",e.shadingShiftFactor),r.assignTexture("shadingShiftTexture",e.shadingShiftTexture,!0),r.assignPrimitive("shadingShiftTextureScale",null==(n=e.shadingShiftTexture)?void 0:n.scale),r.assignPrimitive("shadingToonyFactor",e.shadingToonyFactor),r.assignPrimitive("giEqualizationFactor",e.giEqualizationFactor),r.assignColor("matcapFactor",e.matcapFactor),r.assignTexture("matcapTexture",e.matcapTexture,!0),r.assignColor("parametricRimColorFactor",e.parametricRimColorFactor),r.assignTexture("rimMultiplyTexture",e.rimMultiplyTexture,!0),r.assignPrimitive("rimLightingMixFactor",e.rimLightingMixFactor),r.assignPrimitive("parametricRimFresnelPowerFactor",e.parametricRimFresnelPowerFactor),r.assignPrimitive("parametricRimLiftFactor",e.parametricRimLiftFactor),r.assignPrimitive("outlineWidthMode",e.outlineWidthMode),r.assignPrimitive("outlineWidthFactor",e.outlineWidthFactor),r.assignTexture("outlineWidthMultiplyTexture",e.outlineWidthMultiplyTexture,!1),r.assignColor("outlineColorFactor",e.outlineColorFactor),r.assignPrimitive("outlineLightingMixFactor",e.outlineLightingMixFactor),r.assignTexture("uvAnimationMaskTexture",e.uvAnimationMaskTexture,!1),r.assignPrimitive("uvAnimationScrollXSpeedFactor",e.uvAnimationScrollXSpeedFactor),r.assignPrimitive("uvAnimationScrollYSpeedFactor",e.uvAnimationScrollYSpeedFactor),r.assignPrimitive("uvAnimationRotationSpeedFactor",e.uvAnimationRotationSpeedFactor),r.assignPrimitive("v0CompatShade",this.v0CompatShade),r.assignPrimitive("debugMode",this.debugMode),yield r.pending}))}_setupPrimitive(e,t){const n=this._getMToonExtension(t);if(n){const t=this._parseRenderOrder(n);return e.renderOrder=t+this.renderOrderOffset,this._generateOutline(e),void this._addToMaterialSet(e)}}_shouldGenerateOutline(e){return"string"===typeof e.outlineWidthMode&&"none"!==e.outlineWidthMode&&"number"===typeof e.outlineWidthFactor&&e.outlineWidthFactor>0}_generateOutline(e){const t=e.material;if(!(t instanceof is))return;if(!this._shouldGenerateOutline(t))return;e.material=[t];const n=t.clone();n.name+=" (Outline)",n.isOutline=!0,n.side=g,e.material.push(n);const r=e.geometry,i=r.index?r.index.count:r.attributes.position.count/3;r.addGroup(0,i,0),r.addGroup(0,i,1)}_addToMaterialSet(e){const t=e.material,n=new Set;Array.isArray(t)?t.forEach((e=>n.add(e))):n.add(t);for(const r of n)this._mToonMaterialSet.add(r)}_parseRenderOrder(e){var t;return(e.transparentWithZWrite?0:19)+(null!=(t=e.renderQueueOffsetNumber)?t:0)}};MA.EXTENSION_NAME="VRMC_materials_mtoon";var bA=MA,SA=class e{get name(){return e.EXTENSION_NAME}constructor(e){this.parser=e}extendMaterialParams(e,t){return n=this,r=null,i=function*(){const n=this._getHDREmissiveMultiplierExtension(e);if(null==n)return;console.warn("VRMMaterialsHDREmissiveMultiplierLoaderPlugin: `VRMC_materials_hdr_emissiveMultiplier` is archived. Use `KHR_materials_emissive_strength` instead.");const r=n.emissiveMultiplier;t.emissiveIntensity=r},new Promise(((e,t)=>{var s=e=>{try{o(i.next(e))}catch(n){t(n)}},a=e=>{try{o(i.throw(e))}catch(n){t(n)}},o=t=>t.done?e(t.value):Promise.resolve(t.value).then(s,a);o((i=i.apply(n,r)).next())}));var n,r,i}_getHDREmissiveMultiplierExtension(t){var n,r;const i=null==(n=this.parser.json.materials)?void 0:n[t];if(null==i)return void console.warn(`VRMMaterialsHDREmissiveMultiplierLoaderPlugin: Attempt to use materials[${t}] of glTF but the material doesn't exist`);const s=null==(r=i.extensions)?void 0:r[e.EXTENSION_NAME];return null!=s?s:void 0}};SA.EXTENSION_NAME="VRMC_materials_hdr_emissiveMultiplier";var wA=SA,EA=Object.defineProperty,TA=Object.defineProperties,CA=Object.getOwnPropertyDescriptors,RA=Object.getOwnPropertySymbols,PA=Object.prototype.hasOwnProperty,IA=Object.prototype.propertyIsEnumerable,BA=(e,t,n)=>t in e?EA(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,LA=(e,t)=>{for(var n in t||(t={}))PA.call(t,n)&&BA(e,n,t[n]);if(RA)for(var n of RA(t))IA.call(t,n)&&BA(e,n,t[n]);return e},DA=(e,t)=>TA(e,CA(t));function UA(e){return Math.pow(e,2.2)}var NA=class{get name(){return"VRMMaterialsV0CompatPlugin"}constructor(e){var t;this.parser=e,this._renderQueueMapTransparent=new Map,this._renderQueueMapTransparentZWrite=new Map;const n=this.parser.json;n.extensionsUsed=null!=(t=n.extensionsUsed)?t:[],-1===n.extensionsUsed.indexOf("KHR_texture_transform")&&n.extensionsUsed.push("KHR_texture_transform")}beforeRoot(){return e=this,t=null,n=function*(){var e;const t=this.parser.json,n=null==(e=t.extensions)?void 0:e.VRM,r=null==n?void 0:n.materialProperties;r&&(this._populateRenderQueueMap(r),r.forEach(((e,n)=>{var r,i;const s=null==(r=t.materials)?void 0:r[n];if(null!=s)if("VRM/MToon"===e.shader){const r=this._parseV0MToonProperties(e,s);t.materials[n]=r}else if(null==(i=e.shader)?void 0:i.startsWith("VRM/Unlit")){const r=this._parseV0UnlitProperties(e,s);t.materials[n]=r}else"VRM_USE_GLTFSHADER"===e.shader||console.warn(`VRMMaterialsV0CompatPlugin: Unknown shader: ${e.shader}`);else console.warn(`VRMMaterialsV0CompatPlugin: Attempt to use materials[${n}] of glTF but the material doesn't exist`)})))},new Promise(((r,i)=>{var s=e=>{try{o(n.next(e))}catch(t){i(t)}},a=e=>{try{o(n.throw(e))}catch(t){i(t)}},o=e=>e.done?r(e.value):Promise.resolve(e.value).then(s,a);o((n=n.apply(e,t)).next())}));var e,t,n}_parseV0MToonProperties(e,t){var n,r,i,s,a,o,l,u,c,h,d,p,f,m,g,v,y,_,x,A,M,b,S,w,E,T,C,R,P,I,B,L,D,U,N,F,O,k,H,z,G,V,W,j,X,J,Y,K,q,Q,Z,$,ee,te,ne;const re=null!=(r=null==(n=e.keywordMap)?void 0:n._ALPHABLEND_ON)&&r,ie=1===(null==(i=e.floatProperties)?void 0:i._ZWrite)&&re,se=this._v0ParseRenderQueue(e),ae=null!=(a=null==(s=e.keywordMap)?void 0:s._ALPHATEST_ON)&&a,oe=re?"BLEND":ae?"MASK":"OPAQUE",le=ae?null!=(l=null==(o=e.floatProperties)?void 0:o._Cutoff)?l:.5:void 0,ue=0===(null!=(c=null==(u=e.floatProperties)?void 0:u._CullMode)?c:2),ce=this._portTextureTransform(e),he=(null!=(d=null==(h=e.vectorProperties)?void 0:h._Color)?d:[1,1,1,1]).map(((e,t)=>3===t?e:UA(e))),de=null==(p=e.textureProperties)?void 0:p._MainTex,pe=null!=de?{index:de,extensions:LA({},ce)}:void 0,fe=null!=(m=null==(f=e.floatProperties)?void 0:f._BumpScale)?m:1,me=null==(g=e.textureProperties)?void 0:g._BumpMap,ge=null!=me?{index:me,scale:fe,extensions:LA({},ce)}:void 0,ve=(null!=(y=null==(v=e.vectorProperties)?void 0:v._EmissionColor)?y:[0,0,0,1]).map(UA),ye=null==(_=e.textureProperties)?void 0:_._EmissionMap,_e=null!=ye?{index:ye,extensions:LA({},ce)}:void 0,xe=(null!=(A=null==(x=e.vectorProperties)?void 0:x._ShadeColor)?A:[.97,.81,.86,1]).map(UA),Ae=null==(M=e.textureProperties)?void 0:M._ShadeTexture,Me=null!=Ae?{index:Ae,extensions:LA({},ce)}:void 0;let be=null!=(S=null==(b=e.floatProperties)?void 0:b._ShadeShift)?S:0,Se=null!=(E=null==(w=e.floatProperties)?void 0:w._ShadeToony)?E:.9;Se=rr.lerp(Se,1,.5+.5*be),be=-be-(1-Se);const we=null!=(C=null==(T=e.floatProperties)?void 0:T._IndirectLightIntensity)?C:.1,Ee=we?1-we:void 0,Te=null==(R=e.textureProperties)?void 0:R._SphereAdd,Ce=null!=Te?[1,1,1]:void 0,Re=null!=Te?{index:Te}:void 0,Pe=null!=(I=null==(P=e.floatProperties)?void 0:P._RimLightingMix)?I:0,Ie=null==(B=e.textureProperties)?void 0:B._RimTexture,Be=null!=Ie?{index:Ie,extensions:LA({},ce)}:void 0,Le=(null!=(D=null==(L=e.vectorProperties)?void 0:L._RimColor)?D:[0,0,0,1]).map(UA),De=null!=(N=null==(U=e.floatProperties)?void 0:U._RimFresnelPower)?N:1,Ue=null!=(O=null==(F=e.floatProperties)?void 0:F._RimLift)?O:0,Ne=["none","worldCoordinates","screenCoordinates"][null!=(H=null==(k=e.floatProperties)?void 0:k._OutlineWidthMode)?H:0];let Fe=null!=(G=null==(z=e.floatProperties)?void 0:z._OutlineWidth)?G:0;Fe*=.01;const Oe=null==(V=e.textureProperties)?void 0:V._OutlineWidthTexture,ke=null!=Oe?{index:Oe,extensions:LA({},ce)}:void 0,He=(null!=(j=null==(W=e.vectorProperties)?void 0:W._OutlineColor)?j:[0,0,0]).map(UA),ze=1===(null!=(J=null==(X=e.floatProperties)?void 0:X._OutlineColorMode)?J:0)?null!=(K=null==(Y=e.floatProperties)?void 0:Y._OutlineLightingMix)?K:1:0,Ge=null==(q=e.textureProperties)?void 0:q._UvAnimMaskTexture,Ve=null!=Ge?{index:Ge,extensions:LA({},ce)}:void 0,We=null!=(Z=null==(Q=e.floatProperties)?void 0:Q._UvAnimScrollX)?Z:0;let je=null!=(ee=null==($=e.floatProperties)?void 0:$._UvAnimScrollY)?ee:0;null!=je&&(je=-je);const Xe={specVersion:"1.0",transparentWithZWrite:ie,renderQueueOffsetNumber:se,shadeColorFactor:xe,shadeMultiplyTexture:Me,shadingShiftFactor:be,shadingToonyFactor:Se,giEqualizationFactor:Ee,matcapFactor:Ce,matcapTexture:Re,rimLightingMixFactor:Pe,rimMultiplyTexture:Be,parametricRimColorFactor:Le,parametricRimFresnelPowerFactor:De,parametricRimLiftFactor:Ue,outlineWidthMode:Ne,outlineWidthFactor:Fe,outlineWidthMultiplyTexture:ke,outlineColorFactor:He,outlineLightingMixFactor:ze,uvAnimationMaskTexture:Ve,uvAnimationScrollXSpeedFactor:We,uvAnimationScrollYSpeedFactor:je,uvAnimationRotationSpeedFactor:null!=(ne=null==(te=e.floatProperties)?void 0:te._UvAnimRotation)?ne:0};return DA(LA({},t),{pbrMetallicRoughness:{baseColorFactor:he,baseColorTexture:pe},normalTexture:ge,emissiveTexture:_e,emissiveFactor:ve,alphaMode:oe,alphaCutoff:le,doubleSided:ue,extensions:{VRMC_materials_mtoon:Xe}})}_parseV0UnlitProperties(e,t){var n,r,i,s,a;const o="VRM/UnlitTransparentZWrite"===e.shader,l="VRM/UnlitTransparent"===e.shader||o,u=this._v0ParseRenderQueue(e),c="VRM/UnlitCutout"===e.shader,h=l?"BLEND":c?"MASK":"OPAQUE",d=c?null!=(r=null==(n=e.floatProperties)?void 0:n._Cutoff)?r:.5:void 0,p=this._portTextureTransform(e),f=(null!=(s=null==(i=e.vectorProperties)?void 0:i._Color)?s:[1,1,1,1]).map(UA),m=null==(a=e.textureProperties)?void 0:a._MainTex,g=null!=m?{index:m,extensions:LA({},p)}:void 0,v={specVersion:"1.0",transparentWithZWrite:o,renderQueueOffsetNumber:u,shadeColorFactor:f,shadeMultiplyTexture:g};return DA(LA({},t),{pbrMetallicRoughness:{baseColorFactor:f,baseColorTexture:g},alphaMode:h,alphaCutoff:d,extensions:{VRMC_materials_mtoon:v}})}_portTextureTransform(e){var t,n,r,i,s;const a=null==(t=e.vectorProperties)?void 0:t._MainTex;if(null==a)return{};const o=[null!=(n=null==a?void 0:a[0])?n:0,null!=(r=null==a?void 0:a[1])?r:0],l=[null!=(i=null==a?void 0:a[2])?i:1,null!=(s=null==a?void 0:a[3])?s:1];return o[1]=1-l[1]-o[1],{KHR_texture_transform:{offset:o,scale:l}}}_v0ParseRenderQueue(e){var t,n,r;const i=null!=(n=null==(t=e.keywordMap)?void 0:t._ALPHABLEND_ON)&&n,s=1===(null==(r=e.floatProperties)?void 0:r._ZWrite);let a=0;if(i){const t=e.renderQueue;null!=t&&(a=s?this._renderQueueMapTransparentZWrite.get(t):this._renderQueueMapTransparent.get(t))}return a}_populateRenderQueueMap(e){const t=new Set,n=new Set;e.forEach((e=>{var r,i,s;const a=null!=(i=null==(r=e.keywordMap)?void 0:r._ALPHABLEND_ON)&&i,o=1===(null==(s=e.floatProperties)?void 0:s._ZWrite);if(a){const r=e.renderQueue;null!=r&&(o?n.add(r):t.add(r))}})),t.size>10&&console.warn(`VRMMaterialsV0CompatPlugin: This VRM uses ${t.size} render queues for Transparent materials while VRM 1.0 only supports up to 10 render queues. The model might not be rendered correctly.`),n.size>10&&console.warn(`VRMMaterialsV0CompatPlugin: This VRM uses ${n.size} render queues for TransparentZWrite materials while VRM 1.0 only supports up to 10 render queues. The model might not be rendered correctly.`),Array.from(t).sort().forEach(((e,n)=>{const r=Math.min(Math.max(n-t.size+1,-9),0);this._renderQueueMapTransparent.set(e,r)})),Array.from(n).sort().forEach(((e,t)=>{const n=Math.min(Math.max(t,0),9);this._renderQueueMapTransparentZWrite.set(e,n)}))}},FA=(e,t,n)=>new Promise(((r,i)=>{var s=e=>{try{o(n.next(e))}catch(t){i(t)}},a=e=>{try{o(n.throw(e))}catch(t){i(t)}},o=e=>e.done?r(e.value):Promise.resolve(e.value).then(s,a);o((n=n.apply(e,t)).next())})),OA=new Nr,kA=class extends tu{constructor(e){super(),this._attrPosition=new ps(new Float32Array([0,0,0,0,0,0]),3),this._attrPosition.setUsage(Dn);const t=new Ps;t.setAttribute("position",this._attrPosition);const n=new wc({color:16711935,depthTest:!1,depthWrite:!1});this._line=new Lc(t,n),this.add(this._line),this.constraint=e}updateMatrixWorld(e){OA.setFromMatrixPosition(this.constraint.destination.matrixWorld),this._attrPosition.setXYZ(0,OA.x,OA.y,OA.z),this.constraint.source&&OA.setFromMatrixPosition(this.constraint.source.matrixWorld),this._attrPosition.setXYZ(1,OA.x,OA.y,OA.z),this._attrPosition.needsUpdate=!0,super.updateMatrixWorld(e)}};function HA(e,t){return t.set(e.elements[12],e.elements[13],e.elements[14])}var zA=new Nr,GA=new Nr;function VA(e){return e.invert?e.invert():e.inverse(),e}var WA=class{constructor(e,t){this.destination=e,this.source=t,this.weight=1}},jA=new Nr,XA=new Nr,JA=new Nr,YA=new Ur,KA=new Ur,qA=new Ur,QA=class extends WA{get aimAxis(){return this._aimAxis}set aimAxis(e){this._aimAxis=e,this._v3AimAxis.set("PositiveX"===e?1:"NegativeX"===e?-1:0,"PositiveY"===e?1:"NegativeY"===e?-1:0,"PositiveZ"===e?1:"NegativeZ"===e?-1:0)}get dependencies(){const e=new Set([this.source]);return this.destination.parent&&e.add(this.destination.parent),e}constructor(e,t){super(e,t),this._aimAxis="PositiveX",this._v3AimAxis=new Nr(1,0,0),this._dstRestQuat=new Ur}setInitState(){this._dstRestQuat.copy(this.destination.quaternion)}update(){this.destination.updateWorldMatrix(!0,!1),this.source.updateWorldMatrix(!0,!1);const e=YA.identity(),t=KA.identity();var n,r;this.destination.parent&&(n=this.destination.parent.matrixWorld,r=e,n.decompose(zA,r,GA),VA(t.copy(e)));const i=jA.copy(this._v3AimAxis).applyQuaternion(this._dstRestQuat).applyQuaternion(e),s=HA(this.source.matrixWorld,XA).sub(HA(this.destination.matrixWorld,JA)).normalize(),a=qA.setFromUnitVectors(i,s).premultiply(t).multiply(e).multiply(this._dstRestQuat);this.destination.quaternion.copy(this._dstRestQuat).slerp(a,this.weight)}};function ZA(e,t){const n=[e];let r=e.parent;for(;null!==r;)n.unshift(r),r=r.parent;n.forEach((e=>{t(e)}))}var $A=class{constructor(){this._constraints=new Set,this._objectConstraintsMap=new Map}get constraints(){return this._constraints}addConstraint(e){this._constraints.add(e);let t=this._objectConstraintsMap.get(e.destination);null==t&&(t=new Set,this._objectConstraintsMap.set(e.destination,t)),t.add(e)}deleteConstraint(e){this._constraints.delete(e);this._objectConstraintsMap.get(e.destination).delete(e)}setInitState(){const e=new Set,t=new Set;for(const n of this._constraints)this._processConstraint(n,e,t,(e=>e.setInitState()))}update(){const e=new Set,t=new Set;for(const n of this._constraints)this._processConstraint(n,e,t,(e=>e.update()))}_processConstraint(e,t,n,r){if(n.has(e))return;if(t.has(e))throw new Error("VRMNodeConstraintManager: Circular dependency detected while updating constraints");t.add(e);const i=e.dependencies;for(const s of i)ZA(s,(e=>{const i=this._objectConstraintsMap.get(e);if(i)for(const s of i)this._processConstraint(s,t,n,r)}));r(e),n.add(e)}},eM=new Ur,tM=new Ur,nM=class extends WA{get dependencies(){return new Set([this.source])}constructor(e,t){super(e,t),this._dstRestQuat=new Ur,this._invSrcRestQuat=new Ur}setInitState(){this._dstRestQuat.copy(this.destination.quaternion),VA(this._invSrcRestQuat.copy(this.source.quaternion))}update(){const e=eM.copy(this._invSrcRestQuat).multiply(this.source.quaternion),t=tM.copy(this._dstRestQuat).multiply(e);this.destination.quaternion.copy(this._dstRestQuat).slerp(t,this.weight)}},rM=new Nr,iM=new Ur,sM=new Ur,aM=class extends WA{get rollAxis(){return this._rollAxis}set rollAxis(e){this._rollAxis=e,this._v3RollAxis.set("X"===e?1:0,"Y"===e?1:0,"Z"===e?1:0)}get dependencies(){return new Set([this.source])}constructor(e,t){super(e,t),this._rollAxis="X",this._v3RollAxis=new Nr(1,0,0),this._dstRestQuat=new Ur,this._invDstRestQuat=new Ur,this._invSrcRestQuatMulDstRestQuat=new Ur}setInitState(){this._dstRestQuat.copy(this.destination.quaternion),VA(this._invDstRestQuat.copy(this._dstRestQuat)),VA(this._invSrcRestQuatMulDstRestQuat.copy(this.source.quaternion)).multiply(this._dstRestQuat)}update(){const e=iM.copy(this._invDstRestQuat).multiply(this.source.quaternion).multiply(this._invSrcRestQuatMulDstRestQuat),t=rM.copy(this._v3RollAxis).applyQuaternion(e),n=sM.setFromUnitVectors(t,this._v3RollAxis).premultiply(this._dstRestQuat).multiply(e);this.destination.quaternion.copy(this._dstRestQuat).slerp(n,this.weight)}},oM=new Set(["1.0","1.0-beta"]),lM=class e{get name(){return e.EXTENSION_NAME}constructor(e,t){this.parser=e,this.helperRoot=null==t?void 0:t.helperRoot}afterRoot(e){return FA(this,null,(function*(){e.userData.vrmNodeConstraintManager=yield this._import(e)}))}_import(t){return FA(this,null,(function*(){var n;const r=this.parser.json;if(!(-1!==(null==(n=r.extensionsUsed)?void 0:n.indexOf(e.EXTENSION_NAME))))return null;const i=new $A,s=yield this.parser.getDependencies("node");return s.forEach(((t,n)=>{var a;const o=r.nodes[n],l=null==(a=null==o?void 0:o.extensions)?void 0:a[e.EXTENSION_NAME];if(null==l)return;const u=l.specVersion;if(!oM.has(u))return void console.warn(`VRMNodeConstraintLoaderPlugin: Unknown ${e.EXTENSION_NAME} specVersion "${u}"`);const c=l.constraint;if(null!=c.roll){const e=this._importRollConstraint(t,s,c.roll);i.addConstraint(e)}else if(null!=c.aim){const e=this._importAimConstraint(t,s,c.aim);i.addConstraint(e)}else if(null!=c.rotation){const e=this._importRotationConstraint(t,s,c.rotation);i.addConstraint(e)}})),t.scene.updateMatrixWorld(),i.setInitState(),i}))}_importRollConstraint(e,t,n){const{source:r,rollAxis:i,weight:s}=n,a=t[r],o=new aM(e,a);if(null!=i&&(o.rollAxis=i),null!=s&&(o.weight=s),this.helperRoot){const e=new kA(o);this.helperRoot.add(e)}return o}_importAimConstraint(e,t,n){const{source:r,aimAxis:i,weight:s}=n,a=t[r],o=new QA(e,a);if(null!=i&&(o.aimAxis=i),null!=s&&(o.weight=s),this.helperRoot){const e=new kA(o);this.helperRoot.add(e)}return o}_importRotationConstraint(e,t,n){const{source:r,weight:i}=n,s=t[r],a=new nM(e,s);if(null!=i&&(a.weight=i),this.helperRoot){const e=new kA(a);this.helperRoot.add(e)}return a}};lM.EXTENSION_NAME="VRMC_node_constraint";var uM=lM,cM=(e,t,n)=>new Promise(((r,i)=>{var s=e=>{try{o(n.next(e))}catch(t){i(t)}},a=e=>{try{o(n.throw(e))}catch(t){i(t)}},o=e=>e.done?r(e.value):Promise.resolve(e.value).then(s,a);o((n=n.apply(e,t)).next())})),hM=class{},dM=new Nr,pM=new Nr,fM=class extends hM{get type(){return"capsule"}constructor(e){var t,n,r,i;super(),this.offset=null!=(t=null==e?void 0:e.offset)?t:new Nr(0,0,0),this.tail=null!=(n=null==e?void 0:e.tail)?n:new Nr(0,0,0),this.radius=null!=(r=null==e?void 0:e.radius)?r:0,this.inside=null!=(i=null==e?void 0:e.inside)&&i}calculateCollision(e,t,n,r){dM.copy(this.offset).applyMatrix4(e),pM.copy(this.tail).applyMatrix4(e),pM.sub(dM);const i=pM.lengthSq();r.copy(t).sub(dM);const s=pM.dot(r);s<=0||(i<=s||pM.multiplyScalar(s/i),r.sub(pM));const a=this.inside?this.radius-n-r.length():r.length()-n-this.radius;return r.normalize(),this.inside&&r.negate(),a}},mM=new Nr,gM=new sr,vM=class extends hM{get type(){return"plane"}constructor(e){var t,n;super(),this.offset=null!=(t=null==e?void 0:e.offset)?t:new Nr(0,0,0),this.normal=null!=(n=null==e?void 0:e.normal)?n:new Nr(0,0,1)}calculateCollision(e,t,n,r){r.copy(this.offset).applyMatrix4(e),r.negate().add(t),gM.getNormalMatrix(e),mM.copy(this.normal).applyNormalMatrix(gM).normalize();const i=r.dot(mM)-n;return r.copy(mM),i}},yM=class extends hM{get type(){return"sphere"}constructor(e){var t,n,r;super(),this.offset=null!=(t=null==e?void 0:e.offset)?t:new Nr(0,0,0),this.radius=null!=(n=null==e?void 0:e.radius)?n:0,this.inside=null!=(r=null==e?void 0:e.inside)&&r}calculateCollision(e,t,n,r){r.copy(this.offset).applyMatrix4(e),r.negate().add(t);const i=this.inside?this.radius-n-r.length():r.length()-n-this.radius;return r.normalize(),this.inside&&r.negate(),i}},_M=new Nr,xM=class extends Ps{constructor(e){super(),this.worldScale=1,this._currentRadius=0,this._currentOffset=new Nr,this._currentTail=new Nr,this._shape=e,this._attrPos=new ps(new Float32Array(396),3),this.setAttribute("position",this._attrPos),this._attrIndex=new ps(new Uint16Array(264),1),this.setIndex(this._attrIndex),this._buildIndex(),this.update()}update(){let e=!1;const t=this._shape.radius/this.worldScale;this._currentRadius!==t&&(this._currentRadius=t,e=!0),this._currentOffset.equals(this._shape.offset)||(this._currentOffset.copy(this._shape.offset),e=!0);const n=_M.copy(this._shape.tail).divideScalar(this.worldScale);this._currentTail.distanceToSquared(n)>1e-10&&(this._currentTail.copy(n),e=!0),e&&this._buildPosition()}_buildPosition(){_M.copy(this._currentTail).sub(this._currentOffset);const e=_M.length()/this._currentRadius;for(let r=0;r<=16;r++){const t=r/16*Math.PI;this._attrPos.setXYZ(r,-Math.sin(t),-Math.cos(t),0),this._attrPos.setXYZ(17+r,e+Math.sin(t),Math.cos(t),0),this._attrPos.setXYZ(34+r,-Math.sin(t),0,-Math.cos(t)),this._attrPos.setXYZ(51+r,e+Math.sin(t),0,Math.cos(t))}for(let r=0;r<32;r++){const t=r/16*Math.PI;this._attrPos.setXYZ(68+r,0,Math.sin(t),Math.cos(t)),this._attrPos.setXYZ(100+r,e,Math.sin(t),Math.cos(t))}const t=Math.atan2(_M.y,Math.sqrt(_M.x*_M.x+_M.z*_M.z)),n=-Math.atan2(_M.z,_M.x);this.rotateZ(t),this.rotateY(n),this.scale(this._currentRadius,this._currentRadius,this._currentRadius),this.translate(this._currentOffset.x,this._currentOffset.y,this._currentOffset.z),this._attrPos.needsUpdate=!0}_buildIndex(){for(let e=0;e<34;e++){const t=(e+1)%34;this._attrIndex.setXY(2*e,e,t),this._attrIndex.setXY(68+2*e,34+e,34+t)}for(let e=0;e<32;e++){const t=(e+1)%32;this._attrIndex.setXY(136+2*e,68+e,68+t),this._attrIndex.setXY(200+2*e,100+e,100+t)}this._attrIndex.needsUpdate=!0}},AM=class extends Ps{constructor(e){super(),this.worldScale=1,this._currentOffset=new Nr,this._currentNormal=new Nr,this._shape=e,this._attrPos=new ps(new Float32Array(18),3),this.setAttribute("position",this._attrPos),this._attrIndex=new ps(new Uint16Array(10),1),this.setIndex(this._attrIndex),this._buildIndex(),this.update()}update(){let e=!1;this._currentOffset.equals(this._shape.offset)||(this._currentOffset.copy(this._shape.offset),e=!0),this._currentNormal.equals(this._shape.normal)||(this._currentNormal.copy(this._shape.normal),e=!0),e&&this._buildPosition()}_buildPosition(){this._attrPos.setXYZ(0,-.5,-.5,0),this._attrPos.setXYZ(1,.5,-.5,0),this._attrPos.setXYZ(2,.5,.5,0),this._attrPos.setXYZ(3,-.5,.5,0),this._attrPos.setXYZ(4,0,0,0),this._attrPos.setXYZ(5,0,0,.25),this.translate(this._currentOffset.x,this._currentOffset.y,this._currentOffset.z),this.lookAt(this._currentNormal),this._attrPos.needsUpdate=!0}_buildIndex(){this._attrIndex.setXY(0,0,1),this._attrIndex.setXY(2,1,2),this._attrIndex.setXY(4,2,3),this._attrIndex.setXY(6,3,0),this._attrIndex.setXY(8,4,5),this._attrIndex.needsUpdate=!0}},MM=class extends Ps{constructor(e){super(),this.worldScale=1,this._currentRadius=0,this._currentOffset=new Nr,this._shape=e,this._attrPos=new ps(new Float32Array(288),3),this.setAttribute("position",this._attrPos),this._attrIndex=new ps(new Uint16Array(192),1),this.setIndex(this._attrIndex),this._buildIndex(),this.update()}update(){let e=!1;const t=this._shape.radius/this.worldScale;this._currentRadius!==t&&(this._currentRadius=t,e=!0),this._currentOffset.equals(this._shape.offset)||(this._currentOffset.copy(this._shape.offset),e=!0),e&&this._buildPosition()}_buildPosition(){for(let e=0;e<32;e++){const t=e/16*Math.PI;this._attrPos.setXYZ(e,Math.cos(t),Math.sin(t),0),this._attrPos.setXYZ(32+e,0,Math.cos(t),Math.sin(t)),this._attrPos.setXYZ(64+e,Math.sin(t),0,Math.cos(t))}this.scale(this._currentRadius,this._currentRadius,this._currentRadius),this.translate(this._currentOffset.x,this._currentOffset.y,this._currentOffset.z),this._attrPos.needsUpdate=!0}_buildIndex(){for(let e=0;e<32;e++){const t=(e+1)%32;this._attrIndex.setXY(2*e,e,t),this._attrIndex.setXY(64+2*e,32+e,32+t),this._attrIndex.setXY(128+2*e,64+e,64+t)}this._attrIndex.needsUpdate=!0}},bM=new Nr,SM=class extends tu{constructor(e){if(super(),this.matrixAutoUpdate=!1,this.collider=e,this.collider.shape instanceof yM)this._geometry=new MM(this.collider.shape);else if(this.collider.shape instanceof fM)this._geometry=new xM(this.collider.shape);else{if(!(this.collider.shape instanceof vM))throw new Error("VRMSpringBoneColliderHelper: Unknown collider shape type detected");this._geometry=new AM(this.collider.shape)}const t=new wc({color:16711935,depthTest:!1,depthWrite:!1});this._line=new Fc(this._geometry,t),this.add(this._line)}dispose(){this._geometry.dispose()}updateMatrixWorld(e){this.collider.updateWorldMatrix(!0,!1),this.matrix.copy(this.collider.matrixWorld);const t=this.matrix.elements;this._geometry.worldScale=bM.set(t[0],t[1],t[2]).length(),this._geometry.update(),super.updateMatrixWorld(e)}},wM=class extends Ps{constructor(e){super(),this.worldScale=1,this._currentRadius=0,this._currentTail=new Nr,this._springBone=e,this._attrPos=new ps(new Float32Array(294),3),this.setAttribute("position",this._attrPos),this._attrIndex=new ps(new Uint16Array(194),1),this.setIndex(this._attrIndex),this._buildIndex(),this.update()}update(){let e=!1;const t=this._springBone.settings.hitRadius/this.worldScale;this._currentRadius!==t&&(this._currentRadius=t,e=!0),this._currentTail.equals(this._springBone.initialLocalChildPosition)||(this._currentTail.copy(this._springBone.initialLocalChildPosition),e=!0),e&&this._buildPosition()}_buildPosition(){for(let e=0;e<32;e++){const t=e/16*Math.PI;this._attrPos.setXYZ(e,Math.cos(t),Math.sin(t),0),this._attrPos.setXYZ(32+e,0,Math.cos(t),Math.sin(t)),this._attrPos.setXYZ(64+e,Math.sin(t),0,Math.cos(t))}this.scale(this._currentRadius,this._currentRadius,this._currentRadius),this.translate(this._currentTail.x,this._currentTail.y,this._currentTail.z),this._attrPos.setXYZ(96,0,0,0),this._attrPos.setXYZ(97,this._currentTail.x,this._currentTail.y,this._currentTail.z),this._attrPos.needsUpdate=!0}_buildIndex(){for(let e=0;e<32;e++){const t=(e+1)%32;this._attrIndex.setXY(2*e,e,t),this._attrIndex.setXY(64+2*e,32+e,32+t),this._attrIndex.setXY(128+2*e,64+e,64+t)}this._attrIndex.setXY(192,96,97),this._attrIndex.needsUpdate=!0}},EM=new Nr,TM=class extends tu{constructor(e){super(),this.matrixAutoUpdate=!1,this.springBone=e,this._geometry=new wM(this.springBone);const t=new wc({color:16776960,depthTest:!1,depthWrite:!1});this._line=new Fc(this._geometry,t),this.add(this._line)}dispose(){this._geometry.dispose()}updateMatrixWorld(e){this.springBone.bone.updateWorldMatrix(!0,!1),this.matrix.copy(this.springBone.bone.matrixWorld);const t=this.matrix.elements;this._geometry.worldScale=EM.set(t[0],t[1],t[2]).length(),this._geometry.update(),super.updateMatrixWorld(e)}},CM=class extends ki{constructor(e){super(),this.shape=e}},RM=new di;function PM(e){return e.invert?e.invert():e.getInverse(RM.copy(e)),e}var IM=class{constructor(e){this._inverseCache=new di,this._shouldUpdateInverse=!0,this.matrix=e;const t={set:(e,t,n)=>(this._shouldUpdateInverse=!0,e[t]=n,!0)};this._originalElements=e.elements,e.elements=new Proxy(e.elements,t)}get inverse(){return this._shouldUpdateInverse&&(PM(this._inverseCache.copy(this.matrix)),this._shouldUpdateInverse=!1),this._inverseCache}revert(){this.matrix.elements=this._originalElements}},BM=new di,LM=new Nr,DM=new Nr,UM=new Nr,NM=new Nr,FM=new Nr,OM=new Nr,kM=new Ur,HM=new di,zM=new di,GM=class{constructor(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[];var i,s,a,o,l,u;this._currentTail=new Nr,this._prevTail=new Nr,this._boneAxis=new Nr,this._worldSpaceBoneLength=0,this._center=null,this._initialLocalMatrix=new di,this._initialLocalRotation=new Ur,this._initialLocalChildPosition=new Nr,this.bone=e,this.bone.matrixAutoUpdate=!1,this.child=t,this.settings={hitRadius:null!=(i=n.hitRadius)?i:0,stiffness:null!=(s=n.stiffness)?s:1,gravityPower:null!=(a=n.gravityPower)?a:0,gravityDir:null!=(l=null==(o=n.gravityDir)?void 0:o.clone())?l:new Nr(0,-1,0),dragForce:null!=(u=n.dragForce)?u:.4},this.colliderGroups=r}get center(){return this._center}set center(e){var t;(null==(t=this._center)?void 0:t.userData.inverseCacheProxy)&&(this._center.userData.inverseCacheProxy.revert(),delete this._center.userData.inverseCacheProxy),this._center=e,this._center&&(this._center.userData.inverseCacheProxy||(this._center.userData.inverseCacheProxy=new IM(this._center.matrixWorld)))}get initialLocalChildPosition(){return this._initialLocalChildPosition}get _parentMatrixWorld(){return this.bone.parent?this.bone.parent.matrixWorld:BM}setInitState(){this._initialLocalMatrix.copy(this.bone.matrix),this._initialLocalRotation.copy(this.bone.quaternion),this.child?this._initialLocalChildPosition.copy(this.child.position):this._initialLocalChildPosition.copy(this.bone.position).normalize().multiplyScalar(.07);const e=this._getMatrixWorldToCenter(HM);this.bone.localToWorld(this._currentTail.copy(this._initialLocalChildPosition)).applyMatrix4(e),this._prevTail.copy(this._currentTail),this._boneAxis.copy(this._initialLocalChildPosition).normalize()}reset(){this.bone.quaternion.copy(this._initialLocalRotation),this.bone.updateMatrix(),this.bone.matrixWorld.multiplyMatrices(this._parentMatrixWorld,this.bone.matrix);const e=this._getMatrixWorldToCenter(HM);this.bone.localToWorld(this._currentTail.copy(this._initialLocalChildPosition)).applyMatrix4(e),this._prevTail.copy(this._currentTail)}update(e){if(e<=0)return;this._calcWorldSpaceBoneLength(),NM.setFromMatrixPosition(this.bone.matrixWorld);let t=this._getMatrixWorldToCenter(HM);FM.copy(NM).applyMatrix4(t);const n=kM.setFromRotationMatrix(t),r=zM.copy(t).multiply(this._parentMatrixWorld),i=DM.copy(this._boneAxis).applyMatrix4(this._initialLocalMatrix).applyMatrix4(r).sub(FM).normalize(),s=UM.copy(this.settings.gravityDir).applyQuaternion(n).normalize(),a=this._getMatrixCenterToWorld(HM);OM.copy(this._currentTail).add(LM.copy(this._currentTail).sub(this._prevTail).multiplyScalar(1-this.settings.dragForce)).add(LM.copy(i).multiplyScalar(this.settings.stiffness*e)).add(LM.copy(s).multiplyScalar(this.settings.gravityPower*e)).applyMatrix4(a),OM.sub(NM).normalize().multiplyScalar(this._worldSpaceBoneLength).add(NM),this._collision(OM),t=this._getMatrixWorldToCenter(HM),this._prevTail.copy(this._currentTail),this._currentTail.copy(LM.copy(OM).applyMatrix4(t));const o=PM(HM.copy(this._parentMatrixWorld).multiply(this._initialLocalMatrix)),l=kM.setFromUnitVectors(this._boneAxis,LM.copy(OM).applyMatrix4(o).normalize());this.bone.quaternion.copy(this._initialLocalRotation).multiply(l),this.bone.updateMatrix(),this.bone.matrixWorld.multiplyMatrices(this._parentMatrixWorld,this.bone.matrix)}_collision(e){this.colliderGroups.forEach((t=>{t.colliders.forEach((t=>{const n=t.shape.calculateCollision(t.matrixWorld,e,this.settings.hitRadius,LM);n<0&&(e.add(LM.multiplyScalar(-n)),e.sub(NM).normalize().multiplyScalar(this._worldSpaceBoneLength).add(NM))}))}))}_calcWorldSpaceBoneLength(){LM.setFromMatrixPosition(this.bone.matrixWorld),this.child?DM.setFromMatrixPosition(this.child.matrixWorld):(DM.copy(this._initialLocalChildPosition),DM.applyMatrix4(this.bone.matrixWorld)),this._worldSpaceBoneLength=LM.sub(DM).length()}_getMatrixCenterToWorld(e){return this._center?e.copy(this._center.matrixWorld):e.identity(),e}_getMatrixWorldToCenter(e){return this._center?e.copy(this._center.userData.inverseCacheProxy.inverse):e.identity(),e}};function VM(e,t){const n=[];let r=e;for(;null!==r;)n.unshift(r),r=r.parent;n.forEach((e=>{t(e)}))}function WM(e,t){e.children.forEach((e=>{t(e)||WM(e,t)}))}var jM=class{constructor(){this._joints=new Set,this._objectSpringBonesMap=new Map}get joints(){return this._joints}get springBones(){return console.warn("VRMSpringBoneManager: springBones is deprecated. use joints instead."),this._joints}get colliderGroups(){const e=new Set;return this._joints.forEach((t=>{t.colliderGroups.forEach((t=>{e.add(t)}))})),Array.from(e)}get colliders(){const e=new Set;return this.colliderGroups.forEach((t=>{t.colliders.forEach((t=>{e.add(t)}))})),Array.from(e)}addJoint(e){this._joints.add(e);let t=this._objectSpringBonesMap.get(e.bone);null==t&&(t=new Set,this._objectSpringBonesMap.set(e.bone,t)),t.add(e)}addSpringBone(e){console.warn("VRMSpringBoneManager: addSpringBone() is deprecated. use addJoint() instead."),this.addJoint(e)}deleteJoint(e){this._joints.delete(e);this._objectSpringBonesMap.get(e.bone).delete(e)}deleteSpringBone(e){console.warn("VRMSpringBoneManager: deleteSpringBone() is deprecated. use deleteJoint() instead."),this.deleteJoint(e)}setInitState(){const e=new Set,t=new Set,n=new Set;for(const r of this._joints)this._processSpringBone(r,e,t,n,(e=>e.setInitState()))}reset(){const e=new Set,t=new Set,n=new Set;for(const r of this._joints)this._processSpringBone(r,e,t,n,(e=>e.reset()))}update(e){const t=new Set,n=new Set,r=new Set;for(const i of this._joints)this._processSpringBone(i,t,n,r,(t=>t.update(e))),WM(i.bone,(e=>{var t,n;return(null!=(n=null==(t=this._objectSpringBonesMap.get(e))?void 0:t.size)?n:0)>0||(e.updateWorldMatrix(!1,!1),!1)}))}_processSpringBone(e,t,n,r,i){if(n.has(e))return;if(t.has(e))throw new Error("VRMSpringBoneManager: Circular dependency detected while updating springbones");t.add(e);const s=this._getDependencies(e);for(const a of s)VM(a,(e=>{const s=this._objectSpringBonesMap.get(e);if(s)for(const a of s)this._processSpringBone(a,t,n,r,i);else r.has(e)||(e.updateWorldMatrix(!1,!1),r.add(e))}));e.bone.updateMatrix(),e.bone.updateWorldMatrix(!1,!1),i(e),r.add(e.bone),n.add(e)}_getDependencies(e){const t=new Set,n=e.bone.parent;return n&&t.add(n),e.colliderGroups.forEach((e=>{e.colliders.forEach((e=>{t.add(e)}))})),t}},XM="VRMC_springBone_extended_collider",JM=new Set(["1.0","1.0-beta"]),YM=new Set(["1.0"]),KM=class e{get name(){return e.EXTENSION_NAME}constructor(e,t){var n;this.parser=e,this.jointHelperRoot=null==t?void 0:t.jointHelperRoot,this.colliderHelperRoot=null==t?void 0:t.colliderHelperRoot,this.useExtendedColliders=null==(n=null==t?void 0:t.useExtendedColliders)||n}afterRoot(e){return cM(this,null,(function*(){e.userData.vrmSpringBoneManager=yield this._import(e)}))}_import(e){return cM(this,null,(function*(){const t=yield this._v1Import(e);if(null!=t)return t;const n=yield this._v0Import(e);return null!=n?n:null}))}_v1Import(t){return cM(this,null,(function*(){var n,r,i,s,a;const o=t.parser.json;if(!(-1!==(null==(n=o.extensionsUsed)?void 0:n.indexOf(e.EXTENSION_NAME))))return null;const l=new jM,u=yield t.parser.getDependencies("node"),c=null==(r=o.extensions)?void 0:r[e.EXTENSION_NAME];if(!c)return null;const h=c.specVersion;if(!JM.has(h))return console.warn(`VRMSpringBoneLoaderPlugin: Unknown ${e.EXTENSION_NAME} specVersion "${h}"`),null;const d=null==(i=c.colliders)?void 0:i.map(((t,n)=>{var r,i,s,a,o,l,c,h,d,p,f,m,g,v,y;const _=u[t.node],x=t.shape,A=null==(r=t.extensions)?void 0:r[XM];if(this.useExtendedColliders&&null!=A){const t=A.specVersion;if(YM.has(t)){const e=A.shape;if(e.sphere)return this._importSphereCollider(_,{offset:(new Nr).fromArray(null!=(i=e.sphere.offset)?i:[0,0,0]),radius:null!=(s=e.sphere.radius)?s:0,inside:null!=(a=e.sphere.inside)&&a});if(e.capsule)return this._importCapsuleCollider(_,{offset:(new Nr).fromArray(null!=(o=e.capsule.offset)?o:[0,0,0]),radius:null!=(l=e.capsule.radius)?l:0,tail:(new Nr).fromArray(null!=(c=e.capsule.tail)?c:[0,0,0]),inside:null!=(h=e.capsule.inside)&&h});if(e.plane)return this._importPlaneCollider(_,{offset:(new Nr).fromArray(null!=(d=e.plane.offset)?d:[0,0,0]),normal:(new Nr).fromArray(null!=(p=e.plane.normal)?p:[0,0,1])})}else console.warn(`VRMSpringBoneLoaderPlugin: Unknown ${XM} specVersion "${t}". Fallbacking to the ${e.EXTENSION_NAME} definition`)}if(x.sphere)return this._importSphereCollider(_,{offset:(new Nr).fromArray(null!=(f=x.sphere.offset)?f:[0,0,0]),radius:null!=(m=x.sphere.radius)?m:0,inside:!1});if(x.capsule)return this._importCapsuleCollider(_,{offset:(new Nr).fromArray(null!=(g=x.capsule.offset)?g:[0,0,0]),radius:null!=(v=x.capsule.radius)?v:0,tail:(new Nr).fromArray(null!=(y=x.capsule.tail)?y:[0,0,0]),inside:!1});throw new Error(`VRMSpringBoneLoaderPlugin: The collider #${n} has no valid shape`)})),p=null==(s=c.colliderGroups)?void 0:s.map(((e,t)=>{var n;return{colliders:(null!=(n=e.colliders)?n:[]).map((e=>{const n=null==d?void 0:d[e];if(null==n)throw new Error(`VRMSpringBoneLoaderPlugin: The colliderGroup #${t} attempted to use a collider #${e} but not found`);return n})),name:e.name}}));return null==(a=c.springs)||a.forEach(((e,t)=>{var n;const r=e.joints,i=null==(n=e.colliderGroups)?void 0:n.map((e=>{const n=null==p?void 0:p[e];if(null==n)throw new Error(`VRMSpringBoneLoaderPlugin: The spring #${t} attempted to use a colliderGroup ${e} but not found`);return n})),s=null!=e.center?u[e.center]:void 0;let a;r.forEach((e=>{if(a){const t=a.node,n=u[t],r=e.node,o=u[r],c={hitRadius:a.hitRadius,dragForce:a.dragForce,gravityPower:a.gravityPower,stiffness:a.stiffness,gravityDir:null!=a.gravityDir?(new Nr).fromArray(a.gravityDir):void 0},h=this._importJoint(n,o,c,i);s&&(h.center=s),l.addJoint(h)}a=e}))})),l.setInitState(),l}))}_v0Import(e){return cM(this,null,(function*(){var t,n,r;const i=e.parser.json;if(!(-1!==(null==(t=i.extensionsUsed)?void 0:t.indexOf("VRM"))))return null;const s=null==(n=i.extensions)?void 0:n.VRM,a=null==s?void 0:s.secondaryAnimation;if(!a)return null;const o=null==a?void 0:a.boneGroups;if(!o)return null;const l=new jM,u=yield e.parser.getDependencies("node"),c=null==(r=a.colliderGroups)?void 0:r.map((e=>{var t;const n=u[e.node];return{colliders:(null!=(t=e.colliders)?t:[]).map(((e,t)=>{var r,i,s;const a=new Nr(0,0,0);return e.offset&&a.set(null!=(r=e.offset.x)?r:0,null!=(i=e.offset.y)?i:0,e.offset.z?-e.offset.z:0),this._importSphereCollider(n,{offset:a,radius:null!=(s=e.radius)?s:0,inside:!1})}))}}));return null==o||o.forEach(((e,t)=>{const n=e.bones;n&&n.forEach((n=>{var r,i,s,a;const o=u[n],h=new Nr;e.gravityDir?h.set(null!=(r=e.gravityDir.x)?r:0,null!=(i=e.gravityDir.y)?i:0,null!=(s=e.gravityDir.z)?s:0):h.set(0,-1,0);const d=null!=e.center?u[e.center]:void 0,p={hitRadius:e.hitRadius,dragForce:e.dragForce,gravityPower:e.gravityPower,stiffness:e.stiffiness,gravityDir:h},f=null==(a=e.colliderGroups)?void 0:a.map((e=>{const n=null==c?void 0:c[e];if(null==n)throw new Error(`VRMSpringBoneLoaderPlugin: The spring #${t} attempted to use a colliderGroup ${e} but not found`);return n}));o.traverse((e=>{var t;const n=null!=(t=e.children[0])?t:null,r=this._importJoint(e,n,p,f);d&&(r.center=d),l.addJoint(r)}))}))})),e.scene.updateMatrixWorld(),l.setInitState(),l}))}_importJoint(e,t,n,r){const i=new GM(e,t,n,r);if(this.jointHelperRoot){const e=new TM(i);this.jointHelperRoot.add(e),e.renderOrder=this.jointHelperRoot.renderOrder}return i}_importSphereCollider(e,t){const n=new yM(t),r=new CM(n);if(e.add(r),this.colliderHelperRoot){const e=new SM(r);this.colliderHelperRoot.add(e),e.renderOrder=this.colliderHelperRoot.renderOrder}return r}_importCapsuleCollider(e,t){const n=new fM(t),r=new CM(n);if(e.add(r),this.colliderHelperRoot){const e=new SM(r);this.colliderHelperRoot.add(e),e.renderOrder=this.colliderHelperRoot.renderOrder}return r}_importPlaneCollider(e,t){const n=new vM(t),r=new CM(n);if(e.add(r),this.colliderHelperRoot){const e=new SM(r);this.colliderHelperRoot.add(e),e.renderOrder=this.colliderHelperRoot.renderOrder}return r}};KM.EXTENSION_NAME="VRMC_springBone";var qM=KM,QM=class{get name(){return"VRMLoaderPlugin"}constructor(e,t){var n,r,i,s,a,o,l,u,c,h;this.parser=e;const d=null==t?void 0:t.helperRoot,p=null==t?void 0:t.autoUpdateHumanBones;this.expressionPlugin=null!=(n=null==t?void 0:t.expressionPlugin)?n:new K_(e),this.firstPersonPlugin=null!=(r=null==t?void 0:t.firstPersonPlugin)?r:new $_(e),this.humanoidPlugin=null!=(i=null==t?void 0:t.humanoidPlugin)?i:new yx(e,{helperRoot:d,autoUpdateHumanBones:p}),this.lookAtPlugin=null!=(s=null==t?void 0:t.lookAtPlugin)?s:new eA(e,{helperRoot:d}),this.metaPlugin=null!=(a=null==t?void 0:t.metaPlugin)?a:new nA(e),this.mtoonMaterialPlugin=null!=(o=null==t?void 0:t.mtoonMaterialPlugin)?o:new bA(e),this.materialsHDREmissiveMultiplierPlugin=null!=(l=null==t?void 0:t.materialsHDREmissiveMultiplierPlugin)?l:new wA(e),this.materialsV0CompatPlugin=null!=(u=null==t?void 0:t.materialsV0CompatPlugin)?u:new NA(e),this.springBonePlugin=null!=(c=null==t?void 0:t.springBonePlugin)?c:new qM(e,{colliderHelperRoot:d,jointHelperRoot:d}),this.nodeConstraintPlugin=null!=(h=null==t?void 0:t.nodeConstraintPlugin)?h:new uM(e,{helperRoot:d})}beforeRoot(){return P_(this,null,(function*(){yield this.materialsV0CompatPlugin.beforeRoot(),yield this.mtoonMaterialPlugin.beforeRoot()}))}loadMesh(e){return P_(this,null,(function*(){return yield this.mtoonMaterialPlugin.loadMesh(e)}))}getMaterialType(e){const t=this.mtoonMaterialPlugin.getMaterialType(e);return null!=t?t:null}extendMaterialParams(e,t){return P_(this,null,(function*(){yield this.materialsHDREmissiveMultiplierPlugin.extendMaterialParams(e,t),yield this.mtoonMaterialPlugin.extendMaterialParams(e,t)}))}afterRoot(e){return P_(this,null,(function*(){yield this.metaPlugin.afterRoot(e),yield this.humanoidPlugin.afterRoot(e),yield this.expressionPlugin.afterRoot(e),yield this.lookAtPlugin.afterRoot(e),yield this.firstPersonPlugin.afterRoot(e),yield this.springBonePlugin.afterRoot(e),yield this.nodeConstraintPlugin.afterRoot(e),yield this.mtoonMaterialPlugin.afterRoot(e);const t=e.userData.vrmMeta,n=e.userData.vrmHumanoid;if(t&&n){const r=new iA({scene:e.scene,expressionManager:e.userData.vrmExpressionManager,firstPerson:e.userData.vrmFirstPerson,humanoid:n,lookAt:e.userData.vrmLookAt,meta:t,materials:e.userData.vrmMToonMaterials,springBoneManager:e.userData.vrmSpringBoneManager,nodeConstraintManager:e.userData.vrmNodeConstraintManager});e.userData.vrm=r}}))}};function ZM(e){if(Object.values(e).forEach((e=>{if(null==e?void 0:e.isTexture){e.dispose()}})),e.isShaderMaterial){const t=e.uniforms;t&&Object.values(t).forEach((e=>{const t=e.value;if(null==t?void 0:t.isTexture){t.dispose()}}))}e.dispose()}function $M(e){const t=e.geometry;t&&t.dispose();const n=e.skeleton;n&&n.dispose();const r=e.material;r&&(Array.isArray(r)?r.forEach((e=>ZM(e))):r&&ZM(r))}var eb=class{constructor(){}};eb.deepDispose=function(e){e.traverse($M)},eb.removeUnnecessaryJoints=function(e,t){var n;const r=null!=(n=null==t?void 0:t.experimentalSameBoneCounts)&&n,i=[];e.traverse((e=>{"SkinnedMesh"===e.type&&i.push(e)}));const s=new Map;let a=0;for(const o of i){const e=o.geometry.getAttribute("skinIndex"),t=[],n=[],r={},i=e.array;for(let s=0;s<i.length;s++){const e=i[s];null==r[e]&&(r[e]=t.length,t.push(o.skeleton.bones[e]),n.push(o.skeleton.boneInverses[e])),i[s]=r[e]}e.copyArray(i),e.needsUpdate=!0,s.set(o,{bones:t,boneInverses:n}),a=Math.max(a,t.length)}for(const o of i){const{bones:e,boneInverses:t}=s.get(o);if(r)for(let r=e.length;r<a;r++)e[r]=e[0],t[r]=t[0];const n=new qu(e,t);o.bind(n,new di)}},eb.removeUnnecessaryVertices=function(e){const t=new Map;e.traverse((e=>{var n,r,i,s;if(!e.isMesh)return;const a=e,o=a.geometry,l=o.index;if(null==l)return;const u=t.get(o);if(null!=u)return void(a.geometry=u);const c=new Ps;c.name=o.name,c.morphTargetsRelative=o.morphTargetsRelative,o.groups.forEach((e=>{c.addGroup(e.start,e.count,e.materialIndex)})),c.boundingBox=null!=(r=null==(n=o.boundingBox)?void 0:n.clone())?r:null,c.boundingSphere=null!=(s=null==(i=o.boundingSphere)?void 0:i.clone())?s:null,c.setDrawRange(o.drawRange.start,o.drawRange.count),c.userData=o.userData,t.set(o,c);const h=[],d=[];{const e=l.array,t=new e.constructor(e.length);let n=0;for(let r=0;r<e.length;r++){const i=e[r];let s=h[i];null==s&&(h[i]=n,d[n]=i,s=n,n++),t[r]=s}c.setIndex(new ps(t,1,!1))}Object.keys(o.attributes).forEach((e=>{const t=o.attributes[e];if(t.isInterleavedBufferAttribute)throw new Error("removeUnnecessaryVertices: InterleavedBufferAttribute is not supported");const n=t.array,{itemSize:r,normalized:i}=t,s=new n.constructor(d.length*r);d.forEach(((e,t)=>{for(let i=0;i<r;i++)s[t*r+i]=n[e*r+i]})),c.setAttribute(e,new ps(s,r,i))}));let p=!0;Object.keys(o.morphAttributes).forEach((e=>{c.morphAttributes[e]=[];const t=o.morphAttributes[e];for(let n=0;n<t.length;n++){const r=t[n];if(r.isInterleavedBufferAttribute)throw new Error("removeUnnecessaryVertices: InterleavedBufferAttribute is not supported");const i=r.array,{itemSize:s,normalized:a}=r,o=new i.constructor(d.length*s);d.forEach(((e,t)=>{for(let n=0;n<s;n++)o[t*s+n]=i[e*s+n]})),p=p&&o.every((e=>0===e)),c.morphAttributes[e][n]=new ps(o,s,a)}})),p&&(c.morphAttributes={}),a.geometry=c})),Array.from(t.keys()).forEach((e=>{e.dispose()}))},eb.rotateVRM0=function(e){var t;"0"===(null==(t=e.meta)?void 0:t.metaVersion)&&(e.scene.rotation.y=Math.PI)};var tb=(e,t,n)=>new Promise(((r,i)=>{var s=e=>{try{o(n.next(e))}catch(t){i(t)}},a=e=>{try{o(n.throw(e))}catch(t){i(t)}},o=e=>e.done?r(e.value):Promise.resolve(e.value).then(s,a);o((n=n.apply(e,t)).next())}));var nb={Aa:"aa",Ih:"ih",Ou:"ou",Ee:"ee",Oh:"oh",Blink:"blink",Happy:"happy",Angry:"angry",Sad:"sad",Relaxed:"relaxed",LookUp:"lookUp",Surprised:"surprised",LookDown:"lookDown",LookLeft:"lookLeft",LookRight:"lookRight",BlinkLeft:"blinkLeft",BlinkRight:"blinkRight",Neutral:"neutral"};var rb=new ts,ib=class e{constructor(e){let{material:t,type:n,targetValue:r,targetAlpha:i}=e;this.material=t,this.type=n,this.targetValue=r,this.targetAlpha=null!=i?i:1;const s=this._initColorBindState(),a=this._initAlphaBindState();this._state={color:s,alpha:a}}applyWeight(e){const{color:t,alpha:n}=this._state;if(null!=t){const{propertyName:n,deltaValue:r}=t,i=this.material[n];void 0!=i&&i.add(rb.copy(r).multiplyScalar(e))}if(null!=n){const{propertyName:t,deltaValue:r}=n;void 0!=this.material[t]&&(this.material[t]+=r*e)}}clearAppliedWeight(){const{color:e,alpha:t}=this._state;if(null!=e){const{propertyName:t,initialValue:n}=e,r=this.material[t];void 0!=r&&r.copy(n)}if(null!=t){const{propertyName:e,initialValue:n}=t;void 0!=this.material[e]&&(this.material[e]=n)}}_initColorBindState(){var e,t,n;const{material:r,type:i,targetValue:s}=this,a=this._getPropertyNameMap(),o=null!=(t=null==(e=null==a?void 0:a[i])?void 0:e[0])?t:null;if(null==o)return console.warn(`Tried to add a material color bind to the material ${null!=(n=r.name)?n:"(no name)"}, the type ${i} but the material or the type is not supported.`),null;const l=r[o].clone();return{propertyName:o,initialValue:l,deltaValue:new ts(s.r-l.r,s.g-l.g,s.b-l.b)}}_initAlphaBindState(){var e,t,n;const{material:r,type:i,targetAlpha:s}=this,a=this._getPropertyNameMap(),o=null!=(t=null==(e=null==a?void 0:a[i])?void 0:e[1])?t:null;if(null==o&&1!==s)return console.warn(`Tried to add a material alpha bind to the material ${null!=(n=r.name)?n:"(no name)"}, the type ${i} but the material or the type does not support alpha.`),null;if(null==o)return null;const l=r[o];return{propertyName:o,initialValue:l,deltaValue:s-l}}_getPropertyNameMap(){var t,n;return null!=(n=null==(t=Object.entries(e._propertyNameMapMap).find((e=>{let[t]=e;return!0===this.material[t]})))?void 0:t[1])?n:null}};ib._propertyNameMapMap={isMeshStandardMaterial:{color:["color","opacity"],emissionColor:["emissive",null]},isMeshBasicMaterial:{color:["color","opacity"]},isMToonMaterial:{color:["color","opacity"],emissionColor:["emissive",null],outlineColor:["outlineColorFactor",null],matcapColor:["matcapFactor",null],rimColor:["parametricRimColorFactor",null],shadeColor:["shadeColorFactor",null]}};var sb=new ir,ab=class e{constructor(t){let{material:n,scale:r,offset:i}=t;var s,a;this.material=n,this.scale=r,this.offset=i;const o=null==(s=Object.entries(e._propertyNamesMap).find((e=>{let[t]=e;return!0===n[t]})))?void 0:s[1];null==o?(console.warn(`Tried to add a texture transform bind to the material ${null!=(a=n.name)?a:"(no name)"} but the material is not supported.`),this._properties=[]):(this._properties=[],o.forEach((e=>{var t;const s=null==(t=n[e])?void 0:t.clone();if(!s)return null;n[e]=s;const a=s.offset.clone(),o=s.repeat.clone(),l=i.clone().sub(a),u=r.clone().sub(o);this._properties.push({name:e,initialOffset:a,deltaOffset:l,initialScale:o,deltaScale:u})})))}applyWeight(e){this._properties.forEach((t=>{const n=this.material[t.name];void 0!==n&&(n.offset.add(sb.copy(t.deltaOffset).multiplyScalar(e)),n.repeat.add(sb.copy(t.deltaScale).multiplyScalar(e)))}))}clearAppliedWeight(){this._properties.forEach((e=>{const t=this.material[e.name];void 0!==t&&(t.offset.copy(e.initialOffset),t.repeat.copy(e.initialScale))}))}};ab._propertyNamesMap={isMeshStandardMaterial:["map","emissiveMap","bumpMap","normalMap","displacementMap","roughnessMap","metalnessMap","alphaMap"],isMeshBasicMaterial:["map","specularMap","alphaMap"],isMToonMaterial:["map","normalMap","emissiveMap","shadeMultiplyTexture","rimMultiplyTexture","outlineWidthMultiplyTexture","uvAnimationMaskTexture"]};var ob=class e{constructor(t,n){this._firstPersonOnlyLayer=e.DEFAULT_FIRSTPERSON_ONLY_LAYER,this._thirdPersonOnlyLayer=e.DEFAULT_THIRDPERSON_ONLY_LAYER,this._initializedLayers=!1,this.humanoid=t,this.meshAnnotations=n}copy(e){if(this.humanoid!==e.humanoid)throw new Error("VRMFirstPerson: humanoid must be same in order to copy");return this.meshAnnotations=e.meshAnnotations.map((e=>({meshes:e.meshes.concat(),type:e.type}))),this}clone(){return new e(this.humanoid,this.meshAnnotations).copy(this)}get firstPersonOnlyLayer(){return this._firstPersonOnlyLayer}get thirdPersonOnlyLayer(){return this._thirdPersonOnlyLayer}setup(){let{firstPersonOnlyLayer:t=e.DEFAULT_FIRSTPERSON_ONLY_LAYER,thirdPersonOnlyLayer:n=e.DEFAULT_THIRDPERSON_ONLY_LAYER}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this._initializedLayers||(this._firstPersonOnlyLayer=t,this._thirdPersonOnlyLayer=n,this.meshAnnotations.forEach((e=>{e.meshes.forEach((t=>{"firstPersonOnly"===e.type?(t.layers.set(this._firstPersonOnlyLayer),t.traverse((e=>e.layers.set(this._firstPersonOnlyLayer)))):"thirdPersonOnly"===e.type?(t.layers.set(this._thirdPersonOnlyLayer),t.traverse((e=>e.layers.set(this._thirdPersonOnlyLayer)))):"auto"===e.type&&this._createHeadlessModel(t)}))})),this._initializedLayers=!0)}_excludeTriangles(e,t,n,r){let i=0;if(null!=t&&t.length>0)for(let s=0;s<e.length;s+=3){const a=e[s],o=e[s+1],l=e[s+2],u=t[a],c=n[a];if(u[0]>0&&r.includes(c[0]))continue;if(u[1]>0&&r.includes(c[1]))continue;if(u[2]>0&&r.includes(c[2]))continue;if(u[3]>0&&r.includes(c[3]))continue;const h=t[o],d=n[o];if(h[0]>0&&r.includes(d[0]))continue;if(h[1]>0&&r.includes(d[1]))continue;if(h[2]>0&&r.includes(d[2]))continue;if(h[3]>0&&r.includes(d[3]))continue;const p=t[l],f=n[l];p[0]>0&&r.includes(f[0])||(p[1]>0&&r.includes(f[1])||p[2]>0&&r.includes(f[2])||p[3]>0&&r.includes(f[3])||(e[i++]=a,e[i++]=o,e[i++]=l))}return i}_createErasedMesh(e,t){const n=new ju(e.geometry.clone(),e.material);n.name=`${e.name}(erase)`,n.frustumCulled=e.frustumCulled,n.layers.set(this._firstPersonOnlyLayer);const r=n.geometry,i=r.getAttribute("skinIndex"),s=i instanceof Mf?[]:i.array,a=[];for(let f=0;f<s.length;f+=4)a.push([s[f],s[f+1],s[f+2],s[f+3]]);const o=r.getAttribute("skinWeight"),l=o instanceof Mf?[]:o.array,u=[];for(let f=0;f<l.length;f+=4)u.push([l[f],l[f+1],l[f+2],l[f+3]]);const c=r.getIndex();if(!c)throw new Error("The geometry doesn't have an index buffer");const h=Array.from(c.array),d=this._excludeTriangles(h,u,a,t),p=[];for(let f=0;f<d;f++)p[f]=h[f];return r.setIndex(p),e.onBeforeRender&&(n.onBeforeRender=e.onBeforeRender),n.bind(new qu(e.skeleton.bones,e.skeleton.boneInverses),new di),n}_createHeadlessModelForSkinnedMesh(e,t){const n=[];if(t.skeleton.bones.forEach(((e,t)=>{this._isEraseTarget(e)&&n.push(t)})),!n.length)return t.layers.enable(this._thirdPersonOnlyLayer),void t.layers.enable(this._firstPersonOnlyLayer);t.layers.set(this._thirdPersonOnlyLayer);const r=this._createErasedMesh(t,n);e.add(r)}_createHeadlessModel(e){if("Group"===e.type)if(e.layers.set(this._thirdPersonOnlyLayer),this._isEraseTarget(e))e.traverse((e=>e.layers.set(this._thirdPersonOnlyLayer)));else{const t=new tu;t.name=`_headless_${e.name}`,t.layers.set(this._firstPersonOnlyLayer),e.parent.add(t),e.children.filter((e=>"SkinnedMesh"===e.type)).forEach((e=>{const n=e;this._createHeadlessModelForSkinnedMesh(t,n)}))}else if("SkinnedMesh"===e.type){const t=e;this._createHeadlessModelForSkinnedMesh(e.parent,t)}else this._isEraseTarget(e)&&(e.layers.set(this._thirdPersonOnlyLayer),e.traverse((e=>e.layers.set(this._thirdPersonOnlyLayer))))}_isEraseTarget(e){return e===this.humanoid.getRawBoneNode("head")||!!e.parent&&this._isEraseTarget(e.parent)}};ob.DEFAULT_FIRSTPERSON_ONLY_LAYER=9,ob.DEFAULT_THIRDPERSON_ONLY_LAYER=10;new Nr,new Nr,new Ur;var lb={hips:null,spine:"hips",chest:"spine",upperChest:"chest",neck:"upperChest",head:"neck",leftEye:"head",rightEye:"head",jaw:"head",leftUpperLeg:"hips",leftLowerLeg:"leftUpperLeg",leftFoot:"leftLowerLeg",leftToes:"leftFoot",rightUpperLeg:"hips",rightLowerLeg:"rightUpperLeg",rightFoot:"rightLowerLeg",rightToes:"rightFoot",leftShoulder:"upperChest",leftUpperArm:"leftShoulder",leftLowerArm:"leftUpperArm",leftHand:"leftLowerArm",rightShoulder:"upperChest",rightUpperArm:"rightShoulder",rightLowerArm:"rightUpperArm",rightHand:"rightLowerArm",leftThumbMetacarpal:"leftHand",leftThumbProximal:"leftThumbMetacarpal",leftThumbDistal:"leftThumbProximal",leftIndexProximal:"leftHand",leftIndexIntermediate:"leftIndexProximal",leftIndexDistal:"leftIndexIntermediate",leftMiddleProximal:"leftHand",leftMiddleIntermediate:"leftMiddleProximal",leftMiddleDistal:"leftMiddleIntermediate",leftRingProximal:"leftHand",leftRingIntermediate:"leftRingProximal",leftRingDistal:"leftRingIntermediate",leftLittleProximal:"leftHand",leftLittleIntermediate:"leftLittleProximal",leftLittleDistal:"leftLittleIntermediate",rightThumbMetacarpal:"rightHand",rightThumbProximal:"rightThumbMetacarpal",rightThumbDistal:"rightThumbProximal",rightIndexProximal:"rightHand",rightIndexIntermediate:"rightIndexProximal",rightIndexDistal:"rightIndexIntermediate",rightMiddleProximal:"rightHand",rightMiddleIntermediate:"rightMiddleProximal",rightMiddleDistal:"rightMiddleIntermediate",rightRingProximal:"rightHand",rightRingIntermediate:"rightRingProximal",rightRingDistal:"rightRingIntermediate",rightLittleProximal:"rightHand",rightLittleIntermediate:"rightLittleProximal",rightLittleDistal:"rightLittleIntermediate"};new Nr,new Ur,new Nr,new Ur,new Nr,new Ur,new Ur,new Nr,new Nr;var ub=Math.sqrt(2)/2,cb=(new Ur(0,0,-ub,ub),new Nr(0,1,0),new Nr),hb=new Nr;function db(e,t){return e.matrixWorld.decompose(cb,t,hb),t}function pb(e){return[Math.atan2(-e.z,e.x),Math.atan2(e.y,Math.sqrt(e.x*e.x+e.z*e.z))]}function fb(e){const t=Math.round(e/2/Math.PI);return e-2*Math.PI*t}var mb=new Nr(0,0,1),gb=new Nr,vb=new Nr,yb=new Nr,_b=new Ur,xb=new Ur,Ab=new Ur,Mb=new Ur,bb=new Mi,Sb=class e{constructor(e,t){this.offsetFromHeadBone=new Nr,this.autoUpdate=!0,this.faceFront=new Nr(0,0,1),this.humanoid=e,this.applier=t,this._yaw=0,this._pitch=0,this._needsUpdate=!0,this._restHeadWorldQuaternion=this.getLookAtWorldQuaternion(new Ur)}get yaw(){return this._yaw}set yaw(e){this._yaw=e,this._needsUpdate=!0}get pitch(){return this._pitch}set pitch(e){this._pitch=e,this._needsUpdate=!0}get euler(){return console.warn("VRMLookAt: euler is deprecated. use getEuler() instead."),this.getEuler(new Mi)}getEuler(e){return e.set(rr.DEG2RAD*this._pitch,rr.DEG2RAD*this._yaw,0,"YXZ")}copy(e){if(this.humanoid!==e.humanoid)throw new Error("VRMLookAt: humanoid must be same in order to copy");return this.offsetFromHeadBone.copy(e.offsetFromHeadBone),this.applier=e.applier,this.autoUpdate=e.autoUpdate,this.target=e.target,this.faceFront.copy(e.faceFront),this}clone(){return new e(this.humanoid,this.applier).copy(this)}reset(){this._yaw=0,this._pitch=0,this._needsUpdate=!0}getLookAtWorldPosition(e){const t=this.humanoid.getRawBoneNode("head");return e.copy(this.offsetFromHeadBone).applyMatrix4(t.matrixWorld)}getLookAtWorldQuaternion(e){return db(this.humanoid.getRawBoneNode("head"),e)}getFaceFrontQuaternion(e){if(this.faceFront.distanceToSquared(mb)<.01)return e.copy(this._restHeadWorldQuaternion).invert();const[t,n]=pb(this.faceFront);return bb.set(0,.5*Math.PI+t,n,"YZX"),e.setFromEuler(bb).premultiply(Mb.copy(this._restHeadWorldQuaternion).invert())}getLookAtWorldDirection(e){return this.getLookAtWorldQuaternion(xb),this.getFaceFrontQuaternion(Ab),e.copy(mb).applyQuaternion(xb).applyQuaternion(Ab).applyEuler(this.getEuler(bb))}lookAt(e){const t=_b.copy(this._restHeadWorldQuaternion).multiply(((n=this.getLookAtWorldQuaternion(xb)).invert?n.invert():n.inverse(),n));var n;const r=this.getLookAtWorldPosition(vb),i=yb.copy(e).sub(r).applyQuaternion(t).normalize(),[s,a]=pb(this.faceFront),[o,l]=pb(i),u=fb(o-s),c=fb(a-l);this._yaw=rr.RAD2DEG*u,this._pitch=rr.RAD2DEG*c,this._needsUpdate=!0}update(e){null!=this.target&&this.autoUpdate&&this.lookAt(this.target.getWorldPosition(gb)),this._needsUpdate&&(this._needsUpdate=!1,this.applier.applyYawPitch(this._yaw,this._pitch))}};Sb.EULER_ORDER="YXZ";var wb=Sb,Eb=(new Nr(0,0,1),new Ur,new Ur,new Mi(0,0,0,"YXZ"),180/Math.PI),Tb=new Mi,Cb=class extends ki{constructor(e){super(),this.vrmLookAt=e,this.type="VRMLookAtQuaternionProxy";const t=this.rotation._onChangeCallback;this.rotation._onChange((()=>{t(),this._applyToLookAt()}));const n=this.quaternion._onChangeCallback;this.quaternion._onChange((()=>{n(),this._applyToLookAt()}))}_applyToLookAt(){Tb.setFromQuaternion(this.quaternion,wb.EULER_ORDER),this.vrmLookAt.yaw=Eb*Tb.y,this.vrmLookAt.pitch=Eb*Tb.x}};function Rb(e,t){const n=[],r=function(e,t,n){var r,i;const s=new Map,a=new Map;for(const[o,l]of e.humanoidTracks.rotation.entries()){const e=null==(r=t.getNormalizedBoneNode(o))?void 0:r.name;if(null!=e){const t=new Xd(`${e}.quaternion`,l.times,l.values.map(((e,t)=>"0"===n&&t%2===0?-e:e)));a.set(o,t)}}for(const[o,l]of e.humanoidTracks.translation.entries()){const r=null==(i=t.getNormalizedBoneNode(o))?void 0:i.name;if(null!=r){const i=e.restHipsPosition.y,a=t.normalizedRestPose.hips.position[1]/i,u=l.clone();u.values=u.values.map(((e,t)=>("0"===n&&t%3!==1?-e:e)*a)),u.name=`${r}.position`,s.set(o,u)}}return{translation:s,rotation:a}}(e,t.humanoid,t.meta.metaVersion);if(n.push(...r.translation.values()),n.push(...r.rotation.values()),null!=t.expressionManager){const r=function(e,t){const n=new Map,r=new Map;for(const[i,s]of e.expressionTracks.preset.entries()){const e=t.getExpressionTrackName(i);if(null!=e){const t=s.clone();t.name=e,n.set(i,t)}}for(const[i,s]of e.expressionTracks.custom.entries()){const e=t.getExpressionTrackName(i);if(null!=e){const t=s.clone();t.name=e,r.set(i,t)}}return{preset:n,custom:r}}(e,t.expressionManager);n.push(...r.preset.values()),n.push(...r.custom.values())}if(null!=t.lookAt){let r=t.scene.children.find((e=>e instanceof Cb));null==r?(console.warn("createVRMAnimationClip: VRMLookAtQuaternionProxy is not found. Creating a new one automatically. To suppress this warning, create a VRMLookAtQuaternionProxy manually"),r=new Cb(t.lookAt),r.name="VRMLookAtQuaternionProxy",t.scene.add(r)):null==r.name&&(console.warn("createVRMAnimationClip: VRMLookAtQuaternionProxy is found but its name is not set. Setting the name automatically. To suppress this warning, set the name manually"),r.name="VRMLookAtQuaternionProxy");const i=function(e,t){if(null==e.lookAtTrack)return null;const n=e.lookAtTrack.clone();return n.name=t,n}(e,`${r.name}.quaternion`);null!=i&&n.push(i)}return new Kd("Clip",e.duration,n)}var Pb=class{constructor(){this.duration=0,this.restHipsPosition=new Nr,this.humanoidTracks={translation:new Map,rotation:new Map},this.expressionTracks={preset:new Map,custom:new Map},this.lookAtTrack=null}};function Ib(e,t){const n=e.length,r=[];let i=[],s=0;for(let a=0;a<n;a++){const n=e[a];s<=0&&(s=t,i=[],r.push(i)),i.push(n),s--}return r}var Bb=new di,Lb=new Nr,Db=new Ur,Ub=new Ur,Nb=new Ur,Fb=new Set(["1.0","1.0-draft"]),Ob=new Set(Object.values(nb)),kb=class{constructor(e){this.parser=e}get name(){return"VRMC_vrm_animation"}afterRoot(e){return tb(this,null,(function*(){var t,n,r;const i=e.parser.json,s=i.extensionsUsed;if(null==s||-1==s.indexOf(this.name))return;const a=null==(t=i.extensions)?void 0:t[this.name];if(null==a)return;const o=a.specVersion;if(!Fb.has(o))return void console.warn(`VRMAnimationLoaderPlugin: Unknown VRMC_vrm_animation spec version: ${o}`);"1.0-draft"===o&&console.warn("VRMAnimationLoaderPlugin: Using a draft spec version: 1.0-draft. Some behaviors may be different. Consider updating the animation file.");const l=this._createNodeMap(a),u=yield this._createBoneWorldMatrixMap(e,a),c=null==(r=null==(n=a.humanoid)?void 0:n.humanBones.hips)?void 0:r.node,h=null!=c?yield e.parser.getDependency("node",c):null,d=new Nr;null==h||h.getWorldPosition(d);const p=e.animations.map(((e,t)=>{const n=i.animations[t],r=this._parseAnimation(e,n,l,u);return r.restHipsPosition=d,r}));e.userData.vrmAnimations=p}))}_createNodeMap(e){var t,n,r,i,s;const a=new Map,o=new Map,l=null==(t=e.humanoid)?void 0:t.humanBones;l&&Object.entries(l).forEach((e=>{let[t,n]=e;const r=null==n?void 0:n.node;null!=r&&a.set(r,t)}));const u=null==(n=e.expressions)?void 0:n.preset;u&&Object.entries(u).forEach((e=>{let[t,n]=e;const r=null==n?void 0:n.node;null!=r&&o.set(r,t)}));const c=null==(r=e.expressions)?void 0:r.custom;c&&Object.entries(c).forEach((e=>{let[t,n]=e;const{node:r}=n;o.set(r,t)}));const h=null!=(s=null==(i=e.lookAt)?void 0:i.node)?s:null;return{humanoidIndexToName:a,expressionsIndexToName:o,lookAtIndex:h}}_createBoneWorldMatrixMap(e,t){return tb(this,null,(function*(){var n,r;e.scene.updateWorldMatrix(!1,!0);const i=yield e.parser.getDependencies("node"),s=new Map;if(null==t.humanoid)return s;for(const[e,a]of Object.entries(t.humanoid.humanBones)){const t=null==a?void 0:a.node;if(null!=t){const a=i[t];s.set(e,a.matrixWorld),"hips"===e&&s.set("hipsParent",null!=(r=null==(n=a.parent)?void 0:n.matrixWorld)?r:Bb)}}return s}))}_parseAnimation(e,t,n,r){const i=e.tracks,s=t.channels,a=new Pb;return a.duration=e.duration,s.forEach(((e,t)=>{const{node:s,path:o}=e.target,l=i[t];if(null==s)return;const u=n.humanoidIndexToName.get(s);if(null!=u){let e=lb[u];for(;null!=e&&null==r.get(e);)e=lb[e];if(null!=e||(e="hipsParent"),"translation"===o)if("hips"!==u)console.warn(`The loading animation contains a translation track for ${u}, which is not permitted in the VRMC_vrm_animation spec. ignoring the track`);else{const e=r.get("hipsParent"),t=Ib(l.values,3).flatMap((t=>Lb.fromArray(t).applyMatrix4(e).toArray())),n=l.clone();n.values=new Float32Array(t),a.humanoidTracks.translation.set(u,n)}else{if("rotation"!==o)throw new Error(`Invalid path "${o}"`);{const t=r.get(u),n=r.get(e);t.decompose(Lb,Db,Lb),Db.invert(),n.decompose(Lb,Ub,Lb);const i=Ib(l.values,4).flatMap((e=>Nb.fromArray(e).premultiply(Ub).multiply(Db).toArray())),s=l.clone();s.values=new Float32Array(i),a.humanoidTracks.rotation.set(u,s)}}return}const c=n.expressionsIndexToName.get(s);if(null==c){if(s===n.lookAtIndex){if("rotation"!==o)throw new Error(`Invalid path "${o}"`);a.lookAtTrack=l}}else{if("translation"!==o)throw new Error(`Invalid path "${o}"`);{const e=l.times,t=new Float32Array(l.values.length/3);for(let r=0;r<t.length;r++)t[r]=l.values[3*r];const n=new Wd(`${c}.weight`,e,t);Ob.has(c)?a.expressionTracks.preset.set(c,n):a.expressionTracks.custom.set(c,n)}}})),a}},Hb=.001,zb=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){"undefined"!==typeof document&&void 0!==document.hidden&&(e?document.addEventListener("visibilitychange",this):document.removeEventListener("visibilitychange",this),this._autoReset=e)}get delta(){return this._delta*Hb}get fixedDelta(){return this._fixedDelta*Hb}set fixedDelta(e){this._fixedDelta=1e3*e}get elapsed(){return this._elapsed*Hb}update(e){this.useFixedDelta?this._delta=this.fixedDelta:(this.previousTime=this.currentTime,this.currentTime=(void 0!==e?e:performance.now())-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}},Gb=new na,Vb=null;var Wb=class e{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Pass",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new pu,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Gb;this.name=e,this.renderer=null,this.scene=t,this.camera=n,this.screen=null,this.rtt=!0,this.needsSwap=!0,this.needsDepthTexture=!1,this.enabled=!0}get renderToScreen(){return!this.rtt}set renderToScreen(e){if(this.rtt===e){const t=this.fullscreenMaterial;null!==t&&(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 null!==this.screen?this.screen.material:null}set fullscreenMaterial(e){let t=this.screen;null!==t?t.material=e:(t=new Ys(function(){if(null===Vb){const e=new Float32Array([-1,-1,0,3,-1,0,-1,3,0]),t=new Float32Array([0,0,2,0,0,2]);void 0!==(Vb=new Ps).setAttribute?(Vb.setAttribute("position",new ps(e,3)),Vb.setAttribute("uv",new ps(t,2))):(Vb.addAttribute("position",new ps(e,3)),Vb.addAttribute("uv",new ps(t,2)))}return Vb}(),e),t.frustumCulled=!1,null===this.scene&&(this.scene=new pu),this.scene.add(t),this.screen=t)}getFullscreenMaterial(){return this.fullscreenMaterial}setFullscreenMaterial(e){this.fullscreenMaterial=e}getDepthTexture(){return null}setDepthTexture(e){}render(e,t,n,r,i){throw new Error("Render method not implemented!")}setSize(e,t){}initialize(e,t,n){}dispose(){for(const t of Object.keys(this)){const n=this[t];(n instanceof Pr||n instanceof is||n instanceof Tr||n instanceof e)&&this[t].dispose()}}},jb=class extends Wb{constructor(){super("ClearMaskPass",null,null),this.needsSwap=!1}render(e,t,n,r,i){const s=e.state.buffers.stencil;s.setLocked(!1),s.setTest(!1)}},Xb="varying vec2 vUv;void main(){vUv=position.xy*0.5+0.5;gl_Position=vec4(position.xy,1.0,1.0);}",Jb=class extends ta{constructor(){super({name:"CopyMaterial",uniforms:{inputBuffer:new yf(null),opacity:new yf(1)},blending:y,toneMapped:!1,depthWrite:!1,depthTest:!1,fragmentShader:"#include <common>\n#include <dithering_pars_fragment>\n#ifdef FRAMEBUFFER_PRECISION_HIGH\nuniform mediump sampler2D inputBuffer;\n#else\nuniform lowp sampler2D inputBuffer;\n#endif\nuniform float opacity;varying vec2 vUv;void main(){vec4 texel=texture2D(inputBuffer,vUv);gl_FragColor=opacity*texel;\n#include <colorspace_fragment>\n#include <dithering_fragment>\n}",vertexShader:Xb})}set inputBuffer(e){this.uniforms.inputBuffer.value=e}setInputBuffer(e){this.uniforms.inputBuffer.value=e}getOpacity(e){return this.uniforms.opacity.value}setOpacity(e){this.uniforms.opacity.value=e}},Yb=class extends Wb{constructor(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];super("CopyPass"),this.fullscreenMaterial=new Jb,this.needsSwap=!1,this.renderTarget=e,void 0===e&&(this.renderTarget=new Pr(1,1,{minFilter:we,magFilter:we,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){void 0!==n&&(this.renderTarget.texture.type=n,n!==Pe?this.fullscreenMaterial.defines.FRAMEBUFFER_PRECISION_HIGH="1":null!==e&&e.outputColorSpace===en&&(this.renderTarget.texture.colorSpace=en))}},Kb=new ts,qb=class extends Wb{constructor(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];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){const s=this.overrideClearColor,a=this.overrideClearAlpha,o=e.getClearAlpha(),l=null!==s,u=a>=0;l?(e.getClearColor(Kb),e.setClearColor(s,u?a:o)):u&&e.setClearAlpha(a),e.setRenderTarget(this.renderToScreen?null:t),e.clear(this.color,this.depth,this.stencil),l?e.setClearColor(Kb,o):u&&e.setClearAlpha(o)}},Qb=class extends Wb{constructor(e,t){super("MaskPass",e,t),this.needsSwap=!1,this.clearPass=new qb(!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){const s=e.getContext(),a=e.state.buffers,o=this.scene,l=this.camera,u=this.clearPass,c=this.inverted?0:1,h=1-c;a.color.setMask(!1),a.depth.setMask(!1),a.color.setLocked(!0),a.depth.setLocked(!0),a.stencil.setTest(!0),a.stencil.setOp(s.REPLACE,s.REPLACE,s.REPLACE),a.stencil.setFunc(s.ALWAYS,c,4294967295),a.stencil.setClear(h),a.stencil.setLocked(!0),this.clearPass.enabled&&(this.renderToScreen?u.render(e,null):(u.render(e,t),u.render(e,n))),this.renderToScreen?(e.setRenderTarget(null),e.render(o,l)):(e.setRenderTarget(t),e.render(o,l),e.setRenderTarget(n),e.render(o,l)),a.color.setLocked(!1),a.depth.setLocked(!1),a.stencil.setLocked(!1),a.stencil.setFunc(s.EQUAL,1,4294967295),a.stencil.setOp(s.KEEP,s.KEEP,s.KEEP),a.stencil.setLocked(!0)}},Zb=class{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,{depthBuffer:t=!0,stencilBuffer:n=!1,multisampling:r=0,frameBufferType:i}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.renderer=null,this.inputBuffer=this.createBuffer(t,n,i,r),this.outputBuffer=this.inputBuffer.clone(),this.copyPass=new Yb,this.depthTexture=null,this.passes=[],this.timer=new zb,this.autoRenderToScreen=!0,this.setRenderer(e)}get multisampling(){return this.inputBuffer.samples||0}set multisampling(e){const 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.inputBuffer.depthTexture=this.depthTexture,this.outputBuffer=this.inputBuffer.clone())}getTimer(){return this.timer}getRenderer(){return this.renderer}setRenderer(e){if(this.renderer=e,null!==e){const t=e.getSize(new ir),n=e.getContext().getContextAttributes().alpha,r=this.inputBuffer.texture.type;r===Pe&&e.outputColorSpace===en&&(this.inputBuffer.texture.colorSpace=en,this.outputBuffer.texture.colorSpace=en,this.inputBuffer.dispose(),this.outputBuffer.dispose()),e.autoClear=!1,this.setSize(t.width,t.height);for(const i of this.passes)i.initialize(e,n,r)}}replaceRenderer(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];const n=this.renderer,r=n.domElement.parentNode;return this.setRenderer(e),t&&null!==r&&(r.removeChild(n.domElement),r.appendChild(e.domElement)),n}createDepthTexture(){const e=this.depthTexture=new io;return this.inputBuffer.depthTexture=e,this.inputBuffer.dispose(),this.inputBuffer.stencilBuffer?(e.format=Ye,e.type=He):e.type=Ue,e}deleteDepthTexture(){if(null!==this.depthTexture){this.depthTexture.dispose(),this.depthTexture=null,this.inputBuffer.depthTexture=null,this.inputBuffer.dispose();for(const e of this.passes)e.setDepthTexture(null)}}createBuffer(e,t,n,r){const i=this.renderer,s=null===i?new ir:i.getDrawingBufferSize(new ir),a={minFilter:we,magFilter:we,stencilBuffer:t,depthBuffer:e,type:n},o=new Pr(s.width,s.height,a);return r>0&&(o.ignoreDepthForMultisampleCopy=!1,o.samples=r),n===Pe&&null!==i&&i.outputColorSpace===en&&(o.texture.colorSpace=en),o.texture.name="EffectComposer.Buffer",o.texture.generateMipmaps=!1,o}setMainScene(e){for(const t of this.passes)t.mainScene=e}setMainCamera(e){for(const t of this.passes)t.mainCamera=e}addPass(e,t){const n=this.passes,r=this.renderer,i=r.getDrawingBufferSize(new ir),s=r.getContext().getContextAttributes().alpha,a=this.inputBuffer.texture.type;if(e.setRenderer(r),e.setSize(i.width,i.height),e.initialize(r,s,a),this.autoRenderToScreen&&(n.length>0&&(n[n.length-1].renderToScreen=!1),e.renderToScreen&&(this.autoRenderToScreen=!1)),void 0!==t?n.splice(t,0,e):n.push(e),this.autoRenderToScreen&&(n[n.length-1].renderToScreen=!0),e.needsDepthTexture||null!==this.depthTexture)if(null===this.depthTexture){const t=this.createDepthTexture();for(e of n)e.setDepthTexture(t)}else e.setDepthTexture(this.depthTexture)}removePass(e){const t=this.passes,n=t.indexOf(e);if(-1!==n&&t.splice(n,1).length>0){if(null!==this.depthTexture){const n=(e,t)=>e||t.needsDepthTexture;t.reduce(n,!1)||(e.getDepthTexture()===this.depthTexture&&e.setDepthTexture(null),this.deleteDepthTexture())}this.autoRenderToScreen&&n===t.length&&(e.renderToScreen=!1,t.length>0&&(t[t.length-1].renderToScreen=!0))}}removeAllPasses(){const e=this.passes;this.deleteDepthTexture(),e.length>0&&(this.autoRenderToScreen&&(e[e.length-1].renderToScreen=!1),this.passes=[])}render(e){const t=this.renderer,n=this.copyPass;let r,i,s,a=this.inputBuffer,o=this.outputBuffer,l=!1;void 0===e&&(this.timer.update(),e=this.timer.getDelta());for(const u of this.passes)u.enabled&&(u.render(t,a,o,e,l),u.needsSwap&&(l&&(n.renderToScreen=u.renderToScreen,r=t.getContext(),i=t.state.buffers.stencil,i.setFunc(r.NOTEQUAL,1,4294967295),n.render(t,a,o,e,l),i.setFunc(r.EQUAL,1,4294967295)),s=a,a=o,o=s),u instanceof Qb?l=!0:u instanceof jb&&(l=!1))}setSize(e,t,n){const r=this.renderer,i=r.getSize(new ir);void 0!==e&&void 0!==t||(e=i.width,t=i.height),i.width===e&&i.height===t||r.setSize(e,t,n);const s=r.getDrawingBufferSize(new ir);this.inputBuffer.setSize(s.width,s.height),this.outputBuffer.setSize(s.width,s.height);for(const a of this.passes)a.setSize(s.width,s.height)}reset(){this.dispose(),this.autoRenderToScreen=!0}dispose(){for(const e of this.passes)e.dispose();this.passes=[],null!==this.inputBuffer&&this.inputBuffer.dispose(),null!==this.outputBuffer&&this.outputBuffer.dispose(),this.deleteDepthTexture(),this.copyPass.dispose(),this.timer.dispose()}},$b={NONE:0,DEPTH:1,CONVOLUTION:2},eS={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"},tS=class{constructor(){this.shaderParts=new Map([[eS.FRAGMENT_HEAD,null],[eS.FRAGMENT_MAIN_UV,null],[eS.FRAGMENT_MAIN_IMAGE,null],[eS.VERTEX_HEAD,null],[eS.VERTEX_MAIN_SUPPORT,null]]),this.defines=new Map,this.uniforms=new Map,this.blendModes=new Map,this.extensions=new Set,this.attributes=$b.NONE,this.varyings=new Set,this.uvTransformation=!1,this.readDepth=!1,this.colorSpace=tn}};var nS=!1,rS=class{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]: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 v:t=this.materialsFlatShadedDoubleSide;break;case g:t=this.materialsFlatShadedBackSide;break;default:t=this.materialsFlatShaded}else switch(e.material.side){case v:t=this.materialsDoubleSide;break;case g:t=this.materialsBackSide;break;default:t=this.materials}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 ta))return e.clone();const t=e.uniforms,n=new Map;for(const i in t){const e=t[i].value;e.isRenderTargetTexture&&(t[i].value=null,n.set(i,e))}const r=e.clone();for(const i of n)t[i[0]].value=i[1],r.uniforms[i[0]].value=i[1];return r}setMaterial(e){if(this.disposeMaterials(),this.material=e,null!==e){const t=this.materials=[this.cloneMaterial(e),this.cloneMaterial(e),this.cloneMaterial(e)];for(const n of t)n.uniforms=Object.assign({},e.uniforms),n.side=m;t[2].skinning=!0,this.materialsBackSide=t.map((t=>{const n=this.cloneMaterial(t);return n.uniforms=Object.assign({},e.uniforms),n.side=g,n})),this.materialsDoubleSide=t.map((t=>{const n=this.cloneMaterial(t);return n.uniforms=Object.assign({},e.uniforms),n.side=v,n})),this.materialsFlatShaded=t.map((t=>{const n=this.cloneMaterial(t);return n.uniforms=Object.assign({},e.uniforms),n.flatShading=!0,n})),this.materialsFlatShadedBackSide=t.map((t=>{const n=this.cloneMaterial(t);return n.uniforms=Object.assign({},e.uniforms),n.flatShading=!0,n.side=g,n})),this.materialsFlatShadedDoubleSide=t.map((t=>{const n=this.cloneMaterial(t);return n.uniforms=Object.assign({},e.uniforms),n.flatShading=!0,n.side=v,n}))}}render(e,t,n){const r=e.shadowMap.enabled;if(e.shadowMap.enabled=!1,nS){const r=this.originalMaterials;this.meshCount=0,t.traverse(this.replaceMaterial),e.render(t,n);for(const e of r)e[0].material=e[1];this.meshCount!==r.size&&r.clear()}else{const r=t.overrideMaterial;t.overrideMaterial=this.material,e.render(t,n),t.overrideMaterial=r}e.shadowMap.enabled=r}disposeMaterials(){if(null!==this.material){const e=this.materials.concat(this.materialsBackSide).concat(this.materialsDoubleSide).concat(this.materialsFlatShaded).concat(this.materialsFlatShadedBackSide).concat(this.materialsFlatShadedDoubleSide);for(const t of e)t.dispose()}}dispose(){this.originalMaterials.clear(),this.disposeMaterials()}static get workaroundEnabled(){return nS}static set workaroundEnabled(e){nS=e}},iS=-1,sS=class extends Xn{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:iS,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:iS,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1;super(),this.resizable=e,this.baseSize=new ir(1,1),this.preferredSize=new ir(t,n),this.target=this.preferredSize,this.s=r,this.effectiveSize=new ir,this.addEventListener("change",(()=>this.updateEffectiveSize())),this.updateEffectiveSize()}updateEffectiveSize(){const e=this.baseSize,t=this.preferredSize,n=this.effectiveSize,r=this.scale;t.width!==iS?n.width=t.width:t.height!==iS?n.width=Math.round(t.height*(e.width/Math.max(e.height,1))):n.width=Math.round(e.width*r),t.height!==iS?n.height=t.height:t.width!==iS?n.height=Math.round(t.width/Math.max(e.width/Math.max(e.height,1),1)):n.height=Math.round(e.height*r)}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(iS),this.dispatchEvent({type:"change"}),this.resizable.setSize(this.baseSize.width,this.baseSize.height))}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"}),this.resizable.setSize(this.baseSize.width,this.baseSize.height))}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"}),this.resizable.setSize(this.baseSize.width,this.baseSize.height))}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"}),this.resizable.setSize(this.baseSize.width,this.baseSize.height))}get preferredWidth(){return this.preferredSize.width}set preferredWidth(e){this.preferredSize.width!==e&&(this.preferredSize.width=e,this.dispatchEvent({type:"change"}),this.resizable.setSize(this.baseSize.width,this.baseSize.height))}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"}),this.resizable.setSize(this.baseSize.width,this.baseSize.height))}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"}),this.resizable.setSize(this.baseSize.width,this.baseSize.height))}copy(e){this.s=e.scale,this.baseSize.set(e.baseWidth,e.baseHeight),this.preferredSize.set(e.preferredWidth,e.preferredHeight),this.dispatchEvent({type:"change"}),this.resizable.setSize(this.baseSize.width,this.baseSize.height)}static get AUTO_SIZE(){return iS}},aS=class extends Set{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:10;super(),this.l=t,this.exclusive=!1,void 0!==e&&this.set(e)}get layer(){return this.l}set layer(e){const t=this.l;for(const n of this)n.layers.disable(t),n.layers.enable(e);this.l=e}getLayer(){return this.layer}setLayer(e){this.layer=e}isExclusive(){return this.exclusive}setExclusive(e){this.exclusive=e}clear(){const e=this.layer;for(const t of this)t.layers.disable(e);return super.clear()}set(e){this.clear();for(const t of e)this.add(t);return this}indexOf(e){return this.has(e)?0:-1}add(e){return this.exclusive?e.layers.set(this.layer):e.layers.enable(this.layer),super.add(e)}delete(e){return this.has(e)&&e.layers.disable(this.layer),super.delete(e)}toggle(e){let t;return this.has(e)?(this.delete(e),t=!1):(this.add(e),t=!0),t}setVisible(e){for(const t of this)e?t.layers.enable(0):t.layers.disable(0);return this}},oS={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},lS=new Map([[oS.ADD,"vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,x+y,opacity);}"],[oS.ALPHA,"vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,y,min(y.a,opacity));}"],[oS.AVERAGE,"vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,(x+y)*0.5,opacity);}"],[oS.COLOR,"vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec3 xHSL=RGBToHSL(x.rgb);vec3 yHSL=RGBToHSL(y.rgb);vec3 z=HSLToRGB(vec3(yHSL.rg,xHSL.b));return vec4(mix(x.rgb,z,opacity),y.a);}"],[oS.COLOR_BURN,"vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec4 z=mix(step(0.0,y)*(1.0-min(vec4(1.0),(1.0-x)/y)),vec4(1.0),step(1.0,x));return mix(x,z,opacity);}"],[oS.COLOR_DODGE,"vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec4 z=step(0.0,x)*mix(min(vec4(1.0),x/max(1.0-y,1e-9)),vec4(1.0),step(1.0,y));return mix(x,z,opacity);}"],[oS.DARKEN,"vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,min(x,y),opacity);}"],[oS.DIFFERENCE,"vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,abs(x-y),opacity);}"],[oS.DIVIDE,"vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,x/max(y,1e-12),opacity);}"],[oS.DST,null],[oS.EXCLUSION,"vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,(x+y-2.0*x*y),opacity);}"],[oS.HARD_LIGHT,"vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec4 a=min(x,1.0),b=min(y,1.0);vec4 z=mix(2.0*a*b,1.0-2.0*(1.0-a)*(1.0-b),step(0.5,y));return mix(x,z,opacity);}"],[oS.HARD_MIX,"vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,step(1.0,x+y),opacity);}"],[oS.HUE,"vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec3 xHSL=RGBToHSL(x.rgb);vec3 yHSL=RGBToHSL(y.rgb);vec3 z=HSLToRGB(vec3(yHSL.r,xHSL.gb));return vec4(mix(x.rgb,z,opacity),y.a);}"],[oS.INVERT,"vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,1.0-y,opacity);}"],[oS.INVERT_RGB,"vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,y*(1.0-x),opacity);}"],[oS.LIGHTEN,"vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,max(x,y),opacity);}"],[oS.LINEAR_BURN,"vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,clamp(y+x-1.0,0.0,1.0),opacity);}"],[oS.LINEAR_DODGE,"vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,min(x+y,1.0),opacity);}"],[oS.LINEAR_LIGHT,"vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,clamp(2.0*y+x-1.0,0.0,1.0),opacity);}"],[oS.LUMINOSITY,"vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec3 xHSL=RGBToHSL(x.rgb);vec3 yHSL=RGBToHSL(y.rgb);vec3 z=HSLToRGB(vec3(xHSL.rg,yHSL.b));return vec4(mix(x.rgb,z,opacity),y.a);}"],[oS.MULTIPLY,"vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,x*y,opacity);}"],[oS.NEGATION,"vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,1.0-abs(1.0-x-y),opacity);}"],[oS.NORMAL,"vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,y,opacity);}"],[oS.OVERLAY,"vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec4 z=mix(2.0*y*x,1.0-2.0*(1.0-y)*(1.0-x),step(0.5,x));return mix(x,z,opacity);}"],[oS.PIN_LIGHT,"vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec4 y2=2.0*y;vec4 z=mix(mix(y2,x,step(0.5*x,y)),max(vec4(0.0),y2-1.0),step(x,(y2-1.0)));return mix(x,z,opacity);}"],[oS.REFLECT,"vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec4 z=mix(min(x*x/max(1.0-y,1e-12),1.0),y,step(1.0,y));return mix(x,z,opacity);}"],[oS.SATURATION,"vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec3 xHSL=RGBToHSL(x.rgb);vec3 yHSL=RGBToHSL(y.rgb);vec3 z=HSLToRGB(vec3(xHSL.r,yHSL.g,xHSL.b));return vec4(mix(x.rgb,z,opacity),y.a);}"],[oS.SCREEN,"vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,x+y-min(x*y,1.0),opacity);}"],[oS.SOFT_LIGHT,"vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec4 y2=2.0*y;vec4 w=step(0.5,y);vec4 z=mix(x-(1.0-y2)*x*(1.0-x),mix(x+(y2-1.0)*(sqrt(x)-x),x+(y2-1.0)*x*((16.0*x-12.0)*x+3.0),w*(1.0-step(0.25,x))),w);return mix(x,z,opacity);}"],[oS.SRC,"vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return y;}"],[oS.SUBTRACT,"vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,max(x+y-1.0,0.0),opacity);}"],[oS.VIVID_LIGHT,"vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec4 z=mix(max(1.0-min((1.0-x)/(2.0*y),1.0),0.0),min(x/(2.0*(1.0-y)),1.0),step(0.5,y));return mix(x,z,opacity);}"]]),uS=class extends Xn{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;super(),this._blendFunction=e,this.opacity=new yf(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 lS.get(this.blendFunction)}},cS={VERY_SMALL:0,SMALL:1,MEDIUM:2,LARGE:3,VERY_LARGE:4,HUGE:5},hS=[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])],dS=class extends ta{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new Cr;super({name:"KawaseBlurMaterial",uniforms:{inputBuffer:new yf(null),texelSize:new yf(new Cr),scale:new yf(1),kernel:new yf(0)},blending:y,toneMapped:!1,depthWrite:!1,depthTest:!1,fragmentShader:"#ifdef FRAMEBUFFER_PRECISION_HIGH\nuniform mediump sampler2D inputBuffer;\n#else\nuniform lowp sampler2D inputBuffer;\n#endif\nvarying 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;\n#include <colorspace_fragment>\n}",vertexShader:"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);}"}),this.setTexelSize(e.x,e.y),this.kernelSize=cS.MEDIUM}set inputBuffer(e){this.uniforms.inputBuffer.value=e}setInputBuffer(e){this.inputBuffer=e}get kernelSequence(){return hS[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,.5*e,.5*t)}setSize(e,t){const n=1/e,r=1/t;this.uniforms.texelSize.value.set(n,r,.5*n,.5*r)}},pS=class extends Wb{constructor(){let{kernelSize:e=cS.MEDIUM,resolutionScale:t=.5,width:n=sS.AUTO_SIZE,height:r=sS.AUTO_SIZE,resolutionX:i=n,resolutionY:s=r}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super("KawaseBlurPass"),this.renderTargetA=new Pr(1,1,{depthBuffer:!1}),this.renderTargetA.texture.name="Blur.Target.A",this.renderTargetB=this.renderTargetA.clone(),this.renderTargetB.texture.name="Blur.Target.B";const a=this.resolution=new sS(this,i,s,t);a.addEventListener("change",(e=>this.setSize(a.baseWidth,a.baseHeight))),this._blurMaterial=new dS,this._blurMaterial.kernelSize=e,this.copyMaterial=new Jb}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){const s=this.scene,a=this.camera,o=this.renderTargetA,l=this.renderTargetB,u=this.blurMaterial,c=u.kernelSequence;let h=t;this.fullscreenMaterial=u;for(let d=0,p=c.length;d<p;++d){const t=0===(1&d)?o:l;u.kernel=c[d],u.inputBuffer=h.texture,e.setRenderTarget(t),e.render(s,a),h=t}this.fullscreenMaterial=this.copyMaterial,this.copyMaterial.inputBuffer=h.texture,e.setRenderTarget(this.renderToScreen?null:n),e.render(s,a)}setSize(e,t){const n=this.resolution;n.setBaseSize(e,t);const r=n.width,i=n.height;this.renderTargetA.setSize(r,i),this.renderTargetB.setSize(r,i),this.blurMaterial.setSize(e,t)}initialize(e,t,n){void 0!==n&&(this.renderTargetA.texture.type=n,this.renderTargetB.texture.type=n,n!==Pe?(this.blurMaterial.defines.FRAMEBUFFER_PRECISION_HIGH="1",this.copyMaterial.defines.FRAMEBUFFER_PRECISION_HIGH="1"):null!==e&&e.outputColorSpace===en&&(this.renderTargetA.texture.colorSpace=en,this.renderTargetB.texture.colorSpace=en))}static get AUTO_SIZE(){return sS.AUTO_SIZE}},fS=class extends ta{constructor(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;super({name:"LuminanceMaterial",defines:{THREE_REVISION:i.replace(/\D+/g,"")},uniforms:{inputBuffer:new yf(null),threshold:new yf(0),smoothing:new yf(1),range:new yf(null)},blending:y,toneMapped:!1,depthWrite:!1,depthTest:!1,fragmentShader:"#include <common>\n#ifdef FRAMEBUFFER_PRECISION_HIGH\nuniform mediump sampler2D inputBuffer;\n#else\nuniform lowp sampler2D inputBuffer;\n#endif\n#ifdef RANGE\nuniform vec2 range;\n#elif defined(THRESHOLD)\nuniform float threshold;uniform float smoothing;\n#endif\nvarying vec2 vUv;void main(){vec4 texel=texture2D(inputBuffer,vUv);float l=luminance(texel.rgb);\n#ifdef RANGE\nfloat low=step(range.x,l);float high=step(l,range.y);l*=low*high;\n#elif defined(THRESHOLD)\nl=smoothstep(threshold,threshold+smoothing,l)*l;\n#endif\n#ifdef COLOR\ngl_FragColor=vec4(texel.rgb*clamp(l,0.0,1.0),l);\n#else\ngl_FragColor=vec4(l);\n#endif\n}",vertexShader:Xb}),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 void 0!==this.defines.COLOR}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 null!==this.luminanceRange}set useRange(e){this.luminanceRange=null}get luminanceRange(){return this.uniforms.range.value}set luminanceRange(e){null!==e?this.defines.RANGE="1":delete this.defines.RANGE,this.uniforms.range.value=e,this.needsUpdate=!0}getLuminanceRange(){return this.luminanceRange}setLuminanceRange(e){this.luminanceRange=e}},mS=class extends Wb{constructor(){let{renderTarget:e,luminanceRange:t,colorOutput:n,resolutionScale:r=1,width:i=sS.AUTO_SIZE,height:s=sS.AUTO_SIZE,resolutionX:a=i,resolutionY:o=s}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super("LuminancePass"),this.fullscreenMaterial=new fS(n,t),this.needsSwap=!1,this.renderTarget=e,void 0===this.renderTarget&&(this.renderTarget=new Pr(1,1,{depthBuffer:!1}),this.renderTarget.texture.name="LuminancePass.Target");const l=this.resolution=new sS(this,a,o,r);l.addEventListener("change",(e=>this.setSize(l.baseWidth,l.baseHeight)))}get texture(){return this.renderTarget.texture}getTexture(){return this.renderTarget.texture}getResolution(){return this.resolution}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){const n=this.resolution;n.setBaseSize(e,t),this.renderTarget.setSize(n.width,n.height)}initialize(e,t,n){void 0!==n&&n!==Pe&&(this.renderTarget.texture.type=n,this.fullscreenMaterial.defines.FRAMEBUFFER_PRECISION_HIGH="1")}},gS=class extends ta{constructor(){super({name:"DownsamplingMaterial",uniforms:{inputBuffer:new yf(null),texelSize:new yf(new ir)},blending:y,toneMapped:!1,depthWrite:!1,depthTest:!1,fragmentShader:"#ifdef FRAMEBUFFER_PRECISION_HIGH\nuniform mediump sampler2D inputBuffer;\n#else\nuniform lowp sampler2D inputBuffer;\n#endif\n#define WEIGHT_INNER 0.125\n#define WEIGHT_OUTER 0.0555555\nvarying 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;\n#include <colorspace_fragment>\n}",vertexShader:"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);}"})}set inputBuffer(e){this.uniforms.inputBuffer.value=e}setSize(e,t){this.uniforms.texelSize.value.set(1/e,1/t)}},vS=class extends ta{constructor(){super({name:"UpsamplingMaterial",uniforms:{inputBuffer:new yf(null),supportBuffer:new yf(null),texelSize:new yf(new ir),radius:new yf(.85)},blending:y,toneMapped:!1,depthWrite:!1,depthTest:!1,fragmentShader:"#ifdef FRAMEBUFFER_PRECISION_HIGH\nuniform mediump sampler2D inputBuffer;uniform mediump sampler2D supportBuffer;\n#else\nuniform lowp sampler2D inputBuffer;uniform lowp sampler2D supportBuffer;\n#endif\nuniform 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);\n#include <colorspace_fragment>\n}",vertexShader:"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);}"})}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)}},yS=class extends Wb{constructor(){super("MipmapBlurPass"),this.needsSwap=!1,this.renderTarget=new Pr(1,1,{depthBuffer:!1}),this.renderTarget.texture.name="Upsampling.Mipmap0",this.downsamplingMipmaps=[],this.upsamplingMipmaps=[],this.downsamplingMaterial=new gS,this.upsamplingMaterial=new vS,this.resolution=new ir}get texture(){return this.renderTarget.texture}get levels(){return this.downsamplingMipmaps.length}set levels(e){if(this.levels!==e){const t=this.renderTarget;this.dispose(),this.downsamplingMipmaps=[],this.upsamplingMipmaps=[];for(let n=0;n<e;++n){const e=t.clone();e.texture.name="Downsampling.Mipmap"+n,this.downsamplingMipmaps.push(e)}this.upsamplingMipmaps.push(t);for(let n=1,r=e-1;n<r;++n){const e=t.clone();e.texture.name="Upsampling.Mipmap"+n,this.upsamplingMipmaps.push(e)}this.setSize(this.resolution.x,this.resolution.y)}}get radius(){return this.upsamplingMaterial.radius}set radius(e){this.upsamplingMaterial.radius=e}render(e,t,n,r,i){const{scene:s,camera:a}=this,{downsamplingMaterial:o,upsamplingMaterial:l}=this,{downsamplingMipmaps:u,upsamplingMipmaps:c}=this;let h=t;this.fullscreenMaterial=o;for(let d=0,p=u.length;d<p;++d){const t=u[d];o.setSize(h.width,h.height),o.inputBuffer=h.texture,e.setRenderTarget(t),e.render(s,a),h=t}this.fullscreenMaterial=l;for(let d=c.length-1;d>=0;--d){const t=c[d];l.setSize(h.width,h.height),l.inputBuffer=h.texture,l.supportBuffer=u[d].texture,e.setRenderTarget(t),e.render(s,a),h=t}}setSize(e,t){const n=this.resolution;n.set(e,t);let r=n.width,i=n.height;for(let s=0,a=this.downsamplingMipmaps.length;s<a;++s)r=Math.round(.5*r),i=Math.round(.5*i),this.downsamplingMipmaps[s].setSize(r,i),s<this.upsamplingMipmaps.length&&this.upsamplingMipmaps[s].setSize(r,i)}initialize(e,t,n){if(void 0!==n){const t=this.downsamplingMipmaps.concat(this.upsamplingMipmaps);for(const e of t)e.texture.type=n;if(n!==Pe)this.downsamplingMaterial.defines.FRAMEBUFFER_PRECISION_HIGH="1",this.upsamplingMaterial.defines.FRAMEBUFFER_PRECISION_HIGH="1";else if(null!==e&&e.outputColorSpace===en)for(const e of t)e.texture.colorSpace=en}}dispose(){super.dispose();for(const e of this.downsamplingMipmaps.concat(this.upsamplingMipmaps))e.dispose()}},_S=class extends Xn{constructor(e,t){let{attributes:n=$b.NONE,blendFunction:r=oS.NORMAL,defines:i=new Map,uniforms:s=new Map,extensions:a=null,vertexShader:o=null}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};super(),this.name=e,this.renderer=null,this.attributes=n,this.fragmentShader=t,this.vertexShader=o,this.defines=i,this.uniforms=s,this.extensions=a,this.blendMode=new uS(r),this.blendMode.addEventListener("change",(e=>this.setChanged())),this._inputColorSpace=tn,this._outputColorSpace=$t}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){}update(e,t,n){}setSize(e,t){}initialize(e,t,n){}dispose(){for(const e of Object.keys(this)){const t=this[e];(t instanceof Pr||t instanceof is||t instanceof Tr||t instanceof Wb)&&this[e].dispose()}}},xS=class extends _S{constructor(){let{blendFunction:e=oS.SCREEN,luminanceThreshold:t=.9,luminanceSmoothing:n=.025,mipmapBlur:r=!1,intensity:i=1,radius:s=.85,levels:a=8,kernelSize:o=cS.LARGE,resolutionScale:l=.5,width:u=sS.AUTO_SIZE,height:c=sS.AUTO_SIZE,resolutionX:h=u,resolutionY:d=c}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super("BloomEffect","#ifdef FRAMEBUFFER_PRECISION_HIGH\nuniform mediump sampler2D map;\n#else\nuniform lowp sampler2D map;\n#endif\nuniform float intensity;void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){vec4 texel=texture2D(map,uv);outputColor=vec4(texel.rgb*intensity,texel.a);}",{blendFunction:e,uniforms:new Map([["map",new yf(null)],["intensity",new yf(i)]])}),this.renderTarget=new Pr(1,1,{depthBuffer:!1}),this.renderTarget.texture.name="Bloom.Target",this.blurPass=new pS({kernelSize:o}),this.luminancePass=new mS({colorOutput:!0}),this.luminanceMaterial.threshold=t,this.luminanceMaterial.smoothing=n,this.mipmapBlurPass=new yS,this.mipmapBlurPass.enabled=r,this.mipmapBlurPass.radius=s,this.mipmapBlurPass.levels=a,this.uniforms.get("map").value=r?this.mipmapBlurPass.texture:this.renderTarget.texture;const p=this.resolution=new sS(this,h,d,l);p.addEventListener("change",(e=>this.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){const 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){const 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),void 0!==n&&(this.renderTarget.texture.type=n,null!==e&&e.outputColorSpace===en&&(this.renderTarget.texture.colorSpace=en))}};var AS=class extends Wb{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"inputBuffer";super("ShaderPass"),this.fullscreenMaterial=e,this.input=t}setInput(e){this.input=e}render(e,t,n,r,i){const s=this.fullscreenMaterial.uniforms;null!==t&&void 0!==s&&void 0!==s[this.input]&&(s[this.input].value=t.texture),e.setRenderTarget(this.renderToScreen?null:n),e.render(this.scene,this.camera)}initialize(e,t,n){void 0!==n&&n!==Pe&&(this.fullscreenMaterial.defines.FRAMEBUFFER_PRECISION_HIGH="1")}};var MS=1,bS=2,SS=class extends ta{constructor(){super({name:"DepthMaskMaterial",defines:{DEPTH_EPSILON:"0.0001",DEPTH_PACKING_0:"0",DEPTH_PACKING_1:"0",DEPTH_TEST_STRATEGY:MS},uniforms:{inputBuffer:new yf(null),depthBuffer0:new yf(null),depthBuffer1:new yf(null),cameraNearFar:new yf(new ir(1,1))},blending:y,toneMapped:!1,depthWrite:!1,depthTest:!1,fragmentShader:"#include <common>\n#include <packing>\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nuniform highp sampler2D depthBuffer0;uniform highp sampler2D depthBuffer1;\n#else\nuniform mediump sampler2D depthBuffer0;uniform mediump sampler2D depthBuffer1;\n#endif\nuniform sampler2D inputBuffer;uniform vec2 cameraNearFar;float getViewZ(const in float depth){\n#ifdef PERSPECTIVE_CAMERA\nreturn perspectiveDepthToViewZ(depth,cameraNearFar.x,cameraNearFar.y);\n#else\nreturn orthographicDepthToViewZ(depth,cameraNearFar.x,cameraNearFar.y);\n#endif\n}varying vec2 vUv;void main(){vec2 depth;\n#if DEPTH_PACKING_0 == 3201\ndepth.x=unpackRGBAToDepth(texture2D(depthBuffer0,vUv));\n#else\ndepth.x=texture2D(depthBuffer0,vUv).r;\n#ifdef LOG_DEPTH\nfloat d=pow(2.0,depth.x*log2(cameraNearFar.y+1.0))-1.0;float a=cameraNearFar.y/(cameraNearFar.y-cameraNearFar.x);float b=cameraNearFar.y*cameraNearFar.x/(cameraNearFar.x-cameraNearFar.y);depth.x=a+b/d;\n#endif\n#endif\n#if DEPTH_PACKING_1 == 3201\ndepth.y=unpackRGBAToDepth(texture2D(depthBuffer1,vUv));\n#else\ndepth.y=texture2D(depthBuffer1,vUv).r;\n#ifdef LOG_DEPTH\nfloat d=pow(2.0,depth.y*log2(cameraNearFar.y+1.0))-1.0;float a=cameraNearFar.y/(cameraNearFar.y-cameraNearFar.x);float b=cameraNearFar.y*cameraNearFar.x/(cameraNearFar.x-cameraNearFar.y);depth.y=a+b/d;\n#endif\n#endif\nbool isMaxDepth=(depth.x==1.0);\n#ifdef PERSPECTIVE_CAMERA\ndepth.x=viewZToOrthographicDepth(getViewZ(depth.x),cameraNearFar.x,cameraNearFar.y);depth.y=viewZToOrthographicDepth(getViewZ(depth.y),cameraNearFar.x,cameraNearFar.y);\n#endif\n#if DEPTH_TEST_STRATEGY == 0\nbool keep=depthTest(depth.x,depth.y);\n#elif DEPTH_TEST_STRATEGY == 1\nbool keep=isMaxDepth||depthTest(depth.x,depth.y);\n#else\nbool keep=!isMaxDepth&&depthTest(depth.x,depth.y);\n#endif\nif(keep){gl_FragColor=texture2D(inputBuffer,vUv);}else{discard;}}",vertexShader:Xb}),this.depthMode=X}set depthBuffer0(e){this.uniforms.depthBuffer0.value=e}set depthPacking0(e){this.defines.DEPTH_PACKING_0=e.toFixed(0),this.needsUpdate=!0}setDepthBuffer0(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Jt;this.depthBuffer0=e,this.depthPacking0=t}set depthBuffer1(e){this.uniforms.depthBuffer1.value=e}set depthPacking1(e){this.defines.DEPTH_PACKING_1=e.toFixed(0),this.needsUpdate=!0}setDepthBuffer1(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Jt;this.depthBuffer1=e,this.depthPacking1=t}get maxDepthStrategy(){return Number(this.defines.DEPTH_TEST_STRATEGY)}set maxDepthStrategy(e){this.defines.DEPTH_TEST_STRATEGY=e.toFixed(0),this.needsUpdate=!0}get keepFar(){return this.maxDepthStrategy}set keepFar(e){this.maxDepthStrategy=e?MS:bS}getMaxDepthStrategy(){return this.maxDepthStrategy}setMaxDepthStrategy(e){this.maxDepthStrategy=e}get epsilon(){return Number(this.defines.DEPTH_EPSILON)}set epsilon(e){this.defines.DEPTH_EPSILON=e.toFixed(16),this.needsUpdate=!0}getEpsilon(){return this.epsilon}setEpsilon(e){this.epsilon=e}get depthMode(){return Number(this.defines.DEPTH_MODE)}set depthMode(e){let t;switch(e){case W:t="false";break;case j:t="true";break;case Y:t="abs(d1 - d0) <= DEPTH_EPSILON";break;case Q:t="abs(d1 - d0) > DEPTH_EPSILON";break;case X:t="d0 > d1";break;case J:t="d0 >= d1";break;case K:t="d0 <= d1";break;default:t="d0 < d1"}this.defines.DEPTH_MODE=e.toFixed(0),this.defines["depthTest(d0, d1)"]=t,this.needsUpdate=!0}getDepthMode(){return this.depthMode}setDepthMode(e){this.depthMode=e}adoptCameraSettings(e){this.copyCameraSettings(e)}copyCameraSettings(e){e&&(this.uniforms.cameraNearFar.value.set(e.near,e.far),e instanceof aa?this.defines.PERSPECTIVE_CAMERA="1":delete this.defines.PERSPECTIVE_CAMERA,this.needsUpdate=!0)}},wS=class extends Wb{constructor(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;super("RenderPass",e,t),this.needsSwap=!1,this.clearPass=new qb,this.overrideMaterialManager=null===n?null:new rS(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(){const e=this.overrideMaterialManager;return null!==e?e.material:null}set overrideMaterial(e){const t=this.overrideMaterialManager;null!==e?null!==t?t.setMaterial(e):this.overrideMaterialManager=new rS(e):null!==t&&(t.dispose(),this.overrideMaterialManager=null)}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){const s=this.scene,a=this.camera,o=this.selection,l=a.layers.mask,u=s.background,c=e.shadowMap.autoUpdate,h=this.renderToScreen?null:t;null!==o&&a.layers.set(o.getLayer()),this.skipShadowMapUpdate&&(e.shadowMap.autoUpdate=!1),(this.ignoreBackground||null!==this.clearPass.overrideClearColor)&&(s.background=null),this.clearPass.enabled&&this.clearPass.render(e,t),e.setRenderTarget(h),null!==this.overrideMaterialManager?this.overrideMaterialManager.render(e,s,a):e.render(s,a),a.layers.mask=l,s.background=u,e.shadowMap.autoUpdate=c}};var ES=class extends Wb{constructor(e,t){let{renderTarget:n,resolutionScale:r=1,width:i=sS.AUTO_SIZE,height:s=sS.AUTO_SIZE,resolutionX:a=i,resolutionY:o=s}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};super("DepthPass"),this.needsSwap=!1,this.renderPass=new wS(e,t,new Xl({depthPacking:Yt}));const l=this.renderPass;l.skipShadowMapUpdate=!0,l.ignoreBackground=!0;const u=l.clearPass;u.overrideClearColor=new ts(16777215),u.overrideClearAlpha=1,this.renderTarget=n,void 0===this.renderTarget&&(this.renderTarget=new Pr(1,1,{minFilter:xe,magFilter:xe}),this.renderTarget.texture.name="DepthPass.Target");const c=this.resolution=new sS(this,a,o,r);c.addEventListener("change",(e=>this.setSize(c.baseWidth,c.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){const s=this.renderToScreen?null:this.renderTarget;this.renderPass.render(e,s)}setSize(e,t){const n=this.resolution;n.setBaseSize(e,t),this.renderTarget.setSize(n.width,n.height)}},TS=(Math.PI,class extends xS{constructor(e,t,n){super(n),this.setAttributes(this.getAttributes()|$b.DEPTH),this.camera=t,this.depthPass=new ES(e,t),this.clearPass=new qb(!0,!1,!1),this.clearPass.overrideClearColor=new ts(0),this.depthMaskPass=new AS(new SS);const r=this.depthMaskMaterial;r.copyCameraSettings(t),r.depthBuffer1=this.depthPass.texture,r.depthPacking1=Yt,r.depthMode=Y,this.renderTargetMasked=new Pr(1,1,{depthBuffer:!1}),this.renderTargetMasked.texture.name="Bloom.Masked",this.selection=new aS,this.selection.layer=11,this._inverted=!1,this._ignoreBackground=!1}set mainScene(e){this.depthPass.mainScene=e}set mainCamera(e){this.camera=e,this.depthPass.mainCamera=e,this.depthMaskMaterial.copyCameraSettings(e)}getSelection(){return this.selection}get depthMaskMaterial(){return this.depthMaskPass.fullscreenMaterial}get inverted(){return this._inverted}set inverted(e){this._inverted=e,this.depthMaskMaterial.depthMode=e?Q:Y}isInverted(){return this.inverted}setInverted(e){this.inverted=e}get ignoreBackground(){return this._ignoreBackground}set ignoreBackground(e){this._ignoreBackground=e,this.depthMaskMaterial.maxDepthStrategy=e?bS:MS}isBackgroundDisabled(){return this.ignoreBackground}setBackgroundDisabled(e){this.ignoreBackground=e}setDepthTexture(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Jt;this.depthMaskMaterial.depthBuffer0=e,this.depthMaskMaterial.depthPacking0=t}update(e,t,n){const r=this.camera,i=this.selection,s=this.inverted;let a=t;if(this.ignoreBackground||!s||i.size>0){const n=r.layers.mask;r.layers.set(i.layer),this.depthPass.render(e),r.layers.mask=n,a=this.renderTargetMasked,this.clearPass.render(e,a),this.depthMaskPass.render(e,t,a)}super.update(e,a,n)}setSize(e,t){super.setSize(e,t),this.renderTargetMasked.setSize(e,t),this.depthPass.setSize(e,t)}initialize(e,t,n){super.initialize(e,t,n),this.clearPass.initialize(e,t,n),this.depthPass.initialize(e,t,n),this.depthMaskPass.initialize(e,t,n),null!==e&&e.capabilities.logarithmicDepthBuffer&&(this.depthMaskPass.fullscreenMaterial.defines.LOG_DEPTH="1"),void 0!==n&&(this.renderTargetMasked.texture.type=n,null!==e&&e.outputColorSpace===en&&(this.renderTargetMasked.texture.colorSpace=en))}}),CS=class extends ta{constructor(){super({name:"DepthDownsamplingMaterial",defines:{DEPTH_PACKING:"0"},uniforms:{depthBuffer:new yf(null),normalBuffer:new yf(null),texelSize:new yf(new ir)},blending:y,toneMapped:!1,depthWrite:!1,depthTest:!1,fragmentShader:"#include <packing>\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nuniform highp sampler2D depthBuffer;\n#else\nuniform mediump sampler2D depthBuffer;\n#endif\n#ifdef DOWNSAMPLE_NORMALS\nuniform lowp sampler2D normalBuffer;\n#endif\nvarying vec2 vUv0;varying vec2 vUv1;varying vec2 vUv2;varying vec2 vUv3;float readDepth(const in vec2 uv){\n#if DEPTH_PACKING == 3201\nreturn unpackRGBAToDepth(texture2D(depthBuffer,uv));\n#else\nreturn texture2D(depthBuffer,uv).r;\n#endif\n}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]<maxDistance){remaining[j++]=i;}else{rejected[k++]=i;}}for(;j<3;++j){remaining[j]=rejected[--k];}vec3 s=vec3(samples[remaining[0]],samples[remaining[1]],samples[remaining[2]]);c=(s.x+s.y+s.z)/3.0;distances[0]=abs(c-s.x);distances[1]=abs(c-s.y);distances[2]=abs(c-s.z);float minDistance=min(distances[0],min(distances[1],distances[2]));for(i=0;i<3;++i){if(distances[i]==minDistance){break;}}return remaining[i];}void main(){float d[4];d[0]=readDepth(vUv0);d[1]=readDepth(vUv1);d[2]=readDepth(vUv2);d[3]=readDepth(vUv3);int index=findBestDepth(d);\n#ifdef DOWNSAMPLE_NORMALS\nvec3 n[4];n[0]=texture2D(normalBuffer,vUv0).rgb;n[1]=texture2D(normalBuffer,vUv1).rgb;n[2]=texture2D(normalBuffer,vUv2).rgb;n[3]=texture2D(normalBuffer,vUv3).rgb;\n#else\nvec3 n[4];n[0]=vec3(0.0);n[1]=vec3(0.0);n[2]=vec3(0.0);n[3]=vec3(0.0);\n#endif\ngl_FragColor=vec4(n[index],d[index]);}",vertexShader:"uniform vec2 texelSize;varying vec2 vUv0;varying vec2 vUv1;varying vec2 vUv2;varying vec2 vUv3;void main(){vec2 uv=position.xy*0.5+0.5;vUv0=uv;vUv1=vec2(uv.x,uv.y+texelSize.y);vUv2=vec2(uv.x+texelSize.x,uv.y);vUv3=uv+texelSize;gl_Position=vec4(position.xy,1.0,1.0);}"})}set depthBuffer(e){this.uniforms.depthBuffer.value=e}set depthPacking(e){this.defines.DEPTH_PACKING=e.toFixed(0),this.needsUpdate=!0}setDepthBuffer(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Jt;this.depthBuffer=e,this.depthPacking=t}set normalBuffer(e){this.uniforms.normalBuffer.value=e,null!==e?this.defines.DOWNSAMPLE_NORMALS="1":delete this.defines.DOWNSAMPLE_NORMALS,this.needsUpdate=!0}setNormalBuffer(e){this.normalBuffer=e}setTexelSize(e,t){this.uniforms.texelSize.value.set(e,t)}setSize(e,t){this.uniforms.texelSize.value.set(1/e,1/t)}},RS=class extends Wb{constructor(){let{normalBuffer:e=null,resolutionScale:t=.5,width:n=sS.AUTO_SIZE,height:r=sS.AUTO_SIZE,resolutionX:i=n,resolutionY:s=r}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super("DepthDownsamplingPass");const a=new CS;a.normalBuffer=e,this.fullscreenMaterial=a,this.needsDepthTexture=!0,this.needsSwap=!1,this.renderTarget=new Pr(1,1,{minFilter:xe,magFilter:xe,depthBuffer:!1,type:Ne}),this.renderTarget.texture.name="DepthDownsamplingPass.Target",this.renderTarget.texture.generateMipmaps=!1;const o=this.resolution=new sS(this,i,s,t);o.addEventListener("change",(e=>this.setSize(o.baseWidth,o.baseHeight)))}get texture(){return this.renderTarget.texture}getTexture(){return this.renderTarget.texture}getResolution(){return this.resolution}setDepthTexture(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Jt;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){const n=this.resolution;n.setBaseSize(e,t),this.renderTarget.setSize(n.width,n.height),this.fullscreenMaterial.setSize(e,t)}initialize(e,t,n){const r=e.getContext();if(!(r.getExtension("EXT_color_buffer_float")||r.getExtension("EXT_color_buffer_half_float")))throw new Error("Rendering to float texture is not supported.")}},PS=class extends ta{constructor(e,t,n,r){let s=arguments.length>4&&void 0!==arguments[4]&&arguments[4];super({name:"EffectMaterial",defines:{THREE_REVISION:i.replace(/\D+/g,""),DEPTH_PACKING:"0",ENCODE_OUTPUT:"1"},uniforms:{inputBuffer:new yf(null),depthBuffer:new yf(null),resolution:new yf(new ir),texelSize:new yf(new ir),cameraNear:new yf(.3),cameraFar:new yf(1e3),aspect:new yf(1),time:new yf(0)},blending:y,toneMapped:!1,depthWrite:!1,depthTest:!1,dithering:s}),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){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Jt;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="#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#define packFloatToRGBA(v) packDepthToRGBA(v)\n#define unpackRGBAToFloat(v) unpackRGBAToDepth(v)\n#ifdef FRAMEBUFFER_PRECISION_HIGH\nuniform mediump sampler2D inputBuffer;\n#else\nuniform lowp sampler2D inputBuffer;\n#endif\n#if DEPTH_PACKING == 3201\nuniform lowp sampler2D depthBuffer;\n#elif defined(GL_FRAGMENT_PRECISION_HIGH)\nuniform highp sampler2D depthBuffer;\n#else\nuniform mediump sampler2D depthBuffer;\n#endif\nuniform 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){\n#if DEPTH_PACKING == 3201\nreturn unpackRGBAToDepth(texture2D(depthBuffer,uv));\n#else\nreturn texture2D(depthBuffer,uv).r;\n#endif\n}float getViewZ(const in float depth){\n#ifdef PERSPECTIVE_CAMERA\nreturn perspectiveDepthToViewZ(depth,cameraNear,cameraFar);\n#else\nreturn orthographicDepthToViewZ(depth,cameraNear,cameraFar);\n#endif\n}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;\n#ifdef ENCODE_OUTPUT\n#include <colorspace_fragment>\n#endif\n#include <dithering_fragment>\n}".replace(eS.FRAGMENT_HEAD,e.get(eS.FRAGMENT_HEAD)||"").replace(eS.FRAGMENT_MAIN_UV,e.get(eS.FRAGMENT_MAIN_UV)||"").replace(eS.FRAGMENT_MAIN_IMAGE,e.get(eS.FRAGMENT_MAIN_IMAGE)||""),this.vertexShader="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);}".replace(eS.VERTEX_HEAD,e.get(eS.VERTEX_HEAD)||"").replace(eS.VERTEX_MAIN_SUPPORT,e.get(eS.VERTEX_MAIN_SUPPORT)||""),this.needsUpdate=!0,this}setDefines(e){for(const t of e.entries())this.defines[t[0]]=t[1];return this.needsUpdate=!0,this}setUniforms(e){for(const t of e.entries())this.uniforms[t[0]]=t[1];return this}setExtensions(e){this.extensions={};for(const t of e)this.extensions[t]=!0;return this}get encodeOutput(){return void 0!==this.defines.ENCODE_OUTPUT}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 aa?this.defines.PERSPECTIVE_CAMERA="1":delete this.defines.PERSPECTIVE_CAMERA,this.needsUpdate=!0)}setSize(e,t){const 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 eS}},IS=(Number(i.replace(/\D+/g,"")),255/256);new Float32Array([5.9371814131736755e-8,IS/65536,.0038909912109375,IS]),new Float32Array([IS,.0038909912109375,IS/65536,1/256**3]);function BS(e,t,n){for(const r of t){const t="$1"+e+r.charAt(0).toUpperCase()+r.slice(1),i=new RegExp("([^\\.])(\\b"+r+"\\b)","g");for(const e of n.entries())null!==e[1]&&n.set(e[0],e[1].replace(i,t))}}function LS(e,t,n){let r=t.getFragmentShader(),i=t.getVertexShader();const s=void 0!==r&&/mainImage/.test(r),a=void 0!==r&&/mainUv/.test(r);if(n.attributes|=t.getAttributes(),void 0===r)throw new Error(`Missing fragment shader (${t.name})`);if(a&&0!==(n.attributes&$b.CONVOLUTION))throw new Error(`Effects that transform UVs are incompatible with convolution effects (${t.name})`);if(!s&&!a)throw new Error(`Could not find mainImage or mainUv function (${t.name})`);{const o=/\w+\s+(\w+)\([\w\s,]*\)\s*{/g,l=n.shaderParts;let u=l.get(eS.FRAGMENT_HEAD)||"",c=l.get(eS.FRAGMENT_MAIN_UV)||"",h=l.get(eS.FRAGMENT_MAIN_IMAGE)||"",d=l.get(eS.VERTEX_HEAD)||"",p=l.get(eS.VERTEX_MAIN_SUPPORT)||"";const f=new Set,m=new Set;if(a&&(c+=`\t${e}MainUv(UV);\n`,n.uvTransformation=!0),null!==i&&/mainSupport/.test(i)){const t=/mainSupport *\([\w\s]*?uv\s*?\)/.test(i);p+=`\t${e}MainSupport(`,p+=t?"vUv);\n":");\n";for(const e of i.matchAll(/(?:varying\s+\w+\s+([\S\s]*?);)/g))for(const t of e[1].split(/\s*,\s*/))n.varyings.add(t),f.add(t),m.add(t);for(const e of i.matchAll(o))m.add(e[1])}for(const e of r.matchAll(o))m.add(e[1]);for(const e of t.defines.keys())m.add(e.replace(/\([\w\s,]*\)/g,""));for(const e of t.uniforms.keys())m.add(e);m.delete("while"),m.delete("for"),m.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)));const g=new Map([["fragment",r],["vertex",i]]);BS(e,m,n.defines),BS(e,m,g),r=g.get("fragment"),i=g.get("vertex");const v=t.blendMode;if(n.blendModes.set(v.blendFunction,v),s){null!==t.inputColorSpace&&t.inputColorSpace!==n.colorSpace&&(h+=t.inputColorSpace===en?"color0 = sRGBTransferOETF(color0);\n\t":"color0 = sRGBToLinear(color0);\n\t"),t.outputColorSpace!==$t?n.colorSpace=t.outputColorSpace:null!==t.inputColorSpace&&(n.colorSpace=t.inputColorSpace);const i=/MainImage *\([\w\s,]*?depth[\w\s,]*?\)/;h+=`${e}MainImage(color0, UV, `,0!==(n.attributes&$b.DEPTH)&&i.test(r)&&(h+="depth, ",n.readDepth=!0),h+="color1);\n\t";const s=e+"BlendOpacity";n.uniforms.set(s,v.opacity),h+=`color0 = blend${v.blendFunction}(color0, color1, ${s});\n\n\t`,u+=`uniform float ${s};\n\n`}if(u+=r+"\n",null!==i&&(d+=i+"\n"),l.set(eS.FRAGMENT_HEAD,u),l.set(eS.FRAGMENT_MAIN_UV,c),l.set(eS.FRAGMENT_MAIN_IMAGE,h),l.set(eS.VERTEX_HEAD,d),l.set(eS.VERTEX_MAIN_SUPPORT,p),null!==t.extensions)for(const e of t.extensions)n.extensions.add(e)}}var DS=class extends Wb{constructor(e){super("EffectPass"),this.fullscreenMaterial=new PS(null,null,null,e),this.listener=e=>this.handleEvent(e),this.effects=[];for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];this.setEffects(n),this.skipRendering=!1,this.minTime=1,this.maxTime=Number.POSITIVE_INFINITY,this.timeScale=1}set mainScene(e){for(const t of this.effects)t.mainScene=e}set mainCamera(e){this.fullscreenMaterial.copyCameraSettings(e);for(const 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){const t=this.fullscreenMaterial;t.dithering=e,t.needsUpdate=!0}setEffects(e){for(const t of this.effects)t.removeEventListener("change",this.listener);this.effects=e.sort(((e,t)=>t.attributes-e.attributes));for(const t of this.effects)t.addEventListener("change",this.listener)}updateMaterial(){const e=new tS;let t=0;for(const a of this.effects)if(a.blendMode.blendFunction===oS.DST)e.attributes|=a.getAttributes()&$b.DEPTH;else{if(0!==(e.attributes&a.getAttributes()&$b.CONVOLUTION))throw new Error(`Convolution effects cannot be merged (${a.name})`);LS("e"+t++,a,e)}let n=e.shaderParts.get(eS.FRAGMENT_HEAD),r=e.shaderParts.get(eS.FRAGMENT_MAIN_IMAGE),i=e.shaderParts.get(eS.FRAGMENT_MAIN_UV);const s=/\bblend\b/g;for(const a of e.blendModes.values())n+=a.getShaderCode().replace(s,`blend${a.blendFunction}`)+"\n";0!==(e.attributes&$b.DEPTH)?(e.readDepth&&(r="float depth = readDepth(UV);\n\n\t"+r),this.needsDepthTexture=null===this.getDepthTexture()):this.needsDepthTexture=!1,e.colorSpace===en&&(r+="color0 = sRGBToLinear(color0);\n\t"),e.uvTransformation?(i="vec2 transformedUv = vUv;\n"+i,e.defines.set("UV","transformedUv")):e.defines.set("UV","vUv"),e.shaderParts.set(eS.FRAGMENT_HEAD,n),e.shaderParts.set(eS.FRAGMENT_MAIN_IMAGE,r),e.shaderParts.set(eS.FRAGMENT_MAIN_UV,i);for(const[a,o]of e.shaderParts)null!==o&&e.shaderParts.set(a,o.trim().replace(/^#/,"\n#"));this.skipRendering=0===t,this.needsSwap=!this.skipRendering,this.fullscreenMaterial.setShaderData(e)}recompile(){this.updateMaterial()}getDepthTexture(){return this.fullscreenMaterial.depthBuffer}setDepthTexture(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Jt;this.fullscreenMaterial.depthBuffer=e,this.fullscreenMaterial.depthPacking=t;for(const n of this.effects)n.setDepthTexture(e,t)}render(e,t,n,r,i){for(const s of this.effects)s.update(e,t,r);if(!this.skipRendering||this.renderToScreen){const 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(const n of this.effects)n.setSize(e,t)}initialize(e,t,n){this.renderer=e;for(const r of this.effects)r.initialize(e,t,n);this.updateMaterial(),void 0!==n&&n!==Pe&&(this.fullscreenMaterial.defines.FRAMEBUFFER_PRECISION_HIGH="1")}dispose(){super.dispose();for(const e of this.effects)e.removeEventListener("change",this.listener),e.dispose()}handleEvent(e){if("change"===e.type)this.recompile()}},US=class extends Wb{constructor(e,t){let{renderTarget:n,resolutionScale:r=1,width:i=sS.AUTO_SIZE,height:s=sS.AUTO_SIZE,resolutionX:a=i,resolutionY:o=s}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};super("NormalPass"),this.needsSwap=!1,this.renderPass=new wS(e,t,new Td);const l=this.renderPass;l.ignoreBackground=!0,l.skipShadowMapUpdate=!0;const u=l.getClearPass();u.overrideClearColor=new ts(7829503),u.overrideClearAlpha=1,this.renderTarget=n,void 0===this.renderTarget&&(this.renderTarget=new Pr(1,1,{minFilter:xe,magFilter:xe}),this.renderTarget.texture.name="NormalPass.Target");const c=this.resolution=new sS(this,a,o,r);c.addEventListener("change",(e=>this.setSize(c.baseWidth,c.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){const s=this.renderToScreen?null:this.renderTarget;this.renderPass.render(e,s,s)}setSize(e,t){const n=this.resolution;n.setBaseSize(e,t),this.renderTarget.setSize(n.width,n.height)}};new Float32Array(3),new Float32Array(3),new Float32Array(3),new Float32Array(3),new Float32Array(3),new Float32Array(3),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(2),new Float32Array(2),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]);FS(0,0,0,0),new Float32Array([0,0,0,0]),FS(0,0,0,1),new Float32Array([0,0,0,1]),FS(0,0,1,0),new Float32Array([0,0,1,0]),FS(0,0,1,1),new Float32Array([0,0,1,1]),FS(0,1,0,0),new Float32Array([0,1,0,0]),FS(0,1,0,1),new Float32Array([0,1,0,1]),FS(0,1,1,0),new Float32Array([0,1,1,0]),FS(0,1,1,1),new Float32Array([0,1,1,1]),FS(1,0,0,0),new Float32Array([1,0,0,0]),FS(1,0,0,1),new Float32Array([1,0,0,1]),FS(1,0,1,0),new Float32Array([1,0,1,0]),FS(1,0,1,1),new Float32Array([1,0,1,1]),FS(1,1,0,0),new Float32Array([1,1,0,0]),FS(1,1,0,1),new Float32Array([1,1,0,1]),FS(1,1,1,0),new Float32Array([1,1,1,0]),FS(1,1,1,1),new Float32Array([1,1,1,1]);function NS(e,t,n){return e+(t-e)*n}function FS(e,t,n,r){const i=NS(e,t,.75),s=NS(n,r,.75);return NS(i,s,.875)}let OS;function kS(){var e;if(void 0!==OS)return OS;try{let t;const n=document.createElement("canvas");return OS=!(!window.WebGL2RenderingContext||!(t=n.getContext("webgl2"))),t&&(null==(e=t.getExtension("WEBGL_lose_context"))||e.loseContext()),OS}catch(t){return OS=!1}}const HS=(0,t.createContext)(null),zS=e=>(e.getAttributes()&$b.CONVOLUTION)===$b.CONVOLUTION,GS=t.memo((0,t.forwardRef)(((e,n)=>{let{children:r,camera:i,scene:s,resolutionScale:a,enabled:o=!0,renderPriority:l=1,autoClear:u=!0,depthBuffer:c,enableNormalPass:h,stencilBuffer:d,multisampling:p=8,frameBufferType:f=Fe}=e;const{gl:m,scene:g,camera:v,size:y}=bv(),_=s||g,x=i||v,[A,M,b]=(0,t.useMemo)((()=>{const e=kS(),t=new Zb(m,{depthBuffer:c,stencilBuffer:d,multisampling:p>0&&e?p:0,frameBufferType:f});t.addPass(new wS(_,x));let n=null,r=null;return h&&(r=new US(_,x),r.enabled=!1,t.addPass(r),void 0!==a&&e&&(n=new RS({normalBuffer:r.texture,resolutionScale:a}),n.enabled=!1,t.addPass(n))),[t,r,n]}),[x,m,c,d,p,f,_,h,a]);(0,t.useEffect)((()=>null==A?void 0:A.setSize(y.width,y.height)),[A,y]),Sv(((e,t)=>{if(o){const e=m.autoClear;m.autoClear=u,d&&!u&&m.clearStencil(),A.render(t),m.autoClear=e}}),o?l:0);const S=(0,t.useRef)(null),w=function(e){const n=t.useRef(null);return Og((()=>{n.current=e.current.__r3f}),[e]),n}(S);(0,t.useLayoutEffect)((()=>{const e=[];if(S.current&&w.current&&A){const t=w.current.objects;for(let n=0;n<t.length;n++){const r=t[n];if(r instanceof _S){const i=[r];if(!zS(r)){let e=null;for(;(e=t[n+1])instanceof _S&&!zS(e);)i.push(e),n++}const s=new DS(x,...i);e.push(s)}else r instanceof Wb&&e.push(r)}for(const n of e)null==A||A.addPass(n);M&&(M.enabled=!0),b&&(b.enabled=!0)}return()=>{for(const t of e)null==A||A.removePass(t);M&&(M.enabled=!1),b&&(b.enabled=!1)}}),[A,r,x,M,b,w]),(0,t.useEffect)((()=>{const e=m.toneMapping;return m.toneMapping=te,()=>{m.toneMapping=e}}),[]);const E=(0,t.useMemo)((()=>({composer:A,normalPass:M,downSamplingPass:b,resolutionScale:a,camera:x,scene:_})),[A,M,b,a,x,_]);return(0,t.useImperativeHandle)(n,(()=>A),[A]),(0,Ig.jsx)(HS.Provider,{value:E,children:(0,Ig.jsx)("group",{ref:S,children:r})})}))),VS=(0,t.createContext)(null);const WS=e=>"object"===typeof e&&null!=e&&"current"in e?e.current:e;const jS=(0,t.forwardRef)((function(e,n){let{selection:r=[],selectionLayer:i=10,lights:s=[],luminanceThreshold:a,luminanceSmoothing:o,intensity:l,width:u,height:c,kernelSize:h,mipmapBlur:d,...p}=e;0===s.length&&console.warn("SelectiveBloom requires lights to work.");const f=bv((e=>e.invalidate)),{scene:m,camera:g}=(0,t.useContext)(HS),v=(0,t.useMemo)((()=>new TS(m,g,{blendFunction:oS.ADD,luminanceThreshold:a,luminanceSmoothing:o,intensity:l,width:u,height:c,kernelSize:h,mipmapBlur:d,...p})),[m,g,a,o,l,u,c,h,d,p]),y=(0,t.useContext)(VS);return(0,t.useEffect)((()=>{if(!y&&r)return v.selection.set(Array.isArray(r)?r.map(WS):[WS(r)]),f(),()=>{v.selection.clear(),f()}}),[v,r,y,f]),(0,t.useEffect)((()=>{v.selection.layer=i,f()}),[v,f,i]),(0,t.useEffect)((()=>{if(s&&s.length>0)return s.forEach((e=>((e,t)=>e.layers.enable(t.selection.layer))(WS(e),v))),f(),()=>{s.forEach((e=>((e,t)=>e.layers.disable(t.selection.layer))(WS(e),v))),f()}}),[v,f,s,i]),(0,t.useEffect)((()=>{var e;if(y&&y.enabled&&(null==(e=y.selected)?void 0:e.length))return v.selection.set(y.selected),f(),()=>{v.selection.clear(),f()}}),[y,v.selection,f]),(0,Ig.jsx)("primitive",{ref:n,object:v,dispose:null})})),XS=e=>{let{url:n="./models/ai.vrm",url_anim:r="./models/default.vrma",position:i=[0,0,0],scale:s=1,rotation:a=[0,1.5,0]}=e;const[o,l]=(0,t.useState)(null),u=(0,t.useRef)(null),c=(0,t.useRef)(null);return(0,t.useEffect)((()=>{const e=new Ly;e.register((e=>new QM(e))),e.register((e=>new kb(e))),e.load(n,(t=>{var n;const o=t.userData.vrm;eb.removeUnnecessaryJoints(o.scene),c.current=o.springBoneManager,null===(n=c.current)||void 0===n||n.reset(),l(o),o&&(o.scene.rotation.set(...a),o.scene.position.set(...i),o.scene.scale.setScalar(s));const h=new vf(o.scene);u.current=h,e.load(r,(e=>{const t=e.userData.vrmAnimations;if(t&&t.length>0){const e=Rb(t[0],o);h.clipAction(e).play()}}))}))}),[n,r,i,s,a]),Sv(((e,t)=>{u.current&&u.current.update(t),c.current&&c.current.update(t),o&&o.update(t)})),o?(0,Ig.jsx)("primitive",{object:o.scene}):null},JS=e=>{let{url:t="./models/solar_system.glb",position:n=[0,0,0],scale:r=1,rotation:i=[0,0,0]}=e;const{scene:s}=zv(t);return s.scale.setScalar(r),s.position.set(...n),(0,Ig.jsx)("primitive",{object:s})};function YS(e){var n;const r=(0,t.useRef)(null),i=(0,t.useRef)(null),s=new URLSearchParams(window.location.search);var a=null!==(n=s.get("g"))&&void 0!==n?n:"galaxy";const o=s.get("ms"),l=o?parseInt(o,10):1;var u="./models/ai.vrm",c=.01,h=[-.2,-.8,-.3],d=new pd(1,332,332),p="./models/emote.vrma";const{nodes:f}=zv("./models/galaxy.glb");var m=100;f.Object_2.geometry.center(),"sun"===a?(d=new pd(1,332,332),f.Object_2.geometry=d,c=1):"moon"===a?(d=new pd(1,132,132),f.Object_2.geometry=d,m=1,c=.01,h=[-.5,-1,0],p="./models/fly.vrma",u="./models/ai_default.vrm"):"earth"===a?(d=new pd(1,232,232),f.Object_2.geometry=d,m=.5,c=.3,h=[-1,-1,0],p="./models/fly.vrma",u="./models/ai_default.vrm"):"neutron"===a&&(m=1);const[g,v]=(0,t.useMemo)((()=>{const e=new Float32Array(f.Object_2.geometry.attributes.position.array.buffer),t=new Float32Array(e.length),n=(e,t,n)=>Math.sqrt(e*e+t*t+n*n),r=new ts;for(let i=0;i<e.length;i+=3){const s=n(e[i],e[i+1],e[i+1]),a=s/m;r.setHSL(.15*(.21+Math.cos(.02*s))/2,.75,.6),r.setRGB(Math.cos(a),rr.randFloat(0,.8),Math.sin(a)),r.toArray(t,i)}return[e,t]}),[f,m]);return Sv((e=>{let{clock:t}=e;r.current.rotation.y=t.getElapsedTime()/2,r.current.scale.setScalar(Math.sin(t.getElapsedTime()/2)+1.2)})),(0,Ig.jsxs)("group",{...e,dispose:null,ref:r,children:[(0,Ig.jsx)(XS,{url:u,url_anim:p,position:h,scale:l,rotation:[0,1.5,0]}),"sun"===a&&(0,Ig.jsx)(JS,{url:"./models/solar-system.glb",scale:10}),"galaxy"===a&&(0,Ig.jsx)(JS,{url:"./models/solar-system.glb",scale:.5,position:[0,.5,2]}),(0,Ig.jsx)("pointLight",{position:[0,0,0],ref:i,intensity:.2}),(0,Ig.jsx)(qv,{scale:c,positions:g,colors:v,rotation:[1.5,0,0],children:(0,Ig.jsx)("pointsMaterial",{transparent:!0,depthWrite:!1,vertexColors:!0,opacity:.4,depthTest:!0,size:.01})}),(0,Ig.jsx)(GS,{autoClear:!1,children:(0,Ig.jsx)(jS,{intensity:5,luminanceThreshold:.01,luminanceSmoothing:.225,lights:[i]})}),(0,Ig.jsx)("ambientLight",{intensity:1})]})}const KS=()=>(0,Ig.jsxs)(Iy,{shadows:!0,gl:{toneMapping:le,toneMappingExposure:1.1,alpha:!0,powerPreference:"high-performance",antialias:!0},camera:{position:[1,1,1]},children:[(0,Ig.jsx)("directionalLight",{color:"white",castShadow:!0,position:[0,10,0],intensity:.4,"shadow-mapSize":[1024,1024]}),(0,Ig.jsx)(iy,{minDistance:2,maxDistance:3,enableZoom:!0,enablePan:!1,enableRotate:!0,zoomSpeed:.5,panSpeed:.5,rotateSpeed:.5}),(0,Ig.jsx)("ambientLight",{intensity:1}),(0,Ig.jsx)("pointLight",{position:[10,10,10]}),(0,Ig.jsx)(YS,{position:[0,0,0]})]}),qS=()=>(0,Ig.jsx)(KS,{}),QS=e=>{e&&e instanceof Function&&n.e(206).then(n.bind(n,206)).then((t=>{let{getCLS:n,getFID:r,getFCP:i,getLCP:s,getTTFB:a}=t;n(e),r(e),i(e),s(e),a(e)}))};r.createRoot(document.getElementById("root")).render((0,Ig.jsx)(t.StrictMode,{children:(0,Ig.jsx)(qS,{})})),QS()})()})();